@agoric/cosmos 0.34.2-dev-3c8aafe.0 → 0.34.2-dev-74fbe43.0.74fbe43
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/Makefile +6 -2
- package/ante/ante.go +2 -2
- package/ante/inbound.go +1 -2
- package/ante/inbound_test.go +3 -1
- package/ante/vm_admission.go +1 -2
- package/app/app.go +256 -174
- package/app/encoding.go +6 -3
- package/app/export.go +50 -21
- package/app/genesis.go +7 -5
- package/app/params/encoding.go +1 -1
- package/app/params/proto.go +6 -4
- package/app/sim_test.go +11 -13
- package/app/txconfig/tx_config.go +169 -0
- package/app/upgrade.go +40 -90
- package/cmd/agd/agvm.go +1 -1
- package/cmd/agd/main.go +1 -1
- package/cmd/libdaemon/main.go +2 -2
- package/daemon/cmd/root.go +99 -30
- package/daemon/cmd/root_test.go +12 -27
- package/daemon/main.go +2 -9
- package/git-revision.txt +1 -1
- package/go.mod +130 -109
- package/go.sum +228 -469
- package/package.json +2 -2
- package/proto/agoric/swingset/msgs.proto +72 -9
- package/proto/agoric/swingset/swingset.proto +7 -2
- package/proto/agoric/vbank/vbank.proto +1 -1
- package/proto/agoric/vibc/msgs.proto +4 -0
- package/scripts/mockgen.sh +4 -0
- package/tests/e2e/vbank/vbank_test.go +172 -0
- package/tests/integrations/types/aminojson_test.go +214 -0
- package/tests/integrations/vbank/vbank_test.go +349 -0
- package/third_party/proto/amino/amino.proto +6 -1
- package/third_party/proto/cosmos/base/v1beta1/coin.proto +18 -5
- package/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto +4 -8
- package/third_party/proto/ibc/core/channel/v1/channel.proto +42 -17
- package/third_party/proto/ibc/core/client/v1/client.proto +48 -40
- package/types/address_hooks.go +2 -2
- package/types/address_hooks_test.go +3 -3
- package/types/ibc_packet.go +3 -3
- package/types/ibc_packet_test.go +3 -3
- package/types/kv_entry_helpers.go +3 -27
- package/types/kv_entry_helpers_test.go +2 -2
- package/types/legacy_address_encoder.go +58 -0
- package/vm/proto_json_test.go +1 -1
- package/vm/server.go +2 -1
- package/x/swingset/abci.go +2 -2
- package/x/swingset/client/cli/tx.go +16 -14
- package/x/swingset/config.go +1 -1
- package/x/swingset/genesis.go +2 -1
- package/x/swingset/handler.go +2 -1
- package/x/swingset/keeper/extension_snapshotter.go +14 -5
- package/x/swingset/keeper/extension_snapshotter_test.go +1 -1
- package/x/swingset/keeper/keeper.go +28 -23
- package/x/swingset/keeper/keeper_test.go +10 -7
- package/x/swingset/keeper/msg_server.go +52 -5
- package/x/swingset/keeper/msg_server_test.go +121 -0
- package/x/swingset/keeper/proposal.go +4 -0
- package/x/swingset/keeper/querier.go +1 -1
- package/x/swingset/keeper/swing_store_exports_handler.go +1 -1
- package/x/swingset/keeper/swing_store_exports_handler_test.go +1 -1
- package/x/swingset/keeper/test_utils.go +2 -2
- package/x/swingset/module.go +20 -22
- package/x/swingset/testing/queue.go +5 -2
- package/x/swingset/testutil/mocks.go +379 -0
- package/x/swingset/types/codec.go +10 -5
- package/x/swingset/types/default-params.go +13 -12
- package/x/swingset/types/expected_keepers.go +29 -4
- package/x/swingset/types/msgs.go +51 -36
- package/x/swingset/types/msgs.pb.go +561 -51
- package/x/swingset/types/params_test.go +21 -20
- package/x/swingset/types/swingset.pb.go +67 -61
- package/x/vbank/genesis.go +13 -9
- package/x/vbank/handler.go +2 -1
- package/x/vbank/keeper/grpc_query.go +4 -1
- package/x/vbank/keeper/keeper.go +108 -23
- package/x/vbank/keeper/querier.go +4 -1
- package/x/vbank/keeper/rewards.go +10 -5
- package/x/vbank/module.go +47 -75
- package/x/vbank/types/expected_keepers.go +15 -10
- package/x/vbank/types/key.go +3 -0
- package/x/vbank/types/params.go +4 -3
- package/x/vbank/types/vbank.pb.go +41 -40
- package/x/vbank/vbank.go +29 -11
- package/x/vbank/vbank_test.go +213 -154
- package/x/vibc/handler.go +2 -1
- package/x/vibc/keeper/keeper.go +10 -10
- package/x/vibc/keeper/migrations.go +1 -1
- package/x/vibc/keeper/triggers.go +1 -1
- package/x/vibc/module.go +5 -22
- package/x/vibc/types/codec.go +2 -1
- package/x/vibc/types/expected_keepers.go +7 -5
- package/x/vibc/types/ibc_module.go +5 -5
- package/x/vibc/types/msgs.go +30 -7
- package/x/vibc/types/msgs.pb.go +29 -25
- package/x/vibc/types/receiver.go +2 -2
- package/x/vlocalchain/handler.go +2 -1
- package/x/vlocalchain/keeper/keeper.go +17 -5
- package/x/vlocalchain/keeper/keeper_test.go +3 -2
- package/x/vlocalchain/types/expected_keepers.go +7 -4
- package/x/vlocalchain/vlocalchain_test.go +38 -26
- package/x/vstorage/genesis.go +10 -10
- package/x/vstorage/handler.go +2 -1
- package/x/vstorage/keeper/grpc_query.go +1 -1
- package/x/vstorage/keeper/keeper.go +72 -50
- package/x/vstorage/keeper/keeper_test.go +74 -54
- package/x/vstorage/keeper/querier.go +1 -1
- package/x/vstorage/module.go +27 -13
- package/x/vstorage/testing/queue.go +5 -3
- package/x/vstorage/vstorage.go +10 -9
- package/x/vstorage/vstorage_test.go +24 -18
- package/x/vtransfer/genesis.go +1 -3
- package/x/vtransfer/handler.go +3 -2
- package/x/vtransfer/ibc_middleware.go +5 -5
- package/x/vtransfer/ibc_middleware_test.go +43 -29
- package/x/vtransfer/keeper/keeper.go +35 -33
- package/x/vtransfer/module.go +8 -11
- package/x/vtransfer/types/expected_keepers.go +3 -3
- package/x/vtransfer/utils_test.go +26 -11
- package/daemon/cmd/testnet.go +0 -539
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/cosmos",
|
|
3
|
-
"version": "0.34.2-dev-
|
|
3
|
+
"version": "0.34.2-dev-74fbe43.0.74fbe43",
|
|
4
4
|
"description": "Connect JS to the Cosmos blockchain SDK",
|
|
5
5
|
"parsers": {
|
|
6
6
|
"js": "mjs"
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"typeCoverage": {
|
|
42
42
|
"atLeast": 0
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "74fbe43eaa40de7e79f074c91b520aa72017514e"
|
|
45
45
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
syntax = "proto3";
|
|
2
2
|
package agoric.swingset;
|
|
3
3
|
|
|
4
|
+
import "amino/amino.proto";
|
|
5
|
+
import "cosmos/msg/v1/msg.proto";
|
|
6
|
+
import "cosmos_proto/cosmos.proto";
|
|
4
7
|
import "gogoproto/gogo.proto";
|
|
5
8
|
|
|
6
9
|
option go_package = "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/types";
|
|
@@ -17,16 +20,30 @@ service Msg {
|
|
|
17
20
|
rpc WalletSpendAction(MsgWalletSpendAction) returns (MsgWalletSpendActionResponse);
|
|
18
21
|
// Provision a new endpoint.
|
|
19
22
|
rpc Provision(MsgProvision) returns (MsgProvisionResponse);
|
|
23
|
+
// Execute a core evaluation.
|
|
24
|
+
rpc CoreEval(MsgCoreEval) returns (MsgCoreEvalResponse);
|
|
20
25
|
}
|
|
21
26
|
|
|
22
27
|
// MsgDeliverInbound defines an SDK message for delivering an eventual send
|
|
23
28
|
message MsgDeliverInbound {
|
|
24
29
|
option (gogoproto.equal) = false;
|
|
30
|
+
option (amino.name) = "swingset/DeliverInbound";
|
|
25
31
|
|
|
26
|
-
repeated string messages
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
repeated string messages = 1 [
|
|
33
|
+
(amino.dont_omitempty) = true,
|
|
34
|
+
(amino.encoding) = "null_slice_as_empty",
|
|
35
|
+
(gogoproto.jsontag) = "messages",
|
|
36
|
+
(gogoproto.moretags) = "yaml:\"messages\""
|
|
37
|
+
];
|
|
38
|
+
repeated uint64 nums = 2 [
|
|
39
|
+
(amino.dont_omitempty) = true,
|
|
40
|
+
(amino.encoding) = "null_slice_as_empty",
|
|
41
|
+
(gogoproto.jsontag) = "nums",
|
|
42
|
+
(gogoproto.moretags) = "yaml:\"nums\""
|
|
43
|
+
];
|
|
44
|
+
uint64 ack = 3 [(amino.dont_omitempty) = true, (gogoproto.jsontag) = "ack", (gogoproto.moretags) = "yaml:\"ack\""];
|
|
45
|
+
bytes submitter = 4 [
|
|
46
|
+
(amino.encoding) = "legacy_address",
|
|
30
47
|
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress",
|
|
31
48
|
(gogoproto.jsontag) = "submitter",
|
|
32
49
|
(gogoproto.moretags) = "yaml:\"submitter\""
|
|
@@ -41,8 +58,10 @@ message MsgDeliverInboundResponse {}
|
|
|
41
58
|
// message type is typically protected by feegrant budgets.
|
|
42
59
|
message MsgWalletAction {
|
|
43
60
|
option (gogoproto.equal) = false;
|
|
61
|
+
option (amino.name) = "swingset/WalletAction";
|
|
44
62
|
|
|
45
63
|
bytes owner = 1 [
|
|
64
|
+
(amino.encoding) = "legacy_address",
|
|
46
65
|
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress",
|
|
47
66
|
(gogoproto.jsontag) = "owner",
|
|
48
67
|
(gogoproto.moretags) = "yaml:\"owner\""
|
|
@@ -60,8 +79,10 @@ message MsgWalletActionResponse {}
|
|
|
60
79
|
// typically protected by explicit confirmation by the user.
|
|
61
80
|
message MsgWalletSpendAction {
|
|
62
81
|
option (gogoproto.equal) = false;
|
|
82
|
+
option (amino.name) = "swingset/WalletSpendAction";
|
|
63
83
|
|
|
64
84
|
bytes owner = 1 [
|
|
85
|
+
(amino.encoding) = "legacy_address",
|
|
65
86
|
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress",
|
|
66
87
|
(gogoproto.jsontag) = "owner",
|
|
67
88
|
(gogoproto.moretags) = "yaml:\"owner\""
|
|
@@ -77,19 +98,25 @@ message MsgWalletSpendActionResponse {}
|
|
|
77
98
|
// MsgProvision defines an SDK message for provisioning a client to the chain
|
|
78
99
|
message MsgProvision {
|
|
79
100
|
option (gogoproto.equal) = false;
|
|
101
|
+
option (amino.name) = "swingset/Provision";
|
|
80
102
|
|
|
81
103
|
string nickname = 1 [(gogoproto.jsontag) = "nickname", (gogoproto.moretags) = "yaml:\"nickname\""];
|
|
82
104
|
bytes address = 2 [
|
|
105
|
+
(amino.encoding) = "legacy_address",
|
|
83
106
|
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress",
|
|
84
107
|
(gogoproto.jsontag) = "address",
|
|
85
108
|
(gogoproto.moretags) = "yaml:\"address\""
|
|
86
109
|
];
|
|
87
110
|
repeated string power_flags = 3 [
|
|
111
|
+
(amino.dont_omitempty) = true,
|
|
112
|
+
(amino.encoding) = "null_slice_as_empty",
|
|
113
|
+
(amino.field_name) = "powerFlags",
|
|
88
114
|
(gogoproto.customname) = "PowerFlags",
|
|
89
115
|
(gogoproto.jsontag) = "powerFlags",
|
|
90
116
|
(gogoproto.moretags) = "yaml:\"powerFlags\""
|
|
91
117
|
];
|
|
92
118
|
bytes submitter = 4 [
|
|
119
|
+
(amino.encoding) = "legacy_address",
|
|
93
120
|
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress",
|
|
94
121
|
(gogoproto.jsontag) = "submitter",
|
|
95
122
|
(gogoproto.moretags) = "yaml:\"submitter\""
|
|
@@ -101,20 +128,56 @@ message MsgProvisionResponse {}
|
|
|
101
128
|
|
|
102
129
|
// MsgInstallBundle carries a signed bundle to SwingSet.
|
|
103
130
|
message MsgInstallBundle {
|
|
104
|
-
|
|
105
|
-
|
|
131
|
+
// Until agoric-upgrade-22 this message didn't have an amino name
|
|
132
|
+
// but no clients actually used amino encoding
|
|
133
|
+
option (amino.name) = "swingset/InstallBundle";
|
|
134
|
+
|
|
135
|
+
string bundle = 1
|
|
136
|
+
[(amino.dont_omitempty) = true, (gogoproto.jsontag) = "bundle", (gogoproto.moretags) = "yaml:\"bundle\""];
|
|
137
|
+
bytes submitter = 2 [
|
|
138
|
+
(amino.encoding) = "legacy_address",
|
|
106
139
|
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress",
|
|
107
140
|
(gogoproto.jsontag) = "submitter",
|
|
108
141
|
(gogoproto.moretags) = "yaml:\"submitter\""
|
|
109
142
|
];
|
|
110
143
|
// Either bundle or compressed_bundle will be set.
|
|
111
144
|
// Default compression algorithm is gzip.
|
|
112
|
-
bytes compressed_bundle = 3
|
|
113
|
-
|
|
145
|
+
bytes compressed_bundle = 3 [
|
|
146
|
+
(amino.dont_omitempty) = true,
|
|
147
|
+
(amino.field_name) = "compressedBundle",
|
|
148
|
+
(gogoproto.jsontag) = "compressedBundle",
|
|
149
|
+
(gogoproto.moretags) = "yaml:\"compressedBundle\""
|
|
150
|
+
];
|
|
114
151
|
// Size in bytes of uncompression of compressed_bundle.
|
|
115
|
-
int64 uncompressed_size = 4 [
|
|
152
|
+
int64 uncompressed_size = 4 [
|
|
153
|
+
(amino.dont_omitempty) = true,
|
|
154
|
+
(amino.field_name) = "uncompressedSize",
|
|
155
|
+
(gogoproto.jsontag) = "uncompressedSize"
|
|
156
|
+
];
|
|
116
157
|
}
|
|
117
158
|
|
|
118
159
|
// MsgInstallBundleResponse is an empty acknowledgement that an install bundle
|
|
119
160
|
// message has been queued for the SwingSet kernel's consideration.
|
|
120
161
|
message MsgInstallBundleResponse {}
|
|
162
|
+
|
|
163
|
+
// MsgCoreEval defines an SDK message for a core eval.
|
|
164
|
+
message MsgCoreEval {
|
|
165
|
+
option (cosmos.msg.v1.signer) = "authority";
|
|
166
|
+
option (amino.name) = "cosmos-sdk/x/swingset/MsgCoreEval";
|
|
167
|
+
|
|
168
|
+
// authority is the address that controls the module (defaults to x/gov unless overwritten).
|
|
169
|
+
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
|
170
|
+
// The JSON-stringified core bootstrap permits to grant to the jsCode, as the
|
|
171
|
+
// `powers` endowment.
|
|
172
|
+
string json_permits = 2 [(gogoproto.moretags) = "yaml:\"json_permits\""];
|
|
173
|
+
|
|
174
|
+
// Evaluate this JavaScript code in a Compartment endowed with `powers` as
|
|
175
|
+
// well as some powerless helpers.
|
|
176
|
+
string js_code = 3 [(gogoproto.moretags) = "yaml:\"js_code\""];
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// MsgCoreEvalResponse is an empty reply.
|
|
180
|
+
message MsgCoreEvalResponse {
|
|
181
|
+
// The result of the core eval.
|
|
182
|
+
string result = 1 [(gogoproto.moretags) = "yaml:\"result\""];
|
|
183
|
+
}
|
|
@@ -3,6 +3,8 @@ package agoric.swingset;
|
|
|
3
3
|
|
|
4
4
|
import "gogoproto/gogo.proto";
|
|
5
5
|
import "cosmos/base/v1beta1/coin.proto";
|
|
6
|
+
import "cosmos_proto/cosmos.proto";
|
|
7
|
+
import "amino/amino.proto";
|
|
6
8
|
|
|
7
9
|
option go_package = "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/types";
|
|
8
10
|
|
|
@@ -10,6 +12,9 @@ option go_package = "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/types
|
|
|
10
12
|
// core.
|
|
11
13
|
// See `bridgeCoreEval` in agoric-sdk packages/vats/src/core/chain-behaviors.js.
|
|
12
14
|
message CoreEvalProposal {
|
|
15
|
+
option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content";
|
|
16
|
+
option (amino.name) = "swingset/CoreEvalProposal";
|
|
17
|
+
|
|
13
18
|
option (gogoproto.goproto_getters) = false;
|
|
14
19
|
|
|
15
20
|
string title = 1;
|
|
@@ -101,7 +106,7 @@ message StringBeans {
|
|
|
101
106
|
string key = 1;
|
|
102
107
|
|
|
103
108
|
// The actual bean value.
|
|
104
|
-
string beans = 2 [(gogoproto.customtype) = "
|
|
109
|
+
string beans = 2 [(gogoproto.customtype) = "cosmossdk.io/math.Uint", (gogoproto.nullable) = false];
|
|
105
110
|
}
|
|
106
111
|
|
|
107
112
|
// Map a provisioning power flag to its corresponding fee.
|
|
@@ -131,7 +136,7 @@ message QueueSize {
|
|
|
131
136
|
message UintMapEntry {
|
|
132
137
|
option (gogoproto.equal) = true;
|
|
133
138
|
string key = 1;
|
|
134
|
-
string value
|
|
139
|
+
string value = 2 [(gogoproto.customtype) = "cosmossdk.io/math.Uint", (gogoproto.nullable) = false];
|
|
135
140
|
}
|
|
136
141
|
|
|
137
142
|
// Egress is the format for a swingset egress.
|
|
@@ -21,7 +21,7 @@ message Params {
|
|
|
21
21
|
// per-block distribution.
|
|
22
22
|
string per_epoch_reward_fraction = 2 [
|
|
23
23
|
(gogoproto.moretags) = "yaml:\"discrete_epoch_reward_fraction\"",
|
|
24
|
-
(gogoproto.customtype) = "
|
|
24
|
+
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
|
|
25
25
|
(gogoproto.nullable) = false
|
|
26
26
|
];
|
|
27
27
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
syntax = "proto3";
|
|
2
2
|
package agoric.vibc;
|
|
3
3
|
|
|
4
|
+
import "amino/amino.proto";
|
|
4
5
|
import "gogoproto/gogo.proto";
|
|
5
6
|
import "ibc/core/channel/v1/channel.proto";
|
|
6
7
|
|
|
@@ -15,10 +16,13 @@ service Msg {
|
|
|
15
16
|
// MsgSendPacket is an SDK message for sending an outgoing IBC packet
|
|
16
17
|
message MsgSendPacket {
|
|
17
18
|
option (gogoproto.equal) = false;
|
|
19
|
+
option (amino.name) = "vibc/SendPacket";
|
|
18
20
|
|
|
19
21
|
ibc.core.channel.v1.Packet packet = 1
|
|
20
22
|
[(gogoproto.nullable) = false, (gogoproto.jsontag) = "packet", (gogoproto.moretags) = "yaml:\"packet\""];
|
|
21
23
|
bytes sender = 2 [
|
|
24
|
+
(amino.encoding) = "legacy_address",
|
|
25
|
+
(amino.field_name) = "submitter",
|
|
22
26
|
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress",
|
|
23
27
|
(gogoproto.jsontag) = "submitter",
|
|
24
28
|
(gogoproto.moretags) = "yaml:\"submitter\""
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
package vbank_test
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"cosmossdk.io/math"
|
|
5
|
+
"github.com/stretchr/testify/suite"
|
|
6
|
+
|
|
7
|
+
"github.com/cometbft/cometbft/crypto/secp256k1"
|
|
8
|
+
"github.com/cosmos/cosmos-sdk/testutil/network"
|
|
9
|
+
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
10
|
+
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
// Generate test accounts using secp256k1 keys
|
|
14
|
+
var (
|
|
15
|
+
priv1 = secp256k1.GenPrivKey()
|
|
16
|
+
priv2 = secp256k1.GenPrivKey()
|
|
17
|
+
addr1 = sdk.AccAddress(priv1.PubKey().Address()).String()
|
|
18
|
+
addr2 = sdk.AccAddress(priv2.PubKey().Address()).String()
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
type E2ETestSuite struct {
|
|
22
|
+
suite.Suite
|
|
23
|
+
cfg network.Config
|
|
24
|
+
network *network.Network
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
func NewE2ETestSuite(cfg network.Config) *E2ETestSuite {
|
|
28
|
+
return &E2ETestSuite{cfg: cfg}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
func (s *E2ETestSuite) SetupSuite() {
|
|
32
|
+
s.T().Log("setting up e2e test suite")
|
|
33
|
+
|
|
34
|
+
genesisState := s.cfg.GenesisState
|
|
35
|
+
bankGenesis := banktypes.DefaultGenesisState()
|
|
36
|
+
|
|
37
|
+
bankGenesis.DenomMetadata = []banktypes.Metadata{
|
|
38
|
+
{
|
|
39
|
+
Name: "Agoric",
|
|
40
|
+
Symbol: "BLD",
|
|
41
|
+
Description: "AgorickToken",
|
|
42
|
+
DenomUnits: []*banktypes.DenomUnit{
|
|
43
|
+
{
|
|
44
|
+
Denom: "ulbd",
|
|
45
|
+
Exponent: 0,
|
|
46
|
+
Aliases: []string{"microlbd"},
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
Denom: "lbd",
|
|
50
|
+
Exponent: 6,
|
|
51
|
+
Aliases: []string{"LBD"},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
Base: "ulbd",
|
|
55
|
+
Display: "lbd",
|
|
56
|
+
},
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Add two accounts with 10000 lbd each (10000 * 10^6 ulbd = 10000000000 ulbd)
|
|
60
|
+
// Using generated addresses from testutil
|
|
61
|
+
bankGenesis.Balances = []banktypes.Balance{
|
|
62
|
+
{
|
|
63
|
+
Address: addr1,
|
|
64
|
+
Coins: sdk.NewCoins(
|
|
65
|
+
sdk.NewCoin("ulbd", math.NewInt(10000000000)), // 10000 lbd
|
|
66
|
+
),
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
Address: addr2,
|
|
70
|
+
Coins: sdk.NewCoins(
|
|
71
|
+
sdk.NewCoin("ulbd", math.NewInt(10000000000)), // 10000 lbd
|
|
72
|
+
),
|
|
73
|
+
},
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
genesisState[banktypes.ModuleName] = s.cfg.Codec.MustMarshalJSON(bankGenesis)
|
|
77
|
+
s.cfg.GenesisState = genesisState
|
|
78
|
+
|
|
79
|
+
var err error
|
|
80
|
+
s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg)
|
|
81
|
+
s.Require().NoError(err)
|
|
82
|
+
|
|
83
|
+
_, err = s.network.WaitForHeight(1)
|
|
84
|
+
s.Require().NoError(err)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
func (s *E2ETestSuite) TearDownSuite() {
|
|
88
|
+
s.T().Log("tearing down e2e test suite")
|
|
89
|
+
s.network.Cleanup()
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
func (s *E2ETestSuite) TestSendTokens() {
|
|
93
|
+
s.T().Log("testing token transfer")
|
|
94
|
+
|
|
95
|
+
val := s.network.Validators[0]
|
|
96
|
+
ctx := val.ClientCtx
|
|
97
|
+
|
|
98
|
+
// Generate a new recipient account
|
|
99
|
+
recipientPriv := secp256k1.GenPrivKey()
|
|
100
|
+
recipientAddr := sdk.AccAddress(recipientPriv.PubKey().Address())
|
|
101
|
+
|
|
102
|
+
// Get the app instance for direct keeper access
|
|
103
|
+
app := val.ClientCtx.InterfaceRegistry
|
|
104
|
+
s.Require().NotNil(app)
|
|
105
|
+
|
|
106
|
+
// Create a send message for 1000 lbd (1000000000 ulbd)
|
|
107
|
+
sendAmount := sdk.NewCoins(sdk.NewCoin("ulbd", math.NewInt(1000000000))) // 1000 lbd
|
|
108
|
+
|
|
109
|
+
msgSend := &banktypes.MsgSend{
|
|
110
|
+
FromAddress: addr1,
|
|
111
|
+
ToAddress: recipientAddr.String(),
|
|
112
|
+
Amount: sendAmount,
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
s.T().Logf("Sending %s from %s to %s", sendAmount, addr1, recipientAddr.String())
|
|
116
|
+
|
|
117
|
+
// Create and broadcast the transaction
|
|
118
|
+
txBuilder := ctx.TxConfig.NewTxBuilder()
|
|
119
|
+
err := txBuilder.SetMsgs(msgSend)
|
|
120
|
+
s.Require().NoError(err)
|
|
121
|
+
|
|
122
|
+
// Set gas and fees
|
|
123
|
+
txBuilder.SetGasLimit(200000)
|
|
124
|
+
fees := sdk.NewCoins(sdk.NewCoin("ulbd", math.NewInt(100000))) // Fee in ulbd
|
|
125
|
+
txBuilder.SetFeeAmount(fees)
|
|
126
|
+
|
|
127
|
+
// For this test, we'll broadcast using the validator's address as a proxy
|
|
128
|
+
// In a real scenario, we'd sign with the actual sender's private key
|
|
129
|
+
txBuilder.SetFeeGranter(val.Address)
|
|
130
|
+
|
|
131
|
+
// Build and encode the transaction
|
|
132
|
+
txBytes, err := ctx.TxConfig.TxEncoder()(txBuilder.GetTx())
|
|
133
|
+
s.Require().NoError(err)
|
|
134
|
+
s.Require().NotNil(txBytes)
|
|
135
|
+
|
|
136
|
+
s.T().Logf("Transaction created successfully with size: %d bytes", len(txBytes))
|
|
137
|
+
|
|
138
|
+
// Broadcast the transaction
|
|
139
|
+
res, err := ctx.BroadcastTx(txBytes)
|
|
140
|
+
s.Require().NoError(err)
|
|
141
|
+
s.T().Logf("Transaction broadcast result: %+v", res)
|
|
142
|
+
|
|
143
|
+
// Wait for the transaction to be processed
|
|
144
|
+
s.Require().NoError(s.network.WaitForNextBlock())
|
|
145
|
+
|
|
146
|
+
// Query the recipient's balance to verify they received the tokens
|
|
147
|
+
queryClient := banktypes.NewQueryClient(ctx)
|
|
148
|
+
balanceReq := &banktypes.QueryAllBalancesRequest{
|
|
149
|
+
Address: recipientAddr.String(),
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
balanceResp, err := queryClient.AllBalances(val.ClientCtx.CmdContext, balanceReq)
|
|
153
|
+
s.Require().NoError(err)
|
|
154
|
+
|
|
155
|
+
// Verify the recipient received exactly 1000 lbd (1000000000 ulbd)
|
|
156
|
+
expectedAmount := math.NewInt(1000000000)
|
|
157
|
+
found := false
|
|
158
|
+
actualBalance := math.ZeroInt()
|
|
159
|
+
|
|
160
|
+
for _, coin := range balanceResp.Balances {
|
|
161
|
+
if coin.Denom == "ulbd" {
|
|
162
|
+
actualBalance = coin.Amount
|
|
163
|
+
if coin.Amount.Equal(expectedAmount) {
|
|
164
|
+
found = true
|
|
165
|
+
}
|
|
166
|
+
break
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
s.Require().True(found, "Recipient should have received exactly 1000 lbd (1000000000 ulbd), but got %s ulbd", actualBalance.String())
|
|
171
|
+
|
|
172
|
+
}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
package types_test
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"encoding/json"
|
|
6
|
+
"reflect"
|
|
7
|
+
"testing"
|
|
8
|
+
|
|
9
|
+
"github.com/stretchr/testify/require"
|
|
10
|
+
|
|
11
|
+
"github.com/cosmos/cosmos-proto/anyutil"
|
|
12
|
+
gogoproto "github.com/cosmos/gogoproto/proto"
|
|
13
|
+
"google.golang.org/protobuf/proto"
|
|
14
|
+
"google.golang.org/protobuf/types/known/anypb"
|
|
15
|
+
|
|
16
|
+
v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1"
|
|
17
|
+
txv1beta1 "cosmossdk.io/api/cosmos/tx/v1beta1"
|
|
18
|
+
signing_testutil "cosmossdk.io/x/tx/signing/testutil"
|
|
19
|
+
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
|
20
|
+
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
21
|
+
"github.com/cosmos/cosmos-sdk/types/module/testutil"
|
|
22
|
+
signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing"
|
|
23
|
+
"github.com/cosmos/cosmos-sdk/x/auth"
|
|
24
|
+
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
|
|
25
|
+
"github.com/cosmos/cosmos-sdk/x/auth/signing"
|
|
26
|
+
"github.com/cosmos/cosmos-sdk/x/auth/tx"
|
|
27
|
+
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
|
|
28
|
+
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"
|
|
29
|
+
"github.com/cosmos/cosmos-sdk/x/bank"
|
|
30
|
+
"github.com/cosmos/cosmos-sdk/x/gov"
|
|
31
|
+
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
|
|
32
|
+
"github.com/cosmos/cosmos-sdk/x/params"
|
|
33
|
+
"github.com/cosmos/cosmos-sdk/x/params/types/proposal"
|
|
34
|
+
"github.com/cosmos/cosmos-sdk/x/slashing"
|
|
35
|
+
"github.com/cosmos/cosmos-sdk/x/staking"
|
|
36
|
+
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
|
|
37
|
+
channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
|
|
38
|
+
|
|
39
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/app/txconfig"
|
|
40
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset"
|
|
41
|
+
swingsettypes "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/types"
|
|
42
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vbank"
|
|
43
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vibc"
|
|
44
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vstorage"
|
|
45
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vtransfer"
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
func TestAminoJSON_LegacyParity(t *testing.T) {
|
|
49
|
+
encCfg := testutil.MakeTestEncodingConfig(
|
|
50
|
+
auth.AppModuleBasic{},
|
|
51
|
+
vesting.AppModuleBasic{},
|
|
52
|
+
bank.AppModuleBasic{},
|
|
53
|
+
gov.AppModuleBasic{},
|
|
54
|
+
slashing.AppModuleBasic{},
|
|
55
|
+
staking.AppModuleBasic{},
|
|
56
|
+
authzmodule.AppModuleBasic{},
|
|
57
|
+
params.AppModuleBasic{},
|
|
58
|
+
vstorage.AppModuleBasic{},
|
|
59
|
+
swingset.AppModuleBasic{},
|
|
60
|
+
vibc.AppModuleBasic{},
|
|
61
|
+
vbank.AppModuleBasic{},
|
|
62
|
+
vtransfer.AppModuleBasic{},
|
|
63
|
+
)
|
|
64
|
+
legacytx.RegressionTestingAminoCodec = encCfg.Amino
|
|
65
|
+
|
|
66
|
+
signingOpts, err := tx.NewDefaultSigningOptions()
|
|
67
|
+
require.NoError(t, err)
|
|
68
|
+
|
|
69
|
+
handler, aj, err := txconfig.NewAminoHandlerWithCustomEncoders(signingOpts, txconfig.CustomAminoFieldEncoders)
|
|
70
|
+
require.NoError(t, err)
|
|
71
|
+
|
|
72
|
+
addr1 := sdk.AccAddress("addr1")
|
|
73
|
+
deliverMessages := &swingsettypes.Messages{Messages: []string{"{}"}, Nums: []uint64{2}, Ack: 1}
|
|
74
|
+
emptyDeliverMessages := &swingsettypes.Messages{Messages: []string{}, Nums: []uint64{}, Ack: 1}
|
|
75
|
+
zeroDeliverMessages := &swingsettypes.Messages{Messages: []string{"{}"}, Nums: []uint64{2}, Ack: 0}
|
|
76
|
+
coins := sdk.Coins{sdk.NewInt64Coin("uatom", 1000)}
|
|
77
|
+
|
|
78
|
+
installBundleMsg := swingsettypes.NewMsgInstallBundle("{}", addr1)
|
|
79
|
+
err = installBundleMsg.ValidateBasic()
|
|
80
|
+
require.NoError(t, err)
|
|
81
|
+
|
|
82
|
+
compressedInstallBundleMsg := new(swingsettypes.MsgInstallBundle)
|
|
83
|
+
*compressedInstallBundleMsg = *installBundleMsg
|
|
84
|
+
err = compressedInstallBundleMsg.Compress()
|
|
85
|
+
require.NoError(t, err)
|
|
86
|
+
|
|
87
|
+
coreEvalProposal := swingsettypes.NewCoreEvalProposal("test core eval", "Some core eval", []swingsettypes.CoreEval{{JsonPermits: "true", JsCode: ";"}})
|
|
88
|
+
err = coreEvalProposal.ValidateBasic()
|
|
89
|
+
require.NoError(t, err)
|
|
90
|
+
|
|
91
|
+
coreEvalGovMsg, err := govv1beta1.NewMsgSubmitProposal(coreEvalProposal, coins, addr1)
|
|
92
|
+
require.NoError(t, err)
|
|
93
|
+
|
|
94
|
+
paramsChangeProposal := proposal.NewParameterChangeProposal("title", "description", []proposal.ParamChange{proposal.NewParamChange("swingset", "foo", "bar")})
|
|
95
|
+
err = paramsChangeProposal.ValidateBasic()
|
|
96
|
+
require.NoError(t, err)
|
|
97
|
+
|
|
98
|
+
paramsChangeGovMsg, err := govv1beta1.NewMsgSubmitProposal(paramsChangeProposal, coins, addr1)
|
|
99
|
+
require.NoError(t, err)
|
|
100
|
+
|
|
101
|
+
ibcPacket := channeltypes.NewPacket(
|
|
102
|
+
[]byte("data"),
|
|
103
|
+
987654321098765432,
|
|
104
|
+
"port-src", "channel-13",
|
|
105
|
+
"port-dst", "channel-42",
|
|
106
|
+
clienttypes.Height{},
|
|
107
|
+
123456789012345678,
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
cases := map[string]struct {
|
|
111
|
+
gogo gogoproto.Message
|
|
112
|
+
// If there are any empty slices, the marshal round trip to bytes will likely transform these into nil slices
|
|
113
|
+
roundTripUnequal bool
|
|
114
|
+
}{
|
|
115
|
+
"swingset/msg_deliver_inbound/normal": {gogo: swingsettypes.NewMsgDeliverInbound(deliverMessages, addr1)},
|
|
116
|
+
"swingset/msg_deliver_inbound/empty": {gogo: swingsettypes.NewMsgDeliverInbound(emptyDeliverMessages, addr1), roundTripUnequal: true},
|
|
117
|
+
"swingset/msg_deliver_inbound/zero": {gogo: swingsettypes.NewMsgDeliverInbound(zeroDeliverMessages, addr1)},
|
|
118
|
+
"swingset/msg_wallet_action": {gogo: swingsettypes.NewMsgWalletAction(addr1, "{}")},
|
|
119
|
+
"swingset/msg_wallet_spend_action": {gogo: swingsettypes.NewMsgWalletSpendAction(addr1, "{}")},
|
|
120
|
+
"swingset/msg_provision/normal": {gogo: swingsettypes.NewMsgProvision("foo", addr1, []string{"bar"}, addr1)},
|
|
121
|
+
"swingset/msg_provision/empty": {gogo: swingsettypes.NewMsgProvision("foo", addr1, []string{}, addr1), roundTripUnequal: true},
|
|
122
|
+
"swingset/msg_install_bundle": {gogo: installBundleMsg},
|
|
123
|
+
"swingset/msg_install_bundle/compressed": {gogo: compressedInstallBundleMsg},
|
|
124
|
+
"swingset/gov/core_eval_proposal": {gogo: coreEvalGovMsg},
|
|
125
|
+
"swingset/gov/params_change_proposal": {gogo: paramsChangeGovMsg},
|
|
126
|
+
"vibc/msg_send_packet": {gogo: vibc.NewMsgSendPacket(ibcPacket, addr1)},
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
for name, tc := range cases {
|
|
130
|
+
t.Run(name, func(t *testing.T) {
|
|
131
|
+
gogoMsg := tc.gogo
|
|
132
|
+
|
|
133
|
+
// Convert gogoproto into new proto msg like tx would
|
|
134
|
+
anyGogoMsg, err := codectypes.NewAnyWithValue(gogoMsg)
|
|
135
|
+
require.NoError(t, err)
|
|
136
|
+
|
|
137
|
+
protoMsg, err := anyutil.Unpack(&anypb.Any{
|
|
138
|
+
TypeUrl: anyGogoMsg.TypeUrl,
|
|
139
|
+
Value: anyGogoMsg.Value,
|
|
140
|
+
}, encCfg.InterfaceRegistry, nil)
|
|
141
|
+
require.NoError(t, err)
|
|
142
|
+
|
|
143
|
+
protoBz, err := proto.Marshal(protoMsg)
|
|
144
|
+
require.NoError(t, err)
|
|
145
|
+
|
|
146
|
+
// Sanity check
|
|
147
|
+
gogoType := reflect.TypeOf(gogoMsg).Elem()
|
|
148
|
+
newGogo := reflect.New(gogoType).Interface().(gogoproto.Message)
|
|
149
|
+
err = encCfg.Codec.Unmarshal(protoBz, newGogo)
|
|
150
|
+
require.NoError(t, err)
|
|
151
|
+
if tc.roundTripUnequal {
|
|
152
|
+
require.NotEqual(t, gogoMsg, newGogo)
|
|
153
|
+
} else {
|
|
154
|
+
require.Equal(t, gogoMsg, newGogo)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Check amino json encoding matches
|
|
158
|
+
anyProtoMsg, err := anyutil.New(protoMsg)
|
|
159
|
+
require.NoError(t, err)
|
|
160
|
+
|
|
161
|
+
legacyAminoJSON, err := encCfg.Amino.MarshalJSON(gogoMsg)
|
|
162
|
+
require.NoError(t, err)
|
|
163
|
+
legacyAminoJSON = sortJSON(t, legacyAminoJSON)
|
|
164
|
+
aminoJSON, err := aj.Marshal(anyProtoMsg)
|
|
165
|
+
require.NoError(t, err)
|
|
166
|
+
require.Equal(t, string(legacyAminoJSON), string(aminoJSON))
|
|
167
|
+
|
|
168
|
+
handlerOptions := signing_testutil.HandlerArgumentOptions{
|
|
169
|
+
ChainID: "test-chain",
|
|
170
|
+
Memo: "sometestmemo",
|
|
171
|
+
Msg: protoMsg,
|
|
172
|
+
AccNum: 1,
|
|
173
|
+
AccSeq: 2,
|
|
174
|
+
SignerAddress: "signerAddress",
|
|
175
|
+
Fee: &txv1beta1.Fee{
|
|
176
|
+
Amount: []*v1beta1.Coin{{Denom: "uatom", Amount: "1000"}},
|
|
177
|
+
},
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
signerData, txData, err := signing_testutil.MakeHandlerArguments(handlerOptions)
|
|
181
|
+
require.NoError(t, err)
|
|
182
|
+
|
|
183
|
+
signBz, err := handler.GetSignBytes(context.Background(), signerData, txData)
|
|
184
|
+
require.NoError(t, err)
|
|
185
|
+
|
|
186
|
+
legacyHandler := tx.NewSignModeLegacyAminoJSONHandler()
|
|
187
|
+
txBuilder := encCfg.TxConfig.NewTxBuilder()
|
|
188
|
+
require.NoError(t, txBuilder.SetMsgs([]sdk.Msg{gogoMsg}...))
|
|
189
|
+
txBuilder.SetMemo(handlerOptions.Memo)
|
|
190
|
+
txBuilder.SetFeeAmount(sdk.Coins{sdk.NewInt64Coin("uatom", 1000)})
|
|
191
|
+
theTx := txBuilder.GetTx()
|
|
192
|
+
|
|
193
|
+
legacySigningData := signing.SignerData{
|
|
194
|
+
ChainID: handlerOptions.ChainID,
|
|
195
|
+
Address: handlerOptions.SignerAddress,
|
|
196
|
+
AccountNumber: handlerOptions.AccNum,
|
|
197
|
+
Sequence: handlerOptions.AccSeq,
|
|
198
|
+
}
|
|
199
|
+
legacySignBz, err := legacyHandler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON,
|
|
200
|
+
legacySigningData, theTx)
|
|
201
|
+
require.NoError(t, err)
|
|
202
|
+
require.Equal(t, string(legacySignBz), string(signBz))
|
|
203
|
+
})
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
func sortJSON(t require.TestingT, bz []byte) []byte {
|
|
208
|
+
var c interface{}
|
|
209
|
+
err := json.Unmarshal(bz, &c)
|
|
210
|
+
require.NoError(t, err)
|
|
211
|
+
bz, err = json.Marshal(c)
|
|
212
|
+
require.NoError(t, err)
|
|
213
|
+
return bz
|
|
214
|
+
}
|