Use .js imports in src (#1756)

* Use .js imports in src

* Revert node/test/node -> node/test/node.d.ts (for now)

* util-crypto

* Additional

* Adjust tsconfig aliases

* Bump dev
This commit is contained in:
Jaco
2023-03-09 11:04:03 +02:00
committed by GitHub
parent bcb7861d88
commit 9c224f5076
483 changed files with 1094 additions and 1088 deletions

View File

@@ -35,7 +35,7 @@
},
"devDependencies": {
"@babel/core": "^7.21.0",
"@polkadot/dev": "^0.70.4",
"@polkadot/dev": "^0.71.1",
"@types/node": "^18.14.6"
},
"resolutions": {

View File

@@ -7,7 +7,7 @@ import type { TransportDef } from './types';
import LedgerWebHid from '@ledgerhq/hw-transport-webhid';
import LedgerWebUsb from '@ledgerhq/hw-transport-webusb';
export { packageInfo } from './packageInfo';
export { packageInfo } from './packageInfo.js';
export const transports: TransportDef[] = [
{

View File

@@ -5,7 +5,7 @@
import { detectPackage } from '@polkadot/util';
import others from './detectOther';
import { packageInfo } from './packageInfo';
import others from './detectOther.js';
import { packageInfo } from './packageInfo.js';
detectPackage(packageInfo, null, others);

View File

@@ -3,6 +3,6 @@
import type { TransportDef } from './types';
export { packageInfo } from './packageInfo';
export { packageInfo } from './packageInfo.js';
export const transports: TransportDef[] = [];

View File

@@ -1,4 +1,4 @@
// Copyright 2017-2023 @polkadot/hw-ledger authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './empty';
export * from './empty.js';

View File

@@ -6,7 +6,7 @@ import type { TransportDef } from './types';
import LedgerHid from '@ledgerhq/hw-transport-node-hid-singleton';
export { packageInfo } from './packageInfo';
export { packageInfo } from './packageInfo.js';
export const transports: TransportDef[] = [
{

View File

@@ -1,4 +1,4 @@
// Copyright 2017-2023 @polkadot/hw-ledger authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './empty';
export * from './empty.js';

View File

@@ -2,17 +2,17 @@
// SPDX-License-Identifier: Apache-2.0
import type { SubstrateApp } from '@zondax/ledger-substrate';
import type { AccountOptions, LedgerAddress, LedgerSignature, LedgerTypes, LedgerVersion } from './types';
import type { AccountOptions, LedgerAddress, LedgerSignature, LedgerTypes, LedgerVersion } from './types.js';
import { newSubstrateApp } from '@zondax/ledger-substrate';
import { transports } from '@polkadot/hw-ledger-transports';
import { hexAddPrefix, u8aToBuffer } from '@polkadot/util';
import { LEDGER_DEFAULT_ACCOUNT, LEDGER_DEFAULT_CHANGE, LEDGER_DEFAULT_INDEX, LEDGER_SUCCESS_CODE } from './constants';
import { ledgerApps } from './defaults';
import { LEDGER_DEFAULT_ACCOUNT, LEDGER_DEFAULT_CHANGE, LEDGER_DEFAULT_INDEX, LEDGER_SUCCESS_CODE } from './constants.js';
import { ledgerApps } from './defaults.js';
export { packageInfo } from './packageInfo';
export { packageInfo } from './packageInfo.js';
type Chain = keyof typeof ledgerApps;

View File

@@ -5,7 +5,7 @@
import { supportedApps } from '@zondax/ledger-substrate';
import { ledgerApps } from './defaults';
import { ledgerApps } from './defaults.js';
describe('ledgerApps', (): void => {
for (const k of Object.keys(ledgerApps)) {

View File

@@ -5,7 +5,7 @@
import { detectPackage } from '@polkadot/util';
import others from './detectOther';
import { packageInfo } from './packageInfo';
import others from './detectOther.js';
import { packageInfo } from './packageInfo.js';
detectPackage(packageInfo, null, others);

View File

@@ -1,6 +1,6 @@
// Copyright 2017-2023 @polkadot/hw-ledger authors & contributors
// SPDX-License-Identifier: Apache-2.0
import './detectPackage';
import './detectPackage.js';
export * from './bundle';
export * from './bundle.js';

View File

@@ -1,4 +1,4 @@
// Copyright 2017-2023 @polkadot/hw-ledger authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './index';
export * from './index.js';

View File

@@ -1,15 +1,16 @@
// Copyright 2017-2023 @polkadot/keyring authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { Keyring } from './keyring';
import { Keyring } from './keyring.js';
// eslint-disable-next-line deprecation/deprecation
export { decodeAddress, encodeAddress, setSS58Format } from '@polkadot/util-crypto';
export * from './defaults';
export { createPair } from './pair';
export { packageInfo } from './packageInfo';
export { createTestKeyring } from './testing';
export { createTestPairs } from './testingPairs';
export * from './defaults.js';
export { createPair } from './pair/index.js';
export { packageInfo } from './packageInfo.js';
export { createTestKeyring } from './testing.js';
export { createTestPairs } from './testingPairs.js';
export { Keyring };

View File

@@ -5,7 +5,7 @@
import { detectPackage } from '@polkadot/util';
import others from './detectOther';
import { packageInfo } from './packageInfo';
import others from './detectOther.js';
import { packageInfo } from './packageInfo.js';
detectPackage(packageInfo, null, others);

View File

@@ -8,8 +8,8 @@ import type { KeyringPair$Json } from './types';
import { hexToU8a, stringToU8a } from '@polkadot/util';
import { base64Decode, cryptoWaitReady, encodeAddress, randomAsU8a, setSS58Format } from '@polkadot/util-crypto';
import { decodePair } from './pair/decode';
import Keyring from '.';
import { decodePair } from './pair/decode.js';
import Keyring from './index.js';
await cryptoWaitReady();

View File

@@ -1,10 +1,10 @@
// Copyright 2017-2023 @polkadot/keyring authors & contributors
// SPDX-License-Identifier: Apache-2.0
import './detectPackage';
import './detectPackage.js';
import { Keyring } from './bundle';
import { Keyring } from './bundle.js';
export * from './bundle';
export * from './bundle.js';
export default Keyring;

View File

@@ -7,9 +7,9 @@ import type { KeyringInstance, KeyringOptions, KeyringPair, KeyringPair$Json, Ke
import { hexToU8a, isHex, stringToU8a } from '@polkadot/util';
import { base64Decode, decodeAddress, ed25519PairFromSeed as ed25519FromSeed, encodeAddress, ethereumEncode, hdEthereum, keyExtractSuri, keyFromPath, mnemonicToLegacySeed, mnemonicToMiniSecret, secp256k1PairFromSeed as secp256k1FromSeed, sr25519PairFromSeed as sr25519FromSeed } from '@polkadot/util-crypto';
import { DEV_PHRASE } from './defaults';
import { createPair } from './pair';
import { Pairs } from './pairs';
import { createPair } from './pair/index.js';
import { DEV_PHRASE } from './defaults.js';
import { Pairs } from './pairs.js';
const PairFromSeed = {
ecdsa: (seed: Uint8Array): Keypair => secp256k1FromSeed(seed),

View File

@@ -1,4 +1,4 @@
// Copyright 2017-2023 @polkadot/keyring authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './index';
export * from './index.js';

View File

@@ -3,7 +3,7 @@
/// <reference types="@polkadot/dev/node/test/node" />
import { createTestPairs } from '../testingPairs';
import { createTestPairs } from '../testingPairs.js';
const keyring = createTestPairs({ type: 'ed25519' }, false);

View File

@@ -7,7 +7,7 @@ import type { PairInfo } from './types';
import { u8aEq } from '@polkadot/util';
import { jsonDecryptData } from '@polkadot/util-crypto';
import { PKCS8_DIVIDER, PKCS8_HEADER, PUB_LENGTH, SEC_LENGTH, SEED_LENGTH } from './defaults';
import { PKCS8_DIVIDER, PKCS8_HEADER, PUB_LENGTH, SEC_LENGTH, SEED_LENGTH } from './defaults.js';
const SEED_OFFSET = PKCS8_HEADER.length;

View File

@@ -5,8 +5,8 @@
import { NONCE_LENGTH, SCRYPT_LENGTH } from '@polkadot/util-crypto/json/constants';
import { createTestPairs } from '../testingPairs';
import { PKCS8_DIVIDER, PKCS8_HEADER, PUB_LENGTH, SEC_LENGTH } from './defaults';
import { createTestPairs } from '../testingPairs.js';
import { PKCS8_DIVIDER, PKCS8_HEADER, PUB_LENGTH, SEC_LENGTH } from './defaults.js';
const PKCS8_LENGTH = PKCS8_DIVIDER.length + PKCS8_HEADER.length + PUB_LENGTH + SEC_LENGTH;
const ENCODED_LENGTH = 16 + PKCS8_LENGTH + NONCE_LENGTH + SCRYPT_LENGTH;

View File

@@ -6,7 +6,7 @@ import type { PairInfo } from './types';
import { u8aConcat } from '@polkadot/util';
import { naclEncrypt, scryptEncode, scryptToU8a } from '@polkadot/util-crypto';
import { PKCS8_DIVIDER, PKCS8_HEADER } from './defaults';
import { PKCS8_DIVIDER, PKCS8_HEADER } from './defaults.js';
export function encodePair ({ publicKey, secretKey }: PairInfo, passphrase?: string): Uint8Array {
if (!secretKey) {

View File

@@ -6,9 +6,9 @@
import { hexToU8a, u8aToHex } from '@polkadot/util';
import { cryptoWaitReady, encodeAddress as toSS58, setSS58Format } from '@polkadot/util-crypto';
import { PAIRSSR25519 } from '../testing';
import { createTestPairs } from '../testingPairs';
import { createPair } from '.';
import { PAIRSSR25519 } from '../testing.js';
import { createTestPairs } from '../testingPairs.js';
import { createPair } from './index.js';
const keyring = createTestPairs({ type: 'ed25519' }, false);

View File

@@ -3,15 +3,15 @@
import type { HexString } from '@polkadot/util/types';
import type { EncryptedJsonEncoding, Keypair, KeypairType } from '@polkadot/util-crypto/types';
import type { KeyringPair, KeyringPair$Json, KeyringPair$Meta, SignOptions } from '../types';
import type { KeyringPair, KeyringPair$Json, KeyringPair$Meta, SignOptions } from '../types.js';
import type { PairInfo } from './types';
import { objectSpread, u8aConcat, u8aEmpty, u8aEq, u8aToHex, u8aToU8a } from '@polkadot/util';
import { blake2AsU8a, convertPublicKeyToCurve25519, convertSecretKeyToCurve25519, ed25519PairFromSeed as ed25519FromSeed, ed25519Sign, ethereumEncode, keccakAsU8a, keyExtractPath, keyFromPath, naclOpen, naclSeal, secp256k1Compress, secp256k1Expand, secp256k1PairFromSeed as secp256k1FromSeed, secp256k1Sign, signatureVerify, sr25519PairFromSeed as sr25519FromSeed, sr25519Sign, sr25519VrfSign, sr25519VrfVerify } from '@polkadot/util-crypto';
import { decodePair } from './decode';
import { encodePair } from './encode';
import { pairToJson } from './toJson';
import { decodePair } from './decode.js';
import { encodePair } from './encode.js';
import { pairToJson } from './toJson.js';
interface Setup {
toSS58: (publicKey: Uint8Array) => string;

View File

@@ -1,7 +1,7 @@
// Copyright 2017-2023 @polkadot/keyring authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { KeyringPair, KeyringPair$Json, KeyringPair$Meta } from '../types';
import type { KeyringPair, KeyringPair$Json, KeyringPair$Meta } from '../types.js';
// empty publicKey
const publicKey = new Uint8Array(32);

View File

@@ -3,7 +3,7 @@
/// <reference types="@polkadot/dev/node/test/node" />
import { createTestPairs } from '../testingPairs';
import { createTestPairs } from '../testingPairs.js';
const keyring = createTestPairs({ type: 'ed25519' }, false);

View File

@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import type { KeypairType } from '@polkadot/util-crypto/types';
import type { KeyringPair$Json, KeyringPair$Meta } from '../types';
import type { KeyringPair$Json, KeyringPair$Meta } from '../types.js';
import { objectSpread } from '@polkadot/util';
import { jsonEncryptFormat } from '@polkadot/util-crypto';

View File

@@ -6,7 +6,7 @@
import { u8aToHex } from '@polkadot/util';
import { cryptoWaitReady, ed25519PairFromSeed, encodeAddress as toSS58, randomAsU8a, secp256k1PairFromSeed, sr25519PairFromSeed } from '@polkadot/util-crypto';
import { createPair } from '.';
import { createPair } from './index.js';
const MESSAGE = 'this is a test message';
const CONTEXT = 'some context';

View File

@@ -10,7 +10,7 @@ import type { KeypairType } from '@polkadot/util-crypto/types';
import { u8aToHex } from '@polkadot/util';
import { cryptoWaitReady } from '@polkadot/util-crypto';
import Keyring from '.';
import Keyring from './index.js';
const PHRASE = 'bottom drive obey lake curtain smoke basket hold race lonely fit walk';
const ETHEREUM_PHRASE = 'seed sock milk update focus rotate barely fade car face mechanic mercy';

View File

@@ -7,8 +7,8 @@ import type { KeyringInstance, KeyringOptions } from './types';
import { hexToU8a } from '@polkadot/util';
import { Keyring } from './keyring';
import { createPair } from './pair';
import { createPair } from './pair/index.js';
import { Keyring } from './keyring.js';
interface PairDef {
name?: string;

View File

@@ -6,8 +6,8 @@
import { u8aToHex } from '@polkadot/util';
import { cryptoWaitReady } from '@polkadot/util-crypto';
import { createTestPairs } from './testingPairs';
import Keyring from '.';
import Keyring from './index.js';
import { createTestPairs } from './testingPairs.js';
const TEST_ADD = '0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac';

View File

@@ -3,8 +3,8 @@
import type { KeyringOptions, KeyringPair } from './types';
import { nobody } from './pair/nobody';
import { createTestKeyring } from './testing';
import { nobody } from './pair/nobody.js';
import { createTestKeyring } from './testing.js';
export interface TestKeyringMap {
[index: string]: KeyringPair;

View File

@@ -6,7 +6,7 @@
import { ledgerApps } from '@polkadot/hw-ledger/defaults';
import { isHex } from '@polkadot/util';
import { knownGenesis, knownLedger } from './defaults';
import { knownGenesis, knownLedger } from './defaults/index.js';
describe('defaults', (): void => {
describe('genesis', (): void => {

View File

@@ -1,7 +1,7 @@
// Copyright 2017-2023 @polkadot/networks authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { KnownGenesis } from '../types';
import type { KnownGenesis } from '../types.js';
// NOTE: In the case where the network was hard-spooned and multiple genesisHashes
// are provided, it needs to be in reverse order, i.e. most-recent first, oldest

View File

@@ -1,7 +1,7 @@
// Copyright 2017-2023 @polkadot/networks authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { KnownIcon } from '../types';
import type { KnownIcon } from '../types.js';
// these are icon overrides
export const knownIcon: KnownIcon = {

View File

@@ -1,7 +1,7 @@
// Copyright 2017-2023 @polkadot/networks authors & contributors
// SPDX-License-Identifier: Apache-2.0
export { knownGenesis } from './genesis';
export { knownIcon } from './icons';
export { knownLedger } from './ledger';
export { knownTestnet } from './testnets';
export { knownGenesis } from './genesis.js';
export { knownIcon } from './icons.js';
export { knownLedger } from './ledger.js';
export { knownTestnet } from './testnets.js';

View File

@@ -1,7 +1,7 @@
// Copyright 2017-2023 @polkadot/networks authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { KnownLedger } from '../types';
import type { KnownLedger } from '../types.js';
// These match up with the keys of the ledgerApps object in the @polkadot/hw-ledger/defaults.ts
// and maps to the known slip44 (minus the `0x8` hard derivation flag)

View File

@@ -1,7 +1,7 @@
// Copyright 2017-2023 @polkadot/networks authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { KnownTestnet } from '../types';
import type { KnownTestnet } from '../types.js';
// testnets should not allow selection
export const knownTestnet: KnownTestnet = {

View File

@@ -5,7 +5,7 @@
import { detectPackage } from '@polkadot/util';
import others from './detectOther';
import { packageInfo } from './packageInfo';
import others from './detectOther.js';
import { packageInfo } from './packageInfo.js';
detectPackage(packageInfo, null, others);

View File

@@ -3,10 +3,10 @@
/// <reference types="@polkadot/dev/node/test/node" />
import type { SubstrateNetwork } from './types';
import type { SubstrateNetwork } from './types.js';
import { knownGenesis, knownIcon, knownLedger, knownTestnet } from './defaults';
import { allNetworks, availableNetworks, selectableNetworks } from '.';
import { knownGenesis, knownIcon, knownLedger, knownTestnet } from './defaults/index.js';
import { allNetworks, availableNetworks, selectableNetworks } from './index.js';
describe('availableNetworks', (): void => {
it('has the correct starting order', (): void => {

View File

@@ -5,5 +5,5 @@
// ... put it back, but keep it removed
// import './detectPackage';
export * from './interfaces';
export { packageInfo } from './packageInfo';
export * from './interfaces.js';
export { packageInfo } from './packageInfo.js';

View File

@@ -1,11 +1,11 @@
// Copyright 2017-2023 @polkadot/networks authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { KnownSubstrate, Network, SubstrateNetwork } from './types';
import type { KnownSubstrate, Network, SubstrateNetwork } from './types.js';
import knownSubstrate from '@substrate/ss58-registry';
import { knownGenesis, knownIcon, knownLedger, knownTestnet } from './defaults';
import { knownGenesis, knownIcon, knownLedger, knownTestnet } from './defaults/index.js';
// These are known prefixes that are not sorted
const UNSORTED = [0, 2, 42];

View File

@@ -1,4 +1,4 @@
// Copyright 2017-2023 @polkadot/networks authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './index';
export * from './index.js';

View File

@@ -5,7 +5,7 @@
import { hexToU8a } from '@polkadot/util';
import { addressToEvm } from './addressToEvm';
import { addressToEvm } from './addressToEvm.js';
describe('addressToEvm', (): void => {
it('creates a valid known EVM address', (): void => {

View File

@@ -3,7 +3,7 @@
import type { HexString } from '@polkadot/util/types';
import { decodeAddress } from './decode';
import { decodeAddress } from './decode.js';
/**
* @name addressToEvm

View File

@@ -3,7 +3,7 @@
/// <reference types="@polkadot/dev/node/test/node" />
import { checkAddress } from '.';
import { checkAddress } from './index.js';
describe('checkAddress', (): void => {
it('returns [true, null] for Kusama', (): void => {

View File

@@ -4,9 +4,9 @@
import type { HexString } from '@polkadot/util/types';
import type { Prefix } from './types';
import { base58Decode } from '../base58';
import { checkAddressChecksum } from './checksum';
import { defaults } from './defaults';
import { base58Decode } from '../base58/index.js';
import { checkAddressChecksum } from './checksum.js';
import { defaults } from './defaults.js';
/**
* @name checkAddress

View File

@@ -3,8 +3,8 @@
/// <reference types="@polkadot/dev/node/test/node" />
import { base58Decode } from '../base58';
import { checkAddressChecksum } from './checksum';
import { base58Decode } from '../base58/index.js';
import { checkAddressChecksum } from './checksum.js';
describe('checkAddressChecksum', (): void => {
it('correctly extracts the info from a 1-byte-prefix address', (): void => {

View File

@@ -1,7 +1,7 @@
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { sshash } from './sshash';
import { sshash } from './sshash.js';
export function checkAddressChecksum (decoded: Uint8Array): [boolean, number, number, number] {
const ss58Length = (decoded[0] & 0b0100_0000) ? 2 : 1;

View File

@@ -5,8 +5,8 @@
import { hexToU8a, stringToU8a, u8aToHex } from '@polkadot/util';
import { ALICE_PUBLIC_SR } from './encode.spec';
import { decodeAddress } from '.';
import { ALICE_PUBLIC_SR } from './encode.spec.js';
import { decodeAddress } from './index.js';
describe('decodeAddress', (): void => {
it('decodes an address', (): void => {

View File

@@ -7,9 +7,9 @@ import type { Prefix } from './types';
// Original implementation: https://github.com/paritytech/polka-ui/blob/4858c094684769080f5811f32b081dd7780b0880/src/polkadot.js#L6
import { isHex, isU8a, u8aToU8a } from '@polkadot/util';
import { base58Decode } from '../base58';
import { checkAddressChecksum } from './checksum';
import { defaults } from './defaults';
import { base58Decode } from '../base58/index.js';
import { checkAddressChecksum } from './checksum.js';
import { defaults } from './defaults.js';
export function decodeAddress (encoded?: HexString | string | Uint8Array | null, ignoreChecksum?: boolean, ss58Format: Prefix = -1): Uint8Array {
if (!encoded) {

View File

@@ -1,7 +1,7 @@
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { availableNetworks } from '../networks';
import { availableNetworks } from '../networks.js';
export const defaults = {
allowedDecodedLengths: [1, 2, 4, 8, 32, 33],

View File

@@ -5,7 +5,7 @@
import { waitReady } from '@polkadot/wasm-crypto';
import { deriveAddress } from '.';
import { deriveAddress } from './index.js';
describe('deriveAddress', (): void => {
beforeEach(async (): Promise<void> => {

View File

@@ -5,10 +5,10 @@ import type { HexString } from '@polkadot/util/types';
import type { DeriveJunction } from '../key/DeriveJunction';
import type { Prefix } from './types';
import { keyExtractPath } from '../key';
import { sr25519DerivePublic } from '../sr25519';
import { decodeAddress } from './decode';
import { encodeAddress } from './encode';
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 }: DeriveJunction): boolean {
return isHard;

View File

@@ -3,7 +3,7 @@
/// <reference types="@polkadot/dev/node/test/node" />
import { encodeAddress } from '.';
import { encodeAddress } from './index.js';
export const ALICE_PUBLIC_SR = new Uint8Array([212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125]);

View File

@@ -7,10 +7,10 @@ import type { Prefix } from './types';
// Original implementation: https://github.com/paritytech/polka-ui/blob/4858c094684769080f5811f32b081dd7780b0880/src/polkadot.js#L34
import { u8aConcat } from '@polkadot/util';
import { base58Encode } from '../base58';
import { decodeAddress } from './decode';
import { defaults } from './defaults';
import { sshash } from './sshash';
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: HexString | Uint8Array | string, ss58Format: Prefix = defaults.prefix): string {
// decode it, this means we can re-encode an address

View File

@@ -3,7 +3,7 @@
/// <reference types="@polkadot/dev/node/test/node" />
import { encodeDerivedAddress } from '.';
import { encodeDerivedAddress } from './index.js';
describe('encodeDerivedAddress', (): void => {
it('creates a valid known derived address', (): void => {

View File

@@ -5,9 +5,9 @@ import type { BN } from '@polkadot/util';
import type { HexString } from '@polkadot/util/types';
import type { Prefix } from './types';
import { decodeAddress } from './decode';
import { encodeAddress } from './encode';
import { createKeyDerived } from './keyDerived';
import { decodeAddress } from './decode.js';
import { encodeAddress } from './encode.js';
import { createKeyDerived } from './keyDerived.js';
/**
* @name encodeDerivedAddress

View File

@@ -3,7 +3,7 @@
/// <reference types="@polkadot/dev/node/test/node" />
import { encodeMultiAddress } from '.';
import { encodeMultiAddress } from './index.js';
describe('encodeMultiAddress', (): void => {
it('creates a valid known multi address', (): void => {

View File

@@ -5,8 +5,8 @@ import type { BN } from '@polkadot/util';
import type { HexString } from '@polkadot/util/types';
import type { Prefix } from './types';
import { encodeAddress } from './encode';
import { createKeyMulti } from './keyMulti';
import { encodeAddress } from './encode.js';
import { createKeyMulti } from './keyMulti.js';
/**
* @name encodeMultiAddress

View File

@@ -3,8 +3,8 @@
/// <reference types="@polkadot/dev/node/test/node" />
import { ALICE_PUBLIC_SR } from './encode.spec';
import { addressEq } from '.';
import { ALICE_PUBLIC_SR } from './encode.spec.js';
import { addressEq } from './index.js';
describe('addressEq', (): void => {
it('returns false with non-equal', (): void => {

View File

@@ -5,7 +5,7 @@ import type { HexString } from '@polkadot/util/types';
import { u8aEq } from '@polkadot/util';
import { decodeAddress } from './decode';
import { decodeAddress } from './decode.js';
/**
* @name addressEq

View File

@@ -3,7 +3,7 @@
/// <reference types="@polkadot/dev/node/test/node" />
import { evmToAddress } from '.';
import { evmToAddress } from './index.js';
describe('evmToAddress', (): void => {
it('creates a valid known SS58 address', (): void => {

View File

@@ -7,8 +7,8 @@ import type { Prefix } from './types';
import { u8aConcat } from '@polkadot/util';
import { hasher } from '../secp256k1/hasher';
import { encodeAddress } from './encode';
import { hasher } from '../secp256k1/hasher.js';
import { encodeAddress } from './encode.js';
/**
* @name evmToAddress

View File

@@ -1,21 +1,21 @@
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
export { addressToEvm } from './addressToEvm';
export { checkAddress } from './check';
export { checkAddressChecksum } from './checksum';
export { createKeyMulti } from './keyMulti';
export { createKeyDerived } from './keyDerived';
export { decodeAddress } from './decode';
export { deriveAddress } from './derive';
export { encodeAddress } from './encode';
export { encodeDerivedAddress } from './encodeDerived';
export { encodeMultiAddress } from './encodeMulti';
export { evmToAddress } from './evmToAddress';
export { addressEq } from './eq';
export { isAddress } from './is';
export { sortAddresses } from './sort';
export { validateAddress } from './validate';
export { addressToEvm } from './addressToEvm.js';
export { checkAddress } from './check.js';
export { checkAddressChecksum } from './checksum.js';
export { createKeyMulti } from './keyMulti.js';
export { createKeyDerived } from './keyDerived.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 { evmToAddress } from './evmToAddress.js';
export { addressEq } from './eq.js';
export { isAddress } from './is.js';
export { sortAddresses } from './sort.js';
export { validateAddress } from './validate.js';
// eslint-disable-next-line deprecation/deprecation
export { setSS58Format } from './setSS58Format';
export { setSS58Format } from './setSS58Format.js';

View File

@@ -3,7 +3,7 @@
/// <reference types="@polkadot/dev/node/test/node" />
import { isAddress } from '.';
import { isAddress } from './index.js';
describe('isAddress', (): void => {
it('decodes an address', (): void => {

View File

@@ -4,7 +4,7 @@
import type { HexString } from '@polkadot/util/types';
import type { Prefix } from './types';
import { validateAddress } from './validate';
import { validateAddress } from './validate.js';
export function isAddress (address?: HexString | string | null, ignoreChecksum?: boolean, ss58Format?: Prefix): address is string {
try {

View File

@@ -3,7 +3,7 @@
/// <reference types="@polkadot/dev/node/test/node" />
import { createKeyDerived } from '.';
import { createKeyDerived } from './index.js';
describe('createKeyDerived', (): void => {
it('matches sub accounts with Rust', (): void => {

View File

@@ -6,9 +6,9 @@ import type { HexString } from '@polkadot/util/types';
import { bnToU8a, stringToU8a, u8aConcat } from '@polkadot/util';
import { blake2AsU8a } from '../blake2/asU8a';
import { BN_LE_16_OPTS } from '../bn';
import { decodeAddress } from './decode';
import { blake2AsU8a } from '../blake2/asU8a.js';
import { BN_LE_16_OPTS } from '../bn.js';
import { decodeAddress } from './decode.js';
const PREFIX = stringToU8a('modlpy/utilisuba');

View File

@@ -3,7 +3,7 @@
/// <reference types="@polkadot/dev/node/test/node" />
import { createKeyMulti } from '.';
import { createKeyMulti } from './index.js';
describe('createKeyMulti', (): void => {
it('creates a valid multikey (aligning with Rust, needs sorting)', (): void => {

View File

@@ -6,9 +6,9 @@ import type { HexString } from '@polkadot/util/types';
import { bnToU8a, compactToU8a, stringToU8a, u8aConcat, u8aSorted } from '@polkadot/util';
import { blake2AsU8a } from '../blake2/asU8a';
import { BN_LE_16_OPTS } from '../bn';
import { addressToU8a } from './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');

View File

@@ -3,7 +3,7 @@
/// <reference types="@polkadot/dev/node/test/node" />
import { encodeAddress, setSS58Format } from '.';
import { encodeAddress, setSS58Format } from './index.js';
describe('setSS58Format', (): void => {
beforeEach((): void => {

View File

@@ -5,7 +5,7 @@ import type { Prefix } from './types';
import { logger } from '@polkadot/util';
import { defaults } from './defaults';
import { defaults } from './defaults.js';
const l = logger('setSS58Format');

View File

@@ -3,7 +3,7 @@
/// <reference types="@polkadot/dev/node/test/node" />
import { sortAddresses } from '.';
import { sortAddresses } from './index.js';
describe('sortAddresses', (): void => {
it('sorts addresses by the publicKeys', (): void => {

View File

@@ -6,8 +6,8 @@ import type { Prefix } from './types';
import { u8aSorted } from '@polkadot/util';
import { encodeAddress } from './encode';
import { addressToU8a } from './util';
import { encodeAddress } from './encode.js';
import { addressToU8a } from './util.js';
export function sortAddresses (addresses: (HexString | Uint8Array | string)[], ss58Format?: Prefix): string[] {
const u8aToAddress = (u8a: Uint8Array) => encodeAddress(u8a, ss58Format);

View File

@@ -3,7 +3,7 @@
import { stringToU8a, u8aConcat } from '@polkadot/util';
import { blake2AsU8a } from '../blake2/asU8a';
import { blake2AsU8a } from '../blake2/asU8a.js';
const SS58_PREFIX = stringToU8a('SS58PRE');

View File

@@ -1,7 +1,7 @@
// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { decodeAddress } from './decode';
import { decodeAddress } from './decode.js';
export function addressToU8a (who: string | Uint8Array): Uint8Array {
return decodeAddress(who);

View File

@@ -3,7 +3,7 @@
/// <reference types="@polkadot/dev/node/test/node" />
import { validateAddress } from '.';
import { validateAddress } from './index.js';
describe('validateAddress', (): void => {
it('decodes an address', (): void => {

View File

@@ -4,7 +4,7 @@
import type { HexString } from '@polkadot/util/types';
import type { Prefix } from './types';
import { decodeAddress } from './decode';
import { decodeAddress } from './decode.js';
export function validateAddress (encoded?: HexString | string | null, ignoreChecksum?: boolean, ss58Format?: Prefix): encoded is string {
return !!decodeAddress(encoded, ignoreChecksum, ss58Format);

View File

@@ -3,7 +3,7 @@
import { utils } from '@scure/base';
import { createDecode, createEncode, createIs, createValidate } from './helpers';
import { createDecode, createEncode, createIs, createValidate } from './helpers.js';
const chars = 'abcdefghijklmnopqrstuvwxyz234567';

View File

@@ -5,7 +5,7 @@
import { u8aToString } from '@polkadot/util';
import { base32Decode } from '.';
import { base32Decode } from './index.js';
describe('base32Decode', (): void => {
it('decodes a base32', (): void => {

View File

@@ -3,8 +3,8 @@
/// <reference types="@polkadot/dev/node/test/node" />
import { base58Decode } from '../base58';
import { base32Encode } from '.';
import { base58Decode } from '../base58/index.js';
import { base32Encode } from './index.js';
describe('base32Encode', (): void => {
it('encodes to a base32', (): void => {

View File

@@ -5,4 +5,4 @@
* @summary Encode and decode base32 values
*/
export { base32Decode, base32Encode, base32Validate, isBase32 } from './bs32';
export { base32Decode, base32Encode, base32Validate, isBase32 } from './bs32.js';

View File

@@ -3,7 +3,7 @@
/// <reference types="@polkadot/dev/node/test/node" />
import { isBase32 } from '.';
import { isBase32 } from './index.js';
describe('isBase32', (): void => {
it('validates encoded', (): void => {

View File

@@ -3,7 +3,7 @@
/// <reference types="@polkadot/dev/node/test/node" />
import { base32Validate } from '.';
import { base32Validate } from './index.js';
describe('base32Validate', (): void => {
it('validates encoded', (): void => {

View File

@@ -3,7 +3,7 @@
import { base58 } from '@scure/base';
import { createDecode, createEncode, createIs, createValidate } from '../base32/helpers';
import { createDecode, createEncode, createIs, createValidate } from '../base32/helpers.js';
const config = {
chars: '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz',

View File

@@ -3,8 +3,8 @@
/// <reference types="@polkadot/dev/node/test/node" />
import { base32Decode } from '../base32';
import { base58Decode } from './';
import { base32Decode } from '../base32/index.js';
import { base58Decode } from './index.js';
describe('base58Encode', (): void => {
it('encodes a base58 to a base32', (): void => {

View File

@@ -3,8 +3,8 @@
/// <reference types="@polkadot/dev/node/test/node" />
import { base32Decode } from '../base32';
import { base58Encode } from './';
import { base32Decode } from '../base32/index.js';
import { base58Encode } from './index.js';
describe('base58Encode', (): void => {
it('encodes a base32 to a base58', (): void => {

View File

@@ -5,4 +5,4 @@
* @summary Encode and decode base58 values
*/
export { base58Decode, base58Encode, base58Validate, isBase58 } from './bs58';
export { base58Decode, base58Encode, base58Validate, isBase58 } from './bs58.js';

View File

@@ -3,7 +3,7 @@
import { base64 } from '@scure/base';
import { createDecode, createEncode, createIs, createValidate } from '../base32/helpers';
import { createDecode, createEncode, createIs, createValidate } from '../base32/helpers.js';
const config = {
chars: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',

View File

@@ -5,7 +5,7 @@
import { stringToU8a } from '@polkadot/util';
import { base64Decode } from '.';
import { base64Decode } from './index.js';
describe('base64Decode', (): void => {
it('decodes a mixed base64 utf8 string (1)', (): void => {

View File

@@ -3,7 +3,7 @@
/// <reference types="@polkadot/dev/node/test/node" />
import { base64Encode } from '.';
import { base64Encode } from './index.js';
describe('base64Encode', (): void => {
it('encodes a mixed base64 utf8 string', (): void => {

View File

@@ -5,6 +5,6 @@
* @summary Encode and decode base64 values
*/
export { base64Decode, base64Encode, base64Validate, isBase64 } from './bs64';
export { base64Pad } from './pad';
export { base64Trim } from './trim';
export { base64Decode, base64Encode, base64Validate, isBase64 } from './bs64.js';
export { base64Pad } from './pad.js';
export { base64Trim } from './trim.js';

View File

@@ -3,7 +3,7 @@
/// <reference types="@polkadot/dev/node/test/node" />
import { base64Pad } from '.';
import { base64Pad } from './index.js';
describe('base64Pad', (): void => {
it('pads a utf-8 string', (): void => {

View File

@@ -3,7 +3,7 @@
/// <reference types="@polkadot/dev/node/test/node" />
import { base64Trim } from '.';
import { base64Trim } from './index.js';
describe('base64Trim', (): void => {
it('trims a utf-8 string', (): void => {

View File

@@ -3,7 +3,7 @@
/// <reference types="@polkadot/dev/node/test/node" />
import { base64Validate } from '.';
import { base64Validate } from './index.js';
describe('base64Validate', (): void => {
it('validates a mixed base64 utf8 string', (): void => {

View File

@@ -6,7 +6,7 @@
import { hexToU8a } from '@polkadot/util';
import { waitReady } from '@polkadot/wasm-crypto';
import { blake2AsHex } from '.';
import { blake2AsHex } from './index.js';
describe('blake2AsHex', (): void => {
beforeEach(async (): Promise<void> => {

View File

@@ -6,8 +6,8 @@
import { hexToU8a } from '@polkadot/util';
import { waitReady } from '@polkadot/wasm-crypto';
import { perfWasm } from '../test';
import { blake2AsU8a } from '.';
import { perfWasm } from '../test/index.js';
import { blake2AsU8a } from './index.js';
describe('blake2AsU8a', (): void => {
beforeEach(async (): Promise<void> => {

View File

@@ -8,7 +8,7 @@ import { blake2b as blake2bJs } from '@noble/hashes/blake2b';
import { hasBigInt, u8aToU8a } from '@polkadot/util';
import { blake2b, isReady } from '@polkadot/wasm-crypto';
import { createAsHex } from '../helpers';
import { createAsHex } from '../helpers.js';
/**
* @name blake2AsU8a

View File

@@ -5,4 +5,4 @@
* @summary Create blake2b values with specified bitlengths
*/
export { blake2AsHex, blake2AsU8a } from './asU8a';
export { blake2AsHex, blake2AsU8a } from './asU8a.js';

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