@rango-dev/wallets-react 0.0.0-experimental-99f1781b-20260920 → 0.0.0-experimental-a84f27a7-20260921

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/provider.tsx", "../src/context.ts", "../src/hub/utils.ts", "../src/legacy/types.ts", "../src/hub/constants.ts", "../src/hub/helpers.ts", "../src/errors.ts", "../src/hub/persistor.ts", "../src/hub/lastConnectedWallets.ts", "../src/hub/useHubAdapter.ts", "../src/helpers.ts", "../src/hub/autoConnect.ts", "../src/hub/useAutoConnect.ts", "../src/hub/useHubRefs.ts", "../src/hooks.ts"],
4
- "sourcesContent": ["import type { ProviderProps } from './types.js';\n\nimport React from 'react';\n\nimport { WalletContext } from './context.js';\nimport { useHubAdapter } from './hub/mod.js';\nimport { getHubProviders } from './hub/utils.js';\n\nfunction Provider(props: ProviderProps) {\n const api = useHubAdapter({\n ...props,\n providers: getHubProviders(props.providers),\n });\n\n return (\n <WalletContext.Provider value={api}>\n {props.children}\n </WalletContext.Provider>\n );\n}\n\nexport default Provider;\n", "import type { ProviderContext } from './types.js';\n\nimport { createContext } from 'react';\n\nconst defaultErrorMessage = \"Context hasn't been initialized yet.\";\nconst defaultContext: ProviderContext = {\n async connect() {\n throw new Error(defaultErrorMessage);\n },\n async disconnect() {\n throw new Error(defaultErrorMessage);\n },\n async disconnectAll() {\n throw new Error(defaultErrorMessage);\n },\n async suggestAndConnect() {\n throw new Error(defaultErrorMessage);\n },\n state() {\n throw new Error(defaultErrorMessage);\n },\n canSwitchNetworkTo() {\n throw new Error(defaultErrorMessage);\n },\n getWalletInfo() {\n throw new Error(defaultErrorMessage);\n },\n getSigners() {\n throw new Error(defaultErrorMessage);\n },\n hubProvider() {\n throw new Error(defaultErrorMessage);\n },\n};\n\nexport const WalletContext = createContext<ProviderContext>(defaultContext);\n", "import type { AllProxiedNamespaces } from './types.js';\nimport type {\n ConnectResult,\n EventInfo,\n NamespaceInputForConnect,\n EventHandler as WalletEventHandler,\n WalletState,\n} from '../legacy/mod.js';\nimport type { ProviderProps } from '../types.js';\nimport type { UtxoActions } from '@hub3js/bip122';\nimport type { Hub, Provider, ProxiedNamespace, WalletType } from '@hub3js/core';\nimport type { Event } from '@hub3js/core/store';\nimport type {\n Chain as AddEthereumChainParameter,\n EvmActions,\n} from '@hub3js/evm';\nimport type { SolanaActions } from '@hub3js/solana';\n\nimport { pickVersion, type VersionedProviders } from '@hub3js/core/utils';\nimport {\n convertEvmBlockchainMetaToEvmChainInfo,\n formatAddressWithNetwork,\n getBlockChainNameFromId,\n getSupportedChainsFromProvider,\n} from '@rango-dev/internal-blockchains';\nimport { AccountId } from 'caip';\nimport { type BlockchainMeta, isEvmBlockchain } from 'rango-types';\n\nimport { Events } from '../legacy/mod.js';\n\nimport { HUB_LAST_CONNECTED_WALLETS } from './constants.js';\nimport {\n fromAccountIdToLegacyAddressFormat,\n isConnectResultEvm,\n isConnectResultSolana,\n} from './helpers.js';\nimport { LastConnectedWalletsFromStorage } from './lastConnectedWallets.js';\n\nexport function getHubProviders(providers: VersionedProviders[]): Provider[] {\n return providers.map((provider) => {\n try {\n return pickVersion(provider, '1.0.0')[1] as Provider;\n } catch {\n throw new Error(\n \"Legacy providers aren't supported anymore. Expected a provider with version '1.0.0'.\"\n );\n }\n });\n}\n\nexport function findProviderByType(\n providers: Provider[],\n type: string\n): Provider | undefined {\n return providers.find((provider) => provider.id === type);\n}\n\n// The legacy wallet state sent with an event, before any namespace-specific fields.\nexport function getProviderCoreState(provider: Provider): WalletState {\n const [getProviderState] = provider.state();\n return {\n connected: getProviderState().connected,\n connecting: getProviderState().connecting,\n installed: getProviderState().installed,\n accounts: null,\n network: null,\n reachable: true,\n };\n}\n\n// The legacy event info sent with an event, before any namespace-specific fields.\nexport function getProviderEventInfo(\n provider: Provider,\n allBlockChains: ProviderProps['allBlockChains']\n): EventInfo {\n const detailsProperty = provider\n .info()\n ?.metadata.properties?.find((property) => property.name === 'details');\n\n return {\n supportedBlockchains: getSupportedChainsFromProvider(\n provider,\n allBlockChains\n ),\n isContractWallet: detailsProperty?.value?.isContractWallet ?? false,\n isHub: true,\n };\n}\n\n/**\n * We will call this function on hub's `subscribe`.\n * it will check states and will emit legacy events for backward compatibility.\n */\n\nconst lastConnectedWalletsFromStorage = new LastConnectedWalletsFromStorage(\n HUB_LAST_CONNECTED_WALLETS\n);\n\nexport function mapHubEventsToLegacy(\n hub: Hub,\n event: Event,\n onUpdateState: WalletEventHandler,\n metadata: {\n allBlockChains: ProviderProps['allBlockChains'];\n lastConnectAttemptParams: {\n [type: WalletType]: NamespaceInputForConnect[];\n };\n }\n): void {\n const provider = hub.get(event.provider);\n if (!provider) {\n throw new Error(\n \"Currently all the events have assigned to a provider. The event doesn't include one.\",\n {\n cause: event,\n }\n );\n }\n\n // @ts-expect-error for those events that doesn't have namespace, it will be undefinded\n const namespaceId: string | undefined = event.namespace;\n\n const namespace = namespaceId\n ? provider.findByNamespace(namespaceId)\n : undefined;\n let accounts: string[] | null = null;\n let network: string | null = null;\n let derivationPath: string | undefined;\n\n if (namespace) {\n const [getNamespaceState] = namespace.state();\n accounts = getNamespaceState().accounts;\n network = getNamespaceState().network;\n\n if (metadata.lastConnectAttemptParams[event.provider]) {\n derivationPath = metadata.lastConnectAttemptParams[event.provider].find(\n (namespace) => namespace.namespace === namespaceId\n )?.derivationPath;\n }\n }\n\n const coreState = {\n ...getProviderCoreState(provider),\n accounts,\n network,\n derivationPath,\n };\n\n const eventInfo = {\n ...getProviderEventInfo(provider, metadata.allBlockChains),\n namespace: namespaceId,\n };\n\n switch (event.type) {\n case 'provider_detected':\n onUpdateState(\n event.provider,\n Events.INSTALLED,\n true,\n coreState,\n eventInfo\n );\n break;\n case 'provider_connecting':\n onUpdateState(\n event.provider,\n Events.CONNECTING,\n event.value,\n coreState,\n eventInfo\n );\n break;\n case 'provider_connected':\n onUpdateState(\n event.provider,\n Events.CONNECTED,\n true,\n coreState,\n eventInfo\n );\n break;\n case 'provider_disconnected':\n onUpdateState(\n event.provider,\n Events.PROVIDER_DISCONNECTED,\n event.provider,\n coreState,\n eventInfo\n );\n onUpdateState(\n event.provider,\n Events.CONNECTED,\n false,\n coreState,\n eventInfo\n );\n onUpdateState(\n event.provider,\n Events.ACCOUNTS,\n null,\n coreState,\n eventInfo\n );\n break;\n case 'namespace_disconnected':\n lastConnectedWalletsFromStorage.removeNamespacesFromWallet(\n event.provider,\n [event.namespace]\n );\n\n onUpdateState(\n event.provider,\n Events.NAMESPACE_DISCONNECTED,\n event.namespace,\n coreState,\n {\n ...eventInfo,\n namespace: event.namespace,\n }\n );\n // onUpdateState(event.provider, Events.ACCOUNTS, null, coreState, eventInfo);\n break;\n case 'namespace_connected':\n case 'namespace_account_switched':\n {\n if (event.type === 'namespace_account_switched') {\n onUpdateState(\n event.provider,\n Events.NAMESPACE_DISCONNECTED,\n event.namespace,\n coreState,\n eventInfo\n );\n }\n\n let formattedAddresses: string[] = [];\n if (eventInfo.isContractWallet) {\n formattedAddresses = event.accounts.map((account) => {\n const { chainId, address } = AccountId.parse(account);\n if (typeof chainId === 'string') {\n throw new Error('Should be in CAIP format');\n }\n const blockchainName = getBlockChainNameFromId(\n chainId.reference,\n eventInfo.supportedBlockchains\n );\n\n return blockchainName\n ? formatAddressWithNetwork(address, blockchainName)\n : fromAccountIdToLegacyAddressFormat(account);\n });\n } else {\n formattedAddresses = event.accounts.map((accounts) =>\n fromAccountIdToLegacyAddressFormat(accounts)\n );\n }\n\n onUpdateState(\n event.provider,\n Events.ACCOUNTS,\n formattedAddresses,\n coreState,\n {\n ...eventInfo,\n namespace: event.namespace,\n }\n );\n }\n break;\n case 'namespace_network_switched':\n onUpdateState(event.provider, Events.NETWORK, event.network, coreState, {\n ...eventInfo,\n namespace: event.namespace,\n });\n break;\n }\n}\n\n/**\n * In legacy mode, for those who have switch network functionality (like evm), we are using an enum for network names\n * this enum only has meaning for us, and when we are going to connect an instance (e.g. window.ethereum) we should pass chain id.\n */\nexport function convertNamespaceNetworkToEvmChainId(\n namespace: NamespaceInputForConnect,\n meta: BlockchainMeta[]\n): AddEthereumChainParameter | undefined {\n if (!namespace.network) {\n return undefined;\n }\n\n const evmBlockchainsList = meta.filter(isEvmBlockchain);\n const evmChains = convertEvmBlockchainMetaToEvmChainInfo(evmBlockchainsList);\n\n return evmChains[namespace.network];\n}\n\n/**\n * We are passing an string for chain id (e.g. ETH, POLYGON), but wallet's instances (e.g. window.ethereum) needs chainId (e.g. 0x1).\n * This function will help us to map these strings to proper hex ids.\n */\nexport function tryConvertNamespaceNetworkToChainInfo(\n namespace: NamespaceInputForConnect,\n meta: BlockchainMeta[]\n): string | AddEthereumChainParameter | undefined {\n // `undefined` means it's not evm or we couldn't find it in meta.\n const evmChain = convertNamespaceNetworkToEvmChainId(namespace, meta);\n const network = evmChain || namespace.network;\n\n return network;\n}\n\nexport function transformHubResultToLegacyResult(\n res: Awaited<ReturnType<AllProxiedNamespaces['connect']>>\n): ConnectResult {\n if (isConnectResultEvm(res)) {\n return {\n accounts: res.accounts,\n network: res.network,\n };\n } else if (isConnectResultSolana(res)) {\n return {\n accounts: res,\n network: null,\n };\n }\n\n return {\n accounts: [res],\n network: null,\n };\n}\n\n/**\n * Synchronizes providers in the hub with the configuration providers.\n * - Registers and initializes any configuration providers not yet in the hub\n * - Removes providers from the hub that aren't in the configuration\n */\nexport function synchronizeHubWithConfigProviders(\n hub: Hub,\n configurationProviders: Provider[]\n) {\n const registeredProviders = hub.getAll();\n\n // Register and initialize providers that exist in config but not in hub\n const providersToRegister = configurationProviders.filter(\n (configProvider) => !registeredProviders.get(configProvider.id)\n );\n\n providersToRegister.forEach((providerToRegister) => {\n hub.add(providerToRegister.id, providerToRegister);\n providerToRegister.init();\n });\n\n // Remove providers that exist in hub but not in config\n registeredProviders.forEach((registeredProvider) => {\n const isProviderInConfig = configurationProviders.some(\n (configProvider) => configProvider.id === registeredProvider.id\n );\n\n if (!isProviderInConfig) {\n hub.remove(registeredProvider.id);\n }\n });\n}\n\nexport function isSolanaNamespace(\n ns: AllProxiedNamespaces\n): ns is AllProxiedNamespaces &\n ProxiedNamespace<SolanaActions> & { namespaceId: 'Solana' } {\n return ns.namespaceId === 'Solana';\n}\nexport function isEvmNamespace(\n ns: AllProxiedNamespaces\n): ns is AllProxiedNamespaces &\n ProxiedNamespace<EvmActions> & { namespaceId: 'EVM' } {\n return ns.namespaceId === 'EVM';\n}\nexport function isUtxoNamespace(\n ns: AllProxiedNamespaces\n): ns is AllProxiedNamespaces &\n ProxiedNamespace<UtxoActions> & { namespaceId: 'UTXO' } {\n return ns.namespaceId === 'UTXO';\n}\n", "import type {\n DerivationPathProperty,\n NamespacesProperty,\n ProviderMetadata,\n WalletType,\n} from '@hub3js/core';\nimport type { Namespace } from '@hub3js/namespaces';\nimport type { Network } from '@rango-dev/internal-blockchains';\nimport type { BlockchainMeta, SignerFactory } from 'rango-types';\n\nexport type NamespaceMeta = NamespacesProperty['value']['data'][number];\nexport type NeedsNamespace = NamespacesProperty['value'];\nexport type NeedsDerivationPath = DerivationPathProperty['value'];\n\nexport type InstallObjects = {\n CHROME?: string;\n FIREFOX?: string;\n EDGE?: string;\n BRAVE?: string;\n DEFAULT: string;\n};\n\nexport type WalletInfo = {\n name: string;\n img: string;\n installLink: InstallObjects | string;\n /**\n * @deprecated we don't use this value anymore.\n */\n color: string;\n supportedChains: BlockchainMeta[];\n showOnMobile?: boolean;\n isContractWallet?: boolean;\n mobileWallet?: boolean;\n\n needsDerivationPath?: NeedsDerivationPath;\n needsNamespace?: NeedsNamespace;\n};\n\nexport type WalletState = {\n connected: boolean;\n connecting: boolean;\n /**\n * @deprecated it always returns `false`. don't use it.\n */\n reachable: boolean;\n installed: boolean;\n accounts: string[] | null;\n network: Network | null;\n derivationPath?: string;\n};\n\ntype NamespaceData = {\n namespace: Namespace;\n derivationPath?: string;\n};\n\nexport type NamespaceInputForConnect<T extends Namespace = Namespace> = {\n /**\n * By default, you should specify namespace (e.g. evm).\n */\n namespace: T;\n /**\n * In some cases, we need to connect a specific network on a namespace. e.g. Polygon on EVM.\n */\n network: Network | undefined;\n derivationPath?: string;\n};\n\nexport enum Events {\n CONNECTED = 'connected',\n CONNECTING = 'connecting',\n REACHABLE = 'reachable',\n INSTALLED = 'installed',\n ACCOUNTS = 'accounts',\n NETWORK = 'network',\n // Hub only events\n NAMESPACE_DISCONNECTED = 'namespace_disconnected',\n\n PROVIDER_DISCONNECTED = 'provider_disconnected',\n /**\n * Internal: auto-connect couldn't connect one or more namespaces of a wallet.\n * The value is an `AutoConnectionAttemptError`.\n */\n AUTO_CONNECT_FAILED = 'auto_connect_failed',\n}\n\nexport type EventInfo = {\n supportedBlockchains: BlockchainMeta[];\n isContractWallet: boolean;\n isHub: boolean;\n // will be set alongside ACCOUNT event\n namespace?: Namespace;\n derivationPath?: string;\n};\n\nexport type EventHandler = (\n type: WalletType,\n event: Events,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n value: any,\n coreState: WalletState,\n info: EventInfo\n) => void;\n\nexport type ConnectResult = {\n accounts: string[] | null;\n network: Network | null;\n};\n\nexport type ExtendedWalletInfo = WalletInfo & {\n properties?: ProviderMetadata['properties'];\n isHub?: boolean;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype InstanceType = any;\n\ntype ProviderConnectResult = {\n accounts: string[];\n chainId: string;\n derivationPath?: string;\n};\n\ntype GetInstanceOptions = {\n network?: Network;\n currentProvider: InstanceType;\n meta: BlockchainMeta[];\n getState: () => WalletState;\n /**\n * We always get the instance once and reuse it whenever we needs. By using this option\n * We can force the library to get a new instance and replace it with the old one.\n *\n * Originally, we used this option for wallet connect 1 and its switching network challenge.\n */\n force?: boolean;\n updateChainId: (chainId: number | string) => void;\n};\n\ntype TryGetInstance =\n | (() => InstanceType)\n | ((\n options: Pick<GetInstanceOptions, 'force' | 'network'>\n ) => Promise<InstanceType>);\n\ntype Connect = (options: {\n instance: InstanceType;\n network?: Network;\n meta: BlockchainMeta[];\n namespaces?: NamespaceData[];\n}) => Promise<ProviderConnectResult | ProviderConnectResult[]>;\n\ntype Disconnect = (options: {\n instance: InstanceType;\n destroyInstance: () => void;\n}) => Promise<void>;\n\ntype CleanupSubscribe = () => void;\n\ntype Subscribe = (options: {\n instance: InstanceType;\n state: WalletState;\n meta: BlockchainMeta[];\n updateChainId: (chainId: string) => void;\n updateAccounts: (accounts: string[], chainId?: string) => void;\n connect: (network?: Network) => void;\n disconnect: () => void;\n}) => CleanupSubscribe | void;\n\ntype SwitchNetwork = (options: {\n instance: InstanceType;\n network: Network;\n meta: BlockchainMeta[];\n newInstance?: TryGetInstance;\n getState?: () => WalletState;\n updateChainId: (chainId: string) => void;\n}) => Promise<void>;\n\ntype Suggest = (options: {\n instance: InstanceType;\n network: Network;\n meta: BlockchainMeta[];\n}) => Promise<void>;\n\ntype CanSwitchNetwork = (options: {\n network: Network;\n meta: BlockchainMeta[];\n provider: InstanceType;\n}) => boolean;\n\ntype CanEagerConnect = (options: {\n instance: InstanceType;\n meta: BlockchainMeta[];\n}) => Promise<boolean>;\n\ninterface WalletActions {\n connect: Connect;\n getInstance: InstanceType;\n disconnect?: Disconnect;\n subscribe?: Subscribe;\n // unsubscribe, // coupled to subscribe.\n\n // Optional, but should be provided at the same time.\n suggest?: Suggest;\n switchNetwork?: SwitchNetwork;\n getSigners: (provider: InstanceType) => Promise<SignerFactory>;\n canSwitchNetworkTo?: CanSwitchNetwork;\n canEagerConnect?: CanEagerConnect;\n getWalletInfo(allBlockChains: BlockchainMeta[]): WalletInfo;\n}\n\ninterface WalletConfig {\n type: WalletType;\n defaultNetwork?: Network;\n checkInstallation?: boolean;\n isAsyncInstance?: boolean;\n isAsyncSwitchNetwork?: boolean;\n}\n\n/**\n * @deprecated Pass a hub `Provider` instead. This type will be removed in future versions.\n */\nexport type ProviderInterface = { config: WalletConfig } & WalletActions;\n", "export const HUB_LAST_CONNECTED_WALLETS = 'hub-v1-last-connected-wallets';\n", "import type { AllProxiedNamespaces } from './types.js';\nimport type { NamespaceConnectAttempt } from '../errors.js';\nimport type { NamespaceInputForConnect } from '../legacy/types.js';\nimport type { ProviderProps } from '../types.js';\nimport type { Accounts, AccountsWithActiveChain } from '@hub3js/std/types';\nimport type { Option, Result } from 'ts-results';\n\nimport {\n CAIP_BITCOIN_CHAIN_ID,\n CAIP_BITCOINCASH_CHAIN_ID,\n CAIP_DOGECOIN_CHAIN_ID,\n CAIP_LITECOIN_CHAIN_ID,\n CAIP_ZCASH_CHAIN_ID,\n} from '@hub3js/bip122';\nimport { CAIP_NAMESPACE as CAIP_TON_NAMESPACE } from '@hub3js/tvm';\nimport { formatAddressWithNetwork } from '@rango-dev/internal-blockchains';\nimport { CAIP_TRON_CHAIN_ID } from '@rango-dev/wallets-core/namespaces/tron';\nimport { AccountId, type ChainIdParams } from 'caip';\nimport { Err, None, Ok, Some } from 'ts-results';\n\nimport { buildConnectionAttemptError } from '../errors.js';\n\nexport function mapCaipNamespaceToLegacyNetworkName(\n chainId: ChainIdParams | string\n): string {\n if (typeof chainId === 'string') {\n return chainId;\n }\n const useNamespaceAsNetworkFor = ['solana', 'xrpl', 'stellar'];\n\n if (useNamespaceAsNetworkFor.includes(chainId.namespace.toLowerCase())) {\n return chainId.namespace.toUpperCase();\n }\n\n if (chainId.namespace.toLowerCase() === 'eip155') {\n return 'ETH';\n } else if (chainId.reference === CAIP_BITCOIN_CHAIN_ID) {\n return 'BTC';\n } else if (chainId.reference === CAIP_ZCASH_CHAIN_ID) {\n return 'ZCASH';\n } else if (chainId.reference === CAIP_LITECOIN_CHAIN_ID) {\n return 'LTC';\n } else if (chainId.reference === CAIP_DOGECOIN_CHAIN_ID) {\n return 'DOGE';\n } else if (chainId.reference === CAIP_BITCOINCASH_CHAIN_ID) {\n return 'BCH';\n }\n\n if (chainId.namespace.toLowerCase() === CAIP_TON_NAMESPACE) {\n return 'TON';\n }\n if (chainId.namespace === 'sui' || chainId.reference === CAIP_TRON_CHAIN_ID) {\n return chainId.reference.toUpperCase();\n }\n if (chainId.namespace === 'starknet') {\n return chainId.namespace.toUpperCase();\n }\n\n return chainId.reference;\n}\n\n/**\n * CAIP's accountId has a format like this: eip155:1:0xab16a96D359eC26a11e2C2b3d8f8B8942d5Bfcdb\n * Legacy format is something like this: ETH:0xab16a96D359eC26a11e2C2b3d8f8B8942d5Bfcdb\n * This function will try to convert this two format.\n *\n * @see https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md\n */\nexport function fromAccountIdToLegacyAddressFormat(account: string): string {\n const { chainId, address } = AccountId.parse(account);\n const network = mapCaipNamespaceToLegacyNetworkName(chainId);\n return formatAddressWithNetwork(address, network);\n}\n\n/**\n * Runs a list of (lazy) promises one after another and returns their results in\n * order. The first failure rejects, and the promises after it don't run.\n */\nexport async function runSequentially<R>(\n promises: Array<() => Promise<R>>\n): Promise<R[]> {\n const results: R[] = [];\n for (const task of promises) {\n results.push(await task());\n }\n return results;\n}\n\n/**\n * Runs a list of (lazy) promises one after another, even when one fails, and returns\n * each one's outcome in order as a `Result`.\n */\nexport async function runSequentiallyWithoutFailure<R>(\n promises: Array<() => Promise<R>>\n): Promise<Result<R, unknown>[]> {\n return promises.reduce(async (prevPromise, task) => {\n const previousResults = await prevPromise;\n try {\n const taskResult = await task();\n return [...previousResults, new Ok(taskResult)];\n } catch (error) {\n return [...previousResults, new Err(error)];\n }\n }, Promise.resolve<Result<R, unknown>[]>([]));\n}\n\nexport function isConnectResultEvm(\n result: Awaited<ReturnType<AllProxiedNamespaces['connect']>>\n): result is AccountsWithActiveChain {\n return typeof result === 'object' && !Array.isArray(result);\n}\n\nexport function isConnectResultSolana(\n result: Awaited<ReturnType<AllProxiedNamespaces['connect']>>\n): result is Accounts {\n return Array.isArray(result);\n}\n\nexport type QueueTaskResult<T> = {\n result: Result<T, unknown>;\n /*\n * The task never ran: the queue abandoned it after an earlier task with the same key\n * failed. `result` then holds that earlier failure.\n */\n cancelled: boolean;\n};\n\ntype QueueItem<T> = {\n task: () => Promise<T>;\n resolve: (value: QueueTaskResult<T>) => void;\n key: string;\n};\n/**\n * Creates a queue manager that ensures sequential execution of tasks by key.\n * When multiple tasks with the same key are queued, they are executed one at a time\n * in the order they were added. This prevents race conditions and ensures\n * predictable task execution order.\n *\n */\nexport function createQueue(options?: {\n onError?: (\n error: unknown,\n actions: {\n cancelWaitingItems: () => void;\n }\n ) => void;\n}) {\n const processingKeys = new Set<string>();\n let queue: QueueItem<unknown>[] = [];\n\n const cancelWaitingItems = (\n currentItem: QueueItem<unknown>,\n error: unknown\n ) => {\n queue = queue.filter((q) => {\n if (q === currentItem || q.key !== currentItem.key) {\n return true;\n }\n q.resolve({ result: new Err(error), cancelled: true });\n return false;\n });\n };\n\n const processQueue = async () => {\n const currentItem = queue.find((item) => !processingKeys.has(item.key));\n if (!currentItem) {\n return;\n }\n\n const { task, resolve, key } = currentItem;\n processingKeys.add(key);\n\n try {\n const result = await task();\n resolve({ result: new Ok(result), cancelled: false });\n } catch (error) {\n if (options?.onError) {\n options.onError(error, {\n cancelWaitingItems: () => cancelWaitingItems(currentItem, error),\n });\n }\n\n resolve({ result: new Err(error), cancelled: false });\n } finally {\n const indexOfCurrentItem = queue.findIndex((item) => item.key === key);\n if (indexOfCurrentItem >= 0) {\n queue.splice(indexOfCurrentItem, 1);\n }\n processingKeys.delete(key);\n void processQueue();\n }\n };\n\n const queueTask = async <T>(\n task: () => Promise<T>,\n key: string\n ): Promise<QueueTaskResult<T>> =>\n new Promise((resolve) => {\n queue.push({\n task,\n resolve: resolve as (value: QueueTaskResult<unknown>) => void,\n key,\n });\n void processQueue();\n });\n\n return queueTask;\n}\n\n/**\n * Runs one `connect` attempt for the requested namespaces. `connectNamespaces` passes\n * each namespace's attempt to `reportAttempts` once they have all settled. Anything it\n * throws, such as a config error or saving to storage failing, is added after the\n * namespace failures, unchanged.\n *\n * Throws a `WalletConnectionAttemptError` if anything failed; otherwise returns each\n * namespace's result in request order.\n */\nexport async function runConnectionAttempt<T>(\n namespaces: NamespaceInputForConnect[] | undefined,\n connectNamespaces: (\n reportAttempts: (attempts: NamespaceConnectAttempt<T>[]) => void\n ) => Promise<void>\n): Promise<T[]> {\n let attempts: NamespaceConnectAttempt<T>[] = [];\n let nonNamespaceError: Option<unknown> = None;\n\n try {\n await connectNamespaces((settledAttempts) => {\n attempts = settledAttempts;\n });\n } catch (error) {\n nonNamespaceError = new Some(error);\n }\n\n const attemptError = buildConnectionAttemptError({\n requestedNamespaces: namespaces ?? [],\n attempts,\n nonNamespaceError,\n });\n if (attemptError) {\n throw attemptError;\n }\n\n return attempts.map(({ result }) => result.unwrap());\n}\n\nexport function shouldTryAutoConnect(\n props: Pick<ProviderProps, 'allBlockChains' | 'autoConnect'>\n): boolean {\n return !!props.allBlockChains?.length && !!props.autoConnect;\n}\n", "import type { NamespaceInputForConnect } from './legacy/types.js';\nimport type { Option, Result } from 'ts-results';\n\nimport { WalletConnectionError } from '@hub3js/std/utils';\n\nexport type WalletConnectionAttemptErrorOptions = {\n errors: unknown[];\n requestedNamespaces: NamespaceInputForConnect[];\n message?: string;\n};\n\nfunction messageOf(value: unknown): string {\n if (\n typeof value === 'object' &&\n value !== null &&\n 'message' in value &&\n typeof value.message === 'string'\n ) {\n return value.message;\n }\n return String(value);\n}\n\n/**\n * A connection attempt that failed.\n *\n * - `errors` holds every failed namespace's `WalletConnectionError`, in request order,\n * followed by any other value thrown during the attempt.\n * - `requestedNamespaces` lists every namespace the attempt requested, in request\n * order, cancelled ones included, with the network and derivation path passed for it.\n * - `message` is the `message` passed in, or else the first entry's.\n *\n * It has no `code` and no `cause`: read them from each entry.\n */\nexport class WalletConnectionAttemptError extends AggregateError {\n name = 'WalletConnectionAttemptError';\n declare errors: unknown[];\n readonly requestedNamespaces: NamespaceInputForConnect[];\n\n constructor(options: WalletConnectionAttemptErrorOptions) {\n const { errors, requestedNamespaces, message } = options;\n super(errors, message ?? (errors.length > 0 ? messageOf(errors[0]) : ''));\n this.requestedNamespaces = requestedNamespaces;\n }\n}\n\n/**\n * An auto-connect attempt that failed. Auto-connect sends it with\n * `Events.AUTO_CONNECT_FAILED`.\n */\nexport class AutoConnectionAttemptError extends WalletConnectionAttemptError {\n name = 'AutoConnectionAttemptError';\n}\n\nexport type NamespaceConnectAttempt<T = unknown> = {\n input: NamespaceInputForConnect;\n result: Result<T, unknown>;\n // The connect queue abandoned the namespace after another one was rejected.\n cancelled?: boolean;\n};\n\n/**\n * Lists each failed namespace's `WalletConnectionError` in request order, leaving\n * cancelled namespaces out. A failure that isn't one yet (e.g. from an integrator's\n * provider, or a before-hook) is wrapped in one for its namespace.\n */\nexport function collectConnectionFailures(\n attempts: NamespaceConnectAttempt[]\n): WalletConnectionError[] {\n return attempts.flatMap(({ input, result, cancelled }) => {\n if (cancelled || result.ok) {\n return [];\n }\n return result.val instanceof WalletConnectionError\n ? [result.val]\n : [\n new WalletConnectionError({\n namespace: input.namespace,\n cause: result.val,\n }),\n ];\n });\n}\n\n/**\n * Builds the error `connect` throws, or returns `undefined` when every namespace\n * connected and nothing else was thrown. `nonNamespaceError` holds the value thrown\n * outside any namespace, if any, such as a config error; it's added after the\n * namespace failures, unchanged.\n */\nexport function buildConnectionAttemptError(params: {\n requestedNamespaces: NamespaceInputForConnect[];\n attempts: NamespaceConnectAttempt[];\n nonNamespaceError: Option<unknown>;\n}): WalletConnectionAttemptError | undefined {\n const { requestedNamespaces, attempts, nonNamespaceError } = params;\n if (attempts.every(({ result }) => result.ok) && nonNamespaceError.none) {\n return undefined;\n }\n\n const errors: unknown[] = collectConnectionFailures(attempts);\n if (nonNamespaceError.some) {\n errors.push(nonNamespaceError.val);\n }\n return new WalletConnectionAttemptError({ errors, requestedNamespaces });\n}\n\n/**\n * Builds the value of `Events.AUTO_CONNECT_FAILED` from the namespaces auto-connect\n * tried to connect for a wallet. Returns `undefined` when none of them failed.\n */\nexport function buildAutoConnectionAttemptError(\n attempts: NamespaceConnectAttempt[]\n): AutoConnectionAttemptError | undefined {\n const errors = collectConnectionFailures(attempts);\n if (!errors.length) {\n return undefined;\n }\n\n return new AutoConnectionAttemptError({\n errors,\n requestedNamespaces: attempts.map(({ input }) => input),\n });\n}\n", "export interface PersistStorage<T> {\n getItem: (name: string) => T | null;\n setItem: (name: string, value: T) => void;\n removeItem: (name: string) => void;\n}\n\nexport class Persistor<T> implements PersistStorage<T> {\n getItem(name: string) {\n const item = localStorage.getItem(name);\n const parsedItem = item ? (JSON.parse(item) as T) : null;\n return parsedItem;\n }\n setItem(name: string, value: T) {\n localStorage.setItem(name, JSON.stringify(value));\n }\n removeItem(name: string) {\n localStorage.removeItem(name);\n }\n}\n", "import type { Namespace } from '@hub3js/namespaces';\n\nimport { HUB_LAST_CONNECTED_WALLETS } from './constants.js';\nimport { Persistor } from './persistor.js';\n\nexport interface NamespaceInput {\n namespace: Namespace;\n network: string | undefined;\n}\n\nexport interface LastConnectedWalletsStorage {\n [providerId: string]: NamespaceInput[];\n}\n\n/**\n * We are doing some certain actions on storage for `last-connected-wallets` key.\n * This class helps us to define them in one place.\n */\nexport class LastConnectedWalletsFromStorage {\n #storageKey: string;\n\n constructor(storageKey: string) {\n this.#storageKey = storageKey;\n }\n\n addWallet(providerId: string, namespaces: NamespaceInput[]): void {\n if (this.#storageKey === HUB_LAST_CONNECTED_WALLETS) {\n return this.#addWalletToHub(providerId, namespaces);\n }\n throw new Error('Not implemented');\n }\n removeWallets(providerIds?: string[]): void {\n if (this.#storageKey === HUB_LAST_CONNECTED_WALLETS) {\n return this.#removeWalletsFromHub(providerIds);\n }\n throw new Error('Not implemented');\n }\n list(): LastConnectedWalletsStorage {\n if (this.#storageKey === HUB_LAST_CONNECTED_WALLETS) {\n return this.#listFromHub();\n }\n throw new Error('Not implemented');\n }\n removeNamespacesFromWallet(providerId: string, namespaceIds: string[]) {\n if (this.#storageKey === HUB_LAST_CONNECTED_WALLETS) {\n return this.#removeNamespaceFromWalletHub(providerId, namespaceIds);\n }\n throw new Error('Not implemented');\n }\n\n #listFromHub(): LastConnectedWalletsStorage {\n const persistor = new Persistor<LastConnectedWalletsStorage>();\n const lastConnectedWallets =\n persistor.getItem(HUB_LAST_CONNECTED_WALLETS) || {};\n return lastConnectedWallets;\n }\n #addWalletToHub(providerId: string, namespaces: NamespaceInput[]): void {\n const storage = new Persistor<LastConnectedWalletsStorage>();\n const storageState = storage.getItem(this.#storageKey) || {};\n\n let toBeAddedNamespaces = namespaces;\n\n // If provider already exits in the storage, we should just add new namespaces to the previously added namespaces.\n if (!!storageState[providerId]) {\n const storedNamespaces = storageState[providerId];\n toBeAddedNamespaces = storedNamespaces.concat(\n namespaces.filter(\n (namespace) =>\n !storedNamespaces.some(\n (storedNamespace) =>\n storedNamespace.namespace === namespace.namespace\n )\n )\n );\n }\n\n storage.setItem(this.#storageKey, {\n ...storageState,\n [providerId]: toBeAddedNamespaces,\n });\n }\n #removeWalletsFromHub(providerIds?: string[]): void {\n const persistor = new Persistor<LastConnectedWalletsStorage>();\n const storageState = persistor.getItem(this.#storageKey) || {};\n\n // Remove all wallets\n if (!providerIds) {\n persistor.setItem(this.#storageKey, {});\n return;\n }\n\n // Remove some of the wallets\n providerIds.forEach((providerId) => {\n if (storageState[providerId]) {\n delete storageState[providerId];\n }\n });\n\n persistor.setItem(this.#storageKey, storageState);\n }\n #removeNamespaceFromWalletHub(\n providerId: string,\n namespaceIds: string[]\n ): void {\n const persistor = new Persistor<LastConnectedWalletsStorage>();\n const storageState = persistor.getItem(this.#storageKey) || {};\n\n const currentProviderNamespaces = storageState[providerId];\n const newProviderNamespaces = currentProviderNamespaces?.filter(\n (namespace) => !namespaceIds.includes(namespace.namespace)\n );\n\n this.#removeWalletsFromHub([providerId]);\n if (newProviderNamespaces?.length > 0) {\n this.#addWalletToHub(providerId, newProviderNamespaces);\n }\n }\n}\n", "import type { AllProxiedNamespaces, ExtensionLink } from './types.js';\nimport type { NamespaceConnectAttempt } from '../errors.js';\nimport type {\n ConnectResult,\n NamespaceInputForConnect,\n WalletInfo,\n} from '../legacy/mod.js';\nimport type { ProviderContext, ProviderProps } from '../types.js';\nimport type { Provider, WalletType } from '@hub3js/core';\nimport type { Accounts, AccountsWithActiveChain } from '@hub3js/std/types';\n\nimport { isUserRejectionError } from '@hub3js/std/utils';\nimport {\n getSupportedChainsFromNamespace,\n getSupportedChainsFromProvider,\n} from '@rango-dev/internal-blockchains';\nimport { useEffect, useRef, useState } from 'react';\n\nimport { withErrorLoggingApi } from '../helpers.js';\n\nimport { autoConnect } from './autoConnect.js';\nimport { HUB_LAST_CONNECTED_WALLETS } from './constants.js';\nimport {\n createQueue,\n fromAccountIdToLegacyAddressFormat,\n runConnectionAttempt,\n} from './helpers.js';\nimport { LastConnectedWalletsFromStorage } from './lastConnectedWallets.js';\nimport { useAutoConnect } from './useAutoConnect.js';\nimport { useHubRefs } from './useHubRefs.js';\nimport {\n findProviderByType,\n isEvmNamespace,\n isSolanaNamespace,\n isUtxoNamespace,\n mapHubEventsToLegacy,\n transformHubResultToLegacyResult,\n tryConvertNamespaceNetworkToChainInfo,\n} from './utils.js';\n\nexport type UseAdapterParams = Omit<ProviderProps, 'providers'> & {\n providers: Provider[];\n};\n\nexport function useHubAdapter(params: UseAdapterParams): ProviderContext {\n const { getStore, getHub } = useHubRefs(params.providers);\n const [, rerender] = useState(0);\n // useEffect will run `subscribe` once, so we need a reference and mutate the value if it's changes.\n const dataRef = useRef({\n onUpdateState: params.onUpdateState,\n allBlockChains: params.allBlockChains,\n });\n const hubInitiated = useRef(false);\n\n /*\n * Params of each connection attempt for each wallet type are stored here.\n * Derivation path from params is used in `mapHubEventsToLegacy` to be added to the payload of connect events.\n */\n const lastConnectAttemptParamsRef = useRef<{\n [type: WalletType]: NamespaceInputForConnect[];\n }>({});\n\n const updateLastConnectAttemptParams = (\n type: WalletType,\n namespaces: NamespaceInputForConnect[] | undefined\n ) => {\n lastConnectAttemptParamsRef.current[type] = namespaces || [];\n };\n\n const queueTask = createQueue({\n onError: (error, actions) => {\n if (isUserRejectionError(error)) {\n actions.cancelWaitingItems();\n }\n },\n });\n\n useEffect(() => {\n dataRef.current = {\n onUpdateState: params.onUpdateState,\n allBlockChains: params.allBlockChains,\n };\n }, [params]);\n\n useEffect(() => {\n getStore()\n .subscribe((event) => {\n if (dataRef.current.onUpdateState) {\n try {\n mapHubEventsToLegacy(\n getHub(),\n event,\n dataRef.current.onUpdateState,\n {\n allBlockChains: dataRef.current.allBlockChains,\n lastConnectAttemptParams: lastConnectAttemptParamsRef.current,\n }\n );\n } catch (e) {\n console.error(e);\n }\n }\n rerender((currentRender) => currentRender + 1);\n })\n .flushEvents();\n }, []);\n\n // Initialize hub only after blockchain meta is available (e.g. WalletConnect needs it at init).\n useEffect(() => {\n if (hubInitiated.current || !params.allBlockChains?.length) {\n return;\n }\n\n getHub().init(params.configs?.walletOptions);\n rerender((currentRender) => currentRender + 1);\n hubInitiated.current = true;\n }, [params.allBlockChains, params.configs?.walletOptions]);\n\n useAutoConnect({\n autoConnect: params.autoConnect,\n allBlockChains: params.allBlockChains,\n autoConnectHandler: () => {\n void autoConnect({\n allBlockChains: params.allBlockChains,\n getHub,\n wallets: params.configs?.wallets,\n onUpdateState: params.onUpdateState,\n });\n },\n });\n\n const lastConnectedWalletsFromStorage = new LastConnectedWalletsFromStorage(\n HUB_LAST_CONNECTED_WALLETS\n );\n\n const api: ProviderContext = {\n canSwitchNetworkTo(type, network, namespace) {\n const provider = getHub().get(type);\n\n if (!provider) {\n // TODO: should throw an error\n return false;\n }\n\n if (!namespace) {\n throw new Error(\n 'Passing namespace to `canSwitchNetworkTo` is required.'\n );\n }\n\n const proxiedNamespace = provider.findByNamespace(namespace.namespace);\n if (!proxiedNamespace) {\n throw new Error(\n `We couldn't find any matched namespace on your request provider. (requested namespace: ${namespace.namespace})`\n );\n }\n if (!('canSwitchNetwork' in proxiedNamespace)) {\n return false;\n }\n const namespacesProperty = provider\n .info()\n ?.metadata?.properties?.find(\n (property) => property.name === 'namespaces'\n );\n\n if (!dataRef.current.allBlockChains) {\n throw new Error(`Blockchains are not available`);\n }\n\n const namespaceMeta = namespacesProperty?.value.data.find(\n (providerNamespace) => providerNamespace.value === namespace.namespace\n );\n\n if (!namespaceMeta) {\n throw new Error(\n `NamespaceMeta is not defined for requested namespace: ${namespace.namespace}`\n );\n }\n\n const supportedChains = getSupportedChainsFromNamespace(\n namespaceMeta,\n dataRef.current.allBlockChains\n );\n\n return proxiedNamespace.canSwitchNetwork({\n network,\n supportedChains,\n });\n },\n async connect(type, namespaces) {\n const connectNamespaces = async (\n reportAttempts: (\n attempts: NamespaceConnectAttempt<ConnectResult>[]\n ) => void\n ) => {\n const wallet = getHub().get(type);\n if (!wallet) {\n throw new Error(\n `You should add ${type} to provider first then call 'connect'.`\n );\n }\n\n if (!namespaces) {\n throw new Error('Passing namespace to `connect` is required.');\n }\n\n updateLastConnectAttemptParams(type, namespaces);\n\n // Check `namespace` and look into hub to see how it can match given namespace to hub namespace.\n const targetNamespaces: [\n NamespaceInputForConnect,\n AllProxiedNamespaces\n ][] = [];\n namespaces.forEach((namespace) => {\n const targetNamespace = namespace.namespace;\n\n const result = wallet.findByNamespace(targetNamespace);\n if (!result) {\n throw new Error(\n `We couldn't find any provider matched with your request namespace. (requested namespace: ${namespace.namespace})`\n );\n }\n\n targetNamespaces.push([namespace, result]);\n });\n\n // Try to run `connect` on matched namespaces\n const connectAttemptsFromTargetNamespaces = targetNamespaces.map(\n async ([namespaceInput, namespace]) => {\n const network = tryConvertNamespaceNetworkToChainInfo(\n namespaceInput,\n params.allBlockChains || []\n );\n\n let connectNamespacePromise: () => Promise<\n Accounts | AccountsWithActiveChain\n >;\n\n if (isSolanaNamespace(namespace)) {\n connectNamespacePromise = async () =>\n namespace.connect({\n derivationPath: namespaceInput.derivationPath,\n });\n } else if (isEvmNamespace(namespace)) {\n connectNamespacePromise = async () =>\n namespace.connect(network, {\n derivationPath: namespaceInput.derivationPath,\n });\n } else if (isUtxoNamespace(namespace)) {\n connectNamespacePromise = async () =>\n namespace.connect({\n derivationPath: namespaceInput.derivationPath,\n });\n } else {\n connectNamespacePromise = async () => namespace.connect();\n }\n\n const connectNamespaceProcess = async () =>\n connectNamespacePromise().then<ConnectResult>(\n transformHubResultToLegacyResult\n );\n const { result, cancelled } = await queueTask(\n connectNamespaceProcess,\n type\n );\n return {\n input: namespaceInput,\n result,\n cancelled,\n supportsEagerConnect: 'canEagerConnect' in namespace,\n };\n }\n );\n\n /*\n * We need to connect to namespace one after another, sending multiple requests at the same time may be failed.\n * e.g. when wallet popup opens and asking for the password from the user, it should be resolved first, then other request will be resolved.\n */\n const attempts = await Promise.all(connectAttemptsFromTargetNamespaces);\n reportAttempts(attempts);\n\n // Keeping only namespaces that connected successfully and support eager connect, then we'll store them on storage for auto connect functionality.\n const successfullyConnectedSupportingEagerConnectNamespaces = attempts\n .filter(\n ({ result, supportsEagerConnect }) =>\n result.ok && supportsEagerConnect\n )\n .map(({ input }) => ({\n namespace: input.namespace,\n network: input.network,\n }));\n\n if (successfullyConnectedSupportingEagerConnectNamespaces.length > 0) {\n lastConnectedWalletsFromStorage.addWallet(\n type,\n successfullyConnectedSupportingEagerConnectNamespaces\n );\n }\n };\n\n return runConnectionAttempt(namespaces, connectNamespaces);\n },\n async disconnect(type, namespaces) {\n const wallet = getHub().get(type);\n if (!wallet) {\n throw new Error(\n `You should add ${type} to provider first then call 'disconnect'.`\n );\n }\n\n wallet.getAll().forEach((namespace) => {\n const namespaceShouldBeDisconnected =\n !namespaces || namespaces.includes(namespace.namespaceId);\n const namespaceIsConnected = namespace.state()[0]().connected;\n if (namespaceShouldBeDisconnected && namespaceIsConnected) {\n return namespace.disconnect();\n }\n });\n\n if (params.autoConnect) {\n if (namespaces) {\n lastConnectedWalletsFromStorage.removeNamespacesFromWallet(\n type,\n namespaces\n );\n } else {\n lastConnectedWalletsFromStorage.removeWallets([type]);\n }\n }\n },\n async disconnectAll() {\n const disconnectPromises: Promise<void>[] = Array.from(\n getHub().getAll().values()\n ).map(async (provider) => this.disconnect(provider.id));\n\n return await Promise.allSettled(disconnectPromises);\n },\n async getSigners(type) {\n const wallet = getHub().get(type);\n if (!wallet) {\n throw new Error(`You should add ${type} to provider first.`);\n }\n\n const info = wallet.info();\n if (!info) {\n throw new Error('Your provider should have required `info`.');\n }\n\n const providerProperties = info.metadata.properties;\n\n const signerProperty = providerProperties?.find(\n (property) => property.name === 'signers'\n );\n if (!signerProperty) {\n throw new Error('Your provider should contain signers property.');\n }\n\n return signerProperty.value.getSigners();\n },\n getWalletInfo(type) {\n const wallet = getHub().get(type);\n if (!wallet) {\n throw new Error(`You should add ${type} to provider first.`);\n }\n\n const info = wallet.info();\n if (!info) {\n throw new Error('Your provider should have required `info`.');\n }\n\n const installLink: Exclude<WalletInfo['installLink'], string> = {\n DEFAULT: '',\n };\n\n const { metadata } = info;\n const { extensions } = metadata;\n // `extensions` in legacy format was uppercase and also `DEFAULT` was used instead of `homepage`\n Object.keys(extensions).forEach((k) => {\n const key = k as ExtensionLink;\n\n if (key === 'homepage') {\n installLink.DEFAULT = extensions[key] || '';\n }\n\n const allowedKeys: ExtensionLink[] = [\n 'firefox',\n 'chrome',\n 'brave',\n 'edge',\n ];\n if (allowedKeys.includes(key)) {\n const upperCasedKey = key.toUpperCase() as keyof Exclude<\n WalletInfo['installLink'],\n string\n >;\n installLink[upperCasedKey] = extensions[key] || '';\n }\n });\n\n const providerProperties = metadata.properties;\n\n const namespacesProperty = providerProperties?.find(\n (property) => property.name === 'namespaces'\n );\n const derivationPathProperty = providerProperties?.find(\n (property) => property.name === 'derivationPath'\n );\n const detailsProperty = providerProperties?.find(\n (property) => property.name === 'details'\n );\n\n return {\n name: metadata.name,\n img: metadata.icon,\n installLink: installLink,\n // We don't have this values anymore, fill them with some values that communicate this.\n color: 'red',\n supportedChains: getSupportedChainsFromProvider(\n wallet,\n dataRef.current.allBlockChains\n ),\n isContractWallet: detailsProperty?.value?.isContractWallet,\n mobileWallet: detailsProperty?.value?.mobileWallet,\n // if set to false here, it will not show the wallet in mobile in anyways. to be compatible with old behavior, undefined is more appropirate.\n showOnMobile: detailsProperty?.value?.showOnMobile,\n needsNamespace: namespacesProperty?.value,\n needsDerivationPath: derivationPathProperty?.value,\n isHub: true,\n properties: metadata.properties,\n };\n },\n state(type) {\n const hubState = getHub().state();\n const wallet = getHub().get(type);\n const walletState = hubState[type];\n\n if (!walletState || !wallet) {\n // TODO: should throw an error\n return {\n connected: false,\n connecting: false,\n installed: false,\n reachable: false,\n accounts: null,\n network: null,\n namespaces: new Map(),\n };\n }\n\n const accounts = walletState.namespaces\n .filter((namespace) => namespace.connected)\n .flatMap((namespace) =>\n namespace.accounts?.map((accounts) =>\n fromAccountIdToLegacyAddressFormat(accounts)\n )\n )\n .filter((account): account is string => !!account);\n\n const namespacesState = new Map(\n Array.from(wallet.getAll(), ([_, value]) => [\n value.namespaceId,\n value.state()[0](),\n ])\n );\n\n const coreState = {\n connected: walletState.connected,\n connecting: walletState.connecting,\n installed: walletState.installed,\n reachable: true,\n accounts: accounts,\n network: null,\n namespaces: namespacesState,\n };\n return coreState;\n },\n async suggestAndConnect(type, namespace): Promise<ConnectResult> {\n const provider = getHub().get(type);\n\n if (!provider) {\n throw new Error(\n `You should add ${type} to provider first then call 'suggestAndConnect'.`\n );\n }\n const proxiedNamespace = provider.findByNamespace(namespace.namespace);\n if (!proxiedNamespace) {\n throw new Error(\n `We couldn't find any matched namespace on your request provider. (requested namespace: ${namespace.namespace})`\n );\n }\n if (!('suggest' in proxiedNamespace)) {\n throw new Error('Suggest is not implemented on the provider');\n }\n if (!namespace.network) {\n throw new Error('You should pass network to the suggest and connect');\n }\n throw new Error(\n `Suggest has not been implemented for given chain: ${namespace.network}`\n );\n },\n hubProvider(type) {\n const provider = findProviderByType(params.providers, type);\n\n if (!provider) {\n throw new Error(\n `You're trying to access ${type} provider which is not found in hub providers. it may not be registered yet.`\n );\n }\n\n return provider;\n },\n };\n\n return withErrorLoggingApi(api);\n}\n", "import type { ProviderContext } from './types.js';\n\nimport { debug } from '@rango-dev/logging-core';\n\nfunction logError(method: string, args: unknown[], error: unknown) {\n const err = error instanceof Error ? error : new Error(String(error));\n debug(err, {\n context: { method, args },\n tags: { type: 'wallet-error' },\n });\n}\n\nfunction withErrorLogging<TArgs extends unknown[], TReturn>(\n method: string,\n fn: (...args: TArgs) => TReturn\n): (...args: TArgs) => TReturn {\n return (...args: TArgs): TReturn => {\n try {\n const result = fn(...args);\n // Async method: catch the rejection, log, then throw the rejection.\n if (result instanceof Promise) {\n return result.catch((error: unknown) => {\n logError(method, args, error);\n throw error;\n }) as TReturn;\n }\n return result;\n } catch (error) {\n // Sync method: log and rethrow.\n logError(method, args, error);\n throw error;\n }\n };\n}\n\nexport function withErrorLoggingApi(api: ProviderContext): ProviderContext {\n const entries = Object.entries(api).map(([key, value]) => [\n key,\n withErrorLogging(key, (value as (...args: unknown[]) => unknown).bind(api)),\n ]);\n\n return Object.fromEntries(entries) as ProviderContext;\n}\n", "import type { AllProxiedNamespaces } from './types.js';\nimport type { UseAdapterParams } from './useHubAdapter.js';\nimport type { NamespaceConnectAttempt } from '../errors.js';\nimport type {\n EventHandler,\n NamespaceInputForConnect,\n} from '../legacy/types.js';\nimport type { Hub, Provider, WalletType } from '@hub3js/core';\nimport type { DefaultNamespaces, Namespace } from '@hub3js/namespaces';\nimport type { Accounts, AccountsWithActiveChain } from '@hub3js/std/types';\n\nimport { Result } from 'ts-results';\n\nimport { buildAutoConnectionAttemptError } from '../errors.js';\nimport { Events } from '../legacy/types.js';\n\nimport { HUB_LAST_CONNECTED_WALLETS } from './constants.js';\nimport { runSequentially, runSequentiallyWithoutFailure } from './helpers.js';\nimport { LastConnectedWalletsFromStorage } from './lastConnectedWallets.js';\nimport {\n convertNamespaceNetworkToEvmChainId,\n getProviderCoreState,\n getProviderEventInfo,\n isEvmNamespace,\n} from './utils.js';\n\nfunction isEvmNamespaceInput(\n namespace: NamespaceInputForConnect\n): namespace is NamespaceInputForConnect<'EVM'> {\n return namespace.namespace === 'EVM';\n}\n\n// Getting connected wallets from storage\nconst lastConnectedWalletsFromStorage = new LastConnectedWalletsFromStorage(\n HUB_LAST_CONNECTED_WALLETS\n);\n\n/**\n * Run `.connect` action on some selected namespaces (passed as param) for a provider.\n */\nasync function eagerConnect(\n type: string,\n namespacesInput: NamespaceInputForConnect[] | undefined,\n params: {\n getHub: () => Hub;\n allBlockChains: UseAdapterParams['allBlockChains'];\n onUpdateState?: EventHandler;\n }\n) {\n const { getHub, allBlockChains, onUpdateState } = params;\n const wallet = getHub().get(type);\n if (!wallet) {\n throw new Error(\n `You should add ${type} to provider first then call 'connect'.`\n );\n }\n\n if (!namespacesInput) {\n throw new Error('Passing namespace to `connect` is required. ');\n }\n\n const targetNamespaces: [NamespaceInputForConnect, AllProxiedNamespaces][] =\n [];\n namespacesInput.forEach((namespaceInput) => {\n const targetNamespace: Namespace = namespaceInput.namespace;\n\n const result = wallet.findByNamespace(targetNamespace);\n\n if (!result) {\n throw new Error(\n `We couldn't find any provider matched with your request namespace. (requested namespace: ${namespaceInput.namespace})`\n );\n }\n\n targetNamespaces.push([namespaceInput, result]);\n });\n\n const connectNamespacesPromises = targetNamespaces.map(\n ([info, namespace]) => {\n const evmChain = isEvmNamespaceInput(info)\n ? convertNamespaceNetworkToEvmChainId(info, allBlockChains || [])\n : undefined;\n const chain = evmChain || info.network;\n\n return async (): Promise<NamespaceConnectAttempt> => {\n let connectNamespacePromise: () => Promise<\n Accounts | AccountsWithActiveChain\n >;\n if (isEvmNamespace(namespace)) {\n connectNamespacePromise = async () => namespace.connect(chain);\n } else {\n connectNamespacePromise = async () => namespace.connect();\n }\n return {\n input: info,\n result: await Result.wrapAsync(connectNamespacePromise),\n };\n };\n }\n );\n\n /**\n * Sometimes calling methods on a instance in parallel, would cause an error in wallet.\n * We are running a method at a time to make sure we are covering this.\n * e.g. when we are trying to eagerConnect evm and solana on phantom at the same time, the last namespace throw an error.\n */\n const attempts = await runSequentially(connectNamespacesPromises);\n\n const failedNamespaces = attempts\n .filter(({ result }) => result.err)\n .map(({ input }) => input.namespace);\n\n if (failedNamespaces.length > 0) {\n lastConnectedWalletsFromStorage.removeNamespacesFromWallet(\n type,\n failedNamespaces\n );\n }\n\n const autoConnectionAttemptError = buildAutoConnectionAttemptError(attempts);\n if (autoConnectionAttemptError) {\n onUpdateState?.(\n type,\n Events.AUTO_CONNECT_FAILED,\n autoConnectionAttemptError,\n getProviderCoreState(wallet),\n getProviderEventInfo(wallet, allBlockChains)\n );\n }\n\n const connectNamespacesResult = attempts.map(({ result }) => result);\n const atLeastOneNamespaceConnectedSuccessfully = connectNamespacesResult.some(\n (result) => result.ok\n );\n if (!atLeastOneNamespaceConnectedSuccessfully) {\n throw new Error(`No namespace connected for ${type}`);\n }\n return Result.all(\n ...connectNamespacesResult.filter((result) => result.ok)\n ).unwrap();\n}\n\n/**\n * Run `.canEagerConnect` action on some selected namespaces of a wallet.\n */\nasync function tryRunCanEagerConnect(\n namespaces: NamespaceInputForConnect[],\n wallet: Provider<DefaultNamespaces>\n): Promise<{\n successNamespaces: NamespaceInputForConnect[];\n failedNamespaces: NamespaceInputForConnect[];\n}> {\n const foundNamespaces: NamespaceInputForConnect[] = [];\n const successNamespaces: NamespaceInputForConnect[] = [];\n const failedNamespaces: NamespaceInputForConnect[] = [];\n const canEagerConnectPromises: (() => Promise<boolean>)[] = [];\n\n // 1. Try find namespace instances and create canEagerConnect promises\n namespaces.forEach((namespace) => {\n const namespaceInstance = wallet.findByNamespace(namespace.namespace);\n if (namespaceInstance) {\n foundNamespaces.push(namespace);\n canEagerConnectPromises.push(\n async () => await namespaceInstance.canEagerConnect()\n );\n } else {\n failedNamespaces.push(namespace);\n }\n });\n\n // 2. Run canEagerConnect sequentially on namespaces\n const canEagerConnectResults = await runSequentiallyWithoutFailure(\n canEagerConnectPromises\n );\n\n // 3. Separate success and failed namespaces based on canEagerConnect result\n foundNamespaces.forEach((namespace, index) => {\n if (canEagerConnectResults[index].ok && canEagerConnectResults[index].val) {\n successNamespaces.push(namespace);\n } else {\n failedNamespaces.push(namespace);\n }\n });\n\n return { successNamespaces, failedNamespaces };\n}\n\n/*\n * Get last connected wallets and last connected namespaces for each of them from storage\n * Then run `.connect` on each namespace if `.canEagerConnect` returns true.\n */\nexport async function autoConnect(deps: {\n getHub: () => Hub;\n allBlockChains: UseAdapterParams['allBlockChains'];\n wallets?: (WalletType | Provider)[];\n onUpdateState?: EventHandler;\n}): Promise<void> {\n const { getHub, allBlockChains, wallets, onUpdateState } = deps;\n const lastConnectedWallets = lastConnectedWalletsFromStorage.list();\n const walletIds = Object.keys(lastConnectedWallets);\n\n const walletsToRemoveFromPersistence: string[] = [];\n\n if (walletIds.length) {\n const eagerConnectQueue: Promise<unknown>[] = [];\n\n const configWalletNames = wallets?.map((wallet) =>\n typeof wallet === 'string' ? wallet : wallet.id\n );\n // Run `.connect` if `.canEagerConnect` returns `true`.\n walletIds.forEach(async (providerName) => {\n if (configWalletNames && !configWalletNames.includes(providerName)) {\n console.warn(\n 'Trying to run auto connect for a wallet which is not included in config. Desired wallet:',\n providerName\n );\n walletsToRemoveFromPersistence.push(providerName);\n return;\n }\n\n const wallet = getHub().get(providerName);\n\n const lastConnectedNamespaces: NamespaceInputForConnect[] =\n lastConnectedWallets[providerName].map((namespace) => ({\n namespace: namespace.namespace,\n network: namespace.network,\n }));\n\n if (!lastConnectedNamespaces.length || !wallet) {\n walletsToRemoveFromPersistence.push(providerName);\n return;\n }\n\n const { successNamespaces, failedNamespaces } =\n await tryRunCanEagerConnect(lastConnectedNamespaces, wallet);\n\n if (!successNamespaces.length) {\n walletsToRemoveFromPersistence.push(providerName);\n return;\n } else if (failedNamespaces.length) {\n lastConnectedWalletsFromStorage.removeNamespacesFromWallet(\n wallet.id,\n failedNamespaces.map((namespace) => namespace.namespace)\n );\n }\n eagerConnectQueue.push(\n eagerConnect(providerName, successNamespaces, {\n allBlockChains,\n getHub,\n onUpdateState,\n }).catch((error) => console.warn(error))\n );\n });\n\n lastConnectedWalletsFromStorage.removeWallets(\n walletsToRemoveFromPersistence\n );\n\n await Promise.all(eagerConnectQueue);\n }\n}\n", "import type { ProviderProps } from '../types.js';\n\nimport { useEffect, useRef } from 'react';\n\nimport { shouldTryAutoConnect } from './helpers.js';\n\nexport function useAutoConnect(\n props: Pick<ProviderProps, 'allBlockChains' | 'autoConnect'> & {\n /**\n * A function to run autoConnect on instances\n */\n autoConnectHandler: () => void;\n }\n) {\n const autoConnectInitiated = useRef(false);\n\n useEffect(() => {\n if (shouldTryAutoConnect(props) && !autoConnectInitiated.current) {\n autoConnectInitiated.current = true;\n props.autoConnectHandler();\n }\n }, [props.autoConnect, props.allBlockChains]);\n}\n", "import type { Provider, Store } from '@hub3js/core';\n\nimport { createStore, Hub } from '@hub3js/core';\nimport { useRef } from 'react';\n\nimport { synchronizeHubWithConfigProviders } from './utils.js';\n\nexport function useHubRefs(providers: Provider[]) {\n const store = useRef<Store | null>(null);\n\n const hub = useRef<Hub | null>(null);\n\n function createHub() {\n const createdHub = new Hub({\n store: getStore(),\n });\n /*\n * First add providers to hub\n * This helps to `getWalletInfo` be usable, before initialize.\n */\n providers.forEach((provider) => {\n createdHub.add(provider.id, provider);\n });\n hub.current = createdHub;\n return createdHub;\n }\n\n // https://react.dev/reference/react/useRef#avoiding-recreating-the-ref-contents\n function getStore() {\n if (store.current !== null) {\n return store.current;\n }\n const createdStore = createStore();\n store.current = createdStore;\n return createdStore;\n }\n\n function getHub(): Hub {\n const hubProviders = hub.current?.getAll();\n\n if (!hub.current || !hubProviders) {\n return createHub();\n }\n\n synchronizeHubWithConfigProviders(hub.current, providers);\n return hub.current;\n }\n\n return { getStore, getHub };\n}\n", "import type { ProviderContext } from './types.js';\n\nimport { useContext } from 'react';\n\nimport { WalletContext } from './context.js';\n\nexport function useWallets(): ProviderContext {\n const context = useContext(WalletContext);\n if (!context) {\n throw Error('useWallet can only be used within the Provider component');\n }\n return context;\n}\n"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WY,CAAI,EAE1D,GAAI,CAACoB,EACH,MAAM,IAAI,MACR,2BAA2BpB,CAAI,8EACjC,EAGF,OAAOoB,CACT,CACF,CAE8B,CAChC,CAtdgBrB,EAAAZ,EAAA,iBTpChB,SAASqF,GAASC,EAAsB,CACtC,IAAMC,EAAMC,EAAc,CACxB,GAAGF,EACH,UAAWG,EAAgBH,EAAM,SAAS,CAC5C,CAAC,EAED,OACEI,GAAA,cAACC,EAAc,SAAd,CAAuB,MAAOJ,GAC5BD,EAAM,QACT,CAEJ,CAXSM,EAAAP,GAAA,YAaT,IAAOQ,GAAQR,GcnBf,OAAS,cAAAS,OAAkB,QAIpB,SAASC,IAA8B,CAC5C,IAAMC,EAAUC,GAAWC,CAAa,EACxC,GAAI,CAACF,EACH,MAAM,MAAM,0DAA0D,EAExE,OAAOA,CACT,CANgBG,EAAAJ,GAAA",
6
- "names": ["React", "createContext", "defaultErrorMessage", "defaultContext", "WalletContext", "pickVersion", "convertEvmBlockchainMetaToEvmChainInfo", "formatAddressWithNetwork", "getBlockChainNameFromId", "getSupportedChainsFromProvider", "AccountId", "isEvmBlockchain", "Events", "HUB_LAST_CONNECTED_WALLETS", "CAIP_BITCOIN_CHAIN_ID", "CAIP_BITCOINCASH_CHAIN_ID", "CAIP_DOGECOIN_CHAIN_ID", "CAIP_LITECOIN_CHAIN_ID", "CAIP_ZCASH_CHAIN_ID", "CAIP_TON_NAMESPACE", "formatAddressWithNetwork", "CAIP_TRON_CHAIN_ID", "AccountId", "Err", "None", "Ok", "Some", "WalletConnectionError", "messageOf", "value", "__name", "WalletConnectionAttemptError", "options", "errors", "requestedNamespaces", "message", "AutoConnectionAttemptError", "collectConnectionFailures", "attempts", "input", "result", "cancelled", "WalletConnectionError", "buildConnectionAttemptError", "params", "nonNamespaceError", "buildAutoConnectionAttemptError", "mapCaipNamespaceToLegacyNetworkName", "chainId", "CAIP_BITCOIN_CHAIN_ID", "CAIP_ZCASH_CHAIN_ID", "CAIP_LITECOIN_CHAIN_ID", "CAIP_DOGECOIN_CHAIN_ID", "CAIP_BITCOINCASH_CHAIN_ID", "CAIP_TON_NAMESPACE", "CAIP_TRON_CHAIN_ID", "__name", "fromAccountIdToLegacyAddressFormat", "account", "address", "AccountId", "network", "formatAddressWithNetwork", "runSequentially", "promises", "results", "task", "runSequentiallyWithoutFailure", "prevPromise", "previousResults", "taskResult", "Ok", "error", "Err", "isConnectResultEvm", "result", "isConnectResultSolana", "createQueue", "options", "processingKeys", "queue", "cancelWaitingItems", "currentItem", "q", "processQueue", "item", "resolve", "key", "indexOfCurrentItem", "runConnectionAttempt", "namespaces", "connectNamespaces", "attempts", "nonNamespaceError", "None", "settledAttempts", "Some", "attemptError", "buildConnectionAttemptError", "shouldTryAutoConnect", "props", "Persistor", "__name", "name", "item", "value", "LastConnectedWalletsFromStorage", "__name", "#storageKey", "storageKey", "providerId", "namespaces", "HUB_LAST_CONNECTED_WALLETS", "#addWalletToHub", "providerIds", "#removeWalletsFromHub", "#listFromHub", "namespaceIds", "#removeNamespaceFromWalletHub", "Persistor", "storage", "storageState", "toBeAddedNamespaces", "storedNamespaces", "namespace", "storedNamespace", "persistor", "newProviderNamespaces", "getHubProviders", "providers", "provider", "pickVersion", "__name", "findProviderByType", "type", "getProviderCoreState", "getProviderState", "getProviderEventInfo", "allBlockChains", "detailsProperty", "property", "getSupportedChainsFromProvider", "lastConnectedWalletsFromStorage", "LastConnectedWalletsFromStorage", "HUB_LAST_CONNECTED_WALLETS", "mapHubEventsToLegacy", "hub", "event", "onUpdateState", "metadata", "namespaceId", "namespace", "accounts", "network", "derivationPath", "getNamespaceState", "coreState", "eventInfo", "formattedAddresses", "account", "chainId", "address", "AccountId", "blockchainName", "getBlockChainNameFromId", "formatAddressWithNetwork", "fromAccountIdToLegacyAddressFormat", "convertNamespaceNetworkToEvmChainId", "meta", "evmBlockchainsList", "isEvmBlockchain", "convertEvmBlockchainMetaToEvmChainInfo", "tryConvertNamespaceNetworkToChainInfo", "transformHubResultToLegacyResult", "res", "isConnectResultEvm", "isConnectResultSolana", "synchronizeHubWithConfigProviders", "configurationProviders", "registeredProviders", "configProvider", "providerToRegister", "registeredProvider", "isSolanaNamespace", "ns", "isEvmNamespace", "isUtxoNamespace", "isUserRejectionError", "getSupportedChainsFromNamespace", "getSupportedChainsFromProvider", "useEffect", "useRef", "useState", "debug", "logError", "method", "args", "error", "err", "debug", "__name", "withErrorLogging", "fn", "result", "withErrorLoggingApi", "api", "entries", "key", "value", "Result", "isEvmNamespaceInput", "namespace", "__name", "lastConnectedWalletsFromStorage", "LastConnectedWalletsFromStorage", "HUB_LAST_CONNECTED_WALLETS", "eagerConnect", "type", "namespacesInput", "params", "getHub", "allBlockChains", "onUpdateState", "wallet", "targetNamespaces", "namespaceInput", "targetNamespace", "result", "connectNamespacesPromises", "info", "chain", "convertNamespaceNetworkToEvmChainId", "connectNamespacePromise", "isEvmNamespace", "Result", "attempts", "runSequentially", "failedNamespaces", "input", "autoConnectionAttemptError", "buildAutoConnectionAttemptError", "getProviderCoreState", "getProviderEventInfo", "connectNamespacesResult", "tryRunCanEagerConnect", "namespaces", "foundNamespaces", "successNamespaces", "canEagerConnectPromises", "namespaceInstance", "canEagerConnectResults", "runSequentiallyWithoutFailure", "index", "autoConnect", "deps", "wallets", "lastConnectedWallets", "walletIds", "walletsToRemoveFromPersistence", "eagerConnectQueue", "configWalletNames", "providerName", "lastConnectedNamespaces", "error", "useEffect", "useRef", "useAutoConnect", "props", "autoConnectInitiated", "useRef", "useEffect", "shouldTryAutoConnect", "__name", "createStore", "Hub", "useRef", "useHubRefs", "providers", "store", "useRef", "hub", "createHub", "createdHub", "Hub", "getStore", "provider", "__name", "createdStore", "createStore", "getHub", "hubProviders", "synchronizeHubWithConfigProviders", "useHubAdapter", "params", "getStore", "getHub", "useHubRefs", "rerender", "useState", "dataRef", "useRef", "hubInitiated", "lastConnectAttemptParamsRef", "updateLastConnectAttemptParams", "__name", "type", "namespaces", "queueTask", "createQueue", "error", "actions", "isUserRejectionError", "useEffect", "event", "mapHubEventsToLegacy", "e", "currentRender", "useAutoConnect", "autoConnect", "lastConnectedWalletsFromStorage", "LastConnectedWalletsFromStorage", "HUB_LAST_CONNECTED_WALLETS", "withErrorLoggingApi", "network", "namespace", "provider", "proxiedNamespace", "namespacesProperty", "property", "namespaceMeta", "providerNamespace", "supportedChains", "getSupportedChainsFromNamespace", "runConnectionAttempt", "reportAttempts", "wallet", "targetNamespaces", "targetNamespace", "result", "connectAttemptsFromTargetNamespaces", "namespaceInput", "tryConvertNamespaceNetworkToChainInfo", "connectNamespacePromise", "isSolanaNamespace", "isEvmNamespace", "isUtxoNamespace", "connectNamespaceProcess", "transformHubResultToLegacyResult", "cancelled", "attempts", "successfullyConnectedSupportingEagerConnectNamespaces", "supportsEagerConnect", "input", "namespaceShouldBeDisconnected", "namespaceIsConnected", "disconnectPromises", "info", "signerProperty", "installLink", "metadata", "extensions", "k", "key", "upperCasedKey", "providerProperties", "derivationPathProperty", "detailsProperty", "getSupportedChainsFromProvider", "hubState", "walletState", "accounts", "fromAccountIdToLegacyAddressFormat", "account", "namespacesState", "_", "value", "findProviderByType", "Provider", "props", "api", "useHubAdapter", "getHubProviders", "React", "WalletContext", "__name", "provider_default", "useContext", "useWallets", "context", "useContext", "WalletContext", "__name"]
3
+ "sources": ["../src/provider.tsx", "../src/context.ts", "../src/hub/utils.ts", "../src/legacy/types.ts", "../src/hub/constants.ts", "../src/hub/helpers.ts", "../src/hub/persistor.ts", "../src/hub/lastConnectedWallets.ts", "../src/hub/useHubAdapter.ts", "../src/helpers.ts", "../src/hub/autoConnect.ts", "../src/hub/useAutoConnect.ts", "../src/hub/useHubRefs.ts", "../src/hooks.ts"],
4
+ "sourcesContent": ["import type { ProviderProps } from './types.js';\n\nimport React from 'react';\n\nimport { WalletContext } from './context.js';\nimport { useHubAdapter } from './hub/mod.js';\nimport { getHubProviders } from './hub/utils.js';\n\nfunction Provider(props: ProviderProps) {\n const api = useHubAdapter({\n ...props,\n providers: getHubProviders(props.providers),\n });\n\n return (\n <WalletContext.Provider value={api}>\n {props.children}\n </WalletContext.Provider>\n );\n}\n\nexport default Provider;\n", "import type { ProviderContext } from './types.js';\n\nimport { createContext } from 'react';\n\nconst defaultErrorMessage = \"Context hasn't been initialized yet.\";\nconst defaultContext: ProviderContext = {\n async connect() {\n throw new Error(defaultErrorMessage);\n },\n async disconnect() {\n throw new Error(defaultErrorMessage);\n },\n async disconnectAll() {\n throw new Error(defaultErrorMessage);\n },\n async suggestAndConnect() {\n throw new Error(defaultErrorMessage);\n },\n state() {\n throw new Error(defaultErrorMessage);\n },\n canSwitchNetworkTo() {\n throw new Error(defaultErrorMessage);\n },\n getWalletInfo() {\n throw new Error(defaultErrorMessage);\n },\n getSigners() {\n throw new Error(defaultErrorMessage);\n },\n hubProvider() {\n throw new Error(defaultErrorMessage);\n },\n};\n\nexport const WalletContext = createContext<ProviderContext>(defaultContext);\n", "import type { AllProxiedNamespaces } from './types.js';\nimport type {\n ConnectResult,\n NamespaceInputForConnect,\n EventHandler as WalletEventHandler,\n} from '../legacy/mod.js';\nimport type { ProviderProps } from '../types.js';\nimport type { UtxoActions } from '@hub3js/bip122';\nimport type { Hub, Provider, ProxiedNamespace, WalletType } from '@hub3js/core';\nimport type { Event } from '@hub3js/core/store';\nimport type {\n Chain as AddEthereumChainParameter,\n EvmActions,\n} from '@hub3js/evm';\nimport type { SolanaActions } from '@hub3js/solana';\n\nimport { pickVersion, type VersionedProviders } from '@hub3js/core/utils';\nimport {\n convertEvmBlockchainMetaToEvmChainInfo,\n formatAddressWithNetwork,\n getBlockChainNameFromId,\n getSupportedChainsFromProvider,\n} from '@rango-dev/internal-blockchains';\nimport { AccountId } from 'caip';\nimport { type BlockchainMeta, isEvmBlockchain } from 'rango-types';\n\nimport { Events } from '../legacy/mod.js';\n\nimport { HUB_LAST_CONNECTED_WALLETS } from './constants.js';\nimport {\n fromAccountIdToLegacyAddressFormat,\n isConnectResultEvm,\n isConnectResultSolana,\n} from './helpers.js';\nimport { LastConnectedWalletsFromStorage } from './lastConnectedWallets.js';\n\nexport function getHubProviders(providers: VersionedProviders[]): Provider[] {\n return providers.map((provider) => {\n try {\n return pickVersion(provider, '1.0.0')[1] as Provider;\n } catch {\n throw new Error(\n \"Legacy providers aren't supported anymore. Expected a provider with version '1.0.0'.\"\n );\n }\n });\n}\n\nexport function findProviderByType(\n providers: Provider[],\n type: string\n): Provider | undefined {\n return providers.find((provider) => provider.id === type);\n}\n\n/**\n * We will call this function on hub's `subscribe`.\n * it will check states and will emit legacy events for backward compatibility.\n */\n\nconst lastConnectedWalletsFromStorage = new LastConnectedWalletsFromStorage(\n HUB_LAST_CONNECTED_WALLETS\n);\n\nexport function mapHubEventsToLegacy(\n hub: Hub,\n event: Event,\n onUpdateState: WalletEventHandler,\n metadata: {\n allBlockChains: ProviderProps['allBlockChains'];\n lastConnectAttemptParams: {\n [type: WalletType]: NamespaceInputForConnect[];\n };\n }\n): void {\n const provider = hub.get(event.provider);\n if (!provider) {\n throw new Error(\n \"Currently all the events have assigned to a provider. The event doesn't include one.\",\n {\n cause: event,\n }\n );\n }\n\n // @ts-expect-error for those events that doesn't have namespace, it will be undefinded\n const namespaceId: string | undefined = event.namespace;\n\n const namespace = namespaceId\n ? provider.findByNamespace(namespaceId)\n : undefined;\n let accounts: string[] | null = null;\n let network: string | null = null;\n let derivationPath: string | undefined;\n\n if (namespace) {\n const [getNamespaceState] = namespace.state();\n accounts = getNamespaceState().accounts;\n network = getNamespaceState().network;\n\n if (metadata.lastConnectAttemptParams[event.provider]) {\n derivationPath = metadata.lastConnectAttemptParams[event.provider].find(\n (namespace) => namespace.namespace === namespaceId\n )?.derivationPath;\n }\n }\n\n const [getProviderState] = provider.state();\n const coreState = {\n connected: getProviderState().connected,\n connecting: getProviderState().connecting,\n installed: getProviderState().installed,\n accounts,\n network,\n reachable: true,\n derivationPath,\n };\n\n const detailsProperty = provider\n .info()\n ?.metadata.properties?.find((property) => property.name === 'details');\n\n const eventInfo = {\n supportedBlockchains: getSupportedChainsFromProvider(\n provider,\n metadata.allBlockChains\n ),\n isContractWallet: detailsProperty?.value?.isContractWallet ?? false,\n isHub: true,\n namespace: namespaceId,\n };\n\n switch (event.type) {\n case 'provider_detected':\n onUpdateState(\n event.provider,\n Events.INSTALLED,\n true,\n coreState,\n eventInfo\n );\n break;\n case 'provider_connecting':\n onUpdateState(\n event.provider,\n Events.CONNECTING,\n event.value,\n coreState,\n eventInfo\n );\n break;\n case 'provider_connected':\n onUpdateState(\n event.provider,\n Events.CONNECTED,\n true,\n coreState,\n eventInfo\n );\n break;\n case 'provider_disconnected':\n onUpdateState(\n event.provider,\n Events.PROVIDER_DISCONNECTED,\n event.provider,\n coreState,\n eventInfo\n );\n onUpdateState(\n event.provider,\n Events.CONNECTED,\n false,\n coreState,\n eventInfo\n );\n onUpdateState(\n event.provider,\n Events.ACCOUNTS,\n null,\n coreState,\n eventInfo\n );\n break;\n case 'namespace_disconnected':\n lastConnectedWalletsFromStorage.removeNamespacesFromWallet(\n event.provider,\n [event.namespace]\n );\n\n onUpdateState(\n event.provider,\n Events.NAMESPACE_DISCONNECTED,\n event.namespace,\n coreState,\n {\n ...eventInfo,\n namespace: event.namespace,\n }\n );\n // onUpdateState(event.provider, Events.ACCOUNTS, null, coreState, eventInfo);\n break;\n case 'namespace_connected':\n case 'namespace_account_switched':\n {\n if (event.type === 'namespace_account_switched') {\n onUpdateState(\n event.provider,\n Events.NAMESPACE_DISCONNECTED,\n event.namespace,\n coreState,\n eventInfo\n );\n }\n\n let formattedAddresses: string[] = [];\n if (eventInfo.isContractWallet) {\n formattedAddresses = event.accounts.map((account) => {\n const { chainId, address } = AccountId.parse(account);\n if (typeof chainId === 'string') {\n throw new Error('Should be in CAIP format');\n }\n const blockchainName = getBlockChainNameFromId(\n chainId.reference,\n eventInfo.supportedBlockchains\n );\n\n return blockchainName\n ? formatAddressWithNetwork(address, blockchainName)\n : fromAccountIdToLegacyAddressFormat(account);\n });\n } else {\n formattedAddresses = event.accounts.map((accounts) =>\n fromAccountIdToLegacyAddressFormat(accounts)\n );\n }\n\n onUpdateState(\n event.provider,\n Events.ACCOUNTS,\n formattedAddresses,\n coreState,\n {\n ...eventInfo,\n namespace: event.namespace,\n }\n );\n }\n break;\n case 'namespace_network_switched':\n onUpdateState(event.provider, Events.NETWORK, event.network, coreState, {\n ...eventInfo,\n namespace: event.namespace,\n });\n break;\n }\n}\n\n/**\n * In legacy mode, for those who have switch network functionality (like evm), we are using an enum for network names\n * this enum only has meaning for us, and when we are going to connect an instance (e.g. window.ethereum) we should pass chain id.\n */\nexport function convertNamespaceNetworkToEvmChainId(\n namespace: NamespaceInputForConnect,\n meta: BlockchainMeta[]\n): AddEthereumChainParameter | undefined {\n if (!namespace.network) {\n return undefined;\n }\n\n const evmBlockchainsList = meta.filter(isEvmBlockchain);\n const evmChains = convertEvmBlockchainMetaToEvmChainInfo(evmBlockchainsList);\n\n return evmChains[namespace.network];\n}\n\n/**\n * We are passing an string for chain id (e.g. ETH, POLYGON), but wallet's instances (e.g. window.ethereum) needs chainId (e.g. 0x1).\n * This function will help us to map these strings to proper hex ids.\n */\nexport function tryConvertNamespaceNetworkToChainInfo(\n namespace: NamespaceInputForConnect,\n meta: BlockchainMeta[]\n): string | AddEthereumChainParameter | undefined {\n // `undefined` means it's not evm or we couldn't find it in meta.\n const evmChain = convertNamespaceNetworkToEvmChainId(namespace, meta);\n const network = evmChain || namespace.network;\n\n return network;\n}\n\nexport function transformHubResultToLegacyResult(\n res: Awaited<ReturnType<AllProxiedNamespaces['connect']>>\n): ConnectResult {\n if (isConnectResultEvm(res)) {\n return {\n accounts: res.accounts,\n network: res.network,\n };\n } else if (isConnectResultSolana(res)) {\n return {\n accounts: res,\n network: null,\n };\n }\n\n return {\n accounts: [res],\n network: null,\n };\n}\n\n/**\n * Synchronizes providers in the hub with the configuration providers.\n * - Registers and initializes any configuration providers not yet in the hub\n * - Removes providers from the hub that aren't in the configuration\n */\nexport function synchronizeHubWithConfigProviders(\n hub: Hub,\n configurationProviders: Provider[]\n) {\n const registeredProviders = hub.getAll();\n\n // Register and initialize providers that exist in config but not in hub\n const providersToRegister = configurationProviders.filter(\n (configProvider) => !registeredProviders.get(configProvider.id)\n );\n\n providersToRegister.forEach((providerToRegister) => {\n hub.add(providerToRegister.id, providerToRegister);\n providerToRegister.init();\n });\n\n // Remove providers that exist in hub but not in config\n registeredProviders.forEach((registeredProvider) => {\n const isProviderInConfig = configurationProviders.some(\n (configProvider) => configProvider.id === registeredProvider.id\n );\n\n if (!isProviderInConfig) {\n hub.remove(registeredProvider.id);\n }\n });\n}\n\nexport function isSolanaNamespace(\n ns: AllProxiedNamespaces\n): ns is AllProxiedNamespaces &\n ProxiedNamespace<SolanaActions> & { namespaceId: 'Solana' } {\n return ns.namespaceId === 'Solana';\n}\nexport function isEvmNamespace(\n ns: AllProxiedNamespaces\n): ns is AllProxiedNamespaces &\n ProxiedNamespace<EvmActions> & { namespaceId: 'EVM' } {\n return ns.namespaceId === 'EVM';\n}\nexport function isUtxoNamespace(\n ns: AllProxiedNamespaces\n): ns is AllProxiedNamespaces &\n ProxiedNamespace<UtxoActions> & { namespaceId: 'UTXO' } {\n return ns.namespaceId === 'UTXO';\n}\n", "import type {\n DerivationPathProperty,\n NamespacesProperty,\n ProviderMetadata,\n WalletType,\n} from '@hub3js/core';\nimport type { Namespace } from '@hub3js/namespaces';\nimport type { Network } from '@rango-dev/internal-blockchains';\nimport type { BlockchainMeta, SignerFactory } from 'rango-types';\n\nexport type NamespaceMeta = NamespacesProperty['value']['data'][number];\nexport type NeedsNamespace = NamespacesProperty['value'];\nexport type NeedsDerivationPath = DerivationPathProperty['value'];\n\nexport type InstallObjects = {\n CHROME?: string;\n FIREFOX?: string;\n EDGE?: string;\n BRAVE?: string;\n DEFAULT: string;\n};\n\nexport type WalletInfo = {\n name: string;\n img: string;\n installLink: InstallObjects | string;\n /**\n * @deprecated we don't use this value anymore.\n */\n color: string;\n supportedChains: BlockchainMeta[];\n showOnMobile?: boolean;\n isContractWallet?: boolean;\n mobileWallet?: boolean;\n\n needsDerivationPath?: NeedsDerivationPath;\n needsNamespace?: NeedsNamespace;\n};\n\nexport type WalletState = {\n connected: boolean;\n connecting: boolean;\n /**\n * @deprecated it always returns `false`. don't use it.\n */\n reachable: boolean;\n installed: boolean;\n accounts: string[] | null;\n network: Network | null;\n derivationPath?: string;\n};\n\ntype NamespaceData = {\n namespace: Namespace;\n derivationPath?: string;\n};\n\nexport type NamespaceInputForConnect<T extends Namespace = Namespace> = {\n /**\n * By default, you should specify namespace (e.g. evm).\n */\n namespace: T;\n /**\n * In some cases, we need to connect a specific network on a namespace. e.g. Polygon on EVM.\n */\n network: Network | undefined;\n derivationPath?: string;\n};\n\nexport enum Events {\n CONNECTED = 'connected',\n CONNECTING = 'connecting',\n REACHABLE = 'reachable',\n INSTALLED = 'installed',\n ACCOUNTS = 'accounts',\n NETWORK = 'network',\n // Hub only events\n NAMESPACE_DISCONNECTED = 'namespace_disconnected',\n\n PROVIDER_DISCONNECTED = 'provider_disconnected',\n}\n\nexport type EventInfo = {\n supportedBlockchains: BlockchainMeta[];\n isContractWallet: boolean;\n isHub: boolean;\n // will be set alongside ACCOUNT event\n namespace?: Namespace;\n derivationPath?: string;\n};\n\nexport type EventHandler = (\n type: WalletType,\n event: Events,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n value: any,\n coreState: WalletState,\n info: EventInfo\n) => void;\n\nexport type ConnectResult = {\n accounts: string[] | null;\n network: Network | null;\n};\n\nexport type ExtendedWalletInfo = WalletInfo & {\n properties?: ProviderMetadata['properties'];\n isHub?: boolean;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype InstanceType = any;\n\ntype ProviderConnectResult = {\n accounts: string[];\n chainId: string;\n derivationPath?: string;\n};\n\ntype GetInstanceOptions = {\n network?: Network;\n currentProvider: InstanceType;\n meta: BlockchainMeta[];\n getState: () => WalletState;\n /**\n * We always get the instance once and reuse it whenever we needs. By using this option\n * We can force the library to get a new instance and replace it with the old one.\n *\n * Originally, we used this option for wallet connect 1 and its switching network challenge.\n */\n force?: boolean;\n updateChainId: (chainId: number | string) => void;\n};\n\ntype TryGetInstance =\n | (() => InstanceType)\n | ((\n options: Pick<GetInstanceOptions, 'force' | 'network'>\n ) => Promise<InstanceType>);\n\ntype Connect = (options: {\n instance: InstanceType;\n network?: Network;\n meta: BlockchainMeta[];\n namespaces?: NamespaceData[];\n}) => Promise<ProviderConnectResult | ProviderConnectResult[]>;\n\ntype Disconnect = (options: {\n instance: InstanceType;\n destroyInstance: () => void;\n}) => Promise<void>;\n\ntype CleanupSubscribe = () => void;\n\ntype Subscribe = (options: {\n instance: InstanceType;\n state: WalletState;\n meta: BlockchainMeta[];\n updateChainId: (chainId: string) => void;\n updateAccounts: (accounts: string[], chainId?: string) => void;\n connect: (network?: Network) => void;\n disconnect: () => void;\n}) => CleanupSubscribe | void;\n\ntype SwitchNetwork = (options: {\n instance: InstanceType;\n network: Network;\n meta: BlockchainMeta[];\n newInstance?: TryGetInstance;\n getState?: () => WalletState;\n updateChainId: (chainId: string) => void;\n}) => Promise<void>;\n\ntype Suggest = (options: {\n instance: InstanceType;\n network: Network;\n meta: BlockchainMeta[];\n}) => Promise<void>;\n\ntype CanSwitchNetwork = (options: {\n network: Network;\n meta: BlockchainMeta[];\n provider: InstanceType;\n}) => boolean;\n\ntype CanEagerConnect = (options: {\n instance: InstanceType;\n meta: BlockchainMeta[];\n}) => Promise<boolean>;\n\ninterface WalletActions {\n connect: Connect;\n getInstance: InstanceType;\n disconnect?: Disconnect;\n subscribe?: Subscribe;\n // unsubscribe, // coupled to subscribe.\n\n // Optional, but should be provided at the same time.\n suggest?: Suggest;\n switchNetwork?: SwitchNetwork;\n getSigners: (provider: InstanceType) => Promise<SignerFactory>;\n canSwitchNetworkTo?: CanSwitchNetwork;\n canEagerConnect?: CanEagerConnect;\n getWalletInfo(allBlockChains: BlockchainMeta[]): WalletInfo;\n}\n\ninterface WalletConfig {\n type: WalletType;\n defaultNetwork?: Network;\n checkInstallation?: boolean;\n isAsyncInstance?: boolean;\n isAsyncSwitchNetwork?: boolean;\n}\n\n/**\n * @deprecated Pass a hub `Provider` instead. This type will be removed in future versions.\n */\nexport type ProviderInterface = { config: WalletConfig } & WalletActions;\n", "export const HUB_LAST_CONNECTED_WALLETS = 'hub-v1-last-connected-wallets';\n", "import type { AllProxiedNamespaces } from './types.js';\nimport type { ProviderProps } from '../types.js';\nimport type { Accounts, AccountsWithActiveChain } from '@hub3js/std/types';\nimport type { Result } from 'ts-results';\n\nimport {\n CAIP_BITCOIN_CHAIN_ID,\n CAIP_BITCOINCASH_CHAIN_ID,\n CAIP_DOGECOIN_CHAIN_ID,\n CAIP_LITECOIN_CHAIN_ID,\n CAIP_ZCASH_CHAIN_ID,\n} from '@hub3js/bip122';\nimport { CAIP_NAMESPACE as CAIP_TON_NAMESPACE } from '@hub3js/tvm';\nimport { formatAddressWithNetwork } from '@rango-dev/internal-blockchains';\nimport { CAIP_TRON_CHAIN_ID } from '@rango-dev/wallets-core/namespaces/tron';\nimport { AccountId, type ChainIdParams } from 'caip';\nimport { Err, Ok } from 'ts-results';\n\nexport function mapCaipNamespaceToLegacyNetworkName(\n chainId: ChainIdParams | string\n): string {\n if (typeof chainId === 'string') {\n return chainId;\n }\n const useNamespaceAsNetworkFor = ['solana', 'xrpl', 'stellar'];\n\n if (useNamespaceAsNetworkFor.includes(chainId.namespace.toLowerCase())) {\n return chainId.namespace.toUpperCase();\n }\n\n if (chainId.namespace.toLowerCase() === 'eip155') {\n return 'ETH';\n } else if (chainId.reference === CAIP_BITCOIN_CHAIN_ID) {\n return 'BTC';\n } else if (chainId.reference === CAIP_ZCASH_CHAIN_ID) {\n return 'ZCASH';\n } else if (chainId.reference === CAIP_LITECOIN_CHAIN_ID) {\n return 'LTC';\n } else if (chainId.reference === CAIP_DOGECOIN_CHAIN_ID) {\n return 'DOGE';\n } else if (chainId.reference === CAIP_BITCOINCASH_CHAIN_ID) {\n return 'BCH';\n }\n\n if (chainId.namespace.toLowerCase() === CAIP_TON_NAMESPACE) {\n return 'TON';\n }\n if (chainId.namespace === 'sui' || chainId.reference === CAIP_TRON_CHAIN_ID) {\n return chainId.reference.toUpperCase();\n }\n if (chainId.namespace === 'starknet') {\n return chainId.namespace.toUpperCase();\n }\n\n return chainId.reference;\n}\n\n/**\n * CAIP's accountId has a format like this: eip155:1:0xab16a96D359eC26a11e2C2b3d8f8B8942d5Bfcdb\n * Legacy format is something like this: ETH:0xab16a96D359eC26a11e2C2b3d8f8B8942d5Bfcdb\n * This function will try to convert this two format.\n *\n * @see https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md\n */\nexport function fromAccountIdToLegacyAddressFormat(account: string): string {\n const { chainId, address } = AccountId.parse(account);\n const network = mapCaipNamespaceToLegacyNetworkName(chainId);\n return formatAddressWithNetwork(address, network);\n}\n\n/**\n * Getting a list of (lazy) promises and run them one after another.\n */\n\nexport async function runSequentiallyWithoutFailure<R>(\n promises: Array<() => Promise<R>>\n): Promise<Result<R, unknown>[]> {\n return promises.reduce(async (prevPromise, task) => {\n const previousResults = await prevPromise;\n try {\n const taskResult = await task();\n return [...previousResults, new Ok(taskResult)];\n } catch (error) {\n return [...previousResults, new Err(error)];\n }\n }, Promise.resolve<Result<R, unknown>[]>([]));\n}\n\nexport function isConnectResultEvm(\n result: Awaited<ReturnType<AllProxiedNamespaces['connect']>>\n): result is AccountsWithActiveChain {\n return typeof result === 'object' && !Array.isArray(result);\n}\n\nexport function isConnectResultSolana(\n result: Awaited<ReturnType<AllProxiedNamespaces['connect']>>\n): result is Accounts {\n return Array.isArray(result);\n}\n\ntype QueueItem<T> = {\n task: () => Promise<T>;\n resolve: (value: Result<T, unknown>) => void;\n key: string;\n};\n/**\n * Creates a queue manager that ensures sequential execution of tasks by key.\n * When multiple tasks with the same key are queued, they are executed one at a time\n * in the order they were added. This prevents race conditions and ensures\n * predictable task execution order.\n *\n */\nexport function createQueue(options?: {\n onError?: (\n error: unknown,\n actions: {\n removeCurrentKeyFromQueue: () => void;\n }\n ) => void;\n}) {\n const processingKeys = new Set<string>();\n let queue: QueueItem<unknown>[] = [];\n\n const removeKeyFromQueue = (\n key: string,\n result: Result<unknown, unknown>\n ) => {\n queue = queue.filter((q) => {\n if (q.key !== key) {\n return true;\n }\n q.resolve(result);\n return false;\n });\n };\n\n const processQueue = async () => {\n const currentItem = queue.find((item) => !processingKeys.has(item.key));\n if (!currentItem) {\n return;\n }\n\n const { task, resolve, key } = currentItem;\n processingKeys.add(key);\n\n try {\n const result = await task();\n resolve(new Ok(result));\n } catch (error) {\n if (options?.onError) {\n options.onError(error, {\n removeCurrentKeyFromQueue: () =>\n removeKeyFromQueue(key, new Err(error)),\n });\n }\n\n resolve(new Err(error));\n } finally {\n const indexOfCurrentItem = queue.findIndex((item) => item.key === key);\n if (indexOfCurrentItem >= 0) {\n queue.splice(indexOfCurrentItem, 1);\n }\n processingKeys.delete(key);\n void processQueue();\n }\n };\n\n const queueTask = async <T>(\n task: () => Promise<T>,\n key: string\n ): Promise<Result<T, unknown>> =>\n new Promise((resolve) => {\n queue.push({\n task,\n resolve: resolve as (value: Result<unknown, unknown>) => void,\n key,\n });\n void processQueue();\n });\n\n return queueTask;\n}\n\nexport function shouldTryAutoConnect(\n props: Pick<ProviderProps, 'allBlockChains' | 'autoConnect'>\n): boolean {\n return !!props.allBlockChains?.length && !!props.autoConnect;\n}\n", "export interface PersistStorage<T> {\n getItem: (name: string) => T | null;\n setItem: (name: string, value: T) => void;\n removeItem: (name: string) => void;\n}\n\nexport class Persistor<T> implements PersistStorage<T> {\n getItem(name: string) {\n const item = localStorage.getItem(name);\n const parsedItem = item ? (JSON.parse(item) as T) : null;\n return parsedItem;\n }\n setItem(name: string, value: T) {\n localStorage.setItem(name, JSON.stringify(value));\n }\n removeItem(name: string) {\n localStorage.removeItem(name);\n }\n}\n", "import type { Namespace } from '@hub3js/namespaces';\n\nimport { HUB_LAST_CONNECTED_WALLETS } from './constants.js';\nimport { Persistor } from './persistor.js';\n\nexport interface NamespaceInput {\n namespace: Namespace;\n network: string | undefined;\n}\n\nexport interface LastConnectedWalletsStorage {\n [providerId: string]: NamespaceInput[];\n}\n\n/**\n * We are doing some certain actions on storage for `last-connected-wallets` key.\n * This class helps us to define them in one place.\n */\nexport class LastConnectedWalletsFromStorage {\n #storageKey: string;\n\n constructor(storageKey: string) {\n this.#storageKey = storageKey;\n }\n\n addWallet(providerId: string, namespaces: NamespaceInput[]): void {\n if (this.#storageKey === HUB_LAST_CONNECTED_WALLETS) {\n return this.#addWalletToHub(providerId, namespaces);\n }\n throw new Error('Not implemented');\n }\n removeWallets(providerIds?: string[]): void {\n if (this.#storageKey === HUB_LAST_CONNECTED_WALLETS) {\n return this.#removeWalletsFromHub(providerIds);\n }\n throw new Error('Not implemented');\n }\n list(): LastConnectedWalletsStorage {\n if (this.#storageKey === HUB_LAST_CONNECTED_WALLETS) {\n return this.#listFromHub();\n }\n throw new Error('Not implemented');\n }\n removeNamespacesFromWallet(providerId: string, namespaceIds: string[]) {\n if (this.#storageKey === HUB_LAST_CONNECTED_WALLETS) {\n return this.#removeNamespaceFromWalletHub(providerId, namespaceIds);\n }\n throw new Error('Not implemented');\n }\n\n #listFromHub(): LastConnectedWalletsStorage {\n const persistor = new Persistor<LastConnectedWalletsStorage>();\n const lastConnectedWallets =\n persistor.getItem(HUB_LAST_CONNECTED_WALLETS) || {};\n return lastConnectedWallets;\n }\n #addWalletToHub(providerId: string, namespaces: NamespaceInput[]): void {\n const storage = new Persistor<LastConnectedWalletsStorage>();\n const storageState = storage.getItem(this.#storageKey) || {};\n\n let toBeAddedNamespaces = namespaces;\n\n // If provider already exits in the storage, we should just add new namespaces to the previously added namespaces.\n if (!!storageState[providerId]) {\n const storedNamespaces = storageState[providerId];\n toBeAddedNamespaces = storedNamespaces.concat(\n namespaces.filter(\n (namespace) =>\n !storedNamespaces.some(\n (storedNamespace) =>\n storedNamespace.namespace === namespace.namespace\n )\n )\n );\n }\n\n storage.setItem(this.#storageKey, {\n ...storageState,\n [providerId]: toBeAddedNamespaces,\n });\n }\n #removeWalletsFromHub(providerIds?: string[]): void {\n const persistor = new Persistor<LastConnectedWalletsStorage>();\n const storageState = persistor.getItem(this.#storageKey) || {};\n\n // Remove all wallets\n if (!providerIds) {\n persistor.setItem(this.#storageKey, {});\n return;\n }\n\n // Remove some of the wallets\n providerIds.forEach((providerId) => {\n if (storageState[providerId]) {\n delete storageState[providerId];\n }\n });\n\n persistor.setItem(this.#storageKey, storageState);\n }\n #removeNamespaceFromWalletHub(\n providerId: string,\n namespaceIds: string[]\n ): void {\n const persistor = new Persistor<LastConnectedWalletsStorage>();\n const storageState = persistor.getItem(this.#storageKey) || {};\n\n const currentProviderNamespaces = storageState[providerId];\n const newProviderNamespaces = currentProviderNamespaces?.filter(\n (namespace) => !namespaceIds.includes(namespace.namespace)\n );\n\n this.#removeWalletsFromHub([providerId]);\n if (newProviderNamespaces?.length > 0) {\n this.#addWalletToHub(providerId, newProviderNamespaces);\n }\n }\n}\n", "import type { AllProxiedNamespaces, ExtensionLink } from './types.js';\nimport type {\n ConnectResult,\n NamespaceInputForConnect,\n WalletInfo,\n} from '../legacy/mod.js';\nimport type { ProviderContext, ProviderProps } from '../types.js';\nimport type { Provider, WalletType } from '@hub3js/core';\nimport type { Accounts, AccountsWithActiveChain } from '@hub3js/std/types';\n\nimport { isUserRejectionError, WalletConnectionError } from '@hub3js/std/utils';\nimport {\n getSupportedChainsFromNamespace,\n getSupportedChainsFromProvider,\n} from '@rango-dev/internal-blockchains';\nimport { useEffect, useRef, useState } from 'react';\nimport { Ok, Result } from 'ts-results';\n\nimport { withErrorLoggingApi } from '../helpers.js';\n\nimport { autoConnect } from './autoConnect.js';\nimport { HUB_LAST_CONNECTED_WALLETS } from './constants.js';\nimport { createQueue, fromAccountIdToLegacyAddressFormat } from './helpers.js';\nimport { LastConnectedWalletsFromStorage } from './lastConnectedWallets.js';\nimport { useAutoConnect } from './useAutoConnect.js';\nimport { useHubRefs } from './useHubRefs.js';\nimport {\n findProviderByType,\n isEvmNamespace,\n isSolanaNamespace,\n isUtxoNamespace,\n mapHubEventsToLegacy,\n transformHubResultToLegacyResult,\n tryConvertNamespaceNetworkToChainInfo,\n} from './utils.js';\n\nexport type UseAdapterParams = Omit<ProviderProps, 'providers'> & {\n providers: Provider[];\n};\n\nexport function useHubAdapter(params: UseAdapterParams): ProviderContext {\n const { getStore, getHub } = useHubRefs(params.providers);\n const [, rerender] = useState(0);\n // useEffect will run `subscribe` once, so we need a reference and mutate the value if it's changes.\n const dataRef = useRef({\n onUpdateState: params.onUpdateState,\n allBlockChains: params.allBlockChains,\n });\n const hubInitiated = useRef(false);\n\n /*\n * Params of each connection attempt for each wallet type are stored here.\n * Derivation path from params is used in `mapHubEventsToLegacy` to be added to the payload of connect events.\n */\n const lastConnectAttemptParamsRef = useRef<{\n [type: WalletType]: NamespaceInputForConnect[];\n }>({});\n\n const updateLastConnectAttemptParams = (\n type: WalletType,\n namespaces: NamespaceInputForConnect[] | undefined\n ) => {\n lastConnectAttemptParamsRef.current[type] = namespaces || [];\n };\n\n const queueTask = createQueue({\n onError: (error, actions) => {\n // A connection failure carries the wallet's own error, and so its code, as its cause.\n const walletError =\n error instanceof WalletConnectionError ? error.cause : error;\n if (isUserRejectionError(walletError)) {\n actions.removeCurrentKeyFromQueue();\n }\n },\n });\n\n useEffect(() => {\n dataRef.current = {\n onUpdateState: params.onUpdateState,\n allBlockChains: params.allBlockChains,\n };\n }, [params]);\n\n useEffect(() => {\n getStore()\n .subscribe((event) => {\n if (dataRef.current.onUpdateState) {\n try {\n mapHubEventsToLegacy(\n getHub(),\n event,\n dataRef.current.onUpdateState,\n {\n allBlockChains: dataRef.current.allBlockChains,\n lastConnectAttemptParams: lastConnectAttemptParamsRef.current,\n }\n );\n } catch (e) {\n console.error(e);\n }\n }\n rerender((currentRender) => currentRender + 1);\n })\n .flushEvents();\n }, []);\n\n // Initialize hub only after blockchain meta is available (e.g. WalletConnect needs it at init).\n useEffect(() => {\n if (hubInitiated.current || !params.allBlockChains?.length) {\n return;\n }\n\n getHub().init(params.configs?.walletOptions);\n rerender((currentRender) => currentRender + 1);\n hubInitiated.current = true;\n }, [params.allBlockChains, params.configs?.walletOptions]);\n\n useAutoConnect({\n autoConnect: params.autoConnect,\n allBlockChains: params.allBlockChains,\n autoConnectHandler: () => {\n void autoConnect({\n allBlockChains: params.allBlockChains,\n getHub,\n wallets: params.configs?.wallets,\n });\n },\n });\n\n const lastConnectedWalletsFromStorage = new LastConnectedWalletsFromStorage(\n HUB_LAST_CONNECTED_WALLETS\n );\n\n const api: ProviderContext = {\n canSwitchNetworkTo(type, network, namespace) {\n const provider = getHub().get(type);\n\n if (!provider) {\n // TODO: should throw an error\n return false;\n }\n\n if (!namespace) {\n throw new Error(\n 'Passing namespace to `canSwitchNetworkTo` is required.'\n );\n }\n\n const proxiedNamespace = provider.findByNamespace(namespace.namespace);\n if (!proxiedNamespace) {\n throw new Error(\n `We couldn't find any matched namespace on your request provider. (requested namespace: ${namespace.namespace})`\n );\n }\n if (!('canSwitchNetwork' in proxiedNamespace)) {\n return false;\n }\n const namespacesProperty = provider\n .info()\n ?.metadata?.properties?.find(\n (property) => property.name === 'namespaces'\n );\n\n if (!dataRef.current.allBlockChains) {\n throw new Error(`Blockchains are not available`);\n }\n\n const namespaceMeta = namespacesProperty?.value.data.find(\n (providerNamespace) => providerNamespace.value === namespace.namespace\n );\n\n if (!namespaceMeta) {\n throw new Error(\n `NamespaceMeta is not defined for requested namespace: ${namespace.namespace}`\n );\n }\n\n const supportedChains = getSupportedChainsFromNamespace(\n namespaceMeta,\n dataRef.current.allBlockChains\n );\n\n return proxiedNamespace.canSwitchNetwork({\n network,\n supportedChains,\n });\n },\n async connect(type, namespaces) {\n const wallet = getHub().get(type);\n if (!wallet) {\n throw new Error(\n `You should add ${type} to provider first then call 'connect'.`\n );\n }\n\n if (!namespaces) {\n throw new Error('Passing namespace to `connect` is required.');\n }\n\n updateLastConnectAttemptParams(type, namespaces);\n\n // Check `namespace` and look into hub to see how it can match given namespace to hub namespace.\n const targetNamespaces: [\n NamespaceInputForConnect,\n AllProxiedNamespaces\n ][] = [];\n namespaces.forEach((namespace) => {\n const targetNamespace = namespace.namespace;\n\n const result = wallet.findByNamespace(targetNamespace);\n if (!result) {\n throw new Error(\n `We couldn't find any provider matched with your request namespace. (requested namespace: ${namespace.namespace})`\n );\n }\n\n targetNamespaces.push([namespace, result]);\n });\n\n // Try to run `connect` on matched namespaces\n const connectResultFromTargetNamespaces = targetNamespaces.map(\n async ([namespaceInput, namespace]) => {\n const network = tryConvertNamespaceNetworkToChainInfo(\n namespaceInput,\n params.allBlockChains || []\n );\n\n let connectNamespacePromise: () => Promise<\n Accounts | AccountsWithActiveChain\n >;\n\n if (isSolanaNamespace(namespace)) {\n connectNamespacePromise = async () =>\n namespace.connect({\n derivationPath: namespaceInput.derivationPath,\n });\n } else if (isEvmNamespace(namespace)) {\n connectNamespacePromise = async () =>\n namespace.connect(network, {\n derivationPath: namespaceInput.derivationPath,\n });\n } else if (isUtxoNamespace(namespace)) {\n connectNamespacePromise = async () =>\n namespace.connect({\n derivationPath: namespaceInput.derivationPath,\n });\n } else {\n connectNamespacePromise = async () => namespace.connect();\n }\n\n const connectNamespaceProcess = async () =>\n connectNamespacePromise()\n .then<ConnectResult>(transformHubResultToLegacyResult)\n .then((connectResult) => {\n return {\n response: connectResult,\n input: {\n namespace: namespaceInput.namespace,\n network: namespaceInput.network,\n supportsEagerConnect: 'canEagerConnect' in namespace,\n },\n };\n });\n return queueTask(connectNamespaceProcess, type);\n }\n );\n\n /*\n * We need to connect to namespace one after another, sending multiple requests at the same time may be failed.\n * e.g. when wallet popup opens and asking for the password from the user, it should be resolved first, then other request will be resolved.\n */\n const connectResultWithLegacyFormat = await Promise.all(\n connectResultFromTargetNamespaces\n );\n\n // Keeping only namespaces that connected successfully and support eager connect, then we'll store them on storage for auto connect functionality.\n const successfullyConnectedSupportingEagerConnectNamespaces =\n connectResultWithLegacyFormat\n .filter(<T, E>(result: Result<T, E>): result is Ok<T> => result.ok)\n .filter((result) => result.val.input.supportsEagerConnect)\n .map((result) => ({\n namespace: result.val.input.namespace,\n network: result.val.input.network,\n }));\n\n if (successfullyConnectedSupportingEagerConnectNamespaces.length > 0) {\n lastConnectedWalletsFromStorage.addWallet(\n type,\n successfullyConnectedSupportingEagerConnectNamespaces\n );\n }\n\n // Getting rid of `input` from Result\n const connectResults = connectResultWithLegacyFormat.map((result) =>\n result.andThen((okResult) => new Ok(okResult.response))\n );\n\n const allResult = Result.all(...connectResults);\n if (allResult.err) {\n throw allResult.val;\n }\n\n return allResult.unwrap();\n },\n async disconnect(type, namespaces) {\n const wallet = getHub().get(type);\n if (!wallet) {\n throw new Error(\n `You should add ${type} to provider first then call 'disconnect'.`\n );\n }\n\n wallet.getAll().forEach((namespace) => {\n const namespaceShouldBeDisconnected =\n !namespaces || namespaces.includes(namespace.namespaceId);\n const namespaceIsConnected = namespace.state()[0]().connected;\n if (namespaceShouldBeDisconnected && namespaceIsConnected) {\n return namespace.disconnect();\n }\n });\n\n if (params.autoConnect) {\n if (namespaces) {\n lastConnectedWalletsFromStorage.removeNamespacesFromWallet(\n type,\n namespaces\n );\n } else {\n lastConnectedWalletsFromStorage.removeWallets([type]);\n }\n }\n },\n async disconnectAll() {\n const disconnectPromises: Promise<void>[] = Array.from(\n getHub().getAll().values()\n ).map(async (provider) => this.disconnect(provider.id));\n\n return await Promise.allSettled(disconnectPromises);\n },\n async getSigners(type) {\n const wallet = getHub().get(type);\n if (!wallet) {\n throw new Error(`You should add ${type} to provider first.`);\n }\n\n const info = wallet.info();\n if (!info) {\n throw new Error('Your provider should have required `info`.');\n }\n\n const providerProperties = info.metadata.properties;\n\n const signerProperty = providerProperties?.find(\n (property) => property.name === 'signers'\n );\n if (!signerProperty) {\n throw new Error('Your provider should contain signers property.');\n }\n\n return signerProperty.value.getSigners();\n },\n getWalletInfo(type) {\n const wallet = getHub().get(type);\n if (!wallet) {\n throw new Error(`You should add ${type} to provider first.`);\n }\n\n const info = wallet.info();\n if (!info) {\n throw new Error('Your provider should have required `info`.');\n }\n\n const installLink: Exclude<WalletInfo['installLink'], string> = {\n DEFAULT: '',\n };\n\n const { metadata } = info;\n const { extensions } = metadata;\n // `extensions` in legacy format was uppercase and also `DEFAULT` was used instead of `homepage`\n Object.keys(extensions).forEach((k) => {\n const key = k as ExtensionLink;\n\n if (key === 'homepage') {\n installLink.DEFAULT = extensions[key] || '';\n }\n\n const allowedKeys: ExtensionLink[] = [\n 'firefox',\n 'chrome',\n 'brave',\n 'edge',\n ];\n if (allowedKeys.includes(key)) {\n const upperCasedKey = key.toUpperCase() as keyof Exclude<\n WalletInfo['installLink'],\n string\n >;\n installLink[upperCasedKey] = extensions[key] || '';\n }\n });\n\n const providerProperties = metadata.properties;\n\n const namespacesProperty = providerProperties?.find(\n (property) => property.name === 'namespaces'\n );\n const derivationPathProperty = providerProperties?.find(\n (property) => property.name === 'derivationPath'\n );\n const detailsProperty = providerProperties?.find(\n (property) => property.name === 'details'\n );\n\n return {\n name: metadata.name,\n img: metadata.icon,\n installLink: installLink,\n // We don't have this values anymore, fill them with some values that communicate this.\n color: 'red',\n supportedChains: getSupportedChainsFromProvider(\n wallet,\n dataRef.current.allBlockChains\n ),\n isContractWallet: detailsProperty?.value?.isContractWallet,\n mobileWallet: detailsProperty?.value?.mobileWallet,\n // if set to false here, it will not show the wallet in mobile in anyways. to be compatible with old behavior, undefined is more appropirate.\n showOnMobile: detailsProperty?.value?.showOnMobile,\n needsNamespace: namespacesProperty?.value,\n needsDerivationPath: derivationPathProperty?.value,\n isHub: true,\n properties: metadata.properties,\n };\n },\n state(type) {\n const hubState = getHub().state();\n const wallet = getHub().get(type);\n const walletState = hubState[type];\n\n if (!walletState || !wallet) {\n // TODO: should throw an error\n return {\n connected: false,\n connecting: false,\n installed: false,\n reachable: false,\n accounts: null,\n network: null,\n namespaces: new Map(),\n };\n }\n\n const accounts = walletState.namespaces\n .filter((namespace) => namespace.connected)\n .flatMap((namespace) =>\n namespace.accounts?.map((accounts) =>\n fromAccountIdToLegacyAddressFormat(accounts)\n )\n )\n .filter((account): account is string => !!account);\n\n const namespacesState = new Map(\n Array.from(wallet.getAll(), ([_, value]) => [\n value.namespaceId,\n value.state()[0](),\n ])\n );\n\n const coreState = {\n connected: walletState.connected,\n connecting: walletState.connecting,\n installed: walletState.installed,\n reachable: true,\n accounts: accounts,\n network: null,\n namespaces: namespacesState,\n };\n return coreState;\n },\n async suggestAndConnect(type, namespace): Promise<ConnectResult> {\n const provider = getHub().get(type);\n\n if (!provider) {\n throw new Error(\n `You should add ${type} to provider first then call 'suggestAndConnect'.`\n );\n }\n const proxiedNamespace = provider.findByNamespace(namespace.namespace);\n if (!proxiedNamespace) {\n throw new Error(\n `We couldn't find any matched namespace on your request provider. (requested namespace: ${namespace.namespace})`\n );\n }\n if (!('suggest' in proxiedNamespace)) {\n throw new Error('Suggest is not implemented on the provider');\n }\n if (!namespace.network) {\n throw new Error('You should pass network to the suggest and connect');\n }\n throw new Error(\n `Suggest has not been implemented for given chain: ${namespace.network}`\n );\n },\n hubProvider(type) {\n const provider = findProviderByType(params.providers, type);\n\n if (!provider) {\n throw new Error(\n `You're trying to access ${type} provider which is not found in hub providers. it may not be registered yet.`\n );\n }\n\n return provider;\n },\n };\n\n return withErrorLoggingApi(api);\n}\n", "import type { ProviderContext } from './types.js';\n\nimport { debug } from '@rango-dev/logging-core';\n\nfunction logError(method: string, args: unknown[], error: unknown) {\n const err = error instanceof Error ? error : new Error(String(error));\n debug(err, {\n context: { method, args },\n tags: { type: 'wallet-error' },\n });\n}\n\nfunction withErrorLogging<TArgs extends unknown[], TReturn>(\n method: string,\n fn: (...args: TArgs) => TReturn\n): (...args: TArgs) => TReturn {\n return (...args: TArgs): TReturn => {\n try {\n const result = fn(...args);\n // Async method: catch the rejection, log, then throw the rejection.\n if (result instanceof Promise) {\n return result.catch((error: unknown) => {\n logError(method, args, error);\n throw error;\n }) as TReturn;\n }\n return result;\n } catch (error) {\n // Sync method: log and rethrow.\n logError(method, args, error);\n throw error;\n }\n };\n}\n\nexport function withErrorLoggingApi(api: ProviderContext): ProviderContext {\n const entries = Object.entries(api).map(([key, value]) => [\n key,\n withErrorLogging(key, (value as (...args: unknown[]) => unknown).bind(api)),\n ]);\n\n return Object.fromEntries(entries) as ProviderContext;\n}\n", "import type { AllProxiedNamespaces } from './types.js';\nimport type { UseAdapterParams } from './useHubAdapter.js';\nimport type { NamespaceInputForConnect } from '../legacy/types.js';\nimport type { Hub, Provider, WalletType } from '@hub3js/core';\nimport type { DefaultNamespaces, Namespace } from '@hub3js/namespaces';\nimport type { Accounts, AccountsWithActiveChain } from '@hub3js/std/types';\n\nimport { Result } from 'ts-results';\n\nimport { HUB_LAST_CONNECTED_WALLETS } from './constants.js';\nimport { runSequentiallyWithoutFailure } from './helpers.js';\nimport { LastConnectedWalletsFromStorage } from './lastConnectedWallets.js';\nimport {\n convertNamespaceNetworkToEvmChainId,\n isEvmNamespace,\n} from './utils.js';\n\nfunction isEvmNamespaceInput(\n namespace: NamespaceInputForConnect\n): namespace is NamespaceInputForConnect<'EVM'> {\n return namespace.namespace === 'EVM';\n}\n\n// Getting connected wallets from storage\nconst lastConnectedWalletsFromStorage = new LastConnectedWalletsFromStorage(\n HUB_LAST_CONNECTED_WALLETS\n);\n\n/**\n * Run `.connect` action on some selected namespaces (passed as param) for a provider.\n */\nasync function eagerConnect(\n type: string,\n namespacesInput: NamespaceInputForConnect[] | undefined,\n params: {\n getHub: () => Hub;\n allBlockChains: UseAdapterParams['allBlockChains'];\n }\n) {\n const { getHub, allBlockChains } = params;\n const wallet = getHub().get(type);\n if (!wallet) {\n throw new Error(\n `You should add ${type} to provider first then call 'connect'.`\n );\n }\n\n if (!namespacesInput) {\n throw new Error('Passing namespace to `connect` is required. ');\n }\n\n const targetNamespaces: [NamespaceInputForConnect, AllProxiedNamespaces][] =\n [];\n namespacesInput.forEach((namespaceInput) => {\n const targetNamespace: Namespace = namespaceInput.namespace;\n\n const result = wallet.findByNamespace(targetNamespace);\n\n if (!result) {\n throw new Error(\n `We couldn't find any provider matched with your request namespace. (requested namespace: ${namespaceInput.namespace})`\n );\n }\n\n targetNamespaces.push([namespaceInput, result]);\n });\n\n const connectNamespacesPromises = targetNamespaces.map(\n ([info, namespace]) => {\n const evmChain = isEvmNamespaceInput(info)\n ? convertNamespaceNetworkToEvmChainId(info, allBlockChains || [])\n : undefined;\n const chain = evmChain || info.network;\n\n return async () => {\n let connectNamespacePromise: () => Promise<\n Accounts | AccountsWithActiveChain\n >;\n if (isEvmNamespace(namespace)) {\n connectNamespacePromise = async () => namespace.connect(chain);\n } else {\n connectNamespacePromise = async () => namespace.connect();\n }\n try {\n await connectNamespacePromise();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n /*\n * Since we check for connect failures using `instanceof Error`\n * this check is added here to make sure the thrown error always is an instance of `Error`\n */\n if (e instanceof Error) {\n throw e;\n }\n throw new Error(e);\n }\n };\n }\n );\n\n /**\n * Sometimes calling methods on a instance in parallel, would cause an error in wallet.\n * We are running a method at a time to make sure we are covering this.\n * e.g. when we are trying to eagerConnect evm and solana on phantom at the same time, the last namespace throw an error.\n */\n const connectNamespacesResult = await runSequentiallyWithoutFailure(\n connectNamespacesPromises\n );\n\n const failedNamespaces: NamespaceInputForConnect[] = targetNamespaces\n .filter((_, index) => connectNamespacesResult[index].err)\n .map((targetNamespace) => targetNamespace[0]);\n\n if (failedNamespaces.length > 0) {\n lastConnectedWalletsFromStorage.removeNamespacesFromWallet(\n type,\n failedNamespaces.map((namespace) => namespace.namespace)\n );\n }\n\n const atLeastOneNamespaceConnectedSuccessfully = connectNamespacesResult.some(\n (result) => result.ok\n );\n if (!atLeastOneNamespaceConnectedSuccessfully) {\n throw new Error(`No namespace connected for ${type}`);\n }\n return Result.all(\n ...connectNamespacesResult.filter((result) => result.ok)\n ).unwrap();\n}\n\n/**\n * Run `.canEagerConnect` action on some selected namespaces of a wallet.\n */\nasync function tryRunCanEagerConnect(\n namespaces: NamespaceInputForConnect[],\n wallet: Provider<DefaultNamespaces>\n): Promise<{\n successNamespaces: NamespaceInputForConnect[];\n failedNamespaces: NamespaceInputForConnect[];\n}> {\n const foundNamespaces: NamespaceInputForConnect[] = [];\n const successNamespaces: NamespaceInputForConnect[] = [];\n const failedNamespaces: NamespaceInputForConnect[] = [];\n const canEagerConnectPromises: (() => Promise<boolean>)[] = [];\n\n // 1. Try find namespace instances and create canEagerConnect promises\n namespaces.forEach((namespace) => {\n const namespaceInstance = wallet.findByNamespace(namespace.namespace);\n if (namespaceInstance) {\n foundNamespaces.push(namespace);\n canEagerConnectPromises.push(\n async () => await namespaceInstance.canEagerConnect()\n );\n } else {\n failedNamespaces.push(namespace);\n }\n });\n\n // 2. Run canEagerConnect sequentially on namespaces\n const canEagerConnectResults = await runSequentiallyWithoutFailure(\n canEagerConnectPromises\n );\n\n // 3. Separate success and failed namespaces based on canEagerConnect result\n foundNamespaces.forEach((namespace, index) => {\n if (canEagerConnectResults[index].ok && canEagerConnectResults[index].val) {\n successNamespaces.push(namespace);\n } else {\n failedNamespaces.push(namespace);\n }\n });\n\n return { successNamespaces, failedNamespaces };\n}\n\n/*\n * Get last connected wallets and last connected namespaces for each of them from storage\n * Then run `.connect` on each namespace if `.canEagerConnect` returns true.\n */\nexport async function autoConnect(deps: {\n getHub: () => Hub;\n allBlockChains: UseAdapterParams['allBlockChains'];\n wallets?: (WalletType | Provider)[];\n}): Promise<void> {\n const { getHub, allBlockChains, wallets } = deps;\n const lastConnectedWallets = lastConnectedWalletsFromStorage.list();\n const walletIds = Object.keys(lastConnectedWallets);\n\n const walletsToRemoveFromPersistence: string[] = [];\n\n if (walletIds.length) {\n const eagerConnectQueue: Promise<unknown>[] = [];\n\n const configWalletNames = wallets?.map((wallet) =>\n typeof wallet === 'string' ? wallet : wallet.id\n );\n // Run `.connect` if `.canEagerConnect` returns `true`.\n walletIds.forEach(async (providerName) => {\n if (configWalletNames && !configWalletNames.includes(providerName)) {\n console.warn(\n 'Trying to run auto connect for a wallet which is not included in config. Desired wallet:',\n providerName\n );\n walletsToRemoveFromPersistence.push(providerName);\n return;\n }\n\n const wallet = getHub().get(providerName);\n\n const lastConnectedNamespaces: NamespaceInputForConnect[] =\n lastConnectedWallets[providerName].map((namespace) => ({\n namespace: namespace.namespace,\n network: namespace.network,\n }));\n\n if (!lastConnectedNamespaces.length || !wallet) {\n walletsToRemoveFromPersistence.push(providerName);\n return;\n }\n\n const { successNamespaces, failedNamespaces } =\n await tryRunCanEagerConnect(lastConnectedNamespaces, wallet);\n\n if (!successNamespaces.length) {\n walletsToRemoveFromPersistence.push(providerName);\n return;\n } else if (failedNamespaces.length) {\n lastConnectedWalletsFromStorage.removeNamespacesFromWallet(\n wallet.id,\n failedNamespaces.map((namespace) => namespace.namespace)\n );\n }\n eagerConnectQueue.push(\n eagerConnect(providerName, successNamespaces, {\n allBlockChains,\n getHub,\n }).catch((error) => console.warn(error))\n );\n });\n\n lastConnectedWalletsFromStorage.removeWallets(\n walletsToRemoveFromPersistence\n );\n\n await Promise.all(eagerConnectQueue);\n }\n}\n", "import type { ProviderProps } from '../types.js';\n\nimport { useEffect, useRef } from 'react';\n\nimport { shouldTryAutoConnect } from './helpers.js';\n\nexport function useAutoConnect(\n props: Pick<ProviderProps, 'allBlockChains' | 'autoConnect'> & {\n /**\n * A function to run autoConnect on instances\n */\n autoConnectHandler: () => void;\n }\n) {\n const autoConnectInitiated = useRef(false);\n\n useEffect(() => {\n if (shouldTryAutoConnect(props) && !autoConnectInitiated.current) {\n autoConnectInitiated.current = true;\n props.autoConnectHandler();\n }\n }, [props.autoConnect, props.allBlockChains]);\n}\n", "import type { Provider, Store } from '@hub3js/core';\n\nimport { createStore, Hub } from '@hub3js/core';\nimport { useRef } from 'react';\n\nimport { synchronizeHubWithConfigProviders } from './utils.js';\n\nexport function useHubRefs(providers: Provider[]) {\n const store = useRef<Store | null>(null);\n\n const hub = useRef<Hub | null>(null);\n\n function createHub() {\n const createdHub = new Hub({\n store: getStore(),\n });\n /*\n * First add providers to hub\n * This helps to `getWalletInfo` be usable, before initialize.\n */\n providers.forEach((provider) => {\n createdHub.add(provider.id, provider);\n });\n hub.current = createdHub;\n return createdHub;\n }\n\n // https://react.dev/reference/react/useRef#avoiding-recreating-the-ref-contents\n function getStore() {\n if (store.current !== null) {\n return store.current;\n }\n const createdStore = createStore();\n store.current = createdStore;\n return createdStore;\n }\n\n function getHub(): Hub {\n const hubProviders = hub.current?.getAll();\n\n if (!hub.current || !hubProviders) {\n return createHub();\n }\n\n synchronizeHubWithConfigProviders(hub.current, providers);\n return hub.current;\n }\n\n return { getStore, getHub };\n}\n", "import type { ProviderContext } from './types.js';\n\nimport { useContext } from 'react';\n\nimport { WalletContext } from './context.js';\n\nexport function useWallets(): ProviderContext {\n const context = useContext(WalletContext);\n if (!context) {\n throw Error('useWallet can only be used within the Provider component');\n }\n return context;\n}\n"],
5
+ "mappings": "iFAEA,OAAOA,OAAW,QCAlB,OAAS,iBAAAC,OAAqB,QAE9B,IAAMC,EAAsB,uCACtBC,GAAkC,CACtC,MAAM,SAAU,CACd,MAAM,IAAI,MAAMD,CAAmB,CACrC,EACA,MAAM,YAAa,CACjB,MAAM,IAAI,MAAMA,CAAmB,CACrC,EACA,MAAM,eAAgB,CACpB,MAAM,IAAI,MAAMA,CAAmB,CACrC,EACA,MAAM,mBAAoB,CACxB,MAAM,IAAI,MAAMA,CAAmB,CACrC,EACA,OAAQ,CACN,MAAM,IAAI,MAAMA,CAAmB,CACrC,EACA,oBAAqB,CACnB,MAAM,IAAI,MAAMA,CAAmB,CACrC,EACA,eAAgB,CACd,MAAM,IAAI,MAAMA,CAAmB,CACrC,EACA,YAAa,CACX,MAAM,IAAI,MAAMA,CAAmB,CACrC,EACA,aAAc,CACZ,MAAM,IAAI,MAAMA,CAAmB,CACrC,CACF,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AM,YACNA,EAAM,MAAM,EAAE,CAAC,EAAE,CACnB,CAAC,CACH,EAWA,MATkB,CAChB,UAAWN,EAAY,UACvB,WAAYA,EAAY,WACxB,UAAWA,EAAY,UACvB,UAAW,GACX,SAAUC,EACV,QAAS,KACT,WAAYG,CACd,CAEF,EACA,MAAM,kBAAkBtE,EAAMqB,EAAmC,CAC/D,IAAMC,EAAWhC,EAAO,EAAE,IAAIU,CAAI,EAElC,GAAI,CAACsB,EACH,MAAM,IAAI,MACR,kBAAkBtB,CAAI,mDACxB,EAEF,IAAMuB,EAAmBD,EAAS,gBAAgBD,EAAU,SAAS,EACrE,MAAKE,EAKC,YAAaA,EAGdF,EAAU,QAGT,IAAI,MACR,qDAAqDA,EAAU,OAAO,EACxE,EAJQ,IAAI,MAAM,oDAAoD,EAH9D,IAAI,MAAM,4CAA4C,EALtD,IAAI,MACR,0FAA0FA,EAAU,SAAS,GAC/G,CAWJ,EACA,YAAYrB,EAAM,CAChB,IAAMsB,EAAWmD,EAAmBrF,EAAO,UAAWY,CAAI,EAE1D,GAAI,CAACsB,EACH,MAAM,IAAI,MACR,2BAA2BtB,CAAI,8EACjC,EAGF,OAAOsB,CACT,CACF,CAE8B,CAChC,CA5dgBvB,EAAAZ,EAAA,iBRhChB,SAASuF,GAASC,EAAsB,CACtC,IAAMC,EAAMC,EAAc,CACxB,GAAGF,EACH,UAAWG,EAAgBH,EAAM,SAAS,CAC5C,CAAC,EAED,OACEI,GAAA,cAACC,EAAc,SAAd,CAAuB,MAAOJ,GAC5BD,EAAM,QACT,CAEJ,CAXSM,EAAAP,GAAA,YAaT,IAAOQ,GAAQR,GanBf,OAAS,cAAAS,OAAkB,QAIpB,SAASC,IAA8B,CAC5C,IAAMC,EAAUC,GAAWC,CAAa,EACxC,GAAI,CAACF,EACH,MAAM,MAAM,0DAA0D,EAExE,OAAOA,CACT,CANgBG,EAAAJ,GAAA",
6
+ "names": ["React", "createContext", "defaultErrorMessage", "defaultContext", "WalletContext", "pickVersion", "convertEvmBlockchainMetaToEvmChainInfo", "formatAddressWithNetwork", "getBlockChainNameFromId", "getSupportedChainsFromProvider", "AccountId", "isEvmBlockchain", "Events", "HUB_LAST_CONNECTED_WALLETS", "CAIP_BITCOIN_CHAIN_ID", "CAIP_BITCOINCASH_CHAIN_ID", "CAIP_DOGECOIN_CHAIN_ID", "CAIP_LITECOIN_CHAIN_ID", "CAIP_ZCASH_CHAIN_ID", "CAIP_TON_NAMESPACE", "formatAddressWithNetwork", "CAIP_TRON_CHAIN_ID", "AccountId", "Err", "Ok", "mapCaipNamespaceToLegacyNetworkName", "chainId", "CAIP_BITCOIN_CHAIN_ID", "CAIP_ZCASH_CHAIN_ID", "CAIP_LITECOIN_CHAIN_ID", "CAIP_DOGECOIN_CHAIN_ID", "CAIP_BITCOINCASH_CHAIN_ID", "CAIP_TON_NAMESPACE", "CAIP_TRON_CHAIN_ID", "__name", "fromAccountIdToLegacyAddressFormat", "account", "address", "AccountId", "network", "formatAddressWithNetwork", "runSequentiallyWithoutFailure", "promises", "prevPromise", "task", "previousResults", "taskResult", "Ok", "error", "Err", "isConnectResultEvm", "result", "isConnectResultSolana", "createQueue", "options", "processingKeys", "queue", "removeKeyFromQueue", "key", "q", "processQueue", "currentItem", "item", "resolve", "indexOfCurrentItem", "shouldTryAutoConnect", "props", "Persistor", "__name", "name", "item", "value", "LastConnectedWalletsFromStorage", "__name", "#storageKey", "storageKey", "providerId", "namespaces", "HUB_LAST_CONNECTED_WALLETS", "#addWalletToHub", "providerIds", "#removeWalletsFromHub", "#listFromHub", "namespaceIds", "#removeNamespaceFromWalletHub", "Persistor", "storage", "storageState", "toBeAddedNamespaces", "storedNamespaces", "namespace", "storedNamespace", "persistor", "newProviderNamespaces", "getHubProviders", "providers", "provider", "pickVersion", "__name", "findProviderByType", "type", "lastConnectedWalletsFromStorage", "LastConnectedWalletsFromStorage", "HUB_LAST_CONNECTED_WALLETS", "mapHubEventsToLegacy", "hub", "event", "onUpdateState", "metadata", "namespaceId", "namespace", "accounts", "network", "derivationPath", "getNamespaceState", "getProviderState", "coreState", "detailsProperty", "property", "eventInfo", "getSupportedChainsFromProvider", "formattedAddresses", "account", "chainId", "address", "AccountId", "blockchainName", "getBlockChainNameFromId", "formatAddressWithNetwork", "fromAccountIdToLegacyAddressFormat", "convertNamespaceNetworkToEvmChainId", "meta", "evmBlockchainsList", "isEvmBlockchain", "convertEvmBlockchainMetaToEvmChainInfo", "tryConvertNamespaceNetworkToChainInfo", "transformHubResultToLegacyResult", "res", "isConnectResultEvm", "isConnectResultSolana", "synchronizeHubWithConfigProviders", "configurationProviders", "registeredProviders", "configProvider", "providerToRegister", "registeredProvider", "isSolanaNamespace", "ns", "isEvmNamespace", "isUtxoNamespace", "isUserRejectionError", "WalletConnectionError", "getSupportedChainsFromNamespace", "getSupportedChainsFromProvider", "useEffect", "useRef", "useState", "Ok", "Result", "debug", "logError", "method", "args", "error", "err", "debug", "__name", "withErrorLogging", "fn", "result", "withErrorLoggingApi", "api", "entries", "key", "value", "Result", "isEvmNamespaceInput", "namespace", "__name", "lastConnectedWalletsFromStorage", "LastConnectedWalletsFromStorage", "HUB_LAST_CONNECTED_WALLETS", "eagerConnect", "type", "namespacesInput", "params", "getHub", "allBlockChains", "wallet", "targetNamespaces", "namespaceInput", "targetNamespace", "result", "connectNamespacesPromises", "info", "chain", "convertNamespaceNetworkToEvmChainId", "connectNamespacePromise", "isEvmNamespace", "e", "connectNamespacesResult", "runSequentiallyWithoutFailure", "failedNamespaces", "_", "index", "Result", "tryRunCanEagerConnect", "namespaces", "foundNamespaces", "successNamespaces", "canEagerConnectPromises", "namespaceInstance", "canEagerConnectResults", "autoConnect", "deps", "wallets", "lastConnectedWallets", "walletIds", "walletsToRemoveFromPersistence", "eagerConnectQueue", "configWalletNames", "providerName", "lastConnectedNamespaces", "error", "useEffect", "useRef", "useAutoConnect", "props", "autoConnectInitiated", "useRef", "useEffect", "shouldTryAutoConnect", "__name", "createStore", "Hub", "useRef", "useHubRefs", "providers", "store", "useRef", "hub", "createHub", "createdHub", "Hub", "getStore", "provider", "__name", "createdStore", "createStore", "getHub", "hubProviders", "synchronizeHubWithConfigProviders", "useHubAdapter", "params", "getStore", "getHub", "useHubRefs", "rerender", "useState", "dataRef", "useRef", "hubInitiated", "lastConnectAttemptParamsRef", "updateLastConnectAttemptParams", "__name", "type", "namespaces", "queueTask", "createQueue", "error", "actions", "walletError", "WalletConnectionError", "isUserRejectionError", "useEffect", "event", "mapHubEventsToLegacy", "e", "currentRender", "useAutoConnect", "autoConnect", "lastConnectedWalletsFromStorage", "LastConnectedWalletsFromStorage", "HUB_LAST_CONNECTED_WALLETS", "withErrorLoggingApi", "network", "namespace", "provider", "proxiedNamespace", "namespacesProperty", "property", "namespaceMeta", "providerNamespace", "supportedChains", "getSupportedChainsFromNamespace", "wallet", "targetNamespaces", "targetNamespace", "result", "connectResultFromTargetNamespaces", "namespaceInput", "tryConvertNamespaceNetworkToChainInfo", "connectNamespacePromise", "isSolanaNamespace", "isEvmNamespace", "isUtxoNamespace", "transformHubResultToLegacyResult", "connectResult", "connectResultWithLegacyFormat", "successfullyConnectedSupportingEagerConnectNamespaces", "connectResults", "okResult", "Ok", "allResult", "Result", "namespaceShouldBeDisconnected", "namespaceIsConnected", "disconnectPromises", "info", "signerProperty", "installLink", "metadata", "extensions", "k", "key", "upperCasedKey", "providerProperties", "derivationPathProperty", "detailsProperty", "getSupportedChainsFromProvider", "hubState", "walletState", "accounts", "fromAccountIdToLegacyAddressFormat", "account", "namespacesState", "_", "value", "findProviderByType", "Provider", "props", "api", "useHubAdapter", "getHubProviders", "React", "WalletContext", "__name", "provider_default", "useContext", "useWallets", "context", "useContext", "WalletContext", "__name"]
7
7
  }
@@ -62,12 +62,7 @@ export declare enum Events {
62
62
  ACCOUNTS = "accounts",
63
63
  NETWORK = "network",
64
64
  NAMESPACE_DISCONNECTED = "namespace_disconnected",
65
- PROVIDER_DISCONNECTED = "provider_disconnected",
66
- /**
67
- * Internal: auto-connect couldn't connect one or more namespaces of a wallet.
68
- * The value is an `AutoConnectionAttemptError`.
69
- */
70
- AUTO_CONNECT_FAILED = "auto_connect_failed"
65
+ PROVIDER_DISCONNECTED = "provider_disconnected"
71
66
  }
72
67
  export type EventInfo = {
73
68
  supportedBlockchains: BlockchainMeta[];
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/legacy/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACX,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjE,MAAM,MAAM,aAAa,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AACxE,MAAM,MAAM,cAAc,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;AACzD,MAAM,MAAM,mBAAmB,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAC;AAElE,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,cAAc,GAAG,MAAM,CAAC;IACrC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,YAAY,CAAC,EAAE,OAAO,CA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AC,CAAC;AAEvB,UAAU,aAAa;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,YAAY,CAAC;IAC1B,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,SAAS,CAAC;IAItB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,EAAE,CAAC,QAAQ,EAAE,YAAY,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;IAC/D,kBAAkB,CAAC,EAAE,gBAAgB,CAAC;IACtC,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,aAAa,CAAC,cAAc,EAAE,cAAc,EAAE,GAAG,UAAU,CAAC;CAC7D;AAED,UAAU,YAAY;IACpB,IAAI,EAAE,UAAU,CAAC;IACjB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,GAAG,aAAa,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/wallets-react",
3
- "version": "0.0.0-experimental-99f1781b-20260920",
3
+ "version": "0.0.0-experimental-a84f27a7-20260921",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -31,17 +31,17 @@
31
31
  "react-dom": "^17.0.0 || ^18.0.0"
32
32
  },
33
33
  "dependencies": {
34
- "@hub3js/bip122": "0.0.0-experimental-b57d9319-20260919",
35
- "@hub3js/core": "0.0.0-experimental-b57d9319-20260919",
36
- "@hub3js/evm": "0.0.0-experimental-b57d9319-20260919",
37
- "@hub3js/namespaces": "0.0.0-experimental-b57d9319-20260919",
38
- "@hub3js/solana": "0.0.0-experimental-b57d9319-20260919",
39
- "@hub3js/std": "0.0.0-experimental-b57d9319-20260919",
40
- "@hub3js/sui": "0.0.0-experimental-b57d9319-20260919",
41
- "@hub3js/tvm": "0.0.0-experimental-b57d9319-20260919",
42
- "@rango-dev/internal-blockchains": "^0.0.0-experimental-99f1781b-20260920",
34
+ "@hub3js/bip122": "0.0.0-experimental-7dfefe35-20260921",
35
+ "@hub3js/core": "0.0.0-experimental-7dfefe35-20260921",
36
+ "@hub3js/evm": "0.0.0-experimental-7dfefe35-20260921",
37
+ "@hub3js/namespaces": "0.0.0-experimental-7dfefe35-20260921",
38
+ "@hub3js/solana": "0.0.0-experimental-7dfefe35-20260921",
39
+ "@hub3js/std": "0.0.0-experimental-7dfefe35-20260921",
40
+ "@hub3js/sui": "0.0.0-experimental-7dfefe35-20260921",
41
+ "@hub3js/tvm": "0.0.0-experimental-7dfefe35-20260921",
42
+ "@rango-dev/internal-blockchains": "^0.0.0-experimental-a84f27a7-20260921",
43
43
  "@rango-dev/logging-core": "^0.15.0",
44
- "@rango-dev/wallets-core": "^0.0.0-experimental-99f1781b-20260920",
44
+ "@rango-dev/wallets-core": "^0.0.0-experimental-a84f27a7-20260921",
45
45
  "caip": "^1.1.1",
46
46
  "rango-types": "^0.5.0",
47
47
  "ts-results": "^3.3.0"