Skip to content

Commit d5f7e6e

Browse files
authored
bugfix: parse boolean args in readContract (#627)
* bugfix: Refactor readContract function to parse arguments with boolean values
1 parent 150a775 commit d5f7e6e

File tree

1 file changed

+11
-4
lines changed
  • src/server/routes/contract/read

1 file changed

+11
-4
lines changed

src/server/routes/contract/read/read.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,17 @@ export async function readContract(fastify: FastifyInstance) {
2828
contractAddress,
2929
});
3030

31-
let returnData = await contract.call(
32-
functionName,
33-
args ? args.split(",") : [],
34-
);
31+
const parsedArgs = args?.split(",").map((arg) => {
32+
if (arg === "true") {
33+
return true;
34+
} else if (arg === "false") {
35+
return false;
36+
} else {
37+
return arg;
38+
}
39+
});
40+
41+
let returnData = await contract.call(functionName, parsedArgs ?? []);
3542
returnData = bigNumberReplacer(returnData);
3643

3744
reply.status(StatusCodes.OK).send({

0 commit comments

Comments
 (0)