mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-03 12:24:19 +01:00
Cw 1161 add user added tokens to swap currencies (#2455)
* Add user ETH and SOL tokens to exchange currency lists * Update default_spl_tokens.dart * fix solana token icon issue * add user currency to Trade and update usage * add support for user Tron and Polygon tokens in exchange * removing the providersForCurrentPair method and related logic * Improve currency search * prevent crash in EVM wallets for unknown token symbols * Improve asset lookup in XOSwap provider * revert token enabled state for tron solana * Move SPL and Tron token classes to cw_core * fix updating trades for user tokens * Improve token matching by including tag comparison * safer currency parsing across all exchange providers * Update edit_token_page.dart
This commit is contained in:
@@ -125,13 +125,16 @@ class _EditTokenPageBodyState extends State<EditTokenPageBody> {
|
||||
});
|
||||
}
|
||||
|
||||
void _checkIfTokenIsVerified(String? contractAddress) async {
|
||||
if (contractAddress != null) {
|
||||
final isVerified = widget.homeSettingsViewModel.checkIfTokenIsWhitelisted(contractAddress);
|
||||
setState(() {
|
||||
_isTokenVerified = isVerified;
|
||||
});
|
||||
}
|
||||
void _checkIfTokenIsVerified(String? contractAddress) {
|
||||
if (contractAddress == null) return;
|
||||
|
||||
final isVerified =
|
||||
widget.homeSettingsViewModel.checkIfTokenIsWhitelisted(contractAddress);
|
||||
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_isTokenVerified = isVerified;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -253,7 +256,9 @@ class _EditTokenPageBodyState extends State<EditTokenPageBody> {
|
||||
name: _tokenNameController.text,
|
||||
title: _tokenSymbolController.text.toUpperCase(),
|
||||
decimals: int.parse(_tokenDecimalController.text),
|
||||
iconPath: _tokenIconPathController.text,
|
||||
iconPath: _tokenIconPathController.text.isNotEmpty
|
||||
? _tokenIconPathController.text
|
||||
: null,
|
||||
isPotentialScam: isPotentialScam,
|
||||
),
|
||||
contractAddress: _contractAddressController.text,
|
||||
@@ -335,6 +340,8 @@ class _EditTokenPageBodyState extends State<EditTokenPageBody> {
|
||||
if (_contractAddressController.text.isNotEmpty) {
|
||||
final token = await widget.homeSettingsViewModel.getToken(_contractAddressController.text);
|
||||
|
||||
if (!mounted) return;
|
||||
|
||||
if (token != null) {
|
||||
final isZano = widget.homeSettingsViewModel.walletType == WalletType.zano;
|
||||
if (_tokenNameController.text.isEmpty || isZano) _tokenNameController.text = token.name;
|
||||
|
||||
@@ -164,22 +164,28 @@ class TransactionsPage extends StatelessWidget {
|
||||
if (item is TradeListItem) {
|
||||
final trade = item.trade;
|
||||
|
||||
return Observer(
|
||||
builder: (_) => TradeRow(
|
||||
key: item.key,
|
||||
onTap: () => Navigator.of(context)
|
||||
.pushNamed(Routes.tradeDetails, arguments: trade),
|
||||
swapState: trade.state,
|
||||
provider: trade.provider,
|
||||
from: trade.from,
|
||||
to: trade.to,
|
||||
createdAtFormattedDate: trade.createdAt != null
|
||||
? DateFormat('HH:mm').format(trade.createdAt!)
|
||||
: null,
|
||||
formattedAmount: item.tradeFormattedAmount,
|
||||
formattedReceiveAmount: item.tradeFormattedReceiveAmount
|
||||
),
|
||||
);
|
||||
final tradeFrom =
|
||||
trade.fromRaw >= 0 ? trade.from : trade.userCurrencyFrom;
|
||||
|
||||
final tradeTo = trade.toRaw >= 0 ? trade.to : trade.userCurrencyTo;
|
||||
|
||||
return tradeFrom != null && tradeTo != null
|
||||
? Observer(
|
||||
builder: (_) => TradeRow(
|
||||
key: item.key,
|
||||
onTap: () => Navigator.of(context)
|
||||
.pushNamed(Routes.tradeDetails, arguments: trade),
|
||||
swapState: trade.state,
|
||||
provider: trade.provider,
|
||||
from: tradeFrom,
|
||||
to: tradeTo,
|
||||
createdAtFormattedDate: trade.createdAt != null
|
||||
? DateFormat('HH:mm').format(trade.createdAt!)
|
||||
: null,
|
||||
formattedAmount: item.tradeFormattedAmount,
|
||||
formattedReceiveAmount: item.tradeFormattedReceiveAmount),
|
||||
)
|
||||
: Container();
|
||||
}
|
||||
if (item is OrderListItem) {
|
||||
final order = item.order;
|
||||
|
||||
@@ -39,13 +39,11 @@ class CurrencyPickerState extends State<CurrencyPicker> {
|
||||
String textFieldValue;
|
||||
|
||||
bool currencySearchBySubstring(Currency currency, String subString) {
|
||||
return currency.name.toLowerCase().contains(subString.toLowerCase()) ||
|
||||
(currency.tag != null
|
||||
? currency.tag!.toLowerCase().contains(subString.toLowerCase())
|
||||
: false) ||
|
||||
(currency.fullName != null
|
||||
? currency.fullName!.toLowerCase().contains(subString.toLowerCase())
|
||||
: false);
|
||||
final query = subString.toLowerCase();
|
||||
return currency.name.toLowerCase().contains(query) ||
|
||||
currency.toString().toLowerCase().contains(query) ||
|
||||
(currency.tag != null ? currency.tag!.toLowerCase().contains(query) : false) ||
|
||||
(currency.fullName != null ? currency.fullName!.toLowerCase().contains(query) : false);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -76,7 +76,7 @@ class PresentProviderPicker extends StatelessWidget {
|
||||
(e) => CheckBoxItem(
|
||||
e.title,
|
||||
exchangeViewModel.selectedProviders.contains(e),
|
||||
isDisabled: !exchangeViewModel.providersForCurrentPair().contains(e),
|
||||
isDisabled: !exchangeViewModel.providerList.contains(e),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
|
||||
Reference in New Issue
Block a user