Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solana fixes #1962

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 17 additions & 19 deletions cw_solana/lib/solana_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class SolanaWalletClient {
transactionDetails.addAll(response);

// to avoid reaching the node RPS limit
await Future.delayed(Duration(milliseconds: 500));
await Future.delayed(const Duration(milliseconds: 500));
}

for (final tx in transactionDetails) {
Expand Down Expand Up @@ -379,18 +379,16 @@ class SolanaWalletClient {
required double solBalance,
required double fee,
}) async {
return true;
// TODO: this is not doing what the name inclines
// final rent =
// await _client!.getMinimumBalanceForMintRentExemption(commitment: Commitment.confirmed);
//
// final rentInSol = (rent / lamportsPerSol).toDouble();
//
// final remnant = solBalance - (inputAmount + fee);
//
// if (remnant > rentInSol) return true;
//
// return false;
final rent =
await _client!.getMinimumBalanceForMintRentExemption(commitment: Commitment.confirmed);

final rentInSol = (rent / lamportsPerSol).toDouble();

final remnant = solBalance - (inputAmount + fee);

if (remnant > rentInSol) return true;

return false;
}

Future<PendingSolanaTransaction> _signNativeTokenTransaction({
Expand Down Expand Up @@ -542,7 +540,7 @@ class SolanaWalletClient {
),
);

await Future.delayed(Duration(seconds: 5));
await Future.delayed(const Duration(seconds: 5));
}
} catch (e) {
throw SolanaCreateAssociatedTokenAccountException(e.toString());
Expand All @@ -569,7 +567,7 @@ class SolanaWalletClient {
);

bool hasSufficientFundsLeft = await hasSufficientFundsLeftForRent(
inputAmount: inputAmount,
inputAmount: 0,
fee: fee,
solBalance: solBalance,
);
Expand All @@ -586,12 +584,12 @@ class SolanaWalletClient {
);

sendTx() async {
await Future.delayed(Duration(seconds: 3));
await Future.delayed(const Duration(seconds: 3));

return await sendTransaction(
signedTransaction: signedTx,
commitment: commitment,
);
signedTransaction: signedTx,
commitment: commitment,
);
}

final pendingTransaction = PendingSolanaTransaction(
Expand Down