diff --git a/package.json b/package.json index 9867e740..9ac048fa 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "moment": "^2.30.1", "numerable": "^0.3.15", "qs": "^6.13.0", - "react": "^18.2.0", + "react": "^18.3.1", "react-dom": "^18.2.0", "react-responsive": "^10.0.0", "recharts": "^2.12.7", @@ -61,9 +61,9 @@ "tailwindcss": "^3.4.12", "tailwindcss-animate": "^1.0.7", "typedoc": "^0.26.7", - "viem": "2.x", "vite-plugin-dts": "^4.2.1", - "wagmi": "^2.12.10", + "viem": "2.21.54", + "wagmi": "^2.14.1", "zustand": "^5.0.0-rc.2" }, "devDependencies": { diff --git a/src/components/dapp/TransactionButton.tsx b/src/components/dapp/TransactionButton.tsx index fceca39b..8699f198 100644 --- a/src/components/dapp/TransactionButton.tsx +++ b/src/components/dapp/TransactionButton.tsx @@ -1,5 +1,6 @@ import { type ReactNode, useCallback } from "react"; import { type ResolvedRegister, type UseSendTransactionReturnType, useSendTransaction } from "wagmi"; +import { useWalletContext } from "../../context/Wallet.context"; import Button, { type ButtonProps } from "../primitives/Button"; import Icon from "../primitives/Icon"; @@ -11,18 +12,26 @@ export type TransactionButtonProps = ButtonProps & { export default function TransactionButton({ tx, name, children, onExecute, ...props }: TransactionButtonProps) { const sendTxHook = useSendTransaction(); - const { sendTransactionAsync, status } = sendTxHook; + const { status } = sendTxHook; + const { address: user, client, sendTransaction } = useWalletContext(); const execute = useCallback(async () => { - if (!tx) return; + console.log("CLIENT", client); - const hash = await sendTransactionAsync({ - to: tx.to as `0x${string}`, - data: tx.data as `0x${string}`, - }); + if (!tx || !user || !client) return; - onExecute?.(hash); - }, [tx, sendTransactionAsync, onExecute]); + const hash = await sendTransaction?.([ + { + chain: client.chain, + account: user, + to: tx.to, + data: tx.data, + value: tx.value, + }, + ]); + + hash && onExecute?.(hash); + }, [tx, client, user, sendTransaction, onExecute]); return (