@xyo-network/xl1-protocol-sdk 1.18.0-rc.1 → 1.18.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/CreatableProvider/AbstractCreatableProvider.d.ts +57 -25
- package/dist/neutral/CreatableProvider/AbstractCreatableProvider.d.ts.map +1 -1
- package/dist/neutral/CreatableProvider/CreatableProvider.d.ts +16 -11
- package/dist/neutral/CreatableProvider/CreatableProvider.d.ts.map +1 -1
- package/dist/neutral/CreatableProvider/CreatableProviderRegistry.d.ts +2 -4
- package/dist/neutral/CreatableProvider/CreatableProviderRegistry.d.ts.map +1 -1
- package/dist/neutral/CreatableProvider/ProviderFactory.d.ts +6 -4
- package/dist/neutral/CreatableProvider/ProviderFactory.d.ts.map +1 -1
- package/dist/neutral/CreatableProvider/ProviderFactoryLocator.d.ts +7 -7
- package/dist/neutral/CreatableProvider/ProviderFactoryLocator.d.ts.map +1 -1
- package/dist/neutral/CreatableProvider/ProviderFactoryLocatorInstance.d.ts +3 -2
- package/dist/neutral/CreatableProvider/ProviderFactoryLocatorInstance.d.ts.map +1 -1
- package/dist/neutral/actor/Actor.d.ts +176 -0
- package/dist/neutral/actor/Actor.d.ts.map +1 -0
- package/dist/neutral/actor/index.d.ts +2 -0
- package/dist/neutral/actor/index.d.ts.map +1 -0
- package/dist/neutral/block/hydrate/allHashesPresent.d.ts +2 -2
- package/dist/neutral/block/hydrate/allHashesPresent.d.ts.map +1 -1
- package/dist/neutral/block/hydrate/hydrateBlock.d.ts +2 -2
- package/dist/neutral/block/hydrate/hydrateBlock.d.ts.map +1 -1
- package/dist/neutral/config/Api.d.ts +1 -1
- package/dist/neutral/config/Api.d.ts.map +1 -1
- package/dist/neutral/config/Bridge.d.ts +41 -21
- package/dist/neutral/config/Bridge.d.ts.map +1 -1
- package/dist/neutral/config/Chain.d.ts +7 -3
- package/dist/neutral/config/Chain.d.ts.map +1 -1
- package/dist/neutral/config/Config.d.ts +50 -22
- package/dist/neutral/config/Config.d.ts.map +1 -1
- package/dist/neutral/config/Evm.d.ts +1 -1
- package/dist/neutral/config/Evm.d.ts.map +1 -1
- package/dist/neutral/config/Log.d.ts +2 -2
- package/dist/neutral/config/Log.d.ts.map +1 -1
- package/dist/neutral/config/Mempool.d.ts +1 -1
- package/dist/neutral/config/Mempool.d.ts.map +1 -1
- package/dist/neutral/config/Producer.d.ts +6 -2
- package/dist/neutral/config/Producer.d.ts.map +1 -1
- package/dist/neutral/config/RewardRedemptionApi.d.ts +1 -1
- package/dist/neutral/config/RewardRedemptionApi.d.ts.map +1 -1
- package/dist/neutral/config/Services.d.ts +3 -3
- package/dist/neutral/config/Services.d.ts.map +1 -1
- package/dist/neutral/config/Telemetry.d.ts +11 -4
- package/dist/neutral/config/Telemetry.d.ts.map +1 -1
- package/dist/neutral/config/UsageMeta.d.ts +1 -1
- package/dist/neutral/config/UsageMeta.d.ts.map +1 -1
- package/dist/neutral/config/Validation.d.ts +11 -3
- package/dist/neutral/config/Validation.d.ts.map +1 -1
- package/dist/neutral/config/index.d.ts +1 -0
- package/dist/neutral/config/index.d.ts.map +1 -1
- package/dist/neutral/config/storage/Storage.d.ts +1 -1
- package/dist/neutral/config/storage/Storage.d.ts.map +1 -1
- package/dist/neutral/config/storage/driver/Mongo.d.ts +1 -1
- package/dist/neutral/config/storage/driver/Mongo.d.ts.map +1 -1
- package/dist/neutral/eip-712/Payloads/EIP712Data.d.ts +4 -4
- package/dist/neutral/eip-712/Payloads/EIP712Data.d.ts.map +1 -1
- package/dist/neutral/eip-712/Payloads/EIP712Signature.d.ts +3 -3
- package/dist/neutral/eip-712/Payloads/EIP712Signature.d.ts.map +1 -1
- package/dist/neutral/eip-712/Types.d.ts +4 -4
- package/dist/neutral/eip-712/Types.d.ts.map +1 -1
- package/dist/neutral/index.d.ts +1 -0
- package/dist/neutral/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +3440 -3089
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/model/ChainQualification.d.ts +42 -0
- package/dist/neutral/model/ChainQualification.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/netBalancesForPayloads.d.ts +5 -2
- package/dist/neutral/payloads/netBalancesForPayloads.d.ts.map +1 -1
- package/dist/neutral/payloads/netSchemasForPayloads.d.ts +5 -2
- package/dist/neutral/payloads/netSchemasForPayloads.d.ts.map +1 -1
- package/dist/neutral/primitives/chain/getWindowedChain.d.ts +11 -0
- package/dist/neutral/primitives/chain/getWindowedChain.d.ts.map +1 -0
- package/dist/neutral/primitives/chain/index.d.ts +1 -0
- package/dist/neutral/primitives/chain/index.d.ts.map +1 -1
- package/dist/neutral/primitives/index.d.ts +1 -0
- package/dist/neutral/primitives/index.d.ts.map +1 -1
- package/dist/neutral/primitives/rewards/networkStakeStepRewardPositionWeight.d.ts +1 -1
- package/dist/neutral/primitives/rewards/networkStakeStepRewardPositionWeight.d.ts.map +1 -1
- package/dist/neutral/primitives/stake/weightedStakeForRangeByPosition.d.ts +2 -1
- package/dist/neutral/primitives/stake/weightedStakeForRangeByPosition.d.ts.map +1 -1
- package/dist/neutral/primitives/uncle/findBestUncle.d.ts +32 -0
- package/dist/neutral/primitives/uncle/findBestUncle.d.ts.map +1 -0
- package/dist/neutral/primitives/uncle/findUncles.d.ts +33 -0
- package/dist/neutral/primitives/uncle/findUncles.d.ts.map +1 -0
- package/dist/neutral/primitives/uncle/index.d.ts +4 -0
- package/dist/neutral/primitives/uncle/index.d.ts.map +1 -0
- package/dist/neutral/primitives/uncle/scoreUncle.d.ts +3 -0
- package/dist/neutral/primitives/uncle/scoreUncle.d.ts.map +1 -0
- package/dist/neutral/provider/signer/XyoSigner.d.ts +2 -0
- package/dist/neutral/provider/signer/XyoSigner.d.ts.map +1 -1
- package/dist/neutral/provider/viewer/XyoViewer.d.ts +7 -5
- package/dist/neutral/provider/viewer/XyoViewer.d.ts.map +1 -1
- package/dist/neutral/runners/Finalization.d.ts +12 -0
- package/dist/neutral/runners/Finalization.d.ts.map +1 -0
- package/dist/neutral/runners/index.d.ts +1 -0
- package/dist/neutral/runners/index.d.ts.map +1 -1
- package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts +96 -12
- package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts.map +1 -1
- package/dist/neutral/simple/block/SimpleBlockViewer.d.ts +9 -25
- package/dist/neutral/simple/block/SimpleBlockViewer.d.ts.map +1 -1
- package/dist/neutral/simple/blockReward/SimpleBlockRewardViewer.d.ts +1 -0
- package/dist/neutral/simple/blockReward/SimpleBlockRewardViewer.d.ts.map +1 -1
- package/dist/neutral/simple/blockValidation/SimpleBlockValidationViewer.d.ts +32 -0
- package/dist/neutral/simple/blockValidation/SimpleBlockValidationViewer.d.ts.map +1 -0
- package/dist/neutral/simple/blockValidation/index.d.ts +2 -0
- package/dist/neutral/simple/blockValidation/index.d.ts.map +1 -0
- package/dist/neutral/simple/chainStake/SimpleStakeViewer.d.ts +1 -0
- package/dist/neutral/simple/chainStake/SimpleStakeViewer.d.ts.map +1 -1
- package/dist/neutral/simple/datalake/AbstractSimpleDataLake.d.ts +1 -1
- package/dist/neutral/simple/datalake/AbstractSimpleDataLake.d.ts.map +1 -1
- package/dist/neutral/simple/datalake/SimpleDataLakeRunner.d.ts +1 -0
- package/dist/neutral/simple/datalake/SimpleDataLakeRunner.d.ts.map +1 -1
- package/dist/neutral/simple/datalake/SimpleDataLakeViewer.d.ts +1 -0
- package/dist/neutral/simple/datalake/SimpleDataLakeViewer.d.ts.map +1 -1
- package/dist/neutral/simple/finalization/SimpleFinalizationRunner.d.ts +21 -0
- package/dist/neutral/simple/finalization/SimpleFinalizationRunner.d.ts.map +1 -0
- package/dist/neutral/simple/finalization/SimpleFinalizationViewer.d.ts +61 -0
- package/dist/neutral/simple/finalization/SimpleFinalizationViewer.d.ts.map +1 -0
- package/dist/neutral/simple/finalization/index.d.ts +3 -0
- package/dist/neutral/simple/finalization/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 +2 -0
- package/dist/neutral/simple/mempool/SimpleMempoolRunner.d.ts.map +1 -1
- package/dist/neutral/simple/mempool/SimpleMempoolViewer.d.ts +7 -2
- package/dist/neutral/simple/mempool/SimpleMempoolViewer.d.ts.map +1 -1
- package/dist/neutral/simple/runner/SimpleXyoRunner.d.ts +1 -0
- package/dist/neutral/simple/runner/SimpleXyoRunner.d.ts.map +1 -1
- package/dist/neutral/simple/signer/SimpleXyoSigner.d.ts +19 -3
- package/dist/neutral/simple/signer/SimpleXyoSigner.d.ts.map +1 -1
- package/dist/neutral/simple/stakeEvents/SimpleStakeEventsViewer.d.ts +1 -0
- package/dist/neutral/simple/stakeEvents/SimpleStakeEventsViewer.d.ts.map +1 -1
- package/dist/neutral/simple/timesync/SimpleTimeSyncViewer.d.ts +2 -1
- package/dist/neutral/simple/timesync/SimpleTimeSyncViewer.d.ts.map +1 -1
- package/dist/neutral/simple/windowedBlock/SimpleWindowedBlockViewer.d.ts +191 -0
- package/dist/neutral/simple/windowedBlock/SimpleWindowedBlockViewer.d.ts.map +1 -0
- package/dist/neutral/simple/windowedBlock/index.d.ts +2 -0
- package/dist/neutral/simple/windowedBlock/index.d.ts.map +1 -0
- package/dist/neutral/summary/model/summary.d.ts +3 -2
- package/dist/neutral/summary/model/summary.d.ts.map +1 -1
- package/dist/neutral/summary/primitives/balances/balancesSummary.d.ts +2 -2
- package/dist/neutral/summary/primitives/balances/balancesSummary.d.ts.map +1 -1
- package/dist/neutral/summary/primitives/schemas/schemasSummary.d.ts +2 -2
- package/dist/neutral/summary/primitives/schemas/schemasSummary.d.ts.map +1 -1
- package/dist/neutral/summary/primitives/transfers/transfersSummary.d.ts +3 -3
- package/dist/neutral/summary/primitives/transfers/transfersSummary.d.ts.map +1 -1
- package/dist/neutral/transaction/TransactionBuilder.d.ts +56 -33
- package/dist/neutral/transaction/TransactionBuilder.d.ts.map +1 -1
- package/dist/neutral/transaction/signTransaction.d.ts +24 -12
- package/dist/neutral/transaction/signTransaction.d.ts.map +1 -1
- package/dist/neutral/utils/isZodError.d.ts +1 -1
- package/dist/neutral/utils/isZodError.d.ts.map +1 -1
- package/dist/neutral/validation/schema/Mnemonic.d.ts +1 -1
- package/dist/neutral/validation/schema/Mnemonic.d.ts.map +1 -1
- package/dist/neutral/viewers/AccountBalance.d.ts +92 -44
- package/dist/neutral/viewers/AccountBalance.d.ts.map +1 -1
- package/dist/neutral/viewers/Block.d.ts +2 -2
- package/dist/neutral/viewers/Block.d.ts.map +1 -1
- package/dist/neutral/viewers/BlockValidation.d.ts +54 -0
- package/dist/neutral/viewers/BlockValidation.d.ts.map +1 -0
- package/dist/neutral/viewers/Finalization.d.ts +14 -0
- package/dist/neutral/viewers/Finalization.d.ts.map +1 -0
- package/dist/neutral/viewers/Mempool.d.ts +5 -5
- package/dist/neutral/viewers/Mempool.d.ts.map +1 -1
- package/dist/neutral/viewers/StakeIntent.d.ts +2 -2
- package/dist/neutral/viewers/StakeIntent.d.ts.map +1 -1
- package/dist/neutral/viewers/TransactionValidation.d.ts +35 -0
- package/dist/neutral/viewers/TransactionValidation.d.ts.map +1 -0
- package/dist/neutral/viewers/WindowedBlock.d.ts +14 -0
- package/dist/neutral/viewers/WindowedBlock.d.ts.map +1 -0
- package/dist/neutral/viewers/index.d.ts +4 -0
- package/dist/neutral/viewers/index.d.ts.map +1 -1
- package/package.json +25 -23
- package/src/CreatableProvider/AbstractCreatableProvider.ts +34 -12
- package/src/CreatableProvider/CreatableProvider.ts +24 -12
- package/src/CreatableProvider/CreatableProviderRegistry.ts +4 -3
- package/src/CreatableProvider/ProviderFactory.ts +21 -12
- package/src/CreatableProvider/ProviderFactoryLocator.ts +8 -6
- package/src/CreatableProvider/ProviderFactoryLocatorInstance.ts +6 -2
- package/src/actor/Actor.ts +209 -0
- package/src/actor/index.ts +1 -0
- package/src/block/hydrate/allHashesPresent.ts +2 -2
- package/src/block/hydrate/hydrateBlock.ts +2 -2
- package/src/config/Api.ts +1 -2
- package/src/config/Bridge.ts +1 -2
- package/src/config/Chain.ts +1 -2
- package/src/config/Config.ts +1 -1
- package/src/config/Evm.ts +1 -2
- package/src/config/Log.ts +1 -2
- package/src/config/Mempool.ts +1 -2
- package/src/config/Producer.ts +1 -2
- package/src/config/RewardRedemptionApi.ts +1 -2
- package/src/config/Services.ts +5 -4
- package/src/config/Telemetry.ts +10 -4
- package/src/config/UsageMeta.ts +1 -1
- package/src/config/Validation.ts +1 -2
- package/src/config/index.ts +1 -0
- package/src/config/storage/Storage.ts +1 -2
- package/src/config/storage/driver/Mongo.ts +1 -2
- package/src/eip-712/Payloads/EIP712Data.ts +1 -1
- package/src/eip-712/Payloads/EIP712Signature.ts +1 -1
- package/src/eip-712/Types.ts +1 -1
- package/src/index.ts +1 -0
- package/src/model/ChainQualification.ts +33 -0
- package/src/model/index.ts +1 -1
- package/src/primitives/chain/getWindowedChain.ts +42 -0
- package/src/primitives/chain/index.ts +1 -0
- package/src/primitives/index.ts +1 -0
- package/src/primitives/rewards/networkStakeStepRewardPositionWeight.ts +4 -3
- package/src/primitives/stake/allStakersForStep.ts +1 -1
- package/src/primitives/stake/weightedStakeForRangeByPosition.ts +10 -2
- package/src/primitives/uncle/findBestUncle.ts +8 -0
- package/src/primitives/uncle/findUncles.ts +75 -0
- package/src/primitives/uncle/index.ts +3 -0
- package/src/primitives/uncle/scoreUncle.ts +6 -0
- package/src/provider/signer/XyoSigner.ts +3 -0
- package/src/provider/viewer/XyoViewer.ts +7 -7
- package/src/runners/Finalization.ts +15 -0
- package/src/runners/index.ts +1 -0
- package/src/simple/accountBalance/SimpleAccountBalanceViewer.ts +47 -30
- package/src/simple/block/SimpleBlockViewer.ts +23 -37
- package/src/simple/blockReward/SimpleBlockRewardViewer.ts +1 -0
- package/src/simple/blockValidation/SimpleBlockValidationViewer.ts +129 -0
- package/src/simple/blockValidation/index.ts +1 -0
- package/src/simple/chainStake/SimpleStakeViewer.ts +1 -0
- package/src/simple/datalake/AbstractSimpleDataLake.ts +2 -1
- package/src/simple/datalake/SimpleDataLakeRunner.ts +1 -0
- package/src/simple/datalake/SimpleDataLakeViewer.ts +1 -1
- package/src/simple/finalization/SimpleFinalizationRunner.ts +45 -0
- package/src/simple/finalization/SimpleFinalizationViewer.ts +101 -0
- package/src/simple/finalization/index.ts +2 -0
- package/src/simple/index.ts +3 -0
- package/src/simple/mempool/SimpleMempoolRunner.ts +11 -1
- package/src/simple/mempool/SimpleMempoolViewer.ts +41 -8
- package/src/simple/runner/SimpleXyoRunner.ts +3 -1
- package/src/simple/signer/SimpleXyoSigner.ts +26 -5
- package/src/simple/stakeEvents/SimpleStakeEventsViewer.ts +1 -0
- package/src/simple/timesync/SimpleTimeSyncViewer.ts +4 -2
- package/src/simple/windowedBlock/SimpleWindowedBlockViewer.ts +208 -0
- package/src/simple/windowedBlock/index.ts +1 -0
- package/src/summary/model/summary.ts +3 -4
- package/src/summary/primitives/balances/balancesSummary.ts +12 -12
- package/src/summary/primitives/schemas/schemasSummary.ts +12 -10
- package/src/summary/primitives/transfers/transfersSummary.ts +15 -17
- package/src/utils/isZodError.ts +1 -1
- package/src/validation/schema/Mnemonic.ts +1 -1
- package/src/viewers/AccountBalance.ts +23 -15
- package/src/viewers/Block.ts +2 -2
- package/src/viewers/BlockValidation.ts +47 -0
- package/src/viewers/Finalization.ts +19 -0
- package/src/viewers/Mempool.ts +1 -1
- package/src/viewers/StakeIntent.ts +2 -2
- package/src/viewers/TransactionValidation.ts +35 -0
- package/src/viewers/WindowedBlock.ts +17 -0
- package/src/viewers/index.ts +4 -0
- package/dist/neutral/model/Qualified.d.ts +0 -6
- package/dist/neutral/model/Qualified.d.ts.map +0 -1
- package/src/model/Qualified.ts +0 -9
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CreatableInstance, CreatableParams, EmptyObject,
|
|
3
|
+
Promisable,
|
|
4
|
+
} from '@xylabs/sdk-js'
|
|
5
|
+
import {
|
|
6
|
+
AbstractCreatable,
|
|
7
|
+
assertEx,
|
|
8
|
+
Base, creatable, delay, IdLogger,
|
|
9
|
+
} from '@xylabs/sdk-js'
|
|
10
|
+
import { AccountInstance } from '@xyo-network/account-model'
|
|
11
|
+
import { Semaphore } from 'async-mutex'
|
|
12
|
+
|
|
13
|
+
import { Config, getDefaultConfig } from '../config/index.ts'
|
|
14
|
+
import { ProviderFactoryLocator, ProviderFactoryLocatorInstance } from '../CreatableProvider/index.ts'
|
|
15
|
+
import { BaseContext } from '../model/index.ts'
|
|
16
|
+
|
|
17
|
+
export type ActorContext = BaseContext & {
|
|
18
|
+
config: Config
|
|
19
|
+
locator?: ProviderFactoryLocatorInstance
|
|
20
|
+
singletons: Record<string, unknown>
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type ActorParams<T extends EmptyObject | void = void> = CreatableParams & {
|
|
24
|
+
account: AccountInstance
|
|
25
|
+
context?: ActorContext
|
|
26
|
+
displayName?: string
|
|
27
|
+
id: string
|
|
28
|
+
} & (T extends void ? EmptyObject : T)
|
|
29
|
+
|
|
30
|
+
export type ActorInstance<T extends ActorParams = ActorParams> = CreatableInstance<T>
|
|
31
|
+
|
|
32
|
+
@creatable()
|
|
33
|
+
export class Actor<TParams extends ActorParams = ActorParams> extends AbstractCreatable<TParams> {
|
|
34
|
+
protected readonly _intervals: Map<string, ReturnType<typeof setInterval>> = new Map()
|
|
35
|
+
protected readonly _semaphores: Map<string, Semaphore> = new Map()
|
|
36
|
+
protected readonly _timeouts: Map<string, ReturnType<typeof setTimeout>> = new Map()
|
|
37
|
+
private _active = false
|
|
38
|
+
|
|
39
|
+
get displayName() {
|
|
40
|
+
return this.params.displayName ?? this.params.name ?? 'UnnamedActor'
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
get id() {
|
|
44
|
+
return this.params.id
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
protected get account() {
|
|
48
|
+
return this.params.account!
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
protected get config() {
|
|
52
|
+
return this.context.config
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
protected get context() {
|
|
56
|
+
return this.params.context!
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
protected get locator() {
|
|
60
|
+
return this.context.locator
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
protected get logPrefix() {
|
|
64
|
+
return `[${this.displayName} (${this.id})] `
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
static override async paramsHandler<T extends ActorInstance>(params?: Partial<T['params']>) {
|
|
68
|
+
const baseParams = await super.paramsHandler(params)
|
|
69
|
+
const id = params?.id ?? baseParams.name ?? 'UnnamedActor'
|
|
70
|
+
const displayName = params?.displayName ?? baseParams.name
|
|
71
|
+
const account = assertEx(params?.account, () => `Account is required for actor ${id}.`)
|
|
72
|
+
const context = await this.initContext({
|
|
73
|
+
...params, account, id, displayName,
|
|
74
|
+
})
|
|
75
|
+
const logger = context?.logger ?? new IdLogger(Base.defaultLogger ?? console, () => `[${displayName} (${id})] `)
|
|
76
|
+
return {
|
|
77
|
+
...baseParams, account, context, displayName, id, logger,
|
|
78
|
+
} satisfies ActorParams
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
protected static initContext<T extends ActorInstance>(
|
|
82
|
+
params: T['params'],
|
|
83
|
+
): Promisable<T['params']['context']> {
|
|
84
|
+
const logger = params?.context?.logger
|
|
85
|
+
const config: Config = params?.context?.config ?? getDefaultConfig()
|
|
86
|
+
const singletons = params?.context?.singletons ?? {}
|
|
87
|
+
|
|
88
|
+
const context: ActorContext = {
|
|
89
|
+
...params?.context,
|
|
90
|
+
config,
|
|
91
|
+
logger,
|
|
92
|
+
singletons,
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const locator = params?.context?.locator ?? new ProviderFactoryLocator(context)
|
|
96
|
+
return locator.context
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The timer runs until the actor is deactivated (or you manually stop it).
|
|
101
|
+
*/
|
|
102
|
+
registerTimer(timerName: string, callback: () => Promise<void>, dueTimeMs: number, periodMs: number) {
|
|
103
|
+
if (!this._active) {
|
|
104
|
+
this.logger?.warn(
|
|
105
|
+
`Cannot register timer '${timerName}' because actor is not active.`,
|
|
106
|
+
)
|
|
107
|
+
return
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
let running = false
|
|
111
|
+
|
|
112
|
+
this._semaphores.set(timerName, new Semaphore(1))
|
|
113
|
+
|
|
114
|
+
const timeoutId = setTimeout(() => {
|
|
115
|
+
const intervalId = setInterval(() => {
|
|
116
|
+
const semaphore = this._semaphores.get(timerName)
|
|
117
|
+
if (!this._active || !this._intervals.has(timerName) || !semaphore || running) return
|
|
118
|
+
if (semaphore.isLocked()) {
|
|
119
|
+
this.logger?.warn(
|
|
120
|
+
`Skipping timer '${this.name}:${timerName}' execution because previous execution is still running.`,
|
|
121
|
+
)
|
|
122
|
+
return
|
|
123
|
+
}
|
|
124
|
+
semaphore.acquire().then(([, release]) => {
|
|
125
|
+
const startTime = Date.now()
|
|
126
|
+
running = true
|
|
127
|
+
callback()
|
|
128
|
+
.then(() => {
|
|
129
|
+
const duration = Date.now() - startTime
|
|
130
|
+
if (duration > periodMs) {
|
|
131
|
+
this.logger?.warn(
|
|
132
|
+
`Timer '${this.name}:${timerName}' execution took longer (${duration}ms) than the period (${periodMs}ms).`,
|
|
133
|
+
)
|
|
134
|
+
} else if (duration > 5000) {
|
|
135
|
+
this.logger?.warn(
|
|
136
|
+
`Timer '${this.name}:${timerName}' execution took longer (${duration}ms) than 5000ms.`,
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
.catch((error) => {
|
|
141
|
+
this.logger?.error(`Error in timer '${this.name}:${timerName}': ${error}`)
|
|
142
|
+
this.logger?.error(error.stack)
|
|
143
|
+
})
|
|
144
|
+
.finally(() => {
|
|
145
|
+
release()
|
|
146
|
+
running = false
|
|
147
|
+
})
|
|
148
|
+
}).catch((error) => {
|
|
149
|
+
this.logger?.error(`Error acquiring semaphore for timer '${this.name}:${timerName}': ${error}`)
|
|
150
|
+
})
|
|
151
|
+
}, periodMs)
|
|
152
|
+
|
|
153
|
+
// store interval so we can clear it on stop()
|
|
154
|
+
this._intervals.set(timerName, intervalId)
|
|
155
|
+
}, dueTimeMs)
|
|
156
|
+
|
|
157
|
+
// store timeout so we can clear it on stop() if interval hasn't started yet
|
|
158
|
+
this._timeouts.set(timerName, timeoutId)
|
|
159
|
+
|
|
160
|
+
this.logger?.log(
|
|
161
|
+
`Timer '${this.name}:${timerName}' registered: first call after ${dueTimeMs}ms, recurring every ${periodMs}ms.`,
|
|
162
|
+
)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Called by the Orchestrator when the actor is activated.
|
|
167
|
+
*/
|
|
168
|
+
override async startHandler() {
|
|
169
|
+
await super.startHandler()
|
|
170
|
+
this._active = true
|
|
171
|
+
this.logger?.log('Started.')
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Called by the Orchestrator when the actor is deactivated.
|
|
176
|
+
* Stop all running timers.
|
|
177
|
+
*/
|
|
178
|
+
override async stopHandler() {
|
|
179
|
+
await super.stopHandler()
|
|
180
|
+
this._active = false
|
|
181
|
+
this.logger?.log('Stopping all timers...')
|
|
182
|
+
|
|
183
|
+
// wait for all semaphores to be free and acquire them to prevent new tasks from starting
|
|
184
|
+
await Promise.all(
|
|
185
|
+
[...this._semaphores.values()].map(async (semaphore) => {
|
|
186
|
+
// Wait for any running tasks to complete
|
|
187
|
+
while (semaphore.isLocked()) {
|
|
188
|
+
this.logger?.log('Waiting for running timer task to complete...')
|
|
189
|
+
await delay(500)
|
|
190
|
+
}
|
|
191
|
+
await semaphore.acquire()
|
|
192
|
+
}),
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
this._semaphores.clear()
|
|
196
|
+
|
|
197
|
+
for (const [, timeoutRef] of this._timeouts.entries()) {
|
|
198
|
+
clearTimeout(timeoutRef)
|
|
199
|
+
}
|
|
200
|
+
this._timeouts.clear()
|
|
201
|
+
|
|
202
|
+
for (const [, intervalRef] of this._intervals.entries()) {
|
|
203
|
+
clearInterval(intervalRef)
|
|
204
|
+
}
|
|
205
|
+
this._intervals.clear()
|
|
206
|
+
|
|
207
|
+
this.logger?.log('Stopped.')
|
|
208
|
+
}
|
|
209
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Actor.ts'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Hash } from '@xylabs/sdk-js'
|
|
2
|
-
import type { Payload,
|
|
2
|
+
import type { Payload, WithHashMeta } from '@xyo-network/payload-model'
|
|
3
3
|
|
|
4
|
-
export function allHashesPresent(hashes: Hash[], payloads:
|
|
4
|
+
export function allHashesPresent(hashes: Hash[], payloads: WithHashMeta<Payload>[]): boolean {
|
|
5
5
|
const payloadHashes = new Set(payloads.map(p => p._hash))
|
|
6
6
|
return hashes.every(hash => payloadHashes.has(hash))
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Hash } from '@xylabs/sdk-js'
|
|
2
2
|
import { assertEx } from '@xylabs/sdk-js'
|
|
3
|
-
import type {
|
|
3
|
+
import type { HydratedBlockWithStorageMeta } from '@xyo-network/xl1-protocol'
|
|
4
4
|
import { asBlockBoundWitnessWithStorageMeta, isTransactionBoundWitnessWithStorageMeta } from '@xyo-network/xl1-protocol'
|
|
5
5
|
|
|
6
6
|
import type { ChainStoreRead } from '../../model/index.ts'
|
|
@@ -11,7 +11,7 @@ export const hydrateBlock = async (
|
|
|
11
11
|
hash: Hash,
|
|
12
12
|
maxDepth: number = 1,
|
|
13
13
|
minDepth = maxDepth,
|
|
14
|
-
): Promise<
|
|
14
|
+
): Promise<HydratedBlockWithStorageMeta> => {
|
|
15
15
|
assertEx(maxDepth >= 0, () => 'maxDepth must be greater than or equal to 0')
|
|
16
16
|
assertEx(minDepth >= 0, () => 'minDepth must be greater than or equal to 0')
|
|
17
17
|
assertEx(maxDepth >= minDepth, () => 'maxDepth must be greater than or equal to minDepth')
|
package/src/config/Api.ts
CHANGED
package/src/config/Bridge.ts
CHANGED
|
@@ -3,8 +3,7 @@ import {
|
|
|
3
3
|
} from '@xylabs/hex'
|
|
4
4
|
import type { ChainId } from '@xyo-network/xl1-protocol'
|
|
5
5
|
import { AttoXL1ConvertFactor, XL1 } from '@xyo-network/xl1-protocol'
|
|
6
|
-
import { globalRegistry } from 'zod'
|
|
7
|
-
import * as z from 'zod'
|
|
6
|
+
import { globalRegistry, z } from 'zod'
|
|
8
7
|
|
|
9
8
|
import { MnemonicStringZod } from '../validation/index.ts'
|
|
10
9
|
|
package/src/config/Chain.ts
CHANGED
package/src/config/Config.ts
CHANGED
package/src/config/Evm.ts
CHANGED
package/src/config/Log.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { LogLevelKey } from '@xylabs/sdk-js'
|
|
2
2
|
import { LogLevel } from '@xylabs/sdk-js'
|
|
3
|
-
import { globalRegistry } from 'zod'
|
|
4
|
-
import * as z from 'zod'
|
|
3
|
+
import { globalRegistry, z } from 'zod'
|
|
5
4
|
const LogLevels = Object.keys(LogLevel) as [LogLevelKey, ...LogLevelKey[]]
|
|
6
5
|
|
|
7
6
|
export const LogConfigZod = z.object({
|
package/src/config/Mempool.ts
CHANGED
package/src/config/Producer.ts
CHANGED
package/src/config/Services.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { globalRegistry } from 'zod'
|
|
2
|
-
import * as z from 'zod'
|
|
1
|
+
import { globalRegistry, z } from 'zod'
|
|
3
2
|
|
|
4
3
|
export const ServicesConfigZod = z.object({
|
|
5
|
-
accountBalanceViewerEndpoint: z.string().
|
|
4
|
+
accountBalanceViewerEndpoint: z.string().default('http://localhost:8080/rpc').register(globalRegistry, {
|
|
5
|
+
default: 'http://localhost:8080/rpc',
|
|
6
6
|
description: 'Endpoint of the API to use for instantiating an external AccountBalanceViewer',
|
|
7
7
|
title: 'services.accountBalanceViewerEndpoint',
|
|
8
8
|
type: 'string',
|
|
9
9
|
}),
|
|
10
|
-
apiEndpoint: z.string().
|
|
10
|
+
apiEndpoint: z.string().default('http://localhost:8080/rpc').register(globalRegistry, {
|
|
11
|
+
default: 'http://localhost:8080/rpc',
|
|
11
12
|
description: 'Endpoint of the API to use for instantiating an external Viewers',
|
|
12
13
|
title: 'services.apiEndpoint',
|
|
13
14
|
type: 'string',
|
package/src/config/Telemetry.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import { globalRegistry } from 'zod'
|
|
2
|
-
|
|
1
|
+
import { globalRegistry, z } from 'zod'
|
|
2
|
+
|
|
3
|
+
export const DefaultMetricsScrapePorts = {
|
|
4
|
+
api: 9465,
|
|
5
|
+
bridge: 9468,
|
|
6
|
+
mempool: 9466,
|
|
7
|
+
producer: 9464,
|
|
8
|
+
rewardRedemptionApi: 9467,
|
|
9
|
+
}
|
|
3
10
|
|
|
4
11
|
export const MetricsScrapeConfigZod = z.object({
|
|
5
12
|
path: z.string().default('/metrics').register(globalRegistry, {
|
|
@@ -8,8 +15,7 @@ export const MetricsScrapeConfigZod = z.object({
|
|
|
8
15
|
title: 'telemetry.metrics.scrape.path',
|
|
9
16
|
type: 'string',
|
|
10
17
|
}),
|
|
11
|
-
port: z.coerce.number().
|
|
12
|
-
default: 9464,
|
|
18
|
+
port: z.coerce.number().int().positive().optional().register(globalRegistry, {
|
|
13
19
|
description: 'Port for the metrics scrape endpoint',
|
|
14
20
|
title: 'telemetry.metrics.scrape.port',
|
|
15
21
|
type: 'number',
|
package/src/config/UsageMeta.ts
CHANGED
package/src/config/Validation.ts
CHANGED
package/src/config/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AsObjectFactory, HashZod } from '@xylabs/sdk-js'
|
|
2
2
|
import { isPayloadOfZodType, type Payload } from '@xyo-network/payload-model'
|
|
3
|
-
import z from 'zod'
|
|
3
|
+
import { z } from 'zod'
|
|
4
4
|
|
|
5
5
|
export const EIP712SignaturePayloadFieldsZod = z.object({
|
|
6
6
|
address: z.string(),
|
package/src/eip-712/Types.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { HashZod } from '@xylabs/hex'
|
|
2
|
+
import { zodIsFactory } from '@xylabs/zod'
|
|
3
|
+
import { XL1BlockRangeZod } from '@xyo-network/xl1-protocol'
|
|
4
|
+
import { z } from 'zod'
|
|
5
|
+
|
|
6
|
+
export const ChainQualificationZod = z.object({ head: HashZod, range: XL1BlockRangeZod })
|
|
7
|
+
export type ChainQualification = z.infer<typeof ChainQualificationZod>
|
|
8
|
+
export const isChainQualification = zodIsFactory(ChainQualificationZod)
|
|
9
|
+
|
|
10
|
+
export const ChainQualifiedRangeConfigZod = z.object({ range: XL1BlockRangeZod })
|
|
11
|
+
export type ChainQualifiedRangeConfig = z.infer<typeof ChainQualifiedRangeConfigZod>
|
|
12
|
+
export const isChainQualifiedRangeConfig = zodIsFactory(ChainQualifiedRangeConfigZod)
|
|
13
|
+
|
|
14
|
+
export const ChainQualifiedHeadConfigZod = z.object({ head: HashZod })
|
|
15
|
+
export type ChainQualifiedHeadConfig = z.infer<typeof ChainQualifiedHeadConfigZod>
|
|
16
|
+
export const isChainQualifiedHeadConfig = zodIsFactory(ChainQualifiedHeadConfigZod)
|
|
17
|
+
|
|
18
|
+
export const ChainQualifiedConfigZod = z.union([ChainQualifiedRangeConfigZod, ChainQualifiedHeadConfigZod, z.object({})])
|
|
19
|
+
export type ChainQualifiedConfig = z.infer<typeof ChainQualifiedConfigZod>
|
|
20
|
+
export const isChainQualifiedConfig = zodIsFactory(ChainQualifiedConfigZod)
|
|
21
|
+
|
|
22
|
+
export const ExtendChainQualifiedConfigZod = (<T>(zodType: z.ZodType<T>) => {
|
|
23
|
+
return z.union([
|
|
24
|
+
ChainQualifiedRangeConfigZod.extend(zodType),
|
|
25
|
+
ChainQualifiedHeadConfigZod.extend(zodType),
|
|
26
|
+
zodType,
|
|
27
|
+
])
|
|
28
|
+
}) as <T>(zodType: z.ZodType<T>) => z.ZodType<T & ChainQualifiedConfig>
|
|
29
|
+
|
|
30
|
+
export type ChainQualified<T> = [T, ChainQualification]
|
|
31
|
+
export const ChainQualifiedZod = <T>(zodType: z.ZodType<T>) => {
|
|
32
|
+
return z.tuple([zodType, ChainQualificationZod])
|
|
33
|
+
}
|
package/src/model/index.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export * from './ChainContext/index.ts'
|
|
2
2
|
export * from './ChainFork/index.ts'
|
|
3
3
|
export * from './ChainIdentity.ts'
|
|
4
|
+
export * from './ChainQualification.ts'
|
|
4
5
|
export * from './ChainStore.ts'
|
|
5
6
|
export * from './PayloadBundle/index.ts'
|
|
6
7
|
export * from './PayloadMap.ts'
|
|
7
8
|
export * from './Position.ts'
|
|
8
9
|
export * from './Provider.ts'
|
|
9
|
-
export * from './Qualified.ts'
|
|
10
10
|
export * from './RecordKeyType.ts'
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
assertEx, type Hash, isDefined, isNull,
|
|
3
|
+
} from '@xylabs/sdk-js'
|
|
4
|
+
import type { SignedHydratedBlockWithHashMeta } from '@xyo-network/xl1-protocol'
|
|
5
|
+
|
|
6
|
+
import type { BlockViewer } from '../../viewers/index.ts'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Constructs a bounded, contiguous canonical chain ending at the current head.
|
|
10
|
+
* @param blockViewer The BlockViewer to fetch blocks from
|
|
11
|
+
* @param maxWindowSize The maximum size of the windowed chain
|
|
12
|
+
* @param previousChain An optional previous chain to build upon
|
|
13
|
+
* @returns A promise that resolves to the windowed chain of blocks
|
|
14
|
+
*/
|
|
15
|
+
export async function getWindowedChain(blockViewer: BlockViewer, maxWindowSize: number, previousChain: SignedHydratedBlockWithHashMeta[] = []):
|
|
16
|
+
Promise<SignedHydratedBlockWithHashMeta[]> {
|
|
17
|
+
const newChain: SignedHydratedBlockWithHashMeta[] = []
|
|
18
|
+
const previousChainByHash = new Map<Hash, SignedHydratedBlockWithHashMeta>(previousChain.map(block => [block[0]._hash, block]))
|
|
19
|
+
const head = await blockViewer.currentBlock()
|
|
20
|
+
let currentBlock: SignedHydratedBlockWithHashMeta | null = head
|
|
21
|
+
console.log('[getWindowedChain] Current Block:', currentBlock?.[0]._hash)
|
|
22
|
+
while (currentBlock !== null && newChain.length < maxWindowSize) {
|
|
23
|
+
const currentBlockNumber = currentBlock[0].block
|
|
24
|
+
const nextBlock = newChain[0]
|
|
25
|
+
if (isDefined(nextBlock)) {
|
|
26
|
+
const nextBlockNumber = nextBlock[0].block
|
|
27
|
+
assertEx(
|
|
28
|
+
currentBlockNumber === nextBlockNumber - 1,
|
|
29
|
+
() => `[getWindowedChain] Non-monotonic block sequence detected: current=${currentBlockNumber}, next=${nextBlockNumber}`,
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
assertEx(
|
|
33
|
+
currentBlockNumber <= head[0].block,
|
|
34
|
+
() => `[getWindowedChain] Current block number (${currentBlockNumber}) exceeds head block number (${head[0].block})`,
|
|
35
|
+
)
|
|
36
|
+
newChain.unshift(currentBlock)
|
|
37
|
+
const previousBlockHash: Hash | null = currentBlock[0].previous
|
|
38
|
+
if (isNull(previousBlockHash)) break
|
|
39
|
+
currentBlock = previousChainByHash.get(previousBlockHash) ?? await blockViewer.blockByHash(previousBlockHash)
|
|
40
|
+
}
|
|
41
|
+
return newChain
|
|
42
|
+
}
|
package/src/primitives/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type StepIdentity } from '@xyo-network/xl1-protocol'
|
|
1
|
+
import { type StepIdentity, XYO_NETWORK_STAKING_ADDRESS } from '@xyo-network/xl1-protocol'
|
|
2
2
|
|
|
3
3
|
import type { StakedChainContextRead } from '../../model/index.ts'
|
|
4
|
-
import type { BlockViewer } from '../../viewers/
|
|
5
|
-
import { externalBlockRangeFromStep } from '../chain/
|
|
4
|
+
import type { BlockViewer } from '../../viewers/index.ts'
|
|
5
|
+
import { externalBlockRangeFromStep } from '../chain/index.ts'
|
|
6
6
|
import { weightedStakeForRangeByPosition } from '../stake/index.ts'
|
|
7
7
|
|
|
8
8
|
export async function networkStakeStepRewardPositionWeight(
|
|
@@ -15,6 +15,7 @@ export async function networkStakeStepRewardPositionWeight(
|
|
|
15
15
|
context,
|
|
16
16
|
blockViewer,
|
|
17
17
|
await externalBlockRangeFromStep(context, blockViewer, stepContext),
|
|
18
|
+
XYO_NETWORK_STAKING_ADDRESS,
|
|
18
19
|
position,
|
|
19
20
|
)
|
|
20
21
|
return result
|
|
@@ -3,7 +3,7 @@ import type { StepIdentity } from '@xyo-network/xl1-protocol'
|
|
|
3
3
|
|
|
4
4
|
import type { StakedChainContextRead } from '../../model/index.ts'
|
|
5
5
|
import type { BlockViewer } from '../../viewers/index.ts'
|
|
6
|
-
import { externalBlockRangeFromXL1BlockRange } from '../chain/
|
|
6
|
+
import { externalBlockRangeFromXL1BlockRange } from '../chain/index.ts'
|
|
7
7
|
import { stepBlockRange } from '../step/index.ts'
|
|
8
8
|
import { allStakersForRange } from './allStakersForRange.ts'
|
|
9
9
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/sdk-js'
|
|
1
2
|
import { isDefined } from '@xylabs/sdk-js'
|
|
2
3
|
import { asBlockNumber, type BlockRange } from '@xyo-network/xl1-protocol'
|
|
3
4
|
|
|
@@ -9,6 +10,7 @@ export async function weightedStakeForRangeByPosition(
|
|
|
9
10
|
context: StakedChainContextRead,
|
|
10
11
|
blockViewer: BlockViewer,
|
|
11
12
|
externalRange: BlockRange, // first to last block of step
|
|
13
|
+
staked?: Address,
|
|
12
14
|
positionId?: number,
|
|
13
15
|
): Promise<bigint> {
|
|
14
16
|
const cacheKey = isDefined(positionId) ? `${externalRange[0]}-${externalRange[1]}-${positionId}` : `${externalRange[0]}-${externalRange[1]}-all`
|
|
@@ -22,6 +24,12 @@ export async function weightedStakeForRangeByPosition(
|
|
|
22
24
|
)).toSorted((a, b) => a.time - b.time)
|
|
23
25
|
let currentTime = externalRange[0]
|
|
24
26
|
let currentStake = 0n // await activeStakeAtTimeByPosition(chainEvents, pos.staked, currentTime - 1, position)
|
|
27
|
+
|
|
28
|
+
// if not staking the desired address, return 0n
|
|
29
|
+
if (isDefined(staked) && mergedEvents[0].args.staked !== staked) {
|
|
30
|
+
return 0n
|
|
31
|
+
}
|
|
32
|
+
|
|
25
33
|
for (const event of mergedEvents) {
|
|
26
34
|
if (event.time > currentTime) {
|
|
27
35
|
// Add the weighted stake for the period between the range start or previous event and this event
|
|
@@ -44,9 +52,9 @@ export async function weightedStakeForRangeByPosition(
|
|
|
44
52
|
weightedStakeSum += currentStake * BigInt(externalRange[1] - currentTime)
|
|
45
53
|
}
|
|
46
54
|
} else {
|
|
47
|
-
const positionCount = await context.stake.stakeEvents.positionCount(externalRange)
|
|
55
|
+
const positionCount = await context.stake.stakeEvents.positionCount([0, externalRange[1]])
|
|
48
56
|
for (let pos = 0; pos < positionCount; pos++) {
|
|
49
|
-
weightedStakeSum += await weightedStakeForRangeByPosition(context, blockViewer, externalRange, pos)
|
|
57
|
+
weightedStakeSum += await weightedStakeForRangeByPosition(context, blockViewer, externalRange, staked, pos)
|
|
50
58
|
}
|
|
51
59
|
}
|
|
52
60
|
return weightedStakeSum
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SignedHydratedBlockWithHashMeta } from '@xyo-network/xl1-protocol'
|
|
2
|
+
|
|
3
|
+
import { scoreUncle } from './scoreUncle.ts'
|
|
4
|
+
|
|
5
|
+
export function findBestUncle(finalizedWindowedChain: SignedHydratedBlockWithHashMeta[], uncles: SignedHydratedBlockWithHashMeta[][]) {
|
|
6
|
+
const scores = uncles.map(uncle => ([scoreUncle(finalizedWindowedChain, uncle), uncle] as const)).toSorted((a, b) => b[0] - a[0])
|
|
7
|
+
return scores[0]?.[1] ?? finalizedWindowedChain
|
|
8
|
+
}
|