mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
6.1.0 fixes (#3190)
* - Fix swap state not maintained (fixed rate can be on or off at the same time) - Fix Pay Anything putting contract address - Pick the token of the URI * fix incorrect function calls [skip ci]
This commit is contained in:
@@ -94,6 +94,9 @@ class SwapTradeExchangeProvider extends ExchangeProvider {
|
||||
}) async {
|
||||
try {
|
||||
if (amount == 0) return 0.0;
|
||||
if (isFixedRateMode && !supportsFixedRate) {
|
||||
return 0.0;
|
||||
}
|
||||
if(from == CryptoCurrency.btcln || to == CryptoCurrency.btcln) return 0;
|
||||
|
||||
final params = <String, dynamic>{};
|
||||
|
||||
@@ -378,11 +378,12 @@ class _NewSwapPageState extends State<NewSwapPage> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
_depositAmountFocus.dispose();
|
||||
_depositAddressFocus.dispose();
|
||||
_receiveAmountFocus.dispose();
|
||||
_receiveAddressFocus.dispose();
|
||||
widget.exchangeViewModel.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _onCurrencyChange(CryptoCurrency currency, ExchangeViewModel exchangeViewModel,
|
||||
|
||||
@@ -169,7 +169,11 @@ class _NewSendAddressInputState extends State<NewSendAddressInput> {
|
||||
|
||||
try {
|
||||
final uri = Uri.parse(code);
|
||||
widget.addressController.text = uri.path;
|
||||
// probably should remove this and let the `onURIScanned` handle it, but for now,
|
||||
// will fix that it takes the token contract address
|
||||
if (!uri.path.contains("/transfer")) {
|
||||
widget.addressController.text = uri.path;
|
||||
}
|
||||
widget.onURIScanned?.call(uri);
|
||||
} catch (_) {
|
||||
widget.addressController.text = code;
|
||||
|
||||
@@ -100,7 +100,7 @@ class ConnectionSyncPage extends BasePage {
|
||||
label: S.of(context).arbiscan_history,
|
||||
value: _connectionSyncViewModel.useArbiScan,
|
||||
onChanged: (val) {
|
||||
_connectionSyncViewModel.setUsePolygonScan(val);
|
||||
_connectionSyncViewModel.setUseArbiScan(val);
|
||||
}),
|
||||
if (_connectionSyncViewModel.canUseBscScan)
|
||||
ListItemToggle(
|
||||
@@ -116,7 +116,7 @@ class ConnectionSyncPage extends BasePage {
|
||||
label: S.of(context).trongrid_history,
|
||||
value: _connectionSyncViewModel.useTronGrid,
|
||||
onChanged: (val) {
|
||||
_connectionSyncViewModel.setUsePolygonScan(val);
|
||||
_connectionSyncViewModel.setUseTronGrid(val);
|
||||
}),
|
||||
if (_connectionSyncViewModel.canUseMempoolFeeAPI)
|
||||
ListItemToggle(
|
||||
|
||||
@@ -15,6 +15,9 @@ import 'package:cake_wallet/wallet_types.g.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:cw_core/currency.dart';
|
||||
import 'package:cw_core/currency_for_wallet_type.dart';
|
||||
import 'package:cw_core/erc20_token.dart';
|
||||
import 'package:cw_core/spl_token.dart';
|
||||
import 'package:cw_core/tron_token.dart';
|
||||
import 'package:cw_core/utils/print_verbose.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -78,7 +81,8 @@ class _TokenSelectionContentState extends State<_TokenSelectionContent> {
|
||||
_autoSelectToken();
|
||||
}
|
||||
|
||||
bool get _isNetworkSelectable => widget.fixedNetwork == null || isEVMCompatibleChain(widget.fixedNetwork!);
|
||||
bool get _isNetworkSelectable =>
|
||||
widget.fixedNetwork == null || isEVMCompatibleChain(widget.fixedNetwork!);
|
||||
|
||||
Future<void> _autoSelectToken() async {
|
||||
if (selectedNetwork == null) return;
|
||||
@@ -102,7 +106,11 @@ class _TokenSelectionContentState extends State<_TokenSelectionContent> {
|
||||
}
|
||||
|
||||
setState(() {
|
||||
selectedToken = tokens.first;
|
||||
selectedToken = tokens.firstWhere((e) {
|
||||
return (e is Erc20Token && e.contractAddress == widget.paymentRequest.contractAddress) ||
|
||||
(e is SPLToken && e.mintAddress == widget.paymentRequest.contractAddress) ||
|
||||
(e is TronToken && e.contractAddress == widget.paymentRequest.contractAddress);
|
||||
}, orElse: () => tokens.first);
|
||||
isLoadingTokens = false;
|
||||
});
|
||||
} catch (e) {
|
||||
|
||||
@@ -304,6 +304,7 @@ class ExceptionHandler {
|
||||
"Image upload failed due to loss of GPU access",
|
||||
"transport error",
|
||||
"SdkError.sparkError(field0: Operator RPC error: Connection error: status: Unavailable, message: \"dns error\", details: []",
|
||||
"the timeout of the request was reached",
|
||||
|
||||
"support for coin removed, your seedphrase:"
|
||||
];
|
||||
|
||||
@@ -82,6 +82,16 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
|
||||
// depositCurrency = wallet.currency;
|
||||
}
|
||||
|
||||
final List<ReactionDisposer> _disposers = [];
|
||||
|
||||
void dispose() {
|
||||
bestRateSync.cancel();
|
||||
for (final disposer in _disposers) {
|
||||
disposer();
|
||||
}
|
||||
_disposers.clear();
|
||||
}
|
||||
|
||||
ExchangeViewModelBase(
|
||||
this._appStore,
|
||||
this.trades,
|
||||
@@ -166,11 +176,11 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
|
||||
depositAddress =
|
||||
useSameWalletAddress(depositCurrency) ? wallet.walletAddresses.addressForExchange : '';
|
||||
|
||||
reaction((_) => receiveAddress, (_) {
|
||||
_disposers.add(reaction((_) => receiveAddress, (_) {
|
||||
if(!(tradeState is TradeIsCreatedSuccessfully)) {
|
||||
receiveAddressDisplayName = null;
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
provider = providerList.firstOrNull;
|
||||
final initialProvider = provider;
|
||||
@@ -184,9 +194,9 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
|
||||
|
||||
// providerDisplay is read by ui to display auto-selected provider.
|
||||
// it's on a delay so it doesn't flicker.
|
||||
reaction((_)=>bestRateProvider,(val) {
|
||||
_disposers.add(reaction((_) => bestRateProvider, (val) {
|
||||
providerDisplay = val;
|
||||
},delay: 300);
|
||||
}, delay: 300));
|
||||
|
||||
receiveCurrencies = CryptoCurrency.all
|
||||
.where((cryptoCurrency) => !excludeReceiveCurrencies.contains(cryptoCurrency))
|
||||
@@ -202,19 +212,19 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
|
||||
_injectUserTronTokensIntoCurrencyLists();
|
||||
_defineIsReceiveAmountEditable();
|
||||
loadLimits();
|
||||
reaction((_) => isFixedRateMode, (Object _) {
|
||||
_disposers.add(reaction((_) => isFixedRateMode, (Object _) {
|
||||
bestRateProvider = null;
|
||||
bestRate = 0.0;
|
||||
loadLimits();
|
||||
});
|
||||
}));
|
||||
|
||||
reaction((_) => forceDecentralizedExchanges, (val) {
|
||||
_disposers.add(reaction((_) => forceDecentralizedExchanges, (val) {
|
||||
if (val && (bestRateProvider?.description.isCentralized ?? false)) {
|
||||
bestRateProvider = null;
|
||||
bestRate = 0.0;
|
||||
loadLimits();
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
if (isElectrumWallet) {
|
||||
bitcoin!.updateFeeRates(wallet);
|
||||
@@ -1071,6 +1081,11 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
|
||||
|
||||
printV('createTrade: trying provider=${provider.title}');
|
||||
|
||||
// should not happen but just as an extra check
|
||||
if (isFixedRateMode && provider.supportsFixedRate == false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip Swaps.xyz when sending from external
|
||||
if (isSendFromExternal &&
|
||||
provider.description == ExchangeProviderDescription.swapsXyz) {
|
||||
|
||||
Reference in New Issue
Block a user