From eb8c6a76e232bc2b98895ef1d0dd4b9dc86a1a6b Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Mon, 30 Dec 2024 20:58:58 +0200 Subject: [PATCH 1/9] fix openAlias resolver not being reached --- lib/entities/parse_address_from_domain.dart | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/entities/parse_address_from_domain.dart b/lib/entities/parse_address_from_domain.dart index 5c5075737..258ebf485 100644 --- a/lib/entities/parse_address_from_domain.dart +++ b/lib/entities/parse_address_from_domain.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); + } } } @@ -257,12 +259,25 @@ class AddressResolver { } } + print("@@@@@@@@"); + print(formattedName); + print(domainParts); + print(name); + if (formattedName.contains(".")) { if (settingsStore.lookupsOpenAlias) { final txtRecord = await OpenaliasRecord.lookupOpenAliasRecord(formattedName); + + print("@@@@@@@@"); + print(txtRecord); if (txtRecord != null) { final record = await OpenaliasRecord.fetchAddressAndName( formattedName: formattedName, ticker: ticker.toLowerCase(), txtRecord: txtRecord); + print("@@@@@@@@"); + print(record); + print(record.name); + print(record.address); + print(record.description); return ParsedAddress.fetchOpenAliasAddress(record: record, name: text); } } From c880dbd83c54cd1e338ecec4c3caebe183915fd7 Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Tue, 31 Dec 2024 07:33:45 +0200 Subject: [PATCH 2/9] fix creating associated token account --- cw_solana/lib/solana_client.dart | 49 ++++++++++++++++++++++++++------ cw_solana/lib/solana_wallet.dart | 1 - 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/cw_solana/lib/solana_client.dart b/cw_solana/lib/solana_client.dart index 2207822bb..9412b4e9c 100644 --- a/cw_solana/lib/solana_client.dart +++ b/cw_solana/lib/solana_client.dart @@ -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), @@ -587,6 +618,8 @@ class SolanaWalletClient { signedTransaction.encode(), preflightCommitment: commitment, ); + print("#########"); + print(signature); _client!.waitForSignatureStatus(signature, status: commitment); diff --git a/cw_solana/lib/solana_wallet.dart b/cw_solana/lib/solana_wallet.dart index 33a2e7df4..15c065918 100644 --- a/cw_solana/lib/solana_wallet.dart +++ b/cw_solana/lib/solana_wallet.dart @@ -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'; From 26c1f0b85c2e2de404d9a4597d69650510b3e7c4 Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Tue, 31 Dec 2024 08:06:56 +0200 Subject: [PATCH 3/9] remove print --- lib/entities/parse_address_from_domain.dart | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/lib/entities/parse_address_from_domain.dart b/lib/entities/parse_address_from_domain.dart index 258ebf485..b13dfa9ad 100644 --- a/lib/entities/parse_address_from_domain.dart +++ b/lib/entities/parse_address_from_domain.dart @@ -259,25 +259,13 @@ class AddressResolver { } } - print("@@@@@@@@"); - print(formattedName); - print(domainParts); - print(name); - if (formattedName.contains(".")) { if (settingsStore.lookupsOpenAlias) { final txtRecord = await OpenaliasRecord.lookupOpenAliasRecord(formattedName); - print("@@@@@@@@"); - print(txtRecord); if (txtRecord != null) { final record = await OpenaliasRecord.fetchAddressAndName( formattedName: formattedName, ticker: ticker.toLowerCase(), txtRecord: txtRecord); - print("@@@@@@@@"); - print(record); - print(record.name); - print(record.address); - print(record.description); return ParsedAddress.fetchOpenAliasAddress(record: record, name: text); } } From 84cc0576d56abed644866cbbfe95fd1b6fb7ddad Mon Sep 17 00:00:00 2001 From: Omar Hatem Date: Tue, 31 Dec 2024 17:03:17 +0200 Subject: [PATCH 4/9] fix creating associated token account (#1918) --- cw_solana/lib/solana_client.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/cw_solana/lib/solana_client.dart b/cw_solana/lib/solana_client.dart index 9412b4e9c..16f8988b1 100644 --- a/cw_solana/lib/solana_client.dart +++ b/cw_solana/lib/solana_client.dart @@ -618,8 +618,6 @@ class SolanaWalletClient { signedTransaction.encode(), preflightCommitment: commitment, ); - print("#########"); - print(signature); _client!.waitForSignatureStatus(signature, status: commitment); From a2cb994c09352eb85ff5d8909aa07ad37933bbb7 Mon Sep 17 00:00:00 2001 From: Omar Hatem Date: Tue, 31 Dec 2024 17:03:36 +0200 Subject: [PATCH 5/9] Fix fee check for erc20 transactions (#1915) --- cw_evm/lib/evm_chain_wallet.dart | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cw_evm/lib/evm_chain_wallet.dart b/cw_evm/lib/evm_chain_wallet.dart index dca16539c..9ccb05e7f 100644 --- a/cw_evm/lib/evm_chain_wallet.dart +++ b/cw_evm/lib/evm_chain_wallet.dart @@ -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); } } From 9b27121261a3dd91886cde641ab9f01f44b82075 Mon Sep 17 00:00:00 2001 From: Omar Hatem Date: Tue, 31 Dec 2024 17:04:18 +0200 Subject: [PATCH 6/9] Rename linux app (#1911) --- linux/my_application.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux/my_application.cc b/linux/my_application.cc index 7375d05ca..49ed75499 100644 --- a/linux/my_application.cc +++ b/linux/my_application.cc @@ -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); From d33a901f669b9a2a3868b4c184be5fe58a2974a6 Mon Sep 17 00:00:00 2001 From: cyan Date: Tue, 31 Dec 2024 17:47:17 +0100 Subject: [PATCH 7/9] Fix unavailable balance not refreshing after the app got opened (#1920) --- cw_monero/lib/monero_wallet.dart | 4 ++++ cw_monero/lib/monero_wallet_service.dart | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cw_monero/lib/monero_wallet.dart b/cw_monero/lib/monero_wallet.dart index 4d2f95e47..9f46d32cd 100644 --- a/cw_monero/lib/monero_wallet.dart +++ b/cw_monero/lib/monero_wallet.dart @@ -503,6 +503,7 @@ abstract class MoneroWalletBase extends WalletBase updateUnspent() async { + await transaction_history.txHistoryMutex.acquire(); try { refreshCoins(walletAddresses.account!.id); @@ -531,6 +532,7 @@ abstract class MoneroWalletBase extends WalletBase _addCoinInfo(coin)); + transaction_history.txHistoryMutex.release(); return; } @@ -555,7 +557,9 @@ abstract class MoneroWalletBase extends WalletBase Date: Thu, 2 Jan 2025 00:14:00 +0200 Subject: [PATCH 8/9] Fix Mobx issue (#1922) --- cw_bitcoin/lib/electrum_wallet_addresses.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cw_bitcoin/lib/electrum_wallet_addresses.dart b/cw_bitcoin/lib/electrum_wallet_addresses.dart index 6774a5036..13a32c68c 100644 --- a/cw_bitcoin/lib/electrum_wallet_addresses.dart +++ b/cw_bitcoin/lib/electrum_wallet_addresses.dart @@ -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; } From 0ebfd671f98e84da3455238ae7a9e841080cc5b9 Mon Sep 17 00:00:00 2001 From: Omar Hatem Date: Thu, 2 Jan 2025 18:02:44 +0200 Subject: [PATCH 9/9] Revert "Fix unavailable balance not refreshing after the app got opened (#1920)" (#1925) This reverts commit d33a901f669b9a2a3868b4c184be5fe58a2974a6. --- cw_monero/lib/monero_wallet.dart | 4 ---- cw_monero/lib/monero_wallet_service.dart | 3 +-- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/cw_monero/lib/monero_wallet.dart b/cw_monero/lib/monero_wallet.dart index 9f46d32cd..4d2f95e47 100644 --- a/cw_monero/lib/monero_wallet.dart +++ b/cw_monero/lib/monero_wallet.dart @@ -503,7 +503,6 @@ abstract class MoneroWalletBase extends WalletBase updateUnspent() async { - await transaction_history.txHistoryMutex.acquire(); try { refreshCoins(walletAddresses.account!.id); @@ -532,7 +531,6 @@ abstract class MoneroWalletBase extends WalletBase _addCoinInfo(coin)); - transaction_history.txHistoryMutex.release(); return; } @@ -557,9 +555,7 @@ abstract class MoneroWalletBase extends WalletBase