@agoric/cosmos 0.35.0-u12.0 → 0.35.0-u14.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.
Files changed (91) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/Makefile +25 -12
  3. package/ante/ante.go +7 -5
  4. package/ante/inbound_test.go +8 -0
  5. package/app/app.go +139 -108
  6. package/app/export.go +13 -9
  7. package/app/sim_test.go +4 -4
  8. package/cmd/agd/main.go +5 -3
  9. package/cmd/libdaemon/main.go +5 -2
  10. package/daemon/cmd/genaccounts.go +13 -9
  11. package/daemon/cmd/root.go +38 -17
  12. package/daemon/cmd/root_test.go +1 -1
  13. package/daemon/cmd/testnet.go +17 -6
  14. package/daemon/main.go +3 -2
  15. package/git-revision.txt +1 -1
  16. package/go.mod +117 -76
  17. package/go.sum +858 -210
  18. package/package.json +3 -3
  19. package/proto/agoric/vstorage/query.proto +53 -1
  20. package/scripts/protocgen.sh +12 -1
  21. package/third_party/proto/buf.yaml +1 -0
  22. package/third_party/proto/cosmos/base/query/v1beta1/pagination.proto +4 -1
  23. package/third_party/proto/cosmos/base/v1beta1/coin.proto +7 -4
  24. package/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto +16 -6
  25. package/third_party/proto/cosmos_proto/cosmos.proto +97 -0
  26. package/third_party/proto/google/api/annotations.proto +1 -1
  27. package/third_party/proto/google/api/http.proto +181 -120
  28. package/third_party/proto/google/api/httpbody.proto +9 -6
  29. package/third_party/proto/google/protobuf/any.proto +1 -7
  30. package/third_party/proto/ibc/core/channel/v1/channel.proto +15 -1
  31. package/third_party/proto/ibc/core/client/v1/client.proto +9 -6
  32. package/upgradegaia.sh +13 -4
  33. package/vm/action.go +133 -0
  34. package/vm/action_test.go +129 -0
  35. package/vm/controller.go +9 -16
  36. package/vm/core_proposals.go +31 -0
  37. package/x/lien/keeper/account.go +16 -11
  38. package/x/lien/keeper/keeper.go +5 -4
  39. package/x/lien/keeper/keeper_test.go +9 -9
  40. package/x/lien/lien.go +6 -4
  41. package/x/lien/lien_test.go +20 -16
  42. package/x/swingset/abci.go +25 -33
  43. package/x/swingset/client/cli/query.go +2 -2
  44. package/x/swingset/client/cli/tx.go +48 -33
  45. package/x/swingset/client/proposal_handler.go +2 -17
  46. package/x/swingset/keeper/keeper.go +69 -15
  47. package/x/swingset/keeper/keeper_test.go +1 -1
  48. package/x/swingset/keeper/migrations.go +7 -2
  49. package/x/swingset/keeper/msg_server.go +66 -49
  50. package/x/swingset/keeper/proposal.go +14 -8
  51. package/x/swingset/keeper/querier.go +14 -6
  52. package/x/swingset/keeper/swing_store_exports_handler.go +5 -1
  53. package/x/swingset/proposal_handler.go +3 -3
  54. package/x/swingset/swingset.go +4 -2
  55. package/x/swingset/types/codec.go +2 -2
  56. package/x/swingset/types/default-params.go +22 -16
  57. package/x/swingset/types/expected_keepers.go +11 -0
  58. package/x/swingset/types/msgs.go +43 -2
  59. package/x/swingset/types/msgs.pb.go +16 -16
  60. package/x/swingset/types/params.go +74 -0
  61. package/x/swingset/types/params_test.go +116 -0
  62. package/x/swingset/types/proposal.go +5 -5
  63. package/x/swingset/types/types.go +30 -28
  64. package/x/vbank/keeper/keeper.go +3 -2
  65. package/x/vbank/keeper/querier.go +6 -2
  66. package/x/vbank/keeper/rewards.go +1 -1
  67. package/x/vbank/vbank.go +19 -17
  68. package/x/vbank/vbank_test.go +18 -18
  69. package/x/vibc/handler.go +3 -8
  70. package/x/vibc/ibc.go +79 -126
  71. package/x/vibc/keeper/keeper.go +19 -18
  72. package/x/vibc/types/expected_keepers.go +13 -5
  73. package/x/vibc/types/msgs.go +1 -1
  74. package/x/vibc/types/msgs.pb.go +1 -1
  75. package/x/vstorage/README.md +138 -0
  76. package/x/vstorage/capdata/capdata.go +298 -0
  77. package/x/vstorage/capdata/capdata_test.go +352 -0
  78. package/x/vstorage/client/cli/query.go +51 -4
  79. package/x/vstorage/keeper/grpc_query.go +221 -0
  80. package/x/vstorage/keeper/keeper.go +3 -2
  81. package/x/vstorage/keeper/keeper_grpc_test.go +300 -0
  82. package/x/vstorage/keeper/keeper_test.go +1 -1
  83. package/x/vstorage/keeper/querier.go +6 -2
  84. package/x/vstorage/keeper/querier_test.go +112 -0
  85. package/x/vstorage/types/query.pb.go +646 -36
  86. package/x/vstorage/types/query.pb.gw.go +119 -0
  87. package/x/vstorage/vstorage.go +16 -15
  88. package/x/vstorage/vstorage_test.go +5 -5
  89. package/x/swingset/legacy/v32/params.go +0 -37
  90. package/x/swingset/legacy/v32/params_test.go +0 -133
  91. /package/{src/index.cjs → index.cjs} +0 -0
@@ -2,6 +2,7 @@ package swingset
2
2
 
3
3
  import (
4
4
  // "os"
5
+ "context"
5
6
  "fmt"
6
7
  "time"
7
8
 
@@ -9,38 +10,34 @@ import (
9
10
  sdk "github.com/cosmos/cosmos-sdk/types"
10
11
  abci "github.com/tendermint/tendermint/abci/types"
11
12
 
13
+ "github.com/Agoric/agoric-sdk/golang/cosmos/vm"
12
14
  "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/types"
13
15
  )
14
16
 
15
17
  type beginBlockAction struct {
16
- Type string `json:"type"`
17
- BlockHeight int64 `json:"blockHeight"`
18
- BlockTime int64 `json:"blockTime"`
19
- ChainID string `json:"chainID"`
20
- Params types.Params `json:"params"`
18
+ vm.ActionHeader `actionType:"BEGIN_BLOCK"`
19
+ ChainID string `json:"chainID"`
20
+ Params types.Params `json:"params"`
21
21
  }
22
22
 
23
23
  type endBlockAction struct {
24
- Type string `json:"type"`
25
- BlockHeight int64 `json:"blockHeight"`
26
- BlockTime int64 `json:"blockTime"`
24
+ vm.ActionHeader `actionType:"END_BLOCK"`
27
25
  }
28
26
 
29
27
  type commitBlockAction struct {
30
- Type string `json:"type"`
31
- BlockHeight int64 `json:"blockHeight"`
32
- BlockTime int64 `json:"blockTime"`
28
+ vm.ActionHeader `actionType:"COMMIT_BLOCK"`
29
+ }
30
+
31
+ type afterCommitBlockAction struct {
32
+ vm.ActionHeader `actionType:"AFTER_COMMIT_BLOCK"`
33
33
  }
34
34
 
35
35
  func BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock, keeper Keeper) error {
36
36
  defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker)
37
37
 
38
38
  action := &beginBlockAction{
39
- Type: "BEGIN_BLOCK",
40
- BlockHeight: ctx.BlockHeight(),
41
- BlockTime: ctx.BlockTime().Unix(),
42
- ChainID: ctx.ChainID(),
43
- Params: keeper.GetParams(ctx),
39
+ ChainID: ctx.ChainID(),
40
+ Params: keeper.GetParams(ctx),
44
41
  }
45
42
  _, err := keeper.BlockingSend(ctx, action)
46
43
  // fmt.Fprintf(os.Stderr, "BEGIN_BLOCK Returned from SwingSet: %s, %v\n", out, err)
@@ -59,11 +56,7 @@ var endBlockTime int64
59
56
  func EndBlock(ctx sdk.Context, req abci.RequestEndBlock, keeper Keeper) ([]abci.ValidatorUpdate, error) {
60
57
  defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker)
61
58
 
62
- action := &endBlockAction{
63
- Type: "END_BLOCK",
64
- BlockHeight: ctx.BlockHeight(),
65
- BlockTime: ctx.BlockTime().Unix(),
66
- }
59
+ action := &endBlockAction{}
67
60
  _, err := keeper.BlockingSend(ctx, action)
68
61
 
69
62
  // fmt.Fprintf(os.Stderr, "END_BLOCK Returned from SwingSet: %s, %v\n", out, err)
@@ -80,15 +73,18 @@ func EndBlock(ctx sdk.Context, req abci.RequestEndBlock, keeper Keeper) ([]abci.
80
73
  return []abci.ValidatorUpdate{}, nil
81
74
  }
82
75
 
76
+ func getEndBlockContext() sdk.Context {
77
+ return sdk.Context{}.
78
+ WithContext(context.Background()).
79
+ WithBlockHeight(endBlockHeight).
80
+ WithBlockTime(time.Unix(endBlockTime, 0))
81
+ }
82
+
83
83
  func CommitBlock(keeper Keeper) error {
84
84
  defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), "commit_blocker")
85
85
 
86
- action := &commitBlockAction{
87
- Type: "COMMIT_BLOCK",
88
- BlockHeight: endBlockHeight,
89
- BlockTime: endBlockTime,
90
- }
91
- _, err := keeper.BlockingSend(sdk.Context{}, action)
86
+ action := &commitBlockAction{}
87
+ _, err := keeper.BlockingSend(getEndBlockContext(), action)
92
88
 
93
89
  // fmt.Fprintf(os.Stderr, "COMMIT_BLOCK Returned from SwingSet: %s, %v\n", out, err)
94
90
  if err != nil {
@@ -102,12 +98,8 @@ func CommitBlock(keeper Keeper) error {
102
98
  func AfterCommitBlock(keeper Keeper) error {
103
99
  // defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), "commit_blocker")
104
100
 
105
- action := &commitBlockAction{
106
- Type: "AFTER_COMMIT_BLOCK",
107
- BlockHeight: endBlockHeight,
108
- BlockTime: endBlockTime,
109
- }
110
- _, err := keeper.BlockingSend(sdk.Context{}, action)
101
+ action := &afterCommitBlockAction{}
102
+ _, err := keeper.BlockingSend(getEndBlockContext(), action)
111
103
 
112
104
  // fmt.Fprintf(os.Stderr, "AFTER_COMMIT_BLOCK Returned from SwingSet: %s, %v\n", out, err)
113
105
  if err != nil {
@@ -53,7 +53,7 @@ func GetCmdQueryParams(queryRoute string) *cobra.Command {
53
53
 
54
54
  func GetCmdGetEgress(queryRoute string) *cobra.Command {
55
55
  cmd := &cobra.Command{
56
- Use: "egress [account]",
56
+ Use: "egress <account>",
57
57
  Short: "get egress info for account",
58
58
  Args: cobra.ExactArgs(1),
59
59
  RunE: func(cmd *cobra.Command, args []string) error {
@@ -86,7 +86,7 @@ func GetCmdGetEgress(queryRoute string) *cobra.Command {
86
86
  // GetCmdMailbox queries information about a mailbox
87
87
  func GetCmdMailbox(queryRoute string) *cobra.Command {
88
88
  cmd := &cobra.Command{
89
- Use: "mailbox [peer]",
89
+ Use: "mailbox <peer>",
90
90
  Short: "get mailbox for peer",
91
91
  Args: cobra.ExactArgs(1),
92
92
  RunE: func(cmd *cobra.Command, args []string) error {
@@ -2,6 +2,7 @@ package cli
2
2
 
3
3
  import (
4
4
  "fmt"
5
+ "io"
5
6
  "os"
6
7
  "strings"
7
8
 
@@ -12,7 +13,7 @@ import (
12
13
  "github.com/cosmos/cosmos-sdk/client/flags"
13
14
  "github.com/cosmos/cosmos-sdk/client/tx"
14
15
  govcli "github.com/cosmos/cosmos-sdk/x/gov/client/cli"
15
- govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
16
+ govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
16
17
 
17
18
  "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/types"
18
19
  sdk "github.com/cosmos/cosmos-sdk/types"
@@ -43,11 +44,18 @@ func GetTxCmd(storeKey string) *cobra.Command {
43
44
  }
44
45
 
45
46
  // GetCmdDeliver is the CLI command for sending a DeliverInbound transaction
47
+ // containing mailbox messages.
46
48
  func GetCmdDeliver() *cobra.Command {
47
49
  cmd := &cobra.Command{
48
- Use: "deliver [json string]",
49
- Short: "deliver inbound messages",
50
- Args: cobra.ExactArgs(1),
50
+ Use: "deliver {<messages JSON> | @- | @<file>}",
51
+ Short: "send mailbox messages",
52
+ Long: `send mailbox messages.
53
+ The argument indicates how to read input JSON ("@-" for standard input,
54
+ "@..." for a file path, and otherwise directly as in "deliver '[...]'").
55
+ Input must represent an array in which the first element is an array of
56
+ [messageNum: integer, messageBody: string] pairs and the second element
57
+ is an "Ack" integer.`,
58
+ Args: cobra.ExactArgs(1),
51
59
 
52
60
  RunE: func(cmd *cobra.Command, args []string) error {
53
61
  cctx, err := client.GetClientTxContext(cmd)
@@ -56,20 +64,18 @@ func GetCmdDeliver() *cobra.Command {
56
64
  }
57
65
 
58
66
  jsonIn := args[0]
59
- if jsonIn[0] == '@' {
60
- fname := args[0][1:]
67
+ if strings.HasPrefix(jsonIn, "@") {
68
+ var jsonBytes []byte
69
+ fname := jsonIn[1:]
61
70
  if fname == "-" {
62
- // Reading from stdin.
63
- if _, err := fmt.Scanln(&jsonIn); err != nil {
64
- return err
65
- }
71
+ jsonBytes, err = io.ReadAll(os.Stdin)
66
72
  } else {
67
- jsonBytes, err := os.ReadFile(fname)
68
- if err != nil {
69
- return err
70
- }
71
- jsonIn = string(jsonBytes)
73
+ jsonBytes, err = os.ReadFile(fname)
74
+ }
75
+ if err != nil {
76
+ return err
72
77
  }
78
+ jsonIn = string(jsonBytes)
73
79
  }
74
80
  msgs, err := types.UnmarshalMessagesJSON(jsonIn)
75
81
  if err != nil {
@@ -92,7 +98,14 @@ func GetCmdDeliver() *cobra.Command {
92
98
  // InstallBundle message in a transaction.
93
99
  func GetCmdInstallBundle() *cobra.Command {
94
100
  cmd := &cobra.Command{
95
- Use: "install-bundle <JSON>/@<FILE>/-",
101
+ Use: "install-bundle {<bundle JSON> | @- | @<file>}",
102
+ Short: "install a bundle",
103
+ Long: `install a bundle.
104
+ The argument indicates how to read input JSON ("@-" for standard input,
105
+ "@..." for a file path, and otherwise directly as in
106
+ "install-bundle '{...}'").
107
+ Input should be endoZipBase64 JSON, but this is not verified.
108
+ https://github.com/endojs/endo/tree/master/packages/bundle-source`,
96
109
  Args: cobra.ExactArgs(1),
97
110
 
98
111
  RunE: func(cmd *cobra.Command, args []string) error {
@@ -102,20 +115,18 @@ func GetCmdInstallBundle() *cobra.Command {
102
115
  }
103
116
 
104
117
  jsonIn := args[0]
105
- if jsonIn[0] == '@' {
106
- fname := args[0][1:]
118
+ if strings.HasPrefix(jsonIn, "@") {
119
+ var jsonBytes []byte
120
+ fname := jsonIn[1:]
107
121
  if fname == "-" {
108
- // Reading from stdin.
109
- if _, err := fmt.Scanln(&jsonIn); err != nil {
110
- return err
111
- }
122
+ jsonBytes, err = io.ReadAll(os.Stdin)
112
123
  } else {
113
- jsonBytes, err := os.ReadFile(fname)
114
- if err != nil {
115
- return err
116
- }
117
- jsonIn = string(jsonBytes)
124
+ jsonBytes, err = os.ReadFile(fname)
118
125
  }
126
+ if err != nil {
127
+ return err
128
+ }
129
+ jsonIn = string(jsonBytes)
119
130
  }
120
131
 
121
132
  msg := types.NewMsgInstallBundle(jsonIn, cctx.GetFromAddress())
@@ -150,7 +161,7 @@ func GetCmdInstallBundle() *cobra.Command {
150
161
  // GetCmdProvision is the CLI command for sending a Provision transaction
151
162
  func GetCmdProvisionOne() *cobra.Command {
152
163
  cmd := &cobra.Command{
153
- Use: "provision-one [nickname] [address] [power-flags]",
164
+ Use: "provision-one <nickname> <address> [<power-flag>[,...]]",
154
165
  Short: "provision a single address",
155
166
  Args: cobra.RangeArgs(2, 3),
156
167
 
@@ -160,6 +171,8 @@ func GetCmdProvisionOne() *cobra.Command {
160
171
  return err
161
172
  }
162
173
 
174
+ nickname := args[0]
175
+
163
176
  addr, err := sdk.AccAddressFromBech32(args[1])
164
177
  if err != nil {
165
178
  return err
@@ -170,7 +183,7 @@ func GetCmdProvisionOne() *cobra.Command {
170
183
  powerFlags = strings.Split(args[2], ",")
171
184
  }
172
185
 
173
- msg := types.NewMsgProvision(args[0], addr, powerFlags, cctx.GetFromAddress())
186
+ msg := types.NewMsgProvision(nickname, addr, powerFlags, cctx.GetFromAddress())
174
187
  if err := msg.ValidateBasic(); err != nil {
175
188
  return err
176
189
  }
@@ -186,7 +199,7 @@ func GetCmdProvisionOne() *cobra.Command {
186
199
  // GetCmdWalletAction is the CLI command for sending a WalletAction or WalletSpendAction transaction
187
200
  func GetCmdWalletAction() *cobra.Command {
188
201
  cmd := &cobra.Command{
189
- Use: "wallet-action [json string]",
202
+ Use: "wallet-action <action JSON>",
190
203
  Short: "perform a wallet action",
191
204
  Args: cobra.ExactArgs(1),
192
205
  RunE: func(cmd *cobra.Command, args []string) error {
@@ -221,16 +234,18 @@ func GetCmdWalletAction() *cobra.Command {
221
234
  return cmd
222
235
  }
223
236
 
237
+ // NewCmdSubmitCoreEvalProposal is the CLI command for submitting a "CoreEval"
238
+ // governance proposal via `agd tx gov submit-proposal swingset-core-eval ...`.
224
239
  func NewCmdSubmitCoreEvalProposal() *cobra.Command {
225
240
  cmd := &cobra.Command{
226
- Use: "swingset-core-eval [[permit.json] [code.js]]...",
241
+ Use: "swingset-core-eval <permit.json code.js>...",
227
242
  Args: cobra.MinimumNArgs(2),
228
243
  Short: "Submit a proposal to evaluate code in the SwingSet core",
229
244
  Long: `Submit a SwingSet evaluate core Compartment code proposal along with an initial deposit.
230
245
  Specify at least one pair of permit.json and code.js files`,
231
246
  RunE: func(cmd *cobra.Command, args []string) error {
232
247
  if len(args)%2 != 0 {
233
- return fmt.Errorf("must specify an even number of permit.json and code.js files")
248
+ return fmt.Errorf("must specify paired permit.json and code.js files")
234
249
  }
235
250
 
236
251
  clientCtx, err := client.GetClientTxContext(cmd)
@@ -287,7 +302,7 @@ Specify at least one pair of permit.json and code.js files`,
287
302
  return err
288
303
  }
289
304
 
290
- msg, err := govtypes.NewMsgSubmitProposal(content, deposit, from)
305
+ msg, err := govv1beta1.NewMsgSubmitProposal(content, deposit, from)
291
306
  if err != nil {
292
307
  return err
293
308
  }
@@ -1,25 +1,10 @@
1
1
  package client
2
2
 
3
3
  import (
4
- "net/http"
5
-
6
- "github.com/cosmos/cosmos-sdk/client"
7
- "github.com/cosmos/cosmos-sdk/types/rest"
8
- govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
9
- govrest "github.com/cosmos/cosmos-sdk/x/gov/client/rest"
10
-
11
4
  "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/client/cli"
5
+ govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
12
6
  )
13
7
 
14
8
  var (
15
- CoreEvalProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitCoreEvalProposal, emptyRestHandler)
9
+ CoreEvalProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitCoreEvalProposal)
16
10
  )
17
-
18
- func emptyRestHandler(client.Context) govrest.ProposalRESTHandler {
19
- return govrest.ProposalRESTHandler{
20
- SubRoute: "unsupported-swingset",
21
- Handler: func(w http.ResponseWriter, r *http.Request) {
22
- rest.WriteErrorResponse(w, http.StatusBadRequest, "Legacy REST Routes are not supported for SwingSet proposals")
23
- },
24
- }
25
- }
@@ -7,11 +7,14 @@ import (
7
7
  stdlog "log"
8
8
  "math"
9
9
 
10
+ sdkmath "cosmossdk.io/math"
11
+
10
12
  "github.com/tendermint/tendermint/libs/log"
11
13
 
12
14
  "github.com/cosmos/cosmos-sdk/baseapp"
13
15
  "github.com/cosmos/cosmos-sdk/codec"
14
16
  "github.com/cosmos/cosmos-sdk/store/prefix"
17
+ storetypes "github.com/cosmos/cosmos-sdk/store/types"
15
18
  sdk "github.com/cosmos/cosmos-sdk/types"
16
19
  bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
17
20
  paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
@@ -37,6 +40,12 @@ const (
37
40
  StoragePathSwingStore = "swingStore"
38
41
  )
39
42
 
43
+ const (
44
+ // WalletStoragePathSegment matches the value of WALLET_STORAGE_PATH_SEGMENT
45
+ // packages/vats/src/core/startWalletFactory.js
46
+ WalletStoragePathSegment = "wallet"
47
+ )
48
+
40
49
  const (
41
50
  stateKey = "state"
42
51
  swingStoreKeyPrefix = "swingStore."
@@ -63,7 +72,7 @@ type inboundQueueRecord struct {
63
72
 
64
73
  // Keeper maintains the link to data vstorage and exposes getter/setter methods for the various parts of the state machine
65
74
  type Keeper struct {
66
- storeKey sdk.StoreKey
75
+ storeKey storetypes.StoreKey
67
76
  cdc codec.Codec
68
77
  paramSpace paramtypes.Subspace
69
78
 
@@ -81,7 +90,7 @@ var _ ante.SwingsetKeeper = &Keeper{}
81
90
 
82
91
  // NewKeeper creates a new IBC transfer Keeper instance
83
92
  func NewKeeper(
84
- cdc codec.Codec, key sdk.StoreKey, paramSpace paramtypes.Subspace,
93
+ cdc codec.Codec, key storetypes.StoreKey, paramSpace paramtypes.Subspace,
85
94
  accountKeeper types.AccountKeeper, bankKeeper bankkeeper.Keeper,
86
95
  vstorageKeeper vstoragekeeper.Keeper, feeCollectorName string,
87
96
  callToController func(ctx sdk.Context, str string) (string, error),
@@ -104,6 +113,16 @@ func NewKeeper(
104
113
  }
105
114
  }
106
115
 
116
+ func populateAction(ctx sdk.Context, action vm.Action) (vm.Action, error) {
117
+ action = vm.PopulateAction(ctx, action)
118
+ ah := action.GetActionHeader()
119
+ if len(ah.Type) == 0 {
120
+ return nil, fmt.Errorf("action %q cannot have an empty ActionHeader.Type", action)
121
+ }
122
+
123
+ return action, nil
124
+ }
125
+
107
126
  // pushAction appends an action to the controller's specified inbound queue.
108
127
  // The queue is kept in the kvstore so that changes are properly reverted if the
109
128
  // kvstore is rolled back. By the time the block manager runs, it can commit
@@ -112,20 +131,18 @@ func NewKeeper(
112
131
  //
113
132
  // The inbound queue's format is documented by `makeChainQueue` in
114
133
  // `packages/cosmic-swingset/src/helpers/make-queue.js`.
115
- func (k Keeper) pushAction(ctx sdk.Context, inboundQueuePath string, action vm.Jsonable) error {
134
+ func (k Keeper) pushAction(ctx sdk.Context, inboundQueuePath string, action vm.Action) error {
135
+ action, err := populateAction(ctx, action)
136
+ if err != nil {
137
+ return err
138
+ }
116
139
  txHash, txHashOk := ctx.Context().Value(baseapp.TxHashContextKey).(string)
117
140
  if !txHashOk {
118
141
  txHash = "unknown"
119
142
  }
120
143
  msgIdx, msgIdxOk := ctx.Context().Value(baseapp.TxMsgIdxContextKey).(int)
121
144
  if !txHashOk || !msgIdxOk {
122
- switch action.(type) {
123
- case *coreEvalAction:
124
- // This is expected for CORE_EVAL since it's not in a transaction
125
- // (deferred by governance to a BeginBlocker).
126
- default:
127
- stdlog.Printf("error while extracting context for action %q\n", action)
128
- }
145
+ stdlog.Printf("error while extracting context for action %q\n", action)
129
146
  }
130
147
  record := inboundQueueRecord{Action: action, Context: actionContext{BlockHeight: ctx.BlockHeight(), TxHash: txHash, MsgIdx: msgIdx}}
131
148
  bz, err := json.Marshal(record)
@@ -137,12 +154,12 @@ func (k Keeper) pushAction(ctx sdk.Context, inboundQueuePath string, action vm.J
137
154
  }
138
155
 
139
156
  // PushAction appends an action to the controller's actionQueue.
140
- func (k Keeper) PushAction(ctx sdk.Context, action vm.Jsonable) error {
157
+ func (k Keeper) PushAction(ctx sdk.Context, action vm.Action) error {
141
158
  return k.pushAction(ctx, StoragePathActionQueue, action)
142
159
  }
143
160
 
144
161
  // PushAction appends an action to the controller's highPriorityQueue.
145
- func (k Keeper) PushHighPriorityAction(ctx sdk.Context, action vm.Jsonable) error {
162
+ func (k Keeper) PushHighPriorityAction(ctx sdk.Context, action vm.Action) error {
146
163
  return k.pushAction(ctx, StoragePathHighPriorityQueue, action)
147
164
  }
148
165
 
@@ -151,6 +168,20 @@ func (k Keeper) IsHighPriorityAddress(ctx sdk.Context, addr sdk.AccAddress) (boo
151
168
  return k.vstorageKeeper.HasEntry(ctx, path), nil
152
169
  }
153
170
 
171
+ // GetSmartWalletState returns the provision state of the smart wallet for the account address
172
+ func (k Keeper) GetSmartWalletState(ctx sdk.Context, addr sdk.AccAddress) types.SmartWalletState {
173
+ // walletStoragePath is path of `walletStorageNode` constructed in
174
+ // `provideSmartWallet` from packages/smart-wallet/src/walletFactory.js
175
+ walletStoragePath := StoragePathCustom + "." + WalletStoragePathSegment + "." + addr.String()
176
+
177
+ // TODO: implement a pending provision state
178
+ if k.vstorageKeeper.HasEntry(ctx, walletStoragePath) {
179
+ return types.SmartWalletStateProvisioned
180
+ }
181
+
182
+ return types.SmartWalletStateNone
183
+ }
184
+
154
185
  func (k Keeper) InboundQueueLength(ctx sdk.Context) (int32, error) {
155
186
  size := sdk.NewInt(0)
156
187
 
@@ -214,7 +245,11 @@ func (k Keeper) UpdateQueueAllowed(ctx sdk.Context) error {
214
245
  // until the response. It is orthogonal to PushAction, and should only be used
215
246
  // by SwingSet to perform block lifecycle events (BEGIN_BLOCK, END_BLOCK,
216
247
  // COMMIT_BLOCK).
217
- func (k Keeper) BlockingSend(ctx sdk.Context, action vm.Jsonable) (string, error) {
248
+ func (k Keeper) BlockingSend(ctx sdk.Context, action vm.Action) (string, error) {
249
+ action, err := populateAction(ctx, action)
250
+ if err != nil {
251
+ return "", err
252
+ }
218
253
  bz, err := json.Marshal(action)
219
254
  if err != nil {
220
255
  return "", err
@@ -266,9 +301,9 @@ func (k Keeper) GetBeansOwing(ctx sdk.Context, addr sdk.AccAddress) sdk.Uint {
266
301
  path := getBeansOwingPathForAddress(addr)
267
302
  entry := k.vstorageKeeper.GetEntry(ctx, path)
268
303
  if !entry.HasValue() {
269
- return sdk.ZeroUint()
304
+ return sdkmath.ZeroUint()
270
305
  }
271
- return sdk.NewUintFromString(entry.StringValue())
306
+ return sdkmath.NewUintFromString(entry.StringValue())
272
307
  }
273
308
 
274
309
  // SetBeansOwing sets the number of beans that the given address owes to the
@@ -315,6 +350,25 @@ func (k Keeper) ChargeBeans(ctx sdk.Context, addr sdk.AccAddress, beans sdk.Uint
315
350
  return nil
316
351
  }
317
352
 
353
+ // ChargeForSmartWallet charges the fee for provisioning a smart wallet.
354
+ func (k Keeper) ChargeForSmartWallet(ctx sdk.Context, addr sdk.AccAddress) error {
355
+ beansPerUnit := k.GetBeansPerUnit(ctx)
356
+ beans := beansPerUnit[types.BeansPerSmartWalletProvision]
357
+ err := k.ChargeBeans(ctx, addr, beans)
358
+ if err != nil {
359
+ return err
360
+ }
361
+
362
+ // TODO: mark that a smart wallet provision is pending. However in that case,
363
+ // auto-provisioning should still be performed (but without fees being charged),
364
+ // until the controller actually provisions the smart wallet (the operation may
365
+ // transiently fail, requiring retries until success).
366
+ // However the provisioning code is not currently idempotent, and has side
367
+ // effects when the smart wallet is already provisioned.
368
+
369
+ return nil
370
+ }
371
+
318
372
  // makeFeeMenu returns a map from power flag to its fee. In the case of duplicates, the
319
373
  // first one wins.
320
374
  func makeFeeMenu(powerFlagFees []types.PowerFlagFee) map[string]sdk.Coins {
@@ -196,7 +196,7 @@ var (
196
196
  func makeTestStore() sdk.KVStore {
197
197
  db := dbm.NewMemDB()
198
198
  ms := store.NewCommitMultiStore(db)
199
- ms.MountStoreWithDB(swingsetStoreKey, sdk.StoreTypeIAVL, db)
199
+ ms.MountStoreWithDB(swingsetStoreKey, storetypes.StoreTypeIAVL, db)
200
200
  err := ms.LoadLatestVersion()
201
201
  if err != nil {
202
202
  panic(err)
@@ -1,7 +1,7 @@
1
1
  package keeper
2
2
 
3
3
  import (
4
- v32 "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/legacy/v32"
4
+ "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/types"
5
5
  sdk "github.com/cosmos/cosmos-sdk/types"
6
6
  )
7
7
 
@@ -17,8 +17,13 @@ func NewMigrator(keeper Keeper) Migrator {
17
17
 
18
18
  // Migrate1to2 migrates from version 1 to 2.
19
19
  func (m Migrator) Migrate1to2(ctx sdk.Context) error {
20
+ return m.MigrateParams(ctx)
21
+ }
22
+
23
+ // MigrateParams migrates params by setting new params to their default value
24
+ func (m Migrator) MigrateParams(ctx sdk.Context) error {
20
25
  params := m.keeper.GetParams(ctx)
21
- newParams, err := v32.UpdateParams(params)
26
+ newParams, err := types.UpdateParams(params)
22
27
  if err != nil {
23
28
  return err
24
29
  }