Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: polkadot-js/common
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v12.1.2
Choose a base ref
...
head repository: polkadot-js/common
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v12.2.1
Choose a head ref
  • 9 commits
  • 40 files changed
  • 2 contributors

Commits on May 5, 2023

  1. Bump deps (#1826)

    jacogr authored May 5, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    9de142b View commit details
  2. [CI Skip] bump/beta 12.1.3-0-x

    skip-checks: true
    github-actions[bot] committed May 5, 2023
    Copy the full SHA
    1876efe View commit details
  3. Update Constructor interface params (#1823)

    * Update Constructor interface params
    
    * Adjust
    
    * Adjust
    jacogr authored May 5, 2023
    Copy the full SHA
    6357c1e View commit details
  4. [CI Skip] bump/beta 12.1.3-1-x

    skip-checks: true
    github-actions[bot] committed May 5, 2023
    Copy the full SHA
    fe230f1 View commit details

Commits on May 6, 2023

  1. Bump dev (#1827)

    jacogr authored May 6, 2023
    Copy the full SHA
    18d24bf View commit details
  2. [CI Skip] bump/beta 12.1.3-2-x

    skip-checks: true
    github-actions[bot] committed May 6, 2023
    Copy the full SHA
    b73b96e View commit details

Commits on May 13, 2023

  1. Unroll u8aToBigInt loops (#1821)

    * Unroll u8aToBigInt loops
    
    * Bump dev
    
    * Rolling tests
    jacogr authored May 13, 2023
    Copy the full SHA
    e5373c3 View commit details
  2. 12.2.1 (#1829)

    jacogr authored May 13, 2023
    Copy the full SHA
    5272645 View commit details
  3. [CI Skip] release/stable 12.2.1

    skip-checks: true
    github-actions[bot] committed May 13, 2023
    Copy the full SHA
    ea08763 View commit details
Showing with 660 additions and 485 deletions.
  1. +10 −0 CHANGELOG.md
  2. +1 −1 CONTRIBUTORS
  3. +5 −5 package.json
  4. +6 −6 packages/hw-ledger-transports/package.json
  5. +1 −1 packages/hw-ledger-transports/src/packageInfo.ts
  6. +3 −3 packages/hw-ledger/package.json
  7. +1 −1 packages/hw-ledger/src/bundle.ts
  8. +1 −1 packages/hw-ledger/src/packageInfo.ts
  9. +5 −5 packages/keyring/package.json
  10. +1 −1 packages/keyring/src/packageInfo.ts
  11. +3 −3 packages/networks/package.json
  12. +1 −1 packages/networks/src/packageInfo.ts
  13. +8 −8 packages/util-crypto/package.json
  14. +1 −1 packages/util-crypto/src/packageInfo.ts
  15. +6 −6 packages/util/package.json
  16. +1 −1 packages/util/src/packageInfo.ts
  17. +2 −1 packages/util/src/types.ts
  18. +60 −3 packages/util/src/u8a/toBigInt.spec.ts
  19. +65 −20 packages/util/src/u8a/toBigInt.ts
  20. +60 −3 packages/util/src/u8a/toBn.spec.ts
  21. +74 −69 packages/util/src/u8a/toBn.ts
  22. +2 −2 packages/util/src/u8a/toNumber.spec.ts
  23. +7 −17 packages/util/src/u8a/toNumber.ts
  24. +2 −2 packages/x-bigint/package.json
  25. +1 −1 packages/x-bigint/src/packageInfo.ts
  26. +2 −2 packages/x-bundle/package.json
  27. +1 −1 packages/x-bundle/src/packageInfo.ts
  28. +2 −2 packages/x-fetch/package.json
  29. +1 −1 packages/x-fetch/src/packageInfo.ts
  30. +1 −1 packages/x-global/package.json
  31. +1 −1 packages/x-global/src/packageInfo.ts
  32. +6 −6 packages/x-randomvalues/package.json
  33. +1 −1 packages/x-randomvalues/src/packageInfo.ts
  34. +2 −2 packages/x-textdecoder/package.json
  35. +1 −1 packages/x-textdecoder/src/packageInfo.ts
  36. +2 −2 packages/x-textencoder/package.json
  37. +1 −1 packages/x-textencoder/src/packageInfo.ts
  38. +2 −2 packages/x-ws/package.json
  39. +1 −1 packages/x-ws/src/packageInfo.ts
  40. +309 −299 yarn.lock
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# CHANGELOG

## 12.2.1 May 13, 2023

Changes:

- Align `u8aToBigInt` tests with `u8aToBn`
- Unroll loops on most-frequently used paths for `u8aToBigInt`
- Add `module` to `package.json` export map (ESM-only)
- Upgrade dependencies to latest stable versions


## 12.1.2 May 1, 2023

Changes:
2 changes: 1 addition & 1 deletion CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1608 Jaco Fix typings for isChildClass (#1824)
1613 Jaco 12.2.1 (#1829)
12 Carlo Sala feat(networks): support ledger for pendulum (#1739)
9 Antoine Estienne Add eth uri keyring test (#1291)
6 Amaury Martiny Add tests from Rust (#283)
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -14,10 +14,10 @@
},
"sideEffects": false,
"type": "module",
"version": "12.1.2",
"version": "12.2.1",
"versions": {
"git": "12.1.2",
"npm": "12.1.2"
"git": "12.2.1",
"npm": "12.2.1"
},
"workspaces": [
"packages/*"
@@ -37,8 +37,8 @@
"test:one": "polkadot-dev-run-test --env browser"
},
"devDependencies": {
"@polkadot/dev": "^0.73.8",
"@types/node": "^18.16.3"
"@polkadot/dev": "^0.73.17",
"@types/node": "^20.1.3"
},
"resolutions": {
"typescript": "^5.0.4"
12 changes: 6 additions & 6 deletions packages/hw-ledger-transports/package.json
Original file line number Diff line number Diff line change
@@ -14,18 +14,18 @@
},
"sideEffects": false,
"type": "module",
"version": "12.1.2",
"version": "12.2.1",
"browser": "browser.js",
"main": "node.js",
"react-native": "react-native.js",
"dependencies": {
"@ledgerhq/hw-transport": "^6.28.2",
"@ledgerhq/hw-transport-webhid": "^6.27.13",
"@ledgerhq/hw-transport-webusb": "^6.27.13",
"@polkadot/util": "12.1.2",
"@ledgerhq/hw-transport": "^6.28.3",
"@ledgerhq/hw-transport-webhid": "^6.27.14",
"@ledgerhq/hw-transport-webusb": "^6.27.14",
"@polkadot/util": "12.2.1",
"tslib": "^2.5.0"
},
"optionalDependencies": {
"@ledgerhq/hw-transport-node-hid-singleton": "^6.28.10"
"@ledgerhq/hw-transport-node-hid-singleton": "^6.28.11"
}
}
2 changes: 1 addition & 1 deletion packages/hw-ledger-transports/src/packageInfo.ts
Original file line number Diff line number Diff line change
@@ -3,4 +3,4 @@

// Do not edit, auto-generated by @polkadot/dev

export const packageInfo = { name: '@polkadot/hw-ledger-transports', path: 'auto', type: 'auto', version: '12.1.2' };
export const packageInfo = { name: '@polkadot/hw-ledger-transports', path: 'auto', type: 'auto', version: '12.2.1' };
6 changes: 3 additions & 3 deletions packages/hw-ledger/package.json
Original file line number Diff line number Diff line change
@@ -17,11 +17,11 @@
"./detectPackage.cjs"
],
"type": "module",
"version": "12.1.2",
"version": "12.2.1",
"main": "index.js",
"dependencies": {
"@polkadot/hw-ledger-transports": "12.1.2",
"@polkadot/util": "12.1.2",
"@polkadot/hw-ledger-transports": "12.2.1",
"@polkadot/util": "12.2.1",
"@zondax/ledger-substrate": "^0.40.7",
"tslib": "^2.5.0"
}
2 changes: 1 addition & 1 deletion packages/hw-ledger/src/bundle.ts
Original file line number Diff line number Diff line change
@@ -89,7 +89,7 @@ export class Ledger {
}

/**
* Signs a transcation on the Ledger device
* Signs a transaction on the Ledger device
*/
public async sign (message: Uint8Array, accountOffset = 0, addressOffset = 0, { account = LEDGER_DEFAULT_ACCOUNT, addressIndex = LEDGER_DEFAULT_INDEX, change = LEDGER_DEFAULT_CHANGE }: Partial<AccountOptions> = {}): Promise<LedgerSignature> {
return this.withApp(async (app: SubstrateApp): Promise<LedgerSignature> => {
2 changes: 1 addition & 1 deletion packages/hw-ledger/src/packageInfo.ts
Original file line number Diff line number Diff line change
@@ -3,4 +3,4 @@

// Do not edit, auto-generated by @polkadot/dev

export const packageInfo = { name: '@polkadot/hw-ledger', path: 'auto', type: 'auto', version: '12.1.2' };
export const packageInfo = { name: '@polkadot/hw-ledger', path: 'auto', type: 'auto', version: '12.2.1' };
10 changes: 5 additions & 5 deletions packages/keyring/package.json
Original file line number Diff line number Diff line change
@@ -18,15 +18,15 @@
"./detectPackage.cjs"
],
"type": "module",
"version": "12.1.2",
"version": "12.2.1",
"main": "index.js",
"dependencies": {
"@polkadot/util": "12.1.2",
"@polkadot/util-crypto": "12.1.2",
"@polkadot/util": "12.2.1",
"@polkadot/util-crypto": "12.2.1",
"tslib": "^2.5.0"
},
"peerDependencies": {
"@polkadot/util": "12.1.2",
"@polkadot/util-crypto": "12.1.2"
"@polkadot/util": "12.2.1",
"@polkadot/util-crypto": "12.2.1"
}
}
2 changes: 1 addition & 1 deletion packages/keyring/src/packageInfo.ts
Original file line number Diff line number Diff line change
@@ -3,4 +3,4 @@

// Do not edit, auto-generated by @polkadot/dev

export const packageInfo = { name: '@polkadot/keyring', path: 'auto', type: 'auto', version: '12.1.2' };
export const packageInfo = { name: '@polkadot/keyring', path: 'auto', type: 'auto', version: '12.2.1' };
6 changes: 3 additions & 3 deletions packages/networks/package.json
Original file line number Diff line number Diff line change
@@ -15,14 +15,14 @@
},
"sideEffects": false,
"type": "module",
"version": "12.1.2",
"version": "12.2.1",
"main": "index.js",
"dependencies": {
"@polkadot/util": "12.1.2",
"@polkadot/util": "12.2.1",
"@substrate/ss58-registry": "^1.40.0",
"tslib": "^2.5.0"
},
"devDependencies": {
"@polkadot/hw-ledger": "12.1.2"
"@polkadot/hw-ledger": "12.2.1"
}
}
2 changes: 1 addition & 1 deletion packages/networks/src/packageInfo.ts
Original file line number Diff line number Diff line change
@@ -3,4 +3,4 @@

// Do not edit, auto-generated by @polkadot/dev

export const packageInfo = { name: '@polkadot/networks', path: 'auto', type: 'auto', version: '12.1.2' };
export const packageInfo = { name: '@polkadot/networks', path: 'auto', type: 'auto', version: '12.2.1' };
16 changes: 8 additions & 8 deletions packages/util-crypto/package.json
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
"./detectPackage.cjs"
],
"type": "module",
"version": "12.1.2",
"version": "12.2.1",
"browser": {
"crypto": false,
"stream": false
@@ -29,16 +29,16 @@
"dependencies": {
"@noble/curves": "1.0.0",
"@noble/hashes": "1.3.0",
"@polkadot/networks": "12.1.2",
"@polkadot/util": "12.1.2",
"@polkadot/wasm-crypto": "^7.1.2",
"@polkadot/wasm-util": "^7.1.2",
"@polkadot/x-bigint": "12.1.2",
"@polkadot/x-randomvalues": "12.1.2",
"@polkadot/networks": "12.2.1",
"@polkadot/util": "12.2.1",
"@polkadot/wasm-crypto": "^7.2.1",
"@polkadot/wasm-util": "^7.2.1",
"@polkadot/x-bigint": "12.2.1",
"@polkadot/x-randomvalues": "12.2.1",
"@scure/base": "1.1.1",
"tslib": "^2.5.0"
},
"peerDependencies": {
"@polkadot/util": "12.1.2"
"@polkadot/util": "12.2.1"
}
}
2 changes: 1 addition & 1 deletion packages/util-crypto/src/packageInfo.ts
Original file line number Diff line number Diff line change
@@ -3,4 +3,4 @@

// Do not edit, auto-generated by @polkadot/dev

export const packageInfo = { name: '@polkadot/util-crypto', path: 'auto', type: 'auto', version: '12.1.2' };
export const packageInfo = { name: '@polkadot/util-crypto', path: 'auto', type: 'auto', version: '12.2.1' };
12 changes: 6 additions & 6 deletions packages/util/package.json
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
"./detectPackage.cjs"
],
"type": "module",
"version": "12.1.2",
"version": "12.2.1",
"main": "index.js",
"exports": {
"./hex/toU8a": {
@@ -35,15 +35,15 @@
}
},
"dependencies": {
"@polkadot/x-bigint": "12.1.2",
"@polkadot/x-global": "12.1.2",
"@polkadot/x-textdecoder": "12.1.2",
"@polkadot/x-textencoder": "12.1.2",
"@polkadot/x-bigint": "12.2.1",
"@polkadot/x-global": "12.2.1",
"@polkadot/x-textdecoder": "12.2.1",
"@polkadot/x-textencoder": "12.2.1",
"@types/bn.js": "^5.1.1",
"bn.js": "^5.2.1",
"tslib": "^2.5.0"
},
"devDependencies": {
"@polkadot/x-randomvalues": "12.1.2"
"@polkadot/x-randomvalues": "12.2.1"
}
}
2 changes: 1 addition & 1 deletion packages/util/src/packageInfo.ts
Original file line number Diff line number Diff line change
@@ -3,4 +3,4 @@

// Do not edit, auto-generated by @polkadot/dev

export const packageInfo = { name: '@polkadot/util', path: 'auto', type: 'auto', version: '12.1.2' };
export const packageInfo = { name: '@polkadot/util', path: 'auto', type: 'auto', version: '12.2.1' };
3 changes: 2 additions & 1 deletion packages/util/src/types.ts
Original file line number Diff line number Diff line change
@@ -3,7 +3,8 @@

import type { BN } from './bn/bn.js';

export interface Constructor<T extends object = object> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export interface Constructor<T = any> {
prototype: T;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
new (...args: any[]): T;
63 changes: 60 additions & 3 deletions packages/util/src/u8a/toBigInt.spec.ts
Original file line number Diff line number Diff line change
@@ -54,6 +54,15 @@ describe('u8aToBigInt', (): void => {
).toBe('78563412');
});

it('converts values (i32)', (): void => {
expect(
u8aToBigInt(
new Uint8Array([0xf2, 0x34, 0x56, 0x78]),
{ isLe: false, isNegative: true }
).toString(16)
).toBe('-dcba988');
});

it('converts values (u40)', (): void => {
expect(
u8aToBigInt(
@@ -71,6 +80,29 @@ describe('u8aToBigInt', (): void => {
).toString(16)
).toBe('bc9a78563412');
});

it('converts values (u128)', (): void => {
expect(
u8aToBigInt(
new Uint8Array([0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78]),
{ isLe: true }
).toString(16)
).toBe('78563412785634127856341278563412');
});

for (let i = 1; i < 32; i++) {
const tu8a = [0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78];
const tstr = tu8a.map((n) => n.toString(16));

it(`converts values with length ${i}`, (): void => {
expect(
u8aToBigInt(
new Uint8Array(tu8a.slice(0, i)),
{ isLe: true }
).toString(16)
).toBe(tstr.slice(0, i).reverse().join(''));
});
}
});

describe('signed', (): void => {
@@ -193,6 +225,29 @@ describe('u8aToBigInt', (): void => {
).toString(16)
).toBe('123456789abc');
});

it('converts values (u128)', (): void => {
expect(
u8aToBigInt(
new Uint8Array([0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78]),
{ isLe: false }
).toString(16)
).toBe('12345678123456781234567812345678');
});

for (let i = 1; i < 32; i++) {
const tu8a = [0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78];
const tstr = tu8a.map((n) => n.toString(16));

it(`converts values with length ${i}`, (): void => {
expect(
u8aToBigInt(
new Uint8Array(tu8a.slice(0, i)),
{ isLe: false }
).toString(16)
).toBe(tstr.slice(0, i).join(''));
});
}
});

describe('empty creation', (): void => {
@@ -262,9 +317,11 @@ describe('u8aToBigInt', (): void => {
).toBe(256n);
});

perf('u8aToBigInt (u32)', 1_000_000, [[new Uint8Array([0x68, 0x65, 0x6c, 0x6c])]], u8aToBigInt);
perf('u8aToBigInt (i32)', 1_000_000, [[new Uint8Array([0x68, 0x65, 0x6c, 0x6c])]], (v: Uint8Array) => u8aToBigInt(v, { isNegative: true }));
perf('u8aToBigInt (u64)', 500_000, [[new Uint8Array([0x68, 0x65, 0x6c, 0x6c, 0x68, 0x65, 0x6c, 0x6c])]], u8aToBigInt);
perf('u8aToBigInt (i32)', 750_000, [[new Uint8Array([0x68, 0x65, 0x6c, 0x6c])]], (v: Uint8Array) => u8aToBigInt(v, { isNegative: true }));

perf('u8aToBigInt (u32)', 750_000, [[new Uint8Array([0x68, 0x65, 0x6c, 0x6c])]], u8aToBigInt);
perf('u8aToBigInt (u64)', 750_000, [[new Uint8Array([0x68, 0x65, 0x6c, 0x6c, 0x68, 0x65, 0x6c, 0x6c])]], u8aToBigInt);
perf('u8aToBigInt (u128)', 750_000, [[new Uint8Array([0x68, 0x65, 0x6c, 0x6c, 0x68, 0x65, 0x6c, 0x6c, 0x68, 0x65, 0x6c, 0x6c, 0x68, 0x65, 0x6c, 0x6c])]], u8aToBigInt);

// perf('BigInt (constructor)', 1_000_000, [[12345678]], (v: number) => BigInt(v).toString());
// perf('BigInt (constructor -> string)', 1_000_000, [[12345678]], (v: number) => BigInt(v).toString());
Loading