@rango-dev/wallets-core 0.40.1-next.1 → 0.40.1-next.11

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/namespaces/evm/actions.ts", "../../../src/namespaces/common/actions.ts", "../../../src/namespaces/evm/constants.ts", "../../../src/namespaces/evm/utils.ts", "../../../src/namespaces/evm/after.ts", "../../../src/namespaces/common/after.ts", "../../../src/namespaces/evm/and.ts", "../../../src/hub/store/store.ts", "../../../src/hub/store/namespaces.ts", "../../../src/hub/store/providers.ts", "../../../src/builders/action.ts", "../../../src/utils/mod.ts", "../../../src/namespaces/common/helpers.ts", "../../../src/namespaces/common/and.ts", "../../../src/namespaces/common/before.ts", "../../../src/namespaces/evm/before.ts", "../../../src/namespaces/evm/builders.ts"],
4
- "sourcesContent": ["import type { EIP1193EventMap } from './eip1193.js';\nimport type { EvmActions, ProviderAPI } from './types.js';\nimport type { Context, Subscriber } from '../../hub/namespaces/mod.js';\nimport type { SubscriberCleanUp } from '../../hub/namespaces/types.js';\nimport type { CaipAccount } from '../../types/accounts.js';\nimport type { FunctionWithContext } from '../../types/actions.js';\n\nimport { AccountId } from 'caip';\n\nimport { recommended as commonRecommended } from '../common/actions.js';\n\nimport { CAIP_NAMESPACE } from './constants.js';\nimport { getAccounts, switchOrAddNetwork } from './utils.js';\n\nexport const recommended = [...commonRecommended];\n\nexport function connect(\n instance: () => ProviderAPI\n): FunctionWithContext<EvmActions['connect'], Context> {\n return async (_context, chain) => {\n const evmInstance = instance();\n\n if (!evmInstance) {\n throw new Error(\n 'Do your wallet injected correctly and is evm compatible?'\n );\n }\n\n if (chain) {\n await switchOrAddNetwork(evmInstance, chain);\n }\n\n const chainId = await evmInstance.request({ method: 'eth_chainId' });\n\n const result = await getAccounts(evmInstance);\n\n const formatAccounts = result.accounts.map(\n (account) =>\n AccountId.format({\n address: account,\n chainId: {\n namespace: CAIP_NAMESPACE,\n reference: chainId,\n },\n }) as CaipAccount\n );\n\n return {\n accounts: formatAccounts,\n network: result.chainId,\n };\n };\n}\n\nexport function changeAccountSubscriber(\n instance: () => ProviderAPI\n): [Subscriber<EvmActions>, SubscriberCleanUp<EvmActions>] {\n let eventCallback: EIP1193EventMap['accountsChanged'];\n\n return [\n (context) => {\n const evmInstance = instance();\n\n if (!evmInstance) {\n throw new Error(\n 'Trying to subscribe to your EVM wallet, but seems its instance is not available.'\n );\n }\n\n const [, setState] = context.state();\n\n eventCallback = async (accounts) => {\n const chainId = await evmInstance.request({ method: 'eth_chainId' });\n\n const formatAccounts = accounts.map((account) =>\n AccountId.format({\n address: account,\n chainId: {\n namespace: CAIP_NAMESPACE,\n reference: chainId,\n },\n })\n );\n\n setState('accounts', formatAccounts);\n };\n evmInstance.on('accountsChanged', eventCallback);\n },\n () => {\n const evmInstance = instance();\n\n if (eventCallback && evmInstance) {\n evmInstance.removeListener('accountsChanged', eventCallback);\n }\n },\n ];\n}\n\nexport function changeChainSubscriber(\n instance: () => ProviderAPI\n): [Subscriber<EvmActions>, SubscriberCleanUp<EvmActions>] {\n let eventCallback: EIP1193EventMap['chainChanged'];\n\n return [\n (context) => {\n const evmInstance = instance();\n\n if (!evmInstance) {\n throw new Error(\n 'Trying to subscribe to your EVM wallet, but seems its instance is not available.'\n );\n }\n\n const [, setState] = context.state();\n\n eventCallback = async (chainId: string) => {\n setState('network', chainId);\n };\n evmInstance.on('chainChanged', eventCallback);\n },\n () => {\n const evmInstance = instance();\n\n if (eventCallback && evmInstance) {\n evmInstance.removeListener('chainChanged', eventCallback);\n }\n },\n ];\n}\n", "import type { Context } from '../../hub/namespaces/mod.js';\n\nexport function disconnect(context: Context): void {\n const [, setState] = context.state();\n setState('network', null);\n setState('accounts', null);\n setState('connected', false);\n setState('connecting', false);\n}\n\nexport const recommended = [['disconnect', disconnect] as const];\n", "export const CAIP_NAMESPACE = 'eip155';\nexport const CAIP_ETHEREUM_CHAIN_ID = '1';\n", "import type { Chain, ChainId, ProviderAPI } from './types.js';\n\nexport async function getAccounts(provider: ProviderAPI) {\n const [accounts, chainId] = await Promise.all([\n provider.request({ method: 'eth_requestAccounts' }),\n provider.request({ method: 'eth_chainId' }),\n ]);\n\n return {\n accounts,\n chainId,\n };\n}\n\nexport async function suggestNetwork(instance: ProviderAPI, chain: Chain) {\n return await instance.request({\n method: 'wallet_addEthereumChain',\n params: [chain],\n });\n}\n\nexport async function switchNetwork(instance: ProviderAPI, chainId: ChainId) {\n return await instance.request({\n method: 'wallet_switchEthereumChain',\n params: [{ chainId: chainId }],\n });\n}\n\nexport async function switchOrAddNetwork(\n instance: ProviderAPI,\n chain: ChainId | Chain\n) {\n try {\n const chainId = typeof chain === 'string' ? chain : chain.chainId;\n await switchNetwork(instance, chainId);\n } catch (switchError) {\n const error = switchError as { code: number };\n\n const NOT_FOUND_CHAIN_ERROR_CODE = 4902;\n if (\n typeof chain !== 'string' &&\n (error.code === NOT_FOUND_CHAIN_ERROR_CODE || !error.code)\n ) {\n /*\n * Note: on WalletConnect `code` is undefined so we have to use !switchError.code as fallback.\n * This error code indicates that the chain has not been added to wallet.\n */\n await suggestNetwork(instance, chain);\n }\n throw switchError;\n }\n}\n", "import { recommended as commonRecommended } from '../common/after.js';\n\nexport const recommended = [...commonRecommended];\n", "import type { Context } from '../../hub/namespaces/mod.js';\n\nexport function intoConnectionFinished(context: Context) {\n const [, setState] = context.state();\n setState('connecting', false);\n}\n\nexport const recommended = [['connect', intoConnectionFinished] as const];\n", "import { connectAndUpdateStateForMultiNetworks } from '../common/mod.js';\n\nexport const recommended = [\n ['connect', connectAndUpdateStateForMultiNetworks] as const,\n];\n", "import type { StoreApi } from 'zustand/vanilla';\n\nimport { createStore as createZustandStore } from 'zustand/vanilla';\n\nimport { hubStore, type HubStore } from './hub.js';\nimport { namespacesStore, type NamespaceStore } from './namespaces.js';\nimport { providersStore, type ProviderStore } from './providers.js';\n\n/************ State ************/\n\nexport interface State {\n hub: HubStore;\n providers: ProviderStore;\n namespaces: NamespaceStore;\n}\n\nexport type Store = StoreApi<State>;\nexport const createStore = (): Store => {\n return createZustandStore<State>((...api) => {\n return {\n hub: hubStore(...api),\n providers: providersStore(...api),\n namespaces: namespacesStore(...api),\n };\n });\n};\n", "/************ Namespace ************/\n\nimport type { StateCreator } from 'zustand';\n\nimport { produce } from 'immer';\n\nimport { namespaceStateSelector, type State } from './mod.js';\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface NamespaceConfig {\n // Currently, namespace doesn't has any config.\n}\n\nexport interface NamespaceData {\n accounts: null | string[];\n network: null | string;\n connected: boolean;\n connecting: boolean;\n}\n\ninterface NamespaceInfo {\n providerId: string;\n namespaceId: string;\n}\n\ntype NamespaceState = {\n list: Record<\n string,\n {\n info: NamespaceInfo;\n data: NamespaceData;\n error: unknown;\n }\n >;\n};\n\ninterface NamespaceActions {\n addNamespace: (id: string, config: NamespaceInfo) => void;\n updateStatus: <K extends keyof NamespaceData>(\n id: string,\n key: K,\n value: NamespaceData[K]\n ) => void;\n}\ninterface NamespaceSelectors {\n getNamespaceData(storeId: string): NamespaceData;\n}\n\nexport type NamespaceStore = NamespaceState &\n NamespaceActions &\n NamespaceSelectors;\ntype NamespaceStateCreator = StateCreator<State, [], [], NamespaceStore>;\n\nconst namespacesStore: NamespaceStateCreator = (set, get) => ({\n list: {},\n addNamespace: (id, info) => {\n const item = {\n data: {\n accounts: null,\n network: null,\n connected: false,\n connecting: false,\n },\n error: '',\n info,\n };\n\n set(\n produce((state: State) => {\n state.namespaces.list[id] = item;\n })\n );\n },\n updateStatus: (id, key, value) => {\n if (!get().namespaces.list[id]) {\n throw new Error(`No namespace with '${id}' found.`);\n }\n\n set(\n produce((state: State) => {\n state.namespaces.list[id].data[key] = value;\n })\n );\n },\n getNamespaceData(storeId) {\n return namespaceStateSelector(get(), storeId);\n },\n});\n\nexport { namespacesStore };\n", "import type { State as InternalProviderState } from '../provider/mod.js';\nimport type { CommonNamespaceKeys } from '../provider/types.js';\nimport type { StateCreator } from 'zustand';\n\nimport { produce } from 'immer';\n\nimport { guessProviderStateSelector, type State } from './mod.js';\n\ntype Browsers = 'firefox' | 'chrome' | 'edge' | 'brave' | 'homepage';\ntype Property<N extends string, V> = { name: N; value: V };\ntype DetachedInstances = Property<'detached', CommonNamespaceKeys[]>;\n\nexport type ProviderInfo = {\n name: string;\n icon: string;\n extensions: Partial<Record<Browsers, string>>;\n properties?: DetachedInstances[];\n};\n\nexport interface ProviderConfig {\n info: ProviderInfo;\n}\n\ninterface ProviderData {\n installed: boolean;\n}\n\ntype ProviderState = {\n list: Record<\n string,\n {\n config: ProviderConfig;\n data: ProviderData;\n error: unknown;\n }\n >;\n};\ninterface ProviderActions {\n addProvider: (id: string, config: ProviderConfig) => void;\n updateStatus: <K extends keyof ProviderData>(\n id: string,\n key: K,\n value: ProviderData[K]\n ) => void;\n}\n\ninterface ProviderSelectors {\n /**\n * Provider has a limited state to itself, to be compatible with legacy, we try to produce same object as legacy\n * which includes namespace state as well.\n */\n guessNamespacesState: (id: string) => InternalProviderState;\n}\n\nexport type ProviderStore = ProviderState & ProviderActions & ProviderSelectors;\ntype ProvidersStateCreator = StateCreator<State, [], [], ProviderStore>;\n\nconst providersStore: ProvidersStateCreator = (set, get) => ({\n list: {},\n addProvider: (id, config) => {\n const item = {\n data: {\n installed: false,\n },\n error: '',\n config,\n };\n\n set(\n produce((state: State) => {\n state.providers.list[id] = item;\n })\n );\n },\n updateStatus: (id, key, value) => {\n if (!get().providers.list[id]) {\n throw new Error(`No namespace namespace with '${id}' found.`);\n }\n\n set(\n produce((state: State) => {\n state.providers.list[id].data[key] = value;\n })\n );\n },\n guessNamespacesState: (providerId: string): InternalProviderState => {\n return guessProviderStateSelector(get(), providerId);\n },\n});\n\nexport { providersStore };\n", "import type { Actions, Context, Operators } from '../hub/namespaces/types.js';\nimport type { AnyFunction, FunctionWithContext } from '../types/actions.js';\n\nexport interface ActionByBuilder<T, Context> {\n actionName: keyof T;\n and: Operators<T>;\n or: Operators<T>;\n after: Operators<T>;\n before: Operators<T>;\n action: FunctionWithContext<T[keyof T], Context>;\n}\n\n/*\n * TODO:\n * Currently, to use this builder you will write something like this:\n * new ActionBuilder<EvmActions, 'disconnect'>('disconnect').after(....)\n *\n * I couldn't figure it out to be able typescript infer the constructor value as key of actions.\n * Ideal usage:\n * new ActionBuilder<EvmActions>('disconnect').after(....)\n *\n */\nexport class ActionBuilder<T extends Actions<T>, K extends keyof T> {\n readonly name: K;\n #and: Operators<T> = new Map();\n #or: Operators<T> = new Map();\n #after: Operators<T> = new Map();\n #before: Operators<T> = new Map();\n #action: FunctionWithContext<T[keyof T], Context<T>> | undefined;\n\n constructor(name: K) {\n this.name = name;\n }\n\n public and(action: FunctionWithContext<AnyFunction, Context<T>>) {\n if (!this.#and.has(this.name)) {\n this.#and.set(this.name, []);\n }\n this.#and.get(this.name)?.push(action);\n return this;\n }\n\n public or(action: FunctionWithContext<AnyFunction, Context<T>>) {\n if (!this.#or.has(this.name)) {\n this.#or.set(this.name, []);\n }\n this.#or.get(this.name)?.push(action);\n return this;\n }\n\n public before(action: FunctionWithContext<AnyFunction, Context<T>>) {\n if (!this.#before.has(this.name)) {\n this.#before.set(this.name, []);\n }\n this.#before.get(this.name)?.push(action);\n return this;\n }\n\n public after(action: FunctionWithContext<AnyFunction, Context<T>>) {\n if (!this.#after.has(this.name)) {\n this.#after.set(this.name, []);\n }\n this.#after.get(this.name)?.push(action);\n return this;\n }\n\n public action(action: FunctionWithContext<T[keyof T], Context<T>>) {\n this.#action = action;\n return this;\n }\n\n public build(): ActionByBuilder<T, Context<T>> {\n if (!this.#action) {\n throw new Error('Your action builder should includes an action.');\n }\n\n return {\n actionName: this.name,\n action: this.#action,\n before: this.#before,\n after: this.#after,\n and: this.#and,\n or: this.#or,\n };\n }\n}\n", "/*\n * It is not a good idea to re-export all of CAIP because if they have a breaking change, we will break as well.\n * It would be better to create an abstraction over them and export our own interface to ensure it is under our control.\n */\nexport * as CAIP from 'caip';\n\nexport { generateStoreId } from '../hub/helpers.js';\nexport * from './versions.js';\n", "import { AccountId } from 'caip';\n\nexport function isValidCaipAddress(address: string): boolean {\n try {\n AccountId.parse(address);\n return true;\n } catch {\n return false;\n }\n}\n", "import type {\n Accounts,\n AccountsWithActiveChain,\n} from './../../types/accounts.js';\nimport type { Context } from '../../hub/namespaces/mod.js';\n\nimport { isValidCaipAddress } from './helpers.js';\n\nexport function connectAndUpdateStateForSingleNetwork(\n context: Context,\n accounts: Accounts\n) {\n if (!accounts.every(isValidCaipAddress)) {\n throw new Error(\n `Your provider should format account addresses in CAIP-10 format. Your provided accounts: ${accounts}`\n );\n }\n\n const [, setState] = context.state();\n setState('accounts', accounts);\n setState('connected', true);\n return accounts;\n}\n\nexport function connectAndUpdateStateForMultiNetworks(\n context: Context,\n accounts: AccountsWithActiveChain\n) {\n if (!accounts.accounts.every(isValidCaipAddress)) {\n throw new Error(\n `Your provider should format account addresses in CAIP-10 format. Your provided accounts: ${accounts.accounts}`\n );\n }\n\n const [, setState] = context.state();\n setState('accounts', accounts.accounts);\n setState('network', accounts.network);\n setState('connected', true);\n return accounts;\n}\n\nexport const recommended = [];\n", "import type { Context } from '../../hub/namespaces/mod.js';\n\nexport function intoConnecting(context: Context) {\n const [, setState] = context.state();\n setState('connecting', true);\n}\n\n// Please consider if you are going to add something here, make sure it works on all namespaces.\nexport const recommended = [['connect', intoConnecting] as const];\n", "import { beforeRecommended } from '../common/mod.js';\n\nexport const recommended = [...beforeRecommended];\n", "import type { EvmActions } from './types.js';\n\nimport { ActionBuilder } from '../../mod.js';\nimport { intoConnectionFinished } from '../common/after.js';\nimport { connectAndUpdateStateForMultiNetworks } from '../common/and.js';\n\nexport const connect = () =>\n new ActionBuilder<EvmActions, 'connect'>('connect')\n .and(connectAndUpdateStateForMultiNetworks)\n .after(intoConnectionFinished);\n"],
5
- "mappings": "6IAAA,IAAAA,EAAA,GAAAC,EAAAD,EAA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tCE,EAAS,UAAWF,EAAS,OAAO,EACpCE,EAAS,YAAa,EAAI,EACnBF,CACT,CAfgBG,EAAAL,EAAA,yCCtBT,SAASM,EAAeC,EAAkB,CAC/C,GAAM,CAAC,CAAEC,CAAQ,EAAID,EAAQ,MAAM,EACnCC,EAAS,aAAc,EAAI,CAC7B,CAHgBC,EAAAH,EAAA,kBAMT,IAAMI,EAAc,CAAC,CAAC,UAAWJ,CAAc,CAAU,ERNzD,IAAMK,EAAc,CACzB,CAAC,UAAWC,CAAqC,CACnD,ESJA,IAAAC,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,IAEO,IAAMC,EAAc,CAAC,GAAGA,CAAiB,ECFhD,IAAAC,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAMO,IAAMC,EAAUC,EAAA,IACrB,IAAIC,EAAqC,SAAS,EAC/C,IAAIC,CAAqC,EACzC,MAAMC,CAAsB,EAHV",
6
- "names": ["actions_exports", "__export", "changeAccountSubscriber", "changeChainSubscriber", "connect", "recommended", "AccountId", "disconnect", "context", "setState", "__name", "recommended", "CAIP_NAMESPACE", "CAIP_ETHEREUM_CHAIN_ID", "utils_exports", "__export", "getAccounts", "suggestNetwork", "switchNetwork", "switchOrAddNetwork", "getAccounts", "provider", "accounts", "chainId", "__name", "suggestNetwork", "instance", "chain", "switchNetwork", "switchOrAddNetwork", "switchError", "error", "recommended", "connect", "instance", "_context", "chain", "evmInstance", "switchOrAddNetwork", "chainId", "result", "getAccounts", "account", "AccountId", "CAIP_NAMESPACE", "__name", "changeAccountSubscriber", "eventCallback", "context", "setState", "accounts", "formatAccounts", "changeChainSubscriber", "after_exports", "__export", "recommended", "intoConnectionFinished", "context", "setState", "__name", "recommended", "recommended", "and_exports", "__export", "recommended", "createZustandStore", "produce", "produce", "ActionBuilder", "__name", "#and", "#or", "#after", "#before", "#action", "name", "action", "CAIP", "AccountId", "isValidCaipAddress", "address", "AccountId", "__name", "connectAndUpdateStateForMultiNetworks", "context", "accounts", "isValidCaipAddress", "setState", "__name", "intoConnecting", "context", "setState", "__name", "recommended", "recommended", "connectAndUpdateStateForMultiNetworks", "before_exports", "__export", "recommended", "recommended", "builders_exports", "__export", "connect", "connect", "__name", "ActionBuilder", "connectAndUpdateStateForMultiNetworks", "intoConnectionFinished"]
4
+ "sourcesContent": ["import type { EIP1193EventMap } from './eip1193.js';\nimport type { EvmActions, ProviderAPI } from './types.js';\nimport type { Context, Subscriber } from '../../hub/namespaces/mod.js';\nimport type { SubscriberCleanUp } from '../../hub/namespaces/types.js';\nimport type { CaipAccount } from '../../types/accounts.js';\nimport type { FunctionWithContext } from '../../types/actions.js';\n\nimport { AccountId } from 'caip';\n\nimport { recommended as commonRecommended } from '../common/actions.js';\n\nimport { CAIP_NAMESPACE } from './constants.js';\nimport { getAccounts, switchOrAddNetwork } from './utils.js';\n\nexport const recommended = [...commonRecommended];\n\nexport function connect(\n instance: () => ProviderAPI\n): FunctionWithContext<EvmActions['connect'], Context> {\n return async (_context, chain) => {\n const evmInstance = instance();\n\n if (!evmInstance) {\n throw new Error(\n 'Do your wallet injected correctly and is evm compatible?'\n );\n }\n\n if (chain) {\n await switchOrAddNetwork(evmInstance, chain);\n }\n\n const chainId = await evmInstance.request({ method: 'eth_chainId' });\n\n const result = await getAccounts(evmInstance);\n\n const formatAccounts = result.accounts.map(\n (account) =>\n AccountId.format({\n address: account,\n chainId: {\n namespace: CAIP_NAMESPACE,\n reference: chainId,\n },\n }) as CaipAccount\n );\n\n return {\n accounts: formatAccounts,\n network: result.chainId,\n };\n };\n}\n\nexport function changeAccountSubscriber(\n instance: () => ProviderAPI\n): [Subscriber<EvmActions>, SubscriberCleanUp<EvmActions>] {\n let eventCallback: EIP1193EventMap['accountsChanged'];\n\n // subscriber can be passed to `or`, it will get the error and should rethrow error to pass the error to next `or` or throw error.\n return [\n (context, err) => {\n const evmInstance = instance();\n\n if (!evmInstance) {\n throw new Error(\n 'Trying to subscribe to your EVM wallet, but seems its instance is not available.'\n );\n }\n\n const [, setState] = context.state();\n\n eventCallback = async (accounts) => {\n /*\n * In Phantom, when user is switching to an account which is not connected to dApp yet, it returns a null.\n * So null means we don't have access to account and we need to disconnect and let the user connect the account.\n *\n * This assumption may not work for other wallets, if that the case, we need to consider a new approach.\n */\n if (!accounts || accounts.length === 0) {\n context.action('disconnect');\n return;\n }\n\n const chainId = await evmInstance.request({ method: 'eth_chainId' });\n const formatAccounts = accounts.map((account) =>\n AccountId.format({\n address: account,\n chainId: {\n namespace: CAIP_NAMESPACE,\n reference: chainId,\n },\n })\n );\n\n setState('accounts', formatAccounts);\n };\n evmInstance.on('accountsChanged', eventCallback);\n\n if (err instanceof Error) {\n throw err;\n }\n },\n (_, err) => {\n const evmInstance = instance();\n\n if (eventCallback && evmInstance) {\n evmInstance.removeListener('accountsChanged', eventCallback);\n }\n\n if (err instanceof Error) {\n throw err;\n }\n },\n ];\n}\n\nexport function changeChainSubscriber(\n instance: () => ProviderAPI\n): [Subscriber<EvmActions>, SubscriberCleanUp<EvmActions>] {\n let eventCallback: EIP1193EventMap['chainChanged'];\n\n return [\n (context) => {\n const evmInstance = instance();\n\n if (!evmInstance) {\n throw new Error(\n 'Trying to subscribe to your EVM wallet, but seems its instance is not available.'\n );\n }\n\n const [, setState] = context.state();\n\n eventCallback = async (chainId: string) => {\n setState('network', chainId);\n };\n evmInstance.on('chainChanged', eventCallback);\n },\n () => {\n const evmInstance = instance();\n\n if (eventCallback && evmInstance) {\n evmInstance.removeListener('chainChanged', eventCallback);\n }\n },\n ];\n}\n", "import type { Context } from '../../hub/namespaces/mod.js';\n\nexport function disconnect(context: Context): void {\n const [, setState] = context.state();\n setState('network', null);\n setState('accounts', null);\n setState('connected', false);\n setState('connecting', false);\n}\n\nexport const recommended = [['disconnect', disconnect] as const];\n", "export const CAIP_NAMESPACE = 'eip155';\nexport const CAIP_ETHEREUM_CHAIN_ID = '1';\n", "import type { Chain, ChainId, ProviderAPI } from './types.js';\n\nexport async function getAccounts(provider: ProviderAPI) {\n const [accounts, chainId] = await Promise.all([\n provider.request({ method: 'eth_requestAccounts' }),\n provider.request({ method: 'eth_chainId' }),\n ]);\n\n return {\n accounts,\n chainId,\n };\n}\n\nexport async function suggestNetwork(instance: ProviderAPI, chain: Chain) {\n return await instance.request({\n method: 'wallet_addEthereumChain',\n params: [chain],\n });\n}\n\nexport async function switchNetwork(instance: ProviderAPI, chainId: ChainId) {\n return await instance.request({\n method: 'wallet_switchEthereumChain',\n params: [{ chainId: chainId }],\n });\n}\n\nexport async function switchOrAddNetwork(\n instance: ProviderAPI,\n chain: ChainId | Chain\n) {\n try {\n const chainId = typeof chain === 'string' ? chain : chain.chainId;\n await switchNetwork(instance, chainId);\n } catch (switchError) {\n const error = switchError as { code: number };\n\n const NOT_FOUND_CHAIN_ERROR_CODE = 4902;\n if (\n typeof chain !== 'string' &&\n (error.code === NOT_FOUND_CHAIN_ERROR_CODE || !error.code)\n ) {\n /*\n * Note: on WalletConnect `code` is undefined so we have to use !switchError.code as fallback.\n * This error code indicates that the chain has not been added to wallet.\n */\n await suggestNetwork(instance, chain);\n }\n throw switchError;\n }\n}\n", "import { recommended as commonRecommended } from '../common/after.js';\n\nexport const recommended = [...commonRecommended];\n", "import type { Context } from '../../hub/namespaces/mod.js';\n\nexport function intoConnectionFinished(context: Context) {\n const [, setState] = context.state();\n setState('connecting', false);\n}\n\nexport const recommended = [['connect', intoConnectionFinished] as const];\n", "import { connectAndUpdateStateForMultiNetworks } from '../common/mod.js';\n\nexport const recommended = [\n ['connect', connectAndUpdateStateForMultiNetworks] as const,\n];\n", "import type { StoreApi } from 'zustand/vanilla';\n\nimport { createStore as createZustandStore } from 'zustand/vanilla';\n\nimport { hubStore, type HubStore } from './hub.js';\nimport { namespacesStore, type NamespaceStore } from './namespaces.js';\nimport { providersStore, type ProviderStore } from './providers.js';\n\n/************ State ************/\n\nexport interface State {\n hub: HubStore;\n providers: ProviderStore;\n namespaces: NamespaceStore;\n}\n\nexport type Store = StoreApi<State>;\nexport const createStore = (): Store => {\n return createZustandStore<State>((...api) => {\n return {\n hub: hubStore(...api),\n providers: providersStore(...api),\n namespaces: namespacesStore(...api),\n };\n });\n};\n", "/************ Namespace ************/\n\nimport type { StateCreator } from 'zustand';\n\nimport { produce } from 'immer';\n\nimport { namespaceStateSelector, type State } from './mod.js';\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface NamespaceConfig {\n // Currently, namespace doesn't has any config.\n}\n\nexport interface NamespaceData {\n accounts: null | string[];\n network: null | string;\n connected: boolean;\n connecting: boolean;\n}\n\ninterface NamespaceInfo {\n providerId: string;\n namespaceId: string;\n}\n\ntype NamespaceState = {\n list: Record<\n string,\n {\n info: NamespaceInfo;\n data: NamespaceData;\n error: unknown;\n }\n >;\n};\n\ninterface NamespaceActions {\n addNamespace: (id: string, config: NamespaceInfo) => void;\n updateStatus: <K extends keyof NamespaceData>(\n id: string,\n key: K,\n value: NamespaceData[K]\n ) => void;\n}\ninterface NamespaceSelectors {\n getNamespaceData(storeId: string): NamespaceData;\n}\n\nexport type NamespaceStore = NamespaceState &\n NamespaceActions &\n NamespaceSelectors;\ntype NamespaceStateCreator = StateCreator<State, [], [], NamespaceStore>;\n\nconst namespacesStore: NamespaceStateCreator = (set, get) => ({\n list: {},\n addNamespace: (id, info) => {\n const item = {\n data: {\n accounts: null,\n network: null,\n connected: false,\n connecting: false,\n },\n error: '',\n info,\n };\n\n set(\n produce((state: State) => {\n state.namespaces.list[id] = item;\n })\n );\n },\n updateStatus: (id, key, value) => {\n if (!get().namespaces.list[id]) {\n throw new Error(`No namespace with '${id}' found.`);\n }\n\n set(\n produce((state: State) => {\n state.namespaces.list[id].data[key] = value;\n })\n );\n },\n getNamespaceData(storeId) {\n return namespaceStateSelector(get(), storeId);\n },\n});\n\nexport { namespacesStore };\n", "import type { Namespace } from '../../namespaces/common/types.js';\nimport type { State as InternalProviderState } from '../provider/mod.js';\nimport type { StateCreator } from 'zustand';\n\nimport { produce } from 'immer';\n\nimport { guessProviderStateSelector, type State } from './mod.js';\n\ntype Browsers = 'firefox' | 'chrome' | 'edge' | 'brave' | 'homepage';\ntype Property<N extends string, V> = { name: N; value: V };\ntype DetachedInstances = Property<'detached', Namespace[]>;\n\nexport type ProviderInfo = {\n name: string;\n icon: string;\n extensions: Partial<Record<Browsers, string>>;\n properties?: DetachedInstances[];\n};\n\nexport interface ProviderConfig {\n info: ProviderInfo;\n}\n\ninterface ProviderData {\n installed: boolean;\n}\n\ntype ProviderState = {\n list: Record<\n string,\n {\n config: ProviderConfig;\n data: ProviderData;\n error: unknown;\n }\n >;\n};\ninterface ProviderActions {\n addProvider: (id: string, config: ProviderConfig) => void;\n updateStatus: <K extends keyof ProviderData>(\n id: string,\n key: K,\n value: ProviderData[K]\n ) => void;\n}\n\ninterface ProviderSelectors {\n /**\n * Provider has a limited state to itself, to be compatible with legacy, we try to produce same object as legacy\n * which includes namespace state as well.\n */\n guessNamespacesState: (id: string) => InternalProviderState;\n}\n\nexport type ProviderStore = ProviderState & ProviderActions & ProviderSelectors;\ntype ProvidersStateCreator = StateCreator<State, [], [], ProviderStore>;\n\nconst providersStore: ProvidersStateCreator = (set, get) => ({\n list: {},\n addProvider: (id, config) => {\n const item = {\n data: {\n installed: false,\n },\n error: '',\n config,\n };\n\n set(\n produce((state: State) => {\n state.providers.list[id] = item;\n })\n );\n },\n updateStatus: (id, key, value) => {\n if (!get().providers.list[id]) {\n throw new Error(`No namespace namespace with '${id}' found.`);\n }\n\n set(\n produce((state: State) => {\n state.providers.list[id].data[key] = value;\n })\n );\n },\n guessNamespacesState: (providerId: string): InternalProviderState => {\n return guessProviderStateSelector(get(), providerId);\n },\n});\n\nexport { providersStore };\n", "import type { Actions, Context, Operators } from '../hub/namespaces/types.js';\nimport type { AnyFunction, FunctionWithContext } from '../types/actions.js';\n\nexport interface ActionByBuilder<T, Context> {\n actionName: keyof T;\n and: Operators<T>;\n or: Operators<T>;\n after: Operators<T>;\n before: Operators<T>;\n action: FunctionWithContext<T[keyof T], Context>;\n}\n\n/*\n * TODO:\n * Currently, to use this builder you will write something like this:\n * new ActionBuilder<EvmActions, 'disconnect'>('disconnect').after(....)\n *\n * I couldn't figure it out to be able typescript infer the constructor value as key of actions.\n * Ideal usage:\n * new ActionBuilder<EvmActions>('disconnect').after(....)\n *\n */\nexport class ActionBuilder<T extends Actions<T>, K extends keyof T> {\n readonly name: K;\n #and: Operators<T> = new Map();\n #or: Operators<T> = new Map();\n #after: Operators<T> = new Map();\n #before: Operators<T> = new Map();\n #action: FunctionWithContext<T[keyof T], Context<T>> | undefined;\n\n constructor(name: K) {\n this.name = name;\n }\n\n public and(action: FunctionWithContext<AnyFunction, Context<T>>) {\n if (!this.#and.has(this.name)) {\n this.#and.set(this.name, []);\n }\n this.#and.get(this.name)?.push(action);\n return this;\n }\n\n public or(action: FunctionWithContext<AnyFunction, Context<T>>) {\n if (!this.#or.has(this.name)) {\n this.#or.set(this.name, []);\n }\n this.#or.get(this.name)?.push(action);\n return this;\n }\n\n public before(action: FunctionWithContext<AnyFunction, Context<T>>) {\n if (!this.#before.has(this.name)) {\n this.#before.set(this.name, []);\n }\n this.#before.get(this.name)?.push(action);\n return this;\n }\n\n public after(action: FunctionWithContext<AnyFunction, Context<T>>) {\n if (!this.#after.has(this.name)) {\n this.#after.set(this.name, []);\n }\n this.#after.get(this.name)?.push(action);\n return this;\n }\n\n public action(action: FunctionWithContext<T[keyof T], Context<T>>) {\n this.#action = action;\n return this;\n }\n\n public build(): ActionByBuilder<T, Context<T>> {\n if (!this.#action) {\n throw new Error('Your action builder should includes an action.');\n }\n\n return {\n actionName: this.name,\n action: this.#action,\n before: this.#before,\n after: this.#after,\n and: this.#and,\n or: this.#or,\n };\n }\n}\n", "/*\n * It is not a good idea to re-export all of CAIP because if they have a breaking change, we will break as well.\n * It would be better to create an abstraction over them and export our own interface to ensure it is under our control.\n */\nexport * as CAIP from 'caip';\n\nexport { generateStoreId } from '../hub/helpers.js';\nexport * from './versions.js';\n", "import { AccountId } from 'caip';\n\nexport function isValidCaipAddress(address: string): boolean {\n try {\n AccountId.parse(address);\n return true;\n } catch {\n return false;\n }\n}\n", "import type {\n Accounts,\n AccountsWithActiveChain,\n} from './../../types/accounts.js';\nimport type { Context } from '../../hub/namespaces/mod.js';\n\nimport { isValidCaipAddress } from './helpers.js';\n\nexport function connectAndUpdateStateForSingleNetwork(\n context: Context,\n accounts: Accounts\n) {\n if (!accounts.every(isValidCaipAddress)) {\n throw new Error(\n `Your provider should format account addresses in CAIP-10 format. Your provided accounts: ${accounts}`\n );\n }\n\n const [, setState] = context.state();\n setState('accounts', accounts);\n setState('connected', true);\n return accounts;\n}\n\nexport function connectAndUpdateStateForMultiNetworks(\n context: Context,\n accounts: AccountsWithActiveChain\n) {\n if (!accounts.accounts.every(isValidCaipAddress)) {\n throw new Error(\n `Your provider should format account addresses in CAIP-10 format. Your provided accounts: ${accounts.accounts}`\n );\n }\n\n const [, setState] = context.state();\n setState('accounts', accounts.accounts);\n setState('network', accounts.network);\n setState('connected', true);\n return accounts;\n}\n\nexport const recommended = [];\n", "import type { Context } from '../../hub/namespaces/mod.js';\n\nexport function intoConnecting(context: Context) {\n const [, setState] = context.state();\n setState('connecting', true);\n}\n\n// Please consider if you are going to add something here, make sure it works on all namespaces.\nexport const recommended = [['connect', intoConnecting] as const];\n", "import { beforeRecommended } from '../common/mod.js';\n\nexport const recommended = [...beforeRecommended];\n", "import type { EvmActions } from './types.js';\n\nimport { ActionBuilder } from '../../mod.js';\nimport { intoConnectionFinished } from '../common/after.js';\nimport { connectAndUpdateStateForMultiNetworks } from '../common/and.js';\n\nexport const connect = () =>\n new ActionBuilder<EvmActions, 'connect'>('connect')\n .and(connectAndUpdateStateForMultiNetworks)\n .after(intoConnectionFinished);\n"],
5
+ "mappings": "6IAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,EAAA,0BAAAC,EAAA,YAAAC,EAAA,gBAAAC,IAOA,OAAS,aAAAC,MAAiB,OCLnB,SAASC,EAAWC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GAAM,CAAC,CAAEE,CAAQ,EAAIH,EAAQ,MAAM,EACnC,OAAAG,EAAS,WAAYF,EAAS,QAAQ,EACtCE,EAAS,UAAWF,EAAS,OAAO,EACpCE,EAAS,YAAa,EAAI,EACnBF,CACT,CAfgBG,EAAAL,EAAA,yCCtBT,SAASM,EAAeC,EAAkB,CAC/C,GAAM,CAAC,CAAEC,CAAQ,EAAID,EAAQ,MAAM,EACnCC,EAAS,aAAc,EAAI,CAC7B,CAHgBC,EAAAH,EAAA,kBAMT,IAAMI,EAAc,CAAC,CAAC,UAAWJ,CAAc,CAAU,ERNzD,IAAMK,EAAc,CACzB,CAAC,UAAWC,CAAqC,CACnD,ESJA,IAAAC,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,IAEO,IAAMC,EAAc,CAAC,GAAGA,CAAiB,ECFhD,IAAAC,EAAA,GAAAC,EAAAD,EAAA,aAAAE,KAMO,IAAMC,GAAUC,EAAA,IACrB,IAAIC,EAAqC,SAAS,EAC/C,IAAIC,CAAqC,EACzC,MAAMC,CAAsB,EAHV",
6
+ "names": ["actions_exports", "__export", "changeAccountSubscriber", "changeChainSubscriber", "connect", "recommended", "AccountId", "disconnect", "context", "setState", "__name", "recommended", "CAIP_NAMESPACE", "CAIP_ETHEREUM_CHAIN_ID", "utils_exports", "__export", "getAccounts", "suggestNetwork", "switchNetwork", "switchOrAddNetwork", "getAccounts", "provider", "accounts", "chainId", "__name", "suggestNetwork", "instance", "chain", "switchNetwork", "switchOrAddNetwork", "switchError", "error", "recommended", "connect", "instance", "_context", "chain", "evmInstance", "switchOrAddNetwork", "chainId", "result", "getAccounts", "account", "AccountId", "CAIP_NAMESPACE", "__name", "changeAccountSubscriber", "eventCallback", "context", "err", "setState", "accounts", "formatAccounts", "_", "changeChainSubscriber", "after_exports", "__export", "recommended", "intoConnectionFinished", "context", "setState", "__name", "recommended", "recommended", "and_exports", "__export", "recommended", "createZustandStore", "produce", "produce", "ActionBuilder", "__name", "#and", "#or", "#after", "#before", "#action", "name", "action", "CAIP", "AccountId", "isValidCaipAddress", "address", "AccountId", "__name", "connectAndUpdateStateForMultiNetworks", "context", "accounts", "isValidCaipAddress", "setState", "__name", "intoConnecting", "context", "setState", "__name", "recommended", "recommended", "connectAndUpdateStateForMultiNetworks", "before_exports", "__export", "recommended", "recommended", "builders_exports", "__export", "connect", "connect", "__name", "ActionBuilder", "connectAndUpdateStateForMultiNetworks", "intoConnectionFinished"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/namespaces/solana/actions.ts", "../../../src/namespaces/common/actions.ts", "../../../src/namespaces/solana/constants.ts", "../../../src/namespaces/solana/after.ts", "../../../src/namespaces/common/after.ts", "../../../src/namespaces/solana/and.ts", "../../../src/hub/store/store.ts", "../../../src/hub/store/namespaces.ts", "../../../src/hub/store/providers.ts", "../../../src/builders/action.ts", "../../../src/utils/mod.ts", "../../../src/namespaces/common/helpers.ts", "../../../src/namespaces/common/and.ts", "../../../src/namespaces/common/before.ts", "../../../src/namespaces/solana/before.ts", "../../../src/namespaces/solana/builders.ts"],
4
- "sourcesContent": ["import type { ProviderAPI, SolanaActions } from './types.js';\nimport type { Subscriber } from '../../hub/namespaces/mod.js';\nimport type { SubscriberCleanUp } from '../../hub/namespaces/types.js';\nimport type { AnyFunction } from '../../types/actions.js';\n\nimport { AccountId } from 'caip';\n\nimport { recommended as commonRecommended } from '../common/actions.js';\n\nimport { CAIP_NAMESPACE, CAIP_SOLANA_CHAIN_ID } from './constants.js';\n\nexport const recommended = [...commonRecommended];\n\nexport function changeAccountSubscriber(\n instance: () => ProviderAPI | undefined\n): [Subscriber<SolanaActions>, SubscriberCleanUp<SolanaActions>] {\n let eventCallback: AnyFunction;\n\n // subscriber can be passed to `or`, it will get the error and should rethrow error to pass the error to next `or` or throw error.\n return [\n (context, err) => {\n const solanaInstance = instance();\n\n if (!solanaInstance) {\n throw new Error(\n 'Trying to subscribe to your Solana wallet, but seems its instance is not available.'\n );\n }\n\n const [, setState] = context.state();\n\n eventCallback = (publicKey) => {\n /*\n * In Phantom, when user is switching to an account which is not connected to dApp yet, it returns a null.\n * So null means we don't have access to account and we 0 need to disconnect and let the user connect the account.\n */\n if (!publicKey) {\n context.action('disconnect');\n return;\n }\n\n setState('accounts', [\n AccountId.format({\n address: publicKey.toString(),\n chainId: {\n namespace: CAIP_NAMESPACE,\n reference: CAIP_SOLANA_CHAIN_ID,\n },\n }),\n ]);\n };\n solanaInstance.on('accountChanged', eventCallback);\n\n if (err instanceof Error) {\n throw err;\n }\n },\n (_context, err) => {\n const solanaInstance = instance();\n\n if (eventCallback && solanaInstance) {\n solanaInstance.off('accountChanged', eventCallback);\n }\n\n if (err instanceof Error) {\n throw err;\n }\n },\n ];\n}\n", "import type { Context } from '../../hub/namespaces/mod.js';\n\nexport function disconnect(context: Context): void {\n const [, setState] = context.state();\n setState('network', null);\n setState('accounts', null);\n setState('connected', false);\n setState('connecting', false);\n}\n\nexport const recommended = [['disconnect', disconnect] as const];\n", "export const CAIP_NAMESPACE = 'solana';\nexport const CAIP_SOLANA_CHAIN_ID = '5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp';\n", "import { recommended as commonRecommended } from '../common/after.js';\n\nexport const recommended = [...commonRecommended];\n", "import type { Context } from '../../hub/namespaces/mod.js';\n\nexport function intoConnectionFinished(context: Context) {\n const [, setState] = context.state();\n setState('connecting', false);\n}\n\nexport const recommended = [['connect', intoConnectionFinished] as const];\n", "import { connectAndUpdateStateForSingleNetwork } from '../common/mod.js';\n\nexport const recommended = [\n ['connect', connectAndUpdateStateForSingleNetwork] as const,\n];\n", "import type { StoreApi } from 'zustand/vanilla';\n\nimport { createStore as createZustandStore } from 'zustand/vanilla';\n\nimport { hubStore, type HubStore } from './hub.js';\nimport { namespacesStore, type NamespaceStore } from './namespaces.js';\nimport { providersStore, type ProviderStore } from './providers.js';\n\n/************ State ************/\n\nexport interface State {\n hub: HubStore;\n providers: ProviderStore;\n namespaces: NamespaceStore;\n}\n\nexport type Store = StoreApi<State>;\nexport const createStore = (): Store => {\n return createZustandStore<State>((...api) => {\n return {\n hub: hubStore(...api),\n providers: providersStore(...api),\n namespaces: namespacesStore(...api),\n };\n });\n};\n", "/************ Namespace ************/\n\nimport type { StateCreator } from 'zustand';\n\nimport { produce } from 'immer';\n\nimport { namespaceStateSelector, type State } from './mod.js';\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface NamespaceConfig {\n // Currently, namespace doesn't has any config.\n}\n\nexport interface NamespaceData {\n accounts: null | string[];\n network: null | string;\n connected: boolean;\n connecting: boolean;\n}\n\ninterface NamespaceInfo {\n providerId: string;\n namespaceId: string;\n}\n\ntype NamespaceState = {\n list: Record<\n string,\n {\n info: NamespaceInfo;\n data: NamespaceData;\n error: unknown;\n }\n >;\n};\n\ninterface NamespaceActions {\n addNamespace: (id: string, config: NamespaceInfo) => void;\n updateStatus: <K extends keyof NamespaceData>(\n id: string,\n key: K,\n value: NamespaceData[K]\n ) => void;\n}\ninterface NamespaceSelectors {\n getNamespaceData(storeId: string): NamespaceData;\n}\n\nexport type NamespaceStore = NamespaceState &\n NamespaceActions &\n NamespaceSelectors;\ntype NamespaceStateCreator = StateCreator<State, [], [], NamespaceStore>;\n\nconst namespacesStore: NamespaceStateCreator = (set, get) => ({\n list: {},\n addNamespace: (id, info) => {\n const item = {\n data: {\n accounts: null,\n network: null,\n connected: false,\n connecting: false,\n },\n error: '',\n info,\n };\n\n set(\n produce((state: State) => {\n state.namespaces.list[id] = item;\n })\n );\n },\n updateStatus: (id, key, value) => {\n if (!get().namespaces.list[id]) {\n throw new Error(`No namespace with '${id}' found.`);\n }\n\n set(\n produce((state: State) => {\n state.namespaces.list[id].data[key] = value;\n })\n );\n },\n getNamespaceData(storeId) {\n return namespaceStateSelector(get(), storeId);\n },\n});\n\nexport { namespacesStore };\n", "import type { State as InternalProviderState } from '../provider/mod.js';\nimport type { CommonNamespaceKeys } from '../provider/types.js';\nimport type { StateCreator } from 'zustand';\n\nimport { produce } from 'immer';\n\nimport { guessProviderStateSelector, type State } from './mod.js';\n\ntype Browsers = 'firefox' | 'chrome' | 'edge' | 'brave' | 'homepage';\ntype Property<N extends string, V> = { name: N; value: V };\ntype DetachedInstances = Property<'detached', CommonNamespaceKeys[]>;\n\nexport type ProviderInfo = {\n name: string;\n icon: string;\n extensions: Partial<Record<Browsers, string>>;\n properties?: DetachedInstances[];\n};\n\nexport interface ProviderConfig {\n info: ProviderInfo;\n}\n\ninterface ProviderData {\n installed: boolean;\n}\n\ntype ProviderState = {\n list: Record<\n string,\n {\n config: ProviderConfig;\n data: ProviderData;\n error: unknown;\n }\n >;\n};\ninterface ProviderActions {\n addProvider: (id: string, config: ProviderConfig) => void;\n updateStatus: <K extends keyof ProviderData>(\n id: string,\n key: K,\n value: ProviderData[K]\n ) => void;\n}\n\ninterface ProviderSelectors {\n /**\n * Provider has a limited state to itself, to be compatible with legacy, we try to produce same object as legacy\n * which includes namespace state as well.\n */\n guessNamespacesState: (id: string) => InternalProviderState;\n}\n\nexport type ProviderStore = ProviderState & ProviderActions & ProviderSelectors;\ntype ProvidersStateCreator = StateCreator<State, [], [], ProviderStore>;\n\nconst providersStore: ProvidersStateCreator = (set, get) => ({\n list: {},\n addProvider: (id, config) => {\n const item = {\n data: {\n installed: false,\n },\n error: '',\n config,\n };\n\n set(\n produce((state: State) => {\n state.providers.list[id] = item;\n })\n );\n },\n updateStatus: (id, key, value) => {\n if (!get().providers.list[id]) {\n throw new Error(`No namespace namespace with '${id}' found.`);\n }\n\n set(\n produce((state: State) => {\n state.providers.list[id].data[key] = value;\n })\n );\n },\n guessNamespacesState: (providerId: string): InternalProviderState => {\n return guessProviderStateSelector(get(), providerId);\n },\n});\n\nexport { providersStore };\n", "import type { Actions, Context, Operators } from '../hub/namespaces/types.js';\nimport type { AnyFunction, FunctionWithContext } from '../types/actions.js';\n\nexport interface ActionByBuilder<T, Context> {\n actionName: keyof T;\n and: Operators<T>;\n or: Operators<T>;\n after: Operators<T>;\n before: Operators<T>;\n action: FunctionWithContext<T[keyof T], Context>;\n}\n\n/*\n * TODO:\n * Currently, to use this builder you will write something like this:\n * new ActionBuilder<EvmActions, 'disconnect'>('disconnect').after(....)\n *\n * I couldn't figure it out to be able typescript infer the constructor value as key of actions.\n * Ideal usage:\n * new ActionBuilder<EvmActions>('disconnect').after(....)\n *\n */\nexport class ActionBuilder<T extends Actions<T>, K extends keyof T> {\n readonly name: K;\n #and: Operators<T> = new Map();\n #or: Operators<T> = new Map();\n #after: Operators<T> = new Map();\n #before: Operators<T> = new Map();\n #action: FunctionWithContext<T[keyof T], Context<T>> | undefined;\n\n constructor(name: K) {\n this.name = name;\n }\n\n public and(action: FunctionWithContext<AnyFunction, Context<T>>) {\n if (!this.#and.has(this.name)) {\n this.#and.set(this.name, []);\n }\n this.#and.get(this.name)?.push(action);\n return this;\n }\n\n public or(action: FunctionWithContext<AnyFunction, Context<T>>) {\n if (!this.#or.has(this.name)) {\n this.#or.set(this.name, []);\n }\n this.#or.get(this.name)?.push(action);\n return this;\n }\n\n public before(action: FunctionWithContext<AnyFunction, Context<T>>) {\n if (!this.#before.has(this.name)) {\n this.#before.set(this.name, []);\n }\n this.#before.get(this.name)?.push(action);\n return this;\n }\n\n public after(action: FunctionWithContext<AnyFunction, Context<T>>) {\n if (!this.#after.has(this.name)) {\n this.#after.set(this.name, []);\n }\n this.#after.get(this.name)?.push(action);\n return this;\n }\n\n public action(action: FunctionWithContext<T[keyof T], Context<T>>) {\n this.#action = action;\n return this;\n }\n\n public build(): ActionByBuilder<T, Context<T>> {\n if (!this.#action) {\n throw new Error('Your action builder should includes an action.');\n }\n\n return {\n actionName: this.name,\n action: this.#action,\n before: this.#before,\n after: this.#after,\n and: this.#and,\n or: this.#or,\n };\n }\n}\n", "/*\n * It is not a good idea to re-export all of CAIP because if they have a breaking change, we will break as well.\n * It would be better to create an abstraction over them and export our own interface to ensure it is under our control.\n */\nexport * as CAIP from 'caip';\n\nexport { generateStoreId } from '../hub/helpers.js';\nexport * from './versions.js';\n", "import { AccountId } from 'caip';\n\nexport function isValidCaipAddress(address: string): boolean {\n try {\n AccountId.parse(address);\n return true;\n } catch {\n return false;\n }\n}\n", "import type {\n Accounts,\n AccountsWithActiveChain,\n} from './../../types/accounts.js';\nimport type { Context } from '../../hub/namespaces/mod.js';\n\nimport { isValidCaipAddress } from './helpers.js';\n\nexport function connectAndUpdateStateForSingleNetwork(\n context: Context,\n accounts: Accounts\n) {\n if (!accounts.every(isValidCaipAddress)) {\n throw new Error(\n `Your provider should format account addresses in CAIP-10 format. Your provided accounts: ${accounts}`\n );\n }\n\n const [, setState] = context.state();\n setState('accounts', accounts);\n setState('connected', true);\n return accounts;\n}\n\nexport function connectAndUpdateStateForMultiNetworks(\n context: Context,\n accounts: AccountsWithActiveChain\n) {\n if (!accounts.accounts.every(isValidCaipAddress)) {\n throw new Error(\n `Your provider should format account addresses in CAIP-10 format. Your provided accounts: ${accounts.accounts}`\n );\n }\n\n const [, setState] = context.state();\n setState('accounts', accounts.accounts);\n setState('network', accounts.network);\n setState('connected', true);\n return accounts;\n}\n\nexport const recommended = [];\n", "import type { Context } from '../../hub/namespaces/mod.js';\n\nexport function intoConnecting(context: Context) {\n const [, setState] = context.state();\n setState('connecting', true);\n}\n\n// Please consider if you are going to add something here, make sure it works on all namespaces.\nexport const recommended = [['connect', intoConnecting] as const];\n", "import { recommended as commonRecommended } from '../common/before.js';\n\nexport const recommended = [...commonRecommended];\n", "import type { SolanaActions } from './types.js';\n\nimport { ActionBuilder } from '../../mod.js';\nimport { intoConnectionFinished } from '../common/after.js';\nimport { connectAndUpdateStateForSingleNetwork } from '../common/and.js';\n\nexport const connect = () =>\n new ActionBuilder<SolanaActions, 'connect'>('connect')\n .and(connectAndUpdateStateForSingleNetwork)\n .after(intoConnectionFinished);\n"],
4
+ "sourcesContent": ["import type { ProviderAPI, SolanaActions } from './types.js';\nimport type { Subscriber } from '../../hub/namespaces/mod.js';\nimport type { SubscriberCleanUp } from '../../hub/namespaces/types.js';\nimport type { AnyFunction } from '../../types/actions.js';\n\nimport { AccountId } from 'caip';\n\nimport { recommended as commonRecommended } from '../common/actions.js';\n\nimport { CAIP_NAMESPACE, CAIP_SOLANA_CHAIN_ID } from './constants.js';\n\nexport const recommended = [...commonRecommended];\n\nexport function changeAccountSubscriber(\n instance: () => ProviderAPI | undefined\n): [Subscriber<SolanaActions>, SubscriberCleanUp<SolanaActions>] {\n let eventCallback: AnyFunction;\n\n // subscriber can be passed to `or`, it will get the error and should rethrow error to pass the error to next `or` or throw error.\n return [\n (context, err) => {\n const solanaInstance = instance();\n\n if (!solanaInstance) {\n throw new Error(\n 'Trying to subscribe to your Solana wallet, but seems its instance is not available.'\n );\n }\n\n const [, setState] = context.state();\n\n eventCallback = (publicKey) => {\n /*\n * In Phantom, when user is switching to an account which is not connected to dApp yet, it returns a null.\n * So null means we don't have access to account and we 0 need to disconnect and let the user connect the account.\n */\n if (!publicKey) {\n context.action('disconnect');\n return;\n }\n\n setState('accounts', [\n AccountId.format({\n address: publicKey.toString(),\n chainId: {\n namespace: CAIP_NAMESPACE,\n reference: CAIP_SOLANA_CHAIN_ID,\n },\n }),\n ]);\n };\n solanaInstance.on('accountChanged', eventCallback);\n\n if (err instanceof Error) {\n throw err;\n }\n },\n (_context, err) => {\n const solanaInstance = instance();\n\n if (eventCallback && solanaInstance) {\n solanaInstance.off('accountChanged', eventCallback);\n }\n\n if (err instanceof Error) {\n throw err;\n }\n },\n ];\n}\n", "import type { Context } from '../../hub/namespaces/mod.js';\n\nexport function disconnect(context: Context): void {\n const [, setState] = context.state();\n setState('network', null);\n setState('accounts', null);\n setState('connected', false);\n setState('connecting', false);\n}\n\nexport const recommended = [['disconnect', disconnect] as const];\n", "export const CAIP_NAMESPACE = 'solana';\nexport const CAIP_SOLANA_CHAIN_ID = '5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp';\n", "import { recommended as commonRecommended } from '../common/after.js';\n\nexport const recommended = [...commonRecommended];\n", "import type { Context } from '../../hub/namespaces/mod.js';\n\nexport function intoConnectionFinished(context: Context) {\n const [, setState] = context.state();\n setState('connecting', false);\n}\n\nexport const recommended = [['connect', intoConnectionFinished] as const];\n", "import { connectAndUpdateStateForSingleNetwork } from '../common/mod.js';\n\nexport const recommended = [\n ['connect', connectAndUpdateStateForSingleNetwork] as const,\n];\n", "import type { StoreApi } from 'zustand/vanilla';\n\nimport { createStore as createZustandStore } from 'zustand/vanilla';\n\nimport { hubStore, type HubStore } from './hub.js';\nimport { namespacesStore, type NamespaceStore } from './namespaces.js';\nimport { providersStore, type ProviderStore } from './providers.js';\n\n/************ State ************/\n\nexport interface State {\n hub: HubStore;\n providers: ProviderStore;\n namespaces: NamespaceStore;\n}\n\nexport type Store = StoreApi<State>;\nexport const createStore = (): Store => {\n return createZustandStore<State>((...api) => {\n return {\n hub: hubStore(...api),\n providers: providersStore(...api),\n namespaces: namespacesStore(...api),\n };\n });\n};\n", "/************ Namespace ************/\n\nimport type { StateCreator } from 'zustand';\n\nimport { produce } from 'immer';\n\nimport { namespaceStateSelector, type State } from './mod.js';\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface NamespaceConfig {\n // Currently, namespace doesn't has any config.\n}\n\nexport interface NamespaceData {\n accounts: null | string[];\n network: null | string;\n connected: boolean;\n connecting: boolean;\n}\n\ninterface NamespaceInfo {\n providerId: string;\n namespaceId: string;\n}\n\ntype NamespaceState = {\n list: Record<\n string,\n {\n info: NamespaceInfo;\n data: NamespaceData;\n error: unknown;\n }\n >;\n};\n\ninterface NamespaceActions {\n addNamespace: (id: string, config: NamespaceInfo) => void;\n updateStatus: <K extends keyof NamespaceData>(\n id: string,\n key: K,\n value: NamespaceData[K]\n ) => void;\n}\ninterface NamespaceSelectors {\n getNamespaceData(storeId: string): NamespaceData;\n}\n\nexport type NamespaceStore = NamespaceState &\n NamespaceActions &\n NamespaceSelectors;\ntype NamespaceStateCreator = StateCreator<State, [], [], NamespaceStore>;\n\nconst namespacesStore: NamespaceStateCreator = (set, get) => ({\n list: {},\n addNamespace: (id, info) => {\n const item = {\n data: {\n accounts: null,\n network: null,\n connected: false,\n connecting: false,\n },\n error: '',\n info,\n };\n\n set(\n produce((state: State) => {\n state.namespaces.list[id] = item;\n })\n );\n },\n updateStatus: (id, key, value) => {\n if (!get().namespaces.list[id]) {\n throw new Error(`No namespace with '${id}' found.`);\n }\n\n set(\n produce((state: State) => {\n state.namespaces.list[id].data[key] = value;\n })\n );\n },\n getNamespaceData(storeId) {\n return namespaceStateSelector(get(), storeId);\n },\n});\n\nexport { namespacesStore };\n", "import type { Namespace } from '../../namespaces/common/types.js';\nimport type { State as InternalProviderState } from '../provider/mod.js';\nimport type { StateCreator } from 'zustand';\n\nimport { produce } from 'immer';\n\nimport { guessProviderStateSelector, type State } from './mod.js';\n\ntype Browsers = 'firefox' | 'chrome' | 'edge' | 'brave' | 'homepage';\ntype Property<N extends string, V> = { name: N; value: V };\ntype DetachedInstances = Property<'detached', Namespace[]>;\n\nexport type ProviderInfo = {\n name: string;\n icon: string;\n extensions: Partial<Record<Browsers, string>>;\n properties?: DetachedInstances[];\n};\n\nexport interface ProviderConfig {\n info: ProviderInfo;\n}\n\ninterface ProviderData {\n installed: boolean;\n}\n\ntype ProviderState = {\n list: Record<\n string,\n {\n config: ProviderConfig;\n data: ProviderData;\n error: unknown;\n }\n >;\n};\ninterface ProviderActions {\n addProvider: (id: string, config: ProviderConfig) => void;\n updateStatus: <K extends keyof ProviderData>(\n id: string,\n key: K,\n value: ProviderData[K]\n ) => void;\n}\n\ninterface ProviderSelectors {\n /**\n * Provider has a limited state to itself, to be compatible with legacy, we try to produce same object as legacy\n * which includes namespace state as well.\n */\n guessNamespacesState: (id: string) => InternalProviderState;\n}\n\nexport type ProviderStore = ProviderState & ProviderActions & ProviderSelectors;\ntype ProvidersStateCreator = StateCreator<State, [], [], ProviderStore>;\n\nconst providersStore: ProvidersStateCreator = (set, get) => ({\n list: {},\n addProvider: (id, config) => {\n const item = {\n data: {\n installed: false,\n },\n error: '',\n config,\n };\n\n set(\n produce((state: State) => {\n state.providers.list[id] = item;\n })\n );\n },\n updateStatus: (id, key, value) => {\n if (!get().providers.list[id]) {\n throw new Error(`No namespace namespace with '${id}' found.`);\n }\n\n set(\n produce((state: State) => {\n state.providers.list[id].data[key] = value;\n })\n );\n },\n guessNamespacesState: (providerId: string): InternalProviderState => {\n return guessProviderStateSelector(get(), providerId);\n },\n});\n\nexport { providersStore };\n", "import type { Actions, Context, Operators } from '../hub/namespaces/types.js';\nimport type { AnyFunction, FunctionWithContext } from '../types/actions.js';\n\nexport interface ActionByBuilder<T, Context> {\n actionName: keyof T;\n and: Operators<T>;\n or: Operators<T>;\n after: Operators<T>;\n before: Operators<T>;\n action: FunctionWithContext<T[keyof T], Context>;\n}\n\n/*\n * TODO:\n * Currently, to use this builder you will write something like this:\n * new ActionBuilder<EvmActions, 'disconnect'>('disconnect').after(....)\n *\n * I couldn't figure it out to be able typescript infer the constructor value as key of actions.\n * Ideal usage:\n * new ActionBuilder<EvmActions>('disconnect').after(....)\n *\n */\nexport class ActionBuilder<T extends Actions<T>, K extends keyof T> {\n readonly name: K;\n #and: Operators<T> = new Map();\n #or: Operators<T> = new Map();\n #after: Operators<T> = new Map();\n #before: Operators<T> = new Map();\n #action: FunctionWithContext<T[keyof T], Context<T>> | undefined;\n\n constructor(name: K) {\n this.name = name;\n }\n\n public and(action: FunctionWithContext<AnyFunction, Context<T>>) {\n if (!this.#and.has(this.name)) {\n this.#and.set(this.name, []);\n }\n this.#and.get(this.name)?.push(action);\n return this;\n }\n\n public or(action: FunctionWithContext<AnyFunction, Context<T>>) {\n if (!this.#or.has(this.name)) {\n this.#or.set(this.name, []);\n }\n this.#or.get(this.name)?.push(action);\n return this;\n }\n\n public before(action: FunctionWithContext<AnyFunction, Context<T>>) {\n if (!this.#before.has(this.name)) {\n this.#before.set(this.name, []);\n }\n this.#before.get(this.name)?.push(action);\n return this;\n }\n\n public after(action: FunctionWithContext<AnyFunction, Context<T>>) {\n if (!this.#after.has(this.name)) {\n this.#after.set(this.name, []);\n }\n this.#after.get(this.name)?.push(action);\n return this;\n }\n\n public action(action: FunctionWithContext<T[keyof T], Context<T>>) {\n this.#action = action;\n return this;\n }\n\n public build(): ActionByBuilder<T, Context<T>> {\n if (!this.#action) {\n throw new Error('Your action builder should includes an action.');\n }\n\n return {\n actionName: this.name,\n action: this.#action,\n before: this.#before,\n after: this.#after,\n and: this.#and,\n or: this.#or,\n };\n }\n}\n", "/*\n * It is not a good idea to re-export all of CAIP because if they have a breaking change, we will break as well.\n * It would be better to create an abstraction over them and export our own interface to ensure it is under our control.\n */\nexport * as CAIP from 'caip';\n\nexport { generateStoreId } from '../hub/helpers.js';\nexport * from './versions.js';\n", "import { AccountId } from 'caip';\n\nexport function isValidCaipAddress(address: string): boolean {\n try {\n AccountId.parse(address);\n return true;\n } catch {\n return false;\n }\n}\n", "import type {\n Accounts,\n AccountsWithActiveChain,\n} from './../../types/accounts.js';\nimport type { Context } from '../../hub/namespaces/mod.js';\n\nimport { isValidCaipAddress } from './helpers.js';\n\nexport function connectAndUpdateStateForSingleNetwork(\n context: Context,\n accounts: Accounts\n) {\n if (!accounts.every(isValidCaipAddress)) {\n throw new Error(\n `Your provider should format account addresses in CAIP-10 format. Your provided accounts: ${accounts}`\n );\n }\n\n const [, setState] = context.state();\n setState('accounts', accounts);\n setState('connected', true);\n return accounts;\n}\n\nexport function connectAndUpdateStateForMultiNetworks(\n context: Context,\n accounts: AccountsWithActiveChain\n) {\n if (!accounts.accounts.every(isValidCaipAddress)) {\n throw new Error(\n `Your provider should format account addresses in CAIP-10 format. Your provided accounts: ${accounts.accounts}`\n );\n }\n\n const [, setState] = context.state();\n setState('accounts', accounts.accounts);\n setState('network', accounts.network);\n setState('connected', true);\n return accounts;\n}\n\nexport const recommended = [];\n", "import type { Context } from '../../hub/namespaces/mod.js';\n\nexport function intoConnecting(context: Context) {\n const [, setState] = context.state();\n setState('connecting', true);\n}\n\n// Please consider if you are going to add something here, make sure it works on all namespaces.\nexport const recommended = [['connect', intoConnecting] as const];\n", "import { recommended as commonRecommended } from '../common/before.js';\n\nexport const recommended = [...commonRecommended];\n", "import type { SolanaActions } from './types.js';\n\nimport { ActionBuilder } from '../../mod.js';\nimport { intoConnectionFinished } from '../common/after.js';\nimport { connectAndUpdateStateForSingleNetwork } from '../common/and.js';\n\nexport const connect = () =>\n new ActionBuilder<SolanaActions, 'connect'>('connect')\n .and(connectAndUpdateStateForSingleNetwork)\n .after(intoConnectionFinished);\n"],
5
5
  "mappings": "6IAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,EAAA,gBAAAC,IAKA,OAAS,aAAAC,MAAiB,OCHnB,SAASC,EAAWC,EAAwB,CACjD,GAAM,CAAC,CAAEC,CAAQ,EAAID,EAAQ,MAAM,EACnCC,EAAS,UAAW,IAAI,EACxBA,EAAS,WAAY,IAAI,EACzBA,EAAS,YAAa,EAAK,EAC3BA,EAAS,aAAc,EAAK,CAC9B,CANgBC,EAAAH,EAAA,cAQT,IAAMI,EAAc,CAAC,CAAC,aAAcJ,CAAU,CAAU,ECVxD,IAAMK,EAAiB,SACjBC,EAAuB,mCFU7B,IAAMC,EAAc,CAAC,GAAGA,CAAiB,EAEzC,SAASC,EACdC,EAC+D,CAC/D,IAAIC,EAGJ,MAAO,CACL,CAACC,EAASC,IAAQ,CAChB,IAAMC,EAAiBJ,EAAS,EAEhC,GAAI,CAACI,EACH,MAAM,IAAI,MACR,qFACF,EAGF,GAAM,CAAC,CAAEC,CAAQ,EAAIH,EAAQ,MAAM,EAwBnC,GAtBAD,EAAgBK,EAACC,GAAc,CAK7B,GAAI,CAACA,EAAW,CACdL,EAAQ,OAAO,YAAY,EAC3B,MACF,CAEAG,EAAS,WAAY,CACnBG,EAAU,OAAO,CACf,QAASD,EAAU,SAAS,EAC5B,QAAS,CACP,UAAWE,EACX,UAAWC,CACb,CACF,CAAC,CACH,CAAC,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EAAc,CAAC,CAAC,UAAWJ,CAAc,CAAU,ERNzD,IAAMK,EAAc,CACzB,CAAC,UAAWC,CAAqC,CACnD,ESJA,IAAAC,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,IAEO,IAAMC,EAAc,CAAC,GAAGA,CAAiB,ECFhD,IAAAC,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAMO,IAAMC,EAAUC,EAAA,IACrB,IAAIC,EAAwC,SAAS,EAClD,IAAIC,CAAqC,EACzC,MAAMC,CAAsB,EAHV",
6
6
  "names": ["actions_exports", "__export", "changeAccountSubscriber", "recommended", "AccountId", "disconnect", "context", "setState", "__name", "recommended", "CAIP_NAMESPACE", "CAIP_SOLANA_CHAIN_ID", "recommended", "changeAccountSubscriber", "instance", "eventCallback", "context", "err", "solanaInstance", "setState", "__name", "publicKey", "AccountId", "CAIP_NAMESPACE", "CAIP_SOLANA_CHAIN_ID", "_context", "after_exports", "__export", "recommended", "intoConnectionFinished", "context", "setState", "__name", "recommended", "recommended", "and_exports", "__export", "recommended", "createZustandStore", "produce", "produce", "ActionBuilder", "__name", "#and", "#or", "#after", "#before", "#action", "name", "action", "CAIP", "AccountId", "isValidCaipAddress", "address", "AccountId", "__name", "connectAndUpdateStateForSingleNetwork", "context", "accounts", "isValidCaipAddress", "setState", "__name", "intoConnecting", "context", "setState", "__name", "recommended", "recommended", "connectAndUpdateStateForSingleNetwork", "before_exports", "__export", "recommended", "recommended", "builders_exports", "__export", "connect", "connect", "__name", "ActionBuilder", "connectAndUpdateStateForSingleNetwork", "intoConnectionFinished"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"src/hub/helpers.ts":{"bytes":371,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/namespaces/errors.ts":{"bytes":328,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/namespaces/namespace.ts":{"bytes":12251,"imports":[{"path":"src/hub/helpers.ts","kind":"import-statement","original":"../helpers.js"},{"path":"src/hub/namespaces/errors.ts","kind":"import-statement","original":"./errors.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/namespaces/mod.ts":{"bytes":160,"imports":[{"path":"src/hub/namespaces/namespace.ts","kind":"import-statement","original":"./namespace.js"}],"format":"esm"},"src/hub/provider/provider.ts":{"bytes":9080,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/provider/mod.ts":{"bytes":196,"imports":[{"path":"src/hub/provider/provider.ts","kind":"import-statement","original":"./provider.js"}],"format":"esm"},"src/hub/hub.ts":{"bytes":3050,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/store/selectors.ts":{"bytes":2225,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/store/hub.ts":{"bytes":342,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/store/namespaces.ts":{"bytes":1927,"imports":[{"path":"immer","kind":"import-statement","external":true},{"path":"src/hub/store/mod.ts","kind":"import-statement","original":"./mod.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/store/providers.ts":{"bytes":2282,"imports":[{"path":"immer","kind":"import-statement","external":true},{"path":"src/hub/store/mod.ts","kind":"import-statement","original":"./mod.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/store/store.ts":{"bytes":722,"imports":[{"path":"zustand/vanilla","kind":"import-statement","external":true},{"path":"src/hub/store/hub.ts","kind":"import-statement","original":"./hub.js"},{"path":"src/hub/store/namespaces.ts","kind":"import-statement","original":"./namespaces.js"},{"path":"src/hub/store/providers.ts","kind":"import-statement","original":"./providers.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/store/mod.ts":{"bytes":319,"imports":[{"path":"src/hub/store/selectors.ts","kind":"import-statement","original":"./selectors.js"},{"path":"src/hub/store/store.ts","kind":"import-statement","original":"./store.js"}],"format":"esm"},"src/hub/mod.ts":{"bytes":428,"imports":[{"path":"src/hub/namespaces/mod.ts","kind":"import-statement","original":"./namespaces/mod.js"},{"path":"src/hub/provider/mod.ts","kind":"import-statement","original":"./provider/mod.js"},{"path":"src/hub/hub.ts","kind":"import-statement","original":"./hub.js"},{"path":"src/hub/store/mod.ts","kind":"import-statement","original":"./store/mod.js"},{"path":"src/hub/helpers.ts","kind":"import-statement","original":"./helpers.js"}],"format":"esm"},"src/builders/namespace.ts":{"bytes":6879,"imports":[{"path":"src/hub/mod.ts","kind":"import-statement","original":"../hub/mod.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/builders/provider.ts":{"bytes":1584,"imports":[{"path":"src/hub/provider/mod.ts","kind":"import-statement","original":"../hub/provider/mod.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/builders/action.ts":{"bytes":2385,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/builders/mod.ts":{"bytes":220,"imports":[{"path":"src/builders/namespace.ts","kind":"import-statement","original":"./namespace.js"},{"path":"src/builders/provider.ts","kind":"import-statement","original":"./provider.js"},{"path":"src/builders/action.ts","kind":"import-statement","original":"./action.js"}],"format":"esm"},"src/utils/versions.ts":{"bytes":1851,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/utils/mod.ts":{"bytes":356,"imports":[{"path":"caip","kind":"import-statement","external":true},{"path":"src/hub/helpers.ts","kind":"import-statement","original":"../hub/helpers.js"},{"path":"src/utils/versions.ts","kind":"import-statement","original":"./versions.js"}],"format":"esm"},"src/mod.ts":{"bytes":1344,"imports":[{"path":"src/hub/mod.ts","kind":"import-statement","original":"./hub/mod.js"},{"path":"src/builders/mod.ts","kind":"import-statement","original":"./builders/mod.js"},{"path":"src/utils/mod.ts","kind":"import-statement","original":"./utils/mod.js"}],"format":"esm"},"src/legacy/types.ts":{"bytes":6716,"imports":[],"format":"esm"},"src/legacy/persistor.ts":{"bytes":544,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/helpers.ts":{"bytes":1855,"imports":[{"path":"src/legacy/types.ts","kind":"import-statement","original":"./types.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/utils.ts":{"bytes":920,"imports":[{"path":"src/legacy/types.ts","kind":"import-statement","original":"./types.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/wallet.ts":{"bytes":15288,"imports":[{"path":"src/legacy/helpers.ts","kind":"import-statement","original":"./helpers.js"},{"path":"src/legacy/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/legacy/utils.ts","kind":"import-statement","original":"./utils.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/mod.ts":{"bytes":1599,"imports":[{"path":"src/legacy/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/legacy/persistor.ts","kind":"import-statement","original":"./persistor.js"},{"path":"src/legacy/helpers.ts","kind":"import-statement","original":"./helpers.js"},{"path":"src/legacy/wallet.ts","kind":"import-statement","original":"./wallet.js"},{"path":"src/legacy/utils.ts","kind":"import-statement","original":"./utils.js"}],"format":"esm"},"src/namespaces/common/actions.ts":{"bytes":347,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/namespaces/evm/constants.ts":{"bytes":83,"imports":[],"format":"esm"},"src/namespaces/evm/utils.ts":{"bytes":1450,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/namespaces/evm/actions.ts":{"bytes":3481,"imports":[{"path":"caip","kind":"import-statement","external":true},{"path":"src/namespaces/common/actions.ts","kind":"import-statement","original":"../common/actions.js"},{"path":"src/namespaces/evm/constants.ts","kind":"import-statement","original":"./constants.js"},{"path":"src/namespaces/evm/utils.ts","kind":"import-statement","original":"./utils.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/namespaces/common/after.ts":{"bytes":271,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/namespaces/evm/after.ts":{"bytes":123,"imports":[{"path":"src/namespaces/common/after.ts","kind":"import-statement","original":"../common/after.js"}],"format":"esm"},"src/namespaces/common/builders.ts":{"bytes":595,"imports":[{"path":"src/mod.ts","kind":"import-statement","original":"../../mod.js"},{"path":"src/namespaces/common/actions.ts","kind":"import-statement","original":"./actions.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/namespaces/common/helpers.ts":{"bytes":189,"imports":[{"path":"caip","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/namespaces/common/and.ts":{"bytes":1144,"imports":[{"path":"src/namespaces/common/helpers.ts","kind":"import-statement","original":"./helpers.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/namespaces/common/before.ts":{"bytes":351,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/namespaces/common/mod.ts":{"bytes":501,"imports":[{"path":"src/namespaces/common/actions.ts","kind":"import-statement","original":"./actions.js"},{"path":"src/namespaces/common/builders.ts","kind":"import-statement","original":"./builders.js"},{"path":"src/namespaces/common/after.ts","kind":"import-statement","original":"./after.js"},{"path":"src/namespaces/common/and.ts","kind":"import-statement","original":"./and.js"},{"path":"src/namespaces/common/before.ts","kind":"import-statement","original":"./before.js"}],"format":"esm"},"src/namespaces/evm/and.ts":{"bytes":170,"imports":[{"path":"src/namespaces/common/mod.ts","kind":"import-statement","original":"../common/mod.js"}],"format":"esm"},"src/namespaces/evm/before.ts":{"bytes":106,"imports":[{"path":"src/namespaces/common/mod.ts","kind":"import-statement","original":"../common/mod.js"}],"format":"esm"},"src/namespaces/evm/builders.ts":{"bytes":396,"imports":[{"path":"src/mod.ts","kind":"import-statement","original":"../../mod.js"},{"path":"src/namespaces/common/after.ts","kind":"import-statement","original":"../common/after.js"},{"path":"src/namespaces/common/and.ts","kind":"import-statement","original":"../common/and.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/namespaces/evm/mod.ts":{"bytes":363,"imports":[{"path":"src/namespaces/evm/actions.ts","kind":"import-statement","original":"./actions.js"},{"path":"src/namespaces/evm/after.ts","kind":"import-statement","original":"./after.js"},{"path":"src/namespaces/evm/and.ts","kind":"import-statement","original":"./and.js"},{"path":"src/namespaces/evm/before.ts","kind":"import-statement","original":"./before.js"},{"path":"src/namespaces/evm/utils.ts","kind":"import-statement","original":"./utils.js"},{"path":"src/namespaces/evm/builders.ts","kind":"import-statement","original":"./builders.js"},{"path":"src/namespaces/evm/constants.ts","kind":"import-statement","original":"./constants.js"}],"format":"esm"},"src/namespaces/solana/constants.ts":{"bytes":112,"imports":[],"format":"esm"},"src/namespaces/solana/actions.ts":{"bytes":2143,"imports":[{"path":"caip","kind":"import-statement","external":true},{"path":"src/namespaces/common/actions.ts","kind":"import-statement","original":"../common/actions.js"},{"path":"src/namespaces/solana/constants.ts","kind":"import-statement","original":"./constants.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/namespaces/solana/after.ts":{"bytes":123,"imports":[{"path":"src/namespaces/common/after.ts","kind":"import-statement","original":"../common/after.js"}],"format":"esm"},"src/namespaces/solana/and.ts":{"bytes":170,"imports":[{"path":"src/namespaces/common/mod.ts","kind":"import-statement","original":"../common/mod.js"}],"format":"esm"},"src/namespaces/solana/before.ts":{"bytes":124,"imports":[{"path":"src/namespaces/common/before.ts","kind":"import-statement","original":"../common/before.js"}],"format":"esm"},"src/namespaces/solana/builders.ts":{"bytes":402,"imports":[{"path":"src/mod.ts","kind":"import-statement","original":"../../mod.js"},{"path":"src/namespaces/common/after.ts","kind":"import-statement","original":"../common/after.js"},{"path":"src/namespaces/common/and.ts","kind":"import-statement","original":"../common/and.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/namespaces/solana/mod.ts":{"bytes":327,"imports":[{"path":"src/namespaces/solana/actions.ts","kind":"import-statement","original":"./actions.js"},{"path":"src/namespaces/solana/after.ts","kind":"import-statement","original":"./after.js"},{"path":"src/namespaces/solana/and.ts","kind":"import-statement","original":"./and.js"},{"path":"src/namespaces/solana/before.ts","kind":"import-statement","original":"./before.js"},{"path":"src/namespaces/solana/builders.ts","kind":"import-statement","original":"./builders.js"},{"path":"src/namespaces/solana/constants.ts","kind":"import-statement","original":"./constants.js"}],"format":"esm"}},"outputs":{"dist/mod.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":64156},"dist/mod.js":{"imports":[{"path":"zustand/vanilla","kind":"import-statement","external":true},{"path":"immer","kind":"import-statement","external":true},{"path":"immer","kind":"import-statement","external":true},{"path":"caip","kind":"import-statement","external":true}],"exports":["ActionBuilder","Hub","Namespace","NamespaceBuilder","Provider","ProviderBuilder","createStore","defineVersions","guessProviderStateSelector","namespaceStateSelector","pickVersion"],"entryPoint":"src/mod.ts","inputs":{"src/hub/helpers.ts":{"bytesInOutput":131},"src/hub/namespaces/errors.ts":{"bytesInOutput":235},"src/hub/namespaces/namespace.ts":{"bytesInOutput":2393},"src/hub/namespaces/mod.ts":{"bytesInOutput":0},"src/hub/mod.ts":{"bytesInOutput":0},"src/hub/provider/provider.ts":{"bytesInOutput":1837},"src/hub/provider/mod.ts":{"bytesInOutput":0},"src/hub/hub.ts":{"bytesInOutput":689},"src/hub/store/selectors.ts":{"bytesInOutput":383},"src/hub/store/mod.ts":{"bytesInOutput":0},"src/hub/store/store.ts":{"bytesInOutput":137},"src/hub/store/hub.ts":{"bytesInOutput":38},"src/hub/store/namespaces.ts":{"bytesInOutput":400},"src/hub/store/providers.ts":{"bytesInOutput":362},"src/mod.ts":{"bytesInOutput":0},"src/builders/namespace.ts":{"bytesInOutput":1222},"src/builders/mod.ts":{"bytesInOutput":0},"src/builders/provider.ts":{"bytesInOutput":461},"src/builders/action.ts":{"bytesInOutput":746},"src/utils/mod.ts":{"bytesInOutput":24},"src/utils/versions.ts":{"bytesInOutput":356}},"bytes":9748},"dist/utils/mod.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":3724},"dist/utils/mod.js":{"imports":[{"path":"caip","kind":"import-statement","external":true}],"exports":["CAIP","defineVersions","generateStoreId","legacyProviderImportsToVersionsInterface","pickVersion"],"entryPoint":"src/utils/mod.ts","inputs":{"src/utils/mod.ts":{"bytesInOutput":23},"src/hub/helpers.ts":{"bytesInOutput":58},"src/utils/versions.ts":{"bytesInOutput":456}},"bytes":771},"dist/legacy/mod.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":35821},"dist/legacy/mod.js":{"imports":[],"exports":["LegacyEvents","LegacyNamespace","LegacyNetworks","LegacyWallet","Persistor","legacyEagerConnectHandler","legacyFormatAddressWithNetwork","legacyGetBlockChainNameFromId","legacyIsEvmNamespace","legacyIsNamespaceDiscoverMode","legacyReadAccountAddress"],"entryPoint":"src/legacy/mod.ts","inputs":{"src/legacy/types.ts":{"bytesInOutput":1367},"src/legacy/mod.ts":{"bytesInOutput":0},"src/legacy/persistor.ts":{"bytesInOutput":206},"src/legacy/helpers.ts":{"bytesInOutput":610},"src/legacy/utils.ts":{"bytesInOutput":320},"src/legacy/wallet.ts":{"bytesInOutput":5725}},"bytes":8633},"dist/namespaces/evm/mod.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":23551},"dist/namespaces/evm/mod.js":{"imports":[{"path":"caip","kind":"import-statement","external":true},{"path":"zustand/vanilla","kind":"import-statement","external":true},{"path":"immer","kind":"import-statement","external":true},{"path":"immer","kind":"import-statement","external":true},{"path":"caip","kind":"import-statement","external":true},{"path":"caip","kind":"import-statement","external":true}],"exports":["CAIP_ETHEREUM_CHAIN_ID","CAIP_NAMESPACE","actions","after","and","before","builders","utils"],"entryPoint":"src/namespaces/evm/mod.ts","inputs":{"src/namespaces/evm/actions.ts":{"bytesInOutput":1248},"src/namespaces/common/actions.ts":{"bytesInOutput":149},"src/namespaces/evm/constants.ts":{"bytesInOutput":21},"src/namespaces/evm/utils.ts":{"bytesInOutput":701},"src/namespaces/evm/mod.ts":{"bytesInOutput":0},"src/namespaces/evm/after.ts":{"bytesInOutput":47},"src/namespaces/common/after.ts":{"bytesInOutput":103},"src/namespaces/evm/and.ts":{"bytesInOutput":56},"src/namespaces/common/mod.ts":{"bytesInOutput":0},"src/hub/namespaces/mod.ts":{"bytesInOutput":0},"src/hub/mod.ts":{"bytesInOutput":0},"src/hub/provider/mod.ts":{"bytesInOutput":0},"src/hub/store/mod.ts":{"bytesInOutput":0},"src/hub/store/store.ts":{"bytesInOutput":47},"src/hub/store/namespaces.ts":{"bytesInOutput":33},"src/hub/store/providers.ts":{"bytesInOutput":33},"src/mod.ts":{"bytesInOutput":0},"src/builders/mod.ts":{"bytesInOutput":0},"src/builders/action.ts":{"bytesInOutput":746},"src/utils/mod.ts":{"bytesInOutput":24},"src/namespaces/common/helpers.ts":{"bytesInOutput":114},"src/namespaces/common/and.ts":{"bytesInOutput":300},"src/namespaces/common/before.ts":{"bytesInOutput":95},"src/namespaces/evm/before.ts":{"bytesInOutput":47},"src/namespaces/evm/builders.ts":{"bytesInOutput":86}},"bytes":4150},"dist/namespaces/solana/mod.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":18664},"dist/namespaces/solana/mod.js":{"imports":[{"path":"caip","kind":"import-statement","external":true},{"path":"zustand/vanilla","kind":"import-statement","external":true},{"path":"immer","kind":"import-statement","external":true},{"path":"immer","kind":"import-statement","external":true},{"path":"caip","kind":"import-statement","external":true},{"path":"caip","kind":"import-statement","external":true}],"exports":["CAIP_NAMESPACE","CAIP_SOLANA_CHAIN_ID","actions","after","and","before","builders"],"entryPoint":"src/namespaces/solana/mod.ts","inputs":{"src/namespaces/solana/actions.ts":{"bytesInOutput":597},"src/namespaces/common/actions.ts":{"bytesInOutput":149},"src/namespaces/solana/constants.ts":{"bytesInOutput":52},"src/namespaces/solana/mod.ts":{"bytesInOutput":0},"src/namespaces/solana/after.ts":{"bytesInOutput":47},"src/namespaces/common/after.ts":{"bytesInOutput":103},"src/namespaces/solana/and.ts":{"bytesInOutput":56},"src/namespaces/common/mod.ts":{"bytesInOutput":0},"src/hub/namespaces/mod.ts":{"bytesInOutput":0},"src/hub/mod.ts":{"bytesInOutput":0},"src/hub/provider/mod.ts":{"bytesInOutput":0},"src/hub/store/mod.ts":{"bytesInOutput":0},"src/hub/store/store.ts":{"bytesInOutput":47},"src/hub/store/namespaces.ts":{"bytesInOutput":33},"src/hub/store/providers.ts":{"bytesInOutput":33},"src/mod.ts":{"bytesInOutput":0},"src/builders/mod.ts":{"bytesInOutput":0},"src/builders/action.ts":{"bytesInOutput":746},"src/utils/mod.ts":{"bytesInOutput":24},"src/namespaces/common/helpers.ts":{"bytesInOutput":114},"src/namespaces/common/and.ts":{"bytesInOutput":250},"src/namespaces/common/before.ts":{"bytesInOutput":95},"src/namespaces/solana/before.ts":{"bytesInOutput":47},"src/namespaces/solana/builders.ts":{"bytesInOutput":86}},"bytes":2766},"dist/namespaces/common/mod.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":14751},"dist/namespaces/common/mod.js":{"imports":[{"path":"zustand/vanilla","kind":"import-statement","external":true},{"path":"immer","kind":"import-statement","external":true},{"path":"immer","kind":"import-statement","external":true},{"path":"caip","kind":"import-statement","external":true},{"path":"caip","kind":"import-statement","external":true}],"exports":["actions","afterRecommended","andRecommended","beforeRecommended","builders","connectAndUpdateStateForMultiNetworks","connectAndUpdateStateForSingleNetwork","intoConnecting","intoConnectionFinished"],"entryPoint":"src/namespaces/common/mod.ts","inputs":{"src/namespaces/common/actions.ts":{"bytesInOutput":200},"src/namespaces/common/mod.ts":{"bytesInOutput":0},"src/namespaces/common/builders.ts":{"bytesInOutput":102},"src/hub/namespaces/mod.ts":{"bytesInOutput":0},"src/hub/mod.ts":{"bytesInOutput":0},"src/hub/provider/mod.ts":{"bytesInOutput":0},"src/hub/store/mod.ts":{"bytesInOutput":0},"src/hub/store/store.ts":{"bytesInOutput":47},"src/hub/store/namespaces.ts":{"bytesInOutput":33},"src/hub/store/providers.ts":{"bytesInOutput":33},"src/mod.ts":{"bytesInOutput":0},"src/builders/mod.ts":{"bytesInOutput":0},"src/builders/action.ts":{"bytesInOutput":746},"src/utils/mod.ts":{"bytesInOutput":24},"src/namespaces/common/after.ts":{"bytesInOutput":103},"src/namespaces/common/helpers.ts":{"bytesInOutput":114},"src/namespaces/common/and.ts":{"bytesInOutput":559},"src/namespaces/common/before.ts":{"bytesInOutput":95}},"bytes":2464}}}
1
+ {"inputs":{"src/hub/helpers.ts":{"bytes":371,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/namespaces/errors.ts":{"bytes":328,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/namespaces/namespace.ts":{"bytes":12251,"imports":[{"path":"src/hub/helpers.ts","kind":"import-statement","original":"../helpers.js"},{"path":"src/hub/namespaces/errors.ts","kind":"import-statement","original":"./errors.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/namespaces/mod.ts":{"bytes":160,"imports":[{"path":"src/hub/namespaces/namespace.ts","kind":"import-statement","original":"./namespace.js"}],"format":"esm"},"src/hub/provider/provider.ts":{"bytes":9080,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/provider/mod.ts":{"bytes":196,"imports":[{"path":"src/hub/provider/provider.ts","kind":"import-statement","original":"./provider.js"}],"format":"esm"},"src/hub/hub.ts":{"bytes":3050,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/store/selectors.ts":{"bytes":2225,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/store/hub.ts":{"bytes":342,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/store/namespaces.ts":{"bytes":1927,"imports":[{"path":"immer","kind":"import-statement","external":true},{"path":"src/hub/store/mod.ts","kind":"import-statement","original":"./mod.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/store/providers.ts":{"bytes":2274,"imports":[{"path":"immer","kind":"import-statement","external":true},{"path":"src/hub/store/mod.ts","kind":"import-statement","original":"./mod.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/store/store.ts":{"bytes":722,"imports":[{"path":"zustand/vanilla","kind":"import-statement","external":true},{"path":"src/hub/store/hub.ts","kind":"import-statement","original":"./hub.js"},{"path":"src/hub/store/namespaces.ts","kind":"import-statement","original":"./namespaces.js"},{"path":"src/hub/store/providers.ts","kind":"import-statement","original":"./providers.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/store/mod.ts":{"bytes":319,"imports":[{"path":"src/hub/store/selectors.ts","kind":"import-statement","original":"./selectors.js"},{"path":"src/hub/store/store.ts","kind":"import-statement","original":"./store.js"}],"format":"esm"},"src/hub/mod.ts":{"bytes":428,"imports":[{"path":"src/hub/namespaces/mod.ts","kind":"import-statement","original":"./namespaces/mod.js"},{"path":"src/hub/provider/mod.ts","kind":"import-statement","original":"./provider/mod.js"},{"path":"src/hub/hub.ts","kind":"import-statement","original":"./hub.js"},{"path":"src/hub/store/mod.ts","kind":"import-statement","original":"./store/mod.js"},{"path":"src/hub/helpers.ts","kind":"import-statement","original":"./helpers.js"}],"format":"esm"},"src/builders/namespace.ts":{"bytes":6879,"imports":[{"path":"src/hub/mod.ts","kind":"import-statement","original":"../hub/mod.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/builders/provider.ts":{"bytes":1584,"imports":[{"path":"src/hub/provider/mod.ts","kind":"import-statement","original":"../hub/provider/mod.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/builders/action.ts":{"bytes":2385,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/builders/mod.ts":{"bytes":220,"imports":[{"path":"src/builders/namespace.ts","kind":"import-statement","original":"./namespace.js"},{"path":"src/builders/provider.ts","kind":"import-statement","original":"./provider.js"},{"path":"src/builders/action.ts","kind":"import-statement","original":"./action.js"}],"format":"esm"},"src/utils/versions.ts":{"bytes":1851,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/utils/mod.ts":{"bytes":356,"imports":[{"path":"caip","kind":"import-statement","external":true},{"path":"src/hub/helpers.ts","kind":"import-statement","original":"../hub/helpers.js"},{"path":"src/utils/versions.ts","kind":"import-statement","original":"./versions.js"}],"format":"esm"},"src/mod.ts":{"bytes":1344,"imports":[{"path":"src/hub/mod.ts","kind":"import-statement","original":"./hub/mod.js"},{"path":"src/builders/mod.ts","kind":"import-statement","original":"./builders/mod.js"},{"path":"src/utils/mod.ts","kind":"import-statement","original":"./utils/mod.js"}],"format":"esm"},"src/legacy/types.ts":{"bytes":6444,"imports":[],"format":"esm"},"src/legacy/persistor.ts":{"bytes":544,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/helpers.ts":{"bytes":1855,"imports":[{"path":"src/legacy/types.ts","kind":"import-statement","original":"./types.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/utils.ts":{"bytes":645,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/wallet.ts":{"bytes":15547,"imports":[{"path":"src/legacy/helpers.ts","kind":"import-statement","original":"./helpers.js"},{"path":"src/legacy/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/legacy/utils.ts","kind":"import-statement","original":"./utils.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/mod.ts":{"bytes":1428,"imports":[{"path":"src/legacy/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/legacy/persistor.ts","kind":"import-statement","original":"./persistor.js"},{"path":"src/legacy/helpers.ts","kind":"import-statement","original":"./helpers.js"},{"path":"src/legacy/wallet.ts","kind":"import-statement","original":"./wallet.js"},{"path":"src/legacy/utils.ts","kind":"import-statement","original":"./utils.js"}],"format":"esm"},"src/namespaces/common/actions.ts":{"bytes":347,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/namespaces/evm/constants.ts":{"bytes":83,"imports":[],"format":"esm"},"src/namespaces/evm/utils.ts":{"bytes":1450,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/namespaces/evm/actions.ts":{"bytes":4250,"imports":[{"path":"caip","kind":"import-statement","external":true},{"path":"src/namespaces/common/actions.ts","kind":"import-statement","original":"../common/actions.js"},{"path":"src/namespaces/evm/constants.ts","kind":"import-statement","original":"./constants.js"},{"path":"src/namespaces/evm/utils.ts","kind":"import-statement","original":"./utils.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/namespaces/common/after.ts":{"bytes":271,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/namespaces/evm/after.ts":{"bytes":123,"imports":[{"path":"src/namespaces/common/after.ts","kind":"import-statement","original":"../common/after.js"}],"format":"esm"},"src/namespaces/common/builders.ts":{"bytes":545,"imports":[{"path":"src/mod.ts","kind":"import-statement","original":"../../mod.js"},{"path":"src/namespaces/common/actions.ts","kind":"import-statement","original":"./actions.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/namespaces/common/helpers.ts":{"bytes":189,"imports":[{"path":"caip","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/namespaces/common/and.ts":{"bytes":1144,"imports":[{"path":"src/namespaces/common/helpers.ts","kind":"import-statement","original":"./helpers.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/namespaces/common/before.ts":{"bytes":351,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/namespaces/common/mod.ts":{"bytes":547,"imports":[{"path":"src/namespaces/common/actions.ts","kind":"import-statement","original":"./actions.js"},{"path":"src/namespaces/common/builders.ts","kind":"import-statement","original":"./builders.js"},{"path":"src/namespaces/common/after.ts","kind":"import-statement","original":"./after.js"},{"path":"src/namespaces/common/and.ts","kind":"import-statement","original":"./and.js"},{"path":"src/namespaces/common/before.ts","kind":"import-statement","original":"./before.js"}],"format":"esm"},"src/namespaces/evm/and.ts":{"bytes":170,"imports":[{"path":"src/namespaces/common/mod.ts","kind":"import-statement","original":"../common/mod.js"}],"format":"esm"},"src/namespaces/evm/before.ts":{"bytes":106,"imports":[{"path":"src/namespaces/common/mod.ts","kind":"import-statement","original":"../common/mod.js"}],"format":"esm"},"src/namespaces/evm/builders.ts":{"bytes":396,"imports":[{"path":"src/mod.ts","kind":"import-statement","original":"../../mod.js"},{"path":"src/namespaces/common/after.ts","kind":"import-statement","original":"../common/after.js"},{"path":"src/namespaces/common/and.ts","kind":"import-statement","original":"../common/and.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/namespaces/evm/mod.ts":{"bytes":363,"imports":[{"path":"src/namespaces/evm/actions.ts","kind":"import-statement","original":"./actions.js"},{"path":"src/namespaces/evm/after.ts","kind":"import-statement","original":"./after.js"},{"path":"src/namespaces/evm/and.ts","kind":"import-statement","original":"./and.js"},{"path":"src/namespaces/evm/before.ts","kind":"import-statement","original":"./before.js"},{"path":"src/namespaces/evm/utils.ts","kind":"import-statement","original":"./utils.js"},{"path":"src/namespaces/evm/builders.ts","kind":"import-statement","original":"./builders.js"},{"path":"src/namespaces/evm/constants.ts","kind":"import-statement","original":"./constants.js"}],"format":"esm"},"src/namespaces/solana/constants.ts":{"bytes":112,"imports":[],"format":"esm"},"src/namespaces/solana/actions.ts":{"bytes":2143,"imports":[{"path":"caip","kind":"import-statement","external":true},{"path":"src/namespaces/common/actions.ts","kind":"import-statement","original":"../common/actions.js"},{"path":"src/namespaces/solana/constants.ts","kind":"import-statement","original":"./constants.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/namespaces/solana/after.ts":{"bytes":123,"imports":[{"path":"src/namespaces/common/after.ts","kind":"import-statement","original":"../common/after.js"}],"format":"esm"},"src/namespaces/solana/and.ts":{"bytes":170,"imports":[{"path":"src/namespaces/common/mod.ts","kind":"import-statement","original":"../common/mod.js"}],"format":"esm"},"src/namespaces/solana/before.ts":{"bytes":124,"imports":[{"path":"src/namespaces/common/before.ts","kind":"import-statement","original":"../common/before.js"}],"format":"esm"},"src/namespaces/solana/builders.ts":{"bytes":402,"imports":[{"path":"src/mod.ts","kind":"import-statement","original":"../../mod.js"},{"path":"src/namespaces/common/after.ts","kind":"import-statement","original":"../common/after.js"},{"path":"src/namespaces/common/and.ts","kind":"import-statement","original":"../common/and.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/namespaces/solana/mod.ts":{"bytes":327,"imports":[{"path":"src/namespaces/solana/actions.ts","kind":"import-statement","original":"./actions.js"},{"path":"src/namespaces/solana/after.ts","kind":"import-statement","original":"./after.js"},{"path":"src/namespaces/solana/and.ts","kind":"import-statement","original":"./and.js"},{"path":"src/namespaces/solana/before.ts","kind":"import-statement","original":"./before.js"},{"path":"src/namespaces/solana/builders.ts","kind":"import-statement","original":"./builders.js"},{"path":"src/namespaces/solana/constants.ts","kind":"import-statement","original":"./constants.js"}],"format":"esm"}},"outputs":{"dist/mod.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":64148},"dist/mod.js":{"imports":[{"path":"zustand/vanilla","kind":"import-statement","external":true},{"path":"immer","kind":"import-statement","external":true},{"path":"immer","kind":"import-statement","external":true},{"path":"caip","kind":"import-statement","external":true}],"exports":["ActionBuilder","Hub","Namespace","NamespaceBuilder","Provider","ProviderBuilder","createStore","defineVersions","guessProviderStateSelector","namespaceStateSelector","pickVersion"],"entryPoint":"src/mod.ts","inputs":{"src/hub/helpers.ts":{"bytesInOutput":131},"src/hub/namespaces/errors.ts":{"bytesInOutput":235},"src/hub/namespaces/namespace.ts":{"bytesInOutput":2393},"src/hub/namespaces/mod.ts":{"bytesInOutput":0},"src/hub/mod.ts":{"bytesInOutput":0},"src/hub/provider/provider.ts":{"bytesInOutput":1837},"src/hub/provider/mod.ts":{"bytesInOutput":0},"src/hub/hub.ts":{"bytesInOutput":689},"src/hub/store/selectors.ts":{"bytesInOutput":383},"src/hub/store/mod.ts":{"bytesInOutput":0},"src/hub/store/store.ts":{"bytesInOutput":137},"src/hub/store/hub.ts":{"bytesInOutput":38},"src/hub/store/namespaces.ts":{"bytesInOutput":400},"src/hub/store/providers.ts":{"bytesInOutput":362},"src/mod.ts":{"bytesInOutput":0},"src/builders/namespace.ts":{"bytesInOutput":1222},"src/builders/mod.ts":{"bytesInOutput":0},"src/builders/provider.ts":{"bytesInOutput":461},"src/builders/action.ts":{"bytesInOutput":746},"src/utils/mod.ts":{"bytesInOutput":24},"src/utils/versions.ts":{"bytesInOutput":356}},"bytes":9748},"dist/utils/mod.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":3724},"dist/utils/mod.js":{"imports":[{"path":"caip","kind":"import-statement","external":true}],"exports":["CAIP","defineVersions","generateStoreId","legacyProviderImportsToVersionsInterface","pickVersion"],"entryPoint":"src/utils/mod.ts","inputs":{"src/utils/mod.ts":{"bytesInOutput":23},"src/hub/helpers.ts":{"bytesInOutput":58},"src/utils/versions.ts":{"bytesInOutput":456}},"bytes":771},"dist/legacy/mod.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":35384},"dist/legacy/mod.js":{"imports":[],"exports":["LegacyEvents","LegacyNetworks","LegacyWallet","Persistor","legacyEagerConnectHandler","legacyFormatAddressWithNetwork","legacyGetBlockChainNameFromId","legacyIsEvmNamespace","legacyReadAccountAddress"],"entryPoint":"src/legacy/mod.ts","inputs":{"src/legacy/types.ts":{"bytesInOutput":1251},"src/legacy/mod.ts":{"bytesInOutput":0},"src/legacy/persistor.ts":{"bytesInOutput":206},"src/legacy/helpers.ts":{"bytesInOutput":610},"src/legacy/utils.ts":{"bytesInOutput":238},"src/legacy/wallet.ts":{"bytesInOutput":5876}},"bytes":8530},"dist/namespaces/evm/mod.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":24497},"dist/namespaces/evm/mod.js":{"imports":[{"path":"caip","kind":"import-statement","external":true},{"path":"zustand/vanilla","kind":"import-statement","external":true},{"path":"immer","kind":"import-statement","external":true},{"path":"immer","kind":"import-statement","external":true},{"path":"caip","kind":"import-statement","external":true},{"path":"caip","kind":"import-statement","external":true}],"exports":["CAIP_ETHEREUM_CHAIN_ID","CAIP_NAMESPACE","actions","after","and","before","builders","utils"],"entryPoint":"src/namespaces/evm/mod.ts","inputs":{"src/namespaces/evm/actions.ts":{"bytesInOutput":1366},"src/namespaces/common/actions.ts":{"bytesInOutput":149},"src/namespaces/evm/constants.ts":{"bytesInOutput":21},"src/namespaces/evm/utils.ts":{"bytesInOutput":701},"src/namespaces/evm/mod.ts":{"bytesInOutput":0},"src/namespaces/evm/after.ts":{"bytesInOutput":47},"src/namespaces/common/after.ts":{"bytesInOutput":103},"src/namespaces/evm/and.ts":{"bytesInOutput":56},"src/namespaces/common/mod.ts":{"bytesInOutput":0},"src/hub/namespaces/mod.ts":{"bytesInOutput":0},"src/hub/mod.ts":{"bytesInOutput":0},"src/hub/provider/mod.ts":{"bytesInOutput":0},"src/hub/store/mod.ts":{"bytesInOutput":0},"src/hub/store/store.ts":{"bytesInOutput":47},"src/hub/store/namespaces.ts":{"bytesInOutput":33},"src/hub/store/providers.ts":{"bytesInOutput":33},"src/mod.ts":{"bytesInOutput":0},"src/builders/mod.ts":{"bytesInOutput":0},"src/builders/action.ts":{"bytesInOutput":746},"src/utils/mod.ts":{"bytesInOutput":24},"src/namespaces/common/helpers.ts":{"bytesInOutput":114},"src/namespaces/common/and.ts":{"bytesInOutput":300},"src/namespaces/common/before.ts":{"bytesInOutput":95},"src/namespaces/evm/before.ts":{"bytesInOutput":47},"src/namespaces/evm/builders.ts":{"bytesInOutput":88}},"bytes":4270},"dist/namespaces/solana/mod.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":18656},"dist/namespaces/solana/mod.js":{"imports":[{"path":"caip","kind":"import-statement","external":true},{"path":"zustand/vanilla","kind":"import-statement","external":true},{"path":"immer","kind":"import-statement","external":true},{"path":"immer","kind":"import-statement","external":true},{"path":"caip","kind":"import-statement","external":true},{"path":"caip","kind":"import-statement","external":true}],"exports":["CAIP_NAMESPACE","CAIP_SOLANA_CHAIN_ID","actions","after","and","before","builders"],"entryPoint":"src/namespaces/solana/mod.ts","inputs":{"src/namespaces/solana/actions.ts":{"bytesInOutput":597},"src/namespaces/common/actions.ts":{"bytesInOutput":149},"src/namespaces/solana/constants.ts":{"bytesInOutput":52},"src/namespaces/solana/mod.ts":{"bytesInOutput":0},"src/namespaces/solana/after.ts":{"bytesInOutput":47},"src/namespaces/common/after.ts":{"bytesInOutput":103},"src/namespaces/solana/and.ts":{"bytesInOutput":56},"src/namespaces/common/mod.ts":{"bytesInOutput":0},"src/hub/namespaces/mod.ts":{"bytesInOutput":0},"src/hub/mod.ts":{"bytesInOutput":0},"src/hub/provider/mod.ts":{"bytesInOutput":0},"src/hub/store/mod.ts":{"bytesInOutput":0},"src/hub/store/store.ts":{"bytesInOutput":47},"src/hub/store/namespaces.ts":{"bytesInOutput":33},"src/hub/store/providers.ts":{"bytesInOutput":33},"src/mod.ts":{"bytesInOutput":0},"src/builders/mod.ts":{"bytesInOutput":0},"src/builders/action.ts":{"bytesInOutput":746},"src/utils/mod.ts":{"bytesInOutput":24},"src/namespaces/common/helpers.ts":{"bytesInOutput":114},"src/namespaces/common/and.ts":{"bytesInOutput":250},"src/namespaces/common/before.ts":{"bytesInOutput":95},"src/namespaces/solana/before.ts":{"bytesInOutput":47},"src/namespaces/solana/builders.ts":{"bytesInOutput":86}},"bytes":2766},"dist/namespaces/common/mod.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":14657},"dist/namespaces/common/mod.js":{"imports":[{"path":"zustand/vanilla","kind":"import-statement","external":true},{"path":"immer","kind":"import-statement","external":true},{"path":"immer","kind":"import-statement","external":true},{"path":"caip","kind":"import-statement","external":true},{"path":"caip","kind":"import-statement","external":true}],"exports":["actions","afterRecommended","andRecommended","beforeRecommended","builders","connectAndUpdateStateForMultiNetworks","connectAndUpdateStateForSingleNetwork","intoConnecting","intoConnectionFinished"],"entryPoint":"src/namespaces/common/mod.ts","inputs":{"src/namespaces/common/actions.ts":{"bytesInOutput":200},"src/namespaces/common/mod.ts":{"bytesInOutput":0},"src/namespaces/common/builders.ts":{"bytesInOutput":89},"src/hub/namespaces/mod.ts":{"bytesInOutput":0},"src/hub/mod.ts":{"bytesInOutput":0},"src/hub/provider/mod.ts":{"bytesInOutput":0},"src/hub/store/mod.ts":{"bytesInOutput":0},"src/hub/store/store.ts":{"bytesInOutput":47},"src/hub/store/namespaces.ts":{"bytesInOutput":33},"src/hub/store/providers.ts":{"bytesInOutput":33},"src/mod.ts":{"bytesInOutput":0},"src/builders/mod.ts":{"bytesInOutput":0},"src/builders/action.ts":{"bytesInOutput":746},"src/utils/mod.ts":{"bytesInOutput":24},"src/namespaces/common/after.ts":{"bytesInOutput":103},"src/namespaces/common/helpers.ts":{"bytesInOutput":114},"src/namespaces/common/and.ts":{"bytesInOutput":559},"src/namespaces/common/before.ts":{"bytesInOutput":95}},"bytes":2451}}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/wallets-core",
3
- "version": "0.40.1-next.1",
3
+ "version": "0.40.1-next.11",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/mod.ts",
@@ -42,7 +42,7 @@
42
42
  "ts-check": "tsc --declaration --emitDeclarationOnly -p ./tsconfig.json",
43
43
  "clean": "rimraf dist",
44
44
  "format": "prettier --write '{.,src}/**/*.{ts,tsx}'",
45
- "lint": "eslint \"**/*.{ts,tsx}\" --ignore-path ../../.eslintignore",
45
+ "lint": "eslint \"**/*.{ts,tsx}\"",
46
46
  "test": "vitest",
47
47
  "coverage": "vitest run --coverage"
48
48
  },
@@ -54,7 +54,7 @@
54
54
  "dependencies": {
55
55
  "caip": "^1.1.1",
56
56
  "immer": "^10.0.4",
57
- "rango-types": "^0.1.74",
57
+ "rango-types": "^0.1.78",
58
58
  "zustand": "^4.5.2"
59
59
  },
60
60
  "publishConfig": {
@@ -1,5 +1,5 @@
1
+ import type { Namespace } from '../../namespaces/common/types.js';
1
2
  import type { State as InternalProviderState } from '../provider/mod.js';
2
- import type { CommonNamespaceKeys } from '../provider/types.js';
3
3
  import type { StateCreator } from 'zustand';
4
4
 
5
5
  import { produce } from 'immer';
@@ -8,7 +8,7 @@ import { guessProviderStateSelector, type State } from './mod.js';
8
8
 
9
9
  type Browsers = 'firefox' | 'chrome' | 'edge' | 'brave' | 'homepage';
10
10
  type Property<N extends string, V> = { name: N; value: V };
11
- type DetachedInstances = Property<'detached', CommonNamespaceKeys[]>;
11
+ type DetachedInstances = Property<'detached', Namespace[]>;
12
12
 
13
13
  export type ProviderInfo = {
14
14
  name: string;
package/src/legacy/mod.ts CHANGED
@@ -24,14 +24,9 @@ export type {
24
24
  WalletInfo as LegacyWalletInfo,
25
25
  ConnectResult as LegacyConnectResult,
26
26
  NamespaceInputForConnect as LegacyNamespaceInputForConnect,
27
- NamespaceInputWithDiscoverMode as LegacyNamespaceInputWithDiscoverMode,
28
27
  } from './types.js';
29
28
 
30
- export {
31
- Events as LegacyEvents,
32
- Namespace as LegacyNamespace,
33
- Networks as LegacyNetworks,
34
- } from './types.js';
29
+ export { Events as LegacyEvents, Networks as LegacyNetworks } from './types.js';
35
30
 
36
31
  export { Persistor } from './persistor.js';
37
32
  export {
@@ -43,6 +38,5 @@ export { default as LegacyWallet } from './wallet.js';
43
38
 
44
39
  export {
45
40
  eagerConnectHandler as legacyEagerConnectHandler,
46
- isNamespaceDiscoverMode as legacyIsNamespaceDiscoverMode,
47
41
  isEvmNamespace as legacyIsEvmNamespace,
48
42
  } from './utils.js';
@@ -1,4 +1,5 @@
1
1
  import type { State as WalletState } from './wallet.js';
2
+ import type { Namespace } from '../namespaces/common/mod.js';
2
3
  import type { BlockchainMeta, SignerFactory } from 'rango-types';
3
4
 
4
5
  export enum Networks {
@@ -64,15 +65,6 @@ export enum Networks {
64
65
  Unknown = 'Unkown',
65
66
  }
66
67
 
67
- export enum Namespace {
68
- Solana = 'Solana',
69
- Evm = 'EVM',
70
- Cosmos = 'Cosmos',
71
- Utxo = 'UTXO',
72
- Starknet = 'Starknet',
73
- Tron = 'Tron',
74
- }
75
-
76
68
  export type NamespaceData = {
77
69
  namespace: Namespace;
78
70
  derivationPath?: string;
@@ -89,6 +81,28 @@ export type InstallObjects = {
89
81
  DEFAULT: string;
90
82
  };
91
83
 
84
+ interface NeedsNamespace {
85
+ selection: 'single' | 'multiple';
86
+ data: {
87
+ label: string;
88
+ /**
89
+ * By using a matched `blockchain.name` (in meta) and `id`, we show logo in Namespace modal
90
+ * e.g. ETH
91
+ */
92
+ id: string;
93
+ value: Namespace;
94
+ }[];
95
+ }
96
+
97
+ interface NeedsDerivationPath {
98
+ data: {
99
+ id: string;
100
+ label: string;
101
+ namespace: Namespace;
102
+ generateDerivationPath: (index: string) => string;
103
+ }[];
104
+ }
105
+
92
106
  export type WalletInfo = {
93
107
  name: string;
94
108
  img: string;
@@ -101,9 +115,9 @@ export type WalletInfo = {
101
115
  showOnMobile?: boolean;
102
116
  isContractWallet?: boolean;
103
117
  mobileWallet?: boolean;
104
- namespaces?: Namespace[];
105
- singleNamespace?: boolean;
106
- needsDerivationPath?: boolean;
118
+
119
+ needsDerivationPath?: NeedsDerivationPath;
120
+ needsNamespace?: NeedsNamespace;
107
121
  };
108
122
 
109
123
  export type State = {
@@ -248,32 +262,14 @@ export type ProviderInterface = { config: WalletConfig } & WalletActions;
248
262
  // it comes from wallets.ts and `connect`
249
263
  type NetworkTypeFromLegacyConnect = Network | undefined;
250
264
 
251
- export type NetworkTypeForNamespace<T extends NamespacesWithDiscoverMode> =
252
- T extends 'DISCOVER_MODE'
253
- ? string
254
- : T extends Namespace
255
- ? NetworkTypeFromLegacyConnect
256
- : never;
257
-
258
- export type NamespacesWithDiscoverMode = Namespace | 'DISCOVER_MODE';
259
-
260
- export type NamespaceInputWithDiscoverMode = {
261
- namespace: 'DISCOVER_MODE';
262
- network: string;
265
+ export type NamespaceInputForConnect<T extends Namespace = Namespace> = {
266
+ /**
267
+ * By default, you should specify namespace (e.g. evm).
268
+ */
269
+ namespace: T;
270
+ /**
271
+ * In some cases, we need to connect a specific network on a namespace. e.g. Polygon on EVM.
272
+ */
273
+ network: NetworkTypeFromLegacyConnect;
263
274
  derivationPath?: string;
264
275
  };
265
-
266
- export type NamespaceInputForConnect<T extends Namespace = Namespace> =
267
- | {
268
- /**
269
- * By default, you should specify namespace (e.g. evm).
270
- * For backward compatibility with legacy implementation, DISCOVER_MODE will try to map a list of known (and hardcoded) networks to a namespace.
271
- */
272
- namespace: T;
273
- /**
274
- * In some cases, we need to connect a specific network on a namespace. e.g. Polygon on EVM.
275
- */
276
- network: NetworkTypeForNamespace<T>;
277
- derivationPath?: string;
278
- }
279
- | NamespaceInputWithDiscoverMode;
@@ -1,9 +1,4 @@
1
- import type {
2
- NamespaceInputForConnect,
3
- NamespaceInputWithDiscoverMode,
4
- } from './types.js';
5
-
6
- import { Namespace } from './types.js';
1
+ import type { NamespaceInputForConnect } from './types.js';
7
2
 
8
3
  export async function eagerConnectHandler<R = unknown>(params: {
9
4
  canEagerConnect: () => Promise<boolean>;
@@ -18,14 +13,8 @@ export async function eagerConnectHandler<R = unknown>(params: {
18
13
  throw new Error(`can't restore connection for ${params.providerName}.`);
19
14
  }
20
15
 
21
- export function isNamespaceDiscoverMode(
22
- namespace: NamespaceInputForConnect
23
- ): namespace is NamespaceInputWithDiscoverMode {
24
- return namespace.namespace === 'DISCOVER_MODE';
25
- }
26
-
27
16
  export function isEvmNamespace(
28
17
  namespace: NamespaceInputForConnect
29
- ): namespace is NamespaceInputForConnect<Namespace.Evm> {
30
- return namespace.namespace === Namespace.Evm;
18
+ ): namespace is NamespaceInputForConnect<'EVM'> {
19
+ return namespace.namespace === 'EVM';
31
20
  }
@@ -318,6 +318,13 @@ class Wallet<InstanceType = any> {
318
318
  }
319
319
 
320
320
  onInit() {
321
+ // some times functions can be overridden by wallets. see rf-2119
322
+ if (!this.actions.getInstance) {
323
+ throw new Error(
324
+ `Provider hasn't defined how to get wallet's instance. provider: ${this.options.config.type} on: onInit`
325
+ );
326
+ }
327
+
321
328
  if (!this.options.config.isAsyncInstance) {
322
329
  const instance = this.actions.getInstance();
323
330
  if (!!instance && !this.state.installed) {