@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
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import type { Provider } from '../model/index.ts'
|
|
1
2
|
import type { DataLakeRunner, DataLakeViewer } from './DataLake.ts'
|
|
2
3
|
import type { NetworkStakeViewer, XyoViewer } from './viewer/index.ts'
|
|
3
4
|
import type { XyoNetwork } from './XyoNetwork.ts'
|
|
4
5
|
import type { XyoRunner } from './XyoRunner.ts'
|
|
5
6
|
|
|
6
|
-
export
|
|
7
|
+
export const XyoConnectionMoniker = 'XyoConnection' as const
|
|
8
|
+
export type XyoConnectionMoniker = typeof XyoConnectionMoniker
|
|
9
|
+
|
|
10
|
+
export interface XyoConnection extends Provider<XyoConnectionMoniker> {
|
|
7
11
|
network?: XyoNetwork
|
|
8
12
|
networkStake?: NetworkStakeViewer
|
|
9
13
|
runner?: XyoRunner
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
Address, Hash,
|
|
2
|
+
Address, Hash, Promisable,
|
|
3
3
|
} from '@xylabs/sdk-js'
|
|
4
4
|
import type { Payload } from '@xyo-network/payload-model'
|
|
5
5
|
import type {
|
|
6
|
-
AllowedBlockPayload, AttoXL1, SignedHydratedTransaction, SignedHydratedTransactionWithHashMeta, TransactionFeesBigInt,
|
|
6
|
+
AllowedBlockPayload, AttoXL1, ChainId, SignedHydratedTransaction, SignedHydratedTransactionWithHashMeta, TransactionFeesBigInt,
|
|
7
7
|
UnsignedHydratedTransaction,
|
|
8
8
|
XL1BlockNumber,
|
|
9
9
|
} from '@xyo-network/xl1-protocol'
|
|
@@ -13,7 +13,7 @@ import type { DataLakeRunner } from './DataLake.ts'
|
|
|
13
13
|
import type { XyoGateway } from './XyoGateway.ts'
|
|
14
14
|
|
|
15
15
|
export interface TransactionOptions {
|
|
16
|
-
chain?:
|
|
16
|
+
chain?: ChainId
|
|
17
17
|
exp?: XL1BlockNumber
|
|
18
18
|
fees?: TransactionFeesBigInt
|
|
19
19
|
from?: Address
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import type { Hash, Promisable } from '@xylabs/sdk-js'
|
|
2
2
|
import type { SignedHydratedTransaction } from '@xyo-network/xl1-protocol'
|
|
3
3
|
|
|
4
|
+
import type { Provider } from '../model/index.ts'
|
|
4
5
|
import type { MempoolRunner } from '../runners/index.ts'
|
|
5
6
|
|
|
6
7
|
export interface XyoRunnerMethods {
|
|
7
8
|
broadcastTransaction(transaction: SignedHydratedTransaction): Promisable<Hash>
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
export
|
|
11
|
-
|
|
11
|
+
export const XyoRunnerMoniker = 'XyoRunner' as const
|
|
12
|
+
export type XyoRunnerMoniker = typeof XyoRunnerMoniker
|
|
13
|
+
|
|
14
|
+
export interface XyoRunner extends XyoRunnerMethods, Provider<XyoRunnerMoniker> {
|
|
15
|
+
mempool: MempoolRunner
|
|
12
16
|
}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
} from '@xylabs/sdk-js'
|
|
4
|
-
import type { AttoXL1, XL1BlockRange } from '@xyo-network/xl1-protocol'
|
|
1
|
+
import type { Address, Promisable } from '@xylabs/sdk-js'
|
|
2
|
+
import type { AttoXL1 } from '@xyo-network/xl1-protocol'
|
|
5
3
|
|
|
6
|
-
import type { Provider } from '../../model/index.ts'
|
|
4
|
+
import type { ChainQualifiedConfig, Provider } from '../../model/index.ts'
|
|
7
5
|
import type {
|
|
8
6
|
AccountBalanceHistoryItem,
|
|
9
7
|
AccountBalanceViewer,
|
|
10
8
|
BlockViewer,
|
|
11
9
|
BlockViewerMethods,
|
|
12
|
-
ChainViewerMethods,
|
|
13
10
|
ForkViewerMethods,
|
|
14
11
|
MempoolViewer,
|
|
15
12
|
NetworkStakeStepRewardViewerMethods,
|
|
16
13
|
StakeViewerMethods,
|
|
17
14
|
StepViewer,
|
|
15
|
+
TimeSyncViewer,
|
|
18
16
|
TransactionViewerMethods,
|
|
19
17
|
} from '../../viewers/index.ts'
|
|
20
18
|
import type { NetworkStakeViewer } from './NetworkStake/index.ts'
|
|
21
19
|
|
|
22
20
|
export interface XyoViewerMethods extends
|
|
23
|
-
NetworkStakeStepRewardViewerMethods,
|
|
21
|
+
NetworkStakeStepRewardViewerMethods, BlockViewerMethods,
|
|
24
22
|
TransactionViewerMethods, StakeViewerMethods, ForkViewerMethods {
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
/** @deprecated Use .account.balance.accountBalance instead */
|
|
24
|
+
accountBalance(address: Address, config?: ChainQualifiedConfig): Promisable<AttoXL1>
|
|
25
|
+
/** @deprecated Use .account.balance.accountBalanceHistory instead */
|
|
26
|
+
accountBalanceHistory(address: Address, config?: ChainQualifiedConfig): Promisable<AccountBalanceHistoryItem[]>
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export const XyoViewerMoniker = 'XyoViewer' as const
|
|
@@ -31,11 +31,12 @@ export type XyoViewerMoniker = typeof XyoViewerMoniker
|
|
|
31
31
|
|
|
32
32
|
export interface XyoViewer extends Omit<BlockViewer, 'moniker'>, XyoViewerMethods,
|
|
33
33
|
Omit<StakeViewerMethods, 'moniker'>, Provider<XyoViewerMoniker> {
|
|
34
|
-
account
|
|
35
|
-
balance
|
|
34
|
+
account: {
|
|
35
|
+
balance: AccountBalanceViewer
|
|
36
36
|
}
|
|
37
|
-
block
|
|
38
|
-
mempool
|
|
39
|
-
networkStake
|
|
40
|
-
step
|
|
37
|
+
block: BlockViewer
|
|
38
|
+
mempool: MempoolViewer
|
|
39
|
+
networkStake: NetworkStakeViewer
|
|
40
|
+
step: StepViewer
|
|
41
|
+
time: TimeSyncViewer
|
|
41
42
|
}
|
package/src/runners/Block.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { WithHashMeta } from '@xyo-network/payload-model'
|
|
2
|
+
import type {
|
|
3
|
+
BlockBoundWitness, SignedBlockBoundWitnessWithHashMeta, SignedHydratedBlockWithHashMeta,
|
|
4
|
+
} from '@xyo-network/xl1-protocol'
|
|
5
|
+
|
|
6
|
+
import type { Provider } from '../model/index.ts'
|
|
2
7
|
|
|
3
8
|
export interface BlockRunnerMethods {
|
|
4
9
|
produceNextBlock(head: SignedBlockBoundWitnessWithHashMeta, force: true): Promise<SignedHydratedBlockWithHashMeta>
|
|
5
10
|
produceNextBlock(head: SignedBlockBoundWitnessWithHashMeta, force?: false): Promise<SignedHydratedBlockWithHashMeta | undefined>
|
|
6
11
|
}
|
|
7
12
|
|
|
8
|
-
export
|
|
13
|
+
export const BlockRunnerMoniker = 'BlockRunner' as const
|
|
14
|
+
export type BlockRunnerMoniker = typeof BlockRunnerMoniker
|
|
9
15
|
|
|
16
|
+
export interface BlockRunner extends BlockRunnerMethods, Provider<BlockRunnerMoniker> {
|
|
17
|
+
next(head: WithHashMeta<BlockBoundWitness>): Promise<SignedHydratedBlockWithHashMeta | undefined>
|
|
10
18
|
}
|
package/src/runners/Mempool.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import type { Hash } from '@xylabs/sdk-js'
|
|
2
2
|
import type { SignedHydratedBlock, SignedHydratedTransaction } from '@xyo-network/xl1-protocol'
|
|
3
3
|
|
|
4
|
+
import type { Provider } from '../model/index.ts'
|
|
5
|
+
|
|
4
6
|
export interface MempoolRunnerMethods {
|
|
5
7
|
submitBlocks(blocks: SignedHydratedBlock[]): Promise<Hash[]>
|
|
6
8
|
submitTransactions(transactions: SignedHydratedTransaction[]): Promise<Hash[]>
|
|
7
9
|
}
|
|
8
10
|
|
|
9
|
-
export
|
|
11
|
+
export const MempoolRunnerMoniker = 'MempoolRunner' as const
|
|
12
|
+
export type MempoolRunnerMoniker = typeof MempoolRunnerMoniker
|
|
13
|
+
|
|
14
|
+
export interface MempoolRunner extends MempoolRunnerMethods, Provider<MempoolRunnerMoniker> {}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ChainContractViewer, ChainStakeViewer, ChainViewer,
|
|
3
|
-
} from '../../viewers/index.ts'
|
|
1
|
+
import type { ChainContractViewer, ChainStakeViewer } from '../../viewers/index.ts'
|
|
4
2
|
import type { BaseChainService } from './BaseChainService.ts'
|
|
5
3
|
|
|
6
|
-
export interface ChainService extends Omit<ChainContractViewer, 'moniker'>, Omit<ChainStakeViewer, 'moniker'>,
|
|
4
|
+
export interface ChainService extends Omit<ChainContractViewer, 'moniker'>, Omit<ChainStakeViewer, 'moniker'>, BaseChainService {}
|
|
@@ -2,6 +2,7 @@ import type { Address, Hash } from '@xylabs/sdk-js'
|
|
|
2
2
|
import {
|
|
3
3
|
asHash,
|
|
4
4
|
assertEx, exists, isDefined, spanRootAsync,
|
|
5
|
+
ZERO_ADDRESS,
|
|
5
6
|
} from '@xylabs/sdk-js'
|
|
6
7
|
import type { WithHashMeta, WithStorageMeta } from '@xyo-network/payload-model'
|
|
7
8
|
import type {
|
|
@@ -16,9 +17,12 @@ import {
|
|
|
16
17
|
import { deepCalculateFramesFromRange } from '../../block/index.ts'
|
|
17
18
|
import type { CreatableProviderParams } from '../../CreatableProvider/index.ts'
|
|
18
19
|
import { AbstractCreatableProvider, creatableProvider } from '../../CreatableProvider/index.ts'
|
|
19
|
-
import
|
|
20
|
+
import {
|
|
21
|
+
ChainQualification, type ChainQualified, isChainQualifiedHeadConfig, isChainQualifiedRangeConfig,
|
|
22
|
+
} from '../../model/index.ts'
|
|
20
23
|
import type {
|
|
21
|
-
BalanceStepSummaryContext,
|
|
24
|
+
BalanceStepSummaryContext,
|
|
25
|
+
TransfersStepSummary,
|
|
22
26
|
TransfersStepSummaryContext,
|
|
23
27
|
} from '../../summary/index.ts'
|
|
24
28
|
import {
|
|
@@ -26,13 +30,14 @@ import {
|
|
|
26
30
|
transfersStepSummaryFromRange,
|
|
27
31
|
} from '../../summary/index.ts'
|
|
28
32
|
import {
|
|
33
|
+
AccountBalanceConfig,
|
|
29
34
|
type AccountBalanceHistoryItem, type AccountBalanceViewer, AccountBalanceViewerMoniker,
|
|
30
35
|
type BlockViewer,
|
|
36
|
+
BlockViewerMoniker,
|
|
31
37
|
} from '../../viewers/index.ts'
|
|
32
38
|
|
|
33
39
|
export interface SimpleAccountBalanceViewerParams extends CreatableProviderParams {
|
|
34
|
-
|
|
35
|
-
context: BalanceStepSummaryContext
|
|
40
|
+
balanceSummaryContext: BalanceStepSummaryContext
|
|
36
41
|
transfersSummaryContext: TransfersStepSummaryContext
|
|
37
42
|
}
|
|
38
43
|
|
|
@@ -42,37 +47,38 @@ export class SimpleAccountBalanceViewer extends AbstractCreatableProvider<Simple
|
|
|
42
47
|
static readonly monikers = [AccountBalanceViewerMoniker]
|
|
43
48
|
moniker = SimpleAccountBalanceViewer.defaultMoniker
|
|
44
49
|
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
private _blockViewer?: BlockViewer
|
|
51
|
+
|
|
52
|
+
get balanceSummaryContext() {
|
|
53
|
+
return this.params.balanceSummaryContext!
|
|
47
54
|
}
|
|
48
55
|
|
|
49
|
-
get
|
|
50
|
-
return this.
|
|
56
|
+
get blockViewer() {
|
|
57
|
+
return this._blockViewer!
|
|
51
58
|
}
|
|
52
59
|
|
|
53
|
-
get transfersSummaryContext()
|
|
60
|
+
get transfersSummaryContext() {
|
|
54
61
|
return this.params.transfersSummaryContext!
|
|
55
62
|
}
|
|
56
63
|
|
|
57
|
-
static override async paramsHandler(params: Partial<SimpleAccountBalanceViewerParams>) {
|
|
58
|
-
assertEx(params.blockViewer, () => 'blockViewer is required')
|
|
59
|
-
assertEx(params.context, () => 'context is required')
|
|
64
|
+
static override async paramsHandler(params: Partial<SimpleAccountBalanceViewerParams> = {}) {
|
|
60
65
|
assertEx(params.transfersSummaryContext, () => 'transfersSummaryContext is required')
|
|
66
|
+
assertEx(params.balanceSummaryContext, () => 'balanceSummaryContext is required')
|
|
61
67
|
|
|
62
|
-
return
|
|
68
|
+
return await super.paramsHandler({ ...params })
|
|
63
69
|
}
|
|
64
70
|
|
|
65
|
-
async accountBalance(address: Address,
|
|
66
|
-
const balances = await this.accountBalances([address],
|
|
71
|
+
async accountBalance(address: Address, config?: AccountBalanceConfig) {
|
|
72
|
+
const balances = await this.accountBalances([address], config)
|
|
67
73
|
return balances[address] ?? AttoXL1(0n)
|
|
68
74
|
}
|
|
69
75
|
|
|
70
|
-
accountBalanceHistories(
|
|
71
|
-
|
|
76
|
+
async accountBalanceHistories(addresses: Address[], config: AccountBalanceConfig = {}) {
|
|
77
|
+
return (await this.qualifiedAccountBalanceHistories(addresses, config))[0]
|
|
72
78
|
}
|
|
73
79
|
|
|
74
|
-
async accountBalanceHistory(address: Address,
|
|
75
|
-
const range =
|
|
80
|
+
async accountBalanceHistory(address: Address, config?: AccountBalanceConfig) {
|
|
81
|
+
const range = isChainQualifiedRangeConfig(config) ? config.range : undefined
|
|
76
82
|
const startingRange = asXL1BlockRange(range ?? [0, await this.blockViewer.currentBlockNumber()], true)
|
|
77
83
|
const blockNumbers = await this.distillTransferHistory(address, startingRange)
|
|
78
84
|
const blocks = (await Promise.all(blockNumbers.map(async bn => await this.blockViewer.blockByNumber(bn)))).filter(exists)
|
|
@@ -99,64 +105,81 @@ export class SimpleAccountBalanceViewer extends AbstractCreatableProvider<Simple
|
|
|
99
105
|
return result
|
|
100
106
|
}
|
|
101
107
|
|
|
102
|
-
async accountBalances(address: Address[],
|
|
103
|
-
const [result] = (await this.qualifiedAccountBalances(address,
|
|
108
|
+
async accountBalances(address: Address[], config?: AccountBalanceConfig) {
|
|
109
|
+
const [result] = (await this.qualifiedAccountBalances(address, config ?? {}))
|
|
104
110
|
return result
|
|
105
111
|
}
|
|
106
112
|
|
|
113
|
+
override async createHandler() {
|
|
114
|
+
await super.createHandler()
|
|
115
|
+
this._blockViewer = await this.locator.getInstance(BlockViewerMoniker)
|
|
116
|
+
}
|
|
117
|
+
|
|
107
118
|
async qualifiedAccountBalanceHistories(
|
|
108
119
|
addresses: Address[],
|
|
109
|
-
|
|
110
|
-
)
|
|
111
|
-
const head =
|
|
112
|
-
const range =
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
120
|
+
config: AccountBalanceConfig,
|
|
121
|
+
) {
|
|
122
|
+
const head = isChainQualifiedHeadConfig(config) ? config.head : await this.blockViewer.currentBlockHash()
|
|
123
|
+
const range = isChainQualifiedRangeConfig(config)
|
|
124
|
+
? config.range
|
|
125
|
+
: asXL1BlockRange([0,
|
|
126
|
+
assertEx(
|
|
127
|
+
await this.blockViewer.blockByHash(head),
|
|
128
|
+
() => `Error: Could not find block with hash ${head}`,
|
|
129
|
+
)[0].block])
|
|
130
|
+
const qualifiedEntries = await Promise.all(addresses.map(async address => ([
|
|
118
131
|
address,
|
|
119
132
|
await this.qualifiedAccountBalanceHistory(address, range),
|
|
120
|
-
])))
|
|
133
|
+
]))) satisfies [Address, ChainQualified<AccountBalanceHistoryItem[]>][]
|
|
121
134
|
|
|
122
135
|
const entries = qualifiedEntries.map(([address, [history]]) => {
|
|
123
136
|
return [address, history]
|
|
124
137
|
})
|
|
125
|
-
const qualifiedRange = qualifiedEntries[0][1][1]
|
|
126
|
-
const qualifiedHeadHash = qualifiedEntries[0][1][
|
|
138
|
+
const qualifiedRange = qualifiedEntries[0][1][1].range
|
|
139
|
+
const qualifiedHeadHash = qualifiedEntries[0][1][1].head
|
|
127
140
|
|
|
128
141
|
// check for drift
|
|
129
|
-
for (const [_, [__, range,
|
|
142
|
+
for (const [_, [__, { range, head }]] of qualifiedEntries) {
|
|
130
143
|
assertEx(
|
|
131
144
|
range[0] === qualifiedRange[0] && range[1] === qualifiedRange[1],
|
|
132
145
|
() => 'Inconsistent ranges in qualifiedAccountBalanceHistories',
|
|
133
146
|
)
|
|
134
147
|
assertEx(
|
|
135
|
-
|
|
148
|
+
head === qualifiedHeadHash,
|
|
136
149
|
() => 'Inconsistent head hashes in qualifiedAccountBalanceHistories',
|
|
137
150
|
)
|
|
138
151
|
}
|
|
139
152
|
|
|
140
|
-
return [Object.fromEntries(entries), qualifiedRange, qualifiedHeadHash]
|
|
153
|
+
return [Object.fromEntries(entries), { range: qualifiedRange, head: qualifiedHeadHash }] satisfies
|
|
154
|
+
[Record<Address, AccountBalanceHistoryItem[]>, ChainQualification]
|
|
141
155
|
}
|
|
142
156
|
|
|
143
157
|
async qualifiedAccountBalances(
|
|
144
158
|
address: Address[],
|
|
145
|
-
|
|
146
|
-
): Promise<
|
|
159
|
+
config: AccountBalanceConfig,
|
|
160
|
+
): Promise<ChainQualified<Record<Address, AttoXL1>>> {
|
|
147
161
|
return await spanRootAsync('qualifiedAccountsBalances', async () => {
|
|
148
162
|
const qualifiedSummary = await balancesSummary(
|
|
149
|
-
this.
|
|
163
|
+
{ ...this.balanceSummaryContext },
|
|
164
|
+
config,
|
|
150
165
|
)
|
|
151
166
|
const result: Record<Address, AttoXL1> = {}
|
|
152
167
|
for (const addr of address) {
|
|
153
168
|
const summaryBalance = qualifiedSummary[0][addr] ?? 0n
|
|
154
169
|
result[addr] = AttoXL1(summaryBalance < 0n ? 0n : summaryBalance)
|
|
155
170
|
}
|
|
156
|
-
return [result, qualifiedSummary[1]
|
|
171
|
+
return [result, qualifiedSummary[1]]
|
|
157
172
|
})
|
|
158
173
|
}
|
|
159
174
|
|
|
175
|
+
override async startHandler() {
|
|
176
|
+
await super.startHandler()
|
|
177
|
+
await Promise.all([
|
|
178
|
+
this.accountBalance(ZERO_ADDRESS),
|
|
179
|
+
this.accountBalanceHistory(ZERO_ADDRESS),
|
|
180
|
+
])
|
|
181
|
+
}
|
|
182
|
+
|
|
160
183
|
private async distillTransferHistory(address: Address, range: XL1BlockRange, max: number = 50): Promise<XL1BlockNumber[]> {
|
|
161
184
|
if ((range[1] - range[0]) <= StepSizes[0] || max <= 1) {
|
|
162
185
|
return Array.from({ length: range[1] - range[0] + 1 }, (_, i) => range[1] - i).slice(0, max).map(n => asXL1BlockNumber(n, true))
|
|
@@ -198,7 +221,7 @@ export class SimpleAccountBalanceViewer extends AbstractCreatableProvider<Simple
|
|
|
198
221
|
private async qualifiedAccountBalanceHistory(
|
|
199
222
|
address: Address,
|
|
200
223
|
headOrRange?: Hash | XL1BlockRange,
|
|
201
|
-
): Promise<
|
|
224
|
+
): Promise<ChainQualified<AccountBalanceHistoryItem[]>> {
|
|
202
225
|
const range = asRange(headOrRange)
|
|
203
226
|
const headHash = asHash(headOrRange)
|
|
204
227
|
const [head] = assertEx(isDefined(headHash)
|
|
@@ -227,6 +250,6 @@ export class SimpleAccountBalanceViewer extends AbstractCreatableProvider<Simple
|
|
|
227
250
|
null,
|
|
228
251
|
transfer] satisfies AccountBalanceHistoryItem))
|
|
229
252
|
}
|
|
230
|
-
return [result, startingRange, head._hash]
|
|
253
|
+
return [result, { range: startingRange, head: head._hash }]
|
|
231
254
|
}
|
|
232
255
|
}
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
assertEx,
|
|
4
4
|
exists,
|
|
5
5
|
isDefined,
|
|
6
|
+
isUndefined,
|
|
6
7
|
spanRootAsync,
|
|
7
8
|
} from '@xylabs/sdk-js'
|
|
8
9
|
import type { ReadArchivist } from '@xyo-network/archivist-model'
|
|
@@ -10,6 +11,7 @@ import type { Payload, WithHashMeta } from '@xyo-network/payload-model'
|
|
|
10
11
|
import {
|
|
11
12
|
asSignedHydratedBlockWithHashMeta,
|
|
12
13
|
asXL1BlockNumber,
|
|
14
|
+
ChainId,
|
|
13
15
|
type SignedHydratedBlockWithHashMeta,
|
|
14
16
|
type XL1BlockNumber,
|
|
15
17
|
} from '@xyo-network/xl1-protocol'
|
|
@@ -22,12 +24,13 @@ import type {
|
|
|
22
24
|
ChainContextRead,
|
|
23
25
|
ChainStoreRead, PayloadMap,
|
|
24
26
|
} from '../../model/index.ts'
|
|
25
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
findMostRecentBlock, hydratedBlockByNumber, readPayloadMapFromStore,
|
|
29
|
+
} from '../../primitives/index.ts'
|
|
26
30
|
import { HydratedCache } from '../../utils/index.ts'
|
|
27
31
|
import { type BlockViewer, BlockViewerMoniker } from '../../viewers/index.ts'
|
|
28
32
|
|
|
29
33
|
export interface SimpleBlockViewerParams extends CreatableProviderParams {
|
|
30
|
-
context: ChainContextRead
|
|
31
34
|
finalizedArchivist: ReadArchivist
|
|
32
35
|
}
|
|
33
36
|
|
|
@@ -37,27 +40,25 @@ export class SimpleBlockViewer extends AbstractCreatableProvider<SimpleBlockView
|
|
|
37
40
|
static readonly monikers = [BlockViewerMoniker]
|
|
38
41
|
moniker = SimpleBlockViewer.defaultMoniker
|
|
39
42
|
|
|
43
|
+
protected _store: ChainStoreRead | undefined
|
|
44
|
+
|
|
40
45
|
private _payloadCache: PayloadMap<WithHashMeta<Payload>> | undefined
|
|
41
46
|
private _signedHydratedBlockCache: HydratedCache<SignedHydratedBlockWithHashMeta> | undefined
|
|
42
47
|
|
|
43
|
-
get context(): ChainContextRead {
|
|
44
|
-
return this.params.context!
|
|
45
|
-
}
|
|
46
|
-
|
|
47
48
|
get finalizedArchivist(): ReadArchivist {
|
|
48
49
|
return this.params.finalizedArchivist!
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
protected get hydratedBlockCache(): HydratedCache<SignedHydratedBlockWithHashMeta> {
|
|
52
53
|
if (this._signedHydratedBlockCache) return this._signedHydratedBlockCache
|
|
53
|
-
const chainMap = this.
|
|
54
|
+
const chainMap = this.store.chainMap
|
|
54
55
|
this._signedHydratedBlockCache = new HydratedCache<SignedHydratedBlockWithHashMeta>(chainMap, async (
|
|
55
|
-
|
|
56
|
+
store: ChainStoreRead,
|
|
56
57
|
hash: Hash,
|
|
57
58
|
maxDepth?: number,
|
|
58
59
|
minDepth?: number,
|
|
59
60
|
) => {
|
|
60
|
-
const result = await hydrateBlock(
|
|
61
|
+
const result = await hydrateBlock(store, hash, maxDepth, minDepth)
|
|
61
62
|
return asSignedHydratedBlockWithHashMeta(result, true)
|
|
62
63
|
}, 200)
|
|
63
64
|
return this._signedHydratedBlockCache
|
|
@@ -69,8 +70,11 @@ export class SimpleBlockViewer extends AbstractCreatableProvider<SimpleBlockView
|
|
|
69
70
|
return this._payloadCache
|
|
70
71
|
}
|
|
71
72
|
|
|
73
|
+
protected get store() {
|
|
74
|
+
return this._store!
|
|
75
|
+
}
|
|
76
|
+
|
|
72
77
|
static override async paramsHandler(params: Partial<SimpleBlockViewerParams>) {
|
|
73
|
-
assertEx(params.context, () => 'context is required')
|
|
74
78
|
assertEx(params.finalizedArchivist, () => 'finalizedArchivist is required')
|
|
75
79
|
|
|
76
80
|
return { ...await super.paramsHandler(params) }
|
|
@@ -85,7 +89,18 @@ export class SimpleBlockViewer extends AbstractCreatableProvider<SimpleBlockView
|
|
|
85
89
|
|
|
86
90
|
async blockByNumber(blockNumber: XL1BlockNumber): Promise<SignedHydratedBlockWithHashMeta | null> {
|
|
87
91
|
return await spanRootAsync('blockByNumber', async () => {
|
|
88
|
-
|
|
92
|
+
const head = await this.getCurrentHead()
|
|
93
|
+
if (isUndefined(head)) {
|
|
94
|
+
return null
|
|
95
|
+
}
|
|
96
|
+
return asSignedHydratedBlockWithHashMeta(await hydratedBlockByNumber({
|
|
97
|
+
chainId: head.chain,
|
|
98
|
+
head: () => {
|
|
99
|
+
return [head._hash, head.block]
|
|
100
|
+
},
|
|
101
|
+
store: this.store,
|
|
102
|
+
singletons: this.context.singletons,
|
|
103
|
+
} satisfies ChainContextRead, blockNumber)) ?? null
|
|
89
104
|
}, this.tracer)
|
|
90
105
|
}
|
|
91
106
|
|
|
@@ -121,9 +136,27 @@ export class SimpleBlockViewer extends AbstractCreatableProvider<SimpleBlockView
|
|
|
121
136
|
}, this.tracer)
|
|
122
137
|
}
|
|
123
138
|
|
|
139
|
+
chainId(): Promise<ChainId>
|
|
140
|
+
chainId(blockNumber: XL1BlockNumber): Promise<ChainId>
|
|
141
|
+
chainId(blockNumber: 'latest'): Promise<ChainId>
|
|
142
|
+
async chainId(blockNumber: XL1BlockNumber | 'latest' = 'latest'): Promise<ChainId> {
|
|
143
|
+
return await spanRootAsync('chainId', async () => {
|
|
144
|
+
const block = assertEx(
|
|
145
|
+
blockNumber === 'latest' ? await this.currentBlock() : await this.blockByNumber(blockNumber),
|
|
146
|
+
() => `Could not find block for block number ${blockNumber}`,
|
|
147
|
+
)
|
|
148
|
+
return block[0].chain
|
|
149
|
+
})
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
override async createHandler() {
|
|
153
|
+
await super.createHandler()
|
|
154
|
+
this._store = { chainMap: readPayloadMapFromStore(this.params.finalizedArchivist) }
|
|
155
|
+
}
|
|
156
|
+
|
|
124
157
|
async currentBlock(): Promise<SignedHydratedBlockWithHashMeta> {
|
|
125
158
|
return await spanRootAsync('currentBlock', async () => {
|
|
126
|
-
const currentHead = assertEx(await this.getCurrentHead(), () => 'Could not find most recent block')
|
|
159
|
+
const currentHead = assertEx(await this.getCurrentHead(), () => 'Could not find most recent block [currentBlock]')
|
|
127
160
|
const cache = this.hydratedBlockCache
|
|
128
161
|
const block = await cache.get(currentHead._hash)
|
|
129
162
|
if (!block) {
|
|
@@ -135,14 +168,14 @@ export class SimpleBlockViewer extends AbstractCreatableProvider<SimpleBlockView
|
|
|
135
168
|
|
|
136
169
|
async currentBlockHash(): Promise<Hash> {
|
|
137
170
|
return await spanRootAsync('currentBlockHash', async () => {
|
|
138
|
-
const currentHead = assertEx(await this.getCurrentHead(), () => 'Could not find most recent block')
|
|
171
|
+
const currentHead = assertEx(await this.getCurrentHead(), () => 'Could not find most recent block [currentBlockHash]')
|
|
139
172
|
return currentHead._hash
|
|
140
173
|
}, this.tracer)
|
|
141
174
|
}
|
|
142
175
|
|
|
143
176
|
async currentBlockNumber(): Promise<XL1BlockNumber> {
|
|
144
177
|
return await spanRootAsync('currentBlockNumber', async () => {
|
|
145
|
-
const currentHead = assertEx(await this.getCurrentHead(), () => 'Could not find most recent block')
|
|
178
|
+
const currentHead = assertEx(await this.getCurrentHead(), () => 'Could not find most recent block [currentBlockNumber]')
|
|
146
179
|
return asXL1BlockNumber(currentHead.block, { name: 'currentBlockNumber' })
|
|
147
180
|
}, this.tracer)
|
|
148
181
|
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { exists } from '@xylabs/sdk-js'
|
|
2
|
+
import {
|
|
3
|
+
asXL1BlockRange,
|
|
4
|
+
ChainId,
|
|
5
|
+
type SignedHydratedBlockWithHashMeta,
|
|
6
|
+
} from '@xyo-network/xl1-protocol'
|
|
7
|
+
|
|
8
|
+
import type { CreatableProviderParams } from '../../CreatableProvider/index.ts'
|
|
9
|
+
import { AbstractCreatableProvider, creatableProvider } from '../../CreatableProvider/index.ts'
|
|
10
|
+
import { findUncles, getWindowedChain } from '../../primitives/index.ts'
|
|
11
|
+
import type {
|
|
12
|
+
HydratedBlockStateValidationFunction, HydratedBlockValidationError, HydratedBlockValidationFunction,
|
|
13
|
+
} from '../../validation/index.ts'
|
|
14
|
+
import type {
|
|
15
|
+
AccountBalanceViewer,
|
|
16
|
+
BlockValidationConfig,
|
|
17
|
+
BlockValidationQualification,
|
|
18
|
+
BlockValidationViewer,
|
|
19
|
+
} from '../../viewers/index.ts'
|
|
20
|
+
import {
|
|
21
|
+
AccountBalanceViewerMoniker,
|
|
22
|
+
BlockValidationViewerMoniker, BlockViewer, BlockViewerMoniker,
|
|
23
|
+
} from '../../viewers/index.ts'
|
|
24
|
+
|
|
25
|
+
export interface SimpleBlockValidationViewerParams extends CreatableProviderParams {
|
|
26
|
+
maxUncleWindowSize: number
|
|
27
|
+
state?: HydratedBlockStateValidationFunction
|
|
28
|
+
value?: HydratedBlockValidationFunction
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@creatableProvider()
|
|
32
|
+
export class SimpleBlockValidationViewer extends AbstractCreatableProvider<SimpleBlockValidationViewerParams> implements BlockValidationViewer {
|
|
33
|
+
static readonly defaultMoniker = BlockValidationViewerMoniker
|
|
34
|
+
static readonly monikers = [BlockValidationViewerMoniker]
|
|
35
|
+
moniker = SimpleBlockValidationViewer.defaultMoniker
|
|
36
|
+
|
|
37
|
+
private _accountBalanceViewer!: AccountBalanceViewer
|
|
38
|
+
private _blockViewer!: BlockViewer
|
|
39
|
+
private _uncleWindowedChainCache: SignedHydratedBlockWithHashMeta[] | null = null
|
|
40
|
+
|
|
41
|
+
protected get blockViewer() {
|
|
42
|
+
return this._blockViewer
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
protected get maxUncleWindowSize() {
|
|
46
|
+
return this.params.maxUncleWindowSize
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static override async paramsHandler(params: Partial<SimpleBlockValidationViewerParams>): Promise<SimpleBlockValidationViewerParams> {
|
|
50
|
+
return {
|
|
51
|
+
...await super.paramsHandler(params),
|
|
52
|
+
maxUncleWindowSize: params.maxUncleWindowSize ?? 100,
|
|
53
|
+
} satisfies SimpleBlockValidationViewerParams
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
override async createHandler() {
|
|
57
|
+
await super.createHandler()
|
|
58
|
+
this._accountBalanceViewer = await this.locator.getInstance<AccountBalanceViewer>(AccountBalanceViewerMoniker)
|
|
59
|
+
this._blockViewer = await this.locator.getInstance<BlockViewer>(BlockViewerMoniker)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async qualifiedValidateBlock(
|
|
63
|
+
block: SignedHydratedBlockWithHashMeta,
|
|
64
|
+
config?: BlockValidationConfig,
|
|
65
|
+
): Promise<[HydratedBlockValidationError[], BlockValidationQualification]> {
|
|
66
|
+
return (await this.qualifiedValidateBlocks([block], config))
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async qualifiedValidateBlocks(
|
|
70
|
+
blocks: SignedHydratedBlockWithHashMeta[],
|
|
71
|
+
config?: BlockValidationConfig,
|
|
72
|
+
): Promise<[HydratedBlockValidationError[], BlockValidationQualification]> {
|
|
73
|
+
const { value, state } = config ?? {
|
|
74
|
+
shape: true, links: true, state: true,
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const [headBlock] = await this.blockViewer.currentBlock()
|
|
78
|
+
const chainId = headBlock.chain
|
|
79
|
+
|
|
80
|
+
const validateValue = value ? this.doValidateValue.bind(this) : undefined
|
|
81
|
+
const validateState = state ? this.doValidateState.bind(this) : undefined
|
|
82
|
+
|
|
83
|
+
return [(await Promise.all([
|
|
84
|
+
validateValue?.(blocks, chainId), validateState?.(blocks, chainId),
|
|
85
|
+
].filter(exists))).flat(), { head: headBlock._hash, range: asXL1BlockRange([0, headBlock.block], true) }]
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async validateBlock(block: SignedHydratedBlockWithHashMeta, config?: BlockValidationConfig): Promise<HydratedBlockValidationError[]> {
|
|
89
|
+
return (await this.validateBlocks([block], config))
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async validateBlocks(blocks: SignedHydratedBlockWithHashMeta[], config?: BlockValidationConfig): Promise<HydratedBlockValidationError[]> {
|
|
93
|
+
return (await this.qualifiedValidateBlocks(blocks, config))[0]
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
private async doValidateState(blocks: SignedHydratedBlockWithHashMeta[], chainId: ChainId): Promise<HydratedBlockValidationError[]> {
|
|
97
|
+
const windowedUncleChain = await this.updateWindowedChainCache()
|
|
98
|
+
|
|
99
|
+
const uncles = findUncles(this.context, windowedUncleChain, blocks)
|
|
100
|
+
|
|
101
|
+
if (uncles.length !== 1) {
|
|
102
|
+
throw new Error(`No uncles or greater than one uncle found in block validation, which is not supported [${uncles.length}]`)
|
|
103
|
+
}
|
|
104
|
+
return (await Promise.all(uncles[0].map(async (block) => {
|
|
105
|
+
return await this.params.state!(
|
|
106
|
+
block,
|
|
107
|
+
chainId,
|
|
108
|
+
{ accountBalance: this._accountBalanceViewer },
|
|
109
|
+
)
|
|
110
|
+
}))).flat()
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
private async doValidateValue(blocks: SignedHydratedBlockWithHashMeta[], chainId: ChainId): Promise<HydratedBlockValidationError[]> {
|
|
114
|
+
return (await Promise.all(blocks.map(async (block) => {
|
|
115
|
+
return await this.params.value!(
|
|
116
|
+
block,
|
|
117
|
+
chainId,
|
|
118
|
+
)
|
|
119
|
+
}))).flat()
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
private async updateWindowedChainCache() {
|
|
123
|
+
this._uncleWindowedChainCache = await getWindowedChain(this.blockViewer, this.maxUncleWindowSize, this._uncleWindowedChainCache ?? [])
|
|
124
|
+
return [...this._uncleWindowedChainCache]
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SimpleBlockValidationViewer.ts'
|