@substrate/api-sidecar 18.0.0 → 19.0.1
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/README.md +2 -3
- package/build/package.json +9 -9
- package/build/src/chains-config/assetHubPolkadotControllers.js +2 -1
- package/build/src/chains-config/assetHubPolkadotControllers.js.map +1 -1
- package/build/src/controllers/accounts/AccountsStakingPayoutsController.js +3 -0
- package/build/src/controllers/accounts/AccountsStakingPayoutsController.js.map +1 -1
- package/build/src/controllers/paras/ParasController.js +4 -1
- package/build/src/controllers/paras/ParasController.js.map +1 -1
- package/build/src/controllers/runtime/RuntimeMetadataController.d.ts +18 -0
- package/build/src/controllers/runtime/RuntimeMetadataController.js +53 -2
- package/build/src/controllers/runtime/RuntimeMetadataController.js.map +1 -1
- package/build/src/controllers/transaction/TransactionMaterialController.d.ts +12 -0
- package/build/src/controllers/transaction/TransactionMaterialController.js +39 -2
- package/build/src/controllers/transaction/TransactionMaterialController.js.map +1 -1
- package/build/src/services/accounts/AccountsStakingPayoutsService.d.ts +8 -3
- package/build/src/services/accounts/AccountsStakingPayoutsService.js +97 -22
- package/build/src/services/accounts/AccountsStakingPayoutsService.js.map +1 -1
- package/build/src/services/accounts/AccountsStakingPayoutsService.spec.js +2 -2
- package/build/src/services/accounts/AccountsStakingPayoutsService.spec.js.map +1 -1
- package/build/src/services/node/NodeTransactionPoolService.spec.js +6 -10
- package/build/src/services/node/NodeTransactionPoolService.spec.js.map +1 -1
- package/build/src/services/paras/ParasService.d.ts +28 -0
- package/build/src/services/paras/ParasService.js +28 -0
- package/build/src/services/paras/ParasService.js.map +1 -1
- package/build/src/services/runtime/RuntimeMetadataService.d.ts +14 -1
- package/build/src/services/runtime/RuntimeMetadataService.js +36 -1
- package/build/src/services/runtime/RuntimeMetadataService.js.map +1 -1
- package/build/src/services/transaction/TransactionMaterialService.d.ts +8 -1
- package/build/src/services/transaction/TransactionMaterialService.js +45 -1
- package/build/src/services/transaction/TransactionMaterialService.js.map +1 -1
- package/build/src/types/responses/TransactionMaterial.d.ts +3 -3
- package/build/src/types/responses/TransactionMaterial.js +1 -1
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -331,8 +331,7 @@ All the commits in this repo follow the [Conventional Commits spec](https://www.
|
|
|
331
331
|
|
|
332
332
|
### Updating polkadot-js dependencies
|
|
333
333
|
|
|
334
|
-
1.
|
|
335
|
-
and read the release notes for any breaking changes or high priority updates. In order to update all the dependencies and resolutions run `yarn up "@polkadot/*"`.
|
|
334
|
+
1. Whenever the polkadot-js ecosystem releases a new version, it's important to keep up with these updates and review the release notes for any breaking changes or high priority updates. In order to update all the dependencies and resolutions, create a new branch, such as `yourname-update-pjs`, and then run `yarn up "@polkadot/*"` in that branch.
|
|
336
335
|
|
|
337
336
|
- @polkadot/api [release notes](https://github.com/polkadot-js/api/releases)
|
|
338
337
|
- @polkadot/util-crypto [release notes](https://github.com/polkadot-js/common/releases)
|
|
@@ -349,7 +348,7 @@ and read the release notes for any breaking changes or high priority updates. In
|
|
|
349
348
|
yarn test:latest-e2e-tests
|
|
350
349
|
```
|
|
351
350
|
|
|
352
|
-
1. Commit the dependency updates with a name like `
|
|
351
|
+
1. Commit the dependency updates with a name like `chore(deps): update polkadot-js deps` (adjust the title based on what was updated; refer to the commit history for examples). Then, wait for it to be merged.
|
|
353
352
|
|
|
354
353
|
1. Follow [RELEASE.md](./RELEASE.md) next if you're working through a full sidecar release. This will involve creating a separate PR where the changelog and versions are bumped.
|
|
355
354
|
|
package/build/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "
|
|
2
|
+
"version": "19.0.1",
|
|
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",
|
|
@@ -50,25 +50,25 @@
|
|
|
50
50
|
"test:test-release": "yarn build:scripts && node scripts/build/runYarnPack.js"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@polkadot/api": "^
|
|
54
|
-
"@polkadot/api-contract": "^
|
|
53
|
+
"@polkadot/api": "^11.1.1",
|
|
54
|
+
"@polkadot/api-contract": "^11.1.1",
|
|
55
55
|
"@polkadot/util-crypto": "^12.6.2",
|
|
56
56
|
"@substrate/calc": "^0.3.1",
|
|
57
57
|
"argparse": "^2.0.1",
|
|
58
58
|
"confmgr": "^1.0.10",
|
|
59
|
-
"express": "^4.
|
|
59
|
+
"express": "^4.19.2",
|
|
60
60
|
"express-winston": "^4.2.0",
|
|
61
61
|
"http-errors": "^2.0.0",
|
|
62
|
-
"lru-cache": "^10.2.
|
|
63
|
-
"prom-client": "^15.1.
|
|
62
|
+
"lru-cache": "^10.2.2",
|
|
63
|
+
"prom-client": "^15.1.2",
|
|
64
64
|
"rxjs": "^7.8.1",
|
|
65
|
-
"winston": "^3.
|
|
65
|
+
"winston": "^3.13.0"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@substrate/dev": "^0.7.1",
|
|
69
|
-
"@types/argparse": "2.0.
|
|
69
|
+
"@types/argparse": "2.0.16",
|
|
70
70
|
"@types/express": "^4.17.21",
|
|
71
|
-
"@types/express-serve-static-core": "^4.
|
|
71
|
+
"@types/express-serve-static-core": "^4.19.1",
|
|
72
72
|
"@types/http-errors": "2.0.4",
|
|
73
73
|
"@types/lru-cache": "^7.10.10",
|
|
74
74
|
"@types/morgan": "1.9.9",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright 2017-
|
|
2
|
+
// Copyright 2017-2024 Parity Technologies (UK) Ltd.
|
|
3
3
|
// This file is part of Substrate API Sidecar.
|
|
4
4
|
//
|
|
5
5
|
// Substrate API Sidecar is free software: you can redistribute it and/or modify
|
|
@@ -33,6 +33,7 @@ exports.assetHubPolkadotControllers = {
|
|
|
33
33
|
'NodeTransactionPool',
|
|
34
34
|
'NodeVersion',
|
|
35
35
|
'PalletsAssets',
|
|
36
|
+
'PalletsAssetConversion',
|
|
36
37
|
'PalletsDispatchables',
|
|
37
38
|
'PalletsConsts',
|
|
38
39
|
'PalletsEvents',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assetHubPolkadotControllers.js","sourceRoot":"","sources":["../../../src/chains-config/assetHubPolkadotControllers.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;;;AAGxE,mCAA6D;AAE7D;;GAEG;AACU,QAAA,2BAA2B,GAAqB;IAC5D,WAAW,EAAE;QACZ,gBAAgB;QAChB,qBAAqB;QACrB,mBAAmB;QACnB,kBAAkB;QAClB,QAAQ;QACR,kBAAkB;QAClB,qBAAqB;QACrB,aAAa;QACb,qBAAqB;QACrB,aAAa;QACb,eAAe;QACf,sBAAsB;QACtB,eAAe;QACf,eAAe;QACf,eAAe;QACf,sBAAsB;QACtB,aAAa;QACb,iBAAiB;QACjB,aAAa;QACb,mBAAmB;QACnB,wBAAwB;QACxB,qBAAqB;QACrB,mBAAmB;KACnB;IACD,OAAO,EAAE;QACR,SAAS,EAAE,IAAI;QACf,iBAAiB,EAAE,GAAG;QACtB,UAAU,EAAE,IAAA,oBAAY,GAAE;QAC1B,cAAc,EAAE,IAAI,4BAAoB,CAAC,IAAI,EAAE,IAAI,CAAC;KACpD;CACD,CAAC"}
|
|
1
|
+
{"version":3,"file":"assetHubPolkadotControllers.js","sourceRoot":"","sources":["../../../src/chains-config/assetHubPolkadotControllers.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;;;AAGxE,mCAA6D;AAE7D;;GAEG;AACU,QAAA,2BAA2B,GAAqB;IAC5D,WAAW,EAAE;QACZ,gBAAgB;QAChB,qBAAqB;QACrB,mBAAmB;QACnB,kBAAkB;QAClB,QAAQ;QACR,kBAAkB;QAClB,qBAAqB;QACrB,aAAa;QACb,qBAAqB;QACrB,aAAa;QACb,eAAe;QACf,wBAAwB;QACxB,sBAAsB;QACtB,eAAe;QACf,eAAe;QACf,eAAe;QACf,sBAAsB;QACtB,aAAa;QACb,iBAAiB;QACjB,aAAa;QACb,mBAAmB;QACnB,wBAAwB;QACxB,qBAAqB;QACrB,mBAAmB;KACnB;IACD,OAAO,EAAE;QACR,SAAS,EAAE,IAAI;QACf,iBAAiB,EAAE,GAAG;QACtB,UAAU,EAAE,IAAA,oBAAY,GAAE;QAC1B,cAAc,EAAE,IAAI,4BAAoB,CAAC,IAAI,EAAE,IAAI,CAAC;KACpD;CACD,CAAC"}
|
|
@@ -102,6 +102,9 @@ class AccountsStakingPayoutsController extends AbstractController_1.default {
|
|
|
102
102
|
if (depth && isKusama) {
|
|
103
103
|
sanitizedDepth = Math.min(Number(depth), currentEra - 518).toString();
|
|
104
104
|
}
|
|
105
|
+
else if (depth) {
|
|
106
|
+
sanitizedDepth = depth;
|
|
107
|
+
}
|
|
105
108
|
if (currentEra < 518 && isKusama) {
|
|
106
109
|
const eraStartBlock = earlyErasBlockInfo[currentEra].start;
|
|
107
110
|
hash = await this.getHashFromAt(eraStartBlock.toString());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountsStakingPayoutsController.js","sourceRoot":"","sources":["../../../../src/controllers/accounts/AccountsStakingPayoutsController.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,8CAA8C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C,MAAM,EAAE;oBAC7B,MAAM,IAAI,iCAAmB,CAAC,0CAA0C,CAAC,CAAC;iBAC1E;qBAAM;oBACN,SAAS,GAAG,iBAAiB,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC;iBAClD;aACD;iBAAM;gBACN,SAAS,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;aACtD;SACD;aAAM;YACN,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;YAC9D,MAAM,GAAG,GAAG,YAAY,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;YACxC,kDAAkD;YAClD,IAAI,UAAU,GAAG,GAAG,EAAE;gBACrB,SAAS,GAAG,UAAU,CAAC;aACvB;iBAAM,IAAI,GAAG,GAAG,CAAC,EAAE;gBACnB,SAAS,GAAG,UAAU,CAAC;aACvB;iBAAM;gBACN,SAAS,GAAG,UAAU,GAAG,CAAC,CAAC;aAC3B;SACD;QAED,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,GAAG,SAAS,GAAG,CAAC,EAAE;YAC7C,MAAM,IAAI,wBAAU,CACnB,sBAAsB,GAAG,kBAAkB,GAAG,+CAA+C,SAAS,GAAG,CAAC,EAAE,CAC5G,CAAC;SACF;QAED,OAAO;YACN,MAAM,EAAE,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG;YAC/C,UAAU;SACV,CAAC;IACH,CAAC;CACD;AAlHD,mDAkHC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright 2017-
|
|
2
|
+
// Copyright 2017-2024 Parity Technologies (UK) Ltd.
|
|
3
3
|
// This file is part of Substrate API Sidecar.
|
|
4
4
|
//
|
|
5
5
|
// Substrate API Sidecar is free software: you can redistribute it and/or modify
|
|
@@ -72,6 +72,9 @@ class ParasController extends AbstractController_1.default {
|
|
|
72
72
|
};
|
|
73
73
|
this.initRoutes();
|
|
74
74
|
}
|
|
75
|
+
// ***************************************************************
|
|
76
|
+
// DEPRECATION NOTE: PHASED OUT CONTROLLERS IN FAVOR OF CORETIME
|
|
77
|
+
// ***************************************************************
|
|
75
78
|
initRoutes() {
|
|
76
79
|
this.router.use(this.path + '/paras/leases/current', (0, middleware_1.validateBoolean)(['currentLeaseHolders']));
|
|
77
80
|
this.safeMountAsyncGetHandlers([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParasController.js","sourceRoot":"","sources":["../../../../src/controllers/paras/ParasController.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,iDAAmD;AACnD,6CAA8C;AAE9C,+EAAuD;AAEvD,MAAqB,eAAgB,SAAQ,4BAAgC;IAC5E,YAAY,GAAe;QAC1B,KAAK,CAAC,GAAG,EAAE,EAAE,EAAE,IAAI,uBAAY,CAAC,GAAG,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"ParasController.js","sourceRoot":"","sources":["../../../../src/controllers/paras/ParasController.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,iDAAmD;AACnD,6CAA8C;AAE9C,+EAAuD;AAEvD,MAAqB,eAAgB,SAAQ,4BAAgC;IAC5E,YAAY,GAAe;QAC1B,K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C;YACxD,CAAC,2BAA2B,EAAE,IAAI,CAAC,YAAY,CAAC;YAChD,CAAC,uBAAuB,EAAE,IAAI,CAAC,gBAAgB,CAAC;YAChD,CAAC,yBAAyB,EAAE,IAAI,CAAC,kBAAkB,CAAC;YACpD,CAAC,iCAAiC,EAAE,IAAI,CAAC,8BAA8B,CAAC;YACxE,CAAC,+BAA+B,EAAE,IAAI,CAAC,4BAA4B,CAAC;YACpE,CAAC,sBAAsB,EAAE,IAAI,CAAC,QAAQ,CAAC;YACvC,CAAC,gCAAgC,EAAE,IAAI,CAAC,aAAa,CAAC;YACtD,CAAC,4CAA4C,EAAE,IAAI,CAAC,gBAAgB,CAAC;YACrE,CAAC,wCAAwC,EAAE,IAAI,CAAC,YAAY,CAAC;YAC7D,CAAC,oCAAoC,EAAE,IAAI,CAAC,gBAAgB,CAAC;YAC7D,CAAC,sCAAsC,EAAE,IAAI,CAAC,kBAAkB,CAAC;SACjE,CAAC,CAAC;IACJ,CAAC;CA4ED;AAvGD,kCAuGC"}
|
|
@@ -4,6 +4,10 @@ import AbstractController from '../AbstractController';
|
|
|
4
4
|
/**
|
|
5
5
|
* GET the chain's metadata.
|
|
6
6
|
*
|
|
7
|
+
* Path params:
|
|
8
|
+
* - (Optional) `metadataVersion`: The specific version of the Metadata to query.
|
|
9
|
+
* The input must conform to the `vX` format, where `X` represents the version number (examples: 'v14', 'v15').
|
|
10
|
+
*
|
|
7
11
|
* Query:
|
|
8
12
|
* - (Optional) `at`: Block hash or height at which to query. If not provided, queries
|
|
9
13
|
* finalized head.
|
|
@@ -25,4 +29,18 @@ export default class RuntimeMetadataController extends AbstractController<Runtim
|
|
|
25
29
|
* @param res Express Response
|
|
26
30
|
*/
|
|
27
31
|
private getMetadata;
|
|
32
|
+
/**
|
|
33
|
+
* Get the chain's metadata at a specific version in a decoded, JSON format.
|
|
34
|
+
*
|
|
35
|
+
* @param _req Express Request
|
|
36
|
+
* @param res Express Response
|
|
37
|
+
*/
|
|
38
|
+
private getMetadataVersioned;
|
|
39
|
+
/**
|
|
40
|
+
* Get the available versions of chain's metadata.
|
|
41
|
+
*
|
|
42
|
+
* @param _req Express Request
|
|
43
|
+
* @param res Express Response
|
|
44
|
+
*/
|
|
45
|
+
private getMetadataAvailableVersions;
|
|
28
46
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright 2017-
|
|
2
|
+
// Copyright 2017-2024 Parity Technologies (UK) Ltd.
|
|
3
3
|
// This file is part of Substrate API Sidecar.
|
|
4
4
|
//
|
|
5
5
|
// Substrate API Sidecar is free software: you can redistribute it and/or modify
|
|
@@ -23,6 +23,10 @@ const AbstractController_1 = __importDefault(require("../AbstractController"));
|
|
|
23
23
|
/**
|
|
24
24
|
* GET the chain's metadata.
|
|
25
25
|
*
|
|
26
|
+
* Path params:
|
|
27
|
+
* - (Optional) `metadataVersion`: The specific version of the Metadata to query.
|
|
28
|
+
* The input must conform to the `vX` format, where `X` represents the version number (examples: 'v14', 'v15').
|
|
29
|
+
*
|
|
26
30
|
* Query:
|
|
27
31
|
* - (Optional) `at`: Block hash or height at which to query. If not provided, queries
|
|
28
32
|
* finalized head.
|
|
@@ -55,10 +59,57 @@ class RuntimeMetadataController extends AbstractController_1.default {
|
|
|
55
59
|
metadataOpts: { registry, version: metadata.version },
|
|
56
60
|
});
|
|
57
61
|
};
|
|
62
|
+
/**
|
|
63
|
+
* Get the chain's metadata at a specific version in a decoded, JSON format.
|
|
64
|
+
*
|
|
65
|
+
* @param _req Express Request
|
|
66
|
+
* @param res Express Response
|
|
67
|
+
*/
|
|
68
|
+
this.getMetadataVersioned = async ({ params: { metadataVersion }, query: { at } }, res) => {
|
|
69
|
+
const hash = await this.getHashFromAt(at);
|
|
70
|
+
const api = at ? await this.api.at(hash) : this.api;
|
|
71
|
+
// Validation of the `metadataVersion` path parameter.
|
|
72
|
+
const metadataV = metadataVersion.slice(1);
|
|
73
|
+
const version = this.parseNumberOrThrow(metadataV, `Version ${metadataV.toString()} of metadata provided is not a number.`);
|
|
74
|
+
const regExPattern = new RegExp('^[vV][0-9]+$');
|
|
75
|
+
if (!regExPattern.test(metadataVersion)) {
|
|
76
|
+
throw new Error(`${metadataVersion} input is not of the expected 'vX' format, where 'X' represents the version number (examples: 'v14', 'v15').`);
|
|
77
|
+
}
|
|
78
|
+
let availableVersions = [];
|
|
79
|
+
try {
|
|
80
|
+
availableVersions = (await api.call.metadata.metadataVersions()).toJSON();
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
throw new Error(`Function 'api.call.metadata.metadataVersions()' is not available at this block height.`);
|
|
84
|
+
}
|
|
85
|
+
if (version && !(availableVersions === null || availableVersions === void 0 ? void 0 : availableVersions.includes(version))) {
|
|
86
|
+
throw new Error(`Version ${version} of Metadata is not available.`);
|
|
87
|
+
}
|
|
88
|
+
const registry = api.registry;
|
|
89
|
+
const metadata = await this.service.fetchMetadataVersioned(api, version);
|
|
90
|
+
RuntimeMetadataController.sanitizedSend(res, metadata, {
|
|
91
|
+
metadataOpts: { registry, version },
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Get the available versions of chain's metadata.
|
|
96
|
+
*
|
|
97
|
+
* @param _req Express Request
|
|
98
|
+
* @param res Express Response
|
|
99
|
+
*/
|
|
100
|
+
this.getMetadataAvailableVersions = async ({ query: { at } }, res) => {
|
|
101
|
+
const hash = await this.getHashFromAt(at);
|
|
102
|
+
const metadataVersions = await this.service.fetchMetadataVersions(hash);
|
|
103
|
+
RuntimeMetadataController.sanitizedSend(res, metadataVersions, {});
|
|
104
|
+
};
|
|
58
105
|
this.initRoutes();
|
|
59
106
|
}
|
|
60
107
|
initRoutes() {
|
|
61
|
-
this.safeMountAsyncGetHandlers([
|
|
108
|
+
this.safeMountAsyncGetHandlers([
|
|
109
|
+
['/', this.getMetadata],
|
|
110
|
+
['/versions', this.getMetadataAvailableVersions],
|
|
111
|
+
['/:metadataVersion', this.getMetadataVersioned],
|
|
112
|
+
]);
|
|
62
113
|
}
|
|
63
114
|
}
|
|
64
115
|
exports.default = RuntimeMetadataController;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuntimeMetadataController.js","sourceRoot":"","sources":["../../../../src/controllers/runtime/RuntimeMetadataController.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":"RuntimeMetadataController.js","sourceRoot":"","sources":["../../../../src/controllers/runtime/RuntimeMetadataController.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;;;;;AAMxE,6CAAwD;AACxD,+EAAuD;AAEvD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAqB,yBAA0B,SAAQ,4BAA0C;IAChG,YAAY,GAAe;QAC1B,KAAK,CAAC,GAAG,EAAE,mBAAmB,EAAE,IAAI,iCAAsB,CAAC,GAAG,CAAC,CAAC,CAAC;QAYlE;;;;;WAKG;QACK,gBAAW,GAAmB,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAiB,EAAE;YACrF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;YAE1C,IAAI,WAAW,CAAC;YAChB,IAAI,EAAE,EAAE;gBACP,WAAW,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,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ChD,CAAC,mBAAmB,EAAE,IAAI,CAAC,oBAAoB,CAAC;SAChD,CAAC,CAAC;IACJ,CAAC;CAmFD;AA/FD,4CA+FC"}
|
|
@@ -5,6 +5,10 @@ export type MetadataOpts = 'json' | 'scale';
|
|
|
5
5
|
/**
|
|
6
6
|
* GET all the network information needed to construct a transaction offline.
|
|
7
7
|
*
|
|
8
|
+
* Path params:
|
|
9
|
+
* - (Optional) `metadataVersion`: The specific version of the Metadata to query.
|
|
10
|
+
* The input must conform to the `vX` format, where `X` represents the version number (examples: 'v14', 'v15').
|
|
11
|
+
*
|
|
8
12
|
* Query
|
|
9
13
|
* - (Optional) `metadata`: It accepts `json`, or `scale` values. If it is not present,
|
|
10
14
|
* the metadata field will not be included.
|
|
@@ -48,4 +52,12 @@ export default class TransactionMaterialController extends AbstractController<Tr
|
|
|
48
52
|
* @param metadata
|
|
49
53
|
*/
|
|
50
54
|
private parseMetadataArgs;
|
|
55
|
+
/**
|
|
56
|
+
* Get the chain's metadata at the requested version in JSON or scale format
|
|
57
|
+
* depending on the `metadata` query param.
|
|
58
|
+
*
|
|
59
|
+
* @param _req Express Request
|
|
60
|
+
* @param res Express Response
|
|
61
|
+
*/
|
|
62
|
+
private getTransactionMaterialwithVersionedMetadata;
|
|
51
63
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright 2017-
|
|
2
|
+
// Copyright 2017-2024 Parity Technologies (UK) Ltd.
|
|
3
3
|
// This file is part of Substrate API Sidecar.
|
|
4
4
|
//
|
|
5
5
|
// Substrate API Sidecar is free software: you can redistribute it and/or modify
|
|
@@ -23,6 +23,10 @@ const AbstractController_1 = __importDefault(require("../AbstractController"));
|
|
|
23
23
|
/**
|
|
24
24
|
* GET all the network information needed to construct a transaction offline.
|
|
25
25
|
*
|
|
26
|
+
* Path params:
|
|
27
|
+
* - (Optional) `metadataVersion`: The specific version of the Metadata to query.
|
|
28
|
+
* The input must conform to the `vX` format, where `X` represents the version number (examples: 'v14', 'v15').
|
|
29
|
+
*
|
|
26
30
|
* Query
|
|
27
31
|
* - (Optional) `metadata`: It accepts `json`, or `scale` values. If it is not present,
|
|
28
32
|
* the metadata field will not be included.
|
|
@@ -64,10 +68,43 @@ class TransactionMaterialController extends AbstractController_1.default {
|
|
|
64
68
|
const metadataArg = this.parseMetadataArgs(metadata);
|
|
65
69
|
TransactionMaterialController.sanitizedSend(res, await this.service.fetchTransactionMaterial(hash, metadataArg));
|
|
66
70
|
};
|
|
71
|
+
/**
|
|
72
|
+
* Get the chain's metadata at the requested version in JSON or scale format
|
|
73
|
+
* depending on the `metadata` query param.
|
|
74
|
+
*
|
|
75
|
+
* @param _req Express Request
|
|
76
|
+
* @param res Express Response
|
|
77
|
+
*/
|
|
78
|
+
this.getTransactionMaterialwithVersionedMetadata = async ({ params: { metadataVersion }, query: { at, metadata } }, res) => {
|
|
79
|
+
const hash = await this.getHashFromAt(at);
|
|
80
|
+
const api = at ? await this.api.at(hash) : this.api;
|
|
81
|
+
// Validation of the `metadataVersion` path parameter.
|
|
82
|
+
const metadataV = metadataVersion.slice(1);
|
|
83
|
+
const version = this.parseNumberOrThrow(metadataV, `Version ${metadataV.toString()} of metadata provided is not a number.`);
|
|
84
|
+
const regExPattern = new RegExp('^[vV][0-9]+$');
|
|
85
|
+
if (!regExPattern.test(metadataVersion)) {
|
|
86
|
+
throw new Error(`${metadataVersion} input is not of the expected 'vX' format, where 'X' represents the version number (examples: 'v14', 'v15').`);
|
|
87
|
+
}
|
|
88
|
+
let availableVersions = [];
|
|
89
|
+
try {
|
|
90
|
+
availableVersions = (await api.call.metadata.metadataVersions()).toJSON();
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
throw new Error(`Function 'api.call.metadata.metadataVersions()' is not available at this block height.`);
|
|
94
|
+
}
|
|
95
|
+
if (version && !(availableVersions === null || availableVersions === void 0 ? void 0 : availableVersions.includes(version))) {
|
|
96
|
+
throw new Error(`Version ${version} of Metadata is not available.`);
|
|
97
|
+
}
|
|
98
|
+
const metadataArg = this.parseMetadataArgs(metadata);
|
|
99
|
+
TransactionMaterialController.sanitizedSend(res, await this.service.fetchTransactionMaterialwithVersionedMetadata(api, hash, metadataArg, version));
|
|
100
|
+
};
|
|
67
101
|
this.initRoutes();
|
|
68
102
|
}
|
|
69
103
|
initRoutes() {
|
|
70
|
-
this.safeMountAsyncGetHandlers([
|
|
104
|
+
this.safeMountAsyncGetHandlers([
|
|
105
|
+
['/', this.getTransactionMaterial],
|
|
106
|
+
['/:metadataVersion', this.getTransactionMaterialwithVersionedMetadata],
|
|
107
|
+
]);
|
|
71
108
|
}
|
|
72
109
|
/**
|
|
73
110
|
* The metadata args have two options. `json`, and `scale`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionMaterialController.js","sourceRoot":"","sources":["../../../../src/controllers/transaction/TransactionMaterialController.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":"TransactionMaterialController.js","sourceRoot":"","sources":["../../../../src/controllers/transaction/TransactionMaterialController.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;;;;;AAMxE,6CAA4D;AAC5D,+EAAuD;AAIvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAqB,6BAA8B,SAAQ,4BAA8C;IACxG,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AAC;IACd,CAAC;CAgDD;AAhGD,gDAgGC"}
|
|
@@ -2,7 +2,7 @@ import type { ApiDecoration } from '@polkadot/api/types';
|
|
|
2
2
|
import type { DeriveEraExposure, DeriveEraExposureNominating } from '@polkadot/api-derive/staking/types';
|
|
3
3
|
import { Option } from '@polkadot/types';
|
|
4
4
|
import type { BalanceOf, BlockHash, EraIndex, EraPoints, Perbill } from '@polkadot/types/interfaces';
|
|
5
|
-
import type { PalletStakingEraRewardPoints, PalletStakingStakingLedger } from '@polkadot/types/lookup';
|
|
5
|
+
import type { PalletStakingEraRewardPoints, PalletStakingStakingLedger, SpStakingPagedExposureMetadata } from '@polkadot/types/lookup';
|
|
6
6
|
import type { IAccountStakingPayouts, IEraPayouts } from '../../types/responses';
|
|
7
7
|
import { AbstractService } from '../AbstractService';
|
|
8
8
|
/**
|
|
@@ -17,11 +17,15 @@ interface ValidatorIndex {
|
|
|
17
17
|
[x: string]: number;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
* Adapted AdjustedDeriveEraExposure interface for compatibility
|
|
21
|
-
* previous to 518 in Kusama chain
|
|
20
|
+
* Adapted AdjustedDeriveEraExposure interface for compatibility:
|
|
21
|
+
* - with eras previous to 518 in Kusama chain (via `validatorIndex` property) and
|
|
22
|
+
* - with Staking changes (3 new calls including `ErasStakersOverview`) in
|
|
23
|
+
* Polkadot v1.2.0 runtime (via `validatorOverview` property). Relevant PR:
|
|
24
|
+
* https://github.com/paritytech/polkadot-sdk/pull/1189
|
|
22
25
|
*/
|
|
23
26
|
interface IAdjustedDeriveEraExposure extends DeriveEraExposure {
|
|
24
27
|
validatorIndex?: ValidatorIndex;
|
|
28
|
+
validatorsOverview?: Record<string, Option<SpStakingPagedExposureMetadata>>;
|
|
25
29
|
}
|
|
26
30
|
/**
|
|
27
31
|
* Commission and staking ledger of a validator
|
|
@@ -39,6 +43,7 @@ interface IEraData {
|
|
|
39
43
|
erasValidatorRewardOption: Option<BalanceOf>;
|
|
40
44
|
exposuresWithCommission?: (ICommissionAndLedger & {
|
|
41
45
|
validatorId: string;
|
|
46
|
+
nominatorIndex: number;
|
|
42
47
|
})[];
|
|
43
48
|
eraIndex: EraIndex;
|
|
44
49
|
}
|
|
@@ -86,13 +86,28 @@ class AccountsStakingPayoutsService extends AbstractService_1.AbstractService {
|
|
|
86
86
|
const eraCommissions = allErasCommissions[idx];
|
|
87
87
|
const nominatedExposures = this.deriveNominatedExposures(address, deriveEraExposure);
|
|
88
88
|
// Zip the `validatorId` with its associated `commission`, making the data easier to reason
|
|
89
|
-
// about downstream
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
89
|
+
// about downstream. In this object we added the `nominatorIndex` to account for the rare cases
|
|
90
|
+
// where a nominator has multiple nominations (with different stakes) on the same validator and
|
|
91
|
+
// at the same era.
|
|
92
|
+
const exposuresWithCommission = [];
|
|
93
|
+
if (nominatedExposures) {
|
|
94
|
+
for (let idx = 0; idx < nominatedExposures.length; idx++) {
|
|
95
|
+
let index = 0;
|
|
96
|
+
const { validatorId } = nominatedExposures[idx];
|
|
97
|
+
const nominatorInstances = nominatedExposures.filter((exposure) => exposure.validatorId.toString() === validatorId).length;
|
|
98
|
+
const exposuresValidatorLen = exposuresWithCommission.filter((exposure) => exposure.validatorId.toString() === validatorId).length;
|
|
99
|
+
if (nominatorInstances > 1) {
|
|
100
|
+
index = exposuresValidatorLen;
|
|
101
|
+
}
|
|
102
|
+
if (eraCommissions[idx]) {
|
|
103
|
+
exposuresWithCommission.push({
|
|
104
|
+
validatorId,
|
|
105
|
+
...eraCommissions[idx],
|
|
106
|
+
nominatorIndex: index,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
96
111
|
return {
|
|
97
112
|
deriveEraExposure,
|
|
98
113
|
eraRewardPoints,
|
|
@@ -222,7 +237,7 @@ class AccountsStakingPayoutsService extends AbstractService_1.AbstractService {
|
|
|
222
237
|
const calcPayout = calc_1.CalcPayout.from_params(totalEraRewardPoints.toNumber(), totalEraPayout.toString(10));
|
|
223
238
|
// Iterate through validators that this nominator backs and calculate payouts for the era
|
|
224
239
|
const payouts = [];
|
|
225
|
-
for (const { validatorId, commission: validatorCommission, validatorLedger } of exposuresWithCommission) {
|
|
240
|
+
for (const { validatorId, commission: validatorCommission, validatorLedger, nominatorIndex, } of exposuresWithCommission) {
|
|
226
241
|
const totalValidatorRewardPoints = deriveEraExposure.validatorIndex
|
|
227
242
|
? this.extractTotalValidatorRewardPoints(eraRewardPoints, validatorId, deriveEraExposure.validatorIndex)
|
|
228
243
|
: this.extractTotalValidatorRewardPoints(eraRewardPoints, validatorId);
|
|
@@ -230,7 +245,7 @@ class AccountsStakingPayoutsService extends AbstractService_1.AbstractService {
|
|
|
230
245
|
// Nothing to do if there are no reward points for the validator
|
|
231
246
|
continue;
|
|
232
247
|
}
|
|
233
|
-
const { totalExposure, nominatorExposure } = this.extractExposure(address, validatorId, deriveEraExposure);
|
|
248
|
+
const { totalExposure, nominatorExposure } = this.extractExposure(address, validatorId, deriveEraExposure, nominatorIndex);
|
|
234
249
|
if (nominatorExposure === undefined) {
|
|
235
250
|
// This should not happen once at this point, but here for safety
|
|
236
251
|
continue;
|
|
@@ -255,10 +270,10 @@ class AccountsStakingPayoutsService extends AbstractService_1.AbstractService {
|
|
|
255
270
|
else if (validatorLedger.lastReward) {
|
|
256
271
|
const lastReward = validatorLedger.lastReward;
|
|
257
272
|
if (lastReward.isSome) {
|
|
258
|
-
indexOfEra =
|
|
273
|
+
indexOfEra = lastReward.unwrap().toNumber();
|
|
259
274
|
}
|
|
260
275
|
else {
|
|
261
|
-
|
|
276
|
+
indexOfEra = -1;
|
|
262
277
|
}
|
|
263
278
|
}
|
|
264
279
|
else if (eraIndex.toNumber() < 518 && isKusama) {
|
|
@@ -354,26 +369,45 @@ class AccountsStakingPayoutsService extends AbstractService_1.AbstractService {
|
|
|
354
369
|
* @param eraIndex index of the era to query
|
|
355
370
|
*/
|
|
356
371
|
async deriveEraExposure(historicApi, eraIndex) {
|
|
357
|
-
function mapStakers(era, stakers, validatorIndex) {
|
|
372
|
+
function mapStakers(era, stakers, validatorIndex, validatorsOverviewEntries) {
|
|
358
373
|
const nominators = {};
|
|
359
374
|
const validators = {};
|
|
375
|
+
const validatorsOverview = {};
|
|
360
376
|
stakers.forEach(([key, exposure]) => {
|
|
361
377
|
const validatorId = key.args[1].toString();
|
|
378
|
+
if (validatorsOverviewEntries) {
|
|
379
|
+
for (const validator of validatorsOverviewEntries) {
|
|
380
|
+
const validatorKey = validator[0];
|
|
381
|
+
const valKey = validatorKey.toHuman();
|
|
382
|
+
if (valKey) {
|
|
383
|
+
if (valKey[1].toString() === validatorId) {
|
|
384
|
+
validatorsOverview[validatorId] = validator[1];
|
|
385
|
+
break;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
362
390
|
validators[validatorId] = exposure;
|
|
363
|
-
exposure.others
|
|
391
|
+
const individualExposure = exposure.others
|
|
392
|
+
? exposure.others
|
|
393
|
+
: exposure.isSome
|
|
394
|
+
? exposure.unwrap().others
|
|
395
|
+
: [];
|
|
396
|
+
individualExposure.forEach(({ who }, validatorIndex) => {
|
|
364
397
|
const nominatorId = who.toString();
|
|
365
398
|
nominators[nominatorId] = nominators[nominatorId] || [];
|
|
366
399
|
nominators[nominatorId].push({ validatorId, validatorIndex });
|
|
367
400
|
});
|
|
368
401
|
});
|
|
369
402
|
if (Object.keys(validatorIndex).length > 0) {
|
|
370
|
-
return { era, nominators, validators, validatorIndex };
|
|
403
|
+
return { era, nominators, validators, validatorIndex, validatorsOverview };
|
|
371
404
|
}
|
|
372
405
|
else {
|
|
373
|
-
return { era, nominators, validators };
|
|
406
|
+
return { era, nominators, validators, validatorsOverview };
|
|
374
407
|
}
|
|
375
408
|
}
|
|
376
409
|
let storageKeys = [];
|
|
410
|
+
let validatorsOverviewEntries = [];
|
|
377
411
|
const validatorIndex = {};
|
|
378
412
|
if (historicApi.query.staking.erasStakersClipped) {
|
|
379
413
|
storageKeys = await historicApi.query.staking.erasStakersClipped.entries(eraIndex);
|
|
@@ -394,7 +428,11 @@ class AccountsStakingPayoutsService extends AbstractService_1.AbstractService {
|
|
|
394
428
|
storageKeys.push([storageKey, eraExposure]);
|
|
395
429
|
}
|
|
396
430
|
}
|
|
397
|
-
|
|
431
|
+
if (storageKeys.length === 0 && historicApi.query.staking.erasStakersPaged) {
|
|
432
|
+
storageKeys = await historicApi.query.staking.erasStakersPaged.entries(eraIndex);
|
|
433
|
+
validatorsOverviewEntries = await historicApi.query.staking.erasStakersOverview.entries(eraIndex);
|
|
434
|
+
}
|
|
435
|
+
return mapStakers(eraIndex, storageKeys, validatorIndex, validatorsOverviewEntries);
|
|
398
436
|
}
|
|
399
437
|
/**
|
|
400
438
|
* Extract the reward points of `validatorId` from `EraRewardPoints`.
|
|
@@ -430,15 +468,52 @@ class AccountsStakingPayoutsService extends AbstractService_1.AbstractService {
|
|
|
430
468
|
* @param validatorId accountId of a validator's _Stash_ account
|
|
431
469
|
* @param deriveEraExposure result of deriveEraExposure
|
|
432
470
|
*/
|
|
433
|
-
extractExposure(address, validatorId, deriveEraExposure) {
|
|
471
|
+
extractExposure(address, validatorId, deriveEraExposure, nominatorIndex) {
|
|
434
472
|
var _a;
|
|
435
473
|
// Get total stake behind validator
|
|
436
|
-
|
|
474
|
+
let totalExposure = {};
|
|
475
|
+
if (deriveEraExposure.validators[validatorId].total) {
|
|
476
|
+
totalExposure = deriveEraExposure.validators[validatorId].total;
|
|
477
|
+
}
|
|
478
|
+
else if (deriveEraExposure.validatorsOverview) {
|
|
479
|
+
totalExposure = deriveEraExposure.validatorsOverview[validatorId].isSome
|
|
480
|
+
? deriveEraExposure.validatorsOverview[validatorId].unwrap().total
|
|
481
|
+
: {};
|
|
482
|
+
}
|
|
437
483
|
// Get nominators stake behind validator
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
484
|
+
let exposureAllNominators = [];
|
|
485
|
+
if (deriveEraExposure.validators[validatorId].others) {
|
|
486
|
+
exposureAllNominators = deriveEraExposure.validators[validatorId].others;
|
|
487
|
+
}
|
|
488
|
+
else {
|
|
489
|
+
const exposure = deriveEraExposure.validators[validatorId];
|
|
490
|
+
exposureAllNominators = exposure.isSome
|
|
491
|
+
? exposure.unwrap()
|
|
492
|
+
.others
|
|
493
|
+
: [];
|
|
494
|
+
}
|
|
495
|
+
let nominatorExposure;
|
|
496
|
+
// check `address === validatorId` is when the validator is also the nominator we are getting payouts for
|
|
497
|
+
if (address === validatorId && deriveEraExposure.validators[address].own) {
|
|
498
|
+
nominatorExposure = deriveEraExposure.validators[address].own;
|
|
499
|
+
}
|
|
500
|
+
else if (address === validatorId && deriveEraExposure.validatorsOverview) {
|
|
501
|
+
nominatorExposure = deriveEraExposure.validatorsOverview[address].isSome
|
|
502
|
+
? deriveEraExposure.validatorsOverview[address].unwrap().own
|
|
503
|
+
: {};
|
|
504
|
+
}
|
|
505
|
+
else {
|
|
506
|
+
// We need to account for the rare cases where a nominator has multiple nominations (with different stakes)
|
|
507
|
+
// on the same validator and at the same era.
|
|
508
|
+
const nominatorInstancesLen = exposureAllNominators.filter((exposure) => exposure.who.toString() === address).length;
|
|
509
|
+
const nominatorInstances = exposureAllNominators.filter((exposure) => exposure.who.toString() === address);
|
|
510
|
+
if (nominatorInstancesLen > 1) {
|
|
511
|
+
nominatorExposure = nominatorInstances[nominatorIndex].value;
|
|
512
|
+
}
|
|
513
|
+
else {
|
|
514
|
+
nominatorExposure = (_a = exposureAllNominators.find((exposure) => exposure.who.toString() === address)) === null || _a === void 0 ? void 0 : _a.value;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
442
517
|
return {
|
|
443
518
|
totalExposure,
|
|
444
519
|
nominatorExposure,
|