@xyo-network/xl1-protocol 1.3.8 → 1.3.9
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/README.md +58 -21
- package/dist/neutral/index.mjs +216 -101
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/node/index.mjs +225 -0
- package/dist/node/index.mjs.map +1 -0
- package/dist/types/Addressable.d.ts +5 -0
- package/dist/types/Addressable.d.ts.map +1 -0
- package/dist/types/ChainIterator.d.ts +29 -0
- package/dist/types/ChainIterator.d.ts.map +1 -0
- package/dist/types/ChainIteratorEventData.d.ts +11 -0
- package/dist/types/ChainIteratorEventData.d.ts.map +1 -0
- package/dist/types/OpenTelemetryProviders.d.ts +6 -0
- package/dist/types/OpenTelemetryProviders.d.ts.map +1 -0
- package/dist/types/chain/ChainServiceCollection.d.ts +35 -0
- package/dist/types/chain/ChainServiceCollection.d.ts.map +1 -0
- package/dist/types/chain/Initializable.d.ts +3 -0
- package/dist/types/chain/Initializable.d.ts.map +1 -0
- package/dist/types/chain/index.d.ts +3 -0
- package/dist/types/chain/index.d.ts.map +1 -0
- package/dist/types/ethereum.d.ts +11 -0
- package/dist/types/ethereum.d.ts.map +1 -0
- package/dist/types/index.d.ts +13 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/instances/BoundWitness.d.ts +9 -0
- package/dist/types/instances/BoundWitness.d.ts.map +1 -0
- package/dist/types/instances/Data.d.ts +4 -0
- package/dist/types/instances/Data.d.ts.map +1 -0
- package/dist/types/instances/Fees.d.ts +8 -0
- package/dist/types/instances/Fees.d.ts.map +1 -0
- package/dist/types/instances/HydratedBoundWitness.d.ts +10 -0
- package/dist/types/instances/HydratedBoundWitness.d.ts.map +1 -0
- package/dist/types/instances/Object.d.ts +5 -0
- package/dist/types/instances/Object.d.ts.map +1 -0
- package/dist/types/instances/Payload.d.ts +6 -0
- package/dist/types/instances/Payload.d.ts.map +1 -0
- package/dist/types/instances/Signature.d.ts +8 -0
- package/dist/types/instances/Signature.d.ts.map +1 -0
- package/dist/types/instances/block/BlockFields.d.ts +9 -0
- package/dist/types/instances/block/BlockFields.d.ts.map +1 -0
- package/dist/types/instances/block/HydratedBlock.d.ts +8 -0
- package/dist/types/instances/block/HydratedBlock.d.ts.map +1 -0
- package/dist/types/instances/block/SignedHydratedBlock.d.ts +6 -0
- package/dist/types/instances/block/SignedHydratedBlock.d.ts.map +1 -0
- package/dist/types/instances/block/index.d.ts +3 -0
- package/dist/types/instances/block/index.d.ts.map +1 -0
- package/dist/types/instances/index.d.ts +10 -0
- package/dist/types/instances/index.d.ts.map +1 -0
- package/dist/types/instances/modifiers/Signed.d.ts +7 -0
- package/dist/types/instances/modifiers/Signed.d.ts.map +1 -0
- package/dist/types/instances/modifiers/Validatable.d.ts +5 -0
- package/dist/types/instances/modifiers/Validatable.d.ts.map +1 -0
- package/dist/types/instances/modifiers/index.d.ts +3 -0
- package/dist/types/instances/modifiers/index.d.ts.map +1 -0
- package/dist/types/instances/transaction/HydratedTransaction.d.ts +6 -0
- package/dist/types/instances/transaction/HydratedTransaction.d.ts.map +1 -0
- package/dist/types/instances/transaction/SignedHydratedTransaction.d.ts +6 -0
- package/dist/types/instances/transaction/SignedHydratedTransaction.d.ts.map +1 -0
- package/dist/types/instances/transaction/TransactionFields.d.ts +9 -0
- package/dist/types/instances/transaction/TransactionFields.d.ts.map +1 -0
- package/dist/types/instances/transaction/index.d.ts +3 -0
- package/dist/types/instances/transaction/index.d.ts.map +1 -0
- package/dist/types/payload/elevatable/ChainStakeIntent.d.ts +17 -0
- package/dist/types/payload/elevatable/ChainStakeIntent.d.ts.map +1 -0
- package/dist/types/payload/elevatable/Executable.d.ts +14 -0
- package/dist/types/payload/elevatable/Executable.d.ts.map +1 -0
- package/dist/types/payload/elevatable/Hash.d.ts +19 -0
- package/dist/types/payload/elevatable/Hash.d.ts.map +1 -0
- package/dist/types/payload/elevatable/TransferPayload.d.ts +17 -0
- package/dist/types/payload/elevatable/TransferPayload.d.ts.map +1 -0
- package/dist/types/payload/elevatable/index.d.ts +5 -0
- package/dist/types/payload/elevatable/index.d.ts.map +1 -0
- package/dist/types/payload/index.d.ts +2 -0
- package/dist/types/payload/index.d.ts.map +1 -0
- package/dist/types/protocol/AllowedBlockPayload.d.ts +11 -0
- package/dist/types/protocol/AllowedBlockPayload.d.ts.map +1 -0
- package/dist/types/protocol/BlockBoundWitness.d.ts +34 -0
- package/dist/types/protocol/BlockBoundWitness.d.ts.map +1 -0
- package/dist/types/protocol/BlockDuration.d.ts +23 -0
- package/dist/types/protocol/BlockDuration.d.ts.map +1 -0
- package/dist/types/protocol/BlockNumber.d.ts +37 -0
- package/dist/types/protocol/BlockNumber.d.ts.map +1 -0
- package/dist/types/protocol/ChainAnalyzer.d.ts +9 -0
- package/dist/types/protocol/ChainAnalyzer.d.ts.map +1 -0
- package/dist/types/protocol/ChainReference.d.ts +11 -0
- package/dist/types/protocol/ChainReference.d.ts.map +1 -0
- package/dist/types/protocol/HydratedBlock.d.ts +6 -0
- package/dist/types/protocol/HydratedBlock.d.ts.map +1 -0
- package/dist/types/protocol/HydratedTransaction.d.ts +9 -0
- package/dist/types/protocol/HydratedTransaction.d.ts.map +1 -0
- package/dist/types/protocol/Issuer.d.ts +5 -0
- package/dist/types/protocol/Issuer.d.ts.map +1 -0
- package/dist/types/protocol/Steps.d.ts +2 -0
- package/dist/types/protocol/Steps.d.ts.map +1 -0
- package/dist/types/protocol/TransactionBoundWitness.d.ts +26 -0
- package/dist/types/protocol/TransactionBoundWitness.d.ts.map +1 -0
- package/dist/types/protocol/TransactionFeesFields.d.ts +35 -0
- package/dist/types/protocol/TransactionFeesFields.d.ts.map +1 -0
- package/dist/types/protocol/index.d.ts +13 -0
- package/dist/types/protocol/index.d.ts.map +1 -0
- package/dist/types/provider/XyoProvider.d.ts +18 -0
- package/dist/types/provider/XyoProvider.d.ts.map +1 -0
- package/dist/types/provider/XyoRunner.d.ts +7 -0
- package/dist/types/provider/XyoRunner.d.ts.map +1 -0
- package/dist/types/provider/XyoSigner.d.ts +10 -0
- package/dist/types/provider/XyoSigner.d.ts.map +1 -0
- package/dist/types/provider/XyoStorage.d.ts +16 -0
- package/dist/types/provider/XyoStorage.d.ts.map +1 -0
- package/dist/types/provider/XyoViewer.d.ts +17 -0
- package/dist/types/provider/XyoViewer.d.ts.map +1 -0
- package/dist/types/provider/XyoWallet.d.ts +13 -0
- package/dist/types/provider/XyoWallet.d.ts.map +1 -0
- package/dist/types/provider/index.d.ts +7 -0
- package/dist/types/provider/index.d.ts.map +1 -0
- package/dist/types/repository/Repository.d.ts +10 -0
- package/dist/types/repository/Repository.d.ts.map +1 -0
- package/dist/types/repository/TransactionReadRepository.d.ts +5 -0
- package/dist/types/repository/TransactionReadRepository.d.ts.map +1 -0
- package/dist/types/repository/TransactionRepository.d.ts +10 -0
- package/dist/types/repository/TransactionRepository.d.ts.map +1 -0
- package/dist/types/repository/TransactionRepositoryIterator.d.ts +5 -0
- package/dist/types/repository/TransactionRepositoryIterator.d.ts.map +1 -0
- package/dist/types/repository/TransactionWriteRepository.d.ts +5 -0
- package/dist/types/repository/TransactionWriteRepository.d.ts.map +1 -0
- package/dist/types/repository/index.d.ts +6 -0
- package/dist/types/repository/index.d.ts.map +1 -0
- package/dist/types/services/AccountBalanceService.d.ts +7 -0
- package/dist/types/services/AccountBalanceService.d.ts.map +1 -0
- package/dist/types/services/BlockProducer.d.ts +7 -0
- package/dist/types/services/BlockProducer.d.ts.map +1 -0
- package/dist/types/services/BlockReward.d.ts +6 -0
- package/dist/types/services/BlockReward.d.ts.map +1 -0
- package/dist/types/services/Chain/ChainContractViewer.d.ts +12 -0
- package/dist/types/services/Chain/ChainContractViewer.d.ts.map +1 -0
- package/dist/types/services/Chain/ChainIdentification.d.ts +14 -0
- package/dist/types/services/Chain/ChainIdentification.d.ts.map +1 -0
- package/dist/types/services/Chain/ChainInformation.d.ts +12 -0
- package/dist/types/services/Chain/ChainInformation.d.ts.map +1 -0
- package/dist/types/services/Chain/ChainService.d.ts +8 -0
- package/dist/types/services/Chain/ChainService.d.ts.map +1 -0
- package/dist/types/services/Chain/ChainStakeViewer.d.ts +10 -0
- package/dist/types/services/Chain/ChainStakeViewer.d.ts.map +1 -0
- package/dist/types/services/Chain/ChainStaker.d.ts +6 -0
- package/dist/types/services/Chain/ChainStaker.d.ts.map +1 -0
- package/dist/types/services/Chain/index.d.ts +7 -0
- package/dist/types/services/Chain/index.d.ts.map +1 -0
- package/dist/types/services/Election.d.ts +11 -0
- package/dist/types/services/Election.d.ts.map +1 -0
- package/dist/types/services/Params.d.ts +9 -0
- package/dist/types/services/Params.d.ts.map +1 -0
- package/dist/types/services/PendingTransactionsService.d.ts +7 -0
- package/dist/types/services/PendingTransactionsService.d.ts.map +1 -0
- package/dist/types/services/Service.d.ts +9 -0
- package/dist/types/services/Service.d.ts.map +1 -0
- package/dist/types/services/index.d.ts +10 -0
- package/dist/types/services/index.d.ts.map +1 -0
- package/dist/types/services/stakeIntent/ChainIndexingServiceStateSchema.d.ts +39 -0
- package/dist/types/services/stakeIntent/ChainIndexingServiceStateSchema.d.ts.map +1 -0
- package/dist/types/services/stakeIntent/StakeIntentService.d.ts +24 -0
- package/dist/types/services/stakeIntent/StakeIntentService.d.ts.map +1 -0
- package/dist/types/services/stakeIntent/index.d.ts +3 -0
- package/dist/types/services/stakeIntent/index.d.ts.map +1 -0
- package/dist/types/validation/block/BlockValidationFunction.d.ts +5 -0
- package/dist/types/validation/block/BlockValidationFunction.d.ts.map +1 -0
- package/dist/types/validation/block/HydratedBlockStateValidationFunction.d.ts +13 -0
- package/dist/types/validation/block/HydratedBlockStateValidationFunction.d.ts.map +1 -0
- package/dist/types/validation/block/HydratedBlockValidationFunction.d.ts +11 -0
- package/dist/types/validation/block/HydratedBlockValidationFunction.d.ts.map +1 -0
- package/dist/types/validation/block/index.d.ts +4 -0
- package/dist/types/validation/block/index.d.ts.map +1 -0
- package/dist/types/validation/boundwitness/BoundWitnessValidationFunction.d.ts +4 -0
- package/dist/types/validation/boundwitness/BoundWitnessValidationFunction.d.ts.map +1 -0
- package/dist/types/validation/boundwitness/HydratedBoundWitnessValidationFunction.d.ts +6 -0
- package/dist/types/validation/boundwitness/HydratedBoundWitnessValidationFunction.d.ts.map +1 -0
- package/dist/types/validation/boundwitness/index.d.ts +3 -0
- package/dist/types/validation/boundwitness/index.d.ts.map +1 -0
- package/dist/types/validation/index.d.ts +5 -0
- package/dist/types/validation/index.d.ts.map +1 -0
- package/dist/types/validation/payload/InBlockPayloadValidationFunction.d.ts +5 -0
- package/dist/types/validation/payload/InBlockPayloadValidationFunction.d.ts.map +1 -0
- package/dist/types/validation/payload/index.d.ts +2 -0
- package/dist/types/validation/payload/index.d.ts.map +1 -0
- package/dist/types/validation/transaction/HydratedTransactionStateValidationFunction.d.ts +13 -0
- package/dist/types/validation/transaction/HydratedTransactionStateValidationFunction.d.ts.map +1 -0
- package/dist/types/validation/transaction/HydratedTransactionValidationFunction.d.ts +12 -0
- package/dist/types/validation/transaction/HydratedTransactionValidationFunction.d.ts.map +1 -0
- package/dist/types/validation/transaction/index.d.ts +3 -0
- package/dist/types/validation/transaction/index.d.ts.map +1 -0
- package/documents/proof-of-perfect/proof-of-perfect-draft.log +741 -0
- package/documents/proof-of-perfect/proof-of-perfect-draft.pdf +0 -0
- package/documents/proof-of-perfect/proof-of-perfect-draft.tex +311 -0
- package/documents/xyol1-white-paper/white-paper-draft.log +547 -0
- package/documents/xyol1-white-paper/white-paper-draft.pdf +0 -0
- package/documents/xyol1-white-paper/white-paper-draft.tex +799 -0
- package/eslint.config.mjs +35 -0
- package/knip.config.ts +1 -1
- package/knip.log +491 -0
- package/package.json +31 -18
- package/src/Addressable.ts +6 -0
- package/src/ChainIterator.ts +29 -0
- package/src/ChainIteratorEventData.ts +11 -0
- package/src/OpenTelemetryProviders.ts +6 -0
- package/src/chain/ChainServiceCollection.ts +41 -0
- package/src/chain/Initializable.ts +3 -0
- package/src/chain/index.ts +2 -0
- package/src/ethereum.ts +26 -0
- package/src/index.ts +13 -1
- package/src/instances/BoundWitness.ts +13 -0
- package/src/instances/Data.ts +3 -0
- package/src/instances/Fees.ts +8 -0
- package/src/instances/HydratedBoundWitness.ts +15 -0
- package/src/instances/Object.ts +5 -0
- package/src/instances/Payload.ts +6 -0
- package/src/instances/Signature.ts +11 -0
- package/src/instances/block/BlockFields.ts +13 -0
- package/src/instances/block/HydratedBlock.ts +9 -0
- package/src/instances/block/SignedHydratedBlock.ts +5 -0
- package/src/instances/block/index.ts +2 -0
- package/src/instances/index.ts +9 -0
- package/src/instances/modifiers/Signed.ts +8 -0
- package/src/instances/modifiers/Validatable.ts +5 -0
- package/src/instances/modifiers/index.ts +2 -0
- package/src/instances/transaction/HydratedTransaction.ts +8 -0
- package/src/instances/transaction/SignedHydratedTransaction.ts +7 -0
- package/src/instances/transaction/TransactionFields.ts +12 -0
- package/src/instances/transaction/index.ts +2 -0
- package/src/payload/elevatable/ChainStakeIntent.ts +32 -0
- package/src/payload/elevatable/Executable.ts +29 -0
- package/src/payload/elevatable/Hash.ts +19 -0
- package/src/payload/elevatable/TransferPayload.ts +26 -0
- package/src/payload/elevatable/index.ts +4 -0
- package/src/payload/index.ts +1 -0
- package/src/protocol/AllowedBlockPayload.ts +29 -0
- package/src/protocol/BlockBoundWitness.ts +47 -0
- package/src/protocol/BlockDuration.ts +23 -0
- package/src/protocol/BlockNumber.ts +39 -0
- package/src/protocol/ChainAnalyzer.ts +10 -0
- package/src/protocol/ChainReference.ts +11 -0
- package/src/protocol/HydratedBlock.ts +8 -0
- package/src/protocol/HydratedTransaction.ts +19 -0
- package/src/protocol/Issuer.ts +5 -0
- package/src/protocol/Steps.ts +1 -0
- package/src/protocol/TransactionBoundWitness.ts +51 -0
- package/src/protocol/TransactionFeesFields.ts +38 -0
- package/src/protocol/index.ts +12 -0
- package/src/provider/XyoProvider.ts +29 -0
- package/src/provider/XyoRunner.ts +8 -0
- package/src/provider/XyoSigner.ts +21 -0
- package/src/provider/XyoStorage.ts +17 -0
- package/src/provider/XyoViewer.ts +18 -0
- package/src/provider/XyoWallet.ts +15 -0
- package/src/provider/index.ts +6 -0
- package/src/repository/Repository.ts +11 -0
- package/src/repository/TransactionReadRepository.ts +4 -0
- package/src/repository/TransactionRepository.ts +9 -0
- package/src/repository/TransactionRepositoryIterator.ts +4 -0
- package/src/repository/TransactionWriteRepository.ts +4 -0
- package/src/repository/index.ts +5 -0
- package/src/services/AccountBalanceService.ts +9 -0
- package/src/services/BlockProducer.ts +7 -0
- package/src/services/BlockReward.ts +7 -0
- package/src/services/Chain/ChainContractViewer.ts +12 -0
- package/src/services/Chain/ChainIdentification.ts +17 -0
- package/src/services/Chain/ChainInformation.ts +20 -0
- package/src/services/Chain/ChainService.ts +7 -0
- package/src/services/Chain/ChainStakeViewer.ts +10 -0
- package/src/services/Chain/ChainStaker.ts +5 -0
- package/src/services/Chain/index.ts +6 -0
- package/src/services/Election.ts +14 -0
- package/src/services/Params.ts +11 -0
- package/src/services/PendingTransactionsService.ts +8 -0
- package/src/services/Service.ts +10 -0
- package/src/services/index.ts +9 -0
- package/src/services/stakeIntent/ChainIndexingServiceStateSchema.ts +46 -0
- package/src/services/stakeIntent/StakeIntentService.ts +28 -0
- package/src/services/stakeIntent/index.ts +2 -0
- package/src/validation/block/BlockValidationFunction.ts +9 -0
- package/src/validation/block/HydratedBlockStateValidationFunction.ts +18 -0
- package/src/validation/block/HydratedBlockValidationFunction.ts +15 -0
- package/src/validation/block/index.ts +3 -0
- package/src/validation/boundwitness/BoundWitnessValidationFunction.ts +6 -0
- package/src/validation/boundwitness/HydratedBoundWitnessValidationFunction.ts +10 -0
- package/src/validation/boundwitness/index.ts +2 -0
- package/src/validation/index.ts +4 -0
- package/src/validation/payload/InBlockPayloadValidationFunction.ts +8 -0
- package/src/validation/payload/index.ts +1 -0
- package/src/validation/transaction/HydratedTransactionStateValidationFunction.ts +18 -0
- package/src/validation/transaction/HydratedTransactionValidationFunction.ts +16 -0
- package/src/validation/transaction/index.ts +2 -0
- package/typedoc.json +5 -0
- package/vite.config.ts +30 -0
- package/vitest.config.ts +14 -0
- package/vitest.teardown.ts +10 -0
- package/vitest.workspace.ts +5 -0
- package/xy.config.ts +2 -2
- package/dist/types/transaction/buildTransaction.d.ts +0 -7
- package/dist/types/transaction/buildTransaction.d.ts.map +0 -1
- package/dist/types/transaction/hydrateTransaction.d.ts +0 -11
- package/dist/types/transaction/hydrateTransaction.d.ts.map +0 -1
- package/dist/types/transaction/index.d.ts +0 -3
- package/dist/types/transaction/index.d.ts.map +0 -1
- package/src/transaction/buildTransaction.ts +0 -61
- package/src/transaction/hydrateTransaction.ts +0 -73
- package/src/transaction/index.ts +0 -2
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { BaseParams } from '@xylabs/base'
|
|
2
|
+
import type { Hash } from '@xylabs/hex'
|
|
3
|
+
import type { ArchivistInstance } from '@xyo-network/archivist-model'
|
|
4
|
+
import type { BaseEmitter } from '@xyo-network/module-event-emitter'
|
|
5
|
+
|
|
6
|
+
import type { ChainIteratorEventData } from './ChainIteratorEventData.ts'
|
|
7
|
+
import type { BlockBoundWitness } from './protocol/index.ts'
|
|
8
|
+
import type { IterableRepository, ReadRepository } from './repository/index.ts'
|
|
9
|
+
import type { BaseServiceParams, ChainIdentification } from './services/index.ts'
|
|
10
|
+
|
|
11
|
+
export interface ChainIterator<TKey, THead> extends ReadRepository<TKey, BlockBoundWitness>, IterableRepository<TKey, BlockBoundWitness> {
|
|
12
|
+
chainIdentification: ChainIdentification
|
|
13
|
+
head(): Promise<THead>
|
|
14
|
+
previous(cursor?: TKey | undefined, limit?: number): Promise<BlockBoundWitness[]>
|
|
15
|
+
updateHead(head: THead): Promise<void>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface EventingChainIterator<TKey, THead> extends ChainIterator<TKey, THead>, BaseEmitter<BaseParams, ChainIteratorEventData> {}
|
|
19
|
+
|
|
20
|
+
export interface ChainBlockNumberIterator extends ChainIterator<number, BlockBoundWitness> {}
|
|
21
|
+
export interface EventingChainBlockNumberIterator extends EventingChainIterator<number, BlockBoundWitness> {}
|
|
22
|
+
|
|
23
|
+
export interface ChainHashIterator extends ChainIterator<Hash, Hash> {}
|
|
24
|
+
export interface EventingChainHashIterator extends EventingChainIterator<Hash, Hash> {}
|
|
25
|
+
|
|
26
|
+
export interface XyoChainIteratorParams extends BaseServiceParams {
|
|
27
|
+
chainArchivist: ArchivistInstance
|
|
28
|
+
head: BlockBoundWitness
|
|
29
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { EventData } from '@xyo-network/module-events'
|
|
2
|
+
|
|
3
|
+
import type { BlockBoundWitness } from './protocol/index.ts'
|
|
4
|
+
|
|
5
|
+
export type HeadEventArgs = { blocks: [BlockBoundWitness] }
|
|
6
|
+
|
|
7
|
+
export interface HeadEventData extends EventData {
|
|
8
|
+
headUpdated: HeadEventArgs
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ChainIteratorEventData extends HeadEventData {}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ArchivistInstance, WriteArchivist } from '@xyo-network/archivist-model'
|
|
2
|
+
import type { WalletInstance } from '@xyo-network/wallet-model'
|
|
3
|
+
|
|
4
|
+
import type { EventingChainBlockNumberIterator } from '../ChainIterator.ts'
|
|
5
|
+
import type {
|
|
6
|
+
AccountBalanceService, BlockProducer,
|
|
7
|
+
BlockRewardService, ChainContractViewer, ChainInformation, ChainStaker, ChainStakeViewer, ElectionService,
|
|
8
|
+
StakeIntentService,
|
|
9
|
+
} from '../services/index.ts'
|
|
10
|
+
|
|
11
|
+
export interface ChainServiceCollection {
|
|
12
|
+
|
|
13
|
+
account: WalletInstance
|
|
14
|
+
/**
|
|
15
|
+
* Services for working with account balances
|
|
16
|
+
*/
|
|
17
|
+
balanceService: AccountBalanceService
|
|
18
|
+
/**
|
|
19
|
+
* The archivist which the chain data is stored in
|
|
20
|
+
*/
|
|
21
|
+
chainArchivist: ArchivistInstance
|
|
22
|
+
chainContractViewer: ChainContractViewer
|
|
23
|
+
/**
|
|
24
|
+
* Hydrated information about the chain
|
|
25
|
+
*/
|
|
26
|
+
chainInformation: ChainInformation
|
|
27
|
+
/**
|
|
28
|
+
* The chain iterator
|
|
29
|
+
*/
|
|
30
|
+
chainIterator?: EventingChainBlockNumberIterator
|
|
31
|
+
chainStakeViewer: ChainStakeViewer
|
|
32
|
+
chainStaker: ChainStaker
|
|
33
|
+
chainSubmissionsArchivistWrite: WriteArchivist
|
|
34
|
+
electionService: ElectionService
|
|
35
|
+
producer: BlockProducer
|
|
36
|
+
rewardService: BlockRewardService
|
|
37
|
+
/**
|
|
38
|
+
* Services for working with staked intents
|
|
39
|
+
*/
|
|
40
|
+
stakeIntentService: StakeIntentService
|
|
41
|
+
}
|
package/src/ethereum.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getAddress } from '@ethersproject/address'
|
|
2
|
+
import type { Hex } from '@xylabs/hex'
|
|
3
|
+
import { toHex } from '@xylabs/hex'
|
|
4
|
+
import type { AccountInstance } from '@xyo-network/account-model'
|
|
5
|
+
import { parseUnits } from 'ethers/utils'
|
|
6
|
+
|
|
7
|
+
export interface GasConfig {
|
|
8
|
+
gasLimit?: number
|
|
9
|
+
gasPrice?: bigint
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const getDefaultGasConfig = (): GasConfig => {
|
|
13
|
+
return {
|
|
14
|
+
gasLimit: 2_000_000, // Set the gas limit
|
|
15
|
+
gasPrice: parseUnits('100', 'gwei'),
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type EthAddress = Hex
|
|
20
|
+
|
|
21
|
+
export const ETH_ZERO_ADDRESS: EthAddress = '0x0000000000000000000000000000000000000000' as const
|
|
22
|
+
|
|
23
|
+
export const toEthAddress = (value: bigint | string | AccountInstance): EthAddress => {
|
|
24
|
+
const address = (typeof value === 'object') ? value.address : value
|
|
25
|
+
return getAddress(toHex(address, { prefix: true, bitLength: 160 })) as EthAddress
|
|
26
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1 +1,13 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './Addressable.ts'
|
|
2
|
+
export * from './chain/index.ts'
|
|
3
|
+
export * from './ChainIterator.ts'
|
|
4
|
+
export * from './ChainIteratorEventData.ts'
|
|
5
|
+
export * from './ethereum.ts'
|
|
6
|
+
export * from './instances/index.ts'
|
|
7
|
+
export * from './OpenTelemetryProviders.ts'
|
|
8
|
+
export * from './payload/index.ts'
|
|
9
|
+
export * from './protocol/index.ts'
|
|
10
|
+
export * from './provider/index.ts'
|
|
11
|
+
export * from './repository/index.ts'
|
|
12
|
+
export * from './services/index.ts'
|
|
13
|
+
export * from './validation/index.ts'
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BoundWitness } from '@xyo-network/boundwitness-model'
|
|
2
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
3
|
+
|
|
4
|
+
import type { PayloadInstance } from './Payload.ts'
|
|
5
|
+
|
|
6
|
+
export interface BoundWitnessInstance<TBoundWitness extends BoundWitness = BoundWitness,
|
|
7
|
+
TPayload extends Payload = Payload> extends PayloadInstance<TBoundWitness> {
|
|
8
|
+
|
|
9
|
+
payloadCount: number
|
|
10
|
+
payloads: PayloadInstance<TPayload>[]
|
|
11
|
+
|
|
12
|
+
payload(index: number): PayloadInstance<TPayload> | undefined
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { HydratedBoundWitness } from '@xyo-network/archivist-model'
|
|
2
|
+
|
|
3
|
+
import type { DataInstance } from './Data.ts'
|
|
4
|
+
import type { ValidatableInstance } from './modifiers/Validatable.ts'
|
|
5
|
+
|
|
6
|
+
export interface HydratedBoundWitnessInstance<T extends HydratedBoundWitness = HydratedBoundWitness>
|
|
7
|
+
extends ValidatableInstance, DataInstance<T> {
|
|
8
|
+
|
|
9
|
+
boundWitness: T[0]
|
|
10
|
+
|
|
11
|
+
payloadCount: number
|
|
12
|
+
payloads: T[1][number][]
|
|
13
|
+
|
|
14
|
+
payload(index: number): T[1][number] | undefined
|
|
15
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
2
|
+
|
|
3
|
+
import type { ValidatableInstance } from './modifiers/Validatable.ts'
|
|
4
|
+
import type { ObjectInstance } from './Object.ts'
|
|
5
|
+
|
|
6
|
+
export interface PayloadInstance<TPayload extends Payload = Payload> extends ObjectInstance<TPayload>, ValidatableInstance {}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface BlockFieldsInstance<TTransactionResult> {
|
|
2
|
+
privatePayloadCount: number
|
|
3
|
+
|
|
4
|
+
publicPayloadCount: number
|
|
5
|
+
|
|
6
|
+
reward: bigint
|
|
7
|
+
|
|
8
|
+
transactionCount: number
|
|
9
|
+
|
|
10
|
+
transactions: TTransactionResult[]
|
|
11
|
+
|
|
12
|
+
transaction(index: number): TTransactionResult | undefined
|
|
13
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { HydratedBlock } from '../../protocol/index.ts'
|
|
2
|
+
import type { HydratedBoundWitnessInstance } from '../HydratedBoundWitness.ts'
|
|
3
|
+
import type { HydratedTransactionInstance } from '../transaction/index.ts'
|
|
4
|
+
import type { BlockFieldsInstance } from './BlockFields.ts'
|
|
5
|
+
|
|
6
|
+
export interface HydratedBlockInstance<T extends HydratedBlock = HydratedBlock> extends
|
|
7
|
+
BlockFieldsInstance<HydratedTransactionInstance>, HydratedBoundWitnessInstance<T> {
|
|
8
|
+
publicPayloads: T[1][number][]
|
|
9
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SignedHydratedBlock } from '../../protocol/index.ts'
|
|
2
|
+
import type { SignedInstance } from '../modifiers/Signed.ts'
|
|
3
|
+
import type { HydratedBlockInstance } from './HydratedBlock.ts'
|
|
4
|
+
|
|
5
|
+
export interface SignedHydratedBlockInstance<T extends SignedHydratedBlock = SignedHydratedBlock> extends HydratedBlockInstance<T>, SignedInstance {}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './block/index.ts'
|
|
2
|
+
export * from './BoundWitness.ts'
|
|
3
|
+
export * from './Data.ts'
|
|
4
|
+
export * from './Fees.ts'
|
|
5
|
+
export * from './modifiers/index.ts'
|
|
6
|
+
export * from './Object.ts'
|
|
7
|
+
export * from './Payload.ts'
|
|
8
|
+
export * from './Signature.ts'
|
|
9
|
+
export * from './transaction/index.ts'
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AllowedBlockPayload, HydratedTransaction } from '../../protocol/index.ts'
|
|
2
|
+
import type { HydratedBoundWitnessInstance } from '../HydratedBoundWitness.ts'
|
|
3
|
+
import type { TransactionFieldsInstance } from './TransactionFields.ts'
|
|
4
|
+
|
|
5
|
+
export interface HydratedTransactionInstance<T extends HydratedTransaction = HydratedTransaction,
|
|
6
|
+
TElevatedPayload extends AllowedBlockPayload = AllowedBlockPayload>
|
|
7
|
+
extends TransactionFieldsInstance<T[1][number] & TElevatedPayload>, HydratedBoundWitnessInstance<T> {
|
|
8
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AllowedBlockPayload, HydratedTransaction } from '../../protocol/index.ts'
|
|
2
|
+
import type { SignedInstance } from '../modifiers/Signed.ts'
|
|
3
|
+
import type { HydratedTransactionInstance } from './HydratedTransaction.ts'
|
|
4
|
+
|
|
5
|
+
export interface SignedHydratedTransactionInstance<T extends HydratedTransaction = HydratedTransaction,
|
|
6
|
+
TBlockPayload extends AllowedBlockPayload = AllowedBlockPayload> extends HydratedTransactionInstance<T, TBlockPayload>, SignedInstance {
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AllowedBlockPayload } from '../../protocol/index.ts'
|
|
2
|
+
import type { TransactionFeesInstance } from '../Fees.ts'
|
|
3
|
+
|
|
4
|
+
export interface TransactionFieldsInstance<TBlockPayload extends AllowedBlockPayload = AllowedBlockPayload> {
|
|
5
|
+
|
|
6
|
+
elevatedPayloadCount: number
|
|
7
|
+
elevatedPayloads: TBlockPayload[]
|
|
8
|
+
|
|
9
|
+
fees: TransactionFeesInstance
|
|
10
|
+
|
|
11
|
+
elevatedPayload(index: number): TBlockPayload | undefined
|
|
12
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AsObjectFactory } from '@xylabs/object'
|
|
2
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
3
|
+
import { isPayloadOfSchemaType } from '@xyo-network/payload-model'
|
|
4
|
+
|
|
5
|
+
import type { BlockDuration } from '../../protocol/BlockDuration.ts'
|
|
6
|
+
import type { FromFields } from './Executable.ts'
|
|
7
|
+
|
|
8
|
+
export const ChainStakeIntentSchema = 'network.xyo.chain.stake.intent' as const
|
|
9
|
+
export type ChainStakeIntentSchema = typeof ChainStakeIntentSchema
|
|
10
|
+
|
|
11
|
+
export type Intent = 'producer' // | 'bank'
|
|
12
|
+
|
|
13
|
+
export interface ChainStakeIntentFields extends BlockDuration, FromFields {
|
|
14
|
+
/*
|
|
15
|
+
* The intent of the staking
|
|
16
|
+
*/
|
|
17
|
+
intent: Intent
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type ChainStakeIntent = Payload<ChainStakeIntentFields, ChainStakeIntentSchema>
|
|
21
|
+
|
|
22
|
+
export const isChainStakeIntent = (x?: unknown | null): x is ChainStakeIntent => {
|
|
23
|
+
return isPayloadOfSchemaType<ChainStakeIntent>(ChainStakeIntentSchema)(x)
|
|
24
|
+
&& asNonNegativeInteger(x.nbf) !== undefined
|
|
25
|
+
&& asNonNegativeInteger(x.exp) !== undefined
|
|
26
|
+
}
|
|
27
|
+
export const asChainStakeIntent = AsObjectFactory.create(isChainStakeIntent)
|
|
28
|
+
export const asOptionalChainStakeIntent = AsObjectFactory.createOptional(isChainStakeIntent)
|
|
29
|
+
|
|
30
|
+
const asNonNegativeInteger = (num: number) => {
|
|
31
|
+
return (Number.isInteger(num) && num >= 0) ? num : undefined
|
|
32
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
|
+
import type { EmptyObject } from '@xylabs/object'
|
|
3
|
+
import { isAnyPayload } from '@xyo-network/payload-model'
|
|
4
|
+
|
|
5
|
+
export interface FromFields {
|
|
6
|
+
// the address that is treated as the source of this action
|
|
7
|
+
from: Address
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const hasFrom = (value: unknown): value is FromFields => {
|
|
11
|
+
return (value as FromFields).from !== undefined
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ExecutableFields {
|
|
15
|
+
script: string[]
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type Executable<T extends EmptyObject = EmptyObject> = T & ExecutableFields
|
|
19
|
+
export type OptionalExecutable<T extends EmptyObject = EmptyObject> = T & Partial<ExecutableFields>
|
|
20
|
+
|
|
21
|
+
export const isExecutable = <T extends EmptyObject>(value: T | undefined): value is Executable<T> => {
|
|
22
|
+
return isAnyPayload(value) && Array.isArray((value as unknown as ExecutableFields).script)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const asExecutable = <T extends EmptyObject>(value: T | undefined): Executable<T> | undefined => {
|
|
26
|
+
return isExecutable(value)
|
|
27
|
+
? value as unknown as Executable<T>
|
|
28
|
+
: undefined
|
|
29
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Hash } from '@xylabs/hex'
|
|
2
|
+
import { AsObjectFactory } from '@xylabs/object'
|
|
3
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
4
|
+
import { isPayloadOfSchemaType } from '@xyo-network/payload-model'
|
|
5
|
+
|
|
6
|
+
export const HashSchema = 'network.xyo.hash' as const
|
|
7
|
+
export type HashSchema = typeof HashSchema
|
|
8
|
+
|
|
9
|
+
export interface HashFields {
|
|
10
|
+
hash: Hash
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type HashPayload = Payload<HashFields, HashSchema>
|
|
14
|
+
|
|
15
|
+
export const isHashPayload = isPayloadOfSchemaType<HashPayload>(HashSchema)
|
|
16
|
+
|
|
17
|
+
export const asHashPayload = AsObjectFactory.create(isHashPayload)
|
|
18
|
+
export const asHashPayloadWithStorageMeta = AsObjectFactory.create(isHashPayload)
|
|
19
|
+
export const asOptionalHashPayload = AsObjectFactory.createOptional(isHashPayload)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Address,
|
|
3
|
+
Hex,
|
|
4
|
+
} from '@xylabs/hex'
|
|
5
|
+
import { AsObjectFactory } from '@xylabs/object'
|
|
6
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
7
|
+
import { isPayloadOfSchemaType } from '@xyo-network/payload-model'
|
|
8
|
+
|
|
9
|
+
import type { FromFields } from './Executable.ts'
|
|
10
|
+
|
|
11
|
+
export const TransferSchema = 'network.xyo.transfer' as const
|
|
12
|
+
export type TransferSchema = typeof TransferSchema
|
|
13
|
+
|
|
14
|
+
export interface TransferFields extends FromFields {
|
|
15
|
+
epoch: number
|
|
16
|
+
// the amount that is being sent to another address
|
|
17
|
+
transfers: Record<Address, Hex>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// if this payload is included in a boundwitness, it needs to be available for inspection to be included in block
|
|
21
|
+
export type Transfer = Payload<TransferFields, TransferSchema>
|
|
22
|
+
|
|
23
|
+
export const isTransfer = isPayloadOfSchemaType<Transfer>(TransferSchema)
|
|
24
|
+
|
|
25
|
+
export const asTransfer = AsObjectFactory.create(isTransfer)
|
|
26
|
+
export const asOptionalTransfer = AsObjectFactory.createOptional(isTransfer)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './elevatable/index.ts'
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BoundWitnessSchema } from '@xyo-network/boundwitness-model'
|
|
2
|
+
import type { Schema, WithStorageMeta } from '@xyo-network/payload-model'
|
|
3
|
+
import { isHashStorageMeta, isSchema } from '@xyo-network/payload-model'
|
|
4
|
+
import type { SchemaPayload } from '@xyo-network/schema-payload-plugin'
|
|
5
|
+
import { isSchemaPayload, SchemaSchema } from '@xyo-network/schema-payload-plugin'
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
ChainStakeIntent, HashPayload, Transfer,
|
|
9
|
+
} from '../payload/index.ts'
|
|
10
|
+
import {
|
|
11
|
+
ChainStakeIntentSchema, HashSchema, isChainStakeIntent, isHashPayload, isTransfer, TransferSchema,
|
|
12
|
+
} from '../payload/index.ts'
|
|
13
|
+
import { isTransactionBoundWitness, type TransactionBoundWitness } from './TransactionBoundWitness.ts'
|
|
14
|
+
|
|
15
|
+
export type AllowedBlockPayload = Transfer | ChainStakeIntent | SchemaPayload | TransactionBoundWitness | HashPayload
|
|
16
|
+
export const AllowedBlockPayloadSchemas: Schema[] = [TransferSchema, ChainStakeIntentSchema, SchemaSchema, BoundWitnessSchema, HashSchema]
|
|
17
|
+
export type AllowedBlockPayloadSchema = typeof AllowedBlockPayloadSchemas[number]
|
|
18
|
+
|
|
19
|
+
export const isAllowedBlockPayloadSchema = (value: unknown): value is AllowedBlockPayloadSchema => {
|
|
20
|
+
return isSchema(value) && AllowedBlockPayloadSchemas.includes(value)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const isAllowedBlockPayload = (value: unknown): value is AllowedBlockPayload => {
|
|
24
|
+
return isTransfer(value) || isChainStakeIntent(value) || isSchemaPayload(value) || isTransactionBoundWitness(value) || isHashPayload(value)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const isAllowedBlockPayloadWithHashStorageMeta = (value: unknown): value is WithStorageMeta<AllowedBlockPayload> => {
|
|
28
|
+
return isAllowedBlockPayload(value) && isHashStorageMeta(value)
|
|
29
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Address, Hash, Hex,
|
|
3
|
+
} from '@xylabs/hex'
|
|
4
|
+
import { isHex } from '@xylabs/hex'
|
|
5
|
+
import { AsObjectFactory } from '@xylabs/object'
|
|
6
|
+
import type { BoundWitness } from '@xyo-network/boundwitness-model'
|
|
7
|
+
import { isBoundWitness } from '@xyo-network/boundwitness-model'
|
|
8
|
+
import type { WithStorageMeta } from '@xyo-network/payload-model'
|
|
9
|
+
import { isStorageMeta } from '@xyo-network/payload-model'
|
|
10
|
+
|
|
11
|
+
export interface BlockBoundWitnessMeta {
|
|
12
|
+
$epoch: number
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface BlockBoundWitnessFields {
|
|
16
|
+
/** Updated balance of address whose balance were changed by this block */
|
|
17
|
+
balances: Record<Address, Hex>
|
|
18
|
+
/** Block number */
|
|
19
|
+
block: number
|
|
20
|
+
/** Chain id - this should be "0" for the genesis block */
|
|
21
|
+
chain: Hex
|
|
22
|
+
/** Previous block hash if not block 0 */
|
|
23
|
+
previous: Hash | null /* the previous block hash */
|
|
24
|
+
/** Version of the protocol being used major * 1,000,000 + minor * 1,000 + patch */
|
|
25
|
+
protocol: number
|
|
26
|
+
/** Step hashes */
|
|
27
|
+
step_hashes: Hex[]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type BlockBoundWitness = BoundWitness<BlockBoundWitnessFields & BlockBoundWitnessMeta>
|
|
31
|
+
|
|
32
|
+
export const isBlockBoundWitness = (value: unknown): value is BlockBoundWitness => {
|
|
33
|
+
const typedObj = value as BlockBoundWitness
|
|
34
|
+
return isBoundWitness(value)
|
|
35
|
+
&& Number.isInteger(typedObj.block)
|
|
36
|
+
&& isHex(typedObj.chain)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const isBlockBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<BlockBoundWitness> => {
|
|
40
|
+
return isBlockBoundWitness(value) && isStorageMeta(value)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const asBlockBoundWitness = AsObjectFactory.create(isBlockBoundWitness)
|
|
44
|
+
export const asOptionalBlockBoundWitness = AsObjectFactory.createOptional(isBlockBoundWitness)
|
|
45
|
+
|
|
46
|
+
export const asBlockBoundWitnessWithStorageMeta = AsObjectFactory.create(isBlockBoundWitnessWithStorageMeta)
|
|
47
|
+
export const asOptionalBlockBoundWitnessWithStorageMeta = AsObjectFactory.createOptional(isBlockBoundWitnessWithStorageMeta)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface BlockStart {
|
|
2
|
+
/**
|
|
3
|
+
* The block at which the duration starts
|
|
4
|
+
*/
|
|
5
|
+
nbf: number
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface BlockEnd {
|
|
9
|
+
/**
|
|
10
|
+
* The block at which the duration ends
|
|
11
|
+
*/
|
|
12
|
+
exp: number
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A optional duration referenced to block numbers
|
|
17
|
+
*/
|
|
18
|
+
export interface OptionalBlockDuration extends Partial<BlockStart>, Partial<BlockEnd> {}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A duration referenced to block numbers
|
|
22
|
+
*/
|
|
23
|
+
export interface BlockDuration extends BlockStart, BlockEnd {}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Hex } from '@xylabs/hex'
|
|
2
|
+
import { AsObjectFactory } from '@xylabs/object'
|
|
3
|
+
import type { Payload, WithSources } from '@xyo-network/payload-model'
|
|
4
|
+
import {
|
|
5
|
+
isPayloadOfSchemaType,
|
|
6
|
+
isPayloadOfSchemaTypeWithSources,
|
|
7
|
+
} from '@xyo-network/payload-model'
|
|
8
|
+
|
|
9
|
+
export const BlockNumberSchema = 'network.xyo.chain.block.number' as const
|
|
10
|
+
export type BlockNumberSchema = typeof BlockNumberSchema
|
|
11
|
+
|
|
12
|
+
export interface BlockNumberFields {
|
|
13
|
+
/**
|
|
14
|
+
* The block number
|
|
15
|
+
*/
|
|
16
|
+
block: Hex
|
|
17
|
+
/**
|
|
18
|
+
* The chain id
|
|
19
|
+
*/
|
|
20
|
+
chain?: Hex
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The number of a block
|
|
24
|
+
*/
|
|
25
|
+
export type BlockNumber = Payload<BlockNumberFields, BlockNumberSchema>
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Identity function for determining if an object is a BlockNumber
|
|
29
|
+
*/
|
|
30
|
+
export const isBlockNumber = isPayloadOfSchemaType<BlockNumber>(BlockNumberSchema)
|
|
31
|
+
export const asBlockNumber = AsObjectFactory.create<BlockNumber>(isBlockNumber)
|
|
32
|
+
export const asOptionalBlockNumber = AsObjectFactory.createOptional<BlockNumber>(isBlockNumber)
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Identity function for determining if an object is a BlockNumber with sources
|
|
36
|
+
*/
|
|
37
|
+
export const isBlockNumberWithSources = isPayloadOfSchemaTypeWithSources<BlockNumber>(BlockNumberSchema)
|
|
38
|
+
export const asBlockNumberWithSources = AsObjectFactory.create<WithSources<BlockNumber>>(isBlockNumberWithSources)
|
|
39
|
+
export const asOptionalBlockNumberWithSources = AsObjectFactory.createOptional<WithSources<BlockNumber>>(isBlockNumberWithSources)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Promisable } from '@xylabs/promise'
|
|
2
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
3
|
+
|
|
4
|
+
import type { HydratedBlock } from './HydratedBlock.ts'
|
|
5
|
+
|
|
6
|
+
export interface ChainAnalyzer<T extends Payload = Payload> {
|
|
7
|
+
onBlock(block: HydratedBlock): Promisable<boolean>
|
|
8
|
+
result(): T
|
|
9
|
+
shouldContinue(): boolean
|
|
10
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Signed } from '@xyo-network/boundwitness-model'
|
|
2
|
+
import type { Payload, WithStorageMeta } from '@xyo-network/payload-model'
|
|
3
|
+
|
|
4
|
+
import type { BlockBoundWitness } from './BlockBoundWitness.ts'
|
|
5
|
+
|
|
6
|
+
export type HydratedBlock = [WithStorageMeta<BlockBoundWitness>, WithStorageMeta<Payload>[]]
|
|
7
|
+
|
|
8
|
+
export type SignedHydratedBlock = [WithStorageMeta<Signed<BlockBoundWitness>>, WithStorageMeta<Payload>[]] & HydratedBlock
|