From b6fa6747c5ebfe2bcdd6e83fd984d6124306a87b Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 18:03:28 +0100 Subject: [PATCH] fix(x/accounts/default/lockup): Lockup account track undelegation when unbonding entry is mature (backport #22254) (#22930) Co-authored-by: son trinh Co-authored-by: Julien Robert --- .../lockup/continous_lockup_test_suite.go | 50 +- .../lockup/delayed_lockup_test_suite.go | 56 +- .../lockup/periodic_lockup_test_suite.go | 55 +- .../lockup/permanent_lockup_test_suite.go | 49 +- tests/integration/accounts/lockup/utils.go | 25 + .../lockup/continuous_locking_account.go | 26 +- .../lockup/continuous_locking_account_test.go | 75 +- .../lockup/delayed_locking_account.go | 26 +- .../lockup/delayed_locking_account_test.go | 67 +- x/accounts/defaults/lockup/lockup.go | 322 +++++--- x/accounts/defaults/lockup/lockup_test.go | 11 +- .../lockup/periodic_locking_account.go | 14 +- .../lockup/periodic_locking_account_test.go | 78 +- .../lockup/permanent_locking_account.go | 1 + .../lockup/permanent_locking_account_test.go | 13 + x/accounts/defaults/lockup/utils_test.go | 47 +- x/accounts/defaults/lockup/v1/lockup.pb.go | 552 ++++++++++++- x/accounts/defaults/lockup/v1/query.pb.go | 748 +++++++++++++++++- x/accounts/defaults/lockup/v1/tx.pb.go | 590 ++------------ .../accounts/defaults/lockup/v1/lockup.proto | 18 + .../accounts/defaults/lockup/v1/query.proto | 21 + .../accounts/defaults/lockup/v1/tx.proto | 23 - x/staking/keeper/grpc_query.go | 4 +- 23 files changed, 1775 insertions(+), 1096 deletions(-) diff --git a/tests/integration/accounts/lockup/continous_lockup_test_suite.go b/tests/integration/accounts/lockup/continous_lockup_test_suite.go index 2fbc794edee9..f3de1f753319 100644 --- a/tests/integration/accounts/lockup/continous_lockup_test_suite.go +++ b/tests/integration/accounts/lockup/continous_lockup_test_suite.go @@ -23,11 +23,11 @@ func (s *IntegrationTestSuite) TestContinuousLockingAccount() { ctx := sdk.NewContext(app.CommitMultiStore(), false, app.Logger()).WithHeaderInfo(header.Info{ Time: currentTime, }) + s.setupStakingParams(ctx, app) ownerAddrStr, err := app.AuthKeeper.AddressCodec().BytesToString(accOwner) require.NoError(t, err) s.fundAccount(app, ctx, accOwner, sdk.Coins{sdk.NewCoin("stake", math.NewInt(1000000))}) randAcc := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) - withdrawAcc := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) _, accountAddr, err := app.AccountsKeeper.Init(ctx, lockupaccount.CONTINUOUS_LOCKING_ACCOUNT, accOwner, &types.MsgInitLockupAccount{ Owner: ownerAddrStr, @@ -62,19 +62,6 @@ func (s *IntegrationTestSuite) TestContinuousLockingAccount() { err := s.executeTx(ctx, msg, app, accountAddr, accOwner) require.NotNil(t, err) }) - t.Run("error - execute withdraw message, no withdrawable token", func(t *testing.T) { - ownerAddr, err := app.AuthKeeper.AddressCodec().BytesToString(accOwner) - require.NoError(t, err) - withdrawAddr, err := app.AuthKeeper.AddressCodec().BytesToString(withdrawAcc) - require.NoError(t, err) - msg := &types.MsgWithdraw{ - Withdrawer: ownerAddr, - ToAddress: withdrawAddr, - Denoms: []string{"stake"}, - } - err = s.executeTx(ctx, msg, app, accountAddr, accOwner) - require.NotNil(t, err) - }) // Update context time // 12 sec = 1/5 of a minute so 200stake should be released @@ -95,23 +82,7 @@ func (s *IntegrationTestSuite) TestContinuousLockingAccount() { balance := app.BankKeeper.GetBalance(ctx, randAcc, "stake") require.True(t, balance.Amount.Equal(math.NewInt(100))) }) - t.Run("ok - execute withdraw message", func(t *testing.T) { - ownerAddr, err := app.AuthKeeper.AddressCodec().BytesToString(accOwner) - require.NoError(t, err) - withdrawAddr, err := app.AuthKeeper.AddressCodec().BytesToString(withdrawAcc) - require.NoError(t, err) - msg := &types.MsgWithdraw{ - Withdrawer: ownerAddr, - ToAddress: withdrawAddr, - Denoms: []string{"stake"}, - } - err = s.executeTx(ctx, msg, app, accountAddr, accOwner) - require.NoError(t, err) - // withdrawable amount should be 200 - 100 = 100stake - balance := app.BankKeeper.GetBalance(ctx, withdrawAcc, "stake") - require.True(t, balance.Amount.Equal(math.NewInt(100))) - }) t.Run("ok - execute delegate message", func(t *testing.T) { msg := &types.MsgDelegate{ Sender: ownerAddrStr, @@ -163,10 +134,11 @@ func (s *IntegrationTestSuite) TestContinuousLockingAccount() { require.NoError(t, err) require.Equal(t, len(ubd.Entries), 1) - // check if tracking is updated accordingly - lockupAccountInfoResponse := s.queryLockupAccInfo(ctx, app, accountAddr) - delLocking := lockupAccountInfoResponse.DelegatedLocking - require.True(t, delLocking.AmountOf("stake").Equal(math.ZeroInt())) + // check if an entry is added + unbondingEntriesResponse := s.queryUnbondingEntries(ctx, app, accountAddr, val.OperatorAddress) + entries := unbondingEntriesResponse.UnbondingEntries + require.True(t, entries[0].Amount.Amount.Equal(math.NewInt(100))) + require.True(t, entries[0].ValidatorAddress == val.OperatorAddress) }) // Update context time to end time @@ -174,6 +146,10 @@ func (s *IntegrationTestSuite) TestContinuousLockingAccount() { Time: currentTime.Add(time.Minute), }) + // trigger endblock for staking to handle matured unbonding delegation + _, err = app.StakingKeeper.EndBlocker(ctx) + require.NoError(t, err) + // test if tracking delegate work perfectly t.Run("ok - execute delegate message", func(t *testing.T) { msg := &types.MsgDelegate{ @@ -196,8 +172,14 @@ func (s *IntegrationTestSuite) TestContinuousLockingAccount() { // check if tracking is updated accordingly lockupAccountInfoResponse := s.queryLockupAccInfo(ctx, app, accountAddr) delLocking := lockupAccountInfoResponse.DelegatedLocking + // should be update as ubd entry is matured require.True(t, delLocking.AmountOf("stake").Equal(math.ZeroInt())) delFree := lockupAccountInfoResponse.DelegatedFree require.True(t, delFree.AmountOf("stake").Equal(math.NewInt(100))) + + // check if the entry is removed + unbondingEntriesResponse := s.queryUnbondingEntries(ctx, app, accountAddr, val.OperatorAddress) + entries := unbondingEntriesResponse.UnbondingEntries + require.Len(t, entries, 0) }) } diff --git a/tests/integration/accounts/lockup/delayed_lockup_test_suite.go b/tests/integration/accounts/lockup/delayed_lockup_test_suite.go index ff1131403fb8..046240d9df3d 100644 --- a/tests/integration/accounts/lockup/delayed_lockup_test_suite.go +++ b/tests/integration/accounts/lockup/delayed_lockup_test_suite.go @@ -23,11 +23,11 @@ func (s *IntegrationTestSuite) TestDelayedLockingAccount() { ctx := sdk.NewContext(app.CommitMultiStore(), false, app.Logger()).WithHeaderInfo(header.Info{ Time: currentTime, }) + s.setupStakingParams(ctx, app) ownerAddrStr, err := app.AuthKeeper.AddressCodec().BytesToString(accOwner) require.NoError(t, err) s.fundAccount(app, ctx, accOwner, sdk.Coins{sdk.NewCoin("stake", math.NewInt(1000000))}) randAcc := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) - withdrawAcc := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) _, accountAddr, err := app.AccountsKeeper.Init(ctx, lockupaccount.DELAYED_LOCKING_ACCOUNT, accOwner, &types.MsgInitLockupAccount{ Owner: ownerAddrStr, @@ -61,19 +61,6 @@ func (s *IntegrationTestSuite) TestDelayedLockingAccount() { err := s.executeTx(ctx, msg, app, accountAddr, accOwner) require.NotNil(t, err) }) - t.Run("error - execute withdraw message, no withdrawable token", func(t *testing.T) { - ownerAddr, err := app.AuthKeeper.AddressCodec().BytesToString(accOwner) - require.NoError(t, err) - withdrawAddr, err := app.AuthKeeper.AddressCodec().BytesToString(withdrawAcc) - require.NoError(t, err) - msg := &types.MsgWithdraw{ - Withdrawer: ownerAddr, - ToAddress: withdrawAddr, - Denoms: []string{"stake"}, - } - err = s.executeTx(ctx, msg, app, accountAddr, accOwner) - require.NotNil(t, err) - }) t.Run("ok - execute delegate message", func(t *testing.T) { msg := &types.MsgDelegate{ Sender: ownerAddrStr, @@ -125,18 +112,24 @@ func (s *IntegrationTestSuite) TestDelayedLockingAccount() { require.NoError(t, err) require.Equal(t, len(ubd.Entries), 1) - // check if tracking is updated accordingly - lockupAccountInfoResponse := s.queryLockupAccInfo(ctx, app, accountAddr) - delLocking := lockupAccountInfoResponse.DelegatedLocking - require.True(t, delLocking.AmountOf("stake").Equal(math.ZeroInt())) + // check if an entry is added + unbondingEntriesResponse := s.queryUnbondingEntries(ctx, app, accountAddr, val.OperatorAddress) + entries := unbondingEntriesResponse.UnbondingEntries + require.True(t, entries[0].Amount.Amount.Equal(math.NewInt(100))) + require.True(t, entries[0].ValidatorAddress == val.OperatorAddress) }) // Update context time // After endtime fund should be unlock + // And unbond time elapsed ctx = ctx.WithHeaderInfo(header.Info{ Time: currentTime.Add(time.Second * 61), }) + // trigger endblock for staking to handle matured unbonding delegation + _, err = app.StakingKeeper.EndBlocker(ctx) + require.NoError(t, err) + // Check if token is sendable after unlock t.Run("ok - execute send message", func(t *testing.T) { msg := &types.MsgSend{ @@ -149,24 +142,15 @@ func (s *IntegrationTestSuite) TestDelayedLockingAccount() { balance := app.BankKeeper.GetBalance(ctx, randAcc, "stake") require.True(t, balance.Amount.Equal(math.NewInt(100))) - }) - // Test to withdraw all the remain funds to an account of choice - t.Run("ok - execute withdraw message", func(t *testing.T) { - ownerAddr, err := app.AuthKeeper.AddressCodec().BytesToString(accOwner) - require.NoError(t, err) - withdrawAddr, err := app.AuthKeeper.AddressCodec().BytesToString(withdrawAcc) - require.NoError(t, err) - msg := &types.MsgWithdraw{ - Withdrawer: ownerAddr, - ToAddress: withdrawAddr, - Denoms: []string{"stake"}, - } - err = s.executeTx(ctx, msg, app, accountAddr, accOwner) - require.NoError(t, err) - // withdrawable amount should be - // 1000stake - 100stake( above sent amt ) - 100stake(above delegate amt) = 800stake - balance := app.BankKeeper.GetBalance(ctx, withdrawAcc, "stake") - require.True(t, balance.Amount.Equal(math.NewInt(800))) + // check if tracking ubd entry is updated accordingly + lockupAccountInfoResponse := s.queryLockupAccInfo(ctx, app, accountAddr) + delLocking := lockupAccountInfoResponse.DelegatedLocking + require.True(t, delLocking.AmountOf("stake").Equal(math.ZeroInt())) + + // check if the entry is removed + unbondingEntriesResponse := s.queryUnbondingEntries(ctx, app, accountAddr, val.OperatorAddress) + entries := unbondingEntriesResponse.UnbondingEntries + require.Len(t, entries, 0) }) } diff --git a/tests/integration/accounts/lockup/periodic_lockup_test_suite.go b/tests/integration/accounts/lockup/periodic_lockup_test_suite.go index 2a727bd243cc..fa2b33f83c37 100644 --- a/tests/integration/accounts/lockup/periodic_lockup_test_suite.go +++ b/tests/integration/accounts/lockup/periodic_lockup_test_suite.go @@ -24,11 +24,11 @@ func (s *IntegrationTestSuite) TestPeriodicLockingAccount() { ctx := sdk.NewContext(app.CommitMultiStore(), false, app.Logger()).WithHeaderInfo(header.Info{ Time: currentTime, }) + s.setupStakingParams(ctx, app) ownerAddrStr, err := app.AuthKeeper.AddressCodec().BytesToString(accOwner) require.NoError(t, err) s.fundAccount(app, ctx, accOwner, sdk.Coins{sdk.NewCoin("stake", math.NewInt(1000000))}) randAcc := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) - withdrawAcc := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) _, accountAddr, err := app.AccountsKeeper.Init(ctx, lockupaccount.PERIODIC_LOCKING_ACCOUNT, accOwner, &types.MsgInitPeriodicLockingAccount{ Owner: ownerAddrStr, @@ -76,19 +76,6 @@ func (s *IntegrationTestSuite) TestPeriodicLockingAccount() { err := s.executeTx(ctx, msg, app, accountAddr, accOwner) require.NotNil(t, err) }) - t.Run("error - execute withdraw message, no withdrawable token", func(t *testing.T) { - ownerAddr, err := app.AuthKeeper.AddressCodec().BytesToString(accOwner) - require.NoError(t, err) - withdrawAddr, err := app.AuthKeeper.AddressCodec().BytesToString(withdrawAcc) - require.NoError(t, err) - msg := &types.MsgWithdraw{ - Withdrawer: ownerAddr, - ToAddress: withdrawAddr, - Denoms: []string{"stake"}, - } - err = s.executeTx(ctx, msg, app, accountAddr, accOwner) - require.NotNil(t, err) - }) // Update context time // After first period 500stake should be unlock @@ -116,25 +103,6 @@ func (s *IntegrationTestSuite) TestPeriodicLockingAccount() { Time: currentTime.Add(time.Minute * 2), }) - t.Run("oke - execute withdraw message", func(t *testing.T) { - ownerAddr, err := app.AuthKeeper.AddressCodec().BytesToString(accOwner) - require.NoError(t, err) - withdrawAddr, err := app.AuthKeeper.AddressCodec().BytesToString(withdrawAcc) - require.NoError(t, err) - msg := &types.MsgWithdraw{ - Withdrawer: ownerAddr, - ToAddress: withdrawAddr, - Denoms: []string{"stake"}, - } - err = s.executeTx(ctx, msg, app, accountAddr, accOwner) - require.NoError(t, err) - - // withdrawable amount should be - // 1000stake - 500stake( above sent amt ) = 500stake - balance := app.BankKeeper.GetBalance(ctx, withdrawAcc, "stake") - require.True(t, balance.Amount.Equal(math.NewInt(500))) - }) - t.Run("ok - execute delegate message", func(t *testing.T) { msg := &types.MsgDelegate{ Sender: ownerAddrStr, @@ -187,10 +155,11 @@ func (s *IntegrationTestSuite) TestPeriodicLockingAccount() { require.NoError(t, err) require.Equal(t, len(ubd.Entries), 1) - // check if tracking is updated accordingly - lockupAccountInfoResponse := s.queryLockupAccInfo(ctx, app, accountAddr) - delLocking := lockupAccountInfoResponse.DelegatedLocking - require.True(t, delLocking.AmountOf("stake").Equal(math.ZeroInt())) + // check if an entry is added + unbondingEntriesResponse := s.queryUnbondingEntries(ctx, app, accountAddr, val.OperatorAddress) + entries := unbondingEntriesResponse.UnbondingEntries + require.True(t, entries[0].Amount.Amount.Equal(math.NewInt(100))) + require.True(t, entries[0].ValidatorAddress == val.OperatorAddress) }) // Update context time @@ -199,6 +168,10 @@ func (s *IntegrationTestSuite) TestPeriodicLockingAccount() { Time: currentTime.Add(time.Minute * 3), }) + // trigger endblock for staking to handle matured unbonding delegation + _, err = app.StakingKeeper.EndBlocker(ctx) + require.NoError(t, err) + t.Run("ok - execute delegate message", func(t *testing.T) { msg := &types.MsgDelegate{ Sender: ownerAddrStr, @@ -219,7 +192,15 @@ func (s *IntegrationTestSuite) TestPeriodicLockingAccount() { // check if tracking is updated accordingly lockupAccountInfoResponse := s.queryLockupAccInfo(ctx, app, accountAddr) + // check if matured ubd entry cleared + 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))) + + // check if the entry is removed + unbondingEntriesResponse := s.queryUnbondingEntries(ctx, app, accountAddr, val.OperatorAddress) + entries := unbondingEntriesResponse.UnbondingEntries + require.Len(t, entries, 0) }) } diff --git a/tests/integration/accounts/lockup/permanent_lockup_test_suite.go b/tests/integration/accounts/lockup/permanent_lockup_test_suite.go index 1505dbac0c17..ca38f5629eb5 100644 --- a/tests/integration/accounts/lockup/permanent_lockup_test_suite.go +++ b/tests/integration/accounts/lockup/permanent_lockup_test_suite.go @@ -23,6 +23,7 @@ func (s *IntegrationTestSuite) TestPermanentLockingAccount() { ctx := sdk.NewContext(app.CommitMultiStore(), false, app.Logger()).WithHeaderInfo(header.Info{ Time: currentTime, }) + s.setupStakingParams(ctx, app) ownerAddrStr, err := app.AuthKeeper.AddressCodec().BytesToString(accOwner) require.NoError(t, err) s.fundAccount(app, ctx, accOwner, sdk.Coins{sdk.NewCoin("stake", math.NewInt(1000000))}) @@ -109,10 +110,11 @@ func (s *IntegrationTestSuite) TestPermanentLockingAccount() { require.NoError(t, err) require.Equal(t, len(ubd.Entries), 1) - // check if tracking is updated accordingly - lockupAccountInfoResponse := s.queryLockupAccInfo(ctx, app, accountAddr) - delLocking := lockupAccountInfoResponse.DelegatedLocking - require.True(t, delLocking.AmountOf("stake").Equal(math.ZeroInt())) + // check if an entry is added + unbondingEntriesResponse := s.queryUnbondingEntries(ctx, app, accountAddr, val.OperatorAddress) + entries := unbondingEntriesResponse.UnbondingEntries + require.True(t, entries[0].Amount.Amount.Equal(math.NewInt(100))) + require.True(t, entries[0].ValidatorAddress == val.OperatorAddress) }) s.fundAccount(app, ctx, accountAddr, sdk.Coins{sdk.NewCoin("stake", math.NewInt(1000))}) @@ -129,4 +131,43 @@ func (s *IntegrationTestSuite) TestPermanentLockingAccount() { balance := app.BankKeeper.GetBalance(ctx, randAcc, "stake") require.True(t, balance.Amount.Equal(math.NewInt(100))) }) + + // Update context time + ctx = ctx.WithHeaderInfo(header.Info{ + Time: currentTime.Add(time.Second * 11), + }) + + // trigger endblock for staking to handle matured unbonding delegation + _, err = app.StakingKeeper.EndBlocker(ctx) + require.NoError(t, err) + + t.Run("ok - execute delegate message", func(t *testing.T) { + msg := &types.MsgDelegate{ + Sender: ownerAddrStr, + ValidatorAddress: val.OperatorAddress, + Amount: sdk.NewCoin("stake", math.NewInt(10)), + } + 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(ctx, app, accountAddr) + delLocking := lockupAccountInfoResponse.DelegatedLocking + // matured ubd entry should be cleared so del locking should only be 10 + require.True(t, delLocking.AmountOf("stake").Equal(math.NewInt(10))) + + // check if the entry is removed + unbondingEntriesResponse := s.queryUnbondingEntries(ctx, app, accountAddr, val.OperatorAddress) + entries := unbondingEntriesResponse.UnbondingEntries + require.Len(t, entries, 0) + }) } diff --git a/tests/integration/accounts/lockup/utils.go b/tests/integration/accounts/lockup/utils.go index a0ce8f4e0c23..d92586f1ac90 100644 --- a/tests/integration/accounts/lockup/utils.go +++ b/tests/integration/accounts/lockup/utils.go @@ -2,6 +2,7 @@ package lockup import ( "testing" + "time" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -70,3 +71,27 @@ func (s *IntegrationTestSuite) queryLockupAccInfo(ctx sdk.Context, app *simapp.S return lockupAccountInfoResponse } + +func (s *IntegrationTestSuite) queryUnbondingEntries(ctx sdk.Context, app *simapp.SimApp, accAddr []byte, valAddr string) *types.QueryUnbondingEntriesResponse { + req := &types.QueryUnbondingEntriesRequest{ + ValidatorAddress: valAddr, + } + resp, err := s.queryAcc(ctx, req, app, accAddr) + require.NoError(s.T(), err) + require.NotNil(s.T(), resp) + + unbondingEntriesResponse, ok := resp.(*types.QueryUnbondingEntriesResponse) + require.True(s.T(), ok) + + return unbondingEntriesResponse +} + +func (s *IntegrationTestSuite) setupStakingParams(ctx sdk.Context, app *simapp.SimApp) { + params, err := app.StakingKeeper.Params.Get(ctx) + require.NoError(s.T(), err) + + // update unbonding time + params.UnbondingTime = time.Duration(time.Second * 10) + err = app.StakingKeeper.Params.Set(ctx, params) + require.NoError(s.T(), err) +} diff --git a/x/accounts/defaults/lockup/continuous_locking_account.go b/x/accounts/defaults/lockup/continuous_locking_account.go index 4cf4600eb3d3..abe22f649270 100644 --- a/x/accounts/defaults/lockup/continuous_locking_account.go +++ b/x/accounts/defaults/lockup/continuous_locking_account.go @@ -72,12 +72,6 @@ func (cva *ContinuousLockingAccount) SendCoins(ctx context.Context, msg *lockupt return cva.BaseLockup.SendCoins(ctx, msg, cva.GetLockedCoinsWithDenoms) } -func (cva *ContinuousLockingAccount) WithdrawUnlockedCoins(ctx context.Context, msg *lockuptypes.MsgWithdraw) ( - *lockuptypes.MsgWithdrawResponse, error, -) { - return cva.BaseLockup.WithdrawUnlockedCoins(ctx, msg, cva.GetLockedCoinsWithDenoms) -} - // GetLockCoinsInfo returns the total number of unlocked and locked coins. func (cva ContinuousLockingAccount) GetLockCoinsInfo(ctx context.Context, blockTime time.Time) (unlockedCoins, lockedCoins sdk.Coins, err error) { unlockedCoins = sdk.Coins{} @@ -186,6 +180,23 @@ func (cva ContinuousLockingAccount) QueryLockupAccountInfo(ctx context.Context, return resp, nil } +func (cva ContinuousLockingAccount) QuerySpendableTokens(ctx context.Context, req *lockuptypes.QuerySpendableAmountRequest) ( + *lockuptypes.QuerySpendableAmountResponse, error, +) { + hs := cva.headerService.HeaderInfo(ctx) + _, lockedCoins, err := cva.GetLockCoinsInfo(ctx, hs.Time) + if err != nil { + return nil, err + } + + resp, err := cva.BaseLockup.QuerySpendableTokens(ctx, lockedCoins) + if err != nil { + return nil, err + } + + return resp, nil +} + // Implement smart account interface func (cva ContinuousLockingAccount) RegisterInitHandler(builder *accountstd.InitBuilder) { accountstd.RegisterInitHandler(builder, cva.Init) @@ -194,10 +205,11 @@ func (cva ContinuousLockingAccount) RegisterInitHandler(builder *accountstd.Init func (cva ContinuousLockingAccount) RegisterExecuteHandlers(builder *accountstd.ExecuteBuilder) { accountstd.RegisterExecuteHandler(builder, cva.Delegate) accountstd.RegisterExecuteHandler(builder, cva.SendCoins) - accountstd.RegisterExecuteHandler(builder, cva.WithdrawUnlockedCoins) cva.BaseLockup.RegisterExecuteHandlers(builder) } func (cva ContinuousLockingAccount) RegisterQueryHandlers(builder *accountstd.QueryBuilder) { accountstd.RegisterQueryHandler(builder, cva.QueryLockupAccountInfo) + accountstd.RegisterQueryHandler(builder, cva.QuerySpendableTokens) + cva.BaseLockup.RegisterQueryHandlers(builder) } diff --git a/x/accounts/defaults/lockup/continuous_locking_account_test.go b/x/accounts/defaults/lockup/continuous_locking_account_test.go index 475d38fceaaf..097c335db57d 100644 --- a/x/accounts/defaults/lockup/continuous_locking_account_test.go +++ b/x/accounts/defaults/lockup/continuous_locking_account_test.go @@ -102,48 +102,21 @@ func TestContinuousAccountUndelegate(t *testing.T) { }) require.NoError(t, err) - delLocking, err = acc.DelegatedLocking.Get(ctx, "test") + entries, err := acc.UnbondEntries.Get(sdkCtx, "val_address") require.NoError(t, err) - require.True(t, delLocking.Equal(math.ZeroInt())) - - startTime, err := acc.StartTime.Get(sdkCtx) - require.NoError(t, err) - - // Update context time to unlocked half of the original locking amount - sdkCtx = sdkCtx.WithHeaderInfo(header.Info{ - Time: startTime.Add(time.Minute * 1), - }) + require.Len(t, entries.Entries, 1) + require.True(t, entries.Entries[0].Amount.Amount.Equal(math.NewInt(1))) + require.True(t, entries.Entries[0].ValidatorAddress == "val_address") - _, err = acc.Delegate(sdkCtx, &lockuptypes.MsgDelegate{ - Sender: "owner", - ValidatorAddress: "val_address", - Amount: sdk.NewCoin("test", math.NewInt(6)), - }) + err = acc.checkUnbondingEntriesMature(sdkCtx) require.NoError(t, err) - delLocking, err = acc.DelegatedLocking.Get(ctx, "test") - require.NoError(t, err) - require.True(t, delLocking.Equal(math.NewInt(5))) - - delFree, err := acc.DelegatedFree.Get(ctx, "test") - require.NoError(t, err) - require.True(t, delFree.Equal(math.NewInt(1))) - - // Undelegate - _, err = acc.Undelegate(sdkCtx, &lockuptypes.MsgUndelegate{ - Sender: "owner", - ValidatorAddress: "val_address", - Amount: sdk.NewCoin("test", math.NewInt(4)), - }) - require.NoError(t, err) + _, err = acc.UnbondEntries.Get(sdkCtx, "val_address") + require.Error(t, err) delLocking, err = acc.DelegatedLocking.Get(ctx, "test") require.NoError(t, err) - require.True(t, delLocking.Equal(math.NewInt(2))) - - delFree, err = acc.DelegatedFree.Get(ctx, "test") - require.NoError(t, err) - require.True(t, delFree.Equal(math.ZeroInt())) + require.True(t, delLocking.Equal(math.ZeroInt())) } func TestContinuousAccountSendCoins(t *testing.T) { @@ -176,37 +149,7 @@ func TestContinuousAccountSendCoins(t *testing.T) { require.NoError(t, err) } -func TestContinuousAccountWithdrawUnlockedCoins(t *testing.T) { - ctx, ss := newMockContext(t) - sdkCtx := sdk.NewContext(nil, true, log.NewNopLogger()).WithContext(ctx).WithHeaderInfo(header.Info{ - Time: time.Now(), - }) - - acc := setupContinuousAccount(t, sdkCtx, ss) - _, err := acc.WithdrawUnlockedCoins(sdkCtx, &lockuptypes.MsgWithdraw{ - Withdrawer: "owner", - ToAddress: "receiver", - Denoms: []string{"test"}, - }) - require.Error(t, err) - - startTime, err := acc.StartTime.Get(sdkCtx) - require.NoError(t, err) - - // Update context time to unlocked half of the original locking amount - sdkCtx = sdkCtx.WithHeaderInfo(header.Info{ - Time: startTime.Add(time.Minute * 1), - }) - - _, err = acc.WithdrawUnlockedCoins(sdkCtx, &lockuptypes.MsgWithdraw{ - Withdrawer: "owner", - ToAddress: "receiver", - Denoms: []string{"test"}, - }) - require.NoError(t, err) -} - -func TestContinuousAccountGetLockCoinInfo(t *testing.T) { +func TestContinousAccountGetLockCoinInfo(t *testing.T) { ctx, ss := newMockContext(t) sdkCtx := sdk.NewContext(nil, true, log.NewNopLogger()).WithContext(ctx).WithHeaderInfo(header.Info{ Time: time.Now(), diff --git a/x/accounts/defaults/lockup/delayed_locking_account.go b/x/accounts/defaults/lockup/delayed_locking_account.go index cf078be95739..22d00b3dc502 100644 --- a/x/accounts/defaults/lockup/delayed_locking_account.go +++ b/x/accounts/defaults/lockup/delayed_locking_account.go @@ -49,12 +49,6 @@ func (dva *DelayedLockingAccount) SendCoins(ctx context.Context, msg *lockuptype return dva.BaseLockup.SendCoins(ctx, msg, dva.GetLockedCoinsWithDenoms) } -func (dva *DelayedLockingAccount) WithdrawUnlockedCoins(ctx context.Context, msg *lockuptypes.MsgWithdraw) ( - *lockuptypes.MsgWithdrawResponse, error, -) { - return dva.BaseLockup.WithdrawUnlockedCoins(ctx, msg, dva.GetLockedCoinsWithDenoms) -} - // GetLockCoinsInfo returns the total number of unlocked and locked coins. func (dva DelayedLockingAccount) GetLockCoinsInfo(ctx context.Context, blockTime time.Time) (sdk.Coins, sdk.Coins, error) { endTime, err := dva.EndTime.Get(ctx) @@ -135,6 +129,23 @@ func (dva DelayedLockingAccount) QueryVestingAccountInfo(ctx context.Context, re return resp, nil } +func (dva DelayedLockingAccount) QuerySpendableTokens(ctx context.Context, req *lockuptypes.QuerySpendableAmountRequest) ( + *lockuptypes.QuerySpendableAmountResponse, error, +) { + hs := dva.headerService.HeaderInfo(ctx) + _, lockedCoins, err := dva.GetLockCoinsInfo(ctx, hs.Time) + if err != nil { + return nil, err + } + + resp, err := dva.BaseLockup.QuerySpendableTokens(ctx, lockedCoins) + if err != nil { + return nil, err + } + + return resp, nil +} + // Implement smart account interface func (dva DelayedLockingAccount) RegisterInitHandler(builder *accountstd.InitBuilder) { accountstd.RegisterInitHandler(builder, dva.Init) @@ -143,10 +154,11 @@ func (dva DelayedLockingAccount) RegisterInitHandler(builder *accountstd.InitBui func (dva DelayedLockingAccount) RegisterExecuteHandlers(builder *accountstd.ExecuteBuilder) { accountstd.RegisterExecuteHandler(builder, dva.Delegate) accountstd.RegisterExecuteHandler(builder, dva.SendCoins) - accountstd.RegisterExecuteHandler(builder, dva.WithdrawUnlockedCoins) dva.BaseLockup.RegisterExecuteHandlers(builder) } func (dva DelayedLockingAccount) RegisterQueryHandlers(builder *accountstd.QueryBuilder) { accountstd.RegisterQueryHandler(builder, dva.QueryVestingAccountInfo) + accountstd.RegisterQueryHandler(builder, dva.QuerySpendableTokens) + dva.BaseLockup.RegisterQueryHandlers(builder) } diff --git a/x/accounts/defaults/lockup/delayed_locking_account_test.go b/x/accounts/defaults/lockup/delayed_locking_account_test.go index 5bb722168f24..dc3235c7a6ba 100644 --- a/x/accounts/defaults/lockup/delayed_locking_account_test.go +++ b/x/accounts/defaults/lockup/delayed_locking_account_test.go @@ -101,44 +101,21 @@ func TestDelayedAccountUndelegate(t *testing.T) { }) require.NoError(t, err) - delLocking, err = acc.DelegatedLocking.Get(ctx, "test") + entries, err := acc.UnbondEntries.Get(sdkCtx, "val_address") require.NoError(t, err) - require.True(t, delLocking.Equal(math.ZeroInt())) + require.Len(t, entries.Entries, 1) + require.True(t, entries.Entries[0].Amount.Amount.Equal(math.NewInt(1))) + require.True(t, entries.Entries[0].ValidatorAddress == "val_address") - endTime, err := acc.EndTime.Get(sdkCtx) + err = acc.checkUnbondingEntriesMature(sdkCtx) require.NoError(t, err) - // Update context time to unlocked all the original locking amount - sdkCtx = sdkCtx.WithHeaderInfo(header.Info{ - Time: endTime.Add(time.Second), - }) - - _, err = acc.Delegate(sdkCtx, &lockuptypes.MsgDelegate{ - Sender: "owner", - ValidatorAddress: "val_address", - Amount: sdk.NewCoin("test", math.NewInt(6)), - }) - require.NoError(t, err) + _, err = acc.UnbondEntries.Get(sdkCtx, "val_address") + require.Error(t, err) delLocking, err = acc.DelegatedLocking.Get(ctx, "test") require.NoError(t, err) require.True(t, delLocking.Equal(math.ZeroInt())) - - delFree, err := acc.DelegatedFree.Get(ctx, "test") - require.NoError(t, err) - require.True(t, delFree.Equal(math.NewInt(6))) - - // Undelegate - _, err = acc.Undelegate(sdkCtx, &lockuptypes.MsgUndelegate{ - Sender: "owner", - ValidatorAddress: "val_address", - Amount: sdk.NewCoin("test", math.NewInt(4)), - }) - require.NoError(t, err) - - delFree, err = acc.DelegatedFree.Get(ctx, "test") - require.NoError(t, err) - require.True(t, delFree.Equal(math.NewInt(2))) } func TestDelayedAccountSendCoins(t *testing.T) { @@ -171,36 +148,6 @@ func TestDelayedAccountSendCoins(t *testing.T) { require.NoError(t, err) } -func TestDelayedAccountWithdrawUnlockedCoins(t *testing.T) { - ctx, ss := newMockContext(t) - sdkCtx := sdk.NewContext(nil, true, log.NewNopLogger()).WithContext(ctx).WithHeaderInfo(header.Info{ - Time: time.Now(), - }) - - acc := setupDelayedAccount(t, sdkCtx, ss) - _, err := acc.WithdrawUnlockedCoins(sdkCtx, &lockuptypes.MsgWithdraw{ - Withdrawer: "owner", - ToAddress: "receiver", - Denoms: []string{"test"}, - }) - require.Error(t, err) - - endTime, err := acc.EndTime.Get(sdkCtx) - require.NoError(t, err) - - // Update context time to unlocked all the original locking amount - sdkCtx = sdkCtx.WithHeaderInfo(header.Info{ - Time: endTime.Add(time.Second), - }) - - _, err = acc.WithdrawUnlockedCoins(sdkCtx, &lockuptypes.MsgWithdraw{ - Withdrawer: "owner", - ToAddress: "receiver", - Denoms: []string{"test"}, - }) - require.NoError(t, err) -} - func TestDelayedAccountGetLockCoinInfo(t *testing.T) { ctx, ss := newMockContext(t) sdkCtx := sdk.NewContext(nil, true, log.NewNopLogger()).WithContext(ctx).WithHeaderInfo(header.Info{ diff --git a/x/accounts/defaults/lockup/lockup.go b/x/accounts/defaults/lockup/lockup.go index aecdfd29b265..a1582bf5c625 100644 --- a/x/accounts/defaults/lockup/lockup.go +++ b/x/accounts/defaults/lockup/lockup.go @@ -4,8 +4,6 @@ import ( "bytes" "context" "errors" - "maps" - "slices" "time" "github.com/cosmos/gogoproto/proto" @@ -22,6 +20,7 @@ import ( distrtypes "cosmossdk.io/x/distribution/types" stakingtypes "cosmossdk.io/x/staking/types" + "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -35,7 +34,7 @@ var ( StartTimePrefix = collections.NewPrefix(4) LockingPeriodsPrefix = collections.NewPrefix(5) OwnerPrefix = collections.NewPrefix(6) - WithdrawedCoinsPrefix = collections.NewPrefix(7) + UnbondEntriesPrefix = collections.NewPrefix(7) ) var ( @@ -54,7 +53,7 @@ func newBaseLockup(d accountstd.Dependencies) *BaseLockup { OriginalLocking: collections.NewMap(d.SchemaBuilder, OriginalLockingPrefix, "original_locking", collections.StringKey, sdk.IntValue), DelegatedFree: collections.NewMap(d.SchemaBuilder, DelegatedFreePrefix, "delegated_free", collections.StringKey, sdk.IntValue), DelegatedLocking: collections.NewMap(d.SchemaBuilder, DelegatedLockingPrefix, "delegated_locking", collections.StringKey, sdk.IntValue), - WithdrawedCoins: collections.NewMap(d.SchemaBuilder, WithdrawedCoinsPrefix, "withdrawed_coins", collections.StringKey, sdk.IntValue), + UnbondEntries: collections.NewMap(d.SchemaBuilder, UnbondEntriesPrefix, "unbond_entries", collections.StringKey, codec.CollValue[lockuptypes.UnbondingEntries](d.LegacyStateCodec)), addressCodec: d.AddressCodec, headerService: d.Environment.HeaderService, EndTime: collections.NewItem(d.SchemaBuilder, EndTimePrefix, "end_time", collcodec.KeyToValueCodec[time.Time](sdk.TimeKey)), @@ -69,9 +68,10 @@ type BaseLockup struct { 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 + // map val address to unbonding entries + UnbondEntries collections.Map[string, lockuptypes.UnbondingEntries] + addressCodec address.Codec + headerService header.Service // lockup end time. EndTime collections.Item[time.Time] } @@ -96,12 +96,6 @@ 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.WithdrawedCoins.Set(ctx, coin.Denom, math.ZeroInt()) - if err != nil { - return nil, err - } } bondDenom, err := getStakingDenom(ctx) @@ -155,6 +149,12 @@ func (bva *BaseLockup) Delegate( return nil, err } + // refresh ubd entries to make sure delegation locking amount is up to date + err = bva.checkUnbondingEntriesMature(ctx) + if err != nil { + return nil, err + } + err = bva.TrackDelegation( ctx, sdk.Coins{*balance}, @@ -193,11 +193,6 @@ 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, @@ -208,6 +203,50 @@ func (bva *BaseLockup) Undelegate( return nil, err } + header := bva.headerService.HeaderInfo(ctx) + + msgUndelegateResp, err := accountstd.UnpackAny[stakingtypes.MsgUndelegateResponse](resp[0]) + if err != nil { + return nil, err + } + + isNewEntry := true + entries, err := bva.UnbondEntries.Get(ctx, msg.ValidatorAddress) + if err != nil { + if errorsmod.IsOf(err, collections.ErrNotFound) { + entries = lockuptypes.UnbondingEntries{ + Entries: []*lockuptypes.UnbondingEntry{}, + } + } else { + return nil, err + } + } + + for i, entry := range entries.Entries { + if entry.CreationHeight == header.Height && entry.EndTime.Equal(msgUndelegateResp.CompletionTime) { + entry.Amount = entry.Amount.Add(msg.Amount) + + // update the entry + entries.Entries[i] = entry + isNewEntry = false + break + } + } + + if isNewEntry { + entries.Entries = append(entries.Entries, &lockuptypes.UnbondingEntry{ + EndTime: msgUndelegateResp.CompletionTime, + Amount: msgUndelegateResp.Amount, + ValidatorAddress: msg.ValidatorAddress, + CreationHeight: header.Height, + }) + } + + err = bva.UnbondEntries.Set(ctx, msg.ValidatorAddress, entries) + if err != nil { + return nil, err + } + return &lockuptypes.MsgExecuteMessagesResponse{Responses: resp}, nil } @@ -282,105 +321,6 @@ func (bva *BaseLockup) SendCoins( return &lockuptypes.MsgExecuteMessagesResponse{Responses: resp}, nil } -// WithdrawUnlockedCoins allow owner to withdraw the unlocked token for a specific denoms to an -// account of choice. Update the withdrawed token tracking for lockup account -func (bva *BaseLockup) WithdrawUnlockedCoins( - ctx context.Context, msg *lockuptypes.MsgWithdraw, getLockedCoinsFunc getLockedCoinsFunc, -) ( - *lockuptypes.MsgWithdrawResponse, error, -) { - err := bva.checkSender(ctx, msg.Withdrawer) - if err != nil { - return nil, err - } - whoami := accountstd.Whoami(ctx) - fromAddress, err := bva.addressCodec.BytesToString(whoami) - if err != nil { - return nil, err - } - - // deduplicate the denoms - denoms := make(map[string]struct{}) - for _, denom := range msg.Denoms { - denoms[denom] = struct{}{} - } - uniqueDenoms := slices.Collect(maps.Keys(denoms)) - - hs := bva.headerService.HeaderInfo(ctx) - lockedCoins, err := getLockedCoinsFunc(ctx, hs.Time, uniqueDenoms...) - if err != nil { - return nil, err - } - - amount := sdk.Coins{} - for _, denom := range uniqueDenoms { - balance, err := bva.getBalance(ctx, fromAddress, denom) - if err != nil { - return nil, err - } - lockedAmt := lockedCoins.AmountOf(denom) - - // get lockedCoin from that are not bonded for the sent denom - notBondedLockedCoin, err := bva.GetNotBondedLockedCoin(ctx, sdk.NewCoin(denom, lockedAmt), denom) - if err != nil { - return nil, err - } - - spendable, err := balance.SafeSub(notBondedLockedCoin) - if err != nil { - return nil, errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, - "locked amount exceeds account balance funds: %s > %s", notBondedLockedCoin, balance) - } - - withdrawedAmt, err := bva.WithdrawedCoins.Get(ctx, denom) - if err != nil { - return nil, err - } - originalLockingAmt, err := bva.OriginalLocking.Get(ctx, denom) - if err != nil { - return nil, err - } - - // withdrawable amount is equal to original locking amount subtract already withdrawed amount - withdrawableAmt, err := originalLockingAmt.SafeSub(withdrawedAmt) - if err != nil { - return nil, err - } - - withdrawAmt := math.MinInt(withdrawableAmt, spendable.Amount) - // if zero amount go to the next iteration - if withdrawAmt.IsZero() { - continue - } - amount = append(amount, sdk.NewCoin(denom, withdrawAmt)) - - // update the withdrawed amount - err = bva.WithdrawedCoins.Set(ctx, denom, withdrawedAmt.Add(withdrawAmt)) - if err != nil { - return nil, err - } - } - if len(amount) == 0 { - return nil, errors.New("no tokens available for withdrawing") - } - - msgSend := &banktypes.MsgSend{ - FromAddress: fromAddress, - ToAddress: msg.ToAddress, - Amount: amount, - } - - _, err = sendMessage(ctx, msgSend) - if err != nil { - return nil, err - } - - return &lockuptypes.MsgWithdrawResponse{ - Receiver: msg.ToAddress, - AmountReceived: amount, - }, nil -} - func (bva *BaseLockup) checkSender(ctx context.Context, sender string) error { owner, err := bva.Owner.Get(ctx) if err != nil { @@ -416,6 +356,77 @@ func getStakingDenom(ctx context.Context) (string, error) { return resp.Params.BondDenom, nil } +// checkUnbondingEntriesMature iterates through all the unbonding entries and check if any of the entries are matured and handled. +func (bva *BaseLockup) checkUnbondingEntriesMature(ctx context.Context) error { + whoami := accountstd.Whoami(ctx) + delAddr, err := bva.addressCodec.BytesToString(whoami) + if err != nil { + return err + } + + currentTime := bva.headerService.HeaderInfo(ctx).Time + + removeKeys := []string{} + err = bva.UnbondEntries.Walk(ctx, nil, func(key string, value lockuptypes.UnbondingEntries) (stop bool, err error) { + for i := 0; i < len(value.Entries); i++ { + entry := value.Entries[i] + // if not mature then skip + if entry.EndTime.After(currentTime) { + return false, nil + } + + stakingUnbonding, err := bva.getUnbondingEntries(ctx, delAddr, key) + if err != nil { + // if ubd delegation is empty then skip the next iteration check + if !errorsmod.IsOf(err, stakingtypes.ErrNoUnbondingDelegation) { + return true, err + } + + } + + found := false + // check if the entry is still exist in the unbonding entries + for _, e := range stakingUnbonding { + if e.CompletionTime.Equal(entry.EndTime) && entry.CreationHeight == entry.CreationHeight { + found = true + break + } + } + + // if not found or ubd delegation is empty then assume ubd entry is being handled + if !found { + err = bva.TrackUndelegation(ctx, sdk.NewCoins(entry.Amount)) + if err != nil { + return true, err + } + + // remove entry + value.Entries = append(value.Entries[:i], value.Entries[i+1:]...) + i-- + } + } + + if len(value.Entries) == 0 { + removeKeys = append(removeKeys, key) + } else { + err = bva.UnbondEntries.Set(ctx, key, value) + if err != nil { + return true, err + } + } + + return false, nil + }) + + for _, key := range removeKeys { + err = bva.UnbondEntries.Remove(ctx, key) + if err != nil { + return err + } + } + return err +} + // 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. @@ -546,6 +557,17 @@ func (bva BaseLockup) getBalance(ctx context.Context, sender, denom string) (*sd return resp.Balance, nil } +func (bva BaseLockup) getUnbondingEntries(ctx context.Context, delAddr, valAddr string) ([]stakingtypes.UnbondingDelegationEntry, error) { + resp, err := accountstd.QueryModule[*stakingtypes.QueryUnbondingDelegationResponse]( + ctx, &stakingtypes.QueryUnbondingDelegationRequest{DelegatorAddr: delAddr, ValidatorAddr: valAddr}, + ) + if err != nil { + return nil, err + } + + return resp.Unbond.Entries, nil +} + func (bva BaseLockup) checkTokensSendable(ctx context.Context, sender string, amount, lockedCoins sdk.Coins) error { // Check if any sent tokens is exceeds lockup account balances for _, coin := range amount { @@ -597,6 +619,12 @@ 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) { + // refresh the unbonding entries + err := bva.checkUnbondingEntriesMature(ctx) + if err != nil { + return sdk.Coin{}, err + } + bondDenom, err := getStakingDenom(ctx) if err != nil { return sdk.Coin{}, err @@ -672,7 +700,67 @@ func (bva BaseLockup) QueryLockupAccountBaseInfo(ctx context.Context, _ *lockupt }, nil } +func (bva BaseLockup) QueryUnbondingEntries(ctx context.Context, req *lockuptypes.QueryUnbondingEntriesRequest) ( + *lockuptypes.QueryUnbondingEntriesResponse, error, +) { + entries, err := bva.UnbondEntries.Get(ctx, req.ValidatorAddress) + if err != nil { + if !errorsmod.IsOf(err, collections.ErrNotFound) { + return nil, err + } + + entries = lockuptypes.UnbondingEntries{ + Entries: []*lockuptypes.UnbondingEntry{}, + } + } + + return &lockuptypes.QueryUnbondingEntriesResponse{ + UnbondingEntries: entries.Entries, + }, nil +} + +func (bva BaseLockup) QuerySpendableTokens(ctx context.Context, lockedCoins sdk.Coins) ( + *lockuptypes.QuerySpendableAmountResponse, error, +) { + whoami := accountstd.Whoami(ctx) + accAddr, err := bva.addressCodec.BytesToString(whoami) + if err != nil { + return nil, err + } + + spendables := sdk.Coins{} + for _, denom := range lockedCoins.Denoms() { + balance, err := bva.getBalance(ctx, accAddr, denom) + if err != nil { + return nil, err + } + + lockedAmt := lockedCoins.AmountOf(balance.Denom) + + // get lockedCoin from that are not bonded for the sent denom + notBondedLockedCoin, err := bva.GetNotBondedLockedCoin(ctx, sdk.NewCoin(balance.Denom, lockedAmt), balance.Denom) + if err != nil { + return nil, err + } + + spendable, hasNeg := sdk.Coins{*balance}.SafeSub(notBondedLockedCoin) + if hasNeg { + spendable = sdk.Coins{sdk.NewCoin(balance.Denom, math.ZeroInt())} + } + + spendables = spendables.Add(spendable...) + } + + return &lockuptypes.QuerySpendableAmountResponse{ + SpendableTokens: spendables, + }, nil +} + func (bva BaseLockup) RegisterExecuteHandlers(builder *accountstd.ExecuteBuilder) { accountstd.RegisterExecuteHandler(builder, bva.Undelegate) accountstd.RegisterExecuteHandler(builder, bva.WithdrawReward) } + +func (bva BaseLockup) RegisterQueryHandlers(builder *accountstd.QueryBuilder) { + accountstd.RegisterQueryHandler(builder, bva.QueryUnbondingEntries) +} diff --git a/x/accounts/defaults/lockup/lockup_test.go b/x/accounts/defaults/lockup/lockup_test.go index 3a704d791796..0748a17e8caf 100644 --- a/x/accounts/defaults/lockup/lockup_test.go +++ b/x/accounts/defaults/lockup/lockup_test.go @@ -7,7 +7,9 @@ import ( "github.com/stretchr/testify/require" + "cosmossdk.io/core/header" "cosmossdk.io/core/store" + "cosmossdk.io/log" "cosmossdk.io/math" lockuptypes "cosmossdk.io/x/accounts/defaults/lockup/v1" @@ -229,6 +231,9 @@ func TestTrackingUnDelegation(t *testing.T) { func TestGetNotBondedLockedCoin(t *testing.T) { ctx, ss := newMockContext(t) + sdkCtx := sdk.NewContext(nil, true, log.NewNopLogger()).WithContext(ctx).WithHeaderInfo(header.Info{ + Time: time.Now(), + }) testcases := []struct { name string @@ -257,10 +262,10 @@ func TestGetNotBondedLockedCoin(t *testing.T) { } for _, test := range testcases { - baseLockup := setup(t, ctx, ss) - test.malaete(ctx, baseLockup) + baseLockup := setup(t, sdkCtx, ss) + test.malaete(sdkCtx, baseLockup) - lockedCoin, err := baseLockup.GetNotBondedLockedCoin(ctx, test.lockedCoin, "test") + lockedCoin, err := baseLockup.GetNotBondedLockedCoin(sdkCtx, test.lockedCoin, "test") require.NoError(t, err) require.True(t, test.expLockCoin.Equal(lockedCoin), test.name+" locked amount must be equal") diff --git a/x/accounts/defaults/lockup/periodic_locking_account.go b/x/accounts/defaults/lockup/periodic_locking_account.go index 61f7190f635d..6e2caba7e6cf 100644 --- a/x/accounts/defaults/lockup/periodic_locking_account.go +++ b/x/accounts/defaults/lockup/periodic_locking_account.go @@ -81,12 +81,6 @@ func (pva PeriodicLockingAccount) Init(ctx context.Context, msg *lockuptypes.Msg if err != nil { return nil, err } - - // Set initial value for all withdrawed token - err = pva.WithdrawedCoins.Set(ctx, coin.Denom, math.ZeroInt()) - if err != nil { - return nil, err - } } bondDenom, err := getStakingDenom(ctx) @@ -134,12 +128,6 @@ func (pva *PeriodicLockingAccount) SendCoins(ctx context.Context, msg *lockuptyp return pva.BaseLockup.SendCoins(ctx, msg, pva.GetLockedCoinsWithDenoms) } -func (pva *PeriodicLockingAccount) WithdrawUnlockedCoins(ctx context.Context, msg *lockuptypes.MsgWithdraw) ( - *lockuptypes.MsgWithdrawResponse, error, -) { - return pva.BaseLockup.WithdrawUnlockedCoins(ctx, msg, pva.GetLockedCoinsWithDenoms) -} - // IteratePeriods iterates over all the Periods entries. func (pva PeriodicLockingAccount) IteratePeriods( ctx context.Context, @@ -336,11 +324,11 @@ func (pva PeriodicLockingAccount) RegisterInitHandler(builder *accountstd.InitBu func (pva PeriodicLockingAccount) RegisterExecuteHandlers(builder *accountstd.ExecuteBuilder) { accountstd.RegisterExecuteHandler(builder, pva.Delegate) accountstd.RegisterExecuteHandler(builder, pva.SendCoins) - accountstd.RegisterExecuteHandler(builder, pva.WithdrawUnlockedCoins) pva.BaseLockup.RegisterExecuteHandlers(builder) } func (pva PeriodicLockingAccount) RegisterQueryHandlers(builder *accountstd.QueryBuilder) { accountstd.RegisterQueryHandler(builder, pva.QueryLockupAccountInfo) accountstd.RegisterQueryHandler(builder, pva.QueryLockingPeriods) + pva.BaseLockup.RegisterQueryHandlers(builder) } diff --git a/x/accounts/defaults/lockup/periodic_locking_account_test.go b/x/accounts/defaults/lockup/periodic_locking_account_test.go index 52478cea076f..bff11684e7f3 100644 --- a/x/accounts/defaults/lockup/periodic_locking_account_test.go +++ b/x/accounts/defaults/lockup/periodic_locking_account_test.go @@ -135,48 +135,22 @@ func TestPeriodicAccountUndelegate(t *testing.T) { }) require.NoError(t, err) - delLocking, err = acc.DelegatedLocking.Get(ctx, "test") - require.NoError(t, err) - require.True(t, delLocking.Equal(math.ZeroInt())) - - startTime, err := acc.StartTime.Get(sdkCtx) - require.NoError(t, err) - - // Update context time to unlocked first period token - sdkCtx = sdkCtx.WithHeaderInfo(header.Info{ - Time: startTime.Add(time.Minute * 1), - }) - - _, err = acc.Delegate(sdkCtx, &lockuptypes.MsgDelegate{ - Sender: "owner", - ValidatorAddress: "val_address", - Amount: sdk.NewCoin("test", math.NewInt(6)), - }) + // sequence should be the previous one + entries, err := acc.UnbondEntries.Get(sdkCtx, "val_address") require.NoError(t, err) + require.Len(t, entries.Entries, 1) + require.True(t, entries.Entries[0].Amount.Amount.Equal(math.NewInt(1))) + require.True(t, entries.Entries[0].ValidatorAddress == "val_address") - delLocking, err = acc.DelegatedLocking.Get(ctx, "test") - require.NoError(t, err) - require.True(t, delLocking.Equal(math.NewInt(5))) - - delFree, err := acc.DelegatedFree.Get(ctx, "test") + err = acc.checkUnbondingEntriesMature(sdkCtx) require.NoError(t, err) - require.True(t, delFree.Equal(math.NewInt(1))) - // Undelegate - _, err = acc.Undelegate(sdkCtx, &lockuptypes.MsgUndelegate{ - Sender: "owner", - ValidatorAddress: "val_address", - Amount: sdk.NewCoin("test", math.NewInt(4)), - }) - require.NoError(t, err) + _, err = acc.UnbondEntries.Get(sdkCtx, "val_address") + require.Error(t, err) delLocking, err = acc.DelegatedLocking.Get(ctx, "test") require.NoError(t, err) - require.True(t, delLocking.Equal(math.NewInt(2))) - - delFree, err = acc.DelegatedFree.Get(ctx, "test") - require.NoError(t, err) - require.True(t, delFree.Equal(math.ZeroInt())) + require.True(t, delLocking.Equal(math.ZeroInt())) } func TestPeriodicAccountSendCoins(t *testing.T) { @@ -209,40 +183,6 @@ func TestPeriodicAccountSendCoins(t *testing.T) { require.NoError(t, err) } -func TestPeriodicAccountWithdrawUnlockedCoins(t *testing.T) { - ctx, ss := newMockContext(t) - sdkCtx := sdk.NewContext(nil, true, log.NewNopLogger()).WithContext(ctx).WithHeaderInfo(header.Info{ - Time: time.Now(), - }) - - acc := setupPeriodicAccount(t, sdkCtx, ss) - _, err := acc.WithdrawUnlockedCoins(sdkCtx, &lockuptypes.MsgWithdraw{ - Withdrawer: "owner", - ToAddress: "receiver", - Denoms: []string{"test"}, - }) - require.Error(t, err) - - startTime, err := acc.StartTime.Get(sdkCtx) - require.NoError(t, err) - - // Update context time to unlocked first period token - sdkCtx = sdkCtx.WithHeaderInfo(header.Info{ - Time: startTime.Add(time.Minute * 1), - }) - - // withdraw unlocked token - resp, err := acc.WithdrawUnlockedCoins(sdkCtx, &lockuptypes.MsgWithdraw{ - Withdrawer: "owner", - ToAddress: "receiver", - Denoms: []string{"test", "test"}, // duplicate tokens should be ignored - }) - require.NoError(t, err) - require.Equal(t, resp.AmountReceived.Len(), 1) - require.Equal(t, resp.AmountReceived, sdk.NewCoins(sdk.NewCoin("test", math.NewInt(5)))) - require.Equal(t, resp.Receiver, "receiver") -} - func TestPeriodicAccountGetLockCoinInfo(t *testing.T) { ctx, ss := newMockContext(t) sdkCtx := sdk.NewContext(nil, true, log.NewNopLogger()).WithContext(ctx).WithHeaderInfo(header.Info{ diff --git a/x/accounts/defaults/lockup/permanent_locking_account.go b/x/accounts/defaults/lockup/permanent_locking_account.go index 8c1d633215e3..ee0d0a447a95 100644 --- a/x/accounts/defaults/lockup/permanent_locking_account.go +++ b/x/accounts/defaults/lockup/permanent_locking_account.go @@ -107,4 +107,5 @@ func (plva PermanentLockingAccount) RegisterExecuteHandlers(builder *accountstd. func (plva PermanentLockingAccount) RegisterQueryHandlers(builder *accountstd.QueryBuilder) { accountstd.RegisterQueryHandler(builder, plva.QueryLockupAccountInfo) + plva.BaseLockup.RegisterQueryHandlers(builder) } diff --git a/x/accounts/defaults/lockup/permanent_locking_account_test.go b/x/accounts/defaults/lockup/permanent_locking_account_test.go index ce0fd54fee04..224bfbb83e0a 100644 --- a/x/accounts/defaults/lockup/permanent_locking_account_test.go +++ b/x/accounts/defaults/lockup/permanent_locking_account_test.go @@ -77,6 +77,19 @@ func TestPermanentAccountUndelegate(t *testing.T) { }) require.NoError(t, err) + // sequence should be the previous one + entries, err := acc.UnbondEntries.Get(sdkCtx, "val_address") + require.NoError(t, err) + require.Len(t, entries.Entries, 1) + require.True(t, entries.Entries[0].Amount.Amount.Equal(math.NewInt(1))) + require.True(t, entries.Entries[0].ValidatorAddress == "val_address") + + err = acc.checkUnbondingEntriesMature(sdkCtx) + require.NoError(t, err) + + _, err = acc.UnbondEntries.Get(sdkCtx, "val_address") + require.Error(t, err) + delLocking, err = acc.DelegatedLocking.Get(ctx, "test") require.NoError(t, err) require.True(t, delLocking.Equal(math.ZeroInt())) diff --git a/x/accounts/defaults/lockup/utils_test.go b/x/accounts/defaults/lockup/utils_test.go index 6d5ce14af7ed..684e43b79bd3 100644 --- a/x/accounts/defaults/lockup/utils_test.go +++ b/x/accounts/defaults/lockup/utils_test.go @@ -4,9 +4,9 @@ import ( "context" "errors" "testing" + "time" gogoproto "github.com/cosmos/gogoproto/proto" - "github.com/stretchr/testify/require" "cosmossdk.io/collections" appmodulev2 "cosmossdk.io/core/appmodule/v2" @@ -77,7 +77,9 @@ func newMockContext(t *testing.T) (context.Context, store.KVStoreService) { case "/cosmos.staking.v1beta1.MsgDelegate": return &stakingtypes.MsgDelegateResponse{}, nil case "/cosmos.staking.v1beta1.MsgUndelegate": - return &stakingtypes.MsgUndelegate{}, nil + return &stakingtypes.MsgUndelegateResponse{ + Amount: sdk.NewCoin("test", math.NewInt(1)), + }, nil case "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward": return &distrtypes.MsgWithdrawDelegatorRewardResponse{}, nil case "/cosmos.bank.v1beta1.MsgSend": @@ -86,23 +88,44 @@ func newMockContext(t *testing.T) (context.Context, store.KVStoreService) { return nil, errors.New("unrecognized request type") } }, func(ctx context.Context, req transaction.Msg) (transaction.Msg, error) { - _, ok := req.(*banktypes.QueryBalanceRequest) - if !ok { - _, ok = req.(*stakingtypes.QueryParamsRequest) - require.True(t, ok) + typeUrl := sdk.MsgTypeURL(req) + switch typeUrl { + case "/cosmos.staking.v1beta1.QueryParamsRequest": return &stakingtypes.QueryParamsResponse{ Params: stakingtypes.Params{ BondDenom: "test", }, }, nil + case "/cosmos.staking.v1beta1.QueryUnbondingDelegationRequest": + return &stakingtypes.QueryUnbondingDelegationResponse{ + Unbond: stakingtypes.UnbondingDelegation{ + DelegatorAddress: "sender", + ValidatorAddress: "val_address", + Entries: []stakingtypes.UnbondingDelegationEntry{ + { + CreationHeight: 1, + CompletionTime: time.Now(), + Balance: math.NewInt(1), + }, + { + CreationHeight: 1, + CompletionTime: time.Now().Add(time.Hour), + Balance: math.NewInt(1), + }, + }, + }, + }, nil + case "/cosmos.bank.v1beta1.QueryBalanceRequest": + return &banktypes.QueryBalanceResponse{ + Balance: &(sdk.Coin{ + Denom: "test", + Amount: TestFunds.AmountOf("test"), + }), + }, nil + default: + return nil, errors.New("unrecognized request type") } - return &banktypes.QueryBalanceResponse{ - Balance: &(sdk.Coin{ - Denom: "test", - Amount: TestFunds.AmountOf("test"), - }), - }, nil }, ) } diff --git a/x/accounts/defaults/lockup/v1/lockup.pb.go b/x/accounts/defaults/lockup/v1/lockup.pb.go index c6c9ac175a3a..7b9e835a9e43 100644 --- a/x/accounts/defaults/lockup/v1/lockup.pb.go +++ b/x/accounts/defaults/lockup/v1/lockup.pb.go @@ -5,6 +5,7 @@ package v1 import ( fmt "fmt" + _ "github.com/cosmos/cosmos-proto" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" @@ -12,6 +13,7 @@ import ( proto "github.com/cosmos/gogoproto/proto" github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" _ "google.golang.org/protobuf/types/known/durationpb" + _ "google.golang.org/protobuf/types/known/timestamppb" io "io" math "math" math_bits "math/bits" @@ -84,8 +86,126 @@ func (m *Period) GetAmount() github_com_cosmos_cosmos_sdk_types.Coins { return nil } +type UnbondingEntries struct { + Entries []*UnbondingEntry `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"` +} + +func (m *UnbondingEntries) Reset() { *m = UnbondingEntries{} } +func (m *UnbondingEntries) String() string { return proto.CompactTextString(m) } +func (*UnbondingEntries) ProtoMessage() {} +func (*UnbondingEntries) Descriptor() ([]byte, []int) { + return fileDescriptor_6b9783f5e2b76d96, []int{1} +} +func (m *UnbondingEntries) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *UnbondingEntries) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_UnbondingEntries.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 *UnbondingEntries) XXX_Merge(src proto.Message) { + xxx_messageInfo_UnbondingEntries.Merge(m, src) +} +func (m *UnbondingEntries) XXX_Size() int { + return m.Size() +} +func (m *UnbondingEntries) XXX_DiscardUnknown() { + xxx_messageInfo_UnbondingEntries.DiscardUnknown(m) +} + +var xxx_messageInfo_UnbondingEntries proto.InternalMessageInfo + +func (m *UnbondingEntries) GetEntries() []*UnbondingEntry { + if m != nil { + return m.Entries + } + return nil +} + +// UnbondingEntry defines an entry tracking the lockup account unbonding operation. +type UnbondingEntry struct { + CreationHeight int64 `protobuf:"varint,1,opt,name=creation_height,json=creationHeight,proto3" json:"creation_height,omitempty"` + // end time of entry + EndTime time.Time `protobuf:"bytes,2,opt,name=end_time,json=endTime,proto3,stdtime" json:"end_time"` + // unbond amount + Amount types.Coin `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount"` + // validator address + ValidatorAddress string `protobuf:"bytes,4,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` +} + +func (m *UnbondingEntry) Reset() { *m = UnbondingEntry{} } +func (m *UnbondingEntry) String() string { return proto.CompactTextString(m) } +func (*UnbondingEntry) ProtoMessage() {} +func (*UnbondingEntry) Descriptor() ([]byte, []int) { + return fileDescriptor_6b9783f5e2b76d96, []int{2} +} +func (m *UnbondingEntry) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *UnbondingEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_UnbondingEntry.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 *UnbondingEntry) XXX_Merge(src proto.Message) { + xxx_messageInfo_UnbondingEntry.Merge(m, src) +} +func (m *UnbondingEntry) XXX_Size() int { + return m.Size() +} +func (m *UnbondingEntry) XXX_DiscardUnknown() { + xxx_messageInfo_UnbondingEntry.DiscardUnknown(m) +} + +var xxx_messageInfo_UnbondingEntry proto.InternalMessageInfo + +func (m *UnbondingEntry) GetCreationHeight() int64 { + if m != nil { + return m.CreationHeight + } + return 0 +} + +func (m *UnbondingEntry) GetEndTime() time.Time { + if m != nil { + return m.EndTime + } + return time.Time{} +} + +func (m *UnbondingEntry) GetAmount() types.Coin { + if m != nil { + return m.Amount + } + return types.Coin{} +} + +func (m *UnbondingEntry) GetValidatorAddress() string { + if m != nil { + return m.ValidatorAddress + } + return "" +} + func init() { proto.RegisterType((*Period)(nil), "cosmos.accounts.defaults.lockup.v1.Period") + proto.RegisterType((*UnbondingEntries)(nil), "cosmos.accounts.defaults.lockup.v1.UnbondingEntries") + proto.RegisterType((*UnbondingEntry)(nil), "cosmos.accounts.defaults.lockup.v1.UnbondingEntry") } func init() { @@ -93,28 +213,40 @@ func init() { } var fileDescriptor_6b9783f5e2b76d96 = []byte{ - // 327 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0x31, 0x4e, 0xc3, 0x30, - 0x18, 0x85, 0x63, 0x90, 0x32, 0x04, 0x18, 0xa8, 0x18, 0x4a, 0x07, 0xb7, 0xea, 0x54, 0x55, 0xc2, - 0xbf, 0x02, 0x17, 0x40, 0xa5, 0x62, 0x46, 0x8c, 0x2c, 0xc8, 0x71, 0x5c, 0xd7, 0x6a, 0x92, 0xbf, - 0xaa, 0x9d, 0x8a, 0xde, 0x82, 0x11, 0x71, 0x02, 0xc4, 0xd4, 0x4b, 0x20, 0x75, 0xec, 0xc8, 0x44, - 0x51, 0x33, 0xf4, 0x1a, 0x28, 0x89, 0xb3, 0xb2, 0x24, 0xcf, 0xb2, 0xbf, 0xf7, 0xfe, 0x67, 0x07, - 0x20, 0xd0, 0xa4, 0x68, 0x80, 0x0b, 0x81, 0x79, 0x66, 0x0d, 0xc4, 0x72, 0xc2, 0xf3, 0xc4, 0x1a, - 0x48, 0x50, 0xcc, 0xf2, 0x39, 0x2c, 0x43, 0xa7, 0xd8, 0x7c, 0x81, 0x16, 0x5b, 0xfd, 0x1a, 0x60, - 0x0d, 0xc0, 0x1a, 0x80, 0xb9, 0x63, 0xcb, 0xb0, 0x73, 0xce, 0x53, 0x9d, 0x21, 0x54, 0xdf, 0x1a, - 0xeb, 0x50, 0x97, 0x13, 0x71, 0x23, 0x61, 0x19, 0x46, 0xd2, 0xf2, 0x10, 0x04, 0xea, 0xcc, 0xed, - 0x5f, 0x28, 0x54, 0x58, 0x49, 0x28, 0x55, 0x43, 0x29, 0x44, 0x95, 0x48, 0xa8, 0x56, 0x51, 0x3e, - 0x81, 0x38, 0x5f, 0x70, 0xab, 0xd1, 0x51, 0xfd, 0x2f, 0x12, 0xf8, 0x0f, 0x72, 0xa1, 0x31, 0x6e, - 0xdd, 0x06, 0x7e, 0x22, 0x33, 0x65, 0xa7, 0x6d, 0xd2, 0x23, 0x83, 0x93, 0xeb, 0x4b, 0x56, 0xb3, - 0xac, 0x61, 0xd9, 0xd8, 0xb1, 0xa3, 0xb3, 0xcd, 0x4f, 0xd7, 0x7b, 0xdb, 0x75, 0xc9, 0xc7, 0x61, - 0x3d, 0x24, 0x8f, 0x8e, 0x6b, 0xad, 0x02, 0x9f, 0xa7, 0x65, 0xa7, 0xf6, 0x51, 0xef, 0xb8, 0x72, - 0x70, 0x55, 0xcb, 0x99, 0x99, 0x9b, 0x99, 0xdd, 0xa1, 0xce, 0x46, 0xf7, 0xa5, 0xc3, 0xe7, 0xae, - 0x3b, 0x50, 0xda, 0x4e, 0xf3, 0x88, 0x09, 0x4c, 0x9b, 0x8b, 0xac, 0x7f, 0x57, 0x26, 0x9e, 0x81, - 0x5d, 0xcd, 0xa5, 0xa9, 0x00, 0xf3, 0x7e, 0x58, 0x0f, 0x4f, 0x13, 0xa9, 0xb8, 0x58, 0x3d, 0x97, - 0xad, 0x8d, 0x8b, 0xae, 0x03, 0x47, 0xe3, 0xcd, 0x9e, 0x92, 0xed, 0x9e, 0x92, 0xdf, 0x3d, 0x25, - 0xaf, 0x05, 0xf5, 0xb6, 0x05, 0xf5, 0xbe, 0x0b, 0xea, 0x3d, 0x0d, 0x6b, 0x3f, 0x13, 0xcf, 0x98, - 0x46, 0x78, 0xf9, 0xef, 0x9d, 0x22, 0xbf, 0xaa, 0x7a, 0xf3, 0x17, 0x00, 0x00, 0xff, 0xff, 0xf4, - 0xa4, 0x0b, 0x08, 0xd4, 0x01, 0x00, 0x00, + // 517 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0xcf, 0x6e, 0x13, 0x31, + 0x10, 0xc6, 0xe3, 0x06, 0xa5, 0xd4, 0x40, 0x69, 0x57, 0x1c, 0xd2, 0x48, 0x6c, 0x42, 0x2e, 0x44, + 0x91, 0x6a, 0x2b, 0xe5, 0xca, 0x01, 0x42, 0x40, 0x1c, 0x10, 0x42, 0xe1, 0xcf, 0x81, 0x4b, 0xf0, + 0xae, 0x5d, 0xc7, 0xca, 0xae, 0x1d, 0xad, 0xbd, 0x2b, 0xf2, 0x10, 0x48, 0x3d, 0x22, 0x9e, 0x00, + 0x71, 0xea, 0x81, 0x57, 0x40, 0xea, 0xb1, 0xe2, 0xc4, 0x89, 0xa2, 0xe4, 0xd0, 0xd7, 0x40, 0x6b, + 0x7b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7, 0xfd, 0xdb, 0xde, + 0xeb, 0x4d, 0x75, 0xe6, 0xa1, 0x3b, 0xf2, 0xd2, 0x64, 0x42, 0xf2, 0xf1, 0x4e, 0x71, 0x29, 0x3f, + 0x1c, 0x9d, 0x2c, 0x43, 0x70, 0xba, 0x0c, 0xc1, 0xaf, 0x65, 0x08, 0x8e, 0x56, 0x61, 0xed, 0x74, + 0x15, 0xd6, 0x7e, 0xac, 0xc2, 0xda, 0xdb, 0xbe, 0xb3, 0xd2, 0x74, 0x86, 0x84, 0xc2, 0xef, 0xff, + 0xf5, 0x57, 0x45, 0x0d, 0x3b, 0xff, 0xbd, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xe3, 0xd3, 0xd6, + 0xb7, 0x82, 0x03, 0x00, 0x00, } func (m *Period) Marshal() (dAtA []byte, err error) { @@ -162,6 +294,96 @@ func (m *Period) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *UnbondingEntries) 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 *UnbondingEntries) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *UnbondingEntries) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Entries) > 0 { + for iNdEx := len(m.Entries) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Entries[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLockup(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *UnbondingEntry) 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 *UnbondingEntry) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *UnbondingEntry) 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 = encodeVarintLockup(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0x22 + } + { + size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLockup(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + n3, err3 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.EndTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.EndTime):]) + if err3 != nil { + return 0, err3 + } + i -= n3 + i = encodeVarintLockup(dAtA, i, uint64(n3)) + i-- + dAtA[i] = 0x12 + if m.CreationHeight != 0 { + i = encodeVarintLockup(dAtA, i, uint64(m.CreationHeight)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintLockup(dAtA []byte, offset int, v uint64) int { offset -= sovLockup(v) base := offset @@ -190,6 +412,41 @@ func (m *Period) Size() (n int) { return n } +func (m *UnbondingEntries) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Entries) > 0 { + for _, e := range m.Entries { + l = e.Size() + n += 1 + l + sovLockup(uint64(l)) + } + } + return n +} + +func (m *UnbondingEntry) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CreationHeight != 0 { + n += 1 + sovLockup(uint64(m.CreationHeight)) + } + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.EndTime) + n += 1 + l + sovLockup(uint64(l)) + l = m.Amount.Size() + n += 1 + l + sovLockup(uint64(l)) + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovLockup(uint64(l)) + } + return n +} + func sovLockup(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -313,6 +570,257 @@ func (m *Period) Unmarshal(dAtA []byte) error { } return nil } +func (m *UnbondingEntries) 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 ErrIntOverflowLockup + } + 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: UnbondingEntries: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UnbondingEntries: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Entries", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLockup + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLockup + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLockup + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Entries = append(m.Entries, &UnbondingEntry{}) + if err := m.Entries[len(m.Entries)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLockup(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLockup + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *UnbondingEntry) 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 ErrIntOverflowLockup + } + 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: UnbondingEntry: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UnbondingEntry: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CreationHeight", wireType) + } + m.CreationHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLockup + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CreationHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EndTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLockup + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLockup + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLockup + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.EndTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLockup + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLockup + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLockup + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + 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 ErrIntOverflowLockup + } + 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 ErrInvalidLengthLockup + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLockup + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLockup(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLockup + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipLockup(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/accounts/defaults/lockup/v1/query.pb.go b/x/accounts/defaults/lockup/v1/query.pb.go index c3b9a75d07db..bdea948f1fa2 100644 --- a/x/accounts/defaults/lockup/v1/query.pb.go +++ b/x/accounts/defaults/lockup/v1/query.pb.go @@ -5,6 +5,7 @@ package v1 import ( fmt "fmt" + _ "github.com/cosmos/cosmos-proto" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" @@ -175,6 +176,97 @@ func (m *QueryLockupAccountInfoResponse) GetOwner() string { return "" } +// QueryUnbondingEntriesRequest is used to query the lockup account unbonding entries. +type QueryUnbondingEntriesRequest struct { + ValidatorAddress string `protobuf:"bytes,1,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` +} + +func (m *QueryUnbondingEntriesRequest) Reset() { *m = QueryUnbondingEntriesRequest{} } +func (m *QueryUnbondingEntriesRequest) String() string { return proto.CompactTextString(m) } +func (*QueryUnbondingEntriesRequest) ProtoMessage() {} +func (*QueryUnbondingEntriesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f2c1403191515490, []int{2} +} +func (m *QueryUnbondingEntriesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryUnbondingEntriesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryUnbondingEntriesRequest.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 *QueryUnbondingEntriesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryUnbondingEntriesRequest.Merge(m, src) +} +func (m *QueryUnbondingEntriesRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryUnbondingEntriesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryUnbondingEntriesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryUnbondingEntriesRequest proto.InternalMessageInfo + +func (m *QueryUnbondingEntriesRequest) GetValidatorAddress() string { + if m != nil { + return m.ValidatorAddress + } + return "" +} + +// QueryUnbondingEntriesResponse returns the lockup account unbonding entries. +type QueryUnbondingEntriesResponse struct { + // UnbondingEntry defines the list of unbonding entries. + UnbondingEntries []*UnbondingEntry `protobuf:"bytes,1,rep,name=unbonding_entries,json=unbondingEntries,proto3" json:"unbonding_entries,omitempty"` +} + +func (m *QueryUnbondingEntriesResponse) Reset() { *m = QueryUnbondingEntriesResponse{} } +func (m *QueryUnbondingEntriesResponse) String() string { return proto.CompactTextString(m) } +func (*QueryUnbondingEntriesResponse) ProtoMessage() {} +func (*QueryUnbondingEntriesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f2c1403191515490, []int{3} +} +func (m *QueryUnbondingEntriesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryUnbondingEntriesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryUnbondingEntriesResponse.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 *QueryUnbondingEntriesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryUnbondingEntriesResponse.Merge(m, src) +} +func (m *QueryUnbondingEntriesResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryUnbondingEntriesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryUnbondingEntriesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryUnbondingEntriesResponse proto.InternalMessageInfo + +func (m *QueryUnbondingEntriesResponse) GetUnbondingEntries() []*UnbondingEntry { + if m != nil { + return m.UnbondingEntries + } + return nil +} + // QueryLockingPeriodsRequest is used to query the periodic lockup account locking periods. type QueryLockingPeriodsRequest struct { } @@ -183,7 +275,7 @@ func (m *QueryLockingPeriodsRequest) Reset() { *m = QueryLockingPeriodsR func (m *QueryLockingPeriodsRequest) String() string { return proto.CompactTextString(m) } func (*QueryLockingPeriodsRequest) ProtoMessage() {} func (*QueryLockingPeriodsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f2c1403191515490, []int{2} + return fileDescriptor_f2c1403191515490, []int{4} } func (m *QueryLockingPeriodsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -222,7 +314,7 @@ func (m *QueryLockingPeriodsResponse) Reset() { *m = QueryLockingPeriods func (m *QueryLockingPeriodsResponse) String() string { return proto.CompactTextString(m) } func (*QueryLockingPeriodsResponse) ProtoMessage() {} func (*QueryLockingPeriodsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f2c1403191515490, []int{3} + return fileDescriptor_f2c1403191515490, []int{5} } func (m *QueryLockingPeriodsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -258,11 +350,97 @@ func (m *QueryLockingPeriodsResponse) GetLockingPeriods() []*Period { return nil } +// QuerySpendableAmountRequest is used to query the lockup account total spendable tokens. +type QuerySpendableAmountRequest struct { +} + +func (m *QuerySpendableAmountRequest) Reset() { *m = QuerySpendableAmountRequest{} } +func (m *QuerySpendableAmountRequest) String() string { return proto.CompactTextString(m) } +func (*QuerySpendableAmountRequest) ProtoMessage() {} +func (*QuerySpendableAmountRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f2c1403191515490, []int{6} +} +func (m *QuerySpendableAmountRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySpendableAmountRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySpendableAmountRequest.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 *QuerySpendableAmountRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySpendableAmountRequest.Merge(m, src) +} +func (m *QuerySpendableAmountRequest) XXX_Size() int { + return m.Size() +} +func (m *QuerySpendableAmountRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySpendableAmountRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySpendableAmountRequest proto.InternalMessageInfo + +// QuerySpendableAmountResponse returns lockup account total spendable tokens. +type QuerySpendableAmountResponse struct { + SpendableTokens github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=spendable_tokens,json=spendableTokens,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"spendable_tokens"` +} + +func (m *QuerySpendableAmountResponse) Reset() { *m = QuerySpendableAmountResponse{} } +func (m *QuerySpendableAmountResponse) String() string { return proto.CompactTextString(m) } +func (*QuerySpendableAmountResponse) ProtoMessage() {} +func (*QuerySpendableAmountResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f2c1403191515490, []int{7} +} +func (m *QuerySpendableAmountResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySpendableAmountResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySpendableAmountResponse.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 *QuerySpendableAmountResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySpendableAmountResponse.Merge(m, src) +} +func (m *QuerySpendableAmountResponse) XXX_Size() int { + return m.Size() +} +func (m *QuerySpendableAmountResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySpendableAmountResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySpendableAmountResponse proto.InternalMessageInfo + +func (m *QuerySpendableAmountResponse) GetSpendableTokens() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.SpendableTokens + } + return nil +} + func init() { proto.RegisterType((*QueryLockupAccountInfoRequest)(nil), "cosmos.accounts.defaults.lockup.v1.QueryLockupAccountInfoRequest") proto.RegisterType((*QueryLockupAccountInfoResponse)(nil), "cosmos.accounts.defaults.lockup.v1.QueryLockupAccountInfoResponse") + proto.RegisterType((*QueryUnbondingEntriesRequest)(nil), "cosmos.accounts.defaults.lockup.v1.QueryUnbondingEntriesRequest") + proto.RegisterType((*QueryUnbondingEntriesResponse)(nil), "cosmos.accounts.defaults.lockup.v1.QueryUnbondingEntriesResponse") proto.RegisterType((*QueryLockingPeriodsRequest)(nil), "cosmos.accounts.defaults.lockup.v1.QueryLockingPeriodsRequest") proto.RegisterType((*QueryLockingPeriodsResponse)(nil), "cosmos.accounts.defaults.lockup.v1.QueryLockingPeriodsResponse") + proto.RegisterType((*QuerySpendableAmountRequest)(nil), "cosmos.accounts.defaults.lockup.v1.QuerySpendableAmountRequest") + proto.RegisterType((*QuerySpendableAmountResponse)(nil), "cosmos.accounts.defaults.lockup.v1.QuerySpendableAmountResponse") } func init() { @@ -270,39 +448,48 @@ func init() { } var fileDescriptor_f2c1403191515490 = []byte{ - // 510 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x94, 0x4d, 0x6f, 0xd3, 0x30, - 0x18, 0xc7, 0x1b, 0xb6, 0xee, 0xc5, 0x85, 0x6d, 0x44, 0x3b, 0x84, 0x02, 0x49, 0xd5, 0x53, 0x35, - 0x09, 0x9b, 0x8e, 0x23, 0x07, 0x44, 0x41, 0x48, 0x48, 0x3b, 0x40, 0xe0, 0xc4, 0x25, 0xca, 0xcb, - 0xd3, 0x60, 0x35, 0xb5, 0x33, 0xdb, 0x29, 0xdb, 0xb7, 0xd8, 0xe7, 0xe0, 0x93, 0xec, 0xb8, 0x23, - 0x27, 0x86, 0xda, 0xef, 0x81, 0x50, 0x62, 0xbb, 0x68, 0x12, 0x2f, 0x3d, 0x74, 0xa7, 0xc4, 0xf6, - 0xf3, 0xfc, 0x7f, 0xcf, 0xe3, 0xbf, 0x6d, 0x84, 0x53, 0x2e, 0xa7, 0x5c, 0x92, 0x38, 0x4d, 0x79, - 0xc5, 0x94, 0x24, 0x19, 0x8c, 0xe3, 0xaa, 0x50, 0x92, 0x14, 0x3c, 0x9d, 0x54, 0x25, 0x99, 0x0d, - 0xc9, 0x69, 0x05, 0xe2, 0x1c, 0x97, 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a, 0x74, - 0xa4, 0x45, 0x65, 0x36, 0xc1, 0x94, 0x93, 0xb3, 0x7f, 0xbd, 0x2e, 0xc9, 0x56, 0x63, 0xfa, 0xb3, - 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x78, 0xc7, 0xe4, 0x56, 0xde, 0x04, 0x00, 0x00, + // 654 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xcb, 0x4e, 0xdb, 0x4c, + 0x14, 0x8e, 0x7f, 0xee, 0xc3, 0xff, 0x43, 0x88, 0x58, 0x84, 0xfc, 0xe0, 0x50, 0xaf, 0x22, 0x24, + 0x66, 0x1a, 0xba, 0xec, 0xa2, 0x22, 0xbd, 0x48, 0x95, 0x50, 0xd5, 0x1a, 0xda, 0x45, 0x37, 0x96, + 0x9d, 0x39, 0x71, 0x47, 0x71, 0x66, 0xc2, 0xcc, 0x38, 0x85, 0x5d, 0x1f, 0x81, 0x55, 0x1f, 0xa2, + 0xeb, 0x3e, 0x04, 0x4b, 0xd4, 0x55, 0x57, 0xa5, 0x82, 0xf7, 0xa8, 0x2a, 0x7b, 0x66, 0x82, 0x80, + 0x5e, 0x58, 0xc0, 0x2a, 0x3e, 0x73, 0xce, 0xf9, 0x2e, 0x3e, 0x3e, 0x13, 0x84, 0xbb, 0x42, 0x0d, + 0x84, 0x22, 0x71, 0xb7, 0x2b, 0x72, 0xae, 0x15, 0xa1, 0xd0, 0x8b, 0xf3, 0x4c, 0x2b, 0x92, 0x89, + 0x6e, 0x3f, 0x1f, 0x92, 0x51, 0x9b, 0xec, 0xe7, 0x20, 0x0f, 0xf1, 0x50, 0x0a, 0x2d, 0x6a, 0x81, + 0xa9, 0xc7, 0xae, 0x1e, 0xbb, 0x7a, 0x6c, 0xea, 0xf1, 0xa8, 0xdd, 0x20, 0x37, 0xc0, 0xb4, 0xd5, + 0x25, 0x68, 0xc3, 0xb7, 0x0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0xc3, 0x6a, 0x7e, 0x85, 0x28, 0x58, 0x45, 0x8d, 0xf1, 0xca, 0x33, 0x9e, 0xbe, + 0x04, 0xc9, 0x04, 0x75, 0x86, 0x03, 0x89, 0xfe, 0xff, 0x65, 0xd6, 0xaa, 0xdb, 0x45, 0x8b, 0x76, + 0x2f, 0xa2, 0xa1, 0x49, 0x59, 0x6d, 0x1b, 0x37, 0xd1, 0x66, 0xd0, 0xc2, 0x85, 0xec, 0x12, 0x78, + 0xb0, 0x66, 0x39, 0x77, 0x87, 0xc0, 0x69, 0x9c, 0x64, 0xb0, 0x3d, 0x28, 0x20, 0x9c, 0xa4, 0x8f, + 0x9e, 0x1d, 0xd2, 0xb5, 0xfc, 0xc5, 0x15, 0xa5, 0x5c, 0x2a, 0xd2, 0xa2, 0x0f, 0x5c, 0xdd, 0xc9, + 0x15, 0x35, 0x26, 0xd9, 0x2b, 0x39, 0x3a, 0x4f, 0x8e, 0xcf, 0x7c, 0xef, 0xe4, 0xcc, 0xf7, 0xbe, + 0x9f, 0xf9, 0xde, 0xd1, 0xb9, 0x5f, 0x39, 0x39, 0xf7, 0x2b, 0x5f, 0xcf, 0xfd, 0xca, 0xdb, 0x0d, + 0x03, 0xa1, 0x68, 0x1f, 0x33, 0x41, 0x0e, 0xfe, 0xf4, 0x1f, 0x91, 0x4c, 0x97, 0xfb, 0xf9, 0xe0, + 0x67, 0x00, 0x00, 0x00, 0xff, 0xff, 0x35, 0xa7, 0xeb, 0x0d, 0xa4, 0x06, 0x00, 0x00, } func (m *QueryLockupAccountInfoRequest) Marshal() (dAtA []byte, err error) { @@ -448,6 +635,73 @@ func (m *QueryLockupAccountInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *QueryUnbondingEntriesRequest) 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 *QueryUnbondingEntriesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryUnbondingEntriesRequest) 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 = encodeVarintQuery(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryUnbondingEntriesResponse) 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 *QueryUnbondingEntriesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryUnbondingEntriesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.UnbondingEntries) > 0 { + for iNdEx := len(m.UnbondingEntries) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.UnbondingEntries[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func (m *QueryLockingPeriodsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -508,6 +762,66 @@ func (m *QueryLockingPeriodsResponse) MarshalToSizedBuffer(dAtA []byte) (int, er return len(dAtA) - i, nil } +func (m *QuerySpendableAmountRequest) 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 *QuerySpendableAmountRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySpendableAmountRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QuerySpendableAmountResponse) 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 *QuerySpendableAmountResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySpendableAmountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SpendableTokens) > 0 { + for iNdEx := len(m.SpendableTokens) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.SpendableTokens[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -579,6 +893,34 @@ func (m *QueryLockupAccountInfoResponse) Size() (n int) { return n } +func (m *QueryUnbondingEntriesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryUnbondingEntriesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.UnbondingEntries) > 0 { + for _, e := range m.UnbondingEntries { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + func (m *QueryLockingPeriodsRequest) Size() (n int) { if m == nil { return 0 @@ -603,6 +945,30 @@ func (m *QueryLockingPeriodsResponse) Size() (n int) { return n } +func (m *QuerySpendableAmountRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QuerySpendableAmountResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.SpendableTokens) > 0 { + for _, e := range m.SpendableTokens { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -983,7 +1349,7 @@ func (m *QueryLockupAccountInfoResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryLockingPeriodsRequest) Unmarshal(dAtA []byte) error { +func (m *QueryUnbondingEntriesRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1006,15 +1372,181 @@ func (m *QueryLockingPeriodsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryLockingPeriodsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryUnbondingEntriesRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryLockingPeriodsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryUnbondingEntriesRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) + case 1: + 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 ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryUnbondingEntriesResponse) 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 ErrIntOverflowQuery + } + 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: QueryUnbondingEntriesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryUnbondingEntriesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UnbondingEntries", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.UnbondingEntries = append(m.UnbondingEntries, &UnbondingEntry{}) + if err := m.UnbondingEntries[len(m.UnbondingEntries)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryLockingPeriodsRequest) 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 ErrIntOverflowQuery + } + 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: QueryLockingPeriodsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryLockingPeriodsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) if err != nil { return err } @@ -1117,6 +1649,140 @@ func (m *QueryLockingPeriodsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QuerySpendableAmountRequest) 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 ErrIntOverflowQuery + } + 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: QuerySpendableAmountRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuerySpendableAmountRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QuerySpendableAmountResponse) 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 ErrIntOverflowQuery + } + 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: QuerySpendableAmountResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuerySpendableAmountResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpendableTokens", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SpendableTokens = append(m.SpendableTokens, types.Coin{}) + if err := m.SpendableTokens[len(m.SpendableTokens)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/accounts/defaults/lockup/v1/tx.pb.go b/x/accounts/defaults/lockup/v1/tx.pb.go index eb831479e0fc..858e49e2758b 100644 --- a/x/accounts/defaults/lockup/v1/tx.pb.go +++ b/x/accounts/defaults/lockup/v1/tx.pb.go @@ -441,100 +441,6 @@ func (m *MsgExecuteMessagesResponse) GetResponses() []*any.Any { return nil } -// MsgWithdraw defines a message that the owner of the lockup can perform to withdraw unlocked token to an account of -// choice -type MsgWithdraw struct { - Withdrawer string `protobuf:"bytes,1,opt,name=withdrawer,proto3" json:"withdrawer,omitempty"` - ToAddress string `protobuf:"bytes,2,opt,name=to_address,json=toAddress,proto3" json:"to_address,omitempty"` - Denoms []string `protobuf:"bytes,3,rep,name=denoms,proto3" json:"denoms,omitempty"` -} - -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_84e5f410632b9d39, []int{9} -} -func (m *MsgWithdraw) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgWithdraw) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgWithdraw.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 *MsgWithdraw) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgWithdraw.Merge(m, src) -} -func (m *MsgWithdraw) XXX_Size() int { - return m.Size() -} -func (m *MsgWithdraw) XXX_DiscardUnknown() { - xxx_messageInfo_MsgWithdraw.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgWithdraw proto.InternalMessageInfo - -// MsgWithdrawResponse defines the response for MsgWithdraw -type MsgWithdrawResponse struct { - Receiver string `protobuf:"bytes,1,opt,name=receiver,proto3" json:"receiver,omitempty"` - AmountReceived github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=amount_received,json=amountReceived,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount_received"` -} - -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_84e5f410632b9d39, []int{10} -} -func (m *MsgWithdrawResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgWithdrawResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgWithdrawResponse.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 *MsgWithdrawResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgWithdrawResponse.Merge(m, src) -} -func (m *MsgWithdrawResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgWithdrawResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgWithdrawResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgWithdrawResponse proto.InternalMessageInfo - -func (m *MsgWithdrawResponse) GetReceiver() string { - if m != nil { - return m.Receiver - } - return "" -} - -func (m *MsgWithdrawResponse) GetAmountReceived() github_com_cosmos_cosmos_sdk_types.Coins { - if m != nil { - return m.AmountReceived - } - return nil -} - func init() { proto.RegisterType((*MsgInitLockupAccount)(nil), "cosmos.accounts.defaults.lockup.v1.MsgInitLockupAccount") proto.RegisterType((*MsgInitLockupAccountResponse)(nil), "cosmos.accounts.defaults.lockup.v1.MsgInitLockupAccountResponse") @@ -545,8 +451,6 @@ func init() { proto.RegisterType((*MsgWithdrawReward)(nil), "cosmos.accounts.defaults.lockup.v1.MsgWithdrawReward") proto.RegisterType((*MsgSend)(nil), "cosmos.accounts.defaults.lockup.v1.MsgSend") proto.RegisterType((*MsgExecuteMessagesResponse)(nil), "cosmos.accounts.defaults.lockup.v1.MsgExecuteMessagesResponse") - proto.RegisterType((*MsgWithdraw)(nil), "cosmos.accounts.defaults.lockup.v1.MsgWithdraw") - proto.RegisterType((*MsgWithdrawResponse)(nil), "cosmos.accounts.defaults.lockup.v1.MsgWithdrawResponse") } func init() { @@ -554,59 +458,53 @@ func init() { } var fileDescriptor_84e5f410632b9d39 = []byte{ - // 817 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x56, 0xcf, 0x4f, 0xe3, 0x46, - 0x14, 0x8e, 0x13, 0x35, 0x90, 0xa1, 0x40, 0x31, 0x51, 0x09, 0x51, 0xb1, 0x69, 0x24, 0xd4, 0x28, - 0x15, 0xe3, 0x86, 0x56, 0x6a, 0x15, 0xf5, 0x42, 0x4a, 0xab, 0x56, 0x6a, 0x2a, 0x14, 0xfa, 0x43, - 0xea, 0xa1, 0xd1, 0xc4, 0x1e, 0x06, 0x8b, 0x78, 0x26, 0xf2, 0x4c, 0x12, 0x72, 0xab, 0xaa, 0x1e, - 0x2a, 0x4e, 0x9c, 0x7b, 0xe2, 0xd8, 0x72, 0x4a, 0x25, 0xfe, 0x08, 0x8e, 0x88, 0x13, 0xa7, 0xb2, - 0x0a, 0x2b, 0x85, 0x3f, 0x63, 0x65, 0xcf, 0x98, 0x4d, 0x80, 0x65, 0xb3, 0x39, 0xec, 0x4a, 0x7b, - 0x89, 0x3c, 0xf3, 0x7d, 0xef, 0xbd, 0xef, 0x7d, 0x33, 0xcf, 0x0e, 0xf8, 0xd8, 0x66, 0x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x04, 0xae, 0x60, 0xce, 0x11, 0xc1, 0x3c, 0x9a, 0x4e, 0x7d, 0x03, 0xa4, 0x7c, 0xf5, 0xcc, 0x33, - 0x5a, 0x28, 0x38, 0x7d, 0xef, 0xfd, 0xb4, 0x49, 0xbb, 0xd5, 0xe7, 0xb4, 0xdc, 0x7f, 0x72, 0xa2, - 0xa3, 0x5b, 0xa0, 0x7f, 0x01, 0x40, 0x47, 0x3d, 0x8f, 0x61, 0xf0, 0x10, 0x77, 0x72, 0x93, 0xdf, - 0x07, 0x49, 0x07, 0x53, 0xe6, 0xc9, 0x97, 0x60, 0xaa, 0xaa, 0x56, 0xa5, 0xa5, 0x61, 0x07, 0x86, - 0x2a, 0xe5, 0x2e, 0x35, 0xb0, 0x38, 0x72, 0x73, 0x55, 0xff, 0x9f, 0x81, 0x69, 0x1f, 0xdb, 0xd8, - 0x6d, 0x8f, 0xa1, 0xfc, 0x96, 0xa9, 0x1f, 0x6a, 0x60, 0x5e, 0x7a, 0x5e, 0x53, 0x7b, 0x4e, 0x26, - 0xfe, 0xba, 0x4e, 0x7b, 0x4e, 0x56, 0xae, 0xaa, 0xc2, 0xe5, 0xad, 0xb3, 0xbe, 0xa1, 0x9d, 0xf7, - 0x0d, 0xed, 0x49, 0xdf, 0xd0, 0x8e, 0xae, 0x8d, 0xd8, 0xf9, 0xb5, 0x11, 0xbb, 0xbc, 0x36, 0x62, - 0xbf, 0x16, 0x64, 0x5e, 0xee, 0xec, 0x43, 0x97, 0x59, 0x07, 0x8f, 0xfd, 0x63, 0xa9, 0x27, 0xc3, - 0xd3, 0xfe, 0xf4, 0x59, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb9, 0x35, 0x67, 0x40, 0x62, 0x09, 0x00, - 0x00, + // 735 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x55, 0xbf, 0x4f, 0x1b, 0x49, + 0x18, 0xf5, 0xda, 0x3a, 0x38, 0x0f, 0xc7, 0xdd, 0xb1, 0x67, 0xe9, 0x8c, 0x75, 0xec, 0x72, 0x96, + 0xd0, 0x59, 0x3e, 0x31, 0x7b, 0xe6, 0x8a, 0x48, 0x28, 0x0d, 0x0e, 0x89, 0x12, 0x29, 0x8e, 0x90, + 0xc9, 0x0f, 0x29, 0x45, 0xac, 0xf1, 0xee, 0x30, 0xac, 0xf0, 0xce, 0x58, 0xfb, 0x8d, 0x0d, 0xee, + 0xa2, 0x28, 0x45, 0x94, 0x8a, 0x3a, 0x15, 0x65, 0x42, 0xe5, 0x82, 0x3f, 0x82, 0x12, 0x51, 0xa5, + 0x0a, 0x91, 0x89, 0x64, 0xfe, 0x8c, 0x68, 0x77, 0x66, 0x13, 0x7e, 0x85, 0x10, 0x9a, 0x48, 0x69, + 0xac, 0xdd, 0x79, 0xef, 0x7b, 0xdf, 0xfb, 0x9e, 0x67, 0x76, 0xd0, 0xbf, 0xae, 0x80, 0x40, 0x80, + 0x43, 0x5c, 0x57, 0x74, 0xb8, 0x04, 0xc7, 0xa3, 0x2b, 0xa4, 0xd3, 0x92, 0xe0, 0xb4, 0x84, 0xbb, + 0xd6, 0x69, 0x3b, 0xdd, 0x8a, 0x23, 0x37, 0x70, 0x3b, 0x14, 0x52, 0x98, 0x45, 0x45, 0xc6, 0x09, + 0x19, 0x27, 0x64, 0xac, 0xc8, 0xb8, 0x5b, 0x29, 0x4c, 0x90, 0xc0, 0xe7, 0xc2, 0x89, 0x7f, 0x55, + 0x59, 0xc1, 0xd2, 0x3d, 0x9a, 0x04, 0xa8, 0xd3, 0xad, 0x34, 0xa9, 0x24, 0x15, 0xc7, 0x15, 0x3e, + 0xd7, 0xb8, 0x73, 0x09, 0x0f, 0xba, 0x81, 0x2a, 0xf8, 0x53, 0x17, 0x04, 0xc0, 0x22, 0x2c, 0x00, + 0xa6, 0x81, 0x49, 0x05, 0x34, 0xe2, 0x37, 0x2d, 0xab, 0xa1, 0x1c, 0x13, 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d0, 0xfb, 0xfe, 0xa3, 0x9e, 0x6f, 0xf6, 0x79, 0x1a, + 0x8d, 0xd6, 0x80, 0x2d, 0x53, 0x7e, 0x15, 0x8b, 0xd7, 0x10, 0x92, 0xe2, 0x94, 0xb7, 0x2f, 0x57, + 0x65, 0xa5, 0x48, 0x62, 0xef, 0x1d, 0x8b, 0x3d, 0x73, 0x71, 0xec, 0xb7, 0xa2, 0xd8, 0xb7, 0x0f, + 0xec, 0x12, 0xf3, 0xe5, 0x6a, 0xa7, 0x89, 0x5d, 0x11, 0x24, 0x97, 0xcb, 0xb1, 0x43, 0x28, 0x7b, + 0x6d, 0x0a, 0x71, 0x01, 0xbc, 0x1a, 0xf6, 0xcb, 0xbf, 0x44, 0x1b, 0xcc, 0xed, 0x35, 0xa2, 0x1b, + 0x09, 0x2e, 0xf1, 0x9f, 0x2d, 0xa1, 0x42, 0x0d, 0xd8, 0xcd, 0x0d, 0xea, 0x76, 0x24, 0xad, 0x51, + 0x00, 0xc2, 0x28, 0x24, 0xa7, 0xd3, 0x9c, 0x43, 0xd9, 0x50, 0x3f, 0x43, 0xde, 0x88, 0x0d, 0xe7, + 0xce, 0x7c, 0x9f, 0x16, 0x78, 0xaf, 0xfe, 0x99, 0x56, 0x5d, 0xdc, 0x1d, 0x58, 0xc6, 0xde, 0xc0, + 0x32, 0xde, 0x0f, 0x2c, 0x63, 0xf3, 0xd0, 0x4a, 0xed, 0x1d, 0x5a, 0xa9, 0xb7, 0x87, 0x56, 0xea, + 0x71, 0x59, 0xd9, 0x06, 0x6f, 0x0d, 0xfb, 0xc2, 0xd9, 0xb8, 0xe8, 0x8a, 0x6c, 0x8e, 0xc4, 0xf2, + 0xff, 0x7f, 0x0c, 0x00, 0x00, 0xff, 0xff, 0x08, 0x33, 0x56, 0xd8, 0xd3, 0x07, 0x00, 0x00, } func (this *MsgInitLockupAccount) Equal(that interface{}) bool { @@ -1002,96 +900,6 @@ func (m *MsgExecuteMessagesResponse) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } -func (m *MsgWithdraw) 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 *MsgWithdraw) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgWithdraw) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Denoms) > 0 { - for iNdEx := len(m.Denoms) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Denoms[iNdEx]) - copy(dAtA[i:], m.Denoms[iNdEx]) - i = encodeVarintTx(dAtA, i, uint64(len(m.Denoms[iNdEx]))) - i-- - dAtA[i] = 0x1a - } - } - if len(m.ToAddress) > 0 { - i -= len(m.ToAddress) - copy(dAtA[i:], m.ToAddress) - i = encodeVarintTx(dAtA, i, uint64(len(m.ToAddress))) - i-- - dAtA[i] = 0x12 - } - if len(m.Withdrawer) > 0 { - i -= len(m.Withdrawer) - copy(dAtA[i:], m.Withdrawer) - i = encodeVarintTx(dAtA, i, uint64(len(m.Withdrawer))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgWithdrawResponse) 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 *MsgWithdrawResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgWithdrawResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.AmountReceived) > 0 { - for iNdEx := len(m.AmountReceived) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.AmountReceived[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if len(m.Receiver) > 0 { - i -= len(m.Receiver) - copy(dAtA[i:], m.Receiver) - i = encodeVarintTx(dAtA, i, uint64(len(m.Receiver))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -1252,48 +1060,6 @@ func (m *MsgExecuteMessagesResponse) Size() (n int) { return n } -func (m *MsgWithdraw) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Withdrawer) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ToAddress) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if len(m.Denoms) > 0 { - for _, s := range m.Denoms { - l = len(s) - n += 1 + l + sovTx(uint64(l)) - } - } - return n -} - -func (m *MsgWithdrawResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Receiver) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if len(m.AmountReceived) > 0 { - for _, e := range m.AmountReceived { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } - } - return n -} - func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2337,268 +2103,6 @@ func (m *MsgExecuteMessagesResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgWithdraw) 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: MsgWithdraw: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgWithdraw: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Withdrawer", 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.Withdrawer = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ToAddress", 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.ToAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denoms", 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.Denoms = append(m.Denoms, 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 *MsgWithdrawResponse) 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: MsgWithdrawResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgWithdrawResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Receiver", 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.Receiver = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AmountReceived", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AmountReceived = append(m.AmountReceived, types.Coin{}) - if err := m.AmountReceived[len(m.AmountReceived)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - 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 skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/accounts/proto/cosmos/accounts/defaults/lockup/v1/lockup.proto b/x/accounts/proto/cosmos/accounts/defaults/lockup/v1/lockup.proto index b8be23c4ae95..65338a1f441e 100644 --- a/x/accounts/proto/cosmos/accounts/defaults/lockup/v1/lockup.proto +++ b/x/accounts/proto/cosmos/accounts/defaults/lockup/v1/lockup.proto @@ -4,7 +4,9 @@ package cosmos.accounts.defaults.lockup.v1; import "amino/amino.proto"; import "cosmos/base/v1beta1/coin.proto"; import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; option go_package = "cosmossdk.io/x/accounts/defaults/lockup/v1"; @@ -20,3 +22,19 @@ message Period { (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; } + +message UnbondingEntries { + repeated UnbondingEntry entries = 1; +} + +// UnbondingEntry defines an entry tracking the lockup account unbonding operation. +message UnbondingEntry { + int64 creation_height = 1; + // end time of entry + google.protobuf.Timestamp end_time = 2 + [(gogoproto.nullable) = false, (amino.dont_omitempty) = true, (gogoproto.stdtime) = true]; + // unbond amount + cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + // validator address + string validator_address = 4 [(cosmos_proto.scalar) = "cosmos.ValidatorAddressString"]; +} diff --git a/x/accounts/proto/cosmos/accounts/defaults/lockup/v1/query.proto b/x/accounts/proto/cosmos/accounts/defaults/lockup/v1/query.proto index e2bd5b607306..a5589ce3d9b4 100644 --- a/x/accounts/proto/cosmos/accounts/defaults/lockup/v1/query.proto +++ b/x/accounts/proto/cosmos/accounts/defaults/lockup/v1/query.proto @@ -5,6 +5,7 @@ import "cosmos/accounts/defaults/lockup/v1/lockup.proto"; import "cosmos/base/v1beta1/coin.proto"; import "gogoproto/gogo.proto"; import "google/protobuf/timestamp.proto"; +import "cosmos_proto/cosmos.proto"; option go_package = "cosmossdk.io/x/accounts/defaults/lockup/v1"; @@ -43,6 +44,17 @@ message QueryLockupAccountInfoResponse { string owner = 8; } +// QueryUnbondingEntriesRequest is used to query the lockup account unbonding entries. +message QueryUnbondingEntriesRequest { + string validator_address = 1 [(cosmos_proto.scalar) = "cosmos.ValidatorAddressString"]; +} + +// QueryUnbondingEntriesResponse returns the lockup account unbonding entries. +message QueryUnbondingEntriesResponse { + // UnbondingEntry defines the list of unbonding entries. + repeated UnbondingEntry unbonding_entries = 1; +} + // QueryLockingPeriodsRequest is used to query the periodic lockup account locking periods. message QueryLockingPeriodsRequest {} @@ -51,3 +63,12 @@ message QueryLockingPeriodsResponse { // lockup_periods defines the value of the periodic lockup account locking periods. repeated Period locking_periods = 1; } + +// QuerySpendableAmountRequest is used to query the lockup account total spendable tokens. +message QuerySpendableAmountRequest {} + +// QuerySpendableAmountResponse returns lockup account total spendable tokens. +message QuerySpendableAmountResponse { + repeated cosmos.base.v1beta1.Coin spendable_tokens = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; +} diff --git a/x/accounts/proto/cosmos/accounts/defaults/lockup/v1/tx.proto b/x/accounts/proto/cosmos/accounts/defaults/lockup/v1/tx.proto index 980cc90c5307..11fb09726186 100644 --- a/x/accounts/proto/cosmos/accounts/defaults/lockup/v1/tx.proto +++ b/x/accounts/proto/cosmos/accounts/defaults/lockup/v1/tx.proto @@ -101,26 +101,3 @@ message MsgSend { message MsgExecuteMessagesResponse { repeated google.protobuf.Any responses = 1; } - -// MsgWithdraw defines a message that the owner of the lockup can perform to withdraw unlocked token to an account of -// choice -message MsgWithdraw { - option (cosmos.msg.v1.signer) = "withdrawer"; - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string withdrawer = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - string to_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - repeated string denoms = 3; -} - -// MsgWithdrawResponse defines the response for MsgWithdraw -message MsgWithdrawResponse { - string receiver = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - repeated cosmos.base.v1beta1.Coin amount_received = 2 [ - (gogoproto.nullable) = false, - (amino.dont_omitempty) = true, - (amino.encoding) = "legacy_coins", - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" - ]; -} diff --git a/x/staking/keeper/grpc_query.go b/x/staking/keeper/grpc_query.go index 611582c1a828..f7f616e2205d 100644 --- a/x/staking/keeper/grpc_query.go +++ b/x/staking/keeper/grpc_query.go @@ -302,10 +302,10 @@ func (k Querier) UnbondingDelegation(ctx context.Context, req *types.QueryUnbond unbond, err := k.GetUnbondingDelegation(ctx, delAddr, valAddr) if err != nil { - return nil, status.Errorf( + return nil, errorsmod.Wrap(err, status.Errorf( codes.NotFound, "unbonding delegation with delegator %s not found for validator %s", - req.DelegatorAddr, req.ValidatorAddr) + req.DelegatorAddr, req.ValidatorAddr).Error()) } return &types.QueryUnbondingDelegationResponse{Unbond: unbond}, nil