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,161 @@
|
|
|
1
|
+
import { alith, createAndFinalizeBlock, customWeb3Request, generateKeyringPair, } from "../../util/index.js";
|
|
2
|
+
import { Keyring } from "@polkadot/api";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import { createLogger } from "../../util/index.js";
|
|
5
|
+
import { setTimeout } from "node:timers/promises";
|
|
6
|
+
import { getEnvironmentFromConfig, isEthereumDevConfig } from "../../services/config/index.js";
|
|
7
|
+
import { extractError } from "../../api/testing/events.js";
|
|
8
|
+
import { MoonwallContext } from "../../cli/lib/globalContext.js";
|
|
9
|
+
import { vitestAutoUrl } from "../../cli/internal/providerFactories.js";
|
|
10
|
+
const logger = createLogger({ name: "DevTest" });
|
|
11
|
+
const debug = logger.debug.bind(logger);
|
|
12
|
+
export async function getDevProviderPath() {
|
|
13
|
+
const env = getEnvironmentFromConfig();
|
|
14
|
+
return env.connections
|
|
15
|
+
? env.connections[0].endpoints[0].replace("ws://", "http://")
|
|
16
|
+
: vitestAutoUrl();
|
|
17
|
+
}
|
|
18
|
+
function returnSigner(options) {
|
|
19
|
+
return options.signer && "privateKey" in options.signer && "type" in options.signer
|
|
20
|
+
? generateKeyringPair(options.signer.type, options.signer.privateKey)
|
|
21
|
+
: options.signer;
|
|
22
|
+
}
|
|
23
|
+
function returnDefaultSigner() {
|
|
24
|
+
return isEthereumDevConfig()
|
|
25
|
+
? alith
|
|
26
|
+
: new Keyring({ type: "sr25519" }).addFromUri("//Alice", {
|
|
27
|
+
name: "Alice default",
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export async function createDevBlock(context, options, transactions) {
|
|
31
|
+
const containsViem = !!(context.isEthereumChain &&
|
|
32
|
+
context.viem() &&
|
|
33
|
+
(await MoonwallContext.getContext()).providers.find((prov) => prov.type === "viem"));
|
|
34
|
+
const api = context.polkadotJs();
|
|
35
|
+
const originalBlockNumber = (await api.rpc.chain.getHeader()).number.toBigInt();
|
|
36
|
+
const signer = options.signer ? returnSigner(options) : returnDefaultSigner();
|
|
37
|
+
const results = [];
|
|
38
|
+
const txs = !transactions ? [] : Array.isArray(transactions) ? transactions : [transactions];
|
|
39
|
+
for await (const call of txs) {
|
|
40
|
+
if (typeof call === "string") {
|
|
41
|
+
// Ethereum
|
|
42
|
+
results.push({
|
|
43
|
+
type: "eth",
|
|
44
|
+
hash: containsViem
|
|
45
|
+
? (await context.viem().request({
|
|
46
|
+
method: "eth_sendRawTransaction",
|
|
47
|
+
params: [call],
|
|
48
|
+
})).result
|
|
49
|
+
: (await customWeb3Request(context.web3(), "eth_sendRawTransaction", [call]))
|
|
50
|
+
.result,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
else if (call.isSigned) {
|
|
54
|
+
const tx = api.tx(call);
|
|
55
|
+
debug(`- Signed: ${tx.method.section}.${tx.method.method}(${tx.args
|
|
56
|
+
.map((d) => d.toHuman())
|
|
57
|
+
.join("; ")}) [ nonce: ${tx.nonce}]`);
|
|
58
|
+
results.push({
|
|
59
|
+
type: "sub",
|
|
60
|
+
hash: (await call.send()).toString(),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
const tx = api.tx(call);
|
|
65
|
+
debug(`- Unsigned: ${tx.method.section}.${tx.method.method}(${tx.args
|
|
66
|
+
.map((d) => d.toHuman())
|
|
67
|
+
.join("; ")}) [ nonce: ${tx.nonce}]`);
|
|
68
|
+
results.push({
|
|
69
|
+
type: "sub",
|
|
70
|
+
hash: (await call.signAndSend(signer)).toString(),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const { parentHash, finalize } = options;
|
|
75
|
+
const blockResult = await createAndFinalizeBlock(api, parentHash, finalize);
|
|
76
|
+
// No need to extract events if no transactions
|
|
77
|
+
if (results.length === 0) {
|
|
78
|
+
return {
|
|
79
|
+
block: blockResult,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const allRecords = (await (await api.at(blockResult.hash)).query.system.events());
|
|
83
|
+
const blockData = await api.rpc.chain.getBlock(blockResult.hash);
|
|
84
|
+
const getExtIndex = (records, result) => {
|
|
85
|
+
if (result.type === "eth") {
|
|
86
|
+
const res = records
|
|
87
|
+
.find(({ phase, event: { section, method, data } }) => phase.isApplyExtrinsic &&
|
|
88
|
+
section === "ethereum" &&
|
|
89
|
+
method === "Executed" &&
|
|
90
|
+
data[2].toString() === result.hash)
|
|
91
|
+
?.phase?.asApplyExtrinsic?.toString();
|
|
92
|
+
return typeof res === "undefined" ? undefined : Number(res);
|
|
93
|
+
}
|
|
94
|
+
return blockData.block.extrinsics.findIndex((ext) => ext.hash.toHex() === result.hash);
|
|
95
|
+
};
|
|
96
|
+
const result = results.map((result) => {
|
|
97
|
+
const extrinsicIndex = getExtIndex(allRecords, result);
|
|
98
|
+
const extrinsicFound = typeof extrinsicIndex !== "undefined";
|
|
99
|
+
// We retrieve the events associated with the extrinsic
|
|
100
|
+
const events = allRecords.filter(({ phase }) => phase.isApplyExtrinsic && Number(phase.asApplyExtrinsic.toString()) === extrinsicIndex);
|
|
101
|
+
const failure = extractError(events);
|
|
102
|
+
return {
|
|
103
|
+
extrinsic: extrinsicFound ? blockData.block.extrinsics[extrinsicIndex] : null,
|
|
104
|
+
events,
|
|
105
|
+
error: failure &&
|
|
106
|
+
((failure.isModule && api.registry.findMetaError(failure.asModule)) ||
|
|
107
|
+
{ name: failure.toString() }),
|
|
108
|
+
successful: extrinsicFound && !failure,
|
|
109
|
+
hash: result.hash,
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
if (results.find((res) => res.type === "eth")) {
|
|
113
|
+
// Wait until new block is actually created
|
|
114
|
+
// max wait 2s
|
|
115
|
+
for (let i = 0; i < 1000; i++) {
|
|
116
|
+
const currentBlock = (await api.rpc.chain.getHeader()).number.toBigInt();
|
|
117
|
+
await setTimeout(30);
|
|
118
|
+
if (currentBlock > originalBlockNumber) {
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const actualEvents = result.flatMap((resp) => resp.events);
|
|
124
|
+
if (options.expectEvents && options.expectEvents.length > 0) {
|
|
125
|
+
const match = options.expectEvents.every((eEvt) => {
|
|
126
|
+
const found = actualEvents
|
|
127
|
+
.map((aEvt) => eEvt.is(aEvt.event))
|
|
128
|
+
.reduce((acc, curr) => acc || curr, false);
|
|
129
|
+
if (!found) {
|
|
130
|
+
const message = `Event ${chalk.bgWhiteBright.blackBright(eEvt.meta.name)} not present in block`;
|
|
131
|
+
if (options.logger) {
|
|
132
|
+
// Handle both pino Logger (has .error) and LogFn (callable)
|
|
133
|
+
if ("error" in options.logger) {
|
|
134
|
+
options.logger.error(message);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
options.logger(message);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
console.error(message);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return found;
|
|
145
|
+
});
|
|
146
|
+
if (!match) {
|
|
147
|
+
throw new Error("Expected events not present in block");
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (!options.allowFailures) {
|
|
151
|
+
for (const event of actualEvents) {
|
|
152
|
+
if (api.events.system.ExtrinsicFailed.is(event.event)) {
|
|
153
|
+
throw new Error("ExtrinsicFailed event detected, enable 'allowFailures' if this is expected.");
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
block: blockResult,
|
|
159
|
+
result: Array.isArray(transactions) ? result : result[0],
|
|
160
|
+
};
|
|
161
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/foundations/read-only/handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iCAAiC;AAGlE,eAAO,MAAM,eAAe,EAAE,iBAAiB,CAAC,WAAW,CA2C1D,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { MoonwallContext } from "../../cli/lib/globalContext.js";
|
|
2
|
+
export const readOnlyHandler = ({ testCases, context, testCase, logger, }) => {
|
|
3
|
+
testCases({
|
|
4
|
+
context: {
|
|
5
|
+
...context,
|
|
6
|
+
waitBlock: async (blocksToWaitFor = 1, chainName, mode = "quantity") => {
|
|
7
|
+
const ctx = await MoonwallContext.getContext();
|
|
8
|
+
const provider = chainName
|
|
9
|
+
? ctx.providers.find((prov) => prov.name === chainName && prov.type === "polkadotJs")
|
|
10
|
+
: ctx.providers.find((prov) => prov.type === "polkadotJs");
|
|
11
|
+
if (!provider) {
|
|
12
|
+
throw new Error("No PolkadotJs api found in provider config");
|
|
13
|
+
}
|
|
14
|
+
const api = provider.api;
|
|
15
|
+
const currentBlockNumber = (await api.rpc.chain.getBlock()).block.header.number.toNumber();
|
|
16
|
+
for (;;) {
|
|
17
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
18
|
+
const newBlockNumber = (await api.rpc.chain.getBlock()).block.header.number.toNumber();
|
|
19
|
+
if (mode === "quantity" && newBlockNumber >= currentBlockNumber + blocksToWaitFor) {
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
if (mode === "height" && newBlockNumber >= blocksToWaitFor) {
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
it: testCase,
|
|
29
|
+
log: logger.info.bind(logger),
|
|
30
|
+
logger,
|
|
31
|
+
});
|
|
32
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/foundations/zombie/handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAsB,iCAAiC;AAOtF,eAAO,MAAM,aAAa,EAAE,iBAAiB,CAAC,QAAQ,CA8GrD,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { upgradeRuntime } from "../../cli/lib/upgradeProcedures.js";
|
|
2
|
+
import { MoonwallContext } from "../../cli/lib/globalContext.js";
|
|
3
|
+
import { alith } from "../../util/index.js";
|
|
4
|
+
import { sendIpcMessage } from "./helpers.js";
|
|
5
|
+
export const zombieHandler = ({ testCases, context, testCase, logger, }) => {
|
|
6
|
+
testCases({
|
|
7
|
+
context: {
|
|
8
|
+
...context,
|
|
9
|
+
waitBlock: async (blocksToWaitFor = 1, chain = "parachain", mode = "quantity") => {
|
|
10
|
+
const ctx = await MoonwallContext.getContext();
|
|
11
|
+
const provider = ctx.providers.find((prov) => prov.name === chain);
|
|
12
|
+
if (!provider) {
|
|
13
|
+
throw new Error(`Provider '${chain}' not found`);
|
|
14
|
+
}
|
|
15
|
+
const api = provider.api;
|
|
16
|
+
const currentBlockNumber = (await api.rpc.chain.getBlock()).block.header.number.toNumber();
|
|
17
|
+
for (;;) {
|
|
18
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
19
|
+
const newBlockNumber = (await api.rpc.chain.getBlock()).block.header.number.toNumber();
|
|
20
|
+
if (mode === "quantity" && newBlockNumber >= currentBlockNumber + blocksToWaitFor) {
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
if (mode === "height" && newBlockNumber >= blocksToWaitFor) {
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
upgradeRuntime: async (options = {}) => {
|
|
29
|
+
const ctx = await MoonwallContext.getContext();
|
|
30
|
+
if (!ctx.rtUpgradePath) {
|
|
31
|
+
throw new Error("Runtime upgrade path not defined in moonwall config");
|
|
32
|
+
}
|
|
33
|
+
const provider = ctx.providers.find((prov) => prov.name === "parachain");
|
|
34
|
+
if (!provider) {
|
|
35
|
+
throw new Error(`Provider 'parachain' not found`);
|
|
36
|
+
}
|
|
37
|
+
const api = provider.api;
|
|
38
|
+
const params = {
|
|
39
|
+
runtimeName: options.runtimeName || "moonbase",
|
|
40
|
+
runtimeTag: options.runtimeTag || "local",
|
|
41
|
+
localPath: options.localPath || ctx.rtUpgradePath,
|
|
42
|
+
upgradeMethod: options.upgradeMethod || "Sudo",
|
|
43
|
+
waitMigration: options.waitMigration || true,
|
|
44
|
+
from: options.from || alith,
|
|
45
|
+
};
|
|
46
|
+
if (options.logger) {
|
|
47
|
+
params.logger = options.logger;
|
|
48
|
+
}
|
|
49
|
+
await upgradeRuntime(api, params);
|
|
50
|
+
},
|
|
51
|
+
restartNode: async (nodeName) => {
|
|
52
|
+
await sendIpcMessage({
|
|
53
|
+
text: `Restarting node ${nodeName}`,
|
|
54
|
+
cmd: "restart",
|
|
55
|
+
nodeName: nodeName,
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
pauseNode: async (nodeName) => {
|
|
59
|
+
await sendIpcMessage({
|
|
60
|
+
text: `Pausing node ${nodeName}`,
|
|
61
|
+
cmd: "pause",
|
|
62
|
+
nodeName: nodeName,
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
resumeNode: async (nodeName) => {
|
|
66
|
+
await sendIpcMessage({
|
|
67
|
+
text: `Resuming node ${nodeName}`,
|
|
68
|
+
cmd: "resume",
|
|
69
|
+
nodeName: nodeName,
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
killNode: async (nodeName) => {
|
|
73
|
+
await sendIpcMessage({
|
|
74
|
+
text: `Killing node ${nodeName}`,
|
|
75
|
+
cmd: "kill",
|
|
76
|
+
nodeName: nodeName,
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
isUp: async (nodeName) => {
|
|
80
|
+
const response = await sendIpcMessage({
|
|
81
|
+
text: `Checking if node ${nodeName} is up`,
|
|
82
|
+
cmd: "isup",
|
|
83
|
+
nodeName: nodeName,
|
|
84
|
+
});
|
|
85
|
+
return response.status === "success";
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
it: testCase,
|
|
89
|
+
log: logger.info.bind(logger),
|
|
90
|
+
logger,
|
|
91
|
+
});
|
|
92
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { LaunchConfig } from "@zombienet/orchestrator";
|
|
2
|
+
export declare function checkZombieBins(config: LaunchConfig): Promise<void>;
|
|
3
|
+
export declare function getZombieConfig(path: string): LaunchConfig;
|
|
4
|
+
export type CmdCodes = "restart" | "pause" | "resume" | "kill" | "isup" | "init" | "networkmap";
|
|
5
|
+
export type IPCRequestMessage = {
|
|
6
|
+
text: string;
|
|
7
|
+
cmd: CmdCodes;
|
|
8
|
+
nodeName?: string;
|
|
9
|
+
};
|
|
10
|
+
export type IPCResponseMessage = {
|
|
11
|
+
status: "success" | "failure";
|
|
12
|
+
result: boolean | object;
|
|
13
|
+
message: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function sendIpcMessage(message: IPCRequestMessage): Promise<IPCResponseMessage>;
|
|
16
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/foundations/zombie/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAQ5D,wBAAsB,eAAe,CAAC,MAAM,EAAE,YAAY,iBA4CzD;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAWb,YAAY,CAC1C;AAED,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,YAAY,CAAC;AAEhG,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,QAAQ,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC;IAC9B,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAsB,cAAc,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAqD5F"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import invariant from "tiny-invariant";
|
|
4
|
+
import { checkAccess, checkExists } from "../../cli/internal/fileCheckers.js";
|
|
5
|
+
import { setTimeout as timer } from "node:timers/promises";
|
|
6
|
+
import net from "node:net";
|
|
7
|
+
export async function checkZombieBins(config) {
|
|
8
|
+
const relayBinPath = config.relaychain.default_command;
|
|
9
|
+
if (!relayBinPath) {
|
|
10
|
+
throw new Error("No relayBinPath '[relaychain.default_command]' specified in zombie config");
|
|
11
|
+
}
|
|
12
|
+
await checkExists(relayBinPath);
|
|
13
|
+
checkAccess(relayBinPath);
|
|
14
|
+
if (config.parachains) {
|
|
15
|
+
const promises = config.parachains.map(async (para) => {
|
|
16
|
+
if (para.collator) {
|
|
17
|
+
if (!para.collator.command) {
|
|
18
|
+
throw new Error("No command found for collator, please check your zombienet config file for collator command");
|
|
19
|
+
}
|
|
20
|
+
await checkExists(para.collator.command);
|
|
21
|
+
checkAccess(para.collator.command);
|
|
22
|
+
}
|
|
23
|
+
if (para.collators) {
|
|
24
|
+
for (const coll of para.collators) {
|
|
25
|
+
if (!coll.command) {
|
|
26
|
+
throw new Error("No command found for collators, please check your zombienet config file for collators command");
|
|
27
|
+
}
|
|
28
|
+
await checkExists(coll.command);
|
|
29
|
+
checkAccess(coll.command);
|
|
30
|
+
}
|
|
31
|
+
// para.collators.forEach((coll) => {
|
|
32
|
+
// if (!coll.command) {
|
|
33
|
+
// throw new Error(
|
|
34
|
+
// "No command found for collators, please check your zombienet config file for para collators command"
|
|
35
|
+
// );
|
|
36
|
+
// }
|
|
37
|
+
// checkExists(coll.command);
|
|
38
|
+
// checkAccess(coll.command);
|
|
39
|
+
// });
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
await Promise.all(promises);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export function getZombieConfig(path) {
|
|
46
|
+
const fsResult = fs.existsSync(path);
|
|
47
|
+
if (!fsResult) {
|
|
48
|
+
throw new Error(`No ZombieConfig file found at location: ${path} \n Are you sure your ${chalk.bgWhiteBright.blackBright("moonwall.config.json")} file has the correct "configPath" in zombieSpec?`);
|
|
49
|
+
}
|
|
50
|
+
const buffer = fs.readFileSync(path, "utf-8");
|
|
51
|
+
return JSON.parse(buffer);
|
|
52
|
+
}
|
|
53
|
+
export async function sendIpcMessage(message) {
|
|
54
|
+
return new Promise(async (resolve, reject) => {
|
|
55
|
+
let response;
|
|
56
|
+
const ipcPath = process.env.MOON_IPC_SOCKET;
|
|
57
|
+
invariant(ipcPath, "No IPC path found. This is a bug, please report it.");
|
|
58
|
+
const client = net.createConnection({ path: ipcPath }, () => {
|
|
59
|
+
console.log("📨 Successfully connected to IPC server");
|
|
60
|
+
});
|
|
61
|
+
client.on("error", (err) => {
|
|
62
|
+
console.error("📨 IPC client connection error:", err);
|
|
63
|
+
});
|
|
64
|
+
// Listener to return control flow after server responds
|
|
65
|
+
client.on("data", async (data) => {
|
|
66
|
+
response = JSON.parse(data.toString());
|
|
67
|
+
if (response.status === "success") {
|
|
68
|
+
client.end();
|
|
69
|
+
for (let i = 0;; i++) {
|
|
70
|
+
if (client.closed) {
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
if (i > 100) {
|
|
74
|
+
reject(new Error("Closing IPC connection failed"));
|
|
75
|
+
}
|
|
76
|
+
await timer(200);
|
|
77
|
+
}
|
|
78
|
+
resolve(response);
|
|
79
|
+
}
|
|
80
|
+
if (response.status === "failure") {
|
|
81
|
+
reject(new Error(JSON.stringify(response)));
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
for (let i = 0;; i++) {
|
|
85
|
+
if (!client.connecting) {
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
if (i > 100) {
|
|
89
|
+
reject(new Error(`Connection to ${ipcPath} failed`));
|
|
90
|
+
}
|
|
91
|
+
await timer(200);
|
|
92
|
+
}
|
|
93
|
+
await new Promise((resolve) => {
|
|
94
|
+
client.write(JSON.stringify(message), () => resolve("Sent!"));
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Moonwall - Blockchain Testing Framework
|
|
3
|
+
*
|
|
4
|
+
* Public API exports for test consumers
|
|
5
|
+
*/
|
|
6
|
+
export * from "./api/types/index.js";
|
|
7
|
+
export { afterAll, afterEach, beforeAll, beforeEach, expect } from "vitest";
|
|
8
|
+
export * from "./util/index.js";
|
|
9
|
+
export { describeSuite } from "./cli/lib/runnerContext.js";
|
|
10
|
+
export { getEnvironmentFromConfig, importAsyncConfig, importConfig, isEthereumDevConfig, isEthereumZombieConfig, } from "./cli/lib/configReader.js";
|
|
11
|
+
export { MoonwallContext, contextCreator } from "./cli/lib/globalContext.js";
|
|
12
|
+
export { customDevRpcRequest } from "./cli/lib/rpcFunctions.js";
|
|
13
|
+
export { fetchCompiledContract, deployCreateCompiledContract, interactWithContract, interactWithPrecompileContract, } from "./cli/lib/contractFunctions.js";
|
|
14
|
+
export { whiteListedTrack, notePreimage, instantFastTrack, execCouncilProposal, execTechnicalCommitteeProposal, execOpenTechCommitteeProposal, proposeReferendaAndDeposit, dispatchAsGeneralAdmin, } from "./cli/lib/governanceProcedures.js";
|
|
15
|
+
export { ApiPromise } from "@polkadot/api";
|
|
16
|
+
export { default as Web3 } from "web3";
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,qCAAqC;AAKrC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAM5E,gCAAgC;AAMhC,OAAO,EAAE,aAAa,EAAE,mCAAmC;AAG3D,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,YAAY,EACZ,mBAAmB,EACnB,sBAAsB,GACvB,kCAAkC;AAMnC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,mCAAmC;AAK7E,OAAO,EAAE,mBAAmB,EAAE,kCAAkC;AAKhE,OAAO,EACL,qBAAqB,EACrB,4BAA4B,EAC5B,oBAAoB,EACpB,8BAA8B,GAC/B,uCAAuC;AAKxC,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,EACnB,8BAA8B,EAC9B,6BAA6B,EAC7B,0BAA0B,EAC1B,sBAAsB,GACvB,0CAA0C;AAK3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Moonwall - Blockchain Testing Framework
|
|
3
|
+
*
|
|
4
|
+
* Public API exports for test consumers
|
|
5
|
+
*/
|
|
6
|
+
// =============================================================================
|
|
7
|
+
// Type Definitions
|
|
8
|
+
// =============================================================================
|
|
9
|
+
export * from "./api/types/index.js";
|
|
10
|
+
// =============================================================================
|
|
11
|
+
// Vitest Re-exports
|
|
12
|
+
// =============================================================================
|
|
13
|
+
export { afterAll, afterEach, beforeAll, beforeEach, expect } from "vitest";
|
|
14
|
+
// =============================================================================
|
|
15
|
+
// Testing Utilities
|
|
16
|
+
// =============================================================================
|
|
17
|
+
// Block creation, event filtering, contract helpers, etc.
|
|
18
|
+
export * from "./util/index.js";
|
|
19
|
+
// =============================================================================
|
|
20
|
+
// Test Runner
|
|
21
|
+
// =============================================================================
|
|
22
|
+
// describeSuite - Primary test suite creation function
|
|
23
|
+
export { describeSuite } from "./cli/lib/runnerContext.js";
|
|
24
|
+
// Configuration loading
|
|
25
|
+
export { getEnvironmentFromConfig, importAsyncConfig, importConfig, isEthereumDevConfig, isEthereumZombieConfig, } from "./cli/lib/configReader.js";
|
|
26
|
+
// =============================================================================
|
|
27
|
+
// Context (Advanced Use)
|
|
28
|
+
// =============================================================================
|
|
29
|
+
// For advanced users who need direct access to the Moonwall context
|
|
30
|
+
export { MoonwallContext, contextCreator } from "./cli/lib/globalContext.js";
|
|
31
|
+
// =============================================================================
|
|
32
|
+
// RPC Utilities
|
|
33
|
+
// =============================================================================
|
|
34
|
+
export { customDevRpcRequest } from "./cli/lib/rpcFunctions.js";
|
|
35
|
+
// =============================================================================
|
|
36
|
+
// Contract Utilities
|
|
37
|
+
// =============================================================================
|
|
38
|
+
export { fetchCompiledContract, deployCreateCompiledContract, interactWithContract, interactWithPrecompileContract, } from "./cli/lib/contractFunctions.js";
|
|
39
|
+
// =============================================================================
|
|
40
|
+
// Governance Utilities
|
|
41
|
+
// =============================================================================
|
|
42
|
+
export { whiteListedTrack, notePreimage, instantFastTrack, execCouncilProposal, execTechnicalCommitteeProposal, execOpenTechCommitteeProposal, proposeReferendaAndDeposit, dispatchAsGeneralAdmin, } from "./cli/lib/governanceProcedures.js";
|
|
43
|
+
// =============================================================================
|
|
44
|
+
// Re-exports from Dependencies (for convenience)
|
|
45
|
+
// =============================================================================
|
|
46
|
+
export { ApiPromise } from "@polkadot/api";
|
|
47
|
+
export { default as Web3 } from "web3";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/internal/common.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,GAAG,EAAO,EAClB,SAAS,GAAE,MAAc,GACxB,OAAO,CAAC,GAAG,CAAC,CA6Cd"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export function normalizeUrlToHttps(url) {
|
|
2
|
+
return url.replace(/^ws(s)?:/, "http$1:");
|
|
3
|
+
}
|
|
4
|
+
export async function directRpcRequest(endpoint, method, params = [], timeoutMs = 10000 // Default 10 second timeout
|
|
5
|
+
) {
|
|
6
|
+
const data = {
|
|
7
|
+
jsonrpc: "2.0",
|
|
8
|
+
id: 1,
|
|
9
|
+
method,
|
|
10
|
+
params,
|
|
11
|
+
};
|
|
12
|
+
if (endpoint.startsWith("ws")) {
|
|
13
|
+
console.log("you've passed a websocket to fetch, is this intended?");
|
|
14
|
+
}
|
|
15
|
+
// Create an AbortController for timeout
|
|
16
|
+
const controller = new AbortController();
|
|
17
|
+
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
|
|
18
|
+
try {
|
|
19
|
+
const response = await fetch(endpoint, {
|
|
20
|
+
method: "POST",
|
|
21
|
+
body: JSON.stringify(data),
|
|
22
|
+
headers: { "Content-Type": "application/json" },
|
|
23
|
+
signal: controller.signal,
|
|
24
|
+
});
|
|
25
|
+
clearTimeout(timeoutId);
|
|
26
|
+
const responseData = (await response.json());
|
|
27
|
+
if (responseData.error) {
|
|
28
|
+
throw new Error(responseData.error.message);
|
|
29
|
+
}
|
|
30
|
+
return responseData.result;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
clearTimeout(timeoutId);
|
|
34
|
+
if (error.name === "AbortError") {
|
|
35
|
+
throw new Error(`RPC request to ${endpoint} timed out after ${timeoutMs}ms (method: ${method})`, { cause: error });
|
|
36
|
+
}
|
|
37
|
+
throw new Error(`RPC request to ${endpoint} failed (method: ${method}): ${error.message}`, {
|
|
38
|
+
cause: error,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/internal/index.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,OAAO,EACL,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,KAAK,MAAM,EACX,KAAK,aAAa,GACnB,oBAAoB;AACrB,6BAA6B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import pino from "pino";
|
|
2
|
+
import type { Logger } from "pino";
|
|
3
|
+
export interface LoggerOptions {
|
|
4
|
+
name: string;
|
|
5
|
+
level?: string;
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function createLogger(options: LoggerOptions): Logger;
|
|
9
|
+
export declare function getLogger(name: string): Logger | undefined;
|
|
10
|
+
export declare function clearLoggers(): void;
|
|
11
|
+
export declare function setLoggerEnabled(pattern: string, enabled: boolean): void;
|
|
12
|
+
/**
|
|
13
|
+
* Callable logger type - a function that logs at info level with access to the underlying pino Logger
|
|
14
|
+
*/
|
|
15
|
+
export interface CallableLogger {
|
|
16
|
+
(message: string): void;
|
|
17
|
+
/** Log at info level (alias for calling the logger directly) */
|
|
18
|
+
info: (message: string) => void;
|
|
19
|
+
/** The underlying pino Logger for advanced usage */
|
|
20
|
+
pino: pino.Logger;
|
|
21
|
+
}
|
|
22
|
+
export declare function setupLogger(name: string): CallableLogger;
|
|
23
|
+
export type { Logger } from "pino";
|
|
24
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/internal/logger.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAGnC,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAuBD,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAqB3D;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE1D;AAED,wBAAgB,YAAY,IAAI,IAAI,CAEnC;AAGD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAQxE;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,gEAAgE;IAChE,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,oDAAoD;IACpD,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;CACnB;AAID,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAexD;AAGD,YAAY,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import pino from "pino";
|
|
2
|
+
import pinoPretty from "pino-pretty";
|
|
3
|
+
const logLevel = process.env.LOG_LEVEL || "info";
|
|
4
|
+
// Create pretty stream for all contexts
|
|
5
|
+
const prettyStream = pinoPretty({
|
|
6
|
+
colorize: true,
|
|
7
|
+
translateTime: "HH:MM:ss.l",
|
|
8
|
+
ignore: "pid,hostname",
|
|
9
|
+
sync: true, // Important for worker threads
|
|
10
|
+
});
|
|
11
|
+
const pinoOptions = {
|
|
12
|
+
level: logLevel,
|
|
13
|
+
formatters: {
|
|
14
|
+
level: (label) => {
|
|
15
|
+
return { level: label };
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
const loggers = new Map();
|
|
20
|
+
export function createLogger(options) {
|
|
21
|
+
const { name, level = logLevel, enabled = true } = options;
|
|
22
|
+
const existingLogger = loggers.get(name);
|
|
23
|
+
if (existingLogger) {
|
|
24
|
+
return existingLogger;
|
|
25
|
+
}
|
|
26
|
+
const loggerConfig = {
|
|
27
|
+
name,
|
|
28
|
+
level,
|
|
29
|
+
enabled,
|
|
30
|
+
formatters: pinoOptions.formatters,
|
|
31
|
+
};
|
|
32
|
+
// Create logger with pretty stream
|
|
33
|
+
const logger = pino(loggerConfig, prettyStream);
|
|
34
|
+
loggers.set(name, logger);
|
|
35
|
+
return logger;
|
|
36
|
+
}
|
|
37
|
+
export function getLogger(name) {
|
|
38
|
+
return loggers.get(name);
|
|
39
|
+
}
|
|
40
|
+
export function clearLoggers() {
|
|
41
|
+
loggers.clear();
|
|
42
|
+
}
|
|
43
|
+
// Helper function to enable/disable specific loggers
|
|
44
|
+
export function setLoggerEnabled(pattern, enabled) {
|
|
45
|
+
const regex = new RegExp(pattern.replace(/\*/g, ".*"));
|
|
46
|
+
loggers.forEach((logger, name) => {
|
|
47
|
+
if (regex.test(name)) {
|
|
48
|
+
logger.level = enabled ? logLevel : "silent";
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
// Compatibility layer for the existing setupLogger function
|
|
53
|
+
// Returns a callable function that logs at info level
|
|
54
|
+
export function setupLogger(name) {
|
|
55
|
+
const logger = createLogger({
|
|
56
|
+
name: `test:${name}`,
|
|
57
|
+
enabled: process.argv.includes("--printlogs"),
|
|
58
|
+
});
|
|
59
|
+
// Create a callable function that wraps logger.info
|
|
60
|
+
const logFn = (message) => logger.info(message);
|
|
61
|
+
const callableLogger = logFn;
|
|
62
|
+
// Attach .info as alias and the underlying pino logger
|
|
63
|
+
callableLogger.info = logFn;
|
|
64
|
+
callableLogger.pino = logger;
|
|
65
|
+
return callableLogger;
|
|
66
|
+
}
|