@pezkuwi/api 16.5.5 → 16.5.6

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.
Files changed (204) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +12 -12
  3. package/augment.js +1 -0
  4. package/base/Decorate.js +752 -0
  5. package/base/Events.js +78 -0
  6. package/base/Getters.js +207 -0
  7. package/base/Init.js +400 -0
  8. package/base/find.js +7 -0
  9. package/{build/base → base}/index.d.ts +1 -1
  10. package/base/index.js +57 -0
  11. package/bundle-pezkuwi-api.js +26238 -0
  12. package/{src/bundle.ts → bundle.js} +0 -9
  13. package/cjs/augment.d.ts +1 -0
  14. package/cjs/augment.js +3 -0
  15. package/cjs/base/Decorate.d.ts +143 -0
  16. package/cjs/base/Decorate.js +756 -0
  17. package/cjs/base/Events.d.ts +67 -0
  18. package/cjs/base/Events.js +82 -0
  19. package/cjs/base/Getters.d.ts +163 -0
  20. package/cjs/base/Getters.js +211 -0
  21. package/cjs/base/Init.d.ts +44 -0
  22. package/cjs/base/Init.js +404 -0
  23. package/cjs/base/find.d.ts +3 -0
  24. package/cjs/base/find.js +11 -0
  25. package/cjs/base/index.d.ts +47 -0
  26. package/cjs/base/index.js +61 -0
  27. package/{src/base/types.ts → cjs/base/types.d.ts} +8 -12
  28. package/cjs/base/types.js +2 -0
  29. package/cjs/bundle.d.ts +7 -0
  30. package/cjs/bundle.js +17 -0
  31. package/cjs/index.js +5 -0
  32. package/cjs/package.json +3 -0
  33. package/cjs/packageDetect.d.ts +1 -0
  34. package/cjs/packageDetect.js +10 -0
  35. package/cjs/packageInfo.js +4 -0
  36. package/{build → cjs}/promise/Api.d.ts +2 -2
  37. package/cjs/promise/Api.js +195 -0
  38. package/cjs/promise/Combinator.js +72 -0
  39. package/cjs/promise/decorateMethod.js +75 -0
  40. package/cjs/promise/index.js +7 -0
  41. package/cjs/promise/types.js +2 -0
  42. package/{build → cjs}/rx/Api.d.ts +2 -2
  43. package/cjs/rx/Api.js +173 -0
  44. package/cjs/rx/decorateMethod.js +6 -0
  45. package/cjs/rx/index.js +7 -0
  46. package/cjs/submittable/Result.js +84 -0
  47. package/cjs/submittable/createClass.js +277 -0
  48. package/cjs/submittable/createSubmittable.js +8 -0
  49. package/cjs/submittable/index.js +7 -0
  50. package/cjs/submittable/types.js +2 -0
  51. package/cjs/types/calls.js +4 -0
  52. package/cjs/types/consts.js +4 -0
  53. package/cjs/types/errors.js +4 -0
  54. package/cjs/types/events.js +4 -0
  55. package/cjs/types/index.js +13 -0
  56. package/cjs/types/storage.js +4 -0
  57. package/cjs/types/submittable.js +4 -0
  58. package/cjs/util/augmentObject.js +84 -0
  59. package/cjs/util/decorate.js +17 -0
  60. package/cjs/util/filterEvents.js +25 -0
  61. package/cjs/util/index.js +11 -0
  62. package/cjs/util/isKeyringPair.js +7 -0
  63. package/cjs/util/logging.js +5 -0
  64. package/cjs/util/validate.js +26 -0
  65. package/index.d.ts +2 -0
  66. package/index.js +2 -0
  67. package/package.json +588 -22
  68. package/packageDetect.d.ts +1 -0
  69. package/{src/packageDetect.ts → packageDetect.js} +0 -8
  70. package/packageInfo.d.ts +6 -0
  71. package/packageInfo.js +1 -0
  72. package/promise/Api.d.ts +158 -0
  73. package/promise/Api.js +191 -0
  74. package/promise/Combinator.d.ts +12 -0
  75. package/promise/Combinator.js +68 -0
  76. package/promise/decorateMethod.d.ts +14 -0
  77. package/promise/decorateMethod.js +71 -0
  78. package/promise/index.d.ts +2 -0
  79. package/promise/index.js +2 -0
  80. package/{src/promise/types.ts → promise/types.d.ts} +0 -4
  81. package/promise/types.js +1 -0
  82. package/rx/Api.d.ts +155 -0
  83. package/{src/rx/Api.ts → rx/Api.js} +67 -84
  84. package/rx/decorateMethod.d.ts +3 -0
  85. package/rx/decorateMethod.js +3 -0
  86. package/rx/index.d.ts +2 -0
  87. package/rx/index.js +2 -0
  88. package/submittable/Result.d.ts +31 -0
  89. package/submittable/Result.js +80 -0
  90. package/submittable/createClass.d.ts +12 -0
  91. package/submittable/createClass.js +274 -0
  92. package/submittable/createSubmittable.d.ts +8 -0
  93. package/submittable/createSubmittable.js +5 -0
  94. package/{src/submittable/index.ts → submittable/index.d.ts} +0 -3
  95. package/submittable/index.js +2 -0
  96. package/{src/submittable/types.ts → submittable/types.d.ts} +0 -3
  97. package/submittable/types.js +1 -0
  98. package/types/calls.d.ts +1 -0
  99. package/types/calls.js +1 -0
  100. package/types/consts.d.ts +1 -0
  101. package/types/consts.js +1 -0
  102. package/types/errors.d.ts +1 -0
  103. package/types/errors.js +1 -0
  104. package/types/events.d.ts +1 -0
  105. package/types/events.js +1 -0
  106. package/types/index.d.ts +114 -0
  107. package/types/index.js +8 -0
  108. package/types/storage.d.ts +1 -0
  109. package/types/storage.js +1 -0
  110. package/types/submittable.d.ts +1 -0
  111. package/types/submittable.js +1 -0
  112. package/util/augmentObject.d.ts +9 -0
  113. package/util/augmentObject.js +81 -0
  114. package/util/decorate.d.ts +16 -0
  115. package/util/decorate.js +14 -0
  116. package/util/filterEvents.d.ts +6 -0
  117. package/util/filterEvents.js +22 -0
  118. package/{src/util/index.ts → util/index.d.ts} +0 -6
  119. package/util/index.js +4 -0
  120. package/util/isKeyringPair.d.ts +3 -0
  121. package/util/isKeyringPair.js +4 -0
  122. package/util/logging.d.ts +1 -0
  123. package/util/logging.js +2 -0
  124. package/util/validate.d.ts +3 -0
  125. package/util/validate.js +23 -0
  126. package/src/augment.ts +0 -4
  127. package/src/base/Decorate.ts +0 -1103
  128. package/src/base/Events.ts +0 -91
  129. package/src/base/Getters.ts +0 -245
  130. package/src/base/Init.ts +0 -525
  131. package/src/base/find.ts +0 -14
  132. package/src/base/index.ts +0 -85
  133. package/src/checkTypes.manual.ts +0 -323
  134. package/src/index.ts +0 -6
  135. package/src/mod.ts +0 -4
  136. package/src/packageInfo.ts +0 -6
  137. package/src/promise/Api.ts +0 -214
  138. package/src/promise/Combinator.ts +0 -91
  139. package/src/promise/Combinators.spec.ts +0 -109
  140. package/src/promise/decorateMethod.ts +0 -118
  141. package/src/promise/index.spec.ts +0 -167
  142. package/src/promise/index.ts +0 -5
  143. package/src/rx/decorateMethod.ts +0 -9
  144. package/src/rx/index.ts +0 -5
  145. package/src/submittable/Result.ts +0 -111
  146. package/src/submittable/createClass.ts +0 -438
  147. package/src/submittable/createSubmittable.ts +0 -19
  148. package/src/test/SingleAccountSigner.ts +0 -53
  149. package/src/test/index.ts +0 -5
  150. package/src/test/logEvents.ts +0 -24
  151. package/src/types/calls.ts +0 -4
  152. package/src/types/consts.ts +0 -4
  153. package/src/types/errors.ts +0 -4
  154. package/src/types/events.ts +0 -4
  155. package/src/types/index.ts +0 -137
  156. package/src/types/storage.ts +0 -4
  157. package/src/types/submittable.ts +0 -4
  158. package/src/util/augmentObject.spec.ts +0 -54
  159. package/src/util/augmentObject.ts +0 -112
  160. package/src/util/decorate.ts +0 -43
  161. package/src/util/filterEvents.ts +0 -34
  162. package/src/util/isKeyringPair.ts +0 -11
  163. package/src/util/logging.ts +0 -6
  164. package/src/util/validate.spec.ts +0 -72
  165. package/src/util/validate.ts +0 -36
  166. package/tsconfig.build.json +0 -25
  167. package/tsconfig.build.tsbuildinfo +0 -1
  168. package/tsconfig.spec.json +0 -26
  169. /package/{build/augment.d.ts → augment.d.ts} +0 -0
  170. /package/{build/base → base}/Decorate.d.ts +0 -0
  171. /package/{build/base → base}/Events.d.ts +0 -0
  172. /package/{build/base → base}/Getters.d.ts +0 -0
  173. /package/{build/base → base}/Init.d.ts +0 -0
  174. /package/{build/base → base}/find.d.ts +0 -0
  175. /package/{build/base → base}/types.d.ts +0 -0
  176. /package/{build/packageDetect.d.ts → base/types.js} +0 -0
  177. /package/{build/bundle.d.ts → bundle.d.ts} +0 -0
  178. /package/{build → cjs}/index.d.ts +0 -0
  179. /package/{build → cjs}/packageInfo.d.ts +0 -0
  180. /package/{build → cjs}/promise/Combinator.d.ts +0 -0
  181. /package/{build → cjs}/promise/decorateMethod.d.ts +0 -0
  182. /package/{build → cjs}/promise/index.d.ts +0 -0
  183. /package/{build → cjs}/promise/types.d.ts +0 -0
  184. /package/{build → cjs}/rx/decorateMethod.d.ts +0 -0
  185. /package/{build → cjs}/rx/index.d.ts +0 -0
  186. /package/{build → cjs}/submittable/Result.d.ts +0 -0
  187. /package/{build → cjs}/submittable/createClass.d.ts +0 -0
  188. /package/{build → cjs}/submittable/createSubmittable.d.ts +0 -0
  189. /package/{build → cjs}/submittable/index.d.ts +0 -0
  190. /package/{build → cjs}/submittable/types.d.ts +0 -0
  191. /package/{build → cjs}/types/calls.d.ts +0 -0
  192. /package/{build → cjs}/types/consts.d.ts +0 -0
  193. /package/{build → cjs}/types/errors.d.ts +0 -0
  194. /package/{build → cjs}/types/events.d.ts +0 -0
  195. /package/{build → cjs}/types/index.d.ts +0 -0
  196. /package/{build → cjs}/types/storage.d.ts +0 -0
  197. /package/{build → cjs}/types/submittable.d.ts +0 -0
  198. /package/{build → cjs}/util/augmentObject.d.ts +0 -0
  199. /package/{build → cjs}/util/decorate.d.ts +0 -0
  200. /package/{build → cjs}/util/filterEvents.d.ts +0 -0
  201. /package/{build → cjs}/util/index.d.ts +0 -0
  202. /package/{build → cjs}/util/isKeyringPair.d.ts +0 -0
  203. /package/{build → cjs}/util/logging.d.ts +0 -0
  204. /package/{build → cjs}/util/validate.d.ts +0 -0
@@ -0,0 +1,114 @@
1
+ import type { ApiTypes, DeriveCustom, QueryableStorageMulti } from '@pezkuwi/api-base/types';
2
+ import type { ApiInterfaceRx as ApiInterfaceBase } from '@pezkuwi/api-base/types/api';
3
+ import type { QueryableCalls } from '@pezkuwi/api-base/types/calls';
4
+ import type { QueryableConsts } from '@pezkuwi/api-base/types/consts';
5
+ import type { DecoratedErrors } from '@pezkuwi/api-base/types/errors';
6
+ import type { DecoratedEvents } from '@pezkuwi/api-base/types/events';
7
+ import type { QueryableStorage } from '@pezkuwi/api-base/types/storage';
8
+ import type { ProviderInterface, ProviderInterfaceEmitted } from '@pezkuwi/rpc-provider/types';
9
+ import type { ExtDef } from '@pezkuwi/types/extrinsic/signedExtensions/types';
10
+ import type { Call, Extrinsic, Hash, RuntimeVersionPartial } from '@pezkuwi/types/interfaces';
11
+ import type { CallFunction, DefinitionRpc, DefinitionRpcSub, DefinitionsCall, RegisteredTypes, Registry, RegistryError, SignatureOptions, Signer } from '@pezkuwi/types/types';
12
+ import type { BN } from '@pezkuwi/util';
13
+ import type { HexString } from '@pezkuwi/util/types';
14
+ import type { ApiBase } from '../base/index.js';
15
+ import type { SubmittableExtrinsic } from '../types/submittable.js';
16
+ import type { AllDerives } from '../util/decorate.js';
17
+ export type { Signer, SignerResult } from '@pezkuwi/types/types';
18
+ export { ApiBase } from '../base/index.js';
19
+ export * from '@pezkuwi/api/types/calls';
20
+ export * from '@pezkuwi/api/types/consts';
21
+ export * from '@pezkuwi/api/types/errors';
22
+ export * from '@pezkuwi/api/types/events';
23
+ export * from '@pezkuwi/api/types/storage';
24
+ export * from '@pezkuwi/api/types/submittable';
25
+ export * from '@pezkuwi/api-base/types';
26
+ export interface ApiInterfaceRx extends ApiInterfaceBase {
27
+ derive: AllDerives<'rxjs'>;
28
+ }
29
+ export interface ApiOptions extends RegisteredTypes {
30
+ /**
31
+ * @description Add custom derives to be injected
32
+ */
33
+ derives?: DeriveCustom;
34
+ /**
35
+ * @description Control the initialization of the wasm libraries. When not specified, it defaults to `true`, initializing the wasm libraries, set to `false` to not initialize wasm. (No sr25519 support)
36
+ */
37
+ initWasm?: boolean;
38
+ /**
39
+ * @description Controls the checking of storage values once they have been contructed. When not specified this defaults to `true`. Set to `false` to forgo any checking on storage results.
40
+ */
41
+ isPedantic?: boolean;
42
+ /**
43
+ * @description pre-bundles is a map of 'genesis hash and runtime spec version' as key to a metadata hex string
44
+ * if genesis hash and runtime spec version matches, then use metadata, else fetch it from chain
45
+ */
46
+ metadata?: Record<string, HexString>;
47
+ /**
48
+ * @description Don't display any warnings on initialization (missing RPC methods & runtime calls)
49
+ */
50
+ noInitWarn?: boolean;
51
+ /**
52
+ * @description Transport Provider from rpc-provider. If not specified, it will default to
53
+ * connecting to a WsProvider connecting localhost with the default port, i.e. `ws://127.0.0.1:9944`
54
+ */
55
+ provider?: ProviderInterface;
56
+ /**
57
+ * @description A type registry to use along with this instance
58
+ */
59
+ registry?: Registry;
60
+ /**
61
+ * @description User-defined RPC methods
62
+ */
63
+ rpc?: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>;
64
+ /**
65
+ * @description Defines the size of the cache for the rpc-core. Defaults to 1024 * 10 * 10.
66
+ */
67
+ rpcCacheCapacity?: number;
68
+ /**
69
+ * @description Overrides for state_call usage (this will be removed in some future version)
70
+ */
71
+ runtime?: DefinitionsCall;
72
+ /**
73
+ * @description Any chain-specific signed extensions that are now well-known
74
+ */
75
+ signedExtensions?: ExtDef;
76
+ /**
77
+ * @description An external signer which will be used to sign extrinsic when account passed in is not KeyringPair
78
+ */
79
+ signer?: Signer;
80
+ /**
81
+ * @description The source object to use for runtime information (only used when cloning)
82
+ */
83
+ source?: ApiBase<any>;
84
+ /**
85
+ * @description Throws an error when the initial connection fails (same as isReadyOrError)
86
+ */
87
+ throwOnConnect?: boolean;
88
+ /**
89
+ * @description Throws an error when some types are unknown (useful with throwOnConnect)
90
+ */
91
+ throwOnUnknown?: boolean;
92
+ }
93
+ export type ApiInterfaceEvents = ProviderInterfaceEmitted | 'ready' | 'decorated';
94
+ export interface SignerOptions extends SignatureOptions {
95
+ blockNumber: BN;
96
+ genesisHash: Hash;
97
+ }
98
+ export interface ApiDecoration<ApiType extends ApiTypes> {
99
+ call: QueryableCalls<ApiType>;
100
+ consts: QueryableConsts<ApiType>;
101
+ errors: DecoratedErrors<ApiType>;
102
+ events: DecoratedEvents<ApiType>;
103
+ query: QueryableStorage<ApiType>;
104
+ registry: Registry;
105
+ runtimeVersion: RuntimeVersionPartial;
106
+ rx: {
107
+ call: QueryableCalls<'rxjs'>;
108
+ query: QueryableStorage<'rxjs'>;
109
+ };
110
+ tx: (extrinsic: Call | Extrinsic | Uint8Array | string) => SubmittableExtrinsic<ApiType>;
111
+ findCall(callIndex: Uint8Array | string): CallFunction;
112
+ findError(errorIndex: Uint8Array | string): RegistryError;
113
+ queryMulti: QueryableStorageMulti<ApiType>;
114
+ }
package/types/index.js ADDED
@@ -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/storage';
@@ -0,0 +1 @@
1
+ export * from '@pezkuwi/api-base/types/submittable';
@@ -0,0 +1 @@
1
+ export * from '@pezkuwi/api-base/types/submittable';
@@ -0,0 +1,9 @@
1
+ type Sections<T> = Record<string, Methods<T>>;
2
+ type Methods<T> = Record<string, T>;
3
+ /**
4
+ * @description Takes a decorated api section (e.g. api.tx) and augment it with the details. It does not override what is
5
+ * already available, but rather just adds new missing items into the result object.
6
+ * @internal
7
+ */
8
+ export declare function augmentObject<T>(prefix: string | null, src: Sections<T>, dst: Sections<T>, fromEmpty?: boolean): Sections<T>;
9
+ export {};
@@ -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,16 @@
1
+ import type { ExactDerive } from '@pezkuwi/api-derive';
2
+ import type { AnyFunction } from '@pezkuwi/types/types';
3
+ import type { ApiTypes, DecorateMethod, MethodResult } from '../types/index.js';
4
+ type AnyDeriveSection = Record<string, AnyFunction>;
5
+ type AnyDerive = Record<string, AnyDeriveSection>;
6
+ type DeriveSection<ApiType extends ApiTypes, Section extends AnyDeriveSection> = {
7
+ [M in keyof Section]: MethodResult<ApiType, Section[M]>;
8
+ };
9
+ export type AllDerives<ApiType extends ApiTypes> = {
10
+ [S in keyof ExactDerive]: DeriveSection<ApiType, ExactDerive[S]>;
11
+ };
12
+ /**
13
+ * This is a section decorator which keeps all type information.
14
+ */
15
+ export declare function decorateDeriveSections<ApiType extends ApiTypes>(decorateMethod: DecorateMethod<ApiType>, derives: AnyDerive): AllDerives<ApiType>;
16
+ export {};
@@ -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,6 @@
1
+ import type { BlockNumber, EventRecord, ExtrinsicStatus, H256, SignedBlock } from '@pezkuwi/types/interfaces';
2
+ export declare function filterEvents(txHash: H256, { block: { extrinsics, header } }: SignedBlock, allEvents: EventRecord[], status: ExtrinsicStatus): {
3
+ events?: EventRecord[];
4
+ txIndex?: number;
5
+ blockNumber?: BlockNumber;
6
+ };
@@ -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
+ }
@@ -1,10 +1,4 @@
1
- // Copyright 2017-2025 @polkadot/api authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- // all named
5
1
  export { filterEvents } from './filterEvents.js';
6
2
  export { isKeyringPair } from './isKeyringPair.js';
7
3
  export { l } from './logging.js';
8
-
9
- // all starred
10
4
  export * from './decorate.js';
package/util/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { filterEvents } from './filterEvents.js';
2
+ export { isKeyringPair } from './isKeyringPair.js';
3
+ export { l } from './logging.js';
4
+ export * from './decorate.js';
@@ -0,0 +1,3 @@
1
+ import type { AccountId, Address } from '@pezkuwi/types/interfaces';
2
+ import type { IKeyringPair } from '@pezkuwi/types/types';
3
+ export declare function isKeyringPair(account: string | IKeyringPair | AccountId | Address): account is IKeyringPair;
@@ -0,0 +1,4 @@
1
+ import { isFunction } from '@pezkuwi/util';
2
+ export function isKeyringPair(account) {
3
+ return isFunction(account.sign);
4
+ }
@@ -0,0 +1 @@
1
+ export declare const l: import("@pezkuwi/util/types").Logger;
@@ -0,0 +1,2 @@
1
+ import { logger } from '@pezkuwi/util';
2
+ export const l = /*#__PURE__*/ logger('api/util');
@@ -0,0 +1,3 @@
1
+ import type { StorageEntry } from '@pezkuwi/types/primitive/types';
2
+ import type { Registry } from '@pezkuwi/types/types';
3
+ export declare function extractStorageArgs(registry: Registry, creator: StorageEntry, _args: unknown[]): [StorageEntry, unknown[]];
@@ -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
+ }
package/src/augment.ts DELETED
@@ -1,4 +0,0 @@
1
- // Copyright 2017-2025 @polkadot/api authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- import '@pezkuwi/api-augment';