@agoric/cosmos 0.35.0-upgrade-14-dev-8be87aa.0 → 0.35.0-upgrade-14-dev-c8f9e7b.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 (74) hide show
  1. package/Makefile +25 -12
  2. package/ante/ante.go +7 -5
  3. package/app/app.go +62 -47
  4. package/app/export.go +13 -6
  5. package/cmd/agd/main.go +5 -3
  6. package/cmd/libdaemon/main.go +5 -2
  7. package/daemon/cmd/genaccounts.go +13 -9
  8. package/daemon/cmd/root.go +27 -11
  9. package/daemon/cmd/root_test.go +1 -1
  10. package/daemon/cmd/testnet.go +17 -6
  11. package/daemon/main.go +3 -2
  12. package/git-revision.txt +1 -1
  13. package/go.mod +95 -64
  14. package/go.sum +592 -243
  15. package/package.json +2 -2
  16. package/proto/agoric/vstorage/query.proto +53 -1
  17. package/scripts/protocgen.sh +12 -1
  18. package/third_party/proto/buf.yaml +1 -0
  19. package/third_party/proto/cosmos/base/query/v1beta1/pagination.proto +4 -1
  20. package/third_party/proto/cosmos/base/v1beta1/coin.proto +7 -4
  21. package/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto +16 -6
  22. package/third_party/proto/cosmos_proto/cosmos.proto +97 -0
  23. package/third_party/proto/google/api/annotations.proto +1 -1
  24. package/third_party/proto/google/api/http.proto +181 -120
  25. package/third_party/proto/google/api/httpbody.proto +9 -6
  26. package/third_party/proto/google/protobuf/any.proto +1 -7
  27. package/third_party/proto/ibc/core/channel/v1/channel.proto +15 -1
  28. package/third_party/proto/ibc/core/client/v1/client.proto +9 -6
  29. package/upgradegaia.sh +13 -4
  30. package/vm/action.go +24 -21
  31. package/vm/action_test.go +5 -5
  32. package/vm/controller.go +9 -10
  33. package/x/lien/keeper/account.go +3 -3
  34. package/x/lien/keeper/keeper.go +5 -4
  35. package/x/lien/keeper/keeper_test.go +8 -8
  36. package/x/lien/lien.go +6 -4
  37. package/x/lien/lien_test.go +20 -16
  38. package/x/swingset/client/cli/query.go +2 -2
  39. package/x/swingset/client/cli/tx.go +48 -33
  40. package/x/swingset/client/proposal_handler.go +2 -17
  41. package/x/swingset/keeper/keeper.go +8 -11
  42. package/x/swingset/keeper/keeper_test.go +1 -1
  43. package/x/swingset/keeper/msg_server.go +2 -4
  44. package/x/swingset/keeper/proposal.go +10 -0
  45. package/x/swingset/keeper/querier.go +14 -6
  46. package/x/swingset/proposal_handler.go +3 -3
  47. package/x/swingset/swingset.go +4 -2
  48. package/x/swingset/types/codec.go +2 -2
  49. package/x/swingset/types/msgs.pb.go +16 -16
  50. package/x/swingset/types/proposal.go +5 -5
  51. package/x/swingset/types/types.go +30 -28
  52. package/x/vbank/keeper/keeper.go +3 -2
  53. package/x/vbank/keeper/querier.go +6 -2
  54. package/x/vbank/keeper/rewards.go +1 -1
  55. package/x/vbank/vbank.go +11 -10
  56. package/x/vbank/vbank_test.go +8 -8
  57. package/x/vibc/ibc.go +27 -26
  58. package/x/vibc/keeper/keeper.go +19 -18
  59. package/x/vibc/types/expected_keepers.go +13 -5
  60. package/x/vibc/types/msgs.go +1 -1
  61. package/x/vibc/types/msgs.pb.go +1 -1
  62. package/x/vstorage/README.md +138 -0
  63. package/x/vstorage/capdata/capdata.go +298 -0
  64. package/x/vstorage/capdata/capdata_test.go +352 -0
  65. package/x/vstorage/client/cli/query.go +51 -4
  66. package/x/vstorage/keeper/grpc_query.go +221 -0
  67. package/x/vstorage/keeper/keeper.go +3 -2
  68. package/x/vstorage/keeper/keeper_grpc_test.go +300 -0
  69. package/x/vstorage/keeper/keeper_test.go +1 -1
  70. package/x/vstorage/keeper/querier.go +6 -2
  71. package/x/vstorage/types/query.pb.go +646 -36
  72. package/x/vstorage/types/query.pb.gw.go +119 -0
  73. package/x/vstorage/vstorage.go +16 -15
  74. package/x/vstorage/vstorage_test.go +5 -5
package/vm/action.go CHANGED
@@ -58,21 +58,23 @@ func SetActionHeaderFromContext(ctx sdk.Context, actionType string, ah *ActionHe
58
58
  }
59
59
  }
60
60
 
61
- // PopulateAction interprets `default:"..."` tags and specially handles an
62
- // embedded ActionHeader struct.
61
+ // PopulateAction returns a clone of action in which empty/zero-valued fields
62
+ // in its embedded ActionHeader have been populated using the corresponding
63
+ // `actionType:"..."` tag and the provided ctx, and its own empty/zero-valued
64
+ // fields have been populated as specified by their `default:"..."` tags.
63
65
  func PopulateAction(ctx sdk.Context, action Action) Action {
64
- oldRv := reflect.Indirect(reflect.ValueOf(action))
65
- if oldRv.Kind() != reflect.Struct {
66
+ oldActionDesc := reflect.Indirect(reflect.ValueOf(action))
67
+ if oldActionDesc.Kind() != reflect.Struct {
66
68
  return action
67
69
  }
68
70
 
69
71
  // Shallow copy to a new value.
70
- rp := reflect.New(oldRv.Type())
71
- rv := reflect.Indirect(rp)
72
- for i := 0; i < rv.NumField(); i++ {
73
- oldField := oldRv.Field(i)
74
- field := rv.Field(i)
75
- fieldType := rv.Type().Field(i)
72
+ newActionDescPtr := reflect.New(oldActionDesc.Type())
73
+ newActionDesc := reflect.Indirect(newActionDescPtr)
74
+ for i := 0; i < newActionDesc.NumField(); i++ {
75
+ oldField := oldActionDesc.Field(i)
76
+ field := newActionDesc.Field(i)
77
+ fieldType := newActionDesc.Type().Field(i)
76
78
  if !field.CanSet() {
77
79
  continue
78
80
  }
@@ -81,34 +83,35 @@ func PopulateAction(ctx sdk.Context, action Action) Action {
81
83
  field.Set(oldField)
82
84
 
83
85
  // Populate any ActionHeader struct.
84
- var ahp *ActionHeader
86
+ var headerPtr *ActionHeader
85
87
  if fieldType.Type == actionHeaderType {
86
- ahp = field.Addr().Interface().(*ActionHeader)
88
+ headerPtr = field.Addr().Interface().(*ActionHeader)
87
89
  } else if fieldType.Type == reflect.PtrTo(actionHeaderType) {
88
90
  if field.IsNil() {
89
- ahp = &ActionHeader{}
91
+ headerPtr = &ActionHeader{}
90
92
  } else {
91
- ahp = field.Interface().(*ActionHeader)
93
+ headerPtr = field.Interface().(*ActionHeader)
92
94
  }
93
95
  }
94
- if ahp != nil {
96
+ if headerPtr != nil {
95
97
  actionTypeTag, _ := fieldType.Tag.Lookup("actionType")
96
- ah := *ahp
97
- SetActionHeaderFromContext(ctx, actionTypeTag, &ah)
98
+ newHeader := *headerPtr
99
+ SetActionHeaderFromContext(ctx, actionTypeTag, &newHeader)
98
100
  if field.Kind() == reflect.Ptr {
99
- field.Set(reflect.ValueOf(&ah))
101
+ field.Set(reflect.ValueOf(&newHeader))
100
102
  } else {
101
- field.Set(reflect.ValueOf(ah))
103
+ field.Set(reflect.ValueOf(newHeader))
102
104
  }
103
105
  continue
104
106
  }
105
107
 
106
- // Still zero value, try default struct field tag.
108
+ // Skip any field that is already populated or lacks a "default" tag.
107
109
  defaultTag, _ := fieldType.Tag.Lookup("default")
108
110
  if !field.IsZero() || len(defaultTag) == 0 {
109
111
  continue
110
112
  }
111
113
 
114
+ // Populate the field from its "default" tag.
112
115
  switch field.Kind() {
113
116
  case reflect.String:
114
117
  field.SetString(defaultTag)
@@ -126,5 +129,5 @@ func PopulateAction(ctx sdk.Context, action Action) Action {
126
129
  }
127
130
  }
128
131
  }
129
- return rv.Interface().(Action)
132
+ return newActionDesc.Interface().(Action)
130
133
  }
package/vm/action_test.go CHANGED
@@ -106,21 +106,21 @@ func TestActionContext(t *testing.T) {
106
106
  for _, tc := range testCases {
107
107
  tc := tc
108
108
  t.Run(tc.name, func(t *testing.T) {
109
- jstr := func(in interface{}) string {
109
+ toJson := func(in interface{}) string {
110
110
  bz, err := json.Marshal(in)
111
111
  if err != nil {
112
112
  t.Fatal(err)
113
113
  }
114
114
  return string(bz)
115
115
  }
116
- jsonIn := jstr(tc.in)
116
+ jsonIn := toJson(tc.in)
117
117
  out := vm.PopulateAction(tc.ctx, tc.in)
118
- jsonIn2 := jstr(tc.in)
118
+ jsonIn2 := toJson(tc.in)
119
119
  if jsonIn != jsonIn2 {
120
120
  t.Errorf("unexpected mutated input: %s to %s", jsonIn, jsonIn2)
121
121
  }
122
- jsonOut := jstr(out)
123
- jsonExpectedOut := jstr(tc.expectedOut)
122
+ jsonOut := toJson(out)
123
+ jsonExpectedOut := toJson(tc.expectedOut)
124
124
  if jsonOut != jsonExpectedOut {
125
125
  t.Errorf("expected %s, got %s", jsonExpectedOut, jsonOut)
126
126
  }
package/vm/controller.go CHANGED
@@ -1,16 +1,12 @@
1
1
  package vm
2
2
 
3
3
  import (
4
+ "context"
4
5
  "fmt"
5
6
 
6
7
  sdk "github.com/cosmos/cosmos-sdk/types"
7
8
  )
8
9
 
9
- type ControllerContext struct {
10
- Context sdk.Context
11
- IBCChannelHandlerPort int
12
- }
13
-
14
10
  type ControllerAdmissionMsg interface {
15
11
  sdk.Msg
16
12
  CheckAdmissibility(sdk.Context, interface{}) error
@@ -25,10 +21,13 @@ type ControllerAdmissionMsg interface {
25
21
  IsHighPriority(sdk.Context, interface{}) (bool, error)
26
22
  }
27
23
 
28
- var controllerContext ControllerContext
24
+ var wrappedEmptySDKContext = sdk.WrapSDKContext(
25
+ sdk.Context{}.WithContext(context.Background()),
26
+ )
27
+ var controllerContext context.Context = wrappedEmptySDKContext
29
28
 
30
29
  type PortHandler interface {
31
- Receive(*ControllerContext, string) (string, error)
30
+ Receive(context.Context, string) (string, error)
32
31
  }
33
32
 
34
33
  var portToHandler = make(map[int]PortHandler)
@@ -39,9 +38,9 @@ var lastPort = 0
39
38
  func SetControllerContext(ctx sdk.Context) func() {
40
39
  // We are only called by the controller, so we assume that it is billing its
41
40
  // own meter usage.
42
- controllerContext.Context = ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
41
+ controllerContext = sdk.WrapSDKContext(ctx.WithGasMeter(sdk.NewInfiniteGasMeter()))
43
42
  return func() {
44
- controllerContext.Context = sdk.Context{}
43
+ controllerContext = wrappedEmptySDKContext
45
44
  }
46
45
  }
47
46
 
@@ -69,5 +68,5 @@ func ReceiveFromController(portNum int, msg string) (string, error) {
69
68
  if handler == nil {
70
69
  return "", fmt.Errorf("unregistered port %d", portNum)
71
70
  }
72
- return handler.Receive(&controllerContext, msg)
71
+ return handler.Receive(controllerContext, msg)
73
72
  }
@@ -88,7 +88,7 @@ func (uva unlockedVestingAccount) TrackDelegation(blockTime time.Time, balance,
88
88
  // TrackUndelegation implements the vestexported.VestingAccount interface.
89
89
  func (uva unlockedVestingAccount) TrackUndelegation(amount sdk.Coins) {
90
90
  // max(delegated - amount, 0) == delegated - min(delegated, amount)
91
- uva.lien.Delegated = uva.lien.Delegated.Sub(uva.lien.Delegated.Min(amount))
91
+ uva.lien.Delegated = uva.lien.Delegated.Sub(uva.lien.Delegated.Min(amount)...)
92
92
  }
93
93
 
94
94
  // GetVestedCoins implements the vestexported.VestingAccount interface.
@@ -211,12 +211,12 @@ func (la *LienAccount) LienedLockedCoins(ctx sdk.Context) sdk.Coins {
211
211
  liened := la.lien.Coins
212
212
  acc := la.omniClawbackAccount.(authtypes.AccountI)
213
213
  if clawback, ok := acc.(vestexported.ClawbackVestingAccountI); ok {
214
- liened = liened.Add(clawback.GetOriginalVesting().Sub(clawback.GetVestedOnly(ctx.BlockTime()))...)
214
+ liened = liened.Add(clawback.GetOriginalVesting().Sub(clawback.GetVestedOnly(ctx.BlockTime())...)...)
215
215
  }
216
216
  // Since coins can't go negative, even transiently, use the
217
217
  // identity A + B = max(A, B) + min(A, B)
218
218
  // max(0, A - B) = max(B, A) - B = A - min(A, B)
219
- return liened.Sub(liened.Min(delegated))
219
+ return liened.Sub(liened.Min(delegated)...)
220
220
  }
221
221
 
222
222
  // XXX_MessageName provides the message name for JSON serialization.
@@ -7,6 +7,7 @@ import (
7
7
  "github.com/Agoric/agoric-sdk/golang/cosmos/x/lien/types"
8
8
 
9
9
  "github.com/cosmos/cosmos-sdk/codec"
10
+ storetypes "github.com/cosmos/cosmos-sdk/store/types"
10
11
  sdk "github.com/cosmos/cosmos-sdk/types"
11
12
  vestexported "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported"
12
13
  stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types"
@@ -31,7 +32,7 @@ type Keeper interface {
31
32
  // The accountKeeper field must be the same one that the bankKeeper and
32
33
  // stakingKeeper use.
33
34
  type keeperImpl struct {
34
- key sdk.StoreKey
35
+ key storetypes.StoreKey
35
36
  cdc codec.Codec
36
37
 
37
38
  accountKeeper *types.WrappedAccountKeeper
@@ -43,7 +44,7 @@ type keeperImpl struct {
43
44
 
44
45
  // NewKeeper returns a new Keeper.
45
46
  // The ak must be the same accout keeper that the bk and sk use.
46
- func NewKeeper(cdc codec.Codec, key sdk.StoreKey, ak *types.WrappedAccountKeeper, bk types.BankKeeper, sk types.StakingKeeper,
47
+ func NewKeeper(cdc codec.Codec, key storetypes.StoreKey, ak *types.WrappedAccountKeeper, bk types.BankKeeper, sk types.StakingKeeper,
47
48
  pushAction vm.ActionPusher) Keeper {
48
49
  return keeperImpl{
49
50
  key: key,
@@ -124,7 +125,7 @@ func (lk keeperImpl) ChangeLien(ctx sdk.Context, addr sdk.AccAddress, denom stri
124
125
  return oldAmt, fmt.Errorf("lien delta of %s is larger than existing balance %s", delta, oldAmt)
125
126
  }
126
127
  newCoin := sdk.NewCoin(denom, newAmt)
127
- newCoins := oldCoins.Sub(sdk.NewCoins(sdk.NewCoin(denom, oldAmt))).Add(newCoin)
128
+ newCoins := oldCoins.Sub(sdk.NewCoins(sdk.NewCoin(denom, oldAmt))...).Add(newCoin)
128
129
  newLien := types.Lien{
129
130
  Coins: newCoins,
130
131
  Delegated: oldLien.Delegated,
@@ -223,7 +224,7 @@ func (lk keeperImpl) getLockedUnvested(ctx sdk.Context, addr sdk.AccAddress) (sd
223
224
  original := clawbackAccount.GetOriginalVesting()
224
225
  unlocked := clawbackAccount.GetUnlockedOnly(ctx.BlockTime())
225
226
  vested := clawbackAccount.GetVestedOnly(ctx.BlockTime())
226
- return original.Sub(unlocked), original.Sub(vested)
227
+ return original.Sub(unlocked...), original.Sub(vested...)
227
228
  }
228
229
  if vestingAccount, ok := account.(vestexported.VestingAccount); ok {
229
230
  return vestingAccount.GetVestingCoins(ctx.BlockTime()), sdk.NewCoins()
@@ -99,7 +99,7 @@ func makeTestKit() testKit {
99
99
  stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
100
100
  authtypes.Minter: {authtypes.Minter},
101
101
  }
102
- innerAk := authkeeper.NewAccountKeeper(cdc, authStoreKey, authSpace, authtypes.ProtoBaseAccount, maccPerms)
102
+ innerAk := authkeeper.NewAccountKeeper(cdc, authStoreKey, authSpace, authtypes.ProtoBaseAccount, maccPerms, "agoric")
103
103
  wak := types.NewWrappedAccountKeeper(innerAk)
104
104
 
105
105
  // bank keeper
@@ -120,12 +120,12 @@ func makeTestKit() testKit {
120
120
 
121
121
  db := dbm.NewMemDB()
122
122
  ms := store.NewCommitMultiStore(db)
123
- ms.MountStoreWithDB(paramsTKey, sdk.StoreTypeTransient, nil)
124
- ms.MountStoreWithDB(paramsStoreKey, sdk.StoreTypeIAVL, db)
125
- ms.MountStoreWithDB(authStoreKey, sdk.StoreTypeIAVL, db)
126
- ms.MountStoreWithDB(bankStoreKey, sdk.StoreTypeIAVL, db)
127
- ms.MountStoreWithDB(stakingStoreKey, sdk.StoreTypeIAVL, db)
128
- ms.MountStoreWithDB(lienStoreKey, sdk.StoreTypeIAVL, db)
123
+ ms.MountStoreWithDB(paramsTKey, storetypes.StoreTypeTransient, nil)
124
+ ms.MountStoreWithDB(paramsStoreKey, storetypes.StoreTypeIAVL, db)
125
+ ms.MountStoreWithDB(authStoreKey, storetypes.StoreTypeIAVL, db)
126
+ ms.MountStoreWithDB(bankStoreKey, storetypes.StoreTypeIAVL, db)
127
+ ms.MountStoreWithDB(stakingStoreKey, storetypes.StoreTypeIAVL, db)
128
+ ms.MountStoreWithDB(lienStoreKey, storetypes.StoreTypeIAVL, db)
129
129
  err := ms.LoadLatestVersion()
130
130
  if err != nil {
131
131
  panic(err)
@@ -165,7 +165,7 @@ func (tk testKit) initAccount(t *testing.T, funder, addr sdk.AccAddress, state t
165
165
  }
166
166
 
167
167
  // Total
168
- toMint := state.Total.Sub(state.Locked)
168
+ toMint := state.Total.Sub(state.Locked...)
169
169
  if !toMint.IsZero() {
170
170
  err := tk.bankKeeper.MintCoins(tk.ctx, authtypes.Minter, toMint)
171
171
  if err != nil {
package/x/lien/lien.go CHANGED
@@ -5,6 +5,7 @@
5
5
  package lien
6
6
 
7
7
  import (
8
+ "context"
8
9
  "encoding/json"
9
10
  "fmt"
10
11
  "math"
@@ -70,7 +71,8 @@ const (
70
71
  // Receives and processes a bridge message, returning the
71
72
  // JSON-encoded response or error.
72
73
  // See spec/02_messages.md for the messages and responses.
73
- func (ch portHandler) Receive(ctx *vm.ControllerContext, str string) (string, error) {
74
+ func (ch portHandler) Receive(cctx context.Context, str string) (string, error) {
75
+ ctx := sdk.UnwrapSDKContext(cctx)
74
76
  var msg portMessage
75
77
  err := json.Unmarshal([]byte(str), &msg)
76
78
  if err != nil {
@@ -78,13 +80,13 @@ func (ch portHandler) Receive(ctx *vm.ControllerContext, str string) (string, er
78
80
  }
79
81
  switch msg.Type {
80
82
  case LIEN_GET_ACCOUNT_STATE:
81
- return ch.handleGetAccountState(ctx.Context, msg)
83
+ return ch.handleGetAccountState(ctx, msg)
82
84
 
83
85
  case LIEN_GET_STAKING:
84
- return ch.handleGetStaking(ctx.Context, msg)
86
+ return ch.handleGetStaking(ctx, msg)
85
87
 
86
88
  case LIEN_CHANGE_LIENED:
87
- return ch.handleChangeLiened(ctx.Context, msg)
89
+ return ch.handleChangeLiened(ctx, msg)
88
90
  }
89
91
  return "", fmt.Errorf("unrecognized type %s", msg.Type)
90
92
  }
@@ -1,11 +1,11 @@
1
1
  package lien
2
2
 
3
3
  import (
4
+ "context"
4
5
  "encoding/json"
5
6
  "reflect"
6
7
  "testing"
7
8
 
8
- "github.com/Agoric/agoric-sdk/golang/cosmos/vm"
9
9
  "github.com/Agoric/agoric-sdk/golang/cosmos/x/lien/types"
10
10
 
11
11
  "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
@@ -97,7 +97,7 @@ func (m *mockLienKeeper) BondDenom(ctx sdk.Context) string {
97
97
  func (m *mockLienKeeper) GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins {
98
98
  state := m.GetAccountState(ctx, addr)
99
99
  delegated := state.Bonded.Add(state.Unbonding...)
100
- bank := state.Total.Sub(state.Total.Min(delegated))
100
+ bank := state.Total.Sub(state.Total.Min(delegated)...)
101
101
  return bank
102
102
  }
103
103
 
@@ -114,8 +114,8 @@ func (m *mockLienKeeper) GetDelegatorDelegations(ctx sdk.Context, delegator sdk.
114
114
  }
115
115
 
116
116
  func TestBadType(t *testing.T) {
117
- ctx := sdk.Context{}
118
- ctlCtx := &vm.ControllerContext{Context: ctx}
117
+ ctx := sdk.Context{}.WithContext(context.Background())
118
+ ctlCtx := sdk.WrapSDKContext(ctx)
119
119
  keeper := mockLienKeeper{
120
120
  states: map[string]types.AccountState{},
121
121
  }
@@ -135,8 +135,8 @@ func TestBadType(t *testing.T) {
135
135
  }
136
136
 
137
137
  func TestGetAccountState(t *testing.T) {
138
- ctx := sdk.Context{}
139
- ctlCtx := &vm.ControllerContext{Context: ctx}
138
+ ctx := sdk.Context{}.WithContext(context.Background())
139
+ ctlCtx := sdk.WrapSDKContext(ctx)
140
140
 
141
141
  keeper := mockLienKeeper{
142
142
  states: map[string]types.AccountState{
@@ -177,8 +177,9 @@ func TestGetAccountState(t *testing.T) {
177
177
  }
178
178
 
179
179
  func TestGetAccountState_badRequest(t *testing.T) {
180
- ctx := sdk.Context{}
181
- ctlCtx := &vm.ControllerContext{Context: ctx}
180
+ ctx := sdk.Context{}.WithContext(context.Background())
181
+ ctlCtx := sdk.WrapSDKContext(ctx)
182
+
182
183
  keeper := mockLienKeeper{
183
184
  states: map[string]types.AccountState{},
184
185
  }
@@ -214,8 +215,9 @@ func TestGetAccountState_badRequest(t *testing.T) {
214
215
  }
215
216
 
216
217
  func TestSetLiened_badAddr(t *testing.T) {
217
- ctx := sdk.Context{}
218
- ctlCtx := &vm.ControllerContext{Context: ctx}
218
+ ctx := sdk.Context{}.WithContext(context.Background())
219
+ ctlCtx := sdk.WrapSDKContext(ctx)
220
+
219
221
  keeper := mockLienKeeper{}
220
222
  ph := NewPortHandler(&keeper)
221
223
  msg := portMessage{
@@ -235,8 +237,9 @@ func TestSetLiened_badAddr(t *testing.T) {
235
237
  }
236
238
 
237
239
  func TestSetLiened_badDenom(t *testing.T) {
238
- ctx := sdk.Context{}
239
- ctlCtx := &vm.ControllerContext{Context: ctx}
240
+ ctx := sdk.Context{}.WithContext(context.Background())
241
+ ctlCtx := sdk.WrapSDKContext(ctx)
242
+
240
243
  keeper := mockLienKeeper{}
241
244
  ph := NewPortHandler(&keeper)
242
245
  msg := portMessage{
@@ -256,8 +259,9 @@ func TestSetLiened_badDenom(t *testing.T) {
256
259
  }
257
260
 
258
261
  func TestSetLiened(t *testing.T) {
259
- ctx := sdk.Context{}
260
- ctlCtx := &vm.ControllerContext{Context: ctx}
262
+ ctx := sdk.Context{}.WithContext(context.Background())
263
+ ctlCtx := sdk.WrapSDKContext(ctx)
264
+
261
265
  keeper := mockLienKeeper{}
262
266
  ph := NewPortHandler(&keeper)
263
267
  msg := portMessage{
@@ -336,8 +340,8 @@ func TestGetStaking(t *testing.T) {
336
340
  keeper.delegations[addr4.String()] = []stakingTypes.Delegation{}
337
341
 
338
342
  ph := NewPortHandler(&keeper)
339
- ctx := sdk.Context{}
340
- ctlCtx := &vm.ControllerContext{Context: ctx}
343
+ ctx := sdk.Context{}.WithContext(context.Background())
344
+ ctlCtx := sdk.WrapSDKContext(ctx)
341
345
 
342
346
  pi := func(x int64) *sdk.Int {
343
347
  n := i(x)
@@ -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
- }