Skip to content

Commit 913a4ac

Browse files
committed
add explicit cast and type check
1 parent d2e77c9 commit 913a4ac

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

lib/wallets/wallet/impl/xelis_wallet.dart

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,22 @@ class XelisWallet extends LibXelisWallet {
361361
await libXelisWallet!.rescan(topoheight: BigInt.from(pruningHeight));
362362
}
363363

364-
final txList = objTransactions ??
365-
(await libXelisWallet!.allHistory())
366-
.map((jsonStr) => xelis_sdk.TransactionEntry.fromJson(
367-
json.decode(jsonStr),
368-
) as xelis_sdk.TransactionEntry)
369-
.toList();
364+
xelis_sdk.TransactionEntry _checkDecodeJsonStringTxEntry(
365+
String jsonString,
366+
) {
367+
final json = jsonDecode(jsonString);
368+
if (json is Map) {
369+
return xelis_sdk.TransactionEntry.fromJson(json.cast());
370+
}
371+
372+
throw Exception("Not a Map on jsonDecode($jsonString)");
373+
}
374+
375+
final txList =
376+
objTransactions ??
377+
(await libXelisWallet!.allHistory())
378+
.map(_checkDecodeJsonStringTxEntry)
379+
.toList();
370380

371381
final List<TransactionV2> txns = [];
372382

0 commit comments

Comments
 (0)