@agoric/cosmos 0.34.2-dev-c19f1b5.0 → 0.34.2-dev-27cc9b8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,6 +24,8 @@ type (
24
24
  Keeper = keeper.Keeper
25
25
  SwingStoreExportsHandler = keeper.SwingStoreExportsHandler
26
26
  ExtensionSnapshotter = keeper.ExtensionSnapshotter
27
+ ActionContext = types.ActionContext
28
+ InboundQueueRecord = types.InboundQueueRecord
27
29
  Egress = types.Egress
28
30
  MsgDeliverInbound = types.MsgDeliverInbound
29
31
  MsgProvision = types.MsgProvision
@@ -51,25 +51,6 @@ const (
51
51
  swingStoreKeyPrefix = "swingStore."
52
52
  )
53
53
 
54
- // Contextual information about the message source of an action on an inbound queue.
55
- // This context should be unique per inboundQueueRecord.
56
- type actionContext struct {
57
- // The block height in which the corresponding action was enqueued
58
- BlockHeight int64 `json:"blockHeight"`
59
- // The hash of the cosmos transaction that included the message
60
- // If the action didn't result from a transaction message, a substitute value
61
- // may be used. For example the VBANK_BALANCE_UPDATE actions use `x/vbank`.
62
- TxHash string `json:"txHash"`
63
- // The index of the message within the transaction. If the action didn't
64
- // result from a cosmos transaction, a number should be chosen to make the
65
- // actionContext unique. (for example a counter per block and source module).
66
- MsgIdx int `json:"msgIdx"`
67
- }
68
- type inboundQueueRecord struct {
69
- Action vm.Jsonable `json:"action"`
70
- Context actionContext `json:"context"`
71
- }
72
-
73
54
  // Keeper maintains the link to data vstorage and exposes getter/setter methods for the various parts of the state machine
74
55
  type Keeper struct {
75
56
  storeKey storetypes.StoreKey
@@ -144,7 +125,14 @@ func (k Keeper) pushAction(ctx sdk.Context, inboundQueuePath string, action vm.A
144
125
  if !txHashOk || !msgIdxOk {
145
126
  stdlog.Printf("error while extracting context for action %q\n", action)
146
127
  }
147
- record := inboundQueueRecord{Action: action, Context: actionContext{BlockHeight: ctx.BlockHeight(), TxHash: txHash, MsgIdx: msgIdx}}
128
+ record := types.InboundQueueRecord{
129
+ Action: action,
130
+ Context: types.ActionContext{
131
+ BlockHeight: ctx.BlockHeight(),
132
+ TxHash: txHash,
133
+ MsgIdx: msgIdx,
134
+ },
135
+ }
148
136
  bz, err := json.Marshal(record)
149
137
  if err != nil {
150
138
  return err
@@ -0,0 +1,16 @@
1
+ package keeper
2
+
3
+ import (
4
+ "testing"
5
+
6
+ "github.com/Agoric/agoric-sdk/golang/cosmos/x/vstorage"
7
+ )
8
+
9
+ // GetVstorageKeeper returns the vstorage keeper from the swingset keeper
10
+ // for testing purposes.
11
+ func GetVstorageKeeper(t *testing.T, k Keeper) vstorage.Keeper {
12
+ if t == nil {
13
+ panic("this function is reserved for testing")
14
+ }
15
+ return k.vstorageKeeper
16
+ }
@@ -99,6 +99,11 @@ func (AppModule) Name() string {
99
99
  return ModuleName
100
100
  }
101
101
 
102
+ // For testing purposes
103
+ func (am *AppModule) SetSwingStoreExportDir(dir string) {
104
+ am.swingStoreExportDir = dir
105
+ }
106
+
102
107
  func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {}
103
108
 
104
109
  func (am AppModule) Route() sdk.Route {
@@ -149,9 +154,9 @@ func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.V
149
154
  return []abci.ValidatorUpdate{}
150
155
  }
151
156
 
152
- func (am AppModule) checkSwingStoreExportSetup() {
157
+ func (am *AppModule) checkSwingStoreExportSetup() {
153
158
  if am.swingStoreExportDir == "" {
154
- panic(fmt.Errorf("SwingStore export dir not set"))
159
+ am.swingStoreExportDir = "/tmp/swingset_export"
155
160
  }
156
161
  }
157
162
 
@@ -0,0 +1,17 @@
1
+ package testing
2
+
3
+ import (
4
+ "testing"
5
+
6
+ "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/keeper"
7
+ vstoragetesting "github.com/Agoric/agoric-sdk/golang/cosmos/x/vstorage/testing"
8
+ sdk "github.com/cosmos/cosmos-sdk/types"
9
+ )
10
+
11
+ // GetActionQueueRecords returns the records in the action queue.
12
+ // This is a testing utility function.
13
+ func GetActionQueueRecords(t *testing.T, ctx sdk.Context, swingsetKeeper keeper.Keeper) ([]string, error) {
14
+ vstorageKeeper := keeper.GetVstorageKeeper(t, swingsetKeeper)
15
+ actionQueueName := keeper.StoragePathActionQueue
16
+ return vstoragetesting.GetQueueItems(ctx, vstorageKeeper, actionQueueName)
17
+ }
@@ -29,6 +29,25 @@ var (
29
29
  _ vm.ControllerAdmissionMsg = &MsgWalletSpendAction{}
30
30
  )
31
31
 
32
+ // Contextual information about the message source of an action on an inbound queue.
33
+ // This context should be unique per inboundQueueRecord.
34
+ type ActionContext struct {
35
+ // The block height in which the corresponding action was enqueued
36
+ BlockHeight int64 `json:"blockHeight"`
37
+ // The hash of the cosmos transaction that included the message
38
+ // If the action didn't result from a transaction message, a substitute value
39
+ // may be used. For example the VBANK_BALANCE_UPDATE actions use `x/vbank`.
40
+ TxHash string `json:"txHash"`
41
+ // The index of the message within the transaction. If the action didn't
42
+ // result from a cosmos transaction, a number should be chosen to make the
43
+ // actionContext unique. (for example a counter per block and source module).
44
+ MsgIdx int `json:"msgIdx"`
45
+ }
46
+ type InboundQueueRecord struct {
47
+ Action vm.Jsonable `json:"action"`
48
+ Context ActionContext `json:"context"`
49
+ }
50
+
32
51
  const (
33
52
  // bundleUncompressedSizeLimit is the (exclusive) limit on uncompressed bundle size.
34
53
  // We must ensure there is an exclusive int64 limit in order to detect an underflow.
@@ -1,8 +1,6 @@
1
1
  package vbank
2
2
 
3
3
  import (
4
- // "fmt"
5
-
6
4
  "fmt"
7
5
 
8
6
  "github.com/Agoric/agoric-sdk/golang/cosmos/x/vbank/types"
@@ -1,15 +1,3 @@
1
1
  package types
2
2
 
3
3
  const RouterKey = ModuleName // this was defined in your key.go file
4
-
5
- type VbankSingleBalanceUpdate struct {
6
- Address string `json:"address"`
7
- Denom string `json:"denom"`
8
- Amount string `json:"amount"`
9
- }
10
-
11
- type VbankBalanceUpdate struct {
12
- Nonce uint64 `json:"nonce"`
13
- Type string `json:"type"`
14
- Updated []VbankSingleBalanceUpdate `json:"updated"`
15
- }
package/x/vbank/vbank.go CHANGED
@@ -34,14 +34,14 @@ func NewPortHandler(am AppModule, keeper Keeper) portHandler {
34
34
  }
35
35
  }
36
36
 
37
- type vbankSingleBalanceUpdate struct {
37
+ type VbankSingleBalanceUpdate struct {
38
38
  Address string `json:"address"`
39
39
  Denom string `json:"denom"`
40
40
  Amount string `json:"amount"`
41
41
  }
42
42
 
43
43
  // Make vbankManyBalanceUpdates sortable
44
- type vbankManyBalanceUpdates []vbankSingleBalanceUpdate
44
+ type vbankManyBalanceUpdates []VbankSingleBalanceUpdate
45
45
 
46
46
  var _ sort.Interface = vbankManyBalanceUpdates{}
47
47
 
@@ -67,7 +67,7 @@ func (vbu vbankManyBalanceUpdates) Swap(i int, j int) {
67
67
  vbu[i], vbu[j] = vbu[j], vbu[i]
68
68
  }
69
69
 
70
- type vbankBalanceUpdate struct {
70
+ type VbankBalanceUpdate struct {
71
71
  *vm.ActionHeader `actionType:"VBANK_BALANCE_UPDATE"`
72
72
  Nonce uint64 `json:"nonce"`
73
73
  Updated vbankManyBalanceUpdates `json:"updated"`
@@ -83,9 +83,9 @@ func getBalanceUpdate(ctx sdk.Context, keeper Keeper, addressToUpdate map[string
83
83
  }
84
84
 
85
85
  nonce := keeper.GetNextSequence(ctx)
86
- event := vbankBalanceUpdate{
86
+ event := VbankBalanceUpdate{
87
87
  Nonce: nonce,
88
- Updated: make([]vbankSingleBalanceUpdate, 0, nentries),
88
+ Updated: make([]VbankSingleBalanceUpdate, 0, nentries),
89
89
  }
90
90
 
91
91
  // Note that Golang randomises the order of iteration, so we have to sort
@@ -99,7 +99,7 @@ func getBalanceUpdate(ctx sdk.Context, keeper Keeper, addressToUpdate map[string
99
99
  for _, coin := range coins {
100
100
  // generate an update even when the current balance is zero
101
101
  balance := keeper.GetBalance(ctx, account, coin.Denom)
102
- update := vbankSingleBalanceUpdate{
102
+ update := VbankSingleBalanceUpdate{
103
103
  Address: address,
104
104
  Denom: coin.Denom,
105
105
  Amount: balance.Amount.String(),
@@ -71,7 +71,7 @@ func newBalances(opts ...balancesOption) balances {
71
71
  return bal
72
72
  }
73
73
 
74
- func validateBalanceUpdate(vbu vbankBalanceUpdate) error {
74
+ func validateBalanceUpdate(vbu VbankBalanceUpdate) error {
75
75
  if vbu.Type != "VBANK_BALANCE_UPDATE" {
76
76
  return fmt.Errorf("bad balance update type: %s", vbu.Type)
77
77
  }
@@ -89,7 +89,7 @@ func decodeBalances(encoded []byte) (balances, uint64, error) {
89
89
  if encoded == nil {
90
90
  return nil, 0, nil
91
91
  }
92
- balanceUpdate := vbankBalanceUpdate{}
92
+ balanceUpdate := VbankBalanceUpdate{}
93
93
  err := json.Unmarshal(encoded, &balanceUpdate)
94
94
  if err != nil {
95
95
  return nil, 0, err
package/x/vibc/alias.go CHANGED
@@ -22,6 +22,6 @@ var (
22
22
 
23
23
  type (
24
24
  Keeper = keeper.Keeper
25
- ScopedKeeper = types.ScopedKeeper
25
+ ScopedKeeper = types.ScopedKeeper
26
26
  MsgSendPacket = types.MsgSendPacket
27
27
  )
@@ -14,7 +14,7 @@ import (
14
14
  )
15
15
 
16
16
  var (
17
- _ vm.PortHandler = Receiver{}
17
+ _ vm.PortHandler = (*Receiver)(nil)
18
18
  _ exported.Acknowledgement = (*rawAcknowledgement)(nil)
19
19
  )
20
20
 
@@ -83,18 +83,28 @@ func (r rawAcknowledgement) Success() bool {
83
83
  return true
84
84
  }
85
85
 
86
- func (ir Receiver) Receive(cctx context.Context, str string) (ret string, err error) {
86
+ // Receive implements vm.PortHandler. It unmarshals the string as JSON text
87
+ // representing an IBC portMessage object. If the resulting type is
88
+ // "IBC_METHOD" it dispatches on method ("sendPacket"/"receiveExecuted"/etc.)
89
+ // and calls the corresponding method of the wrapped ReceiverImpl.
90
+ //
91
+ // Otherwise, it requires the wrapped ReceiverImpl to be a vm.PortHandler
92
+ // and delegates to the Receive method of that PortHandler.
93
+ func (ir Receiver) Receive(cctx context.Context, jsonRequest string) (jsonReply string, err error) {
87
94
  ctx := sdk.UnwrapSDKContext(cctx)
88
95
  impl := ir.impl
89
96
 
90
97
  msg := new(portMessage)
91
- err = json.Unmarshal([]byte(str), &msg)
98
+ err = json.Unmarshal([]byte(jsonRequest), &msg)
92
99
  if err != nil {
93
100
  return "", err
94
101
  }
95
102
 
96
103
  if msg.Type != "IBC_METHOD" {
97
- return "", fmt.Errorf(`channel handler only accepts messages of "type": "IBC_METHOD"`)
104
+ if receiver, ok := impl.(vm.PortHandler); ok {
105
+ return receiver.Receive(cctx, jsonRequest)
106
+ }
107
+ return "", fmt.Errorf(`channel handler only accepts messages of "type": "IBC_METHOD"; got %q`, msg.Type)
98
108
  }
99
109
 
100
110
  switch msg.Method {
@@ -116,7 +126,7 @@ func (ir Receiver) Receive(cctx context.Context, str string) (ret string, err er
116
126
  packet.Sequence = seq
117
127
  bytes, err := json.Marshal(&packet)
118
128
  if err == nil {
119
- ret = string(bytes)
129
+ jsonReply = string(bytes)
120
130
  }
121
131
  }
122
132
 
@@ -153,8 +163,8 @@ func (ir Receiver) Receive(cctx context.Context, str string) (ret string, err er
153
163
  err = fmt.Errorf("unrecognized method %s", msg.Method)
154
164
  }
155
165
 
156
- if ret == "" && err == nil {
157
- ret = "true"
166
+ if jsonReply == "" && err == nil {
167
+ jsonReply = "true"
158
168
  }
159
169
  return
160
170
  }
@@ -421,7 +421,7 @@ func (k Keeper) GetNoDataValue() []byte {
421
421
  return types.EncodedNoDataValue
422
422
  }
423
423
 
424
- func (k Keeper) getIntValue(ctx sdk.Context, path string) (sdkmath.Int, error) {
424
+ func (k Keeper) GetIntValue(ctx sdk.Context, path string) (sdkmath.Int, error) {
425
425
  indexEntry := k.GetEntry(ctx, path)
426
426
  if !indexEntry.HasValue() {
427
427
  return sdk.NewInt(0), nil
@@ -435,11 +435,11 @@ func (k Keeper) getIntValue(ctx sdk.Context, path string) (sdkmath.Int, error) {
435
435
  }
436
436
 
437
437
  func (k Keeper) GetQueueLength(ctx sdk.Context, queuePath string) (sdkmath.Int, error) {
438
- head, err := k.getIntValue(ctx, queuePath+".head")
438
+ head, err := k.GetIntValue(ctx, queuePath+".head")
439
439
  if err != nil {
440
440
  return sdkmath.NewInt(0), err
441
441
  }
442
- tail, err := k.getIntValue(ctx, queuePath+".tail")
442
+ tail, err := k.GetIntValue(ctx, queuePath+".tail")
443
443
  if err != nil {
444
444
  return sdkmath.NewInt(0), err
445
445
  }
@@ -450,12 +450,12 @@ func (k Keeper) GetQueueLength(ctx sdk.Context, queuePath string) (sdkmath.Int,
450
450
  func (k Keeper) PushQueueItem(ctx sdk.Context, queuePath string, value string) error {
451
451
  // Get the current queue tail, defaulting to zero if its vstorage doesn't exist.
452
452
  // The `tail` is the value of the next index to be inserted
453
- tail, err := k.getIntValue(ctx, queuePath+".tail")
453
+ tail, err := k.GetIntValue(ctx, queuePath+".tail")
454
454
  if err != nil {
455
455
  return err
456
456
  }
457
457
 
458
- if tail.Equal(MaxSDKInt) {
458
+ if tail.GTE(MaxSDKInt) {
459
459
  return errors.New(queuePath + " overflow")
460
460
  }
461
461
  nextTail := tail.Add(sdk.NewInt(1))
@@ -0,0 +1,27 @@
1
+ package testing
2
+
3
+ import (
4
+ "fmt"
5
+
6
+ keeper "github.com/Agoric/agoric-sdk/golang/cosmos/x/vstorage/keeper"
7
+ sdk "github.com/cosmos/cosmos-sdk/types"
8
+ )
9
+
10
+ func GetQueueItems(ctx sdk.Context, vstorageKeeper keeper.Keeper, queuePath string) ([]string, error) {
11
+ head, err := vstorageKeeper.GetIntValue(ctx, queuePath+".head")
12
+ if err != nil {
13
+ return nil, err
14
+ }
15
+ tail, err := vstorageKeeper.GetIntValue(ctx, queuePath+".tail")
16
+ if err != nil {
17
+ return nil, err
18
+ }
19
+ length := tail.Sub(head).Int64()
20
+ values := make([]string, length)
21
+ var i int64
22
+ for i = 0; i < length; i++ {
23
+ path := fmt.Sprintf("%s.%s", queuePath, head.Add(sdk.NewInt(i)).String())
24
+ values[i] = vstorageKeeper.GetEntry(ctx, path).StringValue()
25
+ }
26
+ return values, nil
27
+ }
@@ -0,0 +1,13 @@
1
+ package vtransfer
2
+
3
+ import (
4
+ "github.com/Agoric/agoric-sdk/golang/cosmos/x/vtransfer/keeper"
5
+ "github.com/Agoric/agoric-sdk/golang/cosmos/x/vtransfer/types"
6
+ )
7
+
8
+ const (
9
+ ModuleName = types.ModuleName
10
+ StoreKey = types.StoreKey
11
+ )
12
+
13
+ type Keeper = keeper.Keeper
@@ -0,0 +1,39 @@
1
+ package vtransfer
2
+
3
+ import (
4
+ "fmt"
5
+
6
+ "github.com/Agoric/agoric-sdk/golang/cosmos/x/vtransfer/types"
7
+ sdk "github.com/cosmos/cosmos-sdk/types"
8
+ abci "github.com/tendermint/tendermint/abci/types"
9
+ )
10
+
11
+ func NewGenesisState() *types.GenesisState {
12
+ return &types.GenesisState{}
13
+ }
14
+
15
+ func ValidateGenesis(data *types.GenesisState) error {
16
+ if data == nil {
17
+ return fmt.Errorf("vtransfer genesis data cannot be nil")
18
+ }
19
+ return nil
20
+ }
21
+
22
+ func DefaultGenesisState() *types.GenesisState {
23
+ return &types.GenesisState{}
24
+ }
25
+
26
+ func InitGenesis(ctx sdk.Context, keeper Keeper, data *types.GenesisState) []abci.ValidatorUpdate {
27
+ keeper.SetWatchedAddresses(ctx, data.GetWatchedAddresses())
28
+ return []abci.ValidatorUpdate{}
29
+ }
30
+
31
+ func ExportGenesis(ctx sdk.Context, k Keeper) *types.GenesisState {
32
+ var gs types.GenesisState
33
+ addresses, err := k.GetWatchedAddresses(ctx)
34
+ if err != nil {
35
+ panic(err)
36
+ }
37
+ gs.WatchedAddresses = addresses
38
+ return &gs
39
+ }
@@ -0,0 +1,12 @@
1
+ package vtransfer
2
+
3
+ import (
4
+ "testing"
5
+ )
6
+
7
+ func TestDefaultGenesis(t *testing.T) {
8
+ defaultGenesisState := DefaultGenesisState()
9
+ if err := ValidateGenesis(defaultGenesisState); err != nil {
10
+ t.Errorf("DefaultGenesisState did not validate %v: %e", defaultGenesisState, err)
11
+ }
12
+ }
@@ -0,0 +1,20 @@
1
+ package vtransfer
2
+
3
+ import (
4
+ "fmt"
5
+
6
+ "github.com/Agoric/agoric-sdk/golang/cosmos/x/vtransfer/keeper"
7
+ sdk "github.com/cosmos/cosmos-sdk/types"
8
+ sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
9
+ )
10
+
11
+ // NewHandler returns a handler for "vtransfer" type messages.
12
+ func NewHandler(keeper keeper.Keeper) sdk.Handler {
13
+ return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
14
+ switch msg := msg.(type) {
15
+ default:
16
+ errMsg := fmt.Sprintf("Unrecognized vtransfer Msg type: %T", msg)
17
+ return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg)
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,186 @@
1
+ package vtransfer
2
+
3
+ import (
4
+ "github.com/Agoric/agoric-sdk/golang/cosmos/x/vtransfer/keeper"
5
+ sdk "github.com/cosmos/cosmos-sdk/types"
6
+ capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
7
+ clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types"
8
+ channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types"
9
+ porttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types"
10
+ "github.com/cosmos/ibc-go/v6/modules/core/exported"
11
+ )
12
+
13
+ // IBCMiddleware (https://ibc.cosmos.network/main/ibc/apps/ibcmodule) forwards
14
+ // most of its methods to the next layer in the stack (which may be the ibc-go
15
+ // transfer application or another middleware), but hooks the packet-related
16
+ // methods and sends them to vtransferKeeper for async interception by the
17
+ // associated VM:
18
+ //
19
+ // 1. IBCModule channel handshake callbacks (OnChanOpenInit, OnChanOpenTry,
20
+ // OnChanOpenAck, and OnChanOpenConfirm)—handled by the wrapped IBCModule.
21
+ //
22
+ // 2. IBCModule channel closing callbacks (OnChanCloseInit and
23
+ // OnChanCloseConfirm)—handled by the wrapped IBCModule.
24
+ //
25
+ // 3. IBCModule packet callbacks (OnRecvPacket, OnAcknowledgementPacket, and
26
+ // OnTimeoutPacket)—intercepted by vtransfer.
27
+ //
28
+ // 4. ICS4Wrapper packet initiation methods (SendPacket, WriteAcknowledgement
29
+ // and GetAppVersion)—delegated by vtransfer to vibc.
30
+
31
+ var _ porttypes.Middleware = (*IBCMiddleware)(nil)
32
+
33
+ // IBCMiddleware implements the ICS26 callbacks for the middleware given the
34
+ // underlying IBCModule and the keeper.
35
+ type IBCMiddleware struct {
36
+ ibcModule porttypes.IBCModule
37
+ vtransferKeeper keeper.Keeper
38
+ }
39
+
40
+ // NewIBCMiddleware creates a new IBCMiddleware given the underlying IBCModule and keeper.
41
+ func NewIBCMiddleware(ibcModule porttypes.IBCModule, vtransferKeeper keeper.Keeper) IBCMiddleware {
42
+ return IBCMiddleware{
43
+ ibcModule: ibcModule,
44
+ vtransferKeeper: vtransferKeeper,
45
+ }
46
+ }
47
+
48
+ ///////////////////////////////////
49
+ // The following channel handshake events are all directly forwarded to the
50
+ // wrapped IBCModule. They are not performed in the context of a packet, and so
51
+ // do not need to be intercepted.
52
+
53
+ // OnChanCloseInit implements the IBCModule interface.
54
+ func (im IBCMiddleware) OnChanOpenInit(
55
+ ctx sdk.Context,
56
+ order channeltypes.Order,
57
+ connectionHops []string,
58
+ portID string,
59
+ channelID string,
60
+ chanCap *capabilitytypes.Capability,
61
+ counterparty channeltypes.Counterparty,
62
+ version string,
63
+ ) (string, error) {
64
+ return im.ibcModule.OnChanOpenInit(ctx, order, connectionHops, portID, channelID, chanCap, counterparty, version)
65
+ }
66
+
67
+ // OnChanOpenTry implements the IBCModule interface.
68
+ func (im IBCMiddleware) OnChanOpenTry(
69
+ ctx sdk.Context,
70
+ order channeltypes.Order,
71
+ connectionHops []string,
72
+ portID,
73
+ channelID string,
74
+ chanCap *capabilitytypes.Capability,
75
+ counterparty channeltypes.Counterparty,
76
+ counterpartyVersion string,
77
+ ) (string, error) {
78
+ return im.ibcModule.OnChanOpenTry(ctx, order, connectionHops, portID, channelID, chanCap, counterparty, counterpartyVersion)
79
+ }
80
+
81
+ // OnChanOpenAck implements the IBCModule interface.
82
+ func (im IBCMiddleware) OnChanOpenAck(
83
+ ctx sdk.Context,
84
+ portID,
85
+ channelID string,
86
+ counterpartyChannelID string,
87
+ counterpartyVersion string,
88
+ ) error {
89
+ return im.ibcModule.OnChanOpenAck(ctx, portID, channelID, counterpartyChannelID, counterpartyVersion)
90
+ }
91
+
92
+ // OnChanOpenConfirm implements the IBCModule interface.
93
+ func (im IBCMiddleware) OnChanOpenConfirm(
94
+ ctx sdk.Context,
95
+ portID,
96
+ channelID string,
97
+ ) error {
98
+ return im.ibcModule.OnChanOpenConfirm(ctx, portID, channelID)
99
+ }
100
+
101
+ // OnChanCloseInit implements the IBCModule interface.
102
+ func (im IBCMiddleware) OnChanCloseInit(
103
+ ctx sdk.Context,
104
+ portID,
105
+ channelID string,
106
+ ) error {
107
+ return im.ibcModule.OnChanCloseInit(ctx, portID, channelID)
108
+ }
109
+
110
+ // OnChanCloseConfirm implements the IBCModule interface.
111
+ func (im IBCMiddleware) OnChanCloseConfirm(
112
+ ctx sdk.Context,
113
+ portID,
114
+ channelID string,
115
+ ) error {
116
+ return im.ibcModule.OnChanCloseConfirm(ctx, portID, channelID)
117
+ }
118
+
119
+ ///////////////////////////////////
120
+ // The following packet methods are all implemented by
121
+ // im.vtransferKeeper.Intercept*, so named because those methods are "tee"s
122
+ // combining the middleware stack with an interception of the packet event
123
+ // (On*Packet) or packet method (WriteAcknowledgment) by the async VM.
124
+
125
+ // OnRecvPacket implements the IBCModule interface.
126
+ func (im IBCMiddleware) OnRecvPacket(
127
+ ctx sdk.Context,
128
+ packet channeltypes.Packet,
129
+ relayer sdk.AccAddress,
130
+ ) exported.Acknowledgement {
131
+ return im.vtransferKeeper.InterceptOnRecvPacket(ctx, im.ibcModule, packet, relayer)
132
+ }
133
+
134
+ // OnAcknowledgementPacket implements the IBCModule interface.
135
+ func (im IBCMiddleware) OnAcknowledgementPacket(
136
+ ctx sdk.Context,
137
+ packet channeltypes.Packet,
138
+ acknowledgement []byte,
139
+ relayer sdk.AccAddress,
140
+ ) error {
141
+ return im.vtransferKeeper.InterceptOnAcknowledgementPacket(ctx, im.ibcModule, packet, acknowledgement, relayer)
142
+ }
143
+
144
+ // OnTimeoutPacket implements the IBCModule interface.
145
+ func (im IBCMiddleware) OnTimeoutPacket(
146
+ ctx sdk.Context,
147
+ packet channeltypes.Packet,
148
+ relayer sdk.AccAddress,
149
+ ) error {
150
+ return im.vtransferKeeper.InterceptOnTimeoutPacket(ctx, im.ibcModule, packet, relayer)
151
+ }
152
+
153
+ // WriteAcknowledgement implements the ICS4 Wrapper interface.
154
+ // Unlike implementations of IBCModule interface methods, implementations of
155
+ // ICS4 Wrapper interface methods do not pass along the wrapped IBC module
156
+ // because they support packet initiation.
157
+ func (im IBCMiddleware) WriteAcknowledgement(
158
+ ctx sdk.Context,
159
+ chanCap *capabilitytypes.Capability,
160
+ packet exported.PacketI,
161
+ ack exported.Acknowledgement,
162
+ ) error {
163
+ return im.vtransferKeeper.InterceptWriteAcknowledgement(ctx, chanCap, packet, ack)
164
+ }
165
+
166
+ ///////////////////////////////////
167
+ // The following methods are directly implemented by the ICS4Wrapper outside of
168
+ // us, whether the ibc-go stack or another middleware.
169
+
170
+ // SendPacket implements the ICS4 Wrapper interface.
171
+ func (im IBCMiddleware) SendPacket(
172
+ ctx sdk.Context,
173
+ chanCap *capabilitytypes.Capability,
174
+ sourcePort string,
175
+ sourceChannel string,
176
+ timeoutHeight clienttypes.Height,
177
+ timeoutTimestamp uint64,
178
+ data []byte,
179
+ ) (uint64, error) {
180
+ return im.vtransferKeeper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data)
181
+ }
182
+
183
+ // GetAppVersion implements the ICS4 Wrapper interface.
184
+ func (im IBCMiddleware) GetAppVersion(ctx sdk.Context, portID, channelID string) (string, bool) {
185
+ return im.vtransferKeeper.GetAppVersion(ctx, portID, channelID)
186
+ }