thirdweb 5.64.2 → 5.64.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js +19 -1
- package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
- package/dist/cjs/react/core/utils/isSmartWallet.js +4 -2
- package/dist/cjs/react/core/utils/isSmartWallet.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +27 -78
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js +27 -13
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js +50 -19
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.js +0 -2
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js +21 -32
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.js +138 -0
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.js.map +1 -0
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js +1 -0
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/formatTokenBalance.js +2 -2
- package/dist/cjs/react/web/ui/ConnectWallet/screens/formatTokenBalance.js.map +1 -1
- package/dist/cjs/react/web/wallets/shared/ConnectWalletSocialOptions.js +1 -1
- package/dist/cjs/react/web/wallets/shared/ConnectWalletSocialOptions.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/wallets/ecosystem/get-ecosystem-wallet-auth-options.js +23 -17
- package/dist/cjs/wallets/ecosystem/get-ecosystem-wallet-auth-options.js.map +1 -1
- package/dist/cjs/wallets/ecosystem/get-ecosystem-wallet-info.js +4 -13
- package/dist/cjs/wallets/ecosystem/get-ecosystem-wallet-info.js.map +1 -1
- package/dist/cjs/wallets/in-app/core/wallet/in-app-core.js +56 -4
- package/dist/cjs/wallets/in-app/core/wallet/in-app-core.js.map +1 -1
- package/dist/cjs/wallets/in-app/core/wallet/index.js +2 -50
- package/dist/cjs/wallets/in-app/core/wallet/index.js.map +1 -1
- package/dist/cjs/wallets/smart/lib/bundler.js +3 -1
- package/dist/cjs/wallets/smart/lib/bundler.js.map +1 -1
- package/dist/esm/react/core/hooks/transaction/useSendTransaction.js +19 -1
- package/dist/esm/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
- package/dist/esm/react/core/utils/isSmartWallet.js +4 -2
- package/dist/esm/react/core/utils/isSmartWallet.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +29 -80
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js +28 -14
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js +50 -19
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.js +0 -2
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js +21 -32
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.js +135 -0
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.js.map +1 -0
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/formatTokenBalance.js +2 -2
- package/dist/esm/react/web/ui/ConnectWallet/screens/formatTokenBalance.js.map +1 -1
- package/dist/esm/react/web/wallets/shared/ConnectWalletSocialOptions.js +2 -2
- package/dist/esm/react/web/wallets/shared/ConnectWalletSocialOptions.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/wallets/ecosystem/get-ecosystem-wallet-auth-options.js +22 -16
- package/dist/esm/wallets/ecosystem/get-ecosystem-wallet-auth-options.js.map +1 -1
- package/dist/esm/wallets/ecosystem/get-ecosystem-wallet-info.js +4 -13
- package/dist/esm/wallets/ecosystem/get-ecosystem-wallet-info.js.map +1 -1
- package/dist/esm/wallets/in-app/core/wallet/in-app-core.js +56 -4
- package/dist/esm/wallets/in-app/core/wallet/in-app-core.js.map +1 -1
- package/dist/esm/wallets/in-app/core/wallet/index.js +2 -50
- package/dist/esm/wallets/in-app/core/wallet/index.js.map +1 -1
- package/dist/esm/wallets/smart/lib/bundler.js +3 -1
- package/dist/esm/wallets/smart/lib/bundler.js.map +1 -1
- package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts.map +1 -1
- package/dist/types/react/core/utils/isSmartWallet.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.d.ts +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.d.ts +12 -8
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/types.d.ts +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/types.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.d.ts +0 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.d.ts +1 -2
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.d.ts +30 -0
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.d.ts.map +1 -0
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.d.ts +1 -0
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/formatTokenBalance.d.ts +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/formatTokenBalance.d.ts.map +1 -1
- package/dist/types/react/web/ui/components/token/TokenSymbol.d.ts +1 -1
- package/dist/types/react/web/ui/components/token/TokenSymbol.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/wallets/ecosystem/get-ecosystem-wallet-auth-options.d.ts +5 -1
- package/dist/types/wallets/ecosystem/get-ecosystem-wallet-auth-options.d.ts.map +1 -1
- package/dist/types/wallets/ecosystem/get-ecosystem-wallet-info.d.ts.map +1 -1
- package/dist/types/wallets/in-app/core/wallet/in-app-core.d.ts.map +1 -1
- package/dist/types/wallets/in-app/core/wallet/index.d.ts +2 -3
- package/dist/types/wallets/in-app/core/wallet/index.d.ts.map +1 -1
- package/dist/types/wallets/smart/lib/bundler.d.ts.map +1 -1
- package/dist/types/wallets/smart/types.d.ts +1 -1
- package/dist/types/wallets/smart/types.d.ts.map +1 -1
- package/package.json +11 -11
- package/src/extensions/unstoppable-domains/read/resolveName.test.ts +20 -17
- package/src/react/core/hooks/transaction/useSendTransaction.ts +34 -4
- package/src/react/core/utils/isSmartWallet.ts +4 -2
- package/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +35 -148
- package/src/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.tsx +62 -31
- package/src/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.tsx +136 -48
- package/src/react/web/ui/ConnectWallet/screens/Buy/main/types.ts +1 -1
- package/src/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.ts +0 -4
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.tsx +57 -71
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.tsx +251 -0
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.ts +1 -1
- package/src/react/web/ui/ConnectWallet/screens/formatTokenBalance.ts +2 -1
- package/src/react/web/ui/components/token/TokenSymbol.tsx +2 -2
- package/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx +2 -2
- package/src/version.ts +1 -1
- package/src/wallets/ecosystem/get-ecosystem-wallet-auth-options.ts +36 -23
- package/src/wallets/ecosystem/get-ecosystem-wallet-info.ts +5 -21
- package/src/wallets/in-app/core/wallet/in-app-core.ts +62 -4
- package/src/wallets/in-app/core/wallet/index.ts +0 -59
- package/src/wallets/smart/lib/bundler.ts +4 -1
- package/src/wallets/smart/smart-wallet-dev.test.ts +23 -4
- package/src/wallets/smart/types.ts +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/icons/GenericWalletIcon.js +0 -12
- package/dist/cjs/react/web/ui/ConnectWallet/icons/GenericWalletIcon.js.map +0 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.js +0 -34
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.js.map +0 -1
- package/dist/esm/react/web/ui/ConnectWallet/icons/GenericWalletIcon.js +0 -8
- package/dist/esm/react/web/ui/ConnectWallet/icons/GenericWalletIcon.js.map +0 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.js +0 -31
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.js.map +0 -1
- package/dist/types/react/web/ui/ConnectWallet/icons/GenericWalletIcon.d.ts +0 -6
- package/dist/types/react/web/ui/ConnectWallet/icons/GenericWalletIcon.d.ts.map +0 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.d.ts +0 -14
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.d.ts.map +0 -1
- package/src/react/web/ui/ConnectWallet/icons/GenericWalletIcon.tsx +0 -22
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.tsx +0 -83
@@ -6,23 +6,32 @@ import { formatNumber } from "../../../../../../utils/formatNumber.js";
|
|
6
6
|
import { toTokens } from "../../../../../../utils/units.js";
|
7
7
|
import type { Account } from "../../../../../../wallets/interfaces/wallet.js";
|
8
8
|
import { useCustomTheme } from "../../../../../core/design-system/CustomThemeProvider.js";
|
9
|
-
import {
|
9
|
+
import { fontSize, spacing } from "../../../../../core/design-system/index.js";
|
10
10
|
import type { PayUIOptions } from "../../../../../core/hooks/connection/ConnectButtonProps.js";
|
11
11
|
import { useChainMetadata } from "../../../../../core/hooks/others/useChainQuery.js";
|
12
|
+
import { useWalletBalance } from "../../../../../core/hooks/others/useWalletBalance.js";
|
13
|
+
import { useActiveAccount } from "../../../../../core/hooks/wallets/useActiveAccount.js";
|
12
14
|
import { useActiveWallet } from "../../../../../core/hooks/wallets/useActiveWallet.js";
|
13
15
|
import { hasSponsoredTransactionsEnabled } from "../../../../../core/utils/wallet.js";
|
14
16
|
import { LoadingScreen } from "../../../../wallets/shared/LoadingScreen.js";
|
15
17
|
import type { PayEmbedConnectOptions } from "../../../PayEmbed.js";
|
16
18
|
import { ChainIcon } from "../../../components/ChainIcon.js";
|
17
19
|
import { Img } from "../../../components/Img.js";
|
20
|
+
import { Skeleton } from "../../../components/Skeleton.js";
|
18
21
|
import { Spacer } from "../../../components/Spacer.js";
|
19
22
|
import { TokenIcon } from "../../../components/TokenIcon.js";
|
20
|
-
import { WalletImage } from "../../../components/WalletImage.js";
|
21
23
|
import { Container, Line, ModalHeader } from "../../../components/basic.js";
|
22
24
|
import { Button } from "../../../components/buttons.js";
|
23
25
|
import { Text } from "../../../components/text.js";
|
26
|
+
import { TokenSymbol } from "../../../components/token/TokenSymbol.js";
|
24
27
|
import { ConnectButton } from "../../ConnectButton.js";
|
25
|
-
import
|
28
|
+
import { formatTokenBalance } from "../formatTokenBalance.js";
|
29
|
+
import {
|
30
|
+
type ERC20OrNativeToken,
|
31
|
+
NATIVE_TOKEN,
|
32
|
+
isNativeToken,
|
33
|
+
} from "../nativeToken.js";
|
34
|
+
import { WalletRow } from "./WalletSelectorButton.js";
|
26
35
|
import { useTransactionCostAndData } from "./main/useBuyTxStates.js";
|
27
36
|
import type { SupportedChainAndTokens } from "./swap/useSwapSupportedChains.js";
|
28
37
|
|
@@ -54,8 +63,22 @@ export function TransactionModeScreen(props: {
|
|
54
63
|
});
|
55
64
|
const theme = useCustomTheme();
|
56
65
|
const activeWallet = useActiveWallet();
|
66
|
+
const activeAccount = useActiveAccount();
|
57
67
|
const sponsoredTransactionsEnabled =
|
58
68
|
hasSponsoredTransactionsEnabled(activeWallet);
|
69
|
+
const balanceQuery = useWalletBalance(
|
70
|
+
{
|
71
|
+
address: activeAccount?.address,
|
72
|
+
chain: payUiOptions.transaction.chain,
|
73
|
+
tokenAddress: isNativeToken(transactionCostAndData?.token || NATIVE_TOKEN)
|
74
|
+
? undefined
|
75
|
+
: transactionCostAndData?.token.address,
|
76
|
+
client: props.client,
|
77
|
+
},
|
78
|
+
{
|
79
|
+
enabled: !!transactionCostAndData,
|
80
|
+
},
|
81
|
+
);
|
59
82
|
|
60
83
|
if (!transactionCostAndData || !chainData) {
|
61
84
|
return <LoadingScreen />;
|
@@ -74,39 +97,47 @@ export function TransactionModeScreen(props: {
|
|
74
97
|
style={{
|
75
98
|
width: "100%",
|
76
99
|
borderRadius: spacing.md,
|
100
|
+
border: `1px solid ${theme.colors.borderColor}`,
|
77
101
|
backgroundColor: theme.colors.tertiaryBg,
|
78
102
|
}}
|
79
103
|
/>
|
80
|
-
) :
|
81
|
-
<Container
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
borderRadius: spacing.md,
|
88
|
-
backgroundColor: theme.colors.tertiaryBg,
|
89
|
-
}}
|
90
|
-
>
|
91
|
-
<WalletImage
|
92
|
-
size={iconSize.xl}
|
93
|
-
id={activeWallet.id}
|
94
|
-
client={client}
|
95
|
-
/>
|
96
|
-
<div
|
104
|
+
) : activeAccount ? (
|
105
|
+
<Container flex="column" gap="sm">
|
106
|
+
<Text size="sm" color="danger" style={{ textAlign: "center" }}>
|
107
|
+
Insufficient funds
|
108
|
+
</Text>
|
109
|
+
<Container
|
110
|
+
flex="row"
|
97
111
|
style={{
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
112
|
+
justifyContent: "space-between",
|
113
|
+
padding: spacing.sm,
|
114
|
+
marginBottom: spacing.sm,
|
115
|
+
borderRadius: spacing.md,
|
116
|
+
backgroundColor: theme.colors.tertiaryBg,
|
117
|
+
border: `1px solid ${theme.colors.borderColor}`,
|
103
118
|
}}
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
119
|
+
>
|
120
|
+
<WalletRow
|
121
|
+
address={activeAccount?.address}
|
122
|
+
iconSize="md"
|
123
|
+
client={client}
|
124
|
+
/>
|
125
|
+
{balanceQuery.data ? (
|
126
|
+
<Container flex="row" gap="3xs" center="y">
|
127
|
+
<Text size="xs" color="secondaryText" weight={500}>
|
128
|
+
{formatTokenBalance(balanceQuery.data, false, 3)}
|
129
|
+
</Text>
|
130
|
+
<TokenSymbol
|
131
|
+
token={transactionCostAndData.token}
|
132
|
+
chain={payUiOptions.transaction.chain}
|
133
|
+
size="xs"
|
134
|
+
color="secondaryText"
|
135
|
+
/>
|
136
|
+
</Container>
|
137
|
+
) : (
|
138
|
+
<Skeleton width="70px" height={fontSize.xs} />
|
139
|
+
)}
|
140
|
+
</Container>
|
110
141
|
</Container>
|
111
142
|
) : null}
|
112
143
|
<Spacer y="md" />
|
@@ -1,83 +1,137 @@
|
|
1
|
-
import
|
1
|
+
import styled from "@emotion/styled";
|
2
|
+
import { useState } from "react";
|
3
|
+
import type { Chain } from "../../../../../../chains/types.js";
|
2
4
|
import type { ThirdwebClient } from "../../../../../../client/client.js";
|
3
5
|
import { shortenAddress } from "../../../../../../utils/address.js";
|
6
|
+
import type { Wallet } from "../../../../../../wallets/interfaces/wallet.js";
|
4
7
|
import type { WalletId } from "../../../../../../wallets/wallet-types.js";
|
5
8
|
import { useCustomTheme } from "../../../../../core/design-system/CustomThemeProvider.js";
|
6
9
|
import {
|
10
|
+
type fontSize,
|
7
11
|
iconSize,
|
8
12
|
radius,
|
9
13
|
spacing,
|
10
14
|
} from "../../../../../core/design-system/index.js";
|
11
|
-
import {
|
15
|
+
import { useChainName } from "../../../../../core/hooks/others/useChainQuery.js";
|
16
|
+
import type { TokenInfo } from "../../../../../core/utils/defaultTokens.js";
|
12
17
|
import { useEnsAvatar, useEnsName } from "../../../../../core/utils/wallet.js";
|
13
18
|
import { Img } from "../../../components/Img.js";
|
19
|
+
import { TokenIcon } from "../../../components/TokenIcon.js";
|
14
20
|
import { WalletImage } from "../../../components/WalletImage.js";
|
15
21
|
import { Container } from "../../../components/basic.js";
|
16
22
|
import { Button } from "../../../components/buttons.js";
|
17
23
|
import { Text } from "../../../components/text.js";
|
24
|
+
import { Blobbie } from "../../Blobbie.js";
|
25
|
+
import { formatTokenBalance } from "../formatTokenBalance.js";
|
26
|
+
import type { TokenBalance } from "./swap/PaymentSelectionScreen.js";
|
18
27
|
|
19
|
-
export function
|
20
|
-
address: string;
|
21
|
-
walletId: WalletId | undefined;
|
22
|
-
onClick: () => void;
|
28
|
+
export function WalletRowWithBalances(props: {
|
23
29
|
client: ThirdwebClient;
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
30
|
+
address: string;
|
31
|
+
wallet: Wallet;
|
32
|
+
balances: TokenBalance[];
|
33
|
+
onClick: (wallet: Wallet, token: TokenInfo, chain: Chain) => void;
|
28
34
|
}) {
|
29
35
|
const theme = useCustomTheme();
|
36
|
+
const [showAll, setShowAll] = useState(false);
|
37
|
+
const maxDisplayedBalances = 3;
|
38
|
+
const displayedBalances = showAll
|
39
|
+
? props.balances
|
40
|
+
: props.balances.slice(0, maxDisplayedBalances);
|
41
|
+
|
30
42
|
return (
|
31
43
|
<Container
|
32
44
|
bg="tertiaryBg"
|
33
45
|
style={{
|
34
46
|
borderRadius: radius.lg,
|
35
47
|
border: `1px solid ${theme.colors.borderColor}`,
|
36
|
-
...props.containerStyle,
|
37
48
|
}}
|
38
49
|
>
|
39
|
-
<
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
50
|
+
<Container style={{ padding: spacing.sm }}>
|
51
|
+
<WalletRow {...props} />
|
52
|
+
</Container>
|
53
|
+
<div style={{ borderTop: `1px solid ${theme.colors.borderColor}` }} />
|
54
|
+
<Container flex="column">
|
55
|
+
{props.balances.length > 0 ? (
|
56
|
+
<>
|
57
|
+
{displayedBalances.map((b) => (
|
58
|
+
<TokenBalanceRow
|
59
|
+
client={props.client}
|
60
|
+
onClick={() => props.onClick(props.wallet, b.token, b.chain)}
|
61
|
+
key={`${b.token.address}-${b.chain.id}`}
|
62
|
+
tokenBalance={b}
|
63
|
+
wallet={props.wallet}
|
64
|
+
/>
|
65
|
+
))}
|
66
|
+
{props.balances.length > maxDisplayedBalances && (
|
67
|
+
<StyledButton
|
68
|
+
variant="secondary"
|
69
|
+
onClick={() => setShowAll(!showAll)}
|
70
|
+
style={{
|
71
|
+
justifyContent: "start",
|
72
|
+
}}
|
73
|
+
>
|
74
|
+
<Text size="xs">{showAll ? "Show less" : "Show more"}</Text>
|
75
|
+
</StyledButton>
|
76
|
+
)}
|
77
|
+
</>
|
78
|
+
) : (
|
79
|
+
<Container style={{ padding: spacing.sm }}>
|
80
|
+
<Text size="sm" color="secondaryText">
|
81
|
+
Not enough funds
|
82
|
+
</Text>
|
83
|
+
</Container>
|
64
84
|
)}
|
65
|
-
</
|
85
|
+
</Container>
|
66
86
|
</Container>
|
67
87
|
);
|
68
88
|
}
|
69
89
|
|
90
|
+
function TokenBalanceRow(props: {
|
91
|
+
client: ThirdwebClient;
|
92
|
+
tokenBalance: TokenBalance;
|
93
|
+
wallet: Wallet;
|
94
|
+
onClick: (token: TokenInfo, wallet: Wallet) => void;
|
95
|
+
}) {
|
96
|
+
const { tokenBalance, wallet, onClick, client } = props;
|
97
|
+
const chainInfo = useChainName(tokenBalance.chain);
|
98
|
+
return (
|
99
|
+
<StyledButton
|
100
|
+
onClick={() => onClick(tokenBalance.token, wallet)}
|
101
|
+
variant="secondary"
|
102
|
+
>
|
103
|
+
<TokenIcon
|
104
|
+
token={tokenBalance.token}
|
105
|
+
chain={tokenBalance.chain}
|
106
|
+
size="md"
|
107
|
+
client={client}
|
108
|
+
/>
|
109
|
+
<Container flex="column" gap="3xs">
|
110
|
+
<Text size="xs" color="primaryText">
|
111
|
+
{tokenBalance.token.symbol}
|
112
|
+
</Text>
|
113
|
+
{chainInfo && <Text size="xs">{chainInfo.name}</Text>}
|
114
|
+
</Container>
|
115
|
+
<div style={{ flex: 1 }} />
|
116
|
+
<Container flex="row" center="y" gap="3xs">
|
117
|
+
<Text size="xs" color="secondaryText">
|
118
|
+
{formatTokenBalance(tokenBalance.balance, true, 3)}
|
119
|
+
</Text>
|
120
|
+
</Container>
|
121
|
+
</StyledButton>
|
122
|
+
);
|
123
|
+
}
|
124
|
+
|
70
125
|
export function WalletRow(props: {
|
71
126
|
client: ThirdwebClient;
|
72
127
|
address: string;
|
128
|
+
iconSize?: keyof typeof iconSize;
|
129
|
+
textSize?: keyof typeof fontSize;
|
73
130
|
walletId?: WalletId;
|
74
131
|
}) {
|
75
132
|
const { client, address } = props;
|
76
|
-
const
|
77
|
-
const
|
78
|
-
(x) => x.getAccount()?.address === props.address,
|
79
|
-
);
|
80
|
-
const walletId = props.walletId || wallet?.id;
|
133
|
+
const walletId = props.walletId;
|
134
|
+
const theme = useCustomTheme();
|
81
135
|
const ensNameQuery = useEnsName({
|
82
136
|
client,
|
83
137
|
address,
|
@@ -92,20 +146,54 @@ export function WalletRow(props: {
|
|
92
146
|
{ensAvatarQuery.data ? (
|
93
147
|
<Img
|
94
148
|
src={ensAvatarQuery.data}
|
95
|
-
width={iconSize.md}
|
96
|
-
height={iconSize.md}
|
149
|
+
width={props.iconSize ? iconSize[props.iconSize] : iconSize.md}
|
150
|
+
height={props.iconSize ? iconSize[props.iconSize] : iconSize.md}
|
97
151
|
style={{
|
98
|
-
borderRadius:
|
152
|
+
borderRadius: "100%",
|
153
|
+
overflow: "hidden",
|
154
|
+
border: `1px solid ${theme.colors.borderColor}`,
|
99
155
|
}}
|
100
156
|
client={props.client}
|
101
157
|
/>
|
102
158
|
) : walletId ? (
|
103
|
-
<WalletImage
|
104
|
-
|
159
|
+
<WalletImage
|
160
|
+
id={walletId}
|
161
|
+
size={props.iconSize || iconSize.md}
|
162
|
+
client={props.client}
|
163
|
+
/>
|
164
|
+
) : (
|
165
|
+
<Container
|
166
|
+
style={{
|
167
|
+
width: iconSize.md,
|
168
|
+
height: iconSize.md,
|
169
|
+
borderRadius: "100%",
|
170
|
+
overflow: "hidden",
|
171
|
+
border: `1px solid ${theme.colors.borderColor}`,
|
172
|
+
}}
|
173
|
+
>
|
174
|
+
<Blobbie address={props.address} size={Number(iconSize.md)} />
|
175
|
+
</Container>
|
176
|
+
)}
|
105
177
|
|
106
|
-
<Text size="sm" color="primaryText">
|
178
|
+
<Text size={props.textSize || "sm"} color="primaryText">
|
107
179
|
{addressOrENS || shortenAddress(props.address)}
|
108
180
|
</Text>
|
109
181
|
</Container>
|
110
182
|
);
|
111
183
|
}
|
184
|
+
|
185
|
+
const StyledButton = /* @__PURE__ */ styled(Button)((_) => {
|
186
|
+
const theme = useCustomTheme();
|
187
|
+
return {
|
188
|
+
background: theme.colors.tertiaryBg,
|
189
|
+
justifyContent: "flex-start",
|
190
|
+
flexDirection: "row",
|
191
|
+
padding: spacing.sm,
|
192
|
+
gap: spacing.sm,
|
193
|
+
"&:hover": {
|
194
|
+
background: theme.colors.secondaryButtonBg,
|
195
|
+
transform: "scale(1.01)",
|
196
|
+
},
|
197
|
+
transition: "background 200ms ease, transform 150ms ease",
|
198
|
+
};
|
199
|
+
});
|
@@ -8,7 +8,6 @@ import type { SupportedChainAndTokens } from "../swap/useSwapSupportedChains.js"
|
|
8
8
|
// change the current method if it should be disabled
|
9
9
|
// return whether the payment selection should be shown or not ( if only one payment method is enabled, don't show the selection )
|
10
10
|
export type PaymentMethods = {
|
11
|
-
showPaymentSelection: boolean;
|
12
11
|
buyWithFiatEnabled: boolean;
|
13
12
|
buyWithCryptoEnabled: boolean;
|
14
13
|
};
|
@@ -59,11 +58,8 @@ export function useEnabledPaymentMethods(options: {
|
|
59
58
|
const buyWithFiatEnabled = payOptions.buyWithFiat !== false && fiat;
|
60
59
|
const buyWithCryptoEnabled = payOptions.buyWithCrypto !== false && swap;
|
61
60
|
|
62
|
-
const showPaymentSelection = buyWithFiatEnabled && buyWithCryptoEnabled;
|
63
|
-
|
64
61
|
return {
|
65
62
|
buyWithFiatEnabled,
|
66
63
|
buyWithCryptoEnabled,
|
67
|
-
showPaymentSelection,
|
68
64
|
};
|
69
65
|
}
|
@@ -1,11 +1,10 @@
|
|
1
|
-
import { ChevronDownIcon } from "@radix-ui/react-icons";
|
2
1
|
import type { Chain } from "../../../../../../../chains/types.js";
|
3
2
|
import type { ThirdwebClient } from "../../../../../../../client/client.js";
|
4
3
|
import { formatNumber } from "../../../../../../../utils/formatNumber.js";
|
5
4
|
import type { Account } from "../../../../../../../wallets/interfaces/wallet.js";
|
5
|
+
import { useCustomTheme } from "../../../../../../core/design-system/CustomThemeProvider.js";
|
6
6
|
import {
|
7
7
|
fontSize,
|
8
|
-
iconSize,
|
9
8
|
radius,
|
10
9
|
spacing,
|
11
10
|
} from "../../../../../../core/design-system/index.js";
|
@@ -14,13 +13,12 @@ import { useWalletBalance } from "../../../../../../core/hooks/others/useWalletB
|
|
14
13
|
import type { TokenInfo } from "../../../../../../core/utils/defaultTokens.js";
|
15
14
|
import { Skeleton } from "../../../../components/Skeleton.js";
|
16
15
|
import { Container } from "../../../../components/basic.js";
|
17
|
-
import { Button } from "../../../../components/buttons.js";
|
18
16
|
import { Text } from "../../../../components/text.js";
|
19
17
|
import { TokenSymbol } from "../../../../components/token/TokenSymbol.js";
|
20
|
-
import { GenericWalletIcon } from "../../../icons/GenericWalletIcon.js";
|
21
18
|
import { formatTokenBalance } from "../../formatTokenBalance.js";
|
22
19
|
import { type NativeToken, isNativeToken } from "../../nativeToken.js";
|
23
20
|
import { PayTokenIcon } from "../PayTokenIcon.js";
|
21
|
+
import { WalletRow } from "../WalletSelectorButton.js";
|
24
22
|
|
25
23
|
/**
|
26
24
|
* Shows an amount "value" and renders the selected token and chain
|
@@ -28,9 +26,8 @@ import { PayTokenIcon } from "../PayTokenIcon.js";
|
|
28
26
|
* It also renders the balance of active wallet for the selected token in selected chain
|
29
27
|
* @internal
|
30
28
|
*/
|
31
|
-
export function
|
29
|
+
export function PayWithCryptoQuoteInfo(props: {
|
32
30
|
value: string;
|
33
|
-
onSelectToken: () => void;
|
34
31
|
chain: Chain;
|
35
32
|
token: TokenInfo | NativeToken;
|
36
33
|
isLoading: boolean;
|
@@ -39,8 +36,8 @@ export function PayWithCrypto(props: {
|
|
39
36
|
payerAccount: Account;
|
40
37
|
swapRequired: boolean;
|
41
38
|
}) {
|
39
|
+
const theme = useCustomTheme();
|
42
40
|
const { name } = useChainName(props.chain);
|
43
|
-
|
44
41
|
const balanceQuery = useWalletBalance({
|
45
42
|
address: props.payerAccount.address,
|
46
43
|
chain: props.chain,
|
@@ -51,36 +48,56 @@ export function PayWithCrypto(props: {
|
|
51
48
|
return (
|
52
49
|
<Container
|
53
50
|
bg="tertiaryBg"
|
54
|
-
borderColor="borderColor"
|
55
|
-
flex="row"
|
56
51
|
style={{
|
57
|
-
|
58
|
-
|
59
|
-
borderStyle: "solid",
|
60
|
-
flexWrap: "nowrap",
|
61
|
-
justifyContent: "space-between",
|
62
|
-
minHeight: "64px",
|
63
|
-
alignItems: "center",
|
52
|
+
borderRadius: radius.lg,
|
53
|
+
border: `1px solid ${theme.colors.borderColor}`,
|
64
54
|
...(props.swapRequired
|
65
|
-
? {
|
66
|
-
|
67
|
-
borderBottomLeftRadius:
|
68
|
-
borderBottomRightRadius:
|
69
|
-
}
|
55
|
+
? {
|
56
|
+
borderBottom: "none",
|
57
|
+
borderBottomLeftRadius: 0,
|
58
|
+
borderBottomRightRadius: 0,
|
59
|
+
}
|
60
|
+
: {}),
|
70
61
|
}}
|
71
62
|
>
|
72
|
-
{/*
|
73
|
-
<
|
74
|
-
|
75
|
-
|
63
|
+
{/* Wallet and balance */}
|
64
|
+
<Container
|
65
|
+
flex="row"
|
66
|
+
gap="sm"
|
67
|
+
style={{
|
68
|
+
justifyContent: "space-between",
|
69
|
+
padding: spacing.sm,
|
70
|
+
borderBottom: `1px solid ${theme.colors.borderColor}`,
|
71
|
+
}}
|
72
|
+
>
|
73
|
+
<WalletRow client={props.client} address={props.payerAccount.address} />
|
74
|
+
{balanceQuery.data ? (
|
75
|
+
<Container flex="row" gap="3xs" center="y">
|
76
|
+
<Text size="xs" color="secondaryText" weight={500}>
|
77
|
+
{formatTokenBalance(balanceQuery.data, false, 3)}
|
78
|
+
</Text>
|
79
|
+
<TokenSymbol
|
80
|
+
token={props.token}
|
81
|
+
chain={props.chain}
|
82
|
+
size="xs"
|
83
|
+
color="secondaryText"
|
84
|
+
/>
|
85
|
+
</Container>
|
86
|
+
) : (
|
87
|
+
<Skeleton width="70px" height={fontSize.xs} />
|
88
|
+
)}
|
89
|
+
</Container>
|
90
|
+
{/* Quoted price */}
|
91
|
+
<Container
|
92
|
+
flex="row"
|
76
93
|
gap="sm"
|
77
94
|
style={{
|
78
95
|
paddingInline: spacing.sm,
|
79
96
|
paddingBlock: spacing.sm,
|
80
97
|
minWidth: "50%",
|
81
98
|
justifyContent: "flex-start",
|
99
|
+
minHeight: "64px",
|
82
100
|
}}
|
83
|
-
disabled={props.freezeChainAndTokenSelection}
|
84
101
|
>
|
85
102
|
<PayTokenIcon
|
86
103
|
token={props.token}
|
@@ -89,57 +106,26 @@ export function PayWithCrypto(props: {
|
|
89
106
|
client={props.client}
|
90
107
|
/>
|
91
108
|
<Container flex="column" gap="3xs">
|
92
|
-
|
93
|
-
<
|
94
|
-
|
95
|
-
|
109
|
+
{props.isLoading ? (
|
110
|
+
<Skeleton width="120px" height={fontSize.md} color="borderColor" />
|
111
|
+
) : (
|
112
|
+
<Container flex="row" gap="xxs" center="y" color="primaryText">
|
113
|
+
<Text
|
114
|
+
size="md"
|
115
|
+
color={props.value ? "primaryText" : "secondaryText"}
|
116
|
+
>
|
117
|
+
{formatNumber(Number(props.value), 6) || ""}
|
118
|
+
</Text>
|
119
|
+
<TokenSymbol token={props.token} chain={props.chain} size="sm" />
|
120
|
+
</Container>
|
121
|
+
)}
|
96
122
|
{name ? (
|
97
123
|
<Text size="xs">{name}</Text>
|
98
124
|
) : (
|
99
125
|
<Skeleton width="90px" height={fontSize.xs} />
|
100
126
|
)}
|
101
127
|
</Container>
|
102
|
-
</
|
103
|
-
|
104
|
-
{/* Right */}
|
105
|
-
<div
|
106
|
-
style={{
|
107
|
-
flexGrow: 1,
|
108
|
-
flexShrink: 1,
|
109
|
-
display: "flex",
|
110
|
-
flexDirection: "column",
|
111
|
-
alignItems: "flex-end",
|
112
|
-
gap: spacing.xxs,
|
113
|
-
overflow: "hidden",
|
114
|
-
textOverflow: "ellipsis",
|
115
|
-
whiteSpace: "nowrap",
|
116
|
-
justifyContent: "center",
|
117
|
-
paddingRight: spacing.sm,
|
118
|
-
}}
|
119
|
-
>
|
120
|
-
{props.isLoading ? (
|
121
|
-
<Skeleton width="120px" height={fontSize.md} color="borderColor" />
|
122
|
-
) : (
|
123
|
-
<Text
|
124
|
-
size="md"
|
125
|
-
color={props.value ? "primaryText" : "secondaryText"}
|
126
|
-
style={{}}
|
127
|
-
>
|
128
|
-
{formatNumber(Number(props.value), 6) || ""}
|
129
|
-
</Text>
|
130
|
-
)}
|
131
|
-
|
132
|
-
<Container flex="row" gap="xxs" center="y" color="secondaryText">
|
133
|
-
<GenericWalletIcon size={fontSize.xs} />
|
134
|
-
{balanceQuery.data ? (
|
135
|
-
<Text size="xs" color="secondaryText" weight={500}>
|
136
|
-
{formatTokenBalance(balanceQuery.data, false)}
|
137
|
-
</Text>
|
138
|
-
) : (
|
139
|
-
<Skeleton width="70px" height={fontSize.xs} />
|
140
|
-
)}
|
141
|
-
</Container>
|
142
|
-
</div>
|
128
|
+
</Container>
|
143
129
|
</Container>
|
144
130
|
);
|
145
131
|
}
|