From 355e4c4ec08df6e84c706cafd969f27480b53013 Mon Sep 17 00:00:00 2001 From: Alec Ananian <1013230+alecananian@users.noreply.github.com> Date: Fri, 18 Jul 2025 13:12:41 -0700 Subject: [PATCH 1/4] react: update hooks to use core transaction types --- .../core/hooks/transaction/useSendAndConfirmTransaction.ts | 4 ++-- .../react/core/hooks/transaction/useSendBatchTransaction.ts | 4 ++-- .../src/react/core/hooks/transaction/useSendTransaction.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/thirdweb/src/react/core/hooks/transaction/useSendAndConfirmTransaction.ts b/packages/thirdweb/src/react/core/hooks/transaction/useSendAndConfirmTransaction.ts index 59632720ff7..5a18c98b58d 100644 --- a/packages/thirdweb/src/react/core/hooks/transaction/useSendAndConfirmTransaction.ts +++ b/packages/thirdweb/src/react/core/hooks/transaction/useSendAndConfirmTransaction.ts @@ -1,7 +1,7 @@ import { type UseMutationResult, useMutation } from "@tanstack/react-query"; import type { GaslessOptions } from "../../../../transaction/actions/gasless/types.js"; import { sendAndConfirmTransaction } from "../../../../transaction/actions/send-and-confirm-transaction.js"; -import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js"; +import type { SendTransactionOptions } from "../../../../transaction/actions/send-transaction.js"; import type { TransactionReceipt } from "../../../../transaction/types.js"; import { useActiveAccount } from "../wallets/useActiveAccount.js"; @@ -56,7 +56,7 @@ type SendAndConfirmTransactionConfig = { */ export function useSendAndConfirmTransaction( config: SendAndConfirmTransactionConfig = {}, -): UseMutationResult { +): UseMutationResult { const account = useActiveAccount(); const { gasless } = config; return useMutation({ diff --git a/packages/thirdweb/src/react/core/hooks/transaction/useSendBatchTransaction.ts b/packages/thirdweb/src/react/core/hooks/transaction/useSendBatchTransaction.ts index bc9ce27ed1e..cc716f93171 100644 --- a/packages/thirdweb/src/react/core/hooks/transaction/useSendBatchTransaction.ts +++ b/packages/thirdweb/src/react/core/hooks/transaction/useSendBatchTransaction.ts @@ -1,7 +1,7 @@ import { type UseMutationResult, useMutation } from "@tanstack/react-query"; import { sendBatchTransaction } from "../../../../transaction/actions/send-batch-transaction.js"; import type { WaitForReceiptOptions } from "../../../../transaction/actions/wait-for-tx-receipt.js"; -import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js"; +import type { SendTransactionOptions } from "../../../../transaction/actions/send-transaction.js"; import { useActiveAccount } from "../wallets/useActiveAccount.js"; /** @@ -20,7 +20,7 @@ import { useActiveAccount } from "../wallets/useActiveAccount.js"; export function useSendBatchTransaction(): UseMutationResult< WaitForReceiptOptions, Error, - PreparedTransaction[] + SendTransactionOptions["transaction"][] > { const account = useActiveAccount(); return useMutation({ diff --git a/packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts b/packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts index c588763ca88..382790b8e41 100644 --- a/packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts +++ b/packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts @@ -9,7 +9,7 @@ import type { BuyWithFiatStatus } from "../../../../pay/buyWithFiat/getStatus.js import type { PurchaseData } from "../../../../pay/types.js"; import type { FiatProvider } from "../../../../pay/utils/commonTypes.js"; import type { GaslessOptions } from "../../../../transaction/actions/gasless/types.js"; -import { sendTransaction } from "../../../../transaction/actions/send-transaction.js"; +import { sendTransaction, type SendTransactionOptions } from "../../../../transaction/actions/send-transaction.js"; import type { WaitForReceiptOptions } from "../../../../transaction/actions/wait-for-tx-receipt.js"; import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js"; import { getTransactionGasCost } from "../../../../transaction/utils.js"; @@ -132,7 +132,7 @@ export function useSendTransactionCore(args: { gasless?: GaslessOptions; wallet: Wallet | undefined; switchChain: (chain: Chain) => Promise; -}): UseMutationResult { +}): UseMutationResult { const { showPayModal, gasless, wallet, switchChain } = args; let _account = wallet?.getAccount(); From b2f35b3a814f168229ddfd8b56a1b02b1688c405 Mon Sep 17 00:00:00 2001 From: Alec Ananian <1013230+alecananian@users.noreply.github.com> Date: Fri, 18 Jul 2025 13:15:45 -0700 Subject: [PATCH 2/4] add changeset --- .changeset/smooth-crabs-reply.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/smooth-crabs-reply.md diff --git a/.changeset/smooth-crabs-reply.md b/.changeset/smooth-crabs-reply.md new file mode 100644 index 00000000000..149e4186d57 --- /dev/null +++ b/.changeset/smooth-crabs-reply.md @@ -0,0 +1,5 @@ +--- +"thirdweb": patch +--- + +react: update hooks to use core transaction types From 8a88efa57403dc89e0661d9eab1d117a8aee47aa Mon Sep 17 00:00:00 2001 From: Alec Ananian <1013230+alecananian@users.noreply.github.com> Date: Sat, 19 Jul 2025 09:14:47 -0700 Subject: [PATCH 3/4] fix core `sendBatchTransaction` types --- .../src/transaction/actions/send-batch-transaction.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/thirdweb/src/transaction/actions/send-batch-transaction.ts b/packages/thirdweb/src/transaction/actions/send-batch-transaction.ts index f888b3234ab..09e2d11cda1 100644 --- a/packages/thirdweb/src/transaction/actions/send-batch-transaction.ts +++ b/packages/thirdweb/src/transaction/actions/send-batch-transaction.ts @@ -3,12 +3,12 @@ import type { Account, SendTransactionOption, } from "../../wallets/interfaces/wallet.js"; -import type { PreparedTransaction } from "../prepare-transaction.js"; import { encode } from "./encode.js"; +import type { SendTransactionOptions } from "./send-transaction.js"; import type { WaitForReceiptOptions } from "./wait-for-tx-receipt.js"; export type SendBatchTransactionOptions = { - transactions: PreparedTransaction[]; + transactions: SendTransactionOptions["transaction"][]; account: Account; }; From 2c983eeb9a509a6bfbdef2f6cebd7607d618881b Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Mon, 21 Jul 2025 12:22:48 +1200 Subject: [PATCH 4/4] lint --- .../hooks/transaction/useSendAndConfirmTransaction.ts | 6 +++++- .../core/hooks/transaction/useSendBatchTransaction.ts | 2 +- .../core/hooks/transaction/useSendTransaction.ts | 11 +++++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/thirdweb/src/react/core/hooks/transaction/useSendAndConfirmTransaction.ts b/packages/thirdweb/src/react/core/hooks/transaction/useSendAndConfirmTransaction.ts index 5a18c98b58d..73a812f00a6 100644 --- a/packages/thirdweb/src/react/core/hooks/transaction/useSendAndConfirmTransaction.ts +++ b/packages/thirdweb/src/react/core/hooks/transaction/useSendAndConfirmTransaction.ts @@ -56,7 +56,11 @@ type SendAndConfirmTransactionConfig = { */ export function useSendAndConfirmTransaction( config: SendAndConfirmTransactionConfig = {}, -): UseMutationResult { +): UseMutationResult< + TransactionReceipt, + Error, + SendTransactionOptions["transaction"] +> { const account = useActiveAccount(); const { gasless } = config; return useMutation({ diff --git a/packages/thirdweb/src/react/core/hooks/transaction/useSendBatchTransaction.ts b/packages/thirdweb/src/react/core/hooks/transaction/useSendBatchTransaction.ts index cc716f93171..16c093bc5f4 100644 --- a/packages/thirdweb/src/react/core/hooks/transaction/useSendBatchTransaction.ts +++ b/packages/thirdweb/src/react/core/hooks/transaction/useSendBatchTransaction.ts @@ -1,7 +1,7 @@ import { type UseMutationResult, useMutation } from "@tanstack/react-query"; import { sendBatchTransaction } from "../../../../transaction/actions/send-batch-transaction.js"; -import type { WaitForReceiptOptions } from "../../../../transaction/actions/wait-for-tx-receipt.js"; import type { SendTransactionOptions } from "../../../../transaction/actions/send-transaction.js"; +import type { WaitForReceiptOptions } from "../../../../transaction/actions/wait-for-tx-receipt.js"; import { useActiveAccount } from "../wallets/useActiveAccount.js"; /** diff --git a/packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts b/packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts index 382790b8e41..b54348cd9f5 100644 --- a/packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts +++ b/packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts @@ -9,7 +9,10 @@ import type { BuyWithFiatStatus } from "../../../../pay/buyWithFiat/getStatus.js import type { PurchaseData } from "../../../../pay/types.js"; import type { FiatProvider } from "../../../../pay/utils/commonTypes.js"; import type { GaslessOptions } from "../../../../transaction/actions/gasless/types.js"; -import { sendTransaction, type SendTransactionOptions } from "../../../../transaction/actions/send-transaction.js"; +import { + type SendTransactionOptions, + sendTransaction, +} from "../../../../transaction/actions/send-transaction.js"; import type { WaitForReceiptOptions } from "../../../../transaction/actions/wait-for-tx-receipt.js"; import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js"; import { getTransactionGasCost } from "../../../../transaction/utils.js"; @@ -132,7 +135,11 @@ export function useSendTransactionCore(args: { gasless?: GaslessOptions; wallet: Wallet | undefined; switchChain: (chain: Chain) => Promise; -}): UseMutationResult { +}): UseMutationResult< + WaitForReceiptOptions, + Error, + SendTransactionOptions["transaction"] +> { const { showPayModal, gasless, wallet, switchChain } = args; let _account = wallet?.getAccount();