@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.
Files changed (44) hide show
  1. package/README.md +5302 -2235
  2. package/dist/neutral/AccountBalance/BaseAccountBalanceService.d.ts +3 -5
  3. package/dist/neutral/AccountBalance/BaseAccountBalanceService.d.ts.map +1 -1
  4. package/dist/neutral/AccountBalance/accountBalanceServiceFromArchivist.d.ts +3 -2
  5. package/dist/neutral/AccountBalance/accountBalanceServiceFromArchivist.d.ts.map +1 -1
  6. package/dist/neutral/AccountTransfers/BaseAccountTransfersService.d.ts +3 -6
  7. package/dist/neutral/AccountTransfers/BaseAccountTransfersService.d.ts.map +1 -1
  8. package/dist/neutral/AccountTransfers/accountTransfersServiceFromArchivist.d.ts +3 -3
  9. package/dist/neutral/AccountTransfers/accountTransfersServiceFromArchivist.d.ts.map +1 -1
  10. package/dist/neutral/BlockProducer/spec/BaseBlockProducerService.spec.d.ts.map +1 -1
  11. package/dist/neutral/ChainBlockNumberIteration/ChainBlockNumberIterationService.d.ts +3 -3
  12. package/dist/neutral/ChainBlockNumberIteration/ChainBlockNumberIterationService.d.ts.map +1 -1
  13. package/dist/neutral/ChainBlockNumberIteration/model/Params.d.ts +3 -2
  14. package/dist/neutral/ChainBlockNumberIteration/model/Params.d.ts.map +1 -1
  15. package/dist/neutral/ChainService/Evm/Evm.d.ts +4 -4
  16. package/dist/neutral/ChainService/Evm/Evm.d.ts.map +1 -1
  17. package/dist/neutral/ChainService/Memory/Memory.d.ts +1 -1
  18. package/dist/neutral/ChainService/Memory/Memory.d.ts.map +1 -1
  19. package/dist/neutral/ChainValidator/XyoValidator.d.ts +2 -2
  20. package/dist/neutral/ChainValidator/XyoValidator.d.ts.map +1 -1
  21. package/dist/neutral/NetworkStakeStepReward/BaseNetworkStakeStepRewardService.d.ts +15 -13
  22. package/dist/neutral/NetworkStakeStepReward/BaseNetworkStakeStepRewardService.d.ts.map +1 -1
  23. package/dist/neutral/PendingTransactions/BasePendingTransactions.d.ts +2 -2
  24. package/dist/neutral/PendingTransactions/BasePendingTransactions.d.ts.map +1 -1
  25. package/dist/neutral/StakeIntent/XyoStakeIntentService.d.ts.map +1 -1
  26. package/dist/neutral/StepStake/BaseStepStakeService.d.ts +3 -3
  27. package/dist/neutral/StepStake/BaseStepStakeService.d.ts.map +1 -1
  28. package/dist/neutral/index.mjs +118 -151
  29. package/dist/neutral/index.mjs.map +1 -1
  30. package/package.json +40 -40
  31. package/src/AccountBalance/BaseAccountBalanceService.ts +6 -8
  32. package/src/AccountBalance/accountBalanceServiceFromArchivist.ts +22 -33
  33. package/src/AccountTransfers/BaseAccountTransfersService.ts +4 -12
  34. package/src/AccountTransfers/accountTransfersServiceFromArchivist.ts +22 -35
  35. package/src/BlockProducer/spec/BaseBlockProducerService.spec.ts +62 -8
  36. package/src/ChainBlockNumberIteration/ChainBlockNumberIterationService.ts +11 -11
  37. package/src/ChainBlockNumberIteration/model/Params.ts +3 -2
  38. package/src/ChainService/Evm/Evm.ts +8 -8
  39. package/src/ChainService/Memory/Memory.ts +1 -1
  40. package/src/ChainValidator/XyoValidator.ts +2 -2
  41. package/src/NetworkStakeStepReward/BaseNetworkStakeStepRewardService.ts +24 -14
  42. package/src/PendingTransactions/BasePendingTransactions.ts +2 -2
  43. package/src/StakeIntent/XyoStakeIntentService.ts +4 -2
  44. 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 { EventingChainBlockNumberIteratorService, NetworkStakeStepRewardService } from '@xyo-network/xl1-protocol'
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
- claimedRewards(_address: Address): Promisable<bigint> {
21
+ networkStakeStepRewardAddressHistory(_address: Address): Promisable<Record<Address, bigint>> {
20
22
  throw new Error('Method not implemented.')
21
23
  }
22
24
 
23
- networkStakeStepAddressReward(_address: Address, _step: number, _block: number): Promisable<Record<Address, bigint>> {
25
+ networkStakeStepRewardAddressReward(_context: StepIdentity, _address: Address): Promisable<Record<Address, bigint>> {
24
26
  throw new Error('Method not implemented.')
25
27
  }
26
28
 
27
- networkStakeStepPoolRewardShares(_step: number, _block: number): Promisable<Record<Address, bigint>> {
29
+ networkStakeStepRewardAddressShare(_context: StepIdentity, _address: Address): Promisable<[bigint, bigint]> {
28
30
  throw new Error('Method not implemented.')
29
31
  }
30
32
 
31
- networkStakeStepPoolRewards(_step: number, _block: number): Promisable<Record<Address, bigint>> {
33
+ networkStakeStepRewardClaimedByAddress(_address: Address): Promisable<bigint> {
32
34
  throw new Error('Method not implemented.')
33
35
  }
34
36
 
35
- networkStakeStepRewardAddressHistory(_address: Address): Promisable<Record<Address, bigint>> {
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
- networkStakeStepRewardAddressShare(_address: Address, _step: number, _block: number): Promisable<[bigint, bigint]> {
49
+ networkStakeStepRewardPoolRewards(_context: StepIdentity): Promisable<Record<Address, bigint>> {
40
50
  throw new Error('Method not implemented.')
41
51
  }
42
52
 
43
- networkStakeStepRewardForStep(_step: number): Promisable<bigint> {
53
+ networkStakeStepRewardPoolShares(_context: StepIdentity): Promisable<Record<Address, bigint>> {
44
54
  throw new Error('Method not implemented.')
45
55
  }
46
56
 
47
- networkStakeStepRewardPositionWeight(_position: bigint, _step: number): Promisable<number> {
57
+ networkStakeStepRewardPositionWeight(_context: StepIdentity, _position: number): Promisable<bigint> {
48
58
  throw new Error('Method not implemented.')
49
59
  }
50
60
 
51
- networkStakeStepRewardPotentialPositionLoss(_position: bigint, _step: number): Promisable<bigint> {
61
+ networkStakeStepRewardPotentialPositionLoss(_context: StepIdentity, _position: number): Promisable<bigint> {
52
62
  throw new Error('Method not implemented.')
53
63
  }
54
64
 
55
- networkStakeStepRewardRandomizer(_step: number, _block: number): Promisable<bigint> {
65
+ networkStakeStepRewardRandomizer(_context: StepIdentity): Promisable<bigint> {
56
66
  throw new Error('Method not implemented.')
57
67
  }
58
68
 
59
- networkStakeStepRewardStakerCount(_step: number, _block: number): Promisable<number> {
69
+ networkStakeStepRewardStakerCount(_context: StepIdentity): Promisable<number> {
60
70
  throw new Error('Method not implemented.')
61
71
  }
62
72
 
63
- networkStakeStepRewardWeightForAddress(_address: Address, _step: number): Promisable<bigint> {
73
+ networkStakeStepRewardUnclaimedByAddress(_address: Address): Promisable<bigint> {
64
74
  throw new Error('Method not implemented.')
65
75
  }
66
76
 
67
- unclaimedRewards(_address: Address): Promisable<bigint> {
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, Chain, isTransactionBoundWitnessWithStorageMeta, PendingTransactionsService,
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?: Chain
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.activeByAddressStaked(`${candidate}`)
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 result = await analyzeChain(this.chainArchivist, [new ChainStakeIntentAnalyzer('producer')], currentHeadHash, this._lastIndexedBlockHash)
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
- CompletedStep,
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: CompletedStep): Promisable<Record<Address, bigint>> {
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: CompletedStep): Promisable<bigint> {
23
+ stepStakeForAddress(_address: Address, _step: StepIdentity): Promisable<bigint> {
24
24
  throw new Error('Method not implemented.')
25
25
  }
26
26
  }