@rango-dev/provider-trezor 0.30.1-next.0 → 0.30.1-next.2
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/{chunk-HUUVMU7F.js → chunk-BIVSKW7I.js} +2 -2
- package/dist/chunk-LLZFYNTU.js +2 -0
- package/dist/chunk-LLZFYNTU.js.map +7 -0
- package/dist/{ethereum-WJFMSBHD.js → ethereum-CARMJDTY.js} +2 -2
- package/dist/mod.js +1 -1
- package/dist/mod.js.map +3 -3
- package/dist/{utxo-ILXYPRDR.js → utxo-WZHR4KZB.js} +2 -2
- package/package.json +2 -2
- package/src/signer.ts +2 -7
- package/src/utils.ts +1 -4
- package/dist/chunk-FTGT4J2G.js +0 -2
- package/dist/chunk-FTGT4J2G.js.map +0 -7
- /package/dist/{chunk-HUUVMU7F.js.map → chunk-BIVSKW7I.js.map} +0 -0
- /package/dist/{ethereum-WJFMSBHD.js.map → ethereum-CARMJDTY.js.map} +0 -0
- /package/dist/{utxo-ILXYPRDR.js.map → utxo-WZHR4KZB.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as p}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as p}from"./chunk-LLZFYNTU.js";var S="btc",o=[{id:"native-segwit",label:"Native SegWit",purpose:84,inputScriptType:"SPENDWITNESS"},{id:"nested-segwit",label:"Nested SegWit",purpose:49,inputScriptType:"SPENDP2SHWITNESS"},{id:"legacy",label:"Legacy",purpose:44,inputScriptType:"SPENDADDRESS"},{id:"taproot",label:"Taproot",purpose:86,inputScriptType:"SPENDTAPROOT"}];function n(e){let r=Number.parseInt(e.replace(/^m\//,"").split("/")[0]?.replace(/['h]$/,"")??"",10),t=o.find(i=>i.purpose===r);if(!t)throw new Error(`Unsupported Bitcoin derivation path: ${e}`);return t.inputScriptType}p(n,"resolveBitcoinScriptType");export{S as a,o as b,n as c};
|
|
2
|
+
//# sourceMappingURL=chunk-BIVSKW7I.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var s=Object.defineProperty;var e=(t,r)=>s(t,"name",{value:r,configurable:!0});var n="";function l(t){n=t}e(l,"setDerivationPath");function i(){return n}e(i,"getDerivationPath");var a="";function f(t){a=t}e(f,"setBitcoinDerivationPath");function m(){return a}e(m,"getBitcoinDerivationPath");import{ETHEREUM_CHAIN_ID as c}from"@rango-dev/wallets-shared";var v={Failure_ActionCancelled:"User rejected the transaction."};async function u(){let t=await import("@trezor/connect-web");return t.default.default?t.default.default:t.default}e(u,"getTrezorModule");async function x(){let t=await u(),r=i(),o=await t.ethereumGetAddress({path:r});if(!o.success)throw new Error(o.payload.error);return{accounts:[o.payload.address],chainId:c,derivationPath:r}}e(x,"getEthereumAccounts");var z=e(t=>t&&!t.startsWith("m/")?"m/"+t:t,"getTrezorNormalizedDerivationPath");export{e as a,l as b,i as c,f as d,m as e,v as f,u as g,x as h,z as i};
|
|
2
|
+
//# sourceMappingURL=chunk-LLZFYNTU.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/state.ts", "../src/utils.ts"],
|
|
4
|
+
"sourcesContent": ["// We keep derivationPath here because we need to maintain it for signing transactions after it is set in connect method\nlet derivationPath = '';\n\nexport function setDerivationPath(path: string) {\n derivationPath = path;\n}\n\nexport function getDerivationPath() {\n return derivationPath;\n}\n\n/*\n * Bitcoin's connect-time path, kept for the same reason as the EVM one: Rango's PSBT\n * carries no derivation data, so the signer must remember which path to sign with. Kept\n * separate from the EVM path so the two namespaces never collide.\n */\nlet bitcoinDerivationPath = '';\n\nexport function setBitcoinDerivationPath(path: string) {\n bitcoinDerivationPath = path;\n}\n\nexport function getBitcoinDerivationPath() {\n return bitcoinDerivationPath;\n}\n", "import type { TrezorConnect } from '@trezor/connect-web';\n\nimport {\n ETHEREUM_CHAIN_ID,\n type ProviderConnectResult,\n} from '@rango-dev/wallets-shared';\n\nimport { getDerivationPath } from './state.js';\n\nexport const trezorErrorMessages: { [statusCode: string]: string } = {\n Failure_ActionCancelled: 'User rejected the transaction.',\n};\n\n// `@trezor/connect-web` is commonjs, when we are importing it dynamically, it has some differences in different tooling. for example vite (you can check widget-examples), goes throw error. this is a workaround for solving this interop issue.\nexport async function getTrezorModule() {\n const mod = await import('@trezor/connect-web');\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (mod.default.default) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return mod.default.default as unknown as TrezorConnect;\n }\n\n return mod.default;\n}\n\nexport async function getEthereumAccounts(): Promise<ProviderConnectResult> {\n const TrezorConnect = await getTrezorModule();\n const derivationPath = getDerivationPath();\n const result = await TrezorConnect.ethereumGetAddress({\n path: derivationPath,\n });\n\n if (!result.success) {\n throw new Error(result.payload.error);\n }\n\n return {\n accounts: [result.payload.address],\n chainId: ETHEREUM_CHAIN_ID,\n derivationPath,\n };\n}\n\nexport const getTrezorNormalizedDerivationPath = (\n path: string // TrezorConnect needs master node to be added to derivation path\n) => (path && !path.startsWith('m/') ? 'm/' + path : path);\n"],
|
|
5
|
+
"mappings": "+EACA,IAAIA,EAAiB,GAEd,SAASC,EAAkBC,EAAc,CAC9CF,EAAiBE,CACnB,CAFgBC,EAAAF,EAAA,qBAIT,SAASG,GAAoB,CAClC,OAAOJ,CACT,CAFgBG,EAAAC,EAAA,qBAShB,IAAIC,EAAwB,GAErB,SAASC,EAAyBJ,EAAc,CACrDG,EAAwBH,CAC1B,CAFgBC,EAAAG,EAAA,4BAIT,SAASC,GAA2B,CACzC,OAAOF,CACT,CAFgBF,EAAAI,EAAA,4BCpBhB,OACE,qBAAAC,MAEK,4BAIA,IAAMC,EAAwD,CACnE,wBAAyB,gCAC3B,EAGA,eAAsBC,GAAkB,CACtC,IAAMC,EAAM,KAAM,QAAO,qBAAqB,EAG9C,OAAIA,EAAI,QAAQ,QAGPA,EAAI,QAAQ,QAGdA,EAAI,OACb,CAXsBC,EAAAF,EAAA,mBAatB,eAAsBG,GAAsD,CAC1E,IAAMC,EAAgB,MAAMJ,EAAgB,EACtCK,EAAiBC,EAAkB,EACnCC,EAAS,MAAMH,EAAc,mBAAmB,CACpD,KAAMC,CACR,CAAC,EAED,GAAI,CAACE,EAAO,QACV,MAAM,IAAI,MAAMA,EAAO,QAAQ,KAAK,EAGtC,MAAO,CACL,SAAU,CAACA,EAAO,QAAQ,OAAO,EACjC,QAASC,EACT,eAAAH,CACF,CACF,CAhBsBH,EAAAC,EAAA,uBAkBf,IAAMM,EAAoCP,EAC/CQ,GACIA,GAAQ,CAACA,EAAK,WAAW,IAAI,EAAI,KAAOA,EAAOA,EAFJ",
|
|
6
|
+
"names": ["derivationPath", "setDerivationPath", "path", "__name", "getDerivationPath", "bitcoinDerivationPath", "setBitcoinDerivationPath", "getBitcoinDerivationPath", "ETHEREUM_CHAIN_ID", "trezorErrorMessages", "getTrezorModule", "mod", "__name", "getEthereumAccounts", "TrezorConnect", "derivationPath", "getDerivationPath", "result", "ETHEREUM_CHAIN_ID", "getTrezorNormalizedDerivationPath", "path"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as p,c as u,f as P,g as h}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=ethereum-
|
|
1
|
+
import{a as p,c as u,f as P,g as h}from"./chunk-LLZFYNTU.js";import{cleanEvmError as G,toHexQuantity as s}from"@rango-dev/signer-evm";import{DEFAULT_ETHEREUM_RPC_URL as z}from"@rango-dev/wallets-shared";import{JsonRpcProvider as S,Transaction as b}from"ethers";import"rango-types";function R(r){return typeof r=="object"&&r!==null&&"shortMessage"in r&&typeof r.shortMessage=="string"?new Error(r.shortMessage,{cause:r}):G(r)}p(R,"getTrezorErrorMessage");var f=class{static{p(this,"EthereumSigner")}async signMessage(e){let a=await h(),{success:o,payload:t}=await a.ethereumSignMessage({message:e,path:u()});if(!o)throw new Error(t.error);return t.signature}async signAndSendTx(e,a,o){try{let t=await h(),{gasPrice:w,maxFeePerGas:i,maxPriorityFeePerGas:c}=e,n=i&&c;if(n&&!i)throw new Error("Missing maxFeePerGas");if(n&&!c)throw new Error("Missing maxPriorityFeePerGas");if(!n&&!w)throw new Error("Missing gasPrice");let d=new S(z),E=await d.getTransactionCount(a),l=n?{maxFeePerGas:s(i||"0"),maxPriorityFeePerGas:s(c||"0")}:{gasPrice:s(w||"0")},g={to:e.to,data:e.data||"0x",value:s(e.value?.toString()||"0"),gasLimit:s(e.gasLimit?.toString()||"0"),chainId:Number.parseInt(o),nonce:s(E.toString()),...l},{success:y,payload:m}=await t.ethereumSignTransaction({path:u(),transaction:g});if(!y){let F=P[m?.code||""]||m.error;throw new Error(F)}let{r:T,s:M,v}=m,x=b.from({...g,nonce:Number.parseInt(g.nonce),type:n?2:0,signature:{r:T,s:M,v:parseInt(v)}}).serialized;return{hash:(await d.broadcastTransaction(x)).hash}}catch(t){throw R(t)}}};export{f as EthereumSigner,R as getTrezorErrorMessage};
|
|
2
|
+
//# sourceMappingURL=ethereum-CARMJDTY.js.map
|
package/dist/mod.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as f,b as g,c as T}from"./chunk-
|
|
1
|
+
import{a as f,b as g,c as T}from"./chunk-BIVSKW7I.js";import{a as o,b as d,d as u,g as a,h as l,i as s}from"./chunk-LLZFYNTU.js";import{defineVersions as tt}from"@hub3js/core/utils";import{ProviderBuilder as Q}from"@hub3js/core";import{CAIP_ETHEREUM_CHAIN_ID as N,isEvmNamespace as B}from"@hub3js/evm";import{getChainIdFromCaip2ChainId as h}from"@hub3js/std/utils";import{CAIP_BITCOIN_CHAIN_ID as L,isUtxoNamespace as U}from"@rango-dev/wallets-core/namespaces/utxo";import{WalletTypes as O}from"@rango-dev/wallets-shared";import{DefaultSignerFactory as M,TransactionType as v}from"rango-types";async function p(){let t=new M,{EthereumSigner:e}=await import("./ethereum-CARMJDTY.js"),{BTCSigner:r}=await import("./utxo-WZHR4KZB.js");return t.registerSigner(v.EVM,new e),t.registerSigner(v.TRANSFER,new r),t}o(p,"getSigners");var i=O.TREZOR,E={name:"Trezor",icon:"https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/trezor/icon.svg",extensions:{homepage:"https://trezor.io/learn/a/download-verify-trezor-suite"},properties:[{name:"namespaces",value:{selection:"single",data:[{label:"Ethereum",value:"EVM",id:"ETH",isChainSupported:t=>B(t)&&h(t)===N},{label:"Bitcoin",value:"UTXO",id:"BTC",isChainSupported:t=>U(t)&&h(t)===L}]}},{name:"derivationPath",value:{data:[{id:"metamask",label:"Metamask (m/44'/60'/0'/0/index)",namespace:"EVM",generateDerivationPath:t=>`44'/60'/0'/0/${t}`},{id:"ledgerLive",label:"LedgerLive (m/44'/60'/index'/0/0)",namespace:"EVM",generateDerivationPath:t=>`44'/60'/${t}'/0/0`},{id:"legacy",label:"Legacy (m/44'/60'/0'/index)",namespace:"EVM",generateDerivationPath:t=>`44'/60'/0'/${t}`},...g.map(t=>({id:`bitcoin-${t.id}`,label:`${t.label} (m/${t.purpose}'/0'/index')`,namespace:"UTXO",generateDerivationPath:e=>`${t.purpose}'/0'/${e}'/0/0`}))]}},{name:"signers",value:{getSigners:async()=>p()}}]};import{NamespaceBuilder as $}from"@hub3js/core";import{builders as w,utils as F}from"@hub3js/evm";import*as C from"@hub3js/std/builders";import{standardizeAndThrowError as H}from"@hub3js/std/operators";import{ETHEREUM_CHAIN_ID as R}from"@rango-dev/wallets-shared";var x=!1;async function m(){if(x)return;await(await a()).init({lazyLoad:!0,manifest:A()}),x=!0}o(m,"initTrezor");var V=w.connect().action(async function(t,e,r){if(!r?.derivationPath)throw new Error("Derivation Path can not be empty.");d(s(r.derivationPath)),await m();let n=await l();return{accounts:F.formatAccountsToCAIP(n.accounts,n.chainId),network:n.chainId}}).or(H).build(),W=C.disconnect().build(),j=w.getChainId().action(()=>R).build(),I=new $("EVM",i).action(V).action(W).action(j).build();import{NamespaceBuilder as Y}from"@hub3js/core";import*as y from"@hub3js/std/builders";import{standardizeAndThrowError as Z}from"@hub3js/std/operators";import{builders as G}from"@rango-dev/wallets-core/namespaces/utxo";import{CAIP_BITCOIN_CHAIN_ID as k,utils as X}from"@rango-dev/wallets-core/namespaces/utxo";function q(){return async(t,e)=>{if(!e?.derivationPath)throw new Error("Derivation Path can not be empty.");await m();let r=s(e.derivationPath),n=T(r);u(r);let c=await(await a()).getAddress({path:r,coin:f,scriptType:n,showOnTrezor:!1});if(!c.success)throw new Error(c.payload.error);let{address:S}=c.payload;return X.formatAccountsToCAIP([S],k)}}o(q,"connect");var b={connect:q};var J=G.connect().action(b.connect()).or(Z).build(),K=y.disconnect().build(),z=new Y("UTXO",i).action(J).action(K).build();var P,A=o(()=>P,"getTrezorManifest"),_=o(()=>new Q(i).init(function(t,e){let[,r]=t.state();if(!e.manifest)throw new Error("Trezor manifest is required");P=e.manifest,r("installed",!0),console.debug("[trezor] instance detected.",t)}).config("metadata",E).add("evm",I).add("utxo",z).build(),"buildProvider");var kt=o(()=>tt().version("1.0.0",_()).build(),"versions");export{kt 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
3
|
"sources": ["../src/mod.ts", "../src/provider.ts", "../src/constants.ts", "../src/signer.ts", "../src/namespaces/evm.ts", "../src/init.ts", "../src/namespaces/utxo.ts", "../src/actions/utxo.ts"],
|
|
4
|
-
"sourcesContent": ["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 };\n", "import type { Environments } from './types.js';\n\nimport { ProviderBuilder } from '@hub3js/core';\n\nimport { metadata, WALLET_ID } from './constants.js';\nimport { evm } from './namespaces/evm.js';\nimport { utxo } from './namespaces/utxo.js';\n\nlet trezorManifest: Environments['manifest'];\n\nexport const getTrezorManifest = () => trezorManifest;\n\nconst buildProvider = () =>\n new ProviderBuilder(WALLET_ID)\n .init(function (context, environments: Environments) {\n const [, setState] = context.state();\n\n if (!environments.manifest) {\n throw new Error('Trezor manifest is required');\n }\n\n trezorManifest = environments.manifest;\n setState('installed', true);\n console.debug('[trezor] instance detected.', context);\n })\n .config('metadata', metadata)\n .add('evm', evm)\n .add('utxo', utxo)\n .build();\n\nexport { buildProvider };\n", "import type { ProviderMetadata } from '@hub3js/core';\n\nimport { CAIP_ETHEREUM_CHAIN_ID, isEvmNamespace } from '@hub3js/evm';\nimport { getChainIdFromCaip2ChainId } from '@hub3js/std/utils';\nimport {\n CAIP_BITCOIN_CHAIN_ID,\n isUtxoNamespace,\n} from '@rango-dev/wallets-core/namespaces/utxo';\nimport { WalletTypes } from '@rango-dev/wallets-shared';\n\nimport getSigners from './signer.js';\nimport { BITCOIN_ADDRESS_TYPES } from './utxo/config.js';\n\nexport const WALLET_ID = WalletTypes.TREZOR;\n\nexport const metadata: ProviderMetadata = {\n name: 'Trezor',\n icon: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/trezor/icon.svg',\n extensions: {\n homepage: 'https://trezor.io/learn/a/download-verify-trezor-suite',\n },\n properties: [\n {\n name: 'namespaces',\n value: {\n selection: 'single',\n data: [\n {\n label: 'Ethereum',\n value: 'EVM',\n id: 'ETH',\n isChainSupported: (chainId: string) =>\n isEvmNamespace(chainId) &&\n getChainIdFromCaip2ChainId(chainId) === CAIP_ETHEREUM_CHAIN_ID,\n },\n {\n label: 'Bitcoin',\n value: 'UTXO',\n id: 'BTC',\n isChainSupported: (chainId: string) =>\n isUtxoNamespace(chainId) &&\n getChainIdFromCaip2ChainId(chainId) === CAIP_BITCOIN_CHAIN_ID,\n },\n ],\n },\n },\n {\n name: 'derivationPath',\n value: {\n data: [\n {\n id: 'metamask',\n label: `Metamask (m/44'/60'/0'/0/index)`,\n namespace: 'EVM',\n generateDerivationPath: (index: string) => `44'/60'/0'/0/${index}`,\n },\n {\n id: 'ledgerLive',\n label: `LedgerLive (m/44'/60'/index'/0/0)`,\n namespace: 'EVM',\n generateDerivationPath: (index: string) => `44'/60'/${index}'/0/0`,\n },\n {\n id: 'legacy',\n label: `Legacy (m/44'/60'/0'/index)`,\n namespace: 'EVM',\n generateDerivationPath: (index: string) => `44'/60'/0'/${index}`,\n },\n /*\n * Bitcoin derivation templates. The BIP-43 purpose (and thus the address\n * type) is what the user picks here; `index` selects the account.\n */\n ...BITCOIN_ADDRESS_TYPES.map((addressType) => ({\n id: `bitcoin-${addressType.id}`,\n label: `${addressType.label} (m/${addressType.purpose}'/0'/index')`,\n namespace: 'UTXO',\n generateDerivationPath: (index: string) =>\n `${addressType.purpose}'/0'/${index}'/0/0`,\n })),\n ],\n },\n },\n {\n name: 'signers',\n value: { getSigners: async () => getSigners() },\n },\n ],\n};\n", "import type { SignerFactory } from 'rango-types';\n\nimport {
|
|
5
|
-
"mappings": "iIAAA,OAAS,kBAAAA,OAAsB,qBCE/B,OAAS,mBAAAC,
|
|
6
|
-
"names": ["defineVersions", "ProviderBuilder", "CAIP_ETHEREUM_CHAIN_ID", "isEvmNamespace", "getChainIdFromCaip2ChainId", "CAIP_BITCOIN_CHAIN_ID", "isUtxoNamespace", "WalletTypes", "
|
|
4
|
+
"sourcesContent": ["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 };\n", "import type { Environments } from './types.js';\n\nimport { ProviderBuilder } from '@hub3js/core';\n\nimport { metadata, WALLET_ID } from './constants.js';\nimport { evm } from './namespaces/evm.js';\nimport { utxo } from './namespaces/utxo.js';\n\nlet trezorManifest: Environments['manifest'];\n\nexport const getTrezorManifest = () => trezorManifest;\n\nconst buildProvider = () =>\n new ProviderBuilder(WALLET_ID)\n .init(function (context, environments: Environments) {\n const [, setState] = context.state();\n\n if (!environments.manifest) {\n throw new Error('Trezor manifest is required');\n }\n\n trezorManifest = environments.manifest;\n setState('installed', true);\n console.debug('[trezor] instance detected.', context);\n })\n .config('metadata', metadata)\n .add('evm', evm)\n .add('utxo', utxo)\n .build();\n\nexport { buildProvider };\n", "import type { ProviderMetadata } from '@hub3js/core';\n\nimport { CAIP_ETHEREUM_CHAIN_ID, isEvmNamespace } from '@hub3js/evm';\nimport { getChainIdFromCaip2ChainId } from '@hub3js/std/utils';\nimport {\n CAIP_BITCOIN_CHAIN_ID,\n isUtxoNamespace,\n} from '@rango-dev/wallets-core/namespaces/utxo';\nimport { WalletTypes } from '@rango-dev/wallets-shared';\n\nimport getSigners from './signer.js';\nimport { BITCOIN_ADDRESS_TYPES } from './utxo/config.js';\n\nexport const WALLET_ID = WalletTypes.TREZOR;\n\nexport const metadata: ProviderMetadata = {\n name: 'Trezor',\n icon: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/trezor/icon.svg',\n extensions: {\n homepage: 'https://trezor.io/learn/a/download-verify-trezor-suite',\n },\n properties: [\n {\n name: 'namespaces',\n value: {\n selection: 'single',\n data: [\n {\n label: 'Ethereum',\n value: 'EVM',\n id: 'ETH',\n isChainSupported: (chainId: string) =>\n isEvmNamespace(chainId) &&\n getChainIdFromCaip2ChainId(chainId) === CAIP_ETHEREUM_CHAIN_ID,\n },\n {\n label: 'Bitcoin',\n value: 'UTXO',\n id: 'BTC',\n isChainSupported: (chainId: string) =>\n isUtxoNamespace(chainId) &&\n getChainIdFromCaip2ChainId(chainId) === CAIP_BITCOIN_CHAIN_ID,\n },\n ],\n },\n },\n {\n name: 'derivationPath',\n value: {\n data: [\n {\n id: 'metamask',\n label: `Metamask (m/44'/60'/0'/0/index)`,\n namespace: 'EVM',\n generateDerivationPath: (index: string) => `44'/60'/0'/0/${index}`,\n },\n {\n id: 'ledgerLive',\n label: `LedgerLive (m/44'/60'/index'/0/0)`,\n namespace: 'EVM',\n generateDerivationPath: (index: string) => `44'/60'/${index}'/0/0`,\n },\n {\n id: 'legacy',\n label: `Legacy (m/44'/60'/0'/index)`,\n namespace: 'EVM',\n generateDerivationPath: (index: string) => `44'/60'/0'/${index}`,\n },\n /*\n * Bitcoin derivation templates. The BIP-43 purpose (and thus the address\n * type) is what the user picks here; `index` selects the account.\n */\n ...BITCOIN_ADDRESS_TYPES.map((addressType) => ({\n id: `bitcoin-${addressType.id}`,\n label: `${addressType.label} (m/${addressType.purpose}'/0'/index')`,\n namespace: 'UTXO',\n generateDerivationPath: (index: string) =>\n `${addressType.purpose}'/0'/${index}'/0/0`,\n })),\n ],\n },\n },\n {\n name: 'signers',\n value: { getSigners: async () => getSigners() },\n },\n ],\n};\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 signers = new DefaultSignerFactory();\n const { EthereumSigner } = await import('./signers/ethereum.js');\n const { BTCSigner } = await import('./signers/utxo.js');\n signers.registerSigner(TxType.EVM, new EthereumSigner());\n signers.registerSigner(TxType.TRANSFER, new BTCSigner());\n return signers;\n}\n", "import type { EvmActions } from '@hub3js/evm';\n\nimport { NamespaceBuilder } from '@hub3js/core';\nimport { builders, utils } from '@hub3js/evm';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\nimport { ETHEREUM_CHAIN_ID } from '@rango-dev/wallets-shared';\n\nimport { WALLET_ID } from '../constants.js';\nimport { initTrezor } from '../init.js';\nimport { setDerivationPath } from '../state.js';\nimport {\n getEthereumAccounts,\n getTrezorNormalizedDerivationPath,\n} from '../utils.js';\n\nconst connect = builders\n .connect()\n .action(async function (_context, _chain, options) {\n if (!options?.derivationPath) {\n throw new Error('Derivation Path can not be empty.');\n }\n setDerivationPath(\n getTrezorNormalizedDerivationPath(options.derivationPath)\n );\n\n await initTrezor();\n\n const result = await getEthereumAccounts();\n\n const formatAccounts = utils.formatAccountsToCAIP(\n result.accounts,\n result.chainId\n );\n\n return {\n accounts: formatAccounts,\n network: result.chainId,\n };\n })\n .or(standardizeAndThrowError)\n .build();\n\nconst disconnect = commonBuilders.disconnect<EvmActions>().build();\n\nconst getChainId = builders\n .getChainId()\n .action(() => ETHEREUM_CHAIN_ID)\n .build();\n\nconst evm = new NamespaceBuilder<EvmActions>('EVM', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .action(getChainId)\n .build();\n\nexport { evm };\n", "import { getTrezorManifest } from './provider.js';\nimport { getTrezorModule } from './utils.js';\n\nlet isTrezorInitialized = false;\n\n/*\n * `TrezorConnect.init` throws if called twice, so initialization is shared across every\n * namespace (EVM, UTXO). `lazyLoad` defers iframe injection until the first method call.\n */\nexport async function initTrezor() {\n if (isTrezorInitialized) {\n return;\n }\n const TrezorConnect = await getTrezorModule();\n await TrezorConnect.init({\n lazyLoad: true,\n manifest: getTrezorManifest(),\n });\n isTrezorInitialized = true;\n}\n", "import type { UtxoActions } from '@rango-dev/wallets-core/namespaces/utxo';\n\nimport { NamespaceBuilder } from '@hub3js/core';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\nimport { builders } from '@rango-dev/wallets-core/namespaces/utxo';\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 disconnect = commonBuilders.disconnect<UtxoActions>().build();\n\nconst utxo = new NamespaceBuilder<UtxoActions>('UTXO', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .build();\n\nexport { utxo };\n", "import type { Context, FunctionWithContext } from '@hub3js/core';\nimport type { UtxoActions } from '@rango-dev/wallets-core/namespaces/utxo';\n\nimport {\n CAIP_BITCOIN_CHAIN_ID,\n utils,\n} from '@rango-dev/wallets-core/namespaces/utxo';\n\nimport { initTrezor } from '../init.js';\nimport { setBitcoinDerivationPath } from '../state.js';\nimport {\n getTrezorModule,\n getTrezorNormalizedDerivationPath,\n} from '../utils.js';\nimport { BITCOIN_COIN_NAME, resolveBitcoinScriptType } from '../utxo/config.js';\n\n/**\n * Connect the Bitcoin account for the selected derivation path: derive the receive\n * address and return it CAIP-encoded with the bip122 Bitcoin chain id. The path is kept\n * (like the EVM namespace does) because Rango's PSBT has no derivation data, so the\n * signer needs it at signing time.\n */\nexport function connect(): FunctionWithContext<\n UtxoActions['connect'],\n Context\n> {\n return async (_context, options) => {\n if (!options?.derivationPath) {\n throw new Error('Derivation Path can not be empty.');\n }\n\n await initTrezor();\n\n const path = getTrezorNormalizedDerivationPath(options.derivationPath);\n const inputScriptType = resolveBitcoinScriptType(path);\n setBitcoinDerivationPath(path);\n\n const TrezorConnect = await getTrezorModule();\n const result = await TrezorConnect.getAddress({\n path,\n coin: BITCOIN_COIN_NAME,\n scriptType: inputScriptType,\n showOnTrezor: false,\n });\n\n if (!result.success) {\n throw new Error(result.payload.error);\n }\n\n const { address } = result.payload;\n\n return utils.formatAccountsToCAIP([address], CAIP_BITCOIN_CHAIN_ID);\n };\n}\n\nexport const utxoActions = { connect };\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["defineVersions", "ProviderBuilder", "CAIP_ETHEREUM_CHAIN_ID", "isEvmNamespace", "getChainIdFromCaip2ChainId", "CAIP_BITCOIN_CHAIN_ID", "isUtxoNamespace", "WalletTypes", "DefaultSignerFactory", "TxType", "getSigners", "signers", "DefaultSignerFactory", "EthereumSigner", "BTCSigner", "TxType", "__name", "WALLET_ID", "WalletTypes", "metadata", "chainId", "isEvmNamespace", "getChainIdFromCaip2ChainId", "CAIP_ETHEREUM_CHAIN_ID", "isUtxoNamespace", "CAIP_BITCOIN_CHAIN_ID", "index", "BITCOIN_ADDRESS_TYPES", "addressType", "getSigners", "NamespaceBuilder", "builders", "utils", "commonBuilders", "standardizeAndThrowError", "ETHEREUM_CHAIN_ID", "isTrezorInitialized", "initTrezor", "getTrezorModule", "getTrezorManifest", "__name", "connect", "builders", "_context", "_chain", "options", "setDerivationPath", "getTrezorNormalizedDerivationPath", "initTrezor", "result", "getEthereumAccounts", "utils", "standardizeAndThrowError", "disconnect", "getChainId", "ETHEREUM_CHAIN_ID", "evm", "NamespaceBuilder", "WALLET_ID", "NamespaceBuilder", "commonBuilders", "standardizeAndThrowError", "builders", "CAIP_BITCOIN_CHAIN_ID", "utils", "connect", "_context", "options", "initTrezor", "path", "getTrezorNormalizedDerivationPath", "inputScriptType", "resolveBitcoinScriptType", "setBitcoinDerivationPath", "result", "getTrezorModule", "BITCOIN_COIN_NAME", "address", "utils", "CAIP_BITCOIN_CHAIN_ID", "__name", "utxoActions", "connect", "builders", "utxoActions", "standardizeAndThrowError", "disconnect", "utxo", "NamespaceBuilder", "WALLET_ID", "trezorManifest", "getTrezorManifest", "__name", "buildProvider", "ProviderBuilder", "WALLET_ID", "context", "environments", "setState", "metadata", "evm", "utxo", "versions", "__name", "defineVersions", "buildProvider"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as d,c as h}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=utxo-
|
|
1
|
+
import{a as d,c as h}from"./chunk-BIVSKW7I.js";import{a as s,e as g,g as m}from"./chunk-LLZFYNTU.js";import{isBitcoinBlockchain as B}from"@rango-dev/wallets-shared";import{SignerError as S}from"rango-types";import*as x from"@bitcoinerlab/secp256k1";import*as n from"bitcoinjs-lib";n.initEccLib(x);var z=s(o=>Buffer.from(o).reverse().toString("hex"),"reverseTxid");function l(o,e,c=n.networks.bitcoin){let r=n.Psbt.fromBase64(o,{network:c}),u=h(e),T=r.txInputs.map((t,p)=>{let i=r.data.inputs[p];if(i.sighashType!=null&&i.sighashType!==n.Transaction.SIGHASH_ALL)throw new Error(`PSBT input #${p} uses sighash type ${i.sighashType}; only SIGHASH_ALL is supported.`);let a=i.witnessUtxo??n.Transaction.fromBuffer(i.nonWitnessUtxo).outs[t.index];return{address_n:e,prev_hash:z(t.hash),prev_index:t.index,amount:a.value.toString(),script_type:u,sequence:t.sequence}}),f=r.txOutputs.map(t=>t.address?{script_type:"PAYTOADDRESS",address:t.address,amount:t.value.toString()}:{script_type:"PAYTOOPRETURN",amount:"0",op_return_data:(n.script.decompile(t.script)?.find(Buffer.isBuffer)??Buffer.alloc(0)).toString("hex")});return{inputs:T,outputs:f,version:r.version,locktime:r.locktime}}s(l,"buildTrezorBitcoinTransaction");function w(o){return new Error(o.code?`${o.error} (${o.code})`:o.error)}s(w,"getTrezorErrorMessage");var b=class{static{s(this,"BTCSigner")}async signMessage(){throw S.UnimplementedError("signMessage")}async signAndSendTx(e){let{blockchain:c}=e.asset;if(!B(c))throw new Error(`Signing ${c} transactions is not supported by Trezor.`);let{psbt:r}=e;if(!r)throw new Error("No PSBT found to sign. Ensure a valid PSBT is provided.");let u=g();if(!u)throw new Error("No connected Bitcoin account found. Please connect the wallet first.");let T=await m(),{inputs:f,outputs:t,version:p,locktime:i}=l(r.unsignedPsbtBase64,u),a=await T.signTransaction({coin:d,inputs:f,outputs:t,version:p,locktime:i,push:!0});if(!a.success)throw w(a.payload);return{hash:await this.#r(a.payload)}}async#r(e){if(e.txid)return e.txid;if(!e.serializedTx)throw new Error("Trezor did not return a transaction id.");let r=await(await m()).pushTransaction({tx:e.serializedTx,coin:d});if(!r.success)throw w(r.payload);return r.payload.txid}};export{b as BTCSigner};
|
|
2
|
+
//# sourceMappingURL=utxo-WZHR4KZB.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/provider-trezor",
|
|
3
|
-
"version": "0.30.1-next.
|
|
3
|
+
"version": "0.30.1-next.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/mod.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@hub3js/std": "^0.2.3",
|
|
28
28
|
"@rango-dev/signer-evm": "^0.45.0",
|
|
29
29
|
"@rango-dev/wallets-core": "^0.61.0",
|
|
30
|
-
"@rango-dev/wallets-shared": "^0.62.1-next.
|
|
30
|
+
"@rango-dev/wallets-shared": "^0.62.1-next.2",
|
|
31
31
|
"@trezor/connect-web": "^9.5.0",
|
|
32
32
|
"bitcoinjs-lib": "^6.1.7",
|
|
33
33
|
"ethers": "^6.13.2",
|
package/src/signer.ts
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import type { SignerFactory } from 'rango-types';
|
|
2
2
|
|
|
3
|
-
import { dynamicImportWithRefinedError } from '@rango-dev/wallets-shared';
|
|
4
3
|
import { DefaultSignerFactory, TransactionType as TxType } from 'rango-types';
|
|
5
4
|
|
|
6
5
|
export default async function getSigners(): Promise<SignerFactory> {
|
|
7
6
|
const signers = new DefaultSignerFactory();
|
|
8
|
-
const { EthereumSigner } = await
|
|
9
|
-
|
|
10
|
-
);
|
|
11
|
-
const { BTCSigner } = await dynamicImportWithRefinedError(
|
|
12
|
-
async () => await import('./signers/utxo.js')
|
|
13
|
-
);
|
|
7
|
+
const { EthereumSigner } = await import('./signers/ethereum.js');
|
|
8
|
+
const { BTCSigner } = await import('./signers/utxo.js');
|
|
14
9
|
signers.registerSigner(TxType.EVM, new EthereumSigner());
|
|
15
10
|
signers.registerSigner(TxType.TRANSFER, new BTCSigner());
|
|
16
11
|
return signers;
|
package/src/utils.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { TrezorConnect } from '@trezor/connect-web';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
dynamicImportWithRefinedError,
|
|
5
4
|
ETHEREUM_CHAIN_ID,
|
|
6
5
|
type ProviderConnectResult,
|
|
7
6
|
} from '@rango-dev/wallets-shared';
|
|
@@ -14,9 +13,7 @@ export const trezorErrorMessages: { [statusCode: string]: string } = {
|
|
|
14
13
|
|
|
15
14
|
// `@trezor/connect-web` is commonjs, when we are importing it dynamically, it has some differences in different tooling. for example vite (you can check widget-examples), goes throw error. this is a workaround for solving this interop issue.
|
|
16
15
|
export async function getTrezorModule() {
|
|
17
|
-
const mod = await
|
|
18
|
-
async () => await import('@trezor/connect-web')
|
|
19
|
-
);
|
|
16
|
+
const mod = await import('@trezor/connect-web');
|
|
20
17
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
21
18
|
// @ts-ignore
|
|
22
19
|
if (mod.default.default) {
|
package/dist/chunk-FTGT4J2G.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var s=Object.defineProperty;var e=(t,r)=>s(t,"name",{value:r,configurable:!0});var n="";function l(t){n=t}e(l,"setDerivationPath");function i(){return n}e(i,"getDerivationPath");var a="";function m(t){a=t}e(m,"setBitcoinDerivationPath");function p(){return a}e(p,"getBitcoinDerivationPath");import{dynamicImportWithRefinedError as c,ETHEREUM_CHAIN_ID as u}from"@rango-dev/wallets-shared";var w={Failure_ActionCancelled:"User rejected the transaction."};async function d(){let t=await c(async()=>await import("@trezor/connect-web"));return t.default.default?t.default.default:t.default}e(d,"getTrezorModule");async function x(){let t=await d(),r=i(),o=await t.ethereumGetAddress({path:r});if(!o.success)throw new Error(o.payload.error);return{accounts:[o.payload.address],chainId:u,derivationPath:r}}e(x,"getEthereumAccounts");var y=e(t=>t&&!t.startsWith("m/")?"m/"+t:t,"getTrezorNormalizedDerivationPath");export{e as a,l as b,i as c,m as d,p as e,w as f,d as g,x as h,y as i};
|
|
2
|
-
//# sourceMappingURL=chunk-FTGT4J2G.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/state.ts", "../src/utils.ts"],
|
|
4
|
-
"sourcesContent": ["// We keep derivationPath here because we need to maintain it for signing transactions after it is set in connect method\nlet derivationPath = '';\n\nexport function setDerivationPath(path: string) {\n derivationPath = path;\n}\n\nexport function getDerivationPath() {\n return derivationPath;\n}\n\n/*\n * Bitcoin's connect-time path, kept for the same reason as the EVM one: Rango's PSBT\n * carries no derivation data, so the signer must remember which path to sign with. Kept\n * separate from the EVM path so the two namespaces never collide.\n */\nlet bitcoinDerivationPath = '';\n\nexport function setBitcoinDerivationPath(path: string) {\n bitcoinDerivationPath = path;\n}\n\nexport function getBitcoinDerivationPath() {\n return bitcoinDerivationPath;\n}\n", "import type { TrezorConnect } from '@trezor/connect-web';\n\nimport {\n dynamicImportWithRefinedError,\n ETHEREUM_CHAIN_ID,\n type ProviderConnectResult,\n} from '@rango-dev/wallets-shared';\n\nimport { getDerivationPath } from './state.js';\n\nexport const trezorErrorMessages: { [statusCode: string]: string } = {\n Failure_ActionCancelled: 'User rejected the transaction.',\n};\n\n// `@trezor/connect-web` is commonjs, when we are importing it dynamically, it has some differences in different tooling. for example vite (you can check widget-examples), goes throw error. this is a workaround for solving this interop issue.\nexport async function getTrezorModule() {\n const mod = await dynamicImportWithRefinedError(\n async () => await import('@trezor/connect-web')\n );\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (mod.default.default) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return mod.default.default as unknown as TrezorConnect;\n }\n\n return mod.default;\n}\n\nexport async function getEthereumAccounts(): Promise<ProviderConnectResult> {\n const TrezorConnect = await getTrezorModule();\n const derivationPath = getDerivationPath();\n const result = await TrezorConnect.ethereumGetAddress({\n path: derivationPath,\n });\n\n if (!result.success) {\n throw new Error(result.payload.error);\n }\n\n return {\n accounts: [result.payload.address],\n chainId: ETHEREUM_CHAIN_ID,\n derivationPath,\n };\n}\n\nexport const getTrezorNormalizedDerivationPath = (\n path: string // TrezorConnect needs master node to be added to derivation path\n) => (path && !path.startsWith('m/') ? 'm/' + path : path);\n"],
|
|
5
|
-
"mappings": "+EACA,IAAIA,EAAiB,GAEd,SAASC,EAAkBC,EAAc,CAC9CF,EAAiBE,CACnB,CAFgBC,EAAAF,EAAA,qBAIT,SAASG,GAAoB,CAClC,OAAOJ,CACT,CAFgBG,EAAAC,EAAA,qBAShB,IAAIC,EAAwB,GAErB,SAASC,EAAyBJ,EAAc,CACrDG,EAAwBH,CAC1B,CAFgBC,EAAAG,EAAA,4BAIT,SAASC,GAA2B,CACzC,OAAOF,CACT,CAFgBF,EAAAI,EAAA,4BCpBhB,OACE,iCAAAC,EACA,qBAAAC,MAEK,4BAIA,IAAMC,EAAwD,CACnE,wBAAyB,gCAC3B,EAGA,eAAsBC,GAAkB,CACtC,IAAMC,EAAM,MAAMC,EAChB,SAAY,KAAM,QAAO,qBAAqB,CAChD,EAGA,OAAID,EAAI,QAAQ,QAGPA,EAAI,QAAQ,QAGdA,EAAI,OACb,CAbsBE,EAAAH,EAAA,mBAetB,eAAsBI,GAAsD,CAC1E,IAAMC,EAAgB,MAAML,EAAgB,EACtCM,EAAiBC,EAAkB,EACnCC,EAAS,MAAMH,EAAc,mBAAmB,CACpD,KAAMC,CACR,CAAC,EAED,GAAI,CAACE,EAAO,QACV,MAAM,IAAI,MAAMA,EAAO,QAAQ,KAAK,EAGtC,MAAO,CACL,SAAU,CAACA,EAAO,QAAQ,OAAO,EACjC,QAASC,EACT,eAAAH,CACF,CACF,CAhBsBH,EAAAC,EAAA,uBAkBf,IAAMM,EAAoCP,EAC/CQ,GACIA,GAAQ,CAACA,EAAK,WAAW,IAAI,EAAI,KAAOA,EAAOA,EAFJ",
|
|
6
|
-
"names": ["derivationPath", "setDerivationPath", "path", "__name", "getDerivationPath", "bitcoinDerivationPath", "setBitcoinDerivationPath", "getBitcoinDerivationPath", "dynamicImportWithRefinedError", "ETHEREUM_CHAIN_ID", "trezorErrorMessages", "getTrezorModule", "mod", "dynamicImportWithRefinedError", "__name", "getEthereumAccounts", "TrezorConnect", "derivationPath", "getDerivationPath", "result", "ETHEREUM_CHAIN_ID", "getTrezorNormalizedDerivationPath", "path"]
|
|
7
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|