mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-23 03:05:11 +00:00
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into mweb-bg-sync-2
This commit is contained in:
commit
e243009fc0
6 changed files with 59 additions and 24 deletions
|
@ -349,8 +349,10 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
|||
type: addressPageType,
|
||||
network: network,
|
||||
);
|
||||
_addresses.add(address);
|
||||
Future.delayed(Duration.zero, () => updateAddressesByMatch());
|
||||
Future.delayed(Duration.zero, () {
|
||||
_addresses.add(address);
|
||||
updateAddressesByMatch();
|
||||
});
|
||||
return address;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ import 'package:cw_evm/evm_chain_transaction_model.dart';
|
|||
import 'package:cw_evm/evm_chain_transaction_priority.dart';
|
||||
import 'package:cw_evm/evm_chain_wallet_addresses.dart';
|
||||
import 'package:cw_evm/evm_ledger_credentials.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hex/hex.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
@ -348,7 +347,7 @@ abstract class EVMChainWalletBase
|
|||
final CryptoCurrency transactionCurrency =
|
||||
balance.keys.firstWhere((element) => element.title == _credentials.currency.title);
|
||||
|
||||
final erc20Balance = balance[transactionCurrency]!;
|
||||
final currencyBalance = balance[transactionCurrency]!;
|
||||
BigInt totalAmount = BigInt.zero;
|
||||
BigInt estimatedFeesForTransaction = BigInt.zero;
|
||||
int exponent = transactionCurrency is Erc20Token ? transactionCurrency.decimal : 18;
|
||||
|
@ -385,7 +384,7 @@ abstract class EVMChainWalletBase
|
|||
estimatedGasUnitsForTransaction = gasFeesModel.estimatedGasUnits;
|
||||
maxFeePerGasForTransaction = gasFeesModel.maxFeePerGas;
|
||||
|
||||
if (erc20Balance.balance < totalAmount) {
|
||||
if (currencyBalance.balance < totalAmount) {
|
||||
throw EVMChainTransactionCreationException(transactionCurrency);
|
||||
}
|
||||
} else {
|
||||
|
@ -398,7 +397,7 @@ abstract class EVMChainWalletBase
|
|||
}
|
||||
|
||||
if (output.sendAll && transactionCurrency is Erc20Token) {
|
||||
totalAmount = erc20Balance.balance;
|
||||
totalAmount = currencyBalance.balance;
|
||||
}
|
||||
|
||||
final gasFeesModel = await calculateActualEstimatedFeeForCreateTransaction(
|
||||
|
@ -413,14 +412,15 @@ abstract class EVMChainWalletBase
|
|||
maxFeePerGasForTransaction = gasFeesModel.maxFeePerGas;
|
||||
|
||||
if (output.sendAll && transactionCurrency is! Erc20Token) {
|
||||
totalAmount = (erc20Balance.balance - estimatedFeesForTransaction);
|
||||
|
||||
if (estimatedFeesForTransaction > erc20Balance.balance) {
|
||||
throw EVMChainTransactionFeesException();
|
||||
}
|
||||
totalAmount = (currencyBalance.balance - estimatedFeesForTransaction);
|
||||
}
|
||||
|
||||
if (erc20Balance.balance < totalAmount) {
|
||||
// check the fees on the base currency (Eth/Polygon)
|
||||
if (estimatedFeesForTransaction > balance[currency]!.balance) {
|
||||
throw EVMChainTransactionFeesException();
|
||||
}
|
||||
|
||||
if (currencyBalance.balance < totalAmount) {
|
||||
throw EVMChainTransactionCreationException(transactionCurrency);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -481,6 +481,9 @@ class SolanaWalletClient {
|
|||
final destinationOwner = Ed25519HDPublicKey.fromBase58(destinationAddress);
|
||||
final mint = Ed25519HDPublicKey.fromBase58(tokenMint);
|
||||
|
||||
// Input by the user
|
||||
final amount = (inputAmount * math.pow(10, tokenDecimals)).toInt();
|
||||
|
||||
ProgramAccount? associatedRecipientAccount;
|
||||
ProgramAccount? associatedSenderAccount;
|
||||
|
||||
|
@ -503,18 +506,46 @@ class SolanaWalletClient {
|
|||
}
|
||||
|
||||
try {
|
||||
associatedRecipientAccount ??= await _client!.createAssociatedTokenAccount(
|
||||
mint: mint,
|
||||
owner: destinationOwner,
|
||||
funder: ownerKeypair,
|
||||
);
|
||||
if (associatedRecipientAccount == null) {
|
||||
final derivedAddress = await findAssociatedTokenAddress(
|
||||
owner: destinationOwner,
|
||||
mint: mint,
|
||||
);
|
||||
|
||||
final instruction = AssociatedTokenAccountInstruction.createAccount(
|
||||
mint: mint,
|
||||
address: derivedAddress,
|
||||
owner: ownerKeypair.publicKey,
|
||||
funder: ownerKeypair.publicKey,
|
||||
);
|
||||
|
||||
final _signedTx = await _signTransactionInternal(
|
||||
message: Message.only(instruction),
|
||||
signers: [ownerKeypair],
|
||||
commitment: commitment,
|
||||
latestBlockhash: await _getLatestBlockhash(commitment),
|
||||
);
|
||||
|
||||
await sendTransaction(
|
||||
signedTransaction: _signedTx,
|
||||
commitment: commitment,
|
||||
);
|
||||
|
||||
associatedRecipientAccount = ProgramAccount(
|
||||
pubkey: derivedAddress.toBase58(),
|
||||
account: Account(
|
||||
owner: destinationOwner.toBase58(),
|
||||
lamports: 0,
|
||||
executable: false,
|
||||
rentEpoch: BigInt.zero,
|
||||
data: null,
|
||||
),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
throw SolanaCreateAssociatedTokenAccountException(e.toString());
|
||||
}
|
||||
|
||||
// Input by the user
|
||||
final amount = (inputAmount * math.pow(10, tokenDecimals)).toInt();
|
||||
|
||||
final instruction = TokenInstruction.transfer(
|
||||
source: Ed25519HDPublicKey.fromBase58(associatedSenderAccount.pubkey),
|
||||
destination: Ed25519HDPublicKey.fromBase58(associatedRecipientAccount.pubkey),
|
||||
|
|
|
@ -33,7 +33,6 @@ import 'package:shared_preferences/shared_preferences.dart';
|
|||
import 'package:solana/base58.dart';
|
||||
import 'package:solana/metaplex.dart' as metaplex;
|
||||
import 'package:solana/solana.dart';
|
||||
import 'package:solana/src/crypto/ed25519_hd_keypair.dart';
|
||||
|
||||
part 'solana_wallet.g.dart';
|
||||
|
||||
|
|
|
@ -244,7 +244,9 @@ class AddressResolver {
|
|||
if (unstoppableDomains.any((domain) => name.trim() == domain)) {
|
||||
if (settingsStore.lookupsUnstoppableDomains) {
|
||||
final address = await fetchUnstoppableDomainAddress(text, ticker);
|
||||
return ParsedAddress.fetchUnstoppableDomainAddress(address: address, name: text);
|
||||
if (address.isNotEmpty) {
|
||||
return ParsedAddress.fetchUnstoppableDomainAddress(address: address, name: text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -260,6 +262,7 @@ class AddressResolver {
|
|||
if (formattedName.contains(".")) {
|
||||
if (settingsStore.lookupsOpenAlias) {
|
||||
final txtRecord = await OpenaliasRecord.lookupOpenAliasRecord(formattedName);
|
||||
|
||||
if (txtRecord != null) {
|
||||
final record = await OpenaliasRecord.fetchAddressAndName(
|
||||
formattedName: formattedName, ticker: ticker.toLowerCase(), txtRecord: txtRecord);
|
||||
|
|
|
@ -40,11 +40,11 @@ static void my_application_activate(GApplication* application) {
|
|||
if (use_header_bar) {
|
||||
GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
|
||||
gtk_widget_show(GTK_WIDGET(header_bar));
|
||||
gtk_header_bar_set_title(header_bar, "cake_wallet");
|
||||
gtk_header_bar_set_title(header_bar, "Cake Wallet");
|
||||
gtk_header_bar_set_show_close_button(header_bar, TRUE);
|
||||
gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
|
||||
} else {
|
||||
gtk_window_set_title(window, "cake_wallet");
|
||||
gtk_window_set_title(window, "Cake Wallet");
|
||||
}
|
||||
|
||||
gtk_window_set_default_size(window, 1280, 720);
|
||||
|
|
Loading…
Reference in a new issue