From 664e9e8f2632667c35e5210279989c0deb972689 Mon Sep 17 00:00:00 2001 From: Jaco Date: Fri, 17 Dec 2021 11:26:26 +0100 Subject: [PATCH] References for api augmentation (#4346) * References for api augmentation * Adjust * Progress... let's see where it leads * It compiles... * Adjust * CC ignore --- .codeclimate.yml | 2 +- .gitignore | 2 +- jest.config.cjs | 2 +- packages/api-augment/LICENSE | 201 ++++++++++++++++++ packages/api-augment/README.md | 3 + packages/api-augment/package.json | 32 +++ .../index.ts => api-augment/src/bundle.ts} | 4 +- .../src/augment => api-augment/src}/consts.ts | 2 +- packages/api-augment/src/detectPackage.ts | 10 + .../src/augment => api-augment/src}/errors.ts | 2 +- .../src/augment => api-augment/src}/events.ts | 2 +- packages/api-augment/src/index.ts | 6 + packages/api-augment/src/packageInfo.ts | 6 + .../src/augment => api-augment/src}/query.ts | 6 +- .../src/augment => api-augment/src}/rpc.ts | 0 .../src/augment => api-augment/src}/tx.ts | 2 +- packages/api-augment/tsconfig.json | 13 ++ packages/api-base/LICENSE | 201 ++++++++++++++++++ packages/api-base/README.md | 3 + packages/api-base/package.json | 31 +++ packages/api-base/src/bundle.ts | 4 + packages/api-base/src/detectPackage.ts | 9 + packages/api-base/src/index.ts | 6 + packages/api-base/src/packageInfo.ts | 6 + packages/{api => api-base}/src/types/base.ts | 0 .../{api => api-base}/src/types/consts.ts | 0 .../{api => api-base}/src/types/errors.ts | 0 .../{api => api-base}/src/types/events.ts | 0 packages/api-base/src/types/index.ts | 10 + packages/{api => api-base}/src/types/rpc.ts | 0 .../{api => api-base}/src/types/storage.ts | 5 - packages/api-base/src/types/submittable.ts | 82 +++++++ packages/api-base/tsconfig.json | 12 ++ packages/api/package.json | 2 + packages/api/src/submittable/types.ts | 69 +----- packages/api/src/{types/index.ts => types.ts} | 26 +-- packages/api/src/types/submittable.ts | 17 -- packages/api/tsconfig.json | 6 + packages/typegen/scripts/aliases.cjs | 2 + packages/typegen/src/generate/consts.ts | 4 +- packages/typegen/src/generate/errors.ts | 4 +- packages/typegen/src/generate/events.ts | 4 +- packages/typegen/src/generate/query.ts | 6 +- packages/typegen/src/generate/rpc.ts | 2 +- packages/typegen/src/generate/tx.ts | 4 +- packages/typegen/src/templates/query.hbs | 6 + rollup.config.mjs | 2 +- tsconfig.base.json | 4 + tsconfig.json | 2 + yarn.lock | 25 +++ 50 files changed, 720 insertions(+), 129 deletions(-) create mode 100644 packages/api-augment/LICENSE create mode 100644 packages/api-augment/README.md create mode 100644 packages/api-augment/package.json rename packages/{api/src/augment/index.ts => api-augment/src/bundle.ts} (61%) rename packages/{api/src/augment => api-augment/src}/consts.ts (99%) create mode 100644 packages/api-augment/src/detectPackage.ts rename packages/{api/src/augment => api-augment/src}/errors.ts (99%) rename packages/{api/src/augment => api-augment/src}/events.ts (99%) create mode 100644 packages/api-augment/src/index.ts create mode 100644 packages/api-augment/src/packageInfo.ts rename packages/{api/src/augment => api-augment/src}/query.ts (99%) rename packages/{api/src/augment => api-augment/src}/rpc.ts (100%) rename packages/{api/src/augment => api-augment/src}/tx.ts (99%) create mode 100644 packages/api-augment/tsconfig.json create mode 100644 packages/api-base/LICENSE create mode 100644 packages/api-base/README.md create mode 100644 packages/api-base/package.json create mode 100644 packages/api-base/src/bundle.ts create mode 100644 packages/api-base/src/detectPackage.ts create mode 100644 packages/api-base/src/index.ts create mode 100644 packages/api-base/src/packageInfo.ts rename packages/{api => api-base}/src/types/base.ts (100%) rename packages/{api => api-base}/src/types/consts.ts (100%) rename packages/{api => api-base}/src/types/errors.ts (100%) rename packages/{api => api-base}/src/types/events.ts (100%) create mode 100644 packages/api-base/src/types/index.ts rename packages/{api => api-base}/src/types/rpc.ts (100%) rename packages/{api => api-base}/src/types/storage.ts (96%) create mode 100644 packages/api-base/src/types/submittable.ts create mode 100644 packages/api-base/tsconfig.json rename packages/api/src/{types/index.ts => types.ts} (87%) delete mode 100644 packages/api/src/types/submittable.ts diff --git a/.codeclimate.yml b/.codeclimate.yml index e1a5b86470..394f70db32 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -19,7 +19,7 @@ exclude_patterns: - "**/*.test.ts" - "docs/**/*.js" - "docs/**/*.ts" -- "packages/api/src/augment/" +- "packages/api-augment/" - "packages/typegen/scripts" - "packages/typegen/src" - "packages/types/src/interfaces/" diff --git a/.gitignore b/.gitignore index d06d28df5c..cdab3a7a90 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,6 @@ cc-test-reporter lerna-debug.log* npm-debug.log* package-lock.json -tsconfig.*buildinfo +tsconfig*buildinfo yarn-debug.log* yarn-error.log* diff --git a/jest.config.cjs b/jest.config.cjs index 4770a4c536..3b81be3cf7 100644 --- a/jest.config.cjs +++ b/jest.config.cjs @@ -6,7 +6,7 @@ const config = require('@polkadot/dev/config/jest.cjs'); module.exports = { ...config, moduleNameMapper: { - '@polkadot/api-(contract|derive)(.*)$': '/packages/api-$1/src/$2', + '@polkadot/api-(augment|base|contract|derive)(.*)$': '/packages/api-$1/src/$2', // eslint-disable-next-line sort-keys '@polkadot/api(.*)$': '/packages/api/src/$1', '@polkadot/rpc-(core|provider)(.*)$': '/packages/rpc-$1/src/$2', diff --git a/packages/api-augment/LICENSE b/packages/api-augment/LICENSE new file mode 100644 index 0000000000..0d381b2e97 --- /dev/null +++ b/packages/api-augment/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/packages/api-augment/README.md b/packages/api-augment/README.md new file mode 100644 index 0000000000..c45d91fe41 --- /dev/null +++ b/packages/api-augment/README.md @@ -0,0 +1,3 @@ +# @polkadot/api-augment + +Generated augmentation. diff --git a/packages/api-augment/package.json b/packages/api-augment/package.json new file mode 100644 index 0000000000..1758fa785f --- /dev/null +++ b/packages/api-augment/package.json @@ -0,0 +1,32 @@ +{ + "author": "Jaco Greeff ", + "bugs": "https://github.com/polkadot-js/api/issues", + "contributors": [], + "description": "API generated augmentation", + "engines": { + "node": ">=14.0.0" + }, + "homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-augment#readme", + "license": "Apache-2.0", + "maintainers": [], + "name": "@polkadot/api-augment", + "repository": { + "directory": "packages/api-augment", + "type": "git", + "url": "https://github.com/polkadot-js/api.git" + }, + "sideEffects": [ + "./detectPackage.js", + "./detectPackage.cjs" + ], + "type": "module", + "version": "6.12.2-11", + "main": "index.js", + "dependencies": { + "@babel/runtime": "^7.16.5", + "@polkadot/api-base": "6.12.2-11", + "@polkadot/rpc-core": "6.12.2-11", + "@polkadot/types": "6.12.2-11", + "@polkadot/util": "^8.1.2" + } +} diff --git a/packages/api/src/augment/index.ts b/packages/api-augment/src/bundle.ts similarity index 61% rename from packages/api/src/augment/index.ts rename to packages/api-augment/src/bundle.ts index 348dd02954..9dba0c3543 100644 --- a/packages/api/src/augment/index.ts +++ b/packages/api-augment/src/bundle.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2021 @polkadot/api authors & contributors +// Copyright 2017-2021 @polkadot/api-contract authors & contributors // SPDX-License-Identifier: Apache-2.0 import '@polkadot/types/augment'; @@ -8,3 +8,5 @@ import './events'; import './query'; import './rpc'; import './tx'; + +export { packageInfo } from './packageInfo'; diff --git a/packages/api/src/augment/consts.ts b/packages/api-augment/src/consts.ts similarity index 99% rename from packages/api/src/augment/consts.ts rename to packages/api-augment/src/consts.ts index 99907b8773..1cb94d7e45 100644 --- a/packages/api/src/augment/consts.ts +++ b/packages/api-augment/src/consts.ts @@ -2,7 +2,7 @@ /* eslint-disable */ declare module '@polkadot/api/types/consts' { - import type { ApiTypes, AugmentedConst, QueryableModuleConsts } from '@polkadot/api/types'; + import type { ApiTypes, AugmentedConst, QueryableModuleConsts } from '@polkadot/api-base/types'; import type { U8aFixed, Vec, bool, u128, u16, u32, u64, u8 } from '@polkadot/types'; import type { Perbill, Percent, Permill } from '@polkadot/types/interfaces/runtime'; import type { FrameSupportPalletId, FrameSupportWeightsRuntimeDbWeight, FrameSupportWeightsWeightToFeeCoefficient, FrameSystemLimitsBlockLength, FrameSystemLimitsBlockWeights, PalletContractsSchedule, SpVersionRuntimeVersion } from '@polkadot/types/lookup'; diff --git a/packages/api-augment/src/detectPackage.ts b/packages/api-augment/src/detectPackage.ts new file mode 100644 index 0000000000..829ddb77a7 --- /dev/null +++ b/packages/api-augment/src/detectPackage.ts @@ -0,0 +1,10 @@ +// Copyright 2017-2021 @polkadot/api-contract authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import { packageInfo as rpcInfo } from '@polkadot/rpc-core/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]); diff --git a/packages/api/src/augment/errors.ts b/packages/api-augment/src/errors.ts similarity index 99% rename from packages/api/src/augment/errors.ts rename to packages/api-augment/src/errors.ts index 91abb23c0d..8180de3889 100644 --- a/packages/api/src/augment/errors.ts +++ b/packages/api-augment/src/errors.ts @@ -2,7 +2,7 @@ /* eslint-disable */ declare module '@polkadot/api/types/errors' { - import type { ApiTypes, AugmentedError, ModuleErrors } from '@polkadot/api/types'; + import type { ApiTypes, AugmentedError, ModuleErrors } from '@polkadot/api-base/types'; export interface AugmentedErrors { assets: { diff --git a/packages/api/src/augment/events.ts b/packages/api-augment/src/events.ts similarity index 99% rename from packages/api/src/augment/events.ts rename to packages/api-augment/src/events.ts index 26907caaf7..24608a73d2 100644 --- a/packages/api/src/augment/events.ts +++ b/packages/api-augment/src/events.ts @@ -2,7 +2,7 @@ /* eslint-disable */ declare module '@polkadot/api/types/events' { - import type { ApiTypes, AugmentedEvent, ModuleEvents } from '@polkadot/api/types'; + import type { ApiTypes, AugmentedEvent, ModuleEvents } from '@polkadot/api-base/types'; import type { Bytes, Null, Option, Result, U8aFixed, Vec, bool, u128, u16, u32, u64, u8 } from '@polkadot/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'; diff --git a/packages/api-augment/src/index.ts b/packages/api-augment/src/index.ts new file mode 100644 index 0000000000..b718d85e20 --- /dev/null +++ b/packages/api-augment/src/index.ts @@ -0,0 +1,6 @@ +// Copyright 2017-2021 @polkadot/api-contract authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import './detectPackage'; + +export * from './bundle'; diff --git a/packages/api-augment/src/packageInfo.ts b/packages/api-augment/src/packageInfo.ts new file mode 100644 index 0000000000..dfb457fd2b --- /dev/null +++ b/packages/api-augment/src/packageInfo.ts @@ -0,0 +1,6 @@ +// Copyright 2017-2021 @polkadot/api-augment authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +// Auto-generated by @polkadot/dev, do not edit + +export const packageInfo = { name: '@polkadot/api-augment', version: '6.12.2-11' }; diff --git a/packages/api/src/augment/query.ts b/packages/api-augment/src/query.ts similarity index 99% rename from packages/api/src/augment/query.ts rename to packages/api-augment/src/query.ts index 3ca279a7bb..a8503b4a3c 100644 --- a/packages/api/src/augment/query.ts +++ b/packages/api-augment/src/query.ts @@ -2,7 +2,7 @@ /* eslint-disable */ declare module '@polkadot/api/types/storage' { - import type { ApiTypes, AugmentedQuery, QueryableModuleStorage, QueryableStorageEntry } from '@polkadot/api/types'; + import type { ApiTypes, AugmentedQuery, QueryableModuleStorage, QueryableModuleStorageAt, QueryableStorageEntry } from '@polkadot/api-base/types'; import type { BTreeMap, Bytes, Data, Null, Option, U8aFixed, Vec, WrapperOpaque, bool, u128, u32, u64, u8 } from '@polkadot/types'; import type { AccountId32, Call, H256, Perbill, Percent } from '@polkadot/types/interfaces/runtime'; 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'; @@ -1453,4 +1453,8 @@ declare module '@polkadot/api/types/storage' { [key: string]: QueryableModuleStorage; } // QueryableStorage + export interface QueryableStorageAt extends AugmentedQueries { + [key: string]: QueryableModuleStorageAt; + } // QueryableStorageAt + } // declare module diff --git a/packages/api/src/augment/rpc.ts b/packages/api-augment/src/rpc.ts similarity index 100% rename from packages/api/src/augment/rpc.ts rename to packages/api-augment/src/rpc.ts diff --git a/packages/api/src/augment/tx.ts b/packages/api-augment/src/tx.ts similarity index 99% rename from packages/api/src/augment/tx.ts rename to packages/api-augment/src/tx.ts index 5ae2dea52a..865f3a7a18 100644 --- a/packages/api/src/augment/tx.ts +++ b/packages/api-augment/src/tx.ts @@ -2,7 +2,7 @@ /* eslint-disable */ declare module '@polkadot/api/types/submittable' { - import type { ApiTypes, AugmentedSubmittable, SubmittableExtrinsic, SubmittableExtrinsicFunction, SubmittableModuleExtrinsics } from '@polkadot/api/types'; + import type { ApiTypes, AugmentedSubmittable, SubmittableExtrinsic, SubmittableExtrinsicFunction, SubmittableModuleExtrinsics } from '@polkadot/api-base/types'; import type { Bytes, Compact, Data, Option, U8aFixed, Vec, bool, u128, u16, u32, u64, u8 } from '@polkadot/types'; import type { Extrinsic } from '@polkadot/types/interfaces/extrinsics'; import type { AccountId32, Call, H256, MultiAddress, Perbill, Percent, Perquintill } from '@polkadot/types/interfaces/runtime'; diff --git a/packages/api-augment/tsconfig.json b/packages/api-augment/tsconfig.json new file mode 100644 index 0000000000..3952b3b3a7 --- /dev/null +++ b/packages/api-augment/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "baseUrl": "..", + "outDir": "./build", + "rootDir": "./src" + }, + "references": [ + { "path": "../api-base" }, + { "path": "../rpc-core" }, + { "path": "../types" } + ] +} diff --git a/packages/api-base/LICENSE b/packages/api-base/LICENSE new file mode 100644 index 0000000000..0d381b2e97 --- /dev/null +++ b/packages/api-base/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/packages/api-base/README.md b/packages/api-base/README.md new file mode 100644 index 0000000000..23b27e1160 --- /dev/null +++ b/packages/api-base/README.md @@ -0,0 +1,3 @@ +# @polkadot/api-base + +API Base interfaces diff --git a/packages/api-base/package.json b/packages/api-base/package.json new file mode 100644 index 0000000000..0a7ff6a8d5 --- /dev/null +++ b/packages/api-base/package.json @@ -0,0 +1,31 @@ +{ + "author": "Jaco Greeff ", + "bugs": "https://github.com/polkadot-js/api/issues", + "contributors": [], + "description": "Interfaces for interacting with contracts and contract ABIs", + "engines": { + "node": ">=14.0.0" + }, + "homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-base#readme", + "license": "Apache-2.0", + "maintainers": [], + "name": "@polkadot/api-base", + "repository": { + "directory": "packages/api-base", + "type": "git", + "url": "https://github.com/polkadot-js/api.git" + }, + "sideEffects": [ + "./detectPackage.js", + "./detectPackage.cjs" + ], + "type": "module", + "version": "6.12.2-11", + "main": "index.js", + "dependencies": { + "@babel/runtime": "^7.16.5", + "@polkadot/types": "6.12.2-11", + "@polkadot/util": "^8.1.2", + "rxjs": "^7.4.0" + } +} diff --git a/packages/api-base/src/bundle.ts b/packages/api-base/src/bundle.ts new file mode 100644 index 0000000000..dc10cc1af7 --- /dev/null +++ b/packages/api-base/src/bundle.ts @@ -0,0 +1,4 @@ +// Copyright 2017-2021 @polkadot/api-contract authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +export { packageInfo } from './packageInfo'; diff --git a/packages/api-base/src/detectPackage.ts b/packages/api-base/src/detectPackage.ts new file mode 100644 index 0000000000..48dfb22bf6 --- /dev/null +++ b/packages/api-base/src/detectPackage.ts @@ -0,0 +1,9 @@ +// Copyright 2017-2021 @polkadot/api-contract authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import { packageInfo as typesInfo } from '@polkadot/types/packageInfo'; +import { detectPackage } from '@polkadot/util'; + +import { packageInfo } from './packageInfo'; + +detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [typesInfo]); diff --git a/packages/api-base/src/index.ts b/packages/api-base/src/index.ts new file mode 100644 index 0000000000..b718d85e20 --- /dev/null +++ b/packages/api-base/src/index.ts @@ -0,0 +1,6 @@ +// Copyright 2017-2021 @polkadot/api-contract authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import './detectPackage'; + +export * from './bundle'; diff --git a/packages/api-base/src/packageInfo.ts b/packages/api-base/src/packageInfo.ts new file mode 100644 index 0000000000..7490c73406 --- /dev/null +++ b/packages/api-base/src/packageInfo.ts @@ -0,0 +1,6 @@ +// Copyright 2017-2021 @polkadot/api-base authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +// Auto-generated by @polkadot/dev, do not edit + +export const packageInfo = { name: '@polkadot/api-base', version: '6.12.2-11' }; diff --git a/packages/api/src/types/base.ts b/packages/api-base/src/types/base.ts similarity index 100% rename from packages/api/src/types/base.ts rename to packages/api-base/src/types/base.ts diff --git a/packages/api/src/types/consts.ts b/packages/api-base/src/types/consts.ts similarity index 100% rename from packages/api/src/types/consts.ts rename to packages/api-base/src/types/consts.ts diff --git a/packages/api/src/types/errors.ts b/packages/api-base/src/types/errors.ts similarity index 100% rename from packages/api/src/types/errors.ts rename to packages/api-base/src/types/errors.ts diff --git a/packages/api/src/types/events.ts b/packages/api-base/src/types/events.ts similarity index 100% rename from packages/api/src/types/events.ts rename to packages/api-base/src/types/events.ts diff --git a/packages/api-base/src/types/index.ts b/packages/api-base/src/types/index.ts new file mode 100644 index 0000000000..0f544142cd --- /dev/null +++ b/packages/api-base/src/types/index.ts @@ -0,0 +1,10 @@ +// Copyright 2017-2021 @polkadot/api authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +export * from './base'; +export * from './consts'; +export * from './errors'; +export * from './events'; +export * from './rpc'; +export * from './storage'; +export * from './submittable'; diff --git a/packages/api/src/types/rpc.ts b/packages/api-base/src/types/rpc.ts similarity index 100% rename from packages/api/src/types/rpc.ts rename to packages/api-base/src/types/rpc.ts diff --git a/packages/api/src/types/storage.ts b/packages/api-base/src/types/storage.ts similarity index 96% rename from packages/api/src/types/storage.ts rename to packages/api-base/src/types/storage.ts index 8612b5b74f..f5f9c64ad9 100644 --- a/packages/api/src/types/storage.ts +++ b/packages/api-base/src/types/storage.ts @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 import type { Observable } from 'rxjs'; -import type { AugmentedQueries } from '@polkadot/api/types/storage'; import type { StorageKey, u64 } from '@polkadot/types'; import type { Hash } from '@polkadot/types/interfaces'; import type { StorageEntry } from '@polkadot/types/primitive/types'; @@ -51,10 +50,6 @@ export type QueryableStorageEntryAt : AugmentedQueryAt<'promise', GenericStorageEntryFunction, A> & StorageEntryPromiseOverloadsAt; -export interface QueryableStorageAt extends AugmentedQueries { - [key: string]: QueryableModuleStorageAt; -} - export interface StorageEntryBase extends StorageEntryBaseAt { /** * @deprecated Use api.at() diff --git a/packages/api-base/src/types/submittable.ts b/packages/api-base/src/types/submittable.ts new file mode 100644 index 0000000000..d456b814b8 --- /dev/null +++ b/packages/api-base/src/types/submittable.ts @@ -0,0 +1,82 @@ +// Copyright 2017-2021 @polkadot/api 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 { AnyFunction, AnyNumber, AnyTuple, Callback, CallBase, Codec, IExtrinsicEra, IKeyringPair, ISubmittableResult, Signer } from '@polkadot/types/types'; +import type { ApiTypes, PromiseOrObs } from './base'; + +export type AddressOrPair = IKeyringPair | string | AccountId | Address; + +export type AugmentedSubmittable = T & CallBase; + +export interface SignerOptions { + blockHash: Uint8Array | string; + era?: IExtrinsicEra | number; + nonce: AnyNumber | Codec; + signer?: Signer; + tip?: AnyNumber; + assetId?: AnyNumber; +} + +export type SubmittableDryRunResult = + ApiType extends 'rxjs' + ? Observable + : Promise; + +export interface SubmittableExtrinsicFunction extends CallBase { + (...params: any[]): SubmittableExtrinsic; +} + +export interface SubmittableModuleExtrinsics { + // only with is augmentation + [index: string]: SubmittableExtrinsicFunction; // | AugmentedIsSubmittable; +} + +export type SubmittablePaymentResult = + ApiType extends 'rxjs' + ? Observable + : Promise; + +export type SubmittableResultResult = + ApiType extends 'rxjs' + ? Observable + : Promise; + +export type SubmittableResultSubscription = + ApiType extends 'rxjs' + ? Observable + : Promise<() => void>; + +export interface SubmittableResultValue { + dispatchError?: DispatchError; + dispatchInfo?: DispatchInfo; + events?: EventRecord[]; + internalError?: Error; + status: ExtrinsicStatus; +} + +export interface SubmittableExtrinsic extends Extrinsic { + dryRun (account: AddressOrPair, options?: Partial): SubmittableDryRunResult; + + paymentInfo (account: AddressOrPair, options?: Partial): SubmittablePaymentResult; + + send (): SubmittableResultResult; + + send (statusCb: Callback): SubmittableResultSubscription; + + /** + * @deprecated + */ + sign (account: IKeyringPair, _options?: Partial): this; + + signAsync (account: AddressOrPair, _options?: Partial): PromiseOrObs; + + signAndSend (account: AddressOrPair, options?: Partial): SubmittableResultResult; + + signAndSend (account: AddressOrPair, statusCb: Callback): SubmittableResultSubscription; + + signAndSend (account: AddressOrPair, options: Partial, statusCb?: Callback): SubmittableResultSubscription; + + withResultTransform (transform: (input: ISubmittableResult) => ISubmittableResult): this; +} diff --git a/packages/api-base/tsconfig.json b/packages/api-base/tsconfig.json new file mode 100644 index 0000000000..22f28e07d6 --- /dev/null +++ b/packages/api-base/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "baseUrl": "..", + "outDir": "./build", + "rootDir": "./src" + }, + "references": [ + { "path": "../rpc-core" }, + { "path": "../types" } + ] +} diff --git a/packages/api/package.json b/packages/api/package.json index 5a3edbf7a4..f4865d9b56 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -24,6 +24,8 @@ "main": "index.js", "dependencies": { "@babel/runtime": "^7.16.5", + "@polkadot/api-augment": "6.12.2-11", + "@polkadot/api-base": "6.12.2-11", "@polkadot/api-derive": "6.12.2-11", "@polkadot/keyring": "^8.1.2", "@polkadot/rpc-core": "6.12.2-11", diff --git a/packages/api/src/submittable/types.ts b/packages/api/src/submittable/types.ts index 9560537ae0..b4af7f71da 100644 --- a/packages/api/src/submittable/types.ts +++ b/packages/api/src/submittable/types.ts @@ -1,71 +1,4 @@ // Copyright 2017-2021 @polkadot/api 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 { AnyNumber, Callback, Codec, IExtrinsicEra, IKeyringPair, ISubmittableResult, Signer } from '@polkadot/types/types'; -import type { ApiTypes, PromiseOrObs } from '../types'; - -export interface SubmittableResultValue { - dispatchError?: DispatchError; - dispatchInfo?: DispatchInfo; - events?: EventRecord[]; - internalError?: Error; - status: ExtrinsicStatus; -} - -export type SubmittableDryRunResult = - ApiType extends 'rxjs' - ? Observable - : Promise; - -export type SubmittablePaymentResult = - ApiType extends 'rxjs' - ? Observable - : Promise; - -export type SubmittableResultResult = - ApiType extends 'rxjs' - ? Observable - : Promise; - -export type SubmittableResultSubscription = - ApiType extends 'rxjs' - ? Observable - : Promise<() => void>; - -export interface SignerOptions { - blockHash: Uint8Array | string; - era?: IExtrinsicEra | number; - nonce: AnyNumber | Codec; - signer?: Signer; - tip?: AnyNumber; - assetId?: AnyNumber; -} - -export type AddressOrPair = IKeyringPair | string | AccountId | Address; - -export interface SubmittableExtrinsic extends Extrinsic { - dryRun (account: AddressOrPair, options?: Partial): SubmittableDryRunResult; - - paymentInfo (account: AddressOrPair, options?: Partial): SubmittablePaymentResult; - - send (): SubmittableResultResult; - - send (statusCb: Callback): SubmittableResultSubscription; - - /** - * @deprecated - */ - sign (account: IKeyringPair, _options?: Partial): this; - - signAsync (account: AddressOrPair, _options?: Partial): PromiseOrObs; - - signAndSend (account: AddressOrPair, options?: Partial): SubmittableResultResult; - - signAndSend (account: AddressOrPair, statusCb: Callback): SubmittableResultSubscription; - - signAndSend (account: AddressOrPair, options: Partial, statusCb?: Callback): SubmittableResultSubscription; - - withResultTransform (transform: (input: ISubmittableResult) => ISubmittableResult): this; -} +export type { AddressOrPair, SignerOptions, SubmittableDryRunResult, SubmittableExtrinsic, SubmittablePaymentResult, SubmittableResultResult, SubmittableResultSubscription, SubmittableResultValue } from '@polkadot/api-base/types'; diff --git a/packages/api/src/types/index.ts b/packages/api/src/types.ts similarity index 87% rename from packages/api/src/types/index.ts rename to packages/api/src/types.ts index 5ab97e8bf0..4f7ef4e720 100644 --- a/packages/api/src/types/index.ts +++ b/packages/api/src/types.ts @@ -1,7 +1,7 @@ // Copyright 2017-2021 @polkadot/api authors & contributors // SPDX-License-Identifier: Apache-2.0 -import '@polkadot/api/augment'; +import '@polkadot/api-augment'; import type { Observable } from 'rxjs'; import type { QueryableConsts } from '@polkadot/api/types/consts'; @@ -9,6 +9,7 @@ import type { DecoratedErrors } from '@polkadot/api/types/errors'; import type { DecoratedEvents } from '@polkadot/api/types/events'; import type { QueryableStorage } from '@polkadot/api/types/storage'; import type { SubmittableExtrinsics } from '@polkadot/api/types/submittable'; +import type { ApiTypes, DecoratedRpc, QueryableStorageMulti } from '@polkadot/api-base/types'; import type { RpcInterface } from '@polkadot/rpc-core/types'; import type { ProviderInterface, ProviderInterfaceEmitted } from '@polkadot/rpc-provider/types'; import type { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types'; @@ -17,30 +18,21 @@ import type { Metadata } from '@polkadot/types/metadata'; 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 { DeriveCustom, ExactDerive } from '../derive'; -import type { DeriveAllSections } from '../util/decorate'; -import type { ApiTypes } from './base'; -import type { DecoratedRpc } from './rpc'; -import type { QueryableStorageMulti } from './storage'; +import type { ApiBase } from './base'; +import type { DeriveCustom, ExactDerive } from './derive'; +import type { DeriveAllSections } 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 * from '@polkadot/api/types/rpc'; +export * from '@polkadot/rpc-core/types'; export { Signer, SignerResult } from '@polkadot/types/types'; -export { ApiBase } from '../base'; -export * from '../submittable/types'; -export * from './base'; -export * from './consts'; -export * from './errors'; -export * from './events'; -export * from './rpc'; -export * from './storage'; -export * from './submittable'; +export { ApiBase } from './base'; export interface ApiOptions extends RegisteredTypes { /** diff --git a/packages/api/src/types/submittable.ts b/packages/api/src/types/submittable.ts deleted file mode 100644 index d3fe5b83ff..0000000000 --- a/packages/api/src/types/submittable.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2017-2021 @polkadot/api authors & contributors -// SPDX-License-Identifier: Apache-2.0 - -import type { AnyFunction, AnyTuple, CallBase } from '@polkadot/types/types'; -import type { SubmittableExtrinsic } from '../submittable/types'; -import type { ApiTypes } from './base'; - -export type AugmentedSubmittable = T & CallBase; - -export interface SubmittableExtrinsicFunction extends CallBase { - (...params: any[]): SubmittableExtrinsic; -} - -export interface SubmittableModuleExtrinsics { - // only with is augmentation - [index: string]: SubmittableExtrinsicFunction; // | AugmentedIsSubmittable; -} diff --git a/packages/api/tsconfig.json b/packages/api/tsconfig.json index a152a2e4e0..1e85d24407 100644 --- a/packages/api/tsconfig.json +++ b/packages/api/tsconfig.json @@ -5,7 +5,13 @@ "outDir": "./build", "rootDir": "./src" }, + "exclude": [ + "**/augment/*.ts", + "**/types-base/*.ts" + ], "references": [ + { "path": "../api-augment" }, + { "path": "../api-base" }, { "path": "../rpc-core" }, { "path": "../rpc-provider" }, { "path": "../types" }, diff --git a/packages/typegen/scripts/aliases.cjs b/packages/typegen/scripts/aliases.cjs index fe6802b5c0..7754f3921b 100644 --- a/packages/typegen/scripts/aliases.cjs +++ b/packages/typegen/scripts/aliases.cjs @@ -5,6 +5,8 @@ module.exports = { alias: { + '^@polkadot/api-augment(.*)': './packages/api-augment/src\\1', + '^@polkadot/api-base(.*)': './packages/api-base/src\\1', '^@polkadot/api-derive(.*)': './packages/api-derive/src\\1', '^@polkadot/api(.*)': './packages/api/src/\\1', '^@polkadot/rpc-core(.*)': './packages/rpc-core/src\\1', diff --git a/packages/typegen/src/generate/consts.ts b/packages/typegen/src/generate/consts.ts index beedc5b716..99ea11ebc6 100644 --- a/packages/typegen/src/generate/consts.ts +++ b/packages/typegen/src/generate/consts.ts @@ -75,7 +75,7 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes, types: Object.keys(imports.localTypes[packagePath]) })), { - file: '@polkadot/api/types', + file: '@polkadot/api-base/types', types: ['ApiTypes', 'AugmentedConst', 'QueryableModuleConsts'] } ] @@ -85,7 +85,7 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes, // Call `generateForMeta()` with current static metadata /** @internal */ -export function generateDefaultConsts (dest = 'packages/api/src/augment/consts.ts', data?: HexString, extraTypes: ExtraTypes = {}, isStrict = false, customLookupDefinitions?: Definitions): void { +export function generateDefaultConsts (dest = 'packages/api-augment/src/consts.ts', data?: HexString, extraTypes: ExtraTypes = {}, isStrict = false, customLookupDefinitions?: Definitions): void { const { metadata } = initMeta(data, extraTypes); return generateForMeta(metadata, dest, extraTypes, isStrict, customLookupDefinitions); diff --git a/packages/typegen/src/generate/errors.ts b/packages/typegen/src/generate/errors.ts index f5e3c5b9fb..f1a8461e2e 100644 --- a/packages/typegen/src/generate/errors.ts +++ b/packages/typegen/src/generate/errors.ts @@ -38,7 +38,7 @@ function generateForMeta (meta: Metadata, dest: string, isStrict: boolean): void modules, types: [ { - file: '@polkadot/api/types', + file: '@polkadot/api-base/types', types: ['ApiTypes', 'AugmentedError', 'ModuleErrors'] } ] @@ -48,7 +48,7 @@ function generateForMeta (meta: Metadata, dest: string, isStrict: boolean): void // Call `generateForMeta()` with current static metadata /** @internal */ -export function generateDefaultErrors (dest = 'packages/api/src/augment/errors.ts', data?: HexString, extraTypes: ExtraTypes = {}, isStrict = false): void { +export function generateDefaultErrors (dest = 'packages/api-augment/src/errors.ts', data?: HexString, extraTypes: ExtraTypes = {}, isStrict = false): void { const { metadata } = initMeta(data, extraTypes); return generateForMeta(metadata, dest, isStrict); diff --git a/packages/typegen/src/generate/events.ts b/packages/typegen/src/generate/events.ts index 9792fc105a..59074c2ab3 100644 --- a/packages/typegen/src/generate/events.ts +++ b/packages/typegen/src/generate/events.ts @@ -67,7 +67,7 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes, types: Object.keys(imports.localTypes[packagePath]) })), { - file: '@polkadot/api/types', + file: '@polkadot/api-base/types', types: ['ApiTypes', 'AugmentedEvent', 'ModuleEvents'] } ] @@ -77,7 +77,7 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes, // Call `generateForMeta()` with current static metadata /** @internal */ -export function generateDefaultEvents (dest = 'packages/api/src/augment/events.ts', data?: HexString, extraTypes: ExtraTypes = {}, isStrict = false, customLookupDefinitions?: Definitions): void { +export function generateDefaultEvents (dest = 'packages/api-augment/src/events.ts', data?: HexString, extraTypes: ExtraTypes = {}, isStrict = false, customLookupDefinitions?: Definitions): void { const { metadata } = initMeta(data, extraTypes); return generateForMeta(metadata, dest, extraTypes, isStrict, customLookupDefinitions); diff --git a/packages/typegen/src/generate/query.ts b/packages/typegen/src/generate/query.ts index 55e8d55017..9da95e0ad1 100644 --- a/packages/typegen/src/generate/query.ts +++ b/packages/typegen/src/generate/query.ts @@ -124,8 +124,8 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr types: Object.keys(imports.localTypes[packagePath]) })), { - file: '@polkadot/api/types', - types: ['ApiTypes', 'AugmentedQuery', 'QueryableStorageEntry', 'QueryableModuleStorage'] + file: '@polkadot/api-base/types', + types: ['ApiTypes', 'AugmentedQuery', 'QueryableStorageEntry', 'QueryableModuleStorage', 'QueryableModuleStorageAt'] } ] }); @@ -134,7 +134,7 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr // Call `generateForMeta()` with current static metadata /** @internal */ -export function generateDefaultQuery (dest = 'packages/api/src/augment/query.ts', data?: HexString, extraTypes: ExtraTypes = {}, isStrict = false, customLookupDefinitions?: Definitions): void { +export function generateDefaultQuery (dest = 'packages/api-augment/src/query.ts', data?: HexString, extraTypes: ExtraTypes = {}, isStrict = false, customLookupDefinitions?: Definitions): void { const { metadata, registry } = initMeta(data, extraTypes); return generateForMeta(registry, metadata, dest, extraTypes, isStrict, customLookupDefinitions); diff --git a/packages/typegen/src/generate/rpc.ts b/packages/typegen/src/generate/rpc.ts index 03d3a932b0..97f35f1429 100644 --- a/packages/typegen/src/generate/rpc.ts +++ b/packages/typegen/src/generate/rpc.ts @@ -143,7 +143,7 @@ export function generateRpcTypes (registry: TypeRegistry, importDefinitions: Rec }); } -export function generateDefaultRpc (dest = 'packages/api/src/augment/rpc.ts', extraTypes: ExtraTypes = {}): void { +export function generateDefaultRpc (dest = 'packages/api-augment/src/rpc.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 e9a83ec628..f5ed8aa401 100644 --- a/packages/typegen/src/generate/tx.ts +++ b/packages/typegen/src/generate/tx.ts @@ -109,7 +109,7 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr types: Object.keys(imports.localTypes[packagePath]) })), { - file: '@polkadot/api/types', + file: '@polkadot/api-base/types', types: ['ApiTypes', 'AugmentedSubmittable', 'SubmittableExtrinsic', 'SubmittableExtrinsicFunction', 'SubmittableModuleExtrinsics'] } ] @@ -119,7 +119,7 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr // Call `generateForMeta()` with current static metadata /** @internal */ -export function generateDefaultTx (dest = 'packages/api/src/augment/tx.ts', data?: HexString, extraTypes: ExtraTypes = {}, isStrict = false, customLookupDefinitions?: Definitions): void { +export function generateDefaultTx (dest = 'packages/api-augment/src/tx.ts', data?: HexString, extraTypes: ExtraTypes = {}, isStrict = false, customLookupDefinitions?: Definitions): void { const { metadata, registry } = initMeta(data, extraTypes); return generateForMeta(registry, metadata, dest, extraTypes, isStrict, customLookupDefinitions); diff --git a/packages/typegen/src/templates/query.hbs b/packages/typegen/src/templates/query.hbs index 66a3038061..8e6b8ea96d 100644 --- a/packages/typegen/src/templates/query.hbs +++ b/packages/typegen/src/templates/query.hbs @@ -28,4 +28,10 @@ declare module '@polkadot/api/types/storage' { {{/unless}} } // QueryableStorage + export interface QueryableStorageAt extends AugmentedQueries { + {{#unless isStrict}} + [key: string]: QueryableModuleStorageAt; + {{/unless}} + } // QueryableStorageAt + } // declare module diff --git a/rollup.config.mjs b/rollup.config.mjs index daaf388c5f..da868a02df 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -23,7 +23,7 @@ function expand (prefix, all) { } const entries = [ - 'api-derive', + ...expand('api', ['augment', 'base', 'derive']), ...expand('rpc', ['core', 'provider']), ...expand('types', ['codec', 'create', 'helpers', 'known']) ].reduce((all, p) => ({ diff --git a/tsconfig.base.json b/tsconfig.base.json index 465a30f3fe..04de989c98 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -5,6 +5,10 @@ "paths": { "@polkadot/api": ["api/src"], "@polkadot/api/*": ["api/src/*"], + "@polkadot/api-augment": ["api-augment/src"], + "@polkadot/api-augment/*": ["api-augment/src/*"], + "@polkadot/api-base": ["api-base/src"], + "@polkadot/api-base/*": ["api-base/src/*"], "@polkadot/api-contract": ["api-contract/src"], "@polkadot/api-contract/*": ["api-contract/src/*"], "@polkadot/api-derive": ["api-derive/src"], diff --git a/tsconfig.json b/tsconfig.json index c31fd07b87..cd18c4add2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,6 +5,8 @@ "files": [], "references": [ { "path": "./packages/api" }, + { "path": "./packages/api-augment" }, + { "path": "./packages/api-base" }, { "path": "./packages/api-contract" }, { "path": "./packages/api-contract/tsconfig.spec.json" }, { "path": "./packages/api-derive" }, diff --git a/yarn.lock b/yarn.lock index df80ee1429..fa2d2cb78d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1867,6 +1867,29 @@ __metadata: languageName: node linkType: hard +"@polkadot/api-augment@6.12.2-11, @polkadot/api-augment@workspace:packages/api-augment": + version: 0.0.0-use.local + resolution: "@polkadot/api-augment@workspace:packages/api-augment" + dependencies: + "@babel/runtime": ^7.16.5 + "@polkadot/api-base": 6.12.2-11 + "@polkadot/rpc-core": 6.12.2-11 + "@polkadot/types": 6.12.2-11 + "@polkadot/util": ^8.1.2 + languageName: unknown + linkType: soft + +"@polkadot/api-base@6.12.2-11, @polkadot/api-base@workspace:packages/api-base": + version: 0.0.0-use.local + resolution: "@polkadot/api-base@workspace:packages/api-base" + dependencies: + "@babel/runtime": ^7.16.5 + "@polkadot/types": 6.12.2-11 + "@polkadot/util": ^8.1.2 + rxjs: ^7.4.0 + languageName: unknown + linkType: soft + "@polkadot/api-contract@workspace:packages/api-contract": version: 0.0.0-use.local resolution: "@polkadot/api-contract@workspace:packages/api-contract" @@ -1893,6 +1916,8 @@ __metadata: resolution: "@polkadot/api@workspace:packages/api" dependencies: "@babel/runtime": ^7.16.5 + "@polkadot/api-augment": 6.12.2-11 + "@polkadot/api-base": 6.12.2-11 "@polkadot/api-derive": 6.12.2-11 "@polkadot/keyring": ^8.1.2 "@polkadot/rpc-core": 6.12.2-11