@xyo-network/chain-services 1.15.2 → 1.15.4
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/README.md +5302 -2235
- package/dist/neutral/AccountBalance/BaseAccountBalanceService.d.ts +3 -5
- package/dist/neutral/AccountBalance/BaseAccountBalanceService.d.ts.map +1 -1
- package/dist/neutral/AccountBalance/accountBalanceServiceFromArchivist.d.ts +3 -2
- package/dist/neutral/AccountBalance/accountBalanceServiceFromArchivist.d.ts.map +1 -1
- package/dist/neutral/AccountTransfers/BaseAccountTransfersService.d.ts +3 -6
- package/dist/neutral/AccountTransfers/BaseAccountTransfersService.d.ts.map +1 -1
- package/dist/neutral/AccountTransfers/accountTransfersServiceFromArchivist.d.ts +3 -3
- package/dist/neutral/AccountTransfers/accountTransfersServiceFromArchivist.d.ts.map +1 -1
- package/dist/neutral/BlockProducer/spec/BaseBlockProducerService.spec.d.ts.map +1 -1
- package/dist/neutral/ChainBlockNumberIteration/ChainBlockNumberIterationService.d.ts +3 -3
- package/dist/neutral/ChainBlockNumberIteration/ChainBlockNumberIterationService.d.ts.map +1 -1
- package/dist/neutral/ChainBlockNumberIteration/model/Params.d.ts +3 -2
- package/dist/neutral/ChainBlockNumberIteration/model/Params.d.ts.map +1 -1
- package/dist/neutral/ChainService/Evm/Evm.d.ts +4 -4
- package/dist/neutral/ChainService/Evm/Evm.d.ts.map +1 -1
- package/dist/neutral/ChainService/Memory/Memory.d.ts +1 -1
- package/dist/neutral/ChainService/Memory/Memory.d.ts.map +1 -1
- package/dist/neutral/ChainValidator/XyoValidator.d.ts +2 -2
- package/dist/neutral/ChainValidator/XyoValidator.d.ts.map +1 -1
- package/dist/neutral/NetworkStakeStepReward/BaseNetworkStakeStepRewardService.d.ts +15 -13
- package/dist/neutral/NetworkStakeStepReward/BaseNetworkStakeStepRewardService.d.ts.map +1 -1
- package/dist/neutral/PendingTransactions/BasePendingTransactions.d.ts +2 -2
- package/dist/neutral/PendingTransactions/BasePendingTransactions.d.ts.map +1 -1
- package/dist/neutral/StakeIntent/XyoStakeIntentService.d.ts.map +1 -1
- package/dist/neutral/StepStake/BaseStepStakeService.d.ts +3 -3
- package/dist/neutral/StepStake/BaseStepStakeService.d.ts.map +1 -1
- package/dist/neutral/index.mjs +118 -151
- package/dist/neutral/index.mjs.map +1 -1
- package/package.json +40 -40
- package/src/AccountBalance/BaseAccountBalanceService.ts +6 -8
- package/src/AccountBalance/accountBalanceServiceFromArchivist.ts +22 -33
- package/src/AccountTransfers/BaseAccountTransfersService.ts +4 -12
- package/src/AccountTransfers/accountTransfersServiceFromArchivist.ts +22 -35
- package/src/BlockProducer/spec/BaseBlockProducerService.spec.ts +62 -8
- package/src/ChainBlockNumberIteration/ChainBlockNumberIterationService.ts +11 -11
- package/src/ChainBlockNumberIteration/model/Params.ts +3 -2
- package/src/ChainService/Evm/Evm.ts +8 -8
- package/src/ChainService/Memory/Memory.ts +1 -1
- package/src/ChainValidator/XyoValidator.ts +2 -2
- package/src/NetworkStakeStepReward/BaseNetworkStakeStepRewardService.ts +24 -14
- package/src/PendingTransactions/BasePendingTransactions.ts +2 -2
- package/src/StakeIntent/XyoStakeIntentService.ts +4 -2
- package/src/StepStake/BaseStepStakeService.ts +3 -3
|
@@ -2,7 +2,9 @@ import { creatable } from '@xylabs/creatable'
|
|
|
2
2
|
import { Address } from '@xylabs/hex'
|
|
3
3
|
import { Promisable } from '@xylabs/promise'
|
|
4
4
|
import { ReadArchivist } from '@xyo-network/archivist-model'
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
EventingChainBlockNumberIteratorService, NetworkStakeStepRewardService, StepIdentity,
|
|
7
|
+
} from '@xyo-network/xl1-protocol'
|
|
6
8
|
import { Provider } from 'ethers'
|
|
7
9
|
|
|
8
10
|
import { BaseService } from '../BaseService.ts'
|
|
@@ -16,55 +18,63 @@ export interface BaseNetworkStakeStepRewardServiceParams extends BaseServicePara
|
|
|
16
18
|
|
|
17
19
|
@creatable()
|
|
18
20
|
export class BaseNetworkStakeStepRewardService extends BaseService<BaseNetworkStakeStepRewardServiceParams> implements NetworkStakeStepRewardService {
|
|
19
|
-
|
|
21
|
+
networkStakeStepRewardAddressHistory(_address: Address): Promisable<Record<Address, bigint>> {
|
|
20
22
|
throw new Error('Method not implemented.')
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
networkStakeStepRewardAddressReward(_context: StepIdentity, _address: Address): Promisable<Record<Address, bigint>> {
|
|
24
26
|
throw new Error('Method not implemented.')
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
networkStakeStepRewardAddressShare(_context: StepIdentity, _address: Address): Promisable<[bigint, bigint]> {
|
|
28
30
|
throw new Error('Method not implemented.')
|
|
29
31
|
}
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
networkStakeStepRewardClaimedByAddress(_address: Address): Promisable<bigint> {
|
|
32
34
|
throw new Error('Method not implemented.')
|
|
33
35
|
}
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
networkStakeStepRewardForPosition(_position: number, _range: [number, number]): Promisable<[bigint, bigint]> {
|
|
38
|
+
throw new Error('Method not implemented.')
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
networkStakeStepRewardForStep(_context: StepIdentity): Promisable<bigint> {
|
|
42
|
+
throw new Error('Method not implemented.')
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
networkStakeStepRewardForStepForPosition(_context: StepIdentity, _position: number): Promisable<[bigint, bigint]> {
|
|
36
46
|
throw new Error('Method not implemented.')
|
|
37
47
|
}
|
|
38
48
|
|
|
39
|
-
|
|
49
|
+
networkStakeStepRewardPoolRewards(_context: StepIdentity): Promisable<Record<Address, bigint>> {
|
|
40
50
|
throw new Error('Method not implemented.')
|
|
41
51
|
}
|
|
42
52
|
|
|
43
|
-
|
|
53
|
+
networkStakeStepRewardPoolShares(_context: StepIdentity): Promisable<Record<Address, bigint>> {
|
|
44
54
|
throw new Error('Method not implemented.')
|
|
45
55
|
}
|
|
46
56
|
|
|
47
|
-
networkStakeStepRewardPositionWeight(
|
|
57
|
+
networkStakeStepRewardPositionWeight(_context: StepIdentity, _position: number): Promisable<bigint> {
|
|
48
58
|
throw new Error('Method not implemented.')
|
|
49
59
|
}
|
|
50
60
|
|
|
51
|
-
networkStakeStepRewardPotentialPositionLoss(
|
|
61
|
+
networkStakeStepRewardPotentialPositionLoss(_context: StepIdentity, _position: number): Promisable<bigint> {
|
|
52
62
|
throw new Error('Method not implemented.')
|
|
53
63
|
}
|
|
54
64
|
|
|
55
|
-
networkStakeStepRewardRandomizer(
|
|
65
|
+
networkStakeStepRewardRandomizer(_context: StepIdentity): Promisable<bigint> {
|
|
56
66
|
throw new Error('Method not implemented.')
|
|
57
67
|
}
|
|
58
68
|
|
|
59
|
-
networkStakeStepRewardStakerCount(
|
|
69
|
+
networkStakeStepRewardStakerCount(_context: StepIdentity): Promisable<number> {
|
|
60
70
|
throw new Error('Method not implemented.')
|
|
61
71
|
}
|
|
62
72
|
|
|
63
|
-
|
|
73
|
+
networkStakeStepRewardUnclaimedByAddress(_address: Address): Promisable<bigint> {
|
|
64
74
|
throw new Error('Method not implemented.')
|
|
65
75
|
}
|
|
66
76
|
|
|
67
|
-
|
|
77
|
+
networkStakeStepRewardWeightForAddress(_context: StepIdentity, _address: Address): Promisable<bigint> {
|
|
68
78
|
throw new Error('Method not implemented.')
|
|
69
79
|
}
|
|
70
80
|
}
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
Payload, PayloadBundle, Sequence, WithStorageMeta,
|
|
14
14
|
} from '@xyo-network/payload-model'
|
|
15
15
|
import {
|
|
16
|
-
asBlockBoundWitnessWithHashStorageMeta,
|
|
16
|
+
asBlockBoundWitnessWithHashStorageMeta, ChainId, isTransactionBoundWitnessWithStorageMeta, PendingTransactionsService,
|
|
17
17
|
SignedHydratedTransactionWithStorageMeta,
|
|
18
18
|
} from '@xyo-network/xl1-protocol'
|
|
19
19
|
import { TransactionJsonSchemaValidator, validateTransaction } from '@xyo-network/xl1-validation'
|
|
@@ -26,7 +26,7 @@ import { hydratedTransactionToPayloadBundle } from './hydratedTransactionToPaylo
|
|
|
26
26
|
|
|
27
27
|
export interface BasePendingTransactionsServiceParams extends BaseServiceParams {
|
|
28
28
|
chainArchivist?: ArchivistInstance
|
|
29
|
-
chainId?:
|
|
29
|
+
chainId?: ChainId
|
|
30
30
|
pendingBundledTransactionsArchivist?: ArchivistInstance
|
|
31
31
|
rejectedTransactionsArchivist?: ArchivistInstance
|
|
32
32
|
}
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
isChainIndexingServiceState,
|
|
26
26
|
StakeIntentService,
|
|
27
27
|
} from '@xyo-network/xl1-protocol'
|
|
28
|
+
import { readPayloadMapFromStore } from '@xyo-network/xl1-protocol-sdk'
|
|
28
29
|
import { Mutex } from 'async-mutex'
|
|
29
30
|
import { LRUCache } from 'lru-cache'
|
|
30
31
|
|
|
@@ -138,7 +139,7 @@ export class XyoStakeIntentService extends BaseService<XyoStakeIntentServicePara
|
|
|
138
139
|
const stake = this._stakeCache.get(candidate)
|
|
139
140
|
if (stake === undefined) {
|
|
140
141
|
// Fetch from chainStakeViewer if not cached
|
|
141
|
-
const activeStake = await chainStakeViewer.
|
|
142
|
+
const activeStake = await chainStakeViewer.activeByStaked(candidate)
|
|
142
143
|
if (activeStake > 0n) {
|
|
143
144
|
// Store result in cache
|
|
144
145
|
this._stakeCache.set(candidate, activeStake, { ttl: ACTIVE_STAKE_TTL })
|
|
@@ -206,7 +207,8 @@ export class XyoStakeIntentService extends BaseService<XyoStakeIntentServicePara
|
|
|
206
207
|
const currentHead = await this.chainIterator.head()
|
|
207
208
|
if (isUndefined(currentHead)) return
|
|
208
209
|
const currentHeadHash = await PayloadBuilder.hash(currentHead)
|
|
209
|
-
const
|
|
210
|
+
const chainMap = readPayloadMapFromStore<WithStorageMeta<Payload>>(this.chainArchivist)
|
|
211
|
+
const result = await analyzeChain({ chainMap }, [new ChainStakeIntentAnalyzer('producer')], currentHeadHash, this._lastIndexedBlockHash)
|
|
210
212
|
const signedDeclarations = filterAs(result.find(isChainSummaryStakeIntent)?.intents ?? [], asChainStakeIntent)
|
|
211
213
|
if (currentHead.block === undefined) return
|
|
212
214
|
const currentHeadBlockNum = currentHead.block
|
|
@@ -3,7 +3,7 @@ import { Address } from '@xylabs/hex'
|
|
|
3
3
|
import { Promisable } from '@xylabs/promise'
|
|
4
4
|
import { ReadArchivist } from '@xyo-network/archivist-model'
|
|
5
5
|
import {
|
|
6
|
-
|
|
6
|
+
StepIdentity,
|
|
7
7
|
StepStakeService,
|
|
8
8
|
} from '@xyo-network/xl1-protocol'
|
|
9
9
|
|
|
@@ -16,11 +16,11 @@ export interface BaseStepStakeServiceParams extends BaseServiceParams {
|
|
|
16
16
|
|
|
17
17
|
@creatable()
|
|
18
18
|
export class BaseStepStakeService extends BaseService<BaseStepStakeServiceParams> implements StepStakeService {
|
|
19
|
-
stepStake(_step:
|
|
19
|
+
stepStake(_step: StepIdentity): Promisable<Record<Address, bigint>> {
|
|
20
20
|
throw new Error('Method not implemented.')
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
stepStakeForAddress(_address: Address, _step:
|
|
23
|
+
stepStakeForAddress(_address: Address, _step: StepIdentity): Promisable<bigint> {
|
|
24
24
|
throw new Error('Method not implemented.')
|
|
25
25
|
}
|
|
26
26
|
}
|