mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-23 06:38:35 +02:00
* feat: Add Binance Smart Chain support to wallet types and EVM chain registry * feat: Add BSC node list and support in wallet type and chain ID mappings * feat: Add BSC default tokens and update evm utility functions * feat: Integrate BSC support in node settings and management * feat: Add BSC support to config scripts and wallet type generation * feat: Add BSC support to EVM chain ID and switcher * feat: Extend BSC support in wallet utilities and chain type checks * feat: Add BSC support to different wallet functions * feat: Add BSCURI class and implement for uri handling * feat: Update Android and iOS configurations to support BSC URL schemes * feat: Add BSC support to different functionalities and settings * refactor: Update wallet type name from'Binance Smart Chain' to BNB Smart Chain * feat: Add switcher icon and updates token utils * Review fixes * More changes to BSC name, wallet listing and images * Add more default tokens
236 lines
6.9 KiB
Dart
236 lines
6.9 KiB
Dart
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
|
import 'package:cake_wallet/entities/auto_generate_subaddress_status.dart';
|
|
import 'package:cake_wallet/entities/exchange_api_mode.dart';
|
|
import 'package:cake_wallet/evm/evm.dart';
|
|
import 'package:cake_wallet/store/settings_store.dart';
|
|
import 'package:cake_wallet/tron/tron.dart';
|
|
import 'package:cake_wallet/reactions/wallet_connect.dart';
|
|
import 'package:cake_wallet/utils/device_info.dart';
|
|
import 'package:cw_core/balance.dart';
|
|
import 'package:cw_core/transaction_history.dart';
|
|
import 'package:cw_core/transaction_info.dart';
|
|
import 'package:cw_core/wallet_base.dart';
|
|
import 'package:cw_core/wallet_type.dart';
|
|
import 'package:mobx/mobx.dart';
|
|
import 'package:cake_wallet/entities/fiat_api_mode.dart';
|
|
|
|
part 'privacy_settings_view_model.g.dart';
|
|
|
|
class PrivacySettingsViewModel = PrivacySettingsViewModelBase with _$PrivacySettingsViewModel;
|
|
|
|
abstract class PrivacySettingsViewModelBase with Store {
|
|
PrivacySettingsViewModelBase(this._settingsStore, this._wallet);
|
|
|
|
final SettingsStore _settingsStore;
|
|
final WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo> _wallet;
|
|
|
|
@computed
|
|
ExchangeApiMode get exchangeStatus => _settingsStore.exchangeStatus;
|
|
|
|
@computed
|
|
bool get isAutoGenerateSubaddressesEnabled =>
|
|
_settingsStore.autoGenerateSubaddressStatus != AutoGenerateSubaddressStatus.disabled;
|
|
|
|
@action
|
|
void setAutoGenerateSubaddresses(bool value) {
|
|
_wallet.isEnabledAutoGenerateSubaddress = value;
|
|
_settingsStore.autoGenerateSubaddressStatus =
|
|
value ? AutoGenerateSubaddressStatus.enabled : AutoGenerateSubaddressStatus.disabled;
|
|
}
|
|
|
|
bool get isAutoGenerateSubaddressesVisible => [
|
|
WalletType.monero,
|
|
WalletType.wownero,
|
|
WalletType.bitcoin,
|
|
WalletType.litecoin,
|
|
WalletType.bitcoinCash,
|
|
WalletType.dogecoin,
|
|
WalletType.decred
|
|
].contains(_wallet.type);
|
|
|
|
bool get isMoneroWallet => _wallet.type == WalletType.monero;
|
|
|
|
@computed
|
|
bool get shouldSaveRecipientAddress => _settingsStore.shouldSaveRecipientAddress;
|
|
|
|
@computed
|
|
FiatApiMode get fiatApiMode => _settingsStore.fiatApiMode;
|
|
|
|
@computed
|
|
bool get isAppSecure => _settingsStore.isAppSecure;
|
|
|
|
@computed
|
|
bool get disableTradeOption => _settingsStore.disableTradeOption;
|
|
|
|
@computed
|
|
bool get disableAutomaticExchangeStatusUpdates =>
|
|
_settingsStore.disableAutomaticExchangeStatusUpdates;
|
|
|
|
@computed
|
|
bool get disableBulletin => _settingsStore.disableBulletin;
|
|
|
|
@computed
|
|
bool get useEtherscan => _settingsStore.useEtherscan;
|
|
|
|
@computed
|
|
bool get usePolygonScan => _settingsStore.usePolygonScan;
|
|
|
|
@computed
|
|
bool get useBaseScan => _settingsStore.useBaseScan;
|
|
|
|
@computed
|
|
bool get useArbiScan => _settingsStore.useArbiScan;
|
|
|
|
@computed
|
|
bool get useBscScan => _settingsStore.useBscScan;
|
|
|
|
@computed
|
|
bool get useTronGrid => _settingsStore.useTronGrid;
|
|
|
|
@computed
|
|
bool get useMempoolFeeAPI => _settingsStore.useMempoolFeeAPI;
|
|
|
|
@computed
|
|
bool get useBlinkProtection => _settingsStore.useBlinkProtection;
|
|
|
|
bool get canUseBlinkProtection => canSupportBlinkProtection(_wallet.chainId);
|
|
|
|
@computed
|
|
bool get lookupTwitter => _settingsStore.lookupsTwitter;
|
|
|
|
@computed
|
|
bool get lookupsZanoAlias => _settingsStore.lookupsZanoAlias;
|
|
|
|
@computed
|
|
bool get looksUpMastodon => _settingsStore.lookupsMastodon;
|
|
|
|
@computed
|
|
bool get looksUpYatService => _settingsStore.lookupsYatService;
|
|
|
|
@computed
|
|
bool get looksUpUnstoppableDomains => _settingsStore.lookupsUnstoppableDomains;
|
|
|
|
@computed
|
|
bool get looksUpOpenAlias => _settingsStore.lookupsOpenAlias;
|
|
|
|
@computed
|
|
bool get looksUpENS => _settingsStore.lookupsENS;
|
|
|
|
@computed
|
|
bool get looksUpWellKnown => _settingsStore.lookupsWellKnown;
|
|
|
|
@computed
|
|
bool get usePayjoin => _settingsStore.usePayjoin;
|
|
|
|
bool get canUseEtherscan => _wallet.chainId == 1;
|
|
|
|
bool get canUsePolygonScan => _wallet.chainId == 137;
|
|
|
|
bool get canUseBaseScan => _wallet.chainId == 8453;
|
|
|
|
bool get canUseArbiScan => _wallet.chainId == 42161;
|
|
|
|
bool get canUseBscScan => _wallet.chainId == 56;
|
|
|
|
bool get canUseTronGrid => _wallet.type == WalletType.tron;
|
|
|
|
bool get canUseMempoolFeeAPI => _wallet.type == WalletType.bitcoin;
|
|
|
|
bool get canUsePayjoin => _wallet.type == WalletType.bitcoin && DeviceInfo.instance.isMobile;
|
|
|
|
@action
|
|
void setShouldSaveRecipientAddress(bool value) =>
|
|
_settingsStore.shouldSaveRecipientAddress = value;
|
|
|
|
@action
|
|
void setExchangeApiMode(ExchangeApiMode value) => _settingsStore.exchangeStatus = value;
|
|
|
|
@action
|
|
void setFiatMode(FiatApiMode fiatApiMode) => _settingsStore.fiatApiMode = fiatApiMode;
|
|
|
|
@action
|
|
void setIsAppSecure(bool value) => _settingsStore.isAppSecure = value;
|
|
|
|
@action
|
|
void setDisableTradeOption(bool value) => _settingsStore.disableTradeOption = value;
|
|
|
|
@action
|
|
void setDisableAutomaticExchangeStatusUpdates(bool value) =>
|
|
_settingsStore.disableAutomaticExchangeStatusUpdates = value;
|
|
|
|
@action
|
|
void setDisableBulletin(bool value) => _settingsStore.disableBulletin = value;
|
|
|
|
@action
|
|
void setLookupsTwitter(bool value) => _settingsStore.lookupsTwitter = value;
|
|
|
|
@action
|
|
void setLookupsZanoAlias(bool value) => _settingsStore.lookupsZanoAlias = value;
|
|
|
|
@action
|
|
void setLookupsMastodon(bool value) => _settingsStore.lookupsMastodon = value;
|
|
|
|
@action
|
|
void setLookupsENS(bool value) => _settingsStore.lookupsENS = value;
|
|
|
|
@action
|
|
void setLookupsWellKnown(bool value) => _settingsStore.lookupsWellKnown = value;
|
|
|
|
@action
|
|
void setLookupsYatService(bool value) => _settingsStore.lookupsYatService = value;
|
|
|
|
@action
|
|
void setLookupsUnstoppableDomains(bool value) => _settingsStore.lookupsUnstoppableDomains = value;
|
|
|
|
@action
|
|
void setLookupsOpenAlias(bool value) => _settingsStore.lookupsOpenAlias = value;
|
|
|
|
@action
|
|
void setUseEtherscan(bool value) {
|
|
_settingsStore.useEtherscan = value;
|
|
evm!.updateScanProviderUsageState(_wallet, value);
|
|
}
|
|
|
|
@action
|
|
void setUsePolygonScan(bool value) {
|
|
_settingsStore.usePolygonScan = value;
|
|
evm!.updateScanProviderUsageState(_wallet, value);
|
|
}
|
|
|
|
@action
|
|
void setUseBaseScan(bool value) {
|
|
_settingsStore.useBaseScan = value;
|
|
evm!.updateScanProviderUsageState(_wallet, value);
|
|
}
|
|
|
|
@action
|
|
void setUseTronGrid(bool value) {
|
|
_settingsStore.useTronGrid = value;
|
|
tron!.updateTronGridUsageState(_wallet, value);
|
|
}
|
|
|
|
@action
|
|
void setUseArbiScan(bool value) {
|
|
_settingsStore.useArbiScan = value;
|
|
evm!.updateScanProviderUsageState(_wallet, value);
|
|
}
|
|
|
|
@action
|
|
void setUseBscScan(bool value) {
|
|
_settingsStore.useBscScan = value;
|
|
evm!.updateScanProviderUsageState(_wallet, value);
|
|
}
|
|
|
|
@action
|
|
void setUseMempoolFeeAPI(bool value) => _settingsStore.useMempoolFeeAPI = value;
|
|
|
|
@action
|
|
void setUseBlinkProtection(bool value) => _settingsStore.useBlinkProtection = value;
|
|
|
|
@action
|
|
void setUsePayjoin(bool value) {
|
|
_settingsStore.usePayjoin = value;
|
|
bitcoin!.updatePayjoinState(_wallet, value);
|
|
}
|
|
}
|