Use .js imports in src (#5526)

* Use .js imports in src

* Adjust

* Fix imports

* Bump dev

* Adjust with .js imports for typegen

* Adjust

* Adjust

* Remove target override
This commit is contained in:
Jaco
2023-03-09 12:19:12 +02:00
committed by GitHub
parent f233671c27
commit 9fe2798b70
754 changed files with 1873 additions and 1871 deletions
+9 -9
View File
@@ -10,9 +10,9 @@ import type { DecoratedMeta } from '@polkadot/types/metadata/decorate/types';
import type { StorageEntry } from '@polkadot/types/primitive/types';
import type { AnyFunction, AnyJson, AnyTuple, CallFunction, Codec, DefinitionCallNamed, DefinitionRpc, DefinitionRpcSub, DefinitionsCall, DefinitionsCallEntry, DetectCodec, IMethod, IStorageKey, Registry, RegistryError, RegistryTypes } from '@polkadot/types/types';
import type { HexString } from '@polkadot/util/types';
import type { SubmittableExtrinsic } from '../submittable/types';
import type { ApiDecoration, ApiInterfaceRx, ApiOptions, ApiTypes, AugmentedQuery, DecoratedErrors, DecoratedEvents, DecoratedRpc, DecorateMethod, GenericStorageEntryFunction, PaginationOptions, QueryableConsts, QueryableStorage, QueryableStorageEntry, QueryableStorageEntryAt, QueryableStorageMulti, QueryableStorageMultiArg, SubmittableExtrinsicFunction, SubmittableExtrinsics } from '../types';
import type { VersionedRegistry } from './types';
import type { SubmittableExtrinsic } from '../submittable/types.js';
import type { ApiDecoration, ApiInterfaceRx, ApiOptions, ApiTypes, AugmentedQuery, DecoratedErrors, DecoratedEvents, DecoratedRpc, DecorateMethod, GenericStorageEntryFunction, PaginationOptions, QueryableConsts, QueryableStorage, QueryableStorageEntry, QueryableStorageEntryAt, QueryableStorageMulti, QueryableStorageMultiArg, SubmittableExtrinsicFunction, SubmittableExtrinsics } from '../types/index.js';
import type { VersionedRegistry } from './types.js';
import { BehaviorSubject, combineLatest, from, map, of, switchMap, tap, toArray } from 'rxjs';
@@ -24,12 +24,12 @@ import { getSpecRuntime } from '@polkadot/types-known';
import { arrayChunk, arrayFlatten, assertReturn, BN, compactStripLength, lazyMethod, lazyMethods, logger, nextTick, objectSpread, stringCamelCase, stringUpperFirst, u8aConcatStrict, u8aToHex } from '@polkadot/util';
import { blake2AsHex } from '@polkadot/util-crypto';
import { createSubmittable } from '../submittable';
import { augmentObject } from '../util/augmentObject';
import { AllDerives, decorateDeriveSections } from '../util/decorate';
import { extractStorageArgs } from '../util/validate';
import { Events } from './Events';
import { findCall, findError } from './find';
import { createSubmittable } from '../submittable/index.js';
import { augmentObject } from '../util/augmentObject.js';
import { AllDerives, decorateDeriveSections } from '../util/decorate.js';
import { extractStorageArgs } from '../util/validate.js';
import { Events } from './Events.js';
import { findCall, findError } from './find.js';
interface MetaDecoration {
callIndex?: Uint8Array;
+1 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2023 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ApiInterfaceEvents } from '../types';
import type { ApiInterfaceEvents } from '../types/index.js';
import EventEmitter from 'eventemitter3';
+4 -4
View File
@@ -7,11 +7,11 @@ import type { Text } from '@polkadot/types';
import type { Hash, RuntimeVersion } from '@polkadot/types/interfaces';
import type { Metadata } from '@polkadot/types/metadata';
import type { CallFunction, RegistryError } from '@polkadot/types/types';
import type { ApiDecoration, ApiInterfaceRx, ApiTypes, DecoratedErrors, DecoratedEvents, DecoratedRpc, QueryableCalls, QueryableConsts, QueryableStorage, QueryableStorageMulti, SubmittableExtrinsics } from '../types';
import type { ApiDecoration, ApiInterfaceRx, ApiTypes, DecoratedErrors, DecoratedEvents, DecoratedRpc, QueryableCalls, QueryableConsts, QueryableStorage, QueryableStorageMulti, SubmittableExtrinsics } from '../types/index.js';
import { packageInfo } from '../packageInfo';
import { findCall, findError } from './find';
import { Init } from './Init';
import { packageInfo } from '../packageInfo.js';
import { findCall, findError } from './find.js';
import { Init } from './Init.js';
interface PkgJson {
name: string;
+3 -3
View File
@@ -8,8 +8,8 @@ import type { ChainProperties, Hash, HeaderPartial, RuntimeVersion, RuntimeVersi
import type { Registry } from '@polkadot/types/types';
import type { BN } from '@polkadot/util';
import type { HexString } from '@polkadot/util/types';
import type { ApiBase, ApiDecoration, ApiOptions, ApiTypes, DecorateMethod } from '../types';
import type { VersionedRegistry } from './types';
import type { ApiBase, ApiDecoration, ApiOptions, ApiTypes, DecorateMethod } from '../types/index.js';
import type { VersionedRegistry } from './types.js';
import { firstValueFrom, map, of, switchMap } from 'rxjs';
@@ -18,7 +18,7 @@ import { getSpecAlias, getSpecExtensions, getSpecHasher, getSpecRpc, getSpecType
import { assertReturn, BN_ZERO, isUndefined, logger, objectSpread, u8aEq, u8aToHex, u8aToU8a } from '@polkadot/util';
import { cryptoWaitReady } from '@polkadot/util-crypto';
import { Decorate } from './Decorate';
import { Decorate } from './Decorate.js';
const KEEPALIVE_INTERVAL = 10000;
const WITH_VERSION_SHORTCUT = false;
+2 -2
View File
@@ -2,11 +2,11 @@
// SPDX-License-Identifier: Apache-2.0
import type { SignerPayloadRawBase } from '@polkadot/types/types';
import type { ApiOptions, ApiTypes, DecorateMethod, Signer } from '../types';
import type { ApiOptions, ApiTypes, DecorateMethod, Signer } from '../types/index.js';
import { isString, objectSpread, u8aToHex, u8aToU8a } from '@polkadot/util';
import { Getters } from './Getters';
import { Getters } from './Getters.js';
interface KeyringSigner {
sign (message: Uint8Array): Uint8Array;
+1 -1
View File
@@ -5,7 +5,7 @@ import type { Metadata } from '@polkadot/types';
import type { RuntimeVersionPartial } from '@polkadot/types/interfaces';
import type { DecoratedMeta } from '@polkadot/types/metadata/decorate/types';
import type { Registry } from '@polkadot/types/types';
import type { ApiDecoration, ApiTypes } from '../types';
import type { ApiDecoration, ApiTypes } from '../types/index.js';
export interface VersionedRegistry<ApiType extends ApiTypes> {
counter: number;
+4 -4
View File
@@ -6,8 +6,8 @@ import '@polkadot/rpc-augment';
export { Keyring } from '@polkadot/keyring';
export { HttpProvider, ScProvider, WsProvider } from '@polkadot/rpc-provider';
export { packageInfo } from './packageInfo';
export { SubmittableResult } from './submittable';
export { packageInfo } from './packageInfo.js';
export { SubmittableResult } from './submittable/index.js';
export * from './promise';
export * from './rx';
export * from './promise/index.js';
export * from './rx/index.js';
+1 -1
View File
@@ -15,7 +15,7 @@ import { ApiPromise } from '@polkadot/api';
import { createTestPairs, TestKeyringMap } from '@polkadot/keyring/testingPairs';
import { createTypeUnsafe, TypeRegistry } from '@polkadot/types/create';
import { SubmittableResult } from './';
import { SubmittableResult } from './index.js';
const registry = new TypeRegistry();
+2 -2
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);
+2 -2
View File
@@ -1,6 +1,6 @@
// Copyright 2017-2023 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
import './detectPackage';
import './detectPackage.js';
export * from './bundle';
export * from './bundle.js';
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2017-2023 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './index';
export * from './index.js';
+4 -4
View File
@@ -1,13 +1,13 @@
// Copyright 2017-2023 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ApiOptions, UnsubscribePromise } from '../types';
import type { ApiOptions, UnsubscribePromise } from '../types/index.js';
import { objectSpread } from '@polkadot/util';
import { ApiBase } from '../base';
import { Combinator, CombinatorCallback, CombinatorFunction } from './Combinator';
import { promiseTracker, toPromiseMethod } from './decorateMethod';
import { ApiBase } from '../base/index.js';
import { Combinator, CombinatorCallback, CombinatorFunction } from './Combinator.js';
import { promiseTracker, toPromiseMethod } from './decorateMethod.js';
/**
* # @polkadot/api/promise
+1 -1
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import type { Callback } from '@polkadot/types/types';
import type { UnsubscribePromise } from '../types';
import type { UnsubscribePromise } from '../types/index.js';
import { isFunction } from '@polkadot/util';
+2 -2
View File
@@ -3,9 +3,9 @@
/// <reference types="@polkadot/dev/node/test/node" />
import type { UnsubscribePromise } from '../types';
import type { UnsubscribePromise } from '../types/index.js';
import { Combinator } from './Combinator';
import { Combinator } from './Combinator.js';
describe('Combinator', (): void => {
let fns: ((value: any) => void)[] = [];
+1 -1
View File
@@ -3,7 +3,7 @@
import type { Observable } from 'rxjs';
import type { Callback, Codec } from '@polkadot/types/types';
import type { DecorateFn, DecorateMethodOptions, ObsInnerType, StorageEntryPromiseOverloads, UnsubscribePromise, VoidFn } from '../types';
import type { DecorateFn, DecorateMethodOptions, ObsInnerType, StorageEntryPromiseOverloads, UnsubscribePromise, VoidFn } from '../types/index.js';
import { catchError, EMPTY, Subscription, tap } from 'rxjs';
+3 -3
View File
@@ -4,7 +4,7 @@
/// <reference types="@polkadot/dev/node/test/node" />
import type { HexString } from '@polkadot/util/types';
import type { SubmittableExtrinsic } from '../types';
import type { SubmittableExtrinsic } from '../types/index.js';
import { createPair } from '@polkadot/keyring/pair';
import { createTestKeyring } from '@polkadot/keyring/testing';
@@ -12,8 +12,8 @@ import { MockProvider } from '@polkadot/rpc-provider/mock';
import { TypeRegistry } from '@polkadot/types';
import { hexToU8a } from '@polkadot/util';
import { SingleAccountSigner } from '../test';
import { ApiPromise } from '.';
import { SingleAccountSigner } from '../test/index.js';
import { ApiPromise } from './index.js';
const TRANSFER_SIG = '0xcc277eb341d3801c08f149508221583fa3185cc3944e6cb376cd061640305edd7dc24dfd754adb24768f1d8547389b7720e6f626bc81f5593fba1141e7f7ba07';
+2 -2
View File
@@ -1,5 +1,5 @@
// Copyright 2017-2023 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
export { ApiPromise } from './Api';
export { toPromiseMethod } from './decorateMethod';
export { ApiPromise } from './Api.js';
export { toPromiseMethod } from './decorateMethod.js';
+1 -1
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import type { SubmittableExtrinsic as SubmittableExtrinsicBase } from '../submittable/types';
import type { QueryableStorageEntry as QueryableStorageEntryBase, SubmittableExtrinsicFunction as SubmittableExtrinsicFunctionBase } from '../types';
import type { QueryableStorageEntry as QueryableStorageEntryBase, SubmittableExtrinsicFunction as SubmittableExtrinsicFunctionBase } from '../types/index.js';
export type QueryableStorageEntry = QueryableStorageEntryBase<'promise'>;
export type SubmittableExtrinsic = SubmittableExtrinsicBase<'promise'>;
+3 -3
View File
@@ -1,14 +1,14 @@
// Copyright 2017-2023 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ApiOptions } from '../types';
import type { ApiOptions } from '../types/index.js';
import { from, Observable } from 'rxjs';
import { objectSpread } from '@polkadot/util';
import { ApiBase } from '../base';
import { toRxMethod } from './decorateMethod';
import { ApiBase } from '../base/index.js';
import { toRxMethod } from './decorateMethod.js';
/**
* # @polkadot/api/rx
+1 -1
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import type { Codec } from '@polkadot/types/types';
import type { DecorateFn } from '../types';
import type { DecorateFn } from '../types/index.js';
export function toRxMethod <M extends DecorateFn<Codec>> (method: M): M {
return method;
+2 -2
View File
@@ -1,5 +1,5 @@
// Copyright 2017-2023 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
export { ApiRx } from './Api';
export { toRxMethod } from './decorateMethod';
export { ApiRx } from './Api.js';
export { toRxMethod } from './decorateMethod.js';
+1 -1
View File
@@ -3,7 +3,7 @@
import type { BlockNumber, DispatchError, DispatchInfo, EventRecord, ExtrinsicStatus, Hash } from '@polkadot/types/interfaces';
import type { AnyJson, ISubmittableResult } from '@polkadot/types/types';
import type { SubmittableResultValue } from './types';
import type { SubmittableResultValue } from './types.js';
const recordIdentity = (record: EventRecord) => record;
+5 -5
View File
@@ -7,16 +7,16 @@ import type { Observable } from 'rxjs';
import type { Address, ApplyExtrinsicResult, Call, Extrinsic, ExtrinsicEra, ExtrinsicStatus, Hash, Header, Index, RuntimeDispatchInfo, SignerPayload } from '@polkadot/types/interfaces';
import type { Callback, Codec, Constructor, ISubmittableResult, SignatureOptions } from '@polkadot/types/types';
import type { Registry } from '@polkadot/types-codec/types';
import type { ApiInterfaceRx, ApiTypes, PromiseOrObs, SignerResult } from '../types';
import type { AddressOrPair, SignerOptions, SubmittableDryRunResult, SubmittableExtrinsic, SubmittablePaymentResult, SubmittableResultResult, SubmittableResultSubscription } from './types';
import type { ApiInterfaceRx, ApiTypes, PromiseOrObs, SignerResult } from '../types/index.js';
import type { AddressOrPair, SignerOptions, SubmittableDryRunResult, SubmittableExtrinsic, SubmittablePaymentResult, SubmittableResultResult, SubmittableResultSubscription } from './types.js';
import { catchError, first, map, mergeMap, of, switchMap, tap } from 'rxjs';
import { isBn, isFunction, isNumber, isString, isU8a, objectSpread } from '@polkadot/util';
import { ApiBase } from '../base';
import { filterEvents, isKeyringPair } from '../util';
import { SubmittableResult } from './Result';
import { ApiBase } from '../base/index.js';
import { filterEvents, isKeyringPair } from '../util/index.js';
import { SubmittableResult } from './Result.js';
interface SubmittableOptions<ApiType extends ApiTypes> {
api: ApiInterfaceRx;
@@ -3,11 +3,11 @@
import type { Call, Extrinsic } from '@polkadot/types/interfaces';
import type { Registry } from '@polkadot/types-codec/types';
import type { ApiInterfaceRx, ApiTypes } from '../types';
import type { SubmittableExtrinsic } from './types';
import type { ApiInterfaceRx, ApiTypes } from '../types/index.js';
import type { SubmittableExtrinsic } from './types.js';
import { ApiBase } from '../base';
import { createClass } from './createClass';
import { ApiBase } from '../base/index.js';
import { createClass } from './createClass.js';
type Creator<ApiType extends ApiTypes> = (extrinsic: Call | Uint8Array | string) => SubmittableExtrinsic<ApiType>;
+2 -2
View File
@@ -1,5 +1,5 @@
// Copyright 2017-2023 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
export { createSubmittable } from './createSubmittable';
export { SubmittableResult } from './Result';
export { createSubmittable } from './createSubmittable.js';
export { SubmittableResult } from './Result.js';
+2 -2
View File
@@ -1,5 +1,5 @@
// Copyright 2017-2023 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './logEvents';
export * from './SingleAccountSigner';
export * from './logEvents.js';
export * from './SingleAccountSigner.js';
+1 -1
View File
@@ -3,7 +3,7 @@
import type { EventRecord } from '@polkadot/types/interfaces';
import { SubmittableResult } from '..';
import { SubmittableResult } from '../index.js';
// log all events for the transfers, calling done() when finalized
export const logEvents = (done: () => Record<string, unknown>): (r: SubmittableResult) => void =>
+4 -4
View File
@@ -14,9 +14,9 @@ import type { Call, Extrinsic, Hash, RuntimeVersionPartial } from '@polkadot/typ
import type { CallFunction, DefinitionRpc, DefinitionRpcSub, DefinitionsCall, RegisteredTypes, Registry, RegistryError, SignatureOptions, Signer } from '@polkadot/types/types';
import type { BN } from '@polkadot/util';
import type { HexString } from '@polkadot/util/types';
import type { ApiBase } from '../base';
import type { SubmittableExtrinsic } from '../types/submittable';
import type { AllDerives } from '../util/decorate';
import type { ApiBase } from '../base/index.js';
import type { SubmittableExtrinsic } from '../types/submittable.js';
import type { AllDerives } from '../util/decorate.js';
export * from '@polkadot/api-base/types';
export * from '@polkadot/api/types/calls';
@@ -28,7 +28,7 @@ export * from '@polkadot/api/types/submittable';
export type { Signer, SignerResult } from '@polkadot/types/types';
export { ApiBase } from '../base';
export { ApiBase } from '../base/index.js';
// A smaller interface of ApiRx, used in derive and in SubmittableExtrinsic
export interface ApiInterfaceRx extends ApiInterfaceBase {
+1 -1
View File
@@ -3,7 +3,7 @@
/// <reference types="@polkadot/dev/node/test/node" />
import { augmentObject } from './augmentObject';
import { augmentObject } from './augmentObject.js';
describe('augmentObject', (): void => {
let spy: ReturnType<typeof jest.spyOn>;
+1 -1
View File
@@ -3,7 +3,7 @@
import type { ExactDerive } from '@polkadot/api-derive';
import type { AnyFunction } from '@polkadot/types/types';
import type { ApiTypes, DecorateMethod, MethodResult } from '../types';
import type { ApiTypes, DecorateMethod, MethodResult } from '../types/index.js';
import { lazyDeriveSection } from '@polkadot/api-derive';
+1 -1
View File
@@ -5,7 +5,7 @@ import type { BlockNumber, EventRecord, ExtrinsicStatus, H256, SignedBlock } fro
import { isCompact } from '@polkadot/util';
import { l } from './logging';
import { l } from './logging.js';
export function filterEvents (txHash: H256, { block: { extrinsics, header } }: SignedBlock, allEvents: EventRecord[], status: ExtrinsicStatus): { events?: EventRecord[], txIndex?: number, blockNumber?: BlockNumber } {
// extrinsics to hashes
+4 -4
View File
@@ -1,8 +1,8 @@
// Copyright 2017-2023 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './decorate';
export * from './decorate.js';
export { filterEvents } from './filterEvents';
export { isKeyringPair } from './isKeyringPair';
export { l } from './logging';
export { filterEvents } from './filterEvents.js';
export { isKeyringPair } from './isKeyringPair.js';
export { l } from './logging.js';
+1 -1
View File
@@ -6,7 +6,7 @@
import { decorateStorage, Metadata, TypeRegistry } from '@polkadot/types';
import metaStatic from '@polkadot/types-support/metadata/static-substrate';
import { extractStorageArgs } from './validate';
import { extractStorageArgs } from './validate.js';
describe('extractStorageArgs', (): void => {
const registry = new TypeRegistry();