import { AppCurrency, ModularChainInfo, ModularChainInfoByType, ModularChainInfoTypeNames } from "@keplr-wallet/types"; import { CurrencyRegistrar } from "./types"; /** * ModularChainInfo v2의 public 인터페이스. * * v1(ModularChainInfo)이 structural union("cosmos" in info)으로 체인 타입을 구분했던 것과 달리, * v2는 discriminated union의 `type` 필드로 체인 타입을 구분한다. * * 5가지 체인 타입: * - "cosmos" — 순수 Cosmos 체인 (cosmos 모듈만) * - "ethermint" — Cosmos + EVM 하이브리드 (cosmos, evm 모듈 동시 보유) * - "evm" — 순수 EVM 체인 (eip155:* chainId, cosmos 모듈 없음) * - "starknet" — Starknet 체인 * - "bitcoin" — Bitcoin 체인 * * 타입 내로잉은 런타임 체크를 통해서만 동작한다: * if (t.type === "evm") { t.embedded.evm; } * switch (t.unwrapped.type) { case "ethermint": t.unwrapped.cosmos; ... } */ export interface IModularChainInfoImpl { readonly type: T; readonly chainId: string; readonly chainIdentifier: string; readonly chainName: string; readonly chainSymbolImageUrl?: string; readonly isTestnet?: boolean; readonly hideInUI?: boolean; readonly linkedChainKey?: string; /** 원본 체인 정보. registeredCurrencies가 반영되지 않은 상태. */ readonly embedded: ModularChainInfoByType; /** 동적으로 등록된 데이터가 병합된 체인 정보. 현재는 registeredCurrencies만 반영. */ readonly unwrapped: ModularChainInfoByType; /** 모든 모듈의 currency를 합친 flat 배열. v1 ChainInfo.currencies 대응. */ readonly currencies: AppCurrency[]; hasFeature(feature: string): boolean; addUnknownDenoms(...coinMinimalDenoms: string[]): void; addUnknownDenomsWithoutReaction(...coinMinimalDenoms: string[]): void; findCurrency(coinMinimalDenom: string): AppCurrency | undefined; findCurrencyWithoutReaction(coinMinimalDenom: string): AppCurrency | undefined; findCurrencyAsync(coinMinimalDenom: string): Promise; forceFindCurrency(coinMinimalDenom: string): AppCurrency; forceFindCurrencyWithoutReaction(coinMinimalDenom: string): AppCurrency; removeCurrencies(...coinMinimalDenoms: string[]): void; addCurrencies(...currencies: AppCurrency[]): void; isCurrencyRegistrationInProgress(coinMinimalDenom: string): boolean; } /** * IModularChainInfoImpl의 MobX observable 구현체. * * ModularChainInfo를 받아서 내부적으로 저장한다. * v1과 독립적인 currency 등록/조회 시스템을 갖고 있으며, registeredCurrencies는 * unwrapModularChainInfo()를 통해 모듈별로 분배된다: * - cosmos: native, IBC, cw20, secret20 (erc20 제외) * - evm: erc20 토큰 * - starknet: erc20 토큰 * - bitcoin: 그대로 유지 */ export declare class ModularChainInfoImpl implements IModularChainInfoImpl { protected readonly currencyRegistry: { getCurrencyRegistrar: CurrencyRegistrar; }; protected _embedded: ModularChainInfo; protected unknownDenoms: { denom: string; reaction: boolean; }[]; protected registeredCurrencies: AppCurrency[]; protected registeredCurrenciesNoReaction: AppCurrency[]; protected registrationInProgressCurrencyMap: Map; protected forceFindCurrencyCache: Map; constructor(modularChainInfo: ModularChainInfo, currencyRegistry: { getCurrencyRegistrar: CurrencyRegistrar; }); get type(): T; get chainId(): string; get chainIdentifier(): string; get chainName(): string; get chainSymbolImageUrl(): string | undefined; get isTestnet(): boolean | undefined; get hideInUI(): boolean | undefined; get linkedChainKey(): string | undefined; get embedded(): ModularChainInfoByType; get unwrapped(): ModularChainInfoByType; get currencies(): AppCurrency[]; hasFeature(feature: string): boolean; addCurrencies(...currencies: AppCurrency[]): void; removeCurrencies(...coinMinimalDenoms: string[]): void; /** * Currency를 반환한다. * 해당 Currency가 없다면 unknown denom에 추가하여 CurrencyRegistrar를 통해 비동기 등록을 시도한다. * MobX reaction을 트리거하므로, reaction이 필요 없는 경우 findCurrencyWithoutReaction()을 사용. */ findCurrency(coinMinimalDenom: string): AppCurrency | undefined; findCurrencyWithoutReaction(coinMinimalDenom: string): AppCurrency | undefined; findCurrencyAsync(coinMinimalDenom: string): Promise; /** * findCurrency와 비슷하지만 해당하는 currency가 없을 경우 coinMinimalDenom만으로 * 구성된 raw currency를 반환한다. undefined를 반환하지 않으므로 UI에서 안전하게 사용 가능. * 동일 denom에 대해 같은 ref를 유지하기 위해 내부 cache를 사용한다. */ forceFindCurrency(coinMinimalDenom: string): AppCurrency; forceFindCurrencyWithoutReaction(coinMinimalDenom: string): AppCurrency; isCurrencyRegistrationInProgress(coinMinimalDenom: string): boolean; addUnknownDenoms(...coinMinimalDenoms: string[]): void; addUnknownDenomsWithoutReaction(...coinMinimalDenoms: string[]): void; /** * unknown denom을 등록하고 CurrencyRegistrar를 통해 currency 정보를 비동기로 resolve한다. * reaction=true이면 resolve된 currency가 MobX reaction을 트리거하고, * false이면 트리거하지 않다가 findCurrency()로 접근 시 reaction 쪽으로 이동된다. */ protected addUnknownDenomsImpl(coinMinimalDenoms: string[], reaction: boolean): void; /** noReaction 목록에서 reaction 목록으로 currency를 이동한다. findCurrency() 호출 시 자동 수행. */ protected moveNoReactionCurrencyToReaction(coinMinimalDenom: string): void; protected get unknownDenomMap(): Map; protected addOrReplaceCurrency(currency: AppCurrency): void; protected addOrReplaceCurrencyNoReaction(currency: AppCurrency): void; /** unwrapped(registeredCurrencies 병합 후)에서 전체 currency map을 구축한다. */ protected get currencyMap(): Map; setEmbeddedModularChainInfo(embedded: ModularChainInfo): void; protected get currencyNoReactionMap(): Map; }