@pezkuwi/hw-ledger 14.0.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/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # @pezkuwi/hw-ledger
2
+
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "author": "Jaco Greeff <jacogr@gmail.com>",
3
+ "bugs": "https://github.com/pezkuwichain/pezkuwi-common/issues",
4
+ "engines": {
5
+ "node": ">=18"
6
+ },
7
+ "homepage": "https://github.com/pezkuwichain/pezkuwi-common/tree/master/packages/hw-ledger#readme",
8
+ "license": "Apache-2.0",
9
+ "name": "@pezkuwi/hw-ledger",
10
+ "repository": {
11
+ "directory": "packages/hw-ledger",
12
+ "type": "git",
13
+ "url": "https://github.com/pezkuwichain/pezkuwi-common.git"
14
+ },
15
+ "sideEffects": [
16
+ "./packageDetect.js",
17
+ "./packageDetect.cjs"
18
+ ],
19
+ "type": "module",
20
+ "version": "14.0.1",
21
+ "main": "index.js",
22
+ "dependencies": {
23
+ "@pezkuwi/hw-ledger-transports": "14.0.1",
24
+ "@pezkuwi/util": "14.0.1",
25
+ "@zondax/ledger-substrate": "1.1.1",
26
+ "tslib": "^2.8.0"
27
+ }
28
+ }
package/src/Ledger.ts ADDED
@@ -0,0 +1,144 @@
1
+ // Copyright 2017-2025 @polkadot/hw-ledger authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { SubstrateApp } from '@zondax/ledger-substrate';
5
+ import type { TransportDef, TransportType } from '@pezkuwi/hw-ledger-transports/types';
6
+ import type { AccountOptions, LedgerAddress, LedgerSignature, LedgerVersion } from './types.js';
7
+
8
+ import { newSubstrateApp } from '@zondax/ledger-substrate';
9
+
10
+ import { transports } from '@pezkuwi/hw-ledger-transports';
11
+ import { hexAddPrefix, u8aToBuffer, u8aWrapBytes } from '@pezkuwi/util';
12
+
13
+ import { LEDGER_DEFAULT_ACCOUNT, LEDGER_DEFAULT_CHANGE, LEDGER_DEFAULT_INDEX, LEDGER_SUCCESS_CODE } from './constants.js';
14
+ import { ledgerApps } from './defaults.js';
15
+
16
+ export { packageInfo } from './packageInfo.js';
17
+
18
+ type Chain = keyof typeof ledgerApps;
19
+
20
+ type WrappedResult = Awaited<ReturnType<SubstrateApp['getAddress' | 'getVersion' | 'sign']>>;
21
+
22
+ /** @internal Wraps a SubstrateApp call, checking the result for any errors which result in a rejection */
23
+ async function wrapError <T extends WrappedResult> (promise: Promise<T>): Promise<T> {
24
+ const result = await promise;
25
+
26
+ if (result.return_code !== LEDGER_SUCCESS_CODE) {
27
+ throw new Error(result.error_message);
28
+ }
29
+
30
+ return result;
31
+ }
32
+
33
+ /** @internal Wraps a sign/signRaw call and returns the associated signature */
34
+ function sign (method: 'sign' | 'signRaw', message: Uint8Array, accountOffset = 0, addressOffset = 0, { account = LEDGER_DEFAULT_ACCOUNT, addressIndex = LEDGER_DEFAULT_INDEX, change = LEDGER_DEFAULT_CHANGE }: Partial<AccountOptions> = {}): (app: SubstrateApp) => Promise<LedgerSignature> {
35
+ return async (app: SubstrateApp): Promise<LedgerSignature> => {
36
+ const { signature } = await wrapError(app[method](account + accountOffset, change, addressIndex + addressOffset, u8aToBuffer(message)));
37
+
38
+ return {
39
+ signature: hexAddPrefix(signature.toString('hex'))
40
+ };
41
+ };
42
+ }
43
+
44
+ /**
45
+ * @name Ledger
46
+ *
47
+ * @description
48
+ * Legacy wrapper for a ledger app -
49
+ * - it connects automatically on use, creating an underlying interface as required
50
+ * - Promises reject with errors (unwrapped errors from @zondax/ledger-substrate)
51
+ * @deprecated Use LedgerGeneric for up to date integration with ledger
52
+ */
53
+ export class Ledger {
54
+ readonly #ledgerName: string;
55
+ readonly #transportDef: TransportDef;
56
+
57
+ #app: SubstrateApp | null = null;
58
+
59
+ constructor (transport: TransportType, chain: Chain) {
60
+ const ledgerName = ledgerApps[chain];
61
+ const transportDef = transports.find(({ type }) => type === transport);
62
+
63
+ if (!ledgerName) {
64
+ throw new Error(`Unsupported Ledger chain ${chain}`);
65
+ } else if (!transportDef) {
66
+ throw new Error(`Unsupported Ledger transport ${transport}`);
67
+ }
68
+
69
+ this.#ledgerName = ledgerName;
70
+ this.#transportDef = transportDef;
71
+ }
72
+
73
+ /**
74
+ * Returns the address associated with a specific account & address offset. Optionally
75
+ * asks for on-device confirmation
76
+ */
77
+ public async getAddress (confirm = false, accountOffset = 0, addressOffset = 0, { account = LEDGER_DEFAULT_ACCOUNT, addressIndex = LEDGER_DEFAULT_INDEX, change = LEDGER_DEFAULT_CHANGE }: Partial<AccountOptions> = {}): Promise<LedgerAddress> {
78
+ return this.withApp(async (app: SubstrateApp): Promise<LedgerAddress> => {
79
+ const { address, pubKey } = await wrapError(app.getAddress(account + accountOffset, change, addressIndex + addressOffset, confirm));
80
+
81
+ return {
82
+ address,
83
+ publicKey: hexAddPrefix(pubKey)
84
+ };
85
+ });
86
+ }
87
+
88
+ /**
89
+ * Returns the version of the Ledger application on the device
90
+ */
91
+ public async getVersion (): Promise<LedgerVersion> {
92
+ return this.withApp(async (app: SubstrateApp): Promise<LedgerVersion> => {
93
+ const { device_locked: isLocked, major, minor, patch, test_mode: isTestMode } = await wrapError(app.getVersion());
94
+
95
+ return {
96
+ isLocked,
97
+ isTestMode,
98
+ version: [major, minor, patch]
99
+ };
100
+ });
101
+ }
102
+
103
+ /**
104
+ * Signs a transaction on the Ledger device
105
+ */
106
+ public async sign (message: Uint8Array, accountOffset?: number, addressOffset?: number, options?: Partial<AccountOptions>): Promise<LedgerSignature> {
107
+ return this.withApp(sign('sign', message, accountOffset, addressOffset, options));
108
+ }
109
+
110
+ /**
111
+ * Signs a message (non-transactional) on the Ledger device
112
+ */
113
+ public async signRaw (message: Uint8Array, accountOffset?: number, addressOffset?: number, options?: Partial<AccountOptions>): Promise<LedgerSignature> {
114
+ return this.withApp(sign('signRaw', u8aWrapBytes(message), accountOffset, addressOffset, options));
115
+ }
116
+
117
+ /**
118
+ * @internal
119
+ *
120
+ * Returns a created SubstrateApp to perform operations against. Generally
121
+ * this is only used internally, to ensure consistent bahavior.
122
+ */
123
+ async withApp <T> (fn: (app: SubstrateApp) => Promise<T>): Promise<T> {
124
+ try {
125
+ if (!this.#app) {
126
+ const transport = await this.#transportDef.create();
127
+
128
+ // We need this override for the actual type passing - the Deno environment
129
+ // is quite a bit stricter and it yields invalids between the two (specifically
130
+ // since we mangle the imports from .default in the types for CJS/ESM and between
131
+ // esm.sh versions this yields problematic outputs)
132
+ //
133
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
134
+ this.#app = newSubstrateApp(transport as any, this.#ledgerName);
135
+ }
136
+
137
+ return await fn(this.#app);
138
+ } catch (error) {
139
+ this.#app = null;
140
+
141
+ throw error;
142
+ }
143
+ }
144
+ }
@@ -0,0 +1,275 @@
1
+ // Copyright 2017-2025 @polkadot/hw-ledger authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { TransportDef, TransportType } from '@pezkuwi/hw-ledger-transports/types';
5
+ import type { AccountOptionsGeneric, LedgerAddress, LedgerSignature, LedgerVersion } from './types.js';
6
+
7
+ import { PolkadotGenericApp } from '@zondax/ledger-substrate';
8
+
9
+ import { transports } from '@pezkuwi/hw-ledger-transports';
10
+ import { hexAddPrefix, u8aToBuffer, u8aWrapBytes } from '@pezkuwi/util';
11
+
12
+ import { ledgerApps } from './defaults.js';
13
+
14
+ export { packageInfo } from './packageInfo.js';
15
+
16
+ type Chain = keyof typeof ledgerApps;
17
+
18
+ type WrappedResult = Awaited<ReturnType<PolkadotGenericApp['getAddress' | 'getVersion' | 'sign' | 'signWithMetadata']>>;
19
+
20
+ // FIXME This type is a copy of the `class ResponseError`
21
+ // imported from `@zondax/ledger-js`. Happens because ledger-js includes
22
+ // circular dependencies. This is a hack to avoid versioning issues
23
+ // with Deno.
24
+ interface ResponseError {
25
+ errorMessage: string
26
+ returnCode: number
27
+ }
28
+
29
+ /** @internal Wraps a PolkadotGenericApp call, checking the result for any errors which result in a rejection */
30
+ async function wrapError <T extends WrappedResult> (promise: Promise<T>): Promise<T> {
31
+ let result: T;
32
+
33
+ try {
34
+ result = await promise;
35
+ } catch (e: unknown) {
36
+ // We check to see if the propogated error is the newer ResponseError type.
37
+ // The response code use to be part of the result, but with the latest breaking changes from 0.42.x
38
+ // the interface and it's types have completely changed.
39
+ if ((e as ResponseError).returnCode) {
40
+ throw new Error(`${(e as ResponseError).returnCode}: ${(e as ResponseError).errorMessage}`);
41
+ }
42
+
43
+ throw new Error((e as Error).message);
44
+ }
45
+
46
+ return result;
47
+ }
48
+
49
+ /** @internal Wraps a signEd25519/signRawEd25519 call and returns the associated signature */
50
+ function sign (method: 'signEd25519' | 'signRawEd25519', message: Uint8Array, slip44: number, accountIndex = 0, addressOffset = 0): (app: PolkadotGenericApp) => Promise<LedgerSignature> {
51
+ const bip42Path = `m/44'/${slip44}'/${accountIndex}'/${0}'/${addressOffset}'`;
52
+
53
+ return async (app: PolkadotGenericApp): Promise<LedgerSignature> => {
54
+ const { signature } = await wrapError(app[method](bip42Path, u8aToBuffer(message)));
55
+
56
+ return {
57
+ signature: hexAddPrefix(signature.toString('hex'))
58
+ };
59
+ };
60
+ }
61
+
62
+ /** @internal Wraps a signEcdsa/signRawEcdsa call and returns the associated signature */
63
+ function signEcdsa (method: 'signEcdsa' | 'signRawEcdsa', message: Uint8Array, slip44: number, accountIndex = 0, addressOffset = 0): (app: PolkadotGenericApp) => Promise<LedgerSignature> {
64
+ const bip42Path = `m/44'/${slip44}'/${accountIndex}'/${0}'/${addressOffset}'`;
65
+
66
+ return async (app: PolkadotGenericApp): Promise<LedgerSignature> => {
67
+ const { r, s, v } = await wrapError(app[method](bip42Path, u8aToBuffer(message)));
68
+
69
+ const signature = Buffer.concat([r, s, v]);
70
+
71
+ return {
72
+ signature: hexAddPrefix(signature.toString('hex'))
73
+ };
74
+ };
75
+ }
76
+
77
+ /** @internal Wraps a signWithMetadataEd25519 call and returns the associated signature */
78
+ function signWithMetadata (message: Uint8Array, slip44: number, accountIndex = 0, addressOffset = 0, { metadata }: Partial<AccountOptionsGeneric> = {}): (app: PolkadotGenericApp) => Promise<LedgerSignature> {
79
+ const bip42Path = `m/44'/${slip44}'/${accountIndex}'/${0}'/${addressOffset}'`;
80
+
81
+ return async (app: PolkadotGenericApp): Promise<LedgerSignature> => {
82
+ if (!metadata) {
83
+ throw new Error('The metadata option must be present when using signWithMetadata');
84
+ }
85
+
86
+ const bufferMsg = Buffer.from(message);
87
+
88
+ const { signature } = await wrapError(app.signWithMetadataEd25519(bip42Path, bufferMsg, metadata));
89
+
90
+ return {
91
+ signature: hexAddPrefix(signature.toString('hex'))
92
+ };
93
+ };
94
+ }
95
+
96
+ /** @internal Wraps a signWithMetadataEcdsa call and returns the associated signature */
97
+ function signWithMetadataEcdsa (message: Uint8Array, slip44: number, accountIndex = 0, addressOffset = 0, { metadata }: Partial<AccountOptionsGeneric> = {}): (app: PolkadotGenericApp) => Promise<LedgerSignature> {
98
+ const bip42Path = `m/44'/${slip44}'/${accountIndex}'/${0}'/${addressOffset}'`;
99
+
100
+ return async (app: PolkadotGenericApp): Promise<LedgerSignature> => {
101
+ if (!metadata) {
102
+ throw new Error('The metadata option must be present when using signWithMetadata');
103
+ }
104
+
105
+ const bufferMsg = Buffer.from(message);
106
+
107
+ const { r, s, v } = await wrapError(app.signWithMetadataEcdsa(bip42Path, bufferMsg, metadata));
108
+
109
+ const signature = Buffer.concat([r, s, v]);
110
+
111
+ return {
112
+ signature: hexAddPrefix(signature.toString('hex'))
113
+ };
114
+ };
115
+ }
116
+
117
+ /**
118
+ * @name Ledger
119
+ *
120
+ * @description
121
+ * A very basic wrapper for a ledger app -
122
+ * - it connects automatically on use, creating an underlying interface as required
123
+ * - Promises reject with errors (unwrapped errors from @zondax/ledger-substrate-js)
124
+ */
125
+ export class LedgerGeneric {
126
+ readonly #transportDef: TransportDef;
127
+ readonly #slip44: number;
128
+ /**
129
+ * The chainId is represented by the chains token in all lowercase. Example: Polkadot -> dot
130
+ */
131
+ readonly #chainId?: string;
132
+ /**
133
+ * The metaUrl is seen as a server url that the underlying `PolkadotGenericApp` will use to
134
+ * retrieve the signature given a tx blob, and a chainId. It is important to note that if you would like to avoid
135
+ * having any network calls made, use `signWithMetadata`, and avoid `sign`.
136
+ */
137
+ readonly #metaUrl?: string;
138
+
139
+ #app: PolkadotGenericApp | null = null;
140
+
141
+ constructor (transport: TransportType, chain: Chain, slip44: number, chainId?: string, metaUrl?: string) {
142
+ const ledgerName = ledgerApps[chain];
143
+ const transportDef = transports.find(({ type }) => type === transport);
144
+
145
+ if (!ledgerName) {
146
+ throw new Error(`Unsupported Ledger chain ${chain}`);
147
+ } else if (!transportDef) {
148
+ throw new Error(`Unsupported Ledger transport ${transport}`);
149
+ }
150
+
151
+ this.#metaUrl = metaUrl;
152
+ this.#chainId = chainId;
153
+ this.#slip44 = slip44;
154
+ this.#transportDef = transportDef;
155
+ }
156
+
157
+ /**
158
+ * @description Returns the address associated with a specific Ed25519 account & address offset. Optionally
159
+ * asks for on-device confirmation
160
+ */
161
+ public async getAddress (ss58Prefix: number, confirm = false, accountIndex = 0, addressOffset = 0): Promise<LedgerAddress> {
162
+ const bip42Path = `m/44'/${this.#slip44}'/${accountIndex}'/${0}'/${addressOffset}'`;
163
+
164
+ return this.withApp(async (app: PolkadotGenericApp): Promise<LedgerAddress> => {
165
+ const { address, pubKey } = await wrapError(app.getAddressEd25519(bip42Path, ss58Prefix, confirm));
166
+
167
+ return {
168
+ address,
169
+ publicKey: hexAddPrefix(pubKey)
170
+ };
171
+ });
172
+ }
173
+
174
+ /**
175
+ * @description Returns the address associated with a specific ecdsa account & address offset. Optionally
176
+ * asks for on-device confirmation
177
+ */
178
+ public async getAddressEcdsa (confirm = false, accountIndex = 0, addressOffset = 0) {
179
+ const bip42Path = `m/44'/${this.#slip44}'/${accountIndex}'/${0}'/${addressOffset}'`;
180
+
181
+ return this.withApp(async (app: PolkadotGenericApp): Promise<LedgerAddress> => {
182
+ const { address, pubKey } = await wrapError(app.getAddressEcdsa(bip42Path, confirm));
183
+
184
+ return {
185
+ address,
186
+ publicKey: hexAddPrefix(pubKey)
187
+ };
188
+ });
189
+ }
190
+
191
+ /**
192
+ * @description Returns the version of the Ledger application on the device
193
+ */
194
+ public async getVersion (): Promise<LedgerVersion> {
195
+ return this.withApp(async (app: PolkadotGenericApp): Promise<LedgerVersion> => {
196
+ const { deviceLocked: isLocked, major, minor, patch, testMode: isTestMode } = await wrapError(app.getVersion());
197
+
198
+ return {
199
+ isLocked: !!isLocked,
200
+ isTestMode: !!isTestMode,
201
+ version: [major || 0, minor || 0, patch || 0]
202
+ };
203
+ });
204
+ }
205
+
206
+ /**
207
+ * @description Signs a transaction on the Ledger device. This requires the LedgerGeneric class to be instantiated with `chainId`, and `metaUrl`
208
+ */
209
+ public async sign (message: Uint8Array, accountIndex?: number, addressOffset?: number): Promise<LedgerSignature> {
210
+ return this.withApp(sign('signEd25519', message, this.#slip44, accountIndex, addressOffset));
211
+ }
212
+
213
+ /**
214
+ * @description Signs a message (non-transactional) on the Ledger device
215
+ */
216
+ public async signRaw (message: Uint8Array, accountIndex?: number, addressOffset?: number): Promise<LedgerSignature> {
217
+ return this.withApp(sign('signRawEd25519', u8aWrapBytes(message), this.#slip44, accountIndex, addressOffset));
218
+ }
219
+
220
+ /**
221
+ * @description Signs a transaction on the Ledger device with Ecdsa. This requires the LedgerGeneric class to be instantiated with `chainId`, and `metaUrl`
222
+ */
223
+ public async signEcdsa (message: Uint8Array, accountIndex?: number, addressOffset?: number): Promise<LedgerSignature> {
224
+ return this.withApp(signEcdsa('signEcdsa', u8aWrapBytes(message), this.#slip44, accountIndex, addressOffset));
225
+ }
226
+
227
+ /**
228
+ * @description Signs a message with Ecdsa (non-transactional) on the Ledger device
229
+ */
230
+ public async signRawEcdsa (message: Uint8Array, accountIndex?: number, addressOffset?: number): Promise<LedgerSignature> {
231
+ return this.withApp(signEcdsa('signRawEcdsa', u8aWrapBytes(message), this.#slip44, accountIndex, addressOffset));
232
+ }
233
+
234
+ /**
235
+ * @description Signs a transaction on the ledger device provided some metadata.
236
+ */
237
+ public async signWithMetadata (message: Uint8Array, accountIndex?: number, addressOffset?: number, options?: Partial<AccountOptionsGeneric>): Promise<LedgerSignature> {
238
+ return this.withApp(signWithMetadata(message, this.#slip44, accountIndex, addressOffset, options));
239
+ }
240
+
241
+ /**
242
+ * @description Signs a transaction on the ledger device for an ecdsa signature provided some metadata.
243
+ */
244
+ public async signWithMetadataEcdsa (message: Uint8Array, accountIndex?: number, addressOffset?: number, options?: Partial<AccountOptionsGeneric>) {
245
+ return this.withApp(signWithMetadataEcdsa(message, this.#slip44, accountIndex, addressOffset, options));
246
+ }
247
+
248
+ /**
249
+ * @internal
250
+ *
251
+ * Returns a created PolkadotGenericApp to perform operations against. Generally
252
+ * this is only used internally, to ensure consistent bahavior.
253
+ */
254
+ async withApp <T> (fn: (app: PolkadotGenericApp) => Promise<T>): Promise<T> {
255
+ try {
256
+ if (!this.#app) {
257
+ const transport = await this.#transportDef.create();
258
+
259
+ // We need this override for the actual type passing - the Deno environment
260
+ // is quite a bit stricter and it yields invalids between the two (specifically
261
+ // since we mangle the imports from .default in the types for CJS/ESM and between
262
+ // esm.sh versions this yields problematic outputs)
263
+ //
264
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
265
+ this.#app = new PolkadotGenericApp(transport as any, this.#chainId, this.#metaUrl);
266
+ }
267
+
268
+ return await fn(this.#app);
269
+ } catch (error) {
270
+ this.#app = null;
271
+
272
+ throw error;
273
+ }
274
+ }
275
+ }
package/src/bundle.ts ADDED
@@ -0,0 +1,8 @@
1
+ // Copyright 2017-2025 @polkadot/hw-ledger authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // This is necessary to ensure users still have access to class Ledger even though its deprecated.
5
+ //
6
+ // eslint-disable-next-line deprecation/deprecation
7
+ export { Ledger } from './Ledger.js';
8
+ export { LedgerGeneric } from './LedgerGeneric.js';
@@ -0,0 +1,10 @@
1
+ // Copyright 2017-2025 @polkadot/hw-ledger authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export const LEDGER_DEFAULT_ACCOUNT = 0x80000000;
5
+
6
+ export const LEDGER_DEFAULT_CHANGE = 0x80000000;
7
+
8
+ export const LEDGER_DEFAULT_INDEX = 0x80000000;
9
+
10
+ export const LEDGER_SUCCESS_CODE = 0x9000;
@@ -0,0 +1,20 @@
1
+ // Copyright 2017-2025 @polkadot/hw-ledger authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ /// <reference types="@polkadot/dev-test/globals.d.ts" />
5
+
6
+ import { supportedApps } from '@zondax/ledger-substrate';
7
+
8
+ import { prevLedgerRecord } from './defaults.js';
9
+
10
+ describe('ledgerApps', (): void => {
11
+ for (const k of Object.keys(prevLedgerRecord)) {
12
+ it(`${k} is available in @zondax/ledger-substrate`, (): void => {
13
+ expect(
14
+ supportedApps.find(({ name }) =>
15
+ name === prevLedgerRecord[k]
16
+ )
17
+ ).toBeDefined();
18
+ });
19
+ }
20
+ });
@@ -0,0 +1,69 @@
1
+ // Copyright 2017-2025 @polkadot/hw-ledger authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // These map to the known name in the @zondax/ledger-substrate/supported_apps package
5
+ // but they do not reflect all ledger apps that are supported. Since ledger now has support for all
6
+ // substrate chains via the PolkadotGenericApp, any new chains that need ledger support can be added to
7
+ // `genericLedgerApps` below.
8
+ export const prevLedgerRecord: Record<string, string> = {
9
+ acala: 'Acala',
10
+ ajuna: 'Ajuna',
11
+ 'aleph-node': 'AlephZero',
12
+ astar: 'Astar',
13
+ bifrost: 'Bifrost',
14
+ 'bifrost-kusama': 'BifrostKusama',
15
+ centrifuge: 'Centrifuge',
16
+ composable: 'Composable',
17
+ darwinia: 'Darwinia',
18
+ 'dock-mainnet': 'Dock',
19
+ edgeware: 'Edgeware',
20
+ enjin: 'Enjin',
21
+ equilibrium: 'Equilibrium',
22
+ genshiro: 'Genshiro',
23
+ hydradx: 'HydraDX',
24
+ 'interlay-parachain': 'Interlay',
25
+ karura: 'Karura',
26
+ khala: 'Khala',
27
+ kusama: 'Kusama',
28
+ matrixchain: 'Matrixchain',
29
+ nodle: 'Nodle',
30
+ origintrail: 'OriginTrail',
31
+ parallel: 'Parallel',
32
+ peaq: 'Peaq',
33
+ pendulum: 'Pendulum',
34
+ phala: 'Phala',
35
+ picasso: 'Picasso',
36
+ polkadex: 'Polkadex',
37
+ polkadot: 'Polkadot',
38
+ polymesh: 'Polymesh',
39
+ quartz: 'Quartz',
40
+ sora: 'Sora',
41
+ stafi: 'Stafi',
42
+ statemine: 'Statemine',
43
+ statemint: 'Statemint',
44
+ ternoa: 'Ternoa',
45
+ unique: 'Unique',
46
+ vtb: 'VTB',
47
+ xxnetwork: 'XXNetwork',
48
+ zeitgeist: 'Zeitgeist'
49
+ };
50
+
51
+ // Any chains moving forward that are supported by the PolkadotGenericApp from ledger will input their names below.
52
+ export const genericLedgerApps = {
53
+ bittensor: 'Bittensor',
54
+ creditcoin3: 'Creditcoin3',
55
+ dentnet: 'DENTNet',
56
+ encointer: 'Encointer',
57
+ frequency: 'Frequency',
58
+ integritee: 'Integritee',
59
+ liberland: 'Liberland',
60
+ mythos: 'Mythos',
61
+ polimec: 'Polimec',
62
+ vara: 'Vara'
63
+ };
64
+
65
+ // These match up with the keys of the knownLedger object in the @polkadot/networks/defaults/ledger.ts
66
+ export const ledgerApps: Record<string, string> = {
67
+ ...prevLedgerRecord,
68
+ ...genericLedgerApps
69
+ };
package/src/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ // Copyright 2017-2025 @polkadot/hw-ledger authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import './packageDetect.js';
5
+
6
+ export * from './bundle.js';
package/src/mod.ts ADDED
@@ -0,0 +1,4 @@
1
+ // Copyright 2017-2025 @polkadot/hw-ledger authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './index.js';
@@ -0,0 +1,13 @@
1
+ // Copyright 2017-2025 @polkadot/hw-ledger authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // Do not edit, auto-generated by @polkadot/dev
5
+ // (packageInfo imports will be kept as-is, user-editable)
6
+
7
+ import { packageInfo as transportInfo } from '@pezkuwi/hw-ledger-transports/packageInfo';
8
+ import { detectPackage } from '@pezkuwi/util';
9
+ import { packageInfo as utilInfo } from '@pezkuwi/util/packageInfo';
10
+
11
+ import { packageInfo } from './packageInfo.js';
12
+
13
+ detectPackage(packageInfo, null, [transportInfo, utilInfo]);
@@ -0,0 +1,6 @@
1
+ // Copyright 2017-2025 @polkadot/hw-ledger authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // Do not edit, auto-generated by @polkadot/dev
5
+
6
+ export const packageInfo = { name: '@polkadot/hw-ledger', path: 'auto', type: 'auto', version: '14.0.1' };
package/src/types.ts ADDED
@@ -0,0 +1,42 @@
1
+ // Copyright 2017-2025 @polkadot/hw-ledger authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { HexString } from '@pezkuwi/util/types';
5
+
6
+ /**
7
+ * Legacy Type that works with the `Ledger` class.
8
+ */
9
+ export interface AccountOptions {
10
+ /** The index of the account */
11
+ account: number;
12
+ /** The index of the address */
13
+ addressIndex: number;
14
+ /** The change to apply */
15
+ change: number;
16
+ }
17
+
18
+ export interface AccountOptionsGeneric extends AccountOptions {
19
+ /** Option for PolkadotGenericApp.signWithMetadata */
20
+ metadata: Buffer;
21
+ }
22
+
23
+ export interface LedgerAddress {
24
+ /** The ss58 encoded address */
25
+ address: string;
26
+ /** The hex-encoded publicKey */
27
+ publicKey: HexString;
28
+ }
29
+
30
+ export interface LedgerSignature {
31
+ /** A hex-encoded signature, as generated by the device */
32
+ signature: HexString;
33
+ }
34
+
35
+ export interface LedgerVersion {
36
+ /** Indicator flag for locked status */
37
+ isLocked: boolean;
38
+ /** Indicator flag for testmode status */
39
+ isTestMode: boolean;
40
+ /** The software version for this device */
41
+ version: [major: number, minor: number, patch: number];
42
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "baseUrl": "..",
5
+ "outDir": "./build",
6
+ "rootDir": "./src"
7
+ },
8
+ "exclude": [
9
+ "**/*.spec.ts",
10
+ "**/mod.ts"
11
+ ],
12
+ "references": [
13
+ { "path": "../hw-ledger-transports/tsconfig.build.json" },
14
+ { "path": "../util/tsconfig.build.json" }
15
+ ]
16
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "baseUrl": "..",
5
+ "outDir": "./build",
6
+ "rootDir": "./src",
7
+ "emitDeclarationOnly": false,
8
+ "noEmit": true
9
+ },
10
+ "include": [
11
+ "**/*.spec.ts"
12
+ ],
13
+ "references": [
14
+ { "path": "../hw-ledger/tsconfig.build.json" }
15
+ ]
16
+ }