chore: update to version 14.0.11 and align website URLs

This commit is contained in:
2026-01-11 11:34:13 +03:00
parent ef74383349
commit 19c8d69bd8
1499 changed files with 53633 additions and 89 deletions
+5
View File
@@ -0,0 +1,5 @@
/**
* @name addressToEvm
* @summary Converts an SS58 address to its corresponding EVM address.
*/
export declare function addressToEvm(address: string | Uint8Array, ignoreChecksum?: boolean): Uint8Array;
@@ -0,0 +1,8 @@
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
@@ -0,0 +1,8 @@
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
@@ -0,0 +1,26 @@
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
@@ -0,0 +1 @@
export declare function checkAddressChecksum(decoded: Uint8Array): [boolean, number, number, number];
+16
View File
@@ -0,0 +1,16 @@
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
@@ -0,0 +1,2 @@
import type { Prefix } from './types.js';
export declare function decodeAddress(encoded?: string | Uint8Array | null, ignoreChecksum?: boolean, ss58Format?: Prefix): Uint8Array;
+29
View File
@@ -0,0 +1,29 @@
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
@@ -0,0 +1,6 @@
export declare const defaults: {
allowedDecodedLengths: number[];
allowedEncodedLengths: number[];
allowedPrefix: number[];
prefix: number;
};
+8
View File
@@ -0,0 +1,8 @@
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
@@ -0,0 +1,8 @@
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
@@ -0,0 +1,24 @@
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
@@ -0,0 +1,2 @@
import type { Prefix } from './types.js';
export declare function encodeAddress(key: string | Uint8Array, ss58Format?: Prefix): string;
+23
View File
@@ -0,0 +1,23 @@
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
@@ -0,0 +1,9 @@
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;
@@ -0,0 +1,12 @@
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
@@ -0,0 +1,9 @@
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;
@@ -0,0 +1,11 @@
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
@@ -0,0 +1,15 @@
/**
* @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
@@ -0,0 +1,19 @@
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
@@ -0,0 +1,7 @@
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;
@@ -0,0 +1,14 @@
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
@@ -0,0 +1,16 @@
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
@@ -0,0 +1,16 @@
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
@@ -0,0 +1,2 @@
import type { Prefix } from './types.js';
export declare function isAddress(address?: string | null, ignoreChecksum?: boolean, ss58Format?: Prefix): address is string;
+9
View File
@@ -0,0 +1,9 @@
import { validateAddress } from './validate.js';
export function isAddress(address, ignoreChecksum, ss58Format) {
try {
return validateAddress(address, ignoreChecksum, ss58Format);
}
catch {
return false;
}
}
+2
View File
@@ -0,0 +1,2 @@
import type { BN } from '@pezkuwi/util';
export declare function createKeyDerived(who: string | Uint8Array, index: bigint | BN | number): Uint8Array;
@@ -0,0 +1,8 @@
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
@@ -0,0 +1,2 @@
import type { BN } from '@pezkuwi/util';
export declare function createKeyMulti(who: (string | Uint8Array)[], threshold: bigint | BN | number): Uint8Array;
+8
View File
@@ -0,0 +1,8 @@
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
@@ -0,0 +1,6 @@
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;
@@ -0,0 +1,11 @@
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
@@ -0,0 +1,2 @@
import type { Prefix } from './types.js';
export declare function sortAddresses(addresses: (string | Uint8Array)[], ss58Format?: Prefix): string[];
+7
View File
@@ -0,0 +1,7 @@
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
@@ -0,0 +1 @@
export declare function sshash(key: Uint8Array): Uint8Array;
+6
View File
@@ -0,0 +1,6 @@
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
@@ -0,0 +1 @@
export type Prefix = number;
+1
View File
@@ -0,0 +1 @@
export {};
+1
View File
@@ -0,0 +1 @@
export declare function addressToU8a(who: string | Uint8Array): Uint8Array;
+4
View File
@@ -0,0 +1,4 @@
import { decodeAddress } from './decode.js';
export function addressToU8a(who) {
return decodeAddress(who);
}
+2
View File
@@ -0,0 +1,2 @@
import type { Prefix } from './types.js';
export declare function validateAddress(encoded?: string | null, ignoreChecksum?: boolean, ss58Format?: Prefix): encoded is string;
+4
View File
@@ -0,0 +1,4 @@
import { decodeAddress } from './decode.js';
export function validateAddress(encoded, ignoreChecksum, ss58Format) {
return !!decodeAddress(encoded, ignoreChecksum, ss58Format);
}
+26
View File
@@ -0,0 +1,26 @@
/**
* @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
@@ -0,0 +1,40 @@
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
@@ -0,0 +1,25 @@
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
@@ -0,0 +1,61 @@
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
@@ -0,0 +1,4 @@
/**
* @summary Encode and decode base32 values
*/
export { base32Decode, base32Encode, base32Validate, isBase32 } from './bs32.js';
+4
View File
@@ -0,0 +1,4 @@
/**
* @summary Encode and decode base32 values
*/
export { base32Decode, base32Encode, base32Validate, isBase32 } from './bs32.js';
+26
View File
@@ -0,0 +1,26 @@
/**
* @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
@@ -0,0 +1,34 @@
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
@@ -0,0 +1,4 @@
/**
* @summary Encode and decode base58 values
*/
export { base58Decode, base58Encode, base58Validate, isBase58 } from './bs58.js';
+4
View File
@@ -0,0 +1,4 @@
/**
* @summary Encode and decode base58 values
*/
export { base58Decode, base58Encode, base58Validate, isBase58 } from './bs58.js';
+26
View File
@@ -0,0 +1,26 @@
/**
* @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
@@ -0,0 +1,34 @@
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
@@ -0,0 +1,6 @@
/**
* @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
@@ -0,0 +1,6 @@
/**
* @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
@@ -0,0 +1,5 @@
/**
* @name base64Pad
* @description Adds padding characters for correct length
*/
export declare function base64Pad(value: string): string;
+7
View File
@@ -0,0 +1,7 @@
/**
* @name base64Pad
* @description Adds padding characters for correct length
*/
export function base64Pad(value) {
return value.padEnd(value.length + (value.length % 4), '=');
}
+5
View File
@@ -0,0 +1,5 @@
/**
* @name base64Trim
* @description Trims padding characters
*/
export declare function base64Trim(value: string): string;
+10
View File
@@ -0,0 +1,10 @@
/**
* @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
@@ -0,0 +1,20 @@
/**
* @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
@@ -0,0 +1,32 @@
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
@@ -0,0 +1,4 @@
/**
* @summary Create blake2b values with specified bitlengths
*/
export { blake2AsHex, blake2AsU8a } from './asU8a.js';
+4
View File
@@ -0,0 +1,4 @@
/**
* @summary Create blake2b values with specified bitlengths
*/
export { blake2AsHex, blake2AsU8a } from './asU8a.js';
+30
View File
@@ -0,0 +1,30 @@
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
@@ -0,0 +1,8 @@
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 one or more lines are too long
+26
View File
@@ -0,0 +1,26 @@
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
@@ -0,0 +1,26 @@
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
@@ -0,0 +1 @@
import '@pezkuwi/x-bigint/shim';
+5
View File
@@ -0,0 +1,5 @@
import '@pezkuwi/x-bigint/shim';
import { cryptoWaitReady } from './crypto.js';
cryptoWaitReady().catch(() => {
// shouldn't happen, logged and caught inside cryptoWaitReady
});
+5
View File
@@ -0,0 +1,5 @@
/**
* @name addressToEvm
* @summary Converts an SS58 address to its corresponding EVM address.
*/
export declare function addressToEvm(address: string | Uint8Array, ignoreChecksum?: boolean): Uint8Array;
@@ -0,0 +1,11 @@
"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
@@ -0,0 +1,8 @@
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
@@ -0,0 +1,29 @@
"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
@@ -0,0 +1 @@
export declare function checkAddressChecksum(decoded: Uint8Array): [boolean, number, number, number];
@@ -0,0 +1,19 @@
"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
@@ -0,0 +1,2 @@
import type { Prefix } from './types.js';
export declare function decodeAddress(encoded?: string | Uint8Array | null, ignoreChecksum?: boolean, ss58Format?: Prefix): Uint8Array;
@@ -0,0 +1,32 @@
"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
@@ -0,0 +1,6 @@
export declare const defaults: {
allowedDecodedLengths: number[];
allowedEncodedLengths: number[];
allowedPrefix: number[];
prefix: number;
};
@@ -0,0 +1,11 @@
"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
@@ -0,0 +1,8 @@
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;
@@ -0,0 +1,27 @@
"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
@@ -0,0 +1,2 @@
import type { Prefix } from './types.js';
export declare function encodeAddress(key: string | Uint8Array, ss58Format?: Prefix): string;
@@ -0,0 +1,26 @@
"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
@@ -0,0 +1,9 @@
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;
@@ -0,0 +1,15 @@
"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
@@ -0,0 +1,9 @@
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;
@@ -0,0 +1,14 @@
"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
@@ -0,0 +1,15 @@
/**
* @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
@@ -0,0 +1,22 @@
"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
@@ -0,0 +1,7 @@
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;
@@ -0,0 +1,17 @@
"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
@@ -0,0 +1,16 @@
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
@@ -0,0 +1,35 @@
"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
@@ -0,0 +1,2 @@
import type { Prefix } from './types.js';
export declare function isAddress(address?: string | null, ignoreChecksum?: boolean, ss58Format?: Prefix): address is string;
+12
View File
@@ -0,0 +1,12 @@
"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
@@ -0,0 +1,2 @@
import type { BN } from '@pezkuwi/util';
export declare function createKeyDerived(who: string | Uint8Array, index: bigint | BN | number): Uint8Array;
@@ -0,0 +1,11 @@
"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)));
}
+2
View File
@@ -0,0 +1,2 @@
import type { BN } from '@pezkuwi/util';
export declare function createKeyMulti(who: (string | Uint8Array)[], threshold: bigint | BN | number): Uint8Array;

Some files were not shown because too many files have changed in this diff Show More