@rango-dev/provider-vultisig 0.4.1-next.3 → 0.4.1-next.5
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/actions/utxo.d.ts +9 -0
- package/dist/actions/utxo.d.ts.map +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/mod.d.ts +1 -1
- package/dist/mod.d.ts.map +1 -1
- package/dist/mod.js +1 -1
- package/dist/mod.js.map +4 -4
- package/dist/namespaces/utxo/namespace.d.ts +1 -1
- package/dist/namespaces/utxo/namespace.d.ts.map +1 -1
- package/dist/namespaces/utxo/singer.d.ts.map +1 -1
- package/dist/provider.d.ts +1 -1
- package/dist/provider.d.ts.map +1 -1
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -1
- package/package.json +7 -6
- package/src/actions/utxo.ts +30 -0
- package/src/constants.ts +3 -6
- package/src/namespaces/utxo/namespace.ts +8 -21
- package/src/namespaces/utxo/singer.ts +1 -3
- package/src/utils.ts +9 -0
- package/dist/namespaces/utxo/helpers.d.ts +0 -3
- package/dist/namespaces/utxo/helpers.d.ts.map +0 -1
- package/src/namespaces/utxo/helpers.ts +0 -10
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { UtxoActions } from '@hub3js/bip122';
|
|
2
|
+
import type { CanEagerConnect, Context, FunctionWithContext } from '@hub3js/core';
|
|
3
|
+
export declare function connect(): FunctionWithContext<UtxoActions['connect'], Context>;
|
|
4
|
+
export declare function canEagerConnect(): CanEagerConnect<UtxoActions>;
|
|
5
|
+
export declare const utxoActions: {
|
|
6
|
+
connect: typeof connect;
|
|
7
|
+
canEagerConnect: typeof canEagerConnect;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=utxo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utxo.d.ts","sourceRoot":"","sources":["../../src/actions/utxo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EACV,eAAe,EACf,OAAO,EACP,mBAAmB,EACpB,MAAM,cAAc,CAAC;AAMtB,wBAAgB,OAAO,IAAI,mBAAmB,CAC5C,WAAW,CAAC,SAAS,CAAC,EACtB,OAAO,CACR,CAMA;AAED,wBAAgB,eAAe,IAAI,eAAe,CAAC,WAAW,CAAC,CAK9D;AAED,eAAO,MAAM,WAAW;;;CAA+B,CAAC"}
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AASrD,eAAO,MAAM,SAAS,aAAa,CAAC;AAEpC,eAAO,MAAM,IAAI,EAAE,gBA4BlB,CAAC"}
|
package/dist/mod.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const versions: () => readonly [readonly ["1.0.0", import("@hub3js/core").Provider<Record<"utxo", import("@
|
|
1
|
+
declare const versions: () => readonly [readonly ["1.0.0", import("@hub3js/core").Provider<Record<"utxo", import("@hub3js/bip122").UtxoActions>>]];
|
|
2
2
|
export { versions };
|
|
3
3
|
export { WALLET_ID } from './constants.js';
|
|
4
4
|
//# sourceMappingURL=mod.d.ts.map
|
package/dist/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,QAAQ,4HAC8C,CAAC;AAE7D,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/mod.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var w=Object.defineProperty;var e=(t,o)=>w(t,"name",{value:o,configurable:!0});var n=(t,o)=>()=>(t&&(o=t(t=0)),o);var B=(t,o)=>{for(var s in o)w(t,s,{get:o[s],enumerable:!0})};import{UTXO_NAMESPACE as y}from"@hub3js/namespaces";function d(){let{vultisig:t}=window;if(!t)return null;let o=new Map;return t.zcash&&o.set(y,t.zcash),o}function c(){let o=d()?.get(y);if(!o)throw new Error("Vultisig not injected. Please check your wallet.");return o}async function C(){return c().requestAccounts()}async function a(){return c().request({method:"get_accounts"})}var m=n(()=>{"use strict";e(d,"vultisig");e(c,"vultisigZcash");e(C,"requestZcashAccounts");e(a,"getZcashAccounts")});import{CAIP_ZCASH_CHAIN_ID as N,utils as R}from"@hub3js/bip122";function k(){return async()=>{let t=await C();return R.formatAccountsToCAIP(t,N)}}function q(){return async()=>(await a().catch(()=>[])).length>0}var l,v=n(()=>{"use strict";m();e(k,"connect");e(q,"canEagerConnect");l={connect:k,canEagerConnect:q}});import{builders as E}from"@hub3js/bip122";import{NamespaceBuilder as F}from"@hub3js/core";import*as S from"@hub3js/std/builders";import{standardizeAndThrowError as H}from"@hub3js/std/operators";var M,V,O,u,f=n(()=>{"use strict";v();p();M=E.connect().action(l.connect()).or(H).build(),V=E.canEagerConnect().action(l.canEagerConnect()).build(),O=S.disconnect().build(),u=new F("UTXO",i).action(M).action(O).action(V).build()});import{isZcashBlockchain as X}from"@rango-dev/internal-blockchains";import{SignerError as h,SignerErrorCode as b}from"rango-types";var g,T=n(()=>{"use strict";m();g=class{static{e(this,"Signer")}async signMessage(){throw h.UnimplementedError("signMessage")}async signAndSendTx(o){let{memo:s,fromWalletAddress:x,recipientAddress:j,amount:D,asset:L}=o;if(!X(L.blockchain))throw new Error(`You can not sign ${o.blockChain} using ZCash signer.`);let W=await a();if(x!==W[0])throw new Error("fromWalletAddress is not matched with the connected account");try{let r={method:"send_transaction",params:[{from:x,to:j,value:D,memo:s}]};return{hash:await c().request(r)}}catch(r){throw typeof r=="string"?new h(b.UNEXPECTED_BEHAVIOUR,r,void 0):new h(b.SEND_TX_ERROR,void 0,r)}}}});var P={};B(P,{Signer:()=>g,namespace:()=>u});var _=n(()=>{"use strict";f();T()});import{DefaultSignerFactory as z,TransactionType as G}from"rango-types";async function A(){let{Signer:t}=await Promise.resolve().then(()=>(_(),P)),o=new z;return o.registerSigner(G.TRANSFER,new t),o}var Z=n(()=>{"use strict";e(A,"getSigners")});import{CAIP_ZCASH_CHAIN_ID as Y,isChainSupported as $}from"@hub3js/bip122";var i,I,p=n(()=>{"use strict";Z();i="vultisig",I={name:"Vultisig",icon:"https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/vultisig/icon.svg",extensions:{chrome:"https://chromewebstore.google.com/detail/vultisig-extension/ggafhcdaplkhmmnlbfjpnnkepdfjaelb",homepage:"https://vultisig.com/"},properties:[{name:"namespaces",value:{selection:"multiple",data:[{label:"Zcash",value:"UTXO",id:"ZCASH",isChainSupported:$([Y])}]}},{name:"signers",value:{getSigners:async()=>A()}}]}});import{defineVersions as K}from"@hub3js/core/utils";p();f();m();import{ProviderBuilder as J}from"@hub3js/core";var U=e(()=>new J(i).init(function(t){let[,o]=t.state();d()&&(o("installed",!0),console.debug("[vultisig] instance detected.",t))}).config("metadata",I).add("utxo",u).build(),"buildProvider");p();var Wt=e(()=>K().version("1.0.0",U()).build(),"versions");export{i as WALLET_ID,Wt as versions};
|
|
2
2
|
//# sourceMappingURL=mod.js.map
|
package/dist/mod.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/utils.ts", "../src/
|
|
4
|
-
"sourcesContent": ["import type { Provider, VultisigZcashProviderApi } from './types.js';\n\nimport { UTXO_NAMESPACE } from '@hub3js/namespaces';\n\nexport function vultisig(): Provider | null {\n const { vultisig } = window;\n if (!vultisig) {\n return null;\n }\n\n const instances: Provider = new Map();\n\n if (vultisig.zcash) {\n instances.set(UTXO_NAMESPACE, vultisig.zcash);\n }\n\n return instances;\n}\n\nexport function vultisigZcash(): VultisigZcashProviderApi {\n const instances = vultisig();\n const zcashInstance = instances?.get(UTXO_NAMESPACE);\n\n if (!zcashInstance) {\n throw new Error('Vultisig not injected. Please check your wallet.');\n }\n\n return zcashInstance;\n}\n
|
|
5
|
-
"mappings": "gLAEA,OAAS,kBAAAA,MAAsB,qBAExB,SAASC,GAA4B,CAC1C,GAAM,CAAE,SAAAA,CAAS,EAAI,OACrB,GAAI,CAACA,EACH,OAAO,KAGT,IAAMC,EAAsB,IAAI,IAEhC,OAAID,EAAS,OACXC,EAAU,IAAIF,EAAgBC,EAAS,KAAK,EAGvCC,CACT,CAEO,SAASC,GAA0C,CAExD,IAAMC,EADYH,EAAS,GACM,IAAID,CAAc,EAEnD,GAAI,CAACI,EACH,MAAM,IAAI,MAAM,kDAAkD,EAGpE,OAAOA,CACT,
|
|
6
|
-
"names": ["UTXO_NAMESPACE", "vultisig", "instances", "vultisigZcash", "zcashInstance", "init_utils", "__esmMin", "__name", "
|
|
3
|
+
"sources": ["../src/utils.ts", "../src/actions/utxo.ts", "../src/namespaces/utxo/namespace.ts", "../src/namespaces/utxo/singer.ts", "../src/namespaces/utxo/mod.ts", "../src/signer.ts", "../src/constants.ts", "../src/mod.ts", "../src/provider.ts"],
|
|
4
|
+
"sourcesContent": ["import type { Provider, VultisigZcashProviderApi } from './types.js';\n\nimport { UTXO_NAMESPACE } from '@hub3js/namespaces';\n\nexport function vultisig(): Provider | null {\n const { vultisig } = window;\n if (!vultisig) {\n return null;\n }\n\n const instances: Provider = new Map();\n\n if (vultisig.zcash) {\n instances.set(UTXO_NAMESPACE, vultisig.zcash);\n }\n\n return instances;\n}\n\nexport function vultisigZcash(): VultisigZcashProviderApi {\n const instances = vultisig();\n const zcashInstance = instances?.get(UTXO_NAMESPACE);\n\n if (!zcashInstance) {\n throw new Error('Vultisig not injected. Please check your wallet.');\n }\n\n return zcashInstance;\n}\n\nexport async function requestZcashAccounts(): Promise<string[]> {\n return vultisigZcash().requestAccounts();\n}\n\n// `get_accounts` is the silent variant \u2014 it never opens the wallet.\nexport async function getZcashAccounts(): Promise<string[]> {\n return vultisigZcash().request({ method: 'get_accounts' });\n}\n", "import type { UtxoActions } from '@hub3js/bip122';\nimport type {\n CanEagerConnect,\n Context,\n FunctionWithContext,\n} from '@hub3js/core';\n\nimport { CAIP_ZCASH_CHAIN_ID, utils } from '@hub3js/bip122';\n\nimport { getZcashAccounts, requestZcashAccounts } from '../utils.js';\n\nexport function connect(): FunctionWithContext<\n UtxoActions['connect'],\n Context\n> {\n return async () => {\n const accounts = await requestZcashAccounts();\n\n return utils.formatAccountsToCAIP(accounts, CAIP_ZCASH_CHAIN_ID);\n };\n}\n\nexport function canEagerConnect(): CanEagerConnect<UtxoActions> {\n return async () => {\n const accounts = await getZcashAccounts().catch(() => []);\n return accounts.length > 0;\n };\n}\n\nexport const utxoActions = { connect, canEagerConnect };\n", "import type { UtxoActions } from '@hub3js/bip122';\n\nimport { builders } from '@hub3js/bip122';\nimport { NamespaceBuilder } from '@hub3js/core';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\n\nimport { utxoActions } from '../../actions/utxo.js';\nimport { WALLET_ID } from '../../constants.js';\n\nconst connect = builders\n .connect()\n .action(utxoActions.connect())\n .or(standardizeAndThrowError)\n .build();\n\nconst canEagerConnect = builders\n .canEagerConnect()\n .action(utxoActions.canEagerConnect())\n .build();\n\nconst disconnect = commonBuilders.disconnect<UtxoActions>().build();\n\nexport const namespace = new NamespaceBuilder<UtxoActions>('UTXO', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .action(canEagerConnect)\n .build();\n", "import type { SendTransactionArgs } from '../../types.js';\nimport type { Transfer } from 'rango-types/mainApi';\n\nimport { isZcashBlockchain } from '@rango-dev/internal-blockchains';\nimport { type GenericSigner, SignerError, SignerErrorCode } from 'rango-types';\n\nimport { getZcashAccounts, vultisigZcash } from '../../utils.js';\n\nexport class Signer implements GenericSigner<Transfer> {\n async signMessage(): Promise<string> {\n throw SignerError.UnimplementedError('signMessage');\n }\n\n async signAndSendTx(tx: Transfer): Promise<{ hash: string }> {\n const { memo, fromWalletAddress, recipientAddress, amount, asset } = tx;\n\n // TODO: check should be performed on the blockchain field of transaction instead of asset, but currently it is not available in the transaction object\n if (!isZcashBlockchain(asset.blockchain)) {\n throw new Error(`You can not sign ${tx.blockChain} using ZCash signer.`);\n }\n\n const accounts = await getZcashAccounts();\n\n if (fromWalletAddress !== accounts[0]) {\n throw new Error(\n 'fromWalletAddress is not matched with the connected account'\n );\n }\n\n try {\n const transactionRequest: SendTransactionArgs = {\n method: 'send_transaction',\n params: [\n {\n from: fromWalletAddress,\n to: recipientAddress,\n value: amount,\n memo,\n },\n ],\n };\n\n const response = await vultisigZcash().request(transactionRequest);\n return { hash: response };\n } catch (error) {\n if (typeof error === 'string') {\n throw new SignerError(\n SignerErrorCode.UNEXPECTED_BEHAVIOUR,\n error,\n undefined\n );\n }\n throw new SignerError(SignerErrorCode.SEND_TX_ERROR, undefined, error);\n }\n }\n}\n", "export { namespace } from './namespace.js';\nexport { Signer } from './singer.js';\n", "import type { SignerFactory } from 'rango-types';\n\nimport { DefaultSignerFactory, TransactionType as TxType } from 'rango-types';\n\nexport default async function getSigners(): Promise<SignerFactory> {\n const { Signer: UtxoSigner } = await import('./namespaces/utxo/mod.js');\n const signers = new DefaultSignerFactory();\n\n signers.registerSigner(TxType.TRANSFER, new UtxoSigner());\n return signers;\n}\n", "import type { ProviderMetadata } from '@hub3js/core';\n\nimport {\n CAIP_ZCASH_CHAIN_ID,\n isChainSupported as isBip122ChainSupported,\n} from '@hub3js/bip122';\n\nimport getSigners from './signer.js';\n\nexport const WALLET_ID = 'vultisig';\n\nexport const info: ProviderMetadata = {\n name: 'Vultisig',\n icon: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/vultisig/icon.svg',\n extensions: {\n chrome:\n 'https://chromewebstore.google.com/detail/vultisig-extension/ggafhcdaplkhmmnlbfjpnnkepdfjaelb',\n homepage: 'https://vultisig.com/',\n },\n properties: [\n {\n name: 'namespaces',\n value: {\n selection: 'multiple',\n data: [\n {\n label: 'Zcash',\n value: 'UTXO',\n id: 'ZCASH',\n isChainSupported: isBip122ChainSupported([CAIP_ZCASH_CHAIN_ID]),\n },\n ],\n },\n },\n {\n name: 'signers',\n value: { getSigners: async () => getSigners() },\n },\n ],\n};\n", "import { defineVersions } from '@hub3js/core/utils';\n\nimport { buildProvider } from './provider.js';\n\nconst versions = () =>\n defineVersions().version('1.0.0', buildProvider()).build();\n\nexport { versions };\nexport { WALLET_ID } from './constants.js';\n", "import { ProviderBuilder } from '@hub3js/core';\n\nimport { info, WALLET_ID } from './constants.js';\nimport { namespace as utxo } from './namespaces/utxo/namespace.js';\nimport { vultisig } from './utils.js';\n\nconst buildProvider = () =>\n new ProviderBuilder(WALLET_ID)\n .init(function (context) {\n const [, setState] = context.state();\n if (vultisig()) {\n setState('installed', true);\n console.debug('[vultisig] instance detected.', context);\n }\n })\n .config('metadata', info)\n .add('utxo', utxo)\n .build();\n\nexport { buildProvider };\n"],
|
|
5
|
+
"mappings": "gLAEA,OAAS,kBAAAA,MAAsB,qBAExB,SAASC,GAA4B,CAC1C,GAAM,CAAE,SAAAA,CAAS,EAAI,OACrB,GAAI,CAACA,EACH,OAAO,KAGT,IAAMC,EAAsB,IAAI,IAEhC,OAAID,EAAS,OACXC,EAAU,IAAIF,EAAgBC,EAAS,KAAK,EAGvCC,CACT,CAEO,SAASC,GAA0C,CAExD,IAAMC,EADYH,EAAS,GACM,IAAID,CAAc,EAEnD,GAAI,CAACI,EACH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M,EACA,oBAAoBC,MACf,iBALP,IASaC,EAEAC,EAXbC,EAAAC,EAAA,kBAOAC,IAEaJ,EAAY,WAEZC,EAAyB,CACpC,KAAM,WACN,KAAM,yFACN,WAAY,CACV,OACE,+FACF,SAAU,uBACZ,EACA,WAAY,CACV,CACE,KAAM,aACN,MAAO,CACL,UAAW,WACX,KAAM,CACJ,CACE,MAAO,QACP,MAAO,OACP,GAAI,QACJ,iBAAkBF,EAAuB,CAACD,CAAmB,CAAC,CAChE,CACF,CACF,CACF,EACA,CACE,KAAM,UACN,MAAO,CAAE,WAAY,SAAYO,EAAW,CAAE,CAChD,CACF,CACF,ICvCA,OAAS,kBAAAC,MAAsB,qBCE/BC,IACAC,IACAC,IAJA,OAAS,mBAAAC,MAAuB,eAMhC,IAAMC,EAAgBC,EAAA,IACpB,IAAIC,EAAgBC,CAAS,EAC1B,KAAK,SAAUC,EAAS,CACvB,GAAM,CAAC,CAAEC,CAAQ,EAAID,EAAQ,MAAM,EAC/BE,EAAS,IACXD,EAAS,YAAa,EAAI,EAC1B,QAAQ,MAAM,gCAAiCD,CAAO,EAE1D,CAAC,EACA,OAAO,WAAYG,CAAI,EACvB,IAAI,OAAQC,CAAI,EAChB,MAAM,EAXW,iBDEtBC,IAJA,IAAMC,GAAWC,EAAA,IACfC,EAAe,EAAE,QAAQ,QAASC,EAAc,CAAC,EAAE,MAAM,EAD1C",
|
|
6
|
+
"names": ["UTXO_NAMESPACE", "vultisig", "instances", "vultisigZcash", "zcashInstance", "requestZcashAccounts", "getZcashAccounts", "init_utils", "__esmMin", "__name", "CAIP_ZCASH_CHAIN_ID", "utils", "connect", "accounts", "requestZcashAccounts", "canEagerConnect", "getZcashAccounts", "utxoActions", "init_utxo", "__esmMin", "init_utils", "__name", "builders", "NamespaceBuilder", "commonBuilders", "standardizeAndThrowError", "connect", "canEagerConnect", "disconnect", "namespace", "init_namespace", "__esmMin", "init_utxo", "init_constants", "utxoActions", "WALLET_ID", "isZcashBlockchain", "SignerError", "SignerErrorCode", "Signer", "init_singer", "__esmMin", "init_utils", "__name", "tx", "memo", "fromWalletAddress", "recipientAddress", "amount", "asset", "accounts", "getZcashAccounts", "transactionRequest", "vultisigZcash", "error", "mod_exports", "__export", "Signer", "namespace", "init_mod", "__esmMin", "init_namespace", "init_singer", "DefaultSignerFactory", "TxType", "getSigners", "UtxoSigner", "signers", "init_signer", "__esmMin", "__name", "CAIP_ZCASH_CHAIN_ID", "isBip122ChainSupported", "WALLET_ID", "info", "init_constants", "__esmMin", "init_signer", "getSigners", "defineVersions", "init_constants", "init_namespace", "init_utils", "ProviderBuilder", "buildProvider", "__name", "ProviderBuilder", "WALLET_ID", "context", "setState", "vultisig", "info", "namespace", "init_constants", "versions", "__name", "defineVersions", "buildProvider"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../../../src/namespaces/utxo/namespace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../../../src/namespaces/utxo/namespace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAuBlD,eAAO,MAAM,SAAS,sDAIZ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"singer.d.ts","sourceRoot":"","sources":["../../../src/namespaces/utxo/singer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,KAAK,aAAa,EAAgC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"singer.d.ts","sourceRoot":"","sources":["../../../src/namespaces/utxo/singer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,KAAK,aAAa,EAAgC,MAAM,aAAa,CAAC;AAI/E,qBAAa,MAAO,YAAW,aAAa,CAAC,QAAQ,CAAC;IAC9C,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAI9B,aAAa,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CA0C7D"}
|
package/dist/provider.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const buildProvider: () => import("@hub3js/core").Provider<Record<"utxo", import("@
|
|
1
|
+
declare const buildProvider: () => import("@hub3js/core").Provider<Record<"utxo", import("@hub3js/bip122").UtxoActions>>;
|
|
2
2
|
export { buildProvider };
|
|
3
3
|
//# sourceMappingURL=provider.d.ts.map
|
package/dist/provider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAMA,QAAA,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAMA,QAAA,MAAM,aAAa,6FAWP,CAAC;AAEb,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { Provider, VultisigZcashProviderApi } from './types.js';
|
|
2
2
|
export declare function vultisig(): Provider | null;
|
|
3
3
|
export declare function vultisigZcash(): VultisigZcashProviderApi;
|
|
4
|
+
export declare function requestZcashAccounts(): Promise<string[]>;
|
|
5
|
+
export declare function getZcashAccounts(): Promise<string[]>;
|
|
4
6
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAIrE,wBAAgB,QAAQ,IAAI,QAAQ,GAAG,IAAI,CAa1C;AAED,wBAAgB,aAAa,IAAI,wBAAwB,CASxD"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAIrE,wBAAgB,QAAQ,IAAI,QAAQ,GAAG,IAAI,CAa1C;AAED,wBAAgB,aAAa,IAAI,wBAAwB,CASxD;AAED,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAE9D;AAGD,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAE1D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/provider-vultisig",
|
|
3
|
-
"version": "0.4.1-next.
|
|
3
|
+
"version": "0.4.1-next.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/mod.ts",
|
|
@@ -21,11 +21,12 @@
|
|
|
21
21
|
"lint": "eslint \"**/*.{ts,tsx}\""
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@hub3js/
|
|
25
|
-
"@hub3js/
|
|
26
|
-
"@hub3js/
|
|
27
|
-
"@
|
|
28
|
-
"@rango-dev/
|
|
24
|
+
"@hub3js/bip122": "^0.2.1",
|
|
25
|
+
"@hub3js/core": "^0.62.0",
|
|
26
|
+
"@hub3js/namespaces": "^0.5.1",
|
|
27
|
+
"@hub3js/std": "^0.4.0",
|
|
28
|
+
"@rango-dev/internal-blockchains": "^0.1.1-next.2",
|
|
29
|
+
"@rango-dev/wallets-core": "^0.61.1-next.2",
|
|
29
30
|
"rango-types": "^0.5.0"
|
|
30
31
|
},
|
|
31
32
|
"publishConfig": {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { UtxoActions } from '@hub3js/bip122';
|
|
2
|
+
import type {
|
|
3
|
+
CanEagerConnect,
|
|
4
|
+
Context,
|
|
5
|
+
FunctionWithContext,
|
|
6
|
+
} from '@hub3js/core';
|
|
7
|
+
|
|
8
|
+
import { CAIP_ZCASH_CHAIN_ID, utils } from '@hub3js/bip122';
|
|
9
|
+
|
|
10
|
+
import { getZcashAccounts, requestZcashAccounts } from '../utils.js';
|
|
11
|
+
|
|
12
|
+
export function connect(): FunctionWithContext<
|
|
13
|
+
UtxoActions['connect'],
|
|
14
|
+
Context
|
|
15
|
+
> {
|
|
16
|
+
return async () => {
|
|
17
|
+
const accounts = await requestZcashAccounts();
|
|
18
|
+
|
|
19
|
+
return utils.formatAccountsToCAIP(accounts, CAIP_ZCASH_CHAIN_ID);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function canEagerConnect(): CanEagerConnect<UtxoActions> {
|
|
24
|
+
return async () => {
|
|
25
|
+
const accounts = await getZcashAccounts().catch(() => []);
|
|
26
|
+
return accounts.length > 0;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const utxoActions = { connect, canEagerConnect };
|
package/src/constants.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { ProviderMetadata } from '@hub3js/core';
|
|
2
2
|
|
|
3
|
-
import { getChainIdFromCaip2ChainId } from '@hub3js/std/utils';
|
|
4
3
|
import {
|
|
5
4
|
CAIP_ZCASH_CHAIN_ID,
|
|
6
|
-
|
|
7
|
-
} from '@
|
|
5
|
+
isChainSupported as isBip122ChainSupported,
|
|
6
|
+
} from '@hub3js/bip122';
|
|
8
7
|
|
|
9
8
|
import getSigners from './signer.js';
|
|
10
9
|
|
|
@@ -28,9 +27,7 @@ export const info: ProviderMetadata = {
|
|
|
28
27
|
label: 'Zcash',
|
|
29
28
|
value: 'UTXO',
|
|
30
29
|
id: 'ZCASH',
|
|
31
|
-
isChainSupported: (
|
|
32
|
-
isUtxoNamespace(chainId) &&
|
|
33
|
-
getChainIdFromCaip2ChainId(chainId) === CAIP_ZCASH_CHAIN_ID,
|
|
30
|
+
isChainSupported: isBip122ChainSupported([CAIP_ZCASH_CHAIN_ID]),
|
|
34
31
|
},
|
|
35
32
|
],
|
|
36
33
|
},
|
|
@@ -1,35 +1,22 @@
|
|
|
1
|
-
import type { UtxoActions } from '@
|
|
1
|
+
import type { UtxoActions } from '@hub3js/bip122';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { builders } from '@hub3js/bip122';
|
|
4
|
+
import { NamespaceBuilder } from '@hub3js/core';
|
|
4
5
|
import * as commonBuilders from '@hub3js/std/builders';
|
|
5
6
|
import { standardizeAndThrowError } from '@hub3js/std/operators';
|
|
6
|
-
import {
|
|
7
|
-
builders,
|
|
8
|
-
CAIP_ZCASH_CHAIN_ID,
|
|
9
|
-
utils,
|
|
10
|
-
} from '@rango-dev/wallets-core/namespaces/utxo';
|
|
11
7
|
|
|
8
|
+
import { utxoActions } from '../../actions/utxo.js';
|
|
12
9
|
import { WALLET_ID } from '../../constants.js';
|
|
13
10
|
|
|
14
|
-
import { getZcashAccounts, requestZcashAccounts } from './helpers.js';
|
|
15
|
-
|
|
16
11
|
const connect = builders
|
|
17
12
|
.connect()
|
|
18
|
-
.action(
|
|
19
|
-
const accounts = await requestZcashAccounts();
|
|
20
|
-
|
|
21
|
-
return utils.formatAccountsToCAIP(accounts, CAIP_ZCASH_CHAIN_ID);
|
|
22
|
-
})
|
|
13
|
+
.action(utxoActions.connect())
|
|
23
14
|
.or(standardizeAndThrowError)
|
|
24
15
|
.build();
|
|
25
16
|
|
|
26
|
-
const canEagerConnect =
|
|
27
|
-
|
|
28
|
-
)
|
|
29
|
-
.action(async () => {
|
|
30
|
-
const accounts = await getZcashAccounts().catch(() => []);
|
|
31
|
-
return accounts.length > 0;
|
|
32
|
-
})
|
|
17
|
+
const canEagerConnect = builders
|
|
18
|
+
.canEagerConnect()
|
|
19
|
+
.action(utxoActions.canEagerConnect())
|
|
33
20
|
.build();
|
|
34
21
|
|
|
35
22
|
const disconnect = commonBuilders.disconnect<UtxoActions>().build();
|
|
@@ -4,9 +4,7 @@ import type { Transfer } from 'rango-types/mainApi';
|
|
|
4
4
|
import { isZcashBlockchain } from '@rango-dev/internal-blockchains';
|
|
5
5
|
import { type GenericSigner, SignerError, SignerErrorCode } from 'rango-types';
|
|
6
6
|
|
|
7
|
-
import { vultisigZcash } from '../../utils.js';
|
|
8
|
-
|
|
9
|
-
import { getZcashAccounts } from './helpers.js';
|
|
7
|
+
import { getZcashAccounts, vultisigZcash } from '../../utils.js';
|
|
10
8
|
|
|
11
9
|
export class Signer implements GenericSigner<Transfer> {
|
|
12
10
|
async signMessage(): Promise<string> {
|
package/src/utils.ts
CHANGED
|
@@ -27,3 +27,12 @@ export function vultisigZcash(): VultisigZcashProviderApi {
|
|
|
27
27
|
|
|
28
28
|
return zcashInstance;
|
|
29
29
|
}
|
|
30
|
+
|
|
31
|
+
export async function requestZcashAccounts(): Promise<string[]> {
|
|
32
|
+
return vultisigZcash().requestAccounts();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// `get_accounts` is the silent variant — it never opens the wallet.
|
|
36
|
+
export async function getZcashAccounts(): Promise<string[]> {
|
|
37
|
+
return vultisigZcash().request({ method: 'get_accounts' });
|
|
38
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/namespaces/utxo/helpers.ts"],"names":[],"mappings":"AAEA,wBAAsB,oBAAoB,sBAEzC;AAGD,wBAAsB,gBAAgB,sBAErC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { vultisigZcash } from '../../utils.js';
|
|
2
|
-
|
|
3
|
-
export async function requestZcashAccounts() {
|
|
4
|
-
return vultisigZcash().requestAccounts();
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
// Get accounts silently
|
|
8
|
-
export async function getZcashAccounts() {
|
|
9
|
-
return await vultisigZcash().request({ method: 'get_accounts' });
|
|
10
|
-
}
|