@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,19 @@
|
|
|
1
|
+
import type { Signed } from '@xyo-network/boundwitness-model'
|
|
2
|
+
import type {
|
|
3
|
+
Payload, WithHashStorageMeta, WithStorageMeta,
|
|
4
|
+
} from '@xyo-network/payload-model'
|
|
5
|
+
|
|
6
|
+
import type { TransactionBoundWitness } from './TransactionBoundWitness.ts'
|
|
7
|
+
|
|
8
|
+
export type HydratedTransaction<T extends TransactionBoundWitness = TransactionBoundWitness, P extends Payload = Payload> = [T, P[]]
|
|
9
|
+
|
|
10
|
+
export type HydratedTransactionWithStorageMeta<T extends HydratedTransaction = HydratedTransaction>
|
|
11
|
+
= [WithStorageMeta<T[0]>, WithStorageMeta<T[1][number]>[]]
|
|
12
|
+
|
|
13
|
+
export type HydratedTransactionWithHashStorageMeta<T extends HydratedTransaction = HydratedTransaction>
|
|
14
|
+
= [WithHashStorageMeta<T[0]>, WithHashStorageMeta<T[1][number]>[]]
|
|
15
|
+
|
|
16
|
+
export type SignedHydratedTransaction<T extends HydratedTransaction = HydratedTransaction> = [Signed<T[0]>, T[1][number][]] & HydratedTransaction
|
|
17
|
+
|
|
18
|
+
export type SignedHydratedTransactionWithStorageMeta<T extends HydratedTransaction = HydratedTransaction>
|
|
19
|
+
= [WithStorageMeta<Signed<T[0]>>, WithStorageMeta<T[1][number]>[]] & SignedHydratedTransaction<T> & HydratedTransaction
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const Steps = [10, 105, 1103, 11_576, 121_551, 1_276_282, 13_400_956]
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
|
+
import { AsObjectFactory } from '@xylabs/object'
|
|
3
|
+
import type { BoundWitness, Signed } from '@xyo-network/boundwitness-model'
|
|
4
|
+
import { isBoundWitness } from '@xyo-network/boundwitness-model'
|
|
5
|
+
import type { WithStorageMeta } from '@xyo-network/payload-model'
|
|
6
|
+
import { isStorageMeta } from '@xyo-network/payload-model'
|
|
7
|
+
|
|
8
|
+
import type {
|
|
9
|
+
FromFields,
|
|
10
|
+
OptionalExecutable,
|
|
11
|
+
} from '../payload/index.ts'
|
|
12
|
+
import type { BlockDuration } from './BlockDuration.ts'
|
|
13
|
+
import type { TransactionFeesFields } from './TransactionFeesFields.ts'
|
|
14
|
+
|
|
15
|
+
export interface TransactionBoundWitnessFields extends BlockDuration, TransactionFeesFields {
|
|
16
|
+
chain: Address
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type TransactionBoundWitness = BoundWitness<TransactionBoundWitnessFields & OptionalExecutable & FromFields>
|
|
20
|
+
|
|
21
|
+
export const isTransactionBoundWitness = (value: unknown): value is TransactionBoundWitness => {
|
|
22
|
+
const typedObj = value as TransactionBoundWitness
|
|
23
|
+
return isBoundWitness(value)
|
|
24
|
+
&& typedObj.chain !== undefined
|
|
25
|
+
&& typedObj.fees !== undefined
|
|
26
|
+
&& typedObj.exp !== undefined
|
|
27
|
+
&& typedObj.nbf !== undefined
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const isSignedTransactionBoundWitness = (value: unknown): value is Signed<TransactionBoundWitness> => {
|
|
31
|
+
return isTransactionBoundWitness(value) && isSigned(value)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const isSigned = <T extends BoundWitness = BoundWitness>(value: unknown): value is Signed<T> =>
|
|
35
|
+
isBoundWitness(value)
|
|
36
|
+
&& value.$signatures.length === value.addresses.length
|
|
37
|
+
&& value.addresses.length > 0
|
|
38
|
+
|
|
39
|
+
export const isTransactionBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<TransactionBoundWitness> =>
|
|
40
|
+
isTransactionBoundWitness(value)
|
|
41
|
+
&& isStorageMeta(value)
|
|
42
|
+
|
|
43
|
+
export const isSignedTransactionBoundWitnessWithStorageMeta = (value: unknown): value is WithStorageMeta<Signed<TransactionBoundWitness>> =>
|
|
44
|
+
isSignedTransactionBoundWitness(value)
|
|
45
|
+
&& isStorageMeta(value)
|
|
46
|
+
|
|
47
|
+
export const asTransactionBoundWitness = AsObjectFactory.create(isTransactionBoundWitness)
|
|
48
|
+
export const asOptionalTransactionBoundWitness = AsObjectFactory.createOptional(isTransactionBoundWitness)
|
|
49
|
+
|
|
50
|
+
export const asTransactionBoundWitnessWithStorageMeta = AsObjectFactory.create(isTransactionBoundWitnessWithStorageMeta)
|
|
51
|
+
export const asOptionalTransactionBoundWitnessWithStorageMeta = AsObjectFactory.createOptional(isTransactionBoundWitnessWithStorageMeta)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Hex } from '@xylabs/hex'
|
|
2
|
+
|
|
3
|
+
export interface TransactionFeesBigInt {
|
|
4
|
+
base: bigint // In mXL1
|
|
5
|
+
gasLimit: bigint // In mXL1
|
|
6
|
+
gasPrice: bigint // In mXL1
|
|
7
|
+
priority: bigint // In mXL1
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type TransactionFeesHex = {
|
|
11
|
+
[K in keyof TransactionFeesBigInt]: Hex;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface TransactionFeesFields {
|
|
15
|
+
fees: TransactionFeesHex
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Gas Calculation
|
|
19
|
+
*
|
|
20
|
+
* 1 Million microXL1 (mXL1) = 1 XL1
|
|
21
|
+
*
|
|
22
|
+
* Gas amount is calculated as follows:
|
|
23
|
+
*
|
|
24
|
+
* 1. Each byte in the transaction cost 10 gas
|
|
25
|
+
* 2. Each payload validation in the transaction costs 1000 gas
|
|
26
|
+
* 3. Each signature verification in the transaction costs 1000 gas
|
|
27
|
+
* 4. Each hash validation in the transaction costs 100 gas
|
|
28
|
+
* 5. Each balance validation in the transaction costs 100 gas
|
|
29
|
+
* 6. Processing/Compute/Storage Cost?
|
|
30
|
+
* 7. operation Costs?
|
|
31
|
+
*
|
|
32
|
+
* The total gas cost is calculated by multiplying the gas amount by the gas price.
|
|
33
|
+
*
|
|
34
|
+
* minGasPrice is initially set to 100 mXL1
|
|
35
|
+
* minBase is initially set to 1000 mXL1
|
|
36
|
+
* minPriority is alway 0 mXL1, but can be set to increase the priority of the transaction
|
|
37
|
+
*
|
|
38
|
+
*/
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './AllowedBlockPayload.ts'
|
|
2
|
+
export * from './BlockBoundWitness.ts'
|
|
3
|
+
export * from './BlockDuration.ts'
|
|
4
|
+
export * from './BlockNumber.ts'
|
|
5
|
+
export * from './ChainAnalyzer.ts'
|
|
6
|
+
export * from './ChainReference.ts'
|
|
7
|
+
export * from './HydratedBlock.ts'
|
|
8
|
+
export * from './HydratedTransaction.ts'
|
|
9
|
+
export * from './Issuer.ts'
|
|
10
|
+
export * from './Steps.ts'
|
|
11
|
+
export * from './TransactionBoundWitness.ts'
|
|
12
|
+
export * from './TransactionFeesFields.ts'
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
|
+
import type { Signed } from '@xyo-network/boundwitness-model'
|
|
3
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
4
|
+
|
|
5
|
+
import type {
|
|
6
|
+
AllowedBlockPayload, TransactionBoundWitness, TransactionFeesBigInt,
|
|
7
|
+
} from '../protocol/index.ts'
|
|
8
|
+
import type { XyoRunner } from './XyoRunner.ts'
|
|
9
|
+
import type { XyoSigner } from './XyoSigner.ts'
|
|
10
|
+
import type { XyoStorage } from './XyoStorage.ts'
|
|
11
|
+
import type { XyoViewer } from './XyoViewer.ts'
|
|
12
|
+
import type { XyoWallet } from './XyoWallet.ts'
|
|
13
|
+
|
|
14
|
+
export interface XyoProvider {
|
|
15
|
+
runner?: XyoRunner
|
|
16
|
+
send?: (
|
|
17
|
+
elevatedPayloads: AllowedBlockPayload[],
|
|
18
|
+
additionalPayloads: Payload[],
|
|
19
|
+
chain?: Address,
|
|
20
|
+
nbf?: number,
|
|
21
|
+
exp?: number,
|
|
22
|
+
from?: Address,
|
|
23
|
+
fees?: TransactionFeesBigInt,
|
|
24
|
+
) => Promise<Signed<TransactionBoundWitness>>
|
|
25
|
+
signer?: XyoSigner
|
|
26
|
+
storage?: XyoStorage
|
|
27
|
+
viewer?: XyoViewer
|
|
28
|
+
wallet?: XyoWallet
|
|
29
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Hash } from '@xylabs/hex'
|
|
2
|
+
import type { Promisable } from '@xylabs/promise'
|
|
3
|
+
|
|
4
|
+
import type { SignedHydratedTransaction } from '../protocol/index.ts'
|
|
5
|
+
|
|
6
|
+
export interface XyoRunner {
|
|
7
|
+
broadcastTransaction(transaction: SignedHydratedTransaction): Promisable<Hash>
|
|
8
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
|
+
import type { Promisable } from '@xylabs/promise'
|
|
3
|
+
import type { Signed } from '@xyo-network/boundwitness-model'
|
|
4
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
AllowedBlockPayload, TransactionBoundWitness, TransactionFeesBigInt,
|
|
8
|
+
} from '../protocol/index.ts'
|
|
9
|
+
|
|
10
|
+
export interface XyoSigner {
|
|
11
|
+
address(): Promisable<Address>
|
|
12
|
+
createSignedTransaction(
|
|
13
|
+
chain: Address,
|
|
14
|
+
elevatedPayloads: AllowedBlockPayload[],
|
|
15
|
+
additionalPayloads: Payload[],
|
|
16
|
+
nbf: number,
|
|
17
|
+
exp: number,
|
|
18
|
+
fees: TransactionFeesBigInt,
|
|
19
|
+
from?: Address,
|
|
20
|
+
): Promisable<Signed<TransactionBoundWitness>>
|
|
21
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Hash } from '@xylabs/hex'
|
|
2
|
+
import type { Promisable } from '@xylabs/promise'
|
|
3
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
4
|
+
|
|
5
|
+
export interface XyoStorageHelpers {
|
|
6
|
+
addPayloads(data: Payload[]): Promisable<Hash[]>
|
|
7
|
+
getPayloads(hashes: Hash[]): Promisable<Payload[]>
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface XyoStorageCalls {
|
|
11
|
+
add(data: ArrayBuffer[]): Promisable<Hash[]>
|
|
12
|
+
fetch(hashes: Hash[], maxDepth?: number): Promisable<ArrayBuffer[]>
|
|
13
|
+
get(hashes: Hash[]): Promisable<ArrayBuffer[]>
|
|
14
|
+
trace(hashes: Hash[]): Promisable<[ArrayBuffer, Payload[]][]>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface XyoStorage extends XyoStorageHelpers, XyoStorageCalls {}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Address, Hash } from '@xylabs/hex'
|
|
2
|
+
import type { Promisable } from '@xylabs/promise'
|
|
3
|
+
|
|
4
|
+
import type { SignedHydratedBlock, SignedHydratedTransaction } from '../protocol/index.ts'
|
|
5
|
+
|
|
6
|
+
export interface XyoViewer {
|
|
7
|
+
accountBalance(address: Address, blockNumber: number, full: boolean): Promisable<bigint>
|
|
8
|
+
blockByHash(hash: Hash): Promisable<SignedHydratedBlock | null>
|
|
9
|
+
blockByNumber(blockNumber: number): Promisable<SignedHydratedBlock | null>
|
|
10
|
+
blocksByHash(hash: Hash, limit?: number): Promisable<SignedHydratedBlock[]>
|
|
11
|
+
chainId(): Promisable<Address>
|
|
12
|
+
currentBlock(): Promisable<SignedHydratedBlock>
|
|
13
|
+
currentBlockHash(): Promisable<Hash>
|
|
14
|
+
currentBlockNumber(): Promisable<number>
|
|
15
|
+
transactionByBlockHashAndIndex(blockHash: Hash, transactionIndex: number): Promisable<SignedHydratedTransaction | null>
|
|
16
|
+
transactionByBlockNumberAndIndex(blockNumber: number, transactionIndex: number): Promisable<SignedHydratedTransaction | null>
|
|
17
|
+
transactionByHash(transactionHash: Hash): Promisable<SignedHydratedTransaction | null>
|
|
18
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
|
+
import type { Promisable } from '@xylabs/promise'
|
|
3
|
+
|
|
4
|
+
// TODO: define the permissions object and return object types
|
|
5
|
+
|
|
6
|
+
export interface XyoWallet {
|
|
7
|
+
accounts(): Promisable<Address[]>
|
|
8
|
+
addChain(chain: Address, name?: string): Promisable<object>
|
|
9
|
+
chain(): Promisable<Address>
|
|
10
|
+
chains(): Promisable<object>
|
|
11
|
+
permissions(): Promisable<Record<string, object>>
|
|
12
|
+
requestPermissions(permissions: object): Promisable<object>
|
|
13
|
+
revokePermissions(permissions: object): Promisable<object>
|
|
14
|
+
switchChain(chain: Address): Promisable<void>
|
|
15
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface ReadRepository<TId, TData> {
|
|
2
|
+
get(id: TId): Promise<TData | undefined>
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface IterableRepository<TId, TData> {
|
|
6
|
+
next(id: TId): Promise<TData | undefined>
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface WriteRepository<TData, TResp> {
|
|
10
|
+
insert(data: TData): Promise<TResp>
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TransactionReadRepository } from './TransactionReadRepository.ts'
|
|
2
|
+
import type { TransactionRepositoryIterator } from './TransactionRepositoryIterator.ts'
|
|
3
|
+
import type { TransactionWriteRepository } from './TransactionWriteRepository.ts'
|
|
4
|
+
|
|
5
|
+
export interface TransactionRepository extends TransactionReadRepository, TransactionWriteRepository {}
|
|
6
|
+
|
|
7
|
+
export interface ReadonlyIterableTransactionRepository extends TransactionReadRepository, TransactionRepositoryIterator {}
|
|
8
|
+
|
|
9
|
+
export interface IterableTransactionRepository extends TransactionRepository, TransactionRepositoryIterator {}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { HydratedTransaction, TransactionBoundWitness } from '../protocol/index.ts'
|
|
2
|
+
import type { IterableRepository } from './Repository.ts'
|
|
3
|
+
|
|
4
|
+
export interface TransactionRepositoryIterator extends IterableRepository<TransactionBoundWitness, HydratedTransaction> {}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Addressable } from '../Addressable.ts'
|
|
2
|
+
import type { BlockBoundWitness, HydratedBlock } from '../protocol/index.ts'
|
|
3
|
+
import type { IterableRepository } from '../repository/index.ts'
|
|
4
|
+
|
|
5
|
+
export type NextBlockProducer = IterableRepository<BlockBoundWitness, HydratedBlock>
|
|
6
|
+
|
|
7
|
+
export interface BlockProducer extends Addressable, NextBlockProducer {}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
|
+
|
|
3
|
+
export interface ChainContractViewer {
|
|
4
|
+
active(): Promise<bigint>
|
|
5
|
+
chainId(): Promise<Address>
|
|
6
|
+
forkedAtBlockNumber(): Promise<bigint>
|
|
7
|
+
forkedAtHash(): Promise<bigint>
|
|
8
|
+
forkedChainId(): Promise<Address>
|
|
9
|
+
minWithdrawalBlocks(): Promise<bigint>
|
|
10
|
+
rewardsContract(): Promise<string>
|
|
11
|
+
stakingTokenAddress(): Promise<string>
|
|
12
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
3
|
+
import { isPayloadOfSchemaType } from '@xyo-network/payload-model'
|
|
4
|
+
|
|
5
|
+
export const ChainIdentificationPayloadSchema = 'network.xyo.chain.identification' as const
|
|
6
|
+
export type ChainIdentificationPayloadSchema = typeof ChainIdentificationPayloadSchema
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Identification required to uniquely identify a chain
|
|
10
|
+
*/
|
|
11
|
+
export interface ChainIdentification {
|
|
12
|
+
/** @field the id of the chain */
|
|
13
|
+
id: Address
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type ChainIdentificationPayload = Payload<ChainIdentification, ChainIdentificationPayloadSchema>
|
|
17
|
+
export const isChainIdentificationPayload = isPayloadOfSchemaType<ChainIdentificationPayload>(ChainIdentificationPayloadSchema)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
2
|
+
import { isPayloadOfSchemaType } from '@xyo-network/payload-model'
|
|
3
|
+
|
|
4
|
+
export const ChainInformationPayloadSchema = 'network.xyo.chain.information' as const
|
|
5
|
+
export type ChainInformationPayloadSchema = typeof ChainInformationPayloadSchema
|
|
6
|
+
|
|
7
|
+
import type { ChainIdentification } from './ChainIdentification.ts'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Information required to produce a chain
|
|
11
|
+
*/
|
|
12
|
+
export interface ChainInformation extends ChainIdentification {
|
|
13
|
+
// TODO: Add these fields which are currently promises on the smart contract
|
|
14
|
+
// forkedAtBlockNumber: bigint
|
|
15
|
+
// forkedAtHash: Hash
|
|
16
|
+
// forkedChainId: Address
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type ChainInformationPayload = Payload<ChainIdentification, ChainInformationPayloadSchema>
|
|
20
|
+
export const isChainInformationPayload = isPayloadOfSchemaType<ChainInformationPayload>(ChainInformationPayloadSchema)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Service } from '../Service.ts'
|
|
2
|
+
import type { ChainContractViewer } from './ChainContractViewer.ts'
|
|
3
|
+
import type { ChainInformation } from './ChainInformation.ts'
|
|
4
|
+
import type { ChainStaker } from './ChainStaker.ts'
|
|
5
|
+
import type { ChainStakeViewer } from './ChainStakeViewer.ts'
|
|
6
|
+
|
|
7
|
+
export interface ChainService extends ChainInformation, ChainContractViewer, ChainStakeViewer, ChainStaker, Service {}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ChainContractViewer } from './ChainContractViewer.ts'
|
|
2
|
+
|
|
3
|
+
export interface ChainStakeViewer extends ChainContractViewer {
|
|
4
|
+
activeByAddressStaked(address: string): Promise<bigint>
|
|
5
|
+
activeByStaker(address: string): Promise<bigint>
|
|
6
|
+
pending(): Promise<bigint>
|
|
7
|
+
pendingByStaker(staker: string): Promise<bigint>
|
|
8
|
+
withdrawn(): Promise<bigint>
|
|
9
|
+
withdrawnByStaker(staker: string): Promise<bigint>
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
|
+
|
|
3
|
+
import type { BlockBoundWitness } from '../protocol/index.ts'
|
|
4
|
+
import type { Service } from './Service.ts'
|
|
5
|
+
|
|
6
|
+
export interface ElectionService extends Service {
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Given the current block, get the leader for the next block
|
|
10
|
+
* @param current The previous block
|
|
11
|
+
*/
|
|
12
|
+
getCreatorCommitteeForNextBlock(current: BlockBoundWitness): Promise<Address[]>
|
|
13
|
+
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BaseParams } from '@xylabs/base'
|
|
2
|
+
import type { EmptyObject } from '@xylabs/object'
|
|
3
|
+
import type { AccountInstance } from '@xyo-network/account-model'
|
|
4
|
+
|
|
5
|
+
import type { OpenTelemetryProviders } from '../OpenTelemetryProviders.ts'
|
|
6
|
+
|
|
7
|
+
export type BaseServiceParams<TAdditionalParams extends EmptyObject = EmptyObject> = BaseParams<TAdditionalParams & OpenTelemetryProviders>
|
|
8
|
+
|
|
9
|
+
export type BaseAccountableServiceParams = BaseServiceParams<{
|
|
10
|
+
account: AccountInstance
|
|
11
|
+
}>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Hash } from '@xylabs/hex'
|
|
2
|
+
|
|
3
|
+
import type { HydratedTransaction } from '../protocol/index.ts'
|
|
4
|
+
import type { Service } from './Service.ts'
|
|
5
|
+
|
|
6
|
+
export interface PendingTransactionsService extends Service {
|
|
7
|
+
getPendingTransactions(head: Hash, limit: number, timeout?: number): Promise<HydratedTransaction[]>
|
|
8
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Meter, Tracer } from '@opentelemetry/api'
|
|
2
|
+
import type { Logger } from '@xylabs/logger'
|
|
3
|
+
|
|
4
|
+
export type ServiceName = Exclude<string, 'reserved-service-name-value'>
|
|
5
|
+
|
|
6
|
+
export interface Service {
|
|
7
|
+
logger?: Logger
|
|
8
|
+
meter?: Meter
|
|
9
|
+
tracer?: Tracer
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './AccountBalanceService.ts'
|
|
2
|
+
export * from './BlockProducer.ts'
|
|
3
|
+
export * from './BlockReward.ts'
|
|
4
|
+
export * from './Chain/index.ts'
|
|
5
|
+
export * from './Election.ts'
|
|
6
|
+
export * from './Params.ts'
|
|
7
|
+
export * from './PendingTransactionsService.ts'
|
|
8
|
+
export * from './Service.ts'
|
|
9
|
+
export * from './stakeIntent/index.ts'
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Hash } from '@xylabs/hex'
|
|
2
|
+
import type { JsonValue } from '@xylabs/object'
|
|
3
|
+
import { AsObjectFactory } from '@xylabs/object'
|
|
4
|
+
import type { Payload, WithStorageMeta } from '@xyo-network/payload-model'
|
|
5
|
+
import { isPayloadOfSchemaType, isStorageMeta } from '@xyo-network/payload-model'
|
|
6
|
+
|
|
7
|
+
export interface ChainIndexingServiceStateFields<T extends JsonValue = JsonValue> {
|
|
8
|
+
/**
|
|
9
|
+
* The hash of the last block that this service has indexing
|
|
10
|
+
*/
|
|
11
|
+
endBlockHash: Hash
|
|
12
|
+
/**
|
|
13
|
+
* The hash of the block that the service started indexing. If undefined, the service is
|
|
14
|
+
* assumed to have started indexing from the genesis block
|
|
15
|
+
*/
|
|
16
|
+
startBlockHash?: Hash
|
|
17
|
+
/**
|
|
18
|
+
* The indexed state for the range
|
|
19
|
+
*/
|
|
20
|
+
state: T
|
|
21
|
+
}
|
|
22
|
+
export const ChainIndexingServiceStateSchema = 'network.xyo.chain.indexing.service.state' as const
|
|
23
|
+
export type ChainIndexingServiceStateSchema = typeof ChainIndexingServiceStateSchema
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The result of a ChainIndexingServiceState
|
|
27
|
+
*/
|
|
28
|
+
export type ChainIndexingServiceState<T extends JsonValue = JsonValue> = Payload<ChainIndexingServiceStateFields<T>, ChainIndexingServiceStateSchema>
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Identity functions for determining if an object is an ChainIndexingServiceState
|
|
32
|
+
*/
|
|
33
|
+
export const isChainIndexingServiceState = <T extends JsonValue = JsonValue>(payload?: unknown): payload is ChainIndexingServiceState<T> => {
|
|
34
|
+
return isPayloadOfSchemaType<ChainIndexingServiceState<T>>(ChainIndexingServiceStateSchema)(payload)
|
|
35
|
+
}
|
|
36
|
+
export const asChainIndexingServiceState = AsObjectFactory.create<ChainIndexingServiceState<JsonValue>>(isChainIndexingServiceState)
|
|
37
|
+
|
|
38
|
+
export const isChainIndexingServiceStateWithStorageMeta
|
|
39
|
+
= <T extends JsonValue = JsonValue>(value: unknown): value is WithStorageMeta<ChainIndexingServiceState<T>> =>
|
|
40
|
+
isChainIndexingServiceState<T>(value) && isStorageMeta(value)
|
|
41
|
+
|
|
42
|
+
export const asChainIndexingServiceStateWithStorageMeta
|
|
43
|
+
= AsObjectFactory.create<WithStorageMeta<ChainIndexingServiceState>>(isChainIndexingServiceStateWithStorageMeta)
|
|
44
|
+
|
|
45
|
+
export const asOptionalChainIndexingServiceStateWithStorageMeta
|
|
46
|
+
= AsObjectFactory.createOptional<WithStorageMeta<ChainIndexingServiceState>>(isChainIndexingServiceStateWithStorageMeta)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
|
+
|
|
3
|
+
import type { Intent } from '../../payload/index.ts'
|
|
4
|
+
|
|
5
|
+
export interface StakeIntentService {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Gets the declared ranges for an address based on historical on-chain data
|
|
9
|
+
* @param address The address to get the declared ranges for
|
|
10
|
+
* @param intent The declared intent to filter for
|
|
11
|
+
*/
|
|
12
|
+
getDeclaredCandidateRanges(address: Address, intent: Intent): Promise<Readonly<Readonly<[number, number]>[]>>
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Gets the declared candidates for a block based on historical on-chain data
|
|
16
|
+
* @param block The block number to get the declared candidates for
|
|
17
|
+
* @param intent The declared intent to filter for
|
|
18
|
+
*/
|
|
19
|
+
getDeclaredCandidatesForBlock(block: number, intent: Intent): Promise<Address[]>
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Checks if the address is staked for a block for a given intent
|
|
23
|
+
* @param block The block number to check
|
|
24
|
+
* @param intent The declared intent to filter for
|
|
25
|
+
* @param address The address to check
|
|
26
|
+
*/
|
|
27
|
+
isStakedForBlock(block: number, intent: Intent, address: Address): Promise<boolean>
|
|
28
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
|
+
import type { Promisable } from '@xylabs/promise'
|
|
3
|
+
|
|
4
|
+
import type { BlockBoundWitness } from '../../protocol/index.ts'
|
|
5
|
+
|
|
6
|
+
export type BlockValidatorFunction = (
|
|
7
|
+
block: BlockBoundWitness,
|
|
8
|
+
chainId?: Address,
|
|
9
|
+
) => Promisable<Error[]>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
|
+
import type { Promisable } from '@xylabs/promise'
|
|
3
|
+
import type { ReadArchivist } from '@xyo-network/archivist-model'
|
|
4
|
+
|
|
5
|
+
import type { HydratedBlock } from '../../protocol/index.ts'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A function that validates a hydrated block against chain state.
|
|
9
|
+
* @param hydratedBlock The hydrated block to validate.
|
|
10
|
+
* @param chainId The chain ID to use for validation.
|
|
11
|
+
* @param archivist The archivist to use for validation.
|
|
12
|
+
* @returns An array of errors if the block is invalid, or an empty array if it is valid.
|
|
13
|
+
*/
|
|
14
|
+
export type HydratedBlockStateValidationFunction = (
|
|
15
|
+
hydratedBlock: HydratedBlock,
|
|
16
|
+
chainId: Address,
|
|
17
|
+
archivist: ReadArchivist,
|
|
18
|
+
) => Promisable<Error[]>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
|
+
import type { Promisable } from '@xylabs/promise'
|
|
3
|
+
|
|
4
|
+
import type { HydratedBlock } from '../../protocol/index.ts'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A function that validates a hydrated block.
|
|
8
|
+
* @param hydratedBlock The hydrated block to validate.
|
|
9
|
+
* @param chainId The chain ID to use for validation.
|
|
10
|
+
* @returns An array of errors if the block is invalid, or an empty array if it is valid.
|
|
11
|
+
*/
|
|
12
|
+
export type HydratedBlockValidatorFunction = (
|
|
13
|
+
hydratedBlock: HydratedBlock,
|
|
14
|
+
chainId?: Address,
|
|
15
|
+
) => Promisable<Error[]>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Promisable } from '@xylabs/promise'
|
|
2
|
+
import type { BoundWitness } from '@xyo-network/boundwitness-model'
|
|
3
|
+
import type { Payload, WithHashStorageMeta } from '@xyo-network/payload-model'
|
|
4
|
+
|
|
5
|
+
export type HydratedBoundWitnessWithHashStorageMeta<T extends BoundWitness = BoundWitness, P extends Payload = Payload>
|
|
6
|
+
= [WithHashStorageMeta<T>, WithHashStorageMeta<P>[]]
|
|
7
|
+
|
|
8
|
+
export type HydratedBoundWitnessValidationFunction<T extends BoundWitness = BoundWitness> = (
|
|
9
|
+
bw: HydratedBoundWitnessWithHashStorageMeta<T>
|
|
10
|
+
) => Promisable<Error[]>
|