mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
- disable Arbitrum
- Minor fixes - Code cleanup
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
||||
@echo off
|
||||
set cw_win_app_config=--monero --bitcoin --ethereum --polygon --nano --bitcoinCash --solana --tron --dogecoin --base --arbitrum
|
||||
set cw_win_app_config=--monero --bitcoin --ethereum --polygon --nano --bitcoinCash --solana --tron --dogecoin --base
|
||||
set cw_root=%cd%
|
||||
set cw_archive_name=Cake Wallet.zip
|
||||
set cw_archive_path=%cw_root%\%cw_archive_name%
|
||||
|
||||
@@ -86,7 +86,7 @@ abstract class WalletBase<BalanceType extends Balance, HistoryType extends Trans
|
||||
|
||||
int calculateEstimatedFee(TransactionPriority priority, int? amount);
|
||||
|
||||
Future<void> updateEstimatedFeesParams(TransactionPriority priority) async {}
|
||||
Future<void> updateEstimatedFeesParams(TransactionPriority? priority) async {}
|
||||
|
||||
// void fetchTransactionsAsync(
|
||||
// void Function(TransactionType transaction) onTransactionLoaded,
|
||||
|
||||
@@ -277,7 +277,7 @@ abstract class EVMChainWalletBase
|
||||
int calculateEstimatedFee(TransactionPriority priority, int? amount) => 0;
|
||||
|
||||
@override
|
||||
Future<void> updateEstimatedFeesParams(TransactionPriority priority) async =>
|
||||
Future<void> updateEstimatedFeesParams(TransactionPriority? priority) async =>
|
||||
await _getEstimatedFees(priority);
|
||||
|
||||
Future<void> _getEstimatedFees(TransactionPriority? priority) async {
|
||||
|
||||
@@ -446,35 +446,34 @@ class NanoClient {
|
||||
required String destinationAddress,
|
||||
required String privateKey,
|
||||
}) async {
|
||||
final receivableResponse = await ProxyWrapper().post(
|
||||
clearnetUri: _node!.uri,
|
||||
headers: getHeaders(_node!.uri.host),
|
||||
body: jsonEncode({
|
||||
"action": "receivable",
|
||||
"account": destinationAddress,
|
||||
"count": "-1",
|
||||
"source": true,
|
||||
}),
|
||||
);
|
||||
final receivableData = jsonDecode(receivableResponse.body) as Map<String, dynamic>;
|
||||
if (receivableData["blocks"] == "" || receivableData["blocks"] == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
dynamic blocks;
|
||||
if (receivableData["blocks"] is List<dynamic>) {
|
||||
var listBlocks = receivableData["blocks"] as List<dynamic>;
|
||||
if (listBlocks.isEmpty) {
|
||||
try {
|
||||
final receivableResponse = await ProxyWrapper().post(
|
||||
clearnetUri: _node!.uri,
|
||||
headers: getHeaders(_node!.uri.host),
|
||||
body: jsonEncode({
|
||||
"action": "receivable",
|
||||
"account": destinationAddress,
|
||||
"count": "-1",
|
||||
"source": true,
|
||||
}),
|
||||
);
|
||||
final receivableData = jsonDecode(receivableResponse.body) as Map<String, dynamic>;
|
||||
if (receivableData["blocks"] == "" || receivableData["blocks"] == null) {
|
||||
return 0;
|
||||
}
|
||||
blocks = {for (var block in listBlocks) block['hash']: block};
|
||||
} else {
|
||||
blocks = receivableData["blocks"] as Map<String, dynamic>;
|
||||
}
|
||||
|
||||
blocks = blocks as Map<String, dynamic>;
|
||||
dynamic blocks;
|
||||
if (receivableData["blocks"] is List<dynamic>) {
|
||||
var listBlocks = receivableData["blocks"] as List<dynamic>;
|
||||
if (listBlocks.isEmpty) {
|
||||
return 0;
|
||||
}
|
||||
blocks = {for (var block in listBlocks) block['hash']: block};
|
||||
} else {
|
||||
blocks = receivableData["blocks"] as Map<String, dynamic>;
|
||||
}
|
||||
|
||||
try {
|
||||
blocks = blocks as Map<String, dynamic>;
|
||||
// confirm all receivable blocks:
|
||||
for (final blockHash in blocks.keys) {
|
||||
final block = blocks[blockHash];
|
||||
|
||||
@@ -19,6 +19,8 @@ wownero.SubaddressAccount? subaddressAccount;
|
||||
bool isUpdating = false;
|
||||
|
||||
void refreshAccounts() {
|
||||
if (wptr == null) return;
|
||||
|
||||
try {
|
||||
isUpdating = true;
|
||||
subaddressAccount = wownero.Wallet_subaddressAccount(wptr!);
|
||||
@@ -31,6 +33,7 @@ void refreshAccounts() {
|
||||
}
|
||||
|
||||
List<wownero.SubaddressAccountRow> getAllAccount() {
|
||||
if (wptr == null) return [];
|
||||
// final size = wownero.Wallet_numSubaddressAccounts(wptr!);
|
||||
refreshAccounts();
|
||||
int size = wownero.SubaddressAccount_getAll_size(subaddressAccount!);
|
||||
|
||||
@@ -162,62 +162,8 @@ abstract class OutputBase with Store {
|
||||
@action
|
||||
Future<void> calculateEstimatedFee() async {
|
||||
try {
|
||||
if (_wallet.type == WalletType.tron) {
|
||||
if (cryptoCurrencyHandler() == CryptoCurrency.trx) {
|
||||
final nativeEstimatedFee = tron!.getTronNativeEstimatedFee(_wallet) ?? '0';
|
||||
estimatedFee = double.parse(nativeEstimatedFee);
|
||||
} else {
|
||||
final trc20EstimatedFee = tron!.getTronTRC20EstimatedFee(_wallet) ?? '0';
|
||||
estimatedFee = double.parse(trc20EstimatedFee);
|
||||
}
|
||||
}
|
||||
|
||||
if (isEVMCompatibleChain(_wallet.type)) {
|
||||
if (_wallet.type == WalletType.arbitrum) {
|
||||
String? fee = cryptoCurrencyHandler() == CryptoCurrency.arbEth
|
||||
? arbitrum!.getArbitrumNativeEstimatedFee(_wallet)
|
||||
: arbitrum!.getArbitrumERC20EstimatedFee(_wallet);
|
||||
|
||||
estimatedFee = arbitrum!
|
||||
.formatterArbitrumAmountToDouble(amount: BigInt.from(double.parse(fee ?? '0.0')));
|
||||
return;
|
||||
}
|
||||
|
||||
await _wallet.updateEstimatedFeesParams(_settingsStore.priority[_wallet.type]!);
|
||||
|
||||
double calculatedFee = 0.0;
|
||||
|
||||
if (_wallet.type == WalletType.ethereum) {
|
||||
String? fee = cryptoCurrencyHandler() == CryptoCurrency.eth
|
||||
? ethereum!.getEthereumNativeEstimatedFee(_wallet)
|
||||
: ethereum!.getEthereumERC20EstimatedFee(_wallet);
|
||||
|
||||
calculatedFee = ethereum!
|
||||
.formatterEthereumAmountToDouble(amount: BigInt.from(double.parse(fee ?? '0.0')));
|
||||
}
|
||||
|
||||
if (_wallet.type == WalletType.polygon) {
|
||||
String? fee = cryptoCurrencyHandler() == CryptoCurrency.maticpoly
|
||||
? polygon!.getPolygonNativeEstimatedFee(_wallet)
|
||||
: polygon!.getPolygonERC20EstimatedFee(_wallet);
|
||||
|
||||
calculatedFee = polygon!
|
||||
.formatterPolygonAmountToDouble(amount: BigInt.from(double.parse(fee ?? '0.0')));
|
||||
}
|
||||
|
||||
if (_wallet.type == WalletType.base) {
|
||||
String? fee = cryptoCurrencyHandler() == CryptoCurrency.baseEth
|
||||
? base!.getBaseNativeEstimatedFee(_wallet)
|
||||
: base!.getBaseERC20EstimatedFee(_wallet);
|
||||
calculatedFee =
|
||||
base!.formatterBaseAmountToDouble(amount: BigInt.from(double.parse(fee ?? '0.0')));
|
||||
}
|
||||
|
||||
estimatedFee = calculatedFee;
|
||||
}
|
||||
|
||||
if (_wallet.type == WalletType.solana) {
|
||||
estimatedFee = solana!.getEstimateFees(_wallet) ?? 0.0;
|
||||
}
|
||||
|
||||
int? fee = _wallet.calculateEstimatedFee(
|
||||
@@ -225,37 +171,87 @@ abstract class OutputBase with Store {
|
||||
formattedCryptoAmount,
|
||||
);
|
||||
|
||||
if (_wallet.type == WalletType.bitcoin) {
|
||||
if (_settingsStore.priority[_wallet.type] ==
|
||||
bitcoin!.getBitcoinTransactionPriorityCustom()) {
|
||||
fee = bitcoin!.getEstimatedFeeWithFeeRate(
|
||||
_wallet, _settingsStore.customBitcoinFeeRate, formattedCryptoAmount);
|
||||
}
|
||||
switch (_wallet.type) {
|
||||
case WalletType.monero:
|
||||
estimatedFee = monero!.formatterMoneroAmountToDouble(amount: fee);
|
||||
break;
|
||||
case WalletType.bitcoin:
|
||||
if (_settingsStore.priority[_wallet.type] ==
|
||||
bitcoin!.getBitcoinTransactionPriorityCustom()) {
|
||||
fee = bitcoin!.getEstimatedFeeWithFeeRate(
|
||||
_wallet, _settingsStore.customBitcoinFeeRate, formattedCryptoAmount);
|
||||
}
|
||||
|
||||
estimatedFee = bitcoin!.formatterBitcoinAmountToDouble(amount: fee);
|
||||
}
|
||||
estimatedFee = bitcoin!.formatterBitcoinAmountToDouble(amount: fee);
|
||||
break;
|
||||
case WalletType.litecoin:
|
||||
case WalletType.bitcoinCash:
|
||||
case WalletType.dogecoin:
|
||||
estimatedFee = bitcoin!.formatterBitcoinAmountToDouble(amount: fee);
|
||||
break;
|
||||
case WalletType.solana:
|
||||
estimatedFee = solana!.getEstimateFees(_wallet) ?? 0.0;
|
||||
break;
|
||||
case WalletType.wownero:
|
||||
estimatedFee = wownero!.formatterWowneroAmountToDouble(amount: fee);
|
||||
break;
|
||||
case WalletType.zano:
|
||||
estimatedFee = zano!.formatterIntAmountToDouble(
|
||||
amount: fee, currency: cryptoCurrencyHandler(), forFee: true);
|
||||
break;
|
||||
case WalletType.decred:
|
||||
estimatedFee = decred!.formatterDecredAmountToDouble(amount: fee);
|
||||
break;
|
||||
case WalletType.tron:
|
||||
if (cryptoCurrencyHandler() == CryptoCurrency.trx) {
|
||||
final nativeEstimatedFee = tron!.getTronNativeEstimatedFee(_wallet) ?? '0';
|
||||
estimatedFee = double.parse(nativeEstimatedFee);
|
||||
} else {
|
||||
final trc20EstimatedFee = tron!.getTronTRC20EstimatedFee(_wallet) ?? '0';
|
||||
estimatedFee = double.parse(trc20EstimatedFee);
|
||||
}
|
||||
break;
|
||||
|
||||
if (_wallet.type == WalletType.litecoin ||
|
||||
_wallet.type == WalletType.bitcoinCash ||
|
||||
_wallet.type == WalletType.dogecoin) {
|
||||
estimatedFee = bitcoin!.formatterBitcoinAmountToDouble(amount: fee);
|
||||
}
|
||||
/// EVMs
|
||||
case WalletType.ethereum:
|
||||
String? fee = cryptoCurrencyHandler() == CryptoCurrency.eth
|
||||
? ethereum!.getEthereumNativeEstimatedFee(_wallet)
|
||||
: ethereum!.getEthereumERC20EstimatedFee(_wallet);
|
||||
|
||||
if (_wallet.type == WalletType.monero) {
|
||||
estimatedFee = monero!.formatterMoneroAmountToDouble(amount: fee);
|
||||
}
|
||||
estimatedFee = ethereum!
|
||||
.formatterEthereumAmountToDouble(amount: BigInt.from(double.parse(fee ?? '0.0')));
|
||||
break;
|
||||
case WalletType.polygon:
|
||||
String? fee = cryptoCurrencyHandler() == CryptoCurrency.maticpoly
|
||||
? polygon!.getPolygonNativeEstimatedFee(_wallet)
|
||||
: polygon!.getPolygonERC20EstimatedFee(_wallet);
|
||||
|
||||
if (_wallet.type == WalletType.wownero) {
|
||||
estimatedFee = wownero!.formatterWowneroAmountToDouble(amount: fee);
|
||||
}
|
||||
estimatedFee = polygon!
|
||||
.formatterPolygonAmountToDouble(amount: BigInt.from(double.parse(fee ?? '0.0')));
|
||||
break;
|
||||
case WalletType.base:
|
||||
String? fee = cryptoCurrencyHandler() == CryptoCurrency.baseEth
|
||||
? base!.getBaseNativeEstimatedFee(_wallet)
|
||||
: base!.getBaseERC20EstimatedFee(_wallet);
|
||||
estimatedFee =
|
||||
base!.formatterBaseAmountToDouble(amount: BigInt.from(double.parse(fee ?? '0.0')));
|
||||
break;
|
||||
case WalletType.arbitrum:
|
||||
String? fee = cryptoCurrencyHandler() == CryptoCurrency.arbEth
|
||||
? arbitrum!.getArbitrumNativeEstimatedFee(_wallet)
|
||||
: arbitrum!.getArbitrumERC20EstimatedFee(_wallet);
|
||||
|
||||
if (_wallet.type == WalletType.zano) {
|
||||
estimatedFee = zano!.formatterIntAmountToDouble(
|
||||
amount: fee, currency: cryptoCurrencyHandler(), forFee: true);
|
||||
}
|
||||
estimatedFee = arbitrum!
|
||||
.formatterArbitrumAmountToDouble(amount: BigInt.from(double.parse(fee ?? '0.0')));
|
||||
break;
|
||||
/// end EVMs
|
||||
|
||||
if (_wallet.type == WalletType.decred) {
|
||||
estimatedFee = decred!.formatterDecredAmountToDouble(amount: fee);
|
||||
case WalletType.haven:
|
||||
case WalletType.nano:
|
||||
case WalletType.banano:
|
||||
case WalletType.none:
|
||||
// will not reach here as it doesn't have priority and this function is triggered only when priority changes
|
||||
break;
|
||||
}
|
||||
} catch (e) {
|
||||
printV(e.toString());
|
||||
@@ -288,6 +284,7 @@ abstract class OutputBase with Store {
|
||||
final SettingsStore _settingsStore;
|
||||
final FiatConversionStore _fiatConversationStore;
|
||||
final NumberFormat _cryptoNumberFormat;
|
||||
|
||||
@action
|
||||
void setSendAll(String fullBalance) {
|
||||
cryptoFullBalance = fullBalance;
|
||||
|
||||
@@ -10,7 +10,7 @@ case $APP_ANDROID_TYPE in
|
||||
CONFIG_ARGS="--monero"
|
||||
;;
|
||||
$CAKEWALLET)
|
||||
CONFIG_ARGS="--monero --bitcoin --ethereum --polygon --nano --bitcoinCash --solana --tron --wownero --zano --decred --dogecoin --base --arbitrum"
|
||||
CONFIG_ARGS="--monero --bitcoin --ethereum --polygon --nano --bitcoinCash --solana --tron --wownero --zano --decred --dogecoin --base" # --arbitrum
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ case $APP_IOS_TYPE in
|
||||
;;
|
||||
|
||||
$CAKEWALLET)
|
||||
CONFIG_ARGS="--monero --bitcoin --ethereum --polygon --nano --bitcoinCash --solana --tron --wownero --zano --decred --dogecoin --base --arbitrum"
|
||||
CONFIG_ARGS="--monero --bitcoin --ethereum --polygon --nano --bitcoinCash --solana --tron --wownero --zano --decred --dogecoin --base" # --arbitrum
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ CONFIG_ARGS=""
|
||||
|
||||
case $APP_LINUX_TYPE in
|
||||
$CAKEWALLET)
|
||||
CONFIG_ARGS="--monero --bitcoin --ethereum --polygon --nano --bitcoinCash --solana --tron --wownero --dogecoin --base --arbitrum --excludeFlutterSecureStorage";;
|
||||
CONFIG_ARGS="--monero --bitcoin --ethereum --polygon --nano --bitcoinCash --solana --tron --wownero --dogecoin --base --excludeFlutterSecureStorage";; # --arbitrum
|
||||
esac
|
||||
|
||||
cp -rf pubspec_description.yaml pubspec.yaml
|
||||
|
||||
@@ -36,7 +36,7 @@ case $APP_MACOS_TYPE in
|
||||
$MONERO_COM)
|
||||
CONFIG_ARGS="--monero";;
|
||||
$CAKEWALLET)
|
||||
CONFIG_ARGS="--monero --bitcoin --ethereum --polygon --nano --bitcoinCash --solana --tron --wownero --dogecoin --base --arbitrum";;
|
||||
CONFIG_ARGS="--monero --bitcoin --ethereum --polygon --nano --bitcoinCash --solana --tron --wownero --dogecoin --base";; # --arbitrum
|
||||
esac
|
||||
|
||||
cp -rf pubspec_description.yaml pubspec.yaml
|
||||
|
||||
Reference in New Issue
Block a user