From 415baeae5594ee4af541b737a1131b08b25fb6f7 Mon Sep 17 00:00:00 2001 From: CharlVS <77973576+CharlVS@users.noreply.github.com> Date: Mon, 13 Jan 2025 19:39:11 +0100 Subject: [PATCH] fix(activation): Fix eth activation parsing exception --- .../lib/src/rpc_methods/eth/enable_eth_with_tokens.dart | 4 ---- .../komodo_defi_types/lib/src/utils/json_type_utils.dart | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/komodo_defi_rpc_methods/lib/src/rpc_methods/eth/enable_eth_with_tokens.dart b/packages/komodo_defi_rpc_methods/lib/src/rpc_methods/eth/enable_eth_with_tokens.dart index 10fee55..fc0a318 100644 --- a/packages/komodo_defi_rpc_methods/lib/src/rpc_methods/eth/enable_eth_with_tokens.dart +++ b/packages/komodo_defi_rpc_methods/lib/src/rpc_methods/eth/enable_eth_with_tokens.dart @@ -42,7 +42,6 @@ class EnableEthWithTokensResponse extends BaseResponse { EnableEthWithTokensResponse({ required super.mmrpc, required this.currentBlock, - required this.ticker, required this.walletBalance, required this.nftsInfos, }); @@ -53,7 +52,6 @@ class EnableEthWithTokensResponse extends BaseResponse { return EnableEthWithTokensResponse( mmrpc: json.value('mmrpc'), currentBlock: result.value('current_block'), - ticker: result.value('ticker'), walletBalance: WalletBalance.fromJson( result.value('wallet_balance'), ), @@ -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 @@ -71,7 +68,6 @@ class EnableEthWithTokensResponse extends BaseResponse { 'mmrpc': mmrpc, 'result': { 'current_block': currentBlock, - 'ticker': ticker, 'wallet_balance': walletBalance.toJson(), 'nfts_infos': nftsInfos, }, diff --git a/packages/komodo_defi_types/lib/src/utils/json_type_utils.dart b/packages/komodo_defi_types/lib/src/utils/json_type_utils.dart index 27780f3..d078e6c 100644 --- a/packages/komodo_defi_types/lib/src/utils/json_type_utils.dart +++ b/packages/komodo_defi_types/lib/src/utils/json_type_utils.dart @@ -150,6 +150,11 @@ T? _traverseJson( 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(