@xyo-network/xl1-protocol-sdk 1.16.26 → 1.17.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 +8 -35
- package/dist/neutral/ChainServiceCollectionV2.d.ts.map +1 -1
- package/dist/neutral/block/hydrate/flattenHydratedBlocks.d.ts +2 -3
- package/dist/neutral/block/hydrate/flattenHydratedBlocks.d.ts.map +1 -1
- package/dist/neutral/index.d.ts +2 -0
- package/dist/neutral/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +1765 -1251
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/model/PayloadBundle/bundledPayloadToHydratedBlock.d.ts +4 -0
- package/dist/neutral/model/PayloadBundle/bundledPayloadToHydratedBlock.d.ts.map +1 -0
- package/dist/neutral/model/PayloadBundle/hydratedBlockToPayloadBundle.d.ts +4 -0
- package/dist/neutral/model/PayloadBundle/hydratedBlockToPayloadBundle.d.ts.map +1 -0
- package/dist/neutral/model/PayloadBundle/index.d.ts +2 -0
- package/dist/neutral/model/PayloadBundle/index.d.ts.map +1 -1
- package/dist/neutral/model/Qualified.d.ts +6 -0
- package/dist/neutral/model/Qualified.d.ts.map +1 -0
- package/dist/neutral/model/index.d.ts +1 -1
- package/dist/neutral/model/index.d.ts.map +1 -1
- package/dist/neutral/payloads/index.d.ts +0 -1
- package/dist/neutral/payloads/index.d.ts.map +1 -1
- package/dist/neutral/primitives/index.d.ts +2 -1
- package/dist/neutral/primitives/index.d.ts.map +1 -1
- package/dist/neutral/primitives/rewardFromBlockNumber.d.ts +3 -0
- package/dist/neutral/primitives/rewardFromBlockNumber.d.ts.map +1 -0
- package/dist/neutral/primitives/state/findMostRecentBlock.d.ts +11 -0
- package/dist/neutral/primitives/state/findMostRecentBlock.d.ts.map +1 -0
- package/dist/neutral/primitives/state/hydratedBlockByNumber.d.ts +4 -0
- package/dist/neutral/primitives/state/hydratedBlockByNumber.d.ts.map +1 -0
- package/dist/neutral/primitives/state/index.d.ts +3 -0
- package/dist/neutral/primitives/state/index.d.ts.map +1 -0
- package/dist/neutral/provider/XyoRunner.d.ts +5 -1
- package/dist/neutral/provider/XyoRunner.d.ts.map +1 -1
- package/dist/neutral/provider/viewer/XyoViewer.d.ts +9 -4
- package/dist/neutral/provider/viewer/XyoViewer.d.ts.map +1 -1
- package/dist/neutral/provider/viewer/index.d.ts +0 -1
- package/dist/neutral/provider/viewer/index.d.ts.map +1 -1
- package/dist/neutral/runners/Block.d.ts +8 -0
- package/dist/neutral/runners/Block.d.ts.map +1 -0
- package/dist/neutral/runners/Mempool.d.ts +9 -0
- package/dist/neutral/runners/Mempool.d.ts.map +1 -0
- package/dist/neutral/runners/index.d.ts +3 -0
- package/dist/neutral/runners/index.d.ts.map +1 -0
- package/dist/neutral/services/BlockProducerService.d.ts +2 -2
- package/dist/neutral/services/BlockProducerService.d.ts.map +1 -1
- package/dist/neutral/services/Chain/BaseChainService.d.ts +0 -2
- package/dist/neutral/services/Chain/BaseChainService.d.ts.map +1 -1
- package/dist/neutral/services/Chain/ChainService.d.ts +2 -3
- package/dist/neutral/services/Chain/ChainService.d.ts.map +1 -1
- package/dist/neutral/services/Chain/index.d.ts +0 -1
- package/dist/neutral/services/Chain/index.d.ts.map +1 -1
- package/dist/neutral/services/index.d.ts +0 -2
- package/dist/neutral/services/index.d.ts.map +1 -1
- package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts +9 -5
- package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts.map +1 -1
- package/dist/neutral/simple/block/SimpleBlockViewer.d.ts +55 -0
- package/dist/neutral/simple/block/SimpleBlockViewer.d.ts.map +1 -0
- package/dist/neutral/simple/block/index.d.ts +2 -0
- package/dist/neutral/simple/block/index.d.ts.map +1 -0
- package/dist/neutral/simple/blockReward/SimpleBlockRewardViewer.d.ts +16 -0
- package/dist/neutral/simple/blockReward/SimpleBlockRewardViewer.d.ts.map +1 -0
- package/dist/neutral/simple/blockReward/index.d.ts +2 -0
- package/dist/neutral/simple/blockReward/index.d.ts.map +1 -0
- package/dist/neutral/simple/chain/SimpleChainViewer.d.ts +12 -0
- package/dist/neutral/simple/chain/SimpleChainViewer.d.ts.map +1 -0
- package/dist/neutral/simple/chain/index.d.ts +2 -0
- package/dist/neutral/simple/chain/index.d.ts.map +1 -0
- package/dist/neutral/simple/index.d.ts +3 -0
- package/dist/neutral/simple/index.d.ts.map +1 -1
- package/dist/neutral/simple/mempool/SimpleMempoolRunner.d.ts +15 -0
- package/dist/neutral/simple/mempool/SimpleMempoolRunner.d.ts.map +1 -0
- package/dist/neutral/simple/mempool/SimpleMempoolViewer.d.ts +10 -4
- package/dist/neutral/simple/mempool/SimpleMempoolViewer.d.ts.map +1 -1
- package/dist/neutral/simple/mempool/index.d.ts +1 -0
- package/dist/neutral/simple/mempool/index.d.ts.map +1 -1
- package/dist/neutral/summary/index.d.ts +3 -0
- package/dist/neutral/summary/index.d.ts.map +1 -0
- package/dist/neutral/summary/model/BalancesStepSummary.d.ts.map +1 -0
- package/dist/neutral/summary/model/SchemasStepSummary.d.ts.map +1 -0
- package/dist/neutral/summary/model/StepSummary.d.ts.map +1 -0
- package/dist/neutral/summary/model/TransfersSummary.d.ts.map +1 -0
- package/dist/neutral/{payloads/summary → summary/model}/index.d.ts +1 -0
- package/dist/neutral/summary/model/index.d.ts.map +1 -0
- package/dist/neutral/{model → summary/model}/summary.d.ts +3 -4
- package/dist/neutral/summary/model/summary.d.ts.map +1 -0
- package/dist/neutral/{primitives/summary → summary/primitives}/balances/balancesStepSummaryFromRange.d.ts +1 -2
- package/dist/neutral/summary/primitives/balances/balancesStepSummaryFromRange.d.ts.map +1 -0
- package/dist/neutral/summary/primitives/balances/balancesSummary.d.ts +5 -0
- package/dist/neutral/summary/primitives/balances/balancesSummary.d.ts.map +1 -0
- package/dist/neutral/summary/primitives/balances/index.d.ts.map +1 -0
- package/dist/neutral/{primitives/summary → summary/primitives}/index.d.ts.map +1 -1
- package/dist/neutral/summary/primitives/schemas/index.d.ts.map +1 -0
- package/dist/neutral/{primitives/summary → summary/primitives}/schemas/schemasStepSummaryFromRange.d.ts +1 -2
- package/dist/neutral/summary/primitives/schemas/schemasStepSummaryFromRange.d.ts.map +1 -0
- package/dist/neutral/summary/primitives/schemas/schemasSummary.d.ts +5 -0
- package/dist/neutral/summary/primitives/schemas/schemasSummary.d.ts.map +1 -0
- package/dist/neutral/summary/primitives/transfers/index.d.ts.map +1 -0
- package/dist/neutral/{primitives/summary → summary/primitives}/transfers/transfersStepSummaryFromRange.d.ts +1 -2
- package/dist/neutral/summary/primitives/transfers/transfersStepSummaryFromRange.d.ts.map +1 -0
- package/dist/neutral/summary/primitives/transfers/transfersSummary.d.ts +6 -0
- package/dist/neutral/summary/primitives/transfers/transfersSummary.d.ts.map +1 -0
- package/dist/neutral/utils/HydratedCache.d.ts +16 -0
- package/dist/neutral/utils/HydratedCache.d.ts.map +1 -0
- package/dist/neutral/utils/index.d.ts +1 -0
- package/dist/neutral/utils/index.d.ts.map +1 -1
- package/dist/neutral/viewers/AccountBalance.d.ts +5 -2
- package/dist/neutral/viewers/AccountBalance.d.ts.map +1 -1
- package/dist/neutral/viewers/Block.d.ts +9 -5
- package/dist/neutral/viewers/Block.d.ts.map +1 -1
- package/dist/neutral/viewers/BlockReward.d.ts +8 -0
- package/dist/neutral/viewers/BlockReward.d.ts.map +1 -0
- package/dist/neutral/viewers/Chain.d.ts +2 -0
- package/dist/neutral/viewers/Chain.d.ts.map +1 -1
- package/dist/neutral/viewers/ChainStakeViewer.d.ts +6 -0
- package/dist/neutral/viewers/ChainStakeViewer.d.ts.map +1 -0
- package/dist/neutral/viewers/Mempool.d.ts +8 -1
- package/dist/neutral/viewers/Mempool.d.ts.map +1 -1
- package/dist/neutral/viewers/StakeIntent.d.ts +10 -0
- package/dist/neutral/viewers/StakeIntent.d.ts.map +1 -0
- package/dist/neutral/{provider/viewer → viewers}/StepViewer.d.ts +2 -2
- package/dist/neutral/viewers/StepViewer.d.ts.map +1 -0
- package/dist/neutral/viewers/index.d.ts +3 -0
- package/dist/neutral/viewers/index.d.ts.map +1 -1
- package/package.json +18 -18
- package/src/ChainServiceCollectionV2.ts +12 -39
- package/src/block/hydrate/flattenHydratedBlocks.ts +2 -3
- package/src/index.ts +2 -1
- package/src/model/PayloadBundle/bundledPayloadToHydratedBlock.ts +14 -0
- package/src/model/PayloadBundle/hydratedBlockToPayloadBundle.ts +18 -0
- package/src/model/PayloadBundle/index.ts +2 -0
- package/src/model/Qualified.ts +9 -0
- package/src/model/index.ts +1 -1
- package/src/payloads/index.ts +0 -1
- package/src/primitives/index.ts +2 -1
- package/src/primitives/rewardFromBlockNumber.ts +25 -0
- package/src/primitives/state/findMostRecentBlock.ts +44 -0
- package/src/primitives/state/hydratedBlockByNumber.ts +19 -0
- package/src/primitives/state/index.ts +2 -0
- package/src/provider/XyoRunner.ts +7 -1
- package/src/provider/viewer/XyoViewer.ts +18 -7
- package/src/provider/viewer/index.ts +0 -1
- package/src/runners/Block.ts +10 -0
- package/src/runners/Mempool.ts +9 -0
- package/src/runners/index.ts +2 -0
- package/src/services/BlockProducerService.ts +3 -2
- package/src/services/Chain/BaseChainService.ts +1 -3
- package/src/services/Chain/ChainService.ts +4 -3
- package/src/services/Chain/index.ts +0 -1
- package/src/services/index.ts +0 -2
- package/src/simple/accountBalance/SimpleAccountBalanceViewer.ts +104 -18
- package/src/simple/block/SimpleBlockViewer.ts +172 -0
- package/src/simple/block/index.ts +1 -0
- package/src/simple/blockReward/SimpleBlockRewardViewer.ts +34 -0
- package/src/simple/blockReward/index.ts +1 -0
- package/src/simple/chain/SimpleChainViewer.ts +25 -0
- package/src/simple/chain/index.ts +1 -0
- package/src/simple/gateway/SimpleXyoGatewayRunner.ts +1 -1
- package/src/simple/index.ts +3 -0
- package/src/simple/mempool/SimpleMempoolRunner.ts +47 -0
- package/src/simple/mempool/SimpleMempoolViewer.ts +34 -8
- package/src/simple/mempool/index.ts +1 -0
- package/src/simple/timesync/SimpleTimeSyncViewer.ts +1 -1
- package/src/summary/index.ts +2 -0
- package/src/{payloads/summary → summary/model}/index.ts +1 -0
- package/src/{model → summary/model}/summary.ts +5 -4
- package/src/{primitives/summary → summary/primitives}/balances/balancesStepSummaryFromRange.ts +4 -3
- package/src/{primitives/summary → summary/primitives}/balances/balancesSummary.ts +6 -5
- package/src/{primitives/summary → summary/primitives}/schemas/schemasStepSummaryFromRange.ts +3 -3
- package/src/{primitives/summary → summary/primitives}/schemas/schemasSummary.ts +7 -6
- package/src/{primitives/summary → summary/primitives}/transfers/transfersStepSummaryFromRange.ts +4 -3
- package/src/{primitives/summary → summary/primitives}/transfers/transfersSummary.ts +6 -5
- package/src/utils/HydratedCache.ts +38 -0
- package/src/utils/index.ts +1 -0
- package/src/viewers/AccountBalance.ts +9 -2
- package/src/viewers/Block.ts +10 -6
- package/src/viewers/BlockReward.ts +9 -0
- package/src/viewers/Chain.ts +2 -0
- package/src/viewers/ChainStakeViewer.ts +7 -0
- package/src/viewers/Mempool.ts +10 -1
- package/src/viewers/StakeIntent.ts +14 -0
- package/src/{provider/viewer → viewers}/StepViewer.ts +2 -2
- package/src/viewers/index.ts +3 -0
- package/dist/neutral/model/summary.d.ts.map +0 -1
- package/dist/neutral/payloads/summary/BalancesStepSummary.d.ts.map +0 -1
- package/dist/neutral/payloads/summary/SchemasStepSummary.d.ts.map +0 -1
- package/dist/neutral/payloads/summary/StepSummary.d.ts.map +0 -1
- package/dist/neutral/payloads/summary/TransfersSummary.d.ts.map +0 -1
- package/dist/neutral/payloads/summary/index.d.ts.map +0 -1
- package/dist/neutral/primitives/summary/balances/balancesStepSummaryFromRange.d.ts.map +0 -1
- package/dist/neutral/primitives/summary/balances/balancesSummary.d.ts +0 -4
- package/dist/neutral/primitives/summary/balances/balancesSummary.d.ts.map +0 -1
- package/dist/neutral/primitives/summary/balances/index.d.ts.map +0 -1
- package/dist/neutral/primitives/summary/schemas/index.d.ts.map +0 -1
- package/dist/neutral/primitives/summary/schemas/schemasStepSummaryFromRange.d.ts.map +0 -1
- package/dist/neutral/primitives/summary/schemas/schemasSummary.d.ts +0 -4
- package/dist/neutral/primitives/summary/schemas/schemasSummary.d.ts.map +0 -1
- package/dist/neutral/primitives/summary/transfers/index.d.ts.map +0 -1
- package/dist/neutral/primitives/summary/transfers/transfersStepSummaryFromRange.d.ts.map +0 -1
- package/dist/neutral/primitives/summary/transfers/transfersSummary.d.ts +0 -5
- package/dist/neutral/primitives/summary/transfers/transfersSummary.d.ts.map +0 -1
- package/dist/neutral/provider/viewer/StepViewer.d.ts.map +0 -1
- package/dist/neutral/services/BlockRewardService.d.ts +0 -5
- package/dist/neutral/services/BlockRewardService.d.ts.map +0 -1
- package/dist/neutral/services/BlockRewardServiceV2.d.ts +0 -6
- package/dist/neutral/services/BlockRewardServiceV2.d.ts.map +0 -1
- package/dist/neutral/services/Chain/interfaces/ChainStakeViewer.d.ts +0 -4
- package/dist/neutral/services/Chain/interfaces/ChainStakeViewer.d.ts.map +0 -1
- package/dist/neutral/services/Chain/interfaces/ChainStaker.d.ts +0 -6
- package/dist/neutral/services/Chain/interfaces/ChainStaker.d.ts.map +0 -1
- package/dist/neutral/services/Chain/interfaces/index.d.ts +0 -3
- package/dist/neutral/services/Chain/interfaces/index.d.ts.map +0 -1
- package/src/services/BlockRewardService.ts +0 -6
- package/src/services/BlockRewardServiceV2.ts +0 -8
- package/src/services/Chain/interfaces/ChainStakeViewer.ts +0 -5
- package/src/services/Chain/interfaces/ChainStaker.ts +0 -5
- package/src/services/Chain/interfaces/index.ts +0 -2
- /package/dist/neutral/{payloads/summary → summary/model}/BalancesStepSummary.d.ts +0 -0
- /package/dist/neutral/{payloads/summary → summary/model}/SchemasStepSummary.d.ts +0 -0
- /package/dist/neutral/{payloads/summary → summary/model}/StepSummary.d.ts +0 -0
- /package/dist/neutral/{payloads/summary → summary/model}/TransfersSummary.d.ts +0 -0
- /package/dist/neutral/{primitives/summary → summary/primitives}/balances/index.d.ts +0 -0
- /package/dist/neutral/{primitives/summary → summary/primitives}/index.d.ts +0 -0
- /package/dist/neutral/{primitives/summary → summary/primitives}/schemas/index.d.ts +0 -0
- /package/dist/neutral/{primitives/summary → summary/primitives}/transfers/index.d.ts +0 -0
- /package/src/{payloads/summary → summary/model}/BalancesStepSummary.ts +0 -0
- /package/src/{payloads/summary → summary/model}/SchemasStepSummary.ts +0 -0
- /package/src/{payloads/summary → summary/model}/StepSummary.ts +0 -0
- /package/src/{payloads/summary → summary/model}/TransfersSummary.ts +0 -0
- /package/src/{primitives/summary → summary/primitives}/balances/index.ts +0 -0
- /package/src/{primitives/summary → summary/primitives}/index.ts +0 -0
- /package/src/{primitives/summary → summary/primitives}/schemas/index.ts +0 -0
- /package/src/{primitives/summary → summary/primitives}/transfers/index.ts +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Address, asHex, Promisable,
|
|
3
|
+
} from '@xylabs/sdk-js'
|
|
4
|
+
import {
|
|
5
|
+
AbstractCreatable,
|
|
6
|
+
creatable, CreatableParams,
|
|
7
|
+
} from '@xylabs/sdk-js'
|
|
8
|
+
import { ChainId } from '@xyo-network/xl1-protocol'
|
|
9
|
+
|
|
10
|
+
import { ChainViewer } from '../../viewers/index.ts'
|
|
11
|
+
|
|
12
|
+
export interface SimpleChainParams extends CreatableParams {
|
|
13
|
+
chainId: Address
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@creatable()
|
|
17
|
+
export class SimpleChainViewer extends AbstractCreatable<SimpleChainParams> implements ChainViewer {
|
|
18
|
+
static override async paramsHandler(params?: Partial<SimpleChainParams>) {
|
|
19
|
+
return ({ ...await super.paramsHandler(params), chainId: asHex(params?.chainId, () => 'chainId not set') }) as SimpleChainParams
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
chainId(): Promisable<ChainId> {
|
|
23
|
+
return this.params.chainId
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SimpleChainViewer.ts'
|
|
@@ -43,7 +43,7 @@ export class SimpleXyoGatewayRunner implements XyoGatewayRunner {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
get dataLakes(): DataLakeRunner[] {
|
|
46
|
-
throw new Error('Method not implemented.')
|
|
46
|
+
throw new Error('Method [dataLakes] not implemented.')
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
get signerInstance(): XyoSigner {
|
package/src/simple/index.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export * from './accountBalance/index.ts'
|
|
2
|
+
export * from './block/index.ts'
|
|
3
|
+
export * from './blockReward/index.ts'
|
|
2
4
|
export * from './chainStake/index.ts'
|
|
3
5
|
export * from './client/index.ts'
|
|
4
6
|
export * from './datalake/index.ts'
|
|
5
7
|
export * from './gateway/index.ts'
|
|
8
|
+
export * from './mempool/index.ts'
|
|
6
9
|
export * from './network/index.ts'
|
|
7
10
|
export * from './permissions/index.ts'
|
|
8
11
|
export * from './runner/index.ts'
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AbstractCreatable, creatable, CreatableParams, type Hash,
|
|
3
|
+
} from '@xylabs/sdk-js'
|
|
4
|
+
import type { ArchivistInstance } from '@xyo-network/archivist-model'
|
|
5
|
+
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
6
|
+
import { type SignedHydratedBlock, type SignedHydratedTransaction } from '@xyo-network/xl1-protocol'
|
|
7
|
+
|
|
8
|
+
import { hydratedBlockToPayloadBundle, hydratedTransactionToPayloadBundle } from '../../model/index.ts'
|
|
9
|
+
import type { MempoolRunner } from '../../runners/index.ts'
|
|
10
|
+
|
|
11
|
+
export interface SimpleMempoolRunnerParams extends CreatableParams {
|
|
12
|
+
pendingBlocksArchivist: ArchivistInstance
|
|
13
|
+
pendingTransactionsArchivist: ArchivistInstance
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@creatable()
|
|
17
|
+
export class SimpleMempoolRunner extends AbstractCreatable<SimpleMempoolRunnerParams> implements MempoolRunner {
|
|
18
|
+
protected get pendingBlocksArchivist() {
|
|
19
|
+
return this.params.pendingBlocksArchivist
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
protected get pendingTransactionsArchivist() {
|
|
23
|
+
return this.params.pendingTransactionsArchivist
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async submitBlocks(blocks: SignedHydratedBlock[]): Promise<Hash[]> {
|
|
27
|
+
const bundles = await Promise.all(blocks.map(async ([bw, payloads]) => {
|
|
28
|
+
return hydratedBlockToPayloadBundle([
|
|
29
|
+
await PayloadBuilder.addHashMeta(bw),
|
|
30
|
+
await PayloadBuilder.addHashMeta(payloads),
|
|
31
|
+
])
|
|
32
|
+
}))
|
|
33
|
+
const inserted = await this.pendingBlocksArchivist.insert(bundles)
|
|
34
|
+
return inserted.map(p => p._hash)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async submitTransactions(transactions: SignedHydratedTransaction[]): Promise<Hash[]> {
|
|
38
|
+
const bundles = await Promise.all(transactions.map(async ([tx, payloads]) => {
|
|
39
|
+
return hydratedTransactionToPayloadBundle([
|
|
40
|
+
await PayloadBuilder.addHashMeta(tx),
|
|
41
|
+
await PayloadBuilder.addHashMeta(payloads),
|
|
42
|
+
])
|
|
43
|
+
}))
|
|
44
|
+
const inserted = await this.pendingBlocksArchivist.insert(bundles)
|
|
45
|
+
return inserted.map(p => p._hash)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -1,34 +1,60 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AbstractCreatable,
|
|
3
|
+
creatable,
|
|
4
|
+
CreatableParams,
|
|
2
5
|
exists, isDefined, isHash,
|
|
3
6
|
} from '@xylabs/sdk-js'
|
|
4
7
|
import type { ArchivistInstance } from '@xyo-network/archivist-model'
|
|
5
8
|
import {
|
|
6
9
|
isHashMeta, isPayloadBundle, type Sequence,
|
|
7
10
|
} from '@xyo-network/payload-model'
|
|
8
|
-
import type { SignedHydratedTransactionWithHashMeta } from '@xyo-network/xl1-protocol'
|
|
11
|
+
import type { SignedHydratedBlockWithHashMeta, SignedHydratedTransactionWithHashMeta } from '@xyo-network/xl1-protocol'
|
|
9
12
|
|
|
10
|
-
import { bundledPayloadToHydratedTransaction } from '../../model/index.ts'
|
|
13
|
+
import { bundledPayloadToHydratedBlock, bundledPayloadToHydratedTransaction } from '../../model/index.ts'
|
|
11
14
|
import type {
|
|
12
15
|
MempoolViewer,
|
|
13
16
|
PendingTransactionsOptions,
|
|
14
17
|
} from '../../viewers/index.ts'
|
|
15
18
|
|
|
16
|
-
export
|
|
17
|
-
|
|
19
|
+
export interface SimpleMempoolViewerParams extends CreatableParams {
|
|
20
|
+
pendingBlocksArchivist: ArchivistInstance
|
|
21
|
+
pendingTransactionsArchivist: ArchivistInstance
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@creatable()
|
|
25
|
+
export class SimpleMempoolViewer extends AbstractCreatable<SimpleMempoolViewerParams> implements MempoolViewer {
|
|
26
|
+
protected get pendingBlocksArchivist() {
|
|
27
|
+
return this.params.pendingBlocksArchivist
|
|
28
|
+
}
|
|
18
29
|
|
|
19
|
-
|
|
20
|
-
this.
|
|
30
|
+
protected get pendingTransactionsArchivist() {
|
|
31
|
+
return this.params.pendingTransactionsArchivist
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async pendingBlocks({ cursor: providedCursor }: PendingTransactionsOptions = {}): Promise<SignedHydratedBlockWithHashMeta[]> {
|
|
35
|
+
let cursor: Sequence | undefined = undefined
|
|
36
|
+
if (isHash(providedCursor)) {
|
|
37
|
+
const [p] = await this.pendingBlocksArchivist.get([providedCursor])
|
|
38
|
+
if (isDefined(p)) {
|
|
39
|
+
cursor = p._sequence
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const bundles = await this.pendingBlocksArchivist.next({
|
|
43
|
+
order: 'asc', limit: 100, cursor,
|
|
44
|
+
})
|
|
45
|
+
const filteredBundles = bundles.filter(isPayloadBundle).filter(isHashMeta)
|
|
46
|
+
return (await Promise.all(filteredBundles.map(async bundle => await bundledPayloadToHydratedBlock(bundle)))).filter(exists)
|
|
21
47
|
}
|
|
22
48
|
|
|
23
49
|
async pendingTransactions({ cursor: providedCursor }: PendingTransactionsOptions = {}): Promise<SignedHydratedTransactionWithHashMeta[]> {
|
|
24
50
|
let cursor: Sequence | undefined = undefined
|
|
25
51
|
if (isHash(providedCursor)) {
|
|
26
|
-
const [p] = await this.
|
|
52
|
+
const [p] = await this.pendingTransactionsArchivist.get([providedCursor])
|
|
27
53
|
if (isDefined(p)) {
|
|
28
54
|
cursor = p._sequence
|
|
29
55
|
}
|
|
30
56
|
}
|
|
31
|
-
const bundles = await this.
|
|
57
|
+
const bundles = await this.pendingTransactionsArchivist.next({
|
|
32
58
|
order: 'asc', limit: 100, cursor,
|
|
33
59
|
})
|
|
34
60
|
const filteredBundles = bundles.filter(isPayloadBundle).filter(isHashMeta)
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { Payload } from '@xyo-network/payload-model'
|
|
2
2
|
import type { Semaphore } from 'async-mutex'
|
|
3
3
|
|
|
4
|
-
import type { MapTypeRead, MapTypeWrite } from '
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
|
|
4
|
+
import type { MapTypeRead, MapTypeWrite } from '../../map/index.ts'
|
|
5
|
+
import type { BaseContext, ChainContextRead } from '../../model/index.ts'
|
|
6
|
+
import type {
|
|
7
|
+
BalancesStepSummary, SchemasStepSummary, TransfersStepSummary,
|
|
8
|
+
} from './index.ts'
|
|
8
9
|
|
|
9
10
|
export interface ChainSummaryContextBase<TPayload extends Payload,
|
|
10
11
|
T extends (MapTypeRead<string, TPayload> | MapTypeWrite<string, TPayload>)> extends BaseContext {
|
package/src/{primitives/summary → summary/primitives}/balances/balancesStepSummaryFromRange.ts
RENAMED
|
@@ -11,12 +11,13 @@ import {
|
|
|
11
11
|
deepCalculateFramesFromRange, hashFromBlockNumber,
|
|
12
12
|
hydrateBlock,
|
|
13
13
|
} from '../../../block/index.ts'
|
|
14
|
-
import
|
|
15
|
-
import type { BalancesStepSummary } from '../../../payloads/index.ts'
|
|
16
|
-
import { BalancesStepSummarySchema, netBalancesForPayloads } from '../../../payloads/index.ts'
|
|
14
|
+
import { netBalancesForPayloads } from '../../../payloads/index.ts'
|
|
17
15
|
import {
|
|
18
16
|
parseSignedBigInt, type SignedBigInt, toSignedBigInt,
|
|
19
17
|
} from '../../../SignedBigInt.ts'
|
|
18
|
+
import {
|
|
19
|
+
type BalancesStepSummary, BalancesStepSummarySchema, type BalanceStepSummaryContext,
|
|
20
|
+
} from '../../model/index.ts'
|
|
20
21
|
|
|
21
22
|
export async function balancesStepSummaryFromRange(
|
|
22
23
|
context: BalanceStepSummaryContext,
|
|
@@ -6,30 +6,31 @@ import {
|
|
|
6
6
|
} from '@xyo-network/xl1-protocol'
|
|
7
7
|
|
|
8
8
|
import { deepCalculateFramesFromRange } from '../../../block/index.ts'
|
|
9
|
-
import type {
|
|
9
|
+
import type { Qualified } from '../../../model/index.ts'
|
|
10
10
|
import { parseSignedBigInt } from '../../../SignedBigInt.ts'
|
|
11
|
+
import type { BalanceStepSummaryContext } from '../../model/index.ts'
|
|
11
12
|
import { balancesStepSummaryFromRange } from './balancesStepSummaryFromRange.ts'
|
|
12
13
|
|
|
13
14
|
export async function balancesSummary(
|
|
14
15
|
context: BalanceStepSummaryContext,
|
|
15
|
-
): Promise<
|
|
16
|
+
): Promise<Qualified<Record<Address, bigint>>> {
|
|
16
17
|
return await spanRootAsync('balancesSummary', async () => {
|
|
17
18
|
const [headHash] = await context.head()
|
|
18
19
|
const headResult = await context.store.chainMap.get(headHash)
|
|
19
20
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta(headResult, () => `Head block not found for hash: ${headHash}`)
|
|
20
|
-
const rangeStart = asXL1BlockNumber(isDefined(context.windowSize) ? Math.max(headBoundWitness.block - context.windowSize + 1, 0) : 0)
|
|
21
|
+
const rangeStart = asXL1BlockNumber(isDefined(context.windowSize) ? Math.max(headBoundWitness.block - context.windowSize + 1, 0) : 0, true)
|
|
21
22
|
const ranges = deepCalculateFramesFromRange(asXL1BlockRange(
|
|
22
23
|
[rangeStart, headBoundWitness.block],
|
|
23
24
|
{ name: 'balancesSummary' },
|
|
24
25
|
))
|
|
25
26
|
const summaries = await Promise.all(ranges.map(range => balancesStepSummaryFromRange(context, range)))
|
|
26
|
-
const balances:
|
|
27
|
+
const balances: Record<Address, bigint> = {}
|
|
27
28
|
for (let summary of summaries) {
|
|
28
29
|
for (const [address, balance] of Object.entries(summary.balances)) {
|
|
29
30
|
const validAddress = asAddress(address, () => `Invalid address: ${address}`)
|
|
30
31
|
balances[validAddress] = (balances[validAddress] ?? 0n) + parseSignedBigInt(balance)
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
|
-
return balances
|
|
34
|
+
return [balances, [rangeStart, headBoundWitness.block], headHash]
|
|
34
35
|
})
|
|
35
36
|
}
|
package/src/{primitives/summary → summary/primitives}/schemas/schemasStepSummaryFromRange.ts
RENAMED
|
@@ -12,9 +12,9 @@ import {
|
|
|
12
12
|
deepCalculateFramesFromRange, hashFromBlockNumber,
|
|
13
13
|
hydrateBlock,
|
|
14
14
|
} from '../../../block/index.ts'
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
import {
|
|
16
|
+
type SchemasStepSummary, type SchemasStepSummaryContext, SchemasStepSummarySchema,
|
|
17
|
+
} from '../../model/index.ts'
|
|
18
18
|
|
|
19
19
|
export async function schemasStepSummaryFromRange(
|
|
20
20
|
context: SchemasStepSummaryContext,
|
|
@@ -6,28 +6,29 @@ import {
|
|
|
6
6
|
} from '@xyo-network/xl1-protocol'
|
|
7
7
|
|
|
8
8
|
import { deepCalculateFramesFromRange } from '../../../block/index.ts'
|
|
9
|
-
import type {
|
|
9
|
+
import type { Qualified } from '../../../model/index.ts'
|
|
10
|
+
import type { SchemasStepSummaryContext } from '../../model/index.ts'
|
|
10
11
|
import { schemasStepSummaryFromRange } from './schemasStepSummaryFromRange.ts'
|
|
11
12
|
|
|
12
13
|
export async function schemasSummary(
|
|
13
14
|
context: SchemasStepSummaryContext,
|
|
14
|
-
): Promise<
|
|
15
|
+
): Promise<Qualified<Record<Schema, number>>> {
|
|
15
16
|
return await spanRootAsync('schemasSummary', async () => {
|
|
16
17
|
const [headHash] = await context.head()
|
|
17
18
|
const headResult = await context.store.chainMap.get(headHash)
|
|
18
19
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta(headResult, () => `Head block not found for hash: ${headHash}`)
|
|
19
|
-
const rangeStart = asXL1BlockNumber(isDefined(context.windowSize) ? Math.max(headBoundWitness.block - context.windowSize + 1, 0) : 0)
|
|
20
|
+
const rangeStart = asXL1BlockNumber(isDefined(context.windowSize) ? Math.max(headBoundWitness.block - context.windowSize + 1, 0) : 0, true)
|
|
20
21
|
const ranges = deepCalculateFramesFromRange(asXL1BlockRange(
|
|
21
22
|
[rangeStart, headBoundWitness.block],
|
|
22
23
|
{ name: 'schemasSummary' },
|
|
23
24
|
))
|
|
24
25
|
const summaries = await Promise.all(ranges.map(range => schemasStepSummaryFromRange(context, range)))
|
|
25
|
-
const
|
|
26
|
+
const results: Record<Schema, number> = {}
|
|
26
27
|
for (let summary of summaries) {
|
|
27
28
|
for (const [schema, count] of Object.entries(summary.schemas)) {
|
|
28
|
-
|
|
29
|
+
results[schema] = (results[schema] ?? 0) + count
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
|
-
return
|
|
32
|
+
return [results, [rangeStart, headBoundWitness.block], headHash]
|
|
32
33
|
})
|
|
33
34
|
}
|
package/src/{primitives/summary → summary/primitives}/transfers/transfersStepSummaryFromRange.ts
RENAMED
|
@@ -10,12 +10,13 @@ import { StepSizes } from '@xyo-network/xl1-protocol'
|
|
|
10
10
|
import {
|
|
11
11
|
deepCalculateFramesFromRange, hashFromBlockNumber, hydrateBlock,
|
|
12
12
|
} from '../../../block/index.ts'
|
|
13
|
-
import
|
|
14
|
-
import type { TransfersStepSummary } from '../../../payloads/index.ts'
|
|
15
|
-
import { netTransfersForPayloads, TransfersStepSummarySchema } from '../../../payloads/index.ts'
|
|
13
|
+
import { netTransfersForPayloads } from '../../../payloads/index.ts'
|
|
16
14
|
import {
|
|
17
15
|
parseSignedBigInt, type SignedBigInt, toSignedBigInt,
|
|
18
16
|
} from '../../../SignedBigInt.ts'
|
|
17
|
+
import {
|
|
18
|
+
type TransfersStepSummary, type TransfersStepSummaryContext, TransfersStepSummarySchema,
|
|
19
|
+
} from '../../model/index.ts'
|
|
19
20
|
import { transfersSummaryKey } from './transfersSummary.ts'
|
|
20
21
|
|
|
21
22
|
export async function transfersStepSummaryFromRange(
|
|
@@ -6,25 +6,26 @@ import {
|
|
|
6
6
|
} from '@xyo-network/xl1-protocol'
|
|
7
7
|
|
|
8
8
|
import { deepCalculateFramesFromRange } from '../../../block/index.ts'
|
|
9
|
-
import type {
|
|
9
|
+
import type { Qualified } from '../../../model/index.ts'
|
|
10
10
|
import { parseSignedBigInt } from '../../../SignedBigInt.ts'
|
|
11
|
+
import type { TransfersStepSummaryContext } from '../../index.ts'
|
|
11
12
|
import { transfersStepSummaryFromRange } from './transfersStepSummaryFromRange.ts'
|
|
12
13
|
|
|
13
14
|
// the summary of amount of rewards claimed from the step reward pool by addresses
|
|
14
15
|
export async function transfersSummary(
|
|
15
16
|
transferContext: TransfersStepSummaryContext,
|
|
16
|
-
): Promise<
|
|
17
|
+
): Promise<Qualified<Record<Address, Record<Address, bigint>>>> {
|
|
17
18
|
return await spanRootAsync('transferSummary', async () => {
|
|
18
19
|
const [headHash] = await transferContext.head()
|
|
19
20
|
const headResult = await transferContext.store.chainMap.get(headHash)
|
|
20
21
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta(headResult, () => `Head block not found for hash: ${transferContext.head}`)
|
|
21
|
-
const rangeStart = asXL1BlockNumber(isDefined(transferContext.windowSize) ? Math.max(headBoundWitness.block - transferContext.windowSize + 1, 0) : 0)
|
|
22
|
+
const rangeStart = asXL1BlockNumber(isDefined(transferContext.windowSize) ? Math.max(headBoundWitness.block - transferContext.windowSize + 1, 0) : 0, true)
|
|
22
23
|
const ranges = deepCalculateFramesFromRange(asXL1BlockRange(
|
|
23
24
|
[rangeStart, headBoundWitness.block],
|
|
24
25
|
{ name: 'transfersSummary' },
|
|
25
26
|
))
|
|
26
27
|
const summaries = await Promise.all(ranges.map(range => transfersStepSummaryFromRange(transferContext, range)))
|
|
27
|
-
const transfers:
|
|
28
|
+
const transfers: Record<Address, Record<Address, bigint>> = {}
|
|
28
29
|
for (let summary of summaries) {
|
|
29
30
|
for (const [from, toMap] of Object.entries(summary.transfers)) {
|
|
30
31
|
const validFrom = asAddress(from, () => `Invalid address: ${from}`)
|
|
@@ -35,7 +36,7 @@ export async function transfersSummary(
|
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
|
-
return transfers
|
|
39
|
+
return [transfers, [rangeStart, headBoundWitness.block], headHash]
|
|
39
40
|
})
|
|
40
41
|
}
|
|
41
42
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Hash } from '@xylabs/sdk-js'
|
|
2
|
+
import type { Payload, WithStorageMeta } from '@xyo-network/payload-model'
|
|
3
|
+
import { LRUCache } from 'lru-cache'
|
|
4
|
+
|
|
5
|
+
import type { PayloadMapRead } from '../model/index.ts'
|
|
6
|
+
|
|
7
|
+
export type HydrateFunction<T> = (
|
|
8
|
+
context: { chainMap: PayloadMapRead<WithStorageMeta<Payload>> },
|
|
9
|
+
hash: Hash,
|
|
10
|
+
) => Promise<T | undefined>
|
|
11
|
+
|
|
12
|
+
export class HydratedCache<T extends {}> {
|
|
13
|
+
protected readonly cache: LRUCache<Hash, T>
|
|
14
|
+
protected readonly chainMap: PayloadMapRead<WithStorageMeta<Payload>>
|
|
15
|
+
protected readonly hydrateFunction: HydrateFunction<T>
|
|
16
|
+
|
|
17
|
+
constructor(
|
|
18
|
+
chainMap: PayloadMapRead<WithStorageMeta<Payload>>,
|
|
19
|
+
hydrateFunction: HydrateFunction<T>,
|
|
20
|
+
maxSize: number = 200,
|
|
21
|
+
) {
|
|
22
|
+
this.chainMap = chainMap
|
|
23
|
+
this.hydrateFunction = hydrateFunction
|
|
24
|
+
this.cache = new LRUCache<Hash, T>({ max: maxSize })
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async get(hash: Hash): Promise<T | null> {
|
|
28
|
+
const existing = this.cache.get(hash)
|
|
29
|
+
if (existing !== undefined) return existing
|
|
30
|
+
const block = (await this.hydrateFunction({ chainMap: this.chainMap }, hash)) ?? null
|
|
31
|
+
if (block !== null) this.cache.set(hash, block)
|
|
32
|
+
return block
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
has(hash: Hash): boolean {
|
|
36
|
+
return this.cache.has(hash)
|
|
37
|
+
}
|
|
38
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
import { BlockBoundWitnessZod, TransactionBoundWitnessZod } from '@xyo-network/xl1-protocol'
|
|
11
11
|
import z from 'zod'
|
|
12
12
|
|
|
13
|
+
import type { Qualified } from '../model/index.ts'
|
|
14
|
+
|
|
13
15
|
export const AccountBalanceHistoryItemZod = z.tuple([
|
|
14
16
|
WithHashMetaZod(BlockBoundWitnessZod),
|
|
15
17
|
WithHashMetaZod(TransactionBoundWitnessZod).nullable(),
|
|
@@ -19,11 +21,16 @@ export const AccountBalanceHistoryItemZod = z.tuple([
|
|
|
19
21
|
export type AccountBalanceHistoryItem = z.infer<typeof AccountBalanceHistoryItemZod>
|
|
20
22
|
|
|
21
23
|
export interface AccountBalanceViewerMethods {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
qualifiedAccountBalanceHistories(
|
|
25
|
+
address: Address[],
|
|
26
|
+
headOrRange?: Hash | XL1BlockRange
|
|
27
|
+
): Promisable<Qualified<Record<Address, AccountBalanceHistoryItem[]>>>
|
|
28
|
+
qualifiedAccountBalances(address: Address[], headOrRange?: Hash | XL1BlockRange): Promisable<Qualified<Record<Address, AttoXL1>>>
|
|
24
29
|
}
|
|
25
30
|
|
|
26
31
|
export interface AccountBalanceViewer extends AccountBalanceViewerMethods {
|
|
27
32
|
accountBalance(address: Address, headOrRange?: Hash | XL1BlockRange): Promisable<AttoXL1>
|
|
33
|
+
accountBalanceHistories(address: Address[], headOrRange?: Hash | XL1BlockRange): Promisable<Record<Address, AccountBalanceHistoryItem[]>>
|
|
28
34
|
accountBalanceHistory(address: Address, headOrRange?: Hash | XL1BlockRange): Promisable<AccountBalanceHistoryItem[]>
|
|
35
|
+
accountBalances(address: Address[], headOrRange?: Hash | XL1BlockRange): Promisable<Record<Address, AttoXL1>>
|
|
29
36
|
}
|
package/src/viewers/Block.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import type { Hash, Promisable } from '@xylabs/sdk-js'
|
|
2
|
+
import type { Payload, WithHashMeta } from '@xyo-network/payload-model'
|
|
2
3
|
import type { SignedHydratedBlockWithHashMeta, XL1BlockNumber } from '@xyo-network/xl1-protocol'
|
|
3
4
|
|
|
4
|
-
export interface
|
|
5
|
-
blockByHash(hash: Hash): Promisable<SignedHydratedBlockWithHashMeta | null>
|
|
6
|
-
blockByNumber(block: XL1BlockNumber): Promisable<SignedHydratedBlockWithHashMeta | null>
|
|
5
|
+
export interface BlockViewerMethods {
|
|
7
6
|
blocksByHash(hash: Hash, limit?: number): Promisable<SignedHydratedBlockWithHashMeta[]>
|
|
8
|
-
|
|
7
|
+
blocksByNumber(block: XL1BlockNumber, limit?: number): Promisable<SignedHydratedBlockWithHashMeta[]>
|
|
9
8
|
currentBlock(): Promisable<SignedHydratedBlockWithHashMeta>
|
|
9
|
+
payloadsByHash(hashes: Hash[]): Promisable<WithHashMeta<Payload>[]>
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface BlockViewer extends BlockViewerMethods {
|
|
13
|
+
blockByHash(hash: Hash): Promisable<SignedHydratedBlockWithHashMeta | null>
|
|
14
|
+
blockByNumber(block: XL1BlockNumber): Promisable<SignedHydratedBlockWithHashMeta | null>
|
|
10
15
|
currentBlockHash(): Promisable<Hash>
|
|
11
16
|
currentBlockNumber(): Promisable<XL1BlockNumber>
|
|
17
|
+
payloadByHash(hash: Hash): Promisable<WithHashMeta<Payload> | null>
|
|
12
18
|
}
|
|
13
|
-
|
|
14
|
-
export interface BlockViewer extends BlockViewierMethods {}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Promisable } from '@xylabs/sdk-js'
|
|
2
|
+
import type { AttoXL1, XL1BlockNumber } from '@xyo-network/xl1-protocol'
|
|
3
|
+
|
|
4
|
+
export interface BlockRewardViewerMethods {
|
|
5
|
+
// The amount of xl1 to send to the producer from the block reward
|
|
6
|
+
allowedRewardForBlock(block: XL1BlockNumber): Promisable<AttoXL1>
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface BlockRewardViewer extends BlockRewardViewerMethods {}
|
package/src/viewers/Chain.ts
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ChainViewer } from './Chain.ts'
|
|
2
|
+
import type { ChainContractViewer } from './ChainContract.ts'
|
|
3
|
+
import type { StakeTotalsViewer } from './StakeTotals.ts'
|
|
4
|
+
|
|
5
|
+
export interface ChainStakeViewer extends ChainContractViewer, StakeTotalsViewer, ChainViewer {
|
|
6
|
+
|
|
7
|
+
}
|
package/src/viewers/Mempool.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HashZod } from '@xylabs/sdk-js'
|
|
2
|
-
import type { SignedHydratedTransactionWithHashMeta } from '@xyo-network/xl1-protocol'
|
|
2
|
+
import type { SignedHydratedBlockWithHashMeta, SignedHydratedTransactionWithHashMeta } from '@xyo-network/xl1-protocol'
|
|
3
3
|
import { XL1BlockRangeZod } from '@xyo-network/xl1-protocol'
|
|
4
4
|
import z from 'zod'
|
|
5
5
|
|
|
@@ -11,7 +11,16 @@ export const PendingTransactionsOptionsZod = z.object({
|
|
|
11
11
|
|
|
12
12
|
export type PendingTransactionsOptions = z.infer<typeof PendingTransactionsOptionsZod>
|
|
13
13
|
|
|
14
|
+
export const PendingBlocksOptionsZod = z.object({
|
|
15
|
+
cursor: HashZod.optional(),
|
|
16
|
+
limit: z.number().int().positive().optional(),
|
|
17
|
+
window: XL1BlockRangeZod.optional(),
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
export type PendingBlocksOptions = z.infer<typeof PendingBlocksOptionsZod>
|
|
21
|
+
|
|
14
22
|
export interface MempoolViewerMethods {
|
|
23
|
+
pendingBlocks(options?: PendingBlocksOptions): Promise<SignedHydratedBlockWithHashMeta[]>
|
|
15
24
|
pendingTransactions(options?: PendingTransactionsOptions): Promise<SignedHydratedTransactionWithHashMeta[]>
|
|
16
25
|
}
|
|
17
26
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Address, Hash, Promisable,
|
|
3
|
+
} from '@xylabs/sdk-js'
|
|
4
|
+
import type { ChainStakeIntent, XL1BlockRange } from '@xyo-network/xl1-protocol'
|
|
5
|
+
|
|
6
|
+
import type { Qualified } from '../model/index.ts'
|
|
7
|
+
|
|
8
|
+
export interface StakeIntentViewerMethods {
|
|
9
|
+
qualifiedIntentByAddress(address: Address, headOrRange?: Hash | XL1BlockRange): Promisable<Qualified<ChainStakeIntent | null>>
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface StakeIntentViewer extends StakeIntentViewerMethods {
|
|
13
|
+
intentByAddress(address: Address, headOrRange?: Hash | XL1BlockRange): Promisable<ChainStakeIntent | null>
|
|
14
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Address, Promisable } from '@xylabs/sdk-js'
|
|
2
2
|
import type { PositionId, StepIdentity } from '@xyo-network/xl1-protocol'
|
|
3
3
|
|
|
4
|
-
import type { Position } from '
|
|
5
|
-
import type { NetworkStakeStepRewardsViewer } from '
|
|
4
|
+
import type { Position } from '../model/index.ts'
|
|
5
|
+
import type { NetworkStakeStepRewardsViewer } from '../provider/index.ts'
|
|
6
6
|
|
|
7
7
|
export interface PagedPositionsOptions {
|
|
8
8
|
cursor?: PositionId
|
package/src/viewers/index.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export * from './AccountBalance.ts'
|
|
2
2
|
export * from './Block.ts'
|
|
3
|
+
export * from './BlockReward.ts'
|
|
3
4
|
export * from './Chain.ts'
|
|
4
5
|
export * from './ChainContract.ts'
|
|
6
|
+
export * from './ChainStakeViewer.ts'
|
|
5
7
|
export * from './Fork.ts'
|
|
6
8
|
export * from './Mempool.ts'
|
|
7
9
|
export * from './NetworkStakeStepReward.ts'
|
|
@@ -9,6 +11,7 @@ export * from './Stake.ts'
|
|
|
9
11
|
export * from './StakeEvents.ts'
|
|
10
12
|
export * from './StakeTotals.ts'
|
|
11
13
|
export * from './StepStake.ts'
|
|
14
|
+
export * from './StepViewer.ts'
|
|
12
15
|
export * from './TimeSync.ts'
|
|
13
16
|
export * from './Transaction.ts'
|
|
14
17
|
export * from './TransferBalance.ts'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../../../src/model/summary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE5C,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAC9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAA;AAC7F,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAE/D,MAAM,WAAW,uBAAuB,CAAC,QAAQ,SAAS,OAAO,EAC/D,CAAC,SAAS,CAAC,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAE,SAAQ,WAAW;IAC/F,cAAc,EAAE,SAAS,EAAE,CAAA;IAC3B,UAAU,EAAE,CAAC,CAAA;IACb,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,uBAAuB,CAAC,CAAC,SAAS,OAAO,CAAE,SAAQ,uBAAuB,CAAC,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,gBAAgB;CAAG;AAE3I,MAAM,WAAW,wBAAwB,CAAC,CAAC,SAAS,OAAO,CAAE,SAAQ,uBAAuB,CAAC,CAAC,EAAE,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,gBAAgB;CAAG;AAE7I,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,OAAO,IAAI,uBAAuB,CAAC,CAAC,CAAC,GAAG,wBAAwB,CAAC,CAAC,CAAC,CAAA;AAE7G,MAAM,WAAW,6BAA8B,SAAQ,uBAAuB,CAAC,mBAAmB,CAAC;CAAG;AAEtG,MAAM,WAAW,yBAA0B,SAAQ,mBAAmB,CAAC,mBAAmB,CAAC;CAAG;AAE9F,MAAM,WAAW,+BAAgC,SAAQ,uBAAuB,CAAC,oBAAoB,CAAC;CAAG;AAEzG,MAAM,WAAW,2BAA4B,SAAQ,mBAAmB,CAAC,oBAAoB,CAAC;CAAG;AAEjG,MAAM,WAAW,6BAA8B,SAAQ,uBAAuB,CAAC,kBAAkB,CAAC;CAAG;AAErG,MAAM,WAAW,yBAA0B,SAAQ,mBAAmB,CAAC,kBAAkB,CAAC;CAAG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BalancesStepSummary.d.ts","sourceRoot":"","sources":["../../../../src/payloads/summary/BalancesStepSummary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAE7C,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAGzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,eAAO,MAAM,yBAAyB,EAAE,MAA4C,CAAA;AACpF,MAAM,MAAM,yBAAyB,GAAG,OAAO,yBAAyB,CAAA;AAExE,MAAM,MAAM,mBAAmB,GAAG,WAAW,CAAC;IAC5C,QAAQ,EAAE,MAAM,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA;CACxC,EAAE,yBAAyB,CAAC,CAAA;AAE7B;;GAEG;AACH,eAAO,MAAM,qBAAqB,kDAAwE,CAAA;AAC1G,eAAO,MAAM,qBAAqB,8DAAqE,CAAA;AAEvG;;GAEG;AACH,eAAO,MAAM,oCAAoC,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,eAAe,CAAC,mBAAmB,CAEjH,CAAA;AACD,eAAO,MAAM,oCAAoC,+EAAqG,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SchemasStepSummary.d.ts","sourceRoot":"","sources":["../../../../src/payloads/summary/SchemasStepSummary.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAGzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,eAAO,MAAM,wBAAwB,EAAE,MAA2C,CAAA;AAClF,MAAM,MAAM,wBAAwB,GAAG,OAAO,wBAAwB,CAAA;AAEtE,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAChC,EAAE,wBAAwB,CAAC,CAAA;AAE5B;;GAEG;AACH,eAAO,MAAM,oBAAoB,iDAAsE,CAAA;AACvG,eAAO,MAAM,oBAAoB,6DAAmE,CAAA;AAEpG;;GAEG;AACH,eAAO,MAAM,mCAAmC,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,eAAe,CAAC,kBAAkB,CAE/G,CAAA;AACD,eAAO,MAAM,mCAAmC,8EAAmG,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StepSummary.d.ts","sourceRoot":"","sources":["../../../../src/payloads/summary/StepSummary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAEjE,eAAO,MAAM,iBAAiB,EAAE,MAAmC,CAAA;AACnE,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAA;AAExD,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,IAAI,CAAA;IACV,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,MAAM,WAAW,CAAC,iBAAiB,SAAS,WAAW,GAAG,IAAI,GAAG,IAAI,EACzE,OAAO,SAAS,MAAM,GAAG,IAAI,GAAG,IAAI,IAAI,OAAO,CAAC,iBAAiB,SAAS,IAAI,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,iBAAiB,EAC1I,OAAO,SAAS,IAAI,GAAG,iBAAiB,GAAG,OAAO,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TransfersSummary.d.ts","sourceRoot":"","sources":["../../../../src/payloads/summary/TransfersSummary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAE7C,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAGzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,eAAO,MAAM,0BAA0B,EAAE,MAA4C,CAAA;AACrF,MAAM,MAAM,0BAA0B,GAAG,OAAO,0BAA0B,CAAA;AAE1E,MAAM,MAAM,oBAAoB,GAAG,WAAW,CAAC;IAC7C,SAAS,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAA;CAC1D,EAAE,0BAA0B,CAAC,CAAA;AAE9B;;GAEG;AACH,eAAO,MAAM,sBAAsB,mDAA0E,CAAA;AAC7G,eAAO,MAAM,sBAAsB,+DAAuE,CAAA;AAE1G;;GAEG;AACH,eAAO,MAAM,qCAAqC,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,eAAe,CAAC,oBAAoB,CAEnH,CAAA;AACD,eAAO,MAAM,qCAAqC,gFACsD,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/payloads/summary/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,kBAAkB,CAAA;AAChC,cAAc,uBAAuB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"balancesStepSummaryFromRange.d.ts","sourceRoot":"","sources":["../../../../../src/primitives/summary/balances/balancesStepSummaryFromRange.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAEjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAO9D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AACxE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAMrE,wBAAsB,4BAA4B,CAChD,OAAO,EAAE,yBAAyB,EAClC,KAAK,EAAE,aAAa,GACnB,OAAO,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC,CA+D/C"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Address } from '@xylabs/sdk-js';
|
|
2
|
-
import type { BalanceStepSummaryContext } from '../../../model/index.ts';
|
|
3
|
-
export declare function balancesSummary(context: BalanceStepSummaryContext): Promise<Partial<Record<Address, bigint>>>;
|
|
4
|
-
//# sourceMappingURL=balancesSummary.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"balancesSummary.d.ts","sourceRoot":"","sources":["../../../../../src/primitives/summary/balances/balancesSummary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAQ7C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AAIxE,wBAAsB,eAAe,CACnC,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,CAoB3C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/primitives/summary/balances/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAA;AACjD,cAAc,sBAAsB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/primitives/summary/schemas/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAA;AAChD,cAAc,qBAAqB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schemasStepSummaryFromRange.d.ts","sourceRoot":"","sources":["../../../../../src/primitives/summary/schemas/schemasStepSummaryFromRange.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACF,YAAY,EACrB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAO9D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AACxE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAGpE,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,yBAAyB,EAClC,KAAK,EAAE,aAAa,GACnB,OAAO,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC,CA6D3C"}
|