@@ -15,16 +15,20 @@ import {
1515} from "lucide-react" ;
1616import { useEffect , useRef , useState } from "react" ;
1717import { toast } from "sonner" ;
18- import type { ThirdwebClient } from "thirdweb" ;
18+ import { type ThirdwebClient , prepareTransaction } from "thirdweb" ;
1919import { useSendTransaction } from "thirdweb/react" ;
20- import type { Account } from "thirdweb/wallets" ;
2120import { TransactionButton } from "../../../../components/buttons/TransactionButton" ;
2221import { MarkdownRenderer } from "../../../../components/contract-components/published-contract/markdown-renderer" ;
2322import { useV5DashboardChain } from "../../../../lib/v5-adapter" ;
2423import { submitFeedback } from "../api/feedback" ;
2524import { NebulaIcon } from "../icons/NebulaIcon" ;
2625
27- type SendTransactionOption = Parameters < Account [ "sendTransaction" ] > [ 0 ] ;
26+ export type NebulaTxData = {
27+ chainId : number ;
28+ data : `0x${string } `;
29+ to : string ;
30+ value : string ;
31+ } ;
2832
2933export type ChatMessage =
3034 | {
@@ -39,7 +43,7 @@ export type ChatMessage =
3943 }
4044 | {
4145 type : "send_transaction" ;
42- data : SendTransactionOption | null ;
46+ data : NebulaTxData | null ;
4347 } ;
4448
4549export function Chats ( props : {
@@ -203,7 +207,7 @@ export function Chats(props: {
203207}
204208
205209function ExecuteTransaction ( props : {
206- txData : SendTransactionOption | null ;
210+ txData : NebulaTxData | null ;
207211 twAccount : TWAccount ;
208212 client : ThirdwebClient ;
209213} ) {
@@ -319,7 +323,7 @@ function MessageActions(props: {
319323}
320324
321325function SendTransactionButton ( props : {
322- txData : SendTransactionOption ;
326+ txData : NebulaTxData ;
323327 twAccount : TWAccount ;
324328 client : ThirdwebClient ;
325329} ) {
@@ -333,14 +337,16 @@ function SendTransactionButton(props: {
333337 transactionCount = { 1 }
334338 txChainID = { txData . chainId }
335339 onClick = { ( ) => {
336- const promise = sendTransaction . mutateAsync ( {
337- ...props . txData ,
338- nonce : Number ( txData . nonce ) ,
339- to : txData . to || undefined , // Get rid of the potential null value
340+ const tx = prepareTransaction ( {
340341 chain : chain ,
341342 client : props . client ,
343+ data : txData . data ,
344+ to : txData . to ,
345+ value : BigInt ( txData . value ) ,
342346 } ) ;
343347
348+ const promise = sendTransaction . mutateAsync ( tx ) ;
349+
344350 toast . promise ( promise , {
345351 success : "Transaction sent successfully" ,
346352 error : "Failed to send transaction" ,
0 commit comments