Skip to content

Commit 162a308

Browse files
committed
handle balance if trades are zero
1 parent 75a3da4 commit 162a308

1 file changed

Lines changed: 29 additions & 6 deletions

File tree

app/lib/widgets/wallets/activate_wallet.dart

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ class _ActivateWalletWidgetState extends ConsumerState<ActivateWalletWidget> {
4343

4444
try {
4545
final price = await StellarService.getTFTPriceFromXLM();
46+
if (price == 0) {
47+
final price =
48+
await TFChainService.getTFTPrice(Globals().chainUrl) * 0.5;
49+
if (mounted) {
50+
setState(() {
51+
tftPrice = price.ceil();
52+
isLoadingPrice = false;
53+
});
54+
}
55+
return;
56+
}
4657
if (mounted) {
4758
setState(() {
4859
tftPrice = price;
@@ -51,12 +62,24 @@ class _ActivateWalletWidgetState extends ConsumerState<ActivateWalletWidget> {
5162
}
5263
} catch (e) {
5364
logger.e('Failed to load TFT price: $e');
54-
final price = await TFChainService.getTFTPrice(Globals().chainUrl) * 0.5;
55-
if (mounted) {
56-
setState(() {
57-
tftPrice = price.ceil();
58-
isLoadingPrice = false;
59-
});
65+
try {
66+
final price =
67+
await TFChainService.getTFTPrice(Globals().chainUrl) * 0.5;
68+
if (mounted) {
69+
setState(() {
70+
tftPrice = price.ceil();
71+
isLoadingPrice = false;
72+
});
73+
}
74+
} catch (tfchainError) {
75+
logger
76+
.e('Failed to load TFT price from TFChain fallback: $tfchainError');
77+
if (mounted) {
78+
setState(() {
79+
tftPrice = 0;
80+
isLoadingPrice = false;
81+
});
82+
}
6083
}
6184
}
6285
}

0 commit comments

Comments
 (0)