Spaces:
Runtime error
Runtime error
Tales-Cunha
feat: refactor tester agent to PoCo LangGraph architecture and add synthetic benchmark
017c628 Download src/agents/tester/utils/parserUtils.ts from TALP-Project/multi-agent-smart-contracts: direct link, hf CLI and curl.
- Browser
- Download file 1 kB
-
https://huggingface.co/spaces/TALP-Project/multi-agent-smart-contracts/resolve/main/src/agents/tester/utils/parserUtils.ts
- Command line
-
hf download hf://spaces/TALP-Project/multi-agent-smart-contracts/src/agents/tester/utils/parserUtils.ts
-
curl -L -o parserUtils.ts https://huggingface.co/spaces/TALP-Project/multi-agent-smart-contracts/resolve/main/src/agents/tester/utils/parserUtils.ts
1 kB
| import * as parser from "@solidity-parser/parser"; | |
| export interface ConstructorInfo { | |
| parameters: string; | |
| } | |
| export function extractConstructor(sourceCode: string, contractName: string): ConstructorInfo | null { | |
| try { | |
| const ast = parser.parse(sourceCode, { range: true }); | |
| let constructorParams = ""; | |
| let found = false; | |
| parser.visit(ast, { | |
| ContractDefinition: (node) => { | |
| if (node.name === contractName) { | |
| for (const part of node.subNodes) { | |
| if (part.type === "FunctionDefinition" && (part as any).isConstructor) { | |
| found = true; | |
| if (part.range) { | |
| constructorParams = sourceCode.slice(part.range[0], part.range[1]).split("{")[0].trim(); | |
| } | |
| } | |
| } | |
| } | |
| } | |
| }); | |
| if (found) { | |
| return { | |
| parameters: constructorParams | |
| }; | |
| } | |
| } catch (e) { | |
| // console.warn("Failed to parse Solidity for constructor:", e); | |
| } | |
| return null; | |
| } | |