@rango-dev/provider-trezor 0.31.1 → 0.31.2-next.1
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/mod.d.ts +1 -2
- package/dist/mod.js +1 -1
- package/dist/mod.js.map +4 -4
- package/package.json +4 -4
- package/src/mod.ts +1 -8
package/dist/mod.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export { versions };
|
|
1
|
+
export { buildProvider } from './provider.js';
|
|
3
2
|
export { WALLET_ID } from './constants.js';
|
package/dist/mod.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as r,b as p,d as u,g as c,h as f,i as a,j as l,k as h,l as i,m as T,n as A}from"./chunk-PCTGR6CA.js";import{ProviderBuilder as k}from"@hub3js/core";import{NamespaceBuilder as _}from"@hub3js/core";import{builders as v,utils as B}from"@hub3js/evm";import*as I from"@hub3js/std/builders";import{standardizeAndThrowError as g}from"@hub3js/std/operators";var x=!1;async function m(){if(x)return;await(await c()).init({lazyLoad:!0,manifest:z()}),x=!0}r(m,"initTrezor");var D=v.connect().action(async function(n,e,t){if(!t?.derivationPath)throw new Error("Derivation Path can not be empty.");p(a(t.derivationPath)),await m();let o=await f();return{accounts:B.formatAccountsToCAIP(o.accounts,o.chainId),network:o.chainId}}).or(g).build(),N=I.disconnect().build(),L=v.getChainId().action(()=>T).build(),w=new _("EVM",i).action(D).action(N).action(L).build();import{builders as W,CAIP_BITCOIN_CHAIN_ID as j}from"@hub3js/bip122";import{NamespaceBuilder as O}from"@hub3js/core";import*as b from"@hub3js/std/builders";import{standardizeAndThrowError as H}from"@hub3js/std/operators";import{utils as M}from"@hub3js/bip122";function U(n){return async(e,t)=>{if(!t?.derivationPath)throw new Error("Derivation Path can not be empty.");await m();let o=a(t.derivationPath),d=h(o);u(o);let s=await(await c()).getAddress({path:o,coin:l,scriptType:d,showOnTrezor:!1});if(!s.success)throw new Error(s.payload.error);let{address:P}=s.payload;return M.formatAccountsToCAIP([P],n)}}r(U,"connect");var E={connect:U};var S=W.connect().action(E.connect(j)).or(H).build(),F=b.disconnect().build(),C=new O("UTXO",i).action(S).action(F).build();var y,z=r(()=>y,"getTrezorManifest"),q=r(()=>new k(i).init(function(n,e){let[,t]=n.state();if(!e.manifest)throw new Error("Trezor manifest is required");y=e.manifest,t("installed",!0),console.debug("[trezor] instance detected.",n)}).config("metadata",A).add("evm",w).add("utxo",C).build(),"buildProvider");export{i as WALLET_ID,q as buildProvider};
|
|
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/
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["
|
|
3
|
+
"sources": ["../src/provider.ts", "../src/namespaces/evm.ts", "../src/init.ts", "../src/namespaces/utxo.ts", "../src/actions/utxo.ts"],
|
|
4
|
+
"sourcesContent": ["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 { 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';\n\nimport { ETHEREUM_CHAIN_ID, 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 '@hub3js/bip122';\n\nimport { builders, CAIP_BITCOIN_CHAIN_ID } 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(CAIP_BITCOIN_CHAIN_ID))\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 { Bip122ChainId, UtxoActions } from '@hub3js/bip122';\nimport type { Context, FunctionWithContext } from '@hub3js/core';\n\nimport { utils } from '@hub3js/bip122';\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(\n network: Bip122ChainId\n): FunctionWithContext<UtxoActions['connect'], Context> {\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], network);\n };\n}\n\nexport const utxoActions = { connect };\n"],
|
|
5
|
+
"mappings": "8GAEA,OAAS,mBAAAA,MAAuB,eCAhC,OAAS,oBAAAC,MAAwB,eACjC,OAAS,YAAAC,EAAU,SAAAC,MAAa,cAChC,UAAYC,MAAoB,uBAChC,OAAS,4BAAAC,MAAgC,wBCFzC,IAA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AAC,EAED,GAAI,CAACG,EAAO,QACV,MAAM,IAAI,MAAMA,EAAO,QAAQ,KAAK,EAGtC,GAAM,CAAE,QAAAG,CAAQ,EAAIH,EAAO,QAE3B,OAAOI,EAAM,qBAAqB,CAACD,CAAO,EAAGZ,CAAO,CACtD,CACF,CA9BgBc,EAAAf,EAAA,WAgCT,IAAMgB,EAAc,CAAE,QAAAhB,CAAQ,EDzCrC,IAAMiB,EAAUC,EACb,QAAQ,EACR,OAAOC,EAAY,QAAQC,CAAqB,CAAC,EACjD,GAAGC,CAAwB,EAC3B,MAAM,EAEHC,EAA4B,aAAwB,EAAE,MAAM,EAE5DC,EAAO,IAAIC,EAA8B,OAAQC,CAAS,EAC7D,OAAOR,CAAO,EACd,OAAOK,CAAU,EACjB,MAAM,EHbT,IAAII,EAESC,EAAoBC,EAAA,IAAMF,EAAN,qBAE3BG,EAAgBD,EAAA,IACpB,IAAIE,EAAgBC,CAAS,EAC1B,KAAK,SAAUC,EAASC,EAA4B,CACnD,GAAM,CAAC,CAAEC,CAAQ,EAAIF,EAAQ,MAAM,EAEnC,GAAI,CAACC,EAAa,SAChB,MAAM,IAAI,MAAM,6BAA6B,EAG/CP,EAAiBO,EAAa,SAC9BC,EAAS,YAAa,EAAI,EAC1B,QAAQ,MAAM,8BAA+BF,CAAO,CACtD,CAAC,EACA,OAAO,WAAYG,CAAQ,EAC3B,IAAI,MAAOC,CAAG,EACd,IAAI,OAAQC,CAAI,EAChB,MAAM,EAhBW",
|
|
6
|
+
"names": ["ProviderBuilder", "NamespaceBuilder", "builders", "utils", "commonBuilders", "standardizeAndThrowError", "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", "builders", "CAIP_BITCOIN_CHAIN_ID", "NamespaceBuilder", "commonBuilders", "standardizeAndThrowError", "utils", "connect", "network", "_context", "options", "initTrezor", "path", "getTrezorNormalizedDerivationPath", "inputScriptType", "resolveBitcoinScriptType", "setBitcoinDerivationPath", "result", "getTrezorModule", "BITCOIN_COIN_NAME", "address", "utils", "__name", "utxoActions", "connect", "builders", "utxoActions", "CAIP_BITCOIN_CHAIN_ID", "standardizeAndThrowError", "disconnect", "utxo", "NamespaceBuilder", "WALLET_ID", "trezorManifest", "getTrezorManifest", "__name", "buildProvider", "ProviderBuilder", "WALLET_ID", "context", "environments", "setState", "metadata", "evm", "utxo"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/provider-trezor",
|
|
3
|
-
"version": "0.31.1",
|
|
3
|
+
"version": "0.31.2-next.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/mod.ts",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"@hub3js/core": "^0.62.0",
|
|
28
28
|
"@hub3js/evm": "^0.5.0",
|
|
29
29
|
"@hub3js/std": "^0.4.0",
|
|
30
|
-
"@rango-dev/internal-blockchains": "^0.2.
|
|
31
|
-
"@rango-dev/signer-evm": "^0.46.
|
|
32
|
-
"@rango-dev/wallets-core": "^0.62.
|
|
30
|
+
"@rango-dev/internal-blockchains": "^0.2.2-next.0",
|
|
31
|
+
"@rango-dev/signer-evm": "^0.46.2-next.0",
|
|
32
|
+
"@rango-dev/wallets-core": "^0.62.2-next.0",
|
|
33
33
|
"@trezor/connect-web": "^9.5.0",
|
|
34
34
|
"bitcoinjs-lib": "^6.1.7",
|
|
35
35
|
"ethers": "^6.13.2",
|
package/src/mod.ts
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { buildProvider } from './provider.js';
|
|
4
|
-
|
|
5
|
-
const versions = () =>
|
|
6
|
-
defineVersions().version('1.0.0', buildProvider()).build();
|
|
7
|
-
|
|
8
|
-
export { versions };
|
|
1
|
+
export { buildProvider } from './provider.js';
|
|
9
2
|
export { WALLET_ID } from './constants.js';
|