@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,274 @@
|
|
|
1
|
+
import { catchError, first, map, mergeMap, of, switchMap, tap } from 'rxjs';
|
|
2
|
+
import { identity, isBn, isFunction, isNumber, isString, isU8a, objectSpread } from '@pezkuwi/util';
|
|
3
|
+
import { filterEvents, isKeyringPair } from '../util/index.js';
|
|
4
|
+
import { SubmittableResult } from './Result.js';
|
|
5
|
+
function makeEraOptions(api, registry, partialOptions, { header, mortalLength, nonce }) {
|
|
6
|
+
if (!header) {
|
|
7
|
+
if (partialOptions.era && !partialOptions.blockHash) {
|
|
8
|
+
throw new Error('Expected blockHash to be passed alongside non-immortal era options');
|
|
9
|
+
}
|
|
10
|
+
if (isNumber(partialOptions.era)) {
|
|
11
|
+
// since we have no header, it is immortal, remove any option overrides
|
|
12
|
+
// so we only supply the genesisHash and no era to the construction
|
|
13
|
+
delete partialOptions.era;
|
|
14
|
+
delete partialOptions.blockHash;
|
|
15
|
+
}
|
|
16
|
+
return makeSignOptions(api, partialOptions, { nonce });
|
|
17
|
+
}
|
|
18
|
+
return makeSignOptions(api, partialOptions, {
|
|
19
|
+
blockHash: header.hash,
|
|
20
|
+
era: registry.createTypeUnsafe('ExtrinsicEra', [{
|
|
21
|
+
current: header.number,
|
|
22
|
+
period: partialOptions.era || mortalLength
|
|
23
|
+
}]),
|
|
24
|
+
nonce
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function makeSignAndSendOptions(partialOptions, statusCb) {
|
|
28
|
+
let options = {};
|
|
29
|
+
if (isFunction(partialOptions)) {
|
|
30
|
+
statusCb = partialOptions;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
options = objectSpread({}, partialOptions);
|
|
34
|
+
}
|
|
35
|
+
return [options, statusCb];
|
|
36
|
+
}
|
|
37
|
+
function makeSignOptions(api, partialOptions, extras) {
|
|
38
|
+
return objectSpread({ blockHash: api.genesisHash, genesisHash: api.genesisHash }, partialOptions, extras, { runtimeVersion: api.runtimeVersion, signedExtensions: api.registry.signedExtensions, version: api.extrinsicType });
|
|
39
|
+
}
|
|
40
|
+
function optionsOrNonce(partialOptions = {}) {
|
|
41
|
+
return isBn(partialOptions) || isNumber(partialOptions)
|
|
42
|
+
? { nonce: partialOptions }
|
|
43
|
+
: partialOptions;
|
|
44
|
+
}
|
|
45
|
+
export function createClass({ api, apiType, blockHash, decorateMethod }) {
|
|
46
|
+
// an instance of the base extrinsic for us to extend
|
|
47
|
+
const ExtrinsicBase = api.registry.createClass('Extrinsic');
|
|
48
|
+
const extrinsicInfoMap = new WeakMap();
|
|
49
|
+
class Submittable extends ExtrinsicBase {
|
|
50
|
+
#ignoreStatusCb;
|
|
51
|
+
#transformResult = (identity);
|
|
52
|
+
constructor(registry, extrinsic) {
|
|
53
|
+
super(registry, extrinsic, { version: api.extrinsicType });
|
|
54
|
+
this.#ignoreStatusCb = apiType === 'rxjs';
|
|
55
|
+
}
|
|
56
|
+
get hasDryRun() {
|
|
57
|
+
return isFunction(api.rpc.system?.dryRun);
|
|
58
|
+
}
|
|
59
|
+
get hasPaymentInfo() {
|
|
60
|
+
return isFunction(api.call.transactionPaymentApi?.queryInfo);
|
|
61
|
+
}
|
|
62
|
+
// dry run an extrinsic
|
|
63
|
+
dryRun(account, optionsOrHash) {
|
|
64
|
+
if (!this.hasDryRun) {
|
|
65
|
+
throw new Error('The system.dryRun RPC call is not available in your environment');
|
|
66
|
+
}
|
|
67
|
+
if (blockHash || isString(optionsOrHash) || isU8a(optionsOrHash)) {
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
69
|
+
return decorateMethod(() => api.rpc.system.dryRun(this.toHex(), blockHash || optionsOrHash));
|
|
70
|
+
}
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return,@typescript-eslint/no-unsafe-call
|
|
72
|
+
return decorateMethod(() => this.#observeSign(account, optionsOrHash).pipe(switchMap(() => api.rpc.system.dryRun(this.toHex()))))();
|
|
73
|
+
}
|
|
74
|
+
// calculate the payment info for this transaction (if signed and submitted)
|
|
75
|
+
paymentInfo(account, optionsOrHash) {
|
|
76
|
+
if (!this.hasPaymentInfo) {
|
|
77
|
+
throw new Error('The transactionPaymentApi.queryInfo runtime call is not available in your environment');
|
|
78
|
+
}
|
|
79
|
+
if (blockHash || isString(optionsOrHash) || isU8a(optionsOrHash)) {
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
81
|
+
return decorateMethod(() => api.callAt(blockHash || optionsOrHash).pipe(switchMap((callAt) => {
|
|
82
|
+
const u8a = this.toU8a();
|
|
83
|
+
return callAt.transactionPaymentApi.queryInfo(u8a, u8a.length);
|
|
84
|
+
})));
|
|
85
|
+
}
|
|
86
|
+
const [allOptions] = makeSignAndSendOptions(optionsOrHash);
|
|
87
|
+
const address = isKeyringPair(account) ? account.address : account.toString();
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return,@typescript-eslint/no-unsafe-call
|
|
89
|
+
return decorateMethod(() => api.derive.tx.signingInfo(address, allOptions.nonce, allOptions.era).pipe(first(), switchMap((signingInfo) => {
|
|
90
|
+
// setup our options (same way as in signAndSend)
|
|
91
|
+
const eraOptions = makeEraOptions(api, this.registry, allOptions, signingInfo);
|
|
92
|
+
const signOptions = makeSignOptions(api, eraOptions, {});
|
|
93
|
+
// 1. Don't use the internal objects inside the new tx (hence toU8a)
|
|
94
|
+
// 2. Don't override the data from existing signed extrinsics
|
|
95
|
+
// 3. Ensure that this object stays intact, with no new sign after operation
|
|
96
|
+
const u8a = api.tx(this.toU8a()).signFake(address, signOptions).toU8a();
|
|
97
|
+
return api.call.transactionPaymentApi.queryInfo(u8a, u8a.length);
|
|
98
|
+
})))();
|
|
99
|
+
}
|
|
100
|
+
// send implementation for both immediate Hash and statusCb variants
|
|
101
|
+
send(statusCb) {
|
|
102
|
+
const isSubscription = api.hasSubscriptions && (this.#ignoreStatusCb || !!statusCb);
|
|
103
|
+
const updatedInfo = extrinsicInfoMap.get(this);
|
|
104
|
+
extrinsicInfoMap.delete(this);
|
|
105
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return,@typescript-eslint/no-unsafe-call
|
|
106
|
+
return decorateMethod(isSubscription
|
|
107
|
+
? () => this.#observeSubscribe(updatedInfo)
|
|
108
|
+
: () => this.#observeSend(updatedInfo))(statusCb);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* @description Signs a transaction, returning `this` to allow chaining. E.g.: `signAsync(...).send()`. Like `.signAndSend` this will retrieve the nonce and blockHash to send the tx with.
|
|
112
|
+
*/
|
|
113
|
+
signAsync(account, partialOptions) {
|
|
114
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return,@typescript-eslint/no-unsafe-call
|
|
115
|
+
return decorateMethod(() => this.#observeSign(account, partialOptions).pipe(map((info) => {
|
|
116
|
+
// If we got a full signed transaction from the signer, attach it
|
|
117
|
+
if (info.signedTransaction) {
|
|
118
|
+
const extrinsic = new Submittable(api.registry, info.signedTransaction);
|
|
119
|
+
extrinsicInfoMap.set(this, info);
|
|
120
|
+
return extrinsic;
|
|
121
|
+
}
|
|
122
|
+
// Fallback if signer didn’t return signedTransaction
|
|
123
|
+
return this;
|
|
124
|
+
})))();
|
|
125
|
+
}
|
|
126
|
+
// signAndSend implementation for all 3 cases above
|
|
127
|
+
signAndSend(account, partialOptions, optionalStatusCb) {
|
|
128
|
+
const [options, statusCb] = makeSignAndSendOptions(partialOptions, optionalStatusCb);
|
|
129
|
+
const isSubscription = api.hasSubscriptions && (this.#ignoreStatusCb || !!statusCb);
|
|
130
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return,@typescript-eslint/no-unsafe-call
|
|
131
|
+
return decorateMethod(() => this.#observeSign(account, options).pipe(switchMap((info) => isSubscription
|
|
132
|
+
? this.#observeSubscribe(info)
|
|
133
|
+
: this.#observeSend(info))) // FIXME This is wrong, SubmittableResult is _not_ a codec
|
|
134
|
+
)(statusCb);
|
|
135
|
+
}
|
|
136
|
+
// adds a transform to the result, applied before result is returned
|
|
137
|
+
withResultTransform(transform) {
|
|
138
|
+
this.#transformResult = transform;
|
|
139
|
+
return this;
|
|
140
|
+
}
|
|
141
|
+
#observeSign = (account, partialOptions) => {
|
|
142
|
+
const address = isKeyringPair(account) ? account.address : account.toString();
|
|
143
|
+
const options = optionsOrNonce(partialOptions);
|
|
144
|
+
return api.derive.tx.signingInfo(address, options.nonce, options.era).pipe(first(), mergeMap(async (signingInfo) => {
|
|
145
|
+
const eraOptions = makeEraOptions(api, this.registry, options, signingInfo);
|
|
146
|
+
let updateId = -1;
|
|
147
|
+
let signedTx = null;
|
|
148
|
+
if (isKeyringPair(account)) {
|
|
149
|
+
this.sign(account, eraOptions);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
const result = await this.#signViaSigner(address, eraOptions, signingInfo.header);
|
|
153
|
+
updateId = result.id;
|
|
154
|
+
if (result.signedTransaction) {
|
|
155
|
+
signedTx = result.signedTransaction;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return { options: eraOptions, signedTransaction: signedTx, updateId };
|
|
159
|
+
}));
|
|
160
|
+
};
|
|
161
|
+
#observeStatus = (txHash, status) => {
|
|
162
|
+
if (!status.isFinalized && !status.isInBlock) {
|
|
163
|
+
return of(this.#transformResult(new SubmittableResult({
|
|
164
|
+
status,
|
|
165
|
+
txHash
|
|
166
|
+
})));
|
|
167
|
+
}
|
|
168
|
+
const blockHash = status.isInBlock
|
|
169
|
+
? status.asInBlock
|
|
170
|
+
: status.asFinalized;
|
|
171
|
+
return api.derive.tx.events(blockHash).pipe(map(({ block, events }) => this.#transformResult(new SubmittableResult({
|
|
172
|
+
...filterEvents(txHash, block, events, status),
|
|
173
|
+
status,
|
|
174
|
+
txHash
|
|
175
|
+
}))), catchError((internalError) => of(this.#transformResult(new SubmittableResult({
|
|
176
|
+
internalError,
|
|
177
|
+
status,
|
|
178
|
+
txHash
|
|
179
|
+
})))));
|
|
180
|
+
};
|
|
181
|
+
#observeSend = (info) => {
|
|
182
|
+
return api.rpc.author.submitExtrinsic(info?.signedTransaction || this).pipe(tap((hash) => {
|
|
183
|
+
this.#updateSigner(hash, info);
|
|
184
|
+
}));
|
|
185
|
+
};
|
|
186
|
+
#observeSubscribe = (info) => {
|
|
187
|
+
const txHash = this.hash;
|
|
188
|
+
return api.rpc.author.submitAndWatchExtrinsic(info?.signedTransaction || this).pipe(switchMap((status) => this.#observeStatus(txHash, status)), tap((status) => {
|
|
189
|
+
this.#updateSigner(status, info);
|
|
190
|
+
}));
|
|
191
|
+
};
|
|
192
|
+
#signViaSigner = async (address, options, header) => {
|
|
193
|
+
const signer = options.signer || api.signer;
|
|
194
|
+
const allowCallDataAlteration = options.allowCallDataAlteration ?? true;
|
|
195
|
+
if (!signer) {
|
|
196
|
+
throw new Error('No signer specified, either via api.setSigner or via sign options. You possibly need to pass through an explicit keypair for the origin so it can be used for signing.');
|
|
197
|
+
}
|
|
198
|
+
const payload = this.registry.createTypeUnsafe('SignerPayload', [objectSpread({}, options, {
|
|
199
|
+
address,
|
|
200
|
+
blockNumber: header ? header.number : 0,
|
|
201
|
+
method: this.method
|
|
202
|
+
})]);
|
|
203
|
+
let result;
|
|
204
|
+
if (isFunction(signer.signPayload)) {
|
|
205
|
+
result = await signer.signPayload(payload.toPayload());
|
|
206
|
+
if (result.signedTransaction && !options.withSignedTransaction) {
|
|
207
|
+
throw new Error('The `signedTransaction` field may not be submitted when `withSignedTransaction` is disabled');
|
|
208
|
+
}
|
|
209
|
+
if (result.signedTransaction && options.withSignedTransaction) {
|
|
210
|
+
const ext = this.registry.createTypeUnsafe('Extrinsic', [result.signedTransaction]);
|
|
211
|
+
const newSignerPayload = this.registry.createTypeUnsafe('SignerPayload', [objectSpread({}, {
|
|
212
|
+
address,
|
|
213
|
+
assetId: ext.assetId && ext.assetId.isSome ? ext.assetId.toHex() : null,
|
|
214
|
+
blockHash: payload.blockHash,
|
|
215
|
+
blockNumber: header ? header.number : 0,
|
|
216
|
+
era: ext.era.toHex(),
|
|
217
|
+
genesisHash: payload.genesisHash,
|
|
218
|
+
metadataHash: ext.metadataHash ? ext.metadataHash.toHex() : null,
|
|
219
|
+
method: ext.method.toHex(),
|
|
220
|
+
mode: ext.mode ? ext.mode.toHex() : null,
|
|
221
|
+
nonce: ext.nonce.toHex(),
|
|
222
|
+
runtimeVersion: payload.runtimeVersion,
|
|
223
|
+
signedExtensions: payload.signedExtensions,
|
|
224
|
+
tip: ext.tip ? ext.tip.toHex() : null,
|
|
225
|
+
version: payload.version
|
|
226
|
+
})]);
|
|
227
|
+
if (!ext.isSigned) {
|
|
228
|
+
throw new Error(`When using the signedTransaction field, the transaction must be signed. Recieved isSigned: ${ext.isSigned}`);
|
|
229
|
+
}
|
|
230
|
+
if (!allowCallDataAlteration) {
|
|
231
|
+
this.#validateSignedTransaction(payload, ext);
|
|
232
|
+
}
|
|
233
|
+
// This is only used for signAsync - signAndSend does not need to adjust the super payload or
|
|
234
|
+
// add the signature.
|
|
235
|
+
super.addSignature(address, result.signature, newSignerPayload.toPayload());
|
|
236
|
+
return { id: result.id, signedTransaction: result.signedTransaction };
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
else if (isFunction(signer.signRaw)) {
|
|
240
|
+
result = await signer.signRaw(payload.toRaw());
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
throw new Error('Invalid signer interface, it should implement either signPayload or signRaw (or both)');
|
|
244
|
+
}
|
|
245
|
+
// Here we explicitly call `toPayload()` again instead of working with an object
|
|
246
|
+
// (reference) as passed to the signer. This means that we are sure that the
|
|
247
|
+
// payload data is not modified from our inputs, but the signer
|
|
248
|
+
super.addSignature(address, result.signature, payload.toPayload());
|
|
249
|
+
return { id: result.id };
|
|
250
|
+
};
|
|
251
|
+
#updateSigner = (status, info) => {
|
|
252
|
+
if (info && (info.updateId !== -1)) {
|
|
253
|
+
const { options, updateId } = info;
|
|
254
|
+
const signer = options.signer || api.signer;
|
|
255
|
+
if (signer && isFunction(signer.update)) {
|
|
256
|
+
signer.update(updateId, status);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* When a signer includes `signedTransaction` within the SignerResult this will validate
|
|
262
|
+
* specific fields within the signed extrinsic against the original payload that was passed
|
|
263
|
+
* to the signer.
|
|
264
|
+
*/
|
|
265
|
+
#validateSignedTransaction = (signerPayload, signedExt) => {
|
|
266
|
+
const payload = signerPayload.toPayload();
|
|
267
|
+
const errMsg = (field) => `signAndSend: ${field} does not match the original payload`;
|
|
268
|
+
if (payload.method !== signedExt.method.toHex()) {
|
|
269
|
+
throw new Error(errMsg('call data'));
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
return Submittable;
|
|
274
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createClass } from './createClass.js';
|
|
2
|
+
export function createSubmittable(apiType, api, decorateMethod, registry, blockHash) {
|
|
3
|
+
const Submittable = createClass({ api, apiType, blockHash, decorateMethod });
|
|
4
|
+
return (extrinsic) => new Submittable(registry || api.registry, extrinsic);
|
|
5
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@pezkuwi/api-base/types/calls';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@pezkuwi/api-base/types/consts';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@pezkuwi/api-base/types/errors';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@pezkuwi/api-base/types/events';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { ApiBase } from '../base/index.js';
|
|
2
|
+
export * from '@pezkuwi/api/types/calls';
|
|
3
|
+
export * from '@pezkuwi/api/types/consts';
|
|
4
|
+
export * from '@pezkuwi/api/types/errors';
|
|
5
|
+
export * from '@pezkuwi/api/types/events';
|
|
6
|
+
export * from '@pezkuwi/api/types/storage';
|
|
7
|
+
export * from '@pezkuwi/api/types/submittable';
|
|
8
|
+
export * from '@pezkuwi/api-base/types';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@pezkuwi/api-base/types/storage';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@pezkuwi/api-base/types/submittable';
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { lazyMethods, logger, objectClear } from '@pezkuwi/util';
|
|
2
|
+
const l = logger('api/augment');
|
|
3
|
+
function logLength(type, values, and = []) {
|
|
4
|
+
return values.length
|
|
5
|
+
? ` ${values.length} ${type}${and.length ? ' and' : ''}`
|
|
6
|
+
: '';
|
|
7
|
+
}
|
|
8
|
+
function logValues(type, values) {
|
|
9
|
+
return values.length
|
|
10
|
+
? `\n\t${type.padStart(7)}: ${values.sort().join(', ')}`
|
|
11
|
+
: '';
|
|
12
|
+
}
|
|
13
|
+
function warn(prefix, type, [added, removed]) {
|
|
14
|
+
if (added.length || removed.length) {
|
|
15
|
+
l.warn(`api.${prefix}: Found${logLength('added', added, removed)}${logLength('removed', removed)} ${type}:${logValues('added', added)}${logValues('removed', removed)}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function findSectionExcludes(a, b) {
|
|
19
|
+
return a.filter((s) => !b.includes(s));
|
|
20
|
+
}
|
|
21
|
+
function findSectionIncludes(a, b) {
|
|
22
|
+
return a.filter((s) => b.includes(s));
|
|
23
|
+
}
|
|
24
|
+
function extractSections(src, dst) {
|
|
25
|
+
const srcSections = Object.keys(src);
|
|
26
|
+
const dstSections = Object.keys(dst);
|
|
27
|
+
return [
|
|
28
|
+
findSectionExcludes(srcSections, dstSections),
|
|
29
|
+
findSectionExcludes(dstSections, srcSections)
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
function findMethodExcludes(src, dst) {
|
|
33
|
+
const srcSections = Object.keys(src);
|
|
34
|
+
const dstSections = findSectionIncludes(Object.keys(dst), srcSections);
|
|
35
|
+
const excludes = [];
|
|
36
|
+
for (let s = 0, scount = dstSections.length; s < scount; s++) {
|
|
37
|
+
const section = dstSections[s];
|
|
38
|
+
const srcMethods = Object.keys(src[section]);
|
|
39
|
+
const dstMethods = Object.keys(dst[section]);
|
|
40
|
+
for (let d = 0, mcount = dstMethods.length; d < mcount; d++) {
|
|
41
|
+
const method = dstMethods[d];
|
|
42
|
+
if (!srcMethods.includes(method)) {
|
|
43
|
+
excludes.push(`${section}.${method}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return excludes;
|
|
48
|
+
}
|
|
49
|
+
function extractMethods(src, dst) {
|
|
50
|
+
return [
|
|
51
|
+
findMethodExcludes(dst, src),
|
|
52
|
+
findMethodExcludes(src, dst)
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* @description Takes a decorated api section (e.g. api.tx) and augment it with the details. It does not override what is
|
|
57
|
+
* already available, but rather just adds new missing items into the result object.
|
|
58
|
+
* @internal
|
|
59
|
+
*/
|
|
60
|
+
export function augmentObject(prefix, src, dst, fromEmpty = false) {
|
|
61
|
+
fromEmpty && objectClear(dst);
|
|
62
|
+
// NOTE: This part is slightly problematic since it will get the
|
|
63
|
+
// values for at least all the sections and the names of the methods
|
|
64
|
+
// (Since methods won't be decorated before lazy, this _may_ be ok)
|
|
65
|
+
if (prefix && Object.keys(dst).length) {
|
|
66
|
+
warn(prefix, 'modules', extractSections(src, dst));
|
|
67
|
+
warn(prefix, 'calls', extractMethods(src, dst));
|
|
68
|
+
}
|
|
69
|
+
const sections = Object.keys(src);
|
|
70
|
+
for (let i = 0, count = sections.length; i < count; i++) {
|
|
71
|
+
const section = sections[i];
|
|
72
|
+
const methods = src[section];
|
|
73
|
+
// We don't set here with a lazy interface, we decorate based
|
|
74
|
+
// on the top-level structure (this bypasses adding lazy onto lazy)
|
|
75
|
+
if (!dst[section]) {
|
|
76
|
+
dst[section] = {};
|
|
77
|
+
}
|
|
78
|
+
lazyMethods(dst[section], Object.keys(methods), (m) => methods[m]);
|
|
79
|
+
}
|
|
80
|
+
return dst;
|
|
81
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { lazyDeriveSection } from '@pezkuwi/api-derive';
|
|
2
|
+
/**
|
|
3
|
+
* This is a section decorator which keeps all type information.
|
|
4
|
+
*/
|
|
5
|
+
export function decorateDeriveSections(decorateMethod, derives) {
|
|
6
|
+
const getKeys = (s) => Object.keys(derives[s]);
|
|
7
|
+
const creator = (s, m) => decorateMethod(derives[s][m]);
|
|
8
|
+
const result = {};
|
|
9
|
+
const names = Object.keys(derives);
|
|
10
|
+
for (let i = 0, count = names.length; i < count; i++) {
|
|
11
|
+
lazyDeriveSection(result, names[i], getKeys, creator);
|
|
12
|
+
}
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { isCompact } from '@pezkuwi/util';
|
|
2
|
+
import { l } from './logging.js';
|
|
3
|
+
export function filterEvents(txHash, { block: { extrinsics, header } }, allEvents, status) {
|
|
4
|
+
// extrinsics to hashes
|
|
5
|
+
for (const [txIndex, x] of extrinsics.entries()) {
|
|
6
|
+
if (x.hash.eq(txHash)) {
|
|
7
|
+
return {
|
|
8
|
+
blockNumber: isCompact(header.number) ? header.number.unwrap() : header.number,
|
|
9
|
+
events: allEvents.filter(({ phase }) => phase.isApplyExtrinsic &&
|
|
10
|
+
phase.asApplyExtrinsic.eqn(txIndex)),
|
|
11
|
+
txIndex
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
// if we do get the block after finalized, it _should_ be there
|
|
16
|
+
// only warn on filtering with isInBlock (finalization finalizes after)
|
|
17
|
+
if (status.isInBlock) {
|
|
18
|
+
const allHashes = extrinsics.map((x) => x.hash.toHex());
|
|
19
|
+
l.warn(`block ${header.hash.toHex()}: Unable to find extrinsic ${txHash.toHex()} inside ${allHashes.join(', ')}`);
|
|
20
|
+
}
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { isUndefined } from '@pezkuwi/util';
|
|
2
|
+
function sig({ lookup }, { method, section }, args) {
|
|
3
|
+
return `${section}.${method}(${args.map((a) => lookup.getTypeDef(a).type).join(', ')})`;
|
|
4
|
+
}
|
|
5
|
+
export function extractStorageArgs(registry, creator, _args) {
|
|
6
|
+
const args = _args.filter((a) => !isUndefined(a));
|
|
7
|
+
if (creator.meta.type.isPlain) {
|
|
8
|
+
if (args.length !== 0) {
|
|
9
|
+
throw new Error(`${sig(registry, creator, [])} does not take any arguments, ${args.length} found`);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
const { hashers, key } = creator.meta.type.asMap;
|
|
14
|
+
const keys = hashers.length === 1
|
|
15
|
+
? [key]
|
|
16
|
+
: registry.lookup.getSiType(key).def.asTuple.map((t) => t);
|
|
17
|
+
if (args.length !== keys.length) {
|
|
18
|
+
throw new Error(`${sig(registry, creator, keys)} is a map, requiring ${keys.length} arguments, ${args.length} found`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
// pass as tuple
|
|
22
|
+
return [creator, args];
|
|
23
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# @pezkuwi/api
|
|
2
|
+
|
|
3
|
+
The Pezkuwi-JS API provides easy-to-use wrappers around JSONRPC calls that flow from an application to a node. It handles all the encoding and decoding or parameters, provides access to RPC functions and allows for the query of chain state and the submission of transactions.
|
|
4
|
+
|
|
5
|
+
The API wrappers provide a standard interface for use -
|
|
6
|
+
|
|
7
|
+
- A static `.create(<optional ApiOptions>)` that returns an API instance when connected, decorated and ready-to use. ApiOptions can include an optional WsProvider and optional custom type definitions `{ provider: <Optional WsProvider>, types: <Optional RegistryTypes> }`.
|
|
8
|
+
- The above is just a wrapper for `new Api(<optional ApiOptions>) `, exposing the `isReady` getter
|
|
9
|
+
- `api.rpc.<section>.<method>` provides access to actual RPC calls, be it for queries, submission or retrieving chain information
|
|
10
|
+
- [RPC (node interface)](https://js.pezkuwichain.app/docs/bizinikiwi/rpc)
|
|
11
|
+
- `api.query.<section>.<method>` provides access to chain state queries. These are dynamically populated based on what the runtime provides
|
|
12
|
+
- [Storage chain state (runtime node interface)](https://js.pezkuwichain.app/docs/bizinikiwi/storage)
|
|
13
|
+
- `api.tx.<section>.<method>` provides the ability to create a transaction, like chain state, this list is populated from a runtime query
|
|
14
|
+
- [Extrinsics (runtime node interface)](https://js.pezkuwichain.app/docs/bizinikiwi/extrinsics)
|
|
15
|
+
- `api.consts.<section>.<constant>` provides access to the module constants (parameter types).
|
|
16
|
+
- [Constants (runtime node interface)](https://js.pezkuwichain.app/docs/bizinikiwi/constants)
|
|
17
|
+
|
|
18
|
+
## API Selection
|
|
19
|
+
|
|
20
|
+
There are two flavours of the API provided, one allowing a standard interface via JavaScript Promises and the second provides an Observable wrapper using [RxJS](https://github.com/ReactiveX/rxjs). Depending on your use-case and familiarity, you can choose either (or even both) for your application.
|
|
21
|
+
|
|
22
|
+
- [[ApiPromise]] All interface calls returns Promises, including the static `.create(...)`. Additionally any subscription method uses `(value) => {}` callbacks, returning the value as the subscription is updated.
|
|
23
|
+
- [[ApiRx]] All interface calls return RxJS Observables, including the static `.create(...)`. In the same fashion subscription-based methods return long-running Observables that update with the latest values.
|
|
24
|
+
|
|
25
|
+
## Dynamic by default
|
|
26
|
+
|
|
27
|
+
Bizinikiwi (upon which Pezkuwi is built) uses on-chain WASM runtimes, allowing for upgradability. Each runtime defining the actual chain extrinsics (submitted transactions and block intrinsics) as well as available entries in the chain state. Due to this, the API endpoints for queries and transactions are dynamically populated from the running chain.
|
|
28
|
+
|
|
29
|
+
Due to this dynamic nature, this API departs from traditional APIs which only has fixed endpoints, driving use by what is available by the runtime. As a start, this generic nature has a learning curve, although the provided documentation, examples and linked documentation tries to make that experience as seamless as possible.
|
|
30
|
+
|
|
31
|
+
## Installation & import
|
|
32
|
+
|
|
33
|
+
Installation -
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
npm install --save @pezkuwi/api
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Subscribing to blocks via Promise-based API -
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
import { ApiPromise } from 'https://deno.land/x/pezkuwi/api/mod.ts';
|
|
43
|
+
|
|
44
|
+
const api = await ApiPromise.create();
|
|
45
|
+
|
|
46
|
+
api.rpc.chain.subscribeNewHeads((header) => {
|
|
47
|
+
console.log(`Chain is at #${header.number}`);
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Subscribing to blocks via RxJS-based API -
|
|
52
|
+
|
|
53
|
+
```javascript
|
|
54
|
+
import { ApiRx } from 'https://deno.land/x/pezkuwi/api/mod.ts';
|
|
55
|
+
|
|
56
|
+
const api = await ApiRx.create().toPromise();
|
|
57
|
+
|
|
58
|
+
api.rpc.chain.subscribeNewHeads().subscribe((header) => {
|
|
59
|
+
console.log(`Chain is at #${header.number}`);
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Registering custom types
|
|
64
|
+
|
|
65
|
+
Additional types used by runtime modules can be added when a new instance of the API is created. This is necessary if the runtime modules use types which are not available in the base Bizinikiwi runtime.
|
|
66
|
+
|
|
67
|
+
```javascript
|
|
68
|
+
import { ApiPromise } from 'https://deno.land/x/pezkuwi/api/mod.ts';
|
|
69
|
+
|
|
70
|
+
const api = await ApiPromise.create({
|
|
71
|
+
types: {
|
|
72
|
+
CustomTypesExample: {
|
|
73
|
+
"id": "u32",
|
|
74
|
+
"data": "Vec<u8>",
|
|
75
|
+
"deposit": "Balance",
|
|
76
|
+
"owner": "AccountId",
|
|
77
|
+
"application_expiry": "Moment",
|
|
78
|
+
"whitelisted": "bool",
|
|
79
|
+
"challenge_id": "u32"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Users
|
|
86
|
+
|
|
87
|
+
Some of the users of the API (let us know if you are missing from the list), include -
|
|
88
|
+
|
|
89
|
+
- [Pezkuwi-JS UI](https://github.com/pezkuwichain/pezkuwi-apps) A user-interface that allows you to make transactions, query the network or participate in actions on the network such as referendums and staking
|
|
90
|
+
- [KodaDot](https://github.com/vue-pezkuwi/apps) ([twitter](https://twitter.com/KodaDot)) - Vue.js web wallet, governance dashboard and aspiring performance (lightweight) alternative to original apps, mobile-first.
|
|
91
|
+
- [Polkabot](https://gitlab.com/Polkabot) Polkabot is a Matrix chatbot that keeps an eye on the Pezkuwi network. You can see Polkabot in action in https://matrix.to/#/#pezkuwi-network-status:matrix.org
|
|
92
|
+
- [Polkawallet.io](https://polkawallet.io) and [Polkawallet (Github)](https://github.com/polkawallet-io/polkawallet-RN/) A mobile wallet for the Pezkuwi network to manage funds and make transactions, available on both Androind and iOS
|
|
93
|
+
- [PolkaStats.io](https://polkastats.io), [PolkaStats frontend GitHub repository](https://github.com/Colm3na/polkastats-v2) and [PolkaStats backend GitHub repository](https://github.com/Colm3na/polkastats-backend-v2) Pezkuwi network statistics (currently Zagros and Alexander). Shows network information and staking details from validators and intentions.
|
|
94
|
+
- [Pezkuwi API Server (GitHub)](https://github.com/SimplyVC/pezkuwi_api_server) A lightweight server for querying Pezkuwi nodes from any language, built primarily as a backend for [PANIC for Pezkuwi (GitHub)](https://github.com/SimplyVC/panic_pezkuwi/), a validator monitoring and alerting tool.
|
|
95
|
+
- [Identity Registrar #1 from Chevdor on Zagros, Zagros and Pezkuwi](https://www.chevdor.com/tags/registrar/)
|