) => {
if (isValidAmount(event.target.value)) {
- setAmount(event.target.value);
+ setAmount?.(event.target.value);
}
},
[setAmount],
@@ -21,7 +21,7 @@ export function SwapAmountInput({
const handleMaxButtonClick = useCallback(() => {
if (tokenBalance && isValidAmount(tokenBalance)) {
- setAmount(tokenBalance);
+ setAmount?.(tokenBalance);
}
}, [tokenBalance, setAmount]);
diff --git a/src/swap/components/SwapButton.tsx b/src/swap/components/SwapButton.tsx
index 76b8c1b7f4..c11a14372a 100644
--- a/src/swap/components/SwapButton.tsx
+++ b/src/swap/components/SwapButton.tsx
@@ -1,15 +1,15 @@
import { useCallback, useContext } from 'react';
import { SwapContext } from '../context';
-import type { SwapButtonReact } from '../types';
+import { SwapButtonReact } from '../types';
-export function SwapButton({ fromToken, onSubmit, toToken }: SwapButtonReact) {
- const { account, fromAmount } = useContext(SwapContext);
+export function SwapButton({ onSubmit }: SwapButtonReact) {
+ const { onSubmit: onSubmitSwap } = useContext(SwapContext);
const handleSubmit = useCallback(() => {
- if (account && fromToken && toToken && fromAmount) {
- onSubmit({ fromAddress: account.address, from: fromToken, to: toToken, amount: fromAmount });
- }
+ onSubmitSwap();
+ onSubmit?.();
}, []);
+
return (