@rango-dev/wallets-core 0.58.2-next.4 → 0.59.1-next.0
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/CHANGELOG.md +11 -0
- package/dist/hub/provider/provider.d.ts +1 -1
- package/dist/hub/provider/types.d.ts +0 -2
- package/dist/hub/provider/types.d.ts.map +1 -1
- package/dist/legacy/mod.js +1 -1
- package/dist/legacy/mod.js.map +2 -2
- package/dist/legacy/types.d.ts +0 -31
- package/dist/legacy/types.d.ts.map +1 -1
- package/dist/mod.js.map +1 -1
- package/dist/namespaces/common/types.d.ts +1 -1
- package/dist/namespaces/common/types.d.ts.map +1 -1
- package/dist/namespaces/solana/mod.js +1 -1
- package/dist/namespaces/starknet/mod.js +1 -1
- package/dist/wallets-core.build.json +1 -1
- package/package.json +2 -7
- package/src/hub/provider/provider.ts +1 -1
- package/src/hub/provider/types.ts +0 -2
- package/src/legacy/types.ts +0 -31
- package/src/namespaces/common/types.ts +0 -1
- package/dist/namespaces/cosmos/actions.d.ts +0 -2
- package/dist/namespaces/cosmos/actions.d.ts.map +0 -1
- package/dist/namespaces/cosmos/after.d.ts +0 -2
- package/dist/namespaces/cosmos/after.d.ts.map +0 -1
- package/dist/namespaces/cosmos/and.d.ts +0 -3
- package/dist/namespaces/cosmos/and.d.ts.map +0 -1
- package/dist/namespaces/cosmos/before.d.ts +0 -2
- package/dist/namespaces/cosmos/before.d.ts.map +0 -1
- package/dist/namespaces/cosmos/builders.d.ts +0 -4
- package/dist/namespaces/cosmos/builders.d.ts.map +0 -1
- package/dist/namespaces/cosmos/constants.d.ts +0 -2
- package/dist/namespaces/cosmos/constants.d.ts.map +0 -1
- package/dist/namespaces/cosmos/mod.d.ts +0 -9
- package/dist/namespaces/cosmos/mod.d.ts.map +0 -1
- package/dist/namespaces/cosmos/mod.js +0 -2
- package/dist/namespaces/cosmos/mod.js.map +0 -7
- package/dist/namespaces/cosmos/types.d.ts +0 -23
- package/dist/namespaces/cosmos/types.d.ts.map +0 -1
- package/dist/namespaces/cosmos/utils.d.ts +0 -3
- package/dist/namespaces/cosmos/utils.d.ts.map +0 -1
- package/src/namespaces/cosmos/actions.ts +0 -3
- package/src/namespaces/cosmos/after.ts +0 -3
- package/src/namespaces/cosmos/and.ts +0 -5
- package/src/namespaces/cosmos/before.ts +0 -3
- package/src/namespaces/cosmos/builders.ts +0 -15
- package/src/namespaces/cosmos/constants.ts +0 -1
- package/src/namespaces/cosmos/mod.ts +0 -15
- package/src/namespaces/cosmos/types.ts +0 -32
- package/src/namespaces/cosmos/utils.ts +0 -21
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export type { CosmosActions, ProviderAPI, CosmosChain, CosmosAssetList, CosmosChainAccounts, } from './types.js';
|
|
2
|
-
export * as actions from './actions.js';
|
|
3
|
-
export * as after from './after.js';
|
|
4
|
-
export * as and from './and.js';
|
|
5
|
-
export * as before from './before.js';
|
|
6
|
-
export * as utils from './utils.js';
|
|
7
|
-
export * as builders from './builders.js';
|
|
8
|
-
export { CAIP_NAMESPACE } from './constants.js';
|
|
9
|
-
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/namespaces/cosmos/mod.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,aAAa,EACb,WAAW,EACX,WAAW,EACX,eAAe,EACf,mBAAmB,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var g=Object.defineProperty;var t=(o,e)=>g(o,"name",{value:e,configurable:!0});var s=(o,e)=>{for(var r in e)g(o,r,{get:e[r],enumerable:!0})};var A={};s(A,{recommended:()=>I});function x(o){let[,e]=o.state();e("network",null),e("accounts",null),e("connected",!1),e("connecting",!1),e("connectArgs",null)}t(x,"disconnect");var S=[["disconnect",x]];var I=[...S];var b={};s(b,{recommended:()=>R});function i(o){let[,e]=o.state();e("connecting",!1)}t(i,"intoConnectionFinished");var p=[["connect",i]];var R=[...p];var w={};s(w,{recommended:()=>M});import{createStore as Le}from"zustand/vanilla";import{produce as Ne}from"immer";import{produce as Fe}from"immer";var n=class{static{t(this,"ActionBuilder")}name;#e=new Map;#t=new Map;#o=new Map;#r=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.#r.has(this.name)||this.#r.set(this.name,[]),this.#r.get(this.name)?.push(e),this}after(e){return this.#o.has(this.name)||this.#o.set(this.name,[]),this.#o.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.#r,after:this.#o,and:this.#e,or:this.#t}}};import*as St from"caip";import{AccountId as V}from"caip";function f(o){try{return V.parse(o),!0}catch{return!1}}t(f,"isValidCaipAddress");function h(o,e){if(!e.every(f))throw new Error(`Your provider should format account addresses in CAIP-10 format. Your provided accounts: ${e}`);let[,r]=o.state();return r("accounts",e),r("connected",!0),e}t(h,"connectAndUpdateStateForSingleNetwork");function l(o,e){if(!e.accounts.every(f))throw new Error(`Your provider should format account addresses in CAIP-10 format. Your provided accounts: ${e.accounts}`);let[,r]=o.state();return r("accounts",e.accounts),r("network",e.network),r("connected",!0),e}t(l,"connectAndUpdateStateForMultiNetworks");function c(o){let[,e]=o.state();e("connecting",!0)}t(c,"intoConnecting");var v=[["connect",c]];var M=[["connect",l]];var E={};s(E,{recommended:()=>W});var W=[...v];var N={};s(N,{formatAccountsToCAIP:()=>B});import{AccountId as H}from"caip";var y="cosmos";function B(o){return o.flatMap(e=>e.accounts.map(r=>H.format({address:r,chainId:{namespace:y,reference:e.chainId}})))}t(B,"formatAccountsToCAIP");var T={};s(T,{connect:()=>L});var L=t(()=>new n("connect").and(h).before(c).after(i),"connect");export{y as CAIP_NAMESPACE,A as actions,b as after,w as and,E as before,T as builders,N as utils};
|
|
2
|
-
//# sourceMappingURL=mod.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/namespaces/cosmos/actions.ts", "../../../src/namespaces/common/actions.ts", "../../../src/namespaces/cosmos/after.ts", "../../../src/namespaces/common/after.ts", "../../../src/namespaces/cosmos/and.ts", "../../../src/hub/store/store.ts", "../../../src/hub/store/namespaces.ts", "../../../src/hub/store/providers.ts", "../../../src/builders/action.ts", "../../../src/utils/mod.ts", "../../../src/namespaces/common/helpers.ts", "../../../src/namespaces/common/and.ts", "../../../src/namespaces/common/before.ts", "../../../src/namespaces/cosmos/before.ts", "../../../src/namespaces/cosmos/utils.ts", "../../../src/namespaces/cosmos/constants.ts", "../../../src/namespaces/cosmos/builders.ts"],
|
|
4
|
-
"sourcesContent": ["import { recommended as commonRecommended } from '../common/actions.js';\n\nexport const recommended = [...commonRecommended];\n", "import type { Context } from '../../hub/namespaces/mod.js';\n\nexport function disconnect(context: Context): void {\n const [, setState] = context.state();\n setState('network', null);\n setState('accounts', null);\n setState('connected', false);\n setState('connecting', false);\n setState('connectArgs', null);\n}\n\nexport const recommended = [['disconnect', disconnect] as const];\n", "import { recommended as commonRecommended } from '../common/after.js';\n\nexport const recommended = [...commonRecommended];\n", "import type { Context } from '../../hub/namespaces/mod.js';\n\nexport function intoConnectionFinished(context: Context) {\n const [, setState] = context.state();\n setState('connecting', false);\n}\n\nexport const recommended = [['connect', intoConnectionFinished] as const];\n", "import { connectAndUpdateStateForMultiNetworks } from '../common/mod.js';\n\nexport const recommended = [\n ['connect', connectAndUpdateStateForMultiNetworks] as const,\n];\n", "import type { StoreApi } from 'zustand/vanilla';\n\nimport { createStore as createZustandStore } from 'zustand/vanilla';\n\nimport { 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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n connectArgs: Record<string, any> | null;\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 connectArgs: null,\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 { State as InternalProviderState } 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}\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", "import { AccountId } from 'caip';\n\nexport function isValidCaipAddress(address: string): boolean {\n try {\n AccountId.parse(address);\n return true;\n } catch {\n return false;\n }\n}\n", "import type {\n Accounts,\n AccountsWithActiveChain,\n} from './../../types/accounts.js';\nimport type { Context } from '../../hub/namespaces/mod.js';\n\nimport { isValidCaipAddress } from './helpers.js';\n\nexport function connectAndUpdateStateForSingleNetwork(\n context: Context,\n accounts: Accounts\n) {\n if (!accounts.every(isValidCaipAddress)) {\n throw new Error(\n `Your provider should format account addresses in CAIP-10 format. Your provided accounts: ${accounts}`\n );\n }\n\n const [, setState] = context.state();\n setState('accounts', accounts);\n setState('connected', true);\n return accounts;\n}\n\nexport function connectAndUpdateStateForMultiNetworks(\n context: Context,\n accounts: AccountsWithActiveChain\n) {\n if (!accounts.accounts.every(isValidCaipAddress)) {\n throw new Error(\n `Your provider should format account addresses in CAIP-10 format. Your provided accounts: ${accounts.accounts}`\n );\n }\n\n const [, setState] = context.state();\n setState('accounts', accounts.accounts);\n setState('network', accounts.network);\n setState('connected', true);\n return accounts;\n}\n\nexport const recommended = [];\n", "import type { Context } from '../../hub/namespaces/mod.js';\n\nexport function intoConnecting(context: Context) {\n const [, setState] = context.state();\n setState('connecting', true);\n}\n\n// Please consider if you are going to add something here, make sure it works on all namespaces.\nexport const recommended = [['connect', intoConnecting] as const];\n", "import { beforeRecommended } from '../common/mod.js';\n\nexport const recommended = [...beforeRecommended];\n", "import type { CosmosChainAccounts } from './types.js';\nimport type { CaipAccount } from '../common/mod.js';\n\nimport { AccountId } from 'caip';\n\nimport { CAIP_NAMESPACE } from './constants.js';\n\nexport function formatAccountsToCAIP(accounts: CosmosChainAccounts[]) {\n return accounts.flatMap((networkAccounts) =>\n networkAccounts.accounts.map(\n (networkAccount) =>\n AccountId.format({\n address: networkAccount,\n chainId: {\n namespace: CAIP_NAMESPACE,\n reference: networkAccounts.chainId,\n },\n }) as CaipAccount\n )\n );\n}\n", "export const CAIP_NAMESPACE = 'cosmos';\n", "import type { CosmosActions } from './types.js';\n\nimport { ActionBuilder } from '../../mod.js';\nimport {\n connectAndUpdateStateForSingleNetwork,\n intoConnecting,\n intoConnectionFinished,\n} from '../common/mod.js';\n\n// Actions\nexport const connect = () =>\n new ActionBuilder<CosmosActions, 'connect'>('connect')\n .and(connectAndUpdateStateForSingleNetwork)\n .before(intoConnecting)\n .after(intoConnectionFinished);\n"],
|
|
5
|
-
"mappings": "6IAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,ICEO,SAASC,EAAWC,EAAwB,CACjD,GAAM,CAAC,CAAEC,CAAQ,EAAID,EAAQ,MAAM,EACnCC,EAAS,UAAW,IAAI,EACxBA,EAAS,WAAY,IAAI,EACzBA,EAAS,YAAa,EAAK,EAC3BA,EAAS,aAAc,EAAK,EAC5BA,EAAS,cAAe,IAAI,CAC9B,CAPgBC,EAAAH,EAAA,cAST,IAAMI,EAAc,CAAC,CAAC,aAAcJ,CAAU,CAAU,EDTxD,IAAMK,EAAc,CAAC,GAAGA,CAAiB,EEFhD,IAAAC,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,ICEO,SAASC,EAAuBC,EAAkB,CACvD,GAAM,CAAC,CAAEC,CAAQ,EAAID,EAAQ,MAAM,EACnCC,EAAS,aAAc,EAAK,CAC9B,CAHgBC,EAAAH,EAAA,0BAKT,IAAMI,EAAc,CAAC,CAAC,UAAWJ,CAAsB,CAAU,EDLjE,IAAMK,EAAc,CAAC,GAAGA,CAAiB,EEFhD,IAAAC,EAA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MAAiB,OCHnB,IAAMC,EAAiB,SDOvB,SAASC,EAAqBC,EAAiC,CACpE,OAAOA,EAAS,QAASC,GACvBA,EAAgB,SAAS,IACtBC,GACCC,EAAU,OAAO,CACf,QAASD,EACT,QAAS,CACP,UAAWE,EACX,UAAWH,EAAgB,OAC7B,CACF,CAAC,CACL,CACF,CACF,CAbgBI,EAAAN,EAAA,wBEPhB,IAAAO,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAUO,IAAMC,EAAUC,EAAA,IACrB,IAAIC,EAAwC,SAAS,EAClD,IAAIC,CAAqC,EACzC,OAAOC,CAAc,EACrB,MAAMC,CAAsB,EAJV",
|
|
6
|
-
"names": ["actions_exports", "__export", "recommended", "disconnect", "context", "setState", "__name", "recommended", "recommended", "after_exports", "__export", "recommended", "intoConnectionFinished", "context", "setState", "__name", "recommended", "recommended", "and_exports", "__export", "recommended", "createZustandStore", "produce", "produce", "ActionBuilder", "__name", "#and", "#or", "#after", "#before", "#action", "name", "action", "CAIP", "AccountId", "isValidCaipAddress", "address", "AccountId", "__name", "connectAndUpdateStateForSingleNetwork", "context", "accounts", "isValidCaipAddress", "setState", "__name", "connectAndUpdateStateForMultiNetworks", "intoConnecting", "context", "setState", "__name", "recommended", "recommended", "connectAndUpdateStateForMultiNetworks", "before_exports", "__export", "recommended", "recommended", "utils_exports", "__export", "formatAccountsToCAIP", "AccountId", "CAIP_NAMESPACE", "formatAccountsToCAIP", "accounts", "networkAccounts", "networkAccount", "AccountId", "CAIP_NAMESPACE", "__name", "builders_exports", "__export", "connect", "connect", "__name", "ActionBuilder", "connectAndUpdateStateForSingleNetwork", "intoConnecting", "intoConnectionFinished"]
|
|
7
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { Accounts } from '../common/mod.js';
|
|
2
|
-
import type { AutoImplementedActionsByRecommended, CommonActions } from '../common/types.js';
|
|
3
|
-
import { type AssetList, type Chain } from '@chain-registry/types';
|
|
4
|
-
export type CosmosChain = Chain;
|
|
5
|
-
export type CosmosAssetList = AssetList;
|
|
6
|
-
export interface CosmosActions extends AutoImplementedActionsByRecommended, CommonActions {
|
|
7
|
-
connect: (options?: ConnectOptions) => Promise<Accounts>;
|
|
8
|
-
suggest: (chain: CosmosChain, assetList: AssetList) => Promise<void>;
|
|
9
|
-
canEagerConnect: () => Promise<boolean>;
|
|
10
|
-
}
|
|
11
|
-
export type ProviderAPI = Record<string, any>;
|
|
12
|
-
export type CosmosChainAccounts = {
|
|
13
|
-
accounts: string[];
|
|
14
|
-
chainId: string;
|
|
15
|
-
};
|
|
16
|
-
export type ConnectOptions = {
|
|
17
|
-
chainIds: string[];
|
|
18
|
-
/**
|
|
19
|
-
* For chains that may not be natively supported by the provider.
|
|
20
|
-
*/
|
|
21
|
-
customChainIds?: string[];
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/namespaces/cosmos/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EACV,mCAAmC,EACnC,aAAa,EACd,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC;AAChC,MAAM,MAAM,eAAe,GAAG,SAAS,CAAC;AACxC,MAAM,WAAW,aACf,SAAQ,mCAAmC,EACzC,aAAa;IACf,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,cAAc,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACzD,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrE,eAAe,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CACzC;AAGD,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAC9C,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/namespaces/cosmos/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAOtD,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,mBAAmB,EAAE,qCAanE"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { CosmosActions } from './types.js';
|
|
2
|
-
|
|
3
|
-
import { ActionBuilder } from '../../mod.js';
|
|
4
|
-
import {
|
|
5
|
-
connectAndUpdateStateForSingleNetwork,
|
|
6
|
-
intoConnecting,
|
|
7
|
-
intoConnectionFinished,
|
|
8
|
-
} from '../common/mod.js';
|
|
9
|
-
|
|
10
|
-
// Actions
|
|
11
|
-
export const connect = () =>
|
|
12
|
-
new ActionBuilder<CosmosActions, 'connect'>('connect')
|
|
13
|
-
.and(connectAndUpdateStateForSingleNetwork)
|
|
14
|
-
.before(intoConnecting)
|
|
15
|
-
.after(intoConnectionFinished);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const CAIP_NAMESPACE = 'cosmos';
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
CosmosActions,
|
|
3
|
-
ProviderAPI,
|
|
4
|
-
CosmosChain,
|
|
5
|
-
CosmosAssetList,
|
|
6
|
-
CosmosChainAccounts,
|
|
7
|
-
} from './types.js';
|
|
8
|
-
export * as actions from './actions.js';
|
|
9
|
-
export * as after from './after.js';
|
|
10
|
-
export * as and from './and.js';
|
|
11
|
-
export * as before from './before.js';
|
|
12
|
-
export * as utils from './utils.js';
|
|
13
|
-
export * as builders from './builders.js';
|
|
14
|
-
|
|
15
|
-
export { CAIP_NAMESPACE } from './constants.js';
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { Accounts } from '../common/mod.js';
|
|
2
|
-
import type {
|
|
3
|
-
AutoImplementedActionsByRecommended,
|
|
4
|
-
CommonActions,
|
|
5
|
-
} from '../common/types.js';
|
|
6
|
-
|
|
7
|
-
import { type AssetList, type Chain } from '@chain-registry/types';
|
|
8
|
-
|
|
9
|
-
export type CosmosChain = Chain;
|
|
10
|
-
export type CosmosAssetList = AssetList;
|
|
11
|
-
export interface CosmosActions
|
|
12
|
-
extends AutoImplementedActionsByRecommended,
|
|
13
|
-
CommonActions {
|
|
14
|
-
connect: (options?: ConnectOptions) => Promise<Accounts>;
|
|
15
|
-
suggest: (chain: CosmosChain, assetList: AssetList) => Promise<void>;
|
|
16
|
-
canEagerConnect: () => Promise<boolean>;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
-
export type ProviderAPI = Record<string, any>;
|
|
21
|
-
export type CosmosChainAccounts = {
|
|
22
|
-
accounts: string[];
|
|
23
|
-
chainId: string;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export type ConnectOptions = {
|
|
27
|
-
chainIds: string[];
|
|
28
|
-
/**
|
|
29
|
-
* For chains that may not be natively supported by the provider.
|
|
30
|
-
*/
|
|
31
|
-
customChainIds?: string[];
|
|
32
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { CosmosChainAccounts } from './types.js';
|
|
2
|
-
import type { CaipAccount } from '../common/mod.js';
|
|
3
|
-
|
|
4
|
-
import { AccountId } from 'caip';
|
|
5
|
-
|
|
6
|
-
import { CAIP_NAMESPACE } from './constants.js';
|
|
7
|
-
|
|
8
|
-
export function formatAccountsToCAIP(accounts: CosmosChainAccounts[]) {
|
|
9
|
-
return accounts.flatMap((networkAccounts) =>
|
|
10
|
-
networkAccounts.accounts.map(
|
|
11
|
-
(networkAccount) =>
|
|
12
|
-
AccountId.format({
|
|
13
|
-
address: networkAccount,
|
|
14
|
-
chainId: {
|
|
15
|
-
namespace: CAIP_NAMESPACE,
|
|
16
|
-
reference: networkAccounts.chainId,
|
|
17
|
-
},
|
|
18
|
-
}) as CaipAccount
|
|
19
|
-
)
|
|
20
|
-
);
|
|
21
|
-
}
|