-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add balance to SwapAmountInput #548
Conversation
</div> | ||
<div className="flex w-full items-center justify-between"> | ||
<TokenChip token={token} /> | ||
{type === "from" && ( | ||
<button | ||
className="flex h-8 w-[58px] max-w-[200px] items-center rounded-[40px] bg-gray-100 px-3 py-2 text-base font-medium not-italic leading-6 text-gray-500" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the cn
utility here so you can split in two line
import { cn } from "../../utils/cn"; | ||
import { SwapContext } from "../context"; | ||
import type { SwapAmountInputReact } from "../types"; | ||
import { useBalance, type UseBalanceReturnType } from "wagmi"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
split this in two line, one for import useBalance and one for the type.
}); | ||
|
||
const roundedBalance = useMemo(() => { | ||
if (tokenBalanceData?.formatted && token?.address) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block can be his own utils getRoundedBalance
…issa.crane/token-balance
@@ -37,6 +40,17 @@ export function SwapAmountInput({ label, token, type }: SwapAmountInputReact) { | |||
return setFromToken; | |||
}, [type, setFromToken, setToToken]); | |||
|
|||
const balanceResponse: UseBalanceReturnType = useBalance({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abcrane123 let's refactor this later today. Thank you @kyhyco
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we address the useBalance for non-native tokens on a follow up PR
Rest looks good!
What changed? Why?
useBalance
hookNotes to reviewers
to
tokenHow has it been tested?