From 84bae0737c1fe538960f704046d7845013e98f4f Mon Sep 17 00:00:00 2001 From: Marko Date: Fri, 26 Apr 2024 17:38:36 +0200 Subject: [PATCH 01/10] docs(lockup): add documentation (#19898) Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- x/accounts/defaults/lockup/README.md | 259 ++++++++++++++++++++++++++- 1 file changed, 256 insertions(+), 3 deletions(-) diff --git a/x/accounts/defaults/lockup/README.md b/x/accounts/defaults/lockup/README.md index c81c2eedbae7..8525b18cd5ef 100644 --- a/x/accounts/defaults/lockup/README.md +++ b/x/accounts/defaults/lockup/README.md @@ -1,5 +1,258 @@ -# x/accounts/lockup +# Lockup Accounts - -The x/accounts/lockup module provides the implementation for lockup accounts within the x/accounts module. +* [Lockup Account Types](#lockup-account-types) + * [BaseLockup](#baselockup) + * [ContinuousLockup](#continuouslockup) + * [DelayedLockup](#delayedlockup) + * [PeriodicLockup](#periodiclockup) + * [PermanentLocked](#permanentlocked) +* [Genesis Initialization](#genesis-initialization) +* [Examples](#examples) + * [Simple](#simple) + * [Slashing](#slashing) + * [Periodic Lockup](#periodic-lockup) + +The x/accounts/defaults/lockup module provides the implementation for lockup accounts within the x/accounts module. + +## Lockup Account Types + +### BaseLockup + +The base lockup account is used by all default lockup accounts. It contains the basic information for a lockup account. The Base lockup account keeps knowledge of the staking delegations from the account. + +```go +type BaseLockup struct { + // Owner is the address of the account owner. + Owner collections.Item[[]byte] + OriginalLocking collections.Map[string, math.Int] + DelegatedFree collections.Map[string, math.Int] + DelegatedLocking collections.Map[string, math.Int] + WithdrawedCoins collections.Map[string, math.Int] + addressCodec address.Codec + headerService header.Service + // lockup end time. + EndTime collections.Item[time.Time] +} +``` + +### ContinuousLockup + +The continuous lockup account has a future start time and begins unlocking continuously until the specified end date. + +To determine the amount of coins that are vested for a given block time `T`, the +following is performed: + +1. Compute `X := T - StartTime` +2. Compute `Y := EndTime - StartTime` +3. Compute `V' := OV * (X / Y)` +4. Compute `V := OV - V'` + +Thus, the total amount of _vested_ coins is `V'` and the remaining amount, `V`, +is _lockup_. + +```go +type ContinuousLockingAccount struct { + *BaseLockup + StartTime collections.Item[time.Time] +} +``` + +### DelayedLockup + +The delayed lockup account unlocks all tokens at a specific time. The account can receive coins and send coins. The account can be used to lock coins for a long period of time. + +```go +type DelayedLockingAccount struct { + *BaseLockup +} +``` + +### PeriodicLockup + +The periodic lockup account locks tokens for a series of periods. The account can receive coins and send coins. After all the periods, all the coins are unlocked and the account can send coins. + +Periodic lockup accounts require calculating the coins released during each period for a given block time `T`. Note that multiple periods could have passed when calling `GetVestedCoins`, so we must iterate over each period until the end of that period is after `T`. + +1. Set `CT := StartTime` +2. Set `V' := 0` + +For each Period P: + + 1. Compute `X := T - CT` + 2. IF `X >= P.Length` + 1. Compute `V' += P.Amount` + 2. Compute `CT += P.Length` + 3. ELSE break + 3. Compute `V := OV - V'` + +```go +type PeriodicLockingAccount struct { + *BaseLockup + StartTime collections.Item[time.Time] + LockingPeriods collections.Vec[lockuptypes.Period] +} +``` + +### PermanentLocked + +The permanent lockup account permanently locks the coins in the account. The account can only receive coins and cannot send coins. The account can be used to lock coins for a long period of time. + +```go +type PermanentLockingAccount struct { + *BaseLockup +} +``` + +## Genesis Initialization + + + +## Examples + +### Simple + +Given a continuous lockup account with 10 vested coins. + +```text +OV = 10 +DF = 0 +DV = 0 +BC = 10 +V = 10 +V' = 0 +``` + +1. Immediately receives 1 coin + + ```text + BC = 11 + ``` + +2. Time passes, 2 coins vest + + ```text + V = 8 + V' = 2 + ``` + +3. Delegates 4 coins to validator A + + ```text + DV = 4 + BC = 7 + ``` + +4. Sends 3 coins + + ```text + BC = 4 + ``` + +5. More time passes, 2 more coins vest + + ```text + V = 6 + V' = 4 + ``` + +6. Sends 2 coins. At this point, the account cannot send anymore until further +coins vest or it receives additional coins. It can still, however, delegate. + + ```text + BC = 2 + ``` + +### Slashing + +Same initial starting conditions as the simple example. + +1. Time passes, 5 coins vest + + ```text + V = 5 + V' = 5 + ``` + +2. Delegate 5 coins to validator A + + ```text + DV = 5 + BC = 5 + ``` + +3. Delegate 5 coins to validator B + + ```text + DF = 5 + BC = 0 + ``` + +4. Validator A gets slashed by 50%, making the delegation to A now worth 2.5 coins +5. Undelegate from validator A (2.5 coins) + + ```text + DF = 5 - 2.5 = 2.5 + BC = 0 + 2.5 = 2.5 + ``` + +6. Undelegate from validator B (5 coins). The account at this point can only +send 2.5 coins unless it receives more coins or until more coins vest. +It can still, however, delegate. + + ```text + DV = 5 - 2.5 = 2.5 + DF = 2.5 - 2.5 = 0 + BC = 2.5 + 5 = 7.5 + ``` + + Notice how we have an excess amount of `DV`. + +### Periodic Lockup + +A lockup account is created where 100 tokens will be released over 1 year, with +1/4 of tokens vesting each quarter. The lockup schedule would be as follows: + +```yaml +Periods: +- amount: 25stake, length: 7884000 +- amount: 25stake, length: 7884000 +- amount: 25stake, length: 7884000 +- amount: 25stake, length: 7884000 +``` + +```text +OV = 100 +DF = 0 +DV = 0 +BC = 100 +V = 100 +V' = 0 +``` + +1. Immediately receives 1 coin + + ```text + BC = 101 + ``` + +2. Lockup period 1 passes, 25 coins vest + + ```text + V = 75 + V' = 25 + ``` + +3. During lockup period 2, 5 coins are transferred and 5 coins are delegated + + ```text + DV = 5 + BC = 91 + ``` + +4. Lockup period 2 passes, 25 coins vest + + ```text + V = 50 + V' = 50 + ``` From a6871c74c35b1be31892bef370db5518fc31f3c9 Mon Sep 17 00:00:00 2001 From: son trinh Date: Sat, 27 Apr 2024 00:46:06 +0700 Subject: [PATCH 02/10] refactor(x/accounts): add sender assertions to SendModuleMessageUntyped (#20197) --- x/accounts/keeper.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/x/accounts/keeper.go b/x/accounts/keeper.go index d61faecf5098..68725959f193 100644 --- a/x/accounts/keeper.go +++ b/x/accounts/keeper.go @@ -324,6 +324,17 @@ func (k Keeper) sendAnyMessages(ctx context.Context, sender []byte, anyMessages // SendModuleMessageUntyped can be used to send a message towards a module. // It should be used when the response type is not known by the caller. func (k Keeper) SendModuleMessageUntyped(ctx context.Context, sender []byte, msg implementation.ProtoMsg) (implementation.ProtoMsg, error) { + // do sender assertions. + wantSenders, _, err := k.codec.GetMsgV1Signers(msg) + if err != nil { + return nil, fmt.Errorf("cannot get signers: %w", err) + } + if len(wantSenders) != 1 { + return nil, fmt.Errorf("expected only one signer, got %d", len(wantSenders)) + } + if !bytes.Equal(sender, wantSenders[0]) { + return nil, fmt.Errorf("%w: sender does not match expected sender", ErrUnauthorized) + } resp, err := k.RouterService.MessageRouterService().InvokeUntyped(ctx, msg) if err != nil { return nil, err From 6828584424d0f1b3e2843dd23d9b9311bcbdeede Mon Sep 17 00:00:00 2001 From: Qt Date: Sun, 28 Apr 2024 13:26:56 +0800 Subject: [PATCH 03/10] refactor(baseapp): when the capacity is determined, avoid memory copying (#20200) --- baseapp/baseapp.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 82f47d81b1c5..2726a36f080b 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -462,7 +462,7 @@ func (app *BaseApp) setTrace(trace bool) { } func (app *BaseApp) setIndexEvents(ie []string) { - app.indexEvents = make(map[string]struct{}) + app.indexEvents = make(map[string]struct{}, len(ie)) for _, e := range ie { app.indexEvents[e] = struct{}{} From 84712ede65623bed0bd414a082344f13cc7aecfe Mon Sep 17 00:00:00 2001 From: Hoa Nguyen Date: Sun, 28 Apr 2024 15:53:32 +0700 Subject: [PATCH 04/10] docs(x/circuit): fix broken link (#20201) --- x/circuit/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x/circuit/README.md b/x/circuit/README.md index 53752df32760..f0d2d5d8df20 100644 --- a/x/circuit/README.md +++ b/x/circuit/README.md @@ -101,7 +101,7 @@ Reset is called by an authorized account to enable execution for a specific msgU ### MsgAuthorizeCircuitBreaker ```protobuf reference -https://github.com/cosmos/cosmos-sdk/blob/main/proto/cosmos/circuit/v1/tx.proto#L25-L75 +https://github.com/cosmos/cosmos-sdk/blob/main/x/circuit/proto/cosmos/circuit/v1/tx.proto#L25-L40 ``` This message is expected to fail if: @@ -111,7 +111,7 @@ This message is expected to fail if: ### MsgTripCircuitBreaker ```protobuf reference -https://github.com/cosmos/cosmos-sdk/blob/main/proto/cosmos/circuit/v1/tx.proto#L77-L93 +https://github.com/cosmos/cosmos-sdk/blob/main/x/circuit/proto/cosmos/circuit/v1/tx.proto#L47-L60 ``` This message is expected to fail if: @@ -121,7 +121,7 @@ This message is expected to fail if: ### MsgResetCircuitBreaker ```protobuf reference -https://github.com/cosmos/cosmos-sdk/blob/main/proto/cosmos/circuit/v1/tx.proto#L95-109 +https://github.com/cosmos/cosmos-sdk/blob/main/x/circuit/proto/cosmos/circuit/v1/tx.proto#L67-L78 ``` This message is expected to fail if: From 92ae8850e1ff0ca6ff2e18f8fb9acf458e7f8f92 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Mon, 29 Apr 2024 01:13:40 -0700 Subject: [PATCH 05/10] perf: Make recheck not re-run validate basic (#20208) --- CHANGELOG.md | 1 + baseapp/baseapp.go | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5e0e8ac1799..b33db49d7cdf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -94,6 +94,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i * (x/genutil) [#19735](https://github.com/cosmos/cosmos-sdk/pull/19735) Update genesis api to match new `appmodule.HasGenesis` interface. * (server) [#19966](https://github.com/cosmos/cosmos-sdk/pull/19966) Return BlockHeader by shallow copy in server Context. * (proto) [#20098](https://github.com/cosmos/cosmos-sdk/pull/20098) Use cosmos_proto added_in annotation instead of // Since comments. +* (baseapp) [#20208](https://github.com/cosmos/cosmos-sdk/pull/20208) Skip running validateBasic for rechecking txs. ### Bug Fixes diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 2726a36f080b..f4cb145b273a 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -871,8 +871,12 @@ func (app *BaseApp) runTx(mode execMode, txBytes []byte) (gInfo sdk.GasInfo, res } msgs := tx.GetMsgs() - if err := validateBasicTxMsgs(app.msgServiceRouter, msgs); err != nil { - return sdk.GasInfo{}, nil, nil, err + // run validate basic if mode != recheck. + // as validate basic is stateless, it is guaranteed to pass recheck, given that its passed checkTx. + if mode != execModeReCheck { + if err := validateBasicTxMsgs(app.msgServiceRouter, msgs); err != nil { + return sdk.GasInfo{}, nil, nil, err + } } if app.anteHandler != nil { From cb50b4caa21868b5ecb9af2a9e5b1d8b267f5db8 Mon Sep 17 00:00:00 2001 From: son trinh Date: Mon, 29 Apr 2024 15:31:51 +0700 Subject: [PATCH 06/10] refactor(x/accounts/defaults/lockup): Clean up some logic (#20037) --- .github/workflows/test.yml | 8 - .../accounts/defaults/lockup/tx.pulsar.go | 748 +++++++++++++++--- .../lockup/continous_lockup_test_suite.go | 57 +- .../lockup/delayed_lockup_test_suite.go | 25 +- .../lockup/periodic_lockup_test_suite.go | 66 +- .../lockup/permanent_lockup_test_suite.go | 25 +- tests/e2e/accounts/lockup/utils.go | 21 + .../lockup/continuous_locking_account.go | 36 +- .../lockup/delayed_locking_account.go | 8 +- x/accounts/defaults/lockup/go.mod | 3 +- x/accounts/defaults/lockup/lockup.go | 261 +++--- x/accounts/defaults/lockup/lockup_test.go | 6 +- .../lockup/periodic_locking_account.go | 45 +- .../lockup/permanent_locking_account.go | 2 +- .../defaults/lockup/sonar-project.properties | 15 - x/accounts/defaults/lockup/types/tx.pb.go | 319 ++++++-- x/accounts/defaults/lockup/utils_test.go | 13 +- .../cosmos/accounts/defaults/lockup/tx.proto | 11 + 18 files changed, 1313 insertions(+), 356 deletions(-) delete mode 100644 x/accounts/defaults/lockup/sonar-project.properties diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b8e796d8d987..f99936eafda2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -722,14 +722,6 @@ jobs: run: | cd x/accounts/defaults/lockup go test -mod=readonly -timeout 30m -coverprofile=coverage.out -covermode=atomic -tags='norace ledger test_ledger_mock' ./... - - name: sonarcloud - if: ${{ env.GIT_DIFF && !github.event.pull_request.draft && env.SONAR_TOKEN != null }} - uses: SonarSource/sonarcloud-github-action@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - with: - projectBaseDir: x/accounts/defaults/lockup/ test-x-tx: runs-on: ubuntu-latest diff --git a/api/cosmos/accounts/defaults/lockup/tx.pulsar.go b/api/cosmos/accounts/defaults/lockup/tx.pulsar.go index 082db8883c5a..5483fe9c096b 100644 --- a/api/cosmos/accounts/defaults/lockup/tx.pulsar.go +++ b/api/cosmos/accounts/defaults/lockup/tx.pulsar.go @@ -3072,6 +3072,490 @@ func (x *fastReflection_MsgUndelegate) ProtoMethods() *protoiface.Methods { } } +var ( + md_MsgWithdrawReward protoreflect.MessageDescriptor + fd_MsgWithdrawReward_sender protoreflect.FieldDescriptor + fd_MsgWithdrawReward_validator_address protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_accounts_defaults_lockup_tx_proto_init() + md_MsgWithdrawReward = File_cosmos_accounts_defaults_lockup_tx_proto.Messages().ByName("MsgWithdrawReward") + fd_MsgWithdrawReward_sender = md_MsgWithdrawReward.Fields().ByName("sender") + fd_MsgWithdrawReward_validator_address = md_MsgWithdrawReward.Fields().ByName("validator_address") +} + +var _ protoreflect.Message = (*fastReflection_MsgWithdrawReward)(nil) + +type fastReflection_MsgWithdrawReward MsgWithdrawReward + +func (x *MsgWithdrawReward) ProtoReflect() protoreflect.Message { + return (*fastReflection_MsgWithdrawReward)(x) +} + +func (x *MsgWithdrawReward) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_MsgWithdrawReward_messageType fastReflection_MsgWithdrawReward_messageType +var _ protoreflect.MessageType = fastReflection_MsgWithdrawReward_messageType{} + +type fastReflection_MsgWithdrawReward_messageType struct{} + +func (x fastReflection_MsgWithdrawReward_messageType) Zero() protoreflect.Message { + return (*fastReflection_MsgWithdrawReward)(nil) +} +func (x fastReflection_MsgWithdrawReward_messageType) New() protoreflect.Message { + return new(fastReflection_MsgWithdrawReward) +} +func (x fastReflection_MsgWithdrawReward_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_MsgWithdrawReward +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_MsgWithdrawReward) Descriptor() protoreflect.MessageDescriptor { + return md_MsgWithdrawReward +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_MsgWithdrawReward) Type() protoreflect.MessageType { + return _fastReflection_MsgWithdrawReward_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_MsgWithdrawReward) New() protoreflect.Message { + return new(fastReflection_MsgWithdrawReward) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_MsgWithdrawReward) Interface() protoreflect.ProtoMessage { + return (*MsgWithdrawReward)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_MsgWithdrawReward) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Sender != "" { + value := protoreflect.ValueOfString(x.Sender) + if !f(fd_MsgWithdrawReward_sender, value) { + return + } + } + if x.ValidatorAddress != "" { + value := protoreflect.ValueOfString(x.ValidatorAddress) + if !f(fd_MsgWithdrawReward_validator_address, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_MsgWithdrawReward) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.sender": + return x.Sender != "" + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.validator_address": + return x.ValidatorAddress != "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.lockup.MsgWithdrawReward")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.lockup.MsgWithdrawReward does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgWithdrawReward) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.sender": + x.Sender = "" + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.validator_address": + x.ValidatorAddress = "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.lockup.MsgWithdrawReward")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.lockup.MsgWithdrawReward does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_MsgWithdrawReward) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.sender": + value := x.Sender + return protoreflect.ValueOfString(value) + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.validator_address": + value := x.ValidatorAddress + return protoreflect.ValueOfString(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.lockup.MsgWithdrawReward")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.lockup.MsgWithdrawReward does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgWithdrawReward) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.sender": + x.Sender = value.Interface().(string) + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.validator_address": + x.ValidatorAddress = value.Interface().(string) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.lockup.MsgWithdrawReward")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.lockup.MsgWithdrawReward does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgWithdrawReward) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.sender": + panic(fmt.Errorf("field sender of message cosmos.accounts.defaults.lockup.MsgWithdrawReward is not mutable")) + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.validator_address": + panic(fmt.Errorf("field validator_address of message cosmos.accounts.defaults.lockup.MsgWithdrawReward is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.lockup.MsgWithdrawReward")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.lockup.MsgWithdrawReward does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_MsgWithdrawReward) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.sender": + return protoreflect.ValueOfString("") + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.validator_address": + return protoreflect.ValueOfString("") + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.lockup.MsgWithdrawReward")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.lockup.MsgWithdrawReward does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_MsgWithdrawReward) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.accounts.defaults.lockup.MsgWithdrawReward", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_MsgWithdrawReward) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgWithdrawReward) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_MsgWithdrawReward) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_MsgWithdrawReward) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*MsgWithdrawReward) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.Sender) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.ValidatorAddress) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*MsgWithdrawReward) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.ValidatorAddress) > 0 { + i -= len(x.ValidatorAddress) + copy(dAtA[i:], x.ValidatorAddress) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ValidatorAddress))) + i-- + dAtA[i] = 0x12 + } + if len(x.Sender) > 0 { + i -= len(x.Sender) + copy(dAtA[i:], x.Sender) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Sender))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*MsgWithdrawReward) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgWithdrawReward: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgWithdrawReward: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.ValidatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + var _ protoreflect.List = (*_MsgSend_3_list)(nil) type _MsgSend_3_list struct { @@ -3147,7 +3631,7 @@ func (x *MsgSend) ProtoReflect() protoreflect.Message { } func (x *MsgSend) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[6] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3765,7 +4249,7 @@ func (x *MsgExecuteMessagesResponse) ProtoReflect() protoreflect.Message { } func (x *MsgExecuteMessagesResponse) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[7] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4258,7 +4742,7 @@ func (x *MsgWithdraw) ProtoReflect() protoreflect.Message { } func (x *MsgWithdraw) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[8] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4869,7 +5353,7 @@ func (x *MsgWithdrawResponse) ProtoReflect() protoreflect.Message { } func (x *MsgWithdrawResponse) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[9] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -5638,6 +6122,50 @@ func (x *MsgUndelegate) GetAmount() *v1beta1.Coin { return nil } +// MsgWithdrawReward defines a message that enable lockup account to execute withdraw reward message +type MsgWithdrawReward struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` +} + +func (x *MsgWithdrawReward) Reset() { + *x = MsgWithdrawReward{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MsgWithdrawReward) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MsgWithdrawReward) ProtoMessage() {} + +// Deprecated: Use MsgWithdrawReward.ProtoReflect.Descriptor instead. +func (*MsgWithdrawReward) Descriptor() ([]byte, []int) { + return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{6} +} + +func (x *MsgWithdrawReward) GetSender() string { + if x != nil { + return x.Sender + } + return "" +} + +func (x *MsgWithdrawReward) GetValidatorAddress() string { + if x != nil { + return x.ValidatorAddress + } + return "" +} + // MsgSend defines a message that enable lockup account to execute send message type MsgSend struct { state protoimpl.MessageState @@ -5652,7 +6180,7 @@ type MsgSend struct { func (x *MsgSend) Reset() { *x = MsgSend{} if protoimpl.UnsafeEnabled { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[6] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -5666,7 +6194,7 @@ func (*MsgSend) ProtoMessage() {} // Deprecated: Use MsgSend.ProtoReflect.Descriptor instead. func (*MsgSend) Descriptor() ([]byte, []int) { - return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{6} + return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{7} } func (x *MsgSend) GetSender() string { @@ -5702,7 +6230,7 @@ type MsgExecuteMessagesResponse struct { func (x *MsgExecuteMessagesResponse) Reset() { *x = MsgExecuteMessagesResponse{} if protoimpl.UnsafeEnabled { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[7] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -5716,7 +6244,7 @@ func (*MsgExecuteMessagesResponse) ProtoMessage() {} // Deprecated: Use MsgExecuteMessagesResponse.ProtoReflect.Descriptor instead. func (*MsgExecuteMessagesResponse) Descriptor() ([]byte, []int) { - return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{7} + return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{8} } func (x *MsgExecuteMessagesResponse) GetResponses() []*anypb.Any { @@ -5741,7 +6269,7 @@ type MsgWithdraw struct { func (x *MsgWithdraw) Reset() { *x = MsgWithdraw{} if protoimpl.UnsafeEnabled { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[8] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -5755,7 +6283,7 @@ func (*MsgWithdraw) ProtoMessage() {} // Deprecated: Use MsgWithdraw.ProtoReflect.Descriptor instead. func (*MsgWithdraw) Descriptor() ([]byte, []int) { - return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{8} + return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{9} } func (x *MsgWithdraw) GetWithdrawer() string { @@ -5792,7 +6320,7 @@ type MsgWithdrawResponse struct { func (x *MsgWithdrawResponse) Reset() { *x = MsgWithdrawResponse{} if protoimpl.UnsafeEnabled { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[9] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -5806,7 +6334,7 @@ func (*MsgWithdrawResponse) ProtoMessage() {} // Deprecated: Use MsgWithdrawResponse.ProtoReflect.Descriptor instead. func (*MsgWithdrawResponse) Descriptor() ([]byte, []int) { - return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{9} + return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{10} } func (x *MsgWithdrawResponse) GetReceiver() string { @@ -5913,70 +6441,81 @@ var file_cosmos_accounts_defaults_lockup_tx_proto_rawDesc = []byte{ 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x09, 0xc8, 0xde, 0x1f, 0x00, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x3a, 0x13, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x82, 0xe7, 0xb0, 0x2a, 0x06, 0x73, 0x65, 0x6e, - 0x64, 0x65, 0x72, 0x22, 0x84, 0x02, 0x0a, 0x07, 0x4d, 0x73, 0x67, 0x53, 0x65, 0x6e, 0x64, 0x12, - 0x30, 0x0a, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, - 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, - 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, - 0x72, 0x12, 0x37, 0x0a, 0x0a, 0x74, 0x6f, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, - 0x09, 0x74, 0x6f, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x79, 0x0a, 0x06, 0x61, 0x6d, - 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, - 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x46, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, - 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x9a, 0xe7, 0xb0, 0x2a, 0x0c, 0x6c, 0x65, 0x67, 0x61, - 0x63, 0x79, 0x5f, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x61, - 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x3a, 0x13, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x82, - 0xe7, 0xb0, 0x2a, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x22, 0x50, 0x0a, 0x1a, 0x4d, 0x73, - 0x67, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, - 0x79, 0x52, 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x22, 0xb1, 0x01, 0x0a, - 0x0b, 0x4d, 0x73, 0x67, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x12, 0x38, 0x0a, 0x0a, - 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x0a, 0x77, 0x69, 0x74, 0x68, - 0x64, 0x72, 0x61, 0x77, 0x65, 0x72, 0x12, 0x37, 0x0a, 0x0a, 0x74, 0x6f, 0x5f, 0x61, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, - 0x72, 0x69, 0x6e, 0x67, 0x52, 0x09, 0x74, 0x6f, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, - 0x16, 0x0a, 0x06, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, - 0x06, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x73, 0x3a, 0x17, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, - 0x00, 0x82, 0xe7, 0xb0, 0x2a, 0x0a, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x65, 0x72, - 0x22, 0xd8, 0x01, 0x0a, 0x13, 0x4d, 0x73, 0x67, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x34, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x65, - 0x69, 0x76, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, - 0x72, 0x69, 0x6e, 0x67, 0x52, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x72, 0x12, 0x8a, - 0x01, 0x0a, 0x0f, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, - 0x65, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, - 0x6f, 0x69, 0x6e, 0x42, 0x46, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, - 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x9a, 0xe7, 0xb0, 0x2a, 0x0c, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, - 0x5f, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x0e, 0x61, 0x6d, 0x6f, - 0x75, 0x6e, 0x74, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x42, 0x80, 0x02, 0x0a, 0x23, - 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x73, 0x2e, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2e, 0x6c, 0x6f, 0x63, - 0x6b, 0x75, 0x70, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, - 0x2f, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2f, 0x6c, 0x6f, 0x63, 0x6b, 0x75, 0x70, - 0xa2, 0x02, 0x04, 0x43, 0x41, 0x44, 0x4c, 0xaa, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, - 0x74, 0x73, 0x2e, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0xca, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x44, 0x65, 0x66, 0x61, - 0x75, 0x6c, 0x74, 0x73, 0x5c, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0xe2, 0x02, 0x2b, 0x43, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x44, 0x65, - 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x5c, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0x5c, 0x47, 0x50, - 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x22, 0x43, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x3a, 0x3a, 0x44, 0x65, - 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x3a, 0x3a, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x64, 0x65, 0x72, 0x22, 0xaa, 0x01, 0x0a, 0x11, 0x4d, 0x73, 0x67, 0x57, 0x69, 0x74, 0x68, 0x64, + 0x72, 0x61, 0x77, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x12, 0x30, 0x0a, 0x06, 0x73, 0x65, 0x6e, + 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, + 0x69, 0x6e, 0x67, 0x52, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x12, 0x4e, 0x0a, 0x11, 0x76, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x21, 0xd2, 0xb4, 0x2d, 0x1d, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x41, 0x64, 0x64, 0x72, + 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x10, 0x76, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x6f, 0x72, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x3a, 0x13, 0x88, 0xa0, 0x1f, + 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x82, 0xe7, 0xb0, 0x2a, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, + 0x22, 0x84, 0x02, 0x0a, 0x07, 0x4d, 0x73, 0x67, 0x53, 0x65, 0x6e, 0x64, 0x12, 0x30, 0x0a, 0x06, + 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, + 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, + 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x12, 0x37, + 0x0a, 0x0a, 0x74, 0x6f, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x09, 0x74, 0x6f, + 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x79, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, + 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, + 0x69, 0x6e, 0x42, 0x46, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, + 0x6f, 0x69, 0x6e, 0x73, 0x9a, 0xe7, 0xb0, 0x2a, 0x0c, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x5f, + 0x63, 0x6f, 0x69, 0x6e, 0x73, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, + 0x6e, 0x74, 0x3a, 0x13, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x82, 0xe7, 0xb0, 0x2a, + 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x22, 0x50, 0x0a, 0x1a, 0x4d, 0x73, 0x67, 0x45, 0x78, + 0x65, 0x63, 0x75, 0x74, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x09, + 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x22, 0xb1, 0x01, 0x0a, 0x0b, 0x4d, 0x73, + 0x67, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x12, 0x38, 0x0a, 0x0a, 0x77, 0x69, 0x74, + 0x68, 0x64, 0x72, 0x61, 0x77, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, + 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x0a, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, + 0x77, 0x65, 0x72, 0x12, 0x37, 0x0a, 0x0a, 0x74, 0x6f, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, + 0x67, 0x52, 0x09, 0x74, 0x6f, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x16, 0x0a, 0x06, + 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x64, 0x65, + 0x6e, 0x6f, 0x6d, 0x73, 0x3a, 0x17, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x82, 0xe7, + 0xb0, 0x2a, 0x0a, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x65, 0x72, 0x22, 0xd8, 0x01, + 0x0a, 0x13, 0x4d, 0x73, 0x67, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x34, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, + 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, + 0x67, 0x52, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x72, 0x12, 0x8a, 0x01, 0x0a, 0x0f, + 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, + 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, + 0x42, 0x46, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, + 0x6e, 0x73, 0x9a, 0xe7, 0xb0, 0x2a, 0x0c, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x5f, 0x63, 0x6f, + 0x69, 0x6e, 0x73, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x0e, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, + 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x42, 0x80, 0x02, 0x0a, 0x23, 0x63, 0x6f, 0x6d, + 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, + 0x2e, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2e, 0x6c, 0x6f, 0x63, 0x6b, 0x75, 0x70, + 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x64, 0x65, + 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2f, 0x6c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0xa2, 0x02, 0x04, + 0x43, 0x41, 0x44, 0x4c, 0xaa, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2e, + 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0xca, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, + 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, + 0x73, 0x5c, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0xe2, 0x02, 0x2b, 0x43, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x44, 0x65, 0x66, 0x61, 0x75, + 0x6c, 0x74, 0x73, 0x5c, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x22, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, + 0x3a, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x3a, 0x3a, 0x44, 0x65, 0x66, 0x61, 0x75, + 0x6c, 0x74, 0x73, 0x3a, 0x3a, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -5991,7 +6530,7 @@ func file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP() []byte { return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescData } -var file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 11) var file_cosmos_accounts_defaults_lockup_tx_proto_goTypes = []interface{}{ (*MsgInitLockupAccount)(nil), // 0: cosmos.accounts.defaults.lockup.MsgInitLockupAccount (*MsgInitLockupAccountResponse)(nil), // 1: cosmos.accounts.defaults.lockup.MsgInitLockupAccountResponse @@ -5999,25 +6538,26 @@ var file_cosmos_accounts_defaults_lockup_tx_proto_goTypes = []interface{}{ (*MsgInitPeriodicLockingAccountResponse)(nil), // 3: cosmos.accounts.defaults.lockup.MsgInitPeriodicLockingAccountResponse (*MsgDelegate)(nil), // 4: cosmos.accounts.defaults.lockup.MsgDelegate (*MsgUndelegate)(nil), // 5: cosmos.accounts.defaults.lockup.MsgUndelegate - (*MsgSend)(nil), // 6: cosmos.accounts.defaults.lockup.MsgSend - (*MsgExecuteMessagesResponse)(nil), // 7: cosmos.accounts.defaults.lockup.MsgExecuteMessagesResponse - (*MsgWithdraw)(nil), // 8: cosmos.accounts.defaults.lockup.MsgWithdraw - (*MsgWithdrawResponse)(nil), // 9: cosmos.accounts.defaults.lockup.MsgWithdrawResponse - (*timestamppb.Timestamp)(nil), // 10: google.protobuf.Timestamp - (*Period)(nil), // 11: cosmos.accounts.defaults.lockup.Period - (*v1beta1.Coin)(nil), // 12: cosmos.base.v1beta1.Coin - (*anypb.Any)(nil), // 13: google.protobuf.Any + (*MsgWithdrawReward)(nil), // 6: cosmos.accounts.defaults.lockup.MsgWithdrawReward + (*MsgSend)(nil), // 7: cosmos.accounts.defaults.lockup.MsgSend + (*MsgExecuteMessagesResponse)(nil), // 8: cosmos.accounts.defaults.lockup.MsgExecuteMessagesResponse + (*MsgWithdraw)(nil), // 9: cosmos.accounts.defaults.lockup.MsgWithdraw + (*MsgWithdrawResponse)(nil), // 10: cosmos.accounts.defaults.lockup.MsgWithdrawResponse + (*timestamppb.Timestamp)(nil), // 11: google.protobuf.Timestamp + (*Period)(nil), // 12: cosmos.accounts.defaults.lockup.Period + (*v1beta1.Coin)(nil), // 13: cosmos.base.v1beta1.Coin + (*anypb.Any)(nil), // 14: google.protobuf.Any } var file_cosmos_accounts_defaults_lockup_tx_proto_depIdxs = []int32{ - 10, // 0: cosmos.accounts.defaults.lockup.MsgInitLockupAccount.end_time:type_name -> google.protobuf.Timestamp - 10, // 1: cosmos.accounts.defaults.lockup.MsgInitLockupAccount.start_time:type_name -> google.protobuf.Timestamp - 10, // 2: cosmos.accounts.defaults.lockup.MsgInitPeriodicLockingAccount.start_time:type_name -> google.protobuf.Timestamp - 11, // 3: cosmos.accounts.defaults.lockup.MsgInitPeriodicLockingAccount.locking_periods:type_name -> cosmos.accounts.defaults.lockup.Period - 12, // 4: cosmos.accounts.defaults.lockup.MsgDelegate.amount:type_name -> cosmos.base.v1beta1.Coin - 12, // 5: cosmos.accounts.defaults.lockup.MsgUndelegate.amount:type_name -> cosmos.base.v1beta1.Coin - 12, // 6: cosmos.accounts.defaults.lockup.MsgSend.amount:type_name -> cosmos.base.v1beta1.Coin - 13, // 7: cosmos.accounts.defaults.lockup.MsgExecuteMessagesResponse.responses:type_name -> google.protobuf.Any - 12, // 8: cosmos.accounts.defaults.lockup.MsgWithdrawResponse.amount_received:type_name -> cosmos.base.v1beta1.Coin + 11, // 0: cosmos.accounts.defaults.lockup.MsgInitLockupAccount.end_time:type_name -> google.protobuf.Timestamp + 11, // 1: cosmos.accounts.defaults.lockup.MsgInitLockupAccount.start_time:type_name -> google.protobuf.Timestamp + 11, // 2: cosmos.accounts.defaults.lockup.MsgInitPeriodicLockingAccount.start_time:type_name -> google.protobuf.Timestamp + 12, // 3: cosmos.accounts.defaults.lockup.MsgInitPeriodicLockingAccount.locking_periods:type_name -> cosmos.accounts.defaults.lockup.Period + 13, // 4: cosmos.accounts.defaults.lockup.MsgDelegate.amount:type_name -> cosmos.base.v1beta1.Coin + 13, // 5: cosmos.accounts.defaults.lockup.MsgUndelegate.amount:type_name -> cosmos.base.v1beta1.Coin + 13, // 6: cosmos.accounts.defaults.lockup.MsgSend.amount:type_name -> cosmos.base.v1beta1.Coin + 14, // 7: cosmos.accounts.defaults.lockup.MsgExecuteMessagesResponse.responses:type_name -> google.protobuf.Any + 13, // 8: cosmos.accounts.defaults.lockup.MsgWithdrawResponse.amount_received:type_name -> cosmos.base.v1beta1.Coin 9, // [9:9] is the sub-list for method output_type 9, // [9:9] is the sub-list for method input_type 9, // [9:9] is the sub-list for extension type_name @@ -6105,7 +6645,7 @@ func file_cosmos_accounts_defaults_lockup_tx_proto_init() { } } file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MsgSend); i { + switch v := v.(*MsgWithdrawReward); i { case 0: return &v.state case 1: @@ -6117,7 +6657,7 @@ func file_cosmos_accounts_defaults_lockup_tx_proto_init() { } } file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MsgExecuteMessagesResponse); i { + switch v := v.(*MsgSend); i { case 0: return &v.state case 1: @@ -6129,7 +6669,7 @@ func file_cosmos_accounts_defaults_lockup_tx_proto_init() { } } file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MsgWithdraw); i { + switch v := v.(*MsgExecuteMessagesResponse); i { case 0: return &v.state case 1: @@ -6141,6 +6681,18 @@ func file_cosmos_accounts_defaults_lockup_tx_proto_init() { } } file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MsgWithdraw); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*MsgWithdrawResponse); i { case 0: return &v.state @@ -6159,7 +6711,7 @@ func file_cosmos_accounts_defaults_lockup_tx_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_cosmos_accounts_defaults_lockup_tx_proto_rawDesc, NumEnums: 0, - NumMessages: 10, + NumMessages: 11, NumExtensions: 0, NumServices: 0, }, diff --git a/tests/e2e/accounts/lockup/continous_lockup_test_suite.go b/tests/e2e/accounts/lockup/continous_lockup_test_suite.go index 36749f7f4105..e331579cb6c4 100644 --- a/tests/e2e/accounts/lockup/continous_lockup_test_suite.go +++ b/tests/e2e/accounts/lockup/continous_lockup_test_suite.go @@ -40,6 +40,10 @@ func (s *E2ETestSuite) TestContinuousLockingAccount() { addr, err := app.AuthKeeper.AddressCodec().BytesToString(randAcc) require.NoError(t, err) + vals, err := app.StakingKeeper.GetAllValidators(ctx) + require.NoError(t, err) + val := vals[0] + t.Run("error - execute message, wrong sender", func(t *testing.T) { msg := &types.MsgSend{ Sender: addr, @@ -109,9 +113,6 @@ func (s *E2ETestSuite) TestContinuousLockingAccount() { require.True(t, balance.Amount.Equal(math.NewInt(100))) }) t.Run("ok - execute delegate message", func(t *testing.T) { - vals, err := app.StakingKeeper.GetAllValidators(ctx) - require.NoError(t, err) - val := vals[0] msg := &types.MsgDelegate{ Sender: ownerAddrStr, ValidatorAddress: val.OperatorAddress, @@ -128,6 +129,19 @@ func (s *E2ETestSuite) TestContinuousLockingAccount() { ) require.NoError(t, err) require.NotNil(t, del) + + // check if tracking is updated accordingly + lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr) + delLocking := lockupAccountInfoResponse.DelegatedLocking + require.True(t, delLocking.AmountOf("stake").Equal(math.NewInt(100))) + }) + t.Run("ok - execute withdraw reward message", func(t *testing.T) { + msg := &types.MsgWithdrawReward{ + Sender: ownerAddrStr, + ValidatorAddress: val.OperatorAddress, + } + err = s.executeTx(ctx, msg, app, accountAddr, accOwner) + require.NoError(t, err) }) t.Run("ok - execute undelegate message", func(t *testing.T) { vals, err := app.StakingKeeper.GetAllValidators(ctx) @@ -148,5 +162,42 @@ func (s *E2ETestSuite) TestContinuousLockingAccount() { ) require.NoError(t, err) require.Equal(t, len(ubd.Entries), 1) + + // check if tracking is updated accordingly + lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr) + delLocking := lockupAccountInfoResponse.DelegatedLocking + require.True(t, delLocking.AmountOf("stake").Equal(math.ZeroInt())) + }) + + // Update context time to end time + ctx = ctx.WithHeaderInfo(header.Info{ + Time: currentTime.Add(time.Minute), + }) + + // test if tracking delegate work perfectly + t.Run("ok - execute delegate message", func(t *testing.T) { + msg := &types.MsgDelegate{ + Sender: ownerAddrStr, + ValidatorAddress: val.OperatorAddress, + Amount: sdk.NewCoin("stake", math.NewInt(100)), + } + err = s.executeTx(ctx, msg, app, accountAddr, accOwner) + require.NoError(t, err) + + valbz, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.OperatorAddress) + require.NoError(t, err) + + del, err := app.StakingKeeper.Delegations.Get( + ctx, collections.Join(sdk.AccAddress(accountAddr), sdk.ValAddress(valbz)), + ) + require.NoError(t, err) + require.NotNil(t, del) + + // check if tracking is updated accordingly + lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr) + delLocking := lockupAccountInfoResponse.DelegatedLocking + require.True(t, delLocking.AmountOf("stake").Equal(math.ZeroInt())) + delFree := lockupAccountInfoResponse.DelegatedFree + require.True(t, delFree.AmountOf("stake").Equal(math.NewInt(100))) }) } diff --git a/tests/e2e/accounts/lockup/delayed_lockup_test_suite.go b/tests/e2e/accounts/lockup/delayed_lockup_test_suite.go index 73254b7f3b3c..1b5a8784eeb7 100644 --- a/tests/e2e/accounts/lockup/delayed_lockup_test_suite.go +++ b/tests/e2e/accounts/lockup/delayed_lockup_test_suite.go @@ -39,6 +39,10 @@ func (s *E2ETestSuite) TestDelayedLockingAccount() { addr, err := app.AuthKeeper.AddressCodec().BytesToString(randAcc) require.NoError(t, err) + vals, err := app.StakingKeeper.GetAllValidators(ctx) + require.NoError(t, err) + val := vals[0] + t.Run("error - execute message, wrong sender", func(t *testing.T) { msg := &types.MsgSend{ Sender: addr, @@ -71,9 +75,6 @@ func (s *E2ETestSuite) TestDelayedLockingAccount() { require.NotNil(t, err) }) t.Run("ok - execute delegate message", func(t *testing.T) { - vals, err := app.StakingKeeper.GetAllValidators(ctx) - require.NoError(t, err) - val := vals[0] msg := &types.MsgDelegate{ Sender: ownerAddrStr, ValidatorAddress: val.OperatorAddress, @@ -90,6 +91,19 @@ func (s *E2ETestSuite) TestDelayedLockingAccount() { ) require.NoError(t, err) require.NotNil(t, del) + + // check if tracking is updated accordingly + lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr) + delLocking := lockupAccountInfoResponse.DelegatedLocking + require.True(t, delLocking.AmountOf("stake").Equal(math.NewInt(100))) + }) + t.Run("ok - execute withdraw reward message", func(t *testing.T) { + msg := &types.MsgWithdrawReward{ + Sender: ownerAddrStr, + ValidatorAddress: val.OperatorAddress, + } + err = s.executeTx(ctx, msg, app, accountAddr, accOwner) + require.NoError(t, err) }) t.Run("ok - execute undelegate message", func(t *testing.T) { vals, err := app.StakingKeeper.GetAllValidators(ctx) @@ -110,6 +124,11 @@ func (s *E2ETestSuite) TestDelayedLockingAccount() { ) require.NoError(t, err) require.Equal(t, len(ubd.Entries), 1) + + // check if tracking is updated accordingly + lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr) + delLocking := lockupAccountInfoResponse.DelegatedLocking + require.True(t, delLocking.AmountOf("stake").Equal(math.ZeroInt())) }) // Update context time diff --git a/tests/e2e/accounts/lockup/periodic_lockup_test_suite.go b/tests/e2e/accounts/lockup/periodic_lockup_test_suite.go index 11647e7c94cf..33be5172452d 100644 --- a/tests/e2e/accounts/lockup/periodic_lockup_test_suite.go +++ b/tests/e2e/accounts/lockup/periodic_lockup_test_suite.go @@ -1,6 +1,7 @@ package lockup import ( + "fmt" "testing" "time" @@ -40,13 +41,21 @@ func (s *E2ETestSuite) TestPeriodicLockingAccount() { Amount: sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(500))), Length: time.Minute, }, + { + Amount: sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(500))), + Length: time.Minute, + }, }, - }, sdk.Coins{sdk.NewCoin("stake", math.NewInt(1000))}) + }, sdk.Coins{sdk.NewCoin("stake", math.NewInt(1500))}) require.NoError(t, err) addr, err := app.AuthKeeper.AddressCodec().BytesToString(randAcc) require.NoError(t, err) + vals, err := app.StakingKeeper.GetAllValidators(ctx) + require.NoError(t, err) + val := vals[0] + t.Run("error - execute message, wrong sender", func(t *testing.T) { msg := &types.MsgSend{ Sender: addr, @@ -125,13 +134,7 @@ func (s *E2ETestSuite) TestPeriodicLockingAccount() { require.True(t, balance.Amount.Equal(math.NewInt(500))) }) - // Fund acc since we withdraw all the funds - s.fundAccount(app, ctx, accountAddr, sdk.Coins{sdk.NewCoin("stake", math.NewInt(100))}) - t.Run("ok - execute delegate message", func(t *testing.T) { - vals, err := app.StakingKeeper.GetAllValidators(ctx) - require.NoError(t, err) - val := vals[0] msg := &types.MsgDelegate{ Sender: ownerAddrStr, ValidatorAddress: val.OperatorAddress, @@ -148,6 +151,20 @@ func (s *E2ETestSuite) TestPeriodicLockingAccount() { ) require.NoError(t, err) require.NotNil(t, del) + + // check if tracking is updated accordingly + lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr) + fmt.Println(lockupAccountInfoResponse) + delLocking := lockupAccountInfoResponse.DelegatedLocking + require.True(t, delLocking.AmountOf("stake").Equal(math.NewInt(100))) + }) + t.Run("ok - execute withdraw reward message", func(t *testing.T) { + msg := &types.MsgWithdrawReward{ + Sender: ownerAddrStr, + ValidatorAddress: val.OperatorAddress, + } + err = s.executeTx(ctx, msg, app, accountAddr, accOwner) + require.NoError(t, err) }) t.Run("ok - execute undelegate message", func(t *testing.T) { vals, err := app.StakingKeeper.GetAllValidators(ctx) @@ -168,5 +185,40 @@ func (s *E2ETestSuite) TestPeriodicLockingAccount() { ) require.NoError(t, err) require.Equal(t, len(ubd.Entries), 1) + + // check if tracking is updated accordingly + lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr) + delLocking := lockupAccountInfoResponse.DelegatedLocking + require.True(t, delLocking.AmountOf("stake").Equal(math.ZeroInt())) + }) + + // Update context time + // After third period 1500stake should be unlock + ctx = ctx.WithHeaderInfo(header.Info{ + Time: currentTime.Add(time.Minute * 3), + }) + + t.Run("ok - execute delegate message", func(t *testing.T) { + msg := &types.MsgDelegate{ + Sender: ownerAddrStr, + ValidatorAddress: val.OperatorAddress, + Amount: sdk.NewCoin("stake", math.NewInt(100)), + } + err = s.executeTx(ctx, msg, app, accountAddr, accOwner) + require.NoError(t, err) + + valbz, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.OperatorAddress) + require.NoError(t, err) + + del, err := app.StakingKeeper.Delegations.Get( + ctx, collections.Join(sdk.AccAddress(accountAddr), sdk.ValAddress(valbz)), + ) + require.NoError(t, err) + require.NotNil(t, del) + + // check if tracking is updated accordingly + lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr) + delFree := lockupAccountInfoResponse.DelegatedFree + require.True(t, delFree.AmountOf("stake").Equal(math.NewInt(100))) }) } diff --git a/tests/e2e/accounts/lockup/permanent_lockup_test_suite.go b/tests/e2e/accounts/lockup/permanent_lockup_test_suite.go index a376f018865d..2ddec4ddf30b 100644 --- a/tests/e2e/accounts/lockup/permanent_lockup_test_suite.go +++ b/tests/e2e/accounts/lockup/permanent_lockup_test_suite.go @@ -36,6 +36,10 @@ func (s *E2ETestSuite) TestPermanentLockingAccount() { addr, err := app.AuthKeeper.AddressCodec().BytesToString(randAcc) require.NoError(t, err) + vals, err := app.StakingKeeper.GetAllValidators(ctx) + require.NoError(t, err) + val := vals[0] + t.Run("error - execute message, wrong sender", func(t *testing.T) { msg := &types.MsgSend{ Sender: addr, @@ -55,9 +59,6 @@ func (s *E2ETestSuite) TestPermanentLockingAccount() { require.NotNil(t, err) }) t.Run("ok - execute delegate message", func(t *testing.T) { - vals, err := app.StakingKeeper.GetAllValidators(ctx) - require.NoError(t, err) - val := vals[0] msg := &types.MsgDelegate{ Sender: ownerAddrStr, ValidatorAddress: val.OperatorAddress, @@ -74,6 +75,19 @@ func (s *E2ETestSuite) TestPermanentLockingAccount() { ) require.NoError(t, err) require.NotNil(t, del) + + // check if tracking is updated accordingly + lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr) + delLocking := lockupAccountInfoResponse.DelegatedLocking + require.True(t, delLocking.AmountOf("stake").Equal(math.NewInt(100))) + }) + t.Run("ok - execute withdraw reward message", func(t *testing.T) { + msg := &types.MsgWithdrawReward{ + Sender: ownerAddrStr, + ValidatorAddress: val.OperatorAddress, + } + err = s.executeTx(ctx, msg, app, accountAddr, accOwner) + require.NoError(t, err) }) t.Run("ok - execute undelegate message", func(t *testing.T) { vals, err := app.StakingKeeper.GetAllValidators(ctx) @@ -94,6 +108,11 @@ func (s *E2ETestSuite) TestPermanentLockingAccount() { ) require.NoError(t, err) require.Equal(t, len(ubd.Entries), 1) + + // check if tracking is updated accordingly + lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr) + delLocking := lockupAccountInfoResponse.DelegatedLocking + require.True(t, delLocking.AmountOf("stake").Equal(math.ZeroInt())) }) s.fundAccount(app, ctx, accountAddr, sdk.Coins{sdk.NewCoin("stake", math.NewInt(1000))}) diff --git a/tests/e2e/accounts/lockup/utils.go b/tests/e2e/accounts/lockup/utils.go index d486b33d38e1..f636459dd066 100644 --- a/tests/e2e/accounts/lockup/utils.go +++ b/tests/e2e/accounts/lockup/utils.go @@ -5,14 +5,18 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + "google.golang.org/protobuf/runtime/protoiface" "cosmossdk.io/simapp" + "cosmossdk.io/x/accounts/defaults/lockup/types" "cosmossdk.io/x/bank/testutil" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" sdk "github.com/cosmos/cosmos-sdk/types" ) +type ProtoMsg = protoiface.MessageV1 + var ( ownerAddr = secp256k1.GenPrivKey().PubKey().Address() accOwner = sdk.AccAddress(ownerAddr) @@ -48,6 +52,23 @@ func (s *E2ETestSuite) executeTx(ctx sdk.Context, msg sdk.Msg, app *simapp.SimAp return err } +func (s *E2ETestSuite) queryAcc(ctx sdk.Context, req sdk.Msg, app *simapp.SimApp, accAddr []byte) (ProtoMsg, error) { + resp, err := app.AccountsKeeper.Query(ctx, accAddr, req) + return resp, err +} + func (s *E2ETestSuite) fundAccount(app *simapp.SimApp, ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) { require.NoError(s.T(), testutil.FundAccount(ctx, app.BankKeeper, addr, amt)) } + +func (s *E2ETestSuite) queryLockupAccInfo(t *testing.T, ctx sdk.Context, app *simapp.SimApp, accAddr []byte) *types.QueryLockupAccountInfoResponse { + req := &types.QueryLockupAccountInfoRequest{} + resp, err := s.queryAcc(ctx, req, app, accAddr) + require.NoError(t, err) + require.NotNil(t, resp) + + lockupAccountInfoResponse, ok := resp.(*types.QueryLockupAccountInfoResponse) + require.True(t, ok) + + return lockupAccountInfoResponse +} diff --git a/x/accounts/defaults/lockup/continuous_locking_account.go b/x/accounts/defaults/lockup/continuous_locking_account.go index aa705aa4c7e4..c90b909cf6cf 100644 --- a/x/accounts/defaults/lockup/continuous_locking_account.go +++ b/x/accounts/defaults/lockup/continuous_locking_account.go @@ -41,7 +41,7 @@ func (cva ContinuousLockingAccount) Init(ctx context.Context, msg *lockuptypes.M return nil, sdkerrors.ErrInvalidRequest.Wrapf("invalid end time %s", msg.EndTime.String()) } - if msg.EndTime.Before(msg.StartTime) || msg.EndTime.Equal(msg.StartTime) { + if !msg.EndTime.After(msg.StartTime) { return nil, sdkerrors.ErrInvalidRequest.Wrap("invalid start and end time (must be start before end)") } @@ -66,12 +66,6 @@ func (cva *ContinuousLockingAccount) Delegate(ctx context.Context, msg *lockupty return cva.BaseLockup.Delegate(ctx, msg, cva.GetLockedCoinsWithDenoms) } -func (cva *ContinuousLockingAccount) Undelegate(ctx context.Context, msg *lockuptypes.MsgUndelegate) ( - *lockuptypes.MsgExecuteMessagesResponse, error, -) { - return cva.BaseLockup.Undelegate(ctx, msg) -} - func (cva *ContinuousLockingAccount) SendCoins(ctx context.Context, msg *lockuptypes.MsgSend) ( *lockuptypes.MsgExecuteMessagesResponse, error, ) { @@ -89,36 +83,20 @@ func (cva ContinuousLockingAccount) GetLockCoinsInfo(ctx context.Context, blockT unlockedCoins = sdk.Coins{} lockedCoins = sdk.Coins{} - // We must handle the case where the start time for a lockup account has - // been set into the future or when the start of the chain is not exactly - // known. - startTime, err := cva.StartTime.Get(ctx) - if err != nil { - return nil, nil, err - } - endTime, err := cva.EndTime.Get(ctx) - if err != nil { - return nil, nil, err - } - var originalVesting sdk.Coins + var originalLocking sdk.Coins err = cva.IterateCoinEntries(ctx, cva.OriginalLocking, func(key string, value math.Int) (stop bool, err error) { - originalVesting = append(originalVesting, sdk.NewCoin(key, value)) - vestedCoin, vestingCoin, err := cva.GetLockCoinInfoWithDenom(ctx, blockTime, key) + originalLocking = append(originalLocking, sdk.NewCoin(key, value)) + unlockedCoin, lockedCoin, err := cva.GetLockCoinInfoWithDenom(ctx, blockTime, key) if err != nil { return true, err } - unlockedCoins = append(unlockedCoins, *vestedCoin) - lockedCoins = append(lockedCoins, *vestingCoin) + unlockedCoins = append(unlockedCoins, *unlockedCoin) + lockedCoins = append(lockedCoins, *lockedCoin) return false, nil }) if err != nil { return nil, nil, err } - if startTime.After(blockTime) { - return unlockedCoins, originalVesting, nil - } else if endTime.Before(blockTime) { - return originalVesting, lockedCoins, nil - } return unlockedCoins, lockedCoins, nil } @@ -215,9 +193,9 @@ func (cva ContinuousLockingAccount) RegisterInitHandler(builder *accountstd.Init func (cva ContinuousLockingAccount) RegisterExecuteHandlers(builder *accountstd.ExecuteBuilder) { accountstd.RegisterExecuteHandler(builder, cva.Delegate) - accountstd.RegisterExecuteHandler(builder, cva.Undelegate) accountstd.RegisterExecuteHandler(builder, cva.SendCoins) accountstd.RegisterExecuteHandler(builder, cva.WithdrawUnlockedCoins) + cva.BaseLockup.RegisterExecuteHandlers(builder) } func (cva ContinuousLockingAccount) RegisterQueryHandlers(builder *accountstd.QueryBuilder) { diff --git a/x/accounts/defaults/lockup/delayed_locking_account.go b/x/accounts/defaults/lockup/delayed_locking_account.go index deb8361d5dcc..057a99001448 100644 --- a/x/accounts/defaults/lockup/delayed_locking_account.go +++ b/x/accounts/defaults/lockup/delayed_locking_account.go @@ -43,12 +43,6 @@ func (dva *DelayedLockingAccount) Delegate(ctx context.Context, msg *lockuptypes return dva.BaseLockup.Delegate(ctx, msg, dva.GetLockedCoinsWithDenoms) } -func (dva *DelayedLockingAccount) Undelegate(ctx context.Context, msg *lockuptypes.MsgUndelegate) ( - *lockuptypes.MsgExecuteMessagesResponse, error, -) { - return dva.BaseLockup.Undelegate(ctx, msg) -} - func (dva *DelayedLockingAccount) SendCoins(ctx context.Context, msg *lockuptypes.MsgSend) ( *lockuptypes.MsgExecuteMessagesResponse, error, ) { @@ -148,9 +142,9 @@ func (dva DelayedLockingAccount) RegisterInitHandler(builder *accountstd.InitBui func (dva DelayedLockingAccount) RegisterExecuteHandlers(builder *accountstd.ExecuteBuilder) { accountstd.RegisterExecuteHandler(builder, dva.Delegate) - accountstd.RegisterExecuteHandler(builder, dva.Undelegate) accountstd.RegisterExecuteHandler(builder, dva.SendCoins) accountstd.RegisterExecuteHandler(builder, dva.WithdrawUnlockedCoins) + dva.BaseLockup.RegisterExecuteHandlers(builder) } func (dva DelayedLockingAccount) RegisterQueryHandlers(builder *accountstd.QueryBuilder) { diff --git a/x/accounts/defaults/lockup/go.mod b/x/accounts/defaults/lockup/go.mod index 8eabfe8d0f0c..b75eb01b50aa 100644 --- a/x/accounts/defaults/lockup/go.mod +++ b/x/accounts/defaults/lockup/go.mod @@ -7,6 +7,8 @@ require ( cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/x/accounts v0.0.0-20240226161501-23359a0b6d91 cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 + cosmossdk.io/x/distribution v0.0.0-00010101000000-000000000000 + cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 github.com/cosmos/cosmos-sdk v0.51.0 github.com/cosmos/gogoproto v1.4.12 ) @@ -20,7 +22,6 @@ require ( cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.1.0 // indirect cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 // indirect - cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 cosmossdk.io/x/tx v0.13.3 // indirect filippo.io/edwards25519 v1.1.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect diff --git a/x/accounts/defaults/lockup/lockup.go b/x/accounts/defaults/lockup/lockup.go index c33aace85477..08f22b304963 100644 --- a/x/accounts/defaults/lockup/lockup.go +++ b/x/accounts/defaults/lockup/lockup.go @@ -17,6 +17,7 @@ import ( "cosmossdk.io/x/accounts/accountstd" lockuptypes "cosmossdk.io/x/accounts/defaults/lockup/types" banktypes "cosmossdk.io/x/bank/types" + distrtypes "cosmossdk.io/x/distribution/types" stakingtypes "cosmossdk.io/x/staking/types" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -99,18 +100,23 @@ func (bva *BaseLockup) Init(ctx context.Context, msg *lockuptypes.MsgInitLockupA if err != nil { return nil, err } + } - // Set initial value for all locked token - err = bva.DelegatedFree.Set(ctx, coin.Denom, math.ZeroInt()) - if err != nil { - return nil, err - } + bondDenom, err := getStakingDenom(ctx) + if err != nil { + return nil, err + } - // Set initial value for all locked token - err = bva.DelegatedLocking.Set(ctx, coin.Denom, math.ZeroInt()) - if err != nil { - return nil, err - } + // Set initial value for all locked token + err = bva.DelegatedFree.Set(ctx, bondDenom, math.ZeroInt()) + if err != nil { + return nil, err + } + + // Set initial value for all locked token + err = bva.DelegatedLocking.Set(ctx, bondDenom, math.ZeroInt()) + if err != nil { + return nil, err } err = bva.EndTime.Set(ctx, msg.EndTime) @@ -146,6 +152,7 @@ func (bva *BaseLockup) Delegate( if err != nil { return nil, err } + err = bva.TrackDelegation( ctx, sdk.Coins{*balance}, @@ -155,17 +162,18 @@ func (bva *BaseLockup) Delegate( if err != nil { return nil, err } + msgDelegate := &stakingtypes.MsgDelegate{ DelegatorAddress: delegatorAddress, ValidatorAddress: msg.ValidatorAddress, Amount: msg.Amount, } - responses, err := sendMessage(ctx, msgDelegate) + resp, err := sendMessage(ctx, msgDelegate) if err != nil { return nil, err } - return &lockuptypes.MsgExecuteMessagesResponse{Responses: responses}, nil + return &lockuptypes.MsgExecuteMessagesResponse{Responses: resp}, nil } func (bva *BaseLockup) Undelegate( @@ -183,17 +191,44 @@ func (bva *BaseLockup) Undelegate( return nil, err } + err = bva.TrackUndelegation(ctx, sdk.Coins{msg.Amount}) + if err != nil { + return nil, err + } + msgUndelegate := &stakingtypes.MsgUndelegate{ DelegatorAddress: delegatorAddress, ValidatorAddress: msg.ValidatorAddress, Amount: msg.Amount, } - responses, err := sendMessage(ctx, msgUndelegate) + resp, err := sendMessage(ctx, msgUndelegate) if err != nil { return nil, err } - err = bva.TrackUndelegation(ctx, sdk.Coins{msg.Amount}) + return &lockuptypes.MsgExecuteMessagesResponse{Responses: resp}, nil +} + +func (bva *BaseLockup) WithdrawReward( + ctx context.Context, msg *lockuptypes.MsgWithdrawReward, +) ( + *lockuptypes.MsgExecuteMessagesResponse, error, +) { + err := bva.checkSender(ctx, msg.Sender) + if err != nil { + return nil, err + } + whoami := accountstd.Whoami(ctx) + delegatorAddress, err := bva.addressCodec.BytesToString(whoami) + if err != nil { + return nil, err + } + + msgWithdraw := &distrtypes.MsgWithdrawDelegatorReward{ + DelegatorAddress: delegatorAddress, + ValidatorAddress: msg.ValidatorAddress, + } + responses, err := sendMessage(ctx, msgWithdraw) if err != nil { return nil, err } @@ -233,12 +268,12 @@ func (bva *BaseLockup) SendCoins( ToAddress: msg.ToAddress, Amount: msg.Amount, } - responses, err := sendMessage(ctx, msgSend) + resp, err := sendMessage(ctx, msgSend) if err != nil { return nil, err } - return &lockuptypes.MsgExecuteMessagesResponse{Responses: responses}, nil + return &lockuptypes.MsgExecuteMessagesResponse{Responses: resp}, nil } // WithdrawUnlockedCoins allow owner to withdraw the unlocked token for a specific denoms to an @@ -265,6 +300,7 @@ func (bva *BaseLockup) WithdrawUnlockedCoins( } amount := sdk.Coins{} + for _, denom := range msg.Denoms { balance, err := bva.getBalance(ctx, fromAddress, denom) if err != nil { @@ -321,6 +357,7 @@ func (bva *BaseLockup) WithdrawUnlockedCoins( ToAddress: msg.ToAddress, Amount: amount, } + _, err = sendMessage(ctx, msgSend) if err != nil { return nil, err @@ -362,6 +399,17 @@ func sendMessage(ctx context.Context, msg proto.Message) ([]*codectypes.Any, err return []*codectypes.Any{respAny}, nil } +func getStakingDenom(ctx context.Context) (string, error) { + // Query account balance for the sent denom + paramsQueryReq := &stakingtypes.QueryParamsRequest{} + resp, err := accountstd.QueryModule[stakingtypes.QueryParamsResponse](ctx, paramsQueryReq) + if err != nil { + return "", err + } + + return resp.Params.BondDenom, nil +} + // TrackDelegation tracks a delegation amount for any given lockup account type // given the amount of coins currently being locked and the current account balance // of the delegation denominations. @@ -371,49 +419,54 @@ func sendMessage(ctx context.Context, msg proto.Message) ([]*codectypes.Any, err func (bva *BaseLockup) TrackDelegation( ctx context.Context, balance, lockedCoins, amount sdk.Coins, ) error { - for _, coin := range amount { - baseAmt := balance.AmountOf(coin.Denom) - // return error if the delegation amount is zero or if the base coins does not - // exceed the desired delegation amount. - if coin.IsZero() || baseAmt.LT(coin.Amount) { - return sdkerrors.ErrInvalidCoins.Wrap("delegation attempt with zero coins or insufficient funds") - } + bondDenom, err := getStakingDenom(ctx) + if err != nil { + return err + } - lockedAmt := lockedCoins.AmountOf(coin.Denom) - delLockingAmt, err := bva.DelegatedLocking.Get(ctx, coin.Denom) + delAmt := amount.AmountOf(bondDenom) + baseAmt := balance.AmountOf(bondDenom) + + // return error if the delegation amount is zero or if the base coins does not + // exceed the desired delegation amount. + if delAmt.IsZero() || baseAmt.LT(delAmt) { + return sdkerrors.ErrInvalidCoins.Wrap("delegation attempt with zero coins for staking denom or insufficient funds") + } + + lockedAmt := lockedCoins.AmountOf(bondDenom) + delLockingAmt, err := bva.DelegatedLocking.Get(ctx, bondDenom) + if err != nil { + return err + } + delFreeAmt, err := bva.DelegatedFree.Get(ctx, bondDenom) + if err != nil { + return err + } + + // compute x and y per the specification, where: + // X := min(max(V - DV, 0), D) + // Y := D - X + x := math.MinInt(math.MaxInt(lockedAmt.Sub(delLockingAmt), math.ZeroInt()), delAmt) + y := delAmt.Sub(x) + + delLockingCoin := sdk.NewCoin(bondDenom, delLockingAmt) + delFreeCoin := sdk.NewCoin(bondDenom, delFreeAmt) + if !x.IsZero() { + xCoin := sdk.NewCoin(bondDenom, x) + newDelLocking := delLockingCoin.Add(xCoin) + err = bva.DelegatedLocking.Set(ctx, bondDenom, newDelLocking.Amount) if err != nil { return err } - delFreeAmt, err := bva.DelegatedFree.Get(ctx, coin.Denom) + } + + if !y.IsZero() { + yCoin := sdk.NewCoin(bondDenom, y) + newDelFree := delFreeCoin.Add(yCoin) + err = bva.DelegatedFree.Set(ctx, bondDenom, newDelFree.Amount) if err != nil { return err } - - // compute x and y per the specification, where: - // X := min(max(V - DV, 0), D) - // Y := D - X - x := math.MinInt(math.MaxInt(lockedAmt.Sub(delLockingAmt), math.ZeroInt()), coin.Amount) - y := coin.Amount.Sub(x) - - delLockingCoin := sdk.NewCoin(coin.Denom, delLockingAmt) - delFreeCoin := sdk.NewCoin(coin.Denom, delFreeAmt) - if !x.IsZero() { - xCoin := sdk.NewCoin(coin.Denom, x) - newDelLocking := delLockingCoin.Add(xCoin) - err = bva.DelegatedLocking.Set(ctx, newDelLocking.Denom, newDelLocking.Amount) - if err != nil { - return err - } - } - - if !y.IsZero() { - yCoin := sdk.NewCoin(coin.Denom, y) - newDelFree := delFreeCoin.Add(yCoin) - err = bva.DelegatedFree.Set(ctx, newDelFree.Denom, newDelFree.Amount) - if err != nil { - return err - } - } } return nil @@ -430,46 +483,48 @@ func (bva *BaseLockup) TrackDelegation( // // CONTRACT: The account's coins and undelegation coins must be sorted. func (bva *BaseLockup) TrackUndelegation(ctx context.Context, amount sdk.Coins) error { - for _, coin := range amount { - // return error if the undelegation amount is zero - if coin.IsZero() { - return sdkerrors.ErrInvalidCoins.Wrap("undelegation attempt with zero coins") - } + bondDenom, err := getStakingDenom(ctx) + if err != nil { + return err + } + delAmt := amount.AmountOf(bondDenom) + // return error if the undelegation amount is zero + if delAmt.IsZero() { + return sdkerrors.ErrInvalidCoins.Wrap("undelegation attempt with zero coins for staking denom") + } + delFreeAmt, err := bva.DelegatedFree.Get(ctx, bondDenom) + if err != nil { + return err + } + delLockingAmt, err := bva.DelegatedLocking.Get(ctx, bondDenom) + if err != nil { + return err + } - delFreeAmt, err := bva.DelegatedFree.Get(ctx, coin.Denom) + // compute x and y per the specification, where: + // X := min(DF, D) + // Y := min(DV, D - X) + x := math.MinInt(delFreeAmt, delAmt) + y := math.MinInt(delLockingAmt, delAmt.Sub(x)) + + delLockingCoin := sdk.NewCoin(bondDenom, delLockingAmt) + delFreeCoin := sdk.NewCoin(bondDenom, delFreeAmt) + if !x.IsZero() { + xCoin := sdk.NewCoin(bondDenom, x) + newDelFree := delFreeCoin.Sub(xCoin) + err = bva.DelegatedFree.Set(ctx, bondDenom, newDelFree.Amount) if err != nil { return err } - delLockingAmt, err := bva.DelegatedLocking.Get(ctx, coin.Denom) + } + + if !y.IsZero() { + yCoin := sdk.NewCoin(bondDenom, y) + newDelLocking := delLockingCoin.Sub(yCoin) + err = bva.DelegatedLocking.Set(ctx, bondDenom, newDelLocking.Amount) if err != nil { return err } - - // compute x and y per the specification, where: - // X := min(DF, D) - // Y := min(DV, D - X) - x := math.MinInt(delFreeAmt, coin.Amount) - y := math.MinInt(delLockingAmt, coin.Amount.Sub(x)) - - delLockingCoin := sdk.NewCoin(coin.Denom, delLockingAmt) - delFreeCoin := sdk.NewCoin(coin.Denom, delFreeAmt) - if !x.IsZero() { - xCoin := sdk.NewCoin(coin.Denom, x) - newDelFree := delFreeCoin.Sub(xCoin) - err = bva.DelegatedFree.Set(ctx, newDelFree.Denom, newDelFree.Amount) - if err != nil { - return err - } - } - - if !y.IsZero() { - yCoin := sdk.NewCoin(coin.Denom, y) - newDelLocking := delLockingCoin.Sub(yCoin) - err = bva.DelegatedLocking.Set(ctx, newDelLocking.Denom, newDelLocking.Amount) - if err != nil { - return err - } - } } return nil @@ -522,7 +577,7 @@ func (bva BaseLockup) checkTokensSendable(ctx context.Context, sender string, am return nil } -// IterateSendEnabledEntries iterates over all the SendEnabled entries. +// IterateCoinEntries iterates over all the CoinEntries entries. func (bva BaseLockup) IterateCoinEntries( ctx context.Context, entries collections.Map[string, math.Int], @@ -537,6 +592,16 @@ func (bva BaseLockup) IterateCoinEntries( // GetNotBondedLockedCoin returns the coin that are not spendable that are not bonded by denom // for a lockup account. If the coin by the provided denom are not locked, an coin with zero amount is returned. func (bva BaseLockup) GetNotBondedLockedCoin(ctx context.Context, lockedCoin sdk.Coin, denom string) (sdk.Coin, error) { + bondDenom, err := getStakingDenom(ctx) + if err != nil { + return sdk.Coin{}, err + } + + // if not bond denom then return the full locked coin + if bondDenom != denom { + return lockedCoin, nil + } + delegatedLockingAmt, err := bva.DelegatedLocking.Get(ctx, denom) if err != nil { return sdk.Coin{}, err @@ -576,23 +641,22 @@ func (bva BaseLockup) QueryLockupAccountBaseInfo(ctx context.Context, _ *lockupt return nil, err } - delegatedLocking := sdk.Coins{} - err = bva.IterateCoinEntries(ctx, bva.DelegatedLocking, func(key string, value math.Int) (stop bool, err error) { - delegatedLocking = append(delegatedLocking, sdk.NewCoin(key, value)) - return false, nil - }) + bondDenom, err := getStakingDenom(ctx) if err != nil { return nil, err } - delegatedFree := sdk.Coins{} - err = bva.IterateCoinEntries(ctx, bva.DelegatedFree, func(key string, value math.Int) (stop bool, err error) { - delegatedFree = append(delegatedFree, sdk.NewCoin(key, value)) - return false, nil - }) + delegatedLockingAmt, err := bva.DelegatedLocking.Get(ctx, bondDenom) if err != nil { return nil, err } + delegatedLocking := sdk.NewCoins(sdk.NewCoin(bondDenom, delegatedLockingAmt)) + + delegatedFreeAmt, err := bva.DelegatedFree.Get(ctx, bondDenom) + if err != nil { + return nil, err + } + delegatedFree := sdk.NewCoins(sdk.NewCoin(bondDenom, delegatedFreeAmt)) return &lockuptypes.QueryLockupAccountInfoResponse{ Owner: ownerAddress, @@ -602,3 +666,8 @@ func (bva BaseLockup) QueryLockupAccountBaseInfo(ctx context.Context, _ *lockupt EndTime: &endTime, }, nil } + +func (bva BaseLockup) RegisterExecuteHandlers(builder *accountstd.ExecuteBuilder) { + accountstd.RegisterExecuteHandler(builder, bva.Undelegate) + accountstd.RegisterExecuteHandler(builder, bva.WithdrawReward) +} diff --git a/x/accounts/defaults/lockup/lockup_test.go b/x/accounts/defaults/lockup/lockup_test.go index 25477bc9c542..c76b16bf8820 100644 --- a/x/accounts/defaults/lockup/lockup_test.go +++ b/x/accounts/defaults/lockup/lockup_test.go @@ -129,7 +129,7 @@ func TestTrackingDelegation(t *testing.T) { nil, nil, nil, - sdkerrors.ErrInvalidCoins.Wrap("delegation attempt with zero coins or insufficient funds"), + sdkerrors.ErrInvalidCoins.Wrap("delegation attempt with zero coins for staking denom or insufficient funds"), }, { "zero amount", @@ -138,7 +138,7 @@ func TestTrackingDelegation(t *testing.T) { nil, nil, nil, - sdkerrors.ErrInvalidCoins.Wrap("delegation attempt with zero coins or insufficient funds"), + sdkerrors.ErrInvalidCoins.Wrap("delegation attempt with zero coins for staking denom or insufficient funds"), }, } @@ -201,7 +201,7 @@ func TestTrackingUnDelegation(t *testing.T) { sdk.Coins{sdk.NewCoin("test", math.NewInt(0))}, nil, nil, - sdkerrors.ErrInvalidCoins.Wrap("undelegation attempt with zero coins"), + sdkerrors.ErrInvalidCoins.Wrap("undelegation attempt with zero coins for staking denom"), }, } diff --git a/x/accounts/defaults/lockup/periodic_locking_account.go b/x/accounts/defaults/lockup/periodic_locking_account.go index c4c45142fd1b..71013980d9d7 100644 --- a/x/accounts/defaults/lockup/periodic_locking_account.go +++ b/x/accounts/defaults/lockup/periodic_locking_account.go @@ -87,18 +87,23 @@ func (pva PeriodicLockingAccount) Init(ctx context.Context, msg *lockuptypes.Msg if err != nil { return nil, err } + } - // Set initial value for all delegated free token - err = pva.DelegatedFree.Set(ctx, coin.Denom, math.ZeroInt()) - if err != nil { - return nil, err - } + bondDenom, err := getStakingDenom(ctx) + if err != nil { + return nil, err + } - // Set initial value for all delegated locking token - err = pva.DelegatedLocking.Set(ctx, coin.Denom, math.ZeroInt()) - if err != nil { - return nil, err - } + // Set initial value for all locked token + err = pva.DelegatedFree.Set(ctx, bondDenom, math.ZeroInt()) + if err != nil { + return nil, err + } + + // Set initial value for all locked token + err = pva.DelegatedLocking.Set(ctx, bondDenom, math.ZeroInt()) + if err != nil { + return nil, err } err = pva.StartTime.Set(ctx, msg.StartTime) @@ -123,12 +128,6 @@ func (pva *PeriodicLockingAccount) Delegate(ctx context.Context, msg *lockuptype return pva.BaseLockup.Delegate(ctx, msg, pva.GetLockedCoinsWithDenoms) } -func (pva *PeriodicLockingAccount) Undelegate(ctx context.Context, msg *lockuptypes.MsgUndelegate) ( - *lockuptypes.MsgExecuteMessagesResponse, error, -) { - return pva.BaseLockup.Undelegate(ctx, msg) -} - func (pva *PeriodicLockingAccount) SendCoins(ctx context.Context, msg *lockuptypes.MsgSend) ( *lockuptypes.MsgExecuteMessagesResponse, error, ) { @@ -141,7 +140,7 @@ func (pva *PeriodicLockingAccount) WithdrawUnlockedCoins(ctx context.Context, ms return pva.BaseLockup.WithdrawUnlockedCoins(ctx, msg, pva.GetLockedCoinsWithDenoms) } -// IterateSendEnabledEntries iterates over all the SendEnabled entries. +// IteratePeriods iterates over all the Periods entries. func (pva PeriodicLockingAccount) IteratePeriods( ctx context.Context, cb func(value lockuptypes.Period) (bool, error), @@ -201,10 +200,7 @@ func (pva PeriodicLockingAccount) GetLockCoinsInfo(ctx context.Context, blockTim unlockedCoins = unlockedCoins.Add(period.Amount...) // update the start time of the next period - err = pva.StartTime.Set(ctx, currentPeriodStartTime.Add(period.Length)) - if err != nil { - return true, err - } + currentPeriodStartTime = currentPeriodStartTime.Add(period.Length) return false, nil }) if err != nil { @@ -268,10 +264,7 @@ func (pva PeriodicLockingAccount) GetLockCoinInfoWithDenom(ctx context.Context, unlocked = unlocked.Add(sdk.NewCoin(denom, period.Amount.AmountOf(denom))) // update the start time of the next period - err = pva.StartTime.Set(ctx, currentPeriodStartTime.Add(period.Length)) - if err != nil { - return true, err - } + currentPeriodStartTime = currentPeriodStartTime.Add(period.Length) return false, nil }) if err != nil { @@ -342,9 +335,9 @@ func (pva PeriodicLockingAccount) RegisterInitHandler(builder *accountstd.InitBu func (pva PeriodicLockingAccount) RegisterExecuteHandlers(builder *accountstd.ExecuteBuilder) { accountstd.RegisterExecuteHandler(builder, pva.Delegate) - accountstd.RegisterExecuteHandler(builder, pva.Undelegate) accountstd.RegisterExecuteHandler(builder, pva.SendCoins) accountstd.RegisterExecuteHandler(builder, pva.WithdrawUnlockedCoins) + pva.BaseLockup.RegisterExecuteHandlers(builder) } func (pva PeriodicLockingAccount) RegisterQueryHandlers(builder *accountstd.QueryBuilder) { diff --git a/x/accounts/defaults/lockup/permanent_locking_account.go b/x/accounts/defaults/lockup/permanent_locking_account.go index 70a8b98dd1d7..2ca615c15ba5 100644 --- a/x/accounts/defaults/lockup/permanent_locking_account.go +++ b/x/accounts/defaults/lockup/permanent_locking_account.go @@ -100,8 +100,8 @@ func (plva PermanentLockingAccount) RegisterInitHandler(builder *accountstd.Init func (plva PermanentLockingAccount) RegisterExecuteHandlers(builder *accountstd.ExecuteBuilder) { accountstd.RegisterExecuteHandler(builder, plva.Delegate) - accountstd.RegisterExecuteHandler(builder, plva.Undelegate) accountstd.RegisterExecuteHandler(builder, plva.SendCoins) + plva.BaseLockup.RegisterExecuteHandlers(builder) } func (plva PermanentLockingAccount) RegisterQueryHandlers(builder *accountstd.QueryBuilder) { diff --git a/x/accounts/defaults/lockup/sonar-project.properties b/x/accounts/defaults/lockup/sonar-project.properties deleted file mode 100644 index 84929aa7ef1d..000000000000 --- a/x/accounts/defaults/lockup/sonar-project.properties +++ /dev/null @@ -1,15 +0,0 @@ -sonar.projectKey=cosmos-sdk-x-accounts-lockup -sonar.organization=cosmos - -sonar.projectName=Cosmos SDK - x/accounts/defaults/lockup -sonar.project.monorepo.enabled=true - -sonar.sources=. -sonar.exclusions=**/*_test.go -sonar.tests=. -sonar.test.inclusions=**/*_test.go -sonar.go.coverage.reportPaths=coverage.out - -sonar.sourceEncoding=UTF-8 -sonar.scm.provider=git -sonar.pullrequest.github.summary_comment=true \ No newline at end of file diff --git a/x/accounts/defaults/lockup/types/tx.pb.go b/x/accounts/defaults/lockup/types/tx.pb.go index c50ab2f5c360..6a4383e31c77 100644 --- a/x/accounts/defaults/lockup/types/tx.pb.go +++ b/x/accounts/defaults/lockup/types/tx.pb.go @@ -318,6 +318,45 @@ func (m *MsgUndelegate) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUndelegate proto.InternalMessageInfo +// MsgWithdrawReward defines a message that enable lockup account to execute withdraw reward message +type MsgWithdrawReward struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` +} + +func (m *MsgWithdrawReward) Reset() { *m = MsgWithdrawReward{} } +func (m *MsgWithdrawReward) String() string { return proto.CompactTextString(m) } +func (*MsgWithdrawReward) ProtoMessage() {} +func (*MsgWithdrawReward) Descriptor() ([]byte, []int) { + return fileDescriptor_e5f39108a4d67f92, []int{6} +} +func (m *MsgWithdrawReward) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgWithdrawReward) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgWithdrawReward.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgWithdrawReward) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgWithdrawReward.Merge(m, src) +} +func (m *MsgWithdrawReward) XXX_Size() int { + return m.Size() +} +func (m *MsgWithdrawReward) XXX_DiscardUnknown() { + xxx_messageInfo_MsgWithdrawReward.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgWithdrawReward proto.InternalMessageInfo + // MsgSend defines a message that enable lockup account to execute send message type MsgSend struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` @@ -329,7 +368,7 @@ func (m *MsgSend) Reset() { *m = MsgSend{} } func (m *MsgSend) String() string { return proto.CompactTextString(m) } func (*MsgSend) ProtoMessage() {} func (*MsgSend) Descriptor() ([]byte, []int) { - return fileDescriptor_e5f39108a4d67f92, []int{6} + return fileDescriptor_e5f39108a4d67f92, []int{7} } func (m *MsgSend) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -367,7 +406,7 @@ func (m *MsgExecuteMessagesResponse) Reset() { *m = MsgExecuteMessagesRe func (m *MsgExecuteMessagesResponse) String() string { return proto.CompactTextString(m) } func (*MsgExecuteMessagesResponse) ProtoMessage() {} func (*MsgExecuteMessagesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e5f39108a4d67f92, []int{7} + return fileDescriptor_e5f39108a4d67f92, []int{8} } func (m *MsgExecuteMessagesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -415,7 +454,7 @@ func (m *MsgWithdraw) Reset() { *m = MsgWithdraw{} } func (m *MsgWithdraw) String() string { return proto.CompactTextString(m) } func (*MsgWithdraw) ProtoMessage() {} func (*MsgWithdraw) Descriptor() ([]byte, []int) { - return fileDescriptor_e5f39108a4d67f92, []int{8} + return fileDescriptor_e5f39108a4d67f92, []int{9} } func (m *MsgWithdraw) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -454,7 +493,7 @@ func (m *MsgWithdrawResponse) Reset() { *m = MsgWithdrawResponse{} } func (m *MsgWithdrawResponse) String() string { return proto.CompactTextString(m) } func (*MsgWithdrawResponse) ProtoMessage() {} func (*MsgWithdrawResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e5f39108a4d67f92, []int{9} + return fileDescriptor_e5f39108a4d67f92, []int{10} } func (m *MsgWithdrawResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -504,6 +543,7 @@ func init() { proto.RegisterType((*MsgInitPeriodicLockingAccountResponse)(nil), "cosmos.accounts.defaults.lockup.MsgInitPeriodicLockingAccountResponse") proto.RegisterType((*MsgDelegate)(nil), "cosmos.accounts.defaults.lockup.MsgDelegate") proto.RegisterType((*MsgUndelegate)(nil), "cosmos.accounts.defaults.lockup.MsgUndelegate") + proto.RegisterType((*MsgWithdrawReward)(nil), "cosmos.accounts.defaults.lockup.MsgWithdrawReward") proto.RegisterType((*MsgSend)(nil), "cosmos.accounts.defaults.lockup.MsgSend") proto.RegisterType((*MsgExecuteMessagesResponse)(nil), "cosmos.accounts.defaults.lockup.MsgExecuteMessagesResponse") proto.RegisterType((*MsgWithdraw)(nil), "cosmos.accounts.defaults.lockup.MsgWithdraw") @@ -515,57 +555,58 @@ func init() { } var fileDescriptor_e5f39108a4d67f92 = []byte{ - // 797 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x56, 0x3d, 0x4f, 0x1b, 0x49, - 0x18, 0xf6, 0xda, 0x3a, 0x83, 0x87, 0x03, 0x8e, 0xc5, 0x3a, 0x8c, 0x75, 0xec, 0x72, 0x96, 0x10, - 0x96, 0x75, 0xde, 0x3d, 0xb8, 0x93, 0xee, 0x64, 0x5d, 0x83, 0x8f, 0x7c, 0x49, 0x71, 0x84, 0x4c, - 0x3e, 0xa4, 0xa4, 0xb0, 0xd6, 0xbb, 0xc3, 0xb0, 0xc2, 0x3b, 0x63, 0xed, 0x8c, 0x0d, 0xee, 0xa2, - 0x28, 0x45, 0x44, 0x45, 0x9d, 0x8a, 0x2a, 0x8a, 0x52, 0x39, 0x12, 0x3f, 0x82, 0x12, 0x51, 0x51, - 0x85, 0xc8, 0x44, 0x32, 0x3f, 0x23, 0x9a, 0x9d, 0x59, 0x62, 0x3e, 0x02, 0x8e, 0x8b, 0x14, 0x69, - 0xbc, 0x33, 0xf3, 0x3e, 0xef, 0xfb, 0x3e, 0xcf, 0x33, 0x1f, 0x32, 0xc8, 0xda, 0x84, 0x7a, 0x84, - 0x9a, 0x96, 0x6d, 0x93, 0x06, 0x66, 0xd4, 0x74, 0xe0, 0x9a, 0xd5, 0xa8, 0x31, 0x6a, 0xd6, 0x88, - 0xbd, 0xd1, 0xa8, 0x9b, 0x6c, 0xcb, 0xa8, 0xfb, 0x84, 0x11, 0x55, 0x17, 0x48, 0x23, 0x44, 0x1a, - 0x21, 0xd2, 0x10, 0xc8, 0xf4, 0x84, 0xe5, 0xb9, 0x98, 0x98, 0xc1, 0xaf, 0xc8, 0x49, 0x6b, 0xb2, - 0x7a, 0xd5, 0xa2, 0xd0, 0x6c, 0x2e, 0x54, 0x21, 0xb3, 0x16, 0x4c, 0x9b, 0xb8, 0x58, 0xc6, 0xff, - 0xb8, 0xa9, 0xbb, 0xf8, 0x48, 0xf4, 0x94, 0x44, 0x7b, 0x14, 0x99, 0xcd, 0x05, 0xfe, 0x91, 0x81, - 0x69, 0x11, 0xa8, 0x04, 0x33, 0x53, 0xf2, 0x14, 0xa1, 0x24, 0x22, 0x88, 0x88, 0x75, 0x3e, 0x0a, - 0x13, 0x10, 0x21, 0xa8, 0x06, 0xcd, 0x60, 0x56, 0x6d, 0xac, 0x99, 0x16, 0x6e, 0xc9, 0x90, 0x7e, - 0x31, 0xc4, 0x5c, 0x0f, 0x52, 0x66, 0x79, 0x92, 0x45, 0xe6, 0x79, 0x14, 0x24, 0x4b, 0x14, 0xdd, - 0xc3, 0x2e, 0xbb, 0x1f, 0xb0, 0x5b, 0x12, 0xe4, 0x55, 0x03, 0xfc, 0x44, 0x36, 0x31, 0xf4, 0x53, - 0xca, 0xac, 0x92, 0x4d, 0x14, 0x53, 0x87, 0x7b, 0xf9, 0xa4, 0xe4, 0xb2, 0xe4, 0x38, 0x3e, 0xa4, - 0x74, 0x95, 0xf9, 0x2e, 0x46, 0x65, 0x01, 0x53, 0x97, 0xc1, 0x30, 0xc4, 0x4e, 0x85, 0xd7, 0x4f, - 0x45, 0x67, 0x95, 0xec, 0xc8, 0x62, 0xda, 0x10, 0xcd, 0x8d, 0xb0, 0xb9, 0xf1, 0x30, 0x6c, 0x5e, - 0x1c, 0xdd, 0xff, 0xa0, 0x47, 0x76, 0x8e, 0x75, 0xe5, 0x6d, 0xb7, 0x9d, 0x53, 0xca, 0x43, 0x10, - 0x3b, 0x3c, 0xa8, 0xde, 0x05, 0x80, 0x32, 0xcb, 0x67, 0xa2, 0x4e, 0xec, 0x5b, 0xeb, 0x24, 0x82, - 0x64, 0x1e, 0x2e, 0x64, 0x4f, 0x77, 0x75, 0x65, 0xbb, 0xdb, 0xce, 0xc9, 0x9d, 0xce, 0x53, 0x67, - 0xc3, 0xbc, 0x4a, 0x69, 0x46, 0x03, 0xbf, 0x5d, 0xb5, 0x5e, 0x86, 0xb4, 0x4e, 0x30, 0x85, 0x99, - 0x37, 0x51, 0x30, 0x23, 0x01, 0x2b, 0xd0, 0x77, 0x89, 0xe3, 0xda, 0x1c, 0xe8, 0x62, 0x34, 0xa8, - 0x57, 0xe7, 0x55, 0x46, 0x07, 0x57, 0xa9, 0x3e, 0x03, 0xe3, 0x35, 0xc1, 0xa5, 0x52, 0x0f, 0xb8, - 0xd1, 0x54, 0x6c, 0x36, 0x96, 0x1d, 0x59, 0x9c, 0x37, 0x6e, 0x38, 0xe0, 0x86, 0xd0, 0x52, 0x4c, - 0xf0, 0xda, 0xa2, 0xee, 0x98, 0x2c, 0x25, 0x22, 0xb4, 0x60, 0x9c, 0xee, 0xea, 0x11, 0x6e, 0xe1, - 0xdc, 0x65, 0x0b, 0x05, 0xe6, 0xbc, 0x91, 0xf3, 0x60, 0xee, 0x5a, 0x9f, 0xce, 0x1c, 0xed, 0x28, - 0x60, 0xa4, 0x44, 0xd1, 0x32, 0xac, 0x41, 0x64, 0x31, 0xa8, 0xfe, 0x09, 0xe2, 0x14, 0x62, 0xa7, - 0x0f, 0x03, 0x25, 0x4e, 0x7d, 0x00, 0x26, 0x9a, 0x56, 0xcd, 0x75, 0x2c, 0x46, 0xfc, 0x8a, 0x25, - 0x20, 0x81, 0x91, 0x89, 0xe2, 0xef, 0x87, 0x7b, 0xf9, 0x19, 0x99, 0xfc, 0x38, 0xc4, 0x9c, 0xaf, - 0xf2, 0x4b, 0xf3, 0xc2, 0xba, 0xfa, 0x1f, 0x88, 0x5b, 0x1e, 0xe7, 0x28, 0xcf, 0xdc, 0x74, 0x68, - 0x1f, 0xbf, 0xeb, 0x86, 0xbc, 0xeb, 0xc6, 0xff, 0xc4, 0xc5, 0xbd, 0x86, 0xc9, 0x9c, 0xc2, 0xe4, - 0xab, 0x5d, 0x3d, 0xc2, 0xcd, 0x7a, 0xd1, 0x6d, 0xe7, 0x24, 0xc5, 0xcc, 0x27, 0x05, 0x8c, 0x96, - 0x28, 0x7a, 0x84, 0x9d, 0x1f, 0x5a, 0xe6, 0xcb, 0x28, 0x18, 0x2a, 0x51, 0xb4, 0x0a, 0xb1, 0x33, - 0x80, 0xc0, 0x7f, 0x00, 0x60, 0xe4, 0x82, 0xb2, 0xaf, 0x67, 0x25, 0x18, 0x09, 0x95, 0xb4, 0x7a, - 0x94, 0xc4, 0xae, 0x57, 0x72, 0x9b, 0x2b, 0x79, 0x77, 0xac, 0x67, 0x91, 0xcb, 0xd6, 0x1b, 0x55, - 0xc3, 0x26, 0x9e, 0x7c, 0x55, 0xcd, 0x9e, 0x73, 0xcd, 0x5a, 0x75, 0x48, 0x83, 0x04, 0xfa, 0xba, - 0xdb, 0xce, 0xfd, 0xcc, 0xf7, 0xcc, 0x6e, 0x55, 0xf8, 0xf3, 0x4e, 0xfb, 0xb0, 0x61, 0x05, 0xa4, - 0x4b, 0x14, 0xdd, 0xda, 0x82, 0x76, 0x83, 0xc1, 0x12, 0xa4, 0xd4, 0x42, 0x90, 0x86, 0x07, 0x5e, - 0x5d, 0x04, 0x09, 0x5f, 0x8e, 0x69, 0x4a, 0x09, 0x08, 0x27, 0x2f, 0xdd, 0xf7, 0x25, 0xdc, 0x2a, - 0x7f, 0x81, 0x65, 0xde, 0x8b, 0x4b, 0xf2, 0xc4, 0x65, 0xeb, 0x8e, 0x6f, 0x6d, 0xaa, 0xff, 0x02, - 0xb0, 0x29, 0xc7, 0x7d, 0x18, 0xdc, 0x83, 0x1d, 0xdc, 0xe4, 0x5f, 0x41, 0xdc, 0x81, 0x98, 0x78, - 0xe2, 0x51, 0x49, 0x94, 0xe5, 0xac, 0x30, 0xd5, 0xeb, 0x40, 0x4f, 0xa7, 0xcc, 0x91, 0x02, 0x26, - 0x7b, 0x38, 0x9f, 0xe9, 0xff, 0x1b, 0x0c, 0xfb, 0xd0, 0x86, 0x6e, 0xb3, 0x0f, 0xe6, 0x67, 0x48, - 0x75, 0x5b, 0x01, 0xe3, 0xc2, 0xf3, 0x8a, 0x5c, 0x73, 0x52, 0xd1, 0xef, 0xb5, 0xdb, 0x63, 0xa2, - 0x73, 0x59, 0x36, 0x2e, 0xde, 0xd9, 0xef, 0x68, 0xca, 0x41, 0x47, 0x53, 0x3e, 0x76, 0x34, 0x65, - 0xe7, 0x44, 0x8b, 0x1c, 0x9c, 0x68, 0x91, 0xa3, 0x13, 0x2d, 0xf2, 0x34, 0x2f, 0xea, 0x52, 0x67, - 0xc3, 0x70, 0x89, 0xb9, 0x75, 0xcd, 0x9f, 0x0f, 0xde, 0xb4, 0x1a, 0x0f, 0x36, 0xfc, 0xaf, 0xcf, - 0x01, 0x00, 0x00, 0xff, 0xff, 0xf7, 0xd7, 0x1d, 0x22, 0xac, 0x08, 0x00, 0x00, + // 816 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x56, 0xcf, 0x4f, 0x1b, 0x47, + 0x14, 0xf6, 0xda, 0xaa, 0xc1, 0x43, 0x81, 0xb2, 0x58, 0xc5, 0x58, 0x65, 0x97, 0x5a, 0x42, 0x58, + 0x56, 0xbd, 0x5b, 0x68, 0xa5, 0x56, 0x56, 0x2f, 0xb8, 0xf4, 0x97, 0x54, 0x57, 0xc8, 0xf4, 0x87, + 0xd4, 0x1c, 0xac, 0xf1, 0xee, 0x30, 0xac, 0xf0, 0xce, 0x58, 0x3b, 0x63, 0x1b, 0xdf, 0xa2, 0x28, + 0x87, 0x88, 0x13, 0xe7, 0x9c, 0x38, 0x45, 0x11, 0x27, 0x47, 0xe2, 0x8f, 0xe0, 0x88, 0x38, 0x71, + 0x0a, 0x91, 0x89, 0x64, 0xfe, 0x8c, 0x68, 0x77, 0x66, 0x89, 0x0d, 0x04, 0x1c, 0x1f, 0x12, 0x29, + 0x17, 0xef, 0xcc, 0xbc, 0xef, 0xbd, 0xf7, 0xbd, 0x6f, 0xde, 0xdb, 0x35, 0xc8, 0x5a, 0x94, 0xb9, + 0x94, 0x99, 0xd0, 0xb2, 0x68, 0x83, 0x70, 0x66, 0xda, 0x68, 0x0b, 0x36, 0x6a, 0x9c, 0x99, 0x35, + 0x6a, 0xed, 0x34, 0xea, 0x26, 0xdf, 0x35, 0xea, 0x1e, 0xe5, 0x54, 0xd5, 0x05, 0xd2, 0x08, 0x91, + 0x46, 0x88, 0x34, 0x04, 0x32, 0x3d, 0x03, 0x5d, 0x87, 0x50, 0x33, 0xf8, 0x15, 0x3e, 0x69, 0x4d, + 0x46, 0xaf, 0x42, 0x86, 0xcc, 0xe6, 0x4a, 0x15, 0x71, 0xb8, 0x62, 0x5a, 0xd4, 0x21, 0xd2, 0xfe, + 0xcd, 0x7d, 0xd9, 0xc5, 0x43, 0xa2, 0xe7, 0x24, 0xda, 0x65, 0xd8, 0x6c, 0xae, 0xf8, 0x0f, 0x69, + 0x98, 0x17, 0x86, 0x4a, 0xb0, 0x33, 0x25, 0x4f, 0x61, 0x4a, 0x62, 0x8a, 0xa9, 0x38, 0xf7, 0x57, + 0xa1, 0x03, 0xa6, 0x14, 0xd7, 0x90, 0x19, 0xec, 0xaa, 0x8d, 0x2d, 0x13, 0x92, 0xb6, 0x34, 0xe9, + 0xd7, 0x4d, 0xdc, 0x71, 0x11, 0xe3, 0xd0, 0x95, 0x2c, 0x32, 0x0f, 0xa3, 0x20, 0x59, 0x62, 0xf8, + 0x0f, 0xe2, 0xf0, 0x3f, 0x03, 0x76, 0x6b, 0x82, 0xbc, 0x6a, 0x80, 0xcf, 0x68, 0x8b, 0x20, 0x2f, + 0xa5, 0x2c, 0x2a, 0xd9, 0x44, 0x31, 0x75, 0x7a, 0x94, 0x4f, 0x4a, 0x2e, 0x6b, 0xb6, 0xed, 0x21, + 0xc6, 0x36, 0xb9, 0xe7, 0x10, 0x5c, 0x16, 0x30, 0x75, 0x1d, 0x8c, 0x23, 0x62, 0x57, 0xfc, 0xf8, + 0xa9, 0xe8, 0xa2, 0x92, 0x9d, 0x58, 0x4d, 0x1b, 0x22, 0xb9, 0x11, 0x26, 0x37, 0xfe, 0x0e, 0x93, + 0x17, 0x27, 0x8f, 0x5f, 0xea, 0x91, 0xfd, 0x73, 0x5d, 0x79, 0xde, 0xeb, 0xe4, 0x94, 0xf2, 0x18, + 0x22, 0xb6, 0x6f, 0x54, 0x7f, 0x07, 0x80, 0x71, 0xe8, 0x71, 0x11, 0x27, 0xf6, 0xbe, 0x71, 0x12, + 0x81, 0xb3, 0x6f, 0x2e, 0x64, 0x2f, 0x0f, 0x74, 0x65, 0xaf, 0xd7, 0xc9, 0xc9, 0x9b, 0xce, 0x33, + 0x7b, 0xc7, 0xbc, 0xad, 0xd2, 0x8c, 0x06, 0xbe, 0xba, 0xed, 0xbc, 0x8c, 0x58, 0x9d, 0x12, 0x86, + 0x32, 0xcf, 0xa2, 0x60, 0x41, 0x02, 0x36, 0x90, 0xe7, 0x50, 0xdb, 0xb1, 0x7c, 0xa0, 0x43, 0xf0, + 0xa8, 0x5a, 0x0d, 0x56, 0x19, 0x1d, 0xbd, 0x4a, 0xf5, 0x01, 0x98, 0xae, 0x09, 0x2e, 0x95, 0x7a, + 0xc0, 0x8d, 0xa5, 0x62, 0x8b, 0xb1, 0xec, 0xc4, 0xea, 0xb2, 0x71, 0x4f, 0x83, 0x1b, 0xa2, 0x96, + 0x62, 0xc2, 0x8f, 0x2d, 0xe2, 0x4e, 0xc9, 0x50, 0xc2, 0xc2, 0x0a, 0xc6, 0xe5, 0x81, 0x1e, 0xf1, + 0x25, 0x5c, 0xba, 0x29, 0xa1, 0xc0, 0x0c, 0x0a, 0xb9, 0x0c, 0x96, 0xee, 0xd4, 0xe9, 0x4a, 0xd1, + 0xae, 0x02, 0x26, 0x4a, 0x0c, 0xaf, 0xa3, 0x1a, 0xc2, 0x90, 0x23, 0xf5, 0x5b, 0x10, 0x67, 0x88, + 0xd8, 0x43, 0x08, 0x28, 0x71, 0xea, 0x5f, 0x60, 0xa6, 0x09, 0x6b, 0x8e, 0x0d, 0x39, 0xf5, 0x2a, + 0x50, 0x40, 0x02, 0x21, 0x13, 0xc5, 0xaf, 0x4f, 0x8f, 0xf2, 0x0b, 0xd2, 0xf9, 0xdf, 0x10, 0x33, + 0x18, 0xe5, 0x8b, 0xe6, 0xb5, 0x73, 0xf5, 0x27, 0x10, 0x87, 0xae, 0xcf, 0x51, 0xf6, 0xdc, 0x7c, + 0x28, 0x9f, 0x3f, 0xeb, 0x86, 0x9c, 0x75, 0xe3, 0x67, 0xea, 0x90, 0x7e, 0xc1, 0xa4, 0x4f, 0x61, + 0xf6, 0xc9, 0x81, 0x1e, 0xf1, 0xc5, 0x7a, 0xd4, 0xeb, 0xe4, 0x24, 0xc5, 0xcc, 0x6b, 0x05, 0x4c, + 0x96, 0x18, 0xfe, 0x87, 0xd8, 0x9f, 0x74, 0x99, 0x87, 0x0a, 0x98, 0x29, 0x31, 0xfc, 0x9f, 0xc3, + 0xb7, 0x6d, 0x0f, 0xb6, 0xca, 0xa8, 0x05, 0x3d, 0xfb, 0xe3, 0x97, 0x7a, 0x3b, 0xd9, 0xc7, 0x51, + 0x30, 0x56, 0x62, 0x78, 0x13, 0x91, 0x51, 0x28, 0xfe, 0x00, 0x00, 0xa7, 0xd7, 0xb8, 0xbd, 0xdb, + 0x2b, 0xc1, 0x69, 0x28, 0x7b, 0xbb, 0x4f, 0xf6, 0xd8, 0xdd, 0xb2, 0xff, 0xea, 0xcb, 0x7e, 0x78, + 0xae, 0x67, 0xb1, 0xc3, 0xb7, 0x1b, 0x55, 0xc3, 0xa2, 0xae, 0xfc, 0x04, 0x98, 0x7d, 0x43, 0xc8, + 0xdb, 0x75, 0xc4, 0x02, 0x07, 0xf6, 0xb4, 0xd7, 0xc9, 0x7d, 0xee, 0x37, 0x98, 0xd5, 0xae, 0xf8, + 0xdf, 0x22, 0x36, 0xc4, 0x9d, 0x6d, 0x80, 0x74, 0x89, 0xe1, 0x5f, 0x76, 0x91, 0xd5, 0xe0, 0xa8, + 0x84, 0x18, 0x83, 0x18, 0xb1, 0x70, 0x3a, 0xd5, 0x55, 0x90, 0xf0, 0xe4, 0x9a, 0xa5, 0x94, 0x80, + 0x70, 0xf2, 0xc6, 0xcb, 0x69, 0x8d, 0xb4, 0xcb, 0x6f, 0x61, 0x99, 0x17, 0x62, 0xa2, 0xc3, 0x2e, + 0x50, 0x7f, 0x04, 0xa0, 0x25, 0xd7, 0x43, 0x08, 0xdc, 0x87, 0x1d, 0x5d, 0xe4, 0x2f, 0x41, 0xdc, + 0x46, 0x84, 0xba, 0xe2, 0x0d, 0x98, 0x28, 0xcb, 0x5d, 0x61, 0xae, 0x5f, 0x81, 0xbe, 0x4c, 0x99, + 0x33, 0x05, 0xcc, 0x0e, 0x74, 0xae, 0xac, 0xff, 0x7b, 0x30, 0xee, 0x21, 0x0b, 0x39, 0xcd, 0x21, + 0x98, 0x5f, 0x21, 0xd5, 0x3d, 0x05, 0x4c, 0x0b, 0xcd, 0x2b, 0xf2, 0xcc, 0x4e, 0x45, 0x3f, 0xd4, + 0x6d, 0x4f, 0x89, 0xcc, 0x65, 0x99, 0xb8, 0xf8, 0xdb, 0x71, 0x57, 0x53, 0x4e, 0xba, 0x9a, 0xf2, + 0xaa, 0xab, 0x29, 0xfb, 0x17, 0x5a, 0xe4, 0xe4, 0x42, 0x8b, 0x9c, 0x5d, 0x68, 0x91, 0xff, 0xf3, + 0x22, 0x2e, 0xb3, 0x77, 0x0c, 0x87, 0x9a, 0xbb, 0x77, 0xfc, 0x53, 0xf2, 0x93, 0x56, 0xe3, 0xc1, + 0x85, 0x7f, 0xf7, 0x26, 0x00, 0x00, 0xff, 0xff, 0x4e, 0xb6, 0xac, 0x3d, 0x59, 0x09, 0x00, 0x00, } func (this *MsgInitLockupAccount) Equal(that interface{}) bool { @@ -836,6 +877,43 @@ func (m *MsgUndelegate) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgWithdrawReward) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgWithdrawReward) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgWithdrawReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *MsgSend) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1119,6 +1197,23 @@ func (m *MsgUndelegate) Size() (n int) { return n } +func (m *MsgWithdrawReward) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + func (m *MsgSend) Size() (n int) { if m == nil { return 0 @@ -1896,6 +1991,120 @@ func (m *MsgUndelegate) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgWithdrawReward) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgWithdrawReward: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgWithdrawReward: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MsgSend) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/accounts/defaults/lockup/utils_test.go b/x/accounts/defaults/lockup/utils_test.go index 23702b051a71..6dd435512ebf 100644 --- a/x/accounts/defaults/lockup/utils_test.go +++ b/x/accounts/defaults/lockup/utils_test.go @@ -13,6 +13,7 @@ import ( "cosmossdk.io/math" "cosmossdk.io/x/accounts/accountstd" banktypes "cosmossdk.io/x/bank/types" + stakingtypes "cosmossdk.io/x/staking/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -61,13 +62,23 @@ func newMockContext(t *testing.T) (context.Context, store.KVStoreService) { return nil, nil }, func(ctx context.Context, req, resp ProtoMsg) error { _, ok := req.(*banktypes.QueryBalanceRequest) - require.True(t, ok) + if !ok { + _, ok = req.(*stakingtypes.QueryParamsRequest) + require.True(t, ok) + gogoproto.Merge(resp.(gogoproto.Message), &stakingtypes.QueryParamsResponse{ + Params: stakingtypes.Params{ + BondDenom: "test", + }, + }) + return nil + } gogoproto.Merge(resp.(gogoproto.Message), &banktypes.QueryBalanceResponse{ Balance: &sdk.Coin{ Denom: "test", Amount: math.NewInt(5), }, }) + return nil }, ) diff --git a/x/accounts/proto/cosmos/accounts/defaults/lockup/tx.proto b/x/accounts/proto/cosmos/accounts/defaults/lockup/tx.proto index a0a6e1a07aea..c13cec55b16f 100644 --- a/x/accounts/proto/cosmos/accounts/defaults/lockup/tx.proto +++ b/x/accounts/proto/cosmos/accounts/defaults/lockup/tx.proto @@ -79,6 +79,17 @@ message MsgUndelegate { cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } +// MsgWithdrawReward defines a message that enable lockup account to execute withdraw reward message +message MsgWithdrawReward { + option (cosmos.msg.v1.signer) = "sender"; + + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string sender = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.ValidatorAddressString"]; +} + // MsgSend defines a message that enable lockup account to execute send message message MsgSend { option (cosmos.msg.v1.signer) = "sender"; From d0f6cc6d405fbce4332b5654e60bd6514ee79649 Mon Sep 17 00:00:00 2001 From: luchenhan <168071714+luchenhan@users.noreply.github.com> Date: Mon, 29 Apr 2024 20:14:40 +0800 Subject: [PATCH 07/10] chore: fix function names in comment (#20210) Signed-off-by: luchenhan --- testutil/ioutil.go | 2 +- tools/cosmovisor/process_test.go | 4 ++-- types/context.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/testutil/ioutil.go b/testutil/ioutil.go index 4413c16e215e..e786dd4fbaf2 100644 --- a/testutil/ioutil.go +++ b/testutil/ioutil.go @@ -38,7 +38,7 @@ func ApplyMockIO(c *cobra.Command) (BufferReader, BufferWriter) { return mockIn, mockOut } -// ApplyMockIODiscardOutputs replaces a cobra.Command output and error streams with a dummy io.Writer. +// ApplyMockIODiscardOutErr replaces a cobra.Command output and error streams with a dummy io.Writer. // Replaces and returns the io.Reader associated to the cobra.Command input stream. func ApplyMockIODiscardOutErr(c *cobra.Command) BufferReader { mockIn := strings.NewReader("") diff --git a/tools/cosmovisor/process_test.go b/tools/cosmovisor/process_test.go index 2ecea4cb780f..3169ba3e3082 100644 --- a/tools/cosmovisor/process_test.go +++ b/tools/cosmovisor/process_test.go @@ -257,7 +257,7 @@ func (s *processTestSuite) TestLaunchProcessWithDownloads() { require.Equal(cfg.UpgradeBin("chain3"), currentBin) } -// TestCustomPreupgrade will try running the script a few times and watch upgrades work properly +// TestLaunchProcessWithDownloadsAndMissingPreupgrade will try running the script a few times and watch upgrades work properly // and args are passed through func (s *processTestSuite) TestLaunchProcessWithDownloadsAndMissingPreupgrade() { // test case upgrade path (binaries from testdata/download directory): @@ -293,7 +293,7 @@ func (s *processTestSuite) TestLaunchProcessWithDownloadsAndMissingPreupgrade() require.ErrorIs(err, fs.ErrNotExist) } -// TestCustomPreupgrade will try running the script a few times and watch upgrades work properly +// TestLaunchProcessWithDownloadsAndPreupgrade will try running the script a few times and watch upgrades work properly // and args are passed through func (s *processTestSuite) TestLaunchProcessWithDownloadsAndPreupgrade() { // test case upgrade path (binaries from testdata/download directory): diff --git a/types/context.go b/types/context.go index 2212301e163d..33ab2f9c6c3b 100644 --- a/types/context.go +++ b/types/context.go @@ -411,7 +411,7 @@ func ToSDKEvidence(ev []abci.Misbehavior) []comet.Evidence { return evidence } -// ToSDKDecidedCommitInfo takes comet commit info and returns sdk commit info +// ToSDKCommitInfo takes comet commit info and returns sdk commit info func ToSDKCommitInfo(commit abci.CommitInfo) comet.CommitInfo { ci := comet.CommitInfo{ Round: commit.Round, From 71adab70998c270efe0effe7598aa03610f98306 Mon Sep 17 00:00:00 2001 From: Marko Date: Mon, 29 Apr 2024 20:58:59 +0200 Subject: [PATCH 08/10] chore: fix mocks (#20209) Co-authored-by: sontrinh16 --- x/auth/ante/expected_keepers.go | 5 + x/gov/keeper/abci.go | 1 - x/gov/simulation/operations.go | 4 +- x/gov/testutil/expected_keepers.go | 35 +- x/gov/testutil/expected_keepers_mocks.go | 813 +---------------------- x/group/testutil/expected_keepers.go | 18 +- x/staking/types/expected_keepers.go | 5 + 7 files changed, 83 insertions(+), 798 deletions(-) diff --git a/x/auth/ante/expected_keepers.go b/x/auth/ante/expected_keepers.go index f65dfb6d2d9a..f9e08cfe3b9e 100644 --- a/x/auth/ante/expected_keepers.go +++ b/x/auth/ante/expected_keepers.go @@ -8,6 +8,7 @@ import ( "cosmossdk.io/x/auth/types" sdk "github.com/cosmos/cosmos-sdk/types" + consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" ) // AccountKeeper defines the contract needed for AccountKeeper related APIs. @@ -26,3 +27,7 @@ type AccountKeeper interface { type FeegrantKeeper interface { UseGrantedFees(ctx context.Context, granter, grantee sdk.AccAddress, fee sdk.Coins, msgs []sdk.Msg) error } + +type ConsensusKeeper interface { + Params(context.Context, *consensustypes.QueryParamsRequest) (*consensustypes.QueryParamsResponse, error) +} diff --git a/x/gov/keeper/abci.go b/x/gov/keeper/abci.go index 1a9fc760cf06..1a5f9fa03385 100644 --- a/x/gov/keeper/abci.go +++ b/x/gov/keeper/abci.go @@ -222,7 +222,6 @@ func (k Keeper) EndBlocker(ctx context.Context) error { // once the regular voting period expires again, the tally is repeated // according to the regular proposal rules. proposal.ProposalType = v1.ProposalType_PROPOSAL_TYPE_STANDARD - proposal.Expedited = false // can be removed as never read but kept for state coherence params, err := k.Params.Get(ctx) if err != nil { return err diff --git a/x/gov/simulation/operations.go b/x/gov/simulation/operations.go index 6941bcc87d38..983a70ebc2fb 100644 --- a/x/gov/simulation/operations.go +++ b/x/gov/simulation/operations.go @@ -342,7 +342,9 @@ func SimulateMsgDeposit( return simtypes.NoOpMsg(types.ModuleName, TypeMsgDeposit, "unable to get proposal"), nil, err } - deposit, skip, err := randomDeposit(r, ctx, ak, bk, k, simAccount.Address, false, p.Expedited) + isExpedited := p.ProposalType == v1.ProposalType_PROPOSAL_TYPE_EXPEDITED + + deposit, skip, err := randomDeposit(r, ctx, ak, bk, k, simAccount.Address, false, isExpedited) switch { case skip: return simtypes.NoOpMsg(types.ModuleName, TypeMsgDeposit, "skip deposit"), nil, nil diff --git a/x/gov/testutil/expected_keepers.go b/x/gov/testutil/expected_keepers.go index b1b1a55c9add..987a7a895eb5 100644 --- a/x/gov/testutil/expected_keepers.go +++ b/x/gov/testutil/expected_keepers.go @@ -5,9 +5,8 @@ package testutil import ( "context" + addresscodec "cosmossdk.io/core/address" "cosmossdk.io/math" - bankkeeper "cosmossdk.io/x/bank/keeper" - "cosmossdk.io/x/gov/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -15,7 +14,15 @@ import ( // AccountKeeper extends gov's actual expected AccountKeeper with additional // methods used in tests. type AccountKeeper interface { - types.AccountKeeper + AddressCodec() addresscodec.Codec + + GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI + + GetModuleAddress(name string) sdk.AccAddress + GetModuleAccount(ctx context.Context, name string) sdk.ModuleAccountI + + // TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862 + SetModuleAccount(context.Context, sdk.ModuleAccountI) IterateAccounts(ctx context.Context, cb func(account sdk.AccountI) (stop bool)) } @@ -23,7 +30,15 @@ type AccountKeeper interface { // BankKeeper extends gov's actual expected BankKeeper with additional // methods used in tests. type BankKeeper interface { - bankkeeper.Keeper + GetAllBalances(ctx context.Context, addr sdk.AccAddress) sdk.Coins + GetBalance(ctx context.Context, addr sdk.AccAddress, denom string) sdk.Coin + MintCoins(ctx context.Context, moduleName string, amt sdk.Coins) error + BurnCoins(ctx context.Context, address []byte, amt sdk.Coins) error + LockedCoins(ctx context.Context, addr sdk.AccAddress) sdk.Coins + SpendableCoins(ctx context.Context, addr sdk.AccAddress) sdk.Coins + SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + SendCoinsFromModuleToModule(ctx context.Context, senderModule, recipientModule string, amt sdk.Coins) error + SendCoinsFromAccountToModule(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error } // PoolKeeper extends the gov's actual expected PoolKeeper. @@ -34,7 +49,17 @@ type PoolKeeper interface { // StakingKeeper extends gov's actual expected StakingKeeper with additional // methods used in tests. type StakingKeeper interface { - types.StakingKeeper + ValidatorAddressCodec() addresscodec.Codec + // iterate through bonded validators by operator address, execute func for each validator + IterateBondedValidatorsByPower( + context.Context, func(index int64, validator sdk.ValidatorI) (stop bool), + ) error + + TotalBondedTokens(context.Context) (math.Int, error) // total bonded tokens within the validator set + IterateDelegations( + ctx context.Context, delegator sdk.AccAddress, + fn func(index int64, delegation sdk.DelegationI) (stop bool), + ) error BondDenom(ctx context.Context) (string, error) TokensFromConsensusPower(ctx context.Context, power int64) math.Int diff --git a/x/gov/testutil/expected_keepers_mocks.go b/x/gov/testutil/expected_keepers_mocks.go index ce5ec75f8f5a..ea9e9e535bcb 100644 --- a/x/gov/testutil/expected_keepers_mocks.go +++ b/x/gov/testutil/expected_keepers_mocks.go @@ -10,10 +10,7 @@ import ( address "cosmossdk.io/core/address" math "cosmossdk.io/math" - keeper "cosmossdk.io/x/bank/keeper" - types "cosmossdk.io/x/bank/types" - types0 "github.com/cosmos/cosmos-sdk/types" - query "github.com/cosmos/cosmos-sdk/types/query" + types "github.com/cosmos/cosmos-sdk/types" gomock "github.com/golang/mock/gomock" ) @@ -55,10 +52,10 @@ func (mr *MockAccountKeeperMockRecorder) AddressCodec() *gomock.Call { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types0.AccAddress) types0.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types.AccAddress) types.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types0.AccountI) + ret0, _ := ret[0].(types.AccountI) return ret0 } @@ -69,10 +66,10 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo } // GetModuleAccount mocks base method. -func (m *MockAccountKeeper) GetModuleAccount(ctx context.Context, name string) types0.ModuleAccountI { +func (m *MockAccountKeeper) GetModuleAccount(ctx context.Context, name string) types.ModuleAccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetModuleAccount", ctx, name) - ret0, _ := ret[0].(types0.ModuleAccountI) + ret0, _ := ret[0].(types.ModuleAccountI) return ret0 } @@ -83,10 +80,10 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAccount(ctx, name interface{}) } // GetModuleAddress mocks base method. -func (m *MockAccountKeeper) GetModuleAddress(name string) types0.AccAddress { +func (m *MockAccountKeeper) GetModuleAddress(name string) types.AccAddress { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetModuleAddress", name) - ret0, _ := ret[0].(types0.AccAddress) + ret0, _ := ret[0].(types.AccAddress) return ret0 } @@ -97,7 +94,7 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(name interface{}) *gom } // IterateAccounts mocks base method. -func (m *MockAccountKeeper) IterateAccounts(ctx context.Context, cb func(types0.AccountI) bool) { +func (m *MockAccountKeeper) IterateAccounts(ctx context.Context, cb func(types.AccountI) bool) { m.ctrl.T.Helper() m.ctrl.Call(m, "IterateAccounts", ctx, cb) } @@ -109,7 +106,7 @@ func (mr *MockAccountKeeperMockRecorder) IterateAccounts(ctx, cb interface{}) *g } // SetModuleAccount mocks base method. -func (m *MockAccountKeeper) SetModuleAccount(arg0 context.Context, arg1 types0.ModuleAccountI) { +func (m *MockAccountKeeper) SetModuleAccount(arg0 context.Context, arg1 types.ModuleAccountI) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetModuleAccount", arg0, arg1) } @@ -143,64 +140,8 @@ func (m *MockBankKeeper) EXPECT() *MockBankKeeperMockRecorder { return m.recorder } -// AllBalances mocks base method. -func (m *MockBankKeeper) AllBalances(arg0 context.Context, arg1 *types.QueryAllBalancesRequest) (*types.QueryAllBalancesResponse, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "AllBalances", arg0, arg1) - ret0, _ := ret[0].(*types.QueryAllBalancesResponse) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// AllBalances indicates an expected call of AllBalances. -func (mr *MockBankKeeperMockRecorder) AllBalances(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AllBalances", reflect.TypeOf((*MockBankKeeper)(nil).AllBalances), arg0, arg1) -} - -// AppendSendRestriction mocks base method. -func (m *MockBankKeeper) AppendSendRestriction(restriction types.SendRestrictionFn) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "AppendSendRestriction", restriction) -} - -// AppendSendRestriction indicates an expected call of AppendSendRestriction. -func (mr *MockBankKeeperMockRecorder) AppendSendRestriction(restriction interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AppendSendRestriction", reflect.TypeOf((*MockBankKeeper)(nil).AppendSendRestriction), restriction) -} - -// Balance mocks base method. -func (m *MockBankKeeper) Balance(arg0 context.Context, arg1 *types.QueryBalanceRequest) (*types.QueryBalanceResponse, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Balance", arg0, arg1) - ret0, _ := ret[0].(*types.QueryBalanceResponse) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Balance indicates an expected call of Balance. -func (mr *MockBankKeeperMockRecorder) Balance(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Balance", reflect.TypeOf((*MockBankKeeper)(nil).Balance), arg0, arg1) -} - -// BlockedAddr mocks base method. -func (m *MockBankKeeper) BlockedAddr(addr types0.AccAddress) bool { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "BlockedAddr", addr) - ret0, _ := ret[0].(bool) - return ret0 -} - -// BlockedAddr indicates an expected call of BlockedAddr. -func (mr *MockBankKeeperMockRecorder) BlockedAddr(addr interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BlockedAddr", reflect.TypeOf((*MockBankKeeper)(nil).BlockedAddr), addr) -} - // BurnCoins mocks base method. -func (m *MockBankKeeper) BurnCoins(ctx context.Context, address []byte, amt types0.Coins) error { +func (m *MockBankKeeper) BurnCoins(ctx context.Context, address []byte, amt types.Coins) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "BurnCoins", ctx, address, amt) ret0, _ := ret[0].(error) @@ -213,172 +154,11 @@ func (mr *MockBankKeeperMockRecorder) BurnCoins(ctx, address, amt interface{}) * return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BurnCoins", reflect.TypeOf((*MockBankKeeper)(nil).BurnCoins), ctx, address, amt) } -// ClearSendRestriction mocks base method. -func (m *MockBankKeeper) ClearSendRestriction() { - m.ctrl.T.Helper() - m.ctrl.Call(m, "ClearSendRestriction") -} - -// ClearSendRestriction indicates an expected call of ClearSendRestriction. -func (mr *MockBankKeeperMockRecorder) ClearSendRestriction() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ClearSendRestriction", reflect.TypeOf((*MockBankKeeper)(nil).ClearSendRestriction)) -} - -// DelegateCoins mocks base method. -func (m *MockBankKeeper) DelegateCoins(ctx context.Context, delegatorAddr, moduleAccAddr types0.AccAddress, amt types0.Coins) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DelegateCoins", ctx, delegatorAddr, moduleAccAddr, amt) - ret0, _ := ret[0].(error) - return ret0 -} - -// DelegateCoins indicates an expected call of DelegateCoins. -func (mr *MockBankKeeperMockRecorder) DelegateCoins(ctx, delegatorAddr, moduleAccAddr, amt interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DelegateCoins", reflect.TypeOf((*MockBankKeeper)(nil).DelegateCoins), ctx, delegatorAddr, moduleAccAddr, amt) -} - -// DelegateCoinsFromAccountToModule mocks base method. -func (m *MockBankKeeper) DelegateCoinsFromAccountToModule(ctx context.Context, senderAddr types0.AccAddress, recipientModule string, amt types0.Coins) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DelegateCoinsFromAccountToModule", ctx, senderAddr, recipientModule, amt) - ret0, _ := ret[0].(error) - return ret0 -} - -// DelegateCoinsFromAccountToModule indicates an expected call of DelegateCoinsFromAccountToModule. -func (mr *MockBankKeeperMockRecorder) DelegateCoinsFromAccountToModule(ctx, senderAddr, recipientModule, amt interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DelegateCoinsFromAccountToModule", reflect.TypeOf((*MockBankKeeper)(nil).DelegateCoinsFromAccountToModule), ctx, senderAddr, recipientModule, amt) -} - -// DeleteSendEnabled mocks base method. -func (m *MockBankKeeper) DeleteSendEnabled(ctx context.Context, denoms ...string) { - m.ctrl.T.Helper() - varargs := []interface{}{ctx} - for _, a := range denoms { - varargs = append(varargs, a) - } - m.ctrl.Call(m, "DeleteSendEnabled", varargs...) -} - -// DeleteSendEnabled indicates an expected call of DeleteSendEnabled. -func (mr *MockBankKeeperMockRecorder) DeleteSendEnabled(ctx interface{}, denoms ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx}, denoms...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteSendEnabled", reflect.TypeOf((*MockBankKeeper)(nil).DeleteSendEnabled), varargs...) -} - -// DenomMetadata mocks base method. -func (m *MockBankKeeper) DenomMetadata(arg0 context.Context, arg1 *types.QueryDenomMetadataRequest) (*types.QueryDenomMetadataResponse, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DenomMetadata", arg0, arg1) - ret0, _ := ret[0].(*types.QueryDenomMetadataResponse) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// DenomMetadata indicates an expected call of DenomMetadata. -func (mr *MockBankKeeperMockRecorder) DenomMetadata(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DenomMetadata", reflect.TypeOf((*MockBankKeeper)(nil).DenomMetadata), arg0, arg1) -} - -// DenomMetadataByQueryString mocks base method. -func (m *MockBankKeeper) DenomMetadataByQueryString(arg0 context.Context, arg1 *types.QueryDenomMetadataByQueryStringRequest) (*types.QueryDenomMetadataByQueryStringResponse, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DenomMetadataByQueryString", arg0, arg1) - ret0, _ := ret[0].(*types.QueryDenomMetadataByQueryStringResponse) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// DenomMetadataByQueryString indicates an expected call of DenomMetadataByQueryString. -func (mr *MockBankKeeperMockRecorder) DenomMetadataByQueryString(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DenomMetadataByQueryString", reflect.TypeOf((*MockBankKeeper)(nil).DenomMetadataByQueryString), arg0, arg1) -} - -// DenomOwners mocks base method. -func (m *MockBankKeeper) DenomOwners(arg0 context.Context, arg1 *types.QueryDenomOwnersRequest) (*types.QueryDenomOwnersResponse, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DenomOwners", arg0, arg1) - ret0, _ := ret[0].(*types.QueryDenomOwnersResponse) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// DenomOwners indicates an expected call of DenomOwners. -func (mr *MockBankKeeperMockRecorder) DenomOwners(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DenomOwners", reflect.TypeOf((*MockBankKeeper)(nil).DenomOwners), arg0, arg1) -} - -// DenomOwnersByQuery mocks base method. -func (m *MockBankKeeper) DenomOwnersByQuery(arg0 context.Context, arg1 *types.QueryDenomOwnersByQueryRequest) (*types.QueryDenomOwnersByQueryResponse, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DenomOwnersByQuery", arg0, arg1) - ret0, _ := ret[0].(*types.QueryDenomOwnersByQueryResponse) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// DenomOwnersByQuery indicates an expected call of DenomOwnersByQuery. -func (mr *MockBankKeeperMockRecorder) DenomOwnersByQuery(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DenomOwnersByQuery", reflect.TypeOf((*MockBankKeeper)(nil).DenomOwnersByQuery), arg0, arg1) -} - -// DenomsMetadata mocks base method. -func (m *MockBankKeeper) DenomsMetadata(arg0 context.Context, arg1 *types.QueryDenomsMetadataRequest) (*types.QueryDenomsMetadataResponse, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DenomsMetadata", arg0, arg1) - ret0, _ := ret[0].(*types.QueryDenomsMetadataResponse) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// DenomsMetadata indicates an expected call of DenomsMetadata. -func (mr *MockBankKeeperMockRecorder) DenomsMetadata(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DenomsMetadata", reflect.TypeOf((*MockBankKeeper)(nil).DenomsMetadata), arg0, arg1) -} - -// ExportGenesis mocks base method. -func (m *MockBankKeeper) ExportGenesis(arg0 context.Context) (*types.GenesisState, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ExportGenesis", arg0) - ret0, _ := ret[0].(*types.GenesisState) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// ExportGenesis indicates an expected call of ExportGenesis. -func (mr *MockBankKeeperMockRecorder) ExportGenesis(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExportGenesis", reflect.TypeOf((*MockBankKeeper)(nil).ExportGenesis), arg0) -} - -// GetAccountsBalances mocks base method. -func (m *MockBankKeeper) GetAccountsBalances(ctx context.Context) []types.Balance { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetAccountsBalances", ctx) - ret0, _ := ret[0].([]types.Balance) - return ret0 -} - -// GetAccountsBalances indicates an expected call of GetAccountsBalances. -func (mr *MockBankKeeperMockRecorder) GetAccountsBalances(ctx interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountsBalances", reflect.TypeOf((*MockBankKeeper)(nil).GetAccountsBalances), ctx) -} - // GetAllBalances mocks base method. -func (m *MockBankKeeper) GetAllBalances(ctx context.Context, addr types0.AccAddress) types0.Coins { +func (m *MockBankKeeper) GetAllBalances(ctx context.Context, addr types.AccAddress) types.Coins { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAllBalances", ctx, addr) - ret0, _ := ret[0].(types0.Coins) + ret0, _ := ret[0].(types.Coins) return ret0 } @@ -388,53 +168,11 @@ func (mr *MockBankKeeperMockRecorder) GetAllBalances(ctx, addr interface{}) *gom return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllBalances", reflect.TypeOf((*MockBankKeeper)(nil).GetAllBalances), ctx, addr) } -// GetAllDenomMetaData mocks base method. -func (m *MockBankKeeper) GetAllDenomMetaData(ctx context.Context) []types.Metadata { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetAllDenomMetaData", ctx) - ret0, _ := ret[0].([]types.Metadata) - return ret0 -} - -// GetAllDenomMetaData indicates an expected call of GetAllDenomMetaData. -func (mr *MockBankKeeperMockRecorder) GetAllDenomMetaData(ctx interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllDenomMetaData", reflect.TypeOf((*MockBankKeeper)(nil).GetAllDenomMetaData), ctx) -} - -// GetAllSendEnabledEntries mocks base method. -func (m *MockBankKeeper) GetAllSendEnabledEntries(ctx context.Context) []types.SendEnabled { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetAllSendEnabledEntries", ctx) - ret0, _ := ret[0].([]types.SendEnabled) - return ret0 -} - -// GetAllSendEnabledEntries indicates an expected call of GetAllSendEnabledEntries. -func (mr *MockBankKeeperMockRecorder) GetAllSendEnabledEntries(ctx interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllSendEnabledEntries", reflect.TypeOf((*MockBankKeeper)(nil).GetAllSendEnabledEntries), ctx) -} - -// GetAuthority mocks base method. -func (m *MockBankKeeper) GetAuthority() string { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetAuthority") - ret0, _ := ret[0].(string) - return ret0 -} - -// GetAuthority indicates an expected call of GetAuthority. -func (mr *MockBankKeeperMockRecorder) GetAuthority() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAuthority", reflect.TypeOf((*MockBankKeeper)(nil).GetAuthority)) -} - // GetBalance mocks base method. -func (m *MockBankKeeper) GetBalance(ctx context.Context, addr types0.AccAddress, denom string) types0.Coin { +func (m *MockBankKeeper) GetBalance(ctx context.Context, addr types.AccAddress, denom string) types.Coin { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetBalance", ctx, addr, denom) - ret0, _ := ret[0].(types0.Coin) + ret0, _ := ret[0].(types.Coin) return ret0 } @@ -444,276 +182,11 @@ func (mr *MockBankKeeperMockRecorder) GetBalance(ctx, addr, denom interface{}) * return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBalance", reflect.TypeOf((*MockBankKeeper)(nil).GetBalance), ctx, addr, denom) } -// GetBlockedAddresses mocks base method. -func (m *MockBankKeeper) GetBlockedAddresses() map[string]bool { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetBlockedAddresses") - ret0, _ := ret[0].(map[string]bool) - return ret0 -} - -// GetBlockedAddresses indicates an expected call of GetBlockedAddresses. -func (mr *MockBankKeeperMockRecorder) GetBlockedAddresses() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBlockedAddresses", reflect.TypeOf((*MockBankKeeper)(nil).GetBlockedAddresses)) -} - -// GetDenomMetaData mocks base method. -func (m *MockBankKeeper) GetDenomMetaData(ctx context.Context, denom string) (types.Metadata, bool) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetDenomMetaData", ctx, denom) - ret0, _ := ret[0].(types.Metadata) - ret1, _ := ret[1].(bool) - return ret0, ret1 -} - -// GetDenomMetaData indicates an expected call of GetDenomMetaData. -func (mr *MockBankKeeperMockRecorder) GetDenomMetaData(ctx, denom interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDenomMetaData", reflect.TypeOf((*MockBankKeeper)(nil).GetDenomMetaData), ctx, denom) -} - -// GetPaginatedTotalSupply mocks base method. -func (m *MockBankKeeper) GetPaginatedTotalSupply(ctx context.Context, pagination *query.PageRequest) (types0.Coins, *query.PageResponse, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetPaginatedTotalSupply", ctx, pagination) - ret0, _ := ret[0].(types0.Coins) - ret1, _ := ret[1].(*query.PageResponse) - ret2, _ := ret[2].(error) - return ret0, ret1, ret2 -} - -// GetPaginatedTotalSupply indicates an expected call of GetPaginatedTotalSupply. -func (mr *MockBankKeeperMockRecorder) GetPaginatedTotalSupply(ctx, pagination interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPaginatedTotalSupply", reflect.TypeOf((*MockBankKeeper)(nil).GetPaginatedTotalSupply), ctx, pagination) -} - -// GetParams mocks base method. -func (m *MockBankKeeper) GetParams(ctx context.Context) types.Params { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetParams", ctx) - ret0, _ := ret[0].(types.Params) - return ret0 -} - -// GetParams indicates an expected call of GetParams. -func (mr *MockBankKeeperMockRecorder) GetParams(ctx interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetParams", reflect.TypeOf((*MockBankKeeper)(nil).GetParams), ctx) -} - -// GetSendEnabledEntry mocks base method. -func (m *MockBankKeeper) GetSendEnabledEntry(ctx context.Context, denom string) (types.SendEnabled, bool) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetSendEnabledEntry", ctx, denom) - ret0, _ := ret[0].(types.SendEnabled) - ret1, _ := ret[1].(bool) - return ret0, ret1 -} - -// GetSendEnabledEntry indicates an expected call of GetSendEnabledEntry. -func (mr *MockBankKeeperMockRecorder) GetSendEnabledEntry(ctx, denom interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSendEnabledEntry", reflect.TypeOf((*MockBankKeeper)(nil).GetSendEnabledEntry), ctx, denom) -} - -// GetSupply mocks base method. -func (m *MockBankKeeper) GetSupply(ctx context.Context, denom string) types0.Coin { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetSupply", ctx, denom) - ret0, _ := ret[0].(types0.Coin) - return ret0 -} - -// GetSupply indicates an expected call of GetSupply. -func (mr *MockBankKeeperMockRecorder) GetSupply(ctx, denom interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSupply", reflect.TypeOf((*MockBankKeeper)(nil).GetSupply), ctx, denom) -} - -// HasBalance mocks base method. -func (m *MockBankKeeper) HasBalance(ctx context.Context, addr types0.AccAddress, amt types0.Coin) bool { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "HasBalance", ctx, addr, amt) - ret0, _ := ret[0].(bool) - return ret0 -} - -// HasBalance indicates an expected call of HasBalance. -func (mr *MockBankKeeperMockRecorder) HasBalance(ctx, addr, amt interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasBalance", reflect.TypeOf((*MockBankKeeper)(nil).HasBalance), ctx, addr, amt) -} - -// HasDenomMetaData mocks base method. -func (m *MockBankKeeper) HasDenomMetaData(ctx context.Context, denom string) bool { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "HasDenomMetaData", ctx, denom) - ret0, _ := ret[0].(bool) - return ret0 -} - -// HasDenomMetaData indicates an expected call of HasDenomMetaData. -func (mr *MockBankKeeperMockRecorder) HasDenomMetaData(ctx, denom interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasDenomMetaData", reflect.TypeOf((*MockBankKeeper)(nil).HasDenomMetaData), ctx, denom) -} - -// HasSupply mocks base method. -func (m *MockBankKeeper) HasSupply(ctx context.Context, denom string) bool { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "HasSupply", ctx, denom) - ret0, _ := ret[0].(bool) - return ret0 -} - -// HasSupply indicates an expected call of HasSupply. -func (mr *MockBankKeeperMockRecorder) HasSupply(ctx, denom interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasSupply", reflect.TypeOf((*MockBankKeeper)(nil).HasSupply), ctx, denom) -} - -// InitGenesis mocks base method. -func (m *MockBankKeeper) InitGenesis(arg0 context.Context, arg1 *types.GenesisState) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "InitGenesis", arg0, arg1) - ret0, _ := ret[0].(error) - return ret0 -} - -// InitGenesis indicates an expected call of InitGenesis. -func (mr *MockBankKeeperMockRecorder) InitGenesis(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InitGenesis", reflect.TypeOf((*MockBankKeeper)(nil).InitGenesis), arg0, arg1) -} - -// InputOutputCoins mocks base method. -func (m *MockBankKeeper) InputOutputCoins(ctx context.Context, input types.Input, outputs []types.Output) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "InputOutputCoins", ctx, input, outputs) - ret0, _ := ret[0].(error) - return ret0 -} - -// InputOutputCoins indicates an expected call of InputOutputCoins. -func (mr *MockBankKeeperMockRecorder) InputOutputCoins(ctx, input, outputs interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InputOutputCoins", reflect.TypeOf((*MockBankKeeper)(nil).InputOutputCoins), ctx, input, outputs) -} - -// IsSendEnabledCoin mocks base method. -func (m *MockBankKeeper) IsSendEnabledCoin(ctx context.Context, coin types0.Coin) bool { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "IsSendEnabledCoin", ctx, coin) - ret0, _ := ret[0].(bool) - return ret0 -} - -// IsSendEnabledCoin indicates an expected call of IsSendEnabledCoin. -func (mr *MockBankKeeperMockRecorder) IsSendEnabledCoin(ctx, coin interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsSendEnabledCoin", reflect.TypeOf((*MockBankKeeper)(nil).IsSendEnabledCoin), ctx, coin) -} - -// IsSendEnabledCoins mocks base method. -func (m *MockBankKeeper) IsSendEnabledCoins(ctx context.Context, coins ...types0.Coin) error { - m.ctrl.T.Helper() - varargs := []interface{}{ctx} - for _, a := range coins { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "IsSendEnabledCoins", varargs...) - ret0, _ := ret[0].(error) - return ret0 -} - -// IsSendEnabledCoins indicates an expected call of IsSendEnabledCoins. -func (mr *MockBankKeeperMockRecorder) IsSendEnabledCoins(ctx interface{}, coins ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx}, coins...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsSendEnabledCoins", reflect.TypeOf((*MockBankKeeper)(nil).IsSendEnabledCoins), varargs...) -} - -// IsSendEnabledDenom mocks base method. -func (m *MockBankKeeper) IsSendEnabledDenom(ctx context.Context, denom string) bool { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "IsSendEnabledDenom", ctx, denom) - ret0, _ := ret[0].(bool) - return ret0 -} - -// IsSendEnabledDenom indicates an expected call of IsSendEnabledDenom. -func (mr *MockBankKeeperMockRecorder) IsSendEnabledDenom(ctx, denom interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsSendEnabledDenom", reflect.TypeOf((*MockBankKeeper)(nil).IsSendEnabledDenom), ctx, denom) -} - -// IterateAccountBalances mocks base method. -func (m *MockBankKeeper) IterateAccountBalances(ctx context.Context, addr types0.AccAddress, cb func(types0.Coin) bool) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "IterateAccountBalances", ctx, addr, cb) -} - -// IterateAccountBalances indicates an expected call of IterateAccountBalances. -func (mr *MockBankKeeperMockRecorder) IterateAccountBalances(ctx, addr, cb interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IterateAccountBalances", reflect.TypeOf((*MockBankKeeper)(nil).IterateAccountBalances), ctx, addr, cb) -} - -// IterateAllBalances mocks base method. -func (m *MockBankKeeper) IterateAllBalances(ctx context.Context, cb func(types0.AccAddress, types0.Coin) bool) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "IterateAllBalances", ctx, cb) -} - -// IterateAllBalances indicates an expected call of IterateAllBalances. -func (mr *MockBankKeeperMockRecorder) IterateAllBalances(ctx, cb interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IterateAllBalances", reflect.TypeOf((*MockBankKeeper)(nil).IterateAllBalances), ctx, cb) -} - -// IterateAllDenomMetaData mocks base method. -func (m *MockBankKeeper) IterateAllDenomMetaData(ctx context.Context, cb func(types.Metadata) bool) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "IterateAllDenomMetaData", ctx, cb) -} - -// IterateAllDenomMetaData indicates an expected call of IterateAllDenomMetaData. -func (mr *MockBankKeeperMockRecorder) IterateAllDenomMetaData(ctx, cb interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IterateAllDenomMetaData", reflect.TypeOf((*MockBankKeeper)(nil).IterateAllDenomMetaData), ctx, cb) -} - -// IterateSendEnabledEntries mocks base method. -func (m *MockBankKeeper) IterateSendEnabledEntries(ctx context.Context, cb func(string, bool) bool) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "IterateSendEnabledEntries", ctx, cb) -} - -// IterateSendEnabledEntries indicates an expected call of IterateSendEnabledEntries. -func (mr *MockBankKeeperMockRecorder) IterateSendEnabledEntries(ctx, cb interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IterateSendEnabledEntries", reflect.TypeOf((*MockBankKeeper)(nil).IterateSendEnabledEntries), ctx, cb) -} - -// IterateTotalSupply mocks base method. -func (m *MockBankKeeper) IterateTotalSupply(ctx context.Context, cb func(types0.Coin) bool) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "IterateTotalSupply", ctx, cb) -} - -// IterateTotalSupply indicates an expected call of IterateTotalSupply. -func (mr *MockBankKeeperMockRecorder) IterateTotalSupply(ctx, cb interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IterateTotalSupply", reflect.TypeOf((*MockBankKeeper)(nil).IterateTotalSupply), ctx, cb) -} - // LockedCoins mocks base method. -func (m *MockBankKeeper) LockedCoins(ctx context.Context, addr types0.AccAddress) types0.Coins { +func (m *MockBankKeeper) LockedCoins(ctx context.Context, addr types.AccAddress) types.Coins { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "LockedCoins", ctx, addr) - ret0, _ := ret[0].(types0.Coins) + ret0, _ := ret[0].(types.Coins) return ret0 } @@ -724,7 +197,7 @@ func (mr *MockBankKeeperMockRecorder) LockedCoins(ctx, addr interface{}) *gomock } // MintCoins mocks base method. -func (m *MockBankKeeper) MintCoins(ctx context.Context, moduleName string, amt types0.Coins) error { +func (m *MockBankKeeper) MintCoins(ctx context.Context, moduleName string, amt types.Coins) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "MintCoins", ctx, moduleName, amt) ret0, _ := ret[0].(error) @@ -737,49 +210,8 @@ func (mr *MockBankKeeperMockRecorder) MintCoins(ctx, moduleName, amt interface{} return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MintCoins", reflect.TypeOf((*MockBankKeeper)(nil).MintCoins), ctx, moduleName, amt) } -// Params mocks base method. -func (m *MockBankKeeper) Params(arg0 context.Context, arg1 *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Params", arg0, arg1) - ret0, _ := ret[0].(*types.QueryParamsResponse) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Params indicates an expected call of Params. -func (mr *MockBankKeeperMockRecorder) Params(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Params", reflect.TypeOf((*MockBankKeeper)(nil).Params), arg0, arg1) -} - -// PrependSendRestriction mocks base method. -func (m *MockBankKeeper) PrependSendRestriction(restriction types.SendRestrictionFn) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "PrependSendRestriction", restriction) -} - -// PrependSendRestriction indicates an expected call of PrependSendRestriction. -func (mr *MockBankKeeperMockRecorder) PrependSendRestriction(restriction interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PrependSendRestriction", reflect.TypeOf((*MockBankKeeper)(nil).PrependSendRestriction), restriction) -} - -// SendCoins mocks base method. -func (m *MockBankKeeper) SendCoins(ctx context.Context, fromAddr, toAddr types0.AccAddress, amt types0.Coins) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SendCoins", ctx, fromAddr, toAddr, amt) - ret0, _ := ret[0].(error) - return ret0 -} - -// SendCoins indicates an expected call of SendCoins. -func (mr *MockBankKeeperMockRecorder) SendCoins(ctx, fromAddr, toAddr, amt interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendCoins", reflect.TypeOf((*MockBankKeeper)(nil).SendCoins), ctx, fromAddr, toAddr, amt) -} - // SendCoinsFromAccountToModule mocks base method. -func (m *MockBankKeeper) SendCoinsFromAccountToModule(ctx context.Context, senderAddr types0.AccAddress, recipientModule string, amt types0.Coins) error { +func (m *MockBankKeeper) SendCoinsFromAccountToModule(ctx context.Context, senderAddr types.AccAddress, recipientModule string, amt types.Coins) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SendCoinsFromAccountToModule", ctx, senderAddr, recipientModule, amt) ret0, _ := ret[0].(error) @@ -793,7 +225,7 @@ func (mr *MockBankKeeperMockRecorder) SendCoinsFromAccountToModule(ctx, senderAd } // SendCoinsFromModuleToAccount mocks base method. -func (m *MockBankKeeper) SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr types0.AccAddress, amt types0.Coins) error { +func (m *MockBankKeeper) SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr types.AccAddress, amt types.Coins) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SendCoinsFromModuleToAccount", ctx, senderModule, recipientAddr, amt) ret0, _ := ret[0].(error) @@ -807,7 +239,7 @@ func (mr *MockBankKeeperMockRecorder) SendCoinsFromModuleToAccount(ctx, senderMo } // SendCoinsFromModuleToModule mocks base method. -func (m *MockBankKeeper) SendCoinsFromModuleToModule(ctx context.Context, senderModule, recipientModule string, amt types0.Coins) error { +func (m *MockBankKeeper) SendCoinsFromModuleToModule(ctx context.Context, senderModule, recipientModule string, amt types.Coins) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SendCoinsFromModuleToModule", ctx, senderModule, recipientModule, amt) ret0, _ := ret[0].(error) @@ -820,120 +252,11 @@ func (mr *MockBankKeeperMockRecorder) SendCoinsFromModuleToModule(ctx, senderMod return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendCoinsFromModuleToModule", reflect.TypeOf((*MockBankKeeper)(nil).SendCoinsFromModuleToModule), ctx, senderModule, recipientModule, amt) } -// SendEnabled mocks base method. -func (m *MockBankKeeper) SendEnabled(arg0 context.Context, arg1 *types.QuerySendEnabledRequest) (*types.QuerySendEnabledResponse, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SendEnabled", arg0, arg1) - ret0, _ := ret[0].(*types.QuerySendEnabledResponse) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// SendEnabled indicates an expected call of SendEnabled. -func (mr *MockBankKeeperMockRecorder) SendEnabled(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendEnabled", reflect.TypeOf((*MockBankKeeper)(nil).SendEnabled), arg0, arg1) -} - -// SetAllSendEnabled mocks base method. -func (m *MockBankKeeper) SetAllSendEnabled(ctx context.Context, sendEnableds []*types.SendEnabled) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "SetAllSendEnabled", ctx, sendEnableds) -} - -// SetAllSendEnabled indicates an expected call of SetAllSendEnabled. -func (mr *MockBankKeeperMockRecorder) SetAllSendEnabled(ctx, sendEnableds interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetAllSendEnabled", reflect.TypeOf((*MockBankKeeper)(nil).SetAllSendEnabled), ctx, sendEnableds) -} - -// SetDenomMetaData mocks base method. -func (m *MockBankKeeper) SetDenomMetaData(ctx context.Context, denomMetaData types.Metadata) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "SetDenomMetaData", ctx, denomMetaData) -} - -// SetDenomMetaData indicates an expected call of SetDenomMetaData. -func (mr *MockBankKeeperMockRecorder) SetDenomMetaData(ctx, denomMetaData interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetDenomMetaData", reflect.TypeOf((*MockBankKeeper)(nil).SetDenomMetaData), ctx, denomMetaData) -} - -// SetParams mocks base method. -func (m *MockBankKeeper) SetParams(ctx context.Context, params types.Params) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetParams", ctx, params) - ret0, _ := ret[0].(error) - return ret0 -} - -// SetParams indicates an expected call of SetParams. -func (mr *MockBankKeeperMockRecorder) SetParams(ctx, params interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetParams", reflect.TypeOf((*MockBankKeeper)(nil).SetParams), ctx, params) -} - -// SetSendEnabled mocks base method. -func (m *MockBankKeeper) SetSendEnabled(ctx context.Context, denom string, value bool) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "SetSendEnabled", ctx, denom, value) -} - -// SetSendEnabled indicates an expected call of SetSendEnabled. -func (mr *MockBankKeeperMockRecorder) SetSendEnabled(ctx, denom, value interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetSendEnabled", reflect.TypeOf((*MockBankKeeper)(nil).SetSendEnabled), ctx, denom, value) -} - -// SpendableBalanceByDenom mocks base method. -func (m *MockBankKeeper) SpendableBalanceByDenom(arg0 context.Context, arg1 *types.QuerySpendableBalanceByDenomRequest) (*types.QuerySpendableBalanceByDenomResponse, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SpendableBalanceByDenom", arg0, arg1) - ret0, _ := ret[0].(*types.QuerySpendableBalanceByDenomResponse) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// SpendableBalanceByDenom indicates an expected call of SpendableBalanceByDenom. -func (mr *MockBankKeeperMockRecorder) SpendableBalanceByDenom(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpendableBalanceByDenom", reflect.TypeOf((*MockBankKeeper)(nil).SpendableBalanceByDenom), arg0, arg1) -} - -// SpendableBalances mocks base method. -func (m *MockBankKeeper) SpendableBalances(arg0 context.Context, arg1 *types.QuerySpendableBalancesRequest) (*types.QuerySpendableBalancesResponse, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SpendableBalances", arg0, arg1) - ret0, _ := ret[0].(*types.QuerySpendableBalancesResponse) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// SpendableBalances indicates an expected call of SpendableBalances. -func (mr *MockBankKeeperMockRecorder) SpendableBalances(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpendableBalances", reflect.TypeOf((*MockBankKeeper)(nil).SpendableBalances), arg0, arg1) -} - -// SpendableCoin mocks base method. -func (m *MockBankKeeper) SpendableCoin(ctx context.Context, addr types0.AccAddress, denom string) types0.Coin { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SpendableCoin", ctx, addr, denom) - ret0, _ := ret[0].(types0.Coin) - return ret0 -} - -// SpendableCoin indicates an expected call of SpendableCoin. -func (mr *MockBankKeeperMockRecorder) SpendableCoin(ctx, addr, denom interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpendableCoin", reflect.TypeOf((*MockBankKeeper)(nil).SpendableCoin), ctx, addr, denom) -} - // SpendableCoins mocks base method. -func (m *MockBankKeeper) SpendableCoins(ctx context.Context, addr types0.AccAddress) types0.Coins { +func (m *MockBankKeeper) SpendableCoins(ctx context.Context, addr types.AccAddress) types.Coins { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SpendableCoins", ctx, addr) - ret0, _ := ret[0].(types0.Coins) + ret0, _ := ret[0].(types.Coins) return ret0 } @@ -943,92 +266,6 @@ func (mr *MockBankKeeperMockRecorder) SpendableCoins(ctx, addr interface{}) *gom return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpendableCoins", reflect.TypeOf((*MockBankKeeper)(nil).SpendableCoins), ctx, addr) } -// SupplyOf mocks base method. -func (m *MockBankKeeper) SupplyOf(arg0 context.Context, arg1 *types.QuerySupplyOfRequest) (*types.QuerySupplyOfResponse, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SupplyOf", arg0, arg1) - ret0, _ := ret[0].(*types.QuerySupplyOfResponse) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// SupplyOf indicates an expected call of SupplyOf. -func (mr *MockBankKeeperMockRecorder) SupplyOf(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SupplyOf", reflect.TypeOf((*MockBankKeeper)(nil).SupplyOf), arg0, arg1) -} - -// TotalSupply mocks base method. -func (m *MockBankKeeper) TotalSupply(arg0 context.Context, arg1 *types.QueryTotalSupplyRequest) (*types.QueryTotalSupplyResponse, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "TotalSupply", arg0, arg1) - ret0, _ := ret[0].(*types.QueryTotalSupplyResponse) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// TotalSupply indicates an expected call of TotalSupply. -func (mr *MockBankKeeperMockRecorder) TotalSupply(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TotalSupply", reflect.TypeOf((*MockBankKeeper)(nil).TotalSupply), arg0, arg1) -} - -// UndelegateCoins mocks base method. -func (m *MockBankKeeper) UndelegateCoins(ctx context.Context, moduleAccAddr, delegatorAddr types0.AccAddress, amt types0.Coins) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "UndelegateCoins", ctx, moduleAccAddr, delegatorAddr, amt) - ret0, _ := ret[0].(error) - return ret0 -} - -// UndelegateCoins indicates an expected call of UndelegateCoins. -func (mr *MockBankKeeperMockRecorder) UndelegateCoins(ctx, moduleAccAddr, delegatorAddr, amt interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UndelegateCoins", reflect.TypeOf((*MockBankKeeper)(nil).UndelegateCoins), ctx, moduleAccAddr, delegatorAddr, amt) -} - -// UndelegateCoinsFromModuleToAccount mocks base method. -func (m *MockBankKeeper) UndelegateCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr types0.AccAddress, amt types0.Coins) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "UndelegateCoinsFromModuleToAccount", ctx, senderModule, recipientAddr, amt) - ret0, _ := ret[0].(error) - return ret0 -} - -// UndelegateCoinsFromModuleToAccount indicates an expected call of UndelegateCoinsFromModuleToAccount. -func (mr *MockBankKeeperMockRecorder) UndelegateCoinsFromModuleToAccount(ctx, senderModule, recipientAddr, amt interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UndelegateCoinsFromModuleToAccount", reflect.TypeOf((*MockBankKeeper)(nil).UndelegateCoinsFromModuleToAccount), ctx, senderModule, recipientAddr, amt) -} - -// ValidateBalance mocks base method. -func (m *MockBankKeeper) ValidateBalance(ctx context.Context, addr types0.AccAddress) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ValidateBalance", ctx, addr) - ret0, _ := ret[0].(error) - return ret0 -} - -// ValidateBalance indicates an expected call of ValidateBalance. -func (mr *MockBankKeeperMockRecorder) ValidateBalance(ctx, addr interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidateBalance", reflect.TypeOf((*MockBankKeeper)(nil).ValidateBalance), ctx, addr) -} - -// WithMintCoinsRestriction mocks base method. -func (m *MockBankKeeper) WithMintCoinsRestriction(arg0 types.MintingRestrictionFn) keeper.BaseKeeper { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WithMintCoinsRestriction", arg0) - ret0, _ := ret[0].(keeper.BaseKeeper) - return ret0 -} - -// WithMintCoinsRestriction indicates an expected call of WithMintCoinsRestriction. -func (mr *MockBankKeeperMockRecorder) WithMintCoinsRestriction(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WithMintCoinsRestriction", reflect.TypeOf((*MockBankKeeper)(nil).WithMintCoinsRestriction), arg0) -} - // MockPoolKeeper is a mock of PoolKeeper interface. type MockPoolKeeper struct { ctrl *gomock.Controller @@ -1053,7 +290,7 @@ func (m *MockPoolKeeper) EXPECT() *MockPoolKeeperMockRecorder { } // FundCommunityPool mocks base method. -func (m *MockPoolKeeper) FundCommunityPool(ctx context.Context, amount types0.Coins, sender types0.AccAddress) error { +func (m *MockPoolKeeper) FundCommunityPool(ctx context.Context, amount types.Coins, sender types.AccAddress) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "FundCommunityPool", ctx, amount, sender) ret0, _ := ret[0].(error) @@ -1105,7 +342,7 @@ func (mr *MockStakingKeeperMockRecorder) BondDenom(ctx interface{}) *gomock.Call } // IterateBondedValidatorsByPower mocks base method. -func (m *MockStakingKeeper) IterateBondedValidatorsByPower(arg0 context.Context, arg1 func(int64, types0.ValidatorI) bool) error { +func (m *MockStakingKeeper) IterateBondedValidatorsByPower(arg0 context.Context, arg1 func(int64, types.ValidatorI) bool) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "IterateBondedValidatorsByPower", arg0, arg1) ret0, _ := ret[0].(error) @@ -1119,7 +356,7 @@ func (mr *MockStakingKeeperMockRecorder) IterateBondedValidatorsByPower(arg0, ar } // IterateDelegations mocks base method. -func (m *MockStakingKeeper) IterateDelegations(ctx context.Context, delegator types0.AccAddress, fn func(int64, types0.DelegationI) bool) error { +func (m *MockStakingKeeper) IterateDelegations(ctx context.Context, delegator types.AccAddress, fn func(int64, types.DelegationI) bool) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "IterateDelegations", ctx, delegator, fn) ret0, _ := ret[0].(error) diff --git a/x/group/testutil/expected_keepers.go b/x/group/testutil/expected_keepers.go index 2d832c13a672..3354ac5d7b54 100644 --- a/x/group/testutil/expected_keepers.go +++ b/x/group/testutil/expected_keepers.go @@ -5,20 +5,32 @@ package testutil import ( "context" + address "cosmossdk.io/core/address" bank "cosmossdk.io/x/bank/types" - "cosmossdk.io/x/group" sdk "github.com/cosmos/cosmos-sdk/types" ) // AccountKeeper extends `AccountKeeper` from expected_keepers. type AccountKeeper interface { - group.AccountKeeper + AddressCodec() address.Codec + + // NewAccount returns a new account with the next account number. Does not save the new account to the store. + NewAccount(context.Context, sdk.AccountI) sdk.AccountI + + // GetAccount retrieves an account from the store. + GetAccount(context.Context, sdk.AccAddress) sdk.AccountI + + // SetAccount sets an account in the store. + SetAccount(context.Context, sdk.AccountI) + + // RemoveAccount Remove an account in the store. + RemoveAccount(ctx context.Context, acc sdk.AccountI) } // BankKeeper extends bank `MsgServer` to mock `Send` and to register handlers in MsgServiceRouter type BankKeeper interface { - group.BankKeeper + SpendableCoins(ctx context.Context, addr sdk.AccAddress) sdk.Coins bank.MsgServer MintCoins(ctx context.Context, moduleName string, amt sdk.Coins) error diff --git a/x/staking/types/expected_keepers.go b/x/staking/types/expected_keepers.go index e10132de836b..a9aa08b40ea5 100644 --- a/x/staking/types/expected_keepers.go +++ b/x/staking/types/expected_keepers.go @@ -11,6 +11,7 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" + consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" ) // AccountKeeper defines the expected account keeper (noalias) @@ -115,3 +116,7 @@ type StakingHooksWrapper struct{ StakingHooks } // IsOnePerModuleType implements the depinject.OnePerModuleType interface. func (StakingHooksWrapper) IsOnePerModuleType() {} + +type ConsensusKeeper interface { + Params(context.Context, *consensustypes.QueryParamsRequest) (*consensustypes.QueryParamsResponse, error) +} From 19e4884d5a4425077196775d8bd8198b24349f64 Mon Sep 17 00:00:00 2001 From: Hoa Nguyen Date: Tue, 30 Apr 2024 07:59:27 +0700 Subject: [PATCH 09/10] chore(x/gov): reduce allocations (#20207) --- x/gov/client/utils/utils.go | 5 +++-- x/gov/keeper/deposit.go | 2 +- x/gov/keeper/proposal.go | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/x/gov/client/utils/utils.go b/x/gov/client/utils/utils.go index 7ac1c77f2156..a3c3723b995a 100644 --- a/x/gov/client/utils/utils.go +++ b/x/gov/client/utils/utils.go @@ -49,8 +49,9 @@ func NormalizeProposalType(proposalType string) v1.ProposalType { // NormalizeWeightedVoteOptions - normalize vote options param string func NormalizeWeightedVoteOptions(options string) string { - newOptions := []string{} - for _, option := range strings.Split(options, ",") { + tmpOptions := strings.Split(options, ",") + newOptions := make([]string, 0, len(tmpOptions)) + for _, option := range tmpOptions { fields := strings.Split(option, "=") fields[0] = NormalizeVoteOption(fields[0]) if len(fields) < 2 { diff --git a/x/gov/keeper/deposit.go b/x/gov/keeper/deposit.go index d2c13cea6ba8..c93ea91e1a54 100644 --- a/x/gov/keeper/deposit.go +++ b/x/gov/keeper/deposit.go @@ -325,7 +325,7 @@ func (k Keeper) validateInitialDeposit(params v1.Params, initialDeposit sdk.Coin // validateDepositDenom validates if the deposit denom is accepted by the governance module. func (k Keeper) validateDepositDenom(params v1.Params, depositAmount sdk.Coins) error { - denoms := []string{} + denoms := make([]string, 0, len(params.MinDeposit)) acceptedDenoms := make(map[string]bool, len(params.MinDeposit)) for _, coin := range params.MinDeposit { acceptedDenoms[coin.Denom] = true diff --git a/x/gov/keeper/proposal.go b/x/gov/keeper/proposal.go index ff7a8ab1ebde..91f97b0a7b3a 100644 --- a/x/gov/keeper/proposal.go +++ b/x/gov/keeper/proposal.go @@ -39,7 +39,7 @@ func (k Keeper) SubmitProposal(ctx context.Context, messages []sdk.Msg, metadata } } - msgs := []string{} // will hold a string slice of all Msg type URLs. + msgs := make([]string, 0, len(messages)) // will hold a string slice of all Msg type URLs. // Loop through all messages and confirm that each has a handler and the gov module account as the only signer for _, msg := range messages { From 0a2481d9e4735e8f60b856f7b8a66b8d79b88d4b Mon Sep 17 00:00:00 2001 From: tom Date: Tue, 30 Apr 2024 18:05:58 +0800 Subject: [PATCH 10/10] chore: remove duplicate word (#20216) --- client/context.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/context.go b/client/context.go index 2d513c81b34a..ef8940c119d3 100644 --- a/client/context.go +++ b/client/context.go @@ -107,7 +107,7 @@ func (ctx Context) WithKeyringOptions(opts ...keyring.Option) Context { // WithInput returns a copy of the context with an updated input. func (ctx Context) WithInput(r io.Reader) Context { // convert to a bufio.Reader to have a shared buffer between the keyring and the - // the Commands, ensuring a read from one advance the read pointer for the other. + // Commands, ensuring a read from one advance the read pointer for the other. // see https://github.com/cosmos/cosmos-sdk/issues/9566. ctx.Input = bufio.NewReader(r) return ctx