mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
fix: Polygon transactions not coming up in transactions history page (#2537)
This commit is contained in:
+83
-73
@@ -14,14 +14,13 @@ class CWPolygon extends Polygon {
|
||||
WalletInfo? walletInfo,
|
||||
String? password,
|
||||
String? passphrase,
|
||||
}) =>
|
||||
EVMChainNewWalletCredentials(
|
||||
name: name,
|
||||
walletInfo: walletInfo,
|
||||
password: password,
|
||||
mnemonic: mnemonic,
|
||||
passphrase: passphrase,
|
||||
);
|
||||
}) => EVMChainNewWalletCredentials(
|
||||
name: name,
|
||||
walletInfo: walletInfo,
|
||||
password: password,
|
||||
mnemonic: mnemonic,
|
||||
passphrase: passphrase,
|
||||
);
|
||||
|
||||
@override
|
||||
WalletCredentials createPolygonRestoreWalletFromSeedCredentials({
|
||||
@@ -29,30 +28,30 @@ class CWPolygon extends Polygon {
|
||||
required String mnemonic,
|
||||
required String password,
|
||||
String? passphrase,
|
||||
}) =>
|
||||
EVMChainRestoreWalletFromSeedCredentials(
|
||||
name: name,
|
||||
password: password,
|
||||
mnemonic: mnemonic,
|
||||
passphrase: passphrase,
|
||||
);
|
||||
}) => EVMChainRestoreWalletFromSeedCredentials(
|
||||
name: name,
|
||||
password: password,
|
||||
mnemonic: mnemonic,
|
||||
passphrase: passphrase,
|
||||
);
|
||||
|
||||
@override
|
||||
WalletCredentials createPolygonRestoreWalletFromPrivateKey({
|
||||
required String name,
|
||||
required String privateKey,
|
||||
required String password,
|
||||
}) =>
|
||||
EVMChainRestoreWalletFromPrivateKey(name: name, password: password, privateKey: privateKey);
|
||||
}) => EVMChainRestoreWalletFromPrivateKey(name: name, password: password, privateKey: privateKey);
|
||||
|
||||
@override
|
||||
WalletCredentials createPolygonHardwareWalletCredentials({
|
||||
required String name,
|
||||
required HardwareAccountData hwAccountData,
|
||||
WalletInfo? walletInfo,
|
||||
}) =>
|
||||
EVMChainRestoreWalletFromHardware(
|
||||
name: name, hwAccountData: hwAccountData, walletInfo: walletInfo);
|
||||
}) => EVMChainRestoreWalletFromHardware(
|
||||
name: name,
|
||||
hwAccountData: hwAccountData,
|
||||
walletInfo: walletInfo,
|
||||
);
|
||||
|
||||
@override
|
||||
String getAddress(WalletBase wallet) => (wallet as PolygonWallet).walletAddresses.address;
|
||||
@@ -88,43 +87,47 @@ class CWPolygon extends Polygon {
|
||||
required TransactionPriority priority,
|
||||
required CryptoCurrency currency,
|
||||
int? feeRate,
|
||||
}) =>
|
||||
EVMChainTransactionCredentials(
|
||||
outputs
|
||||
.map((out) => OutputInfo(
|
||||
fiatAmount: out.fiatAmount,
|
||||
cryptoAmount: out.cryptoAmount,
|
||||
address: out.address,
|
||||
note: out.note,
|
||||
sendAll: out.sendAll,
|
||||
extractedAddress: out.extractedAddress,
|
||||
isParsedAddress: out.isParsedAddress,
|
||||
formattedCryptoAmount: out.formattedCryptoAmount))
|
||||
.toList(),
|
||||
priority: priority as EVMChainTransactionPriority,
|
||||
currency: currency,
|
||||
feeRate: feeRate,
|
||||
);
|
||||
}) => EVMChainTransactionCredentials(
|
||||
outputs
|
||||
.map(
|
||||
(out) => OutputInfo(
|
||||
fiatAmount: out.fiatAmount,
|
||||
cryptoAmount: out.cryptoAmount,
|
||||
address: out.address,
|
||||
note: out.note,
|
||||
sendAll: out.sendAll,
|
||||
extractedAddress: out.extractedAddress,
|
||||
isParsedAddress: out.isParsedAddress,
|
||||
formattedCryptoAmount: out.formattedCryptoAmount,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
priority: priority as EVMChainTransactionPriority,
|
||||
currency: currency,
|
||||
feeRate: feeRate,
|
||||
);
|
||||
|
||||
Object createPolygonTransactionCredentialsRaw(
|
||||
List<OutputInfo> outputs, {
|
||||
TransactionPriority? priority,
|
||||
required CryptoCurrency currency,
|
||||
required int feeRate,
|
||||
}) =>
|
||||
EVMChainTransactionCredentials(
|
||||
outputs,
|
||||
priority: priority as EVMChainTransactionPriority?,
|
||||
currency: currency,
|
||||
feeRate: feeRate,
|
||||
);
|
||||
}) => EVMChainTransactionCredentials(
|
||||
outputs,
|
||||
priority: priority as EVMChainTransactionPriority?,
|
||||
currency: currency,
|
||||
feeRate: feeRate,
|
||||
);
|
||||
|
||||
@override
|
||||
int formatterPolygonParseAmount(String amount) => EVMChainFormatter.parseEVMChainAmount(amount);
|
||||
|
||||
@override
|
||||
double formatterPolygonAmountToDouble(
|
||||
{TransactionInfo? transaction, BigInt? amount, int exponent = 18}) {
|
||||
double formatterPolygonAmountToDouble({
|
||||
TransactionInfo? transaction,
|
||||
BigInt? amount,
|
||||
int exponent = 18,
|
||||
}) {
|
||||
assert(transaction != null || amount != null);
|
||||
|
||||
if (transaction != null) {
|
||||
@@ -148,14 +151,11 @@ class CWPolygon extends Polygon {
|
||||
(wallet as PolygonWallet).deleteErc20Token(token as Erc20Token);
|
||||
|
||||
@override
|
||||
Future<void> removeTokenTransactionsInHistory(
|
||||
WalletBase wallet, CryptoCurrency token) =>
|
||||
(wallet as PolygonWallet)
|
||||
.removeTokenTransactionsInHistory(token as Erc20Token);
|
||||
Future<void> removeTokenTransactionsInHistory(WalletBase wallet, CryptoCurrency token) =>
|
||||
(wallet as PolygonWallet).removeTokenTransactionsInHistory(token as Erc20Token);
|
||||
|
||||
@override
|
||||
Future<Erc20Token?> getErc20Token(
|
||||
WalletBase wallet, String contractAddress) =>
|
||||
Future<Erc20Token?> getErc20Token(WalletBase wallet, String contractAddress) =>
|
||||
(wallet as PolygonWallet).getErc20Token(contractAddress, 'polygon');
|
||||
|
||||
@override
|
||||
@@ -169,7 +169,7 @@ class CWPolygon extends Polygon {
|
||||
wallet as PolygonWallet;
|
||||
|
||||
return wallet.erc20Currencies.firstWhere(
|
||||
(element) => transaction.tokenSymbol.toLowerCase() == element.symbol.toLowerCase(),
|
||||
(element) => transaction.contractAddress?.toLowerCase() == element.contractAddress?.toLowerCase(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -178,30 +178,40 @@ class CWPolygon extends Polygon {
|
||||
(wallet as PolygonWallet).updateScanProviderUsageState(isEnabled);
|
||||
|
||||
@override
|
||||
Web3Client? getWeb3Client(WalletBase wallet) =>
|
||||
(wallet as PolygonWallet).getWeb3Client();
|
||||
Web3Client? getWeb3Client(WalletBase wallet) => (wallet as PolygonWallet).getWeb3Client();
|
||||
|
||||
@override
|
||||
String getTokenAddress(CryptoCurrency asset) =>
|
||||
(asset as Erc20Token).contractAddress;
|
||||
String getTokenAddress(CryptoCurrency asset) => (asset as Erc20Token).contractAddress;
|
||||
|
||||
@override
|
||||
Future<PendingTransaction> createTokenApproval(WalletBase wallet,
|
||||
BigInt amount, String spender, CryptoCurrency token, TransactionPriority priority) =>
|
||||
(wallet as EVMChainWallet)
|
||||
.createApprovalTransaction(amount, spender, token, priority as EVMChainTransactionPriority, "POL");
|
||||
Future<PendingTransaction> createTokenApproval(
|
||||
WalletBase wallet,
|
||||
BigInt amount,
|
||||
String spender,
|
||||
CryptoCurrency token,
|
||||
TransactionPriority priority,
|
||||
) => (wallet as EVMChainWallet).createApprovalTransaction(
|
||||
amount,
|
||||
spender,
|
||||
token,
|
||||
priority as EVMChainTransactionPriority,
|
||||
"POL",
|
||||
);
|
||||
|
||||
@override
|
||||
void setLedgerConnection(
|
||||
WalletBase wallet, ledger.LedgerConnection connection) {
|
||||
((wallet as EVMChainWallet).evmChainPrivateKey as EvmLedgerCredentials)
|
||||
.setLedgerConnection(
|
||||
connection, wallet.walletInfo.derivationInfo?.derivationPath);
|
||||
void setLedgerConnection(WalletBase wallet, ledger.LedgerConnection connection) {
|
||||
((wallet as EVMChainWallet).evmChainPrivateKey as EvmLedgerCredentials).setLedgerConnection(
|
||||
connection,
|
||||
wallet.walletInfo.derivationInfo?.derivationPath,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<HardwareAccountData>> getHardwareWalletAccounts(LedgerViewModel ledgerVM,
|
||||
{int index = 0, int limit = 5}) async {
|
||||
Future<List<HardwareAccountData>> getHardwareWalletAccounts(
|
||||
LedgerViewModel ledgerVM, {
|
||||
int index = 0,
|
||||
int limit = 5,
|
||||
}) async {
|
||||
final hardwareWalletService = EVMChainHardwareWalletService(ledgerVM.connection);
|
||||
try {
|
||||
return await hardwareWalletService.getAvailableAccounts(index: index, limit: limit);
|
||||
@@ -212,14 +222,14 @@ class CWPolygon extends Polygon {
|
||||
}
|
||||
|
||||
@override
|
||||
List<String> getDefaultTokenContractAddresses() => DefaultPolygonErc20Tokens()
|
||||
.initialPolygonErc20Tokens
|
||||
.map((e) => e.contractAddress)
|
||||
.toList();
|
||||
List<String> getDefaultTokenContractAddresses() =>
|
||||
DefaultPolygonErc20Tokens().initialPolygonErc20Tokens.map((e) => e.contractAddress).toList();
|
||||
|
||||
@override
|
||||
bool isTokenAlreadyAdded(WalletBase wallet, String contractAddress) {
|
||||
final polygonWallet = wallet as PolygonWallet;
|
||||
return polygonWallet.erc20Currencies.any((element) => element.contractAddress.toLowerCase() == contractAddress.toLowerCase());
|
||||
return polygonWallet.erc20Currencies.any(
|
||||
(element) => element.contractAddress.toLowerCase() == contractAddress.toLowerCase(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user