From 3974600d1b1c91c7a10f040eb7e9fce4fcb4f731 Mon Sep 17 00:00:00 2001 From: Alaa Elattar Date: Wed, 21 May 2025 16:05:50 +0300 Subject: [PATCH 1/4] fix transferring xlms --- packages/stellar_client/lib/src/client.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/stellar_client/lib/src/client.dart b/packages/stellar_client/lib/src/client.dart index 77f3fef1..67827ce4 100644 --- a/packages/stellar_client/lib/src/client.dart +++ b/packages/stellar_client/lib/src/client.dart @@ -365,9 +365,10 @@ class Client { throw Exception('Balance with asset code ${currency} not found.'); }); // check that receiver account exists - final receiver = await _sdk.accounts.account(accountId); + final balance = await getBalanceByAccountID( + network: _network, accountId: destinationAddress); // check that asset exists - var specificBalance = receiver.balances.firstWhere( + var specificBalance = balance.firstWhere( (balance) => balance.assetCode == currency, orElse: () { throw Exception('Balance with asset code ${currency} not found.'); From 927f1e7bb2f06f6b3ba01536adfcfacbf99e8a32 Mon Sep 17 00:00:00 2001 From: Alaa Elattar Date: Wed, 21 May 2025 16:10:44 +0300 Subject: [PATCH 2/4] add try && catch for errors --- packages/stellar_client/lib/src/client.dart | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/stellar_client/lib/src/client.dart b/packages/stellar_client/lib/src/client.dart index 67827ce4..99cd33bd 100644 --- a/packages/stellar_client/lib/src/client.dart +++ b/packages/stellar_client/lib/src/client.dart @@ -364,9 +364,15 @@ class Client { } throw Exception('Balance with asset code ${currency} not found.'); }); - // check that receiver account exists - final balance = await getBalanceByAccountID( - network: _network, accountId: destinationAddress); + List balance = []; + try { + // check that receiver account exists + balance = await getBalanceByAccountID( + network: _network, accountId: destinationAddress); + } catch (e) { + throw Exception('Receiver account does not exist.'); + } + // check that asset exists var specificBalance = balance.firstWhere( (balance) => balance.assetCode == currency, From ca4438526b52d02491384cc98cca0a3b7a1bd39a Mon Sep 17 00:00:00 2001 From: Alaa228 Date: Wed, 21 May 2025 17:05:22 +0300 Subject: [PATCH 3/4] Update client.dart Co-authored-by: AhmedHanafy725 <41957921+AhmedHanafy725@users.noreply.github.com> --- packages/stellar_client/lib/src/client.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/stellar_client/lib/src/client.dart b/packages/stellar_client/lib/src/client.dart index 99cd33bd..9aa5f6c6 100644 --- a/packages/stellar_client/lib/src/client.dart +++ b/packages/stellar_client/lib/src/client.dart @@ -367,7 +367,7 @@ class Client { List balance = []; try { // check that receiver account exists - balance = await getBalanceByAccountID( + receiverBalance = await getBalanceByAccountID( network: _network, accountId: destinationAddress); } catch (e) { throw Exception('Receiver account does not exist.'); From cb64c15deb7fb38e3eab212f1cada2bedf89411d Mon Sep 17 00:00:00 2001 From: Alaa Elattar Date: Thu, 22 May 2025 09:22:48 +0300 Subject: [PATCH 4/4] fix renaming --- packages/stellar_client/lib/src/client.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/stellar_client/lib/src/client.dart b/packages/stellar_client/lib/src/client.dart index 9aa5f6c6..c945d65d 100644 --- a/packages/stellar_client/lib/src/client.dart +++ b/packages/stellar_client/lib/src/client.dart @@ -364,7 +364,7 @@ class Client { } throw Exception('Balance with asset code ${currency} not found.'); }); - List balance = []; + List receiverBalance = []; try { // check that receiver account exists receiverBalance = await getBalanceByAccountID( @@ -374,7 +374,7 @@ class Client { } // check that asset exists - var specificBalance = balance.firstWhere( + var specificBalance = receiverBalance.firstWhere( (balance) => balance.assetCode == currency, orElse: () { throw Exception('Balance with asset code ${currency} not found.');