forked from latticexyz/mud
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(recs): clean values in indexer before using
fix(std-client): usage of hasEntity feat: upgraded so we are at version parody with voxel-aw replace pnpm with yarn generate the iworld factory using world/iworld.sol vs iworld.sol feat: add new createNamespace param to deploy cmd feat: add optional address fix: add comments loudly show errors estimate gas override feat: changed default behaviour to mirror the canonical mud feat: fix estimate gas default val feat: code to interact with our custom chain feat: added tenet testnet revert chain-id to testnet id minor lockfile update Update tenetTestnet.ts add default modules flag feat(cli): add gas limit expose getTransactionResult await tx reduced flag rm tenet testnet fix(world): snapsync incorrect index for records
- Loading branch information
1 parent
03012e6
commit 0494dab
Showing
34 changed files
with
367 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
import { chromium, Browser, Page } from "@playwright/test"; | ||
import { execa, ExecaChildProcess } from "execa"; | ||
import chalk from "chalk"; | ||
import { createServer } from "vite"; | ||
import type { ViteDevServer } from "vite"; | ||
|
||
export function startAnvil(port: number): ExecaChildProcess { | ||
return execa("anvil", [ | ||
"-b", | ||
"1", | ||
"--block-base-fee-per-gas", | ||
"0", | ||
"--gas-limit", | ||
"20000000", | ||
"--port", | ||
String(port), | ||
]); | ||
} | ||
|
||
export function deployContracts(rpc: string): ExecaChildProcess { | ||
const deploymentProcess = execa("yarn", ["mud", "deploy", "--rpc", rpc], { cwd: "../contracts", stdio: "pipe" }); | ||
deploymentProcess.stdout?.on("data", (data) => { | ||
console.log(chalk.blueBright("[mud deploy]:"), data.toString()); | ||
}); | ||
|
||
deploymentProcess.stderr?.on("data", (data) => { | ||
console.error(chalk.blueBright("[mud deploy error]:"), data.toString()); | ||
}); | ||
return deploymentProcess; | ||
} | ||
|
||
export async function startViteServer(): Promise<ViteDevServer> { | ||
// TODO this should probably be preview instead of dev server | ||
const mode = "development"; | ||
const server = await createServer({ | ||
mode, | ||
server: { port: 3000 }, | ||
root: "../client-vanilla", | ||
}); | ||
await server.listen(); | ||
return server; | ||
} | ||
|
||
export async function startBrowserAndPage( | ||
reportError: (error: string) => void | ||
): Promise<{ browser: Browser; page: Page }> { | ||
// open browser page | ||
const browser = await chromium.launch(); | ||
const page = await browser.newPage(); | ||
|
||
// log uncaught errors in the browser page (browser and test consoles are separate) | ||
page.on("pageerror", (err) => { | ||
console.log(chalk.yellow("[browser page error]:"), err.message); | ||
}); | ||
|
||
// log browser's console logs | ||
page.on("console", (msg) => { | ||
if (msg.text().toLowerCase().includes("error")) { | ||
const errorMessage = chalk.yellowBright("[browser error]:") + chalk.red(msg.text()); | ||
console.log(errorMessage); | ||
reportError(errorMessage); | ||
} else { | ||
console.log(chalk.yellowBright("[browser console]:"), msg.text()); | ||
} | ||
}); | ||
|
||
return { browser, page }; | ||
} | ||
|
||
export function syncMODE(reportError: (error: string) => void) { | ||
let resolve: () => void; | ||
let reject: (reason?: string) => void; | ||
|
||
console.log(chalk.magenta("[mode]:"), "start syncing"); | ||
|
||
const modeProcess = execa("./bin/mode", ["-config", "config.mode.yaml"], { | ||
cwd: "../../../packages/services", | ||
stdio: "pipe", | ||
}); | ||
|
||
modeProcess.on("error", (error) => { | ||
const errorMessage = chalk.magenta("[mode error]:", error); | ||
console.log(errorMessage); | ||
reportError(errorMessage); | ||
reject(errorMessage); | ||
}); | ||
|
||
modeProcess.stdout?.on("data", (data) => { | ||
const dataString = data.toString(); | ||
const errors = extractLineContaining("ERROR", dataString).join("\n"); | ||
if (errors) { | ||
console.log(chalk.magenta("[mode error]:", errors)); | ||
reject(errors); | ||
} | ||
console.log(chalk.magentaBright("[mode postgres]:", dataString)); | ||
}); | ||
|
||
modeProcess.stderr?.on("data", (data) => { | ||
const dataString = data.toString(); | ||
const modeErrors = extractLineContaining("ERROR", dataString).join("\n"); | ||
if (modeErrors) { | ||
const errorMessage = chalk.magenta("[mode error]:", modeErrors); | ||
console.log(errorMessage); | ||
reportError(errorMessage); | ||
reject(modeErrors); | ||
} | ||
if (data.toString().includes("finished syncing")) { | ||
console.log(chalk.magenta("[mode]:"), "done syncing"); | ||
// Wait for 2s after MODE is done syncing to avoid race conditions | ||
// with the first block number not being available yet | ||
setTimeout(resolve, 2000); | ||
} | ||
console.log(chalk.magentaBright("[mode ingress]:", dataString)); | ||
}); | ||
|
||
return { | ||
doneSyncing: new Promise<void>((res, rej) => { | ||
resolve = res; | ||
reject = rej; | ||
}), | ||
process: modeProcess, | ||
}; | ||
} | ||
|
||
function extractLineContaining(containing: string, log: string): string[] { | ||
const pattern = new RegExp(`^.*${containing}.*?$`, "gm"); | ||
return log.match(pattern) ?? []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.