@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,8 +1,10 @@
|
|
|
1
1
|
import { hasAllLabels, type Labels } from '@xylabs/sdk-js'
|
|
2
2
|
import { assertEx } from '@xylabs/sdk-js'
|
|
3
3
|
|
|
4
|
-
import type { ProviderMoniker } from '../model/index.ts'
|
|
5
|
-
import type {
|
|
4
|
+
import type { Provider, ProviderMoniker } from '../model/index.ts'
|
|
5
|
+
import type {
|
|
6
|
+
CreatableProviderContext, CreatableProviderFactory, CreatableProviderInstance,
|
|
7
|
+
} from './CreatableProvider.ts'
|
|
6
8
|
import { type CreatableProviderRegistry, registerCreatableProviderFactory } from './CreatableProviderRegistry.ts'
|
|
7
9
|
import { hasLabels, type LabeledCreatableProviderFactory } from './LabeledCreatableProviderFactory.ts'
|
|
8
10
|
import type { ProviderFactoryLocatorInstance } from './ProviderFactoryLocatorInstance.ts'
|
|
@@ -11,12 +13,18 @@ import type { ProviderFactoryLocatorInstance } from './ProviderFactoryLocatorIns
|
|
|
11
13
|
* A class which encapsulates the Service Locator Pattern for Provider Factories
|
|
12
14
|
*/
|
|
13
15
|
export class ProviderFactoryLocator implements ProviderFactoryLocatorInstance {
|
|
16
|
+
protected readonly _context: CreatableProviderContext
|
|
14
17
|
protected readonly _registry: CreatableProviderRegistry
|
|
15
18
|
|
|
16
19
|
private _frozen = false
|
|
17
20
|
|
|
18
|
-
constructor(registry: CreatableProviderRegistry = {}) {
|
|
21
|
+
constructor(context: Omit<CreatableProviderContext, 'locator'>, registry: CreatableProviderRegistry = {}) {
|
|
19
22
|
this._registry = registry
|
|
23
|
+
this._context = { ...context, locator: this }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
get context() {
|
|
27
|
+
return this._context
|
|
20
28
|
}
|
|
21
29
|
|
|
22
30
|
/**
|
|
@@ -26,29 +34,56 @@ export class ProviderFactoryLocator implements ProviderFactoryLocatorInstance {
|
|
|
26
34
|
return this._registry
|
|
27
35
|
}
|
|
28
36
|
|
|
29
|
-
static empty() {
|
|
30
|
-
return new ProviderFactoryLocator({})
|
|
37
|
+
static empty(context: Omit<CreatableProviderContext, 'locator'>) {
|
|
38
|
+
return new ProviderFactoryLocator(context, {})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static standard(context: Omit<CreatableProviderContext, 'locator'>) {
|
|
42
|
+
return new ProviderFactoryLocator(context, {})
|
|
31
43
|
}
|
|
32
44
|
|
|
33
|
-
|
|
34
|
-
|
|
45
|
+
/** @deprecated use getInstance instead */
|
|
46
|
+
async create<TProvider extends Provider<ProviderMoniker>>(
|
|
47
|
+
moniker: TProvider['moniker'],
|
|
48
|
+
params?: Partial<CreatableProviderInstance<TProvider>['params']>,
|
|
49
|
+
labels?: Labels,
|
|
50
|
+
) {
|
|
51
|
+
return await this.getInstance<TProvider>(moniker, params, labels)
|
|
35
52
|
}
|
|
36
53
|
|
|
37
54
|
freeze() {
|
|
38
55
|
this._frozen = true
|
|
39
56
|
}
|
|
40
57
|
|
|
58
|
+
async getInstance<TProvider extends Provider<ProviderMoniker>>(
|
|
59
|
+
moniker: TProvider['moniker'],
|
|
60
|
+
params?: Partial<CreatableProviderInstance<TProvider>['params']>,
|
|
61
|
+
labels?: Labels,
|
|
62
|
+
) {
|
|
63
|
+
const resolvedParams = {
|
|
64
|
+
...params,
|
|
65
|
+
context: {
|
|
66
|
+
...this.context,
|
|
67
|
+
...params?.context,
|
|
68
|
+
} as CreatableProviderInstance<TProvider>['params']['context'],
|
|
69
|
+
} as CreatableProviderInstance<TProvider>['params']
|
|
70
|
+
const factory = this.locate<TProvider>(moniker, labels)
|
|
71
|
+
const result = await factory.getInstance(resolvedParams)
|
|
72
|
+
return result
|
|
73
|
+
}
|
|
74
|
+
|
|
41
75
|
/**
|
|
42
|
-
* Locates a provider factory that matches the supplied
|
|
43
|
-
* @param
|
|
76
|
+
* Locates a provider factory that matches the supplied moniker and labels
|
|
77
|
+
* @param moniker The config moniker for the provider
|
|
44
78
|
* @param labels The labels for the provider factory
|
|
45
|
-
* @returns A provider factory that matches the supplied
|
|
79
|
+
* @returns A provider factory that matches the supplied moniker and labels or throws if one is not found
|
|
46
80
|
*/
|
|
47
|
-
locate(moniker:
|
|
81
|
+
locate<TProvider extends Provider<ProviderMoniker>>(moniker: TProvider['moniker'], labels?: Labels):
|
|
82
|
+
CreatableProviderFactory<CreatableProviderInstance<TProvider>> | LabeledCreatableProviderFactory<CreatableProviderInstance<TProvider>> {
|
|
48
83
|
return assertEx(
|
|
49
|
-
this.tryLocate(moniker, labels),
|
|
84
|
+
this.tryLocate<TProvider>(moniker, labels),
|
|
50
85
|
|
|
51
|
-
() => `No module factory for the supplied config
|
|
86
|
+
() => `No module factory for the supplied config moniker [${moniker}]${labels ? ` & labels [${JSON.stringify(labels)}]` : ''} registered`,
|
|
52
87
|
)
|
|
53
88
|
}
|
|
54
89
|
|
|
@@ -61,7 +96,7 @@ export class ProviderFactoryLocator implements ProviderFactoryLocatorInstance {
|
|
|
61
96
|
registry[moniker] = locator.registry[moniker]
|
|
62
97
|
}
|
|
63
98
|
}
|
|
64
|
-
return new ProviderFactoryLocator(registry)
|
|
99
|
+
return new ProviderFactoryLocator(this.context, registry)
|
|
65
100
|
}
|
|
66
101
|
|
|
67
102
|
/**
|
|
@@ -86,17 +121,42 @@ export class ProviderFactoryLocator implements ProviderFactoryLocatorInstance {
|
|
|
86
121
|
return this
|
|
87
122
|
}
|
|
88
123
|
|
|
124
|
+
async tryGetInstance<TProvider extends Provider<ProviderMoniker>>(
|
|
125
|
+
moniker: TProvider['moniker'],
|
|
126
|
+
params?: Partial<CreatableProviderInstance<TProvider>['params']>,
|
|
127
|
+
labels?: Labels,
|
|
128
|
+
) {
|
|
129
|
+
try {
|
|
130
|
+
return await this.getInstance<TProvider>(moniker, params, labels)
|
|
131
|
+
} catch {
|
|
132
|
+
return
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
89
136
|
/**
|
|
90
|
-
* Tries to locate a module factory that matches the supplied
|
|
91
|
-
* @param
|
|
137
|
+
* Tries to locate a module factory that matches the supplied moniker and labels
|
|
138
|
+
* @param moniker The config moniker for the module
|
|
92
139
|
* @param labels The labels for the module factory
|
|
93
|
-
* @returns A module factory that matches the supplied
|
|
140
|
+
* @returns A module factory that matches the supplied moniker and labels or undefined
|
|
94
141
|
*/
|
|
95
|
-
tryLocate(moniker:
|
|
96
|
-
|
|
142
|
+
tryLocate<TProvider extends Provider<ProviderMoniker>>(moniker: TProvider['moniker'], labels?: Labels) {
|
|
143
|
+
const result = labels
|
|
97
144
|
// Find the first factory that has labels and has all the labels provided
|
|
98
145
|
? (this._registry[moniker]?.filter(hasLabels).find(factory => hasAllLabels(factory?.labels, labels)) ?? this._registry[moniker]?.[0])
|
|
99
146
|
// Otherwise, return the first factory
|
|
100
147
|
: this._registry[moniker]?.[0]
|
|
148
|
+
|
|
149
|
+
if (result) {
|
|
150
|
+
result.defaultParams = {
|
|
151
|
+
...result?.defaultParams,
|
|
152
|
+
context: {
|
|
153
|
+
...this.context,
|
|
154
|
+
...result?.defaultParams?.context,
|
|
155
|
+
},
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return result as CreatableProviderFactory<CreatableProviderInstance<TProvider>>
|
|
160
|
+
| LabeledCreatableProviderFactory<CreatableProviderInstance<TProvider>> | undefined
|
|
101
161
|
}
|
|
102
162
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Labels } from '@xylabs/sdk-js'
|
|
2
2
|
|
|
3
|
-
import type { ProviderMoniker } from '../model/index.ts'
|
|
4
|
-
import type { CreatableProviderFactory } from './CreatableProvider.ts'
|
|
3
|
+
import type { Provider, ProviderMoniker } from '../model/index.ts'
|
|
4
|
+
import type { CreatableProviderFactory, CreatableProviderInstance } from './CreatableProvider.ts'
|
|
5
5
|
import type { CreatableProviderRegistry } from './CreatableProviderRegistry.ts'
|
|
6
6
|
import type { LabeledCreatableProviderFactory } from './LabeledCreatableProviderFactory.ts'
|
|
7
7
|
|
|
@@ -12,15 +12,31 @@ export interface ProviderFactoryLocatorInstance {
|
|
|
12
12
|
*/
|
|
13
13
|
registry: Readonly<CreatableProviderRegistry>
|
|
14
14
|
|
|
15
|
+
/** @deprecated use getInstance instead */
|
|
16
|
+
create<TProvider extends Provider<ProviderMoniker>,
|
|
17
|
+
TParams extends CreatableProviderInstance<TProvider>['params'] = CreatableProviderInstance<TProvider>['params']>(
|
|
18
|
+
moniker: TProvider['moniker'],
|
|
19
|
+
params?: TParams,
|
|
20
|
+
labels?: Labels,
|
|
21
|
+
): Promise<CreatableProviderInstance<TProvider>>
|
|
22
|
+
|
|
15
23
|
freeze(): void
|
|
16
24
|
|
|
25
|
+
getInstance<TProvider extends Provider<ProviderMoniker>,
|
|
26
|
+
TParams extends CreatableProviderInstance<TProvider>['params'] = CreatableProviderInstance<TProvider>['params']>(
|
|
27
|
+
moniker: TProvider['moniker'],
|
|
28
|
+
params?: Partial<TParams>,
|
|
29
|
+
labels?: Labels,
|
|
30
|
+
): Promise<CreatableProviderInstance<TProvider>>
|
|
31
|
+
|
|
17
32
|
/**
|
|
18
|
-
* Locates a module factory that matches the supplied
|
|
19
|
-
* @param
|
|
33
|
+
* Locates a module factory that matches the supplied moniker and labels
|
|
34
|
+
* @param moniker The config moniker for the module
|
|
20
35
|
* @param labels The labels for the module factory
|
|
21
|
-
* @returns A module factory that matches the supplied
|
|
36
|
+
* @returns A module factory that matches the supplied moniker and labels or throws if one is not found
|
|
22
37
|
*/
|
|
23
|
-
locate(
|
|
38
|
+
locate<TProvider extends Provider<ProviderMoniker>>(moniker: ProviderMoniker, labels?: Labels):
|
|
39
|
+
CreatableProviderFactory<CreatableProviderInstance<TProvider>> | LabeledCreatableProviderFactory<CreatableProviderInstance<TProvider>> | undefined
|
|
24
40
|
|
|
25
41
|
merge(locator: ProviderFactoryLocatorInstance): ProviderFactoryLocatorInstance
|
|
26
42
|
|
|
@@ -37,11 +53,18 @@ export interface ProviderFactoryLocatorInstance {
|
|
|
37
53
|
*/
|
|
38
54
|
registerMany(factories: CreatableProviderFactory[]): ProviderFactoryLocatorInstance
|
|
39
55
|
|
|
56
|
+
tryGetInstance<TProvider extends Provider<ProviderMoniker>,
|
|
57
|
+
TParams extends CreatableProviderInstance<TProvider>['params'] = CreatableProviderInstance<TProvider>['params']>(
|
|
58
|
+
moniker: TProvider['moniker'],
|
|
59
|
+
params?: Partial<TParams>,
|
|
60
|
+
labels?: Labels,
|
|
61
|
+
): Promise<CreatableProviderInstance<TProvider> | undefined>
|
|
62
|
+
|
|
40
63
|
/**
|
|
41
|
-
* Tries to locate a module factory that matches the supplied
|
|
42
|
-
* @param
|
|
64
|
+
* Tries to locate a module factory that matches the supplied moniker and labels
|
|
65
|
+
* @param moniker The config moniker for the module
|
|
43
66
|
* @param labels The labels for the module factory
|
|
44
|
-
* @returns A module factory that matches the supplied
|
|
67
|
+
* @returns A module factory that matches the supplied moniker and labels or undefined
|
|
45
68
|
*/
|
|
46
|
-
tryLocate(
|
|
69
|
+
tryLocate(moniker: ProviderMoniker, labels?: Labels): CreatableProviderFactory | LabeledCreatableProviderFactory | undefined
|
|
47
70
|
}
|
package/src/config/Bridge.ts
CHANGED
|
@@ -9,11 +9,12 @@ import * as z from 'zod'
|
|
|
9
9
|
import { MnemonicStringZod } from '../validation/index.ts'
|
|
10
10
|
|
|
11
11
|
const DEFAULT_FIXED_FEE = toHex(XL1(1n) * AttoXL1ConvertFactor.xl1)
|
|
12
|
-
const
|
|
13
|
-
const DEFAULT_MAX_BRIDGE_AMOUNT = toHex(XL1(100_000n) * AttoXL1ConvertFactor.xl1)
|
|
12
|
+
const DEFAULT_HARDHAT_BRIDGE_CONTRACT = toAddress('2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6')
|
|
14
13
|
const DEFAULT_HARDHAT_CHAIN_ID: ChainId = toHex('7A69')
|
|
14
|
+
const DEFAULT_HARDHAT_REMOTE_CHAIN_WALLET_PRIVATE_KEY = toHex('0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80')
|
|
15
15
|
const DEFAULT_HARDHAT_TOKEN_CONTRACT = toAddress('5FbDB2315678afecb367f032d93F642f64180aa3')
|
|
16
|
-
const
|
|
16
|
+
const DEFAULT_MAX_BRIDGE_AMOUNT = toHex(XL1(100_000n) * AttoXL1ConvertFactor.xl1)
|
|
17
|
+
const DEFAULT_MIN_BRIDGE_AMOUNT = toHex(XL1(10n) * AttoXL1ConvertFactor.xl1)
|
|
17
18
|
|
|
18
19
|
export const BasisPointsZod = z.coerce.number().int().nonnegative().max(10_000)
|
|
19
20
|
export type BasisPoints = z.infer<typeof BasisPointsZod>
|
|
@@ -70,12 +71,24 @@ export const BridgeConfigZod = z.object({
|
|
|
70
71
|
title: 'bridge.mnemonic',
|
|
71
72
|
type: 'string',
|
|
72
73
|
}),
|
|
73
|
-
port: z.coerce.number().default(8081).register(globalRegistry, {
|
|
74
|
+
port: z.coerce.number().int().positive().default(8081).register(globalRegistry, {
|
|
74
75
|
default: 8081,
|
|
75
76
|
description: 'Port for the Bridge',
|
|
76
77
|
title: 'bridge.port',
|
|
77
78
|
type: 'number',
|
|
78
79
|
}),
|
|
80
|
+
redisHost: z.string().default('localhost').register(globalRegistry, {
|
|
81
|
+
default: 'localhost',
|
|
82
|
+
description: 'Host for the Bridge Redis instance',
|
|
83
|
+
title: 'bridge.redisHost',
|
|
84
|
+
type: 'string',
|
|
85
|
+
}),
|
|
86
|
+
redisPort: z.coerce.number().int().positive().default(6379).register(globalRegistry, {
|
|
87
|
+
default: 6379,
|
|
88
|
+
description: 'Port for the Bridge Redis instance',
|
|
89
|
+
title: 'bridge.redisPort',
|
|
90
|
+
type: 'number',
|
|
91
|
+
}),
|
|
79
92
|
remoteBridgeContractAddress: AddressZod.default(DEFAULT_HARDHAT_BRIDGE_CONTRACT).register(globalRegistry, {
|
|
80
93
|
default: DEFAULT_HARDHAT_BRIDGE_CONTRACT,
|
|
81
94
|
description: 'Hex representation of remote token address used for bridging',
|
|
@@ -94,6 +107,11 @@ export const BridgeConfigZod = z.object({
|
|
|
94
107
|
title: 'bridge.remoteTokenAddress',
|
|
95
108
|
type: 'string',
|
|
96
109
|
}),
|
|
110
|
+
remoteChainWalletPrivateKey: HexZod.default(DEFAULT_HARDHAT_REMOTE_CHAIN_WALLET_PRIVATE_KEY).register(globalRegistry, {
|
|
111
|
+
description: 'Private key for the wallet to use for the remote chain wallet',
|
|
112
|
+
title: 'bridge.remoteChainWalletPrivateKey',
|
|
113
|
+
type: 'string',
|
|
114
|
+
}),
|
|
97
115
|
xl1ChainId: HexZod.optional().register(globalRegistry, {
|
|
98
116
|
description: 'XL1 chain id used for bridging',
|
|
99
117
|
title: 'bridge.xl1ChainId',
|
package/src/config/Chain.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { AddressZod } from '@xylabs/sdk-js'
|
|
1
|
+
import { AddressZod, HexZod } from '@xylabs/sdk-js'
|
|
2
2
|
import { globalRegistry } from 'zod'
|
|
3
3
|
import * as z from 'zod'
|
|
4
4
|
|
|
5
5
|
export const ChainConfigZod = z.object({
|
|
6
|
-
id:
|
|
6
|
+
id: HexZod.optional()
|
|
7
7
|
.register(globalRegistry, {
|
|
8
8
|
description:
|
|
9
9
|
'The unique identifier for the chain. Should be the staking contract address for contract-backed chains.',
|
package/src/config/Services.ts
CHANGED
|
@@ -2,12 +2,14 @@ import { globalRegistry } from 'zod'
|
|
|
2
2
|
import * as z from 'zod'
|
|
3
3
|
|
|
4
4
|
export const ServicesConfigZod = z.object({
|
|
5
|
-
accountBalanceViewerEndpoint: z.string().
|
|
5
|
+
accountBalanceViewerEndpoint: z.string().default('http://localhost:8080/rpc').register(globalRegistry, {
|
|
6
|
+
default: 'http://localhost:8080/rpc',
|
|
6
7
|
description: 'Endpoint of the API to use for instantiating an external AccountBalanceViewer',
|
|
7
8
|
title: 'services.accountBalanceViewerEndpoint',
|
|
8
9
|
type: 'string',
|
|
9
10
|
}),
|
|
10
|
-
apiEndpoint: z.string().
|
|
11
|
+
apiEndpoint: z.string().default('http://localhost:8080/rpc').register(globalRegistry, {
|
|
12
|
+
default: 'http://localhost:8080/rpc',
|
|
11
13
|
description: 'Endpoint of the API to use for instantiating an external Viewers',
|
|
12
14
|
title: 'services.apiEndpoint',
|
|
13
15
|
type: 'string',
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/sdk-js'
|
|
2
|
+
import { isDefined } from '@xylabs/sdk-js'
|
|
3
|
+
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
4
|
+
import {
|
|
5
|
+
type ChainStakeIntent, ChainStakeIntentSchema, type Intent,
|
|
6
|
+
} from '@xyo-network/xl1-protocol'
|
|
7
|
+
|
|
8
|
+
export const createDeclarationIntent = (address: Address, intent: Intent, nbf: number, exp?: number): ChainStakeIntent => {
|
|
9
|
+
const expiration = isDefined(exp) ? exp : nbf + 10_000
|
|
10
|
+
const redeclarationIntent = new PayloadBuilder<ChainStakeIntent>({ schema: ChainStakeIntentSchema }).fields({
|
|
11
|
+
from: address, intent, nbf, exp: expiration,
|
|
12
|
+
}).build()
|
|
13
|
+
return redeclarationIntent
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Address, JsonObject } from '@xylabs/sdk-js'
|
|
2
|
+
import { toHex } from '@xylabs/sdk-js'
|
|
3
|
+
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
4
|
+
import type { Transfer } from '@xyo-network/xl1-protocol'
|
|
5
|
+
import { TransferSchema } from '@xyo-network/xl1-protocol'
|
|
6
|
+
|
|
7
|
+
export function createTransferPayload(from: Address, transfers: Record<Address, bigint>, context?: JsonObject): Transfer {
|
|
8
|
+
return new PayloadBuilder<Transfer>({ schema: TransferSchema })
|
|
9
|
+
.fields({
|
|
10
|
+
epoch: Date.now(),
|
|
11
|
+
from,
|
|
12
|
+
transfers: Object.fromEntries(Object.entries(transfers).map(([k, v]) => [k, toHex(v)])),
|
|
13
|
+
context,
|
|
14
|
+
}).build()
|
|
15
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { LRUCache } from 'lru-cache'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { SyncMap } from '../../map/index.ts'
|
|
4
4
|
|
|
5
|
-
export class LruCacheMap<K extends {}, V extends {} | string | number | bigint, FC = () => void> implements
|
|
5
|
+
export class LruCacheMap<K extends {}, V extends {} | string | number | bigint, FC = () => void> implements SyncMap<K, V> {
|
|
6
6
|
private lruCache: LRUCache<K, V, FC>
|
|
7
7
|
|
|
8
8
|
constructor(options?: LRUCache.Options<K, V, FC>) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { isDefined } from '@xylabs/sdk-js'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { SyncMap } from '../../map/index.ts'
|
|
4
4
|
|
|
5
|
-
export class MemoryMap<K extends {}, V = {}> implements
|
|
5
|
+
export class MemoryMap<K extends {}, V = {}> implements SyncMap<K, V> {
|
|
6
6
|
private map: Map<K, V>
|
|
7
7
|
|
|
8
8
|
constructor() {
|
package/src/index.ts
CHANGED
|
@@ -3,6 +3,8 @@ export * from './ChainServiceCollectionV2.ts'
|
|
|
3
3
|
export * from './config/index.ts'
|
|
4
4
|
export * from './constants.ts'
|
|
5
5
|
export * from './CreatableProvider/index.ts'
|
|
6
|
+
export * from './createDeclarationPayload.ts'
|
|
7
|
+
export * from './createTransferPayload.ts'
|
|
6
8
|
export * from './driver/index.ts'
|
|
7
9
|
export * from './eip-712/index.ts'
|
|
8
10
|
export * from './instances/index.ts'
|
|
@@ -16,6 +18,7 @@ export * from './runners/index.ts'
|
|
|
16
18
|
export * from './services/index.ts'
|
|
17
19
|
export * from './SignedBigInt.ts'
|
|
18
20
|
export * from './simple/index.ts'
|
|
21
|
+
export * from './status/index.ts'
|
|
19
22
|
export * from './summary/index.ts'
|
|
20
23
|
export * from './time/index.ts'
|
|
21
24
|
export * from './transaction/index.ts'
|
package/src/map/MapType.ts
CHANGED
|
@@ -5,11 +5,13 @@ import type {
|
|
|
5
5
|
SyncIterableMap, SyncIterableMapRead, SyncIterableMapWrite, SyncMap, SyncMapRead, SyncMapWrite,
|
|
6
6
|
} from './SyncMap.ts'
|
|
7
7
|
|
|
8
|
-
export type
|
|
8
|
+
export type MapType<TId, TData> = SyncMap<TId, TData> | AsyncMap<TId, TData>
|
|
9
9
|
|
|
10
10
|
export type MapTypeRead<TId, TData> = SyncMapRead<TId, TData> | AsyncMapRead<TId, TData>
|
|
11
11
|
|
|
12
|
-
export type
|
|
12
|
+
export type MapTypeWrite<TId, TData> = SyncMapWrite<TId, TData> | AsyncMapWrite<TId, TData>
|
|
13
|
+
|
|
14
|
+
export type AsynchronousMapType<TId, TData> = AsyncMapRead<TId, TData> & AsyncMapWrite<TId, TData>
|
|
13
15
|
|
|
14
16
|
export type IterableMapRead<TId, TData> = SyncIterableMapRead<TId, TData> | AsyncIterableMapRead<TId, TData>
|
|
15
17
|
|
|
@@ -4,7 +4,6 @@ import { isDefined, isUndefined } from '@xylabs/sdk-js'
|
|
|
4
4
|
import { LruCacheMap, MemoryMap } from '../../driver/index.ts'
|
|
5
5
|
import type { MapType } from '../../map/index.ts'
|
|
6
6
|
import { timeBudget } from '../../primitives/index.ts'
|
|
7
|
-
import type { ChainIdentity } from '../ChainIdentity.ts'
|
|
8
7
|
import type {
|
|
9
8
|
ChainStakeContext, ChainStakeContextRead, ChainStakeContextWrite,
|
|
10
9
|
} from './ChainStakeContext.ts'
|
|
@@ -16,6 +15,7 @@ import type {
|
|
|
16
15
|
export interface BaseContext<TCacheValue = string | object | number | bigint> {
|
|
17
16
|
caches?: Record<string, MapType<string, TCacheValue>>
|
|
18
17
|
logger?: Logger
|
|
18
|
+
singletons: Record<string, unknown>
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export function contextCache<TCacheValue>(
|
|
@@ -58,14 +58,14 @@ export async function withContextCacheResponse<T extends {} | string | number |
|
|
|
58
58
|
return result
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
export interface ChainContextWrite extends BaseContext,
|
|
61
|
+
export interface ChainContextWrite extends BaseContext, ChainStateContextWrite, ChainStoreContextWrite {}
|
|
62
62
|
|
|
63
63
|
export interface StakedChainContextWrite extends BaseContext, ChainContextWrite, ChainStakeContextWrite {}
|
|
64
64
|
|
|
65
|
-
export interface ChainContextRead extends BaseContext,
|
|
65
|
+
export interface ChainContextRead extends BaseContext, ChainStateContextRead, ChainStoreContextRead {}
|
|
66
66
|
|
|
67
67
|
export interface StakedChainContextRead extends BaseContext, ChainContextRead, ChainStakeContextRead {}
|
|
68
68
|
|
|
69
|
-
export type ChainContext =
|
|
69
|
+
export type ChainContext = ChainContextRead & ChainContextWrite & ChainStoreContext
|
|
70
70
|
|
|
71
71
|
export type StakedChainContext = ChainContext & ChainStakeContext & ChainStakeContextRead & ChainStakeContextWrite
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { HashZod } from '@xylabs/hex'
|
|
2
|
+
import { zodIsFactory } from '@xylabs/zod'
|
|
3
|
+
import { XL1BlockRangeZod } from '@xyo-network/xl1-protocol'
|
|
4
|
+
import z from 'zod'
|
|
5
|
+
|
|
6
|
+
export const ChainQualificationZod = z.object({ head: HashZod, range: XL1BlockRangeZod })
|
|
7
|
+
export type ChainQualification = z.infer<typeof ChainQualificationZod>
|
|
8
|
+
export const isChainQualification = zodIsFactory(ChainQualificationZod)
|
|
9
|
+
|
|
10
|
+
export const ChainQualifiedRangeConfigZod = z.object({ range: XL1BlockRangeZod })
|
|
11
|
+
export type ChainQualifiedRangeConfig = z.infer<typeof ChainQualifiedRangeConfigZod>
|
|
12
|
+
export const isChainQualifiedRangeConfig = zodIsFactory(ChainQualifiedRangeConfigZod)
|
|
13
|
+
|
|
14
|
+
export const ChainQualifiedHeadConfigZod = z.object({ head: HashZod })
|
|
15
|
+
export type ChainQualifiedHeadConfig = z.infer<typeof ChainQualifiedHeadConfigZod>
|
|
16
|
+
export const isChainQualifiedHeadConfig = zodIsFactory(ChainQualifiedHeadConfigZod)
|
|
17
|
+
|
|
18
|
+
export const ChainQualifiedConfigZod = z.union([ChainQualifiedRangeConfigZod, ChainQualifiedHeadConfigZod, z.object({})])
|
|
19
|
+
export type ChainQualifiedConfig = z.infer<typeof ChainQualifiedConfigZod>
|
|
20
|
+
export const isChainQualifiedConfig = zodIsFactory(ChainQualifiedConfigZod)
|
|
21
|
+
|
|
22
|
+
export const ExtendChainQualifiedConfigZod = (<T>(zodType: z.ZodType<T>) => {
|
|
23
|
+
return z.union([
|
|
24
|
+
ChainQualifiedRangeConfigZod.extend(zodType),
|
|
25
|
+
ChainQualifiedHeadConfigZod.extend(zodType),
|
|
26
|
+
zodType,
|
|
27
|
+
])
|
|
28
|
+
}) as <T>(zodType: z.ZodType<T>) => z.ZodType<T & ChainQualifiedConfig>
|
|
29
|
+
|
|
30
|
+
export type ChainQualified<T> = [T, ChainQualification]
|
|
31
|
+
export const ChainQualifiedZod = <T>(zodType: z.ZodType<T>) => {
|
|
32
|
+
return z.tuple([zodType, ChainQualificationZod])
|
|
33
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
2
|
-
import type { PayloadBundle
|
|
2
|
+
import type { PayloadBundle } from '@xyo-network/payload-model'
|
|
3
3
|
import type { SignedHydratedTransactionWithHashMeta } from '@xyo-network/xl1-protocol'
|
|
4
4
|
import { asSignedTransactionBoundWitnessWithHashMeta } from '@xyo-network/xl1-protocol'
|
|
5
5
|
|
|
6
6
|
export const bundledPayloadToHydratedTransaction = async (
|
|
7
|
-
payload:
|
|
7
|
+
payload: PayloadBundle,
|
|
8
8
|
): Promise<SignedHydratedTransactionWithHashMeta | undefined> => {
|
|
9
9
|
const withHashMeta = await PayloadBuilder.addHashMeta(payload.payloads)
|
|
10
10
|
const tx = asSignedTransactionBoundWitnessWithHashMeta(withHashMeta.find(p => p._hash === payload.root))
|
package/src/model/index.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export * from './ChainContext/index.ts'
|
|
2
2
|
export * from './ChainFork/index.ts'
|
|
3
3
|
export * from './ChainIdentity.ts'
|
|
4
|
+
export * from './ChainQualification.ts'
|
|
4
5
|
export * from './ChainStore.ts'
|
|
5
6
|
export * from './PayloadBundle/index.ts'
|
|
6
7
|
export * from './PayloadMap.ts'
|
|
7
8
|
export * from './Position.ts'
|
|
8
9
|
export * from './Provider.ts'
|
|
9
|
-
export * from './Qualified.ts'
|
|
10
10
|
export * from './RecordKeyType.ts'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './range/index.ts'
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
StepIdentity,
|
|
3
|
+
XL1BlockRange,
|
|
4
|
+
} from '@xyo-network/xl1-protocol'
|
|
5
|
+
import { asXL1BlockNumber, StepSizes } from '@xyo-network/xl1-protocol'
|
|
6
|
+
|
|
7
|
+
export function blockRangeSteps(range: XL1BlockRange, steps: number[]): StepIdentity[] {
|
|
8
|
+
const result: StepIdentity[] = []
|
|
9
|
+
for (const step of steps) {
|
|
10
|
+
const stepSize = StepSizes[step]
|
|
11
|
+
// we add stepSize twice to get to the start of the next full step
|
|
12
|
+
const startOfFirstStepCandidate = range[0] - (range[0] % stepSize) + stepSize
|
|
13
|
+
const startOfFirstStep = asXL1BlockNumber(
|
|
14
|
+
startOfFirstStepCandidate,
|
|
15
|
+
{ name: 'blockRangeSteps' },
|
|
16
|
+
)
|
|
17
|
+
for (let block = startOfFirstStep; block <= range[1]; block = asXL1BlockNumber(block + stepSize, { name: 'blockRangeSteps' })) {
|
|
18
|
+
result.push({ step, block })
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return result
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './blockRangeSteps.ts'
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Hash } from '@xylabs/sdk-js'
|
|
2
|
+
import type { SignedHydratedBlockWithHashMeta } from '@xyo-network/xl1-protocol'
|
|
3
|
+
|
|
4
|
+
import type { BlockViewer } from '../../viewers/index.ts'
|
|
5
|
+
|
|
6
|
+
export async function getWindowedChain(blockViewer: BlockViewer, maxWindowSize: number, previousChain: SignedHydratedBlockWithHashMeta[] = []) {
|
|
7
|
+
const newBlocks: SignedHydratedBlockWithHashMeta[] = []
|
|
8
|
+
let currentBlock: SignedHydratedBlockWithHashMeta | null = await blockViewer.currentBlock()
|
|
9
|
+
console.log('[getWindowedChain] Current Block:', currentBlock?.[0]._hash)
|
|
10
|
+
const head = currentBlock
|
|
11
|
+
while (currentBlock !== null && currentBlock[0].block >= head[0].block) {
|
|
12
|
+
newBlocks.unshift(currentBlock)
|
|
13
|
+
const previousBlockHash: Hash | null = currentBlock[0].previous
|
|
14
|
+
currentBlock = (previousBlockHash === null ? null : await blockViewer.blockByHash(previousBlockHash))
|
|
15
|
+
}
|
|
16
|
+
const newChain = [...previousChain, ...newBlocks].slice(-maxWindowSize)
|
|
17
|
+
while (newChain.length > 0 && newChain.length < maxWindowSize && newChain[0][0].previous !== null) {
|
|
18
|
+
const block = await blockViewer.blockByHash(newChain[0][0].previous!)
|
|
19
|
+
if (block === null) break
|
|
20
|
+
newChain.unshift(block)
|
|
21
|
+
}
|
|
22
|
+
return newChain
|
|
23
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/sdk-js'
|
|
2
|
+
import {
|
|
3
|
+
assertEx, exists, toAddress,
|
|
4
|
+
} from '@xylabs/sdk-js'
|
|
5
|
+
import type { StepIdentity } from '@xyo-network/xl1-protocol'
|
|
6
|
+
import {
|
|
7
|
+
asTransfer, isTransfer, XYO_STEP_REWARD_ADDRESS,
|
|
8
|
+
} from '@xyo-network/xl1-protocol'
|
|
9
|
+
|
|
10
|
+
import type { ChainContextRead } from '../../../model/index.ts'
|
|
11
|
+
import { mergeTransfers } from '../../payload/index.ts'
|
|
12
|
+
import { stepTransferIndex } from '../../step/index.ts'
|
|
13
|
+
import { stepRewardBlock } from './stepRewardBlock.ts'
|
|
14
|
+
|
|
15
|
+
export async function chainStepRewardAddress(context: ChainContextRead, { block, step }: StepIdentity): Promise<Address> {
|
|
16
|
+
const hydratedBlock = await stepRewardBlock(context, { block, step })
|
|
17
|
+
const [transferIndex, transferCount] = stepTransferIndex(block, step)
|
|
18
|
+
const [blockBw, payloads] = hydratedBlock
|
|
19
|
+
|
|
20
|
+
const transfersFromPool = payloads.filter(isTransfer).map(p => asTransfer(p)).filter(exists).filter(t => t.from === XYO_STEP_REWARD_ADDRESS)
|
|
21
|
+
const fromEntries = Object.entries(mergeTransfers(transfersFromPool)[XYO_STEP_REWARD_ADDRESS])
|
|
22
|
+
const sortedTransferAmounts = (fromEntries).toSorted(([,a], [,b]) => a > b ? -1 : a < b ? 1 : 0)
|
|
23
|
+
assertEx(
|
|
24
|
+
sortedTransferAmounts.length === transferCount,
|
|
25
|
+
() => `Step Transfers mismatch ${block} (${blockBw._hash}) [${sortedTransferAmounts.length} - ${transferCount}]`,
|
|
26
|
+
)
|
|
27
|
+
return toAddress(sortedTransferAmounts[transferIndex][0])
|
|
28
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { assertEx } from '@xylabs/sdk-js'
|
|
2
|
+
import type { HydratedBlockWithHashMeta, StepIdentity } from '@xyo-network/xl1-protocol'
|
|
3
|
+
import { StepSizes } from '@xyo-network/xl1-protocol'
|
|
4
|
+
|
|
5
|
+
import type { ChainContextRead } from '../../../model/index.ts'
|
|
6
|
+
import { hydratedBlockByNumber } from '../../state/index.ts'
|
|
7
|
+
|
|
8
|
+
export async function stepRewardBlock(context: ChainContextRead, { block, step }: StepIdentity): Promise<HydratedBlockWithHashMeta> {
|
|
9
|
+
assertEx((block % StepSizes[step]) === 0, () => `Block must be the first block of the step [${StepSizes[step]}], got ${block}`)
|
|
10
|
+
return assertEx(await hydratedBlockByNumber(context, block), () => `Could not find block for block number ${block}`)
|
|
11
|
+
}
|