@substrate/api-sidecar 20.12.0 → 20.13.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/build/package.json +5 -5
- package/build/src/controllers/accounts/AccountsVestingInfoController.d.ts +18 -3
- package/build/src/controllers/accounts/AccountsVestingInfoController.js +24 -6
- package/build/src/controllers/accounts/AccountsVestingInfoController.js.map +1 -1
- package/build/src/controllers/rc/accounts/RcAccountsVestingInfoController.d.ts +12 -1
- package/build/src/controllers/rc/accounts/RcAccountsVestingInfoController.js +15 -3
- package/build/src/controllers/rc/accounts/RcAccountsVestingInfoController.js.map +1 -1
- package/build/src/services/accounts/AccountsVestingInfoService.d.ts +42 -1
- package/build/src/services/accounts/AccountsVestingInfoService.js +236 -5
- package/build/src/services/accounts/AccountsVestingInfoService.js.map +1 -1
- package/build/src/services/paras/ParasInclusionService.d.ts +3 -11
- package/build/src/services/paras/ParasInclusionService.js +7 -60
- package/build/src/services/paras/ParasInclusionService.js.map +1 -1
- package/build/src/types/responses/AccountVestingInfo.d.ts +56 -1
- package/build/src/util/relay/getRelayParentNumber.d.ts +80 -0
- package/build/src/util/relay/getRelayParentNumber.js +170 -0
- package/build/src/util/relay/getRelayParentNumber.js.map +1 -0
- package/build/src/util/relay/getRelayParentNumber.spec.d.ts +1 -0
- package/build/src/util/relay/getRelayParentNumber.spec.js +201 -0
- package/build/src/util/relay/getRelayParentNumber.spec.js.map +1 -0
- package/build/src/util/vesting/vestingCalculations.d.ts +87 -0
- package/build/src/util/vesting/vestingCalculations.js +141 -0
- package/build/src/util/vesting/vestingCalculations.js.map +1 -0
- package/build/src/util/vesting/vestingCalculations.spec.d.ts +1 -0
- package/build/src/util/vesting/vestingCalculations.spec.js +335 -0
- package/build/src/util/vesting/vestingCalculations.spec.js.map +1 -0
- package/package.json +5 -5
package/build/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "20.
|
|
2
|
+
"version": "20.13.0",
|
|
3
3
|
"name": "@substrate/api-sidecar",
|
|
4
4
|
"description": "REST service that makes it easy to interact with blockchain nodes built using Substrate's FRAME framework.",
|
|
5
5
|
"homepage": "https://github.com/paritytech/substrate-api-sidecar#readme",
|
|
@@ -61,17 +61,17 @@
|
|
|
61
61
|
"@substrate/calc": "0.3.1",
|
|
62
62
|
"argparse": "^2.0.1",
|
|
63
63
|
"confmgr": "^1.1.0",
|
|
64
|
-
"express": "^5.
|
|
64
|
+
"express": "^5.2.0",
|
|
65
65
|
"express-winston": "^4.2.0",
|
|
66
66
|
"http-errors": "^2.0.1",
|
|
67
|
-
"lru-cache": "^11.2.
|
|
67
|
+
"lru-cache": "^11.2.4",
|
|
68
68
|
"prom-client": "^15.1.3",
|
|
69
69
|
"rxjs": "^7.8.2",
|
|
70
|
-
"winston": "^3.
|
|
70
|
+
"winston": "^3.19.0",
|
|
71
71
|
"winston-loki": "^6.1.3"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@acala-network/chopsticks-testing": "^1.2.
|
|
74
|
+
"@acala-network/chopsticks-testing": "^1.2.5",
|
|
75
75
|
"@substrate/dev": "^0.9.0",
|
|
76
76
|
"@types/argparse": "2.0.17",
|
|
77
77
|
"@types/express": "^5.0.5",
|
|
@@ -9,7 +9,12 @@ import AbstractController from '../AbstractController';
|
|
|
9
9
|
* Query params:
|
|
10
10
|
* - (Optional)`at`: Block at which to retrieve runtime version information at. Block
|
|
11
11
|
* identifier, as the block height or block hash. Defaults to most recent block.
|
|
12
|
-
* - (Optional)`
|
|
12
|
+
* - (Optional)`includeClaimable`: When set to 'true', calculates and includes vested
|
|
13
|
+
* amounts for each vesting schedule plus the claimable amount. This may require a
|
|
14
|
+
* relay chain connection for Asset Hub post-migration queries. Defaults to 'false'.
|
|
15
|
+
* - (Optional)`useRcBlock`: When set to 'true', uses the relay chain block specified in the
|
|
16
|
+
* 'at' parameter to determine corresponding Asset Hub block(s). Only supported for
|
|
17
|
+
* Asset Hub endpoints.
|
|
13
18
|
*
|
|
14
19
|
* Returns:
|
|
15
20
|
* - When using `useRcBlock` parameter: An array of response objects, one for each Asset Hub block found
|
|
@@ -18,13 +23,23 @@ import AbstractController from '../AbstractController';
|
|
|
18
23
|
*
|
|
19
24
|
* Response object structure:
|
|
20
25
|
* - `at`: Block number and hash at which the call was made.
|
|
21
|
-
* - `vesting`:
|
|
26
|
+
* - `vesting`: Array of vesting schedules for an account.
|
|
22
27
|
* - `locked`: Number of tokens locked at start.
|
|
23
28
|
* - `perBlock`: Number of tokens that gets unlocked every block after `startingBlock`.
|
|
24
29
|
* - `startingBlock`: Starting block for unlocking(vesting).
|
|
25
|
-
*
|
|
30
|
+
* - `vested`: (Only when `includeClaimable=true`) Amount that has vested based on time elapsed.
|
|
31
|
+
* - `vestedBalance`: (Only when `includeClaimable=true`) Total vested across all schedules.
|
|
32
|
+
* - `vestingTotal`: (Only when `includeClaimable=true`) Total locked across all schedules.
|
|
33
|
+
* - `vestedClaimable`: (Only when `includeClaimable=true`) Actual amount that can be claimed now.
|
|
34
|
+
* - `blockNumberForCalculation`: (Only when `includeClaimable=true`) The block number used for calculations.
|
|
35
|
+
* - `blockNumberSource`: (Only when `includeClaimable=true`) Which chain's block number was used ('relay' or 'self').
|
|
36
|
+
* - `rcBlockHash`: The relay chain block hash. Only present when `useRcBlock` parameter is used.
|
|
37
|
+
* - `rcBlockNumber`: The relay chain block number. Only present when `useRcBlock` parameter is used.
|
|
26
38
|
* - `ahTimestamp`: The Asset Hub block timestamp. Only present when `useRcBlock` parameter is used.
|
|
27
39
|
*
|
|
40
|
+
* Note: When `includeClaimable=true` for Asset Hub post-migration queries, a relay chain
|
|
41
|
+
* connection is required since vesting schedules use relay chain block numbers.
|
|
42
|
+
*
|
|
28
43
|
* Substrate Reference:
|
|
29
44
|
* - Vesting Pallet: https://crates.parity.io/pallet_vesting/index.html
|
|
30
45
|
* - `VestingInfo`: https://crates.parity.io/pallet_vesting/struct.VestingInfo.html
|
|
@@ -18,6 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
|
21
22
|
const middleware_1 = require("../../middleware");
|
|
22
23
|
const services_1 = require("../../services");
|
|
23
24
|
const AbstractController_1 = __importDefault(require("../AbstractController"));
|
|
@@ -30,7 +31,12 @@ const AbstractController_1 = __importDefault(require("../AbstractController"));
|
|
|
30
31
|
* Query params:
|
|
31
32
|
* - (Optional)`at`: Block at which to retrieve runtime version information at. Block
|
|
32
33
|
* identifier, as the block height or block hash. Defaults to most recent block.
|
|
33
|
-
* - (Optional)`
|
|
34
|
+
* - (Optional)`includeClaimable`: When set to 'true', calculates and includes vested
|
|
35
|
+
* amounts for each vesting schedule plus the claimable amount. This may require a
|
|
36
|
+
* relay chain connection for Asset Hub post-migration queries. Defaults to 'false'.
|
|
37
|
+
* - (Optional)`useRcBlock`: When set to 'true', uses the relay chain block specified in the
|
|
38
|
+
* 'at' parameter to determine corresponding Asset Hub block(s). Only supported for
|
|
39
|
+
* Asset Hub endpoints.
|
|
34
40
|
*
|
|
35
41
|
* Returns:
|
|
36
42
|
* - When using `useRcBlock` parameter: An array of response objects, one for each Asset Hub block found
|
|
@@ -39,13 +45,23 @@ const AbstractController_1 = __importDefault(require("../AbstractController"));
|
|
|
39
45
|
*
|
|
40
46
|
* Response object structure:
|
|
41
47
|
* - `at`: Block number and hash at which the call was made.
|
|
42
|
-
* - `vesting`:
|
|
48
|
+
* - `vesting`: Array of vesting schedules for an account.
|
|
43
49
|
* - `locked`: Number of tokens locked at start.
|
|
44
50
|
* - `perBlock`: Number of tokens that gets unlocked every block after `startingBlock`.
|
|
45
51
|
* - `startingBlock`: Starting block for unlocking(vesting).
|
|
46
|
-
*
|
|
52
|
+
* - `vested`: (Only when `includeClaimable=true`) Amount that has vested based on time elapsed.
|
|
53
|
+
* - `vestedBalance`: (Only when `includeClaimable=true`) Total vested across all schedules.
|
|
54
|
+
* - `vestingTotal`: (Only when `includeClaimable=true`) Total locked across all schedules.
|
|
55
|
+
* - `vestedClaimable`: (Only when `includeClaimable=true`) Actual amount that can be claimed now.
|
|
56
|
+
* - `blockNumberForCalculation`: (Only when `includeClaimable=true`) The block number used for calculations.
|
|
57
|
+
* - `blockNumberSource`: (Only when `includeClaimable=true`) Which chain's block number was used ('relay' or 'self').
|
|
58
|
+
* - `rcBlockHash`: The relay chain block hash. Only present when `useRcBlock` parameter is used.
|
|
59
|
+
* - `rcBlockNumber`: The relay chain block number. Only present when `useRcBlock` parameter is used.
|
|
47
60
|
* - `ahTimestamp`: The Asset Hub block timestamp. Only present when `useRcBlock` parameter is used.
|
|
48
61
|
*
|
|
62
|
+
* Note: When `includeClaimable=true` for Asset Hub post-migration queries, a relay chain
|
|
63
|
+
* connection is required since vesting schedules use relay chain block numbers.
|
|
64
|
+
*
|
|
49
65
|
* Substrate Reference:
|
|
50
66
|
* - Vesting Pallet: https://crates.parity.io/pallet_vesting/index.html
|
|
51
67
|
* - `VestingInfo`: https://crates.parity.io/pallet_vesting/struct.VestingInfo.html
|
|
@@ -59,7 +75,8 @@ class AccountsVestingInfoController extends AbstractController_1.default {
|
|
|
59
75
|
* @param req Express Request
|
|
60
76
|
* @param res Express Response
|
|
61
77
|
*/
|
|
62
|
-
this.getAccountVestingInfo = async ({ params: { address }, query: { at, useRcBlock } }, res) => {
|
|
78
|
+
this.getAccountVestingInfo = async ({ params: { address }, query: { at, useRcBlock, includeClaimable } }, res) => {
|
|
79
|
+
const shouldIncludeClaimable = includeClaimable === 'true';
|
|
63
80
|
if (useRcBlock === 'true') {
|
|
64
81
|
const rcAtResults = await this.getHashFromRcAt(at);
|
|
65
82
|
// Return empty array if no Asset Hub blocks found
|
|
@@ -70,7 +87,8 @@ class AccountsVestingInfoController extends AbstractController_1.default {
|
|
|
70
87
|
// Process each Asset Hub block found
|
|
71
88
|
const results = [];
|
|
72
89
|
for (const { ahHash, rcBlockHash, rcBlockNumber } of rcAtResults) {
|
|
73
|
-
|
|
90
|
+
// Pass rcBlockNumber to skip relay block search when includeClaimable is used
|
|
91
|
+
const result = await this.service.fetchAccountVestingInfo(ahHash, address, shouldIncludeClaimable, new bn_js_1.default(rcBlockNumber));
|
|
74
92
|
const apiAt = await this.api.at(ahHash);
|
|
75
93
|
const ahTimestamp = await apiAt.query.timestamp.now();
|
|
76
94
|
const enhancedResult = {
|
|
@@ -85,7 +103,7 @@ class AccountsVestingInfoController extends AbstractController_1.default {
|
|
|
85
103
|
}
|
|
86
104
|
else {
|
|
87
105
|
const hash = await this.getHashFromAt(at);
|
|
88
|
-
const result = await this.service.fetchAccountVestingInfo(hash, address);
|
|
106
|
+
const result = await this.service.fetchAccountVestingInfo(hash, address, shouldIncludeClaimable);
|
|
89
107
|
AccountsVestingInfoController.sanitizedSend(res, result);
|
|
90
108
|
}
|
|
91
109
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountsVestingInfoController.js","sourceRoot":"","sources":["../../../../src/controllers/accounts/AccountsVestingInfoController.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,8CAA8C;AAC9C,EAAE;AACF,gFAAgF;AAChF,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,wEAAwE;;;;;
|
|
1
|
+
{"version":3,"file":"AccountsVestingInfoController.js","sourceRoot":"","sources":["../../../../src/controllers/accounts/AccountsVestingInfoController.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,8CAA8C;AAC9C,EAAE;AACF,gFAAgF;AAChF,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,iEAAiE;AACj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,CAAC;oBACxC,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;oBAEtD,MAAM,cAAc,GAAG;wBACtB,GAAG,MAAM;wBACT,WAAW,EAAE,WAAW,CAAC,QAAQ,EAAE;wBACnC,aAAa;wBACb,WAAW,EAAE,WAAW,CAAC,QAAQ,EAAE;qBACnC,CAAC;oBAEF,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;gBAC9B,CAAC;gBAED,6BAA6B,CAAC,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YAC3D,CAAC;iBAAM,CAAC;gBACP,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;gBAC1C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,uBAAuB,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,CAAC,CAAC;gBACjG,6BAA6B,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YAC1D,CAAC;QACF,CAAC,CAAC;QA5DD,IAAI,CAAC,UAAU,EAAE,CAAC;IACnB,CAAC;IAES,UAAU;QACnB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,4BAAe,EAAE,+BAAkB,CAAC,CAAC;QAEhE,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IACpE,CAAC;;AAZM,4CAAc,GAAG,qBAAqB,AAAxB,CAAyB;AACvC,6CAAe,GAAG,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,AAArC,CAAsC;kBAFxC,6BAA6B"}
|
|
@@ -9,13 +9,24 @@ import AbstractController from '../../AbstractController';
|
|
|
9
9
|
* Query params:
|
|
10
10
|
* - (Optional)`at`: Block at which to retrieve vesting information at. Block
|
|
11
11
|
* identifier, as the block height or block hash. Defaults to most recent block.
|
|
12
|
+
* - (Optional)`includeClaimable`: When set to 'true', calculates and includes vested
|
|
13
|
+
* amounts for each vesting schedule plus the claimable amount. Defaults to 'false'.
|
|
12
14
|
*
|
|
13
15
|
* Returns:
|
|
14
16
|
* - `at`: Block number and hash at which the call was made.
|
|
15
|
-
* - `vesting`:
|
|
17
|
+
* - `vesting`: Array of vesting schedules for an account.
|
|
16
18
|
* - `locked`: Number of tokens locked at start.
|
|
17
19
|
* - `perBlock`: Number of tokens that gets unlocked every block after `startingBlock`.
|
|
18
20
|
* - `startingBlock`: Starting block for unlocking(vesting).
|
|
21
|
+
* - `vested`: (Only when `includeClaimable=true`) Amount that has vested based on time elapsed.
|
|
22
|
+
* - `vestedBalance`: (Only when `includeClaimable=true`) Total vested across all schedules.
|
|
23
|
+
* - `vestingTotal`: (Only when `includeClaimable=true`) Total locked across all schedules.
|
|
24
|
+
* - `vestedClaimable`: (Only when `includeClaimable=true`) Actual amount that can be claimed now.
|
|
25
|
+
* - `blockNumberForCalculation`: (Only when `includeClaimable=true`) The block number used for calculations.
|
|
26
|
+
* - `blockNumberSource`: (Only when `includeClaimable=true`) Which chain's block number was used ('relay' or 'self').
|
|
27
|
+
*
|
|
28
|
+
* Note: For relay chain pre-migration queries, vested amounts are calculated using the relay
|
|
29
|
+
* chain's own block number. Post-migration, vesting has moved to Asset Hub.
|
|
19
30
|
*
|
|
20
31
|
* Substrate Reference:
|
|
21
32
|
* - Vesting Pallet: https://crates.parity.io/pallet_vesting/index.html
|
|
@@ -31,13 +31,24 @@ const AbstractController_1 = __importDefault(require("../../AbstractController")
|
|
|
31
31
|
* Query params:
|
|
32
32
|
* - (Optional)`at`: Block at which to retrieve vesting information at. Block
|
|
33
33
|
* identifier, as the block height or block hash. Defaults to most recent block.
|
|
34
|
+
* - (Optional)`includeClaimable`: When set to 'true', calculates and includes vested
|
|
35
|
+
* amounts for each vesting schedule plus the claimable amount. Defaults to 'false'.
|
|
34
36
|
*
|
|
35
37
|
* Returns:
|
|
36
38
|
* - `at`: Block number and hash at which the call was made.
|
|
37
|
-
* - `vesting`:
|
|
39
|
+
* - `vesting`: Array of vesting schedules for an account.
|
|
38
40
|
* - `locked`: Number of tokens locked at start.
|
|
39
41
|
* - `perBlock`: Number of tokens that gets unlocked every block after `startingBlock`.
|
|
40
42
|
* - `startingBlock`: Starting block for unlocking(vesting).
|
|
43
|
+
* - `vested`: (Only when `includeClaimable=true`) Amount that has vested based on time elapsed.
|
|
44
|
+
* - `vestedBalance`: (Only when `includeClaimable=true`) Total vested across all schedules.
|
|
45
|
+
* - `vestingTotal`: (Only when `includeClaimable=true`) Total locked across all schedules.
|
|
46
|
+
* - `vestedClaimable`: (Only when `includeClaimable=true`) Actual amount that can be claimed now.
|
|
47
|
+
* - `blockNumberForCalculation`: (Only when `includeClaimable=true`) The block number used for calculations.
|
|
48
|
+
* - `blockNumberSource`: (Only when `includeClaimable=true`) Which chain's block number was used ('relay' or 'self').
|
|
49
|
+
*
|
|
50
|
+
* Note: For relay chain pre-migration queries, vested amounts are calculated using the relay
|
|
51
|
+
* chain's own block number. Post-migration, vesting has moved to Asset Hub.
|
|
41
52
|
*
|
|
42
53
|
* Substrate Reference:
|
|
43
54
|
* - Vesting Pallet: https://crates.parity.io/pallet_vesting/index.html
|
|
@@ -58,14 +69,15 @@ class RcAccountsVestingInfoController extends AbstractController_1.default {
|
|
|
58
69
|
* @param req Express Request
|
|
59
70
|
* @param res Express Response
|
|
60
71
|
*/
|
|
61
|
-
this.getAccountVestingInfo = async ({ params: { address }, query: { at } }, res) => {
|
|
72
|
+
this.getAccountVestingInfo = async ({ params: { address }, query: { at, includeClaimable } }, res) => {
|
|
62
73
|
var _a;
|
|
63
74
|
const rcApi = (_a = apiRegistry_1.ApiPromiseRegistry.getApiByType('relay')[0]) === null || _a === void 0 ? void 0 : _a.api;
|
|
64
75
|
if (!rcApi) {
|
|
65
76
|
throw new Error('Relay chain API not found, please use SAS_SUBSTRATE_MULTI_CHAIN_URL env variable');
|
|
66
77
|
}
|
|
78
|
+
const shouldIncludeClaimable = includeClaimable === 'true';
|
|
67
79
|
const hash = await this.getHashFromAt(at, { api: rcApi });
|
|
68
|
-
const result = await this.service.fetchAccountVestingInfo(hash, address);
|
|
80
|
+
const result = await this.service.fetchAccountVestingInfo(hash, address, shouldIncludeClaimable);
|
|
69
81
|
RcAccountsVestingInfoController.sanitizedSend(res, result);
|
|
70
82
|
};
|
|
71
83
|
this.initRoutes();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RcAccountsVestingInfoController.js","sourceRoot":"","sources":["../../../../../src/controllers/rc/accounts/RcAccountsVestingInfoController.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,8CAA8C;AAC9C,EAAE;AACF,gFAAgF;AAChF,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,wEAAwE;;;;;AAKxE,sDAA0D;AAC1D,oDAAsD;AACtD,gDAA+D;AAC/D,kFAA0D;AAE1D
|
|
1
|
+
{"version":3,"file":"RcAccountsVestingInfoController.js","sourceRoot":"","sources":["../../../../../src/controllers/rc/accounts/RcAccountsVestingInfoController.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,8CAA8C;AAC9C,EAAE;AACF,gFAAgF;AAChF,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,wEAAwE;;;;;AAKxE,sDAA0D;AAC1D,oDAAsD;AACtD,gDAA+D;AAC/D,kFAA0D;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAqB,+BAAgC,SAAQ,4BAA8C;IAI1G,YAAY,IAAY;;QACv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CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,4BAAe,CAAC,CAAC;QAE5C,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IACpE,CAAC;;AAjBM,8CAAc,GAAG,uBAAuB,AAA1B,CAA2B;AACzC,+CAAe,GAAG,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,AAArC,CAAsC;kBAFxC,+BAA+B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BlockHash } from '@polkadot/types/interfaces';
|
|
2
|
+
import BN from 'bn.js';
|
|
2
3
|
import { IAccountVestingInfo } from 'src/types/responses';
|
|
3
4
|
import { AbstractService } from '../AbstractService';
|
|
4
5
|
export declare class AccountsVestingInfoService extends AbstractService {
|
|
@@ -7,6 +8,46 @@ export declare class AccountsVestingInfoService extends AbstractService {
|
|
|
7
8
|
*
|
|
8
9
|
* @param hash `BlockHash` to make call at
|
|
9
10
|
* @param address address of the account to get the vesting info of
|
|
11
|
+
* @param includeVested whether to calculate and include vested amounts (default: false)
|
|
12
|
+
* @param knownRelayBlockNumber optional relay block number to use for calculations (skips search when provided)
|
|
10
13
|
*/
|
|
11
|
-
fetchAccountVestingInfo(hash: BlockHash, address: string): Promise<IAccountVestingInfo>;
|
|
14
|
+
fetchAccountVestingInfo(hash: BlockHash, address: string, includeVested?: boolean, knownRelayBlockNumber?: BN): Promise<IAccountVestingInfo>;
|
|
15
|
+
/**
|
|
16
|
+
* Get the vesting lock amount from balances.locks.
|
|
17
|
+
* Returns 0 if no vesting lock exists.
|
|
18
|
+
*/
|
|
19
|
+
private getVestingLocked;
|
|
20
|
+
/**
|
|
21
|
+
* Calculate vested amounts for vesting schedules.
|
|
22
|
+
* Returns null if calculation cannot be performed (e.g., during migration window).
|
|
23
|
+
*/
|
|
24
|
+
private calculateVestingAmounts;
|
|
25
|
+
/**
|
|
26
|
+
* Calculate vested amounts for Asset Hub chains.
|
|
27
|
+
* Post-migration: uses relay chain inclusion block number for calculations.
|
|
28
|
+
* If knownRelayBlockNumber is provided, uses it directly instead of searching.
|
|
29
|
+
*/
|
|
30
|
+
private calculateForAssetHub;
|
|
31
|
+
/**
|
|
32
|
+
* Calculate vested amounts for relay chains.
|
|
33
|
+
* Pre-migration: uses the chain's own block number for calculations.
|
|
34
|
+
*/
|
|
35
|
+
private calculateForRelayChain;
|
|
36
|
+
/**
|
|
37
|
+
* Perform the actual vesting calculation for vesting schedules.
|
|
38
|
+
*/
|
|
39
|
+
private performCalculation;
|
|
40
|
+
/**
|
|
41
|
+
* Create a result with zero claimable for all schedules.
|
|
42
|
+
* Used during migration windows or post-migration on relay chain.
|
|
43
|
+
*/
|
|
44
|
+
private createZeroClaimableResult;
|
|
45
|
+
/**
|
|
46
|
+
* Determine migration state for an Asset Hub block.
|
|
47
|
+
*/
|
|
48
|
+
private getAssetHubMigrationState;
|
|
49
|
+
/**
|
|
50
|
+
* Determine migration state for a relay chain block.
|
|
51
|
+
*/
|
|
52
|
+
private getRelayChainMigrationState;
|
|
12
53
|
}
|
|
@@ -14,18 +14,38 @@
|
|
|
14
14
|
//
|
|
15
15
|
// You should have received a copy of the GNU General Public License
|
|
16
16
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
17
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
21
|
exports.AccountsVestingInfoService = void 0;
|
|
22
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
|
19
23
|
const http_errors_1 = require("http-errors");
|
|
24
|
+
const apiRegistry_1 = require("../../apiRegistry");
|
|
25
|
+
const chains_config_1 = require("../../chains-config");
|
|
26
|
+
const getRelayParentNumber_1 = require("../../util/relay/getRelayParentNumber");
|
|
27
|
+
const vestingCalculations_1 = require("../../util/vesting/vestingCalculations");
|
|
20
28
|
const AbstractService_1 = require("../AbstractService");
|
|
29
|
+
const consts_1 = require("../consts");
|
|
30
|
+
/**
|
|
31
|
+
* Asset Hub parachain ID on relay chains
|
|
32
|
+
*/
|
|
33
|
+
const ASSET_HUB_PARA_ID = 1000;
|
|
34
|
+
/**
|
|
35
|
+
* Vesting lock ID used in balances.locks
|
|
36
|
+
* This is "vesting " padded to 8 bytes (0x76657374696e6720)
|
|
37
|
+
*/
|
|
38
|
+
const VESTING_ID = '0x76657374696e6720';
|
|
21
39
|
class AccountsVestingInfoService extends AbstractService_1.AbstractService {
|
|
22
40
|
/**
|
|
23
41
|
* Fetch vesting information for an account at a given block.
|
|
24
42
|
*
|
|
25
43
|
* @param hash `BlockHash` to make call at
|
|
26
44
|
* @param address address of the account to get the vesting info of
|
|
45
|
+
* @param includeVested whether to calculate and include vested amounts (default: false)
|
|
46
|
+
* @param knownRelayBlockNumber optional relay block number to use for calculations (skips search when provided)
|
|
27
47
|
*/
|
|
28
|
-
async fetchAccountVestingInfo(hash, address) {
|
|
48
|
+
async fetchAccountVestingInfo(hash, address, includeVested = false, knownRelayBlockNumber) {
|
|
29
49
|
const { api } = this;
|
|
30
50
|
const historicApi = await api.at(hash);
|
|
31
51
|
if (!historicApi.query.vesting) {
|
|
@@ -37,9 +57,10 @@ class AccountsVestingInfoService extends AbstractService_1.AbstractService {
|
|
|
37
57
|
]).catch((err) => {
|
|
38
58
|
throw this.createHttpErrorForAddr(address, err);
|
|
39
59
|
});
|
|
60
|
+
const blockNumber = number.unwrap().toNumber();
|
|
40
61
|
const at = {
|
|
41
62
|
hash,
|
|
42
|
-
height:
|
|
63
|
+
height: blockNumber.toString(10),
|
|
43
64
|
};
|
|
44
65
|
if (vesting.isNone) {
|
|
45
66
|
return {
|
|
@@ -47,13 +68,223 @@ class AccountsVestingInfoService extends AbstractService_1.AbstractService {
|
|
|
47
68
|
vesting: [],
|
|
48
69
|
};
|
|
49
70
|
}
|
|
50
|
-
|
|
51
|
-
|
|
71
|
+
const unwrapVesting = vesting.unwrap();
|
|
72
|
+
const vestingArray = Array.isArray(unwrapVesting) ? unwrapVesting : [unwrapVesting];
|
|
73
|
+
// If includeVested is not requested, return raw vesting data
|
|
74
|
+
if (!includeVested) {
|
|
52
75
|
return {
|
|
53
76
|
at,
|
|
54
|
-
vesting:
|
|
77
|
+
vesting: vestingArray,
|
|
55
78
|
};
|
|
56
79
|
}
|
|
80
|
+
// Get the on-chain vesting lock amount from balances.locks
|
|
81
|
+
const vestingLocked = await this.getVestingLocked(historicApi, address);
|
|
82
|
+
// Calculate vested amounts based on chain type and migration state
|
|
83
|
+
const vestingResult = await this.calculateVestingAmounts(hash, blockNumber, vestingArray, vestingLocked, knownRelayBlockNumber);
|
|
84
|
+
if (vestingResult === null) {
|
|
85
|
+
// Unable to calculate (e.g., during migration or missing relay connection)
|
|
86
|
+
// Return raw vesting data without calculations
|
|
87
|
+
return {
|
|
88
|
+
at,
|
|
89
|
+
vesting: vestingArray,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
at,
|
|
94
|
+
vesting: vestingResult.schedules,
|
|
95
|
+
vestedBalance: vestingResult.vestedBalance,
|
|
96
|
+
vestingTotal: vestingResult.vestingTotal,
|
|
97
|
+
vestedClaimable: vestingResult.vestedClaimable,
|
|
98
|
+
blockNumberForCalculation: vestingResult.blockNumberForCalculation,
|
|
99
|
+
blockNumberSource: vestingResult.blockNumberSource,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Get the vesting lock amount from balances.locks.
|
|
104
|
+
* Returns 0 if no vesting lock exists.
|
|
105
|
+
*/
|
|
106
|
+
async getVestingLocked(historicApi, address) {
|
|
107
|
+
var _a;
|
|
108
|
+
if (!((_a = historicApi.query.balances) === null || _a === void 0 ? void 0 : _a.locks)) {
|
|
109
|
+
return new bn_js_1.default(0);
|
|
110
|
+
}
|
|
111
|
+
const locks = await historicApi.query.balances.locks(address);
|
|
112
|
+
for (const lock of locks) {
|
|
113
|
+
if (lock.id.toHex() === VESTING_ID) {
|
|
114
|
+
return new bn_js_1.default(lock.amount.toString());
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return new bn_js_1.default(0);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Calculate vested amounts for vesting schedules.
|
|
121
|
+
* Returns null if calculation cannot be performed (e.g., during migration window).
|
|
122
|
+
*/
|
|
123
|
+
async calculateVestingAmounts(hash, blockNumber, vestingArray, vestingLocked, knownRelayBlockNumber) {
|
|
124
|
+
const specName = this.specName;
|
|
125
|
+
const isAssetHub = chains_config_1.assetHubSpecNames.has(specName);
|
|
126
|
+
if (isAssetHub) {
|
|
127
|
+
return this.calculateForAssetHub(hash, blockNumber, vestingArray, vestingLocked, knownRelayBlockNumber);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
return this.calculateForRelayChain(blockNumber, vestingArray, vestingLocked);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Calculate vested amounts for Asset Hub chains.
|
|
135
|
+
* Post-migration: uses relay chain inclusion block number for calculations.
|
|
136
|
+
* If knownRelayBlockNumber is provided, uses it directly instead of searching.
|
|
137
|
+
*/
|
|
138
|
+
async calculateForAssetHub(hash, blockNumber, vestingArray, vestingLocked, knownRelayBlockNumber) {
|
|
139
|
+
const specName = this.specName;
|
|
140
|
+
const boundaries = consts_1.MIGRATION_BOUNDARIES[specName];
|
|
141
|
+
if (!boundaries) {
|
|
142
|
+
// No migration boundaries defined for this Asset Hub - can't calculate
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
const migrationState = this.getAssetHubMigrationState(blockNumber, boundaries);
|
|
146
|
+
if (migrationState === 'during-migration') {
|
|
147
|
+
// During migration window, return 0 for claimable
|
|
148
|
+
return this.createZeroClaimableResult(vestingArray, vestingLocked, blockNumber.toString(), 'self');
|
|
149
|
+
}
|
|
150
|
+
if (migrationState === 'pre-migration') {
|
|
151
|
+
// Pre-migration: vesting didn't exist on Asset Hub
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
// Post-migration: need relay chain block number for calculations
|
|
155
|
+
// If knownRelayBlockNumber is provided (e.g., from useRcBlock), use it directly
|
|
156
|
+
if (knownRelayBlockNumber !== undefined) {
|
|
157
|
+
return this.performCalculation(vestingArray, vestingLocked, knownRelayBlockNumber, 'relay');
|
|
158
|
+
}
|
|
159
|
+
// Otherwise, search for the relay chain inclusion block number
|
|
160
|
+
const relayApis = apiRegistry_1.ApiPromiseRegistry.getApiByType('relay');
|
|
161
|
+
if (relayApis.length === 0) {
|
|
162
|
+
throw new http_errors_1.InternalServerError('Relay chain connection required for vesting calculations on Asset Hub post-migration. ' +
|
|
163
|
+
'Please configure MULTI_CHAIN_URL with a relay chain endpoint.');
|
|
164
|
+
}
|
|
165
|
+
const rcApi = relayApis[0].api;
|
|
166
|
+
const inclusionResult = await (0, getRelayParentNumber_1.getInclusionBlockNumber)(this.api, rcApi, hash, ASSET_HUB_PARA_ID);
|
|
167
|
+
if (!inclusionResult.found || inclusionResult.inclusionBlockNumber === null) {
|
|
168
|
+
// Inclusion not found within search depth
|
|
169
|
+
// Fall back to relay parent number for calculation
|
|
170
|
+
return this.performCalculation(vestingArray, vestingLocked, new bn_js_1.default(inclusionResult.relayParentNumber), 'relay');
|
|
171
|
+
}
|
|
172
|
+
return this.performCalculation(vestingArray, vestingLocked, new bn_js_1.default(inclusionResult.inclusionBlockNumber), 'relay');
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Calculate vested amounts for relay chains.
|
|
176
|
+
* Pre-migration: uses the chain's own block number for calculations.
|
|
177
|
+
*/
|
|
178
|
+
calculateForRelayChain(blockNumber, vestingArray, vestingLocked) {
|
|
179
|
+
const specName = this.specName;
|
|
180
|
+
const assetHubSpec = consts_1.relayToSpecMapping.get(specName);
|
|
181
|
+
if (!assetHubSpec) {
|
|
182
|
+
// Not a known relay chain with migration boundaries
|
|
183
|
+
// Use single-chain calculation
|
|
184
|
+
return this.performCalculation(vestingArray, vestingLocked, new bn_js_1.default(blockNumber), 'self');
|
|
185
|
+
}
|
|
186
|
+
const boundaries = consts_1.MIGRATION_BOUNDARIES[assetHubSpec];
|
|
187
|
+
if (!boundaries) {
|
|
188
|
+
// No boundaries defined, use single-chain calculation
|
|
189
|
+
return this.performCalculation(vestingArray, vestingLocked, new bn_js_1.default(blockNumber), 'self');
|
|
190
|
+
}
|
|
191
|
+
const migrationState = this.getRelayChainMigrationState(blockNumber, boundaries);
|
|
192
|
+
if (migrationState === 'during-migration') {
|
|
193
|
+
// During migration window, return 0 for claimable
|
|
194
|
+
return this.createZeroClaimableResult(vestingArray, vestingLocked, blockNumber.toString(), 'self');
|
|
195
|
+
}
|
|
196
|
+
if (migrationState === 'post-migration') {
|
|
197
|
+
// Post-migration: vesting no longer exists on relay chain
|
|
198
|
+
// Return 0 for claimable since vesting has migrated
|
|
199
|
+
return this.createZeroClaimableResult(vestingArray, vestingLocked, blockNumber.toString(), 'self');
|
|
200
|
+
}
|
|
201
|
+
// Pre-migration: use relay chain's own block number
|
|
202
|
+
return this.performCalculation(vestingArray, vestingLocked, new bn_js_1.default(blockNumber), 'self');
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Perform the actual vesting calculation for vesting schedules.
|
|
206
|
+
*/
|
|
207
|
+
performCalculation(vestingArray, vestingLocked, currentBlock, source) {
|
|
208
|
+
// Convert VestingInfo to calculation interface
|
|
209
|
+
const calcSchedules = vestingArray.map((v) => ({
|
|
210
|
+
locked: new bn_js_1.default(v.locked.toString()),
|
|
211
|
+
perBlock: new bn_js_1.default(v.perBlock.toString()),
|
|
212
|
+
startingBlock: new bn_js_1.default(v.startingBlock.toString()),
|
|
213
|
+
}));
|
|
214
|
+
// Calculate vested for each schedule
|
|
215
|
+
const schedules = vestingArray.map((v, idx) => ({
|
|
216
|
+
locked: v.locked.toString(),
|
|
217
|
+
perBlock: v.perBlock.toString(),
|
|
218
|
+
startingBlock: v.startingBlock.toString(),
|
|
219
|
+
vested: (0, vestingCalculations_1.calculateVested)(currentBlock, calcSchedules[idx]).toString(),
|
|
220
|
+
}));
|
|
221
|
+
// Calculate aggregate values
|
|
222
|
+
const vestedBalance = (0, vestingCalculations_1.calculateTotalVested)(currentBlock, calcSchedules);
|
|
223
|
+
const vestingTotal = (0, vestingCalculations_1.calculateVestingTotal)(calcSchedules);
|
|
224
|
+
const vestedClaimable = (0, vestingCalculations_1.calculateVestedClaimable)(vestingLocked, vestingTotal, vestedBalance);
|
|
225
|
+
return {
|
|
226
|
+
schedules,
|
|
227
|
+
vestedBalance: vestedBalance.toString(),
|
|
228
|
+
vestingTotal: vestingTotal.toString(),
|
|
229
|
+
vestedClaimable: vestedClaimable.toString(),
|
|
230
|
+
blockNumberForCalculation: currentBlock.toString(),
|
|
231
|
+
blockNumberSource: source,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Create a result with zero claimable for all schedules.
|
|
236
|
+
* Used during migration windows or post-migration on relay chain.
|
|
237
|
+
*/
|
|
238
|
+
createZeroClaimableResult(vestingArray, _vestingLocked, blockNumber, source) {
|
|
239
|
+
// Convert VestingInfo to calculation interface
|
|
240
|
+
const calcSchedules = vestingArray.map((v) => ({
|
|
241
|
+
locked: new bn_js_1.default(v.locked.toString()),
|
|
242
|
+
perBlock: new bn_js_1.default(v.perBlock.toString()),
|
|
243
|
+
startingBlock: new bn_js_1.default(v.startingBlock.toString()),
|
|
244
|
+
}));
|
|
245
|
+
const vestingTotal = (0, vestingCalculations_1.calculateVestingTotal)(calcSchedules);
|
|
246
|
+
const schedules = vestingArray.map((v) => ({
|
|
247
|
+
locked: v.locked.toString(),
|
|
248
|
+
perBlock: v.perBlock.toString(),
|
|
249
|
+
startingBlock: v.startingBlock.toString(),
|
|
250
|
+
vested: '0',
|
|
251
|
+
}));
|
|
252
|
+
return {
|
|
253
|
+
schedules,
|
|
254
|
+
vestedBalance: '0',
|
|
255
|
+
vestingTotal: vestingTotal.toString(),
|
|
256
|
+
vestedClaimable: '0',
|
|
257
|
+
blockNumberForCalculation: blockNumber,
|
|
258
|
+
blockNumberSource: source,
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Determine migration state for an Asset Hub block.
|
|
263
|
+
*/
|
|
264
|
+
getAssetHubMigrationState(blockNumber, boundaries) {
|
|
265
|
+
if (blockNumber < boundaries.assetHubMigrationStartedAt) {
|
|
266
|
+
return 'pre-migration';
|
|
267
|
+
}
|
|
268
|
+
else if (blockNumber >= boundaries.assetHubMigrationEndedAt) {
|
|
269
|
+
return 'post-migration';
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
return 'during-migration';
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Determine migration state for a relay chain block.
|
|
277
|
+
*/
|
|
278
|
+
getRelayChainMigrationState(blockNumber, boundaries) {
|
|
279
|
+
if (blockNumber < boundaries.relayMigrationStartedAt) {
|
|
280
|
+
return 'pre-migration';
|
|
281
|
+
}
|
|
282
|
+
else if (blockNumber >= boundaries.relayMigrationEndedAt) {
|
|
283
|
+
return 'post-migration';
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
return 'during-migration';
|
|
287
|
+
}
|
|
57
288
|
}
|
|
58
289
|
}
|
|
59
290
|
exports.AccountsVestingInfoService = AccountsVestingInfoService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountsVestingInfoService.js","sourceRoot":"","sources":["../../../../src/services/accounts/AccountsVestingInfoService.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,8CAA8C;AAC9C,EAAE;AACF,gFAAgF;AAChF,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,wEAAwE
|
|
1
|
+
{"version":3,"file":"AccountsVestingInfoService.js","sourceRoot":"","sources":["../../../../src/services/accounts/AccountsVestingInfoService.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,8CAA8C;AAC9C,EAAE;AACF,gFAAgF;AAChF,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,wEAAwE;;;;;;AAIxE,kDAAuB;AACvB,6CAA8D;AAG9D,mDAAuD;AACvD,uDAAwD;AACxD,gFAAgF;AAChF,gFAMgD;AAChD,wDAAqD;AACrD,sCAAqE;AAOrE;;GAEG;AACH,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAE/B;;;GAGG;AACH,MAAM,UAAU,GAAG,oBAAoB,CAAC;AAExC,MAAa,0BAA2B,SAAQ,iCAAe;IAC9D;;;;;;;OAOG;IACH,KAAK,CAAC,uBAAuB,CAC5B,IAAe,EACf,OAAe,EACf,aAAa,GAAG,KAAK,EACrB,qBAA0B;QAE1B,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;QAErB,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;QAEvC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YAChC,MAAM,IAAI,wBAAU,CAAC,uEAAuE,CAAC,CAAC;QAC/F,CAAC;QAED,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YAC/C,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC;YAC7B,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;SAC1C,CAAC,CAAC,KAAK,CAAC,CA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B,aAAa,EAAE,CAAC,CAAC,aAAa,CAAC,QAAQ,EAAE;YACzC,MAAM,EAAE,GAAG;SACX,CAAC,CAAC,CAAC;QAEJ,OAAO;YACN,SAAS;YACT,aAAa,EAAE,GAAG;YAClB,YAAY,EAAE,YAAY,CAAC,QAAQ,EAAE;YACrC,eAAe,EAAE,GAAG;YACpB,yBAAyB,EAAE,WAAW;YACtC,iBAAiB,EAAE,MAAM;SACzB,CAAC;IACH,CAAC;IAED;;OAEG;IACK,yBAAyB,CAChC,WAAmB,EACnB,UAAoF;QAEpF,IAAI,WAAW,GAAG,UAAU,CAAC,0BAA0B,EAAE,CAAC;YACzD,OAAO,eAAe,CAAC;QACxB,CAAC;aAAM,IAAI,WAAW,IAAI,UAAU,CAAC,wBAAwB,EAAE,CAAC;YAC/D,OAAO,gBAAgB,CAAC;QACzB,CAAC;aAAM,CAAC;YACP,OAAO,kBAAkB,CAAC;QAC3B,CAAC;IACF,CAAC;IAED;;OAEG;IACK,2BAA2B,CAClC,WAAmB,EACnB,UAA8E;QAE9E,IAAI,WAAW,GAAG,UAAU,CAAC,uBAAuB,EAAE,CAAC;YACtD,OAAO,eAAe,CAAC;QACxB,CAAC;aAAM,IAAI,WAAW,IAAI,UAAU,CAAC,qBAAqB,EAAE,CAAC;YAC5D,OAAO,gBAAgB,CAAC;QACzB,CAAC;aAAM,CAAC;YACP,OAAO,kBAAkB,CAAC;QAC3B,CAAC;IACF,CAAC;CACD;AAlXD,gEAkXC"}
|
|
@@ -7,18 +7,10 @@ export declare class ParasInclusionService extends AbstractService {
|
|
|
7
7
|
/**
|
|
8
8
|
* Find the relay chain inclusion information for a specific parachain block.
|
|
9
9
|
*
|
|
10
|
-
* @param hash - The
|
|
11
|
-
* @param
|
|
10
|
+
* @param hash - The parachain block hash
|
|
11
|
+
* @param paraId - The parachain ID
|
|
12
|
+
* @param number - The parachain block number
|
|
12
13
|
* @param depth - Search depth (defaults to 10)
|
|
13
14
|
*/
|
|
14
15
|
getParachainInclusion(hash: BlockHash, paraId: u32, number: string, depth?: number): Promise<IParachainInclusion>;
|
|
15
|
-
/**
|
|
16
|
-
* Search relay chain blocks for inclusion of a specific parachain block
|
|
17
|
-
* Uses optimized candidate_events runtime API when available, falls back to system events for historical support
|
|
18
|
-
*/
|
|
19
|
-
private searchForInclusion;
|
|
20
|
-
/**
|
|
21
|
-
* Search using system events
|
|
22
|
-
*/
|
|
23
|
-
private searchWithSystemEvents;
|
|
24
16
|
}
|