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(Balances): make decimals non-nullable #2291

Merged
merged 5 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions src/datasources/balances-api/safe-balances-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ export class SafeBalancesApi implements IBalancesApi {
const fiatBalance = this._getFiatBalance(price, balance);
return {
...balance,
token: {
...balance.token,
decimals:
balance.token?.decimals ?? SafeBalancesApi.DEFAULT_DECIMALS,
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As there are multiple IBalanceApis, 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.

Copy link
Member Author

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!

fiatBalance: fiatBalance ? getNumberString(fiatBalance) : null,
fiatConversion: price ? getNumberString(price) : null,
};
Expand Down
4 changes: 2 additions & 2 deletions src/routes/balances/entities/token.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { TokenType } from '@/routes/balances/entities/token-type.entity';
export class Token {
@ApiProperty()
address!: `0x${string}`;
@ApiPropertyOptional({ type: Number, nullable: true })
decimals!: number | null;
@ApiPropertyOptional({ type: Number })
decimals!: number;
@ApiProperty()
logoUri?: string;
@ApiProperty()
Expand Down
Loading