From 5f3b98c695f2df026a8f3abd533f6fb623625b68 Mon Sep 17 00:00:00 2001 From: banteg Date: Wed, 15 Sep 2021 16:22:01 +0300 Subject: [PATCH] feat: support lowercase addresses --- ape_safe.py | 7 +++++-- pyproject.toml | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ape_safe.py b/ape_safe.py index 606ac4c..9606f0e 100644 --- a/ape_safe.py +++ b/ape_safe.py @@ -9,6 +9,7 @@ from brownie.network.account import LocalAccount from brownie.network.transaction import TransactionReceipt from eth_abi import encode_abi +from eth_utils import is_address, to_checksum_address from gnosis.eth import EthereumClient from gnosis.safe import Safe, SafeOperation from gnosis.safe.multi_send import MultiSend, MultiSendOperation, MultiSendTx @@ -47,8 +48,7 @@ def __init__(self, address, base_url=None, multisend=None): """ Create an ApeSafe from an address or a ENS name and use a default connection. """ - if not web3.isChecksumAddress(address): - address = web3.ens.resolve(address) + address = to_checksum_address(address) if is_address(address) else web3.ens.resolve(address) ethereum_client = EthereumClient(web3.provider.endpoint_uri) self.base_url = base_url or transaction_service[chain.id] self.multisend = multisend or multisends.get(chain.id, MULTISEND_CALL_ONLY) @@ -57,6 +57,9 @@ def __init__(self, address, base_url=None, multisend=None): def __str__(self): return EthAddress(self.address) + def __repr__(self): + return f'ApeSafe("{self.address}")' + @property def account(self) -> LocalAccount: """ diff --git a/pyproject.toml b/pyproject.toml index 34a07fc..d0a8dab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "ape-safe" -version = "0.2.1" +version = "0.2.2" description = "Build complex Gnosis Safe transactions and safely preview them in a forked environment." authors = ["banteg "] license = "MIT"