From 0ddc1238073c2b7c3d876f79daa542363ec45c0b Mon Sep 17 00:00:00 2001 From: gregfromstl Date: Sun, 15 Dec 2024 23:38:20 +0000 Subject: [PATCH] [Dashboard] Fix: Nebula send transaction params (#5744) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## PR-Codex overview This PR enhances the `SendTransactionButton` component in `Chats.tsx` by introducing improved transaction handling and validation through the addition of a blockchain `chain` context and the `sendTransaction` method. ### Detailed summary - Added import for `sendTransaction` from `thirdweb`. - Introduced `chain` variable using `useV5DashboardChain`. - Updated transaction validation to check for both `txData` and `chain`. - Refactored transaction sending logic to use `sendTransaction` with detailed parameters. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` --- .../app/nebula-app/(app)/components/Chats.tsx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/apps/dashboard/src/app/nebula-app/(app)/components/Chats.tsx b/apps/dashboard/src/app/nebula-app/(app)/components/Chats.tsx index a5355bfe06d..082b1660468 100644 --- a/apps/dashboard/src/app/nebula-app/(app)/components/Chats.tsx +++ b/apps/dashboard/src/app/nebula-app/(app)/components/Chats.tsx @@ -15,10 +15,13 @@ import { import { useState } from "react"; import { toast } from "sonner"; import type { ThirdwebClient } from "thirdweb"; +import { sendTransaction } from "thirdweb"; import { useActiveAccount } from "thirdweb/react"; import type { Account } from "thirdweb/wallets"; +import { getThirdwebClient } from "../../../../@/constants/thirdweb.server"; import { TransactionButton } from "../../../../components/buttons/TransactionButton"; import { MarkdownRenderer } from "../../../../components/contract-components/published-contract/markdown-renderer"; +import { useV5DashboardChain } from "../../../../lib/v5-adapter"; import { submitFeedback } from "../api/feedback"; import { NebulaIcon } from "../icons/NebulaIcon"; @@ -241,16 +244,28 @@ function SendTransactionButton(props: { twAccount: TWAccount; }) { const account = useActiveAccount(); + const chain = useV5DashboardChain(props.txData?.chainId); + const sendTxMutation = useMutation({ mutationFn: () => { if (!account) { throw new Error("No active account"); } - if (!props.txData) { + if (!props.txData || !chain) { throw new Error("Invalid transaction"); } - return account.sendTransaction(props.txData); + + return sendTransaction({ + account, + transaction: { + ...props.txData, + nonce: Number(props.txData.nonce), + to: props.txData.to || undefined, // Get rid of the potential null value + chain, + client: getThirdwebClient(), + }, + }); }, });