Fix sending erc20

fix block explorer issue
This commit is contained in:
OmarHatem 2023-07-21 21:28:56 +03:00
parent 680359e6f1
commit 2e0b02766e
3 changed files with 19 additions and 9 deletions

View file

@ -175,6 +175,9 @@ abstract class EthereumWalletBase
gas: _priorityFees[_credentials.priority!.raw], gas: _priorityFees[_credentials.priority!.raw],
priority: _credentials.priority!, priority: _credentials.priority!,
currency: _credentials.currency, currency: _credentials.currency,
contractAddress: _credentials.currency is Erc20Token
? (_credentials.currency as Erc20Token).contractAddress
: null,
); );
return pendingEthereumTransaction; return pendingEthereumTransaction;

View file

@ -2,6 +2,7 @@ import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/core/validator.dart'; import 'package:cake_wallet/core/validator.dart';
import 'package:cw_core/crypto_currency.dart'; import 'package:cw_core/crypto_currency.dart';
import 'package:cw_core/erc20_token.dart';
class AddressValidator extends TextValidator { class AddressValidator extends TextValidator {
AddressValidator({required CryptoCurrency type}) AddressValidator({required CryptoCurrency type})
@ -14,6 +15,9 @@ class AddressValidator extends TextValidator {
length: getLength(type)); length: getLength(type));
static String getPattern(CryptoCurrency type) { static String getPattern(CryptoCurrency type) {
if (type is Erc20Token) {
return '0x[0-9a-zA-Z]';
}
switch (type) { switch (type) {
case CryptoCurrency.xmr: case CryptoCurrency.xmr:
return '^4[0-9a-zA-Z]{94}\$|^8[0-9a-zA-Z]{94}\$|^[0-9a-zA-Z]{106}\$'; return '^4[0-9a-zA-Z]{94}\$|^8[0-9a-zA-Z]{94}\$|^[0-9a-zA-Z]{106}\$';
@ -117,17 +121,14 @@ class AddressValidator extends TextValidator {
} }
static List<int>? getLength(CryptoCurrency type) { static List<int>? getLength(CryptoCurrency type) {
if (type is Erc20Token) {
return [42];
}
switch (type) { switch (type) {
case CryptoCurrency.xmr: case CryptoCurrency.xmr:
return null; return null;
case CryptoCurrency.ada: case CryptoCurrency.ada:
return null; return null;
case CryptoCurrency.avaxc:
return [42];
case CryptoCurrency.bch:
return [42];
case CryptoCurrency.bnb:
return [42];
case CryptoCurrency.btc: case CryptoCurrency.btc:
return null; return null;
case CryptoCurrency.dash: case CryptoCurrency.dash:
@ -168,6 +169,9 @@ class AddressValidator extends TextValidator {
case CryptoCurrency.dydx: case CryptoCurrency.dydx:
case CryptoCurrency.steth: case CryptoCurrency.steth:
case CryptoCurrency.shib: case CryptoCurrency.shib:
case CryptoCurrency.avaxc:
case CryptoCurrency.bch:
case CryptoCurrency.bnb:
return [42]; return [42];
case CryptoCurrency.ltc: case CryptoCurrency.ltc:
return [34, 43, 63]; return [34, 43, 63];
@ -205,11 +209,8 @@ class AddressValidator extends TextValidator {
case CryptoCurrency.xusd: case CryptoCurrency.xusd:
return [98, 99, 106]; return [98, 99, 106];
case CryptoCurrency.btt: case CryptoCurrency.btt:
return [34];
case CryptoCurrency.bttc: case CryptoCurrency.bttc:
return [34];
case CryptoCurrency.doge: case CryptoCurrency.doge:
return [34];
case CryptoCurrency.firo: case CryptoCurrency.firo:
return [34]; return [34];
case CryptoCurrency.hbar: case CryptoCurrency.hbar:
@ -260,6 +261,8 @@ class AddressValidator extends TextValidator {
return '([^0-9a-zA-Z]|^)^L[a-zA-Z0-9]{26,33}([^0-9a-zA-Z]|\$)' return '([^0-9a-zA-Z]|^)^L[a-zA-Z0-9]{26,33}([^0-9a-zA-Z]|\$)'
'|([^0-9a-zA-Z]|^)[LM][a-km-zA-HJ-NP-Z1-9]{26,33}([^0-9a-zA-Z]|\$)' '|([^0-9a-zA-Z]|^)[LM][a-km-zA-HJ-NP-Z1-9]{26,33}([^0-9a-zA-Z]|\$)'
'|([^0-9a-zA-Z]|^)ltc[a-zA-Z0-9]{26,45}([^0-9a-zA-Z]|\$)'; '|([^0-9a-zA-Z]|^)ltc[a-zA-Z0-9]{26,45}([^0-9a-zA-Z]|\$)';
case CryptoCurrency.eth:
return '0x[0-9a-zA-Z]{42}';
default: default:
return null; return null;
} }

View file

@ -114,6 +114,8 @@ abstract class TransactionDetailsViewModelBase with Store {
return 'https://blockchair.com/litecoin/transaction/${txId}'; return 'https://blockchair.com/litecoin/transaction/${txId}';
case WalletType.haven: case WalletType.haven:
return 'https://explorer.havenprotocol.org/search?value=${txId}'; return 'https://explorer.havenprotocol.org/search?value=${txId}';
case WalletType.ethereum:
return 'https://etherscan.io/tx/${txId}';
default: default:
return ''; return '';
} }
@ -129,6 +131,8 @@ abstract class TransactionDetailsViewModelBase with Store {
return S.current.view_transaction_on + 'Blockchair.com'; return S.current.view_transaction_on + 'Blockchair.com';
case WalletType.haven: case WalletType.haven:
return S.current.view_transaction_on + 'explorer.havenprotocol.org'; return S.current.view_transaction_on + 'explorer.havenprotocol.org';
case WalletType.ethereum:
return S.current.view_transaction_on + 'etherscan.io';
default: default:
return ''; return '';
} }