import { BlockchainData } from '@shared/models/blockchain/blockchain-data' ; import { BLOCKCHAIN_NAME } from '@shared/models/blockchain/blockchain-name' ; import { ErrorsService } from '@core/errors/errors.service' ; import { Token } from '@shared/models/tokens/token' ; import { AddEthChainParams } from '@shared/models/blockchain/add-eth-chain-params' ; import { WALLET_NAME } from '@core/wallets/components/wallets-modal/models/wallet-name' ; import { BehaviorSubject } from 'rxjs' ; import { BlockchainsInfo } from '@core/services/blockchain/blockchain-info' ; import { RubicAny } from '@shared/models/utility-types/rubic-any' ; import { BlockchainType } from '@shared/models/blockchain/blockchain-type' ; export abstract class CommonWalletAdapter < T = RubicAny > { protected selectedAddress : string ; protected selectedChain : string ; protected isEnabled : boolean ; public wallet : T = null ; /**
     * is the blockchain provider installed
     */ get isInstalled ( ) : boolean { return Boolean ( this . wallet ) ; } abstract get walletType ( ) : BlockchainType ; /**
     * is the blockchain provider activated
     */ get isActive ( ) : boolean { return this . isEnabled && Boolean ( this . selectedAddress ) ; } /**
     * Is connected app provider supports multi chain wallet.
     */ abstract get isMultiChainWallet ( ) : boolean ; /**
     * Current provider name.
     */ abstract get walletName ( ) : WALLET_NAME ; /**
     * Gets detailed provider name if it's possible. Otherwise returns common name.
     */ get detailedWalletName ( ) : string { return this . walletName ; } return get address ( ) : string { if ( ! this . isActive ) { return null ; } return this . getAddress ( ) ; } return get network ( ) : BlockchainData { if ( ! this . isActive ) { return null ; } return this . getNetwork ( ) ; } return get networkName ( ) : BLOCKCHAIN_NAME { return this . network ?. name ; } protected constructor ( protected readonly errorsService , protected readonly onAddressChanges$ , protected readonly onNetworkChanges$ ) { this . isEnabled = false ; } protected getAddress ( ) { if ( this . isEnabled ) { return this . selectedAddress ; } return null ; } protected getNetwork ( ) { if ( this . isEnabled && this . selectedChain ) { return ( BlockchainsInfo . getBlockchainByName ( this . selectedChain as BLOCKCHAIN_NAME ) || BlockchainsInfo . getBlockchainById ( this . selectedChain ) ) ; } return null ; } public abstract signPersonal ( message ) ; /**
     * activate the blockchain provider
     */ public abstract activate ( ) ; /**
     * deactivate the blockchain provider
     */ public abstract deActivate ( ) ; param token public abstract addToken ( token ) ; public async requestPermissions ( ) { return [ { parentCapability : 'eth_accounts' } ] ; } public abstract switchChain ( chainParams ) ; public abstract addChain ( params ) ; }