@agoric/cosmos 0.34.1 → 0.34.2-calypso-dev-dabccdc.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
package/cmd/libdaemon/main.go
CHANGED
|
@@ -10,8 +10,9 @@ package main
|
|
|
10
10
|
import "C"
|
|
11
11
|
|
|
12
12
|
import (
|
|
13
|
+
"context"
|
|
13
14
|
"encoding/json"
|
|
14
|
-
"
|
|
15
|
+
"net/rpc"
|
|
15
16
|
"os"
|
|
16
17
|
"path/filepath"
|
|
17
18
|
|
|
@@ -21,6 +22,7 @@ import (
|
|
|
21
22
|
"github.com/Agoric/agoric-sdk/golang/cosmos/daemon"
|
|
22
23
|
daemoncmd "github.com/Agoric/agoric-sdk/golang/cosmos/daemon/cmd"
|
|
23
24
|
"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
|
|
25
|
+
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
|
24
26
|
)
|
|
25
27
|
|
|
26
28
|
type goReturn = struct {
|
|
@@ -30,8 +32,32 @@ type goReturn = struct {
|
|
|
30
32
|
|
|
31
33
|
const SwingSetPort = 123
|
|
32
34
|
|
|
33
|
-
var
|
|
34
|
-
var
|
|
35
|
+
var vmClientCodec *vm.ClientCodec
|
|
36
|
+
var agdServer *vm.AgdServer
|
|
37
|
+
|
|
38
|
+
// ConnectVMClientCodec creates an RPC client codec and a sender to the
|
|
39
|
+
// in-process implementation of the VM.
|
|
40
|
+
func ConnectVMClientCodec(ctx context.Context, nodePort int, sendFunc func(int, int, string)) (*vm.ClientCodec, vm.Sender) {
|
|
41
|
+
vmClientCodec = vm.NewClientCodec(ctx, sendFunc)
|
|
42
|
+
vmClient := rpc.NewClientWithCodec(vmClientCodec)
|
|
43
|
+
|
|
44
|
+
var sendToNode vm.Sender = func(ctx context.Context, needReply bool, jsonRequest string) (jsonReply string, err error) {
|
|
45
|
+
if jsonRequest == "shutdown" {
|
|
46
|
+
return "", vmClientCodec.Close()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
msg := vm.Message{
|
|
50
|
+
Port: nodePort,
|
|
51
|
+
NeedsReply: needReply,
|
|
52
|
+
Data: jsonRequest,
|
|
53
|
+
}
|
|
54
|
+
var reply string
|
|
55
|
+
err = vmClient.Call(vm.ReceiveMessageMethod, msg, &reply)
|
|
56
|
+
return reply, err
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return vmClientCodec, sendToNode
|
|
60
|
+
}
|
|
35
61
|
|
|
36
62
|
//export RunAgCosmosDaemon
|
|
37
63
|
func RunAgCosmosDaemon(nodePort C.int, toNode C.sendFunc, cosmosArgs []*C.char) C.int {
|
|
@@ -42,46 +68,39 @@ func RunAgCosmosDaemon(nodePort C.int, toNode C.sendFunc, cosmosArgs []*C.char)
|
|
|
42
68
|
|
|
43
69
|
gaia.DefaultNodeHome = filepath.Join(userHomeDir, ".ag-chain-cosmos")
|
|
44
70
|
daemoncmd.AppName = "ag-chain-cosmos"
|
|
71
|
+
if err := os.Setenv(daemoncmd.EmbeddedVmEnvVar, "libdaemon"); err != nil {
|
|
72
|
+
panic(err)
|
|
73
|
+
}
|
|
45
74
|
|
|
46
|
-
|
|
47
|
-
sendToNode := func(needReply bool, str string) (string, error) {
|
|
48
|
-
var rPort int
|
|
49
|
-
if needReply {
|
|
50
|
-
lastReply++
|
|
51
|
-
rPort = lastReply
|
|
52
|
-
replies[rPort] = make(chan goReturn)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Send the message
|
|
56
|
-
C.invokeSendFunc(toNode, nodePort, C.int(rPort), C.CString(str))
|
|
57
|
-
if !needReply {
|
|
58
|
-
// Return immediately
|
|
59
|
-
// fmt.Fprintln(os.Stderr, "Don't wait")
|
|
60
|
-
return "<no-reply-requested>", nil
|
|
61
|
-
}
|
|
75
|
+
var sendToNode vm.Sender
|
|
62
76
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
ret := <-replies[rPort]
|
|
66
|
-
delete(replies, rPort)
|
|
67
|
-
// fmt.Fprintln(os.Stderr, "Woken, got", ret)
|
|
68
|
-
return ret.str, ret.err
|
|
77
|
+
sendFunc := func(port int, reply int, str string) {
|
|
78
|
+
C.invokeSendFunc(toNode, C.int(port), C.int(reply), C.CString(str))
|
|
69
79
|
}
|
|
70
80
|
|
|
81
|
+
vmClientCodec, sendToNode = ConnectVMClientCodec(
|
|
82
|
+
context.Background(),
|
|
83
|
+
int(nodePort),
|
|
84
|
+
sendFunc,
|
|
85
|
+
)
|
|
86
|
+
|
|
71
87
|
args := make([]string, len(cosmosArgs))
|
|
72
88
|
for i, s := range cosmosArgs {
|
|
73
89
|
args[i] = C.GoString(s)
|
|
74
90
|
}
|
|
91
|
+
|
|
75
92
|
// fmt.Fprintln(os.Stderr, "Starting Cosmos", args)
|
|
76
93
|
os.Args = args
|
|
77
94
|
go func() {
|
|
78
95
|
// We run in the background, but exit when the job is over.
|
|
79
96
|
// swingset.SendToNode("hello from Initial Go!")
|
|
80
97
|
exitCode := 0
|
|
81
|
-
daemoncmd.OnStartHook = func(logger log.Logger) {
|
|
98
|
+
daemoncmd.OnStartHook = func(srv *vm.AgdServer, logger log.Logger, appOpts servertypes.AppOptions) error {
|
|
99
|
+
agdServer = srv
|
|
82
100
|
// We tried running start, which should never exit, so exit with non-zero
|
|
83
101
|
// code if we ever stop.
|
|
84
102
|
exitCode = 99
|
|
103
|
+
return nil
|
|
85
104
|
}
|
|
86
105
|
daemon.RunWithController(sendToNode)
|
|
87
106
|
// fmt.Fprintln(os.Stderr, "Shutting down Cosmos")
|
|
@@ -94,22 +113,10 @@ func RunAgCosmosDaemon(nodePort C.int, toNode C.sendFunc, cosmosArgs []*C.char)
|
|
|
94
113
|
//export ReplyToGo
|
|
95
114
|
func ReplyToGo(replyPort C.int, isError C.int, resp C.Body) C.int {
|
|
96
115
|
respStr := C.GoString(resp)
|
|
97
|
-
// fmt.
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
// Unexpected reply.
|
|
101
|
-
// This is okay, since the caller decides whether or
|
|
102
|
-
// not she wants to listen for replies.
|
|
103
|
-
return C.int(0)
|
|
116
|
+
// fmt.Printf("Reply to Go %d %s\n", replyPort, respStr)
|
|
117
|
+
if err := vmClientCodec.Receive(int(replyPort), int(isError) != 0, respStr); err != nil {
|
|
118
|
+
return C.int(1)
|
|
104
119
|
}
|
|
105
|
-
// Wake up the waiting goroutine
|
|
106
|
-
ret := goReturn{}
|
|
107
|
-
if int(isError) == 0 {
|
|
108
|
-
ret.str = respStr
|
|
109
|
-
} else {
|
|
110
|
-
ret.err = errors.New(respStr)
|
|
111
|
-
}
|
|
112
|
-
returnCh <- ret
|
|
113
120
|
return C.int(0)
|
|
114
121
|
}
|
|
115
122
|
|
|
@@ -121,20 +128,27 @@ type errorWrapper struct {
|
|
|
121
128
|
func SendToGo(port C.int, msg C.Body) C.Body {
|
|
122
129
|
msgStr := C.GoString(msg)
|
|
123
130
|
// fmt.Fprintln(os.Stderr, "Send to Go", msgStr)
|
|
124
|
-
respStr
|
|
131
|
+
var respStr string
|
|
132
|
+
message := &vm.Message{
|
|
133
|
+
Port: int(port),
|
|
134
|
+
NeedsReply: true,
|
|
135
|
+
Data: msgStr,
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
err := agdServer.ReceiveMessage(message, &respStr)
|
|
139
|
+
if err == nil {
|
|
140
|
+
return C.CString(respStr)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// fmt.Fprintln(os.Stderr, "Cannot receive from controller", err)
|
|
144
|
+
errResp := errorWrapper{
|
|
145
|
+
Error: err.Error(),
|
|
146
|
+
}
|
|
147
|
+
respBytes, err := json.Marshal(&errResp)
|
|
125
148
|
if err != nil {
|
|
126
|
-
|
|
127
|
-
errResp := errorWrapper{
|
|
128
|
-
Error: err.Error(),
|
|
129
|
-
}
|
|
130
|
-
respBytes, err := json.Marshal(&errResp)
|
|
131
|
-
if err != nil {
|
|
132
|
-
panic(err)
|
|
133
|
-
}
|
|
134
|
-
// fmt.Fprintln(os.Stderr, "Marshaled", errResp, respBytes)
|
|
135
|
-
respStr = string(respBytes)
|
|
149
|
+
panic(err)
|
|
136
150
|
}
|
|
137
|
-
return C.CString(
|
|
151
|
+
return C.CString(string(respBytes))
|
|
138
152
|
}
|
|
139
153
|
|
|
140
154
|
// Do nothing in main.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
package main_test
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"fmt"
|
|
5
|
+
"strings"
|
|
6
|
+
"testing"
|
|
7
|
+
|
|
8
|
+
sdkioerrors "cosmossdk.io/errors"
|
|
9
|
+
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
func TestErrorStackTraces(t *testing.T) {
|
|
13
|
+
err := sdkioerrors.Wrapf(sdkerrors.ErrInsufficientFee, "my error %d", 123)
|
|
14
|
+
expected := "my error 123: insufficient fee"
|
|
15
|
+
|
|
16
|
+
// Check that sdkerrors.Wrapf(...).Error() does not leak stack.
|
|
17
|
+
got := err.Error()
|
|
18
|
+
if got != expected {
|
|
19
|
+
t.Fatalf("err.Error() %q should be %q", got, expected)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Check that fmt.Errorf("... %s").Error() does not leak stack.
|
|
23
|
+
expected = "fail: " + expected
|
|
24
|
+
stringified := fmt.Errorf("fail: %s", err)
|
|
25
|
+
got = stringified.Error()
|
|
26
|
+
if got != expected {
|
|
27
|
+
t.Fatalf("stringified.Error() %q should be %q", got, expected)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Check that fmt.Errorf("... %w").Error() leaks stack.
|
|
31
|
+
wrapped := fmt.Errorf("fail: %w", err)
|
|
32
|
+
got = wrapped.Error()
|
|
33
|
+
expectedAndStack := expected + " ["
|
|
34
|
+
if !strings.HasPrefix(got, expectedAndStack) {
|
|
35
|
+
t.Fatalf("wrapped.Error() %q should start with %q", got, expectedAndStack)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -10,6 +10,7 @@ import (
|
|
|
10
10
|
|
|
11
11
|
"github.com/cosmos/cosmos-sdk/client"
|
|
12
12
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
13
|
+
"github.com/cosmos/cosmos-sdk/codec"
|
|
13
14
|
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
|
14
15
|
"github.com/cosmos/cosmos-sdk/server"
|
|
15
16
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
@@ -27,14 +28,14 @@ const (
|
|
|
27
28
|
)
|
|
28
29
|
|
|
29
30
|
// AddGenesisAccountCmd returns add-genesis-account cobra Command.
|
|
30
|
-
func AddGenesisAccountCmd(defaultNodeHome string) *cobra.Command {
|
|
31
|
+
func AddGenesisAccountCmd(cdc codec.Codec, defaultNodeHome string) *cobra.Command {
|
|
31
32
|
cmd := &cobra.Command{
|
|
32
|
-
Use: "add-genesis-account
|
|
33
|
+
Use: "add-genesis-account <address_or_key_name> <coin>[,...]",
|
|
33
34
|
Short: "Add a genesis account to genesis.json",
|
|
34
|
-
Long: `Add a genesis account to genesis.json.
|
|
35
|
-
the
|
|
36
|
-
|
|
37
|
-
|
|
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.
|
|
38
39
|
`,
|
|
39
40
|
Args: cobra.ExactArgs(2),
|
|
40
41
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
@@ -54,22 +55,25 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
|
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
// attempt to lookup address from Keybase if no address was provided
|
|
57
|
-
kb, err := keyring.New(sdk.KeyringServiceName(), keyringBackend, clientCtx.KeyringDir, inBuf)
|
|
58
|
+
kb, err := keyring.New(sdk.KeyringServiceName(), keyringBackend, clientCtx.KeyringDir, inBuf, cdc)
|
|
58
59
|
if err != nil {
|
|
59
60
|
return err
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
info, err := kb.Key(args[0])
|
|
63
64
|
if err != nil {
|
|
64
|
-
return fmt.Errorf("failed to get
|
|
65
|
+
return fmt.Errorf("failed to get key from Keybase: %s", err)
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
addr = info.GetAddress()
|
|
68
|
+
addr, err = info.GetAddress()
|
|
69
|
+
if err != nil {
|
|
70
|
+
return fmt.Errorf("failed to get address from Keybase: %s", err)
|
|
71
|
+
}
|
|
68
72
|
}
|
|
69
73
|
|
|
70
74
|
coins, err := sdk.ParseCoinsNormalized(args[1])
|
|
71
75
|
if err != nil {
|
|
72
|
-
return fmt.Errorf("failed to parse coins: %
|
|
76
|
+
return fmt.Errorf("failed to parse coins: %s", err)
|
|
73
77
|
}
|
|
74
78
|
|
|
75
79
|
vestingStart, err := cmd.Flags().GetInt64(flagVestingStart)
|
|
@@ -87,7 +91,7 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
|
|
|
87
91
|
|
|
88
92
|
vestingAmt, err := sdk.ParseCoinsNormalized(vestingAmtStr)
|
|
89
93
|
if err != nil {
|
|
90
|
-
return fmt.Errorf("failed to parse vesting amount: %
|
|
94
|
+
return fmt.Errorf("failed to parse vesting amount: %s", err)
|
|
91
95
|
}
|
|
92
96
|
|
|
93
97
|
// create concrete account type based on input parameters
|
|
@@ -119,20 +123,20 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
|
|
|
119
123
|
}
|
|
120
124
|
|
|
121
125
|
if err := genAccount.Validate(); err != nil {
|
|
122
|
-
return fmt.Errorf("failed to validate new genesis account: %
|
|
126
|
+
return fmt.Errorf("failed to validate new genesis account: %s", err)
|
|
123
127
|
}
|
|
124
128
|
|
|
125
129
|
genFile := config.GenesisFile()
|
|
126
130
|
appState, genDoc, err := genutiltypes.GenesisStateFromGenFile(genFile)
|
|
127
131
|
if err != nil {
|
|
128
|
-
return fmt.Errorf("failed to unmarshal genesis state: %
|
|
132
|
+
return fmt.Errorf("failed to unmarshal genesis state: %s", err)
|
|
129
133
|
}
|
|
130
134
|
|
|
131
135
|
authGenState := authtypes.GetGenesisStateFromAppState(clientCtx.Codec, appState)
|
|
132
136
|
|
|
133
137
|
accs, err := authtypes.UnpackAccounts(authGenState.Accounts)
|
|
134
138
|
if err != nil {
|
|
135
|
-
return fmt.Errorf("failed to get accounts from any: %
|
|
139
|
+
return fmt.Errorf("failed to get accounts from any: %s", err)
|
|
136
140
|
}
|
|
137
141
|
|
|
138
142
|
if accs.Contains(addr) {
|
|
@@ -146,13 +150,13 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
|
|
|
146
150
|
|
|
147
151
|
genAccs, err := authtypes.PackAccounts(accs)
|
|
148
152
|
if err != nil {
|
|
149
|
-
return fmt.Errorf("failed to convert accounts into any's: %
|
|
153
|
+
return fmt.Errorf("failed to convert accounts into any's: %s", err)
|
|
150
154
|
}
|
|
151
155
|
authGenState.Accounts = genAccs
|
|
152
156
|
|
|
153
157
|
authGenStateBz, err := clientCtx.Codec.MarshalJSON(&authGenState)
|
|
154
158
|
if err != nil {
|
|
155
|
-
return fmt.Errorf("failed to marshal auth genesis state: %
|
|
159
|
+
return fmt.Errorf("failed to marshal auth genesis state: %s", err)
|
|
156
160
|
}
|
|
157
161
|
|
|
158
162
|
appState[authtypes.ModuleName] = authGenStateBz
|
|
@@ -164,14 +168,14 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
|
|
|
164
168
|
|
|
165
169
|
bankGenStateBz, err := clientCtx.Codec.MarshalJSON(bankGenState)
|
|
166
170
|
if err != nil {
|
|
167
|
-
return fmt.Errorf("failed to marshal bank genesis state: %
|
|
171
|
+
return fmt.Errorf("failed to marshal bank genesis state: %s", err)
|
|
168
172
|
}
|
|
169
173
|
|
|
170
174
|
appState[banktypes.ModuleName] = bankGenStateBz
|
|
171
175
|
|
|
172
176
|
appStateJSON, err := json.Marshal(appState)
|
|
173
177
|
if err != nil {
|
|
174
|
-
return fmt.Errorf("failed to marshal application genesis state: %
|
|
178
|
+
return fmt.Errorf("failed to marshal application genesis state: %s", err)
|
|
175
179
|
}
|
|
176
180
|
|
|
177
181
|
genDoc.AppState = appStateJSON
|