-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor proxyFactory and safe (#597)
* Add ContractCommon class * Refactor proxy factory * Refactor Safe class * Apply suggestions from code review Co-authored-by: Uxío <[email protected]> * Remove gas increment * Add get_proxy_factory_fn * Move contract_common to contracts * Revert deploy_contract_with_deploy_function * Fix SafeCreate2TxBuilder * Refactor ProxyFactory * Test every check_proxy_code in a subTest * Refactor Safe.py * Add version property to every Safe class * Remove Creation V1. It was used on the Safe Relay when CREATE2 did not exist * Remove deploy from ContractCommon, use EthereumClient deployandinitialize * Refactor retrieve_all_info * Fix Safe retrieve modules * Move abis to abis folder * Rename `deploy_safe_master_copy` and `deploy_proxy_factory_contract` to `deploy_contract` * Improve docs and add typing for contract methods * Update types and docs --------- Co-authored-by: Uxío <[email protected]>
- Loading branch information
Showing
43 changed files
with
1,039 additions
and
1,871 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from abc import ABCMeta, abstractmethod | ||
from functools import cached_property | ||
from logging import getLogger | ||
from typing import Callable, Optional | ||
|
||
from eth_typing import ChecksumAddress | ||
from web3 import Web3 | ||
from web3.contract import Contract | ||
|
||
logger = getLogger(__name__) | ||
|
||
|
||
class ContractBase(metaclass=ABCMeta): | ||
def __init__( | ||
self, address: ChecksumAddress, ethereum_client: "EthereumClient" # noqa F821 | ||
): | ||
self.address = address | ||
self.ethereum_client = ethereum_client | ||
self.w3 = ethereum_client.w3 | ||
|
||
@abstractmethod | ||
def get_contract_fn(self) -> Callable[[Web3, Optional[ChecksumAddress]], Contract]: | ||
""" | ||
:return: Contract function to get the proper contract | ||
""" | ||
raise NotImplementedError | ||
|
||
@cached_property | ||
def contract(self) -> Contract: | ||
return self.get_contract_fn()(self.ethereum_client.w3, self.address) |
Oops, something went wrong.