-
Notifications
You must be signed in to change notification settings - Fork 73
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(Balances): make decimals non-nullable #2291
Conversation
token: { | ||
...balance.token, | ||
decimals: | ||
balance.token?.decimals ?? SafeBalancesApi.DEFAULT_DECIMALS, | ||
}, |
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.
As there are multiple IBalanceApi
s, we should assign the default value during validation. It then doesn't need to be done in both places and will solve the MultisigTransactionExecutionDetailsMapper
CI error.
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.
Nice, thanks for the pointer!
const token = tokenBuilder().build(); | ||
// @ts-expect-error - inferred type doesn't allow optional properties | ||
delete token.decimals; | ||
|
||
const result = TokenSchema.safeParse(token); | ||
|
||
expect(result.success && result.data.decimals).toBe(null); | ||
expect(result.success && result.data.decimals).toBe(18); |
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.
Nit: I would add a new const
is test named DEFAULT_DECIMALS
.
This reverts commit 4d3c894.
Summary
Token decimals being always a number has been the assumption on the client for quite some time and a lot of code would have to be changed if we were to start treating it as nullable.
Changes
So I've adjusted the OpenAPI type and also added a fallback value (although it's probably never null in reality).