Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: tally grpc query #8718

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions x/superfluid/keeper/stake.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,45 +581,46 @@ func (k Keeper) IterateDelegations(context context.Context, delegator sdk.AccAdd
// get locked coin from the lock ID
interim, ok := k.GetIntermediaryAccountFromLockId(ctx, lock.UnderlyingLockId)
if !ok {
return fmt.Errorf("intermediary account not found for lock id %d", lock.UnderlyingLockId)
ctx.Logger().Error("intermediary account not found for lock id", "lockID", lock.UnderlyingLockId)
continue
}

lock, err := k.lk.GetLockByID(ctx, lock.UnderlyingLockId)
if err != nil {
ctx.Logger().Error("lockup retrieval failed with underlying lock", "Lock", lock, "Error", err)
return err
continue
}

coin, err := lock.SingleCoin()
if err != nil {
ctx.Logger().Error("lock fails to meet expected invariant, it contains multiple coins", "Lock", lock, "Error", err)
return err
continue
}

// get osmo-equivalent token amount
amount, err := k.GetSuperfluidOSMOTokens(ctx, interim.Denom, coin.Amount)
if err != nil {
ctx.Logger().Error("failed to get osmo equivalent of token", "Denom", interim.Denom, "Amount", coin.Amount, "Error", err)
return err
continue
}

// get validator shares equivalent to the token amount
valAddr, err := sdk.ValAddressFromBech32(interim.ValAddr)
if err != nil {
ctx.Logger().Error("failed to decode validator address", "Intermediary", interim.ValAddr, "LockID", lock.ID, "Error", err)
return err
continue
}

validator, err := k.sk.GetValidator(ctx, valAddr)
if err != nil {
ctx.Logger().Error("validator does not exist for lock", "Validator", valAddr, "LockID", lock.ID)
return err
continue
}

shares, err := validator.SharesFromTokens(amount)
if err != nil {
// tokens are not valid. continue.
return err
continue
}

// construct delegation and call callback
Expand Down