@@ -2,7 +2,6 @@ package interchain_accounts
2
2
3
3
import (
4
4
"encoding/json"
5
- "fmt"
6
5
7
6
"github.com/gorilla/mux"
8
7
"github.com/spf13/cobra"
@@ -11,23 +10,19 @@ import (
11
10
"github.com/cosmos/cosmos-sdk/codec"
12
11
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
13
12
sdk "github.com/cosmos/cosmos-sdk/types"
14
- sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
15
13
"github.com/cosmos/cosmos-sdk/types/module"
16
- capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
17
14
"github.com/grpc-ecosystem/grpc-gateway/runtime"
18
15
abci "github.com/tendermint/tendermint/abci/types"
19
16
20
17
"github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/client/cli"
21
18
"github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/keeper"
22
19
"github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types"
23
- channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types"
24
20
porttypes "github.com/cosmos/ibc-go/v2/modules/core/05-port/types"
25
- ibcexported "github.com/cosmos/ibc-go/v2/modules/core/exported"
26
21
)
27
22
28
23
var (
29
24
_ module.AppModule = AppModule {}
30
- _ porttypes.IBCModule = AppModule {}
25
+ _ porttypes.IBCModule = IBCModule {}
31
26
_ module.AppModuleBasic = AppModuleBasic {}
32
27
)
33
28
@@ -135,134 +130,3 @@ func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
135
130
func (am AppModule ) EndBlock (ctx sdk.Context , req abci.RequestEndBlock ) []abci.ValidatorUpdate {
136
131
return []abci.ValidatorUpdate {}
137
132
}
138
-
139
- // Implement IBCModule callbacks
140
- func (am AppModule ) OnChanOpenInit (
141
- ctx sdk.Context ,
142
- order channeltypes.Order ,
143
- connectionHops []string ,
144
- portID string ,
145
- channelID string ,
146
- chanCap * capabilitytypes.Capability ,
147
- counterparty channeltypes.Counterparty ,
148
- version string ,
149
- ) error {
150
- return am .keeper .OnChanOpenInit (ctx , order , connectionHops , portID , channelID , chanCap , counterparty , version )
151
- }
152
-
153
- func (am AppModule ) OnChanOpenTry (
154
- ctx sdk.Context ,
155
- order channeltypes.Order ,
156
- connectionHops []string ,
157
- portID ,
158
- channelID string ,
159
- chanCap * capabilitytypes.Capability ,
160
- counterparty channeltypes.Counterparty ,
161
- version ,
162
- counterpartyVersion string ,
163
- ) error {
164
- return am .keeper .OnChanOpenTry (ctx , order , connectionHops , portID , channelID , chanCap , counterparty , version , counterpartyVersion )
165
- }
166
-
167
- func (am AppModule ) OnChanOpenAck (
168
- ctx sdk.Context ,
169
- portID ,
170
- channelID string ,
171
- counterpartyVersion string ,
172
- ) error {
173
- return am .keeper .OnChanOpenAck (ctx , portID , channelID , counterpartyVersion )
174
- }
175
-
176
- func (am AppModule ) OnChanOpenConfirm (
177
- ctx sdk.Context ,
178
- portID ,
179
- channelID string ,
180
- ) error {
181
- return am .keeper .OnChanOpenConfirm (ctx , portID , channelID )
182
- }
183
-
184
- func (am AppModule ) OnChanCloseInit (
185
- ctx sdk.Context ,
186
- portID ,
187
- channelID string ,
188
- ) error {
189
- // Disallow user-initiated channel closing for interchain account channels
190
- return sdkerrors .Wrap (sdkerrors .ErrInvalidRequest , "user cannot close channel" )
191
- }
192
-
193
- func (am AppModule ) OnChanCloseConfirm (
194
- ctx sdk.Context ,
195
- portID ,
196
- channelID string ,
197
- ) error {
198
- return nil
199
- }
200
-
201
- func (am AppModule ) OnRecvPacket (
202
- ctx sdk.Context ,
203
- packet channeltypes.Packet ,
204
- _ sdk.AccAddress ,
205
- ) ibcexported.Acknowledgement {
206
- ack := channeltypes .NewResultAcknowledgement ([]byte {byte (1 )})
207
-
208
- var data types.IBCAccountPacketData
209
- if err := types .ModuleCdc .UnmarshalJSON (packet .GetData (), & data ); err != nil {
210
- ack = channeltypes .NewErrorAcknowledgement (fmt .Sprintf ("cannot unmarshal ICS-27 interchain account packet data: %s" , err .Error ()))
211
- }
212
-
213
- // only attempt the application logic if the packet data
214
- // was successfully decoded
215
- if ack .Success () {
216
- err := am .keeper .OnRecvPacket (ctx , packet )
217
- if err != nil {
218
- ack = channeltypes .NewErrorAcknowledgement (err .Error ())
219
- }
220
- }
221
-
222
- // NOTE: acknowledgement will be written synchronously during IBC handler execution.
223
- return ack
224
- }
225
-
226
- func (am AppModule ) OnAcknowledgementPacket (
227
- ctx sdk.Context ,
228
- packet channeltypes.Packet ,
229
- acknowledgement []byte ,
230
- _ sdk.AccAddress ,
231
- ) error {
232
- var ack channeltypes.Acknowledgement
233
-
234
- if err := types .ModuleCdc .UnmarshalJSON (acknowledgement , & ack ); err != nil {
235
- return sdkerrors .Wrapf (sdkerrors .ErrUnknownRequest , "cannot unmarshal ICS-27 interchain account packet acknowledgment: %v" , err )
236
- }
237
- var data types.IBCAccountPacketData
238
- if err := types .ModuleCdc .UnmarshalJSON (packet .GetData (), & data ); err != nil {
239
- return sdkerrors .Wrapf (sdkerrors .ErrUnknownRequest , "cannot unmarshal ICS-27 interchain account packet data: %s" , err .Error ())
240
- }
241
-
242
- if err := am .keeper .OnAcknowledgementPacket (ctx , packet , data , ack ); err != nil {
243
- return err
244
- }
245
-
246
- return nil
247
- }
248
-
249
- func (am AppModule ) OnTimeoutPacket (
250
- ctx sdk.Context ,
251
- packet channeltypes.Packet ,
252
- _ sdk.AccAddress ,
253
- ) error {
254
- // TODO
255
- return nil
256
- }
257
-
258
- // NegotiateAppVersion implements the IBCModule interface
259
- func (am AppModule ) NegotiateAppVersion (
260
- ctx sdk.Context ,
261
- order channeltypes.Order ,
262
- connectionID string ,
263
- portID string ,
264
- counterparty channeltypes.Counterparty ,
265
- proposedVersion string ,
266
- ) (string , error ) {
267
- return am .keeper .NegotiateAppVersion (ctx , order , connectionID , portID , counterparty , proposedVersion )
268
- }
0 commit comments