@agoric/cosmos 0.34.2-dev-9f6644d.0 → 0.34.2-dev-0467291.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/.clang-format +116 -0
- package/Makefile +38 -67
- package/ante/ante.go +2 -2
- package/ante/inbound_test.go +1 -1
- package/app/app.go +173 -142
- package/app/export.go +6 -6
- package/app/genesis.go +4 -0
- package/app/sim_test.go +299 -50
- package/app/upgrade.go +70 -3
- package/cmd/agd/agvm.go +1 -1
- package/cmd/agd/main.go +1 -1
- package/cmd/libdaemon/main.go +1 -1
- package/daemon/cmd/root.go +25 -34
- package/daemon/cmd/root_test.go +5 -4
- package/daemon/cmd/testnet.go +221 -95
- package/daemon/main.go +1 -0
- package/git-revision.txt +1 -1
- package/go.mod +93 -58
- package/go.sum +148 -95
- package/package.json +2 -2
- package/proto/agoric/swingset/genesis.proto +7 -11
- package/proto/agoric/swingset/msgs.proto +56 -75
- package/proto/agoric/swingset/query.proto +7 -10
- package/proto/agoric/swingset/swingset.proto +79 -108
- package/proto/agoric/vbank/genesis.proto +5 -5
- package/proto/agoric/vbank/msgs.proto +1 -2
- package/proto/agoric/vbank/vbank.proto +42 -52
- package/proto/agoric/vibc/msgs.proto +8 -11
- package/proto/agoric/vstorage/genesis.proto +6 -9
- package/proto/agoric/vstorage/query.proto +19 -48
- package/proto/agoric/vstorage/vstorage.proto +4 -10
- package/proto/agoric/vtransfer/genesis.proto +7 -7
- package/proto/buf.gen.gogo.yaml +8 -0
- package/proto/buf.gen.pulsar.yaml +17 -0
- package/proto/buf.gen.swagger.yaml +5 -0
- package/proto/buf.yaml +10 -0
- package/scripts/protocgen.sh +14 -21
- package/third_party/proto/amino/amino.proto +79 -0
- package/third_party/proto/cosmos/base/v1beta1/coin.proto +7 -2
- package/third_party/proto/cosmos/ics23/v1/proofs.proto +243 -0
- package/third_party/proto/cosmos/msg/v1/msg.proto +30 -0
- package/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto +17 -5
- package/third_party/proto/cosmos_proto/cosmos.proto +16 -1
- package/third_party/proto/gogoproto/gogo.proto +2 -2
- package/third_party/proto/google/protobuf/any.proto +6 -3
- package/third_party/proto/ibc/core/channel/v1/channel.proto +1 -1
- package/third_party/proto/ibc/core/client/v1/client.proto +4 -2
- 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/vm/proto_json.go +2 -2
- package/x/swingset/abci.go +1 -1
- package/x/swingset/alias.go +0 -1
- package/x/swingset/config.go +1 -1
- package/x/swingset/keeper/extension_snapshotter.go +1 -1
- package/x/swingset/keeper/extension_snapshotter_test.go +1 -1
- package/x/swingset/keeper/keeper.go +1 -1
- package/x/swingset/keeper/keeper_test.go +1 -1
- package/x/swingset/keeper/querier.go +1 -30
- 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/module.go +1 -14
- package/x/swingset/types/genesis.pb.go +2 -2
- package/x/swingset/types/msgs.pb.go +4 -3
- package/x/swingset/types/msgs_test.go +1 -1
- package/x/swingset/types/query.pb.go +4 -3
- package/x/swingset/types/swingset.pb.go +2 -2
- package/x/vbank/genesis.go +1 -1
- package/x/vbank/keeper/querier.go +1 -21
- package/x/vbank/module.go +1 -16
- package/x/vbank/types/genesis.pb.go +2 -2
- package/x/vbank/types/msgs.pb.go +3 -2
- package/x/vbank/types/query.pb.go +4 -3
- package/x/vbank/types/vbank.pb.go +2 -2
- package/x/vbank/vbank_test.go +16 -16
- package/x/vibc/keeper/keeper.go +8 -5
- package/x/vibc/keeper/migrations.go +36 -0
- package/x/vibc/keeper/triggers.go +1 -1
- package/x/vibc/module.go +9 -17
- package/x/vibc/types/expected_keepers.go +5 -10
- package/x/vibc/types/ibc_module.go +4 -4
- package/x/vibc/types/msgs.go +1 -1
- package/x/vibc/types/msgs.pb.go +5 -4
- package/x/vibc/types/receiver.go +2 -2
- package/x/vlocalchain/keeper/keeper.go +3 -3
- package/x/vlocalchain/types/vlocalchain.pb.go +1 -1
- package/x/vlocalchain/vlocalchain_test.go +6 -6
- package/x/vstorage/alias.go +0 -1
- package/x/vstorage/client/cli/query.go +1 -1
- package/x/vstorage/genesis.go +1 -1
- package/x/vstorage/keeper/keeper.go +6 -5
- package/x/vstorage/keeper/keeper_test.go +24 -24
- package/x/vstorage/keeper/querier.go +1 -32
- package/x/vstorage/keeper/querier_test.go +41 -6
- package/x/vstorage/module.go +1 -14
- package/x/vstorage/types/genesis.pb.go +2 -2
- package/x/vstorage/types/query.pb.go +8 -5
- package/x/vstorage/types/vstorage.pb.go +2 -2
- package/x/vstorage/vstorage_test.go +3 -3
- package/x/vtransfer/genesis.go +1 -1
- package/x/vtransfer/ibc_middleware.go +4 -4
- package/x/vtransfer/ibc_middleware_test.go +10 -11
- package/x/vtransfer/keeper/keeper.go +5 -5
- package/x/vtransfer/module.go +1 -14
- package/x/vtransfer/types/expected_keepers.go +2 -18
- package/x/vtransfer/types/genesis.pb.go +2 -2
- package/x/vtransfer/utils_test.go +15 -15
- package/daemon/cmd/genaccounts.go +0 -195
|
@@ -2,22 +2,57 @@ package keeper
|
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
4
|
"bytes"
|
|
5
|
+
"encoding/json"
|
|
5
6
|
"testing"
|
|
6
7
|
|
|
7
8
|
agoric "github.com/Agoric/agoric-sdk/golang/cosmos/types"
|
|
8
|
-
|
|
9
|
-
abci "github.com/tendermint/tendermint/abci/types"
|
|
9
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vstorage/types"
|
|
10
10
|
|
|
11
11
|
sdkioerrors "cosmossdk.io/errors"
|
|
12
|
-
"github.com/cosmos/cosmos-sdk/
|
|
12
|
+
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
13
13
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
14
14
|
)
|
|
15
15
|
|
|
16
|
+
func runRpc(ctx sdk.Context, querier Querier, rpc string, args []string) (res []byte, err error) {
|
|
17
|
+
defer func() {
|
|
18
|
+
if r := recover(); r != nil {
|
|
19
|
+
err = sdkerrors.ErrInvalidRequest
|
|
20
|
+
}
|
|
21
|
+
}()
|
|
22
|
+
switch rpc {
|
|
23
|
+
case "children":
|
|
24
|
+
if len(args) != 1 {
|
|
25
|
+
return nil, sdkerrors.ErrInvalidRequest
|
|
26
|
+
}
|
|
27
|
+
req := &types.QueryChildrenRequest{Path: args[0]}
|
|
28
|
+
r, err := querier.Children(sdk.WrapSDKContext(ctx), req)
|
|
29
|
+
if err != nil {
|
|
30
|
+
return nil, err
|
|
31
|
+
}
|
|
32
|
+
return json.MarshalIndent(r, "", " ")
|
|
33
|
+
|
|
34
|
+
case "data":
|
|
35
|
+
if len(args) != 1 {
|
|
36
|
+
return nil, sdkerrors.ErrInvalidRequest
|
|
37
|
+
}
|
|
38
|
+
req := &types.QueryDataRequest{Path: args[0]}
|
|
39
|
+
r, err := querier.Data(sdk.WrapSDKContext(ctx), req)
|
|
40
|
+
if r != nil && r.Value == "" {
|
|
41
|
+
return nil, sdkerrors.ErrNotFound
|
|
42
|
+
}
|
|
43
|
+
if err != nil {
|
|
44
|
+
return nil, err
|
|
45
|
+
}
|
|
46
|
+
return json.MarshalIndent(r, "", " ")
|
|
47
|
+
default:
|
|
48
|
+
return nil, sdkerrors.ErrUnknownRequest
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
16
52
|
func TestQuerier(t *testing.T) {
|
|
17
53
|
testKit := makeTestKit()
|
|
18
54
|
ctx, keeper := testKit.ctx, testKit.vstorageKeeper
|
|
19
|
-
|
|
20
|
-
querier := NewQuerier(keeper, legacyQuerierCdc.LegacyAmino)
|
|
55
|
+
querier := Querier{keeper}
|
|
21
56
|
|
|
22
57
|
// Populate mock data
|
|
23
58
|
keeper.SetStorage(ctx, agoric.NewKVEntry("foo.bar", "42"))
|
|
@@ -99,7 +134,7 @@ func TestQuerier(t *testing.T) {
|
|
|
99
134
|
}...)
|
|
100
135
|
|
|
101
136
|
for _, desc := range testCases {
|
|
102
|
-
res, err :=
|
|
137
|
+
res, err := runRpc(ctx, querier, desc.path[0], desc.path[1:])
|
|
103
138
|
if desc.err != nil {
|
|
104
139
|
if err == nil {
|
|
105
140
|
t.Errorf("%s: got no error, want error %q", desc.label, *desc.err)
|
package/x/vstorage/module.go
CHANGED
|
@@ -15,8 +15,8 @@ import (
|
|
|
15
15
|
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
|
|
16
16
|
"github.com/cosmos/cosmos-sdk/types/module"
|
|
17
17
|
|
|
18
|
+
abci "github.com/cometbft/cometbft/abci/types"
|
|
18
19
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
19
|
-
abci "github.com/tendermint/tendermint/abci/types"
|
|
20
20
|
)
|
|
21
21
|
|
|
22
22
|
// type check to ensure the interface is properly implemented
|
|
@@ -90,19 +90,6 @@ func (AppModule) Name() string {
|
|
|
90
90
|
|
|
91
91
|
func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {}
|
|
92
92
|
|
|
93
|
-
func (am AppModule) Route() sdk.Route {
|
|
94
|
-
return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper))
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
func (am AppModule) QuerierRoute() string {
|
|
98
|
-
return ModuleName
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// LegacyQuerierHandler returns the sdk.Querier for deployment module
|
|
102
|
-
func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
|
|
103
|
-
return keeper.NewQuerier(am.keeper, legacyQuerierCdc)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
93
|
func (am AppModule) RegisterServices(cfg module.Configurator) {
|
|
107
94
|
querier := keeper.Querier{Keeper: am.keeper}
|
|
108
95
|
types.RegisterQueryServer(cfg.QueryServer(), querier)
|
|
@@ -7,9 +7,9 @@ import (
|
|
|
7
7
|
context "context"
|
|
8
8
|
fmt "fmt"
|
|
9
9
|
query "github.com/cosmos/cosmos-sdk/types/query"
|
|
10
|
-
_ "github.com/
|
|
11
|
-
grpc1 "github.com/
|
|
12
|
-
proto "github.com/
|
|
10
|
+
_ "github.com/cosmos/gogoproto/gogoproto"
|
|
11
|
+
grpc1 "github.com/cosmos/gogoproto/grpc"
|
|
12
|
+
proto "github.com/cosmos/gogoproto/proto"
|
|
13
13
|
_ "google.golang.org/genproto/googleapis/api/annotations"
|
|
14
14
|
grpc "google.golang.org/grpc"
|
|
15
15
|
codes "google.golang.org/grpc/codes"
|
|
@@ -135,8 +135,10 @@ type QueryCapDataRequest struct {
|
|
|
135
135
|
ItemFormat string `protobuf:"bytes,3,opt,name=item_format,json=itemFormat,proto3" json:"itemFormat" yaml:"itemFormat"`
|
|
136
136
|
// remotableValueFormat indicates how to transform references to opaque but
|
|
137
137
|
// distinguishable Remotables into readable embedded representations.
|
|
138
|
-
// * "object" represents each Remotable as an `{ id, allegedName }` object, e.g. `{ "id": "board007", "allegedName":
|
|
139
|
-
//
|
|
138
|
+
// * "object" represents each Remotable as an `{ id, allegedName }` object, e.g. `{ "id": "board007", "allegedName":
|
|
139
|
+
// "IST brand" }`.
|
|
140
|
+
// * "string" represents each Remotable as a string with bracket-wrapped contents including its alleged name and id,
|
|
141
|
+
// e.g. "[Alleged: IST brand <board007>]".
|
|
140
142
|
RemotableValueFormat string `protobuf:"bytes,10,opt,name=remotable_value_format,json=remotableValueFormat,proto3" json:"remotableValueFormat" yaml:"remotableValueFormat"`
|
|
141
143
|
}
|
|
142
144
|
|
|
@@ -557,6 +559,7 @@ func _Query_Children_Handler(srv interface{}, ctx context.Context, dec func(inte
|
|
|
557
559
|
return interceptor(ctx, in, info, handler)
|
|
558
560
|
}
|
|
559
561
|
|
|
562
|
+
var Query_serviceDesc = _Query_serviceDesc
|
|
560
563
|
var _Query_serviceDesc = grpc.ServiceDesc{
|
|
561
564
|
ServiceName: "agoric.vstorage.Query",
|
|
562
565
|
HandlerType: (*QueryServer)(nil),
|
|
@@ -15,9 +15,9 @@ import (
|
|
|
15
15
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
16
16
|
|
|
17
17
|
agorictypes "github.com/Agoric/agoric-sdk/golang/cosmos/types"
|
|
18
|
-
"github.com/
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
dbm "github.com/cometbft/cometbft-db"
|
|
19
|
+
"github.com/cometbft/cometbft/libs/log"
|
|
20
|
+
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
|
21
21
|
)
|
|
22
22
|
|
|
23
23
|
var (
|
package/x/vtransfer/genesis.go
CHANGED
|
@@ -4,8 +4,8 @@ import (
|
|
|
4
4
|
"fmt"
|
|
5
5
|
|
|
6
6
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vtransfer/types"
|
|
7
|
+
abci "github.com/cometbft/cometbft/abci/types"
|
|
7
8
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
8
|
-
abci "github.com/tendermint/tendermint/abci/types"
|
|
9
9
|
)
|
|
10
10
|
|
|
11
11
|
func NewGenesisState() *types.GenesisState {
|
|
@@ -4,10 +4,10 @@ import (
|
|
|
4
4
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vtransfer/keeper"
|
|
5
5
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
6
6
|
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
|
|
7
|
-
clienttypes "github.com/cosmos/ibc-go/
|
|
8
|
-
channeltypes "github.com/cosmos/ibc-go/
|
|
9
|
-
porttypes "github.com/cosmos/ibc-go/
|
|
10
|
-
"github.com/cosmos/ibc-go/
|
|
7
|
+
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
|
|
8
|
+
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
|
|
9
|
+
porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
|
|
10
|
+
"github.com/cosmos/ibc-go/v7/modules/core/exported"
|
|
11
11
|
)
|
|
12
12
|
|
|
13
13
|
// IBCMiddleware (https://ibc.cosmos.network/main/ibc/apps/ibcmodule) forwards
|
|
@@ -12,30 +12,30 @@ import (
|
|
|
12
12
|
|
|
13
13
|
app "github.com/Agoric/agoric-sdk/golang/cosmos/app"
|
|
14
14
|
"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
|
|
15
|
+
dbm "github.com/cometbft/cometbft-db"
|
|
16
|
+
"github.com/cometbft/cometbft/libs/log"
|
|
15
17
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
16
18
|
"github.com/cosmos/cosmos-sdk/store"
|
|
19
|
+
"github.com/cosmos/cosmos-sdk/testutil/sims"
|
|
17
20
|
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
|
18
21
|
"github.com/iancoleman/orderedmap"
|
|
19
22
|
"github.com/stretchr/testify/suite"
|
|
20
|
-
"github.com/tendermint/tendermint/libs/log"
|
|
21
|
-
dbm "github.com/tendermint/tm-db"
|
|
22
23
|
|
|
23
24
|
"github.com/Agoric/agoric-sdk/golang/cosmos/types"
|
|
24
25
|
swingsettesting "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/testing"
|
|
25
26
|
swingsettypes "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/types"
|
|
26
27
|
vibctypes "github.com/Agoric/agoric-sdk/golang/cosmos/x/vibc/types"
|
|
27
28
|
|
|
29
|
+
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
|
28
30
|
"github.com/cosmos/cosmos-sdk/baseapp"
|
|
29
31
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
30
32
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
|
31
33
|
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
|
32
|
-
packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/
|
|
33
|
-
ibctransfertypes "github.com/cosmos/ibc-go/
|
|
34
|
-
channeltypes "github.com/cosmos/ibc-go/
|
|
35
|
-
ibcexported "github.com/cosmos/ibc-go/
|
|
36
|
-
ibctesting "github.com/cosmos/ibc-go/
|
|
37
|
-
"github.com/cosmos/ibc-go/v6/testing/simapp"
|
|
38
|
-
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
|
34
|
+
packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"
|
|
35
|
+
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
|
|
36
|
+
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
|
|
37
|
+
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
|
|
38
|
+
ibctesting "github.com/cosmos/ibc-go/v7/testing"
|
|
39
39
|
)
|
|
40
40
|
|
|
41
41
|
const (
|
|
@@ -109,7 +109,6 @@ func (s *IntegrationTestSuite) nextChannelOffset(instance int) int {
|
|
|
109
109
|
func SetupAgoricTestingApp(instance int) TestingAppMaker {
|
|
110
110
|
return func() (ibctesting.TestingApp, map[string]json.RawMessage) {
|
|
111
111
|
db := dbm.NewMemDB()
|
|
112
|
-
encCdc := app.MakeEncodingConfig()
|
|
113
112
|
mockController := func(ctx context.Context, needReply bool, jsonRequest string) (jsonReply string, err error) {
|
|
114
113
|
// fmt.Printf("controller %d got: %s\n", instance, jsonRequest)
|
|
115
114
|
|
|
@@ -124,7 +123,7 @@ func SetupAgoricTestingApp(instance int) TestingAppMaker {
|
|
|
124
123
|
return jsonReply, nil
|
|
125
124
|
}
|
|
126
125
|
appd := app.NewAgoricApp(mockController, vm.NewAgdServer(), log.TestingLogger(), db, nil,
|
|
127
|
-
true,
|
|
126
|
+
true, sims.EmptyAppOptions{}, interBlockCacheOpt())
|
|
128
127
|
genesisState := app.NewDefaultGenesisState()
|
|
129
128
|
|
|
130
129
|
t := template.Must(template.New("").Parse(`
|
|
@@ -22,11 +22,11 @@ import (
|
|
|
22
22
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vibc"
|
|
23
23
|
vibctypes "github.com/Agoric/agoric-sdk/golang/cosmos/x/vibc/types"
|
|
24
24
|
|
|
25
|
-
clienttypes "github.com/cosmos/ibc-go/
|
|
26
|
-
channeltypes "github.com/cosmos/ibc-go/
|
|
27
|
-
porttypes "github.com/cosmos/ibc-go/
|
|
28
|
-
host "github.com/cosmos/ibc-go/
|
|
29
|
-
ibcexported "github.com/cosmos/ibc-go/
|
|
25
|
+
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
|
|
26
|
+
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
|
|
27
|
+
porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
|
|
28
|
+
host "github.com/cosmos/ibc-go/v7/modules/core/24-host"
|
|
29
|
+
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
|
|
30
30
|
)
|
|
31
31
|
|
|
32
32
|
var _ porttypes.ICS4Wrapper = (*Keeper)(nil)
|
package/x/vtransfer/module.go
CHANGED
|
@@ -12,8 +12,8 @@ import (
|
|
|
12
12
|
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
|
|
13
13
|
"github.com/cosmos/cosmos-sdk/types/module"
|
|
14
14
|
|
|
15
|
+
abci "github.com/cometbft/cometbft/abci/types"
|
|
15
16
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
16
|
-
abci "github.com/tendermint/tendermint/abci/types"
|
|
17
17
|
)
|
|
18
18
|
|
|
19
19
|
// type check to ensure the interface is properly implemented
|
|
@@ -86,19 +86,6 @@ func (AppModule) Name() string {
|
|
|
86
86
|
|
|
87
87
|
func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {}
|
|
88
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
89
|
func (am AppModule) RegisterServices(cfg module.Configurator) {
|
|
103
90
|
}
|
|
104
91
|
|
|
@@ -3,9 +3,8 @@ package types
|
|
|
3
3
|
import (
|
|
4
4
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
5
5
|
capability "github.com/cosmos/cosmos-sdk/x/capability/types"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
ibcexported "github.com/cosmos/ibc-go/v6/modules/core/exported"
|
|
6
|
+
channel "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
|
|
7
|
+
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
|
|
9
8
|
)
|
|
10
9
|
|
|
11
10
|
// ChannelKeeper defines the expected IBC channel keeper
|
|
@@ -21,18 +20,3 @@ type ChannelKeeper interface {
|
|
|
21
20
|
ChanCloseInit(ctx sdk.Context, portID, channelID string, chanCap *capability.Capability) error
|
|
22
21
|
TimeoutExecuted(ctx sdk.Context, channelCap *capability.Capability, packet ibcexported.PacketI) error
|
|
23
22
|
}
|
|
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
|
-
}
|
|
@@ -6,8 +6,8 @@ package types
|
|
|
6
6
|
import (
|
|
7
7
|
fmt "fmt"
|
|
8
8
|
github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
|
|
9
|
-
_ "github.com/
|
|
10
|
-
proto "github.com/
|
|
9
|
+
_ "github.com/cosmos/gogoproto/gogoproto"
|
|
10
|
+
proto "github.com/cosmos/gogoproto/proto"
|
|
11
11
|
io "io"
|
|
12
12
|
math "math"
|
|
13
13
|
math_bits "math/bits"
|
|
@@ -5,10 +5,10 @@ import (
|
|
|
5
5
|
"strconv"
|
|
6
6
|
|
|
7
7
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
8
|
-
clienttypes "github.com/cosmos/ibc-go/
|
|
9
|
-
channeltypes "github.com/cosmos/ibc-go/
|
|
10
|
-
host "github.com/cosmos/ibc-go/
|
|
11
|
-
ibctesting "github.com/cosmos/ibc-go/
|
|
8
|
+
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
|
|
9
|
+
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
|
|
10
|
+
host "github.com/cosmos/ibc-go/v7/modules/core/24-host"
|
|
11
|
+
ibctesting "github.com/cosmos/ibc-go/v7/testing"
|
|
12
12
|
)
|
|
13
13
|
|
|
14
14
|
// acknowledgePacketWithResult sends a MsgAcknowledgement to the channel associated with the endpoint.
|
|
@@ -36,8 +36,8 @@ func ParseAckFromFilteredEvents(events sdk.Events, filteredType string) ([]byte,
|
|
|
36
36
|
for _, ev := range events {
|
|
37
37
|
if ev.Type == filteredType {
|
|
38
38
|
for _, attr := range ev.Attributes {
|
|
39
|
-
if
|
|
40
|
-
return attr.Value, nil
|
|
39
|
+
if attr.Key == channeltypes.AttributeKeyAck { //nolint:staticcheck // DEPRECATED
|
|
40
|
+
return []byte(attr.Value), nil
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -59,12 +59,12 @@ func ParsePacketFromFilteredEvents(events sdk.Events, filteredType string) (chan
|
|
|
59
59
|
if ev.Type == filteredType {
|
|
60
60
|
packet := channeltypes.Packet{}
|
|
61
61
|
for _, attr := range ev.Attributes {
|
|
62
|
-
switch
|
|
62
|
+
switch attr.Key {
|
|
63
63
|
case channeltypes.AttributeKeyData: //nolint:staticcheck // DEPRECATED
|
|
64
|
-
packet.Data = attr.Value
|
|
64
|
+
packet.Data = []byte(attr.Value)
|
|
65
65
|
|
|
66
66
|
case channeltypes.AttributeKeySequence:
|
|
67
|
-
seq, err := strconv.ParseUint(
|
|
67
|
+
seq, err := strconv.ParseUint(attr.Value, 10, 64)
|
|
68
68
|
if err != nil {
|
|
69
69
|
return channeltypes.Packet{}, err
|
|
70
70
|
}
|
|
@@ -72,19 +72,19 @@ func ParsePacketFromFilteredEvents(events sdk.Events, filteredType string) (chan
|
|
|
72
72
|
packet.Sequence = seq
|
|
73
73
|
|
|
74
74
|
case channeltypes.AttributeKeySrcPort:
|
|
75
|
-
packet.SourcePort =
|
|
75
|
+
packet.SourcePort = attr.Value
|
|
76
76
|
|
|
77
77
|
case channeltypes.AttributeKeySrcChannel:
|
|
78
|
-
packet.SourceChannel =
|
|
78
|
+
packet.SourceChannel = attr.Value
|
|
79
79
|
|
|
80
80
|
case channeltypes.AttributeKeyDstPort:
|
|
81
|
-
packet.DestinationPort =
|
|
81
|
+
packet.DestinationPort = attr.Value
|
|
82
82
|
|
|
83
83
|
case channeltypes.AttributeKeyDstChannel:
|
|
84
|
-
packet.DestinationChannel =
|
|
84
|
+
packet.DestinationChannel = attr.Value
|
|
85
85
|
|
|
86
86
|
case channeltypes.AttributeKeyTimeoutHeight:
|
|
87
|
-
height, err := clienttypes.ParseHeight(
|
|
87
|
+
height, err := clienttypes.ParseHeight(attr.Value)
|
|
88
88
|
if err != nil {
|
|
89
89
|
return channeltypes.Packet{}, err
|
|
90
90
|
}
|
|
@@ -92,7 +92,7 @@ func ParsePacketFromFilteredEvents(events sdk.Events, filteredType string) (chan
|
|
|
92
92
|
packet.TimeoutHeight = height
|
|
93
93
|
|
|
94
94
|
case channeltypes.AttributeKeyTimeoutTimestamp:
|
|
95
|
-
timestamp, err := strconv.ParseUint(
|
|
95
|
+
timestamp, err := strconv.ParseUint(attr.Value, 10, 64)
|
|
96
96
|
if err != nil {
|
|
97
97
|
return channeltypes.Packet{}, err
|
|
98
98
|
}
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
package cmd
|
|
2
|
-
|
|
3
|
-
import (
|
|
4
|
-
"bufio"
|
|
5
|
-
"encoding/json"
|
|
6
|
-
"errors"
|
|
7
|
-
"fmt"
|
|
8
|
-
|
|
9
|
-
"github.com/spf13/cobra"
|
|
10
|
-
|
|
11
|
-
"github.com/cosmos/cosmos-sdk/client"
|
|
12
|
-
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
13
|
-
"github.com/cosmos/cosmos-sdk/codec"
|
|
14
|
-
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
|
15
|
-
"github.com/cosmos/cosmos-sdk/server"
|
|
16
|
-
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
17
|
-
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
|
18
|
-
authvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
|
|
19
|
-
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
|
20
|
-
"github.com/cosmos/cosmos-sdk/x/genutil"
|
|
21
|
-
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
const (
|
|
25
|
-
flagVestingStart = "vesting-start-time"
|
|
26
|
-
flagVestingEnd = "vesting-end-time"
|
|
27
|
-
flagVestingAmt = "vesting-amount"
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
// AddGenesisAccountCmd returns add-genesis-account cobra Command.
|
|
31
|
-
func AddGenesisAccountCmd(cdc codec.Codec, defaultNodeHome string) *cobra.Command {
|
|
32
|
-
cmd := &cobra.Command{
|
|
33
|
-
Use: "add-genesis-account <address_or_key_name> <coin>[,...]",
|
|
34
|
-
Short: "Add a genesis account to genesis.json",
|
|
35
|
-
Long: `Add a genesis account to genesis.json.
|
|
36
|
-
If the address is specified by name, it will be looked up in the local Keybase.
|
|
37
|
-
The comma-separated list of initial tokens must contain valid denominations.
|
|
38
|
-
Accounts may optionally be supplied with vesting parameters.
|
|
39
|
-
`,
|
|
40
|
-
Args: cobra.ExactArgs(2),
|
|
41
|
-
RunE: func(cmd *cobra.Command, args []string) error {
|
|
42
|
-
clientCtx := client.GetClientContextFromCmd(cmd)
|
|
43
|
-
|
|
44
|
-
serverCtx := server.GetServerContextFromCmd(cmd)
|
|
45
|
-
config := serverCtx.Config
|
|
46
|
-
|
|
47
|
-
config.SetRoot(clientCtx.HomeDir)
|
|
48
|
-
|
|
49
|
-
addr, err := sdk.AccAddressFromBech32(args[0])
|
|
50
|
-
if err != nil {
|
|
51
|
-
inBuf := bufio.NewReader(cmd.InOrStdin())
|
|
52
|
-
keyringBackend, err := cmd.Flags().GetString(flags.FlagKeyringBackend)
|
|
53
|
-
if err != nil {
|
|
54
|
-
return err
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// attempt to lookup address from Keybase if no address was provided
|
|
58
|
-
kb, err := keyring.New(sdk.KeyringServiceName(), keyringBackend, clientCtx.KeyringDir, inBuf, cdc)
|
|
59
|
-
if err != nil {
|
|
60
|
-
return err
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
info, err := kb.Key(args[0])
|
|
64
|
-
if err != nil {
|
|
65
|
-
return fmt.Errorf("failed to get key from Keybase: %s", err)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
addr, err = info.GetAddress()
|
|
69
|
-
if err != nil {
|
|
70
|
-
return fmt.Errorf("failed to get address from Keybase: %s", err)
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
coins, err := sdk.ParseCoinsNormalized(args[1])
|
|
75
|
-
if err != nil {
|
|
76
|
-
return fmt.Errorf("failed to parse coins: %s", err)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
vestingStart, err := cmd.Flags().GetInt64(flagVestingStart)
|
|
80
|
-
if err != nil {
|
|
81
|
-
return err
|
|
82
|
-
}
|
|
83
|
-
vestingEnd, err := cmd.Flags().GetInt64(flagVestingEnd)
|
|
84
|
-
if err != nil {
|
|
85
|
-
return err
|
|
86
|
-
}
|
|
87
|
-
vestingAmtStr, err := cmd.Flags().GetString(flagVestingAmt)
|
|
88
|
-
if err != nil {
|
|
89
|
-
return err
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
vestingAmt, err := sdk.ParseCoinsNormalized(vestingAmtStr)
|
|
93
|
-
if err != nil {
|
|
94
|
-
return fmt.Errorf("failed to parse vesting amount: %s", err)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// create concrete account type based on input parameters
|
|
98
|
-
var genAccount authtypes.GenesisAccount
|
|
99
|
-
|
|
100
|
-
balances := banktypes.Balance{Address: addr.String(), Coins: coins.Sort()}
|
|
101
|
-
baseAccount := authtypes.NewBaseAccount(addr, nil, 0, 0)
|
|
102
|
-
|
|
103
|
-
if !vestingAmt.IsZero() {
|
|
104
|
-
baseVestingAccount := authvesting.NewBaseVestingAccount(baseAccount, vestingAmt.Sort(), vestingEnd)
|
|
105
|
-
|
|
106
|
-
if (balances.Coins.IsZero() && !baseVestingAccount.OriginalVesting.IsZero()) ||
|
|
107
|
-
baseVestingAccount.OriginalVesting.IsAnyGT(balances.Coins) {
|
|
108
|
-
return errors.New("vesting amount cannot be greater than total amount")
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
switch {
|
|
112
|
-
case vestingStart != 0 && vestingEnd != 0:
|
|
113
|
-
genAccount = authvesting.NewContinuousVestingAccountRaw(baseVestingAccount, vestingStart)
|
|
114
|
-
|
|
115
|
-
case vestingEnd != 0:
|
|
116
|
-
genAccount = authvesting.NewDelayedVestingAccountRaw(baseVestingAccount)
|
|
117
|
-
|
|
118
|
-
default:
|
|
119
|
-
return errors.New("invalid vesting parameters; must supply start and end time or end time")
|
|
120
|
-
}
|
|
121
|
-
} else {
|
|
122
|
-
genAccount = baseAccount
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if err := genAccount.Validate(); err != nil {
|
|
126
|
-
return fmt.Errorf("failed to validate new genesis account: %s", err)
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
genFile := config.GenesisFile()
|
|
130
|
-
appState, genDoc, err := genutiltypes.GenesisStateFromGenFile(genFile)
|
|
131
|
-
if err != nil {
|
|
132
|
-
return fmt.Errorf("failed to unmarshal genesis state: %s", err)
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
authGenState := authtypes.GetGenesisStateFromAppState(clientCtx.Codec, appState)
|
|
136
|
-
|
|
137
|
-
accs, err := authtypes.UnpackAccounts(authGenState.Accounts)
|
|
138
|
-
if err != nil {
|
|
139
|
-
return fmt.Errorf("failed to get accounts from any: %s", err)
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if accs.Contains(addr) {
|
|
143
|
-
return fmt.Errorf("cannot add account at existing address %s", addr)
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// Add the new account to the set of genesis accounts and sanitize the
|
|
147
|
-
// accounts afterwards.
|
|
148
|
-
accs = append(accs, genAccount)
|
|
149
|
-
accs = authtypes.SanitizeGenesisAccounts(accs)
|
|
150
|
-
|
|
151
|
-
genAccs, err := authtypes.PackAccounts(accs)
|
|
152
|
-
if err != nil {
|
|
153
|
-
return fmt.Errorf("failed to convert accounts into any's: %s", err)
|
|
154
|
-
}
|
|
155
|
-
authGenState.Accounts = genAccs
|
|
156
|
-
|
|
157
|
-
authGenStateBz, err := clientCtx.Codec.MarshalJSON(&authGenState)
|
|
158
|
-
if err != nil {
|
|
159
|
-
return fmt.Errorf("failed to marshal auth genesis state: %s", err)
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
appState[authtypes.ModuleName] = authGenStateBz
|
|
163
|
-
|
|
164
|
-
bankGenState := banktypes.GetGenesisStateFromAppState(clientCtx.Codec, appState)
|
|
165
|
-
bankGenState.Balances = append(bankGenState.Balances, balances)
|
|
166
|
-
bankGenState.Balances = banktypes.SanitizeGenesisBalances(bankGenState.Balances)
|
|
167
|
-
bankGenState.Supply = bankGenState.Supply.Add(balances.Coins...)
|
|
168
|
-
|
|
169
|
-
bankGenStateBz, err := clientCtx.Codec.MarshalJSON(bankGenState)
|
|
170
|
-
if err != nil {
|
|
171
|
-
return fmt.Errorf("failed to marshal bank genesis state: %s", err)
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
appState[banktypes.ModuleName] = bankGenStateBz
|
|
175
|
-
|
|
176
|
-
appStateJSON, err := json.Marshal(appState)
|
|
177
|
-
if err != nil {
|
|
178
|
-
return fmt.Errorf("failed to marshal application genesis state: %s", err)
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
genDoc.AppState = appStateJSON
|
|
182
|
-
return genutil.ExportGenesisFile(genDoc, genFile)
|
|
183
|
-
},
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
cmd.Flags().String(flags.FlagHome, defaultNodeHome, "The application home directory")
|
|
187
|
-
cmd.Flags().String(flags.FlagKeyringBackend, flags.DefaultKeyringBackend, "Select keyring's backend (os|file|kwallet|pass|test)")
|
|
188
|
-
cmd.Flags().String(flags.FlagKeyringDir, "", "Keyring's key storage directory")
|
|
189
|
-
cmd.Flags().String(flagVestingAmt, "", "amount of coins for vesting accounts")
|
|
190
|
-
cmd.Flags().Int64(flagVestingStart, 0, "schedule start time (unix epoch) for vesting accounts")
|
|
191
|
-
cmd.Flags().Int64(flagVestingEnd, 0, "schedule end time (unix epoch) for vesting accounts")
|
|
192
|
-
flags.AddQueryFlagsToCmd(cmd)
|
|
193
|
-
|
|
194
|
-
return cmd
|
|
195
|
-
}
|