Skip to content

Commit

Permalink
Merge pull request #53 from dwhiffing/bigint
Browse files Browse the repository at this point in the history
Uses strings for numeric arguments to avoid issues with numbers larger than MAX_SAFE_INTEGER
  • Loading branch information
dwhiffing authored Sep 11, 2024
2 parents 9428191 + da0d4c4 commit f096e54
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion components/EditContractModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ const FunctionDescriptionInput = ({

<div className="mt-2">
<div className="mb-2">
<Label htmlFor="name">Value</Label>
<Label htmlFor="name">Transaction Value</Label>
<Input
placeholder="Enter a description"
value={abiDescription.valueDescription}
Expand Down
12 changes: 5 additions & 7 deletions utils/generateToolFromABI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ const generateToolFromABI =
);

let schema: any = {};
schema.value = z.number().describe(abiDescription?.valueDescription ?? "");
schema.transactionValue = z
.string()
.describe(abiDescription?.valueDescription ?? "");

func.inputs.forEach((input) => {
const inputDescription =
Expand Down Expand Up @@ -87,11 +89,7 @@ const getInputSchema = (input: AbiParameter) => {
const castType = getInputCastType(input);

let zodType: IZodGeneric | ZodArray<IZodGeneric> =
castType === "bool"
? z.boolean()
: castType === "numeric"
? z.number()
: z.string();
castType === "bool" ? z.boolean() : z.string();

if (isArray) {
zodType = z.array(zodType);
Expand Down Expand Up @@ -145,7 +143,7 @@ const getToolFunction =
const txReceipt = await getTransactionReceipt({
contract: contract,
functionName: func.name,
value: args.value ?? 0,
value: args.transactionValue ?? 0,
args: ensuredArgOrder,
publicAddress,
});
Expand Down

0 comments on commit f096e54

Please sign in to comment.