import { KVStore } from "@keplr-wallet/common"; import { BitcoinChainInfo, ChainInfo, ChainInfoWithoutEndpoints, EVMInfo, ModularChainInfo, StarknetChainInfo } from "@keplr-wallet/types"; import { InteractionService } from "../interaction"; import { Env } from "@keplr-wallet/router"; import { ChainInfoWithCoreTypes, ChainInfoWithSuggestedOptions } from "./types"; import { AnalyticsService } from "../analytics"; type ChainRemovedHandler = (chainId: string) => void; type ChainSuggestedHandler = (chainInfo: ChainInfo, options?: Record) => void | Promise; type UpdatedChainInfo = Pick; export declare class ChainsService { protected readonly kvStore: KVStore; protected readonly migrationKVStore: { kvStore: KVStore; updaterKVStore: KVStore; }; protected readonly suggestChainPrivilegedOrigins: string[]; protected readonly communityChainInfoRepo: { readonly organizationName: string; readonly repoName: string; readonly branchName: string; readonly alternativeURL?: string; }; protected readonly analyticsService: AnalyticsService; protected readonly interactionService: InteractionService; protected readonly afterInitFn: ((service: ChainsService, lastEmbedChainInfos: ChainInfoWithCoreTypes[]) => void | Promise) | undefined; static getEVMInfo(chainInfo: ChainInfo): EVMInfo | undefined; protected embedChainInfos: ReadonlyArray; protected modularChainInfos: ReadonlyArray; protected updatedChainInfos: UpdatedChainInfo[]; protected updatedChainInfoKVStore: KVStore; protected suggestedChainInfos: ChainInfoWithSuggestedOptions[]; protected suggestedChainInfoKVStore: KVStore; protected repoChainInfos: ChainInfo[]; protected repoChainInfoKVStore: KVStore; protected endpoints: { chainId: string; rpc?: string; rest?: string; evmRpc?: string; }[]; protected endpointsKVStore: KVStore; protected onChainRemovedHandlers: ChainRemovedHandler[]; protected onChainSuggestedHandlers: ChainSuggestedHandler[]; constructor(kvStore: KVStore, migrationKVStore: { kvStore: KVStore; updaterKVStore: KVStore; }, embedModularChainInfos: ReadonlyArray, suggestChainPrivilegedOrigins: string[], communityChainInfoRepo: { readonly organizationName: string; readonly repoName: string; readonly branchName: string; readonly alternativeURL?: string; }, analyticsService: AnalyticsService, interactionService: InteractionService, afterInitFn: ((service: ChainsService, lastEmbedChainInfos: ChainInfoWithCoreTypes[]) => void | Promise) | undefined); init(): Promise; /** * 이 서비스 자체를 포함한 다른 모든 서비스들이 init된 이후에 실행된다. (message를 받을 수 있는 상태 직전) * 모든 서비스가 init이 된 이후에 실행될 추가적인 로직을 여기에 작성할 수 있다. */ afterInit(): Promise; getChainInfos: () => ChainInfo[]; getChainInfosWithoutEndpoints: () => ChainInfoWithoutEndpoints[]; getChainInfoWithoutEndpoints: (chainId: string) => ChainInfoWithoutEndpoints | undefined; getChainInfo: (chainId: string) => ChainInfo | undefined; getChainInfoByEVMChainId: (evmChainId: number) => ChainInfo | undefined; getChainInfoByEVMChainIdOrThrow: (evmChainId: number) => ChainInfo; hasChainInfo(chainId: string): boolean; getChainInfoOrThrow(chainId: string): ChainInfo; getChainInfosWithCoreTypes: () => ChainInfoWithCoreTypes[]; getChainInfoWithCoreTypes: (chainId: string) => ChainInfoWithCoreTypes | undefined; tryUpdateChainInfoFromRepo(chainId: string): Promise; protected fetchFromRepo(chainId: string, isEvmOnlyChain: boolean): Promise; tryUpdateChainInfoFromRpcOrRest(chainId: string): Promise; protected setUpdatedChainInfo(chainId: string, chainInfo: Partial>): void; needSuggestChainInfoInteraction(origin: string): Promise; suggestChainInfo(env: Env, chainInfo: ChainInfo, origin: string): Promise; addSuggestedChainInfo(chainInfo: ChainInfoWithSuggestedOptions, handlerOptions?: Record, notInvokeHandlers?: boolean): Promise; removeSuggestedChainInfo(chainId: string): void; clearAllSuggestedChainInfos(): void; protected get chainInfoMap(): Map; protected get chainInfoMapWithCoreTypes(): Map; protected get updatedChainInfoMap(): Map; protected getUpdatedChainInfo(chainId: string): UpdatedChainInfo | undefined; protected get repoChainInfoMap(): Map; protected getRepoChainInfo(chainId: string): ChainInfo | undefined; setEndpoint(chainId: string, endpoint: { rpc?: string; rest?: string; evmRpc?: string; }): void; clearEndpoint(chainId: string): void; clearAllEndpoints(): void; getOriginalEndpoint: (chainId: string) => { rpc: string; rest?: string; evmRpc?: string; }; protected getEndpoint(chainId: string): { chainId: string; rpc?: string; rest?: string; evmRpc?: string; } | undefined; protected get endpointMap(): Map; protected mergeChainInfosWithDynamics(chainInfos: C[]): C[]; protected mergeModularChainInfosWithDynamics(modularChainInfos: ModularChainInfo[]): ModularChainInfo[]; onChainRemoved(chainInfo: ChainInfo): void; addChainRemovedHandler(handler: ChainRemovedHandler): void; addChainSuggestedHandler(handler: ChainSuggestedHandler): void; isEvmChain(chainId: string): boolean; isEvmOnlyChain(chainId: string): boolean; getEVMInfoOrThrow(chainId: string): EVMInfo; getModularChainInfos: () => ModularChainInfo[]; hasModularChainInfo: (chainId: string) => boolean; getModularChainInfo: (chainId: string) => ModularChainInfo | undefined; getModularChainInfoOrThrow(chainId: string): ModularChainInfo; getModularChainInfoWithLinkedChainKey: (chainId: string) => ModularChainInfo[]; hasStarknetChainInfo(chainId: string): boolean; getStarknetChainInfo(chainId: string): StarknetChainInfo | undefined; getStarknetChainInfoOrThrow(chainId: string): StarknetChainInfo; getBitcoinChainInfo(chainId: string): BitcoinChainInfo | undefined; getBitcoinChainInfoOrThrow(chainId: string): BitcoinChainInfo; getBaseChainId(chainId: string): string | undefined; getBaseChainIdOrThrow(chainId: string): string; } export {};