From 7495ff3c40a9cc7d7fd2d34e032cea84bd30e208 Mon Sep 17 00:00:00 2001 From: lukaw3d Date: Thu, 19 Sep 2024 00:18:51 +0200 Subject: [PATCH] Simplify IntegerInput: remove bigint type --- .../debug/_components/contract/WriteOnlyFunctionForm.tsx | 2 +- .../components/scaffold-eth/Input/IntegerInput.tsx | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/nextjs/app/debug/_components/contract/WriteOnlyFunctionForm.tsx b/packages/nextjs/app/debug/_components/contract/WriteOnlyFunctionForm.tsx index b8e8f8490..c7b0e6740 100644 --- a/packages/nextjs/app/debug/_components/contract/WriteOnlyFunctionForm.tsx +++ b/packages/nextjs/app/debug/_components/contract/WriteOnlyFunctionForm.tsx @@ -33,7 +33,7 @@ export const WriteOnlyFunctionForm = ({ inheritedFrom, }: WriteOnlyFunctionFormProps) => { const [form, setForm] = useState>(() => getInitialFormState(abiFunction)); - const [txValue, setTxValue] = useState(""); + const [txValue, setTxValue] = useState(""); const { chain } = useAccount(); const writeTxn = useTransactor(); const { targetNetwork } = useTargetNetwork(); diff --git a/packages/nextjs/components/scaffold-eth/Input/IntegerInput.tsx b/packages/nextjs/components/scaffold-eth/Input/IntegerInput.tsx index 496c51126..5ec38be60 100644 --- a/packages/nextjs/components/scaffold-eth/Input/IntegerInput.tsx +++ b/packages/nextjs/components/scaffold-eth/Input/IntegerInput.tsx @@ -1,8 +1,8 @@ import { useCallback, useEffect, useState } from "react"; -import { parseUnits } from "viem"; +import { parseEther } from "viem"; import { CommonInputProps, InputBase, IntegerVariant, isValidInteger } from "~~/components/scaffold-eth"; -type IntegerInputProps = CommonInputProps & { +type IntegerInputProps = CommonInputProps & { variant?: IntegerVariant; disableMultiplyBy1e18?: boolean; }; @@ -21,10 +21,7 @@ export const IntegerInput = ({ if (!value) { return; } - if (typeof value === "bigint") { - return onChange(value * 10n ** 18n); - } - return onChange(parseUnits(value, 18)); + return onChange(parseEther(value).toString()); }, [onChange, value]); useEffect(() => {