@rango-dev/provider-ledger 0.32.1-next.1 → 0.32.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/constants.d.ts +0 -2
- package/dist/mod.d.ts +1 -1
- package/dist/mod.js +1 -1
- package/dist/mod.js.map +4 -4
- package/dist/provider-ledger.build.json +1 -1
- package/package.json +2 -2
- package/src/constants.ts +0 -7
- package/src/mod.ts +1 -5
- package/dist/legacy/index.d.ts +0 -16
- package/src/legacy/index.ts +0 -167
package/package.json
CHANGED
package/src/constants.ts
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import type { ProviderMetadata } from '@hub3js/core';
|
|
2
2
|
|
|
3
|
-
import { LegacyNetworks } from '@rango-dev/wallets-core/legacy';
|
|
4
3
|
import { Networks } from '@rango-dev/wallets-shared';
|
|
5
4
|
import { type BlockchainMeta } from 'rango-types';
|
|
6
5
|
|
|
7
6
|
import getSigners from './signer.js';
|
|
8
7
|
|
|
9
|
-
export const EVM_SUPPORTED_CHAINS = [
|
|
10
|
-
LegacyNetworks.ETHEREUM,
|
|
11
|
-
LegacyNetworks.POLYGON,
|
|
12
|
-
LegacyNetworks.BASE,
|
|
13
|
-
];
|
|
14
|
-
|
|
15
8
|
export const HEXADECIMAL_BASE = 16;
|
|
16
9
|
export const WALLET_ID = 'ledger';
|
|
17
10
|
|
package/src/mod.ts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { defineVersions } from '@hub3js/core/utils';
|
|
2
2
|
|
|
3
|
-
import { buildLegacyProvider } from './legacy/index.js';
|
|
4
3
|
import { buildProvider } from './provider.js';
|
|
5
4
|
|
|
6
5
|
const versions = () =>
|
|
7
|
-
defineVersions()
|
|
8
|
-
.version('0.0.0', buildLegacyProvider())
|
|
9
|
-
.version('1.0.0', buildProvider())
|
|
10
|
-
.build();
|
|
6
|
+
defineVersions().version('1.0.0', buildProvider()).build();
|
|
11
7
|
|
|
12
8
|
export { versions };
|
package/dist/legacy/index.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { LegacyProviderInterface } from '@rango-dev/wallets-core/legacy';
|
|
2
|
-
import type { Connect, Disconnect, WalletInfo } from '@rango-dev/wallets-shared';
|
|
3
|
-
import { WalletTypes } from '@rango-dev/wallets-shared';
|
|
4
|
-
import { type BlockchainMeta, type SignerFactory } from 'rango-types';
|
|
5
|
-
import { ledger as getLedgerInstance } from '../utils.js';
|
|
6
|
-
type InstanceType = any;
|
|
7
|
-
export declare const config: {
|
|
8
|
-
type: WalletTypes;
|
|
9
|
-
};
|
|
10
|
-
export declare const getInstance: typeof getLedgerInstance;
|
|
11
|
-
export declare const connect: Connect;
|
|
12
|
-
export declare const disconnect: Disconnect;
|
|
13
|
-
export declare const getSigners: (provider: InstanceType) => Promise<SignerFactory>;
|
|
14
|
-
export declare const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo;
|
|
15
|
-
declare const buildLegacyProvider: () => LegacyProviderInterface;
|
|
16
|
-
export { buildLegacyProvider };
|
package/src/legacy/index.ts
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import type { LegacyProviderInterface } from '@rango-dev/wallets-core/legacy';
|
|
2
|
-
import type {
|
|
3
|
-
Connect,
|
|
4
|
-
Disconnect,
|
|
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
|
-
import {
|
|
15
|
-
getEthereumAccounts,
|
|
16
|
-
ledger as getLedgerInstance,
|
|
17
|
-
getSolanaAccounts,
|
|
18
|
-
transportDisconnect,
|
|
19
|
-
} from '../utils.js';
|
|
20
|
-
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
-
type InstanceType = any;
|
|
23
|
-
|
|
24
|
-
export const config = {
|
|
25
|
-
type: WalletTypes.LEDGER,
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const getInstance = getLedgerInstance;
|
|
29
|
-
export const connect: Connect = async ({ namespaces }) => {
|
|
30
|
-
const results: ProviderConnectResult[] = [];
|
|
31
|
-
|
|
32
|
-
const solanaNamespace = namespaces?.find(
|
|
33
|
-
(namespaceItem) => namespaceItem.namespace === 'Solana'
|
|
34
|
-
);
|
|
35
|
-
const evmNamespace = namespaces?.find(
|
|
36
|
-
(namespaceItem) => namespaceItem.namespace === 'EVM'
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
if (solanaNamespace) {
|
|
40
|
-
if (solanaNamespace.derivationPath) {
|
|
41
|
-
setDerivationPath(solanaNamespace.derivationPath);
|
|
42
|
-
const accounts = await getSolanaAccounts();
|
|
43
|
-
results.push(accounts);
|
|
44
|
-
} else {
|
|
45
|
-
throw new Error('Derivation Path can not be empty.');
|
|
46
|
-
}
|
|
47
|
-
} else if (evmNamespace) {
|
|
48
|
-
if (evmNamespace.derivationPath) {
|
|
49
|
-
setDerivationPath(evmNamespace.derivationPath);
|
|
50
|
-
const accounts = await getEthereumAccounts();
|
|
51
|
-
results.push(accounts);
|
|
52
|
-
} else {
|
|
53
|
-
throw new Error('Derivation Path can not be empty.');
|
|
54
|
-
}
|
|
55
|
-
} else {
|
|
56
|
-
throw new Error(
|
|
57
|
-
`It appears that you have selected a namespace that is not yet supported by our system. Your namespaces: ${namespaces?.map(
|
|
58
|
-
(namespaceItem) => namespaceItem.namespace
|
|
59
|
-
)}`
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return results;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
export const disconnect: Disconnect = async () => {
|
|
67
|
-
void transportDisconnect();
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export const getSigners: (provider: InstanceType) => Promise<SignerFactory> =
|
|
71
|
-
signer;
|
|
72
|
-
|
|
73
|
-
export const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo = (
|
|
74
|
-
allBlockChains
|
|
75
|
-
) => {
|
|
76
|
-
const supportedChains: BlockchainMeta[] = [];
|
|
77
|
-
|
|
78
|
-
const ethereumBlockchain = allBlockChains.find(
|
|
79
|
-
(chain) => chain.name === Networks.ETHEREUM
|
|
80
|
-
);
|
|
81
|
-
if (ethereumBlockchain) {
|
|
82
|
-
supportedChains.push(ethereumBlockchain);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const solanaBlockchain = allBlockChains.find(
|
|
86
|
-
(chain) => chain.name === Networks.SOLANA
|
|
87
|
-
);
|
|
88
|
-
if (solanaBlockchain) {
|
|
89
|
-
supportedChains.push(solanaBlockchain);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return {
|
|
93
|
-
name: 'Ledger',
|
|
94
|
-
img: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/ledger/icon.svg',
|
|
95
|
-
installLink: {
|
|
96
|
-
DEFAULT:
|
|
97
|
-
'https://support.ledger.com/hc/en-us/articles/4404389606417-Download-and-install-Ledger-Live?docs=true',
|
|
98
|
-
},
|
|
99
|
-
color: 'black',
|
|
100
|
-
supportedChains,
|
|
101
|
-
showOnMobile: false,
|
|
102
|
-
needsDerivationPath: {
|
|
103
|
-
data: [
|
|
104
|
-
{
|
|
105
|
-
id: 'metamask',
|
|
106
|
-
label: `Metamask (m/44'/60'/0'/0/index)`,
|
|
107
|
-
namespace: 'EVM',
|
|
108
|
-
generateDerivationPath: (index: string) => `44'/60'/0'/0/${index}`,
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
id: 'ledgerLive',
|
|
112
|
-
label: `LedgerLive (m/44'/60'/index'/0/0)`,
|
|
113
|
-
namespace: 'EVM',
|
|
114
|
-
generateDerivationPath: (index: string) => `44'/60'/${index}'/0/0`,
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
id: 'legacy',
|
|
118
|
-
label: `Legacy (m/44'/60'/0'/index)`,
|
|
119
|
-
namespace: 'EVM',
|
|
120
|
-
generateDerivationPath: (index: string) => `44'/60'/0'/${index}`,
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
id: `(m/44'/501'/index')`,
|
|
124
|
-
label: `(m/44'/501'/index')`,
|
|
125
|
-
namespace: 'Solana',
|
|
126
|
-
generateDerivationPath: (index: string) => `44'/501'/${index}'`,
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
id: `(m/44'/501'/0'/index)`,
|
|
130
|
-
label: `(m/44'/501'/0'/index)`,
|
|
131
|
-
namespace: 'Solana',
|
|
132
|
-
generateDerivationPath: (index: string) => `44'/501'/0'/${index}`,
|
|
133
|
-
},
|
|
134
|
-
],
|
|
135
|
-
},
|
|
136
|
-
|
|
137
|
-
needsNamespace: {
|
|
138
|
-
selection: 'single',
|
|
139
|
-
data: [
|
|
140
|
-
{
|
|
141
|
-
label: 'EVM',
|
|
142
|
-
value: 'EVM',
|
|
143
|
-
id: 'ETH',
|
|
144
|
-
getSupportedChains: (allBlockchains: BlockchainMeta[]) =>
|
|
145
|
-
allBlockchains.filter((chain) => chain.name === Networks.ETHEREUM),
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
label: 'Solana',
|
|
149
|
-
value: 'Solana',
|
|
150
|
-
id: 'SOLANA',
|
|
151
|
-
getSupportedChains: (allBlockchains: BlockchainMeta[]) =>
|
|
152
|
-
allBlockchains.filter((chain) => chain.name === Networks.SOLANA),
|
|
153
|
-
},
|
|
154
|
-
],
|
|
155
|
-
},
|
|
156
|
-
};
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
const buildLegacyProvider: () => LegacyProviderInterface = () => ({
|
|
160
|
-
config,
|
|
161
|
-
getInstance,
|
|
162
|
-
connect,
|
|
163
|
-
getSigners,
|
|
164
|
-
getWalletInfo,
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
export { buildLegacyProvider };
|