Skip to content

Commit

Permalink
cleaning up and updating packages
Browse files Browse the repository at this point in the history
  • Loading branch information
bh2smith committed Aug 10, 2023
1 parent c395928 commit 38f51fe
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 28 deletions.
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[mypy]
python_version = 3.10
python_version = 3.11
ignore_missing_imports = True
21 changes: 11 additions & 10 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
black==22.10.0
dune-client==0.0.7
dune-client==1.2.1
python-dotenv==1.0.0
requests==2.31.0
safe-cli==0.7.0
safe-eth-py==5.7.0
web3==6.8.0

types-requests==2.31.0.2
pytest==7.4.0
pylint==2.17.5
mypy==0.982
pylint==2.15.5
python-dotenv==0.21.0
pytest==7.2.0
requests==2.28.1
safe-cli==0.5.2
safe-eth-py==4.5.2
types-requests==2.28.11.2
web3==5.31.1
black==23.7.0
2 changes: 1 addition & 1 deletion src/airdrop/allocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from src.environment import CLIENT

AIRDROP_CONTRACT = CLIENT.w3.eth.contract(
address=Web3().toChecksumAddress("0xA0b937D5c8E32a80E3a8ed4227CD020221544ee6"),
address=Web3().to_checksum_address("0xA0b937D5c8E32a80E3a8ed4227CD020221544ee6"),
abi=load_contract_abi("airdrop"),
)

Expand Down
2 changes: 1 addition & 1 deletion src/airdrop/tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def transactions_for(
parent: Safe, children: list[Safe], command: AirdropCommand
) -> list[MultiSendTx]:
"""Builds transaction for given Airdrop command"""
allocations: dict[Safe, list[Allocation]] = {}
allocations: dict[Safe, list[Allocation]] = {child: [] for child in children}
for child in children:
try:
allocations[child] += Allocation.from_address(child.address)
Expand Down
8 changes: 4 additions & 4 deletions src/dune.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from dotenv import load_dotenv
from dune_client.client import DuneClient
from dune_client.query import Query
from dune_client.query import QueryBase
from dune_client.types import QueryParameter
from eth_typing.evm import ChecksumAddress
from web3 import Web3
Expand All @@ -16,7 +16,7 @@ def fetch_child_safes(
load_dotenv()
dune = DuneClient(os.environ["DUNE_API_KEY"])
results = dune.refresh(
query=Query(
query=QueryBase(
name="Safe Families",
query_id=1416166,
params=[
Expand All @@ -26,9 +26,9 @@ def fetch_child_safes(
QueryParameter.number_type("IndexTo", index_to),
],
)
)
).get_rows()
if len(results) == 0:
raise ValueError(f"No results returned for parent {parent}")

print(f"got fleet of size {len(results)}")
return [Web3().toChecksumAddress(row["bracket"]) for row in results]
return [Web3().to_checksum_address(row["bracket"]) for row in results]
2 changes: 1 addition & 1 deletion src/exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def as_snapshot_command(self) -> SnapshotCommand:
safe=parent,
sub_safe=child,
params=AddOwnerArgs(
new_owner=Web3.toChecksumAddress(args.new_owner),
new_owner=Web3.to_checksum_address(args.new_owner),
threshold=args.threshold,
),
)
Expand Down
10 changes: 6 additions & 4 deletions src/safe.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from gnosis.safe.api import TransactionServiceApi
from gnosis.safe.multi_send import MultiSendTx
from web3 import Web3
from web3.contract import Contract
from web3.contract import Contract # type:ignore

from src.constants import ZERO_ADDRESS
from src.dune import fetch_child_safes
Expand All @@ -30,7 +30,7 @@ def get_safe(address: str, client: EthereumClient) -> Safe:
Fetches safe object at address
Safe must exist on the `client.get_network()`
"""
return Safe(address=Web3.toChecksumAddress(address), ethereum_client=client)
return Safe(address=Web3.to_checksum_address(address), ethereum_client=client)


@dataclass
Expand Down Expand Up @@ -130,9 +130,11 @@ def from_args(cls, parser: Optional[argparse.ArgumentParser] = None) -> SafeFami
)

args, _ = parser.parse_known_args()
parent = Web3().toChecksumAddress(args.parent)
parent = Web3().to_checksum_address(args.parent)
if args.sub_safes is not None:
children = [Web3().toChecksumAddress(c) for c in args.sub_safes.split(",")]
children = [
Web3().to_checksum_address(c) for c in args.sub_safes.split(",")
]
else:
start = args.index_from
length = args.num_safes
Expand Down
2 changes: 1 addition & 1 deletion src/snapshot/delegate_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from src.environment import CLIENT

DELEGATION_CONTRACT = CLIENT.w3.eth.contract(
address=Web3().toChecksumAddress("0x469788fE6E9E9681C6ebF3bF78e7Fd26Fc015446"),
address=Web3().to_checksum_address("0x469788fE6E9E9681C6ebF3bF78e7Fd26Fc015446"),
abi=load_contract_abi("delegate_registry"),
)

Expand Down
2 changes: 1 addition & 1 deletion src/snapshot/tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def transactions_for(
delegate = input(f"Delegate Address(default={parent.address}): ")
if delegate != "":
try:
delegate = Web3().toChecksumAddress(delegate)
delegate = Web3().to_checksum_address(delegate)
except ValueError as err:
raise ValueError(f'Invalid Delegate address "{delegate}"') from err
else:
Expand Down
4 changes: 2 additions & 2 deletions src/token_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Token:

def __init__(self, address: str | ChecksumAddress, decimals: Optional[int] = None):
if isinstance(address, str):
address = Web3.toChecksumAddress(address)
address = Web3.to_checksum_address(address)
self.address = address
self.decimals = (
decimals if decimals is not None else get_token_decimals(address)
Expand Down Expand Up @@ -100,7 +100,7 @@ def from_dict(cls, obj: dict[str, str]) -> Transfer:
token_address = obj.get("token_address", None)
return cls(
token=Token(token_address) if token_address else None,
receiver=Web3.toChecksumAddress(obj["receiver"]),
receiver=Web3.to_checksum_address(obj["receiver"]),
amount_wei=int(obj["amount"]),
)

Expand Down
1 change: 0 additions & 1 deletion tests/unit/test_delegation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ def setUp(self) -> None:
self.str_value = "safe.eth"

def test_delegation_id_from_hex(self):

from_hex = DelegationId.from_hex(self.hex_value)
self.assertEqual(str(from_hex), self.str_value)
self.assertEqual(from_hex.hex, self.hex_value)
Expand Down
1 change: 0 additions & 1 deletion tests/unit/test_redeem.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def setUp(self) -> None:
self.client = EthereumClient(URI(node_url))

def test_fetch_and_parse_allocation_data(self):

self.assertEqual(
Allocation.from_address("0xa1097B957A62B75482CFB9Af960Cbd6B8F9F02e8"),
[
Expand Down

0 comments on commit 38f51fe

Please sign in to comment.