mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-01 12:04:21 +01:00
feat: show gas conversion rate for dEURO savings (#2351)
* feat: show gas currency on EVM chains * feat: show gas conversion rate for dEURO savings * Update lib/polygon/cw_polygon.dart [skip ci] * Update cw_evm/lib/evm_chain_wallet.dart [skip ci] --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
+6
-1
@@ -1518,7 +1518,12 @@ Future<void> setup({
|
||||
|
||||
getIt.registerFactory(() => StartTorPage(StartTorViewModel(),));
|
||||
|
||||
getIt.registerFactory(() => DEuroViewModel(getIt<AppStore>()));
|
||||
getIt.registerFactory(() => DEuroViewModel(
|
||||
getIt<AppStore>(),
|
||||
getIt<BalanceViewModel>(),
|
||||
getIt<SettingsStore>(),
|
||||
getIt<FiatConversionStore>(),
|
||||
));
|
||||
|
||||
getIt.registerFactory(() => DEuroSavingsPage(getIt<DEuroViewModel>()));
|
||||
|
||||
|
||||
@@ -213,7 +213,7 @@ class CWEthereum extends Ethereum {
|
||||
Future<PendingTransaction> createTokenApproval(WalletBase wallet, BigInt amount, String spender,
|
||||
CryptoCurrency token, TransactionPriority priority) =>
|
||||
(wallet as EVMChainWallet).createApprovalTransaction(
|
||||
amount, spender, token, priority as EVMChainTransactionPriority);
|
||||
amount, spender, token, priority as EVMChainTransactionPriority, "ETH");
|
||||
|
||||
// Integrations
|
||||
@override
|
||||
|
||||
@@ -189,7 +189,7 @@ class CWPolygon extends Polygon {
|
||||
Future<PendingTransaction> createTokenApproval(WalletBase wallet,
|
||||
BigInt amount, String spender, CryptoCurrency token, TransactionPriority priority) =>
|
||||
(wallet as EVMChainWallet)
|
||||
.createApprovalTransaction(amount, spender, token, priority as EVMChainTransactionPriority);
|
||||
.createApprovalTransaction(amount, spender, token, priority as EVMChainTransactionPriority, "POL");
|
||||
|
||||
@override
|
||||
void setLedgerConnection(
|
||||
|
||||
@@ -125,10 +125,10 @@ class DEuroSavingsPage extends BasePage {
|
||||
currency: CryptoCurrency.deuro,
|
||||
amount: S.of(bottomSheetContext).send_amount,
|
||||
amountValue: tx.amountFormatted,
|
||||
fiatAmountValue: "",
|
||||
fiatAmountValue: _dEuroViewModel.pendingTransactionFiatAmountFormatted,
|
||||
fee: S.of(bottomSheetContext).send_estimated_fee,
|
||||
feeValue: tx.feeFormatted,
|
||||
feeFiatAmount: "",
|
||||
feeFiatAmount: _dEuroViewModel.pendingTransactionFeeFiatAmountFormatted,
|
||||
outputs: [],
|
||||
onSlideComplete: () async {
|
||||
Navigator.of(bottomSheetContext).pop(true);
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
import 'package:cake_wallet/core/execution_state.dart';
|
||||
import 'package:cake_wallet/entities/calculate_fiat_amount.dart';
|
||||
import 'package:cake_wallet/entities/fiat_currency.dart';
|
||||
import 'package:cake_wallet/ethereum/ethereum.dart';
|
||||
import 'package:cake_wallet/store/app_store.dart';
|
||||
import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:cake_wallet/view_model/dashboard/balance_view_model.dart';
|
||||
import 'package:cake_wallet/view_model/send/send_view_model_state.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:cw_core/pending_transaction.dart';
|
||||
import 'package:cw_core/utils/print_verbose.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:cw_core/parse_fixed.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
@@ -14,10 +21,69 @@ class DEuroViewModel = DEuroViewModelBase with _$DEuroViewModel;
|
||||
abstract class DEuroViewModelBase with Store {
|
||||
final AppStore _appStore;
|
||||
|
||||
DEuroViewModelBase(this._appStore) {
|
||||
DEuroViewModelBase(this._appStore, this.balanceViewModel, this._settingsStore, this._fiatConversationStore) {
|
||||
reloadInterestRate();
|
||||
reloadSavingsUserData();
|
||||
}
|
||||
final BalanceViewModel balanceViewModel;
|
||||
final SettingsStore _settingsStore;
|
||||
final FiatConversionStore _fiatConversationStore;
|
||||
|
||||
@computed
|
||||
bool get isFiatDisabled => balanceViewModel.isFiatDisabled;
|
||||
|
||||
@computed
|
||||
String get pendingTransactionFiatAmountFormatted =>
|
||||
isFiatDisabled ? '' : pendingTransactionFiatAmount + ' ' + fiat.title;
|
||||
|
||||
@computed
|
||||
String get pendingTransactionFeeFiatAmountFormatted =>
|
||||
isFiatDisabled ? '' : pendingTransactionFeeFiatAmount + ' ' + fiat.title;
|
||||
|
||||
FiatCurrency get fiat => _settingsStore.fiatCurrency;
|
||||
|
||||
|
||||
@computed
|
||||
String get pendingTransactionFiatAmount {
|
||||
if (transaction == null) {
|
||||
return '0.00';
|
||||
}
|
||||
|
||||
try {
|
||||
final keys = _fiatConversationStore.prices.keys.toList();
|
||||
CryptoCurrency deuro = CryptoCurrency.deuro;
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
if (keys[i].title == "DEURO") {
|
||||
deuro = keys[i];
|
||||
}
|
||||
}
|
||||
final fiat = calculateFiatAmount(
|
||||
price: _fiatConversationStore.prices[deuro]!,
|
||||
cryptoAmount: transaction!.amountFormatted);
|
||||
return fiat;
|
||||
} catch (e) {
|
||||
printV(e);
|
||||
return '0.02';
|
||||
}
|
||||
}
|
||||
|
||||
@computed
|
||||
String get pendingTransactionFeeFiatAmount {
|
||||
try {
|
||||
if (transaction != null) {
|
||||
final currency = CryptoCurrency.eth;
|
||||
final fiat = calculateFiatAmount(
|
||||
price: _fiatConversationStore.prices[currency]!,
|
||||
cryptoAmount: transaction!.feeFormatted.substring(0, transaction!.feeFormatted.indexOf(" ")),
|
||||
);
|
||||
return fiat;
|
||||
} else {
|
||||
return '0.00';
|
||||
}
|
||||
} catch (_) {
|
||||
return '0.00';
|
||||
}
|
||||
}
|
||||
|
||||
@observable
|
||||
String savingsBalance = '0.00';
|
||||
|
||||
@@ -183,7 +183,8 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
final currency = pendingTransactionFeeCurrency(walletType);
|
||||
final fiat = calculateFiatAmount(
|
||||
price: _fiatConversationStore.prices[currency]!,
|
||||
cryptoAmount: pendingTransaction!.feeFormatted);
|
||||
cryptoAmount: pendingTransaction!.feeFormatted.substring(0, pendingTransaction!.feeFormatted.indexOf(" ")),
|
||||
);
|
||||
return fiat;
|
||||
} else {
|
||||
return '0.00';
|
||||
|
||||
Reference in New Issue
Block a user