Example #1
0
    def deploy_master_contract_v0_0_1(
            ethereum_client: EthereumClient,
            deployer_account: LocalAccount) -> EthereumTxSent:
        """
        Deploy master contract. Takes deployer_account (if unlocked in the node) or the deployer private key

        :param ethereum_client:
        :param deployer_account: Ethereum account
        :return: deployed contract address
        """

        safe_contract = get_safe_V0_0_1_contract(ethereum_client.w3)
        constructor_data = safe_contract.constructor().buildTransaction(
            {"gas": 0})["data"]
        initializer_data = safe_contract.functions.setup(
            # We use 2 owners that nobody controls for the master copy
            [
                "0x0000000000000000000000000000000000000002",
                "0x0000000000000000000000000000000000000003",
            ],
            2,  # Threshold. Maximum security
            NULL_ADDRESS,  # Address for optional DELEGATE CALL
            b"",  # Data for optional DELEGATE CALL
        ).buildTransaction({"to": NULL_ADDRESS})["data"]

        ethereum_tx_sent = ethereum_client.deploy_and_initialize_contract(
            deployer_account, constructor_data, HexBytes(initializer_data))
        logger.info(
            "Deployed and initialized Old Safe Master Contract=%s by %s",
            ethereum_tx_sent.contract_address,
            deployer_account.address,
        )
        return ethereum_tx_sent
    def __init__(self):
        #TODO  Refactor this using inheritance
        self.dummy_w3 = Web3()
        exchanges = [
            get_uniswap_exchange_contract(self.dummy_w3),
            self.dummy_w3.eth.contract(abi=gnosis_protocol_abi)
        ]
        sight_contracts = [
            self.dummy_w3.eth.contract(abi=abi)
            for abi in (conditional_token_abi, market_maker_abi,
                        market_maker_factory_abi)
        ]
        erc_contracts = [
            get_erc721_contract(self.dummy_w3),
            get_erc20_contract(self.dummy_w3)
        ]
        safe_contracts = [
            get_safe_V0_0_1_contract(self.dummy_w3),
            get_safe_V1_0_0_contract(self.dummy_w3),
            get_safe_contract(self.dummy_w3)
        ]

        # Order is important. If signature is the same (e.g. renaming of `baseGas`) last elements in the list
        # will take preference
        self.supported_contracts = exchanges + sight_contracts + erc_contracts + safe_contracts

        # Web3 generates possible selectors every time. We cache that and use a dict to do a fast check
        # Store selectors with abi
        self.supported_fn_selectors: Dict[bytes, ContractFunction] = {}
        for supported_contract in self.supported_contracts:
            self.supported_fn_selectors.update(
                self._generate_selectors_with_abis_from_contract(
                    supported_contract))
Example #3
0
    def __init__(self):
        self.dummy_w3 = Web3()
        self.safe_contracts = [get_safe_V0_0_1_contract(self.dummy_w3), get_safe_V1_0_0_contract(self.dummy_w3),
                               get_safe_contract(self.dummy_w3)]

        # Order is important. If signature is the same (e.g. renaming of `baseGas`) last elements in the list
        # will take preference
        self.supported_contracts = self.safe_contracts
    def get_supported_abis(self) -> List[ABI]:
        safe_abis = [get_safe_V0_0_1_contract(self.dummy_w3).abi,
                     get_safe_V1_0_0_contract(self.dummy_w3).abi,
                     get_safe_V1_3_0_contract(self.dummy_w3).abi,
                     get_safe_contract(self.dummy_w3).abi]

        # Order is important. If signature is the same (e.g. renaming of `baseGas`) last elements in the list
        # will take preference
        return safe_abis
 def _get_initial_setup_safe_data(self, owners: List[str], threshold: int) -> bytes:
     return get_safe_V0_0_1_contract(self.w3, self.master_copy).functions.setup(
         owners,
         threshold,
         NULL_ADDRESS,  # Contract address for optional delegate call
         b''            # Data payload for optional delegate call
     ).buildTransaction({
         'gas': 1,
         'gasPrice': 1,
     })['data']
Example #6
0
    def __init__(self):
        self.dummy_w3 = Web3()
        # Order is important. If signature is the same (e.g. renaming of `baseGas`) last elements in the list
        # will take preference
        self.supported_contracts = [get_safe_V0_0_1_contract(self.dummy_w3),
                                    get_safe_V1_0_0_contract(self.dummy_w3),
                                    get_safe_contract(self.dummy_w3)]

        # Web3 generates possible selectors every time. We cache that and use a dict to do a fast check
        # Store selectors with abi
        self.supported_fn_selectors: Dict[bytes, ContractFunction] = {}
        for supported_contract in self.supported_contracts:
            self.supported_fn_selectors.update(self._generate_selectors_with_abis_from_contract(supported_contract))