@pezkuwi/api-base 16.5.16 → 16.5.18

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 (145) hide show
  1. package/build/LICENSE +201 -0
  2. package/build/README.md +3 -0
  3. package/build/bundle.js +1 -0
  4. package/build/cjs/bundle.d.ts +1 -0
  5. package/build/cjs/bundle.js +5 -0
  6. package/build/cjs/index.js +5 -0
  7. package/build/cjs/packageInfo.js +4 -0
  8. package/build/cjs/types/api.js +2 -0
  9. package/build/cjs/types/base.js +2 -0
  10. package/build/cjs/types/calls.js +2 -0
  11. package/build/cjs/types/consts.js +2 -0
  12. package/build/cjs/types/derive.js +2 -0
  13. package/build/cjs/types/errors.js +2 -0
  14. package/build/cjs/types/events.js +2 -0
  15. package/build/cjs/types/index.js +13 -0
  16. package/build/cjs/types/rpc.js +2 -0
  17. package/build/cjs/types/storage.js +2 -0
  18. package/build/cjs/types/submittable.js +2 -0
  19. package/build/index.d.ts +2 -0
  20. package/build/index.js +2 -0
  21. package/build/package.json +264 -0
  22. package/build/packageDetect.d.ts +1 -0
  23. package/build/packageDetect.js +5 -0
  24. package/build/packageInfo.d.ts +6 -0
  25. package/build/packageInfo.js +1 -0
  26. package/build/types/api.d.ts +23 -0
  27. package/build/types/api.js +1 -0
  28. package/build/types/base.d.ts +36 -0
  29. package/build/types/base.js +1 -0
  30. package/build/types/calls.d.ts +14 -0
  31. package/build/types/calls.js +1 -0
  32. package/build/types/consts.d.ts +12 -0
  33. package/build/types/consts.js +1 -0
  34. package/build/types/derive.d.ts +4 -0
  35. package/build/types/derive.js +1 -0
  36. package/build/types/errors.d.ts +9 -0
  37. package/build/types/errors.js +1 -0
  38. package/build/types/events.d.ts +10 -0
  39. package/build/types/events.js +1 -0
  40. package/build/types/index.d.ts +10 -0
  41. package/build/types/index.js +10 -0
  42. package/build/types/rpc.d.ts +21 -0
  43. package/build/types/rpc.js +1 -0
  44. package/build/types/storage.d.ts +81 -0
  45. package/build/types/storage.js +1 -0
  46. package/build/types/submittable.d.ts +72 -0
  47. package/build/types/submittable.js +1 -0
  48. package/build-deno/README.md +3 -0
  49. package/build-deno/bundle.ts +2 -0
  50. package/build-deno/index.ts +4 -0
  51. package/build-deno/mod.ts +2 -0
  52. package/build-deno/packageDetect.ts +9 -0
  53. package/build-deno/packageInfo.ts +3 -0
  54. package/build-deno/types/api.ts +26 -0
  55. package/build-deno/types/base.ts +65 -0
  56. package/build-deno/types/calls.ts +26 -0
  57. package/build-deno/types/consts.ts +20 -0
  58. package/build-deno/types/derive.ts +6 -0
  59. package/build-deno/types/errors.ts +17 -0
  60. package/build-deno/types/events.ts +18 -0
  61. package/build-deno/types/index.ts +12 -0
  62. package/build-deno/types/rpc.ts +33 -0
  63. package/build-deno/types/storage.ts +115 -0
  64. package/build-deno/types/submittable.ts +110 -0
  65. package/build-tsc-cjs/packageDetect.js +7 -0
  66. package/{cjs → build-tsc-cjs}/packageInfo.js +1 -1
  67. package/{packageInfo.js → build-tsc-esm/packageInfo.js} +1 -1
  68. package/package.json +11 -11
  69. package/src/bundle.ts +4 -0
  70. package/src/index.ts +6 -0
  71. package/src/mod.ts +4 -0
  72. package/src/packageDetect.ts +13 -0
  73. package/src/packageInfo.ts +6 -0
  74. package/src/types/api.ts +29 -0
  75. package/src/types/base.ts +78 -0
  76. package/src/types/calls.ts +31 -0
  77. package/src/types/consts.ts +25 -0
  78. package/src/types/derive.ts +8 -0
  79. package/src/types/errors.ts +22 -0
  80. package/src/types/events.ts +23 -0
  81. package/src/types/index.ts +16 -0
  82. package/src/types/rpc.ts +35 -0
  83. package/src/types/storage.ts +123 -0
  84. package/src/types/submittable.ts +114 -0
  85. package/tsconfig.build.json +15 -0
  86. package/tsconfig.build.tsbuildinfo +1 -0
  87. /package/{cjs → build}/bundle.d.ts +0 -0
  88. /package/{index.d.ts → build/cjs/index.d.ts} +0 -0
  89. /package/{cjs → build/cjs}/package.json +0 -0
  90. /package/{packageDetect.d.ts → build/cjs/packageDetect.d.ts} +0 -0
  91. /package/{cjs → build/cjs}/packageDetect.js +0 -0
  92. /package/{packageInfo.d.ts → build/cjs/packageInfo.d.ts} +0 -0
  93. /package/{types → build/cjs/types}/api.d.ts +0 -0
  94. /package/{types → build/cjs/types}/base.d.ts +0 -0
  95. /package/{types → build/cjs/types}/calls.d.ts +0 -0
  96. /package/{types → build/cjs/types}/consts.d.ts +0 -0
  97. /package/{types → build/cjs/types}/derive.d.ts +0 -0
  98. /package/{types → build/cjs/types}/errors.d.ts +0 -0
  99. /package/{types → build/cjs/types}/events.d.ts +0 -0
  100. /package/{types → build/cjs/types}/index.d.ts +0 -0
  101. /package/{types → build/cjs/types}/rpc.d.ts +0 -0
  102. /package/{types → build/cjs/types}/storage.d.ts +0 -0
  103. /package/{types → build/cjs/types}/submittable.d.ts +0 -0
  104. /package/{bundle.d.ts → build-tsc/bundle.d.ts} +0 -0
  105. /package/{cjs → build-tsc}/index.d.ts +0 -0
  106. /package/{cjs → build-tsc}/packageDetect.d.ts +0 -0
  107. /package/{cjs → build-tsc}/packageInfo.d.ts +0 -0
  108. /package/{cjs → build-tsc}/types/api.d.ts +0 -0
  109. /package/{cjs → build-tsc}/types/base.d.ts +0 -0
  110. /package/{cjs → build-tsc}/types/calls.d.ts +0 -0
  111. /package/{cjs → build-tsc}/types/consts.d.ts +0 -0
  112. /package/{cjs → build-tsc}/types/derive.d.ts +0 -0
  113. /package/{cjs → build-tsc}/types/errors.d.ts +0 -0
  114. /package/{cjs → build-tsc}/types/events.d.ts +0 -0
  115. /package/{cjs → build-tsc}/types/index.d.ts +0 -0
  116. /package/{cjs → build-tsc}/types/rpc.d.ts +0 -0
  117. /package/{cjs → build-tsc}/types/storage.d.ts +0 -0
  118. /package/{cjs → build-tsc}/types/submittable.d.ts +0 -0
  119. /package/{cjs → build-tsc-cjs}/bundle.js +0 -0
  120. /package/{cjs → build-tsc-cjs}/index.js +0 -0
  121. /package/{cjs → build-tsc-cjs}/types/api.js +0 -0
  122. /package/{cjs → build-tsc-cjs}/types/base.js +0 -0
  123. /package/{cjs → build-tsc-cjs}/types/calls.js +0 -0
  124. /package/{cjs → build-tsc-cjs}/types/consts.js +0 -0
  125. /package/{cjs → build-tsc-cjs}/types/derive.js +0 -0
  126. /package/{cjs → build-tsc-cjs}/types/errors.js +0 -0
  127. /package/{cjs → build-tsc-cjs}/types/events.js +0 -0
  128. /package/{cjs → build-tsc-cjs}/types/index.js +0 -0
  129. /package/{cjs → build-tsc-cjs}/types/rpc.js +0 -0
  130. /package/{cjs → build-tsc-cjs}/types/storage.js +0 -0
  131. /package/{cjs → build-tsc-cjs}/types/submittable.js +0 -0
  132. /package/{bundle.js → build-tsc-esm/bundle.js} +0 -0
  133. /package/{index.js → build-tsc-esm/index.js} +0 -0
  134. /package/{packageDetect.js → build-tsc-esm/packageDetect.js} +0 -0
  135. /package/{types → build-tsc-esm/types}/api.js +0 -0
  136. /package/{types → build-tsc-esm/types}/base.js +0 -0
  137. /package/{types → build-tsc-esm/types}/calls.js +0 -0
  138. /package/{types → build-tsc-esm/types}/consts.js +0 -0
  139. /package/{types → build-tsc-esm/types}/derive.js +0 -0
  140. /package/{types → build-tsc-esm/types}/errors.js +0 -0
  141. /package/{types → build-tsc-esm/types}/events.js +0 -0
  142. /package/{types → build-tsc-esm/types}/index.js +0 -0
  143. /package/{types → build-tsc-esm/types}/rpc.js +0 -0
  144. /package/{types → build-tsc-esm/types}/storage.js +0 -0
  145. /package/{types → build-tsc-esm/types}/submittable.js +0 -0
@@ -0,0 +1,115 @@
1
+
2
+ import type { Observable } from 'https://esm.sh/rxjs@7.8.1';
3
+ import type { StorageKey, u64 } from 'https://deno.land/x/pezkuwi/types/mod.ts';
4
+ import type { Hash } from 'https://deno.land/x/pezkuwi/types/interfaces/index.ts';
5
+ import type { StorageEntry } from 'https://deno.land/x/pezkuwi/types/primitive/types.ts';
6
+ import type { AnyFunction, AnyTuple, Callback, Codec, IStorageKey } from 'https://deno.land/x/pezkuwi/types/types/index.ts';
7
+ import type { ApiTypes, DropLast, EmptyBase, MethodResult, PaginationOptions, PromiseOrObs, ReturnCodec, UnsubscribePromise } from './base.ts';
8
+
9
+ type StorageEntryObservableMulti<R extends Codec = Codec> = <T extends Codec = R>(args: unknown[]) => Observable<T[]>;
10
+
11
+ interface StorageEntryPromiseMulti<R extends Codec = Codec> {
12
+ <T extends Codec = R>(args: unknown[]): Promise<T[]>;
13
+ <T extends Codec = R>(args: unknown[], callback: Callback<T[]>): UnsubscribePromise;
14
+ }
15
+
16
+ export interface StorageEntryPromiseOverloads {
17
+ (arg1?: unknown, arg2?: unknown, arg3?: unknown): Promise<Codec>;
18
+ <T extends Codec>(arg1?: unknown, arg2?: unknown, arg3?: unknown): Promise<T>;
19
+ <T extends Codec>(callback: Callback<T>): UnsubscribePromise;
20
+ <T extends Codec>(arg: unknown, callback: Callback<T>): UnsubscribePromise;
21
+ <T extends Codec>(arg1: unknown, arg2: unknown, callback: Callback<T>): UnsubscribePromise;
22
+ <T extends Codec>(arg1: unknown, arg2: unknown, arg3: unknown, callback: Callback<T>): UnsubscribePromise;
23
+ }
24
+
25
+ export interface StorageEntryPromiseOverloadsAt {
26
+ (arg1?: unknown, arg2?: unknown, arg3?: unknown): Promise<Codec>;
27
+ <T extends Codec>(arg1?: unknown, arg2?: unknown, arg3?: unknown): Promise<T>;
28
+ }
29
+
30
+ export type GenericStorageEntryFunction = (...args: unknown[]) => Observable<Codec>
31
+
32
+ export type QueryableStorageEntry<ApiType extends ApiTypes, A extends AnyTuple = AnyTuple> =
33
+ ApiType extends 'rxjs'
34
+ ? AugmentedQuery<'rxjs', GenericStorageEntryFunction, A>
35
+ : AugmentedQuery<'promise', GenericStorageEntryFunction, A> & StorageEntryPromiseOverloads;
36
+
37
+ export type QueryableStorageEntryAt<ApiType extends ApiTypes, A extends AnyTuple = AnyTuple> =
38
+ ApiType extends 'rxjs'
39
+ ? AugmentedQueryAt<'rxjs', GenericStorageEntryFunction, A>
40
+ : AugmentedQueryAt<'promise', GenericStorageEntryFunction, A> & StorageEntryPromiseOverloadsAt;
41
+
42
+ export interface StorageEntryBase<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> extends StorageEntryBaseAt<ApiType, F, A> {
43
+ /**
44
+ * @deprecated Use api.at(<blockHash>)
45
+ */
46
+ at: <T = ReturnCodec<F>>(hash: Hash | Uint8Array | string, ...args: Parameters<F>) => PromiseOrObs<ApiType, T>;
47
+ creator: StorageEntry;
48
+ /**
49
+ * @deprecated Use api.at(<blockHash>)
50
+ */
51
+ entriesAt: <T = ReturnCodec<F>, K extends AnyTuple = A>(hash: Hash | Uint8Array | string, ...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
52
+ /**
53
+ * @deprecated Use api.at(<blockHash>)
54
+ */
55
+ keysAt: <K extends AnyTuple = A> (hash: Hash | Uint8Array | string, ...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, StorageKey<K>[]>;
56
+ /**
57
+ * @deprecated Use api.at(<blockHash>)
58
+ */
59
+ sizeAt: (hash: Hash | Uint8Array | string, ...args: Parameters<F>) => PromiseOrObs<ApiType, u64>;
60
+ multi: ApiType extends 'rxjs'
61
+ ? StorageEntryObservableMulti<ReturnCodec<F>>
62
+ : StorageEntryPromiseMulti<ReturnCodec<F>>;
63
+ }
64
+
65
+ export interface StorageEntryBaseAt<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> {
66
+ entries: <T = ReturnCodec<F>, K extends AnyTuple = A>(...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
67
+ entriesPaged: <T = ReturnCodec<F>, K extends AnyTuple = A>(opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
68
+ hash: (...args: Parameters<F>) => PromiseOrObs<ApiType, Hash>;
69
+ is: (key: IStorageKey<AnyTuple>) => key is IStorageKey<A>;
70
+ key: (...args: Parameters<F>) => string;
71
+ keyPrefix: (...args: DropLast<Parameters<F>>) => string;
72
+ keys: <K extends AnyTuple = A> (...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, StorageKey<K>[]>;
73
+ keysPaged: <K extends AnyTuple = A> (opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, StorageKey<K>[]>;
74
+ size: (...args: Parameters<F>) => PromiseOrObs<ApiType, u64>;
75
+ }
76
+
77
+ export type QueryableModuleStorage<ApiType extends ApiTypes> = Record<string, QueryableStorageEntry<ApiType, AnyTuple>>;
78
+
79
+ export type QueryableModuleStorageAt<ApiType extends ApiTypes> = Record<string, QueryableStorageEntryAt<ApiType, AnyTuple>>;
80
+
81
+ export type QueryableStorageMultiArg<ApiType extends ApiTypes> =
82
+ QueryableStorageEntry<ApiType> |
83
+ [QueryableStorageEntry<ApiType>, ...unknown[]];
84
+
85
+ export type QueryableStorageMultiBase<ApiType extends ApiTypes> = <T extends Codec[]>(calls: QueryableStorageMultiArg<ApiType>[]) => Observable<T>;
86
+
87
+ export interface QueryableStorageMultiPromise<ApiType extends ApiTypes> {
88
+ <T extends Codec[]>(calls: QueryableStorageMultiArg<ApiType>[], callback: Callback<T>): UnsubscribePromise;
89
+ <T extends Codec[]>(calls: QueryableStorageMultiArg<ApiType>[]): Promise<T>;
90
+ }
91
+
92
+ export type QueryableStorageMulti<ApiType extends ApiTypes> =
93
+ ApiType extends 'rxjs'
94
+ ? QueryableStorageMultiBase<ApiType>
95
+ : QueryableStorageMultiPromise<ApiType>;
96
+
97
+ export type AugmentedQuery<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> = MethodResult<ApiType, F> & StorageEntryBase<ApiType, F, A>;
98
+
99
+ export type AugmentedQueryAt<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> = MethodResult<ApiType, F> & StorageEntryBaseAt<ApiType, F, A>;
100
+
101
+ export type AugmentedQueryDoubleMap<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> = AugmentedQuery<ApiType, F, A>;
102
+
103
+
104
+ export interface AugmentedQueries<ApiType extends ApiTypes> extends EmptyBase<ApiType> {
105
+ // augmented
106
+ }
107
+
108
+ export interface QueryableStorage<ApiType extends ApiTypes> extends AugmentedQueries<ApiType> {
109
+ // when non-augmented, we need to at least have Codec results
110
+ [key: string]: QueryableModuleStorage<ApiType>;
111
+ }
112
+
113
+ export interface QueryableStorageAt<ApiType extends ApiTypes> extends AugmentedQueries<ApiType> {
114
+ [key: string]: QueryableModuleStorageAt<ApiType>;
115
+ }
@@ -0,0 +1,110 @@
1
+
2
+ import type { Observable } from 'https://esm.sh/rxjs@7.8.1';
3
+ import type { AccountId, Address, ApplyExtrinsicResult, BlockNumber, Call, DispatchError, DispatchInfo, EventRecord, Extrinsic, ExtrinsicStatus, Hash, RuntimeDispatchInfo } from 'https://deno.land/x/pezkuwi/types/interfaces/index.ts';
4
+ import type { AnyFunction, AnyNumber, AnyTuple, AnyU8a, Callback, CallBase, Codec, IExtrinsicEra, IKeyringPair, ISubmittableResult, Signer } from 'https://deno.land/x/pezkuwi/types/types/index.ts';
5
+ import type { ApiTypes, EmptyBase, PromiseOrObs } from './base.ts';
6
+
7
+ export type AugmentedSubmittable<T extends AnyFunction, A extends AnyTuple = AnyTuple> = T & CallBase<A>;
8
+
9
+ export type AddressOrPair = IKeyringPair | string | AccountId | Address;
10
+
11
+ export interface SignerOptions {
12
+ blockHash: Uint8Array | string;
13
+ era?: IExtrinsicEra | number;
14
+ nonce: AnyNumber | Codec;
15
+ signer?: Signer;
16
+ tip?: AnyNumber;
17
+ assetId?: AnyNumber | object;
18
+ mode?: AnyNumber;
19
+ metadataHash?: AnyU8a;
20
+ withSignedTransaction?: boolean;
21
+ }
22
+
23
+ export type SubmittableDryRunResult<ApiType extends ApiTypes> =
24
+ ApiType extends 'rxjs'
25
+ ? Observable<ApplyExtrinsicResult>
26
+ : Promise<ApplyExtrinsicResult>;
27
+
28
+ export type SubmittableResultResult<ApiType extends ApiTypes, R extends ISubmittableResult = ISubmittableResult> =
29
+ ApiType extends 'rxjs'
30
+ ? Observable<R>
31
+ : Promise<Hash>;
32
+
33
+ export type SubmittableResultSubscription<ApiType extends ApiTypes, R extends ISubmittableResult = ISubmittableResult> =
34
+ ApiType extends 'rxjs'
35
+ ? Observable<R>
36
+ : Promise<() => void>;
37
+
38
+ export type SubmittablePaymentResult<ApiType extends ApiTypes> =
39
+ ApiType extends 'rxjs'
40
+ ? Observable<RuntimeDispatchInfo>
41
+ : Promise<RuntimeDispatchInfo>;
42
+
43
+ export interface SubmittableResultValue {
44
+ dispatchError?: DispatchError | undefined;
45
+ dispatchInfo?: DispatchInfo | undefined;
46
+ events?: EventRecord[];
47
+ internalError?: Error | undefined;
48
+ status: ExtrinsicStatus;
49
+ txHash: Hash;
50
+ txIndex?: number | undefined;
51
+ blockNumber?: BlockNumber;
52
+ }
53
+
54
+ export interface SubmittableExtrinsic<ApiType extends ApiTypes, R extends ISubmittableResult = ISubmittableResult> extends Extrinsic {
55
+ /** true if api.rpc.system.dryRun is available, enabling dryRun(...) */
56
+ hasDryRun: boolean;
57
+ /** true if api.call.transactionPaymentApi.queryInfo is available, enabling paymentInfo(...) */
58
+ hasPaymentInfo: boolean;
59
+
60
+ dryRun (account: AddressOrPair, options?: Partial<SignerOptions>): SubmittableDryRunResult<ApiType>;
61
+
62
+ paymentInfo (account: AddressOrPair, options?: Partial<SignerOptions>): SubmittablePaymentResult<ApiType>;
63
+
64
+ send (): SubmittableResultResult<ApiType>;
65
+
66
+ send (statusCb: Callback<R>): SubmittableResultSubscription<ApiType, R>;
67
+
68
+ /**
69
+ * @description Sign the constructed transaction asynchronously.
70
+ *
71
+ * The result is a signed extrinsic that is ready to be broadcast to the network via `.send()`, `rpc.author.submitExtrinsic()`, or
72
+ * any custom submission logic.
73
+ */
74
+ signAsync (account: AddressOrPair, _options?: Partial<SignerOptions>): PromiseOrObs<ApiType, this>;
75
+
76
+ /**
77
+ * @description Sign and broadcast the constructued transaction.
78
+ *
79
+ * Note for injected signers:
80
+ * As of v12.0.1 and up the `SignerResult` return type for `signPayload` allows for the `signedTransaction` field.
81
+ * This allows the signer to input a signed transaction that will be directly broadcasted. This
82
+ * bypasses the api adding the signature to the payload. The api will ensure that the Call Data is not changed before it broadcasts the
83
+ * transaction. This allows for the signer to modify the payload to add things like `mode`, and `metadataHash` for
84
+ * signedExtensions such as `CheckMetadataHash`.
85
+ */
86
+ signAndSend (account: AddressOrPair, options?: Partial<SignerOptions>): SubmittableResultResult<ApiType, R>;
87
+
88
+ signAndSend (account: AddressOrPair, statusCb: Callback<R>): SubmittableResultSubscription<ApiType>;
89
+
90
+ signAndSend (account: AddressOrPair, options: Partial<SignerOptions>, statusCb?: Callback<R>): SubmittableResultSubscription<ApiType, R>;
91
+
92
+ withResultTransform (transform: (input: ISubmittableResult) => ISubmittableResult): this;
93
+ }
94
+
95
+ export interface SubmittableExtrinsicFunction<ApiType extends ApiTypes, A extends AnyTuple = AnyTuple> extends CallBase<A> {
96
+ (...params: any[]): SubmittableExtrinsic<ApiType>;
97
+ }
98
+
99
+
100
+ export interface AugmentedSubmittables<ApiType extends ApiTypes> extends EmptyBase<ApiType> {
101
+ // augmented
102
+ }
103
+
104
+ export interface SubmittableExtrinsics<ApiType extends ApiTypes> extends AugmentedSubmittables<ApiType> {
105
+ (extrinsic: Call | Extrinsic | Uint8Array | string): SubmittableExtrinsic<ApiType>;
106
+ // when non-augmented, we need to at least have Codec results
107
+ [key: string]: SubmittableModuleExtrinsics<ApiType>;
108
+ }
109
+
110
+ export type SubmittableModuleExtrinsics<ApiType extends ApiTypes> = Record<string, SubmittableExtrinsicFunction<ApiType>>;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const packageInfo_1 = require("@pezkuwi/rpc-core/packageInfo");
4
+ const packageInfo_2 = require("@pezkuwi/types/packageInfo");
5
+ const util_1 = require("@pezkuwi/util");
6
+ const packageInfo_js_1 = require("./packageInfo.js");
7
+ (0, util_1.detectPackage)(packageInfo_js_1.packageInfo, null, [packageInfo_1.packageInfo, packageInfo_2.packageInfo]);
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.packageInfo = void 0;
4
- exports.packageInfo = { name: '@pezkuwi/api-base', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '16.5.16' };
4
+ exports.packageInfo = { name: '@pezkuwi/api-base', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '16.5.18' };
@@ -1 +1 @@
1
- export const packageInfo = { name: '@pezkuwi/api-base', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '16.5.16' };
1
+ export const packageInfo = { name: '@pezkuwi/api-base', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '16.5.18' };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "author": "Dijital Kurdistan Tech Institute <dev@pezkuwichain.io>",
2
+ "author": "Jaco Greeff <jacogr@gmail.com>",
3
3
  "bugs": "https://github.com/pezkuwichain/pezkuwi-api/issues",
4
4
  "description": "Interfaces for interacting with contracts and contract ABIs",
5
5
  "engines": {
@@ -18,13 +18,11 @@
18
18
  "./cjs/packageDetect.js"
19
19
  ],
20
20
  "type": "module",
21
- "version": "16.5.16",
21
+ "types": "./index.d.ts",
22
+ "version": "16.5.18",
22
23
  "main": "./cjs/index.js",
23
- "module": "./cjs/index.js",
24
- "types": "./cjs/index.d.ts",
24
+ "module": "./index.js",
25
25
  "exports": {
26
- "./cjs/package.json": "./cjs/package.json",
27
- "./cjs/*": "./cjs/*.js",
28
26
  ".": {
29
27
  "module": {
30
28
  "types": "./index.d.ts",
@@ -53,6 +51,8 @@
53
51
  "default": "./bundle.js"
54
52
  }
55
53
  },
54
+ "./cjs/*": "./cjs/*.js",
55
+ "./cjs/package.json": "./cjs/package.json",
56
56
  "./package.json": {
57
57
  "require": "./cjs/package.json",
58
58
  "default": "./package.json"
@@ -71,7 +71,7 @@
71
71
  "default": "./packageDetect.js"
72
72
  }
73
73
  },
74
- "./packageInfo.js": {
74
+ "./packageInfo": {
75
75
  "module": {
76
76
  "types": "./packageInfo.d.ts",
77
77
  "default": "./packageInfo.js"
@@ -85,7 +85,7 @@
85
85
  "default": "./packageInfo.js"
86
86
  }
87
87
  },
88
- "./packageInfo": {
88
+ "./packageInfo.js": {
89
89
  "module": {
90
90
  "types": "./packageInfo.d.ts",
91
91
  "default": "./packageInfo.js"
@@ -255,9 +255,9 @@
255
255
  }
256
256
  },
257
257
  "dependencies": {
258
- "@pezkuwi/rpc-core": "16.5.15",
259
- "@pezkuwi/types": "16.5.15",
260
- "@pezkuwi/util": "14.0.12",
258
+ "@pezkuwi/rpc-core": "16.5.9",
259
+ "@pezkuwi/types": "16.5.9",
260
+ "@pezkuwi/util": "14.0.11",
261
261
  "rxjs": "^7.8.1",
262
262
  "tslib": "^2.8.1"
263
263
  }
package/src/bundle.ts ADDED
@@ -0,0 +1,4 @@
1
+ // Copyright 2017-2025 @pezkuwi/api-base authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export { packageInfo } from './packageInfo.js';
package/src/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ // Copyright 2017-2025 @pezkuwi/api-base authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import './packageDetect.js';
5
+
6
+ export * from './bundle.js';
package/src/mod.ts ADDED
@@ -0,0 +1,4 @@
1
+ // Copyright 2017-2025 @pezkuwi/api-base authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './index.js';
@@ -0,0 +1,13 @@
1
+ // Copyright 2017-2026 @pezkuwi/api-base authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // Do not edit, auto-generated by @pezkuwi/dev
5
+ // (packageInfo imports will be kept as-is, user-editable)
6
+
7
+ import { packageInfo as rpcInfo } from '@pezkuwi/rpc-core/packageInfo';
8
+ import { packageInfo as typesInfo } from '@pezkuwi/types/packageInfo';
9
+ import { detectPackage } from '@pezkuwi/util';
10
+
11
+ import { packageInfo } from './packageInfo.js';
12
+
13
+ detectPackage(packageInfo, null, [rpcInfo, typesInfo]);
@@ -0,0 +1,6 @@
1
+ // Copyright 2017-2026 @pezkuwi/api-base authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // Do not edit, auto-generated by @pezkuwi/dev
5
+
6
+ export const packageInfo = { name: '@pezkuwi/api-base', path: 'auto', type: 'auto', version: '16.5.18' };
@@ -0,0 +1,29 @@
1
+ // Copyright 2017-2025 @pezkuwi/api-base authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Observable } from 'rxjs';
5
+ import type { DecoratedRpc, QueryableCalls, QueryableConsts, QueryableStorage, QueryableStorageMulti, SubmittableExtrinsics } from '@pezkuwi/api-base/types';
6
+ import type { RpcInterface } from '@pezkuwi/rpc-core/types';
7
+ import type { Metadata } from '@pezkuwi/types';
8
+ import type { Hash, RuntimeVersion } from '@pezkuwi/types/interfaces';
9
+ import type { Registry, Signer } from '@pezkuwi/types/types';
10
+
11
+ // A smaller interface of ApiRx, used in derive and in SubmittableExtrinsic
12
+ export interface ApiInterfaceRx {
13
+ call: QueryableCalls<'rxjs'>;
14
+ consts: QueryableConsts<'rxjs'>;
15
+ extrinsicType: number;
16
+ genesisHash?: Hash | undefined;
17
+ hasSubscriptions: boolean;
18
+ registry: Registry;
19
+ runtimeMetadata: Metadata;
20
+ runtimeVersion: RuntimeVersion;
21
+ query: QueryableStorage<'rxjs'>;
22
+ queryMulti: QueryableStorageMulti<'rxjs'>;
23
+ rpc: DecoratedRpc<'rxjs', RpcInterface>;
24
+ tx: SubmittableExtrinsics<'rxjs'>;
25
+ signer?: Signer | undefined;
26
+
27
+ callAt: (blockHash: Uint8Array | string, knownVersion?: RuntimeVersion) => Observable<QueryableCalls<'rxjs'>>;
28
+ queryAt: (blockHash: Uint8Array | string, knownVersion?: RuntimeVersion) => Observable<QueryableStorage<'rxjs'>>;
29
+ }
@@ -0,0 +1,78 @@
1
+ // Copyright 2017-2025 @pezkuwi/api-base authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Observable } from 'rxjs';
5
+ import type { AnyFunction, Callback, Codec } from '@pezkuwi/types/types';
6
+
7
+ export type Push<T extends readonly unknown[], V> = [...T, V]
8
+
9
+ export type DropLast<T extends readonly unknown[]> = T extends readonly [...infer U, any?] ? U : [...T];
10
+
11
+ export type ApiTypes = 'promise' | 'rxjs';
12
+
13
+ // Returns the inner type of an Observable
14
+ export type ObsInnerType<O extends Observable<any>> = O extends Observable<infer U> ? U : never;
15
+
16
+ export type VoidFn = () => void;
17
+
18
+ export type UnsubscribePromise = Promise<VoidFn>;
19
+
20
+ export type PromiseOrObs<ApiType extends ApiTypes, T> =
21
+ ApiType extends 'rxjs'
22
+ ? Observable<T>
23
+ : Promise<T>;
24
+
25
+ export type MethodResult<ApiType extends ApiTypes, F extends AnyFunction> =
26
+ ApiType extends 'rxjs'
27
+ ? RxResult<F>
28
+ : PromiseResult<F>;
29
+
30
+ // Here are the return types of these parts of the api:
31
+ // - api.query.*.*: no exact typings
32
+ // - api.tx.*.*: SubmittableExtrinsic<ApiType extends ApiTypes>
33
+ // - api.derive.*.*: MethodResult<ApiType, F>
34
+ // - api.rpc.*.*: no exact typings (for now, FIXME: should be MethodResult<ApiType, F>, like in derive)
35
+
36
+ // These are the types that don't lose type information (used for api.derive.*)
37
+ // Also use these for api.rpc.* https://github.com/pezkuwichain/pezkuwi-api/issues/1009
38
+ export interface RxResult<F extends AnyFunction> {
39
+ (...args: Parameters<F>): Observable<ObsInnerType<ReturnType<F>>>;
40
+ <T>(...args: Parameters<F>): Observable<T>;
41
+ }
42
+
43
+ export interface PromiseResult<F extends AnyFunction> {
44
+ (...args: Parameters<F>): Promise<ObsInnerType<ReturnType<F>>>;
45
+ (...args: Push<Parameters<F>, Callback<ObsInnerType<ReturnType<F>>>>): UnsubscribePromise;
46
+ <T extends Codec | Codec[]>(...args: Parameters<F>): Promise<T>;
47
+ <T extends Codec | Codec[]>(...args: Push<Parameters<F>, Callback<T>>): UnsubscribePromise;
48
+ }
49
+
50
+ // In the abstract `decorateMethod` in Base.ts, we can also pass in some meta-
51
+ // information. This describes it.
52
+ export interface DecorateMethodOptions {
53
+ methodName?: string;
54
+ overrideNoSub?: (...args: unknown[]) => Observable<Codec>;
55
+ }
56
+
57
+ export type DecorateFn <T extends Codec> = (...args: any[]) => Observable<T>;
58
+
59
+ export interface PaginationOptions<A = unknown> {
60
+ args: A[];
61
+ pageSize: number;
62
+ startKey?: string;
63
+ }
64
+
65
+ export type DecorateMethod<_ApiType extends ApiTypes, T = any> =
66
+ <M extends (...args: any[]) => Observable<any>>(method: M, options?: DecorateMethodOptions) => T;
67
+
68
+ type AsCodec<R> = R extends Codec
69
+ ? R
70
+ : Codec;
71
+
72
+ export type ReturnCodec<F extends AnyFunction> = AsCodec<ObsInnerType<ReturnType<F>>>;
73
+
74
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
75
+ export interface EmptyBase<_> {
76
+ // this is use to allow use to have unused vars in augmented interfaces,
77
+ // so intentionally left empty
78
+ }
@@ -0,0 +1,31 @@
1
+ // Copyright 2017-2025 @pezkuwi/api-base authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Observable } from 'rxjs';
5
+ import type { AnyFunction, Codec, DefinitionCallNamed } from '@pezkuwi/types/types';
6
+ import type { ApiTypes, EmptyBase, ReturnCodec } from './base.js';
7
+
8
+ export type DecoratedCallBase<ApiType extends ApiTypes, F extends AnyFunction = (...args: any[]) => Observable<Codec>> =
9
+ ApiType extends 'rxjs'
10
+ ? <T = ReturnCodec<F>> (...args: Parameters<F>) => Observable<T>
11
+ : <T = ReturnCodec<F>> (...args: Parameters<F>) => Promise<T>;
12
+
13
+ export type AugmentedCall<ApiType extends ApiTypes, F extends AnyFunction = (...args: any[]) => Observable<Codec>> = DecoratedCallBase<ApiType, F> & {
14
+ /** The metadata/description/definition for this method */
15
+ meta: DefinitionCallNamed
16
+ };
17
+
18
+ // augmented interfaces
19
+
20
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
21
+ export interface AugmentedCalls<ApiType extends ApiTypes> extends EmptyBase<ApiType> {
22
+ // augmented
23
+ }
24
+
25
+ // eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style
26
+ export interface QueryableCalls<ApiType extends ApiTypes> extends AugmentedCalls<ApiType> {
27
+ // when non-augmented, we need to at least have Codec results
28
+ [key: string]: QueryableModuleCalls<ApiType>;
29
+ }
30
+
31
+ export type QueryableModuleCalls<ApiType extends ApiTypes> = Record<string, DecoratedCallBase<ApiType>>;
@@ -0,0 +1,25 @@
1
+ // Copyright 2017-2025 @pezkuwi/api-base authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { PezpalletConstantMetadataLatest } from '@pezkuwi/types/interfaces';
5
+ import type { Codec } from '@pezkuwi/types/types';
6
+ import type { ApiTypes, EmptyBase } from './base.js';
7
+
8
+ export interface AugmentedConst<_ extends ApiTypes> {
9
+ meta: PezpalletConstantMetadataLatest;
10
+ }
11
+
12
+ // augmented interfaces
13
+
14
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
15
+ export interface AugmentedConsts<ApiType extends ApiTypes> extends EmptyBase<ApiType> {
16
+ // augmented
17
+ }
18
+
19
+ // eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style
20
+ export interface QueryableConsts<ApiType extends ApiTypes> extends AugmentedConsts<ApiType> {
21
+ // when non-augmented, we need to at least have Codec results
22
+ [key: string]: QueryableModuleConsts;
23
+ }
24
+
25
+ export type QueryableModuleConsts = Record<string, Codec>;
@@ -0,0 +1,8 @@
1
+ // Copyright 2017-2025 @pezkuwi/api-base authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Observable } from 'rxjs';
5
+
6
+ type DeriveCreator = (instanceId: string, api: unknown) => (...args: unknown[]) => Observable<any>;
7
+
8
+ export type DeriveCustom = Record<string, Record<string, DeriveCreator>>;
@@ -0,0 +1,22 @@
1
+ // Copyright 2017-2025 @pezkuwi/api-base authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { IsError } from '@pezkuwi/types/metadata/decorate/types';
5
+ import type { ApiTypes, EmptyBase } from './base.js';
6
+
7
+ export type AugmentedError<_ extends ApiTypes> = IsError;
8
+
9
+ // augmented interfaces
10
+
11
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
12
+ export interface AugmentedErrors<ApiType extends ApiTypes> extends EmptyBase<ApiType> {
13
+ // augmented
14
+ }
15
+
16
+ // eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style
17
+ export interface DecoratedErrors<ApiType extends ApiTypes> extends AugmentedErrors<ApiType> {
18
+ // when non-augmented, we need to at least have Codec results
19
+ [key: string]: ModuleErrors<ApiType>;
20
+ }
21
+
22
+ export type ModuleErrors<ApiType extends ApiTypes> = Record<string, AugmentedError<ApiType>>;
@@ -0,0 +1,23 @@
1
+ // Copyright 2017-2025 @pezkuwi/api-base authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { IsEvent } from '@pezkuwi/types/metadata/decorate/types';
5
+ import type { AnyTuple } from '@pezkuwi/types/types';
6
+ import type { ApiTypes, EmptyBase } from './base.js';
7
+
8
+ export type AugmentedEvent<_ extends ApiTypes, T extends AnyTuple = AnyTuple, N = unknown> = IsEvent<T, N>;
9
+
10
+ // augmented interfaces
11
+
12
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
13
+ export interface AugmentedEvents<ApiType extends ApiTypes> extends EmptyBase<ApiType> {
14
+ // augmented
15
+ }
16
+
17
+ // eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style
18
+ export interface DecoratedEvents<ApiType extends ApiTypes> extends AugmentedEvents<ApiType> {
19
+ // when non-augmented, we need to at least have Codec results
20
+ [key: string]: ModuleEvents<ApiType>;
21
+ }
22
+
23
+ export type ModuleEvents<ApiType extends ApiTypes> = Record<string, AugmentedEvent<ApiType>>;
@@ -0,0 +1,16 @@
1
+ // Copyright 2017-2025 @pezkuwi/api authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // These are augmented, do an augmentation export
5
+ export * from '@pezkuwi/api-base/types/calls';
6
+ export * from '@pezkuwi/api-base/types/consts';
7
+ export * from '@pezkuwi/api-base/types/errors';
8
+ export * from '@pezkuwi/api-base/types/events';
9
+ export * from '@pezkuwi/api-base/types/storage';
10
+ export * from '@pezkuwi/api-base/types/submittable';
11
+
12
+ // normal exports
13
+ export * from './api.js';
14
+ export * from './base.js';
15
+ export * from './derive.js';
16
+ export * from './rpc.js';
@@ -0,0 +1,35 @@
1
+ // Copyright 2017-2025 @pezkuwi/api-base authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Observable } from 'rxjs';
5
+ import type { AnyFunction, AnyJson, Callback, DefinitionRpc } from '@pezkuwi/types/types';
6
+ import type { ApiTypes, PromiseResult, Push, RxResult, UnsubscribePromise } from './base.js';
7
+
8
+ export type { AugmentedRpc } from '@pezkuwi/rpc-core/types';
9
+
10
+ export interface RxRpcResult<F extends AnyFunction> extends RxResult<F> {
11
+ raw <T> (...args: Parameters<F>): Observable<T>;
12
+ meta: DefinitionRpc;
13
+ }
14
+
15
+ export interface PromiseRpcResult<F extends AnyFunction> extends PromiseResult<F> {
16
+ raw <T> (...args: Parameters<F>): Promise<T>;
17
+ raw <T> (...args: Push<Parameters<F>, Callback<T>>): UnsubscribePromise;
18
+ meta: DefinitionRpc;
19
+ }
20
+
21
+ export type RpcMethodResult<ApiType extends ApiTypes, F extends AnyFunction> = ApiType extends 'rxjs'
22
+ ? RxRpcResult<F>
23
+ : PromiseRpcResult<F>;
24
+
25
+ export type DecoratedRpcSection<ApiType extends ApiTypes, Section> = {
26
+ [M in keyof Section]: Section[M] extends AnyFunction
27
+ ? RpcMethodResult<ApiType, Section[M]>
28
+ : never
29
+ }
30
+
31
+ export type RawRpcType<ApiType extends ApiTypes> = (method: string, ...params: unknown[]) => ApiType extends 'rxjs' ? Observable<AnyJson> : Promise<AnyJson>;
32
+
33
+ export type DecoratedRpc<ApiType extends ApiTypes, AllSections> = {
34
+ [S in keyof AllSections]: DecoratedRpcSection<ApiType, AllSections[S]>
35
+ } & RawRpcType<ApiType>