mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-10-30 17:07:53 +00:00
b3d579c24a
* chore: Initial setup for polygon package * feat: Add polygon node urls * feat: Add Polygon(MATIC) wallet WIP * feat: Add Polygon(MATIC) wallet WIP * feat: Add Polygon MATIC wallet [skip ci] * fix: Issue with create/restore wallet for polygon * feat: Add erc20 tokens for polygon * feat: Adding Polygon MATIC Wallet * fix: Add build command for polygon to workflow file to fix failing action * fix: Switch evm to not display additional balance * chore: Sync with remote * fix: Revert change to inject app script * feat: Add polygon erc20 tokens * feat: Increase migration version * fix: Restore from QR address validator fix * fix: Adjust wallet connect connection flow to adapt to wallet type * fix: Make wallet fetch nfts based on the current wallet type * fix: Make wallet fetch nfts based on the current wallet type * fix: Try fetching transactions with moralis * fix: Requested review changes * fix: Error creating new wallet * fix: Revert script * fix: Exclude spam NFTs from nft listing API response * Update default_erc20_tokens.dart * replace matic with matic poly * Add polygon wallet scheme to app links * style: reformat default_settings_migration.dart * minor enhancement * fix using different wallet function for setting the transaction priorities * fix: Add chain to calls * Add USDC.e to initial coins * Add other default polygon node * Use Polygon scan some UI fixes * Add polygon scan api key to secrets generation code --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
98 lines
3.1 KiB
Dart
98 lines
3.1 KiB
Dart
import 'package:cake_wallet/view_model/send/template_view_model.dart';
|
|
import 'package:cw_core/crypto_currency.dart';
|
|
import 'package:cw_core/wallet_type.dart';
|
|
import 'package:mobx/mobx.dart';
|
|
import 'package:cake_wallet/entities/template.dart';
|
|
import 'package:cake_wallet/store/templates/send_template_store.dart';
|
|
import 'package:cake_wallet/core/template_validator.dart';
|
|
import 'package:cake_wallet/core/address_validator.dart';
|
|
import 'package:cake_wallet/core/amount_validator.dart';
|
|
import 'package:cw_core/wallet_base.dart';
|
|
import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart';
|
|
import 'package:cake_wallet/store/settings_store.dart';
|
|
|
|
part 'send_template_view_model.g.dart';
|
|
|
|
class SendTemplateViewModel = SendTemplateViewModelBase with _$SendTemplateViewModel;
|
|
|
|
abstract class SendTemplateViewModelBase with Store {
|
|
final WalletBase _wallet;
|
|
final SettingsStore _settingsStore;
|
|
final SendTemplateStore _sendTemplateStore;
|
|
final FiatConversionStore _fiatConversationStore;
|
|
|
|
SendTemplateViewModelBase(
|
|
this._wallet, this._settingsStore, this._sendTemplateStore, this._fiatConversationStore)
|
|
: recipients = ObservableList<TemplateViewModel>() {
|
|
addRecipient();
|
|
}
|
|
|
|
ObservableList<TemplateViewModel> recipients;
|
|
|
|
@action
|
|
void addRecipient() {
|
|
recipients.add(TemplateViewModel(
|
|
wallet: _wallet,
|
|
settingsStore: _settingsStore,
|
|
fiatConversationStore: _fiatConversationStore));
|
|
}
|
|
|
|
@action
|
|
void removeRecipient(TemplateViewModel recipient) {
|
|
recipients.remove(recipient);
|
|
}
|
|
|
|
AmountValidator get amountValidator =>
|
|
AmountValidator(currency: walletTypeToCryptoCurrency(_wallet.type));
|
|
|
|
AddressValidator get addressValidator => AddressValidator(type: _wallet.currency);
|
|
|
|
TemplateValidator get templateValidator => TemplateValidator();
|
|
|
|
bool get hasMultiRecipient =>
|
|
_wallet.type != WalletType.haven &&
|
|
_wallet.type != WalletType.ethereum &&
|
|
_wallet.type != WalletType.polygon;
|
|
|
|
@computed
|
|
CryptoCurrency get cryptoCurrency => _wallet.currency;
|
|
|
|
@computed
|
|
String get fiatCurrency => _settingsStore.fiatCurrency.title;
|
|
|
|
@computed
|
|
ObservableList<Template> get templates => _sendTemplateStore.templates;
|
|
|
|
@action
|
|
void updateTemplate() => _sendTemplateStore.update();
|
|
|
|
@action
|
|
void addTemplate(
|
|
{required String name,
|
|
required bool isCurrencySelected,
|
|
required String cryptoCurrency,
|
|
required String address,
|
|
required String amount,
|
|
required String amountFiat,
|
|
required List<Template> additionalRecipients}) {
|
|
_sendTemplateStore.addTemplate(
|
|
name: name,
|
|
isCurrencySelected: isCurrencySelected,
|
|
address: address,
|
|
cryptoCurrency: cryptoCurrency,
|
|
fiatCurrency: fiatCurrency,
|
|
amount: amount,
|
|
amountFiat: amountFiat,
|
|
additionalRecipients: additionalRecipients);
|
|
updateTemplate();
|
|
}
|
|
|
|
@action
|
|
void removeTemplate({required Template template}) {
|
|
_sendTemplateStore.remove(template: template);
|
|
updateTemplate();
|
|
}
|
|
|
|
@computed
|
|
List<CryptoCurrency> get walletCurrencies => _wallet.balance.keys.toList();
|
|
}
|