Skip to content

Commit 68d6802

Browse files
committed
[MNY-348] SDK: Remove in-app wallet from default wallet list for bridge widgets
1 parent 3bbc7ee commit 68d6802

File tree

9 files changed

+185
-0
lines changed

9 files changed

+185
-0
lines changed

.changeset/plain-maps-care.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": minor
3+
---
4+
5+
Remove in-app wallet from default wallet list for bridge widgets"

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
isAddress,
1616
shortenAddress,
1717
} from "../../../../utils/address.js";
18+
import { getDefaultWalletsForBridgeComponents } from "../../../../wallets/defaultWallets.js";
1819
import { useCustomTheme } from "../../../core/design-system/CustomThemeProvider.js";
1920
import {
2021
fontSize,
@@ -299,6 +300,13 @@ export function FundWallet(props: FundWalletProps) {
299300
theme={theme}
300301
{...props.connectOptions}
301302
autoConnect={false}
303+
wallets={
304+
props.connectOptions?.wallets ||
305+
getDefaultWalletsForBridgeComponents({
306+
appMetadata: props.connectOptions?.appMetadata,
307+
chains: props.connectOptions?.chains,
308+
})
309+
}
302310
/>
303311
) : (
304312
<Button

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
shortenAddress,
1212
} from "../../../../utils/address.js";
1313
import { resolvePromisedValue } from "../../../../utils/promise/resolve-promised-value.js";
14+
import { getDefaultWalletsForBridgeComponents } from "../../../../wallets/defaultWallets.js";
1415
import { getWalletBalance } from "../../../../wallets/utils/getWalletBalance.js";
1516
import { useCustomTheme } from "../../../core/design-system/CustomThemeProvider.js";
1617
import {
@@ -445,6 +446,13 @@ export function TransactionPayment({
445446
}}
446447
theme={theme}
447448
{...connectOptions}
449+
wallets={
450+
connectOptions?.wallets ||
451+
getDefaultWalletsForBridgeComponents({
452+
appMetadata: connectOptions?.appMetadata,
453+
chains: connectOptions?.chains,
454+
})
455+
}
448456
/>
449457
)}
450458

packages/thirdweb/src/react/web/ui/Bridge/swap-widget/swap-ui.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { getToken } from "../../../../../pay/convert/get-token.js";
1111
import type { SupportedFiatCurrency } from "../../../../../pay/convert/type.js";
1212
import { getAddress } from "../../../../../utils/address.js";
1313
import { toTokens, toUnits } from "../../../../../utils/units.js";
14+
import { getDefaultWalletsForBridgeComponents } from "../../../../../wallets/defaultWallets.js";
1415
import { useCustomTheme } from "../../../../core/design-system/CustomThemeProvider.js";
1516
import {
1617
fontSize,
@@ -456,6 +457,13 @@ export function SwapUI(props: SwapUIProps) {
456457
}}
457458
theme={props.theme}
458459
{...props.connectOptions}
460+
wallets={
461+
props.connectOptions?.wallets ||
462+
getDefaultWalletsForBridgeComponents({
463+
appMetadata: props.connectOptions?.appMetadata,
464+
chains: props.connectOptions?.chains,
465+
})
466+
}
459467
/>
460468
) : (
461469
<Button
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import type { Meta } from "@storybook/react";
2+
import { lightTheme } from "../../../react/core/design-system/index.js";
3+
import {
4+
BridgeWidget,
5+
type BridgeWidgetProps,
6+
} from "../../../react/web/ui/Bridge/bridge-widget/bridge-widget.js";
7+
import { createWallet } from "../../../wallets/create-wallet.js";
8+
import { storyClient } from "../../utils.js";
9+
10+
const meta: Meta<typeof BridgeWidget> = {
11+
title: "Bridge/BridgeWidget",
12+
};
13+
export default meta;
14+
15+
export function BasicUsage() {
16+
return (
17+
<Variant client={storyClient} buy={{ chainId: 8453, amount: "0.1" }} />
18+
);
19+
}
20+
21+
export function CurrencySet() {
22+
return (
23+
<Variant
24+
client={storyClient}
25+
currency="JPY"
26+
buy={{ chainId: 8453, amount: "0.1" }}
27+
/>
28+
);
29+
}
30+
31+
export function NoThirdwebBranding() {
32+
return (
33+
<Variant
34+
client={storyClient}
35+
theme="light"
36+
buy={{ chainId: 8453, amount: "0.1" }}
37+
showThirdwebBranding={false}
38+
/>
39+
);
40+
}
41+
42+
export function CustomTheme() {
43+
return (
44+
<div
45+
style={{
46+
display: "flex",
47+
flexDirection: "column",
48+
gap: "40px",
49+
alignItems: "center",
50+
}}
51+
>
52+
<BridgeWidget
53+
client={storyClient}
54+
currency="JPY"
55+
buy={{ chainId: 8453, amount: "0.1" }}
56+
showThirdwebBranding={false}
57+
theme={lightTheme({
58+
colors: {
59+
modalBg: "#FFFFF0",
60+
tertiaryBg: "#DBE4C9",
61+
borderColor: "#8AA624",
62+
secondaryText: "#3E3F29",
63+
accentText: "#E43636",
64+
},
65+
})}
66+
/>
67+
</div>
68+
);
69+
}
70+
71+
export function CustomWallets() {
72+
return (
73+
<Variant
74+
client={storyClient}
75+
currency="JPY"
76+
buy={{ chainId: 8453, amount: "0.1" }}
77+
connectOptions={{
78+
wallets: [createWallet("io.metamask"), createWallet("me.rainbow")],
79+
}}
80+
/>
81+
);
82+
}
83+
84+
function Variant(props: BridgeWidgetProps) {
85+
return (
86+
<div
87+
style={{
88+
display: "flex",
89+
flexDirection: "column",
90+
gap: "40px",
91+
alignItems: "center",
92+
}}
93+
>
94+
<BridgeWidget {...props} theme="dark" />
95+
<BridgeWidget {...props} theme="light" />
96+
</div>
97+
);
98+
}

packages/thirdweb/src/stories/Bridge/Swap/SwapWidget.stories.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
SwapWidget,
55
type SwapWidgetProps,
66
} from "../../../react/web/ui/Bridge/swap-widget/SwapWidget.js";
7+
import { createWallet } from "../../../wallets/create-wallet.js";
78
import { storyClient } from "../../utils.js";
89

910
const meta: Meta<typeof SwapWidget> = {
@@ -66,6 +67,19 @@ export function CustomTheme() {
6667
);
6768
}
6869

70+
export function CustomWallets() {
71+
return (
72+
<Variant
73+
client={storyClient}
74+
currency="JPY"
75+
persistTokenSelections={false}
76+
connectOptions={{
77+
wallets: [createWallet("io.metamask"), createWallet("me.rainbow")],
78+
}}
79+
/>
80+
);
81+
}
82+
6983
function Variant(props: SwapWidgetProps) {
7084
return (
7185
<div

packages/thirdweb/src/stories/Bridge/Transaction/TransactionWidget.stories.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
TransactionWidget,
44
type TransactionWidgetProps,
55
} from "../../../react/web/ui/Bridge/TransactionWidget.js";
6+
import { createWallet } from "../../../wallets/create-wallet.js";
67
import { storyClient } from "../../utils.js";
78
import { TRANSACTION_UI_OPTIONS } from "../fixtures.js";
89

@@ -28,6 +29,15 @@ export const EthereumTransfer: Story = {
2829
},
2930
};
3031

32+
export const EthereumTransferCustomWallets: Story = {
33+
args: {
34+
...TRANSACTION_UI_OPTIONS.ethTransfer,
35+
connectOptions: {
36+
wallets: [createWallet("io.metamask"), createWallet("me.rainbow")],
37+
},
38+
},
39+
};
40+
3141
export const ERC20TokenTransfer: Story = {
3242
args: {
3343
...TRANSACTION_UI_OPTIONS.erc20Transfer,

packages/thirdweb/src/stories/BuyWidget.stories.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
BuyWidget,
77
type BuyWidgetProps,
88
} from "../react/web/ui/Bridge/BuyWidget.js";
9+
import { createWallet } from "../wallets/create-wallet.js";
910
import { storyClient } from "./utils.js";
1011

1112
const meta = {
@@ -152,6 +153,17 @@ export function NoAutoConnect() {
152153
);
153154
}
154155

156+
export function CustomWallets() {
157+
return (
158+
<Variant
159+
client={storyClient}
160+
connectOptions={{
161+
wallets: [createWallet("io.metamask"), createWallet("me.rainbow")],
162+
}}
163+
/>
164+
);
165+
}
166+
155167
function Variant(props: BuyWidgetProps) {
156168
return (
157169
<div

packages/thirdweb/src/wallets/defaultWallets.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,27 @@ export function getDefaultWallets(options?: {
2525
createWallet(RAINBOW),
2626
createWallet("io.rabby"),
2727
createWallet(ZERION),
28+
createWallet("com.okex.wallet"),
29+
];
30+
}
31+
32+
/**
33+
* @internal
34+
*/
35+
export function getDefaultWalletsForBridgeComponents(options?: {
36+
appMetadata?: AppMetadata;
37+
chains?: Chain[];
38+
executionMode?: ExecutionModeOptions;
39+
}): Wallet[] {
40+
return [
41+
createWallet(METAMASK),
42+
createWallet(COINBASE, {
43+
appMetadata: options?.appMetadata,
44+
chains: options?.chains,
45+
}),
46+
createWallet(RAINBOW),
47+
createWallet("io.rabby"),
48+
createWallet(ZERION),
49+
createWallet("com.okex.wallet"),
2850
];
2951
}

0 commit comments

Comments
 (0)