@xyo-network/xl1-protocol 1.11.1 → 1.12.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/block/AllowedBlockPayload.d.ts +2 -2
- package/dist/neutral/block/AllowedBlockPayload.d.ts.map +1 -1
- package/dist/neutral/index.mjs +62 -45
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/interfaces/Balance.d.ts +9 -0
- package/dist/neutral/interfaces/Balance.d.ts.map +1 -0
- package/dist/neutral/interfaces/Block.d.ts +12 -0
- package/dist/neutral/interfaces/Block.d.ts.map +1 -0
- package/dist/neutral/interfaces/Chain.d.ts +6 -0
- package/dist/neutral/interfaces/Chain.d.ts.map +1 -0
- package/dist/neutral/interfaces/ChainContract.d.ts +10 -0
- package/dist/neutral/interfaces/ChainContract.d.ts.map +1 -0
- package/dist/neutral/interfaces/ChainStake.d.ts +10 -0
- package/dist/neutral/interfaces/ChainStake.d.ts.map +1 -0
- package/dist/neutral/{provider/ForkViewer.d.ts → interfaces/Fork.d.ts} +2 -2
- package/dist/neutral/interfaces/Fork.d.ts.map +1 -0
- package/dist/neutral/interfaces/NetworkStakeStepReward.d.ts +17 -0
- package/dist/neutral/interfaces/NetworkStakeStepReward.d.ts.map +1 -0
- package/dist/neutral/interfaces/Stake.d.ts +16 -0
- package/dist/neutral/interfaces/Stake.d.ts.map +1 -0
- package/dist/neutral/{provider/StakeViewer.d.ts → interfaces/StakeTotals.d.ts} +2 -2
- package/dist/neutral/interfaces/StakeTotals.d.ts.map +1 -0
- package/dist/neutral/interfaces/Transaction.d.ts +9 -0
- package/dist/neutral/interfaces/Transaction.d.ts.map +1 -0
- package/dist/neutral/interfaces/index.d.ts +11 -0
- package/dist/neutral/interfaces/index.d.ts.map +1 -0
- package/dist/neutral/payload/elevatable/TransferRequest.d.ts +13 -0
- package/dist/neutral/payload/elevatable/TransferRequest.d.ts.map +1 -0
- package/dist/neutral/payload/elevatable/index.d.ts +1 -0
- package/dist/neutral/payload/elevatable/index.d.ts.map +1 -1
- package/dist/neutral/provider/XyoConnection.d.ts +7 -4
- package/dist/neutral/provider/XyoConnection.d.ts.map +1 -1
- package/dist/neutral/provider/XyoDataLake.d.ts +5 -2
- package/dist/neutral/provider/XyoDataLake.d.ts.map +1 -1
- package/dist/neutral/provider/XyoGateway.d.ts +5 -5
- package/dist/neutral/provider/XyoGateway.d.ts.map +1 -1
- package/dist/neutral/provider/XyoViewer.d.ts +2 -19
- package/dist/neutral/provider/XyoViewer.d.ts.map +1 -1
- package/dist/neutral/provider/index.d.ts +0 -2
- package/dist/neutral/provider/index.d.ts.map +1 -1
- package/dist/neutral/services/AccountBalanceService.d.ts +6 -5
- package/dist/neutral/services/AccountBalanceService.d.ts.map +1 -1
- package/dist/neutral/services/BlockProducerService.d.ts +2 -2
- package/dist/neutral/services/BlockProducerService.d.ts.map +1 -1
- package/dist/neutral/services/BlockRewardService.d.ts +2 -2
- package/dist/neutral/services/BlockRewardService.d.ts.map +1 -1
- package/dist/neutral/services/Chain/BaseChainService.d.ts +2 -2
- package/dist/neutral/services/Chain/BaseChainService.d.ts.map +1 -1
- package/dist/neutral/services/Chain/interfaces/ChainContractViewer.d.ts +2 -9
- package/dist/neutral/services/Chain/interfaces/ChainContractViewer.d.ts.map +1 -1
- package/dist/neutral/services/Chain/interfaces/ChainStakeViewer.d.ts +2 -7
- package/dist/neutral/services/Chain/interfaces/ChainStakeViewer.d.ts.map +1 -1
- package/dist/neutral/services/Election.d.ts +2 -2
- package/dist/neutral/services/Election.d.ts.map +1 -1
- package/dist/neutral/services/PendingTransactionsService.d.ts +2 -2
- package/dist/neutral/services/PendingTransactionsService.d.ts.map +1 -1
- package/dist/neutral/services/Service.d.ts +3 -1
- package/dist/neutral/services/Service.d.ts.map +1 -1
- package/dist/neutral/services/StakeIntentService/StakeIntentService.d.ts +2 -2
- package/dist/neutral/services/StakeIntentService/StakeIntentService.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/block/AllowedBlockPayload.ts +11 -3
- package/src/interfaces/Balance.ts +11 -0
- package/src/interfaces/Block.ts +14 -0
- package/src/interfaces/Chain.ts +7 -0
- package/src/interfaces/ChainContract.ts +10 -0
- package/src/interfaces/ChainStake.ts +9 -0
- package/src/{provider/ForkViewer.ts → interfaces/Fork.ts} +1 -1
- package/src/interfaces/NetworkStakeStepReward.ts +31 -0
- package/src/interfaces/Stake.ts +24 -0
- package/src/{provider/StakeViewer.ts → interfaces/StakeTotals.ts} +10 -1
- package/src/interfaces/Transaction.ts +10 -0
- package/src/interfaces/index.ts +10 -0
- package/src/payload/elevatable/TransferPayload.ts +1 -1
- package/src/payload/elevatable/TransferRequest.ts +28 -0
- package/src/payload/elevatable/index.ts +1 -0
- package/src/provider/XyoConnection.ts +7 -4
- package/src/provider/XyoDataLake.ts +7 -3
- package/src/provider/XyoGateway.ts +5 -5
- package/src/provider/XyoViewer.ts +8 -26
- package/src/provider/index.ts +0 -2
- package/src/services/AccountBalanceService.ts +7 -5
- package/src/services/BlockProducerService.ts +2 -2
- package/src/services/BlockRewardService.ts +2 -2
- package/src/services/Chain/BaseChainService.ts +2 -2
- package/src/services/Chain/interfaces/ChainContractViewer.ts +3 -9
- package/src/services/Chain/interfaces/ChainStakeViewer.ts +3 -7
- package/src/services/Election.ts +2 -2
- package/src/services/PendingTransactionsService.ts +2 -2
- package/src/services/Service.ts +5 -1
- package/src/services/StakeIntentService/StakeIntentService.ts +2 -2
- package/dist/neutral/provider/ForkViewer.d.ts.map +0 -1
- package/dist/neutral/provider/StakeViewer.d.ts.map +0 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Hash } from 'node:crypto'
|
|
2
|
+
|
|
3
|
+
import type { Address } from '@xylabs/hex'
|
|
4
|
+
import type { Promisable } from '@xylabs/promise'
|
|
5
|
+
|
|
6
|
+
import type { Transfer } from '../payload/index.ts'
|
|
7
|
+
|
|
8
|
+
export interface BalanceInterface {
|
|
9
|
+
accountBalance(address: Address | bigint): Promisable<bigint>
|
|
10
|
+
accountBalanceHistory(address: Address): Promisable<[Hash /* block */, Hash /* transaction */, Transfer][]>
|
|
11
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Hash } from '@xylabs/hex'
|
|
2
|
+
import type { Promisable } from '@xylabs/promise'
|
|
3
|
+
|
|
4
|
+
import type { HydratedBlock } from '../block/index.ts'
|
|
5
|
+
|
|
6
|
+
export interface BlockInterface {
|
|
7
|
+
blockByHash(hash: Hash): Promisable<HydratedBlock | null>
|
|
8
|
+
blockByNumber(blockNumber: number): Promisable<HydratedBlock | null>
|
|
9
|
+
blocksByHash(hash: Hash, limit?: number): Promisable<HydratedBlock[]>
|
|
10
|
+
|
|
11
|
+
currentBlock(): Promisable<HydratedBlock>
|
|
12
|
+
currentBlockHash(): Promisable<Hash>
|
|
13
|
+
currentBlockNumber(): Promisable<number>
|
|
14
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
|
+
|
|
3
|
+
export interface ChainContractInterface {
|
|
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
|
+
export interface ChainStakeInterface {
|
|
2
|
+
active(): Promise<bigint>
|
|
3
|
+
activeByAddressStaked(address: string): Promise<bigint>
|
|
4
|
+
activeByStaker(address: string): Promise<bigint>
|
|
5
|
+
pending(): Promise<bigint>
|
|
6
|
+
pendingByStaker(staker: string): Promise<bigint>
|
|
7
|
+
withdrawn(): Promise<bigint>
|
|
8
|
+
withdrawnByStaker(staker: string): Promise<bigint>
|
|
9
|
+
}
|
|
@@ -3,7 +3,7 @@ import type { Promisable } from '@xylabs/promise'
|
|
|
3
3
|
|
|
4
4
|
export type ForkHistory = Record<number, Address>
|
|
5
5
|
|
|
6
|
-
export interface
|
|
6
|
+
export interface ForkInterface {
|
|
7
7
|
chainIdAtBlock(blockNumber: number): Promisable<Address>
|
|
8
8
|
forkHistory(): Promisable<ForkHistory>
|
|
9
9
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
|
+
import type { Promisable } from '@xylabs/promise'
|
|
3
|
+
|
|
4
|
+
export interface NetworkStakeStepAddressReward {
|
|
5
|
+
claimedRewards(address: Address): Promisable<bigint>
|
|
6
|
+
|
|
7
|
+
// the step rewards for a specific network stakers for a given step and block
|
|
8
|
+
networkStakeStepAddressReward(address: Address, step: number, block: number): Promisable<Record<Address, bigint>>
|
|
9
|
+
|
|
10
|
+
// the step rewards for a specific network stakers for all of history
|
|
11
|
+
networkStakeStepRewardAddressHistory(address: Address): Promisable<Record<Address, bigint>>
|
|
12
|
+
|
|
13
|
+
// the shares for a specific network staker for a given step and block
|
|
14
|
+
networkStakeStepRewardAddressShare(address: Address, step: number, block: number): Promisable<[/* address shares */bigint, /* total shares */bigint]>
|
|
15
|
+
|
|
16
|
+
unclaimedRewards(address: Address): Promisable<bigint>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface NetworkStakeStepPoolReward {
|
|
20
|
+
|
|
21
|
+
// all the shares for all the network stakers for a given step and block
|
|
22
|
+
networkStakeStepPoolRewardShares(step: number, block: number): Promisable<Record<Address, bigint>>
|
|
23
|
+
|
|
24
|
+
// all the step rewards for all the network stakers for a given step and block
|
|
25
|
+
networkStakeStepPoolRewards(step: number, block: number): Promisable<Record<Address, bigint>>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface NetworkStakeStepReward extends NetworkStakeStepPoolReward, NetworkStakeStepAddressReward {
|
|
29
|
+
// the predictable random number for a given step and block
|
|
30
|
+
networkStakeStepRewardRandomizer(step: number, block: number): Promisable<bigint>
|
|
31
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
|
+
import type { Promisable } from '@xylabs/promise'
|
|
3
|
+
|
|
4
|
+
export type Stake = {
|
|
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: number
|
|
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
|
+
export interface StakeInterface {
|
|
22
|
+
stakeByAddress(address: Address, slot: number): Promisable<Stake>
|
|
23
|
+
stakeById(id: number): Promisable<Stake>
|
|
24
|
+
}
|
|
@@ -8,10 +8,19 @@ export interface StakeScope {
|
|
|
8
8
|
type?: 'all' | 'network' | 'address'
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export interface
|
|
11
|
+
export interface StakeTotalsInterface {
|
|
12
|
+
// the total amount that is staked in a given scope
|
|
12
13
|
stakeAmount(scope?: StakeScope): Promisable<[bigint /* amount */, number /* external block number */]>
|
|
14
|
+
|
|
15
|
+
// the total number of stakes in a given scope
|
|
13
16
|
stakeCount(scope?: StakeScope): Promisable<[number /* amount */, number /* external block number */]>
|
|
17
|
+
|
|
18
|
+
// the total number of unique addresses staked in a given scope
|
|
14
19
|
stakedCount(scope?: StakeScope): Promisable<[number /* amount */, number /* external block number */]>
|
|
20
|
+
|
|
21
|
+
// the total number of unique stakers in a given scope
|
|
15
22
|
stakerCount(scope?: StakeScope): Promisable<[number /* amount */, number /* external block number */]>
|
|
23
|
+
|
|
24
|
+
// the total number of unique stake positions in a given scope
|
|
16
25
|
stakes(scope?: StakeScope): Promisable<[bigint /* amount */, number /* external block number */]>
|
|
17
26
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Hash } from '@xylabs/hex'
|
|
2
|
+
import type { Promisable } from '@xylabs/promise'
|
|
3
|
+
|
|
4
|
+
import type { SignedHydratedTransaction } from '../transaction/index.ts'
|
|
5
|
+
|
|
6
|
+
export interface TransactionInterface {
|
|
7
|
+
transactionByBlockHashAndIndex(blockHash: Hash, transactionIndex: number): Promisable<SignedHydratedTransaction | null>
|
|
8
|
+
transactionByBlockNumberAndIndex(blockNumber: number, transactionIndex: number): Promisable<SignedHydratedTransaction | null>
|
|
9
|
+
transactionByHash(transactionHash: Hash): Promisable<SignedHydratedTransaction | null>
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './Balance.ts'
|
|
2
|
+
export * from './Block.ts'
|
|
3
|
+
export * from './Chain.ts'
|
|
4
|
+
export * from './ChainContract.ts'
|
|
5
|
+
export * from './ChainStake.ts'
|
|
6
|
+
export * from './Fork.ts'
|
|
7
|
+
export * from './NetworkStakeStepReward.ts'
|
|
8
|
+
export * from './Stake.ts'
|
|
9
|
+
export * from './StakeTotals.ts'
|
|
10
|
+
export * from './Transaction.ts'
|
|
@@ -13,7 +13,7 @@ export type TransferSchema = typeof TransferSchema
|
|
|
13
13
|
|
|
14
14
|
export interface TransferFields extends FromFields {
|
|
15
15
|
epoch: number
|
|
16
|
-
// the amount that is being sent to
|
|
16
|
+
// the amount that is being sent to other addresses
|
|
17
17
|
transfers: Partial<Record<Address, Hex>>
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Address,
|
|
3
|
+
Hex,
|
|
4
|
+
} from '@xylabs/hex'
|
|
5
|
+
import { AsObjectFactory } from '@xylabs/object'
|
|
6
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
7
|
+
import { isPayloadOfSchemaType } from '@xyo-network/payload-model'
|
|
8
|
+
|
|
9
|
+
import type { FromFields } from './Executable.ts'
|
|
10
|
+
|
|
11
|
+
export const TransferRequestSchema = 'network.xyo.transfer.request' as const
|
|
12
|
+
export type TransferRequestSchema = typeof TransferRequestSchema
|
|
13
|
+
|
|
14
|
+
/* The initial use for this is for a network staker to request a transfer from the step reward account to them for the rewards they are owed */
|
|
15
|
+
/* By definition, a request is valid for 1000 blocks following its inclusion in a block or until the request has been filled */
|
|
16
|
+
|
|
17
|
+
export interface TransferRequestFields extends FromFields {
|
|
18
|
+
epoch: number
|
|
19
|
+
// the amount that is requested to be sent to other addresses
|
|
20
|
+
transfers: Partial<Record<Address, Hex>>
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// if this payload is included in a boundwitness, it needs to be available for inspection to be included in block
|
|
24
|
+
export type TransferRequest = Payload<TransferRequestFields, TransferRequestSchema>
|
|
25
|
+
|
|
26
|
+
export const isTransferRequest = isPayloadOfSchemaType<TransferRequest>(TransferRequestSchema)
|
|
27
|
+
|
|
28
|
+
export const asTransferRequest = AsObjectFactory.create(isTransferRequest)
|
|
@@ -6,7 +6,7 @@ import type { AllowedBlockPayload } from '../block/index.ts'
|
|
|
6
6
|
import type { TransactionBoundWitness, TransactionFeesBigInt } from '../transaction/index.ts'
|
|
7
7
|
// eslint-disable-next-line sonarjs/deprecation
|
|
8
8
|
import type { TransactionSubmitter } from './TransactionSubmitter.ts'
|
|
9
|
-
import type {
|
|
9
|
+
import type { XyoDataLake, XyoDataLakeViewer } from './XyoDataLake.ts'
|
|
10
10
|
import type { XyoNetwork } from './XyoNetwork.ts'
|
|
11
11
|
import type { XyoRunner } from './XyoRunner.ts'
|
|
12
12
|
import type { XyoSigner } from './XyoSigner.ts'
|
|
@@ -38,12 +38,15 @@ export interface XyoConnectionProviderDeprecated extends TransactionSubmitter {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
// eslint-disable-next-line sonarjs/deprecation
|
|
41
|
-
export interface
|
|
41
|
+
export interface XyoConnection extends Partial<XyoConnectionProviderDeprecated> {
|
|
42
42
|
network?: XyoNetwork
|
|
43
43
|
runner?: XyoRunner
|
|
44
|
-
storage?:
|
|
44
|
+
storage?: XyoDataLake | XyoDataLakeViewer
|
|
45
45
|
viewer?: XyoViewer
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
/** @deprecated use XyoConnectionProvider */
|
|
49
|
-
export interface
|
|
49
|
+
export interface XyoConnectionProvider extends XyoConnection {}
|
|
50
|
+
|
|
51
|
+
/** @deprecated use XyoConnectionProvider */
|
|
52
|
+
export interface XyoProvider extends XyoConnection {}
|
|
@@ -13,10 +13,14 @@ export interface XyoDataLakeViewer {
|
|
|
13
13
|
trace(hash: Hash): Promisable<[DataLakeData | undefined, Payload[]]>
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export interface
|
|
16
|
+
export interface XyoDataLake extends XyoDataLakeViewer {
|
|
17
17
|
add(items: DataLakeData[]): Promisable<DataLakeData[]>
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
/** @deprecated use XyoDataLake instead */
|
|
21
|
+
export interface XyoDataLakeProvider extends XyoDataLake {
|
|
22
|
+
}
|
|
23
|
+
|
|
20
24
|
export const isDataLakeViewer = (value: unknown): value is XyoDataLakeViewer => {
|
|
21
25
|
return (
|
|
22
26
|
typeof value === 'object'
|
|
@@ -30,10 +34,10 @@ export const isDataLakeViewer = (value: unknown): value is XyoDataLakeViewer =>
|
|
|
30
34
|
)
|
|
31
35
|
}
|
|
32
36
|
|
|
33
|
-
export const isDataLakeProvider = (value: unknown): value is
|
|
37
|
+
export const isDataLakeProvider = (value: unknown): value is XyoDataLake => {
|
|
34
38
|
return (
|
|
35
39
|
isDataLakeViewer(value)
|
|
36
40
|
&& 'add' in value
|
|
37
|
-
&& typeof (value as
|
|
41
|
+
&& typeof (value as XyoDataLake).add === 'function'
|
|
38
42
|
)
|
|
39
43
|
}
|
|
@@ -3,7 +3,7 @@ import type { Promisable } from '@xylabs/promise'
|
|
|
3
3
|
import type { InvokerPermission, Permission } from './PermissionsProvider.ts'
|
|
4
4
|
// eslint-disable-next-line sonarjs/deprecation
|
|
5
5
|
import type { TransactionSubmitter } from './TransactionSubmitter.ts'
|
|
6
|
-
import type {
|
|
6
|
+
import type { XyoConnection } from './XyoConnection.ts'
|
|
7
7
|
import type { XyoGatewayHelpers } from './XyoGatewayHelpers.ts'
|
|
8
8
|
import type { XyoSigner } from './XyoSigner.ts'
|
|
9
9
|
|
|
@@ -18,16 +18,16 @@ export interface XyoGatewayProviderDeprecated extends TransactionSubmitter {
|
|
|
18
18
|
/**
|
|
19
19
|
* @deprecated use `connection()` instead
|
|
20
20
|
*/
|
|
21
|
-
activeConnection(): Promisable<
|
|
21
|
+
activeConnection(): Promisable<XyoConnection | undefined>
|
|
22
22
|
/**
|
|
23
23
|
* @deprecated use `connection()` instead
|
|
24
24
|
*/
|
|
25
25
|
// eslint-disable-next-line sonarjs/deprecation
|
|
26
|
-
addConnection(config: XyoConnectionConfigDeprecated): Promisable<
|
|
26
|
+
addConnection(config: XyoConnectionConfigDeprecated): Promisable<XyoConnection>
|
|
27
27
|
/**
|
|
28
28
|
* @deprecated use `connection()` instead
|
|
29
29
|
*/
|
|
30
|
-
connections(): Promisable<Record<string,
|
|
30
|
+
connections(): Promisable<Record<string, XyoConnection>>
|
|
31
31
|
/**
|
|
32
32
|
* @deprecated Permissions now at Client level
|
|
33
33
|
*/
|
|
@@ -47,7 +47,7 @@ export interface XyoGatewayProvider extends Partial<XyoGatewayHelpers>, Partial<
|
|
|
47
47
|
/**
|
|
48
48
|
* Returns the connection provider for this gateway.
|
|
49
49
|
*/
|
|
50
|
-
connection(): Promisable<
|
|
50
|
+
connection(): Promisable<XyoConnection>
|
|
51
51
|
/**
|
|
52
52
|
* Returns the signer for this gateway.
|
|
53
53
|
*/
|
|
@@ -1,26 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export interface XyoViewer {
|
|
10
|
-
accountBalance(address: Address): Promisable<bigint>
|
|
11
|
-
accountHistory(address: Address): Promisable<[Hash /* block */, Hash /* transaction */, Transfer][]>
|
|
12
|
-
|
|
13
|
-
blockByHash(hash: Hash): Promisable<HydratedBlock | null>
|
|
14
|
-
blockByNumber(blockNumber: number): Promisable<HydratedBlock | null>
|
|
15
|
-
blocksByHash(hash: Hash, limit?: number): Promisable<HydratedBlock[]>
|
|
16
|
-
|
|
17
|
-
chainId(): Promisable<Chain>
|
|
18
|
-
|
|
19
|
-
currentBlock(): Promisable<HydratedBlock>
|
|
20
|
-
currentBlockHash(): Promisable<Hash>
|
|
21
|
-
currentBlockNumber(): Promisable<number>
|
|
22
|
-
|
|
23
|
-
transactionByBlockHashAndIndex(blockHash: Hash, transactionIndex: number): Promisable<SignedHydratedTransaction | null>
|
|
24
|
-
transactionByBlockNumberAndIndex(blockNumber: number, transactionIndex: number): Promisable<SignedHydratedTransaction | null>
|
|
25
|
-
transactionByHash(transactionHash: Hash): Promisable<SignedHydratedTransaction | null>
|
|
26
|
-
}
|
|
1
|
+
import type {
|
|
2
|
+
BalanceInterface, BlockInterface, ChainInterface,
|
|
3
|
+
ForkInterface,
|
|
4
|
+
StakeInterface,
|
|
5
|
+
TransactionInterface,
|
|
6
|
+
} from '../interfaces/index.ts'
|
|
7
|
+
|
|
8
|
+
export interface XyoViewer extends BalanceInterface, ChainInterface, BlockInterface, TransactionInterface, StakeInterface, ForkInterface {}
|
package/src/provider/index.ts
CHANGED
|
@@ -4,17 +4,19 @@ import type {
|
|
|
4
4
|
import type { Promisable } from '@xylabs/promise'
|
|
5
5
|
|
|
6
6
|
import type { AttoXL1 } from '../xl1/index.ts'
|
|
7
|
-
import type {
|
|
7
|
+
import type { ServiceInterface } from './Service.ts'
|
|
8
8
|
|
|
9
|
-
export interface
|
|
10
|
-
getBalanceValue
|
|
9
|
+
export interface AccountBalanceProvider {
|
|
10
|
+
getBalanceValue: (address: Address) => bigint
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface AccountBalanceService extends AccountBalanceProvider, ServiceInterface {
|
|
11
14
|
getBalanceValues?: Record<Address, bigint>
|
|
12
15
|
|
|
13
16
|
getBalance(address: Address): Hex
|
|
14
17
|
getBalances(): Record<Address, Hex>
|
|
15
|
-
sync(head: Hash): Promise<void>
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
export interface AccountBalanceServiceV2 extends
|
|
20
|
+
export interface AccountBalanceServiceV2 extends ServiceInterface {
|
|
19
21
|
balances(head: Hash, addresses: Address[]): Promisable<Partial<Record<Address, AttoXL1>>>
|
|
20
22
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { BlockBoundWitness, HydratedBlock } from '../block/index.ts'
|
|
2
2
|
import type { Addressable } from '../fields/index.ts'
|
|
3
3
|
import type { IterableRepository } from '../repository/index.ts'
|
|
4
|
-
import type {
|
|
4
|
+
import type { ServiceInterface } from './Service.ts'
|
|
5
5
|
|
|
6
6
|
export type NextBlockProducer = IterableRepository<BlockBoundWitness, HydratedBlock | undefined>
|
|
7
7
|
|
|
8
|
-
export interface BlockProducerService extends Addressable, NextBlockProducer,
|
|
8
|
+
export interface BlockProducerService extends Addressable, NextBlockProducer, ServiceInterface {}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Promisable } from '@xylabs/promise'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { ServiceInterface } from './Service.ts'
|
|
4
4
|
|
|
5
|
-
export interface BlockRewardService extends
|
|
5
|
+
export interface BlockRewardService extends ServiceInterface {
|
|
6
6
|
getRewardForBlock(block: bigint): Promisable<bigint>
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Chain } from '../../model.ts'
|
|
2
|
-
import type {
|
|
2
|
+
import type { ServiceInterface } from '../Service.ts'
|
|
3
3
|
|
|
4
|
-
export interface BaseChainService extends
|
|
4
|
+
export interface BaseChainService extends ServiceInterface {
|
|
5
5
|
chainId: Chain
|
|
6
6
|
}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ChainContractInterface } from '../../../interfaces/index.ts'
|
|
2
|
+
|
|
3
|
+
export interface ChainContractViewer extends ChainContractInterface {
|
|
2
4
|
|
|
3
|
-
export interface ChainContractViewer {
|
|
4
|
-
active(): Promise<bigint>
|
|
5
|
-
forkedAtBlockNumber(): Promise<bigint>
|
|
6
|
-
forkedAtHash(): Promise<bigint>
|
|
7
|
-
forkedChainId(): Promise<Address>
|
|
8
|
-
minWithdrawalBlocks(): Promise<bigint>
|
|
9
|
-
rewardsContract(): Promise<string>
|
|
10
|
-
stakingTokenAddress(): Promise<string>
|
|
11
5
|
}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
+
import type { ChainStakeInterface } from '../../../interfaces/index.ts'
|
|
1
2
|
import type { ChainContractViewer } from './ChainContractViewer.ts'
|
|
2
3
|
|
|
3
|
-
export interface ChainStakeViewer extends ChainContractViewer {
|
|
4
|
-
|
|
5
|
-
activeByStaker(address: string): Promise<bigint>
|
|
6
|
-
pending(): Promise<bigint>
|
|
7
|
-
pendingByStaker(staker: string): Promise<bigint>
|
|
8
|
-
withdrawn(): Promise<bigint>
|
|
9
|
-
withdrawnByStaker(staker: string): Promise<bigint>
|
|
4
|
+
export interface ChainStakeViewer extends ChainContractViewer, ChainStakeInterface {
|
|
5
|
+
|
|
10
6
|
}
|
package/src/services/Election.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Address } from '@xylabs/hex'
|
|
2
2
|
|
|
3
3
|
import type { BlockBoundWitness } from '../block/index.ts'
|
|
4
|
-
import type {
|
|
4
|
+
import type { ServiceInterface } from './Service.ts'
|
|
5
5
|
|
|
6
|
-
export interface ElectionService extends
|
|
6
|
+
export interface ElectionService extends ServiceInterface {
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Given the current block, get the leader for the next block
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Hash } from '@xylabs/hex'
|
|
2
2
|
|
|
3
3
|
import type { SignedHydratedTransaction } from '../transaction/index.ts'
|
|
4
|
-
import type {
|
|
4
|
+
import type { ServiceInterface } from './Service.ts'
|
|
5
5
|
|
|
6
|
-
export interface PendingTransactionsService extends
|
|
6
|
+
export interface PendingTransactionsService extends ServiceInterface {
|
|
7
7
|
getPendingTransactions(head: Hash, limit: number, timeout?: number): Promise<SignedHydratedTransaction[]>
|
|
8
8
|
}
|
package/src/services/Service.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Address } from '@xylabs/hex'
|
|
2
2
|
|
|
3
3
|
import type { Intent } from '../../payload/index.ts'
|
|
4
|
-
import type {
|
|
4
|
+
import type { ServiceInterface } from '../Service.ts'
|
|
5
5
|
|
|
6
|
-
export interface StakeIntentService extends
|
|
6
|
+
export interface StakeIntentService extends ServiceInterface {
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Gets the declared ranges for an address based on historical on-chain data
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ForkViewer.d.ts","sourceRoot":"","sources":["../../../src/provider/ForkViewer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAEjD,MAAM,WAAW,UAAU;IACzB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,CAAA;IACxD,WAAW,IAAI,UAAU,CAAC,WAAW,CAAC,CAAA;CACvC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StakeViewer.d.ts","sourceRoot":"","sources":["../../../src/provider/StakeViewer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,WAAW,GAAG,KAAK,CAAA;IACnD,IAAI,CAAC,EAAE,KAAK,GAAG,SAAS,GAAG,SAAS,CAAA;CACrC;AAED,MAAM,WAAW,WAAW;IAC1B,WAAW,CAAC,KAAK,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC,MAAM,EAAe,MAAM,CAA6B,CAAC,CAAA;IACtG,UAAU,CAAC,KAAK,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC,MAAM,EAAe,MAAM,CAA6B,CAAC,CAAA;IACrG,WAAW,CAAC,KAAK,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC,MAAM,EAAe,MAAM,CAA6B,CAAC,CAAA;IACtG,WAAW,CAAC,KAAK,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC,MAAM,EAAe,MAAM,CAA6B,CAAC,CAAA;IACtG,MAAM,CAAC,KAAK,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC,MAAM,EAAe,MAAM,CAA6B,CAAC,CAAA;CAClG"}
|