Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
500a38e1ab | ||
|
|
3437fb65cd | ||
|
|
3d43aba4a1 | ||
|
|
7cd5204fb7 | ||
|
|
3fdf3b5523 | ||
|
|
8fd0fe846f | ||
|
|
130a59fb02 | ||
|
|
e6aec6d178 | ||
|
|
6fb73f3124 | ||
|
|
ea96abc1a4 | ||
|
|
9c08fa6206 | ||
|
|
8edb2abe30 | ||
|
|
3e2c3a6ed8 | ||
|
|
1e35c5cd25 | ||
|
|
40dc599acc | ||
|
|
d1d6fc631c | ||
|
|
28c6139068 | ||
|
|
b00d8573fd | ||
|
|
6afebd70d0 | ||
|
|
1f4d423682 | ||
|
|
57718cacfb | ||
|
|
b51d4e13fb | ||
|
|
08af19e2d5 | ||
|
|
9830457c9a | ||
|
|
4619ab6668 | ||
|
|
d886c02b23 | ||
|
|
7d745661b7 | ||
|
|
da9c2bc10b | ||
|
|
eab8d44487 | ||
|
|
19ecae37dd | ||
|
|
3d3e46cb77 | ||
|
|
e09027e83d | ||
|
|
c544e0b478 | ||
|
|
f914061365 | ||
|
|
55e4e8209e | ||
|
|
193c9ebb37 | ||
|
|
5d67d92454 | ||
|
|
3a0d566f60 | ||
|
|
675f1e71b5 | ||
|
|
4bbf38c7e4 | ||
|
|
fd76246c11 | ||
|
|
0b14539a98 | ||
|
|
09b1a0e6e3 | ||
|
|
03e64c9120 | ||
|
|
f848c87fde | ||
|
|
46a05b6a60 | ||
|
|
a9f671b501 | ||
|
|
f1187f5981 | ||
|
|
4134bf8a85 | ||
|
|
4709a62c0b | ||
|
|
900cf21bc5 | ||
|
|
fa8229de06 | ||
|
|
913bf65dab | ||
|
|
769b953983 | ||
|
|
2949e12c55 | ||
|
|
1664a8d8a2 | ||
|
|
ab71a25b96 | ||
|
|
02c1a95ea1 | ||
|
|
3ee6830c0e | ||
|
|
642724ab6d | ||
|
|
022756e6dd | ||
|
|
e29003f51e | ||
|
|
e5c2f8f529 | ||
|
|
f7ce22b158 | ||
|
|
0028d212e4 | ||
|
|
719c48f8f2 | ||
|
|
b137f8ec8b | ||
|
|
e93b7a3626 | ||
|
|
7bf2d220dd | ||
|
|
7efa20c066 | ||
|
|
f2afcfc1a7 | ||
|
|
45e2a560a9 | ||
|
|
5b5cdae9ff | ||
|
|
5147f64a64 | ||
|
|
0116a3f1f7 | ||
|
|
01839b5f63 | ||
|
|
18d02f49fd | ||
|
|
12e2a44935 | ||
|
|
9c47980c68 | ||
|
|
14f7a5c0bb | ||
|
|
f512f4aa27 | ||
|
|
4b9d4fa935 | ||
|
|
35288e81e1 | ||
|
|
f95fa2e60d | ||
|
|
0c62a8a676 | ||
|
|
346989211c | ||
|
|
ba2453457d | ||
|
|
9c4d409e66 | ||
|
|
5f9e345dd4 | ||
|
|
bf141cd874 | ||
|
|
08bf4b7eb2 | ||
|
|
42daac5327 | ||
|
|
694fb8b241 | ||
|
|
b0b69c27dc | ||
|
|
b57bcdc38f | ||
|
|
4fd4178ce9 | ||
|
|
39403fcfe7 | ||
|
|
955605b2b0 | ||
|
|
d291a76798 | ||
|
|
aa12647ef6 | ||
|
|
ceff8cc9ff |
@@ -9,7 +9,7 @@ jobs:
|
||||
if: "! startsWith(github.event.head_commit.message, '[CI Skip]') && (!github.event.pull_request || github.event.pull_request.head.repo.full_name == github.repository)"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: jacogr/action-approve@9d6ce78d26f23ad29d009d034822cf773f2cb50e
|
||||
- uses: jacogr/action-approve@795afd1dd096a2071d7ec98740661af4e853b7da
|
||||
with:
|
||||
authors: jacogr
|
||||
labels: -auto
|
||||
|
||||
@@ -8,9 +8,9 @@ jobs:
|
||||
merge:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: jacogr/action-merge@3b4b49af8a8644bf5cbb5409ee236abe04eeb1b0
|
||||
- uses: jacogr/action-merge@d2d64b4545acd93b0a9575177d3d215ae3f92029
|
||||
with:
|
||||
checks: build,lint,test
|
||||
checks: pr (build),pr (lint),pr (test)
|
||||
labels: -auto
|
||||
strategy: squash
|
||||
token: ${{ secrets.GH_PAT_BOT }}
|
||||
|
||||
@@ -3,17 +3,20 @@ on: [pull_request]
|
||||
|
||||
jobs:
|
||||
pr:
|
||||
continue-on-error: true
|
||||
strategy:
|
||||
matrix:
|
||||
step: ['lint', 'test', 'build', 'deno']
|
||||
name: ${{ matrix.step }}
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
YARN_ENABLE_SCRIPTS: false
|
||||
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
||||
steps:
|
||||
- uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e
|
||||
- uses: denoland/setup-deno@004814556e37c54a2f6e31384c9e18e983317366
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
- uses: denoland/setup-deno@v1
|
||||
with:
|
||||
deno-version: vx.x.x
|
||||
- name: ${{ matrix.step }}
|
||||
|
||||
@@ -10,7 +10,6 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
step: ['build:release']
|
||||
name: ${{ matrix.step }}
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
YARN_ENABLE_SCRIPTS: false
|
||||
@@ -19,10 +18,13 @@ jobs:
|
||||
GH_RELEASE_GITHUB_API_TOKEN: ${{ secrets.GH_PAT_BOT }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
steps:
|
||||
- uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GH_PAT_BOT }}
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
- name: ${{ matrix.step }}
|
||||
run: |
|
||||
yarn install --immutable | grep -v 'YN0013'
|
||||
|
||||
@@ -1,5 +1,88 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 11.0.1 Mar 4, 2023
|
||||
|
||||
Changes:
|
||||
|
||||
- Change `@polkadot/x-ws` to use [ws](https://www.npmjs.com/package/ws) package (previous: `websocket`)
|
||||
- Add `/*#__PURE__*/` annotations for `@polkadot/x-*` packages
|
||||
- Swap TS -> JS compiler to use tsc (from babel)
|
||||
- Adjust all tests to use `node:test` runner (ESM variants)
|
||||
- Move `cryptoWaitReady()` top-level in test files
|
||||
- Upgrade to `@polkadot/wasm-crypto` 7.0.1
|
||||
|
||||
|
||||
## 10.4.2 Feb 19, 2023
|
||||
|
||||
Contributed:
|
||||
|
||||
- Ledger support for Pendulum (Thanks to https://github.com/carlosala)
|
||||
|
||||
Changes:
|
||||
|
||||
- Ensure `u8aToU8a` correctly unwraps Buffer value (check ordering)
|
||||
- Upgrade dependencies to latest stable versions
|
||||
|
||||
|
||||
## 10.4.1 Feb 12, 2023
|
||||
|
||||
Contributed:
|
||||
|
||||
- Locale support for number formatting (Thanks to https://github.com/alko89)
|
||||
- Ledger support for Picasso (Thanks to https://github.com/carlosala)
|
||||
|
||||
Changes:
|
||||
|
||||
- Add `isClass` helper (checks if input is actual Class Constructor)
|
||||
- Adjust `isChildClass` to rely on new `isClass`
|
||||
- Upgrade dependencies to latest stable versions
|
||||
|
||||
|
||||
## 10.3.1 Jan 28, 2023
|
||||
|
||||
Contributed:
|
||||
|
||||
- Ledger support for Ternoa (Thanks to https://github.com/mohsinriaz17)
|
||||
|
||||
Changes:
|
||||
|
||||
- Expand `arrayChunk` tests
|
||||
- Adjust output for Ledger sanity checks
|
||||
- Expand exported `bigint` constants to match with those in `BN`
|
||||
- Adjust internal character maps to operate on `Uint8Array` instad of `Array<number>`
|
||||
- Upgrade dependencies to latest stable versions
|
||||
|
||||
|
||||
## 10.2.6 Jan 13, 2023
|
||||
|
||||
Changes:
|
||||
|
||||
- Drop stray `console.error` log (it really _is_ Friday 13th)
|
||||
|
||||
|
||||
## 10.2.5 Jan 13, 2023
|
||||
|
||||
Changes:
|
||||
|
||||
- Bugfix for `formatBalance` (forceUnit) with `BN` inputs where output is less than 0
|
||||
|
||||
|
||||
## 10.2.4 Jan 13, 2023
|
||||
|
||||
Changes:
|
||||
|
||||
- Add the `withAll` (default false) flag to `formatBalance` to format to max decimals
|
||||
- Add the `withZero` (default true) flags to `formatBalance` to retain trailing zeros
|
||||
|
||||
|
||||
## 10.2.3 Jan 7, 2023
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust `isBuffer` check on `xglobal` (no auto-polyfill detection on eg. parcel)
|
||||
- Upgrade dependencies to latest stable versions
|
||||
|
||||
|
||||
## 10.2.2 Jan 6, 2023
|
||||
|
||||
Contributed:
|
||||
|
||||
+4
-2
@@ -1,5 +1,5 @@
|
||||
1502 Jaco 10.2.2 (#1700)
|
||||
10 Carlo Sala feat(networks): support ledger for ajuna (#1682)
|
||||
1551 Jaco 11.0.1 (#1753)
|
||||
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)
|
||||
5 Jakub Pánik Add HydraDX parachain to genesis (#1583)
|
||||
@@ -16,6 +16,7 @@
|
||||
2 Nantian fix bigint type (#1079)
|
||||
2 Stefanie Doll Add missing dependencies to util-crypto (#424)
|
||||
1 Agustinus Theodorus docs: fix typo in naclSeal docs. (#1005)
|
||||
1 Aleš Ferlan feat: allow setting of thousand/decimal separators (#1722)
|
||||
1 Alex Sedighi fix Nodle's known network name (#1699)
|
||||
1 Alexander Krupenkin Added ECDSA keypair support (#589)
|
||||
1 alexdniep added equilibrium slip44; added equilibrium genesis hash (#984)
|
||||
@@ -37,6 +38,7 @@
|
||||
1 Lezek123 logger - wildcard include/exclude with DEBUG env (#932)
|
||||
1 Mario Neises remove redudant export (#257)
|
||||
1 Miguel Hervas Add CFG Ledger Support (#1057)
|
||||
1 Mohsan Riaz Add Ternoa for ledger hardware support (#1711)
|
||||
1 nahuseyoum Reserving 65 for Aventus based on the new extended range (#871)
|
||||
1 Nantian add acala ledger config (#1485)
|
||||
1 qwer951123 Add acala genesis (#1161)
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
// Copyright 2017-2023 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const config = require('@polkadot/dev/config/jest.cjs');
|
||||
|
||||
module.exports = Object.assign({}, config, {
|
||||
moduleNameMapper: {
|
||||
'@polkadot/hw-ledger-transports(.*)$': '<rootDir>/packages/hw-ledger-transports/src/node',
|
||||
// eslint-disable-next-line sort-keys
|
||||
'@polkadot/hw-ledger(.*)$': '<rootDir>/packages/hw-ledger/src/$1',
|
||||
'@polkadot/keyring(.*)$': '<rootDir>/packages/keyring/src/$1',
|
||||
'@polkadot/networks(.*)$': '<rootDir>/packages/networks/src/$1',
|
||||
'@polkadot/util-(crypto)(.*)$': '<rootDir>/packages/util-$1/src/$2',
|
||||
// eslint-disable-next-line sort-keys
|
||||
'@polkadot/util(.*)$': '<rootDir>/packages/util/src/$1',
|
||||
'@polkadot/x-(bigint|global)(.*)$': '<rootDir>/packages/x-$1/src/$2',
|
||||
'@polkadot/x-(fetch|randomvalues|textdecoder|textencoder|ws)(.*)$': '<rootDir>/packages/x-$1/src/node'
|
||||
}
|
||||
});
|
||||
+12
-11
@@ -11,33 +11,34 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "10.2.2",
|
||||
"version": "11.0.1",
|
||||
"versions": {
|
||||
"git": "10.2.2",
|
||||
"npm": "10.2.2"
|
||||
"git": "11.0.1",
|
||||
"npm": "11.0.1"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "polkadot-dev-build-ts",
|
||||
"build:networks": "yarn test:one packages/networks/src",
|
||||
"build:networks": "polkadot-dev-run-test packages/networks/src",
|
||||
"build:release": "polkadot-ci-ghact-build",
|
||||
"build:rollup": "polkadot-exec-rollup --config",
|
||||
"clean": "polkadot-dev-clean-build",
|
||||
"deno": "yarn polkadot-dev-deno-map && yarn build && deno check --import-map=import_map.json mod.ts",
|
||||
"lint": "polkadot-dev-run-lint",
|
||||
"postinstall": "polkadot-dev-yarn-only",
|
||||
"test": "NODE_OPTIONS=--experimental-vm-modules polkadot-dev-run-test --coverage --runInBand --testPathIgnorePatterns crosscheck --testPathIgnorePatterns toMiniSecretCmp",
|
||||
"test:mnemonicCmp": "polkadot-dev-run-test packages/util-crypto/src/mnemonic/toMiniSecretCmp.spec.ts",
|
||||
"test:one": "polkadot-dev-run-test --runInBand"
|
||||
"test": "polkadot-dev-run-test --env browser ^mnemonic/toMiniSecretCmp",
|
||||
"test:mnemonicCmp": "polkadot-dev-run-test --env browser mnemonic/toMiniSecretCmp",
|
||||
"test:node": "polkadot-dev-run-test --env browser ^mnemonic/toMiniSecretCmp",
|
||||
"test:one": "polkadot-dev-run-test --env browser"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.20.12",
|
||||
"@polkadot/dev": "^0.67.177",
|
||||
"@types/jest": "^29.2.5"
|
||||
"@babel/core": "^7.21.0",
|
||||
"@polkadot/dev": "^0.69.27",
|
||||
"@types/node": "^18.14.6"
|
||||
},
|
||||
"resolutions": {
|
||||
"typescript": "^4.9.4"
|
||||
"typescript": "^4.9.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -16,18 +16,18 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "10.2.2",
|
||||
"version": "11.0.1",
|
||||
"browser": "browser.js",
|
||||
"main": "node.js",
|
||||
"react-native": "react-native.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.7",
|
||||
"@ledgerhq/hw-transport": "^6.27.9",
|
||||
"@ledgerhq/hw-transport-webhid": "^6.27.9",
|
||||
"@ledgerhq/hw-transport-webusb": "^6.27.9",
|
||||
"@polkadot/util": "10.2.2"
|
||||
"@ledgerhq/hw-transport": "^6.28.1",
|
||||
"@ledgerhq/hw-transport-webhid": "^6.27.12",
|
||||
"@ledgerhq/hw-transport-webusb": "^6.27.12",
|
||||
"@polkadot/util": "11.0.1",
|
||||
"tslib": "^2.5.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@ledgerhq/hw-transport-node-hid-singleton": "^6.28.6"
|
||||
"@ledgerhq/hw-transport-node-hid-singleton": "^6.28.9"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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: '10.2.2' };
|
||||
export const packageInfo = { name: '@polkadot/hw-ledger-transports', path: 'auto', type: 'auto', version: '11.0.1' };
|
||||
|
||||
@@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -19,13 +19,13 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "10.2.2",
|
||||
"version": "11.0.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.7",
|
||||
"@ledgerhq/hw-transport": "^6.27.9",
|
||||
"@polkadot/hw-ledger-transports": "10.2.2",
|
||||
"@polkadot/util": "10.2.2",
|
||||
"@zondax/ledger-substrate": "^0.40.3"
|
||||
"@ledgerhq/hw-transport": "^6.28.1",
|
||||
"@polkadot/hw-ledger-transports": "11.0.1",
|
||||
"@polkadot/util": "11.0.1",
|
||||
"@zondax/ledger-substrate": "^0.40.5",
|
||||
"tslib": "^2.5.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ export class Ledger {
|
||||
}
|
||||
|
||||
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> {
|
||||
return this.#withApp(async (app: SubstrateApp): Promise<LedgerAddress> => {
|
||||
return this.withApp(async (app: SubstrateApp): Promise<LedgerAddress> => {
|
||||
const { address, pubKey } = await wrapError(app.getAddress(account + accountOffset, change, addressIndex + addressOffset, confirm));
|
||||
|
||||
return {
|
||||
@@ -63,7 +63,7 @@ export class Ledger {
|
||||
}
|
||||
|
||||
public async getVersion (): Promise<LedgerVersion> {
|
||||
return this.#withApp(async (app: SubstrateApp): Promise<LedgerVersion> => {
|
||||
return this.withApp(async (app: SubstrateApp): Promise<LedgerVersion> => {
|
||||
const { device_locked: isLocked, major, minor, patch, test_mode: isTestMode } = await wrapError(app.getVersion());
|
||||
|
||||
return {
|
||||
@@ -75,7 +75,7 @@ export class Ledger {
|
||||
}
|
||||
|
||||
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> => {
|
||||
return this.withApp(async (app: SubstrateApp): Promise<LedgerSignature> => {
|
||||
const buffer = u8aToBuffer(message);
|
||||
const { signature } = await wrapError(app.sign(account + accountOffset, change, addressIndex + addressOffset, buffer));
|
||||
|
||||
@@ -85,7 +85,7 @@ export class Ledger {
|
||||
});
|
||||
}
|
||||
|
||||
#getApp = async (): Promise<SubstrateApp> => {
|
||||
async getApp (): Promise<SubstrateApp> {
|
||||
if (!this.#app) {
|
||||
const def = transports.find(({ type }) => type === this.#transport);
|
||||
|
||||
@@ -99,11 +99,11 @@ export class Ledger {
|
||||
}
|
||||
|
||||
return this.#app;
|
||||
};
|
||||
}
|
||||
|
||||
#withApp = async <T> (fn: (app: SubstrateApp) => Promise<T>): Promise<T> => {
|
||||
async withApp <T> (fn: (app: SubstrateApp) => Promise<T>): Promise<T> {
|
||||
try {
|
||||
const app = await this.#getApp();
|
||||
const app = await this.getApp();
|
||||
|
||||
return await fn(app);
|
||||
} catch (error) {
|
||||
@@ -111,5 +111,5 @@ export class Ledger {
|
||||
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
// Copyright 2017-2023 @polkadot/hw-ledger authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { supportedApps } from '@zondax/ledger-substrate';
|
||||
|
||||
import { ledgerApps } from './defaults';
|
||||
|
||||
describe('ledgerApps', (): void => {
|
||||
it.each(Object.keys(ledgerApps))('%s is known', (k): void => {
|
||||
expect(
|
||||
supportedApps.find(({ name }) =>
|
||||
name === ledgerApps[k]
|
||||
)
|
||||
).toBeDefined();
|
||||
});
|
||||
for (const k of Object.keys(ledgerApps)) {
|
||||
it(`${k} is available in @zondax/ledger-substrate`, (): void => {
|
||||
expect(
|
||||
supportedApps.find(({ name }) =>
|
||||
name === ledgerApps[k]
|
||||
)
|
||||
).toBeDefined();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -25,7 +25,9 @@ export const ledgerApps: Record<string, string> = {
|
||||
nodle: 'Nodle',
|
||||
origintrail: 'OriginTrail',
|
||||
parallel: 'Parallel',
|
||||
pendulum: 'Pendulum',
|
||||
phala: 'Phala',
|
||||
picasso: 'Picasso',
|
||||
polkadex: 'Polkadex',
|
||||
polkadot: 'Polkadot',
|
||||
polymesh: 'Polymesh',
|
||||
@@ -33,6 +35,7 @@ export const ledgerApps: Record<string, string> = {
|
||||
stafi: 'Stafi',
|
||||
statemine: 'Statemine',
|
||||
statemint: 'Statemint',
|
||||
ternoa: 'Ternoa',
|
||||
unique: 'Unique',
|
||||
vtb: 'VTB',
|
||||
xxnetwork: 'XXNetwork'
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/hw-ledger', path: 'auto', type: 'auto', version: '10.2.2' };
|
||||
export const packageInfo = { name: '@polkadot/hw-ledger', path: 'auto', type: 'auto', version: '11.0.1' };
|
||||
|
||||
@@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -20,15 +20,15 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "10.2.2",
|
||||
"version": "11.0.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.7",
|
||||
"@polkadot/util": "10.2.2",
|
||||
"@polkadot/util-crypto": "10.2.2"
|
||||
"@polkadot/util": "11.0.1",
|
||||
"@polkadot/util-crypto": "11.0.1",
|
||||
"tslib": "^2.5.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "10.2.2",
|
||||
"@polkadot/util-crypto": "10.2.2"
|
||||
"@polkadot/util": "11.0.1",
|
||||
"@polkadot/util-crypto": "11.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { KeyringPair$Json } from './types';
|
||||
|
||||
import { hexToU8a, stringToU8a } from '@polkadot/util';
|
||||
@@ -9,11 +12,9 @@ import { base64Decode, cryptoWaitReady, encodeAddress, randomAsU8a, setSS58Forma
|
||||
import { decodePair } from './pair/decode';
|
||||
import Keyring from '.';
|
||||
|
||||
describe('keypair', (): void => {
|
||||
beforeEach(async (): Promise<void> => {
|
||||
await cryptoWaitReady();
|
||||
});
|
||||
await cryptoWaitReady();
|
||||
|
||||
describe('keypair', (): void => {
|
||||
describe('ed25519', (): void => {
|
||||
const publicKeyOne = new Uint8Array([47, 140, 97, 41, 216, 22, 207, 81, 195, 116, 188, 127, 8, 195, 230, 62, 209, 86, 207, 120, 174, 251, 74, 101, 80, 217, 123, 135, 153, 121, 119, 238]);
|
||||
const publicKeyTwo = new Uint8Array([215, 90, 152, 1, 130, 177, 10, 183, 213, 75, 254, 211, 201, 100, 7, 58, 14, 225, 114, 243, 218, 166, 35, 37, 175, 2, 26, 104, 247, 7, 81, 26]);
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/keyring', path: 'auto', type: 'auto', version: '10.2.2' };
|
||||
export const packageInfo = { name: '@polkadot/keyring', path: 'auto', type: 'auto', version: '11.0.1' };
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { createTestPairs } from '../testingPairs';
|
||||
|
||||
const keyring = createTestPairs({ type: 'ed25519' }, false);
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { NONCE_LENGTH, SCRYPT_LENGTH } from '@polkadot/util-crypto/json/constants';
|
||||
|
||||
import { createTestPairs } from '../testingPairs';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { hexToU8a, u8aToHex } from '@polkadot/util';
|
||||
import { cryptoWaitReady, encodeAddress as toSS58, setSS58Format } from '@polkadot/util-crypto';
|
||||
|
||||
@@ -12,11 +15,9 @@ const keyring = createTestPairs({ type: 'ed25519' }, false);
|
||||
|
||||
const TEST_ADDRESS = '0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887';
|
||||
|
||||
describe('pair', (): void => {
|
||||
beforeEach(async (): Promise<void> => {
|
||||
await cryptoWaitReady();
|
||||
});
|
||||
await cryptoWaitReady();
|
||||
|
||||
describe('pair', (): void => {
|
||||
const SIGNATURE = new Uint8Array([80, 191, 198, 147, 225, 207, 75, 88, 126, 39, 129, 109, 191, 38, 72, 181, 75, 254, 81, 143, 244, 79, 237, 38, 236, 141, 28, 252, 134, 26, 169, 234, 79, 33, 153, 158, 151, 34, 175, 188, 235, 20, 35, 135, 83, 120, 139, 211, 233, 130, 1, 208, 201, 215, 73, 80, 56, 98, 185, 196, 11, 8, 193, 14]);
|
||||
const ENCRYPTED = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 132, 59, 53, 85, 227, 40, 107, 48, 234, 198, 238, 157, 238, 224, 235, 179, 75, 153, 241, 142, 254]);
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { createTestPairs } from '../testingPairs';
|
||||
|
||||
const keyring = createTestPairs({ type: 'ed25519' }, false);
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// Copyright 2017-2023 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { KeyringPair } from '../types';
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { u8aToHex } from '@polkadot/util';
|
||||
import { cryptoWaitReady, ed25519PairFromSeed, encodeAddress as toSS58, randomAsU8a, secp256k1PairFromSeed, sr25519PairFromSeed } from '@polkadot/util-crypto';
|
||||
@@ -11,19 +12,13 @@ import { createPair } from '.';
|
||||
const MESSAGE = 'this is a test message';
|
||||
const CONTEXT = 'some context';
|
||||
|
||||
await cryptoWaitReady();
|
||||
|
||||
const ecdsa = createPair({ toSS58, type: 'ecdsa' }, secp256k1PairFromSeed(randomAsU8a()));
|
||||
const ed25519 = createPair({ toSS58, type: 'ed25519' }, ed25519PairFromSeed(randomAsU8a()));
|
||||
const sr25519 = createPair({ toSS58, type: 'sr25519' }, sr25519PairFromSeed(randomAsU8a()));
|
||||
|
||||
describe('vrf', (): void => {
|
||||
let ecdsa: KeyringPair;
|
||||
let ed25519: KeyringPair;
|
||||
let sr25519: KeyringPair;
|
||||
|
||||
beforeAll(async (): Promise<void> => {
|
||||
await cryptoWaitReady();
|
||||
|
||||
ecdsa = createPair({ toSS58, type: 'ecdsa' }, secp256k1PairFromSeed(randomAsU8a()));
|
||||
ed25519 = createPair({ toSS58, type: 'ed25519' }, ed25519PairFromSeed(randomAsU8a()));
|
||||
sr25519 = createPair({ toSS58, type: 'sr25519' }, sr25519PairFromSeed(randomAsU8a()));
|
||||
});
|
||||
|
||||
it('has deterministic signature values for ecdsa', (): void => {
|
||||
const sig1 = ecdsa.vrfSign(MESSAGE, CONTEXT);
|
||||
const sig2 = ecdsa.vrfSign(MESSAGE, CONTEXT);
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
// From https://github.com/paritytech/substrate/wiki/Secret-URI-Test-Vectors
|
||||
|
||||
import type { KeypairType } from '@polkadot/util-crypto/types';
|
||||
@@ -87,13 +90,11 @@ const TESTS = {
|
||||
]
|
||||
};
|
||||
|
||||
describe('keyring.addFromUri', (): void => {
|
||||
Object.entries(TESTS).forEach(([type, tests]): void => {
|
||||
const keyring = new Keyring({ type: type as KeypairType });
|
||||
await cryptoWaitReady();
|
||||
|
||||
beforeEach(async (): Promise<void> => {
|
||||
await cryptoWaitReady();
|
||||
});
|
||||
describe('keyring.addFromUri', (): void => {
|
||||
for (const [type, tests] of Object.entries(TESTS)) {
|
||||
const keyring = new Keyring({ type: type as KeypairType });
|
||||
|
||||
describe(type, (): void => {
|
||||
tests.forEach(({ pk, ss, uri }): void => {
|
||||
@@ -105,5 +106,5 @@ describe('keyring.addFromUri', (): void => {
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { u8aToHex } from '@polkadot/util';
|
||||
import { cryptoWaitReady } from '@polkadot/util-crypto';
|
||||
|
||||
@@ -9,11 +12,9 @@ import Keyring from '.';
|
||||
|
||||
const TEST_ADD = '0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac';
|
||||
|
||||
describe('testingPairs', (): void => {
|
||||
beforeEach(async (): Promise<void> => {
|
||||
await cryptoWaitReady();
|
||||
});
|
||||
await cryptoWaitReady();
|
||||
|
||||
describe('testingPairs', (): void => {
|
||||
it('creates without failing', (): void => {
|
||||
expect(
|
||||
Object.keys(createTestPairs())
|
||||
|
||||
@@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -17,14 +17,14 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "10.2.2",
|
||||
"version": "11.0.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.7",
|
||||
"@polkadot/util": "10.2.2",
|
||||
"@substrate/ss58-registry": "^1.36.0"
|
||||
"@polkadot/util": "11.0.1",
|
||||
"@substrate/ss58-registry": "^1.39.0",
|
||||
"tslib": "^2.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/hw-ledger": "10.2.2"
|
||||
"@polkadot/hw-ledger": "11.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/networks authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { ledgerApps } from '@polkadot/hw-ledger/defaults';
|
||||
import { isHex } from '@polkadot/util';
|
||||
|
||||
|
||||
@@ -85,10 +85,14 @@ export const knownGenesis: KnownGenesis = {
|
||||
parallel: [
|
||||
'0xe61a41c53f5dcd0beb09df93b34402aada44cb05117b71059cce40a2723a4e97'
|
||||
],
|
||||
pendulum: [
|
||||
'0x5d3c298622d5634ed019bf61ea4b71655030015bde9beb0d6a24743714462c86'
|
||||
],
|
||||
phala: [
|
||||
'0x1bb969d85965e4bb5a651abbedf21a54b6b31a21f66b5401cc3f1e286268d736'
|
||||
],
|
||||
picasso: [
|
||||
'0x6811a339673c9daa897944dcdac99c6e2939cc88245ed21951a0a3c9a2be75bc',
|
||||
'0xe8e7f0f4c4f5a00720b4821dbfddefea7490bcf0b19009961cc46957984e2c1c'
|
||||
],
|
||||
polkadex: [
|
||||
@@ -129,6 +133,9 @@ export const knownGenesis: KnownGenesis = {
|
||||
subsocial: [
|
||||
'0x0bd72c1c305172e1275278aaeb3f161e02eccb7a819e63f62d47bd53a28189f8'
|
||||
],
|
||||
ternoa: [
|
||||
'0x6859c81ca95ef624c9dfe4dc6e3381c33e5d6509e35e147092bfbc780f777c4e'
|
||||
],
|
||||
unique: [
|
||||
'0x84322d9cddbf35088f1e54e9a85c967a41a56a4f43445768125e61af166c7d31'
|
||||
],
|
||||
|
||||
@@ -29,7 +29,9 @@ export const knownLedger: KnownLedger = {
|
||||
nodle: 0x000003eb,
|
||||
origintrail: 0x00000162,
|
||||
parallel: 0x00000162,
|
||||
pendulum: 0x00000162,
|
||||
phala: 0x00000162,
|
||||
picasso: 0x000001b2,
|
||||
polkadex: 0x0000031f,
|
||||
polkadot: 0x00000162,
|
||||
polymesh: 0x00000253,
|
||||
@@ -37,6 +39,7 @@ export const knownLedger: KnownLedger = {
|
||||
stafi: 0x0000038b,
|
||||
statemine: 0x000001b2, // common-good on Kusama, shares derivation
|
||||
statemint: 0x00000162, // common-good on Polkadot, shares derivation
|
||||
ternoa: 0x00003e3,
|
||||
unique: 0x00000162,
|
||||
vtb: 0x000002b6,
|
||||
xxnetwork: 0x000007a3
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/networks authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { SubstrateNetwork } from './types';
|
||||
|
||||
import { knownGenesis, knownIcon, knownLedger, knownTestnet } from './defaults';
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/networks', path: 'auto', type: 'auto', version: '10.2.2' };
|
||||
export const packageInfo = { name: '@polkadot/networks', path: 'auto', type: 'auto', version: '11.0.1' };
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
// Copyright 2017-2023 @polkadot/networks authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import known from '@substrate/ss58-registry';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import other from './test/ss58registry.test.json';
|
||||
import known from '@substrate/ss58-registry';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
import other from './test/ss58registry.test.json' assert { type: 'json' };
|
||||
|
||||
describe('@substrate/ss58-registry', (): void => {
|
||||
it('has known values', (): void => {
|
||||
@@ -20,7 +23,7 @@ describe('@substrate/ss58-registry', (): void => {
|
||||
throw error;
|
||||
}
|
||||
|
||||
fs.writeFileSync(path.join(__dirname, './test/ss58registry.test.json'), json, { flag: 'w' });
|
||||
fs.writeFileSync(path.join(process.cwd(), 'packages/networks/src/test/ss58registry.test.json'), json, { flag: 'w' });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1181,6 +1181,19 @@
|
||||
"standardAccount": "*25519",
|
||||
"website": "https://geek.gl"
|
||||
},
|
||||
{
|
||||
"prefix": 995,
|
||||
"network": "ternoa",
|
||||
"displayName": "Ternoa",
|
||||
"symbols": [
|
||||
"CAPS"
|
||||
],
|
||||
"decimals": [
|
||||
18
|
||||
],
|
||||
"standardAccount": "*25519",
|
||||
"website": "https://www.ternoa.network"
|
||||
},
|
||||
{
|
||||
"prefix": 1110,
|
||||
"network": "efinity",
|
||||
@@ -1272,6 +1285,19 @@
|
||||
"standardAccount": "*25519",
|
||||
"website": "https://ajuna.io"
|
||||
},
|
||||
{
|
||||
"prefix": 1516,
|
||||
"network": "societal",
|
||||
"displayName": "Societal",
|
||||
"symbols": [
|
||||
"SCTL"
|
||||
],
|
||||
"decimals": [
|
||||
12
|
||||
],
|
||||
"standardAccount": "*25519",
|
||||
"website": "https://www.sctl.xyz"
|
||||
},
|
||||
{
|
||||
"prefix": 1985,
|
||||
"network": "seals",
|
||||
@@ -1364,24 +1390,11 @@
|
||||
"website": "https://chainflip.io/"
|
||||
},
|
||||
{
|
||||
"prefix": 2114,
|
||||
"network": "Turing",
|
||||
"displayName": "Turing Network",
|
||||
"prefix": 2206,
|
||||
"network": "ICE",
|
||||
"displayName": "ICE Network",
|
||||
"symbols": [
|
||||
"TUR"
|
||||
],
|
||||
"decimals": [
|
||||
10
|
||||
],
|
||||
"standardAccount": "*25519",
|
||||
"website": "https://oak.tech/turing/home/"
|
||||
},
|
||||
{
|
||||
"prefix": 2207,
|
||||
"network": "SNOW",
|
||||
"displayName": "SNOW: ICE Canary Network",
|
||||
"symbols": [
|
||||
"ICZ"
|
||||
"ICY"
|
||||
],
|
||||
"decimals": [
|
||||
18
|
||||
@@ -1390,11 +1403,11 @@
|
||||
"website": "https://icenetwork.io"
|
||||
},
|
||||
{
|
||||
"prefix": 2208,
|
||||
"network": "ICE",
|
||||
"displayName": "ICE Network",
|
||||
"prefix": 2207,
|
||||
"network": "SNOW",
|
||||
"displayName": "SNOW: ICE Canary Network",
|
||||
"symbols": [
|
||||
"ICY"
|
||||
"ICZ"
|
||||
],
|
||||
"decimals": [
|
||||
18
|
||||
@@ -1639,5 +1652,18 @@
|
||||
],
|
||||
"standardAccount": "*25519",
|
||||
"website": "https://nftmart.io"
|
||||
},
|
||||
{
|
||||
"prefix": 13116,
|
||||
"network": "bittensor",
|
||||
"displayName": "Bittensor",
|
||||
"symbols": [
|
||||
"TAO"
|
||||
],
|
||||
"decimals": [
|
||||
9
|
||||
],
|
||||
"standardAccount": "*25519",
|
||||
"website": "https://bittensor.com"
|
||||
}
|
||||
]
|
||||
@@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -22,29 +22,29 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "10.2.2",
|
||||
"version": "11.0.1",
|
||||
"browser": {
|
||||
"crypto": false,
|
||||
"stream": false
|
||||
},
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.7",
|
||||
"@noble/hashes": "1.1.5",
|
||||
"@noble/secp256k1": "1.7.0",
|
||||
"@polkadot/networks": "10.2.2",
|
||||
"@polkadot/util": "10.2.2",
|
||||
"@polkadot/wasm-crypto": "^6.4.1",
|
||||
"@polkadot/x-bigint": "10.2.2",
|
||||
"@polkadot/x-randomvalues": "10.2.2",
|
||||
"@noble/hashes": "1.2.0",
|
||||
"@noble/secp256k1": "1.7.1",
|
||||
"@polkadot/networks": "11.0.1",
|
||||
"@polkadot/util": "11.0.1",
|
||||
"@polkadot/wasm-crypto": "^7.0.2",
|
||||
"@polkadot/x-bigint": "11.0.1",
|
||||
"@polkadot/x-randomvalues": "11.0.1",
|
||||
"@scure/base": "1.1.1",
|
||||
"ed2curve": "^0.3.0",
|
||||
"tslib": "^2.5.0",
|
||||
"tweetnacl": "^1.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/ed2curve": "^0.2.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "10.2.2"
|
||||
"@polkadot/util": "11.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { hexToU8a } from '@polkadot/util';
|
||||
|
||||
import { addressToEvm } from './addressToEvm';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { checkAddress } from '.';
|
||||
|
||||
describe('checkAddress', (): void => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { base58Decode } from '../base58';
|
||||
import { checkAddressChecksum } from './checksum';
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { hexToU8a, stringToU8a, u8aToHex } from '@polkadot/util';
|
||||
|
||||
import { ALICE_PUBLIC_SR } from './encode.spec';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { waitReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
import { deriveAddress } from '.';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { encodeAddress } from '.';
|
||||
|
||||
export const ALICE_PUBLIC_SR = new Uint8Array([212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125]);
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { encodeDerivedAddress } from '.';
|
||||
|
||||
describe('encodeDerivedAddress', (): void => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { encodeMultiAddress } from '.';
|
||||
|
||||
describe('encodeMultiAddress', (): void => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { ALICE_PUBLIC_SR } from './encode.spec';
|
||||
import { addressEq } from '.';
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { evmToAddress } from '.';
|
||||
|
||||
describe('evmToAddress', (): void => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { isAddress } from '.';
|
||||
|
||||
describe('isAddress', (): void => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { createKeyDerived } from '.';
|
||||
|
||||
describe('createKeyDerived', (): void => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { createKeyMulti } from '.';
|
||||
|
||||
describe('createKeyMulti', (): void => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { encodeAddress, setSS58Format } from '.';
|
||||
|
||||
describe('setSS58Format', (): void => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { sortAddresses } from '.';
|
||||
|
||||
describe('sortAddresses', (): void => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { validateAddress } from '.';
|
||||
|
||||
describe('validateAddress', (): void => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { u8aToString } from '@polkadot/util';
|
||||
|
||||
import { base32Decode } from '.';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { base58Decode } from '../base58';
|
||||
import { base32Encode } from '.';
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { isBase32 } from '.';
|
||||
|
||||
describe('isBase32', (): void => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { base32Validate } from '.';
|
||||
|
||||
describe('base32Validate', (): void => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { base32Decode } from '../base32';
|
||||
import { base58Decode } from './';
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { base32Decode } from '../base32';
|
||||
import { base58Encode } from './';
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { stringToU8a } from '@polkadot/util';
|
||||
|
||||
import { base64Decode } from '.';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { base64Encode } from '.';
|
||||
|
||||
describe('base64Encode', (): void => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { base64Pad } from '.';
|
||||
|
||||
describe('base64Pad', (): void => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { base64Trim } from '.';
|
||||
|
||||
describe('base64Trim', (): void => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { base64Validate } from '.';
|
||||
|
||||
describe('base64Validate', (): void => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { hexToU8a } from '@polkadot/util';
|
||||
import { waitReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
@@ -11,43 +14,45 @@ describe('blake2AsHex', (): void => {
|
||||
await waitReady();
|
||||
});
|
||||
|
||||
describe.each([false, true])('onlyJs=%p', (onlyJs): void => {
|
||||
it('returns a 64-bit value (specified)', (): void => {
|
||||
expect(
|
||||
blake2AsHex('abc', 64, null, onlyJs)
|
||||
).toEqual('0xd8bb14d833d59559');
|
||||
});
|
||||
for (const onlyJs of [false, true]) {
|
||||
describe(`onlyJs=${(onlyJs && 'true') || 'false'}`, (): void => {
|
||||
it('returns a 64-bit value (specified)', (): void => {
|
||||
expect(
|
||||
blake2AsHex('abc', 64, null, onlyJs)
|
||||
).toEqual('0xd8bb14d833d59559');
|
||||
});
|
||||
|
||||
it('returns a 128-bit value (as specified)', (): void => {
|
||||
expect(
|
||||
blake2AsHex('abc', 128, null, onlyJs)
|
||||
).toEqual('0xcf4ab791c62b8d2b2109c90275287816');
|
||||
});
|
||||
it('returns a 128-bit value (as specified)', (): void => {
|
||||
expect(
|
||||
blake2AsHex('abc', 128, null, onlyJs)
|
||||
).toEqual('0xcf4ab791c62b8d2b2109c90275287816');
|
||||
});
|
||||
|
||||
it('returns a 128-bit value (as specified, with key)', (): void => {
|
||||
expect(
|
||||
blake2AsHex('abc', 128, new Uint8Array([1, 2]), onlyJs)
|
||||
).toEqual('0x36f3d08cda72a00ddf2be103eb5770d9');
|
||||
});
|
||||
it('returns a 128-bit value (as specified, with key)', (): void => {
|
||||
expect(
|
||||
blake2AsHex('abc', 128, new Uint8Array([1, 2]), onlyJs)
|
||||
).toEqual('0x36f3d08cda72a00ddf2be103eb5770d9');
|
||||
});
|
||||
|
||||
it('returns a 256-bit value (default)', (): void => {
|
||||
expect(
|
||||
blake2AsHex('abc', undefined, null, onlyJs)
|
||||
).toEqual('0xbddd813c634239723171ef3fee98579b94964e3bb1cb3e427262c8c068d52319');
|
||||
});
|
||||
it('returns a 256-bit value (default)', (): void => {
|
||||
expect(
|
||||
blake2AsHex('abc', undefined, null, onlyJs)
|
||||
).toEqual('0xbddd813c634239723171ef3fee98579b94964e3bb1cb3e427262c8c068d52319');
|
||||
});
|
||||
|
||||
it('returns a 512-bit value (as specified)', (): void => {
|
||||
expect(
|
||||
blake2AsHex('abc', 512, null, onlyJs)
|
||||
).toEqual('0xba80a53f981c4d0d6a2797b69f12f6e94c212f14685ac4b74b12bb6fdbffa2d17d87c5392aab792dc252d5de4533cc9518d38aa8dbf1925ab92386edd4009923');
|
||||
});
|
||||
it('returns a 512-bit value (as specified)', (): void => {
|
||||
expect(
|
||||
blake2AsHex('abc', 512, null, onlyJs)
|
||||
).toEqual('0xba80a53f981c4d0d6a2797b69f12f6e94c212f14685ac4b74b12bb6fdbffa2d17d87c5392aab792dc252d5de4533cc9518d38aa8dbf1925ab92386edd4009923');
|
||||
});
|
||||
|
||||
it('matches with the Rust implementation', (): void => {
|
||||
expect(
|
||||
blake2AsHex(
|
||||
hexToU8a('0x454545454545454545454545454545454545454545454545454545454545454501000000000000002481853da20b9f4322f34650fea5f240dcbfb266d02db94bfa0153c31f4a29dbdbf025dd4a69a6f4ee6e1577b251b655097e298b692cb34c18d3182cac3de0dc00000000'), 256, undefined, onlyJs
|
||||
)
|
||||
).toEqual('0x1025e5db74fdaf4d2818822dccf0e1604ae9ccc62f26cecfde23448ff0248abf');
|
||||
it('matches with the Rust implementation', (): void => {
|
||||
expect(
|
||||
blake2AsHex(
|
||||
hexToU8a('0x454545454545454545454545454545454545454545454545454545454545454501000000000000002481853da20b9f4322f34650fea5f240dcbfb266d02db94bfa0153c31f4a29dbdbf025dd4a69a6f4ee6e1577b251b655097e298b692cb34c18d3182cac3de0dc00000000'), 256, undefined, onlyJs
|
||||
)
|
||||
).toEqual('0x1025e5db74fdaf4d2818822dccf0e1604ae9ccc62f26cecfde23448ff0248abf');
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { hexToU8a } from '@polkadot/util';
|
||||
import { waitReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
import { performanceWasm } from '../test/performance';
|
||||
import { perfWasm } from '../test';
|
||||
import { blake2AsU8a } from '.';
|
||||
|
||||
describe('blake2AsU8a', (): void => {
|
||||
@@ -12,39 +15,41 @@ describe('blake2AsU8a', (): void => {
|
||||
await waitReady();
|
||||
});
|
||||
|
||||
describe.each([false, true])('onlyJs=%p', (onlyJs): void => {
|
||||
it('returns a 64-bit value by default', (): void => {
|
||||
expect(
|
||||
blake2AsU8a('abc', undefined, undefined, onlyJs)
|
||||
).toEqual(
|
||||
new Uint8Array([189, 221, 129, 60, 99, 66, 57, 114, 49, 113, 239, 63, 238, 152, 87, 155, 148, 150, 78, 59, 177, 203, 62, 66, 114, 98, 200, 192, 104, 213, 35, 25])
|
||||
);
|
||||
});
|
||||
for (const onlyJs of [false, true]) {
|
||||
describe(`onlyJs=${(onlyJs && 'true') || 'false'}`, (): void => {
|
||||
it('returns a 64-bit value by default', (): void => {
|
||||
expect(
|
||||
blake2AsU8a('abc', undefined, undefined, onlyJs)
|
||||
).toEqual(
|
||||
new Uint8Array([189, 221, 129, 60, 99, 66, 57, 114, 49, 113, 239, 63, 238, 152, 87, 155, 148, 150, 78, 59, 177, 203, 62, 66, 114, 98, 200, 192, 104, 213, 35, 25])
|
||||
);
|
||||
});
|
||||
|
||||
it('returns a 128-bit value (as specified,)', (): void => {
|
||||
expect(
|
||||
blake2AsU8a('abc', 128, undefined, onlyJs)
|
||||
).toEqual(
|
||||
new Uint8Array([207, 74, 183, 145, 198, 43, 141, 43, 33, 9, 201, 2, 117, 40, 120, 22])
|
||||
);
|
||||
});
|
||||
it('returns a 128-bit value (as specified,)', (): void => {
|
||||
expect(
|
||||
blake2AsU8a('abc', 128, undefined, onlyJs)
|
||||
).toEqual(
|
||||
new Uint8Array([207, 74, 183, 145, 198, 43, 141, 43, 33, 9, 201, 2, 117, 40, 120, 22])
|
||||
);
|
||||
});
|
||||
|
||||
it('returns a 256-bit value (as specified)', (): void => {
|
||||
expect(
|
||||
blake2AsU8a('abc', 256, undefined, onlyJs)
|
||||
).toEqual(
|
||||
new Uint8Array([189, 221, 129, 60, 99, 66, 57, 114, 49, 113, 239, 63, 238, 152, 87, 155, 148, 150, 78, 59, 177, 203, 62, 66, 114, 98, 200, 192, 104, 213, 35, 25])
|
||||
);
|
||||
});
|
||||
it('returns a 256-bit value (as specified)', (): void => {
|
||||
expect(
|
||||
blake2AsU8a('abc', 256, undefined, onlyJs)
|
||||
).toEqual(
|
||||
new Uint8Array([189, 221, 129, 60, 99, 66, 57, 114, 49, 113, 239, 63, 238, 152, 87, 155, 148, 150, 78, 59, 177, 203, 62, 66, 114, 98, 200, 192, 104, 213, 35, 25])
|
||||
);
|
||||
});
|
||||
|
||||
it('returns a 512-bit value (as specified)', (): void => {
|
||||
expect(
|
||||
blake2AsU8a('abc', 512, undefined, onlyJs)
|
||||
).toEqual(
|
||||
hexToU8a('0xba80a53f981c4d0d6a2797b69f12f6e94c212f14685ac4b74b12bb6fdbffa2d17d87c5392aab792dc252d5de4533cc9518d38aa8dbf1925ab92386edd4009923')
|
||||
);
|
||||
it('returns a 512-bit value (as specified)', (): void => {
|
||||
expect(
|
||||
blake2AsU8a('abc', 512, undefined, onlyJs)
|
||||
).toEqual(
|
||||
hexToU8a('0xba80a53f981c4d0d6a2797b69f12f6e94c212f14685ac4b74b12bb6fdbffa2d17d87c5392aab792dc252d5de4533cc9518d38aa8dbf1925ab92386edd4009923')
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
it('has equivalent Wasm/Js outputs on hex inputs', (): void => {
|
||||
const a = blake2AsU8a('0x123456', 256, null, false);
|
||||
@@ -60,9 +65,11 @@ describe('blake2AsU8a', (): void => {
|
||||
expect(a).toEqual(b);
|
||||
});
|
||||
|
||||
describe.each([256, 512] as (256 | 512)[])('bitLength=$p', (bitLength): void => {
|
||||
performanceWasm(`blake2AsU8a, bitLength=${bitLength}`, 64000, (input, onlyJs) =>
|
||||
blake2AsU8a(input, bitLength, null, onlyJs)
|
||||
);
|
||||
});
|
||||
for (const bitLength of [256, 512] as const) {
|
||||
describe(`bitLength=${bitLength}`, (): void => {
|
||||
perfWasm(`blake2AsU8a, bitLength=${bitLength}`, 64000, (input, onlyJs) =>
|
||||
blake2AsU8a(input, bitLength, null, onlyJs)
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
// Copyright 2017-2023 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
// no TS, this is not meant to be a global...
|
||||
export {};
|
||||
|
||||
describe('cryptoWaitReady', (): void => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { u8aToHex } from '@polkadot/util';
|
||||
|
||||
import { convertPublicKeyToCurve25519, convertSecretKeyToCurve25519 } from '.';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { Keypair } from '../../types';
|
||||
|
||||
import { ed25519PairFromRandom } from '..';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { ed25519PairFromSecret } from '..';
|
||||
|
||||
describe('ed25519PairFromSecret', (): void => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { stringToU8a } from '@polkadot/util';
|
||||
import { waitReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { ed25519PairFromString } from '..';
|
||||
|
||||
describe('ed25519PairFromSeed', (): void => {
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { stringToU8a } from '@polkadot/util';
|
||||
import { waitReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
import { performanceWasm } from '../test/performance';
|
||||
import { perfWasm } from '../test';
|
||||
import { ed25519PairFromSeed, ed25519Sign } from '.';
|
||||
|
||||
const PAIR = ed25519PairFromSeed(
|
||||
@@ -16,21 +19,23 @@ describe('ed25519Sign', (): void => {
|
||||
await waitReady();
|
||||
});
|
||||
|
||||
describe.each([false, true])('onlyJs=%p', (onlyJs): void => {
|
||||
it('returns a valid signature for the message', (): void => {
|
||||
expect(
|
||||
ed25519Sign(
|
||||
new Uint8Array([0x61, 0x62, 0x63, 0x64]),
|
||||
PAIR,
|
||||
onlyJs
|
||||
)
|
||||
).toEqual(
|
||||
new Uint8Array([28, 58, 206, 239, 249, 70, 59, 191, 166, 40, 219, 218, 235, 170, 25, 79, 10, 94, 9, 197, 34, 126, 1, 150, 246, 68, 28, 238, 36, 26, 172, 163, 168, 90, 202, 211, 126, 246, 57, 212, 43, 24, 88, 197, 240, 113, 118, 76, 37, 81, 91, 110, 236, 50, 144, 134, 100, 223, 220, 238, 34, 185, 211, 7])
|
||||
);
|
||||
for (const onlyJs of [false, true]) {
|
||||
describe(`onlyJs=${(onlyJs && 'true') || 'false'}`, (): void => {
|
||||
it('returns a valid signature for the message', (): void => {
|
||||
expect(
|
||||
ed25519Sign(
|
||||
new Uint8Array([0x61, 0x62, 0x63, 0x64]),
|
||||
PAIR,
|
||||
onlyJs
|
||||
)
|
||||
).toEqual(
|
||||
new Uint8Array([28, 58, 206, 239, 249, 70, 59, 191, 166, 40, 219, 218, 235, 170, 25, 79, 10, 94, 9, 197, 34, 126, 1, 150, 246, 68, 28, 238, 36, 26, 172, 163, 168, 90, 202, 211, 126, 246, 57, 212, 43, 24, 88, 197, 240, 113, 118, 76, 37, 81, 91, 110, 236, 50, 144, 134, 100, 223, 220, 238, 34, 185, 211, 7])
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
performanceWasm('ed25519Sign', 250, (input, onlyJs) =>
|
||||
perfWasm('ed25519Sign', 250, (input, onlyJs) =>
|
||||
ed25519Sign(input, PAIR, onlyJs)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { stringToU8a } from '@polkadot/util';
|
||||
import { waitReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
@@ -19,62 +22,64 @@ describe('ed25519Verify', (): void => {
|
||||
signature = new Uint8Array([28, 58, 206, 239, 249, 70, 59, 191, 166, 40, 219, 218, 235, 170, 25, 79, 10, 94, 9, 197, 34, 126, 1, 150, 246, 68, 28, 238, 36, 26, 172, 163, 168, 90, 202, 211, 126, 246, 57, 212, 43, 24, 88, 197, 240, 113, 118, 76, 37, 81, 91, 110, 236, 50, 144, 134, 100, 223, 220, 238, 34, 185, 211, 7]);
|
||||
});
|
||||
|
||||
describe.each([false, true])('onlyJs=%p', (onlyJs): void => {
|
||||
it('validates a correctly signed message', (): void => {
|
||||
expect(
|
||||
ed25519Verify(
|
||||
new Uint8Array([0x61, 0x62, 0x63, 0x64]),
|
||||
signature,
|
||||
publicKey,
|
||||
onlyJs
|
||||
)
|
||||
).toEqual(true);
|
||||
});
|
||||
for (const onlyJs of [false, true]) {
|
||||
describe(`onlyJs=${(onlyJs && 'true') || 'false'}`, (): void => {
|
||||
it('validates a correctly signed message', (): void => {
|
||||
expect(
|
||||
ed25519Verify(
|
||||
new Uint8Array([0x61, 0x62, 0x63, 0x64]),
|
||||
signature,
|
||||
publicKey,
|
||||
onlyJs
|
||||
)
|
||||
).toEqual(true);
|
||||
});
|
||||
|
||||
it('fails a correctly signed message (message changed)', (): void => {
|
||||
expect(
|
||||
ed25519Verify(
|
||||
new Uint8Array([0x61, 0x62, 0x63, 0x64, 0x65]),
|
||||
signature,
|
||||
publicKey,
|
||||
onlyJs
|
||||
)
|
||||
).toEqual(false);
|
||||
});
|
||||
it('fails a correctly signed message (message changed)', (): void => {
|
||||
expect(
|
||||
ed25519Verify(
|
||||
new Uint8Array([0x61, 0x62, 0x63, 0x64, 0x65]),
|
||||
signature,
|
||||
publicKey,
|
||||
onlyJs
|
||||
)
|
||||
).toEqual(false);
|
||||
});
|
||||
|
||||
it('fails a correctly signed message (signature changed)', (): void => {
|
||||
signature[0] = 0xff;
|
||||
it('fails a correctly signed message (signature changed)', (): void => {
|
||||
signature[0] = 0xff;
|
||||
|
||||
expect(
|
||||
ed25519Verify(
|
||||
new Uint8Array([0x61, 0x62, 0x63, 0x64]),
|
||||
signature,
|
||||
publicKey,
|
||||
onlyJs
|
||||
)
|
||||
).toEqual(false);
|
||||
});
|
||||
expect(
|
||||
ed25519Verify(
|
||||
new Uint8Array([0x61, 0x62, 0x63, 0x64]),
|
||||
signature,
|
||||
publicKey,
|
||||
onlyJs
|
||||
)
|
||||
).toEqual(false);
|
||||
});
|
||||
|
||||
it('throws error when publicKey lengths do not match', (): void => {
|
||||
expect(
|
||||
() => ed25519Verify(
|
||||
new Uint8Array([0x61, 0x62, 0x63, 0x64]),
|
||||
signature,
|
||||
new Uint8Array([1, 2]),
|
||||
onlyJs
|
||||
)
|
||||
).toThrow(/Invalid publicKey/);
|
||||
});
|
||||
it('throws error when publicKey lengths do not match', (): void => {
|
||||
expect(
|
||||
() => ed25519Verify(
|
||||
new Uint8Array([0x61, 0x62, 0x63, 0x64]),
|
||||
signature,
|
||||
new Uint8Array([1, 2]),
|
||||
onlyJs
|
||||
)
|
||||
).toThrow(/Invalid publicKey/);
|
||||
});
|
||||
|
||||
it('throws error when signature lengths do not match', (): void => {
|
||||
expect(
|
||||
() => ed25519Verify(
|
||||
new Uint8Array([0x61, 0x62, 0x63, 0x64]),
|
||||
new Uint8Array([1, 2]),
|
||||
publicKey,
|
||||
onlyJs
|
||||
)
|
||||
).toThrow(/Invalid signature/);
|
||||
it('throws error when signature lengths do not match', (): void => {
|
||||
expect(
|
||||
() => ed25519Verify(
|
||||
new Uint8Array([0x61, 0x62, 0x63, 0x64]),
|
||||
new Uint8Array([1, 2]),
|
||||
publicKey,
|
||||
onlyJs
|
||||
)
|
||||
).toThrow(/Invalid signature/);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { keccakAsU8a } from '../keccak';
|
||||
import { ethereumEncode } from './';
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { isEthereumAddress } from './';
|
||||
|
||||
const ADDRESS = '0x00a329c0648769A73afAc7F9381E08FB43dBEA72';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { isEthereumChecksum } from './';
|
||||
|
||||
const ADDRESS = '0x00a329c0648769A73afAc7F9381E08FB43dBEA72';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { mnemonicToLegacySeed } from '@polkadot/util-crypto';
|
||||
|
||||
import { hdEthereum } from '.';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { u8aToHex } from '@polkadot/util';
|
||||
|
||||
import { hdLedger } from '..';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { u8aToHex } from '@polkadot/util';
|
||||
|
||||
import { ledgerMaster } from './master';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { hdValidatePath } from '.';
|
||||
|
||||
const VECTORS: [string, boolean][] = [
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { hexToU8a, stringToU8a } from '@polkadot/util';
|
||||
import { waitReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
import { performanceWasm } from '../test/performance';
|
||||
import { perfWasm } from '../test';
|
||||
import { hmacShaAsU8a } from '.';
|
||||
|
||||
describe('hmacShaAsU8a', (): void => {
|
||||
@@ -23,17 +26,21 @@ describe('hmacShaAsU8a', (): void => {
|
||||
)
|
||||
};
|
||||
|
||||
describe.each([256, 512] as (256 | 512)[])('bitLength=%p', (bitLength): void => {
|
||||
describe.each([false, true])('onlyJs=%p', (onlyJs): void => {
|
||||
it('returns an hex representation (string)', (): void => {
|
||||
expect(
|
||||
hmacShaAsU8a(key, data, bitLength, onlyJs)
|
||||
).toEqual(output[bitLength]);
|
||||
});
|
||||
for (const bitLength of [256, 512] as const) {
|
||||
describe(`bitLength=${bitLength}`, (): void => {
|
||||
for (const onlyJs of [false, true]) {
|
||||
describe(`onlyJs=${(onlyJs && 'true') || 'false'}`, (): void => {
|
||||
it('returns an hex representation (string)', (): void => {
|
||||
expect(
|
||||
hmacShaAsU8a(key, data, bitLength, onlyJs)
|
||||
).toEqual(output[bitLength]);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
performanceWasm(`hmacShaAsU8a, bitLength=${bitLength}`, 16000, (input, onlyJs) =>
|
||||
perfWasm(`hmacShaAsU8a, bitLength=${bitLength}`, 16000, (input, onlyJs) =>
|
||||
hmacShaAsU8a(input, input, bitLength, onlyJs)
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { waitReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
import { keccakAsHex } from '.';
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { hexToU8a, stringToU8a } from '@polkadot/util';
|
||||
import { waitReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
import { performanceWasm } from '../test/performance';
|
||||
import { perfWasm } from '../test';
|
||||
import { keccakAsU8a } from '.';
|
||||
|
||||
describe('keccakAsU8a', (): void => {
|
||||
@@ -22,29 +25,33 @@ describe('keccakAsU8a', (): void => {
|
||||
)
|
||||
};
|
||||
|
||||
describe.each([256, 512] as (256 | 512)[])('bitLength=$p', (bitLength): void => {
|
||||
describe.each([false, true])('onlyJs=%p', (onlyJs): void => {
|
||||
it('returns an hex representation (string)', (): void => {
|
||||
expect(
|
||||
keccakAsU8a(input, bitLength, onlyJs)
|
||||
).toEqual(output[bitLength]);
|
||||
});
|
||||
for (const bitLength of [256, 512] as const) {
|
||||
describe(`bitLength=${bitLength}`, (): void => {
|
||||
for (const onlyJs of [false, true]) {
|
||||
describe(`onlyJs=${(onlyJs && 'true') || 'false'}`, (): void => {
|
||||
it('returns an hex representation (string)', (): void => {
|
||||
expect(
|
||||
keccakAsU8a(input, bitLength, onlyJs)
|
||||
).toEqual(output[bitLength]);
|
||||
});
|
||||
|
||||
it('returns an hex representation (Buffer)', (): void => {
|
||||
expect(
|
||||
keccakAsU8a(Buffer.from(input), bitLength, onlyJs)
|
||||
).toEqual(output[bitLength]);
|
||||
});
|
||||
it('returns an hex representation (Buffer)', (): void => {
|
||||
expect(
|
||||
keccakAsU8a(Buffer.from(input), bitLength, onlyJs)
|
||||
).toEqual(output[bitLength]);
|
||||
});
|
||||
|
||||
it('returns an hex representation (Uint8Array)', (): void => {
|
||||
expect(
|
||||
keccakAsU8a(stringToU8a(input), bitLength, onlyJs)
|
||||
).toEqual(output[bitLength]);
|
||||
});
|
||||
it('returns an hex representation (Uint8Array)', (): void => {
|
||||
expect(
|
||||
keccakAsU8a(stringToU8a(input), bitLength, onlyJs)
|
||||
).toEqual(output[bitLength]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
perfWasm(`keccakAsU8a, bitLength=${bitLength}`, 128000, (input, onlyJs) =>
|
||||
keccakAsU8a(input, bitLength, onlyJs)
|
||||
);
|
||||
});
|
||||
|
||||
performanceWasm(`keccakAsU8a, bitLength=${bitLength}`, 128000, (input, onlyJs) =>
|
||||
keccakAsU8a(input, bitLength, onlyJs)
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { ExtractResult, keyExtractPath } from './extractPath';
|
||||
|
||||
describe('keyExtractPath', (): void => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { ExtractResult, keyExtractSuri } from './extractSuri';
|
||||
|
||||
describe('keyExtractSuri', (): void => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { entropyToMnemonic, mnemonicToEntropy } from './bip39';
|
||||
import DEFAULT_WORDLIST from './bip39-en';
|
||||
|
||||
|
||||
@@ -1,37 +1,42 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { cryptoWaitReady } from '..';
|
||||
import { mnemonicGenerate } from './generate';
|
||||
import { mnemonicValidate } from './validate';
|
||||
|
||||
describe('mnemonicGenerate', (): void => {
|
||||
beforeEach(async (): Promise<void> => {
|
||||
await cryptoWaitReady();
|
||||
});
|
||||
await cryptoWaitReady();
|
||||
|
||||
describe('mnemonicGenerate', (): void => {
|
||||
it('generates a valid mnemonic (default strength)', (): void => {
|
||||
expect(
|
||||
mnemonicValidate(mnemonicGenerate())
|
||||
).toEqual(true);
|
||||
});
|
||||
|
||||
describe.each([false, true])('onlyJs=%p', (onlyJs): void => {
|
||||
it.each([12, 15, 18, 21, 24] as 12[])('generates a valid mnemonic (%p words)', (num): void => {
|
||||
const mnemonic = mnemonicGenerate(num, onlyJs);
|
||||
const isValid = mnemonicValidate(mnemonic);
|
||||
for (const onlyJs of [false, true]) {
|
||||
describe(`onlyJs=${(onlyJs && 'true') || 'false'}`, (): void => {
|
||||
for (const num of [12, 15, 18, 21, 24] as const) {
|
||||
it(`generates a valid mnemonic (${num} words)`, (): void => {
|
||||
const mnemonic = mnemonicGenerate(num, onlyJs);
|
||||
const isValid = mnemonicValidate(mnemonic);
|
||||
|
||||
expect(mnemonic.split(' ')).toHaveLength(num);
|
||||
expect(isValid).toEqual(true);
|
||||
expect(mnemonic.split(' ')).toHaveLength(num);
|
||||
expect(isValid).toEqual(true);
|
||||
});
|
||||
}
|
||||
|
||||
it('generates non-deterministic', (): void => {
|
||||
const m1 = mnemonicGenerate(24, onlyJs);
|
||||
const m2 = mnemonicGenerate(24, onlyJs);
|
||||
|
||||
expect(m1 === m2).toEqual(false);
|
||||
expect(mnemonicValidate(m1)).toEqual(true);
|
||||
expect(mnemonicValidate(m2)).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('generates not deterministic', (): void => {
|
||||
const m1 = mnemonicGenerate(24, onlyJs);
|
||||
const m2 = mnemonicGenerate(24, onlyJs);
|
||||
|
||||
expect(m1 === m2).toEqual(false);
|
||||
expect(mnemonicValidate(m1)).toEqual(true);
|
||||
expect(mnemonicValidate(m2)).toEqual(true);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,22 +1,25 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { u8aToHex } from '@polkadot/util';
|
||||
|
||||
import tests from '../sr25519/pair/testing.spec';
|
||||
import { cryptoWaitReady } from '..';
|
||||
import { mnemonicToEntropy } from './toEntropy';
|
||||
|
||||
describe('mnemonicToEntropy', (): void => {
|
||||
beforeEach(async (): Promise<void> => {
|
||||
await cryptoWaitReady();
|
||||
});
|
||||
await cryptoWaitReady();
|
||||
|
||||
describe.each([false, true])('onlyJs=%p', (onlyJs): void => {
|
||||
tests.forEach(([mnemonic, entropy], index): void => {
|
||||
it(`Created correct entropy for ${index}`, (): void => {
|
||||
expect(u8aToHex(mnemonicToEntropy(mnemonic, onlyJs))).toEqual(entropy);
|
||||
describe('mnemonicToEntropy', (): void => {
|
||||
for (const onlyJs of [false, true]) {
|
||||
describe(`onlyJs=${(onlyJs && 'true') || 'false'}`, (): void => {
|
||||
tests.forEach(([mnemonic, entropy], index): void => {
|
||||
it(`Created correct entropy for ${index}`, (): void => {
|
||||
expect(u8aToHex(mnemonicToEntropy(mnemonic, onlyJs))).toEqual(entropy);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { u8aEq, u8aToHex } from '@polkadot/util';
|
||||
import { waitReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
@@ -15,32 +18,36 @@ describe('mnemonicToLegacySeed', (): void => {
|
||||
await waitReady();
|
||||
});
|
||||
|
||||
it.each([undefined, 'foo', 'bar'])('generates Wasm & Js equivalents (password = %p', (password): void => {
|
||||
expect(
|
||||
u8aEq(
|
||||
mnemonicToLegacySeed(MNEMONIC, password, true),
|
||||
mnemonicToLegacySeed(MNEMONIC, password, false)
|
||||
)
|
||||
).toEqual(true);
|
||||
});
|
||||
|
||||
describe.each([false, true])('onlyJs=%p', (onlyJs): void => {
|
||||
it('generates a valid 64bytes seed', (): void => {
|
||||
for (const password of [undefined, 'foo', 'bar']) {
|
||||
it(`generates Wasm & Js equivalents for password=${password || 'undefined'}`, (): void => {
|
||||
expect(
|
||||
u8aToHex(mnemonicToLegacySeed(MNEMONIC, undefined, onlyJs, 64))
|
||||
).toEqual(SEED_64);
|
||||
u8aEq(
|
||||
mnemonicToLegacySeed(MNEMONIC, password, true),
|
||||
mnemonicToLegacySeed(MNEMONIC, password, false)
|
||||
)
|
||||
).toEqual(true);
|
||||
});
|
||||
}
|
||||
|
||||
it('generates a valid 32bytes seed', (): void => {
|
||||
expect(
|
||||
u8aToHex(mnemonicToLegacySeed(MNEMONIC, undefined, onlyJs))
|
||||
).toEqual(SEED_32);
|
||||
});
|
||||
for (const onlyJs of [false, true]) {
|
||||
describe(`onlyJs=${(onlyJs && 'true') || 'false'}`, (): void => {
|
||||
it('generates a valid 64bytes seed', (): void => {
|
||||
expect(
|
||||
u8aToHex(mnemonicToLegacySeed(MNEMONIC, undefined, onlyJs, 64))
|
||||
).toEqual(SEED_64);
|
||||
});
|
||||
|
||||
it('fails with non-mnemonics', (): void => {
|
||||
expect(
|
||||
() => mnemonicToLegacySeed('foo bar baz', undefined, onlyJs)
|
||||
).toThrow(/mnemonic specified/);
|
||||
it('generates a valid 32bytes seed', (): void => {
|
||||
expect(
|
||||
u8aToHex(mnemonicToLegacySeed(MNEMONIC, undefined, onlyJs))
|
||||
).toEqual(SEED_32);
|
||||
});
|
||||
|
||||
it('fails with non-mnemonics', (): void => {
|
||||
expect(
|
||||
() => mnemonicToLegacySeed('foo bar baz', undefined, onlyJs)
|
||||
).toThrow(/mnemonic specified/);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { u8aEq, u8aToHex } from '@polkadot/util';
|
||||
|
||||
import tests from '../sr25519/pair/testing.spec';
|
||||
@@ -10,42 +13,44 @@ import { mnemonicToMiniSecret } from './toMiniSecret';
|
||||
const MNEMONIC = 'seed sock milk update focus rotate barely fade car face mechanic mercy';
|
||||
const SEED = '0x4d1ab2a57929edfd018aaa974e62ed557e3f54b4104acabedf73c8f5a1dbb029';
|
||||
|
||||
await cryptoWaitReady();
|
||||
|
||||
describe('mnemonicToMiniSecret', (): void => {
|
||||
beforeEach(async (): Promise<void> => {
|
||||
await cryptoWaitReady();
|
||||
});
|
||||
|
||||
it.each([undefined, 'foo', 'bar'])('generates Wasm & Js equivalents for password = %p', (password): void => {
|
||||
expect(
|
||||
u8aEq(
|
||||
mnemonicToMiniSecret(MNEMONIC, password, true),
|
||||
mnemonicToMiniSecret(MNEMONIC, password, false)
|
||||
)
|
||||
).toEqual(true);
|
||||
});
|
||||
|
||||
describe.each([false, true])('onlyJs=%p', (onlyJs): void => {
|
||||
it('generates a valid seed', (): void => {
|
||||
for (const password of [undefined, 'foo', 'bar']) {
|
||||
it(`generates Wasm & Js equivalents for password=${password || 'undefined'}`, (): void => {
|
||||
expect(
|
||||
u8aToHex(mnemonicToMiniSecret(MNEMONIC, undefined, onlyJs))
|
||||
).toEqual(SEED);
|
||||
u8aEq(
|
||||
mnemonicToMiniSecret(MNEMONIC, password, true),
|
||||
mnemonicToMiniSecret(MNEMONIC, password, false)
|
||||
)
|
||||
).toEqual(true);
|
||||
});
|
||||
}
|
||||
|
||||
it('fails with non-mnemonics', (): void => {
|
||||
expect(
|
||||
() => mnemonicToMiniSecret('foo bar baz', undefined, onlyJs)
|
||||
).toThrow(/mnemonic specified/);
|
||||
});
|
||||
|
||||
tests.forEach(([mnemonic, , seed], index): void => {
|
||||
it(`Created correct seed for ${index}`, (): void => {
|
||||
for (const onlyJs of [false, true]) {
|
||||
describe(`onlyJs=${(onlyJs && 'true') || 'false'}`, (): void => {
|
||||
it('generates a valid seed', (): void => {
|
||||
expect(
|
||||
u8aToHex(mnemonicToMiniSecret(mnemonic, 'Substrate', onlyJs))
|
||||
).toEqual(
|
||||
// mini returned here, only check first 32-bytes (64 hex + 2 prefix)
|
||||
seed.substring(0, 66)
|
||||
);
|
||||
u8aToHex(mnemonicToMiniSecret(MNEMONIC, undefined, onlyJs))
|
||||
).toEqual(SEED);
|
||||
});
|
||||
|
||||
it('fails with non-mnemonics', (): void => {
|
||||
expect(
|
||||
() => mnemonicToMiniSecret('foo bar baz', undefined, onlyJs)
|
||||
).toThrow(/mnemonic specified/);
|
||||
});
|
||||
|
||||
tests.forEach(([mnemonic, , seed], index): void => {
|
||||
it(`Created correct seed for ${index}`, (): void => {
|
||||
expect(
|
||||
u8aToHex(mnemonicToMiniSecret(mnemonic, 'Substrate', onlyJs))
|
||||
).toEqual(
|
||||
// mini returned here, only check first 32-bytes (64 hex + 2 prefix)
|
||||
seed.substring(0, 66)
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { arrayRange, u8aEq } from '@polkadot/util';
|
||||
|
||||
import { cryptoWaitReady, ed25519PairFromSeed, mnemonicGenerate, mnemonicToMiniSecret, sr25519PairFromSeed } from '..';
|
||||
@@ -12,46 +15,51 @@ import { cryptoWaitReady, ed25519PairFromSeed, mnemonicGenerate, mnemonicToMiniS
|
||||
const NUM_RUNS = 100;
|
||||
const NUM_CHECKS = 5;
|
||||
|
||||
await cryptoWaitReady();
|
||||
|
||||
// generate either a JS or WASM mnemonic
|
||||
describe.each([true, false])('mnemonicToMiniSecret (compare), onlyJsMnemonic=%p', (onlyJsMnemonic): void => {
|
||||
beforeAll(async (): Promise<void> => {
|
||||
await cryptoWaitReady();
|
||||
});
|
||||
for (const onlyJsMnemonic of [false, true]) {
|
||||
describe(`mnemonicToMiniSecret (conpare), onlyJs${(onlyJsMnemonic && 'true') || 'false'}`, (): void => {
|
||||
for (const i of arrayRange(NUM_RUNS)) {
|
||||
// loop through lots of mnemonics
|
||||
describe(`run=${i + 1}`, (): void => {
|
||||
// compare both JS and WASM outputs against original
|
||||
for (const onlyJsMini of [false, true]) {
|
||||
describe(`onlyJsMini=${(onlyJsMini && 'true') || 'false'}`, (): void => {
|
||||
// NOTE we cannot actually use the onlyJsMnemonic flag here
|
||||
const mnemonic = mnemonicGenerate(12);
|
||||
|
||||
// loop through lots of mnemonics
|
||||
describe.each(arrayRange(NUM_RUNS))('run=%p', (): void => {
|
||||
// compare both JS and WASM outputs against original
|
||||
describe.each([true, false])('onlyJsMini=%p', (onlyJsMini): void => {
|
||||
// NOTE we cannot actually use the onlyJsMnemonic flag here
|
||||
const mnemonic = mnemonicGenerate(12);
|
||||
describe(mnemonic, (): void => {
|
||||
// do iterations to check and re-check that all matches
|
||||
for (const count of arrayRange(NUM_CHECKS)) {
|
||||
it(`check=${count + 1}`, (): void => {
|
||||
const minisecret = mnemonicToMiniSecret(mnemonic, count ? `${count}` : '', onlyJsMnemonic);
|
||||
const edpub = ed25519PairFromSeed(minisecret).publicKey;
|
||||
const srpub = sr25519PairFromSeed(minisecret).publicKey;
|
||||
const testmini = mnemonicToMiniSecret(mnemonic, count ? `${count}` : '', onlyJsMini);
|
||||
|
||||
describe(mnemonic, (): void => {
|
||||
// do iterations to check and re-check that all matches
|
||||
it.concurrent.each(arrayRange(NUM_CHECKS))('check=%p', (count): void => {
|
||||
const minisecret = mnemonicToMiniSecret(mnemonic, count ? `${count}` : '', onlyJsMnemonic);
|
||||
const edpub = ed25519PairFromSeed(minisecret).publicKey;
|
||||
const srpub = sr25519PairFromSeed(minisecret).publicKey;
|
||||
// explicit minisecret compare
|
||||
expect(
|
||||
u8aEq(minisecret, testmini)
|
||||
).toEqual(true);
|
||||
|
||||
const testmini = mnemonicToMiniSecret(mnemonic, count ? `${count}` : '', onlyJsMini);
|
||||
// compare the sr25519 keypair generated
|
||||
expect(
|
||||
u8aEq(srpub, sr25519PairFromSeed(testmini).publicKey)
|
||||
).toEqual(true);
|
||||
|
||||
// explicit minisecret compare
|
||||
expect(
|
||||
u8aEq(minisecret, testmini)
|
||||
).toEqual(true);
|
||||
|
||||
// compare the sr25519 keypair generated
|
||||
expect(
|
||||
u8aEq(srpub, sr25519PairFromSeed(testmini).publicKey)
|
||||
).toEqual(true);
|
||||
|
||||
// compare ed both in WASM and JS
|
||||
[true, false].forEach((onlyJsEd): void => {
|
||||
expect(
|
||||
u8aEq(edpub, ed25519PairFromSeed(testmini, onlyJsEd).publicKey)
|
||||
).toEqual(true);
|
||||
// compare ed both in WASM and JS
|
||||
[true, false].forEach((onlyJsEd): void => {
|
||||
expect(
|
||||
u8aEq(edpub, ed25519PairFromSeed(testmini, onlyJsEd).publicKey)
|
||||
).toEqual(true);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,29 +1,28 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { cryptoWaitReady } from '..';
|
||||
import { mnemonicValidate } from './validate';
|
||||
|
||||
await cryptoWaitReady();
|
||||
|
||||
describe('mnemonicValidate', (): void => {
|
||||
beforeEach(async (): Promise<void> => {
|
||||
await cryptoWaitReady();
|
||||
});
|
||||
for (const onlyJs of [undefined, true]) {
|
||||
describe(`onlyJs=${(onlyJs && 'true') || 'false'}`, (): void => {
|
||||
it('returns true on valid', (): void => {
|
||||
expect(
|
||||
mnemonicValidate('seed sock milk update focus rotate barely fade car face mechanic mercy', onlyJs)
|
||||
).toEqual(true);
|
||||
});
|
||||
|
||||
it('returns true on valid', (): void => {
|
||||
expect(
|
||||
mnemonicValidate('seed sock milk update focus rotate barely fade car face mechanic mercy')
|
||||
).toEqual(true);
|
||||
expect(
|
||||
mnemonicValidate('seed sock milk update focus rotate barely fade car face mechanic mercy', true)
|
||||
).toEqual(true);
|
||||
});
|
||||
|
||||
it('returns false on invalid', (): void => {
|
||||
expect(
|
||||
mnemonicValidate('wine photo extra cushion basket dwarf humor cloud truck job boat submit')
|
||||
).toEqual(false);
|
||||
expect(
|
||||
mnemonicValidate('wine photo extra cushion basket dwarf humor cloud truck job boat submit', true)
|
||||
).toEqual(false);
|
||||
});
|
||||
it('returns false on invalid', (): void => {
|
||||
expect(
|
||||
mnemonicValidate('wine photo extra cushion basket dwarf humor cloud truck job boat submit', onlyJs)
|
||||
).toEqual(false);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { naclBoxPairFromSecret } from '..';
|
||||
|
||||
describe('naclBoxPairFromSecret', (): void => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { naclDecrypt, naclEncrypt } from '.';
|
||||
|
||||
describe('naclDecrypt', (): void => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { naclEncrypt } from '.';
|
||||
|
||||
describe('naclEncrypt', (): void => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { ed25519PairFromString } from '../ed25519';
|
||||
import { keyExtractPath } from '../key';
|
||||
import { keyFromPath } from '../key/fromPath';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { ed25519PairFromString } from '../ed25519';
|
||||
import { naclBoxPairFromSecret, naclSeal } from '.';
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user