Skip to content

Commit

Permalink
added Receipt
Browse files Browse the repository at this point in the history
  • Loading branch information
lmittmann committed Jul 11, 2023
1 parent bb06bc5 commit 4aba347
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions w3vm/receipt.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package w3vm

import (
"errors"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/lmittmann/w3/w3types"
)

// Receipt represents the result of an applied [w3types.Message].
type Receipt struct {
f w3types.Func // Func of corresponding message

GasUsed uint64 // Gas used by the message
GasLimit uint64 // Minimum required gas limit (gas used + gas refund)
Logs []*types.Log // Logs emitted by the message
Output []byte // Output bytes of the applied message
ContractAddress *common.Address // Contract address created by a contract creation transaction

Err error // Err returned on revert
}

func (r Receipt) DecodeReturns(returns ...any) error {
if r.Err != nil {
return r.Err
}
if r.f == nil {
return errors.New("no function")
}
return r.f.DecodeReturns(r.Output, returns...)
}

0 comments on commit 4aba347

Please sign in to comment.