@xyo-network/xl1-protocol-lib 1.26.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/LICENSE +165 -0
- package/README.md +81 -0
- package/dist/neutral/OpenTelemetryProviders.d.ts +7 -0
- package/dist/neutral/OpenTelemetryProviders.d.ts.map +1 -0
- package/dist/neutral/index.d.ts +10 -0
- package/dist/neutral/index.d.ts.map +1 -0
- package/dist/neutral/index.mjs +375 -0
- package/dist/neutral/index.mjs.map +1 -0
- package/dist/neutral/network/Status.d.ts +26 -0
- package/dist/neutral/network/Status.d.ts.map +1 -0
- package/dist/neutral/network/index.d.ts +2 -0
- package/dist/neutral/network/index.d.ts.map +1 -0
- package/dist/neutral/permissions/InvokerPermission.d.ts +53 -0
- package/dist/neutral/permissions/InvokerPermission.d.ts.map +1 -0
- package/dist/neutral/permissions/XyoPermissions.d.ts +33 -0
- package/dist/neutral/permissions/XyoPermissions.d.ts.map +1 -0
- package/dist/neutral/permissions/index.d.ts +3 -0
- package/dist/neutral/permissions/index.d.ts.map +1 -0
- package/dist/neutral/providers/DataLake/Provider.d.ts +10 -0
- package/dist/neutral/providers/DataLake/Provider.d.ts.map +1 -0
- package/dist/neutral/providers/DataLake/Runner.d.ts +15 -0
- package/dist/neutral/providers/DataLake/Runner.d.ts.map +1 -0
- package/dist/neutral/providers/DataLake/Viewer.d.ts +14 -0
- package/dist/neutral/providers/DataLake/Viewer.d.ts.map +1 -0
- package/dist/neutral/providers/DataLake/index.d.ts +4 -0
- package/dist/neutral/providers/DataLake/index.d.ts.map +1 -0
- package/dist/neutral/providers/TransactionHelper.d.ts +9 -0
- package/dist/neutral/providers/TransactionHelper.d.ts.map +1 -0
- package/dist/neutral/providers/XyoClient.d.ts +23 -0
- package/dist/neutral/providers/XyoClient.d.ts.map +1 -0
- package/dist/neutral/providers/XyoConnection.d.ts +18 -0
- package/dist/neutral/providers/XyoConnection.d.ts.map +1 -0
- package/dist/neutral/providers/XyoGateway.d.ts +20 -0
- package/dist/neutral/providers/XyoGateway.d.ts.map +1 -0
- package/dist/neutral/providers/XyoGatewayRunner.d.ts +50 -0
- package/dist/neutral/providers/XyoGatewayRunner.d.ts.map +1 -0
- package/dist/neutral/providers/XyoNetwork.d.ts +7 -0
- package/dist/neutral/providers/XyoNetwork.d.ts.map +1 -0
- package/dist/neutral/providers/XyoRunner.d.ts +16 -0
- package/dist/neutral/providers/XyoRunner.d.ts.map +1 -0
- package/dist/neutral/providers/index.d.ts +9 -0
- package/dist/neutral/providers/index.d.ts.map +1 -0
- package/dist/neutral/providers/signer/XyoSigner.d.ts +21 -0
- package/dist/neutral/providers/signer/XyoSigner.d.ts.map +1 -0
- package/dist/neutral/providers/signer/index.d.ts +2 -0
- package/dist/neutral/providers/signer/index.d.ts.map +1 -0
- package/dist/neutral/repository/Repository.d.ts +27 -0
- package/dist/neutral/repository/Repository.d.ts.map +1 -0
- package/dist/neutral/repository/TransactionReadRepository.d.ts +6 -0
- package/dist/neutral/repository/TransactionReadRepository.d.ts.map +1 -0
- package/dist/neutral/repository/TransactionRepository.d.ts +13 -0
- package/dist/neutral/repository/TransactionRepository.d.ts.map +1 -0
- package/dist/neutral/repository/TransactionRepositoryIterator.d.ts +6 -0
- package/dist/neutral/repository/TransactionRepositoryIterator.d.ts.map +1 -0
- package/dist/neutral/repository/TransactionWriteRepository.d.ts +6 -0
- package/dist/neutral/repository/TransactionWriteRepository.d.ts.map +1 -0
- package/dist/neutral/repository/index.d.ts +6 -0
- package/dist/neutral/repository/index.d.ts.map +1 -0
- package/dist/neutral/runners/Block.d.ts +16 -0
- package/dist/neutral/runners/Block.d.ts.map +1 -0
- package/dist/neutral/runners/Finalization.d.ts +15 -0
- package/dist/neutral/runners/Finalization.d.ts.map +1 -0
- package/dist/neutral/runners/Mempool.d.ts +25 -0
- package/dist/neutral/runners/Mempool.d.ts.map +1 -0
- package/dist/neutral/runners/index.d.ts +4 -0
- package/dist/neutral/runners/index.d.ts.map +1 -0
- package/dist/neutral/validation/block/BlockValidationFunction.d.ts +6 -0
- package/dist/neutral/validation/block/BlockValidationFunction.d.ts.map +1 -0
- package/dist/neutral/validation/block/HydratedBlockStateValidationFunction.d.ts +19 -0
- package/dist/neutral/validation/block/HydratedBlockStateValidationFunction.d.ts.map +1 -0
- package/dist/neutral/validation/block/HydratedBlockValidationFunction.d.ts +14 -0
- package/dist/neutral/validation/block/HydratedBlockValidationFunction.d.ts.map +1 -0
- package/dist/neutral/validation/block/error.d.ts +21 -0
- package/dist/neutral/validation/block/error.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/boundwitness/BoundWitnessValidationFunction.d.ts +6 -0
- package/dist/neutral/validation/boundwitness/BoundWitnessValidationFunction.d.ts.map +1 -0
- package/dist/neutral/validation/boundwitness/HydratedBoundWitnessValidationFunction.d.ts +8 -0
- package/dist/neutral/validation/boundwitness/HydratedBoundWitnessValidationFunction.d.ts.map +1 -0
- package/dist/neutral/validation/boundwitness/error.d.ts +13 -0
- package/dist/neutral/validation/boundwitness/error.d.ts.map +1 -0
- package/dist/neutral/validation/boundwitness/index.d.ts +4 -0
- package/dist/neutral/validation/boundwitness/index.d.ts.map +1 -0
- package/dist/neutral/validation/error.d.ts +11 -0
- package/dist/neutral/validation/error.d.ts.map +1 -0
- package/dist/neutral/validation/index.d.ts +6 -0
- package/dist/neutral/validation/index.d.ts.map +1 -0
- package/dist/neutral/validation/payload/InBlockPayloadValidationFunction.d.ts +10 -0
- package/dist/neutral/validation/payload/InBlockPayloadValidationFunction.d.ts.map +1 -0
- package/dist/neutral/validation/payload/error.d.ts +12 -0
- package/dist/neutral/validation/payload/error.d.ts.map +1 -0
- package/dist/neutral/validation/payload/index.d.ts +3 -0
- package/dist/neutral/validation/payload/index.d.ts.map +1 -0
- package/dist/neutral/validation/transaction/HydratedTransactionStateValidationFunction.d.ts +18 -0
- package/dist/neutral/validation/transaction/HydratedTransactionStateValidationFunction.d.ts.map +1 -0
- package/dist/neutral/validation/transaction/HydratedTransactionValidationFunction.d.ts +16 -0
- package/dist/neutral/validation/transaction/HydratedTransactionValidationFunction.d.ts.map +1 -0
- package/dist/neutral/validation/transaction/error.d.ts +8 -0
- package/dist/neutral/validation/transaction/error.d.ts.map +1 -0
- package/dist/neutral/validation/transaction/index.d.ts +4 -0
- package/dist/neutral/validation/transaction/index.d.ts.map +1 -0
- package/dist/neutral/viewers/Block.d.ts +29 -0
- package/dist/neutral/viewers/Block.d.ts.map +1 -0
- package/dist/neutral/viewers/BlockInvalidation.d.ts +68 -0
- package/dist/neutral/viewers/BlockInvalidation.d.ts.map +1 -0
- package/dist/neutral/viewers/BlockReward.d.ts +14 -0
- package/dist/neutral/viewers/BlockReward.d.ts.map +1 -0
- package/dist/neutral/viewers/BlockValidation.d.ts +68 -0
- package/dist/neutral/viewers/BlockValidation.d.ts.map +1 -0
- package/dist/neutral/viewers/ChainContract.d.ts +22 -0
- package/dist/neutral/viewers/ChainContract.d.ts.map +1 -0
- package/dist/neutral/viewers/ChainStakeViewer.d.ts +11 -0
- package/dist/neutral/viewers/ChainStakeViewer.d.ts.map +1 -0
- package/dist/neutral/viewers/Finalization.d.ts +18 -0
- package/dist/neutral/viewers/Finalization.d.ts.map +1 -0
- package/dist/neutral/viewers/Fork.d.ts +9 -0
- package/dist/neutral/viewers/Fork.d.ts.map +1 -0
- package/dist/neutral/viewers/Mempool.d.ts +31 -0
- package/dist/neutral/viewers/Mempool.d.ts.map +1 -0
- package/dist/neutral/viewers/NetworkStake/NetworkStakeViewer.d.ts +17 -0
- package/dist/neutral/viewers/NetworkStake/NetworkStakeViewer.d.ts.map +1 -0
- package/dist/neutral/viewers/NetworkStake/Rewards/ByPositionViewer.d.ts +14 -0
- package/dist/neutral/viewers/NetworkStake/Rewards/ByPositionViewer.d.ts.map +1 -0
- package/dist/neutral/viewers/NetworkStake/Rewards/ByStakerViewer.d.ts +15 -0
- package/dist/neutral/viewers/NetworkStake/Rewards/ByStakerViewer.d.ts.map +1 -0
- package/dist/neutral/viewers/NetworkStake/Rewards/ByStepViewer.d.ts +14 -0
- package/dist/neutral/viewers/NetworkStake/Rewards/ByStepViewer.d.ts.map +1 -0
- package/dist/neutral/viewers/NetworkStake/Rewards/Options.d.ts +19 -0
- package/dist/neutral/viewers/NetworkStake/Rewards/Options.d.ts.map +1 -0
- package/dist/neutral/viewers/NetworkStake/Rewards/TotalViewer.d.ts +14 -0
- package/dist/neutral/viewers/NetworkStake/Rewards/TotalViewer.d.ts.map +1 -0
- package/dist/neutral/viewers/NetworkStake/Rewards/Viewer.d.ts +20 -0
- package/dist/neutral/viewers/NetworkStake/Rewards/Viewer.d.ts.map +1 -0
- package/dist/neutral/viewers/NetworkStake/Rewards/index.d.ts +8 -0
- package/dist/neutral/viewers/NetworkStake/Rewards/index.d.ts.map +1 -0
- package/dist/neutral/viewers/NetworkStake/Rewards/templates/ByIndexMethodsTemplate.d.ts +6 -0
- package/dist/neutral/viewers/NetworkStake/Rewards/templates/ByIndexMethodsTemplate.d.ts.map +1 -0
- package/dist/neutral/viewers/NetworkStake/Rewards/templates/MethodsTemplate.d.ts +10 -0
- package/dist/neutral/viewers/NetworkStake/Rewards/templates/MethodsTemplate.d.ts.map +1 -0
- package/dist/neutral/viewers/NetworkStake/Rewards/templates/index.d.ts +3 -0
- package/dist/neutral/viewers/NetworkStake/Rewards/templates/index.d.ts.map +1 -0
- package/dist/neutral/viewers/NetworkStake/index.d.ts +3 -0
- package/dist/neutral/viewers/NetworkStake/index.d.ts.map +1 -0
- package/dist/neutral/viewers/NetworkStakeStepReward.d.ts +40 -0
- package/dist/neutral/viewers/NetworkStakeStepReward.d.ts.map +1 -0
- package/dist/neutral/viewers/Stake.d.ts +38 -0
- package/dist/neutral/viewers/Stake.d.ts.map +1 -0
- package/dist/neutral/viewers/StakeEvents.d.ts +44 -0
- package/dist/neutral/viewers/StakeEvents.d.ts.map +1 -0
- package/dist/neutral/viewers/StakeIntent.d.ts +15 -0
- package/dist/neutral/viewers/StakeIntent.d.ts.map +1 -0
- package/dist/neutral/viewers/StakeTotals.d.ts +20 -0
- package/dist/neutral/viewers/StakeTotals.d.ts.map +1 -0
- package/dist/neutral/viewers/StepStake.d.ts +14 -0
- package/dist/neutral/viewers/StepStake.d.ts.map +1 -0
- package/dist/neutral/viewers/StepViewer.d.ts +37 -0
- package/dist/neutral/viewers/StepViewer.d.ts.map +1 -0
- package/dist/neutral/viewers/TimeSync.d.ts +21 -0
- package/dist/neutral/viewers/TimeSync.d.ts.map +1 -0
- package/dist/neutral/viewers/Transaction.d.ts +22 -0
- package/dist/neutral/viewers/Transaction.d.ts.map +1 -0
- package/dist/neutral/viewers/TransactionInvalidation.d.ts +66 -0
- package/dist/neutral/viewers/TransactionInvalidation.d.ts.map +1 -0
- package/dist/neutral/viewers/TransactionValidation.d.ts +67 -0
- package/dist/neutral/viewers/TransactionValidation.d.ts.map +1 -0
- package/dist/neutral/viewers/TransferBalance.d.ts +30 -0
- package/dist/neutral/viewers/TransferBalance.d.ts.map +1 -0
- package/dist/neutral/viewers/WindowedBlock.d.ts +18 -0
- package/dist/neutral/viewers/WindowedBlock.d.ts.map +1 -0
- package/dist/neutral/viewers/XyoViewer.d.ts +55 -0
- package/dist/neutral/viewers/XyoViewer.d.ts.map +1 -0
- package/dist/neutral/viewers/index.d.ts +24 -0
- package/dist/neutral/viewers/index.d.ts.map +1 -0
- package/package.json +73 -0
- package/src/OpenTelemetryProviders.ts +7 -0
- package/src/index.ts +9 -0
- package/src/network/Status.ts +30 -0
- package/src/network/index.ts +1 -0
- package/src/permissions/InvokerPermission.ts +58 -0
- package/src/permissions/XyoPermissions.ts +41 -0
- package/src/permissions/index.ts +2 -0
- package/src/providers/DataLake/Provider.ts +11 -0
- package/src/providers/DataLake/Runner.ts +16 -0
- package/src/providers/DataLake/Viewer.ts +16 -0
- package/src/providers/DataLake/index.ts +3 -0
- package/src/providers/TransactionHelper.ts +15 -0
- package/src/providers/XyoClient.ts +27 -0
- package/src/providers/XyoConnection.ts +20 -0
- package/src/providers/XyoGateway.ts +24 -0
- package/src/providers/XyoGatewayRunner.ts +72 -0
- package/src/providers/XyoNetwork.ts +8 -0
- package/src/providers/XyoRunner.ts +19 -0
- package/src/providers/index.ts +8 -0
- package/src/providers/signer/XyoSigner.ts +36 -0
- package/src/providers/signer/index.ts +1 -0
- package/src/repository/Repository.ts +32 -0
- package/src/repository/TransactionReadRepository.ts +6 -0
- package/src/repository/TransactionRepository.ts +12 -0
- package/src/repository/TransactionRepositoryIterator.ts +6 -0
- package/src/repository/TransactionWriteRepository.ts +6 -0
- package/src/repository/index.ts +5 -0
- package/src/runners/Block.ts +21 -0
- package/src/runners/Finalization.ts +17 -0
- package/src/runners/Mempool.ts +31 -0
- package/src/runners/index.ts +3 -0
- package/src/validation/block/BlockValidationFunction.ts +13 -0
- package/src/validation/block/HydratedBlockStateValidationFunction.ts +29 -0
- package/src/validation/block/HydratedBlockValidationFunction.ts +21 -0
- package/src/validation/block/error.ts +51 -0
- package/src/validation/block/index.ts +4 -0
- package/src/validation/boundwitness/BoundWitnessValidationFunction.ts +9 -0
- package/src/validation/boundwitness/HydratedBoundWitnessValidationFunction.ts +15 -0
- package/src/validation/boundwitness/error.ts +29 -0
- package/src/validation/boundwitness/index.ts +3 -0
- package/src/validation/error.ts +25 -0
- package/src/validation/index.ts +5 -0
- package/src/validation/payload/InBlockPayloadValidationFunction.ts +16 -0
- package/src/validation/payload/error.ts +24 -0
- package/src/validation/payload/index.ts +2 -0
- package/src/validation/transaction/HydratedTransactionStateValidationFunction.ts +27 -0
- package/src/validation/transaction/HydratedTransactionValidationFunction.ts +23 -0
- package/src/validation/transaction/error.ts +16 -0
- package/src/validation/transaction/index.ts +3 -0
- package/src/viewers/Block.ts +40 -0
- package/src/viewers/BlockInvalidation.ts +81 -0
- package/src/viewers/BlockReward.ts +18 -0
- package/src/viewers/BlockValidation.ts +81 -0
- package/src/viewers/ChainContract.ts +28 -0
- package/src/viewers/ChainStakeViewer.ts +15 -0
- package/src/viewers/Finalization.ts +22 -0
- package/src/viewers/Fork.ts +10 -0
- package/src/viewers/Mempool.ts +40 -0
- package/src/viewers/NetworkStake/NetworkStakeViewer.ts +20 -0
- package/src/viewers/NetworkStake/Rewards/ByPositionViewer.ts +19 -0
- package/src/viewers/NetworkStake/Rewards/ByStakerViewer.ts +20 -0
- package/src/viewers/NetworkStake/Rewards/ByStepViewer.ts +18 -0
- package/src/viewers/NetworkStake/Rewards/Options.ts +22 -0
- package/src/viewers/NetworkStake/Rewards/TotalViewer.ts +17 -0
- package/src/viewers/NetworkStake/Rewards/Viewer.ts +22 -0
- package/src/viewers/NetworkStake/Rewards/index.ts +7 -0
- package/src/viewers/NetworkStake/Rewards/templates/ByIndexMethodsTemplate.ts +7 -0
- package/src/viewers/NetworkStake/Rewards/templates/MethodsTemplate.ts +10 -0
- package/src/viewers/NetworkStake/Rewards/templates/index.ts +2 -0
- package/src/viewers/NetworkStake/index.ts +4 -0
- package/src/viewers/NetworkStakeStepReward.ts +82 -0
- package/src/viewers/Stake.ts +44 -0
- package/src/viewers/StakeEvents.ts +54 -0
- package/src/viewers/StakeIntent.ts +21 -0
- package/src/viewers/StakeTotals.ts +21 -0
- package/src/viewers/StepStake.ts +26 -0
- package/src/viewers/StepViewer.ts +57 -0
- package/src/viewers/TimeSync.ts +27 -0
- package/src/viewers/Transaction.ts +27 -0
- package/src/viewers/TransactionInvalidation.ts +71 -0
- package/src/viewers/TransactionValidation.ts +72 -0
- package/src/viewers/TransferBalance.ts +35 -0
- package/src/viewers/WindowedBlock.ts +23 -0
- package/src/viewers/XyoViewer.ts +73 -0
- package/src/viewers/index.ts +23 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Payload } from '@xyo-network/sdk-js'
|
|
2
|
+
import { asSchema, isPayloadOfSchemaType } from '@xyo-network/sdk-js'
|
|
3
|
+
|
|
4
|
+
/** Schema identifier for network status payloads. */
|
|
5
|
+
export const NetworkStatusSchema = asSchema('network.xyo.chain.status', true)
|
|
6
|
+
/** Schema type for NetworkStatus payloads. */
|
|
7
|
+
export type NetworkStatusSchema = typeof NetworkStatusSchema
|
|
8
|
+
|
|
9
|
+
/** Possible states of the network: online, offline, degraded, or unknown. */
|
|
10
|
+
export type NetworkStatusState = 'online' | 'offline' | 'degraded' | 'unknown'
|
|
11
|
+
|
|
12
|
+
/** Represents a single network status update with a time range and description. */
|
|
13
|
+
export type NetworkStatusUpdate = {
|
|
14
|
+
end: number
|
|
15
|
+
start: number
|
|
16
|
+
update: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Fields describing the current network status, including state and optional updates. */
|
|
20
|
+
export interface NetworkStatusFields {
|
|
21
|
+
description: string
|
|
22
|
+
state: NetworkStatusState
|
|
23
|
+
updates?: NetworkStatusUpdate[]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** A payload representing the current network status. */
|
|
27
|
+
export type NetworkStatus = Payload<NetworkStatusFields, NetworkStatusSchema>
|
|
28
|
+
|
|
29
|
+
/** Type guard that checks whether a value is a NetworkStatus payload. */
|
|
30
|
+
export const isNetworkStatus = isPayloadOfSchemaType<NetworkStatus>(NetworkStatusSchema)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Status.ts'
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { JsonValue } from '@xylabs/sdk-js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Modeled after EIP-2255
|
|
5
|
+
* See - https://eips.ethereum.org/EIPS/eip-2255#specification
|
|
6
|
+
*
|
|
7
|
+
* 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
|
+
/** CaveatTypes type. */
|
|
28
|
+
export type CaveatTypes = 'chain' | 'expiration' | 'filteredResponse' | 'rateLimit' | 'restrictReturnedAccounts'
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Modeled after EIP-2255
|
|
32
|
+
* See - https://eips.ethereum.org/EIPS/eip-2255#specification
|
|
33
|
+
*/
|
|
34
|
+
export interface Caveats {
|
|
35
|
+
/** Type of caveat */
|
|
36
|
+
type: CaveatTypes
|
|
37
|
+
/** Value for the caveat (i.e. chain id, subset of accounts, expiration, max request per minute, etc.) */
|
|
38
|
+
value: JsonValue
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Modeled after EIP-2255
|
|
43
|
+
* See - https://eips.ethereum.org/EIPS/eip-2255#specification
|
|
44
|
+
*/
|
|
45
|
+
export interface Permission {
|
|
46
|
+
/** Caveats for the permission, if applicable (i.e. allowed accounts, signing, etc.) */
|
|
47
|
+
caveats?: Caveats[]
|
|
48
|
+
/** Invoker for the given permission (URI, domain, webpage, address, etc.) */
|
|
49
|
+
invoker: string
|
|
50
|
+
/** Permission identifier (i.e. RPC method, action, etc.) */
|
|
51
|
+
parentCapability: string
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** InvokerPermission interface. */
|
|
55
|
+
export interface InvokerPermission extends Permission {
|
|
56
|
+
/** Time at which the permission was granted */
|
|
57
|
+
date?: number
|
|
58
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
/** PermissionsProvider interface. */
|
|
41
|
+
export interface PermissionsProvider extends XyoPermissions {}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Payload, Schema } from '@xyo-network/sdk-js'
|
|
2
|
+
import type { Provider, ProviderMoniker } from '@xyo-network/xl1-protocol-model'
|
|
3
|
+
|
|
4
|
+
/** DataLakeData type. */
|
|
5
|
+
export type DataLakeData = Payload | ArrayBuffer
|
|
6
|
+
|
|
7
|
+
/** DataLakeProvider interface. */
|
|
8
|
+
export interface DataLakeProvider<TMoniker extends ProviderMoniker = ProviderMoniker> extends Provider<TMoniker> {
|
|
9
|
+
allowedSchemas?: Schema[]
|
|
10
|
+
disallowedSchemas?: Schema[]
|
|
11
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Hash } from '@xylabs/sdk-js'
|
|
2
|
+
import type { WriteArchivistFunctions } from '@xyo-network/sdk-js'
|
|
3
|
+
|
|
4
|
+
import type { DataLakeData, DataLakeProvider } from './Provider.ts'
|
|
5
|
+
import type { DataLakeViewer, DataLakeViewerMethods } from './Viewer.ts'
|
|
6
|
+
|
|
7
|
+
/** Moniker identifier for the DataLakeRunner provider. */
|
|
8
|
+
export const DataLakeRunnerMoniker = 'DataLakeRunner' as const
|
|
9
|
+
/** Type literal for the DataLakeRunner provider moniker. */
|
|
10
|
+
export type DataLakeRunnerMoniker = typeof DataLakeRunnerMoniker
|
|
11
|
+
|
|
12
|
+
/** DataLakeRunnerMethods interface. */
|
|
13
|
+
export interface DataLakeRunnerMethods extends WriteArchivistFunctions<DataLakeData, DataLakeData, DataLakeData, Hash>, DataLakeViewerMethods {}
|
|
14
|
+
|
|
15
|
+
/** Runner interface for executing DataLake operations. */
|
|
16
|
+
export interface DataLakeRunner extends DataLakeProvider<DataLakeRunnerMoniker>, DataLakeRunnerMethods, Omit<DataLakeViewer, 'moniker'> {}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Hash } from '@xylabs/sdk-js'
|
|
2
|
+
import type { ReadArchivistFunctions, Sequence } from '@xyo-network/sdk-js'
|
|
3
|
+
|
|
4
|
+
import type { DataLakeData, DataLakeProvider } from './Provider.ts'
|
|
5
|
+
|
|
6
|
+
/** Moniker identifier for the DataLakeViewer provider. */
|
|
7
|
+
export const DataLakeViewerMoniker = 'DataLakeViewer' as const
|
|
8
|
+
/** Type literal for the DataLakeViewer provider moniker. */
|
|
9
|
+
export type DataLakeViewerMoniker = typeof DataLakeViewerMoniker
|
|
10
|
+
|
|
11
|
+
/** DataLakeViewerMethods interface. */
|
|
12
|
+
export interface DataLakeViewerMethods extends ReadArchivistFunctions<DataLakeData, Hash, Sequence> {}
|
|
13
|
+
|
|
14
|
+
/** Viewer interface for reading DataLake data. */
|
|
15
|
+
export interface DataLakeViewer extends DataLakeProvider<DataLakeViewerMoniker>, DataLakeViewerMethods {
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/member-ordering */
|
|
2
|
+
import type { Payload } from '@xyo-network/sdk-js'
|
|
3
|
+
import type { UnsignedHydratedTransaction } from '@xyo-network/xl1-protocol-model'
|
|
4
|
+
|
|
5
|
+
/** TransactionHelper interface. */
|
|
6
|
+
export interface TransactionHelper {
|
|
7
|
+
// build tx, sign tx, send tx
|
|
8
|
+
addPayloadsToChain(onChain: Payload[], offChain: Payload[]): void
|
|
9
|
+
|
|
10
|
+
// sign tx, send tx
|
|
11
|
+
addUnsignedTransactionToChain(tx: UnsignedHydratedTransaction): void
|
|
12
|
+
|
|
13
|
+
// send tx (primitive)
|
|
14
|
+
addSignedTransactionToChain(tx: UnsignedHydratedTransaction): void
|
|
15
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { GatewayName } from '@xyo-network/xl1-protocol-model'
|
|
2
|
+
|
|
3
|
+
import type { XyoPermissions } from '../permissions/index.ts'
|
|
4
|
+
import type { XyoGateway } from './XyoGateway.ts'
|
|
5
|
+
import type { XyoGatewayRunner } from './XyoGatewayRunner.ts'
|
|
6
|
+
|
|
7
|
+
/** @deprecated */
|
|
8
|
+
export interface XyoGatewayConfig {
|
|
9
|
+
name: GatewayName
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** @deprecated */
|
|
13
|
+
export interface XyoRpcGatewayConfig extends XyoGatewayConfig {
|
|
14
|
+
dataLakeEndpoint: string
|
|
15
|
+
networkEndpoint: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** XyoClient interface. */
|
|
19
|
+
export interface XyoClient {
|
|
20
|
+
gateways: Readonly<Partial<Record<GatewayName, XyoGatewayRunner>>>
|
|
21
|
+
permissions: XyoPermissions
|
|
22
|
+
|
|
23
|
+
/** @deprecated */
|
|
24
|
+
addGateway?(providerOrConfig: XyoGatewayConfig | XyoRpcGatewayConfig | XyoGateway): Promise<XyoGateway>
|
|
25
|
+
/** @deprecated */
|
|
26
|
+
removeGateway?(name: GatewayName): Promise<void>
|
|
27
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Provider } from '@xyo-network/xl1-protocol-model'
|
|
2
|
+
|
|
3
|
+
import type { NetworkStakeViewer, XyoViewer } from '../viewers/index.ts'
|
|
4
|
+
import type { DataLakeRunner, DataLakeViewer } from './DataLake/index.ts'
|
|
5
|
+
import type { XyoNetwork } from './XyoNetwork.ts'
|
|
6
|
+
import type { XyoRunner } from './XyoRunner.ts'
|
|
7
|
+
|
|
8
|
+
/** Moniker identifier for the XyoConnection provider. */
|
|
9
|
+
export const XyoConnectionMoniker = 'XyoConnection' as const
|
|
10
|
+
/** Type literal for the XyoConnection provider moniker. */
|
|
11
|
+
export type XyoConnectionMoniker = typeof XyoConnectionMoniker
|
|
12
|
+
|
|
13
|
+
/** XyoConnection interface. */
|
|
14
|
+
export interface XyoConnection extends Provider<XyoConnectionMoniker> {
|
|
15
|
+
network?: XyoNetwork
|
|
16
|
+
networkStake?: NetworkStakeViewer
|
|
17
|
+
runner?: XyoRunner
|
|
18
|
+
storage?: DataLakeRunner | DataLakeViewer | (DataLakeRunner & DataLakeViewer)
|
|
19
|
+
viewer?: XyoViewer
|
|
20
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Provider, ProviderMoniker } from '@xyo-network/xl1-protocol-model'
|
|
2
|
+
|
|
3
|
+
import type { XyoConnection } from './XyoConnection.ts'
|
|
4
|
+
|
|
5
|
+
/** Moniker identifier for the XyoGateway provider. */
|
|
6
|
+
export const XyoGatewayMoniker = 'XyoGateway' as const
|
|
7
|
+
/** Type literal for the XyoGateway provider moniker. */
|
|
8
|
+
export type XyoGatewayMoniker = typeof XyoGatewayMoniker
|
|
9
|
+
|
|
10
|
+
/** XyoGatewayMethods interface. */
|
|
11
|
+
export interface XyoGatewayMethods {}
|
|
12
|
+
|
|
13
|
+
/** XyoGatewayProvider interface. */
|
|
14
|
+
export interface XyoGatewayProvider<
|
|
15
|
+
TMoniker extends ProviderMoniker = ProviderMoniker> extends XyoGatewayMethods, Provider<TMoniker> {
|
|
16
|
+
/**
|
|
17
|
+
* Returns the connection provider for this gateway.
|
|
18
|
+
*/
|
|
19
|
+
connection: XyoConnection
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** XyoGateway interface. */
|
|
23
|
+
export interface XyoGateway extends XyoGatewayProvider<XyoGatewayMoniker>, Provider<XyoGatewayMoniker> {
|
|
24
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Address, Hash, Logger, Promisable,
|
|
3
|
+
} from '@xylabs/sdk-js'
|
|
4
|
+
import type { Payload } from '@xyo-network/sdk-js'
|
|
5
|
+
import type {
|
|
6
|
+
AllowedBlockPayload, AttoXL1, ChainId,
|
|
7
|
+
SignedHydratedTransaction, SignedHydratedTransactionWithHashMeta,
|
|
8
|
+
TransactionFeesBigInt, UnsignedHydratedTransaction, XL1BlockNumber,
|
|
9
|
+
} from '@xyo-network/xl1-protocol-model'
|
|
10
|
+
|
|
11
|
+
import type { XyoSigner } from './signer/index.ts'
|
|
12
|
+
import type { XyoGatewayProvider } from './XyoGateway.ts'
|
|
13
|
+
|
|
14
|
+
/** ConfirmSubmittedTransactionOptions type. */
|
|
15
|
+
export type ConfirmSubmittedTransactionOptions = {
|
|
16
|
+
/**
|
|
17
|
+
* Number of attempts to confirm the transaction.
|
|
18
|
+
* Defaults to 20.
|
|
19
|
+
*/
|
|
20
|
+
attempts?: number
|
|
21
|
+
/**
|
|
22
|
+
* Delay in milliseconds between confirmation attempts.
|
|
23
|
+
* Defaults to 1000 (1 second).
|
|
24
|
+
*/
|
|
25
|
+
delay?: number
|
|
26
|
+
/**
|
|
27
|
+
* Optional logger instance for logging progress.
|
|
28
|
+
*/
|
|
29
|
+
logger?: Logger
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Options for Transaction. */
|
|
33
|
+
export interface TransactionOptions {
|
|
34
|
+
chain?: ChainId
|
|
35
|
+
exp?: XL1BlockNumber
|
|
36
|
+
fees?: TransactionFeesBigInt
|
|
37
|
+
from?: Address
|
|
38
|
+
nbf?: XL1BlockNumber
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Moniker identifier for the XyoGatewayRunner provider. */
|
|
42
|
+
export const XyoGatewayRunnerMoniker = 'XyoGatewayRunner' as const
|
|
43
|
+
/** Type literal for the XyoGatewayRunner provider moniker. */
|
|
44
|
+
export type XyoGatewayRunnerMoniker = typeof XyoGatewayRunnerMoniker
|
|
45
|
+
|
|
46
|
+
/** XyoGatewayRunnerMethods interface. */
|
|
47
|
+
export interface XyoGatewayRunnerMethods {
|
|
48
|
+
|
|
49
|
+
addPayloadsToChain(
|
|
50
|
+
onChain: AllowedBlockPayload[],
|
|
51
|
+
offChain: Payload[],
|
|
52
|
+
options?: TransactionOptions
|
|
53
|
+
): Promisable<[Hash, SignedHydratedTransactionWithHashMeta]>
|
|
54
|
+
|
|
55
|
+
addTransactionToChain(
|
|
56
|
+
tx: UnsignedHydratedTransaction | SignedHydratedTransaction,
|
|
57
|
+
offChain?: Payload[]
|
|
58
|
+
): Promisable<[Hash, SignedHydratedTransactionWithHashMeta]>
|
|
59
|
+
|
|
60
|
+
confirmSubmittedTransaction(txHash: Hash, options?: ConfirmSubmittedTransactionOptions): Promisable<SignedHydratedTransaction>
|
|
61
|
+
|
|
62
|
+
send(to: Address, amount: AttoXL1, options?: TransactionOptions): Promisable<Hash>
|
|
63
|
+
sendMany(transfers: Record<Address, AttoXL1>, options?: TransactionOptions): Promisable<Hash>
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Runner interface for executing XyoGateway operations. */
|
|
67
|
+
export interface XyoGatewayRunner extends XyoGatewayRunnerMethods, XyoGatewayProvider<XyoGatewayRunnerMoniker> {
|
|
68
|
+
/**
|
|
69
|
+
* Returns the signer for this gateway.
|
|
70
|
+
*/
|
|
71
|
+
signer: XyoSigner
|
|
72
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Hash, Promisable } from '@xylabs/sdk-js'
|
|
2
|
+
import type { Provider, SignedHydratedTransaction } from '@xyo-network/xl1-protocol-model'
|
|
3
|
+
|
|
4
|
+
import type { MempoolRunner } from '../runners/index.ts'
|
|
5
|
+
|
|
6
|
+
/** XyoRunnerMethods interface. */
|
|
7
|
+
export interface XyoRunnerMethods {
|
|
8
|
+
broadcastTransaction(transaction: SignedHydratedTransaction): Promisable<Hash>
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Moniker identifier for the XyoRunner provider. */
|
|
12
|
+
export const XyoRunnerMoniker = 'XyoRunner' as const
|
|
13
|
+
/** Type literal for the XyoRunner provider moniker. */
|
|
14
|
+
export type XyoRunnerMoniker = typeof XyoRunnerMoniker
|
|
15
|
+
|
|
16
|
+
/** Runner interface for executing Xyo operations. */
|
|
17
|
+
export interface XyoRunner extends XyoRunnerMethods, Provider<XyoRunnerMoniker> {
|
|
18
|
+
mempool: MempoolRunner
|
|
19
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './DataLake/index.ts'
|
|
2
|
+
export * from './signer/index.ts'
|
|
3
|
+
export * from './XyoClient.ts'
|
|
4
|
+
export * from './XyoConnection.ts'
|
|
5
|
+
export * from './XyoGateway.ts'
|
|
6
|
+
export * from './XyoGatewayRunner.ts'
|
|
7
|
+
export * from './XyoNetwork.ts'
|
|
8
|
+
export * from './XyoRunner.ts'
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Address, Promisable } from '@xylabs/sdk-js'
|
|
2
|
+
import type { Payload, Signed } from '@xyo-network/sdk-js'
|
|
3
|
+
import type {
|
|
4
|
+
AllowedBlockPayload, ChainId, Provider, SignedHydratedTransactionWithHashMeta, TransactionBoundWitness, TransactionFeesBigInt,
|
|
5
|
+
} from '@xyo-network/xl1-protocol-model'
|
|
6
|
+
|
|
7
|
+
/** Moniker identifier for the XyoSigner provider. */
|
|
8
|
+
export const XyoSignerMoniker = 'XyoSigner' as const
|
|
9
|
+
/** Type literal for the XyoSigner provider moniker. */
|
|
10
|
+
export type XyoSignerMoniker = typeof XyoSignerMoniker
|
|
11
|
+
|
|
12
|
+
/** XyoSignerMethods interface. */
|
|
13
|
+
export interface XyoSignerMethods {
|
|
14
|
+
address(): Promisable<Address>
|
|
15
|
+
// The tx passed in must have all the payloads (on and off chain) in the payloads array
|
|
16
|
+
// Returns the signed transaction and the payloads array excluding the off-chain payloads.
|
|
17
|
+
// The return value is ready to be broadcast to block producers
|
|
18
|
+
signTransaction(tx: [TransactionBoundWitness, Payload[]]): Promisable<SignedHydratedTransactionWithHashMeta>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** XyoSigner interface. */
|
|
22
|
+
export interface XyoSigner extends XyoSignerMethods, Provider<XyoSignerMoniker> {}
|
|
23
|
+
|
|
24
|
+
/** XyoSignerDeprecated interface. */
|
|
25
|
+
export interface XyoSignerDeprecated {
|
|
26
|
+
/** @deprecated use signTransaction instead */
|
|
27
|
+
createSignedTransaction(
|
|
28
|
+
chain: ChainId,
|
|
29
|
+
elevatedPayloads: AllowedBlockPayload[],
|
|
30
|
+
additionalPayloads: Payload[],
|
|
31
|
+
nbf: number,
|
|
32
|
+
exp: number,
|
|
33
|
+
fees: TransactionFeesBigInt,
|
|
34
|
+
from?: Address,
|
|
35
|
+
): Promisable<Signed<TransactionBoundWitness>>
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './XyoSigner.ts'
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Hash, Promisable } from '@xylabs/sdk-js'
|
|
2
|
+
import type {
|
|
3
|
+
NextOptions, Payload, WithStorageMeta,
|
|
4
|
+
} from '@xyo-network/sdk-js'
|
|
5
|
+
|
|
6
|
+
/** ReadRepository interface. */
|
|
7
|
+
export interface ReadRepository<TId, TData> {
|
|
8
|
+
get(id: TId): Promisable<TData>
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** IterableRepository interface. */
|
|
12
|
+
export interface IterableRepository<TId, TData> {
|
|
13
|
+
next(id: TId): Promisable<TData>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** WriteRepository interface. */
|
|
17
|
+
export interface WriteRepository<TData, TResp> {
|
|
18
|
+
insert(data: TData): Promisable<TResp>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** PayloadReadRepository interface. */
|
|
22
|
+
export interface PayloadReadRepository<TId = Hash, TData extends Payload = Payload> extends ReadRepository<TId[], WithStorageMeta<TData>[]> {}
|
|
23
|
+
/** PayloadWriteRepository interface. */
|
|
24
|
+
export interface PayloadWriteRepository<TData extends Payload = Payload> extends WriteRepository<TData[], WithStorageMeta<TData>[]> {}
|
|
25
|
+
|
|
26
|
+
/** PayloadIterableRepository interface. */
|
|
27
|
+
export interface PayloadIterableRepository<TId = Hash, TData extends Payload = Payload>
|
|
28
|
+
extends IterableRepository<NextOptions<TId>, WithStorageMeta<TData>[]> {}
|
|
29
|
+
|
|
30
|
+
/** PayloadRepository interface. */
|
|
31
|
+
export interface PayloadRepository<TId = Hash, TData extends Payload = Payload>
|
|
32
|
+
extends PayloadReadRepository<TId, TData>, PayloadWriteRepository<TData>, PayloadIterableRepository<TId, TData> {}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SignedHydratedTransaction, TransactionBoundWitness } from '@xyo-network/xl1-protocol-model'
|
|
2
|
+
|
|
3
|
+
import type { ReadRepository } from './Repository.ts'
|
|
4
|
+
|
|
5
|
+
/** TransactionReadRepository interface. */
|
|
6
|
+
export interface TransactionReadRepository extends ReadRepository<TransactionBoundWitness, SignedHydratedTransaction | undefined> {}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TransactionReadRepository } from './TransactionReadRepository.ts'
|
|
2
|
+
import type { TransactionRepositoryIterator } from './TransactionRepositoryIterator.ts'
|
|
3
|
+
import type { TransactionWriteRepository } from './TransactionWriteRepository.ts'
|
|
4
|
+
|
|
5
|
+
/** TransactionRepository interface. */
|
|
6
|
+
export interface TransactionRepository extends TransactionReadRepository, TransactionWriteRepository {}
|
|
7
|
+
|
|
8
|
+
/** ReadonlyIterableTransactionRepository interface. */
|
|
9
|
+
export interface ReadonlyIterableTransactionRepository extends TransactionReadRepository, TransactionRepositoryIterator {}
|
|
10
|
+
|
|
11
|
+
/** IterableTransactionRepository interface. */
|
|
12
|
+
export interface IterableTransactionRepository extends TransactionRepository, TransactionRepositoryIterator {}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SignedHydratedTransactionWithStorageMeta, TransactionBoundWitness } from '@xyo-network/xl1-protocol-model'
|
|
2
|
+
|
|
3
|
+
import type { IterableRepository } from './Repository.ts'
|
|
4
|
+
|
|
5
|
+
/** TransactionRepositoryIterator interface. */
|
|
6
|
+
export interface TransactionRepositoryIterator extends IterableRepository<TransactionBoundWitness, SignedHydratedTransactionWithStorageMeta | undefined> {}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SignedHydratedTransaction } from '@xyo-network/xl1-protocol-model'
|
|
2
|
+
|
|
3
|
+
import type { WriteRepository } from './Repository.ts'
|
|
4
|
+
|
|
5
|
+
/** TransactionWriteRepository interface. */
|
|
6
|
+
export interface TransactionWriteRepository extends WriteRepository<SignedHydratedTransaction, boolean> {}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { WithHashMeta } from '@xyo-network/sdk-js'
|
|
2
|
+
import type {
|
|
3
|
+
BlockBoundWitness, Provider,
|
|
4
|
+
SignedBlockBoundWitnessWithHashMeta, SignedHydratedBlockWithHashMeta,
|
|
5
|
+
} from '@xyo-network/xl1-protocol-model'
|
|
6
|
+
|
|
7
|
+
/** BlockRunnerMethods interface. */
|
|
8
|
+
export interface BlockRunnerMethods {
|
|
9
|
+
produceNextBlock(head: SignedBlockBoundWitnessWithHashMeta, force: true): Promise<SignedHydratedBlockWithHashMeta>
|
|
10
|
+
produceNextBlock(head: SignedBlockBoundWitnessWithHashMeta, force?: false): Promise<SignedHydratedBlockWithHashMeta | undefined>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Moniker identifier for the BlockRunner provider. */
|
|
14
|
+
export const BlockRunnerMoniker = 'BlockRunner' as const
|
|
15
|
+
/** Type literal for the BlockRunner provider moniker. */
|
|
16
|
+
export type BlockRunnerMoniker = typeof BlockRunnerMoniker
|
|
17
|
+
|
|
18
|
+
/** Runner interface for executing Block operations. */
|
|
19
|
+
export interface BlockRunner extends BlockRunnerMethods, Provider<BlockRunnerMoniker> {
|
|
20
|
+
next(head: WithHashMeta<BlockBoundWitness>): Promise<SignedHydratedBlockWithHashMeta | undefined>
|
|
21
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Hash } from '@xylabs/sdk-js'
|
|
2
|
+
import type { Provider, SignedHydratedBlockWithHashMeta } from '@xyo-network/xl1-protocol-model'
|
|
3
|
+
|
|
4
|
+
/** FinalizationRunnerMethods interface. */
|
|
5
|
+
export interface FinalizationRunnerMethods {
|
|
6
|
+
finalizeBlocks(blocks: SignedHydratedBlockWithHashMeta[]): Promise<Hash[]>
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** Moniker identifier for the FinalizationRunner provider. */
|
|
10
|
+
export const FinalizationRunnerMoniker = 'FinalizationRunner' as const
|
|
11
|
+
/** Type literal for the FinalizationRunner provider moniker. */
|
|
12
|
+
export type FinalizationRunnerMoniker = typeof FinalizationRunnerMoniker
|
|
13
|
+
|
|
14
|
+
/** Runner interface for executing Finalization operations. */
|
|
15
|
+
export interface FinalizationRunner extends FinalizationRunnerMethods, Provider<FinalizationRunnerMoniker> {
|
|
16
|
+
finalizeBlock(block: SignedHydratedBlockWithHashMeta): Promise<Hash>
|
|
17
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Hash } from '@xylabs/sdk-js'
|
|
2
|
+
import type {
|
|
3
|
+
Provider, SignedHydratedBlock, SignedHydratedTransaction,
|
|
4
|
+
} from '@xyo-network/xl1-protocol-model'
|
|
5
|
+
|
|
6
|
+
/** MempoolRunnerMethods interface. */
|
|
7
|
+
export interface MempoolRunnerMethods {
|
|
8
|
+
submitBlocks(blocks: SignedHydratedBlock[]): Promise<Hash[]>
|
|
9
|
+
submitTransactions(transactions: SignedHydratedTransaction[]): Promise<Hash[]>
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Moniker identifier for the MempoolRunner provider. */
|
|
13
|
+
export const MempoolRunnerMoniker = 'MempoolRunner' as const
|
|
14
|
+
/** Type literal for the MempoolRunner provider moniker. */
|
|
15
|
+
export type MempoolRunnerMoniker = typeof MempoolRunnerMoniker
|
|
16
|
+
|
|
17
|
+
/** DEFAULT_MAX_EXP_AHEAD constant. */
|
|
18
|
+
export const DEFAULT_MAX_EXP_AHEAD = 1000
|
|
19
|
+
|
|
20
|
+
/** Options for MempoolPrune. */
|
|
21
|
+
export interface MempoolPruneOptions {
|
|
22
|
+
batchSize?: number
|
|
23
|
+
maxCheck?: number
|
|
24
|
+
maxPrune?: number
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Runner interface for executing Mempool operations. */
|
|
28
|
+
export interface MempoolRunner extends MempoolRunnerMethods, Provider<MempoolRunnerMoniker> {
|
|
29
|
+
prunePendingBlocks(options?: MempoolPruneOptions): Promise<[number, number]>
|
|
30
|
+
prunePendingTransactions(options?: MempoolPruneOptions): Promise<[number, number]>
|
|
31
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Promisable } from '@xylabs/sdk-js'
|
|
2
|
+
import type {
|
|
3
|
+
BaseContext, BlockBoundWitness, ChainId,
|
|
4
|
+
} from '@xyo-network/xl1-protocol-model'
|
|
5
|
+
|
|
6
|
+
import type { BlockValidationError } from './error.ts'
|
|
7
|
+
|
|
8
|
+
/** Function type for BlockValidator operations. */
|
|
9
|
+
export type BlockValidatorFunction = (
|
|
10
|
+
context: BaseContext,
|
|
11
|
+
block: BlockBoundWitness,
|
|
12
|
+
chainId?: ChainId,
|
|
13
|
+
) => Promisable<BlockValidationError[]>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Promisable } from '@xylabs/sdk-js'
|
|
2
|
+
import type {
|
|
3
|
+
AccountBalanceViewer,
|
|
4
|
+
BaseContext, ChainId,
|
|
5
|
+
HydratedBlockWithHashMeta, XL1BlockNumber,
|
|
6
|
+
} from '@xyo-network/xl1-protocol-model'
|
|
7
|
+
|
|
8
|
+
import type { HydratedBlockStateValidationError } from './error.ts'
|
|
9
|
+
|
|
10
|
+
/** Function type for ChainAtBlockNumber operations. */
|
|
11
|
+
export type ChainAtBlockNumberFunction = (blockNumber: XL1BlockNumber) => Promisable<ChainId>
|
|
12
|
+
|
|
13
|
+
/** Context for HydratedBlockStateValidationFunction operations. */
|
|
14
|
+
export interface HydratedBlockStateValidationFunctionContext extends BaseContext {
|
|
15
|
+
accountBalance: AccountBalanceViewer
|
|
16
|
+
chainIdAtBlockNumber: ChainAtBlockNumberFunction
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A function that validates a hydrated block against chain state.
|
|
21
|
+
* @param hydratedBlock The hydrated block to validate.
|
|
22
|
+
* @param chainId The chain ID to use for validation.
|
|
23
|
+
* @param archivist The archivist to use for validation.
|
|
24
|
+
* @returns An array of errors if the block is invalid, or an empty array if it is valid.
|
|
25
|
+
*/
|
|
26
|
+
export type HydratedBlockStateValidationFunction = (
|
|
27
|
+
context: HydratedBlockStateValidationFunctionContext,
|
|
28
|
+
hydratedBlock: HydratedBlockWithHashMeta,
|
|
29
|
+
) => Promisable<HydratedBlockStateValidationError[]>
|