Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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,7 +8,7 @@ jobs:
|
||||
merge:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: jacogr/action-merge@3b4b49af8a8644bf5cbb5409ee236abe04eeb1b0
|
||||
- uses: jacogr/action-merge@d2d64b4545acd93b0a9575177d3d215ae3f92029
|
||||
with:
|
||||
checks: build,lint,test
|
||||
labels: -auto
|
||||
|
||||
@@ -12,7 +12,10 @@ jobs:
|
||||
YARN_ENABLE_SCRIPTS: false
|
||||
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
||||
steps:
|
||||
- uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
- uses: denoland/setup-deno@004814556e37c54a2f6e31384c9e18e983317366
|
||||
with:
|
||||
deno-version: vx.x.x
|
||||
|
||||
@@ -19,10 +19,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,76 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 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)
|
||||
1539 Jaco 10.4.2 (#1741)
|
||||
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)
|
||||
|
||||
+8
-7
@@ -11,10 +11,10 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "10.2.2",
|
||||
"version": "10.4.2",
|
||||
"versions": {
|
||||
"git": "10.2.2",
|
||||
"npm": "10.2.2"
|
||||
"git": "10.4.2",
|
||||
"npm": "10.4.2"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
@@ -28,16 +28,17 @@
|
||||
"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": "NODE_OPTIONS=--experimental-vm-modules polkadot-dev-run-test --coverage --runInBand --testPathIgnorePatterns toMiniSecretCmp",
|
||||
"test:mnemonicCmp": "polkadot-dev-run-test packages/util-crypto/src/mnemonic/toMiniSecretCmp.spec.ts",
|
||||
"test:node": "polkadot-dev-run-node-test --browser ^toMiniSecretCmp",
|
||||
"test:one": "polkadot-dev-run-test --runInBand"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.20.12",
|
||||
"@polkadot/dev": "^0.67.177",
|
||||
"@types/jest": "^29.2.5"
|
||||
"@polkadot/dev": "^0.68.37",
|
||||
"@types/jest": "^29.4.0"
|
||||
},
|
||||
"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": "10.4.2",
|
||||
"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"
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@ledgerhq/hw-transport": "^6.28.1",
|
||||
"@ledgerhq/hw-transport-webhid": "^6.27.12",
|
||||
"@ledgerhq/hw-transport-webusb": "^6.27.12",
|
||||
"@polkadot/util": "10.4.2"
|
||||
},
|
||||
"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: '10.4.2' };
|
||||
|
||||
@@ -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": "10.4.2",
|
||||
"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"
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@ledgerhq/hw-transport": "^6.28.1",
|
||||
"@polkadot/hw-ledger-transports": "10.4.2",
|
||||
"@polkadot/util": "10.4.2",
|
||||
"@zondax/ledger-substrate": "^0.40.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { supportedApps } from '@zondax/ledger-substrate';
|
||||
import { ledgerApps } from './defaults';
|
||||
|
||||
describe('ledgerApps', (): void => {
|
||||
it.each(Object.keys(ledgerApps))('%s is known', (k): void => {
|
||||
it.each(Object.keys(ledgerApps))('%s is available in @zondax/ledger-substrate', (k): void => {
|
||||
expect(
|
||||
supportedApps.find(({ name }) =>
|
||||
name === ledgerApps[k]
|
||||
|
||||
@@ -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: '10.4.2' };
|
||||
|
||||
@@ -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": "10.4.2",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.7",
|
||||
"@polkadot/util": "10.2.2",
|
||||
"@polkadot/util-crypto": "10.2.2"
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@polkadot/util": "10.4.2",
|
||||
"@polkadot/util-crypto": "10.4.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "10.2.2",
|
||||
"@polkadot/util-crypto": "10.2.2"
|
||||
"@polkadot/util": "10.4.2",
|
||||
"@polkadot/util-crypto": "10.4.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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: '10.4.2' };
|
||||
|
||||
@@ -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": "10.4.2",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.7",
|
||||
"@polkadot/util": "10.2.2",
|
||||
"@substrate/ss58-registry": "^1.36.0"
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@polkadot/util": "10.4.2",
|
||||
"@substrate/ss58-registry": "^1.38.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/hw-ledger": "10.2.2"
|
||||
"@polkadot/hw-ledger": "10.4.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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: '10.4.2' };
|
||||
|
||||
@@ -5,7 +5,7 @@ import known from '@substrate/ss58-registry';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import other from './test/ss58registry.test.json';
|
||||
import other from './test/ss58registry.test.json' assert { type: 'json' };
|
||||
|
||||
describe('@substrate/ss58-registry', (): void => {
|
||||
it('has known values', (): void => {
|
||||
|
||||
@@ -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",
|
||||
@@ -1363,19 +1376,6 @@
|
||||
"standardAccount": "*25519",
|
||||
"website": "https://chainflip.io/"
|
||||
},
|
||||
{
|
||||
"prefix": 2114,
|
||||
"network": "Turing",
|
||||
"displayName": "Turing Network",
|
||||
"symbols": [
|
||||
"TUR"
|
||||
],
|
||||
"decimals": [
|
||||
10
|
||||
],
|
||||
"standardAccount": "*25519",
|
||||
"website": "https://oak.tech/turing/home/"
|
||||
},
|
||||
{
|
||||
"prefix": 2207,
|
||||
"network": "SNOW",
|
||||
@@ -1639,5 +1639,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,21 +22,21 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "10.2.2",
|
||||
"version": "10.4.2",
|
||||
"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",
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@noble/hashes": "1.2.0",
|
||||
"@noble/secp256k1": "1.7.1",
|
||||
"@polkadot/networks": "10.4.2",
|
||||
"@polkadot/util": "10.4.2",
|
||||
"@polkadot/wasm-crypto": "^6.4.1",
|
||||
"@polkadot/x-bigint": "10.2.2",
|
||||
"@polkadot/x-randomvalues": "10.2.2",
|
||||
"@polkadot/x-bigint": "10.4.2",
|
||||
"@polkadot/x-randomvalues": "10.4.2",
|
||||
"@scure/base": "1.1.1",
|
||||
"ed2curve": "^0.3.0",
|
||||
"tweetnacl": "^1.0.3"
|
||||
@@ -45,6 +45,6 @@
|
||||
"@types/ed2curve": "^0.2.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "10.2.2"
|
||||
"@polkadot/util": "10.4.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
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 => {
|
||||
@@ -61,7 +61,7 @@ describe('blake2AsU8a', (): void => {
|
||||
});
|
||||
|
||||
describe.each([256, 512] as (256 | 512)[])('bitLength=$p', (bitLength): void => {
|
||||
performanceWasm(`blake2AsU8a, bitLength=${bitLength}`, 64000, (input, onlyJs) =>
|
||||
perfWasm(`blake2AsU8a, bitLength=${bitLength}`, 64000, (input, onlyJs) =>
|
||||
blake2AsU8a(input, bitLength, null, onlyJs)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
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(
|
||||
@@ -30,7 +30,7 @@ describe('ed25519Sign', (): void => {
|
||||
});
|
||||
});
|
||||
|
||||
performanceWasm('ed25519Sign', 250, (input, onlyJs) =>
|
||||
perfWasm('ed25519Sign', 250, (input, onlyJs) =>
|
||||
ed25519Sign(input, PAIR, onlyJs)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
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 => {
|
||||
@@ -32,7 +32,7 @@ describe('hmacShaAsU8a', (): void => {
|
||||
});
|
||||
});
|
||||
|
||||
performanceWasm(`hmacShaAsU8a, bitLength=${bitLength}`, 16000, (input, onlyJs) =>
|
||||
perfWasm(`hmacShaAsU8a, bitLength=${bitLength}`, 16000, (input, onlyJs) =>
|
||||
hmacShaAsU8a(input, input, bitLength, onlyJs)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
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 => {
|
||||
@@ -43,7 +43,7 @@ describe('keccakAsU8a', (): void => {
|
||||
});
|
||||
});
|
||||
|
||||
performanceWasm(`keccakAsU8a, bitLength=${bitLength}`, 128000, (input, onlyJs) =>
|
||||
perfWasm(`keccakAsU8a, bitLength=${bitLength}`, 128000, (input, onlyJs) =>
|
||||
keccakAsU8a(input, bitLength, onlyJs)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -14,24 +14,21 @@ const NUM_CHECKS = 5;
|
||||
|
||||
// generate either a JS or WASM mnemonic
|
||||
describe.each([true, false])('mnemonicToMiniSecret (compare), onlyJsMnemonic=%p', (onlyJsMnemonic): void => {
|
||||
beforeAll(async (): Promise<void> => {
|
||||
await cryptoWaitReady();
|
||||
});
|
||||
|
||||
// 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 => {
|
||||
describe.each([true, false])('onlyJsMini=%p', async (onlyJsMini): Promise<void> => {
|
||||
await cryptoWaitReady();
|
||||
|
||||
// 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
|
||||
it.concurrent.each(arrayRange(NUM_CHECKS))('check=%p', (count): void => {
|
||||
it.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;
|
||||
|
||||
const testmini = mnemonicToMiniSecret(mnemonic, count ? `${count}` : '', onlyJsMini);
|
||||
|
||||
// explicit minisecret compare
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/util-crypto', path: 'auto', type: 'auto', version: '10.2.2' };
|
||||
export const packageInfo = { name: '@polkadot/util-crypto', path: 'auto', type: 'auto', version: '10.4.2' };
|
||||
|
||||
@@ -5,7 +5,7 @@ import { u8aEq, u8aToHex } from '@polkadot/util';
|
||||
import { waitReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
import { randomAsU8a } from '../random/asU8a';
|
||||
import { performanceWasm } from '../test/performance';
|
||||
import { perfWasm } from '../test';
|
||||
import { pbkdf2Encode } from '.';
|
||||
|
||||
const KNOWN_SALT = new Uint8Array([
|
||||
@@ -42,7 +42,7 @@ describe('pbkdf2Encode', (): void => {
|
||||
});
|
||||
});
|
||||
|
||||
performanceWasm('pbkdf2Encode', 8, (input, onlyJs) =>
|
||||
perfWasm('pbkdf2Encode', 8, (input, onlyJs) =>
|
||||
pbkdf2Encode(input, input, undefined, onlyJs)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import { waitReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
import { performanceWasm } from '../test/performance';
|
||||
import { perfWasm } from '../test';
|
||||
import { DEFAULT_PARAMS } from './defaults';
|
||||
import { scryptEncode } from '.';
|
||||
|
||||
@@ -30,7 +30,7 @@ describe('scryptEncode', (): void => {
|
||||
});
|
||||
});
|
||||
|
||||
performanceWasm('scryptEncode', 4, (input, onlyJs) =>
|
||||
perfWasm('scryptEncode', 4, (input, onlyJs) =>
|
||||
scryptEncode(input, input, undefined, onlyJs)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { hexToU8a } from '@polkadot/util';
|
||||
import { waitReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
import { performanceWasm } from '../test/performance';
|
||||
import { perfWasm } from '../test';
|
||||
import { secp256k1Compress } from '.';
|
||||
|
||||
describe('secp256k1Compress', (): void => {
|
||||
@@ -36,7 +36,7 @@ describe('secp256k1Compress', (): void => {
|
||||
});
|
||||
});
|
||||
|
||||
performanceWasm('secp256k1Compress', 100000, (input, onlyJs) => secp256k1Compress(input, onlyJs),
|
||||
perfWasm('secp256k1Compress', 100000, (input, onlyJs) => secp256k1Compress(input, onlyJs),
|
||||
[[
|
||||
hexToU8a('0x04b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb1307763fe926c273235fd979a134076d00fd1683cbd35868cb485d4a3a640e52184af')
|
||||
]]
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { hexToU8a } from '@polkadot/util';
|
||||
import { waitReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
import { performanceWasm } from '../test/performance';
|
||||
import { perfWasm } from '../test';
|
||||
import { secp256k1Expand } from '.';
|
||||
|
||||
describe('secp256k1Expand', (): void => {
|
||||
@@ -36,7 +36,7 @@ describe('secp256k1Expand', (): void => {
|
||||
});
|
||||
});
|
||||
|
||||
performanceWasm('secp256k1Expand', 2000, (input, onlyJs) => secp256k1Expand(input, onlyJs),
|
||||
perfWasm('secp256k1Expand', 2000, (input, onlyJs) => secp256k1Expand(input, onlyJs),
|
||||
[[
|
||||
hexToU8a('0x03b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb13077')
|
||||
]]
|
||||
|
||||
@@ -5,7 +5,7 @@ import { hexToU8a, u8aToHex } from '@polkadot/util';
|
||||
import { waitReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
import { mnemonicToMiniSecret } from '../../mnemonic';
|
||||
import { performanceWasm } from '../../test/performance';
|
||||
import { perfWasm } from '../../test';
|
||||
import { secp256k1PairFromSeed } from '..';
|
||||
|
||||
// mnemonic, secret, public, account_id
|
||||
@@ -65,7 +65,7 @@ describe('secp256k1PairFromSeed', (): void => {
|
||||
});
|
||||
});
|
||||
|
||||
performanceWasm('secp256k1PairFromSeed', 500, (input, onlyJs) =>
|
||||
perfWasm('secp256k1PairFromSeed', 500, (input, onlyJs) =>
|
||||
secp256k1PairFromSeed(input, onlyJs)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -5,7 +5,7 @@ import { u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
import { waitReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
import { keccakAsU8a } from '../keccak';
|
||||
import { performanceWasm } from '../test/performance';
|
||||
import { perfWasm } from '../test';
|
||||
import { secp256k1Recover } from '.';
|
||||
|
||||
const sig = u8aToU8a('0x7505f2880114da51b3f5d535f8687953c0ab9af4ab81e592eaebebf53b728d2b6dfd9b5bcd70fee412b1f31360e7c2774009305cb84fc50c1d0ff8034dfa5fff');
|
||||
@@ -25,7 +25,7 @@ describe('secp256k1Recover', (): void => {
|
||||
});
|
||||
});
|
||||
|
||||
performanceWasm('secp256k1Recover', 200, (_, onlyJs) =>
|
||||
perfWasm('secp256k1Recover', 200, (_, onlyJs) =>
|
||||
secp256k1Recover(msg, sig, 0, undefined, onlyJs)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { hexToU8a } from '@polkadot/util';
|
||||
import { waitReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
import { performanceWasm } from '../test/performance';
|
||||
import { perfWasm } from '../test';
|
||||
import { secp256k1PairFromSeed, secp256k1Sign } from '.';
|
||||
|
||||
const pair = secp256k1PairFromSeed(hexToU8a('0x4380de832af797688026ce24f85204d508243f201650c1a134929e5458b7fbae'));
|
||||
@@ -29,7 +29,7 @@ describe('sign', (): void => {
|
||||
|
||||
// since the libsecp256k1 signatures don't match (but can be verified), we
|
||||
// do both signing and verification here (checking the extracted key)
|
||||
performanceWasm('secp256k1Sign', 1000, (_, onlyJs) =>
|
||||
perfWasm('secp256k1Sign', 1000, (_, onlyJs) =>
|
||||
secp256k1Sign(msg, pair, undefined, onlyJs)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -6,7 +6,7 @@ import '../bundleInit';
|
||||
import { hexToU8a } from '@polkadot/util';
|
||||
import { waitReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
import { performanceWasm } from '../test/performance';
|
||||
import { perfWasm } from '../test';
|
||||
import { hasher } from './hasher';
|
||||
import { secp256k1PairFromSeed, secp256k1Verify } from '.';
|
||||
|
||||
@@ -63,7 +63,7 @@ describe('secp256k1Verify', (): void => {
|
||||
});
|
||||
});
|
||||
|
||||
performanceWasm('secp256k1Verify', 100, (_, onlyJs) =>
|
||||
perfWasm('secp256k1Verify', 100, (_, onlyJs) =>
|
||||
secp256k1Verify(
|
||||
`\x19Ethereum Signed Message:\n${message.length.toString()}${message}`,
|
||||
'0x55bd020bdbbdc02de34e915effc9b18a99002f4c29f64e22e8dcbb69e722ea6c28e1bb53b9484063fbbfd205e49dcc1f620929f520c9c4c3695150f05a28f52a01',
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { hexToU8a } from '@polkadot/util';
|
||||
import { waitReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
import { performanceWasm } from '../test/performance';
|
||||
import { perfWasm } from '../test';
|
||||
import { sha256AsU8a } from '.';
|
||||
|
||||
const TESTS = [
|
||||
@@ -43,7 +43,7 @@ describe('sha256AsU8a', (): void => {
|
||||
});
|
||||
});
|
||||
|
||||
performanceWasm('sha256AsU8a', 128000, (input, onlyJs) =>
|
||||
perfWasm('sha256AsU8a', 128000, (input, onlyJs) =>
|
||||
sha256AsU8a(input, onlyJs)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import { waitReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
import { performanceWasm } from '../test/performance';
|
||||
import { perfWasm } from '../test';
|
||||
import { sha512AsU8a } from '.';
|
||||
|
||||
describe('sha512AsU8a', (): void => {
|
||||
@@ -23,7 +23,7 @@ describe('sha512AsU8a', (): void => {
|
||||
});
|
||||
});
|
||||
|
||||
performanceWasm('sha512AsU8a', 64000, (input, onlyJs) =>
|
||||
perfWasm('sha512AsU8a', 64000, (input, onlyJs) =>
|
||||
sha512AsU8a(input, onlyJs)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { perf, perfCmp } from '@polkadot/util/test';
|
||||
|
||||
export { perfWasm } from './performance';
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { arrayRange } from '@polkadot/util';
|
||||
import { perf, perfCmp } from '@polkadot/util/test/performance';
|
||||
import { perf, perfCmp } from '@polkadot/util/test';
|
||||
|
||||
import { randomAsU8a } from '..';
|
||||
|
||||
@@ -10,7 +10,7 @@ type ExecFn = (input: Uint8Array, onlyJs: boolean) => unknown;
|
||||
|
||||
const GENERATED = arrayRange(256).map(() => [randomAsU8a()]);
|
||||
|
||||
export function performanceWasm (name: string, count: number, exec: ExecFn, inputs = GENERATED): void {
|
||||
export function perfWasm (name: string, count: number, exec: ExecFn, inputs = GENERATED): void {
|
||||
perfCmp(name, ['WebAssembly', 'JavaScript'], count, inputs, exec);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { hexToU8a } from '@polkadot/util';
|
||||
import { waitReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
import { performanceWasm } from '../test/performance';
|
||||
import { perfWasm } from '../test';
|
||||
import { xxhashAsU8a } from '.';
|
||||
|
||||
describe('xxhashAsU8a', (): void => {
|
||||
@@ -38,7 +38,7 @@ describe('xxhashAsU8a', (): void => {
|
||||
});
|
||||
});
|
||||
|
||||
performanceWasm('xxhashAsU8a', 8000, (input, onlyJs) =>
|
||||
perfWasm('xxhashAsU8a', 8000, (input, onlyJs) =>
|
||||
xxhashAsU8a(input, 128, onlyJs)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -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.
|
||||
+21
-21
@@ -6,20 +6,6 @@
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
"exports": {
|
||||
"./hex/toU8a": {
|
||||
"node": {
|
||||
"require": "./cjs/hex/toU8aBuffer.js",
|
||||
"default": "./hex/toU8aBuffer.js"
|
||||
}
|
||||
},
|
||||
"./u8a/toHex": {
|
||||
"node": {
|
||||
"require": "./cjs/u8a/toHexBuffer.js",
|
||||
"default": "./u8a/toHexBuffer.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/util#readme",
|
||||
"license": "Apache-2.0",
|
||||
"maintainers": [],
|
||||
@@ -34,18 +20,32 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "10.2.2",
|
||||
"version": "10.4.2",
|
||||
"main": "index.js",
|
||||
"exports": {
|
||||
"./hex/toU8a": {
|
||||
"node": {
|
||||
"require": "./cjs/hex/toU8aBuffer.js",
|
||||
"default": "./hex/toU8aBuffer.js"
|
||||
}
|
||||
},
|
||||
"./u8a/toHex": {
|
||||
"node": {
|
||||
"require": "./cjs/u8a/toHexBuffer.js",
|
||||
"default": "./u8a/toHexBuffer.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.7",
|
||||
"@polkadot/x-bigint": "10.2.2",
|
||||
"@polkadot/x-global": "10.2.2",
|
||||
"@polkadot/x-textdecoder": "10.2.2",
|
||||
"@polkadot/x-textencoder": "10.2.2",
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@polkadot/x-bigint": "10.4.2",
|
||||
"@polkadot/x-global": "10.4.2",
|
||||
"@polkadot/x-textdecoder": "10.4.2",
|
||||
"@polkadot/x-textencoder": "10.4.2",
|
||||
"@types/bn.js": "^5.1.1",
|
||||
"bn.js": "^5.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/x-randomvalues": "10.2.2"
|
||||
"@polkadot/x-randomvalues": "10.4.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,27 @@
|
||||
// Copyright 2017-2023 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { perf } from '../test/performance';
|
||||
import { perf } from '../test';
|
||||
import { arrayChunk, arrayRange } from '.';
|
||||
|
||||
describe('arrayChunk', (): void => {
|
||||
it('chunks arrays', (): void => {
|
||||
it('chunks with exact', (): void => {
|
||||
expect(
|
||||
arrayChunk([1, 2, 3, 4, 5, 6, 7, 8], 8)
|
||||
).toEqual([[1, 2, 3, 4, 5, 6, 7, 8]]);
|
||||
});
|
||||
|
||||
it('chunks with unequal', (): void => {
|
||||
expect(
|
||||
arrayChunk([1, 2, 3, 4, 5, 6, 7], 3)
|
||||
).toEqual([[1, 2, 3], [4, 5, 6], [7]]);
|
||||
});
|
||||
|
||||
it('chunks with non-empty results', (): void => {
|
||||
expect(
|
||||
arrayChunk([[1, 2], [3, 4], [5, 6], [7, 8]], 2)
|
||||
).toEqual([[[1, 2], [3, 4]], [[5, 6], [7, 8]]]);
|
||||
});
|
||||
|
||||
perf('arrayChunk', 200_000, [[arrayRange(500), 50]], arrayChunk);
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2023 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { perf } from '../test/performance';
|
||||
import { perf } from '../test';
|
||||
import { arrayFlatten } from '.';
|
||||
|
||||
const PERF_ONE = [[1, 2, 3, 4, 5]];
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2023 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { perf } from '../test/performance';
|
||||
import { perf } from '../test';
|
||||
import { arrayRange, arrayShuffle } from '.';
|
||||
|
||||
const ptest = arrayRange(16284);
|
||||
|
||||
@@ -7,29 +7,95 @@ import { BigInt } from '@polkadot/x-bigint';
|
||||
* @name _0n
|
||||
* @summary BigInt constant for 0.
|
||||
*/
|
||||
export const _0n = BigInt(0);
|
||||
export const _0n = /*#__PURE__*/ BigInt(0);
|
||||
|
||||
/**
|
||||
* @name _1n
|
||||
* @summary BigInt constant for 1.
|
||||
*/
|
||||
export const _1n = BigInt(1);
|
||||
export const _1n = /*#__PURE__*/ BigInt(1);
|
||||
|
||||
/**
|
||||
* @name _2n
|
||||
* @summary BigInt constant for 2.
|
||||
*/
|
||||
export const _2n = /*#__PURE__*/ BigInt(2);
|
||||
|
||||
/**
|
||||
* @name _3n
|
||||
* @summary BigInt constant for 3.
|
||||
*/
|
||||
export const _3n = /*#__PURE__*/ BigInt(3);
|
||||
|
||||
/**
|
||||
* @name _4n
|
||||
* @summary BigInt constant for 4.
|
||||
*/
|
||||
export const _4n = /*#__PURE__*/ BigInt(4);
|
||||
|
||||
/**
|
||||
* @name _5n
|
||||
* @summary BigInt constant for 5.
|
||||
*/
|
||||
export const _5n = /*#__PURE__*/ BigInt(5);
|
||||
|
||||
/**
|
||||
* @name _6n
|
||||
* @summary BigInt constant for 6.
|
||||
*/
|
||||
export const _6n = /*#__PURE__*/ BigInt(6);
|
||||
|
||||
/**
|
||||
* @name _7n
|
||||
* @summary BigInt constant for 7.
|
||||
*/
|
||||
export const _7n = /*#__PURE__*/ BigInt(7);
|
||||
|
||||
/**
|
||||
* @name _8n
|
||||
* @summary BigInt constant for 8.
|
||||
*/
|
||||
export const _8n = /*#__PURE__*/ BigInt(8);
|
||||
|
||||
/**
|
||||
* @name _9n
|
||||
* @summary BigInt constant for 9.
|
||||
*/
|
||||
export const _9n = /*#__PURE__*/ BigInt(9);
|
||||
|
||||
/**
|
||||
* @name _10n
|
||||
* @summary BigInt constant for 10.
|
||||
*/
|
||||
export const _10n = /*#__PURE__*/ BigInt(10);
|
||||
|
||||
/**
|
||||
* @name _100n
|
||||
* @summary BigInt constant for 100.
|
||||
*/
|
||||
export const _100n = /*#__PURE__*/ BigInt(100);
|
||||
|
||||
/**
|
||||
* @name _1000n
|
||||
* @summary BigInt constant for 1000.
|
||||
*/
|
||||
export const _1000n = /*#__PURE__*/ BigInt(1_000);
|
||||
|
||||
/**
|
||||
* @name _1Mn
|
||||
* @summary BigInt constant for 1,000,000.
|
||||
* @summary BigInt constant for 1,000,000 (million).
|
||||
*/
|
||||
export const _1Mn = BigInt(1_000_000);
|
||||
export const _1Mn = /*#__PURE__*/ BigInt(1_000_000);
|
||||
|
||||
/**
|
||||
* @name _1Bn
|
||||
* @summary BigInt constant for 1,000,000,000.
|
||||
* @summary BigInt constant for 1,000,000,000 (billion).
|
||||
*/
|
||||
export const _1Bn = BigInt(1_000_000_000);
|
||||
export const _1Bn = /*#__PURE__*/ BigInt(1_000_000_000);
|
||||
|
||||
/**
|
||||
* @name _1Qn
|
||||
* @summary BigInt constant for 1,000,000,000,000,000,000.
|
||||
* @summary BigInt constant for 1,000,000,000,000,000,000 (quitillion).
|
||||
*/
|
||||
export const _1Qn = _1Bn * _1Bn;
|
||||
|
||||
@@ -37,4 +103,10 @@ export const _1Qn = _1Bn * _1Bn;
|
||||
* @name _2pow53n
|
||||
* @summary BigInt constant for MAX_SAFE_INTEGER
|
||||
*/
|
||||
export const _2pow53n = BigInt(Number.MAX_SAFE_INTEGER);
|
||||
export const _2pow53n = /*#__PURE__*/ BigInt(Number.MAX_SAFE_INTEGER);
|
||||
|
||||
/**
|
||||
* @name _sqrt2pow53n
|
||||
* @summary BigInt constant for Math.sqrt(MAX_SAFE_INTEGER)
|
||||
*/
|
||||
export const _sqrt2pow53n = /*#__PURE__*/ BigInt(94906265);
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { BN } from '../bn';
|
||||
import { SQRT_MAX_SAFE_INTEGER } from './sqrt';
|
||||
import { nSqrt } from '.';
|
||||
import { _sqrt2pow53n, nSqrt } from '.';
|
||||
|
||||
export const SQRT_TESTS: [string | number | BN | bigint, string | number][] = [
|
||||
[0, 0],
|
||||
@@ -41,7 +40,7 @@ describe('nSqrt', (): void => {
|
||||
~~Math.sqrt(
|
||||
Number.MAX_SAFE_INTEGER
|
||||
)
|
||||
) === SQRT_MAX_SAFE_INTEGER
|
||||
) === _sqrt2pow53n
|
||||
).toEqual(true);
|
||||
});
|
||||
|
||||
|
||||
@@ -6,12 +6,9 @@ import type { ToBigInt, ToBn } from '../types';
|
||||
|
||||
import { BigInt } from '@polkadot/x-bigint';
|
||||
|
||||
import { _0n, _1n, _2pow53n } from './consts';
|
||||
import { _0n, _1n, _2pow53n, _sqrt2pow53n } from './consts';
|
||||
import { nToBigInt } from './toBigInt';
|
||||
|
||||
/** @internal */
|
||||
export const SQRT_MAX_SAFE_INTEGER = BigInt(94906265);
|
||||
|
||||
/**
|
||||
* @name nSqrt
|
||||
* @summary Calculates the integer square root of a bigint
|
||||
@@ -32,7 +29,7 @@ export function nSqrt <ExtToBn extends ToBn | ToBigInt> (value: ExtToBn | BN | b
|
||||
|
||||
// Use sqrt(MAX_SAFE_INTEGER) as starting point. since we already know the
|
||||
// output will be larger than this, we expect this to be a safe start
|
||||
let x0 = SQRT_MAX_SAFE_INTEGER;
|
||||
let x0 = _sqrt2pow53n;
|
||||
|
||||
while (true) {
|
||||
const x1 = ((n / x0) + x0) >> _1n;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { arrayRange } from '../array';
|
||||
import { perf } from '../test/performance';
|
||||
import { perf } from '../test';
|
||||
import { nToU8a } from '.';
|
||||
|
||||
const ptest = arrayRange(65536).map((v) => [v]);
|
||||
|
||||
@@ -7,91 +7,91 @@ import { BN } from './bn';
|
||||
* @name BN_ZERO
|
||||
* @summary BN constant for 0.
|
||||
*/
|
||||
export const BN_ZERO: BN = new BN(0);
|
||||
export const BN_ZERO: BN = /*#__PURE__*/ new BN(0);
|
||||
|
||||
/**
|
||||
* @name BN_ONE
|
||||
* @summary BN constant for 1.
|
||||
*/
|
||||
export const BN_ONE: BN = new BN(1);
|
||||
export const BN_ONE: BN = /*#__PURE__*/ new BN(1);
|
||||
|
||||
/**
|
||||
* @name BN_TWO
|
||||
* @summary BN constant for 2.
|
||||
*/
|
||||
export const BN_TWO: BN = new BN(2);
|
||||
export const BN_TWO: BN = /*#__PURE__*/ new BN(2);
|
||||
|
||||
/**
|
||||
* @name BN_THREE
|
||||
* @summary BN constant for 3.
|
||||
*/
|
||||
export const BN_THREE: BN = new BN(3);
|
||||
export const BN_THREE: BN = /*#__PURE__*/ new BN(3);
|
||||
|
||||
/**
|
||||
* @name BN_FOUR
|
||||
* @summary BN constant for 4.
|
||||
*/
|
||||
export const BN_FOUR: BN = new BN(4);
|
||||
export const BN_FOUR: BN = /*#__PURE__*/ new BN(4);
|
||||
|
||||
/**
|
||||
* @name BN_FIVE
|
||||
* @summary BN constant for 5.
|
||||
*/
|
||||
export const BN_FIVE: BN = new BN(5);
|
||||
export const BN_FIVE: BN = /*#__PURE__*/ new BN(5);
|
||||
|
||||
/**
|
||||
* @name BN_SIX
|
||||
* @summary BN constant for 6.
|
||||
*/
|
||||
export const BN_SIX: BN = new BN(6);
|
||||
export const BN_SIX: BN = /*#__PURE__*/ new BN(6);
|
||||
|
||||
/**
|
||||
* @name BN_SEVEN
|
||||
* @summary BN constant for 7.
|
||||
*/
|
||||
export const BN_SEVEN: BN = new BN(7);
|
||||
export const BN_SEVEN: BN = /*#__PURE__*/ new BN(7);
|
||||
|
||||
/**
|
||||
* @name BN_EIGHT
|
||||
* @summary BN constant for 8.
|
||||
*/
|
||||
export const BN_EIGHT: BN = new BN(8);
|
||||
export const BN_EIGHT: BN = /*#__PURE__*/ new BN(8);
|
||||
|
||||
/**
|
||||
* @name BN_NINE
|
||||
* @summary BN constant for 9.
|
||||
*/
|
||||
export const BN_NINE: BN = new BN(9);
|
||||
export const BN_NINE: BN = /*#__PURE__*/ new BN(9);
|
||||
|
||||
/**
|
||||
* @name BN_TEN
|
||||
* @summary BN constant for 10.
|
||||
*/
|
||||
export const BN_TEN: BN = new BN(10);
|
||||
export const BN_TEN: BN = /*#__PURE__*/ new BN(10);
|
||||
|
||||
/**
|
||||
* @name BN_HUNDRED
|
||||
* @summary BN constant for 100.
|
||||
*/
|
||||
export const BN_HUNDRED: BN = new BN(100);
|
||||
export const BN_HUNDRED: BN = /*#__PURE__*/ new BN(100);
|
||||
|
||||
/**
|
||||
* @name BN_THOUSAND
|
||||
* @summary BN constant for 1,000.
|
||||
*/
|
||||
export const BN_THOUSAND: BN = new BN(1_000);
|
||||
export const BN_THOUSAND: BN = /*#__PURE__*/ new BN(1_000);
|
||||
|
||||
/**
|
||||
* @name BN_MILLION
|
||||
* @summary BN constant for 1,000,000.
|
||||
*/
|
||||
export const BN_MILLION: BN = new BN(1_000_000);
|
||||
export const BN_MILLION: BN = /*#__PURE__*/ new BN(1_000_000);
|
||||
|
||||
/**
|
||||
* @name BN_BILLION
|
||||
* @summary BN constant for 1,000,000,000.
|
||||
*/
|
||||
export const BN_BILLION: BN = new BN(1_000_000_000);
|
||||
export const BN_BILLION: BN = /*#__PURE__*/ new BN(1_000_000_000);
|
||||
|
||||
/**
|
||||
* @name BN_QUINTILL
|
||||
@@ -103,4 +103,10 @@ export const BN_QUINTILL: BN = BN_BILLION.mul(BN_BILLION);
|
||||
* @name BN_MAX_INTEGER
|
||||
* @summary BN constant for MAX_SAFE_INTEGER
|
||||
*/
|
||||
export const BN_MAX_INTEGER: BN = new BN(Number.MAX_SAFE_INTEGER);
|
||||
export const BN_MAX_INTEGER: BN = /*#__PURE__*/ new BN(Number.MAX_SAFE_INTEGER);
|
||||
|
||||
/**
|
||||
* @name BN_SQRT_MAX_INTEGER
|
||||
* @summary BN constant for Math.sqrt(MAX_SAFE_INTEGER)
|
||||
*/
|
||||
export const BN_SQRT_MAX_INTEGER: BN = /*#__PURE__*/ new BN(94906265);
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { SQRT_TESTS } from '../bi/sqrt.spec';
|
||||
import { SQRT_MAX_SAFE_INTEGER } from './sqrt';
|
||||
import { BN, bnSqrt } from '.';
|
||||
import { BN, BN_SQRT_MAX_INTEGER, bnSqrt } from '.';
|
||||
|
||||
describe('bnSqrt', (): void => {
|
||||
it('fails on < 0 roots', (): void => {
|
||||
@@ -14,7 +13,7 @@ describe('bnSqrt', (): void => {
|
||||
|
||||
it('has the correct constant for sqrt(Number.MAX_SAFE_INTEGER)', (): void => {
|
||||
expect(
|
||||
SQRT_MAX_SAFE_INTEGER.eq(
|
||||
BN_SQRT_MAX_INTEGER.eq(
|
||||
new BN(
|
||||
~~Math.sqrt(
|
||||
Number.MAX_SAFE_INTEGER
|
||||
|
||||
@@ -4,12 +4,9 @@
|
||||
import type { ToBn } from '../types';
|
||||
|
||||
import { BN } from './bn';
|
||||
import { BN_MAX_INTEGER, BN_ONE } from './consts';
|
||||
import { BN_MAX_INTEGER, BN_ONE, BN_SQRT_MAX_INTEGER } from './consts';
|
||||
import { bnToBn } from './toBn';
|
||||
|
||||
/** @internal */
|
||||
export const SQRT_MAX_SAFE_INTEGER = new BN(94906265);
|
||||
|
||||
/**
|
||||
* @name bnSqrt
|
||||
* @summary Calculates the integer square root of a BN
|
||||
@@ -39,7 +36,7 @@ export function bnSqrt <ExtToBn extends ToBn> (value: ExtToBn | BN | bigint | st
|
||||
|
||||
// Use sqrt(MAX_SAFE_INTEGER) as starting point. since we already know the
|
||||
// output will be larger than this, we expect this to be a safe start
|
||||
let x0 = SQRT_MAX_SAFE_INTEGER.clone();
|
||||
let x0 = BN_SQRT_MAX_INTEGER.clone();
|
||||
|
||||
while (true) {
|
||||
const x1 = n.div(x0).iadd(x0).ishrn(1);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { arrayRange } from '../array';
|
||||
import { perf } from '../test/performance';
|
||||
import { perf } from '../test';
|
||||
import { BN, bnToU8a } from '.';
|
||||
|
||||
const ptest = arrayRange(65536).map((v) => [v]);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import { BN } from '../bn/bn';
|
||||
import { hexToU8a } from '../hex/toU8a';
|
||||
import { perf } from '../test/performance';
|
||||
import { perf } from '../test';
|
||||
import { compactFromU8a, compactFromU8aLim } from '.';
|
||||
|
||||
describe('compactFromU8a', (): void => {
|
||||
|
||||
@@ -4,15 +4,59 @@
|
||||
import { BN } from '../bn';
|
||||
import { formatBalance } from '.';
|
||||
|
||||
const FMT_DEFAULTS = {
|
||||
decimals: 0,
|
||||
unit: 'Unit'
|
||||
};
|
||||
|
||||
describe('formatBalance', (): void => {
|
||||
const TESTVAL = new BN('123456789000');
|
||||
|
||||
// We mess around with the global setDefaults inside some tests,
|
||||
// ensure we restore it to the defaults straight after each run
|
||||
afterEach((): void => {
|
||||
formatBalance.setDefaults(FMT_DEFAULTS);
|
||||
});
|
||||
|
||||
it('returns options for dropdown', (): void => {
|
||||
formatBalance.setDefaults({ decimals: 0, unit: 'TEST' });
|
||||
|
||||
expect(
|
||||
formatBalance.getOptions()
|
||||
).toEqual([
|
||||
{ power: 0, text: 'TEST', value: '-' },
|
||||
{ power: 3, text: 'Kilo', value: 'k' },
|
||||
{ power: 6, text: 'Mill', value: 'M' },
|
||||
{ power: 9, text: 'Bill', value: 'B' },
|
||||
{ power: 12, text: 'Tril', value: 'T' },
|
||||
{ power: 15, text: 'Peta', value: 'P' },
|
||||
{ power: 18, text: 'Exa', value: 'E' },
|
||||
{ power: 21, text: 'Zeta', value: 'Z' },
|
||||
{ power: 24, text: 'Yotta', value: 'Y' }
|
||||
]);
|
||||
});
|
||||
|
||||
it('can set defaults from array values', (): void => {
|
||||
formatBalance.setDefaults({ decimals: [12, 24], unit: ['Multi', 'Unit'] });
|
||||
|
||||
expect(
|
||||
formatBalance(TESTVAL)
|
||||
).toEqual('123.4567 mMulti');
|
||||
});
|
||||
|
||||
describe('SI formatting', (): void => {
|
||||
it('formats empty to 0', (): void => {
|
||||
expect(formatBalance()).toEqual('0');
|
||||
expect(formatBalance('0')).toEqual('0');
|
||||
});
|
||||
|
||||
// this is after an issue/test from actual values with forceUnit
|
||||
it('formats 1000 (BN) (decimals = 12, withAll, withZero = false)', (): void => {
|
||||
expect(
|
||||
formatBalance(new BN(1000), { decimals: 12, forceUnit: '-', withAll: true, withSi: false, withZero: true })
|
||||
).toEqual('0.000000001000');
|
||||
});
|
||||
|
||||
it('formats 123,456,789,000 (decimals=15)', (): void => {
|
||||
expect(
|
||||
formatBalance(TESTVAL, { decimals: 15, withSi: true })
|
||||
@@ -37,6 +81,24 @@ describe('formatBalance', (): void => {
|
||||
).toEqual('123.4567 µUnit');
|
||||
});
|
||||
|
||||
it('formats 123,456,789,000 (decimals=10, withAll=true)', (): void => {
|
||||
expect(
|
||||
formatBalance(TESTVAL, { decimals: 10, forceUnit: '-', withAll: true, withSi: true })
|
||||
).toEqual('12.3456789000 Unit');
|
||||
});
|
||||
|
||||
it('formats 123,456,789,000 (decimals=10, withAll=true, withZero=false)', (): void => {
|
||||
expect(
|
||||
formatBalance(TESTVAL, { decimals: 10, forceUnit: '-', withAll: true, withSi: true, withZero: false })
|
||||
).toEqual('12.3456789 Unit');
|
||||
});
|
||||
|
||||
it('formats 123,000,000,000 (decimals=9, withAll=true, withZero=false)', (): void => {
|
||||
expect(
|
||||
formatBalance('123000000000', { decimals: 9, forceUnit: '-', withAll: true, withSi: true, withZero: false })
|
||||
).toEqual('123 Unit');
|
||||
});
|
||||
|
||||
it('formats 123,456,789,000 (decimals=15, Compact)', (): void => {
|
||||
const compact = {
|
||||
something: 'else',
|
||||
@@ -159,11 +221,29 @@ describe('formatBalance', (): void => {
|
||||
).toEqual('12,345.6789 Unit');
|
||||
});
|
||||
|
||||
it('formats 123,456,789,000 (decimals=15, forceUnit=µ)', (): void => {
|
||||
it('formats 123,456,789,000 (decimals=15, forceUnit=micro)', (): void => {
|
||||
expect(
|
||||
formatBalance(TESTVAL, { decimals: 15, forceUnit: 'µ' })
|
||||
).toEqual('123.4567 µUnit');
|
||||
});
|
||||
|
||||
it('formats 123,456 (decimals=0, locale=sl)', (): void => {
|
||||
expect(
|
||||
formatBalance(123456, { decimals: 0, locale: 'sl', withSi: true })
|
||||
).toEqual('123,4560 kUnit');
|
||||
});
|
||||
|
||||
it('formats BigInt numbers (locale=sl)', (): void => {
|
||||
expect(
|
||||
formatBalance(123456789000n, { decimals: 15, locale: 'sl', withSi: true })
|
||||
).toEqual('123,4567 µUnit');
|
||||
});
|
||||
|
||||
it('formats 123,456,789,000 (decimals=7, forceUnit=base locale=sl)', (): void => {
|
||||
expect(
|
||||
formatBalance(TESTVAL, { decimals: 7, forceUnit: '-', locale: 'sl' })
|
||||
).toEqual('12.345,6789 Unit');
|
||||
});
|
||||
});
|
||||
|
||||
describe('calcSi', (): void => {
|
||||
@@ -190,10 +270,9 @@ describe('formatBalance', (): void => {
|
||||
|
||||
describe('defaults', (): void => {
|
||||
it('returns defaults', (): void => {
|
||||
expect(formatBalance.getDefaults()).toEqual({
|
||||
decimals: 0,
|
||||
unit: 'Unit'
|
||||
});
|
||||
expect(
|
||||
formatBalance.getDefaults()
|
||||
).toEqual(FMT_DEFAULTS);
|
||||
});
|
||||
|
||||
it('formats 123,456,789,000 (defaultDecimals=12)', (): void => {
|
||||
@@ -205,37 +284,11 @@ describe('formatBalance', (): void => {
|
||||
});
|
||||
|
||||
it('formats 123,456,789,000 (defaultUnit=TEST)', (): void => {
|
||||
formatBalance.setDefaults({ unit: 'TEST' });
|
||||
formatBalance.setDefaults({ decimals: 12, unit: 'TEST' });
|
||||
|
||||
expect(
|
||||
formatBalance(TESTVAL)
|
||||
).toEqual('123.4567 mTEST');
|
||||
});
|
||||
});
|
||||
|
||||
it('returns options for dropdown', (): void => {
|
||||
formatBalance.setDefaults({ decimals: 0, unit: 'TEST' });
|
||||
|
||||
expect(
|
||||
formatBalance.getOptions()
|
||||
).toEqual([
|
||||
{ power: 0, text: 'TEST', value: '-' },
|
||||
{ power: 3, text: 'Kilo', value: 'k' },
|
||||
{ power: 6, text: 'Mill', value: 'M' },
|
||||
{ power: 9, text: 'Bill', value: 'B' },
|
||||
{ power: 12, text: 'Tril', value: 'T' },
|
||||
{ power: 15, text: 'Peta', value: 'P' },
|
||||
{ power: 18, text: 'Exa', value: 'E' },
|
||||
{ power: 21, text: 'Zeta', value: 'Z' },
|
||||
{ power: 24, text: 'Yotta', value: 'Y' }
|
||||
]);
|
||||
});
|
||||
|
||||
it('can set defaults from array values', (): void => {
|
||||
formatBalance.setDefaults({ decimals: [12, 24], unit: ['Multi', 'Unit'] });
|
||||
|
||||
expect(
|
||||
formatBalance(TESTVAL)
|
||||
).toEqual('123.4567 mMulti');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,6 +7,7 @@ import type { SiDef, ToBn } from '../types';
|
||||
import { bnToBn } from '../bn/toBn';
|
||||
import { isBoolean } from '../is/boolean';
|
||||
import { formatDecimal } from './formatDecimal';
|
||||
import { getSeparator } from './getSeparator';
|
||||
import { calcSi, findSi, SI, SI_MID } from './si';
|
||||
|
||||
interface Defaults {
|
||||
@@ -29,7 +30,11 @@ interface Options {
|
||||
*/
|
||||
forceUnit?: string;
|
||||
/**
|
||||
* @description Format with SI, i.e. m/M/etc.
|
||||
* @description Returns value using all available decimals
|
||||
*/
|
||||
withAll?: boolean;
|
||||
/**
|
||||
* @description Format with SI, i.e. m/M/etc. (default = true)
|
||||
*/
|
||||
withSi?: boolean;
|
||||
/**
|
||||
@@ -40,6 +45,14 @@ interface Options {
|
||||
* @description Add the unit (useful in Balance formats)
|
||||
*/
|
||||
withUnit?: boolean | string;
|
||||
/**
|
||||
* @description Returns all trailing zeros, otherwise removes (default = true)
|
||||
*/
|
||||
withZero?: boolean;
|
||||
/**
|
||||
* @description The locale to use
|
||||
*/
|
||||
locale?: string;
|
||||
}
|
||||
|
||||
interface BalanceFormatter {
|
||||
@@ -57,35 +70,10 @@ const DEFAULT_UNIT = SI[SI_MID].text;
|
||||
let defaultDecimals = DEFAULT_DECIMALS;
|
||||
let defaultUnit = DEFAULT_UNIT;
|
||||
|
||||
function getUnits (si: SiDef, withSi: boolean, withSiFull: boolean, withUnit: boolean | string): string {
|
||||
const unit = isBoolean(withUnit)
|
||||
? SI[SI_MID].text
|
||||
: withUnit;
|
||||
|
||||
return withSi || withSiFull
|
||||
? si.value === '-'
|
||||
? withUnit
|
||||
? ` ${unit}`
|
||||
: ''
|
||||
: ` ${withSiFull ? `${si.text}${withUnit ? ' ' : ''}` : si.value}${withUnit ? unit : ''}`
|
||||
: '';
|
||||
}
|
||||
|
||||
function getPrePost (text: string, decimals: number, forceUnit?: string): [SiDef, string, string] {
|
||||
// NOTE We start at midpoint (8) minus 1 - this means that values display as
|
||||
// 123.456 instead of 0.123k (so always 6 relevant). Additionally we use ceil
|
||||
// so there are at most 3 decimal before the decimal separator
|
||||
const si = calcSi(text, decimals, forceUnit);
|
||||
const mid = text.length - (decimals + si.power);
|
||||
const prefix = text.substring(0, mid);
|
||||
const padding = mid < 0 ? 0 - mid : 0;
|
||||
const postfix = `${`${new Array(padding + 1).join('0')}${text}`.substring(mid < 0 ? 0 : mid)}0000`.substring(0, 4);
|
||||
|
||||
return [si, prefix || '0', postfix];
|
||||
}
|
||||
|
||||
// Formats a string/number with <prefix>.<postfix><type> notation
|
||||
function _formatBalance <ExtToBn extends ToBn> (input?: number | string | BN | bigint | ExtToBn, { decimals = defaultDecimals, forceUnit, withSi = true, withSiFull = false, withUnit = true }: Options = {}): string {
|
||||
function _formatBalance <ExtToBn extends ToBn> (input?: number | string | BN | bigint | ExtToBn, { decimals = defaultDecimals, forceUnit, locale = 'en', withAll = false, withSi = true, withSiFull = false, withUnit = true, withZero = true }: Options = {}): string {
|
||||
// we only work with string inputs here - convert anything
|
||||
// into the string-only value
|
||||
let text = bnToBn(input).toString();
|
||||
|
||||
if (text.length === 0 || text === '0') {
|
||||
@@ -101,22 +89,61 @@ function _formatBalance <ExtToBn extends ToBn> (input?: number | string | BN | b
|
||||
text = text.substring(1);
|
||||
}
|
||||
|
||||
const [si, prefix, postfix] = getPrePost(text, decimals, forceUnit);
|
||||
const units = getUnits(si, withSi, withSiFull, withUnit);
|
||||
// We start at midpoint (8) minus 1 - this means that values display as
|
||||
// 123.4567 instead of 0.1234 k (so we always have the most relevant).
|
||||
const si = calcSi(text, decimals, forceUnit);
|
||||
const mid = text.length - (decimals + si.power);
|
||||
const pre = mid <= 0 ? '0' : text.substring(0, mid);
|
||||
|
||||
return `${sign}${formatDecimal(prefix)}.${postfix}${units}`;
|
||||
// get the post from the midpoint onward and then first add max decimals
|
||||
// before trimming to the correct (calculated) amount of decimals again
|
||||
let post = text
|
||||
.padStart(mid < 0 ? decimals : 1, '0')
|
||||
.substring(mid < 0 ? 0 : mid)
|
||||
.padEnd(withAll ? Math.max(decimals, 4) : 4, '0')
|
||||
.substring(0, withAll ? Math.max(4, decimals + si.power) : 4);
|
||||
|
||||
// remove all trailing 0's (if required via flag)
|
||||
if (!withZero) {
|
||||
let end = post.length - 1;
|
||||
|
||||
// This looks inefficient, however it is better to do the checks and
|
||||
// only make one final slice than it is to do it in multiples
|
||||
do {
|
||||
if (post[end] === '0') {
|
||||
end--;
|
||||
}
|
||||
} while (post[end] === '0');
|
||||
|
||||
post = post.substring(0, end + 1);
|
||||
}
|
||||
|
||||
// the display unit
|
||||
const unit = isBoolean(withUnit)
|
||||
? SI[SI_MID].text
|
||||
: withUnit;
|
||||
|
||||
// format the units for display based on the flags
|
||||
const units = withSi || withSiFull
|
||||
? si.value === '-'
|
||||
? withUnit
|
||||
? ` ${unit}`
|
||||
: ''
|
||||
: ` ${withSiFull ? `${si.text}${withUnit ? ' ' : ''}` : si.value}${withUnit ? unit : ''}`
|
||||
: '';
|
||||
|
||||
const { decimal, thousand } = getSeparator(locale);
|
||||
|
||||
return `${sign}${formatDecimal(pre, thousand)}${post && `${decimal}${post}`}${units}`;
|
||||
}
|
||||
|
||||
export const formatBalance = _formatBalance as BalanceFormatter;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
formatBalance.calcSi = (text: string, decimals: number = defaultDecimals): SiDef =>
|
||||
calcSi(text, decimals);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
formatBalance.findSi = findSi;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
formatBalance.getDefaults = (): Defaults => {
|
||||
return {
|
||||
decimals: defaultDecimals,
|
||||
@@ -125,7 +152,6 @@ formatBalance.getDefaults = (): Defaults => {
|
||||
};
|
||||
|
||||
// get allowable options to display in a dropdown
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
formatBalance.getOptions = (decimals: number = defaultDecimals): SiDef[] => {
|
||||
return SI.filter(({ power }): boolean =>
|
||||
power < 0
|
||||
@@ -135,7 +161,6 @@ formatBalance.getOptions = (decimals: number = defaultDecimals): SiDef[] => {
|
||||
};
|
||||
|
||||
// Sets the default decimals to use for formatting (ui-wide)
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
formatBalance.setDefaults = ({ decimals, unit }: SetDefaults): void => {
|
||||
defaultDecimals = decimals === undefined
|
||||
? defaultDecimals
|
||||
|
||||
@@ -6,9 +6,9 @@ const NUMBER_REGEX = new RegExp('(\\d+?)(?=(\\d{3})+(?!\\d)|$)', 'g');
|
||||
|
||||
/**
|
||||
* @name formatDecimal
|
||||
* @description Formats a number into string format with thousand seperators
|
||||
* @description Formats a number into string format with thousand separators
|
||||
*/
|
||||
export function formatDecimal (value: string): string {
|
||||
export function formatDecimal (value: string, separator = ','): string {
|
||||
// We can do this by adjusting the regx, however for the sake of clarity
|
||||
// we rather strip and re-add the negative sign in the output
|
||||
const isNegative = value[0].startsWith('-');
|
||||
@@ -17,6 +17,6 @@ export function formatDecimal (value: string): string {
|
||||
: value.match(NUMBER_REGEX);
|
||||
|
||||
return matched
|
||||
? `${isNegative ? '-' : ''}${matched.join(',')}`
|
||||
? `${isNegative ? '-' : ''}${matched.join(separator)}`
|
||||
: value;
|
||||
}
|
||||
|
||||
@@ -37,4 +37,22 @@ describe('formatNumber', (): void => {
|
||||
})
|
||||
).toEqual('12,345');
|
||||
});
|
||||
|
||||
it('formats negative numbers (locale=sl)', (): void => {
|
||||
expect(
|
||||
formatNumber(-123456, { locale: 'sl' })
|
||||
).toEqual('-123.456');
|
||||
});
|
||||
|
||||
it('formats BN numbers (locale=sl)', (): void => {
|
||||
expect(
|
||||
formatNumber(new BN(12345), { locale: 'sl' })
|
||||
).toEqual('12.345');
|
||||
});
|
||||
|
||||
it('formats BigInt numbers (locale=sl)', (): void => {
|
||||
expect(
|
||||
formatNumber(123456789n, { locale: 'sl' })
|
||||
).toEqual('123.456.789');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,11 +6,24 @@ import type { ToBn } from '../types';
|
||||
|
||||
import { bnToBn } from '../bn/toBn';
|
||||
import { formatDecimal } from './formatDecimal';
|
||||
import { getSeparator } from './getSeparator';
|
||||
|
||||
interface Options {
|
||||
/**
|
||||
* @description The locale to use
|
||||
*/
|
||||
locale?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name formatNumber
|
||||
* @description Formats a number into string format with thousand seperators
|
||||
* @description Formats a number into string format with thousand separators
|
||||
*/
|
||||
export function formatNumber <ExtToBn extends ToBn> (value?: ExtToBn | BN | bigint | number | null): string {
|
||||
return formatDecimal(bnToBn(value).toString());
|
||||
export function formatNumber <ExtToBn extends ToBn> (
|
||||
value?: ExtToBn | BN | bigint | number | null,
|
||||
{ locale = 'en' }: Options = {}
|
||||
): string {
|
||||
const { thousand } = getSeparator(locale);
|
||||
|
||||
return formatDecimal(bnToBn(value).toString(), thousand);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
// Copyright 2017-2023 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { getSeparator } from './getSeparator';
|
||||
|
||||
describe('getSeparator', (): void => {
|
||||
it('uses system locale', (): void => {
|
||||
const n = 1000.1;
|
||||
const locale = {
|
||||
decimal: n.toLocaleString().substring(5, 6),
|
||||
thousand: n.toLocaleString().substring(1, 2)
|
||||
};
|
||||
|
||||
expect(
|
||||
getSeparator()
|
||||
).toEqual(locale);
|
||||
});
|
||||
|
||||
it('uses en locale', (): void => {
|
||||
expect(
|
||||
getSeparator('en')
|
||||
).toEqual({
|
||||
decimal: '.',
|
||||
thousand: ','
|
||||
});
|
||||
});
|
||||
|
||||
it('uses en-gb locale', (): void => {
|
||||
expect(
|
||||
getSeparator('en-gb')
|
||||
).toEqual({
|
||||
decimal: '.',
|
||||
thousand: ','
|
||||
});
|
||||
});
|
||||
|
||||
it('uses sl locale', (): void => {
|
||||
expect(
|
||||
getSeparator('sl')
|
||||
).toEqual({
|
||||
decimal: ',',
|
||||
thousand: '.'
|
||||
});
|
||||
});
|
||||
|
||||
it('uses sl-si locale', (): void => {
|
||||
expect(
|
||||
getSeparator('sl-si')
|
||||
).toEqual({
|
||||
decimal: ',',
|
||||
thousand: '.'
|
||||
});
|
||||
});
|
||||
|
||||
it('uses it-it locale', (): void => {
|
||||
expect(
|
||||
getSeparator('it-it')
|
||||
).toEqual({
|
||||
decimal: ',',
|
||||
thousand: '.'
|
||||
});
|
||||
});
|
||||
|
||||
it('uses ja-jp locale', (): void => {
|
||||
expect(
|
||||
getSeparator('ja-jp')
|
||||
).toEqual({
|
||||
decimal: '.',
|
||||
thousand: ','
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright 2017-2023 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/**
|
||||
* Get the decimal and thousand separator of a locale
|
||||
* @param locale
|
||||
* @returns {decimal: string, thousand: string}
|
||||
*/
|
||||
export function getSeparator (locale?: string):
|
||||
{ thousand: string, decimal: string } {
|
||||
return {
|
||||
decimal: (0.1).toLocaleString(locale).substring(1, 2),
|
||||
thousand: (1000).toLocaleString(locale).substring(1, 2)
|
||||
};
|
||||
}
|
||||
@@ -11,6 +11,12 @@ declare const __dirname: unknown;
|
||||
declare const module: unknown;
|
||||
declare const require: unknown;
|
||||
|
||||
// We define a scappy low-level interface to mock Buffer
|
||||
// (this removes the need for the node typings)
|
||||
type BufferClass = ((value: unknown) => unknown) & {
|
||||
isBuffer: (value: unknown) => boolean;
|
||||
}
|
||||
|
||||
/** true if the environment has proper BigInt support */
|
||||
export const hasBigInt = typeof BigInt === 'function' && typeof BigInt.asIntN === 'function';
|
||||
|
||||
@@ -30,7 +36,7 @@ export const hasWasm = typeof WebAssembly !== 'undefined';
|
||||
// that some bundlers such as parcel would add (this is a check, not a use)
|
||||
|
||||
/** true if the environment has support for Buffer (typically Node.js) */
|
||||
export const hasBuffer = typeof xglobal.Buffer !== 'undefined';
|
||||
export const hasBuffer = typeof xglobal.Buffer === 'function' && typeof (xglobal.Buffer as BufferClass).isBuffer === 'function';
|
||||
|
||||
/** true if the environment has process available (typically Node.js) */
|
||||
export const hasProcess = typeof xglobal.process === 'object';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2023 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { perfCmp } from '../test/performance';
|
||||
import { perfCmp } from '../test';
|
||||
import { hexToU8a as hexToU8aBuffer } from './toU8aBuffer';
|
||||
import { hexToU8a } from '.';
|
||||
|
||||
@@ -72,7 +72,7 @@ describe('hexToU8a', (): void => {
|
||||
).toThrow(/hex value to convert/);
|
||||
});
|
||||
|
||||
perfCmp('hexToU8a', ['hexToU8aBuffer', 'hexToU8a'], 25, [[ptest]], (s: string, isSecond) =>
|
||||
perfCmp('hexToU8a', ['hexToU8aBuffer', 'hexToU8a'], 40, [[ptest]], (s: string, isSecond) =>
|
||||
isSecond
|
||||
? hexToU8a(s)
|
||||
: hexToU8aBuffer(s)
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
import type { HexString } from '../types';
|
||||
|
||||
const CHR = '0123456789abcdef';
|
||||
const U8 = new Array<number>(256);
|
||||
const U16 = new Array<number>(256 * 256);
|
||||
const U8 = new Uint8Array(256);
|
||||
const U16 = new Uint8Array(256 * 256);
|
||||
|
||||
for (let i = 0; i < CHR.length; i++) {
|
||||
U8[CHR[i].charCodeAt(0) | 0] = i | 0;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { stringToU8a } from '../string';
|
||||
import { perf } from '../test/performance';
|
||||
import { perf } from '../test';
|
||||
import { isAscii } from '.';
|
||||
|
||||
describe('isAscii', (): void => {
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
// Copyright 2017-2023 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { xglobal } from '@polkadot/x-global';
|
||||
|
||||
import { hasBuffer } from '../has';
|
||||
import { isFunction } from './function';
|
||||
|
||||
// We define these interfaces to not have the Buffer type
|
||||
// (doing this removes the need for node types being available)
|
||||
interface BufTyp { isBuffer: (value: unknown) => boolean }
|
||||
interface BufObj { readDoubleLE: (...args: unknown[]) => unknown }
|
||||
|
||||
/**
|
||||
* @name isBuffer
|
||||
* @summary Tests for a `Buffer` object instance.
|
||||
@@ -20,5 +27,5 @@ import { isFunction } from './function';
|
||||
*/
|
||||
export function isBuffer (value: unknown): value is Buffer {
|
||||
// we do check a function first, since it is slightly faster than isBuffer itself
|
||||
return hasBuffer && isFunction(value && (value as Buffer).readDoubleLE) && Buffer.isBuffer(value);
|
||||
return hasBuffer && isFunction(value && (value as BufObj).readDoubleLE) && (xglobal.Buffer as BufTyp).isBuffer(value);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
import type { Constructor } from '../types';
|
||||
|
||||
import { isClass } from './class';
|
||||
|
||||
/**
|
||||
* @name isChildClass
|
||||
* @summary Tests if the child extends the parent Class
|
||||
@@ -20,8 +22,8 @@ import type { Constructor } from '../types';
|
||||
*/
|
||||
export function isChildClass <P extends Constructor> (Parent: P, Child?: Constructor | null | unknown): Child is P {
|
||||
// https://stackoverflow.com/questions/30993434/check-if-a-constructor-inherits-another-in-es6/30993664
|
||||
return Child
|
||||
return isClass(Child) && isClass(Parent)
|
||||
// eslint-disable-next-line no-prototype-builtins
|
||||
? Parent === Child || Parent.isPrototypeOf(Child as Constructor)
|
||||
? Parent === Child || Parent.isPrototypeOf(Child)
|
||||
: false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright 2017-2023 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { BN } from '../bn';
|
||||
import { isClass } from '.';
|
||||
|
||||
describe('isClass', (): void => {
|
||||
it('returns false on a pure object', (): void => {
|
||||
expect(isClass({})).toEqual(false);
|
||||
});
|
||||
|
||||
it('returns false on instance values', (): void => {
|
||||
expect(
|
||||
isClass(new BN(1))
|
||||
).toEqual(false);
|
||||
});
|
||||
|
||||
it('returns true when a class value', (): void => {
|
||||
expect(
|
||||
isClass(BN)
|
||||
).toEqual(true);
|
||||
});
|
||||
|
||||
it('returns true on extends', (): void => {
|
||||
expect(
|
||||
isClass(class Test extends BN {})
|
||||
).toEqual(true);
|
||||
});
|
||||
|
||||
it('returns true on built-ins', (): void => {
|
||||
expect(
|
||||
isClass(Uint8Array)
|
||||
).toEqual(true);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
// Copyright 2017-2023 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Constructor } from '../types';
|
||||
|
||||
import { isOnFunction } from './helpers';
|
||||
|
||||
/**
|
||||
* @name isClass
|
||||
* Tests if the supplied agrument is a Class
|
||||
*/
|
||||
export const isClass: <T extends Constructor> (value?: unknown) => value is T = /*#__PURE__*/ isOnFunction('isPrototypeOf', 'hasOwnProperty');
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2023 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { perfCmp } from '../test/performance';
|
||||
import { perfCmp } from '../test';
|
||||
import { isCodec } from '.';
|
||||
|
||||
const ptest = {
|
||||
|
||||
@@ -10,6 +10,12 @@ export function isOn <T> (...fns: (keyof T)[]): (value?: unknown) => value is T
|
||||
fns.every((f) => isFunction((value as T)[f]));
|
||||
}
|
||||
|
||||
export function isOnFunction <T> (...fns: (keyof T)[]): (value?: unknown) => value is T {
|
||||
return (value?: unknown): value is T =>
|
||||
isFunction(value) &&
|
||||
fns.every((f) => isFunction((value as T)[f]));
|
||||
}
|
||||
|
||||
export function isOnObject <T> (...fns: (keyof T)[]): (value?: unknown) => value is T {
|
||||
return (value?: unknown): value is T =>
|
||||
isObject(value) &&
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2023 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { perf } from '../test/performance';
|
||||
import { perf } from '../test';
|
||||
import { isHex } from '.';
|
||||
|
||||
describe('isHex', (): void => {
|
||||
|
||||
@@ -11,6 +11,7 @@ export { isBn } from './bn';
|
||||
export { isBuffer } from './buffer';
|
||||
export { isBoolean } from './boolean';
|
||||
export { isChildClass } from './childClass';
|
||||
export { isClass } from './class';
|
||||
export { isCodec } from './codec';
|
||||
export { isCompact } from './compact';
|
||||
export { isError } from './error';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2023 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { perf } from '../test/performance';
|
||||
import { perf } from '../test';
|
||||
import { isU8a } from '.';
|
||||
|
||||
describe('isU8a', (): void => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2023 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { perf } from '../test/performance';
|
||||
import { perf } from '../test';
|
||||
import { isUndefined } from '.';
|
||||
|
||||
describe('isUndefined', (): void => {
|
||||
|
||||
Vendored
-11
@@ -1,11 +0,0 @@
|
||||
// Copyright 2017-2023 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Be able to import json in TS
|
||||
// https://stackoverflow.com/questions/49996456/importing-json-file-in-typescript
|
||||
declare module '*.json' {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const value: any;
|
||||
|
||||
export default value;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2023 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { perf } from '../test/performance';
|
||||
import { perf } from '../test';
|
||||
import { objectProperties, objectProperty } from '.';
|
||||
|
||||
describe('objectProperty/objectProperties', (): void => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2023 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { perf } from '../test/performance';
|
||||
import { perf } from '../test';
|
||||
import { objectSpread } from '.';
|
||||
|
||||
describe('objectSpread', (): void => {
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/util', path: 'auto', type: 'auto', version: '10.2.2' };
|
||||
export const packageInfo = { name: '@polkadot/util', path: 'auto', type: 'auto', version: '10.4.2' };
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { getRandomValues } from '@polkadot/x-randomvalues';
|
||||
|
||||
import { arrayRange } from '../array';
|
||||
import { perf } from '../test/performance';
|
||||
import { perf } from '../test';
|
||||
import { stringCamelCase, stringUpperFirst } from '.';
|
||||
|
||||
const SEPS = [' ', '_', '-', '.', ','];
|
||||
|
||||
@@ -33,7 +33,7 @@ function formatAllCaps (w: string): string {
|
||||
function converter (format: (w: string, i: number) => string): (value: AnyString) => string {
|
||||
return (value: AnyString): string => {
|
||||
const parts = value
|
||||
// replace all seperators (including consequtive) with spaces
|
||||
// replace all separators (including consequtive) with spaces
|
||||
.replace(/[-_., ]+/g, ' ')
|
||||
// we don't want leading or trailing spaces
|
||||
.trim()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2023 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { perf } from '../test/performance';
|
||||
import { perf } from '../test';
|
||||
import { stringLowerFirst } from '.';
|
||||
|
||||
describe('stringLowerFirst', (): void => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2023 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { perf } from '../test/performance';
|
||||
import { perf } from '../test';
|
||||
import { stringUpperFirst } from '.';
|
||||
|
||||
describe('stringUpperFirst', (): void => {
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2017-2023 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { perf, perfCmp } from './performance';
|
||||
@@ -9,7 +9,7 @@ type ExecFn = (...params: any[]) => unknown;
|
||||
const NUM_PAD = 16;
|
||||
const PRE_PAD = 32;
|
||||
|
||||
function loop (count: number, inputs: readonly unknown[][], exec: ExecFn): [number, unknown[]] {
|
||||
function loop (exec: ExecFn, count: number, inputs: readonly unknown[][]): [number, unknown[]] {
|
||||
const start = performance.now();
|
||||
const results = new Array<unknown>(inputs.length);
|
||||
|
||||
@@ -40,14 +40,14 @@ ${formatFixed(micro).padStart(NUM_PAD + PRE_PAD + 1)} μs/op`;
|
||||
}
|
||||
|
||||
export function perf (name: string, count: number, inputs: readonly unknown[][], exec: ExecFn, withLog?: boolean): void {
|
||||
if (process.env.GITHUB_REPOSITORY) {
|
||||
return;
|
||||
}
|
||||
const test = process.env.GITHUB_REPOSITORY
|
||||
? it.skip
|
||||
: it;
|
||||
|
||||
it(`performance: ${name}`, (): void => {
|
||||
const [time, results] = loop(count, inputs, exec);
|
||||
test(`performance: ${name}`, (): void => {
|
||||
const [time, results] = loop(exec, count, inputs);
|
||||
|
||||
console.log(`
|
||||
console.error(`
|
||||
performance run for ${name} completed with ${formatNumber(count)} iterations.
|
||||
|
||||
${`${name}:`.padStart(PRE_PAD)} ${time.toFixed(2).padStart(NUM_PAD)} ms${formatOps(count, time)}
|
||||
@@ -60,28 +60,29 @@ ${`${name}:`.padStart(PRE_PAD)} ${time.toFixed(2).padStart(NUM_PAD)} ms${formatO
|
||||
}
|
||||
|
||||
export function perfCmp (name: string, [first, second]: [string, string], count: number, inputs: readonly unknown[][], exec: ExecFn): void {
|
||||
if (process.env.GITHUB_REPOSITORY) {
|
||||
return;
|
||||
}
|
||||
const test = process.env.GITHUB_REPOSITORY
|
||||
? it.skip
|
||||
: it;
|
||||
|
||||
it(`performance: ${name}`, (): void => {
|
||||
const pa = inputs.map((values) => [...values, false]);
|
||||
const pb = inputs.map((values) => [...values, true]);
|
||||
const [ta, ra] = loop(count, pa, exec);
|
||||
const [tb, rb] = loop(count, pb, exec);
|
||||
|
||||
console.log(`
|
||||
performance run for ${name} completed with ${formatNumber(count)} iterations.
|
||||
|
||||
${`${first}:`.padStart(PRE_PAD)} ${ta.toFixed(2).padStart(NUM_PAD)} ms ${ta < tb ? '(fastest)' : `(slowest, ${(ta / tb).toFixed(2)}x)`}${formatOps(count, ta)}
|
||||
|
||||
${`${second}:`.padStart(PRE_PAD)} ${tb.toFixed(2).padStart(NUM_PAD)} ms ${ta > tb ? '(fastest)' : `(slowest, ${(tb / ta).toFixed(2)}x)`}${formatOps(count, tb)}
|
||||
`);
|
||||
|
||||
const unmatched = ra.filter((r, i) =>
|
||||
JSON.stringify(r) !== JSON.stringify(rb[i])
|
||||
test(`performance: ${name}`, (): void => {
|
||||
const [[t1, r1], [t2, r2]] = [false, true].map((flag) =>
|
||||
loop(exec, count, inputs.map((values) =>
|
||||
[...values, flag]
|
||||
))
|
||||
);
|
||||
|
||||
expect(unmatched.length).toEqual(0);
|
||||
console.error(`
|
||||
performance run for ${name} completed with ${formatNumber(count)} iterations.
|
||||
|
||||
${`${first}:`.padStart(PRE_PAD)} ${t1.toFixed(2).padStart(NUM_PAD)} ms ${t1 < t2 ? '(fastest)' : `(slowest, ${(t1 / t2).toFixed(2)}x)`}${formatOps(count, t1)}
|
||||
|
||||
${`${second}:`.padStart(PRE_PAD)} ${t2.toFixed(2).padStart(NUM_PAD)} ms ${t1 > t2 ? '(fastest)' : `(slowest, ${(t2 / t1).toFixed(2)}x)`}${formatOps(count, t2)}
|
||||
`);
|
||||
|
||||
expect(
|
||||
r1.filter((_, i) =>
|
||||
JSON.stringify(r1[i]) !== JSON.stringify(r2[i])
|
||||
)
|
||||
).toHaveLength(0);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -7,6 +7,10 @@ import type { BN } from './bn/bn';
|
||||
export interface Constructor<T = any> {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
new(...value: any[]): T;
|
||||
|
||||
hasOwnProperty (prop: string): boolean;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
isPrototypeOf (other: any): boolean;
|
||||
}
|
||||
|
||||
export interface ToBigInt {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2023 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { perf } from '../test/performance';
|
||||
import { perf } from '../test';
|
||||
import { u8aCmp } from '.';
|
||||
|
||||
const ltest = new Uint8Array(32768);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { getRandomValues } from '@polkadot/x-randomvalues';
|
||||
|
||||
import { arrayRange } from '../array';
|
||||
import { perf } from '../test/performance';
|
||||
import { perf } from '../test';
|
||||
import { u8aConcat, u8aConcatStrict } from '.';
|
||||
|
||||
const ptest = arrayRange(10).map(() => getRandomValues(new Uint8Array(32)));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2023 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { perf } from '../test/performance';
|
||||
import { perf } from '../test';
|
||||
import { u8aEmpty } from '.';
|
||||
|
||||
describe('u8aEmpty', (): void => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2023 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { perf } from '../test/performance';
|
||||
import { perf } from '../test';
|
||||
import { u8aEq } from '.';
|
||||
|
||||
const ltest = new Uint8Array(32768);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2023 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { perf } from '../test/performance';
|
||||
import { perf } from '../test';
|
||||
import { u8aToBigInt } from '.';
|
||||
|
||||
describe('u8aToBigInt', (): void => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2023 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { perf } from '../test/performance';
|
||||
import { perf } from '../test';
|
||||
import { u8aToBn } from '.';
|
||||
|
||||
describe('u8aToBn', (): void => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2023 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { perfCmp } from '../test/performance';
|
||||
import { perfCmp } from '../test';
|
||||
import { u8aToHex as u8aToHexBuffer } from './toHexBuffer';
|
||||
import { u8aToHex } from '.';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2023 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { perf } from '../test/performance';
|
||||
import { perf } from '../test';
|
||||
import { u8aToNumber } from '.';
|
||||
|
||||
describe('u8aToNumber', (): void => {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user