Skip to content

Commit

Permalink
fix: tally grpc query (#8718)
Browse files Browse the repository at this point in the history
* fix tally

* error format
  • Loading branch information
czarcas7ic authored Sep 19, 2024
1 parent 4c355a2 commit 768fbf7
Showing 1 changed file with 8 additions and 7 deletions.
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

0 comments on commit 768fbf7

Please sign in to comment.