@agoric/cosmos 0.34.1 → 0.34.2-calypso-dev-84eb287.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/MAINTAINERS.md +3 -0
- package/Makefile +67 -41
- package/agoric/config.go +35 -0
- package/ante/ante.go +65 -0
- package/ante/expected_keepers.go +26 -0
- package/ante/inbound.go +137 -0
- package/ante/inbound_test.go +228 -0
- package/ante/vm_admission.go +65 -0
- package/app/app.go +396 -211
- package/app/export.go +13 -9
- package/app/sim_test.go +4 -4
- package/app/upgrade.go +215 -0
- package/binding.gyp.in +29 -4
- package/buf.work.yaml +4 -0
- package/cmd/agd/agvm.go +42 -0
- package/cmd/agd/find_binary.go +22 -7
- package/cmd/agd/main.go +133 -10
- package/cmd/libdaemon/main.go +67 -53
- package/cmd/libdaemon/main_test.go +37 -0
- package/daemon/cmd/genaccounts.go +22 -18
- package/daemon/cmd/root.go +253 -52
- package/daemon/cmd/root_test.go +190 -2
- package/daemon/cmd/testnet.go +17 -6
- package/daemon/main.go +6 -3
- 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 -0
- package/go.mod +207 -0
- package/go.sum +1877 -0
- package/package.json +13 -21
- package/proto/agoric/swingset/genesis.proto +14 -0
- package/proto/agoric/swingset/swingset.proto +6 -3
- package/proto/agoric/vlocalchain/.clang-format +7 -0
- package/proto/agoric/vlocalchain/vlocalchain.proto +31 -0
- package/proto/agoric/vstorage/query.proto +53 -1
- package/proto/agoric/vtransfer/genesis.proto +18 -0
- package/scripts/protocgen.sh +16 -6
- package/third_party/proto/buf.yaml +1 -0
- package/third_party/proto/cosmos/base/query/v1beta1/pagination.proto +4 -1
- package/third_party/proto/cosmos/base/v1beta1/coin.proto +7 -4
- package/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto +16 -6
- package/third_party/proto/cosmos_proto/cosmos.proto +97 -0
- package/third_party/proto/google/api/annotations.proto +1 -1
- package/third_party/proto/google/api/http.proto +181 -120
- package/third_party/proto/google/api/httpbody.proto +9 -6
- package/third_party/proto/google/protobuf/any.proto +1 -7
- package/third_party/proto/ibc/core/channel/v1/channel.proto +15 -1
- package/third_party/proto/ibc/core/client/v1/client.proto +9 -6
- package/tools/tools.go +11 -0
- package/types/events.go +41 -0
- package/types/kv_entry.go +114 -0
- package/types/kv_entry_helpers.go +276 -0
- package/types/kv_entry_helpers_test.go +237 -0
- package/types/kv_entry_test.go +143 -0
- package/upgradegaia.sh +75 -0
- package/vm/action.go +134 -0
- package/vm/action_test.go +149 -0
- package/vm/client.go +113 -0
- package/vm/client_test.go +182 -0
- package/vm/controller.go +49 -0
- package/vm/core_proposals.go +51 -0
- 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 +26 -37
- package/x/swingset/alias.go +9 -6
- package/x/swingset/client/cli/query.go +2 -2
- package/x/swingset/client/cli/tx.go +52 -33
- package/x/swingset/client/proposal_handler.go +2 -17
- package/x/swingset/genesis.go +163 -37
- package/x/swingset/handler.go +2 -1
- package/x/swingset/keeper/extension_snapshotter.go +309 -0
- package/x/swingset/keeper/extension_snapshotter_test.go +104 -0
- package/x/swingset/keeper/keeper.go +95 -48
- package/x/swingset/keeper/keeper_test.go +77 -0
- package/x/swingset/keeper/migrations.go +7 -2
- package/x/swingset/keeper/msg_server.go +71 -56
- package/x/swingset/keeper/proposal.go +15 -9
- package/x/swingset/keeper/querier.go +24 -15
- package/x/swingset/keeper/swing_store_exports_handler.go +872 -0
- package/x/swingset/keeper/swing_store_exports_handler_test.go +247 -0
- package/x/swingset/keeper/test_utils.go +16 -0
- package/x/swingset/module.go +33 -11
- package/x/swingset/proposal_handler.go +5 -4
- package/x/swingset/swingset.go +73 -0
- package/x/swingset/testing/queue.go +17 -0
- package/x/swingset/types/codec.go +2 -2
- package/x/swingset/types/default-params.go +23 -17
- package/x/swingset/types/expected_keepers.go +14 -2
- package/x/swingset/types/genesis.pb.go +361 -18
- package/x/swingset/types/msgs.go +87 -26
- package/x/swingset/types/msgs.pb.go +16 -16
- package/x/swingset/types/params.go +76 -1
- package/x/swingset/types/params_test.go +116 -0
- package/x/swingset/types/proposal.go +10 -9
- package/x/swingset/types/swingset.pb.go +83 -81
- package/x/swingset/types/types.go +30 -28
- package/x/vbank/genesis.go +0 -2
- package/x/vbank/handler.go +2 -1
- package/x/vbank/keeper/keeper.go +3 -2
- package/x/vbank/keeper/querier.go +9 -4
- package/x/vbank/keeper/rewards.go +1 -1
- package/x/vbank/module.go +0 -5
- package/x/vbank/types/msgs.go +0 -12
- package/x/vbank/vbank.go +34 -32
- package/x/vbank/vbank_test.go +20 -20
- package/x/vibc/alias.go +3 -0
- package/x/vibc/handler.go +17 -15
- package/x/vibc/keeper/keeper.go +113 -89
- package/x/vibc/keeper/triggers.go +101 -0
- package/x/vibc/module.go +5 -8
- package/x/vibc/types/expected_keepers.go +28 -6
- package/x/vibc/types/ibc_module.go +336 -0
- package/x/vibc/types/msgs.go +1 -1
- package/x/vibc/types/msgs.pb.go +1 -1
- 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/README.md +138 -0
- package/x/vstorage/capdata/capdata.go +298 -0
- package/x/vstorage/capdata/capdata_test.go +352 -0
- package/x/vstorage/client/cli/query.go +51 -4
- package/x/vstorage/genesis.go +0 -3
- package/x/vstorage/handler.go +2 -1
- package/x/vstorage/keeper/grpc_query.go +220 -0
- package/x/vstorage/keeper/keeper.go +75 -57
- package/x/vstorage/keeper/keeper_grpc_test.go +300 -0
- package/x/vstorage/keeper/keeper_test.go +40 -62
- package/x/vstorage/keeper/querier.go +39 -14
- package/x/vstorage/keeper/querier_test.go +113 -0
- package/x/vstorage/module.go +0 -5
- package/x/vstorage/testing/queue.go +27 -0
- package/x/vstorage/types/path_keys.go +22 -10
- package/x/vstorage/types/path_keys_test.go +84 -18
- package/x/vstorage/types/query.pb.go +646 -36
- package/x/vstorage/types/query.pb.gw.go +119 -0
- package/x/vstorage/types/types.go +0 -66
- package/x/vstorage/vstorage.go +33 -35
- package/x/vstorage/vstorage_test.go +19 -19
- 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/app/const.go +0 -6
- package/cmd/helper/main.go +0 -21
- 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 -285
- package/x/lien/keeper/keeper.go +0 -254
- package/x/lien/keeper/keeper_test.go +0 -623
- package/x/lien/lien.go +0 -203
- package/x/lien/lien_test.go +0 -529
- 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/swingset/keeper/snapshotter.go +0 -491
- package/x/swingset/keeper/snapshotter_test.go +0 -185
- package/x/swingset/legacy/v32/params.go +0 -37
- package/x/swingset/legacy/v32/params_test.go +0 -133
- package/x/vibc/ibc.go +0 -442
- /package/{src/index.cjs → index.cjs} +0 -0
|
@@ -3,6 +3,7 @@ package types
|
|
|
3
3
|
import (
|
|
4
4
|
"encoding/json"
|
|
5
5
|
"errors"
|
|
6
|
+
"fmt"
|
|
6
7
|
|
|
7
8
|
vstoragetypes "github.com/Agoric/agoric-sdk/golang/cosmos/x/vstorage/types"
|
|
8
9
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
@@ -25,18 +26,16 @@ func NewEgress(nickname string, peer sdk.AccAddress, powerFlags []string) *Egres
|
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
//
|
|
29
|
+
// Nat is analogous to @endo/nat
|
|
30
|
+
// https://github.com/endojs/endo/blob/master/packages/nat
|
|
29
31
|
func Nat(num float64) (uint64, error) {
|
|
30
|
-
if num <
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if float64(nat) != num {
|
|
36
|
-
return 0, errors.New("Not a precise integer")
|
|
32
|
+
if 0 <= num && num < (1<<53) {
|
|
33
|
+
nat := uint64(num)
|
|
34
|
+
if float64(nat) == num {
|
|
35
|
+
return nat, nil
|
|
36
|
+
}
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
return nat, nil
|
|
38
|
+
return 0, errors.New("Not a Nat")
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
type Messages struct {
|
|
@@ -45,24 +44,26 @@ type Messages struct {
|
|
|
45
44
|
Ack uint64
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
// UnmarshalMessagesJSON decodes Messages from JSON text.
|
|
48
|
+
// Input must represent an array in which the first element is an array of
|
|
49
|
+
// [messageNum: integer, messageBody: string] pairs and the second element is
|
|
50
|
+
// an "Ack" integer.
|
|
51
|
+
func UnmarshalMessagesJSON(jsonString string) (ret *Messages, err error) {
|
|
52
|
+
packet := [2]interface{}{}
|
|
53
|
+
err = json.Unmarshal([]byte(jsonString), &packet)
|
|
53
54
|
if err != nil {
|
|
54
55
|
return nil, err
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
ret
|
|
58
|
+
ret = &Messages{}
|
|
58
59
|
|
|
59
60
|
ackFloat, ok := packet[1].(float64)
|
|
60
61
|
if !ok {
|
|
61
|
-
return nil, errors.New("Ack is not
|
|
62
|
+
return nil, errors.New("Ack is not a number")
|
|
62
63
|
}
|
|
63
64
|
ret.Ack, err = Nat(ackFloat)
|
|
64
65
|
if err != nil {
|
|
65
|
-
return nil,
|
|
66
|
+
return nil, errors.New("Ack is not a Nat")
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
msgs, ok := packet[0].([]interface{})
|
|
@@ -72,24 +73,25 @@ func UnmarshalMessagesJSON(jsonString string) (*Messages, error) {
|
|
|
72
73
|
|
|
73
74
|
ret.Messages = make([]string, len(msgs))
|
|
74
75
|
ret.Nums = make([]uint64, len(msgs))
|
|
75
|
-
for i,
|
|
76
|
-
|
|
77
|
-
if !ok || len(
|
|
78
|
-
return nil,
|
|
76
|
+
for i, rawMsg := range msgs {
|
|
77
|
+
arrMsg, ok := rawMsg.([]interface{})
|
|
78
|
+
if !ok || len(arrMsg) != 2 {
|
|
79
|
+
return nil, fmt.Errorf("Messages[%d] is not a pair", i)
|
|
79
80
|
}
|
|
80
|
-
|
|
81
|
+
|
|
82
|
+
numFloat, ok := arrMsg[0].(float64)
|
|
81
83
|
if !ok {
|
|
82
|
-
return nil,
|
|
84
|
+
return nil, fmt.Errorf("Messages[%d] Num is not a number", i)
|
|
83
85
|
}
|
|
84
86
|
ret.Nums[i], err = Nat(numFloat)
|
|
85
87
|
if err != nil {
|
|
86
|
-
return nil,
|
|
88
|
+
return nil, fmt.Errorf("Messages[%d] Num is not a Nat", i)
|
|
87
89
|
}
|
|
88
|
-
|
|
90
|
+
|
|
91
|
+
ret.Messages[i], ok = arrMsg[1].(string)
|
|
89
92
|
if !ok {
|
|
90
|
-
return nil,
|
|
93
|
+
return nil, fmt.Errorf("Messages[%d] body is not a string", i)
|
|
91
94
|
}
|
|
92
|
-
ret.Messages[i] = msg
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
return ret, nil
|
package/x/vbank/genesis.go
CHANGED
package/x/vbank/handler.go
CHANGED
|
@@ -3,6 +3,7 @@ package vbank
|
|
|
3
3
|
import (
|
|
4
4
|
"fmt"
|
|
5
5
|
|
|
6
|
+
sdkioerrors "cosmossdk.io/errors"
|
|
6
7
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
7
8
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
8
9
|
)
|
|
@@ -13,7 +14,7 @@ func NewHandler(keeper Keeper) sdk.Handler {
|
|
|
13
14
|
switch msg := msg.(type) {
|
|
14
15
|
default:
|
|
15
16
|
errMsg := fmt.Sprintf("Unrecognized vbank Msg type: %T", msg)
|
|
16
|
-
return nil,
|
|
17
|
+
return nil, sdkioerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg)
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
}
|
package/x/vbank/keeper/keeper.go
CHANGED
|
@@ -2,6 +2,7 @@ package keeper
|
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
4
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
5
|
+
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
|
5
6
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
6
7
|
|
|
7
8
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vbank/types"
|
|
@@ -15,7 +16,7 @@ const stateKey string = "state"
|
|
|
15
16
|
|
|
16
17
|
// Keeper maintains the link to data storage and exposes getter/setter methods for the various parts of the state machine
|
|
17
18
|
type Keeper struct {
|
|
18
|
-
storeKey
|
|
19
|
+
storeKey storetypes.StoreKey
|
|
19
20
|
cdc codec.Codec
|
|
20
21
|
paramSpace paramtypes.Subspace
|
|
21
22
|
|
|
@@ -27,7 +28,7 @@ type Keeper struct {
|
|
|
27
28
|
|
|
28
29
|
// NewKeeper creates a new vbank Keeper instance
|
|
29
30
|
func NewKeeper(
|
|
30
|
-
cdc codec.Codec, key
|
|
31
|
+
cdc codec.Codec, key storetypes.StoreKey, paramSpace paramtypes.Subspace,
|
|
31
32
|
accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper,
|
|
32
33
|
rewardDistributorName string,
|
|
33
34
|
pushAction vm.ActionPusher,
|
|
@@ -3,6 +3,7 @@ package keeper
|
|
|
3
3
|
import (
|
|
4
4
|
abci "github.com/tendermint/tendermint/abci/types"
|
|
5
5
|
|
|
6
|
+
sdkioerrors "cosmossdk.io/errors"
|
|
6
7
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vbank/types"
|
|
7
8
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
8
9
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
@@ -11,7 +12,11 @@ import (
|
|
|
11
12
|
|
|
12
13
|
func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
|
|
13
14
|
return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) {
|
|
14
|
-
|
|
15
|
+
var queryType string
|
|
16
|
+
if len(path) > 0 {
|
|
17
|
+
queryType = path[0]
|
|
18
|
+
}
|
|
19
|
+
switch queryType {
|
|
15
20
|
case types.QueryParams:
|
|
16
21
|
return queryParams(ctx, path[1:], req, k, legacyQuerierCdc)
|
|
17
22
|
|
|
@@ -19,7 +24,7 @@ func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
|
|
|
19
24
|
return queryState(ctx, path[1:], req, k, legacyQuerierCdc)
|
|
20
25
|
|
|
21
26
|
default:
|
|
22
|
-
return nil,
|
|
27
|
+
return nil, sdkioerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown vbank query path")
|
|
23
28
|
}
|
|
24
29
|
}
|
|
25
30
|
}
|
|
@@ -29,7 +34,7 @@ func queryParams(ctx sdk.Context, _ []string, _ abci.RequestQuery, k Keeper, leg
|
|
|
29
34
|
|
|
30
35
|
res, err := codec.MarshalJSONIndent(legacyQuerierCdc, params)
|
|
31
36
|
if err != nil {
|
|
32
|
-
return nil,
|
|
37
|
+
return nil, sdkioerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error())
|
|
33
38
|
}
|
|
34
39
|
|
|
35
40
|
return res, nil
|
|
@@ -40,7 +45,7 @@ func queryState(ctx sdk.Context, _ []string, _ abci.RequestQuery, k Keeper, lega
|
|
|
40
45
|
|
|
41
46
|
res, err := codec.MarshalJSONIndent(legacyQuerierCdc, state)
|
|
42
47
|
if err != nil {
|
|
43
|
-
return nil,
|
|
48
|
+
return nil, sdkioerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error())
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
return res, nil
|
package/x/vbank/module.go
CHANGED
|
@@ -5,7 +5,6 @@ import (
|
|
|
5
5
|
"encoding/json"
|
|
6
6
|
stdlog "log"
|
|
7
7
|
|
|
8
|
-
"github.com/gorilla/mux"
|
|
9
8
|
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
|
10
9
|
"github.com/spf13/cobra"
|
|
11
10
|
|
|
@@ -60,10 +59,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod
|
|
|
60
59
|
return ValidateGenesis(&data)
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
// Register rest routes
|
|
64
|
-
func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {
|
|
65
|
-
}
|
|
66
|
-
|
|
67
62
|
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
|
|
68
63
|
_ = types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx))
|
|
69
64
|
}
|
package/x/vbank/types/msgs.go
CHANGED
|
@@ -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
|
|
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 []
|
|
44
|
+
type vbankManyBalanceUpdates []VbankSingleBalanceUpdate
|
|
45
45
|
|
|
46
46
|
var _ sort.Interface = vbankManyBalanceUpdates{}
|
|
47
47
|
|
|
@@ -67,26 +67,25 @@ func (vbu vbankManyBalanceUpdates) Swap(i int, j int) {
|
|
|
67
67
|
vbu[i], vbu[j] = vbu[j], vbu[i]
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
type
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
Updated
|
|
70
|
+
type VbankBalanceUpdate struct {
|
|
71
|
+
*vm.ActionHeader `actionType:"VBANK_BALANCE_UPDATE"`
|
|
72
|
+
Nonce uint64 `json:"nonce"`
|
|
73
|
+
Updated vbankManyBalanceUpdates `json:"updated"`
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
// getBalanceUpdate returns a bridge message containing the current bank balance
|
|
77
77
|
// for the given addresses each for the specified denominations. Coins are used
|
|
78
78
|
// only to track the set of denoms, not for the particular nonzero amounts.
|
|
79
|
-
func getBalanceUpdate(ctx sdk.Context, keeper Keeper, addressToUpdate map[string]sdk.Coins) vm.
|
|
79
|
+
func getBalanceUpdate(ctx sdk.Context, keeper Keeper, addressToUpdate map[string]sdk.Coins) vm.Action {
|
|
80
80
|
nentries := len(addressToUpdate)
|
|
81
81
|
if nentries == 0 {
|
|
82
82
|
return nil
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
nonce := keeper.GetNextSequence(ctx)
|
|
86
|
-
event :=
|
|
87
|
-
Type: "VBANK_BALANCE_UPDATE",
|
|
86
|
+
event := VbankBalanceUpdate{
|
|
88
87
|
Nonce: nonce,
|
|
89
|
-
Updated: make([]
|
|
88
|
+
Updated: make([]VbankSingleBalanceUpdate, 0, nentries),
|
|
90
89
|
}
|
|
91
90
|
|
|
92
91
|
// Note that Golang randomises the order of iteration, so we have to sort
|
|
@@ -100,7 +99,7 @@ func getBalanceUpdate(ctx sdk.Context, keeper Keeper, addressToUpdate map[string
|
|
|
100
99
|
for _, coin := range coins {
|
|
101
100
|
// generate an update even when the current balance is zero
|
|
102
101
|
balance := keeper.GetBalance(ctx, account, coin.Denom)
|
|
103
|
-
update :=
|
|
102
|
+
update := VbankSingleBalanceUpdate{
|
|
104
103
|
Address: address,
|
|
105
104
|
Denom: coin.Denom,
|
|
106
105
|
Amount: balance.Amount.String(),
|
|
@@ -111,7 +110,9 @@ func getBalanceUpdate(ctx sdk.Context, keeper Keeper, addressToUpdate map[string
|
|
|
111
110
|
|
|
112
111
|
// Ensure we have a deterministic order of updates.
|
|
113
112
|
sort.Sort(event.Updated)
|
|
114
|
-
|
|
113
|
+
|
|
114
|
+
// Populate the event default fields (even though event does not embed vm.ActionHeader)
|
|
115
|
+
return vm.PopulateAction(ctx, event)
|
|
115
116
|
}
|
|
116
117
|
|
|
117
118
|
func marshal(event vm.Jsonable) ([]byte, error) {
|
|
@@ -121,8 +122,9 @@ func marshal(event vm.Jsonable) ([]byte, error) {
|
|
|
121
122
|
return json.Marshal(event)
|
|
122
123
|
}
|
|
123
124
|
|
|
124
|
-
func (ch portHandler) Receive(
|
|
125
|
+
func (ch portHandler) Receive(cctx context.Context, str string) (ret string, err error) {
|
|
125
126
|
// fmt.Println("vbank.go downcall", str)
|
|
127
|
+
ctx := sdk.UnwrapSDKContext(cctx)
|
|
126
128
|
keeper := ch.keeper
|
|
127
129
|
|
|
128
130
|
var msg portMessage
|
|
@@ -135,12 +137,12 @@ func (ch portHandler) Receive(ctx *vm.ControllerContext, str string) (ret string
|
|
|
135
137
|
case "VBANK_GET_BALANCE":
|
|
136
138
|
addr, err := sdk.AccAddressFromBech32(msg.Address)
|
|
137
139
|
if err != nil {
|
|
138
|
-
return "", fmt.Errorf("cannot convert %s to address: %
|
|
140
|
+
return "", fmt.Errorf("cannot convert %s to address: %s", msg.Address, err)
|
|
139
141
|
}
|
|
140
142
|
if err = sdk.ValidateDenom(msg.Denom); err != nil {
|
|
141
|
-
return "", fmt.Errorf("invalid denom %s: %
|
|
143
|
+
return "", fmt.Errorf("invalid denom %s: %s", msg.Denom, err)
|
|
142
144
|
}
|
|
143
|
-
coin := keeper.GetBalance(ctx
|
|
145
|
+
coin := keeper.GetBalance(ctx, addr, msg.Denom)
|
|
144
146
|
packet := coin.Amount.String()
|
|
145
147
|
if err == nil {
|
|
146
148
|
bytes, err := json.Marshal(&packet)
|
|
@@ -152,22 +154,22 @@ func (ch portHandler) Receive(ctx *vm.ControllerContext, str string) (ret string
|
|
|
152
154
|
case "VBANK_GRAB":
|
|
153
155
|
addr, err := sdk.AccAddressFromBech32(msg.Sender)
|
|
154
156
|
if err != nil {
|
|
155
|
-
return "", fmt.Errorf("cannot convert %s to address: %
|
|
157
|
+
return "", fmt.Errorf("cannot convert %s to address: %s", msg.Sender, err)
|
|
156
158
|
}
|
|
157
159
|
if err = sdk.ValidateDenom(msg.Denom); err != nil {
|
|
158
|
-
return "", fmt.Errorf("invalid denom %s: %
|
|
160
|
+
return "", fmt.Errorf("invalid denom %s: %s", msg.Denom, err)
|
|
159
161
|
}
|
|
160
162
|
value, ok := sdk.NewIntFromString(msg.Amount)
|
|
161
163
|
if !ok {
|
|
162
164
|
return "", fmt.Errorf("cannot convert %s to int", msg.Amount)
|
|
163
165
|
}
|
|
164
166
|
coins := sdk.NewCoins(sdk.NewCoin(msg.Denom, value))
|
|
165
|
-
if err := keeper.GrabCoins(ctx
|
|
166
|
-
return "", fmt.Errorf("cannot grab %s coins: %
|
|
167
|
+
if err := keeper.GrabCoins(ctx, addr, coins); err != nil {
|
|
168
|
+
return "", fmt.Errorf("cannot grab %s coins: %s", coins.Sort().String(), err)
|
|
167
169
|
}
|
|
168
170
|
addressToBalances := make(map[string]sdk.Coins, 1)
|
|
169
171
|
addressToBalances[msg.Sender] = sdk.NewCoins(sdk.NewInt64Coin(msg.Denom, 1))
|
|
170
|
-
bz, err := marshal(getBalanceUpdate(ctx
|
|
172
|
+
bz, err := marshal(getBalanceUpdate(ctx, keeper, addressToBalances))
|
|
171
173
|
if err != nil {
|
|
172
174
|
return "", err
|
|
173
175
|
}
|
|
@@ -180,22 +182,22 @@ func (ch portHandler) Receive(ctx *vm.ControllerContext, str string) (ret string
|
|
|
180
182
|
case "VBANK_GIVE":
|
|
181
183
|
addr, err := sdk.AccAddressFromBech32(msg.Recipient)
|
|
182
184
|
if err != nil {
|
|
183
|
-
return "", fmt.Errorf("cannot convert %s to address: %
|
|
185
|
+
return "", fmt.Errorf("cannot convert %s to address: %s", msg.Recipient, err)
|
|
184
186
|
}
|
|
185
187
|
if err = sdk.ValidateDenom(msg.Denom); err != nil {
|
|
186
|
-
return "", fmt.Errorf("invalid denom %s: %
|
|
188
|
+
return "", fmt.Errorf("invalid denom %s: %s", msg.Denom, err)
|
|
187
189
|
}
|
|
188
190
|
value, ok := sdk.NewIntFromString(msg.Amount)
|
|
189
191
|
if !ok {
|
|
190
192
|
return "", fmt.Errorf("cannot convert %s to int", msg.Amount)
|
|
191
193
|
}
|
|
192
194
|
coins := sdk.NewCoins(sdk.NewCoin(msg.Denom, value))
|
|
193
|
-
if err := keeper.SendCoins(ctx
|
|
194
|
-
return "", fmt.Errorf("cannot give %s coins: %
|
|
195
|
+
if err := keeper.SendCoins(ctx, addr, coins); err != nil {
|
|
196
|
+
return "", fmt.Errorf("cannot give %s coins: %s", coins.Sort().String(), err)
|
|
195
197
|
}
|
|
196
198
|
addressToBalances := make(map[string]sdk.Coins, 1)
|
|
197
199
|
addressToBalances[msg.Recipient] = sdk.NewCoins(sdk.NewInt64Coin(msg.Denom, 1))
|
|
198
|
-
bz, err := marshal(getBalanceUpdate(ctx
|
|
200
|
+
bz, err := marshal(getBalanceUpdate(ctx, keeper, addressToBalances))
|
|
199
201
|
if err != nil {
|
|
200
202
|
return "", err
|
|
201
203
|
}
|
|
@@ -211,20 +213,20 @@ func (ch portHandler) Receive(ctx *vm.ControllerContext, str string) (ret string
|
|
|
211
213
|
return "", fmt.Errorf("cannot convert %s to int", msg.Amount)
|
|
212
214
|
}
|
|
213
215
|
coins := sdk.NewCoins(sdk.NewCoin(msg.Denom, value))
|
|
214
|
-
if err := keeper.StoreRewardCoins(ctx
|
|
215
|
-
return "", fmt.Errorf("cannot store reward %s coins: %
|
|
216
|
+
if err := keeper.StoreRewardCoins(ctx, coins); err != nil {
|
|
217
|
+
return "", fmt.Errorf("cannot store reward %s coins: %s", coins.Sort().String(), err)
|
|
216
218
|
}
|
|
217
219
|
if err != nil {
|
|
218
220
|
return "", err
|
|
219
221
|
}
|
|
220
|
-
state := keeper.GetState(ctx
|
|
222
|
+
state := keeper.GetState(ctx)
|
|
221
223
|
state.RewardPool = state.RewardPool.Add(coins...)
|
|
222
|
-
keeper.SetState(ctx
|
|
224
|
+
keeper.SetState(ctx, state)
|
|
223
225
|
// We don't supply the module balance, since the controller shouldn't know.
|
|
224
226
|
ret = "true"
|
|
225
227
|
|
|
226
228
|
case "VBANK_GET_MODULE_ACCOUNT_ADDRESS":
|
|
227
|
-
addr := keeper.GetModuleAccountAddress(ctx
|
|
229
|
+
addr := keeper.GetModuleAccountAddress(ctx, msg.ModuleName).String()
|
|
228
230
|
if len(addr) == 0 {
|
|
229
231
|
return "", fmt.Errorf("module account %s not found", msg.ModuleName)
|
|
230
232
|
}
|
|
@@ -242,7 +244,7 @@ func (ch portHandler) Receive(ctx *vm.ControllerContext, str string) (ret string
|
|
|
242
244
|
return
|
|
243
245
|
}
|
|
244
246
|
|
|
245
|
-
func (am AppModule) PushAction(ctx sdk.Context, action vm.
|
|
247
|
+
func (am AppModule) PushAction(ctx sdk.Context, action vm.Action) error {
|
|
246
248
|
// vbank actions are not triggered by a swingset message in a transaction, so we need to
|
|
247
249
|
// synthesize unique context information.
|
|
248
250
|
// We use a fixed placeholder value for the txHash context, and can simply use `0` for the
|
package/x/vbank/vbank_test.go
CHANGED
|
@@ -71,7 +71,7 @@ func newBalances(opts ...balancesOption) balances {
|
|
|
71
71
|
return bal
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
func validateBalanceUpdate(vbu
|
|
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 :=
|
|
92
|
+
balanceUpdate := VbankBalanceUpdate{}
|
|
93
93
|
err := json.Unmarshal(encoded, &balanceUpdate)
|
|
94
94
|
if err != nil {
|
|
95
95
|
return nil, 0, err
|
|
@@ -250,7 +250,7 @@ func (b *mockBank) SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, re
|
|
|
250
250
|
func makeTestKit(account types.AccountKeeper, bank types.BankKeeper) (Keeper, sdk.Context) {
|
|
251
251
|
encodingConfig := params.MakeEncodingConfig()
|
|
252
252
|
cdc := encodingConfig.Marshaler
|
|
253
|
-
pushAction := func(ctx sdk.Context, action vm.
|
|
253
|
+
pushAction := func(ctx sdk.Context, action vm.Action) error {
|
|
254
254
|
return nil
|
|
255
255
|
}
|
|
256
256
|
|
|
@@ -263,9 +263,9 @@ func makeTestKit(account types.AccountKeeper, bank types.BankKeeper) (Keeper, sd
|
|
|
263
263
|
|
|
264
264
|
db := dbm.NewMemDB()
|
|
265
265
|
ms := store.NewCommitMultiStore(db)
|
|
266
|
-
ms.MountStoreWithDB(vbankStoreKey,
|
|
267
|
-
ms.MountStoreWithDB(paramsStoreKey,
|
|
268
|
-
ms.MountStoreWithDB(paramsTStoreKey,
|
|
266
|
+
ms.MountStoreWithDB(vbankStoreKey, storetypes.StoreTypeIAVL, db)
|
|
267
|
+
ms.MountStoreWithDB(paramsStoreKey, storetypes.StoreTypeIAVL, db)
|
|
268
|
+
ms.MountStoreWithDB(paramsTStoreKey, storetypes.StoreTypeTransient, db)
|
|
269
269
|
err := ms.LoadLatestVersion()
|
|
270
270
|
if err != nil {
|
|
271
271
|
panic(err)
|
|
@@ -284,7 +284,7 @@ func Test_Receive_GetBalance(t *testing.T) {
|
|
|
284
284
|
}}
|
|
285
285
|
keeper, ctx := makeTestKit(nil, bank)
|
|
286
286
|
ch := NewPortHandler(AppModule{}, keeper)
|
|
287
|
-
ctlCtx :=
|
|
287
|
+
ctlCtx := sdk.WrapSDKContext(ctx)
|
|
288
288
|
|
|
289
289
|
ret, err := ch.Receive(ctlCtx, `{
|
|
290
290
|
"type": "VBANK_GET_BALANCE",
|
|
@@ -312,7 +312,7 @@ func Test_Receive_Give(t *testing.T) {
|
|
|
312
312
|
}}
|
|
313
313
|
keeper, ctx := makeTestKit(nil, bank)
|
|
314
314
|
ch := NewPortHandler(AppModule{}, keeper)
|
|
315
|
-
ctlCtx :=
|
|
315
|
+
ctlCtx := sdk.WrapSDKContext(ctx)
|
|
316
316
|
|
|
317
317
|
ret, err := ch.Receive(ctlCtx, `{
|
|
318
318
|
"type": "VBANK_GIVE",
|
|
@@ -349,7 +349,7 @@ func Test_Receive_GiveToRewardDistributor(t *testing.T) {
|
|
|
349
349
|
bank := &mockBank{}
|
|
350
350
|
keeper, ctx := makeTestKit(nil, bank)
|
|
351
351
|
ch := NewPortHandler(AppModule{}, keeper)
|
|
352
|
-
ctlCtx :=
|
|
352
|
+
ctlCtx := sdk.WrapSDKContext(ctx)
|
|
353
353
|
|
|
354
354
|
tests := []struct {
|
|
355
355
|
name string
|
|
@@ -474,7 +474,7 @@ func Test_Receive_Grab(t *testing.T) {
|
|
|
474
474
|
}}
|
|
475
475
|
keeper, ctx := makeTestKit(nil, bank)
|
|
476
476
|
ch := NewPortHandler(AppModule{}, keeper)
|
|
477
|
-
ctlCtx :=
|
|
477
|
+
ctlCtx := sdk.WrapSDKContext(ctx)
|
|
478
478
|
|
|
479
479
|
ret, err := ch.Receive(ctlCtx, `{
|
|
480
480
|
"type": "VBANK_GRAB",
|
|
@@ -517,16 +517,16 @@ func Test_EndBlock_Events(t *testing.T) {
|
|
|
517
517
|
}}
|
|
518
518
|
acct := &mockAuthKeeper{
|
|
519
519
|
accounts: map[string]authtypes.AccountI{
|
|
520
|
-
addr1: &authtypes.ModuleAccount{BaseAccount: &authtypes.BaseAccount{
|
|
521
|
-
addr2: &authtypes.ModuleAccount{BaseAccount: &authtypes.BaseAccount{
|
|
522
|
-
addr3: &authtypes.BaseAccount{
|
|
520
|
+
addr1: &authtypes.ModuleAccount{BaseAccount: &authtypes.BaseAccount{Address: addr1}},
|
|
521
|
+
addr2: &authtypes.ModuleAccount{BaseAccount: &authtypes.BaseAccount{Address: addr2}},
|
|
522
|
+
addr3: &authtypes.BaseAccount{Address: addr3},
|
|
523
523
|
},
|
|
524
524
|
}
|
|
525
525
|
keeper, ctx := makeTestKit(acct, bank)
|
|
526
526
|
// Turn off rewards.
|
|
527
527
|
keeper.SetParams(ctx, types.Params{PerEpochRewardFraction: sdk.ZeroDec()})
|
|
528
528
|
msgsSent := []string{}
|
|
529
|
-
keeper.PushAction = func(ctx sdk.Context, action vm.
|
|
529
|
+
keeper.PushAction = func(ctx sdk.Context, action vm.Action) error {
|
|
530
530
|
bz, err := json.Marshal(action)
|
|
531
531
|
if err != nil {
|
|
532
532
|
return err
|
|
@@ -630,7 +630,7 @@ func Test_EndBlock_Rewards(t *testing.T) {
|
|
|
630
630
|
}
|
|
631
631
|
keeper, ctx := makeTestKit(nil, bank)
|
|
632
632
|
msgsSent := []string{}
|
|
633
|
-
keeper.PushAction = func(ctx sdk.Context, action vm.
|
|
633
|
+
keeper.PushAction = func(ctx sdk.Context, action vm.Action) error {
|
|
634
634
|
bz, err := json.Marshal(action)
|
|
635
635
|
if err != nil {
|
|
636
636
|
return err
|
|
@@ -746,7 +746,7 @@ func Test_EndBlock_Rewards(t *testing.T) {
|
|
|
746
746
|
}
|
|
747
747
|
}
|
|
748
748
|
|
|
749
|
-
type mockAuthKeeper struct{
|
|
749
|
+
type mockAuthKeeper struct {
|
|
750
750
|
accounts map[string]authtypes.AccountI
|
|
751
751
|
modAddrs map[string]string
|
|
752
752
|
}
|
|
@@ -754,11 +754,11 @@ type mockAuthKeeper struct{
|
|
|
754
754
|
func (ma mockAuthKeeper) GetModuleAccount(ctx sdk.Context, name string) authtypes.ModuleAccountI {
|
|
755
755
|
addr, ok := ma.modAddrs[name]
|
|
756
756
|
if !ok {
|
|
757
|
-
|
|
757
|
+
return nil
|
|
758
758
|
}
|
|
759
759
|
acct, ok := ma.accounts[addr]
|
|
760
760
|
if !ok {
|
|
761
|
-
|
|
761
|
+
panic("missing module account")
|
|
762
762
|
}
|
|
763
763
|
return acct.(authtypes.ModuleAccountI)
|
|
764
764
|
}
|
|
@@ -778,7 +778,7 @@ func Test_Module_Account(t *testing.T) {
|
|
|
778
778
|
acct := &mockAuthKeeper{
|
|
779
779
|
accounts: map[string]authtypes.AccountI{
|
|
780
780
|
moduleBech32: authtypes.NewEmptyModuleAccount("vbank/reserve"),
|
|
781
|
-
addr1:
|
|
781
|
+
addr1: authtypes.NewBaseAccountWithAddress(sdk.MustAccAddressFromBech32(addr1)),
|
|
782
782
|
},
|
|
783
783
|
modAddrs: map[string]string{
|
|
784
784
|
"vbank/reserve": moduleBech32,
|
|
@@ -787,7 +787,7 @@ func Test_Module_Account(t *testing.T) {
|
|
|
787
787
|
keeper, ctx := makeTestKit(acct, nil)
|
|
788
788
|
am := AppModule{keeper: keeper}
|
|
789
789
|
ch := NewPortHandler(am, keeper)
|
|
790
|
-
ctlCtx :=
|
|
790
|
+
ctlCtx := sdk.WrapSDKContext(ctx)
|
|
791
791
|
|
|
792
792
|
mod1 := "vbank/reserve"
|
|
793
793
|
ret, err := ch.Receive(ctlCtx, `{
|
package/x/vibc/alias.go
CHANGED
|
@@ -14,11 +14,14 @@ const (
|
|
|
14
14
|
var (
|
|
15
15
|
NewKeeper = keeper.NewKeeper
|
|
16
16
|
NewMsgSendPacket = types.NewMsgSendPacket
|
|
17
|
+
NewReceiver = types.NewReceiver
|
|
18
|
+
NewIBCModule = types.NewIBCModule
|
|
17
19
|
ModuleCdc = types.ModuleCdc
|
|
18
20
|
RegisterCodec = types.RegisterCodec
|
|
19
21
|
)
|
|
20
22
|
|
|
21
23
|
type (
|
|
22
24
|
Keeper = keeper.Keeper
|
|
25
|
+
ScopedKeeper = types.ScopedKeeper
|
|
23
26
|
MsgSendPacket = types.MsgSendPacket
|
|
24
27
|
)
|
package/x/vibc/handler.go
CHANGED
|
@@ -3,48 +3,50 @@ package vibc
|
|
|
3
3
|
import (
|
|
4
4
|
"fmt"
|
|
5
5
|
|
|
6
|
+
sdkioerrors "cosmossdk.io/errors"
|
|
7
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
|
|
8
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vibc/types"
|
|
6
9
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
7
10
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
8
11
|
)
|
|
9
12
|
|
|
10
13
|
// NewHandler returns a handler for "vibc" type messages.
|
|
11
|
-
func NewHandler(keeper Keeper) sdk.Handler {
|
|
14
|
+
func NewHandler(keeper Keeper, bankKeeper types.BankKeeper) sdk.Handler {
|
|
12
15
|
return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
|
|
13
16
|
switch msg := msg.(type) {
|
|
14
17
|
case *MsgSendPacket:
|
|
15
|
-
return handleMsgSendPacket(ctx, keeper, msg)
|
|
18
|
+
return handleMsgSendPacket(ctx, keeper, bankKeeper, msg)
|
|
16
19
|
|
|
17
20
|
default:
|
|
18
21
|
errMsg := fmt.Sprintf("Unrecognized vibc Msg type: %T", msg)
|
|
19
|
-
return nil,
|
|
22
|
+
return nil, sdkioerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg)
|
|
20
23
|
}
|
|
21
24
|
}
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
type sendPacketAction struct {
|
|
28
|
+
*vm.ActionHeader `actionType:"IBC_EVENT"`
|
|
29
|
+
Event string `json:"event" default:"sendPacket"`
|
|
25
30
|
*MsgSendPacket
|
|
26
|
-
Type string `json:"type"` // IBC_EVENT
|
|
27
|
-
Event string `json:"event"` // sendPacket
|
|
28
|
-
BlockHeight int64 `json:"blockHeight"`
|
|
29
|
-
BlockTime int64 `json:"blockTime"`
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
func handleMsgSendPacket(
|
|
33
|
+
func handleMsgSendPacket(
|
|
34
|
+
ctx sdk.Context,
|
|
35
|
+
keeper Keeper,
|
|
36
|
+
bankKeeper types.BankKeeper,
|
|
37
|
+
msg *MsgSendPacket,
|
|
38
|
+
) (*sdk.Result, error) {
|
|
33
39
|
onePass := sdk.NewInt64Coin("sendpacketpass", 1)
|
|
34
|
-
balance :=
|
|
40
|
+
balance := bankKeeper.GetBalance(ctx, msg.Sender, onePass.Denom)
|
|
35
41
|
if balance.IsLT(onePass) {
|
|
36
|
-
return nil,
|
|
42
|
+
return nil, sdkioerrors.Wrap(
|
|
37
43
|
sdkerrors.ErrInsufficientFee,
|
|
38
44
|
fmt.Sprintf("sender %s needs at least %s", msg.Sender, onePass.String()),
|
|
39
45
|
)
|
|
40
46
|
}
|
|
41
47
|
|
|
42
|
-
action :=
|
|
48
|
+
action := sendPacketAction{
|
|
43
49
|
MsgSendPacket: msg,
|
|
44
|
-
Type: "IBC_EVENT",
|
|
45
|
-
Event: "sendPacket",
|
|
46
|
-
BlockHeight: ctx.BlockHeight(),
|
|
47
|
-
BlockTime: ctx.BlockTime().Unix(),
|
|
48
50
|
}
|
|
49
51
|
// fmt.Fprintf(os.Stderr, "Context is %+v\n", ctx)
|
|
50
52
|
|