@xyo-network/chain-services 1.18.0 → 1.18.2
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/AccountBalance/accountBalanceServiceFromArchivist.d.ts +1 -2
- package/dist/neutral/AccountBalance/accountBalanceServiceFromArchivist.d.ts.map +1 -1
- package/dist/neutral/BlockReward/EvmBlockRewardViewer.d.ts +1 -2
- package/dist/neutral/BlockReward/EvmBlockRewardViewer.d.ts.map +1 -1
- package/dist/neutral/ChainValidator/XyoValidator.d.ts +8 -8
- package/dist/neutral/ChainValidator/XyoValidator.d.ts.map +1 -1
- package/dist/neutral/ChainValidator/model/Validator.d.ts +1 -1
- package/dist/neutral/ChainValidator/model/Validator.d.ts.map +1 -1
- package/dist/neutral/Election/BaseElectionService.d.ts +8 -5
- package/dist/neutral/Election/BaseElectionService.d.ts.map +1 -1
- package/dist/neutral/NetworkStakeStepReward/BaseNetworkStakeStepRewardService.d.ts +16 -17
- package/dist/neutral/NetworkStakeStepReward/BaseNetworkStakeStepRewardService.d.ts.map +1 -1
- package/dist/neutral/PendingTransactions/BasePendingTransactions.d.ts +3 -4
- package/dist/neutral/PendingTransactions/BasePendingTransactions.d.ts.map +1 -1
- package/dist/neutral/PendingTransactions/bundledPayloadToHydratedTransaction.d.ts +1 -1
- package/dist/neutral/PendingTransactions/bundledPayloadToHydratedTransaction.d.ts.map +1 -1
- package/dist/neutral/PendingTransactions/hydratedTransactionToPayloadBundle.d.ts +1 -1
- package/dist/neutral/PendingTransactions/hydratedTransactionToPayloadBundle.d.ts.map +1 -1
- package/dist/neutral/Schemas/BaseSchemasService.d.ts +6 -3
- package/dist/neutral/Schemas/BaseSchemasService.d.ts.map +1 -1
- package/dist/neutral/StakeIntent/XyoStakeIntentService.d.ts +13 -6
- package/dist/neutral/StakeIntent/XyoStakeIntentService.d.ts.map +1 -1
- package/dist/neutral/StakeIntent/lib/getBlockSignedStakeDeclarations.d.ts +1 -1
- package/dist/neutral/StakeIntent/lib/getBlockSignedStakeDeclarations.d.ts.map +1 -1
- package/dist/neutral/StepStake/BaseStepStakeService.d.ts +6 -7
- package/dist/neutral/StepStake/BaseStepStakeService.d.ts.map +1 -1
- package/dist/neutral/blockViewerFromChainIteratorAndArchivist.d.ts +1 -1
- package/dist/neutral/blockViewerFromChainIteratorAndArchivist.d.ts.map +1 -1
- package/dist/neutral/implementation/evm/initChainId.d.ts +1 -1
- package/dist/neutral/implementation/evm/initChainId.d.ts.map +1 -1
- package/dist/neutral/implementation/evm/initEvmProvider.d.ts +1 -1
- package/dist/neutral/implementation/evm/initEvmProvider.d.ts.map +1 -1
- package/dist/neutral/implementation/evm/initInfuraProvider.d.ts +1 -1
- package/dist/neutral/implementation/evm/initInfuraProvider.d.ts.map +1 -1
- package/dist/neutral/implementation/evm/initJsonRpcProvider.d.ts +1 -1
- package/dist/neutral/implementation/evm/initJsonRpcProvider.d.ts.map +1 -1
- package/dist/neutral/implementation/head/createBootstrapHead.d.ts +1 -1
- package/dist/neutral/implementation/head/createBootstrapHead.d.ts.map +1 -1
- package/dist/neutral/implementation/index.d.ts +0 -1
- package/dist/neutral/implementation/index.d.ts.map +1 -1
- package/dist/neutral/index.d.ts +0 -2
- package/dist/neutral/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +180 -415
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/model/Params.d.ts +1 -2
- package/dist/neutral/model/Params.d.ts.map +1 -1
- package/dist/neutral/simple/block/runner/SimpleBlockRunner.d.ts +34 -20
- package/dist/neutral/simple/block/runner/SimpleBlockRunner.d.ts.map +1 -1
- package/dist/neutral/simple/block/runner/generateTransactionFeeTransfers.d.ts +1 -1
- package/dist/neutral/simple/block/runner/generateTransactionFeeTransfers.d.ts.map +1 -1
- package/package.json +29 -32
- package/src/AccountBalance/accountBalanceServiceFromArchivist.ts +12 -9
- package/src/BlockReward/EvmBlockRewardViewer.ts +5 -7
- package/src/ChainValidator/XyoValidator.ts +9 -14
- package/src/ChainValidator/model/Validator.ts +1 -1
- package/src/Election/BaseElectionService.ts +15 -10
- package/src/NetworkStakeStepReward/BaseNetworkStakeStepRewardService.ts +24 -24
- package/src/PendingTransactions/BasePendingTransactions.ts +14 -14
- package/src/PendingTransactions/bundledPayloadToHydratedTransaction.ts +2 -2
- package/src/PendingTransactions/hydratedTransactionToPayloadBundle.ts +2 -2
- package/src/Schemas/BaseSchemasService.ts +12 -9
- package/src/StakeIntent/XyoStakeIntentService.ts +32 -29
- package/src/StakeIntent/lib/getBlockSignedStakeDeclarations.ts +2 -2
- package/src/StepStake/BaseStepStakeService.ts +7 -11
- package/src/blockViewerFromChainIteratorAndArchivist.ts +14 -4
- package/src/implementation/evm/initChainId.ts +1 -1
- package/src/implementation/evm/initEvmProvider.ts +1 -1
- package/src/implementation/evm/initInfuraProvider.ts +1 -1
- package/src/implementation/evm/initJsonRpcProvider.ts +1 -1
- package/src/implementation/head/createBootstrapHead.ts +2 -2
- package/src/implementation/index.ts +0 -1
- package/src/index.ts +0 -2
- package/src/model/Params.ts +1 -2
- package/src/simple/block/runner/SimpleBlockRunner.ts +39 -36
- package/src/simple/block/runner/generateTransactionFeeTransfers.ts +5 -4
- package/dist/neutral/BaseService.d.ts +0 -19
- package/dist/neutral/BaseService.d.ts.map +0 -1
- package/dist/neutral/ChainService/Evm/Evm.d.ts +0 -39
- package/dist/neutral/ChainService/Evm/Evm.d.ts.map +0 -1
- package/dist/neutral/ChainService/Evm/index.d.ts +0 -2
- package/dist/neutral/ChainService/Evm/index.d.ts.map +0 -1
- package/dist/neutral/ChainService/Memory/Memory.d.ts +0 -38
- package/dist/neutral/ChainService/Memory/Memory.d.ts.map +0 -1
- package/dist/neutral/ChainService/Memory/index.d.ts +0 -2
- package/dist/neutral/ChainService/Memory/index.d.ts.map +0 -1
- package/dist/neutral/ChainService/index.d.ts +0 -3
- package/dist/neutral/ChainService/index.d.ts.map +0 -1
- package/dist/neutral/implementation/chain/evm.d.ts +0 -7
- package/dist/neutral/implementation/chain/evm.d.ts.map +0 -1
- package/dist/neutral/implementation/chain/index.d.ts +0 -6
- package/dist/neutral/implementation/chain/index.d.ts.map +0 -1
- package/src/BaseService.ts +0 -45
- package/src/ChainService/Evm/Evm.ts +0 -105
- package/src/ChainService/Evm/index.ts +0 -1
- package/src/ChainService/Memory/Memory.ts +0 -106
- package/src/ChainService/Memory/index.ts +0 -1
- package/src/ChainService/index.ts +0 -2
- package/src/implementation/chain/evm.ts +0 -39
- package/src/implementation/chain/index.ts +0 -44
|
@@ -1,28 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
creatable, Hash, spanRootAsync,
|
|
3
|
-
} from '@xylabs/sdk-js'
|
|
1
|
+
import { Hash } from '@xylabs/sdk-js'
|
|
4
2
|
import { Schema } from '@xyo-network/payload-model'
|
|
5
3
|
import {
|
|
4
|
+
AbstractCreatableProvider,
|
|
5
|
+
creatableProvider,
|
|
6
6
|
SchemasService,
|
|
7
7
|
SchemasStepSummaryContext,
|
|
8
8
|
schemasSummary,
|
|
9
|
-
} from '@xyo-network/xl1-
|
|
9
|
+
} from '@xyo-network/xl1-sdk'
|
|
10
10
|
|
|
11
|
-
import { BaseService } from '../BaseService.ts'
|
|
12
11
|
import { BaseServiceParams } from '../model/index.ts'
|
|
13
12
|
|
|
14
13
|
export interface BaseSchemasServiceParams extends BaseServiceParams {
|
|
15
14
|
schemasStepSummaryContext: SchemasStepSummaryContext
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
@
|
|
19
|
-
export class BaseSchemasService extends
|
|
17
|
+
@creatableProvider()
|
|
18
|
+
export class BaseSchemasService extends AbstractCreatableProvider<BaseSchemasServiceParams> implements SchemasService {
|
|
19
|
+
static readonly defaultMoniker = 'SchemasService'
|
|
20
|
+
static readonly dependencies = []
|
|
21
|
+
static readonly monikers = [BaseSchemasService.defaultMoniker]
|
|
22
|
+
moniker = BaseSchemasService.defaultMoniker
|
|
20
23
|
async schema(head: Hash, schema: Schema): Promise<number> {
|
|
21
24
|
return (await this.schemas(head, [schema]))[schema] ?? 0
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
async schemas(head: Hash, schemas: Schema[]): Promise<Partial<Record<Schema, number>>> {
|
|
25
|
-
return await
|
|
28
|
+
return await this.spanAsync('schemas', async () => {
|
|
26
29
|
const [summary] = await schemasSummary(this.params.schemasStepSummaryContext)
|
|
27
30
|
const result: Record<Schema, number> = {}
|
|
28
31
|
for (const schema of schemas) {
|
|
@@ -30,6 +33,6 @@ export class BaseSchemasService extends BaseService<BaseSchemasServiceParams> im
|
|
|
30
33
|
result[schema] = count
|
|
31
34
|
}
|
|
32
35
|
return result
|
|
33
|
-
})
|
|
36
|
+
}, { timeBudgetLimit: 100 })
|
|
34
37
|
}
|
|
35
38
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Address, asAddress, assertEx,
|
|
2
|
+
Address, asAddress, assertEx, filterAs, Hash,
|
|
3
3
|
isUndefined,
|
|
4
4
|
} from '@xylabs/sdk-js'
|
|
5
5
|
import { ArchivistInstance, ArchivistNextOptions } from '@xyo-network/archivist-model'
|
|
@@ -15,23 +15,24 @@ import {
|
|
|
15
15
|
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
16
16
|
import { Payload, WithStorageMeta } from '@xyo-network/payload-model'
|
|
17
17
|
import {
|
|
18
|
-
|
|
19
|
-
} from '@xyo-network/xl1-protocol'
|
|
20
|
-
import {
|
|
18
|
+
AbstractCreatableProvider,
|
|
21
19
|
asChainIndexingServiceStateWithStorageMeta,
|
|
22
20
|
BlockViewer,
|
|
23
21
|
BlockViewerMoniker,
|
|
24
22
|
ChainIndexingServiceState, ChainIndexingServiceStateSchema, ChainStakeViewer,
|
|
25
23
|
ChainStakeViewerMoniker,
|
|
24
|
+
creatableProvider,
|
|
26
25
|
isChainIndexingServiceState,
|
|
27
26
|
readPayloadMapFromStore,
|
|
28
27
|
StakeIntentService,
|
|
29
28
|
timeBudget,
|
|
30
|
-
} from '@xyo-network/xl1-
|
|
29
|
+
} from '@xyo-network/xl1-sdk'
|
|
30
|
+
import {
|
|
31
|
+
asBlockBoundWitness, asBlockBoundWitnessWithStorageMeta, asChainStakeIntent, type Intent,
|
|
32
|
+
} from '@xyo-network/xl1-sdk'
|
|
31
33
|
import { Mutex } from 'async-mutex'
|
|
32
34
|
import { LRUCache } from 'lru-cache'
|
|
33
35
|
|
|
34
|
-
import { BaseService } from '../BaseService.ts'
|
|
35
36
|
import { BaseServiceParams } from '../model/index.ts'
|
|
36
37
|
|
|
37
38
|
export interface XyoStakeIntentServiceParams extends BaseServiceParams {
|
|
@@ -50,8 +51,12 @@ const ACTIVE_STAKE_TTL = 1000 * 60 * 60 * 2 // 2 hours in milliseconds
|
|
|
50
51
|
const NO_ACTIVE_STAKE_TTL = 1000 * 2 // 2 seconds in milliseconds
|
|
51
52
|
const STAKE_CACHE_MAX_ENTRIES = 10_000
|
|
52
53
|
|
|
53
|
-
@
|
|
54
|
-
export class XyoStakeIntentService extends
|
|
54
|
+
@creatableProvider()
|
|
55
|
+
export class XyoStakeIntentService extends AbstractCreatableProvider<XyoStakeIntentServiceParams> implements StakeIntentService {
|
|
56
|
+
static readonly defaultMoniker = 'StakeIntent'
|
|
57
|
+
static readonly dependencies = []
|
|
58
|
+
static readonly monikers = [XyoStakeIntentService.defaultMoniker]
|
|
59
|
+
moniker = 'StakeIntent'
|
|
55
60
|
// TODO: Use hash instead of block number to handle chain reorgs
|
|
56
61
|
protected _lastIndexedBlockHash: Hash | undefined = undefined
|
|
57
62
|
// TODO: Interval tree per declaration (bank, validator, etc.)
|
|
@@ -116,7 +121,7 @@ export class XyoStakeIntentService extends BaseService<XyoStakeIntentServicePara
|
|
|
116
121
|
const requiredMinimumStake = this.getRequiredMinimumStakeForIntent(intent)
|
|
117
122
|
const validCandidates = await this.filterToValidStake(candidates, this.chainStakeViewer, requiredMinimumStake)
|
|
118
123
|
return validCandidates
|
|
119
|
-
})
|
|
124
|
+
}, { timeBudgetLimit: 200 })
|
|
120
125
|
}
|
|
121
126
|
|
|
122
127
|
getRequiredMinimumStakeForIntent(intent: Intent): bigint {
|
|
@@ -220,32 +225,30 @@ export class XyoStakeIntentService extends BaseService<XyoStakeIntentServicePara
|
|
|
220
225
|
return await this.spanAsync('updateIndex', async () => {
|
|
221
226
|
const currentHead = (await this.blockViewer.currentBlock())[0]
|
|
222
227
|
if (isUndefined(currentHead)) return
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
this._producers.insert(address, start, stop)
|
|
238
|
-
}
|
|
228
|
+
const currentHeadHash = currentHead._hash
|
|
229
|
+
const chainMap = readPayloadMapFromStore<WithStorageMeta<Payload>>(this.chainArchivist)
|
|
230
|
+
const result = await analyzeChain({ chainMap }, [new ChainStakeIntentAnalyzer('producer')], currentHeadHash, this._lastIndexedBlockHash)
|
|
231
|
+
const signedDeclarations = filterAs(result.find(isChainSummaryStakeIntent)?.intents ?? [], asChainStakeIntent)
|
|
232
|
+
if (currentHead.block === undefined) return
|
|
233
|
+
const currentHeadBlockNum = currentHead.block
|
|
234
|
+
if (displayProgress) this.logger?.log(`Updating index through 0x${currentHeadBlockNum}`)
|
|
235
|
+
for (const signedDeclaration of signedDeclarations) {
|
|
236
|
+
const { exp, nbf } = signedDeclaration
|
|
237
|
+
const start = nbf
|
|
238
|
+
const stop = exp
|
|
239
|
+
const address = asAddress(signedDeclaration?.from)
|
|
240
|
+
if (start !== undefined && stop !== undefined && address !== undefined) {
|
|
241
|
+
this._producers.insert(address, start, stop)
|
|
239
242
|
}
|
|
240
|
-
|
|
243
|
+
}
|
|
244
|
+
/*
|
|
241
245
|
if (index % STATE_PERSISTENCE_INTERVAL === 0n) {
|
|
242
246
|
if (displayProgress) this.logger?.info(`Persisting state at block ${index}`)
|
|
243
247
|
await this.persistState(await PayloadBuilder.hash(block))
|
|
244
248
|
}
|
|
245
249
|
*/
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
})
|
|
250
|
+
this._lastIndexedBlockHash = currentHeadHash
|
|
251
|
+
}, { timeBudgetLimit: 1000 })
|
|
249
252
|
})
|
|
250
253
|
}
|
|
251
254
|
}
|
|
@@ -7,8 +7,8 @@ import { payloadSchemasContains } from '@xyo-network/boundwitness-validator'
|
|
|
7
7
|
import { BoundWitnessWrapper } from '@xyo-network/boundwitness-wrapper'
|
|
8
8
|
import type {
|
|
9
9
|
BlockBoundWitness, ChainStakeIntent, Intent,
|
|
10
|
-
} from '@xyo-network/xl1-
|
|
11
|
-
import { asChainStakeIntent, ChainStakeIntentSchema } from '@xyo-network/xl1-
|
|
10
|
+
} from '@xyo-network/xl1-sdk'
|
|
11
|
+
import { asChainStakeIntent, ChainStakeIntentSchema } from '@xyo-network/xl1-sdk'
|
|
12
12
|
|
|
13
13
|
export const getBlockSignedStakeDeclarations = async (block: BlockBoundWitness, archivist: ArchivistInstance, intent: Intent): Promise<ChainStakeIntent[]> => {
|
|
14
14
|
// Get payloads in block
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
} from '@
|
|
4
|
-
import {
|
|
5
|
-
import { StepIdentity } from '@xyo-network/xl1-protocol'
|
|
6
|
-
import { StepStakeViewer, StepStakeViewerMoniker } from '@xyo-network/xl1-protocol-sdk'
|
|
1
|
+
import type { Address, Promisable } from '@xylabs/sdk-js'
|
|
2
|
+
import type { ReadArchivist } from '@xyo-network/archivist-model'
|
|
3
|
+
import type { StepIdentity, StepStakeViewer } from '@xyo-network/xl1-sdk'
|
|
4
|
+
import { AbstractCreatableProvider, StepStakeViewerMoniker } from '@xyo-network/xl1-sdk'
|
|
7
5
|
|
|
8
|
-
import {
|
|
9
|
-
import { BaseServiceParams } from '../model/index.ts'
|
|
6
|
+
import type { BaseServiceParams } from '../model/index.ts'
|
|
10
7
|
|
|
11
8
|
export interface BaseStepStakeServiceParams extends BaseServiceParams {
|
|
12
9
|
chainArchivist: ReadArchivist
|
|
13
10
|
}
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
export class BaseStepStakeService extends BaseService<BaseStepStakeServiceParams> implements StepStakeViewer {
|
|
12
|
+
export abstract class AbstractStepStakeService extends AbstractCreatableProvider<BaseStepStakeServiceParams> implements StepStakeViewer {
|
|
17
13
|
static readonly defaultMoniker = StepStakeViewerMoniker
|
|
18
14
|
static readonly monikers = [StepStakeViewerMoniker]
|
|
19
|
-
moniker =
|
|
15
|
+
override moniker = AbstractStepStakeService.defaultMoniker
|
|
20
16
|
|
|
21
17
|
stepStake(_step: StepIdentity): Promisable<Record<Address, bigint>> {
|
|
22
18
|
throw new Error('Method [stepStake] not implemented.')
|
|
@@ -4,13 +4,14 @@ import type { ReadArchivist } from '@xyo-network/archivist-model'
|
|
|
4
4
|
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
5
5
|
import type { Payload, WithHashMeta } from '@xyo-network/payload-model'
|
|
6
6
|
import type {
|
|
7
|
+
BlockRate,
|
|
8
|
+
BlockViewer, EventingChainBlockNumberIteratorService,
|
|
7
9
|
SignedHydratedBlockWithHashMeta,
|
|
8
10
|
XL1BlockNumber,
|
|
9
|
-
} from '@xyo-network/xl1-
|
|
10
|
-
import { asSignedBlockBoundWitness, asSignedBlockBoundWitnessWithStorageMeta } from '@xyo-network/xl1-protocol'
|
|
11
|
+
} from '@xyo-network/xl1-sdk'
|
|
11
12
|
import {
|
|
12
|
-
|
|
13
|
-
} from '@xyo-network/xl1-
|
|
13
|
+
asSignedBlockBoundWitness, asSignedBlockBoundWitnessWithStorageMeta, BlockViewerMoniker,
|
|
14
|
+
} from '@xyo-network/xl1-sdk'
|
|
14
15
|
|
|
15
16
|
export function blockViewerFromChainIteratorAndArchivist(
|
|
16
17
|
chainIterator: EventingChainBlockNumberIteratorService,
|
|
@@ -87,6 +88,15 @@ export function blockViewerFromChainIteratorAndArchivist(
|
|
|
87
88
|
payloadsByHash: function (_hashes: Hash[]): Promisable<WithHashMeta<Payload>[]> {
|
|
88
89
|
throw new Error('Function not implemented.')
|
|
89
90
|
},
|
|
91
|
+
rate(..._args): Promisable<BlockRate> {
|
|
92
|
+
throw new Error('Function not implemented.')
|
|
93
|
+
},
|
|
94
|
+
stepSizeRate(..._args) {
|
|
95
|
+
throw new Error('Function not implemented.')
|
|
96
|
+
},
|
|
97
|
+
timeDurationRate(..._args) {
|
|
98
|
+
throw new Error('Function not implemented.')
|
|
99
|
+
},
|
|
90
100
|
} satisfies BlockViewer
|
|
91
101
|
return result
|
|
92
102
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
assertEx, hexFrom, isDefined, isHex,
|
|
3
3
|
} from '@xylabs/sdk-js'
|
|
4
|
-
import type { Config } from '@xyo-network/xl1-
|
|
4
|
+
import type { Config } from '@xyo-network/xl1-sdk'
|
|
5
5
|
|
|
6
6
|
export const canUseChainId = (config: Pick<Config, 'evm'>): boolean => {
|
|
7
7
|
return isDefined(config.evm.chainId)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Logger } from '@xylabs/sdk-js'
|
|
2
2
|
import { assertEx } from '@xylabs/sdk-js'
|
|
3
|
-
import type { Config } from '@xyo-network/xl1-
|
|
3
|
+
import type { Config } from '@xyo-network/xl1-sdk'
|
|
4
4
|
import type { Provider } from 'ethers'
|
|
5
5
|
import type { JsonRpcProvider } from 'ethers/providers'
|
|
6
6
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assertEx, isDefined } from '@xylabs/sdk-js'
|
|
2
|
-
import type { Config } from '@xyo-network/xl1-
|
|
2
|
+
import type { Config } from '@xyo-network/xl1-sdk'
|
|
3
3
|
import { InfuraProvider } from 'ethers/providers'
|
|
4
4
|
|
|
5
5
|
import { canUseChainId, getChainId } from './initChainId.ts'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assertEx, isDefined } from '@xylabs/sdk-js'
|
|
2
|
-
import type { Config } from '@xyo-network/xl1-
|
|
2
|
+
import type { Config } from '@xyo-network/xl1-sdk'
|
|
3
3
|
import { JsonRpcProvider } from 'ethers/providers'
|
|
4
4
|
|
|
5
5
|
import { canUseChainId, getChainId } from './initChainId.ts'
|
|
@@ -3,8 +3,8 @@ import { buildNextBlock, createGenesisBlock } from '@xyo-network/chain-protocol'
|
|
|
3
3
|
import type { WalletInstance } from '@xyo-network/wallet-model'
|
|
4
4
|
import type {
|
|
5
5
|
AttoXL1, ChainId, SignedHydratedBlockWithHashMeta,
|
|
6
|
-
} from '@xyo-network/xl1-
|
|
7
|
-
import { createDeclarationIntent } from '@xyo-network/xl1-
|
|
6
|
+
} from '@xyo-network/xl1-sdk'
|
|
7
|
+
import { createDeclarationIntent } from '@xyo-network/xl1-sdk'
|
|
8
8
|
|
|
9
9
|
export const createBootstrapHead = async (
|
|
10
10
|
account: WalletInstance,
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export * from './AccountBalance/index.ts'
|
|
2
|
-
export * from './BaseService.ts'
|
|
3
2
|
export * from './BlockReward/index.ts'
|
|
4
3
|
export * from './blockViewerFromChainIteratorAndArchivist.ts'
|
|
5
|
-
export * from './ChainService/index.ts'
|
|
6
4
|
export * from './ChainValidator/index.ts'
|
|
7
5
|
export * from './Election/index.ts'
|
|
8
6
|
export * from './implementation/index.ts'
|
package/src/model/Params.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { AccountInstance } from '@xyo-network/account-model'
|
|
2
|
-
import type { OpenTelemetryProviders } from '@xyo-network/xl1-
|
|
3
|
-
import type { CreatableProviderParams } from '@xyo-network/xl1-protocol-sdk'
|
|
2
|
+
import type { CreatableProviderParams, OpenTelemetryProviders } from '@xyo-network/xl1-sdk'
|
|
4
3
|
|
|
5
4
|
export interface BaseServiceParams extends CreatableProviderParams, OpenTelemetryProviders {
|
|
6
5
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Address,
|
|
3
|
-
assertEx, exists, Hex, hexToBigInt, isDefined, Promisable,
|
|
2
|
+
Address, assertEx, exists, Hex, hexToBigInt, isDefined, Promisable,
|
|
4
3
|
} from '@xylabs/sdk-js'
|
|
5
4
|
import { AccountInstance } from '@xyo-network/account-model'
|
|
6
5
|
import { MemoryArchivist } from '@xyo-network/archivist-memory'
|
|
@@ -12,32 +11,12 @@ import { buildNextBlock } from '@xyo-network/chain-protocol'
|
|
|
12
11
|
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
13
12
|
import { WithHashMeta } from '@xyo-network/payload-model'
|
|
14
13
|
import {
|
|
15
|
-
AllowedBlockPayload, asBlockBoundWitness, AttoXL1, BlockBoundWitness,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
AbstractCreatableProvider,
|
|
22
|
-
AccountBalanceViewer,
|
|
23
|
-
AccountBalanceViewerMoniker,
|
|
24
|
-
BlockRewardViewer,
|
|
25
|
-
BlockRewardViewerMoniker,
|
|
26
|
-
BlockRunner,
|
|
27
|
-
BlockRunnerMoniker,
|
|
28
|
-
BlockValidationViewer,
|
|
29
|
-
BlockValidationViewerMoniker,
|
|
30
|
-
creatableProvider,
|
|
31
|
-
CreatableProviderParams,
|
|
32
|
-
createDeclarationIntent,
|
|
33
|
-
HydratedBlockStateValidationFunction,
|
|
34
|
-
MempoolRunner,
|
|
35
|
-
MempoolRunnerMoniker,
|
|
36
|
-
MempoolViewer,
|
|
37
|
-
MempoolViewerMoniker,
|
|
38
|
-
TimeSyncViewer,
|
|
39
|
-
TimeSyncViewerMoniker,
|
|
40
|
-
} from '@xyo-network/xl1-protocol-sdk'
|
|
14
|
+
AbstractCreatableProvider, AccountBalanceViewer, AccountBalanceViewerMoniker, AllowedBlockPayload, asBlockBoundWitness, AttoXL1, BlockBoundWitness,
|
|
15
|
+
BlockNumberPayload, BlockNumberSchema, BlockRewardViewer, BlockRewardViewerMoniker, BlockRunner, BlockRunnerMoniker, BlockValidationViewer,
|
|
16
|
+
BlockValidationViewerMoniker, ChainId, ChainStakeIntent, creatableProvider, CreatableProviderParams, createDeclarationIntent, defaultRewardRatio,
|
|
17
|
+
HydratedBlockStateValidationFunction, MempoolRunner, MempoolRunnerMoniker, MempoolViewer, MempoolViewerMoniker, SignedBlockBoundWitnessWithHashMeta,
|
|
18
|
+
SignedHydratedBlockWithHashMeta, SignedHydratedTransaction, TimeSyncViewer, TimeSyncViewerMoniker, Transfer, XYO_STEP_REWARD_ADDRESS,
|
|
19
|
+
} from '@xyo-network/xl1-sdk'
|
|
41
20
|
|
|
42
21
|
import { generateTransactionFeeTransfers } from './generateTransactionFeeTransfers.ts'
|
|
43
22
|
|
|
@@ -57,7 +36,7 @@ export const XYO_PRODUCER_REDECLARATION_DURATION = 10_000
|
|
|
57
36
|
*/
|
|
58
37
|
export const XYO_PRODUCER_REDECLARATION_WINDOW = 500
|
|
59
38
|
|
|
60
|
-
export
|
|
39
|
+
export interface SimpleBlockRunnerParams extends CreatableProviderParams {
|
|
61
40
|
account: AccountInstance
|
|
62
41
|
rejectedTransactionsArchivist?: ArchivistInstance
|
|
63
42
|
rewardAddress: Address
|
|
@@ -67,6 +46,15 @@ export type SimpleBlockRunnerParams = CreatableProviderParams & {
|
|
|
67
46
|
@creatableProvider()
|
|
68
47
|
export class SimpleBlockRunner extends AbstractCreatableProvider<SimpleBlockRunnerParams> implements BlockRunner {
|
|
69
48
|
static readonly defaultMoniker = BlockRunnerMoniker
|
|
49
|
+
static readonly dependencies = [
|
|
50
|
+
AccountBalanceViewerMoniker,
|
|
51
|
+
BlockRewardViewerMoniker,
|
|
52
|
+
BlockValidationViewerMoniker,
|
|
53
|
+
MempoolRunnerMoniker,
|
|
54
|
+
MempoolViewerMoniker,
|
|
55
|
+
TimeSyncViewerMoniker,
|
|
56
|
+
]
|
|
57
|
+
|
|
70
58
|
static readonly monikers = [BlockRunnerMoniker]
|
|
71
59
|
moniker = SimpleBlockRunner.defaultMoniker
|
|
72
60
|
|
|
@@ -79,6 +67,7 @@ export class SimpleBlockRunner extends AbstractCreatableProvider<SimpleBlockRunn
|
|
|
79
67
|
private _address?: Address
|
|
80
68
|
private _blockRewardViewer?: BlockRewardViewer
|
|
81
69
|
private _blockValidationViewer?: BlockValidationViewer
|
|
70
|
+
private _chainId?: ChainId
|
|
82
71
|
private _mempoolRunner?: MempoolRunner
|
|
83
72
|
private _mempoolViewer?: MempoolViewer
|
|
84
73
|
private _rewardAddress?: Address
|
|
@@ -127,6 +116,10 @@ export class SimpleBlockRunner extends AbstractCreatableProvider<SimpleBlockRunn
|
|
|
127
116
|
return this._blockValidationViewer!
|
|
128
117
|
}
|
|
129
118
|
|
|
119
|
+
protected get chainId() {
|
|
120
|
+
return this._chainId
|
|
121
|
+
}
|
|
122
|
+
|
|
130
123
|
// protected get electionService() {
|
|
131
124
|
// return assertEx(this.params.electionService, () => 'electionService is required')
|
|
132
125
|
// }
|
|
@@ -148,7 +141,7 @@ export class SimpleBlockRunner extends AbstractCreatableProvider<SimpleBlockRunn
|
|
|
148
141
|
}
|
|
149
142
|
|
|
150
143
|
protected get rewardAddress(): Address {
|
|
151
|
-
return
|
|
144
|
+
return this._rewardAddress!
|
|
152
145
|
}
|
|
153
146
|
|
|
154
147
|
// protected get stakeIntentService(): StakeIntentService {
|
|
@@ -166,13 +159,14 @@ export class SimpleBlockRunner extends AbstractCreatableProvider<SimpleBlockRunn
|
|
|
166
159
|
override async createHandler() {
|
|
167
160
|
this._rejectedTransactionsArchivist = this.params.rejectedTransactionsArchivist ?? await MemoryArchivist.create()
|
|
168
161
|
this._account = assertEx(this.params.account, () => 'Account is required')
|
|
169
|
-
this._rewardAddress = assertEx(this.params.rewardAddress, () => 'No reward address provided')
|
|
170
162
|
this._address = this.account.address
|
|
171
163
|
this._accountBalanceViewer = await this.locateAndCreate<AccountBalanceViewer>(AccountBalanceViewerMoniker)
|
|
172
164
|
this._blockRewardViewer = await this.locateAndCreate<BlockRewardViewer>(BlockRewardViewerMoniker)
|
|
173
165
|
this._blockValidationViewer = await this.locator.getInstance<BlockValidationViewer>(BlockValidationViewerMoniker)
|
|
166
|
+
this._chainId = this.context.config.chain.id
|
|
174
167
|
this._mempoolRunner = await this.locateAndCreate<MempoolRunner>(MempoolRunnerMoniker)
|
|
175
168
|
this._mempoolViewer = await this.locateAndCreate<MempoolViewer>(MempoolViewerMoniker)
|
|
169
|
+
this._rewardAddress = this.params.rewardAddress ?? this.context.config.producer.rewardAddress
|
|
176
170
|
this._timeSyncViewer = await this.locateAndCreate<TimeSyncViewer>(TimeSyncViewerMoniker)
|
|
177
171
|
}
|
|
178
172
|
|
|
@@ -268,7 +262,7 @@ export class SimpleBlockRunner extends AbstractCreatableProvider<SimpleBlockRunn
|
|
|
268
262
|
|
|
269
263
|
const transactionTransfers = await generateTransactionFeeTransfers(this.address, nextBlockTransactions)
|
|
270
264
|
const timeStart = Date.now()
|
|
271
|
-
const timePayload = await this.generateTimePayload(
|
|
265
|
+
const timePayload = await this.generateTimePayload()
|
|
272
266
|
const timeDuration = Date.now() - timeStart
|
|
273
267
|
if (timeDuration > 100) {
|
|
274
268
|
this.logger?.warn(`[Slow] Generated time payload in ${timeDuration}ms`)
|
|
@@ -282,7 +276,16 @@ export class SimpleBlockRunner extends AbstractCreatableProvider<SimpleBlockRunn
|
|
|
282
276
|
this.logger?.info(`Building block ${head.block + 1}`)
|
|
283
277
|
const startBuild = Date.now()
|
|
284
278
|
const stepRewardPoolBalance = (await this.accountBalanceViewer.accountBalances([XYO_STEP_REWARD_ADDRESS]))[XYO_STEP_REWARD_ADDRESS]
|
|
285
|
-
const block = await buildNextBlock(
|
|
279
|
+
const block = await buildNextBlock(
|
|
280
|
+
head,
|
|
281
|
+
fundedNextBlockTransactions,
|
|
282
|
+
blockPayloads,
|
|
283
|
+
[this.account],
|
|
284
|
+
XYO_STEP_REWARD_ADDRESS,
|
|
285
|
+
stepRewardPoolBalance,
|
|
286
|
+
undefined,
|
|
287
|
+
this.chainId,
|
|
288
|
+
)
|
|
286
289
|
|
|
287
290
|
this.logger?.info(
|
|
288
291
|
`Built block ${block[0].block} in ${Date.now() - startBuild}ms with ${block[1].length} payloads`,
|
|
@@ -290,7 +293,7 @@ export class SimpleBlockRunner extends AbstractCreatableProvider<SimpleBlockRunn
|
|
|
290
293
|
|
|
291
294
|
this.logger?.info(`Validating block ${block[0].block} with ${block[1].length} payloads`)
|
|
292
295
|
const startValidate = Date.now()
|
|
293
|
-
const errors = await this.blockValidationViewer.validateBlock(block)
|
|
296
|
+
const errors = await this.blockValidationViewer.validateBlock(block, { head: head._hash })
|
|
294
297
|
this.logger?.info(`Validated block ${block[0].block} in ${Date.now() - startValidate}ms with ${block[1].length} payloads`)
|
|
295
298
|
|
|
296
299
|
if (errors.length > 0) {
|
|
@@ -305,7 +308,7 @@ export class SimpleBlockRunner extends AbstractCreatableProvider<SimpleBlockRunn
|
|
|
305
308
|
this.logger?.error(`Error proposing next valid block: ${(error as Error).message}`)
|
|
306
309
|
throw error
|
|
307
310
|
}
|
|
308
|
-
})
|
|
311
|
+
}, { timeBudgetLimit: 200 })
|
|
309
312
|
}
|
|
310
313
|
|
|
311
314
|
// remove unfunded transactions and block transfers
|
|
@@ -334,7 +337,7 @@ export class SimpleBlockRunner extends AbstractCreatableProvider<SimpleBlockRunn
|
|
|
334
337
|
return [fundedTransactions, fundedTransfers]
|
|
335
338
|
}
|
|
336
339
|
|
|
337
|
-
private async generateTimePayload(
|
|
340
|
+
private async generateTimePayload() {
|
|
338
341
|
return await this.timeSyncViewer.currentTimePayload()
|
|
339
342
|
}
|
|
340
343
|
|
|
@@ -5,10 +5,11 @@ import type {
|
|
|
5
5
|
SignedHydratedTransaction,
|
|
6
6
|
Transfer,
|
|
7
7
|
XL1,
|
|
8
|
-
} from '@xyo-network/xl1-
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
} from '@xyo-network/xl1-sdk'
|
|
9
|
+
import {
|
|
10
|
+
HydratedTransactionWrapper,
|
|
11
|
+
transactionRequiredGas, TransferSchema, XYO_ZERO_ADDRESS,
|
|
12
|
+
} from '@xyo-network/xl1-sdk'
|
|
12
13
|
|
|
13
14
|
export async function generateTransactionFeeTransfers(address: Address, transactions: SignedHydratedTransaction[]): Promise<Transfer[]> {
|
|
14
15
|
const txs = await Promise.all(transactions.map(async (tx) => {
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { EventData, Promisable } from '@xylabs/sdk-js';
|
|
2
|
-
import { AbstractCreatableProvider } from '@xyo-network/xl1-protocol-sdk';
|
|
3
|
-
import type { BaseAccountableServiceParams, BaseServiceParams } from './model/index.ts';
|
|
4
|
-
declare global {
|
|
5
|
-
var xyoServiceSingletons: Record<string, unknown>;
|
|
6
|
-
}
|
|
7
|
-
export declare class BaseService<TParams extends BaseServiceParams = BaseServiceParams, TEventData extends EventData = EventData> extends AbstractCreatableProvider<TParams, TEventData> {
|
|
8
|
-
private static singletonInitMutex;
|
|
9
|
-
static get singletons(): Record<string, unknown>;
|
|
10
|
-
static initSingleton<TService extends BaseService<TParams>, TParams extends BaseServiceParams>(params: Partial<TParams>): Promise<TService>;
|
|
11
|
-
}
|
|
12
|
-
export declare abstract class BaseAccountableService<TParams extends BaseAccountableServiceParams = BaseAccountableServiceParams> extends BaseService<TParams> {
|
|
13
|
-
}
|
|
14
|
-
export interface CreatableService<T extends BaseService = BaseService> {
|
|
15
|
-
new (params: T['params']): T;
|
|
16
|
-
create<T extends BaseService>(this: CreatableService<T>, params?: Partial<T['params']>): Promisable<T>;
|
|
17
|
-
}
|
|
18
|
-
export declare function creatableService<T extends BaseService = BaseService>(): <U extends CreatableService<T>>(constructor: U) => void;
|
|
19
|
-
//# sourceMappingURL=BaseService.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BaseService.d.ts","sourceRoot":"","sources":["../../src/BaseService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAA;AAGzE,OAAO,KAAK,EAAE,4BAA4B,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEvF,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAClD;AAED,qBACa,WAAW,CAAC,OAAO,SAAS,iBAAiB,GAAG,iBAAiB,EAAE,UAAU,SAAS,SAAS,GAAG,SAAS,CACtH,SAAQ,yBAAyB,CAAC,OAAO,EAAE,UAAU,CAAC;IACtD,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAc;IAE/C,MAAM,KAAK,UAAU,4BAEpB;IAED,MAAM,CAAC,aAAa,CAAC,QAAQ,SAAS,WAAW,CAAC,OAAO,CAAC,EAAE,OAAO,SAAS,iBAAiB,EAAE,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC;CAMxH;AAED,8BAAsB,sBAAsB,CAC1C,OAAO,SAAS,4BAA4B,GAAG,4BAA4B,CAC3E,SAAQ,WAAW,CAAC,OAAO,CAAC;CAE7B;AAED,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW;IACnE,KAAI,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;IAC3B,MAAM,CAAC,CAAC,SAAS,WAAW,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAA;CACvG;AAED,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,MAC1D,CAAC,SAAS,gBAAgB,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC,UAItD"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { Address, Hex, Promisable } from '@xylabs/sdk-js';
|
|
2
|
-
import type { StakedXyoChain } from '@xyo-network/typechain';
|
|
3
|
-
import type { AttoXL1, XL1BlockNumber } from '@xyo-network/xl1-protocol';
|
|
4
|
-
import { type ChainService } from '@xyo-network/xl1-protocol-sdk';
|
|
5
|
-
import type { ContractRunner } from 'ethers/providers';
|
|
6
|
-
import { BaseService } from '../../BaseService.ts';
|
|
7
|
-
import type { BaseServiceParams } from '../../model/index.ts';
|
|
8
|
-
export interface EvmChainViewerParams extends BaseServiceParams {
|
|
9
|
-
contract: StakedXyoChain;
|
|
10
|
-
id: Hex;
|
|
11
|
-
runner: ContractRunner;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* A class that represents a chain stake as backed by an EVM smart contract
|
|
15
|
-
*/
|
|
16
|
-
export declare class EvmChainViewer extends BaseService<EvmChainViewerParams> implements ChainService {
|
|
17
|
-
static readonly defaultMoniker: "ChainContractViewer";
|
|
18
|
-
static readonly monikers: "ChainContractViewer"[];
|
|
19
|
-
moniker: "ChainContractViewer";
|
|
20
|
-
protected get contract(): StakedXyoChain;
|
|
21
|
-
active(): Promise<bigint>;
|
|
22
|
-
activeByStaked(staked: Address): Promise<bigint>;
|
|
23
|
-
activeByStaker(address: Address): Promise<bigint>;
|
|
24
|
-
addStake(staked: Address, amount: bigint): Promise<boolean>;
|
|
25
|
-
forkedAtBlockNumber(): Promise<bigint>;
|
|
26
|
-
forkedAtHash(): Promise<bigint>;
|
|
27
|
-
forkedChainId(): Promise<Address>;
|
|
28
|
-
minWithdrawalBlocks(): Promise<bigint>;
|
|
29
|
-
pending(): Promise<bigint>;
|
|
30
|
-
pendingByStaker(staker: Address): Promise<bigint>;
|
|
31
|
-
removeStake(slot: bigint): Promise<boolean>;
|
|
32
|
-
rewardForBlock(_block: XL1BlockNumber): Promisable<AttoXL1>;
|
|
33
|
-
rewardsContract(): Promise<string>;
|
|
34
|
-
stakingTokenAddress(): Promise<string>;
|
|
35
|
-
withdrawStake(slot: bigint): Promise<boolean>;
|
|
36
|
-
withdrawn(): Promise<bigint>;
|
|
37
|
-
withdrawnByStaker(staker: string): Promise<bigint>;
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=Evm.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Evm.d.ts","sourceRoot":"","sources":["../../../../src/ChainService/Evm/Evm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAAE,GAAG,EAAE,UAAU,EACzB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AACxE,OAAO,EAA8B,KAAK,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAE7F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAE7D,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;IAC7D,QAAQ,EAAE,cAAc,CAAA;IACxB,EAAE,EAAE,GAAG,CAAA;IACP,MAAM,EAAE,cAAc,CAAA;CACvB;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,WAAW,CAAC,oBAAoB,CAAE,YAAW,YAAY;IAC3F,MAAM,CAAC,QAAQ,CAAC,cAAc,wBAA6B;IAC3D,MAAM,CAAC,QAAQ,CAAC,QAAQ,0BAA+B;IACvD,OAAO,wBAAgC;IAEvC,SAAS,KAAK,QAAQ,mBAErB;IAEK,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC;IAIzB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAIhD,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAIjD,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAM3D,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC;IAItC,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;IAI/B,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC;IAIjC,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC;IAItC,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IAI1B,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAIjD,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAMjD,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC;IAIrD,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC;IAIlC,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC;IAItC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAM7C,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAI5B,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAGzD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ChainService/Evm/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { Address, Hex, Promisable } from '@xylabs/sdk-js';
|
|
2
|
-
import type { AttoXL1, XL1BlockNumber } from '@xyo-network/xl1-protocol';
|
|
3
|
-
import { type ChainService } from '@xyo-network/xl1-protocol-sdk';
|
|
4
|
-
import { BaseService } from '../../BaseService.ts';
|
|
5
|
-
import type { BaseServiceParams } from '../../model/index.ts';
|
|
6
|
-
export interface MemoryChainViewerParams extends BaseServiceParams {
|
|
7
|
-
chainId: Hex;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* A class that represents a chain stake as backed in memory
|
|
11
|
-
*/
|
|
12
|
-
export declare class MemoryChainViewer extends BaseService<MemoryChainViewerParams> implements ChainService {
|
|
13
|
-
static readonly defaultMoniker: "ChainContractViewer";
|
|
14
|
-
static readonly monikers: "ChainContractViewer"[];
|
|
15
|
-
moniker: "ChainContractViewer";
|
|
16
|
-
protected _chainId: Hex | undefined;
|
|
17
|
-
protected _simulatedStake: bigint;
|
|
18
|
-
active(): Promise<bigint>;
|
|
19
|
-
activeByStaked(_staked: Address): Promise<bigint>;
|
|
20
|
-
activeByStaker(_address: string): Promise<bigint>;
|
|
21
|
-
addStake(_staked: string, _amount: bigint): Promise<boolean>;
|
|
22
|
-
createHandler(): void;
|
|
23
|
-
forkedAtBlockNumber(): Promise<bigint>;
|
|
24
|
-
forkedAtHash(): Promise<bigint>;
|
|
25
|
-
forkedChainId(): Promise<Address>;
|
|
26
|
-
minWithdrawalBlocks(): Promise<bigint>;
|
|
27
|
-
pending(): Promise<bigint>;
|
|
28
|
-
pendingByStaker(_staker: string): Promise<bigint>;
|
|
29
|
-
removeStake(_slot: bigint): Promise<boolean>;
|
|
30
|
-
rewardForBlock(_block: XL1BlockNumber): Promisable<AttoXL1>;
|
|
31
|
-
rewardsContract(): Promise<string>;
|
|
32
|
-
stakingTokenAddress(): Promise<string>;
|
|
33
|
-
withdrawStake(_slot: bigint): Promise<boolean>;
|
|
34
|
-
withdrawn(): Promise<bigint>;
|
|
35
|
-
withdrawnByStaker(_staker: string): Promise<bigint>;
|
|
36
|
-
protected startHandler(): Promise<void>;
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=Memory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Memory.d.ts","sourceRoot":"","sources":["../../../../src/ChainService/Memory/Memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAAE,GAAG,EAAE,UAAU,EACzB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AACxE,OAAO,EAEL,KAAK,YAAY,EAClB,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAE7D,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAChE,OAAO,EAAE,GAAG,CAAA;CACb;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,WAAW,CAAC,uBAAuB,CAAE,YAAW,YAAY;IACjG,MAAM,CAAC,QAAQ,CAAC,cAAc,wBAA6B;IAC3D,MAAM,CAAC,QAAQ,CAAC,QAAQ,0BAA+B;IACvD,OAAO,wBAAmC;IAE1C,SAAS,CAAC,QAAQ,EAAE,GAAG,GAAG,SAAS,CAAA;IACnC,SAAS,CAAC,eAAe,EAAE,MAAM,CAAK;IAEhC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC;IAIzB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAIjD,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIjD,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIzD,aAAa,IAAI,IAAI;IAKxB,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC;IAItC,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;IAI/B,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC;IAIjC,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC;IAItC,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IAI1B,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIjD,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIlD,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC;IAIrD,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC;IAIlC,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC;IAItC,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI9C,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAI5B,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;cAIhC,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;CAIvD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ChainService/Memory/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ChainService/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA"}
|