Skip to content

Commit

Permalink
Add query for undelegating time (#988)
Browse files Browse the repository at this point in the history
(cherry picked from commit 237b6f0)
  • Loading branch information
mattverse authored and mergify-bot committed Feb 26, 2022
1 parent 91e48c5 commit b4d674d
Show file tree
Hide file tree
Showing 3 changed files with 165 additions and 93 deletions.
3 changes: 3 additions & 0 deletions proto/osmosis/superfluid/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import "google/protobuf/timestamp.proto";
import "google/protobuf/duration.proto";
import "osmosis/superfluid/superfluid.proto";
import "osmosis/superfluid/params.proto";
import "osmosis/lockup/lock.proto";
import "cosmos/base/query/v1beta1/pagination.proto";

option go_package = "github.com/osmosis-labs/osmosis/v7/x/superfluid/types";
Expand Down Expand Up @@ -200,6 +201,8 @@ message SuperfluidUndelegationsByDelegatorResponse {
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
repeated osmosis.lockup.SyntheticLock synthetic_locks = 3
[ (gogoproto.nullable) = false ];
}

message SuperfluidDelegationsByValidatorDenomRequest {
Expand Down
3 changes: 3 additions & 0 deletions x/superfluid/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
lockuptypes "github.com/osmosis-labs/osmosis/v7/x/lockup/types"
"github.com/osmosis-labs/osmosis/v7/x/superfluid/types"
)

Expand Down Expand Up @@ -177,6 +178,7 @@ func (k Keeper) SuperfluidUndelegationsByDelegator(goCtx context.Context, req *t
res := types.SuperfluidUndelegationsByDelegatorResponse{
SuperfluidDelegationRecords: []types.SuperfluidDelegationRecord{},
TotalUndelegatedCoins: sdk.NewCoins(),
SyntheticLocks: []lockuptypes.SyntheticLock{},
}

syntheticLocks := k.lk.GetAllSyntheticLockupsByAddr(ctx, delAddr)
Expand Down Expand Up @@ -204,6 +206,7 @@ func (k Keeper) SuperfluidUndelegationsByDelegator(goCtx context.Context, req *t
DelegationAmount: lockedCoin,
},
)
res.SyntheticLocks = append(res.SyntheticLocks, syntheticLock)
res.TotalUndelegatedCoins = res.TotalUndelegatedCoins.Add(lockedCoin)
}
return &res, nil
Expand Down
Loading

0 comments on commit b4d674d

Please sign in to comment.