@pezkuwi/api 16.5.5 → 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/LICENSE +201 -0
- package/README.md +12 -12
- package/augment.d.ts +1 -0
- package/augment.js +1 -0
- package/base/Decorate.d.ts +143 -0
- package/base/Decorate.js +752 -0
- package/base/Events.d.ts +67 -0
- package/base/Events.js +78 -0
- package/base/Getters.d.ts +163 -0
- package/base/Getters.js +207 -0
- package/base/Init.d.ts +44 -0
- package/base/Init.js +400 -0
- package/base/find.d.ts +3 -0
- package/base/find.js +7 -0
- package/base/index.d.ts +47 -0
- package/base/index.js +57 -0
- package/base/types.d.ts +15 -0
- package/base/types.js +1 -0
- package/build/LICENSE +201 -0
- package/build/README.md +100 -0
- package/build/augment.js +1 -0
- package/build/base/Decorate.js +752 -0
- package/build/base/Events.js +78 -0
- package/build/base/Getters.js +207 -0
- package/build/base/Init.js +400 -0
- package/build/base/find.js +7 -0
- package/build/base/index.d.ts +1 -1
- package/build/base/index.js +57 -0
- package/build/base/types.js +1 -0
- package/build/bundle-pezkuwi-api.js +26247 -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.js +2 -0
- package/build/package.json +612 -0
- package/build/packageDetect.js +8 -0
- package/build/packageInfo.js +1 -0
- package/build/promise/Api.d.ts +2 -2
- package/build/promise/Api.js +191 -0
- package/build/promise/Combinator.js +68 -0
- package/build/promise/decorateMethod.js +71 -0
- package/build/promise/index.js +2 -0
- package/build/promise/types.js +1 -0
- package/build/rx/Api.d.ts +2 -2
- package/build/rx/Api.js +169 -0
- package/build/rx/decorateMethod.js +3 -0
- package/build/rx/index.js +2 -0
- package/build/submittable/Result.js +80 -0
- package/build/submittable/createClass.js +274 -0
- package/build/submittable/createSubmittable.js +5 -0
- package/build/submittable/index.js +2 -0
- package/build/submittable/types.js +1 -0
- package/build/types/calls.js +1 -0
- package/build/types/consts.js +1 -0
- package/build/types/errors.js +1 -0
- package/build/types/events.js +1 -0
- package/build/types/index.js +8 -0
- package/build/types/storage.js +1 -0
- package/build/types/submittable.js +1 -0
- package/build/util/augmentObject.js +81 -0
- package/build/util/decorate.js +14 -0
- package/build/util/filterEvents.js +22 -0
- package/build/util/index.js +4 -0
- package/build/util/isKeyringPair.js +4 -0
- package/build/util/logging.js +2 -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 +26247 -0
- package/bundle.d.ts +7 -0
- package/bundle.js +7 -0
- package/cjs/augment.d.ts +1 -0
- package/cjs/augment.js +3 -0
- package/cjs/base/Decorate.d.ts +143 -0
- package/cjs/base/Decorate.js +756 -0
- package/cjs/base/Events.d.ts +67 -0
- package/cjs/base/Events.js +82 -0
- package/cjs/base/Getters.d.ts +163 -0
- package/cjs/base/Getters.js +211 -0
- package/cjs/base/Init.d.ts +44 -0
- package/cjs/base/Init.js +404 -0
- package/cjs/base/find.d.ts +3 -0
- package/cjs/base/find.js +11 -0
- package/cjs/base/index.d.ts +47 -0
- package/cjs/base/index.js +61 -0
- package/cjs/base/types.d.ts +15 -0
- package/cjs/base/types.js +2 -0
- package/cjs/bundle.d.ts +7 -0
- package/cjs/bundle.js +17 -0
- package/cjs/index.d.ts +2 -0
- package/cjs/index.js +5 -0
- package/cjs/package.json +3 -0
- package/cjs/packageDetect.d.ts +1 -0
- package/cjs/packageDetect.js +10 -0
- package/cjs/packageInfo.d.ts +6 -0
- package/cjs/packageInfo.js +4 -0
- package/cjs/promise/Api.d.ts +158 -0
- package/cjs/promise/Api.js +195 -0
- package/cjs/promise/Combinator.d.ts +12 -0
- package/cjs/promise/Combinator.js +72 -0
- package/cjs/promise/decorateMethod.d.ts +14 -0
- package/cjs/promise/decorateMethod.js +75 -0
- package/cjs/promise/index.d.ts +2 -0
- package/cjs/promise/index.js +7 -0
- package/cjs/promise/types.d.ts +5 -0
- package/cjs/promise/types.js +2 -0
- package/cjs/rx/Api.d.ts +155 -0
- package/cjs/rx/Api.js +173 -0
- package/cjs/rx/decorateMethod.d.ts +3 -0
- package/cjs/rx/decorateMethod.js +6 -0
- package/cjs/rx/index.d.ts +2 -0
- package/cjs/rx/index.js +7 -0
- package/cjs/submittable/Result.d.ts +31 -0
- package/cjs/submittable/Result.js +84 -0
- package/cjs/submittable/createClass.d.ts +12 -0
- package/cjs/submittable/createClass.js +277 -0
- package/cjs/submittable/createSubmittable.d.ts +8 -0
- package/cjs/submittable/createSubmittable.js +8 -0
- package/cjs/submittable/index.d.ts +2 -0
- package/cjs/submittable/index.js +7 -0
- package/cjs/submittable/types.d.ts +1 -0
- package/cjs/submittable/types.js +2 -0
- package/cjs/types/calls.d.ts +1 -0
- package/cjs/types/calls.js +4 -0
- package/cjs/types/consts.d.ts +1 -0
- package/cjs/types/consts.js +4 -0
- package/cjs/types/errors.d.ts +1 -0
- package/cjs/types/errors.js +4 -0
- package/cjs/types/events.d.ts +1 -0
- package/cjs/types/events.js +4 -0
- package/cjs/types/index.d.ts +114 -0
- package/cjs/types/index.js +13 -0
- package/cjs/types/storage.d.ts +1 -0
- package/cjs/types/storage.js +4 -0
- package/cjs/types/submittable.d.ts +1 -0
- package/cjs/types/submittable.js +4 -0
- package/cjs/util/augmentObject.d.ts +9 -0
- package/cjs/util/augmentObject.js +84 -0
- package/cjs/util/decorate.d.ts +16 -0
- package/cjs/util/decorate.js +17 -0
- package/cjs/util/filterEvents.d.ts +6 -0
- package/cjs/util/filterEvents.js +25 -0
- package/cjs/util/index.d.ts +4 -0
- package/cjs/util/index.js +11 -0
- package/cjs/util/isKeyringPair.d.ts +3 -0
- package/cjs/util/isKeyringPair.js +7 -0
- package/cjs/util/logging.d.ts +1 -0
- package/cjs/util/logging.js +5 -0
- package/cjs/util/validate.d.ts +3 -0
- package/cjs/util/validate.js +26 -0
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/package.json +588 -22
- package/packageDetect.d.ts +1 -0
- package/packageDetect.js +8 -0
- package/packageInfo.d.ts +6 -0
- package/packageInfo.js +1 -0
- package/promise/Api.d.ts +158 -0
- package/promise/Api.js +191 -0
- package/promise/Combinator.d.ts +12 -0
- package/promise/Combinator.js +68 -0
- package/promise/decorateMethod.d.ts +14 -0
- package/promise/decorateMethod.js +71 -0
- package/promise/index.d.ts +2 -0
- package/promise/index.js +2 -0
- package/promise/types.d.ts +5 -0
- package/promise/types.js +1 -0
- package/rx/Api.d.ts +155 -0
- package/rx/Api.js +169 -0
- package/rx/decorateMethod.d.ts +3 -0
- package/rx/decorateMethod.js +3 -0
- package/rx/index.d.ts +2 -0
- package/rx/index.js +2 -0
- package/src/augment.ts +1 -1
- package/src/base/Decorate.ts +1 -1
- package/src/base/Events.ts +1 -1
- package/src/base/Getters.ts +1 -1
- package/src/base/Init.ts +1 -1
- package/src/base/find.ts +1 -1
- package/src/base/index.ts +1 -1
- package/src/base/types.ts +1 -1
- package/src/bundle.ts +1 -1
- package/src/checkTypes.manual.ts +7 -7
- package/src/index.ts +1 -1
- package/src/mod.ts +1 -1
- package/src/packageDetect.ts +2 -2
- package/src/packageInfo.ts +3 -3
- package/src/promise/Api.ts +3 -3
- package/src/promise/Combinator.ts +1 -1
- package/src/promise/Combinators.spec.ts +1 -1
- package/src/promise/decorateMethod.ts +1 -1
- package/src/promise/index.spec.ts +1 -1
- package/src/promise/index.ts +1 -1
- package/src/promise/types.ts +1 -1
- package/src/rx/Api.ts +3 -3
- package/src/rx/decorateMethod.ts +1 -1
- package/src/rx/index.ts +1 -1
- package/src/submittable/Result.ts +1 -1
- package/src/submittable/createClass.ts +1 -1
- package/src/submittable/createSubmittable.ts +1 -1
- package/src/submittable/index.ts +1 -1
- package/src/submittable/types.ts +1 -1
- package/src/test/SingleAccountSigner.ts +1 -1
- package/src/test/index.ts +1 -1
- package/src/test/logEvents.ts +1 -1
- package/src/types/calls.ts +1 -1
- package/src/types/consts.ts +1 -1
- package/src/types/errors.ts +1 -1
- package/src/types/events.ts +1 -1
- package/src/types/index.ts +1 -1
- package/src/types/storage.ts +1 -1
- package/src/types/submittable.ts +1 -1
- package/src/util/augmentObject.spec.ts +1 -1
- package/src/util/augmentObject.ts +1 -1
- package/src/util/decorate.ts +1 -1
- package/src/util/filterEvents.ts +1 -1
- package/src/util/index.ts +1 -1
- package/src/util/isKeyringPair.ts +1 -1
- package/src/util/logging.ts +1 -1
- package/src/util/validate.spec.ts +2 -2
- package/src/util/validate.ts +1 -1
- package/submittable/Result.d.ts +31 -0
- package/submittable/Result.js +80 -0
- package/submittable/createClass.d.ts +12 -0
- package/submittable/createClass.js +274 -0
- package/submittable/createSubmittable.d.ts +8 -0
- package/submittable/createSubmittable.js +5 -0
- package/submittable/index.d.ts +2 -0
- package/submittable/index.js +2 -0
- package/submittable/types.d.ts +1 -0
- package/submittable/types.js +1 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.spec.tsbuildinfo +1 -0
- package/types/calls.d.ts +1 -0
- package/types/calls.js +1 -0
- package/types/consts.d.ts +1 -0
- package/types/consts.js +1 -0
- package/types/errors.d.ts +1 -0
- package/types/errors.js +1 -0
- package/types/events.d.ts +1 -0
- package/types/events.js +1 -0
- package/types/index.d.ts +114 -0
- package/types/index.js +8 -0
- package/types/storage.d.ts +1 -0
- package/types/storage.js +1 -0
- package/types/submittable.d.ts +1 -0
- package/types/submittable.js +1 -0
- package/util/augmentObject.d.ts +9 -0
- package/util/augmentObject.js +81 -0
- package/util/decorate.d.ts +16 -0
- package/util/decorate.js +14 -0
- package/util/filterEvents.d.ts +6 -0
- package/util/filterEvents.js +22 -0
- package/util/index.d.ts +4 -0
- package/util/index.js +4 -0
- package/util/isKeyringPair.d.ts +3 -0
- package/util/isKeyringPair.js +4 -0
- package/util/logging.d.ts +1 -0
- package/util/logging.js +2 -0
- package/util/validate.d.ts +3 -0
- package/util/validate.js +23 -0
|
@@ -0,0 +1,756 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Decorate = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const api_derive_1 = require("@pezkuwi/api-derive");
|
|
6
|
+
const rpc_core_1 = require("@pezkuwi/rpc-core");
|
|
7
|
+
const rpc_provider_1 = require("@pezkuwi/rpc-provider");
|
|
8
|
+
const types_1 = require("@pezkuwi/types");
|
|
9
|
+
const types_known_1 = require("@pezkuwi/types-known");
|
|
10
|
+
const util_1 = require("@pezkuwi/util");
|
|
11
|
+
const util_crypto_1 = require("@pezkuwi/util-crypto");
|
|
12
|
+
const index_js_1 = require("../submittable/index.js");
|
|
13
|
+
const augmentObject_js_1 = require("../util/augmentObject.js");
|
|
14
|
+
const decorate_js_1 = require("../util/decorate.js");
|
|
15
|
+
const validate_js_1 = require("../util/validate.js");
|
|
16
|
+
const Events_js_1 = require("./Events.js");
|
|
17
|
+
const find_js_1 = require("./find.js");
|
|
18
|
+
const PAGE_SIZE_K = 1000; // limit aligned with the 1k on the node (trie lookups are heavy)
|
|
19
|
+
const PAGE_SIZE_V = 250; // limited since the data may be > 16MB (e.g. misfiring elections)
|
|
20
|
+
const PAGE_SIZE_Q = 50; // queue of pending storage queries (mapped together, next tick)
|
|
21
|
+
const l = (0, util_1.logger)('api/init');
|
|
22
|
+
let instanceCounter = 0;
|
|
23
|
+
function getAtQueryFn(api, { method, section }) {
|
|
24
|
+
return (0, util_1.assertReturn)(api.rx.query[section] && api.rx.query[section][method], () => `query.${section}.${method} is not available in this version of the metadata`);
|
|
25
|
+
}
|
|
26
|
+
class Decorate extends Events_js_1.Events {
|
|
27
|
+
#instanceId;
|
|
28
|
+
#runtimeLog = {};
|
|
29
|
+
#registry;
|
|
30
|
+
#storageGetQ = [];
|
|
31
|
+
#storageSubQ = [];
|
|
32
|
+
// HACK Use BN import so decorateDerive works... yes, wtf.
|
|
33
|
+
__phantom = new util_1.BN(0);
|
|
34
|
+
_type;
|
|
35
|
+
_call = {};
|
|
36
|
+
_consts = {};
|
|
37
|
+
_derive;
|
|
38
|
+
_errors = {};
|
|
39
|
+
_events = {};
|
|
40
|
+
_extrinsics;
|
|
41
|
+
_extrinsicType = types_1.GenericExtrinsic.LATEST_EXTRINSIC_VERSION;
|
|
42
|
+
_genesisHash;
|
|
43
|
+
_isConnected;
|
|
44
|
+
_isReady = false;
|
|
45
|
+
_query = {};
|
|
46
|
+
_queryMulti;
|
|
47
|
+
_rpc;
|
|
48
|
+
_rpcCore;
|
|
49
|
+
_runtimeMap = {};
|
|
50
|
+
_runtimeChain;
|
|
51
|
+
_runtimeMetadata;
|
|
52
|
+
_runtimeVersion;
|
|
53
|
+
_rx = { call: {}, consts: {}, query: {}, tx: {} };
|
|
54
|
+
_options;
|
|
55
|
+
/**
|
|
56
|
+
* This is the one and only method concrete children classes need to implement.
|
|
57
|
+
* It's a higher-order function, which takes one argument
|
|
58
|
+
* `method: Method extends (...args: any[]) => Observable<any>`
|
|
59
|
+
* (and one optional `options`), and should return the user facing method.
|
|
60
|
+
* For example:
|
|
61
|
+
* - For ApiRx, `decorateMethod` should just be identity, because the input
|
|
62
|
+
* function is already an Observable
|
|
63
|
+
* - For ApiPromise, `decorateMethod` should return a function that takes all
|
|
64
|
+
* the parameters from `method`, adds an optional `callback` argument, and
|
|
65
|
+
* returns a Promise.
|
|
66
|
+
*
|
|
67
|
+
* We could easily imagine other user-facing interfaces, which are simply
|
|
68
|
+
* implemented by transforming the Observable to Stream/Iterator/Kefir/Bacon
|
|
69
|
+
* via `decorateMethod`.
|
|
70
|
+
*/
|
|
71
|
+
_decorateMethod;
|
|
72
|
+
/**
|
|
73
|
+
* @description Create an instance of the class
|
|
74
|
+
*
|
|
75
|
+
* @param options Options object to create API instance or a Provider instance
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* <BR>
|
|
79
|
+
*
|
|
80
|
+
* ```javascript
|
|
81
|
+
* import Api from '@pezkuwi/api/promise';
|
|
82
|
+
*
|
|
83
|
+
* const api = new Api().isReady();
|
|
84
|
+
*
|
|
85
|
+
* api.rpc.subscribeNewHeads((header) => {
|
|
86
|
+
* console.log(`new block #${header.number.toNumber()}`);
|
|
87
|
+
* });
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
constructor(options, type, decorateMethod) {
|
|
91
|
+
super();
|
|
92
|
+
this.#instanceId = `${++instanceCounter}`;
|
|
93
|
+
this.#registry = options.source?.registry || options.registry || new types_1.TypeRegistry();
|
|
94
|
+
this._rx.callAt = (blockHash, knownVersion) => (0, rxjs_1.from)(this.at(blockHash, knownVersion)).pipe((0, rxjs_1.map)((a) => a.rx.call));
|
|
95
|
+
this._rx.queryAt = (blockHash, knownVersion) => (0, rxjs_1.from)(this.at(blockHash, knownVersion)).pipe((0, rxjs_1.map)((a) => a.rx.query));
|
|
96
|
+
this._rx.registry = this.#registry;
|
|
97
|
+
this._decorateMethod = decorateMethod;
|
|
98
|
+
this._options = options;
|
|
99
|
+
this._type = type;
|
|
100
|
+
const provider = options.source
|
|
101
|
+
? options.source._rpcCore.provider.isClonable
|
|
102
|
+
? options.source._rpcCore.provider.clone()
|
|
103
|
+
: options.source._rpcCore.provider
|
|
104
|
+
: (options.provider || new rpc_provider_1.WsProvider());
|
|
105
|
+
// The RPC interface decorates the known interfaces on init
|
|
106
|
+
this._rpcCore = new rpc_core_1.RpcCore(this.#instanceId, this.#registry, {
|
|
107
|
+
isPedantic: this._options.isPedantic,
|
|
108
|
+
provider,
|
|
109
|
+
rpcCacheCapacity: this._options.rpcCacheCapacity,
|
|
110
|
+
ttl: this._options.provider?.ttl,
|
|
111
|
+
userRpc: this._options.rpc
|
|
112
|
+
});
|
|
113
|
+
this._isConnected = new rxjs_1.BehaviorSubject(this._rpcCore.provider.isConnected);
|
|
114
|
+
this._rx.hasSubscriptions = this._rpcCore.provider.hasSubscriptions;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* @description Return the current used registry
|
|
118
|
+
*/
|
|
119
|
+
get registry() {
|
|
120
|
+
return this.#registry;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* @description Creates an instance of a type as registered
|
|
124
|
+
*/
|
|
125
|
+
createType(type, ...params) {
|
|
126
|
+
return this.#registry.createType(type, ...params);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* @description Register additional user-defined of chain-specific types in the type registry
|
|
130
|
+
*/
|
|
131
|
+
registerTypes(types) {
|
|
132
|
+
types && this.#registry.register(types);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* @returns `true` if the API operates with subscriptions
|
|
136
|
+
*/
|
|
137
|
+
get hasSubscriptions() {
|
|
138
|
+
return this._rpcCore.provider.hasSubscriptions;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* @returns `true` if the API decorate multi-key queries
|
|
142
|
+
*/
|
|
143
|
+
get supportMulti() {
|
|
144
|
+
return this._rpcCore.provider.hasSubscriptions || !!this._rpcCore.state.queryStorageAt;
|
|
145
|
+
}
|
|
146
|
+
_emptyDecorated(registry, blockHash) {
|
|
147
|
+
return {
|
|
148
|
+
call: {},
|
|
149
|
+
consts: {},
|
|
150
|
+
errors: {},
|
|
151
|
+
events: {},
|
|
152
|
+
query: {},
|
|
153
|
+
registry,
|
|
154
|
+
rx: {
|
|
155
|
+
call: {},
|
|
156
|
+
query: {}
|
|
157
|
+
},
|
|
158
|
+
tx: (0, index_js_1.createSubmittable)(this._type, this._rx, this._decorateMethod, registry, blockHash)
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
_createDecorated(registry, fromEmpty, decoratedApi, blockHash) {
|
|
162
|
+
if (!decoratedApi) {
|
|
163
|
+
decoratedApi = this._emptyDecorated(registry.registry, blockHash);
|
|
164
|
+
}
|
|
165
|
+
if (fromEmpty || !registry.decoratedMeta) {
|
|
166
|
+
registry.decoratedMeta = (0, types_1.expandMetadata)(registry.registry, registry.metadata);
|
|
167
|
+
}
|
|
168
|
+
const runtime = this._decorateCalls(registry, this._decorateMethod, blockHash);
|
|
169
|
+
const runtimeRx = this._decorateCalls(registry, this._rxDecorateMethod, blockHash);
|
|
170
|
+
const storage = this._decorateStorage(registry.decoratedMeta, this._decorateMethod, blockHash);
|
|
171
|
+
const storageRx = this._decorateStorage(registry.decoratedMeta, this._rxDecorateMethod, blockHash);
|
|
172
|
+
(0, augmentObject_js_1.augmentObject)('consts', registry.decoratedMeta.consts, decoratedApi.consts, fromEmpty);
|
|
173
|
+
(0, augmentObject_js_1.augmentObject)('errors', registry.decoratedMeta.errors, decoratedApi.errors, fromEmpty);
|
|
174
|
+
(0, augmentObject_js_1.augmentObject)('events', registry.decoratedMeta.events, decoratedApi.events, fromEmpty);
|
|
175
|
+
(0, augmentObject_js_1.augmentObject)('query', storage, decoratedApi.query, fromEmpty);
|
|
176
|
+
(0, augmentObject_js_1.augmentObject)('query', storageRx, decoratedApi.rx.query, fromEmpty);
|
|
177
|
+
(0, augmentObject_js_1.augmentObject)('call', runtime, decoratedApi.call, fromEmpty);
|
|
178
|
+
(0, augmentObject_js_1.augmentObject)('call', runtimeRx, decoratedApi.rx.call, fromEmpty);
|
|
179
|
+
decoratedApi.findCall = (callIndex) => (0, find_js_1.findCall)(registry.registry, callIndex);
|
|
180
|
+
decoratedApi.findError = (errorIndex) => (0, find_js_1.findError)(registry.registry, errorIndex);
|
|
181
|
+
decoratedApi.queryMulti = blockHash
|
|
182
|
+
? this._decorateMultiAt(decoratedApi, this._decorateMethod, blockHash)
|
|
183
|
+
: this._decorateMulti(this._decorateMethod);
|
|
184
|
+
decoratedApi.runtimeVersion = registry.runtimeVersion;
|
|
185
|
+
return {
|
|
186
|
+
createdAt: blockHash,
|
|
187
|
+
decoratedApi,
|
|
188
|
+
decoratedMeta: registry.decoratedMeta
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
_injectMetadata(registry, fromEmpty = false) {
|
|
192
|
+
// clear the decoration, we are redoing it here
|
|
193
|
+
if (fromEmpty || !registry.decoratedApi) {
|
|
194
|
+
registry.decoratedApi = this._emptyDecorated(registry.registry);
|
|
195
|
+
}
|
|
196
|
+
const { decoratedApi, decoratedMeta } = this._createDecorated(registry, fromEmpty, registry.decoratedApi);
|
|
197
|
+
this._call = decoratedApi.call;
|
|
198
|
+
this._consts = decoratedApi.consts;
|
|
199
|
+
this._errors = decoratedApi.errors;
|
|
200
|
+
this._events = decoratedApi.events;
|
|
201
|
+
this._query = decoratedApi.query;
|
|
202
|
+
this._rx.call = decoratedApi.rx.call;
|
|
203
|
+
this._rx.query = decoratedApi.rx.query;
|
|
204
|
+
const tx = this._decorateExtrinsics(decoratedMeta, this._decorateMethod);
|
|
205
|
+
const rxtx = this._decorateExtrinsics(decoratedMeta, this._rxDecorateMethod);
|
|
206
|
+
if (fromEmpty || !this._extrinsics) {
|
|
207
|
+
this._extrinsics = tx;
|
|
208
|
+
this._rx.tx = rxtx;
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
(0, augmentObject_js_1.augmentObject)('tx', tx, this._extrinsics, false);
|
|
212
|
+
(0, augmentObject_js_1.augmentObject)(null, rxtx, this._rx.tx, false);
|
|
213
|
+
}
|
|
214
|
+
(0, augmentObject_js_1.augmentObject)(null, decoratedMeta.consts, this._rx.consts, fromEmpty);
|
|
215
|
+
this.emit('decorated');
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* @deprecated
|
|
219
|
+
* backwards compatible endpoint for metadata injection, may be removed in the future (However, it is still useful for testing injection)
|
|
220
|
+
*/
|
|
221
|
+
injectMetadata(metadata, fromEmpty, registry) {
|
|
222
|
+
this._injectMetadata({ counter: 0, metadata, registry: registry || this.#registry, runtimeVersion: this.#registry.createType('RuntimeVersionPartial') }, fromEmpty);
|
|
223
|
+
}
|
|
224
|
+
_decorateFunctionMeta(input, output) {
|
|
225
|
+
output.meta = input.meta;
|
|
226
|
+
output.method = input.method;
|
|
227
|
+
output.section = input.section;
|
|
228
|
+
output.toJSON = input.toJSON;
|
|
229
|
+
if (input.callIndex) {
|
|
230
|
+
output.callIndex = input.callIndex;
|
|
231
|
+
}
|
|
232
|
+
return output;
|
|
233
|
+
}
|
|
234
|
+
// Filter all RPC methods based on the results of the rpc_methods call. We do this in the following
|
|
235
|
+
// manner to cater for both old and new:
|
|
236
|
+
// - when the number of entries are 0, only remove the ones with isOptional (account & contracts)
|
|
237
|
+
// - when non-zero, remove anything that is not in the array (we don't do this)
|
|
238
|
+
_filterRpc(methods, additional) {
|
|
239
|
+
// add any specific user-base RPCs
|
|
240
|
+
if (Object.keys(additional).length !== 0) {
|
|
241
|
+
this._rpcCore.addUserInterfaces(additional);
|
|
242
|
+
// re-decorate, only adding any new additional interfaces
|
|
243
|
+
this._decorateRpc(this._rpcCore, this._decorateMethod, this._rpc);
|
|
244
|
+
this._decorateRpc(this._rpcCore, this._rxDecorateMethod, this._rx.rpc);
|
|
245
|
+
}
|
|
246
|
+
// extract the actual sections from the methods (this is useful when
|
|
247
|
+
// we try and create mappings to runtime names via a hash mapping)
|
|
248
|
+
const sectionMap = {};
|
|
249
|
+
for (let i = 0, count = methods.length; i < count; i++) {
|
|
250
|
+
const [section] = methods[i].split('_');
|
|
251
|
+
sectionMap[section] = true;
|
|
252
|
+
}
|
|
253
|
+
// convert the actual section names into an easy name lookup
|
|
254
|
+
const sections = Object.keys(sectionMap);
|
|
255
|
+
for (let i = 0, count = sections.length; i < count; i++) {
|
|
256
|
+
const nameA = (0, util_1.stringUpperFirst)(sections[i]);
|
|
257
|
+
const nameB = `${nameA}Api`;
|
|
258
|
+
this._runtimeMap[(0, util_crypto_1.blake2AsHex)(nameA, 64)] = nameA;
|
|
259
|
+
this._runtimeMap[(0, util_crypto_1.blake2AsHex)(nameB, 64)] = nameB;
|
|
260
|
+
}
|
|
261
|
+
// finally we filter the actual methods to expose
|
|
262
|
+
this._filterRpcMethods(methods);
|
|
263
|
+
}
|
|
264
|
+
_filterRpcMethods(exposed) {
|
|
265
|
+
const hasResults = exposed.length !== 0;
|
|
266
|
+
const allKnown = [...this._rpcCore.mapping.entries()];
|
|
267
|
+
const allKeys = [];
|
|
268
|
+
const count = allKnown.length;
|
|
269
|
+
for (let i = 0; i < count; i++) {
|
|
270
|
+
const [, { alias, endpoint, method, pubsub, section }] = allKnown[i];
|
|
271
|
+
allKeys.push(`${section}_${method}`);
|
|
272
|
+
if (pubsub) {
|
|
273
|
+
allKeys.push(`${section}_${pubsub[1]}`);
|
|
274
|
+
allKeys.push(`${section}_${pubsub[2]}`);
|
|
275
|
+
}
|
|
276
|
+
if (alias) {
|
|
277
|
+
allKeys.push(...alias);
|
|
278
|
+
}
|
|
279
|
+
if (endpoint) {
|
|
280
|
+
allKeys.push(endpoint);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
const unknown = exposed.filter((k) => !allKeys.includes(k) &&
|
|
284
|
+
!k.includes('_unstable_'));
|
|
285
|
+
if (unknown.length && !this._options.noInitWarn) {
|
|
286
|
+
l.warn(`RPC methods not decorated: ${unknown.join(', ')}`);
|
|
287
|
+
}
|
|
288
|
+
// loop through all entries we have (populated in decorate) and filter as required
|
|
289
|
+
// only remove when we have results and method missing, or with no results if optional
|
|
290
|
+
for (let i = 0; i < count; i++) {
|
|
291
|
+
const [k, { method, section }] = allKnown[i];
|
|
292
|
+
if (hasResults && !exposed.includes(k) && k !== 'rpc_methods') {
|
|
293
|
+
if (this._rpc[section]) {
|
|
294
|
+
delete this._rpc[section][method];
|
|
295
|
+
delete this._rx.rpc[section][method];
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
_rpcSubmitter(decorateMethod) {
|
|
301
|
+
const method = (method, ...params) => {
|
|
302
|
+
return (0, rxjs_1.from)(this._rpcCore.provider.send(method, params));
|
|
303
|
+
};
|
|
304
|
+
return decorateMethod(method);
|
|
305
|
+
}
|
|
306
|
+
_decorateRpc(rpc, decorateMethod, input = this._rpcSubmitter(decorateMethod)) {
|
|
307
|
+
const out = input;
|
|
308
|
+
const decorateFn = (section, method) => {
|
|
309
|
+
const source = rpc[section][method];
|
|
310
|
+
const fn = decorateMethod(source, { methodName: method });
|
|
311
|
+
fn.meta = source.meta;
|
|
312
|
+
fn.raw = decorateMethod(source.raw, { methodName: method });
|
|
313
|
+
return fn;
|
|
314
|
+
};
|
|
315
|
+
for (let s = 0, scount = rpc.sections.length; s < scount; s++) {
|
|
316
|
+
const section = rpc.sections[s];
|
|
317
|
+
if (!Object.prototype.hasOwnProperty.call(out, section)) {
|
|
318
|
+
const methods = Object.keys(rpc[section]);
|
|
319
|
+
const decorateInternal = (method) => decorateFn(section, method);
|
|
320
|
+
for (let m = 0, mcount = methods.length; m < mcount; m++) {
|
|
321
|
+
const method = methods[m];
|
|
322
|
+
// skip subscriptions where we have a non-subscribe interface
|
|
323
|
+
if (this.hasSubscriptions || !(method.startsWith('subscribe') || method.startsWith('unsubscribe'))) {
|
|
324
|
+
if (!Object.prototype.hasOwnProperty.call(out, section)) {
|
|
325
|
+
out[section] = {};
|
|
326
|
+
}
|
|
327
|
+
(0, util_1.lazyMethod)(out[section], method, decorateInternal);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return out;
|
|
333
|
+
}
|
|
334
|
+
// add all definition entries
|
|
335
|
+
_addRuntimeDef(result, additional) {
|
|
336
|
+
if (!additional) {
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
const entries = Object.entries(additional);
|
|
340
|
+
for (let j = 0, ecount = entries.length; j < ecount; j++) {
|
|
341
|
+
const [key, defs] = entries[j];
|
|
342
|
+
if (result[key]) {
|
|
343
|
+
// we have this one already, step through for new versions or
|
|
344
|
+
// new methods and add those as applicable
|
|
345
|
+
for (let k = 0, dcount = defs.length; k < dcount; k++) {
|
|
346
|
+
const def = defs[k];
|
|
347
|
+
const prev = result[key].find(({ version }) => def.version === version);
|
|
348
|
+
if (prev) {
|
|
349
|
+
// interleave the new methods with the old - last definition wins
|
|
350
|
+
(0, util_1.objectSpread)(prev.methods, def.methods);
|
|
351
|
+
}
|
|
352
|
+
else {
|
|
353
|
+
// we don't have this specific version, add it
|
|
354
|
+
result[key].push(def);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
// we don't have this runtime definition, add it as-is
|
|
360
|
+
result[key] = defs;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
// extract all runtime definitions
|
|
365
|
+
_getRuntimeDefs(registry, specName, chain = '') {
|
|
366
|
+
const result = {};
|
|
367
|
+
const defValues = Object.values(types_1.typeDefinitions);
|
|
368
|
+
// options > chain/spec > built-in, apply in reverse order with
|
|
369
|
+
// methods overriding previous definitions (or interleave missing)
|
|
370
|
+
for (let i = 0, count = defValues.length; i < count; i++) {
|
|
371
|
+
this._addRuntimeDef(result, defValues[i].runtime);
|
|
372
|
+
}
|
|
373
|
+
this._addRuntimeDef(result, (0, types_known_1.getSpecRuntime)(registry, chain, specName));
|
|
374
|
+
this._addRuntimeDef(result, this._options.runtime);
|
|
375
|
+
return Object.entries(result);
|
|
376
|
+
}
|
|
377
|
+
// Helper for _getRuntimeDefsViaMetadata
|
|
378
|
+
_getMethods(registry, methods) {
|
|
379
|
+
const result = {};
|
|
380
|
+
methods.forEach((m) => {
|
|
381
|
+
const { docs, inputs, name, output } = m;
|
|
382
|
+
result[name.toString()] = {
|
|
383
|
+
description: docs.map((d) => d.toString()).join(),
|
|
384
|
+
params: inputs.map(({ name, type }) => {
|
|
385
|
+
return { name: name.toString(), type: registry.lookup.getName(type) || registry.lookup.getTypeDef(type).type };
|
|
386
|
+
}),
|
|
387
|
+
type: registry.lookup.getName(output) || registry.lookup.getTypeDef(output).type
|
|
388
|
+
};
|
|
389
|
+
});
|
|
390
|
+
return result;
|
|
391
|
+
}
|
|
392
|
+
// Maintains the same structure as `_getRuntimeDefs` in order to make conversion easier.
|
|
393
|
+
_getRuntimeDefsViaMetadata(registry) {
|
|
394
|
+
const result = {};
|
|
395
|
+
const { apis } = registry.metadata;
|
|
396
|
+
for (let i = 0, count = apis.length; i < count; i++) {
|
|
397
|
+
const { methods, name } = apis[i];
|
|
398
|
+
result[name.toString()] = [{
|
|
399
|
+
methods: this._getMethods(registry, methods),
|
|
400
|
+
// We set the version to 0 here since it will not be relevant when we are grabbing the runtime apis
|
|
401
|
+
// from the Metadata.
|
|
402
|
+
version: 0
|
|
403
|
+
}];
|
|
404
|
+
}
|
|
405
|
+
return Object.entries(result);
|
|
406
|
+
}
|
|
407
|
+
// When the calls are available in the metadata, it will generate them based off of the metadata.
|
|
408
|
+
// When they are not available it will use the hardcoded calls generated in the static types.
|
|
409
|
+
_decorateCalls({ registry, runtimeVersion: { apis, specName, specVersion } }, decorateMethod, blockHash) {
|
|
410
|
+
const result = {};
|
|
411
|
+
const named = {};
|
|
412
|
+
const hashes = {};
|
|
413
|
+
const isApiInMetadata = registry.metadata.apis.length > 0;
|
|
414
|
+
const sections = isApiInMetadata ? this._getRuntimeDefsViaMetadata(registry) : this._getRuntimeDefs(registry, specName, this._runtimeChain);
|
|
415
|
+
const older = [];
|
|
416
|
+
const implName = `${specName.toString()}/${specVersion.toString()}`;
|
|
417
|
+
const hasLogged = this.#runtimeLog[implName] || false;
|
|
418
|
+
this.#runtimeLog[implName] = true;
|
|
419
|
+
if (isApiInMetadata) {
|
|
420
|
+
for (let i = 0, scount = sections.length; i < scount; i++) {
|
|
421
|
+
const [_section, secs] = sections[i];
|
|
422
|
+
const sec = secs[0];
|
|
423
|
+
const sectionHash = (0, util_crypto_1.blake2AsHex)(_section, 64);
|
|
424
|
+
const section = (0, util_1.stringCamelCase)(_section);
|
|
425
|
+
const methods = Object.entries(sec.methods);
|
|
426
|
+
if (!named[section]) {
|
|
427
|
+
named[section] = {};
|
|
428
|
+
}
|
|
429
|
+
for (let m = 0, mcount = methods.length; m < mcount; m++) {
|
|
430
|
+
const [_method, def] = methods[m];
|
|
431
|
+
const method = (0, util_1.stringCamelCase)(_method);
|
|
432
|
+
named[section][method] = (0, util_1.objectSpread)({ method, name: `${_section}_${_method}`, section, sectionHash }, def);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
else {
|
|
437
|
+
for (let i = 0, scount = sections.length; i < scount; i++) {
|
|
438
|
+
const [_section, secs] = sections[i];
|
|
439
|
+
const sectionHash = (0, util_crypto_1.blake2AsHex)(_section, 64);
|
|
440
|
+
const rtApi = apis.find(([a]) => a.eq(sectionHash));
|
|
441
|
+
hashes[sectionHash] = true;
|
|
442
|
+
if (rtApi) {
|
|
443
|
+
const all = secs.map(({ version }) => version).sort();
|
|
444
|
+
const sec = secs.find(({ version }) => rtApi[1].eq(version));
|
|
445
|
+
if (sec) {
|
|
446
|
+
const section = (0, util_1.stringCamelCase)(_section);
|
|
447
|
+
const methods = Object.entries(sec.methods);
|
|
448
|
+
if (methods.length) {
|
|
449
|
+
if (!named[section]) {
|
|
450
|
+
named[section] = {};
|
|
451
|
+
}
|
|
452
|
+
for (let m = 0, mcount = methods.length; m < mcount; m++) {
|
|
453
|
+
const [_method, def] = methods[m];
|
|
454
|
+
const method = (0, util_1.stringCamelCase)(_method);
|
|
455
|
+
named[section][method] = (0, util_1.objectSpread)({ method, name: `${_section}_${_method}`, section, sectionHash }, def);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
else {
|
|
460
|
+
older.push(`${_section}/${rtApi[1].toString()} (${all.join('/')} known)`);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
// find the runtimes that we don't have hashes for
|
|
465
|
+
const notFound = apis
|
|
466
|
+
.map(([a, v]) => [a.toHex(), v.toString()])
|
|
467
|
+
.filter(([a]) => !hashes[a])
|
|
468
|
+
.map(([a, v]) => `${this._runtimeMap[a] || a}/${v}`);
|
|
469
|
+
if (!this._options.noInitWarn && !hasLogged) {
|
|
470
|
+
if (older.length) {
|
|
471
|
+
l.warn(`${implName}: Not decorating runtime apis without matching versions: ${older.join(', ')}`);
|
|
472
|
+
}
|
|
473
|
+
if (notFound.length) {
|
|
474
|
+
l.warn(`${implName}: Not decorating unknown runtime apis: ${notFound.join(', ')}`);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
const stateCall = blockHash
|
|
479
|
+
? (name, bytes) => this._rpcCore.state.call(name, bytes, blockHash)
|
|
480
|
+
: (name, bytes) => this._rpcCore.state.call(name, bytes);
|
|
481
|
+
const lazySection = (section) => (0, util_1.lazyMethods)({}, Object.keys(named[section]), (method) => this._decorateCall(registry, named[section][method], stateCall, decorateMethod));
|
|
482
|
+
const modules = Object.keys(named);
|
|
483
|
+
for (let i = 0, count = modules.length; i < count; i++) {
|
|
484
|
+
(0, util_1.lazyMethod)(result, modules[i], lazySection);
|
|
485
|
+
}
|
|
486
|
+
return result;
|
|
487
|
+
}
|
|
488
|
+
_decorateCall(registry, def, stateCall, decorateMethod) {
|
|
489
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
490
|
+
const decorated = decorateMethod((...args) => {
|
|
491
|
+
if (args.length !== def.params.length) {
|
|
492
|
+
throw new Error(`${def.name}:: Expected ${def.params.length} arguments, found ${args.length}`);
|
|
493
|
+
}
|
|
494
|
+
const bytes = registry.createType('Raw', (0, util_1.u8aConcatStrict)(args.map((a, i) => registry.createTypeUnsafe(def.params[i].type, [a]).toU8a())));
|
|
495
|
+
return stateCall(def.name, bytes).pipe((0, rxjs_1.map)((r) => registry.createTypeUnsafe(def.type, [r])));
|
|
496
|
+
});
|
|
497
|
+
decorated.meta = def;
|
|
498
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
499
|
+
return decorated;
|
|
500
|
+
}
|
|
501
|
+
// only be called if supportMulti is true
|
|
502
|
+
_decorateMulti(decorateMethod) {
|
|
503
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
504
|
+
return decorateMethod((keys) => keys.length
|
|
505
|
+
? (this.hasSubscriptions
|
|
506
|
+
? this._rpcCore.state.subscribeStorage
|
|
507
|
+
: this._rpcCore.state.queryStorageAt)(keys.map((args) => Array.isArray(args)
|
|
508
|
+
? args[0].creator.meta.type.isPlain
|
|
509
|
+
? [args[0].creator]
|
|
510
|
+
: args[0].creator.meta.type.asMap.hashers.length === 1
|
|
511
|
+
? [args[0].creator, args.slice(1)]
|
|
512
|
+
: [args[0].creator, ...args.slice(1)]
|
|
513
|
+
: [args.creator]))
|
|
514
|
+
: (0, rxjs_1.of)([]));
|
|
515
|
+
}
|
|
516
|
+
_decorateMultiAt(atApi, decorateMethod, blockHash) {
|
|
517
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
518
|
+
return decorateMethod((calls) => calls.length
|
|
519
|
+
? this._rpcCore.state.queryStorageAt(calls.map((args) => {
|
|
520
|
+
if (Array.isArray(args)) {
|
|
521
|
+
const { creator } = getAtQueryFn(atApi, args[0].creator);
|
|
522
|
+
return creator.meta.type.isPlain
|
|
523
|
+
? [creator]
|
|
524
|
+
: creator.meta.type.asMap.hashers.length === 1
|
|
525
|
+
? [creator, args.slice(1)]
|
|
526
|
+
: [creator, ...args.slice(1)];
|
|
527
|
+
}
|
|
528
|
+
return [getAtQueryFn(atApi, args.creator).creator];
|
|
529
|
+
}), blockHash)
|
|
530
|
+
: (0, rxjs_1.of)([]));
|
|
531
|
+
}
|
|
532
|
+
_decorateExtrinsics({ tx }, decorateMethod) {
|
|
533
|
+
const result = (0, index_js_1.createSubmittable)(this._type, this._rx, decorateMethod);
|
|
534
|
+
const lazySection = (section) => (0, util_1.lazyMethods)({}, Object.keys(tx[section]), (method) => method.startsWith('$')
|
|
535
|
+
? tx[section][method]
|
|
536
|
+
: this._decorateExtrinsicEntry(tx[section][method], result));
|
|
537
|
+
const sections = Object.keys(tx);
|
|
538
|
+
for (let i = 0, count = sections.length; i < count; i++) {
|
|
539
|
+
(0, util_1.lazyMethod)(result, sections[i], lazySection);
|
|
540
|
+
}
|
|
541
|
+
return result;
|
|
542
|
+
}
|
|
543
|
+
_decorateExtrinsicEntry(method, creator) {
|
|
544
|
+
const decorated = (...params) => creator(method(...params));
|
|
545
|
+
// pass through the `.is`
|
|
546
|
+
decorated.is = (other) => method.is(other);
|
|
547
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
548
|
+
return this._decorateFunctionMeta(method, decorated);
|
|
549
|
+
}
|
|
550
|
+
_decorateStorage({ query, registry }, decorateMethod, blockHash) {
|
|
551
|
+
const result = {};
|
|
552
|
+
const lazySection = (section) => (0, util_1.lazyMethods)({}, Object.keys(query[section]), (method) => blockHash
|
|
553
|
+
? this._decorateStorageEntryAt(registry, query[section][method], decorateMethod, blockHash)
|
|
554
|
+
: this._decorateStorageEntry(query[section][method], decorateMethod));
|
|
555
|
+
const sections = Object.keys(query);
|
|
556
|
+
for (let i = 0, count = sections.length; i < count; i++) {
|
|
557
|
+
(0, util_1.lazyMethod)(result, sections[i], lazySection);
|
|
558
|
+
}
|
|
559
|
+
return result;
|
|
560
|
+
}
|
|
561
|
+
_decorateStorageEntry(creator, decorateMethod) {
|
|
562
|
+
const getArgs = (args, registry) => (0, validate_js_1.extractStorageArgs)(registry || this.#registry, creator, args);
|
|
563
|
+
const getQueryAt = (blockHash) => (0, rxjs_1.from)(this.at(blockHash)).pipe((0, rxjs_1.map)((api) => getAtQueryFn(api, creator)));
|
|
564
|
+
// Disable this where it occurs for each field we are decorating
|
|
565
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment */
|
|
566
|
+
const decorated = this._decorateStorageCall(creator, decorateMethod);
|
|
567
|
+
decorated.creator = creator;
|
|
568
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
569
|
+
decorated.at = decorateMethod((blockHash, ...args) => getQueryAt(blockHash).pipe((0, rxjs_1.switchMap)((q) => q(...args))));
|
|
570
|
+
decorated.hash = decorateMethod((...args) => this._rpcCore.state.getStorageHash(getArgs(args)));
|
|
571
|
+
decorated.is = (key) => key.section === creator.section &&
|
|
572
|
+
key.method === creator.method;
|
|
573
|
+
decorated.key = (...args) => (0, util_1.u8aToHex)((0, util_1.compactStripLength)(creator(...args))[1]);
|
|
574
|
+
decorated.keyPrefix = (...args) => (0, util_1.u8aToHex)(creator.keyPrefix(...args));
|
|
575
|
+
decorated.size = decorateMethod((...args) => this._rpcCore.state.getStorageSize(getArgs(args)));
|
|
576
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
577
|
+
decorated.sizeAt = decorateMethod((blockHash, ...args) => getQueryAt(blockHash).pipe((0, rxjs_1.switchMap)((q) => this._rpcCore.state.getStorageSize(getArgs(args, q.creator.meta.registry), blockHash))));
|
|
578
|
+
// .keys() & .entries() only available on map types
|
|
579
|
+
if (creator.iterKey && creator.meta.type.isMap) {
|
|
580
|
+
decorated.entries = decorateMethod((0, rpc_core_1.memo)(this.#instanceId, (...args) => this._retrieveMapEntries(creator, null, args)));
|
|
581
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
582
|
+
decorated.entriesAt = decorateMethod((0, rpc_core_1.memo)(this.#instanceId, (blockHash, ...args) => getQueryAt(blockHash).pipe((0, rxjs_1.switchMap)((q) => this._retrieveMapEntries(q.creator, blockHash, args)))));
|
|
583
|
+
decorated.entriesPaged = decorateMethod((0, rpc_core_1.memo)(this.#instanceId, (opts) => this._retrieveMapEntriesPaged(creator, undefined, opts)));
|
|
584
|
+
decorated.keys = decorateMethod((0, rpc_core_1.memo)(this.#instanceId, (...args) => this._retrieveMapKeys(creator, null, args)));
|
|
585
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
586
|
+
decorated.keysAt = decorateMethod((0, rpc_core_1.memo)(this.#instanceId, (blockHash, ...args) => getQueryAt(blockHash).pipe((0, rxjs_1.switchMap)((q) => this._retrieveMapKeys(q.creator, blockHash, args)))));
|
|
587
|
+
decorated.keysPaged = decorateMethod((0, rpc_core_1.memo)(this.#instanceId, (opts) => this._retrieveMapKeysPaged(creator, undefined, opts)));
|
|
588
|
+
}
|
|
589
|
+
if (this.supportMulti && creator.meta.type.isMap) {
|
|
590
|
+
// When using double map storage function, user need to pass double map key as an array
|
|
591
|
+
decorated.multi = decorateMethod((args) => creator.meta.type.asMap.hashers.length === 1
|
|
592
|
+
? this._retrieveMulti(args.map((a) => [creator, [a]]))
|
|
593
|
+
: this._retrieveMulti(args.map((a) => [creator, a])));
|
|
594
|
+
}
|
|
595
|
+
/* eslint-enable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment */
|
|
596
|
+
return this._decorateFunctionMeta(creator, decorated);
|
|
597
|
+
}
|
|
598
|
+
_decorateStorageEntryAt(registry, creator, decorateMethod, blockHash) {
|
|
599
|
+
const getArgs = (args) => (0, validate_js_1.extractStorageArgs)(registry, creator, args);
|
|
600
|
+
// Disable this where it occurs for each field we are decorating
|
|
601
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment */
|
|
602
|
+
const decorated = decorateMethod((...args) => this._rpcCore.state.getStorage(getArgs(args), blockHash));
|
|
603
|
+
decorated.creator = creator;
|
|
604
|
+
decorated.hash = decorateMethod((...args) => this._rpcCore.state.getStorageHash(getArgs(args), blockHash));
|
|
605
|
+
decorated.is = (key) => key.section === creator.section &&
|
|
606
|
+
key.method === creator.method;
|
|
607
|
+
decorated.key = (...args) => (0, util_1.u8aToHex)((0, util_1.compactStripLength)(creator(...args))[1]);
|
|
608
|
+
decorated.keyPrefix = (...keys) => (0, util_1.u8aToHex)(creator.keyPrefix(...keys));
|
|
609
|
+
decorated.size = decorateMethod((...args) => this._rpcCore.state.getStorageSize(getArgs(args), blockHash));
|
|
610
|
+
// .keys() & .entries() only available on map types
|
|
611
|
+
if (creator.iterKey && creator.meta.type.isMap) {
|
|
612
|
+
decorated.entries = decorateMethod((0, rpc_core_1.memo)(this.#instanceId, (...args) => this._retrieveMapEntries(creator, blockHash, args)));
|
|
613
|
+
decorated.entriesPaged = decorateMethod((0, rpc_core_1.memo)(this.#instanceId, (opts) => this._retrieveMapEntriesPaged(creator, blockHash, opts)));
|
|
614
|
+
decorated.keys = decorateMethod((0, rpc_core_1.memo)(this.#instanceId, (...args) => this._retrieveMapKeys(creator, blockHash, args)));
|
|
615
|
+
decorated.keysPaged = decorateMethod((0, rpc_core_1.memo)(this.#instanceId, (opts) => this._retrieveMapKeysPaged(creator, blockHash, opts)));
|
|
616
|
+
}
|
|
617
|
+
if (this.supportMulti && creator.meta.type.isMap) {
|
|
618
|
+
// When using double map storage function, user need to pass double map key as an array
|
|
619
|
+
decorated.multi = decorateMethod((args) => creator.meta.type.asMap.hashers.length === 1
|
|
620
|
+
? this._retrieveMulti(args.map((a) => [creator, [a]]), blockHash)
|
|
621
|
+
: this._retrieveMulti(args.map((a) => [creator, a]), blockHash));
|
|
622
|
+
}
|
|
623
|
+
/* eslint-enable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment */
|
|
624
|
+
return this._decorateFunctionMeta(creator, decorated);
|
|
625
|
+
}
|
|
626
|
+
_queueStorage(call, queue) {
|
|
627
|
+
const query = queue === this.#storageSubQ
|
|
628
|
+
? this._rpcCore.state.subscribeStorage
|
|
629
|
+
: this._rpcCore.state.queryStorageAt;
|
|
630
|
+
let queueIdx = queue.length - 1;
|
|
631
|
+
let valueIdx = 0;
|
|
632
|
+
let valueObs;
|
|
633
|
+
// if we don't have queue entries yet,
|
|
634
|
+
// or the current queue has fired (see from below),
|
|
635
|
+
// or the current queue has the max entries,
|
|
636
|
+
// then we create a new queue
|
|
637
|
+
if (queueIdx === -1 || !queue[queueIdx] || queue[queueIdx][1].length === PAGE_SIZE_Q) {
|
|
638
|
+
queueIdx++;
|
|
639
|
+
valueObs = (0, rxjs_1.from)(
|
|
640
|
+
// we delay the execution until the next tick, this allows
|
|
641
|
+
// any queries made in this timeframe to be added to the same
|
|
642
|
+
// queue for a single query
|
|
643
|
+
new Promise((resolve) => {
|
|
644
|
+
(0, util_1.nextTick)(() => {
|
|
645
|
+
// get all the calls in this instance, resolve with it
|
|
646
|
+
// and then clear the queue so we don't add more
|
|
647
|
+
// (anything after this will be added to a new queue)
|
|
648
|
+
const calls = queue[queueIdx][1];
|
|
649
|
+
delete queue[queueIdx];
|
|
650
|
+
resolve(calls);
|
|
651
|
+
});
|
|
652
|
+
})).pipe((0, rxjs_1.switchMap)((calls) => query(calls)));
|
|
653
|
+
queue.push([valueObs, [call]]);
|
|
654
|
+
}
|
|
655
|
+
else {
|
|
656
|
+
valueObs = queue[queueIdx][0];
|
|
657
|
+
valueIdx = queue[queueIdx][1].length;
|
|
658
|
+
queue[queueIdx][1].push(call);
|
|
659
|
+
}
|
|
660
|
+
return valueObs.pipe(
|
|
661
|
+
// return the single value at this index
|
|
662
|
+
(0, rxjs_1.map)((values) => values[valueIdx]));
|
|
663
|
+
}
|
|
664
|
+
// Decorate the base storage call. In the case or rxjs or promise-without-callback (await)
|
|
665
|
+
// we make a subscription, alternatively we push this through a single-shot query
|
|
666
|
+
_decorateStorageCall(creator, decorateMethod) {
|
|
667
|
+
const memoed = (0, rpc_core_1.memo)(this.#instanceId, (...args) => {
|
|
668
|
+
const call = (0, validate_js_1.extractStorageArgs)(this.#registry, creator, args);
|
|
669
|
+
if (!this.hasSubscriptions) {
|
|
670
|
+
return this._rpcCore.state.getStorage(call);
|
|
671
|
+
}
|
|
672
|
+
return this._queueStorage(call, this.#storageSubQ);
|
|
673
|
+
});
|
|
674
|
+
return decorateMethod(memoed, {
|
|
675
|
+
methodName: creator.method,
|
|
676
|
+
overrideNoSub: (...args) => this._queueStorage((0, validate_js_1.extractStorageArgs)(this.#registry, creator, args), this.#storageGetQ)
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
// retrieve a set of values for a specific set of keys - here we chunk the keys into PAGE_SIZE sizes
|
|
680
|
+
_retrieveMulti(keys, blockHash) {
|
|
681
|
+
if (!keys.length) {
|
|
682
|
+
return (0, rxjs_1.of)([]);
|
|
683
|
+
}
|
|
684
|
+
const query = this.hasSubscriptions && !blockHash
|
|
685
|
+
? this._rpcCore.state.subscribeStorage
|
|
686
|
+
: this._rpcCore.state.queryStorageAt;
|
|
687
|
+
if (keys.length <= PAGE_SIZE_V) {
|
|
688
|
+
return blockHash
|
|
689
|
+
? query(keys, blockHash)
|
|
690
|
+
: query(keys);
|
|
691
|
+
}
|
|
692
|
+
return (0, rxjs_1.combineLatest)((0, util_1.arrayChunk)(keys, PAGE_SIZE_V).map((k) => blockHash
|
|
693
|
+
? query(k, blockHash)
|
|
694
|
+
: query(k))).pipe((0, rxjs_1.map)(util_1.arrayFlatten));
|
|
695
|
+
}
|
|
696
|
+
_retrieveMapKeys({ iterKey, meta, method, section }, at, args) {
|
|
697
|
+
if (!iterKey || !meta.type.isMap) {
|
|
698
|
+
throw new Error('keys can only be retrieved on maps');
|
|
699
|
+
}
|
|
700
|
+
const headKey = iterKey(...args).toHex();
|
|
701
|
+
const startSubject = new rxjs_1.BehaviorSubject(headKey);
|
|
702
|
+
const query = at
|
|
703
|
+
? (startKey) => this._rpcCore.state.getKeysPaged(headKey, PAGE_SIZE_K, startKey, at)
|
|
704
|
+
: (startKey) => this._rpcCore.state.getKeysPaged(headKey, PAGE_SIZE_K, startKey);
|
|
705
|
+
const setMeta = (key) => key.setMeta(meta, section, method);
|
|
706
|
+
return startSubject.pipe((0, rxjs_1.switchMap)(query), (0, rxjs_1.map)((keys) => keys.map(setMeta)), (0, rxjs_1.tap)((keys) => (0, util_1.nextTick)(() => {
|
|
707
|
+
keys.length === PAGE_SIZE_K
|
|
708
|
+
? startSubject.next(keys[PAGE_SIZE_K - 1].toHex())
|
|
709
|
+
: startSubject.complete();
|
|
710
|
+
})), (0, rxjs_1.toArray)(), // toArray since we want to startSubject to be completed
|
|
711
|
+
(0, rxjs_1.map)(util_1.arrayFlatten));
|
|
712
|
+
}
|
|
713
|
+
_retrieveMapKeysPaged({ iterKey, meta, method, section }, at, opts) {
|
|
714
|
+
if (!iterKey || !meta.type.isMap) {
|
|
715
|
+
throw new Error('keys can only be retrieved on maps');
|
|
716
|
+
}
|
|
717
|
+
const setMeta = (key) => key.setMeta(meta, section, method);
|
|
718
|
+
const query = at
|
|
719
|
+
? (headKey) => this._rpcCore.state.getKeysPaged(headKey, opts.pageSize, opts.startKey || headKey, at)
|
|
720
|
+
: (headKey) => this._rpcCore.state.getKeysPaged(headKey, opts.pageSize, opts.startKey || headKey);
|
|
721
|
+
return query(iterKey(...opts.args).toHex()).pipe((0, rxjs_1.map)((keys) => keys.map(setMeta)));
|
|
722
|
+
}
|
|
723
|
+
_retrieveMapEntries(entry, at, args) {
|
|
724
|
+
const query = at
|
|
725
|
+
? (keys) => this._rpcCore.state.queryStorageAt(keys, at)
|
|
726
|
+
: (keys) => this._rpcCore.state.queryStorageAt(keys);
|
|
727
|
+
return this._retrieveMapKeys(entry, at, args).pipe((0, rxjs_1.switchMap)((keys) => keys.length
|
|
728
|
+
? (0, rxjs_1.combineLatest)((0, util_1.arrayChunk)(keys, PAGE_SIZE_V).map(query)).pipe((0, rxjs_1.map)((valsArr) => (0, util_1.arrayFlatten)(valsArr).map((value, index) => [keys[index], value])))
|
|
729
|
+
: (0, rxjs_1.of)([])));
|
|
730
|
+
}
|
|
731
|
+
_retrieveMapEntriesPaged(entry, at, opts) {
|
|
732
|
+
const query = at
|
|
733
|
+
? (keys) => this._rpcCore.state.queryStorageAt(keys, at)
|
|
734
|
+
: (keys) => this._rpcCore.state.queryStorageAt(keys);
|
|
735
|
+
return this._retrieveMapKeysPaged(entry, at, opts).pipe((0, rxjs_1.switchMap)((keys) => keys.length
|
|
736
|
+
? query(keys).pipe((0, rxjs_1.map)((valsArr) => valsArr.map((value, index) => [keys[index], value])))
|
|
737
|
+
: (0, rxjs_1.of)([])));
|
|
738
|
+
}
|
|
739
|
+
_decorateDeriveRx(decorateMethod) {
|
|
740
|
+
const specName = this._runtimeVersion?.specName.toString();
|
|
741
|
+
// Pull in derive from api-derive
|
|
742
|
+
const available = (0, api_derive_1.getAvailableDerives)(this.#instanceId, this._rx, (0, util_1.objectSpread)({}, this._options.derives, this._options.typesBundle?.spec?.[specName || '']?.derives));
|
|
743
|
+
return (0, decorate_js_1.decorateDeriveSections)(decorateMethod, available);
|
|
744
|
+
}
|
|
745
|
+
_decorateDerive(decorateMethod) {
|
|
746
|
+
return (0, decorate_js_1.decorateDeriveSections)(decorateMethod, this._rx.derive);
|
|
747
|
+
}
|
|
748
|
+
/**
|
|
749
|
+
* Put the `this.onCall` function of ApiRx here, because it is needed by
|
|
750
|
+
* `api._rx`.
|
|
751
|
+
*/
|
|
752
|
+
_rxDecorateMethod = (method) => {
|
|
753
|
+
return method;
|
|
754
|
+
};
|
|
755
|
+
}
|
|
756
|
+
exports.Decorate = Decorate;
|