Skip to content

Commit

Permalink
hadnle tuple arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
karooolis committed Jan 23, 2025
1 parent 63089cb commit b7d229b
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ export function FunctionField({ worldAbi, functionAbi }: Props) {
const [txHash, setTxHash] = useState<Hex>();
const txUrl = blockExplorerTransactionUrl({ hash: txHash, chainId });

// Tuples are mapped to e.g. "[int16, int16, int16]" to inform the user what to input
const inputLabels = functionAbi.inputs.map((input) =>
input.type === "tuple" && "components" in input
? `[${input.components.map((c) => c.type).join(", ")}]`
: input.type,
);
const inputLabels = functionAbi.inputs.map((input) => {
if (input.type === "tuple" && "components" in input) {
return `[${input.components.map((c) => c.type).join(", ")}]`;
} else if (input.type === "tuple[]" && "components" in input) {
return `[${input.components.map((c) => c.type).join(", ")}][]`;
}
return input.type;
});

const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
Expand Down

0 comments on commit b7d229b

Please sign in to comment.