@agoric/cosmos 0.35.0-upgrade-14-dev-c8f9e7b.0 → 0.35.0-upgrade-16a-dev-fb592e4.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.
- package/CHANGELOG.md +121 -77
- package/MAINTAINERS.md +3 -0
- package/Makefile +36 -26
- package/ante/ante.go +7 -9
- package/ante/inbound_test.go +3 -2
- package/ante/vm_admission.go +2 -1
- package/app/app.go +212 -140
- package/app/upgrade.go +76 -0
- package/cmd/agd/agvm.go +42 -0
- package/cmd/agd/main.go +130 -11
- package/cmd/libdaemon/main.go +64 -53
- package/cmd/libdaemon/main_test.go +2 -1
- package/daemon/cmd/root.go +171 -74
- package/daemon/cmd/root_test.go +189 -1
- package/daemon/main.go +4 -2
- package/e2e_test/Makefile +29 -0
- package/e2e_test/README.md +100 -0
- package/e2e_test/go.mod +217 -0
- package/e2e_test/go.sum +1323 -0
- package/e2e_test/ibc_conformance_test.go +56 -0
- package/e2e_test/pfm_test.go +613 -0
- package/e2e_test/util.go +271 -0
- package/git-revision.txt +1 -1
- package/go.mod +22 -11
- package/go.sum +17 -13
- package/package.json +9 -5
- package/proto/agoric/swingset/genesis.proto +4 -0
- package/proto/agoric/swingset/swingset.proto +1 -1
- package/proto/agoric/vlocalchain/.clang-format +7 -0
- package/proto/agoric/vlocalchain/vlocalchain.proto +31 -0
- package/proto/agoric/vtransfer/genesis.proto +18 -0
- package/scripts/protocgen.sh +7 -8
- package/types/kv_entry_helpers.go +42 -0
- package/upgradegaia.sh +8 -8
- package/vm/action.go +5 -4
- package/vm/action_test.go +31 -11
- package/vm/client.go +113 -0
- package/vm/client_test.go +182 -0
- package/vm/controller.go +17 -40
- package/vm/core_proposals.go +22 -2
- package/vm/jsonrpcconn/jsonrpcconn.go +160 -0
- package/vm/jsonrpcconn/jsonrpcconn_test.go +126 -0
- package/vm/proto_json.go +38 -0
- package/vm/proto_json_test.go +103 -0
- package/vm/server.go +124 -0
- package/x/swingset/abci.go +10 -10
- package/x/swingset/alias.go +2 -0
- package/x/swingset/client/cli/tx.go +4 -0
- package/x/swingset/genesis.go +84 -24
- package/x/swingset/handler.go +2 -1
- package/x/swingset/keeper/extension_snapshotter.go +2 -2
- package/x/swingset/keeper/keeper.go +13 -25
- package/x/swingset/keeper/msg_server.go +18 -18
- package/x/swingset/keeper/proposal.go +3 -3
- package/x/swingset/keeper/querier.go +12 -11
- package/x/swingset/keeper/swing_store_exports_handler.go +21 -6
- package/x/swingset/keeper/test_utils.go +16 -0
- package/x/swingset/module.go +7 -7
- package/x/swingset/proposal_handler.go +2 -1
- package/x/swingset/testing/queue.go +17 -0
- package/x/swingset/types/default-params.go +1 -1
- package/x/swingset/types/expected_keepers.go +3 -2
- package/x/swingset/types/genesis.pb.go +78 -25
- package/x/swingset/types/msgs.go +44 -24
- package/x/swingset/types/params.go +2 -1
- package/x/swingset/types/proposal.go +5 -4
- package/x/swingset/types/swingset.pb.go +1 -1
- package/x/vbank/genesis.go +0 -2
- package/x/vbank/handler.go +2 -1
- package/x/vbank/keeper/querier.go +4 -3
- package/x/vbank/module.go +0 -5
- package/x/vbank/types/msgs.go +0 -12
- package/x/vbank/vbank.go +9 -9
- package/x/vbank/vbank_test.go +2 -2
- package/x/vibc/alias.go +3 -0
- package/x/vibc/handler.go +16 -9
- package/x/vibc/keeper/keeper.go +102 -65
- package/x/vibc/keeper/triggers.go +101 -0
- package/x/vibc/module.go +5 -8
- package/x/vibc/types/expected_keepers.go +13 -0
- package/x/vibc/types/ibc_module.go +336 -0
- package/x/vibc/types/receiver.go +170 -0
- package/x/vlocalchain/alias.go +19 -0
- package/x/vlocalchain/handler.go +21 -0
- package/x/vlocalchain/keeper/keeper.go +279 -0
- package/x/vlocalchain/keeper/keeper_test.go +97 -0
- package/x/vlocalchain/types/codec.go +34 -0
- package/x/vlocalchain/types/key.go +27 -0
- package/x/vlocalchain/types/msgs.go +16 -0
- package/x/vlocalchain/types/vlocalchain.pb.go +1072 -0
- package/x/vlocalchain/vlocalchain.go +114 -0
- package/x/vlocalchain/vlocalchain_test.go +434 -0
- package/x/vstorage/handler.go +2 -1
- package/x/vstorage/keeper/grpc_query.go +0 -1
- package/x/vstorage/keeper/keeper.go +13 -20
- package/x/vstorage/keeper/querier.go +6 -5
- package/x/vstorage/keeper/querier_test.go +4 -3
- package/x/vstorage/module.go +0 -5
- package/x/vstorage/testing/queue.go +27 -0
- package/x/vtransfer/alias.go +13 -0
- package/x/vtransfer/genesis.go +39 -0
- package/x/vtransfer/genesis_test.go +12 -0
- package/x/vtransfer/handler.go +20 -0
- package/x/vtransfer/ibc_middleware.go +186 -0
- package/x/vtransfer/ibc_middleware_test.go +448 -0
- package/x/vtransfer/keeper/keeper.go +281 -0
- package/x/vtransfer/module.go +124 -0
- package/x/vtransfer/types/expected_keepers.go +38 -0
- package/x/vtransfer/types/genesis.pb.go +327 -0
- package/x/vtransfer/types/key.go +9 -0
- package/x/vtransfer/types/msgs.go +9 -0
- package/ante/fee.go +0 -96
- package/proto/agoric/lien/genesis.proto +0 -25
- package/proto/agoric/lien/lien.proto +0 -25
- package/x/lien/alias.go +0 -17
- package/x/lien/genesis.go +0 -58
- package/x/lien/genesis_test.go +0 -101
- package/x/lien/keeper/account.go +0 -290
- package/x/lien/keeper/keeper.go +0 -255
- package/x/lien/keeper/keeper_test.go +0 -623
- package/x/lien/lien.go +0 -205
- package/x/lien/lien_test.go +0 -533
- package/x/lien/module.go +0 -115
- package/x/lien/spec/01_concepts.md +0 -146
- package/x/lien/spec/02_messages.md +0 -96
- package/x/lien/types/accountkeeper.go +0 -81
- package/x/lien/types/accountstate.go +0 -27
- package/x/lien/types/expected_keepers.go +0 -18
- package/x/lien/types/genesis.pb.go +0 -567
- package/x/lien/types/key.go +0 -25
- package/x/lien/types/lien.pb.go +0 -403
- package/x/vibc/ibc.go +0 -394
- /package/{src/index.cjs → index.cjs} +0 -0
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
package keeper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"encoding/json"
|
|
6
|
+
|
|
7
|
+
"github.com/cosmos/cosmos-sdk/codec"
|
|
8
|
+
"github.com/cosmos/cosmos-sdk/store/prefix"
|
|
9
|
+
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
|
10
|
+
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
11
|
+
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
12
|
+
|
|
13
|
+
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
|
|
14
|
+
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
|
|
15
|
+
|
|
16
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
|
|
17
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vibc"
|
|
18
|
+
vibctypes "github.com/Agoric/agoric-sdk/golang/cosmos/x/vibc/types"
|
|
19
|
+
transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types"
|
|
20
|
+
channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types"
|
|
21
|
+
porttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types"
|
|
22
|
+
host "github.com/cosmos/ibc-go/v6/modules/core/24-host"
|
|
23
|
+
ibcexported "github.com/cosmos/ibc-go/v6/modules/core/exported"
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
var _ porttypes.ICS4Wrapper = (*Keeper)(nil)
|
|
27
|
+
var _ vibctypes.ReceiverImpl = (*Keeper)(nil)
|
|
28
|
+
var _ vm.PortHandler = (*Keeper)(nil)
|
|
29
|
+
|
|
30
|
+
// "watched addresses" is logically a set and physically a collection of
|
|
31
|
+
// KVStore entries in which each key is a concatenation of a fixed prefix and
|
|
32
|
+
// the address, and its corresponding value is a non-empty but otherwise irrelevant
|
|
33
|
+
// sentinel.
|
|
34
|
+
const (
|
|
35
|
+
watchedAddressStoreKeyPrefix = "watchedAddress/"
|
|
36
|
+
watchedAddressSentinel = "y"
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
// Keeper handles the interceptions from the vtransfer IBC middleware, passing
|
|
40
|
+
// them to the embedded vibc keeper if they involve a targeted address (which is
|
|
41
|
+
// an address associated with a VM listener). The embedded vibc keeper is used
|
|
42
|
+
// to bridge calls to swingset, but with a special wrapper on the bridge
|
|
43
|
+
// controller to use distinct action types. The keeper keeps a store of
|
|
44
|
+
// "targeted addresses", managed from Swingset by bridge messages.
|
|
45
|
+
type Keeper struct {
|
|
46
|
+
porttypes.ICS4Wrapper
|
|
47
|
+
vibctypes.ReceiverImpl
|
|
48
|
+
|
|
49
|
+
vibcKeeper vibc.Keeper
|
|
50
|
+
|
|
51
|
+
key storetypes.StoreKey
|
|
52
|
+
cdc codec.Codec
|
|
53
|
+
|
|
54
|
+
vibcModule porttypes.IBCModule
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// NewKeeper creates a new vtransfer Keeper instance
|
|
58
|
+
func NewKeeper(
|
|
59
|
+
cdc codec.Codec,
|
|
60
|
+
key storetypes.StoreKey,
|
|
61
|
+
prototypeVibcKeeper vibc.Keeper,
|
|
62
|
+
scopedTransferKeeper capabilitykeeper.ScopedKeeper,
|
|
63
|
+
pushAction vm.ActionPusher,
|
|
64
|
+
) Keeper {
|
|
65
|
+
wrappedPushAction := wrapActionPusher(pushAction)
|
|
66
|
+
|
|
67
|
+
// This vibcKeeper is used to send notifications from the vtransfer middleware
|
|
68
|
+
// to the VM.
|
|
69
|
+
vibcKeeper := prototypeVibcKeeper.WithScope(nil, scopedTransferKeeper, wrappedPushAction)
|
|
70
|
+
return Keeper{
|
|
71
|
+
ICS4Wrapper: vibcKeeper,
|
|
72
|
+
ReceiverImpl: vibcKeeper,
|
|
73
|
+
|
|
74
|
+
vibcKeeper: vibcKeeper,
|
|
75
|
+
key: key,
|
|
76
|
+
vibcModule: vibc.NewIBCModule(vibcKeeper),
|
|
77
|
+
cdc: cdc,
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// wrapActionPusher wraps an ActionPusher to prefix the action type with
|
|
82
|
+
// "VTRANSFER_".
|
|
83
|
+
func wrapActionPusher(pusher vm.ActionPusher) vm.ActionPusher {
|
|
84
|
+
return func(ctx sdk.Context, action vm.Action) error {
|
|
85
|
+
action = vm.PopulateAction(ctx, action)
|
|
86
|
+
|
|
87
|
+
// Prefix the action type.
|
|
88
|
+
ah := action.GetActionHeader()
|
|
89
|
+
ah.Type = "VTRANSFER_" + ah.Type
|
|
90
|
+
|
|
91
|
+
// fmt.Println("@@@ vtransfer action", action)
|
|
92
|
+
return pusher(ctx, action)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
func (k Keeper) GetICS4Wrapper() porttypes.ICS4Wrapper {
|
|
97
|
+
return k
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
func (k Keeper) GetReceiverImpl() vibctypes.ReceiverImpl {
|
|
101
|
+
return k
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// InterceptOnRecvPacket runs the ibcModule and eventually acknowledges a packet.
|
|
105
|
+
// Many error acknowledgments are sent synchronously, but most cases instead return nil
|
|
106
|
+
// to tell the IBC system that acknowledgment is async (i.e., that WriteAcknowledgement
|
|
107
|
+
// will be called later, after the VM has dealt with the packet).
|
|
108
|
+
func (k Keeper) InterceptOnRecvPacket(ctx sdk.Context, ibcModule porttypes.IBCModule, packet channeltypes.Packet, relayer sdk.AccAddress) ibcexported.Acknowledgement {
|
|
109
|
+
ack := ibcModule.OnRecvPacket(ctx, packet, relayer)
|
|
110
|
+
|
|
111
|
+
if ack == nil {
|
|
112
|
+
// Already declared to be an async ack.
|
|
113
|
+
return nil
|
|
114
|
+
}
|
|
115
|
+
portID := packet.GetDestPort()
|
|
116
|
+
channelID := packet.GetDestChannel()
|
|
117
|
+
capName := host.ChannelCapabilityPath(portID, channelID)
|
|
118
|
+
chanCap, ok := k.vibcKeeper.GetCapability(ctx, capName)
|
|
119
|
+
if !ok {
|
|
120
|
+
err := sdkerrors.Wrapf(channeltypes.ErrChannelCapabilityNotFound, "could not retrieve channel capability at: %s", capName)
|
|
121
|
+
return channeltypes.NewErrorAcknowledgement(err)
|
|
122
|
+
}
|
|
123
|
+
// Give the VM a chance to write (or override) the ack.
|
|
124
|
+
if err := k.InterceptWriteAcknowledgement(ctx, chanCap, packet, ack); err != nil {
|
|
125
|
+
return channeltypes.NewErrorAcknowledgement(err)
|
|
126
|
+
}
|
|
127
|
+
return nil
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// InterceptOnAcknowledgementPacket checks to see if the packet sender is a
|
|
131
|
+
// targeted account, and if so, delegates to the VM.
|
|
132
|
+
func (k Keeper) InterceptOnAcknowledgementPacket(
|
|
133
|
+
ctx sdk.Context,
|
|
134
|
+
ibcModule porttypes.IBCModule,
|
|
135
|
+
packet channeltypes.Packet,
|
|
136
|
+
acknowledgement []byte,
|
|
137
|
+
relayer sdk.AccAddress,
|
|
138
|
+
) error {
|
|
139
|
+
// Pass every acknowledgement to the wrapped IBC module.
|
|
140
|
+
modErr := ibcModule.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer)
|
|
141
|
+
|
|
142
|
+
// If the sender is not a targeted account, we're done.
|
|
143
|
+
sender, _, err := k.parseTransfer(ctx, packet)
|
|
144
|
+
if err != nil || sender == "" {
|
|
145
|
+
return modErr
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Trigger VM, regardless of errors in the ibcModule.
|
|
149
|
+
vmErr := k.vibcKeeper.TriggerOnAcknowledgementPacket(ctx, sender, packet, acknowledgement, relayer)
|
|
150
|
+
|
|
151
|
+
// Any error from the VM is trumped by one from the wrapped IBC module.
|
|
152
|
+
if modErr != nil {
|
|
153
|
+
return modErr
|
|
154
|
+
}
|
|
155
|
+
return vmErr
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// InterceptOnTimeoutPacket checks to see if the packet sender is a targeted
|
|
159
|
+
// account, and if so, delegates to the VM.
|
|
160
|
+
func (k Keeper) InterceptOnTimeoutPacket(
|
|
161
|
+
ctx sdk.Context,
|
|
162
|
+
ibcModule porttypes.IBCModule,
|
|
163
|
+
packet channeltypes.Packet,
|
|
164
|
+
relayer sdk.AccAddress,
|
|
165
|
+
) error {
|
|
166
|
+
// Pass every timeout to the wrapped IBC module.
|
|
167
|
+
modErr := ibcModule.OnTimeoutPacket(ctx, packet, relayer)
|
|
168
|
+
|
|
169
|
+
// If the sender is not a targeted account, we're done.
|
|
170
|
+
sender, _, err := k.parseTransfer(ctx, packet)
|
|
171
|
+
if err != nil || sender == "" {
|
|
172
|
+
return modErr
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Trigger VM, regardless of errors in the app.
|
|
176
|
+
vmErr := k.vibcKeeper.TriggerOnTimeoutPacket(ctx, sender, packet, relayer)
|
|
177
|
+
|
|
178
|
+
// Any error from the VM is trumped by one from the wrapped IBC module.
|
|
179
|
+
if modErr != nil {
|
|
180
|
+
return modErr
|
|
181
|
+
}
|
|
182
|
+
return vmErr
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// InterceptWriteAcknowledgement checks to see if the packet's receiver is a
|
|
186
|
+
// targeted account, and if so, delegates to the VM.
|
|
187
|
+
func (k Keeper) InterceptWriteAcknowledgement(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI, ack ibcexported.Acknowledgement) error {
|
|
188
|
+
_, receiver, err := k.parseTransfer(ctx, packet)
|
|
189
|
+
if err != nil || receiver == "" {
|
|
190
|
+
// We can't parse, but that means just to ack directly.
|
|
191
|
+
return k.WriteAcknowledgement(ctx, chanCap, packet, ack)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Trigger VM
|
|
195
|
+
if err = k.vibcKeeper.TriggerWriteAcknowledgement(ctx, receiver, packet, ack); err != nil {
|
|
196
|
+
errAck := channeltypes.NewErrorAcknowledgement(err)
|
|
197
|
+
return k.WriteAcknowledgement(ctx, chanCap, packet, errAck)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return nil
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// parseTransfer checks if a packet's sender and/or receiver are targeted accounts.
|
|
204
|
+
func (k Keeper) parseTransfer(ctx sdk.Context, packet ibcexported.PacketI) (string, string, error) {
|
|
205
|
+
var transferData transfertypes.FungibleTokenPacketData
|
|
206
|
+
err := k.cdc.UnmarshalJSON(packet.GetData(), &transferData)
|
|
207
|
+
if err != nil {
|
|
208
|
+
return "", "", err
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
var sender string
|
|
212
|
+
var receiver string
|
|
213
|
+
prefixStore := prefix.NewStore(
|
|
214
|
+
ctx.KVStore(k.key),
|
|
215
|
+
[]byte(watchedAddressStoreKeyPrefix),
|
|
216
|
+
)
|
|
217
|
+
if prefixStore.Has([]byte(transferData.Sender)) {
|
|
218
|
+
sender = transferData.Sender
|
|
219
|
+
}
|
|
220
|
+
if prefixStore.Has([]byte(transferData.Receiver)) {
|
|
221
|
+
receiver = transferData.Receiver
|
|
222
|
+
}
|
|
223
|
+
return sender, receiver, nil
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// GetWatchedAdresses returns the watched addresses from the keeper as a slice
|
|
227
|
+
// of account addresses.
|
|
228
|
+
func (k Keeper) GetWatchedAddresses(ctx sdk.Context) ([]sdk.AccAddress, error) {
|
|
229
|
+
addresses := make([]sdk.AccAddress, 0)
|
|
230
|
+
prefixStore := prefix.NewStore(ctx.KVStore(k.key), []byte(watchedAddressStoreKeyPrefix))
|
|
231
|
+
iterator := sdk.KVStorePrefixIterator(prefixStore, []byte{})
|
|
232
|
+
defer iterator.Close()
|
|
233
|
+
for ; iterator.Valid(); iterator.Next() {
|
|
234
|
+
addr, err := sdk.AccAddressFromBech32(string(iterator.Key()))
|
|
235
|
+
if err != nil {
|
|
236
|
+
return nil, err
|
|
237
|
+
}
|
|
238
|
+
addresses = append(addresses, addr)
|
|
239
|
+
}
|
|
240
|
+
return addresses, nil
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// SetWatchedAddresses sets the watched addresses in the keeper from a slice of
|
|
244
|
+
// SDK account addresses.
|
|
245
|
+
func (k Keeper) SetWatchedAddresses(ctx sdk.Context, addresses []sdk.AccAddress) {
|
|
246
|
+
prefixStore := prefix.NewStore(
|
|
247
|
+
ctx.KVStore(k.key),
|
|
248
|
+
[]byte(watchedAddressStoreKeyPrefix),
|
|
249
|
+
)
|
|
250
|
+
for _, addr := range addresses {
|
|
251
|
+
prefixStore.Set([]byte(addr.String()), []byte(watchedAddressSentinel))
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
type registrationAction struct {
|
|
256
|
+
Type string `json:"type"` // BRIDGE_TARGET_REGISTER or BRIDGE_TARGET_UNREGISTER
|
|
257
|
+
Target string `json:"target"`
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Receive implements the vm.PortHandler interface.
|
|
261
|
+
func (k Keeper) Receive(cctx context.Context, jsonRequest string) (jsonReply string, err error) {
|
|
262
|
+
ctx := sdk.UnwrapSDKContext(cctx)
|
|
263
|
+
var msg registrationAction
|
|
264
|
+
if err := json.Unmarshal([]byte(jsonRequest), &msg); err != nil {
|
|
265
|
+
return "", err
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
prefixStore := prefix.NewStore(
|
|
269
|
+
ctx.KVStore(k.key),
|
|
270
|
+
[]byte(watchedAddressStoreKeyPrefix),
|
|
271
|
+
)
|
|
272
|
+
switch msg.Type {
|
|
273
|
+
case "BRIDGE_TARGET_REGISTER":
|
|
274
|
+
prefixStore.Set([]byte(msg.Target), []byte(watchedAddressSentinel))
|
|
275
|
+
case "BRIDGE_TARGET_UNREGISTER":
|
|
276
|
+
prefixStore.Delete([]byte(msg.Target))
|
|
277
|
+
default:
|
|
278
|
+
return "", sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown action type: %s", msg.Type)
|
|
279
|
+
}
|
|
280
|
+
return "true", nil
|
|
281
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
package vtransfer
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"encoding/json"
|
|
5
|
+
|
|
6
|
+
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
|
7
|
+
"github.com/spf13/cobra"
|
|
8
|
+
|
|
9
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vtransfer/types"
|
|
10
|
+
"github.com/cosmos/cosmos-sdk/client"
|
|
11
|
+
"github.com/cosmos/cosmos-sdk/codec"
|
|
12
|
+
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
|
|
13
|
+
"github.com/cosmos/cosmos-sdk/types/module"
|
|
14
|
+
|
|
15
|
+
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
16
|
+
abci "github.com/tendermint/tendermint/abci/types"
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
// type check to ensure the interface is properly implemented
|
|
20
|
+
var (
|
|
21
|
+
_ module.AppModule = AppModule{}
|
|
22
|
+
_ module.AppModuleBasic = AppModuleBasic{}
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
// app module Basics object
|
|
26
|
+
type AppModuleBasic struct {
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
func (AppModuleBasic) Name() string {
|
|
30
|
+
return ModuleName
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// RegisterInterfaces registers the module's interface types
|
|
37
|
+
func (b AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// DefaultGenesis returns default genesis state as raw bytes for the deployment
|
|
41
|
+
func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
|
|
42
|
+
return cdc.MustMarshalJSON(DefaultGenesisState())
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Validation check of the Genesis
|
|
46
|
+
func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error {
|
|
47
|
+
var data types.GenesisState
|
|
48
|
+
err := cdc.UnmarshalJSON(bz, &data)
|
|
49
|
+
if err != nil {
|
|
50
|
+
return err
|
|
51
|
+
}
|
|
52
|
+
// Once json successfully marshalled, passes along to genesis.go
|
|
53
|
+
return ValidateGenesis(&data)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Get the root query command of this module
|
|
60
|
+
func (AppModuleBasic) GetQueryCmd() *cobra.Command {
|
|
61
|
+
return nil
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Get the root tx command of this module
|
|
65
|
+
func (AppModuleBasic) GetTxCmd() *cobra.Command {
|
|
66
|
+
return nil
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
type AppModule struct {
|
|
70
|
+
AppModuleBasic
|
|
71
|
+
keeper Keeper
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// NewAppModule creates a new AppModule Object
|
|
75
|
+
func NewAppModule(k Keeper) AppModule {
|
|
76
|
+
am := AppModule{
|
|
77
|
+
AppModuleBasic: AppModuleBasic{},
|
|
78
|
+
keeper: k,
|
|
79
|
+
}
|
|
80
|
+
return am
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
func (AppModule) Name() string {
|
|
84
|
+
return ModuleName
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {}
|
|
88
|
+
|
|
89
|
+
func (am AppModule) Route() sdk.Route {
|
|
90
|
+
return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper))
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
func (am AppModule) QuerierRoute() string {
|
|
94
|
+
return ModuleName
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// LegacyQuerierHandler returns the sdk.Querier for module
|
|
98
|
+
func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
|
|
99
|
+
return nil
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
func (am AppModule) RegisterServices(cfg module.Configurator) {
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
func (AppModule) ConsensusVersion() uint64 { return 1 }
|
|
106
|
+
|
|
107
|
+
func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate {
|
|
111
|
+
// Prevent Cosmos SDK internal errors.
|
|
112
|
+
return []abci.ValidatorUpdate{}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
|
|
116
|
+
var genesisState types.GenesisState
|
|
117
|
+
cdc.MustUnmarshalJSON(data, &genesisState)
|
|
118
|
+
return InitGenesis(ctx, am.keeper, &genesisState)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
|
122
|
+
gs := ExportGenesis(ctx, am.keeper)
|
|
123
|
+
return cdc.MustMarshalJSON(gs)
|
|
124
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
package types
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
5
|
+
capability "github.com/cosmos/cosmos-sdk/x/capability/types"
|
|
6
|
+
connection "github.com/cosmos/ibc-go/v6/modules/core/03-connection/types"
|
|
7
|
+
channel "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types"
|
|
8
|
+
ibcexported "github.com/cosmos/ibc-go/v6/modules/core/exported"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
// ChannelKeeper defines the expected IBC channel keeper
|
|
12
|
+
type ChannelKeeper interface {
|
|
13
|
+
GetChannel(ctx sdk.Context, srcPort, srcChan string) (channel channel.Channel, found bool)
|
|
14
|
+
GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool)
|
|
15
|
+
SendPacket(ctx sdk.Context, channelCap *capability.Capability, packet ibcexported.PacketI) error
|
|
16
|
+
WriteAcknowledgement(ctx sdk.Context, channelCap *capability.Capability, packet ibcexported.PacketI, acknowledgement ibcexported.Acknowledgement) error
|
|
17
|
+
ChanOpenInit(ctx sdk.Context, order channel.Order, connectionHops []string, portID string,
|
|
18
|
+
portCap *capability.Capability, counterparty channel.Counterparty, version string) (string, *capability.Capability, error)
|
|
19
|
+
WriteOpenInitChannel(ctx sdk.Context, portID, channelID string, order channel.Order,
|
|
20
|
+
connectionHops []string, counterparty channel.Counterparty, version string)
|
|
21
|
+
ChanCloseInit(ctx sdk.Context, portID, channelID string, chanCap *capability.Capability) error
|
|
22
|
+
TimeoutExecuted(ctx sdk.Context, channelCap *capability.Capability, packet ibcexported.PacketI) error
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// ClientKeeper defines the expected IBC client keeper
|
|
26
|
+
type ClientKeeper interface {
|
|
27
|
+
GetClientConsensusState(ctx sdk.Context, clientID string) (connection ibcexported.ConsensusState, found bool)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// ConnectionKeeper defines the expected IBC connection keeper
|
|
31
|
+
type ConnectionKeeper interface {
|
|
32
|
+
GetConnection(ctx sdk.Context, connectionID string) (connection connection.ConnectionEnd, found bool)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// PortKeeper defines the expected IBC port keeper
|
|
36
|
+
type PortKeeper interface {
|
|
37
|
+
BindPort(ctx sdk.Context, portID string) *capability.Capability
|
|
38
|
+
}
|