@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,320 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import 'https://deno.land/x/pezkuwi/api-augment/mod.ts';
|
|
4
|
+
|
|
5
|
+
import type { HeaderExtended } from 'https://deno.land/x/pezkuwi/api-derive/types.ts';
|
|
6
|
+
import type { TestKeyringMapBizinikiwi } from 'https://deno.land/x/pezkuwi/keyring/testingPairs.ts';
|
|
7
|
+
import type { StorageKey } from 'https://deno.land/x/pezkuwi/types/mod.ts';
|
|
8
|
+
import type { AccountId, Balance, DispatchErrorModule, Event, Header, Index } from 'https://deno.land/x/pezkuwi/types/interfaces/index.ts';
|
|
9
|
+
import type { PezframeSystemAccountInfo } from 'https://deno.land/x/pezkuwi/types/lookup.ts';
|
|
10
|
+
import type { AnyTuple, IExtrinsic, IMethod } from 'https://deno.land/x/pezkuwi/types/types/index.ts';
|
|
11
|
+
import type { SubmittableResult } from './index.ts';
|
|
12
|
+
|
|
13
|
+
import { ApiPromise } from 'https://deno.land/x/pezkuwi/api/mod.ts';
|
|
14
|
+
import { createTestPairs } from 'https://deno.land/x/pezkuwi/keyring/testingPairs.ts';
|
|
15
|
+
import { createTypeUnsafe, TypeRegistry } from 'https://deno.land/x/pezkuwi/types/create/index.ts';
|
|
16
|
+
|
|
17
|
+
const registry = new TypeRegistry();
|
|
18
|
+
|
|
19
|
+
async function calls (api: ApiPromise): Promise<void> {
|
|
20
|
+
// it allows defaults
|
|
21
|
+
const testSetId = await api.call.grandpaApi.currentSetId();
|
|
22
|
+
|
|
23
|
+
// it allows type overrides (generally shouldn't be used, but available)
|
|
24
|
+
const testSetIdO = await api.call.grandpaApi.currentSetId<AccountId>();
|
|
25
|
+
|
|
26
|
+
// it allows actual params
|
|
27
|
+
const nonce = await api.call.accountNonceApi.accountNonce('5Test');
|
|
28
|
+
|
|
29
|
+
console.log(testSetId.toNumber(), testSetIdO.isAscii, nonce.toNumber());
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function consts (api: ApiPromise): void {
|
|
33
|
+
// constants has actual value & metadata
|
|
34
|
+
console.log(
|
|
35
|
+
api.consts['notIn']['augmentation'],
|
|
36
|
+
api.consts.balances.existentialDeposit.toNumber(),
|
|
37
|
+
api.consts.balances.existentialDeposit.meta.docs.map((s) => s.toString()).join(''),
|
|
38
|
+
api.consts.system.blockWeights.maxBlock.refTime.toNumber()
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function derive (api: ApiPromise): Promise<void> {
|
|
43
|
+
await api.derive.chain.subscribeNewHeads((header: HeaderExtended): void => {
|
|
44
|
+
console.log('current author:', header.author);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const info = await api.derive.balances.account('0x1234');
|
|
48
|
+
|
|
49
|
+
console.log('info', info);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function errors (api: ApiPromise): void {
|
|
53
|
+
const someError = {} as DispatchErrorModule;
|
|
54
|
+
|
|
55
|
+
// existing
|
|
56
|
+
console.log(api.errors.vesting.AmountLow.is(someError));
|
|
57
|
+
|
|
58
|
+
// non-existing error, existing module
|
|
59
|
+
console.log(api.errors.vesting['NonAugmented'].is(someError));
|
|
60
|
+
|
|
61
|
+
// something random
|
|
62
|
+
console.log(api.errors['thisIsNot']['Augmented'].is(someError));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function events (api: ApiPromise): void {
|
|
66
|
+
const event = {} as Event;
|
|
67
|
+
|
|
68
|
+
// existing
|
|
69
|
+
if (api.events.balances.Transfer.is(event)) {
|
|
70
|
+
// the types are correctly expanded
|
|
71
|
+
const [afrom, ato, aamount] = event.data;
|
|
72
|
+
|
|
73
|
+
console.log(
|
|
74
|
+
afrom.toHuman(),
|
|
75
|
+
ato.toHuman(),
|
|
76
|
+
aamount.toBn()
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
// the types have getters
|
|
80
|
+
const { amount, from, to } = event.data;
|
|
81
|
+
|
|
82
|
+
console.log(
|
|
83
|
+
from.toHuman(),
|
|
84
|
+
to.toHuman(),
|
|
85
|
+
amount.toBn()
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// something with only tuple data
|
|
90
|
+
if (api.events.staking.Bonded.is(event)) {
|
|
91
|
+
const [account, amount] = event.data;
|
|
92
|
+
|
|
93
|
+
console.log(account.toHuman(), amount.toBn());
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// something random, just codec[]
|
|
97
|
+
if (api.events['not']['Augmented'].is(event)) {
|
|
98
|
+
const [a, b] = event.data;
|
|
99
|
+
|
|
100
|
+
console.log(a.toHuman(), b.toHuman());
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async function query (api: ApiPromise, pairs: TestKeyringMapBizinikiwi): Promise<void> {
|
|
105
|
+
const intentions = await api.query.staking.bonded();
|
|
106
|
+
|
|
107
|
+
console.log('intentions:', intentions);
|
|
108
|
+
|
|
109
|
+
// api.query.*.* is well-typed
|
|
110
|
+
const bar = await api.query['notIn']['augmentation'](); // bar is Codec (unknown module)
|
|
111
|
+
const bal = await api.query.balances.totalIssuance(); // bal is Balance
|
|
112
|
+
const bal2 = await api.query.balances.totalIssuance('WRONG_ARG'); // bal2 is Codec (wrong args)
|
|
113
|
+
const override = await api.query.balances.totalIssuance<Header>(); // override is still available
|
|
114
|
+
|
|
115
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
116
|
+
const oldBal = await api.query.balances.totalIssuance.at('abcd');
|
|
117
|
+
|
|
118
|
+
// For older queries we can cast with `<Balance>` (newer chain have multi typed)
|
|
119
|
+
const multia = await api.query.balances['freeBalance'].multi<Balance>([pairs.alice.address, pairs.bob.address]);
|
|
120
|
+
const multib = await api.query.system.account.multi([pairs.alice.address, pairs.bob.address]);
|
|
121
|
+
|
|
122
|
+
await api.query.system.account(pairs.alice.address);
|
|
123
|
+
await api.query.system.account<PezframeSystemAccountInfo>(pairs.alice.address);
|
|
124
|
+
|
|
125
|
+
console.log('query types:', bar, bal, bal2, override, oldBal, multia, multib);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
async function queryExtra (api: ApiPromise): Promise<void> {
|
|
129
|
+
// events destructing
|
|
130
|
+
await api.query.system.events((records): void => {
|
|
131
|
+
records.forEach(({ event, phase }): void => {
|
|
132
|
+
if (phase.isApplyExtrinsic) {
|
|
133
|
+
// Dunno... this should work
|
|
134
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
135
|
+
// @ts-ignore
|
|
136
|
+
const [accountId, value]: [AccountId, Balance] = event.data;
|
|
137
|
+
|
|
138
|
+
console.log(`${accountId.toString()} has ${value.toHuman()}`);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// at queries
|
|
144
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
145
|
+
const events = await api.query.system.events.at('0x12345');
|
|
146
|
+
|
|
147
|
+
console.log(`Received ${events.length} events:`);
|
|
148
|
+
|
|
149
|
+
// check entries()
|
|
150
|
+
await api.query.system.account.entries(); // should not take a param
|
|
151
|
+
await api.query.staking.nominatorSlashInEra.entries(123); // should take a param
|
|
152
|
+
|
|
153
|
+
// nmap with keys
|
|
154
|
+
await api.query.assets.approvals.keys(123, 'blah');
|
|
155
|
+
await api.query.assets.account.keys(123);
|
|
156
|
+
await api.query.assets.account.entries(123);
|
|
157
|
+
await api.query.assets['notAugmented'].keys();
|
|
158
|
+
|
|
159
|
+
// is
|
|
160
|
+
const key = {} as StorageKey;
|
|
161
|
+
|
|
162
|
+
if (api.query.balances.account.is(key)) {
|
|
163
|
+
const [accountId] = key.args;
|
|
164
|
+
|
|
165
|
+
// should be AccountId type
|
|
166
|
+
console.log(accountId.toHuman());
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async function queryMulti (api: ApiPromise, pairs: TestKeyringMapBizinikiwi): Promise<void> {
|
|
171
|
+
// check multi for unsub
|
|
172
|
+
const multiUnsub = await api.queryMulti([
|
|
173
|
+
[api.query.staking.validators],
|
|
174
|
+
[api.query.system.events]
|
|
175
|
+
], (values): void => {
|
|
176
|
+
console.log('values', values);
|
|
177
|
+
|
|
178
|
+
multiUnsub();
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// check multi , Promise result
|
|
182
|
+
const multiRes = await api.queryMulti([
|
|
183
|
+
[api.query.system.account, pairs.eve.address],
|
|
184
|
+
// older chains only
|
|
185
|
+
[api.query.system['accountNonce'], pairs.eve.address]
|
|
186
|
+
]);
|
|
187
|
+
|
|
188
|
+
console.log(multiRes);
|
|
189
|
+
|
|
190
|
+
// check multi, via at
|
|
191
|
+
const apiAt = await api.at('0x12345678');
|
|
192
|
+
const multiResAt = await apiAt.queryMulti([
|
|
193
|
+
api.query.timestamp.now,
|
|
194
|
+
[apiAt.query.staking.validators],
|
|
195
|
+
[apiAt.query.system.account, pairs.eve.address]
|
|
196
|
+
]);
|
|
197
|
+
|
|
198
|
+
console.log(multiResAt);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
async function rpc (api: ApiPromise): Promise<void> {
|
|
202
|
+
// defaults
|
|
203
|
+
await api.rpc.chain.subscribeNewHeads((header): void => {
|
|
204
|
+
console.log('current header #', header.number.toNumber());
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
// with generic params
|
|
208
|
+
await api.rpc.state.subscribeStorage<[Balance]>(['my_balance_key'], ([balance]): void => {
|
|
209
|
+
console.log('current balance:', balance.toString());
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
// using json & raw
|
|
213
|
+
await api.rpc.chain.getBlock.raw('0x123456');
|
|
214
|
+
|
|
215
|
+
// using raw subs
|
|
216
|
+
await api.rpc.chain.subscribeNewHeads.raw((result: Uint8Array): void => {
|
|
217
|
+
console.log(result);
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
// deprecated methods
|
|
221
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
222
|
+
await api.rpc.state.getPairs('123');
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function types (api: ApiPromise): void {
|
|
226
|
+
// check correct types with `createType`
|
|
227
|
+
const balance = registry.createType('Balance', 2);
|
|
228
|
+
const gas = registry.createType('Gas', 2);
|
|
229
|
+
const compact = registry.createType('Compact<u32>', 2);
|
|
230
|
+
const f32 = registry.createType('f32');
|
|
231
|
+
const u32 = registry.createType('u32');
|
|
232
|
+
const raw = registry.createType('Raw');
|
|
233
|
+
// const random = registry.createType('RandomType', 2); // This one should deliberately show a TS error
|
|
234
|
+
|
|
235
|
+
const gasUnsafe = createTypeUnsafe(registry, 'Gas', [2]);
|
|
236
|
+
const overriddenUnsafe = createTypeUnsafe<Header>(registry, 'Gas', [2]);
|
|
237
|
+
|
|
238
|
+
console.log(balance, gas, compact, gasUnsafe, overriddenUnsafe, u32.toNumber(), f32.toNumber(), api.createType('AccountData'), raw.subarray(0, 10));
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
async function tx (api: ApiPromise, pairs: TestKeyringMapBizinikiwi): Promise<void> {
|
|
242
|
+
// transfer, also allows for bigint inputs here
|
|
243
|
+
const transfer = api.tx.balances.transferAllowDeath(pairs.bob.address, BigInt(123456789));
|
|
244
|
+
|
|
245
|
+
console.log('transfer casted', transfer as IMethod<AnyTuple>, transfer as IExtrinsic<AnyTuple>);
|
|
246
|
+
|
|
247
|
+
// simple "return the hash" variant
|
|
248
|
+
console.log('hash:', (await transfer.signAndSend(pairs.alice)).toHex());
|
|
249
|
+
|
|
250
|
+
// passing options, but waiting for hash
|
|
251
|
+
const nonce = await api.query.system['accountNonce']<Index>(pairs.alice.address);
|
|
252
|
+
|
|
253
|
+
(await api.tx.balances
|
|
254
|
+
.transferAllowDeath(pairs.bob.address, 12345)
|
|
255
|
+
.signAndSend(pairs.alice, { nonce })
|
|
256
|
+
).toHex();
|
|
257
|
+
|
|
258
|
+
// just with the callback
|
|
259
|
+
await api.tx.balances
|
|
260
|
+
.transferAllowDeath(pairs.bob.address, 12345)
|
|
261
|
+
.signAndSend(pairs.alice, ({ status }: SubmittableResult) => console.log(status.type));
|
|
262
|
+
|
|
263
|
+
// with options and the callback
|
|
264
|
+
const nonce2 = await api.query.system['accountNonce'](pairs.alice.address);
|
|
265
|
+
const unsub2 = await api.tx.balances
|
|
266
|
+
.transferAllowDeath(pairs.bob.address, 12345)
|
|
267
|
+
.signAndSend(pairs.alice, { nonce: nonce2 }, ({ status }: SubmittableResult): void => {
|
|
268
|
+
console.log('transfer status:', status.type);
|
|
269
|
+
|
|
270
|
+
unsub2();
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
// it allows for query & then using the submittable
|
|
274
|
+
const second = api.tx.democracy.second(123);
|
|
275
|
+
|
|
276
|
+
await second.signAndSend('123', (result) => console.log(result));
|
|
277
|
+
|
|
278
|
+
// it handles enum inputs correctly
|
|
279
|
+
await api.tx.democracy['proxyVote'](123, { Split: { nay: 456, yay: 123 } }).signAndSend(pairs.alice);
|
|
280
|
+
|
|
281
|
+
// is
|
|
282
|
+
if (api.tx.balances.transferAllowDeath.is(second)) {
|
|
283
|
+
const [recipientId, balance] = second.args;
|
|
284
|
+
|
|
285
|
+
// should be LookupSource & Balance types
|
|
286
|
+
console.log(recipientId.toHuman(), balance.toNumber());
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
async function at (api: ApiPromise): Promise<void> {
|
|
291
|
+
const apiAt = await api.at('0x1234');
|
|
292
|
+
|
|
293
|
+
// get old balances
|
|
294
|
+
console.log(await apiAt.query.balances['freeBalance']('0x1234'));
|
|
295
|
+
|
|
296
|
+
// get some constants
|
|
297
|
+
console.log(apiAt.consts.balances.existentialDeposit);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
async function main (): Promise<void> {
|
|
301
|
+
const api = await ApiPromise.create();
|
|
302
|
+
const pairs = createTestPairs();
|
|
303
|
+
|
|
304
|
+
await Promise.all([
|
|
305
|
+
calls(api),
|
|
306
|
+
consts(api),
|
|
307
|
+
derive(api),
|
|
308
|
+
errors(api),
|
|
309
|
+
events(api),
|
|
310
|
+
query(api, pairs),
|
|
311
|
+
queryExtra(api),
|
|
312
|
+
queryMulti(api, pairs),
|
|
313
|
+
rpc(api),
|
|
314
|
+
types(api),
|
|
315
|
+
tx(api, pairs),
|
|
316
|
+
at(api)
|
|
317
|
+
]);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
main().catch(console.error);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import { packageInfo as deriveInfo } from 'https://deno.land/x/pezkuwi/api-derive/packageInfo.ts';
|
|
4
|
+
import { packageInfo as coreInfo } from 'https://deno.land/x/pezkuwi/rpc-core/packageInfo.ts';
|
|
5
|
+
import { packageInfo as providerInfo } from 'https://deno.land/x/pezkuwi/rpc-provider/packageInfo.ts';
|
|
6
|
+
import { packageInfo as typesInfo } from 'https://deno.land/x/pezkuwi/types/packageInfo.ts';
|
|
7
|
+
import { packageInfo as knownInfo } from 'https://deno.land/x/pezkuwi/types-known/packageInfo.ts';
|
|
8
|
+
import { detectPackage } from 'https://deno.land/x/pezkuwi/util/mod.ts';
|
|
9
|
+
|
|
10
|
+
import { packageInfo } from './packageInfo.ts';
|
|
11
|
+
|
|
12
|
+
detectPackage(packageInfo, null, [coreInfo, deriveInfo, knownInfo, providerInfo, typesInfo]);
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
|
|
2
|
+
import type { ApiOptions, UnsubscribePromise } from '../types/index.ts';
|
|
3
|
+
import type { CombinatorCallback, CombinatorFunction } from './Combinator.ts';
|
|
4
|
+
|
|
5
|
+
import { noop, objectSpread } from 'https://deno.land/x/pezkuwi/util/mod.ts';
|
|
6
|
+
|
|
7
|
+
import { ApiBase } from '../base/index.ts';
|
|
8
|
+
import { Combinator } from './Combinator.ts';
|
|
9
|
+
import { promiseTracker, toPromiseMethod } from './decorateMethod.ts';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* # @pezkuwi/api/promise
|
|
13
|
+
*
|
|
14
|
+
* ## Overview
|
|
15
|
+
*
|
|
16
|
+
* @name ApiPromise
|
|
17
|
+
* @description
|
|
18
|
+
* ApiPromise is a standard JavaScript wrapper around the RPC and interfaces on the Pezkuwi network. As a full Promise-based, all interface calls return Promises, including the static `.create(...)`. Subscription calls utilise `(value) => {}` callbacks to pass through the latest values.
|
|
19
|
+
*
|
|
20
|
+
* The API is well suited to real-time applications where either the single-shot state is needed or use is to be made of the subscription-based features of Pezkuwi (and Bizinikiwi) clients.
|
|
21
|
+
*
|
|
22
|
+
* @see [[ApiRx]]
|
|
23
|
+
*
|
|
24
|
+
* ## Usage
|
|
25
|
+
*
|
|
26
|
+
* Making rpc calls -
|
|
27
|
+
* <BR>
|
|
28
|
+
*
|
|
29
|
+
* ```javascript
|
|
30
|
+
* import ApiPromise from 'https://deno.land/x/pezkuwi/api/promise/index.ts';
|
|
31
|
+
*
|
|
32
|
+
* // initialise via static create
|
|
33
|
+
* const api = await ApiPromise.create();
|
|
34
|
+
*
|
|
35
|
+
* // make a subscription to the network head
|
|
36
|
+
* api.rpc.chain.subscribeNewHeads((header) => {
|
|
37
|
+
* console.log(`Chain is at #${header.number}`);
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
* <BR>
|
|
41
|
+
*
|
|
42
|
+
* Subscribing to chain state -
|
|
43
|
+
* <BR>
|
|
44
|
+
*
|
|
45
|
+
* ```javascript
|
|
46
|
+
* import { ApiPromise, WsProvider } from 'https://deno.land/x/pezkuwi/api/mod.ts';
|
|
47
|
+
*
|
|
48
|
+
* // initialise a provider with a specific endpoint
|
|
49
|
+
* const provider = new WsProvider('wss://example.com:9944')
|
|
50
|
+
*
|
|
51
|
+
* // initialise via isReady & new with specific provider
|
|
52
|
+
* const api = await new ApiPromise({ provider }).isReady;
|
|
53
|
+
*
|
|
54
|
+
* // retrieve the block target time
|
|
55
|
+
* const blockPeriod = await api.query.timestamp.blockPeriod().toNumber();
|
|
56
|
+
* let last = 0;
|
|
57
|
+
*
|
|
58
|
+
* // subscribe to the current block timestamp, updates automatically (callback provided)
|
|
59
|
+
* api.query.timestamp.now((timestamp) => {
|
|
60
|
+
* const elapsed = last
|
|
61
|
+
* ? `, ${timestamp.toNumber() - last}s since last`
|
|
62
|
+
* : '';
|
|
63
|
+
*
|
|
64
|
+
* last = timestamp.toNumber();
|
|
65
|
+
* console.log(`timestamp ${timestamp}${elapsed} (${blockPeriod}s target)`);
|
|
66
|
+
* });
|
|
67
|
+
* ```
|
|
68
|
+
* <BR>
|
|
69
|
+
*
|
|
70
|
+
* Submitting a transaction -
|
|
71
|
+
* <BR>
|
|
72
|
+
*
|
|
73
|
+
* ```javascript
|
|
74
|
+
* import ApiPromise from 'https://deno.land/x/pezkuwi/api/promise/index.ts';
|
|
75
|
+
*
|
|
76
|
+
* ApiPromise.create().then((api) => {
|
|
77
|
+
* const [nonce] = await api.query.system.account(keyring.alice.address);
|
|
78
|
+
*
|
|
79
|
+
* api.tx.balances
|
|
80
|
+
* // create transfer
|
|
81
|
+
* transfer(keyring.bob.address, 12345)
|
|
82
|
+
* // sign the transcation
|
|
83
|
+
* .sign(keyring.alice, { nonce })
|
|
84
|
+
* // send the transaction (optional status callback)
|
|
85
|
+
* .send((status) => {
|
|
86
|
+
* console.log(`current status ${status.type}`);
|
|
87
|
+
* })
|
|
88
|
+
* // retrieve the submitted extrinsic hash
|
|
89
|
+
* .then((hash) => {
|
|
90
|
+
* console.log(`submitted with hash ${hash}`);
|
|
91
|
+
* });
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export class ApiPromise extends ApiBase<'promise'> {
|
|
96
|
+
#isReadyPromise: Promise<ApiPromise>;
|
|
97
|
+
#isReadyOrErrorPromise: Promise<ApiPromise>;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @description Creates an instance of the ApiPromise class
|
|
101
|
+
* @param options Options to create an instance. This can be either [[ApiOptions]] or
|
|
102
|
+
* an [[WsProvider]].
|
|
103
|
+
* @example
|
|
104
|
+
* <BR>
|
|
105
|
+
*
|
|
106
|
+
* ```javascript
|
|
107
|
+
* import Api from 'https://deno.land/x/pezkuwi/api/promise/index.ts';
|
|
108
|
+
*
|
|
109
|
+
* new Api().isReady.then((api) => {
|
|
110
|
+
* api.rpc.subscribeNewHeads((header) => {
|
|
111
|
+
* console.log(`new block #${header.number.toNumber()}`);
|
|
112
|
+
* });
|
|
113
|
+
* });
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
constructor (options?: ApiOptions) {
|
|
117
|
+
super(options, 'promise', toPromiseMethod);
|
|
118
|
+
|
|
119
|
+
this.#isReadyPromise = new Promise((resolve): void => {
|
|
120
|
+
super.once('ready', () => resolve(this));
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
this.#isReadyOrErrorPromise = new Promise((resolve, reject): void => {
|
|
124
|
+
const tracker = promiseTracker(resolve, reject);
|
|
125
|
+
|
|
126
|
+
super.once('ready', () => tracker.resolve(this));
|
|
127
|
+
super.once('error', (error: Error) => tracker.reject(error));
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @description Creates an ApiPromise instance using the supplied provider. Returns an Promise containing the actual Api instance.
|
|
133
|
+
* @param options options that is passed to the class contructor. Can be either [[ApiOptions]] or a
|
|
134
|
+
* provider (see the constructor arguments)
|
|
135
|
+
* @example
|
|
136
|
+
* <BR>
|
|
137
|
+
*
|
|
138
|
+
* ```javascript
|
|
139
|
+
* import Api from 'https://deno.land/x/pezkuwi/api/promise/index.ts';
|
|
140
|
+
*
|
|
141
|
+
* Api.create().then(async (api) => {
|
|
142
|
+
* const timestamp = await api.query.timestamp.now();
|
|
143
|
+
*
|
|
144
|
+
* console.log(`lastest block timestamp ${timestamp}`);
|
|
145
|
+
* });
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
public static create (options?: ApiOptions): Promise<ApiPromise> {
|
|
149
|
+
const instance = new ApiPromise(options);
|
|
150
|
+
|
|
151
|
+
if (options && options.throwOnConnect) {
|
|
152
|
+
return instance.isReadyOrError;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Swallow any rejections on isReadyOrError
|
|
156
|
+
// (in Node 15.x this creates issues, when not being looked at)
|
|
157
|
+
instance.isReadyOrError.catch(noop);
|
|
158
|
+
|
|
159
|
+
return instance.isReady;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* @description Promise that resolves the first time we are connected and loaded
|
|
164
|
+
*/
|
|
165
|
+
public get isReady (): Promise<ApiPromise> {
|
|
166
|
+
return this.#isReadyPromise;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* @description Promise that resolves if we can connect, or reject if there is an error
|
|
171
|
+
*/
|
|
172
|
+
public get isReadyOrError (): Promise<ApiPromise> {
|
|
173
|
+
return this.#isReadyOrErrorPromise;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* @description Returns a clone of this ApiPromise instance (new underlying provider connection)
|
|
178
|
+
*/
|
|
179
|
+
public clone (): ApiPromise {
|
|
180
|
+
return new ApiPromise(
|
|
181
|
+
objectSpread({}, this._options, { source: this })
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* @description Creates a combinator that can be used to combine the latest results from multiple subscriptions
|
|
187
|
+
* @param fns An array of function to combine, each in the form of `(cb: (value: void)) => void`
|
|
188
|
+
* @param callback A callback that will return an Array of all the values this combinator has been applied to
|
|
189
|
+
* @example
|
|
190
|
+
* <BR>
|
|
191
|
+
*
|
|
192
|
+
* ```javascript
|
|
193
|
+
* const address = '5DTestUPts3kjeXSTMyerHihn1uwMfLj8vU8sqF7qYrFacT7';
|
|
194
|
+
*
|
|
195
|
+
* // combines values from balance & nonce as it updates
|
|
196
|
+
* api.combineLatest([
|
|
197
|
+
* api.rpc.chain.subscribeNewHeads,
|
|
198
|
+
* (cb) => api.query.system.account(address, cb)
|
|
199
|
+
* ], ([head, [balance, nonce]]) => {
|
|
200
|
+
* console.log(`#${head.number}: You have ${balance.free} units, with ${nonce} transactions sent`);
|
|
201
|
+
* });
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
205
|
+
public async combineLatest <T extends any[] = any[]> (fns: (CombinatorFunction | [CombinatorFunction, ...any[]])[], callback: CombinatorCallback<T>): UnsubscribePromise {
|
|
206
|
+
const combinator = new Combinator(fns, callback);
|
|
207
|
+
|
|
208
|
+
return (): void => {
|
|
209
|
+
combinator.unsubscribe();
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
|
|
2
|
+
import type { Callback } from 'https://deno.land/x/pezkuwi/types/types/index.ts';
|
|
3
|
+
import type { UnsubscribePromise } from '../types/index.ts';
|
|
4
|
+
|
|
5
|
+
import { isFunction, noop } from 'https://deno.land/x/pezkuwi/util/mod.ts';
|
|
6
|
+
|
|
7
|
+
export type CombinatorCallback <T extends unknown[]> = Callback<T>;
|
|
8
|
+
|
|
9
|
+
export type CombinatorFunction = (cb: Callback<any>) => UnsubscribePromise;
|
|
10
|
+
|
|
11
|
+
export class Combinator<T extends unknown[] = unknown[]> {
|
|
12
|
+
#allHasFired = false;
|
|
13
|
+
#callback: CombinatorCallback<T>;
|
|
14
|
+
#fired: boolean[] = [];
|
|
15
|
+
#fns: CombinatorFunction[] = [];
|
|
16
|
+
#isActive = true;
|
|
17
|
+
#results: unknown[] = [];
|
|
18
|
+
#subscriptions: UnsubscribePromise[] = [];
|
|
19
|
+
|
|
20
|
+
constructor (fns: (CombinatorFunction | [CombinatorFunction, ...unknown[]])[], callback: CombinatorCallback<T>) {
|
|
21
|
+
this.#callback = callback;
|
|
22
|
+
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises, @typescript-eslint/require-await
|
|
24
|
+
this.#subscriptions = fns.map(async (input, index): UnsubscribePromise => {
|
|
25
|
+
const [fn, ...args] = Array.isArray(input)
|
|
26
|
+
? input
|
|
27
|
+
: [input];
|
|
28
|
+
|
|
29
|
+
this.#fired.push(false);
|
|
30
|
+
this.#fns.push(fn);
|
|
31
|
+
|
|
32
|
+
// Not quite 100% how to have a variable number at the front here
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return,@typescript-eslint/ban-types
|
|
34
|
+
return (fn as Function)(...args, this._createCallback(index));
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
protected _allHasFired (): boolean {
|
|
39
|
+
this.#allHasFired ||= this.#fired.filter((hasFired): boolean => !hasFired).length === 0;
|
|
40
|
+
|
|
41
|
+
return this.#allHasFired;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
protected _createCallback (index: number): (value: any) => void {
|
|
45
|
+
return (value: unknown): void => {
|
|
46
|
+
this.#fired[index] = true;
|
|
47
|
+
this.#results[index] = value;
|
|
48
|
+
|
|
49
|
+
this._triggerUpdate();
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
protected _triggerUpdate (): void {
|
|
54
|
+
if (!this.#isActive || !isFunction(this.#callback) || !this._allHasFired()) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
Promise
|
|
60
|
+
.resolve(this.#callback(this.#results as T))
|
|
61
|
+
.catch(noop);
|
|
62
|
+
} catch {
|
|
63
|
+
// swallow, we don't want the handler to trip us up
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public unsubscribe (): void {
|
|
68
|
+
if (!this.#isActive) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
this.#isActive = false;
|
|
73
|
+
|
|
74
|
+
Promise
|
|
75
|
+
.all(this.#subscriptions.map(async (subscription): Promise<void> => {
|
|
76
|
+
try {
|
|
77
|
+
const unsubscribe = await subscription;
|
|
78
|
+
|
|
79
|
+
if (isFunction(unsubscribe)) {
|
|
80
|
+
unsubscribe();
|
|
81
|
+
}
|
|
82
|
+
} catch {
|
|
83
|
+
// ignore
|
|
84
|
+
}
|
|
85
|
+
})).catch(() => {
|
|
86
|
+
// ignore, already ignored above, should never throw
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|