@pezkuwi/api 16.5.6 → 16.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/LICENSE +201 -0
- package/build/README.md +100 -0
- package/build/augment.d.ts +1 -0
- package/build/augment.js +1 -0
- package/build/base/Decorate.d.ts +143 -0
- package/build/base/Decorate.js +752 -0
- package/build/base/Events.d.ts +67 -0
- package/build/base/Events.js +78 -0
- package/build/base/Getters.d.ts +163 -0
- package/build/base/Getters.js +207 -0
- package/build/base/Init.d.ts +44 -0
- package/build/base/Init.js +400 -0
- package/build/base/find.d.ts +3 -0
- package/build/base/find.js +7 -0
- package/build/base/index.d.ts +47 -0
- package/build/base/index.js +57 -0
- package/build/base/types.d.ts +15 -0
- package/build/base/types.js +1 -0
- package/build/bundle-pezkuwi-api.js +26247 -0
- package/build/bundle.d.ts +7 -0
- package/build/bundle.js +7 -0
- package/build/cjs/augment.d.ts +1 -0
- package/build/cjs/augment.js +3 -0
- package/build/cjs/base/Decorate.d.ts +143 -0
- package/build/cjs/base/Decorate.js +756 -0
- package/build/cjs/base/Events.d.ts +67 -0
- package/build/cjs/base/Events.js +82 -0
- package/build/cjs/base/Getters.d.ts +163 -0
- package/build/cjs/base/Getters.js +211 -0
- package/build/cjs/base/Init.d.ts +44 -0
- package/build/cjs/base/Init.js +404 -0
- package/build/cjs/base/find.d.ts +3 -0
- package/build/cjs/base/find.js +11 -0
- package/build/cjs/base/index.d.ts +47 -0
- package/build/cjs/base/index.js +61 -0
- package/build/cjs/base/types.d.ts +15 -0
- package/build/cjs/base/types.js +2 -0
- package/build/cjs/bundle.d.ts +7 -0
- package/build/cjs/bundle.js +17 -0
- package/build/cjs/index.d.ts +2 -0
- package/build/cjs/index.js +5 -0
- package/build/cjs/package.json +3 -0
- package/build/cjs/packageDetect.d.ts +1 -0
- package/build/cjs/packageDetect.js +10 -0
- package/build/cjs/packageInfo.d.ts +6 -0
- package/build/cjs/packageInfo.js +4 -0
- package/build/cjs/promise/Api.d.ts +158 -0
- package/build/cjs/promise/Api.js +195 -0
- package/build/cjs/promise/Combinator.d.ts +12 -0
- package/build/cjs/promise/Combinator.js +72 -0
- package/build/cjs/promise/decorateMethod.d.ts +14 -0
- package/build/cjs/promise/decorateMethod.js +75 -0
- package/build/cjs/promise/index.d.ts +2 -0
- package/build/cjs/promise/index.js +7 -0
- package/build/cjs/promise/types.d.ts +5 -0
- package/build/cjs/promise/types.js +2 -0
- package/build/cjs/rx/Api.d.ts +155 -0
- package/build/cjs/rx/Api.js +173 -0
- package/build/cjs/rx/decorateMethod.d.ts +3 -0
- package/build/cjs/rx/decorateMethod.js +6 -0
- package/build/cjs/rx/index.d.ts +2 -0
- package/build/cjs/rx/index.js +7 -0
- package/build/cjs/submittable/Result.d.ts +31 -0
- package/build/cjs/submittable/Result.js +84 -0
- package/build/cjs/submittable/createClass.d.ts +12 -0
- package/build/cjs/submittable/createClass.js +277 -0
- package/build/cjs/submittable/createSubmittable.d.ts +8 -0
- package/build/cjs/submittable/createSubmittable.js +8 -0
- package/build/cjs/submittable/index.d.ts +2 -0
- package/build/cjs/submittable/index.js +7 -0
- package/build/cjs/submittable/types.d.ts +1 -0
- package/build/cjs/submittable/types.js +2 -0
- package/build/cjs/types/calls.d.ts +1 -0
- package/build/cjs/types/calls.js +4 -0
- package/build/cjs/types/consts.d.ts +1 -0
- package/build/cjs/types/consts.js +4 -0
- package/build/cjs/types/errors.d.ts +1 -0
- package/build/cjs/types/errors.js +4 -0
- package/build/cjs/types/events.d.ts +1 -0
- package/build/cjs/types/events.js +4 -0
- package/build/cjs/types/index.d.ts +114 -0
- package/build/cjs/types/index.js +13 -0
- package/build/cjs/types/storage.d.ts +1 -0
- package/build/cjs/types/storage.js +4 -0
- package/build/cjs/types/submittable.d.ts +1 -0
- package/build/cjs/types/submittable.js +4 -0
- package/build/cjs/util/augmentObject.d.ts +9 -0
- package/build/cjs/util/augmentObject.js +84 -0
- package/build/cjs/util/decorate.d.ts +16 -0
- package/build/cjs/util/decorate.js +17 -0
- package/build/cjs/util/filterEvents.d.ts +6 -0
- package/build/cjs/util/filterEvents.js +25 -0
- package/build/cjs/util/index.d.ts +4 -0
- package/build/cjs/util/index.js +11 -0
- package/build/cjs/util/isKeyringPair.d.ts +3 -0
- package/build/cjs/util/isKeyringPair.js +7 -0
- package/build/cjs/util/logging.d.ts +1 -0
- package/build/cjs/util/logging.js +5 -0
- package/build/cjs/util/validate.d.ts +3 -0
- package/build/cjs/util/validate.js +26 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +2 -0
- package/build/package.json +612 -0
- package/build/packageDetect.d.ts +1 -0
- package/build/packageDetect.js +8 -0
- package/build/packageInfo.d.ts +6 -0
- package/build/packageInfo.js +1 -0
- package/build/promise/Api.d.ts +158 -0
- package/build/promise/Api.js +191 -0
- package/build/promise/Combinator.d.ts +12 -0
- package/build/promise/Combinator.js +68 -0
- package/build/promise/decorateMethod.d.ts +14 -0
- package/build/promise/decorateMethod.js +71 -0
- package/build/promise/index.d.ts +2 -0
- package/build/promise/index.js +2 -0
- package/build/promise/types.d.ts +5 -0
- package/build/promise/types.js +1 -0
- package/build/rx/Api.d.ts +155 -0
- package/build/rx/Api.js +169 -0
- package/build/rx/decorateMethod.d.ts +3 -0
- package/build/rx/decorateMethod.js +3 -0
- package/build/rx/index.d.ts +2 -0
- package/build/rx/index.js +2 -0
- package/build/submittable/Result.d.ts +31 -0
- package/build/submittable/Result.js +80 -0
- package/build/submittable/createClass.d.ts +12 -0
- package/build/submittable/createClass.js +274 -0
- package/build/submittable/createSubmittable.d.ts +8 -0
- package/build/submittable/createSubmittable.js +5 -0
- package/build/submittable/index.d.ts +2 -0
- package/build/submittable/index.js +2 -0
- package/build/submittable/types.d.ts +1 -0
- package/build/submittable/types.js +1 -0
- package/build/types/calls.d.ts +1 -0
- package/build/types/calls.js +1 -0
- package/build/types/consts.d.ts +1 -0
- package/build/types/consts.js +1 -0
- package/build/types/errors.d.ts +1 -0
- package/build/types/errors.js +1 -0
- package/build/types/events.d.ts +1 -0
- package/build/types/events.js +1 -0
- package/build/types/index.d.ts +114 -0
- package/build/types/index.js +8 -0
- package/build/types/storage.d.ts +1 -0
- package/build/types/storage.js +1 -0
- package/build/types/submittable.d.ts +1 -0
- package/build/types/submittable.js +1 -0
- package/build/util/augmentObject.d.ts +9 -0
- package/build/util/augmentObject.js +81 -0
- package/build/util/decorate.d.ts +16 -0
- package/build/util/decorate.js +14 -0
- package/build/util/filterEvents.d.ts +6 -0
- package/build/util/filterEvents.js +22 -0
- package/build/util/index.d.ts +4 -0
- package/build/util/index.js +4 -0
- package/build/util/isKeyringPair.d.ts +3 -0
- package/build/util/isKeyringPair.js +4 -0
- package/build/util/logging.d.ts +1 -0
- package/build/util/logging.js +2 -0
- package/build/util/validate.d.ts +3 -0
- package/build/util/validate.js +23 -0
- package/build-deno/README.md +95 -0
- package/build-deno/augment.ts +2 -0
- package/build-deno/base/Decorate.ts +1100 -0
- package/build-deno/base/Events.ts +89 -0
- package/build-deno/base/Getters.ts +243 -0
- package/build-deno/base/Init.ts +523 -0
- package/build-deno/base/find.ts +12 -0
- package/build-deno/base/index.ts +83 -0
- package/build-deno/base/types.ts +17 -0
- package/build-deno/bundle.ts +11 -0
- package/build-deno/checkTypes.manual.ts +320 -0
- package/build-deno/index.ts +4 -0
- package/build-deno/mod.ts +2 -0
- package/build-deno/packageDetect.ts +12 -0
- package/build-deno/packageInfo.ts +3 -0
- package/build-deno/promise/Api.ts +212 -0
- package/build-deno/promise/Combinator.ts +89 -0
- package/build-deno/promise/decorateMethod.ts +111 -0
- package/build-deno/promise/index.ts +3 -0
- package/build-deno/promise/types.ts +7 -0
- package/build-deno/rx/Api.ts +184 -0
- package/build-deno/rx/decorateMethod.ts +7 -0
- package/build-deno/rx/index.ts +3 -0
- package/build-deno/submittable/Result.ts +109 -0
- package/build-deno/submittable/createClass.ts +436 -0
- package/build-deno/submittable/createSubmittable.ts +17 -0
- package/build-deno/submittable/index.ts +3 -0
- package/build-deno/submittable/types.ts +2 -0
- package/build-deno/test/SingleAccountSigner.ts +51 -0
- package/build-deno/test/index.ts +3 -0
- package/build-deno/test/logEvents.ts +21 -0
- package/build-deno/types/calls.ts +2 -0
- package/build-deno/types/consts.ts +2 -0
- package/build-deno/types/errors.ts +2 -0
- package/build-deno/types/events.ts +2 -0
- package/build-deno/types/index.ts +124 -0
- package/build-deno/types/storage.ts +2 -0
- package/build-deno/types/submittable.ts +2 -0
- package/build-deno/util/augmentObject.ts +109 -0
- package/build-deno/util/decorate.ts +38 -0
- package/build-deno/util/filterEvents.ts +32 -0
- package/build-deno/util/index.ts +6 -0
- package/build-deno/util/isKeyringPair.ts +9 -0
- package/build-deno/util/logging.ts +4 -0
- package/build-deno/util/validate.ts +32 -0
- package/build-tsc/augment.d.ts +1 -0
- package/build-tsc/base/Decorate.d.ts +143 -0
- package/build-tsc/base/Events.d.ts +67 -0
- package/build-tsc/base/Getters.d.ts +163 -0
- package/build-tsc/base/Init.d.ts +44 -0
- package/build-tsc/base/find.d.ts +3 -0
- package/build-tsc/base/index.d.ts +47 -0
- package/build-tsc/base/types.d.ts +15 -0
- package/build-tsc/bundle.d.ts +7 -0
- package/build-tsc/index.d.ts +2 -0
- package/build-tsc/packageDetect.d.ts +1 -0
- package/build-tsc/packageInfo.d.ts +6 -0
- package/build-tsc/promise/Api.d.ts +158 -0
- package/build-tsc/promise/Combinator.d.ts +12 -0
- package/build-tsc/promise/decorateMethod.d.ts +14 -0
- package/build-tsc/promise/index.d.ts +2 -0
- package/build-tsc/promise/types.d.ts +5 -0
- package/build-tsc/rx/Api.d.ts +155 -0
- package/build-tsc/rx/decorateMethod.d.ts +3 -0
- package/build-tsc/rx/index.d.ts +2 -0
- package/build-tsc/submittable/Result.d.ts +31 -0
- package/build-tsc/submittable/createClass.d.ts +12 -0
- package/build-tsc/submittable/createSubmittable.d.ts +8 -0
- package/build-tsc/submittable/index.d.ts +2 -0
- package/build-tsc/submittable/types.d.ts +1 -0
- package/build-tsc/types/calls.d.ts +1 -0
- package/build-tsc/types/consts.d.ts +1 -0
- package/build-tsc/types/errors.d.ts +1 -0
- package/build-tsc/types/events.d.ts +1 -0
- package/build-tsc/types/index.d.ts +114 -0
- package/build-tsc/types/storage.d.ts +1 -0
- package/build-tsc/types/submittable.d.ts +1 -0
- package/build-tsc/util/augmentObject.d.ts +9 -0
- package/build-tsc/util/decorate.d.ts +16 -0
- package/build-tsc/util/filterEvents.d.ts +6 -0
- package/build-tsc/util/index.d.ts +4 -0
- package/build-tsc/util/isKeyringPair.d.ts +3 -0
- package/build-tsc/util/logging.d.ts +1 -0
- package/build-tsc/util/validate.d.ts +3 -0
- package/build-tsc-cjs/augment.js +3 -0
- package/build-tsc-cjs/base/Decorate.js +756 -0
- package/build-tsc-cjs/base/Events.js +82 -0
- package/build-tsc-cjs/base/Getters.js +211 -0
- package/build-tsc-cjs/base/Init.js +404 -0
- package/build-tsc-cjs/base/find.js +11 -0
- package/build-tsc-cjs/base/index.js +61 -0
- package/build-tsc-cjs/base/types.js +2 -0
- package/build-tsc-cjs/bundle.js +17 -0
- package/build-tsc-cjs/index.js +5 -0
- package/build-tsc-cjs/packageDetect.js +10 -0
- package/build-tsc-cjs/packageInfo.js +4 -0
- package/build-tsc-cjs/promise/Api.js +195 -0
- package/build-tsc-cjs/promise/Combinator.js +72 -0
- package/build-tsc-cjs/promise/decorateMethod.js +75 -0
- package/build-tsc-cjs/promise/index.js +7 -0
- package/build-tsc-cjs/promise/types.js +2 -0
- package/build-tsc-cjs/rx/Api.js +173 -0
- package/build-tsc-cjs/rx/decorateMethod.js +6 -0
- package/build-tsc-cjs/rx/index.js +7 -0
- package/build-tsc-cjs/submittable/Result.js +84 -0
- package/build-tsc-cjs/submittable/createClass.js +277 -0
- package/build-tsc-cjs/submittable/createSubmittable.js +8 -0
- package/build-tsc-cjs/submittable/index.js +7 -0
- package/build-tsc-cjs/submittable/types.js +2 -0
- package/build-tsc-cjs/types/calls.js +4 -0
- package/build-tsc-cjs/types/consts.js +4 -0
- package/build-tsc-cjs/types/errors.js +4 -0
- package/build-tsc-cjs/types/events.js +4 -0
- package/build-tsc-cjs/types/index.js +13 -0
- package/build-tsc-cjs/types/storage.js +4 -0
- package/build-tsc-cjs/types/submittable.js +4 -0
- package/build-tsc-cjs/util/augmentObject.js +84 -0
- package/build-tsc-cjs/util/decorate.js +17 -0
- package/build-tsc-cjs/util/filterEvents.js +25 -0
- package/build-tsc-cjs/util/index.js +11 -0
- package/build-tsc-cjs/util/isKeyringPair.js +7 -0
- package/build-tsc-cjs/util/logging.js +5 -0
- package/build-tsc-cjs/util/validate.js +26 -0
- package/build-tsc-esm/augment.js +1 -0
- package/build-tsc-esm/base/Decorate.js +752 -0
- package/build-tsc-esm/base/Events.js +78 -0
- package/build-tsc-esm/base/Getters.js +207 -0
- package/build-tsc-esm/base/Init.js +400 -0
- package/build-tsc-esm/base/find.js +7 -0
- package/build-tsc-esm/base/index.js +57 -0
- package/build-tsc-esm/base/types.js +1 -0
- package/build-tsc-esm/bundle.js +7 -0
- package/build-tsc-esm/index.js +2 -0
- package/build-tsc-esm/packageDetect.js +8 -0
- package/build-tsc-esm/packageInfo.js +1 -0
- package/build-tsc-esm/promise/Api.js +191 -0
- package/build-tsc-esm/promise/Combinator.js +68 -0
- package/build-tsc-esm/promise/decorateMethod.js +71 -0
- package/build-tsc-esm/promise/index.js +2 -0
- package/build-tsc-esm/promise/types.js +1 -0
- package/build-tsc-esm/rx/Api.js +169 -0
- package/build-tsc-esm/rx/decorateMethod.js +3 -0
- package/build-tsc-esm/rx/index.js +2 -0
- package/build-tsc-esm/submittable/Result.js +80 -0
- package/build-tsc-esm/submittable/createClass.js +274 -0
- package/build-tsc-esm/submittable/createSubmittable.js +5 -0
- package/build-tsc-esm/submittable/index.js +2 -0
- package/build-tsc-esm/submittable/types.js +1 -0
- package/build-tsc-esm/types/calls.js +1 -0
- package/build-tsc-esm/types/consts.js +1 -0
- package/build-tsc-esm/types/errors.js +1 -0
- package/build-tsc-esm/types/events.js +1 -0
- package/build-tsc-esm/types/index.js +8 -0
- package/build-tsc-esm/types/storage.js +1 -0
- package/build-tsc-esm/types/submittable.js +1 -0
- package/build-tsc-esm/util/augmentObject.js +81 -0
- package/build-tsc-esm/util/decorate.js +14 -0
- package/build-tsc-esm/util/filterEvents.js +22 -0
- package/build-tsc-esm/util/index.js +4 -0
- package/build-tsc-esm/util/isKeyringPair.js +4 -0
- package/build-tsc-esm/util/logging.js +2 -0
- package/build-tsc-esm/util/validate.js +23 -0
- package/bundle-pezkuwi-api.js +26240 -26231
- package/cjs/packageInfo.js +1 -1
- package/package.json +12 -12
- package/packageInfo.js +1 -1
- package/src/augment.ts +4 -0
- package/src/base/Decorate.ts +1103 -0
- package/src/base/Events.ts +91 -0
- package/src/base/Getters.ts +245 -0
- package/src/base/Init.ts +525 -0
- package/src/base/find.ts +14 -0
- package/src/base/index.ts +85 -0
- package/src/base/types.ts +19 -0
- package/src/bundle.ts +16 -0
- package/src/checkTypes.manual.ts +323 -0
- package/src/index.ts +6 -0
- package/src/mod.ts +4 -0
- package/src/packageDetect.ts +16 -0
- package/src/packageInfo.ts +6 -0
- package/src/promise/Api.ts +214 -0
- package/src/promise/Combinator.ts +91 -0
- package/src/promise/Combinators.spec.ts +109 -0
- package/src/promise/decorateMethod.ts +118 -0
- package/src/promise/index.spec.ts +167 -0
- package/src/promise/index.ts +5 -0
- package/src/promise/types.ts +9 -0
- package/src/rx/Api.ts +186 -0
- package/src/rx/decorateMethod.ts +9 -0
- package/src/rx/index.ts +5 -0
- package/src/submittable/Result.ts +111 -0
- package/src/submittable/createClass.ts +438 -0
- package/src/submittable/createSubmittable.ts +19 -0
- package/src/submittable/index.ts +5 -0
- package/src/submittable/types.ts +4 -0
- package/src/test/SingleAccountSigner.ts +53 -0
- package/src/test/index.ts +5 -0
- package/src/test/logEvents.ts +24 -0
- package/src/types/calls.ts +4 -0
- package/src/types/consts.ts +4 -0
- package/src/types/errors.ts +4 -0
- package/src/types/events.ts +4 -0
- package/src/types/index.ts +137 -0
- package/src/types/storage.ts +4 -0
- package/src/types/submittable.ts +4 -0
- package/src/util/augmentObject.spec.ts +54 -0
- package/src/util/augmentObject.ts +112 -0
- package/src/util/decorate.ts +43 -0
- package/src/util/filterEvents.ts +34 -0
- package/src/util/index.ts +10 -0
- package/src/util/isKeyringPair.ts +11 -0
- package/src/util/logging.ts +6 -0
- package/src/util/validate.spec.ts +72 -0
- package/src/util/validate.ts +36 -0
- package/tsconfig.build.json +25 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.spec.json +26 -0
- package/tsconfig.spec.tsbuildinfo +1 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
// Copyright 2017-2025 @pezkuwi/api authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { ApiTypes, DeriveCustom, QueryableStorageMulti } from '@pezkuwi/api-base/types';
|
|
5
|
+
import type { ApiInterfaceRx as ApiInterfaceBase } from '@pezkuwi/api-base/types/api';
|
|
6
|
+
import type { QueryableCalls } from '@pezkuwi/api-base/types/calls';
|
|
7
|
+
import type { QueryableConsts } from '@pezkuwi/api-base/types/consts';
|
|
8
|
+
import type { DecoratedErrors } from '@pezkuwi/api-base/types/errors';
|
|
9
|
+
import type { DecoratedEvents } from '@pezkuwi/api-base/types/events';
|
|
10
|
+
import type { QueryableStorage } from '@pezkuwi/api-base/types/storage';
|
|
11
|
+
import type { ProviderInterface, ProviderInterfaceEmitted } from '@pezkuwi/rpc-provider/types';
|
|
12
|
+
import type { ExtDef } from '@pezkuwi/types/extrinsic/signedExtensions/types';
|
|
13
|
+
import type { Call, Extrinsic, Hash, RuntimeVersionPartial } from '@pezkuwi/types/interfaces';
|
|
14
|
+
import type { CallFunction, DefinitionRpc, DefinitionRpcSub, DefinitionsCall, RegisteredTypes, Registry, RegistryError, SignatureOptions, Signer } from '@pezkuwi/types/types';
|
|
15
|
+
import type { BN } from '@pezkuwi/util';
|
|
16
|
+
import type { HexString } from '@pezkuwi/util/types';
|
|
17
|
+
import type { ApiBase } from '../base/index.js';
|
|
18
|
+
import type { SubmittableExtrinsic } from '../types/submittable.js';
|
|
19
|
+
import type { AllDerives } from '../util/decorate.js';
|
|
20
|
+
|
|
21
|
+
// types
|
|
22
|
+
export type { Signer, SignerResult } from '@pezkuwi/types/types';
|
|
23
|
+
|
|
24
|
+
// all named
|
|
25
|
+
export { ApiBase } from '../base/index.js';
|
|
26
|
+
|
|
27
|
+
// all starred
|
|
28
|
+
// eslint-disable-next-line import/export
|
|
29
|
+
export * from '@pezkuwi/api/types/calls';
|
|
30
|
+
// eslint-disable-next-line import/export
|
|
31
|
+
export * from '@pezkuwi/api/types/consts';
|
|
32
|
+
// eslint-disable-next-line import/export
|
|
33
|
+
export * from '@pezkuwi/api/types/errors';
|
|
34
|
+
// eslint-disable-next-line import/export
|
|
35
|
+
export * from '@pezkuwi/api/types/events';
|
|
36
|
+
// eslint-disable-next-line import/export
|
|
37
|
+
export * from '@pezkuwi/api/types/storage';
|
|
38
|
+
// eslint-disable-next-line import/export
|
|
39
|
+
export * from '@pezkuwi/api/types/submittable';
|
|
40
|
+
// eslint-disable-next-line import/export
|
|
41
|
+
export * from '@pezkuwi/api-base/types';
|
|
42
|
+
|
|
43
|
+
// A smaller interface of ApiRx, used in derive and in SubmittableExtrinsic
|
|
44
|
+
export interface ApiInterfaceRx extends ApiInterfaceBase {
|
|
45
|
+
derive: AllDerives<'rxjs'>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface ApiOptions extends RegisteredTypes {
|
|
49
|
+
/**
|
|
50
|
+
* @description Add custom derives to be injected
|
|
51
|
+
*/
|
|
52
|
+
derives?: DeriveCustom;
|
|
53
|
+
/**
|
|
54
|
+
* @description Control the initialization of the wasm libraries. When not specified, it defaults to `true`, initializing the wasm libraries, set to `false` to not initialize wasm. (No sr25519 support)
|
|
55
|
+
*/
|
|
56
|
+
initWasm?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* @description Controls the checking of storage values once they have been contructed. When not specified this defaults to `true`. Set to `false` to forgo any checking on storage results.
|
|
59
|
+
*/
|
|
60
|
+
isPedantic?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* @description pre-bundles is a map of 'genesis hash and runtime spec version' as key to a metadata hex string
|
|
63
|
+
* if genesis hash and runtime spec version matches, then use metadata, else fetch it from chain
|
|
64
|
+
*/
|
|
65
|
+
metadata?: Record<string, HexString>;
|
|
66
|
+
/**
|
|
67
|
+
* @description Don't display any warnings on initialization (missing RPC methods & runtime calls)
|
|
68
|
+
*/
|
|
69
|
+
noInitWarn?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* @description Transport Provider from rpc-provider. If not specified, it will default to
|
|
72
|
+
* connecting to a WsProvider connecting localhost with the default port, i.e. `ws://127.0.0.1:9944`
|
|
73
|
+
*/
|
|
74
|
+
provider?: ProviderInterface;
|
|
75
|
+
/**
|
|
76
|
+
* @description A type registry to use along with this instance
|
|
77
|
+
*/
|
|
78
|
+
registry?: Registry;
|
|
79
|
+
/**
|
|
80
|
+
* @description User-defined RPC methods
|
|
81
|
+
*/
|
|
82
|
+
rpc?: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>;
|
|
83
|
+
/**
|
|
84
|
+
* @description Defines the size of the cache for the rpc-core. Defaults to 1024 * 10 * 10.
|
|
85
|
+
*/
|
|
86
|
+
rpcCacheCapacity?: number;
|
|
87
|
+
/**
|
|
88
|
+
* @description Overrides for state_call usage (this will be removed in some future version)
|
|
89
|
+
*/
|
|
90
|
+
runtime?: DefinitionsCall;
|
|
91
|
+
/**
|
|
92
|
+
* @description Any chain-specific signed extensions that are now well-known
|
|
93
|
+
*/
|
|
94
|
+
signedExtensions?: ExtDef;
|
|
95
|
+
/**
|
|
96
|
+
* @description An external signer which will be used to sign extrinsic when account passed in is not KeyringPair
|
|
97
|
+
*/
|
|
98
|
+
signer?: Signer;
|
|
99
|
+
/**
|
|
100
|
+
* @description The source object to use for runtime information (only used when cloning)
|
|
101
|
+
*/
|
|
102
|
+
source?: ApiBase<any>;
|
|
103
|
+
/**
|
|
104
|
+
* @description Throws an error when the initial connection fails (same as isReadyOrError)
|
|
105
|
+
*/
|
|
106
|
+
throwOnConnect?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* @description Throws an error when some types are unknown (useful with throwOnConnect)
|
|
109
|
+
*/
|
|
110
|
+
throwOnUnknown?: boolean;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export type ApiInterfaceEvents = ProviderInterfaceEmitted | 'ready' | 'decorated';
|
|
114
|
+
|
|
115
|
+
export interface SignerOptions extends SignatureOptions {
|
|
116
|
+
blockNumber: BN;
|
|
117
|
+
genesisHash: Hash;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export interface ApiDecoration<ApiType extends ApiTypes> {
|
|
121
|
+
call: QueryableCalls<ApiType>;
|
|
122
|
+
consts: QueryableConsts<ApiType>;
|
|
123
|
+
errors: DecoratedErrors<ApiType>;
|
|
124
|
+
events: DecoratedEvents<ApiType>;
|
|
125
|
+
query: QueryableStorage<ApiType>;
|
|
126
|
+
registry: Registry;
|
|
127
|
+
runtimeVersion: RuntimeVersionPartial;
|
|
128
|
+
rx: {
|
|
129
|
+
call: QueryableCalls<'rxjs'>;
|
|
130
|
+
query: QueryableStorage<'rxjs'>;
|
|
131
|
+
};
|
|
132
|
+
tx: (extrinsic: Call | Extrinsic | Uint8Array | string) => SubmittableExtrinsic<ApiType>;
|
|
133
|
+
|
|
134
|
+
findCall (callIndex: Uint8Array | string): CallFunction;
|
|
135
|
+
findError (errorIndex: Uint8Array | string): RegistryError;
|
|
136
|
+
queryMulti: QueryableStorageMulti<ApiType>;
|
|
137
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Copyright 2017-2025 @pezkuwi/api authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/// <reference types="@pezkuwi/dev-test/globals.d.ts" />
|
|
5
|
+
|
|
6
|
+
import { augmentObject } from './augmentObject.js';
|
|
7
|
+
|
|
8
|
+
describe('augmentObject', (): void => {
|
|
9
|
+
let spy: ReturnType<typeof jest.spyOn>;
|
|
10
|
+
|
|
11
|
+
beforeEach((): void => {
|
|
12
|
+
spy = jest.spyOn(console, 'warn');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
afterEach((): void => {
|
|
16
|
+
spy.mockRestore();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('logs added/removed sections and methods', (): void => {
|
|
20
|
+
augmentObject(
|
|
21
|
+
'test',
|
|
22
|
+
{ bar: { b: 1 }, foo: { d: 1, f: 1 }, new: { z: 1 } },
|
|
23
|
+
{ bar: { a: 1, c: 1 }, baz: { a: 1 }, foo: { c: 1, f: 1 } }
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
expect(spy).toHaveBeenCalledWith(
|
|
27
|
+
expect.anything(),
|
|
28
|
+
expect.stringMatching(/API\/AUGMENT/),
|
|
29
|
+
'api.test: Found 1 added and 1 removed modules:\n\t added: new\n\tremoved: baz'
|
|
30
|
+
);
|
|
31
|
+
expect(spy).toHaveBeenCalledWith(
|
|
32
|
+
expect.anything(),
|
|
33
|
+
expect.stringMatching(/API\/AUGMENT/),
|
|
34
|
+
'api.test: Found 2 added and 3 removed calls:\n\t added: bar.b, foo.d\n\tremoved: bar.a, bar.c, foo.c'
|
|
35
|
+
);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('copies sections to the dest', (): void => {
|
|
39
|
+
const src = { bar: { b: 1 }, foo: { a: 1 } };
|
|
40
|
+
|
|
41
|
+
expect(augmentObject('test', src, {})).toEqual(src);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('adds fields to existing sections', (): void => {
|
|
45
|
+
const src = { bar: { b: 1 }, foo: { a: 1 } };
|
|
46
|
+
const dst = { baz: { c: 1 }, foo: { b: 2 } };
|
|
47
|
+
|
|
48
|
+
expect(augmentObject('test', src, dst)).toEqual({
|
|
49
|
+
bar: { b: 1 },
|
|
50
|
+
baz: { c: 1 },
|
|
51
|
+
foo: { a: 1, b: 2 }
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// Copyright 2017-2025 @pezkuwi/api authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { lazyMethods, logger, objectClear } from '@pezkuwi/util';
|
|
5
|
+
|
|
6
|
+
type Sections <T> = Record<string, Methods<T>>;
|
|
7
|
+
|
|
8
|
+
type Methods <T> = Record<string, T>;
|
|
9
|
+
|
|
10
|
+
type StringsStrings = [string[], string[]];
|
|
11
|
+
|
|
12
|
+
const l = logger('api/augment');
|
|
13
|
+
|
|
14
|
+
function logLength (type: 'added' | 'removed', values: string[], and: string[] = []): string {
|
|
15
|
+
return values.length
|
|
16
|
+
? ` ${values.length} ${type}${and.length ? ' and' : ''}`
|
|
17
|
+
: '';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function logValues (type: 'added' | 'removed', values: string[]): string {
|
|
21
|
+
return values.length
|
|
22
|
+
? `\n\t${type.padStart(7)}: ${values.sort().join(', ')}`
|
|
23
|
+
: '';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// log details to console
|
|
27
|
+
function warn (prefix: string, type: 'calls' | 'modules', [added, removed]: StringsStrings): void {
|
|
28
|
+
if (added.length || removed.length) {
|
|
29
|
+
l.warn(`api.${prefix}: Found${logLength('added', added, removed)}${logLength('removed', removed)} ${type}:${logValues('added', added)}${logValues('removed', removed)}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function findSectionExcludes (a: string[], b: string[]): string[] {
|
|
34
|
+
return a.filter((s) => !b.includes(s));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function findSectionIncludes (a: string[], b: string[]): string[] {
|
|
38
|
+
return a.filter((s) => b.includes(s));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function extractSections <T> (src: Sections<T>, dst: Sections<T>): StringsStrings {
|
|
42
|
+
const srcSections = Object.keys(src);
|
|
43
|
+
const dstSections = Object.keys(dst);
|
|
44
|
+
|
|
45
|
+
return [
|
|
46
|
+
findSectionExcludes(srcSections, dstSections),
|
|
47
|
+
findSectionExcludes(dstSections, srcSections)
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function findMethodExcludes <T> (src: Sections<T>, dst: Sections<T>): string[] {
|
|
52
|
+
const srcSections = Object.keys(src);
|
|
53
|
+
const dstSections = findSectionIncludes(Object.keys(dst), srcSections);
|
|
54
|
+
const excludes: string[] = [];
|
|
55
|
+
|
|
56
|
+
for (let s = 0, scount = dstSections.length; s < scount; s++) {
|
|
57
|
+
const section = dstSections[s];
|
|
58
|
+
const srcMethods = Object.keys(src[section]);
|
|
59
|
+
const dstMethods = Object.keys(dst[section]);
|
|
60
|
+
|
|
61
|
+
for (let d = 0, mcount = dstMethods.length; d < mcount; d++) {
|
|
62
|
+
const method = dstMethods[d];
|
|
63
|
+
|
|
64
|
+
if (!srcMethods.includes(method)) {
|
|
65
|
+
excludes.push(`${section}.${method}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return excludes;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function extractMethods <T> (src: Sections<T>, dst: Sections<T>): StringsStrings {
|
|
74
|
+
return [
|
|
75
|
+
findMethodExcludes(dst, src),
|
|
76
|
+
findMethodExcludes(src, dst)
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @description Takes a decorated api section (e.g. api.tx) and augment it with the details. It does not override what is
|
|
82
|
+
* already available, but rather just adds new missing items into the result object.
|
|
83
|
+
* @internal
|
|
84
|
+
*/
|
|
85
|
+
export function augmentObject <T> (prefix: string | null, src: Sections<T>, dst: Sections<T>, fromEmpty = false): Sections<T> {
|
|
86
|
+
fromEmpty && objectClear(dst);
|
|
87
|
+
|
|
88
|
+
// NOTE: This part is slightly problematic since it will get the
|
|
89
|
+
// values for at least all the sections and the names of the methods
|
|
90
|
+
// (Since methods won't be decorated before lazy, this _may_ be ok)
|
|
91
|
+
if (prefix && Object.keys(dst).length) {
|
|
92
|
+
warn(prefix, 'modules', extractSections(src, dst));
|
|
93
|
+
warn(prefix, 'calls', extractMethods(src, dst));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const sections = Object.keys(src);
|
|
97
|
+
|
|
98
|
+
for (let i = 0, count = sections.length; i < count; i++) {
|
|
99
|
+
const section = sections[i];
|
|
100
|
+
const methods = src[section];
|
|
101
|
+
|
|
102
|
+
// We don't set here with a lazy interface, we decorate based
|
|
103
|
+
// on the top-level structure (this bypasses adding lazy onto lazy)
|
|
104
|
+
if (!dst[section]) {
|
|
105
|
+
dst[section] = {};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
lazyMethods(dst[section], Object.keys(methods), (m: string) => methods[m]);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return dst;
|
|
112
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Copyright 2017-2025 @pezkuwi/api authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { ExactDerive } from '@pezkuwi/api-derive';
|
|
5
|
+
import type { AnyFunction } from '@pezkuwi/types/types';
|
|
6
|
+
import type { ApiTypes, DecorateMethod, MethodResult } from '../types/index.js';
|
|
7
|
+
|
|
8
|
+
import { lazyDeriveSection } from '@pezkuwi/api-derive';
|
|
9
|
+
|
|
10
|
+
type AnyDeriveSection = Record<string, AnyFunction>;
|
|
11
|
+
|
|
12
|
+
// Most generic typings for `api.derive.*.*`
|
|
13
|
+
type AnyDerive = Record<string, AnyDeriveSection>;
|
|
14
|
+
|
|
15
|
+
// Exact typings for a particular section `api.derive.section.*`
|
|
16
|
+
type DeriveSection<ApiType extends ApiTypes, Section extends AnyDeriveSection> = {
|
|
17
|
+
[M in keyof Section]: MethodResult<ApiType, Section[M]>
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// Exact typings for all sections `api.derive.*.*`
|
|
21
|
+
export type AllDerives<ApiType extends ApiTypes> = {
|
|
22
|
+
[S in keyof ExactDerive]: DeriveSection<ApiType, ExactDerive[S]>
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* This is a section decorator which keeps all type information.
|
|
27
|
+
*/
|
|
28
|
+
export function decorateDeriveSections<ApiType extends ApiTypes> (decorateMethod: DecorateMethod<ApiType>, derives: AnyDerive): AllDerives<ApiType> {
|
|
29
|
+
const getKeys = (s: string) =>
|
|
30
|
+
Object.keys(derives[s]);
|
|
31
|
+
|
|
32
|
+
const creator = (s: string, m: string) =>
|
|
33
|
+
decorateMethod(derives[s][m]) as AnyFunction;
|
|
34
|
+
|
|
35
|
+
const result: AnyDerive = {};
|
|
36
|
+
const names = Object.keys(derives);
|
|
37
|
+
|
|
38
|
+
for (let i = 0, count = names.length; i < count; i++) {
|
|
39
|
+
lazyDeriveSection(result, names[i], getKeys, creator);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return result as AllDerives<ApiType>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Copyright 2017-2025 @pezkuwi/api authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { BlockNumber, EventRecord, ExtrinsicStatus, H256, SignedBlock } from '@pezkuwi/types/interfaces';
|
|
5
|
+
|
|
6
|
+
import { isCompact } from '@pezkuwi/util';
|
|
7
|
+
|
|
8
|
+
import { l } from './logging.js';
|
|
9
|
+
|
|
10
|
+
export function filterEvents (txHash: H256, { block: { extrinsics, header } }: SignedBlock, allEvents: EventRecord[], status: ExtrinsicStatus): { events?: EventRecord[], txIndex?: number, blockNumber?: BlockNumber } {
|
|
11
|
+
// extrinsics to hashes
|
|
12
|
+
for (const [txIndex, x] of extrinsics.entries()) {
|
|
13
|
+
if (x.hash.eq(txHash)) {
|
|
14
|
+
return {
|
|
15
|
+
blockNumber: isCompact<BlockNumber>(header.number) ? header.number.unwrap() : header.number,
|
|
16
|
+
events: allEvents.filter(({ phase }) =>
|
|
17
|
+
phase.isApplyExtrinsic &&
|
|
18
|
+
phase.asApplyExtrinsic.eqn(txIndex)
|
|
19
|
+
),
|
|
20
|
+
txIndex
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// if we do get the block after finalized, it _should_ be there
|
|
26
|
+
// only warn on filtering with isInBlock (finalization finalizes after)
|
|
27
|
+
if (status.isInBlock) {
|
|
28
|
+
const allHashes = extrinsics.map((x) => x.hash.toHex());
|
|
29
|
+
|
|
30
|
+
l.warn(`block ${header.hash.toHex()}: Unable to find extrinsic ${txHash.toHex()} inside ${allHashes.join(', ')}`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Copyright 2017-2025 @pezkuwi/api authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
// all named
|
|
5
|
+
export { filterEvents } from './filterEvents.js';
|
|
6
|
+
export { isKeyringPair } from './isKeyringPair.js';
|
|
7
|
+
export { l } from './logging.js';
|
|
8
|
+
|
|
9
|
+
// all starred
|
|
10
|
+
export * from './decorate.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright 2017-2025 @pezkuwi/api authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { AccountId, Address } from '@pezkuwi/types/interfaces';
|
|
5
|
+
import type { IKeyringPair } from '@pezkuwi/types/types';
|
|
6
|
+
|
|
7
|
+
import { isFunction } from '@pezkuwi/util';
|
|
8
|
+
|
|
9
|
+
export function isKeyringPair (account: string | IKeyringPair | AccountId | Address): account is IKeyringPair {
|
|
10
|
+
return isFunction((account as IKeyringPair).sign);
|
|
11
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Copyright 2017-2025 @pezkuwi/api authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/// <reference types="@pezkuwi/dev-test/globals.d.ts" />
|
|
5
|
+
|
|
6
|
+
import { decorateStorage, Metadata, TypeRegistry } from '@pezkuwi/types';
|
|
7
|
+
import metaStatic from '@pezkuwi/types-support/metadata/static-bizinikiwi';
|
|
8
|
+
|
|
9
|
+
import { extractStorageArgs } from './validate.js';
|
|
10
|
+
|
|
11
|
+
describe('extractStorageArgs', (): void => {
|
|
12
|
+
const registry = new TypeRegistry();
|
|
13
|
+
const metadata = new Metadata(registry, metaStatic);
|
|
14
|
+
|
|
15
|
+
registry.setMetadata(metadata);
|
|
16
|
+
|
|
17
|
+
const storage = decorateStorage(registry, metadata.asLatest, metadata.version);
|
|
18
|
+
|
|
19
|
+
it('validates no-arg plain', (): void => {
|
|
20
|
+
expect(
|
|
21
|
+
extractStorageArgs(registry, storage['timestamp']['now'], [])
|
|
22
|
+
).toEqual([storage['timestamp']['now'], []]);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('validates no-arg plain (with undefined, undefined)', (): void => {
|
|
26
|
+
expect(
|
|
27
|
+
extractStorageArgs(registry, storage['timestamp']['now'], [undefined, undefined])
|
|
28
|
+
).toEqual([storage['timestamp']['now'], []]);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('validates no-arg plain (failing when there are args)', (): void => {
|
|
32
|
+
expect(
|
|
33
|
+
() => extractStorageArgs(registry, storage['timestamp']['now'], [123, 456])
|
|
34
|
+
).toThrow('timestamp.now() does not take any arguments, 2 found');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('validates map, 1 arg', (): void => {
|
|
38
|
+
expect(
|
|
39
|
+
extractStorageArgs(registry, storage['staking']['payee'], ['abc'])
|
|
40
|
+
).toEqual([storage['staking']['payee'], ['abc']]);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('validates map, 1 arg (failing with no args)', (): void => {
|
|
44
|
+
expect(
|
|
45
|
+
() => extractStorageArgs(registry, storage['staking']['payee'], [])
|
|
46
|
+
).toThrow('staking.payee(AccountId32) is a map, requiring 1 arguments, 0 found');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('validates map, 1 arg (failing with more args)', (): void => {
|
|
50
|
+
expect(
|
|
51
|
+
() => extractStorageArgs(registry, storage['staking']['payee'], ['abc', 'def'])
|
|
52
|
+
).toThrow('staking.payee(AccountId32) is a map, requiring 1 arguments, 2 found');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('validates doublemap, 2 args', (): void => {
|
|
56
|
+
expect(
|
|
57
|
+
extractStorageArgs(registry, storage['staking']['erasStakers'], [1, '0x1234'])
|
|
58
|
+
).toEqual([storage['staking']['erasStakers'], [1, '0x1234']]);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('validates doublemap, 2 args (failing with no args)', (): void => {
|
|
62
|
+
expect(
|
|
63
|
+
() => extractStorageArgs(registry, storage['staking']['erasStakers'], [])
|
|
64
|
+
).toThrow('staking.erasStakers(u32, AccountId32) is a map, requiring 2 arguments, 0 found');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('validates doublemap, 2 args (failing with 1 arg)', (): void => {
|
|
68
|
+
expect(
|
|
69
|
+
() => extractStorageArgs(registry, storage['staking']['erasStakers'], [123])
|
|
70
|
+
).toThrow('staking.erasStakers(u32, AccountId32) is a map, requiring 2 arguments, 1 found');
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Copyright 2017-2025 @pezkuwi/api authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { SiLookupTypeId } from '@pezkuwi/types/interfaces';
|
|
5
|
+
import type { StorageEntry } from '@pezkuwi/types/primitive/types';
|
|
6
|
+
import type { Registry } from '@pezkuwi/types/types';
|
|
7
|
+
|
|
8
|
+
import { isUndefined } from '@pezkuwi/util';
|
|
9
|
+
|
|
10
|
+
function sig ({ lookup }: Registry, { method, section }: StorageEntry, args: SiLookupTypeId[]): string {
|
|
11
|
+
return `${section}.${method}(${args.map((a) => lookup.getTypeDef(a).type).join(', ')})`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// sets up the arguments in the form of [creator, args] ready to be used in a storage
|
|
15
|
+
// call. Additionally, it verifies that the correct number of arguments have been passed
|
|
16
|
+
export function extractStorageArgs (registry: Registry, creator: StorageEntry, _args: unknown[]): [StorageEntry, unknown[]] {
|
|
17
|
+
const args = _args.filter((a) => !isUndefined(a));
|
|
18
|
+
|
|
19
|
+
if (creator.meta.type.isPlain) {
|
|
20
|
+
if (args.length !== 0) {
|
|
21
|
+
throw new Error(`${sig(registry, creator, [])} does not take any arguments, ${args.length} found`);
|
|
22
|
+
}
|
|
23
|
+
} else {
|
|
24
|
+
const { hashers, key } = creator.meta.type.asMap;
|
|
25
|
+
const keys = hashers.length === 1
|
|
26
|
+
? [key]
|
|
27
|
+
: registry.lookup.getSiType(key).def.asTuple.map((t) => t);
|
|
28
|
+
|
|
29
|
+
if (args.length !== keys.length) {
|
|
30
|
+
throw new Error(`${sig(registry, creator, keys)} is a map, requiring ${keys.length} arguments, ${args.length} found`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// pass as tuple
|
|
35
|
+
return [creator, args];
|
|
36
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"baseUrl": "..",
|
|
5
|
+
"outDir": "./build",
|
|
6
|
+
"rootDir": "./src"
|
|
7
|
+
},
|
|
8
|
+
"exclude": [
|
|
9
|
+
"**/checkTypes.manual.ts",
|
|
10
|
+
"**/mod.ts",
|
|
11
|
+
"**/*.spec.ts",
|
|
12
|
+
"**/test/**/*"
|
|
13
|
+
],
|
|
14
|
+
"references": [
|
|
15
|
+
{ "path": "../api-augment/tsconfig.build.json" },
|
|
16
|
+
{ "path": "../api-base/tsconfig.build.json" },
|
|
17
|
+
{ "path": "../api-derive/tsconfig.build.json" },
|
|
18
|
+
{ "path": "../rpc-augment/tsconfig.build.json" },
|
|
19
|
+
{ "path": "../rpc-core/tsconfig.build.json" },
|
|
20
|
+
{ "path": "../rpc-provider/tsconfig.build.json" },
|
|
21
|
+
{ "path": "../types/tsconfig.build.json" },
|
|
22
|
+
{ "path": "../types-codec/tsconfig.build.json" },
|
|
23
|
+
{ "path": "../types-known/tsconfig.build.json" }
|
|
24
|
+
]
|
|
25
|
+
}
|