@pezkuwi/api 16.5.5

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 (92) hide show
  1. package/README.md +100 -0
  2. package/build/augment.d.ts +1 -0
  3. package/build/base/Decorate.d.ts +143 -0
  4. package/build/base/Events.d.ts +67 -0
  5. package/build/base/Getters.d.ts +163 -0
  6. package/build/base/Init.d.ts +44 -0
  7. package/build/base/find.d.ts +3 -0
  8. package/build/base/index.d.ts +47 -0
  9. package/build/base/types.d.ts +15 -0
  10. package/build/bundle.d.ts +7 -0
  11. package/build/index.d.ts +2 -0
  12. package/build/packageDetect.d.ts +1 -0
  13. package/build/packageInfo.d.ts +6 -0
  14. package/build/promise/Api.d.ts +158 -0
  15. package/build/promise/Combinator.d.ts +12 -0
  16. package/build/promise/decorateMethod.d.ts +14 -0
  17. package/build/promise/index.d.ts +2 -0
  18. package/build/promise/types.d.ts +5 -0
  19. package/build/rx/Api.d.ts +155 -0
  20. package/build/rx/decorateMethod.d.ts +3 -0
  21. package/build/rx/index.d.ts +2 -0
  22. package/build/submittable/Result.d.ts +31 -0
  23. package/build/submittable/createClass.d.ts +12 -0
  24. package/build/submittable/createSubmittable.d.ts +8 -0
  25. package/build/submittable/index.d.ts +2 -0
  26. package/build/submittable/types.d.ts +1 -0
  27. package/build/types/calls.d.ts +1 -0
  28. package/build/types/consts.d.ts +1 -0
  29. package/build/types/errors.d.ts +1 -0
  30. package/build/types/events.d.ts +1 -0
  31. package/build/types/index.d.ts +114 -0
  32. package/build/types/storage.d.ts +1 -0
  33. package/build/types/submittable.d.ts +1 -0
  34. package/build/util/augmentObject.d.ts +9 -0
  35. package/build/util/decorate.d.ts +16 -0
  36. package/build/util/filterEvents.d.ts +6 -0
  37. package/build/util/index.d.ts +4 -0
  38. package/build/util/isKeyringPair.d.ts +3 -0
  39. package/build/util/logging.d.ts +1 -0
  40. package/build/util/validate.d.ts +3 -0
  41. package/package.json +46 -0
  42. package/src/augment.ts +4 -0
  43. package/src/base/Decorate.ts +1103 -0
  44. package/src/base/Events.ts +91 -0
  45. package/src/base/Getters.ts +245 -0
  46. package/src/base/Init.ts +525 -0
  47. package/src/base/find.ts +14 -0
  48. package/src/base/index.ts +85 -0
  49. package/src/base/types.ts +19 -0
  50. package/src/bundle.ts +16 -0
  51. package/src/checkTypes.manual.ts +323 -0
  52. package/src/index.ts +6 -0
  53. package/src/mod.ts +4 -0
  54. package/src/packageDetect.ts +16 -0
  55. package/src/packageInfo.ts +6 -0
  56. package/src/promise/Api.ts +214 -0
  57. package/src/promise/Combinator.ts +91 -0
  58. package/src/promise/Combinators.spec.ts +109 -0
  59. package/src/promise/decorateMethod.ts +118 -0
  60. package/src/promise/index.spec.ts +167 -0
  61. package/src/promise/index.ts +5 -0
  62. package/src/promise/types.ts +9 -0
  63. package/src/rx/Api.ts +186 -0
  64. package/src/rx/decorateMethod.ts +9 -0
  65. package/src/rx/index.ts +5 -0
  66. package/src/submittable/Result.ts +111 -0
  67. package/src/submittable/createClass.ts +438 -0
  68. package/src/submittable/createSubmittable.ts +19 -0
  69. package/src/submittable/index.ts +5 -0
  70. package/src/submittable/types.ts +4 -0
  71. package/src/test/SingleAccountSigner.ts +53 -0
  72. package/src/test/index.ts +5 -0
  73. package/src/test/logEvents.ts +24 -0
  74. package/src/types/calls.ts +4 -0
  75. package/src/types/consts.ts +4 -0
  76. package/src/types/errors.ts +4 -0
  77. package/src/types/events.ts +4 -0
  78. package/src/types/index.ts +137 -0
  79. package/src/types/storage.ts +4 -0
  80. package/src/types/submittable.ts +4 -0
  81. package/src/util/augmentObject.spec.ts +54 -0
  82. package/src/util/augmentObject.ts +112 -0
  83. package/src/util/decorate.ts +43 -0
  84. package/src/util/filterEvents.ts +34 -0
  85. package/src/util/index.ts +10 -0
  86. package/src/util/isKeyringPair.ts +11 -0
  87. package/src/util/logging.ts +6 -0
  88. package/src/util/validate.spec.ts +72 -0
  89. package/src/util/validate.ts +36 -0
  90. package/tsconfig.build.json +25 -0
  91. package/tsconfig.build.tsbuildinfo +1 -0
  92. package/tsconfig.spec.json +26 -0
@@ -0,0 +1,158 @@
1
+ import type { ApiOptions, UnsubscribePromise } from '../types/index.js';
2
+ import type { CombinatorCallback, CombinatorFunction } from './Combinator.js';
3
+ import { ApiBase } from '../base/index.js';
4
+ /**
5
+ * # @polkadot/api/promise
6
+ *
7
+ * ## Overview
8
+ *
9
+ * @name ApiPromise
10
+ * @description
11
+ * 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.
12
+ *
13
+ * 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 Polkadot (and Substrate) clients.
14
+ *
15
+ * @see [[ApiRx]]
16
+ *
17
+ * ## Usage
18
+ *
19
+ * Making rpc calls -
20
+ * <BR>
21
+ *
22
+ * ```javascript
23
+ * import ApiPromise from '@pezkuwi/api/promise';
24
+ *
25
+ * // initialise via static create
26
+ * const api = await ApiPromise.create();
27
+ *
28
+ * // make a subscription to the network head
29
+ * api.rpc.chain.subscribeNewHeads((header) => {
30
+ * console.log(`Chain is at #${header.number}`);
31
+ * });
32
+ * ```
33
+ * <BR>
34
+ *
35
+ * Subscribing to chain state -
36
+ * <BR>
37
+ *
38
+ * ```javascript
39
+ * import { ApiPromise, WsProvider } from '@pezkuwi/api';
40
+ *
41
+ * // initialise a provider with a specific endpoint
42
+ * const provider = new WsProvider('wss://example.com:9944')
43
+ *
44
+ * // initialise via isReady & new with specific provider
45
+ * const api = await new ApiPromise({ provider }).isReady;
46
+ *
47
+ * // retrieve the block target time
48
+ * const blockPeriod = await api.query.timestamp.blockPeriod().toNumber();
49
+ * let last = 0;
50
+ *
51
+ * // subscribe to the current block timestamp, updates automatically (callback provided)
52
+ * api.query.timestamp.now((timestamp) => {
53
+ * const elapsed = last
54
+ * ? `, ${timestamp.toNumber() - last}s since last`
55
+ * : '';
56
+ *
57
+ * last = timestamp.toNumber();
58
+ * console.log(`timestamp ${timestamp}${elapsed} (${blockPeriod}s target)`);
59
+ * });
60
+ * ```
61
+ * <BR>
62
+ *
63
+ * Submitting a transaction -
64
+ * <BR>
65
+ *
66
+ * ```javascript
67
+ * import ApiPromise from '@pezkuwi/api/promise';
68
+ *
69
+ * ApiPromise.create().then((api) => {
70
+ * const [nonce] = await api.query.system.account(keyring.alice.address);
71
+ *
72
+ * api.tx.balances
73
+ * // create transfer
74
+ * transfer(keyring.bob.address, 12345)
75
+ * // sign the transcation
76
+ * .sign(keyring.alice, { nonce })
77
+ * // send the transaction (optional status callback)
78
+ * .send((status) => {
79
+ * console.log(`current status ${status.type}`);
80
+ * })
81
+ * // retrieve the submitted extrinsic hash
82
+ * .then((hash) => {
83
+ * console.log(`submitted with hash ${hash}`);
84
+ * });
85
+ * });
86
+ * ```
87
+ */
88
+ export declare class ApiPromise extends ApiBase<'promise'> {
89
+ #private;
90
+ /**
91
+ * @description Creates an instance of the ApiPromise class
92
+ * @param options Options to create an instance. This can be either [[ApiOptions]] or
93
+ * an [[WsProvider]].
94
+ * @example
95
+ * <BR>
96
+ *
97
+ * ```javascript
98
+ * import Api from '@pezkuwi/api/promise';
99
+ *
100
+ * new Api().isReady.then((api) => {
101
+ * api.rpc.subscribeNewHeads((header) => {
102
+ * console.log(`new block #${header.number.toNumber()}`);
103
+ * });
104
+ * });
105
+ * ```
106
+ */
107
+ constructor(options?: ApiOptions);
108
+ /**
109
+ * @description Creates an ApiPromise instance using the supplied provider. Returns an Promise containing the actual Api instance.
110
+ * @param options options that is passed to the class contructor. Can be either [[ApiOptions]] or a
111
+ * provider (see the constructor arguments)
112
+ * @example
113
+ * <BR>
114
+ *
115
+ * ```javascript
116
+ * import Api from '@pezkuwi/api/promise';
117
+ *
118
+ * Api.create().then(async (api) => {
119
+ * const timestamp = await api.query.timestamp.now();
120
+ *
121
+ * console.log(`lastest block timestamp ${timestamp}`);
122
+ * });
123
+ * ```
124
+ */
125
+ static create(options?: ApiOptions): Promise<ApiPromise>;
126
+ /**
127
+ * @description Promise that resolves the first time we are connected and loaded
128
+ */
129
+ get isReady(): Promise<ApiPromise>;
130
+ /**
131
+ * @description Promise that resolves if we can connect, or reject if there is an error
132
+ */
133
+ get isReadyOrError(): Promise<ApiPromise>;
134
+ /**
135
+ * @description Returns a clone of this ApiPromise instance (new underlying provider connection)
136
+ */
137
+ clone(): ApiPromise;
138
+ /**
139
+ * @description Creates a combinator that can be used to combine the latest results from multiple subscriptions
140
+ * @param fns An array of function to combine, each in the form of `(cb: (value: void)) => void`
141
+ * @param callback A callback that will return an Array of all the values this combinator has been applied to
142
+ * @example
143
+ * <BR>
144
+ *
145
+ * ```javascript
146
+ * const address = '5DTestUPts3kjeXSTMyerHihn1uwMfLj8vU8sqF7qYrFacT7';
147
+ *
148
+ * // combines values from balance & nonce as it updates
149
+ * api.combineLatest([
150
+ * api.rpc.chain.subscribeNewHeads,
151
+ * (cb) => api.query.system.account(address, cb)
152
+ * ], ([head, [balance, nonce]]) => {
153
+ * console.log(`#${head.number}: You have ${balance.free} units, with ${nonce} transactions sent`);
154
+ * });
155
+ * ```
156
+ */
157
+ combineLatest<T extends any[] = any[]>(fns: (CombinatorFunction | [CombinatorFunction, ...any[]])[], callback: CombinatorCallback<T>): UnsubscribePromise;
158
+ }
@@ -0,0 +1,12 @@
1
+ import type { Callback } from '@pezkuwi/types/types';
2
+ import type { UnsubscribePromise } from '../types/index.js';
3
+ export type CombinatorCallback<T extends unknown[]> = Callback<T>;
4
+ export type CombinatorFunction = (cb: Callback<any>) => UnsubscribePromise;
5
+ export declare class Combinator<T extends unknown[] = unknown[]> {
6
+ #private;
7
+ constructor(fns: (CombinatorFunction | [CombinatorFunction, ...unknown[]])[], callback: CombinatorCallback<T>);
8
+ protected _allHasFired(): boolean;
9
+ protected _createCallback(index: number): (value: any) => void;
10
+ protected _triggerUpdate(): void;
11
+ unsubscribe(): void;
12
+ }
@@ -0,0 +1,14 @@
1
+ import type { Observable } from 'rxjs';
2
+ import type { Codec } from '@pezkuwi/types/types';
3
+ import type { DecorateFn, DecorateMethodOptions, ObsInnerType, StorageEntryPromiseOverloads } from '../types/index.js';
4
+ interface Tracker<T> {
5
+ reject: (value: Error) => Observable<never>;
6
+ resolve: (value: T) => void;
7
+ }
8
+ type CodecReturnType<T extends (...args: unknown[]) => Observable<Codec>> = T extends (...args: any) => infer R ? R extends Observable<Codec> ? ObsInnerType<R> : never : never;
9
+ export declare function promiseTracker<T>(resolve: (value: T) => void, reject: (value: Error) => void): Tracker<T>;
10
+ /**
11
+ * @description Decorate method for ApiPromise, where the results are converted to the Promise equivalent
12
+ */
13
+ export declare function toPromiseMethod<M extends DecorateFn<CodecReturnType<M>>>(method: M, options?: DecorateMethodOptions): StorageEntryPromiseOverloads;
14
+ export {};
@@ -0,0 +1,2 @@
1
+ export { ApiPromise } from './Api.js';
2
+ export { toPromiseMethod } from './decorateMethod.js';
@@ -0,0 +1,5 @@
1
+ import type { SubmittableExtrinsic as SubmittableExtrinsicBase } from '../submittable/types.js';
2
+ import type { QueryableStorageEntry as QueryableStorageEntryBase, SubmittableExtrinsicFunction as SubmittableExtrinsicFunctionBase } from '../types/index.js';
3
+ export type QueryableStorageEntry = QueryableStorageEntryBase<'promise'>;
4
+ export type SubmittableExtrinsic = SubmittableExtrinsicBase<'promise'>;
5
+ export type SubmittableExtrinsicFunction = SubmittableExtrinsicFunctionBase<'promise'>;
@@ -0,0 +1,155 @@
1
+ import type { Observable } from 'rxjs';
2
+ import type { ApiOptions } from '../types/index.js';
3
+ import { ApiBase } from '../base/index.js';
4
+ /**
5
+ * # @polkadot/api/rx
6
+ *
7
+ * ## Overview
8
+ *
9
+ * @name ApiRx
10
+ *
11
+ * @description
12
+ * ApiRx is a powerful RxJS Observable wrapper around the RPC and interfaces on the Pezkuwi network. As a full Observable API, all interface calls return RxJS Observables, including the static `.create(...)`. In the same fashion and subscription-based methods return long-running Observables that update with the latest values.
13
+ *
14
+ * The API is well suited to real-time applications where the latest state is needed, unlocking the subscription-based features of Polkadot (and Substrate) clients. Some familiarity with RxJS is a requirement to use the API, however just understanding `.subscribe` and `.pipe` on Observables will unlock full-scale use thereof.
15
+ *
16
+ * @see [[ApiPromise]]
17
+ *
18
+ * ## Usage
19
+ *
20
+ * Making rpc calls -
21
+ * <BR>
22
+ *
23
+ * ```javascript
24
+ * import ApiRx from '@pezkuwi/api/rx';
25
+ *
26
+ * // initialize via Promise & static create
27
+ * const api = await ApiRx.create().toPromise();
28
+ *
29
+ * // make a call to retrieve the current network head
30
+ * api.rpc.chain.subscribeNewHeads().subscribe((header) => {
31
+ * console.log(`Chain is at #${header.number}`);
32
+ * });
33
+ * ```
34
+ * <BR>
35
+ *
36
+ * Subscribing to chain state -
37
+ * <BR>
38
+ *
39
+ * ```javascript
40
+ * import { combineLatest, pairwise, switchMap } from 'rxjs';
41
+ * import { ApiRx, WsProvider } from '@pezkuwi/api';
42
+ *
43
+ *
44
+ * // initialize a provider with a specific endpoint
45
+ * const provider = new WsProvider('wss://example.com:9944')
46
+ *
47
+ * // initialize via isReady & new with specific provider
48
+ * new ApiRx({ provider })
49
+ * .isReady
50
+ * .pipe(
51
+ * switchMap((api) =>
52
+ * combineLatest([
53
+ * api.query.timestamp.blockPeriod(),
54
+ * api.query.timestamp.now().pipe(pairwise())
55
+ * ])
56
+ * )
57
+ * )
58
+ * .subscribe(([blockPeriod, timestamp]) => {
59
+ * const elapsed = timestamp[1].toNumber() - timestamp[0].toNumber();
60
+ * console.log(`timestamp ${timestamp[1]} \nelapsed ${elapsed} \n(${blockPeriod}s target)`);
61
+ * });
62
+ * ```
63
+ * <BR>
64
+ *
65
+ * Submitting a transaction -
66
+ * <BR>
67
+ *
68
+ * ```javascript
69
+ * import { first, switchMap } from 'rxjs';
70
+ * import ApiRx from '@pezkuwi/api/rx';
71
+ *
72
+ * // import the test keyring (already has dev keys for Alice, Bob, Charlie, Eve & Ferdie)
73
+ * import testingPairs from '@pezkuwi/keyring/testingPairs';
74
+ * const keyring = testingPairs();
75
+ *
76
+ * // get api via Promise
77
+ * const api = await ApiRx.create().toPromise();
78
+ *
79
+ * // retrieve nonce for the account
80
+ * api.query.system
81
+ * .account(keyring.alice.address)
82
+ * .pipe(
83
+ * first(),
84
+ * // pipe nonce into transfer
85
+ * switchMap(([nonce]) =>
86
+ * api.tx.balances
87
+ * // create transfer
88
+ * .transferAllowDeath(keyring.bob.address, 12345)
89
+ * // sign the transaction
90
+ * .sign(keyring.alice, { nonce })
91
+ * // send the transaction
92
+ * .send()
93
+ * )
94
+ * )
95
+ * // subscribe to overall result
96
+ * .subscribe(({ status }) => {
97
+ * if (status.isInBlock) {
98
+ * console.log('Completed at block hash', status.asFinalized.toHex());
99
+ * }
100
+ * });
101
+ * ```
102
+ */
103
+ export declare class ApiRx extends ApiBase<'rxjs'> {
104
+ #private;
105
+ /**
106
+ * @description Create an instance of the ApiRx class
107
+ * @param options Options to create an instance. Can be either [[ApiOptions]] or [[WsProvider]]
108
+ * @example
109
+ * <BR>
110
+ *
111
+ * ```javascript
112
+ * import { switchMap } from 'rxjs';
113
+ * import Api from '@pezkuwi/api/rx';
114
+ *
115
+ * new Api().isReady
116
+ * .pipe(
117
+ * switchMap((api) =>
118
+ * api.rpc.chain.subscribeNewHeads()
119
+ * ))
120
+ * .subscribe((header) => {
121
+ * console.log(`new block #${header.number.toNumber()}`);
122
+ * });
123
+ * ```
124
+ */
125
+ constructor(options?: ApiOptions);
126
+ /**
127
+ * @description Creates an ApiRx instance using the supplied provider. Returns an Observable containing the actual Api instance.
128
+ * @param options options that is passed to the class constructor. Can be either [[ApiOptions]] or [[WsProvider]]
129
+ * @example
130
+ * <BR>
131
+ *
132
+ * ```javascript
133
+ * import { switchMap } from 'rxjs';
134
+ * import Api from '@pezkuwi/api/rx';
135
+ *
136
+ * Api.create()
137
+ * .pipe(
138
+ * switchMap((api) =>
139
+ * api.rpc.chain.subscribeNewHeads()
140
+ * ))
141
+ * .subscribe((header) => {
142
+ * console.log(`new block #${header.number.toNumber()}`);
143
+ * });
144
+ * ```
145
+ */
146
+ static create(options?: ApiOptions): Observable<ApiRx>;
147
+ /**
148
+ * @description Observable that returns the first time we are connected and loaded
149
+ */
150
+ get isReady(): Observable<ApiRx>;
151
+ /**
152
+ * @description Returns a clone of this ApiRx instance (new underlying provider connection)
153
+ */
154
+ clone(): ApiRx;
155
+ }
@@ -0,0 +1,3 @@
1
+ import type { Codec } from '@pezkuwi/types/types';
2
+ import type { DecorateFn } from '../types/index.js';
3
+ export declare function toRxMethod<M extends DecorateFn<Codec>>(method: M): M;
@@ -0,0 +1,2 @@
1
+ export { ApiRx } from './Api.js';
2
+ export { toRxMethod } from './decorateMethod.js';
@@ -0,0 +1,31 @@
1
+ import type { BlockNumber, DispatchError, DispatchInfo, EventRecord, ExtrinsicStatus, Hash } from '@pezkuwi/types/interfaces';
2
+ import type { AnyJson, ISubmittableResult } from '@pezkuwi/types/types';
3
+ import type { SubmittableResultValue } from './types.js';
4
+ export declare class SubmittableResult implements ISubmittableResult {
5
+ readonly dispatchError?: DispatchError | undefined;
6
+ readonly dispatchInfo?: DispatchInfo | undefined;
7
+ readonly internalError?: Error | undefined;
8
+ readonly events: EventRecord[];
9
+ readonly status: ExtrinsicStatus;
10
+ readonly txHash: Hash;
11
+ readonly txIndex?: number | undefined;
12
+ readonly blockNumber?: BlockNumber | undefined;
13
+ constructor({ blockNumber, dispatchError, dispatchInfo, events, internalError, status, txHash, txIndex }: SubmittableResultValue);
14
+ get isCompleted(): boolean;
15
+ get isError(): boolean;
16
+ get isFinalized(): boolean;
17
+ get isInBlock(): boolean;
18
+ get isWarning(): boolean;
19
+ /**
20
+ * @description Filters EventRecords for the specified method & section (there could be multiple)
21
+ */
22
+ filterRecords(section: string, method: string | string[]): EventRecord[];
23
+ /**
24
+ * @description Finds an EventRecord for the specified method & section
25
+ */
26
+ findRecord(section: string, method: string | string[]): EventRecord | undefined;
27
+ /**
28
+ * @description Creates a human representation of the output
29
+ */
30
+ toHuman(isExtended?: boolean): AnyJson;
31
+ }
@@ -0,0 +1,12 @@
1
+ import type { CodecClass } from '@pezkuwi/types/types';
2
+ import type { ApiBase } from '../base/index.js';
3
+ import type { ApiInterfaceRx, ApiTypes } from '../types/index.js';
4
+ import type { SubmittableExtrinsic } from './types.js';
5
+ interface SubmittableOptions<ApiType extends ApiTypes> {
6
+ api: ApiInterfaceRx;
7
+ apiType: ApiTypes;
8
+ blockHash?: Uint8Array | undefined;
9
+ decorateMethod: ApiBase<ApiType>['_decorateMethod'];
10
+ }
11
+ export declare function createClass<ApiType extends ApiTypes>({ api, apiType, blockHash, decorateMethod }: SubmittableOptions<ApiType>): CodecClass<SubmittableExtrinsic<ApiType>>;
12
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { Call } from '@pezkuwi/types/interfaces';
2
+ import type { Registry } from '@pezkuwi/types-codec/types';
3
+ import type { ApiBase } from '../base/index.js';
4
+ import type { ApiInterfaceRx, ApiTypes } from '../types/index.js';
5
+ import type { SubmittableExtrinsic } from './types.js';
6
+ type Creator<ApiType extends ApiTypes> = (extrinsic: Call | Uint8Array | string) => SubmittableExtrinsic<ApiType>;
7
+ export declare function createSubmittable<ApiType extends ApiTypes>(apiType: ApiTypes, api: ApiInterfaceRx, decorateMethod: ApiBase<ApiType>['_decorateMethod'], registry?: Registry, blockHash?: Uint8Array): Creator<ApiType>;
8
+ export {};
@@ -0,0 +1,2 @@
1
+ export { createSubmittable } from './createSubmittable.js';
2
+ export { SubmittableResult } from './Result.js';
@@ -0,0 +1 @@
1
+ export type { AddressOrPair, SignerOptions, SubmittableDryRunResult, SubmittableExtrinsic, SubmittablePaymentResult, SubmittableResultResult, SubmittableResultSubscription, SubmittableResultValue } from '@pezkuwi/api-base/types';
@@ -0,0 +1 @@
1
+ export * from '@pezkuwi/api-base/types/calls';
@@ -0,0 +1 @@
1
+ export * from '@pezkuwi/api-base/types/consts';
@@ -0,0 +1 @@
1
+ export * from '@pezkuwi/api-base/types/errors';
@@ -0,0 +1 @@
1
+ export * from '@pezkuwi/api-base/types/events';
@@ -0,0 +1,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
+ }
@@ -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,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,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,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,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 @@
1
+ export declare const l: import("@pezkuwi/util/types").Logger;
@@ -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[]];
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "author": "Jaco Greeff <jacogr@gmail.com>",
3
+ "bugs": "https://github.com/pezkuwichain/pezkuwi-api/issues",
4
+ "description": "Promise and RxJS wrappers around the Polkadot JS RPC",
5
+ "engines": {
6
+ "node": ">=18"
7
+ },
8
+ "homepage": "https://github.com/pezkuwichain/pezkuwi-api/tree/master/packages/api#readme",
9
+ "license": "Apache-2.0",
10
+ "name": "@pezkuwi/api",
11
+ "repository": {
12
+ "directory": "packages/api",
13
+ "type": "git",
14
+ "url": "https://github.com/pezkuwichain/pezkuwi-api.git"
15
+ },
16
+ "sideEffects": [
17
+ "./packageDetect.js",
18
+ "./packageDetect.cjs"
19
+ ],
20
+ "type": "module",
21
+ "version": "16.5.5",
22
+ "main": "index.js",
23
+ "dependencies": {
24
+ "@pezkuwi/api-augment": "16.5.5",
25
+ "@pezkuwi/api-base": "16.5.5",
26
+ "@pezkuwi/api-derive": "16.5.5",
27
+ "@pezkuwi/keyring": "14.0.5",
28
+ "@pezkuwi/rpc-augment": "16.5.5",
29
+ "@pezkuwi/rpc-core": "16.5.5",
30
+ "@pezkuwi/rpc-provider": "16.5.5",
31
+ "@pezkuwi/types": "16.5.5",
32
+ "@pezkuwi/types-augment": "16.5.5",
33
+ "@pezkuwi/types-codec": "16.5.5",
34
+ "@pezkuwi/types-create": "16.5.5",
35
+ "@pezkuwi/types-known": "16.5.5",
36
+ "@pezkuwi/util": "14.0.5",
37
+ "@pezkuwi/util-crypto": "14.0.5",
38
+ "eventemitter3": "^5.0.1",
39
+ "rxjs": "^7.8.1",
40
+ "tslib": "^2.8.1"
41
+ },
42
+ "devDependencies": {
43
+ "@pezkuwi/api-augment": "16.5.5",
44
+ "@pezkuwi/types-support": "16.5.5"
45
+ }
46
+ }