Skip to content

Commit 0ddc123

Browse files
committed
[Dashboard] Fix: Nebula send transaction params (#5744)
<!-- start pr-codex --> ## 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}` <!-- end pr-codex -->
1 parent f91f631 commit 0ddc123

File tree

1 file changed

+17
-2
lines changed
  • apps/dashboard/src/app/nebula-app/(app)/components

1 file changed

+17
-2
lines changed

apps/dashboard/src/app/nebula-app/(app)/components/Chats.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ import {
1515
import { useState } from "react";
1616
import { toast } from "sonner";
1717
import type { ThirdwebClient } from "thirdweb";
18+
import { sendTransaction } from "thirdweb";
1819
import { useActiveAccount } from "thirdweb/react";
1920
import type { Account } from "thirdweb/wallets";
21+
import { getThirdwebClient } from "../../../../@/constants/thirdweb.server";
2022
import { TransactionButton } from "../../../../components/buttons/TransactionButton";
2123
import { MarkdownRenderer } from "../../../../components/contract-components/published-contract/markdown-renderer";
24+
import { useV5DashboardChain } from "../../../../lib/v5-adapter";
2225
import { submitFeedback } from "../api/feedback";
2326
import { NebulaIcon } from "../icons/NebulaIcon";
2427

@@ -241,16 +244,28 @@ function SendTransactionButton(props: {
241244
twAccount: TWAccount;
242245
}) {
243246
const account = useActiveAccount();
247+
const chain = useV5DashboardChain(props.txData?.chainId);
248+
244249
const sendTxMutation = useMutation({
245250
mutationFn: () => {
246251
if (!account) {
247252
throw new Error("No active account");
248253
}
249254

250-
if (!props.txData) {
255+
if (!props.txData || !chain) {
251256
throw new Error("Invalid transaction");
252257
}
253-
return account.sendTransaction(props.txData);
258+
259+
return sendTransaction({
260+
account,
261+
transaction: {
262+
...props.txData,
263+
nonce: Number(props.txData.nonce),
264+
to: props.txData.to || undefined, // Get rid of the potential null value
265+
chain,
266+
client: getThirdwebClient(),
267+
},
268+
});
254269
},
255270
});
256271

0 commit comments

Comments
 (0)