@rango-dev/wallets-core 0.58.1-next.0 → 0.58.2-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 +4 -0
- package/dist/hub/hub.d.ts +10 -2
- package/dist/hub/hub.d.ts.map +1 -1
- package/dist/hub/provider/provider.d.ts +1 -1
- package/dist/hub/provider/provider.d.ts.map +1 -1
- package/dist/hub/provider/types.d.ts +2 -0
- 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 +1 -0
- package/dist/legacy/types.d.ts.map +1 -1
- package/dist/mod.js +1 -1
- package/dist/mod.js.map +3 -3
- package/dist/namespaces/common/mod.js +1 -1
- package/dist/namespaces/cosmos/mod.js +1 -1
- package/dist/namespaces/evm/mod.js +1 -1
- package/dist/namespaces/solana/mod.js +1 -1
- package/dist/namespaces/starknet/mod.js +1 -1
- package/dist/namespaces/sui/mod.js +1 -1
- package/dist/namespaces/ton/builders.d.ts +5 -0
- package/dist/namespaces/ton/builders.d.ts.map +1 -0
- package/dist/namespaces/ton/constants.d.ts +3 -0
- package/dist/namespaces/ton/constants.d.ts.map +1 -0
- package/dist/namespaces/ton/mod.d.ts +5 -0
- package/dist/namespaces/ton/mod.d.ts.map +1 -0
- package/dist/namespaces/ton/mod.js +2 -0
- package/dist/namespaces/ton/mod.js.map +7 -0
- package/dist/namespaces/ton/types.d.ts +7 -0
- package/dist/namespaces/ton/types.d.ts.map +1 -0
- package/dist/namespaces/ton/utils.d.ts +2 -0
- package/dist/namespaces/ton/utils.d.ts.map +1 -0
- package/dist/namespaces/tron/mod.js +1 -1
- package/dist/namespaces/utxo/constants.d.ts +1 -0
- package/dist/namespaces/utxo/constants.d.ts.map +1 -1
- package/dist/namespaces/utxo/mod.d.ts +1 -1
- package/dist/namespaces/utxo/mod.d.ts.map +1 -1
- package/dist/namespaces/utxo/mod.js +1 -1
- package/dist/namespaces/utxo/mod.js.map +3 -3
- package/dist/namespaces/utxo/utils.d.ts +1 -1
- package/dist/namespaces/utxo/utils.d.ts.map +1 -1
- package/dist/namespaces/xrpl/mod.js +1 -1
- package/dist/wallets-core.build.json +1 -1
- package/package.json +7 -3
- package/src/hub/hub.ts +19 -5
- package/src/hub/provider/provider.ts +2 -2
- package/src/hub/provider/types.ts +2 -0
- package/src/legacy/types.ts +1 -0
- package/src/namespaces/ton/builders.ts +15 -0
- package/src/namespaces/ton/constants.ts +2 -0
- package/src/namespaces/ton/mod.ts +5 -0
- package/src/namespaces/ton/types.ts +12 -0
- package/src/namespaces/ton/utils.ts +18 -0
- package/src/namespaces/utxo/constants.ts +1 -0
- package/src/namespaces/utxo/mod.ts +5 -1
- package/src/namespaces/utxo/utils.ts +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builders.d.ts","sourceRoot":"","sources":["../../../src/namespaces/ton/builders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAKzD,eAAO,MAAM,OAAO,4CAIc,CAAC;AAEnC,eAAO,MAAM,eAAe,oDACyC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/namespaces/ton/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,QAAQ,CAAC;AACpC,eAAO,MAAM,iBAAiB,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/namespaces/ton/mod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAE1C,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var c=Object.defineProperty;var e=(n,t)=>c(n,"name",{value:t,configurable:!0});var a=(n,t)=>{for(var o in t)c(n,o,{get:t[o],enumerable:!0})};var p={};a(p,{formatAccountsToCAIP:()=>A});import{AccountId as C}from"caip";var i="tvm",s="-239";function A(n){return n.map(t=>C.format({address:t.toString(),chainId:{namespace:i,reference:s}}))}e(A,"formatAccountsToCAIP");var f={};a(f,{canEagerConnect:()=>y,connect:()=>T});var r=class{static{e(this,"ActionBuilder")}name;#t=new Map;#e=new Map;#n=new Map;#o=new Map;#r;constructor(t){this.name=t}and(t){return this.#t.has(this.name)||this.#t.set(this.name,[]),this.#t.get(this.name)?.push(t),this}or(t){return this.#e.has(this.name)||this.#e.set(this.name,[]),this.#e.get(this.name)?.push(t),this}before(t){return this.#o.has(this.name)||this.#o.set(this.name,[]),this.#o.get(this.name)?.push(t),this}after(t){return this.#n.has(this.name)||this.#n.set(this.name,[]),this.#n.get(this.name)?.push(t),this}action(t){return this.#r=t,this}build(){if(!this.#r)throw new Error("Your action builder should includes an action.");return{actionName:this.name,action:this.#r,before:this.#o,after:this.#n,and:this.#t,or:this.#e}}};function u(n){let[,t]=n.state();t("connecting",!1)}e(u,"intoConnectionFinished");import{AccountId as x}from"caip";function m(n){try{return x.parse(n),!0}catch{return!1}}e(m,"isValidCaipAddress");function h(n,t){if(!t.every(m))throw new Error(`Your provider should format account addresses in CAIP-10 format. Your provided accounts: ${t}`);let[,o]=n.state();return o("accounts",t),o("connected",!0),t}e(h,"connectAndUpdateStateForSingleNetwork");function d(n){let[,t]=n.state();t("connecting",!0)}e(d,"intoConnecting");var T=e(()=>new r("connect").and(h).before(d).after(u),"connect"),y=e(()=>new r("canEagerConnect"),"canEagerConnect");export{i as CAIP_NAMESPACE,s as CAIP_TON_CHAIN_ID,f as builders,p as utils};
|
|
2
|
+
//# sourceMappingURL=mod.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/namespaces/ton/utils.ts", "../../../src/namespaces/ton/constants.ts", "../../../src/namespaces/ton/builders.ts", "../../../src/builders/action.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 { CaipAccount } from '../../types/accounts.js';\n\nimport { AccountId } from 'caip';\n\nimport { CAIP_NAMESPACE, CAIP_TON_CHAIN_ID } from './constants.js';\n\nexport function formatAccountsToCAIP(accounts: string[]) {\n return accounts.map(\n (account) =>\n AccountId.format({\n address: account.toString(),\n chainId: {\n namespace: CAIP_NAMESPACE,\n reference: CAIP_TON_CHAIN_ID,\n },\n }) as CaipAccount\n );\n}\n", "export const CAIP_NAMESPACE = 'tvm';\nexport const CAIP_TON_CHAIN_ID = '-239';\n", "import type { TonActions } from './types.js';\n\nimport { ActionBuilder } from '../../builders/action.js';\nimport { intoConnectionFinished } from '../common/after.js';\nimport { connectAndUpdateStateForSingleNetwork } from '../common/and.js';\nimport { intoConnecting } from '../common/before.js';\n\nexport const connect = () =>\n new ActionBuilder<TonActions, 'connect'>('connect')\n .and(connectAndUpdateStateForSingleNetwork)\n .before(intoConnecting)\n .after(intoConnectionFinished);\n\nexport const canEagerConnect = () =>\n new ActionBuilder<TonActions, 'canEagerConnect'>('canEagerConnect');\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", "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
|
+
"mappings": "6IAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAEA,OAAS,aAAAC,MAAiB,OCFnB,IAAMC,EAAiB,MACjBC,EAAoB,ODK1B,SAASC,EAAqBC,EAAoB,CACvD,OAAOA,EAAS,IACbC,GACCC,EAAU,OAAO,CACf,QAASD,EAAQ,SAAS,EAC1B,QAAS,CACP,UAAWE,EACX,UAAWC,CACb,CACF,CAAC,CACL,CACF,CAXgBC,EAAAN,EAAA,wBENhB,IAAAO,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,EAAA,YAAAC,ICsBO,IAAMC,EAAN,KAA6D,CAtBpE,MAsBoE,CAAAC,EAAA,sBACzD,KACTC,GAAqB,IAAI,IACzBC,GAAoB,IAAI,IACxBC,GAAuB,IAAI,IAC3BC,GAAwB,IAAI,IAC5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,EAA0B,CAC3D,GAAI,CACF,OAAAC,EAAU,MAAMD,CAAO,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,yCCNT,SAASM,EAAeC,EAAkB,CAC/C,GAAM,CAAC,CAAEC,CAAQ,EAAID,EAAQ,MAAM,EACnCC,EAAS,aAAc,EAAI,CAC7B,CAHgBC,EAAAH,EAAA,kBLKT,IAAMI,EAAUC,EAAA,IACrB,IAAIC,EAAqC,SAAS,EAC/C,IAAIC,CAAqC,EACzC,OAAOC,CAAc,EACrB,MAAMC,CAAsB,EAJV,WAMVC,EAAkBL,EAAA,IAC7B,IAAIC,EAA6C,iBAAiB,EADrC",
|
|
6
|
+
"names": ["utils_exports", "__export", "formatAccountsToCAIP", "AccountId", "CAIP_NAMESPACE", "CAIP_TON_CHAIN_ID", "formatAccountsToCAIP", "accounts", "account", "AccountId", "CAIP_NAMESPACE", "CAIP_TON_CHAIN_ID", "__name", "builders_exports", "__export", "canEagerConnect", "connect", "ActionBuilder", "__name", "#and", "#or", "#after", "#before", "#action", "name", "action", "intoConnectionFinished", "context", "setState", "__name", "AccountId", "isValidCaipAddress", "address", "AccountId", "__name", "connectAndUpdateStateForSingleNetwork", "context", "accounts", "isValidCaipAddress", "setState", "__name", "intoConnecting", "context", "setState", "__name", "connect", "__name", "ActionBuilder", "connectAndUpdateStateForSingleNetwork", "intoConnecting", "intoConnectionFinished", "canEagerConnect"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Accounts } from '../../types/accounts.js';
|
|
2
|
+
import type { AutoImplementedActionsByRecommended, CommonActions } from '../common/types.js';
|
|
3
|
+
export interface TonActions extends AutoImplementedActionsByRecommended, CommonActions {
|
|
4
|
+
connect: () => Promise<Accounts>;
|
|
5
|
+
canEagerConnect: () => Promise<boolean>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/namespaces/ton/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EACV,mCAAmC,EACnC,aAAa,EACd,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,UACf,SAAQ,mCAAmC,EACzC,aAAa;IACf,OAAO,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjC,eAAe,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CACzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/namespaces/ton/utils.ts"],"names":[],"mappings":"AAMA,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,qCAWtD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var y=Object.defineProperty;var e=(o,t)=>y(o,"name",{value:t,configurable:!0});var n=(o,t)=>{for(var s in t)y(o,s,{get:t[s],enumerable:!0})};var S={};n(S,{recommended:()=>k});function g(o){let[,t]=o.state();t("network",null),t("accounts",null),t("connected",!1),t("connecting",!1),t("connectArgs",null)}e(g,"disconnect");var x=[["disconnect",g]];var k=[...x];var A={};n(A,{recommended:()=>R});function a(o){let[,t]=o.state();t("connecting",!1)}e(a,"intoConnectionFinished");var d=[["connect",a]];var R=[...d];var
|
|
1
|
+
var y=Object.defineProperty;var e=(o,t)=>y(o,"name",{value:t,configurable:!0});var n=(o,t)=>{for(var s in t)y(o,s,{get:t[s],enumerable:!0})};var S={};n(S,{recommended:()=>k});function g(o){let[,t]=o.state();t("network",null),t("accounts",null),t("connected",!1),t("connecting",!1),t("connectArgs",null)}e(g,"disconnect");var x=[["disconnect",g]];var k=[...x];var A={};n(A,{recommended:()=>R});function a(o){let[,t]=o.state();t("connecting",!1)}e(a,"intoConnectionFinished");var d=[["connect",a]];var R=[...d];var w={};n(w,{recommended:()=>M});import{createStore as Le}from"zustand/vanilla";import{produce as Te}from"immer";import{produce as Fe}from"immer";var r=class{static{e(this,"ActionBuilder")}name;#e=new Map;#t=new Map;#o=new Map;#r=new Map;#n;constructor(t){this.name=t}and(t){return this.#e.has(this.name)||this.#e.set(this.name,[]),this.#e.get(this.name)?.push(t),this}or(t){return this.#t.has(this.name)||this.#t.set(this.name,[]),this.#t.get(this.name)?.push(t),this}before(t){return this.#r.has(this.name)||this.#r.set(this.name,[]),this.#r.get(this.name)?.push(t),this}after(t){return this.#o.has(this.name)||this.#o.set(this.name,[]),this.#o.get(this.name)?.push(t),this}action(t){return this.#n=t,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 At from"caip";import{AccountId as V}from"caip";function C(o){try{return V.parse(o),!0}catch{return!1}}e(C,"isValidCaipAddress");function i(o,t){if(!t.every(C))throw new Error(`Your provider should format account addresses in CAIP-10 format. Your provided accounts: ${t}`);let[,s]=o.state();return s("accounts",t),s("connected",!0),t}e(i,"connectAndUpdateStateForSingleNetwork");function p(o){let[,t]=o.state();t("connecting",!0)}e(p,"intoConnecting");var h=[["connect",p]];var M=[["connect",i]];var E={};n(E,{recommended:()=>W});var W=[...h];var N={};n(N,{canEagerConnect:()=>B,connect:()=>H});var H=e(()=>new r("connect").and(i).before(p).after(a),"connect"),B=e(()=>new r("canEagerConnect"),"canEagerConnect");var T={};n(T,{formatAccountsToCAIP:()=>L});import{AccountId as U}from"caip";var l="tron",v="tron";function L(o){return o.map(t=>U.format({address:t.toString(),chainId:{namespace:l,reference:v}}))}e(L,"formatAccountsToCAIP");export{l as CAIP_NAMESPACE,v as CAIP_TRON_CHAIN_ID,S as actions,A as after,w as and,E as before,N as builders,T as utils};
|
|
2
2
|
//# sourceMappingURL=mod.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/namespaces/utxo/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,WAAW,CAAC;AACvC,eAAO,MAAM,qBAAqB,qCAAqC,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/namespaces/utxo/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,WAAW,CAAC;AACvC,eAAO,MAAM,qBAAqB,qCAAqC,CAAC;AACxE,eAAO,MAAM,mBAAmB,UAAU,CAAC"}
|
|
@@ -5,5 +5,5 @@ export * as before from './before.js';
|
|
|
5
5
|
export * as builders from './builders.js';
|
|
6
6
|
export * as utils from './utils.js';
|
|
7
7
|
export type { ProviderAPI, UtxoActions } from './types.js';
|
|
8
|
-
export { CAIP_NAMESPACE, CAIP_BITCOIN_CHAIN_ID } from './constants.js';
|
|
8
|
+
export { CAIP_NAMESPACE, CAIP_BITCOIN_CHAIN_ID, CAIP_ZCASH_CHAIN_ID, } from './constants.js';
|
|
9
9
|
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/namespaces/utxo/mod.ts"],"names":[],"mappings":"AAAA,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,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/namespaces/utxo/mod.ts"],"names":[],"mappings":"AAAA,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,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,gBAAgB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var v=Object.defineProperty;var e=(o,t)=>v(o,"name",{value:t,configurable:!0});var s=(o,t)=>{for(var r in t)v(o,r,{get:t[r],enumerable:!0})};var x={};s(x,{recommended:()=>T});function y(o){let[,t]=o.state();t("network",null),t("accounts",null),t("connected",!1),t("connecting",!1),t("connectArgs",null)}e(y,"disconnect");var g=[["disconnect",y]];var T=[...g];var S={};s(S,{recommended:()=>k});function a(o){let[,t]=o.state();t("connecting",!1)}e(a,"intoConnectionFinished");var d=[["connect",a]];var k=[...d];var P={};s(P,{recommended:()=>V});import{createStore as Le}from"zustand/vanilla";import{produce as Ie}from"immer";import{produce as Fe}from"immer";var n=class{static{e(this,"ActionBuilder")}name;#e=new Map;#t=new Map;#o=new Map;#r=new Map;#n;constructor(t){this.name=t}and(t){return this.#e.has(this.name)||this.#e.set(this.name,[]),this.#e.get(this.name)?.push(t),this}or(t){return this.#t.has(this.name)||this.#t.set(this.name,[]),this.#t.get(this.name)?.push(t),this}before(t){return this.#r.has(this.name)||this.#r.set(this.name,[]),this.#r.get(this.name)?.push(t),this}after(t){return this.#o.has(this.name)||this.#o.set(this.name,[]),this.#o.get(this.name)?.push(t),this}action(t){return this.#n=t,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 At from"caip";import{AccountId as D}from"caip";function C(o){try{return D.parse(o),!0}catch{return!1}}e(C,"isValidCaipAddress");function i(o,t){if(!t.every(C))throw new Error(`Your provider should format account addresses in CAIP-10 format. Your provided accounts: ${t}`);let[,r]=o.state();return r("accounts",t),r("connected",!0),t}e(i,"connectAndUpdateStateForSingleNetwork");function p(o){let[,t]=o.state();t("connecting",!0)}e(p,"intoConnecting");var h=[["connect",p]];var V=[["connect",i]];var w={};s(w,{recommended:()=>M});var M=[...h];var E={};s(E,{connect:()=>W});var W=e(()=>new n("connect").and(i).before(p).after(a),"connect");var N={};s(N,{formatAccountsToCAIP:()=>L});import{AccountId as B}from"caip";var l="bip122",H="000000000019d6689c085ae165831e93",U="zcash";function L(o,t){return o.map(r=>B.format({address:r.toString(),chainId:{namespace:l,reference:t}}))}e(L,"formatAccountsToCAIP");export{H as CAIP_BITCOIN_CHAIN_ID,l as CAIP_NAMESPACE,U as CAIP_ZCASH_CHAIN_ID,x as actions,S as after,P as and,w as before,E as builders,N as utils};
|
|
2
2
|
//# sourceMappingURL=mod.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/namespaces/utxo/actions.ts", "../../../src/namespaces/common/actions.ts", "../../../src/namespaces/utxo/after.ts", "../../../src/namespaces/common/after.ts", "../../../src/namespaces/utxo/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/utxo/before.ts", "../../../src/namespaces/utxo/builders.ts", "../../../src/namespaces/utxo/utils.ts", "../../../src/namespaces/utxo/constants.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 { connectAndUpdateStateForSingleNetwork } from '../common/mod.js';\n\nexport const recommended = [\n ['connect', connectAndUpdateStateForSingleNetwork] as const,\n];\n", "import type { StoreApi } from 'zustand/vanilla';\n\nimport { createStore as createZustandStore } from 'zustand/vanilla';\n\nimport { 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 { recommended as commonRecommended } from '../common/before.js';\n\nexport const recommended = [...commonRecommended];\n", "import type { UtxoActions } from './types.js';\n\nimport { ActionBuilder } from '../../mod.js';\nimport { intoConnectionFinished } from '../common/after.js';\nimport { connectAndUpdateStateForSingleNetwork } from '../common/and.js';\nimport { intoConnecting } from '../common/before.js';\n\nexport const connect = () =>\n new ActionBuilder<UtxoActions, 'connect'>('connect')\n .and(connectAndUpdateStateForSingleNetwork)\n .before(intoConnecting)\n .after(intoConnectionFinished);\n", "import type { CaipAccount } from '../common/mod.js';\n\nimport { AccountId } from 'caip';\n\nimport { CAIP_BITCOIN_CHAIN_ID, CAIP_NAMESPACE } from './constants.js';\n\nexport function formatAccountsToCAIP(accounts: string[]) {\n return accounts.map(\n (account) =>\n AccountId.format({\n address: account.toString(),\n chainId: {\n namespace: CAIP_NAMESPACE,\n reference: CAIP_BITCOIN_CHAIN_ID,\n },\n }) as CaipAccount\n );\n}\n", "export const CAIP_NAMESPACE = 'bip122';\nexport const CAIP_BITCOIN_CHAIN_ID = '000000000019d6689c085ae165831e93';\n"],
|
|
5
|
-
"mappings": "6IAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,ICEO,SAASC,EAAWC,EAAwB,CACjD,GAAM,CAAC,CAAEC,CAAQ,EAAID,EAAQ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AC,CAAC,UAAWJ,CAAc,CAAU,ERNzD,IAAMK,EAAc,CACzB,CAAC,UAAWC,CAAqC,CACnD,ESJA,IAAAC,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,IAEO,IAAMC,EAAc,CAAC,GAAGA,CAAiB,ECFhD,IAAAC,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAOO,IAAMC,EAAUC,EAAA,IACrB,IAAIC,EAAsC,SAAS,EAChD,IAAIC,CAAqC,EACzC,OAAOC,CAAc,EACrB,MAAMC,CAAsB,EAJV,WCPvB,IAAAC,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAEA,OAAS,aAAAC,MAAiB,OCFnB,IAAMC,EAAiB,SACjBC,EAAwB,
|
|
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", "intoConnecting", "context", "setState", "__name", "recommended", "recommended", "connectAndUpdateStateForSingleNetwork", "before_exports", "__export", "recommended", "recommended", "builders_exports", "__export", "connect", "connect", "__name", "ActionBuilder", "connectAndUpdateStateForSingleNetwork", "intoConnecting", "intoConnectionFinished", "utils_exports", "__export", "formatAccountsToCAIP", "AccountId", "CAIP_NAMESPACE", "CAIP_BITCOIN_CHAIN_ID", "formatAccountsToCAIP", "accounts", "
|
|
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 { connectAndUpdateStateForSingleNetwork } from '../common/mod.js';\n\nexport const recommended = [\n ['connect', connectAndUpdateStateForSingleNetwork] as const,\n];\n", "import type { StoreApi } from 'zustand/vanilla';\n\nimport { createStore as createZustandStore } from 'zustand/vanilla';\n\nimport { 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 { recommended as commonRecommended } from '../common/before.js';\n\nexport const recommended = [...commonRecommended];\n", "import type { UtxoActions } from './types.js';\n\nimport { ActionBuilder } from '../../mod.js';\nimport { intoConnectionFinished } from '../common/after.js';\nimport { connectAndUpdateStateForSingleNetwork } from '../common/and.js';\nimport { intoConnecting } from '../common/before.js';\n\nexport const connect = () =>\n new ActionBuilder<UtxoActions, 'connect'>('connect')\n .and(connectAndUpdateStateForSingleNetwork)\n .before(intoConnecting)\n .after(intoConnectionFinished);\n", "import type { CaipAccount } from '../common/mod.js';\n\nimport { AccountId } from 'caip';\n\nimport { CAIP_NAMESPACE } from './constants.js';\n\nexport function formatAccountsToCAIP(accounts: string[], chainId: string) {\n return accounts.map(\n (account) =>\n AccountId.format({\n address: account.toString(),\n chainId: {\n namespace: CAIP_NAMESPACE,\n reference: chainId,\n },\n }) as CaipAccount\n );\n}\n", "export const CAIP_NAMESPACE = 'bip122';\nexport const CAIP_BITCOIN_CHAIN_ID = '000000000019d6689c085ae165831e93';\nexport const CAIP_ZCASH_CHAIN_ID = 'zcash';\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,CA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AA,GAAAC,EAAAD,EAAA,0BAAAE,IAEA,OAAS,aAAAC,MAAiB,OCFnB,IAAMC,EAAiB,SACjBC,EAAwB,mCACxBC,EAAsB,QDI5B,SAASC,EAAqBC,EAAoBC,EAAiB,CACxE,OAAOD,EAAS,IACbE,GACCC,EAAU,OAAO,CACf,QAASD,EAAQ,SAAS,EAC1B,QAAS,CACP,UAAWE,EACX,UAAWH,CACb,CACF,CAAC,CACL,CACF,CAXgBI,EAAAN,EAAA",
|
|
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", "intoConnecting", "context", "setState", "__name", "recommended", "recommended", "connectAndUpdateStateForSingleNetwork", "before_exports", "__export", "recommended", "recommended", "builders_exports", "__export", "connect", "connect", "__name", "ActionBuilder", "connectAndUpdateStateForSingleNetwork", "intoConnecting", "intoConnectionFinished", "utils_exports", "__export", "formatAccountsToCAIP", "AccountId", "CAIP_NAMESPACE", "CAIP_BITCOIN_CHAIN_ID", "CAIP_ZCASH_CHAIN_ID", "formatAccountsToCAIP", "accounts", "chainId", "account", "AccountId", "CAIP_NAMESPACE", "__name"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function formatAccountsToCAIP(accounts: string[]): `${string}:${string}:${string}`[];
|
|
1
|
+
export declare function formatAccountsToCAIP(accounts: string[], chainId: string): `${string}:${string}:${string}`[];
|
|
2
2
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/namespaces/utxo/utils.ts"],"names":[],"mappings":"AAMA,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/namespaces/utxo/utils.ts"],"names":[],"mappings":"AAMA,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,qCAWvE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var h=Object.defineProperty;var e=(r,t)=>h(r,"name",{value:t,configurable:!0});var l=(r,t)=>{for(var n in t)h(r,n,{get:t[n],enumerable:!0})};var S={};l(S,{connect:()=>I});import{createStore as
|
|
1
|
+
var h=Object.defineProperty;var e=(r,t)=>h(r,"name",{value:t,configurable:!0});var l=(r,t)=>{for(var n in t)h(r,n,{get:t[n],enumerable:!0})};var S={};l(S,{connect:()=>I});import{createStore as Ee}from"zustand/vanilla";import{produce as de}from"immer";import{produce as ve}from"immer";var o=class{static{e(this,"ActionBuilder")}name;#e=new Map;#t=new Map;#r=new Map;#o=new Map;#n;constructor(t){this.name=t}and(t){return this.#e.has(this.name)||this.#e.set(this.name,[]),this.#e.get(this.name)?.push(t),this}or(t){return this.#t.has(this.name)||this.#t.set(this.name,[]),this.#t.get(this.name)?.push(t),this}before(t){return this.#o.has(this.name)||this.#o.set(this.name,[]),this.#o.get(this.name)?.push(t),this}after(t){return this.#r.has(this.name)||this.#r.set(this.name,[]),this.#r.get(this.name)?.push(t),this}action(t){return this.#n=t,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 ot from"caip";function p(r){let[,t]=r.state();t("connecting",!1)}e(p,"intoConnectionFinished");import{AccountId as T}from"caip";function g(r){try{return T.parse(r),!0}catch{return!1}}e(g,"isValidCaipAddress");function d(r,t){if(!t.every(g))throw new Error(`Your provider should format account addresses in CAIP-10 format. Your provided accounts: ${t}`);let[,n]=r.state();return n("accounts",t),n("connected",!0),t}e(d,"connectAndUpdateStateForSingleNetwork");function u(r){let[,t]=r.state();t("connecting",!0)}e(u,"intoConnecting");var I=e(()=>new o("connect").and(d).before(u).after(p),"connect");var x={};l(x,{formatAddressToCAIP:()=>R});import{AccountId as k}from"caip";var m="xrpl",f="mainnet";function R(r){return k.format({address:r,chainId:{namespace:m,reference:f}})}e(R,"formatAddressToCAIP");export{m as CAIP_NAMESPACE,f as CAIP_XRPL_CHAIN_ID,S as builders,x as utils};
|
|
2
2
|
//# sourceMappingURL=mod.js.map
|