forked from EscanBE/evermint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
response_deliver_eth_tx.go
46 lines (40 loc) · 1.34 KB
/
response_deliver_eth_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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package types
import (
evmtypes "github.com/servprotocolorg/serv/v12/x/evm/types"
abci "github.com/cometbft/cometbft/abci/types"
)
type ResponseDeliverEthTx struct {
CosmosTxHash string
EthTxHash string
EvmError string
ResponseDeliverEthTx *abci.ResponseDeliverTx
}
func NewResponseDeliverEthTx(responseDeliverTx *abci.ResponseDeliverTx) *ResponseDeliverEthTx {
if responseDeliverTx == nil {
return nil
}
response := &ResponseDeliverEthTx{
ResponseDeliverEthTx: responseDeliverTx,
}
for _, event := range responseDeliverTx.Events {
if event.Type == evmtypes.TypeMsgEthereumTx {
for _, attribute := range event.Attributes {
//fmt.Println(evmtypes.TypeMsgEthereumTx, "attribute.Key", attribute.Key, "attribute.Value", attribute.Value)
if attribute.Key == evmtypes.AttributeKeyTxHash {
if len(attribute.Value) > 0 && response.CosmosTxHash == "" {
response.CosmosTxHash = attribute.Value
}
} else if attribute.Key == evmtypes.AttributeKeyEthereumTxHash {
if len(attribute.Value) > 0 && response.EthTxHash == "" {
response.EthTxHash = attribute.Value
}
} else if attribute.Key == evmtypes.AttributeKeyEthereumTxFailed {
if len(attribute.Value) > 0 && response.EvmError == "" {
response.EvmError = attribute.Value
}
}
}
}
}
return response
}