Spaces:
Runtime error
Runtime error
Download src/utils/forgeSandbox.ts from TALP-Project/multi-agent-smart-contracts: direct link, hf CLI and curl.
- Browser
- Download file 900 Bytes
-
https://huggingface.co/spaces/TALP-Project/multi-agent-smart-contracts/resolve/main/src/utils/forgeSandbox.ts
- Command line
-
hf download hf://spaces/TALP-Project/multi-agent-smart-contracts/src/utils/forgeSandbox.ts
-
curl -L -o forgeSandbox.ts https://huggingface.co/spaces/TALP-Project/multi-agent-smart-contracts/resolve/main/src/utils/forgeSandbox.ts
900 Bytes
| import fs from "node:fs/promises"; | |
| import path from "node:path"; | |
| import { execSync } from "node:child_process"; | |
| export async function createEmptyFoundryProject(targetDir: string, sourceCode: string, contractName: string) { | |
| await fs.mkdir(targetDir, { recursive: true }); | |
| execSync("forge init --no-git --force", { | |
| cwd: targetDir, | |
| env: { ...process.env } // Deixa o PATH nativo agir (configurado pelo bash ou Dockerfile) | |
| }); | |
| // Clean up default files | |
| await fs.rm(path.join(targetDir, "src", "Counter.sol"), { force: true }); | |
| await fs.rm(path.join(targetDir, "test", "Counter.t.sol"), { force: true }); | |
| await fs.rm(path.join(targetDir, "script", "Counter.s.sol"), { force: true }); | |
| // Write the vulnerable contract source | |
| const sourcePath = path.join(targetDir, "src", `${contractName}.sol`); | |
| await fs.writeFile(sourcePath, sourceCode, "utf8"); | |
| return sourcePath; | |
| } | |