-
Notifications
You must be signed in to change notification settings - Fork 0
/
module.go
146 lines (108 loc) · 5.09 KB
/
module.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
package ibchooker
import (
"encoding/json"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types"
porttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types"
"github.com/cosmos/ibc-go/v6/modules/core/exported"
"github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
abci "github.com/tendermint/tendermint/abci/types"
ibchookerkeeper "github.com/merlin-network/elysium-sdk/v2/x/ibchooker/keeper"
"github.com/merlin-network/elysium-sdk/v2/x/ibchooker/types"
)
var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ porttypes.IBCModule = AppModule{}
)
type AppModuleBasic struct{}
func (a AppModuleBasic) Name() string { return types.ModuleName }
func (a AppModuleBasic) RegisterLegacyAminoCodec(_ *codec.LegacyAmino) {}
func (a AppModuleBasic) RegisterInterfaces(_ cdctypes.InterfaceRegistry) {}
func (a AppModuleBasic) DefaultGenesis(_ codec.JSONCodec) json.RawMessage {
return nil
}
func (a AppModuleBasic) ValidateGenesis(_ codec.JSONCodec, _ client.TxEncodingConfig, _ json.RawMessage) error {
return nil
}
func (a AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {}
func (a AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *runtime.ServeMux) {}
func (a AppModuleBasic) GetTxCmd() *cobra.Command {
return nil
}
func (a AppModuleBasic) GetQueryCmd() *cobra.Command {
return nil
}
type AppModule struct {
AppModuleBasic
keeper ibchookerkeeper.Keeper
// ONLY PASS IBC TRANSFER APP
ibcApp porttypes.IBCModule
}
func NewAppModule(keeper ibchookerkeeper.Keeper, ibcTransferApp porttypes.IBCModule) AppModule {
return AppModule{
AppModuleBasic: AppModuleBasic{},
keeper: keeper,
ibcApp: ibcTransferApp,
}
}
func (am AppModule) InitGenesis(_ sdk.Context, _ codec.JSONCodec, _ json.RawMessage) []abci.ValidatorUpdate {
return []abci.ValidatorUpdate{}
}
func (am AppModule) ExportGenesis(_ sdk.Context, _ codec.JSONCodec) json.RawMessage {
return nil
}
func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {}
func (am AppModule) Route() sdk.Route {
return sdk.Route{}
}
func (am AppModule) QuerierRoute() string { return "" }
func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier {
return nil
}
func (am AppModule) RegisterServices(_ module.Configurator) {}
func (am AppModule) ConsensusVersion() uint64 { return 1 }
func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}
func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
return []abci.ValidatorUpdate{}
}
func (am AppModule) OnChanOpenInit(ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID string, channelID string, channelCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, version string) (string, error) {
return am.ibcApp.OnChanOpenInit(ctx, order, connectionHops, portID, channelID, channelCap, counterparty, version)
}
func (am AppModule) OnChanOpenTry(ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID, channelID string, channelCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, counterpartyVersion string) (version string, err error) {
return am.ibcApp.OnChanOpenTry(ctx, order, connectionHops, portID, channelID, channelCap, counterparty, counterpartyVersion)
}
func (am AppModule) OnChanOpenAck(ctx sdk.Context, portID, channelID string, counterpartyChannelID string, counterpartyVersion string) error {
return am.ibcApp.OnChanOpenAck(ctx, portID, channelID, counterpartyChannelID, counterpartyVersion)
}
func (am AppModule) OnChanOpenConfirm(ctx sdk.Context, portID, channelID string) error {
return am.ibcApp.OnChanOpenConfirm(ctx, portID, channelID)
}
func (am AppModule) OnChanCloseInit(ctx sdk.Context, portID, channelID string) error {
return am.ibcApp.OnChanCloseInit(ctx, portID, channelID)
}
func (am AppModule) OnChanCloseConfirm(ctx sdk.Context, portID, channelID string) error {
return am.ibcApp.OnChanCloseConfirm(ctx, portID, channelID)
}
func (am AppModule) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress) exported.Acknowledgement {
ack := am.ibcApp.OnRecvPacket(ctx, packet, relayer)
am.keeper.OnRecvPacket(ctx, packet, relayer, ack)
return ack
}
func (am AppModule) OnAcknowledgementPacket(ctx sdk.Context, packet channeltypes.Packet, acknowledgement []byte, relayer sdk.AccAddress) error {
err := am.ibcApp.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer)
am.keeper.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer, err)
return err
}
func (am AppModule) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress) error {
err := am.ibcApp.OnTimeoutPacket(ctx, packet, relayer)
am.keeper.OnTimeoutPacket(ctx, packet, relayer, err)
return err
}