UNPKG

@bnb-chain/canonical-bridge-sdk

Version:
95 lines (93 loc) 3.57 kB
import { IBaseAdapterOptions, ITokenPair } from './types'; import { BridgeType, ChainType, IBridgeTokenBaseInfo, IChainConfig, IExternalChain, INativeCurrency } from '../../shared/types'; export declare abstract class BaseAdapter<G extends object, C = unknown, T = unknown> { abstract id: BridgeType; protected abstract bridgedTokenGroups: string[][]; protected options: IBaseAdapterOptions<G>; protected config: G; protected excludedChains: number[]; protected excludedTokens: Record<number, Array<string>>; protected assetPrefix: string; protected nativeCurrencies: Record<number, INativeCurrency>; protected brandChains: number[]; protected externalChains: IExternalChain[]; protected displayTokenSymbols: Record<number, Record<string, string>>; protected chainConfigs: IChainConfig[]; protected chains: C[]; protected chainMap: Map<number, C>; protected tokenMap: Map<number, T[]>; protected symbolMap: Map<number, Map<string, T[]>>; protected transferMap: Map<number, Map<number, Map<string, ITokenPair<T, unknown>[]>>>; constructor(options: IBaseAdapterOptions<G>); init(): this; protected abstract initChains(): void; protected abstract initTokens(): void; protected abstract initTransferMap(): void; protected filterTransferMap(): void; abstract getChainId(chain: C): number; abstract getTokenBaseInfo({ chainId, token, }: { chainId: number; token: T; }): IBridgeTokenBaseInfo; getChainBaseInfo(chainId: number): { id: number; name: string; icon: string; explorerUrl: string; tokenUrlPattern: string; chainType: ChainType; externalBridgeUrl: string | undefined; }; protected getTokenDisplaySymbolAndIcon({ chainId, defaultSymbol, tokenAddress, icon, }: { chainId: number; defaultSymbol: string; tokenAddress: string; icon?: string | null; }): { displaySymbol: string; icon: string; }; protected getToTokensForPair({ fromChainId, toChainId, fromTokenSymbol, }: { fromChainId: number; toChainId: number; fromTokenSymbol: string; }): T[]; protected getTokenSymbolByTokenAddress({ chainId, tokenAddress, }: { chainId: number; tokenAddress: string; }): string | undefined; getChainById(chainId: number): C | undefined; getFromChains(): C[]; getToChains({ fromChainId }: { fromChainId: number; }): C[]; getAllTokenPairsOnFromChain({ fromChainId, toChainId, }: { fromChainId: number; toChainId: number; }): ITokenPair<T, unknown>[][]; getTokenPairs({ fromChainId, toChainId, tokenAddress, }: { fromChainId: number; toChainId: number; tokenAddress: string; }): ITokenPair<T, unknown>[] | undefined; getTokenPair({ fromChainId, toChainId, fromTokenAddress, toTokenAddress, }: { fromChainId: number; toChainId: number; fromTokenAddress: string; toTokenAddress: string; }): ITokenPair<T, unknown> | undefined; protected isExcludedToken({ chainId, tokenSymbol, tokenAddress, }: { chainId: number; tokenSymbol: string; tokenAddress: string; }): boolean; isToChainCompatible({ fromChainId, toChainId, }: { fromChainId: number; toChainId: number; }): boolean; isTokenCompatible(params: { fromChainId: number; toChainId: number; tokenAddress: string; }): boolean; }