-
Notifications
You must be signed in to change notification settings - Fork 0
/
codec.go
44 lines (37 loc) · 1011 Bytes
/
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
package codec
import (
"github.com/cometbft/cometbft/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
ctypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/auth/signing"
)
var (
AppModules []module.AppModuleBasic
Encodecfg EncodingConfig
)
type EncodingConfig struct {
InterfaceRegistry ctypes.InterfaceRegistry
Codec codec.Codec
TxConfig client.TxConfig
Amino *codec.LegacyAmino
}
func GetTxDecoder() sdk.TxDecoder {
return Encodecfg.TxConfig.TxDecoder()
}
func GetMarshaler() codec.Codec {
return Encodecfg.Codec
}
func GetSigningTx(txBytes types.Tx) (signing.Tx, error) {
Tx, err := GetTxDecoder()(txBytes)
if err != nil {
return nil, err
}
signingTx := Tx.(signing.Tx)
return signingTx, nil
}
func RegisterAppModules(module ...module.AppModuleBasic) {
AppModules = append(AppModules, module...)
}