Ejemplo n.º 1
0
    def deploy_contract(ethereum_client: EthereumClient,
                        deployer_account: LocalAccount) -> EthereumTxSent:
        """
        Deploy proxy factory contract

        :param ethereum_client:
        :param deployer_account: Ethereum Account
        :return: deployed contract address
        """
        contract = get_multi_send_contract(ethereum_client.w3)
        tx = contract.constructor().buildTransaction(
            {"from": deployer_account.address})

        tx_hash = ethereum_client.send_unsigned_transaction(
            tx, private_key=deployer_account.key)
        tx_receipt = ethereum_client.get_transaction_receipt(tx_hash,
                                                             timeout=120)
        assert tx_receipt
        assert tx_receipt["status"]
        contract_address = tx_receipt["contractAddress"]
        logger.info(
            "Deployed and initialized Proxy Factory Contract=%s by %s",
            contract_address,
            deployer_account.address,
        )
        return EthereumTxSent(tx_hash, tx, contract_address)
Ejemplo n.º 2
0
    def setUpTestData(cls):
        super().setUpTestData()

        for key, value in contract_addresses.items():
            if callable(value):
                contract_addresses[key] = value(cls.ethereum_client, cls.ethereum_test_account).contract_address

        settings.SAFE_CONTRACT_ADDRESS = contract_addresses['safe']
        settings.SAFE_MULTISEND_ADDRESS = contract_addresses['multi_send']
        settings.SAFE_V1_0_0_CONTRACT_ADDRESS = contract_addresses['safe_V1_0_0']
        settings.SAFE_V0_0_1_CONTRACT_ADDRESS = contract_addresses['safe_V0_0_1']
        settings.SAFE_PROXY_FACTORY_ADDRESS = contract_addresses['proxy_factory']
        settings.SAFE_PROXY_FACTORY_V1_0_0_ADDRESS = contract_addresses['proxy_factory_V1_0_0']
        settings.SAFE_VALID_CONTRACT_ADDRESSES = {settings.SAFE_CONTRACT_ADDRESS,
                                                  settings.SAFE_V1_0_0_CONTRACT_ADDRESS,
                                                  settings.SAFE_V0_0_1_CONTRACT_ADDRESS,
                                                  }
        cls.safe_contract_address = contract_addresses['safe']
        cls.safe_contract = get_safe_contract(cls.w3, cls.safe_contract_address)
        cls.safe_contract_V1_0_0_address = contract_addresses['safe_V1_0_0']
        cls.safe_contract_V1_0_0 = get_safe_V1_0_0_contract(cls.w3, cls.safe_contract_V1_0_0_address)
        cls.safe_contract_V0_0_1_address = contract_addresses['safe_V0_0_1']
        cls.safe_contract_V0_0_1 = get_safe_V1_0_0_contract(cls.w3, cls.safe_contract_V0_0_1_address)
        cls.proxy_factory_contract_address = contract_addresses['proxy_factory']
        cls.proxy_factory_contract = get_proxy_factory_contract(cls.w3, cls.proxy_factory_contract_address)
        cls.proxy_factory = ProxyFactory(cls.proxy_factory_contract_address, cls.ethereum_client)
        cls.multi_send_contract = get_multi_send_contract(cls.w3, contract_addresses['multi_send'])
        cls.multi_send = MultiSend(cls.multi_send_contract.address, cls.ethereum_client)
Ejemplo n.º 3
0
    def __init__(self):
        super().__init__()

        compound_contracts = [
            self.dummy_w3.eth.contract(abi=ctoken_abi)
            #                      self.dummy_w3.eth.contract(abi=comptroller_abi)]
        ]

        exchanges = [
            get_uniswap_exchange_contract(self.dummy_w3),
            get_kyber_network_proxy_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)
        ]

        self.multisend_contracts = [get_multi_send_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 = (compound_contracts + exchanges +
                                    sight_contracts + erc_contracts +
                                    self.multisend_contracts +
                                    self.supported_contracts)
Ejemplo n.º 4
0
    def __init__(self):
        super().__init__()

        compound_contracts = [
            self.dummy_w3.eth.contract(abi=ctoken_abi),
            self.dummy_w3.eth.contract(abi=comptroller_abi),
        ]

        aave_abis = [aave_a_token, aave_lending_pool, aave_lending_pool_addresses_provider, aave_lending_pool_core]
        aave_contracts = [self.dummy_w3.eth.contract(abi=abi) for abi in aave_abis]
        idle_abis = [idle_token_v3]
        idle_contracts = [self.dummy_w3.eth.contract(abi=abi) for abi in idle_abis]
        request_abis = [request_erc20_proxy, request_ethereum_proxy]
        request_contracts = [self.dummy_w3.eth.contract(abi=abi) for abi in request_abis]
        sablier_abis = [sablier_ctoken_manager, sablier_payroll, sablier_abi]
        sablier_contracts = [self.dummy_w3.eth.contract(abi=abi) for abi in sablier_abis]

        exchanges = [get_uniswap_exchange_contract(self.dummy_w3),
                     get_kyber_network_proxy_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)]

        self.multisend_contracts = [get_multi_send_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 = (aave_contracts + idle_contracts + request_contracts + sablier_contracts
                                    + compound_contracts + exchanges + sight_contracts + erc_contracts
                                    + self.multisend_contracts + self.supported_contracts)
Ejemplo n.º 5
0
    def setUpClass(cls):
        super().setUpClass()

        for key, value in _contract_addresses.items():
            if callable(value):
                _contract_addresses[key] = value(
                    cls.ethereum_client,
                    cls.ethereum_test_account).contract_address

        settings.SAFE_DEFAULT_CALLBACK_HANDLER = _contract_addresses[
            "compatibility_fallback_handler"]
        settings.SAFE_MULTISEND_ADDRESS = _contract_addresses["multi_send"]
        settings.SAFE_CONTRACT_ADDRESS = _contract_addresses["safe_v1_3_0"]
        settings.SAFE_V1_1_1_CONTRACT_ADDRESS = _contract_addresses[
            "safe_V1_1_1"]
        settings.SAFE_V1_0_0_CONTRACT_ADDRESS = _contract_addresses[
            "safe_V1_0_0"]
        settings.SAFE_V0_0_1_CONTRACT_ADDRESS = _contract_addresses[
            "safe_V0_0_1"]
        settings.SAFE_PROXY_FACTORY_ADDRESS = _contract_addresses[
            "proxy_factory"]
        settings.SAFE_PROXY_FACTORY_V1_0_0_ADDRESS = _contract_addresses[
            "proxy_factory_V1_0_0"]
        settings.SAFE_VALID_CONTRACT_ADDRESSES = {
            settings.SAFE_CONTRACT_ADDRESS,
            settings.SAFE_V1_1_1_CONTRACT_ADDRESS,
            settings.SAFE_V1_0_0_CONTRACT_ADDRESS,
            settings.SAFE_V0_0_1_CONTRACT_ADDRESS,
        }
        cls.compatibility_fallback_handler = (
            get_compatibility_fallback_handler_V1_3_0_contract(
                cls.w3, _contract_addresses["compatibility_fallback_handler"]))
        cls.safe_contract_address = _contract_addresses["safe_v1_3_0"]
        cls.safe_contract = get_safe_V1_3_0_contract(cls.w3,
                                                     cls.safe_contract_address)
        cls.safe_contract_V1_1_1_address = _contract_addresses["safe_V1_1_1"]
        cls.safe_contract_V1_1_1 = get_safe_V1_1_1_contract(
            cls.w3, cls.safe_contract_V1_1_1_address)
        cls.safe_contract_V1_0_0_address = _contract_addresses["safe_V1_0_0"]
        cls.safe_contract_V1_0_0 = get_safe_V1_0_0_contract(
            cls.w3, cls.safe_contract_V1_0_0_address)
        cls.safe_contract_V0_0_1_address = _contract_addresses["safe_V0_0_1"]
        cls.safe_contract_V0_0_1 = get_safe_V1_0_0_contract(
            cls.w3, cls.safe_contract_V0_0_1_address)
        cls.proxy_factory_contract_address = _contract_addresses[
            "proxy_factory"]
        cls.proxy_factory_contract = get_proxy_factory_contract(
            cls.w3, cls.proxy_factory_contract_address)
        cls.proxy_factory = ProxyFactory(cls.proxy_factory_contract_address,
                                         cls.ethereum_client)
        cls.multi_send_contract = get_multi_send_contract(
            cls.w3, _contract_addresses["multi_send"])
        cls.multi_send = MultiSend(cls.multi_send_contract.address,
                                   cls.ethereum_client)
Ejemplo n.º 6
0
 def from_transaction_data(
         cls, multisend_data: Union[str, bytes]) -> List[MultiSendTx]:
     """
     Decodes multisend transactions from transaction data (ABI encoded with selector)
     :return:
     """
     try:
         _, data = get_multi_send_contract(
             Web3()).decode_function_input(multisend_data)
         return cls.from_bytes(data['transactions'])
     except ValueError:
         return []
Ejemplo n.º 7
0
 def multisend_abis(self) -> List[ABIFunction]:
     return [get_multi_send_contract(self.dummy_w3).abi]
Ejemplo n.º 8
0
 def get_contract(self):
     return get_multi_send_contract(self.ethereum_client.w3, self.address)
 def _get_multisend_abis(self):
     return [get_multi_send_contract(self.dummy_w3).abi]
Ejemplo n.º 10
0
 def __init__(self):
     self.multisend_contracts: List[Type[Contract]] = [
         get_multi_send_contract(self.dummy_w3)
     ]
     super().__init__()