github.com/lmittmann/w3@v0.20.0/w3vm/receipt.go (about) 1 package w3vm 2 3 import ( 4 "errors" 5 6 "github.com/ethereum/go-ethereum/common" 7 "github.com/ethereum/go-ethereum/core/types" 8 "github.com/lmittmann/w3/w3types" 9 ) 10 11 var ErrMissingFunc = errors.New("missing function") 12 13 // Receipt represents the result of an applied [w3types.Message]. 14 type Receipt struct { 15 f w3types.Func // Func of corresponding message 16 17 GasUsed uint64 // Gas used for executing the message (including refunds) 18 MaxGasUsed uint64 // Maximum gas used during executing the message (excluding refunds) 19 Logs []*types.Log // Logs emitted while executing the message 20 Output []byte // Output of the executed message 21 ContractAddress *common.Address // Address of the created contract, if any 22 23 Err error // Execution error, if any 24 } 25 26 // DecodeReturns is like [w3types.Func.DecodeReturns], but returns [ErrMissingFunc] 27 // if the underlying [w3types.Message.Func] is nil. 28 func (r Receipt) DecodeReturns(returns ...any) error { 29 if r.Err != nil { 30 return r.Err 31 } 32 if r.f == nil { 33 return ErrMissingFunc 34 } 35 return r.f.DecodeReturns(r.Output, returns...) 36 }