import 'package:hash_wallet/evm/evm.dart'; import 'package:hash_wallet/reactions/wallet_connect.dart'; import 'package:hash_wallet/store/app_store.dart'; import 'package:hash_wallet/view_model/send/template_view_model.dart'; import 'package:cw_core/crypto_currency.dart'; import 'package:cw_core/currency_for_wallet_type.dart'; import 'package:cw_core/wallet_type.dart'; import 'package:mobx/mobx.dart'; import 'package:hash_wallet/entities/template.dart'; import 'package:hash_wallet/store/templates/send_template_store.dart'; import 'package:hash_wallet/core/template_validator.dart'; import 'package:hash_wallet/core/address_validator.dart'; import 'package:hash_wallet/core/amount_validator.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:hash_wallet/store/dashboard/fiat_conversion_store.dart'; part 'send_template_view_model.g.dart'; class SendTemplateViewModel = SendTemplateViewModelBase with _$SendTemplateViewModel; abstract class SendTemplateViewModelBase with Store { final WalletBase _wallet; final AppStore _appStore; final SendTemplateStore _sendTemplateStore; final FiatConversionStore _fiatConversationStore; SendTemplateViewModelBase( this._wallet, this._appStore, this._sendTemplateStore, this._fiatConversationStore) : recipients = ObservableList() { addRecipient(); } ObservableList recipients; @action void addRecipient() { recipients.add(TemplateViewModel( wallet: _wallet, appStore: _appStore, fiatConversationStore: _fiatConversationStore)); } @action void removeRecipient(TemplateViewModel recipient) { recipients.remove(recipient); } AmountValidator get amountValidator => AmountValidator( currency: walletTypeToCryptoCurrency(_wallet.type, chainId: _wallet.chainId), amountParsingProxy: _appStore.amountParsingProxy, ); AddressValidator get addressValidator => AddressValidator(type: _wallet.currency, isTestnet: _wallet.isTestnet); TemplateValidator get templateValidator => TemplateValidator(); bool get hasMultiRecipient => !isEVMCompatibleChain(_wallet.type); @computed CryptoCurrency get cryptoCurrency => _wallet.currency; @computed String get fiatCurrency => _appStore.settingsStore.fiatCurrency.title; @computed int get fiatCurrencyDecimals => _appStore.settingsStore.fiatCurrency.decimals; @computed ObservableList