@@ -12,22 +12,25 @@ import (
12
12
"github.com/cosmos/ibc-go/v3/modules/core/exported"
13
13
)
14
14
15
- // IBCModule implements the ICS26 callbacks for the fee middleware given the fee keeper and the underlying application.
16
- type IBCModule struct {
17
- keeper keeper.Keeper
15
+ var _ porttypes.Middleware = & IBCMiddleware {}
16
+
17
+ // IBCMiddleware implements the ICS26 callbacks for the fee middleware given the
18
+ // fee keeper and the underlying application.
19
+ type IBCMiddleware struct {
18
20
app porttypes.IBCModule
21
+ keeper keeper.Keeper
19
22
}
20
23
21
- // NewIBCModule creates a new IBCModule given the keeper and underlying application
22
- func NewIBCModule (k keeper.Keeper , app porttypes.IBCModule ) IBCModule {
23
- return IBCModule {
24
- keeper : k ,
24
+ // NewIBCMiddleware creates a new IBCMiddlware given the keeper and underlying application
25
+ func NewIBCMiddleware (app porttypes.IBCModule , k keeper.Keeper ) IBCMiddleware {
26
+ return IBCMiddleware {
25
27
app : app ,
28
+ keeper : k ,
26
29
}
27
30
}
28
31
29
- // OnChanOpenInit implements the IBCModule interface
30
- func (im IBCModule ) OnChanOpenInit (
32
+ // OnChanOpenInit implements the IBCMiddleware interface
33
+ func (im IBCMiddleware ) OnChanOpenInit (
31
34
ctx sdk.Context ,
32
35
order channeltypes.Order ,
33
36
connectionHops []string ,
@@ -57,10 +60,10 @@ func (im IBCModule) OnChanOpenInit(
57
60
chanCap , counterparty , versionMetadata .AppVersion )
58
61
}
59
62
60
- // OnChanOpenTry implements the IBCModule interface
63
+ // OnChanOpenTry implements the IBCMiddleware interface
61
64
// If the channel is not fee enabled the underlying application version will be returned
62
65
// If the channel is fee enabled we merge the underlying application version with the ics29 version
63
- func (im IBCModule ) OnChanOpenTry (
66
+ func (im IBCMiddleware ) OnChanOpenTry (
64
67
ctx sdk.Context ,
65
68
order channeltypes.Order ,
66
69
connectionHops []string ,
@@ -100,8 +103,8 @@ func (im IBCModule) OnChanOpenTry(
100
103
return string (versionBytes ), nil
101
104
}
102
105
103
- // OnChanOpenAck implements the IBCModule interface
104
- func (im IBCModule ) OnChanOpenAck (
106
+ // OnChanOpenAck implements the IBCMiddleware interface
107
+ func (im IBCMiddleware ) OnChanOpenAck (
105
108
ctx sdk.Context ,
106
109
portID ,
107
110
channelID string ,
@@ -128,8 +131,8 @@ func (im IBCModule) OnChanOpenAck(
128
131
return im .app .OnChanOpenAck (ctx , portID , channelID , counterpartyChannelID , counterpartyVersion )
129
132
}
130
133
131
- // OnChanOpenConfirm implements the IBCModule interface
132
- func (im IBCModule ) OnChanOpenConfirm (
134
+ // OnChanOpenConfirm implements the IBCMiddleware interface
135
+ func (im IBCMiddleware ) OnChanOpenConfirm (
133
136
ctx sdk.Context ,
134
137
portID ,
135
138
channelID string ,
@@ -138,8 +141,8 @@ func (im IBCModule) OnChanOpenConfirm(
138
141
return im .app .OnChanOpenConfirm (ctx , portID , channelID )
139
142
}
140
143
141
- // OnChanCloseInit implements the IBCModule interface
142
- func (im IBCModule ) OnChanCloseInit (
144
+ // OnChanCloseInit implements the IBCMiddleware interface
145
+ func (im IBCMiddleware ) OnChanCloseInit (
143
146
ctx sdk.Context ,
144
147
portID ,
145
148
channelID string ,
@@ -155,8 +158,8 @@ func (im IBCModule) OnChanCloseInit(
155
158
return nil
156
159
}
157
160
158
- // OnChanCloseConfirm implements the IBCModule interface
159
- func (im IBCModule ) OnChanCloseConfirm (
161
+ // OnChanCloseConfirm implements the IBCMiddleware interface
162
+ func (im IBCMiddleware ) OnChanCloseConfirm (
160
163
ctx sdk.Context ,
161
164
portID ,
162
165
channelID string ,
@@ -172,9 +175,9 @@ func (im IBCModule) OnChanCloseConfirm(
172
175
return nil
173
176
}
174
177
175
- // OnRecvPacket implements the IBCModule interface.
178
+ // OnRecvPacket implements the IBCMiddleware interface.
176
179
// If fees are not enabled, this callback will default to the ibc-core packet callback
177
- func (im IBCModule ) OnRecvPacket (
180
+ func (im IBCMiddleware ) OnRecvPacket (
178
181
ctx sdk.Context ,
179
182
packet channeltypes.Packet ,
180
183
relayer sdk.AccAddress ,
@@ -197,9 +200,9 @@ func (im IBCModule) OnRecvPacket(
197
200
return types .NewIncentivizedAcknowledgement (forwardRelayer , ack .Acknowledgement (), ack .Success ())
198
201
}
199
202
200
- // OnAcknowledgementPacket implements the IBCModule interface
203
+ // OnAcknowledgementPacket implements the IBCMiddleware interface
201
204
// If fees are not enabled, this callback will default to the ibc-core packet callback
202
- func (im IBCModule ) OnAcknowledgementPacket (
205
+ func (im IBCMiddleware ) OnAcknowledgementPacket (
203
206
ctx sdk.Context ,
204
207
packet channeltypes.Packet ,
205
208
acknowledgement []byte ,
@@ -239,9 +242,9 @@ func (im IBCModule) OnAcknowledgementPacket(
239
242
return im .app .OnAcknowledgementPacket (ctx , packet , ack .Result , relayer )
240
243
}
241
244
242
- // OnTimeoutPacket implements the IBCModule interface
245
+ // OnTimeoutPacket implements the IBCMiddleware interface
243
246
// If fees are not enabled, this callback will default to the ibc-core packet callback
244
- func (im IBCModule ) OnTimeoutPacket (
247
+ func (im IBCMiddleware ) OnTimeoutPacket (
245
248
ctx sdk.Context ,
246
249
packet channeltypes.Packet ,
247
250
relayer sdk.AccAddress ,
@@ -268,7 +271,26 @@ func (im IBCModule) OnTimeoutPacket(
268
271
return im .app .OnTimeoutPacket (ctx , packet , relayer )
269
272
}
270
273
274
+ // SendPacket implements the ICS4 Wrapper interface
275
+ func (im IBCMiddleware ) SendPacket (
276
+ ctx sdk.Context ,
277
+ chanCap * capabilitytypes.Capability ,
278
+ packet exported.PacketI ,
279
+ ) error {
280
+ return im .keeper .SendPacket (ctx , chanCap , packet )
281
+ }
282
+
283
+ // WriteAcknowledgement implements the ICS4 Wrapper interface
284
+ func (im IBCMiddleware ) WriteAcknowledgement (
285
+ ctx sdk.Context ,
286
+ chanCap * capabilitytypes.Capability ,
287
+ packet exported.PacketI ,
288
+ ack exported.Acknowledgement ,
289
+ ) error {
290
+ return im .keeper .WriteAcknowledgement (ctx , chanCap , packet , ack )
291
+ }
292
+
271
293
// GetAppVersion returns the application version of the underlying application
272
- func (im IBCModule ) GetAppVersion (ctx sdk.Context , portID , channelID string ) (string , bool ) {
294
+ func (im IBCMiddleware ) GetAppVersion (ctx sdk.Context , portID , channelID string ) (string , bool ) {
273
295
return im .keeper .GetAppVersion (ctx , portID , channelID )
274
296
}
0 commit comments