@xyo-network/xl1-protocol-sdk 1.15.28 → 1.16.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/ChainServiceCollectionV2.d.ts +1 -1
- package/dist/neutral/ChainServiceCollectionV2.d.ts.map +1 -1
- package/dist/neutral/block/primitives/transfers/transfersStepSummaryFromRange.d.ts.map +1 -1
- package/dist/neutral/block/primitives/transfers/transfersSummary.d.ts +3 -2
- package/dist/neutral/block/primitives/transfers/transfersSummary.d.ts.map +1 -1
- package/dist/neutral/config/Config.d.ts +6 -0
- package/dist/neutral/config/Config.d.ts.map +1 -1
- package/dist/neutral/config/Mempool.d.ts +9 -0
- package/dist/neutral/config/Mempool.d.ts.map +1 -0
- package/dist/neutral/index.d.ts +3 -0
- package/dist/neutral/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +249 -126
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/interfaces/index.d.ts +2 -0
- package/dist/neutral/interfaces/index.d.ts.map +1 -0
- package/dist/neutral/interfaces/viewers/AccountBalance.d.ts +19 -0
- package/dist/neutral/interfaces/viewers/AccountBalance.d.ts.map +1 -0
- package/dist/neutral/interfaces/viewers/Block.d.ts +12 -0
- package/dist/neutral/interfaces/viewers/Block.d.ts.map +1 -0
- package/dist/neutral/interfaces/viewers/Chain.d.ts +6 -0
- package/dist/neutral/interfaces/viewers/Chain.d.ts.map +1 -0
- package/dist/neutral/interfaces/viewers/ChainContract.d.ts +10 -0
- package/dist/neutral/interfaces/viewers/ChainContract.d.ts.map +1 -0
- package/dist/neutral/interfaces/viewers/Fork.d.ts +8 -0
- package/dist/neutral/interfaces/viewers/Fork.d.ts.map +1 -0
- package/dist/neutral/interfaces/viewers/NetworkStakeStepReward.d.ts +30 -0
- package/dist/neutral/interfaces/viewers/NetworkStakeStepReward.d.ts.map +1 -0
- package/dist/neutral/interfaces/viewers/NetworkStakeViewer/NetworkStakeViewer.d.ts +10 -0
- package/dist/neutral/interfaces/viewers/NetworkStakeViewer/NetworkStakeViewer.d.ts.map +1 -0
- package/dist/neutral/interfaces/viewers/NetworkStakeViewer/RecordKeyType.d.ts +2 -0
- package/dist/neutral/interfaces/viewers/NetworkStakeViewer/RecordKeyType.d.ts.map +1 -0
- package/dist/neutral/interfaces/viewers/NetworkStakeViewer/RewardsByIndexViewerMethodsTemplate.d.ts +6 -0
- package/dist/neutral/interfaces/viewers/NetworkStakeViewer/RewardsByIndexViewerMethodsTemplate.d.ts.map +1 -0
- package/dist/neutral/interfaces/viewers/NetworkStakeViewer/RewardsByPositionViewer.d.ts +7 -0
- package/dist/neutral/interfaces/viewers/NetworkStakeViewer/RewardsByPositionViewer.d.ts.map +1 -0
- package/dist/neutral/interfaces/viewers/NetworkStakeViewer/RewardsByStakerViewer.d.ts +8 -0
- package/dist/neutral/interfaces/viewers/NetworkStakeViewer/RewardsByStakerViewer.d.ts.map +1 -0
- package/dist/neutral/interfaces/viewers/NetworkStakeViewer/RewardsByStepViewer.d.ts +8 -0
- package/dist/neutral/interfaces/viewers/NetworkStakeViewer/RewardsByStepViewer.d.ts.map +1 -0
- package/dist/neutral/interfaces/viewers/NetworkStakeViewer/RewardsTotalViewer.d.ts +8 -0
- package/dist/neutral/interfaces/viewers/NetworkStakeViewer/RewardsTotalViewer.d.ts.map +1 -0
- package/dist/neutral/interfaces/viewers/NetworkStakeViewer/RewardsViewerMethodsTemplate.d.ts +9 -0
- package/dist/neutral/interfaces/viewers/NetworkStakeViewer/RewardsViewerMethodsTemplate.d.ts.map +1 -0
- package/dist/neutral/interfaces/viewers/NetworkStakeViewer/RewardsViewerOptions.d.ts +15 -0
- package/dist/neutral/interfaces/viewers/NetworkStakeViewer/RewardsViewerOptions.d.ts.map +1 -0
- package/dist/neutral/interfaces/viewers/NetworkStakeViewer/StepRewardsViewer.d.ts +13 -0
- package/dist/neutral/interfaces/viewers/NetworkStakeViewer/StepRewardsViewer.d.ts.map +1 -0
- package/dist/neutral/interfaces/viewers/NetworkStakeViewer/StepViewer.d.ts +26 -0
- package/dist/neutral/interfaces/viewers/NetworkStakeViewer/StepViewer.d.ts.map +1 -0
- package/dist/neutral/interfaces/viewers/NetworkStakeViewer/index.d.ts +12 -0
- package/dist/neutral/interfaces/viewers/NetworkStakeViewer/index.d.ts.map +1 -0
- package/dist/neutral/interfaces/viewers/Stake.d.ts +14 -0
- package/dist/neutral/interfaces/viewers/Stake.d.ts.map +1 -0
- package/dist/neutral/interfaces/viewers/StakeTotalsViewer.d.ts +12 -0
- package/dist/neutral/interfaces/viewers/StakeTotalsViewer.d.ts.map +1 -0
- package/dist/neutral/interfaces/viewers/StakeViewer.d.ts +11 -0
- package/dist/neutral/interfaces/viewers/StakeViewer.d.ts.map +1 -0
- package/dist/neutral/interfaces/viewers/StepStake.d.ts +8 -0
- package/dist/neutral/interfaces/viewers/StepStake.d.ts.map +1 -0
- package/dist/neutral/interfaces/viewers/TimeSync.d.ts +16 -0
- package/dist/neutral/interfaces/viewers/TimeSync.d.ts.map +1 -0
- package/dist/neutral/interfaces/viewers/Transaction.d.ts +9 -0
- package/dist/neutral/interfaces/viewers/Transaction.d.ts.map +1 -0
- package/dist/neutral/interfaces/viewers/TransferBalance.d.ts +23 -0
- package/dist/neutral/interfaces/viewers/TransferBalance.d.ts.map +1 -0
- package/dist/neutral/interfaces/viewers/index.d.ts +15 -0
- package/dist/neutral/interfaces/viewers/index.d.ts.map +1 -0
- package/dist/neutral/model/ChainStake/ChainStakeRead.d.ts +1 -1
- package/dist/neutral/model/ChainStake/ChainStakeRead.d.ts.map +1 -1
- package/dist/neutral/model/summary.d.ts +2 -2
- package/dist/neutral/model/summary.d.ts.map +1 -1
- package/dist/neutral/provider/TransactionHelper.d.ts +8 -0
- package/dist/neutral/provider/TransactionHelper.d.ts.map +1 -0
- package/dist/neutral/provider/TransactionSubmitter.d.ts +18 -0
- package/dist/neutral/provider/TransactionSubmitter.d.ts.map +1 -0
- package/dist/neutral/provider/XyoClient.d.ts +19 -0
- package/dist/neutral/provider/XyoClient.d.ts.map +1 -0
- package/dist/neutral/provider/XyoConnection.d.ts +35 -0
- package/dist/neutral/provider/XyoConnection.d.ts.map +1 -0
- package/dist/neutral/provider/XyoDataLake.d.ts +18 -0
- package/dist/neutral/provider/XyoDataLake.d.ts.map +1 -0
- package/dist/neutral/provider/XyoGateway.d.ts +19 -0
- package/dist/neutral/provider/XyoGateway.d.ts.map +1 -0
- package/dist/neutral/provider/XyoGatewayHelpers.d.ts +16 -0
- package/dist/neutral/provider/XyoGatewayHelpers.d.ts.map +1 -0
- package/dist/neutral/provider/XyoNetwork.d.ts +6 -0
- package/dist/neutral/provider/XyoNetwork.d.ts.map +1 -0
- package/dist/neutral/provider/XyoRunner.d.ts +7 -0
- package/dist/neutral/provider/XyoRunner.d.ts.map +1 -0
- package/dist/neutral/provider/XyoSigner.d.ts +14 -0
- package/dist/neutral/provider/XyoSigner.d.ts.map +1 -0
- package/dist/neutral/provider/XyoViewer.d.ts +7 -0
- package/dist/neutral/provider/XyoViewer.d.ts.map +1 -0
- package/dist/neutral/provider/XyoWallet.d.ts +15 -0
- package/dist/neutral/provider/XyoWallet.d.ts.map +1 -0
- package/dist/neutral/provider/index.d.ts +13 -0
- package/dist/neutral/provider/index.d.ts.map +1 -0
- package/dist/neutral/provider/permissions/InvokerPermission.d.ts +51 -0
- package/dist/neutral/provider/permissions/InvokerPermission.d.ts.map +1 -0
- package/dist/neutral/provider/permissions/XyoPermissions.d.ts +32 -0
- package/dist/neutral/provider/permissions/XyoPermissions.d.ts.map +1 -0
- package/dist/neutral/provider/permissions/index.d.ts +3 -0
- package/dist/neutral/provider/permissions/index.d.ts.map +1 -0
- package/dist/neutral/services/AccountBalanceService.d.ts +16 -0
- package/dist/neutral/services/AccountBalanceService.d.ts.map +1 -0
- package/dist/neutral/services/AccountTransfersService.d.ts +11 -0
- package/dist/neutral/services/AccountTransfersService.d.ts.map +1 -0
- package/dist/neutral/services/BlockProducerService.d.ts +6 -0
- package/dist/neutral/services/BlockProducerService.d.ts.map +1 -0
- package/dist/neutral/services/BlockRewardService.d.ts +6 -0
- package/dist/neutral/services/BlockRewardService.d.ts.map +1 -0
- package/dist/neutral/services/BlockRewardServiceV2.d.ts +6 -0
- package/dist/neutral/services/BlockRewardServiceV2.d.ts.map +1 -0
- package/dist/neutral/services/Chain/BaseChainService.d.ts +6 -0
- package/dist/neutral/services/Chain/BaseChainService.d.ts.map +1 -0
- package/dist/neutral/services/Chain/ChainHeadService.d.ts +6 -0
- package/dist/neutral/services/Chain/ChainHeadService.d.ts.map +1 -0
- package/dist/neutral/services/Chain/ChainService.d.ts +5 -0
- package/dist/neutral/services/Chain/ChainService.d.ts.map +1 -0
- package/dist/neutral/services/Chain/index.d.ts +5 -0
- package/dist/neutral/services/Chain/index.d.ts.map +1 -0
- package/dist/neutral/services/Chain/interfaces/ChainContractViewer.d.ts +4 -0
- package/dist/neutral/services/Chain/interfaces/ChainContractViewer.d.ts.map +1 -0
- package/dist/neutral/services/Chain/interfaces/ChainStakeViewer.d.ts +5 -0
- package/dist/neutral/services/Chain/interfaces/ChainStakeViewer.d.ts.map +1 -0
- package/dist/neutral/services/Chain/interfaces/ChainStaker.d.ts +6 -0
- package/dist/neutral/services/Chain/interfaces/ChainStaker.d.ts.map +1 -0
- package/dist/neutral/services/Chain/interfaces/index.d.ts +4 -0
- package/dist/neutral/services/Chain/interfaces/index.d.ts.map +1 -0
- package/dist/neutral/services/ChainIterator/ChainIteratorService.d.ts +23 -0
- package/dist/neutral/services/ChainIterator/ChainIteratorService.d.ts.map +1 -0
- package/dist/neutral/services/ChainIterator/ChainIteratorServiceEventData.d.ts +11 -0
- package/dist/neutral/services/ChainIterator/ChainIteratorServiceEventData.d.ts.map +1 -0
- package/dist/neutral/services/ChainIterator/index.d.ts +3 -0
- package/dist/neutral/services/ChainIterator/index.d.ts.map +1 -0
- package/dist/neutral/services/Election.d.ts +12 -0
- package/dist/neutral/services/Election.d.ts.map +1 -0
- package/dist/neutral/services/NetworkStakeService.d.ts +5 -0
- package/dist/neutral/services/NetworkStakeService.d.ts.map +1 -0
- package/dist/neutral/services/Params.d.ts +9 -0
- package/dist/neutral/services/Params.d.ts.map +1 -0
- package/dist/neutral/services/PendingTransactionsService.d.ts +7 -0
- package/dist/neutral/services/PendingTransactionsService.d.ts.map +1 -0
- package/dist/neutral/services/Service.d.ts +5 -0
- package/dist/neutral/services/Service.d.ts.map +1 -0
- package/dist/neutral/services/StakeIntentService/ChainIndexingServiceStateSchema.d.ts +32 -0
- package/dist/neutral/services/StakeIntentService/ChainIndexingServiceStateSchema.d.ts.map +1 -0
- package/dist/neutral/services/StakeIntentService/StakeIntentService.d.ts +31 -0
- package/dist/neutral/services/StakeIntentService/StakeIntentService.d.ts.map +1 -0
- package/dist/neutral/services/StakeIntentService/index.d.ts +3 -0
- package/dist/neutral/services/StakeIntentService/index.d.ts.map +1 -0
- package/dist/neutral/services/StepStakeService.d.ts +5 -0
- package/dist/neutral/services/StepStakeService.d.ts.map +1 -0
- package/dist/neutral/services/TimeSyncService.d.ts +7 -0
- package/dist/neutral/services/TimeSyncService.d.ts.map +1 -0
- package/dist/neutral/services/index.d.ts +15 -0
- package/dist/neutral/services/index.d.ts.map +1 -0
- package/dist/neutral/transaction/confirmSubmittedTransaction.d.ts +2 -1
- package/dist/neutral/transaction/confirmSubmittedTransaction.d.ts.map +1 -1
- package/dist/neutral/validation/block/BlockValidationFunction.d.ts +5 -0
- package/dist/neutral/validation/block/BlockValidationFunction.d.ts.map +1 -0
- package/dist/neutral/validation/block/HydratedBlockStateValidationFunction.d.ts +18 -0
- package/dist/neutral/validation/block/HydratedBlockStateValidationFunction.d.ts.map +1 -0
- package/dist/neutral/validation/block/HydratedBlockValidationFunction.d.ts +11 -0
- package/dist/neutral/validation/block/HydratedBlockValidationFunction.d.ts.map +1 -0
- package/dist/neutral/validation/block/error.d.ts +15 -0
- package/dist/neutral/validation/block/error.d.ts.map +1 -0
- package/dist/neutral/validation/block/error.spec.d.ts +2 -0
- package/dist/neutral/validation/block/error.spec.d.ts.map +1 -0
- package/dist/neutral/validation/block/index.d.ts +5 -0
- package/dist/neutral/validation/block/index.d.ts.map +1 -0
- package/dist/neutral/validation/index.d.ts +1 -0
- package/dist/neutral/validation/index.d.ts.map +1 -1
- package/package.json +26 -23
- package/src/ChainServiceCollectionV2.ts +4 -3
- package/src/block/primitives/frames/spec/calculateFramesFromRange.spec.ts +1 -1
- package/src/block/primitives/transfers/transfersStepSummaryFromRange.ts +7 -4
- package/src/block/primitives/transfers/transfersSummary.ts +11 -7
- package/src/config/Config.ts +2 -0
- package/src/config/Mempool.ts +42 -0
- package/src/index.ts +3 -0
- package/src/interfaces/index.ts +1 -0
- package/src/interfaces/viewers/AccountBalance.ts +25 -0
- package/src/interfaces/viewers/Block.ts +13 -0
- package/src/interfaces/viewers/Chain.ts +6 -0
- package/src/interfaces/viewers/ChainContract.ts +10 -0
- package/src/interfaces/viewers/Fork.ts +9 -0
- package/src/interfaces/viewers/NetworkStakeStepReward.ts +69 -0
- package/src/interfaces/viewers/NetworkStakeViewer/NetworkStakeViewer.ts +12 -0
- package/src/interfaces/viewers/NetworkStakeViewer/RecordKeyType.ts +2 -0
- package/src/interfaces/viewers/NetworkStakeViewer/RewardsByIndexViewerMethodsTemplate.ts +7 -0
- package/src/interfaces/viewers/NetworkStakeViewer/RewardsByPositionViewer.ts +7 -0
- package/src/interfaces/viewers/NetworkStakeViewer/RewardsByStakerViewer.ts +9 -0
- package/src/interfaces/viewers/NetworkStakeViewer/RewardsByStepViewer.ts +9 -0
- package/src/interfaces/viewers/NetworkStakeViewer/RewardsTotalViewer.ts +9 -0
- package/src/interfaces/viewers/NetworkStakeViewer/RewardsViewerMethodsTemplate.ts +9 -0
- package/src/interfaces/viewers/NetworkStakeViewer/RewardsViewerOptions.ts +18 -0
- package/src/interfaces/viewers/NetworkStakeViewer/StepRewardsViewer.ts +13 -0
- package/src/interfaces/viewers/NetworkStakeViewer/StepViewer.ts +42 -0
- package/src/interfaces/viewers/NetworkStakeViewer/index.ts +13 -0
- package/src/interfaces/viewers/Stake.ts +22 -0
- package/src/interfaces/viewers/StakeTotalsViewer.ts +12 -0
- package/src/interfaces/viewers/StakeViewer.ts +13 -0
- package/src/interfaces/viewers/StepStake.ts +19 -0
- package/src/interfaces/viewers/TimeSync.ts +19 -0
- package/src/interfaces/viewers/Transaction.ts +9 -0
- package/src/interfaces/viewers/TransferBalance.ts +29 -0
- package/src/interfaces/viewers/index.ts +14 -0
- package/src/model/ChainStake/ChainStakeRead.ts +2 -1
- package/src/model/summary.ts +3 -2
- package/src/provider/TransactionHelper.ts +14 -0
- package/src/provider/TransactionSubmitter.ts +26 -0
- package/src/provider/XyoClient.ts +21 -0
- package/src/provider/XyoConnection.ts +55 -0
- package/src/provider/XyoDataLake.ts +43 -0
- package/src/provider/XyoGateway.ts +21 -0
- package/src/provider/XyoGatewayHelpers.ts +30 -0
- package/src/provider/XyoNetwork.ts +6 -0
- package/src/provider/XyoRunner.ts +7 -0
- package/src/provider/XyoSigner.ts +29 -0
- package/src/provider/XyoViewer.ts +17 -0
- package/src/provider/XyoWallet.ts +15 -0
- package/src/provider/index.ts +12 -0
- package/src/provider/permissions/InvokerPermission.ts +56 -0
- package/src/provider/permissions/XyoPermissions.ts +40 -0
- package/src/provider/permissions/index.ts +2 -0
- package/src/services/AccountBalanceService.ts +22 -0
- package/src/services/AccountTransfersService.ts +12 -0
- package/src/services/BlockProducerService.ts +10 -0
- package/src/services/BlockRewardService.ts +8 -0
- package/src/services/BlockRewardServiceV2.ts +8 -0
- package/src/services/Chain/BaseChainService.ts +7 -0
- package/src/services/Chain/ChainHeadService.ts +7 -0
- package/src/services/Chain/ChainService.ts +6 -0
- package/src/services/Chain/index.ts +4 -0
- package/src/services/Chain/interfaces/ChainContractViewer.ts +5 -0
- package/src/services/Chain/interfaces/ChainStakeViewer.ts +6 -0
- package/src/services/Chain/interfaces/ChainStaker.ts +5 -0
- package/src/services/Chain/interfaces/index.ts +3 -0
- package/src/services/ChainIterator/ChainIteratorService.ts +45 -0
- package/src/services/ChainIterator/ChainIteratorServiceEventData.ts +13 -0
- package/src/services/ChainIterator/index.ts +2 -0
- package/src/services/Election.ts +15 -0
- package/src/services/NetworkStakeService.ts +4 -0
- package/src/services/Params.ts +11 -0
- package/src/services/PendingTransactionsService.ts +8 -0
- package/src/services/Service.ts +5 -0
- package/src/services/StakeIntentService/ChainIndexingServiceStateSchema.ts +43 -0
- package/src/services/StakeIntentService/StakeIntentService.ts +36 -0
- package/src/services/StakeIntentService/index.ts +2 -0
- package/src/services/StepStakeService.ts +4 -0
- package/src/services/TimeSyncService.ts +6 -0
- package/src/services/index.ts +14 -0
- package/src/transaction/confirmSubmittedTransaction.ts +3 -3
- package/src/validation/block/BlockValidationFunction.ts +9 -0
- package/src/validation/block/HydratedBlockStateValidationFunction.ts +24 -0
- package/src/validation/block/HydratedBlockValidationFunction.ts +15 -0
- package/src/validation/block/error.spec.ts +20 -0
- package/src/validation/block/error.ts +46 -0
- package/src/validation/block/index.ts +4 -0
- package/src/validation/index.ts +1 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
|
+
import type { Promisable } from '@xylabs/promise'
|
|
3
|
+
import type { Signed, UnsignedBoundWitness } from '@xyo-network/boundwitness-model'
|
|
4
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
5
|
+
import type {
|
|
6
|
+
AllowedBlockPayload, ChainId, TransactionBoundWitness,
|
|
7
|
+
TransactionFeesBigInt,
|
|
8
|
+
} from '@xyo-network/xl1-protocol'
|
|
9
|
+
|
|
10
|
+
export interface XyoSigner {
|
|
11
|
+
address(): Promisable<Address>
|
|
12
|
+
// The tx passed in must have all the payloads (on and off chain) in the payloads array
|
|
13
|
+
// Returns the signed transaction and the payloads array excluding the off-chain payloads.
|
|
14
|
+
// The return value is ready to be broadcast to block producers
|
|
15
|
+
signTransaction(tx: [UnsignedBoundWitness<TransactionBoundWitness>, Payload[]]): Promisable<[Signed<TransactionBoundWitness>, Payload[]]>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface XyoSignerDeprecated {
|
|
19
|
+
/** @deprecated use signTransaction instead */
|
|
20
|
+
createSignedTransaction(
|
|
21
|
+
chain: ChainId,
|
|
22
|
+
elevatedPayloads: AllowedBlockPayload[],
|
|
23
|
+
additionalPayloads: Payload[],
|
|
24
|
+
nbf: number,
|
|
25
|
+
exp: number,
|
|
26
|
+
fees: TransactionFeesBigInt,
|
|
27
|
+
from?: Address,
|
|
28
|
+
): Promisable<Signed<TransactionBoundWitness>>
|
|
29
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AccountBalanceViewInterface, BlockViewInterface, ChainViewInterface,
|
|
3
|
+
ForkViewer,
|
|
4
|
+
NetworkStakeStepRewardViewInterface,
|
|
5
|
+
NetworkStakeViewer,
|
|
6
|
+
StakeViewer,
|
|
7
|
+
TransactionViewInterface, TransferBalanceViewInterface,
|
|
8
|
+
} from '../interfaces/index.ts'
|
|
9
|
+
|
|
10
|
+
export interface XyoViewerMethods extends AccountBalanceViewInterface, TransferBalanceViewInterface,
|
|
11
|
+
NetworkStakeStepRewardViewInterface,
|
|
12
|
+
ChainViewInterface, BlockViewInterface, TransactionViewInterface, StakeViewer, ForkViewer {
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface XyoViewer extends XyoViewerMethods {
|
|
16
|
+
networkStakeViewer?: NetworkStakeViewer
|
|
17
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
|
+
import type { Promisable } from '@xylabs/promise'
|
|
3
|
+
import type { ChainId } from '@xyo-network/xl1-protocol'
|
|
4
|
+
|
|
5
|
+
/** @deprecated - use XyoClient instead */
|
|
6
|
+
export interface XyoWallet {
|
|
7
|
+
accounts(): Promisable<Address[]>
|
|
8
|
+
addChain(chain: ChainId, name?: string): Promisable<object>
|
|
9
|
+
chain(): Promisable<ChainId>
|
|
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: ChainId): Promisable<void>
|
|
15
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './permissions/index.ts'
|
|
2
|
+
export * from './TransactionSubmitter.ts'
|
|
3
|
+
export * from './XyoClient.ts'
|
|
4
|
+
export * from './XyoConnection.ts'
|
|
5
|
+
export * from './XyoDataLake.ts'
|
|
6
|
+
export * from './XyoGateway.ts'
|
|
7
|
+
export * from './XyoGatewayHelpers.ts'
|
|
8
|
+
export * from './XyoNetwork.ts'
|
|
9
|
+
export * from './XyoRunner.ts'
|
|
10
|
+
export * from './XyoSigner.ts'
|
|
11
|
+
export * from './XyoViewer.ts'
|
|
12
|
+
export * from './XyoWallet.ts'
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { JsonValue } from '@xylabs/object'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Modeled after EIP-2255
|
|
5
|
+
* See - https://eips.ethereum.org/EIPS/eip-2255#specification
|
|
6
|
+
*
|
|
7
|
+
* NOTE: In order to send multiple permission requests at once, do not send multiple parentCapability keys.
|
|
8
|
+
* Instead, send multiple PermissionRequest objects in the params array of the rpc call.
|
|
9
|
+
*/
|
|
10
|
+
export interface PermissionRequest {
|
|
11
|
+
[parentCapability: string]: {
|
|
12
|
+
[caveatName: string]: JsonValue
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Modeled after EIP-2255
|
|
18
|
+
* See - https://eips.ethereum.org/EIPS/eip-2255#specification
|
|
19
|
+
*/
|
|
20
|
+
export interface RequestedPermission {
|
|
21
|
+
/** Optional timestamp for when the permission was granted */
|
|
22
|
+
date?: number
|
|
23
|
+
/** Permission identifier (i.e. RPC method, action, etc.) */
|
|
24
|
+
parentCapability: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type CaveatTypes = 'chain' | 'expiration' | 'filteredResponse' | 'rateLimit' | 'restrictReturnedAccounts'
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Modeled after EIP-2255
|
|
31
|
+
* See - https://eips.ethereum.org/EIPS/eip-2255#specification
|
|
32
|
+
*/
|
|
33
|
+
export interface Caveats {
|
|
34
|
+
/** Type of caveat */
|
|
35
|
+
type: CaveatTypes
|
|
36
|
+
/** Value for the caveat (i.e. chain id, subset of accounts, expiration, max request per minute, etc.) */
|
|
37
|
+
value: JsonValue
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Modeled after EIP-2255
|
|
42
|
+
* See - https://eips.ethereum.org/EIPS/eip-2255#specification
|
|
43
|
+
*/
|
|
44
|
+
export interface Permission {
|
|
45
|
+
/** Caveats for the permission, if applicable (i.e. allowed accounts, signing, etc.) */
|
|
46
|
+
caveats?: Caveats[]
|
|
47
|
+
/** Invoker for the given permission (URI, domain, webpage, address, etc.) */
|
|
48
|
+
invoker: string
|
|
49
|
+
/** Permission identifier (i.e. RPC method, action, etc.) */
|
|
50
|
+
parentCapability: string
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface InvokerPermission extends Permission {
|
|
54
|
+
/** Time at which the permission was granted */
|
|
55
|
+
date?: number
|
|
56
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
InvokerPermission, PermissionRequest, RequestedPermission,
|
|
3
|
+
} from './InvokerPermission.ts'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Handles Getting Permissions
|
|
7
|
+
*/
|
|
8
|
+
export interface PermissionsGetHandler {
|
|
9
|
+
/**
|
|
10
|
+
* Returns the permissions that are currently granted
|
|
11
|
+
*
|
|
12
|
+
* Per the spec - "The wallet_getPermissions method is used for getting an array of current permissions
|
|
13
|
+
* (empty by default). It takes no parameters and returns an array of Permission objects."
|
|
14
|
+
*
|
|
15
|
+
* See - https://eips.ethereum.org/EIPS/eip-2255#specification
|
|
16
|
+
*/
|
|
17
|
+
getPermissions(): Promise<InvokerPermission[]>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Handles Permission Requests
|
|
22
|
+
*/
|
|
23
|
+
export interface PermissionRequestsHandler {
|
|
24
|
+
// Given a permissions request, attempts to request the permissions from the user
|
|
25
|
+
requestPermissions(permissions: PermissionRequest[]): Promise<RequestedPermission[]>
|
|
26
|
+
// Given a permissions request, attempts to revoke the permissions from the user
|
|
27
|
+
revokePermissions(permissions: PermissionRequest): Promise<RequestedPermission[]>
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Interface for getting, requesting and revoking permissions
|
|
32
|
+
*
|
|
33
|
+
* See - https://eips.ethereum.org/EIPS/eip-2255
|
|
34
|
+
*/
|
|
35
|
+
export interface XyoPermissions extends PermissionsGetHandler, PermissionRequestsHandler {
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// @deprecated - use XyoPermissions instead
|
|
40
|
+
export interface PermissionsProvider extends XyoPermissions {}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Address, Hash, Hex,
|
|
3
|
+
} from '@xylabs/hex'
|
|
4
|
+
import type { Promisable } from '@xylabs/promise'
|
|
5
|
+
import type { AttoXL1 } from '@xyo-network/xl1-protocol'
|
|
6
|
+
|
|
7
|
+
import type { ServiceInterface } from './Service.ts'
|
|
8
|
+
|
|
9
|
+
export interface AccountBalanceProvider {
|
|
10
|
+
getBalanceValue: (address: Address) => bigint
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface AccountBalanceService extends AccountBalanceProvider, ServiceInterface {
|
|
14
|
+
getBalanceValues?: Record<Address, bigint>
|
|
15
|
+
|
|
16
|
+
getBalance(address: Address): Hex
|
|
17
|
+
getBalances(): Record<Address, Hex>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface AccountBalanceServiceV2 extends ServiceInterface {
|
|
21
|
+
balances(head: Hash, addresses: Address[]): Promisable<Partial<Record<Address, AttoXL1>>>
|
|
22
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Address, Hash } from '@xylabs/hex'
|
|
2
|
+
import type { Promisable } from '@xylabs/promise'
|
|
3
|
+
import type { AttoXL1 } from '@xyo-network/xl1-protocol'
|
|
4
|
+
|
|
5
|
+
import type { ServiceInterface } from './Service.ts'
|
|
6
|
+
|
|
7
|
+
export interface AccountTransfersProvider {
|
|
8
|
+
transfer(head: Hash, account: Address): Promisable<AttoXL1>
|
|
9
|
+
transfers(head: Hash, accounts: Address[]): Promisable<Partial<Record<Address, AttoXL1>>>
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface AccountTransfersService extends AccountTransfersProvider, ServiceInterface {}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Addressable,
|
|
3
|
+
BlockBoundWitness, HydratedBlock, IterableRepository,
|
|
4
|
+
} from '@xyo-network/xl1-protocol'
|
|
5
|
+
|
|
6
|
+
import type { ServiceInterface } from './Service.ts'
|
|
7
|
+
|
|
8
|
+
export type NextBlockProducer = IterableRepository<BlockBoundWitness, HydratedBlock | undefined>
|
|
9
|
+
|
|
10
|
+
export interface BlockProducerService extends Addressable, NextBlockProducer, ServiceInterface {}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Promisable } from '@xylabs/promise'
|
|
2
|
+
|
|
3
|
+
import type { ServiceInterface } from './Service.ts'
|
|
4
|
+
|
|
5
|
+
export interface BlockRewardService extends ServiceInterface {
|
|
6
|
+
// The amount of xl1 to send to the producer from the block reward
|
|
7
|
+
getRewardForBlock(block: bigint): Promisable<bigint>
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Promisable } from '@xylabs/promise'
|
|
2
|
+
|
|
3
|
+
import type { BlockRewardService } from './BlockRewardService.ts'
|
|
4
|
+
|
|
5
|
+
export interface BlockRewardServiceV2 extends BlockRewardService {
|
|
6
|
+
// The amount of xl1 to send to the step pool from the block reward
|
|
7
|
+
getRewardForStepPool(block: bigint): Promisable<bigint>
|
|
8
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BaseChainService } from './BaseChainService.ts'
|
|
2
|
+
import type {
|
|
3
|
+
ChainContractViewer, ChainStaker, ChainStakeViewer,
|
|
4
|
+
} from './interfaces/index.ts'
|
|
5
|
+
|
|
6
|
+
export interface ChainService extends ChainContractViewer, ChainStakeViewer, ChainStaker, BaseChainService {}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { BaseParams } from '@xylabs/base'
|
|
2
|
+
import type { BaseEmitter } from '@xylabs/events'
|
|
3
|
+
import type { Hash } from '@xylabs/hex'
|
|
4
|
+
import type { WithStorageMeta } from '@xyo-network/payload-model'
|
|
5
|
+
import type {
|
|
6
|
+
BlockBoundWitness, ChainId, IterableRepository, ReadRepository,
|
|
7
|
+
} from '@xyo-network/xl1-protocol'
|
|
8
|
+
|
|
9
|
+
import type { ChainIteratorServiceEventData } from './ChainIteratorServiceEventData.ts'
|
|
10
|
+
|
|
11
|
+
export interface ChainIteratorService<TKey>
|
|
12
|
+
extends ReadRepository<TKey, BlockBoundWitness | undefined>, IterableRepository<TKey, WithStorageMeta<BlockBoundWitness> | undefined> {
|
|
13
|
+
chainId: ChainId
|
|
14
|
+
head(): Promise<WithStorageMeta<BlockBoundWitness>>
|
|
15
|
+
previous(cursor?: TKey | undefined, limit?: number): Promise<WithStorageMeta<BlockBoundWitness>[]>
|
|
16
|
+
updateHead(head: BlockBoundWitness): Promise<void>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// /** @deprecated use ChainIteratorService instead */
|
|
20
|
+
// export interface ChainIterator<TKey> extends ChainIteratorService<TKey> {}
|
|
21
|
+
|
|
22
|
+
export interface EventingChainIteratorService<TKey> extends ChainIteratorService<TKey>, BaseEmitter<BaseParams, ChainIteratorServiceEventData> {}
|
|
23
|
+
|
|
24
|
+
// /** @deprecated use EventingChainIteratorService instead */
|
|
25
|
+
// export interface EventingChainIterator<TKey> extends EventingChainIteratorService<TKey> {}
|
|
26
|
+
|
|
27
|
+
export interface ChainBlockNumberIteratorService extends ChainIteratorService<number> {}
|
|
28
|
+
|
|
29
|
+
// /** @deprecated use ChainBlockNumberIteratorService instead */
|
|
30
|
+
// export interface ChainBlockNumberIterator extends ChainBlockNumberIteratorService {}
|
|
31
|
+
|
|
32
|
+
export interface EventingChainBlockNumberIteratorService extends EventingChainIteratorService<number> {}
|
|
33
|
+
|
|
34
|
+
// /** @deprecated use EventingChainBlockNumberIteratorService instead */
|
|
35
|
+
// export interface EventingChainBlockNumberIterator extends EventingChainBlockNumberIteratorService {}
|
|
36
|
+
|
|
37
|
+
export interface ChainHashIteratorService extends ChainIteratorService<Hash> {}
|
|
38
|
+
|
|
39
|
+
// /** @deprecated use ChainHashIteratorService instead */
|
|
40
|
+
// export interface ChainHashIterator extends ChainHashIteratorService {}
|
|
41
|
+
|
|
42
|
+
export interface EventingChainHashIteratorService extends EventingChainIteratorService<Hash> {}
|
|
43
|
+
|
|
44
|
+
// /** @deprecated use EventingChainHashIteratorService instead */
|
|
45
|
+
// export interface EventingChainHashIterator extends EventingChainHashIteratorService {}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { EventData } from '@xylabs/events'
|
|
2
|
+
import type { BlockBoundWitness } from '@xyo-network/xl1-protocol'
|
|
3
|
+
|
|
4
|
+
export type HeadEventArgs = { blocks: [BlockBoundWitness] }
|
|
5
|
+
|
|
6
|
+
export interface HeadEventData extends EventData {
|
|
7
|
+
headUpdated: HeadEventArgs
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ChainIteratorServiceEventData extends HeadEventData { }
|
|
11
|
+
|
|
12
|
+
// /** @deprecated use ChainIteratorServiceEventData instead */
|
|
13
|
+
// export interface ChainIteratorEventData extends ChainIteratorServiceEventData { }
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
|
+
import type { WithHashMeta } from '@xyo-network/payload-model'
|
|
3
|
+
import type { BlockBoundWitness } from '@xyo-network/xl1-protocol'
|
|
4
|
+
|
|
5
|
+
import type { ServiceInterface } from './Service.ts'
|
|
6
|
+
|
|
7
|
+
export interface ElectionService extends ServiceInterface {
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Given the current block, get the leader for the next block
|
|
11
|
+
* @param current The previous block
|
|
12
|
+
*/
|
|
13
|
+
getCreatorCommitteeForNextBlock(current: WithHashMeta<BlockBoundWitness>): Promise<Address[]>
|
|
14
|
+
|
|
15
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CreatableParams } from '@xylabs/creatable'
|
|
2
|
+
import type { AccountInstance } from '@xyo-network/account-model'
|
|
3
|
+
import type { OpenTelemetryProviders } from '@xyo-network/xl1-protocol'
|
|
4
|
+
|
|
5
|
+
export interface BaseServiceParams extends CreatableParams, OpenTelemetryProviders {
|
|
6
|
+
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface BaseAccountableServiceParams extends BaseServiceParams {
|
|
10
|
+
account: AccountInstance
|
|
11
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Hash } from '@xylabs/hex'
|
|
2
|
+
import type { SignedHydratedTransaction } from '@xyo-network/xl1-protocol'
|
|
3
|
+
|
|
4
|
+
import type { ServiceInterface } from './Service.ts'
|
|
5
|
+
|
|
6
|
+
export interface PendingTransactionsService extends ServiceInterface {
|
|
7
|
+
getPendingTransactions(head: Hash, limit: number, timeout?: number): Promise<SignedHydratedTransaction[]>
|
|
8
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
|
+
import type { Intent } from '@xyo-network/xl1-protocol'
|
|
3
|
+
|
|
4
|
+
import type { ServiceInterface } from '../Service.ts'
|
|
5
|
+
|
|
6
|
+
export interface StakeIntentService extends ServiceInterface {
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Gets the declared ranges for an address based on historical on-chain data
|
|
10
|
+
* @param address The address to get the declared ranges for
|
|
11
|
+
* @param intent The declared intent to filter for
|
|
12
|
+
*/
|
|
13
|
+
getDeclaredCandidateRanges(address: Address, intent: Intent): Promise<Readonly<Readonly<[number, number]>[]>>
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Gets the declared candidates for a block based on historical on-chain data
|
|
17
|
+
* @param block The block number to get the declared candidates for
|
|
18
|
+
* @param intent The declared intent to filter for
|
|
19
|
+
*/
|
|
20
|
+
getDeclaredCandidatesForBlock(block: number, intent: Intent): Promise<Address[]>
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Gets the required minimum stake for a given intent
|
|
24
|
+
* @param intent The declared intent to filter for
|
|
25
|
+
* @returns The required minimum stake for the intent
|
|
26
|
+
*/
|
|
27
|
+
getRequiredMinimumStakeForIntent(intent: Intent): bigint
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Checks if the address is staked for a block for a given intent
|
|
31
|
+
* @param block The block number to check
|
|
32
|
+
* @param intent The declared intent to filter for
|
|
33
|
+
* @param address The address to check
|
|
34
|
+
*/
|
|
35
|
+
isStakedForBlock(block: number, intent: Intent, address: Address): Promise<boolean>
|
|
36
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TimeSyncViewInterface, TimeSyncViewInterfaceV2 } from '../interfaces/index.ts'
|
|
2
|
+
import type { ServiceInterface } from './Service.ts'
|
|
3
|
+
|
|
4
|
+
export interface TimeSyncService extends ServiceInterface, TimeSyncViewInterface {}
|
|
5
|
+
|
|
6
|
+
export interface TimeSyncServiceV2 extends ServiceInterface, TimeSyncViewInterfaceV2 {}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './AccountBalanceService.ts'
|
|
2
|
+
export * from './AccountTransfersService.ts'
|
|
3
|
+
export * from './BlockProducerService.ts'
|
|
4
|
+
export * from './BlockRewardService.ts'
|
|
5
|
+
export * from './BlockRewardServiceV2.ts'
|
|
6
|
+
export * from './Chain/index.ts'
|
|
7
|
+
export * from './ChainIterator/index.ts'
|
|
8
|
+
export * from './Election.ts'
|
|
9
|
+
export * from './NetworkStakeService.ts'
|
|
10
|
+
export * from './PendingTransactionsService.ts'
|
|
11
|
+
export * from './Service.ts'
|
|
12
|
+
export * from './StakeIntentService/index.ts'
|
|
13
|
+
export * from './StepStakeService.ts'
|
|
14
|
+
export * from './TimeSyncService.ts'
|
|
@@ -3,9 +3,9 @@ import type { Logger } from '@xylabs/logger'
|
|
|
3
3
|
import { isDefined } from '@xylabs/typeof'
|
|
4
4
|
import type { Signed } from '@xyo-network/boundwitness-model'
|
|
5
5
|
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
6
|
-
import type {
|
|
7
|
-
|
|
8
|
-
} from '
|
|
6
|
+
import type { SignedHydratedTransaction, TransactionBoundWitness } from '@xyo-network/xl1-protocol'
|
|
7
|
+
|
|
8
|
+
import type { XyoViewer } from '../provider/index.ts'
|
|
9
9
|
|
|
10
10
|
const DEFAULT_CONFIRMATION_ATTEMPTS = 20
|
|
11
11
|
const DEFAULT_DELAY_BETWEEN_ATTEMPTS = 1000 // milliseconds
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Promisable } from '@xylabs/promise'
|
|
2
|
+
import type { BlockBoundWitness, ChainId } from '@xyo-network/xl1-protocol'
|
|
3
|
+
|
|
4
|
+
import type { BlockValidationError } from './error.ts'
|
|
5
|
+
|
|
6
|
+
export type BlockValidatorFunction = (
|
|
7
|
+
block: BlockBoundWitness,
|
|
8
|
+
chainId?: ChainId,
|
|
9
|
+
) => Promisable<BlockValidationError[]>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Promisable } from '@xylabs/promise'
|
|
2
|
+
import type { ChainId, HydratedBlock } from '@xyo-network/xl1-protocol'
|
|
3
|
+
|
|
4
|
+
import type { AccountBalanceService, AccountBalanceServiceV2 } from '../../services/index.ts'
|
|
5
|
+
import type { HydratedBlockStateValidationError } from './error.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: ChainId,
|
|
17
|
+
services: { accountBalance: AccountBalanceService },
|
|
18
|
+
) => Promisable<HydratedBlockStateValidationError[]>
|
|
19
|
+
|
|
20
|
+
export type HydratedBlockStateValidationFunctionV2 = (
|
|
21
|
+
hydratedBlock: HydratedBlock,
|
|
22
|
+
chainId: ChainId,
|
|
23
|
+
services: { accountBalance: AccountBalanceServiceV2 },
|
|
24
|
+
) => Promisable<HydratedBlockStateValidationError[]>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Promisable } from '@xylabs/promise'
|
|
2
|
+
import type { ChainId, HydratedBlock } from '@xyo-network/xl1-protocol'
|
|
3
|
+
|
|
4
|
+
import type { HydratedBlockValidationError } from './error.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 HydratedBlockValidationFunction = (
|
|
13
|
+
hydratedBlock: HydratedBlock,
|
|
14
|
+
chainId?: ChainId,
|
|
15
|
+
) => Promisable<HydratedBlockValidationError[]>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Address, Hash } from '@xylabs/hex'
|
|
2
|
+
import type { HydratedBlock } from '@xyo-network/xl1-protocol'
|
|
3
|
+
import {
|
|
4
|
+
describe, expect, it,
|
|
5
|
+
} from 'vitest'
|
|
6
|
+
|
|
7
|
+
import { HydratedBlockStateValidationError } from './error.ts'
|
|
8
|
+
|
|
9
|
+
describe('HydratedBlockStateValidationError', () => {
|
|
10
|
+
it('should be able display chainId', () => {
|
|
11
|
+
const error: HydratedBlockStateValidationError = new HydratedBlockStateValidationError(
|
|
12
|
+
'2234567890abcdef1234567890abcdef12345678' as Hash, // Mock Hash
|
|
13
|
+
'1234567890abcdef1234567890abcdef12345678' as Address, // Mock Address
|
|
14
|
+
{} as HydratedBlock, // Mock HydratedBlock
|
|
15
|
+
'Test Error',
|
|
16
|
+
[new Error('Inner error')],
|
|
17
|
+
)
|
|
18
|
+
expect(error).toBeDefined()
|
|
19
|
+
})
|
|
20
|
+
})
|