@xyo-network/xl1-protocol-sdk 1.17.7 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/neutral/CreatableProvider/AbstractCreatableProvider.d.ts +104 -1
- package/dist/neutral/CreatableProvider/AbstractCreatableProvider.d.ts.map +1 -1
- package/dist/neutral/CreatableProvider/CreatableProvider.d.ts +27 -10
- package/dist/neutral/CreatableProvider/CreatableProvider.d.ts.map +1 -1
- package/dist/neutral/CreatableProvider/CreatableProviderRegistry.d.ts.map +1 -1
- package/dist/neutral/CreatableProvider/ProviderFactory.d.ts +11 -3
- package/dist/neutral/CreatableProvider/ProviderFactory.d.ts.map +1 -1
- package/dist/neutral/CreatableProvider/ProviderFactoryLocator.d.ts +19 -13
- package/dist/neutral/CreatableProvider/ProviderFactoryLocator.d.ts.map +1 -1
- package/dist/neutral/CreatableProvider/ProviderFactoryLocatorInstance.d.ts +14 -10
- package/dist/neutral/CreatableProvider/ProviderFactoryLocatorInstance.d.ts.map +1 -1
- package/dist/neutral/config/Bridge.d.ts +3 -0
- package/dist/neutral/config/Bridge.d.ts.map +1 -1
- package/dist/neutral/config/Chain.d.ts +1 -1
- package/dist/neutral/config/Config.d.ts +8 -5
- package/dist/neutral/config/Config.d.ts.map +1 -1
- package/dist/neutral/config/Log.d.ts +1 -1
- package/dist/neutral/config/Services.d.ts +2 -2
- package/dist/neutral/config/Services.d.ts.map +1 -1
- package/dist/neutral/createDeclarationPayload.d.ts +4 -0
- package/dist/neutral/createDeclarationPayload.d.ts.map +1 -0
- package/dist/neutral/createTransferPayload.d.ts +4 -0
- package/dist/neutral/createTransferPayload.d.ts.map +1 -0
- package/dist/neutral/driver/cache/LruCacheMap.d.ts +2 -2
- package/dist/neutral/driver/cache/LruCacheMap.d.ts.map +1 -1
- package/dist/neutral/driver/memory/MemoryMap.d.ts +2 -2
- package/dist/neutral/driver/memory/MemoryMap.d.ts.map +1 -1
- package/dist/neutral/index.d.ts +3 -0
- package/dist/neutral/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +1887 -632
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/map/MapType.d.ts +3 -2
- package/dist/neutral/map/MapType.d.ts.map +1 -1
- package/dist/neutral/model/ChainContext/ChainContext.d.ts +4 -4
- package/dist/neutral/model/ChainContext/ChainContext.d.ts.map +1 -1
- package/dist/neutral/model/ChainQualification.d.ts +42 -0
- package/dist/neutral/model/ChainQualification.d.ts.map +1 -0
- package/dist/neutral/model/PayloadBundle/bundledPayloadToHydratedTransaction.d.ts +2 -2
- package/dist/neutral/model/PayloadBundle/bundledPayloadToHydratedTransaction.d.ts.map +1 -1
- package/dist/neutral/model/index.d.ts +1 -1
- package/dist/neutral/model/index.d.ts.map +1 -1
- package/dist/neutral/primitives/block/index.d.ts +2 -0
- package/dist/neutral/primitives/block/index.d.ts.map +1 -0
- package/dist/neutral/primitives/block/range/blockRangeSteps.d.ts +3 -0
- package/dist/neutral/primitives/block/range/blockRangeSteps.d.ts.map +1 -0
- package/dist/neutral/primitives/block/range/index.d.ts +2 -0
- package/dist/neutral/primitives/block/range/index.d.ts.map +1 -0
- package/dist/neutral/primitives/chain/getWindowedChain.d.ts +26 -0
- package/dist/neutral/primitives/chain/getWindowedChain.d.ts.map +1 -0
- package/dist/neutral/primitives/chain/index.d.ts +4 -0
- package/dist/neutral/primitives/chain/index.d.ts.map +1 -0
- package/dist/neutral/primitives/chain/step/chainStepRewardAddress.d.ts +5 -0
- package/dist/neutral/primitives/chain/step/chainStepRewardAddress.d.ts.map +1 -0
- package/dist/neutral/primitives/chain/step/index.d.ts +5 -0
- package/dist/neutral/primitives/chain/step/index.d.ts.map +1 -0
- package/dist/neutral/primitives/chain/step/stepRewardBlock.d.ts +4 -0
- package/dist/neutral/primitives/chain/step/stepRewardBlock.d.ts.map +1 -0
- package/dist/neutral/primitives/chain/step/stepRewardTotal.d.ts +4 -0
- package/dist/neutral/primitives/chain/step/stepRewardTotal.d.ts.map +1 -0
- package/dist/neutral/primitives/chain/step/stepsRewardTotal.d.ts +6 -0
- package/dist/neutral/primitives/chain/step/stepsRewardTotal.d.ts.map +1 -0
- package/dist/neutral/primitives/chain/time/externalBlockNumberFromXL1BlockNumber.d.ts +5 -0
- package/dist/neutral/primitives/chain/time/externalBlockNumberFromXL1BlockNumber.d.ts.map +1 -0
- package/dist/neutral/primitives/chain/time/externalBlockRangeFromStep.d.ts +5 -0
- package/dist/neutral/primitives/chain/time/externalBlockRangeFromStep.d.ts.map +1 -0
- package/dist/neutral/primitives/chain/time/externalBlockRangeFromXL1BlockRange.d.ts +5 -0
- package/dist/neutral/primitives/chain/time/externalBlockRangeFromXL1BlockRange.d.ts.map +1 -0
- package/dist/neutral/primitives/chain/time/index.d.ts +4 -0
- package/dist/neutral/primitives/chain/time/index.d.ts.map +1 -0
- package/dist/neutral/primitives/index.d.ts +7 -0
- package/dist/neutral/primitives/index.d.ts.map +1 -1
- package/dist/neutral/primitives/mapToMapType.d.ts +3 -0
- package/dist/neutral/primitives/mapToMapType.d.ts.map +1 -0
- package/dist/neutral/primitives/payload/index.d.ts +2 -0
- package/dist/neutral/primitives/payload/index.d.ts.map +1 -0
- package/dist/neutral/primitives/payload/mergeTransfers.d.ts +4 -0
- package/dist/neutral/primitives/payload/mergeTransfers.d.ts.map +1 -0
- package/dist/neutral/primitives/readPayloadMapFromStore.d.ts +5 -4
- package/dist/neutral/primitives/readPayloadMapFromStore.d.ts.map +1 -1
- package/dist/neutral/primitives/rewards/index.d.ts +2 -0
- package/dist/neutral/primitives/rewards/index.d.ts.map +1 -0
- package/dist/neutral/primitives/rewards/networkStakeStepRewardPositionWeight.d.ts +5 -0
- package/dist/neutral/primitives/rewards/networkStakeStepRewardPositionWeight.d.ts.map +1 -0
- package/dist/neutral/primitives/stake/activeStakeAtTimeByAddress.d.ts +4 -0
- package/dist/neutral/primitives/stake/activeStakeAtTimeByAddress.d.ts.map +1 -0
- package/dist/neutral/primitives/stake/activeStakeAtTimeByPosition.d.ts +3 -0
- package/dist/neutral/primitives/stake/activeStakeAtTimeByPosition.d.ts.map +1 -0
- package/dist/neutral/primitives/stake/allStakersForRange.d.ts +4 -0
- package/dist/neutral/primitives/stake/allStakersForRange.d.ts.map +1 -0
- package/dist/neutral/primitives/stake/allStakersForStep.d.ts +6 -0
- package/dist/neutral/primitives/stake/allStakersForStep.d.ts.map +1 -0
- package/dist/neutral/primitives/stake/index.d.ts +7 -0
- package/dist/neutral/primitives/stake/index.d.ts.map +1 -0
- package/dist/neutral/primitives/stake/mergedAddRemoveStakeEventsByPosition.d.ts +3 -0
- package/dist/neutral/primitives/stake/mergedAddRemoveStakeEventsByPosition.d.ts.map +1 -0
- package/dist/neutral/primitives/stake/mergedAddRemoveStakeEventsByStaker.d.ts +4 -0
- package/dist/neutral/primitives/stake/mergedAddRemoveStakeEventsByStaker.d.ts.map +1 -0
- package/dist/neutral/primitives/stake/weightedStakeForRangeByPosition.d.ts +6 -0
- package/dist/neutral/primitives/stake/weightedStakeForRangeByPosition.d.ts.map +1 -0
- package/dist/neutral/primitives/uncle/findBestUncle.d.ts +24 -0
- package/dist/neutral/primitives/uncle/findBestUncle.d.ts.map +1 -0
- package/dist/neutral/primitives/uncle/findUncles.d.ts +26 -0
- package/dist/neutral/primitives/uncle/findUncles.d.ts.map +1 -0
- package/dist/neutral/primitives/uncle/index.d.ts +4 -0
- package/dist/neutral/primitives/uncle/index.d.ts.map +1 -0
- package/dist/neutral/primitives/uncle/scoreUncle.d.ts +3 -0
- package/dist/neutral/primitives/uncle/scoreUncle.d.ts.map +1 -0
- package/dist/neutral/provider/DataLake.d.ts +10 -9
- package/dist/neutral/provider/DataLake.d.ts.map +1 -1
- package/dist/neutral/provider/XyoConnection.d.ts +4 -1
- package/dist/neutral/provider/XyoConnection.d.ts.map +1 -1
- package/dist/neutral/provider/XyoGatewayRunner.d.ts +3 -3
- package/dist/neutral/provider/XyoGatewayRunner.d.ts.map +1 -1
- package/dist/neutral/provider/XyoRunner.d.ts +5 -2
- package/dist/neutral/provider/XyoRunner.d.ts.map +1 -1
- package/dist/neutral/provider/viewer/XyoViewer.d.ts +16 -13
- package/dist/neutral/provider/viewer/XyoViewer.d.ts.map +1 -1
- package/dist/neutral/runners/Block.d.ts +7 -2
- package/dist/neutral/runners/Block.d.ts.map +1 -1
- package/dist/neutral/runners/Mempool.d.ts +4 -1
- package/dist/neutral/runners/Mempool.d.ts.map +1 -1
- package/dist/neutral/services/Chain/ChainService.d.ts +2 -2
- package/dist/neutral/services/Chain/ChainService.d.ts.map +1 -1
- package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts +65 -21
- package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts.map +1 -1
- package/dist/neutral/simple/block/SimpleBlockViewer.d.ts +9 -6
- package/dist/neutral/simple/block/SimpleBlockViewer.d.ts.map +1 -1
- package/dist/neutral/simple/blockValidation/SimpleBlockValidationViewer.d.ts +31 -0
- package/dist/neutral/simple/blockValidation/SimpleBlockValidationViewer.d.ts.map +1 -0
- package/dist/neutral/simple/blockValidation/index.d.ts +2 -0
- package/dist/neutral/simple/blockValidation/index.d.ts.map +1 -0
- package/dist/neutral/simple/chainStake/{SimpleChainStakeViewer.d.ts → SimpleStakeViewer.d.ts} +3 -5
- package/dist/neutral/simple/chainStake/SimpleStakeViewer.d.ts.map +1 -0
- package/dist/neutral/simple/chainStake/index.d.ts +1 -1
- package/dist/neutral/simple/chainStake/index.d.ts.map +1 -1
- package/dist/neutral/simple/datalake/AbstractSimpleDataLake.d.ts +6 -3
- package/dist/neutral/simple/datalake/AbstractSimpleDataLake.d.ts.map +1 -1
- package/dist/neutral/simple/datalake/SimpleDataLakeRunner.d.ts +4 -3
- package/dist/neutral/simple/datalake/SimpleDataLakeRunner.d.ts.map +1 -1
- package/dist/neutral/simple/datalake/SimpleDataLakeViewer.d.ts +0 -3
- package/dist/neutral/simple/datalake/SimpleDataLakeViewer.d.ts.map +1 -1
- package/dist/neutral/simple/index.d.ts +2 -0
- package/dist/neutral/simple/index.d.ts.map +1 -1
- package/dist/neutral/simple/mempool/SimpleMempoolRunner.d.ts +8 -4
- package/dist/neutral/simple/mempool/SimpleMempoolRunner.d.ts.map +1 -1
- package/dist/neutral/simple/mempool/SimpleMempoolViewer.d.ts.map +1 -1
- package/dist/neutral/simple/runner/SimpleXyoRunner.d.ts +24 -6
- package/dist/neutral/simple/runner/SimpleXyoRunner.d.ts.map +1 -1
- package/dist/neutral/simple/{chainStakeEvents/SimpleChainStakeEventsViewer.d.ts → stakeEvents/SimpleStakeEventsViewer.d.ts} +3 -3
- package/dist/neutral/simple/stakeEvents/SimpleStakeEventsViewer.d.ts.map +1 -0
- package/dist/neutral/simple/stakeEvents/index.d.ts +2 -0
- package/dist/neutral/simple/stakeEvents/index.d.ts.map +1 -0
- package/dist/neutral/simple/timesync/SimpleTimeSyncViewer.d.ts +4 -3
- package/dist/neutral/simple/timesync/SimpleTimeSyncViewer.d.ts.map +1 -1
- package/dist/neutral/status/RuntimeStatusMonitor.d.ts +31 -0
- package/dist/neutral/status/RuntimeStatusMonitor.d.ts.map +1 -0
- package/dist/neutral/status/ServiceStatus.d.ts +8 -0
- package/dist/neutral/status/ServiceStatus.d.ts.map +1 -0
- package/dist/neutral/status/index.d.ts +3 -0
- package/dist/neutral/status/index.d.ts.map +1 -0
- package/dist/neutral/summary/model/summary.d.ts +4 -5
- package/dist/neutral/summary/model/summary.d.ts.map +1 -1
- package/dist/neutral/summary/primitives/balances/balancesStepSummaryFromRange.d.ts +1 -1
- package/dist/neutral/summary/primitives/balances/balancesStepSummaryFromRange.d.ts.map +1 -1
- package/dist/neutral/summary/primitives/balances/balancesSummary.d.ts +2 -2
- package/dist/neutral/summary/primitives/balances/balancesSummary.d.ts.map +1 -1
- package/dist/neutral/summary/primitives/schemas/schemasSummary.d.ts +2 -2
- package/dist/neutral/summary/primitives/schemas/schemasSummary.d.ts.map +1 -1
- package/dist/neutral/summary/primitives/transfers/transfersSummary.d.ts +2 -2
- package/dist/neutral/summary/primitives/transfers/transfersSummary.d.ts.map +1 -1
- package/dist/neutral/transaction/TransactionBuilder.d.ts +82 -0
- package/dist/neutral/transaction/TransactionBuilder.d.ts.map +1 -0
- package/dist/neutral/transaction/buildRandomTransaction.d.ts +6 -0
- package/dist/neutral/transaction/buildRandomTransaction.d.ts.map +1 -0
- package/dist/neutral/transaction/index.d.ts +2 -0
- package/dist/neutral/transaction/index.d.ts.map +1 -1
- package/dist/neutral/viewers/AccountBalance.d.ts +35 -15
- package/dist/neutral/viewers/AccountBalance.d.ts.map +1 -1
- package/dist/neutral/viewers/Block.d.ts +4 -1
- package/dist/neutral/viewers/Block.d.ts.map +1 -1
- package/dist/neutral/viewers/BlockValidation.d.ts +54 -0
- package/dist/neutral/viewers/BlockValidation.d.ts.map +1 -0
- package/dist/neutral/viewers/ChainStakeViewer.d.ts +1 -2
- package/dist/neutral/viewers/ChainStakeViewer.d.ts.map +1 -1
- package/dist/neutral/viewers/Fork.d.ts +0 -1
- package/dist/neutral/viewers/Fork.d.ts.map +1 -1
- package/dist/neutral/viewers/Stake.d.ts +0 -1
- package/dist/neutral/viewers/Stake.d.ts.map +1 -1
- package/dist/neutral/viewers/StakeIntent.d.ts +2 -2
- package/dist/neutral/viewers/StakeIntent.d.ts.map +1 -1
- package/dist/neutral/viewers/TransactionValidation.d.ts +35 -0
- package/dist/neutral/viewers/TransactionValidation.d.ts.map +1 -0
- package/dist/neutral/viewers/index.d.ts +2 -1
- package/dist/neutral/viewers/index.d.ts.map +1 -1
- package/package.json +8 -6
- package/src/CreatableProvider/AbstractCreatableProvider.ts +60 -3
- package/src/CreatableProvider/CreatableProvider.ts +38 -11
- package/src/CreatableProvider/CreatableProviderRegistry.ts +10 -5
- package/src/CreatableProvider/ProviderFactory.ts +73 -10
- package/src/CreatableProvider/ProviderFactoryLocator.ts +79 -19
- package/src/CreatableProvider/ProviderFactoryLocatorInstance.ts +33 -10
- package/src/config/Bridge.ts +22 -4
- package/src/config/Chain.ts +2 -2
- package/src/config/Services.ts +4 -2
- package/src/createDeclarationPayload.ts +14 -0
- package/src/createTransferPayload.ts +15 -0
- package/src/driver/cache/LruCacheMap.ts +2 -2
- package/src/driver/memory/MemoryMap.ts +2 -2
- package/src/index.ts +3 -0
- package/src/map/MapType.ts +4 -2
- package/src/model/ChainContext/ChainContext.ts +4 -4
- package/src/model/ChainQualification.ts +33 -0
- package/src/model/PayloadBundle/bundledPayloadToHydratedTransaction.ts +2 -2
- package/src/model/index.ts +1 -1
- package/src/primitives/block/index.ts +1 -0
- package/src/primitives/block/range/blockRangeSteps.ts +22 -0
- package/src/primitives/block/range/index.ts +1 -0
- package/src/primitives/chain/getWindowedChain.ts +23 -0
- package/src/primitives/chain/index.ts +3 -0
- package/src/primitives/chain/step/chainStepRewardAddress.ts +28 -0
- package/src/primitives/chain/step/index.ts +4 -0
- package/src/primitives/chain/step/stepRewardBlock.ts +11 -0
- package/src/primitives/chain/step/stepRewardTotal.ts +45 -0
- package/src/primitives/chain/step/stepsRewardTotal.ts +34 -0
- package/src/primitives/chain/time/externalBlockNumberFromXL1BlockNumber.ts +31 -0
- package/src/primitives/chain/time/externalBlockRangeFromStep.ts +19 -0
- package/src/primitives/chain/time/externalBlockRangeFromXL1BlockRange.ts +16 -0
- package/src/primitives/chain/time/index.ts +3 -0
- package/src/primitives/index.ts +7 -0
- package/src/primitives/mapToMapType.ts +35 -0
- package/src/primitives/payload/index.ts +1 -0
- package/src/primitives/payload/mergeTransfers.ts +15 -0
- package/src/primitives/readPayloadMapFromStore.ts +38 -8
- package/src/primitives/rewards/index.ts +1 -0
- package/src/primitives/rewards/networkStakeStepRewardPositionWeight.ts +21 -0
- package/src/primitives/stake/activeStakeAtTimeByAddress.ts +26 -0
- package/src/primitives/stake/activeStakeAtTimeByPosition.ts +24 -0
- package/src/primitives/stake/allStakersForRange.ts +31 -0
- package/src/primitives/stake/allStakersForStep.ts +22 -0
- package/src/primitives/stake/index.ts +6 -0
- package/src/primitives/stake/mergedAddRemoveStakeEventsByPosition.ts +14 -0
- package/src/primitives/stake/mergedAddRemoveStakeEventsByStaker.ts +17 -0
- package/src/primitives/stake/weightedStakeForRangeByPosition.ts +54 -0
- package/src/primitives/uncle/findBestUncle.ts +8 -0
- package/src/primitives/uncle/findUncles.ts +75 -0
- package/src/primitives/uncle/index.ts +3 -0
- package/src/primitives/uncle/scoreUncle.ts +6 -0
- package/src/provider/DataLake.ts +12 -11
- package/src/provider/XyoConnection.ts +5 -1
- package/src/provider/XyoGatewayRunner.ts +3 -3
- package/src/provider/XyoRunner.ts +6 -2
- package/src/provider/viewer/XyoViewer.ts +16 -15
- package/src/runners/Block.ts +10 -2
- package/src/runners/Mempool.ts +6 -1
- package/src/services/Chain/ChainService.ts +2 -4
- package/src/simple/accountBalance/SimpleAccountBalanceViewer.ts +65 -42
- package/src/simple/block/SimpleBlockViewer.ts +47 -14
- package/src/simple/blockValidation/SimpleBlockValidationViewer.ts +126 -0
- package/src/simple/blockValidation/index.ts +1 -0
- package/src/simple/chainStake/{SimpleChainStakeViewer.ts → SimpleStakeViewer.ts} +11 -16
- package/src/simple/chainStake/index.ts +1 -1
- package/src/simple/datalake/AbstractSimpleDataLake.ts +19 -18
- package/src/simple/datalake/SimpleDataLakeRunner.ts +4 -3
- package/src/simple/datalake/SimpleDataLakeViewer.ts +0 -19
- package/src/simple/index.ts +2 -0
- package/src/simple/mempool/SimpleMempoolRunner.ts +13 -8
- package/src/simple/mempool/SimpleMempoolViewer.ts +6 -1
- package/src/simple/runner/SimpleXyoRunner.ts +41 -16
- package/src/simple/{chainStakeEvents/SimpleChainStakeEventsViewer.ts → stakeEvents/SimpleStakeEventsViewer.ts} +5 -5
- package/src/simple/stakeEvents/index.ts +1 -0
- package/src/simple/timesync/SimpleTimeSyncViewer.ts +27 -6
- package/src/status/RuntimeStatusMonitor.ts +117 -0
- package/src/status/ServiceStatus.ts +20 -0
- package/src/status/index.ts +2 -0
- package/src/summary/model/summary.ts +6 -5
- package/src/summary/primitives/balances/balancesStepSummaryFromRange.ts +2 -3
- package/src/summary/primitives/balances/balancesSummary.ts +12 -12
- package/src/summary/primitives/schemas/schemasSummary.ts +12 -10
- package/src/summary/primitives/transfers/transfersSummary.ts +14 -16
- package/src/transaction/TransactionBuilder.ts +162 -0
- package/src/transaction/buildRandomTransaction.ts +36 -0
- package/src/transaction/hydrateTransaction.ts +1 -1
- package/src/transaction/index.ts +2 -0
- package/src/viewers/AccountBalance.ts +22 -14
- package/src/viewers/Block.ts +6 -1
- package/src/viewers/BlockValidation.ts +47 -0
- package/src/viewers/ChainStakeViewer.ts +1 -2
- package/src/viewers/Fork.ts +0 -1
- package/src/viewers/Stake.ts +0 -1
- package/src/viewers/StakeIntent.ts +2 -2
- package/src/viewers/TransactionValidation.ts +35 -0
- package/src/viewers/index.ts +2 -1
- package/dist/neutral/model/Qualified.d.ts +0 -6
- package/dist/neutral/model/Qualified.d.ts.map +0 -1
- package/dist/neutral/simple/chain/SimpleChainViewer.d.ts +0 -15
- package/dist/neutral/simple/chain/SimpleChainViewer.d.ts.map +0 -1
- package/dist/neutral/simple/chain/index.d.ts +0 -2
- package/dist/neutral/simple/chain/index.d.ts.map +0 -1
- package/dist/neutral/simple/chainStake/SimpleChainStakeViewer.d.ts.map +0 -1
- package/dist/neutral/simple/chainStakeEvents/SimpleChainStakeEventsViewer.d.ts.map +0 -1
- package/dist/neutral/simple/chainStakeEvents/index.d.ts +0 -2
- package/dist/neutral/simple/chainStakeEvents/index.d.ts.map +0 -1
- package/dist/neutral/viewers/Chain.d.ts +0 -11
- package/dist/neutral/viewers/Chain.d.ts.map +0 -1
- package/src/model/Qualified.ts +0 -9
- package/src/simple/chain/SimpleChainViewer.ts +0 -28
- package/src/simple/chain/index.ts +0 -1
- package/src/simple/chainStakeEvents/index.ts +0 -1
- package/src/viewers/Chain.ts +0 -13
package/dist/neutral/index.mjs
CHANGED
|
@@ -118,12 +118,12 @@ var tryHydrateBlock = /* @__PURE__ */ __name(async (archivist, hash, maxDepth =
|
|
|
118
118
|
}, "tryHydrateBlock");
|
|
119
119
|
|
|
120
120
|
// src/block/primitives/blockFromBlockNumber.ts
|
|
121
|
-
import { asHash as asHash3, isDefined as
|
|
121
|
+
import { asHash as asHash3, isDefined as isDefined10 } from "@xylabs/sdk-js";
|
|
122
122
|
import { toSafeJsonString } from "@xylabs/sdk-js";
|
|
123
|
-
import { asSignedBlockBoundWitnessWithStorageMeta, SignedBlockBoundWitnessWithHashMetaZod, StepSizes as
|
|
123
|
+
import { asSignedBlockBoundWitnessWithStorageMeta, SignedBlockBoundWitnessWithHashMetaZod, StepSizes as StepSizes6 } from "@xyo-network/xl1-protocol";
|
|
124
124
|
|
|
125
125
|
// src/model/ChainContext/ChainContext.ts
|
|
126
|
-
import { isDefined as
|
|
126
|
+
import { isDefined as isDefined8, isUndefined as isUndefined2 } from "@xylabs/sdk-js";
|
|
127
127
|
|
|
128
128
|
// src/driver/cache/LruCacheMap.ts
|
|
129
129
|
import { LRUCache } from "lru-cache";
|
|
@@ -211,46 +211,137 @@ var MemoryMap = class {
|
|
|
211
211
|
}
|
|
212
212
|
};
|
|
213
213
|
|
|
214
|
-
// src/primitives/
|
|
215
|
-
import {
|
|
216
|
-
function
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
};
|
|
214
|
+
// src/primitives/block/range/blockRangeSteps.ts
|
|
215
|
+
import { asXL1BlockNumber, StepSizes } from "@xyo-network/xl1-protocol";
|
|
216
|
+
function blockRangeSteps(range, steps) {
|
|
217
|
+
const result = [];
|
|
218
|
+
for (const step of steps) {
|
|
219
|
+
const stepSize2 = StepSizes[step];
|
|
220
|
+
const startOfFirstStepCandidate = range[0] - range[0] % stepSize2 + stepSize2;
|
|
221
|
+
const startOfFirstStep = asXL1BlockNumber(startOfFirstStepCandidate, {
|
|
222
|
+
name: "blockRangeSteps"
|
|
223
|
+
});
|
|
224
|
+
for (let block = startOfFirstStep; block <= range[1]; block = asXL1BlockNumber(block + stepSize2, {
|
|
225
|
+
name: "blockRangeSteps"
|
|
226
|
+
})) {
|
|
227
|
+
result.push({
|
|
228
|
+
step,
|
|
229
|
+
block
|
|
230
|
+
});
|
|
231
|
+
}
|
|
233
232
|
}
|
|
234
|
-
return
|
|
233
|
+
return result;
|
|
235
234
|
}
|
|
236
|
-
__name(
|
|
235
|
+
__name(blockRangeSteps, "blockRangeSteps");
|
|
236
|
+
|
|
237
|
+
// src/primitives/chain/getWindowedChain.ts
|
|
238
|
+
async function getWindowedChain(blockViewer, maxWindowSize, previousChain = []) {
|
|
239
|
+
const newBlocks = [];
|
|
240
|
+
let currentBlock = await blockViewer.currentBlock();
|
|
241
|
+
console.log("[getWindowedChain] Current Block:", currentBlock?.[0]._hash);
|
|
242
|
+
const head = currentBlock;
|
|
243
|
+
while (currentBlock !== null && currentBlock[0].block >= head[0].block) {
|
|
244
|
+
newBlocks.unshift(currentBlock);
|
|
245
|
+
const previousBlockHash = currentBlock[0].previous;
|
|
246
|
+
currentBlock = previousBlockHash === null ? null : await blockViewer.blockByHash(previousBlockHash);
|
|
247
|
+
}
|
|
248
|
+
const newChain = [
|
|
249
|
+
...previousChain,
|
|
250
|
+
...newBlocks
|
|
251
|
+
].slice(-maxWindowSize);
|
|
252
|
+
while (newChain.length > 0 && newChain.length < maxWindowSize && newChain[0][0].previous !== null) {
|
|
253
|
+
const block = await blockViewer.blockByHash(newChain[0][0].previous);
|
|
254
|
+
if (block === null) break;
|
|
255
|
+
newChain.unshift(block);
|
|
256
|
+
}
|
|
257
|
+
return newChain;
|
|
258
|
+
}
|
|
259
|
+
__name(getWindowedChain, "getWindowedChain");
|
|
260
|
+
|
|
261
|
+
// src/primitives/chain/step/chainStepRewardAddress.ts
|
|
262
|
+
import { assertEx as assertEx7, exists, toAddress as toAddress4 } from "@xylabs/sdk-js";
|
|
263
|
+
import { asTransfer, isTransfer, XYO_STEP_REWARD_ADDRESS } from "@xyo-network/xl1-protocol";
|
|
264
|
+
|
|
265
|
+
// src/primitives/payload/mergeTransfers.ts
|
|
266
|
+
import { hexToBigInt, toAddress } from "@xylabs/sdk-js";
|
|
267
|
+
function mergeTransfers(transfers) {
|
|
268
|
+
const result = {};
|
|
269
|
+
for (const transfer of transfers) {
|
|
270
|
+
result[transfer.from] = result[transfer.from] ?? {};
|
|
271
|
+
for (const [to, value] of Object.entries(transfer.transfers)) {
|
|
272
|
+
const typedTo = toAddress(to);
|
|
273
|
+
result[transfer.from][typedTo] = (result[transfer.from][typedTo] ?? 0n) + hexToBigInt(value);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return result;
|
|
277
|
+
}
|
|
278
|
+
__name(mergeTransfers, "mergeTransfers");
|
|
237
279
|
|
|
238
|
-
// src/primitives/
|
|
239
|
-
import {
|
|
240
|
-
import {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
280
|
+
// src/primitives/step/completedStepRewardAddress.ts
|
|
281
|
+
import { toAddress as toAddress2 } from "@xylabs/sdk-js";
|
|
282
|
+
import { StepSizes as StepSizes2 } from "@xyo-network/xl1-protocol";
|
|
283
|
+
import { keccak256 } from "ethers";
|
|
284
|
+
function completedStepRewardAddress({ block, step }) {
|
|
285
|
+
const resolvedStepSize = step < StepSizes2.length ? StepSizes2[step] : step;
|
|
286
|
+
const addressKey = new TextEncoder().encode(`${block}|${resolvedStepSize}`);
|
|
287
|
+
return toAddress2(keccak256(addressKey).slice(-40), {
|
|
288
|
+
prefix: false
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
__name(completedStepRewardAddress, "completedStepRewardAddress");
|
|
292
|
+
|
|
293
|
+
// src/primitives/step/derivedReceiveAddress.ts
|
|
294
|
+
import { toAddress as toAddress3 } from "@xylabs/sdk-js";
|
|
295
|
+
import { isDefined as isDefined2 } from "@xylabs/sdk-js";
|
|
296
|
+
import { keccak256 as keccak2562 } from "ethers";
|
|
297
|
+
function derivedReceiveAddress(address, scope) {
|
|
298
|
+
const addressKey = new TextEncoder().encode(isDefined2(scope) ? `${scope}|${address}` : address);
|
|
299
|
+
return toAddress3(keccak2562(addressKey).slice(-40), {
|
|
300
|
+
prefix: false
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
__name(derivedReceiveAddress, "derivedReceiveAddress");
|
|
304
|
+
|
|
305
|
+
// src/primitives/step/stepBlockRange.ts
|
|
306
|
+
import { asXL1BlockRange, StepSizes as StepSizes3 } from "@xyo-network/xl1-protocol";
|
|
307
|
+
function stepBlockRange({ block, step }) {
|
|
308
|
+
const stepSize2 = StepSizes3[step];
|
|
309
|
+
const start = block - stepSize2;
|
|
310
|
+
return asXL1BlockRange([
|
|
311
|
+
start,
|
|
312
|
+
start + stepSize2 - 1
|
|
313
|
+
], {
|
|
314
|
+
name: "stepBlockRange"
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
__name(stepBlockRange, "stepBlockRange");
|
|
318
|
+
|
|
319
|
+
// src/primitives/step/stepTransferIndex.ts
|
|
320
|
+
import { assertEx as assertEx4 } from "@xylabs/sdk-js";
|
|
321
|
+
import { StepSizes as StepSizes4 } from "@xyo-network/xl1-protocol";
|
|
322
|
+
function stepTransferIndex(block, step) {
|
|
323
|
+
let rewardTransferCount = 0;
|
|
324
|
+
let rewardTransferIndex = -1;
|
|
325
|
+
for (let i = 3; i < StepSizes4.length; i++) {
|
|
326
|
+
const stepSize2 = StepSizes4[i];
|
|
327
|
+
if (block % stepSize2 === 0) {
|
|
328
|
+
if (stepSize2 === StepSizes4[step]) {
|
|
329
|
+
rewardTransferIndex = rewardTransferCount;
|
|
330
|
+
}
|
|
331
|
+
rewardTransferCount++;
|
|
245
332
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
333
|
+
}
|
|
334
|
+
assertEx4(rewardTransferIndex >= 0, () => `Could not find step size for step ${step} at block ${block}`);
|
|
335
|
+
return [
|
|
336
|
+
rewardTransferIndex,
|
|
337
|
+
rewardTransferCount
|
|
338
|
+
];
|
|
339
|
+
}
|
|
340
|
+
__name(stepTransferIndex, "stepTransferIndex");
|
|
341
|
+
|
|
342
|
+
// src/primitives/chain/step/stepRewardBlock.ts
|
|
343
|
+
import { assertEx as assertEx6 } from "@xylabs/sdk-js";
|
|
344
|
+
import { StepSizes as StepSizes5 } from "@xyo-network/xl1-protocol";
|
|
254
345
|
|
|
255
346
|
// src/primitives/state/findMostRecentBlock.ts
|
|
256
347
|
import { isSignedBlockBoundWitnessWithStorageMeta } from "@xyo-network/xl1-protocol";
|
|
@@ -282,80 +373,534 @@ var findMostRecentBlock = /* @__PURE__ */ __name(async (chainArchivist, nextOpti
|
|
|
282
373
|
}, "findMostRecentBlock");
|
|
283
374
|
|
|
284
375
|
// src/primitives/state/hydratedBlockByNumber.ts
|
|
285
|
-
import { assertEx as
|
|
376
|
+
import { assertEx as assertEx5 } from "@xylabs/sdk-js";
|
|
286
377
|
async function hydratedBlockByNumber(context, blockNumber) {
|
|
287
378
|
if (blockNumber < 0) throw new Error(`Block number ${blockNumber} is less than 0`);
|
|
288
379
|
if (blockNumber > Number.MAX_SAFE_INTEGER) throw new Error(`Block number ${blockNumber} is greater than the maximum safe integer`);
|
|
289
380
|
if (blockNumber % 1 !== 0) throw new Error(`Block number ${blockNumber} is not an integer`);
|
|
290
381
|
const cacheKey = `${blockNumber}`;
|
|
291
382
|
return await withContextCacheResponse(context, "hydratedBlockByNumber", cacheKey, async () => {
|
|
292
|
-
const block =
|
|
383
|
+
const block = assertEx5(await blockFromBlockNumber(context, blockNumber), () => `Could not find block for block number ${blockNumber}`);
|
|
293
384
|
return await hydrateBlock(context.store, block._hash);
|
|
294
385
|
});
|
|
295
386
|
}
|
|
296
387
|
__name(hydratedBlockByNumber, "hydratedBlockByNumber");
|
|
297
388
|
|
|
298
|
-
// src/primitives/step/
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
389
|
+
// src/primitives/chain/step/stepRewardBlock.ts
|
|
390
|
+
async function stepRewardBlock(context, { block, step }) {
|
|
391
|
+
assertEx6(block % StepSizes5[step] === 0, () => `Block must be the first block of the step [${StepSizes5[step]}], got ${block}`);
|
|
392
|
+
return assertEx6(await hydratedBlockByNumber(context, block), () => `Could not find block for block number ${block}`);
|
|
393
|
+
}
|
|
394
|
+
__name(stepRewardBlock, "stepRewardBlock");
|
|
395
|
+
|
|
396
|
+
// src/primitives/chain/step/chainStepRewardAddress.ts
|
|
397
|
+
async function chainStepRewardAddress(context, { block, step }) {
|
|
398
|
+
const hydratedBlock = await stepRewardBlock(context, {
|
|
399
|
+
block,
|
|
400
|
+
step
|
|
307
401
|
});
|
|
402
|
+
const [transferIndex, transferCount] = stepTransferIndex(block, step);
|
|
403
|
+
const [blockBw, payloads] = hydratedBlock;
|
|
404
|
+
const transfersFromPool = payloads.filter(isTransfer).map((p) => asTransfer(p)).filter(exists).filter((t) => t.from === XYO_STEP_REWARD_ADDRESS);
|
|
405
|
+
const fromEntries = Object.entries(mergeTransfers(transfersFromPool)[XYO_STEP_REWARD_ADDRESS]);
|
|
406
|
+
const sortedTransferAmounts = fromEntries.toSorted(([, a], [, b]) => a > b ? -1 : a < b ? 1 : 0);
|
|
407
|
+
assertEx7(sortedTransferAmounts.length === transferCount, () => `Step Transfers mismatch ${block} (${blockBw._hash}) [${sortedTransferAmounts.length} - ${transferCount}]`);
|
|
408
|
+
return toAddress4(sortedTransferAmounts[transferIndex][0]);
|
|
308
409
|
}
|
|
309
|
-
__name(
|
|
410
|
+
__name(chainStepRewardAddress, "chainStepRewardAddress");
|
|
310
411
|
|
|
311
|
-
// src/primitives/step/
|
|
312
|
-
import {
|
|
313
|
-
import {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
412
|
+
// src/primitives/chain/step/stepRewardTotal.ts
|
|
413
|
+
import { assertEx as assertEx8, isDefined as isDefined3 } from "@xylabs/sdk-js";
|
|
414
|
+
import { asAttoXL1, asXL1BlockRange as asXL1BlockRange2, isTransfer as isTransfer5, XYO_STEP_REWARD_ADDRESS as XYO_STEP_REWARD_ADDRESS2 } from "@xyo-network/xl1-protocol";
|
|
415
|
+
|
|
416
|
+
// src/payloads/AddressPairPayload.ts
|
|
417
|
+
import { AsObjectFactory } from "@xylabs/sdk-js";
|
|
418
|
+
import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
|
|
419
|
+
var AddressPairSchema = "network.xyo.address.pair";
|
|
420
|
+
var isAddressPairPayload = isPayloadOfSchemaType(AddressPairSchema);
|
|
421
|
+
var asAddressPairPayload = AsObjectFactory.create(isAddressPairPayload);
|
|
422
|
+
var asOptionalAddressPairPayload = AsObjectFactory.createOptional(isAddressPairPayload);
|
|
423
|
+
|
|
424
|
+
// src/payloads/netBalancesForPayloads.ts
|
|
425
|
+
import { hexToBigInt as hexToBigInt2, toAddress as toAddress5 } from "@xylabs/sdk-js";
|
|
426
|
+
import { span } from "@xylabs/sdk-js";
|
|
427
|
+
import { isTransfer as isTransfer2 } from "@xyo-network/xl1-protocol";
|
|
428
|
+
var netBalancesForPayloads = /* @__PURE__ */ __name((payloads) => {
|
|
429
|
+
return span("netBalancesForPayloads", () => {
|
|
430
|
+
const balances = {};
|
|
431
|
+
for (const payload of payloads) {
|
|
432
|
+
if (isTransfer2(payload)) {
|
|
433
|
+
const { from } = payload;
|
|
434
|
+
for (let [address, amount] of Object.entries(payload.transfers)) {
|
|
435
|
+
balances[toAddress5(address)] = (balances[toAddress5(address)] ?? 0n) + hexToBigInt2(amount);
|
|
436
|
+
balances[toAddress5(from)] = (balances[toAddress5(from)] ?? 0n) - hexToBigInt2(amount);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
return balances;
|
|
441
|
+
});
|
|
442
|
+
}, "netBalancesForPayloads");
|
|
443
|
+
|
|
444
|
+
// src/payloads/netSchemasForPayloads.ts
|
|
445
|
+
import { hexToBigInt as hexToBigInt3, toAddress as toAddress6 } from "@xylabs/sdk-js";
|
|
446
|
+
import { span as span2 } from "@xylabs/sdk-js";
|
|
447
|
+
import { isTransfer as isTransfer3 } from "@xyo-network/xl1-protocol";
|
|
448
|
+
var netSchemasForPayloads = /* @__PURE__ */ __name((payloads) => {
|
|
449
|
+
return span2("netSchemasForPayloads", () => {
|
|
450
|
+
const balances = {};
|
|
451
|
+
for (const payload of payloads) {
|
|
452
|
+
if (isTransfer3(payload)) {
|
|
453
|
+
const { from } = payload;
|
|
454
|
+
for (let [address, amount] of Object.entries(payload.transfers)) {
|
|
455
|
+
balances[toAddress6(address)] = (balances[toAddress6(address)] ?? 0n) + hexToBigInt3(amount);
|
|
456
|
+
balances[toAddress6(from)] = (balances[toAddress6(from)] ?? 0n) - hexToBigInt3(amount);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
return balances;
|
|
461
|
+
});
|
|
462
|
+
}, "netSchemasForPayloads");
|
|
463
|
+
|
|
464
|
+
// src/payloads/netTransfersForPayloads.ts
|
|
465
|
+
import { hexToBigInt as hexToBigInt4 } from "@xylabs/sdk-js";
|
|
466
|
+
import { span as span3 } from "@xylabs/sdk-js";
|
|
467
|
+
import { isTransfer as isTransfer4 } from "@xyo-network/xl1-protocol";
|
|
468
|
+
function netTransfersForPayloads(payloads) {
|
|
469
|
+
return span3("netTransfersForPayloads", () => {
|
|
470
|
+
const transfers = {};
|
|
471
|
+
for (const payload of payloads) {
|
|
472
|
+
if (isTransfer4(payload)) {
|
|
473
|
+
const { from } = payload;
|
|
474
|
+
transfers[from] = transfers[from] ?? {};
|
|
475
|
+
for (let [to, amount] of Object.entries(payload.transfers)) {
|
|
476
|
+
transfers[to] = transfers[to] ?? {};
|
|
477
|
+
transfers[to][from] = (transfers[to][from] ?? 0n) + hexToBigInt4(amount);
|
|
478
|
+
transfers[from][to] = (transfers[from][to] ?? 0n) - hexToBigInt4(amount);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
return transfers;
|
|
319
483
|
});
|
|
320
484
|
}
|
|
321
|
-
__name(
|
|
485
|
+
__name(netTransfersForPayloads, "netTransfersForPayloads");
|
|
322
486
|
|
|
323
|
-
// src/primitives/step/
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
487
|
+
// src/primitives/chain/step/stepRewardTotal.ts
|
|
488
|
+
function stepInRange(step, range) {
|
|
489
|
+
const stepRange = stepBlockRange(step);
|
|
490
|
+
return stepRange[0] >= range[0] && stepRange[1] <= range[1];
|
|
491
|
+
}
|
|
492
|
+
__name(stepInRange, "stepInRange");
|
|
493
|
+
async function stepRewardTotal(context, { block, step }, multipliers) {
|
|
494
|
+
const cacheKey = `${block}|${step}|${isDefined3(multipliers)}`;
|
|
495
|
+
return await withContextCacheResponse(context, "stepRewardTotal", cacheKey, async () => {
|
|
496
|
+
const [blockBw, payloads] = await stepRewardBlock(context, {
|
|
497
|
+
block,
|
|
498
|
+
step
|
|
499
|
+
});
|
|
500
|
+
assertEx8(blockBw.block === block, () => `Block Mismatch: expected ${block}, got ${blockBw.block}`);
|
|
501
|
+
const [transferIndex] = stepTransferIndex(block, step);
|
|
502
|
+
const stepTransfer = assertEx8(payloads.find((p) => isTransfer5(p) && p.from === XYO_STEP_REWARD_ADDRESS2), () => `No step transfer found for step ${step} at block ${block} (${blockBw._hash})`);
|
|
503
|
+
const rewards = assertEx8(netTransfersForPayloads([
|
|
504
|
+
stepTransfer
|
|
505
|
+
])[XYO_STEP_REWARD_ADDRESS2], () => `No rewards found for step reward address ${XYO_STEP_REWARD_ADDRESS2} at block ${block} (${blockBw._hash})`);
|
|
506
|
+
const sortedTransfers = Object.entries(rewards).toSorted(([, a], [, b]) => a > b ? -1 : a < b ? 1 : 0);
|
|
507
|
+
let result = asAttoXL1(sortedTransfers[transferIndex][1] * -1n);
|
|
508
|
+
for (const [rangeKey, [numerator, denominator]] of Object.entries(multipliers)) {
|
|
509
|
+
const rangeParts = rangeKey.split("|").map(Number);
|
|
510
|
+
const range = asXL1BlockRange2([
|
|
511
|
+
rangeParts[0],
|
|
512
|
+
rangeParts[1]
|
|
513
|
+
], {
|
|
514
|
+
name: "stepRewardTotal"
|
|
515
|
+
});
|
|
516
|
+
if (stepInRange({
|
|
517
|
+
block,
|
|
518
|
+
step
|
|
519
|
+
}, range)) {
|
|
520
|
+
result = asAttoXL1(result + result * numerator / denominator);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
return result;
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
__name(stepRewardTotal, "stepRewardTotal");
|
|
527
|
+
|
|
528
|
+
// src/primitives/chain/step/stepsRewardTotal.ts
|
|
529
|
+
import { asAttoXL1 as asAttoXL12, asXL1BlockRange as asXL1BlockRange3 } from "@xyo-network/xl1-protocol";
|
|
530
|
+
|
|
531
|
+
// src/constants.ts
|
|
532
|
+
var XL1_NETWORK_STAKING_GENESIS_PERIOD_END_EPOCH = 1760572800;
|
|
533
|
+
var XL1_NETWORK_STAKING_GENESIS_PERIOD_END_XL1_BLOCK = 107496;
|
|
534
|
+
|
|
535
|
+
// src/primitives/chain/step/stepsRewardTotal.ts
|
|
536
|
+
async function stepsRewardTotalGenesisPeriod(context, multipliers, stepSizes) {
|
|
537
|
+
const range = asXL1BlockRange3([
|
|
538
|
+
0,
|
|
539
|
+
XL1_NETWORK_STAKING_GENESIS_PERIOD_END_XL1_BLOCK
|
|
331
540
|
], {
|
|
332
|
-
name: "
|
|
541
|
+
name: "stepsRewardTotalGenesisPeriod"
|
|
333
542
|
});
|
|
543
|
+
return await stepsRewardTotalRange(context, range, stepSizes, multipliers);
|
|
334
544
|
}
|
|
335
|
-
__name(
|
|
545
|
+
__name(stepsRewardTotalGenesisPeriod, "stepsRewardTotalGenesisPeriod");
|
|
546
|
+
async function stepsRewardTotalRange(context, range, stepSizes = [
|
|
547
|
+
3,
|
|
548
|
+
4,
|
|
549
|
+
5,
|
|
550
|
+
6
|
|
551
|
+
], multipliers) {
|
|
552
|
+
const steps = blockRangeSteps(range, stepSizes);
|
|
553
|
+
return await stepsRewardTotal(context, steps, multipliers);
|
|
554
|
+
}
|
|
555
|
+
__name(stepsRewardTotalRange, "stepsRewardTotalRange");
|
|
556
|
+
async function stepsRewardTotal(context, steps, multipliers) {
|
|
557
|
+
let totalRewards = 0n;
|
|
558
|
+
for (const step of steps) {
|
|
559
|
+
const stepTotal = await stepRewardTotal(context, step, multipliers);
|
|
560
|
+
totalRewards += stepTotal;
|
|
561
|
+
}
|
|
562
|
+
return asAttoXL12(totalRewards);
|
|
563
|
+
}
|
|
564
|
+
__name(stepsRewardTotal, "stepsRewardTotal");
|
|
565
|
+
|
|
566
|
+
// src/primitives/chain/time/externalBlockNumberFromXL1BlockNumber.ts
|
|
567
|
+
import { assertEx as assertEx9, isArray } from "@xylabs/sdk-js";
|
|
568
|
+
import { asBlockNumber, asTimePayload, isTimePayload } from "@xyo-network/xl1-protocol";
|
|
569
|
+
var functionName = "externalBlockNumberFromXL1BlockNumber";
|
|
570
|
+
async function externalBlockNumberFromXL1BlockNumber(context, blockViewer, xl1BlockNumber, externalTimeName, externalGenesisTime, timeBudgetMs = 2e3) {
|
|
571
|
+
const cacheKey = `${xl1BlockNumber}-${externalTimeName}-${externalGenesisTime ?? "default"}`;
|
|
572
|
+
return await withContextCacheResponse(context, functionName, cacheKey, async () => {
|
|
573
|
+
const [, payloads = []] = await blockViewer.blockByNumber(xl1BlockNumber) ?? [];
|
|
574
|
+
assertEx9(isArray(payloads));
|
|
575
|
+
const timePayload = asTimePayload(payloads.find(isTimePayload));
|
|
576
|
+
return asBlockNumber(timePayload?.[externalTimeName] ?? externalGenesisTime ?? 23372716, {
|
|
577
|
+
name: functionName
|
|
578
|
+
});
|
|
579
|
+
}, {
|
|
580
|
+
timeBudgetMs
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
__name(externalBlockNumberFromXL1BlockNumber, "externalBlockNumberFromXL1BlockNumber");
|
|
336
584
|
|
|
337
|
-
// src/primitives/
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
585
|
+
// src/primitives/chain/time/externalBlockRangeFromXL1BlockRange.ts
|
|
586
|
+
async function externalBlockRangeFromXL1BlockRange(context, blockViewer, xl1BlockRange, externalTimeName = "ethereum") {
|
|
587
|
+
const start = await externalBlockNumberFromXL1BlockNumber(context, blockViewer, xl1BlockRange[0], externalTimeName);
|
|
588
|
+
const end = await externalBlockNumberFromXL1BlockNumber(context, blockViewer, xl1BlockRange[1], externalTimeName);
|
|
589
|
+
return [
|
|
590
|
+
start,
|
|
591
|
+
end
|
|
592
|
+
];
|
|
593
|
+
}
|
|
594
|
+
__name(externalBlockRangeFromXL1BlockRange, "externalBlockRangeFromXL1BlockRange");
|
|
595
|
+
|
|
596
|
+
// src/primitives/chain/time/externalBlockRangeFromStep.ts
|
|
597
|
+
async function externalBlockRangeFromStep(context, blockViewer, stepIdentity) {
|
|
598
|
+
const cacheKey = toStepIdentityString(stepIdentity);
|
|
599
|
+
return await withContextCacheResponse(context, "externalBlockRangeFromStep", cacheKey, async () => {
|
|
600
|
+
const xl1BlockRange = stepBlockRange(stepIdentity);
|
|
601
|
+
return await externalBlockRangeFromXL1BlockRange(context, blockViewer, xl1BlockRange);
|
|
602
|
+
}, {
|
|
603
|
+
timeBudgetMs: 1e3
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
__name(externalBlockRangeFromStep, "externalBlockRangeFromStep");
|
|
607
|
+
|
|
608
|
+
// src/primitives/mapToMapType.ts
|
|
609
|
+
import { isDefined as isDefined4 } from "@xylabs/sdk-js";
|
|
610
|
+
function mapToMapType(map) {
|
|
611
|
+
return {
|
|
612
|
+
get: /* @__PURE__ */ __name((key) => map.get(key), "get"),
|
|
613
|
+
has: /* @__PURE__ */ __name((key) => map.has(key), "has"),
|
|
614
|
+
set: /* @__PURE__ */ __name((key, value) => {
|
|
615
|
+
map.set(key, value);
|
|
616
|
+
}, "set"),
|
|
617
|
+
setMany: /* @__PURE__ */ __name((entries) => {
|
|
618
|
+
for (const [key, value] of entries) {
|
|
619
|
+
map.set(key, value);
|
|
620
|
+
}
|
|
621
|
+
}, "setMany"),
|
|
622
|
+
delete: /* @__PURE__ */ __name((key) => map.delete(key), "delete"),
|
|
623
|
+
clear: /* @__PURE__ */ __name(() => map.clear(), "clear"),
|
|
624
|
+
getMany: /* @__PURE__ */ __name((keys) => {
|
|
625
|
+
const result = [];
|
|
626
|
+
for (const key of keys) {
|
|
627
|
+
const value = map.get(key);
|
|
628
|
+
if (isDefined4(value)) {
|
|
629
|
+
result.push(value);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
return result;
|
|
633
|
+
}, "getMany"),
|
|
634
|
+
[Symbol.iterator]: function* () {
|
|
635
|
+
for (const entry of map) {
|
|
636
|
+
yield entry;
|
|
348
637
|
}
|
|
349
|
-
rewardTransferCount++;
|
|
350
638
|
}
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
__name(mapToMapType, "mapToMapType");
|
|
642
|
+
|
|
643
|
+
// src/primitives/readPayloadMapFromStore.ts
|
|
644
|
+
import { isDefined as isDefined5 } from "@xylabs/sdk-js";
|
|
645
|
+
function readPayloadMapFromStore(store) {
|
|
646
|
+
if (isReadArchivist(store)) {
|
|
647
|
+
return {
|
|
648
|
+
get: /* @__PURE__ */ __name(async (hash) => {
|
|
649
|
+
return (await store.get([
|
|
650
|
+
hash
|
|
651
|
+
]))[0];
|
|
652
|
+
}, "get"),
|
|
653
|
+
getMany: /* @__PURE__ */ __name(async (hashes) => {
|
|
654
|
+
return await store.get(hashes);
|
|
655
|
+
}, "getMany"),
|
|
656
|
+
has: /* @__PURE__ */ __name(async (hash) => {
|
|
657
|
+
return isDefined5((await store.get([
|
|
658
|
+
hash
|
|
659
|
+
]))[0]);
|
|
660
|
+
}, "has")
|
|
661
|
+
};
|
|
351
662
|
}
|
|
352
|
-
|
|
353
|
-
return [
|
|
354
|
-
rewardTransferIndex,
|
|
355
|
-
rewardTransferCount
|
|
356
|
-
];
|
|
663
|
+
return store;
|
|
357
664
|
}
|
|
358
|
-
__name(
|
|
665
|
+
__name(readPayloadMapFromStore, "readPayloadMapFromStore");
|
|
666
|
+
function payloadMapFromStore(store) {
|
|
667
|
+
if (isReadWriteArchivist(store)) {
|
|
668
|
+
return {
|
|
669
|
+
get: /* @__PURE__ */ __name(async (hash) => {
|
|
670
|
+
return (await store.get([
|
|
671
|
+
hash
|
|
672
|
+
]))[0];
|
|
673
|
+
}, "get"),
|
|
674
|
+
getMany: /* @__PURE__ */ __name(async (hashes) => {
|
|
675
|
+
return await store.get(hashes);
|
|
676
|
+
}, "getMany"),
|
|
677
|
+
has: /* @__PURE__ */ __name(async (hash) => {
|
|
678
|
+
return isDefined5((await store.get([
|
|
679
|
+
hash
|
|
680
|
+
]))[0]);
|
|
681
|
+
}, "has"),
|
|
682
|
+
clear: /* @__PURE__ */ __name(async () => {
|
|
683
|
+
return await store.clear();
|
|
684
|
+
}, "clear"),
|
|
685
|
+
delete: /* @__PURE__ */ __name(async (id) => {
|
|
686
|
+
await store.delete([
|
|
687
|
+
id
|
|
688
|
+
]);
|
|
689
|
+
return true;
|
|
690
|
+
}, "delete"),
|
|
691
|
+
set: /* @__PURE__ */ __name(async (_id, data) => {
|
|
692
|
+
await store.insert([
|
|
693
|
+
data
|
|
694
|
+
]);
|
|
695
|
+
}, "set"),
|
|
696
|
+
setMany: /* @__PURE__ */ __name(async (entries) => {
|
|
697
|
+
await store.insert(entries.map((e) => e[1]));
|
|
698
|
+
}, "setMany")
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
return store;
|
|
702
|
+
}
|
|
703
|
+
__name(payloadMapFromStore, "payloadMapFromStore");
|
|
704
|
+
|
|
705
|
+
// src/primitives/rewardFromBlockNumber.ts
|
|
706
|
+
import { toFixedPoint } from "@xylabs/sdk-js";
|
|
707
|
+
import { asAttoXL1 as asAttoXL13 } from "@xyo-network/xl1-protocol";
|
|
708
|
+
var rewardFromBlockNumber = /* @__PURE__ */ __name((places = 18) => {
|
|
709
|
+
return (blockNumber, startingReward = asAttoXL13(toFixedPoint(500n, places)), blocksPerStep = 1e6, stepFactorNumerator = 95n, stepFactorDenominator = 100n, minBlockReward = asAttoXL13(toFixedPoint(10n, places)), creatorReward = asAttoXL13(toFixedPoint(20000000000n, places))) => {
|
|
710
|
+
if (blockNumber === 0) {
|
|
711
|
+
return creatorReward;
|
|
712
|
+
}
|
|
713
|
+
const step = Math.floor((blockNumber + blocksPerStep) / blocksPerStep);
|
|
714
|
+
const stepExp = BigInt(step - 1);
|
|
715
|
+
const poweredNumerator = stepExp > 0 ? stepFactorNumerator ** stepExp : 1n;
|
|
716
|
+
const poweredDenominator = stepExp > 0 ? stepFactorDenominator ** stepExp : 1n;
|
|
717
|
+
let reward = startingReward * poweredNumerator / poweredDenominator;
|
|
718
|
+
return asAttoXL13(reward < minBlockReward ? minBlockReward : reward);
|
|
719
|
+
};
|
|
720
|
+
}, "rewardFromBlockNumber");
|
|
721
|
+
|
|
722
|
+
// src/primitives/stake/activeStakeAtTimeByAddress.ts
|
|
723
|
+
import { isDefined as isDefined6 } from "@xylabs/sdk-js";
|
|
724
|
+
|
|
725
|
+
// src/primitives/stake/mergedAddRemoveStakeEventsByStaker.ts
|
|
726
|
+
async function mergedAddRemoveStakeEventsByStaker(chainEvents, range, staked, staker) {
|
|
727
|
+
const [addedEvents, removedEvents] = await Promise.all([
|
|
728
|
+
chainEvents.stakeEvents(range, {
|
|
729
|
+
name: "StakeAdded",
|
|
730
|
+
args: {
|
|
731
|
+
staked,
|
|
732
|
+
staker
|
|
733
|
+
}
|
|
734
|
+
}),
|
|
735
|
+
chainEvents.stakeEvents(range, {
|
|
736
|
+
name: "StakeRemoved",
|
|
737
|
+
args: {
|
|
738
|
+
staked,
|
|
739
|
+
staker
|
|
740
|
+
}
|
|
741
|
+
})
|
|
742
|
+
]);
|
|
743
|
+
const result = [
|
|
744
|
+
...addedEvents,
|
|
745
|
+
...removedEvents
|
|
746
|
+
].toSorted((a, b) => a.time - b.time);
|
|
747
|
+
return result;
|
|
748
|
+
}
|
|
749
|
+
__name(mergedAddRemoveStakeEventsByStaker, "mergedAddRemoveStakeEventsByStaker");
|
|
750
|
+
|
|
751
|
+
// src/primitives/stake/activeStakeAtTimeByAddress.ts
|
|
752
|
+
async function activeStakeAtTimeByAddress(chain, staked, time, staker) {
|
|
753
|
+
const stakeEvents = (await mergedAddRemoveStakeEventsByStaker(chain, [
|
|
754
|
+
0,
|
|
755
|
+
time
|
|
756
|
+
], staked, staker)).toSorted((a, b) => a.time - b.time);
|
|
757
|
+
let result = 0n;
|
|
758
|
+
for (const event of stakeEvents) {
|
|
759
|
+
if (event.time > time) break;
|
|
760
|
+
if (event.args.staked !== staked) continue;
|
|
761
|
+
if (isDefined6(staker) && event.args.staker !== staker) continue;
|
|
762
|
+
if (event.name === "StakeAdded") {
|
|
763
|
+
result += event.args.amount;
|
|
764
|
+
} else if (event.name === "StakeRemoved") {
|
|
765
|
+
result -= event.args.amount;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
return result;
|
|
769
|
+
}
|
|
770
|
+
__name(activeStakeAtTimeByAddress, "activeStakeAtTimeByAddress");
|
|
771
|
+
|
|
772
|
+
// src/primitives/stake/activeStakeAtTimeByPosition.ts
|
|
773
|
+
import { isUndefined } from "@xylabs/sdk-js";
|
|
774
|
+
|
|
775
|
+
// src/primitives/stake/mergedAddRemoveStakeEventsByPosition.ts
|
|
776
|
+
async function mergedAddRemoveStakeEventsByPosition(chainEvents, range, position) {
|
|
777
|
+
const [addedEvents, removedEvents] = await Promise.all([
|
|
778
|
+
chainEvents.stakeEvents(range, {
|
|
779
|
+
name: "StakeAdded",
|
|
780
|
+
args: {
|
|
781
|
+
id: position
|
|
782
|
+
}
|
|
783
|
+
}),
|
|
784
|
+
chainEvents.stakeEvents(range, {
|
|
785
|
+
name: "StakeRemoved",
|
|
786
|
+
args: {
|
|
787
|
+
id: position
|
|
788
|
+
}
|
|
789
|
+
})
|
|
790
|
+
]);
|
|
791
|
+
const result = [
|
|
792
|
+
...addedEvents,
|
|
793
|
+
...removedEvents
|
|
794
|
+
].toSorted((a, b) => a.time - b.time);
|
|
795
|
+
return result;
|
|
796
|
+
}
|
|
797
|
+
__name(mergedAddRemoveStakeEventsByPosition, "mergedAddRemoveStakeEventsByPosition");
|
|
798
|
+
|
|
799
|
+
// src/primitives/stake/activeStakeAtTimeByPosition.ts
|
|
800
|
+
async function activeStakeAtTimeByPosition(chainStakeEvents, externalTime, position) {
|
|
801
|
+
const stakeEvents = (await mergedAddRemoveStakeEventsByPosition(chainStakeEvents, [
|
|
802
|
+
0,
|
|
803
|
+
externalTime
|
|
804
|
+
], position)).toSorted((a, b) => a.time - b.time);
|
|
805
|
+
let result = 0n;
|
|
806
|
+
for (const event of stakeEvents) {
|
|
807
|
+
if (event.time > externalTime) break;
|
|
808
|
+
if (isUndefined(position) || position === Number(event.args.id)) {
|
|
809
|
+
if (event.name === "StakeAdded") {
|
|
810
|
+
result += event.args.amount;
|
|
811
|
+
} else if (event.name === "StakeRemoved") {
|
|
812
|
+
result -= event.args.amount;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
return result;
|
|
817
|
+
}
|
|
818
|
+
__name(activeStakeAtTimeByPosition, "activeStakeAtTimeByPosition");
|
|
819
|
+
|
|
820
|
+
// src/primitives/stake/allStakersForRange.ts
|
|
821
|
+
import { toAddress as toAddress7 } from "@xylabs/sdk-js";
|
|
822
|
+
async function allStakersForRange(chain, externalRange, staked) {
|
|
823
|
+
const mergedEvents = await mergedAddRemoveStakeEventsByStaker(chain, [
|
|
824
|
+
0,
|
|
825
|
+
externalRange[1]
|
|
826
|
+
], staked);
|
|
827
|
+
const resultWithZeros = {};
|
|
828
|
+
for (const event of mergedEvents) {
|
|
829
|
+
const staker = toAddress7(event.args.staker);
|
|
830
|
+
resultWithZeros[staker] = resultWithZeros[staker] ?? 0n;
|
|
831
|
+
if (event.name === "StakeAdded") {
|
|
832
|
+
resultWithZeros[staker] += event.args.amount;
|
|
833
|
+
} else if (event.name === "StakeRemoved") {
|
|
834
|
+
resultWithZeros[staker] -= event.args.amount;
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
const nonZero = Object.entries(resultWithZeros).filter(([, amount]) => amount > 0n).map(([address]) => address);
|
|
838
|
+
const result = {};
|
|
839
|
+
for (const address of nonZero) {
|
|
840
|
+
result[toAddress7(address)] = resultWithZeros[toAddress7(address)];
|
|
841
|
+
}
|
|
842
|
+
return result;
|
|
843
|
+
}
|
|
844
|
+
__name(allStakersForRange, "allStakersForRange");
|
|
845
|
+
|
|
846
|
+
// src/primitives/stake/allStakersForStep.ts
|
|
847
|
+
async function allStakersForStep(context, blockViewer, stepContext, staked) {
|
|
848
|
+
const xl1BlockRange = stepBlockRange(stepContext);
|
|
849
|
+
return await allStakersForRange(context.stake.stakeEvents, await externalBlockRangeFromXL1BlockRange(context, blockViewer, xl1BlockRange), staked);
|
|
850
|
+
}
|
|
851
|
+
__name(allStakersForStep, "allStakersForStep");
|
|
852
|
+
|
|
853
|
+
// src/primitives/stake/weightedStakeForRangeByPosition.ts
|
|
854
|
+
import { isDefined as isDefined7 } from "@xylabs/sdk-js";
|
|
855
|
+
import { asBlockNumber as asBlockNumber2 } from "@xyo-network/xl1-protocol";
|
|
856
|
+
async function weightedStakeForRangeByPosition(context, blockViewer, externalRange, positionId) {
|
|
857
|
+
const cacheKey = isDefined7(positionId) ? `${externalRange[0]}-${externalRange[1]}-${positionId}` : `${externalRange[0]}-${externalRange[1]}-all`;
|
|
858
|
+
return await withContextCacheResponse(context, "weightedStakeForRangeByPosition", cacheKey, async () => {
|
|
859
|
+
let weightedStakeSum = 0n;
|
|
860
|
+
if (isDefined7(positionId)) {
|
|
861
|
+
const mergedEvents = (await mergedAddRemoveStakeEventsByPosition(context.stake.stakeEvents, [
|
|
862
|
+
0,
|
|
863
|
+
externalRange[1]
|
|
864
|
+
], positionId)).toSorted((a, b) => a.time - b.time);
|
|
865
|
+
let currentTime = externalRange[0];
|
|
866
|
+
let currentStake = 0n;
|
|
867
|
+
for (const event of mergedEvents) {
|
|
868
|
+
if (event.time > currentTime) {
|
|
869
|
+
weightedStakeSum += currentStake * BigInt(event.time - currentTime);
|
|
870
|
+
}
|
|
871
|
+
if (event.name === "StakeAdded") {
|
|
872
|
+
currentStake += event.args.amount;
|
|
873
|
+
} else if (event.name === "StakeRemoved") {
|
|
874
|
+
currentStake -= event.args.amount;
|
|
875
|
+
}
|
|
876
|
+
currentStake = currentStake < 0n ? 0n : currentStake;
|
|
877
|
+
currentTime = asBlockNumber2(event.time, {
|
|
878
|
+
name: "weightedStakeForRangeByPosition"
|
|
879
|
+
});
|
|
880
|
+
if (currentTime > externalRange[1]) {
|
|
881
|
+
break;
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
if (externalRange[1] > currentTime) {
|
|
885
|
+
weightedStakeSum += currentStake * BigInt(externalRange[1] - currentTime);
|
|
886
|
+
}
|
|
887
|
+
} else {
|
|
888
|
+
const positionCount = await context.stake.stakeEvents.positionCount(externalRange);
|
|
889
|
+
for (let pos = 0; pos < positionCount; pos++) {
|
|
890
|
+
weightedStakeSum += await weightedStakeForRangeByPosition(context, blockViewer, externalRange, pos);
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
return weightedStakeSum;
|
|
894
|
+
});
|
|
895
|
+
}
|
|
896
|
+
__name(weightedStakeForRangeByPosition, "weightedStakeForRangeByPosition");
|
|
897
|
+
|
|
898
|
+
// src/primitives/rewards/networkStakeStepRewardPositionWeight.ts
|
|
899
|
+
async function networkStakeStepRewardPositionWeight(context, blockViewer, stepContext, position) {
|
|
900
|
+
const result = await weightedStakeForRangeByPosition(context, blockViewer, await externalBlockRangeFromStep(context, blockViewer, stepContext), position);
|
|
901
|
+
return result;
|
|
902
|
+
}
|
|
903
|
+
__name(networkStakeStepRewardPositionWeight, "networkStakeStepRewardPositionWeight");
|
|
359
904
|
|
|
360
905
|
// src/primitives/timeBudget.ts
|
|
361
906
|
async function timeBudget(name, logger, func, budget, status = false) {
|
|
@@ -400,12 +945,89 @@ function elevatedPayloads([tx, payloads]) {
|
|
|
400
945
|
}
|
|
401
946
|
__name(elevatedPayloads, "elevatedPayloads");
|
|
402
947
|
|
|
948
|
+
// src/primitives/uncle/scoreUncle.ts
|
|
949
|
+
function scoreUncle(finalizedWindowedChain, blocks) {
|
|
950
|
+
return blocks.length;
|
|
951
|
+
}
|
|
952
|
+
__name(scoreUncle, "scoreUncle");
|
|
953
|
+
|
|
954
|
+
// src/primitives/uncle/findBestUncle.ts
|
|
955
|
+
function findBestUncle(finalizedWindowedChain, uncles) {
|
|
956
|
+
const scores = uncles.map((uncle) => [
|
|
957
|
+
scoreUncle(finalizedWindowedChain, uncle),
|
|
958
|
+
uncle
|
|
959
|
+
]).toSorted((a, b) => b[0] - a[0]);
|
|
960
|
+
return scores[0]?.[1] ?? finalizedWindowedChain;
|
|
961
|
+
}
|
|
962
|
+
__name(findBestUncle, "findBestUncle");
|
|
963
|
+
|
|
964
|
+
// src/primitives/uncle/findUncles.ts
|
|
965
|
+
import { assertEx as assertEx10, exists as exists2 } from "@xylabs/sdk-js";
|
|
966
|
+
import { isTransactionBoundWitness as isTransactionBoundWitness2 } from "@xyo-network/xl1-protocol";
|
|
967
|
+
function blocksToChains(blocks) {
|
|
968
|
+
const chains = [];
|
|
969
|
+
const map = /* @__PURE__ */ new Map();
|
|
970
|
+
for (const block of blocks) {
|
|
971
|
+
map.set(block[0]._hash, block);
|
|
972
|
+
}
|
|
973
|
+
for (const block of blocks) {
|
|
974
|
+
let uncle = [
|
|
975
|
+
block
|
|
976
|
+
];
|
|
977
|
+
let previous = block[0].previous ? map.get(block[0].previous) : void 0;
|
|
978
|
+
while (previous) {
|
|
979
|
+
if (previous[0].block === uncle[0][0].block - 1) {
|
|
980
|
+
uncle.unshift(previous);
|
|
981
|
+
previous = previous[0].previous ? map.get(previous[0].previous) : void 0;
|
|
982
|
+
} else {
|
|
983
|
+
uncle = [];
|
|
984
|
+
break;
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
if (uncle.length > 0) {
|
|
988
|
+
chains.push(uncle);
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
return chains;
|
|
992
|
+
}
|
|
993
|
+
__name(blocksToChains, "blocksToChains");
|
|
994
|
+
function toValidUncle(_context, finalizedWindowedChain, possibleUncle) {
|
|
995
|
+
const finalizedWindowStartBlockNumber = finalizedWindowedChain.at(0)?.[0].block ?? -1;
|
|
996
|
+
const finalizedHead = assertEx10(finalizedWindowedChain.at(-1), () => "finalizedWindowedChain is empty");
|
|
997
|
+
const prunedPossibleUncle = possibleUncle.filter((b) => b[0].block > finalizedHead[0].block);
|
|
998
|
+
if (prunedPossibleUncle.length === 0) {
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
if (prunedPossibleUncle[0][0].block !== finalizedHead[0].block + 1) {
|
|
1002
|
+
return;
|
|
1003
|
+
}
|
|
1004
|
+
if (prunedPossibleUncle[0][0].previous !== finalizedHead[0]._hash) {
|
|
1005
|
+
return;
|
|
1006
|
+
}
|
|
1007
|
+
const allUncleTransactions = prunedPossibleUncle.flatMap((b) => b[1]).filter(isTransactionBoundWitness2);
|
|
1008
|
+
const allFinalizedTransactions = finalizedWindowedChain.flatMap((b) => b[1]).filter(isTransactionBoundWitness2);
|
|
1009
|
+
const txPossiblyBeforeWindow = allUncleTransactions.find((tx) => tx.nbf < finalizedWindowStartBlockNumber);
|
|
1010
|
+
if (txPossiblyBeforeWindow) {
|
|
1011
|
+
return;
|
|
1012
|
+
}
|
|
1013
|
+
const txExistsInWindow = allUncleTransactions.find((tx) => allFinalizedTransactions.find((finalTx) => finalTx._hash === tx._hash));
|
|
1014
|
+
if (txExistsInWindow) {
|
|
1015
|
+
return;
|
|
1016
|
+
}
|
|
1017
|
+
return prunedPossibleUncle;
|
|
1018
|
+
}
|
|
1019
|
+
__name(toValidUncle, "toValidUncle");
|
|
1020
|
+
function findUncles(context, finalizedWindowedChain, blocks) {
|
|
1021
|
+
return blocksToChains(blocks).map((chain) => toValidUncle(context, finalizedWindowedChain, chain)).filter(exists2);
|
|
1022
|
+
}
|
|
1023
|
+
__name(findUncles, "findUncles");
|
|
1024
|
+
|
|
403
1025
|
// src/model/ChainContext/ChainContext.ts
|
|
404
1026
|
function contextCache(context, name, create) {
|
|
405
1027
|
if (!context.caches) {
|
|
406
1028
|
context.caches = {};
|
|
407
1029
|
}
|
|
408
|
-
if (
|
|
1030
|
+
if (isUndefined2(context.caches[name])) {
|
|
409
1031
|
context.caches[name] = create?.() ?? new MemoryMap();
|
|
410
1032
|
}
|
|
411
1033
|
return context.caches[name];
|
|
@@ -416,7 +1038,7 @@ async function withContextCacheResponse(context, name, key, func, { max = 1e4, t
|
|
|
416
1038
|
max
|
|
417
1039
|
}));
|
|
418
1040
|
const cacheResult = await cache.get(key);
|
|
419
|
-
if (
|
|
1041
|
+
if (isDefined8(cacheResult)) {
|
|
420
1042
|
return cacheResult;
|
|
421
1043
|
}
|
|
422
1044
|
const result = timeBudgetMs > 0 ? await timeBudget(name, context.logger, func, timeBudgetMs) : await func();
|
|
@@ -425,6 +1047,44 @@ async function withContextCacheResponse(context, name, key, func, { max = 1e4, t
|
|
|
425
1047
|
}
|
|
426
1048
|
__name(withContextCacheResponse, "withContextCacheResponse");
|
|
427
1049
|
|
|
1050
|
+
// src/model/ChainQualification.ts
|
|
1051
|
+
import { HashZod } from "@xylabs/hex";
|
|
1052
|
+
import { zodIsFactory } from "@xylabs/zod";
|
|
1053
|
+
import { XL1BlockRangeZod } from "@xyo-network/xl1-protocol";
|
|
1054
|
+
import z from "zod";
|
|
1055
|
+
var ChainQualificationZod = z.object({
|
|
1056
|
+
head: HashZod,
|
|
1057
|
+
range: XL1BlockRangeZod
|
|
1058
|
+
});
|
|
1059
|
+
var isChainQualification = zodIsFactory(ChainQualificationZod);
|
|
1060
|
+
var ChainQualifiedRangeConfigZod = z.object({
|
|
1061
|
+
range: XL1BlockRangeZod
|
|
1062
|
+
});
|
|
1063
|
+
var isChainQualifiedRangeConfig = zodIsFactory(ChainQualifiedRangeConfigZod);
|
|
1064
|
+
var ChainQualifiedHeadConfigZod = z.object({
|
|
1065
|
+
head: HashZod
|
|
1066
|
+
});
|
|
1067
|
+
var isChainQualifiedHeadConfig = zodIsFactory(ChainQualifiedHeadConfigZod);
|
|
1068
|
+
var ChainQualifiedConfigZod = z.union([
|
|
1069
|
+
ChainQualifiedRangeConfigZod,
|
|
1070
|
+
ChainQualifiedHeadConfigZod,
|
|
1071
|
+
z.object({})
|
|
1072
|
+
]);
|
|
1073
|
+
var isChainQualifiedConfig = zodIsFactory(ChainQualifiedConfigZod);
|
|
1074
|
+
var ExtendChainQualifiedConfigZod = /* @__PURE__ */ __name((zodType) => {
|
|
1075
|
+
return z.union([
|
|
1076
|
+
ChainQualifiedRangeConfigZod.extend(zodType),
|
|
1077
|
+
ChainQualifiedHeadConfigZod.extend(zodType),
|
|
1078
|
+
zodType
|
|
1079
|
+
]);
|
|
1080
|
+
}, "ExtendChainQualifiedConfigZod");
|
|
1081
|
+
var ChainQualifiedZod = /* @__PURE__ */ __name((zodType) => {
|
|
1082
|
+
return z.tuple([
|
|
1083
|
+
zodType,
|
|
1084
|
+
ChainQualificationZod
|
|
1085
|
+
]);
|
|
1086
|
+
}, "ChainQualifiedZod");
|
|
1087
|
+
|
|
428
1088
|
// src/model/PayloadBundle/bundledPayloadToHydratedBlock.ts
|
|
429
1089
|
import { PayloadBuilder } from "@xyo-network/payload-builder";
|
|
430
1090
|
import { asSignedBlockBoundWitnessWithHashMeta } from "@xyo-network/xl1-protocol";
|
|
@@ -471,13 +1131,36 @@ var bundle = /* @__PURE__ */ __name((root, transaction) => {
|
|
|
471
1131
|
}, "bundle");
|
|
472
1132
|
|
|
473
1133
|
// src/model/PayloadBundle/hydratedTransactionToPayloadBundle.ts
|
|
474
|
-
import { PayloadBuilder as
|
|
1134
|
+
import { PayloadBuilder as PayloadBuilder10 } from "@xyo-network/payload-builder";
|
|
475
1135
|
import { PayloadBundleSchema as PayloadBundleSchema2 } from "@xyo-network/payload-model";
|
|
476
1136
|
|
|
1137
|
+
// src/transaction/buildRandomTransaction.ts
|
|
1138
|
+
import { Account } from "@xyo-network/account";
|
|
1139
|
+
import { asXL1BlockNumber as asXL1BlockNumber2, isAllowedBlockPayload as isAllowedBlockPayload2 } from "@xyo-network/xl1-protocol";
|
|
1140
|
+
|
|
1141
|
+
// src/createTransferPayload.ts
|
|
1142
|
+
import { toHex } from "@xylabs/sdk-js";
|
|
1143
|
+
import { PayloadBuilder as PayloadBuilder4 } from "@xyo-network/payload-builder";
|
|
1144
|
+
import { TransferSchema } from "@xyo-network/xl1-protocol";
|
|
1145
|
+
function createTransferPayload(from, transfers, context) {
|
|
1146
|
+
return new PayloadBuilder4({
|
|
1147
|
+
schema: TransferSchema
|
|
1148
|
+
}).fields({
|
|
1149
|
+
epoch: Date.now(),
|
|
1150
|
+
from,
|
|
1151
|
+
transfers: Object.fromEntries(Object.entries(transfers).map(([k, v]) => [
|
|
1152
|
+
k,
|
|
1153
|
+
toHex(v)
|
|
1154
|
+
])),
|
|
1155
|
+
context
|
|
1156
|
+
}).build();
|
|
1157
|
+
}
|
|
1158
|
+
__name(createTransferPayload, "createTransferPayload");
|
|
1159
|
+
|
|
477
1160
|
// src/transaction/buildTransaction.ts
|
|
478
|
-
import { assertEx as
|
|
1161
|
+
import { assertEx as assertEx11, toHex as toHex2 } from "@xylabs/sdk-js";
|
|
479
1162
|
import { BoundWitnessBuilder } from "@xyo-network/boundwitness-builder";
|
|
480
|
-
import { PayloadBuilder as
|
|
1163
|
+
import { PayloadBuilder as PayloadBuilder5 } from "@xyo-network/payload-builder";
|
|
481
1164
|
import { defaultTransactionFees } from "@xyo-network/xl1-protocol";
|
|
482
1165
|
async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer, nbf, exp, from, fees = defaultTransactionFees) {
|
|
483
1166
|
if (from === void 0 && Array.isArray(signer)) {
|
|
@@ -486,22 +1169,22 @@ async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer
|
|
|
486
1169
|
const txBoundWitnessFields = {
|
|
487
1170
|
chain,
|
|
488
1171
|
fees: {
|
|
489
|
-
base:
|
|
490
|
-
gasLimit:
|
|
491
|
-
gasPrice:
|
|
492
|
-
priority:
|
|
1172
|
+
base: toHex2(fees.base),
|
|
1173
|
+
gasLimit: toHex2(fees.gasLimit),
|
|
1174
|
+
gasPrice: toHex2(fees.gasPrice),
|
|
1175
|
+
priority: toHex2(fees.priority)
|
|
493
1176
|
},
|
|
494
1177
|
nbf,
|
|
495
1178
|
exp
|
|
496
1179
|
};
|
|
497
|
-
const elevatedHashes = await
|
|
1180
|
+
const elevatedHashes = await PayloadBuilder5.hashes(onChainPayloads);
|
|
498
1181
|
const script = [];
|
|
499
1182
|
for (const elevatedHash of elevatedHashes) {
|
|
500
1183
|
script.push(`elevate|${elevatedHash}`);
|
|
501
1184
|
}
|
|
502
1185
|
const fields = {
|
|
503
1186
|
...txBoundWitnessFields,
|
|
504
|
-
from: from ?? (Array.isArray(signer) ?
|
|
1187
|
+
from: from ?? (Array.isArray(signer) ? assertEx11(signer.at(0)?.address) : signer.address)
|
|
505
1188
|
};
|
|
506
1189
|
if (script.length > 0) {
|
|
507
1190
|
fields.script = script;
|
|
@@ -515,30 +1198,49 @@ async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer
|
|
|
515
1198
|
signer
|
|
516
1199
|
]).build();
|
|
517
1200
|
return [
|
|
518
|
-
await
|
|
519
|
-
await
|
|
1201
|
+
await PayloadBuilder5.addHashMeta(tx),
|
|
1202
|
+
await PayloadBuilder5.addHashMeta(txPayloads)
|
|
520
1203
|
];
|
|
521
1204
|
}
|
|
522
1205
|
__name(buildTransaction, "buildTransaction");
|
|
523
1206
|
|
|
1207
|
+
// src/transaction/buildRandomTransaction.ts
|
|
1208
|
+
var buildRandomTransaction = /* @__PURE__ */ __name(async (chain, payloads, account, nbf = asXL1BlockNumber2(0, true), exp = asXL1BlockNumber2(nbf + 1e3, true), privatePayloadSchemas = [], receiverAddress) => {
|
|
1209
|
+
const elevatedPayloads2 = (payloads ?? []).filter(isAllowedBlockPayload2);
|
|
1210
|
+
const additionalPayloads = (payloads ?? []).filter((payload) => !isAllowedBlockPayload2(payload));
|
|
1211
|
+
const sender = account ?? await Account.random();
|
|
1212
|
+
if (elevatedPayloads2?.length === 0) {
|
|
1213
|
+
const receiver = receiverAddress ?? (await Account.random()).address;
|
|
1214
|
+
const transferPayload = createTransferPayload(sender.address, {
|
|
1215
|
+
[receiver]: 1n
|
|
1216
|
+
});
|
|
1217
|
+
elevatedPayloads2.push(transferPayload);
|
|
1218
|
+
}
|
|
1219
|
+
const hydratedTransaction = await buildTransaction(chain, elevatedPayloads2, additionalPayloads, sender, nbf, exp);
|
|
1220
|
+
return [
|
|
1221
|
+
hydratedTransaction[0],
|
|
1222
|
+
hydratedTransaction[1].filter((p) => !privatePayloadSchemas.includes(p.schema))
|
|
1223
|
+
];
|
|
1224
|
+
}, "buildRandomTransaction");
|
|
1225
|
+
|
|
524
1226
|
// src/transaction/buildUnsignedTransaction.ts
|
|
525
|
-
import { toHex as
|
|
1227
|
+
import { toHex as toHex3 } from "@xylabs/sdk-js";
|
|
526
1228
|
import { BoundWitnessBuilder as BoundWitnessBuilder2 } from "@xyo-network/boundwitness-builder";
|
|
527
|
-
import { PayloadBuilder as
|
|
1229
|
+
import { PayloadBuilder as PayloadBuilder6 } from "@xyo-network/payload-builder";
|
|
528
1230
|
import { defaultTransactionFees as defaultTransactionFees2 } from "@xyo-network/xl1-protocol";
|
|
529
1231
|
async function buildUnsignedTransaction(chain, onChainPayloads, offChainPayloads, nbf, exp, from, fees = defaultTransactionFees2) {
|
|
530
1232
|
const txBoundWitnessFields = {
|
|
531
1233
|
chain,
|
|
532
1234
|
fees: {
|
|
533
|
-
base:
|
|
534
|
-
gasLimit:
|
|
535
|
-
gasPrice:
|
|
536
|
-
priority:
|
|
1235
|
+
base: toHex3(fees.base),
|
|
1236
|
+
gasLimit: toHex3(fees.gasLimit),
|
|
1237
|
+
gasPrice: toHex3(fees.gasPrice),
|
|
1238
|
+
priority: toHex3(fees.priority)
|
|
537
1239
|
},
|
|
538
1240
|
nbf,
|
|
539
1241
|
exp
|
|
540
1242
|
};
|
|
541
|
-
const elevatedHashes = await
|
|
1243
|
+
const elevatedHashes = await PayloadBuilder6.hashes(onChainPayloads);
|
|
542
1244
|
const script = [];
|
|
543
1245
|
for (const elevatedHash of elevatedHashes) {
|
|
544
1246
|
script.push(`elevate|${elevatedHash}`);
|
|
@@ -564,7 +1266,7 @@ async function buildUnsignedTransaction(chain, onChainPayloads, offChainPayloads
|
|
|
564
1266
|
__name(buildUnsignedTransaction, "buildUnsignedTransaction");
|
|
565
1267
|
|
|
566
1268
|
// src/transaction/confirmSubmittedTransaction.ts
|
|
567
|
-
import { delay, isDefined as
|
|
1269
|
+
import { delay, isDefined as isDefined9 } from "@xylabs/sdk-js";
|
|
568
1270
|
var DEFAULT_CONFIRMATION_ATTEMPTS = 20;
|
|
569
1271
|
var DEFAULT_DELAY_BETWEEN_ATTEMPTS = 1e3;
|
|
570
1272
|
var confirmSubmittedTransaction = /* @__PURE__ */ __name(async (viewer, txHash, options) => {
|
|
@@ -573,7 +1275,7 @@ var confirmSubmittedTransaction = /* @__PURE__ */ __name(async (viewer, txHash,
|
|
|
573
1275
|
let attempts = 0;
|
|
574
1276
|
while (true) {
|
|
575
1277
|
const tx = await viewer.transactionByHash(txHash) ?? void 0;
|
|
576
|
-
if (
|
|
1278
|
+
if (isDefined9(tx)) {
|
|
577
1279
|
options?.logger?.log("\u2705 Transaction confirmed:", txHash, "\n");
|
|
578
1280
|
return tx;
|
|
579
1281
|
} else {
|
|
@@ -590,9 +1292,9 @@ var confirmSubmittedTransaction = /* @__PURE__ */ __name(async (viewer, txHash,
|
|
|
590
1292
|
}, "confirmSubmittedTransaction");
|
|
591
1293
|
|
|
592
1294
|
// src/transaction/hydrateTransaction.ts
|
|
593
|
-
import { assertEx as
|
|
1295
|
+
import { assertEx as assertEx12 } from "@xylabs/sdk-js";
|
|
594
1296
|
import { hydrateTypedBoundWitness, tryHydrateTypedBoundWitness } from "@xyo-network/archivist-model";
|
|
595
|
-
import { asSignedHydratedTransaction, isAllowedBlockPayload as
|
|
1297
|
+
import { asSignedHydratedTransaction, isAllowedBlockPayload as isAllowedBlockPayload3, isSignedTransactionBoundWitnessWithStorageMeta } from "@xyo-network/xl1-protocol";
|
|
596
1298
|
var tryHydrateTransaction = /* @__PURE__ */ __name(async ({ chainMap }, hash) => {
|
|
597
1299
|
return await tryHydrateTypedBoundWitness({
|
|
598
1300
|
get(hashes) {
|
|
@@ -644,7 +1346,7 @@ var tryHydrateElevatedTransaction = /* @__PURE__ */ __name(async ({ chainMap },
|
|
|
644
1346
|
const [code, hash2] = opCode.split("|");
|
|
645
1347
|
if (code === "elevated") {
|
|
646
1348
|
const elevatedPayload = payloads.find((payload) => payload._hash === hash2);
|
|
647
|
-
if (
|
|
1349
|
+
if (isAllowedBlockPayload3(elevatedPayload)) {
|
|
648
1350
|
elevatedPayloads2.push(elevatedPayload);
|
|
649
1351
|
}
|
|
650
1352
|
}
|
|
@@ -658,15 +1360,15 @@ var tryHydrateElevatedTransaction = /* @__PURE__ */ __name(async ({ chainMap },
|
|
|
658
1360
|
return void 0;
|
|
659
1361
|
}, "tryHydrateElevatedTransaction");
|
|
660
1362
|
var hydrateElevatedTransaction = /* @__PURE__ */ __name(async (context, hash) => {
|
|
661
|
-
return
|
|
1363
|
+
return assertEx12(await tryHydrateElevatedTransaction(context, hash), () => "Hydration failed");
|
|
662
1364
|
}, "hydrateElevatedTransaction");
|
|
663
1365
|
|
|
664
1366
|
// src/transaction/primitives/transactionBlockByteCount.ts
|
|
665
|
-
import { PayloadBuilder as
|
|
1367
|
+
import { PayloadBuilder as PayloadBuilder7 } from "@xyo-network/payload-builder";
|
|
666
1368
|
function transactionBlockByteCount([transaction, payloads]) {
|
|
667
|
-
const cleanTransaction =
|
|
1369
|
+
const cleanTransaction = PayloadBuilder7.omitStorageMeta(transaction);
|
|
668
1370
|
const transactionBytes = JSON.stringify(cleanTransaction).length;
|
|
669
|
-
const cleanPayloads =
|
|
1371
|
+
const cleanPayloads = PayloadBuilder7.omitStorageMeta(payloads);
|
|
670
1372
|
return cleanPayloads.reduce((acc, payload) => acc + JSON.stringify(payload).length, 0) + transactionBytes;
|
|
671
1373
|
}
|
|
672
1374
|
__name(transactionBlockByteCount, "transactionBlockByteCount");
|
|
@@ -724,7 +1426,7 @@ __name(transactionRequiredGas, "transactionRequiredGas");
|
|
|
724
1426
|
|
|
725
1427
|
// src/transaction/script.ts
|
|
726
1428
|
import { asHash as asHash2 } from "@xylabs/sdk-js";
|
|
727
|
-
import { assertEx as
|
|
1429
|
+
import { assertEx as assertEx13, filterAs } from "@xylabs/sdk-js";
|
|
728
1430
|
import { isAllowedBlockPayloadWithHashMeta } from "@xyo-network/xl1-protocol";
|
|
729
1431
|
var tryExtractElevatedHashesFromScript = /* @__PURE__ */ __name((strings) => {
|
|
730
1432
|
const hashes = strings.filter((str) => str.startsWith("elevate|")).map((str) => str.split("|")[1]);
|
|
@@ -733,7 +1435,7 @@ var tryExtractElevatedHashesFromScript = /* @__PURE__ */ __name((strings) => {
|
|
|
733
1435
|
var extractElevatedHashesFromScript = /* @__PURE__ */ __name((strings) => {
|
|
734
1436
|
const hashes = strings.filter((str) => str.startsWith("elevate|")).map((str) => str.split("|")[1]);
|
|
735
1437
|
const filtered = filterAs(hashes, (h) => asHash2(h));
|
|
736
|
-
|
|
1438
|
+
assertEx13(filtered.length === hashes.length, () => "Invalid elevated hashes");
|
|
737
1439
|
return filtered;
|
|
738
1440
|
}, "extractElevatedHashesFromScript");
|
|
739
1441
|
var tryExtractElevatedHashes = /* @__PURE__ */ __name((tx) => {
|
|
@@ -747,15 +1449,15 @@ var extractElevatedHashes = /* @__PURE__ */ __name((tx) => {
|
|
|
747
1449
|
const { script } = bw;
|
|
748
1450
|
const hashes = script ? tryExtractElevatedHashesFromScript(script) : [];
|
|
749
1451
|
const filtered = payloads.filter((p) => hashes.includes(p._hash)).filter(isAllowedBlockPayloadWithHashMeta);
|
|
750
|
-
|
|
1452
|
+
assertEx13(filtered.length === hashes.length, () => "Invalid elevated hashes");
|
|
751
1453
|
return filtered;
|
|
752
1454
|
}, "extractElevatedHashes");
|
|
753
1455
|
|
|
754
1456
|
// src/transaction/signTransaction.ts
|
|
755
|
-
import { assertEx as
|
|
756
|
-
import { PayloadBuilder as
|
|
1457
|
+
import { assertEx as assertEx14, hexFromArrayBuffer, toArrayBuffer } from "@xylabs/sdk-js";
|
|
1458
|
+
import { PayloadBuilder as PayloadBuilder8 } from "@xyo-network/payload-builder";
|
|
757
1459
|
async function signTransaction(tx, account) {
|
|
758
|
-
|
|
1460
|
+
assertEx14(tx.from === account.address, () => "Signer address does not match transaction from address");
|
|
759
1461
|
const unsignedTx = structuredClone(tx);
|
|
760
1462
|
unsignedTx.addresses = [
|
|
761
1463
|
account.address
|
|
@@ -763,7 +1465,7 @@ async function signTransaction(tx, account) {
|
|
|
763
1465
|
unsignedTx.previous_hashes = [
|
|
764
1466
|
account.previousHash ?? null
|
|
765
1467
|
];
|
|
766
|
-
const hash = await
|
|
1468
|
+
const hash = await PayloadBuilder8.dataHash(unsignedTx);
|
|
767
1469
|
const hashBytes = toArrayBuffer(hash);
|
|
768
1470
|
const [signature] = await account.sign(hashBytes);
|
|
769
1471
|
const result = {
|
|
@@ -776,14 +1478,126 @@ async function signTransaction(tx, account) {
|
|
|
776
1478
|
}
|
|
777
1479
|
__name(signTransaction, "signTransaction");
|
|
778
1480
|
|
|
1481
|
+
// src/transaction/TransactionBuilder.ts
|
|
1482
|
+
import { assertEx as assertEx15, Base } from "@xylabs/sdk-js";
|
|
1483
|
+
import { PayloadBuilder as PayloadBuilder9 } from "@xyo-network/payload-builder";
|
|
1484
|
+
import { asXL1BlockNumber as asXL1BlockNumber3, defaultTransactionFees as defaultTransactionFees3, isAllowedBlockPayload as isAllowedBlockPayload4, minTransactionFees, XYO_ZERO_ADDRESS } from "@xyo-network/xl1-protocol";
|
|
1485
|
+
var TransactionBuilder = class extends Base {
|
|
1486
|
+
static {
|
|
1487
|
+
__name(this, "TransactionBuilder");
|
|
1488
|
+
}
|
|
1489
|
+
_blockRange;
|
|
1490
|
+
_chain;
|
|
1491
|
+
_elevatedPayloads = [];
|
|
1492
|
+
_fees;
|
|
1493
|
+
_payloads = [];
|
|
1494
|
+
_signers = [];
|
|
1495
|
+
constructor(options = {}) {
|
|
1496
|
+
super(options);
|
|
1497
|
+
}
|
|
1498
|
+
async build() {
|
|
1499
|
+
const chain = assertEx15(this._chain, () => "Chain must be set before building the transaction");
|
|
1500
|
+
const fees = assertEx15(this._fees, () => "Fees must be set before building the transaction");
|
|
1501
|
+
const blockRange = assertEx15(this._blockRange, () => "Block range must be set before building the transaction");
|
|
1502
|
+
return await buildTransaction(chain, this._elevatedPayloads, this._payloads, this._signers, asXL1BlockNumber3(blockRange[0], true), asXL1BlockNumber3(blockRange[1], true), this._signers[0]?.address, fees);
|
|
1503
|
+
}
|
|
1504
|
+
chain(chain) {
|
|
1505
|
+
this._chain = chain;
|
|
1506
|
+
return this;
|
|
1507
|
+
}
|
|
1508
|
+
async dryRun() {
|
|
1509
|
+
return await buildTransaction(XYO_ZERO_ADDRESS, this._elevatedPayloads, this._payloads, this._signers, asXL1BlockNumber3(0, true), asXL1BlockNumber3(1e3, true), this._signers[0]?.address, defaultTransactionFees3);
|
|
1510
|
+
}
|
|
1511
|
+
elevatedPayload(payload) {
|
|
1512
|
+
const allowedPayload = isAllowedBlockPayload4(payload) ? payload : void 0;
|
|
1513
|
+
const allowPayloadExists = assertEx15(allowedPayload, () => "Payload must be an AllowedBlockPayload");
|
|
1514
|
+
this._elevatedPayloads.push(allowPayloadExists);
|
|
1515
|
+
return this;
|
|
1516
|
+
}
|
|
1517
|
+
elevatedPayloads(payloads) {
|
|
1518
|
+
if (payloads) for (const payload of payloads) {
|
|
1519
|
+
this.elevatedPayload(payload);
|
|
1520
|
+
}
|
|
1521
|
+
return this;
|
|
1522
|
+
}
|
|
1523
|
+
async estimatedMinimumFees() {
|
|
1524
|
+
const tx = await this.dryRun();
|
|
1525
|
+
const requiredGas = transactionRequiredGas(tx);
|
|
1526
|
+
return {
|
|
1527
|
+
base: minTransactionFees.base,
|
|
1528
|
+
// eslint-disable-next-line unicorn/prefer-math-min-max
|
|
1529
|
+
gasLimit: requiredGas > minTransactionFees.gasLimit ? requiredGas : minTransactionFees.gasLimit,
|
|
1530
|
+
gasPrice: minTransactionFees.gasPrice,
|
|
1531
|
+
priority: minTransactionFees.priority
|
|
1532
|
+
};
|
|
1533
|
+
}
|
|
1534
|
+
fees(fees) {
|
|
1535
|
+
this._fees = fees;
|
|
1536
|
+
return this;
|
|
1537
|
+
}
|
|
1538
|
+
payload(payload) {
|
|
1539
|
+
this._payloads.push(payload);
|
|
1540
|
+
return this;
|
|
1541
|
+
}
|
|
1542
|
+
payloads(payloads) {
|
|
1543
|
+
if (payloads) for (const payload of payloads) {
|
|
1544
|
+
if (payload !== null) {
|
|
1545
|
+
this.payload(payload);
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
return this;
|
|
1549
|
+
}
|
|
1550
|
+
range(blockRange) {
|
|
1551
|
+
if (blockRange.length !== 2) {
|
|
1552
|
+
throw new Error("Block range must be an array of two numbers");
|
|
1553
|
+
}
|
|
1554
|
+
this._blockRange = blockRange;
|
|
1555
|
+
return this;
|
|
1556
|
+
}
|
|
1557
|
+
async removeElevatedPayload(payload) {
|
|
1558
|
+
const hash = await PayloadBuilder9.hash(payload);
|
|
1559
|
+
const existingHashes = await PayloadBuilder9.hashes(this._elevatedPayloads);
|
|
1560
|
+
const existingPayloadIndex = existingHashes.indexOf(hash);
|
|
1561
|
+
if (existingPayloadIndex === -1) {
|
|
1562
|
+
throw new Error("Payload not found in the transaction");
|
|
1563
|
+
}
|
|
1564
|
+
this._elevatedPayloads = this._elevatedPayloads.filter((_, index) => index !== existingPayloadIndex);
|
|
1565
|
+
return this;
|
|
1566
|
+
}
|
|
1567
|
+
async removePayload(payload) {
|
|
1568
|
+
const hash = await PayloadBuilder9.hash(payload);
|
|
1569
|
+
const existingHashes = await PayloadBuilder9.hashes(this._payloads);
|
|
1570
|
+
const existingPayloadIndex = existingHashes.indexOf(hash);
|
|
1571
|
+
if (existingPayloadIndex === -1) {
|
|
1572
|
+
throw new Error("Payload not found in the transaction");
|
|
1573
|
+
}
|
|
1574
|
+
this._payloads = this._payloads.filter((_, index) => index !== existingPayloadIndex);
|
|
1575
|
+
return this;
|
|
1576
|
+
}
|
|
1577
|
+
signer(signer) {
|
|
1578
|
+
if (signer) {
|
|
1579
|
+
this._signers.push(signer);
|
|
1580
|
+
}
|
|
1581
|
+
return this;
|
|
1582
|
+
}
|
|
1583
|
+
signers(signers) {
|
|
1584
|
+
if (signers) for (const signer of signers) {
|
|
1585
|
+
if (signer !== null) {
|
|
1586
|
+
this.signer(signer);
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
return this;
|
|
1590
|
+
}
|
|
1591
|
+
};
|
|
1592
|
+
|
|
779
1593
|
// src/model/PayloadBundle/hydratedTransactionToPayloadBundle.ts
|
|
780
1594
|
var hydratedTransactionToPayloadBundle = /* @__PURE__ */ __name((transaction) => {
|
|
781
1595
|
const root = transaction[0]._hash;
|
|
782
1596
|
return bundle2(root, transaction);
|
|
783
1597
|
}, "hydratedTransactionToPayloadBundle");
|
|
784
1598
|
var bundle2 = /* @__PURE__ */ __name((root, transaction) => {
|
|
785
|
-
const payloads = flattenHydratedTransaction(transaction).flatMap((p) =>
|
|
786
|
-
return new
|
|
1599
|
+
const payloads = flattenHydratedTransaction(transaction).flatMap((p) => PayloadBuilder10.omitStorageMeta(p));
|
|
1600
|
+
return new PayloadBuilder10({
|
|
787
1601
|
schema: PayloadBundleSchema2
|
|
788
1602
|
}).fields({
|
|
789
1603
|
payloads,
|
|
@@ -792,32 +1606,20 @@ var bundle2 = /* @__PURE__ */ __name((root, transaction) => {
|
|
|
792
1606
|
}, "bundle");
|
|
793
1607
|
|
|
794
1608
|
// src/model/Provider.ts
|
|
795
|
-
import { assertEx as
|
|
1609
|
+
import { assertEx as assertEx16, isString } from "@xylabs/sdk-js";
|
|
796
1610
|
var asProviderMoniker = /* @__PURE__ */ __name((value) => {
|
|
797
1611
|
const moniker = isString(value) ? value : void 0;
|
|
798
|
-
return
|
|
1612
|
+
return assertEx16(moniker);
|
|
799
1613
|
}, "asProviderMoniker");
|
|
800
1614
|
var DefaultProviderMoniker = "Provider";
|
|
801
1615
|
|
|
802
|
-
// src/model/Qualified.ts
|
|
803
|
-
import { HashZod } from "@xylabs/sdk-js";
|
|
804
|
-
import { XL1BlockRangeZod } from "@xyo-network/xl1-protocol";
|
|
805
|
-
import z from "zod";
|
|
806
|
-
var QualifiedZod = /* @__PURE__ */ __name((zodType) => {
|
|
807
|
-
return z.tuple([
|
|
808
|
-
zodType,
|
|
809
|
-
XL1BlockRangeZod,
|
|
810
|
-
HashZod
|
|
811
|
-
]);
|
|
812
|
-
}, "QualifiedZod");
|
|
813
|
-
|
|
814
1616
|
// src/block/primitives/blockFromBlockNumber.ts
|
|
815
1617
|
async function blockFromBlockNumber(context, blockNumber) {
|
|
816
1618
|
const cacheKey = `${blockNumber}`;
|
|
817
1619
|
return await withContextCacheResponse(context, "blockFromBlockNumber", cacheKey, async () => {
|
|
818
1620
|
const [headHash] = await context.head();
|
|
819
1621
|
const result = await context.store.chainMap.get(headHash);
|
|
820
|
-
if (!
|
|
1622
|
+
if (!isDefined10(result)) {
|
|
821
1623
|
throw new Error(`Head block not found for hash: ${headHash}`);
|
|
822
1624
|
}
|
|
823
1625
|
let currentBlock = asSignedBlockBoundWitnessWithStorageMeta(result, () => `Found Payload is not a Signed<BlockBoundWitness>: ${JSON.stringify(result, null, 2)}`);
|
|
@@ -827,7 +1629,7 @@ async function blockFromBlockNumber(context, blockNumber) {
|
|
|
827
1629
|
while (currentBlock.block > blockNumber) {
|
|
828
1630
|
let jumpHash = currentBlock.previous;
|
|
829
1631
|
let jumpBlockNumber = currentBlock.block - 1;
|
|
830
|
-
for (const [step, stepSize2] of
|
|
1632
|
+
for (const [step, stepSize2] of StepSizes6.entries()) {
|
|
831
1633
|
const possibleJumpBlockNumber = currentBlock.block - currentBlock.block % stepSize2 - 1;
|
|
832
1634
|
if (possibleJumpBlockNumber >= blockNumber && possibleJumpBlockNumber <= jumpBlockNumber) {
|
|
833
1635
|
jumpBlockNumber = possibleJumpBlockNumber;
|
|
@@ -835,7 +1637,7 @@ async function blockFromBlockNumber(context, blockNumber) {
|
|
|
835
1637
|
}
|
|
836
1638
|
}
|
|
837
1639
|
const newBlock = await context.store.chainMap.get(asHash3(jumpHash, () => `Jump hash not found for block number [${blockNumber}]: ${jumpBlockNumber} ${toSafeJsonString(currentBlock, 10)}`));
|
|
838
|
-
if (!
|
|
1640
|
+
if (!isDefined10(newBlock)) {
|
|
839
1641
|
throw new Error(`Block not found for jump hash: ${jumpHash}`);
|
|
840
1642
|
}
|
|
841
1643
|
currentBlock = asSignedBlockBoundWitnessWithStorageMeta(newBlock, () => {
|
|
@@ -855,7 +1657,7 @@ async function blockFromBlockNumber(context, blockNumber) {
|
|
|
855
1657
|
__name(blockFromBlockNumber, "blockFromBlockNumber");
|
|
856
1658
|
|
|
857
1659
|
// src/block/primitives/frames/calculateFramesFromRange.ts
|
|
858
|
-
import { asXL1BlockNumber, stepSize } from "@xyo-network/xl1-protocol";
|
|
1660
|
+
import { asXL1BlockNumber as asXL1BlockNumber4, stepSize } from "@xyo-network/xl1-protocol";
|
|
859
1661
|
function calculateFramesFromRange(range, step) {
|
|
860
1662
|
const size = stepSize(step);
|
|
861
1663
|
let start = Math.trunc(range[0] / size) * size;
|
|
@@ -865,22 +1667,22 @@ function calculateFramesFromRange(range, step) {
|
|
|
865
1667
|
start += size;
|
|
866
1668
|
remaining.push([
|
|
867
1669
|
range[0],
|
|
868
|
-
|
|
1670
|
+
asXL1BlockNumber4(Math.min(start - 1, range[1]), true)
|
|
869
1671
|
]);
|
|
870
1672
|
}
|
|
871
1673
|
for (let i = start; i <= range[1]; i += size) {
|
|
872
1674
|
if (i + size - 1 <= range[1]) {
|
|
873
1675
|
fitted.push([
|
|
874
|
-
|
|
1676
|
+
asXL1BlockNumber4(i, {
|
|
875
1677
|
name: "calculateFramesFromRange A"
|
|
876
1678
|
}),
|
|
877
|
-
|
|
1679
|
+
asXL1BlockNumber4(Math.min(i + size - 1, range[1]), {
|
|
878
1680
|
name: "calculateFramesFromRange B"
|
|
879
1681
|
})
|
|
880
1682
|
]);
|
|
881
1683
|
} else {
|
|
882
1684
|
remaining.push([
|
|
883
|
-
|
|
1685
|
+
asXL1BlockNumber4(i, {
|
|
884
1686
|
name: "calculateFramesFromRange C"
|
|
885
1687
|
}),
|
|
886
1688
|
range[1]
|
|
@@ -895,8 +1697,8 @@ function calculateFramesFromRange(range, step) {
|
|
|
895
1697
|
__name(calculateFramesFromRange, "calculateFramesFromRange");
|
|
896
1698
|
|
|
897
1699
|
// src/block/primitives/frames/deepCalculateFramesFromRange.ts
|
|
898
|
-
import { StepSizes as
|
|
899
|
-
function deepCalculateFramesFromRange(range, startingStep =
|
|
1700
|
+
import { StepSizes as StepSizes7 } from "@xyo-network/xl1-protocol";
|
|
1701
|
+
function deepCalculateFramesFromRange(range, startingStep = StepSizes7.length - 1) {
|
|
900
1702
|
const fitted = [];
|
|
901
1703
|
let remaining = [
|
|
902
1704
|
range
|
|
@@ -949,7 +1751,7 @@ function toStepIdentityString({ block, step }) {
|
|
|
949
1751
|
__name(toStepIdentityString, "toStepIdentityString");
|
|
950
1752
|
|
|
951
1753
|
// src/config/Bridge.ts
|
|
952
|
-
import { AddressZod, HexZod, toAddress as
|
|
1754
|
+
import { AddressZod, HexZod, toAddress as toAddress8, toHex as toHex4 } from "@xylabs/hex";
|
|
953
1755
|
import { AttoXL1ConvertFactor, XL1 } from "@xyo-network/xl1-protocol";
|
|
954
1756
|
import { globalRegistry } from "zod";
|
|
955
1757
|
import * as z3 from "zod";
|
|
@@ -1016,12 +1818,13 @@ var MnemonicStringZod = z2.string().transform((s) => s.trim().replaceAll(/\s+/g,
|
|
|
1016
1818
|
}).describe("BIP-39 mnemonic string");
|
|
1017
1819
|
|
|
1018
1820
|
// src/config/Bridge.ts
|
|
1019
|
-
var DEFAULT_FIXED_FEE =
|
|
1020
|
-
var
|
|
1021
|
-
var
|
|
1022
|
-
var
|
|
1023
|
-
var DEFAULT_HARDHAT_TOKEN_CONTRACT =
|
|
1024
|
-
var
|
|
1821
|
+
var DEFAULT_FIXED_FEE = toHex4(XL1(1n) * AttoXL1ConvertFactor.xl1);
|
|
1822
|
+
var DEFAULT_HARDHAT_BRIDGE_CONTRACT = toAddress8("2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6");
|
|
1823
|
+
var DEFAULT_HARDHAT_CHAIN_ID = toHex4("7A69");
|
|
1824
|
+
var DEFAULT_HARDHAT_REMOTE_CHAIN_WALLET_PRIVATE_KEY = toHex4("0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80");
|
|
1825
|
+
var DEFAULT_HARDHAT_TOKEN_CONTRACT = toAddress8("5FbDB2315678afecb367f032d93F642f64180aa3");
|
|
1826
|
+
var DEFAULT_MAX_BRIDGE_AMOUNT = toHex4(XL1(100000n) * AttoXL1ConvertFactor.xl1);
|
|
1827
|
+
var DEFAULT_MIN_BRIDGE_AMOUNT = toHex4(XL1(10n) * AttoXL1ConvertFactor.xl1);
|
|
1025
1828
|
var BasisPointsZod = z3.coerce.number().int().nonnegative().max(1e4);
|
|
1026
1829
|
var BridgeConfigZod = z3.object({
|
|
1027
1830
|
chainRpcApiUrl: z3.string().default("http://localhost:8080/rpc").register(globalRegistry, {
|
|
@@ -1075,12 +1878,24 @@ var BridgeConfigZod = z3.object({
|
|
|
1075
1878
|
title: "bridge.mnemonic",
|
|
1076
1879
|
type: "string"
|
|
1077
1880
|
}),
|
|
1078
|
-
port: z3.coerce.number().default(8081).register(globalRegistry, {
|
|
1881
|
+
port: z3.coerce.number().int().positive().default(8081).register(globalRegistry, {
|
|
1079
1882
|
default: 8081,
|
|
1080
1883
|
description: "Port for the Bridge",
|
|
1081
1884
|
title: "bridge.port",
|
|
1082
1885
|
type: "number"
|
|
1083
1886
|
}),
|
|
1887
|
+
redisHost: z3.string().default("localhost").register(globalRegistry, {
|
|
1888
|
+
default: "localhost",
|
|
1889
|
+
description: "Host for the Bridge Redis instance",
|
|
1890
|
+
title: "bridge.redisHost",
|
|
1891
|
+
type: "string"
|
|
1892
|
+
}),
|
|
1893
|
+
redisPort: z3.coerce.number().int().positive().default(6379).register(globalRegistry, {
|
|
1894
|
+
default: 6379,
|
|
1895
|
+
description: "Port for the Bridge Redis instance",
|
|
1896
|
+
title: "bridge.redisPort",
|
|
1897
|
+
type: "number"
|
|
1898
|
+
}),
|
|
1084
1899
|
remoteBridgeContractAddress: AddressZod.default(DEFAULT_HARDHAT_BRIDGE_CONTRACT).register(globalRegistry, {
|
|
1085
1900
|
default: DEFAULT_HARDHAT_BRIDGE_CONTRACT,
|
|
1086
1901
|
description: "Hex representation of remote token address used for bridging",
|
|
@@ -1099,6 +1914,11 @@ var BridgeConfigZod = z3.object({
|
|
|
1099
1914
|
title: "bridge.remoteTokenAddress",
|
|
1100
1915
|
type: "string"
|
|
1101
1916
|
}),
|
|
1917
|
+
remoteChainWalletPrivateKey: HexZod.default(DEFAULT_HARDHAT_REMOTE_CHAIN_WALLET_PRIVATE_KEY).register(globalRegistry, {
|
|
1918
|
+
description: "Private key for the wallet to use for the remote chain wallet",
|
|
1919
|
+
title: "bridge.remoteChainWalletPrivateKey",
|
|
1920
|
+
type: "string"
|
|
1921
|
+
}),
|
|
1102
1922
|
xl1ChainId: HexZod.optional().register(globalRegistry, {
|
|
1103
1923
|
description: "XL1 chain id used for bridging",
|
|
1104
1924
|
title: "bridge.xl1ChainId",
|
|
@@ -1158,11 +1978,11 @@ var ApiConfigZod = z4.object({
|
|
|
1158
1978
|
});
|
|
1159
1979
|
|
|
1160
1980
|
// src/config/Chain.ts
|
|
1161
|
-
import { AddressZod as AddressZod2 } from "@xylabs/sdk-js";
|
|
1981
|
+
import { AddressZod as AddressZod2, HexZod as HexZod2 } from "@xylabs/sdk-js";
|
|
1162
1982
|
import { globalRegistry as globalRegistry3 } from "zod";
|
|
1163
1983
|
import * as z5 from "zod";
|
|
1164
1984
|
var ChainConfigZod = z5.object({
|
|
1165
|
-
id:
|
|
1985
|
+
id: HexZod2.optional().register(globalRegistry3, {
|
|
1166
1986
|
description: "The unique identifier for the chain. Should be the staking contract address for contract-backed chains.",
|
|
1167
1987
|
title: "chain.id",
|
|
1168
1988
|
type: "string"
|
|
@@ -1366,12 +2186,14 @@ var RewardRedemptionApiConfigZod = z10.object({
|
|
|
1366
2186
|
import { globalRegistry as globalRegistry9 } from "zod";
|
|
1367
2187
|
import * as z11 from "zod";
|
|
1368
2188
|
var ServicesConfigZod = z11.object({
|
|
1369
|
-
accountBalanceViewerEndpoint: z11.string().
|
|
2189
|
+
accountBalanceViewerEndpoint: z11.string().default("http://localhost:8080/rpc").register(globalRegistry9, {
|
|
2190
|
+
default: "http://localhost:8080/rpc",
|
|
1370
2191
|
description: "Endpoint of the API to use for instantiating an external AccountBalanceViewer",
|
|
1371
2192
|
title: "services.accountBalanceViewerEndpoint",
|
|
1372
2193
|
type: "string"
|
|
1373
2194
|
}),
|
|
1374
|
-
apiEndpoint: z11.string().
|
|
2195
|
+
apiEndpoint: z11.string().default("http://localhost:8080/rpc").register(globalRegistry9, {
|
|
2196
|
+
default: "http://localhost:8080/rpc",
|
|
1375
2197
|
description: "Endpoint of the API to use for instantiating an external Viewers",
|
|
1376
2198
|
title: "services.apiEndpoint",
|
|
1377
2199
|
type: "string"
|
|
@@ -1379,12 +2201,12 @@ var ServicesConfigZod = z11.object({
|
|
|
1379
2201
|
});
|
|
1380
2202
|
|
|
1381
2203
|
// src/config/storage/driver/Mongo.ts
|
|
1382
|
-
import { isDefined as
|
|
2204
|
+
import { isDefined as isDefined11, isUndefined as isUndefined3 } from "@xylabs/sdk-js";
|
|
1383
2205
|
import { globalRegistry as globalRegistry10 } from "zod";
|
|
1384
2206
|
import * as z12 from "zod";
|
|
1385
2207
|
var hasMongoConfig = /* @__PURE__ */ __name((config) => {
|
|
1386
|
-
if (
|
|
1387
|
-
return
|
|
2208
|
+
if (isUndefined3(config)) return false;
|
|
2209
|
+
return isDefined11(config.connectionString) && isDefined11(config.database) && isDefined11(config.domain) && isDefined11(config.password) && isDefined11(config.username);
|
|
1388
2210
|
}, "hasMongoConfig");
|
|
1389
2211
|
var MongoConfigZod = z12.object({
|
|
1390
2212
|
// TODO: Create from other arguments
|
|
@@ -1546,15 +2368,11 @@ function isUsageMeta(v) {
|
|
|
1546
2368
|
}
|
|
1547
2369
|
__name(isUsageMeta, "isUsageMeta");
|
|
1548
2370
|
|
|
1549
|
-
// src/constants.ts
|
|
1550
|
-
var XL1_NETWORK_STAKING_GENESIS_PERIOD_END_EPOCH = 1760572800;
|
|
1551
|
-
var XL1_NETWORK_STAKING_GENESIS_PERIOD_END_XL1_BLOCK = 107496;
|
|
1552
|
-
|
|
1553
2371
|
// src/CreatableProvider/AbstractCreatableProvider.ts
|
|
1554
|
-
import { AbstractCreatable } from "@xylabs/sdk-js";
|
|
2372
|
+
import { AbstractCreatable, assertEx as assertEx18 } from "@xylabs/sdk-js";
|
|
1555
2373
|
|
|
1556
2374
|
// src/CreatableProvider/ProviderFactory.ts
|
|
1557
|
-
import { assertEx as
|
|
2375
|
+
import { assertEx as assertEx17 } from "@xylabs/sdk-js";
|
|
1558
2376
|
var ProviderFactory = class _ProviderFactory {
|
|
1559
2377
|
static {
|
|
1560
2378
|
__name(this, "ProviderFactory");
|
|
@@ -1564,30 +2382,80 @@ var ProviderFactory = class _ProviderFactory {
|
|
|
1564
2382
|
defaultParams;
|
|
1565
2383
|
labels;
|
|
1566
2384
|
monikers;
|
|
1567
|
-
|
|
2385
|
+
scope;
|
|
2386
|
+
constructor(creatableProvider2, params, labels = {}, scope = "context") {
|
|
1568
2387
|
this.creatableProvider = creatableProvider2;
|
|
1569
2388
|
this.defaultParams = params;
|
|
1570
2389
|
this.defaultMoniker = creatableProvider2.defaultMoniker;
|
|
1571
2390
|
this.monikers = creatableProvider2.monikers;
|
|
1572
|
-
|
|
2391
|
+
this.scope = scope;
|
|
2392
|
+
assertEx17(this.monikers.includes(this.defaultMoniker), () => "defaultMoniker must be in monikers");
|
|
1573
2393
|
this.labels = Object.assign({}, creatableProvider2.labels ?? {}, labels ?? {});
|
|
1574
2394
|
}
|
|
2395
|
+
get resolvedMoniker() {
|
|
2396
|
+
const labels = this.labels ?? {};
|
|
2397
|
+
const labelString = Object.entries(labels).map(([key, value]) => `${key}=${value}`).join(",");
|
|
2398
|
+
return labelString.length === 0 ? `${this.defaultMoniker}` : `${this.defaultMoniker}|${labelString}`;
|
|
2399
|
+
}
|
|
1575
2400
|
static withParams(creatableProvider2, params, labels = {}) {
|
|
1576
2401
|
return new _ProviderFactory(creatableProvider2, params, labels);
|
|
1577
2402
|
}
|
|
1578
|
-
|
|
2403
|
+
/** @deprecated use getInstance instead */
|
|
2404
|
+
async create(params, start = true) {
|
|
2405
|
+
return await this.getInstance(params, start);
|
|
2406
|
+
}
|
|
2407
|
+
factory(params, labels = {}) {
|
|
2408
|
+
return new _ProviderFactory(this.creatableProvider, params, labels);
|
|
2409
|
+
}
|
|
2410
|
+
async getInstance(params, start = true) {
|
|
2411
|
+
let scopeObject = {};
|
|
2412
|
+
switch (this.scope) {
|
|
2413
|
+
case "global": {
|
|
2414
|
+
if (globalThis.xyoServiceSingletons === void 0) {
|
|
2415
|
+
globalThis.xyoServiceSingletons = {};
|
|
2416
|
+
}
|
|
2417
|
+
scopeObject = globalThis.xyoServiceSingletons;
|
|
2418
|
+
break;
|
|
2419
|
+
}
|
|
2420
|
+
case "context": {
|
|
2421
|
+
const context = assertEx17(params?.context, () => "Context is required for context-scoped providers");
|
|
2422
|
+
if (context.singletons === void 0) {
|
|
2423
|
+
context.singletons = {};
|
|
2424
|
+
}
|
|
2425
|
+
scopeObject = context.singletons;
|
|
2426
|
+
break;
|
|
2427
|
+
}
|
|
2428
|
+
default: {
|
|
2429
|
+
scopeObject = {};
|
|
2430
|
+
break;
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
1579
2433
|
const mergedParams = {
|
|
1580
2434
|
...this.defaultParams,
|
|
1581
2435
|
...params,
|
|
1582
|
-
|
|
1583
|
-
...this.defaultParams?.
|
|
1584
|
-
...params?.
|
|
2436
|
+
context: {
|
|
2437
|
+
...this.defaultParams?.context,
|
|
2438
|
+
...params?.context,
|
|
2439
|
+
config: {
|
|
2440
|
+
...this.defaultParams?.context?.config,
|
|
2441
|
+
...params?.context?.config
|
|
2442
|
+
}
|
|
1585
2443
|
}
|
|
1586
2444
|
};
|
|
1587
|
-
|
|
2445
|
+
const resultPromise = scopeObject[this.resolvedMoniker] ?? this.creatableProvider.create(mergedParams);
|
|
2446
|
+
scopeObject[this.resolvedMoniker] = resultPromise;
|
|
2447
|
+
const result = await resultPromise;
|
|
2448
|
+
if (start) {
|
|
2449
|
+
assertEx17(await result.start(), () => "Failed to start provider instance");
|
|
2450
|
+
}
|
|
2451
|
+
return result;
|
|
1588
2452
|
}
|
|
1589
|
-
|
|
1590
|
-
|
|
2453
|
+
async tryGetInstance(params, start = true) {
|
|
2454
|
+
try {
|
|
2455
|
+
return await this.getInstance(params, start);
|
|
2456
|
+
} catch {
|
|
2457
|
+
return;
|
|
2458
|
+
}
|
|
1591
2459
|
}
|
|
1592
2460
|
};
|
|
1593
2461
|
|
|
@@ -1596,8 +2464,48 @@ var AbstractCreatableProvider = class extends AbstractCreatable {
|
|
|
1596
2464
|
static {
|
|
1597
2465
|
__name(this, "AbstractCreatableProvider");
|
|
1598
2466
|
}
|
|
2467
|
+
_contextCache;
|
|
2468
|
+
get config() {
|
|
2469
|
+
return this.context.config;
|
|
2470
|
+
}
|
|
2471
|
+
get context() {
|
|
2472
|
+
return this.params.context;
|
|
2473
|
+
}
|
|
2474
|
+
get locator() {
|
|
2475
|
+
return this.context.locator;
|
|
2476
|
+
}
|
|
1599
2477
|
static factory(params) {
|
|
1600
|
-
|
|
2478
|
+
const factory = ProviderFactory.withParams(this, params);
|
|
2479
|
+
return factory;
|
|
2480
|
+
}
|
|
2481
|
+
static async getInstance(inParams) {
|
|
2482
|
+
const instance = await this.create(inParams);
|
|
2483
|
+
return instance;
|
|
2484
|
+
}
|
|
2485
|
+
static async paramsHandler(params = {}) {
|
|
2486
|
+
const context = assertEx18(params.context, () => new Error("Context is required"));
|
|
2487
|
+
const config = assertEx18(context.config, () => new Error("Context config is required"));
|
|
2488
|
+
const locator = assertEx18(context.locator, () => new Error("Context locator is required"));
|
|
2489
|
+
return await super.paramsHandler({
|
|
2490
|
+
...params,
|
|
2491
|
+
statusReporter: params.statusReporter ?? context.statusReporter,
|
|
2492
|
+
context: {
|
|
2493
|
+
...context,
|
|
2494
|
+
config,
|
|
2495
|
+
locator
|
|
2496
|
+
},
|
|
2497
|
+
name: params.name ?? this.defaultMoniker
|
|
2498
|
+
});
|
|
2499
|
+
}
|
|
2500
|
+
static async tryGetInstance(inParams) {
|
|
2501
|
+
try {
|
|
2502
|
+
return await this.create(inParams);
|
|
2503
|
+
} catch {
|
|
2504
|
+
return;
|
|
2505
|
+
}
|
|
2506
|
+
}
|
|
2507
|
+
async locateAndCreate(moniker) {
|
|
2508
|
+
return await this.locator?.getInstance(moniker);
|
|
1601
2509
|
}
|
|
1602
2510
|
};
|
|
1603
2511
|
|
|
@@ -1619,16 +2527,22 @@ __name(labeledCreatableProvider, "labeledCreatableProvider");
|
|
|
1619
2527
|
import { isTruthy } from "@xylabs/sdk-js";
|
|
1620
2528
|
var buildProviderFactory = /* @__PURE__ */ __name((provider, labels) => {
|
|
1621
2529
|
const factory = {
|
|
1622
|
-
// Destructure instance properties
|
|
1623
|
-
...provider,
|
|
1624
2530
|
monikers: provider.monikers,
|
|
1625
2531
|
// Copy static methods
|
|
2532
|
+
// eslint-disable-next-line sonarjs/deprecation
|
|
1626
2533
|
create: provider.create.bind(provider),
|
|
1627
2534
|
// Merge module & supplied labels
|
|
1628
2535
|
labels: {
|
|
1629
2536
|
...provider.labels,
|
|
1630
2537
|
...labels
|
|
1631
|
-
}
|
|
2538
|
+
},
|
|
2539
|
+
creatableProvider: provider.creatableProvider,
|
|
2540
|
+
resolvedMoniker: provider.resolvedMoniker,
|
|
2541
|
+
scope: provider.scope,
|
|
2542
|
+
getInstance: provider.getInstance.bind(provider),
|
|
2543
|
+
tryGetInstance: provider.tryGetInstance?.bind(provider),
|
|
2544
|
+
defaultMoniker: provider.defaultMoniker,
|
|
2545
|
+
factory: provider.factory.bind(provider)
|
|
1632
2546
|
};
|
|
1633
2547
|
return factory;
|
|
1634
2548
|
}, "buildProviderFactory");
|
|
@@ -1692,15 +2606,23 @@ __name(labeledCreatableProviderFactory, "labeledCreatableProviderFactory");
|
|
|
1692
2606
|
|
|
1693
2607
|
// src/CreatableProvider/ProviderFactoryLocator.ts
|
|
1694
2608
|
import { hasAllLabels } from "@xylabs/sdk-js";
|
|
1695
|
-
import { assertEx as
|
|
2609
|
+
import { assertEx as assertEx19 } from "@xylabs/sdk-js";
|
|
1696
2610
|
var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
1697
2611
|
static {
|
|
1698
2612
|
__name(this, "ProviderFactoryLocator");
|
|
1699
2613
|
}
|
|
2614
|
+
_context;
|
|
1700
2615
|
_registry;
|
|
1701
2616
|
_frozen = false;
|
|
1702
|
-
constructor(registry = {}) {
|
|
2617
|
+
constructor(context, registry = {}) {
|
|
1703
2618
|
this._registry = registry;
|
|
2619
|
+
this._context = {
|
|
2620
|
+
...context,
|
|
2621
|
+
locator: this
|
|
2622
|
+
};
|
|
2623
|
+
}
|
|
2624
|
+
get context() {
|
|
2625
|
+
return this._context;
|
|
1704
2626
|
}
|
|
1705
2627
|
/**
|
|
1706
2628
|
* The current registry for the module factory
|
|
@@ -1708,23 +2630,39 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
1708
2630
|
get registry() {
|
|
1709
2631
|
return this._registry;
|
|
1710
2632
|
}
|
|
1711
|
-
static empty() {
|
|
1712
|
-
return new _ProviderFactoryLocator({});
|
|
2633
|
+
static empty(context) {
|
|
2634
|
+
return new _ProviderFactoryLocator(context, {});
|
|
1713
2635
|
}
|
|
1714
|
-
static standard() {
|
|
1715
|
-
return new _ProviderFactoryLocator({});
|
|
2636
|
+
static standard(context) {
|
|
2637
|
+
return new _ProviderFactoryLocator(context, {});
|
|
2638
|
+
}
|
|
2639
|
+
/** @deprecated use getInstance instead */
|
|
2640
|
+
async create(moniker, params, labels) {
|
|
2641
|
+
return await this.getInstance(moniker, params, labels);
|
|
1716
2642
|
}
|
|
1717
2643
|
freeze() {
|
|
1718
2644
|
this._frozen = true;
|
|
1719
2645
|
}
|
|
2646
|
+
async getInstance(moniker, params, labels) {
|
|
2647
|
+
const resolvedParams = {
|
|
2648
|
+
...params,
|
|
2649
|
+
context: {
|
|
2650
|
+
...this.context,
|
|
2651
|
+
...params?.context
|
|
2652
|
+
}
|
|
2653
|
+
};
|
|
2654
|
+
const factory = this.locate(moniker, labels);
|
|
2655
|
+
const result = await factory.getInstance(resolvedParams);
|
|
2656
|
+
return result;
|
|
2657
|
+
}
|
|
1720
2658
|
/**
|
|
1721
|
-
* Locates a provider factory that matches the supplied
|
|
1722
|
-
* @param
|
|
2659
|
+
* Locates a provider factory that matches the supplied moniker and labels
|
|
2660
|
+
* @param moniker The config moniker for the provider
|
|
1723
2661
|
* @param labels The labels for the provider factory
|
|
1724
|
-
* @returns A provider factory that matches the supplied
|
|
2662
|
+
* @returns A provider factory that matches the supplied moniker and labels or throws if one is not found
|
|
1725
2663
|
*/
|
|
1726
2664
|
locate(moniker, labels) {
|
|
1727
|
-
return
|
|
2665
|
+
return assertEx19(this.tryLocate(moniker, labels), () => `No module factory for the supplied config moniker [${moniker}]${labels ? ` & labels [${JSON.stringify(labels)}]` : ""} registered`);
|
|
1728
2666
|
}
|
|
1729
2667
|
merge(locator) {
|
|
1730
2668
|
const registry = {
|
|
@@ -1737,7 +2675,7 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
1737
2675
|
registry[moniker] = locator.registry[moniker];
|
|
1738
2676
|
}
|
|
1739
2677
|
}
|
|
1740
|
-
return new _ProviderFactoryLocator(registry);
|
|
2678
|
+
return new _ProviderFactoryLocator(this.context, registry);
|
|
1741
2679
|
}
|
|
1742
2680
|
/**
|
|
1743
2681
|
* Registers a single module factory (with optional tags) with the locator
|
|
@@ -1745,7 +2683,7 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
1745
2683
|
* @param labels The labels for the module factory
|
|
1746
2684
|
*/
|
|
1747
2685
|
register(factory, labels, primary = false) {
|
|
1748
|
-
|
|
2686
|
+
assertEx19(!this._frozen, () => "Cannot register a module factory after the locator has been frozen");
|
|
1749
2687
|
registerCreatableProviderFactory(this._registry, factory, labels, primary);
|
|
1750
2688
|
return this;
|
|
1751
2689
|
}
|
|
@@ -1759,19 +2697,53 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
1759
2697
|
}
|
|
1760
2698
|
return this;
|
|
1761
2699
|
}
|
|
2700
|
+
async tryGetInstance(moniker, params, labels) {
|
|
2701
|
+
try {
|
|
2702
|
+
return await this.getInstance(moniker, params, labels);
|
|
2703
|
+
} catch {
|
|
2704
|
+
return;
|
|
2705
|
+
}
|
|
2706
|
+
}
|
|
1762
2707
|
/**
|
|
1763
|
-
* Tries to locate a module factory that matches the supplied
|
|
1764
|
-
* @param
|
|
2708
|
+
* Tries to locate a module factory that matches the supplied moniker and labels
|
|
2709
|
+
* @param moniker The config moniker for the module
|
|
1765
2710
|
* @param labels The labels for the module factory
|
|
1766
|
-
* @returns A module factory that matches the supplied
|
|
2711
|
+
* @returns A module factory that matches the supplied moniker and labels or undefined
|
|
1767
2712
|
*/
|
|
1768
2713
|
tryLocate(moniker, labels) {
|
|
1769
|
-
|
|
2714
|
+
const result = labels ? this._registry[moniker]?.filter(hasLabels).find((factory) => hasAllLabels(factory?.labels, labels)) ?? this._registry[moniker]?.[0] : this._registry[moniker]?.[0];
|
|
2715
|
+
if (result) {
|
|
2716
|
+
result.defaultParams = {
|
|
2717
|
+
...result?.defaultParams,
|
|
2718
|
+
context: {
|
|
2719
|
+
...this.context,
|
|
2720
|
+
...result?.defaultParams?.context
|
|
2721
|
+
}
|
|
2722
|
+
};
|
|
2723
|
+
}
|
|
2724
|
+
return result;
|
|
1770
2725
|
}
|
|
1771
2726
|
};
|
|
1772
2727
|
|
|
2728
|
+
// src/createDeclarationPayload.ts
|
|
2729
|
+
import { isDefined as isDefined12 } from "@xylabs/sdk-js";
|
|
2730
|
+
import { PayloadBuilder as PayloadBuilder11 } from "@xyo-network/payload-builder";
|
|
2731
|
+
import { ChainStakeIntentSchema } from "@xyo-network/xl1-protocol";
|
|
2732
|
+
var createDeclarationIntent = /* @__PURE__ */ __name((address, intent, nbf, exp) => {
|
|
2733
|
+
const expiration = isDefined12(exp) ? exp : nbf + 1e4;
|
|
2734
|
+
const redeclarationIntent = new PayloadBuilder11({
|
|
2735
|
+
schema: ChainStakeIntentSchema
|
|
2736
|
+
}).fields({
|
|
2737
|
+
from: address,
|
|
2738
|
+
intent,
|
|
2739
|
+
nbf,
|
|
2740
|
+
exp: expiration
|
|
2741
|
+
}).build();
|
|
2742
|
+
return redeclarationIntent;
|
|
2743
|
+
}, "createDeclarationIntent");
|
|
2744
|
+
|
|
1773
2745
|
// src/eip-712/Payloads/EIP712Data.ts
|
|
1774
|
-
import { AsObjectFactory } from "@xylabs/sdk-js";
|
|
2746
|
+
import { AsObjectFactory as AsObjectFactory2 } from "@xylabs/sdk-js";
|
|
1775
2747
|
import { isPayloadOfZodType } from "@xyo-network/payload-model";
|
|
1776
2748
|
import z19 from "zod";
|
|
1777
2749
|
|
|
@@ -1806,10 +2778,10 @@ var EIP712DataPayloadFieldsZod = z19.object({
|
|
|
1806
2778
|
});
|
|
1807
2779
|
var EIP712DataPayloadSchema = "network.xyo.chains.ethereum.eip712.data";
|
|
1808
2780
|
var isEIP712DataPayload = isPayloadOfZodType(EIP712DataPayloadFieldsZod, EIP712DataPayloadSchema);
|
|
1809
|
-
var asEIP712DataPayload =
|
|
2781
|
+
var asEIP712DataPayload = AsObjectFactory2.create(isEIP712DataPayload);
|
|
1810
2782
|
|
|
1811
2783
|
// src/eip-712/Payloads/EIP712Signature.ts
|
|
1812
|
-
import { AsObjectFactory as
|
|
2784
|
+
import { AsObjectFactory as AsObjectFactory3, HashZod as HashZod2 } from "@xylabs/sdk-js";
|
|
1813
2785
|
import { isPayloadOfZodType as isPayloadOfZodType2 } from "@xyo-network/payload-model";
|
|
1814
2786
|
import z20 from "zod";
|
|
1815
2787
|
var EIP712SignaturePayloadFieldsZod = z20.object({
|
|
@@ -1819,14 +2791,14 @@ var EIP712SignaturePayloadFieldsZod = z20.object({
|
|
|
1819
2791
|
});
|
|
1820
2792
|
var EIP712SignaturePayloadSchema = "network.xyo.chains.ethereum.eip712.signature";
|
|
1821
2793
|
var isEIP712SignaturePayload = isPayloadOfZodType2(EIP712SignaturePayloadFieldsZod, EIP712SignaturePayloadSchema);
|
|
1822
|
-
var asEIP712SignaturePayload =
|
|
2794
|
+
var asEIP712SignaturePayload = AsObjectFactory3.create(isEIP712SignaturePayload);
|
|
1823
2795
|
|
|
1824
2796
|
// src/eip-712/sign.ts
|
|
1825
|
-
import { PayloadBuilder as
|
|
2797
|
+
import { PayloadBuilder as PayloadBuilder12 } from "@xyo-network/payload-builder";
|
|
1826
2798
|
var signEIP712Message = /* @__PURE__ */ __name(async (signer, data) => {
|
|
1827
2799
|
const { domain, types, values } = data;
|
|
1828
2800
|
const signature = await signer.signTypedData(domain, types, values);
|
|
1829
|
-
const hash = await
|
|
2801
|
+
const hash = await PayloadBuilder12.hash(data);
|
|
1830
2802
|
const address = await signer.getAddress();
|
|
1831
2803
|
return {
|
|
1832
2804
|
address,
|
|
@@ -1837,22 +2809,22 @@ var signEIP712Message = /* @__PURE__ */ __name(async (signer, data) => {
|
|
|
1837
2809
|
}, "signEIP712Message");
|
|
1838
2810
|
|
|
1839
2811
|
// src/eip-712/verify.ts
|
|
1840
|
-
import { asHash as asHash4, isUndefined as
|
|
1841
|
-
import { PayloadBuilder as
|
|
2812
|
+
import { asHash as asHash4, isUndefined as isUndefined4 } from "@xylabs/sdk-js";
|
|
2813
|
+
import { PayloadBuilder as PayloadBuilder13 } from "@xyo-network/payload-builder";
|
|
1842
2814
|
import { verifyTypedData } from "ethers/hash";
|
|
1843
2815
|
var verifyEIP712Message = /* @__PURE__ */ __name(async (data, sig) => {
|
|
1844
2816
|
const { address, signature, hash } = sig;
|
|
1845
2817
|
const { schema, ...fields } = data;
|
|
1846
2818
|
const signedHash = asHash4(hash);
|
|
1847
|
-
if (
|
|
2819
|
+
if (isUndefined4(signedHash) || signedHash !== await PayloadBuilder13.hash(data)) return false;
|
|
1848
2820
|
const recoveredAddress = verifyTypedData(fields.domain, fields.types, fields.values, signature);
|
|
1849
2821
|
return recoveredAddress.toLowerCase() === address.toLowerCase();
|
|
1850
2822
|
}, "verifyEIP712Message");
|
|
1851
2823
|
|
|
1852
2824
|
// src/multipliers.ts
|
|
1853
|
-
import { asAttoXL1 as
|
|
1854
|
-
var XL1_NETWORK_STAKING_GENESIS_PERIOD_TOTAL_EARNED_REWARDS =
|
|
1855
|
-
var XL1_NETWORK_STAKING_GENESIS_PERIOD_TOTAL_BONUS_REWARDS =
|
|
2825
|
+
import { asAttoXL1 as asAttoXL14 } from "@xyo-network/xl1-protocol";
|
|
2826
|
+
var XL1_NETWORK_STAKING_GENESIS_PERIOD_TOTAL_EARNED_REWARDS = asAttoXL14(1343884111859145740576652n);
|
|
2827
|
+
var XL1_NETWORK_STAKING_GENESIS_PERIOD_TOTAL_BONUS_REWARDS = asAttoXL14(100000000000000000000000000n);
|
|
1856
2828
|
var XL1_NETWORK_STAKING_GENESIS_PERIOD_TOTAL_REWARDS = XL1_NETWORK_STAKING_GENESIS_PERIOD_TOTAL_EARNED_REWARDS + XL1_NETWORK_STAKING_GENESIS_PERIOD_TOTAL_BONUS_REWARDS;
|
|
1857
2829
|
var RewardMultipliers = {
|
|
1858
2830
|
[`0|${XL1_NETWORK_STAKING_GENESIS_PERIOD_END_XL1_BLOCK}`]: [
|
|
@@ -1861,77 +2833,6 @@ var RewardMultipliers = {
|
|
|
1861
2833
|
]
|
|
1862
2834
|
};
|
|
1863
2835
|
|
|
1864
|
-
// src/payloads/AddressPairPayload.ts
|
|
1865
|
-
import { AsObjectFactory as AsObjectFactory3 } from "@xylabs/sdk-js";
|
|
1866
|
-
import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
|
|
1867
|
-
var AddressPairSchema = "network.xyo.address.pair";
|
|
1868
|
-
var isAddressPairPayload = isPayloadOfSchemaType(AddressPairSchema);
|
|
1869
|
-
var asAddressPairPayload = AsObjectFactory3.create(isAddressPairPayload);
|
|
1870
|
-
var asOptionalAddressPairPayload = AsObjectFactory3.createOptional(isAddressPairPayload);
|
|
1871
|
-
|
|
1872
|
-
// src/payloads/netBalancesForPayloads.ts
|
|
1873
|
-
import { hexToBigInt, toAddress as toAddress4 } from "@xylabs/sdk-js";
|
|
1874
|
-
import { span } from "@xylabs/sdk-js";
|
|
1875
|
-
import { isTransfer } from "@xyo-network/xl1-protocol";
|
|
1876
|
-
var netBalancesForPayloads = /* @__PURE__ */ __name((payloads) => {
|
|
1877
|
-
return span("netBalancesForPayloads", () => {
|
|
1878
|
-
const balances = {};
|
|
1879
|
-
for (const payload of payloads) {
|
|
1880
|
-
if (isTransfer(payload)) {
|
|
1881
|
-
const { from } = payload;
|
|
1882
|
-
for (let [address, amount] of Object.entries(payload.transfers)) {
|
|
1883
|
-
balances[toAddress4(address)] = (balances[toAddress4(address)] ?? 0n) + hexToBigInt(amount);
|
|
1884
|
-
balances[toAddress4(from)] = (balances[toAddress4(from)] ?? 0n) - hexToBigInt(amount);
|
|
1885
|
-
}
|
|
1886
|
-
}
|
|
1887
|
-
}
|
|
1888
|
-
return balances;
|
|
1889
|
-
});
|
|
1890
|
-
}, "netBalancesForPayloads");
|
|
1891
|
-
|
|
1892
|
-
// src/payloads/netSchemasForPayloads.ts
|
|
1893
|
-
import { hexToBigInt as hexToBigInt2, toAddress as toAddress5 } from "@xylabs/sdk-js";
|
|
1894
|
-
import { span as span2 } from "@xylabs/sdk-js";
|
|
1895
|
-
import { isTransfer as isTransfer2 } from "@xyo-network/xl1-protocol";
|
|
1896
|
-
var netSchemasForPayloads = /* @__PURE__ */ __name((payloads) => {
|
|
1897
|
-
return span2("netSchemasForPayloads", () => {
|
|
1898
|
-
const balances = {};
|
|
1899
|
-
for (const payload of payloads) {
|
|
1900
|
-
if (isTransfer2(payload)) {
|
|
1901
|
-
const { from } = payload;
|
|
1902
|
-
for (let [address, amount] of Object.entries(payload.transfers)) {
|
|
1903
|
-
balances[toAddress5(address)] = (balances[toAddress5(address)] ?? 0n) + hexToBigInt2(amount);
|
|
1904
|
-
balances[toAddress5(from)] = (balances[toAddress5(from)] ?? 0n) - hexToBigInt2(amount);
|
|
1905
|
-
}
|
|
1906
|
-
}
|
|
1907
|
-
}
|
|
1908
|
-
return balances;
|
|
1909
|
-
});
|
|
1910
|
-
}, "netSchemasForPayloads");
|
|
1911
|
-
|
|
1912
|
-
// src/payloads/netTransfersForPayloads.ts
|
|
1913
|
-
import { hexToBigInt as hexToBigInt3 } from "@xylabs/sdk-js";
|
|
1914
|
-
import { span as span3 } from "@xylabs/sdk-js";
|
|
1915
|
-
import { isTransfer as isTransfer3 } from "@xyo-network/xl1-protocol";
|
|
1916
|
-
function netTransfersForPayloads(payloads) {
|
|
1917
|
-
return span3("netTransfersForPayloads", () => {
|
|
1918
|
-
const transfers = {};
|
|
1919
|
-
for (const payload of payloads) {
|
|
1920
|
-
if (isTransfer3(payload)) {
|
|
1921
|
-
const { from } = payload;
|
|
1922
|
-
transfers[from] = transfers[from] ?? {};
|
|
1923
|
-
for (let [to, amount] of Object.entries(payload.transfers)) {
|
|
1924
|
-
transfers[to] = transfers[to] ?? {};
|
|
1925
|
-
transfers[to][from] = (transfers[to][from] ?? 0n) + hexToBigInt3(amount);
|
|
1926
|
-
transfers[from][to] = (transfers[from][to] ?? 0n) - hexToBigInt3(amount);
|
|
1927
|
-
}
|
|
1928
|
-
}
|
|
1929
|
-
}
|
|
1930
|
-
return transfers;
|
|
1931
|
-
});
|
|
1932
|
-
}
|
|
1933
|
-
__name(netTransfersForPayloads, "netTransfersForPayloads");
|
|
1934
|
-
|
|
1935
2836
|
// src/provider/DataLake.ts
|
|
1936
2837
|
var DataLakeViewerMoniker = "DataLakeViewer";
|
|
1937
2838
|
var DataLakeRunnerMoniker = "DataLakeRunner";
|
|
@@ -1957,6 +2858,18 @@ var NetworkStakeStepRewardsViewerMoniker = "NetworkStakeStepRewardsViewer";
|
|
|
1957
2858
|
// src/provider/viewer/XyoViewer.ts
|
|
1958
2859
|
var XyoViewerMoniker = "XyoViewer";
|
|
1959
2860
|
|
|
2861
|
+
// src/provider/XyoConnection.ts
|
|
2862
|
+
var XyoConnectionMoniker = "XyoConnection";
|
|
2863
|
+
|
|
2864
|
+
// src/provider/XyoRunner.ts
|
|
2865
|
+
var XyoRunnerMoniker = "XyoRunner";
|
|
2866
|
+
|
|
2867
|
+
// src/runners/Block.ts
|
|
2868
|
+
var BlockRunnerMoniker = "BlockRunner";
|
|
2869
|
+
|
|
2870
|
+
// src/runners/Mempool.ts
|
|
2871
|
+
var MempoolRunnerMoniker = "MempoolRunner";
|
|
2872
|
+
|
|
1960
2873
|
// src/services/StakeIntentService/ChainIndexingServiceStateSchema.ts
|
|
1961
2874
|
import { AsObjectFactory as AsObjectFactory4 } from "@xylabs/sdk-js";
|
|
1962
2875
|
import { isPayloadOfSchemaType as isPayloadOfSchemaType2, isStorageMeta } from "@xyo-network/payload-model";
|
|
@@ -1969,7 +2882,7 @@ var isChainIndexingServiceStateWithStorageMeta = /* @__PURE__ */ __name((value)
|
|
|
1969
2882
|
var asChainIndexingServiceStateWithStorageMeta = AsObjectFactory4.create(isChainIndexingServiceStateWithStorageMeta);
|
|
1970
2883
|
|
|
1971
2884
|
// src/SignedBigInt.ts
|
|
1972
|
-
import { hexToBigInt as
|
|
2885
|
+
import { hexToBigInt as hexToBigInt5, toHex as toHex5 } from "@xylabs/sdk-js";
|
|
1973
2886
|
import { isObject } from "@xylabs/sdk-js";
|
|
1974
2887
|
var isNegativeBigInt = /* @__PURE__ */ __name((value) => {
|
|
1975
2888
|
return isObject(value) && "negative" in value && typeof value.negative === "string";
|
|
@@ -1979,24 +2892,24 @@ var isPositiveBigInt = /* @__PURE__ */ __name((value) => {
|
|
|
1979
2892
|
}, "isPositiveBigInt");
|
|
1980
2893
|
var parseSignedBigInt = /* @__PURE__ */ __name((value) => {
|
|
1981
2894
|
if (isNegativeBigInt(value)) {
|
|
1982
|
-
return -
|
|
2895
|
+
return -hexToBigInt5(value.negative);
|
|
1983
2896
|
} else if (isPositiveBigInt(value)) {
|
|
1984
|
-
return
|
|
2897
|
+
return hexToBigInt5(value.positive);
|
|
1985
2898
|
} else {
|
|
1986
2899
|
throw new Error("Invalid balance type");
|
|
1987
2900
|
}
|
|
1988
2901
|
}, "parseSignedBigInt");
|
|
1989
2902
|
var toSignedBigInt = /* @__PURE__ */ __name((value) => {
|
|
1990
2903
|
return value < 0n ? {
|
|
1991
|
-
negative:
|
|
2904
|
+
negative: toHex5(-value)
|
|
1992
2905
|
} : {
|
|
1993
|
-
positive:
|
|
2906
|
+
positive: toHex5(value)
|
|
1994
2907
|
};
|
|
1995
2908
|
}, "toSignedBigInt");
|
|
1996
2909
|
var toPositiveBigInt = /* @__PURE__ */ __name((value) => {
|
|
1997
2910
|
if (isNegativeBigInt(value)) {
|
|
1998
2911
|
return {
|
|
1999
|
-
positive:
|
|
2912
|
+
positive: toHex5(0n)
|
|
2000
2913
|
};
|
|
2001
2914
|
}
|
|
2002
2915
|
if (isPositiveBigInt(value)) {
|
|
@@ -2006,15 +2919,15 @@ var toPositiveBigInt = /* @__PURE__ */ __name((value) => {
|
|
|
2006
2919
|
}
|
|
2007
2920
|
if (typeof value === "bigint") {
|
|
2008
2921
|
return {
|
|
2009
|
-
positive:
|
|
2922
|
+
positive: toHex5(value)
|
|
2010
2923
|
};
|
|
2011
2924
|
}
|
|
2012
2925
|
throw new Error("Invalid value for positive big int");
|
|
2013
2926
|
}, "toPositiveBigInt");
|
|
2014
2927
|
|
|
2015
2928
|
// src/simple/accountBalance/SimpleAccountBalanceViewer.ts
|
|
2016
|
-
import { asHash as asHash5, assertEx as
|
|
2017
|
-
import { asRange, asXL1BlockNumber as asXL1BlockNumber5, asXL1BlockRange as
|
|
2929
|
+
import { asHash as asHash5, assertEx as assertEx23, exists as exists3, isDefined as isDefined13, spanRootAsync as spanRootAsync4, ZERO_ADDRESS } from "@xylabs/sdk-js";
|
|
2930
|
+
import { asRange, asXL1BlockNumber as asXL1BlockNumber5, asXL1BlockRange as asXL1BlockRange7, AttoXL1 as AttoXL12, StepSizes as StepSizes11, TransferSchema as TransferSchema2 } from "@xyo-network/xl1-protocol";
|
|
2018
2931
|
|
|
2019
2932
|
// src/summary/model/BalancesStepSummary.ts
|
|
2020
2933
|
import { AsObjectFactory as AsObjectFactory5 } from "@xylabs/sdk-js";
|
|
@@ -2053,10 +2966,10 @@ var isTransfersStepSummaryWithStorageMeta = /* @__PURE__ */ __name((value) => {
|
|
|
2053
2966
|
var asTransfersStepSummaryWithStorageMeta = AsObjectFactory7.create(isTransfersStepSummaryWithStorageMeta);
|
|
2054
2967
|
|
|
2055
2968
|
// src/summary/primitives/balances/balancesStepSummaryFromRange.ts
|
|
2056
|
-
import { assertEx as
|
|
2057
|
-
import { PayloadBuilder as
|
|
2969
|
+
import { assertEx as assertEx20 } from "@xylabs/sdk-js";
|
|
2970
|
+
import { PayloadBuilder as PayloadBuilder14 } from "@xyo-network/payload-builder";
|
|
2058
2971
|
import { isAnyPayload } from "@xyo-network/payload-model";
|
|
2059
|
-
import { StepSizes as
|
|
2972
|
+
import { StepSizes as StepSizes8 } from "@xyo-network/xl1-protocol";
|
|
2060
2973
|
async function balancesStepSummaryFromRange(context, range) {
|
|
2061
2974
|
const frameHeadHash = await hashFromBlockNumber(context, range[1]);
|
|
2062
2975
|
const frameSize = range[1] - range[0] + 1;
|
|
@@ -2076,8 +2989,8 @@ async function balancesStepSummaryFromRange(context, range) {
|
|
|
2076
2989
|
balances
|
|
2077
2990
|
};
|
|
2078
2991
|
} else {
|
|
2079
|
-
const step =
|
|
2080
|
-
|
|
2992
|
+
const step = StepSizes8.indexOf(frameSize);
|
|
2993
|
+
assertEx20(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes8.join(", ")}`);
|
|
2081
2994
|
const summaryResult = await context.summaryMap.get(`${frameHeadHash}|${frameSize}`);
|
|
2082
2995
|
if (isAnyPayload(summaryResult)) {
|
|
2083
2996
|
result = summaryResult;
|
|
@@ -2109,27 +3022,29 @@ async function balancesStepSummaryFromRange(context, range) {
|
|
|
2109
3022
|
}
|
|
2110
3023
|
}
|
|
2111
3024
|
}
|
|
2112
|
-
const finalResult = await
|
|
3025
|
+
const finalResult = await PayloadBuilder14.addStorageMeta(result);
|
|
2113
3026
|
return finalResult;
|
|
2114
3027
|
}
|
|
2115
3028
|
__name(balancesStepSummaryFromRange, "balancesStepSummaryFromRange");
|
|
2116
3029
|
|
|
2117
3030
|
// src/summary/primitives/balances/balancesSummary.ts
|
|
2118
|
-
import { asAddress as asAddress3,
|
|
2119
|
-
import { asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta2,
|
|
2120
|
-
async function balancesSummary(context) {
|
|
3031
|
+
import { asAddress as asAddress3, spanRootAsync } from "@xylabs/sdk-js";
|
|
3032
|
+
import { asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta2, asXL1BlockRange as asXL1BlockRange4 } from "@xyo-network/xl1-protocol";
|
|
3033
|
+
async function balancesSummary(context, config) {
|
|
2121
3034
|
return await spanRootAsync("balancesSummary", async () => {
|
|
2122
|
-
const [headHash] =
|
|
3035
|
+
const [headHash] = isChainQualifiedHeadConfig(config) ? [
|
|
3036
|
+
config.head
|
|
3037
|
+
] : await context.head();
|
|
2123
3038
|
const headResult = await context.store.chainMap.get(headHash);
|
|
2124
3039
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta2(headResult, () => `Head block not found for hash: ${headHash}`);
|
|
2125
|
-
const
|
|
2126
|
-
|
|
2127
|
-
rangeStart,
|
|
3040
|
+
const range = isChainQualifiedRangeConfig(config) ? config.range : asXL1BlockRange4([
|
|
3041
|
+
0,
|
|
2128
3042
|
headBoundWitness.block
|
|
2129
|
-
],
|
|
3043
|
+
], true);
|
|
3044
|
+
const ranges = deepCalculateFramesFromRange(asXL1BlockRange4(range, {
|
|
2130
3045
|
name: "balancesSummary"
|
|
2131
3046
|
}));
|
|
2132
|
-
const summaries = await Promise.all(ranges.map((
|
|
3047
|
+
const summaries = await Promise.all(ranges.map((range2) => balancesStepSummaryFromRange(context, range2)));
|
|
2133
3048
|
const balances = {};
|
|
2134
3049
|
for (let summary of summaries) {
|
|
2135
3050
|
for (const [address, balance] of Object.entries(summary.balances)) {
|
|
@@ -2139,22 +3054,21 @@ async function balancesSummary(context) {
|
|
|
2139
3054
|
}
|
|
2140
3055
|
return [
|
|
2141
3056
|
balances,
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
headHash
|
|
3057
|
+
{
|
|
3058
|
+
range,
|
|
3059
|
+
head: headHash
|
|
3060
|
+
}
|
|
2147
3061
|
];
|
|
2148
3062
|
});
|
|
2149
3063
|
}
|
|
2150
3064
|
__name(balancesSummary, "balancesSummary");
|
|
2151
3065
|
|
|
2152
3066
|
// src/summary/primitives/schemas/schemasStepSummaryFromRange.ts
|
|
2153
|
-
import { assertEx as
|
|
3067
|
+
import { assertEx as assertEx21 } from "@xylabs/sdk-js";
|
|
2154
3068
|
import { isBoundWitness } from "@xyo-network/boundwitness-model";
|
|
2155
|
-
import { PayloadBuilder as
|
|
3069
|
+
import { PayloadBuilder as PayloadBuilder15 } from "@xyo-network/payload-builder";
|
|
2156
3070
|
import { isAnyPayload as isAnyPayload2, isHashMeta } from "@xyo-network/payload-model";
|
|
2157
|
-
import { StepSizes as
|
|
3071
|
+
import { StepSizes as StepSizes9 } from "@xyo-network/xl1-protocol";
|
|
2158
3072
|
async function schemasStepSummaryFromRange(context, range) {
|
|
2159
3073
|
const frameHeadHash = await hashFromBlockNumber(context, range[1]);
|
|
2160
3074
|
const frameSize = range[1] - range[0] + 1;
|
|
@@ -2181,8 +3095,8 @@ async function schemasStepSummaryFromRange(context, range) {
|
|
|
2181
3095
|
schemas
|
|
2182
3096
|
};
|
|
2183
3097
|
} else {
|
|
2184
|
-
const step =
|
|
2185
|
-
|
|
3098
|
+
const step = StepSizes9.indexOf(frameSize);
|
|
3099
|
+
assertEx21(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes9.join(", ")}`);
|
|
2186
3100
|
const summaryResult = await context.summaryMap.get(`${frameHeadHash}|${frameSize}`);
|
|
2187
3101
|
if (isAnyPayload2(summaryResult)) {
|
|
2188
3102
|
result = summaryResult;
|
|
@@ -2210,26 +3124,28 @@ async function schemasStepSummaryFromRange(context, range) {
|
|
|
2210
3124
|
}
|
|
2211
3125
|
}
|
|
2212
3126
|
}
|
|
2213
|
-
return await
|
|
3127
|
+
return await PayloadBuilder15.addHashMeta(result);
|
|
2214
3128
|
}
|
|
2215
3129
|
__name(schemasStepSummaryFromRange, "schemasStepSummaryFromRange");
|
|
2216
3130
|
|
|
2217
3131
|
// src/summary/primitives/schemas/schemasSummary.ts
|
|
2218
|
-
import {
|
|
2219
|
-
import { asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta3,
|
|
2220
|
-
async function schemasSummary(context) {
|
|
3132
|
+
import { spanRootAsync as spanRootAsync2 } from "@xylabs/sdk-js";
|
|
3133
|
+
import { asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta3, asXL1BlockRange as asXL1BlockRange5 } from "@xyo-network/xl1-protocol";
|
|
3134
|
+
async function schemasSummary(context, config) {
|
|
2221
3135
|
return await spanRootAsync2("schemasSummary", async () => {
|
|
2222
|
-
const [headHash] =
|
|
3136
|
+
const [headHash] = isChainQualifiedHeadConfig(config) ? [
|
|
3137
|
+
config.head
|
|
3138
|
+
] : await context.head();
|
|
2223
3139
|
const headResult = await context.store.chainMap.get(headHash);
|
|
2224
3140
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta3(headResult, () => `Head block not found for hash: ${headHash}`);
|
|
2225
|
-
const
|
|
2226
|
-
|
|
2227
|
-
rangeStart,
|
|
3141
|
+
const range = isChainQualifiedRangeConfig(config) ? config.range : asXL1BlockRange5([
|
|
3142
|
+
0,
|
|
2228
3143
|
headBoundWitness.block
|
|
2229
|
-
],
|
|
3144
|
+
], true);
|
|
3145
|
+
const ranges = deepCalculateFramesFromRange(asXL1BlockRange5(range, {
|
|
2230
3146
|
name: "schemasSummary"
|
|
2231
3147
|
}));
|
|
2232
|
-
const summaries = await Promise.all(ranges.map((
|
|
3148
|
+
const summaries = await Promise.all(ranges.map((range2) => schemasStepSummaryFromRange(context, range2)));
|
|
2233
3149
|
const results = {};
|
|
2234
3150
|
for (let summary of summaries) {
|
|
2235
3151
|
for (const [schema, count] of Object.entries(summary.schemas)) {
|
|
@@ -2238,38 +3154,39 @@ async function schemasSummary(context) {
|
|
|
2238
3154
|
}
|
|
2239
3155
|
return [
|
|
2240
3156
|
results,
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
headHash
|
|
3157
|
+
{
|
|
3158
|
+
range,
|
|
3159
|
+
head: headHash
|
|
3160
|
+
}
|
|
2246
3161
|
];
|
|
2247
3162
|
});
|
|
2248
3163
|
}
|
|
2249
3164
|
__name(schemasSummary, "schemasSummary");
|
|
2250
3165
|
|
|
2251
3166
|
// src/summary/primitives/transfers/transfersStepSummaryFromRange.ts
|
|
2252
|
-
import { assertEx as
|
|
2253
|
-
import { PayloadBuilder as
|
|
3167
|
+
import { assertEx as assertEx22 } from "@xylabs/sdk-js";
|
|
3168
|
+
import { PayloadBuilder as PayloadBuilder16 } from "@xyo-network/payload-builder";
|
|
2254
3169
|
import { isAnyPayload as isAnyPayload3 } from "@xyo-network/payload-model";
|
|
2255
|
-
import { StepSizes as
|
|
3170
|
+
import { StepSizes as StepSizes10 } from "@xyo-network/xl1-protocol";
|
|
2256
3171
|
|
|
2257
3172
|
// src/summary/primitives/transfers/transfersSummary.ts
|
|
2258
|
-
import { asAddress as asAddress4,
|
|
2259
|
-
import { asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta4,
|
|
2260
|
-
async function transfersSummary(
|
|
3173
|
+
import { asAddress as asAddress4, spanRootAsync as spanRootAsync3 } from "@xylabs/sdk-js";
|
|
3174
|
+
import { asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta4, asXL1BlockRange as asXL1BlockRange6 } from "@xyo-network/xl1-protocol";
|
|
3175
|
+
async function transfersSummary(context, config) {
|
|
2261
3176
|
return await spanRootAsync3("transferSummary", async () => {
|
|
2262
|
-
const [headHash] =
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
const
|
|
2266
|
-
const
|
|
2267
|
-
|
|
3177
|
+
const [headHash] = isChainQualifiedHeadConfig(config) ? [
|
|
3178
|
+
config.head
|
|
3179
|
+
] : await context.head();
|
|
3180
|
+
const headResult = await context.store.chainMap.get(headHash);
|
|
3181
|
+
const headBoundWitness = asBlockBoundWitnessWithStorageMeta4(headResult, () => `Head block not found for hash: ${headHash}`);
|
|
3182
|
+
const range = isChainQualifiedRangeConfig(config) ? config.range : asXL1BlockRange6([
|
|
3183
|
+
0,
|
|
2268
3184
|
headBoundWitness.block
|
|
2269
|
-
],
|
|
3185
|
+
], true);
|
|
3186
|
+
const ranges = deepCalculateFramesFromRange(asXL1BlockRange6(range, {
|
|
2270
3187
|
name: "transfersSummary"
|
|
2271
3188
|
}));
|
|
2272
|
-
const summaries = await Promise.all(ranges.map((
|
|
3189
|
+
const summaries = await Promise.all(ranges.map((range2) => transfersStepSummaryFromRange(context, range2)));
|
|
2273
3190
|
const transfers = {};
|
|
2274
3191
|
for (let summary of summaries) {
|
|
2275
3192
|
for (const [from, toMap] of Object.entries(summary.transfers)) {
|
|
@@ -2283,11 +3200,10 @@ async function transfersSummary(transferContext) {
|
|
|
2283
3200
|
}
|
|
2284
3201
|
return [
|
|
2285
3202
|
transfers,
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
headHash
|
|
3203
|
+
{
|
|
3204
|
+
range,
|
|
3205
|
+
head: headHash
|
|
3206
|
+
}
|
|
2291
3207
|
];
|
|
2292
3208
|
});
|
|
2293
3209
|
}
|
|
@@ -2320,8 +3236,8 @@ async function transfersStepSummaryFromRange(context, range) {
|
|
|
2320
3236
|
transfers
|
|
2321
3237
|
};
|
|
2322
3238
|
} else {
|
|
2323
|
-
const step =
|
|
2324
|
-
|
|
3239
|
+
const step = StepSizes10.indexOf(frameSize);
|
|
3240
|
+
assertEx22(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes10.join(", ")}`);
|
|
2325
3241
|
const key = transfersSummaryKey(frameHeadHash, frameSize);
|
|
2326
3242
|
const summaryResult = await context.summaryMap.get(key);
|
|
2327
3243
|
if (isAnyPayload3(summaryResult)) {
|
|
@@ -2360,12 +3276,13 @@ async function transfersStepSummaryFromRange(context, range) {
|
|
|
2360
3276
|
}
|
|
2361
3277
|
}
|
|
2362
3278
|
}
|
|
2363
|
-
const finalResult = await
|
|
3279
|
+
const finalResult = await PayloadBuilder16.addStorageMeta(result);
|
|
2364
3280
|
return finalResult;
|
|
2365
3281
|
}
|
|
2366
3282
|
__name(transfersStepSummaryFromRange, "transfersStepSummaryFromRange");
|
|
2367
3283
|
|
|
2368
3284
|
// src/viewers/AccountBalance.ts
|
|
3285
|
+
import { zodIsFactory as zodIsFactory2 } from "@xylabs/zod";
|
|
2369
3286
|
import { WithHashMetaZod } from "@xyo-network/payload-model";
|
|
2370
3287
|
import { TransferZod } from "@xyo-network/xl1-protocol";
|
|
2371
3288
|
import { BlockBoundWitnessZod, TransactionBoundWitnessZod } from "@xyo-network/xl1-protocol";
|
|
@@ -2375,6 +3292,10 @@ var AccountBalanceHistoryItemZod = z21.tuple([
|
|
|
2375
3292
|
WithHashMetaZod(TransactionBoundWitnessZod).nullable(),
|
|
2376
3293
|
WithHashMetaZod(TransferZod)
|
|
2377
3294
|
]);
|
|
3295
|
+
var AccountBalanceQualificationZod = ChainQualificationZod;
|
|
3296
|
+
var isAccountBalanceQualification = zodIsFactory2(AccountBalanceQualificationZod);
|
|
3297
|
+
var AccountBalanceConfigZod = ChainQualifiedConfigZod;
|
|
3298
|
+
var isAccountBalanceCOnfig = zodIsFactory2(AccountBalanceConfigZod);
|
|
2378
3299
|
var AccountBalanceViewerMoniker = "AccountBalanceViewer";
|
|
2379
3300
|
|
|
2380
3301
|
// src/viewers/Block.ts
|
|
@@ -2383,8 +3304,23 @@ var BlockViewerMoniker = "BlockViewer";
|
|
|
2383
3304
|
// src/viewers/BlockReward.ts
|
|
2384
3305
|
var BlockRewardViewerMoniker = "BlockRewardViewer";
|
|
2385
3306
|
|
|
2386
|
-
// src/viewers/
|
|
2387
|
-
|
|
3307
|
+
// src/viewers/BlockValidation.ts
|
|
3308
|
+
import { zodIsFactory as zodIsFactory3 } from "@xylabs/zod";
|
|
3309
|
+
import z22 from "zod";
|
|
3310
|
+
var BlockValidationQualificationZod = ChainQualificationZod;
|
|
3311
|
+
var isBlockValidationQualification = zodIsFactory3(BlockValidationQualificationZod);
|
|
3312
|
+
var BlockValidationConfigFieldsZod = z22.object({
|
|
3313
|
+
value: z22.boolean().optional(),
|
|
3314
|
+
state: z22.boolean().optional()
|
|
3315
|
+
});
|
|
3316
|
+
var BlockValidationConfigZod = z22.union([
|
|
3317
|
+
BlockValidationConfigFieldsZod.extend(ChainQualifiedHeadConfigZod.shape),
|
|
3318
|
+
BlockValidationConfigFieldsZod.extend(ChainQualifiedRangeConfigZod.shape),
|
|
3319
|
+
BlockValidationConfigFieldsZod,
|
|
3320
|
+
z22.object({})
|
|
3321
|
+
]);
|
|
3322
|
+
var isBlockValidationConfig = zodIsFactory3(BlockValidationConfigZod);
|
|
3323
|
+
var BlockValidationViewerMoniker = "BlockValidationViewer";
|
|
2388
3324
|
|
|
2389
3325
|
// src/viewers/ChainContract.ts
|
|
2390
3326
|
var ChainContractViewerMoniker = "ChainContractViewer";
|
|
@@ -2395,15 +3331,15 @@ var ChainStakeViewerMoniker = "ChainStakeViewer";
|
|
|
2395
3331
|
// src/viewers/Mempool.ts
|
|
2396
3332
|
import { HashZod as HashZod3 } from "@xylabs/sdk-js";
|
|
2397
3333
|
import { XL1BlockRangeZod as XL1BlockRangeZod2 } from "@xyo-network/xl1-protocol";
|
|
2398
|
-
import
|
|
2399
|
-
var PendingTransactionsOptionsZod =
|
|
3334
|
+
import z23 from "zod";
|
|
3335
|
+
var PendingTransactionsOptionsZod = z23.object({
|
|
2400
3336
|
cursor: HashZod3.optional(),
|
|
2401
|
-
limit:
|
|
3337
|
+
limit: z23.number().int().positive().optional(),
|
|
2402
3338
|
window: XL1BlockRangeZod2.optional()
|
|
2403
3339
|
});
|
|
2404
|
-
var PendingBlocksOptionsZod =
|
|
3340
|
+
var PendingBlocksOptionsZod = z23.object({
|
|
2405
3341
|
cursor: HashZod3.optional(),
|
|
2406
|
-
limit:
|
|
3342
|
+
limit: z23.number().int().positive().optional(),
|
|
2407
3343
|
window: XL1BlockRangeZod2.optional()
|
|
2408
3344
|
});
|
|
2409
3345
|
var MempoolViewerMoniker = "MempoolViewer";
|
|
@@ -2435,6 +3371,14 @@ var StepViewerMoniker = "StepViewer";
|
|
|
2435
3371
|
// src/viewers/TimeSync.ts
|
|
2436
3372
|
var TimeSyncViewerMoniker = "TimeSyncViewer";
|
|
2437
3373
|
|
|
3374
|
+
// src/viewers/TransactionValidation.ts
|
|
3375
|
+
import { zodIsFactory as zodIsFactory4 } from "@xylabs/zod";
|
|
3376
|
+
var TransactionValidationQualificationZod = ChainQualificationZod;
|
|
3377
|
+
var isTransactionValidationQualification = zodIsFactory4(TransactionValidationQualificationZod);
|
|
3378
|
+
var TransactionValidationConfigZod = ChainQualifiedConfigZod;
|
|
3379
|
+
var isTransactionValidationConfig = zodIsFactory4(TransactionValidationConfigZod);
|
|
3380
|
+
var TransactionValidationViewerMoniker = "TransactionValidationViewer";
|
|
3381
|
+
|
|
2438
3382
|
// src/viewers/TransferBalance.ts
|
|
2439
3383
|
var TransferBalanceViewerMoniker = "TransferBalanceViewer";
|
|
2440
3384
|
|
|
@@ -2455,47 +3399,47 @@ var SimpleAccountBalanceViewer = class _SimpleAccountBalanceViewer extends Abstr
|
|
|
2455
3399
|
AccountBalanceViewerMoniker
|
|
2456
3400
|
];
|
|
2457
3401
|
moniker = _SimpleAccountBalanceViewer.defaultMoniker;
|
|
2458
|
-
|
|
2459
|
-
|
|
3402
|
+
_blockViewer;
|
|
3403
|
+
get balanceSummaryContext() {
|
|
3404
|
+
return this.params.balanceSummaryContext;
|
|
2460
3405
|
}
|
|
2461
|
-
get
|
|
2462
|
-
return this.
|
|
3406
|
+
get blockViewer() {
|
|
3407
|
+
return this._blockViewer;
|
|
2463
3408
|
}
|
|
2464
3409
|
get transfersSummaryContext() {
|
|
2465
3410
|
return this.params.transfersSummaryContext;
|
|
2466
3411
|
}
|
|
2467
|
-
static async paramsHandler(params) {
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
};
|
|
3412
|
+
static async paramsHandler(params = {}) {
|
|
3413
|
+
assertEx23(params.transfersSummaryContext, () => "transfersSummaryContext is required");
|
|
3414
|
+
assertEx23(params.balanceSummaryContext, () => "balanceSummaryContext is required");
|
|
3415
|
+
return await super.paramsHandler({
|
|
3416
|
+
...params
|
|
3417
|
+
});
|
|
2474
3418
|
}
|
|
2475
|
-
async accountBalance(address,
|
|
3419
|
+
async accountBalance(address, config) {
|
|
2476
3420
|
const balances = await this.accountBalances([
|
|
2477
3421
|
address
|
|
2478
|
-
],
|
|
3422
|
+
], config);
|
|
2479
3423
|
return balances[address] ?? AttoXL12(0n);
|
|
2480
3424
|
}
|
|
2481
|
-
accountBalanceHistories(
|
|
2482
|
-
|
|
3425
|
+
async accountBalanceHistories(addresses, config = {}) {
|
|
3426
|
+
return (await this.qualifiedAccountBalanceHistories(addresses, config))[0];
|
|
2483
3427
|
}
|
|
2484
|
-
async accountBalanceHistory(address,
|
|
2485
|
-
const range =
|
|
2486
|
-
const startingRange =
|
|
3428
|
+
async accountBalanceHistory(address, config) {
|
|
3429
|
+
const range = isChainQualifiedRangeConfig(config) ? config.range : void 0;
|
|
3430
|
+
const startingRange = asXL1BlockRange7(range ?? [
|
|
2487
3431
|
0,
|
|
2488
3432
|
await this.blockViewer.currentBlockNumber()
|
|
2489
3433
|
], true);
|
|
2490
3434
|
const blockNumbers = await this.distillTransferHistory(address, startingRange);
|
|
2491
|
-
const blocks = (await Promise.all(blockNumbers.map(async (bn) => await this.blockViewer.blockByNumber(bn)))).filter(
|
|
3435
|
+
const blocks = (await Promise.all(blockNumbers.map(async (bn) => await this.blockViewer.blockByNumber(bn)))).filter(exists3);
|
|
2492
3436
|
const result = [];
|
|
2493
3437
|
for (const block of blocks) {
|
|
2494
|
-
const transferIndexes = block[0].payload_schemas.map((schema, index) => schema ===
|
|
3438
|
+
const transferIndexes = block[0].payload_schemas.map((schema, index) => schema === TransferSchema2 ? index : void 0).filter(exists3);
|
|
2495
3439
|
const transfers = transferIndexes.map((index) => {
|
|
2496
3440
|
const hash = block[0].payload_hashes[index];
|
|
2497
|
-
return
|
|
2498
|
-
}).filter(
|
|
3441
|
+
return assertEx23(block[1].find((p) => p._hash === hash), () => `Error: Could not find Transfer with hash ${hash} in block ${block[0]._hash}`);
|
|
3442
|
+
}).filter(exists3).filter((t) => t.from === address || isDefined13(t.transfers[address]));
|
|
2499
3443
|
if (transfers.length === 0) {
|
|
2500
3444
|
continue;
|
|
2501
3445
|
}
|
|
@@ -2513,15 +3457,19 @@ var SimpleAccountBalanceViewer = class _SimpleAccountBalanceViewer extends Abstr
|
|
|
2513
3457
|
}
|
|
2514
3458
|
return result;
|
|
2515
3459
|
}
|
|
2516
|
-
async accountBalances(address,
|
|
2517
|
-
const [result] = await this.qualifiedAccountBalances(address,
|
|
3460
|
+
async accountBalances(address, config) {
|
|
3461
|
+
const [result] = await this.qualifiedAccountBalances(address, config ?? {});
|
|
2518
3462
|
return result;
|
|
2519
3463
|
}
|
|
2520
|
-
async
|
|
2521
|
-
|
|
2522
|
-
|
|
3464
|
+
async createHandler() {
|
|
3465
|
+
await super.createHandler();
|
|
3466
|
+
this._blockViewer = await this.locator.getInstance(BlockViewerMoniker);
|
|
3467
|
+
}
|
|
3468
|
+
async qualifiedAccountBalanceHistories(addresses, config) {
|
|
3469
|
+
const head = isChainQualifiedHeadConfig(config) ? config.head : await this.blockViewer.currentBlockHash();
|
|
3470
|
+
const range = isChainQualifiedRangeConfig(config) ? config.range : asXL1BlockRange7([
|
|
2523
3471
|
0,
|
|
2524
|
-
|
|
3472
|
+
assertEx23(await this.blockViewer.blockByHash(head), () => `Error: Could not find block with hash ${head}`)[0].block
|
|
2525
3473
|
]);
|
|
2526
3474
|
const qualifiedEntries = await Promise.all(addresses.map(async (address) => [
|
|
2527
3475
|
address,
|
|
@@ -2533,21 +3481,25 @@ var SimpleAccountBalanceViewer = class _SimpleAccountBalanceViewer extends Abstr
|
|
|
2533
3481
|
history
|
|
2534
3482
|
];
|
|
2535
3483
|
});
|
|
2536
|
-
const qualifiedRange = qualifiedEntries[0][1][1];
|
|
2537
|
-
const qualifiedHeadHash = qualifiedEntries[0][1][
|
|
2538
|
-
for (const [_, [__, range2,
|
|
2539
|
-
|
|
2540
|
-
|
|
3484
|
+
const qualifiedRange = qualifiedEntries[0][1][1].range;
|
|
3485
|
+
const qualifiedHeadHash = qualifiedEntries[0][1][1].head;
|
|
3486
|
+
for (const [_, [__, { range: range2, head: head2 }]] of qualifiedEntries) {
|
|
3487
|
+
assertEx23(range2[0] === qualifiedRange[0] && range2[1] === qualifiedRange[1], () => "Inconsistent ranges in qualifiedAccountBalanceHistories");
|
|
3488
|
+
assertEx23(head2 === qualifiedHeadHash, () => "Inconsistent head hashes in qualifiedAccountBalanceHistories");
|
|
2541
3489
|
}
|
|
2542
3490
|
return [
|
|
2543
3491
|
Object.fromEntries(entries),
|
|
2544
|
-
|
|
2545
|
-
|
|
3492
|
+
{
|
|
3493
|
+
range: qualifiedRange,
|
|
3494
|
+
head: qualifiedHeadHash
|
|
3495
|
+
}
|
|
2546
3496
|
];
|
|
2547
3497
|
}
|
|
2548
|
-
async qualifiedAccountBalances(address,
|
|
3498
|
+
async qualifiedAccountBalances(address, config) {
|
|
2549
3499
|
return await spanRootAsync4("qualifiedAccountsBalances", async () => {
|
|
2550
|
-
const qualifiedSummary = await balancesSummary(
|
|
3500
|
+
const qualifiedSummary = await balancesSummary({
|
|
3501
|
+
...this.balanceSummaryContext
|
|
3502
|
+
}, config);
|
|
2551
3503
|
const result = {};
|
|
2552
3504
|
for (const addr of address) {
|
|
2553
3505
|
const summaryBalance = qualifiedSummary[0][addr] ?? 0n;
|
|
@@ -2555,18 +3507,24 @@ var SimpleAccountBalanceViewer = class _SimpleAccountBalanceViewer extends Abstr
|
|
|
2555
3507
|
}
|
|
2556
3508
|
return [
|
|
2557
3509
|
result,
|
|
2558
|
-
qualifiedSummary[1]
|
|
2559
|
-
qualifiedSummary[2]
|
|
3510
|
+
qualifiedSummary[1]
|
|
2560
3511
|
];
|
|
2561
3512
|
});
|
|
2562
3513
|
}
|
|
3514
|
+
async startHandler() {
|
|
3515
|
+
await super.startHandler();
|
|
3516
|
+
await Promise.all([
|
|
3517
|
+
this.accountBalance(ZERO_ADDRESS),
|
|
3518
|
+
this.accountBalanceHistory(ZERO_ADDRESS)
|
|
3519
|
+
]);
|
|
3520
|
+
}
|
|
2563
3521
|
async distillTransferHistory(address, range, max = 50) {
|
|
2564
|
-
if (range[1] - range[0] <=
|
|
3522
|
+
if (range[1] - range[0] <= StepSizes11[0] || max <= 1) {
|
|
2565
3523
|
return Array.from({
|
|
2566
3524
|
length: range[1] - range[0] + 1
|
|
2567
3525
|
}, (_, i) => range[1] - i).slice(0, max).map((n) => asXL1BlockNumber5(n, true));
|
|
2568
3526
|
}
|
|
2569
|
-
const frames = deepCalculateFramesFromRange(
|
|
3527
|
+
const frames = deepCalculateFramesFromRange(asXL1BlockRange7(range, true));
|
|
2570
3528
|
const transferSummaryPairs = await Promise.all(frames.map(async (frame) => {
|
|
2571
3529
|
return [
|
|
2572
3530
|
frame,
|
|
@@ -2579,8 +3537,8 @@ var SimpleAccountBalanceViewer = class _SimpleAccountBalanceViewer extends Abstr
|
|
|
2579
3537
|
});
|
|
2580
3538
|
const resultBlockNumbers = /* @__PURE__ */ new Set();
|
|
2581
3539
|
for (const [frame] of sortedTransferSummaryPairs) {
|
|
2582
|
-
if (frame[1] - frame[0] + 1 >
|
|
2583
|
-
const values = await this.distillTransferHistory(address,
|
|
3540
|
+
if (frame[1] - frame[0] + 1 > StepSizes11[0]) {
|
|
3541
|
+
const values = await this.distillTransferHistory(address, asXL1BlockRange7([
|
|
2584
3542
|
frame[0],
|
|
2585
3543
|
frame[1] - 1
|
|
2586
3544
|
], true), max - resultBlockNumbers.size);
|
|
@@ -2604,20 +3562,20 @@ var SimpleAccountBalanceViewer = class _SimpleAccountBalanceViewer extends Abstr
|
|
|
2604
3562
|
async qualifiedAccountBalanceHistory(address, headOrRange) {
|
|
2605
3563
|
const range = asRange(headOrRange);
|
|
2606
3564
|
const headHash = asHash5(headOrRange);
|
|
2607
|
-
const [head] =
|
|
2608
|
-
const startingRange =
|
|
3565
|
+
const [head] = assertEx23(isDefined13(headHash) ? await this.blockViewer.blockByHash(headHash) : await this.blockViewer.currentBlock(), () => "Could not resolve head block");
|
|
3566
|
+
const startingRange = asXL1BlockRange7(range ?? [
|
|
2609
3567
|
0,
|
|
2610
3568
|
head.block
|
|
2611
3569
|
], true);
|
|
2612
3570
|
const blockNumbers = await this.distillTransferHistory(address, startingRange);
|
|
2613
|
-
const blocks = (await Promise.all(blockNumbers.map(async (bn) => await this.blockViewer.blockByNumber(bn)))).filter(
|
|
3571
|
+
const blocks = (await Promise.all(blockNumbers.map(async (bn) => await this.blockViewer.blockByNumber(bn)))).filter(exists3);
|
|
2614
3572
|
const result = [];
|
|
2615
3573
|
for (const block of blocks) {
|
|
2616
|
-
const transferIndexes = block[0].payload_schemas.map((schema, index) => schema ===
|
|
3574
|
+
const transferIndexes = block[0].payload_schemas.map((schema, index) => schema === TransferSchema2 ? index : void 0).filter(exists3);
|
|
2617
3575
|
const transfers = transferIndexes.map((index) => {
|
|
2618
3576
|
const hash = block[0].payload_hashes[index];
|
|
2619
|
-
return
|
|
2620
|
-
}).filter(
|
|
3577
|
+
return assertEx23(block[1].find((p) => p._hash === hash), () => `Error: Could not find Transfer with hash ${hash} in block ${block[0]._hash}`);
|
|
3578
|
+
}).filter(exists3).filter((t) => t.from === address || isDefined13(t.transfers[address]));
|
|
2621
3579
|
if (transfers.length === 0) {
|
|
2622
3580
|
continue;
|
|
2623
3581
|
}
|
|
@@ -2635,8 +3593,10 @@ var SimpleAccountBalanceViewer = class _SimpleAccountBalanceViewer extends Abstr
|
|
|
2635
3593
|
}
|
|
2636
3594
|
return [
|
|
2637
3595
|
result,
|
|
2638
|
-
|
|
2639
|
-
|
|
3596
|
+
{
|
|
3597
|
+
range: startingRange,
|
|
3598
|
+
head: head._hash
|
|
3599
|
+
}
|
|
2640
3600
|
];
|
|
2641
3601
|
}
|
|
2642
3602
|
};
|
|
@@ -2645,7 +3605,7 @@ SimpleAccountBalanceViewer = _ts_decorate([
|
|
|
2645
3605
|
], SimpleAccountBalanceViewer);
|
|
2646
3606
|
|
|
2647
3607
|
// src/simple/block/SimpleBlockViewer.ts
|
|
2648
|
-
import { assertEx as
|
|
3608
|
+
import { assertEx as assertEx24, exists as exists4, isDefined as isDefined14, isUndefined as isUndefined5, spanRootAsync as spanRootAsync5 } from "@xylabs/sdk-js";
|
|
2649
3609
|
import { asSignedHydratedBlockWithHashMeta, asXL1BlockNumber as asXL1BlockNumber6 } from "@xyo-network/xl1-protocol";
|
|
2650
3610
|
|
|
2651
3611
|
// src/utils/HydratedCache.ts
|
|
@@ -2679,12 +3639,12 @@ var HydratedCache = class {
|
|
|
2679
3639
|
};
|
|
2680
3640
|
|
|
2681
3641
|
// src/utils/isZodError.ts
|
|
2682
|
-
import * as
|
|
3642
|
+
import * as z24 from "zod";
|
|
2683
3643
|
var isZodError = /* @__PURE__ */ __name((error) => {
|
|
2684
|
-
return error instanceof
|
|
3644
|
+
return error instanceof z24.ZodError;
|
|
2685
3645
|
}, "isZodError");
|
|
2686
3646
|
var prettifyZodError = /* @__PURE__ */ __name((error) => {
|
|
2687
|
-
return
|
|
3647
|
+
return z24.prettifyError(error);
|
|
2688
3648
|
}, "prettifyZodError");
|
|
2689
3649
|
|
|
2690
3650
|
// src/simple/block/SimpleBlockViewer.ts
|
|
@@ -2704,21 +3664,17 @@ var SimpleBlockViewer = class _SimpleBlockViewer extends AbstractCreatableProvid
|
|
|
2704
3664
|
BlockViewerMoniker
|
|
2705
3665
|
];
|
|
2706
3666
|
moniker = _SimpleBlockViewer.defaultMoniker;
|
|
3667
|
+
_store;
|
|
2707
3668
|
_payloadCache;
|
|
2708
3669
|
_signedHydratedBlockCache;
|
|
2709
|
-
get context() {
|
|
2710
|
-
return this.params.context;
|
|
2711
|
-
}
|
|
2712
3670
|
get finalizedArchivist() {
|
|
2713
3671
|
return this.params.finalizedArchivist;
|
|
2714
3672
|
}
|
|
2715
3673
|
get hydratedBlockCache() {
|
|
2716
3674
|
if (this._signedHydratedBlockCache) return this._signedHydratedBlockCache;
|
|
2717
|
-
const chainMap = this.
|
|
2718
|
-
this._signedHydratedBlockCache = new HydratedCache(chainMap, async (
|
|
2719
|
-
const result = await hydrateBlock(
|
|
2720
|
-
chainMap: chainMap2
|
|
2721
|
-
}, hash, maxDepth, minDepth);
|
|
3675
|
+
const chainMap = this.store.chainMap;
|
|
3676
|
+
this._signedHydratedBlockCache = new HydratedCache(chainMap, async (store, hash, maxDepth, minDepth) => {
|
|
3677
|
+
const result = await hydrateBlock(store, hash, maxDepth, minDepth);
|
|
2722
3678
|
return asSignedHydratedBlockWithHashMeta(result, true);
|
|
2723
3679
|
}, 200);
|
|
2724
3680
|
return this._signedHydratedBlockCache;
|
|
@@ -2730,9 +3686,11 @@ var SimpleBlockViewer = class _SimpleBlockViewer extends AbstractCreatableProvid
|
|
|
2730
3686
|
});
|
|
2731
3687
|
return this._payloadCache;
|
|
2732
3688
|
}
|
|
3689
|
+
get store() {
|
|
3690
|
+
return this._store;
|
|
3691
|
+
}
|
|
2733
3692
|
static async paramsHandler(params) {
|
|
2734
|
-
|
|
2735
|
-
assertEx17(params.finalizedArchivist, () => "finalizedArchivist is required");
|
|
3693
|
+
assertEx24(params.finalizedArchivist, () => "finalizedArchivist is required");
|
|
2736
3694
|
return {
|
|
2737
3695
|
...await super.paramsHandler(params)
|
|
2738
3696
|
};
|
|
@@ -2745,13 +3703,27 @@ var SimpleBlockViewer = class _SimpleBlockViewer extends AbstractCreatableProvid
|
|
|
2745
3703
|
}
|
|
2746
3704
|
async blockByNumber(blockNumber) {
|
|
2747
3705
|
return await spanRootAsync5("blockByNumber", async () => {
|
|
2748
|
-
|
|
3706
|
+
const head = await this.getCurrentHead();
|
|
3707
|
+
if (isUndefined5(head)) {
|
|
3708
|
+
return null;
|
|
3709
|
+
}
|
|
3710
|
+
return asSignedHydratedBlockWithHashMeta(await hydratedBlockByNumber({
|
|
3711
|
+
chainId: head.chain,
|
|
3712
|
+
head: /* @__PURE__ */ __name(() => {
|
|
3713
|
+
return [
|
|
3714
|
+
head._hash,
|
|
3715
|
+
head.block
|
|
3716
|
+
];
|
|
3717
|
+
}, "head"),
|
|
3718
|
+
store: this.store,
|
|
3719
|
+
singletons: this.context.singletons
|
|
3720
|
+
}, blockNumber)) ?? null;
|
|
2749
3721
|
}, this.tracer);
|
|
2750
3722
|
}
|
|
2751
3723
|
async blocksByHash(hash, limit = 50) {
|
|
2752
3724
|
return await spanRootAsync5("blocksByHash", async () => {
|
|
2753
|
-
|
|
2754
|
-
|
|
3725
|
+
assertEx24(limit > 0, () => "limit must be greater than 0");
|
|
3726
|
+
assertEx24(limit <= 100, () => "limit must be less than 100");
|
|
2755
3727
|
const blocks = [];
|
|
2756
3728
|
let current = await this.blockByHash(hash);
|
|
2757
3729
|
while (current && blocks.length < limit) {
|
|
@@ -2765,8 +3737,8 @@ var SimpleBlockViewer = class _SimpleBlockViewer extends AbstractCreatableProvid
|
|
|
2765
3737
|
}
|
|
2766
3738
|
async blocksByNumber(blockNumber, limit = 50) {
|
|
2767
3739
|
return await spanRootAsync5("blocksByHash", async () => {
|
|
2768
|
-
|
|
2769
|
-
|
|
3740
|
+
assertEx24(limit > 0, () => "limit must be greater than 0");
|
|
3741
|
+
assertEx24(limit <= 100, () => "limit must be less than 100");
|
|
2770
3742
|
const blocks = [];
|
|
2771
3743
|
let current = await this.blockByNumber(blockNumber);
|
|
2772
3744
|
while (current && blocks.length < limit) {
|
|
@@ -2778,26 +3750,38 @@ var SimpleBlockViewer = class _SimpleBlockViewer extends AbstractCreatableProvid
|
|
|
2778
3750
|
return blocks.map((b) => asSignedHydratedBlockWithHashMeta(b, true));
|
|
2779
3751
|
}, this.tracer);
|
|
2780
3752
|
}
|
|
3753
|
+
async chainId(blockNumber = "latest") {
|
|
3754
|
+
return await spanRootAsync5("chainId", async () => {
|
|
3755
|
+
const block = assertEx24(blockNumber === "latest" ? await this.currentBlock() : await this.blockByNumber(blockNumber), () => `Could not find block for block number ${blockNumber}`);
|
|
3756
|
+
return block[0].chain;
|
|
3757
|
+
});
|
|
3758
|
+
}
|
|
3759
|
+
async createHandler() {
|
|
3760
|
+
await super.createHandler();
|
|
3761
|
+
this._store = {
|
|
3762
|
+
chainMap: readPayloadMapFromStore(this.params.finalizedArchivist)
|
|
3763
|
+
};
|
|
3764
|
+
}
|
|
2781
3765
|
async currentBlock() {
|
|
2782
3766
|
return await spanRootAsync5("currentBlock", async () => {
|
|
2783
|
-
const currentHead =
|
|
3767
|
+
const currentHead = assertEx24(await this.getCurrentHead(), () => "Could not find most recent block [currentBlock]");
|
|
2784
3768
|
const cache = this.hydratedBlockCache;
|
|
2785
3769
|
const block = await cache.get(currentHead._hash);
|
|
2786
3770
|
if (!block) {
|
|
2787
3771
|
console.log(`Could not find current block with hash ${currentHead._hash}`);
|
|
2788
3772
|
}
|
|
2789
|
-
return
|
|
3773
|
+
return assertEx24(block, () => "Could not find current block");
|
|
2790
3774
|
}, this.tracer);
|
|
2791
3775
|
}
|
|
2792
3776
|
async currentBlockHash() {
|
|
2793
3777
|
return await spanRootAsync5("currentBlockHash", async () => {
|
|
2794
|
-
const currentHead =
|
|
3778
|
+
const currentHead = assertEx24(await this.getCurrentHead(), () => "Could not find most recent block [currentBlockHash]");
|
|
2795
3779
|
return currentHead._hash;
|
|
2796
3780
|
}, this.tracer);
|
|
2797
3781
|
}
|
|
2798
3782
|
async currentBlockNumber() {
|
|
2799
3783
|
return await spanRootAsync5("currentBlockNumber", async () => {
|
|
2800
|
-
const currentHead =
|
|
3784
|
+
const currentHead = assertEx24(await this.getCurrentHead(), () => "Could not find most recent block [currentBlockNumber]");
|
|
2801
3785
|
return asXL1BlockNumber6(currentHead.block, {
|
|
2802
3786
|
name: "currentBlockNumber"
|
|
2803
3787
|
});
|
|
@@ -2811,7 +3795,7 @@ var SimpleBlockViewer = class _SimpleBlockViewer extends AbstractCreatableProvid
|
|
|
2811
3795
|
const [result] = await this.finalizedArchivist.get([
|
|
2812
3796
|
hash
|
|
2813
3797
|
]);
|
|
2814
|
-
if (
|
|
3798
|
+
if (isDefined14(result)) {
|
|
2815
3799
|
await this.payloadCache.set(hash, result);
|
|
2816
3800
|
}
|
|
2817
3801
|
return result ?? null;
|
|
@@ -2827,7 +3811,7 @@ var SimpleBlockViewer = class _SimpleBlockViewer extends AbstractCreatableProvid
|
|
|
2827
3811
|
const remainingPayloads = remainingHashes.length > 0 ? await this.finalizedArchivist.get(remainingHashes) : [];
|
|
2828
3812
|
return [
|
|
2829
3813
|
...cachedPayloads,
|
|
2830
|
-
...remainingPayloads.filter(
|
|
3814
|
+
...remainingPayloads.filter(exists4)
|
|
2831
3815
|
];
|
|
2832
3816
|
}
|
|
2833
3817
|
async getCurrentHead() {
|
|
@@ -2865,13 +3849,9 @@ SimpleBlockRewardViewer = _ts_decorate3([
|
|
|
2865
3849
|
creatableProvider()
|
|
2866
3850
|
], SimpleBlockRewardViewer);
|
|
2867
3851
|
|
|
2868
|
-
// src/simple/
|
|
2869
|
-
import {
|
|
2870
|
-
import {
|
|
2871
|
-
import { Account } from "@xyo-network/account";
|
|
2872
|
-
|
|
2873
|
-
// src/simple/chainStakeEvents/SimpleChainStakeEventsViewer.ts
|
|
2874
|
-
import { isDefined as isDefined13 } from "@xylabs/sdk-js";
|
|
3852
|
+
// src/simple/blockValidation/SimpleBlockValidationViewer.ts
|
|
3853
|
+
import { exists as exists5 } from "@xylabs/sdk-js";
|
|
3854
|
+
import { asXL1BlockRange as asXL1BlockRange8 } from "@xyo-network/xl1-protocol";
|
|
2875
3855
|
function _ts_decorate4(decorators, target, key, desc) {
|
|
2876
3856
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2877
3857
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2879,88 +3859,103 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
2879
3859
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2880
3860
|
}
|
|
2881
3861
|
__name(_ts_decorate4, "_ts_decorate");
|
|
2882
|
-
var
|
|
3862
|
+
var SimpleBlockValidationViewer = class _SimpleBlockValidationViewer extends AbstractCreatableProvider {
|
|
2883
3863
|
static {
|
|
2884
|
-
__name(this, "
|
|
3864
|
+
__name(this, "SimpleBlockValidationViewer");
|
|
2885
3865
|
}
|
|
2886
|
-
static defaultMoniker =
|
|
3866
|
+
static defaultMoniker = BlockValidationViewerMoniker;
|
|
2887
3867
|
static monikers = [
|
|
2888
|
-
|
|
3868
|
+
BlockValidationViewerMoniker
|
|
2889
3869
|
];
|
|
2890
|
-
moniker =
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
return this.
|
|
3870
|
+
moniker = _SimpleBlockValidationViewer.defaultMoniker;
|
|
3871
|
+
_accountBalanceViewer;
|
|
3872
|
+
_blockViewer;
|
|
3873
|
+
_uncleWindowedChainCache = null;
|
|
3874
|
+
get blockViewer() {
|
|
3875
|
+
return this._blockViewer;
|
|
2896
3876
|
}
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
const events = this.eventsFromPositions(positions);
|
|
2900
|
-
if (isDefined13(name)) {
|
|
2901
|
-
return events.filter((event) => event.name === name);
|
|
2902
|
-
}
|
|
2903
|
-
return events;
|
|
3877
|
+
get maxUncleWindowSize() {
|
|
3878
|
+
return this.params.maxUncleWindowSize;
|
|
2904
3879
|
}
|
|
2905
|
-
async
|
|
2906
|
-
|
|
3880
|
+
static async paramsHandler(params) {
|
|
3881
|
+
return {
|
|
3882
|
+
...await super.paramsHandler(params),
|
|
3883
|
+
maxUncleWindowSize: params.maxUncleWindowSize ?? 100
|
|
3884
|
+
};
|
|
2907
3885
|
}
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
staker: position.staker,
|
|
2940
|
-
staked: position.staked,
|
|
2941
|
-
amount: position.amount,
|
|
2942
|
-
id: position.id
|
|
2943
|
-
}
|
|
2944
|
-
});
|
|
3886
|
+
async createHandler() {
|
|
3887
|
+
await super.createHandler();
|
|
3888
|
+
this._accountBalanceViewer = await this.locator.getInstance(AccountBalanceViewerMoniker);
|
|
3889
|
+
this._blockViewer = await this.locator.getInstance(BlockViewerMoniker);
|
|
3890
|
+
}
|
|
3891
|
+
async qualifiedValidateBlock(block, config) {
|
|
3892
|
+
return await this.qualifiedValidateBlocks([
|
|
3893
|
+
block
|
|
3894
|
+
], config);
|
|
3895
|
+
}
|
|
3896
|
+
async qualifiedValidateBlocks(blocks, config) {
|
|
3897
|
+
const { value, state } = config ?? {
|
|
3898
|
+
shape: true,
|
|
3899
|
+
links: true,
|
|
3900
|
+
state: true
|
|
3901
|
+
};
|
|
3902
|
+
const [headBlock] = await this.blockViewer.currentBlock();
|
|
3903
|
+
const chainId = headBlock.chain;
|
|
3904
|
+
const validateValue = value ? this.doValidateValue.bind(this) : void 0;
|
|
3905
|
+
const validateState = state ? this.doValidateState.bind(this) : void 0;
|
|
3906
|
+
return [
|
|
3907
|
+
(await Promise.all([
|
|
3908
|
+
validateValue?.(blocks, chainId),
|
|
3909
|
+
validateState?.(blocks, chainId)
|
|
3910
|
+
].filter(exists5))).flat(),
|
|
3911
|
+
{
|
|
3912
|
+
head: headBlock._hash,
|
|
3913
|
+
range: asXL1BlockRange8([
|
|
3914
|
+
0,
|
|
3915
|
+
headBlock.block
|
|
3916
|
+
], true)
|
|
2945
3917
|
}
|
|
2946
|
-
|
|
2947
|
-
});
|
|
2948
|
-
return events.flat();
|
|
3918
|
+
];
|
|
2949
3919
|
}
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
return
|
|
3920
|
+
async validateBlock(block, config) {
|
|
3921
|
+
return await this.validateBlocks([
|
|
3922
|
+
block
|
|
3923
|
+
], config);
|
|
3924
|
+
}
|
|
3925
|
+
async validateBlocks(blocks, config) {
|
|
3926
|
+
return (await this.qualifiedValidateBlocks(blocks, config))[0];
|
|
3927
|
+
}
|
|
3928
|
+
async doValidateState(blocks, chainId) {
|
|
3929
|
+
const windowedUncleChain = await this.updateWindowedChainCache();
|
|
3930
|
+
const uncles = findUncles(this.context, windowedUncleChain, blocks);
|
|
3931
|
+
if (uncles.length !== 1) {
|
|
3932
|
+
throw new Error(`No uncles or greater than one uncle found in block validation, which is not supported [${uncles.length}]`);
|
|
3933
|
+
}
|
|
3934
|
+
return (await Promise.all(uncles[0].map(async (block) => {
|
|
3935
|
+
return await this.params.state(block, chainId, {
|
|
3936
|
+
accountBalance: this._accountBalanceViewer
|
|
3937
|
+
});
|
|
3938
|
+
}))).flat();
|
|
3939
|
+
}
|
|
3940
|
+
async doValidateValue(blocks, chainId) {
|
|
3941
|
+
return (await Promise.all(blocks.map(async (block) => {
|
|
3942
|
+
return await this.params.value(block, chainId);
|
|
3943
|
+
}))).flat();
|
|
3944
|
+
}
|
|
3945
|
+
async updateWindowedChainCache() {
|
|
3946
|
+
this._uncleWindowedChainCache = await getWindowedChain(this.blockViewer, this.maxUncleWindowSize, this._uncleWindowedChainCache ?? []);
|
|
3947
|
+
return [
|
|
3948
|
+
...this._uncleWindowedChainCache
|
|
3949
|
+
];
|
|
2957
3950
|
}
|
|
2958
3951
|
};
|
|
2959
|
-
|
|
3952
|
+
SimpleBlockValidationViewer = _ts_decorate4([
|
|
2960
3953
|
creatableProvider()
|
|
2961
|
-
],
|
|
3954
|
+
], SimpleBlockValidationViewer);
|
|
2962
3955
|
|
|
2963
|
-
// src/simple/chainStake/
|
|
3956
|
+
// src/simple/chainStake/SimpleStakeViewer.ts
|
|
3957
|
+
import { asAddress as asAddress5, toAddress as toAddress9 } from "@xylabs/sdk-js";
|
|
3958
|
+
import { assertEx as assertEx25 } from "@xylabs/sdk-js";
|
|
2964
3959
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
2965
3960
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2966
3961
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2968,20 +3963,16 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
2968
3963
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2969
3964
|
}
|
|
2970
3965
|
__name(_ts_decorate5, "_ts_decorate");
|
|
2971
|
-
var
|
|
3966
|
+
var SimpleStakeViewer = class _SimpleStakeViewer extends AbstractCreatableProvider {
|
|
2972
3967
|
static {
|
|
2973
|
-
__name(this, "
|
|
3968
|
+
__name(this, "SimpleStakeViewer");
|
|
2974
3969
|
}
|
|
2975
3970
|
static defaultMoniker = StakeViewerMoniker;
|
|
2976
3971
|
static monikers = [
|
|
2977
3972
|
StakeViewerMoniker
|
|
2978
3973
|
];
|
|
2979
|
-
moniker =
|
|
2980
|
-
_chainId;
|
|
3974
|
+
moniker = _SimpleStakeViewer.defaultMoniker;
|
|
2981
3975
|
_chainStakeEventsViewer;
|
|
2982
|
-
get chainId() {
|
|
2983
|
-
return assertEx18(this._chainId, () => "Chain ID not set");
|
|
2984
|
-
}
|
|
2985
3976
|
get chainMap() {
|
|
2986
3977
|
return this.params.chainMap;
|
|
2987
3978
|
}
|
|
@@ -2989,13 +3980,13 @@ var SimpleChainStakeViewer = class _SimpleChainStakeViewer extends AbstractCreat
|
|
|
2989
3980
|
return this.params.minWithdrawalBlocks ?? 10;
|
|
2990
3981
|
}
|
|
2991
3982
|
get rewardsContract() {
|
|
2992
|
-
return
|
|
3983
|
+
return toAddress9(toAddress9(1n));
|
|
2993
3984
|
}
|
|
2994
3985
|
get stakeEvents() {
|
|
2995
|
-
return
|
|
3986
|
+
return assertEx25(this._chainStakeEventsViewer, () => "Stake events viewer not set");
|
|
2996
3987
|
}
|
|
2997
3988
|
get stakingTokenAddress() {
|
|
2998
|
-
return
|
|
3989
|
+
return toAddress9("0x000000000000000000000000000011");
|
|
2999
3990
|
}
|
|
3000
3991
|
get positions() {
|
|
3001
3992
|
return this.params.positions;
|
|
@@ -3027,6 +4018,10 @@ var SimpleChainStakeViewer = class _SimpleChainStakeViewer extends AbstractCreat
|
|
|
3027
4018
|
}
|
|
3028
4019
|
return active;
|
|
3029
4020
|
}
|
|
4021
|
+
async createHandler() {
|
|
4022
|
+
await super.createHandler();
|
|
4023
|
+
this._chainStakeEventsViewer = assertEx25(await this.locateAndCreate(StakeEventsViewerMoniker), () => "Failed to create StakeEventsViewer");
|
|
4024
|
+
}
|
|
3030
4025
|
pending() {
|
|
3031
4026
|
let pending = 0n;
|
|
3032
4027
|
for (const position of this.positions) {
|
|
@@ -3046,7 +4041,7 @@ var SimpleChainStakeViewer = class _SimpleChainStakeViewer extends AbstractCreat
|
|
|
3046
4041
|
return pending;
|
|
3047
4042
|
}
|
|
3048
4043
|
stakeById(id) {
|
|
3049
|
-
return
|
|
4044
|
+
return assertEx25(this.positions[id], () => new Error(`Stake with id ${id} not found`));
|
|
3050
4045
|
}
|
|
3051
4046
|
stakeByStaker(staker, slot) {
|
|
3052
4047
|
return this.positions.filter((s) => asAddress5(s.staker) === asAddress5(staker))[slot];
|
|
@@ -3083,17 +4078,10 @@ var SimpleChainStakeViewer = class _SimpleChainStakeViewer extends AbstractCreat
|
|
|
3083
4078
|
}
|
|
3084
4079
|
return withdrawn;
|
|
3085
4080
|
}
|
|
3086
|
-
async startHandler() {
|
|
3087
|
-
await super.startHandler();
|
|
3088
|
-
this._chainId = this.params.chainId ?? (await Account.random()).address;
|
|
3089
|
-
this._chainStakeEventsViewer = await SimpleChainStakeEventsViewer.create({
|
|
3090
|
-
positions: this.positions
|
|
3091
|
-
});
|
|
3092
|
-
}
|
|
3093
4081
|
};
|
|
3094
|
-
|
|
4082
|
+
SimpleStakeViewer = _ts_decorate5([
|
|
3095
4083
|
creatableProvider()
|
|
3096
|
-
],
|
|
4084
|
+
], SimpleStakeViewer);
|
|
3097
4085
|
|
|
3098
4086
|
// src/simple/client/SimpleXyoClient.ts
|
|
3099
4087
|
var SimpleXyoClient = class {
|
|
@@ -3123,21 +4111,21 @@ var AbstractSimpleDataLake = class extends AbstractCreatableProvider {
|
|
|
3123
4111
|
get map() {
|
|
3124
4112
|
return this.params.map;
|
|
3125
4113
|
}
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
4114
|
+
async get(hash) {
|
|
4115
|
+
const result = await this.map.get(hash);
|
|
4116
|
+
return this.isAllowed(result) ? result : void 0;
|
|
4117
|
+
}
|
|
4118
|
+
async getMany(hashes) {
|
|
4119
|
+
const result = await this.map.getMany(hashes);
|
|
4120
|
+
return result.filter((data) => this.isAllowed(data));
|
|
4121
|
+
}
|
|
4122
|
+
async has(hash) {
|
|
4123
|
+
const value = await this.get(hash);
|
|
4124
|
+
if (isAnyPayload4(value)) {
|
|
4125
|
+
return this.isAllowed(value);
|
|
4126
|
+
}
|
|
4127
|
+
return value !== void 0;
|
|
4128
|
+
}
|
|
3141
4129
|
isAllowed(value) {
|
|
3142
4130
|
if (isAnyPayload4(value)) {
|
|
3143
4131
|
return this.isAllowedSchema(value.schema);
|
|
@@ -3193,7 +4181,6 @@ SimpleDataLakeRunner = _ts_decorate6([
|
|
|
3193
4181
|
], SimpleDataLakeRunner);
|
|
3194
4182
|
|
|
3195
4183
|
// src/simple/datalake/SimpleDataLakeViewer.ts
|
|
3196
|
-
import { isAnyPayload as isAnyPayload5 } from "@xyo-network/payload-model";
|
|
3197
4184
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
3198
4185
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3199
4186
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3210,21 +4197,6 @@ var SimpleDataLakeViewer = class _SimpleDataLakeViewer extends AbstractSimpleDat
|
|
|
3210
4197
|
DataLakeViewerMoniker
|
|
3211
4198
|
];
|
|
3212
4199
|
moniker = _SimpleDataLakeViewer.defaultMoniker;
|
|
3213
|
-
async get(hash) {
|
|
3214
|
-
const result = await this.map.get(hash);
|
|
3215
|
-
return this.isAllowed(result) ? result : void 0;
|
|
3216
|
-
}
|
|
3217
|
-
async getMany(hashes) {
|
|
3218
|
-
const result = await this.map.getMany(hashes);
|
|
3219
|
-
return result.filter((data) => this.isAllowed(data));
|
|
3220
|
-
}
|
|
3221
|
-
async has(hash) {
|
|
3222
|
-
const value = await this.get(hash);
|
|
3223
|
-
if (isAnyPayload5(value)) {
|
|
3224
|
-
return this.isAllowed(value);
|
|
3225
|
-
}
|
|
3226
|
-
return value !== void 0;
|
|
3227
|
-
}
|
|
3228
4200
|
};
|
|
3229
4201
|
SimpleDataLakeViewer = _ts_decorate7([
|
|
3230
4202
|
creatableProvider()
|
|
@@ -3256,9 +4228,9 @@ var SimpleXyoGateway = class {
|
|
|
3256
4228
|
};
|
|
3257
4229
|
|
|
3258
4230
|
// src/simple/gateway/SimpleXyoGatewayRunner.ts
|
|
3259
|
-
import { assertEx as
|
|
3260
|
-
import { PayloadBuilder as
|
|
3261
|
-
import { asXL1BlockNumber as asXL1BlockNumber7, TransferSchema as
|
|
4231
|
+
import { assertEx as assertEx26, BigIntToJsonZod, isDefined as isDefined15 } from "@xylabs/sdk-js";
|
|
4232
|
+
import { PayloadBuilder as PayloadBuilder17 } from "@xyo-network/payload-builder";
|
|
4233
|
+
import { asXL1BlockNumber as asXL1BlockNumber7, TransferSchema as TransferSchema3 } from "@xyo-network/xl1-protocol";
|
|
3262
4234
|
var SimpleXyoGatewayRunner = class {
|
|
3263
4235
|
static {
|
|
3264
4236
|
__name(this, "SimpleXyoGatewayRunner");
|
|
@@ -3287,18 +4259,18 @@ var SimpleXyoGatewayRunner = class {
|
|
|
3287
4259
|
return this._dataLakes.length - 1;
|
|
3288
4260
|
}
|
|
3289
4261
|
async addPayloadsToChain(onChain, offChain, options) {
|
|
3290
|
-
const viewer =
|
|
4262
|
+
const viewer = assertEx26(this.connectionInstance.viewer, () => "No viewer available on connection");
|
|
3291
4263
|
const { nbf, exp, chain, fees } = options ?? {};
|
|
3292
|
-
const resolvedChainId =
|
|
3293
|
-
const resolvedNbf = asXL1BlockNumber7(
|
|
3294
|
-
const resolvedExp = asXL1BlockNumber7(
|
|
4264
|
+
const resolvedChainId = isDefined15(chain) ? chain : await viewer.chainId();
|
|
4265
|
+
const resolvedNbf = asXL1BlockNumber7(isDefined15(nbf) ? nbf : await viewer.currentBlockNumber(), true);
|
|
4266
|
+
const resolvedExp = asXL1BlockNumber7(isDefined15(exp) ? exp : resolvedNbf + 10, true);
|
|
3295
4267
|
const tx = await buildUnsignedTransaction(resolvedChainId, onChain, offChain, resolvedNbf, resolvedExp, await (await this.signer()).address(), fees);
|
|
3296
4268
|
return await this.addTransactionToChain(tx);
|
|
3297
4269
|
}
|
|
3298
4270
|
async addTransactionToChain(tx) {
|
|
3299
4271
|
const connection = this.connectionInstance;
|
|
3300
4272
|
const signer = this.signerInstance;
|
|
3301
|
-
const runner =
|
|
4273
|
+
const runner = assertEx26(connection.runner, () => "No runner available on connection");
|
|
3302
4274
|
const signedTx = await signer.signTransaction(tx);
|
|
3303
4275
|
await this.addPayloadsToDataLakes(signedTx[1]);
|
|
3304
4276
|
return [
|
|
@@ -3310,7 +4282,7 @@ var SimpleXyoGatewayRunner = class {
|
|
|
3310
4282
|
];
|
|
3311
4283
|
}
|
|
3312
4284
|
async confirmSubmittedTransaction(txHash, options) {
|
|
3313
|
-
return await confirmSubmittedTransaction(
|
|
4285
|
+
return await confirmSubmittedTransaction(assertEx26(this.connectionInstance.viewer, () => "Connection viewer is undefined"), txHash, options);
|
|
3314
4286
|
}
|
|
3315
4287
|
/** @deprecated use connectionInstance instead */
|
|
3316
4288
|
connection() {
|
|
@@ -3330,8 +4302,8 @@ var SimpleXyoGatewayRunner = class {
|
|
|
3330
4302
|
address,
|
|
3331
4303
|
BigIntToJsonZod.parse(amount)
|
|
3332
4304
|
]));
|
|
3333
|
-
const transfer = new
|
|
3334
|
-
schema:
|
|
4305
|
+
const transfer = new PayloadBuilder17({
|
|
4306
|
+
schema: TransferSchema3
|
|
3335
4307
|
}).fields({
|
|
3336
4308
|
from,
|
|
3337
4309
|
transfers: hexTransfers,
|
|
@@ -3356,8 +4328,7 @@ var SimpleXyoGatewayRunner = class {
|
|
|
3356
4328
|
};
|
|
3357
4329
|
|
|
3358
4330
|
// src/simple/mempool/SimpleMempoolRunner.ts
|
|
3359
|
-
import {
|
|
3360
|
-
import { PayloadBuilder as PayloadBuilder15 } from "@xyo-network/payload-builder";
|
|
4331
|
+
import { PayloadBuilder as PayloadBuilder18 } from "@xyo-network/payload-builder";
|
|
3361
4332
|
function _ts_decorate8(decorators, target, key, desc) {
|
|
3362
4333
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3363
4334
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3365,10 +4336,15 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
3365
4336
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3366
4337
|
}
|
|
3367
4338
|
__name(_ts_decorate8, "_ts_decorate");
|
|
3368
|
-
var SimpleMempoolRunner = class extends
|
|
4339
|
+
var SimpleMempoolRunner = class _SimpleMempoolRunner extends AbstractCreatableProvider {
|
|
3369
4340
|
static {
|
|
3370
4341
|
__name(this, "SimpleMempoolRunner");
|
|
3371
4342
|
}
|
|
4343
|
+
static defaultMoniker = MempoolRunnerMoniker;
|
|
4344
|
+
static monikers = [
|
|
4345
|
+
MempoolRunnerMoniker
|
|
4346
|
+
];
|
|
4347
|
+
moniker = _SimpleMempoolRunner.defaultMoniker;
|
|
3372
4348
|
get pendingBlocksArchivist() {
|
|
3373
4349
|
return this.params.pendingBlocksArchivist;
|
|
3374
4350
|
}
|
|
@@ -3378,8 +4354,8 @@ var SimpleMempoolRunner = class extends AbstractCreatable2 {
|
|
|
3378
4354
|
async submitBlocks(blocks) {
|
|
3379
4355
|
const bundles = await Promise.all(blocks.map(async ([bw, payloads]) => {
|
|
3380
4356
|
return hydratedBlockToPayloadBundle([
|
|
3381
|
-
await
|
|
3382
|
-
await
|
|
4357
|
+
await PayloadBuilder18.addHashMeta(bw),
|
|
4358
|
+
await PayloadBuilder18.addHashMeta(payloads)
|
|
3383
4359
|
]);
|
|
3384
4360
|
}));
|
|
3385
4361
|
const inserted = await this.pendingBlocksArchivist.insert(bundles);
|
|
@@ -3388,20 +4364,20 @@ var SimpleMempoolRunner = class extends AbstractCreatable2 {
|
|
|
3388
4364
|
async submitTransactions(transactions) {
|
|
3389
4365
|
const bundles = await Promise.all(transactions.map(async ([tx, payloads]) => {
|
|
3390
4366
|
return hydratedTransactionToPayloadBundle([
|
|
3391
|
-
await
|
|
3392
|
-
await
|
|
4367
|
+
await PayloadBuilder18.addHashMeta(tx),
|
|
4368
|
+
await PayloadBuilder18.addHashMeta(payloads)
|
|
3393
4369
|
]);
|
|
3394
4370
|
}));
|
|
3395
|
-
const inserted = await this.
|
|
4371
|
+
const inserted = await this.pendingTransactionsArchivist.insert(bundles);
|
|
3396
4372
|
return inserted.map((p) => p._hash);
|
|
3397
4373
|
}
|
|
3398
4374
|
};
|
|
3399
4375
|
SimpleMempoolRunner = _ts_decorate8([
|
|
3400
|
-
|
|
4376
|
+
creatableProvider()
|
|
3401
4377
|
], SimpleMempoolRunner);
|
|
3402
4378
|
|
|
3403
4379
|
// src/simple/mempool/SimpleMempoolViewer.ts
|
|
3404
|
-
import { creatable
|
|
4380
|
+
import { creatable, exists as exists6, isDefined as isDefined16, isHash } from "@xylabs/sdk-js";
|
|
3405
4381
|
import { isHashMeta as isHashMeta2, isPayloadBundle } from "@xyo-network/payload-model";
|
|
3406
4382
|
function _ts_decorate9(decorators, target, key, desc) {
|
|
3407
4383
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -3431,7 +4407,7 @@ var SimpleMempoolViewer = class _SimpleMempoolViewer extends AbstractCreatablePr
|
|
|
3431
4407
|
const [p] = await this.pendingBlocksArchivist.get([
|
|
3432
4408
|
providedCursor
|
|
3433
4409
|
]);
|
|
3434
|
-
if (
|
|
4410
|
+
if (isDefined16(p)) {
|
|
3435
4411
|
cursor = p._sequence;
|
|
3436
4412
|
}
|
|
3437
4413
|
}
|
|
@@ -3441,7 +4417,7 @@ var SimpleMempoolViewer = class _SimpleMempoolViewer extends AbstractCreatablePr
|
|
|
3441
4417
|
cursor
|
|
3442
4418
|
});
|
|
3443
4419
|
const filteredBundles = bundles.filter(isPayloadBundle).filter(isHashMeta2);
|
|
3444
|
-
return (await Promise.all(filteredBundles.map(async (bundle3) => await bundledPayloadToHydratedBlock(bundle3)))).filter(
|
|
4420
|
+
return (await Promise.all(filteredBundles.map(async (bundle3) => await bundledPayloadToHydratedBlock(bundle3)))).filter(exists6);
|
|
3445
4421
|
}
|
|
3446
4422
|
async pendingTransactions({ cursor: providedCursor } = {}) {
|
|
3447
4423
|
let cursor = void 0;
|
|
@@ -3449,25 +4425,30 @@ var SimpleMempoolViewer = class _SimpleMempoolViewer extends AbstractCreatablePr
|
|
|
3449
4425
|
const [p] = await this.pendingTransactionsArchivist.get([
|
|
3450
4426
|
providedCursor
|
|
3451
4427
|
]);
|
|
3452
|
-
if (
|
|
4428
|
+
if (isDefined16(p)) {
|
|
3453
4429
|
cursor = p._sequence;
|
|
3454
4430
|
}
|
|
3455
4431
|
}
|
|
4432
|
+
this.logger?.info(`Fetching pending transactions from cursor: ${cursor}`);
|
|
3456
4433
|
const bundles = await this.pendingTransactionsArchivist.next({
|
|
3457
4434
|
order: "asc",
|
|
3458
4435
|
limit: 100,
|
|
3459
4436
|
cursor
|
|
3460
4437
|
});
|
|
4438
|
+
this.logger?.info(`Fetched pending transactions: ${bundles.length} bundles`);
|
|
3461
4439
|
const filteredBundles = bundles.filter(isPayloadBundle).filter(isHashMeta2);
|
|
3462
|
-
|
|
4440
|
+
this.logger?.info(`Filtered pending transactions: ${JSON.stringify(bundles, null, 2)} filteredBundles`);
|
|
4441
|
+
const result = (await Promise.all(filteredBundles.map(async (bundle3) => await bundledPayloadToHydratedTransaction(bundle3)))).filter(exists6);
|
|
4442
|
+
this.logger?.info(`Converted pending transactions: ${JSON.stringify(result, null, 2)} results`);
|
|
4443
|
+
return result;
|
|
3463
4444
|
}
|
|
3464
4445
|
};
|
|
3465
4446
|
SimpleMempoolViewer = _ts_decorate9([
|
|
3466
|
-
|
|
4447
|
+
creatable()
|
|
3467
4448
|
], SimpleMempoolViewer);
|
|
3468
4449
|
|
|
3469
4450
|
// src/simple/network/SimpleXyoNetwork.ts
|
|
3470
|
-
import { isUndefined as
|
|
4451
|
+
import { isUndefined as isUndefined6 } from "@xylabs/sdk-js";
|
|
3471
4452
|
import { isNetworkStatus } from "@xyo-network/xl1-protocol";
|
|
3472
4453
|
import axios from "axios";
|
|
3473
4454
|
|
|
@@ -3514,7 +4495,7 @@ var SimpleXyoNetwork = class {
|
|
|
3514
4495
|
}
|
|
3515
4496
|
async status() {
|
|
3516
4497
|
const statusNetwork = StatusNetworks[this._networkId];
|
|
3517
|
-
if (
|
|
4498
|
+
if (isUndefined6(statusNetwork)) {
|
|
3518
4499
|
throw new Error(`Unknown status network ID: ${this._networkId}`);
|
|
3519
4500
|
}
|
|
3520
4501
|
return await this.makeRequest(statusNetwork.statusUrl);
|
|
@@ -3539,7 +4520,7 @@ var SimpleXyoNetwork = class {
|
|
|
3539
4520
|
};
|
|
3540
4521
|
|
|
3541
4522
|
// src/simple/permissions/SimpleXyoPermissions.ts
|
|
3542
|
-
import { assertEx as
|
|
4523
|
+
import { assertEx as assertEx27 } from "@xylabs/sdk-js";
|
|
3543
4524
|
var SimpleXyoPermissions = class {
|
|
3544
4525
|
static {
|
|
3545
4526
|
__name(this, "SimpleXyoPermissions");
|
|
@@ -3551,7 +4532,7 @@ var SimpleXyoPermissions = class {
|
|
|
3551
4532
|
this.invoker = store.invoker;
|
|
3552
4533
|
}
|
|
3553
4534
|
get store() {
|
|
3554
|
-
return
|
|
4535
|
+
return assertEx27(this._store, () => "Store must be defined to get permissions");
|
|
3555
4536
|
}
|
|
3556
4537
|
async getPermissions() {
|
|
3557
4538
|
return await this.store.getPermissions();
|
|
@@ -3609,7 +4590,7 @@ var SimpleXyoPermissions = class {
|
|
|
3609
4590
|
};
|
|
3610
4591
|
|
|
3611
4592
|
// src/simple/permissions/store/MemoryPermissions.ts
|
|
3612
|
-
import { assertEx as
|
|
4593
|
+
import { assertEx as assertEx28 } from "@xylabs/sdk-js";
|
|
3613
4594
|
var MemoryPermissionsStore = class {
|
|
3614
4595
|
static {
|
|
3615
4596
|
__name(this, "MemoryPermissionsStore");
|
|
@@ -3620,7 +4601,7 @@ var MemoryPermissionsStore = class {
|
|
|
3620
4601
|
this._invoker = invoker;
|
|
3621
4602
|
}
|
|
3622
4603
|
get invoker() {
|
|
3623
|
-
return
|
|
4604
|
+
return assertEx28(this._invoker, () => "Invoker must be defined to get permissions");
|
|
3624
4605
|
}
|
|
3625
4606
|
async getPermissions() {
|
|
3626
4607
|
await Promise.resolve();
|
|
@@ -3633,33 +4614,48 @@ var MemoryPermissionsStore = class {
|
|
|
3633
4614
|
};
|
|
3634
4615
|
|
|
3635
4616
|
// src/simple/runner/SimpleXyoRunner.ts
|
|
3636
|
-
import {
|
|
3637
|
-
import { PayloadBuilder as
|
|
3638
|
-
var SimpleXyoRunner = class {
|
|
4617
|
+
import { assertEx as assertEx29 } from "@xylabs/sdk-js";
|
|
4618
|
+
import { PayloadBuilder as PayloadBuilder19 } from "@xyo-network/payload-builder";
|
|
4619
|
+
var SimpleXyoRunner = class _SimpleXyoRunner extends AbstractCreatableProvider {
|
|
3639
4620
|
static {
|
|
3640
4621
|
__name(this, "SimpleXyoRunner");
|
|
3641
4622
|
}
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
4623
|
+
static defaultMoniker = XyoRunnerMoniker;
|
|
4624
|
+
static monikers = [
|
|
4625
|
+
XyoRunnerMoniker
|
|
4626
|
+
];
|
|
4627
|
+
moniker = _SimpleXyoRunner.defaultMoniker;
|
|
4628
|
+
_mempoolRunner;
|
|
4629
|
+
get mempool() {
|
|
4630
|
+
return this._mempoolRunner;
|
|
4631
|
+
}
|
|
4632
|
+
static async paramsHandler(params) {
|
|
4633
|
+
return {
|
|
4634
|
+
...await super.paramsHandler(params),
|
|
4635
|
+
pendingTransactionsArchivist: assertEx29(params?.pendingTransactionsArchivist, () => "A pendingTransactionsArchivist is required to create a SimpleXyoRunner")
|
|
4636
|
+
};
|
|
3645
4637
|
}
|
|
3646
4638
|
async broadcastTransaction(transaction) {
|
|
3647
|
-
const archivist =
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
}
|
|
3657
|
-
return
|
|
4639
|
+
const archivist = this.params.pendingTransactionsArchivist;
|
|
4640
|
+
const bundle3 = hydratedTransactionToPayloadBundle(transaction);
|
|
4641
|
+
await archivist.insert([
|
|
4642
|
+
bundle3
|
|
4643
|
+
]);
|
|
4644
|
+
await this.mempool.submitTransactions([
|
|
4645
|
+
transaction
|
|
4646
|
+
]);
|
|
4647
|
+
const hash = await PayloadBuilder19.hash(transaction[0]);
|
|
4648
|
+
this.logger?.info(`Broadcasted transaction with hash ${hash}`);
|
|
4649
|
+
return hash;
|
|
4650
|
+
}
|
|
4651
|
+
async createHandler() {
|
|
4652
|
+
await super.createHandler();
|
|
4653
|
+
this._mempoolRunner = await this.locator.getInstance(MempoolRunnerMoniker);
|
|
3658
4654
|
}
|
|
3659
4655
|
};
|
|
3660
4656
|
|
|
3661
4657
|
// src/simple/signer/SimpleXyoSigner.ts
|
|
3662
|
-
import { PayloadBuilder as
|
|
4658
|
+
import { PayloadBuilder as PayloadBuilder20 } from "@xyo-network/payload-builder";
|
|
3663
4659
|
import { SignedHydratedTransactionWithHashMetaZod } from "@xyo-network/xl1-protocol";
|
|
3664
4660
|
var SimpleXyoSigner = class {
|
|
3665
4661
|
static {
|
|
@@ -3680,15 +4676,105 @@ var SimpleXyoSigner = class {
|
|
|
3680
4676
|
async signTransaction(tx) {
|
|
3681
4677
|
const txBW = await signTransaction(tx[0], this._account);
|
|
3682
4678
|
return SignedHydratedTransactionWithHashMetaZod.parse([
|
|
3683
|
-
await
|
|
3684
|
-
await
|
|
4679
|
+
await PayloadBuilder20.addStorageMeta(txBW),
|
|
4680
|
+
await PayloadBuilder20.addStorageMeta(tx[1])
|
|
3685
4681
|
]);
|
|
3686
4682
|
}
|
|
3687
4683
|
};
|
|
3688
4684
|
|
|
4685
|
+
// src/simple/stakeEvents/SimpleStakeEventsViewer.ts
|
|
4686
|
+
import { isDefined as isDefined17 } from "@xylabs/sdk-js";
|
|
4687
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
4688
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4689
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4690
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4691
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4692
|
+
}
|
|
4693
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
4694
|
+
var SimpleStakeEventsViewer = class _SimpleStakeEventsViewer extends AbstractCreatableProvider {
|
|
4695
|
+
static {
|
|
4696
|
+
__name(this, "SimpleStakeEventsViewer");
|
|
4697
|
+
}
|
|
4698
|
+
static defaultMoniker = StakeEventsViewerMoniker;
|
|
4699
|
+
static monikers = [
|
|
4700
|
+
StakeEventsViewerMoniker
|
|
4701
|
+
];
|
|
4702
|
+
moniker = _SimpleStakeEventsViewer.defaultMoniker;
|
|
4703
|
+
get positions() {
|
|
4704
|
+
return this.params.positions;
|
|
4705
|
+
}
|
|
4706
|
+
positionCount(range) {
|
|
4707
|
+
return this.positionsFromRange(range).length;
|
|
4708
|
+
}
|
|
4709
|
+
stakeEvents(range, { name } = {}) {
|
|
4710
|
+
const positions = this.positionsFromRange(range);
|
|
4711
|
+
const events = this.eventsFromPositions(positions);
|
|
4712
|
+
if (isDefined17(name)) {
|
|
4713
|
+
return events.filter((event) => event.name === name);
|
|
4714
|
+
}
|
|
4715
|
+
return events;
|
|
4716
|
+
}
|
|
4717
|
+
async startHandler() {
|
|
4718
|
+
await super.startHandler();
|
|
4719
|
+
}
|
|
4720
|
+
eventsFromPositions(positions) {
|
|
4721
|
+
const events = positions.map((position) => {
|
|
4722
|
+
const events2 = [
|
|
4723
|
+
{
|
|
4724
|
+
name: "StakeAdded",
|
|
4725
|
+
time: position.addBlock,
|
|
4726
|
+
args: {
|
|
4727
|
+
staker: position.staker,
|
|
4728
|
+
staked: position.staked,
|
|
4729
|
+
amount: position.amount,
|
|
4730
|
+
id: position.id
|
|
4731
|
+
}
|
|
4732
|
+
}
|
|
4733
|
+
];
|
|
4734
|
+
if (position.removeBlock !== 0) {
|
|
4735
|
+
events2.push({
|
|
4736
|
+
name: "StakeRemoved",
|
|
4737
|
+
time: position.removeBlock,
|
|
4738
|
+
args: {
|
|
4739
|
+
staker: position.staker,
|
|
4740
|
+
staked: position.staked,
|
|
4741
|
+
amount: position.amount,
|
|
4742
|
+
id: position.id
|
|
4743
|
+
}
|
|
4744
|
+
});
|
|
4745
|
+
}
|
|
4746
|
+
if (position.withdrawBlock !== 0) {
|
|
4747
|
+
events2.push({
|
|
4748
|
+
name: "StakeWithdrawn",
|
|
4749
|
+
time: position.withdrawBlock,
|
|
4750
|
+
args: {
|
|
4751
|
+
staker: position.staker,
|
|
4752
|
+
staked: position.staked,
|
|
4753
|
+
amount: position.amount,
|
|
4754
|
+
id: position.id
|
|
4755
|
+
}
|
|
4756
|
+
});
|
|
4757
|
+
}
|
|
4758
|
+
return events2;
|
|
4759
|
+
});
|
|
4760
|
+
return events.flat();
|
|
4761
|
+
}
|
|
4762
|
+
positionsFromRange(range) {
|
|
4763
|
+
const startBlock = range[0];
|
|
4764
|
+
const endBlock = range[1] === "latest" ? Number.MAX_SAFE_INTEGER : range[1];
|
|
4765
|
+
const filteredPositions = this.positions?.filter((position) => {
|
|
4766
|
+
return position.addBlock <= endBlock && (position.removeBlock === 0 || position.removeBlock >= startBlock);
|
|
4767
|
+
}) ?? [];
|
|
4768
|
+
return filteredPositions;
|
|
4769
|
+
}
|
|
4770
|
+
};
|
|
4771
|
+
SimpleStakeEventsViewer = _ts_decorate10([
|
|
4772
|
+
creatableProvider()
|
|
4773
|
+
], SimpleStakeEventsViewer);
|
|
4774
|
+
|
|
3689
4775
|
// src/simple/timesync/SimpleTimeSyncViewer.ts
|
|
3690
|
-
import { asHash as asHash6, assertEx as
|
|
3691
|
-
import { asTimePayload, asXL1BlockNumber as asXL1BlockNumber8, TimeSchema } from "@xyo-network/xl1-protocol";
|
|
4776
|
+
import { asHash as asHash6, assertEx as assertEx30, isDefined as isDefined18 } from "@xylabs/sdk-js";
|
|
4777
|
+
import { asTimePayload as asTimePayload2, asXL1BlockNumber as asXL1BlockNumber8, TimeSchema } from "@xyo-network/xl1-protocol";
|
|
3692
4778
|
var SimpleTimeSyncViewer = class _SimpleTimeSyncViewer extends AbstractCreatableProvider {
|
|
3693
4779
|
static {
|
|
3694
4780
|
__name(this, "SimpleTimeSyncViewer");
|
|
@@ -3698,8 +4784,9 @@ var SimpleTimeSyncViewer = class _SimpleTimeSyncViewer extends AbstractCreatable
|
|
|
3698
4784
|
TimeSyncViewerMoniker
|
|
3699
4785
|
];
|
|
3700
4786
|
moniker = _SimpleTimeSyncViewer.defaultMoniker;
|
|
4787
|
+
_blockViewer;
|
|
3701
4788
|
get blockViewer() {
|
|
3702
|
-
return this.
|
|
4789
|
+
return this._blockViewer;
|
|
3703
4790
|
}
|
|
3704
4791
|
get ethProvider() {
|
|
3705
4792
|
return this.params.ethProvider;
|
|
@@ -3707,10 +4794,10 @@ var SimpleTimeSyncViewer = class _SimpleTimeSyncViewer extends AbstractCreatable
|
|
|
3707
4794
|
async convertTime(fromDomain, toDomain, from) {
|
|
3708
4795
|
switch (fromDomain) {
|
|
3709
4796
|
case "xl1": {
|
|
3710
|
-
const [block, payloads] =
|
|
4797
|
+
const [block, payloads] = assertEx30(await this.blockViewer.blockByNumber(asXL1BlockNumber8(from, true)), () => "Block not found");
|
|
3711
4798
|
const timeSchemaIndex = block.payload_schemas.indexOf(TimeSchema);
|
|
3712
4799
|
const hash = timeSchemaIndex === -1 ? void 0 : block.payload_hashes[timeSchemaIndex];
|
|
3713
|
-
const timePayload =
|
|
4800
|
+
const timePayload = asTimePayload2(isDefined18(hash) ? payloads.find((p) => p._hash === hash) : void 0);
|
|
3714
4801
|
if (timePayload === void 0) return 0;
|
|
3715
4802
|
switch (toDomain) {
|
|
3716
4803
|
case "xl1": {
|
|
@@ -3732,6 +4819,10 @@ var SimpleTimeSyncViewer = class _SimpleTimeSyncViewer extends AbstractCreatable
|
|
|
3732
4819
|
}
|
|
3733
4820
|
}
|
|
3734
4821
|
}
|
|
4822
|
+
async createHandler() {
|
|
4823
|
+
await super.createHandler();
|
|
4824
|
+
this._blockViewer = await this.locator.getInstance(BlockViewerMoniker);
|
|
4825
|
+
}
|
|
3735
4826
|
async currentTime(domain) {
|
|
3736
4827
|
switch (domain) {
|
|
3737
4828
|
case "xl1": {
|
|
@@ -3773,10 +4864,10 @@ var SimpleTimeSyncViewer = class _SimpleTimeSyncViewer extends AbstractCreatable
|
|
|
3773
4864
|
];
|
|
3774
4865
|
}
|
|
3775
4866
|
case "ethereum": {
|
|
3776
|
-
const provider =
|
|
4867
|
+
const provider = assertEx30(this.ethProvider, () => "Ethereum provider not configured");
|
|
3777
4868
|
const blockNumber = await provider.getBlockNumber() ?? 0;
|
|
3778
4869
|
const block = await provider.getBlock(blockNumber);
|
|
3779
|
-
const blockHash = asHash6(
|
|
4870
|
+
const blockHash = asHash6(assertEx30(block?.hash, () => "Block hash not found"), true);
|
|
3780
4871
|
return [
|
|
3781
4872
|
blockNumber,
|
|
3782
4873
|
blockHash
|
|
@@ -3787,21 +4878,126 @@ var SimpleTimeSyncViewer = class _SimpleTimeSyncViewer extends AbstractCreatable
|
|
|
3787
4878
|
}
|
|
3788
4879
|
}
|
|
3789
4880
|
}
|
|
3790
|
-
currentTimePayload() {
|
|
3791
|
-
|
|
4881
|
+
async currentTimePayload() {
|
|
4882
|
+
const [xl1, xl1Hash] = await this.currentTimeAndHash("xl1");
|
|
4883
|
+
const timePayload = {
|
|
4884
|
+
schema: TimeSchema,
|
|
4885
|
+
// this is for the previous block
|
|
4886
|
+
xl1,
|
|
4887
|
+
// this is for the previous block
|
|
4888
|
+
xl1Hash: assertEx30(xl1Hash, () => "No xl1 hash available from time sync service"),
|
|
4889
|
+
epoch: Date.now()
|
|
4890
|
+
};
|
|
4891
|
+
if (isDefined18(this.ethProvider)) {
|
|
4892
|
+
const [ethereum, ethHashOrNull] = await this.currentTimeAndHash("ethereum");
|
|
4893
|
+
const ethereumHash = asHash6(ethHashOrNull, () => "No ethereum hash available from time sync service");
|
|
4894
|
+
timePayload.ethereum = ethereum;
|
|
4895
|
+
timePayload.ethereumHash = ethereumHash;
|
|
4896
|
+
}
|
|
4897
|
+
return timePayload;
|
|
4898
|
+
}
|
|
4899
|
+
};
|
|
4900
|
+
|
|
4901
|
+
// src/status/ServiceStatus.ts
|
|
4902
|
+
var LoggerStatusReporter = class {
|
|
4903
|
+
static {
|
|
4904
|
+
__name(this, "LoggerStatusReporter");
|
|
4905
|
+
}
|
|
4906
|
+
logger;
|
|
4907
|
+
statusMap = {};
|
|
4908
|
+
constructor(logger) {
|
|
4909
|
+
this.logger = logger;
|
|
4910
|
+
}
|
|
4911
|
+
report(name, status, progress) {
|
|
4912
|
+
this.statusMap[name] = status;
|
|
4913
|
+
const starting = Object.entries(this.statusMap).map(([, value]) => value === "starting" ? 1 : 0).reduce((a, b) => a + b, 0);
|
|
4914
|
+
const started = Object.entries(this.statusMap).map(([, value]) => value === "started" ? 1 : 0).reduce((a, b) => a + b, 0);
|
|
4915
|
+
this.logger.info(`${started}/${starting + started} ${name} status: ${status}`, {
|
|
4916
|
+
progress
|
|
4917
|
+
});
|
|
4918
|
+
}
|
|
4919
|
+
};
|
|
4920
|
+
|
|
4921
|
+
// src/status/RuntimeStatusMonitor.ts
|
|
4922
|
+
var statusPriority = {
|
|
4923
|
+
error: 0,
|
|
4924
|
+
stopped: 1,
|
|
4925
|
+
stopping: 2,
|
|
4926
|
+
creating: 3,
|
|
4927
|
+
created: 4,
|
|
4928
|
+
starting: 5,
|
|
4929
|
+
started: 6
|
|
4930
|
+
};
|
|
4931
|
+
var SENTINEL_STATUS = "starting";
|
|
4932
|
+
var reduceToMinimumStatus = /* @__PURE__ */ __name((statuses) => {
|
|
4933
|
+
let minStatus = SENTINEL_STATUS;
|
|
4934
|
+
let minPriority = Infinity;
|
|
4935
|
+
for (const status of statuses) {
|
|
4936
|
+
const priority = statusPriority[status];
|
|
4937
|
+
if (priority < minPriority) {
|
|
4938
|
+
minPriority = priority;
|
|
4939
|
+
minStatus = status;
|
|
4940
|
+
}
|
|
4941
|
+
}
|
|
4942
|
+
return minStatus;
|
|
4943
|
+
}, "reduceToMinimumStatus");
|
|
4944
|
+
var RuntimeStatusMonitor = class extends LoggerStatusReporter {
|
|
4945
|
+
static {
|
|
4946
|
+
__name(this, "RuntimeStatusMonitor");
|
|
4947
|
+
}
|
|
4948
|
+
globalTransitions = [];
|
|
4949
|
+
transitions = [];
|
|
4950
|
+
getGlobalStatus() {
|
|
4951
|
+
if (Object.keys(this.statusMap).length === 0) return SENTINEL_STATUS;
|
|
4952
|
+
return reduceToMinimumStatus(Object.values(this.statusMap));
|
|
4953
|
+
}
|
|
4954
|
+
getStatus(name) {
|
|
4955
|
+
return this.statusMap[name];
|
|
4956
|
+
}
|
|
4957
|
+
onGlobalTransition(match, handler) {
|
|
4958
|
+
this.globalTransitions.push({
|
|
4959
|
+
...match,
|
|
4960
|
+
handler
|
|
4961
|
+
});
|
|
4962
|
+
}
|
|
4963
|
+
/**
|
|
4964
|
+
* Register a callback to be called on a specific transition.
|
|
4965
|
+
*/
|
|
4966
|
+
onTransition(match, handler) {
|
|
4967
|
+
this.transitions.push({
|
|
4968
|
+
...match,
|
|
4969
|
+
handler
|
|
4970
|
+
});
|
|
4971
|
+
}
|
|
4972
|
+
report(name, status, progress) {
|
|
4973
|
+
const previous = this.statusMap[name];
|
|
4974
|
+
const previousGlobal = this.getGlobalStatus();
|
|
4975
|
+
super.report(name, status, progress);
|
|
4976
|
+
if (previous === status) return;
|
|
4977
|
+
this.runTransitions(this.transitions, previous, status, name);
|
|
4978
|
+
const globalStatus = this.getGlobalStatus();
|
|
4979
|
+
if (previousGlobal === globalStatus) return;
|
|
4980
|
+
this.runTransitions(this.globalTransitions, previousGlobal, globalStatus);
|
|
4981
|
+
}
|
|
4982
|
+
runTransitions(transitions, prev, next, name) {
|
|
4983
|
+
for (const { from, to, name: matchName, handler } of transitions) {
|
|
4984
|
+
if ((matchName === void 0 || matchName === name) && (from === void 0 || from === prev) && (to === void 0 || to === next)) {
|
|
4985
|
+
handler(prev, next);
|
|
4986
|
+
}
|
|
4987
|
+
}
|
|
3792
4988
|
}
|
|
3793
4989
|
};
|
|
3794
4990
|
|
|
3795
4991
|
// src/time/primitives/xl1BlockNumberToEthBlockNumber.ts
|
|
3796
|
-
import { assertEx as
|
|
3797
|
-
import { asTimePayload as
|
|
4992
|
+
import { assertEx as assertEx31 } from "@xylabs/sdk-js";
|
|
4993
|
+
import { asTimePayload as asTimePayload3, TimeSchema as TimeSchema2 } from "@xyo-network/xl1-protocol";
|
|
3798
4994
|
async function xl1BlockNumberToEthBlockNumber(context, xl1BlockNumber) {
|
|
3799
4995
|
const blockHash = await hashFromBlockNumber(context, xl1BlockNumber);
|
|
3800
4996
|
const hydratedBlock = await hydrateBlock(context.store, blockHash);
|
|
3801
|
-
const timePayload =
|
|
4997
|
+
const timePayload = asTimePayload3(hydratedBlock[1].find((p) => p.schema === TimeSchema2), {
|
|
3802
4998
|
required: true
|
|
3803
4999
|
});
|
|
3804
|
-
return
|
|
5000
|
+
return assertEx31(timePayload.ethereum, () => "No ethereum timestamp found on block");
|
|
3805
5001
|
}
|
|
3806
5002
|
__name(xl1BlockNumberToEthBlockNumber, "xl1BlockNumberToEthBlockNumber");
|
|
3807
5003
|
|
|
@@ -3836,13 +5032,20 @@ export {
|
|
|
3836
5032
|
ACCOUNT_TYPE,
|
|
3837
5033
|
ADDRESS_INDEX,
|
|
3838
5034
|
AbstractCreatableProvider,
|
|
5035
|
+
AccountBalanceConfigZod,
|
|
3839
5036
|
AccountBalanceHistoryItemZod,
|
|
5037
|
+
AccountBalanceQualificationZod,
|
|
3840
5038
|
AccountBalanceViewerMoniker,
|
|
3841
5039
|
AddressPairSchema,
|
|
3842
5040
|
BalancesStepSummarySchema,
|
|
3843
5041
|
BasisPointsZod,
|
|
3844
5042
|
BlockRewardViewerMoniker,
|
|
5043
|
+
BlockRunnerMoniker,
|
|
5044
|
+
BlockValidationConfigFieldsZod,
|
|
5045
|
+
BlockValidationConfigZod,
|
|
3845
5046
|
BlockValidationError,
|
|
5047
|
+
BlockValidationQualificationZod,
|
|
5048
|
+
BlockValidationViewerMoniker,
|
|
3846
5049
|
BlockViewerMoniker,
|
|
3847
5050
|
BridgeConfigZod,
|
|
3848
5051
|
BridgeSettingsZod,
|
|
@@ -3850,8 +5053,12 @@ export {
|
|
|
3850
5053
|
COIN_TYPES,
|
|
3851
5054
|
ChainContractViewerMoniker,
|
|
3852
5055
|
ChainIndexingServiceStateSchema,
|
|
5056
|
+
ChainQualificationZod,
|
|
5057
|
+
ChainQualifiedConfigZod,
|
|
5058
|
+
ChainQualifiedHeadConfigZod,
|
|
5059
|
+
ChainQualifiedRangeConfigZod,
|
|
5060
|
+
ChainQualifiedZod,
|
|
3853
5061
|
ChainStakeViewerMoniker,
|
|
3854
|
-
ChainViewerMoniker,
|
|
3855
5062
|
ConfigZod,
|
|
3856
5063
|
DEFAULT_WALLET_PATH,
|
|
3857
5064
|
DataLakeRunnerMoniker,
|
|
@@ -3861,14 +5068,17 @@ export {
|
|
|
3861
5068
|
EIP712DataPayloadSchema,
|
|
3862
5069
|
EIP712SignaturePayloadFieldsZod,
|
|
3863
5070
|
EIP712SignaturePayloadSchema,
|
|
5071
|
+
ExtendChainQualifiedConfigZod,
|
|
3864
5072
|
GlobalMetaSchema,
|
|
3865
5073
|
HydratedBlockStateValidationError,
|
|
3866
5074
|
HydratedBlockValidationError,
|
|
3867
5075
|
HydratedCache,
|
|
3868
5076
|
JSONSchemaMetaSchema,
|
|
5077
|
+
LoggerStatusReporter,
|
|
3869
5078
|
LruCacheMap,
|
|
3870
5079
|
MemoryMap,
|
|
3871
5080
|
MemoryPermissionsStore,
|
|
5081
|
+
MempoolRunnerMoniker,
|
|
3872
5082
|
MempoolViewerMoniker,
|
|
3873
5083
|
MnemonicStringZod,
|
|
3874
5084
|
NetworkStakeStepRewardViewerMoniker,
|
|
@@ -3882,17 +5092,19 @@ export {
|
|
|
3882
5092
|
PendingTransactionsOptionsZod,
|
|
3883
5093
|
ProviderFactory,
|
|
3884
5094
|
ProviderFactoryLocator,
|
|
3885
|
-
QualifiedZod,
|
|
3886
5095
|
RewardMultipliers,
|
|
5096
|
+
RuntimeStatusMonitor,
|
|
3887
5097
|
SchemasStepSummarySchema,
|
|
3888
5098
|
SimpleAccountBalanceViewer,
|
|
3889
5099
|
SimpleBlockRewardViewer,
|
|
5100
|
+
SimpleBlockValidationViewer,
|
|
3890
5101
|
SimpleBlockViewer,
|
|
3891
|
-
SimpleChainStakeViewer,
|
|
3892
5102
|
SimpleDataLakeRunner,
|
|
3893
5103
|
SimpleDataLakeViewer,
|
|
3894
5104
|
SimpleMempoolRunner,
|
|
3895
5105
|
SimpleMempoolViewer,
|
|
5106
|
+
SimpleStakeEventsViewer,
|
|
5107
|
+
SimpleStakeViewer,
|
|
3896
5108
|
SimpleTimeSyncViewer,
|
|
3897
5109
|
SimpleXyoClient,
|
|
3898
5110
|
SimpleXyoGateway,
|
|
@@ -3911,6 +5123,10 @@ export {
|
|
|
3911
5123
|
StepViewerMoniker,
|
|
3912
5124
|
TODO,
|
|
3913
5125
|
TimeSyncViewerMoniker,
|
|
5126
|
+
TransactionBuilder,
|
|
5127
|
+
TransactionValidationConfigZod,
|
|
5128
|
+
TransactionValidationQualificationZod,
|
|
5129
|
+
TransactionValidationViewerMoniker,
|
|
3914
5130
|
TransferBalanceViewerMoniker,
|
|
3915
5131
|
TransfersStepSummarySchema,
|
|
3916
5132
|
TypedDataDomainZod,
|
|
@@ -3925,8 +5141,14 @@ export {
|
|
|
3925
5141
|
XL1_NETWORK_STAKING_GENESIS_PERIOD_TOTAL_EARNED_REWARDS,
|
|
3926
5142
|
XL1_NETWORK_STAKING_GENESIS_PERIOD_TOTAL_REWARDS,
|
|
3927
5143
|
Xl1CommonConfigSchema,
|
|
5144
|
+
XyoConnectionMoniker,
|
|
5145
|
+
XyoRunnerMoniker,
|
|
3928
5146
|
XyoViewerMoniker,
|
|
5147
|
+
activeStakeAtTimeByAddress,
|
|
5148
|
+
activeStakeAtTimeByPosition,
|
|
3929
5149
|
allHashesPresent,
|
|
5150
|
+
allStakersForRange,
|
|
5151
|
+
allStakersForStep,
|
|
3930
5152
|
asAddressPairPayload,
|
|
3931
5153
|
asBalancesStepSummary,
|
|
3932
5154
|
asBalancesStepSummaryWithStorageMeta,
|
|
@@ -3944,23 +5166,33 @@ export {
|
|
|
3944
5166
|
balancesSummary,
|
|
3945
5167
|
blockFromBlockNumber,
|
|
3946
5168
|
blockPayloadsFromHydratedBlock,
|
|
5169
|
+
blockRangeSteps,
|
|
5170
|
+
buildRandomTransaction,
|
|
3947
5171
|
buildTransaction,
|
|
3948
5172
|
buildUnsignedTransaction,
|
|
3949
5173
|
bundledPayloadToHydratedBlock,
|
|
3950
5174
|
bundledPayloadToHydratedTransaction,
|
|
3951
5175
|
calculateFramesFromRange,
|
|
5176
|
+
chainStepRewardAddress,
|
|
3952
5177
|
completedStepRewardAddress,
|
|
3953
5178
|
confirmSubmittedTransaction,
|
|
3954
5179
|
contextCache,
|
|
3955
5180
|
crackOperation,
|
|
3956
5181
|
crackOperations,
|
|
3957
5182
|
creatableProvider,
|
|
5183
|
+
createDeclarationIntent,
|
|
5184
|
+
createTransferPayload,
|
|
3958
5185
|
deepCalculateFramesFromRange,
|
|
3959
5186
|
derivedReceiveAddress,
|
|
3960
5187
|
elevatedPayloads,
|
|
5188
|
+
externalBlockNumberFromXL1BlockNumber,
|
|
5189
|
+
externalBlockRangeFromStep,
|
|
5190
|
+
externalBlockRangeFromXL1BlockRange,
|
|
3961
5191
|
extractElevatedHashes,
|
|
3962
5192
|
extractElevatedHashesFromScript,
|
|
5193
|
+
findBestUncle,
|
|
3963
5194
|
findMostRecentBlock,
|
|
5195
|
+
findUncles,
|
|
3964
5196
|
flattenHydratedBlock,
|
|
3965
5197
|
flattenHydratedBlocks,
|
|
3966
5198
|
flattenHydratedTransaction,
|
|
@@ -3968,6 +5200,7 @@ export {
|
|
|
3968
5200
|
generateXyoBaseWalletFromPhrase,
|
|
3969
5201
|
getDefaultConfig,
|
|
3970
5202
|
getUrl,
|
|
5203
|
+
getWindowedChain,
|
|
3971
5204
|
hasLabels,
|
|
3972
5205
|
hasMongoConfig,
|
|
3973
5206
|
hashFromBlockNumber,
|
|
@@ -3977,12 +5210,20 @@ export {
|
|
|
3977
5210
|
hydratedBlockByNumber,
|
|
3978
5211
|
hydratedBlockToPayloadBundle,
|
|
3979
5212
|
hydratedTransactionToPayloadBundle,
|
|
5213
|
+
isAccountBalanceCOnfig,
|
|
5214
|
+
isAccountBalanceQualification,
|
|
3980
5215
|
isAddressPairPayload,
|
|
3981
5216
|
isBalancesStepSummary,
|
|
3982
5217
|
isBalancesStepSummaryWithStorageMeta,
|
|
5218
|
+
isBlockValidationConfig,
|
|
3983
5219
|
isBlockValidationError,
|
|
5220
|
+
isBlockValidationQualification,
|
|
3984
5221
|
isChainIndexingServiceState,
|
|
3985
5222
|
isChainIndexingServiceStateWithStorageMeta,
|
|
5223
|
+
isChainQualification,
|
|
5224
|
+
isChainQualifiedConfig,
|
|
5225
|
+
isChainQualifiedHeadConfig,
|
|
5226
|
+
isChainQualifiedRangeConfig,
|
|
3986
5227
|
isEIP712DataPayload,
|
|
3987
5228
|
isEIP712SignaturePayload,
|
|
3988
5229
|
isHydratedBlockStateValidationError,
|
|
@@ -3994,6 +5235,8 @@ export {
|
|
|
3994
5235
|
isReadWriteArchivist,
|
|
3995
5236
|
isSchemasStepSummary,
|
|
3996
5237
|
isSchemasStepSummaryWithStorageMeta,
|
|
5238
|
+
isTransactionValidationConfig,
|
|
5239
|
+
isTransactionValidationQualification,
|
|
3997
5240
|
isTransfersStepSummary,
|
|
3998
5241
|
isTransfersStepSummaryWithStorageMeta,
|
|
3999
5242
|
isUsageMeta,
|
|
@@ -4001,10 +5244,15 @@ export {
|
|
|
4001
5244
|
isZodError,
|
|
4002
5245
|
labeledCreatableProvider,
|
|
4003
5246
|
labeledCreatableProviderFactory,
|
|
5247
|
+
mapToMapType,
|
|
5248
|
+
mergeTransfers,
|
|
5249
|
+
mergedAddRemoveStakeEventsByPosition,
|
|
4004
5250
|
netBalancesForPayloads,
|
|
4005
5251
|
netSchemasForPayloads,
|
|
4006
5252
|
netTransfersForPayloads,
|
|
5253
|
+
networkStakeStepRewardPositionWeight,
|
|
4007
5254
|
parseSignedBigInt,
|
|
5255
|
+
payloadMapFromStore,
|
|
4008
5256
|
prettifyZodError,
|
|
4009
5257
|
readPayloadMapFromStore,
|
|
4010
5258
|
registerCreatableProviderFactories,
|
|
@@ -4012,10 +5260,16 @@ export {
|
|
|
4012
5260
|
rewardFromBlockNumber,
|
|
4013
5261
|
schemasStepSummaryFromRange,
|
|
4014
5262
|
schemasSummary,
|
|
5263
|
+
scoreUncle,
|
|
4015
5264
|
signEIP712Message,
|
|
4016
5265
|
signTransaction,
|
|
4017
5266
|
stepBlockRange,
|
|
5267
|
+
stepRewardBlock,
|
|
5268
|
+
stepRewardTotal,
|
|
4018
5269
|
stepTransferIndex,
|
|
5270
|
+
stepsRewardTotal,
|
|
5271
|
+
stepsRewardTotalGenesisPeriod,
|
|
5272
|
+
stepsRewardTotalRange,
|
|
4019
5273
|
timeBudget,
|
|
4020
5274
|
toPositiveBigInt,
|
|
4021
5275
|
toSignedBigInt,
|
|
@@ -4039,6 +5293,7 @@ export {
|
|
|
4039
5293
|
unflattenHydratedBlock,
|
|
4040
5294
|
unflattenHydratedTransaction,
|
|
4041
5295
|
verifyEIP712Message,
|
|
5296
|
+
weightedStakeForRangeByPosition,
|
|
4042
5297
|
withContextCacheResponse,
|
|
4043
5298
|
xl1BlockNumberToEthBlockNumber
|
|
4044
5299
|
};
|