@dedot/api 0.18.8 → 1.0.0
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/chaintypes/substrate/consts.d.ts +2 -2
- package/chaintypes/substrate/consts.js +1 -0
- package/chaintypes/substrate/errors.d.ts +909 -909
- package/chaintypes/substrate/errors.js +1 -0
- package/chaintypes/substrate/events.d.ts +664 -664
- package/chaintypes/substrate/events.js +1 -0
- package/chaintypes/substrate/index.d.ts +13 -16
- package/chaintypes/substrate/index.js +1 -0
- package/chaintypes/substrate/json-rpc.d.ts +2 -2
- package/chaintypes/substrate/json-rpc.js +1 -0
- package/chaintypes/substrate/query.d.ts +509 -527
- package/chaintypes/substrate/query.js +1 -0
- package/chaintypes/substrate/runtime.d.ts +123 -123
- package/chaintypes/substrate/runtime.js +1 -0
- package/chaintypes/substrate/tx.d.ts +1311 -1311
- package/chaintypes/substrate/tx.js +1 -0
- package/chaintypes/substrate/types.js +1 -0
- package/chaintypes/substrate/view-functions.d.ts +2 -2
- package/chaintypes/substrate/view-functions.js +1 -0
- package/cjs/chaintypes/substrate/consts.js +1 -0
- package/cjs/chaintypes/substrate/errors.js +1 -0
- package/cjs/chaintypes/substrate/events.js +1 -0
- package/cjs/chaintypes/substrate/index.js +1 -0
- package/cjs/chaintypes/substrate/json-rpc.js +1 -0
- package/cjs/chaintypes/substrate/query.js +1 -0
- package/cjs/chaintypes/substrate/runtime.js +1 -0
- package/cjs/chaintypes/substrate/tx.js +1 -0
- package/cjs/chaintypes/substrate/types.js +1 -0
- package/cjs/chaintypes/substrate/view-functions.js +1 -0
- package/cjs/client/BaseSubstrateClient.js +45 -2
- package/cjs/client/DedotClient.js +356 -224
- package/cjs/client/LegacyClient.js +99 -23
- package/cjs/client/V2Client.js +316 -0
- package/cjs/client/explorer/LegacyBlockExplorer.js +263 -0
- package/cjs/client/explorer/V2BlockExplorer.js +74 -0
- package/cjs/client/explorer/index.js +18 -0
- package/cjs/client/utils.js +57 -0
- package/cjs/executor/EventExecutor.js +1 -0
- package/cjs/executor/RuntimeApiExecutor.js +49 -2
- package/cjs/executor/StorageQueryExecutor.js +114 -2
- package/cjs/executor/ViewFunctionExecutor.js +21 -2
- package/cjs/executor/v2/StorageQueryExecutorV2.js +7 -1
- package/cjs/executor/validation-helpers.js +181 -0
- package/cjs/extrinsic/submittable/BaseSubmittableExtrinsic.js +86 -2
- package/cjs/extrinsic/submittable/SubmittableExtrinsic.js +38 -16
- package/cjs/extrinsic/submittable/SubmittableExtrinsicV2.js +12 -2
- package/cjs/json-rpc/group/ChainHead/ChainHead.js +226 -21
- package/cjs/storage/QueryableStorage.js +1 -0
- package/client/BaseSubstrateClient.d.ts +34 -18
- package/client/BaseSubstrateClient.js +47 -4
- package/client/DedotClient.d.ts +346 -49
- package/client/DedotClient.js +356 -224
- package/client/LegacyClient.d.ts +22 -17
- package/client/LegacyClient.js +101 -25
- package/client/V2Client.d.ts +75 -0
- package/client/V2Client.js +312 -0
- package/client/explorer/LegacyBlockExplorer.d.ts +68 -0
- package/client/explorer/LegacyBlockExplorer.js +259 -0
- package/client/explorer/V2BlockExplorer.d.ts +40 -0
- package/client/explorer/V2BlockExplorer.js +70 -0
- package/client/explorer/index.d.ts +2 -0
- package/client/explorer/index.js +2 -0
- package/client/utils.d.ts +18 -0
- package/client/utils.js +52 -0
- package/executor/ConstantExecutor.d.ts +1 -2
- package/executor/ErrorExecutor.d.ts +2 -2
- package/executor/EventExecutor.d.ts +2 -2
- package/executor/EventExecutor.js +1 -0
- package/executor/Executor.d.ts +4 -5
- package/executor/RuntimeApiExecutor.d.ts +2 -2
- package/executor/RuntimeApiExecutor.js +27 -3
- package/executor/StorageQueryExecutor.d.ts +3 -2
- package/executor/StorageQueryExecutor.js +92 -3
- package/executor/TxExecutor.d.ts +2 -2
- package/executor/ViewFunctionExecutor.d.ts +2 -2
- package/executor/ViewFunctionExecutor.js +22 -3
- package/executor/v2/RuntimeApiExecutorV2.d.ts +2 -3
- package/executor/v2/StorageQueryExecutorV2.d.ts +3 -3
- package/executor/v2/StorageQueryExecutorV2.js +8 -2
- package/executor/v2/TxExecutorV2.d.ts +5 -5
- package/executor/v2/ViewFunctionExecutorV2.d.ts +2 -3
- package/executor/validation-helpers.d.ts +36 -0
- package/executor/validation-helpers.js +174 -0
- package/extrinsic/extensions/SignedExtension.d.ts +1 -1
- package/extrinsic/submittable/BaseSubmittableExtrinsic.d.ts +7 -3
- package/extrinsic/submittable/BaseSubmittableExtrinsic.js +64 -3
- package/extrinsic/submittable/SubmittableExtrinsic.d.ts +4 -1
- package/extrinsic/submittable/SubmittableExtrinsic.js +39 -17
- package/extrinsic/submittable/SubmittableExtrinsicV2.d.ts +6 -3
- package/extrinsic/submittable/SubmittableExtrinsicV2.js +13 -3
- package/json-rpc/JsonRpcClient.d.ts +6 -6
- package/json-rpc/group/Archive.d.ts +1 -1
- package/json-rpc/group/ChainHead/ChainHead.d.ts +18 -2
- package/json-rpc/group/ChainHead/ChainHead.js +226 -21
- package/json-rpc/group/ChainSpec.d.ts +3 -3
- package/json-rpc/group/Transaction.d.ts +1 -1
- package/json-rpc/group/TransactionWatch.d.ts +1 -1
- package/package.json +9 -9
- package/proxychain.d.ts +3 -4
- package/storage/NewStorageQuery.d.ts +3 -3
- package/storage/QueryableStorage.js +1 -0
- package/types.d.ts +94 -6
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { GenericChainViewFunctions
|
|
2
|
-
export interface ChainViewFunctions
|
|
1
|
+
import type { GenericChainViewFunctions } from '@dedot/types';
|
|
2
|
+
export interface ChainViewFunctions extends GenericChainViewFunctions {
|
|
3
3
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseSubstrateClient = exports.ensurePresence = void 0;
|
|
4
4
|
const codecs_1 = require("@dedot/codecs");
|
|
5
|
+
const providers_1 = require("@dedot/providers");
|
|
5
6
|
const storage_1 = require("@dedot/storage");
|
|
6
7
|
const utils_1 = require("@dedot/utils");
|
|
7
8
|
const index_js_1 = require("../executor/index.js");
|
|
@@ -31,6 +32,7 @@ class BaseSubstrateClient extends index_js_2.JsonRpcClient {
|
|
|
31
32
|
_localCache;
|
|
32
33
|
_runtimeUpgrading;
|
|
33
34
|
_apiAtCache;
|
|
35
|
+
#stalingWatchdogTimer;
|
|
34
36
|
constructor(rpcVersion, options) {
|
|
35
37
|
super(options);
|
|
36
38
|
this.rpcVersion = rpcVersion;
|
|
@@ -98,7 +100,7 @@ class BaseSubstrateClient extends index_js_2.JsonRpcClient {
|
|
|
98
100
|
if (!metadata) {
|
|
99
101
|
throw new Error('Cannot load metadata');
|
|
100
102
|
}
|
|
101
|
-
this.setMetadata(metadata);
|
|
103
|
+
await this.setMetadata(metadata);
|
|
102
104
|
}
|
|
103
105
|
/**
|
|
104
106
|
* Safely set metadata to cache with fallback cleanup if storage limit is exceeded
|
|
@@ -130,7 +132,7 @@ class BaseSubstrateClient extends index_js_2.JsonRpcClient {
|
|
|
130
132
|
}
|
|
131
133
|
}
|
|
132
134
|
}
|
|
133
|
-
setMetadata(metadata) {
|
|
135
|
+
async setMetadata(metadata) {
|
|
134
136
|
this._metadata = metadata;
|
|
135
137
|
this._registry = new codecs_1.PortableRegistry(metadata.latest, this.options.hasher);
|
|
136
138
|
}
|
|
@@ -203,6 +205,34 @@ class BaseSubstrateClient extends index_js_2.JsonRpcClient {
|
|
|
203
205
|
return await this.rpc.state_getMetadata();
|
|
204
206
|
}
|
|
205
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Set up staling detection with timeout reset logic.
|
|
210
|
+
* Returns a callback function that should be called on each activity (block/event).
|
|
211
|
+
*
|
|
212
|
+
* @returns A function to call on each activity to reset the timeout
|
|
213
|
+
*/
|
|
214
|
+
getStalingDetectionFn() {
|
|
215
|
+
const timeout = this._options.stalingDetectionTimeout ?? 30_000; // default to 30 seconds
|
|
216
|
+
if (timeout === 0 || !(this.provider instanceof providers_1.WsProvider)) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
return () => {
|
|
220
|
+
this.cleanupStalingDetection();
|
|
221
|
+
this.#stalingWatchdogTimer = setTimeout(() => {
|
|
222
|
+
console.warn(`No new blocks received for over ${timeout}ms, triggering reconnection with endpoint switch...`);
|
|
223
|
+
this.provider.disconnect(true).catch(utils_1.noop);
|
|
224
|
+
}, timeout);
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Clean up staling detection timer
|
|
229
|
+
*/
|
|
230
|
+
cleanupStalingDetection() {
|
|
231
|
+
if (this.#stalingWatchdogTimer) {
|
|
232
|
+
clearTimeout(this.#stalingWatchdogTimer);
|
|
233
|
+
this.#stalingWatchdogTimer = undefined;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
206
236
|
cleanUp() {
|
|
207
237
|
this._registry = undefined;
|
|
208
238
|
this._metadata = undefined;
|
|
@@ -210,6 +240,7 @@ class BaseSubstrateClient extends index_js_2.JsonRpcClient {
|
|
|
210
240
|
this._runtimeVersion = undefined;
|
|
211
241
|
this._localCache = undefined;
|
|
212
242
|
this._apiAtCache.clear();
|
|
243
|
+
this.cleanupStalingDetection();
|
|
213
244
|
}
|
|
214
245
|
/**
|
|
215
246
|
* @description Clear local cache and API at-block cache
|
|
@@ -310,6 +341,9 @@ class BaseSubstrateClient extends index_js_2.JsonRpcClient {
|
|
|
310
341
|
await this.ensureRuntimeUpgraded();
|
|
311
342
|
return this.runtimeVersion;
|
|
312
343
|
}
|
|
344
|
+
get block() {
|
|
345
|
+
throw new Error('Unimplemented!');
|
|
346
|
+
}
|
|
313
347
|
get consts() {
|
|
314
348
|
return (0, proxychain_js_1.newProxyChain)({ executor: new index_js_1.ConstantExecutor(this) });
|
|
315
349
|
}
|
|
@@ -373,5 +407,14 @@ class BaseSubstrateClient extends index_js_2.JsonRpcClient {
|
|
|
373
407
|
getStorageQuery() {
|
|
374
408
|
throw new Error('Unimplemented!');
|
|
375
409
|
}
|
|
410
|
+
sendTx(tx, callback) {
|
|
411
|
+
throw new Error('Unimplemented!');
|
|
412
|
+
}
|
|
413
|
+
get chainSpec() {
|
|
414
|
+
throw new Error('Unimplemented!');
|
|
415
|
+
}
|
|
416
|
+
on(event, handler) {
|
|
417
|
+
return super.on(event, handler);
|
|
418
|
+
}
|
|
376
419
|
}
|
|
377
420
|
exports.BaseSubstrateClient = BaseSubstrateClient;
|