@rango-dev/provider-trezor 0.15.0 → 0.15.1-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/CHANGELOG.md +4 -0
- package/dist/chunk-7E345USG.js +2 -0
- package/dist/chunk-7E345USG.js.map +7 -0
- package/dist/{ethereum-56FGPA2J.js → ethereum-WBSYC4WD.js} +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/provider-trezor.build.json +1 -1
- package/package.json +4 -4
- package/src/helpers.ts +4 -1
- package/src/signer.ts +4 -1
- package/dist/chunk-C6TCVRNL.js +0 -2
- package/dist/chunk-C6TCVRNL.js.map +0 -7
- /package/dist/{ethereum-56FGPA2J.js.map → ethereum-WBSYC4WD.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var i=Object.defineProperty;var e=(t,r)=>i(t,"name",{value:r,configurable:!0});var o="";function l(t){o=t}e(l,"setDerivationPath");function a(){return o}e(a,"getDerivationPath");import{ETHEREUM_CHAIN_ID as s,Networks as c,retryLazyImport as u}from"@rango-dev/wallets-shared";var h={Failure_ActionCancelled:"User rejected the transaction."};async function d(){let t=await u(async()=>await import("@trezor/connect-web"));return t.default.default?t.default.default:t.default}e(d,"getTrezorModule");function x(){let t=new Map;return t.set(c.ETHEREUM,{chainId:s}),t}e(x,"getTrezorInstance");async function I(){let t=await d(),r=a(),n=await t.ethereumGetAddress({path:r});if(!n.success)throw new Error(n.payload.error);return{accounts:[n.payload.address],chainId:s,derivationPath:r}}e(I,"getEthereumAccounts");var w=e(t=>{let r=BigInt(0);return BigInt(t)>r?`0x${BigInt(t).toString(16)}`:"0x0"},"valueToHex"),z=e(t=>t&&!t.startsWith("m/")?"m/"+t:t,"getTrezorNormalizedDerivationPath");export{e as a,l as b,a as c,h as d,d as e,x as f,I as g,w as h,z as i};
|
|
2
|
+
//# sourceMappingURL=chunk-7E345USG.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/state.ts", "../src/helpers.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", "import type { TrezorConnect } from '@trezor/connect-web';\n\nimport {\n ETHEREUM_CHAIN_ID,\n Networks,\n type ProviderConnectResult,\n retryLazyImport,\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 retryLazyImport(\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 function getTrezorInstance() {\n /*\n * Instances have a required property which is `chainId` and is using in swap execution.\n * Here we are setting it as Ethereum always since we are supporting only eth for now.\n */\n const instances = new Map();\n\n instances.set(Networks.ETHEREUM, { chainId: ETHEREUM_CHAIN_ID });\n\n return instances;\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\n/*\n * Using BigInt in the valueToHex function ensures that the function\n * can handle very large integer values that exceed the range of standard JavaScript number types.\n */\nexport const valueToHex = (value: string) => {\n const ZERO_BIGINT = BigInt(0);\n const HEX_BASE = 16;\n return BigInt(value) > ZERO_BIGINT\n ? `0x${BigInt(value).toString(HEX_BASE)}`\n : '0x0';\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,qBCLhB,OACE,qBAAAC,EACA,YAAAC,EAEA,mBAAAC,MACK,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,mBAef,SAASI,GAAoB,CAKlC,IAAMC,EAAY,IAAI,IAEtB,OAAAA,EAAU,IAAIC,EAAS,SAAU,CAAE,QAASC,CAAkB,CAAC,EAExDF,CACT,CAVgBF,EAAAC,EAAA,qBAYhB,eAAsBI,GAAsD,CAC1E,IAAMC,EAAgB,MAAMT,EAAgB,EACtCU,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,QAASL,EACT,eAAAG,CACF,CACF,CAhBsBP,EAAAK,EAAA,uBAsBf,IAAMK,EAAaV,EAACW,GAAkB,CAC3C,IAAMC,EAAc,OAAO,CAAC,EAE5B,OAAO,OAAOD,CAAK,EAAIC,EACnB,KAAK,OAAOD,CAAK,EAAE,SAFN,EAEuB,CAAC,GACrC,KACN,EAN0B,cAQbE,EAAoCb,EAC/Cc,GACIA,GAAQ,CAACA,EAAK,WAAW,IAAI,EAAI,KAAOA,EAAOA,EAFJ",
|
|
6
|
+
"names": ["derivationPath", "setDerivationPath", "path", "__name", "getDerivationPath", "ETHEREUM_CHAIN_ID", "Networks", "retryLazyImport", "trezorErrorMessages", "getTrezorModule", "mod", "retryLazyImport", "__name", "getTrezorInstance", "instances", "Networks", "ETHEREUM_CHAIN_ID", "getEthereumAccounts", "TrezorConnect", "derivationPath", "getDerivationPath", "result", "valueToHex", "value", "ZERO_BIGINT", "getTrezorNormalizedDerivationPath", "path"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as p,c as u,d as P,e as h,h as e}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=ethereum-
|
|
1
|
+
import{a as p,c as u,d as P,e as h,h as e}from"./chunk-7E345USG.js";import{cleanEvmError as G}from"@rango-dev/signer-evm";import{DEFAULT_ETHEREUM_RPC_URL as z}from"@rango-dev/wallets-shared";import{JsonRpcProvider as S,Transaction as R}from"ethers";import"rango-types";function b(s){return s?.shortMessage?new Error(s.shortMessage,{cause:s}):G(s)}p(b,"getTrezorErrorMessage");var E=class{static{p(this,"EthereumSigner")}async signMessage(r){let o=await h(),{success:n,payload:t}=await o.ethereumSignMessage({message:r,path:u()});if(!n)throw new Error(t.error);return t.signature}async signAndSendTx(r,o,n){try{let t=await h(),{gasPrice:d,maxFeePerGas:i,maxPriorityFeePerGas:c}=r,a=i&&c;if(a&&!i)throw new Error("Missing maxFeePerGas");if(a&&!c)throw new Error("Missing maxPriorityFeePerGas");if(!a&&!d)throw new Error("Missing gasPrice");let w=new S(z),T=await w.getTransactionCount(o),f=a?{maxFeePerGas:e(i||"0"),maxPriorityFeePerGas:e(c||"0")}:{gasPrice:e(d||"0")},g={to:r.to,data:r.data||"0x",value:e(r.value?.toString()||"0"),gasLimit:e(r.gasLimit?.toString()||"0"),chainId:Number.parseInt(n),nonce:e(T.toString()),...f},{success:l,payload:m}=await t.ethereumSignTransaction({path:u(),transaction:g});if(!l){let F=P[m?.code||""]||m.error;throw new Error(F)}let{r:y,s:v,v:M}=m,x=R.from({...g,nonce:Number.parseInt(g.nonce),type:a?2:0,signature:{r:y,s:v,v:parseInt(M)}}).serialized;return{hash:(await w.broadcastTransaction(x)).hash}}catch(t){throw b(t)}}};export{E as EthereumSigner,b as getTrezorErrorMessage};
|
|
2
|
+
//# sourceMappingURL=ethereum-WBSYC4WD.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as r,b as s,e as c,f as
|
|
1
|
+
import{a as r,b as s,e as c,f as m,g as l,i as p}from"./chunk-7E345USG.js";import{Networks as g,WalletTypes as v}from"@rango-dev/wallets-shared";import"rango-types";import{retryLazyImport as y}from"@rango-dev/wallets-shared";import{DefaultSignerFactory as f,TransactionType as u}from"rango-types";async function i(){let t=new f,{EthereumSigner:n}=await y(async()=>await import("./ethereum-WBSYC4WD.js"));return t.registerSigner(u.EVM,new n),t}r(i,"getSigners");var h={appUrl:"",email:""},k={type:v.TREZOR},D=r(t=>{h=t.manifest},"init"),C=m,d=!1,I=r(async({namespaces:t})=>{let n=[],o=await c(),e=t?.find(a=>a.namespace==="EVM");if(e)if(e.derivationPath){s(p(e.derivationPath)),d||(await o.init({lazyLoad:!0,manifest:h}),d=!0);let a=await l();n.push(a)}else throw new Error("Derivation Path can not be empty.");else throw new Error(`It appears that you have selected a namespace that is not yet supported by our system. Your namespaces: ${t?.map(a=>a.namespace)}`);return n},"connect"),L=i,B=r(t=>{let n=[],o=t.find(e=>e.name===g.ETHEREUM);return o&&n.push(o),{name:"Trezor",img:"https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/trezor/icon.svg",installLink:{DEFAULT:"https://trezor.io/learn/a/download-verify-trezor-suite"},color:"black",supportedChains:n,showOnMobile:!1,needsNamespace:{selection:"single",data:[{id:"ETH",value:"EVM",label:"Ethereum",getSupportedChains:e=>e.filter(a=>a.name===g.ETHEREUM)}]},needsDerivationPath:{data:[{id:"metamask",label:"Metamask (m/44'/60'/0'/0/index)",namespace:"EVM",generateDerivationPath:e=>`44'/60'/0'/0/${e}`},{id:"ledgerLive",label:"LedgerLive (m/44'/60'/index'/0/0)",namespace:"EVM",generateDerivationPath:e=>`44'/60'/${e}'/0/0`},{id:"legacy",label:"Legacy (m/44'/60'/0'/index)",namespace:"EVM",generateDerivationPath:e=>`44'/60'/0'/${e}`},{id:"(m/44'/501'/index')",label:"(m/44'/501'/index')",namespace:"Solana",generateDerivationPath:e=>`44'/501'/${e}'`},{id:"(m/44'/501'/0'/index)",label:"(m/44'/501'/0'/index)",namespace:"Solana",generateDerivationPath:e=>`44'/501'/0'/${e}`}]}}},"getWalletInfo");export{k as config,I as connect,C as getInstance,L as getSigners,B as getWalletInfo,D as init};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/signer.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Environments } from './types.js';\nimport type {\n Connect,\n ProviderConnectResult,\n WalletInfo,\n} from '@rango-dev/wallets-shared';\n\nimport { Networks, WalletTypes } from '@rango-dev/wallets-shared';\nimport { type BlockchainMeta, type SignerFactory } from 'rango-types';\n\nimport {\n getEthereumAccounts,\n getTrezorInstance,\n getTrezorModule,\n getTrezorNormalizedDerivationPath,\n} from './helpers.js';\nimport signer from './signer.js';\nimport { setDerivationPath } from './state.js';\n\nlet trezorManifest: Environments['manifest'] = {\n appUrl: '',\n email: '',\n};\nexport const config = {\n type: WalletTypes.TREZOR,\n};\n\nexport type { Environments };\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Provider = any;\n\nexport const init = (environments: Environments) => {\n trezorManifest = environments.manifest;\n};\n\nexport const getInstance = getTrezorInstance;\n\nlet isTrezorInitialized = false;\nexport const connect: Connect = async ({ namespaces }) => {\n const results: ProviderConnectResult[] = [];\n\n const TrezorConnect = await getTrezorModule();\n\n const evmNamespace = namespaces?.find(\n (namespaceItem) => namespaceItem.namespace === 'EVM'\n );\n\n if (evmNamespace) {\n if (evmNamespace.derivationPath) {\n setDerivationPath(\n getTrezorNormalizedDerivationPath(evmNamespace.derivationPath)\n );\n\n if (!isTrezorInitialized) {\n await TrezorConnect.init({\n lazyLoad: true, // this param will prevent iframe injection until TrezorConnect.method will be called\n manifest: trezorManifest,\n });\n\n isTrezorInitialized = true;\n }\n\n const accounts = await getEthereumAccounts();\n results.push(accounts);\n } else {\n throw new Error('Derivation Path can not be empty.');\n }\n } else {\n throw new Error(\n `It appears that you have selected a namespace that is not yet supported by our system. Your namespaces: ${namespaces?.map(\n (namespaceItem) => namespaceItem.namespace\n )}`\n );\n }\n\n return results;\n};\n\nexport const getSigners: (provider: Provider) => Promise<SignerFactory> =\n signer;\n\nexport const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo = (\n allBlockChains\n) => {\n const supportedChains: BlockchainMeta[] = [];\n\n const ethereumBlockchain = allBlockChains.find(\n (chain) => chain.name === Networks.ETHEREUM\n );\n if (ethereumBlockchain) {\n supportedChains.push(ethereumBlockchain);\n }\n\n return {\n name: 'Trezor',\n img: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/trezor/icon.svg',\n installLink: {\n DEFAULT: 'https://trezor.io/learn/a/download-verify-trezor-suite',\n },\n color: 'black',\n supportedChains,\n showOnMobile: false,\n\n needsNamespace: {\n selection: 'single',\n data: [\n {\n id: 'ETH',\n value: 'EVM',\n label: 'Ethereum',\n getSupportedChains: (allBlockchains: BlockchainMeta[]) =>\n allBlockchains.filter((chain) => chain.name === Networks.ETHEREUM),\n },\n ],\n },\n needsDerivationPath: {\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 id: `(m/44'/501'/index')`,\n label: `(m/44'/501'/index')`,\n namespace: 'Solana',\n generateDerivationPath: (index: string) => `44'/501'/${index}'`,\n },\n {\n id: `(m/44'/501'/0'/index)`,\n label: `(m/44'/501'/0'/index)`,\n namespace: 'Solana',\n generateDerivationPath: (index: string) => `44'/501'/0'/${index}`,\n },\n ],\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 signers.registerSigner(TxType.EVM, new EthereumSigner());\n return signers;\n}\n"],
|
|
5
|
-
"mappings": "2EAOA,OAAS,YAAAA,EAAU,eAAAC,MAAmB,4BACtC,MAAwD,cCNxD,OAAS,wBAAAC,EAAsB,mBAAmBC,MAAc,cAEhE,eAAOC,GAA4D,CACjE,IAAMC,EAAU,IAAIC,EACd,CAAE,eAAAC,CAAe,EAAI,KAAM,QAAO,wBAAuB,
|
|
6
|
-
"names": ["Networks", "WalletTypes", "DefaultSignerFactory", "TxType", "getSigners", "signers", "DefaultSignerFactory", "EthereumSigner", "TxType", "__name", "trezorManifest", "config", "WalletTypes", "init", "__name", "environments", "getInstance", "getTrezorInstance", "isTrezorInitialized", "connect", "namespaces", "results", "TrezorConnect", "getTrezorModule", "evmNamespace", "namespaceItem", "setDerivationPath", "getTrezorNormalizedDerivationPath", "accounts", "getEthereumAccounts", "getSigners", "getWalletInfo", "allBlockChains", "supportedChains", "ethereumBlockchain", "chain", "Networks", "allBlockchains", "index"]
|
|
4
|
+
"sourcesContent": ["import type { Environments } from './types.js';\nimport type {\n Connect,\n ProviderConnectResult,\n WalletInfo,\n} from '@rango-dev/wallets-shared';\n\nimport { Networks, WalletTypes } from '@rango-dev/wallets-shared';\nimport { type BlockchainMeta, type SignerFactory } from 'rango-types';\n\nimport {\n getEthereumAccounts,\n getTrezorInstance,\n getTrezorModule,\n getTrezorNormalizedDerivationPath,\n} from './helpers.js';\nimport signer from './signer.js';\nimport { setDerivationPath } from './state.js';\n\nlet trezorManifest: Environments['manifest'] = {\n appUrl: '',\n email: '',\n};\nexport const config = {\n type: WalletTypes.TREZOR,\n};\n\nexport type { Environments };\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Provider = any;\n\nexport const init = (environments: Environments) => {\n trezorManifest = environments.manifest;\n};\n\nexport const getInstance = getTrezorInstance;\n\nlet isTrezorInitialized = false;\nexport const connect: Connect = async ({ namespaces }) => {\n const results: ProviderConnectResult[] = [];\n\n const TrezorConnect = await getTrezorModule();\n\n const evmNamespace = namespaces?.find(\n (namespaceItem) => namespaceItem.namespace === 'EVM'\n );\n\n if (evmNamespace) {\n if (evmNamespace.derivationPath) {\n setDerivationPath(\n getTrezorNormalizedDerivationPath(evmNamespace.derivationPath)\n );\n\n if (!isTrezorInitialized) {\n await TrezorConnect.init({\n lazyLoad: true, // this param will prevent iframe injection until TrezorConnect.method will be called\n manifest: trezorManifest,\n });\n\n isTrezorInitialized = true;\n }\n\n const accounts = await getEthereumAccounts();\n results.push(accounts);\n } else {\n throw new Error('Derivation Path can not be empty.');\n }\n } else {\n throw new Error(\n `It appears that you have selected a namespace that is not yet supported by our system. Your namespaces: ${namespaces?.map(\n (namespaceItem) => namespaceItem.namespace\n )}`\n );\n }\n\n return results;\n};\n\nexport const getSigners: (provider: Provider) => Promise<SignerFactory> =\n signer;\n\nexport const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo = (\n allBlockChains\n) => {\n const supportedChains: BlockchainMeta[] = [];\n\n const ethereumBlockchain = allBlockChains.find(\n (chain) => chain.name === Networks.ETHEREUM\n );\n if (ethereumBlockchain) {\n supportedChains.push(ethereumBlockchain);\n }\n\n return {\n name: 'Trezor',\n img: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/trezor/icon.svg',\n installLink: {\n DEFAULT: 'https://trezor.io/learn/a/download-verify-trezor-suite',\n },\n color: 'black',\n supportedChains,\n showOnMobile: false,\n\n needsNamespace: {\n selection: 'single',\n data: [\n {\n id: 'ETH',\n value: 'EVM',\n label: 'Ethereum',\n getSupportedChains: (allBlockchains: BlockchainMeta[]) =>\n allBlockchains.filter((chain) => chain.name === Networks.ETHEREUM),\n },\n ],\n },\n needsDerivationPath: {\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 id: `(m/44'/501'/index')`,\n label: `(m/44'/501'/index')`,\n namespace: 'Solana',\n generateDerivationPath: (index: string) => `44'/501'/${index}'`,\n },\n {\n id: `(m/44'/501'/0'/index)`,\n label: `(m/44'/501'/0'/index)`,\n namespace: 'Solana',\n generateDerivationPath: (index: string) => `44'/501'/0'/${index}`,\n },\n ],\n },\n };\n};\n", "import type { SignerFactory } from 'rango-types';\n\nimport { retryLazyImport } from '@rango-dev/wallets-shared';\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 retryLazyImport(\n async () => await import('./signers/ethereum.js')\n );\n signers.registerSigner(TxType.EVM, new EthereumSigner());\n return signers;\n}\n"],
|
|
5
|
+
"mappings": "2EAOA,OAAS,YAAAA,EAAU,eAAAC,MAAmB,4BACtC,MAAwD,cCNxD,OAAS,mBAAAC,MAAuB,4BAChC,OAAS,wBAAAC,EAAsB,mBAAmBC,MAAc,cAEhE,eAAOC,GAA4D,CACjE,IAAMC,EAAU,IAAIC,EACd,CAAE,eAAAC,CAAe,EAAI,MAAMC,EAC/B,SAAY,KAAM,QAAO,wBAAuB,CAClD,EACA,OAAAH,EAAQ,eAAeI,EAAO,IAAK,IAAIF,CAAgB,EAChDF,CACT,CAP8BK,EAAAN,EAAA,cDc9B,IAAIO,EAA2C,CAC7C,OAAQ,GACR,MAAO,EACT,EACaC,EAAS,CACpB,KAAMC,EAAY,MACpB,EAMaC,EAAOC,EAACC,GAA+B,CAClDL,EAAiBK,EAAa,QAChC,EAFoB,QAIPC,EAAcC,EAEvBC,EAAsB,GACbC,EAAmBL,EAAA,MAAO,CAAE,WAAAM,CAAW,IAAM,CACxD,IAAMC,EAAmC,CAAC,EAEpCC,EAAgB,MAAMC,EAAgB,EAEtCC,EAAeJ,GAAY,KAC9BK,GAAkBA,EAAc,YAAc,KACjD,EAEA,GAAID,EACF,GAAIA,EAAa,eAAgB,CAC/BE,EACEC,EAAkCH,EAAa,cAAc,CAC/D,EAEKN,IACH,MAAMI,EAAc,KAAK,CACvB,SAAU,GACV,SAAUZ,CACZ,CAAC,EAEDQ,EAAsB,IAGxB,IAAMU,EAAW,MAAMC,EAAoB,EAC3CR,EAAQ,KAAKO,CAAQ,CACvB,KACE,OAAM,IAAI,MAAM,mCAAmC,MAGrD,OAAM,IAAI,MACR,2GAA2GR,GAAY,IACpHK,GAAkBA,EAAc,SACnC,CAAC,EACH,EAGF,OAAOJ,CACT,EAtCgC,WAwCnBS,EACXA,EAEWC,EAAkEjB,EAC7EkB,GACG,CACH,IAAMC,EAAoC,CAAC,EAErCC,EAAqBF,EAAe,KACvCG,GAAUA,EAAM,OAASC,EAAS,QACrC,EACA,OAAIF,GACFD,EAAgB,KAAKC,CAAkB,EAGlC,CACL,KAAM,SACN,IAAK,uFACL,YAAa,CACX,QAAS,wDACX,EACA,MAAO,QACP,gBAAAD,EACA,aAAc,GAEd,eAAgB,CACd,UAAW,SACX,KAAM,CACJ,CACE,GAAI,MACJ,MAAO,MACP,MAAO,WACP,mBAAqBI,GACnBA,EAAe,OAAQF,GAAUA,EAAM,OAASC,EAAS,QAAQ,CACrE,CACF,CACF,EACA,oBAAqB,CACnB,KAAM,CACJ,CACE,GAAI,WACJ,MAAO,kCACP,UAAW,MACX,uBAAyBE,GAAkB,gBAAgBA,CAAK,EAClE,EACA,CACE,GAAI,aACJ,MAAO,oCACP,UAAW,MACX,uBAAyBA,GAAkB,WAAWA,CAAK,OAC7D,EACA,CACE,GAAI,SACJ,MAAO,8BACP,UAAW,MACX,uBAAyBA,GAAkB,cAAcA,CAAK,EAChE,EACA,CACE,GAAI,sBACJ,MAAO,sBACP,UAAW,SACX,uBAAyBA,GAAkB,YAAYA,CAAK,GAC9D,EACA,CACE,GAAI,wBACJ,MAAO,wBACP,UAAW,SACX,uBAAyBA,GAAkB,eAAeA,CAAK,EACjE,CACF,CACF,CACF,CACF,EArE+E",
|
|
6
|
+
"names": ["Networks", "WalletTypes", "retryLazyImport", "DefaultSignerFactory", "TxType", "getSigners", "signers", "DefaultSignerFactory", "EthereumSigner", "retryLazyImport", "TxType", "__name", "trezorManifest", "config", "WalletTypes", "init", "__name", "environments", "getInstance", "getTrezorInstance", "isTrezorInitialized", "connect", "namespaces", "results", "TrezorConnect", "getTrezorModule", "evmNamespace", "namespaceItem", "setDerivationPath", "getTrezorNormalizedDerivationPath", "accounts", "getEthereumAccounts", "getSigners", "getWalletInfo", "allBlockChains", "supportedChains", "ethereumBlockchain", "chain", "Networks", "allBlockchains", "index"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/state.ts":{"bytes":290,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/helpers.ts":{"bytes":
|
|
1
|
+
{"inputs":{"src/state.ts":{"bytes":290,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/helpers.ts":{"bytes":2405,"imports":[{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"src/state.ts","kind":"import-statement","original":"./state.js"},{"path":"@trezor/connect-web","kind":"dynamic-import","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/signers/ethereum.ts":{"bytes":3696,"imports":[{"path":"@rango-dev/signer-evm","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"ethers","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"src/helpers.ts","kind":"import-statement","original":"../helpers.js"},{"path":"src/state.ts","kind":"import-statement","original":"../state.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/signer.ts":{"bytes":498,"imports":[{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"src/signers/ethereum.ts","kind":"dynamic-import","original":"./signers/ethereum.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":4182,"imports":[{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"src/helpers.ts","kind":"import-statement","original":"./helpers.js"},{"path":"src/signer.ts","kind":"import-statement","original":"./signer.js"},{"path":"src/state.ts","kind":"import-statement","original":"./state.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":7331},"dist/index.js":{"imports":[{"path":"dist/chunk-7E345USG.js","kind":"import-statement"},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"dist/ethereum-WBSYC4WD.js","kind":"dynamic-import"}],"exports":["config","connect","getInstance","getSigners","getWalletInfo","init"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":1697},"src/signer.ts":{"bytesInOutput":296}},"bytes":2198},"dist/ethereum-WBSYC4WD.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":6222},"dist/ethereum-WBSYC4WD.js":{"imports":[{"path":"dist/chunk-7E345USG.js","kind":"import-statement"},{"path":"@rango-dev/signer-evm","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"ethers","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true}],"exports":["EthereumSigner","getTrezorErrorMessage"],"entryPoint":"src/signers/ethereum.ts","inputs":{"src/signers/ethereum.ts":{"bytesInOutput":1391}},"bytes":1561},"dist/chunk-7E345USG.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":4343},"dist/chunk-7E345USG.js":{"imports":[{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"@trezor/connect-web","kind":"dynamic-import","external":true}],"exports":["a","b","c","d","e","f","g","h","i"],"inputs":{"src/state.ts":{"bytesInOutput":99},"src/helpers.ts":{"bytesInOutput":800}},"bytes":1093}}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/provider-trezor",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.1-next.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
"lint": "eslint \"**/*.{ts,tsx}\""
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@rango-dev/signer-evm": "^0.39.0",
|
|
28
|
-
"@rango-dev/wallets-shared": "^0.48.
|
|
27
|
+
"@rango-dev/signer-evm": "^0.39.1-next.0",
|
|
28
|
+
"@rango-dev/wallets-shared": "^0.48.1-next.1",
|
|
29
29
|
"@trezor/connect-web": "^9.5.0",
|
|
30
30
|
"ethers": "^6.13.2",
|
|
31
|
-
"rango-types": "^0.1.
|
|
31
|
+
"rango-types": "^0.1.89"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|
package/src/helpers.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
ETHEREUM_CHAIN_ID,
|
|
5
5
|
Networks,
|
|
6
6
|
type ProviderConnectResult,
|
|
7
|
+
retryLazyImport,
|
|
7
8
|
} from '@rango-dev/wallets-shared';
|
|
8
9
|
|
|
9
10
|
import { getDerivationPath } from './state.js';
|
|
@@ -14,7 +15,9 @@ export const trezorErrorMessages: { [statusCode: string]: string } = {
|
|
|
14
15
|
|
|
15
16
|
// `@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
17
|
export async function getTrezorModule() {
|
|
17
|
-
const mod = await
|
|
18
|
+
const mod = await retryLazyImport(
|
|
19
|
+
async () => await import('@trezor/connect-web')
|
|
20
|
+
);
|
|
18
21
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
19
22
|
// @ts-ignore
|
|
20
23
|
if (mod.default.default) {
|
package/src/signer.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { SignerFactory } from 'rango-types';
|
|
2
2
|
|
|
3
|
+
import { retryLazyImport } from '@rango-dev/wallets-shared';
|
|
3
4
|
import { DefaultSignerFactory, TransactionType as TxType } from 'rango-types';
|
|
4
5
|
|
|
5
6
|
export default async function getSigners(): Promise<SignerFactory> {
|
|
6
7
|
const signers = new DefaultSignerFactory();
|
|
7
|
-
const { EthereumSigner } = await
|
|
8
|
+
const { EthereumSigner } = await retryLazyImport(
|
|
9
|
+
async () => await import('./signers/ethereum.js')
|
|
10
|
+
);
|
|
8
11
|
signers.registerSigner(TxType.EVM, new EthereumSigner());
|
|
9
12
|
return signers;
|
|
10
13
|
}
|
package/dist/chunk-C6TCVRNL.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var a=Object.defineProperty;var e=(t,r)=>a(t,"name",{value:r,configurable:!0});var o="";function g(t){o=t}e(g,"setDerivationPath");function s(){return o}e(s,"getDerivationPath");import{ETHEREUM_CHAIN_ID as i,Networks as c}from"@rango-dev/wallets-shared";var E={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");function h(){let t=new Map;return t.set(c.ETHEREUM,{chainId:i}),t}e(h,"getTrezorInstance");async function x(){let t=await u(),r=s(),n=await t.ethereumGetAddress({path:r});if(!n.success)throw new Error(n.payload.error);return{accounts:[n.payload.address],chainId:i,derivationPath:r}}e(x,"getEthereumAccounts");var I=e(t=>{let r=BigInt(0);return BigInt(t)>r?`0x${BigInt(t).toString(16)}`:"0x0"},"valueToHex"),T=e(t=>t&&!t.startsWith("m/")?"m/"+t:t,"getTrezorNormalizedDerivationPath");export{e as a,g as b,s as c,E as d,u as e,h as f,x as g,I as h,T as i};
|
|
2
|
-
//# sourceMappingURL=chunk-C6TCVRNL.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/state.ts", "../src/helpers.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", "import type { TrezorConnect } from '@trezor/connect-web';\n\nimport {\n ETHEREUM_CHAIN_ID,\n Networks,\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 function getTrezorInstance() {\n /*\n * Instances have a required property which is `chainId` and is using in swap execution.\n * Here we are setting it as Ethereum always since we are supporting only eth for now.\n */\n const instances = new Map();\n\n instances.set(Networks.ETHEREUM, { chainId: ETHEREUM_CHAIN_ID });\n\n return instances;\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\n/*\n * Using BigInt in the valueToHex function ensures that the function\n * can handle very large integer values that exceed the range of standard JavaScript number types.\n */\nexport const valueToHex = (value: string) => {\n const ZERO_BIGINT = BigInt(0);\n const HEX_BASE = 16;\n return BigInt(value) > ZERO_BIGINT\n ? `0x${BigInt(value).toString(HEX_BASE)}`\n : '0x0';\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,qBCLhB,OACE,qBAAAC,EACA,YAAAC,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,mBAaf,SAASG,GAAoB,CAKlC,IAAMC,EAAY,IAAI,IAEtB,OAAAA,EAAU,IAAIC,EAAS,SAAU,CAAE,QAASC,CAAkB,CAAC,EAExDF,CACT,CAVgBF,EAAAC,EAAA,qBAYhB,eAAsBI,GAAsD,CAC1E,IAAMC,EAAgB,MAAMR,EAAgB,EACtCS,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,QAASL,EACT,eAAAG,CACF,CACF,CAhBsBP,EAAAK,EAAA,uBAsBf,IAAMK,EAAaV,EAACW,GAAkB,CAC3C,IAAMC,EAAc,OAAO,CAAC,EAE5B,OAAO,OAAOD,CAAK,EAAIC,EACnB,KAAK,OAAOD,CAAK,EAAE,SAFN,EAEuB,CAAC,GACrC,KACN,EAN0B,cAQbE,EAAoCb,EAC/Cc,GACIA,GAAQ,CAACA,EAAK,WAAW,IAAI,EAAI,KAAOA,EAAOA,EAFJ",
|
|
6
|
-
"names": ["derivationPath", "setDerivationPath", "path", "__name", "getDerivationPath", "ETHEREUM_CHAIN_ID", "Networks", "trezorErrorMessages", "getTrezorModule", "mod", "__name", "getTrezorInstance", "instances", "Networks", "ETHEREUM_CHAIN_ID", "getEthereumAccounts", "TrezorConnect", "derivationPath", "getDerivationPath", "result", "valueToHex", "value", "ZERO_BIGINT", "getTrezorNormalizedDerivationPath", "path"]
|
|
7
|
-
}
|
|
File without changes
|