mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 11:59:30 +00:00
solana fee estimation fixes
This commit is contained in:
parent
cfe06f5b13
commit
bf3667da85
1 changed files with 6 additions and 18 deletions
|
@ -18,7 +18,6 @@ import 'package:stackwallet/services/tor_service.dart';
|
||||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||||
import 'package:stackwallet/utilities/default_nodes.dart';
|
import 'package:stackwallet/utilities/default_nodes.dart';
|
||||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||||
import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart';
|
|
||||||
import 'package:stackwallet/utilities/logger.dart';
|
import 'package:stackwallet/utilities/logger.dart';
|
||||||
import 'package:stackwallet/wallets/crypto_currency/coins/solana.dart';
|
import 'package:stackwallet/wallets/crypto_currency/coins/solana.dart';
|
||||||
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
||||||
|
@ -66,10 +65,8 @@ class SolanaWallet extends Bip39Wallet<Solana> {
|
||||||
recipientAccount: pubKey,
|
recipientAccount: pubKey,
|
||||||
lamports: transferAmount.raw.toInt(),
|
lamports: transferAmount.raw.toInt(),
|
||||||
),
|
),
|
||||||
]).compile(
|
ComputeBudgetInstruction.setComputeUnitPrice(microLamports: 6000),
|
||||||
recentBlockhash: latestBlockhash!.value.blockhash,
|
]).compile(recentBlockhash: latestBlockhash!.value.blockhash, feePayer: (await _getKeyPair()).publicKey);
|
||||||
feePayer: pubKey,
|
|
||||||
);
|
|
||||||
|
|
||||||
return await _rpcClient?.getFeeForMessage(
|
return await _rpcClient?.getFeeForMessage(
|
||||||
base64Encode(compiledMessage.toByteArray().toList()),
|
base64Encode(compiledMessage.toByteArray().toList()),
|
||||||
|
@ -118,19 +115,10 @@ class SolanaWallet extends Bip39Wallet<Solana> {
|
||||||
throw Exception("Insufficient available balance");
|
throw Exception("Insufficient available balance");
|
||||||
}
|
}
|
||||||
|
|
||||||
int feeAmount;
|
final feeAmount = await _getEstimatedNetworkFee(sendAmount);
|
||||||
final currentFees = await fees;
|
if (feeAmount == null) {
|
||||||
switch (txData.feeRateType) {
|
throw Exception(
|
||||||
case FeeRateType.fast:
|
"Failed to get fees, please check your node connection.");
|
||||||
feeAmount = currentFees.fast;
|
|
||||||
break;
|
|
||||||
case FeeRateType.slow:
|
|
||||||
feeAmount = currentFees.slow;
|
|
||||||
break;
|
|
||||||
case FeeRateType.average:
|
|
||||||
default:
|
|
||||||
feeAmount = currentFees.medium;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rent exemption of Solana
|
// Rent exemption of Solana
|
||||||
|
|
Loading…
Reference in a new issue