@rango-dev/wallets-core 0.49.1-next.2 → 0.49.1-next.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hub/store/mod.js +1 -1
- package/dist/hub/store/mod.js.map +2 -2
- package/dist/hub/store/namespaces.d.ts.map +1 -1
- package/dist/mod.d.ts +1 -0
- package/dist/mod.d.ts.map +1 -1
- package/dist/mod.js +1 -1
- package/dist/mod.js.map +2 -2
- package/dist/namespaces/common/mod.js +1 -1
- package/dist/namespaces/common/mod.js.map +1 -1
- package/dist/namespaces/evm/actions.d.ts.map +1 -1
- package/dist/namespaces/evm/builders.d.ts.map +1 -1
- package/dist/namespaces/evm/eip1193.d.ts +1 -0
- package/dist/namespaces/evm/eip1193.d.ts.map +1 -1
- package/dist/namespaces/evm/mod.js +1 -1
- package/dist/namespaces/evm/mod.js.map +3 -3
- package/dist/namespaces/solana/mod.js +1 -1
- package/dist/namespaces/solana/mod.js.map +3 -3
- package/dist/namespaces/solana/utils.d.ts.map +1 -1
- package/dist/namespaces/sui/mod.js.map +1 -1
- package/dist/namespaces/utxo/mod.js +1 -1
- package/dist/namespaces/utxo/mod.js.map +1 -1
- package/dist/types/mod.d.ts +1 -1
- package/dist/types/mod.d.ts.map +1 -1
- package/dist/wallets-core.build.json +1 -1
- package/package.json +1 -1
- package/src/hub/store/namespaces.ts +2 -1
- package/src/mod.ts +1 -0
- package/src/namespaces/evm/actions.ts +14 -4
- package/src/namespaces/evm/builders.ts +2 -12
- package/src/namespaces/evm/eip1193.ts +2 -1
- package/src/namespaces/solana/utils.ts +7 -1
- package/src/types/mod.ts +1 -1
package/dist/mod.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/hub/helpers.ts", "../src/hub/namespaces/errors.ts", "../src/hub/namespaces/namespace.ts", "../src/hub/provider/provider.ts", "../src/hub/hub.ts", "../src/hub/store/selectors.ts", "../src/hub/store/store.ts", "../src/hub/store/extend.ts", "../src/hub/store/hub.ts", "../src/hub/store/namespaces.ts", "../src/hub/store/events.ts", "../src/hub/store/providers.ts", "../src/builders/namespace.ts", "../src/builders/provider.ts", "../src/builders/action.ts", "../src/utils/mod.ts", "../src/utils/versions.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Note: This only works native async, if we are going to support for old transpilers like Babel.\n */\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function isAsync(fn: Function) {\n return fn.constructor.name === 'AsyncFunction';\n}\n\nexport function generateStoreId(providerId: string, namespace: string) {\n return `${providerId}$$${namespace}`;\n}\n", "export const ACTION_NOT_FOUND_ERROR = (name: string) =>\n `Couldn't find \"${name}\" action. Are you sure you've added the action?`;\n\nexport const OR_ELSE_ACTION_FAILED_ERROR = (name: string) =>\n `An error occurred during running ${name}`;\n\nexport const BEFORE_ACTION_FAILED_ERROR = (name: string) =>\n `An error occurred during running before for \"${name}\" action`;\n\nexport const NO_STORE_FOUND_ERROR =\n 'For setup store, you should set `store` first.';\n", "import type {\n Actions,\n Context,\n GetState,\n HooksWithOptions,\n Operators,\n RegisteredActions,\n SetState,\n State,\n} from './types.js';\nimport type {\n AndFunction,\n AnyFunction,\n FunctionWithContext,\n} from '../../types/actions.js';\nimport type { NamespaceConfig, Store } from '../store/mod.js';\n\nimport { generateStoreId, isAsync } from '../helpers.js';\n\nimport {\n ACTION_NOT_FOUND_ERROR,\n BEFORE_ACTION_FAILED_ERROR,\n NO_STORE_FOUND_ERROR,\n OR_ELSE_ACTION_FAILED_ERROR,\n} from './errors.js';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Params = any[];\n\n/**\n *\n * A Namespace is a unit of wallets where usually handles connecting, signing, accounts, ...\n * It will be injected by wallet in its object, for example, `window.phantom.ethereum` or `window.phantom.solana`\n * Each namespace (like solana) has its own functionality which is not shared between all the blockchains.\n * For example in EVM namespaces, you can have different networks (e.g. Ethereum,Polygon, ...) and there are specific flows to handle connecting to them or add a network and etc.\n * But Solana doesn't have this concept and you will directly always connect to solana itself.\n * This is true for signing a transaction, getting information about blockchain and more.\n * So by creating a namespace for each of these, we can define a custom namespace based on blockchain's properties.\n *\n */\nclass Namespace<T extends Actions<T>> {\n /** it will be used for `store` and accessing to store by its id mainly. */\n public readonly namespaceId: string;\n /** it will be used for `store` and accessing to store by its id mainly. */\n public readonly providerId: string;\n\n #actions: RegisteredActions<T>;\n #andOperators: Operators<T> = new Map();\n #orOperators: Operators<T> = new Map();\n // `context` for these two can be Namespace context or Provider context\n #beforeHooks: HooksWithOptions<T> = new Map();\n #afterHooks: HooksWithOptions<T> = new Map();\n\n #initiated = false;\n #store: Store | undefined;\n // Namespace doesn't has any configs now, but we will need the feature in future\n // eslint-disable-next-line no-unused-private-class-members\n #configs: NamespaceConfig;\n\n constructor(\n id: string,\n providerId: string,\n options: {\n store?: Store;\n configs?: NamespaceConfig;\n actions: RegisteredActions<T>;\n }\n ) {\n const { configs, actions } = options;\n\n this.namespaceId = id;\n this.providerId = providerId;\n\n this.#configs = configs || new Map();\n this.#actions = actions;\n\n if (options.store) {\n this.store(options.store);\n }\n }\n\n /**\n * This is an special action that will be called **only once**.\n * We don't call this in `constructor` and developer should call this manually. we only ensure it will be called once.\n *\n * ```ts\n * const myInit = () => { whatever; }\n * const actions = new Map();\n * actions.set(\"init\", myInit)\n * const ns = new Namespace(..., {actions});\n *\n * // Will run `myInit`\n * ns.init()\n *\n * // Will not run `myInit` anymore.\n * ns.init()\n * ns.init()\n * ```\n */\n public init(): void {\n if (this.#initiated) {\n return;\n }\n\n const definedInitByUser = this.#actions.get('init');\n\n if (definedInitByUser) {\n definedInitByUser(this.#context());\n }\n // else, this namespace doesn't have any `init` implemented.\n\n this.#initiated = true;\n }\n\n /**\n * Reading states from store and also update them.\n *\n * @example\n * ```ts\n * const ns = new Namespace(...);\n * const [getState, setState] = ns.state();\n * ```\n */\n public state(): [GetState, SetState] {\n const store = this.#store;\n if (!store) {\n throw new Error(\n 'You need to set your store using `.store` method first.'\n );\n }\n\n const id = this.#storeId();\n const setState: SetState = (name, value) => {\n store.getState().namespaces.updateStatus(id, name, value);\n };\n\n const getState: GetState = <K extends keyof State>(name?: K) => {\n const state: State = store.getState().namespaces.getNamespaceData(id);\n\n if (!name) {\n return state;\n }\n\n return state[name];\n };\n\n return [getState, setState];\n }\n\n /**\n * For keeping state, we need a store. all the states will be write to/read from store.\n *\n * Note: Store can be setup on constructor as well.\n *\n * @example\n * ```ts\n * const myStore = createStore();\n * const ns = new Namespace(...);\n * ns.store(myStore);\n * ```\n */\n public store(store: Store): this {\n if (this.#store) {\n console.warn(\n \"You've already set an store for your Namespace. Old store will be replaced by the new one.\"\n );\n }\n this.#store = store;\n this.#setupStore();\n\n return this;\n }\n\n /**\n * It's a boolean operator to run a sync function if action ran successfully.\n * For example, if we have a `connect` action, we can add function to be run after `connect` if it ran successfully.\n *\n * @example\n * ```ts\n * const ns = new Namespace(..);\n *\n * ns.and_then('connect', (context) => {\n * ...\n * });\n * ```\n *\n */\n public and_then<K extends keyof T>(\n actionName: K,\n operatorFn: FunctionWithContext<AndFunction<T, K>, Context>\n ): this {\n const currentAndOperators = this.#andOperators.get(actionName) || [];\n this.#andOperators.set(actionName, currentAndOperators.concat(operatorFn));\n\n return this;\n }\n\n /**\n * It's a boolean operator to run a function to handle when an action fails.\n * For example, if we have a `connect` action, we can add function to be run when `connect` fails (throw an error).\n *\n * @example\n * ```ts\n * const ns = new Namespace(..);\n *\n * ns.or_else('connect', (context, error) => {\n * ...\n * });\n * ```\n */\n public or_else<K extends keyof T>(\n actionName: K,\n operatorFn: FunctionWithContext<AnyFunction, Context>\n ): this {\n const currentOrOperators = this.#orOperators.get(actionName) || [];\n this.#orOperators.set(actionName, currentOrOperators.concat(operatorFn));\n\n return this;\n }\n\n /**\n * Running a function after a specific action\n *\n * Note: the context can be set from outside as well. this is useful for Provider to set its context instead of namespace context.\n *\n * @example\n * ```ts\n * const ns = new Namespace(...);\n *\n * ns.after(\"connect\", (context) => {});\n * ```\n */\n public after<K extends keyof T, C = unknown>(\n actionName: K,\n hook: FunctionWithContext<AnyFunction, C>,\n options?: { context?: C }\n ): this {\n const currentAfterHooks = this.#afterHooks.get(actionName) || [];\n const hookWithOptions = {\n hook,\n options: {\n context: options?.context,\n },\n };\n\n this.#afterHooks.set(actionName, currentAfterHooks.concat(hookWithOptions));\n return this;\n }\n\n /**\n * Running a function before a specific action\n *\n * Note: the context can be set from outside as well. this is useful for Provider to set its context instead of using namespace context.\n *\n * @example\n * ```ts\n * const ns = new Namespace(...);\n *\n * ns.before(\"connect\", (context) => {});\n * ```\n */\n public before<K extends keyof T, C = unknown>(\n actionName: K,\n hook: FunctionWithContext<AnyFunction, C>,\n options?: { context?: C }\n ): this {\n const currentBeforeHooks = this.#beforeHooks.get(actionName) || [];\n const hookWithOptions = {\n hook,\n options: {\n context: options?.context,\n },\n };\n this.#beforeHooks.set(\n actionName,\n currentBeforeHooks.concat(hookWithOptions)\n );\n\n return this;\n }\n public has<K extends keyof T>(actionName: K): boolean {\n return !!this.#actions.get(actionName);\n }\n /**\n *\n * Registered actions will be called using `run`. it will run an action and all the operators or hooks that assigned.\n *\n * @example\n * ```ts\n * const actions = new Map();\n * actions.set('connect', connectAction);\n *\n * const ns = new Namespace(NAMESPACE, PROVIDER_ID, {\n * actions: actions,\n * });\n *\n * ns.run(\"action\");\n * ```\n */\n public run<K extends keyof T>(\n actionName: K,\n ...args: Params\n ): unknown | Promise<unknown> {\n const action = this.#actions.get(actionName);\n if (!action) {\n throw new Error(ACTION_NOT_FOUND_ERROR(actionName.toString()));\n }\n\n /*\n * Action can be both, sync or async. To simplify the process we can not make `sync` mode to async\n * Since every user's sync action will be an async function and affect what user expect,\n * it makes all the actions async and it doesn't match with Namespace interface (e.g. EvmActions)\n *\n * To avoid this issue and also not duplicating code, I broke the process into smaller methods\n * and two main methods to run actions: tryRunAsyncAction & tryRunAction.\n */\n const result = isAsync(action)\n ? this.#tryRunAsyncAction(actionName, args)\n : this.#tryRunAction(actionName, args);\n\n return result;\n }\n\n #tryRunAction<K extends keyof T>(actionName: K, params: Params): unknown {\n try {\n this.#tryRunBeforeHooks(actionName);\n } catch (error) {\n this.#tryRunAfterHooks(actionName);\n throw new Error(BEFORE_ACTION_FAILED_ERROR(actionName.toString()), {\n cause: error,\n });\n }\n\n const action = this.#actions.get(actionName);\n if (!action) {\n throw new Error(ACTION_NOT_FOUND_ERROR(actionName.toString()));\n }\n\n const context = this.#context();\n\n let result;\n try {\n result = action(context, ...params);\n result = this.#tryRunAndOperators(actionName, result);\n } catch (e) {\n result = this.#tryRunOrOperators(actionName, e);\n } finally {\n this.#tryRunAfterHooks(actionName);\n }\n\n return result;\n }\n\n async #tryRunAsyncAction<K extends keyof T>(\n actionName: K,\n params: Params\n ): Promise<unknown> {\n try {\n this.#tryRunBeforeHooks(actionName);\n } catch (error) {\n this.#tryRunAfterHooks(actionName);\n throw new Error(BEFORE_ACTION_FAILED_ERROR(actionName.toString()), {\n cause: error,\n });\n }\n\n const action = this.#actions.get(actionName);\n if (!action) {\n throw new Error(ACTION_NOT_FOUND_ERROR(actionName.toString()));\n }\n\n const context = this.#context();\n return await action(context, ...params)\n .then((result: unknown) => this.#tryRunAndOperators(actionName, result))\n .catch((e: unknown) => this.#tryRunOrOperators(actionName, e))\n .finally(() => this.#tryRunAfterHooks(actionName));\n }\n\n #tryRunAfterHooks<K extends keyof T>(actionName: K) {\n const afterActions = this.#afterHooks.get(actionName);\n\n if (afterActions) {\n afterActions.forEach((afterAction) => {\n const context = afterAction.options?.context || this.#context();\n afterAction.hook(context);\n });\n }\n }\n\n #tryRunBeforeHooks<K extends keyof T>(actionName: K): void {\n const beforeActions = this.#beforeHooks.get(actionName);\n if (beforeActions) {\n beforeActions.forEach((beforeAction) => {\n const context = beforeAction.options?.context || this.#context();\n beforeAction.hook(context);\n });\n }\n }\n\n #tryRunAndOperators<K extends keyof T>(\n actionName: K,\n result: unknown\n ): unknown {\n const andActions = this.#andOperators.get(actionName);\n\n if (andActions) {\n const context = this.#context();\n result = andActions.reduce((prev, andAction) => {\n return andAction(context, prev);\n }, result);\n }\n return result;\n }\n\n #tryRunOrOperators<K extends keyof T>(\n actionName: K,\n actionError: unknown\n ): unknown {\n const orActions = this.#orOperators.get(actionName);\n\n if (orActions) {\n try {\n const context = this.#context();\n return orActions.reduce((prev, orAction) => {\n return orAction(context, prev);\n }, actionError);\n } catch (orActionError) {\n if (orActionError instanceof Error) {\n orActionError.cause = actionError;\n throw orActionError;\n }\n const errorMessage = OR_ELSE_ACTION_FAILED_ERROR(\n `${actionName.toString()} for ${this.namespaceId} namespace.`\n );\n const standardOrActionError = new Error(String(orActionError), {\n cause: actionError,\n });\n throw new Error(errorMessage, { cause: standardOrActionError });\n }\n } else {\n throw actionError;\n }\n }\n\n #setupStore(): void {\n const store = this.#store;\n if (!store) {\n throw new Error(NO_STORE_FOUND_ERROR);\n }\n\n const id = this.#storeId();\n store.getState().namespaces.addNamespace(id, {\n namespaceId: this.namespaceId,\n providerId: this.providerId,\n });\n }\n\n #storeId() {\n return generateStoreId(this.providerId, this.namespaceId);\n }\n\n #context(): Context<T> {\n return {\n state: this.state.bind(this),\n action: this.run.bind(this),\n };\n }\n}\n\nexport { Namespace };\n", "import type {\n CommonNamespaces,\n Context,\n ExtendableInternalActions,\n GetState,\n RegisteredNamespaces,\n SetState,\n State,\n} from './types.js';\nimport type { FindProxiedNamespace } from '../../builders/mod.js';\nimport type { AnyFunction, FunctionWithContext } from '../../types/actions.js';\nimport type { ProviderConfig, ProviderInfo, Store } from '../store/mod.js';\n\nconst VERSION = '1.0';\n\nexport class Provider {\n public readonly id: string;\n public readonly version = VERSION;\n\n #namespaces: RegisteredNamespaces<keyof CommonNamespaces, CommonNamespaces>;\n #initiated = false;\n #extendInternalActions: ExtendableInternalActions = {};\n #store: Store | undefined;\n #configs: ProviderConfig;\n\n constructor(\n id: string,\n namespaces: RegisteredNamespaces<keyof CommonNamespaces, CommonNamespaces>,\n configs: ProviderConfig,\n options?: {\n /**\n * There are some cases we need to have a behavior like initializing a provider which will be run when we are creating an instance.\n * These internal steps and behaviors will be useful for library user to extend the behavior by running a specific code.\n */\n extendInternalActions?: ExtendableInternalActions;\n store?: Store;\n }\n ) {\n this.id = id;\n this.#configs = configs;\n // it should be only created here, to make sure `after/before` will work properly.\n this.#extendInternalActions = options?.extendInternalActions || {};\n this.#namespaces = namespaces;\n\n /**\n * Our assumption is that the store will be optional for the provider.\n * If a store is provided in the options, it will be initialized and set up.\n */\n if (options?.store) {\n this.#store = options.store;\n this.#setupStore();\n }\n }\n\n /**\n * This is an special callback that will be called **only once**.\n * We don't call this in `constructor` and developer should call this manually. we only ensure it will be called once.\n *\n * ```ts\n * const myInit = () => { whatever; } *\n * const provider = new Provider(..., {extendInternalActions: {init: myInit} });\n *\n * // Will run `myInit`\n * provider.init()\n *\n * // Will not run `myInit` anymore.\n * provider.init()\n * provider.init()\n * ```\n */\n public init(): void {\n if (this.#initiated) {\n return;\n }\n\n const definedInitByUser = this.#extendInternalActions.init;\n if (definedInitByUser) {\n definedInitByUser(this.#context());\n }\n\n this.#initiated = true;\n }\n\n /**\n * Getting state of a provider\n *\n * **Note:**\n * Each namespace has it's own state as well, in Legacy we didn't have this separation and all of them was accessible through Provider itself\n * To be compatible with legacy, `getState` has a logic to guess the final state to produce same state as legacy.\n *\n * @example\n * ```ts\n * const provider = new Provider(...);\n * const [getState, setState] = provider.state();\n *\n * getState('installed');\n * // or\n * getState().installed;\n * ```\n *\n */\n public state(): [GetState, SetState] {\n const store = this.#store;\n if (!store) {\n throw new Error(\n `Any store detected for ${this.id}. You need to set your store using '.store' method first.`\n );\n }\n\n /**\n * State updater\n */\n const setState: SetState = (name, value) => {\n switch (name) {\n case 'installed':\n return store.getState().providers.updateStatus(this.id, name, value);\n default:\n throw new Error(\n `Unhandled state update for provider. (provider id: ${this.id}, state name: ${name})`\n );\n }\n };\n\n /**\n * State getter\n */\n const getState: GetState = <K extends keyof State>(name?: K) => {\n const state: State = store\n .getState()\n .providers.guessNamespacesState(this.id);\n\n if (!name) {\n return state;\n }\n\n switch (name) {\n case 'installed':\n case 'connected':\n case 'connecting':\n return state[name];\n default:\n throw new Error('Unhandled state for provider');\n }\n };\n\n return [getState, setState];\n }\n\n /**\n * For keeping state, we need a store. all the states will be write to/read from store.\n *\n * **Note: When you are setting an store for provider, it will be set for its namespaces automatically as well**\n *\n * @example\n * ```ts\n * const myStore = createStore();\n * const provider = new Provider(...);\n * provider.store(myStore); // or it can be passed to Provider constructor;\n * ```\n */\n public store(store: Store): this {\n if (this.#store) {\n console.warn(\n \"You've already set an store for your Provider. Old store will be replaced by the new one.\"\n );\n }\n this.#store = store;\n this.#setupStore();\n return this;\n }\n\n /**\n * Getting information about a provider which has been set on constructing Provider.\n *\n * @example\n * ```ts\n * const walletInfo = {name: \"Garbage wallet\", ...}\n * const provider = new Provider(..., {info: walletInfo});\n *\n * provider.info();\n * ```\n */\n public info(): ProviderInfo | undefined {\n const store = this.#store;\n if (!store) {\n return this.#configs;\n }\n const config = store.getState().providers.list[this.id].config;\n\n return { metadata: config.metadata, deepLink: config.deepLink };\n }\n\n /**\n * A list of registered _proxied_ namespaces.\n *\n * @example\n * ```ts\n * const provider = new Provider(...);\n * const allNamespaces = provider.getAll();\n * ```\n */\n public getAll(): RegisteredNamespaces<\n keyof CommonNamespaces,\n CommonNamespaces\n > {\n return this.#namespaces;\n }\n\n /**\n * Get a registered namespace in provider by its **namespace key**.\n *\n * Note: difference between namespace key and namespace id is the first one is setting from a predefined list the second one can be anything and will be chosen by library's user.\n *\n * @param {string} id - evm, solana, cosmos, ... (CommonActions)\n */\n public get<K extends keyof CommonNamespaces>(\n id: K\n ): FindProxiedNamespace<K, CommonNamespaces> | undefined {\n return this.#namespaces.get(id) as unknown as\n | FindProxiedNamespace<K, CommonNamespaces>\n | undefined;\n }\n\n /**\n *\n * Get a registered namespace by its **namespaceId**.\n *\n * Note: difference between namespace key and namespace id is the first one is setting from a predefined list the second one can be anything and will be chosen by library's user.\n *\n * @example\n * ```ts\n * const provider = new Provider(...);\n * provider.findByNamespace(\"whatever-id-i-set-for-namespace\")\n * ```\n */\n public findByNamespace<K extends keyof CommonNamespaces>(\n namespaceLookingFor: K | string\n ): FindProxiedNamespace<K, CommonNamespaces> | undefined {\n // If we didn't found any match, we will return `undefined`.\n let result: object | undefined = undefined;\n\n this.#namespaces.forEach((namespace) => {\n if (namespace.namespaceId === namespaceLookingFor) {\n result = namespace;\n }\n });\n\n return result;\n }\n\n /**\n * Running a hook function _after_ a specific action for **all registered namespaces**.\n *\n * **Note:** the context can be set from outside as well. this is useful for Provider to set its context instead of namespace context.\n *\n * @example\n * ```ts\n * const provider = new Provider(...);\n *\n * provider.after(\"connect\", (context) => {});\n * ```\n */\n public before(\n actionName: string,\n hookFn: FunctionWithContext<AnyFunction, Context>\n ): this {\n this.#addHook('before', actionName, hookFn);\n return this;\n }\n\n /**\n * Running a hook function _before_ a specific action for **all registered namespaces**.\n *\n * **Note:** the context can be set from outside as well. this is useful for Provider to set its context instead of namespace context.\n *\n * @example\n * ```ts\n * const provider = new Provider(...);\n *\n * provider.after(\"connect\", (context) => {});\n * ```\n */\n public after(\n actionName: string,\n hookFn: FunctionWithContext<AnyFunction, Context>\n ): this {\n this.#addHook('after', actionName, hookFn);\n return this;\n }\n\n #addHook(\n hookName: 'after' | 'before',\n actionName: string,\n cb: FunctionWithContext<AnyFunction, Context>\n ): this {\n const context = {\n state: this.state.bind(this),\n };\n\n this.#namespaces.forEach((namespace) => {\n if (hookName === 'after') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n namespace.after(actionName as any, cb, {\n context,\n });\n } else if (hookName === 'before') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n namespace.before(actionName as any, cb, {\n context,\n });\n } else {\n throw new Error(`You hook name is invalid: ${hookName}`);\n }\n });\n\n return this;\n }\n\n #setupStore(): void {\n const store = this.#store;\n if (!store) {\n throw new Error('For setup store, you should set `store` first.');\n }\n store.getState().providers.addProvider(this.id, this.#configs);\n this.#namespaces.forEach((provider) => {\n provider.store(store);\n });\n }\n\n #context(): Context {\n return {\n state: this.state.bind(this),\n };\n }\n}\n", "import type { Namespace, State as NamespaceState } from './namespaces/mod.js';\nimport type { Provider, State as ProviderState } from './provider/mod.js';\nimport type { Store } from './store/mod.js';\n\ntype HubState = {\n [key in string]: ProviderState & {\n namespaces: NamespaceState[];\n };\n};\n\ntype RunAllResult = {\n id: string;\n provider: unknown;\n namespaces: unknown[];\n};\n\ninterface HubOptions {\n store?: Store;\n}\nexport class Hub {\n #providers = new Map<string, Provider>();\n #options: HubOptions;\n\n constructor(options?: HubOptions) {\n this.#options = options ?? {};\n }\n\n init() {\n this.runAll('init');\n }\n\n /*\n * Running a specific action (e.g. init) on all namespaces and providers one by one.\n *\n * TODO: Some of methods may accepts args, with this implementation we only limit to those one without any argument.\n */\n runAll(action: string): RunAllResult[] {\n const output: RunAllResult[] = [];\n\n // run action on all providers eagerConnect, disconnect\n const providers = this.#providers.values();\n\n for (const provider of providers) {\n // Calling `action` on `Provider` if exists.\n const providerOutput: RunAllResult = {\n id: provider.id,\n provider: undefined,\n namespaces: [],\n };\n\n const providerMethod = provider[action as keyof Provider];\n if (typeof providerMethod === 'function') {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore-next-line\n providerOutput.provider = providerMethod.call(provider);\n }\n\n // Namespace instances can have their own `action` as well. we will call them as well.\n const namespaces = provider.getAll().values();\n for (const namespace of namespaces) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore-next-line\n const namespaceMethod = namespace[action];\n if (typeof namespaceMethod === 'function') {\n const result = namespaceMethod();\n providerOutput.namespaces.push(result);\n }\n }\n\n output.push(providerOutput);\n }\n\n return output;\n }\n\n add(id: string, provider: Provider) {\n if (this.#options.store) {\n provider.store(this.#options.store);\n }\n this.#providers.set(id, provider);\n return this;\n }\n remove(id: string) {\n const providerToRemove = this.#providers.get(id);\n\n if (!providerToRemove) {\n throw new Error(`Provider not found: No provider exists with ID \"${id}\"`);\n }\n\n this.#options.store?.getState().providers.removeProvider(id);\n this.#providers.delete(id);\n\n return this;\n }\n\n get(providerId: string): Provider | undefined {\n return this.#providers.get(providerId);\n }\n\n getAll() {\n return this.#providers;\n }\n\n state(): HubState {\n const output = this.runAll('state');\n const res: HubState = {};\n\n output.forEach((result) => {\n const namespaces: NamespaceState[] = [];\n result.namespaces.forEach((b) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const [getNamespaceState] = b as ReturnType<Namespace<any>['state']>;\n\n namespaces.push(getNamespaceState());\n });\n\n const [getProviderState] = result.provider as ReturnType<\n Provider['state']\n >;\n\n res[result.id] = {\n ...(getProviderState() || {}),\n namespaces: namespaces,\n };\n });\n return res;\n }\n}\n", "/**\n * Note: Zustand has some difficulty when you are trying to `previous` state on `subscribe`.\n * If these selectors define inside store directly and use `get()` for accessing state, it will get the latest state\n * instead of previous state which desired.\n * So make them a helper will let us to reuse them both in store and outside of store in a `subscribe`.\n */\nimport type { State } from '../mod.js';\nimport type { State as InternalProviderState } from '../provider/mod.js';\n\n/**\n * Legacy provider state includes `connecting` and `connected` values. It hadn't a separation layer for `namespaces`.\n * For compatibility reasons, we should produce these two values somehow.\n *\n * Currently, We return `true` if any of namespaces return true. We are missing failed namespace here.\n * But if we want to solve that, we should migrate our client code to use `namespace` state directly and not from `provider`\n */\nexport function guessProviderStateSelector(\n state: State,\n providerId: string\n): InternalProviderState {\n /*\n * We keep namespaces in a separate branch than providers.\n * We should look at all of them and find all the namespaces that for our current proivder.\n */\n const allNamespaces = state.namespaces.list;\n const currentProviderNamespaces = Object.keys(allNamespaces).filter(\n (key) => allNamespaces[key].info.providerId === providerId\n );\n\n // Returning provider state value directly.\n const installed = !!state.providers.list[providerId]?.data.installed;\n\n /*\n * If any namespaces returns `true`, we consider the whole provider for this field to be `true`.\n * it has a downside regarding errors which explained on top of the function.\n */\n const connected =\n currentProviderNamespaces.length > 0\n ? currentProviderNamespaces.some(\n (key) => allNamespaces[key].data.connected\n )\n : false;\n const connecting =\n currentProviderNamespaces.length > 0\n ? currentProviderNamespaces.some(\n (key) => allNamespaces[key].data.connecting\n )\n : false;\n\n return {\n installed,\n connected,\n connecting,\n };\n}\n\nexport function namespaceStateSelector(state: State, storeId: string) {\n return state.namespaces.list[storeId].data;\n}\n", "import type { StoreApi } from 'zustand/vanilla';\n\nimport { createStore as createZustandStore } from 'zustand/vanilla';\n\nimport { extend, type Store } from './extend.js';\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 RawStore = StoreApi<State>;\n\nexport const createStore = (): Store => {\n const store = createZustandStore<State>((...api) => {\n return {\n hub: hubStore(...api),\n providers: providersStore(...api),\n namespaces: namespacesStore(...api),\n };\n });\n\n return extend(store);\n};\n", "import type {\n Event,\n ProviderConnectedEvent,\n ProviderConnectingEvent,\n ProviderDisconnectedEvent,\n} from './events.js';\nimport type { RawStore, State } from './store.js';\n\nimport { guessProviderStateSelector } from './selectors.js';\n\nexport interface Store extends Omit<RawStore, 'subscribe'> {\n subscribe(listener: (event: Event, state: State, prevState: State) => void): {\n flushEvents(): void;\n };\n}\n\n/**\n * Zustand's store provides a set of built-in functionalities,\n * but it may not meet all our requirements.\n * This function modifies the interface and adds or updates the available methods.\n */\nexport function extend(store: RawStore): Store {\n const extendedSubscribe: (store: RawStore) => Store['subscribe'] =\n (store) => (listener) => {\n const executeListener = (\n events: Event[],\n state: State,\n prevState: State\n ) => {\n for (const ev of events) {\n listener(ev, state, prevState);\n }\n };\n\n /*\n * only known changes will fire event for lib users\n * so all the changes in store won't trigger a user-face event\n */\n store.subscribe((state, prevState) => {\n const eventsLike = getEventsLike(state, prevState);\n const events = tryConsumeEvents(state);\n const allQueuedEvents = [...events, ...eventsLike];\n executeListener(allQueuedEvents, state, prevState);\n });\n\n return {\n /**\n * Manually run pending events.\n * This useful when use `subscribe` method after sometime and when store initialized.\n *\n * Note: Please consider both current and previous state will be same and we don't have access to previous state in a such scenario.\n */\n flushEvents: () => {\n const state = store.getState();\n const events = tryConsumeEvents(state);\n executeListener(events, state, state);\n },\n };\n };\n\n return new Proxy(store, {\n get: function (target, prop, receiver) {\n if (prop === 'subscribe') {\n return extendedSubscribe(target);\n }\n return Reflect.get(target, prop, receiver);\n },\n }) as unknown as Store;\n}\n\n/**\n * Retrieves the ConsumableEvent from the store and returns its values.\n * The values will be consumed by iterating over the field.\n */\nfunction tryConsumeEvents(state: State): Event[] {\n return [...state.providers.events, ...state.namespaces.events];\n}\n\n/**\n * In certain cases, adding events to the store is not possible (e.g., namespace or provider layer).\n * In these cases, we observe store changes and treat specific patterns as events when detected.\n *\n * Note: This approach should be avoided in most cases. It is used here to maintain backward compatibility\n * with the provider's legacy interface.\n */\nfunction getEventsLike(state: State, prevState: State): Event[] {\n const events: Event[] = [];\n\n for (const providerId of Object.keys(state.providers.list)) {\n const currentProviderState = guessProviderStateSelector(state, providerId);\n const previousProviderState = guessProviderStateSelector(\n prevState,\n providerId\n );\n\n if (previousProviderState.connecting !== currentProviderState.connecting) {\n const ev: ProviderConnectingEvent = {\n type: 'provider_connecting',\n provider: providerId,\n value: currentProviderState.connecting,\n };\n events.push(ev);\n }\n\n if (!previousProviderState.connected && currentProviderState.connected) {\n const ev: ProviderConnectedEvent = {\n type: 'provider_connected',\n provider: providerId,\n };\n\n events.push(ev);\n }\n\n if (previousProviderState.connected && !currentProviderState.connected) {\n const ev: ProviderDisconnectedEvent = {\n type: 'provider_disconnected',\n provider: providerId,\n };\n\n events.push(ev);\n }\n }\n\n return events;\n}\n", "/************ Hub ************/\n\nimport type { State } from './mod.js';\nimport type { StateCreator } from 'zustand';\n\ntype HubConfig = object;\n\nexport interface HubStore {\n config: HubConfig;\n}\n\ntype HubStateCreator = StateCreator<State, [], [], HubStore>;\n\nconst hubStore: HubStateCreator = () => ({\n config: {},\n});\n\nexport { hubStore };\n", "/************ Namespace ************/\n\nimport type { StateCreator } from 'zustand';\n\nimport { produce } from 'immer';\n\nimport {\n ConsumableEvents,\n type NamespaceConnectedEvent,\n type NamespaceDisconnectedEvent,\n type NamespaceSwitchedAccountEvent,\n type NamespaceSwitchedNetworkEvent,\n} from './events.js';\nimport { namespaceStateSelector, type State } from './mod.js';\n\n// Currently, namespace doesn't has any config.\nexport type NamespaceConfig = object;\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\ninterface NamespaceItem {\n info: NamespaceInfo;\n data: NamespaceData;\n error: unknown;\n}\n\ntype NamespaceState = {\n events: InstanceType<typeof ConsumableEvents>;\n list: Record<string, NamespaceItem>;\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\n _produceEventsWhenUpdatingStatus: <K extends keyof NamespaceData>(\n namespace: NamespaceItem,\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 events: new ConsumableEvents(),\n\n list: {},\n addNamespace: (id, info) => {\n const data: NamespaceData = {\n accounts: null,\n network: null,\n connected: false,\n connecting: false,\n };\n\n const item = {\n data,\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 const ns = get().namespaces.list[id];\n if (!ns) {\n throw new Error(`No namespace with '${id}' found.`);\n }\n\n get().namespaces._produceEventsWhenUpdatingStatus(ns, id, key, value);\n\n // Updating state\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 _produceEventsWhenUpdatingStatus: (namespace, id, key, value) => {\n if (key === 'accounts') {\n // check for both null and empty array\n const isAccountsEmpty =\n Object.is(value, null) || (Array.isArray(value) && value.length === 0);\n\n if (isAccountsEmpty) {\n const currentConnectedStatus = get().namespaces.list[id].data.connected;\n if (currentConnectedStatus) {\n const event: NamespaceDisconnectedEvent = {\n type: 'namespace_disconnected',\n provider: namespace.info.providerId,\n namespace: namespace.info.namespaceId,\n };\n\n get().namespaces.events.push(event);\n }\n // Skip emitting disconnect event, if the `connected` is false\n } else {\n const currentAccounts = get().namespaces.list[id].data.accounts;\n\n if (!currentAccounts) {\n const event: NamespaceConnectedEvent = {\n type: 'namespace_connected',\n provider: namespace.info.providerId,\n namespace: namespace.info.namespaceId,\n accounts: value as string[],\n };\n\n get().namespaces.events.push(event);\n } else {\n const areSameAccounts =\n currentAccounts.sort().toString() ===\n (value as string[]).sort().toString();\n\n if (!areSameAccounts) {\n const event: NamespaceSwitchedAccountEvent = {\n type: 'namespace_account_switched',\n provider: namespace.info.providerId,\n namespace: namespace.info.namespaceId,\n previousAccounts: currentAccounts,\n accounts: value as string[],\n };\n\n get().namespaces.events.push(event);\n }\n }\n }\n } else if (key === 'network') {\n const currentNetwork = get().namespaces.list[id].data.network;\n\n const event: NamespaceSwitchedNetworkEvent = {\n type: 'namespace_network_switched',\n provider: namespace.info.providerId,\n namespace: namespace.info.namespaceId,\n network: value as string,\n previousNetwork: currentNetwork,\n };\n\n get().namespaces.events.push(event);\n }\n },\n});\n\nexport { namespacesStore };\n", "export type NamespaceDisconnectedEvent = {\n type: 'namespace_disconnected';\n provider: string;\n namespace: string;\n};\n\nexport type NamespaceConnectedEvent = {\n type: 'namespace_connected';\n provider: string;\n namespace: string;\n accounts: string[];\n};\n\nexport type NamespaceSwitchedAccountEvent = {\n type: 'namespace_account_switched';\n provider: string;\n namespace: string;\n accounts: string[];\n previousAccounts: string[];\n};\n\nexport type NamespaceSwitchedNetworkEvent = {\n type: 'namespace_network_switched';\n provider: string;\n namespace: string;\n network: string;\n previousNetwork: string | null;\n};\n\nexport type ProviderDetectedEvent = {\n type: 'provider_detected';\n provider: string;\n};\n\nexport type ProviderConnectingEvent = {\n type: 'provider_connecting';\n provider: string;\n value: boolean;\n};\n\nexport type ProviderConnectedEvent = {\n type: 'provider_connected';\n provider: string;\n};\n\nexport type ProviderDisconnectedEvent = {\n type: 'provider_disconnected';\n provider: string;\n};\n\nexport type Event =\n | NamespaceDisconnectedEvent\n | NamespaceConnectedEvent\n | NamespaceSwitchedAccountEvent\n | NamespaceSwitchedNetworkEvent\n | ProviderDetectedEvent\n | ProviderConnectingEvent\n | ProviderConnectedEvent\n | ProviderDisconnectedEvent;\n\n/**\n *\n * Keeping an array of Event and when iterates over its values, it will be removed (consume) from the array.\n *\n */\nexport class ConsumableEvents {\n #data: Event[] = [];\n\n push(val: Event) {\n this.#data.push(val);\n }\n\n [Symbol.iterator](): Iterator<Event> {\n return {\n next: (): IteratorResult<Event> => {\n if (this.#data.length == 0) {\n return { done: true, value: undefined };\n }\n\n // Typescript can not narrow the type, but we have a runtime check to ensure it will never be an empty list\n const value = this.#data.shift()!;\n return {\n done: false,\n value,\n };\n },\n };\n }\n}\n", "import type { Namespace } from '../../namespaces/common/types.js';\nimport type {\n GenerateDeepLink,\n State as InternalProviderState,\n} from '../provider/mod.js';\nimport type { BlockchainMeta, SignerFactory } from 'rango-types';\nimport type { StateCreator } from 'zustand';\n\nimport { produce } from 'immer';\n\nimport { ConsumableEvents, type ProviderDetectedEvent } from './events.js';\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 };\n\ntype NamespacesProperty = Property<\n 'namespaces',\n {\n selection: 'single' | 'multiple';\n data: {\n label: string;\n id: string;\n value: Namespace;\n unsupported?: boolean;\n getSupportedChains: (chains: BlockchainMeta[]) => BlockchainMeta[];\n }[];\n }\n>;\ntype DerivationPathProperty = Property<\n 'derivationPath',\n {\n data: {\n id: string;\n label: string;\n namespace: Namespace;\n generateDerivationPath: (index: string) => string;\n }[];\n }\n>;\ntype DetailsProperty = Property<\n 'details',\n {\n mobileWallet?: boolean;\n showOnMobile?: boolean;\n isContractWallet?: boolean;\n }\n>;\ntype SignersProperty = Property<\n 'signers',\n {\n getSigners: () => Promise<SignerFactory>;\n }\n>;\n\nexport type ProviderMetadata = {\n name: string;\n icon: string;\n extensions: Partial<Record<Browsers, string>>;\n properties?: Array<\n | NamespacesProperty\n | DerivationPathProperty\n | DetailsProperty\n | SignersProperty\n >;\n};\n\nexport interface ProviderConfig {\n metadata: ProviderMetadata;\n deepLink?: GenerateDeepLink;\n}\n\nexport type ProviderInfo = ProviderConfig;\n\ninterface ProviderData {\n installed: boolean;\n}\n\ninterface ProviderItem {\n config: ProviderConfig;\n data: ProviderData;\n error: unknown;\n}\n\ntype ProviderState = {\n events: ConsumableEvents;\n list: Record<string, ProviderItem>;\n};\ninterface ProviderActions {\n addProvider: (id: string, config: ProviderConfig) => void;\n removeProvider: (id: string) => void;\n updateStatus: <K extends keyof ProviderData>(\n id: string,\n key: K,\n value: ProviderData[K]\n ) => void;\n\n _produceEventsWhenUpdatingStatus: <K extends keyof ProviderData>(\n provider: ProviderItem,\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 events: new ConsumableEvents(),\n\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 removeProvider: (id) => {\n set(\n produce((state: State) => {\n delete state.providers.list[id];\n })\n );\n },\n updateStatus: (id, key, value) => {\n const provider = get().providers.list[id];\n if (!provider) {\n throw new Error(`No namespace namespace with '${id}' found.`);\n }\n\n get().providers._produceEventsWhenUpdatingStatus(provider, id, key, value);\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 _produceEventsWhenUpdatingStatus: (_provider, id, key, _value) => {\n if (key === 'installed') {\n const event: ProviderDetectedEvent = {\n type: 'provider_detected',\n provider: id,\n };\n\n get().providers.events.push(event);\n }\n },\n});\n\nexport { providersStore };\n", "import type { ActionByBuilder } from './action.js';\nimport type { ProxiedNamespace } from './types.js';\nimport type { Actions, ActionsMap, Context } from '../hub/namespaces/mod.js';\nimport type { NamespaceConfig } from '../hub/store/mod.js';\nimport type { FunctionWithContext } from '../types/actions.js';\n\nimport { Namespace } from '../hub/mod.js';\n\n/**\n * There are Namespace's methods that should be called directly on Proxy object.\n * The Proxy object is creating in `.build`.\n */\nexport const allowedMethods = [\n 'init',\n 'state',\n 'after',\n 'before',\n 'and_then',\n 'or_else',\n 'store',\n] as const;\n/**\n * List of value types that are considered safe to return directly when\n * accessing properties on a proxied `Namespace`.\n *\n * This is useful for allowing public values like `version` to be accessed.\n * If a property's value is of one of these types (e.g.,`'string'`, `'number'`),\n * it will be returned as-is.\n *\n * @const {Array<'string' | 'number'>} allowedPublicValues\n */\nconst allowedPublicValues = ['string', 'number'];\n\nexport class NamespaceBuilder<T extends Actions<T>> {\n #id: string;\n #providerId: string;\n #actions: ActionsMap<T> = new Map();\n /*\n * We keep a list of `ActionBuilder` outputs here to use them in separate phases.\n * Actually, `ActionBuilder` is packing action and its hooks in one place, here we should expand them and them in appropriate places.\n * Eventually, action will be added to `#actions` and its hooks will be added to `Namespace`.\n */\n #actionBuilders: ActionByBuilder<T, Context<T>>[] = [];\n #configs: NamespaceConfig;\n\n constructor(id: string, providerId: string) {\n this.#id = id;\n this.#providerId = providerId;\n this.#configs = {};\n }\n\n /** There are some predefined configs that can be set for each namespace separately */\n public config<K extends keyof NamespaceConfig>(\n name: K,\n value: NamespaceConfig[K]\n ) {\n this.#configs[name] = value;\n return this;\n }\n\n /**\n * Getting a list of actions.\n *\n * e.g.:\n * ```ts\n * .action([\n * [\"connect\", () => {}],\n * [\"disconnect\", () => {}]\n * ])\n * ```\n *\n */\n public action<K extends keyof T>(\n action: (readonly [K, FunctionWithContext<T[K], Context<T>>])[]\n ): NamespaceBuilder<T>;\n\n /**\n *\n * Add a single action\n *\n * e.g.:\n * ```ts\n * .action( [\"connect\", () => {}] )\n * ```\n */\n public action<K extends keyof T>(\n action: K,\n actionFn: FunctionWithContext<T[K], Context<T>>\n ): NamespaceBuilder<T>;\n\n public action(action: ActionByBuilder<T, Context<T>>): NamespaceBuilder<T>;\n\n /**\n *\n * Actions are piece of functionality that a namespace can have, for example it can be a `connect` function\n * or a sign function or even a function for updating namespace's internal state. Actions are flexible and can be anything.\n *\n * Generally, each standard namespace (e.g. evm) has an standard interface defined in `src/namespaces/`\n * and provider (which includes namespaces) authors will implement those actions.\n *\n * You can call this function by a list of actions or a single action.\n *\n */\n public action<K extends keyof T>(\n action: (readonly [K, FunctionWithContext<T[K], Context<T>>])[] | K,\n actionFn?: FunctionWithContext<T[K], Context<T>>\n ) {\n // List mode\n if (Array.isArray(action)) {\n action.forEach(([name, actionFnForItem]) => {\n this.#actions.set(name, actionFnForItem);\n });\n return this;\n }\n\n // Action builder mode\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (typeof action === 'object' && !!action?.actionName) {\n this.#actionBuilders.push(action);\n return this;\n }\n\n // Single action mode\n if (!!actionFn) {\n this.#actions.set(action, actionFn);\n }\n\n return this;\n }\n\n /**\n * By calling build, an instance of Namespace will be built.\n *\n * Note: it's not exactly a `Namespace`, it returns a Proxy which add more convenient use like `namespace.connect()` instead of `namespace.run(\"connect\")`\n */\n public build(): ProxiedNamespace<T> {\n if (this.#isConfigsValid(this.#configs)) {\n return this.#buildApi(this.#configs);\n }\n\n throw new Error(`You namespace config isn't valid.`);\n }\n\n // Currently, namespace doesn't has any config.\n #isConfigsValid(_config: NamespaceConfig): boolean {\n return true;\n }\n\n /*\n * Extracting hooks and add them to `Namespace` for the action.\n *\n * Note: this should be called after `addActionsFromActionBuilders` to ensure the action is added first.\n */\n #addHooksFromActionBuilders(namespace: Namespace<T>) {\n this.#actionBuilders.forEach((actionByBuild) => {\n actionByBuild.after.forEach((afterHooks) => {\n afterHooks.map((action) => {\n namespace.after(actionByBuild.actionName, action);\n });\n });\n\n actionByBuild.before.forEach((beforeHooks) => {\n beforeHooks.map((action) => {\n namespace.before(actionByBuild.actionName, action);\n });\n });\n\n actionByBuild.and.forEach((andHooks) => {\n andHooks.map((action) => {\n namespace.and_then(actionByBuild.actionName, action);\n });\n });\n\n actionByBuild.or.forEach((orHooks) => {\n orHooks.map((action) => {\n namespace.or_else(actionByBuild.actionName, action);\n });\n });\n });\n }\n\n /**\n * Iterate over `actionBuilders` and add them to exists `actions`.\n * Note: Hooks will be added in a separate phase.\n */\n #addActionsFromActionBuilders() {\n this.#actionBuilders.forEach((actionByBuild) => {\n this.#actions.set(actionByBuild.actionName, actionByBuild.action);\n });\n }\n\n /**\n * Build a Proxy object to call actions in a more convenient way. e.g `.connect()` instead of `.run(connect)`\n */\n #buildApi(configs: NamespaceConfig): ProxiedNamespace<T> {\n this.#addActionsFromActionBuilders();\n const namespace = new Namespace<T>(this.#id, this.#providerId, {\n configs,\n actions: this.#actions,\n });\n this.#addHooksFromActionBuilders(namespace);\n\n const api = new Proxy(namespace, {\n has: (_, property) => {\n if (typeof property !== 'string') {\n throw new Error(\n 'You can use string as your property on Namespace instance.'\n );\n }\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore-next-line\n if (allowedMethods.includes(property)) {\n return true;\n }\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore-next-line\n if (allowedPublicValues.includes(typeof namespace[property])) {\n return true;\n }\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore-next-line\n return namespace.has(property);\n },\n get: (_, property) => {\n if (typeof property !== 'string') {\n throw new Error(\n 'You can use string as your property on Namespace instance.'\n );\n }\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore-next-line\n const targetValue = namespace[property];\n\n if (\n allowedMethods.includes(property as (typeof allowedMethods)[number])\n ) {\n return targetValue.bind(namespace);\n }\n /*\n * This is useful accessing values like `version`, If we don't do this, we should whitelist\n * All the values as well, So it can be confusing for someone that only wants to add a public value to `Namespace`\n */\n if (allowedPublicValues.includes(typeof targetValue)) {\n return targetValue;\n }\n\n return namespace.run.bind(namespace, property as keyof T);\n },\n set: () => {\n throw new Error('You can not set anything on this object.');\n },\n });\n\n return api as unknown as ProxiedNamespace<T>;\n }\n}\n", "import type { FindProxiedNamespace } from './types.js';\nimport type {\n CommonNamespaces,\n ExtendableInternalActions,\n ProviderBuilderOptions,\n} from '../hub/provider/mod.js';\nimport type { ProviderConfig } from '../hub/store/mod.js';\n\nimport { Provider } from '../hub/provider/mod.js';\n\nexport class ProviderBuilder {\n #id: string;\n #namespaces = new Map();\n #methods: ExtendableInternalActions = {};\n #configs: Partial<ProviderConfig> = {};\n #options: Partial<ProviderBuilderOptions>;\n\n constructor(id: string, options?: ProviderBuilderOptions) {\n this.#id = id;\n this.#options = options || {};\n }\n\n public add<K extends keyof CommonNamespaces>(\n id: K,\n namespace: FindProxiedNamespace<K, CommonNamespaces>\n ) {\n if (this.#options.store) {\n namespace.store(this.#options.store);\n }\n this.#namespaces.set(id, namespace);\n return this;\n }\n\n public config<K extends keyof ProviderConfig>(\n name: K,\n value: ProviderConfig[K]\n ) {\n this.#configs[name] = value;\n return this;\n }\n\n public init(cb: Exclude<ExtendableInternalActions['init'], undefined>) {\n this.#methods.init = cb;\n return this;\n }\n\n public build(): Provider {\n if (this.#isConfigsValid(this.#configs)) {\n return new Provider(this.#id, this.#namespaces, this.#configs, {\n extendInternalActions: this.#methods,\n store: this.#options.store,\n });\n }\n\n throw new Error('You need to set all required configs.');\n }\n\n #isConfigsValid(config: Partial<ProviderConfig>): config is ProviderConfig {\n return !!config.metadata;\n }\n}\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 type { Provider } from '../hub/mod.js';\nimport type { LegacyProviderInterface } from '../legacy/mod.js';\n\ntype LegacyVersioned = ['0.0.0', LegacyProviderInterface];\ntype HubVersioned = ['1.0.0', Provider];\ntype AvailableVersionedProviders = LegacyVersioned | HubVersioned;\nexport type VersionedProviders = AvailableVersionedProviders[];\nexport type VersionInterface<T extends AvailableVersionedProviders[]> = T[1];\n\ntype SemVer<T extends [string, any]> = T extends [infer U, any] ? U : never;\ntype MatchVersion<T extends VersionedProviders, Version> = Extract<\n T[number],\n [Version, any]\n>;\n\nexport function pickVersion<\n L extends VersionedProviders,\n V extends SemVer<VersionedProviders[number]>\n>(list: L, targetVersion: V): MatchVersion<L, V> {\n if (!targetVersion) {\n throw new Error(`You should provide a valid semver, e.g 1.0.0.`);\n }\n\n const target = list.find(([version]) => version === targetVersion);\n\n if (!target) {\n throw new Error(\n `You target version hasn't been found. Available versions: ${Object.keys(\n list\n ).join(', ')}`\n );\n }\n return target as MatchVersion<L, V>;\n}\n\ninterface DefineVersionsApi {\n version: <T extends SemVer<VersionedProviders[number]>>(\n semver: T,\n value: VersionInterface<MatchVersion<VersionedProviders, T>>\n ) => DefineVersionsApi;\n build: () => VersionedProviders;\n}\n\nexport function defineVersions(): DefineVersionsApi {\n const versions: VersionedProviders = [];\n const api: DefineVersionsApi = {\n version: (semver, value) => {\n versions.push([semver, value]);\n return api;\n },\n build: () => {\n return versions;\n },\n };\n return api;\n}\n\nexport function legacyProviderImportsToVersionsInterface(\n provider: LegacyProviderInterface\n): VersionedProviders {\n return defineVersions().version('0.0.0', provider).build();\n}\n"],
|
|
5
|
-
"mappings": "+EAIO,SAASA,EAAQC,EAAc,CACpC,OAAOA,EAAG,YAAY,OAAS,eACjC,CAFgBC,EAAAF,EAAA,WAIT,SAASG,EAAgBC,EAAoBC,EAAmB,CACrE,MAAO,GAAGD,CAAU,KAAKC,CAAS,EACpC,CAFgBH,EAAAC,EAAA,mBCRT,IAAMG,EAAyBC,EAACC,GACrC,kBAAkBA,CAAI,kDADc,0BAGzBC,EAA8BF,EAACC,GAC1C,oCAAoCA,CAAI,GADC,+BAG9BE,EAA6BH,EAACC,GACzC,gDAAgDA,CAAI,WADZ,8BAG7BG,EACX,iDC8BF,IAAMC,EAAN,KAAsC,CAxCtC,MAwCsC,CAAAC,EAAA,kBAEpB,YAEA,WAEhBC,GACAC,GAA8B,IAAI,IAClCC,GAA6B,IAAI,IAEjCC,GAAoC,IAAI,IACxCC,GAAmC,IAAI,IAEvCC,GAAa,GACbC,GAGAC,GAEA,YACEC,EACAC,EACAC,EAKA,CACA,GAAM,CAAE,QAAAC,EAAS,QAAAC,CAAQ,EAAIF,EAE7B,KAAK,YAAcF,EACnB,KAAK,WAAaC,EAElB,KAAKF,GAAWI,GAAW,IAAI,IAC/B,KAAKX,GAAWY,EAEZF,EAAQ,OACV,KAAK,MAAMA,EAAQ,KAAK,CAE5B,CAoBO,MAAa,CAClB,GAAI,KAAKL,GACP,OAGF,IAAMQ,EAAoB,KAAKb,GAAS,IAAI,MA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C,CAACG,CAAO,IAAMA,IAAYF,CAAa,EAEjE,GAAI,CAACC,EACH,MAAM,IAAI,MACR,6DAA6D,OAAO,KAClEF,CACF,EAAE,KAAK,IAAI,CAAC,EACd,EAEF,OAAOE,CACT,CAlBgBE,EAAAL,EAAA,eA4BT,SAASM,GAAoC,CAClD,IAAMC,EAA+B,CAAC,EAChCC,EAAyB,CAC7B,QAAS,CAACC,EAAQC,KAChBH,EAAS,KAAK,CAACE,EAAQC,CAAK,CAAC,EACtBF,GAET,MAAO,IACED,CAEX,EACA,OAAOC,CACT,CAZgBH,EAAAC,EAAA",
|
|
4
|
+
"sourcesContent": ["/**\n * Note: This only works native async, if we are going to support for old transpilers like Babel.\n */\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function isAsync(fn: Function) {\n return fn.constructor.name === 'AsyncFunction';\n}\n\nexport function generateStoreId(providerId: string, namespace: string) {\n return `${providerId}$$${namespace}`;\n}\n", "export const ACTION_NOT_FOUND_ERROR = (name: string) =>\n `Couldn't find \"${name}\" action. Are you sure you've added the action?`;\n\nexport const OR_ELSE_ACTION_FAILED_ERROR = (name: string) =>\n `An error occurred during running ${name}`;\n\nexport const BEFORE_ACTION_FAILED_ERROR = (name: string) =>\n `An error occurred during running before for \"${name}\" action`;\n\nexport const NO_STORE_FOUND_ERROR =\n 'For setup store, you should set `store` first.';\n", "import type {\n Actions,\n Context,\n GetState,\n HooksWithOptions,\n Operators,\n RegisteredActions,\n SetState,\n State,\n} from './types.js';\nimport type {\n AndFunction,\n AnyFunction,\n FunctionWithContext,\n} from '../../types/actions.js';\nimport type { NamespaceConfig, Store } from '../store/mod.js';\n\nimport { generateStoreId, isAsync } from '../helpers.js';\n\nimport {\n ACTION_NOT_FOUND_ERROR,\n BEFORE_ACTION_FAILED_ERROR,\n NO_STORE_FOUND_ERROR,\n OR_ELSE_ACTION_FAILED_ERROR,\n} from './errors.js';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Params = any[];\n\n/**\n *\n * A Namespace is a unit of wallets where usually handles connecting, signing, accounts, ...\n * It will be injected by wallet in its object, for example, `window.phantom.ethereum` or `window.phantom.solana`\n * Each namespace (like solana) has its own functionality which is not shared between all the blockchains.\n * For example in EVM namespaces, you can have different networks (e.g. Ethereum,Polygon, ...) and there are specific flows to handle connecting to them or add a network and etc.\n * But Solana doesn't have this concept and you will directly always connect to solana itself.\n * This is true for signing a transaction, getting information about blockchain and more.\n * So by creating a namespace for each of these, we can define a custom namespace based on blockchain's properties.\n *\n */\nclass Namespace<T extends Actions<T>> {\n /** it will be used for `store` and accessing to store by its id mainly. */\n public readonly namespaceId: string;\n /** it will be used for `store` and accessing to store by its id mainly. */\n public readonly providerId: string;\n\n #actions: RegisteredActions<T>;\n #andOperators: Operators<T> = new Map();\n #orOperators: Operators<T> = new Map();\n // `context` for these two can be Namespace context or Provider context\n #beforeHooks: HooksWithOptions<T> = new Map();\n #afterHooks: HooksWithOptions<T> = new Map();\n\n #initiated = false;\n #store: Store | undefined;\n // Namespace doesn't has any configs now, but we will need the feature in future\n // eslint-disable-next-line no-unused-private-class-members\n #configs: NamespaceConfig;\n\n constructor(\n id: string,\n providerId: string,\n options: {\n store?: Store;\n configs?: NamespaceConfig;\n actions: RegisteredActions<T>;\n }\n ) {\n const { configs, actions } = options;\n\n this.namespaceId = id;\n this.providerId = providerId;\n\n this.#configs = configs || new Map();\n this.#actions = actions;\n\n if (options.store) {\n this.store(options.store);\n }\n }\n\n /**\n * This is an special action that will be called **only once**.\n * We don't call this in `constructor` and developer should call this manually. we only ensure it will be called once.\n *\n * ```ts\n * const myInit = () => { whatever; }\n * const actions = new Map();\n * actions.set(\"init\", myInit)\n * const ns = new Namespace(..., {actions});\n *\n * // Will run `myInit`\n * ns.init()\n *\n * // Will not run `myInit` anymore.\n * ns.init()\n * ns.init()\n * ```\n */\n public init(): void {\n if (this.#initiated) {\n return;\n }\n\n const definedInitByUser = this.#actions.get('init');\n\n if (definedInitByUser) {\n definedInitByUser(this.#context());\n }\n // else, this namespace doesn't have any `init` implemented.\n\n this.#initiated = true;\n }\n\n /**\n * Reading states from store and also update them.\n *\n * @example\n * ```ts\n * const ns = new Namespace(...);\n * const [getState, setState] = ns.state();\n * ```\n */\n public state(): [GetState, SetState] {\n const store = this.#store;\n if (!store) {\n throw new Error(\n 'You need to set your store using `.store` method first.'\n );\n }\n\n const id = this.#storeId();\n const setState: SetState = (name, value) => {\n store.getState().namespaces.updateStatus(id, name, value);\n };\n\n const getState: GetState = <K extends keyof State>(name?: K) => {\n const state: State = store.getState().namespaces.getNamespaceData(id);\n\n if (!name) {\n return state;\n }\n\n return state[name];\n };\n\n return [getState, setState];\n }\n\n /**\n * For keeping state, we need a store. all the states will be write to/read from store.\n *\n * Note: Store can be setup on constructor as well.\n *\n * @example\n * ```ts\n * const myStore = createStore();\n * const ns = new Namespace(...);\n * ns.store(myStore);\n * ```\n */\n public store(store: Store): this {\n if (this.#store) {\n console.warn(\n \"You've already set an store for your Namespace. Old store will be replaced by the new one.\"\n );\n }\n this.#store = store;\n this.#setupStore();\n\n return this;\n }\n\n /**\n * It's a boolean operator to run a sync function if action ran successfully.\n * For example, if we have a `connect` action, we can add function to be run after `connect` if it ran successfully.\n *\n * @example\n * ```ts\n * const ns = new Namespace(..);\n *\n * ns.and_then('connect', (context) => {\n * ...\n * });\n * ```\n *\n */\n public and_then<K extends keyof T>(\n actionName: K,\n operatorFn: FunctionWithContext<AndFunction<T, K>, Context>\n ): this {\n const currentAndOperators = this.#andOperators.get(actionName) || [];\n this.#andOperators.set(actionName, currentAndOperators.concat(operatorFn));\n\n return this;\n }\n\n /**\n * It's a boolean operator to run a function to handle when an action fails.\n * For example, if we have a `connect` action, we can add function to be run when `connect` fails (throw an error).\n *\n * @example\n * ```ts\n * const ns = new Namespace(..);\n *\n * ns.or_else('connect', (context, error) => {\n * ...\n * });\n * ```\n */\n public or_else<K extends keyof T>(\n actionName: K,\n operatorFn: FunctionWithContext<AnyFunction, Context>\n ): this {\n const currentOrOperators = this.#orOperators.get(actionName) || [];\n this.#orOperators.set(actionName, currentOrOperators.concat(operatorFn));\n\n return this;\n }\n\n /**\n * Running a function after a specific action\n *\n * Note: the context can be set from outside as well. this is useful for Provider to set its context instead of namespace context.\n *\n * @example\n * ```ts\n * const ns = new Namespace(...);\n *\n * ns.after(\"connect\", (context) => {});\n * ```\n */\n public after<K extends keyof T, C = unknown>(\n actionName: K,\n hook: FunctionWithContext<AnyFunction, C>,\n options?: { context?: C }\n ): this {\n const currentAfterHooks = this.#afterHooks.get(actionName) || [];\n const hookWithOptions = {\n hook,\n options: {\n context: options?.context,\n },\n };\n\n this.#afterHooks.set(actionName, currentAfterHooks.concat(hookWithOptions));\n return this;\n }\n\n /**\n * Running a function before a specific action\n *\n * Note: the context can be set from outside as well. this is useful for Provider to set its context instead of using namespace context.\n *\n * @example\n * ```ts\n * const ns = new Namespace(...);\n *\n * ns.before(\"connect\", (context) => {});\n * ```\n */\n public before<K extends keyof T, C = unknown>(\n actionName: K,\n hook: FunctionWithContext<AnyFunction, C>,\n options?: { context?: C }\n ): this {\n const currentBeforeHooks = this.#beforeHooks.get(actionName) || [];\n const hookWithOptions = {\n hook,\n options: {\n context: options?.context,\n },\n };\n this.#beforeHooks.set(\n actionName,\n currentBeforeHooks.concat(hookWithOptions)\n );\n\n return this;\n }\n public has<K extends keyof T>(actionName: K): boolean {\n return !!this.#actions.get(actionName);\n }\n /**\n *\n * Registered actions will be called using `run`. it will run an action and all the operators or hooks that assigned.\n *\n * @example\n * ```ts\n * const actions = new Map();\n * actions.set('connect', connectAction);\n *\n * const ns = new Namespace(NAMESPACE, PROVIDER_ID, {\n * actions: actions,\n * });\n *\n * ns.run(\"action\");\n * ```\n */\n public run<K extends keyof T>(\n actionName: K,\n ...args: Params\n ): unknown | Promise<unknown> {\n const action = this.#actions.get(actionName);\n if (!action) {\n throw new Error(ACTION_NOT_FOUND_ERROR(actionName.toString()));\n }\n\n /*\n * Action can be both, sync or async. To simplify the process we can not make `sync` mode to async\n * Since every user's sync action will be an async function and affect what user expect,\n * it makes all the actions async and it doesn't match with Namespace interface (e.g. EvmActions)\n *\n * To avoid this issue and also not duplicating code, I broke the process into smaller methods\n * and two main methods to run actions: tryRunAsyncAction & tryRunAction.\n */\n const result = isAsync(action)\n ? this.#tryRunAsyncAction(actionName, args)\n : this.#tryRunAction(actionName, args);\n\n return result;\n }\n\n #tryRunAction<K extends keyof T>(actionName: K, params: Params): unknown {\n try {\n this.#tryRunBeforeHooks(actionName);\n } catch (error) {\n this.#tryRunAfterHooks(actionName);\n throw new Error(BEFORE_ACTION_FAILED_ERROR(actionName.toString()), {\n cause: error,\n });\n }\n\n const action = this.#actions.get(actionName);\n if (!action) {\n throw new Error(ACTION_NOT_FOUND_ERROR(actionName.toString()));\n }\n\n const context = this.#context();\n\n let result;\n try {\n result = action(context, ...params);\n result = this.#tryRunAndOperators(actionName, result);\n } catch (e) {\n result = this.#tryRunOrOperators(actionName, e);\n } finally {\n this.#tryRunAfterHooks(actionName);\n }\n\n return result;\n }\n\n async #tryRunAsyncAction<K extends keyof T>(\n actionName: K,\n params: Params\n ): Promise<unknown> {\n try {\n this.#tryRunBeforeHooks(actionName);\n } catch (error) {\n this.#tryRunAfterHooks(actionName);\n throw new Error(BEFORE_ACTION_FAILED_ERROR(actionName.toString()), {\n cause: error,\n });\n }\n\n const action = this.#actions.get(actionName);\n if (!action) {\n throw new Error(ACTION_NOT_FOUND_ERROR(actionName.toString()));\n }\n\n const context = this.#context();\n return await action(context, ...params)\n .then((result: unknown) => this.#tryRunAndOperators(actionName, result))\n .catch((e: unknown) => this.#tryRunOrOperators(actionName, e))\n .finally(() => this.#tryRunAfterHooks(actionName));\n }\n\n #tryRunAfterHooks<K extends keyof T>(actionName: K) {\n const afterActions = this.#afterHooks.get(actionName);\n\n if (afterActions) {\n afterActions.forEach((afterAction) => {\n const context = afterAction.options?.context || this.#context();\n afterAction.hook(context);\n });\n }\n }\n\n #tryRunBeforeHooks<K extends keyof T>(actionName: K): void {\n const beforeActions = this.#beforeHooks.get(actionName);\n if (beforeActions) {\n beforeActions.forEach((beforeAction) => {\n const context = beforeAction.options?.context || this.#context();\n beforeAction.hook(context);\n });\n }\n }\n\n #tryRunAndOperators<K extends keyof T>(\n actionName: K,\n result: unknown\n ): unknown {\n const andActions = this.#andOperators.get(actionName);\n\n if (andActions) {\n const context = this.#context();\n result = andActions.reduce((prev, andAction) => {\n return andAction(context, prev);\n }, result);\n }\n return result;\n }\n\n #tryRunOrOperators<K extends keyof T>(\n actionName: K,\n actionError: unknown\n ): unknown {\n const orActions = this.#orOperators.get(actionName);\n\n if (orActions) {\n try {\n const context = this.#context();\n return orActions.reduce((prev, orAction) => {\n return orAction(context, prev);\n }, actionError);\n } catch (orActionError) {\n if (orActionError instanceof Error) {\n orActionError.cause = actionError;\n throw orActionError;\n }\n const errorMessage = OR_ELSE_ACTION_FAILED_ERROR(\n `${actionName.toString()} for ${this.namespaceId} namespace.`\n );\n const standardOrActionError = new Error(String(orActionError), {\n cause: actionError,\n });\n throw new Error(errorMessage, { cause: standardOrActionError });\n }\n } else {\n throw actionError;\n }\n }\n\n #setupStore(): void {\n const store = this.#store;\n if (!store) {\n throw new Error(NO_STORE_FOUND_ERROR);\n }\n\n const id = this.#storeId();\n store.getState().namespaces.addNamespace(id, {\n namespaceId: this.namespaceId,\n providerId: this.providerId,\n });\n }\n\n #storeId() {\n return generateStoreId(this.providerId, this.namespaceId);\n }\n\n #context(): Context<T> {\n return {\n state: this.state.bind(this),\n action: this.run.bind(this),\n };\n }\n}\n\nexport { Namespace };\n", "import type {\n CommonNamespaces,\n Context,\n ExtendableInternalActions,\n GetState,\n RegisteredNamespaces,\n SetState,\n State,\n} from './types.js';\nimport type { FindProxiedNamespace } from '../../builders/mod.js';\nimport type { AnyFunction, FunctionWithContext } from '../../types/actions.js';\nimport type { ProviderConfig, ProviderInfo, Store } from '../store/mod.js';\n\nconst VERSION = '1.0';\n\nexport class Provider {\n public readonly id: string;\n public readonly version = VERSION;\n\n #namespaces: RegisteredNamespaces<keyof CommonNamespaces, CommonNamespaces>;\n #initiated = false;\n #extendInternalActions: ExtendableInternalActions = {};\n #store: Store | undefined;\n #configs: ProviderConfig;\n\n constructor(\n id: string,\n namespaces: RegisteredNamespaces<keyof CommonNamespaces, CommonNamespaces>,\n configs: ProviderConfig,\n options?: {\n /**\n * There are some cases we need to have a behavior like initializing a provider which will be run when we are creating an instance.\n * These internal steps and behaviors will be useful for library user to extend the behavior by running a specific code.\n */\n extendInternalActions?: ExtendableInternalActions;\n store?: Store;\n }\n ) {\n this.id = id;\n this.#configs = configs;\n // it should be only created here, to make sure `after/before` will work properly.\n this.#extendInternalActions = options?.extendInternalActions || {};\n this.#namespaces = namespaces;\n\n /**\n * Our assumption is that the store will be optional for the provider.\n * If a store is provided in the options, it will be initialized and set up.\n */\n if (options?.store) {\n this.#store = options.store;\n this.#setupStore();\n }\n }\n\n /**\n * This is an special callback that will be called **only once**.\n * We don't call this in `constructor` and developer should call this manually. we only ensure it will be called once.\n *\n * ```ts\n * const myInit = () => { whatever; } *\n * const provider = new Provider(..., {extendInternalActions: {init: myInit} });\n *\n * // Will run `myInit`\n * provider.init()\n *\n * // Will not run `myInit` anymore.\n * provider.init()\n * provider.init()\n * ```\n */\n public init(): void {\n if (this.#initiated) {\n return;\n }\n\n const definedInitByUser = this.#extendInternalActions.init;\n if (definedInitByUser) {\n definedInitByUser(this.#context());\n }\n\n this.#initiated = true;\n }\n\n /**\n * Getting state of a provider\n *\n * **Note:**\n * Each namespace has it's own state as well, in Legacy we didn't have this separation and all of them was accessible through Provider itself\n * To be compatible with legacy, `getState` has a logic to guess the final state to produce same state as legacy.\n *\n * @example\n * ```ts\n * const provider = new Provider(...);\n * const [getState, setState] = provider.state();\n *\n * getState('installed');\n * // or\n * getState().installed;\n * ```\n *\n */\n public state(): [GetState, SetState] {\n const store = this.#store;\n if (!store) {\n throw new Error(\n `Any store detected for ${this.id}. You need to set your store using '.store' method first.`\n );\n }\n\n /**\n * State updater\n */\n const setState: SetState = (name, value) => {\n switch (name) {\n case 'installed':\n return store.getState().providers.updateStatus(this.id, name, value);\n default:\n throw new Error(\n `Unhandled state update for provider. (provider id: ${this.id}, state name: ${name})`\n );\n }\n };\n\n /**\n * State getter\n */\n const getState: GetState = <K extends keyof State>(name?: K) => {\n const state: State = store\n .getState()\n .providers.guessNamespacesState(this.id);\n\n if (!name) {\n return state;\n }\n\n switch (name) {\n case 'installed':\n case 'connected':\n case 'connecting':\n return state[name];\n default:\n throw new Error('Unhandled state for provider');\n }\n };\n\n return [getState, setState];\n }\n\n /**\n * For keeping state, we need a store. all the states will be write to/read from store.\n *\n * **Note: When you are setting an store for provider, it will be set for its namespaces automatically as well**\n *\n * @example\n * ```ts\n * const myStore = createStore();\n * const provider = new Provider(...);\n * provider.store(myStore); // or it can be passed to Provider constructor;\n * ```\n */\n public store(store: Store): this {\n if (this.#store) {\n console.warn(\n \"You've already set an store for your Provider. Old store will be replaced by the new one.\"\n );\n }\n this.#store = store;\n this.#setupStore();\n return this;\n }\n\n /**\n * Getting information about a provider which has been set on constructing Provider.\n *\n * @example\n * ```ts\n * const walletInfo = {name: \"Garbage wallet\", ...}\n * const provider = new Provider(..., {info: walletInfo});\n *\n * provider.info();\n * ```\n */\n public info(): ProviderInfo | undefined {\n const store = this.#store;\n if (!store) {\n return this.#configs;\n }\n const config = store.getState().providers.list[this.id].config;\n\n return { metadata: config.metadata, deepLink: config.deepLink };\n }\n\n /**\n * A list of registered _proxied_ namespaces.\n *\n * @example\n * ```ts\n * const provider = new Provider(...);\n * const allNamespaces = provider.getAll();\n * ```\n */\n public getAll(): RegisteredNamespaces<\n keyof CommonNamespaces,\n CommonNamespaces\n > {\n return this.#namespaces;\n }\n\n /**\n * Get a registered namespace in provider by its **namespace key**.\n *\n * Note: difference between namespace key and namespace id is the first one is setting from a predefined list the second one can be anything and will be chosen by library's user.\n *\n * @param {string} id - evm, solana, cosmos, ... (CommonActions)\n */\n public get<K extends keyof CommonNamespaces>(\n id: K\n ): FindProxiedNamespace<K, CommonNamespaces> | undefined {\n return this.#namespaces.get(id) as unknown as\n | FindProxiedNamespace<K, CommonNamespaces>\n | undefined;\n }\n\n /**\n *\n * Get a registered namespace by its **namespaceId**.\n *\n * Note: difference between namespace key and namespace id is the first one is setting from a predefined list the second one can be anything and will be chosen by library's user.\n *\n * @example\n * ```ts\n * const provider = new Provider(...);\n * provider.findByNamespace(\"whatever-id-i-set-for-namespace\")\n * ```\n */\n public findByNamespace<K extends keyof CommonNamespaces>(\n namespaceLookingFor: K | string\n ): FindProxiedNamespace<K, CommonNamespaces> | undefined {\n // If we didn't found any match, we will return `undefined`.\n let result: object | undefined = undefined;\n\n this.#namespaces.forEach((namespace) => {\n if (namespace.namespaceId === namespaceLookingFor) {\n result = namespace;\n }\n });\n\n return result;\n }\n\n /**\n * Running a hook function _after_ a specific action for **all registered namespaces**.\n *\n * **Note:** the context can be set from outside as well. this is useful for Provider to set its context instead of namespace context.\n *\n * @example\n * ```ts\n * const provider = new Provider(...);\n *\n * provider.after(\"connect\", (context) => {});\n * ```\n */\n public before(\n actionName: string,\n hookFn: FunctionWithContext<AnyFunction, Context>\n ): this {\n this.#addHook('before', actionName, hookFn);\n return this;\n }\n\n /**\n * Running a hook function _before_ a specific action for **all registered namespaces**.\n *\n * **Note:** the context can be set from outside as well. this is useful for Provider to set its context instead of namespace context.\n *\n * @example\n * ```ts\n * const provider = new Provider(...);\n *\n * provider.after(\"connect\", (context) => {});\n * ```\n */\n public after(\n actionName: string,\n hookFn: FunctionWithContext<AnyFunction, Context>\n ): this {\n this.#addHook('after', actionName, hookFn);\n return this;\n }\n\n #addHook(\n hookName: 'after' | 'before',\n actionName: string,\n cb: FunctionWithContext<AnyFunction, Context>\n ): this {\n const context = {\n state: this.state.bind(this),\n };\n\n this.#namespaces.forEach((namespace) => {\n if (hookName === 'after') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n namespace.after(actionName as any, cb, {\n context,\n });\n } else if (hookName === 'before') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n namespace.before(actionName as any, cb, {\n context,\n });\n } else {\n throw new Error(`You hook name is invalid: ${hookName}`);\n }\n });\n\n return this;\n }\n\n #setupStore(): void {\n const store = this.#store;\n if (!store) {\n throw new Error('For setup store, you should set `store` first.');\n }\n store.getState().providers.addProvider(this.id, this.#configs);\n this.#namespaces.forEach((provider) => {\n provider.store(store);\n });\n }\n\n #context(): Context {\n return {\n state: this.state.bind(this),\n };\n }\n}\n", "import type { Namespace, State as NamespaceState } from './namespaces/mod.js';\nimport type { Provider, State as ProviderState } from './provider/mod.js';\nimport type { Store } from './store/mod.js';\n\ntype HubState = {\n [key in string]: ProviderState & {\n namespaces: NamespaceState[];\n };\n};\n\ntype RunAllResult = {\n id: string;\n provider: unknown;\n namespaces: unknown[];\n};\n\ninterface HubOptions {\n store?: Store;\n}\nexport class Hub {\n #providers = new Map<string, Provider>();\n #options: HubOptions;\n\n constructor(options?: HubOptions) {\n this.#options = options ?? {};\n }\n\n init() {\n this.runAll('init');\n }\n\n /*\n * Running a specific action (e.g. init) on all namespaces and providers one by one.\n *\n * TODO: Some of methods may accepts args, with this implementation we only limit to those one without any argument.\n */\n runAll(action: string): RunAllResult[] {\n const output: RunAllResult[] = [];\n\n // run action on all providers eagerConnect, disconnect\n const providers = this.#providers.values();\n\n for (const provider of providers) {\n // Calling `action` on `Provider` if exists.\n const providerOutput: RunAllResult = {\n id: provider.id,\n provider: undefined,\n namespaces: [],\n };\n\n const providerMethod = provider[action as keyof Provider];\n if (typeof providerMethod === 'function') {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore-next-line\n providerOutput.provider = providerMethod.call(provider);\n }\n\n // Namespace instances can have their own `action` as well. we will call them as well.\n const namespaces = provider.getAll().values();\n for (const namespace of namespaces) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore-next-line\n const namespaceMethod = namespace[action];\n if (typeof namespaceMethod === 'function') {\n const result = namespaceMethod();\n providerOutput.namespaces.push(result);\n }\n }\n\n output.push(providerOutput);\n }\n\n return output;\n }\n\n add(id: string, provider: Provider) {\n if (this.#options.store) {\n provider.store(this.#options.store);\n }\n this.#providers.set(id, provider);\n return this;\n }\n remove(id: string) {\n const providerToRemove = this.#providers.get(id);\n\n if (!providerToRemove) {\n throw new Error(`Provider not found: No provider exists with ID \"${id}\"`);\n }\n\n this.#options.store?.getState().providers.removeProvider(id);\n this.#providers.delete(id);\n\n return this;\n }\n\n get(providerId: string): Provider | undefined {\n return this.#providers.get(providerId);\n }\n\n getAll() {\n return this.#providers;\n }\n\n state(): HubState {\n const output = this.runAll('state');\n const res: HubState = {};\n\n output.forEach((result) => {\n const namespaces: NamespaceState[] = [];\n result.namespaces.forEach((b) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const [getNamespaceState] = b as ReturnType<Namespace<any>['state']>;\n\n namespaces.push(getNamespaceState());\n });\n\n const [getProviderState] = result.provider as ReturnType<\n Provider['state']\n >;\n\n res[result.id] = {\n ...(getProviderState() || {}),\n namespaces: namespaces,\n };\n });\n return res;\n }\n}\n", "/**\n * Note: Zustand has some difficulty when you are trying to `previous` state on `subscribe`.\n * If these selectors define inside store directly and use `get()` for accessing state, it will get the latest state\n * instead of previous state which desired.\n * So make them a helper will let us to reuse them both in store and outside of store in a `subscribe`.\n */\nimport type { State } from '../mod.js';\nimport type { State as InternalProviderState } from '../provider/mod.js';\n\n/**\n * Legacy provider state includes `connecting` and `connected` values. It hadn't a separation layer for `namespaces`.\n * For compatibility reasons, we should produce these two values somehow.\n *\n * Currently, We return `true` if any of namespaces return true. We are missing failed namespace here.\n * But if we want to solve that, we should migrate our client code to use `namespace` state directly and not from `provider`\n */\nexport function guessProviderStateSelector(\n state: State,\n providerId: string\n): InternalProviderState {\n /*\n * We keep namespaces in a separate branch than providers.\n * We should look at all of them and find all the namespaces that for our current proivder.\n */\n const allNamespaces = state.namespaces.list;\n const currentProviderNamespaces = Object.keys(allNamespaces).filter(\n (key) => allNamespaces[key].info.providerId === providerId\n );\n\n // Returning provider state value directly.\n const installed = !!state.providers.list[providerId]?.data.installed;\n\n /*\n * If any namespaces returns `true`, we consider the whole provider for this field to be `true`.\n * it has a downside regarding errors which explained on top of the function.\n */\n const connected =\n currentProviderNamespaces.length > 0\n ? currentProviderNamespaces.some(\n (key) => allNamespaces[key].data.connected\n )\n : false;\n const connecting =\n currentProviderNamespaces.length > 0\n ? currentProviderNamespaces.some(\n (key) => allNamespaces[key].data.connecting\n )\n : false;\n\n return {\n installed,\n connected,\n connecting,\n };\n}\n\nexport function namespaceStateSelector(state: State, storeId: string) {\n return state.namespaces.list[storeId].data;\n}\n", "import type { StoreApi } from 'zustand/vanilla';\n\nimport { createStore as createZustandStore } from 'zustand/vanilla';\n\nimport { extend, type Store } from './extend.js';\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 RawStore = StoreApi<State>;\n\nexport const createStore = (): Store => {\n const store = createZustandStore<State>((...api) => {\n return {\n hub: hubStore(...api),\n providers: providersStore(...api),\n namespaces: namespacesStore(...api),\n };\n });\n\n return extend(store);\n};\n", "import type {\n Event,\n ProviderConnectedEvent,\n ProviderConnectingEvent,\n ProviderDisconnectedEvent,\n} from './events.js';\nimport type { RawStore, State } from './store.js';\n\nimport { guessProviderStateSelector } from './selectors.js';\n\nexport interface Store extends Omit<RawStore, 'subscribe'> {\n subscribe(listener: (event: Event, state: State, prevState: State) => void): {\n flushEvents(): void;\n };\n}\n\n/**\n * Zustand's store provides a set of built-in functionalities,\n * but it may not meet all our requirements.\n * This function modifies the interface and adds or updates the available methods.\n */\nexport function extend(store: RawStore): Store {\n const extendedSubscribe: (store: RawStore) => Store['subscribe'] =\n (store) => (listener) => {\n const executeListener = (\n events: Event[],\n state: State,\n prevState: State\n ) => {\n for (const ev of events) {\n listener(ev, state, prevState);\n }\n };\n\n /*\n * only known changes will fire event for lib users\n * so all the changes in store won't trigger a user-face event\n */\n store.subscribe((state, prevState) => {\n const eventsLike = getEventsLike(state, prevState);\n const events = tryConsumeEvents(state);\n const allQueuedEvents = [...events, ...eventsLike];\n executeListener(allQueuedEvents, state, prevState);\n });\n\n return {\n /**\n * Manually run pending events.\n * This useful when use `subscribe` method after sometime and when store initialized.\n *\n * Note: Please consider both current and previous state will be same and we don't have access to previous state in a such scenario.\n */\n flushEvents: () => {\n const state = store.getState();\n const events = tryConsumeEvents(state);\n executeListener(events, state, state);\n },\n };\n };\n\n return new Proxy(store, {\n get: function (target, prop, receiver) {\n if (prop === 'subscribe') {\n return extendedSubscribe(target);\n }\n return Reflect.get(target, prop, receiver);\n },\n }) as unknown as Store;\n}\n\n/**\n * Retrieves the ConsumableEvent from the store and returns its values.\n * The values will be consumed by iterating over the field.\n */\nfunction tryConsumeEvents(state: State): Event[] {\n return [...state.providers.events, ...state.namespaces.events];\n}\n\n/**\n * In certain cases, adding events to the store is not possible (e.g., namespace or provider layer).\n * In these cases, we observe store changes and treat specific patterns as events when detected.\n *\n * Note: This approach should be avoided in most cases. It is used here to maintain backward compatibility\n * with the provider's legacy interface.\n */\nfunction getEventsLike(state: State, prevState: State): Event[] {\n const events: Event[] = [];\n\n for (const providerId of Object.keys(state.providers.list)) {\n const currentProviderState = guessProviderStateSelector(state, providerId);\n const previousProviderState = guessProviderStateSelector(\n prevState,\n providerId\n );\n\n if (previousProviderState.connecting !== currentProviderState.connecting) {\n const ev: ProviderConnectingEvent = {\n type: 'provider_connecting',\n provider: providerId,\n value: currentProviderState.connecting,\n };\n events.push(ev);\n }\n\n if (!previousProviderState.connected && currentProviderState.connected) {\n const ev: ProviderConnectedEvent = {\n type: 'provider_connected',\n provider: providerId,\n };\n\n events.push(ev);\n }\n\n if (previousProviderState.connected && !currentProviderState.connected) {\n const ev: ProviderDisconnectedEvent = {\n type: 'provider_disconnected',\n provider: providerId,\n };\n\n events.push(ev);\n }\n }\n\n return events;\n}\n", "/************ Hub ************/\n\nimport type { State } from './mod.js';\nimport type { StateCreator } from 'zustand';\n\ntype HubConfig = object;\n\nexport interface HubStore {\n config: HubConfig;\n}\n\ntype HubStateCreator = StateCreator<State, [], [], HubStore>;\n\nconst hubStore: HubStateCreator = () => ({\n config: {},\n});\n\nexport { hubStore };\n", "/************ Namespace ************/\n\nimport type { StateCreator } from 'zustand';\n\nimport { produce } from 'immer';\n\nimport {\n ConsumableEvents,\n type NamespaceConnectedEvent,\n type NamespaceDisconnectedEvent,\n type NamespaceSwitchedAccountEvent,\n type NamespaceSwitchedNetworkEvent,\n} from './events.js';\nimport { namespaceStateSelector, type State } from './mod.js';\n\n// Currently, namespace doesn't has any config.\nexport type NamespaceConfig = object;\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\ninterface NamespaceItem {\n info: NamespaceInfo;\n data: NamespaceData;\n error: unknown;\n}\n\ntype NamespaceState = {\n events: InstanceType<typeof ConsumableEvents>;\n list: Record<string, NamespaceItem>;\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\n _produceEventsWhenUpdatingStatus: <K extends keyof NamespaceData>(\n namespace: NamespaceItem,\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 events: new ConsumableEvents(),\n\n list: {},\n addNamespace: (id, info) => {\n const data: NamespaceData = {\n accounts: null,\n network: null,\n connected: false,\n connecting: false,\n };\n\n const item = {\n data,\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 const ns = get().namespaces.list[id];\n if (!ns) {\n throw new Error(`No namespace with '${id}' found.`);\n }\n\n get().namespaces._produceEventsWhenUpdatingStatus(ns, id, key, value);\n\n // Updating state\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 _produceEventsWhenUpdatingStatus: (namespace, id, key, value) => {\n if (key === 'accounts') {\n // check for both null and empty array\n const isAccountsEmpty =\n Object.is(value, null) || (Array.isArray(value) && value.length === 0);\n\n if (isAccountsEmpty) {\n const currentConnectedStatus = get().namespaces.list[id].data.connected;\n if (currentConnectedStatus) {\n const event: NamespaceDisconnectedEvent = {\n type: 'namespace_disconnected',\n provider: namespace.info.providerId,\n namespace: namespace.info.namespaceId,\n };\n\n get().namespaces.events.push(event);\n }\n // Skip emitting disconnect event, if the `connected` is false\n } else {\n const currentAccounts = get().namespaces.list[id].data.accounts;\n\n if (!currentAccounts) {\n const event: NamespaceConnectedEvent = {\n type: 'namespace_connected',\n provider: namespace.info.providerId,\n namespace: namespace.info.namespaceId,\n accounts: value as string[],\n };\n\n get().namespaces.events.push(event);\n } else {\n const areSameAccounts =\n // Clone the object from the Zustand store, as it's immutable, to avoid errors during sorting.\n [...currentAccounts].sort().toString() ===\n (value as string[]).sort().toString();\n\n if (!areSameAccounts) {\n const event: NamespaceSwitchedAccountEvent = {\n type: 'namespace_account_switched',\n provider: namespace.info.providerId,\n namespace: namespace.info.namespaceId,\n previousAccounts: currentAccounts,\n accounts: value as string[],\n };\n\n get().namespaces.events.push(event);\n }\n }\n }\n } else if (key === 'network') {\n const currentNetwork = get().namespaces.list[id].data.network;\n\n const event: NamespaceSwitchedNetworkEvent = {\n type: 'namespace_network_switched',\n provider: namespace.info.providerId,\n namespace: namespace.info.namespaceId,\n network: value as string,\n previousNetwork: currentNetwork,\n };\n\n get().namespaces.events.push(event);\n }\n },\n});\n\nexport { namespacesStore };\n", "export type NamespaceDisconnectedEvent = {\n type: 'namespace_disconnected';\n provider: string;\n namespace: string;\n};\n\nexport type NamespaceConnectedEvent = {\n type: 'namespace_connected';\n provider: string;\n namespace: string;\n accounts: string[];\n};\n\nexport type NamespaceSwitchedAccountEvent = {\n type: 'namespace_account_switched';\n provider: string;\n namespace: string;\n accounts: string[];\n previousAccounts: string[];\n};\n\nexport type NamespaceSwitchedNetworkEvent = {\n type: 'namespace_network_switched';\n provider: string;\n namespace: string;\n network: string;\n previousNetwork: string | null;\n};\n\nexport type ProviderDetectedEvent = {\n type: 'provider_detected';\n provider: string;\n};\n\nexport type ProviderConnectingEvent = {\n type: 'provider_connecting';\n provider: string;\n value: boolean;\n};\n\nexport type ProviderConnectedEvent = {\n type: 'provider_connected';\n provider: string;\n};\n\nexport type ProviderDisconnectedEvent = {\n type: 'provider_disconnected';\n provider: string;\n};\n\nexport type Event =\n | NamespaceDisconnectedEvent\n | NamespaceConnectedEvent\n | NamespaceSwitchedAccountEvent\n | NamespaceSwitchedNetworkEvent\n | ProviderDetectedEvent\n | ProviderConnectingEvent\n | ProviderConnectedEvent\n | ProviderDisconnectedEvent;\n\n/**\n *\n * Keeping an array of Event and when iterates over its values, it will be removed (consume) from the array.\n *\n */\nexport class ConsumableEvents {\n #data: Event[] = [];\n\n push(val: Event) {\n this.#data.push(val);\n }\n\n [Symbol.iterator](): Iterator<Event> {\n return {\n next: (): IteratorResult<Event> => {\n if (this.#data.length == 0) {\n return { done: true, value: undefined };\n }\n\n // Typescript can not narrow the type, but we have a runtime check to ensure it will never be an empty list\n const value = this.#data.shift()!;\n return {\n done: false,\n value,\n };\n },\n };\n }\n}\n", "import type { Namespace } from '../../namespaces/common/types.js';\nimport type {\n GenerateDeepLink,\n State as InternalProviderState,\n} from '../provider/mod.js';\nimport type { BlockchainMeta, SignerFactory } from 'rango-types';\nimport type { StateCreator } from 'zustand';\n\nimport { produce } from 'immer';\n\nimport { ConsumableEvents, type ProviderDetectedEvent } from './events.js';\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 };\n\ntype NamespacesProperty = Property<\n 'namespaces',\n {\n selection: 'single' | 'multiple';\n data: {\n label: string;\n id: string;\n value: Namespace;\n unsupported?: boolean;\n getSupportedChains: (chains: BlockchainMeta[]) => BlockchainMeta[];\n }[];\n }\n>;\ntype DerivationPathProperty = Property<\n 'derivationPath',\n {\n data: {\n id: string;\n label: string;\n namespace: Namespace;\n generateDerivationPath: (index: string) => string;\n }[];\n }\n>;\ntype DetailsProperty = Property<\n 'details',\n {\n mobileWallet?: boolean;\n showOnMobile?: boolean;\n isContractWallet?: boolean;\n }\n>;\ntype SignersProperty = Property<\n 'signers',\n {\n getSigners: () => Promise<SignerFactory>;\n }\n>;\n\nexport type ProviderMetadata = {\n name: string;\n icon: string;\n extensions: Partial<Record<Browsers, string>>;\n properties?: Array<\n | NamespacesProperty\n | DerivationPathProperty\n | DetailsProperty\n | SignersProperty\n >;\n};\n\nexport interface ProviderConfig {\n metadata: ProviderMetadata;\n deepLink?: GenerateDeepLink;\n}\n\nexport type ProviderInfo = ProviderConfig;\n\ninterface ProviderData {\n installed: boolean;\n}\n\ninterface ProviderItem {\n config: ProviderConfig;\n data: ProviderData;\n error: unknown;\n}\n\ntype ProviderState = {\n events: ConsumableEvents;\n list: Record<string, ProviderItem>;\n};\ninterface ProviderActions {\n addProvider: (id: string, config: ProviderConfig) => void;\n removeProvider: (id: string) => void;\n updateStatus: <K extends keyof ProviderData>(\n id: string,\n key: K,\n value: ProviderData[K]\n ) => void;\n\n _produceEventsWhenUpdatingStatus: <K extends keyof ProviderData>(\n provider: ProviderItem,\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 events: new ConsumableEvents(),\n\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 removeProvider: (id) => {\n set(\n produce((state: State) => {\n delete state.providers.list[id];\n })\n );\n },\n updateStatus: (id, key, value) => {\n const provider = get().providers.list[id];\n if (!provider) {\n throw new Error(`No namespace namespace with '${id}' found.`);\n }\n\n get().providers._produceEventsWhenUpdatingStatus(provider, id, key, value);\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 _produceEventsWhenUpdatingStatus: (_provider, id, key, _value) => {\n if (key === 'installed') {\n const event: ProviderDetectedEvent = {\n type: 'provider_detected',\n provider: id,\n };\n\n get().providers.events.push(event);\n }\n },\n});\n\nexport { providersStore };\n", "import type { ActionByBuilder } from './action.js';\nimport type { ProxiedNamespace } from './types.js';\nimport type { Actions, ActionsMap, Context } from '../hub/namespaces/mod.js';\nimport type { NamespaceConfig } from '../hub/store/mod.js';\nimport type { FunctionWithContext } from '../types/actions.js';\n\nimport { Namespace } from '../hub/mod.js';\n\n/**\n * There are Namespace's methods that should be called directly on Proxy object.\n * The Proxy object is creating in `.build`.\n */\nexport const allowedMethods = [\n 'init',\n 'state',\n 'after',\n 'before',\n 'and_then',\n 'or_else',\n 'store',\n] as const;\n/**\n * List of value types that are considered safe to return directly when\n * accessing properties on a proxied `Namespace`.\n *\n * This is useful for allowing public values like `version` to be accessed.\n * If a property's value is of one of these types (e.g.,`'string'`, `'number'`),\n * it will be returned as-is.\n *\n * @const {Array<'string' | 'number'>} allowedPublicValues\n */\nconst allowedPublicValues = ['string', 'number'];\n\nexport class NamespaceBuilder<T extends Actions<T>> {\n #id: string;\n #providerId: string;\n #actions: ActionsMap<T> = new Map();\n /*\n * We keep a list of `ActionBuilder` outputs here to use them in separate phases.\n * Actually, `ActionBuilder` is packing action and its hooks in one place, here we should expand them and them in appropriate places.\n * Eventually, action will be added to `#actions` and its hooks will be added to `Namespace`.\n */\n #actionBuilders: ActionByBuilder<T, Context<T>>[] = [];\n #configs: NamespaceConfig;\n\n constructor(id: string, providerId: string) {\n this.#id = id;\n this.#providerId = providerId;\n this.#configs = {};\n }\n\n /** There are some predefined configs that can be set for each namespace separately */\n public config<K extends keyof NamespaceConfig>(\n name: K,\n value: NamespaceConfig[K]\n ) {\n this.#configs[name] = value;\n return this;\n }\n\n /**\n * Getting a list of actions.\n *\n * e.g.:\n * ```ts\n * .action([\n * [\"connect\", () => {}],\n * [\"disconnect\", () => {}]\n * ])\n * ```\n *\n */\n public action<K extends keyof T>(\n action: (readonly [K, FunctionWithContext<T[K], Context<T>>])[]\n ): NamespaceBuilder<T>;\n\n /**\n *\n * Add a single action\n *\n * e.g.:\n * ```ts\n * .action( [\"connect\", () => {}] )\n * ```\n */\n public action<K extends keyof T>(\n action: K,\n actionFn: FunctionWithContext<T[K], Context<T>>\n ): NamespaceBuilder<T>;\n\n public action(action: ActionByBuilder<T, Context<T>>): NamespaceBuilder<T>;\n\n /**\n *\n * Actions are piece of functionality that a namespace can have, for example it can be a `connect` function\n * or a sign function or even a function for updating namespace's internal state. Actions are flexible and can be anything.\n *\n * Generally, each standard namespace (e.g. evm) has an standard interface defined in `src/namespaces/`\n * and provider (which includes namespaces) authors will implement those actions.\n *\n * You can call this function by a list of actions or a single action.\n *\n */\n public action<K extends keyof T>(\n action: (readonly [K, FunctionWithContext<T[K], Context<T>>])[] | K,\n actionFn?: FunctionWithContext<T[K], Context<T>>\n ) {\n // List mode\n if (Array.isArray(action)) {\n action.forEach(([name, actionFnForItem]) => {\n this.#actions.set(name, actionFnForItem);\n });\n return this;\n }\n\n // Action builder mode\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (typeof action === 'object' && !!action?.actionName) {\n this.#actionBuilders.push(action);\n return this;\n }\n\n // Single action mode\n if (!!actionFn) {\n this.#actions.set(action, actionFn);\n }\n\n return this;\n }\n\n /**\n * By calling build, an instance of Namespace will be built.\n *\n * Note: it's not exactly a `Namespace`, it returns a Proxy which add more convenient use like `namespace.connect()` instead of `namespace.run(\"connect\")`\n */\n public build(): ProxiedNamespace<T> {\n if (this.#isConfigsValid(this.#configs)) {\n return this.#buildApi(this.#configs);\n }\n\n throw new Error(`You namespace config isn't valid.`);\n }\n\n // Currently, namespace doesn't has any config.\n #isConfigsValid(_config: NamespaceConfig): boolean {\n return true;\n }\n\n /*\n * Extracting hooks and add them to `Namespace` for the action.\n *\n * Note: this should be called after `addActionsFromActionBuilders` to ensure the action is added first.\n */\n #addHooksFromActionBuilders(namespace: Namespace<T>) {\n this.#actionBuilders.forEach((actionByBuild) => {\n actionByBuild.after.forEach((afterHooks) => {\n afterHooks.map((action) => {\n namespace.after(actionByBuild.actionName, action);\n });\n });\n\n actionByBuild.before.forEach((beforeHooks) => {\n beforeHooks.map((action) => {\n namespace.before(actionByBuild.actionName, action);\n });\n });\n\n actionByBuild.and.forEach((andHooks) => {\n andHooks.map((action) => {\n namespace.and_then(actionByBuild.actionName, action);\n });\n });\n\n actionByBuild.or.forEach((orHooks) => {\n orHooks.map((action) => {\n namespace.or_else(actionByBuild.actionName, action);\n });\n });\n });\n }\n\n /**\n * Iterate over `actionBuilders` and add them to exists `actions`.\n * Note: Hooks will be added in a separate phase.\n */\n #addActionsFromActionBuilders() {\n this.#actionBuilders.forEach((actionByBuild) => {\n this.#actions.set(actionByBuild.actionName, actionByBuild.action);\n });\n }\n\n /**\n * Build a Proxy object to call actions in a more convenient way. e.g `.connect()` instead of `.run(connect)`\n */\n #buildApi(configs: NamespaceConfig): ProxiedNamespace<T> {\n this.#addActionsFromActionBuilders();\n const namespace = new Namespace<T>(this.#id, this.#providerId, {\n configs,\n actions: this.#actions,\n });\n this.#addHooksFromActionBuilders(namespace);\n\n const api = new Proxy(namespace, {\n has: (_, property) => {\n if (typeof property !== 'string') {\n throw new Error(\n 'You can use string as your property on Namespace instance.'\n );\n }\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore-next-line\n if (allowedMethods.includes(property)) {\n return true;\n }\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore-next-line\n if (allowedPublicValues.includes(typeof namespace[property])) {\n return true;\n }\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore-next-line\n return namespace.has(property);\n },\n get: (_, property) => {\n if (typeof property !== 'string') {\n throw new Error(\n 'You can use string as your property on Namespace instance.'\n );\n }\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore-next-line\n const targetValue = namespace[property];\n\n if (\n allowedMethods.includes(property as (typeof allowedMethods)[number])\n ) {\n return targetValue.bind(namespace);\n }\n /*\n * This is useful accessing values like `version`, If we don't do this, we should whitelist\n * All the values as well, So it can be confusing for someone that only wants to add a public value to `Namespace`\n */\n if (allowedPublicValues.includes(typeof targetValue)) {\n return targetValue;\n }\n\n return namespace.run.bind(namespace, property as keyof T);\n },\n set: () => {\n throw new Error('You can not set anything on this object.');\n },\n });\n\n return api as unknown as ProxiedNamespace<T>;\n }\n}\n", "import type { FindProxiedNamespace } from './types.js';\nimport type {\n CommonNamespaces,\n ExtendableInternalActions,\n ProviderBuilderOptions,\n} from '../hub/provider/mod.js';\nimport type { ProviderConfig } from '../hub/store/mod.js';\n\nimport { Provider } from '../hub/provider/mod.js';\n\nexport class ProviderBuilder {\n #id: string;\n #namespaces = new Map();\n #methods: ExtendableInternalActions = {};\n #configs: Partial<ProviderConfig> = {};\n #options: Partial<ProviderBuilderOptions>;\n\n constructor(id: string, options?: ProviderBuilderOptions) {\n this.#id = id;\n this.#options = options || {};\n }\n\n public add<K extends keyof CommonNamespaces>(\n id: K,\n namespace: FindProxiedNamespace<K, CommonNamespaces>\n ) {\n if (this.#options.store) {\n namespace.store(this.#options.store);\n }\n this.#namespaces.set(id, namespace);\n return this;\n }\n\n public config<K extends keyof ProviderConfig>(\n name: K,\n value: ProviderConfig[K]\n ) {\n this.#configs[name] = value;\n return this;\n }\n\n public init(cb: Exclude<ExtendableInternalActions['init'], undefined>) {\n this.#methods.init = cb;\n return this;\n }\n\n public build(): Provider {\n if (this.#isConfigsValid(this.#configs)) {\n return new Provider(this.#id, this.#namespaces, this.#configs, {\n extendInternalActions: this.#methods,\n store: this.#options.store,\n });\n }\n\n throw new Error('You need to set all required configs.');\n }\n\n #isConfigsValid(config: Partial<ProviderConfig>): config is ProviderConfig {\n return !!config.metadata;\n }\n}\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 type { Provider } from '../hub/mod.js';\nimport type { LegacyProviderInterface } from '../legacy/mod.js';\n\ntype LegacyVersioned = ['0.0.0', LegacyProviderInterface];\ntype HubVersioned = ['1.0.0', Provider];\ntype AvailableVersionedProviders = LegacyVersioned | HubVersioned;\nexport type VersionedProviders = AvailableVersionedProviders[];\nexport type VersionInterface<T extends AvailableVersionedProviders[]> = T[1];\n\ntype SemVer<T extends [string, any]> = T extends [infer U, any] ? U : never;\ntype MatchVersion<T extends VersionedProviders, Version> = Extract<\n T[number],\n [Version, any]\n>;\n\nexport function pickVersion<\n L extends VersionedProviders,\n V extends SemVer<VersionedProviders[number]>\n>(list: L, targetVersion: V): MatchVersion<L, V> {\n if (!targetVersion) {\n throw new Error(`You should provide a valid semver, e.g 1.0.0.`);\n }\n\n const target = list.find(([version]) => version === targetVersion);\n\n if (!target) {\n throw new Error(\n `You target version hasn't been found. Available versions: ${Object.keys(\n list\n ).join(', ')}`\n );\n }\n return target as MatchVersion<L, V>;\n}\n\ninterface DefineVersionsApi {\n version: <T extends SemVer<VersionedProviders[number]>>(\n semver: T,\n value: VersionInterface<MatchVersion<VersionedProviders, T>>\n ) => DefineVersionsApi;\n build: () => VersionedProviders;\n}\n\nexport function defineVersions(): DefineVersionsApi {\n const versions: VersionedProviders = [];\n const api: DefineVersionsApi = {\n version: (semver, value) => {\n versions.push([semver, value]);\n return api;\n },\n build: () => {\n return versions;\n },\n };\n return api;\n}\n\nexport function legacyProviderImportsToVersionsInterface(\n provider: LegacyProviderInterface\n): VersionedProviders {\n return defineVersions().version('0.0.0', provider).build();\n}\n"],
|
|
5
|
+
"mappings": "+EAIO,SAASA,EAAQC,EAAc,CACpC,OAAOA,EAAG,YAAY,OAAS,eACjC,CAFgBC,EAAAF,EAAA,WAIT,SAASG,EAAgBC,EAAoBC,EAAmB,CACrE,MAAO,GAAGD,CAAU,KAAKC,CAAS,EACpC,CAFgBH,EAAAC,EAAA,mBCRT,IAAMG,EAAyBC,EAACC,GACrC,kBAAkBA,CAAI,kDADc,0BAGzBC,EAA8BF,EAACC,GAC1C,oCAAoCA,CAAI,GADC,+BAG9BE,EAA6BH,EAACC,GACzC,gDAAgDA,CAAI,WADZ,8BAG7BG,EACX,iDC8BF,IAAMC,EAAN,KAAsC,CAxCtC,MAwCsC,CAAAC,EAAA,kBAEpB,YAEA,WAEhBC,GACAC,GAA8B,IAAI,IAClCC,GAA6B,IAAI,IAEjCC,GAAoC,IAAI,IACxCC,GAAmC,IAAI,IAEvCC,GAAa,GACbC,GAGAC,GAEA,YACEC,EACAC,EACAC,EAKA,CACA,GAAM,CAAE,QAAAC,EAAS,QAAAC,CAAQ,EAAIF,EAE7B,KAA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KA,GACb,OAAQ,KAAKD,GACb,MAAO,KAAKD,GACZ,IAAK,KAAKF,GACV,GAAI,KAAKC,EACX,CACF,CACF,ECjFA,UAAYM,OAAU,OCWf,SAASC,EAGdC,EAASC,EAAsC,CAC/C,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,+CAA+C,EAGjE,IAAMC,EAASF,EAAK,KAAK,CAAC,CAACG,CAAO,IAAMA,IAAYF,CAAa,EAEjE,GAAI,CAACC,EACH,MAAM,IAAI,MACR,6DAA6D,OAAO,KAClEF,CACF,EAAE,KAAK,IAAI,CAAC,EACd,EAEF,OAAOE,CACT,CAlBgBE,EAAAL,EAAA,eA4BT,SAASM,GAAoC,CAClD,IAAMC,EAA+B,CAAC,EAChCC,EAAyB,CAC7B,QAAS,CAACC,EAAQC,KAChBH,EAAS,KAAK,CAACE,EAAQC,CAAK,CAAC,EACtBF,GAET,MAAO,IACED,CAEX,EACA,OAAOC,CACT,CAZgBH,EAAAC,EAAA",
|
|
6
6
|
"names": ["isAsync", "fn", "__name", "generateStoreId", "providerId", "namespace", "ACTION_NOT_FOUND_ERROR", "__name", "name", "OR_ELSE_ACTION_FAILED_ERROR", "BEFORE_ACTION_FAILED_ERROR", "NO_STORE_FOUND_ERROR", "Namespace", "__name", "#actions", "#andOperators", "#orOperators", "#beforeHooks", "#afterHooks", "#initiated", "#store", "#configs", "id", "providerId", "options", "configs", "actions", "definedInitByUser", "#context", "store", "#storeId", "name", "state", "value", "#setupStore", "actionName", "operatorFn", "currentAndOperators", "currentOrOperators", "hook", "currentAfterHooks", "hookWithOptions", "currentBeforeHooks", "args", "action", "ACTION_NOT_FOUND_ERROR", "isAsync", "#tryRunAsyncAction", "#tryRunAction", "params", "#tryRunBeforeHooks", "error", "#tryRunAfterHooks", "BEFORE_ACTION_FAILED_ERROR", "context", "result", "#tryRunAndOperators", "e", "#tryRunOrOperators", "afterActions", "afterAction", "beforeActions", "beforeAction", "andActions", "prev", "andAction", "actionError", "orActions", "orAction", "orActionError", "errorMessage", "OR_ELSE_ACTION_FAILED_ERROR", "standardOrActionError", "NO_STORE_FOUND_ERROR", "generateStoreId", "VERSION", "Provider", "__name", "#namespaces", "#initiated", "#extendInternalActions", "#store", "#configs", "id", "namespaces", "configs", "options", "#setupStore", "definedInitByUser", "#context", "store", "name", "state", "value", "config", "namespaceLookingFor", "result", "namespace", "actionName", "hookFn", "#addHook", "hookName", "cb", "context", "provider", "Hub", "__name", "#providers", "#options", "options", "action", "output", "providers", "provider", "providerOutput", "providerMethod", "namespaces", "namespace", "namespaceMethod", "result", "id", "providerId", "res", "b", "getNamespaceState", "getProviderState", "guessProviderStateSelector", "state", "providerId", "allNamespaces", "currentProviderNamespaces", "key", "installed", "connected", "connecting", "__name", "namespaceStateSelector", "storeId", "createZustandStore", "extend", "store", "extendedSubscribe", "__name", "listener", "executeListener", "events", "state", "prevState", "ev", "eventsLike", "getEventsLike", "allQueuedEvents", "tryConsumeEvents", "target", "prop", "receiver", "providerId", "currentProviderState", "guessProviderStateSelector", "previousProviderState", "hubStore", "__name", "produce", "ConsumableEvents", "__name", "#data", "val", "namespacesStore", "__name", "set", "get", "ConsumableEvents", "id", "info", "item", "produce", "state", "key", "value", "ns", "storeId", "namespaceStateSelector", "namespace", "event", "currentAccounts", "currentNetwork", "produce", "providersStore", "__name", "set", "get", "ConsumableEvents", "id", "config", "item", "produce", "state", "key", "value", "provider", "providerId", "guessProviderStateSelector", "_provider", "_value", "event", "createStore", "__name", "store", "createZustandStore", "api", "hubStore", "providersStore", "namespacesStore", "extend", "allowedMethods", "allowedPublicValues", "NamespaceBuilder", "__name", "#id", "#providerId", "#actions", "#actionBuilders", "#configs", "id", "providerId", "name", "value", "action", "actionFn", "actionFnForItem", "#isConfigsValid", "#buildApi", "_config", "#addHooksFromActionBuilders", "namespace", "actionByBuild", "afterHooks", "beforeHooks", "andHooks", "orHooks", "#addActionsFromActionBuilders", "configs", "Namespace", "_", "property", "targetValue", "ProviderBuilder", "__name", "#id", "#namespaces", "#methods", "#configs", "#options", "id", "options", "namespace", "name", "value", "cb", "#isConfigsValid", "Provider", "config", "ActionBuilder", "__name", "#and", "#or", "#after", "#before", "#action", "name", "action", "CAIP", "pickVersion", "list", "targetVersion", "target", "version", "__name", "defineVersions", "versions", "api", "semver", "value"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var m=Object.defineProperty;var r=(t,e)=>m(t,"name",{value:e,configurable:!0});var f=(t,e)=>{for(var o in e)m(t,o,{get:e[o],enumerable:!0})};var h={};f(h,{disconnect:()=>s,recommended:()=>S});function s(t){let[,e]=t.state();e("network",null),e("accounts",null),e("connected",!1),e("connecting",!1)}r(s,"disconnect");var S=[["disconnect",s]];var y={};f(y,{disconnect:()=>A});import{createStore as ke}from"zustand/vanilla";import{produce as me}from"immer";import{produce as
|
|
1
|
+
var m=Object.defineProperty;var r=(t,e)=>m(t,"name",{value:e,configurable:!0});var f=(t,e)=>{for(var o in e)m(t,o,{get:e[o],enumerable:!0})};var h={};f(h,{disconnect:()=>s,recommended:()=>S});function s(t){let[,e]=t.state();e("network",null),e("accounts",null),e("connected",!1),e("connecting",!1)}r(s,"disconnect");var S=[["disconnect",s]];var y={};f(y,{disconnect:()=>A});import{createStore as ke}from"zustand/vanilla";import{produce as me}from"immer";import{produce as xe}from"immer";var n=class{static{r(this,"ActionBuilder")}name;#e=new Map;#t=new Map;#r=new Map;#o=new Map;#n;constructor(e){this.name=e}and(e){return this.#e.has(this.name)||this.#e.set(this.name,[]),this.#e.get(this.name)?.push(e),this}or(e){return this.#t.has(this.name)||this.#t.set(this.name,[]),this.#t.get(this.name)?.push(e),this}before(e){return this.#o.has(this.name)||this.#o.set(this.name,[]),this.#o.get(this.name)?.push(e),this}after(e){return this.#r.has(this.name)||this.#r.set(this.name,[]),this.#r.get(this.name)?.push(e),this}action(e){return this.#n=e,this}build(){if(!this.#n)throw new Error("Your action builder should includes an action.");return{actionName:this.name,action:this.#n,before:this.#o,after:this.#r,and:this.#e,or:this.#t}}};import*as st from"caip";var A=r(()=>new n("disconnect").action(s),"disconnect");function d(t){if(t instanceof Error)throw t;let e;typeof t=="object"&&t!==null&&"message"in t&&typeof t.message=="string"?e=t.message:typeof t=="string"?e=t:e=String(t);let o=new Error(e);throw typeof t=="object"&&t!==null&&("code"in t&&(o.code=t.code),"data"in t&&(o.data=t.data)),o}r(d,"parseErrorAndThrowStandardizeError");function E(t,e){d(e)}r(E,"standardizeAndThrowError");function x(t){let[,e]=t.state();e("connecting",!1)}r(x,"intoConnectionFinished");var N=[["connect",x]];import{AccountId as k}from"caip";function u(t){try{return k.parse(t),!0}catch{return!1}}r(u,"isValidCaipAddress");function T(t,e){if(!e.every(u))throw new Error(`Your provider should format account addresses in CAIP-10 format. Your provided accounts: ${e}`);let[,o]=t.state();return o("accounts",e),o("connected",!0),e}r(T,"connectAndUpdateStateForSingleNetwork");function I(t,e){if(!e.accounts.every(u))throw new Error(`Your provider should format account addresses in CAIP-10 format. Your provided accounts: ${e.accounts}`);let[,o]=t.state();return o("accounts",e.accounts),o("network",e.network),o("connected",!0),e}r(I,"connectAndUpdateStateForMultiNetworks");var K=[];function g(t){let[,e]=t.state();e("connecting",!0)}r(g,"intoConnecting");var R=[["connect",g]];export{h as actions,N as afterRecommended,K as andRecommended,R as beforeRecommended,y as builders,I as connectAndUpdateStateForMultiNetworks,T as connectAndUpdateStateForSingleNetwork,g as intoConnecting,x as intoConnectionFinished,d as parseErrorAndThrowStandardizeError,E as standardizeAndThrowError};
|
|
2
2
|
//# sourceMappingURL=mod.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/namespaces/common/actions.ts", "../../../src/namespaces/common/builders.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/utils.ts", "../../../src/namespaces/common/or.ts", "../../../src/namespaces/common/after.ts", "../../../src/namespaces/common/helpers.ts", "../../../src/namespaces/common/and.ts", "../../../src/namespaces/common/before.ts"],
|
|
4
|
-
"sourcesContent": ["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", "import type { AutoImplementedActionsByRecommended } from './types.js';\nimport type { Actions } from '../../hub/namespaces/types.js';\n\nimport { ActionBuilder } from '../../mod.js';\n\nimport { disconnect as disconnectAction } from './actions.js';\n\nexport const disconnect = <\n T extends Actions<T> &\n Record<'disconnect', AutoImplementedActionsByRecommended['disconnect']>\n>() =>\n new ActionBuilder<AutoImplementedActionsByRecommended, 'disconnect'>(\n 'disconnect'\n ).action(disconnectAction) as unknown as ActionBuilder<T, 'disconnect'>;\n", "import type { StoreApi } from 'zustand/vanilla';\n\nimport { createStore as createZustandStore } from 'zustand/vanilla';\n\nimport { extend, type Store } from './extend.js';\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 RawStore = StoreApi<State>;\n\nexport const createStore = (): Store => {\n const store = createZustandStore<State>((...api) => {\n return {\n hub: hubStore(...api),\n providers: providersStore(...api),\n namespaces: namespacesStore(...api),\n };\n });\n\n return extend(store);\n};\n", "/************ Namespace ************/\n\nimport type { StateCreator } from 'zustand';\n\nimport { produce } from 'immer';\n\nimport {\n ConsumableEvents,\n type NamespaceConnectedEvent,\n type NamespaceDisconnectedEvent,\n type NamespaceSwitchedAccountEvent,\n type NamespaceSwitchedNetworkEvent,\n} from './events.js';\nimport { namespaceStateSelector, type State } from './mod.js';\n\n// Currently, namespace doesn't has any config.\nexport type NamespaceConfig = object;\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\ninterface NamespaceItem {\n info: NamespaceInfo;\n data: NamespaceData;\n error: unknown;\n}\n\ntype NamespaceState = {\n events: InstanceType<typeof ConsumableEvents>;\n list: Record<string, NamespaceItem>;\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\n _produceEventsWhenUpdatingStatus: <K extends keyof NamespaceData>(\n namespace: NamespaceItem,\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 events: new ConsumableEvents(),\n\n list: {},\n addNamespace: (id, info) => {\n const data: NamespaceData = {\n accounts: null,\n network: null,\n connected: false,\n connecting: false,\n };\n\n const item = {\n data,\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 const ns = get().namespaces.list[id];\n if (!ns) {\n throw new Error(`No namespace with '${id}' found.`);\n }\n\n get().namespaces._produceEventsWhenUpdatingStatus(ns, id, key, value);\n\n // Updating state\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 _produceEventsWhenUpdatingStatus: (namespace, id, key, value) => {\n if (key === 'accounts') {\n // check for both null and empty array\n const isAccountsEmpty =\n Object.is(value, null) || (Array.isArray(value) && value.length === 0);\n\n if (isAccountsEmpty) {\n const currentConnectedStatus = get().namespaces.list[id].data.connected;\n if (currentConnectedStatus) {\n const event: NamespaceDisconnectedEvent = {\n type: 'namespace_disconnected',\n provider: namespace.info.providerId,\n namespace: namespace.info.namespaceId,\n };\n\n get().namespaces.events.push(event);\n }\n // Skip emitting disconnect event, if the `connected` is false\n } else {\n const currentAccounts = get().namespaces.list[id].data.accounts;\n\n if (!currentAccounts) {\n const event: NamespaceConnectedEvent = {\n type: 'namespace_connected',\n provider: namespace.info.providerId,\n namespace: namespace.info.namespaceId,\n accounts: value as string[],\n };\n\n get().namespaces.events.push(event);\n } else {\n const areSameAccounts =\n currentAccounts.sort().toString() ===\n (value as string[]).sort().toString();\n\n if (!areSameAccounts) {\n const event: NamespaceSwitchedAccountEvent = {\n type: 'namespace_account_switched',\n provider: namespace.info.providerId,\n namespace: namespace.info.namespaceId,\n previousAccounts: currentAccounts,\n accounts: value as string[],\n };\n\n get().namespaces.events.push(event);\n }\n }\n }\n } else if (key === 'network') {\n const currentNetwork = get().namespaces.list[id].data.network;\n\n const event: NamespaceSwitchedNetworkEvent = {\n type: 'namespace_network_switched',\n provider: namespace.info.providerId,\n namespace: namespace.info.namespaceId,\n network: value as string,\n previousNetwork: currentNetwork,\n };\n\n get().namespaces.events.push(event);\n }\n },\n});\n\nexport { namespacesStore };\n", "import type { Namespace } from '../../namespaces/common/types.js';\nimport type {\n GenerateDeepLink,\n State as InternalProviderState,\n} from '../provider/mod.js';\nimport type { BlockchainMeta, SignerFactory } from 'rango-types';\nimport type { StateCreator } from 'zustand';\n\nimport { produce } from 'immer';\n\nimport { ConsumableEvents, type ProviderDetectedEvent } from './events.js';\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 };\n\ntype NamespacesProperty = Property<\n 'namespaces',\n {\n selection: 'single' | 'multiple';\n data: {\n label: string;\n id: string;\n value: Namespace;\n unsupported?: boolean;\n getSupportedChains: (chains: BlockchainMeta[]) => BlockchainMeta[];\n }[];\n }\n>;\ntype DerivationPathProperty = Property<\n 'derivationPath',\n {\n data: {\n id: string;\n label: string;\n namespace: Namespace;\n generateDerivationPath: (index: string) => string;\n }[];\n }\n>;\ntype DetailsProperty = Property<\n 'details',\n {\n mobileWallet?: boolean;\n showOnMobile?: boolean;\n isContractWallet?: boolean;\n }\n>;\ntype SignersProperty = Property<\n 'signers',\n {\n getSigners: () => Promise<SignerFactory>;\n }\n>;\n\nexport type ProviderMetadata = {\n name: string;\n icon: string;\n extensions: Partial<Record<Browsers, string>>;\n properties?: Array<\n | NamespacesProperty\n | DerivationPathProperty\n | DetailsProperty\n | SignersProperty\n >;\n};\n\nexport interface ProviderConfig {\n metadata: ProviderMetadata;\n deepLink?: GenerateDeepLink;\n}\n\nexport type ProviderInfo = ProviderConfig;\n\ninterface ProviderData {\n installed: boolean;\n}\n\ninterface ProviderItem {\n config: ProviderConfig;\n data: ProviderData;\n error: unknown;\n}\n\ntype ProviderState = {\n events: ConsumableEvents;\n list: Record<string, ProviderItem>;\n};\ninterface ProviderActions {\n addProvider: (id: string, config: ProviderConfig) => void;\n removeProvider: (id: string) => void;\n updateStatus: <K extends keyof ProviderData>(\n id: string,\n key: K,\n value: ProviderData[K]\n ) => void;\n\n _produceEventsWhenUpdatingStatus: <K extends keyof ProviderData>(\n provider: ProviderItem,\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 events: new ConsumableEvents(),\n\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 removeProvider: (id) => {\n set(\n produce((state: State) => {\n delete state.providers.list[id];\n })\n );\n },\n updateStatus: (id, key, value) => {\n const provider = get().providers.list[id];\n if (!provider) {\n throw new Error(`No namespace namespace with '${id}' found.`);\n }\n\n get().providers._produceEventsWhenUpdatingStatus(provider, id, key, value);\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 _produceEventsWhenUpdatingStatus: (_provider, id, key, _value) => {\n if (key === 'installed') {\n const event: ProviderDetectedEvent = {\n type: 'provider_detected',\n provider: id,\n };\n\n get().providers.events.push(event);\n }\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", "/**\n * Standardizes an unknown error into an Error object and throws it.\n * If the input is already an Error, it's thrown directly.\n * Otherwise, a new Error is created with the input's message or string representation.\n *\n * @param e - The unknown error object.\n * @throws {Error} - The standardized Error object.\n */\nexport function parseErrorAndThrowStandardizeError(e: unknown): never {\n if (e instanceof Error) {\n throw e;\n }\n\n let errorMessage: string;\n if (\n typeof e === 'object' &&\n e !== null &&\n 'message' in e &&\n typeof e.message === 'string'\n ) {\n errorMessage = e.message;\n } else if (typeof e === 'string') {\n errorMessage = e;\n } else {\n errorMessage = String(e);\n }\n\n const err = new Error(errorMessage) as Error & {\n code?: unknown;\n data?: unknown;\n };\n\n if (typeof e === 'object' && e !== null) {\n if ('code' in e) {\n err.code = e.code;\n }\n if ('data' in e) {\n err.data = e.data;\n }\n }\n\n throw err;\n}\n", "import type { Context } from '../../hub/namespaces/mod.js';\n\nimport { parseErrorAndThrowStandardizeError } from './utils.js';\n\n/**\n * Standardizes an unknown error into an Error object and throws it.\n * If the input is already an Error, it's thrown directly.\n * Otherwise, a new Error is created with the input's message or string representation.\n * Note: The parseErrorAndThrowStandardizeError function is defined as a separate function, so that it can be used independently.\n *\n * @param _context - The context.\n * @param e - The unknown error object.\n * @throws {Error} - The standardized Error object.\n */\nexport function standardizeAndThrowError(_context: Context, e: unknown): never {\n parseErrorAndThrowStandardizeError(e);\n}\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 { 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"],
|
|
4
|
+
"sourcesContent": ["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", "import type { AutoImplementedActionsByRecommended } from './types.js';\nimport type { Actions } from '../../hub/namespaces/types.js';\n\nimport { ActionBuilder } from '../../mod.js';\n\nimport { disconnect as disconnectAction } from './actions.js';\n\nexport const disconnect = <\n T extends Actions<T> &\n Record<'disconnect', AutoImplementedActionsByRecommended['disconnect']>\n>() =>\n new ActionBuilder<AutoImplementedActionsByRecommended, 'disconnect'>(\n 'disconnect'\n ).action(disconnectAction) as unknown as ActionBuilder<T, 'disconnect'>;\n", "import type { StoreApi } from 'zustand/vanilla';\n\nimport { createStore as createZustandStore } from 'zustand/vanilla';\n\nimport { extend, type Store } from './extend.js';\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 RawStore = StoreApi<State>;\n\nexport const createStore = (): Store => {\n const store = createZustandStore<State>((...api) => {\n return {\n hub: hubStore(...api),\n providers: providersStore(...api),\n namespaces: namespacesStore(...api),\n };\n });\n\n return extend(store);\n};\n", "/************ Namespace ************/\n\nimport type { StateCreator } from 'zustand';\n\nimport { produce } from 'immer';\n\nimport {\n ConsumableEvents,\n type NamespaceConnectedEvent,\n type NamespaceDisconnectedEvent,\n type NamespaceSwitchedAccountEvent,\n type NamespaceSwitchedNetworkEvent,\n} from './events.js';\nimport { namespaceStateSelector, type State } from './mod.js';\n\n// Currently, namespace doesn't has any config.\nexport type NamespaceConfig = object;\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\ninterface NamespaceItem {\n info: NamespaceInfo;\n data: NamespaceData;\n error: unknown;\n}\n\ntype NamespaceState = {\n events: InstanceType<typeof ConsumableEvents>;\n list: Record<string, NamespaceItem>;\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\n _produceEventsWhenUpdatingStatus: <K extends keyof NamespaceData>(\n namespace: NamespaceItem,\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 events: new ConsumableEvents(),\n\n list: {},\n addNamespace: (id, info) => {\n const data: NamespaceData = {\n accounts: null,\n network: null,\n connected: false,\n connecting: false,\n };\n\n const item = {\n data,\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 const ns = get().namespaces.list[id];\n if (!ns) {\n throw new Error(`No namespace with '${id}' found.`);\n }\n\n get().namespaces._produceEventsWhenUpdatingStatus(ns, id, key, value);\n\n // Updating state\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 _produceEventsWhenUpdatingStatus: (namespace, id, key, value) => {\n if (key === 'accounts') {\n // check for both null and empty array\n const isAccountsEmpty =\n Object.is(value, null) || (Array.isArray(value) && value.length === 0);\n\n if (isAccountsEmpty) {\n const currentConnectedStatus = get().namespaces.list[id].data.connected;\n if (currentConnectedStatus) {\n const event: NamespaceDisconnectedEvent = {\n type: 'namespace_disconnected',\n provider: namespace.info.providerId,\n namespace: namespace.info.namespaceId,\n };\n\n get().namespaces.events.push(event);\n }\n // Skip emitting disconnect event, if the `connected` is false\n } else {\n const currentAccounts = get().namespaces.list[id].data.accounts;\n\n if (!currentAccounts) {\n const event: NamespaceConnectedEvent = {\n type: 'namespace_connected',\n provider: namespace.info.providerId,\n namespace: namespace.info.namespaceId,\n accounts: value as string[],\n };\n\n get().namespaces.events.push(event);\n } else {\n const areSameAccounts =\n // Clone the object from the Zustand store, as it's immutable, to avoid errors during sorting.\n [...currentAccounts].sort().toString() ===\n (value as string[]).sort().toString();\n\n if (!areSameAccounts) {\n const event: NamespaceSwitchedAccountEvent = {\n type: 'namespace_account_switched',\n provider: namespace.info.providerId,\n namespace: namespace.info.namespaceId,\n previousAccounts: currentAccounts,\n accounts: value as string[],\n };\n\n get().namespaces.events.push(event);\n }\n }\n }\n } else if (key === 'network') {\n const currentNetwork = get().namespaces.list[id].data.network;\n\n const event: NamespaceSwitchedNetworkEvent = {\n type: 'namespace_network_switched',\n provider: namespace.info.providerId,\n namespace: namespace.info.namespaceId,\n network: value as string,\n previousNetwork: currentNetwork,\n };\n\n get().namespaces.events.push(event);\n }\n },\n});\n\nexport { namespacesStore };\n", "import type { Namespace } from '../../namespaces/common/types.js';\nimport type {\n GenerateDeepLink,\n State as InternalProviderState,\n} from '../provider/mod.js';\nimport type { BlockchainMeta, SignerFactory } from 'rango-types';\nimport type { StateCreator } from 'zustand';\n\nimport { produce } from 'immer';\n\nimport { ConsumableEvents, type ProviderDetectedEvent } from './events.js';\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 };\n\ntype NamespacesProperty = Property<\n 'namespaces',\n {\n selection: 'single' | 'multiple';\n data: {\n label: string;\n id: string;\n value: Namespace;\n unsupported?: boolean;\n getSupportedChains: (chains: BlockchainMeta[]) => BlockchainMeta[];\n }[];\n }\n>;\ntype DerivationPathProperty = Property<\n 'derivationPath',\n {\n data: {\n id: string;\n label: string;\n namespace: Namespace;\n generateDerivationPath: (index: string) => string;\n }[];\n }\n>;\ntype DetailsProperty = Property<\n 'details',\n {\n mobileWallet?: boolean;\n showOnMobile?: boolean;\n isContractWallet?: boolean;\n }\n>;\ntype SignersProperty = Property<\n 'signers',\n {\n getSigners: () => Promise<SignerFactory>;\n }\n>;\n\nexport type ProviderMetadata = {\n name: string;\n icon: string;\n extensions: Partial<Record<Browsers, string>>;\n properties?: Array<\n | NamespacesProperty\n | DerivationPathProperty\n | DetailsProperty\n | SignersProperty\n >;\n};\n\nexport interface ProviderConfig {\n metadata: ProviderMetadata;\n deepLink?: GenerateDeepLink;\n}\n\nexport type ProviderInfo = ProviderConfig;\n\ninterface ProviderData {\n installed: boolean;\n}\n\ninterface ProviderItem {\n config: ProviderConfig;\n data: ProviderData;\n error: unknown;\n}\n\ntype ProviderState = {\n events: ConsumableEvents;\n list: Record<string, ProviderItem>;\n};\ninterface ProviderActions {\n addProvider: (id: string, config: ProviderConfig) => void;\n removeProvider: (id: string) => void;\n updateStatus: <K extends keyof ProviderData>(\n id: string,\n key: K,\n value: ProviderData[K]\n ) => void;\n\n _produceEventsWhenUpdatingStatus: <K extends keyof ProviderData>(\n provider: ProviderItem,\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 events: new ConsumableEvents(),\n\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 removeProvider: (id) => {\n set(\n produce((state: State) => {\n delete state.providers.list[id];\n })\n );\n },\n updateStatus: (id, key, value) => {\n const provider = get().providers.list[id];\n if (!provider) {\n throw new Error(`No namespace namespace with '${id}' found.`);\n }\n\n get().providers._produceEventsWhenUpdatingStatus(provider, id, key, value);\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 _produceEventsWhenUpdatingStatus: (_provider, id, key, _value) => {\n if (key === 'installed') {\n const event: ProviderDetectedEvent = {\n type: 'provider_detected',\n provider: id,\n };\n\n get().providers.events.push(event);\n }\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", "/**\n * Standardizes an unknown error into an Error object and throws it.\n * If the input is already an Error, it's thrown directly.\n * Otherwise, a new Error is created with the input's message or string representation.\n *\n * @param e - The unknown error object.\n * @throws {Error} - The standardized Error object.\n */\nexport function parseErrorAndThrowStandardizeError(e: unknown): never {\n if (e instanceof Error) {\n throw e;\n }\n\n let errorMessage: string;\n if (\n typeof e === 'object' &&\n e !== null &&\n 'message' in e &&\n typeof e.message === 'string'\n ) {\n errorMessage = e.message;\n } else if (typeof e === 'string') {\n errorMessage = e;\n } else {\n errorMessage = String(e);\n }\n\n const err = new Error(errorMessage) as Error & {\n code?: unknown;\n data?: unknown;\n };\n\n if (typeof e === 'object' && e !== null) {\n if ('code' in e) {\n err.code = e.code;\n }\n if ('data' in e) {\n err.data = e.data;\n }\n }\n\n throw err;\n}\n", "import type { Context } from '../../hub/namespaces/mod.js';\n\nimport { parseErrorAndThrowStandardizeError } from './utils.js';\n\n/**\n * Standardizes an unknown error into an Error object and throws it.\n * If the input is already an Error, it's thrown directly.\n * Otherwise, a new Error is created with the input's message or string representation.\n * Note: The parseErrorAndThrowStandardizeError function is defined as a separate function, so that it can be used independently.\n *\n * @param _context - The context.\n * @param e - The unknown error object.\n * @throws {Error} - The standardized Error object.\n */\nexport function standardizeAndThrowError(_context: Context, e: unknown): never {\n parseErrorAndThrowStandardizeError(e);\n}\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 { 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"],
|
|
5
5
|
"mappings": "6IAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,EAAA,gBAAAC,IAEO,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O,EAChB,EACT,MAAQ,CACN,MAAO,EACT,CACF,CAPgBE,EAAAH,EAAA,sBCMT,SAASI,EACdC,EACAC,EACA,CACA,GAAI,CAACA,EAAS,MAAMC,CAAkB,EACpC,MAAM,IAAI,MACR,4FAA4FD,CAAQ,EACtG,EAGF,GAAM,CAAC,CAAEE,CAAQ,EAAIH,EAAQ,MAAM,EACnC,OAAAG,EAAS,WAAYF,CAAQ,EAC7BE,EAAS,YAAa,EAAI,EACnBF,CACT,CAdgBG,EAAAL,EAAA,yCAgBT,SAASM,EACdL,EACAC,EACA,CACA,GAAI,CAACA,EAAS,SAAS,MAAMC,CAAkB,EAC7C,MAAM,IAAI,MACR,4FAA4FD,EAAS,QAAQ,EAC/G,EAGF,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,EAAAC,EAAA,yCAiBT,IAAMC,EAAc,CAAC,ECvCrB,SAASC,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",
|
|
6
6
|
"names": ["actions_exports", "__export", "disconnect", "recommended", "disconnect", "context", "setState", "__name", "recommended", "builders_exports", "__export", "disconnect", "createZustandStore", "produce", "produce", "ActionBuilder", "__name", "#and", "#or", "#after", "#before", "#action", "name", "action", "CAIP", "disconnect", "__name", "ActionBuilder", "parseErrorAndThrowStandardizeError", "e", "errorMessage", "err", "__name", "standardizeAndThrowError", "_context", "parseErrorAndThrowStandardizeError", "__name", "intoConnectionFinished", "context", "setState", "__name", "recommended", "AccountId", "isValidCaipAddress", "address", "AccountId", "__name", "connectAndUpdateStateForSingleNetwork", "context", "accounts", "isValidCaipAddress", "setState", "__name", "connectAndUpdateStateForMultiNetworks", "recommended", "intoConnecting", "context", "setState", "__name", "recommended"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../src/namespaces/evm/actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAWlE,eAAO,MAAM,WAAW,+EAAyB,CAAC;AAClD,wBAAgB,OAAO,CACrB,QAAQ,EAAE,MAAM,WAAW,EAC3B,OAAO,CAAC,EAAE,cAAc,GACvB,mBAAmB,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../src/namespaces/evm/actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAWlE,eAAO,MAAM,WAAW,+EAAyB,CAAC;AAClD,wBAAgB,OAAO,CACrB,QAAQ,EAAE,MAAM,WAAW,EAC3B,OAAO,CAAC,EAAE,cAAc,GACvB,mBAAmB,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,CA8CrD;AAED,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,WAAW,GAAG,SAAS,GACtC,eAAe,CAAC,UAAU,CAAC,CAsB7B;AACD,wBAAgB,gBAAgB,IAAI,mBAAmB,CACrD,UAAU,CAAC,kBAAkB,CAAC,EAC9B,OAAO,CACR,CAKA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builders.d.ts","sourceRoot":"","sources":["../../../src/namespaces/evm/builders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"builders.d.ts","sourceRoot":"","sources":["../../../src/namespaces/evm/builders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,8BAA8B,EAAE,MAAM,4CAA4C,CAAC;AAU5F,eAAO,MAAM,OAAO,4CAIc,CAAC;AAEnC,eAAO,MAAM,eAAe,oDACyC,CAAC;AACtE,eAAO,MAAM,gBAAgB,qDAC0C,CAAC;AAGxE,eAAO,MAAM,uBAAuB,gBAAiB,MAAM,WAAW,qFAqBhE,CAAC"}
|