@rango-dev/provider-vultisig 0.1.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/dist/constants.d.ts +4 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/mod.d.ts +3 -0
- package/dist/mod.d.ts.map +1 -0
- package/dist/mod.js +2 -0
- package/dist/mod.js.map +7 -0
- package/dist/namespaces/utxo/helpers.d.ts +3 -0
- package/dist/namespaces/utxo/helpers.d.ts.map +1 -0
- package/dist/namespaces/utxo/mod.d.ts +3 -0
- package/dist/namespaces/utxo/mod.d.ts.map +1 -0
- package/dist/namespaces/utxo/namespace.d.ts +3 -0
- package/dist/namespaces/utxo/namespace.d.ts.map +1 -0
- package/dist/namespaces/utxo/singer.d.ts +9 -0
- package/dist/namespaces/utxo/singer.d.ts.map +1 -0
- package/dist/provider-vultisig.build.json +1 -0
- package/dist/provider.d.ts +3 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/signer.d.ts +3 -0
- package/dist/signer.d.ts.map +1 -0
- package/dist/types.d.ts +24 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils.d.ts +4 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +30 -0
- package/readme.md +28 -0
- package/src/constants.ts +39 -0
- package/src/mod.ts +8 -0
- package/src/namespaces/utxo/helpers.ts +10 -0
- package/src/namespaces/utxo/mod.ts +2 -0
- package/src/namespaces/utxo/namespace.ts +43 -0
- package/src/namespaces/utxo/singer.ts +58 -0
- package/src/provider.ts +20 -0
- package/src/signer.ts +11 -0
- package/src/types.ts +28 -0
- package/src/utils.ts +29 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,eAAO,MAAM,SAAS,aAAa,CAAC;AAEpC,eAAO,MAAM,IAAI,EAAE,gBA+BlB,CAAC"}
|
package/dist/mod.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,QAAQ,kEAC8C,CAAC;AAE7D,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
package/dist/mod.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var y=Object.defineProperty;var o=(t,e)=>y(t,"name",{value:e,configurable:!0});var r=(t,e)=>()=>(t&&(e=t(t=0)),e);var H=(t,e)=>{for(var i in e)y(t,i,{get:e[i],enumerable:!0})};import{LegacyNetworks as v}from"@rango-dev/wallets-core/legacy";function g(){let{vultisig:t}=window;if(!t)return null;let e=new Map;return t.zcash&&e.set(v.ZCASH,t.zcash),e}function s(){let e=g()?.get(v.ZCASH);if(!e)throw new Error("Vultisig not injected. Please check your wallet.");return e}var a=r(()=>{"use strict";o(g,"vultisig");o(s,"vultisigZcash")});async function S(){return s().requestAccounts()}async function c(){return await s().request({method:"get_accounts"})}var l=r(()=>{"use strict";a();o(S,"requestZcashAccounts");o(c,"getZcashAccounts")});import{ActionBuilder as L,NamespaceBuilder as B}from"@rango-dev/wallets-core";import{builders as D,standardizeAndThrowError as M}from"@rango-dev/wallets-core/namespaces/common";import{builders as N,CAIP_ZCASH_CHAIN_ID as R,utils as q}from"@rango-dev/wallets-core/namespaces/utxo";var V,j,W,m,d=r(()=>{"use strict";f();l();V=N.connect().action(async function(){let t=await S();return q.formatAccountsToCAIP(t,R)}).or(M).build(),j=new L("canEagerConnect").action(async()=>(await c().catch(()=>[])).length>0).build(),W=D.disconnect().build(),m=new B("UTXO",u).action(V).action(W).action(j).build()});import{LegacyNetworks as z}from"@rango-dev/wallets-core/legacy";import{SignerError as h,SignerErrorCode as x}from"rango-types";var p,E=r(()=>{"use strict";a();l();p=class{static{o(this,"Signer")}async signMessage(){throw h.UnimplementedError("signMessage")}async signAndSendTx(e){let{memo:i,fromWalletAddress:w,recipientAddress:_,amount:U,asset:k}=e;if(k.blockchain!==z.ZCASH)throw new Error(`You can not sign ${e.blockChain} using ZCash signer.`);let I=await c();if(w!==I[0])throw new Error("fromWalletAddress is not matched with the connected account");try{let n={method:"send_transaction",params:[{from:w,to:_,value:U,memo:i}]};return{hash:await s().request(n)}}catch(n){throw typeof n=="string"?new h(x.UNEXPECTED_BEHAVIOUR,n,void 0):new h(x.SEND_TX_ERROR,void 0,n)}}}});var T={};H(T,{Signer:()=>p,namespace:()=>m});var b=r(()=>{"use strict";d();E()});import{DefaultSignerFactory as F,TransactionType as O}from"rango-types";async function A(){let{Signer:t}=await Promise.resolve().then(()=>(b(),T)),e=new F;return e.registerSigner(O.TRANSFER,new t),e}var Z=r(()=>{"use strict";o(A,"getSigners")});var u,C,f=r(()=>{"use strict";Z();u="vultisig",C={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",getSupportedChains:t=>t.filter(e=>e.name==="ZCASH")}]}},{name:"signers",value:{getSigners:async()=>A()}}]}});import{defineVersions as G}from"@rango-dev/wallets-core/utils";f();d();a();import{ProviderBuilder as X}from"@rango-dev/wallets-core";var P=o(()=>new X(u).init(function(t){let[,e]=t.state();g()&&(e("installed",!0),console.debug("[vultisig] instance detected.",t))}).config("metadata",C).add("utxo",m).build(),"buildProvider");var Ut=o(()=>G().version("1.0.0",P()).build(),"versions");export{Ut as versions};
|
|
2
|
+
//# sourceMappingURL=mod.js.map
|
package/dist/mod.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/utils.ts", "../src/namespaces/utxo/helpers.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 { LegacyNetworks } from '@rango-dev/wallets-core/legacy';\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(LegacyNetworks.ZCASH, vultisig.zcash);\n }\n\n return instances;\n}\n\nexport function vultisigZcash(): VultisigZcashProviderApi {\n const instances = vultisig();\n const zcashInstance = instances?.get(LegacyNetworks.ZCASH);\n\n if (!zcashInstance) {\n throw new Error('Vultisig not injected. Please check your wallet.');\n }\n\n return zcashInstance;\n}\n", "import { vultisigZcash } from '../../utils.js';\n\nexport async function requestZcashAccounts() {\n return vultisigZcash().requestAccounts();\n}\n\n// Get accounts silently\nexport async function getZcashAccounts() {\n return await vultisigZcash().request({ method: 'get_accounts' });\n}\n", "import type { UtxoActions } from '@rango-dev/wallets-core/namespaces/utxo';\n\nimport { ActionBuilder, NamespaceBuilder } from '@rango-dev/wallets-core';\nimport {\n builders as commonBuilders,\n standardizeAndThrowError,\n} from '@rango-dev/wallets-core/namespaces/common';\nimport {\n builders,\n CAIP_ZCASH_CHAIN_ID,\n utils,\n} from '@rango-dev/wallets-core/namespaces/utxo';\n\nimport { WALLET_ID } from '../../constants.js';\n\nimport { getZcashAccounts, requestZcashAccounts } from './helpers.js';\n\nconst connect = builders\n .connect()\n .action(async function () {\n const accounts = await requestZcashAccounts();\n\n return utils.formatAccountsToCAIP(accounts, CAIP_ZCASH_CHAIN_ID);\n })\n .or(standardizeAndThrowError)\n .build();\n\nconst canEagerConnect = new ActionBuilder<UtxoActions, 'canEagerConnect'>(\n 'canEagerConnect'\n)\n .action(async () => {\n const accounts = await getZcashAccounts().catch(() => []);\n return accounts.length > 0;\n })\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 { LegacyNetworks } from '@rango-dev/wallets-core/legacy';\nimport { type GenericSigner, SignerError, SignerErrorCode } from 'rango-types';\n\nimport { vultisigZcash } from '../../utils.js';\n\nimport { getZcashAccounts } from './helpers.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 (asset.blockchain !== LegacyNetworks.ZCASH) {\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 '@rango-dev/wallets-core';\nimport type { BlockchainMeta } from 'rango-types';\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 getSupportedChains: (allBlockchains: BlockchainMeta[]) =>\n allBlockchains.filter(\n (blockchain) => blockchain.name === 'ZCASH'\n ),\n },\n ],\n },\n },\n {\n name: 'signers',\n value: { getSigners: async () => getSigners() },\n },\n ],\n};\n", "import { defineVersions } from '@rango-dev/wallets-core/utils';\n\nimport { buildProvider } from './provider.js';\n\nconst versions = () =>\n defineVersions().version('1.0.0', buildProvider()).build();\n\nexport { versions };\n", "import { ProviderBuilder } from '@rango-dev/wallets-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": "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",
|
|
6
|
+
"names": ["LegacyNetworks", "vultisig", "instances", "vultisigZcash", "zcashInstance", "init_utils", "__esmMin", "__name", "requestZcashAccounts", "vultisigZcash", "getZcashAccounts", "init_helpers", "__esmMin", "init_utils", "__name", "ActionBuilder", "NamespaceBuilder", "commonBuilders", "standardizeAndThrowError", "builders", "CAIP_ZCASH_CHAIN_ID", "utils", "connect", "canEagerConnect", "disconnect", "namespace", "init_namespace", "__esmMin", "init_constants", "init_helpers", "accounts", "requestZcashAccounts", "getZcashAccounts", "WALLET_ID", "LegacyNetworks", "SignerError", "SignerErrorCode", "Signer", "init_singer", "__esmMin", "init_utils", "init_helpers", "__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", "WALLET_ID", "info", "init_constants", "__esmMin", "init_signer", "allBlockchains", "blockchain", "getSigners", "defineVersions", "init_constants", "init_namespace", "init_utils", "ProviderBuilder", "buildProvider", "__name", "ProviderBuilder", "WALLET_ID", "context", "setState", "vultisig", "info", "namespace", "versions", "__name", "defineVersions", "buildProvider"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/namespaces/utxo/helpers.ts"],"names":[],"mappings":"AAEA,wBAAsB,oBAAoB,sBAEzC;AAGD,wBAAsB,gBAAgB,sBAErC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/namespaces/utxo/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../../../src/namespaces/utxo/namespace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAsC3E,eAAO,MAAM,SAAS,iEAIZ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Transfer } from 'rango-types/mainApi';
|
|
2
|
+
import { type GenericSigner } from 'rango-types';
|
|
3
|
+
export declare class Signer implements GenericSigner<Transfer> {
|
|
4
|
+
signMessage(): Promise<string>;
|
|
5
|
+
signAndSendTx(tx: Transfer): Promise<{
|
|
6
|
+
hash: string;
|
|
7
|
+
}>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=singer.d.ts.map
|
|
@@ -0,0 +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;AAM/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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"src/utils.ts":{"bytes":689,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/namespaces/utxo/helpers.ts":{"bytes":281,"imports":[{"path":"src/utils.ts","kind":"import-statement","original":"../../utils.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/namespaces/utxo/namespace.ts":{"bytes":1198,"imports":[{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/common","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/utxo","kind":"import-statement","external":true},{"path":"src/constants.ts","kind":"import-statement","original":"../../constants.js"},{"path":"src/namespaces/utxo/helpers.ts","kind":"import-statement","original":"./helpers.js"}],"format":"esm"},"src/namespaces/utxo/singer.ts":{"bytes":1834,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"src/utils.ts","kind":"import-statement","original":"../../utils.js"},{"path":"src/namespaces/utxo/helpers.ts","kind":"import-statement","original":"./helpers.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/namespaces/utxo/mod.ts":{"bytes":82,"imports":[{"path":"src/namespaces/utxo/namespace.ts","kind":"import-statement","original":"./namespace.js"},{"path":"src/namespaces/utxo/singer.ts","kind":"import-statement","original":"./singer.js"}],"format":"esm"},"src/signer.ts":{"bytes":403,"imports":[{"path":"rango-types","kind":"import-statement","external":true},{"path":"src/namespaces/utxo/mod.ts","kind":"dynamic-import","original":"./namespaces/utxo/mod.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/constants.ts":{"bytes":1051,"imports":[{"path":"src/signer.ts","kind":"import-statement","original":"./signer.js"}],"format":"esm"},"src/provider.ts":{"bytes":589,"imports":[{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"src/constants.ts","kind":"import-statement","original":"./constants.js"},{"path":"src/namespaces/utxo/namespace.ts","kind":"import-statement","original":"./namespaces/utxo/namespace.js"},{"path":"src/utils.ts","kind":"import-statement","original":"./utils.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/mod.ts":{"bytes":220,"imports":[{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"src/provider.ts","kind":"import-statement","original":"./provider.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/mod.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":11281},"dist/mod.js":{"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/common","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/utxo","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true}],"exports":["versions"],"entryPoint":"src/mod.ts","inputs":{"src/utils.ts":{"bytesInOutput":358},"src/namespaces/utxo/helpers.ts":{"bytesInOutput":201},"src/namespaces/utxo/namespace.ts":{"bytesInOutput":597},"src/namespaces/utxo/singer.ts":{"bytesInOutput":775},"src/namespaces/utxo/mod.ts":{"bytesInOutput":81},"src/signer.ts":{"bytesInOutput":245},"src/constants.ts":{"bytesInOutput":521},"src/mod.ts":{"bytesInOutput":121},"src/provider.ts":{"bytesInOutput":262}},"bytes":3393}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAMA,QAAA,MAAM,aAAa,kDAWP,CAAC;AAEb,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/signer.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD,wBAA8B,UAAU,IAAI,OAAO,CAAC,aAAa,CAAC,CAMjE"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { LegacyNetworks } from '@rango-dev/wallets-core/legacy';
|
|
2
|
+
export type SendTransactionArgs = {
|
|
3
|
+
method: 'send_transaction';
|
|
4
|
+
params: {
|
|
5
|
+
from: string;
|
|
6
|
+
to: string;
|
|
7
|
+
value: string;
|
|
8
|
+
memo: string | null;
|
|
9
|
+
}[];
|
|
10
|
+
};
|
|
11
|
+
export type VultisigZcashProviderApi = {
|
|
12
|
+
requestAccounts: () => Promise<string[]>;
|
|
13
|
+
request: {
|
|
14
|
+
(args: {
|
|
15
|
+
method: 'get_accounts';
|
|
16
|
+
}): Promise<string[]>;
|
|
17
|
+
(args: SendTransactionArgs): Promise<string>;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export type ProviderObject = {
|
|
21
|
+
[LegacyNetworks.ZCASH]: VultisigZcashProviderApi;
|
|
22
|
+
};
|
|
23
|
+
export type Provider = Map<keyof ProviderObject, ProviderObject[keyof ProviderObject]>;
|
|
24
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;KACrB,EAAE,CAAC;CACL,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,eAAe,EAAE,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACzC,OAAO,EAAE;QACP,CAAC,IAAI,EAAE;YAAE,MAAM,EAAE,cAAc,CAAA;SAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QACtD,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;KAC9C,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,wBAAwB,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,GAAG,CACxB,MAAM,cAAc,EACpB,cAAc,CAAC,MAAM,cAAc,CAAC,CACrC,CAAC"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rango-dev/provider-vultisig",
|
|
3
|
+
"version": "0.1.1-next.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"source": "./src/mod.ts",
|
|
7
|
+
"main": "./dist/mod.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./dist/mod.js"
|
|
10
|
+
},
|
|
11
|
+
"typings": "dist/mod.d.ts",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"src"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "node ../../scripts/build/command.mjs --path wallets/provider-vultisig --inputs src/mod.ts",
|
|
18
|
+
"ts-check": "tsc --declaration --emitDeclarationOnly -p ./tsconfig.json",
|
|
19
|
+
"clean": "rimraf dist",
|
|
20
|
+
"format": "prettier --write '{.,src}/**/*.{ts,tsx}'",
|
|
21
|
+
"lint": "eslint \"**/*.{ts,tsx}\""
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@rango-dev/wallets-shared": "^0.59.2-next.0",
|
|
25
|
+
"rango-types": "^0.3.0"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
}
|
|
30
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Vultisig Provider
|
|
2
|
+
|
|
3
|
+
Vultisig integration for hub.
|
|
4
|
+
[Homepage](https://vultisig.com/) | [Docs](https://docs.vultisig.com/)
|
|
5
|
+
|
|
6
|
+
More about implementation status can be found [here](../readme.md).
|
|
7
|
+
|
|
8
|
+
## Implementation notes/limitation
|
|
9
|
+
|
|
10
|
+
### Group
|
|
11
|
+
|
|
12
|
+
#### ⚠️ UTXO
|
|
13
|
+
|
|
14
|
+
Only supports Zcash.
|
|
15
|
+
|
|
16
|
+
### Feature
|
|
17
|
+
|
|
18
|
+
#### ⚠️ Sign transaction
|
|
19
|
+
|
|
20
|
+
It only supports Zcash transparent transactions.
|
|
21
|
+
|
|
22
|
+
### ❌ Switch Account
|
|
23
|
+
|
|
24
|
+
Switch account is not supported because the provider does not emit any events on switch account.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
More wallet information can be found in [readme.md](../readme.md).
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ProviderMetadata } from '@rango-dev/wallets-core';
|
|
2
|
+
import type { BlockchainMeta } from 'rango-types';
|
|
3
|
+
|
|
4
|
+
import getSigners from './signer.js';
|
|
5
|
+
|
|
6
|
+
export const WALLET_ID = 'vultisig';
|
|
7
|
+
|
|
8
|
+
export const info: ProviderMetadata = {
|
|
9
|
+
name: 'Vultisig',
|
|
10
|
+
icon: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/vultisig/icon.svg',
|
|
11
|
+
extensions: {
|
|
12
|
+
chrome:
|
|
13
|
+
'https://chromewebstore.google.com/detail/vultisig-extension/ggafhcdaplkhmmnlbfjpnnkepdfjaelb',
|
|
14
|
+
homepage: 'https://vultisig.com/',
|
|
15
|
+
},
|
|
16
|
+
properties: [
|
|
17
|
+
{
|
|
18
|
+
name: 'namespaces',
|
|
19
|
+
value: {
|
|
20
|
+
selection: 'multiple',
|
|
21
|
+
data: [
|
|
22
|
+
{
|
|
23
|
+
label: 'Zcash',
|
|
24
|
+
value: 'UTXO',
|
|
25
|
+
id: 'ZCASH',
|
|
26
|
+
getSupportedChains: (allBlockchains: BlockchainMeta[]) =>
|
|
27
|
+
allBlockchains.filter(
|
|
28
|
+
(blockchain) => blockchain.name === 'ZCASH'
|
|
29
|
+
),
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'signers',
|
|
36
|
+
value: { getSigners: async () => getSigners() },
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
};
|
package/src/mod.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { UtxoActions } from '@rango-dev/wallets-core/namespaces/utxo';
|
|
2
|
+
|
|
3
|
+
import { ActionBuilder, NamespaceBuilder } from '@rango-dev/wallets-core';
|
|
4
|
+
import {
|
|
5
|
+
builders as commonBuilders,
|
|
6
|
+
standardizeAndThrowError,
|
|
7
|
+
} from '@rango-dev/wallets-core/namespaces/common';
|
|
8
|
+
import {
|
|
9
|
+
builders,
|
|
10
|
+
CAIP_ZCASH_CHAIN_ID,
|
|
11
|
+
utils,
|
|
12
|
+
} from '@rango-dev/wallets-core/namespaces/utxo';
|
|
13
|
+
|
|
14
|
+
import { WALLET_ID } from '../../constants.js';
|
|
15
|
+
|
|
16
|
+
import { getZcashAccounts, requestZcashAccounts } from './helpers.js';
|
|
17
|
+
|
|
18
|
+
const connect = builders
|
|
19
|
+
.connect()
|
|
20
|
+
.action(async function () {
|
|
21
|
+
const accounts = await requestZcashAccounts();
|
|
22
|
+
|
|
23
|
+
return utils.formatAccountsToCAIP(accounts, CAIP_ZCASH_CHAIN_ID);
|
|
24
|
+
})
|
|
25
|
+
.or(standardizeAndThrowError)
|
|
26
|
+
.build();
|
|
27
|
+
|
|
28
|
+
const canEagerConnect = new ActionBuilder<UtxoActions, 'canEagerConnect'>(
|
|
29
|
+
'canEagerConnect'
|
|
30
|
+
)
|
|
31
|
+
.action(async () => {
|
|
32
|
+
const accounts = await getZcashAccounts().catch(() => []);
|
|
33
|
+
return accounts.length > 0;
|
|
34
|
+
})
|
|
35
|
+
.build();
|
|
36
|
+
|
|
37
|
+
const disconnect = commonBuilders.disconnect<UtxoActions>().build();
|
|
38
|
+
|
|
39
|
+
export const namespace = new NamespaceBuilder<UtxoActions>('UTXO', WALLET_ID)
|
|
40
|
+
.action(connect)
|
|
41
|
+
.action(disconnect)
|
|
42
|
+
.action(canEagerConnect)
|
|
43
|
+
.build();
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { SendTransactionArgs } from '../../types.js';
|
|
2
|
+
import type { Transfer } from 'rango-types/mainApi';
|
|
3
|
+
|
|
4
|
+
import { LegacyNetworks } from '@rango-dev/wallets-core/legacy';
|
|
5
|
+
import { type GenericSigner, SignerError, SignerErrorCode } from 'rango-types';
|
|
6
|
+
|
|
7
|
+
import { vultisigZcash } from '../../utils.js';
|
|
8
|
+
|
|
9
|
+
import { getZcashAccounts } from './helpers.js';
|
|
10
|
+
|
|
11
|
+
export class Signer implements GenericSigner<Transfer> {
|
|
12
|
+
async signMessage(): Promise<string> {
|
|
13
|
+
throw SignerError.UnimplementedError('signMessage');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async signAndSendTx(tx: Transfer): Promise<{ hash: string }> {
|
|
17
|
+
const { memo, fromWalletAddress, recipientAddress, amount, asset } = tx;
|
|
18
|
+
|
|
19
|
+
// TODO: check should be performed on the blockchain field of transaction instead of asset, but currently it is not available in the transaction object
|
|
20
|
+
if (asset.blockchain !== LegacyNetworks.ZCASH) {
|
|
21
|
+
throw new Error(`You can not sign ${tx.blockChain} using ZCash signer.`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const accounts = await getZcashAccounts();
|
|
25
|
+
|
|
26
|
+
if (fromWalletAddress !== accounts[0]) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
'fromWalletAddress is not matched with the connected account'
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
const transactionRequest: SendTransactionArgs = {
|
|
34
|
+
method: 'send_transaction',
|
|
35
|
+
params: [
|
|
36
|
+
{
|
|
37
|
+
from: fromWalletAddress,
|
|
38
|
+
to: recipientAddress,
|
|
39
|
+
value: amount,
|
|
40
|
+
memo,
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const response = await vultisigZcash().request(transactionRequest);
|
|
46
|
+
return { hash: response };
|
|
47
|
+
} catch (error) {
|
|
48
|
+
if (typeof error === 'string') {
|
|
49
|
+
throw new SignerError(
|
|
50
|
+
SignerErrorCode.UNEXPECTED_BEHAVIOUR,
|
|
51
|
+
error,
|
|
52
|
+
undefined
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
throw new SignerError(SignerErrorCode.SEND_TX_ERROR, undefined, error);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
package/src/provider.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ProviderBuilder } from '@rango-dev/wallets-core';
|
|
2
|
+
|
|
3
|
+
import { info, WALLET_ID } from './constants.js';
|
|
4
|
+
import { namespace as utxo } from './namespaces/utxo/namespace.js';
|
|
5
|
+
import { vultisig } from './utils.js';
|
|
6
|
+
|
|
7
|
+
const buildProvider = () =>
|
|
8
|
+
new ProviderBuilder(WALLET_ID)
|
|
9
|
+
.init(function (context) {
|
|
10
|
+
const [, setState] = context.state();
|
|
11
|
+
if (vultisig()) {
|
|
12
|
+
setState('installed', true);
|
|
13
|
+
console.debug('[vultisig] instance detected.', context);
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
.config('metadata', info)
|
|
17
|
+
.add('utxo', utxo)
|
|
18
|
+
.build();
|
|
19
|
+
|
|
20
|
+
export { buildProvider };
|
package/src/signer.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SignerFactory } from 'rango-types';
|
|
2
|
+
|
|
3
|
+
import { DefaultSignerFactory, TransactionType as TxType } from 'rango-types';
|
|
4
|
+
|
|
5
|
+
export default async function getSigners(): Promise<SignerFactory> {
|
|
6
|
+
const { Signer: UtxoSigner } = await import('./namespaces/utxo/mod.js');
|
|
7
|
+
const signers = new DefaultSignerFactory();
|
|
8
|
+
|
|
9
|
+
signers.registerSigner(TxType.TRANSFER, new UtxoSigner());
|
|
10
|
+
return signers;
|
|
11
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { LegacyNetworks } from '@rango-dev/wallets-core/legacy';
|
|
2
|
+
|
|
3
|
+
export type SendTransactionArgs = {
|
|
4
|
+
method: 'send_transaction';
|
|
5
|
+
params: {
|
|
6
|
+
from: string;
|
|
7
|
+
to: string;
|
|
8
|
+
value: string;
|
|
9
|
+
memo: string | null;
|
|
10
|
+
}[];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type VultisigZcashProviderApi = {
|
|
14
|
+
requestAccounts: () => Promise<string[]>;
|
|
15
|
+
request: {
|
|
16
|
+
(args: { method: 'get_accounts' }): Promise<string[]>;
|
|
17
|
+
(args: SendTransactionArgs): Promise<string>;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type ProviderObject = {
|
|
22
|
+
[LegacyNetworks.ZCASH]: VultisigZcashProviderApi;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type Provider = Map<
|
|
26
|
+
keyof ProviderObject,
|
|
27
|
+
ProviderObject[keyof ProviderObject]
|
|
28
|
+
>;
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Provider, VultisigZcashProviderApi } from './types.js';
|
|
2
|
+
|
|
3
|
+
import { LegacyNetworks } from '@rango-dev/wallets-core/legacy';
|
|
4
|
+
|
|
5
|
+
export function vultisig(): Provider | null {
|
|
6
|
+
const { vultisig } = window;
|
|
7
|
+
if (!vultisig) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const instances: Provider = new Map();
|
|
12
|
+
|
|
13
|
+
if (vultisig.zcash) {
|
|
14
|
+
instances.set(LegacyNetworks.ZCASH, vultisig.zcash);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return instances;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function vultisigZcash(): VultisigZcashProviderApi {
|
|
21
|
+
const instances = vultisig();
|
|
22
|
+
const zcashInstance = instances?.get(LegacyNetworks.ZCASH);
|
|
23
|
+
|
|
24
|
+
if (!zcashInstance) {
|
|
25
|
+
throw new Error('Vultisig not injected. Please check your wallet.');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return zcashInstance;
|
|
29
|
+
}
|