@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,50 +0,0 @@
1
- import type { Hash, JsonValue } from '@xylabs/sdk-js'
2
- import { AsObjectFactory } from '@xylabs/sdk-js'
3
- import type { Payload, WithStorageMeta } from '@xyo-network/sdk-js'
4
- import {
5
- asSchema, isPayloadOfSchemaType, isStorageMeta,
6
- } from '@xyo-network/sdk-js'
7
-
8
- /** Fields stored by a chain indexing service to track its indexing progress and state */
9
- export interface ChainIndexingServiceStateFields<T extends JsonValue = JsonValue> {
10
- /**
11
- * The hash of the last block that this service has indexing
12
- */
13
- endBlockHash: Hash
14
- /**
15
- * The hash of the block that the service started indexing. If undefined, the service is
16
- * assumed to have started indexing from the genesis block
17
- */
18
- startBlockHash?: Hash
19
- /**
20
- * The indexed state for the range
21
- */
22
- state: T
23
- }
24
- /** Schema identifier for chain indexing service state payloads */
25
- export const ChainIndexingServiceStateSchema = asSchema('network.xyo.chain.indexing.service.state', true)
26
- /** Schema type for ChainIndexingServiceState payloads. */
27
- export type ChainIndexingServiceStateSchema = typeof ChainIndexingServiceStateSchema
28
-
29
- /**
30
- * The result of a ChainIndexingServiceState
31
- */
32
- export type ChainIndexingServiceState<T extends JsonValue = JsonValue> = Payload<ChainIndexingServiceStateFields<T>, ChainIndexingServiceStateSchema>
33
-
34
- /**
35
- * Identity functions for determining if an object is an ChainIndexingServiceState
36
- */
37
- export const isChainIndexingServiceState = <T extends JsonValue = JsonValue>(payload?: unknown): payload is ChainIndexingServiceState<T> => {
38
- return isPayloadOfSchemaType<ChainIndexingServiceState<T>>(ChainIndexingServiceStateSchema)(payload)
39
- }
40
- /** Type assertion factory for ChainIndexingServiceState payloads */
41
- export const asChainIndexingServiceState = AsObjectFactory.create<ChainIndexingServiceState<JsonValue>>(isChainIndexingServiceState)
42
-
43
- /** Type guard for ChainIndexingServiceState with storage metadata */
44
- export const isChainIndexingServiceStateWithStorageMeta
45
- = <T extends JsonValue = JsonValue>(value: unknown): value is WithStorageMeta<ChainIndexingServiceState<T>> =>
46
- isChainIndexingServiceState<T>(value) && isStorageMeta(value)
47
-
48
- /** Type assertion factory for ChainIndexingServiceState with storage metadata */
49
- export const asChainIndexingServiceStateWithStorageMeta
50
- = AsObjectFactory.create<WithStorageMeta<ChainIndexingServiceState>>(isChainIndexingServiceStateWithStorageMeta)
@@ -1,35 +0,0 @@
1
- import type { Address } from '@xylabs/sdk-js'
2
- import type { Intent } from '@xyo-network/xl1-protocol-lib'
3
-
4
- /** Service for managing and querying stake intent declarations on the chain */
5
- export interface StakeIntentService {
6
-
7
- /**
8
- * Gets the declared ranges for an address based on historical on-chain data
9
- * @param address The address to get the declared ranges for
10
- * @param intent The declared intent to filter for
11
- */
12
- getDeclaredCandidateRanges(address: Address, intent: Intent): Promise<Readonly<Readonly<[number, number]>[]>>
13
-
14
- /**
15
- * Gets the declared candidates for a block based on historical on-chain data
16
- * @param block The block number to get the declared candidates for
17
- * @param intent The declared intent to filter for
18
- */
19
- getDeclaredCandidatesForBlock(block: number, intent: Intent): Promise<Address[]>
20
-
21
- /**
22
- * Gets the required minimum stake for a given intent
23
- * @param intent The declared intent to filter for
24
- * @returns The required minimum stake for the intent
25
- */
26
- getRequiredMinimumStakeForIntent(intent: Intent): bigint
27
-
28
- /**
29
- * Checks if the address is staked for a block for a given intent
30
- * @param block The block number to check
31
- * @param intent The declared intent to filter for
32
- * @param address The address to check
33
- */
34
- isStakedForBlock(block: number, intent: Intent, address: Address): Promise<boolean>
35
- }
@@ -1,2 +0,0 @@
1
- export * from './ChainIndexingServiceStateSchema.ts'
2
- export * from './StakeIntentService.ts'
@@ -1,8 +0,0 @@
1
- export * from './AccountTransfersService.ts'
2
- export * from './BlockProducerService.ts'
3
- export * from './Chain/index.ts'
4
- export * from './Election.ts'
5
- export * from './NetworkStakeService.ts'
6
- export * from './PendingTransactionsService.ts'
7
- export * from './SchemasService.ts'
8
- export * from './StakeIntentService/index.ts'
@@ -1,93 +0,0 @@
1
- import { isDefined } from '@xylabs/sdk-js'
2
- import {
3
- Position, StakeEvent, StakeEventFilter, StakeEventName, StakeEventsViewer, StakeEventsViewerMoniker,
4
- } from '@xyo-network/xl1-protocol-lib'
5
-
6
- import {
7
- AbstractCreatableProvider, creatableProvider, CreatableProviderParams,
8
- } from '../../CreatableProvider/index.ts'
9
-
10
- /** Parameters for SimpleStakeEvents. */
11
- export interface SimpleStakeEventsParams extends CreatableProviderParams {
12
- positions: Position[]
13
- }
14
-
15
- /** SimpleStakeEventsViewer implementation. */
16
- @creatableProvider()
17
- export class SimpleStakeEventsViewer extends AbstractCreatableProvider<SimpleStakeEventsParams> implements StakeEventsViewer {
18
- static readonly defaultMoniker = StakeEventsViewerMoniker
19
- static readonly dependencies = []
20
- static readonly monikers = [StakeEventsViewerMoniker]
21
- moniker = SimpleStakeEventsViewer.defaultMoniker
22
-
23
- protected get positions() {
24
- return this.params.positions
25
- }
26
-
27
- positionCount(range: [number, number | 'latest']): number {
28
- return this.positionsFromRange(range).length
29
- }
30
-
31
- stakeEvents<TName extends StakeEventName>(range: [number, number | 'latest'], { name }: StakeEventFilter<TName> = {}): StakeEvent<TName>[] {
32
- const positions = this.positionsFromRange(range)
33
- const events = this.eventsFromPositions(positions)
34
- if (isDefined(name)) {
35
- return events.filter((event): event is StakeEvent<TName> => event.name === name)
36
- }
37
- return events as StakeEvent<TName>[]
38
- }
39
-
40
- protected override async startHandler(): Promise<void> {
41
- await super.startHandler()
42
- }
43
-
44
- private eventsFromPositions(positions: Position[]): StakeEvent<StakeEventName>[] {
45
- const events = positions.map((position) => {
46
- const events: StakeEvent<StakeEventName>[] = [{
47
- name: 'StakeAdded',
48
- time: position.addBlock,
49
- args: {
50
- staker: position.staker,
51
- staked: position.staked,
52
- amount: position.amount,
53
- id: position.id,
54
- },
55
- }]
56
- if (position.removeBlock !== 0) {
57
- events.push({
58
- name: 'StakeRemoved',
59
- time: position.removeBlock,
60
- args: {
61
- staker: position.staker,
62
- staked: position.staked,
63
- amount: position.amount,
64
- id: position.id,
65
- },
66
- })
67
- }
68
- if (position.withdrawBlock !== 0) {
69
- events.push({
70
- name: 'StakeWithdrawn',
71
- time: position.withdrawBlock,
72
- args: {
73
- staker: position.staker,
74
- staked: position.staked,
75
- amount: position.amount,
76
- id: position.id,
77
- },
78
- })
79
- }
80
- return events
81
- })
82
- return events.flat()
83
- }
84
-
85
- private positionsFromRange(range: [number, number | 'latest']): Position[] {
86
- const startBlock = range[0]
87
- const endBlock = range[1] === 'latest' ? Number.MAX_SAFE_INTEGER : range[1]
88
- const filteredPositions = this.positions?.filter((position) => {
89
- return position.addBlock <= endBlock && (position.removeBlock === 0 || position.removeBlock >= startBlock)
90
- }) ?? []
91
- return filteredPositions
92
- }
93
- }
@@ -1 +0,0 @@
1
- export * from './SimpleStakeEventsViewer.ts'
@@ -1,116 +0,0 @@
1
- import { type Address, asAddress } from '@xylabs/sdk-js'
2
- import { assertEx } from '@xylabs/sdk-js'
3
- import {
4
- StakeTotalsViewer, StakeTotalsViewerMoniker,
5
- StakeViewer,
6
- StakeViewerMoniker,
7
- } from '@xyo-network/xl1-protocol-lib'
8
-
9
- import {
10
- AbstractCreatableProvider, creatableProvider, CreatableProviderParams,
11
- } from '../../CreatableProvider/index.ts'
12
-
13
- /** Parameters for SimpleStakeTotalsViewer. */
14
- export interface SimpleStakeTotalsViewerParams extends CreatableProviderParams {
15
-
16
- }
17
-
18
- /** SimpleStakeTotalsViewer implementation. */
19
- @creatableProvider()
20
- export class SimpleStakeTotalsViewer extends AbstractCreatableProvider<SimpleStakeTotalsViewerParams> implements StakeTotalsViewer {
21
- static readonly defaultMoniker = StakeTotalsViewerMoniker
22
- static readonly dependencies = [StakeTotalsViewerMoniker]
23
- static readonly monikers = [StakeTotalsViewerMoniker]
24
- moniker = SimpleStakeTotalsViewer.defaultMoniker
25
-
26
- private _stakeViewer!: StakeViewer
27
-
28
- get stakeViewer() {
29
- return this._stakeViewer
30
- }
31
-
32
- async active(time = Number.MAX_SAFE_INTEGER) {
33
- let active = 0n
34
- const positions = await this.stakeViewer.activeStakes()
35
- for (const position of positions) {
36
- if (position.removeBlock === 0 || position.removeBlock > time) {
37
- active += position.amount
38
- }
39
- }
40
- return active
41
- }
42
-
43
- async activeByStaked(staked: Address, time = Number.MAX_SAFE_INTEGER) {
44
- let active = 0n
45
- const positions = await this.stakeViewer.activeStakes()
46
- for (const position of positions) {
47
- if ((position.removeBlock === 0 || position.removeBlock > time) && asAddress(position.staked) === asAddress(staked)) {
48
- active += position.amount
49
- }
50
- }
51
- return active
52
- }
53
-
54
- async activeByStaker(staker: Address, time = Number.MAX_SAFE_INTEGER) {
55
- let active = 0n
56
- const positions = await this.stakeViewer.activeStakes()
57
- for (const position of positions) {
58
- if ((position.removeBlock === 0 || position.removeBlock > time) && asAddress(position.staker) === asAddress(staker)) {
59
- active += position.amount
60
- }
61
- }
62
- return active
63
- }
64
-
65
- override async createHandler() {
66
- await super.createHandler()
67
- this._stakeViewer = assertEx(
68
- (await this.locateAndCreate<StakeViewer>(StakeViewerMoniker)),
69
- () => 'Failed to create StakeViewer',
70
- )
71
- }
72
-
73
- async pending(time = Number.MAX_SAFE_INTEGER): Promise<bigint> {
74
- let pending = 0n
75
- const positions = await this.stakeViewer.removedStakes()
76
- for (const position of positions) {
77
- if ((position.removeBlock !== 0 && position.removeBlock <= time) && (position.withdrawBlock === 0 || position.withdrawBlock > time)) {
78
- pending += position.amount
79
- }
80
- }
81
- return pending
82
- }
83
-
84
- async pendingByStaker(staker: Address, time = Number.MAX_SAFE_INTEGER) {
85
- let pending = 0n
86
- const positions = await this.stakeViewer.removedStakes()
87
- for (const position of positions) {
88
- if ((position.removeBlock !== 0 && position.removeBlock <= time) && (position.withdrawBlock === 0 || position.withdrawBlock > time) && asAddress(position.staker) === asAddress(staker)) {
89
- pending += position.amount
90
- }
91
- }
92
- return pending
93
- }
94
-
95
- async withdrawn(time = Number.MAX_SAFE_INTEGER): Promise<bigint> {
96
- let withdrawn = 0n
97
- const positions = await this.stakeViewer.withdrawnStakes()
98
- for (const position of positions) {
99
- if (position.withdrawBlock !== 0 && position.withdrawBlock <= time) {
100
- withdrawn += position.amount
101
- }
102
- }
103
- return withdrawn
104
- }
105
-
106
- async withdrawnByStaker(staker: Address, time = Number.MAX_SAFE_INTEGER): Promise<bigint> {
107
- let withdrawn = 0n
108
- const positions = await this.stakeViewer.withdrawnStakes()
109
- for (const position of positions) {
110
- if (position.withdrawBlock !== 0 && position.withdrawBlock <= time && asAddress(position.staker) === asAddress(staker)) {
111
- withdrawn += position.amount
112
- }
113
- }
114
- return withdrawn
115
- }
116
- }
@@ -1 +0,0 @@
1
- export * from './SimpleStakeTotalsViewer.ts'
@@ -1,164 +0,0 @@
1
- import {
2
- type Address, asAddress, Promisable, toAddress,
3
- } from '@xylabs/sdk-js'
4
- import { assertEx } from '@xylabs/sdk-js'
5
- import {
6
- Position, StakeEventsViewer, StakeEventsViewerMoniker, StakeViewer, StakeViewerMoniker,
7
- } from '@xyo-network/xl1-protocol-lib'
8
-
9
- import {
10
- AbstractCreatableProvider, creatableProvider, CreatableProviderParams,
11
- } from '../../CreatableProvider/index.ts'
12
-
13
- /** Parameters for SimpleStakeViewer. */
14
- export interface SimpleStakeViewerParams extends CreatableProviderParams {
15
- chainId?: Address
16
- minWithdrawalBlocks?: number
17
- positions: Position[]
18
- }
19
-
20
- /** SimpleStakeViewer implementation. */
21
- @creatableProvider()
22
- export class SimpleStakeViewer extends AbstractCreatableProvider<SimpleStakeViewerParams> implements StakeViewer {
23
- static readonly defaultMoniker = StakeViewerMoniker
24
- static readonly dependencies = [StakeEventsViewerMoniker]
25
- static readonly monikers = [StakeViewerMoniker]
26
- moniker = SimpleStakeViewer.defaultMoniker
27
-
28
- private _chainStakeEventsViewer: StakeEventsViewer | undefined
29
-
30
- get stakeEvents() {
31
- return assertEx(this._chainStakeEventsViewer, () => 'Stake events viewer not set')
32
- }
33
-
34
- protected get positions() {
35
- return this.params.positions
36
- }
37
-
38
- async active(): Promise<bigint> {
39
- let active = 0n
40
- const positions = await this.activeStakes()
41
- for (const position of positions) {
42
- if (position.removeBlock === 0) {
43
- active += position.amount
44
- }
45
- }
46
- return active
47
- }
48
-
49
- async activeByAddressStaked(staked: Address) {
50
- let active = 0n
51
- const positions = await this.activeStakes()
52
- for (const position of positions) {
53
- if (position.removeBlock === 0 && asAddress(position.staked) === asAddress(staked)) {
54
- active += position.amount
55
- }
56
- }
57
- return active
58
- }
59
-
60
- async activeByStaker(staker: Address): Promise<bigint> {
61
- let active = 0n
62
- const positions = await this.activeStakes()
63
- for (const position of positions) {
64
- if (position.removeBlock === 0 && asAddress(position.staker) === asAddress(staker)) {
65
- active += position.amount
66
- }
67
- }
68
- return active
69
- }
70
-
71
- activeStakes(): Promisable<Position[]> {
72
- return this.positions.filter(s => (s.withdrawBlock === 0) && (s.removeBlock === 0))
73
- }
74
-
75
- override async createHandler() {
76
- await super.createHandler()
77
- this._chainStakeEventsViewer = assertEx(
78
- (await this.locateAndCreate<StakeEventsViewer>(StakeEventsViewerMoniker)),
79
- () => 'Failed to create StakeEventsViewer',
80
- )
81
- }
82
-
83
- minWithdrawalBlocks(): number {
84
- return this.params.minWithdrawalBlocks ?? 10
85
- }
86
-
87
- async pending() {
88
- let pending = 0n
89
- const positions = await this.removedStakes()
90
- for (const position of positions) {
91
- if (position.removeBlock !== 0 && position.withdrawBlock === 0) {
92
- pending += position.amount
93
- }
94
- }
95
- return pending
96
- }
97
-
98
- async pendingByStaker(staker: Address) {
99
- let pending = 0n
100
- const positions = await this.removedStakes()
101
- for (const position of positions) {
102
- if (position.removeBlock !== 0 && position.withdrawBlock === 0 && asAddress(position.staker) === asAddress(staker)) {
103
- pending += position.amount
104
- }
105
- }
106
- return pending
107
- }
108
-
109
- removedStakes(): Promisable<Position[]> {
110
- return this.positions.filter(s => (s.withdrawBlock === 0) && (s.removeBlock !== 0))
111
- }
112
-
113
- rewardsContract(): Address {
114
- return toAddress(toAddress(1n))
115
- }
116
-
117
- stakeById(id: number): Position {
118
- return assertEx(this.positions[id], () => new Error(`Stake with id ${id} not found`))
119
- }
120
-
121
- stakeByStaker(staker: Address, slot: number): Position {
122
- return this.positions.filter(s => asAddress(s.staker) === asAddress(staker))[slot]
123
- }
124
-
125
- stakesByStaked(staked: Address, range: [number, number | undefined] = [0, undefined]): Position[] {
126
- const endBlock = (range[1] ?? Number.MAX_SAFE_INTEGER)
127
- return this.positions.filter(s => asAddress(s.staked) === asAddress(staked) && s.addBlock <= endBlock && s.removeBlock <= endBlock)
128
- }
129
-
130
- stakesByStaker(staker: Address, range: [number, number | undefined] = [0, undefined]): Position[] {
131
- const endBlock = (range[1] ?? Number.MAX_SAFE_INTEGER)
132
- return this.positions.filter(s => asAddress(s.staker) === asAddress(staker) && s.addBlock <= endBlock && s.removeBlock <= endBlock)
133
- }
134
-
135
- stakingTokenAddress(): Address {
136
- return toAddress('0x000000000000000000000000000011')
137
- }
138
-
139
- async withdrawn() {
140
- let withdrawn = 0n
141
- const positions = await this.withdrawnStakes()
142
- for (const position of positions) {
143
- if (position.withdrawBlock !== 0) {
144
- withdrawn += position.amount
145
- }
146
- }
147
- return withdrawn
148
- }
149
-
150
- async withdrawnByStaker(staker: Address) {
151
- let withdrawn = 0n
152
- const positions = await this.withdrawnStakes()
153
- for (const position of positions) {
154
- if (position.withdrawBlock !== 0 && asAddress(position.staker) === asAddress(staker)) {
155
- withdrawn += position.amount
156
- }
157
- }
158
- return withdrawn
159
- }
160
-
161
- withdrawnStakes(): Promisable<Position[]> {
162
- return this.positions.filter(s => (s.withdrawBlock !== 0))
163
- }
164
- }
@@ -1 +0,0 @@
1
- export * from './SimpleStakeViewer.ts'
@@ -1,100 +0,0 @@
1
- import {
2
- assertEx, exists, Hash,
3
- } from '@xylabs/sdk-js'
4
- import { BoundWitnessSchema } from '@xyo-network/sdk-js'
5
- import {
6
- asSignedHydratedTransactionWithHashMeta,
7
- asSignedTransactionBoundWitness,
8
- BlockViewer,
9
- BlockViewerMoniker,
10
- isTransactionBoundWitnessWithHashMeta,
11
- SignedHydratedTransactionWithHashMeta, TransactionViewer, TransactionViewerMoniker,
12
- XL1BlockNumber,
13
- } from '@xyo-network/xl1-protocol-lib'
14
-
15
- import {
16
- AbstractCreatableProvider, creatableProvider, CreatableProviderParams,
17
- } from '../../CreatableProvider/index.ts'
18
-
19
- /** Parameters for SimpleTransactionViewer. */
20
- export interface SimpleTransactionViewerParams extends CreatableProviderParams {
21
-
22
- }
23
-
24
- /** SimpleTransactionViewer implementation. */
25
- @creatableProvider()
26
- export class SimpleTransactionViewer extends AbstractCreatableProvider<SimpleTransactionViewerParams> implements TransactionViewer {
27
- static readonly defaultMoniker = TransactionViewerMoniker
28
- static readonly dependencies = [BlockViewerMoniker]
29
- static readonly monikers = [TransactionViewerMoniker]
30
- moniker = SimpleTransactionViewer.defaultMoniker
31
-
32
- private _blockViewer!: BlockViewer
33
-
34
- protected get blockViewer() {
35
- return this._blockViewer
36
- }
37
-
38
- async byBlockHashAndIndex(blockHash: Hash, transactionIndex: number): Promise<SignedHydratedTransactionWithHashMeta | null> {
39
- return await this.spanAsync('byBlockHashAndIndex', async () => {
40
- assertEx(transactionIndex >= 0, () => 'transactionIndex must be greater than or equal to 0')
41
- try {
42
- const block = await this.blockViewer.blockByHash(blockHash)
43
- if (!block) return null
44
- const blockBoundWitnessIndexes = block[0].payload_schemas.map((schema, index) => schema === BoundWitnessSchema ? index : undefined).filter(exists)
45
- const blockBoundWitnessHashes = new Set(blockBoundWitnessIndexes.map(index => block[0].payload_hashes[index]))
46
- const blockBoundWitnesses = block[1].filter(payload => blockBoundWitnessHashes.has(payload._hash) || blockBoundWitnessHashes.has(payload._dataHash))
47
- const blockTransactionBoundWitnesses = blockBoundWitnesses.filter(isTransactionBoundWitnessWithHashMeta)
48
- const transaction = blockTransactionBoundWitnesses.at(transactionIndex)
49
- if (!transaction) return null
50
- return await this.byHash(transaction._hash)
51
- } catch {
52
- return null
53
- }
54
- }, this.context)
55
- }
56
-
57
- async byBlockNumberAndIndex(blockNumber: XL1BlockNumber, transactionIndex: number): Promise<SignedHydratedTransactionWithHashMeta | null> {
58
- return await this.spanAsync('byBlockNumberAndIndex', async () => {
59
- try {
60
- const block = await this.blockViewer.blockByNumber(blockNumber)
61
- if (!block) return null
62
- return await this.byBlockHashAndIndex(block[0]._hash, transactionIndex)
63
- } catch {
64
- return null
65
- }
66
- }, this.context)
67
- }
68
-
69
- async byHash(transactionHash: Hash): Promise<SignedHydratedTransactionWithHashMeta | null> {
70
- return await this.spanAsync('byHash', async () => {
71
- try {
72
- const transaction = asSignedTransactionBoundWitness(await this.blockViewer.payloadByHash(transactionHash))
73
- if (transaction) {
74
- const payloads = await this.blockViewer.payloadsByHash(transaction.payload_hashes)
75
- return asSignedHydratedTransactionWithHashMeta([transaction, payloads]) ?? null
76
- }
77
- return null
78
- } catch {
79
- return null
80
- }
81
- }, this.context)
82
- }
83
-
84
- override async createHandler(): Promise<void> {
85
- await super.createHandler()
86
- this._blockViewer = await this.locator.getInstance<BlockViewer>(BlockViewerMoniker)
87
- }
88
-
89
- async transactionByBlockHashAndIndex(blockHash: Hash, transactionIndex: number = 0): Promise<SignedHydratedTransactionWithHashMeta | null> {
90
- return await this.byBlockHashAndIndex(blockHash, transactionIndex)
91
- }
92
-
93
- async transactionByBlockNumberAndIndex(blockNumber: XL1BlockNumber, transactionIndex: number = 0): Promise<SignedHydratedTransactionWithHashMeta | null> {
94
- return await this.byBlockNumberAndIndex(blockNumber, transactionIndex)
95
- }
96
-
97
- async transactionByHash(transactionHash: Hash): Promise<SignedHydratedTransactionWithHashMeta | null> {
98
- return await this.byHash(transactionHash)
99
- }
100
- }
@@ -1 +0,0 @@
1
- export * from './SimpleTransactionViewer.ts'