@substrate/api-sidecar 20.3.2 → 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.
Files changed (178) hide show
  1. package/README.md +9 -0
  2. package/build/package.json +8 -18
  3. package/build/src/chains-config/assetHubKusamaControllers.js +17 -0
  4. package/build/src/chains-config/assetHubKusamaControllers.js.map +1 -1
  5. package/build/src/chains-config/assetHubNextWestendControllers.js +18 -0
  6. package/build/src/chains-config/assetHubNextWestendControllers.js.map +1 -1
  7. package/build/src/chains-config/assetHubPolkadotControllers.js +17 -0
  8. package/build/src/chains-config/assetHubPolkadotControllers.js.map +1 -1
  9. package/build/src/chains-config/assetHubWestendControllers.js +18 -0
  10. package/build/src/chains-config/assetHubWestendControllers.js.map +1 -1
  11. package/build/src/chains-config/index.d.ts +6 -0
  12. package/build/src/chains-config/index.js +24 -1
  13. package/build/src/chains-config/index.js.map +1 -1
  14. package/build/src/controllers/AbstractController.d.ts +13 -2
  15. package/build/src/controllers/AbstractController.js +56 -6
  16. package/build/src/controllers/AbstractController.js.map +1 -1
  17. package/build/src/controllers/accounts/AccountsAssetsController.d.ts +16 -0
  18. package/build/src/controllers/accounts/AccountsAssetsController.js +75 -8
  19. package/build/src/controllers/accounts/AccountsAssetsController.js.map +1 -1
  20. package/build/src/controllers/accounts/AccountsBalanceInfoController.d.ts +9 -0
  21. package/build/src/controllers/accounts/AccountsBalanceInfoController.js +50 -10
  22. package/build/src/controllers/accounts/AccountsBalanceInfoController.js.map +1 -1
  23. package/build/src/controllers/accounts/AccountsPoolAssetsController.d.ts +15 -0
  24. package/build/src/controllers/accounts/AccountsPoolAssetsController.js +74 -8
  25. package/build/src/controllers/accounts/AccountsPoolAssetsController.js.map +1 -1
  26. package/build/src/controllers/accounts/AccountsProxyInfoController.d.ts +1 -1
  27. package/build/src/controllers/accounts/AccountsProxyInfoController.js +30 -5
  28. package/build/src/controllers/accounts/AccountsProxyInfoController.js.map +1 -1
  29. package/build/src/controllers/accounts/AccountsStakingInfoController.d.ts +9 -0
  30. package/build/src/controllers/accounts/AccountsStakingInfoController.js +47 -6
  31. package/build/src/controllers/accounts/AccountsStakingInfoController.js.map +1 -1
  32. package/build/src/controllers/accounts/AccountsStakingPayoutsController.d.ts +9 -0
  33. package/build/src/controllers/accounts/AccountsStakingPayoutsController.js +71 -14
  34. package/build/src/controllers/accounts/AccountsStakingPayoutsController.js.map +1 -1
  35. package/build/src/controllers/accounts/AccountsVestingInfoController.d.ts +8 -0
  36. package/build/src/controllers/accounts/AccountsVestingInfoController.js +36 -8
  37. package/build/src/controllers/accounts/AccountsVestingInfoController.js.map +1 -1
  38. package/build/src/controllers/blocks/BlocksController.d.ts +10 -0
  39. package/build/src/controllers/blocks/BlocksController.js +244 -23
  40. package/build/src/controllers/blocks/BlocksController.js.map +1 -1
  41. package/build/src/controllers/blocks/BlocksExtrinsicsController.js +95 -36
  42. package/build/src/controllers/blocks/BlocksExtrinsicsController.js.map +1 -1
  43. package/build/src/controllers/blocks/BlocksRawExtrinsicsController.js +29 -4
  44. package/build/src/controllers/blocks/BlocksRawExtrinsicsController.js.map +1 -1
  45. package/build/src/controllers/controllerInjection.spec.js +5 -1
  46. package/build/src/controllers/controllerInjection.spec.js.map +1 -1
  47. package/build/src/controllers/index.d.ts +23 -0
  48. package/build/src/controllers/index.js +27 -4
  49. package/build/src/controllers/index.js.map +1 -1
  50. package/build/src/controllers/pallets/PalletsAssetConversionController.js +58 -6
  51. package/build/src/controllers/pallets/PalletsAssetConversionController.js.map +1 -1
  52. package/build/src/controllers/pallets/PalletsAssetsController.d.ts +8 -0
  53. package/build/src/controllers/pallets/PalletsAssetsController.js +38 -3
  54. package/build/src/controllers/pallets/PalletsAssetsController.js.map +1 -1
  55. package/build/src/controllers/pallets/PalletsConstsController.js +82 -18
  56. package/build/src/controllers/pallets/PalletsConstsController.js.map +1 -1
  57. package/build/src/controllers/pallets/PalletsDispatchablesController.d.ts +0 -8
  58. package/build/src/controllers/pallets/PalletsDispatchablesController.js +82 -28
  59. package/build/src/controllers/pallets/PalletsDispatchablesController.js.map +1 -1
  60. package/build/src/controllers/pallets/PalletsErrorsController.js +82 -18
  61. package/build/src/controllers/pallets/PalletsErrorsController.js.map +1 -1
  62. package/build/src/controllers/pallets/PalletsEventsController.js +82 -18
  63. package/build/src/controllers/pallets/PalletsEventsController.js.map +1 -1
  64. package/build/src/controllers/pallets/PalletsForeignAssetsController.d.ts +8 -0
  65. package/build/src/controllers/pallets/PalletsForeignAssetsController.js +38 -3
  66. package/build/src/controllers/pallets/PalletsForeignAssetsController.js.map +1 -1
  67. package/build/src/controllers/pallets/PalletsNominationPoolsController.js +58 -6
  68. package/build/src/controllers/pallets/PalletsNominationPoolsController.js.map +1 -1
  69. package/build/src/controllers/pallets/PalletsOnGoingReferendaController.js +30 -3
  70. package/build/src/controllers/pallets/PalletsOnGoingReferendaController.js.map +1 -1
  71. package/build/src/controllers/pallets/PalletsPoolAssetsController.js +30 -3
  72. package/build/src/controllers/pallets/PalletsPoolAssetsController.js.map +1 -1
  73. package/build/src/controllers/pallets/PalletsStakingProgressController.d.ts +1 -1
  74. package/build/src/controllers/pallets/PalletsStakingProgressController.js +30 -8
  75. package/build/src/controllers/pallets/PalletsStakingProgressController.js.map +1 -1
  76. package/build/src/controllers/pallets/PalletsStakingValidatorsController.js +30 -3
  77. package/build/src/controllers/pallets/PalletsStakingValidatorsController.js.map +1 -1
  78. package/build/src/controllers/pallets/PalletsStorageController.js +84 -19
  79. package/build/src/controllers/pallets/PalletsStorageController.js.map +1 -1
  80. package/build/src/controllers/rc/accounts/RcAccountsBalanceInfoController.d.ts +15 -0
  81. package/build/src/controllers/rc/accounts/RcAccountsBalanceInfoController.js +65 -0
  82. package/build/src/controllers/rc/accounts/RcAccountsBalanceInfoController.js.map +1 -0
  83. package/build/src/controllers/rc/accounts/RcAccountsProxyInfoController.d.ts +15 -0
  84. package/build/src/controllers/rc/accounts/RcAccountsProxyInfoController.js +59 -0
  85. package/build/src/controllers/rc/accounts/RcAccountsProxyInfoController.js.map +1 -0
  86. package/build/src/controllers/rc/accounts/index.d.ts +2 -0
  87. package/build/src/controllers/rc/accounts/index.js +26 -0
  88. package/build/src/controllers/rc/accounts/index.js.map +1 -0
  89. package/build/src/controllers/rc/blocks/RcBlocksController.d.ts +17 -0
  90. package/build/src/controllers/rc/blocks/RcBlocksController.js +263 -0
  91. package/build/src/controllers/rc/blocks/RcBlocksController.js.map +1 -0
  92. package/build/src/controllers/rc/blocks/RcBlocksExtrinsicsController.d.ts +11 -0
  93. package/build/src/controllers/rc/blocks/RcBlocksExtrinsicsController.js +80 -0
  94. package/build/src/controllers/rc/blocks/RcBlocksExtrinsicsController.js.map +1 -0
  95. package/build/src/controllers/rc/blocks/RcBlocksRawExtrinsicsController.d.ts +10 -0
  96. package/build/src/controllers/rc/blocks/RcBlocksRawExtrinsicsController.js +60 -0
  97. package/build/src/controllers/rc/blocks/RcBlocksRawExtrinsicsController.js.map +1 -0
  98. package/build/src/controllers/rc/blocks/RcBlocksTraceController.d.ts +12 -0
  99. package/build/src/controllers/rc/blocks/RcBlocksTraceController.js +89 -0
  100. package/build/src/controllers/rc/blocks/RcBlocksTraceController.js.map +1 -0
  101. package/build/src/controllers/rc/blocks/index.d.ts +4 -0
  102. package/build/src/controllers/rc/blocks/index.js +30 -0
  103. package/build/src/controllers/rc/blocks/index.js.map +1 -0
  104. package/build/src/controllers/rc/index.d.ts +4 -0
  105. package/build/src/controllers/rc/index.js +36 -0
  106. package/build/src/controllers/rc/index.js.map +1 -0
  107. package/build/src/controllers/rc/node/RcNodeNetworkController.d.ts +40 -0
  108. package/build/src/controllers/rc/node/RcNodeNetworkController.js +76 -0
  109. package/build/src/controllers/rc/node/RcNodeNetworkController.js.map +1 -0
  110. package/build/src/controllers/rc/node/RcNodeTransactionPoolController.d.ts +27 -0
  111. package/build/src/controllers/rc/node/RcNodeTransactionPoolController.js +66 -0
  112. package/build/src/controllers/rc/node/RcNodeTransactionPoolController.js.map +1 -0
  113. package/build/src/controllers/rc/node/RcNodeVersionController.d.ts +24 -0
  114. package/build/src/controllers/rc/node/RcNodeVersionController.js +59 -0
  115. package/build/src/controllers/rc/node/RcNodeVersionController.js.map +1 -0
  116. package/build/src/controllers/rc/node/index.d.ts +3 -0
  117. package/build/src/controllers/rc/node/index.js +13 -0
  118. package/build/src/controllers/rc/node/index.js.map +1 -0
  119. package/build/src/controllers/rc/pallets/RcPalletsConstsController.d.ts +10 -0
  120. package/build/src/controllers/rc/pallets/RcPalletsConstsController.js +79 -0
  121. package/build/src/controllers/rc/pallets/RcPalletsConstsController.js.map +1 -0
  122. package/build/src/controllers/rc/pallets/RcPalletsDispatchablesController.d.ts +10 -0
  123. package/build/src/controllers/rc/pallets/RcPalletsDispatchablesController.js +79 -0
  124. package/build/src/controllers/rc/pallets/RcPalletsDispatchablesController.js.map +1 -0
  125. package/build/src/controllers/rc/pallets/RcPalletsErrorsController.d.ts +10 -0
  126. package/build/src/controllers/rc/pallets/RcPalletsErrorsController.js +79 -0
  127. package/build/src/controllers/rc/pallets/RcPalletsErrorsController.js.map +1 -0
  128. package/build/src/controllers/rc/pallets/RcPalletsEventsController.d.ts +10 -0
  129. package/build/src/controllers/rc/pallets/RcPalletsEventsController.js +79 -0
  130. package/build/src/controllers/rc/pallets/RcPalletsEventsController.js.map +1 -0
  131. package/build/src/controllers/rc/pallets/RcPalletsOnGoingReferendaController.d.ts +9 -0
  132. package/build/src/controllers/rc/pallets/RcPalletsOnGoingReferendaController.js +52 -0
  133. package/build/src/controllers/rc/pallets/RcPalletsOnGoingReferendaController.js.map +1 -0
  134. package/build/src/controllers/rc/pallets/RcPalletsStorageController.d.ts +10 -0
  135. package/build/src/controllers/rc/pallets/RcPalletsStorageController.js +81 -0
  136. package/build/src/controllers/rc/pallets/RcPalletsStorageController.js.map +1 -0
  137. package/build/src/controllers/rc/pallets/index.d.ts +6 -0
  138. package/build/src/controllers/rc/pallets/index.js +34 -0
  139. package/build/src/controllers/rc/pallets/index.js.map +1 -0
  140. package/build/src/controllers/rc/runtime/RcRuntimeCodeController.d.ts +26 -0
  141. package/build/src/controllers/rc/runtime/RcRuntimeCodeController.js +68 -0
  142. package/build/src/controllers/rc/runtime/RcRuntimeCodeController.js.map +1 -0
  143. package/build/src/controllers/rc/runtime/RcRuntimeMetadataController.d.ts +47 -0
  144. package/build/src/controllers/rc/runtime/RcRuntimeMetadataController.js +140 -0
  145. package/build/src/controllers/rc/runtime/RcRuntimeMetadataController.js.map +1 -0
  146. package/build/src/controllers/rc/runtime/RcRuntimeSpecController.d.ts +34 -0
  147. package/build/src/controllers/rc/runtime/RcRuntimeSpecController.js +76 -0
  148. package/build/src/controllers/rc/runtime/RcRuntimeSpecController.js.map +1 -0
  149. package/build/src/controllers/rc/runtime/index.d.ts +3 -0
  150. package/build/src/controllers/rc/runtime/index.js +28 -0
  151. package/build/src/controllers/rc/runtime/index.js.map +1 -0
  152. package/build/src/main.js +4 -0
  153. package/build/src/main.js.map +1 -1
  154. package/build/src/middleware/validate/index.d.ts +1 -0
  155. package/build/src/middleware/validate/index.js +3 -1
  156. package/build/src/middleware/validate/index.js.map +1 -1
  157. package/build/src/middleware/validate/validateUseRcBlockMiddleware.d.ts +10 -0
  158. package/build/src/middleware/validate/validateUseRcBlockMiddleware.js +58 -0
  159. package/build/src/middleware/validate/validateUseRcBlockMiddleware.js.map +1 -0
  160. package/build/src/services/accounts/AccountsStakingInfoService.js +0 -1
  161. package/build/src/services/accounts/AccountsStakingInfoService.js.map +1 -1
  162. package/build/src/services/blocks/BlocksService.js +15 -1
  163. package/build/src/services/blocks/BlocksService.js.map +1 -1
  164. package/build/src/services/pallets/PalletsStakingProgressService.d.ts +56 -0
  165. package/build/src/services/pallets/PalletsStakingProgressService.js +140 -21
  166. package/build/src/services/pallets/PalletsStakingProgressService.js.map +1 -1
  167. package/build/src/services/pallets/PalletsStakingProgressService.spec.js +255 -43
  168. package/build/src/services/pallets/PalletsStakingProgressService.spec.js.map +1 -1
  169. package/build/src/types/requests.d.ts +1 -0
  170. package/build/src/types/responses/AccountAssets.d.ts +4 -0
  171. package/build/src/types/responses/AccountBalanceInfo.d.ts +2 -0
  172. package/build/src/types/responses/AccountPoolAssets.d.ts +6 -2
  173. package/build/src/types/responses/AccountProxyInfo.d.ts +2 -0
  174. package/build/src/types/responses/AccountStakingInfo.d.ts +2 -0
  175. package/build/src/types/responses/AccountStakingPayouts.d.ts +2 -0
  176. package/build/src/types/responses/AccountVestingInfo.d.ts +2 -0
  177. package/build/src/types/responses/PalletStakingProgress.d.ts +2 -0
  178. package/package.json +8 -18
@@ -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,iDAAmD;AACnD,sDAAgE;AAChE,+EAAuD;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;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,MAAM,EAAE,EAAE,EAC9C,GAAG,EACa,EAAE;YAClB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;YAE1C,MAAM,WAAW,GAAG,KAAK,CAAC,OAA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AAG,gBAAgB,AAAnB,CAAoB;AAClC,wCAAe,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,AAAf,CAAgB;kBAFlB,wBAAwB"}
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,C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CAAC,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YACtD,CAAC;iBAAM,CAAC;gBACP,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,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
- const tokenArg = typeof token === 'string'
68
- ? token.toUpperCase()
69
- : // We assume the first token is the native token
70
- this.api.registry.chainTokens[0].toUpperCase();
71
- const withDenomination = denominated === 'true';
72
- const hash = await this.getHashFromAt(at);
73
- const historicApi = await this.api.at(hash);
74
- AccountsBalanceController.sanitizedSend(res, await this.service.fetchAccountBalanceInfo(hash, historicApi, address, tokenArg, withDenomination));
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,iDAAoE;AACpE,6CAA4D;AAC5D,+EAAuD;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;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,KAAK,EAAE,WAAW,EAAE,EAAE,EAC1D,GAAG,EACa,EAAE;YAClB,MAAM,QAAQ,GACb,OAAO,KAAK,KAAK,QAAQ;gBACxB,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE;gBACrB,CAAC,CAAC,gDAAgD;oBACjD,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;YAClD,MAAM,gBAAgB,GAAG,WAAW,KAAK,MAAM,CAAC;YAEhD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;YAC1C,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;YAE5C,yBAAyB,CAAC,aAAa,CACtC,GAAG,EACH,MAAM,IAAI,CAAC,OAAO,CAAC,uBAAuB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAClG,CAAC;QACH,CAAC,CAAC;QAjCD,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,CAAC,CAAC;QAE9E,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"}
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;AACt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AAC,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
- const hash = await this.getHashFromAt(at);
73
- const assetsArray = Array.isArray(assets) ? this.parseQueryParamArrayOrThrow(assets) : [];
74
- AccountsPoolAssetsController.sanitizedSend(res, await this.service.fetchPoolAssetBalances(hash, address, assetsArray));
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
- AccountsPoolAssetsController.sanitizedSend(res, await this.service.fetchPoolAssetApprovals(hash, address, id, delegate));
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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AAkB,CAAC,OAAO,EAAE,qCAAqC,CAAC,CAAC;YAEnF,4BAA4B,CAAC,aAAa,CACzC,GAAG,EACH,MAAM,IAAI,CAAC,OAAO,CAAC,uBAAuB,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,CAAC,CACvE,CAAC;QACH,CAAC,CAAC;QA1CD,IAAI,CAAC,UAAU,EAAE,CAAC;IACnB,CAAC;IAES,UAAU;QACnB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,4BAAe,CAAC,CAAC;QAE5C,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"}
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,oC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rD,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 balance summary of `address`.
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 balance summary of `address`.
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
- const hash = await this.getHashFromAt(at);
35
- AccountsProxyInfoController.sanitizedSend(res, await this.service.fetchAccountProxyInfo(hash, address));
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,iDAAmD;AACnD,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,EAAE,EACtC,GAAG,EACa,EAAE;YAClB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;YAE1C,2BAA2B,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;QACzG,CAAC,CAAC;QAtBD,IAAI,CAAC,UAAU,EAAE,CAAC;IACnB,CAAC;IAES,UAAU;QACnB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,4BAAe,CAAC,CAAC;QAE5C,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;IAClE,CAAC;;AAXM,0CAAc,GAAG,mBAAmB,AAAtB,CAAuB;AACrC,2CAAe,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,AAAd,CAAe;kBAFjB,2BAA2B"}
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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AI,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;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:
@@ -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) `includeClaimedRewards`: Controls whether or not the `claimedRewards`
35
37
  * field is included in the response. Defaults to `true`.
36
38
  * If set to `false`:
@@ -39,6 +41,11 @@ const AbstractController_1 = __importDefault(require("../AbstractController"));
39
41
  * will be skipped, potentially speeding up the response time.
40
42
  *
41
43
  * Returns:
44
+ * - When using `useRcBlock=true`: 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 `useRcBlock=false` or omitted: A single response object.
47
+ *
48
+ * Response object structure:
42
49
  * - `at`: Block number and hash at which the call was made.
43
50
  * - `rewardDestination`: The account to which rewards will be paid. Can be 'Staked' (Stash
44
51
  * account, adding to the amount at stake), 'Stash' (Stash address, not adding to the amount at
@@ -57,6 +64,8 @@ const AbstractController_1 = __importDefault(require("../AbstractController"));
57
64
  * with an `era` at which `value` will be unlocked.
58
65
  * - `claimedRewards`: Array of eras for which the stakers behind a validator have claimed
59
66
  * rewards. Only updated for _validators._
67
+ * - `rcBlockNumber`: The relay chain block number used for the query. Only present when `useRcBlock=true`.
68
+ * - `ahTimestamp`: The Asset Hub block timestamp. Only present when `useRcBlock=true`.
60
69
  *
61
70
  * Note: Runtime versions of Kusama less than 1062 will either have `lastReward` in place of
62
71
  * `claimedRewards`, or no field at all. This is related to changes in reward distribution. See:
@@ -78,22 +87,54 @@ class AccountsStakingInfoController extends AbstractController_1.default {
78
87
  * @param req Express Request
79
88
  * @param res Express Response
80
89
  */
81
- this.getAccountStakingInfo = async ({ params: { address }, query: { at, includeClaimedRewards } }, res) => {
90
+ this.getAccountStakingInfo = async ({ params: { address }, query: { at, useRcBlock, includeClaimedRewards } }, res) => {
82
91
  const { isAssetHubMigrated } = apiRegistry_1.ApiPromiseRegistry.assetHubInfo;
83
- const hash = await this.getHashFromAt(at);
84
92
  const includeClaimedRewardsArg = includeClaimedRewards !== 'false';
85
- if (isAssetHubMigrated) {
86
- AccountsStakingInfoController.sanitizedSend(res, await this.service.fetchAccountStakingInfoAssetHub(hash, includeClaimedRewardsArg, address));
93
+ if (useRcBlock === 'true') {
94
+ const rcAtResults = await this.getHashFromRcAt(at);
95
+ // Return empty array if no Asset Hub blocks found
96
+ if (rcAtResults.length === 0) {
97
+ AccountsStakingInfoController.sanitizedSend(res, []);
98
+ return;
99
+ }
100
+ // Process each Asset Hub block found
101
+ const results = [];
102
+ for (const { ahHash, rcBlockNumber } of rcAtResults) {
103
+ let result;
104
+ if (isAssetHubMigrated) {
105
+ result = await this.service.fetchAccountStakingInfoAssetHub(ahHash, includeClaimedRewardsArg, address);
106
+ }
107
+ else {
108
+ result = await this.service.fetchAccountStakingInfo(ahHash, includeClaimedRewardsArg, address);
109
+ }
110
+ const apiAt = await this.api.at(ahHash);
111
+ const ahTimestamp = await apiAt.query.timestamp.now();
112
+ const enhancedResult = {
113
+ ...result,
114
+ rcBlockNumber,
115
+ ahTimestamp: ahTimestamp.toString(),
116
+ };
117
+ results.push(enhancedResult);
118
+ }
119
+ AccountsStakingInfoController.sanitizedSend(res, results);
87
120
  }
88
121
  else {
89
- AccountsStakingInfoController.sanitizedSend(res, await this.service.fetchAccountStakingInfo(hash, includeClaimedRewardsArg, address));
122
+ const hash = await this.getHashFromAt(at);
123
+ let result;
124
+ if (isAssetHubMigrated) {
125
+ result = await this.service.fetchAccountStakingInfoAssetHub(hash, includeClaimedRewardsArg, address);
126
+ }
127
+ else {
128
+ result = await this.service.fetchAccountStakingInfo(hash, includeClaimedRewardsArg, address);
129
+ }
130
+ AccountsStakingInfoController.sanitizedSend(res, result);
90
131
  }
91
132
  };
92
133
  this.initRoutes();
93
134
  this.options = options;
94
135
  }
95
136
  initRoutes() {
96
- this.router.use(this.path, middleware_1.validateAddress, (0, middleware_1.validateBoolean)(['includeClaimedRewards']));
137
+ this.router.use(this.path, middleware_1.validateAddress, (0, middleware_1.validateBoolean)(['includeClaimedRewards']), middleware_1.validateUseRcBlock);
97
138
  this.safeMountAsyncGetHandlers([['', this.getAccountStakingInfo]]);
98
139
  }
99
140
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AccountsStakingInfoController.js","sourceRoot":"","sources":["../../../../src/controllers/accounts/AccountsStakingInfoController.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,mDAAuD;AACvD,iDAAoE;AACpE,6CAA4D;AAC5D,+EAAuD;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAqB,6BAA8B,SAAQ,4BAA8C;IAUxG,YAAY,GAAW,EAAE,OAA0B;QAClD,KAAK,CAAC,GAAG,EAAE,iCAAiC,EAAE,IAAI,qCAA0B,CAAC,GAAG,CAAC,CAAC,CAAC;QAWpF;;;;;WAKG;QACK,0BAAqB,GAAkC,KAAK,EACnE,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,qBAAqB,EAAE,EAAE,EAC7D,GAAG,EACa,EAAE;YAClB,MAAM,EAAE,kBAAkB,EAAE,GAAG,gCAAkB,CAAC,YAAY,CAAC;YAC/D,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;YAC1C,MAAM,wBAAwB,GAAG,qBAAqB,KAAK,OAAO,CAAC;YAEnE,IAAI,kBAAkB,EAAE,CAAC;gBACxB,6BAA6B,CAAC,aAAa,CAC1C,GAAG,EACH,MAAM,IAAI,CAAC,OAAO,CAAC,+BAA+B,CAAC,IAAI,EAAE,wBAAwB,EAAE,OAAO,CAAC,CAC3F,CAAC;YACH,CAAC;iBAAM,CAAC;gBACP,6BAA6B,CAAC,aAAa,CAC1C,GAAG,EACH,MAAM,IAAI,CAAC,OAAO,CAAC,uBAAuB,CAAC,IAAI,EAAE,wBAAwB,EAAE,OAAO,CAAC,CACnF,CAAC;YACH,CAAC;QACF,CAAC,CAAC;QAnCD,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;IAES,UAAU;QACnB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,4BAAe,EAAE,IAAA,4BAAe,EAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;QAExF,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IACpE,CAAC;;AAjBM,4CAAc,GAAG,qBAAqB,AAAxB,CAAyB;AACvC,6CAAe,GAAG;IACxB,CAAC,SAAS,EAAE,QAAQ,CAAC;IACrB,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;IACvC,CAAC,kBAAkB,EAAE,QAAQ,CAAC;IAC9B,CAAC,SAAS,EAAE,iBAAiB,CAAC;CAC9B,AALqB,CAKpB;kBATkB,6BAA6B"}
1
+ {"version":3,"file":"AccountsStakingInfoController.js","sourceRoot":"","sources":["../../../../src/controllers/accounts/AccountsStakingInfoController.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;A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C,uBAAuB,CAAC,CAAC,EAAE,+BAAkB,CAAC,CAAC;QAE5G,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IACpE,CAAC;;AAjBM,4CAAc,GAAG,qBAAqB,AAAxB,CAAyB;AACvC,6CAAe,GAAG;IACxB,CAAC,SAAS,EAAE,QAAQ,CAAC;IACrB,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;IACvC,CAAC,kBAAkB,EAAE,QAAQ,CAAC;IAC9B,CAAC,SAAS,EAAE,iBAAiB,CAAC;CAC9B,AALqB,CAKpB;kBATkB,6BAA6B"}
@@ -13,8 +13,15 @@ import AbstractController from '../AbstractController';
13
13
  * - (Optional) `era`: The era to query at. Max era payout info is available for
14
14
  * is the latest finished era: `active_era - 1`. Defaults to `active_era - 1`.
15
15
  * - (Optional) `unclaimedOnly`: Only return unclaimed rewards. Defaults to true.
16
+ * - (Optional) `useRcBlock`: When true, treats the `at` parameter as a relay chain block
17
+ * to find corresponding Asset Hub blocks. Only supported for Asset Hub endpoints.
16
18
  *
17
19
  * Returns:
20
+ * - When using `useRcBlock=true`: An array of response objects, one for each Asset Hub block found
21
+ * in the specified relay chain block. Returns empty array `[]` if no Asset Hub blocks found.
22
+ * - When using `useRcBlock=false` or omitted: A single response object.
23
+ *
24
+ * Response object structure:
18
25
  * - `at`:
19
26
  * - `hash`: The block's hash.
20
27
  * - `height`: The block's height.
@@ -33,6 +40,8 @@ import AbstractController from '../AbstractController';
33
40
  * takes as commission, expressed as a Perbill.
34
41
  * - `totalValidatorExposure`: The sum of the validator's and its nominators' stake.
35
42
  * - `nominatorExposure`: The amount of stake the nominator has behind the validator.
43
+ * - `rcBlockNumber`: The relay chain block number used for the query. Only present when `useRcBlock=true`.
44
+ * - `ahTimestamp`: The Asset Hub block timestamp. Only present when `useRcBlock=true`.
36
45
  *
37
46
  * Description:
38
47
  * Returns payout information for the last specified eras. If specifying both