Remove build output committed beside the sources

19c8d69 (2026-01-11) and later commits added the build's output to every
package directory: 1484 .js/.d.ts files under cjs/ and at the package roots,
plus 14 copies of LICENSE (identical to the root one, which the build copies
into each package itself). Upstream keeps none of it. With the source
manifests pointing at them, imports resolved to this stale output instead of
src, and a JavaScript-checking build (@pezkuwi/dev 0.85.12) reads them as
inputs (TS5055).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Satoshi Qazi MuhammedandClaude Opus 5.5 authored and SatoshiQaziMuhammed committed 2026-10-07 19:21:45 +04:00
1 parent 134f0ae3ce
commit 8c0bb78993
1498 files changed
-50566

No files matched your search

-201
View File
@@ -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.
-5
View File
@@ -1,5 +0,0 @@
/**
* @name addressToEvm
* @summary Converts an SS58 address to its corresponding EVM address.
*/
export declare function addressToEvm(address: string | Uint8Array, ignoreChecksum?: boolean): Uint8Array;
@@ -1,8 +0,0 @@
import { decodeAddress } from './decode.js';
/**
* @name addressToEvm
* @summary Converts an SS58 address to its corresponding EVM address.
*/
export function addressToEvm(address, ignoreChecksum) {
return decodeAddress(address, ignoreChecksum).subarray(0, 20);
}
-8
View File
@@ -1,8 +0,0 @@
import type { Prefix } from './types.js';
/**
* @name checkAddress
* @summary Validates an ss58 address.
* @description
* From the provided input, validate that the address is a valid input.
*/
export declare function checkAddress(address: string, prefix: Prefix): [boolean, string | null];
-26
View File
@@ -1,26 +0,0 @@
import { base58Decode } from '../base58/index.js';
import { checkAddressChecksum } from './checksum.js';
import { defaults } from './defaults.js';
/**
* @name checkAddress
* @summary Validates an ss58 address.
* @description
* From the provided input, validate that the address is a valid input.
*/
export function checkAddress(address, prefix) {
let decoded;
try {
decoded = base58Decode(address);
}
catch (error) {
return [false, error.message];
}
const [isValid, , , ss58Decoded] = checkAddressChecksum(decoded);
if (ss58Decoded !== prefix) {
return [false, `Prefix mismatch, expected ${prefix}, found ${ss58Decoded}`];
}
else if (!defaults.allowedEncodedLengths.includes(decoded.length)) {
return [false, 'Invalid decoded address length'];
}
return [isValid, isValid ? null : 'Invalid decoded address checksum'];
}
-1
View File
@@ -1 +0,0 @@
export declare function checkAddressChecksum(decoded: Uint8Array): [boolean, number, number, number];
-16
View File
@@ -1,16 +0,0 @@
import { sshash } from './sshash.js';
export function checkAddressChecksum(decoded) {
const ss58Length = (decoded[0] & 0b0100_0000) ? 2 : 1;
const ss58Decoded = ss58Length === 1
? decoded[0]
: ((decoded[0] & 0b0011_1111) << 2) | (decoded[1] >> 6) | ((decoded[1] & 0b0011_1111) << 8);
// 32/33 bytes public + 2 bytes checksum + prefix
const isPublicKey = [34 + ss58Length, 35 + ss58Length].includes(decoded.length);
const length = decoded.length - (isPublicKey ? 2 : 1);
// calculate the hash and do the checksum byte checks
const hash = sshash(decoded.subarray(0, length));
const isValid = (decoded[0] & 0b1000_0000) === 0 && ![46, 47].includes(decoded[0]) && (isPublicKey
? decoded[decoded.length - 2] === hash[0] && decoded[decoded.length - 1] === hash[1]
: decoded[decoded.length - 1] === hash[0]);
return [isValid, length, ss58Length, ss58Decoded];
}
-2
View File
@@ -1,2 +0,0 @@
import type { Prefix } from './types.js';
export declare function decodeAddress(encoded?: string | Uint8Array | null, ignoreChecksum?: boolean, ss58Format?: Prefix): Uint8Array;
-29
View File
@@ -1,29 +0,0 @@
import { isHex, isU8a, u8aToU8a } from '@pezkuwi/util';
import { base58Decode } from '../base58/index.js';
import { checkAddressChecksum } from './checksum.js';
import { defaults } from './defaults.js';
export function decodeAddress(encoded, ignoreChecksum, ss58Format = -1) {
if (!encoded) {
throw new Error('Invalid empty address passed');
}
if (isU8a(encoded) || isHex(encoded)) {
return u8aToU8a(encoded);
}
try {
const decoded = base58Decode(encoded);
if (!defaults.allowedEncodedLengths.includes(decoded.length)) {
throw new Error('Invalid decoded address length');
}
const [isValid, endPos, ss58Length, ss58Decoded] = checkAddressChecksum(decoded);
if (!isValid && !ignoreChecksum) {
throw new Error('Invalid decoded address checksum');
}
else if (ss58Format !== -1 && ss58Format !== ss58Decoded) {
throw new Error(`Expected ss58Format ${ss58Format}, received ${ss58Decoded}`);
}
return decoded.slice(ss58Length, endPos);
}
catch (error) {
throw new Error(`Decoding ${encoded}: ${error.message}`);
}
}
-6
View File
@@ -1,6 +0,0 @@
export declare const defaults: {
allowedDecodedLengths: number[];
allowedEncodedLengths: number[];
allowedPrefix: number[];
prefix: number;
};
-8
View File
@@ -1,8 +0,0 @@
import { availableNetworks } from '../networks.js';
export const defaults = {
allowedDecodedLengths: [1, 2, 4, 8, 32, 33],
// publicKey has prefix + 2 checksum bytes, short only prefix + 1 checksum byte
allowedEncodedLengths: [3, 4, 6, 10, 35, 36, 37, 38],
allowedPrefix: availableNetworks.map(({ prefix }) => prefix),
prefix: 42
};
-8
View File
@@ -1,8 +0,0 @@
import type { Prefix } from './types.js';
/**
* @name deriveAddress
* @summary Creates a sr25519 derived address from the supplied and path.
* @description
* Creates a sr25519 derived address based on the input address/publicKey and the uri supplied.
*/
export declare function deriveAddress(who: string | Uint8Array, suri: string, ss58Format?: Prefix): string;
-24
View File
@@ -1,24 +0,0 @@
import { keyExtractPath } from '../key/index.js';
import { sr25519DerivePublic } from '../sr25519/index.js';
import { decodeAddress } from './decode.js';
import { encodeAddress } from './encode.js';
function filterHard({ isHard }) {
return isHard;
}
/**
* @name deriveAddress
* @summary Creates a sr25519 derived address from the supplied and path.
* @description
* Creates a sr25519 derived address based on the input address/publicKey and the uri supplied.
*/
export function deriveAddress(who, suri, ss58Format) {
const { path } = keyExtractPath(suri);
if (!path.length || path.every(filterHard)) {
throw new Error('Expected suri to contain a combination of non-hard paths');
}
let publicKey = decodeAddress(who);
for (const { chainCode } of path) {
publicKey = sr25519DerivePublic(publicKey, chainCode);
}
return encodeAddress(publicKey, ss58Format);
}
-2
View File
@@ -1,2 +0,0 @@
import type { Prefix } from './types.js';
export declare function encodeAddress(key: string | Uint8Array, ss58Format?: Prefix): string;
-23
View File
@@ -1,23 +0,0 @@
import { u8aConcat } from '@pezkuwi/util';
import { base58Encode } from '../base58/index.js';
import { decodeAddress } from './decode.js';
import { defaults } from './defaults.js';
import { sshash } from './sshash.js';
export function encodeAddress(key, ss58Format = defaults.prefix) {
// decode it, this means we can re-encode an address
const u8a = decodeAddress(key);
if ((ss58Format < 0) || (ss58Format > 16383 && !ss58Exceptions.includes(ss58Format)) || [46, 47].includes(ss58Format)) {
throw new Error('Out of range ss58Format specified');
}
else if (!defaults.allowedDecodedLengths.includes(u8a.length)) {
throw new Error(`Expected a valid key to convert, with length ${defaults.allowedDecodedLengths.join(', ')}`);
}
const input = u8aConcat(ss58Format < 64
? [ss58Format]
: [
((ss58Format & 0b0000_0000_1111_1100) >> 2) | 0b0100_0000,
(ss58Format >> 8) | ((ss58Format & 0b0000_0000_0000_0011) << 6)
], u8a);
return base58Encode(u8aConcat(input, sshash(input).subarray(0, [32, 33].includes(u8a.length) ? 2 : 1)));
}
const ss58Exceptions = [29972];
-9
View File
@@ -1,9 +0,0 @@
import type { BN } from '@pezkuwi/util';
import type { Prefix } from './types.js';
/**
* @name encodeDerivedAddress
* @summary Creates a derived address as used in Substrate utility.
* @description
* Creates a Substrate derived address based on the input address/publicKey and the index supplied.
*/
export declare function encodeDerivedAddress(who: string | Uint8Array, index: bigint | BN | number, ss58Format?: Prefix): string;
@@ -1,12 +0,0 @@
import { decodeAddress } from './decode.js';
import { encodeAddress } from './encode.js';
import { createKeyDerived } from './keyDerived.js';
/**
* @name encodeDerivedAddress
* @summary Creates a derived address as used in Substrate utility.
* @description
* Creates a Substrate derived address based on the input address/publicKey and the index supplied.
*/
export function encodeDerivedAddress(who, index, ss58Format) {
return encodeAddress(createKeyDerived(decodeAddress(who), index), ss58Format);
}
-9
View File
@@ -1,9 +0,0 @@
import type { BN } from '@pezkuwi/util';
import type { Prefix } from './types.js';
/**
* @name encodeMultiAddress
* @summary Creates a multisig address.
* @description
* Creates a Substrate multisig address based on the input address and the required threshold.
*/
export declare function encodeMultiAddress(who: (string | Uint8Array)[], threshold: bigint | BN | number, ss58Format?: Prefix): string;
@@ -1,11 +0,0 @@
import { encodeAddress } from './encode.js';
import { createKeyMulti } from './keyMulti.js';
/**
* @name encodeMultiAddress
* @summary Creates a multisig address.
* @description
* Creates a Substrate multisig address based on the input address and the required threshold.
*/
export function encodeMultiAddress(who, threshold, ss58Format) {
return encodeAddress(createKeyMulti(who, threshold), ss58Format);
}
-15
View File
@@ -1,15 +0,0 @@
/**
* @name addressEq
* @summary Compares two addresses, either in ss58, Uint8Array or hex format.
* @description
* For the input values, return true is the underlying public keys do match.
* @example
* <BR>
*
* ```javascript
* import { u8aEq } from '@pezkuwi/util';
*
* u8aEq(new Uint8Array([0x68, 0x65]), new Uint8Array([0x68, 0x65])); // true
* ```
*/
export declare function addressEq(a: string | Uint8Array, b: string | Uint8Array): boolean;
-19
View File
@@ -1,19 +0,0 @@
import { u8aEq } from '@pezkuwi/util';
import { decodeAddress } from './decode.js';
/**
* @name addressEq
* @summary Compares two addresses, either in ss58, Uint8Array or hex format.
* @description
* For the input values, return true is the underlying public keys do match.
* @example
* <BR>
*
* ```javascript
* import { u8aEq } from '@pezkuwi/util';
*
* u8aEq(new Uint8Array([0x68, 0x65]), new Uint8Array([0x68, 0x65])); // true
* ```
*/
export function addressEq(a, b) {
return u8aEq(decodeAddress(a), decodeAddress(b));
}
-7
View File
@@ -1,7 +0,0 @@
import type { HashType } from '../secp256k1/types.js';
import type { Prefix } from './types.js';
/**
* @name evmToAddress
* @summary Converts an EVM address to its corresponding SS58 address.
*/
export declare function evmToAddress(evmAddress: string | Uint8Array, ss58Format?: Prefix, hashType?: HashType): string;
@@ -1,14 +0,0 @@
import { u8aConcat } from '@pezkuwi/util';
import { hasher } from '../secp256k1/hasher.js';
import { encodeAddress } from './encode.js';
/**
* @name evmToAddress
* @summary Converts an EVM address to its corresponding SS58 address.
*/
export function evmToAddress(evmAddress, ss58Format, hashType = 'blake2') {
const message = u8aConcat('evm:', evmAddress);
if (message.length !== 24) {
throw new Error(`Converting ${evmAddress}: Invalid evm address length`);
}
return encodeAddress(hasher(hashType, message), ss58Format);
}
-16
View File
@@ -1,16 +0,0 @@
export { addressToEvm } from './addressToEvm.js';
export { checkAddress } from './check.js';
export { checkAddressChecksum } from './checksum.js';
export { decodeAddress } from './decode.js';
export { deriveAddress } from './derive.js';
export { encodeAddress } from './encode.js';
export { encodeDerivedAddress } from './encodeDerived.js';
export { encodeMultiAddress } from './encodeMulti.js';
export { addressEq } from './eq.js';
export { evmToAddress } from './evmToAddress.js';
export { isAddress } from './is.js';
export { createKeyDerived } from './keyDerived.js';
export { createKeyMulti } from './keyMulti.js';
export { sortAddresses } from './sort.js';
export { validateAddress } from './validate.js';
export { setSS58Format } from './setSS58Format.js';
-16
View File
@@ -1,16 +0,0 @@
export { addressToEvm } from './addressToEvm.js';
export { checkAddress } from './check.js';
export { checkAddressChecksum } from './checksum.js';
export { decodeAddress } from './decode.js';
export { deriveAddress } from './derive.js';
export { encodeAddress } from './encode.js';
export { encodeDerivedAddress } from './encodeDerived.js';
export { encodeMultiAddress } from './encodeMulti.js';
export { addressEq } from './eq.js';
export { evmToAddress } from './evmToAddress.js';
export { isAddress } from './is.js';
export { createKeyDerived } from './keyDerived.js';
export { createKeyMulti } from './keyMulti.js';
export { sortAddresses } from './sort.js';
export { validateAddress } from './validate.js';
export { setSS58Format } from './setSS58Format.js';
-2
View File
@@ -1,2 +0,0 @@
import type { Prefix } from './types.js';
export declare function isAddress(address?: string | null, ignoreChecksum?: boolean, ss58Format?: Prefix): address is string;
-9
View File
@@ -1,9 +0,0 @@
import { validateAddress } from './validate.js';
export function isAddress(address, ignoreChecksum, ss58Format) {
try {
return validateAddress(address, ignoreChecksum, ss58Format);
}
catch {
return false;
}
}
-2
View File
@@ -1,2 +0,0 @@
import type { BN } from '@pezkuwi/util';
export declare function createKeyDerived(who: string | Uint8Array, index: bigint | BN | number): Uint8Array;
@@ -1,8 +0,0 @@
import { bnToU8a, stringToU8a, u8aConcat } from '@pezkuwi/util';
import { blake2AsU8a } from '../blake2/asU8a.js';
import { BN_LE_16_OPTS } from '../bn.js';
import { decodeAddress } from './decode.js';
const PREFIX = stringToU8a('modlpy/utilisuba');
export function createKeyDerived(who, index) {
return blake2AsU8a(u8aConcat(PREFIX, decodeAddress(who), bnToU8a(index, BN_LE_16_OPTS)));
}
-2
View File
@@ -1,2 +0,0 @@
import type { BN } from '@pezkuwi/util';
export declare function createKeyMulti(who: (string | Uint8Array)[], threshold: bigint | BN | number): Uint8Array;
-8
View File
@@ -1,8 +0,0 @@
import { bnToU8a, compactToU8a, stringToU8a, u8aConcat, u8aSorted } from '@pezkuwi/util';
import { blake2AsU8a } from '../blake2/asU8a.js';
import { BN_LE_16_OPTS } from '../bn.js';
import { addressToU8a } from './util.js';
const PREFIX = stringToU8a('modlpy/utilisuba');
export function createKeyMulti(who, threshold) {
return blake2AsU8a(u8aConcat(PREFIX, compactToU8a(who.length), ...u8aSorted(who.map(addressToU8a)), bnToU8a(threshold, BN_LE_16_OPTS)));
}
-6
View File
@@ -1,6 +0,0 @@
import type { Prefix } from './types.js';
/**
* @description Sets the global SS58 format to use for address encoding
* @deprecated Use keyring.setSS58Format
*/
export declare function setSS58Format(prefix: Prefix): void;
@@ -1,11 +0,0 @@
import { logger } from '@pezkuwi/util';
import { defaults } from './defaults.js';
const l = logger('setSS58Format');
/**
* @description Sets the global SS58 format to use for address encoding
* @deprecated Use keyring.setSS58Format
*/
export function setSS58Format(prefix) {
l.warn('Global setting of the ss58Format is deprecated and not recommended. Set format on the keyring (if used) or as part of the address encode function');
defaults.prefix = prefix;
}
-2
View File
@@ -1,2 +0,0 @@
import type { Prefix } from './types.js';
export declare function sortAddresses(addresses: (string | Uint8Array)[], ss58Format?: Prefix): string[];
-7
View File
@@ -1,7 +0,0 @@
import { u8aSorted } from '@pezkuwi/util';
import { encodeAddress } from './encode.js';
import { addressToU8a } from './util.js';
export function sortAddresses(addresses, ss58Format) {
const u8aToAddress = (u8a) => encodeAddress(u8a, ss58Format);
return u8aSorted(addresses.map(addressToU8a)).map(u8aToAddress);
}
-1
View File
@@ -1 +0,0 @@
export declare function sshash(key: Uint8Array): Uint8Array;
-6
View File
@@ -1,6 +0,0 @@
import { stringToU8a, u8aConcat } from '@pezkuwi/util';
import { blake2AsU8a } from '../blake2/asU8a.js';
const SS58_PREFIX = stringToU8a('SS58PRE');
export function sshash(key) {
return blake2AsU8a(u8aConcat(SS58_PREFIX, key), 512);
}
-1
View File
@@ -1 +0,0 @@
export type Prefix = number;
-1
View File
@@ -1 +0,0 @@
export {};
-1
View File
@@ -1 +0,0 @@
export declare function addressToU8a(who: string | Uint8Array): Uint8Array;
-4
View File
@@ -1,4 +0,0 @@
import { decodeAddress } from './decode.js';
export function addressToU8a(who) {
return decodeAddress(who);
}
-2
View File
@@ -1,2 +0,0 @@
import type { Prefix } from './types.js';
export declare function validateAddress(encoded?: string | null, ignoreChecksum?: boolean, ss58Format?: Prefix): encoded is string;
-4
View File
@@ -1,4 +0,0 @@
import { decodeAddress } from './decode.js';
export function validateAddress(encoded, ignoreChecksum, ss58Format) {
return !!decodeAddress(encoded, ignoreChecksum, ss58Format);
}
-26
View File
@@ -1,26 +0,0 @@
/**
* @name base32Validate
* @summary Validates a base32 value.
* @description
* Validates that the supplied value is valid base32, throwing exceptions if not
*/
export declare const base32Validate: (value?: unknown, ipfsCompat?: boolean) => value is string;
/**
* @name isBase32
* @description Checks if the input is in base32, returning true/false
*/
export declare const isBase32: (value?: unknown, ipfsCompat?: boolean) => value is string;
/**
* @name base32Decode
* @summary Delookup a base32 value.
* @description
* From the provided input, decode the base32 and return the result as an `Uint8Array`.
*/
export declare const base32Decode: (value: string, ipfsCompat?: boolean) => Uint8Array;
/**
* @name base32Encode
* @summary Creates a base32 value.
* @description
* From the provided input, create the base32 and return the result as a string.
*/
export declare const base32Encode: (value: import("@pezkuwi/util/types").U8aLike, ipfsCompat?: boolean) => string;
-40
View File
@@ -1,40 +0,0 @@
import { utils } from '@scure/base';
import { createDecode, createEncode, createIs, createValidate } from './helpers.js';
const chars = 'abcdefghijklmnopqrstuvwxyz234567';
const config = {
chars,
coder: utils.chain(
// We define our own chain, the default base32 has padding
utils.radix2(5), utils.alphabet(chars), {
decode: (input) => input.split(''),
encode: (input) => input.join('')
}),
ipfs: 'b',
type: 'base32'
};
/**
* @name base32Validate
* @summary Validates a base32 value.
* @description
* Validates that the supplied value is valid base32, throwing exceptions if not
*/
export const base32Validate = /*#__PURE__*/ createValidate(config);
/**
* @name isBase32
* @description Checks if the input is in base32, returning true/false
*/
export const isBase32 = /*#__PURE__*/ createIs(base32Validate);
/**
* @name base32Decode
* @summary Delookup a base32 value.
* @description
* From the provided input, decode the base32 and return the result as an `Uint8Array`.
*/
export const base32Decode = /*#__PURE__*/ createDecode(config, base32Validate);
/**
* @name base32Encode
* @summary Creates a base32 value.
* @description
* From the provided input, create the base32 and return the result as a string.
*/
export const base32Encode = /*#__PURE__*/ createEncode(config);
-25
View File
@@ -1,25 +0,0 @@
import type { U8aLike } from '@pezkuwi/util/types';
export type { U8aLike } from '@pezkuwi/util/types';
interface Coder {
decode: (value: string) => Uint8Array;
encode: (value: Uint8Array) => string;
}
interface Config {
chars: string;
coder: Coder;
ipfs?: string;
regex?: RegExp;
type: string;
withPadding?: boolean;
}
type DecodeFn = (value: string, ipfsCompat?: boolean) => Uint8Array;
type EncodeFn = (value: U8aLike, ipfsCompat?: boolean) => string;
type ValidateFn = (value?: unknown, ipfsCompat?: boolean) => value is string;
/** @internal */
export declare function createDecode({ coder, ipfs }: Config, validate: ValidateFn): DecodeFn;
/** @internal */
export declare function createEncode({ coder, ipfs }: Config): EncodeFn;
/** @internal */
export declare function createIs(validate: ValidateFn): ValidateFn;
/** @internal */
export declare function createValidate({ chars, ipfs, type, withPadding }: Config): ValidateFn;
-61
View File
@@ -1,61 +0,0 @@
import { u8aToU8a } from '@pezkuwi/util';
/** @internal */
export function createDecode({ coder, ipfs }, validate) {
return (value, ipfsCompat) => {
validate(value, ipfsCompat);
return coder.decode(ipfs && ipfsCompat
? value.substring(1)
: value);
};
}
/** @internal */
export function createEncode({ coder, ipfs }) {
return (value, ipfsCompat) => {
const out = coder.encode(u8aToU8a(value));
return ipfs && ipfsCompat
? `${ipfs}${out}`
: out;
};
}
/** @internal */
export function createIs(validate) {
return (value, ipfsCompat) => {
try {
return validate(value, ipfsCompat);
}
catch {
return false;
}
};
}
/** @internal */
export function createValidate({ chars, ipfs, type, withPadding }) {
return (value, ipfsCompat) => {
if (typeof value !== 'string') {
throw new Error(`Expected ${type} string input`);
}
else if (ipfs && ipfsCompat && !value.startsWith(ipfs)) {
throw new Error(`Expected ipfs-compatible ${type} to start with '${ipfs}'`);
}
for (let i = (ipfsCompat ? 1 : 0), count = value.length; i < count; i++) {
if (chars.includes(value[i])) {
// all ok, character found
}
else if (withPadding && value[i] === '=') {
if (i === count - 1) {
// last character, everything ok
}
else if (value[i + 1] === '=') {
// next one is also padding, sequence ok
}
else {
throw new Error(`Invalid ${type} padding sequence "${value[i]}${value[i + 1]}" at index ${i}`);
}
}
else {
throw new Error(`Invalid ${type} character "${value[i]}" (0x${value.charCodeAt(i).toString(16)}) at index ${i}`);
}
}
return true;
};
}
-4
View File
@@ -1,4 +0,0 @@
/**
* @summary Encode and decode base32 values
*/
export { base32Decode, base32Encode, base32Validate, isBase32 } from './bs32.js';
-4
View File
@@ -1,4 +0,0 @@
/**
* @summary Encode and decode base32 values
*/
export { base32Decode, base32Encode, base32Validate, isBase32 } from './bs32.js';
-26
View File
@@ -1,26 +0,0 @@
/**
* @name base58Validate
* @summary Validates a base58 value.
* @description
* Validates that the supplied value is valid base58, throwing exceptions if not
*/
export declare const base58Validate: (value?: unknown, ipfsCompat?: boolean) => value is string;
/**
* @name base58Decode
* @summary Decodes a base58 value.
* @description
* From the provided input, decode the base58 and return the result as an `Uint8Array`.
*/
export declare const base58Decode: (value: string, ipfsCompat?: boolean) => Uint8Array;
/**
* @name base58Encode
* @summary Creates a base58 value.
* @description
* From the provided input, create the base58 and return the result as a string.
*/
export declare const base58Encode: (value: import("@pezkuwi/util/types").U8aLike, ipfsCompat?: boolean) => string;
/**
* @name isBase58
* @description Checks if the input is in base58, returning true/false
*/
export declare const isBase58: (value?: unknown, ipfsCompat?: boolean) => value is string;
-34
View File
@@ -1,34 +0,0 @@
import { base58 } from '@scure/base';
import { createDecode, createEncode, createIs, createValidate } from '../base32/helpers.js';
const config = {
chars: '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz',
coder: base58,
ipfs: 'z',
type: 'base58'
};
/**
* @name base58Validate
* @summary Validates a base58 value.
* @description
* Validates that the supplied value is valid base58, throwing exceptions if not
*/
export const base58Validate = /*#__PURE__*/ createValidate(config);
/**
* @name base58Decode
* @summary Decodes a base58 value.
* @description
* From the provided input, decode the base58 and return the result as an `Uint8Array`.
*/
export const base58Decode = /*#__PURE__*/ createDecode(config, base58Validate);
/**
* @name base58Encode
* @summary Creates a base58 value.
* @description
* From the provided input, create the base58 and return the result as a string.
*/
export const base58Encode = /*#__PURE__*/ createEncode(config);
/**
* @name isBase58
* @description Checks if the input is in base58, returning true/false
*/
export const isBase58 = /*#__PURE__*/ createIs(base58Validate);
-4
View File
@@ -1,4 +0,0 @@
/**
* @summary Encode and decode base58 values
*/
export { base58Decode, base58Encode, base58Validate, isBase58 } from './bs58.js';
-4
View File
@@ -1,4 +0,0 @@
/**
* @summary Encode and decode base58 values
*/
export { base58Decode, base58Encode, base58Validate, isBase58 } from './bs58.js';
-26
View File
@@ -1,26 +0,0 @@
/**
* @name base64Validate
* @summary Validates a base64 value.
* @description
* Validates that the supplied value is valid base64
*/
export declare const base64Validate: (value?: unknown, ipfsCompat?: boolean) => value is string;
/**
* @name isBase64
* @description Checks if the input is in base64, returning true/false
*/
export declare const isBase64: (value?: unknown, ipfsCompat?: boolean) => value is string;
/**
* @name base64Decode
* @summary Decodes a base64 value.
* @description
* From the provided input, decode the base64 and return the result as an `Uint8Array`.
*/
export declare const base64Decode: (value: string, ipfsCompat?: boolean) => Uint8Array;
/**
* @name base64Encode
* @summary Creates a base64 value.
* @description
* From the provided input, create the base64 and return the result as a string.
*/
export declare const base64Encode: (value: import("@pezkuwi/util/types").U8aLike, ipfsCompat?: boolean) => string;
-34
View File
@@ -1,34 +0,0 @@
import { base64 } from '@scure/base';
import { createDecode, createEncode, createIs, createValidate } from '../base32/helpers.js';
const config = {
chars: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
coder: base64,
type: 'base64',
withPadding: true
};
/**
* @name base64Validate
* @summary Validates a base64 value.
* @description
* Validates that the supplied value is valid base64
*/
export const base64Validate = /*#__PURE__*/ createValidate(config);
/**
* @name isBase64
* @description Checks if the input is in base64, returning true/false
*/
export const isBase64 = /*#__PURE__*/ createIs(base64Validate);
/**
* @name base64Decode
* @summary Decodes a base64 value.
* @description
* From the provided input, decode the base64 and return the result as an `Uint8Array`.
*/
export const base64Decode = /*#__PURE__*/ createDecode(config, base64Validate);
/**
* @name base64Encode
* @summary Creates a base64 value.
* @description
* From the provided input, create the base64 and return the result as a string.
*/
export const base64Encode = /*#__PURE__*/ createEncode(config);
-6
View File
@@ -1,6 +0,0 @@
/**
* @summary Encode and decode base64 values
*/
export { base64Decode, base64Encode, base64Validate, isBase64 } from './bs64.js';
export { base64Pad } from './pad.js';
export { base64Trim } from './trim.js';
-6
View File
@@ -1,6 +0,0 @@
/**
* @summary Encode and decode base64 values
*/
export { base64Decode, base64Encode, base64Validate, isBase64 } from './bs64.js';
export { base64Pad } from './pad.js';
export { base64Trim } from './trim.js';
-5
View File
@@ -1,5 +0,0 @@
/**
* @name base64Pad
* @description Adds padding characters for correct length
*/
export declare function base64Pad(value: string): string;
-7
View File
@@ -1,7 +0,0 @@
/**
* @name base64Pad
* @description Adds padding characters for correct length
*/
export function base64Pad(value) {
return value.padEnd(value.length + (value.length % 4), '=');
}
-5
View File
@@ -1,5 +0,0 @@
/**
* @name base64Trim
* @description Trims padding characters
*/
export declare function base64Trim(value: string): string;
-10
View File
@@ -1,10 +0,0 @@
/**
* @name base64Trim
* @description Trims padding characters
*/
export function base64Trim(value) {
while (value.length && value.endsWith('=')) {
value = value.slice(0, -1);
}
return value;
}
-20
View File
@@ -1,20 +0,0 @@
/**
* @name blake2AsU8a
* @summary Creates a blake2b u8a from the input.
* @description
* From a `Uint8Array` input, create the blake2b and return the result as a u8a with the specified `bitLength`.
* @example
* <BR>
*
* ```javascript
* import { blake2AsU8a } from '@pezkuwi/util-crypto';
*
* blake2AsU8a('abc'); // => [0xba, 0x80, 0xa5, 0x3f, 0x98, 0x1c, 0x4d, 0x0d]
* ```
*/
export declare function blake2AsU8a(data: string | Uint8Array, bitLength?: 64 | 128 | 256 | 384 | 512, key?: Uint8Array | null, onlyJs?: boolean): Uint8Array;
/**
* @name blake2AsHex
* @description Creates a blake2b hex from the input.
*/
export declare const blake2AsHex: (data: string | Uint8Array, bitLength?: 256 | 512 | 64 | 128 | 384 | undefined, key?: Uint8Array | null | undefined, onlyJs?: boolean | undefined) => import("@pezkuwi/util/types").HexString;
-32
View File
@@ -1,32 +0,0 @@
import { blake2b as blake2bJs } from '@noble/hashes/blake2b';
import { hasBigInt, u8aToU8a } from '@pezkuwi/util';
import { blake2b, isReady } from '@pezkuwi/wasm-crypto';
import { createAsHex } from '../helpers.js';
/**
* @name blake2AsU8a
* @summary Creates a blake2b u8a from the input.
* @description
* From a `Uint8Array` input, create the blake2b and return the result as a u8a with the specified `bitLength`.
* @example
* <BR>
*
* ```javascript
* import { blake2AsU8a } from '@pezkuwi/util-crypto';
*
* blake2AsU8a('abc'); // => [0xba, 0x80, 0xa5, 0x3f, 0x98, 0x1c, 0x4d, 0x0d]
* ```
*/
export function blake2AsU8a(data, bitLength = 256, key, onlyJs) {
const byteLength = Math.ceil(bitLength / 8);
const u8a = u8aToU8a(data);
return !hasBigInt || (!onlyJs && isReady())
? blake2b(u8a, u8aToU8a(key), byteLength)
: key
? blake2bJs(u8a, { dkLen: byteLength, key })
: blake2bJs(u8a, { dkLen: byteLength });
}
/**
* @name blake2AsHex
* @description Creates a blake2b hex from the input.
*/
export const blake2AsHex = /*#__PURE__*/ createAsHex(blake2AsU8a);
-4
View File
@@ -1,4 +0,0 @@
/**
* @summary Create blake2b values with specified bitlengths
*/
export { blake2AsHex, blake2AsU8a } from './asU8a.js';
-4
View File
@@ -1,4 +0,0 @@
/**
* @summary Create blake2b values with specified bitlengths
*/
export { blake2AsHex, blake2AsU8a } from './asU8a.js';
-30
View File
@@ -1,30 +0,0 @@
export declare const BN_BE_OPTS: {
isLe: boolean;
};
export declare const BN_LE_OPTS: {
isLe: boolean;
};
export declare const BN_LE_16_OPTS: {
bitLength: number;
isLe: boolean;
};
export declare const BN_BE_32_OPTS: {
bitLength: number;
isLe: boolean;
};
export declare const BN_LE_32_OPTS: {
bitLength: number;
isLe: boolean;
};
export declare const BN_BE_256_OPTS: {
bitLength: number;
isLe: boolean;
};
export declare const BN_LE_256_OPTS: {
bitLength: number;
isLe: boolean;
};
export declare const BN_LE_512_OPTS: {
bitLength: number;
isLe: boolean;
};
-8
View File
@@ -1,8 +0,0 @@
export const BN_BE_OPTS = { isLe: false };
export const BN_LE_OPTS = { isLe: true };
export const BN_LE_16_OPTS = { bitLength: 16, isLe: true };
export const BN_BE_32_OPTS = { bitLength: 32, isLe: false };
export const BN_LE_32_OPTS = { bitLength: 32, isLe: true };
export const BN_BE_256_OPTS = { bitLength: 256, isLe: false };
export const BN_LE_256_OPTS = { bitLength: 256, isLe: true };
export const BN_LE_512_OPTS = { bitLength: 512, isLe: true };
File diff suppressed because it is too large. Load diff
-26
View File
@@ -1,26 +0,0 @@
import './bundleInit.js';
export { packageInfo } from './packageInfo.js';
export * from './address/index.js';
export * from './base32/index.js';
export * from './base58/index.js';
export * from './base64/index.js';
export * from './blake2/index.js';
export * from './crypto.js';
export * from './ed25519/index.js';
export * from './ethereum/index.js';
export * from './hd/index.js';
export * from './hmac/index.js';
export * from './json/index.js';
export * from './keccak/index.js';
export * from './key/index.js';
export * from './mnemonic/index.js';
export * from './nacl/index.js';
export * from './networks.js';
export * from './pbkdf2/index.js';
export * from './random/index.js';
export * from './scrypt/index.js';
export * from './secp256k1/index.js';
export * from './sha/index.js';
export * from './signature/index.js';
export * from './sr25519/index.js';
export * from './xxhash/index.js';
-26
View File
@@ -1,26 +0,0 @@
import './bundleInit.js';
export { packageInfo } from './packageInfo.js';
export * from './address/index.js';
export * from './base32/index.js';
export * from './base58/index.js';
export * from './base64/index.js';
export * from './blake2/index.js';
export * from './crypto.js';
export * from './ed25519/index.js';
export * from './ethereum/index.js';
export * from './hd/index.js';
export * from './hmac/index.js';
export * from './json/index.js';
export * from './keccak/index.js';
export * from './key/index.js';
export * from './mnemonic/index.js';
export * from './nacl/index.js';
export * from './networks.js';
export * from './pbkdf2/index.js';
export * from './random/index.js';
export * from './scrypt/index.js';
export * from './secp256k1/index.js';
export * from './sha/index.js';
export * from './signature/index.js';
export * from './sr25519/index.js';
export * from './xxhash/index.js';
-1
View File
@@ -1 +0,0 @@
import '@pezkuwi/x-bigint/shim';
-5
View File
@@ -1,5 +0,0 @@
import '@pezkuwi/x-bigint/shim';
import { cryptoWaitReady } from './crypto.js';
cryptoWaitReady().catch(() => {
// shouldn't happen, logged and caught inside cryptoWaitReady
});
-5
View File
@@ -1,5 +0,0 @@
/**
* @name addressToEvm
* @summary Converts an SS58 address to its corresponding EVM address.
*/
export declare function addressToEvm(address: string | Uint8Array, ignoreChecksum?: boolean): Uint8Array;
@@ -1,11 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.addressToEvm = addressToEvm;
const decode_js_1 = require("./decode.js");
/**
* @name addressToEvm
* @summary Converts an SS58 address to its corresponding EVM address.
*/
function addressToEvm(address, ignoreChecksum) {
return (0, decode_js_1.decodeAddress)(address, ignoreChecksum).subarray(0, 20);
}
-8
View File
@@ -1,8 +0,0 @@
import type { Prefix } from './types.js';
/**
* @name checkAddress
* @summary Validates an ss58 address.
* @description
* From the provided input, validate that the address is a valid input.
*/
export declare function checkAddress(address: string, prefix: Prefix): [boolean, string | null];
-29
View File
@@ -1,29 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkAddress = checkAddress;
const index_js_1 = require("../base58/index.js");
const checksum_js_1 = require("./checksum.js");
const defaults_js_1 = require("./defaults.js");
/**
* @name checkAddress
* @summary Validates an ss58 address.
* @description
* From the provided input, validate that the address is a valid input.
*/
function checkAddress(address, prefix) {
let decoded;
try {
decoded = (0, index_js_1.base58Decode)(address);
}
catch (error) {
return [false, error.message];
}
const [isValid, , , ss58Decoded] = (0, checksum_js_1.checkAddressChecksum)(decoded);
if (ss58Decoded !== prefix) {
return [false, `Prefix mismatch, expected ${prefix}, found ${ss58Decoded}`];
}
else if (!defaults_js_1.defaults.allowedEncodedLengths.includes(decoded.length)) {
return [false, 'Invalid decoded address length'];
}
return [isValid, isValid ? null : 'Invalid decoded address checksum'];
}
-1
View File
@@ -1 +0,0 @@
export declare function checkAddressChecksum(decoded: Uint8Array): [boolean, number, number, number];
@@ -1,19 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkAddressChecksum = checkAddressChecksum;
const sshash_js_1 = require("./sshash.js");
function checkAddressChecksum(decoded) {
const ss58Length = (decoded[0] & 0b0100_0000) ? 2 : 1;
const ss58Decoded = ss58Length === 1
? decoded[0]
: ((decoded[0] & 0b0011_1111) << 2) | (decoded[1] >> 6) | ((decoded[1] & 0b0011_1111) << 8);
// 32/33 bytes public + 2 bytes checksum + prefix
const isPublicKey = [34 + ss58Length, 35 + ss58Length].includes(decoded.length);
const length = decoded.length - (isPublicKey ? 2 : 1);
// calculate the hash and do the checksum byte checks
const hash = (0, sshash_js_1.sshash)(decoded.subarray(0, length));
const isValid = (decoded[0] & 0b1000_0000) === 0 && ![46, 47].includes(decoded[0]) && (isPublicKey
? decoded[decoded.length - 2] === hash[0] && decoded[decoded.length - 1] === hash[1]
: decoded[decoded.length - 1] === hash[0]);
return [isValid, length, ss58Length, ss58Decoded];
}
-2
View File
@@ -1,2 +0,0 @@
import type { Prefix } from './types.js';
export declare function decodeAddress(encoded?: string | Uint8Array | null, ignoreChecksum?: boolean, ss58Format?: Prefix): Uint8Array;
@@ -1,32 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.decodeAddress = decodeAddress;
const util_1 = require("@pezkuwi/util");
const index_js_1 = require("../base58/index.js");
const checksum_js_1 = require("./checksum.js");
const defaults_js_1 = require("./defaults.js");
function decodeAddress(encoded, ignoreChecksum, ss58Format = -1) {
if (!encoded) {
throw new Error('Invalid empty address passed');
}
if ((0, util_1.isU8a)(encoded) || (0, util_1.isHex)(encoded)) {
return (0, util_1.u8aToU8a)(encoded);
}
try {
const decoded = (0, index_js_1.base58Decode)(encoded);
if (!defaults_js_1.defaults.allowedEncodedLengths.includes(decoded.length)) {
throw new Error('Invalid decoded address length');
}
const [isValid, endPos, ss58Length, ss58Decoded] = (0, checksum_js_1.checkAddressChecksum)(decoded);
if (!isValid && !ignoreChecksum) {
throw new Error('Invalid decoded address checksum');
}
else if (ss58Format !== -1 && ss58Format !== ss58Decoded) {
throw new Error(`Expected ss58Format ${ss58Format}, received ${ss58Decoded}`);
}
return decoded.slice(ss58Length, endPos);
}
catch (error) {
throw new Error(`Decoding ${encoded}: ${error.message}`);
}
}
-6
View File
@@ -1,6 +0,0 @@
export declare const defaults: {
allowedDecodedLengths: number[];
allowedEncodedLengths: number[];
allowedPrefix: number[];
prefix: number;
};
@@ -1,11 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaults = void 0;
const networks_js_1 = require("../networks.js");
exports.defaults = {
allowedDecodedLengths: [1, 2, 4, 8, 32, 33],
// publicKey has prefix + 2 checksum bytes, short only prefix + 1 checksum byte
allowedEncodedLengths: [3, 4, 6, 10, 35, 36, 37, 38],
allowedPrefix: networks_js_1.availableNetworks.map(({ prefix }) => prefix),
prefix: 42
};
-8
View File
@@ -1,8 +0,0 @@
import type { Prefix } from './types.js';
/**
* @name deriveAddress
* @summary Creates a sr25519 derived address from the supplied and path.
* @description
* Creates a sr25519 derived address based on the input address/publicKey and the uri supplied.
*/
export declare function deriveAddress(who: string | Uint8Array, suri: string, ss58Format?: Prefix): string;
@@ -1,27 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deriveAddress = deriveAddress;
const index_js_1 = require("../key/index.js");
const index_js_2 = require("../sr25519/index.js");
const decode_js_1 = require("./decode.js");
const encode_js_1 = require("./encode.js");
function filterHard({ isHard }) {
return isHard;
}
/**
* @name deriveAddress
* @summary Creates a sr25519 derived address from the supplied and path.
* @description
* Creates a sr25519 derived address based on the input address/publicKey and the uri supplied.
*/
function deriveAddress(who, suri, ss58Format) {
const { path } = (0, index_js_1.keyExtractPath)(suri);
if (!path.length || path.every(filterHard)) {
throw new Error('Expected suri to contain a combination of non-hard paths');
}
let publicKey = (0, decode_js_1.decodeAddress)(who);
for (const { chainCode } of path) {
publicKey = (0, index_js_2.sr25519DerivePublic)(publicKey, chainCode);
}
return (0, encode_js_1.encodeAddress)(publicKey, ss58Format);
}
-2
View File
@@ -1,2 +0,0 @@
import type { Prefix } from './types.js';
export declare function encodeAddress(key: string | Uint8Array, ss58Format?: Prefix): string;
@@ -1,26 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.encodeAddress = encodeAddress;
const util_1 = require("@pezkuwi/util");
const index_js_1 = require("../base58/index.js");
const decode_js_1 = require("./decode.js");
const defaults_js_1 = require("./defaults.js");
const sshash_js_1 = require("./sshash.js");
function encodeAddress(key, ss58Format = defaults_js_1.defaults.prefix) {
// decode it, this means we can re-encode an address
const u8a = (0, decode_js_1.decodeAddress)(key);
if ((ss58Format < 0) || (ss58Format > 16383 && !ss58Exceptions.includes(ss58Format)) || [46, 47].includes(ss58Format)) {
throw new Error('Out of range ss58Format specified');
}
else if (!defaults_js_1.defaults.allowedDecodedLengths.includes(u8a.length)) {
throw new Error(`Expected a valid key to convert, with length ${defaults_js_1.defaults.allowedDecodedLengths.join(', ')}`);
}
const input = (0, util_1.u8aConcat)(ss58Format < 64
? [ss58Format]
: [
((ss58Format & 0b0000_0000_1111_1100) >> 2) | 0b0100_0000,
(ss58Format >> 8) | ((ss58Format & 0b0000_0000_0000_0011) << 6)
], u8a);
return (0, index_js_1.base58Encode)((0, util_1.u8aConcat)(input, (0, sshash_js_1.sshash)(input).subarray(0, [32, 33].includes(u8a.length) ? 2 : 1)));
}
const ss58Exceptions = [29972];
-9
View File
@@ -1,9 +0,0 @@
import type { BN } from '@pezkuwi/util';
import type { Prefix } from './types.js';
/**
* @name encodeDerivedAddress
* @summary Creates a derived address as used in Substrate utility.
* @description
* Creates a Substrate derived address based on the input address/publicKey and the index supplied.
*/
export declare function encodeDerivedAddress(who: string | Uint8Array, index: bigint | BN | number, ss58Format?: Prefix): string;
@@ -1,15 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.encodeDerivedAddress = encodeDerivedAddress;
const decode_js_1 = require("./decode.js");
const encode_js_1 = require("./encode.js");
const keyDerived_js_1 = require("./keyDerived.js");
/**
* @name encodeDerivedAddress
* @summary Creates a derived address as used in Substrate utility.
* @description
* Creates a Substrate derived address based on the input address/publicKey and the index supplied.
*/
function encodeDerivedAddress(who, index, ss58Format) {
return (0, encode_js_1.encodeAddress)((0, keyDerived_js_1.createKeyDerived)((0, decode_js_1.decodeAddress)(who), index), ss58Format);
}
-9
View File
@@ -1,9 +0,0 @@
import type { BN } from '@pezkuwi/util';
import type { Prefix } from './types.js';
/**
* @name encodeMultiAddress
* @summary Creates a multisig address.
* @description
* Creates a Substrate multisig address based on the input address and the required threshold.
*/
export declare function encodeMultiAddress(who: (string | Uint8Array)[], threshold: bigint | BN | number, ss58Format?: Prefix): string;
@@ -1,14 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.encodeMultiAddress = encodeMultiAddress;
const encode_js_1 = require("./encode.js");
const keyMulti_js_1 = require("./keyMulti.js");
/**
* @name encodeMultiAddress
* @summary Creates a multisig address.
* @description
* Creates a Substrate multisig address based on the input address and the required threshold.
*/
function encodeMultiAddress(who, threshold, ss58Format) {
return (0, encode_js_1.encodeAddress)((0, keyMulti_js_1.createKeyMulti)(who, threshold), ss58Format);
}
-15
View File
@@ -1,15 +0,0 @@
/**
* @name addressEq
* @summary Compares two addresses, either in ss58, Uint8Array or hex format.
* @description
* For the input values, return true is the underlying public keys do match.
* @example
* <BR>
*
* ```javascript
* import { u8aEq } from '@pezkuwi/util';
*
* u8aEq(new Uint8Array([0x68, 0x65]), new Uint8Array([0x68, 0x65])); // true
* ```
*/
export declare function addressEq(a: string | Uint8Array, b: string | Uint8Array): boolean;
-22
View File
@@ -1,22 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.addressEq = addressEq;
const util_1 = require("@pezkuwi/util");
const decode_js_1 = require("./decode.js");
/**
* @name addressEq
* @summary Compares two addresses, either in ss58, Uint8Array or hex format.
* @description
* For the input values, return true is the underlying public keys do match.
* @example
* <BR>
*
* ```javascript
* import { u8aEq } from '@pezkuwi/util';
*
* u8aEq(new Uint8Array([0x68, 0x65]), new Uint8Array([0x68, 0x65])); // true
* ```
*/
function addressEq(a, b) {
return (0, util_1.u8aEq)((0, decode_js_1.decodeAddress)(a), (0, decode_js_1.decodeAddress)(b));
}
-7
View File
@@ -1,7 +0,0 @@
import type { HashType } from '../secp256k1/types.js';
import type { Prefix } from './types.js';
/**
* @name evmToAddress
* @summary Converts an EVM address to its corresponding SS58 address.
*/
export declare function evmToAddress(evmAddress: string | Uint8Array, ss58Format?: Prefix, hashType?: HashType): string;
@@ -1,17 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.evmToAddress = evmToAddress;
const util_1 = require("@pezkuwi/util");
const hasher_js_1 = require("../secp256k1/hasher.js");
const encode_js_1 = require("./encode.js");
/**
* @name evmToAddress
* @summary Converts an EVM address to its corresponding SS58 address.
*/
function evmToAddress(evmAddress, ss58Format, hashType = 'blake2') {
const message = (0, util_1.u8aConcat)('evm:', evmAddress);
if (message.length !== 24) {
throw new Error(`Converting ${evmAddress}: Invalid evm address length`);
}
return (0, encode_js_1.encodeAddress)((0, hasher_js_1.hasher)(hashType, message), ss58Format);
}
-16
View File
@@ -1,16 +0,0 @@
export { addressToEvm } from './addressToEvm.js';
export { checkAddress } from './check.js';
export { checkAddressChecksum } from './checksum.js';
export { decodeAddress } from './decode.js';
export { deriveAddress } from './derive.js';
export { encodeAddress } from './encode.js';
export { encodeDerivedAddress } from './encodeDerived.js';
export { encodeMultiAddress } from './encodeMulti.js';
export { addressEq } from './eq.js';
export { evmToAddress } from './evmToAddress.js';
export { isAddress } from './is.js';
export { createKeyDerived } from './keyDerived.js';
export { createKeyMulti } from './keyMulti.js';
export { sortAddresses } from './sort.js';
export { validateAddress } from './validate.js';
export { setSS58Format } from './setSS58Format.js';
-35
View File
@@ -1,35 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setSS58Format = exports.validateAddress = exports.sortAddresses = exports.createKeyMulti = exports.createKeyDerived = exports.isAddress = exports.evmToAddress = exports.addressEq = exports.encodeMultiAddress = exports.encodeDerivedAddress = exports.encodeAddress = exports.deriveAddress = exports.decodeAddress = exports.checkAddressChecksum = exports.checkAddress = exports.addressToEvm = void 0;
var addressToEvm_js_1 = require("./addressToEvm.js");
Object.defineProperty(exports, "addressToEvm", { enumerable: true, get: function () { return addressToEvm_js_1.addressToEvm; } });
var check_js_1 = require("./check.js");
Object.defineProperty(exports, "checkAddress", { enumerable: true, get: function () { return check_js_1.checkAddress; } });
var checksum_js_1 = require("./checksum.js");
Object.defineProperty(exports, "checkAddressChecksum", { enumerable: true, get: function () { return checksum_js_1.checkAddressChecksum; } });
var decode_js_1 = require("./decode.js");
Object.defineProperty(exports, "decodeAddress", { enumerable: true, get: function () { return decode_js_1.decodeAddress; } });
var derive_js_1 = require("./derive.js");
Object.defineProperty(exports, "deriveAddress", { enumerable: true, get: function () { return derive_js_1.deriveAddress; } });
var encode_js_1 = require("./encode.js");
Object.defineProperty(exports, "encodeAddress", { enumerable: true, get: function () { return encode_js_1.encodeAddress; } });
var encodeDerived_js_1 = require("./encodeDerived.js");
Object.defineProperty(exports, "encodeDerivedAddress", { enumerable: true, get: function () { return encodeDerived_js_1.encodeDerivedAddress; } });
var encodeMulti_js_1 = require("./encodeMulti.js");
Object.defineProperty(exports, "encodeMultiAddress", { enumerable: true, get: function () { return encodeMulti_js_1.encodeMultiAddress; } });
var eq_js_1 = require("./eq.js");
Object.defineProperty(exports, "addressEq", { enumerable: true, get: function () { return eq_js_1.addressEq; } });
var evmToAddress_js_1 = require("./evmToAddress.js");
Object.defineProperty(exports, "evmToAddress", { enumerable: true, get: function () { return evmToAddress_js_1.evmToAddress; } });
var is_js_1 = require("./is.js");
Object.defineProperty(exports, "isAddress", { enumerable: true, get: function () { return is_js_1.isAddress; } });
var keyDerived_js_1 = require("./keyDerived.js");
Object.defineProperty(exports, "createKeyDerived", { enumerable: true, get: function () { return keyDerived_js_1.createKeyDerived; } });
var keyMulti_js_1 = require("./keyMulti.js");
Object.defineProperty(exports, "createKeyMulti", { enumerable: true, get: function () { return keyMulti_js_1.createKeyMulti; } });
var sort_js_1 = require("./sort.js");
Object.defineProperty(exports, "sortAddresses", { enumerable: true, get: function () { return sort_js_1.sortAddresses; } });
var validate_js_1 = require("./validate.js");
Object.defineProperty(exports, "validateAddress", { enumerable: true, get: function () { return validate_js_1.validateAddress; } });
var setSS58Format_js_1 = require("./setSS58Format.js");
Object.defineProperty(exports, "setSS58Format", { enumerable: true, get: function () { return setSS58Format_js_1.setSS58Format; } });
-2
View File
@@ -1,2 +0,0 @@
import type { Prefix } from './types.js';
export declare function isAddress(address?: string | null, ignoreChecksum?: boolean, ss58Format?: Prefix): address is string;
-12
View File
@@ -1,12 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isAddress = isAddress;
const validate_js_1 = require("./validate.js");
function isAddress(address, ignoreChecksum, ss58Format) {
try {
return (0, validate_js_1.validateAddress)(address, ignoreChecksum, ss58Format);
}
catch {
return false;
}
}
-2
View File
@@ -1,2 +0,0 @@
import type { BN } from '@pezkuwi/util';
export declare function createKeyDerived(who: string | Uint8Array, index: bigint | BN | number): Uint8Array;
@@ -1,11 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createKeyDerived = createKeyDerived;
const util_1 = require("@pezkuwi/util");
const asU8a_js_1 = require("../blake2/asU8a.js");
const bn_js_1 = require("../bn.js");
const decode_js_1 = require("./decode.js");
const PREFIX = (0, util_1.stringToU8a)('modlpy/utilisuba');
function createKeyDerived(who, index) {
return (0, asU8a_js_1.blake2AsU8a)((0, util_1.u8aConcat)(PREFIX, (0, decode_js_1.decodeAddress)(who), (0, util_1.bnToU8a)(index, bn_js_1.BN_LE_16_OPTS)));
}
Loaded 100 of 1498 files, more files were not shown because too many files have changed in this diff. Show more