-
Notifications
You must be signed in to change notification settings - Fork 0
/
tx.go
29 lines (25 loc) · 850 Bytes
/
tx.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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)
}