mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-22 11:29:23 +00:00
"handle" null account info according to https://solana.com/docs/rpc/http/getaccountinfo#result
This commit is contained in:
parent
3fb18bf2db
commit
d6abd7d658
1 changed files with 14 additions and 10 deletions
|
@ -132,11 +132,14 @@ class SolanaWallet extends Bip39Wallet<Solana> {
|
|||
|
||||
// Rent exemption of Solana
|
||||
final accInfo = await _rpcClient?.getAccountInfo(address!.value);
|
||||
if (accInfo!.value == null) {
|
||||
throw Exception("Account does not appear to exist");
|
||||
}
|
||||
|
||||
final int minimumRent =
|
||||
await _rpcClient?.getMinimumBalanceForRentExemption(
|
||||
accInfo!.value!.data.toString().length,
|
||||
) ??
|
||||
0; // TODO revisit null condition.
|
||||
await _rpcClient!.getMinimumBalanceForRentExemption(
|
||||
accInfo.value!.data.toString().length,
|
||||
);
|
||||
if (minimumRent >
|
||||
((await _getCurrentBalanceInLamports()) -
|
||||
txData.amount!.raw.toInt() -
|
||||
|
@ -300,13 +303,14 @@ class SolanaWallet extends Bip39Wallet<Solana> {
|
|||
|
||||
// Rent exemption of Solana
|
||||
final accInfo = await _rpcClient?.getAccountInfo(address!.value);
|
||||
// TODO [prio=low]: handle null account info.
|
||||
if (accInfo!.value == null) {
|
||||
throw Exception("Account does not appear to exist");
|
||||
}
|
||||
|
||||
final int minimumRent =
|
||||
await _rpcClient?.getMinimumBalanceForRentExemption(
|
||||
accInfo!.value!.data.toString().length,
|
||||
) ??
|
||||
0;
|
||||
// TODO [prio=low]: revisit null condition.
|
||||
await _rpcClient!.getMinimumBalanceForRentExemption(
|
||||
accInfo.value!.data.toString().length,
|
||||
);
|
||||
final spendableBalance = balance!.value - minimumRent;
|
||||
|
||||
final newBalance = Balance(
|
||||
|
|
Loading…
Reference in a new issue