def from_function_call( cls, function_call, *, from_: str = None, chain_id: int = None, to: str, nonce: int = None, base_fee: int = 0, gas_price: int = 0, gas_limit: int = 0, currency_network_of_fees: str = None, time_limit: int = 0, operation_type: OperationType = OperationType.CALL, ): """Construct a meta transaction from a web3 function call. Usage: `from_function_call(contract.functions.function())` """ data = function_call.buildTransaction( transaction={"gas": MAX_GAS})["data"] if chain_id is None: chain_id = get_chain_id(function_call.web3) optional_meta_transaction_args = {} if currency_network_of_fees is not None: optional_meta_transaction_args[ "currency_network_of_fees"] = currency_network_of_fees return cls( from_=from_, to=to, chain_id=chain_id, value=0, data=data, base_fee=base_fee, gas_price=gas_price, gas_limit=gas_limit, nonce=nonce, time_limit=time_limit, operation_type=operation_type, **optional_meta_transaction_args, # type: ignore )
def defaults_filled(self, meta_transaction: MetaTransaction) -> MetaTransaction: """Returns a meta transaction where the from field of the transaction is set to the identity address, the nonce if not set yet is set to the next nonce and the chainId is set""" meta_transaction = attr.evolve(meta_transaction, from_=self.address) if meta_transaction.nonce is None: meta_transaction = attr.evolve(meta_transaction, nonce=self.get_next_nonce()) if meta_transaction.chain_id is None: meta_transaction = attr.evolve(meta_transaction, chain_id=get_chain_id( self.contract.web3)) return meta_transaction
def deploy_identity_proxy_factory( *, chain_id=None, web3: Web3, transaction_options: Dict = None, private_key: bytes = None, ): if transaction_options is None: transaction_options = {} if chain_id is None: chain_id = get_chain_id(web3) identity_proxy_factory = deploy( "IdentityProxyFactory", constructor_args=(chain_id, ), web3=web3, transaction_options=transaction_options, private_key=private_key, ) increase_transaction_options_nonce(transaction_options) return identity_proxy_factory
def validate_chain_id(self, meta_transaction: MetaTransaction): """Validates the chain id by checking it against the web3 chain id. Returns: True, if the chain id was correct """ return meta_transaction.chain_id == get_chain_id(self._web3)
def chain_id(web3): return get_chain_id(web3)