@substrate/api-sidecar 20.3.1 → 20.4.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/README.md +9 -0
- package/build/package.json +9 -19
- package/build/src/chains-config/assetHubKusamaControllers.js +17 -0
- package/build/src/chains-config/assetHubKusamaControllers.js.map +1 -1
- package/build/src/chains-config/assetHubNextWestendControllers.js +18 -0
- package/build/src/chains-config/assetHubNextWestendControllers.js.map +1 -1
- package/build/src/chains-config/assetHubPolkadotControllers.js +17 -0
- package/build/src/chains-config/assetHubPolkadotControllers.js.map +1 -1
- package/build/src/chains-config/assetHubWestendControllers.js +18 -0
- package/build/src/chains-config/assetHubWestendControllers.js.map +1 -1
- package/build/src/chains-config/index.d.ts +6 -0
- package/build/src/chains-config/index.js +24 -1
- package/build/src/chains-config/index.js.map +1 -1
- package/build/src/controllers/AbstractController.d.ts +13 -2
- package/build/src/controllers/AbstractController.js +73 -13
- package/build/src/controllers/AbstractController.js.map +1 -1
- package/build/src/controllers/accounts/AccountsAssetsController.d.ts +16 -0
- package/build/src/controllers/accounts/AccountsAssetsController.js +75 -8
- package/build/src/controllers/accounts/AccountsAssetsController.js.map +1 -1
- package/build/src/controllers/accounts/AccountsBalanceInfoController.d.ts +9 -0
- package/build/src/controllers/accounts/AccountsBalanceInfoController.js +50 -10
- package/build/src/controllers/accounts/AccountsBalanceInfoController.js.map +1 -1
- package/build/src/controllers/accounts/AccountsPoolAssetsController.d.ts +15 -0
- package/build/src/controllers/accounts/AccountsPoolAssetsController.js +74 -8
- package/build/src/controllers/accounts/AccountsPoolAssetsController.js.map +1 -1
- package/build/src/controllers/accounts/AccountsProxyInfoController.d.ts +1 -1
- package/build/src/controllers/accounts/AccountsProxyInfoController.js +30 -5
- package/build/src/controllers/accounts/AccountsProxyInfoController.js.map +1 -1
- package/build/src/controllers/accounts/AccountsStakingInfoController.d.ts +9 -0
- package/build/src/controllers/accounts/AccountsStakingInfoController.js +47 -6
- package/build/src/controllers/accounts/AccountsStakingInfoController.js.map +1 -1
- package/build/src/controllers/accounts/AccountsStakingPayoutsController.d.ts +9 -0
- package/build/src/controllers/accounts/AccountsStakingPayoutsController.js +71 -14
- package/build/src/controllers/accounts/AccountsStakingPayoutsController.js.map +1 -1
- package/build/src/controllers/accounts/AccountsVestingInfoController.d.ts +8 -0
- package/build/src/controllers/accounts/AccountsVestingInfoController.js +36 -8
- package/build/src/controllers/accounts/AccountsVestingInfoController.js.map +1 -1
- package/build/src/controllers/blocks/BlocksController.d.ts +10 -0
- package/build/src/controllers/blocks/BlocksController.js +244 -23
- package/build/src/controllers/blocks/BlocksController.js.map +1 -1
- package/build/src/controllers/blocks/BlocksExtrinsicsController.js +95 -36
- package/build/src/controllers/blocks/BlocksExtrinsicsController.js.map +1 -1
- package/build/src/controllers/blocks/BlocksRawExtrinsicsController.js +29 -4
- package/build/src/controllers/blocks/BlocksRawExtrinsicsController.js.map +1 -1
- package/build/src/controllers/controllerInjection.spec.js +5 -1
- package/build/src/controllers/controllerInjection.spec.js.map +1 -1
- package/build/src/controllers/index.d.ts +23 -0
- package/build/src/controllers/index.js +27 -4
- package/build/src/controllers/index.js.map +1 -1
- package/build/src/controllers/pallets/PalletsAssetConversionController.js +58 -6
- package/build/src/controllers/pallets/PalletsAssetConversionController.js.map +1 -1
- package/build/src/controllers/pallets/PalletsAssetsController.d.ts +8 -0
- package/build/src/controllers/pallets/PalletsAssetsController.js +38 -3
- package/build/src/controllers/pallets/PalletsAssetsController.js.map +1 -1
- package/build/src/controllers/pallets/PalletsConstsController.js +82 -18
- package/build/src/controllers/pallets/PalletsConstsController.js.map +1 -1
- package/build/src/controllers/pallets/PalletsDispatchablesController.d.ts +0 -8
- package/build/src/controllers/pallets/PalletsDispatchablesController.js +82 -28
- package/build/src/controllers/pallets/PalletsDispatchablesController.js.map +1 -1
- package/build/src/controllers/pallets/PalletsErrorsController.js +82 -18
- package/build/src/controllers/pallets/PalletsErrorsController.js.map +1 -1
- package/build/src/controllers/pallets/PalletsEventsController.js +82 -18
- package/build/src/controllers/pallets/PalletsEventsController.js.map +1 -1
- package/build/src/controllers/pallets/PalletsForeignAssetsController.d.ts +8 -0
- package/build/src/controllers/pallets/PalletsForeignAssetsController.js +38 -3
- package/build/src/controllers/pallets/PalletsForeignAssetsController.js.map +1 -1
- package/build/src/controllers/pallets/PalletsNominationPoolsController.js +58 -6
- package/build/src/controllers/pallets/PalletsNominationPoolsController.js.map +1 -1
- package/build/src/controllers/pallets/PalletsOnGoingReferendaController.js +30 -3
- package/build/src/controllers/pallets/PalletsOnGoingReferendaController.js.map +1 -1
- package/build/src/controllers/pallets/PalletsPoolAssetsController.js +30 -3
- package/build/src/controllers/pallets/PalletsPoolAssetsController.js.map +1 -1
- package/build/src/controllers/pallets/PalletsStakingProgressController.d.ts +1 -1
- package/build/src/controllers/pallets/PalletsStakingProgressController.js +30 -8
- package/build/src/controllers/pallets/PalletsStakingProgressController.js.map +1 -1
- package/build/src/controllers/pallets/PalletsStakingValidatorsController.js +30 -3
- package/build/src/controllers/pallets/PalletsStakingValidatorsController.js.map +1 -1
- package/build/src/controllers/pallets/PalletsStorageController.js +84 -19
- package/build/src/controllers/pallets/PalletsStorageController.js.map +1 -1
- package/build/src/controllers/rc/accounts/RcAccountsBalanceInfoController.d.ts +15 -0
- package/build/src/controllers/rc/accounts/RcAccountsBalanceInfoController.js +65 -0
- package/build/src/controllers/rc/accounts/RcAccountsBalanceInfoController.js.map +1 -0
- package/build/src/controllers/rc/accounts/RcAccountsProxyInfoController.d.ts +15 -0
- package/build/src/controllers/rc/accounts/RcAccountsProxyInfoController.js +59 -0
- package/build/src/controllers/rc/accounts/RcAccountsProxyInfoController.js.map +1 -0
- package/build/src/controllers/rc/accounts/index.d.ts +2 -0
- package/build/src/controllers/rc/accounts/index.js +26 -0
- package/build/src/controllers/rc/accounts/index.js.map +1 -0
- package/build/src/controllers/rc/blocks/RcBlocksController.d.ts +17 -0
- package/build/src/controllers/rc/blocks/RcBlocksController.js +263 -0
- package/build/src/controllers/rc/blocks/RcBlocksController.js.map +1 -0
- package/build/src/controllers/rc/blocks/RcBlocksExtrinsicsController.d.ts +11 -0
- package/build/src/controllers/rc/blocks/RcBlocksExtrinsicsController.js +80 -0
- package/build/src/controllers/rc/blocks/RcBlocksExtrinsicsController.js.map +1 -0
- package/build/src/controllers/rc/blocks/RcBlocksRawExtrinsicsController.d.ts +10 -0
- package/build/src/controllers/rc/blocks/RcBlocksRawExtrinsicsController.js +60 -0
- package/build/src/controllers/rc/blocks/RcBlocksRawExtrinsicsController.js.map +1 -0
- package/build/src/controllers/rc/blocks/RcBlocksTraceController.d.ts +12 -0
- package/build/src/controllers/rc/blocks/RcBlocksTraceController.js +89 -0
- package/build/src/controllers/rc/blocks/RcBlocksTraceController.js.map +1 -0
- package/build/src/controllers/rc/blocks/index.d.ts +4 -0
- package/build/src/controllers/rc/blocks/index.js +30 -0
- package/build/src/controllers/rc/blocks/index.js.map +1 -0
- package/build/src/controllers/rc/index.d.ts +4 -0
- package/build/src/controllers/rc/index.js +36 -0
- package/build/src/controllers/rc/index.js.map +1 -0
- package/build/src/controllers/rc/node/RcNodeNetworkController.d.ts +40 -0
- package/build/src/controllers/rc/node/RcNodeNetworkController.js +76 -0
- package/build/src/controllers/rc/node/RcNodeNetworkController.js.map +1 -0
- package/build/src/controllers/rc/node/RcNodeTransactionPoolController.d.ts +27 -0
- package/build/src/controllers/rc/node/RcNodeTransactionPoolController.js +66 -0
- package/build/src/controllers/rc/node/RcNodeTransactionPoolController.js.map +1 -0
- package/build/src/controllers/rc/node/RcNodeVersionController.d.ts +24 -0
- package/build/src/controllers/rc/node/RcNodeVersionController.js +59 -0
- package/build/src/controllers/rc/node/RcNodeVersionController.js.map +1 -0
- package/build/src/controllers/rc/node/index.d.ts +3 -0
- package/build/src/controllers/rc/node/index.js +13 -0
- package/build/src/controllers/rc/node/index.js.map +1 -0
- package/build/src/controllers/rc/pallets/RcPalletsConstsController.d.ts +10 -0
- package/build/src/controllers/rc/pallets/RcPalletsConstsController.js +79 -0
- package/build/src/controllers/rc/pallets/RcPalletsConstsController.js.map +1 -0
- package/build/src/controllers/rc/pallets/RcPalletsDispatchablesController.d.ts +10 -0
- package/build/src/controllers/rc/pallets/RcPalletsDispatchablesController.js +79 -0
- package/build/src/controllers/rc/pallets/RcPalletsDispatchablesController.js.map +1 -0
- package/build/src/controllers/rc/pallets/RcPalletsErrorsController.d.ts +10 -0
- package/build/src/controllers/rc/pallets/RcPalletsErrorsController.js +79 -0
- package/build/src/controllers/rc/pallets/RcPalletsErrorsController.js.map +1 -0
- package/build/src/controllers/rc/pallets/RcPalletsEventsController.d.ts +10 -0
- package/build/src/controllers/rc/pallets/RcPalletsEventsController.js +79 -0
- package/build/src/controllers/rc/pallets/RcPalletsEventsController.js.map +1 -0
- package/build/src/controllers/rc/pallets/RcPalletsOnGoingReferendaController.d.ts +9 -0
- package/build/src/controllers/rc/pallets/RcPalletsOnGoingReferendaController.js +52 -0
- package/build/src/controllers/rc/pallets/RcPalletsOnGoingReferendaController.js.map +1 -0
- package/build/src/controllers/rc/pallets/RcPalletsStorageController.d.ts +10 -0
- package/build/src/controllers/rc/pallets/RcPalletsStorageController.js +81 -0
- package/build/src/controllers/rc/pallets/RcPalletsStorageController.js.map +1 -0
- package/build/src/controllers/rc/pallets/index.d.ts +6 -0
- package/build/src/controllers/rc/pallets/index.js +34 -0
- package/build/src/controllers/rc/pallets/index.js.map +1 -0
- package/build/src/controllers/rc/runtime/RcRuntimeCodeController.d.ts +26 -0
- package/build/src/controllers/rc/runtime/RcRuntimeCodeController.js +68 -0
- package/build/src/controllers/rc/runtime/RcRuntimeCodeController.js.map +1 -0
- package/build/src/controllers/rc/runtime/RcRuntimeMetadataController.d.ts +47 -0
- package/build/src/controllers/rc/runtime/RcRuntimeMetadataController.js +140 -0
- package/build/src/controllers/rc/runtime/RcRuntimeMetadataController.js.map +1 -0
- package/build/src/controllers/rc/runtime/RcRuntimeSpecController.d.ts +34 -0
- package/build/src/controllers/rc/runtime/RcRuntimeSpecController.js +76 -0
- package/build/src/controllers/rc/runtime/RcRuntimeSpecController.js.map +1 -0
- package/build/src/controllers/rc/runtime/index.d.ts +3 -0
- package/build/src/controllers/rc/runtime/index.js +28 -0
- package/build/src/controllers/rc/runtime/index.js.map +1 -0
- package/build/src/logging/transformers/nodeUtilFormat.js +17 -7
- package/build/src/logging/transformers/nodeUtilFormat.js.map +1 -1
- package/build/src/main.js +21 -7
- package/build/src/main.js.map +1 -1
- package/build/src/metrics/index.js +17 -7
- package/build/src/metrics/index.js.map +1 -1
- package/build/src/middleware/logger/httpLogger.js +17 -7
- package/build/src/middleware/logger/httpLogger.js.map +1 -1
- package/build/src/middleware/validate/index.d.ts +1 -0
- package/build/src/middleware/validate/index.js +3 -1
- package/build/src/middleware/validate/index.js.map +1 -1
- package/build/src/middleware/validate/validateUseRcBlockMiddleware.d.ts +10 -0
- package/build/src/middleware/validate/validateUseRcBlockMiddleware.js +58 -0
- package/build/src/middleware/validate/validateUseRcBlockMiddleware.js.map +1 -0
- package/build/src/services/accounts/AccountsStakingInfoService.js +0 -1
- package/build/src/services/accounts/AccountsStakingInfoService.js.map +1 -1
- package/build/src/services/blocks/BlocksService.js +15 -1
- package/build/src/services/blocks/BlocksService.js.map +1 -1
- package/build/src/services/pallets/PalletsStakingProgressService.d.ts +56 -0
- package/build/src/services/pallets/PalletsStakingProgressService.js +140 -21
- package/build/src/services/pallets/PalletsStakingProgressService.js.map +1 -1
- package/build/src/services/pallets/PalletsStakingProgressService.spec.js +255 -43
- package/build/src/services/pallets/PalletsStakingProgressService.spec.js.map +1 -1
- package/build/src/types/requests.d.ts +1 -0
- package/build/src/types/responses/AccountAssets.d.ts +4 -0
- package/build/src/types/responses/AccountBalanceInfo.d.ts +2 -0
- package/build/src/types/responses/AccountPoolAssets.d.ts +6 -2
- package/build/src/types/responses/AccountProxyInfo.d.ts +2 -0
- package/build/src/types/responses/AccountStakingInfo.d.ts +2 -0
- package/build/src/types/responses/AccountStakingPayouts.d.ts +2 -0
- package/build/src/types/responses/AccountVestingInfo.d.ts +2 -0
- package/build/src/types/responses/PalletStakingProgress.d.ts +2 -0
- package/package.json +9 -19
|
@@ -31,6 +31,8 @@ const AbstractController_1 = __importDefault(require("../AbstractController"));
|
|
|
31
31
|
* Query:
|
|
32
32
|
* - (Optional)`at`: Block at which to retrieve runtime version information at. Block
|
|
33
33
|
* identifier, as the block height or block hash. Defaults to most recent block.
|
|
34
|
+
* - (Optional) `useRcBlock`: When true, treats the `at` parameter as a relay chain block
|
|
35
|
+
* to find corresponding Asset Hub blocks. Only supported for Asset Hub endpoints.
|
|
34
36
|
* - (Optional for `/accounts/:address/asset-balances`)`assets`
|
|
35
37
|
* - (Required for `/accounts/:address/asset-approvals)`assetId` The assetId associated
|
|
36
38
|
* with the `AssetApproval`.
|
|
@@ -40,6 +42,11 @@ const AbstractController_1 = __importDefault(require("../AbstractController"));
|
|
|
40
42
|
*
|
|
41
43
|
* `/accounts/:address/asset-balances`
|
|
42
44
|
* Returns:
|
|
45
|
+
* - When using `useRcBlock=true`: An array of response objects, one for each Asset Hub block found
|
|
46
|
+
* in the specified relay chain block. Returns empty array `[]` if no Asset Hub blocks found.
|
|
47
|
+
* - When using `useRcBlock=false` or omitted: A single response object.
|
|
48
|
+
*
|
|
49
|
+
* Response object structure:
|
|
43
50
|
* - `at`: Block number and hash at which the call was made.
|
|
44
51
|
* - `assets`: An array of `AssetBalance` objects which have a AssetId attached to them
|
|
45
52
|
* - `assetId`: The identifier of the asset.
|
|
@@ -50,13 +57,22 @@ const AbstractController_1 = __importDefault(require("../AbstractController"));
|
|
|
50
57
|
* `true`, then non-zero balances may be stored without a `consumer` reference (and thus
|
|
51
58
|
* an ED in the Balances pallet or whatever else is used to control user-account state
|
|
52
59
|
* growth).
|
|
60
|
+
* - `rcBlockNumber`: The relay chain block number used for the query. Only present when `useRcBlock=true`.
|
|
61
|
+
* - `ahTimestamp`: The Asset Hub block timestamp. Only present when `useRcBlock=true`.
|
|
53
62
|
*
|
|
54
63
|
* `/accounts/:address/asset-approvals`
|
|
55
64
|
* Returns:
|
|
65
|
+
* - When using `useRcBlock=true`: An array of response objects, one for each Asset Hub block found
|
|
66
|
+
* in the specified relay chain block. Returns empty array `[]` if no Asset Hub blocks found.
|
|
67
|
+
* - When using `useRcBlock=false` or omitted: A single response object.
|
|
68
|
+
*
|
|
69
|
+
* Response object structure:
|
|
56
70
|
* - `at`: Block number and hash at which the call was made.
|
|
57
71
|
* - `amount`: The amount of funds approved for the balance transfer from the owner
|
|
58
72
|
* to some delegated target.
|
|
59
73
|
* - `deposit`: The amount reserved on the owner's account to hold this item in storage.
|
|
74
|
+
* - `rcBlockNumber`: The relay chain block number used for the query. Only present when `useRcBlock=true`.
|
|
75
|
+
* - `ahTimestamp`: The Asset Hub block timestamp. Only present when `useRcBlock=true`.
|
|
60
76
|
*
|
|
61
77
|
* Substrate Reference:
|
|
62
78
|
* - Assets Pallet: https://crates.parity.io/pallet_assets/index.html
|
|
@@ -68,23 +84,74 @@ const AbstractController_1 = __importDefault(require("../AbstractController"));
|
|
|
68
84
|
class AccountsAssetsController extends AbstractController_1.default {
|
|
69
85
|
constructor(api) {
|
|
70
86
|
super(api, '/accounts/:address', new accounts_1.AccountsAssetsService(api));
|
|
71
|
-
this.getAssetBalances = async ({ params: { address }, query: { at, assets } }, res) => {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
87
|
+
this.getAssetBalances = async ({ params: { address }, query: { at, useRcBlock, assets } }, res) => {
|
|
88
|
+
if (useRcBlock === 'true') {
|
|
89
|
+
const rcAtResults = await this.getHashFromRcAt(at);
|
|
90
|
+
// Return empty array if no Asset Hub blocks found
|
|
91
|
+
if (rcAtResults.length === 0) {
|
|
92
|
+
AccountsAssetsController.sanitizedSend(res, []);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const assetsArray = Array.isArray(assets) ? this.parseQueryParamArrayOrThrow(assets) : [];
|
|
96
|
+
// Process each Asset Hub block found
|
|
97
|
+
const results = [];
|
|
98
|
+
for (const { ahHash, rcBlockNumber } of rcAtResults) {
|
|
99
|
+
const result = await this.service.fetchAssetBalances(ahHash, address, assetsArray);
|
|
100
|
+
const apiAt = await this.api.at(ahHash);
|
|
101
|
+
const ahTimestamp = await apiAt.query.timestamp.now();
|
|
102
|
+
const enhancedResult = {
|
|
103
|
+
...result,
|
|
104
|
+
rcBlockNumber,
|
|
105
|
+
ahTimestamp: ahTimestamp.toString(),
|
|
106
|
+
};
|
|
107
|
+
results.push(enhancedResult);
|
|
108
|
+
}
|
|
109
|
+
AccountsAssetsController.sanitizedSend(res, results);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
const hash = await this.getHashFromAt(at);
|
|
113
|
+
const assetsArray = Array.isArray(assets) ? this.parseQueryParamArrayOrThrow(assets) : [];
|
|
114
|
+
const result = await this.service.fetchAssetBalances(hash, address, assetsArray);
|
|
115
|
+
AccountsAssetsController.sanitizedSend(res, result);
|
|
116
|
+
}
|
|
75
117
|
};
|
|
76
|
-
this.getAssetApprovals = async ({ params: { address }, query: { at, delegate, assetId } }, res) => {
|
|
77
|
-
const hash = await this.getHashFromAt(at);
|
|
118
|
+
this.getAssetApprovals = async ({ params: { address }, query: { at, useRcBlock, delegate, assetId } }, res) => {
|
|
78
119
|
if (typeof delegate !== 'string' || typeof assetId !== 'string') {
|
|
79
120
|
throw new http_errors_1.BadRequest('Must include a `delegate` and `assetId` query param');
|
|
80
121
|
}
|
|
81
122
|
const id = this.parseNumberOrThrow(assetId, '`assetId` provided is not a number.');
|
|
82
|
-
|
|
123
|
+
if (useRcBlock === 'true') {
|
|
124
|
+
const rcAtResults = await this.getHashFromRcAt(at);
|
|
125
|
+
// Return empty array if no Asset Hub blocks found
|
|
126
|
+
if (rcAtResults.length === 0) {
|
|
127
|
+
AccountsAssetsController.sanitizedSend(res, []);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
// Process each Asset Hub block found
|
|
131
|
+
const results = [];
|
|
132
|
+
for (const { ahHash, rcBlockNumber } of rcAtResults) {
|
|
133
|
+
const result = await this.service.fetchAssetApproval(ahHash, address, id, delegate);
|
|
134
|
+
const apiAt = await this.api.at(ahHash);
|
|
135
|
+
const ahTimestamp = await apiAt.query.timestamp.now();
|
|
136
|
+
const enhancedResult = {
|
|
137
|
+
...result,
|
|
138
|
+
rcBlockNumber,
|
|
139
|
+
ahTimestamp: ahTimestamp.toString(),
|
|
140
|
+
};
|
|
141
|
+
results.push(enhancedResult);
|
|
142
|
+
}
|
|
143
|
+
AccountsAssetsController.sanitizedSend(res, results);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
const hash = await this.getHashFromAt(at);
|
|
147
|
+
const result = await this.service.fetchAssetApproval(hash, address, id, delegate);
|
|
148
|
+
AccountsAssetsController.sanitizedSend(res, result);
|
|
149
|
+
}
|
|
83
150
|
};
|
|
84
151
|
this.initRoutes();
|
|
85
152
|
}
|
|
86
153
|
initRoutes() {
|
|
87
|
-
this.router.use(this.path, middleware_1.validateAddress);
|
|
154
|
+
this.router.use(this.path, middleware_1.validateAddress, middleware_1.validateUseRcBlock);
|
|
88
155
|
this.safeMountAsyncGetHandlers([
|
|
89
156
|
['/asset-balances', this.getAssetBalances],
|
|
90
157
|
['/asset-approvals', this.getAssetApprovals],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountsAssetsController.js","sourceRoot":"","sources":["../../../../src/controllers/accounts/AccountsAssetsController.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,6CAAyC;AAEzC,
|
|
1
|
+
{"version":3,"file":"AccountsAssetsController.js","sourceRoot":"","sources":["../../../../src/controllers/accounts/AccountsAssetsController.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,6CAAyC;AAEzC,iDAAuE;AACvE,sDAAgE;AAChE,+EAAuD;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,MAAqB,wBAAyB,SAAQ,4BAAyC;IAI9F,YAAY,GAAW;QACtB,KAAK,CAAC,GAAG,EAAE,oBAAoB,EAAE,IAAI,gCAAqB,CAAC,GAAG,CAAC,CAAC,CAAC;QAY1D,qBAAgB,GAAmB,KAAK,EAC/C,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAC1D,GAAG,EACa,EAAE;YAClB,IAAI,UAAU,KAAK,MAAM,EAAE,CAAC;gBAC3B,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;gBAEnD,kDAAkD;gBAClD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBAC9B,wBAAwB,CAAC,aAAa,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;oBAChD,OAAO;gBACR,CAAC;gBAED,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,2BAA2B,CAAC,MAAkB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAEtG,qCAAqC;gBACrC,MAAM,OAAO,GAAG,EAAE,CAAC;gBACnB,KAA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EAAE,CAAC,CAAC;gBAC1C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC;gBAClF,wBAAwB,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YACrD,CAAC;QACF,CAAC,CAAC;QA9FD,IAAI,CAAC,UAAU,EAAE,CAAC;IACnB,CAAC;IACS,UAAU;QACnB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,4BAAe,EAAE,+BAAkB,CAAC,CAAC;QAEhE,IAAI,CAAC,yBAAyB,CAAC;YAC9B,CAAC,iBAAiB,EAAE,IAAI,CAAC,gBAAgB,CAAC;YAC1C,CAAC,kBAAkB,EAAE,IAAI,CAAC,iBAAiB,CAAC;SAC5C,CAAC,CAAC;IACJ,CAAC;;AAdM,uCAAc,GAAG,gBAAgB,AAAnB,CAAoB;AAClC,wCAAe,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,AAAf,CAAgB;kBAFlB,wBAAwB"}
|
|
@@ -9,8 +9,15 @@ import AbstractController from '../AbstractController';
|
|
|
9
9
|
* Query:
|
|
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) `useRcBlock`: When true, treats the `at` parameter as a relay chain block
|
|
13
|
+
* to find corresponding Asset Hub blocks. Only supported for Asset Hub endpoints.
|
|
12
14
|
*
|
|
13
15
|
* Returns:
|
|
16
|
+
* - When using `useRcBlock=true`: An array of response objects, one for each Asset Hub block found
|
|
17
|
+
* in the specified relay chain block. Returns empty array `[]` if no Asset Hub blocks found.
|
|
18
|
+
* - When using `useRcBlock=false` or omitted: A single response object.
|
|
19
|
+
*
|
|
20
|
+
* Response object structure:
|
|
14
21
|
* - `at`: Block number and hash at which the call was made.
|
|
15
22
|
* - `nonce`: Account nonce.
|
|
16
23
|
* - `free`: Free balance of the account. Not equivalent to _spendable_ balance. This is the only
|
|
@@ -25,6 +32,8 @@ import AbstractController from '../AbstractController';
|
|
|
25
32
|
* - `id`: An identifier for this lock. Only one lock may be in existence for each identifier.
|
|
26
33
|
* - `amount`: The amount below which the free balance may not drop with this lock in effect.
|
|
27
34
|
* - `reasons`: If true, then the lock remains in effect even for payment of transaction fees.
|
|
35
|
+
* - `rcBlockNumber`: The relay chain block number used for the query. Only present when `useRcBlock=true`.
|
|
36
|
+
* - `ahTimestamp`: The Asset Hub block timestamp. Only present when `useRcBlock=true`.
|
|
28
37
|
*
|
|
29
38
|
* Substrate Reference:
|
|
30
39
|
* - FRAME System: https://crates.parity.io/frame_system/index.html
|
|
@@ -30,8 +30,15 @@ const AbstractController_1 = __importDefault(require("../AbstractController"));
|
|
|
30
30
|
* Query:
|
|
31
31
|
* - (Optional)`at`: Block at which to retrieve runtime version information at. Block
|
|
32
32
|
* identifier, as the block height or block hash. Defaults to most recent block.
|
|
33
|
+
* - (Optional) `useRcBlock`: When true, treats the `at` parameter as a relay chain block
|
|
34
|
+
* to find corresponding Asset Hub blocks. Only supported for Asset Hub endpoints.
|
|
33
35
|
*
|
|
34
36
|
* Returns:
|
|
37
|
+
* - When using `useRcBlock=true`: An array of response objects, one for each Asset Hub block found
|
|
38
|
+
* in the specified relay chain block. Returns empty array `[]` if no Asset Hub blocks found.
|
|
39
|
+
* - When using `useRcBlock=false` or omitted: A single response object.
|
|
40
|
+
*
|
|
41
|
+
* Response object structure:
|
|
35
42
|
* - `at`: Block number and hash at which the call was made.
|
|
36
43
|
* - `nonce`: Account nonce.
|
|
37
44
|
* - `free`: Free balance of the account. Not equivalent to _spendable_ balance. This is the only
|
|
@@ -46,6 +53,8 @@ const AbstractController_1 = __importDefault(require("../AbstractController"));
|
|
|
46
53
|
* - `id`: An identifier for this lock. Only one lock may be in existence for each identifier.
|
|
47
54
|
* - `amount`: The amount below which the free balance may not drop with this lock in effect.
|
|
48
55
|
* - `reasons`: If true, then the lock remains in effect even for payment of transaction fees.
|
|
56
|
+
* - `rcBlockNumber`: The relay chain block number used for the query. Only present when `useRcBlock=true`.
|
|
57
|
+
* - `ahTimestamp`: The Asset Hub block timestamp. Only present when `useRcBlock=true`.
|
|
49
58
|
*
|
|
50
59
|
* Substrate Reference:
|
|
51
60
|
* - FRAME System: https://crates.parity.io/frame_system/index.html
|
|
@@ -63,20 +72,51 @@ class AccountsBalanceController extends AbstractController_1.default {
|
|
|
63
72
|
* @param req Express Request
|
|
64
73
|
* @param res Express Response
|
|
65
74
|
*/
|
|
66
|
-
this.getAccountBalanceInfo = async ({ params: { address }, query: { at, token, denominated } }, res) => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
this.getAccountBalanceInfo = async ({ params: { address }, query: { at, useRcBlock, token, denominated } }, res) => {
|
|
76
|
+
if (useRcBlock === 'true') {
|
|
77
|
+
const rcAtResults = await this.getHashFromRcAt(at);
|
|
78
|
+
// Return empty array if no Asset Hub blocks found
|
|
79
|
+
if (rcAtResults.length === 0) {
|
|
80
|
+
AccountsBalanceController.sanitizedSend(res, []);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const tokenArg = typeof token === 'string'
|
|
84
|
+
? token.toUpperCase()
|
|
85
|
+
: // We assume the first token is the native token
|
|
86
|
+
this.api.registry.chainTokens[0].toUpperCase();
|
|
87
|
+
const withDenomination = denominated === 'true';
|
|
88
|
+
// Process each Asset Hub block found
|
|
89
|
+
const results = [];
|
|
90
|
+
for (const { ahHash, rcBlockNumber } of rcAtResults) {
|
|
91
|
+
const historicApi = await this.api.at(ahHash);
|
|
92
|
+
const result = await this.service.fetchAccountBalanceInfo(ahHash, historicApi, address, tokenArg, withDenomination);
|
|
93
|
+
const apiAt = await this.api.at(ahHash);
|
|
94
|
+
const ahTimestamp = await apiAt.query.timestamp.now();
|
|
95
|
+
const enhancedResult = {
|
|
96
|
+
...result,
|
|
97
|
+
rcBlockNumber,
|
|
98
|
+
ahTimestamp: ahTimestamp.toString(),
|
|
99
|
+
};
|
|
100
|
+
results.push(enhancedResult);
|
|
101
|
+
}
|
|
102
|
+
AccountsBalanceController.sanitizedSend(res, results);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
const hash = await this.getHashFromAt(at);
|
|
106
|
+
const tokenArg = typeof token === 'string'
|
|
107
|
+
? token.toUpperCase()
|
|
108
|
+
: // We assume the first token is the native token
|
|
109
|
+
this.api.registry.chainTokens[0].toUpperCase();
|
|
110
|
+
const withDenomination = denominated === 'true';
|
|
111
|
+
const historicApi = await this.api.at(hash);
|
|
112
|
+
const result = await this.service.fetchAccountBalanceInfo(hash, historicApi, address, tokenArg, withDenomination);
|
|
113
|
+
AccountsBalanceController.sanitizedSend(res, result);
|
|
114
|
+
}
|
|
75
115
|
};
|
|
76
116
|
this.initRoutes();
|
|
77
117
|
}
|
|
78
118
|
initRoutes() {
|
|
79
|
-
this.router.use(this.path, middleware_1.validateAddress, (0, middleware_1.validateBoolean)(['denominated']));
|
|
119
|
+
this.router.use(this.path, middleware_1.validateAddress, (0, middleware_1.validateBoolean)(['denominated']), middleware_1.validateUseRcBlock);
|
|
80
120
|
this.safeMountAsyncGetHandlers([['', this.getAccountBalanceInfo]]);
|
|
81
121
|
}
|
|
82
122
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountsBalanceInfoController.js","sourceRoot":"","sources":["../../../../src/controllers/accounts/AccountsBalanceInfoController.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,
|
|
1
|
+
{"version":3,"file":"AccountsBalanceInfoController.js","sourceRoot":"","sources":["../../../../src/controllers/accounts/AccountsBalanceInfoController.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,iDAAwF;AACxF,6CAA4D;AAC5D,+EAAuD;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAqB,yBAA0B,SAAQ,4BAA8C;IAGpG,YAAY,GAAW;QACtB,KAAK,CAAC,GAAG,EAAE,iCAAiC,EAAE,IAAI,qCAA0B,CAAC,GAAG,CAAC,CAAC,CAAC;QAUpF;;;;;WAKG;QACK,0BAAqB,GAAkC,KAAK,EACnE,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EACtE,GAAG,EACa,EAAE;YAClB,IAAI,UAAU,KAAK,MAAM,EAAE,CAAC;gBAC3B,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;gBAEnD,kDAAkD;gBAClD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBAC9B,yBAAyB,CAAC,aAAa,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;oBACjD,OAAO;gBACR,CAAC;gBAED,MAAM,QAAQ,GACb,OAAO,KAAK,KAAK,QAAQ;oBACxB,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE;oBACrB,CAAC,CAAC,gDAAgD;wBACjD,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,CA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AAG,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;gBAC5C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,uBAAuB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC;gBAElH,yBAAyB,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YACtD,CAAC;QACF,CAAC,CAAC;QA1ED,IAAI,CAAC,UAAU,EAAE,CAAC;IACnB,CAAC;IAES,UAAU;QACnB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,4BAAe,EAAE,IAAA,4BAAe,EAAC,CAAC,aAAa,CAAC,CAAC,EAAE,+BAAkB,CAAC,CAAC;QAElG,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IACpE,CAAC;;AAXM,wCAAc,GAAG,qBAAqB,AAAxB,CAAyB;AACvC,yCAAe,GAAG,CAAC,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,AAA3B,CAA4B;kBAF9B,yBAAyB"}
|
|
@@ -9,6 +9,7 @@ import AbstractController from '../AbstractController';
|
|
|
9
9
|
* Query:
|
|
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)`useRcBlock`: When set to 'true', uses the relay chain block specified in the 'at' parameter to determine corresponding Asset Hub block(s). Only supported for Asset Hub endpoints.
|
|
12
13
|
* - (Optional for `/accounts/:address/pool-asset-balances`)`assets`
|
|
13
14
|
* - (Required for `/accounts/:address/pool-asset-approvals)`assetId` The assetId associated
|
|
14
15
|
* with the `AssetApproval`.
|
|
@@ -18,6 +19,11 @@ import AbstractController from '../AbstractController';
|
|
|
18
19
|
*
|
|
19
20
|
* `/accounts/:address/pool-asset-balances`
|
|
20
21
|
* Returns:
|
|
22
|
+
* - When using `useRcBlock` parameter: An array of response objects, one for each Asset Hub block found
|
|
23
|
+
* in the specified relay chain block. Returns empty array `[]` if no Asset Hub blocks found.
|
|
24
|
+
* - When using `at` parameter or no query params: A single response object.
|
|
25
|
+
*
|
|
26
|
+
* Response object structure:
|
|
21
27
|
* - `at`: Block number and hash at which the call was made.
|
|
22
28
|
* - `poolAssets`: An array of `AssetBalance` objects which have a AssetId attached to them
|
|
23
29
|
* - `assetId`: The identifier of the asset.
|
|
@@ -28,13 +34,22 @@ import AbstractController from '../AbstractController';
|
|
|
28
34
|
* `true`, then non-zero balances may be stored without a `consumer` reference (and thus
|
|
29
35
|
* an ED in the Balances pallet or whatever else is used to control user-account state
|
|
30
36
|
* growth).
|
|
37
|
+
* - `rcBlockNumber`: The relay chain block number used for the query. Only present when `useRcBlock` parameter is used.
|
|
38
|
+
* - `ahTimestamp`: The Asset Hub block timestamp. Only present when `useRcBlock` parameter is used.
|
|
31
39
|
*
|
|
32
40
|
* `/accounts/:address/pool-asset-approvals`
|
|
33
41
|
* Returns:
|
|
42
|
+
* - When using `useRcBlock` parameter: An array of response objects, one for each Asset Hub block found
|
|
43
|
+
* in the specified relay chain block. Returns empty array `[]` if no Asset Hub blocks found.
|
|
44
|
+
* - When using `at` parameter or no query params: A single response object.
|
|
45
|
+
*
|
|
46
|
+
* Response object structure:
|
|
34
47
|
* - `at`: Block number and hash at which the call was made.
|
|
35
48
|
* - `amount`: The amount of funds approved for the balance transfer from the owner
|
|
36
49
|
* to some delegated target.
|
|
37
50
|
* - `deposit`: The amount reserved on the owner's account to hold this item in storage.
|
|
51
|
+
* - `rcBlockNumber`: The relay chain block number used for the query. Only present when `useRcBlock` parameter is used.
|
|
52
|
+
* - `ahTimestamp`: The Asset Hub block timestamp. Only present when `useRcBlock` parameter is used.
|
|
38
53
|
*
|
|
39
54
|
* Substrate Reference:
|
|
40
55
|
* - PoolAssets Pallet: instance of Assets Pallet https://crates.parity.io/pallet_assets/index.html
|
|
@@ -31,6 +31,7 @@ const AbstractController_1 = __importDefault(require("../AbstractController"));
|
|
|
31
31
|
* Query:
|
|
32
32
|
* - (Optional)`at`: Block at which to retrieve runtime version information at. Block
|
|
33
33
|
* identifier, as the block height or block hash. Defaults to most recent block.
|
|
34
|
+
* - (Optional)`useRcBlock`: When set to 'true', uses the relay chain block specified in the 'at' parameter to determine corresponding Asset Hub block(s). Only supported for Asset Hub endpoints.
|
|
34
35
|
* - (Optional for `/accounts/:address/pool-asset-balances`)`assets`
|
|
35
36
|
* - (Required for `/accounts/:address/pool-asset-approvals)`assetId` The assetId associated
|
|
36
37
|
* with the `AssetApproval`.
|
|
@@ -40,6 +41,11 @@ const AbstractController_1 = __importDefault(require("../AbstractController"));
|
|
|
40
41
|
*
|
|
41
42
|
* `/accounts/:address/pool-asset-balances`
|
|
42
43
|
* Returns:
|
|
44
|
+
* - When using `useRcBlock` parameter: An array of response objects, one for each Asset Hub block found
|
|
45
|
+
* in the specified relay chain block. Returns empty array `[]` if no Asset Hub blocks found.
|
|
46
|
+
* - When using `at` parameter or no query params: A single response object.
|
|
47
|
+
*
|
|
48
|
+
* Response object structure:
|
|
43
49
|
* - `at`: Block number and hash at which the call was made.
|
|
44
50
|
* - `poolAssets`: An array of `AssetBalance` objects which have a AssetId attached to them
|
|
45
51
|
* - `assetId`: The identifier of the asset.
|
|
@@ -50,13 +56,22 @@ const AbstractController_1 = __importDefault(require("../AbstractController"));
|
|
|
50
56
|
* `true`, then non-zero balances may be stored without a `consumer` reference (and thus
|
|
51
57
|
* an ED in the Balances pallet or whatever else is used to control user-account state
|
|
52
58
|
* growth).
|
|
59
|
+
* - `rcBlockNumber`: The relay chain block number used for the query. Only present when `useRcBlock` parameter is used.
|
|
60
|
+
* - `ahTimestamp`: The Asset Hub block timestamp. Only present when `useRcBlock` parameter is used.
|
|
53
61
|
*
|
|
54
62
|
* `/accounts/:address/pool-asset-approvals`
|
|
55
63
|
* Returns:
|
|
64
|
+
* - When using `useRcBlock` parameter: An array of response objects, one for each Asset Hub block found
|
|
65
|
+
* in the specified relay chain block. Returns empty array `[]` if no Asset Hub blocks found.
|
|
66
|
+
* - When using `at` parameter or no query params: A single response object.
|
|
67
|
+
*
|
|
68
|
+
* Response object structure:
|
|
56
69
|
* - `at`: Block number and hash at which the call was made.
|
|
57
70
|
* - `amount`: The amount of funds approved for the balance transfer from the owner
|
|
58
71
|
* to some delegated target.
|
|
59
72
|
* - `deposit`: The amount reserved on the owner's account to hold this item in storage.
|
|
73
|
+
* - `rcBlockNumber`: The relay chain block number used for the query. Only present when `useRcBlock` parameter is used.
|
|
74
|
+
* - `ahTimestamp`: The Asset Hub block timestamp. Only present when `useRcBlock` parameter is used.
|
|
60
75
|
*
|
|
61
76
|
* Substrate Reference:
|
|
62
77
|
* - PoolAssets Pallet: instance of Assets Pallet https://crates.parity.io/pallet_assets/index.html
|
|
@@ -68,23 +83,74 @@ const AbstractController_1 = __importDefault(require("../AbstractController"));
|
|
|
68
83
|
class AccountsPoolAssetsController extends AbstractController_1.default {
|
|
69
84
|
constructor(api) {
|
|
70
85
|
super(api, '/accounts/:address', new accounts_1.AccountsPoolAssetsService(api));
|
|
71
|
-
this.getPoolAssetBalances = async ({ params: { address }, query: { at, assets } }, res) => {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
86
|
+
this.getPoolAssetBalances = async ({ params: { address }, query: { at, useRcBlock, assets } }, res) => {
|
|
87
|
+
if (useRcBlock === 'true') {
|
|
88
|
+
const rcAtResults = await this.getHashFromRcAt(at);
|
|
89
|
+
// Return empty array if no Asset Hub blocks found
|
|
90
|
+
if (rcAtResults.length === 0) {
|
|
91
|
+
AccountsPoolAssetsController.sanitizedSend(res, []);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const assetsArray = Array.isArray(assets) ? this.parseQueryParamArrayOrThrow(assets) : [];
|
|
95
|
+
// Process each Asset Hub block found
|
|
96
|
+
const results = [];
|
|
97
|
+
for (const { ahHash, rcBlockNumber } of rcAtResults) {
|
|
98
|
+
const result = await this.service.fetchPoolAssetBalances(ahHash, address, assetsArray);
|
|
99
|
+
const apiAt = await this.api.at(ahHash);
|
|
100
|
+
const ahTimestamp = await apiAt.query.timestamp.now();
|
|
101
|
+
const enhancedResult = {
|
|
102
|
+
...result,
|
|
103
|
+
rcBlockNumber,
|
|
104
|
+
ahTimestamp: ahTimestamp.toString(),
|
|
105
|
+
};
|
|
106
|
+
results.push(enhancedResult);
|
|
107
|
+
}
|
|
108
|
+
AccountsPoolAssetsController.sanitizedSend(res, results);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
const hash = await this.getHashFromAt(at);
|
|
112
|
+
const assetsArray = Array.isArray(assets) ? this.parseQueryParamArrayOrThrow(assets) : [];
|
|
113
|
+
const result = await this.service.fetchPoolAssetBalances(hash, address, assetsArray);
|
|
114
|
+
AccountsPoolAssetsController.sanitizedSend(res, result);
|
|
115
|
+
}
|
|
75
116
|
};
|
|
76
|
-
this.getPoolAssetApprovals = async ({ params: { address }, query: { at, delegate, assetId } }, res) => {
|
|
77
|
-
const hash = await this.getHashFromAt(at);
|
|
117
|
+
this.getPoolAssetApprovals = async ({ params: { address }, query: { at, useRcBlock, delegate, assetId } }, res) => {
|
|
78
118
|
if (typeof delegate !== 'string' || typeof assetId !== 'string') {
|
|
79
119
|
throw new http_errors_1.BadRequest('Must include a `delegate` and `assetId` query param');
|
|
80
120
|
}
|
|
81
121
|
const id = this.parseNumberOrThrow(assetId, '`assetId` provided is not a number.');
|
|
82
|
-
|
|
122
|
+
if (useRcBlock === 'true') {
|
|
123
|
+
const rcAtResults = await this.getHashFromRcAt(at);
|
|
124
|
+
// Return empty array if no Asset Hub blocks found
|
|
125
|
+
if (rcAtResults.length === 0) {
|
|
126
|
+
AccountsPoolAssetsController.sanitizedSend(res, []);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
// Process each Asset Hub block found
|
|
130
|
+
const results = [];
|
|
131
|
+
for (const { ahHash, rcBlockNumber } of rcAtResults) {
|
|
132
|
+
const result = await this.service.fetchPoolAssetApprovals(ahHash, address, id, delegate);
|
|
133
|
+
const apiAt = await this.api.at(ahHash);
|
|
134
|
+
const ahTimestamp = await apiAt.query.timestamp.now();
|
|
135
|
+
const enhancedResult = {
|
|
136
|
+
...result,
|
|
137
|
+
rcBlockNumber,
|
|
138
|
+
ahTimestamp: ahTimestamp.toString(),
|
|
139
|
+
};
|
|
140
|
+
results.push(enhancedResult);
|
|
141
|
+
}
|
|
142
|
+
AccountsPoolAssetsController.sanitizedSend(res, results);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
const hash = await this.getHashFromAt(at);
|
|
146
|
+
const result = await this.service.fetchPoolAssetApprovals(hash, address, id, delegate);
|
|
147
|
+
AccountsPoolAssetsController.sanitizedSend(res, result);
|
|
148
|
+
}
|
|
83
149
|
};
|
|
84
150
|
this.initRoutes();
|
|
85
151
|
}
|
|
86
152
|
initRoutes() {
|
|
87
|
-
this.router.use(this.path, middleware_1.validateAddress);
|
|
153
|
+
this.router.use(this.path, middleware_1.validateAddress, middleware_1.validateUseRcBlock);
|
|
88
154
|
this.safeMountAsyncGetHandlers([
|
|
89
155
|
['/pool-asset-balances', this.getPoolAssetBalances],
|
|
90
156
|
['/pool-asset-approvals', this.getPoolAssetApprovals],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountsPoolAssetsController.js","sourceRoot":"","sources":["../../../../src/controllers/accounts/AccountsPoolAssetsController.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,6CAAyC;AAEzC,
|
|
1
|
+
{"version":3,"file":"AccountsPoolAssetsController.js","sourceRoot":"","sources":["../../../../src/controllers/accounts/AccountsPoolAssetsController.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,6CAAyC;AAEzC,iDAAuE;AACvE,sDAAoE;AACpE,+EAAuD;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,MAAqB,4BAA6B,SAAQ,4BAA6C;IAGtG,YAAY,GAAW;QACtB,KAAK,CAAC,GAAG,EAAE,oBAAoB,EAAE,IAAI,oCAAyB,CAAC,GAAG,CAAC,CAAC,CAAC;QAa9D,yBAAoB,GAAmB,KAAK,EACnD,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAC1D,GAAG,EACa,EAAE;YAClB,IAAI,UAAU,KAAK,MAAM,EAAE,CAAC;gBAC3B,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;gBAEnD,kDAAkD;gBAClD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBAC9B,4BAA4B,CAAC,aAAa,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;oBACpD,OAAO;gBACR,CAAC;gBAED,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,2BAA2B,CAAC,MAAkB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAEtG,qCAAqC;gBACrC,MAAM,OAAO,GAAG,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,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;gBAC1C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,uBAAuB,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC;gBACvF,4BAA4B,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YACzD,CAAC;QACF,CAAC,CAAC;QA/FD,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;YAC9B,CAAC,sBAAsB,EAAE,IAAI,CAAC,oBAAoB,CAAC;YACnD,CAAC,uBAAuB,EAAE,IAAI,CAAC,qBAAqB,CAAC;SACrD,CAAC,CAAC;IACJ,CAAC;;AAdM,2CAAc,GAAG,oBAAoB,AAAvB,CAAwB;AACtC,4CAAe,GAAG,CAAC,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,AAA7B,CAA8B;kBAFhC,4BAA4B"}
|
|
@@ -6,7 +6,7 @@ export default class AccountsProxyInfoController extends AbstractController<Acco
|
|
|
6
6
|
constructor(api: string);
|
|
7
7
|
protected initRoutes(): void;
|
|
8
8
|
/**
|
|
9
|
-
* Get the latest account
|
|
9
|
+
* Get the latest account proxy info of `address`.
|
|
10
10
|
*
|
|
11
11
|
* @param req Express Request
|
|
12
12
|
* @param res Express Response
|
|
@@ -25,19 +25,44 @@ class AccountsProxyInfoController extends AbstractController_1.default {
|
|
|
25
25
|
constructor(api) {
|
|
26
26
|
super(api, '/accounts/:address/proxy-info', new services_1.AccountsProxyInfoService(api));
|
|
27
27
|
/**
|
|
28
|
-
* Get the latest account
|
|
28
|
+
* Get the latest account proxy info of `address`.
|
|
29
29
|
*
|
|
30
30
|
* @param req Express Request
|
|
31
31
|
* @param res Express Response
|
|
32
32
|
*/
|
|
33
|
-
this.getAccountProxyInfo = async ({ params: { address }, query: { at } }, res) => {
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
this.getAccountProxyInfo = async ({ params: { address }, query: { at, useRcBlock } }, res) => {
|
|
34
|
+
if (useRcBlock === 'true') {
|
|
35
|
+
const rcAtResults = await this.getHashFromRcAt(at);
|
|
36
|
+
// Return empty array if no Asset Hub blocks found
|
|
37
|
+
if (rcAtResults.length === 0) {
|
|
38
|
+
AccountsProxyInfoController.sanitizedSend(res, []);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
// Process each Asset Hub block found
|
|
42
|
+
const results = [];
|
|
43
|
+
for (const { ahHash, rcBlockNumber } of rcAtResults) {
|
|
44
|
+
const result = await this.service.fetchAccountProxyInfo(ahHash, address);
|
|
45
|
+
const apiAt = await this.api.at(ahHash);
|
|
46
|
+
const ahTimestamp = await apiAt.query.timestamp.now();
|
|
47
|
+
const enhancedResult = {
|
|
48
|
+
...result,
|
|
49
|
+
rcBlockNumber,
|
|
50
|
+
ahTimestamp: ahTimestamp.toString(),
|
|
51
|
+
};
|
|
52
|
+
results.push(enhancedResult);
|
|
53
|
+
}
|
|
54
|
+
AccountsProxyInfoController.sanitizedSend(res, results);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
const hash = await this.getHashFromAt(at);
|
|
58
|
+
const result = await this.service.fetchAccountProxyInfo(hash, address);
|
|
59
|
+
AccountsProxyInfoController.sanitizedSend(res, result);
|
|
60
|
+
}
|
|
36
61
|
};
|
|
37
62
|
this.initRoutes();
|
|
38
63
|
}
|
|
39
64
|
initRoutes() {
|
|
40
|
-
this.router.use(this.path, middleware_1.validateAddress);
|
|
65
|
+
this.router.use(this.path, middleware_1.validateAddress, middleware_1.validateUseRcBlock);
|
|
41
66
|
this.safeMountAsyncGetHandlers([['', this.getAccountProxyInfo]]);
|
|
42
67
|
}
|
|
43
68
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountsProxyInfoController.js","sourceRoot":"","sources":["../../../../src/controllers/accounts/AccountsProxyInfoController.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,
|
|
1
|
+
{"version":3,"file":"AccountsProxyInfoController.js","sourceRoot":"","sources":["../../../../src/controllers/accounts/AccountsProxyInfoController.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,iDAAuE;AACvE,6CAA0D;AAC1D,+EAAuD;AAEvD,MAAqB,2BAA4B,SAAQ,4BAA4C;IAGpG,YAAY,GAAW;QACtB,KAAK,CAAC,GAAG,EAAE,+BAA+B,EAAE,IAAI,mCAAwB,CAAC,GAAG,CAAC,CAAC,CAAC;QAUhF;;;;;WAKG;QACK,wBAAmB,GAAkC,KAAK,EACjE,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAClD,GAAG,EACa,EAAE;YAClB,IAAI,UAAU,KAAK,MAAM,EAAE,CAAC;gBAC3B,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;gBAEnD,kDAAkD;gBAClD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBAC9B,2BAA2B,CAAC,aAAa,CAAC,GAAG,EAA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AAC;IAClE,CAAC;;AAXM,0CAAc,GAAG,mBAAmB,AAAtB,CAAuB;AACrC,2CAAe,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,AAAd,CAAe;kBAFjB,2BAA2B"}
|
|
@@ -10,6 +10,8 @@ import AbstractController from '../AbstractController';
|
|
|
10
10
|
* Query:
|
|
11
11
|
* - (Optional)`at`: Block at which to retrieve runtime version information at. Block
|
|
12
12
|
* identifier, as the block height or block hash. Defaults to most recent block.
|
|
13
|
+
* - (Optional) `useRcBlock`: When true, treats the `at` parameter as a relay chain block
|
|
14
|
+
* to find corresponding Asset Hub blocks. Only supported for Asset Hub endpoints.
|
|
13
15
|
* - (Optional) `includeClaimedRewards`: Controls whether or not the `claimedRewards`
|
|
14
16
|
* field is included in the response. Defaults to `true`.
|
|
15
17
|
* If set to `false`:
|
|
@@ -18,6 +20,11 @@ import AbstractController from '../AbstractController';
|
|
|
18
20
|
* will be skipped, potentially speeding up the response time.
|
|
19
21
|
*
|
|
20
22
|
* Returns:
|
|
23
|
+
* - When using `useRcBlock=true`: An array of response objects, one for each Asset Hub block found
|
|
24
|
+
* in the specified relay chain block. Returns empty array `[]` if no Asset Hub blocks found.
|
|
25
|
+
* - When using `useRcBlock=false` or omitted: A single response object.
|
|
26
|
+
*
|
|
27
|
+
* Response object structure:
|
|
21
28
|
* - `at`: Block number and hash at which the call was made.
|
|
22
29
|
* - `rewardDestination`: The account to which rewards will be paid. Can be 'Staked' (Stash
|
|
23
30
|
* account, adding to the amount at stake), 'Stash' (Stash address, not adding to the amount at
|
|
@@ -36,6 +43,8 @@ import AbstractController from '../AbstractController';
|
|
|
36
43
|
* with an `era` at which `value` will be unlocked.
|
|
37
44
|
* - `claimedRewards`: Array of eras for which the stakers behind a validator have claimed
|
|
38
45
|
* rewards. Only updated for _validators._
|
|
46
|
+
* - `rcBlockNumber`: The relay chain block number used for the query. Only present when `useRcBlock=true`.
|
|
47
|
+
* - `ahTimestamp`: The Asset Hub block timestamp. Only present when `useRcBlock=true`.
|
|
39
48
|
*
|
|
40
49
|
* Note: Runtime versions of Kusama less than 1062 will either have `lastReward` in place of
|
|
41
50
|
* `claimedRewards`, or no field at all. This is related to changes in reward distribution. See:
|