Skip to content

Commit 5d0505c

Browse files
authored
Add purchaseData to transfer transactions (#4871)
1 parent e552fda commit 5d0505c

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

.changeset/olive-rings-develop.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Add purchaseData to direct transfer pay transactions

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ function BuyScreenContent(props: BuyScreenContentProps) {
357357
tokenAmount={tokenAmount}
358358
receiverAddress={receiverAddress}
359359
transactionMode={props.payOptions.mode === "transaction"}
360+
payOptions={payOptions}
360361
isEmbed={props.isEmbed}
361362
onDone={onDone}
362363
onTryAgain={() => {

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { sendTransaction } from "../../../../../../../transaction/actions/send-t
1111
import { prepareTransaction } from "../../../../../../../transaction/prepare-transaction.js";
1212
import { toWei } from "../../../../../../../utils/units.js";
1313
import { iconSize } from "../../../../../../core/design-system/index.js";
14+
import type { PayUIOptions } from "../../../../../../core/hooks/connection/ConnectButtonProps.js";
1415
import { useChainSymbol } from "../../../../../../core/hooks/others/useChainQuery.js";
1516
import { Spacer } from "../../../../components/Spacer.js";
1617
import { Spinner } from "../../../../components/Spinner.js";
@@ -26,7 +27,7 @@ import { TokenInfoRow } from "../pay-transactions/TokenInfoRow.js";
2627
import type { PayerInfo } from "../types.js";
2728
import { ConnectorLine } from "./ConfirmationScreen.js";
2829

29-
type TrasnferConfirmationScreenProps = {
30+
type TransferConfirmationScreenProps = {
3031
title: string;
3132
onBack?: () => void;
3233
setTransactionHash: (txHash: string) => void;
@@ -38,10 +39,11 @@ type TrasnferConfirmationScreenProps = {
3839
token: ERC20OrNativeToken;
3940
tokenAmount: string;
4041
transactionMode?: boolean;
42+
payOptions?: PayUIOptions;
4143
};
4244

4345
export function TransferConfirmationScreen(
44-
props: TrasnferConfirmationScreenProps,
46+
props: TransferConfirmationScreenProps,
4547
) {
4648
const {
4749
title,
@@ -55,6 +57,7 @@ export function TransferConfirmationScreen(
5557
tokenAmount,
5658
transactionMode,
5759
setTransactionHash,
60+
payOptions,
5861
} = props;
5962
const [step, setStep] = useState<"approve" | "transfer" | "execute">(
6063
"transfer",
@@ -242,7 +245,7 @@ export function TransferConfirmationScreen(
242245
? NATIVE_TOKEN_ADDRESS
243246
: token.address,
244247
amount: tokenAmount,
245-
purchaseData: undefined, // TODO (pay): add purchase data
248+
purchaseData: payOptions?.purchaseData,
246249
});
247250

248251
if (transferResponse.approval) {

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import { useState } from "react";
22
import type { Chain } from "../../../../../../../chains/types.js";
33
import type { ThirdwebClient } from "../../../../../../../client/client.js";
44
import type { BuyWithCryptoStatus } from "../../../../../../../pay/buyWithCrypto/getStatus.js";
5+
import type { PayUIOptions } from "../../../../../../core/hooks/connection/ConnectButtonProps.js";
56
import type { ERC20OrNativeToken } from "../../nativeToken.js";
67
import type { PayerInfo } from "../types.js";
78
import { SwapStatusScreen } from "./SwapStatusScreen.js";
89
import { TransferConfirmationScreen } from "./TransferConfirmationScreen.js";
910

10-
type TrasnferFlowProps = {
11+
type TransferFlowProps = {
1112
title: string;
1213
onBack?: () => void;
1314
payer: PayerInfo;
@@ -21,9 +22,10 @@ type TrasnferFlowProps = {
2122
token: ERC20OrNativeToken;
2223
tokenAmount: string;
2324
transactionMode?: boolean;
25+
payOptions?: PayUIOptions;
2426
};
2527

26-
export function TransferFlow(props: TrasnferFlowProps) {
28+
export function TransferFlow(props: TransferFlowProps) {
2729
const [transferTxHash, setTransferTxHash] = useState<string | undefined>();
2830

2931
if (transferTxHash) {

0 commit comments

Comments
 (0)