-
Notifications
You must be signed in to change notification settings - Fork 3
/
codec.go
55 lines (46 loc) · 1.5 KB
/
codec.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
49
50
51
52
53
54
55
package pvm
import (
"github.com/oracleNetworkProtocol/plugchain-sdk-go/codec"
"github.com/oracleNetworkProtocol/plugchain-sdk-go/codec/types"
cryptocodec "github.com/oracleNetworkProtocol/plugchain-sdk-go/crypto/codec"
sdk "github.com/oracleNetworkProtocol/plugchain-sdk-go/types"
sdkerrors "github.com/oracleNetworkProtocol/plugchain-sdk-go/types/errors"
)
var (
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewAminoCodec(amino)
)
type (
ExtensionOptionsEthereumTxI interface{}
)
func init() {
cryptocodec.RegisterCrypto(amino)
amino.Seal()
}
func RegisterInterfaces(registry types.InterfaceRegistry) {
registry.RegisterImplementations(
(*sdk.Msg)(nil),
&MsgEthereumTx{},
)
registry.RegisterInterface("ethermint.evm.v1.ExtensionOptionsEthereumTx", (*ExtensionOptionsEthereumTxI)(nil), &ExtensionOptionsEthereumTx{})
registry.RegisterInterface(
"ethermint.evm.v1.TxData",
(*TxData)(nil),
&DynamicFeeTx{},
&AccessListTx{},
&LegacyTx{},
)
//registry.RegisterInterface("ethermint.evm.v1.TxData\"", (*TokenInterface)(nil), &Token{})
}
// UnpackTxData unpacks an Any into a TxData. It returns an error if the
// client state can't be unpacked into a TxData.
func UnpackTxData(any *types.Any) (TxData, error) {
if any == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrUnpackAny, "protobuf Any message cannot be nil")
}
txData, ok := any.GetCachedValue().(TxData)
if !ok {
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnpackAny, "cannot unpack Any into TxData %T", any)
}
return txData, nil
}