@xyo-network/xl1-protocol-sdk 1.17.7 → 1.18.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 (309) hide show
  1. package/dist/neutral/CreatableProvider/AbstractCreatableProvider.d.ts +104 -1
  2. package/dist/neutral/CreatableProvider/AbstractCreatableProvider.d.ts.map +1 -1
  3. package/dist/neutral/CreatableProvider/CreatableProvider.d.ts +27 -10
  4. package/dist/neutral/CreatableProvider/CreatableProvider.d.ts.map +1 -1
  5. package/dist/neutral/CreatableProvider/CreatableProviderRegistry.d.ts.map +1 -1
  6. package/dist/neutral/CreatableProvider/ProviderFactory.d.ts +11 -3
  7. package/dist/neutral/CreatableProvider/ProviderFactory.d.ts.map +1 -1
  8. package/dist/neutral/CreatableProvider/ProviderFactoryLocator.d.ts +19 -13
  9. package/dist/neutral/CreatableProvider/ProviderFactoryLocator.d.ts.map +1 -1
  10. package/dist/neutral/CreatableProvider/ProviderFactoryLocatorInstance.d.ts +14 -10
  11. package/dist/neutral/CreatableProvider/ProviderFactoryLocatorInstance.d.ts.map +1 -1
  12. package/dist/neutral/config/Bridge.d.ts +3 -0
  13. package/dist/neutral/config/Bridge.d.ts.map +1 -1
  14. package/dist/neutral/config/Chain.d.ts +1 -1
  15. package/dist/neutral/config/Config.d.ts +8 -5
  16. package/dist/neutral/config/Config.d.ts.map +1 -1
  17. package/dist/neutral/config/Log.d.ts +1 -1
  18. package/dist/neutral/config/Services.d.ts +2 -2
  19. package/dist/neutral/config/Services.d.ts.map +1 -1
  20. package/dist/neutral/createDeclarationPayload.d.ts +4 -0
  21. package/dist/neutral/createDeclarationPayload.d.ts.map +1 -0
  22. package/dist/neutral/createTransferPayload.d.ts +4 -0
  23. package/dist/neutral/createTransferPayload.d.ts.map +1 -0
  24. package/dist/neutral/driver/cache/LruCacheMap.d.ts +2 -2
  25. package/dist/neutral/driver/cache/LruCacheMap.d.ts.map +1 -1
  26. package/dist/neutral/driver/memory/MemoryMap.d.ts +2 -2
  27. package/dist/neutral/driver/memory/MemoryMap.d.ts.map +1 -1
  28. package/dist/neutral/index.d.ts +3 -0
  29. package/dist/neutral/index.d.ts.map +1 -1
  30. package/dist/neutral/index.mjs +1887 -632
  31. package/dist/neutral/index.mjs.map +1 -1
  32. package/dist/neutral/map/MapType.d.ts +3 -2
  33. package/dist/neutral/map/MapType.d.ts.map +1 -1
  34. package/dist/neutral/model/ChainContext/ChainContext.d.ts +4 -4
  35. package/dist/neutral/model/ChainContext/ChainContext.d.ts.map +1 -1
  36. package/dist/neutral/model/ChainQualification.d.ts +42 -0
  37. package/dist/neutral/model/ChainQualification.d.ts.map +1 -0
  38. package/dist/neutral/model/PayloadBundle/bundledPayloadToHydratedTransaction.d.ts +2 -2
  39. package/dist/neutral/model/PayloadBundle/bundledPayloadToHydratedTransaction.d.ts.map +1 -1
  40. package/dist/neutral/model/index.d.ts +1 -1
  41. package/dist/neutral/model/index.d.ts.map +1 -1
  42. package/dist/neutral/primitives/block/index.d.ts +2 -0
  43. package/dist/neutral/primitives/block/index.d.ts.map +1 -0
  44. package/dist/neutral/primitives/block/range/blockRangeSteps.d.ts +3 -0
  45. package/dist/neutral/primitives/block/range/blockRangeSteps.d.ts.map +1 -0
  46. package/dist/neutral/primitives/block/range/index.d.ts +2 -0
  47. package/dist/neutral/primitives/block/range/index.d.ts.map +1 -0
  48. package/dist/neutral/primitives/chain/getWindowedChain.d.ts +26 -0
  49. package/dist/neutral/primitives/chain/getWindowedChain.d.ts.map +1 -0
  50. package/dist/neutral/primitives/chain/index.d.ts +4 -0
  51. package/dist/neutral/primitives/chain/index.d.ts.map +1 -0
  52. package/dist/neutral/primitives/chain/step/chainStepRewardAddress.d.ts +5 -0
  53. package/dist/neutral/primitives/chain/step/chainStepRewardAddress.d.ts.map +1 -0
  54. package/dist/neutral/primitives/chain/step/index.d.ts +5 -0
  55. package/dist/neutral/primitives/chain/step/index.d.ts.map +1 -0
  56. package/dist/neutral/primitives/chain/step/stepRewardBlock.d.ts +4 -0
  57. package/dist/neutral/primitives/chain/step/stepRewardBlock.d.ts.map +1 -0
  58. package/dist/neutral/primitives/chain/step/stepRewardTotal.d.ts +4 -0
  59. package/dist/neutral/primitives/chain/step/stepRewardTotal.d.ts.map +1 -0
  60. package/dist/neutral/primitives/chain/step/stepsRewardTotal.d.ts +6 -0
  61. package/dist/neutral/primitives/chain/step/stepsRewardTotal.d.ts.map +1 -0
  62. package/dist/neutral/primitives/chain/time/externalBlockNumberFromXL1BlockNumber.d.ts +5 -0
  63. package/dist/neutral/primitives/chain/time/externalBlockNumberFromXL1BlockNumber.d.ts.map +1 -0
  64. package/dist/neutral/primitives/chain/time/externalBlockRangeFromStep.d.ts +5 -0
  65. package/dist/neutral/primitives/chain/time/externalBlockRangeFromStep.d.ts.map +1 -0
  66. package/dist/neutral/primitives/chain/time/externalBlockRangeFromXL1BlockRange.d.ts +5 -0
  67. package/dist/neutral/primitives/chain/time/externalBlockRangeFromXL1BlockRange.d.ts.map +1 -0
  68. package/dist/neutral/primitives/chain/time/index.d.ts +4 -0
  69. package/dist/neutral/primitives/chain/time/index.d.ts.map +1 -0
  70. package/dist/neutral/primitives/index.d.ts +7 -0
  71. package/dist/neutral/primitives/index.d.ts.map +1 -1
  72. package/dist/neutral/primitives/mapToMapType.d.ts +3 -0
  73. package/dist/neutral/primitives/mapToMapType.d.ts.map +1 -0
  74. package/dist/neutral/primitives/payload/index.d.ts +2 -0
  75. package/dist/neutral/primitives/payload/index.d.ts.map +1 -0
  76. package/dist/neutral/primitives/payload/mergeTransfers.d.ts +4 -0
  77. package/dist/neutral/primitives/payload/mergeTransfers.d.ts.map +1 -0
  78. package/dist/neutral/primitives/readPayloadMapFromStore.d.ts +5 -4
  79. package/dist/neutral/primitives/readPayloadMapFromStore.d.ts.map +1 -1
  80. package/dist/neutral/primitives/rewards/index.d.ts +2 -0
  81. package/dist/neutral/primitives/rewards/index.d.ts.map +1 -0
  82. package/dist/neutral/primitives/rewards/networkStakeStepRewardPositionWeight.d.ts +5 -0
  83. package/dist/neutral/primitives/rewards/networkStakeStepRewardPositionWeight.d.ts.map +1 -0
  84. package/dist/neutral/primitives/stake/activeStakeAtTimeByAddress.d.ts +4 -0
  85. package/dist/neutral/primitives/stake/activeStakeAtTimeByAddress.d.ts.map +1 -0
  86. package/dist/neutral/primitives/stake/activeStakeAtTimeByPosition.d.ts +3 -0
  87. package/dist/neutral/primitives/stake/activeStakeAtTimeByPosition.d.ts.map +1 -0
  88. package/dist/neutral/primitives/stake/allStakersForRange.d.ts +4 -0
  89. package/dist/neutral/primitives/stake/allStakersForRange.d.ts.map +1 -0
  90. package/dist/neutral/primitives/stake/allStakersForStep.d.ts +6 -0
  91. package/dist/neutral/primitives/stake/allStakersForStep.d.ts.map +1 -0
  92. package/dist/neutral/primitives/stake/index.d.ts +7 -0
  93. package/dist/neutral/primitives/stake/index.d.ts.map +1 -0
  94. package/dist/neutral/primitives/stake/mergedAddRemoveStakeEventsByPosition.d.ts +3 -0
  95. package/dist/neutral/primitives/stake/mergedAddRemoveStakeEventsByPosition.d.ts.map +1 -0
  96. package/dist/neutral/primitives/stake/mergedAddRemoveStakeEventsByStaker.d.ts +4 -0
  97. package/dist/neutral/primitives/stake/mergedAddRemoveStakeEventsByStaker.d.ts.map +1 -0
  98. package/dist/neutral/primitives/stake/weightedStakeForRangeByPosition.d.ts +6 -0
  99. package/dist/neutral/primitives/stake/weightedStakeForRangeByPosition.d.ts.map +1 -0
  100. package/dist/neutral/primitives/uncle/findBestUncle.d.ts +24 -0
  101. package/dist/neutral/primitives/uncle/findBestUncle.d.ts.map +1 -0
  102. package/dist/neutral/primitives/uncle/findUncles.d.ts +26 -0
  103. package/dist/neutral/primitives/uncle/findUncles.d.ts.map +1 -0
  104. package/dist/neutral/primitives/uncle/index.d.ts +4 -0
  105. package/dist/neutral/primitives/uncle/index.d.ts.map +1 -0
  106. package/dist/neutral/primitives/uncle/scoreUncle.d.ts +3 -0
  107. package/dist/neutral/primitives/uncle/scoreUncle.d.ts.map +1 -0
  108. package/dist/neutral/provider/DataLake.d.ts +10 -9
  109. package/dist/neutral/provider/DataLake.d.ts.map +1 -1
  110. package/dist/neutral/provider/XyoConnection.d.ts +4 -1
  111. package/dist/neutral/provider/XyoConnection.d.ts.map +1 -1
  112. package/dist/neutral/provider/XyoGatewayRunner.d.ts +3 -3
  113. package/dist/neutral/provider/XyoGatewayRunner.d.ts.map +1 -1
  114. package/dist/neutral/provider/XyoRunner.d.ts +5 -2
  115. package/dist/neutral/provider/XyoRunner.d.ts.map +1 -1
  116. package/dist/neutral/provider/viewer/XyoViewer.d.ts +16 -13
  117. package/dist/neutral/provider/viewer/XyoViewer.d.ts.map +1 -1
  118. package/dist/neutral/runners/Block.d.ts +7 -2
  119. package/dist/neutral/runners/Block.d.ts.map +1 -1
  120. package/dist/neutral/runners/Mempool.d.ts +4 -1
  121. package/dist/neutral/runners/Mempool.d.ts.map +1 -1
  122. package/dist/neutral/services/Chain/ChainService.d.ts +2 -2
  123. package/dist/neutral/services/Chain/ChainService.d.ts.map +1 -1
  124. package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts +65 -21
  125. package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts.map +1 -1
  126. package/dist/neutral/simple/block/SimpleBlockViewer.d.ts +9 -6
  127. package/dist/neutral/simple/block/SimpleBlockViewer.d.ts.map +1 -1
  128. package/dist/neutral/simple/blockValidation/SimpleBlockValidationViewer.d.ts +31 -0
  129. package/dist/neutral/simple/blockValidation/SimpleBlockValidationViewer.d.ts.map +1 -0
  130. package/dist/neutral/simple/blockValidation/index.d.ts +2 -0
  131. package/dist/neutral/simple/blockValidation/index.d.ts.map +1 -0
  132. package/dist/neutral/simple/chainStake/{SimpleChainStakeViewer.d.ts → SimpleStakeViewer.d.ts} +3 -5
  133. package/dist/neutral/simple/chainStake/SimpleStakeViewer.d.ts.map +1 -0
  134. package/dist/neutral/simple/chainStake/index.d.ts +1 -1
  135. package/dist/neutral/simple/chainStake/index.d.ts.map +1 -1
  136. package/dist/neutral/simple/datalake/AbstractSimpleDataLake.d.ts +6 -3
  137. package/dist/neutral/simple/datalake/AbstractSimpleDataLake.d.ts.map +1 -1
  138. package/dist/neutral/simple/datalake/SimpleDataLakeRunner.d.ts +4 -3
  139. package/dist/neutral/simple/datalake/SimpleDataLakeRunner.d.ts.map +1 -1
  140. package/dist/neutral/simple/datalake/SimpleDataLakeViewer.d.ts +0 -3
  141. package/dist/neutral/simple/datalake/SimpleDataLakeViewer.d.ts.map +1 -1
  142. package/dist/neutral/simple/index.d.ts +2 -0
  143. package/dist/neutral/simple/index.d.ts.map +1 -1
  144. package/dist/neutral/simple/mempool/SimpleMempoolRunner.d.ts +8 -4
  145. package/dist/neutral/simple/mempool/SimpleMempoolRunner.d.ts.map +1 -1
  146. package/dist/neutral/simple/mempool/SimpleMempoolViewer.d.ts.map +1 -1
  147. package/dist/neutral/simple/runner/SimpleXyoRunner.d.ts +24 -6
  148. package/dist/neutral/simple/runner/SimpleXyoRunner.d.ts.map +1 -1
  149. package/dist/neutral/simple/{chainStakeEvents/SimpleChainStakeEventsViewer.d.ts → stakeEvents/SimpleStakeEventsViewer.d.ts} +3 -3
  150. package/dist/neutral/simple/stakeEvents/SimpleStakeEventsViewer.d.ts.map +1 -0
  151. package/dist/neutral/simple/stakeEvents/index.d.ts +2 -0
  152. package/dist/neutral/simple/stakeEvents/index.d.ts.map +1 -0
  153. package/dist/neutral/simple/timesync/SimpleTimeSyncViewer.d.ts +4 -3
  154. package/dist/neutral/simple/timesync/SimpleTimeSyncViewer.d.ts.map +1 -1
  155. package/dist/neutral/status/RuntimeStatusMonitor.d.ts +31 -0
  156. package/dist/neutral/status/RuntimeStatusMonitor.d.ts.map +1 -0
  157. package/dist/neutral/status/ServiceStatus.d.ts +8 -0
  158. package/dist/neutral/status/ServiceStatus.d.ts.map +1 -0
  159. package/dist/neutral/status/index.d.ts +3 -0
  160. package/dist/neutral/status/index.d.ts.map +1 -0
  161. package/dist/neutral/summary/model/summary.d.ts +4 -5
  162. package/dist/neutral/summary/model/summary.d.ts.map +1 -1
  163. package/dist/neutral/summary/primitives/balances/balancesStepSummaryFromRange.d.ts +1 -1
  164. package/dist/neutral/summary/primitives/balances/balancesStepSummaryFromRange.d.ts.map +1 -1
  165. package/dist/neutral/summary/primitives/balances/balancesSummary.d.ts +2 -2
  166. package/dist/neutral/summary/primitives/balances/balancesSummary.d.ts.map +1 -1
  167. package/dist/neutral/summary/primitives/schemas/schemasSummary.d.ts +2 -2
  168. package/dist/neutral/summary/primitives/schemas/schemasSummary.d.ts.map +1 -1
  169. package/dist/neutral/summary/primitives/transfers/transfersSummary.d.ts +2 -2
  170. package/dist/neutral/summary/primitives/transfers/transfersSummary.d.ts.map +1 -1
  171. package/dist/neutral/transaction/TransactionBuilder.d.ts +82 -0
  172. package/dist/neutral/transaction/TransactionBuilder.d.ts.map +1 -0
  173. package/dist/neutral/transaction/buildRandomTransaction.d.ts +6 -0
  174. package/dist/neutral/transaction/buildRandomTransaction.d.ts.map +1 -0
  175. package/dist/neutral/transaction/index.d.ts +2 -0
  176. package/dist/neutral/transaction/index.d.ts.map +1 -1
  177. package/dist/neutral/viewers/AccountBalance.d.ts +35 -15
  178. package/dist/neutral/viewers/AccountBalance.d.ts.map +1 -1
  179. package/dist/neutral/viewers/Block.d.ts +4 -1
  180. package/dist/neutral/viewers/Block.d.ts.map +1 -1
  181. package/dist/neutral/viewers/BlockValidation.d.ts +54 -0
  182. package/dist/neutral/viewers/BlockValidation.d.ts.map +1 -0
  183. package/dist/neutral/viewers/ChainStakeViewer.d.ts +1 -2
  184. package/dist/neutral/viewers/ChainStakeViewer.d.ts.map +1 -1
  185. package/dist/neutral/viewers/Fork.d.ts +0 -1
  186. package/dist/neutral/viewers/Fork.d.ts.map +1 -1
  187. package/dist/neutral/viewers/Stake.d.ts +0 -1
  188. package/dist/neutral/viewers/Stake.d.ts.map +1 -1
  189. package/dist/neutral/viewers/StakeIntent.d.ts +2 -2
  190. package/dist/neutral/viewers/StakeIntent.d.ts.map +1 -1
  191. package/dist/neutral/viewers/TransactionValidation.d.ts +35 -0
  192. package/dist/neutral/viewers/TransactionValidation.d.ts.map +1 -0
  193. package/dist/neutral/viewers/index.d.ts +2 -1
  194. package/dist/neutral/viewers/index.d.ts.map +1 -1
  195. package/package.json +8 -6
  196. package/src/CreatableProvider/AbstractCreatableProvider.ts +60 -3
  197. package/src/CreatableProvider/CreatableProvider.ts +38 -11
  198. package/src/CreatableProvider/CreatableProviderRegistry.ts +10 -5
  199. package/src/CreatableProvider/ProviderFactory.ts +73 -10
  200. package/src/CreatableProvider/ProviderFactoryLocator.ts +79 -19
  201. package/src/CreatableProvider/ProviderFactoryLocatorInstance.ts +33 -10
  202. package/src/config/Bridge.ts +22 -4
  203. package/src/config/Chain.ts +2 -2
  204. package/src/config/Services.ts +4 -2
  205. package/src/createDeclarationPayload.ts +14 -0
  206. package/src/createTransferPayload.ts +15 -0
  207. package/src/driver/cache/LruCacheMap.ts +2 -2
  208. package/src/driver/memory/MemoryMap.ts +2 -2
  209. package/src/index.ts +3 -0
  210. package/src/map/MapType.ts +4 -2
  211. package/src/model/ChainContext/ChainContext.ts +4 -4
  212. package/src/model/ChainQualification.ts +33 -0
  213. package/src/model/PayloadBundle/bundledPayloadToHydratedTransaction.ts +2 -2
  214. package/src/model/index.ts +1 -1
  215. package/src/primitives/block/index.ts +1 -0
  216. package/src/primitives/block/range/blockRangeSteps.ts +22 -0
  217. package/src/primitives/block/range/index.ts +1 -0
  218. package/src/primitives/chain/getWindowedChain.ts +23 -0
  219. package/src/primitives/chain/index.ts +3 -0
  220. package/src/primitives/chain/step/chainStepRewardAddress.ts +28 -0
  221. package/src/primitives/chain/step/index.ts +4 -0
  222. package/src/primitives/chain/step/stepRewardBlock.ts +11 -0
  223. package/src/primitives/chain/step/stepRewardTotal.ts +45 -0
  224. package/src/primitives/chain/step/stepsRewardTotal.ts +34 -0
  225. package/src/primitives/chain/time/externalBlockNumberFromXL1BlockNumber.ts +31 -0
  226. package/src/primitives/chain/time/externalBlockRangeFromStep.ts +19 -0
  227. package/src/primitives/chain/time/externalBlockRangeFromXL1BlockRange.ts +16 -0
  228. package/src/primitives/chain/time/index.ts +3 -0
  229. package/src/primitives/index.ts +7 -0
  230. package/src/primitives/mapToMapType.ts +35 -0
  231. package/src/primitives/payload/index.ts +1 -0
  232. package/src/primitives/payload/mergeTransfers.ts +15 -0
  233. package/src/primitives/readPayloadMapFromStore.ts +38 -8
  234. package/src/primitives/rewards/index.ts +1 -0
  235. package/src/primitives/rewards/networkStakeStepRewardPositionWeight.ts +21 -0
  236. package/src/primitives/stake/activeStakeAtTimeByAddress.ts +26 -0
  237. package/src/primitives/stake/activeStakeAtTimeByPosition.ts +24 -0
  238. package/src/primitives/stake/allStakersForRange.ts +31 -0
  239. package/src/primitives/stake/allStakersForStep.ts +22 -0
  240. package/src/primitives/stake/index.ts +6 -0
  241. package/src/primitives/stake/mergedAddRemoveStakeEventsByPosition.ts +14 -0
  242. package/src/primitives/stake/mergedAddRemoveStakeEventsByStaker.ts +17 -0
  243. package/src/primitives/stake/weightedStakeForRangeByPosition.ts +54 -0
  244. package/src/primitives/uncle/findBestUncle.ts +8 -0
  245. package/src/primitives/uncle/findUncles.ts +75 -0
  246. package/src/primitives/uncle/index.ts +3 -0
  247. package/src/primitives/uncle/scoreUncle.ts +6 -0
  248. package/src/provider/DataLake.ts +12 -11
  249. package/src/provider/XyoConnection.ts +5 -1
  250. package/src/provider/XyoGatewayRunner.ts +3 -3
  251. package/src/provider/XyoRunner.ts +6 -2
  252. package/src/provider/viewer/XyoViewer.ts +16 -15
  253. package/src/runners/Block.ts +10 -2
  254. package/src/runners/Mempool.ts +6 -1
  255. package/src/services/Chain/ChainService.ts +2 -4
  256. package/src/simple/accountBalance/SimpleAccountBalanceViewer.ts +65 -42
  257. package/src/simple/block/SimpleBlockViewer.ts +47 -14
  258. package/src/simple/blockValidation/SimpleBlockValidationViewer.ts +126 -0
  259. package/src/simple/blockValidation/index.ts +1 -0
  260. package/src/simple/chainStake/{SimpleChainStakeViewer.ts → SimpleStakeViewer.ts} +11 -16
  261. package/src/simple/chainStake/index.ts +1 -1
  262. package/src/simple/datalake/AbstractSimpleDataLake.ts +19 -18
  263. package/src/simple/datalake/SimpleDataLakeRunner.ts +4 -3
  264. package/src/simple/datalake/SimpleDataLakeViewer.ts +0 -19
  265. package/src/simple/index.ts +2 -0
  266. package/src/simple/mempool/SimpleMempoolRunner.ts +13 -8
  267. package/src/simple/mempool/SimpleMempoolViewer.ts +6 -1
  268. package/src/simple/runner/SimpleXyoRunner.ts +41 -16
  269. package/src/simple/{chainStakeEvents/SimpleChainStakeEventsViewer.ts → stakeEvents/SimpleStakeEventsViewer.ts} +5 -5
  270. package/src/simple/stakeEvents/index.ts +1 -0
  271. package/src/simple/timesync/SimpleTimeSyncViewer.ts +27 -6
  272. package/src/status/RuntimeStatusMonitor.ts +117 -0
  273. package/src/status/ServiceStatus.ts +20 -0
  274. package/src/status/index.ts +2 -0
  275. package/src/summary/model/summary.ts +6 -5
  276. package/src/summary/primitives/balances/balancesStepSummaryFromRange.ts +2 -3
  277. package/src/summary/primitives/balances/balancesSummary.ts +12 -12
  278. package/src/summary/primitives/schemas/schemasSummary.ts +12 -10
  279. package/src/summary/primitives/transfers/transfersSummary.ts +14 -16
  280. package/src/transaction/TransactionBuilder.ts +162 -0
  281. package/src/transaction/buildRandomTransaction.ts +36 -0
  282. package/src/transaction/hydrateTransaction.ts +1 -1
  283. package/src/transaction/index.ts +2 -0
  284. package/src/viewers/AccountBalance.ts +22 -14
  285. package/src/viewers/Block.ts +6 -1
  286. package/src/viewers/BlockValidation.ts +47 -0
  287. package/src/viewers/ChainStakeViewer.ts +1 -2
  288. package/src/viewers/Fork.ts +0 -1
  289. package/src/viewers/Stake.ts +0 -1
  290. package/src/viewers/StakeIntent.ts +2 -2
  291. package/src/viewers/TransactionValidation.ts +35 -0
  292. package/src/viewers/index.ts +2 -1
  293. package/dist/neutral/model/Qualified.d.ts +0 -6
  294. package/dist/neutral/model/Qualified.d.ts.map +0 -1
  295. package/dist/neutral/simple/chain/SimpleChainViewer.d.ts +0 -15
  296. package/dist/neutral/simple/chain/SimpleChainViewer.d.ts.map +0 -1
  297. package/dist/neutral/simple/chain/index.d.ts +0 -2
  298. package/dist/neutral/simple/chain/index.d.ts.map +0 -1
  299. package/dist/neutral/simple/chainStake/SimpleChainStakeViewer.d.ts.map +0 -1
  300. package/dist/neutral/simple/chainStakeEvents/SimpleChainStakeEventsViewer.d.ts.map +0 -1
  301. package/dist/neutral/simple/chainStakeEvents/index.d.ts +0 -2
  302. package/dist/neutral/simple/chainStakeEvents/index.d.ts.map +0 -1
  303. package/dist/neutral/viewers/Chain.d.ts +0 -11
  304. package/dist/neutral/viewers/Chain.d.ts.map +0 -1
  305. package/src/model/Qualified.ts +0 -9
  306. package/src/simple/chain/SimpleChainViewer.ts +0 -28
  307. package/src/simple/chain/index.ts +0 -1
  308. package/src/simple/chainStakeEvents/index.ts +0 -1
  309. package/src/viewers/Chain.ts +0 -13
@@ -1,8 +1,10 @@
1
1
  import { hasAllLabels, type Labels } from '@xylabs/sdk-js'
2
2
  import { assertEx } from '@xylabs/sdk-js'
3
3
 
4
- import type { ProviderMoniker } from '../model/index.ts'
5
- import type { CreatableProviderFactory } from './CreatableProvider.ts'
4
+ import type { Provider, ProviderMoniker } from '../model/index.ts'
5
+ import type {
6
+ CreatableProviderContext, CreatableProviderFactory, CreatableProviderInstance,
7
+ } from './CreatableProvider.ts'
6
8
  import { type CreatableProviderRegistry, registerCreatableProviderFactory } from './CreatableProviderRegistry.ts'
7
9
  import { hasLabels, type LabeledCreatableProviderFactory } from './LabeledCreatableProviderFactory.ts'
8
10
  import type { ProviderFactoryLocatorInstance } from './ProviderFactoryLocatorInstance.ts'
@@ -11,12 +13,18 @@ import type { ProviderFactoryLocatorInstance } from './ProviderFactoryLocatorIns
11
13
  * A class which encapsulates the Service Locator Pattern for Provider Factories
12
14
  */
13
15
  export class ProviderFactoryLocator implements ProviderFactoryLocatorInstance {
16
+ protected readonly _context: CreatableProviderContext
14
17
  protected readonly _registry: CreatableProviderRegistry
15
18
 
16
19
  private _frozen = false
17
20
 
18
- constructor(registry: CreatableProviderRegistry = {}) {
21
+ constructor(context: Omit<CreatableProviderContext, 'locator'>, registry: CreatableProviderRegistry = {}) {
19
22
  this._registry = registry
23
+ this._context = { ...context, locator: this }
24
+ }
25
+
26
+ get context() {
27
+ return this._context
20
28
  }
21
29
 
22
30
  /**
@@ -26,29 +34,56 @@ export class ProviderFactoryLocator implements ProviderFactoryLocatorInstance {
26
34
  return this._registry
27
35
  }
28
36
 
29
- static empty() {
30
- return new ProviderFactoryLocator({})
37
+ static empty(context: Omit<CreatableProviderContext, 'locator'>) {
38
+ return new ProviderFactoryLocator(context, {})
39
+ }
40
+
41
+ static standard(context: Omit<CreatableProviderContext, 'locator'>) {
42
+ return new ProviderFactoryLocator(context, {})
31
43
  }
32
44
 
33
- static standard() {
34
- return new ProviderFactoryLocator({})
45
+ /** @deprecated use getInstance instead */
46
+ async create<TProvider extends Provider<ProviderMoniker>>(
47
+ moniker: TProvider['moniker'],
48
+ params?: Partial<CreatableProviderInstance<TProvider>['params']>,
49
+ labels?: Labels,
50
+ ) {
51
+ return await this.getInstance<TProvider>(moniker, params, labels)
35
52
  }
36
53
 
37
54
  freeze() {
38
55
  this._frozen = true
39
56
  }
40
57
 
58
+ async getInstance<TProvider extends Provider<ProviderMoniker>>(
59
+ moniker: TProvider['moniker'],
60
+ params?: Partial<CreatableProviderInstance<TProvider>['params']>,
61
+ labels?: Labels,
62
+ ) {
63
+ const resolvedParams = {
64
+ ...params,
65
+ context: {
66
+ ...this.context,
67
+ ...params?.context,
68
+ } as CreatableProviderInstance<TProvider>['params']['context'],
69
+ } as CreatableProviderInstance<TProvider>['params']
70
+ const factory = this.locate<TProvider>(moniker, labels)
71
+ const result = await factory.getInstance(resolvedParams)
72
+ return result
73
+ }
74
+
41
75
  /**
42
- * Locates a provider factory that matches the supplied schema and labels
43
- * @param schema The config schema for the provider
76
+ * Locates a provider factory that matches the supplied moniker and labels
77
+ * @param moniker The config moniker for the provider
44
78
  * @param labels The labels for the provider factory
45
- * @returns A provider factory that matches the supplied schema and labels or throws if one is not found
79
+ * @returns A provider factory that matches the supplied moniker and labels or throws if one is not found
46
80
  */
47
- locate(moniker: ProviderMoniker, labels?: Labels): CreatableProviderFactory | LabeledCreatableProviderFactory {
81
+ locate<TProvider extends Provider<ProviderMoniker>>(moniker: TProvider['moniker'], labels?: Labels):
82
+ CreatableProviderFactory<CreatableProviderInstance<TProvider>> | LabeledCreatableProviderFactory<CreatableProviderInstance<TProvider>> {
48
83
  return assertEx(
49
- this.tryLocate(moniker, labels),
84
+ this.tryLocate<TProvider>(moniker, labels),
50
85
 
51
- () => `No module factory for the supplied config schema [${moniker}]${labels ? ` & labels [${JSON.stringify(labels)}]` : ''} registered`,
86
+ () => `No module factory for the supplied config moniker [${moniker}]${labels ? ` & labels [${JSON.stringify(labels)}]` : ''} registered`,
52
87
  )
53
88
  }
54
89
 
@@ -61,7 +96,7 @@ export class ProviderFactoryLocator implements ProviderFactoryLocatorInstance {
61
96
  registry[moniker] = locator.registry[moniker]
62
97
  }
63
98
  }
64
- return new ProviderFactoryLocator(registry)
99
+ return new ProviderFactoryLocator(this.context, registry)
65
100
  }
66
101
 
67
102
  /**
@@ -86,17 +121,42 @@ export class ProviderFactoryLocator implements ProviderFactoryLocatorInstance {
86
121
  return this
87
122
  }
88
123
 
124
+ async tryGetInstance<TProvider extends Provider<ProviderMoniker>>(
125
+ moniker: TProvider['moniker'],
126
+ params?: Partial<CreatableProviderInstance<TProvider>['params']>,
127
+ labels?: Labels,
128
+ ) {
129
+ try {
130
+ return await this.getInstance<TProvider>(moniker, params, labels)
131
+ } catch {
132
+ return
133
+ }
134
+ }
135
+
89
136
  /**
90
- * Tries to locate a module factory that matches the supplied schema and labels
91
- * @param schema The config schema for the module
137
+ * Tries to locate a module factory that matches the supplied moniker and labels
138
+ * @param moniker The config moniker for the module
92
139
  * @param labels The labels for the module factory
93
- * @returns A module factory that matches the supplied schema and labels or undefined
140
+ * @returns A module factory that matches the supplied moniker and labels or undefined
94
141
  */
95
- tryLocate(moniker: ProviderMoniker, labels?: Labels): CreatableProviderFactory | LabeledCreatableProviderFactory | undefined {
96
- return labels
142
+ tryLocate<TProvider extends Provider<ProviderMoniker>>(moniker: TProvider['moniker'], labels?: Labels) {
143
+ const result = labels
97
144
  // Find the first factory that has labels and has all the labels provided
98
145
  ? (this._registry[moniker]?.filter(hasLabels).find(factory => hasAllLabels(factory?.labels, labels)) ?? this._registry[moniker]?.[0])
99
146
  // Otherwise, return the first factory
100
147
  : this._registry[moniker]?.[0]
148
+
149
+ if (result) {
150
+ result.defaultParams = {
151
+ ...result?.defaultParams,
152
+ context: {
153
+ ...this.context,
154
+ ...result?.defaultParams?.context,
155
+ },
156
+ }
157
+ }
158
+
159
+ return result as CreatableProviderFactory<CreatableProviderInstance<TProvider>>
160
+ | LabeledCreatableProviderFactory<CreatableProviderInstance<TProvider>> | undefined
101
161
  }
102
162
  }
@@ -1,7 +1,7 @@
1
1
  import type { Labels } from '@xylabs/sdk-js'
2
2
 
3
- import type { ProviderMoniker } from '../model/index.ts'
4
- import type { CreatableProviderFactory } from './CreatableProvider.ts'
3
+ import type { Provider, ProviderMoniker } from '../model/index.ts'
4
+ import type { CreatableProviderFactory, CreatableProviderInstance } from './CreatableProvider.ts'
5
5
  import type { CreatableProviderRegistry } from './CreatableProviderRegistry.ts'
6
6
  import type { LabeledCreatableProviderFactory } from './LabeledCreatableProviderFactory.ts'
7
7
 
@@ -12,15 +12,31 @@ export interface ProviderFactoryLocatorInstance {
12
12
  */
13
13
  registry: Readonly<CreatableProviderRegistry>
14
14
 
15
+ /** @deprecated use getInstance instead */
16
+ create<TProvider extends Provider<ProviderMoniker>,
17
+ TParams extends CreatableProviderInstance<TProvider>['params'] = CreatableProviderInstance<TProvider>['params']>(
18
+ moniker: TProvider['moniker'],
19
+ params?: TParams,
20
+ labels?: Labels,
21
+ ): Promise<CreatableProviderInstance<TProvider>>
22
+
15
23
  freeze(): void
16
24
 
25
+ getInstance<TProvider extends Provider<ProviderMoniker>,
26
+ TParams extends CreatableProviderInstance<TProvider>['params'] = CreatableProviderInstance<TProvider>['params']>(
27
+ moniker: TProvider['moniker'],
28
+ params?: Partial<TParams>,
29
+ labels?: Labels,
30
+ ): Promise<CreatableProviderInstance<TProvider>>
31
+
17
32
  /**
18
- * Locates a module factory that matches the supplied schema and labels
19
- * @param schema The config schema for the module
33
+ * Locates a module factory that matches the supplied moniker and labels
34
+ * @param moniker The config moniker for the module
20
35
  * @param labels The labels for the module factory
21
- * @returns A module factory that matches the supplied schema and labels or throws if one is not found
36
+ * @returns A module factory that matches the supplied moniker and labels or throws if one is not found
22
37
  */
23
- locate(schema: string, labels?: Labels): CreatableProviderFactory | LabeledCreatableProviderFactory
38
+ locate<TProvider extends Provider<ProviderMoniker>>(moniker: ProviderMoniker, labels?: Labels):
39
+ CreatableProviderFactory<CreatableProviderInstance<TProvider>> | LabeledCreatableProviderFactory<CreatableProviderInstance<TProvider>> | undefined
24
40
 
25
41
  merge(locator: ProviderFactoryLocatorInstance): ProviderFactoryLocatorInstance
26
42
 
@@ -37,11 +53,18 @@ export interface ProviderFactoryLocatorInstance {
37
53
  */
38
54
  registerMany(factories: CreatableProviderFactory[]): ProviderFactoryLocatorInstance
39
55
 
56
+ tryGetInstance<TProvider extends Provider<ProviderMoniker>,
57
+ TParams extends CreatableProviderInstance<TProvider>['params'] = CreatableProviderInstance<TProvider>['params']>(
58
+ moniker: TProvider['moniker'],
59
+ params?: Partial<TParams>,
60
+ labels?: Labels,
61
+ ): Promise<CreatableProviderInstance<TProvider> | undefined>
62
+
40
63
  /**
41
- * Tries to locate a module factory that matches the supplied schema and labels
42
- * @param schema The config schema for the module
64
+ * Tries to locate a module factory that matches the supplied moniker and labels
65
+ * @param moniker The config moniker for the module
43
66
  * @param labels The labels for the module factory
44
- * @returns A module factory that matches the supplied schema and labels or undefined
67
+ * @returns A module factory that matches the supplied moniker and labels or undefined
45
68
  */
46
- tryLocate(schema: string, labels?: Labels): CreatableProviderFactory | LabeledCreatableProviderFactory | undefined
69
+ tryLocate(moniker: ProviderMoniker, labels?: Labels): CreatableProviderFactory | LabeledCreatableProviderFactory | undefined
47
70
  }
@@ -9,11 +9,12 @@ import * as z from 'zod'
9
9
  import { MnemonicStringZod } from '../validation/index.ts'
10
10
 
11
11
  const DEFAULT_FIXED_FEE = toHex(XL1(1n) * AttoXL1ConvertFactor.xl1)
12
- const DEFAULT_MIN_BRIDGE_AMOUNT = toHex(XL1(10n) * AttoXL1ConvertFactor.xl1)
13
- const DEFAULT_MAX_BRIDGE_AMOUNT = toHex(XL1(100_000n) * AttoXL1ConvertFactor.xl1)
12
+ const DEFAULT_HARDHAT_BRIDGE_CONTRACT = toAddress('2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6')
14
13
  const DEFAULT_HARDHAT_CHAIN_ID: ChainId = toHex('7A69')
14
+ const DEFAULT_HARDHAT_REMOTE_CHAIN_WALLET_PRIVATE_KEY = toHex('0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80')
15
15
  const DEFAULT_HARDHAT_TOKEN_CONTRACT = toAddress('5FbDB2315678afecb367f032d93F642f64180aa3')
16
- const DEFAULT_HARDHAT_BRIDGE_CONTRACT = toAddress('2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6')
16
+ const DEFAULT_MAX_BRIDGE_AMOUNT = toHex(XL1(100_000n) * AttoXL1ConvertFactor.xl1)
17
+ const DEFAULT_MIN_BRIDGE_AMOUNT = toHex(XL1(10n) * AttoXL1ConvertFactor.xl1)
17
18
 
18
19
  export const BasisPointsZod = z.coerce.number().int().nonnegative().max(10_000)
19
20
  export type BasisPoints = z.infer<typeof BasisPointsZod>
@@ -70,12 +71,24 @@ export const BridgeConfigZod = z.object({
70
71
  title: 'bridge.mnemonic',
71
72
  type: 'string',
72
73
  }),
73
- port: z.coerce.number().default(8081).register(globalRegistry, {
74
+ port: z.coerce.number().int().positive().default(8081).register(globalRegistry, {
74
75
  default: 8081,
75
76
  description: 'Port for the Bridge',
76
77
  title: 'bridge.port',
77
78
  type: 'number',
78
79
  }),
80
+ redisHost: z.string().default('localhost').register(globalRegistry, {
81
+ default: 'localhost',
82
+ description: 'Host for the Bridge Redis instance',
83
+ title: 'bridge.redisHost',
84
+ type: 'string',
85
+ }),
86
+ redisPort: z.coerce.number().int().positive().default(6379).register(globalRegistry, {
87
+ default: 6379,
88
+ description: 'Port for the Bridge Redis instance',
89
+ title: 'bridge.redisPort',
90
+ type: 'number',
91
+ }),
79
92
  remoteBridgeContractAddress: AddressZod.default(DEFAULT_HARDHAT_BRIDGE_CONTRACT).register(globalRegistry, {
80
93
  default: DEFAULT_HARDHAT_BRIDGE_CONTRACT,
81
94
  description: 'Hex representation of remote token address used for bridging',
@@ -94,6 +107,11 @@ export const BridgeConfigZod = z.object({
94
107
  title: 'bridge.remoteTokenAddress',
95
108
  type: 'string',
96
109
  }),
110
+ remoteChainWalletPrivateKey: HexZod.default(DEFAULT_HARDHAT_REMOTE_CHAIN_WALLET_PRIVATE_KEY).register(globalRegistry, {
111
+ description: 'Private key for the wallet to use for the remote chain wallet',
112
+ title: 'bridge.remoteChainWalletPrivateKey',
113
+ type: 'string',
114
+ }),
97
115
  xl1ChainId: HexZod.optional().register(globalRegistry, {
98
116
  description: 'XL1 chain id used for bridging',
99
117
  title: 'bridge.xl1ChainId',
@@ -1,9 +1,9 @@
1
- import { AddressZod } from '@xylabs/sdk-js'
1
+ import { AddressZod, HexZod } from '@xylabs/sdk-js'
2
2
  import { globalRegistry } from 'zod'
3
3
  import * as z from 'zod'
4
4
 
5
5
  export const ChainConfigZod = z.object({
6
- id: z.string().optional()
6
+ id: HexZod.optional()
7
7
  .register(globalRegistry, {
8
8
  description:
9
9
  'The unique identifier for the chain. Should be the staking contract address for contract-backed chains.',
@@ -2,12 +2,14 @@ import { globalRegistry } from 'zod'
2
2
  import * as z from 'zod'
3
3
 
4
4
  export const ServicesConfigZod = z.object({
5
- accountBalanceViewerEndpoint: z.string().optional().register(globalRegistry, {
5
+ accountBalanceViewerEndpoint: z.string().default('http://localhost:8080/rpc').register(globalRegistry, {
6
+ default: 'http://localhost:8080/rpc',
6
7
  description: 'Endpoint of the API to use for instantiating an external AccountBalanceViewer',
7
8
  title: 'services.accountBalanceViewerEndpoint',
8
9
  type: 'string',
9
10
  }),
10
- apiEndpoint: z.string().optional().register(globalRegistry, {
11
+ apiEndpoint: z.string().default('http://localhost:8080/rpc').register(globalRegistry, {
12
+ default: 'http://localhost:8080/rpc',
11
13
  description: 'Endpoint of the API to use for instantiating an external Viewers',
12
14
  title: 'services.apiEndpoint',
13
15
  type: 'string',
@@ -0,0 +1,14 @@
1
+ import type { Address } from '@xylabs/sdk-js'
2
+ import { isDefined } from '@xylabs/sdk-js'
3
+ import { PayloadBuilder } from '@xyo-network/payload-builder'
4
+ import {
5
+ type ChainStakeIntent, ChainStakeIntentSchema, type Intent,
6
+ } from '@xyo-network/xl1-protocol'
7
+
8
+ export const createDeclarationIntent = (address: Address, intent: Intent, nbf: number, exp?: number): ChainStakeIntent => {
9
+ const expiration = isDefined(exp) ? exp : nbf + 10_000
10
+ const redeclarationIntent = new PayloadBuilder<ChainStakeIntent>({ schema: ChainStakeIntentSchema }).fields({
11
+ from: address, intent, nbf, exp: expiration,
12
+ }).build()
13
+ return redeclarationIntent
14
+ }
@@ -0,0 +1,15 @@
1
+ import type { Address, JsonObject } from '@xylabs/sdk-js'
2
+ import { toHex } from '@xylabs/sdk-js'
3
+ import { PayloadBuilder } from '@xyo-network/payload-builder'
4
+ import type { Transfer } from '@xyo-network/xl1-protocol'
5
+ import { TransferSchema } from '@xyo-network/xl1-protocol'
6
+
7
+ export function createTransferPayload(from: Address, transfers: Record<Address, bigint>, context?: JsonObject): Transfer {
8
+ return new PayloadBuilder<Transfer>({ schema: TransferSchema })
9
+ .fields({
10
+ epoch: Date.now(),
11
+ from,
12
+ transfers: Object.fromEntries(Object.entries(transfers).map(([k, v]) => [k, toHex(v)])),
13
+ context,
14
+ }).build()
15
+ }
@@ -1,8 +1,8 @@
1
1
  import { LRUCache } from 'lru-cache'
2
2
 
3
- import type { SynchronousMap } from '../../map/index.ts'
3
+ import type { SyncMap } from '../../map/index.ts'
4
4
 
5
- export class LruCacheMap<K extends {}, V extends {} | string | number | bigint, FC = () => void> implements SynchronousMap<K, V> {
5
+ export class LruCacheMap<K extends {}, V extends {} | string | number | bigint, FC = () => void> implements SyncMap<K, V> {
6
6
  private lruCache: LRUCache<K, V, FC>
7
7
 
8
8
  constructor(options?: LRUCache.Options<K, V, FC>) {
@@ -1,8 +1,8 @@
1
1
  import { isDefined } from '@xylabs/sdk-js'
2
2
 
3
- import type { SynchronousMap } from '../../map/index.ts'
3
+ import type { SyncMap } from '../../map/index.ts'
4
4
 
5
- export class MemoryMap<K extends {}, V = {}> implements SynchronousMap<K, V> {
5
+ export class MemoryMap<K extends {}, V = {}> implements SyncMap<K, V> {
6
6
  private map: Map<K, V>
7
7
 
8
8
  constructor() {
package/src/index.ts CHANGED
@@ -3,6 +3,8 @@ export * from './ChainServiceCollectionV2.ts'
3
3
  export * from './config/index.ts'
4
4
  export * from './constants.ts'
5
5
  export * from './CreatableProvider/index.ts'
6
+ export * from './createDeclarationPayload.ts'
7
+ export * from './createTransferPayload.ts'
6
8
  export * from './driver/index.ts'
7
9
  export * from './eip-712/index.ts'
8
10
  export * from './instances/index.ts'
@@ -16,6 +18,7 @@ export * from './runners/index.ts'
16
18
  export * from './services/index.ts'
17
19
  export * from './SignedBigInt.ts'
18
20
  export * from './simple/index.ts'
21
+ export * from './status/index.ts'
19
22
  export * from './summary/index.ts'
20
23
  export * from './time/index.ts'
21
24
  export * from './transaction/index.ts'
@@ -5,11 +5,13 @@ import type {
5
5
  SyncIterableMap, SyncIterableMapRead, SyncIterableMapWrite, SyncMap, SyncMapRead, SyncMapWrite,
6
6
  } from './SyncMap.ts'
7
7
 
8
- export type MapTypeWrite<TId, TData> = SyncMapWrite<TId, TData> | AsyncMapWrite<TId, TData>
8
+ export type MapType<TId, TData> = SyncMap<TId, TData> | AsyncMap<TId, TData>
9
9
 
10
10
  export type MapTypeRead<TId, TData> = SyncMapRead<TId, TData> | AsyncMapRead<TId, TData>
11
11
 
12
- export type MapType<TId, TData> = SyncMap<TId, TData> | AsyncMap<TId, TData>
12
+ export type MapTypeWrite<TId, TData> = SyncMapWrite<TId, TData> | AsyncMapWrite<TId, TData>
13
+
14
+ export type AsynchronousMapType<TId, TData> = AsyncMapRead<TId, TData> & AsyncMapWrite<TId, TData>
13
15
 
14
16
  export type IterableMapRead<TId, TData> = SyncIterableMapRead<TId, TData> | AsyncIterableMapRead<TId, TData>
15
17
 
@@ -4,7 +4,6 @@ import { isDefined, isUndefined } from '@xylabs/sdk-js'
4
4
  import { LruCacheMap, MemoryMap } from '../../driver/index.ts'
5
5
  import type { MapType } from '../../map/index.ts'
6
6
  import { timeBudget } from '../../primitives/index.ts'
7
- import type { ChainIdentity } from '../ChainIdentity.ts'
8
7
  import type {
9
8
  ChainStakeContext, ChainStakeContextRead, ChainStakeContextWrite,
10
9
  } from './ChainStakeContext.ts'
@@ -16,6 +15,7 @@ import type {
16
15
  export interface BaseContext<TCacheValue = string | object | number | bigint> {
17
16
  caches?: Record<string, MapType<string, TCacheValue>>
18
17
  logger?: Logger
18
+ singletons: Record<string, unknown>
19
19
  }
20
20
 
21
21
  export function contextCache<TCacheValue>(
@@ -58,14 +58,14 @@ export async function withContextCacheResponse<T extends {} | string | number |
58
58
  return result
59
59
  }
60
60
 
61
- export interface ChainContextWrite extends BaseContext, ChainIdentity, ChainStateContextWrite, ChainStoreContextWrite {}
61
+ export interface ChainContextWrite extends BaseContext, ChainStateContextWrite, ChainStoreContextWrite {}
62
62
 
63
63
  export interface StakedChainContextWrite extends BaseContext, ChainContextWrite, ChainStakeContextWrite {}
64
64
 
65
- export interface ChainContextRead extends BaseContext, ChainIdentity, ChainStateContextRead, ChainStoreContextRead {}
65
+ export interface ChainContextRead extends BaseContext, ChainStateContextRead, ChainStoreContextRead {}
66
66
 
67
67
  export interface StakedChainContextRead extends BaseContext, ChainContextRead, ChainStakeContextRead {}
68
68
 
69
- export type ChainContext = ChainIdentity & ChainContextRead & ChainContextWrite & ChainStoreContext
69
+ export type ChainContext = ChainContextRead & ChainContextWrite & ChainStoreContext
70
70
 
71
71
  export type StakedChainContext = ChainContext & ChainStakeContext & ChainStakeContextRead & ChainStakeContextWrite
@@ -0,0 +1,33 @@
1
+ import { HashZod } from '@xylabs/hex'
2
+ import { zodIsFactory } from '@xylabs/zod'
3
+ import { XL1BlockRangeZod } from '@xyo-network/xl1-protocol'
4
+ import z from 'zod'
5
+
6
+ export const ChainQualificationZod = z.object({ head: HashZod, range: XL1BlockRangeZod })
7
+ export type ChainQualification = z.infer<typeof ChainQualificationZod>
8
+ export const isChainQualification = zodIsFactory(ChainQualificationZod)
9
+
10
+ export const ChainQualifiedRangeConfigZod = z.object({ range: XL1BlockRangeZod })
11
+ export type ChainQualifiedRangeConfig = z.infer<typeof ChainQualifiedRangeConfigZod>
12
+ export const isChainQualifiedRangeConfig = zodIsFactory(ChainQualifiedRangeConfigZod)
13
+
14
+ export const ChainQualifiedHeadConfigZod = z.object({ head: HashZod })
15
+ export type ChainQualifiedHeadConfig = z.infer<typeof ChainQualifiedHeadConfigZod>
16
+ export const isChainQualifiedHeadConfig = zodIsFactory(ChainQualifiedHeadConfigZod)
17
+
18
+ export const ChainQualifiedConfigZod = z.union([ChainQualifiedRangeConfigZod, ChainQualifiedHeadConfigZod, z.object({})])
19
+ export type ChainQualifiedConfig = z.infer<typeof ChainQualifiedConfigZod>
20
+ export const isChainQualifiedConfig = zodIsFactory(ChainQualifiedConfigZod)
21
+
22
+ export const ExtendChainQualifiedConfigZod = (<T>(zodType: z.ZodType<T>) => {
23
+ return z.union([
24
+ ChainQualifiedRangeConfigZod.extend(zodType),
25
+ ChainQualifiedHeadConfigZod.extend(zodType),
26
+ zodType,
27
+ ])
28
+ }) as <T>(zodType: z.ZodType<T>) => z.ZodType<T & ChainQualifiedConfig>
29
+
30
+ export type ChainQualified<T> = [T, ChainQualification]
31
+ export const ChainQualifiedZod = <T>(zodType: z.ZodType<T>) => {
32
+ return z.tuple([zodType, ChainQualificationZod])
33
+ }
@@ -1,10 +1,10 @@
1
1
  import { PayloadBuilder } from '@xyo-network/payload-builder'
2
- import type { PayloadBundle, WithHashMeta } from '@xyo-network/payload-model'
2
+ import type { PayloadBundle } from '@xyo-network/payload-model'
3
3
  import type { SignedHydratedTransactionWithHashMeta } from '@xyo-network/xl1-protocol'
4
4
  import { asSignedTransactionBoundWitnessWithHashMeta } from '@xyo-network/xl1-protocol'
5
5
 
6
6
  export const bundledPayloadToHydratedTransaction = async (
7
- payload: WithHashMeta<PayloadBundle>,
7
+ payload: PayloadBundle,
8
8
  ): Promise<SignedHydratedTransactionWithHashMeta | undefined> => {
9
9
  const withHashMeta = await PayloadBuilder.addHashMeta(payload.payloads)
10
10
  const tx = asSignedTransactionBoundWitnessWithHashMeta(withHashMeta.find(p => p._hash === payload.root))
@@ -1,10 +1,10 @@
1
1
  export * from './ChainContext/index.ts'
2
2
  export * from './ChainFork/index.ts'
3
3
  export * from './ChainIdentity.ts'
4
+ export * from './ChainQualification.ts'
4
5
  export * from './ChainStore.ts'
5
6
  export * from './PayloadBundle/index.ts'
6
7
  export * from './PayloadMap.ts'
7
8
  export * from './Position.ts'
8
9
  export * from './Provider.ts'
9
- export * from './Qualified.ts'
10
10
  export * from './RecordKeyType.ts'
@@ -0,0 +1 @@
1
+ export * from './range/index.ts'
@@ -0,0 +1,22 @@
1
+ import type {
2
+ StepIdentity,
3
+ XL1BlockRange,
4
+ } from '@xyo-network/xl1-protocol'
5
+ import { asXL1BlockNumber, StepSizes } from '@xyo-network/xl1-protocol'
6
+
7
+ export function blockRangeSteps(range: XL1BlockRange, steps: number[]): StepIdentity[] {
8
+ const result: StepIdentity[] = []
9
+ for (const step of steps) {
10
+ const stepSize = StepSizes[step]
11
+ // we add stepSize twice to get to the start of the next full step
12
+ const startOfFirstStepCandidate = range[0] - (range[0] % stepSize) + stepSize
13
+ const startOfFirstStep = asXL1BlockNumber(
14
+ startOfFirstStepCandidate,
15
+ { name: 'blockRangeSteps' },
16
+ )
17
+ for (let block = startOfFirstStep; block <= range[1]; block = asXL1BlockNumber(block + stepSize, { name: 'blockRangeSteps' })) {
18
+ result.push({ step, block })
19
+ }
20
+ }
21
+ return result
22
+ }
@@ -0,0 +1 @@
1
+ export * from './blockRangeSteps.ts'
@@ -0,0 +1,23 @@
1
+ import type { Hash } from '@xylabs/sdk-js'
2
+ import type { SignedHydratedBlockWithHashMeta } from '@xyo-network/xl1-protocol'
3
+
4
+ import type { BlockViewer } from '../../viewers/index.ts'
5
+
6
+ export async function getWindowedChain(blockViewer: BlockViewer, maxWindowSize: number, previousChain: SignedHydratedBlockWithHashMeta[] = []) {
7
+ const newBlocks: SignedHydratedBlockWithHashMeta[] = []
8
+ let currentBlock: SignedHydratedBlockWithHashMeta | null = await blockViewer.currentBlock()
9
+ console.log('[getWindowedChain] Current Block:', currentBlock?.[0]._hash)
10
+ const head = currentBlock
11
+ while (currentBlock !== null && currentBlock[0].block >= head[0].block) {
12
+ newBlocks.unshift(currentBlock)
13
+ const previousBlockHash: Hash | null = currentBlock[0].previous
14
+ currentBlock = (previousBlockHash === null ? null : await blockViewer.blockByHash(previousBlockHash))
15
+ }
16
+ const newChain = [...previousChain, ...newBlocks].slice(-maxWindowSize)
17
+ while (newChain.length > 0 && newChain.length < maxWindowSize && newChain[0][0].previous !== null) {
18
+ const block = await blockViewer.blockByHash(newChain[0][0].previous!)
19
+ if (block === null) break
20
+ newChain.unshift(block)
21
+ }
22
+ return newChain
23
+ }
@@ -0,0 +1,3 @@
1
+ export * from './getWindowedChain.ts'
2
+ export * from './step/index.ts'
3
+ export * from './time/index.ts'
@@ -0,0 +1,28 @@
1
+ import type { Address } from '@xylabs/sdk-js'
2
+ import {
3
+ assertEx, exists, toAddress,
4
+ } from '@xylabs/sdk-js'
5
+ import type { StepIdentity } from '@xyo-network/xl1-protocol'
6
+ import {
7
+ asTransfer, isTransfer, XYO_STEP_REWARD_ADDRESS,
8
+ } from '@xyo-network/xl1-protocol'
9
+
10
+ import type { ChainContextRead } from '../../../model/index.ts'
11
+ import { mergeTransfers } from '../../payload/index.ts'
12
+ import { stepTransferIndex } from '../../step/index.ts'
13
+ import { stepRewardBlock } from './stepRewardBlock.ts'
14
+
15
+ export async function chainStepRewardAddress(context: ChainContextRead, { block, step }: StepIdentity): Promise<Address> {
16
+ const hydratedBlock = await stepRewardBlock(context, { block, step })
17
+ const [transferIndex, transferCount] = stepTransferIndex(block, step)
18
+ const [blockBw, payloads] = hydratedBlock
19
+
20
+ const transfersFromPool = payloads.filter(isTransfer).map(p => asTransfer(p)).filter(exists).filter(t => t.from === XYO_STEP_REWARD_ADDRESS)
21
+ const fromEntries = Object.entries(mergeTransfers(transfersFromPool)[XYO_STEP_REWARD_ADDRESS])
22
+ const sortedTransferAmounts = (fromEntries).toSorted(([,a], [,b]) => a > b ? -1 : a < b ? 1 : 0)
23
+ assertEx(
24
+ sortedTransferAmounts.length === transferCount,
25
+ () => `Step Transfers mismatch ${block} (${blockBw._hash}) [${sortedTransferAmounts.length} - ${transferCount}]`,
26
+ )
27
+ return toAddress(sortedTransferAmounts[transferIndex][0])
28
+ }
@@ -0,0 +1,4 @@
1
+ export * from './chainStepRewardAddress.ts'
2
+ export * from './stepRewardBlock.ts'
3
+ export * from './stepRewardTotal.ts'
4
+ export * from './stepsRewardTotal.ts'
@@ -0,0 +1,11 @@
1
+ import { assertEx } from '@xylabs/sdk-js'
2
+ import type { HydratedBlockWithHashMeta, StepIdentity } from '@xyo-network/xl1-protocol'
3
+ import { StepSizes } from '@xyo-network/xl1-protocol'
4
+
5
+ import type { ChainContextRead } from '../../../model/index.ts'
6
+ import { hydratedBlockByNumber } from '../../state/index.ts'
7
+
8
+ export async function stepRewardBlock(context: ChainContextRead, { block, step }: StepIdentity): Promise<HydratedBlockWithHashMeta> {
9
+ assertEx((block % StepSizes[step]) === 0, () => `Block must be the first block of the step [${StepSizes[step]}], got ${block}`)
10
+ return assertEx(await hydratedBlockByNumber(context, block), () => `Could not find block for block number ${block}`)
11
+ }