@dedot/api 1.0.1 → 1.0.3
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.
|
@@ -6,7 +6,7 @@ const SignedExtension_js_1 = require("../SignedExtension.js");
|
|
|
6
6
|
exports.MAX_FINALITY_LAG = 5;
|
|
7
7
|
exports.FALLBACK_MAX_HASH_COUNT = 250;
|
|
8
8
|
exports.FALLBACK_PERIOD = 6 * 1000;
|
|
9
|
-
exports.MORTAL_PERIOD =
|
|
9
|
+
exports.MORTAL_PERIOD = 12 * 60 * 1000;
|
|
10
10
|
/**
|
|
11
11
|
* @description Check for transaction mortality.
|
|
12
12
|
*/
|
|
@@ -30,9 +30,7 @@ class CheckMortality extends SignedExtension_js_1.SignedExtension {
|
|
|
30
30
|
return this.#getSigningHeaderViaLegacyRpc();
|
|
31
31
|
}
|
|
32
32
|
async #getSigningHeaderRpcV2() {
|
|
33
|
-
const
|
|
34
|
-
// TODO similar to the legacy, we should account for the case finality is lagging behind
|
|
35
|
-
const finalizedBlock = await api.chainHead.finalizedBlock();
|
|
33
|
+
const finalizedBlock = await this.client.block.finalized();
|
|
36
34
|
return {
|
|
37
35
|
hash: finalizedBlock.hash,
|
|
38
36
|
number: finalizedBlock.number,
|
|
@@ -233,10 +233,11 @@ class ChainHead extends JsonRpcGroup_js_1.JsonRpcGroup {
|
|
|
233
233
|
(0, utils_1.assert)(this.#finalizedRuntime, 'Invalid finalized runtime');
|
|
234
234
|
// Build initial pinned blocks
|
|
235
235
|
this.#finalizedHash = finalizedBlockHashes.at(-1);
|
|
236
|
-
|
|
236
|
+
this.#pinnedBlocks = this.#buildInitialPinnedBlocks(finalizedBlockHashes, this.#finalizedRuntime);
|
|
237
|
+
if (!this.#bestHash || (this.#bestHash && !this.findBlock(this.#bestHash))) {
|
|
237
238
|
this.#bestHash = this.#finalizedHash;
|
|
239
|
+
this.#lastBestBlockNumber = undefined; // Reset to avoid stale gap detection after recovery
|
|
238
240
|
}
|
|
239
|
-
this.#pinnedBlocks = this.#buildInitialPinnedBlocks(finalizedBlockHashes, this.#finalizedRuntime);
|
|
240
241
|
await this.#updateBlockNumbersAndParents(finalizedBlockHashes, prevPinnedBlocks);
|
|
241
242
|
// Handle first initialization or reconnection
|
|
242
243
|
if (!lastFinalizedHash) {
|
|
@@ -3,7 +3,7 @@ import { SignedExtension } from '../SignedExtension.js';
|
|
|
3
3
|
export const MAX_FINALITY_LAG = 5;
|
|
4
4
|
export const FALLBACK_MAX_HASH_COUNT = 250;
|
|
5
5
|
export const FALLBACK_PERIOD = 6 * 1000;
|
|
6
|
-
export const MORTAL_PERIOD =
|
|
6
|
+
export const MORTAL_PERIOD = 12 * 60 * 1000;
|
|
7
7
|
/**
|
|
8
8
|
* @description Check for transaction mortality.
|
|
9
9
|
*/
|
|
@@ -27,9 +27,7 @@ export class CheckMortality extends SignedExtension {
|
|
|
27
27
|
return this.#getSigningHeaderViaLegacyRpc();
|
|
28
28
|
}
|
|
29
29
|
async #getSigningHeaderRpcV2() {
|
|
30
|
-
const
|
|
31
|
-
// TODO similar to the legacy, we should account for the case finality is lagging behind
|
|
32
|
-
const finalizedBlock = await api.chainHead.finalizedBlock();
|
|
30
|
+
const finalizedBlock = await this.client.block.finalized();
|
|
33
31
|
return {
|
|
34
32
|
hash: finalizedBlock.hash,
|
|
35
33
|
number: finalizedBlock.number,
|
|
@@ -230,10 +230,11 @@ export class ChainHead extends JsonRpcGroup {
|
|
|
230
230
|
assert(this.#finalizedRuntime, 'Invalid finalized runtime');
|
|
231
231
|
// Build initial pinned blocks
|
|
232
232
|
this.#finalizedHash = finalizedBlockHashes.at(-1);
|
|
233
|
-
|
|
233
|
+
this.#pinnedBlocks = this.#buildInitialPinnedBlocks(finalizedBlockHashes, this.#finalizedRuntime);
|
|
234
|
+
if (!this.#bestHash || (this.#bestHash && !this.findBlock(this.#bestHash))) {
|
|
234
235
|
this.#bestHash = this.#finalizedHash;
|
|
236
|
+
this.#lastBestBlockNumber = undefined; // Reset to avoid stale gap detection after recovery
|
|
235
237
|
}
|
|
236
|
-
this.#pinnedBlocks = this.#buildInitialPinnedBlocks(finalizedBlockHashes, this.#finalizedRuntime);
|
|
237
238
|
await this.#updateBlockNumbersAndParents(finalizedBlockHashes, prevPinnedBlocks);
|
|
238
239
|
// Handle first initialization or reconnection
|
|
239
240
|
if (!lastFinalizedHash) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dedot/api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "A delightful JavaScript/TypeScript client for Polkadot & Substrate",
|
|
5
5
|
"author": "Thang X. Vu <thang@dedot.dev>",
|
|
6
6
|
"homepage": "https://dedot.dev",
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"type": "module",
|
|
14
14
|
"sideEffects": false,
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@dedot/codecs": "1.0.
|
|
17
|
-
"@dedot/providers": "1.0.
|
|
18
|
-
"@dedot/runtime-specs": "1.0.
|
|
19
|
-
"@dedot/shape": "1.0.
|
|
20
|
-
"@dedot/storage": "1.0.
|
|
21
|
-
"@dedot/types": "1.0.
|
|
22
|
-
"@dedot/utils": "1.0.
|
|
16
|
+
"@dedot/codecs": "1.0.3",
|
|
17
|
+
"@dedot/providers": "1.0.3",
|
|
18
|
+
"@dedot/runtime-specs": "1.0.3",
|
|
19
|
+
"@dedot/shape": "1.0.3",
|
|
20
|
+
"@dedot/storage": "1.0.3",
|
|
21
|
+
"@dedot/types": "1.0.3",
|
|
22
|
+
"@dedot/utils": "1.0.3"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "tsc --project tsconfig.build.json && tsc --project tsconfig.build.cjs.json",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"node": ">=18"
|
|
49
49
|
},
|
|
50
50
|
"license": "Apache-2.0",
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "034c564d00bd0f8b041a13e89623c605da54f38a",
|
|
52
52
|
"module": "./index.js",
|
|
53
53
|
"types": "./index.d.ts"
|
|
54
54
|
}
|