@rango-dev/provider-trezor 0.29.0 → 0.29.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/actions/utxo.d.ts +12 -0
  3. package/dist/chunk-FTGT4J2G.js +2 -0
  4. package/dist/chunk-FTGT4J2G.js.map +7 -0
  5. package/dist/chunk-HUUVMU7F.js +2 -0
  6. package/dist/chunk-HUUVMU7F.js.map +7 -0
  7. package/dist/{ethereum-AWO7VVVT.js → ethereum-WJFMSBHD.js} +2 -2
  8. package/dist/ethereum-WJFMSBHD.js.map +7 -0
  9. package/dist/init.d.ts +1 -0
  10. package/dist/mod.d.ts +1 -1
  11. package/dist/mod.js +1 -1
  12. package/dist/mod.js.map +4 -4
  13. package/dist/namespaces/utxo.d.ts +3 -0
  14. package/dist/provider.d.ts +1 -1
  15. package/dist/signers/utxo.d.ts +8 -0
  16. package/dist/state.d.ts +2 -0
  17. package/dist/{legacy/helpers.d.ts → utils.d.ts} +1 -2
  18. package/dist/utxo/config.d.ts +17 -0
  19. package/dist/utxo/psbt.d.ts +29 -0
  20. package/dist/utxo/psbt.test.d.ts +1 -0
  21. package/dist/utxo-MZNQ2QK4.js +2 -0
  22. package/dist/utxo-MZNQ2QK4.js.map +7 -0
  23. package/package.json +9 -4
  24. package/readme.md +15 -0
  25. package/src/actions/utxo.ts +56 -0
  26. package/src/constants.ts +23 -1
  27. package/src/init.ts +20 -0
  28. package/src/mod.ts +1 -5
  29. package/src/namespaces/evm.ts +4 -14
  30. package/src/namespaces/utxo.ts +24 -0
  31. package/src/provider.ts +2 -0
  32. package/src/signer.ts +4 -0
  33. package/src/signers/ethereum.ts +1 -1
  34. package/src/signers/utxo.ts +90 -0
  35. package/src/state.ts +15 -0
  36. package/src/{legacy/helpers.ts → utils.ts} +1 -14
  37. package/src/utxo/config.ts +67 -0
  38. package/src/utxo/psbt.test.ts +162 -0
  39. package/src/utxo/psbt.ts +96 -0
  40. package/dist/chunk-DRNBRMLU.js +0 -2
  41. package/dist/chunk-DRNBRMLU.js.map +0 -7
  42. package/dist/ethereum-AWO7VVVT.js.map +0 -7
  43. package/dist/legacy/index.d.ts +0 -18
  44. package/dist/provider-trezor.build.json +0 -1
  45. package/src/legacy/index.ts +0 -151
@@ -1 +0,0 @@
1
- {"inputs":{"src/state.ts":{"bytes":290,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/helpers.ts":{"bytes":2053,"imports":[{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"src/state.ts","kind":"import-statement","original":"../state"},{"path":"@trezor/connect-web","kind":"dynamic-import","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/signers/ethereum.ts":{"bytes":3834,"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/legacy/helpers.ts","kind":"import-statement","original":"../legacy/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":526,"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/legacy/index.ts":{"bytes":4024,"imports":[{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"src/signer.ts","kind":"import-statement","original":"../signer.js"},{"path":"src/state.ts","kind":"import-statement","original":"../state.js"},{"path":"src/legacy/helpers.ts","kind":"import-statement","original":"./helpers.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/constants.ts":{"bytes":1774,"imports":[{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"src/signer.ts","kind":"import-statement","original":"./signer.js"}],"format":"esm"},"src/namespaces/evm.ts":{"bytes":1843,"imports":[{"path":"@hub3js/core","kind":"import-statement","external":true},{"path":"@hub3js/evm","kind":"import-statement","external":true},{"path":"@hub3js/std/builders","kind":"import-statement","external":true},{"path":"@hub3js/std/operators","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"src/constants.ts","kind":"import-statement","original":"../constants.js"},{"path":"src/legacy/helpers.ts","kind":"import-statement","original":"../legacy/helpers.js"},{"path":"src/provider.ts","kind":"import-statement","original":"../provider.js"},{"path":"src/state.ts","kind":"import-statement","original":"../state.js"}],"format":"esm"},"src/provider.ts":{"bytes":810,"imports":[{"path":"@hub3js/core","kind":"import-statement","external":true},{"path":"src/constants.ts","kind":"import-statement","original":"./constants.js"},{"path":"src/namespaces/evm.ts","kind":"import-statement","original":"./namespaces/evm.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/mod.ts":{"bytes":321,"imports":[{"path":"@hub3js/core/utils","kind":"import-statement","external":true},{"path":"src/legacy/index.ts","kind":"import-statement","original":"./legacy/index.js"},{"path":"src/provider.ts","kind":"import-statement","original":"./provider.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/mod.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":14876},"dist/mod.js":{"imports":[{"path":"dist/chunk-DRNBRMLU.js","kind":"import-statement"},{"path":"@hub3js/core/utils","kind":"import-statement","external":true},{"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-AWO7VVVT.js","kind":"dynamic-import"},{"path":"@hub3js/core","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"@hub3js/core","kind":"import-statement","external":true},{"path":"@hub3js/evm","kind":"import-statement","external":true},{"path":"@hub3js/std/builders","kind":"import-statement","external":true},{"path":"@hub3js/std/operators","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true}],"exports":["versions"],"entryPoint":"src/mod.ts","inputs":{"src/mod.ts":{"bytesInOutput":131},"src/legacy/index.ts":{"bytesInOutput":1528},"src/signer.ts":{"bytesInOutput":310},"src/provider.ts":{"bytesInOutput":339},"src/constants.ts":{"bytesInOutput":894},"src/namespaces/evm.ts":{"bytesInOutput":705}},"bytes":4038},"dist/ethereum-AWO7VVVT.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":6437},"dist/ethereum-AWO7VVVT.js":{"imports":[{"path":"dist/chunk-DRNBRMLU.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":1474}},"bytes":1637},"dist/chunk-DRNBRMLU.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":3837},"dist/chunk-DRNBRMLU.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"],"inputs":{"src/state.ts":{"bytesInOutput":99},"src/legacy/helpers.ts":{"bytesInOutput":720}},"bytes":1006}}}
@@ -1,151 +0,0 @@
1
- import type { Environments } from '../types.js';
2
- import type { LegacyProviderInterface } from '@rango-dev/wallets-core/legacy';
3
- import type {
4
- Connect,
5
- ProviderConnectResult,
6
- WalletInfo,
7
- } from '@rango-dev/wallets-shared';
8
-
9
- import { Networks, WalletTypes } from '@rango-dev/wallets-shared';
10
- import { type BlockchainMeta, type SignerFactory } from 'rango-types';
11
-
12
- import signer from '../signer.js';
13
- import { setDerivationPath } from '../state.js';
14
-
15
- import {
16
- getEthereumAccounts,
17
- getTrezorInstance,
18
- getTrezorModule,
19
- getTrezorNormalizedDerivationPath,
20
- } from './helpers.js';
21
-
22
- let trezorManifest: Environments['manifest'] = {
23
- appUrl: '',
24
- email: '',
25
- };
26
- export const config = {
27
- type: WalletTypes.TREZOR,
28
- };
29
-
30
- export type { Environments };
31
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
- type Provider = any;
33
-
34
- export const init = (environments: Environments) => {
35
- trezorManifest = environments.manifest;
36
- };
37
-
38
- export const getInstance = getTrezorInstance;
39
-
40
- let isTrezorInitialized = false;
41
- export const connect: Connect = async ({ namespaces }) => {
42
- const results: ProviderConnectResult[] = [];
43
-
44
- const TrezorConnect = await getTrezorModule();
45
-
46
- const evmNamespace = namespaces?.find(
47
- (namespaceItem) => namespaceItem.namespace === 'EVM'
48
- );
49
-
50
- if (evmNamespace) {
51
- if (evmNamespace.derivationPath) {
52
- setDerivationPath(
53
- getTrezorNormalizedDerivationPath(evmNamespace.derivationPath)
54
- );
55
-
56
- if (!isTrezorInitialized) {
57
- await TrezorConnect.init({
58
- lazyLoad: true, // this param will prevent iframe injection until TrezorConnect.method will be called
59
- manifest: trezorManifest,
60
- });
61
-
62
- isTrezorInitialized = true;
63
- }
64
-
65
- const accounts = await getEthereumAccounts();
66
- results.push(accounts);
67
- } else {
68
- throw new Error('Derivation Path can not be empty.');
69
- }
70
- } else {
71
- throw new Error(
72
- `It appears that you have selected a namespace that is not yet supported by our system. Your namespaces: ${namespaces?.map(
73
- (namespaceItem) => namespaceItem.namespace
74
- )}`
75
- );
76
- }
77
-
78
- return results;
79
- };
80
-
81
- export const getSigners: (provider: Provider) => Promise<SignerFactory> =
82
- signer;
83
-
84
- export const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo = (
85
- allBlockChains
86
- ) => {
87
- const supportedChains: BlockchainMeta[] = [];
88
-
89
- const ethereumBlockchain = allBlockChains.find(
90
- (chain) => chain.name === Networks.ETHEREUM
91
- );
92
- if (ethereumBlockchain) {
93
- supportedChains.push(ethereumBlockchain);
94
- }
95
-
96
- return {
97
- name: 'Trezor',
98
- img: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/trezor/icon.svg',
99
- installLink: {
100
- DEFAULT: 'https://trezor.io/learn/a/download-verify-trezor-suite',
101
- },
102
- color: 'black',
103
- supportedChains,
104
- showOnMobile: false,
105
-
106
- needsNamespace: {
107
- selection: 'single',
108
- data: [
109
- {
110
- id: 'ETH',
111
- value: 'EVM',
112
- label: 'Ethereum',
113
- getSupportedChains: (allBlockchains: BlockchainMeta[]) =>
114
- allBlockchains.filter((chain) => chain.name === Networks.ETHEREUM),
115
- },
116
- ],
117
- },
118
- needsDerivationPath: {
119
- data: [
120
- {
121
- id: 'metamask',
122
- label: `Metamask (m/44'/60'/0'/0/index)`,
123
- namespace: 'EVM',
124
- generateDerivationPath: (index: string) => `44'/60'/0'/0/${index}`,
125
- },
126
- {
127
- id: 'ledgerLive',
128
- label: `LedgerLive (m/44'/60'/index'/0/0)`,
129
- namespace: 'EVM',
130
- generateDerivationPath: (index: string) => `44'/60'/${index}'/0/0`,
131
- },
132
- {
133
- id: 'legacy',
134
- label: `Legacy (m/44'/60'/0'/index)`,
135
- namespace: 'EVM',
136
- generateDerivationPath: (index: string) => `44'/60'/0'/${index}`,
137
- },
138
- ],
139
- },
140
- };
141
- };
142
-
143
- const buildLegacyProvider: () => LegacyProviderInterface = () => ({
144
- config,
145
- getInstance,
146
- connect,
147
- getSigners,
148
- getWalletInfo,
149
- });
150
-
151
- export { buildLegacyProvider };