Skip to content

Commit 1f0f2c5

Browse files
hw-{ledger, ledger-transports}, keyring, networks, util, util-crypto, x-{bigint, fetch, global, randomvalues, textdecoder, textencoder, ws} 13.5.1
1 parent 407bd34 commit 1f0f2c5

File tree

16 files changed

+99
-24
lines changed

16 files changed

+99
-24
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## master
44

5+
- hw-{ledger, ledger-transports}, keyring, networks, util, util-crypto, x-{bigint, fetch, global, randomvalues, textdecoder, textencoder, ws} 13.5.1
56
- api, api-{augment, base, contract, derive}, rpc-{augment, core, provider}, types, types-{augment, codec, create, known} 15.10.2
67
- api, api-{augment, base, contract, derive}, rpc-{augment, core, provider}, types, types-{augment, codec, create, known} 15.10.1
78
- phishing 0.25.10

hw-ledger-transports/packageInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

22

3-
export const packageInfo = { name: '@polkadot/hw-ledger-transports', path: new URL(import.meta.url).pathname, type: 'deno', version: '13.4.4' };
3+
export const packageInfo = { name: '@polkadot/hw-ledger-transports', path: new URL(import.meta.url).pathname, type: 'deno', version: '13.5.1' };

hw-ledger/Ledger.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Buffer } from 'node:buffer';
22

33

4-
import type { SubstrateApp } from 'https://esm.sh/@zondax/ledger-substrate@1.0.0';
4+
import type { SubstrateApp } from 'https://esm.sh/@zondax/ledger-substrate@1.1.1';
55
import type { TransportDef, TransportType } from 'https://deno.land/x/polkadot/hw-ledger-transports/types.ts';
66
import type { AccountOptions, LedgerAddress, LedgerSignature, LedgerVersion } from './types.ts';
77

8-
import { newSubstrateApp } from 'https://esm.sh/@zondax/ledger-substrate@1.0.0';
8+
import { newSubstrateApp } from 'https://esm.sh/@zondax/ledger-substrate@1.1.1';
99

1010
import { transports } from 'https://deno.land/x/polkadot/hw-ledger-transports/mod.ts';
1111
import { hexAddPrefix, u8aToBuffer, u8aWrapBytes } from 'https://deno.land/x/polkadot/util/mod.ts';

hw-ledger/LedgerGeneric.ts

Lines changed: 83 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Buffer } from 'node:buffer';
44
import type { TransportDef, TransportType } from 'https://deno.land/x/polkadot/hw-ledger-transports/types.ts';
55
import type { AccountOptionsGeneric, LedgerAddress, LedgerSignature, LedgerVersion } from './types.ts';
66

7-
import { PolkadotGenericApp } from 'https://esm.sh/@zondax/ledger-substrate@1.0.0';
7+
import { PolkadotGenericApp } from 'https://esm.sh/@zondax/ledger-substrate@1.1.1';
88

99
import { transports } from 'https://deno.land/x/polkadot/hw-ledger-transports/mod.ts';
1010
import { hexAddPrefix, u8aToBuffer, u8aWrapBytes } from 'https://deno.land/x/polkadot/util/mod.ts';
@@ -42,8 +42,8 @@ async function wrapError <T extends WrappedResult> (promise: Promise<T>): Promis
4242
return result;
4343
}
4444

45-
/** @internal Wraps a sign/signRaw call and returns the associated signature */
46-
function sign (method: 'sign' | 'signRaw', message: Uint8Array, slip44: number, accountIndex = 0, addressOffset = 0): (app: PolkadotGenericApp) => Promise<LedgerSignature> {
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> {
4747
const bip42Path = `m/44'/${slip44}'/${accountIndex}'/${0}'/${addressOffset}'`;
4848

4949
return async (app: PolkadotGenericApp): Promise<LedgerSignature> => {
@@ -55,7 +55,22 @@ function sign (method: 'sign' | 'signRaw', message: Uint8Array, slip44: number,
5555
};
5656
}
5757

58-
/** @internal Wraps a signWithMetadata call and returns the associated signature */
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 */
5974
function signWithMetadata (message: Uint8Array, slip44: number, accountIndex = 0, addressOffset = 0, { metadata }: Partial<AccountOptionsGeneric> = {}): (app: PolkadotGenericApp) => Promise<LedgerSignature> {
6075
const bip42Path = `m/44'/${slip44}'/${accountIndex}'/${0}'/${addressOffset}'`;
6176

@@ -66,7 +81,28 @@ function signWithMetadata (message: Uint8Array, slip44: number, accountIndex = 0
6681

6782
const bufferMsg = Buffer.from(message);
6883

69-
const { signature } = await wrapError(app.signWithMetadata(bip42Path, bufferMsg, metadata));
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]);
70106

71107
return {
72108
signature: hexAddPrefix(signature.toString('hex'))
@@ -115,14 +151,31 @@ export class LedgerGeneric {
115151
}
116152

117153
/**
118-
* @description Returns the address associated with a specific account & address offset. Optionally
154+
* @description Returns the address associated with a specific Ed25519 account & address offset. Optionally
119155
* asks for on-device confirmation
120156
*/
121157
public async getAddress (ss58Prefix: number, confirm = false, accountIndex = 0, addressOffset = 0): Promise<LedgerAddress> {
122158
const bip42Path = `m/44'/${this.#slip44}'/${accountIndex}'/${0}'/${addressOffset}'`;
123159

124160
return this.withApp(async (app: PolkadotGenericApp): Promise<LedgerAddress> => {
125-
const { address, pubKey } = await wrapError(app.getAddress(bip42Path, ss58Prefix, confirm));
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));
126179

127180
return {
128181
address,
@@ -150,14 +203,28 @@ export class LedgerGeneric {
150203
* @description Signs a transaction on the Ledger device. This requires the LedgerGeneric class to be instantiated with `chainId`, and `metaUrl`
151204
*/
152205
public async sign (message: Uint8Array, accountIndex?: number, addressOffset?: number): Promise<LedgerSignature> {
153-
return this.withApp(sign('sign', message, this.#slip44, accountIndex, addressOffset));
206+
return this.withApp(sign('signEd25519', message, this.#slip44, accountIndex, addressOffset));
154207
}
155208

156209
/**
157210
* @description Signs a message (non-transactional) on the Ledger device
158211
*/
159212
public async signRaw (message: Uint8Array, accountIndex?: number, addressOffset?: number): Promise<LedgerSignature> {
160-
return this.withApp(sign('signRaw', u8aWrapBytes(message), this.#slip44, accountIndex, addressOffset));
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));
161228
}
162229

163230
/**
@@ -167,6 +234,13 @@ export class LedgerGeneric {
167234
return this.withApp(signWithMetadata(message, this.#slip44, accountIndex, addressOffset, options));
168235
}
169236

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+
170244
/**
171245
* @internal
172246
*

hw-ledger/packageInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

22

3-
export const packageInfo = { name: '@polkadot/hw-ledger', path: new URL(import.meta.url).pathname, type: 'deno', version: '13.4.4' };
3+
export const packageInfo = { name: '@polkadot/hw-ledger', path: new URL(import.meta.url).pathname, type: 'deno', version: '13.5.1' };

keyring/packageInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

22

3-
export const packageInfo = { name: '@polkadot/keyring', path: new URL(import.meta.url).pathname, type: 'deno', version: '13.4.4' };
3+
export const packageInfo = { name: '@polkadot/keyring', path: new URL(import.meta.url).pathname, type: 'deno', version: '13.5.1' };

networks/packageInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

22

3-
export const packageInfo = { name: '@polkadot/networks', path: new URL(import.meta.url).pathname, type: 'deno', version: '13.4.4' };
3+
export const packageInfo = { name: '@polkadot/networks', path: new URL(import.meta.url).pathname, type: 'deno', version: '13.5.1' };

util-crypto/packageInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

22

3-
export const packageInfo = { name: '@polkadot/util-crypto', path: new URL(import.meta.url).pathname, type: 'deno', version: '13.4.4' };
3+
export const packageInfo = { name: '@polkadot/util-crypto', path: new URL(import.meta.url).pathname, type: 'deno', version: '13.5.1' };

util/packageInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

22

3-
export const packageInfo = { name: '@polkadot/util', path: new URL(import.meta.url).pathname, type: 'deno', version: '13.4.4' };
3+
export const packageInfo = { name: '@polkadot/util', path: new URL(import.meta.url).pathname, type: 'deno', version: '13.5.1' };

x-bigint/packageInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

22

3-
export const packageInfo = { name: '@polkadot/x-bigint', path: new URL(import.meta.url).pathname, type: 'deno', version: '13.4.4' };
3+
export const packageInfo = { name: '@polkadot/x-bigint', path: new URL(import.meta.url).pathname, type: 'deno', version: '13.5.1' };

x-fetch/packageInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

22

3-
export const packageInfo = { name: '@polkadot/x-fetch', path: new URL(import.meta.url).pathname, type: 'deno', version: '13.4.4' };
3+
export const packageInfo = { name: '@polkadot/x-fetch', path: new URL(import.meta.url).pathname, type: 'deno', version: '13.5.1' };

x-global/packageInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

22

3-
export const packageInfo = { name: '@polkadot/x-global', path: new URL(import.meta.url).pathname, type: 'deno', version: '13.4.4' };
3+
export const packageInfo = { name: '@polkadot/x-global', path: new URL(import.meta.url).pathname, type: 'deno', version: '13.5.1' };

x-randomvalues/packageInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

22

3-
export const packageInfo = { name: '@polkadot/x-randomvalues', path: new URL(import.meta.url).pathname, type: 'deno', version: '13.4.4' };
3+
export const packageInfo = { name: '@polkadot/x-randomvalues', path: new URL(import.meta.url).pathname, type: 'deno', version: '13.5.1' };

x-textdecoder/packageInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

22

3-
export const packageInfo = { name: '@polkadot/x-textdecoder', path: new URL(import.meta.url).pathname, type: 'deno', version: '13.4.4' };
3+
export const packageInfo = { name: '@polkadot/x-textdecoder', path: new URL(import.meta.url).pathname, type: 'deno', version: '13.5.1' };

x-textencoder/packageInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

22

3-
export const packageInfo = { name: '@polkadot/x-textencoder', path: new URL(import.meta.url).pathname, type: 'deno', version: '13.4.4' };
3+
export const packageInfo = { name: '@polkadot/x-textencoder', path: new URL(import.meta.url).pathname, type: 'deno', version: '13.5.1' };

x-ws/packageInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

22

3-
export const packageInfo = { name: '@polkadot/x-ws', path: new URL(import.meta.url).pathname, type: 'deno', version: '13.4.4' };
3+
export const packageInfo = { name: '@polkadot/x-ws', path: new URL(import.meta.url).pathname, type: 'deno', version: '13.5.1' };

0 commit comments

Comments
 (0)