mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-22 19:39:22 +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
|
// Rent exemption of Solana
|
||||||
final accInfo = await _rpcClient?.getAccountInfo(address!.value);
|
final accInfo = await _rpcClient?.getAccountInfo(address!.value);
|
||||||
|
if (accInfo!.value == null) {
|
||||||
|
throw Exception("Account does not appear to exist");
|
||||||
|
}
|
||||||
|
|
||||||
final int minimumRent =
|
final int minimumRent =
|
||||||
await _rpcClient?.getMinimumBalanceForRentExemption(
|
await _rpcClient!.getMinimumBalanceForRentExemption(
|
||||||
accInfo!.value!.data.toString().length,
|
accInfo.value!.data.toString().length,
|
||||||
) ??
|
);
|
||||||
0; // TODO revisit null condition.
|
|
||||||
if (minimumRent >
|
if (minimumRent >
|
||||||
((await _getCurrentBalanceInLamports()) -
|
((await _getCurrentBalanceInLamports()) -
|
||||||
txData.amount!.raw.toInt() -
|
txData.amount!.raw.toInt() -
|
||||||
|
@ -300,13 +303,14 @@ class SolanaWallet extends Bip39Wallet<Solana> {
|
||||||
|
|
||||||
// Rent exemption of Solana
|
// Rent exemption of Solana
|
||||||
final accInfo = await _rpcClient?.getAccountInfo(address!.value);
|
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 =
|
final int minimumRent =
|
||||||
await _rpcClient?.getMinimumBalanceForRentExemption(
|
await _rpcClient!.getMinimumBalanceForRentExemption(
|
||||||
accInfo!.value!.data.toString().length,
|
accInfo.value!.data.toString().length,
|
||||||
) ??
|
);
|
||||||
0;
|
|
||||||
// TODO [prio=low]: revisit null condition.
|
|
||||||
final spendableBalance = balance!.value - minimumRent;
|
final spendableBalance = balance!.value - minimumRent;
|
||||||
|
|
||||||
final newBalance = Balance(
|
final newBalance = Balance(
|
||||||
|
|
Loading…
Reference in a new issue