-
Notifications
You must be signed in to change notification settings - Fork 0
/
ethereum_tx.go
48 lines (41 loc) · 1.16 KB
/
ethereum_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
47
48
package evm
import (
. "github.com/bianjieai/chain-parser/common-parser/modules"
"github.com/bianjieai/chain-parser/common-parser/utils"
. "github.com/bianjieai/chain-parser/iritachain-mod-parser/modules"
evm "github.com/tharsis/ethermint/x/evm/types"
)
// MsgEthereumTx encapsulates an Ethereum transaction as an SDK message.
type DocMsgEthereumTx struct {
Data string `bson:"data"`
Size_ float64 `bson:"size"`
Hash string `bson:"hash"`
From string `bson:"from"`
FeePayer string `bson:"fee_payer"`
}
func (doctx *DocMsgEthereumTx) GetType() string {
return MsgTypeEthereumTx
}
func (doctx *DocMsgEthereumTx) BuildMsg(txMsg interface{}) {
msg := txMsg.(*MsgEthereumTx)
doctx.Size_ = msg.Size_
doctx.Hash = msg.Hash
doctx.From = msg.From
if txData, err := evm.UnpackTxData(msg.Data); err == nil {
doctx.Data = utils.MarshalJsonIgnoreErr(txData)
}
doctx.FeePayer = msg.FeePayer
}
func (m *DocMsgEthereumTx) HandleTxMsg(v SdkMsg) MsgDocInfo {
var (
addrs []string
)
msg, ok := v.(*MsgEthereumTx)
if ok {
addrs = append(addrs, msg.From)
}
handler := func() (Msg, []string) {
return m, addrs
}
return CreateMsgDocInfo(v, handler)
}