github.com/onflow/flow-go@v0.33.17/fvm/evm/types/result.go (about) 1 package types 2 3 import ( 4 gethTypes "github.com/ethereum/go-ethereum/core/types" 5 ) 6 7 // Result captures the result of an interaction to the emulator 8 // it could be the out put of a direct call or output of running an 9 // evm transaction. 10 // Its more comprehensive than typical evm receipt, usually 11 // the receipt generation requires some extra calculation (e.g. Deployed contract address) 12 // but we take a different apporach here and include more data so that 13 // it requires less work for anyone who tracks and consume results. 14 type Result struct { 15 // a boolean that is set to false if the execution has failed (non-fatal) 16 Failed bool 17 // type of transaction defined by the evm package 18 // see DirectCallTxType as extra type we added type for direct calls. 19 TxType uint8 20 // total gas consumed during an opeartion 21 GasConsumed uint64 22 // the address where the contract is deployed (if any) 23 DeployedContractAddress Address 24 // returned value from a function call 25 ReturnedValue []byte 26 // EVM logs (events that are emited by evm) 27 Logs []*gethTypes.Log 28 } 29 30 // Receipt constructs an EVM-style receipt 31 // can be used by json-rpc and other integration to be returned. 32 func (res *Result) Receipt() *gethTypes.ReceiptForStorage { 33 receipt := &gethTypes.Receipt{ 34 Type: res.TxType, 35 CumulativeGasUsed: res.GasConsumed, // TODO: update to capture cumulative 36 Logs: res.Logs, 37 ContractAddress: res.DeployedContractAddress.ToCommon(), 38 } 39 if res.Failed { 40 receipt.Status = gethTypes.ReceiptStatusFailed 41 } else { 42 receipt.Status = gethTypes.ReceiptStatusSuccessful 43 } 44 45 receipt.Bloom = gethTypes.CreateBloom(gethTypes.Receipts{receipt}) 46 return (*gethTypes.ReceiptForStorage)(receipt) 47 }