forked from evmos/ethermint
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
e3c38bb
commit cf15e28
Showing
4 changed files
with
50 additions
and
16 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
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
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
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 |
---|---|---|
@@ -1,6 +1,29 @@ | ||
package types | ||
|
||
import ( | ||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/core/vm" | ||
) | ||
|
||
// Failed returns if the contract execution failed in vm errors | ||
func (m *MsgEthereumTxResponse) Failed() bool { | ||
return len(m.VmError) > 0 | ||
} | ||
|
||
// Return is a helper function to help caller distinguish between revert reason | ||
// and function return. Return returns the data after execution if no error occurs. | ||
func (m *MsgEthereumTxResponse) Return() []byte { | ||
if m.Failed() { | ||
return nil | ||
} | ||
return common.CopyBytes(m.Ret) | ||
} | ||
|
||
// Revert returns the concrete revert reason if the execution is aborted by `REVERT` | ||
// opcode. Note the reason can be nil if no data supplied with revert opcode. | ||
func (m *MsgEthereumTxResponse) Revert() []byte { | ||
if m.VmError != vm.ErrExecutionReverted.Error() { | ||
return nil | ||
} | ||
return common.CopyBytes(m.Ret) | ||
} |