Skip to content

Commit

Permalink
fix(activation): Fix eth activation parsing exception
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlVS committed Jan 14, 2025
1 parent 7c0c5d0 commit 415baea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class EnableEthWithTokensResponse extends BaseResponse {
EnableEthWithTokensResponse({
required super.mmrpc,
required this.currentBlock,
required this.ticker,
required this.walletBalance,
required this.nftsInfos,
});
Expand All @@ -53,7 +52,6 @@ class EnableEthWithTokensResponse extends BaseResponse {
return EnableEthWithTokensResponse(
mmrpc: json.value<String>('mmrpc'),
currentBlock: result.value<int>('current_block'),
ticker: result.value<String>('ticker'),
walletBalance: WalletBalance.fromJson(
result.value<JsonMap>('wallet_balance'),
),
Expand All @@ -62,7 +60,6 @@ class EnableEthWithTokensResponse extends BaseResponse {
}

final int currentBlock;
final String ticker;
final WalletBalance walletBalance;
final JsonMap nftsInfos; // Could be expanded into a proper type if needed

Expand All @@ -71,7 +68,6 @@ class EnableEthWithTokensResponse extends BaseResponse {
'mmrpc': mmrpc,
'result': {
'current_block': currentBlock,
'ticker': ticker,
'wallet_balance': walletBalance.toJson(),
'nfts_infos': nftsInfos,
},
Expand Down
5 changes: 5 additions & 0 deletions packages/komodo_defi_types/lib/src/utils/json_type_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ T? _traverseJson<T>(
return _convertMap(value);
}

// Cast 0 to false and 1 to true for boolean types
if (T == bool && value is int && (value == 0 || value == 1)) {
return (value == 1) as T;
}

// Final type check
if (value is! T) {
throw ArgumentError(
Expand Down

0 comments on commit 415baea

Please sign in to comment.