UNPKG

nimbus-bridge

Version:
71 lines 2.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.convertToLinkedWallet = exports.extractWalletIcon = exports.convertRelayChainToDynamicNetwork = void 0; const convertRelayChainToDynamicNetwork = (chain) => { return { blockExplorerUrls: [chain.explorerUrl ?? "https://etherscan.io"], chainId: chain.id, chainName: chain.name, iconUrls: chain.icon?.light || chain.icon?.dark ? [chain.icon?.light ?? "", chain.icon?.dark ?? ""] : [], name: chain.name, nativeCurrency: { decimals: chain.currency?.decimals ?? 18, name: chain.currency?.name ?? "ETH", symbol: chain.currency?.symbol ?? "ETH", }, networkId: chain.id, rpcUrls: chain.httpRpcUrl ? [chain.httpRpcUrl] : [], vanityName: chain.displayName, }; }; exports.convertRelayChainToDynamicNetwork = convertRelayChainToDynamicNetwork; const extractWalletIcon = (wallet) => { const dynamicStaticAssetUrl = "https://iconic.dynamic-static-assets.com/icons/sprite.svg"; //@ts-ignore const walletBook = wallet?.connector?.walletBook?.wallets; let walletLogoId = // @ts-ignore wallet?.connector?.wallet?.brand?.spriteId ?? (walletBook && wallet.key && walletBook[wallet.key] && walletBook[wallet.key].brand && walletBook[wallet.key].brand.spriteId) ? walletBook[wallet.key].brand.spriteId : undefined; // @ts-ignore let walletIcon = wallet?.connector?.wallet?.icon; if (walletLogoId) { return `${dynamicStaticAssetUrl}#${walletLogoId}`; } else if (walletIcon) { return walletIcon; } else { return undefined; } }; exports.extractWalletIcon = extractWalletIcon; const convertToLinkedWallet = (wallet) => { const walletIcon = (0, exports.extractWalletIcon)(wallet); let walletChain = wallet.chain.toLowerCase(); let vmType = "evm"; if (walletChain === "sol" || walletChain === "eclipse") { vmType = "svm"; } else if (walletChain === "btc") { vmType = "bvm"; } const address = wallet.additionalAddresses.find((address) => address.type !== "ordinals") ?.address ?? wallet.address; return { address, walletLogoUrl: walletIcon, vmType, connector: wallet.connector.key, }; }; exports.convertToLinkedWallet = convertToLinkedWallet; //# sourceMappingURL=dynamic.js.map