From 3d4511607f8559a9acbc3b4aa28491605483d3a8 Mon Sep 17 00:00:00 2001 From: Jaco Date: Sun, 19 Dec 2021 20:30:34 +0100 Subject: [PATCH] API optional augmentation (#4355) * API optional augmentation * Rebuild * Rebuild * Cleanups * Adjust, no multi-imports * Adjust * Adjust * Dedupe * Augmented exports * It builds via references (no circulars) * Don't output *.manual.{js,cjs} --- package.json | 2 +- packages/api-augment/package.json | 4 +-- packages/api-augment/src/augment/api.ts | 31 ------------------- .../src/{tx.ts => augment/augment.ts} | 3 +- packages/api-augment/src/augment/consts.ts | 11 ++----- packages/api-augment/src/augment/errors.ts | 9 ++---- packages/api-augment/src/augment/events.ts | 9 ++---- packages/api-augment/src/augment/index.ts | 4 +-- packages/api-augment/src/augment/query.ts | 13 ++------ packages/api-augment/src/augment/tx.ts | 11 ++----- packages/api-augment/src/bundle.ts | 3 -- packages/api-augment/src/consts.ts | 5 --- packages/api-augment/src/detectPackage.ts | 4 +-- packages/api-augment/src/events.ts | 5 --- packages/api-augment/src/types.ts | 12 ------- packages/api-augment/tsconfig.json | 1 + packages/api-base/src/types/api.ts | 26 ++++++++++++++-- packages/api-base/src/types/base.ts | 2 +- packages/api-base/src/types/consts.ts | 12 ++++++- packages/api-base/src/types/derive.ts | 8 +++++ packages/api-base/src/types/errors.ts | 12 ++++++- packages/api-base/src/types/events.ts | 12 ++++++- packages/api-base/src/types/index.ts | 16 +++++----- packages/api-base/src/types/rpc.ts | 2 +- packages/api-base/src/types/storage.ts | 20 ++++++++++-- packages/api-base/src/types/submittable.ts | 17 ++++++++-- .../api-contract/src/checkTypes.manual.ts | 2 ++ packages/api-contract/tsconfig.json | 4 ++- packages/api-contract/tsconfig.spec.json | 4 ++- packages/api-derive/src/augment.ts | 1 - packages/api-derive/src/bundle.ts | 3 +- packages/api-derive/src/checkTypes.manual.ts | 2 +- packages/api-derive/src/derive.ts | 5 --- packages/api-derive/tsconfig.json | 5 +-- packages/api-derive/tsconfig.spec.json | 3 +- packages/api/src/base/Decorate.ts | 2 +- packages/api/src/checkTypes.manual.ts | 2 +- packages/api/src/test/util/index.ts | 2 +- .../api/src/{augment.ts => types/consts.ts} | 3 +- packages/api/src/types/errors.ts | 4 +++ packages/api/src/types/events.ts | 4 +++ packages/api/src/{types.ts => types/index.ts} | 24 ++++++++------ .../src/query.ts => api/src/types/storage.ts} | 3 +- .../src/types/submittable.ts} | 3 +- packages/api/tsconfig.json | 3 +- packages/api/tsconfig.spec.json | 2 +- packages/rpc-augment/src/augment/index.ts | 3 +- .../src/augment/{rpc.ts => jsonrpc.ts} | 5 ++- packages/rpc-augment/src/bundle.ts | 2 -- packages/rpc-augment/src/rpc.ts | 5 --- packages/rpc-augment/tsconfig.json | 4 +-- .../src/{augment.ts => checkTypes.manual.ts} | 0 packages/rpc-core/src/types.ts | 5 --- .../types.ts => rpc-core/src/types/base.ts} | 2 +- packages/rpc-core/src/types/index.ts | 8 +++++ packages/rpc-core/src/types/jsonrpc.ts | 7 +++++ packages/rpc-core/tsconfig.json | 2 +- packages/rpc-core/tsconfig.spec.json | 1 + packages/typegen/src/augment.ts | 5 +++ packages/typegen/src/generate/consts.ts | 2 +- packages/typegen/src/generate/errors.ts | 2 +- packages/typegen/src/generate/events.ts | 2 +- packages/typegen/src/generate/query.ts | 2 +- packages/typegen/src/generate/rpc.ts | 4 +-- packages/typegen/src/generate/tx.ts | 4 +-- packages/typegen/src/templates/consts.hbs | 11 ++----- packages/typegen/src/templates/errors.hbs | 9 +----- packages/typegen/src/templates/events.hbs | 9 +----- .../src/templates/interfaceRegistry.hbs | 2 +- .../typegen/src/templates/lookup/types.hbs | 6 ++-- packages/typegen/src/templates/query.hbs | 15 +-------- packages/typegen/src/templates/rpc.hbs | 3 +- packages/typegen/src/templates/tx.hbs | 10 +----- packages/types-augment/src/augment/index.ts | 3 +- .../src/augment/lookup/types-kusama.ts | 8 ++--- .../src/augment/lookup/types-polkadot.ts | 10 +++--- .../src/augment/lookup/types-substrate.ts | 14 ++++----- .../types-augment/src/augment/registry.ts | 2 +- .../types-augment/src/augment/types/index.ts | 7 ----- .../types-augment/src/augment/types/lookup.ts | 6 ---- .../src/augment/types/registry.ts | 6 ---- packages/types-codec/tsconfig.json | 2 +- packages/types-codec/tsconfig.spec.json | 2 +- packages/types-create/package.json | 1 + packages/types/tsconfig.json | 2 +- packages/types/tsconfig.spec.json | 2 +- tsconfig.full.json => tsconfig.all.files.json | 0 tsconfig.all.refs.json | 31 +++++++++++++++++++ tsconfig.json | 30 +----------------- yarn.lock | 13 ++++---- 90 files changed, 282 insertions(+), 322 deletions(-) delete mode 100644 packages/api-augment/src/augment/api.ts rename packages/api-augment/src/{tx.ts => augment/augment.ts} (65%) delete mode 100644 packages/api-augment/src/consts.ts delete mode 100644 packages/api-augment/src/events.ts delete mode 100644 packages/api-augment/src/types.ts create mode 100644 packages/api-base/src/types/derive.ts rename packages/api/src/{augment.ts => types/consts.ts} (59%) create mode 100644 packages/api/src/types/errors.ts create mode 100644 packages/api/src/types/events.ts rename packages/api/src/{types.ts => types/index.ts} (79%) rename packages/{api-augment/src/query.ts => api/src/types/storage.ts} (63%) rename packages/{api-augment/src/errors.ts => api/src/types/submittable.ts} (63%) rename packages/rpc-augment/src/augment/{rpc.ts => jsonrpc.ts} (99%) delete mode 100644 packages/rpc-augment/src/rpc.ts rename packages/rpc-core/src/{augment.ts => checkTypes.manual.ts} (100%) delete mode 100644 packages/rpc-core/src/types.ts rename packages/{rpc-augment/src/types.ts => rpc-core/src/types/base.ts} (87%) create mode 100644 packages/rpc-core/src/types/index.ts create mode 100644 packages/rpc-core/src/types/jsonrpc.ts create mode 100644 packages/typegen/src/augment.ts delete mode 100644 packages/types-augment/src/augment/types/index.ts delete mode 100644 packages/types-augment/src/augment/types/lookup.ts delete mode 100644 packages/types-augment/src/augment/types/registry.ts rename tsconfig.full.json => tsconfig.all.files.json (100%) create mode 100644 tsconfig.all.refs.json diff --git a/package.json b/package.json index 461b67d2ca..bcfff5a363 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "@babel/core": "^7.16.5", "@babel/register": "^7.16.5", "@babel/runtime": "^7.16.5", - "@polkadot/dev": "^0.64.5", + "@polkadot/dev": "^0.64.6", "@polkadot/ts": "^0.4.20", "@polkadot/typegen": "workspace:packages/typegen", "@types/jest": "^27.0.3", diff --git a/packages/api-augment/package.json b/packages/api-augment/package.json index ff85fcb3a8..0bd539e85b 100644 --- a/packages/api-augment/package.json +++ b/packages/api-augment/package.json @@ -25,7 +25,7 @@ "dependencies": { "@babel/runtime": "^7.16.5", "@polkadot/api-base": "6.12.2-20", - "@polkadot/rpc-core": "6.12.2-20", - "@polkadot/types": "6.12.2-20" + "@polkadot/types": "6.12.2-20", + "@polkadot/types-codec": "6.12.2-20" } } diff --git a/packages/api-augment/src/augment/api.ts b/packages/api-augment/src/augment/api.ts deleted file mode 100644 index 9679e7449b..0000000000 --- a/packages/api-augment/src/augment/api.ts +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2017-2021 @polkadot/api-augment authors & contributors -// SPDX-License-Identifier: Apache-2.0 - -import type { Observable } from 'rxjs'; -import type { QueryableConsts } from '@polkadot/api-augment/consts'; -import type { QueryableStorage } from '@polkadot/api-augment/query'; -import type { SubmittableExtrinsics } from '@polkadot/api-augment/tx'; -import type { DecoratedRpc, QueryableStorageMulti } from '@polkadot/api-base/types'; -import type { RpcInterface } from '@polkadot/rpc-core/types'; -import type { Metadata } from '@polkadot/types'; -import type { Hash, RuntimeVersion } from '@polkadot/types/interfaces'; -import type { Registry, Signer } from '@polkadot/types/types'; - -declare module '@polkadot/api-base/types/api' { - // A smaller interface of ApiRx, used in derive and in SubmittableExtrinsic - export interface ApiInterfaceRx { - consts: QueryableConsts<'rxjs'>; - extrinsicType: number; - genesisHash?: Hash; - hasSubscriptions: boolean; - registry: Registry; - runtimeMetadata: Metadata; - runtimeVersion: RuntimeVersion; - query: QueryableStorage<'rxjs'>; - queryAt: (blockHash: Uint8Array | string, knownVersion?: RuntimeVersion) => Observable>; - queryMulti: QueryableStorageMulti<'rxjs'>; - rpc: DecoratedRpc<'rxjs', RpcInterface>; - tx: SubmittableExtrinsics<'rxjs'>; - signer?: Signer; - } -} diff --git a/packages/api-augment/src/tx.ts b/packages/api-augment/src/augment/augment.ts similarity index 65% rename from packages/api-augment/src/tx.ts rename to packages/api-augment/src/augment/augment.ts index b3c31df710..0fde3a536c 100644 --- a/packages/api-augment/src/tx.ts +++ b/packages/api-augment/src/augment/augment.ts @@ -1,5 +1,4 @@ // Copyright 2017-2021 @polkadot/api-augment authors & contributors // SPDX-License-Identifier: Apache-2.0 -// augmented -export const __API_AUGMENT_TX = 'augmented'; +import '@polkadot/types-augment'; diff --git a/packages/api-augment/src/augment/consts.ts b/packages/api-augment/src/augment/consts.ts index ba7bae150f..266f264da2 100644 --- a/packages/api-augment/src/augment/consts.ts +++ b/packages/api-augment/src/augment/consts.ts @@ -1,14 +1,14 @@ // Auto-generated via `yarn polkadot-types-from-chain`, do not edit /* eslint-disable */ -import type { ApiTypes, AugmentedConst, QueryableModuleConsts } from '@polkadot/api-base/types'; +import type { ApiTypes } from '@polkadot/api-base/types'; import type { U8aFixed, Vec, bool, u128, u16, u32, u64, u8 } from '@polkadot/types-codec'; import type { Codec } from '@polkadot/types-codec/types'; import type { Perbill, Percent, Permill } from '@polkadot/types/interfaces/runtime'; import type { FrameSupportPalletId, FrameSupportWeightsRuntimeDbWeight, FrameSupportWeightsWeightToFeeCoefficient, FrameSystemLimitsBlockLength, FrameSystemLimitsBlockWeights, PalletContractsSchedule, SpVersionRuntimeVersion } from '@polkadot/types/lookup'; -declare module '@polkadot/api-augment/consts' { - export interface AugmentedConsts { +declare module '@polkadot/api-base/types/consts' { + export interface AugmentedConsts { assets: { /** * The amount of funds that must be reserved when creating a new approval. @@ -951,9 +951,4 @@ declare module '@polkadot/api-augment/consts' { [key: string]: Codec; }; } // AugmentedConsts - - export interface QueryableConsts extends AugmentedConsts { - [key: string]: QueryableModuleConsts; - } // QueryableConsts - } // declare module diff --git a/packages/api-augment/src/augment/errors.ts b/packages/api-augment/src/augment/errors.ts index 1d63b4efc3..dcebc6ab03 100644 --- a/packages/api-augment/src/augment/errors.ts +++ b/packages/api-augment/src/augment/errors.ts @@ -1,9 +1,9 @@ // Auto-generated via `yarn polkadot-types-from-chain`, do not edit /* eslint-disable */ -import type { ApiTypes, AugmentedError, ModuleErrors } from '@polkadot/api-base/types'; +import type { ApiTypes } from '@polkadot/api-base/types'; -declare module '@polkadot/api-augment/errors' { +declare module '@polkadot/api-base/types/errors' { export interface AugmentedErrors { assets: { /** @@ -1559,9 +1559,4 @@ declare module '@polkadot/api-augment/errors' { [key: string]: AugmentedError; }; } // AugmentedErrors - - export interface DecoratedErrors extends AugmentedErrors { - [key: string]: ModuleErrors; - } // DecoratedErrors - } // declare module diff --git a/packages/api-augment/src/augment/events.ts b/packages/api-augment/src/augment/events.ts index ce954c457c..084f866fe6 100644 --- a/packages/api-augment/src/augment/events.ts +++ b/packages/api-augment/src/augment/events.ts @@ -1,13 +1,13 @@ // Auto-generated via `yarn polkadot-types-from-chain`, do not edit /* eslint-disable */ -import type { ApiTypes, AugmentedEvent, ModuleEvents } from '@polkadot/api-base/types'; +import type { ApiTypes } from '@polkadot/api-base/types'; import type { Bytes, Null, Option, Result, U8aFixed, Vec, bool, u128, u16, u32, u64, u8 } from '@polkadot/types-codec'; import type { ITuple } from '@polkadot/types-codec/types'; import type { AccountId32, H256 } from '@polkadot/types/interfaces/runtime'; import type { FrameSupportTokensMiscBalanceStatus, FrameSupportWeightsDispatchInfo, NodeRuntimeProxyType, PalletDemocracyVoteAccountVote, PalletDemocracyVoteThreshold, PalletElectionProviderMultiPhaseElectionCompute, PalletImOnlineSr25519AppSr25519Public, PalletMultisigTimepoint, PalletStakingExposure, SpFinalityGrandpaAppPublic, SpRuntimeDispatchError } from '@polkadot/types/lookup'; -declare module '@polkadot/api-augment/events' { +declare module '@polkadot/api-base/types/events' { export interface AugmentedEvents { assets: { /** @@ -1154,9 +1154,4 @@ declare module '@polkadot/api-augment/events' { [key: string]: AugmentedEvent; }; } // AugmentedEvents - - export interface DecoratedEvents extends AugmentedEvents { - [key: string]: ModuleEvents; - } // DecoratedEvents - } // declare module diff --git a/packages/api-augment/src/augment/index.ts b/packages/api-augment/src/augment/index.ts index bf9a7b8811..e1cd221ff2 100644 --- a/packages/api-augment/src/augment/index.ts +++ b/packages/api-augment/src/augment/index.ts @@ -1,12 +1,10 @@ // Copyright 2017-2021 @polkadot/api-augment authors & contributors // SPDX-License-Identifier: Apache-2.0 +import '@polkadot/rpc-augment'; import '@polkadot/types-augment'; import './consts'; import './errors'; import './events'; import './query'; import './tx'; -// these are external to this module -import './api'; -import './rpc'; diff --git a/packages/api-augment/src/augment/query.ts b/packages/api-augment/src/augment/query.ts index fe04a21ae7..c7cb78be89 100644 --- a/packages/api-augment/src/augment/query.ts +++ b/packages/api-augment/src/augment/query.ts @@ -1,7 +1,7 @@ // Auto-generated via `yarn polkadot-types-from-chain`, do not edit /* eslint-disable */ -import type { ApiTypes, AugmentedQuery, QueryableModuleStorage, QueryableModuleStorageAt, QueryableStorageEntry } from '@polkadot/api-base/types'; +import type { ApiTypes } from '@polkadot/api-base/types'; import type { Data } from '@polkadot/types'; import type { BTreeMap, Bytes, Null, Option, U8aFixed, Vec, WrapperOpaque, bool, u128, u32, u64, u8 } from '@polkadot/types-codec'; import type { AnyNumber, ITuple } from '@polkadot/types-codec/types'; @@ -9,7 +9,7 @@ import type { AccountId32, Call, H256, Perbill, Percent } from '@polkadot/types/ import type { FrameSupportWeightsPerDispatchClassU64, FrameSystemAccountInfo, FrameSystemEventRecord, FrameSystemLastRuntimeUpgradeInfo, FrameSystemPhase, NodeRuntimeSessionKeys, PalletAssetsApproval, PalletAssetsAssetBalance, PalletAssetsAssetDetails, PalletAssetsAssetMetadata, PalletAuthorshipUncleEntryItem, PalletBagsListListBag, PalletBagsListListNode, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesReleases, PalletBalancesReserveData, PalletBountiesBounty, PalletChildBountiesChildBounty, PalletCollectiveVotes, PalletContractsStorageDeletedContract, PalletContractsStorageRawContractInfo, PalletContractsWasmOwnerInfo, PalletContractsWasmPrefabWasmModule, PalletDemocracyPreimageStatus, PalletDemocracyReferendumInfo, PalletDemocracyReleases, PalletDemocracyVoteThreshold, PalletDemocracyVoteVoting, PalletElectionProviderMultiPhasePhase, PalletElectionProviderMultiPhaseReadySolution, PalletElectionProviderMultiPhaseRoundSnapshot, PalletElectionProviderMultiPhaseSignedSignedSubmission, PalletElectionProviderMultiPhaseSolutionOrSnapshotSize, PalletElectionsPhragmenSeatHolder, PalletElectionsPhragmenVoter, PalletGiltActiveGilt, PalletGiltActiveGiltsTotal, PalletGiltGiltBid, PalletGrandpaStoredPendingChange, PalletGrandpaStoredState, PalletIdentityRegistrarInfo, PalletIdentityRegistration, PalletImOnlineBoundedOpaqueNetworkState, PalletImOnlineSr25519AppSr25519Public, PalletLotteryLotteryConfig, PalletMultisigMultisig, PalletProxyAnnouncement, PalletProxyProxyDefinition, PalletRecoveryActiveRecovery, PalletRecoveryRecoveryConfig, PalletSchedulerReleases, PalletSchedulerScheduledV2, PalletSocietyBid, PalletSocietyBidKind, PalletSocietyVote, PalletSocietyVouchingStatus, PalletStakingActiveEraInfo, PalletStakingEraRewardPoints, PalletStakingExposure, PalletStakingForcing, PalletStakingNominations, PalletStakingReleases, PalletStakingRewardDestination, PalletStakingSlashingSlashingSpans, PalletStakingSlashingSpanRecord, PalletStakingStakingLedger, PalletStakingUnappliedSlash, PalletStakingValidatorPrefs, PalletTipsOpenTip, PalletTransactionPaymentReleases, PalletTransactionStorageTransactionInfo, PalletTreasuryProposal, PalletUniquesClassDetails, PalletUniquesClassMetadata, PalletUniquesInstanceDetails, PalletUniquesInstanceMetadata, PalletVestingReleases, PalletVestingVestingInfo, SpAuthorityDiscoveryAppPublic, SpConsensusBabeAppPublic, SpConsensusBabeBabeEpochConfiguration, SpConsensusBabeDigestsNextConfigDescriptor, SpCoreCryptoKeyTypeId, SpRuntimeDigest, SpStakingOffenceOffenceDetails } from '@polkadot/types/lookup'; import type { Observable } from '@polkadot/types/types'; -declare module '@polkadot/api-augment/query' { +declare module '@polkadot/api-base/types/storage' { export interface AugmentedQueries { assets: { /** @@ -1450,13 +1450,4 @@ declare module '@polkadot/api-augment/query' { [key: string]: QueryableStorageEntry; }; } // AugmentedQueries - - export interface QueryableStorage extends AugmentedQueries { - [key: string]: QueryableModuleStorage; - } // QueryableStorage - - export interface QueryableStorageAt extends AugmentedQueries { - [key: string]: QueryableModuleStorageAt; - } // QueryableStorageAt - } // declare module diff --git a/packages/api-augment/src/augment/tx.ts b/packages/api-augment/src/augment/tx.ts index 7c11606c3f..1d9f4704dd 100644 --- a/packages/api-augment/src/augment/tx.ts +++ b/packages/api-augment/src/augment/tx.ts @@ -1,15 +1,14 @@ // Auto-generated via `yarn polkadot-types-from-chain`, do not edit /* eslint-disable */ -import type { ApiTypes, AugmentedSubmittable, SubmittableExtrinsic, SubmittableExtrinsicFunction, SubmittableModuleExtrinsics } from '@polkadot/api-base/types'; +import type { ApiTypes } from '@polkadot/api-base/types'; import type { Data } from '@polkadot/types'; import type { Bytes, Compact, Option, U8aFixed, Vec, bool, u128, u16, u32, u64, u8 } from '@polkadot/types-codec'; import type { AnyNumber, ITuple } from '@polkadot/types-codec/types'; -import type { Extrinsic } from '@polkadot/types/interfaces/extrinsics'; import type { AccountId32, Call, H256, MultiAddress, Perbill, Percent, Perquintill } from '@polkadot/types/interfaces/runtime'; import type { NodeRuntimeOriginCaller, NodeRuntimeProxyType, NodeRuntimeSessionKeys, PalletAssetsDestroyWitness, PalletDemocracyConviction, PalletDemocracyVoteAccountVote, PalletElectionProviderMultiPhaseRawSolution, PalletElectionProviderMultiPhaseSolutionOrSnapshotSize, PalletElectionsPhragmenRenouncing, PalletIdentityBitFlags, PalletIdentityIdentityInfo, PalletIdentityJudgement, PalletImOnlineHeartbeat, PalletImOnlineSr25519AppSr25519Signature, PalletMultisigTimepoint, PalletSocietyJudgement, PalletStakingRewardDestination, PalletStakingValidatorPrefs, PalletUniquesDestroyWitness, PalletVestingVestingInfo, SpConsensusBabeDigestsNextConfigDescriptor, SpConsensusSlotsEquivocationProof, SpFinalityGrandpaEquivocationProof, SpNposElectionsSupport, SpRuntimeHeader, SpSessionMembershipProof, SpTransactionStorageProofTransactionStorageProof } from '@polkadot/types/lookup'; -declare module '@polkadot/api-augment/tx' { +declare module '@polkadot/api-base/types/submittable' { export interface AugmentedSubmittables { assets: { /** @@ -4655,10 +4654,4 @@ declare module '@polkadot/api-augment/tx' { [key: string]: SubmittableExtrinsicFunction; }; } // AugmentedSubmittables - - export interface SubmittableExtrinsics extends AugmentedSubmittables { - (extrinsic: Call | Extrinsic | Uint8Array | string): SubmittableExtrinsic; - [key: string]: SubmittableModuleExtrinsics; - } // SubmittableExtrinsics - } // declare module diff --git a/packages/api-augment/src/bundle.ts b/packages/api-augment/src/bundle.ts index 9fb6782e07..55d51c5706 100644 --- a/packages/api-augment/src/bundle.ts +++ b/packages/api-augment/src/bundle.ts @@ -1,9 +1,6 @@ // Copyright 2017-2021 @polkadot/api-augment authors & contributors // SPDX-License-Identifier: Apache-2.0 -// trigger in the same way as we do externally import './augment'; export { packageInfo } from './packageInfo'; - -export * from './types'; diff --git a/packages/api-augment/src/consts.ts b/packages/api-augment/src/consts.ts deleted file mode 100644 index 911a5ba5a1..0000000000 --- a/packages/api-augment/src/consts.ts +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2017-2021 @polkadot/api-augment authors & contributors -// SPDX-License-Identifier: Apache-2.0 - -// augmented -export const __API_AUGMENT_CONSTS = 'augmented'; diff --git a/packages/api-augment/src/detectPackage.ts b/packages/api-augment/src/detectPackage.ts index 7dd3156094..c3e3d4029d 100644 --- a/packages/api-augment/src/detectPackage.ts +++ b/packages/api-augment/src/detectPackage.ts @@ -1,10 +1,10 @@ // Copyright 2017-2021 @polkadot/api-augment authors & contributors // SPDX-License-Identifier: Apache-2.0 -import { packageInfo as rpcInfo } from '@polkadot/rpc-core/packageInfo'; +import { packageInfo as baseInfo } from '@polkadot/api-base/packageInfo'; import { packageInfo as typesInfo } from '@polkadot/types/packageInfo'; import { detectPackage } from '@polkadot/util'; import { packageInfo } from './packageInfo'; -detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [rpcInfo, typesInfo]); +detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [baseInfo, typesInfo]); diff --git a/packages/api-augment/src/events.ts b/packages/api-augment/src/events.ts deleted file mode 100644 index 376bd08d8e..0000000000 --- a/packages/api-augment/src/events.ts +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2017-2021 @polkadot/api-augment authors & contributors -// SPDX-License-Identifier: Apache-2.0 - -// augmented -export const __API_AUGMENT_EVENTS = 'augmented'; diff --git a/packages/api-augment/src/types.ts b/packages/api-augment/src/types.ts deleted file mode 100644 index 09984dc308..0000000000 --- a/packages/api-augment/src/types.ts +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2017-2021 @polkadot/api-augment authors & contributors -// SPDX-License-Identifier: Apache-2.0 - -// trigger in the same way as we do externally -import '@polkadot/api-augment'; - -// Important: we do the exports here via the full package name -export * from '@polkadot/api-augment/consts'; -export * from '@polkadot/api-augment/errors'; -export * from '@polkadot/api-augment/events'; -export * from '@polkadot/api-augment/query'; -export * from '@polkadot/api-augment/tx'; diff --git a/packages/api-augment/tsconfig.json b/packages/api-augment/tsconfig.json index 59ad1a3dd3..14ed9a3ca0 100644 --- a/packages/api-augment/tsconfig.json +++ b/packages/api-augment/tsconfig.json @@ -7,6 +7,7 @@ }, "references": [ { "path": "../api-base" }, + { "path": "../rpc-augment" }, { "path": "../rpc-core" }, { "path": "../types" }, { "path": "../types-augment" } diff --git a/packages/api-base/src/types/api.ts b/packages/api-base/src/types/api.ts index c1ec47e738..3b03063509 100644 --- a/packages/api-base/src/types/api.ts +++ b/packages/api-base/src/types/api.ts @@ -1,4 +1,26 @@ -// Copyright 2017-2021 @polkadot/api authors & contributors +// Copyright 2017-2021 @polkadot/api-base authors & contributors // SPDX-License-Identifier: Apache-2.0 -export const __API_BASE_TYPES_API = 'empty'; +import type { Observable } from 'rxjs'; +import type { DecoratedRpc, QueryableConsts, QueryableStorage, QueryableStorageMulti, SubmittableExtrinsics } from '@polkadot/api-base/types'; +import type { RpcInterface } from '@polkadot/rpc-core/types'; +import type { Metadata } from '@polkadot/types'; +import type { Hash, RuntimeVersion } from '@polkadot/types/interfaces'; +import type { Registry, Signer } from '@polkadot/types/types'; + +// A smaller interface of ApiRx, used in derive and in SubmittableExtrinsic +export interface ApiInterfaceRx { + consts: QueryableConsts<'rxjs'>; + extrinsicType: number; + genesisHash?: Hash; + hasSubscriptions: boolean; + registry: Registry; + runtimeMetadata: Metadata; + runtimeVersion: RuntimeVersion; + query: QueryableStorage<'rxjs'>; + queryAt: (blockHash: Uint8Array | string, knownVersion?: RuntimeVersion) => Observable>; + queryMulti: QueryableStorageMulti<'rxjs'>; + rpc: DecoratedRpc<'rxjs', RpcInterface>; + tx: SubmittableExtrinsics<'rxjs'>; + signer?: Signer; +} diff --git a/packages/api-base/src/types/base.ts b/packages/api-base/src/types/base.ts index d8aa840603..39bb3be415 100644 --- a/packages/api-base/src/types/base.ts +++ b/packages/api-base/src/types/base.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2021 @polkadot/api authors & contributors +// Copyright 2017-2021 @polkadot/api-base authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { Observable } from 'rxjs'; diff --git a/packages/api-base/src/types/consts.ts b/packages/api-base/src/types/consts.ts index 2a3285d3cb..4daa180dc9 100644 --- a/packages/api-base/src/types/consts.ts +++ b/packages/api-base/src/types/consts.ts @@ -1,10 +1,20 @@ -// Copyright 2017-2021 @polkadot/api authors & contributors +// Copyright 2017-2021 @polkadot/api-base authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { PalletConstantMetadataLatest } from '@polkadot/types/interfaces'; import type { Codec } from '@polkadot/types/types'; import type { ApiTypes } from './base'; +// eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/no-empty-interface +export interface AugmentedConsts { + // augmented +} + +export interface QueryableConsts extends AugmentedConsts { + // when non-augmented, we need to at least have Codec results + [key: string]: QueryableModuleConsts; +} + // eslint-disable-next-line @typescript-eslint/no-unused-vars export interface AugmentedConst { meta: PalletConstantMetadataLatest; diff --git a/packages/api-base/src/types/derive.ts b/packages/api-base/src/types/derive.ts new file mode 100644 index 0000000000..2d6fa4bd78 --- /dev/null +++ b/packages/api-base/src/types/derive.ts @@ -0,0 +1,8 @@ +// Copyright 2017-2021 @polkadot/api-base authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import type { Observable } from 'rxjs'; + +type DeriveCreator = (instanceId: string, api: unknown) => (...args: unknown[]) => Observable; + +export type DeriveCustom = Record>; diff --git a/packages/api-base/src/types/errors.ts b/packages/api-base/src/types/errors.ts index 054efed486..d57a1842ad 100644 --- a/packages/api-base/src/types/errors.ts +++ b/packages/api-base/src/types/errors.ts @@ -1,9 +1,19 @@ -// Copyright 2017-2021 @polkadot/api authors & contributors +// Copyright 2017-2021 @polkadot/api-base authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { IsError } from '@polkadot/types/metadata/decorate/types'; import type { ApiTypes } from './base'; +// eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/no-empty-interface +export interface AugmentedErrors { + // augmented +} + +export interface DecoratedErrors extends AugmentedErrors { + // when non-augmented, we need to at least have Codec results + [key: string]: ModuleErrors; +} + // eslint-disable-next-line @typescript-eslint/no-unused-vars export type AugmentedError = IsError; diff --git a/packages/api-base/src/types/events.ts b/packages/api-base/src/types/events.ts index 8d5f2faf8c..ea44a06b9d 100644 --- a/packages/api-base/src/types/events.ts +++ b/packages/api-base/src/types/events.ts @@ -1,10 +1,20 @@ -// Copyright 2017-2021 @polkadot/api authors & contributors +// Copyright 2017-2021 @polkadot/api-base authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { IsEvent } from '@polkadot/types/metadata/decorate/types'; import type { AnyTuple } from '@polkadot/types/types'; import type { ApiTypes } from './base'; +// eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/no-empty-interface +export interface AugmentedEvents { + // augmented +} + +export interface DecoratedEvents extends AugmentedEvents { + // when non-augmented, we need to at least have Codec results + [key: string]: ModuleEvents; +} + // eslint-disable-next-line @typescript-eslint/no-unused-vars export type AugmentedEvent = IsEvent; diff --git a/packages/api-base/src/types/index.ts b/packages/api-base/src/types/index.ts index 8467aabc38..a6721d39ac 100644 --- a/packages/api-base/src/types/index.ts +++ b/packages/api-base/src/types/index.ts @@ -1,13 +1,15 @@ // Copyright 2017-2021 @polkadot/api authors & contributors // SPDX-License-Identifier: Apache-2.0 -// this is augmented, do an augmentation export -export * from '@polkadot/api-base/types/api'; +// These are augmented, do an augmentation export +export * from '@polkadot/api-base/types/consts'; +export * from '@polkadot/api-base/types/errors'; +export * from '@polkadot/api-base/types/events'; +export * from '@polkadot/api-base/types/storage'; +export * from '@polkadot/api-base/types/submittable'; +// normal exports +export * from './api'; export * from './base'; -export * from './consts'; -export * from './errors'; -export * from './events'; +export * from './derive'; export * from './rpc'; -export * from './storage'; -export * from './submittable'; diff --git a/packages/api-base/src/types/rpc.ts b/packages/api-base/src/types/rpc.ts index 231e266521..fe4d3b3c43 100644 --- a/packages/api-base/src/types/rpc.ts +++ b/packages/api-base/src/types/rpc.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2021 @polkadot/api authors & contributors +// Copyright 2017-2021 @polkadot/api-base authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { Observable } from 'rxjs'; diff --git a/packages/api-base/src/types/storage.ts b/packages/api-base/src/types/storage.ts index f5f9c64ad9..7437daedd1 100644 --- a/packages/api-base/src/types/storage.ts +++ b/packages/api-base/src/types/storage.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2021 @polkadot/api authors & contributors +// Copyright 2017-2021 @polkadot/api-base authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { Observable } from 'rxjs'; @@ -8,6 +8,20 @@ import type { StorageEntry } from '@polkadot/types/primitive/types'; import type { AnyFunction, AnyTuple, Callback, Codec, IStorageKey } from '@polkadot/types/types'; import type { ApiTypes, DropLast, MethodResult, ObsInnerType, PaginationOptions, PromiseOrObs, UnsubscribePromise } from './base'; +// eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/no-empty-interface +export interface AugmentedQueries { + // augmented +} + +export interface QueryableStorage extends AugmentedQueries { + // when non-augmented, we need to at least have Codec results + [key: string]: QueryableModuleStorage; +} + +export interface QueryableStorageAt extends AugmentedQueries { + [key: string]: QueryableModuleStorageAt; +} + type AsCodec = R extends Codec ? R : Codec; @@ -90,11 +104,11 @@ export interface StorageEntryBaseAt { - [index: string]: QueryableStorageEntry; + [key: string]: QueryableStorageEntry; } export interface QueryableModuleStorageAt { - [index: string]: QueryableStorageEntryAt; + [key: string]: QueryableStorageEntryAt; } export type QueryableStorageMultiArg = diff --git a/packages/api-base/src/types/submittable.ts b/packages/api-base/src/types/submittable.ts index d456b814b8..b04afaeafc 100644 --- a/packages/api-base/src/types/submittable.ts +++ b/packages/api-base/src/types/submittable.ts @@ -1,11 +1,22 @@ -// Copyright 2017-2021 @polkadot/api authors & contributors +// Copyright 2017-2021 @polkadot/api-base authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { Observable } from 'rxjs'; -import type { AccountId, Address, ApplyExtrinsicResult, DispatchError, DispatchInfo, EventRecord, Extrinsic, ExtrinsicStatus, Hash, RuntimeDispatchInfo } from '@polkadot/types/interfaces'; +import type { AccountId, Address, ApplyExtrinsicResult, Call, DispatchError, DispatchInfo, EventRecord, Extrinsic, ExtrinsicStatus, Hash, RuntimeDispatchInfo } from '@polkadot/types/interfaces'; import type { AnyFunction, AnyNumber, AnyTuple, Callback, CallBase, Codec, IExtrinsicEra, IKeyringPair, ISubmittableResult, Signer } from '@polkadot/types/types'; import type { ApiTypes, PromiseOrObs } from './base'; +// eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/no-empty-interface +export interface AugmentedSubmittables { + // augmented +} + +export interface SubmittableExtrinsics extends AugmentedSubmittables { + (extrinsic: Call | Extrinsic | Uint8Array | string): SubmittableExtrinsic; + // when non-augmented, we need to at least have Codec results + [key: string]: SubmittableModuleExtrinsics; +} + export type AddressOrPair = IKeyringPair | string | AccountId | Address; export type AugmentedSubmittable = T & CallBase; @@ -30,7 +41,7 @@ export interface SubmittableExtrinsicFunction { // only with is augmentation - [index: string]: SubmittableExtrinsicFunction; // | AugmentedIsSubmittable; + [key: string]: SubmittableExtrinsicFunction; } export type SubmittablePaymentResult = diff --git a/packages/api-contract/src/checkTypes.manual.ts b/packages/api-contract/src/checkTypes.manual.ts index 95f8afaedc..87528cd422 100644 --- a/packages/api-contract/src/checkTypes.manual.ts +++ b/packages/api-contract/src/checkTypes.manual.ts @@ -3,6 +3,8 @@ // Simple non-runnable checks to test type definitions in the editor itself +import '@polkadot/api-augment'; + import { ApiPromise } from '@polkadot/api'; import { BlueprintPromise, ContractPromise } from '@polkadot/api-contract'; import { createTestPairs, TestKeyringMap } from '@polkadot/keyring/testingPairs'; diff --git a/packages/api-contract/tsconfig.json b/packages/api-contract/tsconfig.json index de3def31de..51f8eb0b4c 100644 --- a/packages/api-contract/tsconfig.json +++ b/packages/api-contract/tsconfig.json @@ -9,12 +9,14 @@ "**/test/**/*.json", "**/test/**/*.ts", "**/test/**/*.wasm", - "**/*.manual.ts", + "**/checkTypes.manual.ts", "**/*.spec.ts", "mock.ts" ], "references": [ { "path": "../api" }, + { "path": "../api-augment" }, + { "path": "../rpc-augment" }, { "path": "../types" } ] } diff --git a/packages/api-contract/tsconfig.spec.json b/packages/api-contract/tsconfig.spec.json index 0f64aeb741..909d00876f 100644 --- a/packages/api-contract/tsconfig.spec.json +++ b/packages/api-contract/tsconfig.spec.json @@ -12,13 +12,15 @@ "**/test/**/*.json", "**/test/**/*.ts", "**/test/**/*.wasm", - "**/*.manual.ts", + "**/checkTypes.manual.ts", "**/*.spec.ts", "mock.ts" ], "references": [ { "path": "../api" }, + { "path": "../api-augment" }, { "path": "../api-contract" }, + { "path": "../rpc-augment" }, { "path": "../types" }, { "path": "../types-augment" } ] diff --git a/packages/api-derive/src/augment.ts b/packages/api-derive/src/augment.ts index 4fff1f35e0..cd63cbe9c4 100644 --- a/packages/api-derive/src/augment.ts +++ b/packages/api-derive/src/augment.ts @@ -2,4 +2,3 @@ // SPDX-License-Identifier: Apache-2.0 import '@polkadot/api-augment'; -import '@polkadot/rpc-augment'; diff --git a/packages/api-derive/src/bundle.ts b/packages/api-derive/src/bundle.ts index 68281fa560..f3f4a64115 100644 --- a/packages/api-derive/src/bundle.ts +++ b/packages/api-derive/src/bundle.ts @@ -1,8 +1,9 @@ // Copyright 2017-2021 @polkadot/api-derive authors & contributors // SPDX-License-Identifier: Apache-2.0 +import type { DeriveCustom } from '@polkadot/api-base/types'; import type { AnyFunction } from '@polkadot/types/types'; -import type { DeriveCustom, ExactDerive } from './derive'; +import type { ExactDerive } from './derive'; import type { DeriveApi } from './types'; import { lazyDeriveSection } from './util/lazy'; diff --git a/packages/api-derive/src/checkTypes.manual.ts b/packages/api-derive/src/checkTypes.manual.ts index 7265d248a3..20ed5cb228 100644 --- a/packages/api-derive/src/checkTypes.manual.ts +++ b/packages/api-derive/src/checkTypes.manual.ts @@ -1,7 +1,7 @@ // Copyright 2017-2021 @polkadot/api-derive authors & contributors // SPDX-License-Identifier: Apache-2.0 -import './augment'; +import '@polkadot/api-augment'; import { derive } from '.'; diff --git a/packages/api-derive/src/derive.ts b/packages/api-derive/src/derive.ts index 7af6b3157e..bab0b36860 100644 --- a/packages/api-derive/src/derive.ts +++ b/packages/api-derive/src/derive.ts @@ -1,7 +1,6 @@ // Copyright 2017-2021 @polkadot/api-derive authors & contributors // SPDX-License-Identifier: Apache-2.0 -import type { Observable } from 'rxjs'; import type { AnyFunction } from '@polkadot/types/types'; import * as accounts from './accounts'; @@ -34,8 +33,4 @@ type DeriveAllSections = { [S in keyof AllSections]: DeriveSection }; -type DeriveCreator = (instanceId: string, api: unknown) => (...args: unknown[]) => Observable; - -export type DeriveCustom = Record>; - export type ExactDerive = DeriveAllSections; diff --git a/packages/api-derive/tsconfig.json b/packages/api-derive/tsconfig.json index 2b11bb0c8f..9fe3ef8dc3 100644 --- a/packages/api-derive/tsconfig.json +++ b/packages/api-derive/tsconfig.json @@ -7,12 +7,13 @@ }, "exclude": [ "**/test/*", - "**/*.manual.ts", + "**/checkTypes.manual.ts", "**/*.spec.ts" ], "references": [ - { "path": "../api-augment" }, { "path": "../api-base" }, + { "path": "../api-augment" }, + { "path": "../rpc-augment" }, { "path": "../rpc-core" }, { "path": "../types" }, { "path": "../types-codec" } diff --git a/packages/api-derive/tsconfig.spec.json b/packages/api-derive/tsconfig.spec.json index e8902a3154..5731caa933 100644 --- a/packages/api-derive/tsconfig.spec.json +++ b/packages/api-derive/tsconfig.spec.json @@ -9,7 +9,7 @@ }, "include": [ "**/test/*", - "**/*.manual.ts", + "**/checkTypes.manual.ts", "**/*.spec.ts" ], "references": [ @@ -17,6 +17,7 @@ { "path": "../api-augment" }, { "path": "../api-base" }, { "path": "../api-derive" }, + { "path": "../rpc-augment" }, { "path": "../types" }, { "path": "../types-augment" }, { "path": "../types-codec" } diff --git a/packages/api/src/base/Decorate.ts b/packages/api/src/base/Decorate.ts index c80d3ffee9..a308376b06 100644 --- a/packages/api/src/base/Decorate.ts +++ b/packages/api/src/base/Decorate.ts @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 import type { Observable } from 'rxjs'; -import type { DeriveCustom } from '@polkadot/api-derive'; +import type { DeriveCustom } from '@polkadot/api-base/types'; import type { RpcInterface } from '@polkadot/rpc-core/types'; import type { Option, Raw, StorageKey, Text, u64 } from '@polkadot/types'; import type { Call, Hash, RuntimeVersion } from '@polkadot/types/interfaces'; diff --git a/packages/api/src/checkTypes.manual.ts b/packages/api/src/checkTypes.manual.ts index 5a6f9fd18d..0caaf2c8cf 100644 --- a/packages/api/src/checkTypes.manual.ts +++ b/packages/api/src/checkTypes.manual.ts @@ -3,7 +3,7 @@ // Simple non-runnable checks to test type definitions in the editor itself -import './augment'; +import '@polkadot/api-augment'; import type { HeaderExtended } from '@polkadot/api-derive/types'; import type { StorageKey } from '@polkadot/types'; diff --git a/packages/api/src/test/util/index.ts b/packages/api/src/test/util/index.ts index 51bf333cd0..b647574755 100644 --- a/packages/api/src/test/util/index.ts +++ b/packages/api/src/test/util/index.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2021 @polkadot/api-derive authors & contributors +// Copyright 2017-2021 @polkadot/api authors & contributors // SPDX-License-Identifier: Apache-2.0 export * from './logEvents'; diff --git a/packages/api/src/augment.ts b/packages/api/src/types/consts.ts similarity index 59% rename from packages/api/src/augment.ts rename to packages/api/src/types/consts.ts index d35cf47a29..1d0419e4fe 100644 --- a/packages/api/src/augment.ts +++ b/packages/api/src/types/consts.ts @@ -1,5 +1,4 @@ // Copyright 2017-2021 @polkadot/api authors & contributors // SPDX-License-Identifier: Apache-2.0 -// import '@polkadot/api-augment'; -import '@polkadot/rpc-augment'; +export * from '@polkadot/api-base/types/consts'; diff --git a/packages/api/src/types/errors.ts b/packages/api/src/types/errors.ts new file mode 100644 index 0000000000..61b8ba734e --- /dev/null +++ b/packages/api/src/types/errors.ts @@ -0,0 +1,4 @@ +// Copyright 2017-2021 @polkadot/api authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +export * from '@polkadot/api-base/types/errors'; diff --git a/packages/api/src/types/events.ts b/packages/api/src/types/events.ts new file mode 100644 index 0000000000..eb938bab25 --- /dev/null +++ b/packages/api/src/types/events.ts @@ -0,0 +1,4 @@ +// Copyright 2017-2021 @polkadot/api authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +export * from '@polkadot/api-base/types/events'; diff --git a/packages/api/src/types.ts b/packages/api/src/types/index.ts similarity index 79% rename from packages/api/src/types.ts rename to packages/api/src/types/index.ts index ad94245f4f..e2da4af607 100644 --- a/packages/api/src/types.ts +++ b/packages/api/src/types/index.ts @@ -1,27 +1,31 @@ // Copyright 2017-2021 @polkadot/api authors & contributors // SPDX-License-Identifier: Apache-2.0 -import type { QueryableConsts } from '@polkadot/api-augment/consts'; -import type { DecoratedErrors } from '@polkadot/api-augment/errors'; -import type { DecoratedEvents } from '@polkadot/api-augment/events'; -import type { QueryableStorage } from '@polkadot/api-augment/query'; -import type { ApiInterfaceRx as ApiInterfaceBase, ApiTypes, QueryableStorageMulti } from '@polkadot/api-base/types'; -import type { DeriveCustom } from '@polkadot/api-derive'; +import type { ApiTypes, DeriveCustom, QueryableStorageMulti } from '@polkadot/api-base/types'; +import type { ApiInterfaceRx as ApiInterfaceBase } from '@polkadot/api-base/types/api'; +import type { QueryableConsts } from '@polkadot/api-base/types/consts'; +import type { DecoratedErrors } from '@polkadot/api-base/types/errors'; +import type { DecoratedEvents } from '@polkadot/api-base/types/events'; +import type { QueryableStorage } from '@polkadot/api-base/types/storage'; import type { ProviderInterface, ProviderInterfaceEmitted } from '@polkadot/rpc-provider/types'; import type { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types'; import type { Hash } from '@polkadot/types/interfaces'; import type { CallFunction, DefinitionRpc, DefinitionRpcSub, 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 { AllDerives } from './util/decorate'; +import type { ApiBase } from '../base'; +import type { AllDerives } from '../util/decorate'; export * from '@polkadot/api-base/types'; +export * from '@polkadot/api/types/consts'; +export * from '@polkadot/api/types/errors'; +export * from '@polkadot/api/types/events'; +export * from '@polkadot/api/types/storage'; +export * from '@polkadot/api/types/submittable'; -export type { AugmentedConsts, AugmentedErrors, AugmentedEvents, AugmentedQueries, AugmentedSubmittables, QueryableConsts, DecoratedErrors, DecoratedEvents, QueryableStorage, QueryableStorageAt, SubmittableExtrinsics } from '@polkadot/api-augment'; export { Signer, SignerResult } from '@polkadot/types/types'; -export { ApiBase } from './base'; +export { ApiBase } from '../base'; // A smaller interface of ApiRx, used in derive and in SubmittableExtrinsic export interface ApiInterfaceRx extends ApiInterfaceBase { diff --git a/packages/api-augment/src/query.ts b/packages/api/src/types/storage.ts similarity index 63% rename from packages/api-augment/src/query.ts rename to packages/api/src/types/storage.ts index 8335fa8903..d8defd4432 100644 --- a/packages/api-augment/src/query.ts +++ b/packages/api/src/types/storage.ts @@ -1,5 +1,4 @@ // Copyright 2017-2021 @polkadot/api-augment authors & contributors // SPDX-License-Identifier: Apache-2.0 -// augmented -export const __API_AUGMENT_QUERY = 'augmented'; +export * from '@polkadot/api-base/types/storage'; diff --git a/packages/api-augment/src/errors.ts b/packages/api/src/types/submittable.ts similarity index 63% rename from packages/api-augment/src/errors.ts rename to packages/api/src/types/submittable.ts index 778344e40c..93d8bbfc75 100644 --- a/packages/api-augment/src/errors.ts +++ b/packages/api/src/types/submittable.ts @@ -1,5 +1,4 @@ // Copyright 2017-2021 @polkadot/api-augment authors & contributors // SPDX-License-Identifier: Apache-2.0 -// augmented -export const __API_AUGMENT_ERRORS = 'augmented'; +export * from '@polkadot/api-base/types/submittable'; diff --git a/packages/api/tsconfig.json b/packages/api/tsconfig.json index 3225b8269c..b0b8bd3724 100644 --- a/packages/api/tsconfig.json +++ b/packages/api/tsconfig.json @@ -6,11 +6,10 @@ "rootDir": "./src" }, "exclude": [ - "**/*.manual.ts", + "**/checkTypes.manual.ts", "**/*.spec.ts" ], "references": [ - { "path": "../api-augment" }, { "path": "../api-base" }, { "path": "../api-derive" }, { "path": "../rpc-core" }, diff --git a/packages/api/tsconfig.spec.json b/packages/api/tsconfig.spec.json index 21f949168e..afc6c6d484 100644 --- a/packages/api/tsconfig.spec.json +++ b/packages/api/tsconfig.spec.json @@ -8,7 +8,7 @@ "noEmit": true }, "include": [ - "**/*.manual.ts", + "**/checkTypes.manual.ts", "**/*.spec.ts", "**/test/**/*" ], diff --git a/packages/rpc-augment/src/augment/index.ts b/packages/rpc-augment/src/augment/index.ts index 44427f558b..f360ca2493 100644 --- a/packages/rpc-augment/src/augment/index.ts +++ b/packages/rpc-augment/src/augment/index.ts @@ -1,5 +1,4 @@ // Copyright 2017-2021 @polkadot/rpc-augment authors & contributors // SPDX-License-Identifier: Apache-2.0 -import '@polkadot/types-augment'; -import './rpc'; +import './jsonrpc'; diff --git a/packages/rpc-augment/src/augment/rpc.ts b/packages/rpc-augment/src/augment/jsonrpc.ts similarity index 99% rename from packages/rpc-augment/src/augment/rpc.ts rename to packages/rpc-augment/src/augment/jsonrpc.ts index cb655cc437..e0c6f8cf2b 100644 --- a/packages/rpc-augment/src/augment/rpc.ts +++ b/packages/rpc-augment/src/augment/jsonrpc.ts @@ -1,7 +1,7 @@ // Auto-generated via `yarn polkadot-types-from-chain`, do not edit /* eslint-disable */ -import type { AugmentedRpc } from '@polkadot/rpc-augment/types'; +import type { AugmentedRpc } from '@polkadot/rpc-core/types'; import type { Metadata, StorageKey } from '@polkadot/types'; import type { Bytes, HashMap, Json, Null, Option, Text, U256, U64, Vec, bool, u32, u64 } from '@polkadot/types-codec'; import type { AnyNumber, Codec } from '@polkadot/types-codec/types'; @@ -25,7 +25,7 @@ import type { ReadProof, RuntimeVersion, TraceBlockResponse } from '@polkadot/ty import type { ApplyExtrinsicResult, ChainProperties, ChainType, Health, NetworkState, NodeRole, PeerInfo, SyncState } from '@polkadot/types/interfaces/system'; import type { IExtrinsic, Observable } from '@polkadot/types/types'; -declare module '@polkadot/rpc-augment/rpc' { +declare module '@polkadot/rpc-core/types/jsonrpc' { export interface RpcInterface { author: { /** @@ -560,5 +560,4 @@ declare module '@polkadot/rpc-augment/rpc' { sha3: AugmentedRpc<(data: Bytes | string | Uint8Array) => Observable>; }; } // RpcInterface - } // declare module diff --git a/packages/rpc-augment/src/bundle.ts b/packages/rpc-augment/src/bundle.ts index cf63cf5823..76492533fc 100644 --- a/packages/rpc-augment/src/bundle.ts +++ b/packages/rpc-augment/src/bundle.ts @@ -4,5 +4,3 @@ import './augment'; export { packageInfo } from './packageInfo'; - -export * from '@polkadot/rpc-augment/rpc'; diff --git a/packages/rpc-augment/src/rpc.ts b/packages/rpc-augment/src/rpc.ts deleted file mode 100644 index cd640f75bb..0000000000 --- a/packages/rpc-augment/src/rpc.ts +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2017-2021 @polkadot/rpc-augment authors & contributors -// SPDX-License-Identifier: Apache-2.0 - -// augmented -export const __RPC_AUGMENT_RPC = 'augmented'; diff --git a/packages/rpc-augment/tsconfig.json b/packages/rpc-augment/tsconfig.json index 1256f2012b..22f28e07d6 100644 --- a/packages/rpc-augment/tsconfig.json +++ b/packages/rpc-augment/tsconfig.json @@ -6,7 +6,7 @@ "rootDir": "./src" }, "references": [ - { "path": "../types" }, - { "path": "../types-augment" } + { "path": "../rpc-core" }, + { "path": "../types" } ] } diff --git a/packages/rpc-core/src/augment.ts b/packages/rpc-core/src/checkTypes.manual.ts similarity index 100% rename from packages/rpc-core/src/augment.ts rename to packages/rpc-core/src/checkTypes.manual.ts diff --git a/packages/rpc-core/src/types.ts b/packages/rpc-core/src/types.ts deleted file mode 100644 index 2747415322..0000000000 --- a/packages/rpc-core/src/types.ts +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2017-2021 @polkadot/rpc-core authors & contributors -// SPDX-License-Identifier: Apache-2.0 - -export type { RpcInterface } from '@polkadot/rpc-augment/rpc'; -export type { AugmentedRpc, RpcInterfaceMethod } from '@polkadot/rpc-augment/types'; diff --git a/packages/rpc-augment/src/types.ts b/packages/rpc-core/src/types/base.ts similarity index 87% rename from packages/rpc-augment/src/types.ts rename to packages/rpc-core/src/types/base.ts index e984724ee3..abb7ed8c0d 100644 --- a/packages/rpc-augment/src/types.ts +++ b/packages/rpc-core/src/types/base.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2021 @polkadot/rpc-augment authors & contributors +// Copyright 2017-2021 @polkadot/rpc-core authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { Observable } from 'rxjs'; diff --git a/packages/rpc-core/src/types/index.ts b/packages/rpc-core/src/types/index.ts new file mode 100644 index 0000000000..5d4983300c --- /dev/null +++ b/packages/rpc-core/src/types/index.ts @@ -0,0 +1,8 @@ +// Copyright 2017-2021 @polkadot/rpc-core authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +// augmented, do an augmentation export +export * from '@polkadot/rpc-core/types/jsonrpc'; + +// normal exports +export * from './base'; diff --git a/packages/rpc-core/src/types/jsonrpc.ts b/packages/rpc-core/src/types/jsonrpc.ts new file mode 100644 index 0000000000..9be25051fb --- /dev/null +++ b/packages/rpc-core/src/types/jsonrpc.ts @@ -0,0 +1,7 @@ +// Copyright 2017-2021 @polkadot/rpc-core authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface RpcInterface { + // augmented +} diff --git a/packages/rpc-core/tsconfig.json b/packages/rpc-core/tsconfig.json index 539bf8ea12..b86a4a13b2 100644 --- a/packages/rpc-core/tsconfig.json +++ b/packages/rpc-core/tsconfig.json @@ -6,10 +6,10 @@ "rootDir": "./src" }, "exclude": [ + "**/checkTypes.manual.ts", "**/*.spec.ts" ], "references": [ - { "path": "../rpc-augment" }, { "path": "../rpc-provider" } ] } diff --git a/packages/rpc-core/tsconfig.spec.json b/packages/rpc-core/tsconfig.spec.json index 49a15363b2..7b66e835b8 100644 --- a/packages/rpc-core/tsconfig.spec.json +++ b/packages/rpc-core/tsconfig.spec.json @@ -8,6 +8,7 @@ "noEmit": true }, "include": [ + "**/checkTypes.manual.ts", "**/*.spec.ts" ], "references": [ diff --git a/packages/typegen/src/augment.ts b/packages/typegen/src/augment.ts new file mode 100644 index 0000000000..06d49be0d6 --- /dev/null +++ b/packages/typegen/src/augment.ts @@ -0,0 +1,5 @@ +// Copyright 2017-2021 @polkadot/typegen authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import '@polkadot/api-augment'; +import '@polkadot/rpc-augment'; diff --git a/packages/typegen/src/generate/consts.ts b/packages/typegen/src/generate/consts.ts index 3a85c25fd5..5aacf21aec 100644 --- a/packages/typegen/src/generate/consts.ts +++ b/packages/typegen/src/generate/consts.ts @@ -76,7 +76,7 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes, })), { file: '@polkadot/api-base/types', - types: ['ApiTypes', 'AugmentedConst', 'QueryableModuleConsts'] + types: ['ApiTypes'] } ] }); diff --git a/packages/typegen/src/generate/errors.ts b/packages/typegen/src/generate/errors.ts index 87289a65e2..b9d5e494b7 100644 --- a/packages/typegen/src/generate/errors.ts +++ b/packages/typegen/src/generate/errors.ts @@ -39,7 +39,7 @@ function generateForMeta (meta: Metadata, dest: string, isStrict: boolean): void types: [ { file: '@polkadot/api-base/types', - types: ['ApiTypes', 'AugmentedError', 'ModuleErrors'] + types: ['ApiTypes'] } ] }); diff --git a/packages/typegen/src/generate/events.ts b/packages/typegen/src/generate/events.ts index d100512227..e39ff73a80 100644 --- a/packages/typegen/src/generate/events.ts +++ b/packages/typegen/src/generate/events.ts @@ -68,7 +68,7 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes, })), { file: '@polkadot/api-base/types', - types: ['ApiTypes', 'AugmentedEvent', 'ModuleEvents'] + types: ['ApiTypes'] } ] }); diff --git a/packages/typegen/src/generate/query.ts b/packages/typegen/src/generate/query.ts index 346bf1df72..6e79385e61 100644 --- a/packages/typegen/src/generate/query.ts +++ b/packages/typegen/src/generate/query.ts @@ -125,7 +125,7 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr })), { file: '@polkadot/api-base/types', - types: ['ApiTypes', 'AugmentedQuery', 'QueryableStorageEntry', 'QueryableModuleStorage', 'QueryableModuleStorageAt'] + types: ['ApiTypes'] } ] }); diff --git a/packages/typegen/src/generate/rpc.ts b/packages/typegen/src/generate/rpc.ts index 64db8bfd8f..dd16d95e42 100644 --- a/packages/typegen/src/generate/rpc.ts +++ b/packages/typegen/src/generate/rpc.ts @@ -135,7 +135,7 @@ export function generateRpcTypes (registry: TypeRegistry, importDefinitions: Rec types: Object.keys(imports.localTypes[packagePath]) })), { - file: '@polkadot/rpc-augment/types', + file: '@polkadot/rpc-core/types', types: ['AugmentedRpc'] } ] @@ -143,7 +143,7 @@ export function generateRpcTypes (registry: TypeRegistry, importDefinitions: Rec }); } -export function generateDefaultRpc (dest = 'packages/rpc-augment/src/augment/rpc.ts', extraTypes: ExtraTypes = {}): void { +export function generateDefaultRpc (dest = 'packages/rpc-augment/src/augment/jsonrpc.ts', extraTypes: ExtraTypes = {}): void { const { registry } = initMeta(undefined, extraTypes); generateRpcTypes( diff --git a/packages/typegen/src/generate/tx.ts b/packages/typegen/src/generate/tx.ts index 84c9bbc77c..5b84b50a66 100644 --- a/packages/typegen/src/generate/tx.ts +++ b/packages/typegen/src/generate/tx.ts @@ -50,7 +50,7 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr .sort(compareName) .filter(({ calls }) => calls.isSome) .map(({ calls, name }) => { - setImports(allDefs, imports, ['Call', 'Extrinsic', 'SubmittableExtrinsic']); + setImports(allDefs, imports, ['SubmittableExtrinsic']); const sectionName = stringCamelCase(name); const items = lookup.getSiType(calls.unwrap().type).def.asVariant.variants @@ -110,7 +110,7 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr })), { file: '@polkadot/api-base/types', - types: ['ApiTypes', 'AugmentedSubmittable', 'SubmittableExtrinsic', 'SubmittableExtrinsicFunction', 'SubmittableModuleExtrinsics'] + types: ['ApiTypes'] } ] }); diff --git a/packages/typegen/src/templates/consts.hbs b/packages/typegen/src/templates/consts.hbs index a04de52701..94d43b4b9d 100644 --- a/packages/typegen/src/templates/consts.hbs +++ b/packages/typegen/src/templates/consts.hbs @@ -2,8 +2,8 @@ {{{ importsAll }}} -declare module '@polkadot/api-augment/consts' { - export interface AugmentedConsts { +declare module '@polkadot/api-base/types/consts' { + export interface AugmentedConsts { {{#each modules}} {{{name}}}: { {{#each items}} @@ -19,11 +19,4 @@ declare module '@polkadot/api-augment/consts' { }; {{/each}} } // AugmentedConsts - - export interface QueryableConsts extends AugmentedConsts { - {{#unless isStrict}} - [key: string]: QueryableModuleConsts; - {{/unless}} - } // QueryableConsts - } // declare module diff --git a/packages/typegen/src/templates/errors.hbs b/packages/typegen/src/templates/errors.hbs index 2d53f58df7..bdb00fe904 100644 --- a/packages/typegen/src/templates/errors.hbs +++ b/packages/typegen/src/templates/errors.hbs @@ -2,7 +2,7 @@ {{{ importsAll }}} -declare module '@polkadot/api-augment/errors' { +declare module '@polkadot/api-base/types/errors' { export interface AugmentedErrors { {{#each modules}} {{{name}}}: { @@ -19,11 +19,4 @@ declare module '@polkadot/api-augment/errors' { }; {{/each}} } // AugmentedErrors - - export interface DecoratedErrors extends AugmentedErrors { - {{#unless isStrict}} - [key: string]: ModuleErrors; - {{/unless}} - } // DecoratedErrors - } // declare module diff --git a/packages/typegen/src/templates/events.hbs b/packages/typegen/src/templates/events.hbs index 5b6e27d646..3eadee2506 100644 --- a/packages/typegen/src/templates/events.hbs +++ b/packages/typegen/src/templates/events.hbs @@ -2,7 +2,7 @@ {{{ importsAll }}} -declare module '@polkadot/api-augment/events' { +declare module '@polkadot/api-base/types/events' { export interface AugmentedEvents { {{#each modules}} {{{name}}}: { @@ -19,11 +19,4 @@ declare module '@polkadot/api-augment/events' { }; {{/each}} } // AugmentedEvents - - export interface DecoratedEvents extends AugmentedEvents { - {{#unless isStrict}} - [key: string]: ModuleEvents; - {{/unless}} - } // DecoratedEvents - } // declare module diff --git a/packages/typegen/src/templates/interfaceRegistry.hbs b/packages/typegen/src/templates/interfaceRegistry.hbs index 8e9c9de64b..f7b4edfe58 100644 --- a/packages/typegen/src/templates/interfaceRegistry.hbs +++ b/packages/typegen/src/templates/interfaceRegistry.hbs @@ -2,7 +2,7 @@ {{{ importsAll }}} -declare module '@polkadot/types-augment/registry' { +declare module '@polkadot/types/types/registry' { export interface InterfaceTypes { {{#each items}} {{{this}}}: {{{this}}}; diff --git a/packages/typegen/src/templates/lookup/types.hbs b/packages/typegen/src/templates/lookup/types.hbs index bcfd7a6043..8fa1bc3db8 100644 --- a/packages/typegen/src/templates/lookup/types.hbs +++ b/packages/typegen/src/templates/lookup/types.hbs @@ -1,8 +1,10 @@ {{> header }} -{{{ importsAll }}} +{{{ importsRelative }}} + +declare module '@polkadot/types/lookup' { + {{{ importsPackage }}} -declare module '@polkadot/types-augment/lookup' { {{#each items}} {{{this}}} diff --git a/packages/typegen/src/templates/query.hbs b/packages/typegen/src/templates/query.hbs index 55da0071bf..4b3b05f11d 100644 --- a/packages/typegen/src/templates/query.hbs +++ b/packages/typegen/src/templates/query.hbs @@ -2,7 +2,7 @@ {{{ importsAll }}} -declare module '@polkadot/api-augment/query' { +declare module '@polkadot/api-base/types/storage' { export interface AugmentedQueries { {{#each modules}} {{{name}}}: { @@ -19,17 +19,4 @@ declare module '@polkadot/api-augment/query' { }; {{/each}} } // AugmentedQueries - - export interface QueryableStorage extends AugmentedQueries { - {{#unless isStrict}} - [key: string]: QueryableModuleStorage; - {{/unless}} - } // QueryableStorage - - export interface QueryableStorageAt extends AugmentedQueries { - {{#unless isStrict}} - [key: string]: QueryableModuleStorageAt; - {{/unless}} - } // QueryableStorageAt - } // declare module diff --git a/packages/typegen/src/templates/rpc.hbs b/packages/typegen/src/templates/rpc.hbs index 917cebaa77..53686c129b 100644 --- a/packages/typegen/src/templates/rpc.hbs +++ b/packages/typegen/src/templates/rpc.hbs @@ -2,7 +2,7 @@ {{{ importsAll }}} -declare module '@polkadot/rpc-augment/rpc' { +declare module '@polkadot/rpc-core/types/jsonrpc' { export interface RpcInterface { {{#each modules}} {{{name}}}: { @@ -13,5 +13,4 @@ declare module '@polkadot/rpc-augment/rpc' { }; {{/each}} } // RpcInterface - } // declare module diff --git a/packages/typegen/src/templates/tx.hbs b/packages/typegen/src/templates/tx.hbs index 7011cb27ad..5fb81f5e0e 100644 --- a/packages/typegen/src/templates/tx.hbs +++ b/packages/typegen/src/templates/tx.hbs @@ -2,7 +2,7 @@ {{{ importsAll }}} -declare module '@polkadot/api-augment/tx' { +declare module '@polkadot/api-base/types/submittable' { export interface AugmentedSubmittables { {{#each modules}} {{{name}}}: { @@ -19,12 +19,4 @@ declare module '@polkadot/api-augment/tx' { }; {{/each}} } // AugmentedSubmittables - - export interface SubmittableExtrinsics extends AugmentedSubmittables { - (extrinsic: Call | Extrinsic | Uint8Array | string): SubmittableExtrinsic; - {{#unless isStrict}} - [key: string]: SubmittableModuleExtrinsics; - {{/unless}} - } // SubmittableExtrinsics - } // declare module diff --git a/packages/types-augment/src/augment/index.ts b/packages/types-augment/src/augment/index.ts index 2e0f22cfb1..ab929ba6d5 100644 --- a/packages/types-augment/src/augment/index.ts +++ b/packages/types-augment/src/augment/index.ts @@ -1,6 +1,5 @@ // Copyright 2017-2021 @polkadot/types-augment authors & contributors // SPDX-License-Identifier: Apache-2.0 -import './lookup'; import './registry'; -import './types'; +import './lookup'; diff --git a/packages/types-augment/src/augment/lookup/types-kusama.ts b/packages/types-augment/src/augment/lookup/types-kusama.ts index 236cbbc45a..284ab436b0 100644 --- a/packages/types-augment/src/augment/lookup/types-kusama.ts +++ b/packages/types-augment/src/augment/lookup/types-kusama.ts @@ -1,11 +1,11 @@ // Auto-generated via `yarn polkadot-types-from-defs`, do not edit /* eslint-disable */ -import type { BitVec, Compact, Enum, Null, Option, Struct, Vec, u16, u32 } from '@polkadot/types-codec'; -import type { ITuple } from '@polkadot/types-codec/types'; -import type { H256, PerU16 } from '@polkadot/types/interfaces/runtime'; +declare module '@polkadot/types/lookup' { + import type { BitVec, Compact, Enum, Null, Option, Struct, Vec, u16, u32 } from '@polkadot/types-codec'; + import type { ITuple } from '@polkadot/types-codec/types'; + import type { H256, PerU16 } from '@polkadot/types/interfaces/runtime'; -declare module '@polkadot/types-augment/lookup' { /** @name KusamaRuntimeProxyType (73) */ export interface KusamaRuntimeProxyType extends Enum { readonly isAny: boolean; diff --git a/packages/types-augment/src/augment/lookup/types-polkadot.ts b/packages/types-augment/src/augment/lookup/types-polkadot.ts index 9fbe185245..23ca6ec3ec 100644 --- a/packages/types-augment/src/augment/lookup/types-polkadot.ts +++ b/packages/types-augment/src/augment/lookup/types-polkadot.ts @@ -1,12 +1,12 @@ // Auto-generated via `yarn polkadot-types-from-defs`, do not edit /* eslint-disable */ -import type { BitVec, Bytes, Compact, Enum, Null, Option, Result, Struct, U8aFixed, Vec, bool, u128, u16, u32, u64, u8 } from '@polkadot/types-codec'; -import type { ITuple } from '@polkadot/types-codec/types'; -import type { EthereumAddress } from '@polkadot/types/interfaces/eth'; -import type { AccountId32, H256, PerU16 } from '@polkadot/types/interfaces/runtime'; +declare module '@polkadot/types/lookup' { + import type { BitVec, Bytes, Compact, Enum, Null, Option, Result, Struct, U8aFixed, Vec, bool, u128, u16, u32, u64, u8 } from '@polkadot/types-codec'; + import type { ITuple } from '@polkadot/types-codec/types'; + import type { EthereumAddress } from '@polkadot/types/interfaces/eth'; + import type { AccountId32, H256, PerU16 } from '@polkadot/types/interfaces/runtime'; -declare module '@polkadot/types-augment/lookup' { /** @name PolkadotRuntimeCommonClaimsPalletEvent (64) */ export interface PolkadotRuntimeCommonClaimsPalletEvent extends Enum { readonly isClaimed: boolean; diff --git a/packages/types-augment/src/augment/lookup/types-substrate.ts b/packages/types-augment/src/augment/lookup/types-substrate.ts index 4a1adc70e1..f54f243c61 100644 --- a/packages/types-augment/src/augment/lookup/types-substrate.ts +++ b/packages/types-augment/src/augment/lookup/types-substrate.ts @@ -1,14 +1,14 @@ // Auto-generated via `yarn polkadot-types-from-defs`, do not edit /* eslint-disable */ -import type { Data } from '@polkadot/types'; -import type { BTreeMap, Bytes, Compact, Enum, Null, Option, Result, Set, Struct, Text, U8aFixed, Vec, bool, u128, u16, u32, u64, u8 } from '@polkadot/types-codec'; -import type { ITuple } from '@polkadot/types-codec/types'; -import type { Vote } from '@polkadot/types/interfaces/elections'; -import type { AccountId32, Call, H256, MultiAddress, PerU16, Perbill, Percent, Perquintill } from '@polkadot/types/interfaces/runtime'; -import type { Event } from '@polkadot/types/interfaces/system'; +declare module '@polkadot/types/lookup' { + import type { Data } from '@polkadot/types'; + import type { BTreeMap, Bytes, Compact, Enum, Null, Option, Result, Set, Struct, Text, U8aFixed, Vec, bool, u128, u16, u32, u64, u8 } from '@polkadot/types-codec'; + import type { ITuple } from '@polkadot/types-codec/types'; + import type { Vote } from '@polkadot/types/interfaces/elections'; + import type { AccountId32, Call, H256, MultiAddress, PerU16, Perbill, Percent, Perquintill } from '@polkadot/types/interfaces/runtime'; + import type { Event } from '@polkadot/types/interfaces/system'; -declare module '@polkadot/types-augment/lookup' { /** @name FrameSystemAccountInfo (3) */ export interface FrameSystemAccountInfo extends Struct { readonly nonce: u32; diff --git a/packages/types-augment/src/augment/registry.ts b/packages/types-augment/src/augment/registry.ts index be8011831c..4655e6ee07 100644 --- a/packages/types-augment/src/augment/registry.ts +++ b/packages/types-augment/src/augment/registry.ts @@ -60,7 +60,7 @@ import type { Multisig, Timepoint } from '@polkadot/types/interfaces/utility'; import type { VestingInfo } from '@polkadot/types/interfaces/vesting'; import type { AssetInstance, AssetInstanceV0, AssetInstanceV1, AssetInstanceV2, BodyId, BodyPart, DoubleEncodedCall, Fungibility, FungibilityV0, FungibilityV1, FungibilityV2, InboundStatus, InstructionV2, InteriorMultiLocation, Junction, JunctionV0, JunctionV1, JunctionV2, Junctions, JunctionsV1, JunctionsV2, MultiAsset, MultiAssetFilter, MultiAssetFilterV1, MultiAssetFilterV2, MultiAssetV0, MultiAssetV1, MultiAssetV2, MultiAssets, MultiAssetsV1, MultiAssetsV2, MultiLocation, MultiLocationV0, MultiLocationV1, MultiLocationV2, NetworkId, OriginKindV0, OriginKindV1, OriginKindV2, OutboundStatus, Outcome, QueryId, QueryStatus, QueueConfigData, Response, ResponseV0, ResponseV1, ResponseV2, ResponseV2Error, ResponseV2Result, VersionMigrationStage, VersionedMultiAsset, VersionedMultiAssets, VersionedMultiLocation, VersionedResponse, VersionedXcm, WeightLimitV2, WildFungibility, WildFungibilityV0, WildFungibilityV1, WildFungibilityV2, WildMultiAsset, WildMultiAssetV1, WildMultiAssetV2, Xcm, XcmAssetId, XcmError, XcmErrorV0, XcmErrorV1, XcmErrorV2, XcmOrder, XcmOrderV0, XcmOrderV1, XcmOrderV2, XcmOrigin, XcmOriginKind, XcmV0, XcmV1, XcmV2, XcmVersion, XcmpMessageFormat } from '@polkadot/types/interfaces/xcm'; -declare module '@polkadot/types-augment/registry' { +declare module '@polkadot/types/types/registry' { export interface InterfaceTypes { AbridgedCandidateReceipt: AbridgedCandidateReceipt; AbridgedHostConfiguration: AbridgedHostConfiguration; diff --git a/packages/types-augment/src/augment/types/index.ts b/packages/types-augment/src/augment/types/index.ts deleted file mode 100644 index 2c2ed46c05..0000000000 --- a/packages/types-augment/src/augment/types/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2017-2021 @polkadot/types-augment authors & contributors -// SPDX-License-Identifier: Apache-2.0 - -// NOTE: This is not a typical types export, rather this is to augment types - -import './lookup'; -import './registry'; diff --git a/packages/types-augment/src/augment/types/lookup.ts b/packages/types-augment/src/augment/types/lookup.ts deleted file mode 100644 index ebe3ac4c45..0000000000 --- a/packages/types-augment/src/augment/types/lookup.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2017-2021 @polkadot/types-augment authors & contributors -// SPDX-License-Identifier: Apache-2.0 - -declare module '@polkadot/types/lookup' { - export * from '@polkadot/types-augment/lookup'; -} diff --git a/packages/types-augment/src/augment/types/registry.ts b/packages/types-augment/src/augment/types/registry.ts deleted file mode 100644 index 2b137f5117..0000000000 --- a/packages/types-augment/src/augment/types/registry.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2017-2021 @polkadot/types-augment authors & contributors -// SPDX-License-Identifier: Apache-2.0 - -declare module '@polkadot/types/types/registry' { - export { InterfaceTypes } from '@polkadot/types-augment/registry'; -} diff --git a/packages/types-codec/tsconfig.json b/packages/types-codec/tsconfig.json index 245ea120ea..eb4a7fbcd1 100644 --- a/packages/types-codec/tsconfig.json +++ b/packages/types-codec/tsconfig.json @@ -8,7 +8,7 @@ }, "exclude": [ "**/*.data.ts", - "**/*.manual.ts", + "**/checkTypes.manual.ts", "**/*.spec.ts" ], "references": [] diff --git a/packages/types-codec/tsconfig.spec.json b/packages/types-codec/tsconfig.spec.json index 6fc411a0b0..45c6f8b152 100644 --- a/packages/types-codec/tsconfig.spec.json +++ b/packages/types-codec/tsconfig.spec.json @@ -10,7 +10,7 @@ }, "include": [ "**/*.data.ts", - "**/*.manual.ts", + "**/checkTypes.manual.ts", "**/*.spec.ts" ], "references": [ diff --git a/packages/types-create/package.json b/packages/types-create/package.json index 623b550727..2e3338ea7b 100644 --- a/packages/types-create/package.json +++ b/packages/types-create/package.json @@ -24,6 +24,7 @@ "main": "index.js", "dependencies": { "@babel/runtime": "^7.16.5", + "@polkadot/types-codec": "6.12.2-20", "@polkadot/util": "^8.2.2" } } diff --git a/packages/types/tsconfig.json b/packages/types/tsconfig.json index b54f4d2e58..d7df5670f6 100644 --- a/packages/types/tsconfig.json +++ b/packages/types/tsconfig.json @@ -7,7 +7,7 @@ "resolveJsonModule": true }, "exclude": [ - "**/*.manual.ts", + "**/checkTypes.manual.ts", "**/*.spec.ts" ], "references": [ diff --git a/packages/types/tsconfig.spec.json b/packages/types/tsconfig.spec.json index 7fe2f1f98c..0689416e42 100644 --- a/packages/types/tsconfig.spec.json +++ b/packages/types/tsconfig.spec.json @@ -9,7 +9,7 @@ "noEmit": true }, "include": [ - "**/*.manual.ts", + "**/checkTypes.manual.ts", "**/*.spec.ts" ], "references": [ diff --git a/tsconfig.full.json b/tsconfig.all.files.json similarity index 100% rename from tsconfig.full.json rename to tsconfig.all.files.json diff --git a/tsconfig.all.refs.json b/tsconfig.all.refs.json new file mode 100644 index 0000000000..cef845e4cc --- /dev/null +++ b/tsconfig.all.refs.json @@ -0,0 +1,31 @@ +{ + "compilerOptions": { + "composite": true + }, + "files": [], + "references": [ + { "path": "./packages/api" }, + { "path": "./packages/api/tsconfig.spec.json" }, + { "path": "./packages/api-augment" }, + { "path": "./packages/api-base" }, + { "path": "./packages/api-contract" }, + { "path": "./packages/api-contract/tsconfig.spec.json" }, + { "path": "./packages/api-derive" }, + { "path": "./packages/api-derive/tsconfig.spec.json" }, + { "path": "./packages/rpc-augment" }, + { "path": "./packages/rpc-core" }, + { "path": "./packages/rpc-core/tsconfig.spec.json" }, + { "path": "./packages/rpc-provider" }, + { "path": "./packages/rpc-provider/tsconfig.spec.json" }, + { "path": "./packages/typegen" }, + { "path": "./packages/types" }, + { "path": "./packages/types/tsconfig.spec.json" }, + { "path": "./packages/types-augment" }, + { "path": "./packages/types-codec" }, + { "path": "./packages/types-codec/tsconfig.spec.json" }, + { "path": "./packages/types-create" }, + { "path": "./packages/types-create/tsconfig.spec.json" }, + { "path": "./packages/types-known" }, + { "path": "./packages/types-support" } + ] +} diff --git a/tsconfig.json b/tsconfig.json index cef845e4cc..fbabb6b653 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,31 +1,3 @@ { - "compilerOptions": { - "composite": true - }, - "files": [], - "references": [ - { "path": "./packages/api" }, - { "path": "./packages/api/tsconfig.spec.json" }, - { "path": "./packages/api-augment" }, - { "path": "./packages/api-base" }, - { "path": "./packages/api-contract" }, - { "path": "./packages/api-contract/tsconfig.spec.json" }, - { "path": "./packages/api-derive" }, - { "path": "./packages/api-derive/tsconfig.spec.json" }, - { "path": "./packages/rpc-augment" }, - { "path": "./packages/rpc-core" }, - { "path": "./packages/rpc-core/tsconfig.spec.json" }, - { "path": "./packages/rpc-provider" }, - { "path": "./packages/rpc-provider/tsconfig.spec.json" }, - { "path": "./packages/typegen" }, - { "path": "./packages/types" }, - { "path": "./packages/types/tsconfig.spec.json" }, - { "path": "./packages/types-augment" }, - { "path": "./packages/types-codec" }, - { "path": "./packages/types-codec/tsconfig.spec.json" }, - { "path": "./packages/types-create" }, - { "path": "./packages/types-create/tsconfig.spec.json" }, - { "path": "./packages/types-known" }, - { "path": "./packages/types-support" } - ] + "extends": "./tsconfig.all.refs.json" } diff --git a/yarn.lock b/yarn.lock index 994b62f61e..cbde15678b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1873,8 +1873,8 @@ __metadata: dependencies: "@babel/runtime": ^7.16.5 "@polkadot/api-base": 6.12.2-20 - "@polkadot/rpc-core": 6.12.2-20 "@polkadot/types": 6.12.2-20 + "@polkadot/types-codec": 6.12.2-20 languageName: unknown linkType: soft @@ -1938,9 +1938,9 @@ __metadata: languageName: unknown linkType: soft -"@polkadot/dev@npm:^0.64.5": - version: 0.64.5 - resolution: "@polkadot/dev@npm:0.64.5" +"@polkadot/dev@npm:^0.64.6": + version: 0.64.6 + resolution: "@polkadot/dev@npm:0.64.6" dependencies: "@babel/cli": ^7.16.0 "@babel/core": ^7.16.5 @@ -2025,7 +2025,7 @@ __metadata: polkadot-exec-rollup: scripts/polkadot-exec-rollup.mjs polkadot-exec-tsc: scripts/polkadot-exec-tsc.mjs polkadot-exec-webpack: scripts/polkadot-exec-webpack.mjs - checksum: 04a30123e45254058afb772b8484fabb537ebeda07fc7aa595dec1e384b52fcf8cb9be0e2050b4961e63c0adfd2bc9b8d4f78dc8eabfed91a62b5f7ae84681f3 + checksum: 9a4f05074fc99ddeb7843f8a14c1b14a8041e23d35590664032e4c3972f6ca6bc1352893698d8be7efacaf06fef09d3fce6b7f8f12612c89c0fdf6ced8f45908 languageName: node linkType: hard @@ -2158,6 +2158,7 @@ __metadata: resolution: "@polkadot/types-create@workspace:packages/types-create" dependencies: "@babel/runtime": ^7.16.5 + "@polkadot/types-codec": 6.12.2-20 "@polkadot/util": ^8.2.2 languageName: unknown linkType: soft @@ -8963,7 +8964,7 @@ resolve@^2.0.0-next.3: "@babel/core": ^7.16.5 "@babel/register": ^7.16.5 "@babel/runtime": ^7.16.5 - "@polkadot/dev": ^0.64.5 + "@polkadot/dev": ^0.64.6 "@polkadot/ts": ^0.4.20 "@polkadot/typegen": "workspace:packages/typegen" "@types/jest": ^27.0.3