@xyo-network/xl1-protocol-sdk 1.26.12 → 1.26.14

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 (331) hide show
  1. package/dist/neutral/config/Actors.d.ts +1 -1
  2. package/dist/neutral/config/Base.d.ts +1 -1
  3. package/dist/neutral/config/Config.d.ts +4 -4
  4. package/dist/neutral/payloads/AddressPairPayload.d.ts +1 -1
  5. package/dist/neutral/payloads/AddressPairPayload.d.ts.map +1 -1
  6. package/dist/neutral/primitives/uncle/findBestUncle.d.ts +13 -13
  7. package/dist/neutral/primitives/uncle/findUncles.d.ts +2 -2
  8. package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts +2 -2
  9. package/dist/neutral/simple/block/SimpleBlockViewer.d.ts +2 -2
  10. package/dist/neutral/simple/chainContractViewer/SimpleChainContractViewer.d.ts +1 -1
  11. package/dist/neutral/simple/datalake/SimpleDataLakeRunner.d.ts +1 -1
  12. package/dist/neutral/simple/finalization/SimpleFinalizationViewer.d.ts +1 -1
  13. package/dist/neutral/simple/windowedBlock/SimpleWindowedBlockViewer.d.ts +10 -10
  14. package/dist/neutral/transaction/TransactionBuilder.d.ts +4 -4
  15. package/dist/neutral/transaction/signTransaction.d.ts +1 -1
  16. package/package.json +24 -21
  17. package/src/ChainContextHelpers.ts +0 -50
  18. package/src/CreatableProvider/AbstractCreatableProvider.ts +0 -97
  19. package/src/CreatableProvider/CreatableProvider.ts +0 -102
  20. package/src/CreatableProvider/CreatableProviderRegistry.ts +0 -94
  21. package/src/CreatableProvider/GetInstanceOptions.ts +0 -11
  22. package/src/CreatableProvider/LabeledCreatableProviderFactory.ts +0 -24
  23. package/src/CreatableProvider/ProviderFactory.ts +0 -138
  24. package/src/CreatableProvider/ProviderFactoryLocator.ts +0 -170
  25. package/src/CreatableProvider/ProviderFactoryLocatorInstance.ts +0 -70
  26. package/src/CreatableProvider/index.ts +0 -8
  27. package/src/SignedBigInt.ts +0 -59
  28. package/src/_internal/context/getTestProviderContext.ts +0 -13
  29. package/src/_internal/context/index.ts +0 -1
  30. package/src/_internal/index.ts +0 -2
  31. package/src/actor/ActorV3.ts +0 -177
  32. package/src/actor/index.ts +0 -1
  33. package/src/amount/ShiftedBigInt.ts +0 -73
  34. package/src/amount/XL1Amount.ts +0 -103
  35. package/src/amount/index.ts +0 -4
  36. package/src/amount/splitOnDecimal.ts +0 -6
  37. package/src/amount/splitOnDecimalToString.ts +0 -40
  38. package/src/block/hydrate/allHashesPresent.ts +0 -8
  39. package/src/block/hydrate/blockPayloadsFromHydratedBlock.ts +0 -12
  40. package/src/block/hydrate/flattenHydratedBlock.ts +0 -28
  41. package/src/block/hydrate/flattenHydratedBlocks.ts +0 -7
  42. package/src/block/hydrate/hydrateBlock.ts +0 -43
  43. package/src/block/hydrate/index.ts +0 -7
  44. package/src/block/hydrate/transactionsFromHydratedBlock.ts +0 -7
  45. package/src/block/hydrate/tryHydrateBlock.ts +0 -26
  46. package/src/block/index.ts +0 -2
  47. package/src/block/primitives/blockFromBlockNumber.ts +0 -69
  48. package/src/block/primitives/frames/calculateFramesFromRange.ts +0 -30
  49. package/src/block/primitives/frames/deepCalculateFramesFromRange.ts +0 -28
  50. package/src/block/primitives/frames/index.ts +0 -2
  51. package/src/block/primitives/hashFromBlockNumber.ts +0 -9
  52. package/src/block/primitives/index.ts +0 -7
  53. package/src/block/primitives/model.ts +0 -18
  54. package/src/block/primitives/payloads/ChainWindow.ts +0 -7
  55. package/src/block/primitives/payloads/index.ts +0 -1
  56. package/src/block/primitives/toStepIdentityString.ts +0 -6
  57. package/src/block/primitives/validateTransactionOpcodes.ts +0 -45
  58. package/src/config/Actor.ts +0 -32
  59. package/src/config/Actors.ts +0 -9
  60. package/src/config/Base.ts +0 -27
  61. package/src/config/Chain.ts +0 -23
  62. package/src/config/Config.ts +0 -24
  63. package/src/config/DataLake/DataLake.ts +0 -12
  64. package/src/config/DataLake/DataLakeRemoteConfig.ts +0 -11
  65. package/src/config/DataLake/RestDataLakeConfig.ts +0 -18
  66. package/src/config/DataLake/RouterDataLakeConfig.ts +0 -22
  67. package/src/config/DataLake/index.ts +0 -4
  68. package/src/config/DeepPartial.ts +0 -4
  69. package/src/config/Evm.ts +0 -38
  70. package/src/config/HostActor.ts +0 -32
  71. package/src/config/Log.ts +0 -25
  72. package/src/config/Provider.ts +0 -20
  73. package/src/config/Providers.ts +0 -9
  74. package/src/config/Remote.ts +0 -59
  75. package/src/config/Telemetry.ts +0 -49
  76. package/src/config/UsageMeta.ts +0 -46
  77. package/src/config/Validation.ts +0 -29
  78. package/src/config/index.ts +0 -12
  79. package/src/config/storage/Storage.ts +0 -16
  80. package/src/config/storage/driver/Mongo.ts +0 -53
  81. package/src/config/storage/driver/index.ts +0 -1
  82. package/src/config/storage/index.ts +0 -2
  83. package/src/constants.ts +0 -4
  84. package/src/context/Actor.ts +0 -20
  85. package/src/context/HostActor.ts +0 -20
  86. package/src/context/getEmptyProviderContext.ts +0 -19
  87. package/src/context/index.ts +0 -3
  88. package/src/createDeclarationPayload.ts +0 -15
  89. package/src/createTransferPayload.ts +0 -16
  90. package/src/driver/cache/LruCacheMap.ts +0 -48
  91. package/src/driver/cache/index.ts +0 -1
  92. package/src/driver/index.ts +0 -2
  93. package/src/driver/memory/MemoryMap.ts +0 -48
  94. package/src/driver/memory/index.ts +0 -1
  95. package/src/eip-712/Payloads/EIP712Data.ts +0 -35
  96. package/src/eip-712/Payloads/EIP712Signature.ts +0 -32
  97. package/src/eip-712/Payloads/index.ts +0 -2
  98. package/src/eip-712/Types.ts +0 -41
  99. package/src/eip-712/index.ts +0 -4
  100. package/src/eip-712/sign.ts +0 -19
  101. package/src/eip-712/spec/fixtures.ts +0 -27
  102. package/src/eip-712/verify.ts +0 -20
  103. package/src/getFileConfig.ts +0 -36
  104. package/src/index.ts +0 -27
  105. package/src/instances/Address.ts +0 -16
  106. package/src/instances/BoundWitness.ts +0 -13
  107. package/src/instances/Data.ts +0 -4
  108. package/src/instances/Fees.ts +0 -9
  109. package/src/instances/HydratedBoundWitness.ts +0 -16
  110. package/src/instances/Object.ts +0 -6
  111. package/src/instances/Payload.ts +0 -7
  112. package/src/instances/Signature.ts +0 -12
  113. package/src/instances/block/BlockFields.ts +0 -18
  114. package/src/instances/block/HydratedBlock.ts +0 -10
  115. package/src/instances/block/index.ts +0 -1
  116. package/src/instances/index.ts +0 -10
  117. package/src/instances/modifiers/BlockWindowInstance.ts +0 -8
  118. package/src/instances/modifiers/BlockWindowState.ts +0 -6
  119. package/src/instances/modifiers/Signed.ts +0 -9
  120. package/src/instances/modifiers/Validatable.ts +0 -6
  121. package/src/instances/modifiers/index.ts +0 -4
  122. package/src/instances/transaction/HydratedTransaction.ts +0 -9
  123. package/src/instances/transaction/TransactionFields.ts +0 -22
  124. package/src/instances/transaction/index.ts +0 -1
  125. package/src/isInternetAvailable.ts +0 -11
  126. package/src/model/ChainFork/ChainForkStatic.ts +0 -9
  127. package/src/model/ChainFork/index.ts +0 -1
  128. package/src/model/ChainIdentity.ts +0 -6
  129. package/src/model/ChainStore.ts +0 -16
  130. package/src/model/CreatableProviderContext.ts +0 -6
  131. package/src/model/CreatableProviderContext.zod.ts +0 -55
  132. package/src/model/PayloadBundle/bundledPayloadToHydratedBlock.ts +0 -15
  133. package/src/model/PayloadBundle/bundledPayloadToHydratedTransaction.ts +0 -15
  134. package/src/model/PayloadBundle/hydratedBlockToPayloadBundle.ts +0 -19
  135. package/src/model/PayloadBundle/hydratedTransactionToPayloadBundle.ts +0 -19
  136. package/src/model/PayloadBundle/index.ts +0 -4
  137. package/src/model/index.ts +0 -6
  138. package/src/multipliers.ts +0 -18
  139. package/src/payloads/AddressPairPayload.ts +0 -27
  140. package/src/payloads/index.ts +0 -4
  141. package/src/payloads/netBalancesForPayloads.ts +0 -24
  142. package/src/payloads/netSchemasForPayloads.ts +0 -24
  143. package/src/payloads/netTransfersForPayloads.ts +0 -27
  144. package/src/primitives/block/index.ts +0 -2
  145. package/src/primitives/block/range/blockRangeSteps.ts +0 -23
  146. package/src/primitives/block/range/index.ts +0 -1
  147. package/src/primitives/block/rate/blockRate.ts +0 -77
  148. package/src/primitives/block/rate/index.ts +0 -4
  149. package/src/primitives/block/rate/stepRate.ts +0 -37
  150. package/src/primitives/block/rate/timeHelpers.ts +0 -61
  151. package/src/primitives/block/rate/timeRate.ts +0 -121
  152. package/src/primitives/chain/getWindowedChain.ts +0 -50
  153. package/src/primitives/chain/index.ts +0 -3
  154. package/src/primitives/chain/step/chainStepRewardAddress.ts +0 -30
  155. package/src/primitives/chain/step/index.ts +0 -4
  156. package/src/primitives/chain/step/stepRewardBlock.ts +0 -13
  157. package/src/primitives/chain/step/stepRewardTotal.ts +0 -46
  158. package/src/primitives/chain/step/stepsRewardTotal.ts +0 -37
  159. package/src/primitives/chain/time/externalBlockNumberFromXL1BlockNumber.ts +0 -32
  160. package/src/primitives/chain/time/externalBlockRangeFromStep.ts +0 -21
  161. package/src/primitives/chain/time/externalBlockRangeFromXL1BlockRange.ts +0 -17
  162. package/src/primitives/chain/time/index.ts +0 -3
  163. package/src/primitives/datalake/addDataLakePayloads.ts +0 -18
  164. package/src/primitives/datalake/addDataLakePayloadsToPayloads.ts +0 -24
  165. package/src/primitives/datalake/index.ts +0 -2
  166. package/src/primitives/index.ts +0 -13
  167. package/src/primitives/mapToMapType.ts +0 -35
  168. package/src/primitives/payload/index.ts +0 -1
  169. package/src/primitives/payload/mergeTransfers.ts +0 -16
  170. package/src/primitives/readPayloadMapFromStore.ts +0 -58
  171. package/src/primitives/rewardFromBlockNumber.ts +0 -19
  172. package/src/primitives/rewards/index.ts +0 -1
  173. package/src/primitives/rewards/networkStakeStepRewardPositionWeight.ts +0 -26
  174. package/src/primitives/stake/activeStakeAtTimeByAddress.ts +0 -27
  175. package/src/primitives/stake/activeStakeAtTimeByPosition.ts +0 -25
  176. package/src/primitives/stake/allStakersForRange.ts +0 -32
  177. package/src/primitives/stake/allStakersForStep.ts +0 -24
  178. package/src/primitives/stake/index.ts +0 -6
  179. package/src/primitives/stake/mergedAddRemoveStakeEventsByPosition.ts +0 -15
  180. package/src/primitives/stake/mergedAddRemoveStakeEventsByStaker.ts +0 -17
  181. package/src/primitives/stake/weightedStakeForRangeByPosition.ts +0 -69
  182. package/src/primitives/state/findMostRecentBlock.ts +0 -44
  183. package/src/primitives/state/hydratedBlockByNumber.ts +0 -25
  184. package/src/primitives/state/index.ts +0 -2
  185. package/src/primitives/step/completedStepRewardAddress.ts +0 -10
  186. package/src/primitives/step/derivedReceiveAddress.ts +0 -9
  187. package/src/primitives/step/index.ts +0 -4
  188. package/src/primitives/step/stepBlockRange.ts +0 -9
  189. package/src/primitives/step/stepTransferIndex.ts +0 -19
  190. package/src/primitives/transaction/elevatedPayloads.ts +0 -24
  191. package/src/primitives/transaction/index.ts +0 -1
  192. package/src/primitives/uncle/findBestUncle.ts +0 -9
  193. package/src/primitives/uncle/findUncles.ts +0 -75
  194. package/src/primitives/uncle/index.ts +0 -3
  195. package/src/primitives/uncle/scoreUncle.ts +0 -7
  196. package/src/services/AccountTransfersService.ts +0 -13
  197. package/src/services/BlockProducerService.ts +0 -11
  198. package/src/services/Chain/BaseChainService.ts +0 -4
  199. package/src/services/Chain/ChainHeadService.ts +0 -8
  200. package/src/services/Chain/ChainService.ts +0 -6
  201. package/src/services/Chain/index.ts +0 -3
  202. package/src/services/Election.ts +0 -14
  203. package/src/services/NetworkStakeService.ts +0 -4
  204. package/src/services/Params.ts +0 -13
  205. package/src/services/PendingTransactionsService.ts +0 -7
  206. package/src/services/SchemasService.ts +0 -11
  207. package/src/services/StakeIntentService/ChainIndexingServiceStateSchema.ts +0 -50
  208. package/src/services/StakeIntentService/StakeIntentService.ts +0 -35
  209. package/src/services/StakeIntentService/index.ts +0 -2
  210. package/src/services/index.ts +0 -8
  211. package/src/simple/StakeEventsViewer/SimpleStakeEventsViewer.ts +0 -93
  212. package/src/simple/StakeEventsViewer/index.ts +0 -1
  213. package/src/simple/StakeTotalsViewer/SimpleStakeTotalsViewer.ts +0 -116
  214. package/src/simple/StakeTotalsViewer/index.ts +0 -1
  215. package/src/simple/StakeViewer/SimpleStakeViewer.ts +0 -164
  216. package/src/simple/StakeViewer/index.ts +0 -1
  217. package/src/simple/TransactionViewer/SimpleTransactionViewer.ts +0 -100
  218. package/src/simple/TransactionViewer/index.ts +0 -1
  219. package/src/simple/accountBalance/SimpleAccountBalanceViewer.ts +0 -271
  220. package/src/simple/accountBalance/index.ts +0 -1
  221. package/src/simple/block/SimpleBlockViewer.ts +0 -231
  222. package/src/simple/block/index.ts +0 -1
  223. package/src/simple/blockInvalidation/SimpleBlockInvalidationViewer.ts +0 -197
  224. package/src/simple/blockInvalidation/index.ts +0 -1
  225. package/src/simple/blockReward/SimpleBlockRewardViewer.ts +0 -27
  226. package/src/simple/blockReward/index.ts +0 -1
  227. package/src/simple/blockValidation/SimpleBlockValidationViewer.ts +0 -194
  228. package/src/simple/blockValidation/index.ts +0 -1
  229. package/src/simple/chainContractViewer/SimpleChainContractViewer.ts +0 -92
  230. package/src/simple/chainContractViewer/index.ts +0 -1
  231. package/src/simple/client/SimpleXyoClient.ts +0 -14
  232. package/src/simple/client/index.ts +0 -1
  233. package/src/simple/datalake/AbstractRestDataLake.ts +0 -70
  234. package/src/simple/datalake/AbstractSimpleDataLake.ts +0 -62
  235. package/src/simple/datalake/RestDataLakeRunner.ts +0 -54
  236. package/src/simple/datalake/RestDataLakeViewer.ts +0 -22
  237. package/src/simple/datalake/SimpleDataLakeRunner.ts +0 -44
  238. package/src/simple/datalake/SimpleDataLakeViewer.ts +0 -24
  239. package/src/simple/datalake/index.ts +0 -4
  240. package/src/simple/finalization/SimpleFinalizationRunner.ts +0 -45
  241. package/src/simple/finalization/SimpleFinalizationViewer.ts +0 -123
  242. package/src/simple/finalization/index.ts +0 -2
  243. package/src/simple/gateway/SimpleXyoGateway.ts +0 -30
  244. package/src/simple/gateway/SimpleXyoGatewayRunner.ts +0 -137
  245. package/src/simple/gateway/index.ts +0 -2
  246. package/src/simple/index.ts +0 -22
  247. package/src/simple/mempool/SimpleMempoolRunner.ts +0 -390
  248. package/src/simple/mempool/SimpleMempoolViewer.ts +0 -215
  249. package/src/simple/mempool/index.ts +0 -2
  250. package/src/simple/network/SimpleXyoNetwork.ts +0 -48
  251. package/src/simple/network/index.ts +0 -1
  252. package/src/simple/network/lib/FailedNetworkStatusPayloads.ts +0 -16
  253. package/src/simple/network/lib/StatusNetworks.ts +0 -32
  254. package/src/simple/network/lib/index.ts +0 -2
  255. package/src/simple/permissions/SimpleXyoPermissions.ts +0 -82
  256. package/src/simple/permissions/index.ts +0 -2
  257. package/src/simple/permissions/store/MemoryPermissions.ts +0 -32
  258. package/src/simple/permissions/store/PermissionsStore.ts +0 -17
  259. package/src/simple/permissions/store/index.ts +0 -2
  260. package/src/simple/runner/SimpleXyoRunner.ts +0 -41
  261. package/src/simple/runner/index.ts +0 -1
  262. package/src/simple/signer/SimpleXyoSigner.ts +0 -78
  263. package/src/simple/signer/index.ts +0 -1
  264. package/src/simple/timeSync2/SimpleTimeSyncViewer.ts +0 -132
  265. package/src/simple/timeSync2/index.ts +0 -1
  266. package/src/simple/transactionInvalidation/SimpleTransactionInvalidationViewer.ts +0 -197
  267. package/src/simple/transactionInvalidation/index.ts +0 -1
  268. package/src/simple/transactionValidation/SimpleTransactionValidationViewer.ts +0 -173
  269. package/src/simple/transactionValidation/index.ts +0 -1
  270. package/src/simple/windowedBlock/SimpleWindowedBlockViewer.ts +0 -207
  271. package/src/simple/windowedBlock/index.ts +0 -1
  272. package/src/status/RuntimeStatusMonitor.ts +0 -120
  273. package/src/status/ServiceStatus.ts +0 -21
  274. package/src/status/index.ts +0 -2
  275. package/src/summary/index.ts +0 -2
  276. package/src/summary/model/BalancesStepSummary.ts +0 -35
  277. package/src/summary/model/SchemasStepSummary.ts +0 -33
  278. package/src/summary/model/StepSummary.ts +0 -20
  279. package/src/summary/model/TransfersSummary.ts +0 -36
  280. package/src/summary/model/index.ts +0 -4
  281. package/src/summary/primitives/balances/balancesStepSummaryFromRange.ts +0 -94
  282. package/src/summary/primitives/balances/balancesSummary.ts +0 -48
  283. package/src/summary/primitives/balances/index.ts +0 -2
  284. package/src/summary/primitives/index.ts +0 -3
  285. package/src/summary/primitives/schemas/index.ts +0 -2
  286. package/src/summary/primitives/schemas/schemasStepSummaryFromRange.ts +0 -86
  287. package/src/summary/primitives/schemas/schemasSummary.ts +0 -44
  288. package/src/summary/primitives/transfers/index.ts +0 -2
  289. package/src/summary/primitives/transfers/transfersStepSummaryFromRange.ts +0 -109
  290. package/src/summary/primitives/transfers/transfersSummary.ts +0 -52
  291. package/src/test/BuildBlockOptions.ts +0 -81
  292. package/src/test/buildBlock.ts +0 -105
  293. package/src/test/buildGenesisBlock.ts +0 -29
  294. package/src/test/buildNextBlock.ts +0 -37
  295. package/src/test/buildRandomChain.ts +0 -92
  296. package/src/test/buildRandomGenesisBlock.ts +0 -47
  297. package/src/test/createGenesisBlock.ts +0 -41
  298. package/src/test/createProducerChainStakeIntentTransaction.ts +0 -48
  299. package/src/test/getSimpleBlockViewerLocator.ts +0 -41
  300. package/src/test/getTestProviderContext.ts +0 -8
  301. package/src/test/index.ts +0 -2
  302. package/src/time/index.ts +0 -1
  303. package/src/time/primitives/index.ts +0 -1
  304. package/src/time/primitives/xl1BlockNumberToEthBlockNumber.ts +0 -13
  305. package/src/transaction/TransactionBuilder.ts +0 -164
  306. package/src/transaction/buildRandomTransaction.ts +0 -38
  307. package/src/transaction/buildTransaction.ts +0 -68
  308. package/src/transaction/buildUnsignedTransaction.ts +0 -56
  309. package/src/transaction/confirmSubmittedTransaction.ts +0 -42
  310. package/src/transaction/hydrateTransaction.ts +0 -117
  311. package/src/transaction/index.ts +0 -9
  312. package/src/transaction/primitives/index.ts +0 -4
  313. package/src/transaction/primitives/transactionBlockByteCount.ts +0 -10
  314. package/src/transaction/primitives/transactionElevatedPayloads.ts +0 -18
  315. package/src/transaction/primitives/transactionOperations.ts +0 -13
  316. package/src/transaction/primitives/transactionRequiredGas.ts +0 -22
  317. package/src/transaction/script.ts +0 -48
  318. package/src/transaction/signTransaction.ts +0 -32
  319. package/src/utils/HydratedCache.ts +0 -39
  320. package/src/utils/index.ts +0 -2
  321. package/src/utils/isZodError.ts +0 -11
  322. package/src/validation/index.ts +0 -2
  323. package/src/validation/lib/getUrl.ts +0 -7
  324. package/src/validation/lib/index.ts +0 -2
  325. package/src/validation/lib/isLocalhost.ts +0 -9
  326. package/src/validation/schema/Address.ts +0 -2
  327. package/src/validation/schema/Mnemonic.ts +0 -21
  328. package/src/validation/schema/index.ts +0 -2
  329. package/src/wallet/generateXyoBaseWalletFromPhrase.ts +0 -13
  330. package/src/wallet/index.ts +0 -2
  331. package/src/wallet/paths.ts +0 -17
@@ -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'
@@ -1,4 +0,0 @@
1
- /** DeepPartial type. */
2
- export type DeepPartial<T> = {
3
- [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P]
4
- }
package/src/config/Evm.ts DELETED
@@ -1,38 +0,0 @@
1
- import { globalRegistry, z } from 'zod'
2
-
3
- /** EvmInfuraConfigZod constant. */
4
- export const EvmInfuraConfigZod = z.object({
5
- projectId: z.string().optional().register(globalRegistry, {
6
- description: 'Infura project ID',
7
- title: 'evm.infura.projectId',
8
- type: 'string',
9
- }),
10
- projectSecret: z.string().optional().register(globalRegistry, {
11
- description: 'Infura project secret',
12
- title: 'evm.infura.projectSecret',
13
- type: 'string',
14
- }),
15
- })
16
-
17
- /** EvmJsonRpcConfigZod constant. */
18
- export const EvmJsonRpcConfigZod = z.object({
19
- url: z.url().optional().register(globalRegistry, {
20
- description: 'JSON-RPC URL',
21
- title: 'evm.jsonRpc.url',
22
- type: 'string',
23
- }),
24
- })
25
-
26
- /** EvmConfigZod constant. */
27
- export const EvmConfigZod = z.object({
28
- chainId: z.string().optional().register(globalRegistry, {
29
- description: 'EVM chain ID',
30
- title: 'evm.chainId',
31
- type: 'string',
32
- }),
33
- infura: EvmInfuraConfigZod.optional().describe('Infura Provider configuration'),
34
- jsonRpc: EvmJsonRpcConfigZod.optional().describe('JSON-RPC Provider configuration'),
35
- })
36
-
37
- /** EvmConfig type. */
38
- export type EvmConfig = z.infer<typeof EvmConfigZod>
@@ -1,32 +0,0 @@
1
- import {
2
- zodAsFactory, zodIsFactory, zodToFactory,
3
- } from '@xylabs/sdk-js'
4
- import { globalRegistry, z } from 'zod'
5
-
6
- import { ActorConfigZod } from './Actor.ts'
7
-
8
- /** HostActorConfigZod constant. */
9
- export const HostActorConfigZod = ActorConfigZod.extend({
10
- host: z.string().default('localhost').register(globalRegistry, {
11
- default: 'localhost',
12
- description: 'Host for the Actor',
13
- title: 'host',
14
- type: 'string',
15
- }),
16
- port: z.coerce.number().default(8080).register(globalRegistry, {
17
- default: 8080,
18
- description: 'Port for the Actor',
19
- title: 'port',
20
- type: 'number',
21
- }),
22
- })
23
-
24
- /** HostActorConfig type. */
25
- export type HostActorConfig = z.infer<typeof HostActorConfigZod>
26
-
27
- /** Type guard that checks if a value is a valid HostActorConfig. */
28
- export const isHostActorConfig = zodIsFactory(HostActorConfigZod)
29
- /** Converts a value to HostActorConfig, throwing if invalid. */
30
- export const asHostActorConfig = zodAsFactory(HostActorConfigZod, 'asHostActorConfig')
31
- /** toHostActorConfig constant. */
32
- export const toHostActorConfig = zodToFactory(HostActorConfigZod, 'toHostActorConfig')
package/src/config/Log.ts DELETED
@@ -1,25 +0,0 @@
1
- import type { LogLevelKey } from '@xylabs/sdk-js'
2
- import { LogLevel } from '@xylabs/sdk-js'
3
- import { globalRegistry, z } from 'zod'
4
-
5
- const LogLevelNames = Object.keys(LogLevel) as [LogLevelKey]
6
-
7
- /** LogConfigZod constant. */
8
- export const LogConfigZod = z.object({
9
- logLevel: z.enum(LogLevelNames).default('info').register(globalRegistry, {
10
- choices: LogLevelNames,
11
- default: 'info',
12
- description: 'Desired process verbosity',
13
- title: 'logLevel',
14
- type: 'string',
15
- }),
16
- silent: z.boolean().default(false).register(globalRegistry, {
17
- default: false,
18
- description: 'Whether to run in silent mode',
19
- title: 'silent',
20
- type: 'boolean',
21
- }),
22
- })
23
-
24
- /** LogConfig type. */
25
- export type LogConfig = z.infer<typeof LogConfigZod>
@@ -1,20 +0,0 @@
1
- import {
2
- zodAsFactory, zodIsFactory, zodToFactory,
3
- } from '@xylabs/sdk-js'
4
- import { z } from 'zod'
5
-
6
- /** ProviderConfigZod constant. */
7
- export const ProviderConfigZod = z.object({
8
- moniker: z.string(),
9
- labels: z.array(z.string()).optional(),
10
- }).describe('Configuration for a Provider')
11
-
12
- /** ProviderConfig type. */
13
- export type ProviderConfig = z.infer<typeof ProviderConfigZod>
14
-
15
- /** Type guard that checks if a value is a valid ProviderConfig. */
16
- export const isProviderConfig = zodIsFactory(ProviderConfigZod)
17
- /** Converts a value to ProviderConfig, throwing if invalid. */
18
- export const asProviderConfig = zodAsFactory(ProviderConfigZod, 'asProviderConfig')
19
- /** toProviderConfig constant. */
20
- export const toProviderConfig = zodToFactory(ProviderConfigZod, 'toProviderConfig')
@@ -1,9 +0,0 @@
1
- import z from 'zod'
2
-
3
- import { ProviderConfigZod } from './Provider.ts'
4
-
5
- /** ProvidersConfigZod constant. */
6
- export const ProvidersConfigZod = z.array(ProviderConfigZod.loose()).describe('Configuration for providers').default([])
7
-
8
- /** ProvidersConfig type. */
9
- export type ProvidersConfig = z.infer<typeof ProvidersConfigZod>
@@ -1,59 +0,0 @@
1
- import { globalRegistry, z } from 'zod'
2
-
3
- /** RpcRemoteConfigBaseZod constant. */
4
- export const RpcRemoteConfigBaseZod = z.object({
5
- protocol: z.string('http').register(globalRegistry, {
6
- description: 'Protocol for the RPC connection',
7
- type: 'string',
8
- }),
9
- }).describe('Base configuration for the remote RPC')
10
-
11
- /** RpcRemoteConfigBase type. */
12
- export type RpcRemoteConfigBase = z.infer<typeof RpcRemoteConfigBaseZod>
13
-
14
- /** HttpRpcRemoteConfigZod constant. */
15
- export const HttpRpcRemoteConfigZod = RpcRemoteConfigBaseZod.extend({
16
- protocol: z.string('http').register(globalRegistry, {
17
- description: 'Protocol for the RPC connection',
18
- type: 'string',
19
- }).default('http'),
20
- url: z.string().register(globalRegistry, {
21
- description: 'URL for the Chain RPC API',
22
- type: 'string',
23
- }),
24
- }).describe('Configuration for the remote RPC using Http')
25
-
26
- /** HttpRpcRemoteConfig type. */
27
- export type HttpRpcRemoteConfig = z.infer<typeof HttpRpcRemoteConfigZod>
28
-
29
- /** PostMessageRpcRemoteConfigZod constant. */
30
- export const PostMessageRpcRemoteConfigZod = RpcRemoteConfigBaseZod.extend({
31
- protocol: z.string().register(globalRegistry, {
32
- description: 'Protocol for the RPC connection',
33
- type: 'string',
34
- }).default('postMessage'),
35
- networkId: z.string().register(globalRegistry, {
36
- description: 'Network ID to use for the postMessage RPC connection',
37
- type: 'string',
38
- }),
39
- sessionId: z.string().register(globalRegistry, {
40
- description: 'Session ID to use for the postMessage RPC connection',
41
- type: 'string',
42
- }),
43
- }).describe('Configuration for the remote RPC using postMessage')
44
-
45
- /** PostMessageRpcRemoteConfig type. */
46
- export type PostMessageRpcRemoteConfig = z.infer<typeof PostMessageRpcRemoteConfigZod>
47
-
48
- /** RpcRemoteConfigZod constant. */
49
- export const RpcRemoteConfigZod = z.union([HttpRpcRemoteConfigZod, PostMessageRpcRemoteConfigZod])
50
- .describe('Configuration for a remote RPC connection, either Http or postMessage')
51
-
52
- /** RpcRemoteConfig type. */
53
- export type RpcRemoteConfig = z.infer<typeof RpcRemoteConfigZod>
54
-
55
- /** RemoteConfigZod constant. */
56
- export const RemoteConfigZod = z.object({ rpc: RpcRemoteConfigZod.optional() }).describe('Configuration for remote connections, including RPC')
57
-
58
- /** RemoteConfig type. */
59
- export type RemoteConfig = z.infer<typeof RemoteConfigZod>
@@ -1,49 +0,0 @@
1
- import { globalRegistry, z } from 'zod'
2
-
3
- /** DefaultMetricsScrapePorts constant. */
4
- export const DefaultMetricsScrapePorts = {
5
- api: 9465,
6
- bridge: 9468,
7
- mempool: 9466,
8
- producer: 9464,
9
- rewardRedemptionApi: 9467,
10
- }
11
-
12
- /** MetricsScrapeConfigZod constant. */
13
- export const MetricsScrapeConfigZod = z.object({
14
- path: z.string().default('/metrics').register(globalRegistry, {
15
- default: '/metrics',
16
- description: 'Path for the metrics scrape endpoint',
17
- title: 'telemetry.metrics.scrape.path',
18
- type: 'string',
19
- }),
20
- port: z.coerce.number().int().positive().optional().register(globalRegistry, {
21
- description: 'Port for the metrics scrape endpoint',
22
- title: 'telemetry.metrics.scrape.port',
23
- type: 'number',
24
- }),
25
- }).describe('Metrics scrape configuration')
26
-
27
- /** MetricsConfigZod constant. */
28
- export const MetricsConfigZod = z.object({ scrape: MetricsScrapeConfigZod }).describe('Metrics configuration options')
29
-
30
- /** OpenTelemetryConfigZod constant. */
31
- export const OpenTelemetryConfigZod = z.object({
32
- // OpenTelemetry options
33
- otlpEndpoint: z.url().optional().register(globalRegistry, {
34
- description: 'OTLP endpoint for exporting telemetry data',
35
- title: 'telemetry.otel.otlpEndpoint',
36
- type: 'string',
37
- }),
38
- })
39
-
40
- /** TelemetryConfigZod constant. */
41
- export const TelemetryConfigZod = z.object({
42
- // Metrics configuration
43
- metrics: MetricsConfigZod.optional().describe('Metrics configuration'),
44
- // OpenTelemetry configuration
45
- otel: OpenTelemetryConfigZod.optional().describe('OpenTelemetry configuration'),
46
- }).describe('Telemetry configuration options')
47
-
48
- /** TelemetryConfig type. */
49
- export type TelemetryConfig = z.infer<typeof TelemetryConfigZod>
@@ -1,46 +0,0 @@
1
- import { z } from 'zod'
2
-
3
- const DescriptionSchema = z.string()
4
- const TitleSchema = z.string()
5
-
6
- /** Schema identifier for JSONMeta payloads. */
7
- export const JSONSchemaMetaSchema = z
8
- .object({
9
- id: z.string().optional(),
10
- title: TitleSchema.optional(),
11
- description: DescriptionSchema.optional(),
12
- deprecated: z.boolean().optional(),
13
- })
14
- .catchall(z.unknown()) // allow arbitrary extra keys
15
-
16
- /** Schema identifier for GlobalMeta payloads. */
17
- export const GlobalMetaSchema = JSONSchemaMetaSchema.extend({})
18
-
19
- const ChoicesSchema = z
20
- .array(z.union([z.string(), z.number(), z.literal(true), z.undefined()]))
21
- .readonly()
22
-
23
- /** Schema identifier for UsageMeta payloads. */
24
- export const UsageMetaSchema = GlobalMetaSchema.extend({
25
- choices: ChoicesSchema.optional(),
26
- default: z.unknown().optional(),
27
- description: DescriptionSchema,
28
- group: z.string().optional(),
29
- hidden: z.boolean().optional(),
30
- title: TitleSchema,
31
- type: z.union([
32
- z.literal('array'),
33
- z.literal('count'),
34
- z.literal('boolean'),
35
- z.literal('number'),
36
- z.literal('string'),
37
- ]),
38
- })
39
-
40
- /** UsageMeta type. */
41
- export type UsageMeta = z.infer<typeof UsageMetaSchema>
42
-
43
- /** Type guard that checks if a value is a valid UsageMeta. */
44
- export function isUsageMeta(v: unknown): v is UsageMeta {
45
- return UsageMetaSchema.safeParse(v).success
46
- }