def dict_to_spoof_transaction( chain: BaseAsyncChain, header: BlockHeader, transaction_dict: Dict[str, Any]) -> SpoofTransaction: """ Convert dicts used in calls & gas estimates into a spoof transaction """ txn_dict = normalize_transaction_dict(transaction_dict) sender = txn_dict.get('from', ZERO_ADDRESS) if 'nonce' in txn_dict: nonce = txn_dict['nonce'] else: vm = chain.get_vm(header) nonce = vm.state.account_db.get_nonce(sender) gas_price = txn_dict.get('gasPrice', 0) gas = txn_dict.get('gas', header.gas_limit) unsigned = chain.get_vm_class(header).create_unsigned_transaction( nonce=nonce, gas_price=gas_price, gas=gas, to=txn_dict['to'], value=txn_dict['value'], data=txn_dict['data'], ) return SpoofTransaction(unsigned, from_=sender)
async def account_db_at_block(chain: BaseAsyncChain, at_block: Union[str, int], read_only: bool = True) -> BaseAccountDB: at_header = await get_header(chain, at_block) vm = chain.get_vm(at_header) return vm.state.account_db