@xyo-network/chain-orchestration 1.20.14 → 1.20.16
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 +9 -177
- package/dist/browser/index.mjs.map +1 -1
- package/dist/browser/shared/config/actors/Api.d.ts +9 -539
- package/dist/browser/shared/config/actors/Api.d.ts.map +1 -1
- package/dist/browser/shared/config/actors/Bridge.d.ts +9 -689
- package/dist/browser/shared/config/actors/Bridge.d.ts.map +1 -1
- package/dist/browser/shared/config/actors/Mempool.d.ts +9 -539
- package/dist/browser/shared/config/actors/Mempool.d.ts.map +1 -1
- package/dist/browser/shared/config/actors/Producer.d.ts +9 -575
- package/dist/browser/shared/config/actors/Producer.d.ts.map +1 -1
- package/dist/browser/shared/config/actors/RewardRedemption.d.ts +9 -533
- package/dist/browser/shared/config/actors/RewardRedemption.d.ts.map +1 -1
- package/dist/browser/shared/config/actors/Validator.d.ts +9 -563
- package/dist/browser/shared/config/actors/Validator.d.ts.map +1 -1
- package/dist/browser/shared/createDeclarationIntentBlock.d.ts +11 -11
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/shared/config/actors/Api.d.ts +9 -539
- package/dist/neutral/shared/config/actors/Api.d.ts.map +1 -1
- package/dist/neutral/shared/config/actors/Bridge.d.ts +9 -689
- package/dist/neutral/shared/config/actors/Bridge.d.ts.map +1 -1
- package/dist/neutral/shared/config/actors/Mempool.d.ts +9 -539
- package/dist/neutral/shared/config/actors/Mempool.d.ts.map +1 -1
- package/dist/neutral/shared/config/actors/Producer.d.ts +9 -575
- package/dist/neutral/shared/config/actors/Producer.d.ts.map +1 -1
- package/dist/neutral/shared/config/actors/RewardRedemption.d.ts +9 -533
- package/dist/neutral/shared/config/actors/RewardRedemption.d.ts.map +1 -1
- package/dist/neutral/shared/config/actors/Validator.d.ts +9 -563
- package/dist/neutral/shared/config/actors/Validator.d.ts.map +1 -1
- package/dist/neutral/shared/createDeclarationIntentBlock.d.ts +11 -11
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/shared/config/actors/Api.d.ts +9 -539
- package/dist/node/shared/config/actors/Api.d.ts.map +1 -1
- package/dist/node/shared/config/actors/Bridge.d.ts +9 -689
- package/dist/node/shared/config/actors/Bridge.d.ts.map +1 -1
- package/dist/node/shared/config/actors/Mempool.d.ts +9 -539
- package/dist/node/shared/config/actors/Mempool.d.ts.map +1 -1
- package/dist/node/shared/config/actors/Producer.d.ts +9 -575
- package/dist/node/shared/config/actors/Producer.d.ts.map +1 -1
- package/dist/node/shared/config/actors/RewardRedemption.d.ts +9 -533
- package/dist/node/shared/config/actors/RewardRedemption.d.ts.map +1 -1
- package/dist/node/shared/config/actors/Validator.d.ts +9 -563
- package/dist/node/shared/config/actors/Validator.d.ts.map +1 -1
- package/dist/node/shared/createDeclarationIntentBlock.d.ts +11 -11
- package/package.json +136 -52
- package/src/neutral/config/index.ts +0 -1
- package/src/neutral/config/locators/basicRemoteRunnerLocator.ts +0 -14
- package/src/neutral/config/locators/basicRemoteViewerLocator.ts +0 -11
- package/src/neutral/config/locators/index.ts +0 -3
- package/src/neutral/config/locators/rootLocatorFromConfig.ts +0 -19
- package/src/neutral/index.ts +0 -2
- package/src/node/archivists/ChainFinalized/archivist.ts +0 -21
- package/src/node/archivists/ChainFinalized/index.ts +0 -1
- package/src/node/archivists/ChainFinalized/local.ts +0 -17
- package/src/node/archivists/PendingBlocks/archivist.ts +0 -21
- package/src/node/archivists/PendingBlocks/index.ts +0 -1
- package/src/node/archivists/PendingBlocks/local.ts +0 -17
- package/src/node/archivists/RejectedTransactions/archivist.ts +0 -21
- package/src/node/archivists/RejectedTransactions/index.ts +0 -1
- package/src/node/archivists/RejectedTransactions/local.ts +0 -19
- package/src/node/archivists/StakeIntentState/archivist.ts +0 -21
- package/src/node/archivists/StakeIntentState/index.ts +0 -1
- package/src/node/archivists/StakeIntentState/local.ts +0 -18
- package/src/node/archivists/index.ts +0 -4
- package/src/node/archivists/lib/index.ts +0 -1
- package/src/node/archivists/lib/localPersistentArchivist.ts +0 -63
- package/src/node/config/index.ts +0 -2
- package/src/node/config/locators/actors/apiLocatorFromConfig.ts +0 -25
- package/src/node/config/locators/actors/bridgeLocatorFromConfig.ts +0 -83
- package/src/node/config/locators/actors/index.ts +0 -6
- package/src/node/config/locators/actors/mempoolLocatorFromConfig.ts +0 -17
- package/src/node/config/locators/actors/producerLocatorFromConfig.ts +0 -29
- package/src/node/config/locators/actors/rewardRedemptionLocatorFromConfig.ts +0 -56
- package/src/node/config/locators/actors/validatorLocatorFromConfig.ts +0 -15
- package/src/node/config/locators/basicRemoteRunnerLocator.ts +0 -38
- package/src/node/config/locators/basicRemoteViewerLocator.ts +0 -19
- package/src/node/config/locators/contextFromConfigWithoutLocator.ts +0 -25
- package/src/node/config/locators/index.ts +0 -7
- package/src/node/config/locators/localLocatorFromConfig.ts +0 -75
- package/src/node/config/locators/localViewerFromConfig.ts +0 -14
- package/src/node/config/locators/locatorsFromConfig.ts +0 -75
- package/src/node/config/locators/remoteViewerFromConfig.ts +0 -13
- package/src/node/config/locators/rootLocatorFromConfig.ts +0 -22
- package/src/node/config/locators/telemetryContextFromConfig.ts +0 -15
- package/src/node/config/tryParseConfig.ts +0 -42
- package/src/node/evm/index.ts +0 -4
- package/src/node/evm/initChainId.ts +0 -20
- package/src/node/evm/initEvmProvider.ts +0 -22
- package/src/node/evm/initInfuraProvider.ts +0 -29
- package/src/node/evm/initJsonRpcProvider.ts +0 -22
- package/src/node/health/index.ts +0 -1
- package/src/node/health/initHealthEndpoints.ts +0 -67
- package/src/node/index.ts +0 -8
- package/src/node/init/index.ts +0 -6
- package/src/node/init/initBalanceSummaryMap.ts +0 -33
- package/src/node/init/initEvmProvidersIfAvailable.ts +0 -93
- package/src/node/init/initFinalizationArchivistIfNeeded.ts +0 -44
- package/src/node/init/initFinalizedArchivist.ts +0 -16
- package/src/node/init/initServerNode.ts +0 -51
- package/src/node/init/initTransferSummaryMap.ts +0 -33
- package/src/node/manifest/getLocator.ts +0 -65
- package/src/node/manifest/index.ts +0 -5
- package/src/node/manifest/loadNode.ts +0 -26
- package/src/node/manifest/node.json +0 -17
- package/src/node/manifest/nodeManifest.ts +0 -8
- package/src/node/manifest/private/index.ts +0 -4
- package/src/node/manifest/public/Chain.json +0 -49
- package/src/node/manifest/public/Pending.json +0 -54
- package/src/node/manifest/public/index.ts +0 -20
- package/src/node/sharedMiddleware.ts +0 -24
- package/src/shared/ChainInitializableParams.ts +0 -4
- package/src/shared/actor/ValidatorActor.ts +0 -75
- package/src/shared/actor/index.ts +0 -1
- package/src/shared/buildTelemetryConfig.ts +0 -10
- package/src/shared/config/actors/Api.ts +0 -29
- package/src/shared/config/actors/Bridge.ts +0 -131
- package/src/shared/config/actors/Mempool.ts +0 -39
- package/src/shared/config/actors/Producer.ts +0 -56
- package/src/shared/config/actors/RewardRedemption.ts +0 -21
- package/src/shared/config/actors/Validator.ts +0 -22
- package/src/shared/config/actors/index.ts +0 -7
- package/src/shared/config/index.ts +0 -3
- package/src/shared/config/locators/basicRemoteRunnerLocator.ts +0 -63
- package/src/shared/config/locators/basicRemoteViewerLocator.ts +0 -44
- package/src/shared/config/locators/commonLocatorFromConfig.ts +0 -40
- package/src/shared/config/locators/index.ts +0 -4
- package/src/shared/config/locators/remoteLocatorFromConfig.ts +0 -56
- package/src/shared/config/mergeConfig.ts +0 -11
- package/src/shared/createDeclarationIntentBlock.ts +0 -19
- package/src/shared/host/implementation/DefaultHost.ts +0 -25
- package/src/shared/host/implementation/DefaultServiceCollection.ts +0 -60
- package/src/shared/host/implementation/DefaultServiceProvider.ts +0 -12
- package/src/shared/host/implementation/index.ts +0 -2
- package/src/shared/host/index.ts +0 -2
- package/src/shared/host/model/Host.ts +0 -21
- package/src/shared/host/model/ServiceCollection.ts +0 -22
- package/src/shared/host/model/ServiceProvider.ts +0 -3
- package/src/shared/host/model/index.ts +0 -3
- package/src/shared/index.ts +0 -8
- package/src/shared/init/index.ts +0 -5
- package/src/shared/init/initActorAccount.ts +0 -28
- package/src/shared/init/initActorSeedPhrase.ts +0 -29
- package/src/shared/init/initBridgedModule.ts +0 -40
- package/src/shared/init/initStatusReporter.ts +0 -15
- package/src/shared/init/initWallet.ts +0 -44
- package/src/shared/orchestrator/Orchestrator.ts +0 -66
- package/src/shared/orchestrator/index.ts +0 -1
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import type { Promisable } from '@xylabs/sdk-js'
|
|
2
|
-
import { isDefined } from '@xylabs/sdk-js'
|
|
3
|
-
import { HDWallet } from '@xyo-network/sdk-js'
|
|
4
|
-
import type { ProviderFactoryLocatorInstance, RestDataLakeRunnerParams } from '@xyo-network/xl1-sdk'
|
|
5
|
-
import {
|
|
6
|
-
ADDRESS_INDEX,
|
|
7
|
-
generateXyoBaseWalletFromPhrase,
|
|
8
|
-
JsonRpcAccountBalanceViewer,
|
|
9
|
-
JsonRpcBlockViewer,
|
|
10
|
-
JsonRpcFinalizationViewer,
|
|
11
|
-
JsonRpcMempoolRunner,
|
|
12
|
-
JsonRpcMempoolViewer,
|
|
13
|
-
JsonRpcXyoRunner,
|
|
14
|
-
JsonRpcXyoViewer,
|
|
15
|
-
ProviderFactoryLocator,
|
|
16
|
-
RestDataLakeRunner,
|
|
17
|
-
RestDataLakeViewer,
|
|
18
|
-
SimpleStakeEventsViewer,
|
|
19
|
-
SimpleXyoConnectionRunner,
|
|
20
|
-
SimpleXyoGatewayRunner,
|
|
21
|
-
SimpleXyoRunner,
|
|
22
|
-
SimpleXyoSigner,
|
|
23
|
-
} from '@xyo-network/xl1-sdk'
|
|
24
|
-
|
|
25
|
-
import type { BridgeConfigContext } from '../../../../neutral/index.ts'
|
|
26
|
-
|
|
27
|
-
export async function bridgeLocatorFromConfig(
|
|
28
|
-
context: BridgeConfigContext,
|
|
29
|
-
parent?: ProviderFactoryLocatorInstance,
|
|
30
|
-
): Promise<Promise<Promisable<ProviderFactoryLocatorInstance>>> {
|
|
31
|
-
const locator = new ProviderFactoryLocator({ ...context, locator: parent })
|
|
32
|
-
|
|
33
|
-
const { config } = context
|
|
34
|
-
|
|
35
|
-
const { dataLake, mnemonic } = config
|
|
36
|
-
const walletPhrase = isDefined(mnemonic) ? mnemonic : HDWallet.generateMnemonic()
|
|
37
|
-
const wallet = await generateXyoBaseWalletFromPhrase(walletPhrase)
|
|
38
|
-
const signerAccount = await wallet.derivePath(ADDRESS_INDEX.XYO)
|
|
39
|
-
|
|
40
|
-
if (config.remote.rpc) {
|
|
41
|
-
locator.registerMany([
|
|
42
|
-
JsonRpcMempoolViewer.factory<JsonRpcMempoolViewer>(JsonRpcMempoolViewer.dependencies, {}),
|
|
43
|
-
JsonRpcMempoolRunner.factory<JsonRpcMempoolRunner>(JsonRpcMempoolRunner.dependencies, {}),
|
|
44
|
-
JsonRpcAccountBalanceViewer.factory<JsonRpcAccountBalanceViewer>(
|
|
45
|
-
JsonRpcAccountBalanceViewer.dependencies,
|
|
46
|
-
{},
|
|
47
|
-
),
|
|
48
|
-
JsonRpcFinalizationViewer.factory<JsonRpcFinalizationViewer>(
|
|
49
|
-
JsonRpcFinalizationViewer.dependencies,
|
|
50
|
-
{},
|
|
51
|
-
),
|
|
52
|
-
JsonRpcBlockViewer.factory<JsonRpcBlockViewer>(JsonRpcBlockViewer.dependencies, {}),
|
|
53
|
-
JsonRpcXyoRunner.factory<JsonRpcXyoRunner>(JsonRpcXyoRunner.dependencies, {}),
|
|
54
|
-
JsonRpcXyoViewer.factory<JsonRpcXyoViewer>(JsonRpcXyoViewer.dependencies, {}),
|
|
55
|
-
])
|
|
56
|
-
}
|
|
57
|
-
if (isDefined(dataLake)) {
|
|
58
|
-
const { driver } = dataLake
|
|
59
|
-
switch (driver) {
|
|
60
|
-
case 'rest': {
|
|
61
|
-
const { url: endpoint } = dataLake
|
|
62
|
-
locator.registerMany([
|
|
63
|
-
RestDataLakeRunner.factory<RestDataLakeRunner<RestDataLakeRunnerParams>>(RestDataLakeRunner.dependencies, { endpoint }),
|
|
64
|
-
RestDataLakeViewer.factory<RestDataLakeViewer>(RestDataLakeViewer.dependencies, { endpoint }),
|
|
65
|
-
])
|
|
66
|
-
break
|
|
67
|
-
}
|
|
68
|
-
default: {
|
|
69
|
-
throw new Error(`Unsupported data lake protocol: ${driver}`)
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
locator.registerMany([
|
|
75
|
-
SimpleStakeEventsViewer.factory<SimpleStakeEventsViewer>(SimpleStakeEventsViewer.dependencies, { positions: [] }),
|
|
76
|
-
SimpleXyoSigner.factory<SimpleXyoSigner>(SimpleXyoSigner.dependencies, { account: signerAccount }),
|
|
77
|
-
SimpleXyoRunner.factory<SimpleXyoRunner>(SimpleXyoRunner.dependencies, {}),
|
|
78
|
-
SimpleXyoConnectionRunner.factory<SimpleXyoConnectionRunner>(SimpleXyoConnectionRunner.dependencies, {}),
|
|
79
|
-
SimpleXyoGatewayRunner.factory<SimpleXyoGatewayRunner>(SimpleXyoGatewayRunner.dependencies, {}),
|
|
80
|
-
])
|
|
81
|
-
locator.freeze()
|
|
82
|
-
return locator
|
|
83
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export * from './apiLocatorFromConfig.ts'
|
|
2
|
-
export * from './bridgeLocatorFromConfig.ts'
|
|
3
|
-
export * from './mempoolLocatorFromConfig.ts'
|
|
4
|
-
export * from './producerLocatorFromConfig.ts'
|
|
5
|
-
export * from './rewardRedemptionLocatorFromConfig.ts'
|
|
6
|
-
export * from './validatorLocatorFromConfig.ts'
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Promisable } from '@xylabs/sdk-js'
|
|
2
|
-
import type { ProviderFactoryLocatorInstance } from '@xyo-network/xl1-sdk'
|
|
3
|
-
import { ProviderFactoryLocator } from '@xyo-network/xl1-sdk'
|
|
4
|
-
|
|
5
|
-
import type { MempoolConfigContext } from '../../../../neutral/index.ts'
|
|
6
|
-
|
|
7
|
-
export function mempoolLocatorFromConfig(
|
|
8
|
-
context: MempoolConfigContext,
|
|
9
|
-
parent?: ProviderFactoryLocatorInstance,
|
|
10
|
-
): Promisable<ProviderFactoryLocatorInstance> {
|
|
11
|
-
const locator = new ProviderFactoryLocator({ ...context, locator: parent })
|
|
12
|
-
|
|
13
|
-
locator.registerMany([
|
|
14
|
-
])
|
|
15
|
-
locator.freeze()
|
|
16
|
-
return locator
|
|
17
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { asAddress } from '@xylabs/sdk-js'
|
|
2
|
-
import { SimpleBlockRunner } from '@xyo-network/chain-services'
|
|
3
|
-
import type { ProviderFactoryLocatorInstance } from '@xyo-network/xl1-sdk'
|
|
4
|
-
import { ProviderFactoryLocator } from '@xyo-network/xl1-sdk'
|
|
5
|
-
|
|
6
|
-
import type { ProducerConfigContext } from '../../../../neutral/index.ts'
|
|
7
|
-
import { initActorAccount } from '../../../../neutral/index.ts'
|
|
8
|
-
|
|
9
|
-
export async function producerLocatorFromConfig(
|
|
10
|
-
context: ProducerConfigContext,
|
|
11
|
-
parent?: ProviderFactoryLocatorInstance,
|
|
12
|
-
): Promise<ProviderFactoryLocatorInstance> {
|
|
13
|
-
const { logger, config } = context
|
|
14
|
-
const account = await initActorAccount(context)
|
|
15
|
-
const locator = new ProviderFactoryLocator({ ...context, locator: parent })
|
|
16
|
-
const rewardAddress = asAddress(config.rewardAddress ?? account.address, true)
|
|
17
|
-
logger?.info(`Using reward address ${rewardAddress}`)
|
|
18
|
-
if (rewardAddress === account.address) {
|
|
19
|
-
logger?.warn(`Using producer account address as reward address: ${account.address}`)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
locator.registerMany([
|
|
23
|
-
SimpleBlockRunner.factory<SimpleBlockRunner>(
|
|
24
|
-
SimpleBlockRunner.dependencies,
|
|
25
|
-
{ account, rewardAddress },
|
|
26
|
-
)])
|
|
27
|
-
locator.freeze()
|
|
28
|
-
return locator
|
|
29
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { Promisable } from '@xylabs/sdk-js'
|
|
2
|
-
import type { ProviderFactoryLocatorInstance } from '@xyo-network/xl1-sdk'
|
|
3
|
-
import {
|
|
4
|
-
JsonRpcAccountBalanceViewer,
|
|
5
|
-
JsonRpcBlockViewer,
|
|
6
|
-
JsonRpcFinalizationViewer,
|
|
7
|
-
JsonRpcMempoolRunner,
|
|
8
|
-
JsonRpcMempoolViewer,
|
|
9
|
-
JsonRpcXyoRunner,
|
|
10
|
-
JsonRpcXyoViewer,
|
|
11
|
-
ProviderFactoryLocator,
|
|
12
|
-
SimpleXyoConnectionRunner,
|
|
13
|
-
SimpleXyoGatewayRunner,
|
|
14
|
-
SimpleXyoRunner,
|
|
15
|
-
SimpleXyoSigner,
|
|
16
|
-
} from '@xyo-network/xl1-sdk'
|
|
17
|
-
|
|
18
|
-
import { initActorAccount, type RewardRedemptionConfigContext } from '../../../../neutral/index.ts'
|
|
19
|
-
|
|
20
|
-
export async function rewardRedemptionLocatorFromConfig(
|
|
21
|
-
context: RewardRedemptionConfigContext,
|
|
22
|
-
parent?: ProviderFactoryLocatorInstance,
|
|
23
|
-
): Promise<Promisable<ProviderFactoryLocatorInstance>> {
|
|
24
|
-
const locator = new ProviderFactoryLocator({ ...context, locator: parent })
|
|
25
|
-
|
|
26
|
-
const { config } = context
|
|
27
|
-
|
|
28
|
-
const account = await initActorAccount(context)
|
|
29
|
-
|
|
30
|
-
if (config.remote.rpc) {
|
|
31
|
-
locator.registerMany([
|
|
32
|
-
JsonRpcMempoolViewer.factory<JsonRpcMempoolViewer>(JsonRpcMempoolViewer.dependencies, {}),
|
|
33
|
-
JsonRpcMempoolRunner.factory<JsonRpcMempoolRunner>(JsonRpcMempoolRunner.dependencies, {}),
|
|
34
|
-
JsonRpcAccountBalanceViewer.factory<JsonRpcAccountBalanceViewer>(
|
|
35
|
-
JsonRpcAccountBalanceViewer.dependencies,
|
|
36
|
-
{},
|
|
37
|
-
),
|
|
38
|
-
JsonRpcFinalizationViewer.factory<JsonRpcFinalizationViewer>(
|
|
39
|
-
JsonRpcFinalizationViewer.dependencies,
|
|
40
|
-
{},
|
|
41
|
-
),
|
|
42
|
-
JsonRpcBlockViewer.factory<JsonRpcBlockViewer>(JsonRpcBlockViewer.dependencies, {}),
|
|
43
|
-
JsonRpcXyoRunner.factory<JsonRpcXyoRunner>(JsonRpcXyoRunner.dependencies, {}),
|
|
44
|
-
JsonRpcXyoViewer.factory<JsonRpcXyoViewer>(JsonRpcXyoViewer.dependencies, {}),
|
|
45
|
-
])
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
locator.registerMany([
|
|
49
|
-
SimpleXyoSigner.factory<SimpleXyoSigner>(SimpleXyoSigner.dependencies, { account }),
|
|
50
|
-
SimpleXyoRunner.factory<SimpleXyoRunner>(SimpleXyoRunner.dependencies, {}),
|
|
51
|
-
SimpleXyoConnectionRunner.factory<SimpleXyoConnectionRunner>(SimpleXyoConnectionRunner.dependencies, {}),
|
|
52
|
-
SimpleXyoGatewayRunner.factory<SimpleXyoGatewayRunner>(SimpleXyoGatewayRunner.dependencies, {}),
|
|
53
|
-
])
|
|
54
|
-
locator.freeze()
|
|
55
|
-
return locator
|
|
56
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { Promisable } from '@xylabs/sdk-js'
|
|
2
|
-
import type { ActorConfigContext, ProviderFactoryLocatorInstance } from '@xyo-network/xl1-sdk'
|
|
3
|
-
import { ProviderFactoryLocator } from '@xyo-network/xl1-sdk'
|
|
4
|
-
|
|
5
|
-
export function validatorLocatorFromConfig(
|
|
6
|
-
context: ActorConfigContext,
|
|
7
|
-
parent?: ProviderFactoryLocatorInstance,
|
|
8
|
-
): Promisable<ProviderFactoryLocatorInstance> {
|
|
9
|
-
const locator = new ProviderFactoryLocator({ ...context, locator: parent })
|
|
10
|
-
|
|
11
|
-
locator.registerMany([
|
|
12
|
-
])
|
|
13
|
-
locator.freeze()
|
|
14
|
-
return locator
|
|
15
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { AccountInstance } from '@xyo-network/sdk-js'
|
|
2
|
-
import { isAccountInstance } from '@xyo-network/sdk-js'
|
|
3
|
-
import type {
|
|
4
|
-
RemoteConfig, RpcTransport, XyoSignerRpcSchemas,
|
|
5
|
-
} from '@xyo-network/xl1-sdk'
|
|
6
|
-
import {
|
|
7
|
-
JsonRpcAccountBalanceViewer,
|
|
8
|
-
JsonRpcXyoSigner,
|
|
9
|
-
SimpleXyoSigner,
|
|
10
|
-
} from '@xyo-network/xl1-sdk'
|
|
11
|
-
|
|
12
|
-
import { baseBasicRemoteRunnerLocator } from '../../../shared/index.ts'
|
|
13
|
-
|
|
14
|
-
function signerFactoryFromParam(signer: RpcTransport<XyoSignerRpcSchemas> | AccountInstance) {
|
|
15
|
-
if (isAccountInstance(signer)) {
|
|
16
|
-
return SimpleXyoSigner.factory<SimpleXyoSigner>(SimpleXyoSigner.dependencies, { account: signer })
|
|
17
|
-
}
|
|
18
|
-
return JsonRpcXyoSigner.factory<JsonRpcXyoSigner>(JsonRpcXyoSigner.dependencies, { transport: signer })
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function basicRemoteRunnerLocator(
|
|
22
|
-
name: string,
|
|
23
|
-
remoteConfig: RemoteConfig,
|
|
24
|
-
signer: RpcTransport<XyoSignerRpcSchemas> | AccountInstance,
|
|
25
|
-
dataLakeEndpoint?: string,
|
|
26
|
-
) {
|
|
27
|
-
const transport = isAccountInstance(signer) ? undefined as never : signer
|
|
28
|
-
return baseBasicRemoteRunnerLocator(name, remoteConfig, transport, dataLakeEndpoint, {
|
|
29
|
-
additionalProviders: [
|
|
30
|
-
JsonRpcAccountBalanceViewer.factory<JsonRpcAccountBalanceViewer>(
|
|
31
|
-
JsonRpcAccountBalanceViewer.dependencies,
|
|
32
|
-
{},
|
|
33
|
-
),
|
|
34
|
-
],
|
|
35
|
-
signerFactory: signerFactoryFromParam(signer),
|
|
36
|
-
skipGatewayRunner: true,
|
|
37
|
-
})
|
|
38
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { RemoteConfig } from '@xyo-network/xl1-sdk'
|
|
2
|
-
import { JsonRpcAccountBalanceViewer } from '@xyo-network/xl1-sdk'
|
|
3
|
-
|
|
4
|
-
import { baseBasicRemoteViewerLocator } from '../../../shared/index.ts'
|
|
5
|
-
|
|
6
|
-
export function basicRemoteViewerLocator(
|
|
7
|
-
name: string,
|
|
8
|
-
remoteConfig: RemoteConfig,
|
|
9
|
-
dataLakeEndpoint?: string,
|
|
10
|
-
) {
|
|
11
|
-
return baseBasicRemoteViewerLocator(name, remoteConfig, dataLakeEndpoint, {
|
|
12
|
-
additionalProviders: [
|
|
13
|
-
JsonRpcAccountBalanceViewer.factory<JsonRpcAccountBalanceViewer>(
|
|
14
|
-
JsonRpcAccountBalanceViewer.dependencies,
|
|
15
|
-
{},
|
|
16
|
-
),
|
|
17
|
-
],
|
|
18
|
-
})
|
|
19
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { Logger } from '@xylabs/sdk-js'
|
|
2
|
-
import type { Config, CreatableProviderContext } from '@xyo-network/xl1-sdk'
|
|
3
|
-
|
|
4
|
-
import { initStatusReporter } from '../../../shared/index.ts'
|
|
5
|
-
import { telemetryContextFromConfig } from './telemetryContextFromConfig.ts'
|
|
6
|
-
|
|
7
|
-
export async function contextFromConfigWithoutLocator(
|
|
8
|
-
config: Config,
|
|
9
|
-
logger: Logger,
|
|
10
|
-
serviceName: string,
|
|
11
|
-
serviceVersion: string,
|
|
12
|
-
): Promise<Omit<CreatableProviderContext, 'locator'>> {
|
|
13
|
-
const singletons = {}
|
|
14
|
-
const caches = {}
|
|
15
|
-
const telemetryConfig = await telemetryContextFromConfig(config, serviceName, serviceVersion)
|
|
16
|
-
const statusReporter = initStatusReporter({ logger })
|
|
17
|
-
return {
|
|
18
|
-
...telemetryConfig,
|
|
19
|
-
config,
|
|
20
|
-
singletons,
|
|
21
|
-
caches,
|
|
22
|
-
logger,
|
|
23
|
-
statusReporter,
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export * from './basicRemoteRunnerLocator.ts'
|
|
2
|
-
export * from './basicRemoteViewerLocator.ts'
|
|
3
|
-
export * from './contextFromConfigWithoutLocator.ts'
|
|
4
|
-
export * from './localLocatorFromConfig.ts'
|
|
5
|
-
export * from './locatorsFromConfig.ts'
|
|
6
|
-
export * from './rootLocatorFromConfig.ts'
|
|
7
|
-
export * from './telemetryContextFromConfig.ts'
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { assertEx } from '@xylabs/sdk-js'
|
|
2
|
-
import { validateHydratedBlock, validateHydratedBlockState } from '@xyo-network/chain-validation'
|
|
3
|
-
import type { ActorConfigContext, HydratedBlockStateValidationFunction } from '@xyo-network/xl1-sdk'
|
|
4
|
-
import {
|
|
5
|
-
BlockCumulativeBalanceValidatorFactory,
|
|
6
|
-
ProviderFactoryLocator,
|
|
7
|
-
SimpleAccountBalanceViewer,
|
|
8
|
-
SimpleBlockValidationViewer,
|
|
9
|
-
SimpleBlockViewer,
|
|
10
|
-
SimpleFinalizationRunner,
|
|
11
|
-
SimpleFinalizationViewer,
|
|
12
|
-
SimpleMempoolRunner,
|
|
13
|
-
SimpleMempoolViewer,
|
|
14
|
-
SimpleTransactionViewer,
|
|
15
|
-
SimpleWindowedBlockViewer,
|
|
16
|
-
SimpleXyoConnectionViewer,
|
|
17
|
-
SimpleXyoViewer,
|
|
18
|
-
} from '@xyo-network/xl1-sdk'
|
|
19
|
-
|
|
20
|
-
import { initActorWallet } from '../../../shared/index.ts'
|
|
21
|
-
import {
|
|
22
|
-
initBalanceSummaryMap, initFinalizationArchivistIfNeeded,
|
|
23
|
-
initServerNode, initTransferSummaryMap,
|
|
24
|
-
} from '../../init/index.ts'
|
|
25
|
-
|
|
26
|
-
const cumulativeBalanceValidator = BlockCumulativeBalanceValidatorFactory()
|
|
27
|
-
|
|
28
|
-
const validateHydratedBlockStateWithCumulativeBalance: HydratedBlockStateValidationFunction = async (context, block) => {
|
|
29
|
-
const [stateErrors, cumulativeErrors] = await Promise.all([
|
|
30
|
-
validateHydratedBlockState(context, block),
|
|
31
|
-
cumulativeBalanceValidator(context, block),
|
|
32
|
-
])
|
|
33
|
-
return [...stateErrors, ...cumulativeErrors]
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export async function localLocatorFromConfig(
|
|
37
|
-
context: ActorConfigContext,
|
|
38
|
-
validateDepsOnRegister = false,
|
|
39
|
-
) {
|
|
40
|
-
const balancesSummaryMap = assertEx(await initBalanceSummaryMap(context), () => 'Balance Summary Map not initialized')
|
|
41
|
-
const transfersSummaryMap = assertEx(await initTransferSummaryMap(context), () => 'Transfer Summary Map not initialized')
|
|
42
|
-
|
|
43
|
-
// TODO: this should not be an api wallet, but a server wallet
|
|
44
|
-
const wallet = await initActorWallet(context)
|
|
45
|
-
|
|
46
|
-
const {
|
|
47
|
-
writableChainArchivist, readonlyChainArchivist, pendingTransactionsArchivist, pendingBlocksArchivist,
|
|
48
|
-
} = await initServerNode(
|
|
49
|
-
context,
|
|
50
|
-
wallet,
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
await initFinalizationArchivistIfNeeded(writableChainArchivist, context.config, wallet)
|
|
54
|
-
|
|
55
|
-
const locator = new ProviderFactoryLocator(context, {}, validateDepsOnRegister)
|
|
56
|
-
locator.registerMany([
|
|
57
|
-
SimpleMempoolViewer.factory<SimpleMempoolViewer>(SimpleMempoolViewer.dependencies, { pendingTransactionsArchivist, pendingBlocksArchivist }),
|
|
58
|
-
SimpleMempoolRunner.factory<SimpleMempoolRunner>(SimpleMempoolRunner.dependencies, { pendingTransactionsArchivist, pendingBlocksArchivist }),
|
|
59
|
-
SimpleAccountBalanceViewer.factory<SimpleAccountBalanceViewer>(SimpleAccountBalanceViewer.dependencies, { balancesSummaryMap, transfersSummaryMap }),
|
|
60
|
-
SimpleFinalizationViewer.factory<SimpleFinalizationViewer>(SimpleFinalizationViewer.dependencies, { finalizedArchivist: readonlyChainArchivist }),
|
|
61
|
-
SimpleBlockViewer.factory<SimpleBlockViewer>(SimpleBlockViewer.dependencies, { finalizedArchivist: readonlyChainArchivist }),
|
|
62
|
-
SimpleWindowedBlockViewer.factory<SimpleWindowedBlockViewer>(SimpleWindowedBlockViewer.dependencies, { maxWindowSize: 1000, syncInterval: 10_000 }),
|
|
63
|
-
SimpleXyoConnectionViewer.factory<SimpleXyoConnectionViewer>(SimpleXyoConnectionViewer.dependencies, {}),
|
|
64
|
-
SimpleTransactionViewer.factory<SimpleTransactionViewer>(SimpleTransactionViewer.dependencies, {}),
|
|
65
|
-
SimpleXyoViewer.factory<SimpleXyoViewer>(SimpleXyoViewer.dependencies, {}),
|
|
66
|
-
SimpleFinalizationViewer.factory<SimpleFinalizationViewer>(SimpleFinalizationViewer.dependencies, { finalizedArchivist: readonlyChainArchivist }),
|
|
67
|
-
SimpleFinalizationRunner.factory<SimpleFinalizationRunner>(SimpleFinalizationRunner.dependencies, { finalizedArchivist: writableChainArchivist }),
|
|
68
|
-
SimpleBlockValidationViewer.factory<SimpleBlockValidationViewer>(
|
|
69
|
-
SimpleBlockValidationViewer.dependencies,
|
|
70
|
-
{ state: validateHydratedBlockStateWithCumulativeBalance, protocol: validateHydratedBlock },
|
|
71
|
-
),
|
|
72
|
-
|
|
73
|
-
])
|
|
74
|
-
return locator
|
|
75
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { ActorConfigContext } from '@xyo-network/xl1-sdk'
|
|
2
|
-
import { XyoViewerMoniker } from '@xyo-network/xl1-sdk'
|
|
3
|
-
|
|
4
|
-
import { commonLocatorFromConfig } from '../../../shared/index.ts'
|
|
5
|
-
import { localLocatorFromConfig } from './localLocatorFromConfig.ts'
|
|
6
|
-
|
|
7
|
-
export async function localViewerFromConfig(
|
|
8
|
-
context: ActorConfigContext,
|
|
9
|
-
) {
|
|
10
|
-
const commonLocator = await commonLocatorFromConfig(context)
|
|
11
|
-
const locator = await localLocatorFromConfig({ ...commonLocator.context, config: { ...commonLocator.context.config, ...context.config } }, true)
|
|
12
|
-
locator.freeze()
|
|
13
|
-
return locator.getInstance(XyoViewerMoniker)
|
|
14
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { deepMerge } from '@xylabs/sdk-js'
|
|
2
|
-
import {
|
|
3
|
-
ActorConfigZod,
|
|
4
|
-
type CachingContext,
|
|
5
|
-
type Config, type ProviderFactoryLocatorInstance,
|
|
6
|
-
} from '@xyo-network/xl1-sdk'
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
ApiConfigZod, BridgeConfigZod, MempoolConfigZod, ProducerConfigZod, RewardRedemptionConfigZod,
|
|
10
|
-
} from '../../../shared/index.ts'
|
|
11
|
-
import {
|
|
12
|
-
apiLocatorFromConfig, bridgeLocatorFromConfig, mempoolLocatorFromConfig,
|
|
13
|
-
producerLocatorFromConfig, rewardRedemptionLocatorFromConfig, validatorLocatorFromConfig,
|
|
14
|
-
} from './actors/index.ts'
|
|
15
|
-
import { rootLocatorFromConfig } from './rootLocatorFromConfig.ts'
|
|
16
|
-
|
|
17
|
-
export async function locatorsFromConfig(
|
|
18
|
-
context: CachingContext,
|
|
19
|
-
{ actors, ...config }: Config,
|
|
20
|
-
): Promise<Record<string, ProviderFactoryLocatorInstance>> {
|
|
21
|
-
const result: Record<string, ProviderFactoryLocatorInstance> = { _root: await rootLocatorFromConfig({ ...context, config: { ...config, name: '_root' } }) }
|
|
22
|
-
for (const actorConfig of actors) {
|
|
23
|
-
switch (actorConfig.name) {
|
|
24
|
-
case 'producer': {
|
|
25
|
-
result[actorConfig.name] = await producerLocatorFromConfig(
|
|
26
|
-
{ ...context, config: ProducerConfigZod.parse(deepMerge(config, actorConfig)) },
|
|
27
|
-
result._root,
|
|
28
|
-
)
|
|
29
|
-
break
|
|
30
|
-
}
|
|
31
|
-
case 'api': {
|
|
32
|
-
result[actorConfig.name] = await apiLocatorFromConfig(
|
|
33
|
-
{ ...context, config: ApiConfigZod.parse(deepMerge(config, actorConfig)) },
|
|
34
|
-
result._root,
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
break
|
|
38
|
-
}
|
|
39
|
-
case 'mempool': {
|
|
40
|
-
result[actorConfig.name] = await mempoolLocatorFromConfig(
|
|
41
|
-
{ ...context, config: MempoolConfigZod.parse(deepMerge(config, actorConfig)) },
|
|
42
|
-
result._root,
|
|
43
|
-
)
|
|
44
|
-
break
|
|
45
|
-
}
|
|
46
|
-
case 'validator': {
|
|
47
|
-
result[actorConfig.name] = await validatorLocatorFromConfig(
|
|
48
|
-
{ ...context, config: ActorConfigZod.parse(deepMerge(config, actorConfig)) },
|
|
49
|
-
result._root,
|
|
50
|
-
)
|
|
51
|
-
break
|
|
52
|
-
}
|
|
53
|
-
case 'bridge': {
|
|
54
|
-
result[actorConfig.name] = await bridgeLocatorFromConfig(
|
|
55
|
-
{ ...context, config: BridgeConfigZod.parse(deepMerge(config, actorConfig)) },
|
|
56
|
-
result._root,
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
break
|
|
60
|
-
}
|
|
61
|
-
case 'rewardRedemption': {
|
|
62
|
-
result[actorConfig.name] = await rewardRedemptionLocatorFromConfig(
|
|
63
|
-
{
|
|
64
|
-
...context,
|
|
65
|
-
config: RewardRedemptionConfigZod.parse(deepMerge(config, actorConfig)),
|
|
66
|
-
},
|
|
67
|
-
result._root,
|
|
68
|
-
)
|
|
69
|
-
break
|
|
70
|
-
}
|
|
71
|
-
// No default
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return result
|
|
75
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { BaseConfigContext } from '@xyo-network/xl1-sdk'
|
|
2
|
-
import { XyoViewerMoniker } from '@xyo-network/xl1-sdk'
|
|
3
|
-
|
|
4
|
-
import { commonLocatorFromConfig, remoteLocatorFromConfig } from '../../../shared/index.ts'
|
|
5
|
-
|
|
6
|
-
export async function remoteViewerFromConfig(
|
|
7
|
-
context: BaseConfigContext,
|
|
8
|
-
) {
|
|
9
|
-
const commonLocator = await commonLocatorFromConfig(context)
|
|
10
|
-
const locator = await remoteLocatorFromConfig(commonLocator.context)
|
|
11
|
-
locator.freeze()
|
|
12
|
-
return locator.getInstance(XyoViewerMoniker)
|
|
13
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { ActorConfigContext, ProviderFactoryLocatorInstance } from '@xyo-network/xl1-sdk'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
commonLocatorFromConfig, initEvmProvidersIfAvailable, remoteLocatorFromConfig,
|
|
5
|
-
} from '../../index.ts'
|
|
6
|
-
import { localLocatorFromConfig } from './localLocatorFromConfig.ts'
|
|
7
|
-
|
|
8
|
-
export async function rootLocatorFromConfig(
|
|
9
|
-
context: ActorConfigContext,
|
|
10
|
-
validateDepsOnRegister = false,
|
|
11
|
-
): Promise<ProviderFactoryLocatorInstance> {
|
|
12
|
-
const { config } = context
|
|
13
|
-
let locator = await commonLocatorFromConfig(context, validateDepsOnRegister)
|
|
14
|
-
|
|
15
|
-
const newLocator = await (config.remote.rpc
|
|
16
|
-
? remoteLocatorFromConfig(locator.context, validateDepsOnRegister)
|
|
17
|
-
: localLocatorFromConfig({ ...locator.context, config: { ...locator.context.config, ...context.config } }, validateDepsOnRegister))
|
|
18
|
-
locator = newLocator
|
|
19
|
-
locator = await initEvmProvidersIfAvailable(locator)
|
|
20
|
-
locator.freeze()
|
|
21
|
-
return locator
|
|
22
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { initTelemetry } from '@xyo-network/chain-telemetry'
|
|
2
|
-
import type { Config } from '@xyo-network/xl1-sdk'
|
|
3
|
-
|
|
4
|
-
export async function telemetryContextFromConfig(config: Config, serviceName: string, serviceVersion: string) {
|
|
5
|
-
const { otlpEndpoint } = config.telemetry?.otel ?? {}
|
|
6
|
-
const { path: endpoint = '/metrics', port: port = 9466 } = config.telemetry?.metrics?.scrape ?? {}
|
|
7
|
-
return await initTelemetry({
|
|
8
|
-
attributes: {
|
|
9
|
-
serviceName,
|
|
10
|
-
serviceVersion,
|
|
11
|
-
},
|
|
12
|
-
otlpEndpoint,
|
|
13
|
-
metricsConfig: { endpoint, port },
|
|
14
|
-
})
|
|
15
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { isDefined, isNull } from '@xylabs/sdk-js'
|
|
2
|
-
import { ConfigZod } from '@xyo-network/xl1-sdk'
|
|
3
|
-
import { cosmiconfig } from 'cosmiconfig'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* The name of the configuration file to search for.
|
|
7
|
-
*/
|
|
8
|
-
const configName = 'xyo'
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* The name of the section within the configuration file to parse.
|
|
12
|
-
*/
|
|
13
|
-
const configSection = 'xl1' // Default section in the config file
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Attempts to parse the configuration from a file using cosmiconfig.
|
|
17
|
-
* @param options - Optional config loading options.
|
|
18
|
-
* @param options.configPath - Explicit path to a config file to load instead of searching.
|
|
19
|
-
* @param options.searchPlaces - Custom search places for cosmiconfig.
|
|
20
|
-
* @returns The parsed configuration object if found and valid, otherwise undefined.
|
|
21
|
-
*/
|
|
22
|
-
export async function tryParseConfig(options?: { configPath?: string; searchPlaces?: string[] }) {
|
|
23
|
-
const { configPath, searchPlaces } = options ?? {}
|
|
24
|
-
const explorer = cosmiconfig(
|
|
25
|
-
configName,
|
|
26
|
-
{
|
|
27
|
-
cache: true,
|
|
28
|
-
// loaders: { '.ts': TypeScriptLoader() },
|
|
29
|
-
searchPlaces,
|
|
30
|
-
},
|
|
31
|
-
)
|
|
32
|
-
const result = isDefined(configPath)
|
|
33
|
-
? (await explorer.load(configPath))?.config
|
|
34
|
-
: (await explorer.search())?.config
|
|
35
|
-
if (isDefined(result) && !isNull(result)) {
|
|
36
|
-
const section = result[configSection]
|
|
37
|
-
if (isDefined(section) && typeof section === 'object') {
|
|
38
|
-
return ConfigZod.loose().parse(section)
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return ConfigZod.parse({})
|
|
42
|
-
}
|
package/src/node/evm/index.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
assertEx, hexFrom, isDefined, isHex,
|
|
3
|
-
} from '@xylabs/sdk-js'
|
|
4
|
-
import type { BaseConfigContext } from '@xyo-network/xl1-sdk'
|
|
5
|
-
|
|
6
|
-
export const canUseChainId = ({ config }: BaseConfigContext): boolean => {
|
|
7
|
-
return isDefined(config.evm.chainId)
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const getChainId = ({ config }: BaseConfigContext) => {
|
|
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
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { assertEx } from '@xylabs/sdk-js'
|
|
2
|
-
import type { BaseConfigContext } from '@xyo-network/xl1-sdk'
|
|
3
|
-
import type { Provider } from 'ethers'
|
|
4
|
-
|
|
5
|
-
import { canUseInfuraProvider, initInfuraProvider } from './initInfuraProvider.ts'
|
|
6
|
-
import { canUseJsonRpcProvider, initJsonRpcProvider } from './initJsonRpcProvider.ts'
|
|
7
|
-
|
|
8
|
-
let provider: Promise<Provider> | undefined
|
|
9
|
-
|
|
10
|
-
export const initEvmProvider = async (context: BaseConfigContext): Promise<Provider> => {
|
|
11
|
-
if (provider) return provider
|
|
12
|
-
if (canUseInfuraProvider(context)) {
|
|
13
|
-
provider = initInfuraProvider(context)
|
|
14
|
-
} else if (canUseJsonRpcProvider(context)) {
|
|
15
|
-
provider = initJsonRpcProvider(context)
|
|
16
|
-
}
|
|
17
|
-
return assertEx(await provider, () => 'No provider available')
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const canUseEvmProvider = (context: BaseConfigContext) => {
|
|
21
|
-
return canUseInfuraProvider(context) || canUseJsonRpcProvider(context)
|
|
22
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { assertEx, isDefined } from '@xylabs/sdk-js'
|
|
2
|
-
import type { BaseConfigContext } from '@xyo-network/xl1-sdk'
|
|
3
|
-
import type { Provider } from 'ethers'
|
|
4
|
-
import { InfuraProvider } from 'ethers/providers'
|
|
5
|
-
|
|
6
|
-
import { canUseChainId, getChainId } from './initChainId.ts'
|
|
7
|
-
|
|
8
|
-
let instance: Promise<InfuraProvider> | undefined
|
|
9
|
-
|
|
10
|
-
export const initInfuraProvider = (context: BaseConfigContext): Promise<Provider> => {
|
|
11
|
-
if (instance) return instance
|
|
12
|
-
const providerConfig = getInfuraProviderConfig(context)
|
|
13
|
-
instance = Promise.resolve(new InfuraProvider(providerConfig[0], providerConfig[1]))
|
|
14
|
-
return instance
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const canUseInfuraProvider = (context: BaseConfigContext): boolean => {
|
|
18
|
-
const { config } = context
|
|
19
|
-
return canUseChainId(context)
|
|
20
|
-
&& isDefined(config.evm?.infura?.projectId)
|
|
21
|
-
&& isDefined(config.evm?.infura?.projectSecret)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const getInfuraProviderConfig = (context: BaseConfigContext) => {
|
|
25
|
-
const { config } = context
|
|
26
|
-
const projectId = assertEx(config.evm?.infura?.projectId, () => 'Missing config.evm.infura.projectId')
|
|
27
|
-
const projectSecret = assertEx(config.evm?.infura?.projectSecret, () => 'Missing config.evm.infura.projectSecret')
|
|
28
|
-
return [getChainId(context), projectId, projectSecret] as const
|
|
29
|
-
}
|