-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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...) | ||
} |