Skip to content

Commit 74faebe

Browse files
ui polish, reuse header accross all modes
1 parent 2221dcf commit 74faebe

File tree

19 files changed

+995
-784
lines changed

19 files changed

+995
-784
lines changed

apps/playground-web/src/app/connect/pay/commerce/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ function BuyMerch() {
6363
sellerAddress: "0xEb0effdFB4dC5b3d5d3aC6ce29F3ED213E95d675",
6464
},
6565
metadata: {
66-
name: "Black Hoodie (Size L)",
66+
name: "Black Hoodie",
67+
description: "Size L. Ships worldwide.",
6768
image: "/drip-hoodie.png",
6869
},
6970
}}

apps/playground-web/src/components/pay/direct-payment.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export function BuyMerchPreview() {
2020
},
2121
metadata: {
2222
name: "Black Hoodie (Size L)",
23+
description: "Size L. Ships worldwide.",
2324
image: "/drip-hoodie.png",
2425
},
2526
}}

packages/thirdweb/src/react/core/hooks/connection/ConnectButtonProps.ts

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -25,40 +25,42 @@ import type {
2525
} from "../../utils/defaultTokens.js";
2626
import type { SiweAuthOptions } from "../auth/useSiweAuth.js";
2727

28-
export type PaymentInfo = {
29-
/**
30-
* The chain to receive the payment on.
31-
*/
32-
chain: Chain;
33-
/**
34-
* The address of the seller wallet to receive the payment on.
35-
*/
36-
sellerAddress: string;
37-
/**
38-
* Optional ERC20 token to receive the payment on.
39-
* If not provided, the native token will be used.
40-
*/
41-
token?: TokenInfo;
42-
/**
43-
* For direct transfers, specify who will pay the transfer fee. Can be "sender" or "receiver".
44-
*/
45-
feePayer?: "sender" | "receiver";
46-
} & (
47-
| {
48-
/**
49-
* The amount of tokens to receive in ETH or tokens.
50-
* ex: 0.1 ETH or 100 USDC
51-
*/
52-
amount: string;
53-
}
54-
| {
55-
/**
56-
* The amount of tokens to receive in wei.
57-
* ex: 1000000000000000000 wei
58-
*/
59-
amountWei: bigint;
60-
}
61-
);
28+
export type PaymentInfo = Prettify<
29+
{
30+
/**
31+
* The chain to receive the payment on.
32+
*/
33+
chain: Chain;
34+
/**
35+
* The address of the seller wallet to receive the payment on.
36+
*/
37+
sellerAddress: string;
38+
/**
39+
* Optional ERC20 token to receive the payment on.
40+
* If not provided, the native token will be used.
41+
*/
42+
token?: Partial<TokenInfo> & { address: string };
43+
/**
44+
* For direct transfers, specify who will pay the transfer fee. Can be "sender" or "receiver".
45+
*/
46+
feePayer?: "sender" | "receiver";
47+
} & (
48+
| {
49+
/**
50+
* The amount of tokens to receive in ETH or tokens.
51+
* ex: 0.1 ETH or 100 USDC
52+
*/
53+
amount: string;
54+
}
55+
| {
56+
/**
57+
* The amount of tokens to receive in wei.
58+
* ex: 1000000000000000000 wei
59+
*/
60+
amountWei: bigint;
61+
}
62+
)
63+
>;
6264

6365
export type PayUIOptions = Prettify<
6466
{
@@ -133,6 +135,7 @@ export type PayUIOptions = Prettify<
133135
*/
134136
metadata?: {
135137
name?: string;
138+
description?: string;
136139
image?: string;
137140
};
138141

packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { ThirdwebClient } from "../../../../client/client.js";
55
import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js";
66
import type { Address } from "../../../../utils/address.js";
77
import { webLocalStorage } from "../../../../utils/storage/webStorage.js";
8+
import type { Prettify } from "../../../../utils/type-utils.js";
89
import type { BridgePrepareResult } from "../../../core/hooks/useBridgePrepare.js";
910
import type { CompletedStatusResult } from "../../../core/hooks/useStepExecutor.js";
1011
import {
@@ -26,28 +27,32 @@ import { PaymentDetails } from "./payment-details/PaymentDetails.js";
2627
import { PaymentSelection } from "./payment-selection/PaymentSelection.js";
2728
import { SuccessScreen } from "./payment-success/SuccessScreen.js";
2829

29-
export type UIOptions =
30-
| {
31-
mode: "fund_wallet";
32-
destinationToken: Token;
33-
initialAmount?: string;
34-
quickOptions?: [number, number, number];
35-
}
36-
| {
37-
mode: "direct_payment";
38-
paymentInfo: {
39-
sellerAddress: Address;
40-
token: Token;
41-
amount: string;
42-
feePayer?: "sender" | "receiver";
43-
metadata: {
44-
name: string;
45-
image?: string;
46-
description?: string;
30+
export type UIOptions = Prettify<
31+
{
32+
metadata?: {
33+
title?: string;
34+
description?: string;
35+
image?: string;
36+
};
37+
} & (
38+
| {
39+
mode: "fund_wallet";
40+
destinationToken: Token;
41+
initialAmount?: string;
42+
quickOptions?: [number, number, number];
43+
}
44+
| {
45+
mode: "direct_payment";
46+
paymentInfo: {
47+
sellerAddress: Address;
48+
token: Token;
49+
amount: string;
50+
feePayer?: "sender" | "receiver";
4751
};
48-
};
49-
}
50-
| { mode: "transaction"; transaction: PreparedTransaction };
52+
}
53+
| { mode: "transaction"; transaction: PreparedTransaction }
54+
)
55+
>;
5156

5257
export interface BridgeOrchestratorProps {
5358
/**
@@ -207,19 +212,18 @@ export function BridgeOrchestrator({
207212
{/* Render current screen based on state */}
208213
{state.value === "init" && uiOptions.mode === "fund_wallet" && (
209214
<FundWallet
210-
token={uiOptions.destinationToken}
215+
uiOptions={uiOptions}
211216
receiverAddress={receiverAddress}
212-
initialAmount={uiOptions.initialAmount}
213217
client={client}
214218
onContinue={handleRequirementsResolved}
215219
connectOptions={connectOptions}
216-
quickOptions={quickOptions ?? [5, 10, 20]}
220+
quickOptions={quickOptions}
217221
/>
218222
)}
219223

220224
{state.value === "init" && uiOptions.mode === "direct_payment" && (
221225
<DirectPayment
222-
paymentInfo={uiOptions.paymentInfo}
226+
uiOptions={uiOptions}
223227
client={client}
224228
onContinue={handleRequirementsResolved}
225229
connectOptions={connectOptions}
@@ -228,7 +232,7 @@ export function BridgeOrchestrator({
228232

229233
{state.value === "init" && uiOptions.mode === "transaction" && (
230234
<TransactionPayment
231-
transaction={uiOptions.transaction}
235+
uiOptions={uiOptions}
232236
client={client}
233237
onContinue={handleRequirementsResolved}
234238
connectOptions={connectOptions}

0 commit comments

Comments
 (0)