-
Notifications
You must be signed in to change notification settings - Fork 25
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
add better typing for standalone balances #1475
Conversation
const v: any = resp.balances[k]; | ||
if (v.liquidity_pool_id) { | ||
const v = resp.balances[k]; | ||
if (v.liquidityPoolId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed this key to be camelcase rather than snake
const { balances, subentry_count, num_sponsored, num_sponsoring } = | ||
accountDetails; | ||
|
||
const displayableBalances = Object.values(balances).reduce( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using reduce
made it hard for TS to typecheck the different balance types. Switching to a for loop for more clarity.
Also, at some point balances
must have changed from an object to an array. No need to do this Object.values
conversion
reserves: lp.reserves, | ||
}; | ||
delete balances[k].liquidity_pool_id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initially, we assigned liquidity_pool_id
's value to liquidityPoolId
and then deleted the old liquidity_pool_id
. I'm just simplifying the logic in makeDisplayableBalances
so we don't need to do this anymore
Motivation:
I added
blockaidData
to the BE's balances which caused the balances we get from the BE to be out of sync with the balances we get using a custom network. This should have raised type errors throughout the app, but it did not because we used a lot of casting asany
with balances to work our way out of some tricky type issues.I'm removing the use of
any
when dealing with balances so we have a strongly typed (and more predictable) format for balances