@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,215 +0,0 @@
1
- import {
2
- exists, isDefined, isHash,
3
- } from '@xylabs/sdk-js'
4
- import type {
5
- ArchivistInstance,
6
- HashMeta,
7
- PayloadBundle, Sequence,
8
- } from '@xyo-network/sdk-js'
9
- import { isHashMeta, isPayloadBundle } from '@xyo-network/sdk-js'
10
- import {
11
- type HydratedTransactionWithHashMeta, type MempoolViewer, MempoolViewerMoniker,
12
- PendingTransactionsOptions,
13
- type SignedHydratedBlockWithHashMeta, type SignedHydratedTransactionWithHashMeta,
14
- WindowedBlockViewer,
15
- WindowedBlockViewerMoniker,
16
- } from '@xyo-network/xl1-protocol-lib'
17
-
18
- import {
19
- AbstractCreatableProvider, creatableProvider, CreatableProviderParams,
20
- } from '../../CreatableProvider/index.ts'
21
- import { bundledPayloadToHydratedBlock, bundledPayloadToHydratedTransaction } from '../../model/index.ts'
22
-
23
- type PayloadBundleWithHashMeta = PayloadBundle & HashMeta
24
-
25
- type HydratedTxWithBundle = {
26
- bundle: PayloadBundleWithHashMeta
27
- tx: SignedHydratedTransactionWithHashMeta
28
- }
29
-
30
- /** Default maximum fraction of mempool transactions to return. */
31
- const DEFAULT_MEMPOOL_SELECTION_RATIO = 0.66
32
-
33
- /** Parameters for SimpleMempoolViewer. */
34
- export interface SimpleMempoolViewerParams extends CreatableProviderParams {
35
- /** External mempool viewers (reserved for future use). */
36
- externalMempools?: MempoolViewer[]
37
- /** Maximum fraction (0–1) of mempool inclusion candidates to return. Defaults to 0.66. */
38
- mempoolSelectionRatio?: number
39
- pendingBlocksArchivist: ArchivistInstance
40
- pendingTransactionsArchivist: ArchivistInstance
41
- }
42
-
43
- /** SimpleMempoolViewer implementation. */
44
- @creatableProvider()
45
- export class SimpleMempoolViewer extends AbstractCreatableProvider<SimpleMempoolViewerParams> implements MempoolViewer {
46
- static readonly defaultMoniker = MempoolViewerMoniker
47
- static readonly dependencies = [WindowedBlockViewerMoniker]
48
- static readonly monikers = [MempoolViewerMoniker]
49
- moniker = SimpleMempoolViewer.defaultMoniker
50
-
51
- private _windowedBlockViewer?: WindowedBlockViewer
52
-
53
- protected get pendingBlocksArchivist() {
54
- return this.params.pendingBlocksArchivist
55
- }
56
-
57
- protected get pendingTransactionsArchivist() {
58
- return this.params.pendingTransactionsArchivist
59
- }
60
-
61
- protected get windowedBlockViewer() {
62
- return this._windowedBlockViewer!
63
- }
64
-
65
- override async createHandler() {
66
- await super.createHandler()
67
- this._windowedBlockViewer = await this.locator.getInstance<WindowedBlockViewer>(WindowedBlockViewerMoniker)
68
- }
69
-
70
- async pendingBlocks({ cursor: providedCursor }: PendingTransactionsOptions = {}): Promise<SignedHydratedBlockWithHashMeta[]> {
71
- let cursor: Sequence | undefined = undefined
72
- if (isHash(providedCursor)) {
73
- const [p] = await this.pendingBlocksArchivist.get([providedCursor])
74
- if (isDefined(p)) {
75
- cursor = p._sequence
76
- }
77
- }
78
- const bundles = await this.pendingBlocksArchivist.next({
79
- order: 'desc', limit: 100, cursor,
80
- })
81
- const filteredBundles = bundles.filter(isPayloadBundle).filter(isHashMeta)
82
- return (await Promise.all(filteredBundles.map(async bundle => await bundledPayloadToHydratedBlock(bundle)))).filter(exists)
83
- }
84
-
85
- async pendingTransactions({
86
- cursor: providedCursor,
87
- limit = 100,
88
- }: PendingTransactionsOptions = {}): Promise<SignedHydratedTransactionWithHashMeta[]> {
89
- let cursor: Sequence | undefined = undefined
90
- if (isHash(providedCursor)) {
91
- const [p] = await this.pendingTransactionsArchivist.get([providedCursor])
92
- if (isDefined(p)) {
93
- cursor = p._sequence
94
- }
95
- }
96
- this.logger?.info(`Fetching pending transactions from cursor: ${cursor}`)
97
- const bundles = (await this.pendingTransactionsArchivist.next({
98
- order: 'asc', limit: limit * 5, cursor,
99
- }))
100
-
101
- this.logger?.info(`Fetched pending transactions: ${bundles.length} bundles`)
102
-
103
- const filteredBundles: PayloadBundleWithHashMeta[] = bundles.filter(isPayloadBundle).filter(isHashMeta)
104
- // this.logger?.info(`Filtered pending transactions: ${JSON.stringify(filteredBundles, null, 2)} filteredBundles`)
105
-
106
- const hydratedWithBundle: HydratedTxWithBundle[] = (await Promise.all(
107
- filteredBundles.map(async (bundle) => {
108
- const tx = await bundledPayloadToHydratedTransaction(bundle)
109
- return isDefined(tx) ? { bundle, tx } : undefined
110
- }),
111
- )).filter(exists)
112
- // this.logger?.info(`Converted pending transactions: ${JSON.stringify(hydratedWithBundle.map(x => x.tx), null, 2)} results`)
113
-
114
- const currentBlock = await this.windowedBlockViewer.currentBlock()
115
- const evaluated = await Promise.all(
116
- hydratedWithBundle.map(async ({ bundle, tx }) => ({
117
- bundle, tx, deletable: await this.isDeletable(tx, currentBlock),
118
- })),
119
- )
120
-
121
- const validTransactions = evaluated.filter(x => !x.deletable)
122
- const deletionCandidates = evaluated.filter(x => x.deletable)
123
- this.logger?.info(`Pending transactions: ${validTransactions.length} valid, ${deletionCandidates.length} not deletable`)
124
-
125
- // Delete the invalid transactions that should not remain in the mempool.
126
- await Promise.all(
127
- deletionCandidates.map(async ({ bundle, tx }) => {
128
- await this.deleteBundledTransaction(bundle)
129
- this.logger?.info(`Purged completed/expired bundled transaction: ${bundle._hash}/${tx[0]._hash}`)
130
- }),
131
- )
132
-
133
- const inclusionCandidates = (await Promise.all(validTransactions.map(x => x.tx).map(async (tx) => {
134
- // Check if it's a candidate for inclusion (skip deletable check as we've already done that)
135
- if (await this.isInclusionCandidate(tx, currentBlock, false)) return tx
136
- }))).filter(exists)
137
-
138
- const selectionRatio = this.params.mempoolSelectionRatio ?? DEFAULT_MEMPOOL_SELECTION_RATIO
139
- const maxByRatio = Math.ceil(inclusionCandidates.length * selectionRatio)
140
- const effectiveLimit = Math.min(limit, maxByRatio)
141
-
142
- const randomInclusionCandidates = deduplicateBySigner(
143
- inclusionCandidates.filter(() => Math.random() < selectionRatio),
144
- ).slice(0, effectiveLimit)
145
-
146
- // if the random filter resulted in 0 bundles, we fallback to just taking the first bundle to ensure we return something
147
- const result = randomInclusionCandidates.length > 0 ? randomInclusionCandidates : deduplicateBySigner(inclusionCandidates).slice(0, 1)
148
-
149
- this.logger?.info(`Inclusion candidates: ${inclusionCandidates.length}`)
150
- return result
151
- }
152
-
153
- private async deleteBundledTransaction(bundle: PayloadBundleWithHashMeta): Promise<void> {
154
- await this.pendingTransactionsArchivist.delete([bundle._hash])
155
- }
156
-
157
- /**
158
- * Evaluates a transaction to determine if it should be purged from the mempool.
159
- * @param tx The transaction to evaluate
160
- * @param currentBlock The current block to use for evaluation
161
- * @returns True if the transaction should be purged, false otherwise
162
- */
163
- private async isDeletable(tx: HydratedTransactionWithHashMeta, currentBlock: SignedHydratedBlockWithHashMeta): Promise<boolean> {
164
- const currentBlockNumber = currentBlock[0].block
165
- const nextBlockNumber = currentBlockNumber + 1
166
- const { exp } = tx[0]
167
-
168
- // If it's expired
169
- if (nextBlockNumber > exp) return true
170
-
171
- // If it's already included in a block
172
- const existingBlock = await this.windowedBlockViewer.blockByTransactionHash(tx[0]._hash)
173
- if (existingBlock) return true
174
-
175
- return false
176
- }
177
-
178
- /**
179
- * Evaluates a transaction to determine if is valid for inclusion in the next block. A transaction is invalid if:
180
- * - The transaction is too early/expired
181
- * - The transaction has already been included in a block
182
- * @param tx The transaction to evaluate
183
- * @param currentBlock The current block to use for evaluation
184
- * @param checkForDeletable Whether to check if the transaction is deletable (default: true)
185
- * @returns True if the transaction is valid for inclusion in the next block, false otherwise
186
- */
187
- private async isInclusionCandidate(
188
- tx: HydratedTransactionWithHashMeta,
189
- currentBlock: SignedHydratedBlockWithHashMeta,
190
- checkForDeletable: boolean = true,
191
- ): Promise<boolean> {
192
- const currentBlockNumber = currentBlock[0].block
193
- const nextBlockNumber = currentBlockNumber + 1
194
- const { nbf } = tx[0]
195
-
196
- // If it's not time yet
197
- if (nextBlockNumber < nbf) return false
198
-
199
- // If it's deletable
200
- if (checkForDeletable && await this.isDeletable(tx, currentBlock)) return false
201
-
202
- return true
203
- }
204
- }
205
-
206
- /** Remove transactions that share the same signer set, keeping the first occurrence. */
207
- function deduplicateBySigner(txs: SignedHydratedTransactionWithHashMeta[]): SignedHydratedTransactionWithHashMeta[] {
208
- const seen = new Set<string>()
209
- return txs.filter((tx) => {
210
- const key = tx[0].addresses.toSorted().join(',')
211
- if (seen.has(key)) return false
212
- seen.add(key)
213
- return true
214
- })
215
- }
@@ -1,2 +0,0 @@
1
- export * from './SimpleMempoolRunner.ts'
2
- export * from './SimpleMempoolViewer.ts'
@@ -1,48 +0,0 @@
1
- import { isUndefined } from '@xylabs/sdk-js'
2
- import type {
3
- GatewayName,
4
- NetworkStatus, XyoNetwork,
5
- } from '@xyo-network/xl1-protocol-lib'
6
- import { isNetworkStatus } from '@xyo-network/xl1-protocol-lib'
7
- import axios from 'axios'
8
-
9
- import {
10
- errorStatus, StatusNetworks, unknownStatus,
11
- } from './lib/index.ts'
12
-
13
- /** SimpleXyoNetwork implementation. */
14
- export class SimpleXyoNetwork implements XyoNetwork {
15
- protected readonly _networkId: GatewayName
16
-
17
- constructor(networkId: GatewayName) {
18
- this._networkId = networkId
19
- }
20
-
21
- async status(): Promise<NetworkStatus> {
22
- const statusNetwork = StatusNetworks[this._networkId]
23
- if (isUndefined(statusNetwork)) {
24
- throw new Error(`Unknown status network ID: ${this._networkId}`)
25
- }
26
-
27
- return await this.makeRequest(statusNetwork.statusUrl)
28
- }
29
-
30
- private async makeRequest(url: string): Promise<NetworkStatus> {
31
- try {
32
- const response = await axios.get(url)
33
- if (isNetworkStatus(response.data)) {
34
- return response.data
35
- } else {
36
- if (response.status === 200) {
37
- console.error('Unknown network status response:', response.data)
38
-
39
- return unknownStatus
40
- }
41
- return errorStatus
42
- }
43
- } catch (error) {
44
- console.error('Error fetching network status:', error)
45
- return errorStatus
46
- }
47
- }
48
- }
@@ -1 +0,0 @@
1
- export * from './SimpleXyoNetwork.ts'
@@ -1,16 +0,0 @@
1
- import type { NetworkStatus } from '@xyo-network/xl1-protocol-lib'
2
- import { NetworkStatusSchema } from '@xyo-network/xl1-protocol-lib'
3
-
4
- /** unknownStatus constant. */
5
- export const unknownStatus: NetworkStatus = {
6
- description: 'Unknown Network Status',
7
- schema: NetworkStatusSchema,
8
- state: 'unknown',
9
- }
10
-
11
- /** errorStatus constant. */
12
- export const errorStatus: NetworkStatus = {
13
- description: 'Error Fetching Network Status',
14
- schema: NetworkStatusSchema,
15
- state: 'unknown',
16
- }
@@ -1,32 +0,0 @@
1
- import type { GatewayName } from '@xyo-network/xl1-protocol-lib'
2
-
3
- /** StatusNetwork type. */
4
- export type StatusNetwork = {
5
- id: GatewayName
6
- statusUrl: string
7
- }
8
-
9
- /** MainNetworkStats constant. */
10
- export const MainNetworkStats: StatusNetwork = {
11
- id: 'mainnet' as GatewayName,
12
- statusUrl: 'https://xyo.network/chain-network-status-mainnet.json',
13
- }
14
-
15
- /** SequenceNetworkStats constant. */
16
- export const SequenceNetworkStats: StatusNetwork = {
17
- id: 'sequence' as GatewayName,
18
- statusUrl: 'https://beta.xyo.network/chain-network-status-sequence.json',
19
- }
20
-
21
- /** LocalNetworkStats constant. */
22
- export const LocalNetworkStats: StatusNetwork = {
23
- id: 'local' as GatewayName,
24
- statusUrl: 'http://localhost:3002/chain-network-status-local.json',
25
- }
26
-
27
- /** StatusNetworks constant. */
28
- export const StatusNetworks: Record<GatewayName, StatusNetwork> = {
29
- ['mainnet' as GatewayName]: MainNetworkStats,
30
- ['sequence' as GatewayName]: SequenceNetworkStats,
31
- ['local' as GatewayName]: LocalNetworkStats,
32
- }
@@ -1,2 +0,0 @@
1
- export * from './FailedNetworkStatusPayloads.ts'
2
- export * from './StatusNetworks.ts'
@@ -1,82 +0,0 @@
1
- import { assertEx } from '@xylabs/sdk-js'
2
- import type {
3
- CaveatTypes,
4
- InvokerPermission, PermissionRequest, RequestedPermission, XyoPermissions,
5
- } from '@xyo-network/xl1-protocol-lib'
6
-
7
- import type { Invoker, PermissionsStore } from './store/index.ts'
8
-
9
- /**
10
- * In-memory implementation of XyoPermissions for testing or ephemeral use cases.
11
- * Does not persist data beyond the lifetime of the instance.
12
- * Assumes all permission requests are granted and revocations always succeed.
13
- */
14
- export class SimpleXyoPermissions implements XyoPermissions {
15
- invoker: Invoker
16
- private _store: PermissionsStore
17
-
18
- constructor(store: PermissionsStore) {
19
- this._store = store
20
- this.invoker = store.invoker
21
- }
22
-
23
- get store(): PermissionsStore {
24
- return assertEx(this._store, () => 'Store must be defined to get permissions')
25
- }
26
-
27
- async getPermissions(): Promise<InvokerPermission[]> {
28
- return await this.store.getPermissions()
29
- }
30
-
31
- // assumed the permissions are always granted
32
- async requestPermissions(permissions: PermissionRequest[]): Promise<RequestedPermission[]> {
33
- await Promise.resolve()
34
- // Flatten PermissionRequest[] into InvokerPermission[]
35
- const newPermissions: InvokerPermission[] = []
36
- const now = Date.now()
37
- for (const req of permissions) {
38
- for (const parentCapability in req) {
39
- newPermissions.push({
40
- invoker: this.invoker,
41
- parentCapability,
42
- caveats: Object.entries(req[parentCapability]).map(([type, value]) => ({ type: type as CaveatTypes, value })),
43
- date: now,
44
- })
45
- }
46
- }
47
-
48
- // Update or add permissions in the store
49
- const existingPermissions = await this.getPermissions()
50
- for (const perm of newPermissions) {
51
- const idx = existingPermissions.findIndex(
52
- p => p.invoker === perm.invoker && p.parentCapability === perm.parentCapability,
53
- )
54
- if (idx === -1) {
55
- existingPermissions.push(perm)
56
- } else {
57
- existingPermissions[idx] = perm
58
- }
59
- }
60
- await this.store.setPermissions(existingPermissions)
61
-
62
- // Return the granted permissions in RequestedPermission shape
63
- return newPermissions.map(({ parentCapability, date }) => ({ parentCapability, date }))
64
- }
65
-
66
- // Assumes the permissions are always revoked
67
- async revokePermissions(permissions: PermissionRequest): Promise<RequestedPermission[]> {
68
- const existingPermissions = await this.getPermissions()
69
- const revoked: RequestedPermission[] = []
70
- for (const parentCapability in permissions) {
71
- const idx = existingPermissions.findIndex(
72
- p => p.invoker === this.invoker && p.parentCapability === parentCapability,
73
- )
74
- if (idx !== -1) {
75
- const removed = existingPermissions.splice(idx, 1)[0]
76
- revoked.push({ parentCapability: removed.parentCapability, date: removed.date })
77
- }
78
- }
79
- await this.store.setPermissions(existingPermissions)
80
- return revoked
81
- }
82
- }
@@ -1,2 +0,0 @@
1
- export * from './SimpleXyoPermissions.ts'
2
- export * from './store/index.ts'
@@ -1,32 +0,0 @@
1
- import { assertEx } from '@xylabs/sdk-js'
2
- import type { InvokerPermission } from '@xyo-network/xl1-protocol-lib'
3
-
4
- import type { Invoker, PermissionsStore } from './PermissionsStore.ts'
5
-
6
- /**
7
- * In-memory implementation of XyoPermissions for testing or ephemeral use cases.
8
- * Does not persist data beyond the lifetime of the instance.
9
- * Assumes all permission requests are granted and revocations always succeed.
10
- */
11
- export class MemoryPermissionsStore implements PermissionsStore {
12
- private _invoker: Invoker
13
- private permissions: InvokerPermission[] = []
14
-
15
- constructor(invoker: Invoker) {
16
- this._invoker = invoker
17
- }
18
-
19
- get invoker(): Invoker {
20
- return assertEx(this._invoker, () => 'Invoker must be defined to get permissions')
21
- }
22
-
23
- async getPermissions(): Promise<InvokerPermission[]> {
24
- await Promise.resolve()
25
- return this.permissions
26
- }
27
-
28
- async setPermissions(permissions: InvokerPermission[]): Promise<void> {
29
- await Promise.resolve()
30
- this.permissions = permissions
31
- }
32
- }
@@ -1,17 +0,0 @@
1
- import type { InvokerPermission, PermissionsGetHandler } from '@xyo-network/xl1-protocol-lib'
2
-
3
- /** Invoker type. */
4
- export type Invoker = string
5
- /** ParentCapability type. */
6
- export type ParentCapability = string
7
- /**
8
- * Interface for a permissions store that abstracts away the storage medium.
9
- * (i.e. in-memory, browser storage, database, etc.)
10
- */
11
- export interface PermissionsStore extends PermissionsGetHandler {
12
- // The invoker associated with this permissions store
13
- readonly invoker: Invoker
14
- // Retrieve all permissions associated with the invoker.
15
- // Store or update permissions for the invoker
16
- setPermissions(permissions: InvokerPermission[]): Promise<void>
17
- }
@@ -1,2 +0,0 @@
1
- export * from './MemoryPermissions.ts'
2
- export * from './PermissionsStore.ts'
@@ -1,41 +0,0 @@
1
- import { type Hash } from '@xylabs/sdk-js'
2
- import { PayloadBuilder } from '@xyo-network/sdk-js'
3
- import {
4
- MempoolRunner,
5
- MempoolRunnerMoniker, SignedHydratedTransactionWithStorageMeta,
6
- XyoRunner, XyoRunnerMoniker,
7
- } from '@xyo-network/xl1-protocol-lib'
8
-
9
- import type { CreatableProviderParams } from '../../CreatableProvider/index.ts'
10
- import { AbstractCreatableProvider, creatableProvider } from '../../CreatableProvider/index.ts'
11
-
12
- /** Parameters for SimpleXyoRunner. */
13
- export interface SimpleXyoRunnerParams extends CreatableProviderParams {
14
- }
15
-
16
- /** SimpleXyoRunner implementation. */
17
- @creatableProvider()
18
- export class SimpleXyoRunner extends AbstractCreatableProvider<SimpleXyoRunnerParams> implements XyoRunner {
19
- static readonly defaultMoniker = XyoRunnerMoniker
20
- static readonly dependencies = [MempoolRunnerMoniker]
21
- static readonly monikers = [XyoRunnerMoniker]
22
- moniker = SimpleXyoRunner.defaultMoniker
23
-
24
- private _mempoolRunner?: MempoolRunner
25
-
26
- get mempool() {
27
- return this._mempoolRunner!
28
- }
29
-
30
- async broadcastTransaction(transaction: SignedHydratedTransactionWithStorageMeta): Promise<Hash> {
31
- await this.mempool.submitTransactions([transaction])
32
- const hash = await PayloadBuilder.hash(transaction[0])
33
- this.logger?.info(`Broadcasted transaction with hash ${hash}`)
34
- return hash
35
- }
36
-
37
- override async createHandler() {
38
- await super.createHandler()
39
- this._mempoolRunner = await this.locator.getInstance<MempoolRunner>(MempoolRunnerMoniker)
40
- }
41
- }
@@ -1 +0,0 @@
1
- export * from './SimpleXyoRunner.ts'
@@ -1,78 +0,0 @@
1
- import type { Address, Promisable } from '@xylabs/sdk-js'
2
- import type { AccountInstance, Payload } from '@xyo-network/sdk-js'
3
- import { Account, PayloadBuilder } from '@xyo-network/sdk-js'
4
- import type {
5
- AllowedBlockPayload, ChainId, SignedHydratedTransactionWithHashMeta,
6
- SignedTransactionBoundWitness, TransactionFeesBigInt,
7
- UnsignedTransactionBoundWitness,
8
- XL1BlockNumber, XyoSigner,
9
- } from '@xyo-network/xl1-protocol-lib'
10
- import {
11
- SignedHydratedTransactionWithHashMetaZod,
12
- XyoSignerMoniker,
13
- } from '@xyo-network/xl1-protocol-lib'
14
-
15
- import type { CreatableProviderParams } from '../../CreatableProvider/index.ts'
16
- import { AbstractCreatableProvider } from '../../CreatableProvider/index.ts'
17
- import { buildTransaction, signTransaction } from '../../transaction/index.ts'
18
-
19
- /** Parameters for SimpleXyoSigner. */
20
- export interface SimpleXyoSignerParams extends CreatableProviderParams {
21
- account: AccountInstance
22
- }
23
-
24
- /** SimpleXyoSigner implementation. */
25
- export class SimpleXyoSigner extends AbstractCreatableProvider<SimpleXyoSignerParams> implements XyoSigner {
26
- static readonly defaultMoniker = XyoSignerMoniker
27
- static readonly dependencies = []
28
- static readonly monikers = [XyoSignerMoniker]
29
- moniker = SimpleXyoSigner.defaultMoniker
30
-
31
- static override async paramsHandler(params?: Partial<SimpleXyoSignerParams>) {
32
- let account: AccountInstance
33
- if (params?.account) {
34
- account = params.account
35
- } else {
36
- const localLogger = params?.logger ?? params?.context?.logger
37
- localLogger?.warn(`No account provided to SimpleXyoSigner, generating a random account.
38
- This account will not be persisted and any transactions signed with it may be lost.
39
- `)
40
-
41
- account = await Account.random()
42
- }
43
- return { ...await super.paramsHandler(params), account }
44
- }
45
-
46
- address(): Promisable<Address> {
47
- return this.params.account.address
48
- }
49
-
50
- /** @deprecated - use signTransaction instead */
51
- async createSignedTransaction(
52
- chain: ChainId,
53
- elevatedPayloads: AllowedBlockPayload[],
54
- additionalPayloads: Payload[],
55
- nbf: XL1BlockNumber,
56
- exp: XL1BlockNumber,
57
- fees: TransactionFeesBigInt,
58
- from?: Address,
59
- ): Promise<SignedTransactionBoundWitness> {
60
- const fromAddress = from ?? await this.address()
61
- const transaction = await buildTransaction(
62
- chain,
63
- elevatedPayloads,
64
- additionalPayloads,
65
- this.params.account,
66
- nbf,
67
- exp,
68
- fromAddress,
69
- fees,
70
- )
71
- return transaction[0]
72
- }
73
-
74
- async signTransaction(tx: [UnsignedTransactionBoundWitness, Payload[]]): Promise<SignedHydratedTransactionWithHashMeta> {
75
- const txBW = await signTransaction(tx[0], this.params.account)
76
- return SignedHydratedTransactionWithHashMetaZod.parse([await PayloadBuilder.addStorageMeta(txBW), await PayloadBuilder.addStorageMeta(tx[1])])
77
- }
78
- }
@@ -1 +0,0 @@
1
- export * from './SimpleXyoSigner.ts'