@rango-dev/provider-trezor 0.8.0 → 0.8.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/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/provider-trezor.build.json +1 -1
- package/package.json +2 -2
- package/src/index.ts +48 -5
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a
|
|
1
|
+
import{a,b as s,e as c,f as l,g as m,i as p}from"./chunk-VKZ2HTGF.js";import{Networks as u,WalletTypes as y}from"@rango-dev/wallets-shared";import"rango-types";import{DefaultSignerFactory as h,TransactionType as f}from"rango-types";async function i(){let t=new h,{EthereumSigner:n}=await import("./ethereum-2ZKMGNFA.js");return t.registerSigner(f.EVM,new n),t}a(i,"getSigners");var d={appUrl:"",email:""},b={type:y.TREZOR},D=a(t=>{d=t.manifest},"init"),S=l,g=!1,k=a(async({namespaces:t})=>{let n=[],o=await c(),e=t?.find(r=>r.namespace==="EVM");if(e)if(e.derivationPath){s(p(e.derivationPath)),g||(await o.init({lazyLoad:!0,manifest:d}),g=!0);let r=await m();n.push(r)}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(r=>r.namespace)}`);return n},"connect"),C=i,I=a(t=>{let n=[],o=t.find(e=>e.name===u.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"}]},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{b as config,k as connect,S as getInstance,C as getSigners,I 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 {
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["
|
|
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\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: any) => Promise<SignerFactory> = 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 },\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": "sEAOA,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,EAC/D,OAAAF,EAAQ,eAAeG,EAAO,IAAK,IAAID,CAAgB,EAChDF,CACT,CAL8BI,EAAAL,EAAA,cDe9B,IAAIM,EAA2C,CAC7C,OAAQ,GACR,MAAO,EACT,EACaC,EAAS,CACpB,KAAMC,EAAY,MACpB,EAIaC,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,EAAwDA,EAExDC,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,UACT,CACF,CACF,EACA,oBAAqB,CACnB,KAAM,CACJ,CACE,GAAI,WACJ,MAAO,kCACP,UAAW,MACX,uBAAyBI,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,EAnE+E",
|
|
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", "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":2270,"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":394,"imports":[{"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":
|
|
1
|
+
{"inputs":{"src/state.ts":{"bytes":290,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/helpers.ts":{"bytes":2270,"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":394,"imports":[{"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":3943,"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":6820},"dist/index.js":{"imports":[{"path":"dist/chunk-VKZ2HTGF.js","kind":"import-statement"},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"dist/ethereum-2ZKMGNFA.js","kind":"dynamic-import"}],"exports":["config","connect","getInstance","getSigners","getWalletInfo","init"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":1642},"src/signer.ts":{"bytesInOutput":218}},"bytes":2060},"dist/ethereum-2ZKMGNFA.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":6222},"dist/ethereum-2ZKMGNFA.js":{"imports":[{"path":"dist/chunk-VKZ2HTGF.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-VKZ2HTGF.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":4059},"dist/chunk-VKZ2HTGF.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":737}},"bytes":1030}}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/provider-trezor",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1-next.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@rango-dev/signer-evm": "^0.32.0",
|
|
28
|
-
"@rango-dev/wallets-shared": "^0.41.
|
|
28
|
+
"@rango-dev/wallets-shared": "^0.41.1-next.1",
|
|
29
29
|
"@trezor/connect-web": "^9.2.4",
|
|
30
30
|
"ethers": "^6.13.2",
|
|
31
31
|
"rango-types": "^0.1.74"
|
package/src/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
WalletInfo,
|
|
6
6
|
} from '@rango-dev/wallets-shared';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { Networks, WalletTypes } from '@rango-dev/wallets-shared';
|
|
9
9
|
import { type BlockchainMeta, type SignerFactory } from 'rango-types';
|
|
10
10
|
|
|
11
11
|
import {
|
|
@@ -40,7 +40,7 @@ export const connect: Connect = async ({ namespaces }) => {
|
|
|
40
40
|
const TrezorConnect = await getTrezorModule();
|
|
41
41
|
|
|
42
42
|
const evmNamespace = namespaces?.find(
|
|
43
|
-
(namespaceItem) => namespaceItem.namespace ===
|
|
43
|
+
(namespaceItem) => namespaceItem.namespace === 'EVM'
|
|
44
44
|
);
|
|
45
45
|
|
|
46
46
|
if (evmNamespace) {
|
|
@@ -87,6 +87,7 @@ export const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo = (
|
|
|
87
87
|
if (ethereumBlockchain) {
|
|
88
88
|
supportedChains.push(ethereumBlockchain);
|
|
89
89
|
}
|
|
90
|
+
|
|
90
91
|
return {
|
|
91
92
|
name: 'Trezor',
|
|
92
93
|
img: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/trezor/icon.svg',
|
|
@@ -95,9 +96,51 @@ export const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo = (
|
|
|
95
96
|
},
|
|
96
97
|
color: 'black',
|
|
97
98
|
supportedChains,
|
|
98
|
-
namespaces: [Namespace.Evm],
|
|
99
|
-
singleNamespace: true,
|
|
100
99
|
showOnMobile: false,
|
|
101
|
-
|
|
100
|
+
|
|
101
|
+
needsNamespace: {
|
|
102
|
+
selection: 'single',
|
|
103
|
+
data: [
|
|
104
|
+
{
|
|
105
|
+
id: 'ETH',
|
|
106
|
+
value: 'EVM',
|
|
107
|
+
label: 'Ethereum',
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
},
|
|
111
|
+
needsDerivationPath: {
|
|
112
|
+
data: [
|
|
113
|
+
{
|
|
114
|
+
id: 'metamask',
|
|
115
|
+
label: `Metamask (m/44'/60'/0'/0/index)`,
|
|
116
|
+
namespace: 'EVM',
|
|
117
|
+
generateDerivationPath: (index: string) => `44'/60'/0'/0/${index}`,
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
id: 'ledgerLive',
|
|
121
|
+
label: `LedgerLive (m/44'/60'/index'/0/0)`,
|
|
122
|
+
namespace: 'EVM',
|
|
123
|
+
generateDerivationPath: (index: string) => `44'/60'/${index}'/0/0`,
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
id: 'legacy',
|
|
127
|
+
label: `Legacy (m/44'/60'/0'/index)`,
|
|
128
|
+
namespace: 'EVM',
|
|
129
|
+
generateDerivationPath: (index: string) => `44'/60'/0'/${index}`,
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
id: `(m/44'/501'/index')`,
|
|
133
|
+
label: `(m/44'/501'/index')`,
|
|
134
|
+
namespace: 'Solana',
|
|
135
|
+
generateDerivationPath: (index: string) => `44'/501'/${index}'`,
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
id: `(m/44'/501'/0'/index)`,
|
|
139
|
+
label: `(m/44'/501'/0'/index)`,
|
|
140
|
+
namespace: 'Solana',
|
|
141
|
+
generateDerivationPath: (index: string) => `44'/501'/0'/${index}`,
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
},
|
|
102
145
|
};
|
|
103
146
|
};
|