Skip to content

Commit dabf623

Browse files
fix transferring xlms (#161)
* fix transferring xlms * add try && catch for errors * Update client.dart Co-authored-by: AhmedHanafy725 <41957921+AhmedHanafy725@users.noreply.github.com> * fix renaming --------- Co-authored-by: AhmedHanafy725 <41957921+AhmedHanafy725@users.noreply.github.com>
1 parent 488ca66 commit dabf623

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

packages/stellar_client/lib/src/client.dart

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,17 @@ class Client {
364364
}
365365
throw Exception('Balance with asset code ${currency} not found.');
366366
});
367-
// check that receiver account exists
368-
final receiver = await _sdk.accounts.account(accountId);
367+
List<BalanceInfo> receiverBalance = [];
368+
try {
369+
// check that receiver account exists
370+
receiverBalance = await getBalanceByAccountID(
371+
network: _network, accountId: destinationAddress);
372+
} catch (e) {
373+
throw Exception('Receiver account does not exist.');
374+
}
375+
369376
// check that asset exists
370-
var specificBalance = receiver.balances.firstWhere(
377+
var specificBalance = receiverBalance.firstWhere(
371378
(balance) => balance.assetCode == currency,
372379
orElse: () {
373380
throw Exception('Balance with asset code ${currency} not found.');

0 commit comments

Comments
 (0)