moonwall 1.0.0-dev.0
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/LICENSE +681 -0
- package/README.md +54 -0
- package/config_schema.json +811 -0
- package/dist/api/constants/accounts.d.ts +36 -0
- package/dist/api/constants/accounts.d.ts.map +1 -0
- package/dist/api/constants/accounts.js +67 -0
- package/dist/api/constants/chain.d.ts +134 -0
- package/dist/api/constants/chain.d.ts.map +1 -0
- package/dist/api/constants/chain.js +149 -0
- package/dist/api/constants/index.d.ts +4 -0
- package/dist/api/constants/index.d.ts.map +1 -0
- package/dist/api/constants/index.js +3 -0
- package/dist/api/constants/smartContract.d.ts +29 -0
- package/dist/api/constants/smartContract.d.ts.map +1 -0
- package/dist/api/constants/smartContract.js +118 -0
- package/dist/api/testing/blocks.d.ts +59 -0
- package/dist/api/testing/blocks.d.ts.map +1 -0
- package/dist/api/testing/blocks.js +147 -0
- package/dist/api/testing/contracts.d.ts +5 -0
- package/dist/api/testing/contracts.d.ts.map +1 -0
- package/dist/api/testing/contracts.js +32 -0
- package/dist/api/testing/ethers.d.ts +3 -0
- package/dist/api/testing/ethers.d.ts.map +1 -0
- package/dist/api/testing/ethers.js +38 -0
- package/dist/api/testing/events.d.ts +12 -0
- package/dist/api/testing/events.d.ts.map +1 -0
- package/dist/api/testing/events.js +23 -0
- package/dist/api/testing/extrinsics.d.ts +5 -0
- package/dist/api/testing/extrinsics.d.ts.map +1 -0
- package/dist/api/testing/extrinsics.js +10 -0
- package/dist/api/testing/index.d.ts +9 -0
- package/dist/api/testing/index.d.ts.map +1 -0
- package/dist/api/testing/index.js +8 -0
- package/dist/api/testing/jumping.d.ts +8 -0
- package/dist/api/testing/jumping.d.ts.map +1 -0
- package/dist/api/testing/jumping.js +78 -0
- package/dist/api/testing/providers.d.ts +18 -0
- package/dist/api/testing/providers.d.ts.map +1 -0
- package/dist/api/testing/providers.js +34 -0
- package/dist/api/testing/viem.d.ts +139 -0
- package/dist/api/testing/viem.d.ts.map +1 -0
- package/dist/api/testing/viem.js +247 -0
- package/dist/api/types/config.d.ts +609 -0
- package/dist/api/types/config.d.ts.map +1 -0
- package/dist/api/types/config.js +1 -0
- package/dist/api/types/context.d.ts +125 -0
- package/dist/api/types/context.d.ts.map +1 -0
- package/dist/api/types/context.js +1 -0
- package/dist/api/types/contracts.d.ts +66 -0
- package/dist/api/types/contracts.d.ts.map +1 -0
- package/dist/api/types/contracts.js +1 -0
- package/dist/api/types/eth.d.ts +3 -0
- package/dist/api/types/eth.d.ts.map +1 -0
- package/dist/api/types/eth.js +1 -0
- package/dist/api/types/foundations.d.ts +11 -0
- package/dist/api/types/foundations.d.ts.map +1 -0
- package/dist/api/types/foundations.js +1 -0
- package/dist/api/types/helpers.d.ts +7 -0
- package/dist/api/types/helpers.d.ts.map +1 -0
- package/dist/api/types/helpers.js +1 -0
- package/dist/api/types/index.d.ts +8 -0
- package/dist/api/types/index.d.ts.map +1 -0
- package/dist/api/types/index.js +7 -0
- package/dist/api/types/runner.d.ts +490 -0
- package/dist/api/types/runner.d.ts.map +1 -0
- package/dist/api/types/runner.js +1 -0
- package/dist/cli/cmds/components/LogViewer.d.ts +17 -0
- package/dist/cli/cmds/components/LogViewer.d.ts.map +1 -0
- package/dist/cli/cmds/components/LogViewer.js +171 -0
- package/dist/cli/cmds/entrypoint.d.ts +6 -0
- package/dist/cli/cmds/entrypoint.d.ts.map +1 -0
- package/dist/cli/cmds/entrypoint.js +192 -0
- package/dist/cli/cmds/interactiveCmds/chopsticksIntCmds.d.ts +2 -0
- package/dist/cli/cmds/interactiveCmds/chopsticksIntCmds.d.ts.map +1 -0
- package/dist/cli/cmds/interactiveCmds/chopsticksIntCmds.js +117 -0
- package/dist/cli/cmds/interactiveCmds/devIntCmds.d.ts +2 -0
- package/dist/cli/cmds/interactiveCmds/devIntCmds.d.ts.map +1 -0
- package/dist/cli/cmds/interactiveCmds/devIntCmds.js +103 -0
- package/dist/cli/cmds/interactiveCmds/index.d.ts +4 -0
- package/dist/cli/cmds/interactiveCmds/index.d.ts.map +1 -0
- package/dist/cli/cmds/interactiveCmds/index.js +3 -0
- package/dist/cli/cmds/interactiveCmds/zombieIntCmds.d.ts +2 -0
- package/dist/cli/cmds/interactiveCmds/zombieIntCmds.d.ts.map +1 -0
- package/dist/cli/cmds/interactiveCmds/zombieIntCmds.js +32 -0
- package/dist/cli/cmds/main.d.ts +2 -0
- package/dist/cli/cmds/main.d.ts.map +1 -0
- package/dist/cli/cmds/main.js +336 -0
- package/dist/cli/cmds/runNetwork.d.ts +3 -0
- package/dist/cli/cmds/runNetwork.d.ts.map +1 -0
- package/dist/cli/cmds/runNetwork.js +292 -0
- package/dist/cli/cmds/runTests.d.ts +12 -0
- package/dist/cli/cmds/runTests.d.ts.map +1 -0
- package/dist/cli/cmds/runTests.js +257 -0
- package/dist/cli/internal/cmdFunctions/downloader.d.ts +4 -0
- package/dist/cli/internal/cmdFunctions/downloader.d.ts.map +1 -0
- package/dist/cli/internal/cmdFunctions/downloader.js +49 -0
- package/dist/cli/internal/cmdFunctions/fetchArtifact.d.ts +10 -0
- package/dist/cli/internal/cmdFunctions/fetchArtifact.d.ts.map +1 -0
- package/dist/cli/internal/cmdFunctions/fetchArtifact.js +145 -0
- package/dist/cli/internal/cmdFunctions/index.d.ts +5 -0
- package/dist/cli/internal/cmdFunctions/index.d.ts.map +1 -0
- package/dist/cli/internal/cmdFunctions/index.js +4 -0
- package/dist/cli/internal/cmdFunctions/initialisation.d.ts +20 -0
- package/dist/cli/internal/cmdFunctions/initialisation.d.ts.map +1 -0
- package/dist/cli/internal/cmdFunctions/initialisation.js +150 -0
- package/dist/cli/internal/cmdFunctions/tempLogs.d.ts +3 -0
- package/dist/cli/internal/cmdFunctions/tempLogs.d.ts.map +1 -0
- package/dist/cli/internal/cmdFunctions/tempLogs.js +37 -0
- package/dist/cli/internal/commandParsers.d.ts +59 -0
- package/dist/cli/internal/commandParsers.d.ts.map +1 -0
- package/dist/cli/internal/commandParsers.js +305 -0
- package/dist/cli/internal/deriveTestIds.d.ts +8 -0
- package/dist/cli/internal/deriveTestIds.d.ts.map +1 -0
- package/dist/cli/internal/deriveTestIds.js +123 -0
- package/dist/cli/internal/effect/index.d.ts +6 -0
- package/dist/cli/internal/effect/index.d.ts.map +1 -0
- package/dist/cli/internal/effect/index.js +5 -0
- package/dist/cli/internal/fileCheckers.d.ts +11 -0
- package/dist/cli/internal/fileCheckers.d.ts.map +1 -0
- package/dist/cli/internal/fileCheckers.js +165 -0
- package/dist/cli/internal/foundations/index.d.ts +4 -0
- package/dist/cli/internal/foundations/index.d.ts.map +1 -0
- package/dist/cli/internal/foundations/index.js +4 -0
- package/dist/cli/internal/index.d.ts +12 -0
- package/dist/cli/internal/index.d.ts.map +1 -0
- package/dist/cli/internal/index.js +11 -0
- package/dist/cli/internal/launcherCommon.d.ts +4 -0
- package/dist/cli/internal/launcherCommon.d.ts.map +1 -0
- package/dist/cli/internal/launcherCommon.js +130 -0
- package/dist/cli/internal/localNode.d.ts +16 -0
- package/dist/cli/internal/localNode.d.ts.map +1 -0
- package/dist/cli/internal/localNode.js +362 -0
- package/dist/cli/internal/logging.d.ts +2 -0
- package/dist/cli/internal/logging.d.ts.map +1 -0
- package/dist/cli/internal/logging.js +26 -0
- package/dist/cli/internal/node.d.ts +33 -0
- package/dist/cli/internal/node.d.ts.map +1 -0
- package/dist/cli/internal/node.js +228 -0
- package/dist/cli/internal/processHelpers.d.ts +17 -0
- package/dist/cli/internal/processHelpers.d.ts.map +1 -0
- package/dist/cli/internal/processHelpers.js +56 -0
- package/dist/cli/internal/providerFactories.d.ts +48 -0
- package/dist/cli/internal/providerFactories.d.ts.map +1 -0
- package/dist/cli/internal/providerFactories.js +442 -0
- package/dist/cli/internal/testIdParser.d.ts +34 -0
- package/dist/cli/internal/testIdParser.d.ts.map +1 -0
- package/dist/cli/internal/testIdParser.js +167 -0
- package/dist/cli/lib/binariesHelpers.d.ts +15 -0
- package/dist/cli/lib/binariesHelpers.d.ts.map +1 -0
- package/dist/cli/lib/binariesHelpers.js +99 -0
- package/dist/cli/lib/configReader.d.ts +8 -0
- package/dist/cli/lib/configReader.d.ts.map +1 -0
- package/dist/cli/lib/configReader.js +115 -0
- package/dist/cli/lib/contractFunctions.d.ts +2 -0
- package/dist/cli/lib/contractFunctions.d.ts.map +1 -0
- package/dist/cli/lib/contractFunctions.js +2 -0
- package/dist/cli/lib/globalContext.d.ts +46 -0
- package/dist/cli/lib/globalContext.d.ts.map +1 -0
- package/dist/cli/lib/globalContext.js +710 -0
- package/dist/cli/lib/governanceProcedures.d.ts +27 -0
- package/dist/cli/lib/governanceProcedures.d.ts.map +1 -0
- package/dist/cli/lib/governanceProcedures.js +458 -0
- package/dist/cli/lib/handlers/index.d.ts +5 -0
- package/dist/cli/lib/handlers/index.d.ts.map +1 -0
- package/dist/cli/lib/handlers/index.js +5 -0
- package/dist/cli/lib/repoDefinitions/index.d.ts +6 -0
- package/dist/cli/lib/repoDefinitions/index.d.ts.map +1 -0
- package/dist/cli/lib/repoDefinitions/index.js +21 -0
- package/dist/cli/lib/repoDefinitions/moonbeam.d.ts +4 -0
- package/dist/cli/lib/repoDefinitions/moonbeam.d.ts.map +1 -0
- package/dist/cli/lib/repoDefinitions/moonbeam.js +30 -0
- package/dist/cli/lib/repoDefinitions/polkadot.d.ts +4 -0
- package/dist/cli/lib/repoDefinitions/polkadot.d.ts.map +1 -0
- package/dist/cli/lib/repoDefinitions/polkadot.js +11 -0
- package/dist/cli/lib/repoDefinitions/tanssi.d.ts +4 -0
- package/dist/cli/lib/repoDefinitions/tanssi.d.ts.map +1 -0
- package/dist/cli/lib/repoDefinitions/tanssi.js +14 -0
- package/dist/cli/lib/rpcFunctions.d.ts +2 -0
- package/dist/cli/lib/rpcFunctions.d.ts.map +1 -0
- package/dist/cli/lib/rpcFunctions.js +26 -0
- package/dist/cli/lib/runnerContext.d.ts +32 -0
- package/dist/cli/lib/runnerContext.d.ts.map +1 -0
- package/dist/cli/lib/runnerContext.js +156 -0
- package/dist/cli/lib/shardManager.d.ts +40 -0
- package/dist/cli/lib/shardManager.d.ts.map +1 -0
- package/dist/cli/lib/shardManager.js +80 -0
- package/dist/cli/lib/upgradeProcedures.d.ts +5 -0
- package/dist/cli/lib/upgradeProcedures.d.ts.map +1 -0
- package/dist/cli/lib/upgradeProcedures.js +221 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +3 -0
- package/dist/contracts/contractInteraction.d.ts +17 -0
- package/dist/contracts/contractInteraction.d.ts.map +1 -0
- package/dist/contracts/contractInteraction.js +170 -0
- package/dist/contracts/index.d.ts +2 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +1 -0
- package/dist/foundations/chopsticks/handler.d.ts +3 -0
- package/dist/foundations/chopsticks/handler.d.ts.map +1 -0
- package/dist/foundations/chopsticks/handler.js +93 -0
- package/dist/foundations/chopsticks/helpers.d.ts +27 -0
- package/dist/foundations/chopsticks/helpers.d.ts.map +1 -0
- package/dist/foundations/chopsticks/helpers.js +133 -0
- package/dist/foundations/dev/handler.d.ts +3 -0
- package/dist/foundations/dev/handler.d.ts.map +1 -0
- package/dist/foundations/dev/handler.js +136 -0
- package/dist/foundations/dev/helpers.d.ts +27 -0
- package/dist/foundations/dev/helpers.d.ts.map +1 -0
- package/dist/foundations/dev/helpers.js +161 -0
- package/dist/foundations/read-only/handler.d.ts +3 -0
- package/dist/foundations/read-only/handler.d.ts.map +1 -0
- package/dist/foundations/read-only/handler.js +32 -0
- package/dist/foundations/zombie/handler.d.ts +3 -0
- package/dist/foundations/zombie/handler.d.ts.map +1 -0
- package/dist/foundations/zombie/handler.js +92 -0
- package/dist/foundations/zombie/helpers.d.ts +16 -0
- package/dist/foundations/zombie/helpers.d.ts.map +1 -0
- package/dist/foundations/zombie/helpers.js +97 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +47 -0
- package/dist/internal/common.d.ts +3 -0
- package/dist/internal/common.d.ts.map +1 -0
- package/dist/internal/common.js +41 -0
- package/dist/internal/index.d.ts +4 -0
- package/dist/internal/index.d.ts.map +1 -0
- package/dist/internal/index.js +3 -0
- package/dist/internal/logger.d.ts +24 -0
- package/dist/internal/logger.d.ts.map +1 -0
- package/dist/internal/logger.js +66 -0
- package/dist/internal/logging.d.ts +7 -0
- package/dist/internal/logging.d.ts.map +1 -0
- package/dist/internal/logging.js +36 -0
- package/dist/moondebug.d.ts +3 -0
- package/dist/moondebug.d.ts.map +1 -0
- package/dist/moondebug.js +2 -0
- package/dist/services/cache/FileLock.d.ts +11 -0
- package/dist/services/cache/FileLock.d.ts.map +1 -0
- package/dist/services/cache/FileLock.js +68 -0
- package/dist/services/cache/StartupCacheService.d.ts +23 -0
- package/dist/services/cache/StartupCacheService.d.ts.map +1 -0
- package/dist/services/cache/StartupCacheService.js +159 -0
- package/dist/services/cache/index.d.ts +3 -0
- package/dist/services/cache/index.d.ts.map +1 -0
- package/dist/services/cache/index.js +2 -0
- package/dist/services/chopsticks/ChopsticksMultiChain.d.ts +158 -0
- package/dist/services/chopsticks/ChopsticksMultiChain.d.ts.map +1 -0
- package/dist/services/chopsticks/ChopsticksMultiChain.js +282 -0
- package/dist/services/chopsticks/ChopsticksService.d.ts +313 -0
- package/dist/services/chopsticks/ChopsticksService.d.ts.map +1 -0
- package/dist/services/chopsticks/ChopsticksService.js +77 -0
- package/dist/services/chopsticks/chopsticksConfigParser.d.ts +40 -0
- package/dist/services/chopsticks/chopsticksConfigParser.d.ts.map +1 -0
- package/dist/services/chopsticks/chopsticksConfigParser.js +201 -0
- package/dist/services/chopsticks/index.d.ts +5 -0
- package/dist/services/chopsticks/index.d.ts.map +1 -0
- package/dist/services/chopsticks/index.js +4 -0
- package/dist/services/chopsticks/launchChopsticksEffect.d.ts +225 -0
- package/dist/services/chopsticks/launchChopsticksEffect.d.ts.map +1 -0
- package/dist/services/chopsticks/launchChopsticksEffect.js +623 -0
- package/dist/services/config/configAccessors.d.ts +41 -0
- package/dist/services/config/configAccessors.d.ts.map +1 -0
- package/dist/services/config/configAccessors.js +149 -0
- package/dist/services/config/index.d.ts +2 -0
- package/dist/services/config/index.d.ts.map +1 -0
- package/dist/services/config/index.js +1 -0
- package/dist/services/errors.d.ts +72 -0
- package/dist/services/errors.d.ts.map +1 -0
- package/dist/services/errors.js +31 -0
- package/dist/services/index.d.ts +7 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +6 -0
- package/dist/services/network/NodeReadinessService.d.ts +35 -0
- package/dist/services/network/NodeReadinessService.d.ts.map +1 -0
- package/dist/services/network/NodeReadinessService.js +120 -0
- package/dist/services/network/PortDiscoveryService.d.ts +22 -0
- package/dist/services/network/PortDiscoveryService.d.ts.map +1 -0
- package/dist/services/network/PortDiscoveryService.js +77 -0
- package/dist/services/network/RpcPortDiscoveryService.d.ts +25 -0
- package/dist/services/network/RpcPortDiscoveryService.d.ts.map +1 -0
- package/dist/services/network/RpcPortDiscoveryService.js +136 -0
- package/dist/services/network/index.d.ts +4 -0
- package/dist/services/network/index.d.ts.map +1 -0
- package/dist/services/network/index.js +3 -0
- package/dist/services/process/ProcessManagerService.d.ts +49 -0
- package/dist/services/process/ProcessManagerService.d.ts.map +1 -0
- package/dist/services/process/ProcessManagerService.js +162 -0
- package/dist/services/process/index.d.ts +3 -0
- package/dist/services/process/index.d.ts.map +1 -0
- package/dist/services/process/index.js +2 -0
- package/dist/services/process/launchNodeEffect.d.ts +40 -0
- package/dist/services/process/launchNodeEffect.d.ts.map +1 -0
- package/dist/services/process/launchNodeEffect.js +86 -0
- package/dist/util/functions/index.d.ts +3 -0
- package/dist/util/functions/index.d.ts.map +1 -0
- package/dist/util/functions/index.js +4 -0
- package/dist/util/index.d.ts +4 -0
- package/dist/util/index.d.ts.map +1 -0
- package/dist/util/index.js +2 -0
- package/package.json +157 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-chain Chopsticks support for XCM testing
|
|
3
|
+
*
|
|
4
|
+
* This module provides Effect-based support for launching multiple chopsticks
|
|
5
|
+
* instances and coordinating XCM message passing between them.
|
|
6
|
+
*/
|
|
7
|
+
import { Context, Data, Effect, Layer } from "effect";
|
|
8
|
+
import { createLogger } from "../../util/index.js";
|
|
9
|
+
import { ChopsticksSetupError, ChopsticksXcmError, } from "./ChopsticksService.js";
|
|
10
|
+
import { launchChopsticksEffect } from "./launchChopsticksEffect.js";
|
|
11
|
+
const logger = createLogger({ name: "ChopsticksMultiChain" });
|
|
12
|
+
/**
|
|
13
|
+
* Extract a single endpoint string from the config.
|
|
14
|
+
* The ChopsticksConfig endpoint can be a string, array of strings, or undefined.
|
|
15
|
+
*/
|
|
16
|
+
const getEndpointString = (endpoint) => {
|
|
17
|
+
if (typeof endpoint === "string")
|
|
18
|
+
return endpoint;
|
|
19
|
+
if (Array.isArray(endpoint))
|
|
20
|
+
return endpoint[0];
|
|
21
|
+
return undefined;
|
|
22
|
+
};
|
|
23
|
+
// =============================================================================
|
|
24
|
+
// Error Types
|
|
25
|
+
// =============================================================================
|
|
26
|
+
/**
|
|
27
|
+
* Error thrown when multi-chain orchestration fails
|
|
28
|
+
*/
|
|
29
|
+
export class ChopsticksOrchestrationError extends Data.TaggedError("ChopsticksOrchestrationError") {
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Service tag for multi-chain orchestration
|
|
33
|
+
*/
|
|
34
|
+
export class ChopsticksMultiChainService extends Context.Tag("ChopsticksMultiChainService")() {
|
|
35
|
+
}
|
|
36
|
+
// =============================================================================
|
|
37
|
+
// Implementation
|
|
38
|
+
// =============================================================================
|
|
39
|
+
/**
|
|
40
|
+
* Create the multi-chain service implementation
|
|
41
|
+
*/
|
|
42
|
+
const createMultiChainService = (relay, parachains) => {
|
|
43
|
+
const chains = new Map();
|
|
44
|
+
// Add relay chain
|
|
45
|
+
chains.set("relay", { service: relay, type: "relay" });
|
|
46
|
+
// Add parachains
|
|
47
|
+
for (const [paraId, service] of parachains) {
|
|
48
|
+
chains.set(`para-${paraId}`, { service, type: "parachain", paraId });
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
relay,
|
|
52
|
+
parachain: (paraId) => parachains.get(paraId),
|
|
53
|
+
chains,
|
|
54
|
+
createBlocksAll: () => Effect.gen(function* () {
|
|
55
|
+
const results = new Map();
|
|
56
|
+
// Create blocks on all chains in parallel
|
|
57
|
+
const blockEffects = Array.from(chains.entries()).map(([id, chain]) => chain.service.createBlock().pipe(Effect.map((result) => [id, result])));
|
|
58
|
+
const blockResults = yield* Effect.all(blockEffects, { concurrency: "unbounded" });
|
|
59
|
+
for (const [id, result] of blockResults) {
|
|
60
|
+
results.set(id, result);
|
|
61
|
+
}
|
|
62
|
+
return results;
|
|
63
|
+
}),
|
|
64
|
+
sendUmp: (paraId, messages) => Effect.gen(function* () {
|
|
65
|
+
// UMP: Submit upward messages FROM parachain TO relay
|
|
66
|
+
// The messages are submitted to the relay chain
|
|
67
|
+
yield* relay.submitUpwardMessages(paraId, messages);
|
|
68
|
+
logger.debug(`Sent ${messages.length} UMP messages from para ${paraId} to relay`);
|
|
69
|
+
}),
|
|
70
|
+
sendDmp: (paraId, messages) => Effect.gen(function* () {
|
|
71
|
+
const para = parachains.get(paraId);
|
|
72
|
+
if (!para) {
|
|
73
|
+
yield* Effect.fail(new ChopsticksXcmError({
|
|
74
|
+
cause: new Error(`Parachain ${paraId} not found`),
|
|
75
|
+
messageType: "dmp",
|
|
76
|
+
paraId,
|
|
77
|
+
}));
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
// DMP: Submit downward messages FROM relay TO parachain
|
|
81
|
+
// The messages are submitted to the parachain
|
|
82
|
+
yield* para.submitDownwardMessages(messages);
|
|
83
|
+
logger.debug(`Sent ${messages.length} DMP messages from relay to para ${paraId}`);
|
|
84
|
+
}),
|
|
85
|
+
sendHrmp: (fromParaId, toParaId, messages) => Effect.gen(function* () {
|
|
86
|
+
const toPara = parachains.get(toParaId);
|
|
87
|
+
if (!toPara) {
|
|
88
|
+
yield* Effect.fail(new ChopsticksXcmError({
|
|
89
|
+
cause: new Error(`Target parachain ${toParaId} not found`),
|
|
90
|
+
messageType: "hrmp",
|
|
91
|
+
paraId: toParaId,
|
|
92
|
+
}));
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
// HRMP: Submit horizontal messages FROM one parachain TO another
|
|
96
|
+
// The messages are submitted to the receiving parachain
|
|
97
|
+
yield* toPara.submitHorizontalMessages(fromParaId, messages);
|
|
98
|
+
logger.debug(`Sent ${messages.length} HRMP messages from para ${fromParaId} to para ${toParaId}`);
|
|
99
|
+
}),
|
|
100
|
+
processXcm: () => Effect.gen(function* () {
|
|
101
|
+
// Create blocks on all chains to process pending XCM messages
|
|
102
|
+
// First create block on relay, then on parachains
|
|
103
|
+
yield* relay.createBlock();
|
|
104
|
+
for (const para of parachains.values()) {
|
|
105
|
+
yield* para.createBlock();
|
|
106
|
+
}
|
|
107
|
+
logger.debug("Processed XCM messages across all chains");
|
|
108
|
+
}),
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
// =============================================================================
|
|
112
|
+
// Launch Functions
|
|
113
|
+
// =============================================================================
|
|
114
|
+
/**
|
|
115
|
+
* Launch a multi-chain setup with manual cleanup
|
|
116
|
+
*
|
|
117
|
+
* @param config - Multi-chain configuration
|
|
118
|
+
* @returns Promise with multi-chain service and cleanup function
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```typescript
|
|
122
|
+
* const { service, cleanup } = await launchMultiChainEffect({
|
|
123
|
+
* relay: {
|
|
124
|
+
* type: "relay",
|
|
125
|
+
* endpoint: "wss://rpc.polkadot.io",
|
|
126
|
+
* port: 8000,
|
|
127
|
+
* },
|
|
128
|
+
* parachains: [
|
|
129
|
+
* {
|
|
130
|
+
* type: "parachain",
|
|
131
|
+
* paraId: 2000,
|
|
132
|
+
* endpoint: "wss://moonbeam.rpc.io",
|
|
133
|
+
* port: 8001,
|
|
134
|
+
* },
|
|
135
|
+
* ],
|
|
136
|
+
* });
|
|
137
|
+
*
|
|
138
|
+
* // Send XCM message
|
|
139
|
+
* await Effect.runPromise(service.sendUmp(2000, ["0x..."]));
|
|
140
|
+
*
|
|
141
|
+
* // Process messages
|
|
142
|
+
* await Effect.runPromise(service.processXcm());
|
|
143
|
+
*
|
|
144
|
+
* // Cleanup
|
|
145
|
+
* await cleanup();
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
export async function launchMultiChainEffect(config) {
|
|
149
|
+
const cleanups = [];
|
|
150
|
+
try {
|
|
151
|
+
// Launch relay chain
|
|
152
|
+
logger.debug(`Launching relay chain on port ${config.relay.port}`);
|
|
153
|
+
const relayResult = await launchChopsticksEffect(config.relay);
|
|
154
|
+
cleanups.push(relayResult.cleanup);
|
|
155
|
+
// Launch parachains
|
|
156
|
+
const parachains = new Map();
|
|
157
|
+
for (const paraConfig of config.parachains) {
|
|
158
|
+
logger.debug(`Launching parachain ${paraConfig.paraId} on port ${paraConfig.port}`);
|
|
159
|
+
const paraResult = await launchChopsticksEffect(paraConfig);
|
|
160
|
+
cleanups.push(paraResult.cleanup);
|
|
161
|
+
parachains.set(paraConfig.paraId, paraResult.result);
|
|
162
|
+
}
|
|
163
|
+
const service = createMultiChainService(relayResult.result, parachains);
|
|
164
|
+
return {
|
|
165
|
+
service,
|
|
166
|
+
cleanup: async () => {
|
|
167
|
+
logger.debug("Cleaning up multi-chain setup...");
|
|
168
|
+
// Cleanup in reverse order (parachains first, then relay)
|
|
169
|
+
for (const cleanupFn of cleanups.reverse()) {
|
|
170
|
+
await cleanupFn();
|
|
171
|
+
}
|
|
172
|
+
logger.debug("Multi-chain cleanup complete");
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
// If any launch fails, cleanup what was started
|
|
178
|
+
for (const cleanupFn of cleanups.reverse()) {
|
|
179
|
+
try {
|
|
180
|
+
await cleanupFn();
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
// Ignore cleanup errors during error handling
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
throw error;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Create a Layer for multi-chain setup
|
|
191
|
+
*
|
|
192
|
+
* @param config - Multi-chain configuration
|
|
193
|
+
* @returns Layer providing ChopsticksMultiChainService
|
|
194
|
+
*/
|
|
195
|
+
export const ChopsticksMultiChainLayer = (config) => Layer.scoped(ChopsticksMultiChainService, Effect.gen(function* () {
|
|
196
|
+
const cleanups = [];
|
|
197
|
+
// Launch relay chain
|
|
198
|
+
const relayResult = yield* Effect.tryPromise({
|
|
199
|
+
try: () => launchChopsticksEffect(config.relay),
|
|
200
|
+
catch: (cause) => new ChopsticksSetupError({
|
|
201
|
+
cause,
|
|
202
|
+
endpoint: getEndpointString(config.relay.endpoint),
|
|
203
|
+
}),
|
|
204
|
+
});
|
|
205
|
+
cleanups.push(Effect.tryPromise({
|
|
206
|
+
try: () => relayResult.cleanup(),
|
|
207
|
+
catch: () => undefined,
|
|
208
|
+
}).pipe(Effect.ignore));
|
|
209
|
+
// Launch parachains
|
|
210
|
+
const parachains = new Map();
|
|
211
|
+
for (const paraConfig of config.parachains) {
|
|
212
|
+
const paraResult = yield* Effect.tryPromise({
|
|
213
|
+
try: () => launchChopsticksEffect(paraConfig),
|
|
214
|
+
catch: (cause) => new ChopsticksSetupError({
|
|
215
|
+
cause,
|
|
216
|
+
endpoint: getEndpointString(paraConfig.endpoint),
|
|
217
|
+
}),
|
|
218
|
+
});
|
|
219
|
+
cleanups.push(Effect.tryPromise({
|
|
220
|
+
try: () => paraResult.cleanup(),
|
|
221
|
+
catch: () => undefined,
|
|
222
|
+
}).pipe(Effect.ignore));
|
|
223
|
+
parachains.set(paraConfig.paraId, paraResult.result);
|
|
224
|
+
}
|
|
225
|
+
// Register cleanup with scope finalizer
|
|
226
|
+
yield* Effect.addFinalizer(() => Effect.gen(function* () {
|
|
227
|
+
logger.debug("Finalizing multi-chain setup...");
|
|
228
|
+
for (const cleanup of cleanups.reverse()) {
|
|
229
|
+
yield* cleanup;
|
|
230
|
+
}
|
|
231
|
+
logger.debug("Multi-chain finalization complete");
|
|
232
|
+
}));
|
|
233
|
+
return createMultiChainService(relayResult.result, parachains);
|
|
234
|
+
}));
|
|
235
|
+
/**
|
|
236
|
+
* Helper to create a standard Polkadot + Moonbeam XCM testing setup
|
|
237
|
+
*
|
|
238
|
+
* @param relayPort - Port for relay chain (default: 8000)
|
|
239
|
+
* @param moonbeamPort - Port for Moonbeam parachain (default: 8001)
|
|
240
|
+
* @returns Multi-chain configuration
|
|
241
|
+
*/
|
|
242
|
+
export const createPolkadotMoonbeamConfig = (relayPort = 8000, moonbeamPort = 8001) => ({
|
|
243
|
+
relay: {
|
|
244
|
+
type: "relay",
|
|
245
|
+
endpoint: "wss://rpc.polkadot.io",
|
|
246
|
+
port: relayPort,
|
|
247
|
+
"build-block-mode": "Manual",
|
|
248
|
+
},
|
|
249
|
+
parachains: [
|
|
250
|
+
{
|
|
251
|
+
type: "parachain",
|
|
252
|
+
paraId: 2004, // Moonbeam on Polkadot
|
|
253
|
+
endpoint: "wss://wss.api.moonbeam.network",
|
|
254
|
+
port: moonbeamPort,
|
|
255
|
+
"build-block-mode": "Manual",
|
|
256
|
+
},
|
|
257
|
+
],
|
|
258
|
+
});
|
|
259
|
+
/**
|
|
260
|
+
* Helper to create a standard Kusama + Moonriver XCM testing setup
|
|
261
|
+
*
|
|
262
|
+
* @param relayPort - Port for relay chain (default: 8000)
|
|
263
|
+
* @param moonriverPort - Port for Moonriver parachain (default: 8001)
|
|
264
|
+
* @returns Multi-chain configuration
|
|
265
|
+
*/
|
|
266
|
+
export const createKusamaMoonriverConfig = (relayPort = 8000, moonriverPort = 8001) => ({
|
|
267
|
+
relay: {
|
|
268
|
+
type: "relay",
|
|
269
|
+
endpoint: "wss://kusama-rpc.polkadot.io",
|
|
270
|
+
port: relayPort,
|
|
271
|
+
"build-block-mode": "Manual",
|
|
272
|
+
},
|
|
273
|
+
parachains: [
|
|
274
|
+
{
|
|
275
|
+
type: "parachain",
|
|
276
|
+
paraId: 2023, // Moonriver on Kusama
|
|
277
|
+
endpoint: "wss://wss.api.moonriver.moonbeam.network",
|
|
278
|
+
port: moonriverPort,
|
|
279
|
+
"build-block-mode": "Manual",
|
|
280
|
+
},
|
|
281
|
+
],
|
|
282
|
+
});
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Effect-based Chopsticks Service for programmatic blockchain fork management
|
|
3
|
+
*
|
|
4
|
+
* This service provides a type-safe, Effect-based interface to @acala-network/chopsticks,
|
|
5
|
+
* replacing the previous CLI-subprocess approach with direct programmatic control.
|
|
6
|
+
*
|
|
7
|
+
* The configuration type (ChopsticksConfig) is imported directly from @acala-network/chopsticks
|
|
8
|
+
* to ensure it stays in sync with upstream changes and supports all config options like rpc-timeout.
|
|
9
|
+
*/
|
|
10
|
+
import { Context, Effect } from "effect";
|
|
11
|
+
import type { Blockchain, BuildBlockMode, fetchConfig } from "@acala-network/chopsticks";
|
|
12
|
+
import type { HexString } from "@polkadot/util/types";
|
|
13
|
+
/**
|
|
14
|
+
* The ChopsticksConfig type, derived from the fetchConfig return type.
|
|
15
|
+
*
|
|
16
|
+
* This ensures our type stays in sync with upstream chopsticks changes.
|
|
17
|
+
* The config uses kebab-case keys as defined by chopsticks (e.g., 'rpc-timeout',
|
|
18
|
+
* 'build-block-mode', 'mock-signature-host').
|
|
19
|
+
*/
|
|
20
|
+
export type ChopsticksConfig = Awaited<ReturnType<typeof fetchConfig>>;
|
|
21
|
+
declare const ChopsticksSetupError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
|
22
|
+
readonly _tag: "ChopsticksSetupError";
|
|
23
|
+
} & Readonly<A>;
|
|
24
|
+
/**
|
|
25
|
+
* Error thrown when chopsticks setup/initialization fails
|
|
26
|
+
*/
|
|
27
|
+
export declare class ChopsticksSetupError extends ChopsticksSetupError_base<{
|
|
28
|
+
readonly cause: unknown;
|
|
29
|
+
readonly endpoint?: string;
|
|
30
|
+
readonly block?: string | number;
|
|
31
|
+
}> {
|
|
32
|
+
}
|
|
33
|
+
declare const ChopsticksBlockError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
|
34
|
+
readonly _tag: "ChopsticksBlockError";
|
|
35
|
+
} & Readonly<A>;
|
|
36
|
+
/**
|
|
37
|
+
* Error thrown when block creation fails
|
|
38
|
+
*/
|
|
39
|
+
export declare class ChopsticksBlockError extends ChopsticksBlockError_base<{
|
|
40
|
+
readonly cause: unknown;
|
|
41
|
+
readonly operation: "newBlock" | "setHead" | "getBlock";
|
|
42
|
+
readonly blockIdentifier?: string | number;
|
|
43
|
+
}> {
|
|
44
|
+
}
|
|
45
|
+
declare const ChopsticksStorageError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
|
46
|
+
readonly _tag: "ChopsticksStorageError";
|
|
47
|
+
} & Readonly<A>;
|
|
48
|
+
/**
|
|
49
|
+
* Error thrown when storage operations fail
|
|
50
|
+
*/
|
|
51
|
+
export declare class ChopsticksStorageError extends ChopsticksStorageError_base<{
|
|
52
|
+
readonly cause: unknown;
|
|
53
|
+
readonly module: string;
|
|
54
|
+
readonly method: string;
|
|
55
|
+
}> {
|
|
56
|
+
}
|
|
57
|
+
declare const ChopsticksExtrinsicError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
|
58
|
+
readonly _tag: "ChopsticksExtrinsicError";
|
|
59
|
+
} & Readonly<A>;
|
|
60
|
+
/**
|
|
61
|
+
* Error thrown when extrinsic operations fail
|
|
62
|
+
*/
|
|
63
|
+
export declare class ChopsticksExtrinsicError extends ChopsticksExtrinsicError_base<{
|
|
64
|
+
readonly cause: unknown;
|
|
65
|
+
readonly operation: "submit" | "dryRun" | "validate";
|
|
66
|
+
readonly extrinsic?: string;
|
|
67
|
+
}> {
|
|
68
|
+
}
|
|
69
|
+
declare const ChopsticksXcmError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
|
70
|
+
readonly _tag: "ChopsticksXcmError";
|
|
71
|
+
} & Readonly<A>;
|
|
72
|
+
/**
|
|
73
|
+
* Error thrown when XCM message operations fail
|
|
74
|
+
*/
|
|
75
|
+
export declare class ChopsticksXcmError extends ChopsticksXcmError_base<{
|
|
76
|
+
readonly cause: unknown;
|
|
77
|
+
readonly messageType: "ump" | "dmp" | "hrmp";
|
|
78
|
+
readonly paraId?: number;
|
|
79
|
+
}> {
|
|
80
|
+
}
|
|
81
|
+
declare const ChopsticksCleanupError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
|
82
|
+
readonly _tag: "ChopsticksCleanupError";
|
|
83
|
+
} & Readonly<A>;
|
|
84
|
+
/**
|
|
85
|
+
* Error thrown when chopsticks cleanup/shutdown fails
|
|
86
|
+
*/
|
|
87
|
+
export declare class ChopsticksCleanupError extends ChopsticksCleanupError_base<{
|
|
88
|
+
readonly cause: unknown;
|
|
89
|
+
}> {
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Union type of all chopsticks errors for exhaustive handling
|
|
93
|
+
*/
|
|
94
|
+
export type ChopsticksError = ChopsticksSetupError | ChopsticksBlockError | ChopsticksStorageError | ChopsticksExtrinsicError | ChopsticksXcmError | ChopsticksCleanupError;
|
|
95
|
+
/**
|
|
96
|
+
* Result from creating a new block
|
|
97
|
+
*/
|
|
98
|
+
export interface BlockCreationResult {
|
|
99
|
+
/** The created block */
|
|
100
|
+
readonly block: {
|
|
101
|
+
readonly hash: HexString;
|
|
102
|
+
readonly number: number;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Parameters for creating a new block
|
|
107
|
+
*/
|
|
108
|
+
export interface BlockCreationParams {
|
|
109
|
+
/** Number of blocks to create */
|
|
110
|
+
readonly count?: number;
|
|
111
|
+
/** Target block number to create up to */
|
|
112
|
+
readonly to?: number;
|
|
113
|
+
/** Transactions to include */
|
|
114
|
+
readonly transactions?: HexString[];
|
|
115
|
+
/** UMP messages to include */
|
|
116
|
+
readonly ump?: Record<number, HexString[]>;
|
|
117
|
+
/** DMP messages to include */
|
|
118
|
+
readonly dmp?: Array<{
|
|
119
|
+
sentAt: number;
|
|
120
|
+
msg: HexString;
|
|
121
|
+
}>;
|
|
122
|
+
/** HRMP messages to include */
|
|
123
|
+
readonly hrmp?: Record<number, Array<{
|
|
124
|
+
sentAt: number;
|
|
125
|
+
data: HexString;
|
|
126
|
+
}>>;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Result from dry-running an extrinsic
|
|
130
|
+
*/
|
|
131
|
+
export interface DryRunResult {
|
|
132
|
+
/** Whether the extrinsic would succeed */
|
|
133
|
+
readonly success: boolean;
|
|
134
|
+
/** Storage changes that would occur */
|
|
135
|
+
readonly storageDiff: Array<[HexString, HexString | null]>;
|
|
136
|
+
/** Any error message if failed */
|
|
137
|
+
readonly error?: string;
|
|
138
|
+
}
|
|
139
|
+
declare const ChopsticksService_base: Context.TagClass<ChopsticksService, "ChopsticksService", {
|
|
140
|
+
/**
|
|
141
|
+
* Direct access to the underlying Blockchain instance.
|
|
142
|
+
* Use this for advanced operations not covered by the service methods.
|
|
143
|
+
*/
|
|
144
|
+
readonly chain: Blockchain;
|
|
145
|
+
/**
|
|
146
|
+
* The WebSocket address the chopsticks server is listening on
|
|
147
|
+
*/
|
|
148
|
+
readonly addr: string;
|
|
149
|
+
/**
|
|
150
|
+
* The port the chopsticks server is listening on
|
|
151
|
+
*/
|
|
152
|
+
readonly port: number;
|
|
153
|
+
/**
|
|
154
|
+
* Create one or more new blocks
|
|
155
|
+
*
|
|
156
|
+
* @param params - Optional block creation parameters
|
|
157
|
+
* @returns The created block information
|
|
158
|
+
*/
|
|
159
|
+
readonly createBlock: (params?: BlockCreationParams) => Effect.Effect<BlockCreationResult, ChopsticksBlockError>;
|
|
160
|
+
/**
|
|
161
|
+
* Set storage values directly
|
|
162
|
+
*
|
|
163
|
+
* @param params - Storage modification parameters
|
|
164
|
+
*/
|
|
165
|
+
readonly setStorage: (params: {
|
|
166
|
+
module: string;
|
|
167
|
+
method: string;
|
|
168
|
+
params: unknown[];
|
|
169
|
+
}) => Effect.Effect<void, ChopsticksStorageError>;
|
|
170
|
+
/**
|
|
171
|
+
* Submit an extrinsic to the transaction pool
|
|
172
|
+
*
|
|
173
|
+
* @param extrinsic - The encoded extrinsic
|
|
174
|
+
* @returns The extrinsic hash
|
|
175
|
+
*/
|
|
176
|
+
readonly submitExtrinsic: (extrinsic: HexString) => Effect.Effect<HexString, ChopsticksExtrinsicError>;
|
|
177
|
+
/**
|
|
178
|
+
* Dry-run an extrinsic without submitting it
|
|
179
|
+
*
|
|
180
|
+
* @param extrinsic - The encoded extrinsic or call data with address
|
|
181
|
+
* @param at - Optional block hash to dry-run at
|
|
182
|
+
* @returns The dry-run result
|
|
183
|
+
*/
|
|
184
|
+
readonly dryRunExtrinsic: (extrinsic: HexString | {
|
|
185
|
+
call: HexString;
|
|
186
|
+
address: string;
|
|
187
|
+
}, at?: HexString) => Effect.Effect<DryRunResult, ChopsticksExtrinsicError>;
|
|
188
|
+
/**
|
|
189
|
+
* Get a block by hash or number
|
|
190
|
+
*
|
|
191
|
+
* @param hashOrNumber - Block hash or number (defaults to head)
|
|
192
|
+
*/
|
|
193
|
+
readonly getBlock: (hashOrNumber?: HexString | number) => Effect.Effect<{
|
|
194
|
+
hash: HexString;
|
|
195
|
+
number: number;
|
|
196
|
+
} | undefined, ChopsticksBlockError>;
|
|
197
|
+
/**
|
|
198
|
+
* Set the head of the chain to a specific block
|
|
199
|
+
*
|
|
200
|
+
* @param hashOrNumber - Block hash or number to set as head
|
|
201
|
+
*/
|
|
202
|
+
readonly setHead: (hashOrNumber: HexString | number) => Effect.Effect<void, ChopsticksBlockError>;
|
|
203
|
+
/**
|
|
204
|
+
* Submit upward messages (parachain → relay chain)
|
|
205
|
+
*
|
|
206
|
+
* @param paraId - The parachain ID
|
|
207
|
+
* @param messages - Array of encoded UMP messages
|
|
208
|
+
*/
|
|
209
|
+
readonly submitUpwardMessages: (paraId: number, messages: HexString[]) => Effect.Effect<void, ChopsticksXcmError>;
|
|
210
|
+
/**
|
|
211
|
+
* Submit downward messages (relay chain → parachain)
|
|
212
|
+
*
|
|
213
|
+
* @param messages - Array of DMP messages
|
|
214
|
+
*/
|
|
215
|
+
readonly submitDownwardMessages: (messages: Array<{
|
|
216
|
+
sentAt: number;
|
|
217
|
+
msg: HexString;
|
|
218
|
+
}>) => Effect.Effect<void, ChopsticksXcmError>;
|
|
219
|
+
/**
|
|
220
|
+
* Submit horizontal messages (parachain → parachain)
|
|
221
|
+
*
|
|
222
|
+
* @param paraId - The source parachain ID
|
|
223
|
+
* @param messages - Array of HRMP messages
|
|
224
|
+
*/
|
|
225
|
+
readonly submitHorizontalMessages: (paraId: number, messages: Array<{
|
|
226
|
+
sentAt: number;
|
|
227
|
+
data: HexString;
|
|
228
|
+
}>) => Effect.Effect<void, ChopsticksXcmError>;
|
|
229
|
+
}>;
|
|
230
|
+
/**
|
|
231
|
+
* ChopsticksService provides programmatic access to a chopsticks blockchain fork.
|
|
232
|
+
*
|
|
233
|
+
* This service wraps the @acala-network/chopsticks library and exposes its
|
|
234
|
+
* functionality through Effect-based methods with proper error handling.
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```typescript
|
|
238
|
+
* const program = Effect.gen(function* () {
|
|
239
|
+
* const chopsticks = yield* ChopsticksService;
|
|
240
|
+
*
|
|
241
|
+
* // Create a new block
|
|
242
|
+
* const block = yield* chopsticks.createBlock();
|
|
243
|
+
* console.log(`Created block #${block.block.number}`);
|
|
244
|
+
*
|
|
245
|
+
* // Modify storage
|
|
246
|
+
* yield* chopsticks.setStorage({
|
|
247
|
+
* module: "System",
|
|
248
|
+
* method: "Account",
|
|
249
|
+
* params: [[address, { data: { free: "1000000000000" } }]]
|
|
250
|
+
* });
|
|
251
|
+
* });
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
254
|
+
export declare class ChopsticksService extends ChopsticksService_base {
|
|
255
|
+
}
|
|
256
|
+
declare const ChopsticksConfigTag_base: Context.TagClass<ChopsticksConfigTag, "ChopsticksConfig", {
|
|
257
|
+
port: number;
|
|
258
|
+
'build-block-mode': BuildBlockMode;
|
|
259
|
+
addr?: string | undefined;
|
|
260
|
+
host?: string | undefined;
|
|
261
|
+
endpoint?: string | string[] | undefined;
|
|
262
|
+
block?: string | number | null | undefined;
|
|
263
|
+
'import-storage'?: any;
|
|
264
|
+
'allow-unresolved-imports'?: boolean | undefined;
|
|
265
|
+
'mock-signature-host'?: boolean | undefined;
|
|
266
|
+
'max-memory-block-count'?: number | undefined;
|
|
267
|
+
db?: string | undefined;
|
|
268
|
+
'save-blocks'?: boolean | undefined;
|
|
269
|
+
'wasm-override'?: string | undefined;
|
|
270
|
+
genesis?: string | {
|
|
271
|
+
name: string;
|
|
272
|
+
id: string;
|
|
273
|
+
properties: {
|
|
274
|
+
ss58Format?: number | undefined;
|
|
275
|
+
tokenDecimals?: number | number[] | undefined;
|
|
276
|
+
tokenSymbol?: string | string[] | undefined;
|
|
277
|
+
};
|
|
278
|
+
genesis: {
|
|
279
|
+
raw: {
|
|
280
|
+
top: Record<string, string>;
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
} | undefined;
|
|
284
|
+
'chain-spec'?: string | {
|
|
285
|
+
name: string;
|
|
286
|
+
id: string;
|
|
287
|
+
properties: {
|
|
288
|
+
ss58Format?: number | undefined;
|
|
289
|
+
tokenDecimals?: number | number[] | undefined;
|
|
290
|
+
tokenSymbol?: string | string[] | undefined;
|
|
291
|
+
};
|
|
292
|
+
genesis: {
|
|
293
|
+
raw: {
|
|
294
|
+
top: Record<string, string>;
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
} | undefined;
|
|
298
|
+
timestamp?: number | undefined;
|
|
299
|
+
'registered-types'?: any;
|
|
300
|
+
'runtime-log-level'?: number | undefined;
|
|
301
|
+
'offchain-worker'?: boolean | undefined;
|
|
302
|
+
resume?: number | boolean | `0x${string}` | undefined;
|
|
303
|
+
'process-queued-messages'?: boolean | undefined;
|
|
304
|
+
'prefetch-storages'?: any;
|
|
305
|
+
'rpc-timeout'?: number | undefined;
|
|
306
|
+
}>;
|
|
307
|
+
/**
|
|
308
|
+
* Configuration service tag for dependency injection
|
|
309
|
+
*/
|
|
310
|
+
export declare class ChopsticksConfigTag extends ChopsticksConfigTag_base {
|
|
311
|
+
}
|
|
312
|
+
export {};
|
|
313
|
+
//# sourceMappingURL=ChopsticksService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChopsticksService.d.ts","sourceRoot":"","sources":["../../../src/services/chopsticks/ChopsticksService.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,OAAO,EAAQ,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,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;;;;OAKG;mCAC4B,CAC7B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,SAAS,EAAE,KAClB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAE5C;;;;OAIG;qCAC8B,CAC/B,QAAQ,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,SAAS,CAAA;KAAE,CAAC,KAChD,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAE5C;;;;;OAKG;uCACgC,CACjC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,SAAS,CAAA;KAAE,CAAC,KACjD,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,kBAAkB,CAAC;;AArIhD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,iBAAkB,SAAQ,sBA+GpC;CAAG;;;;;;;;;;;;;;;;;;;sBA7DD,CAAC;yBACuC,CAAC;uBAED,CAAC;;;;;;;;;;;;sBAOF,CAAC;yBAG1B,CAAC;uBAEY,CAAC;;;;;;;;;;;;;;;;;AAgDjC;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,wBAGtC;CAAG"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Effect-based Chopsticks Service for programmatic blockchain fork management
|
|
3
|
+
*
|
|
4
|
+
* This service provides a type-safe, Effect-based interface to @acala-network/chopsticks,
|
|
5
|
+
* replacing the previous CLI-subprocess approach with direct programmatic control.
|
|
6
|
+
*
|
|
7
|
+
* The configuration type (ChopsticksConfig) is imported directly from @acala-network/chopsticks
|
|
8
|
+
* to ensure it stays in sync with upstream changes and supports all config options like rpc-timeout.
|
|
9
|
+
*/
|
|
10
|
+
import { Context, Data } from "effect";
|
|
11
|
+
// =============================================================================
|
|
12
|
+
// Error Types
|
|
13
|
+
// =============================================================================
|
|
14
|
+
/**
|
|
15
|
+
* Error thrown when chopsticks setup/initialization fails
|
|
16
|
+
*/
|
|
17
|
+
export class ChopsticksSetupError extends Data.TaggedError("ChopsticksSetupError") {
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Error thrown when block creation fails
|
|
21
|
+
*/
|
|
22
|
+
export class ChopsticksBlockError extends Data.TaggedError("ChopsticksBlockError") {
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Error thrown when storage operations fail
|
|
26
|
+
*/
|
|
27
|
+
export class ChopsticksStorageError extends Data.TaggedError("ChopsticksStorageError") {
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Error thrown when extrinsic operations fail
|
|
31
|
+
*/
|
|
32
|
+
export class ChopsticksExtrinsicError extends Data.TaggedError("ChopsticksExtrinsicError") {
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Error thrown when XCM message operations fail
|
|
36
|
+
*/
|
|
37
|
+
export class ChopsticksXcmError extends Data.TaggedError("ChopsticksXcmError") {
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Error thrown when chopsticks cleanup/shutdown fails
|
|
41
|
+
*/
|
|
42
|
+
export class ChopsticksCleanupError extends Data.TaggedError("ChopsticksCleanupError") {
|
|
43
|
+
}
|
|
44
|
+
// =============================================================================
|
|
45
|
+
// Service Definition
|
|
46
|
+
// =============================================================================
|
|
47
|
+
/**
|
|
48
|
+
* ChopsticksService provides programmatic access to a chopsticks blockchain fork.
|
|
49
|
+
*
|
|
50
|
+
* This service wraps the @acala-network/chopsticks library and exposes its
|
|
51
|
+
* functionality through Effect-based methods with proper error handling.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* const program = Effect.gen(function* () {
|
|
56
|
+
* const chopsticks = yield* ChopsticksService;
|
|
57
|
+
*
|
|
58
|
+
* // Create a new block
|
|
59
|
+
* const block = yield* chopsticks.createBlock();
|
|
60
|
+
* console.log(`Created block #${block.block.number}`);
|
|
61
|
+
*
|
|
62
|
+
* // Modify storage
|
|
63
|
+
* yield* chopsticks.setStorage({
|
|
64
|
+
* module: "System",
|
|
65
|
+
* method: "Account",
|
|
66
|
+
* params: [[address, { data: { free: "1000000000000" } }]]
|
|
67
|
+
* });
|
|
68
|
+
* });
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export class ChopsticksService extends Context.Tag("ChopsticksService")() {
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Configuration service tag for dependency injection
|
|
75
|
+
*/
|
|
76
|
+
export class ChopsticksConfigTag extends Context.Tag("ChopsticksConfig")() {
|
|
77
|
+
}
|