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.
Files changed (134) hide show
  1. package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js +19 -1
  2. package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
  3. package/dist/cjs/react/core/utils/isSmartWallet.js +4 -2
  4. package/dist/cjs/react/core/utils/isSmartWallet.js.map +1 -1
  5. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +27 -78
  6. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
  7. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js +27 -13
  8. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js.map +1 -1
  9. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js +50 -19
  10. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js.map +1 -1
  11. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.js +0 -2
  12. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.js.map +1 -1
  13. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js +21 -32
  14. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js.map +1 -1
  15. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.js +138 -0
  16. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.js.map +1 -0
  17. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js +1 -0
  18. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js.map +1 -1
  19. package/dist/cjs/react/web/ui/ConnectWallet/screens/formatTokenBalance.js +2 -2
  20. package/dist/cjs/react/web/ui/ConnectWallet/screens/formatTokenBalance.js.map +1 -1
  21. package/dist/cjs/react/web/wallets/shared/ConnectWalletSocialOptions.js +1 -1
  22. package/dist/cjs/react/web/wallets/shared/ConnectWalletSocialOptions.js.map +1 -1
  23. package/dist/cjs/version.js +1 -1
  24. package/dist/cjs/wallets/ecosystem/get-ecosystem-wallet-auth-options.js +23 -17
  25. package/dist/cjs/wallets/ecosystem/get-ecosystem-wallet-auth-options.js.map +1 -1
  26. package/dist/cjs/wallets/ecosystem/get-ecosystem-wallet-info.js +4 -13
  27. package/dist/cjs/wallets/ecosystem/get-ecosystem-wallet-info.js.map +1 -1
  28. package/dist/cjs/wallets/in-app/core/wallet/in-app-core.js +56 -4
  29. package/dist/cjs/wallets/in-app/core/wallet/in-app-core.js.map +1 -1
  30. package/dist/cjs/wallets/in-app/core/wallet/index.js +2 -50
  31. package/dist/cjs/wallets/in-app/core/wallet/index.js.map +1 -1
  32. package/dist/cjs/wallets/smart/lib/bundler.js +3 -1
  33. package/dist/cjs/wallets/smart/lib/bundler.js.map +1 -1
  34. package/dist/esm/react/core/hooks/transaction/useSendTransaction.js +19 -1
  35. package/dist/esm/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
  36. package/dist/esm/react/core/utils/isSmartWallet.js +4 -2
  37. package/dist/esm/react/core/utils/isSmartWallet.js.map +1 -1
  38. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +29 -80
  39. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
  40. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js +28 -14
  41. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js.map +1 -1
  42. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js +50 -19
  43. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js.map +1 -1
  44. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.js +0 -2
  45. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.js.map +1 -1
  46. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js +21 -32
  47. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js.map +1 -1
  48. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.js +135 -0
  49. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.js.map +1 -0
  50. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js +1 -1
  51. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js.map +1 -1
  52. package/dist/esm/react/web/ui/ConnectWallet/screens/formatTokenBalance.js +2 -2
  53. package/dist/esm/react/web/ui/ConnectWallet/screens/formatTokenBalance.js.map +1 -1
  54. package/dist/esm/react/web/wallets/shared/ConnectWalletSocialOptions.js +2 -2
  55. package/dist/esm/react/web/wallets/shared/ConnectWalletSocialOptions.js.map +1 -1
  56. package/dist/esm/version.js +1 -1
  57. package/dist/esm/wallets/ecosystem/get-ecosystem-wallet-auth-options.js +22 -16
  58. package/dist/esm/wallets/ecosystem/get-ecosystem-wallet-auth-options.js.map +1 -1
  59. package/dist/esm/wallets/ecosystem/get-ecosystem-wallet-info.js +4 -13
  60. package/dist/esm/wallets/ecosystem/get-ecosystem-wallet-info.js.map +1 -1
  61. package/dist/esm/wallets/in-app/core/wallet/in-app-core.js +56 -4
  62. package/dist/esm/wallets/in-app/core/wallet/in-app-core.js.map +1 -1
  63. package/dist/esm/wallets/in-app/core/wallet/index.js +2 -50
  64. package/dist/esm/wallets/in-app/core/wallet/index.js.map +1 -1
  65. package/dist/esm/wallets/smart/lib/bundler.js +3 -1
  66. package/dist/esm/wallets/smart/lib/bundler.js.map +1 -1
  67. package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts.map +1 -1
  68. package/dist/types/react/core/utils/isSmartWallet.d.ts.map +1 -1
  69. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.d.ts.map +1 -1
  70. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.d.ts +1 -1
  71. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.d.ts.map +1 -1
  72. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.d.ts +12 -8
  73. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.d.ts.map +1 -1
  74. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/types.d.ts +1 -1
  75. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/types.d.ts.map +1 -1
  76. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.d.ts +0 -1
  77. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.d.ts.map +1 -1
  78. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.d.ts +1 -2
  79. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.d.ts.map +1 -1
  80. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.d.ts +30 -0
  81. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.d.ts.map +1 -0
  82. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.d.ts +1 -0
  83. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.d.ts.map +1 -1
  84. package/dist/types/react/web/ui/ConnectWallet/screens/formatTokenBalance.d.ts +1 -1
  85. package/dist/types/react/web/ui/ConnectWallet/screens/formatTokenBalance.d.ts.map +1 -1
  86. package/dist/types/react/web/ui/components/token/TokenSymbol.d.ts +1 -1
  87. package/dist/types/react/web/ui/components/token/TokenSymbol.d.ts.map +1 -1
  88. package/dist/types/version.d.ts +1 -1
  89. package/dist/types/wallets/ecosystem/get-ecosystem-wallet-auth-options.d.ts +5 -1
  90. package/dist/types/wallets/ecosystem/get-ecosystem-wallet-auth-options.d.ts.map +1 -1
  91. package/dist/types/wallets/ecosystem/get-ecosystem-wallet-info.d.ts.map +1 -1
  92. package/dist/types/wallets/in-app/core/wallet/in-app-core.d.ts.map +1 -1
  93. package/dist/types/wallets/in-app/core/wallet/index.d.ts +2 -3
  94. package/dist/types/wallets/in-app/core/wallet/index.d.ts.map +1 -1
  95. package/dist/types/wallets/smart/lib/bundler.d.ts.map +1 -1
  96. package/dist/types/wallets/smart/types.d.ts +1 -1
  97. package/dist/types/wallets/smart/types.d.ts.map +1 -1
  98. package/package.json +11 -11
  99. package/src/extensions/unstoppable-domains/read/resolveName.test.ts +20 -17
  100. package/src/react/core/hooks/transaction/useSendTransaction.ts +34 -4
  101. package/src/react/core/utils/isSmartWallet.ts +4 -2
  102. package/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +35 -148
  103. package/src/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.tsx +62 -31
  104. package/src/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.tsx +136 -48
  105. package/src/react/web/ui/ConnectWallet/screens/Buy/main/types.ts +1 -1
  106. package/src/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.ts +0 -4
  107. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.tsx +57 -71
  108. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.tsx +251 -0
  109. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.ts +1 -1
  110. package/src/react/web/ui/ConnectWallet/screens/formatTokenBalance.ts +2 -1
  111. package/src/react/web/ui/components/token/TokenSymbol.tsx +2 -2
  112. package/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx +2 -2
  113. package/src/version.ts +1 -1
  114. package/src/wallets/ecosystem/get-ecosystem-wallet-auth-options.ts +36 -23
  115. package/src/wallets/ecosystem/get-ecosystem-wallet-info.ts +5 -21
  116. package/src/wallets/in-app/core/wallet/in-app-core.ts +62 -4
  117. package/src/wallets/in-app/core/wallet/index.ts +0 -59
  118. package/src/wallets/smart/lib/bundler.ts +4 -1
  119. package/src/wallets/smart/smart-wallet-dev.test.ts +23 -4
  120. package/src/wallets/smart/types.ts +1 -1
  121. package/dist/cjs/react/web/ui/ConnectWallet/icons/GenericWalletIcon.js +0 -12
  122. package/dist/cjs/react/web/ui/ConnectWallet/icons/GenericWalletIcon.js.map +0 -1
  123. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.js +0 -34
  124. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.js.map +0 -1
  125. package/dist/esm/react/web/ui/ConnectWallet/icons/GenericWalletIcon.js +0 -8
  126. package/dist/esm/react/web/ui/ConnectWallet/icons/GenericWalletIcon.js.map +0 -1
  127. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.js +0 -31
  128. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.js.map +0 -1
  129. package/dist/types/react/web/ui/ConnectWallet/icons/GenericWalletIcon.d.ts +0 -6
  130. package/dist/types/react/web/ui/ConnectWallet/icons/GenericWalletIcon.d.ts.map +0 -1
  131. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.d.ts +0 -14
  132. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.d.ts.map +0 -1
  133. package/src/react/web/ui/ConnectWallet/icons/GenericWalletIcon.tsx +0 -22
  134. 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 { iconSize, spacing } from "../../../../../core/design-system/index.js";
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 type { ERC20OrNativeToken } from "../nativeToken.js";
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
- ) : activeWallet ? (
81
- <Container
82
- flex="row"
83
- center="both"
84
- style={{
85
- padding: spacing.md,
86
- marginBottom: spacing.md,
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
- flexGrow: 1,
99
- borderBottom: "6px dotted",
100
- borderColor: theme.colors.secondaryIconColor,
101
- marginLeft: spacing.md,
102
- marginRight: spacing.md,
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
- <ChainIcon
106
- client={client}
107
- size={iconSize.xl}
108
- chainIconUrl={chainData.icon?.url}
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 { CheckIcon, ChevronDownIcon } from "@radix-ui/react-icons";
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 { useConnectedWallets } from "../../../../../core/hooks/wallets/useConnectedWallets.js";
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 WalletSelectorButton(props: {
20
- address: string;
21
- walletId: WalletId | undefined;
22
- onClick: () => void;
28
+ export function WalletRowWithBalances(props: {
23
29
  client: ThirdwebClient;
24
- containerStyle?: React.CSSProperties;
25
- disableChevron?: boolean;
26
- disabled?: boolean;
27
- checked?: boolean;
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
- <Button
40
- fullWidth
41
- disabled={props.disabled}
42
- onClick={props.onClick}
43
- variant="ghost"
44
- style={{
45
- justifyContent: "space-between",
46
- padding: spacing.sm,
47
- backgroundColor: theme.colors.tertiaryBg,
48
- }}
49
- gap="sm"
50
- >
51
- <WalletRow client={props.client} address={props.address} />
52
- {!props.disableChevron && (
53
- <ChevronDownIcon
54
- width={iconSize.sm}
55
- height={iconSize.sm}
56
- style={{
57
- color: theme.colors.secondaryText,
58
- }}
59
- />
60
- )}
61
-
62
- {props.checked && (
63
- <CheckIcon width={iconSize.md} height={iconSize.md} />
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
- </Button>
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 connectedWallets = useConnectedWallets();
77
- const wallet = connectedWallets.find(
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: radius.sm,
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 id={walletId} size={iconSize.md} client={props.client} />
104
- ) : null}
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
+ });
@@ -13,7 +13,7 @@ export type TransactionCostAndData = {
13
13
 
14
14
  export type SelectedScreen =
15
15
  | {
16
- id: "main" | "select-payment-method" | "buy-with-fiat" | "select-wallet";
16
+ id: "main" | "select-payment-method" | "buy-with-fiat";
17
17
  }
18
18
  | {
19
19
  id: "buy-with-crypto";
@@ -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 PayWithCrypto(props: {
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
- borderWidth: "1px",
58
- borderTopWidth: 0,
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
- ? { borderBottom: "none" }
66
- : {
67
- borderBottomLeftRadius: radius.md,
68
- borderBottomRightRadius: radius.md,
69
- }),
55
+ ? {
56
+ borderBottom: "none",
57
+ borderBottomLeftRadius: 0,
58
+ borderBottomRightRadius: 0,
59
+ }
60
+ : {}),
70
61
  }}
71
62
  >
72
- {/* Left */}
73
- <Button
74
- variant="ghost"
75
- onClick={props.onSelectToken}
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
- <Container flex="row" gap="xs" center="y" color="primaryText">
93
- <TokenSymbol token={props.token} chain={props.chain} size="sm" />
94
- <ChevronDownIcon width={iconSize.sm} height={iconSize.sm} />
95
- </Container>
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
- </Button>
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
  }