mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-24 06:48:38 +02:00
* feat: Integration tests setup and tests for Disclaimer, Welcome and Setup Pin Code pages * feat: Integration test flow from start to restoring a wallet successfully done * test: Dashboard view test and linking to flow * feat: Testing the Exchange flow section, selecting sending and receiving currencies * test: Successfully create an exchange section * feat: Implement flow up to sending section * test: Complete Exchange flow * fix dependency issue * test: Final cleanups * feat: Add CI to run automated integration tests withan android emulator * feat: Adjust Automated integration test CI to run on ubuntu 20.04-a * fix: Move integration test CI into PR test build CI * ci: Add automated test ci which is a streamlined replica of pr test build ci * ci: Re-add step to access branch name * ci: Add KVM * ci: Add filepath to trigger the test run from * ci: Add required key * ci: Add required key * ci: Add missing secret key * ci: Add missing secret key * ci: Add nano secrets to workflow * ci: Switch step to free space on runner * ci: Remove timeout from workflow * ci: Confirm impact that removing copy_monero_deps would have on entire workflow time * ci: Update CI and temporarily remove cache related to emulator * ci: Remove dynamic java version * ci: Temporarily switch CI * ci: Switch to 11.x jdk * ci: Temporarily switch CI * ci: Revert ubuntu version * ci: Add more api levels * ci: Add more target options * ci: Settled on stable emulator matrix options * ci: Add more target options * ci: Modify flow * ci: Streamline api levels to 28 and 29 * ci: One more trial * ci: Switch to flutter drive * ci: Reduce options * ci: Remove haven from test * ci: Check for solana in list * ci: Adjust amounts and currencies for exchange flow * ci: Set write response on failure to true * ci: Split ci to funds and non funds related tests * test: Test for Send flow scenario and minor restructuring for test folders and files * chore: cleanup * ci: Pause CI for now * ci: Pause CI for now * ci: Pause CI for now * test: Restore wallets integration automated tests * Fix: Add keys back to currency amount textfield widget * fix: Switch variable name * fix: remove automation for now * tests: Automated tests for Create wallets flow * tests: Further optimize common flows * tests: Add missing await for call * tests: Confirm Seeds Display Properly WIP * tests: Confirm Seeds Display Correctly Automated Tests * fix: Add missing pubspec params for bitcoin and bitcoin_cash * feat: Automated Tests for Transaction History Flow * fix: Add missing pubspec parameter * feat: Automated Integration Tests for Transaction History flow * test: Updating send page robot and also syncing branch with main * test: Modifying tests to flow with wallet grouping implementation * fix: Issue with transaction history test * fix: Modifications to the PR and add automated confirmation for checking that all wallet types are restored or created correctly * test: Attempting automation for testing * fix: Issue from merge conflicts * test: Remove automation of test in this PR --------- Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
227 lines
7.8 KiB
Dart
227 lines
7.8 KiB
Dart
import 'package:cake_wallet/entities/balance_display_mode.dart';
|
|
import 'package:cake_wallet/entities/fiat_currency.dart';
|
|
import 'package:cake_wallet/ethereum/ethereum.dart';
|
|
import 'package:cake_wallet/generated/i18n.dart';
|
|
import 'package:cake_wallet/nano/nano.dart';
|
|
import 'package:cake_wallet/polygon/polygon.dart';
|
|
import 'package:cake_wallet/reactions/wallet_connect.dart';
|
|
import 'package:cake_wallet/solana/solana.dart';
|
|
import 'package:cake_wallet/tron/tron.dart';
|
|
import 'package:cake_wallet/wownero/wownero.dart';
|
|
import 'package:cw_core/crypto_currency.dart';
|
|
import 'package:cw_core/transaction_direction.dart';
|
|
import 'package:cw_core/transaction_info.dart';
|
|
import 'package:cake_wallet/store/settings_store.dart';
|
|
import 'package:cake_wallet/view_model/dashboard/action_list_item.dart';
|
|
import 'package:cake_wallet/monero/monero.dart';
|
|
import 'package:cake_wallet/haven/haven.dart';
|
|
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
|
import 'package:cake_wallet/entities/calculate_fiat_amount_raw.dart';
|
|
import 'package:cake_wallet/view_model/dashboard/balance_view_model.dart';
|
|
import 'package:cw_core/keyable.dart';
|
|
import 'package:cw_core/wallet_type.dart';
|
|
|
|
class TransactionListItem extends ActionListItem with Keyable {
|
|
TransactionListItem({
|
|
required this.transaction,
|
|
required this.balanceViewModel,
|
|
required this.settingsStore,
|
|
required super.key,
|
|
});
|
|
|
|
final TransactionInfo transaction;
|
|
final BalanceViewModel balanceViewModel;
|
|
final SettingsStore settingsStore;
|
|
|
|
double get price => balanceViewModel.price;
|
|
|
|
FiatCurrency get fiatCurrency => settingsStore.fiatCurrency;
|
|
|
|
BalanceDisplayMode get displayMode => balanceViewModel.displayMode;
|
|
|
|
@override
|
|
dynamic get keyIndex => transaction.id;
|
|
|
|
bool get hasTokens =>
|
|
isEVMCompatibleChain(balanceViewModel.wallet.type) ||
|
|
balanceViewModel.wallet.type == WalletType.solana ||
|
|
balanceViewModel.wallet.type == WalletType.tron;
|
|
|
|
String get formattedCryptoAmount {
|
|
return displayMode == BalanceDisplayMode.hiddenBalance ? '---' : transaction.amountFormatted();
|
|
}
|
|
|
|
String get formattedTitle {
|
|
if (transaction.direction == TransactionDirection.incoming) {
|
|
return S.current.received;
|
|
}
|
|
|
|
return S.current.sent;
|
|
}
|
|
|
|
String get formattedPendingStatus {
|
|
switch (balanceViewModel.wallet.type) {
|
|
case WalletType.monero:
|
|
case WalletType.haven:
|
|
if (transaction.confirmations >= 0 && transaction.confirmations < 10) {
|
|
return ' (${transaction.confirmations}/10)';
|
|
}
|
|
break;
|
|
case WalletType.wownero:
|
|
if (transaction.confirmations >= 0 && transaction.confirmations < 3) {
|
|
return ' (${transaction.confirmations}/3)';
|
|
}
|
|
break;
|
|
case WalletType.litecoin:
|
|
bool isPegIn = (transaction.additionalInfo["isPegIn"] as bool?) ?? false;
|
|
bool isPegOut = (transaction.additionalInfo["isPegOut"] as bool?) ?? false;
|
|
bool fromPegOut = (transaction.additionalInfo["fromPegOut"] as bool?) ?? false;
|
|
String str = '';
|
|
if (transaction.confirmations <= 0) {
|
|
str = S.current.pending;
|
|
}
|
|
if ((isPegOut || fromPegOut) && transaction.confirmations >= 0 && transaction.confirmations < 6) {
|
|
str = " (${transaction.confirmations}/6)";
|
|
}
|
|
if (isPegIn) {
|
|
str += " (Peg In)";
|
|
}
|
|
if (isPegOut) {
|
|
str += " (Peg Out)";
|
|
}
|
|
return str;
|
|
default:
|
|
return '';
|
|
}
|
|
|
|
return '';
|
|
}
|
|
|
|
String get formattedStatus {
|
|
if ([
|
|
WalletType.monero,
|
|
WalletType.haven,
|
|
WalletType.wownero,
|
|
WalletType.litecoin,
|
|
].contains(balanceViewModel.wallet.type)) {
|
|
return formattedPendingStatus;
|
|
}
|
|
|
|
return transaction.isPending ? S.current.pending : '';
|
|
}
|
|
|
|
String get formattedType {
|
|
if (transaction.evmSignatureName == 'approval') {
|
|
return ' (${transaction.evmSignatureName})';
|
|
}
|
|
return '';
|
|
}
|
|
|
|
CryptoCurrency? get assetOfTransaction {
|
|
try {
|
|
if (balanceViewModel.wallet.type == WalletType.ethereum) {
|
|
final asset = ethereum!.assetOfTransaction(balanceViewModel.wallet, transaction);
|
|
return asset;
|
|
}
|
|
|
|
if (balanceViewModel.wallet.type == WalletType.polygon) {
|
|
final asset = polygon!.assetOfTransaction(balanceViewModel.wallet, transaction);
|
|
return asset;
|
|
}
|
|
|
|
if (balanceViewModel.wallet.type == WalletType.solana) {
|
|
final asset = solana!.assetOfTransaction(balanceViewModel.wallet, transaction);
|
|
return asset;
|
|
}
|
|
|
|
if (balanceViewModel.wallet.type == WalletType.tron) {
|
|
final asset = tron!.assetOfTransaction(balanceViewModel.wallet, transaction);
|
|
return asset;
|
|
}
|
|
} catch (e) {
|
|
return null;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
String get formattedFiatAmount {
|
|
var amount = '';
|
|
|
|
switch (balanceViewModel.wallet.type) {
|
|
case WalletType.monero:
|
|
amount = calculateFiatAmountRaw(
|
|
cryptoAmount: monero!.formatterMoneroAmountToDouble(amount: transaction.amount),
|
|
price: price);
|
|
break;
|
|
case WalletType.wownero:
|
|
amount = calculateFiatAmountRaw(
|
|
cryptoAmount: wownero!.formatterWowneroAmountToDouble(amount: transaction.amount),
|
|
price: price);
|
|
break;
|
|
case WalletType.bitcoin:
|
|
case WalletType.litecoin:
|
|
case WalletType.bitcoinCash:
|
|
amount = calculateFiatAmountRaw(
|
|
cryptoAmount: bitcoin!.formatterBitcoinAmountToDouble(amount: transaction.amount),
|
|
price: price);
|
|
break;
|
|
case WalletType.haven:
|
|
final asset = haven!.assetOfTransaction(transaction);
|
|
final price = balanceViewModel.fiatConvertationStore.prices[asset];
|
|
amount = calculateFiatAmountRaw(
|
|
cryptoAmount: haven!.formatterMoneroAmountToDouble(amount: transaction.amount),
|
|
price: price);
|
|
break;
|
|
case WalletType.ethereum:
|
|
final asset = ethereum!.assetOfTransaction(balanceViewModel.wallet, transaction);
|
|
final price = balanceViewModel.fiatConvertationStore.prices[asset];
|
|
amount = calculateFiatAmountRaw(
|
|
cryptoAmount: ethereum!.formatterEthereumAmountToDouble(transaction: transaction),
|
|
price: price);
|
|
break;
|
|
case WalletType.polygon:
|
|
final asset = polygon!.assetOfTransaction(balanceViewModel.wallet, transaction);
|
|
final price = balanceViewModel.fiatConvertationStore.prices[asset];
|
|
amount = calculateFiatAmountRaw(
|
|
cryptoAmount: polygon!.formatterPolygonAmountToDouble(transaction: transaction),
|
|
price: price);
|
|
break;
|
|
case WalletType.nano:
|
|
amount = calculateFiatAmountRaw(
|
|
cryptoAmount: double.parse(nanoUtil!.getRawAsUsableString(
|
|
nano!.getTransactionAmountRaw(transaction).toString(), nanoUtil!.rawPerNano)),
|
|
price: price);
|
|
break;
|
|
case WalletType.solana:
|
|
final asset = solana!.assetOfTransaction(balanceViewModel.wallet, transaction);
|
|
final price = balanceViewModel.fiatConvertationStore.prices[asset];
|
|
amount = calculateFiatAmountRaw(
|
|
cryptoAmount: solana!.getTransactionAmountRaw(transaction),
|
|
price: price,
|
|
);
|
|
break;
|
|
|
|
case WalletType.tron:
|
|
final asset = tron!.assetOfTransaction(balanceViewModel.wallet, transaction);
|
|
final price = balanceViewModel.fiatConvertationStore.prices[asset];
|
|
final cryptoAmount = tron!.getTransactionAmountRaw(transaction);
|
|
amount = calculateFiatAmountRaw(
|
|
cryptoAmount: cryptoAmount,
|
|
price: price,
|
|
);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
transaction.changeFiatAmount(amount);
|
|
return displayMode == BalanceDisplayMode.hiddenBalance
|
|
? '---'
|
|
: fiatCurrency.title + ' ' + transaction.fiatAmount();
|
|
}
|
|
|
|
@override
|
|
DateTime get date => transaction.date;
|
|
}
|