@xyo-network/chain-services 1.15.3 → 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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "http://json.schemastore.org/package.json",
3
3
  "name": "@xyo-network/chain-services",
4
- "version": "1.15.3",
4
+ "version": "1.15.4",
5
5
  "description": "XYO Layer One SDK Services",
6
6
  "homepage": "https://xylabs.com",
7
7
  "bugs": {
@@ -54,17 +54,17 @@
54
54
  "@xyo-network/boundwitness-model": "~5.1.6",
55
55
  "@xyo-network/boundwitness-validator": "~5.1.6",
56
56
  "@xyo-network/boundwitness-wrapper": "~5.1.6",
57
- "@xyo-network/chain-analyze": "~1.15.3",
58
- "@xyo-network/chain-modules": "~1.15.3",
59
- "@xyo-network/chain-protocol": "~1.15.3",
60
- "@xyo-network/chain-utils": "~1.15.3",
57
+ "@xyo-network/chain-analyze": "~1.15.4",
58
+ "@xyo-network/chain-modules": "~1.15.4",
59
+ "@xyo-network/chain-protocol": "~1.15.4",
60
+ "@xyo-network/chain-utils": "~1.15.4",
61
61
  "@xyo-network/payload-builder": "~5.1.6",
62
62
  "@xyo-network/payload-model": "~5.1.6",
63
63
  "@xyo-network/typechain": "~4.0.10",
64
- "@xyo-network/xl1-protocol": "~1.12.66",
65
- "@xyo-network/xl1-protocol-sdk": "~1.15.3",
66
- "@xyo-network/xl1-validation": "~1.15.3",
67
- "@xyo-network/xl1-wrappers": "~1.15.3",
64
+ "@xyo-network/xl1-protocol": "~1.12.69",
65
+ "@xyo-network/xl1-protocol-sdk": "~1.15.4",
66
+ "@xyo-network/xl1-validation": "~1.15.4",
67
+ "@xyo-network/xl1-wrappers": "~1.15.4",
68
68
  "async-mutex": "~0.5.0",
69
69
  "ethers": "6.15.0",
70
70
  "lru-cache": "~11.2.2"
@@ -77,7 +77,7 @@
77
77
  "@xylabs/vitest-extended": "~5.0.12",
78
78
  "@xyo-network/account": "~5.1.6",
79
79
  "@xyo-network/account-model": "~5.1.6",
80
- "@xyo-network/chain-validation": "~1.15.3",
80
+ "@xyo-network/chain-validation": "~1.15.4",
81
81
  "@xyo-network/wallet": "~5.1.6",
82
82
  "eslint": "^9.37.0",
83
83
  "tslib": "~2.8.1",
@@ -2,8 +2,11 @@ import { ZERO_HASH } from '@xylabs/hex'
2
2
  import type { ReadArchivist } from '@xyo-network/archivist-model'
3
3
  import { LruCacheMap } from '@xyo-network/chain-protocol'
4
4
  import type { Payload, WithStorageMeta } from '@xyo-network/payload-model'
5
- import type { AccountBalanceServiceV2, ChainId } from '@xyo-network/xl1-protocol'
5
+ import {
6
+ type AccountBalanceServiceV2, type ChainId, StepSizes,
7
+ } from '@xyo-network/xl1-protocol'
6
8
  import { type BalancesStepSummary, readPayloadMapFromStore } from '@xyo-network/xl1-protocol-sdk'
9
+ import { Semaphore } from 'async-mutex'
7
10
 
8
11
  import { BaseAccountBalanceService } from './BaseAccountBalanceService.ts'
9
12
 
@@ -22,6 +25,7 @@ export const accountBalancesServiceFromArchivist = async (
22
25
  context: {
23
26
  chainId,
24
27
  store: { chainMap },
28
+ stepSemaphores: StepSizes.map(() => new Semaphore(20)),
25
29
  summaryMap,
26
30
  head: () => ZERO_HASH,
27
31
  },
@@ -2,9 +2,12 @@ import { ZERO_HASH } from '@xylabs/hex'
2
2
  import type { ReadArchivist } from '@xyo-network/archivist-model'
3
3
  import { LruCacheMap } from '@xyo-network/chain-protocol'
4
4
  import type { Payload, WithStorageMeta } from '@xyo-network/payload-model'
5
- import type { AccountTransfersService, ChainId } from '@xyo-network/xl1-protocol'
5
+ import {
6
+ type AccountTransfersService, type ChainId, StepSizes,
7
+ } from '@xyo-network/xl1-protocol'
6
8
  import type { TransfersStepSummary } from '@xyo-network/xl1-protocol-sdk'
7
9
  import { readPayloadMapFromStore } from '@xyo-network/xl1-protocol-sdk'
10
+ import { Semaphore } from 'async-mutex'
8
11
 
9
12
  import { BaseAccountTransfersService } from './BaseAccountTransfersService.ts'
10
13
 
@@ -23,6 +26,7 @@ export const accountTransfersServiceFromArchivist = async (
23
26
  context: {
24
27
  chainId,
25
28
  store: { chainMap },
29
+ stepSemaphores: StepSizes.map(() => new Semaphore(20)),
26
30
  summaryMap,
27
31
  head: () => ZERO_HASH,
28
32
  },
@@ -42,16 +42,16 @@ export class EvmChainService extends BaseService<EvmChainServiceParams> implemen
42
42
  return await this.contract.active()
43
43
  }
44
44
 
45
- async activeByAddressStaked(address: string): Promise<bigint> {
46
- return await this.contract.activeByAddressStaked(getAddress(address))
45
+ async activeByStaked(staked: Address): Promise<bigint> {
46
+ return await this.contract.activeByAddressStaked(getAddress(toEthAddress(staked)))
47
47
  }
48
48
 
49
- async activeByStaker(address: string): Promise<bigint> {
50
- return await this.contract.activeByStaker(getAddress(address))
49
+ async activeByStaker(address: Address): Promise<bigint> {
50
+ return await this.contract.activeByStaker(getAddress(toEthAddress(address)))
51
51
  }
52
52
 
53
- async addStake(staked: string, amount: bigint): Promise<boolean> {
54
- const result = await this.contract.addStake(getAddress(staked), amount)
53
+ async addStake(staked: Address, amount: bigint): Promise<boolean> {
54
+ const result = await this.contract.addStake(getAddress(toEthAddress(staked)), amount)
55
55
  await result.wait()
56
56
  return true
57
57
  }
@@ -76,8 +76,8 @@ export class EvmChainService extends BaseService<EvmChainServiceParams> implemen
76
76
  return await this.contract.pending()
77
77
  }
78
78
 
79
- async pendingByStaker(staker: string): Promise<bigint> {
80
- return await this.contract.pendingByStaker(getAddress(staker))
79
+ async pendingByStaker(staker: Address): Promise<bigint> {
80
+ return await this.contract.pendingByStaker(getAddress(toEthAddress(staker)))
81
81
  }
82
82
 
83
83
  async removeStake(slot: bigint): Promise<boolean> {
@@ -21,7 +21,7 @@ export class MemoryChainService extends BaseService<MemoryChainServiceParams> im
21
21
  return await Promise.resolve(this._simulatedStake)
22
22
  }
23
23
 
24
- async activeByAddressStaked(_address: string): Promise<bigint> {
24
+ async activeByStaked(_staked: Address): Promise<bigint> {
25
25
  return await Promise.resolve(this._simulatedStake)
26
26
  }
27
27
 
@@ -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
- EventingChainBlockNumberIteratorService, NetworkStakeStepRewardService, StepContext,
6
+ EventingChainBlockNumberIteratorService, NetworkStakeStepRewardService, StepIdentity,
7
7
  } from '@xyo-network/xl1-protocol'
8
8
  import { Provider } from 'ethers'
9
9
 
@@ -22,11 +22,11 @@ export class BaseNetworkStakeStepRewardService extends BaseService<BaseNetworkSt
22
22
  throw new Error('Method not implemented.')
23
23
  }
24
24
 
25
- networkStakeStepRewardAddressReward(_context: StepContext, _address: Address): Promisable<Record<Address, bigint>> {
25
+ networkStakeStepRewardAddressReward(_context: StepIdentity, _address: Address): Promisable<Record<Address, bigint>> {
26
26
  throw new Error('Method not implemented.')
27
27
  }
28
28
 
29
- networkStakeStepRewardAddressShare(_context: StepContext, _address: Address): Promisable<[bigint, bigint]> {
29
+ networkStakeStepRewardAddressShare(_context: StepIdentity, _address: Address): Promisable<[bigint, bigint]> {
30
30
  throw new Error('Method not implemented.')
31
31
  }
32
32
 
@@ -34,35 +34,39 @@ export class BaseNetworkStakeStepRewardService extends BaseService<BaseNetworkSt
34
34
  throw new Error('Method not implemented.')
35
35
  }
36
36
 
37
- networkStakeStepRewardForStep(_context: StepContext): Promisable<bigint> {
37
+ networkStakeStepRewardForPosition(_position: number, _range: [number, number]): Promisable<[bigint, bigint]> {
38
38
  throw new Error('Method not implemented.')
39
39
  }
40
40
 
41
- networkStakeStepRewardForStepForPosition(_context: StepContext, _position: number): Promisable<[bigint, bigint]> {
41
+ networkStakeStepRewardForStep(_context: StepIdentity): Promisable<bigint> {
42
42
  throw new Error('Method not implemented.')
43
43
  }
44
44
 
45
- networkStakeStepRewardPoolRewards(_context: StepContext): Promisable<Record<Address, bigint>> {
45
+ networkStakeStepRewardForStepForPosition(_context: StepIdentity, _position: number): Promisable<[bigint, bigint]> {
46
46
  throw new Error('Method not implemented.')
47
47
  }
48
48
 
49
- networkStakeStepRewardPoolShares(_context: StepContext): Promisable<Record<Address, bigint>> {
49
+ networkStakeStepRewardPoolRewards(_context: StepIdentity): Promisable<Record<Address, bigint>> {
50
50
  throw new Error('Method not implemented.')
51
51
  }
52
52
 
53
- networkStakeStepRewardPositionWeight(_context: StepContext, _position: number): Promisable<bigint> {
53
+ networkStakeStepRewardPoolShares(_context: StepIdentity): Promisable<Record<Address, bigint>> {
54
54
  throw new Error('Method not implemented.')
55
55
  }
56
56
 
57
- networkStakeStepRewardPotentialPositionLoss(_context: StepContext, _position: number): Promisable<bigint> {
57
+ networkStakeStepRewardPositionWeight(_context: StepIdentity, _position: number): Promisable<bigint> {
58
58
  throw new Error('Method not implemented.')
59
59
  }
60
60
 
61
- networkStakeStepRewardRandomizer(_context: StepContext): Promisable<bigint> {
61
+ networkStakeStepRewardPotentialPositionLoss(_context: StepIdentity, _position: number): Promisable<bigint> {
62
62
  throw new Error('Method not implemented.')
63
63
  }
64
64
 
65
- networkStakeStepRewardStakerCount(_context: StepContext): Promisable<number> {
65
+ networkStakeStepRewardRandomizer(_context: StepIdentity): Promisable<bigint> {
66
+ throw new Error('Method not implemented.')
67
+ }
68
+
69
+ networkStakeStepRewardStakerCount(_context: StepIdentity): Promisable<number> {
66
70
  throw new Error('Method not implemented.')
67
71
  }
68
72
 
@@ -70,7 +74,7 @@ export class BaseNetworkStakeStepRewardService extends BaseService<BaseNetworkSt
70
74
  throw new Error('Method not implemented.')
71
75
  }
72
76
 
73
- networkStakeStepRewardWeightForAddress(_context: StepContext, _address: Address): Promisable<bigint> {
77
+ networkStakeStepRewardWeightForAddress(_context: StepIdentity, _address: Address): Promisable<bigint> {
74
78
  throw new Error('Method not implemented.')
75
79
  }
76
80
  }
@@ -139,7 +139,7 @@ export class XyoStakeIntentService extends BaseService<XyoStakeIntentServicePara
139
139
  const stake = this._stakeCache.get(candidate)
140
140
  if (stake === undefined) {
141
141
  // Fetch from chainStakeViewer if not cached
142
- const activeStake = await chainStakeViewer.activeByAddressStaked(`${candidate}`)
142
+ const activeStake = await chainStakeViewer.activeByStaked(candidate)
143
143
  if (activeStake > 0n) {
144
144
  // Store result in cache
145
145
  this._stakeCache.set(candidate, activeStake, { ttl: ACTIVE_STAKE_TTL })
@@ -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
  }