@xyo-network/chain-services 1.17.0 → 1.17.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/AccountBalance/accountBalanceServiceFromArchivist.d.ts +1 -1
- package/dist/neutral/AccountBalance/accountBalanceServiceFromArchivist.d.ts.map +1 -1
- package/dist/neutral/AccountBalance/index.d.ts +0 -1
- package/dist/neutral/AccountBalance/index.d.ts.map +1 -1
- package/dist/neutral/BaseService.d.ts +0 -3
- package/dist/neutral/BaseService.d.ts.map +1 -1
- package/dist/neutral/BlockReward/EvmBlockRewardViewer.d.ts +17 -0
- package/dist/neutral/BlockReward/EvmBlockRewardViewer.d.ts.map +1 -0
- package/dist/neutral/BlockReward/index.d.ts +1 -3
- package/dist/neutral/BlockReward/index.d.ts.map +1 -1
- package/dist/neutral/ChainBlockNumberIteration/ChainBlockNumberIterationService.d.ts +4 -2
- package/dist/neutral/ChainBlockNumberIteration/ChainBlockNumberIterationService.d.ts.map +1 -1
- package/dist/neutral/ChainService/Evm/Evm.d.ts +2 -1
- package/dist/neutral/ChainService/Evm/Evm.d.ts.map +1 -1
- package/dist/neutral/ChainService/Memory/Memory.d.ts +2 -0
- package/dist/neutral/ChainService/Memory/Memory.d.ts.map +1 -1
- package/dist/neutral/ChainValidator/XyoValidator.d.ts +2 -16
- package/dist/neutral/ChainValidator/XyoValidator.d.ts.map +1 -1
- package/dist/neutral/PendingTransactions/BasePendingTransactions.d.ts +7 -6
- package/dist/neutral/PendingTransactions/BasePendingTransactions.d.ts.map +1 -1
- package/dist/neutral/StakeIntent/XyoStakeIntentService.d.ts +5 -4
- package/dist/neutral/StakeIntent/XyoStakeIntentService.d.ts.map +1 -1
- package/dist/neutral/blockViewerFromChainIteratorAndArchivist.d.ts.map +1 -1
- package/dist/neutral/implementation/accountBalance.d.ts +7 -0
- package/dist/neutral/implementation/accountBalance.d.ts.map +1 -0
- package/dist/neutral/implementation/blockViewer.d.ts +7 -0
- package/dist/neutral/implementation/blockViewer.d.ts.map +1 -0
- package/dist/neutral/implementation/chain/evm.d.ts +7 -0
- package/dist/neutral/implementation/chain/evm.d.ts.map +1 -0
- package/dist/neutral/implementation/chain/index.d.ts +7 -0
- package/dist/neutral/implementation/chain/index.d.ts.map +1 -0
- package/dist/neutral/implementation/evm/index.d.ts +2 -0
- package/dist/neutral/implementation/evm/index.d.ts.map +1 -0
- package/dist/neutral/implementation/evm/initChainId.d.ts +4 -0
- package/dist/neutral/implementation/evm/initChainId.d.ts.map +1 -0
- package/dist/neutral/implementation/evm/initEvmProvider.d.ts +11 -0
- package/dist/neutral/implementation/evm/initEvmProvider.d.ts.map +1 -0
- package/dist/neutral/implementation/evm/initInfuraProvider.d.ts +6 -0
- package/dist/neutral/implementation/evm/initInfuraProvider.d.ts.map +1 -0
- package/dist/neutral/implementation/evm/initJsonRpcProvider.d.ts +6 -0
- package/dist/neutral/implementation/evm/initJsonRpcProvider.d.ts.map +1 -0
- package/dist/neutral/implementation/head/createBootstrapHead.d.ts +5 -0
- package/dist/neutral/implementation/head/createBootstrapHead.d.ts.map +1 -0
- package/dist/neutral/implementation/head/createForkedHead/config/getBridgeDestinationDetails.d.ts +8 -0
- package/dist/neutral/implementation/head/createForkedHead/config/getBridgeDestinationDetails.d.ts.map +1 -0
- package/dist/neutral/implementation/head/createForkedHead/config/getBridgeSourceDetails.d.ts +9 -0
- package/dist/neutral/implementation/head/createForkedHead/config/getBridgeSourceDetails.d.ts.map +1 -0
- package/dist/neutral/implementation/head/createForkedHead/config/getForkDetails.d.ts +4 -0
- package/dist/neutral/implementation/head/createForkedHead/config/getForkDetails.d.ts.map +1 -0
- package/dist/neutral/implementation/head/createForkedHead/config/index.d.ts +4 -0
- package/dist/neutral/implementation/head/createForkedHead/config/index.d.ts.map +1 -0
- package/dist/neutral/implementation/head/createForkedHead/createForkedHead.d.ts +5 -0
- package/dist/neutral/implementation/head/createForkedHead/createForkedHead.d.ts.map +1 -0
- package/dist/neutral/implementation/head/createForkedHead/getBridgeDestinationObservation.d.ts +11 -0
- package/dist/neutral/implementation/head/createForkedHead/getBridgeDestinationObservation.d.ts.map +1 -0
- package/dist/neutral/implementation/head/createForkedHead/getBridgeIntent.d.ts +11 -0
- package/dist/neutral/implementation/head/createForkedHead/getBridgeIntent.d.ts.map +1 -0
- package/dist/neutral/implementation/head/createForkedHead/getBridgeSourceObservation.d.ts +11 -0
- package/dist/neutral/implementation/head/createForkedHead/getBridgeSourceObservation.d.ts.map +1 -0
- package/dist/neutral/implementation/head/createForkedHead/getFirstBlockForNewChain.d.ts +13 -0
- package/dist/neutral/implementation/head/createForkedHead/getFirstBlockForNewChain.d.ts.map +1 -0
- package/dist/neutral/implementation/head/createForkedHead/index.d.ts +2 -0
- package/dist/neutral/implementation/head/createForkedHead/index.d.ts.map +1 -0
- package/dist/neutral/implementation/head/getForkFromBlock.d.ts +12 -0
- package/dist/neutral/implementation/head/getForkFromBlock.d.ts.map +1 -0
- package/dist/neutral/implementation/head/head.d.ts +11 -0
- package/dist/neutral/implementation/head/head.d.ts.map +1 -0
- package/dist/neutral/implementation/head/index.d.ts +2 -0
- package/dist/neutral/implementation/head/index.d.ts.map +1 -0
- package/dist/neutral/implementation/head/submitNewChain.d.ts +10 -0
- package/dist/neutral/implementation/head/submitNewChain.d.ts.map +1 -0
- package/dist/neutral/implementation/index.d.ts +13 -0
- package/dist/neutral/implementation/index.d.ts.map +1 -0
- package/dist/neutral/implementation/mempoolRunner.d.ts +7 -0
- package/dist/neutral/implementation/mempoolRunner.d.ts.map +1 -0
- package/dist/neutral/implementation/mempoolViewer.d.ts +7 -0
- package/dist/neutral/implementation/mempoolViewer.d.ts.map +1 -0
- package/dist/neutral/implementation/pendingTransactions.d.ts +9 -0
- package/dist/neutral/implementation/pendingTransactions.d.ts.map +1 -0
- package/dist/neutral/implementation/producer.d.ts +5 -0
- package/dist/neutral/implementation/producer.d.ts.map +1 -0
- package/dist/neutral/implementation/reward.d.ts +14 -0
- package/dist/neutral/implementation/reward.d.ts.map +1 -0
- package/dist/neutral/implementation/time.d.ts +6 -0
- package/dist/neutral/implementation/time.d.ts.map +1 -0
- package/dist/neutral/implementation/validator.d.ts +5 -0
- package/dist/neutral/implementation/validator.d.ts.map +1 -0
- package/dist/neutral/index.d.ts +2 -2
- package/dist/neutral/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +1565 -1140
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/simple/block/index.d.ts +2 -0
- package/dist/neutral/simple/block/index.d.ts.map +1 -0
- package/dist/neutral/simple/block/runner/SimpleBlockRunner.d.ts +117 -0
- package/dist/neutral/simple/block/runner/SimpleBlockRunner.d.ts.map +1 -0
- package/dist/neutral/simple/block/runner/generateTransactionFeeTransfers.d.ts.map +1 -0
- package/dist/neutral/simple/block/runner/index.d.ts +2 -0
- package/dist/neutral/simple/block/runner/index.d.ts.map +1 -0
- package/dist/neutral/simple/block/runner/spec/SimpleBlockRewardViewer.d.ts +2 -0
- package/dist/neutral/simple/block/runner/spec/SimpleBlockRewardViewer.d.ts.map +1 -0
- package/dist/neutral/simple/index.d.ts +2 -0
- package/dist/neutral/simple/index.d.ts.map +1 -0
- package/package.json +30 -27
- package/src/AccountBalance/accountBalanceServiceFromArchivist.ts +35 -8
- package/src/AccountBalance/index.ts +0 -1
- package/src/BaseService.ts +0 -13
- package/src/BlockReward/EvmBlockRewardViewer.ts +50 -0
- package/src/BlockReward/index.ts +1 -3
- package/src/ChainBlockNumberIteration/ChainBlockNumberIterationService.ts +14 -2
- package/src/ChainService/Evm/Evm.ts +5 -4
- package/src/ChainService/Memory/Memory.ts +5 -0
- package/src/ChainValidator/XyoValidator.ts +25 -30
- package/src/NetworkStakeStepReward/BaseNetworkStakeStepRewardService.ts +18 -18
- package/src/PendingTransactions/BasePendingTransactions.ts +10 -5
- package/src/Schemas/BaseSchemasService.ts +1 -1
- package/src/StakeIntent/XyoStakeIntentService.ts +18 -8
- package/src/StepStake/BaseStepStakeService.ts +2 -2
- package/src/blockViewerFromChainIteratorAndArchivist.ts +8 -1
- package/src/implementation/accountBalance.ts +29 -0
- package/src/implementation/blockViewer.ts +29 -0
- package/src/implementation/chain/evm.ts +39 -0
- package/src/implementation/chain/index.ts +46 -0
- package/src/implementation/evm/index.ts +1 -0
- package/src/implementation/evm/initChainId.ts +20 -0
- package/src/implementation/evm/initEvmProvider.ts +24 -0
- package/src/implementation/evm/initInfuraProvider.ts +26 -0
- package/src/implementation/evm/initJsonRpcProvider.ts +20 -0
- package/src/implementation/head/createBootstrapHead.ts +31 -0
- package/src/implementation/head/createForkedHead/config/getBridgeDestinationDetails.ts +27 -0
- package/src/implementation/head/createForkedHead/config/getBridgeSourceDetails.ts +19 -0
- package/src/implementation/head/createForkedHead/config/getForkDetails.ts +10 -0
- package/src/implementation/head/createForkedHead/config/index.ts +3 -0
- package/src/implementation/head/createForkedHead/createForkedHead.ts +29 -0
- package/src/implementation/head/createForkedHead/getBridgeDestinationObservation.ts +42 -0
- package/src/implementation/head/createForkedHead/getBridgeIntent.ts +51 -0
- package/src/implementation/head/createForkedHead/getBridgeSourceObservation.ts +46 -0
- package/src/implementation/head/createForkedHead/getFirstBlockForNewChain.ts +41 -0
- package/src/implementation/head/createForkedHead/index.ts +1 -0
- package/src/implementation/head/getForkFromBlock.ts +43 -0
- package/src/implementation/head/head.ts +49 -0
- package/src/implementation/head/index.ts +1 -0
- package/src/implementation/head/submitNewChain.ts +27 -0
- package/src/implementation/index.ts +12 -0
- package/src/implementation/mempoolRunner.ts +29 -0
- package/src/implementation/mempoolViewer.ts +29 -0
- package/src/implementation/pendingTransactions.ts +36 -0
- package/src/implementation/producer.ts +16 -0
- package/src/implementation/reward.ts +53 -0
- package/src/implementation/time.ts +26 -0
- package/src/implementation/validator.ts +15 -0
- package/src/index.ts +2 -2
- package/src/simple/block/index.ts +1 -0
- package/src/{BlockProducer/BaseBlockProducerService.ts → simple/block/runner/SimpleBlockRunner.ts} +111 -74
- package/src/simple/block/runner/index.ts +1 -0
- package/src/simple/block/runner/spec/SimpleBlockRewardViewer.ts +413 -0
- package/src/simple/index.ts +1 -0
- package/dist/neutral/AccountBalance/BaseAccountBalanceService.d.ts +0 -35
- package/dist/neutral/AccountBalance/BaseAccountBalanceService.d.ts.map +0 -1
- package/dist/neutral/AccountTransfers/BaseAccountTransfersService.d.ts +0 -13
- package/dist/neutral/AccountTransfers/BaseAccountTransfersService.d.ts.map +0 -1
- package/dist/neutral/AccountTransfers/index.d.ts +0 -2
- package/dist/neutral/AccountTransfers/index.d.ts.map +0 -1
- package/dist/neutral/BlockProducer/BaseBlockProducerService.d.ts +0 -85
- package/dist/neutral/BlockProducer/BaseBlockProducerService.d.ts.map +0 -1
- package/dist/neutral/BlockProducer/generateTransactionFeeTransfers.d.ts.map +0 -1
- package/dist/neutral/BlockProducer/index.d.ts +0 -2
- package/dist/neutral/BlockProducer/index.d.ts.map +0 -1
- package/dist/neutral/BlockReward/BaseBlockRewardService.d.ts +0 -10
- package/dist/neutral/BlockReward/BaseBlockRewardService.d.ts.map +0 -1
- package/dist/neutral/BlockReward/EvmBlockRewardService.d.ts +0 -18
- package/dist/neutral/BlockReward/EvmBlockRewardService.d.ts.map +0 -1
- package/dist/neutral/BlockReward/MemoryBlockRewardService.d.ts +0 -23
- package/dist/neutral/BlockReward/MemoryBlockRewardService.d.ts.map +0 -1
- package/src/AccountBalance/BaseAccountBalanceService.ts +0 -98
- package/src/AccountTransfers/BaseAccountTransfersService.ts +0 -36
- package/src/AccountTransfers/index.ts +0 -1
- package/src/BlockProducer/index.ts +0 -1
- package/src/BlockReward/BaseBlockRewardService.ts +0 -17
- package/src/BlockReward/EvmBlockRewardService.ts +0 -49
- package/src/BlockReward/MemoryBlockRewardService.ts +0 -72
- /package/dist/neutral/{BlockProducer → simple/block/runner}/generateTransactionFeeTransfers.d.ts +0 -0
- /package/src/{BlockProducer → simple/block/runner}/generateTransactionFeeTransfers.ts +0 -0
|
@@ -21,74 +21,74 @@ export interface BaseNetworkStakeStepRewardServiceParams extends BaseServicePara
|
|
|
21
21
|
@creatable()
|
|
22
22
|
export class BaseNetworkStakeStepRewardService extends BaseService<BaseNetworkStakeStepRewardServiceParams> implements NetworkStakeStepRewardService {
|
|
23
23
|
networkStakeStepRewardAddressHistory(_address: Address): Promisable<Record<Address, bigint>> {
|
|
24
|
-
throw new Error('Method not implemented.')
|
|
24
|
+
throw new Error('Method [networkStakeStepRewardAddressHistory] not implemented.')
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
networkStakeStepRewardAddressReward(_context: StepIdentity, _address: Address): Promisable<Record<Address, bigint>> {
|
|
28
|
-
throw new Error('Method not implemented.')
|
|
28
|
+
throw new Error('Method [networkStakeStepRewardAddressReward] not implemented.')
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
networkStakeStepRewardAddressShare(_context: StepIdentity, _address: Address): Promisable<[bigint, bigint]> {
|
|
32
|
-
throw new Error('Method not implemented.')
|
|
32
|
+
throw new Error('Method [networkStakeStepRewardAddressShare] not implemented.')
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
networkStakeStepRewardClaimedByAddress(_address: Address): Promisable<bigint> {
|
|
36
|
-
throw new Error('Method not implemented.')
|
|
36
|
+
throw new Error('Method [networkStakeStepRewardClaimedByAddress] not implemented.')
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
networkStakeStepRewardForPosition(_position: number, _range: [number, number]): Promisable<[bigint, bigint]> {
|
|
40
|
-
throw new Error('Method not implemented.')
|
|
40
|
+
throw new Error('Method [networkStakeStepRewardForPosition] not implemented.')
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
networkStakeStepRewardForStep(_context: StepIdentity): Promisable<bigint> {
|
|
44
|
-
throw new Error('Method not implemented.')
|
|
44
|
+
throw new Error('Method [networkStakeStepRewardForStep] not implemented.')
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
networkStakeStepRewardForStepForPosition(_context: StepIdentity, _position: number): Promisable<[bigint, bigint]> {
|
|
48
|
-
throw new Error('Method not implemented.')
|
|
48
|
+
throw new Error('Method [networkStakeStepRewardForStepForPosition] not implemented.')
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
networkStakeStepRewardPoolRewards(_context: StepIdentity): Promisable<Record<Address, bigint>> {
|
|
52
|
-
throw new Error('Method not implemented.')
|
|
52
|
+
throw new Error('Method [networkStakeStepRewardPoolRewards] not implemented.')
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
networkStakeStepRewardPoolShares(_context: StepIdentity): Promisable<Record<Address, bigint>> {
|
|
56
|
-
throw new Error('Method not implemented.')
|
|
56
|
+
throw new Error('Method [networkStakeStepRewardPoolShares] not implemented.')
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
networkStakeStepRewardPositionWeight(_context: StepIdentity, _position: number): Promisable<bigint> {
|
|
60
|
-
throw new Error('Method not implemented.')
|
|
60
|
+
throw new Error('Method [networkStakeStepRewardPositionWeight] not implemented.')
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
networkStakeStepRewardPotentialPositionLoss(_context: StepIdentity, _position: number): Promisable<bigint> {
|
|
64
|
-
throw new Error('Method not implemented.')
|
|
64
|
+
throw new Error('Method [networkStakeStepRewardPotentialPositionLoss] not implemented.')
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
networkStakeStepRewardRandomizer(_context: StepIdentity): Promisable<bigint> {
|
|
68
|
-
throw new Error('Method not implemented.')
|
|
68
|
+
throw new Error('Method [networkStakeStepRewardRandomizer] not implemented.')
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
networkStakeStepRewardStakerCount(_context: StepIdentity): Promisable<number> {
|
|
72
|
-
throw new Error('Method not implemented.')
|
|
72
|
+
throw new Error('Method [networkStakeStepRewardStakerCount] not implemented.')
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
networkStakeStepRewardUnclaimedByAddress(_address: Address): Promisable<bigint> {
|
|
76
|
-
throw new Error('Method not implemented.')
|
|
76
|
+
throw new Error('Method [networkStakeStepRewardUnclaimedByAddress] not implemented.')
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
networkStakeStepRewardWeightForAddress(_context: StepIdentity, _address: Address): Promisable<bigint> {
|
|
80
|
-
throw new Error('Method not implemented.')
|
|
80
|
+
throw new Error('Method [networkStakeStepRewardWeightForAddress] not implemented.')
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
networkStakeStepRewardsForPosition(_position: number, _range: [number, number]): Promisable<Record<StepIdentityString, [bigint, bigint]>> {
|
|
84
|
-
throw new Error('Method not implemented.')
|
|
84
|
+
throw new Error('Method [networkStakeStepRewardsForPosition] not implemented.')
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
networkStakeStepRewardsForRange(_range: [number, number]): Promisable<bigint> {
|
|
88
|
-
throw new Error('Method not implemented.')
|
|
88
|
+
throw new Error('Method [networkStakeStepRewardsForRange] not implemented.')
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
networkStakeStepRewardsForStepLevel(_stepLevel: number, _range: [number, number]): Promisable<bigint> {
|
|
92
|
-
throw new Error('Method not implemented.')
|
|
92
|
+
throw new Error('Method [networkStakeStepRewardsForStepLevel] not implemented.')
|
|
93
93
|
}
|
|
94
94
|
}
|
|
@@ -12,12 +12,13 @@ import {
|
|
|
12
12
|
} from '@xyo-network/payload-model'
|
|
13
13
|
import {
|
|
14
14
|
asBlockBoundWitnessWithHashMeta, asXL1BlockNumber, ChainId, HydratedTransactionValidationFunction, isTransactionBoundWitnessWithStorageMeta,
|
|
15
|
+
SignedHydratedBlockWithHashMeta,
|
|
15
16
|
SignedHydratedTransactionWithHashMeta,
|
|
16
17
|
SignedHydratedTransactionWithStorageMeta,
|
|
17
18
|
XL1BlockNumber,
|
|
18
19
|
} from '@xyo-network/xl1-protocol'
|
|
19
20
|
import {
|
|
20
|
-
findMostRecentBlock, MempoolViewer, PendingTransactionsOptions,
|
|
21
|
+
findMostRecentBlock, MempoolViewer, PendingBlocksOptions, PendingTransactionsOptions,
|
|
21
22
|
} from '@xyo-network/xl1-protocol-sdk'
|
|
22
23
|
import { TransactionJsonSchemaValidator, validateTransaction } from '@xyo-network/xl1-validation'
|
|
23
24
|
import { Mutex } from 'async-mutex'
|
|
@@ -29,10 +30,10 @@ import { hydratedTransactionToPayloadBundle } from './hydratedTransactionToPaylo
|
|
|
29
30
|
|
|
30
31
|
export interface BasePendingTransactionsServiceParams extends BaseServiceParams {
|
|
31
32
|
additionalPendingTransactionValidators?: HydratedTransactionValidationFunction[]
|
|
32
|
-
chainArchivist
|
|
33
|
-
chainId
|
|
34
|
-
pendingBundledTransactionsArchivist
|
|
35
|
-
rejectedTransactionsArchivist
|
|
33
|
+
chainArchivist: ArchivistInstance
|
|
34
|
+
chainId: ChainId
|
|
35
|
+
pendingBundledTransactionsArchivist: ArchivistInstance
|
|
36
|
+
rejectedTransactionsArchivist: ArchivistInstance
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
@creatable()
|
|
@@ -143,6 +144,10 @@ export class BasePendingTransactionsService extends BaseService<BasePendingTrans
|
|
|
143
144
|
})
|
|
144
145
|
}
|
|
145
146
|
|
|
147
|
+
pendingBlocks(_options?: PendingBlocksOptions): Promise<SignedHydratedBlockWithHashMeta[]> {
|
|
148
|
+
throw new Error('Method [pendingBlocks] not implemented.')
|
|
149
|
+
}
|
|
150
|
+
|
|
146
151
|
async pendingTransactions({ limit = 100 }: PendingTransactionsOptions = {}): Promise<SignedHydratedTransactionWithStorageMeta[]> {
|
|
147
152
|
return await this.spanAsync('getPendingTransactions', async () => {
|
|
148
153
|
// Acquires an exclusive mutex to ensure no race conditions while accessing pending transactions.
|
|
@@ -22,7 +22,7 @@ export class BaseSchemasService extends BaseService<BaseSchemasServiceParams> im
|
|
|
22
22
|
|
|
23
23
|
async schemas(head: Hash, schemas: Schema[]): Promise<Partial<Record<Schema, number>>> {
|
|
24
24
|
return await spanRootAsync('transfers', async () => {
|
|
25
|
-
const summary = await schemasSummary(this.params.context)
|
|
25
|
+
const [summary] = await schemasSummary(this.params.context)
|
|
26
26
|
const result: Record<Schema, number> = {}
|
|
27
27
|
for (const schema of schemas) {
|
|
28
28
|
const count = summary[schema] ?? 0
|
|
@@ -34,10 +34,10 @@ import { BaseService } from '../BaseService.ts'
|
|
|
34
34
|
import { BaseServiceParams } from '../model/index.ts'
|
|
35
35
|
|
|
36
36
|
export interface XyoStakeIntentServiceParams extends BaseServiceParams<Pick<Config, 'producer'>> {
|
|
37
|
-
blockViewer
|
|
38
|
-
chainArchivist
|
|
39
|
-
chainStakeViewer
|
|
40
|
-
stakeIntentStateArchivist
|
|
37
|
+
blockViewer: BlockViewer
|
|
38
|
+
chainArchivist: ArchivistInstance
|
|
39
|
+
chainStakeViewer: ChainStakeViewer
|
|
40
|
+
stakeIntentStateArchivist: ArchivistInstance
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
@@ -66,19 +66,29 @@ export class XyoStakeIntentService extends BaseService<XyoStakeIntentServicePara
|
|
|
66
66
|
protected _updateMutex = new Mutex()
|
|
67
67
|
|
|
68
68
|
protected get blockViewer() {
|
|
69
|
-
return
|
|
69
|
+
return this.params.blockViewer
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
protected get chainArchivist() {
|
|
73
|
-
return assertEx(this.params.chainArchivist
|
|
73
|
+
return assertEx(this.params.chainArchivist!, () => 'chainArchivist not set')
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
protected get chainStakeViewer() {
|
|
77
|
-
return assertEx(this.params.chainStakeViewer
|
|
77
|
+
return assertEx(this.params.chainStakeViewer!, () => 'chainStakeViewer not set')
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
protected get stakeIntentStateArchivist() {
|
|
81
|
-
return assertEx(this.params.stakeIntentStateArchivist
|
|
81
|
+
return assertEx(this.params.stakeIntentStateArchivist!, () => 'stakeIntentStateArchivist not set')
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
static override async paramsHandler(params?: Partial<XyoStakeIntentServiceParams>): Promise<XyoStakeIntentServiceParams> {
|
|
85
|
+
return {
|
|
86
|
+
...await super.paramsHandler(params),
|
|
87
|
+
blockViewer: assertEx(params?.blockViewer, () => 'blockViewer is required'),
|
|
88
|
+
chainArchivist: assertEx(params?.chainArchivist, () => 'chainArchivist is required'),
|
|
89
|
+
chainStakeViewer: assertEx(params?.chainStakeViewer, () => 'chainStakeViewer is required'),
|
|
90
|
+
stakeIntentStateArchivist: assertEx(params?.stakeIntentStateArchivist, () => 'stakeIntentStateArchivist is required'),
|
|
91
|
+
} as XyoStakeIntentServiceParams
|
|
82
92
|
}
|
|
83
93
|
|
|
84
94
|
override async createHandler() {
|
|
@@ -15,10 +15,10 @@ export interface BaseStepStakeServiceParams extends BaseServiceParams {
|
|
|
15
15
|
@creatable()
|
|
16
16
|
export class BaseStepStakeService extends BaseService<BaseStepStakeServiceParams> implements StepStakeViewer {
|
|
17
17
|
stepStake(_step: StepIdentity): Promisable<Record<Address, bigint>> {
|
|
18
|
-
throw new Error('Method not implemented.')
|
|
18
|
+
throw new Error('Method [stepStake] not implemented.')
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
stepStakeForAddress(_address: Address, _step: StepIdentity): Promisable<bigint> {
|
|
22
|
-
throw new Error('Method not implemented.')
|
|
22
|
+
throw new Error('Method [stepStakeForAddress] not implemented.')
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { Hash } from '@xylabs/sdk-js'
|
|
1
|
+
import type { Hash, Promisable } from '@xylabs/sdk-js'
|
|
2
2
|
import { isDefined } from '@xylabs/sdk-js'
|
|
3
3
|
import type { ReadArchivist } from '@xyo-network/archivist-model'
|
|
4
4
|
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
5
|
+
import type { Payload, WithHashMeta } from '@xyo-network/payload-model'
|
|
5
6
|
import type {
|
|
6
7
|
SignedHydratedBlockWithHashMeta,
|
|
7
8
|
XL1BlockNumber,
|
|
@@ -68,6 +69,12 @@ export function blockViewerFromChainIteratorAndArchivist(
|
|
|
68
69
|
const head = await chainIterator.head()
|
|
69
70
|
return head.block
|
|
70
71
|
},
|
|
72
|
+
payloadByHash: function (_hash: Hash): Promisable<WithHashMeta<Payload> | null> {
|
|
73
|
+
throw new Error('Function not implemented.')
|
|
74
|
+
},
|
|
75
|
+
payloadsByHash: function (_hashes: Hash[]): Promisable<WithHashMeta<Payload>[]> {
|
|
76
|
+
throw new Error('Function not implemented.')
|
|
77
|
+
},
|
|
71
78
|
} satisfies BlockViewer
|
|
72
79
|
return result
|
|
73
80
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { isDefined, type Promisable } from '@xylabs/sdk-js'
|
|
2
|
+
import type { Initializable, InitializableParams } from '@xyo-network/xl1-protocol'
|
|
3
|
+
import type { AccountBalanceViewer, Config } from '@xyo-network/xl1-protocol-sdk'
|
|
4
|
+
import {
|
|
5
|
+
AccountBalanceViewerRpcSchemas,
|
|
6
|
+
HttpRpcTransport,
|
|
7
|
+
JsonRpcAccountBalanceViewer,
|
|
8
|
+
} from '@xyo-network/xl1-rpc'
|
|
9
|
+
|
|
10
|
+
let balanceServiceSingleton: Promisable<AccountBalanceViewer> | undefined
|
|
11
|
+
|
|
12
|
+
export type InitAccountBalanceServiceParams = InitializableParams<{
|
|
13
|
+
config: Config
|
|
14
|
+
}>
|
|
15
|
+
|
|
16
|
+
export const initAccountBalanceService: Initializable<InitAccountBalanceServiceParams, AccountBalanceViewer>
|
|
17
|
+
= (params): Promisable<AccountBalanceViewer> => {
|
|
18
|
+
const { config, logger } = params
|
|
19
|
+
if (balanceServiceSingleton) return balanceServiceSingleton
|
|
20
|
+
const endpoint = config.services?.accountBalanceViewerEndpoint ?? config.services?.apiEndpoint
|
|
21
|
+
if (isDefined(endpoint)) {
|
|
22
|
+
const transport = new HttpRpcTransport(endpoint, { ...AccountBalanceViewerRpcSchemas })
|
|
23
|
+
const viewer = new JsonRpcAccountBalanceViewer(transport)
|
|
24
|
+
logger?.log('Using AccountBalanceViewer RPC service at', endpoint)
|
|
25
|
+
return viewer
|
|
26
|
+
} else {
|
|
27
|
+
throw new Error('No AccountBalanceViewer endpoint configured')
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { isDefined, type Promisable } from '@xylabs/sdk-js'
|
|
2
|
+
import type { Initializable, InitializableParams } from '@xyo-network/xl1-protocol'
|
|
3
|
+
import type { BlockViewer, Config } from '@xyo-network/xl1-protocol-sdk'
|
|
4
|
+
import {
|
|
5
|
+
BlockViewerRpcSchemas,
|
|
6
|
+
HttpRpcTransport,
|
|
7
|
+
JsonRpcBlockViewer,
|
|
8
|
+
} from '@xyo-network/xl1-rpc'
|
|
9
|
+
|
|
10
|
+
let blockViewerSingleton: Promisable<BlockViewer> | undefined
|
|
11
|
+
|
|
12
|
+
export type InitBlockViewerParams = InitializableParams<{
|
|
13
|
+
config: Config
|
|
14
|
+
}>
|
|
15
|
+
|
|
16
|
+
export const initBlockViewer: Initializable<InitBlockViewerParams, BlockViewer>
|
|
17
|
+
= (params): Promisable<BlockViewer> => {
|
|
18
|
+
const { config, logger } = params
|
|
19
|
+
if (blockViewerSingleton) return blockViewerSingleton
|
|
20
|
+
const endpoint = config.services?.apiEndpoint
|
|
21
|
+
if (isDefined(endpoint)) {
|
|
22
|
+
const transport = new HttpRpcTransport(endpoint, { ...BlockViewerRpcSchemas })
|
|
23
|
+
const viewer = new JsonRpcBlockViewer(transport)
|
|
24
|
+
logger?.log('Using BlockViewer RPC service at', endpoint)
|
|
25
|
+
return viewer
|
|
26
|
+
} else {
|
|
27
|
+
throw new Error('No BlockViewer endpoint configured')
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Address, Promisable } from '@xylabs/sdk-js'
|
|
2
|
+
import {
|
|
3
|
+
asAddress, assertEx, isDefined, ZERO_ADDRESS,
|
|
4
|
+
} from '@xylabs/sdk-js'
|
|
5
|
+
import type { Initializable } from '@xyo-network/xl1-protocol'
|
|
6
|
+
import type { Config } from '@xyo-network/xl1-protocol-sdk'
|
|
7
|
+
import type { ContractRunner } from 'ethers'
|
|
8
|
+
import { Wallet } from 'ethers/wallet'
|
|
9
|
+
|
|
10
|
+
import { EvmChainService } from '../../ChainService/index.ts'
|
|
11
|
+
import type { BaseAccountableServiceParams } from '../../model/index.ts'
|
|
12
|
+
import { canUseEvmProvider, initEvmProvider } from '../evm/index.ts'
|
|
13
|
+
|
|
14
|
+
let chainStakeServiceSingleton: Promisable<EvmChainService> | undefined
|
|
15
|
+
|
|
16
|
+
export const canUseEvmContractChainService = (config: Pick<Config, 'chain' | 'evm'>) => {
|
|
17
|
+
const { id } = config.chain
|
|
18
|
+
return isDefined(id) && id !== ZERO_ADDRESS && canUseEvmProvider({ config })
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const initEvmContractChainService: Initializable<BaseAccountableServiceParams<Pick<Config, 'chain' | 'evm'>>, EvmChainService> = async ({
|
|
22
|
+
account, config, traceProvider, meterProvider, logger,
|
|
23
|
+
}) => {
|
|
24
|
+
if (chainStakeServiceSingleton) return chainStakeServiceSingleton
|
|
25
|
+
// Parse config
|
|
26
|
+
const emvStakingContractAddress = assertEx(config.chain.id, () => 'config.chain.id is required')
|
|
27
|
+
// Configure ContractRunner
|
|
28
|
+
const id: Address = assertEx(asAddress(emvStakingContractAddress), () => 'config.chain.id is not a valid address')
|
|
29
|
+
const provider = assertEx(await initEvmProvider({ config }))
|
|
30
|
+
const privateKey = assertEx(account.private?.hex, () => 'Account does not have a private key')
|
|
31
|
+
const runner: ContractRunner = new Wallet(privateKey, provider)
|
|
32
|
+
// Create service
|
|
33
|
+
chainStakeServiceSingleton = EvmChainService.create({
|
|
34
|
+
id, runner, traceProvider, meterProvider, logger,
|
|
35
|
+
})
|
|
36
|
+
const result = await chainStakeServiceSingleton
|
|
37
|
+
await result.start()
|
|
38
|
+
return result
|
|
39
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {
|
|
2
|
+
assertEx, type CreatableName, type Promisable,
|
|
3
|
+
} from '@xylabs/sdk-js'
|
|
4
|
+
import type { Initializable } from '@xyo-network/xl1-protocol'
|
|
5
|
+
import type { ChainService } from '@xyo-network/xl1-protocol-sdk'
|
|
6
|
+
import type { Config } from 'cosmiconfig'
|
|
7
|
+
|
|
8
|
+
import { MemoryChainService } from '../../ChainService/index.ts'
|
|
9
|
+
import type { BaseAccountableServiceParams } from '../../model/index.ts'
|
|
10
|
+
import { canUseEvmContractChainService, initEvmContractChainService } from './evm.ts'
|
|
11
|
+
|
|
12
|
+
let chainStakeServiceSingleton: Promisable<ChainService> | undefined
|
|
13
|
+
|
|
14
|
+
export const initChainService: Initializable<BaseAccountableServiceParams<
|
|
15
|
+
Pick<Config, 'chain' | 'evm' | 'producer'>>,
|
|
16
|
+
ChainService> = ({
|
|
17
|
+
account, config, logger,
|
|
18
|
+
}) => {
|
|
19
|
+
logger?.log('ChainService: Initializing...')
|
|
20
|
+
const result = init({
|
|
21
|
+
config, name: 'ChainService' as CreatableName, account,
|
|
22
|
+
})
|
|
23
|
+
logger?.log('ChainService: Initialized')
|
|
24
|
+
return result
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const initMemoryChainService: Initializable<BaseAccountableServiceParams<
|
|
28
|
+
Pick<Config, 'producer'>>, ChainService> = async ({ config }) => {
|
|
29
|
+
const result = await MemoryChainService.create({
|
|
30
|
+
config,
|
|
31
|
+
name: 'MemoryChainService' as CreatableName,
|
|
32
|
+
})
|
|
33
|
+
assertEx(await result.start(), () => 'Failed to start MemoryChainService')
|
|
34
|
+
return result
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const init: Initializable<BaseAccountableServiceParams<Pick<Config, 'chain' | 'evm' | 'producer'>>,
|
|
38
|
+
ChainService> = async (params): Promise<ChainService> => {
|
|
39
|
+
if (chainStakeServiceSingleton) return chainStakeServiceSingleton
|
|
40
|
+
const { config } = params
|
|
41
|
+
chainStakeServiceSingleton = canUseEvmContractChainService(config)
|
|
42
|
+
? await initEvmContractChainService({ ...params, name: 'ChainStakeService' as CreatableName })
|
|
43
|
+
: await initMemoryChainService(params)
|
|
44
|
+
// Create service
|
|
45
|
+
return chainStakeServiceSingleton
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './initEvmProvider.ts'
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
assertEx, hexFrom, isDefined, isHex,
|
|
3
|
+
} from '@xylabs/sdk-js'
|
|
4
|
+
import type { Config } from '@xyo-network/xl1-protocol-sdk'
|
|
5
|
+
|
|
6
|
+
export const canUseChainId = (config: Pick<Config, 'evm'>): boolean => {
|
|
7
|
+
return isDefined(config.evm.chainId)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const getChainId = (config: Pick<Config, 'evm'>) => {
|
|
11
|
+
const chainId = assertEx(config.evm.chainId, () => 'Missing config.evm.chainId')
|
|
12
|
+
if (isHex(chainId, { prefix: true })) {
|
|
13
|
+
const hex = hexFrom(chainId)
|
|
14
|
+
const parsed = Number.parseInt(hex, 16)
|
|
15
|
+
return parsed
|
|
16
|
+
} else {
|
|
17
|
+
const parsed = Number.parseInt(chainId, 10)
|
|
18
|
+
return parsed
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Logger } from '@xylabs/sdk-js'
|
|
2
|
+
import { assertEx } from '@xylabs/sdk-js'
|
|
3
|
+
import type { Config } from '@xyo-network/xl1-protocol-sdk'
|
|
4
|
+
import type { Provider } from 'ethers'
|
|
5
|
+
import type { JsonRpcProvider } from 'ethers/providers'
|
|
6
|
+
|
|
7
|
+
import { canUseInfuraProvider, initInfuraProvider } from './initInfuraProvider.ts'
|
|
8
|
+
import { canUseJsonRpcProvider, initJsonRpcProvider } from './initJsonRpcProvider.ts'
|
|
9
|
+
|
|
10
|
+
let provider: Promise<JsonRpcProvider> | undefined
|
|
11
|
+
|
|
12
|
+
export const initEvmProvider = async ({ config }: { config: Pick<Config, 'evm'>; logger?: Logger }): Promise<Provider> => {
|
|
13
|
+
if (provider) return provider
|
|
14
|
+
if (canUseInfuraProvider(config)) {
|
|
15
|
+
provider = initInfuraProvider(config)
|
|
16
|
+
} else if (canUseJsonRpcProvider(config)) {
|
|
17
|
+
provider = initJsonRpcProvider(config)
|
|
18
|
+
}
|
|
19
|
+
return assertEx(await provider, () => 'No provider available')
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const canUseEvmProvider = ({ config }: { config: Pick<Config, 'evm'> }) => {
|
|
23
|
+
return canUseInfuraProvider(config) || canUseJsonRpcProvider(config)
|
|
24
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { assertEx, isDefined } from '@xylabs/sdk-js'
|
|
2
|
+
import type { Config } from '@xyo-network/xl1-protocol-sdk'
|
|
3
|
+
import { InfuraProvider } from 'ethers/providers'
|
|
4
|
+
|
|
5
|
+
import { canUseChainId, getChainId } from './initChainId.ts'
|
|
6
|
+
|
|
7
|
+
let instance: Promise<InfuraProvider> | undefined
|
|
8
|
+
|
|
9
|
+
export const initInfuraProvider = (config: Pick<Config, 'evm'>) => {
|
|
10
|
+
if (instance) return instance
|
|
11
|
+
const providerConfig = getInfuraProviderConfig(config)
|
|
12
|
+
instance = Promise.resolve(new InfuraProvider(...providerConfig))
|
|
13
|
+
return instance
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const canUseInfuraProvider = (config: Pick<Config, 'evm'>): boolean => {
|
|
17
|
+
return canUseChainId(config)
|
|
18
|
+
&& isDefined(config.evm?.infura?.projectId)
|
|
19
|
+
&& isDefined(config.evm?.infura?.projectSecret)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const getInfuraProviderConfig = (config: Pick<Config, 'evm'>) => {
|
|
23
|
+
const projectId = assertEx(config.evm?.infura?.projectId, () => 'Missing config.evm.infura.projectId')
|
|
24
|
+
const projectSecret = assertEx(config.evm?.infura?.projectSecret, () => 'Missing config.evm.infura.projectSecret')
|
|
25
|
+
return [getChainId(config), projectId, projectSecret] as const
|
|
26
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { assertEx, isDefined } from '@xylabs/sdk-js'
|
|
2
|
+
import type { Config } from '@xyo-network/xl1-protocol-sdk'
|
|
3
|
+
import { JsonRpcProvider } from 'ethers/providers'
|
|
4
|
+
|
|
5
|
+
import { canUseChainId, getChainId } from './initChainId.ts'
|
|
6
|
+
|
|
7
|
+
export const initJsonRpcProvider = (config: Pick<Config, 'evm'>) => {
|
|
8
|
+
const providerConfig = getJsonRpcProviderConfig(config)
|
|
9
|
+
return Promise.resolve(new JsonRpcProvider(...providerConfig))
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const canUseJsonRpcProvider = (config: Pick<Config, 'evm'>) => {
|
|
13
|
+
return canUseChainId(config)
|
|
14
|
+
&& isDefined(config.evm.jsonRpc?.url)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const getJsonRpcProviderConfig = (config: Pick<Config, 'evm'>) => {
|
|
18
|
+
const jsonRpcUrl = assertEx(config.evm.jsonRpc?.url, () => 'Missing config.evm.jsonRpc.url')
|
|
19
|
+
return [jsonRpcUrl, getChainId(config)] as const
|
|
20
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildNextBlock, createDeclarationIntent, createGenesisBlock,
|
|
3
|
+
} from '@xyo-network/chain-protocol'
|
|
4
|
+
import type { WalletInstance } from '@xyo-network/wallet-model'
|
|
5
|
+
import type { SignedHydratedBlockWithHashMeta } from '@xyo-network/xl1-protocol'
|
|
6
|
+
import type { ChainService } from '@xyo-network/xl1-protocol-sdk'
|
|
7
|
+
|
|
8
|
+
export const createBootstrapHead = async (account: WalletInstance, chainService: ChainService): Promise<SignedHydratedBlockWithHashMeta[]> => {
|
|
9
|
+
const chainId = await chainService.chainId()
|
|
10
|
+
const chain: SignedHydratedBlockWithHashMeta[] = []
|
|
11
|
+
|
|
12
|
+
// Create genesis block
|
|
13
|
+
const genesisBlock = await createGenesisBlock(account, chainId, 10_000_000n, account.address)
|
|
14
|
+
chain.push(genesisBlock)
|
|
15
|
+
|
|
16
|
+
// Create producer declaration block
|
|
17
|
+
const producerDeclarationPayload = createDeclarationIntent(
|
|
18
|
+
account.address,
|
|
19
|
+
'producer',
|
|
20
|
+
genesisBlock[0].block,
|
|
21
|
+
genesisBlock[0].block + 10_000,
|
|
22
|
+
)
|
|
23
|
+
const producerDeclarationBlock = await buildNextBlock(
|
|
24
|
+
genesisBlock[0],
|
|
25
|
+
[],
|
|
26
|
+
[producerDeclarationPayload],
|
|
27
|
+
[account],
|
|
28
|
+
)
|
|
29
|
+
chain.push(producerDeclarationBlock)
|
|
30
|
+
return chain
|
|
31
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { toHex } from '@xylabs/sdk-js'
|
|
2
|
+
import type { BridgeDetailsDestinationFields } from '@xyo-network/xl1-protocol'
|
|
3
|
+
|
|
4
|
+
import { getForkBlockRewardHex } from './getForkDetails.ts'
|
|
5
|
+
|
|
6
|
+
// const bridgeableTokenContract = toHex('0x4865Cb10d55cfB0E60DD2B4F9b888f6a49B76733')
|
|
7
|
+
// const bridgeDestAddress = toHex('0xe53218d47913b5f9E58bb74F0a0eD790bbF21972')
|
|
8
|
+
// const destConfirmation = toHex('0x4fa05d7e799f36f1d45c441a4866eb4570a00a753a39377f404a8d113c01a657') // Eth TX for mint
|
|
9
|
+
const ethChainId = toHex('0x1')
|
|
10
|
+
const bridgeableTokenContract = toHex('0xf72aE3E0DA743033AbD7A407557D684c1aE66aed')
|
|
11
|
+
const bridgeDestAddress = toHex('0x0e65b65B10C791942665030402c35023d88B14dA')
|
|
12
|
+
const destConfirmation = toHex('0x950861b10523b52cdbb4a9ee52ed26601db555d2652bfec21c709e5e70d5b7d3') // Eth TX for mint
|
|
13
|
+
|
|
14
|
+
export const getBridgeDestChainId = () => ethChainId
|
|
15
|
+
export const getBridgeDestToken = () => bridgeableTokenContract
|
|
16
|
+
export const getBridgeDestAddress = () => bridgeDestAddress
|
|
17
|
+
export const getBridgeDestAmount = () => getForkBlockRewardHex()
|
|
18
|
+
export const getBridgeDestConfirmation = () => destConfirmation
|
|
19
|
+
|
|
20
|
+
export const getBridgeDestinationDetails = (): BridgeDetailsDestinationFields => {
|
|
21
|
+
return {
|
|
22
|
+
dest: getBridgeDestChainId(),
|
|
23
|
+
destToken: getBridgeDestToken(),
|
|
24
|
+
destAddress: getBridgeDestAddress(),
|
|
25
|
+
destAmount: getBridgeDestAmount(),
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AccountInstance } from '@xyo-network/account-model'
|
|
2
|
+
import type { BridgeDetailsSourceFields } from '@xyo-network/xl1-protocol'
|
|
3
|
+
import type { ChainService } from '@xyo-network/xl1-protocol-sdk'
|
|
4
|
+
|
|
5
|
+
import { getForkBlockRewardHex } from './getForkDetails.ts'
|
|
6
|
+
|
|
7
|
+
export const getBridgeSrcChainId = (chainService: ChainService) => chainService.chainId()
|
|
8
|
+
export const getBridgeSrcAddress = (account: AccountInstance) => account.address
|
|
9
|
+
export const getBridgeSrcToken = (chainService: ChainService) => chainService.chainId()
|
|
10
|
+
export const getBridgeSrcAmount = () => getForkBlockRewardHex()
|
|
11
|
+
|
|
12
|
+
export const getBridgeSourceDetails = async (account: AccountInstance, chainService: ChainService): Promise<BridgeDetailsSourceFields> => {
|
|
13
|
+
return {
|
|
14
|
+
src: await getBridgeSrcChainId(chainService),
|
|
15
|
+
srcAddress: getBridgeSrcAddress(account),
|
|
16
|
+
srcToken: await getBridgeSrcToken(chainService),
|
|
17
|
+
srcAmount: getBridgeSrcAmount(),
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Hex, toHex } from '@xylabs/sdk-js'
|
|
2
|
+
import { AttoXL1ConvertFactor } from '@xyo-network/xl1-protocol'
|
|
3
|
+
|
|
4
|
+
export const getForkBlockReward = (): bigint => {
|
|
5
|
+
return 18_000_000_000n * AttoXL1ConvertFactor.xl1 // 18b XL1 in AttoXL1
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const getForkBlockRewardHex = (): Hex => {
|
|
9
|
+
return toHex(getForkBlockReward())
|
|
10
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { WalletInstance } from '@xyo-network/wallet-model'
|
|
2
|
+
import type { SignedBlockBoundWitnessWithHashMeta, SignedHydratedBlockWithHashMeta } from '@xyo-network/xl1-protocol'
|
|
3
|
+
import type { ChainService } from '@xyo-network/xl1-protocol-sdk'
|
|
4
|
+
|
|
5
|
+
import { getBridgeDestinationObservation } from './getBridgeDestinationObservation.ts'
|
|
6
|
+
import { getBridgeIntent } from './getBridgeIntent.ts'
|
|
7
|
+
import { getBridgeSourceObservation } from './getBridgeSourceObservation.ts'
|
|
8
|
+
import { getFirstBlockForNewChain } from './getFirstBlockForNewChain.ts'
|
|
9
|
+
|
|
10
|
+
export const createForkedHead = async (
|
|
11
|
+
forkFromBlock: SignedBlockBoundWitnessWithHashMeta,
|
|
12
|
+
account: WalletInstance,
|
|
13
|
+
chainService: ChainService,
|
|
14
|
+
): Promise<SignedHydratedBlockWithHashMeta[]> => {
|
|
15
|
+
const chain: SignedHydratedBlockWithHashMeta[] = []
|
|
16
|
+
// Build the first block for the new chain
|
|
17
|
+
const firstBlockForNewChain = await getFirstBlockForNewChain(forkFromBlock, account, chainService)
|
|
18
|
+
chain.push(firstBlockForNewChain)
|
|
19
|
+
// Build the bridge intent
|
|
20
|
+
const bridgeIntent = await getBridgeIntent(firstBlockForNewChain, account, chainService)
|
|
21
|
+
chain.push(bridgeIntent)
|
|
22
|
+
// Build the bridge source observation
|
|
23
|
+
const bridgeSourceObservation = await getBridgeSourceObservation(bridgeIntent, account, chainService)
|
|
24
|
+
chain.push(bridgeSourceObservation)
|
|
25
|
+
// Build the bridge destination observation
|
|
26
|
+
const bridgeDestinationObservation = await getBridgeDestinationObservation(bridgeSourceObservation, account, chainService)
|
|
27
|
+
chain.push(bridgeDestinationObservation)
|
|
28
|
+
return chain
|
|
29
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { buildNextBlock } from '@xyo-network/chain-protocol'
|
|
2
|
+
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
3
|
+
import type { WalletInstance } from '@xyo-network/wallet-model'
|
|
4
|
+
import type {
|
|
5
|
+
BridgeDestinationObservation, BridgeDestinationObservationFields,
|
|
6
|
+
HydratedBlockWithHashMeta,
|
|
7
|
+
SignedHydratedBlockWithHashMeta,
|
|
8
|
+
} from '@xyo-network/xl1-protocol'
|
|
9
|
+
import { BridgeDestinationObservationSchema } from '@xyo-network/xl1-protocol'
|
|
10
|
+
import type { ChainService } from '@xyo-network/xl1-protocol-sdk'
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
getBridgeDestConfirmation, getBridgeDestinationDetails, getBridgeSourceDetails,
|
|
14
|
+
} from './config/index.ts'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Get the bridge destination observation for a given block.
|
|
18
|
+
* @param previousBlock The previous block to base the observation on.
|
|
19
|
+
* @param account The wallet account to use for the observation.
|
|
20
|
+
* @param chainService The chain service to use for the observation.
|
|
21
|
+
*/
|
|
22
|
+
export const getBridgeDestinationObservation = async (
|
|
23
|
+
previousBlock: HydratedBlockWithHashMeta,
|
|
24
|
+
account: WalletInstance,
|
|
25
|
+
chainService: ChainService,
|
|
26
|
+
): Promise<SignedHydratedBlockWithHashMeta> => {
|
|
27
|
+
const bridgeDestinationObservationFields: BridgeDestinationObservationFields = {
|
|
28
|
+
...await getBridgeSourceDetails(account, chainService),
|
|
29
|
+
...getBridgeDestinationDetails(),
|
|
30
|
+
destConfirmation: getBridgeDestConfirmation(),
|
|
31
|
+
}
|
|
32
|
+
const bridgeDestinationObservation = new PayloadBuilder<BridgeDestinationObservation>({ schema: BridgeDestinationObservationSchema })
|
|
33
|
+
.fields(bridgeDestinationObservationFields)
|
|
34
|
+
.build()
|
|
35
|
+
|
|
36
|
+
return await buildNextBlock(
|
|
37
|
+
previousBlock[0],
|
|
38
|
+
[],
|
|
39
|
+
[bridgeDestinationObservation],
|
|
40
|
+
[account],
|
|
41
|
+
)
|
|
42
|
+
}
|