@pezkuwi/hw-ledger 14.0.12 → 14.0.14

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