Skip to content

Commit 5b97929

Browse files
committed
fix(spl): init rpc even when you skip opening the parent wallet
applicable if the user selects "only sync selected wallets"
1 parent 9887fd6 commit 5b97929

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

lib/wallets/wallet/impl/solana_wallet.dart

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ class SolanaWallet extends Bip39Wallet<Solana> {
7575
}
7676

7777
Future<BigInt> _getCurrentBalanceInLamports() async {
78-
_checkClient();
78+
checkClient();
7979
final balance = await _rpcClient?.getBalance((await _getKeyPair()).address);
8080
return BigInt.from(balance!.value);
8181
}
8282

8383
Future<BigInt?> _getEstimatedNetworkFee(Amount transferAmount) async {
84-
_checkClient();
84+
checkClient();
8585
final latestBlockhash = await _rpcClient?.getLatestBlockhash();
8686
final pubKey = (await _getKeyPair()).publicKey;
8787

@@ -134,7 +134,7 @@ class SolanaWallet extends Bip39Wallet<Solana> {
134134
@override
135135
Future<TxData> prepareSend({required TxData txData}) async {
136136
try {
137-
_checkClient();
137+
checkClient();
138138

139139
if (txData.recipients == null || txData.recipients!.length != 1) {
140140
throw Exception("$runtimeType prepareSend requires 1 recipient");
@@ -195,7 +195,7 @@ class SolanaWallet extends Bip39Wallet<Solana> {
195195
@override
196196
Future<TxData> confirmSend({required TxData txData}) async {
197197
try {
198-
_checkClient();
198+
checkClient();
199199

200200
final keyPair = await _getKeyPair();
201201
final recipientAccount = txData.recipients!.first;
@@ -280,7 +280,7 @@ class SolanaWallet extends Bip39Wallet<Solana> {
280280

281281
@override
282282
Future<Amount> estimateFeeFor(Amount amount, BigInt feeRate) async {
283-
_checkClient();
283+
checkClient();
284284

285285
if (info.cachedBalance.spendable.raw == BigInt.zero) {
286286
return Amount(
@@ -292,12 +292,15 @@ class SolanaWallet extends Bip39Wallet<Solana> {
292292
// The feeRate parameter contains the total fee amount to use.
293293
// For Solana, this is already calculated based on priority tier.
294294
// Simply return it as the fee estimate.
295-
return Amount(rawValue: feeRate, fractionDigits: cryptoCurrency.fractionDigits);
295+
return Amount(
296+
rawValue: feeRate,
297+
fractionDigits: cryptoCurrency.fractionDigits,
298+
);
296299
}
297300

298301
@override
299302
Future<FeeObject> get fees async {
300-
_checkClient();
303+
checkClient();
301304

302305
final baseFee = await _getEstimatedNetworkFee(
303306
Amount.fromDecimal(
@@ -348,7 +351,7 @@ class SolanaWallet extends Bip39Wallet<Solana> {
348351
Future<bool> pingCheck() async {
349352
String? health;
350353
try {
351-
_checkClient();
354+
checkClient();
352355
health = await _rpcClient?.getHealth();
353356
return health != null;
354357
} catch (e, s) {
@@ -387,7 +390,7 @@ class SolanaWallet extends Bip39Wallet<Solana> {
387390

388391
@override
389392
Future<void> updateBalance() async {
390-
_checkClient();
393+
checkClient();
391394
try {
392395
final address = await getCurrentReceivingAddress();
393396

@@ -437,7 +440,7 @@ class SolanaWallet extends Bip39Wallet<Solana> {
437440
@override
438441
Future<void> updateChainHeight() async {
439442
try {
440-
_checkClient();
443+
checkClient();
441444

442445
final int blockHeight = await _rpcClient?.getSlot() ?? 0;
443446
// TODO [prio=low]: Revisit null condition.
@@ -478,7 +481,7 @@ class SolanaWallet extends Bip39Wallet<Solana> {
478481
@override
479482
Future<void> updateTransactions() async {
480483
try {
481-
_checkClient();
484+
checkClient();
482485

483486
final transactionsList = await _rpcClient?.getTransactionsList(
484487
(await _getKeyPair()).publicKey,
@@ -665,7 +668,7 @@ class SolanaWallet extends Bip39Wallet<Solana> {
665668
}
666669

667670
/// Make sure the Solana RpcClient uses Tor if it's enabled.
668-
void _checkClient() {
671+
void checkClient() {
669672
final node = getCurrentNode();
670673

671674
final netOption = TorPlainNetworkOption.fromNodeData(

lib/wallets/wallet/impl/sub_wallets/solana_token_wallet.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ class SolanaTokenWallet extends Wallet {
7777
@override
7878
Future<void> init() async {
7979
await super.init();
80-
// TODO: Initialize token account address derivation.
80+
81+
parentSolanaWallet.checkClient();
82+
8183
await Future<void>.delayed(const Duration(milliseconds: 100));
8284
}
8385

0 commit comments

Comments
 (0)