def test_set_deploy_proxied_identity_transaction_params(
    web3,
    proxy_factory,
    identity_implementation,
    signature_of_owner_on_implementation,
    accounts,
):

    transaction_options = {
        "gasPrice": 1000,
        "gas": 1000000,
        "from": accounts[2]
    }

    deploy_proxied_identity(
        web3=web3,
        factory_address=proxy_factory.address,
        implementation_address=identity_implementation.address,
        signature=signature_of_owner_on_implementation,
        transaction_options=transaction_options,
    )

    block = web3.eth.getBlock("latest")
    tx_hash = block.transactions[0]
    tx = web3.eth.getTransaction(tx_hash)

    assert tx["from"] == transaction_options["from"]
    assert tx["gas"] == transaction_options["gas"]
    assert tx["gasPrice"] == transaction_options["gasPrice"]
Esempio n. 2
0
 def deploy_identity(self, factory_address, implementation_address,
                     signature):
     if factory_address not in self.known_factories:
         raise UnknownIdentityFactoryException(factory_address)
     try:
         # when getting an address via contract.address, the address might not be a checksummed address
         return self._web3.toChecksumAddress(
             deploy_proxied_identity(self._web3, factory_address,
                                     implementation_address,
                                     signature).address)
     except TransactionFailed:
         raise IdentityDeploymentFailedException
Esempio n. 3
0
def test_deploy_proxied_identity(
    web3,
    table,
    proxy_factory,
    identity_implementation,
    signature_of_owner_on_implementation,
):
    block_number_before = web3.eth.blockNumber

    deploy_proxied_identity(
        web3,
        proxy_factory.address,
        identity_implementation.address,
        signature_of_owner_on_implementation,
    )

    block_number_after = web3.eth.blockNumber

    gas_cost = 0
    for block_number in range(block_number_after, block_number_before, -1):
        gas_cost += web3.eth.getBlock(block_number).gasUsed

    report_gas_costs(table, "Deploy Proxied Identity", gas_cost, limit=310_000)
Esempio n. 4
0
def test_deploy_proxied_identity(
    web3,
    gas_values_snapshot,
    proxy_factory,
    identity_implementation,
    signature_of_owner_on_implementation,
):
    block_number_before = web3.eth.blockNumber

    deploy_proxied_identity(
        web3,
        proxy_factory.address,
        identity_implementation.address,
        signature_of_owner_on_implementation,
    )

    block_number_after = web3.eth.blockNumber

    gas_cost = 0
    for block_number in range(block_number_after, block_number_before, -1):
        gas_cost += web3.eth.getBlock(block_number).gasUsed

    gas_values_snapshot.assert_gas_costs_match("DEPLOY_PROXIED_IDENTITY", gas_cost)
Esempio n. 5
0
def proxied_identity_contract(
    web3,
    proxy_factory,
    identity_implementation,
    signature_of_owner_on_implementation,
    owner,
):
    proxied_identity_contract = deploy_proxied_identity(
        web3=web3,
        factory_address=proxy_factory.address,
        implementation_address=identity_implementation.address,
        signature=signature_of_owner_on_implementation,
    )

    web3.eth.sendTransaction(
        {"to": proxied_identity_contract.address, "from": owner, "value": 1000000}
    )
    return proxied_identity_contract
Esempio n. 6
0
 def deploy_identity(self, factory_address, implementation_address, signature):
     if factory_address not in self.known_factories:
         raise UnknownIdentityFactoryException(factory_address)
     transaction_options = {
         "gasPrice": self._calculate_gas_price(meta_transaction=None)
     }
     try:
         # when getting an address via contract.address, the address might not be a checksummed address
         return self._web3.toChecksumAddress(
             deploy_proxied_identity(
                 self._web3,
                 factory_address,
                 implementation_address,
                 signature,
                 transaction_options=transaction_options,
             ).address
         )
     except TransactionFailed:
         raise IdentityDeploymentFailedException
def test_deploy_identity_proxy(
    web3,
    proxy_factory,
    identity_implementation,
    signature_of_owner_on_implementation,
    owner,
    get_proxy_initcode,
):
    proxy = deploy_proxied_identity(
        web3,
        proxy_factory.address,
        identity_implementation.address,
        signature_of_owner_on_implementation,
    )

    identity_proxy_initcode = get_proxy_initcode([owner])
    pre_computed_address = build_create2_address(proxy_factory.address,
                                                 identity_proxy_initcode)

    assert proxy.address == pre_computed_address
    assert proxy.functions.implementation().call(
    ) == identity_implementation.address