@agoric/cosmos 0.34.2-dev-6368fcd.0 → 0.34.2-dev-9c61393.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/git-revision.txt +1 -1
- package/package.json +2 -2
- package/proto/agoric/vbank/vbank.proto +7 -0
- package/x/vbank/README.md +6 -1
- package/x/vbank/keeper/keeper.go +4 -9
- package/x/vbank/keeper/migrations.go +30 -0
- package/x/vbank/module.go +8 -2
- package/x/vbank/types/params.go +43 -2
- package/x/vbank/types/vbank.pb.go +105 -36
- package/x/vbank/vbank_test.go +12 -7
package/git-revision.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
9c61393
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/cosmos",
|
|
3
|
-
"version": "0.34.2-dev-
|
|
3
|
+
"version": "0.34.2-dev-9c61393.0+9c61393",
|
|
4
4
|
"description": "Connect JS to the Cosmos blockchain SDK",
|
|
5
5
|
"parsers": {
|
|
6
6
|
"js": "mjs"
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"typeCoverage": {
|
|
40
40
|
"atLeast": 0
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "9c613931dc0ba7daeb614a1265e2015009669515"
|
|
43
43
|
}
|
|
@@ -33,6 +33,13 @@ message Params {
|
|
|
33
33
|
int64 reward_smoothing_blocks = 3 [
|
|
34
34
|
(gogoproto.moretags) = "yaml:\"reward_smoothing_blocks\""
|
|
35
35
|
];
|
|
36
|
+
|
|
37
|
+
// allowed_monitoring_accounts is an array of account addresses that can be
|
|
38
|
+
// monitored for sends and receives. An element of `"*"` will permit any
|
|
39
|
+
// address.
|
|
40
|
+
repeated string allowed_monitoring_accounts = 4 [
|
|
41
|
+
(gogoproto.moretags) = "yaml:\"allowed_monitoring_accounts\""
|
|
42
|
+
];
|
|
36
43
|
}
|
|
37
44
|
|
|
38
45
|
// The current state of the module.
|
package/x/vbank/README.md
CHANGED
|
@@ -13,6 +13,11 @@ entirely at the ERTP level.
|
|
|
13
13
|
|
|
14
14
|
- `feeCollectorName`: the module which handles fee distribution to stakers.
|
|
15
15
|
- `reward_epoch_duration_blocks`: the duration (in blocks) over which fees should be given to the fee collector.
|
|
16
|
+
- `per_epoch_reward_fraction`: a decimal of how much of the `GiveawayPool` is paid as validator rewards per epoch
|
|
17
|
+
- `allowed_monitoring_accounts`: an array of account addresses that can be
|
|
18
|
+
monitored for sends and receives, defaulting to
|
|
19
|
+
`[authtypes.NewModuleAddress(types.ProvisionPoolName)]`. An element of `"*"`
|
|
20
|
+
will permit any address.
|
|
16
21
|
|
|
17
22
|
## State
|
|
18
23
|
|
|
@@ -22,7 +27,7 @@ The Vbank module maintains no significant state, but will access stored state th
|
|
|
22
27
|
|
|
23
28
|
Purse operations which change the balance result in a downcall to this module to update the underlying account. A downcall is also made to query the account balance.
|
|
24
29
|
|
|
25
|
-
Upon an `EndBlock()` call, the module will scan the block for all `MsgSend` and `MsgMultiSend` events (see `cosmos-sdk/x/bank/spec/04_events.md`) and perform a `VBANK_BALANCE_UPDATE` upcall for all denominations held in *only the
|
|
30
|
+
Upon an `EndBlock()` call, the module will scan the block for all `MsgSend` and `MsgMultiSend` events (see `cosmos-sdk/x/bank/spec/04_events.md`) and perform a `VBANK_BALANCE_UPDATE` upcall for all denominations held in *only in the allowed_monitoring_accounts*.
|
|
26
31
|
|
|
27
32
|
The following fields are common to the Vbank messages:
|
|
28
33
|
- `"address"`, `"recipient"`, `"sender"`: account address as a bech32-encoded string
|
package/x/vbank/keeper/keeper.go
CHANGED
|
@@ -6,7 +6,6 @@ import (
|
|
|
6
6
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
7
7
|
|
|
8
8
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vbank/types"
|
|
9
|
-
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
|
10
9
|
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
|
11
10
|
|
|
12
11
|
vm "github.com/Agoric/agoric-sdk/golang/cosmos/vm"
|
|
@@ -88,17 +87,13 @@ func (k Keeper) GetModuleAccountAddress(ctx sdk.Context, name string) sdk.AccAdd
|
|
|
88
87
|
return acct.GetAddress()
|
|
89
88
|
}
|
|
90
89
|
|
|
91
|
-
func (k Keeper)
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return false
|
|
95
|
-
}
|
|
96
|
-
_, ok := acc.(authtypes.ModuleAccountI)
|
|
97
|
-
return ok
|
|
90
|
+
func (k Keeper) IsAllowedMonitoringAccount(ctx sdk.Context, addr sdk.AccAddress) bool {
|
|
91
|
+
params := k.GetParams(ctx)
|
|
92
|
+
return params.IsAllowedMonitoringAccount(addr.String())
|
|
98
93
|
}
|
|
99
94
|
|
|
100
95
|
func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
|
|
101
|
-
k.paramSpace.
|
|
96
|
+
k.paramSpace.GetParamSetIfExists(ctx, ¶ms)
|
|
102
97
|
return params
|
|
103
98
|
}
|
|
104
99
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
package keeper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vbank/types"
|
|
5
|
+
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
// Migrator handles in-place store migrations.
|
|
9
|
+
type Migrator struct {
|
|
10
|
+
keeper Keeper
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// NewMigrator creates a new Migrator based on the keeper.
|
|
14
|
+
func NewMigrator(keeper Keeper) Migrator {
|
|
15
|
+
return Migrator{keeper: keeper}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Migrate1to2 migrates from version 1 to 2.
|
|
19
|
+
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
|
|
20
|
+
params := m.keeper.GetParams(ctx)
|
|
21
|
+
if params.AllowedMonitoringAccounts != nil {
|
|
22
|
+
return nil
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
defaultParams := types.DefaultParams()
|
|
26
|
+
params.AllowedMonitoringAccounts = defaultParams.AllowedMonitoringAccounts
|
|
27
|
+
m.keeper.SetParams(ctx, params)
|
|
28
|
+
|
|
29
|
+
return nil
|
|
30
|
+
}
|
package/x/vbank/module.go
CHANGED
|
@@ -91,7 +91,7 @@ func (AppModule) Name() string {
|
|
|
91
91
|
return ModuleName
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
func (AppModule) ConsensusVersion() uint64 { return
|
|
94
|
+
func (AppModule) ConsensusVersion() uint64 { return 2 }
|
|
95
95
|
|
|
96
96
|
// BeginBlock implements the AppModule interface
|
|
97
97
|
func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
|
|
@@ -157,7 +157,7 @@ NextEvent:
|
|
|
157
157
|
addressToUpdate = make(map[string]sdk.Coins, len(addressToUpdate))
|
|
158
158
|
for addr, denoms := range unfilteredAddresses {
|
|
159
159
|
accAddr, err := sdk.AccAddressFromBech32(addr)
|
|
160
|
-
if err == nil && am.keeper.
|
|
160
|
+
if err == nil && am.keeper.IsAllowedMonitoringAccount(ctx, accAddr) {
|
|
161
161
|
// Pass through the module account.
|
|
162
162
|
addressToUpdate[addr] = denoms
|
|
163
163
|
}
|
|
@@ -204,6 +204,12 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
|
|
|
204
204
|
tx := &types.UnimplementedMsgServer{}
|
|
205
205
|
types.RegisterMsgServer(cfg.MsgServer(), tx)
|
|
206
206
|
types.RegisterQueryServer(cfg.QueryServer(), am.keeper)
|
|
207
|
+
|
|
208
|
+
m := keeper.NewMigrator(am.keeper)
|
|
209
|
+
err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2)
|
|
210
|
+
if err != nil {
|
|
211
|
+
panic(err)
|
|
212
|
+
}
|
|
207
213
|
}
|
|
208
214
|
|
|
209
215
|
// InitGenesis performs genesis initialization for the ibc-transfer module. It returns
|
package/x/vbank/types/params.go
CHANGED
|
@@ -6,14 +6,18 @@ import (
|
|
|
6
6
|
yaml "gopkg.in/yaml.v2"
|
|
7
7
|
|
|
8
8
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
9
|
+
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
|
9
10
|
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
|
10
11
|
)
|
|
11
12
|
|
|
13
|
+
const AllowAllMonitoringAccountsPattern = "*"
|
|
14
|
+
|
|
12
15
|
// Parameter keys
|
|
13
16
|
var (
|
|
14
17
|
ParamStoreKeyRewardEpochDurationBlocks = []byte("reward_epoch_duration_blocks")
|
|
15
18
|
ParamStoreKeyRewardSmoothingBlocks = []byte("reward_smoothing_blocks")
|
|
16
19
|
ParamStoreKeyPerEpochRewardFraction = []byte("per_epoch_reward_fraction")
|
|
20
|
+
ParamStoreKeyAllowedMonitoringAccounts = []byte("allowed_monitoring_accounts")
|
|
17
21
|
)
|
|
18
22
|
|
|
19
23
|
// ParamKeyTable returns the parameter key table.
|
|
@@ -21,12 +25,14 @@ func ParamKeyTable() paramtypes.KeyTable {
|
|
|
21
25
|
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
|
|
22
26
|
}
|
|
23
27
|
|
|
24
|
-
// DefaultParams returns default
|
|
28
|
+
// DefaultParams returns default parameters
|
|
25
29
|
func DefaultParams() Params {
|
|
30
|
+
provisionAddress := authtypes.NewModuleAddress(ProvisionPoolName)
|
|
26
31
|
return Params{
|
|
27
32
|
RewardEpochDurationBlocks: 0,
|
|
28
33
|
RewardSmoothingBlocks: 1,
|
|
29
34
|
PerEpochRewardFraction: sdk.OneDec(),
|
|
35
|
+
AllowedMonitoringAccounts: []string{provisionAddress.String()},
|
|
30
36
|
}
|
|
31
37
|
}
|
|
32
38
|
|
|
@@ -67,12 +73,27 @@ func (p Params) RewardRate(pool sdk.Coins, blocks int64) sdk.Coins {
|
|
|
67
73
|
return sdk.NewCoins(coins...)
|
|
68
74
|
}
|
|
69
75
|
|
|
76
|
+
// IsAllowedMonitoringAccount checks to see if a given address is allowed to monitor its balance.
|
|
77
|
+
func (p Params) IsAllowedMonitoringAccount(addr string) bool {
|
|
78
|
+
for _, pat := range p.AllowedMonitoringAccounts {
|
|
79
|
+
switch pat {
|
|
80
|
+
case AllowAllMonitoringAccountsPattern, addr:
|
|
81
|
+
// Got an AllowAll pattern or an exact match.
|
|
82
|
+
return true
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// No match found.
|
|
87
|
+
return false
|
|
88
|
+
}
|
|
89
|
+
|
|
70
90
|
// ParamSetPairs returns the parameter set pairs.
|
|
71
91
|
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
|
|
72
92
|
return paramtypes.ParamSetPairs{
|
|
73
93
|
paramtypes.NewParamSetPair(ParamStoreKeyRewardEpochDurationBlocks, &p.RewardEpochDurationBlocks, validateRewardEpochDurationBlocks),
|
|
74
94
|
paramtypes.NewParamSetPair(ParamStoreKeyRewardSmoothingBlocks, &p.RewardSmoothingBlocks, validateRewardSmoothingBlocks),
|
|
75
95
|
paramtypes.NewParamSetPair(ParamStoreKeyPerEpochRewardFraction, &p.PerEpochRewardFraction, validatePerEpochRewardFraction),
|
|
96
|
+
paramtypes.NewParamSetPair(ParamStoreKeyAllowedMonitoringAccounts, &p.AllowedMonitoringAccounts, validateAllowedMonitoringAccounts),
|
|
76
97
|
}
|
|
77
98
|
}
|
|
78
99
|
|
|
@@ -84,7 +105,12 @@ func (p Params) ValidateBasic() error {
|
|
|
84
105
|
if err := validatePerEpochRewardFraction(p.PerEpochRewardFraction); err != nil {
|
|
85
106
|
return err
|
|
86
107
|
}
|
|
87
|
-
|
|
108
|
+
if err := validateRewardSmoothingBlocks(p.RewardSmoothingBlocks); err != nil {
|
|
109
|
+
return err
|
|
110
|
+
}
|
|
111
|
+
if err := validateAllowedMonitoringAccounts(p.AllowedMonitoringAccounts); err != nil {
|
|
112
|
+
return err
|
|
113
|
+
}
|
|
88
114
|
return nil
|
|
89
115
|
}
|
|
90
116
|
|
|
@@ -130,3 +156,18 @@ func validatePerEpochRewardFraction(i interface{}) error {
|
|
|
130
156
|
|
|
131
157
|
return nil
|
|
132
158
|
}
|
|
159
|
+
|
|
160
|
+
func validateAllowedMonitoringAccounts(i interface{}) error {
|
|
161
|
+
v, ok := i.([]string)
|
|
162
|
+
if !ok {
|
|
163
|
+
return fmt.Errorf("invalid parameter type: %T", i)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
for a, acc := range v {
|
|
167
|
+
if acc == "" {
|
|
168
|
+
return fmt.Errorf("allowed monitoring accounts element[%d] cannot be empty", a)
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return nil
|
|
173
|
+
}
|
|
@@ -39,6 +39,10 @@ type Params struct {
|
|
|
39
39
|
// an epoch's rewards. If zero, use the same value as
|
|
40
40
|
// reward_epoch_duration_blocks.
|
|
41
41
|
RewardSmoothingBlocks int64 `protobuf:"varint,3,opt,name=reward_smoothing_blocks,json=rewardSmoothingBlocks,proto3" json:"reward_smoothing_blocks,omitempty" yaml:"reward_smoothing_blocks"`
|
|
42
|
+
// allowed_monitoring_accounts is an array of account addresses that can be
|
|
43
|
+
// monitored for sends and receives. An element of `"*"` will permit any
|
|
44
|
+
// address.
|
|
45
|
+
AllowedMonitoringAccounts []string `protobuf:"bytes,4,rep,name=allowed_monitoring_accounts,json=allowedMonitoringAccounts,proto3" json:"allowed_monitoring_accounts,omitempty" yaml:"allowed_monitoring_accounts"`
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
func (m *Params) Reset() { *m = Params{} }
|
|
@@ -87,6 +91,13 @@ func (m *Params) GetRewardSmoothingBlocks() int64 {
|
|
|
87
91
|
return 0
|
|
88
92
|
}
|
|
89
93
|
|
|
94
|
+
func (m *Params) GetAllowedMonitoringAccounts() []string {
|
|
95
|
+
if m != nil {
|
|
96
|
+
return m.AllowedMonitoringAccounts
|
|
97
|
+
}
|
|
98
|
+
return nil
|
|
99
|
+
}
|
|
100
|
+
|
|
90
101
|
// The current state of the module.
|
|
91
102
|
type State struct {
|
|
92
103
|
// rewardPool is the current balance of rewards in the module account.
|
|
@@ -170,42 +181,45 @@ func init() {
|
|
|
170
181
|
func init() { proto.RegisterFile("agoric/vbank/vbank.proto", fileDescriptor_5e89b3b9e5e671b4) }
|
|
171
182
|
|
|
172
183
|
var fileDescriptor_5e89b3b9e5e671b4 = []byte{
|
|
173
|
-
//
|
|
174
|
-
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94,
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
0x20,
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
0x72,
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
0x62,
|
|
207
|
-
|
|
208
|
-
|
|
184
|
+
// 597 bytes of a gzipped FileDescriptorProto
|
|
185
|
+
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0x3f, 0x6f, 0xd3, 0x4e,
|
|
186
|
+
0x18, 0xc7, 0xe3, 0x26, 0xbf, 0xea, 0xd7, 0x6b, 0x19, 0x30, 0x05, 0x9c, 0x16, 0xd9, 0xd1, 0x21,
|
|
187
|
+
0x4a, 0x18, 0xb0, 0x55, 0x58, 0x50, 0x25, 0x86, 0x9a, 0xd2, 0x0d, 0x54, 0xb9, 0x03, 0x52, 0x97,
|
|
188
|
+
0xe8, 0x7c, 0xb9, 0x3a, 0x56, 0x6d, 0x3f, 0xe1, 0xee, 0xd2, 0xd2, 0x95, 0x57, 0x80, 0x98, 0x60,
|
|
189
|
+
0xeb, 0xcc, 0x2b, 0xe9, 0xd8, 0x05, 0x09, 0x21, 0x61, 0x50, 0xbb, 0x30, 0xe7, 0x15, 0xa0, 0xfb,
|
|
190
|
+
0x53, 0xda, 0x20, 0x14, 0x60, 0x49, 0xe2, 0x7c, 0xbe, 0xcf, 0x93, 0xef, 0xf3, 0x27, 0x0f, 0xf2,
|
|
191
|
+
0x48, 0x06, 0x3c, 0xa7, 0xd1, 0x7e, 0x4a, 0xaa, 0x3d, 0xf3, 0x1a, 0x0e, 0x39, 0x48, 0x70, 0x17,
|
|
192
|
+
0x0c, 0x09, 0xf5, 0x77, 0x4b, 0x8b, 0x19, 0x64, 0xa0, 0x41, 0xa4, 0x3e, 0x19, 0xcd, 0x92, 0x4f,
|
|
193
|
+
0x41, 0x94, 0x20, 0xa2, 0x94, 0x08, 0x16, 0xed, 0xaf, 0xa6, 0x4c, 0x92, 0xd5, 0x88, 0x42, 0x5e,
|
|
194
|
+
0x19, 0x8e, 0x3f, 0x36, 0xd1, 0xec, 0x16, 0xe1, 0xa4, 0x14, 0xee, 0x00, 0xdd, 0xe2, 0xec, 0x80,
|
|
195
|
+
0xf0, 0x7e, 0x8f, 0x0d, 0x81, 0x0e, 0x7a, 0xfd, 0x11, 0x27, 0x32, 0x87, 0xaa, 0x97, 0x16, 0x40,
|
|
196
|
+
0xf7, 0x84, 0xe7, 0x74, 0x9c, 0x6e, 0x33, 0xbe, 0x3b, 0xae, 0x83, 0xdb, 0x87, 0xa4, 0x2c, 0xd6,
|
|
197
|
+
0xf0, 0x34, 0x35, 0x4e, 0xda, 0x06, 0x3f, 0x55, 0x74, 0xc3, 0xc2, 0x58,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73, 0x72, 0xea, 0x3b, 0xdf, 0x4e, 0x7d, 0xe7, 0xcd,
|
|
219
|
+
0x99, 0xdf, 0x38, 0x39, 0xf3, 0x1b, 0x9f, 0xce, 0xfc, 0xc6, 0xce, 0xa3, 0x4b, 0xbd, 0x58, 0x37,
|
|
220
|
+
0xa7, 0xc3, 0xdc, 0x09, 0xdd, 0x8b, 0x0c, 0x0a, 0x52, 0x65, 0xe7, 0x4d, 0x7a, 0x65, 0xaf, 0x8a,
|
|
221
|
+
0xee, 0x50, 0x3a, 0xab, 0x4f, 0xc2, 0xc3, 0x1f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x60, 0x18, 0x80,
|
|
222
|
+
0x8f, 0x72, 0x04, 0x00, 0x00,
|
|
209
223
|
}
|
|
210
224
|
|
|
211
225
|
func (this *Params) Equal(that interface{}) bool {
|
|
@@ -236,6 +250,14 @@ func (this *Params) Equal(that interface{}) bool {
|
|
|
236
250
|
if this.RewardSmoothingBlocks != that1.RewardSmoothingBlocks {
|
|
237
251
|
return false
|
|
238
252
|
}
|
|
253
|
+
if len(this.AllowedMonitoringAccounts) != len(that1.AllowedMonitoringAccounts) {
|
|
254
|
+
return false
|
|
255
|
+
}
|
|
256
|
+
for i := range this.AllowedMonitoringAccounts {
|
|
257
|
+
if this.AllowedMonitoringAccounts[i] != that1.AllowedMonitoringAccounts[i] {
|
|
258
|
+
return false
|
|
259
|
+
}
|
|
260
|
+
}
|
|
239
261
|
return true
|
|
240
262
|
}
|
|
241
263
|
func (this *State) Equal(that interface{}) bool {
|
|
@@ -301,6 +323,15 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|
|
301
323
|
_ = i
|
|
302
324
|
var l int
|
|
303
325
|
_ = l
|
|
326
|
+
if len(m.AllowedMonitoringAccounts) > 0 {
|
|
327
|
+
for iNdEx := len(m.AllowedMonitoringAccounts) - 1; iNdEx >= 0; iNdEx-- {
|
|
328
|
+
i -= len(m.AllowedMonitoringAccounts[iNdEx])
|
|
329
|
+
copy(dAtA[i:], m.AllowedMonitoringAccounts[iNdEx])
|
|
330
|
+
i = encodeVarintVbank(dAtA, i, uint64(len(m.AllowedMonitoringAccounts[iNdEx])))
|
|
331
|
+
i--
|
|
332
|
+
dAtA[i] = 0x22
|
|
333
|
+
}
|
|
334
|
+
}
|
|
304
335
|
if m.RewardSmoothingBlocks != 0 {
|
|
305
336
|
i = encodeVarintVbank(dAtA, i, uint64(m.RewardSmoothingBlocks))
|
|
306
337
|
i--
|
|
@@ -410,6 +441,12 @@ func (m *Params) Size() (n int) {
|
|
|
410
441
|
if m.RewardSmoothingBlocks != 0 {
|
|
411
442
|
n += 1 + sovVbank(uint64(m.RewardSmoothingBlocks))
|
|
412
443
|
}
|
|
444
|
+
if len(m.AllowedMonitoringAccounts) > 0 {
|
|
445
|
+
for _, s := range m.AllowedMonitoringAccounts {
|
|
446
|
+
l = len(s)
|
|
447
|
+
n += 1 + l + sovVbank(uint64(l))
|
|
448
|
+
}
|
|
449
|
+
}
|
|
413
450
|
return n
|
|
414
451
|
}
|
|
415
452
|
|
|
@@ -547,6 +584,38 @@ func (m *Params) Unmarshal(dAtA []byte) error {
|
|
|
547
584
|
break
|
|
548
585
|
}
|
|
549
586
|
}
|
|
587
|
+
case 4:
|
|
588
|
+
if wireType != 2 {
|
|
589
|
+
return fmt.Errorf("proto: wrong wireType = %d for field AllowedMonitoringAccounts", wireType)
|
|
590
|
+
}
|
|
591
|
+
var stringLen uint64
|
|
592
|
+
for shift := uint(0); ; shift += 7 {
|
|
593
|
+
if shift >= 64 {
|
|
594
|
+
return ErrIntOverflowVbank
|
|
595
|
+
}
|
|
596
|
+
if iNdEx >= l {
|
|
597
|
+
return io.ErrUnexpectedEOF
|
|
598
|
+
}
|
|
599
|
+
b := dAtA[iNdEx]
|
|
600
|
+
iNdEx++
|
|
601
|
+
stringLen |= uint64(b&0x7F) << shift
|
|
602
|
+
if b < 0x80 {
|
|
603
|
+
break
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
intStringLen := int(stringLen)
|
|
607
|
+
if intStringLen < 0 {
|
|
608
|
+
return ErrInvalidLengthVbank
|
|
609
|
+
}
|
|
610
|
+
postIndex := iNdEx + intStringLen
|
|
611
|
+
if postIndex < 0 {
|
|
612
|
+
return ErrInvalidLengthVbank
|
|
613
|
+
}
|
|
614
|
+
if postIndex > l {
|
|
615
|
+
return io.ErrUnexpectedEOF
|
|
616
|
+
}
|
|
617
|
+
m.AllowedMonitoringAccounts = append(m.AllowedMonitoringAccounts, string(dAtA[iNdEx:postIndex]))
|
|
618
|
+
iNdEx = postIndex
|
|
550
619
|
default:
|
|
551
620
|
iNdEx = preIndex
|
|
552
621
|
skippy, err := skipVbank(dAtA[iNdEx:])
|
package/x/vbank/vbank_test.go
CHANGED
|
@@ -439,6 +439,7 @@ func Test_Receive_GiveToRewardDistributor(t *testing.T) {
|
|
|
439
439
|
params := types.DefaultParams()
|
|
440
440
|
params.RewardEpochDurationBlocks = 0
|
|
441
441
|
params.RewardSmoothingBlocks = tt.duration
|
|
442
|
+
params.AllowedMonitoringAccounts = []string{"*"}
|
|
442
443
|
|
|
443
444
|
keeper.SetParams(ctx, params)
|
|
444
445
|
keeper.SetState(ctx, types.State{RewardPool: tt.rewardPool})
|
|
@@ -524,7 +525,7 @@ func Test_EndBlock_Events(t *testing.T) {
|
|
|
524
525
|
}
|
|
525
526
|
keeper, ctx := makeTestKit(acct, bank)
|
|
526
527
|
// Turn off rewards.
|
|
527
|
-
keeper.SetParams(ctx, types.Params{PerEpochRewardFraction: sdk.ZeroDec()})
|
|
528
|
+
keeper.SetParams(ctx, types.Params{PerEpochRewardFraction: sdk.ZeroDec(), AllowedMonitoringAccounts: []string{"*"}})
|
|
528
529
|
msgsSent := []string{}
|
|
529
530
|
keeper.PushAction = func(ctx sdk.Context, action vm.Action) error {
|
|
530
531
|
bz, err := json.Marshal(action)
|
|
@@ -804,15 +805,19 @@ func Test_Module_Account(t *testing.T) {
|
|
|
804
805
|
}
|
|
805
806
|
|
|
806
807
|
modAddr := sdk.MustAccAddressFromBech32(moduleBech32)
|
|
807
|
-
if
|
|
808
|
-
t.Errorf("got
|
|
808
|
+
if keeper.IsAllowedMonitoringAccount(ctx, modAddr) {
|
|
809
|
+
t.Errorf("got IsAllowedMonitoringAccount modAddr = true, want false")
|
|
810
|
+
}
|
|
811
|
+
provisionPool := authtypes.NewModuleAddress("vbank/provision")
|
|
812
|
+
if !keeper.IsAllowedMonitoringAccount(ctx, provisionPool) {
|
|
813
|
+
t.Errorf("got IsAllowedMonitoringAccount provisionPool = false, want true")
|
|
809
814
|
}
|
|
810
815
|
notModAddr := sdk.MustAccAddressFromBech32(addr1)
|
|
811
|
-
if keeper.
|
|
812
|
-
t.Errorf("got
|
|
816
|
+
if keeper.IsAllowedMonitoringAccount(ctx, notModAddr) {
|
|
817
|
+
t.Errorf("got IsAllowedMonitoringAccount notModAddr = true, want false")
|
|
813
818
|
}
|
|
814
819
|
missingAddr := sdk.MustAccAddressFromBech32(addr2)
|
|
815
|
-
if keeper.
|
|
816
|
-
t.Errorf("got
|
|
820
|
+
if keeper.IsAllowedMonitoringAccount(ctx, missingAddr) {
|
|
821
|
+
t.Errorf("got IsAllowedMonitoringAccount missingAddr = false, want true")
|
|
817
822
|
}
|
|
818
823
|
}
|