@xyo-network/xl1-protocol-sdk 1.26.11 → 1.26.13

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 (316) hide show
  1. package/package.json +29 -16
  2. package/src/ChainContextHelpers.ts +0 -50
  3. package/src/CreatableProvider/AbstractCreatableProvider.ts +0 -97
  4. package/src/CreatableProvider/CreatableProvider.ts +0 -102
  5. package/src/CreatableProvider/CreatableProviderRegistry.ts +0 -94
  6. package/src/CreatableProvider/GetInstanceOptions.ts +0 -11
  7. package/src/CreatableProvider/LabeledCreatableProviderFactory.ts +0 -24
  8. package/src/CreatableProvider/ProviderFactory.ts +0 -138
  9. package/src/CreatableProvider/ProviderFactoryLocator.ts +0 -170
  10. package/src/CreatableProvider/ProviderFactoryLocatorInstance.ts +0 -70
  11. package/src/CreatableProvider/index.ts +0 -8
  12. package/src/SignedBigInt.ts +0 -59
  13. package/src/_internal/context/getTestProviderContext.ts +0 -13
  14. package/src/_internal/context/index.ts +0 -1
  15. package/src/_internal/index.ts +0 -2
  16. package/src/actor/ActorV3.ts +0 -177
  17. package/src/actor/index.ts +0 -1
  18. package/src/amount/ShiftedBigInt.ts +0 -73
  19. package/src/amount/XL1Amount.ts +0 -103
  20. package/src/amount/index.ts +0 -4
  21. package/src/amount/splitOnDecimal.ts +0 -6
  22. package/src/amount/splitOnDecimalToString.ts +0 -40
  23. package/src/block/hydrate/allHashesPresent.ts +0 -8
  24. package/src/block/hydrate/blockPayloadsFromHydratedBlock.ts +0 -12
  25. package/src/block/hydrate/flattenHydratedBlock.ts +0 -28
  26. package/src/block/hydrate/flattenHydratedBlocks.ts +0 -7
  27. package/src/block/hydrate/hydrateBlock.ts +0 -43
  28. package/src/block/hydrate/index.ts +0 -7
  29. package/src/block/hydrate/transactionsFromHydratedBlock.ts +0 -7
  30. package/src/block/hydrate/tryHydrateBlock.ts +0 -26
  31. package/src/block/index.ts +0 -2
  32. package/src/block/primitives/blockFromBlockNumber.ts +0 -69
  33. package/src/block/primitives/frames/calculateFramesFromRange.ts +0 -30
  34. package/src/block/primitives/frames/deepCalculateFramesFromRange.ts +0 -28
  35. package/src/block/primitives/frames/index.ts +0 -2
  36. package/src/block/primitives/hashFromBlockNumber.ts +0 -9
  37. package/src/block/primitives/index.ts +0 -7
  38. package/src/block/primitives/model.ts +0 -18
  39. package/src/block/primitives/payloads/ChainWindow.ts +0 -7
  40. package/src/block/primitives/payloads/index.ts +0 -1
  41. package/src/block/primitives/toStepIdentityString.ts +0 -6
  42. package/src/block/primitives/validateTransactionOpcodes.ts +0 -45
  43. package/src/config/Actor.ts +0 -32
  44. package/src/config/Actors.ts +0 -9
  45. package/src/config/Base.ts +0 -27
  46. package/src/config/Chain.ts +0 -23
  47. package/src/config/Config.ts +0 -24
  48. package/src/config/DataLake/DataLake.ts +0 -12
  49. package/src/config/DataLake/DataLakeRemoteConfig.ts +0 -11
  50. package/src/config/DataLake/RestDataLakeConfig.ts +0 -18
  51. package/src/config/DataLake/RouterDataLakeConfig.ts +0 -22
  52. package/src/config/DataLake/index.ts +0 -4
  53. package/src/config/DeepPartial.ts +0 -4
  54. package/src/config/Evm.ts +0 -38
  55. package/src/config/HostActor.ts +0 -32
  56. package/src/config/Log.ts +0 -25
  57. package/src/config/Provider.ts +0 -20
  58. package/src/config/Providers.ts +0 -9
  59. package/src/config/Remote.ts +0 -59
  60. package/src/config/Telemetry.ts +0 -49
  61. package/src/config/UsageMeta.ts +0 -46
  62. package/src/config/Validation.ts +0 -29
  63. package/src/config/index.ts +0 -12
  64. package/src/config/storage/Storage.ts +0 -16
  65. package/src/config/storage/driver/Mongo.ts +0 -53
  66. package/src/config/storage/driver/index.ts +0 -1
  67. package/src/config/storage/index.ts +0 -2
  68. package/src/constants.ts +0 -4
  69. package/src/context/Actor.ts +0 -20
  70. package/src/context/HostActor.ts +0 -20
  71. package/src/context/getEmptyProviderContext.ts +0 -19
  72. package/src/context/index.ts +0 -3
  73. package/src/createDeclarationPayload.ts +0 -15
  74. package/src/createTransferPayload.ts +0 -16
  75. package/src/driver/cache/LruCacheMap.ts +0 -48
  76. package/src/driver/cache/index.ts +0 -1
  77. package/src/driver/index.ts +0 -2
  78. package/src/driver/memory/MemoryMap.ts +0 -48
  79. package/src/driver/memory/index.ts +0 -1
  80. package/src/eip-712/Payloads/EIP712Data.ts +0 -35
  81. package/src/eip-712/Payloads/EIP712Signature.ts +0 -32
  82. package/src/eip-712/Payloads/index.ts +0 -2
  83. package/src/eip-712/Types.ts +0 -41
  84. package/src/eip-712/index.ts +0 -4
  85. package/src/eip-712/sign.ts +0 -19
  86. package/src/eip-712/spec/fixtures.ts +0 -27
  87. package/src/eip-712/verify.ts +0 -20
  88. package/src/getFileConfig.ts +0 -36
  89. package/src/index.ts +0 -27
  90. package/src/instances/Address.ts +0 -16
  91. package/src/instances/BoundWitness.ts +0 -13
  92. package/src/instances/Data.ts +0 -4
  93. package/src/instances/Fees.ts +0 -9
  94. package/src/instances/HydratedBoundWitness.ts +0 -16
  95. package/src/instances/Object.ts +0 -6
  96. package/src/instances/Payload.ts +0 -7
  97. package/src/instances/Signature.ts +0 -12
  98. package/src/instances/block/BlockFields.ts +0 -18
  99. package/src/instances/block/HydratedBlock.ts +0 -10
  100. package/src/instances/block/index.ts +0 -1
  101. package/src/instances/index.ts +0 -10
  102. package/src/instances/modifiers/BlockWindowInstance.ts +0 -8
  103. package/src/instances/modifiers/BlockWindowState.ts +0 -6
  104. package/src/instances/modifiers/Signed.ts +0 -9
  105. package/src/instances/modifiers/Validatable.ts +0 -6
  106. package/src/instances/modifiers/index.ts +0 -4
  107. package/src/instances/transaction/HydratedTransaction.ts +0 -9
  108. package/src/instances/transaction/TransactionFields.ts +0 -22
  109. package/src/instances/transaction/index.ts +0 -1
  110. package/src/isInternetAvailable.ts +0 -11
  111. package/src/model/ChainFork/ChainForkStatic.ts +0 -9
  112. package/src/model/ChainFork/index.ts +0 -1
  113. package/src/model/ChainIdentity.ts +0 -6
  114. package/src/model/ChainStore.ts +0 -16
  115. package/src/model/CreatableProviderContext.ts +0 -6
  116. package/src/model/CreatableProviderContext.zod.ts +0 -55
  117. package/src/model/PayloadBundle/bundledPayloadToHydratedBlock.ts +0 -15
  118. package/src/model/PayloadBundle/bundledPayloadToHydratedTransaction.ts +0 -15
  119. package/src/model/PayloadBundle/hydratedBlockToPayloadBundle.ts +0 -19
  120. package/src/model/PayloadBundle/hydratedTransactionToPayloadBundle.ts +0 -19
  121. package/src/model/PayloadBundle/index.ts +0 -4
  122. package/src/model/index.ts +0 -6
  123. package/src/multipliers.ts +0 -18
  124. package/src/payloads/AddressPairPayload.ts +0 -27
  125. package/src/payloads/index.ts +0 -4
  126. package/src/payloads/netBalancesForPayloads.ts +0 -24
  127. package/src/payloads/netSchemasForPayloads.ts +0 -24
  128. package/src/payloads/netTransfersForPayloads.ts +0 -27
  129. package/src/primitives/block/index.ts +0 -2
  130. package/src/primitives/block/range/blockRangeSteps.ts +0 -23
  131. package/src/primitives/block/range/index.ts +0 -1
  132. package/src/primitives/block/rate/blockRate.ts +0 -77
  133. package/src/primitives/block/rate/index.ts +0 -4
  134. package/src/primitives/block/rate/stepRate.ts +0 -37
  135. package/src/primitives/block/rate/timeHelpers.ts +0 -61
  136. package/src/primitives/block/rate/timeRate.ts +0 -121
  137. package/src/primitives/chain/getWindowedChain.ts +0 -50
  138. package/src/primitives/chain/index.ts +0 -3
  139. package/src/primitives/chain/step/chainStepRewardAddress.ts +0 -30
  140. package/src/primitives/chain/step/index.ts +0 -4
  141. package/src/primitives/chain/step/stepRewardBlock.ts +0 -13
  142. package/src/primitives/chain/step/stepRewardTotal.ts +0 -46
  143. package/src/primitives/chain/step/stepsRewardTotal.ts +0 -37
  144. package/src/primitives/chain/time/externalBlockNumberFromXL1BlockNumber.ts +0 -32
  145. package/src/primitives/chain/time/externalBlockRangeFromStep.ts +0 -21
  146. package/src/primitives/chain/time/externalBlockRangeFromXL1BlockRange.ts +0 -17
  147. package/src/primitives/chain/time/index.ts +0 -3
  148. package/src/primitives/datalake/addDataLakePayloads.ts +0 -18
  149. package/src/primitives/datalake/addDataLakePayloadsToPayloads.ts +0 -24
  150. package/src/primitives/datalake/index.ts +0 -2
  151. package/src/primitives/index.ts +0 -13
  152. package/src/primitives/mapToMapType.ts +0 -35
  153. package/src/primitives/payload/index.ts +0 -1
  154. package/src/primitives/payload/mergeTransfers.ts +0 -16
  155. package/src/primitives/readPayloadMapFromStore.ts +0 -58
  156. package/src/primitives/rewardFromBlockNumber.ts +0 -19
  157. package/src/primitives/rewards/index.ts +0 -1
  158. package/src/primitives/rewards/networkStakeStepRewardPositionWeight.ts +0 -26
  159. package/src/primitives/stake/activeStakeAtTimeByAddress.ts +0 -27
  160. package/src/primitives/stake/activeStakeAtTimeByPosition.ts +0 -25
  161. package/src/primitives/stake/allStakersForRange.ts +0 -32
  162. package/src/primitives/stake/allStakersForStep.ts +0 -24
  163. package/src/primitives/stake/index.ts +0 -6
  164. package/src/primitives/stake/mergedAddRemoveStakeEventsByPosition.ts +0 -15
  165. package/src/primitives/stake/mergedAddRemoveStakeEventsByStaker.ts +0 -17
  166. package/src/primitives/stake/weightedStakeForRangeByPosition.ts +0 -69
  167. package/src/primitives/state/findMostRecentBlock.ts +0 -44
  168. package/src/primitives/state/hydratedBlockByNumber.ts +0 -25
  169. package/src/primitives/state/index.ts +0 -2
  170. package/src/primitives/step/completedStepRewardAddress.ts +0 -10
  171. package/src/primitives/step/derivedReceiveAddress.ts +0 -9
  172. package/src/primitives/step/index.ts +0 -4
  173. package/src/primitives/step/stepBlockRange.ts +0 -9
  174. package/src/primitives/step/stepTransferIndex.ts +0 -19
  175. package/src/primitives/transaction/elevatedPayloads.ts +0 -24
  176. package/src/primitives/transaction/index.ts +0 -1
  177. package/src/primitives/uncle/findBestUncle.ts +0 -9
  178. package/src/primitives/uncle/findUncles.ts +0 -75
  179. package/src/primitives/uncle/index.ts +0 -3
  180. package/src/primitives/uncle/scoreUncle.ts +0 -7
  181. package/src/services/AccountTransfersService.ts +0 -13
  182. package/src/services/BlockProducerService.ts +0 -11
  183. package/src/services/Chain/BaseChainService.ts +0 -4
  184. package/src/services/Chain/ChainHeadService.ts +0 -8
  185. package/src/services/Chain/ChainService.ts +0 -6
  186. package/src/services/Chain/index.ts +0 -3
  187. package/src/services/Election.ts +0 -14
  188. package/src/services/NetworkStakeService.ts +0 -4
  189. package/src/services/Params.ts +0 -13
  190. package/src/services/PendingTransactionsService.ts +0 -7
  191. package/src/services/SchemasService.ts +0 -11
  192. package/src/services/StakeIntentService/ChainIndexingServiceStateSchema.ts +0 -50
  193. package/src/services/StakeIntentService/StakeIntentService.ts +0 -35
  194. package/src/services/StakeIntentService/index.ts +0 -2
  195. package/src/services/index.ts +0 -8
  196. package/src/simple/StakeEventsViewer/SimpleStakeEventsViewer.ts +0 -93
  197. package/src/simple/StakeEventsViewer/index.ts +0 -1
  198. package/src/simple/StakeTotalsViewer/SimpleStakeTotalsViewer.ts +0 -116
  199. package/src/simple/StakeTotalsViewer/index.ts +0 -1
  200. package/src/simple/StakeViewer/SimpleStakeViewer.ts +0 -164
  201. package/src/simple/StakeViewer/index.ts +0 -1
  202. package/src/simple/TransactionViewer/SimpleTransactionViewer.ts +0 -100
  203. package/src/simple/TransactionViewer/index.ts +0 -1
  204. package/src/simple/accountBalance/SimpleAccountBalanceViewer.ts +0 -271
  205. package/src/simple/accountBalance/index.ts +0 -1
  206. package/src/simple/block/SimpleBlockViewer.ts +0 -231
  207. package/src/simple/block/index.ts +0 -1
  208. package/src/simple/blockInvalidation/SimpleBlockInvalidationViewer.ts +0 -197
  209. package/src/simple/blockInvalidation/index.ts +0 -1
  210. package/src/simple/blockReward/SimpleBlockRewardViewer.ts +0 -27
  211. package/src/simple/blockReward/index.ts +0 -1
  212. package/src/simple/blockValidation/SimpleBlockValidationViewer.ts +0 -194
  213. package/src/simple/blockValidation/index.ts +0 -1
  214. package/src/simple/chainContractViewer/SimpleChainContractViewer.ts +0 -92
  215. package/src/simple/chainContractViewer/index.ts +0 -1
  216. package/src/simple/client/SimpleXyoClient.ts +0 -14
  217. package/src/simple/client/index.ts +0 -1
  218. package/src/simple/datalake/AbstractRestDataLake.ts +0 -70
  219. package/src/simple/datalake/AbstractSimpleDataLake.ts +0 -62
  220. package/src/simple/datalake/RestDataLakeRunner.ts +0 -54
  221. package/src/simple/datalake/RestDataLakeViewer.ts +0 -22
  222. package/src/simple/datalake/SimpleDataLakeRunner.ts +0 -44
  223. package/src/simple/datalake/SimpleDataLakeViewer.ts +0 -24
  224. package/src/simple/datalake/index.ts +0 -4
  225. package/src/simple/finalization/SimpleFinalizationRunner.ts +0 -45
  226. package/src/simple/finalization/SimpleFinalizationViewer.ts +0 -123
  227. package/src/simple/finalization/index.ts +0 -2
  228. package/src/simple/gateway/SimpleXyoGateway.ts +0 -30
  229. package/src/simple/gateway/SimpleXyoGatewayRunner.ts +0 -137
  230. package/src/simple/gateway/index.ts +0 -2
  231. package/src/simple/index.ts +0 -22
  232. package/src/simple/mempool/SimpleMempoolRunner.ts +0 -390
  233. package/src/simple/mempool/SimpleMempoolViewer.ts +0 -215
  234. package/src/simple/mempool/index.ts +0 -2
  235. package/src/simple/network/SimpleXyoNetwork.ts +0 -48
  236. package/src/simple/network/index.ts +0 -1
  237. package/src/simple/network/lib/FailedNetworkStatusPayloads.ts +0 -16
  238. package/src/simple/network/lib/StatusNetworks.ts +0 -32
  239. package/src/simple/network/lib/index.ts +0 -2
  240. package/src/simple/permissions/SimpleXyoPermissions.ts +0 -82
  241. package/src/simple/permissions/index.ts +0 -2
  242. package/src/simple/permissions/store/MemoryPermissions.ts +0 -32
  243. package/src/simple/permissions/store/PermissionsStore.ts +0 -17
  244. package/src/simple/permissions/store/index.ts +0 -2
  245. package/src/simple/runner/SimpleXyoRunner.ts +0 -41
  246. package/src/simple/runner/index.ts +0 -1
  247. package/src/simple/signer/SimpleXyoSigner.ts +0 -78
  248. package/src/simple/signer/index.ts +0 -1
  249. package/src/simple/timeSync2/SimpleTimeSyncViewer.ts +0 -132
  250. package/src/simple/timeSync2/index.ts +0 -1
  251. package/src/simple/transactionInvalidation/SimpleTransactionInvalidationViewer.ts +0 -197
  252. package/src/simple/transactionInvalidation/index.ts +0 -1
  253. package/src/simple/transactionValidation/SimpleTransactionValidationViewer.ts +0 -173
  254. package/src/simple/transactionValidation/index.ts +0 -1
  255. package/src/simple/windowedBlock/SimpleWindowedBlockViewer.ts +0 -207
  256. package/src/simple/windowedBlock/index.ts +0 -1
  257. package/src/status/RuntimeStatusMonitor.ts +0 -120
  258. package/src/status/ServiceStatus.ts +0 -21
  259. package/src/status/index.ts +0 -2
  260. package/src/summary/index.ts +0 -2
  261. package/src/summary/model/BalancesStepSummary.ts +0 -35
  262. package/src/summary/model/SchemasStepSummary.ts +0 -33
  263. package/src/summary/model/StepSummary.ts +0 -20
  264. package/src/summary/model/TransfersSummary.ts +0 -36
  265. package/src/summary/model/index.ts +0 -4
  266. package/src/summary/primitives/balances/balancesStepSummaryFromRange.ts +0 -94
  267. package/src/summary/primitives/balances/balancesSummary.ts +0 -48
  268. package/src/summary/primitives/balances/index.ts +0 -2
  269. package/src/summary/primitives/index.ts +0 -3
  270. package/src/summary/primitives/schemas/index.ts +0 -2
  271. package/src/summary/primitives/schemas/schemasStepSummaryFromRange.ts +0 -86
  272. package/src/summary/primitives/schemas/schemasSummary.ts +0 -44
  273. package/src/summary/primitives/transfers/index.ts +0 -2
  274. package/src/summary/primitives/transfers/transfersStepSummaryFromRange.ts +0 -109
  275. package/src/summary/primitives/transfers/transfersSummary.ts +0 -52
  276. package/src/test/BuildBlockOptions.ts +0 -81
  277. package/src/test/buildBlock.ts +0 -105
  278. package/src/test/buildGenesisBlock.ts +0 -29
  279. package/src/test/buildNextBlock.ts +0 -37
  280. package/src/test/buildRandomChain.ts +0 -92
  281. package/src/test/buildRandomGenesisBlock.ts +0 -47
  282. package/src/test/createGenesisBlock.ts +0 -41
  283. package/src/test/createProducerChainStakeIntentTransaction.ts +0 -48
  284. package/src/test/getSimpleBlockViewerLocator.ts +0 -41
  285. package/src/test/getTestProviderContext.ts +0 -8
  286. package/src/test/index.ts +0 -2
  287. package/src/time/index.ts +0 -1
  288. package/src/time/primitives/index.ts +0 -1
  289. package/src/time/primitives/xl1BlockNumberToEthBlockNumber.ts +0 -13
  290. package/src/transaction/TransactionBuilder.ts +0 -164
  291. package/src/transaction/buildRandomTransaction.ts +0 -38
  292. package/src/transaction/buildTransaction.ts +0 -68
  293. package/src/transaction/buildUnsignedTransaction.ts +0 -56
  294. package/src/transaction/confirmSubmittedTransaction.ts +0 -42
  295. package/src/transaction/hydrateTransaction.ts +0 -117
  296. package/src/transaction/index.ts +0 -9
  297. package/src/transaction/primitives/index.ts +0 -4
  298. package/src/transaction/primitives/transactionBlockByteCount.ts +0 -10
  299. package/src/transaction/primitives/transactionElevatedPayloads.ts +0 -18
  300. package/src/transaction/primitives/transactionOperations.ts +0 -13
  301. package/src/transaction/primitives/transactionRequiredGas.ts +0 -22
  302. package/src/transaction/script.ts +0 -48
  303. package/src/transaction/signTransaction.ts +0 -32
  304. package/src/utils/HydratedCache.ts +0 -39
  305. package/src/utils/index.ts +0 -2
  306. package/src/utils/isZodError.ts +0 -11
  307. package/src/validation/index.ts +0 -2
  308. package/src/validation/lib/getUrl.ts +0 -7
  309. package/src/validation/lib/index.ts +0 -2
  310. package/src/validation/lib/isLocalhost.ts +0 -9
  311. package/src/validation/schema/Address.ts +0 -2
  312. package/src/validation/schema/Mnemonic.ts +0 -21
  313. package/src/validation/schema/index.ts +0 -2
  314. package/src/wallet/generateXyoBaseWalletFromPhrase.ts +0 -13
  315. package/src/wallet/index.ts +0 -2
  316. package/src/wallet/paths.ts +0 -17
@@ -1,4 +0,0 @@
1
- export * from './ShiftedBigInt.ts'
2
- export * from './splitOnDecimal.ts'
3
- export * from './splitOnDecimalToString.ts'
4
- export * from './XL1Amount.ts'
@@ -1,6 +0,0 @@
1
- /** Splits a bigint into whole and decimal parts based on the specified number of decimal places */
2
- export const splitOnDecimal = (value: bigint, places = 18): [bigint, bigint] => {
3
- const whole = value / BigInt(10 ** places)
4
- const decimal = value % BigInt(10 ** places)
5
- return [whole, decimal]
6
- }
@@ -1,40 +0,0 @@
1
- import { splitOnDecimal } from './splitOnDecimal.ts'
2
-
3
- /** Formats a bigint as a locale-aware decimal string with configurable precision and character limits */
4
- export const splitOnDecimalToString = (
5
- value: bigint,
6
- places = 18,
7
- maxDecimal = places,
8
- maxCharacters = 9,
9
- minDecimals = 1,
10
- locale: Intl.LocalesArgument = 'en-US',
11
- ): string => {
12
- const [whole, decimal] = splitOnDecimal(value, places)
13
- const remainderLength = decimal.toString().length
14
- const precedingZerosInDecimal = places - remainderLength
15
- if (whole === 0n && precedingZerosInDecimal >= maxDecimal && decimal !== 0n) return '< 0.'.padEnd(maxDecimal + 5, '0') + '1'
16
-
17
- const wholeCharacters = whole.toString(10).length
18
- const calcMaxDecimalCharacters = maxCharacters === -1 ? places : wholeCharacters > maxCharacters ? 0 : maxCharacters - wholeCharacters
19
- const maxDecimalCharacters = Math.min(maxDecimal, calcMaxDecimalCharacters)
20
-
21
- // Format whole number with thousand separators according to locale
22
- const formattedWhole = new Intl.NumberFormat(locale, {
23
- maximumFractionDigits: 0,
24
- useGrouping: true,
25
- }).format(whole)
26
-
27
- // Get decimal separator for the locale
28
- const decimalSeparator = new Intl.NumberFormat(locale)
29
- .formatToParts(1.1)
30
- .find(part => part.type === 'decimal')?.value ?? '.'
31
-
32
- // Pad decimal part to correct number of places
33
- let paddedDecimal = decimal.toString().padStart(places, '0').slice(0, maxDecimalCharacters)
34
- // remove unneeded trailing zeros (honoring minDecimals)
35
- while (paddedDecimal.length > minDecimals && paddedDecimal.endsWith('0')) {
36
- paddedDecimal = paddedDecimal.slice(0, -1)
37
- }
38
-
39
- return `${formattedWhole}${paddedDecimal.length > 0 ? decimalSeparator : ''}${paddedDecimal}`
40
- }
@@ -1,8 +0,0 @@
1
- import type { Hash } from '@xylabs/sdk-js'
2
- import type { Payload, WithHashMeta } from '@xyo-network/sdk-js'
3
-
4
- /** AllHashesPresent helper function. */
5
- export function allHashesPresent(hashes: Hash[], payloads: WithHashMeta<Payload>[]): boolean {
6
- const payloadHashes = new Set(payloads.map(p => p._hash))
7
- return hashes.every(hash => payloadHashes.has(hash))
8
- }
@@ -1,12 +0,0 @@
1
- import { assertEx } from '@xylabs/sdk-js'
2
- import type { WithStorageMeta } from '@xyo-network/sdk-js'
3
- import type { HydratedBlockWithStorageMeta } from '@xyo-network/xl1-protocol-lib'
4
- import { isTransactionBoundWitness } from '@xyo-network/xl1-protocol-lib'
5
-
6
- /** blockPayloadsFromHydratedBlock constant. */
7
- export const blockPayloadsFromHydratedBlock = (block: HydratedBlockWithStorageMeta): WithStorageMeta[] => {
8
- return block[0].payload_hashes.map(hash => assertEx(
9
- block[1].find(p => p._hash === hash),
10
- () => `missing payload ${hash}`,
11
- )).filter(x => !isTransactionBoundWitness(x))
12
- }
@@ -1,28 +0,0 @@
1
- import type { Payload } from '@xyo-network/sdk-js'
2
- import { type BlockBoundWitness, toHydratedBlock } from '@xyo-network/xl1-protocol-lib'
3
-
4
- /** flattenHydratedBlock constant. */
5
- export const flattenHydratedBlock = <B extends BlockBoundWitness, P extends Payload>(hydratedBlock: [B, P[]]): (P | B)[] => {
6
- const [blk, blkPayloads] = hydratedBlock
7
- return [...blkPayloads, blk]
8
- }
9
-
10
- /** tryUnflattenHydratedBlock constant. */
11
- export const tryUnflattenHydratedBlock = <
12
- B extends BlockBoundWitness,
13
- P extends Payload,
14
- >(flattened: (P | B)[]): [B, P[]] | undefined => {
15
- // Last element is the block
16
- const blk = flattened.at(-1) as B
17
-
18
- // All previous elements are payloads
19
- const payloads = flattened.slice(0, -1) as P[]
20
-
21
- return toHydratedBlock([blk, payloads])
22
- }
23
-
24
- /** unflattenHydratedBlock constant. */
25
- export const unflattenHydratedBlock = <
26
- B extends BlockBoundWitness,
27
- P extends Payload,
28
- >(flattened: (P | B)[]): [B, P[]] => toHydratedBlock(tryUnflattenHydratedBlock(flattened), true) as [B, P[]]
@@ -1,7 +0,0 @@
1
- import type { HydratedBlock } from '@xyo-network/xl1-protocol-lib'
2
-
3
- import { flattenHydratedBlock } from './flattenHydratedBlock.ts'
4
-
5
- /** flattenHydratedBlocks constant. */
6
- export const flattenHydratedBlocks = <T extends HydratedBlock>(hydratedBlocks: T[]): (T[0] | T[1][number])[] =>
7
- hydratedBlocks.flatMap(blk => flattenHydratedBlock(blk))
@@ -1,43 +0,0 @@
1
- import type { Hash } from '@xylabs/sdk-js'
2
- import { assertEx } from '@xylabs/sdk-js'
3
- import { asAnyPayload } from '@xyo-network/sdk-js'
4
- import type { BlockContextRead, HydratedBlockWithStorageMeta } from '@xyo-network/xl1-protocol-lib'
5
- import { asBlockBoundWitnessWithStorageMeta, isTransactionBoundWitnessWithStorageMeta } from '@xyo-network/xl1-protocol-lib'
6
-
7
- import { allHashesPresent } from './allHashesPresent.ts'
8
-
9
- /** hydrateBlock constant. */
10
- export const hydrateBlock = async (
11
- context: BlockContextRead,
12
- hash: Hash,
13
- maxDepth: number = 1,
14
- minDepth = maxDepth,
15
- ): Promise<HydratedBlockWithStorageMeta> => {
16
- assertEx(maxDepth >= 0, () => 'maxDepth must be greater than or equal to 0')
17
- assertEx(minDepth >= 0, () => 'minDepth must be greater than or equal to 0')
18
- assertEx(maxDepth >= minDepth, () => 'maxDepth must be greater than or equal to minDepth')
19
-
20
- const { chainMap } = context
21
-
22
- const [block] = await chainMap.get([hash])
23
- const bw = assertEx(asBlockBoundWitnessWithStorageMeta(
24
- assertEx(block, () => `block ${hash} not found`),
25
- ), () => `hash ${hash} is not a BlockBoundWitness`)
26
-
27
- if (maxDepth === 0) return [bw, []]
28
- const blkPayloads = (await chainMap.get(bw.payload_hashes)).map(p => asAnyPayload(p, true))
29
- if (minDepth === 1) assertEx(allHashesPresent(bw.payload_hashes, blkPayloads), () => `Unable to find all payloads for block ${hash}`)
30
- if (maxDepth === 1) return [bw, blkPayloads]
31
- const transactions = blkPayloads.filter(isTransactionBoundWitnessWithStorageMeta)
32
- const transactionsPayloadHashes = transactions.flatMap(tx => tx.payload_hashes)
33
- const transactionsPayloads = (await chainMap.get(transactionsPayloadHashes)).map(p => asAnyPayload(p, true))
34
- assertEx(allHashesPresent(transactionsPayloadHashes, transactionsPayloads), () => `Unable to find all payloads for transactions in block ${hash}`)
35
- const allPayloadsHashes = new Set([...blkPayloads, ...transactionsPayloads].flatMap(p => p._hash))
36
- const allPayloads = (await chainMap.get([...allPayloadsHashes])).map(p => asAnyPayload(p, true))
37
- const allPayloadsFiltered = allPayloads.filter(p => allPayloadsHashes.has(p._hash))
38
- if (maxDepth === 2) assertEx(allHashesPresent(
39
- [...allPayloadsHashes],
40
- allPayloadsFiltered,
41
- ), () => `Unable to find all payloads for transactions in block ${hash}`)
42
- return [bw, allPayloadsFiltered]
43
- }
@@ -1,7 +0,0 @@
1
- export * from './allHashesPresent.ts'
2
- export * from './blockPayloadsFromHydratedBlock.ts'
3
- export * from './flattenHydratedBlock.ts'
4
- export * from './flattenHydratedBlocks.ts'
5
- export * from './hydrateBlock.ts'
6
- export * from './transactionsFromHydratedBlock.ts'
7
- export * from './tryHydrateBlock.ts'
@@ -1,7 +0,0 @@
1
- import type { HydratedBlock, TransactionBoundWitnessWithStorageMeta } from '@xyo-network/xl1-protocol-lib'
2
- import { isTransactionBoundWitnessWithStorageMeta } from '@xyo-network/xl1-protocol-lib'
3
-
4
- /** transactionsFromHydratedBlock constant. */
5
- export const transactionsFromHydratedBlock = (block: HydratedBlock): TransactionBoundWitnessWithStorageMeta[] => {
6
- return block[1].filter(isTransactionBoundWitnessWithStorageMeta)
7
- }
@@ -1,26 +0,0 @@
1
- import type { Hash } from '@xylabs/sdk-js'
2
- import { assertEx } from '@xylabs/sdk-js'
3
- import type { ReadArchivist } from '@xyo-network/sdk-js'
4
- import type { HydratedBlock } from '@xyo-network/xl1-protocol-lib'
5
- import { isBlockBoundWitnessWithStorageMeta, isTransactionBoundWitnessWithStorageMeta } from '@xyo-network/xl1-protocol-lib'
6
-
7
- /** tryHydrateBlock constant. */
8
- export const tryHydrateBlock = async (
9
- archivist: ReadArchivist,
10
- hash: Hash,
11
- maxDepth: number = 1,
12
- ): Promise<HydratedBlock | undefined> => {
13
- assertEx(maxDepth >= 0, () => 'maxDepth must be greater than or equal to 0')
14
- const bw = (await archivist.get([hash])).find(isBlockBoundWitnessWithStorageMeta)
15
- if (!bw) return undefined
16
- if (maxDepth === 0) return [bw, []]
17
- const blkPayloads = await archivist.get(bw.payload_hashes)
18
- if (maxDepth === 1) return [bw, blkPayloads]
19
- const transactions = blkPayloads.filter(isTransactionBoundWitnessWithStorageMeta)
20
- const transactionsPayloadHashes = transactions.flatMap(tx => tx.payload_hashes)
21
- const transactionsPayloads = await archivist.get(transactionsPayloadHashes)
22
- const allPayloadsHashes = new Set([...blkPayloads, ...transactionsPayloads].flatMap(p => p._hash))
23
- const allPayloads = await archivist.get([...allPayloadsHashes])
24
- const allPayloadsFiltered = allPayloads.filter(p => allPayloadsHashes.has(p._hash))
25
- return [bw, allPayloadsFiltered]
26
- }
@@ -1,2 +0,0 @@
1
- export * from './hydrate/index.ts'
2
- export * from './primitives/index.ts'
@@ -1,69 +0,0 @@
1
- import {
2
- asHash, type Hash, isDefined,
3
- spanAsync,
4
- } from '@xylabs/sdk-js'
5
- import { toSafeJsonString } from '@xylabs/sdk-js'
6
- import type { Signed, WithHashMeta } from '@xyo-network/sdk-js'
7
- import type {
8
- BlockBoundWitness, ChainContextRead, XL1BlockNumber,
9
- } from '@xyo-network/xl1-protocol-lib'
10
- import {
11
- asSignedBlockBoundWitnessWithStorageMeta, SignedBlockBoundWitnessWithHashMetaZod, StepSizes,
12
- } from '@xyo-network/xl1-protocol-lib'
13
-
14
- import { withContextCacheResponse } from '../../ChainContextHelpers.ts'
15
-
16
- /** BlockFromBlockNumber helper function. */
17
- export async function blockFromBlockNumber(
18
- context: ChainContextRead,
19
- blockNumber: XL1BlockNumber,
20
- ): Promise<WithHashMeta<Signed<BlockBoundWitness>>> {
21
- return await spanAsync('blockFromBlockNumber', async () => {
22
- const cacheKey = `${blockNumber}`
23
- const { chainMap, head } = context
24
- return await withContextCacheResponse(context, 'blockFromBlockNumber', cacheKey, async () => {
25
- const [result] = await chainMap.get([head._hash])
26
- if (!isDefined(result)) {
27
- throw new Error(`Head block not found for hash: ${head._hash}`)
28
- }
29
- let currentBlock = asSignedBlockBoundWitnessWithStorageMeta(
30
- result,
31
- () => `Found Payload is not a Signed<BlockBoundWitness>: ${JSON.stringify(result, null, 2)}`,
32
- )
33
- if (currentBlock.block < blockNumber) {
34
- throw new Error(`Block number ${blockNumber} is greater than head ${currentBlock.block}.`)
35
- }
36
- while (currentBlock.block > blockNumber) {
37
- let jumpHash: Hash | null = currentBlock.previous
38
- let jumpBlockNumber = currentBlock.block - 1
39
- for (const [step, stepSize] of StepSizes.entries()) {
40
- const possibleJumpBlockNumber = currentBlock.block - (currentBlock.block % stepSize) - 1
41
- if (possibleJumpBlockNumber >= blockNumber && possibleJumpBlockNumber <= jumpBlockNumber) {
42
- jumpBlockNumber = possibleJumpBlockNumber
43
- jumpHash = asHash(currentBlock.step_hashes?.at(step), () => `Step hash not found for step ${step} in block ${currentBlock.block}`)
44
- }
45
- }
46
- const [newBlock] = await chainMap.get([
47
- asHash(jumpHash, () => `Jump hash not found for block number [${blockNumber}]: ${jumpBlockNumber} ${toSafeJsonString(currentBlock, 10)}`),
48
- ])
49
- if (!isDefined(newBlock)) {
50
- throw new Error(`Block not found for jump hash: ${jumpHash}`)
51
- }
52
- currentBlock = asSignedBlockBoundWitnessWithStorageMeta(
53
- newBlock,
54
- () => {
55
- const result = SignedBlockBoundWitnessWithHashMetaZod.safeParse(newBlock)
56
- return `Found Payload [jump hash] is not a Signed<BlockBoundWitness>: ${result.error}`
57
- },
58
- )
59
- if (currentBlock.block === blockNumber) {
60
- break
61
- }
62
- if (currentBlock.block < blockNumber) {
63
- throw new Error(`Block number ${blockNumber} is not a valid step block number for block ${head._hash}.`)
64
- }
65
- }
66
- return currentBlock
67
- })
68
- }, { ...context, timeBudgetLimit: 500 })
69
- }
@@ -1,30 +0,0 @@
1
- import type { XL1BlockRange } from '@xyo-network/xl1-protocol-lib'
2
- import { asXL1BlockNumber, stepSize } from '@xyo-network/xl1-protocol-lib'
3
-
4
- /** CalculateFramesFromRange helper function. */
5
- export function calculateFramesFromRange(range: XL1BlockRange, step: number): [
6
- // ranges of fitted frames
7
- XL1BlockRange[],
8
- // ranges of remaining blocks
9
- XL1BlockRange[]] {
10
- const size = stepSize(step)
11
- let start = (Math.trunc(range[0] / size)) * size
12
- const fitted: XL1BlockRange[] = []
13
- const remaining: XL1BlockRange[] = []
14
-
15
- // if the start is not aligned with the range, add a remaining block
16
- if (start !== range[0]) {
17
- start += size
18
- remaining.push([range[0], asXL1BlockNumber(Math.min(start - 1, range[1]), true)])
19
- }
20
-
21
- for (let i = start; i <= range[1]; i += size) {
22
- if ((i + size - 1) <= range[1]) {
23
- fitted.push([asXL1BlockNumber(i, { name: 'calculateFramesFromRange A' }),
24
- asXL1BlockNumber(Math.min(i + size - 1, range[1]), { name: 'calculateFramesFromRange B' })])
25
- } else {
26
- remaining.push([asXL1BlockNumber(i, { name: 'calculateFramesFromRange C' }), range[1]])
27
- }
28
- }
29
- return [fitted, remaining]
30
- }
@@ -1,28 +0,0 @@
1
- import type { XL1BlockRange } from '@xyo-network/xl1-protocol-lib'
2
- import { StepSizes } from '@xyo-network/xl1-protocol-lib'
3
-
4
- import { calculateFramesFromRange } from './calculateFramesFromRange.ts'
5
-
6
- /** DeepCalculateFramesFromRange helper function. */
7
- export function deepCalculateFramesFromRange(range: XL1BlockRange, startingStep = StepSizes.length - 1): XL1BlockRange[] {
8
- const fitted: XL1BlockRange[] = []
9
- let remaining: XL1BlockRange[] = [range]
10
-
11
- for (let step = startingStep; step >= 0; step--) {
12
- const newRemaining: XL1BlockRange[] = []
13
- for (const range of remaining) {
14
- const [newFittedFrames, newRemainingFrames] = calculateFramesFromRange(range, step)
15
- fitted.push(...newFittedFrames)
16
- newRemaining.push(...newRemainingFrames)
17
- }
18
- remaining = newRemaining
19
- }
20
-
21
- for (const range of remaining) {
22
- for (let i = range[0]; i <= range[1]; i++) {
23
- fitted.push([i, i]) // Add individual frames for remaining ranges
24
- }
25
- }
26
-
27
- return fitted.toSorted((a, b) => a[0] - b[0]) // Sort by start of range
28
- }
@@ -1,2 +0,0 @@
1
- export * from './calculateFramesFromRange.ts'
2
- export * from './deepCalculateFramesFromRange.ts'
@@ -1,9 +0,0 @@
1
- import { type Hash } from '@xylabs/sdk-js'
2
- import type { ChainContextRead, XL1BlockNumber } from '@xyo-network/xl1-protocol-lib'
3
-
4
- import { blockFromBlockNumber } from './blockFromBlockNumber.ts'
5
-
6
- /** HashFromBlockNumber helper function. */
7
- export async function hashFromBlockNumber(context: ChainContextRead, blockNumber: XL1BlockNumber): Promise<Hash> {
8
- return (await blockFromBlockNumber(context, blockNumber))._hash
9
- }
@@ -1,7 +0,0 @@
1
- export * from './blockFromBlockNumber.ts'
2
- export * from './frames/index.ts'
3
- export * from './hashFromBlockNumber.ts'
4
- export * from './model.ts'
5
- export * from './payloads/index.ts'
6
- export * from './toStepIdentityString.ts'
7
- export * from './validateTransactionOpcodes.ts'
@@ -1,18 +0,0 @@
1
- import type {
2
- ReadArchivist, ReadWriteArchivist, WriteArchivist,
3
- } from '@xyo-network/sdk-js'
4
-
5
- /** Type guard that checks if a value is a valid ReadArchivist. */
6
- export function isReadArchivist(value: unknown): value is ReadArchivist {
7
- return (value as ReadArchivist).get !== undefined && (value as ReadArchivist).next !== undefined
8
- }
9
-
10
- /** Type guard that checks if a value is a valid WriteArchivist. */
11
- export function isWriteArchivist(value: unknown): value is WriteArchivist {
12
- return (value as WriteArchivist).insert !== undefined
13
- }
14
-
15
- /** Type guard that checks if a value is a valid ReadWriteArchivist. */
16
- export function isReadWriteArchivist(value: unknown): value is ReadWriteArchivist {
17
- return isReadArchivist(value) && isWriteArchivist(value)
18
- }
@@ -1,7 +0,0 @@
1
- import type { Hash } from '@xylabs/sdk-js'
2
-
3
- /** ChainWindow interface. */
4
- export interface ChainWindow {
5
- depth: number // number of blocks the window covers, including the head
6
- head: Hash // the head of the chain
7
- }
@@ -1 +0,0 @@
1
- export * from './ChainWindow.ts'
@@ -1,6 +0,0 @@
1
- import type { StepIdentity, StepIdentityString } from '@xyo-network/xl1-protocol-lib'
2
-
3
- /** Converts a value to StepIdentityString format. */
4
- export function toStepIdentityString({ block, step }: StepIdentity): StepIdentityString {
5
- return `${block}|${step}` as StepIdentityString
6
- }
@@ -1,45 +0,0 @@
1
- import {
2
- assertEx, isHash, toSafeJsonString,
3
- } from '@xylabs/sdk-js'
4
- import {
5
- type Payload, PayloadBuilder, type WithStorageMeta,
6
- } from '@xyo-network/sdk-js'
7
- import type { HydratedTransaction } from '@xyo-network/xl1-protocol-lib'
8
- import { isExecutable } from '@xyo-network/xl1-protocol-lib'
9
-
10
- /** Validates TransactionsOpcodes and returns any errors found. */
11
- export async function validateTransactionsOpcodes(txs: HydratedTransaction[]) {
12
- const txElevatedPayloads: WithStorageMeta<Payload>[] = []
13
- for (const [txBw, txPayloads] of txs) {
14
- if (isExecutable(txBw)) {
15
- const operations = txBw.script.map(op => op.split('|'))
16
- for (let [opCode, ...args] of operations) {
17
- switch (opCode) {
18
- case 'elevate': {
19
- const [hash, ...rest] = args
20
- const txPayloadsWithStorageMeta = await PayloadBuilder.addStorageMeta(txPayloads)
21
- assertEx(rest.length === 0, () => `Invalid elevate operation ${opCode} ${args} - Too many Arguments`)
22
- if (isHash(hash)) {
23
- assertEx(
24
- txBw.payload_hashes.includes(hash),
25
- () => `Invalid elevate operation ${opCode} ${args} - Hash not in payload hashes => ${toSafeJsonString(txBw, 20)}`,
26
- )
27
- const txPayload = assertEx(
28
- txPayloadsWithStorageMeta.find(p => p._hash === hash),
29
- () => `Invalid elevate operation ${opCode} ${args} - Payload not found`,
30
- )
31
- txElevatedPayloads.push(txPayload)
32
- } else {
33
- throw new Error(`Invalid elevate operation ${opCode} ${args} - Invalid hash`)
34
- }
35
- break
36
- }
37
- default: {
38
- throw new Error(`Invalid opCode ${opCode}`)
39
- }
40
- }
41
- }
42
- }
43
- }
44
- return txElevatedPayloads
45
- }
@@ -1,32 +0,0 @@
1
- import {
2
- zodAsFactory, zodIsFactory, zodToFactory,
3
- } from '@xylabs/sdk-js'
4
- import { globalRegistry, z } from 'zod'
5
-
6
- import { MnemonicStringZod } from '../validation/index.ts'
7
- import { BaseConfigZod } from './Base.ts'
8
-
9
- /** ActorConfigZod constant. */
10
- export const ActorConfigZod = BaseConfigZod.extend({
11
- name: z.string(),
12
- mnemonic: MnemonicStringZod.optional().register(globalRegistry, {
13
- description: 'Mnemonic for the Actor wallet',
14
- title: 'mnemonic',
15
- type: 'string',
16
- }),
17
- healthCheckPort: z.coerce.number().optional().register(globalRegistry, {
18
- description: 'Port for the Producer health checks',
19
- title: 'producer.healthCheckPort',
20
- type: 'number',
21
- }),
22
- })
23
-
24
- /** ActorConfig type. */
25
- export type ActorConfig = z.infer<typeof ActorConfigZod>
26
-
27
- /** Type guard that checks if a value is a valid ActorConfig. */
28
- export const isActorConfig = zodIsFactory(ActorConfigZod)
29
- /** Converts a value to ActorConfig, throwing if invalid. */
30
- export const asActorConfig = zodAsFactory(ActorConfigZod, 'asActorConfig')
31
- /** toActorConfig constant. */
32
- export const toActorConfig = zodToFactory(ActorConfigZod, 'toActorConfig')
@@ -1,9 +0,0 @@
1
- import z from 'zod'
2
-
3
- import { ActorConfigZod } from './Actor.ts'
4
-
5
- /** ActorsConfigZod constant. */
6
- export const ActorsConfigZod = z.array(ActorConfigZod.loose()).describe('Actor-specific configurations that override the base configuration when the actor is running').default([])
7
-
8
- /** ActorsConfig type. */
9
- export type ActorsConfig = z.infer<typeof ActorsConfigZod>
@@ -1,27 +0,0 @@
1
- import { z } from 'zod'
2
-
3
- import { ChainConfigZod } from './Chain.ts'
4
- import { DataLakeConfigZod } from './DataLake/index.ts'
5
- import { EvmConfigZod } from './Evm.ts'
6
- import { LogConfigZod } from './Log.ts'
7
- import { ProvidersConfigZod } from './Providers.ts'
8
- import { RemoteConfigZod } from './Remote.ts'
9
- import { StorageConfigZod } from './storage/index.ts'
10
- import { TelemetryConfigZod } from './Telemetry.ts'
11
- import { ValidationConfigZod } from './Validation.ts'
12
-
13
- /** BaseConfigZod constant. */
14
- export const BaseConfigZod = z.object({
15
- chain: ChainConfigZod.default(ChainConfigZod.parse({})).describe('Configuration for the chain'),
16
- dataLake: DataLakeConfigZod.optional().describe('Configuration for data lakes'),
17
- evm: EvmConfigZod.default(EvmConfigZod.parse({})).describe('Configuration for EVM-backed services'),
18
- log: LogConfigZod.default(LogConfigZod.parse({})).describe('Configuration for logging'),
19
- providers: ProvidersConfigZod.default(ProvidersConfigZod.parse([])).describe('Configuration for providers'),
20
- remote: RemoteConfigZod.default(RemoteConfigZod.parse({})).describe('Configuration for remote services'),
21
- storage: StorageConfigZod.default(StorageConfigZod.parse({})).describe('Configuration for the storage'),
22
- telemetry: TelemetryConfigZod.default(TelemetryConfigZod.parse({})).describe('Configuration for telemetry'),
23
- validation: ValidationConfigZod.default(ValidationConfigZod.parse({})).describe('Configuration for validation'),
24
- })
25
-
26
- /** BaseConfig type. */
27
- export type BaseConfig = z.infer<typeof BaseConfigZod>
@@ -1,23 +0,0 @@
1
- import { AddressZod, HexZod } from '@xylabs/sdk-js'
2
- import { globalRegistry, z } from 'zod'
3
-
4
- /** ChainConfigZod constant. */
5
- export const ChainConfigZod = z.object({
6
- id: HexZod.optional()
7
- .register(globalRegistry, {
8
- description:
9
- 'The unique identifier for the chain. Should be the staking contract address for contract-backed chains.',
10
- title: 'chain.id',
11
- type: 'string',
12
- }),
13
- genesisRewardAddress: AddressZod.optional()
14
- .register(globalRegistry, {
15
- description:
16
- 'Address to send the initial genesis rewards to, if a new chain is being created.',
17
- title: 'chain.genesisRewardAddress',
18
- type: 'Address',
19
- }),
20
- })
21
-
22
- /** ChainConfig type. */
23
- export type ChainConfig = z.infer<typeof ChainConfigZod>
@@ -1,24 +0,0 @@
1
- import type z from 'zod'
2
-
3
- import { ActorConfigZod } from './Actor.ts'
4
- import { ActorsConfigZod } from './Actors.ts'
5
- import { BaseConfigZod } from './Base.ts'
6
- import type { DeepPartial } from './DeepPartial.ts'
7
-
8
- /** ConfigZod constant. */
9
- export const ConfigZod = BaseConfigZod.extend({ actors: ActorsConfigZod }).describe('The complete configuration for the protocol, including global settings and actor-specific overrides')
10
-
11
- /** Config type. */
12
- export type Config = z.infer<typeof ConfigZod>
13
-
14
- /** ResolveConfig helper function. */
15
- export function resolveConfig(
16
- config: DeepPartial<Config>,
17
- ) {
18
- const parsedConfig = ConfigZod.parse(config)
19
- const { actors, ...rootConfig } = parsedConfig
20
- parsedConfig.actors = actors.map((actorConfig) => {
21
- return ActorConfigZod.loose().parse({ ...rootConfig, ...actorConfig })
22
- })
23
- return parsedConfig
24
- }
@@ -1,12 +0,0 @@
1
- import { z } from 'zod'
2
-
3
- import { type RestDataLakeConfig, RestDataLakeConfigZod } from './RestDataLakeConfig.ts'
4
- import { type RouterDataLakeConfig, RouterDataLakeConfigZod } from './RouterDataLakeConfig.ts'
5
-
6
- /** DataLakeConfig type. */
7
- export type DataLakeConfig = RestDataLakeConfig | RouterDataLakeConfig
8
-
9
- // z.lazy handles the circular reference between DataLakeConfigZod and RouterDataLakeZod
10
- /** DataLakeConfigZod constant. */
11
- export const DataLakeConfigZod: z.ZodType<DataLakeConfig> = z.lazy(() =>
12
- z.union([RestDataLakeConfigZod, RouterDataLakeConfigZod])).describe('Configuration for a data lake')
@@ -1,11 +0,0 @@
1
- import { globalRegistry, z } from 'zod'
2
-
3
- /** DataLakeDriverConfigBaseZod constant. */
4
- export const DataLakeDriverConfigBaseZod = z.object({
5
- driver: z.string().register(globalRegistry, {
6
- description: 'Driver for the data lake',
7
- type: 'string',
8
- }),
9
- }).describe('Base configuration for a data lake driver')
10
- /** DataLakeDriverConfigBase type. */
11
- export type DataLakeDriverConfigBase = z.infer<typeof DataLakeDriverConfigBaseZod>
@@ -1,18 +0,0 @@
1
- import { globalRegistry, z } from 'zod'
2
-
3
- import { DataLakeDriverConfigBaseZod } from './DataLakeRemoteConfig.ts'
4
-
5
- /** RestDataLakeConfigZod constant. */
6
- export const RestDataLakeConfigZod = DataLakeDriverConfigBaseZod.extend({
7
- driver: z.literal('rest').register(globalRegistry, {
8
- description: 'Driver for the REST data lake',
9
- type: 'string',
10
- }),
11
- url: z.string().register(globalRegistry, {
12
- description: 'URL for the REST data lake',
13
- type: 'string',
14
- }),
15
- }).describe('Configuration for the REST data lake driver')
16
-
17
- /** RestDataLakeConfig type. */
18
- export type RestDataLakeConfig = z.infer<typeof RestDataLakeConfigZod>
@@ -1,22 +0,0 @@
1
- import { globalRegistry, z } from 'zod'
2
-
3
- import type { DataLakeConfig } from './DataLake.ts'
4
- import { DataLakeConfigZod } from './DataLake.ts'
5
-
6
- /** Configuration for RouterDataLake. */
7
- export interface RouterDataLakeConfig {
8
- children: DataLakeConfig[]
9
- driver: 'router'
10
- }
11
-
12
- /** RouterDataLakeConfigZod constant. */
13
- export const RouterDataLakeConfigZod: z.ZodType<RouterDataLakeConfig> = z.object({
14
- driver: z.literal('router').register(globalRegistry, {
15
- description: 'Driver for the router data lake',
16
- type: 'string',
17
- }),
18
- children: z.array(z.lazy(() => DataLakeConfigZod)).register(globalRegistry, {
19
- description: 'Child data lake drivers',
20
- type: 'array',
21
- }),
22
- }).describe('Configuration for the router data lake driver')
@@ -1,4 +0,0 @@
1
- export * from './DataLake.ts'
2
- export * from './DataLakeRemoteConfig.ts'
3
- export * from './RestDataLakeConfig.ts'
4
- export * from './RouterDataLakeConfig.ts'