diff --git a/proto/staking/v1beta1/query.proto b/proto/staking/v1beta1/query.proto index abcff74..4bc77e9 100644 --- a/proto/staking/v1beta1/query.proto +++ b/proto/staking/v1beta1/query.proto @@ -450,19 +450,26 @@ message QueryTotalLiquidStakedResponse { } // QueryTokenizeShareLockInfo queries the tokenize share lock information -// associated with given account +// associated with given account. message QueryTokenizeShareLockInfo { string address = 1; } // QueryTokenizeShareLockInfoResponse is the response from the -// QueryTokenizeShareLockInfo query +// QueryTokenizeShareLockInfo query. message QueryTokenizeShareLockInfoResponse{ string status = 1; string expiration_time = 2; } +// TokenizeShareLockStatus represents status of an account's tokenize share lock. enum TokenizeShareLockStatus { - LOCKED = 0; - UNLOCKED = 1; - LOCK_EXPIRING = 2; -} \ No newline at end of file + option (gogoproto.goproto_enum_prefix) = false; + // An empty value is not allowed. + TOKENIZE_SHARE_LOCK_STATUS_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "ShareLockStatusNil"]; + // Status means cannot tokenize shares. + TOKENIZE_SHARE_LOCK_STATUS_LOCKED = 1 [(gogoproto.enumvalue_customname) = "ShareLockStatusLocked"]; + // Status means cannot tokenize shares. + TOKENIZE_SHARE_LOCK_STATUS_UNLOCKED = 2 [(gogoproto.enumvalue_customname) = "ShareLockStatusUnlocked"]; + // Status when lock is queued for unlocking. + TOKENIZE_SHARE_LOCK_STATUS_LOCK_EXPIRING = 3 [(gogoproto.enumvalue_customname) = "ShareLockStatusLockExpiring"]; +} diff --git a/x/staking/keeper/liquid_stake.go b/x/staking/keeper/liquid_stake.go index e44f74b..e473fac 100644 --- a/x/staking/keeper/liquid_stake.go +++ b/x/staking/keeper/liquid_stake.go @@ -200,16 +200,16 @@ func (k Keeper) GetTokenizeSharesLock(ctx sdk.Context, address sdk.AccAddress) ( key := types.GetTokenizeSharesLockKey(address) bz := store.Get(key) if len(bz) == 0 { - return types.TokenizeShareLockStatus_UNLOCKED, time.Time{} + return types.ShareLockStatusUnlocked, time.Time{} } unlockTime, err := sdk.ParseTimeBytes(bz) if err != nil { panic(err) } if unlockTime.IsZero() { - return types.TokenizeShareLockStatus_LOCKED, time.Time{} + return types.ShareLockStatusLocked, time.Time{} } - return types.TokenizeShareLockStatus_LOCK_EXPIRING, unlockTime + return types.ShareLockStatusLockExpiring, unlockTime } // Stores a list of addresses pending tokenize share unlocking at the same time diff --git a/x/staking/keeper/liquid_stake_test.go b/x/staking/keeper/liquid_stake_test.go index 69d4a0a..d4a3bd0 100644 --- a/x/staking/keeper/liquid_stake_test.go +++ b/x/staking/keeper/liquid_stake_test.go @@ -730,9 +730,9 @@ func TestTokenizeSharesLock(t *testing.T) { addresses := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1)) addressA, addressB := addresses[0], addresses[1] - unlocked := types.TokenizeShareLockStatus_UNLOCKED.String() - locked := types.TokenizeShareLockStatus_LOCKED.String() - lockExpiring := types.TokenizeShareLockStatus_LOCK_EXPIRING.String() + unlocked := types.ShareLockStatusUnlocked.String() + locked := types.ShareLockStatusLocked.String() + lockExpiring := types.ShareLockStatusLockExpiring.String() // Confirm both accounts start unlocked status, _ := app.StakingKeeper.GetTokenizeSharesLock(ctx, addressA) diff --git a/x/staking/keeper/msg_server.go b/x/staking/keeper/msg_server.go index 9949c5f..5b0a31f 100644 --- a/x/staking/keeper/msg_server.go +++ b/x/staking/keeper/msg_server.go @@ -640,10 +640,10 @@ func (k msgServer) TokenizeShares(goCtx context.Context, msg *types.MsgTokenizeS // Check if the delegator has disabled tokenization lockStatus, unlockTime := k.GetTokenizeSharesLock(ctx, delegatorAddress) - if lockStatus == types.TokenizeShareLockStatus_LOCKED { + if lockStatus == types.ShareLockStatusLocked { return nil, types.ErrTokenizeSharesDisabledForAccount } - if lockStatus == types.TokenizeShareLockStatus_LOCK_EXPIRING { + if lockStatus == types.ShareLockStatusLockExpiring { return nil, types.ErrTokenizeSharesDisabledForAccount.Wrapf("tokenization will be allowed at %s", unlockTime) } @@ -941,12 +941,12 @@ func (k msgServer) DisableTokenizeShares(goCtx context.Context, msg *types.MsgDi // If tokenized shares is already disabled, alert the user lockStatus, completionTime := k.GetTokenizeSharesLock(ctx, delegator) - if lockStatus == types.TokenizeShareLockStatus_LOCKED { + if lockStatus == types.ShareLockStatusLocked { return nil, types.ErrTokenizeSharesAlreadyDisabledForAccount } // If the tokenized shares lock is expiring, remove the pending unlock from the queue - if lockStatus == types.TokenizeShareLockStatus_LOCK_EXPIRING { + if lockStatus == types.ShareLockStatusLockExpiring { k.CancelTokenizeShareLockExpiration(ctx, delegator, completionTime) } @@ -966,10 +966,10 @@ func (k msgServer) EnableTokenizeShares(goCtx context.Context, msg *types.MsgEna // If tokenized shares aren't current disabled, alert the user lockStatus, unlockTime := k.GetTokenizeSharesLock(ctx, delegator) - if lockStatus == types.TokenizeShareLockStatus_UNLOCKED { + if lockStatus == types.ShareLockStatusUnlocked { return nil, types.ErrTokenizeSharesAlreadyEnabledForAccount } - if lockStatus == types.TokenizeShareLockStatus_LOCK_EXPIRING { + if lockStatus == types.ShareLockStatusLockExpiring { return nil, types.ErrTokenizeSharesAlreadyEnabledForAccount.Wrapf( "tokenize shares re-enablement already in progress, ending at %s", unlockTime) }