@xyo-network/xl1-protocol-sdk 1.15.28 → 1.16.1
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 +239 -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/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 +14 -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/RecordKeyType.d.ts +2 -0
- package/dist/neutral/model/RecordKeyType.d.ts.map +1 -0
- package/dist/neutral/model/index.d.ts +1 -0
- package/dist/neutral/model/index.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/DataLake.d.ts +11 -0
- package/dist/neutral/provider/DataLake.d.ts.map +1 -0
- 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 +34 -0
- package/dist/neutral/provider/XyoConnection.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/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/provider/viewer/NetworkStake/NetworkStakeViewer.d.ts +10 -0
- package/dist/neutral/provider/viewer/NetworkStake/NetworkStakeViewer.d.ts.map +1 -0
- package/dist/neutral/provider/viewer/NetworkStake/Rewards/ByPositionViewer.d.ts +7 -0
- package/dist/neutral/provider/viewer/NetworkStake/Rewards/ByPositionViewer.d.ts.map +1 -0
- package/dist/neutral/provider/viewer/NetworkStake/Rewards/ByStakerViewer.d.ts +8 -0
- package/dist/neutral/provider/viewer/NetworkStake/Rewards/ByStakerViewer.d.ts.map +1 -0
- package/dist/neutral/provider/viewer/NetworkStake/Rewards/ByStepViewer.d.ts +8 -0
- package/dist/neutral/provider/viewer/NetworkStake/Rewards/ByStepViewer.d.ts.map +1 -0
- package/dist/neutral/provider/viewer/NetworkStake/Rewards/Options.d.ts +15 -0
- package/dist/neutral/provider/viewer/NetworkStake/Rewards/Options.d.ts.map +1 -0
- package/dist/neutral/provider/viewer/NetworkStake/Rewards/TotalViewer.d.ts +8 -0
- package/dist/neutral/provider/viewer/NetworkStake/Rewards/TotalViewer.d.ts.map +1 -0
- package/dist/neutral/provider/viewer/NetworkStake/Rewards/Viewer.d.ts +13 -0
- package/dist/neutral/provider/viewer/NetworkStake/Rewards/Viewer.d.ts.map +1 -0
- package/dist/neutral/provider/viewer/NetworkStake/Rewards/index.d.ts +8 -0
- package/dist/neutral/provider/viewer/NetworkStake/Rewards/index.d.ts.map +1 -0
- package/dist/neutral/provider/viewer/NetworkStake/Rewards/templates/ByIndexMethodsTemplate.d.ts +6 -0
- package/dist/neutral/provider/viewer/NetworkStake/Rewards/templates/ByIndexMethodsTemplate.d.ts.map +1 -0
- package/dist/neutral/provider/viewer/NetworkStake/Rewards/templates/MethodsTemplate.d.ts +9 -0
- package/dist/neutral/provider/viewer/NetworkStake/Rewards/templates/MethodsTemplate.d.ts.map +1 -0
- package/dist/neutral/provider/viewer/NetworkStake/Rewards/templates/index.d.ts +3 -0
- package/dist/neutral/provider/viewer/NetworkStake/Rewards/templates/index.d.ts.map +1 -0
- package/dist/neutral/provider/viewer/NetworkStake/index.d.ts +3 -0
- package/dist/neutral/provider/viewer/NetworkStake/index.d.ts.map +1 -0
- package/dist/neutral/provider/viewer/StepViewer.d.ts +30 -0
- package/dist/neutral/provider/viewer/StepViewer.d.ts.map +1 -0
- package/dist/neutral/provider/viewer/XyoViewer.d.ts +10 -0
- package/dist/neutral/provider/viewer/XyoViewer.d.ts.map +1 -0
- package/dist/neutral/provider/viewer/index.d.ts +4 -0
- package/dist/neutral/provider/viewer/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 +28 -25
- 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/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 +13 -0
- package/src/model/ChainStake/ChainStakeRead.ts +2 -1
- package/src/model/RecordKeyType.ts +2 -0
- package/src/model/index.ts +1 -0
- package/src/model/summary.ts +3 -2
- package/src/provider/DataLake.ts +14 -0
- 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 +54 -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/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/provider/viewer/NetworkStake/NetworkStakeViewer.ts +12 -0
- package/src/provider/viewer/NetworkStake/Rewards/ByPositionViewer.ts +9 -0
- package/src/provider/viewer/NetworkStake/Rewards/ByStakerViewer.ts +10 -0
- package/src/provider/viewer/NetworkStake/Rewards/ByStepViewer.ts +10 -0
- package/src/provider/viewer/NetworkStake/Rewards/Options.ts +18 -0
- package/src/provider/viewer/NetworkStake/Rewards/TotalViewer.ts +9 -0
- package/src/provider/viewer/NetworkStake/Rewards/Viewer.ts +13 -0
- package/src/provider/viewer/NetworkStake/Rewards/index.ts +7 -0
- package/src/provider/viewer/NetworkStake/Rewards/templates/ByIndexMethodsTemplate.ts +7 -0
- package/src/provider/viewer/NetworkStake/Rewards/templates/MethodsTemplate.ts +9 -0
- package/src/provider/viewer/NetworkStake/Rewards/templates/index.ts +2 -0
- package/src/provider/viewer/NetworkStake/index.ts +4 -0
- package/src/provider/viewer/StepViewer.ts +47 -0
- package/src/provider/viewer/XyoViewer.ts +19 -0
- package/src/provider/viewer/index.ts +3 -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,10 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
|
+
|
|
3
|
+
export interface ChainContractViewInterface {
|
|
4
|
+
forkedAtBlockNumber(): Promise<bigint>
|
|
5
|
+
forkedAtHash(): Promise<bigint>
|
|
6
|
+
forkedChainId(): Promise<Address>
|
|
7
|
+
minWithdrawalBlocks(): Promise<bigint>
|
|
8
|
+
rewardsContract(): Promise<string>
|
|
9
|
+
stakingTokenAddress(): Promise<string>
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Promisable } from '@xylabs/promise'
|
|
2
|
+
import type { ChainId } from '@xyo-network/xl1-protocol'
|
|
3
|
+
|
|
4
|
+
export type ForkHistory = Record<number, ChainId>
|
|
5
|
+
|
|
6
|
+
export interface ForkViewer {
|
|
7
|
+
chainIdAtBlock(blockNumber: number): Promisable<ChainId | undefined>
|
|
8
|
+
forkHistory(): Promisable<ForkHistory>
|
|
9
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
|
+
import type { Promisable } from '@xylabs/promise'
|
|
3
|
+
import type { StepIdentity, StepIdentityString } from '@xyo-network/xl1-protocol'
|
|
4
|
+
|
|
5
|
+
export interface NetworkStakeStepAddressRewardViewInterface {
|
|
6
|
+
// the step rewards for a specific network stakers for all of history
|
|
7
|
+
networkStakeStepRewardAddressHistory(address: Address): Promisable<Record<Address, bigint>>
|
|
8
|
+
|
|
9
|
+
// the step rewards for a specific network stakers for a given step and block
|
|
10
|
+
networkStakeStepRewardAddressReward(context: StepIdentity, address: Address): Promisable<Record<Address, bigint>>
|
|
11
|
+
|
|
12
|
+
// the shares for a specific network staker for a given step and block
|
|
13
|
+
networkStakeStepRewardAddressShare(context: StepIdentity, address: Address): Promisable<[/* address shares */bigint, /* total shares */bigint]>
|
|
14
|
+
|
|
15
|
+
// estimate the current reward weight for a given address at a given step
|
|
16
|
+
networkStakeStepRewardWeightForAddress(context: StepIdentity, address: Address): Promisable<bigint>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface NetworkStakeStepPoolRewardViewInterface {
|
|
20
|
+
|
|
21
|
+
// all the step rewards for all the network stakers for a given step and block
|
|
22
|
+
networkStakeStepRewardPoolRewards(context: StepIdentity): Promisable<Record<Address, bigint>>
|
|
23
|
+
|
|
24
|
+
// all the shares for all the network stakers for a given step and block
|
|
25
|
+
networkStakeStepRewardPoolShares(context: StepIdentity): Promisable<Record<Address, bigint>>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface NetworkStakeStepRewardPositionViewInterface {
|
|
29
|
+
// estimate the current weight for a given position at a given step
|
|
30
|
+
networkStakeStepRewardPositionWeight(context: StepIdentity, position: number): Promisable<bigint>
|
|
31
|
+
|
|
32
|
+
// estimate the potential loss for removing a given position at a given step
|
|
33
|
+
networkStakeStepRewardPotentialPositionLoss(context: StepIdentity, position: number): Promisable<bigint>
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface NetworkStakeStepRewardViewInterface extends
|
|
37
|
+
NetworkStakeStepPoolRewardViewInterface,
|
|
38
|
+
NetworkStakeStepAddressRewardViewInterface,
|
|
39
|
+
NetworkStakeStepRewardPositionViewInterface
|
|
40
|
+
{
|
|
41
|
+
networkStakeStepRewardClaimedByAddress(address: Address): Promisable<bigint>
|
|
42
|
+
|
|
43
|
+
// the share & total rewards for a given position
|
|
44
|
+
networkStakeStepRewardForPosition(position: number, range: [number, number]): Promisable<[bigint, bigint]>
|
|
45
|
+
|
|
46
|
+
// estimate the total possible block rewards for a given step
|
|
47
|
+
networkStakeStepRewardForStep(context: StepIdentity): Promisable<bigint>
|
|
48
|
+
|
|
49
|
+
// the share & total rewards for a given step and block for a given position
|
|
50
|
+
networkStakeStepRewardForStepForPosition(context: StepIdentity, position: number): Promisable<[bigint, bigint]>
|
|
51
|
+
|
|
52
|
+
// the predictable random number for a given step and block
|
|
53
|
+
networkStakeStepRewardRandomizer(context: StepIdentity): Promisable<bigint>
|
|
54
|
+
|
|
55
|
+
// the total number of stakers for a given step and block
|
|
56
|
+
networkStakeStepRewardStakerCount(context: StepIdentity): Promisable<number>
|
|
57
|
+
|
|
58
|
+
networkStakeStepRewardUnclaimedByAddress(address: Address): Promisable<bigint>
|
|
59
|
+
|
|
60
|
+
// the share & total rewards for a given position for each step in range
|
|
61
|
+
networkStakeStepRewardsForPosition(position: number,
|
|
62
|
+
range: [number, number]): Promisable<Record<StepIdentityString, [bigint, bigint]>>
|
|
63
|
+
|
|
64
|
+
// the total rewards for a given range
|
|
65
|
+
networkStakeStepRewardsForRange(range: [number, number]): Promisable<bigint>
|
|
66
|
+
|
|
67
|
+
// the total rewards for a given range and step level
|
|
68
|
+
networkStakeStepRewardsForStepLevel(stepLevel: number, range: [number, number]): Promisable<bigint>
|
|
69
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
|
+
import type { PositionId } from '@xyo-network/xl1-protocol'
|
|
3
|
+
|
|
4
|
+
export type Position = {
|
|
5
|
+
// the block number when the stake was added
|
|
6
|
+
addBlock: number
|
|
7
|
+
// the amount that is staked
|
|
8
|
+
amount: bigint
|
|
9
|
+
// the unique id for the stake item
|
|
10
|
+
id: PositionId
|
|
11
|
+
// the block number when the stake was removed (set to 0 if not removed)
|
|
12
|
+
removeBlock: number
|
|
13
|
+
// the address that is being staked
|
|
14
|
+
staked: Address
|
|
15
|
+
// the address that owns the stake
|
|
16
|
+
staker: Address
|
|
17
|
+
// the block number when the stake was withdrawn (set to 0 if not withdrawn)
|
|
18
|
+
withdrawBlock: number
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** @deprecated - use Position instead */
|
|
22
|
+
export type Stake = Position
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
|
+
import type { Promisable } from '@xylabs/promise'
|
|
3
|
+
|
|
4
|
+
export interface StakeTotalsViewer {
|
|
5
|
+
active(): Promisable<bigint>
|
|
6
|
+
activeByStaked(staked: Address): Promisable<bigint>
|
|
7
|
+
activeByStaker(address: Address): Promisable<bigint>
|
|
8
|
+
pending(): Promisable<bigint>
|
|
9
|
+
pendingByStaker(staker: Address): Promisable<bigint>
|
|
10
|
+
withdrawn(): Promisable<bigint>
|
|
11
|
+
withdrawnByStaker(staker: Address): Promisable<bigint>
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
|
+
import type { Promisable } from '@xylabs/promise'
|
|
3
|
+
|
|
4
|
+
import type { Position } from './Stake.ts'
|
|
5
|
+
|
|
6
|
+
export interface StakeViewer {
|
|
7
|
+
stakeById(id: number): Promisable<Position>
|
|
8
|
+
stakeByStaker(staker: Address, slot: number): Promisable<Position>
|
|
9
|
+
/* @deprecated use stakesByStaker */
|
|
10
|
+
stakedByStaker(staker: Address): Promisable<Address[]>
|
|
11
|
+
stakesByStaked(staked: Address): Promisable<Position[]>
|
|
12
|
+
stakesByStaker(staker: Address): Promisable<Position[]>
|
|
13
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
|
+
import type { Promisable } from '@xylabs/promise'
|
|
3
|
+
import type { StepIdentity } from '@xyo-network/xl1-protocol'
|
|
4
|
+
|
|
5
|
+
export interface StepStakeViewInterface {
|
|
6
|
+
// this is the prorated stake for all addresses in the step
|
|
7
|
+
stepStake: (step: StepIdentity) => Promisable<Record<Address, bigint>>
|
|
8
|
+
|
|
9
|
+
// this is the prorated stake for a specific address in the step
|
|
10
|
+
stepStakeForAddress: (address: Address, step: StepIdentity) => Promisable<bigint>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/* Prorated stake is the amount of stake that is allocated to a specific step
|
|
14
|
+
based on the total stake and the number of steps. This is used to ensure
|
|
15
|
+
that the stake is distributed fairly among all steps.
|
|
16
|
+
|
|
17
|
+
The simplest way to calculate it is to enumerate every XL1 block in the step add the current stake at that point to a counter.
|
|
18
|
+
For example, if an Address had a stake of 100 for the entire time, then the prorated stake would be 100 * number of blocks in the step.
|
|
19
|
+
*/
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Hash } from '@xylabs/hex'
|
|
2
|
+
import type { Promisable } from '@xylabs/promise'
|
|
3
|
+
import type { TimeDomain, TimePayload } from '@xyo-network/xl1-protocol'
|
|
4
|
+
|
|
5
|
+
export interface TimeSyncViewInterface {
|
|
6
|
+
/** Convert time between different domains */
|
|
7
|
+
convertTime(fromDomain: TimeDomain, toDomain: TimeDomain, from: number): Promisable<number>
|
|
8
|
+
|
|
9
|
+
/** Get the current time for a given domain */
|
|
10
|
+
currentTime(domain: TimeDomain): Promisable<[string, number]>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface TimeSyncViewInterfaceV2 extends TimeSyncViewInterface {
|
|
14
|
+
/** Get the current time for a given domain */
|
|
15
|
+
currentTimeAndHash(domain: TimeDomain): Promisable<[number, Hash | null]>
|
|
16
|
+
|
|
17
|
+
/** Create a TimePayload with the current time from all configured domains */
|
|
18
|
+
currentTimePayload(): Promisable<TimePayload>
|
|
19
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Hash } from '@xylabs/hex'
|
|
2
|
+
import type { Promisable } from '@xylabs/promise'
|
|
3
|
+
import type { SignedHydratedTransaction } from '@xyo-network/xl1-protocol'
|
|
4
|
+
|
|
5
|
+
export interface TransactionViewInterface {
|
|
6
|
+
transactionByBlockHashAndIndex(blockHash: Hash, transactionIndex: number): Promisable<SignedHydratedTransaction | null>
|
|
7
|
+
transactionByBlockNumberAndIndex(blockNumber: number, transactionIndex: number): Promisable<SignedHydratedTransaction | null>
|
|
8
|
+
transactionByHash(transactionHash: Hash): Promisable<SignedHydratedTransaction | null>
|
|
9
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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 {
|
|
5
|
+
AttoXL1,
|
|
6
|
+
BlockBoundWitness, TransactionBoundWitness, Transfer,
|
|
7
|
+
XL1BlockRange,
|
|
8
|
+
} from '@xyo-network/xl1-protocol'
|
|
9
|
+
|
|
10
|
+
export type TransferBalanceHistoryItem = [
|
|
11
|
+
Signed<BlockBoundWitness> /* block */,
|
|
12
|
+
Signed<TransactionBoundWitness> | null,
|
|
13
|
+
Transfer, /* the actual transfer payload */
|
|
14
|
+
]
|
|
15
|
+
export type TransferPair = [/* from */ Address, /* to */Address]
|
|
16
|
+
|
|
17
|
+
export interface TransferBalancesViewInterface {
|
|
18
|
+
transferBalances(address: Address[]): Promisable<Partial<Record<Address, Record<Address, AttoXL1>>>>
|
|
19
|
+
transferBalancesHistories(address: Address[]): Promisable<Partial<Record<Address, Record<Address, TransferBalanceHistoryItem[]>>>>
|
|
20
|
+
transferPairBalances(address: TransferPair[]): Promisable<Partial<Record<Address, Record<Address, AttoXL1>>>>
|
|
21
|
+
transferPairBalancesHistories(address: TransferPair[]): Promisable<Partial<Record<Address, Record<Address, TransferBalanceHistoryItem[]>>>>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface TransferBalanceViewInterface {
|
|
25
|
+
transferBalance(address: Address): Promisable<AttoXL1>
|
|
26
|
+
transferBalanceHistory(address: Address, range?: XL1BlockRange): Promisable<TransferBalanceHistoryItem[]>
|
|
27
|
+
transferPairBalance(address: TransferPair): Promisable<AttoXL1>
|
|
28
|
+
transferPairBalanceHistory(address: TransferPair): Promisable<TransferBalanceHistoryItem[]>
|
|
29
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './AccountBalance.ts'
|
|
2
|
+
export * from './Block.ts'
|
|
3
|
+
export * from './Chain.ts'
|
|
4
|
+
export * from './ChainContract.ts'
|
|
5
|
+
export * from './Fork.ts'
|
|
6
|
+
export * from './NetworkStakeStepReward.ts'
|
|
7
|
+
export * from './Stake.ts'
|
|
8
|
+
export * from './StakeTotalsViewer.ts'
|
|
9
|
+
export * from './StakeViewer.ts'
|
|
10
|
+
export * from './StepStake.ts'
|
|
11
|
+
export * from './TimeSync.ts'
|
|
12
|
+
export * from './Transaction.ts'
|
|
13
|
+
export * from './TransferBalance.ts'
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Address } from '@xylabs/hex'
|
|
2
2
|
import type { Promisable } from '@xylabs/promise'
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
import type { Position } from '../../interfaces/index.ts'
|
|
4
5
|
|
|
5
6
|
export interface ChainStakeRead {
|
|
6
7
|
active(time?: number): Promisable<bigint>
|
package/src/model/index.ts
CHANGED
package/src/model/summary.ts
CHANGED
|
@@ -3,9 +3,10 @@ import type { Semaphore } from 'async-mutex'
|
|
|
3
3
|
|
|
4
4
|
import type { MapTypeRead, MapTypeWrite } from '../map/index.ts'
|
|
5
5
|
import type { BalancesStepSummary, TransfersStepSummary } from '../payloads/summary/index.ts'
|
|
6
|
-
import type { ChainContextRead } from './index.ts'
|
|
6
|
+
import type { BaseContext, ChainContextRead } from './index.ts'
|
|
7
7
|
|
|
8
|
-
export interface ChainSummaryContextBase<TPayload extends Payload,
|
|
8
|
+
export interface ChainSummaryContextBase<TPayload extends Payload,
|
|
9
|
+
T extends (MapTypeRead<string, TPayload> | MapTypeWrite<string, TPayload>)> extends BaseContext {
|
|
9
10
|
stepSemaphores: Semaphore[]
|
|
10
11
|
summaryMap: T
|
|
11
12
|
windowSize?: number
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Hash } from '@xylabs/hex'
|
|
2
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
3
|
+
|
|
4
|
+
import type { MapType } from '../map/index.ts'
|
|
5
|
+
|
|
6
|
+
export type DataLakeData = Payload | ArrayBuffer
|
|
7
|
+
|
|
8
|
+
export type DataLakeViewerMethods = Pick<MapType<Hash, DataLakeData>, 'get' | 'getMany' | 'has'>
|
|
9
|
+
|
|
10
|
+
export interface DataLakeViewer extends DataLakeViewerMethods {}
|
|
11
|
+
|
|
12
|
+
export type DataLakeRunnerMethods = Pick<MapType<Hash, DataLakeData>, 'set' | 'delete' | 'clear'>
|
|
13
|
+
|
|
14
|
+
export interface DataLakeRunner extends DataLakeViewerMethods, DataLakeRunnerMethods {}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/member-ordering */
|
|
2
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
3
|
+
import type { UnsignedHydratedTransaction } from '@xyo-network/xl1-protocol'
|
|
4
|
+
|
|
5
|
+
export interface TransactionHelper {
|
|
6
|
+
// build tx, sign tx, send tx
|
|
7
|
+
addPayloadsToChain(onChain: Payload[], offChain: Payload[]): void
|
|
8
|
+
|
|
9
|
+
// sign tx, send tx
|
|
10
|
+
addUnsignedTransactionToChain(tx: UnsignedHydratedTransaction): void
|
|
11
|
+
|
|
12
|
+
// send tx (primitive)
|
|
13
|
+
addSignedTransactionToChain(tx: UnsignedHydratedTransaction): void
|
|
14
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Address, Hex } from '@xylabs/hex'
|
|
2
|
+
import type { Promisable } from '@xylabs/promise'
|
|
3
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
4
|
+
import type {
|
|
5
|
+
AllowedBlockPayload, SignedHydratedTransaction, TransactionFeesBigInt,
|
|
6
|
+
} from '@xyo-network/xl1-protocol'
|
|
7
|
+
|
|
8
|
+
/** @deprecated use TransactionOptions instead */
|
|
9
|
+
export interface TransactionSubmitterOptions {
|
|
10
|
+
chain?: Hex
|
|
11
|
+
exp?: number
|
|
12
|
+
fees?: TransactionFeesBigInt
|
|
13
|
+
from?: Address
|
|
14
|
+
nbf?: number
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** @deprecated use XyoGatewayHelpers instead */
|
|
18
|
+
export interface TransactionSubmitter {
|
|
19
|
+
/** @deprecated use runner.broadcastTransaction */
|
|
20
|
+
submitTransaction(
|
|
21
|
+
elevatedPayloads: AllowedBlockPayload[],
|
|
22
|
+
additionalPayloads: Payload[],
|
|
23
|
+
// eslint-disable-next-line sonarjs/deprecation
|
|
24
|
+
options?: TransactionSubmitterOptions
|
|
25
|
+
): Promisable<SignedHydratedTransaction>
|
|
26
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { XyoPermissions } from './permissions/index.ts'
|
|
2
|
+
import type { XyoGatewayProvider } from './XyoGateway.ts'
|
|
3
|
+
|
|
4
|
+
export type GatewayName = string & { __gatewayName: true }
|
|
5
|
+
|
|
6
|
+
export interface XyoGatewayConfig {
|
|
7
|
+
name: GatewayName
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface XyoRpcGatewayConfig extends XyoGatewayConfig {
|
|
11
|
+
dataLakeEndpoint: string
|
|
12
|
+
networkEndpoint: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface XyoClient {
|
|
16
|
+
gateways: Readonly<Record<GatewayName, XyoGatewayProvider>>
|
|
17
|
+
permissions: XyoPermissions
|
|
18
|
+
|
|
19
|
+
addGateway?(providerOrConfig: XyoGatewayConfig | XyoRpcGatewayConfig | XyoGatewayProvider): Promise<XyoGatewayProvider>
|
|
20
|
+
removeGateway?(name: GatewayName): Promise<void>
|
|
21
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Address, Hex } from '@xylabs/hex'
|
|
2
|
+
import type { Signed } from '@xyo-network/boundwitness-model'
|
|
3
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
4
|
+
import type {
|
|
5
|
+
AllowedBlockPayload, TransactionBoundWitness, TransactionFeesBigInt,
|
|
6
|
+
} from '@xyo-network/xl1-protocol'
|
|
7
|
+
|
|
8
|
+
import type { DataLakeRunner, DataLakeViewer } from './DataLake.ts'
|
|
9
|
+
// eslint-disable-next-line sonarjs/deprecation
|
|
10
|
+
import type { TransactionSubmitter } from './TransactionSubmitter.ts'
|
|
11
|
+
import type { NetworkStakeViewer, XyoViewer } from './viewer/index.ts'
|
|
12
|
+
import type { XyoNetwork } from './XyoNetwork.ts'
|
|
13
|
+
import type { XyoRunner } from './XyoRunner.ts'
|
|
14
|
+
import type { XyoSigner } from './XyoSigner.ts'
|
|
15
|
+
// eslint-disable-next-line sonarjs/deprecation
|
|
16
|
+
import type { XyoWallet } from './XyoWallet.ts'
|
|
17
|
+
|
|
18
|
+
/** @deprecated use XyoConnectionProvider instead */
|
|
19
|
+
// eslint-disable-next-line sonarjs/deprecation
|
|
20
|
+
export interface XyoConnectionProviderDeprecated extends TransactionSubmitter {
|
|
21
|
+
|
|
22
|
+
/** @deprecated - use from gateway instead */
|
|
23
|
+
signer: XyoSigner
|
|
24
|
+
|
|
25
|
+
/** @deprecated - use host instead */
|
|
26
|
+
// eslint-disable-next-line sonarjs/deprecation
|
|
27
|
+
wallet: XyoWallet
|
|
28
|
+
|
|
29
|
+
/** @deprecated - use submitTransaction instead */
|
|
30
|
+
send(
|
|
31
|
+
elevatedPayloads: AllowedBlockPayload[],
|
|
32
|
+
additionalPayloads: Payload[],
|
|
33
|
+
chain?: Hex,
|
|
34
|
+
nbf?: number,
|
|
35
|
+
exp?: number,
|
|
36
|
+
from?: Address,
|
|
37
|
+
fees?: TransactionFeesBigInt,
|
|
38
|
+
): Promise<Signed<TransactionBoundWitness>>
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// eslint-disable-next-line sonarjs/deprecation
|
|
42
|
+
export interface XyoConnection extends Partial<XyoConnectionProviderDeprecated> {
|
|
43
|
+
network?: XyoNetwork
|
|
44
|
+
networkStake?: NetworkStakeViewer
|
|
45
|
+
runner?: XyoRunner
|
|
46
|
+
storage?: DataLakeRunner | DataLakeViewer | (DataLakeRunner & DataLakeViewer)
|
|
47
|
+
viewer?: XyoViewer
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** @deprecated use XyoConnectionProvider */
|
|
51
|
+
export interface XyoConnectionProvider extends XyoConnection {}
|
|
52
|
+
|
|
53
|
+
/** @deprecated use XyoConnectionProvider */
|
|
54
|
+
export interface XyoProvider extends XyoConnection {}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Promisable } from '@xylabs/promise'
|
|
2
|
+
|
|
3
|
+
import type { XyoConnection } from './XyoConnection.ts'
|
|
4
|
+
import type { XyoGatewayHelpers } from './XyoGatewayHelpers.ts'
|
|
5
|
+
import type { XyoSigner } from './XyoSigner.ts'
|
|
6
|
+
|
|
7
|
+
/** @deprecated use XyoConnectionConfig instead */
|
|
8
|
+
export interface XyoConnectionConfigDeprecated {
|
|
9
|
+
name: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface XyoGatewayProvider extends Partial<XyoGatewayHelpers> {
|
|
13
|
+
/**
|
|
14
|
+
* Returns the connection provider for this gateway.
|
|
15
|
+
*/
|
|
16
|
+
connection(): Promisable<XyoConnection>
|
|
17
|
+
/**
|
|
18
|
+
* Returns the signer for this gateway.
|
|
19
|
+
*/
|
|
20
|
+
signer(): Promisable<XyoSigner>
|
|
21
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Address, Hash, Hex,
|
|
3
|
+
} from '@xylabs/hex'
|
|
4
|
+
import type { Promisable } from '@xylabs/promise'
|
|
5
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
6
|
+
import type {
|
|
7
|
+
AllowedBlockPayload, TransactionBoundWitness, TransactionFeesBigInt,
|
|
8
|
+
} from '@xyo-network/xl1-protocol'
|
|
9
|
+
|
|
10
|
+
export interface TransactionOptions {
|
|
11
|
+
chain?: Hex
|
|
12
|
+
exp?: number
|
|
13
|
+
fees?: TransactionFeesBigInt
|
|
14
|
+
from?: Address
|
|
15
|
+
nbf?: number
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface XyoGatewayHelpers {
|
|
19
|
+
|
|
20
|
+
addPayloadsToChain(
|
|
21
|
+
onChain: AllowedBlockPayload[],
|
|
22
|
+
offChain: Payload[],
|
|
23
|
+
options?: TransactionOptions
|
|
24
|
+
): Promisable<[Hash, [TransactionBoundWitness, Payload[]]]>
|
|
25
|
+
|
|
26
|
+
addTransactionToChain(
|
|
27
|
+
tx: [TransactionBoundWitness, Payload[]],
|
|
28
|
+
): Promisable<Hash>
|
|
29
|
+
|
|
30
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Hash } from '@xylabs/hex'
|
|
2
|
+
import type { Promisable } from '@xylabs/promise'
|
|
3
|
+
import type { SignedHydratedTransaction } from '@xyo-network/xl1-protocol'
|
|
4
|
+
|
|
5
|
+
export interface XyoRunner {
|
|
6
|
+
broadcastTransaction(transaction: SignedHydratedTransaction): Promisable<Hash>
|
|
7
|
+
}
|
|
@@ -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,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 './DataLake.ts'
|
|
2
|
+
export * from './permissions/index.ts'
|
|
3
|
+
export * from './TransactionSubmitter.ts'
|
|
4
|
+
export * from './viewer/index.ts'
|
|
5
|
+
export * from './XyoClient.ts'
|
|
6
|
+
export * from './XyoConnection.ts'
|
|
7
|
+
export * from './XyoGateway.ts'
|
|
8
|
+
export * from './XyoGatewayHelpers.ts'
|
|
9
|
+
export * from './XyoNetwork.ts'
|
|
10
|
+
export * from './XyoRunner.ts'
|
|
11
|
+
export * from './XyoSigner.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 {}
|