Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/smooth-crabs-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

react: update hooks to use core transaction types
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -56,7 +56,11 @@
*/
export function useSendAndConfirmTransaction(
config: SendAndConfirmTransactionConfig = {},
): UseMutationResult<TransactionReceipt, Error, PreparedTransaction> {
): UseMutationResult<
TransactionReceipt,
Error,
SendTransactionOptions["transaction"]
> {

Check warning on line 63 in packages/thirdweb/src/react/core/hooks/transaction/useSendAndConfirmTransaction.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/core/hooks/transaction/useSendAndConfirmTransaction.ts#L63

Added line #L63 was not covered by tests
const account = useActiveAccount();
const { gasless } = config;
return useMutation({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type UseMutationResult, useMutation } from "@tanstack/react-query";
import { sendBatchTransaction } from "../../../../transaction/actions/send-batch-transaction.js";
import 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 { useActiveAccount } from "../wallets/useActiveAccount.js";

/**
Expand All @@ -20,7 +20,7 @@ import { useActiveAccount } from "../wallets/useActiveAccount.js";
export function useSendBatchTransaction(): UseMutationResult<
WaitForReceiptOptions,
Error,
PreparedTransaction[]
SendTransactionOptions["transaction"][]
> {
const account = useActiveAccount();
return useMutation({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 } 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";
Expand Down Expand Up @@ -132,7 +135,11 @@ export function useSendTransactionCore(args: {
gasless?: GaslessOptions;
wallet: Wallet | undefined;
switchChain: (chain: Chain) => Promise<void>;
}): UseMutationResult<WaitForReceiptOptions, Error, PreparedTransaction> {
}): UseMutationResult<
WaitForReceiptOptions,
Error,
SendTransactionOptions["transaction"]
> {
const { showPayModal, gasless, wallet, switchChain } = args;
let _account = wallet?.getAccount();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
Loading