From 38f51fe6699938d9d734aeefd359f68b719b8418 Mon Sep 17 00:00:00 2001 From: Ben Smith Date: Thu, 10 Aug 2023 10:26:43 +0200 Subject: [PATCH] cleaning up and updating packages --- mypy.ini | 2 +- requirements.txt | 21 +++++++++++---------- src/airdrop/allocation.py | 2 +- src/airdrop/tx.py | 2 +- src/dune.py | 8 ++++---- src/exec.py | 2 +- src/safe.py | 10 ++++++---- src/snapshot/delegate_registry.py | 2 +- src/snapshot/tx.py | 2 +- src/token_transfer.py | 4 ++-- tests/unit/test_delegation.py | 1 - tests/unit/test_redeem.py | 1 - 12 files changed, 29 insertions(+), 28 deletions(-) diff --git a/mypy.ini b/mypy.ini index 41ca336..8138a08 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,3 +1,3 @@ [mypy] -python_version = 3.10 +python_version = 3.11 ignore_missing_imports = True diff --git a/requirements.txt b/requirements.txt index 29681c3..aae13a3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/src/airdrop/allocation.py b/src/airdrop/allocation.py index 98b500d..7a9d2d9 100644 --- a/src/airdrop/allocation.py +++ b/src/airdrop/allocation.py @@ -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"), ) diff --git a/src/airdrop/tx.py b/src/airdrop/tx.py index 7bdf94e..8e83088 100644 --- a/src/airdrop/tx.py +++ b/src/airdrop/tx.py @@ -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) diff --git a/src/dune.py b/src/dune.py index 3086e1e..0a73302 100644 --- a/src/dune.py +++ b/src/dune.py @@ -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 @@ -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=[ @@ -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] diff --git a/src/exec.py b/src/exec.py index 72ab8ea..baae3b3 100644 --- a/src/exec.py +++ b/src/exec.py @@ -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, ), ) diff --git a/src/safe.py b/src/safe.py index a5aa3e5..6d90b92 100644 --- a/src/safe.py +++ b/src/safe.py @@ -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 @@ -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 @@ -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 diff --git a/src/snapshot/delegate_registry.py b/src/snapshot/delegate_registry.py index b5dc408..52a61d4 100644 --- a/src/snapshot/delegate_registry.py +++ b/src/snapshot/delegate_registry.py @@ -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"), ) diff --git a/src/snapshot/tx.py b/src/snapshot/tx.py index 7bb2b92..a6291bc 100644 --- a/src/snapshot/tx.py +++ b/src/snapshot/tx.py @@ -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: diff --git a/src/token_transfer.py b/src/token_transfer.py index d51c82a..eb89623 100644 --- a/src/token_transfer.py +++ b/src/token_transfer.py @@ -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) @@ -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"]), ) diff --git a/tests/unit/test_delegation.py b/tests/unit/test_delegation.py index 16ec8c8..d884594 100644 --- a/tests/unit/test_delegation.py +++ b/tests/unit/test_delegation.py @@ -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) diff --git a/tests/unit/test_redeem.py b/tests/unit/test_redeem.py index 9d0e5a2..75fe2af 100644 --- a/tests/unit/test_redeem.py +++ b/tests/unit/test_redeem.py @@ -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"), [