thirdweb 5.105.37 → 5.105.39

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 (114) hide show
  1. package/dist/cjs/adapters/eip1193/to-eip1193.js +12 -3
  2. package/dist/cjs/adapters/eip1193/to-eip1193.js.map +1 -1
  3. package/dist/cjs/bridge/Token.js +4 -1
  4. package/dist/cjs/bridge/Token.js.map +1 -1
  5. package/dist/cjs/react/web/ui/Bridge/BridgeOrchestrator.js +2 -2
  6. package/dist/cjs/react/web/ui/Bridge/BridgeOrchestrator.js.map +1 -1
  7. package/dist/cjs/react/web/ui/Bridge/CheckoutWidget.js +6 -0
  8. package/dist/cjs/react/web/ui/Bridge/CheckoutWidget.js.map +1 -1
  9. package/dist/cjs/react/web/ui/Bridge/DirectPayment.js +2 -12
  10. package/dist/cjs/react/web/ui/Bridge/DirectPayment.js.map +1 -1
  11. package/dist/cjs/react/web/ui/Bridge/FundWallet.js.map +1 -1
  12. package/dist/cjs/react/web/ui/Bridge/TransactionPayment.js.map +1 -1
  13. package/dist/cjs/react/web/ui/Bridge/payment-selection/WalletFiatSelection.js +2 -2
  14. package/dist/cjs/react/web/ui/Bridge/payment-selection/WalletFiatSelection.js.map +1 -1
  15. package/dist/cjs/react/web/ui/Bridge/payment-success/SuccessScreen.js +6 -2
  16. package/dist/cjs/react/web/ui/Bridge/payment-success/SuccessScreen.js.map +1 -1
  17. package/dist/cjs/stories/Bridge/SuccessScreen.stories.js +14 -1
  18. package/dist/cjs/stories/Bridge/SuccessScreen.stories.js.map +1 -1
  19. package/dist/cjs/stories/Bridge/fixtures.js.map +1 -1
  20. package/dist/cjs/version.js +1 -1
  21. package/dist/cjs/wallets/wallet-connect/controller.js +3 -2
  22. package/dist/cjs/wallets/wallet-connect/controller.js.map +1 -1
  23. package/dist/esm/adapters/eip1193/to-eip1193.js +12 -3
  24. package/dist/esm/adapters/eip1193/to-eip1193.js.map +1 -1
  25. package/dist/esm/bridge/Token.js +4 -1
  26. package/dist/esm/bridge/Token.js.map +1 -1
  27. package/dist/esm/react/web/ui/Bridge/BridgeOrchestrator.js +2 -2
  28. package/dist/esm/react/web/ui/Bridge/BridgeOrchestrator.js.map +1 -1
  29. package/dist/esm/react/web/ui/Bridge/CheckoutWidget.js +7 -1
  30. package/dist/esm/react/web/ui/Bridge/CheckoutWidget.js.map +1 -1
  31. package/dist/esm/react/web/ui/Bridge/DirectPayment.js +2 -12
  32. package/dist/esm/react/web/ui/Bridge/DirectPayment.js.map +1 -1
  33. package/dist/esm/react/web/ui/Bridge/FundWallet.js.map +1 -1
  34. package/dist/esm/react/web/ui/Bridge/TransactionPayment.js.map +1 -1
  35. package/dist/esm/react/web/ui/Bridge/payment-selection/WalletFiatSelection.js +2 -2
  36. package/dist/esm/react/web/ui/Bridge/payment-selection/WalletFiatSelection.js.map +1 -1
  37. package/dist/esm/react/web/ui/Bridge/payment-success/SuccessScreen.js +6 -2
  38. package/dist/esm/react/web/ui/Bridge/payment-success/SuccessScreen.js.map +1 -1
  39. package/dist/esm/stories/Bridge/SuccessScreen.stories.js +13 -0
  40. package/dist/esm/stories/Bridge/SuccessScreen.stories.js.map +1 -1
  41. package/dist/esm/stories/Bridge/fixtures.js.map +1 -1
  42. package/dist/esm/version.js +1 -1
  43. package/dist/esm/wallets/wallet-connect/controller.js +3 -2
  44. package/dist/esm/wallets/wallet-connect/controller.js.map +1 -1
  45. package/dist/types/adapters/eip1193/to-eip1193.d.ts.map +1 -1
  46. package/dist/types/bridge/Onramp.d.ts +2 -2
  47. package/dist/types/bridge/Onramp.d.ts.map +1 -1
  48. package/dist/types/bridge/Token.d.ts +7 -5
  49. package/dist/types/bridge/Token.d.ts.map +1 -1
  50. package/dist/types/bridge/index.d.ts +1 -1
  51. package/dist/types/bridge/index.d.ts.map +1 -1
  52. package/dist/types/bridge/types/Route.d.ts +7 -7
  53. package/dist/types/bridge/types/Route.d.ts.map +1 -1
  54. package/dist/types/bridge/types/Token.d.ts +2 -0
  55. package/dist/types/bridge/types/Token.d.ts.map +1 -1
  56. package/dist/types/pay/convert/get-token.d.ts +2 -2
  57. package/dist/types/pay/convert/get-token.d.ts.map +1 -1
  58. package/dist/types/react/core/hooks/usePaymentMethods.d.ts.map +1 -1
  59. package/dist/types/react/core/hooks/useTransactionDetails.d.ts +2 -2
  60. package/dist/types/react/core/hooks/useTransactionDetails.d.ts.map +1 -1
  61. package/dist/types/react/core/machines/paymentMachine.d.ts +4 -4
  62. package/dist/types/react/core/machines/paymentMachine.d.ts.map +1 -1
  63. package/dist/types/react/web/ui/Bridge/BridgeOrchestrator.d.ts +3 -3
  64. package/dist/types/react/web/ui/Bridge/BridgeOrchestrator.d.ts.map +1 -1
  65. package/dist/types/react/web/ui/Bridge/CheckoutWidget.d.ts.map +1 -1
  66. package/dist/types/react/web/ui/Bridge/DirectPayment.d.ts +3 -8
  67. package/dist/types/react/web/ui/Bridge/DirectPayment.d.ts.map +1 -1
  68. package/dist/types/react/web/ui/Bridge/FundWallet.d.ts +2 -2
  69. package/dist/types/react/web/ui/Bridge/FundWallet.d.ts.map +1 -1
  70. package/dist/types/react/web/ui/Bridge/TransactionPayment.d.ts +2 -2
  71. package/dist/types/react/web/ui/Bridge/TransactionPayment.d.ts.map +1 -1
  72. package/dist/types/react/web/ui/Bridge/payment-success/SuccessScreen.d.ts +5 -1
  73. package/dist/types/react/web/ui/Bridge/payment-success/SuccessScreen.d.ts.map +1 -1
  74. package/dist/types/stories/Bridge/BridgeOrchestrator.stories.d.ts +1 -1
  75. package/dist/types/stories/Bridge/BridgeOrchestrator.stories.d.ts.map +1 -1
  76. package/dist/types/stories/Bridge/DirectPayment.stories.d.ts +2 -2
  77. package/dist/types/stories/Bridge/DirectPayment.stories.d.ts.map +1 -1
  78. package/dist/types/stories/Bridge/FundWallet.stories.d.ts +2 -2
  79. package/dist/types/stories/Bridge/FundWallet.stories.d.ts.map +1 -1
  80. package/dist/types/stories/Bridge/PaymentDetails.stories.d.ts +1 -1
  81. package/dist/types/stories/Bridge/PaymentSelection.stories.d.ts +1 -1
  82. package/dist/types/stories/Bridge/SuccessScreen.stories.d.ts +2 -1
  83. package/dist/types/stories/Bridge/SuccessScreen.stories.d.ts.map +1 -1
  84. package/dist/types/stories/Bridge/TransactionPayment.stories.d.ts +1 -1
  85. package/dist/types/stories/Bridge/TransactionPayment.stories.d.ts.map +1 -1
  86. package/dist/types/stories/Bridge/fixtures.d.ts +4 -4
  87. package/dist/types/stories/Bridge/fixtures.d.ts.map +1 -1
  88. package/dist/types/stories/TokenBalanceRow.stories.d.ts +1 -1
  89. package/dist/types/version.d.ts +1 -1
  90. package/dist/types/wallets/wallet-connect/controller.d.ts.map +1 -1
  91. package/package.json +1 -1
  92. package/src/adapters/eip1193/to-eip1193.test.ts +10 -5
  93. package/src/adapters/eip1193/to-eip1193.ts +16 -5
  94. package/src/bridge/Onramp.ts +2 -2
  95. package/src/bridge/Token.test.ts +20 -2
  96. package/src/bridge/Token.ts +25 -9
  97. package/src/bridge/index.ts +1 -1
  98. package/src/bridge/types/Route.ts +7 -7
  99. package/src/bridge/types/Token.ts +3 -0
  100. package/src/pay/convert/get-token.ts +2 -2
  101. package/src/react/core/hooks/usePaymentMethods.ts +2 -2
  102. package/src/react/core/hooks/useTransactionDetails.ts +2 -2
  103. package/src/react/core/machines/paymentMachine.ts +4 -4
  104. package/src/react/web/ui/Bridge/BridgeOrchestrator.tsx +5 -5
  105. package/src/react/web/ui/Bridge/CheckoutWidget.tsx +16 -0
  106. package/src/react/web/ui/Bridge/DirectPayment.tsx +9 -31
  107. package/src/react/web/ui/Bridge/FundWallet.tsx +6 -2
  108. package/src/react/web/ui/Bridge/TransactionPayment.tsx +6 -2
  109. package/src/react/web/ui/Bridge/payment-selection/WalletFiatSelection.tsx +3 -3
  110. package/src/react/web/ui/Bridge/payment-success/SuccessScreen.tsx +16 -4
  111. package/src/stories/Bridge/SuccessScreen.stories.tsx +14 -0
  112. package/src/stories/Bridge/fixtures.ts +4 -4
  113. package/src/version.ts +1 -1
  114. package/src/wallets/wallet-connect/controller.ts +3 -2
@@ -22,8 +22,11 @@ import type { ConnectButton_connectModalOptions } from "../../../core/hooks/conn
22
22
  import type { SupportedTokens } from "../../../core/utils/defaultTokens.js";
23
23
  import { useConnectLocale } from "../ConnectWallet/locale/getConnectLocale.js";
24
24
  import { EmbedContainer } from "../ConnectWallet/Modal/ConnectEmbed.js";
25
+ import { Container } from "../components/basic.js";
26
+ import { Button } from "../components/buttons.js";
25
27
  import { DynamicHeight } from "../components/DynamicHeight.js";
26
28
  import { Spinner } from "../components/Spinner.js";
29
+ import { Text } from "../components/text.js";
27
30
  import type { LocaleId } from "../types.js";
28
31
  import { BridgeOrchestrator, type UIOptions } from "./BridgeOrchestrator.js";
29
32
  import { UnsupportedTokenScreen } from "./UnsupportedTokenScreen.js";
@@ -421,6 +424,19 @@ export function CheckoutWidget(props: CheckoutWidgetProps) {
421
424
  );
422
425
  }
423
426
 
427
+ if (bridgeDataQuery.isError) {
428
+ content = (
429
+ <Container flex="column" center="both" gap="md" p="md" py="xl">
430
+ <Text center size="md" weight={600}>
431
+ Something went wrong.
432
+ </Text>
433
+ <Button variant="ghost" onClick={() => bridgeDataQuery.refetch()}>
434
+ Retry
435
+ </Button>
436
+ </Container>
437
+ );
438
+ }
439
+
424
440
  return (
425
441
  <CustomThemeProvider theme={theme}>
426
442
  <EmbedContainer
@@ -1,11 +1,8 @@
1
1
  "use client";
2
- import type { Token } from "../../../../bridge/types/Token.js";
2
+ import type { TokenWithPrices } from "../../../../bridge/types/Token.js";
3
3
  import { defineChain } from "../../../../chains/utils.js";
4
4
  import type { ThirdwebClient } from "../../../../client/client.js";
5
5
  import type { Address } from "../../../../utils/address.js";
6
- import { useCustomTheme } from "../../../core/design-system/CustomThemeProvider.js";
7
- import { useActiveAccount } from "../../../core/hooks/wallets/useActiveAccount.js";
8
- import { ConnectButton } from "../ConnectWallet/ConnectButton.js";
9
6
  import { PoweredByThirdweb } from "../ConnectWallet/PoweredByTW.js";
10
7
  import { FiatValue } from "../ConnectWallet/screens/Buy/swap/FiatValue.js";
11
8
  import { Container, Line } from "../components/basic.js";
@@ -13,7 +10,6 @@ import { Button } from "../components/buttons.js";
13
10
  import { ChainName } from "../components/ChainName.js";
14
11
  import { Spacer } from "../components/Spacer.js";
15
12
  import { Text } from "../components/text.js";
16
- import type { PayEmbedConnectOptions } from "../PayEmbed.js";
17
13
  import type { UIOptions } from "./BridgeOrchestrator.js";
18
14
  import { ChainIcon } from "./common/TokenAndChain.js";
19
15
  import { WithHeader } from "./common/WithHeader.js";
@@ -32,12 +28,11 @@ export interface DirectPaymentProps {
32
28
  /**
33
29
  * Called when user continues with the payment
34
30
  */
35
- onContinue: (amount: string, token: Token, receiverAddress: Address) => void;
36
-
37
- /**
38
- * Connect options for wallet connection
39
- */
40
- connectOptions?: PayEmbedConnectOptions;
31
+ onContinue: (
32
+ amount: string,
33
+ token: TokenWithPrices,
34
+ receiverAddress: Address,
35
+ ) => void;
41
36
 
42
37
  /**
43
38
  * Whether to show thirdweb branding in the widget.
@@ -50,12 +45,9 @@ export function DirectPayment({
50
45
  uiOptions,
51
46
  client,
52
47
  onContinue,
53
- connectOptions,
54
48
  showThirdwebBranding = true,
55
49
  }: DirectPaymentProps) {
56
- const activeAccount = useActiveAccount();
57
50
  const chain = defineChain(uiOptions.paymentInfo.token.chainId);
58
- const theme = useCustomTheme();
59
51
  const handleContinue = () => {
60
52
  onContinue(
61
53
  uiOptions.paymentInfo.amount,
@@ -188,23 +180,9 @@ export function DirectPayment({
188
180
 
189
181
  {/* Action button */}
190
182
  <Container flex="column">
191
- {activeAccount ? (
192
- <Button fullWidth onClick={handleContinue} variant="primary">
193
- {buyNow}
194
- </Button>
195
- ) : (
196
- <ConnectButton
197
- client={client}
198
- connectButton={{
199
- label: buyNow,
200
- style: {
201
- width: "100%",
202
- },
203
- }}
204
- theme={theme}
205
- {...connectOptions}
206
- />
207
- )}
183
+ <Button fullWidth onClick={handleContinue} variant="primary">
184
+ {buyNow}
185
+ </Button>
208
186
 
209
187
  {showThirdwebBranding ? (
210
188
  <div>
@@ -1,7 +1,7 @@
1
1
  /** biome-ignore-all lint/a11y/useSemanticElements: FIXME */
2
2
  "use client";
3
3
  import { useRef, useState } from "react";
4
- import type { Token } from "../../../../bridge/types/Token.js";
4
+ import type { TokenWithPrices } from "../../../../bridge/types/Token.js";
5
5
  import type { ThirdwebClient } from "../../../../client/client.js";
6
6
  import { type Address, getAddress } from "../../../../utils/address.js";
7
7
  import { numberToPlainString } from "../../../../utils/formatNumber.js";
@@ -46,7 +46,11 @@ export interface FundWalletProps {
46
46
  /**
47
47
  * Called when continue is clicked with the resolved requirements
48
48
  */
49
- onContinue: (amount: string, token: Token, receiverAddress: Address) => void;
49
+ onContinue: (
50
+ amount: string,
51
+ token: TokenWithPrices,
52
+ receiverAddress: Address,
53
+ ) => void;
50
54
 
51
55
  /**
52
56
  * Quick buy amounts
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { useQuery } from "@tanstack/react-query";
3
- import type { Token } from "../../../../bridge/index.js";
3
+ import type { TokenWithPrices } from "../../../../bridge/types/Token.js";
4
4
  import type { ThirdwebClient } from "../../../../client/client.js";
5
5
  import { NATIVE_TOKEN_ADDRESS } from "../../../../constants/addresses.js";
6
6
  import {
@@ -46,7 +46,11 @@ export interface TransactionPaymentProps {
46
46
  /**
47
47
  * Called when user confirms transaction execution
48
48
  */
49
- onContinue: (amount: string, token: Token, receiverAddress: Address) => void;
49
+ onContinue: (
50
+ amount: string,
51
+ token: TokenWithPrices,
52
+ receiverAddress: Address,
53
+ ) => void;
50
54
 
51
55
  /**
52
56
  * Request to execute the transaction immediately (skips funding flow)
@@ -121,10 +121,10 @@ export function WalletFiatSelection({
121
121
  </Container>
122
122
  <Container flex="column" gap="3xs" style={{ flex: 1 }}>
123
123
  <Text color="primaryText" size="sm" style={{ fontWeight: 600 }}>
124
- Connect Another Wallet
124
+ Connect a Wallet
125
125
  </Text>
126
126
  <Text color="secondaryText" size="xs">
127
- Use a different wallet to pay
127
+ Pay with any web3 wallet
128
128
  </Text>
129
129
  </Container>
130
130
  </Container>
@@ -169,7 +169,7 @@ export function WalletFiatSelection({
169
169
  Pay with Card
170
170
  </Text>
171
171
  <Text color="secondaryText" size="xs">
172
- Buy crypto and bridge in one step
172
+ Onramp and pay in one step
173
173
  </Text>
174
174
  </Container>
175
175
  </Container>
@@ -42,6 +42,11 @@ export interface SuccessScreenProps {
42
42
  windowAdapter: WindowAdapter;
43
43
 
44
44
  client: ThirdwebClient;
45
+
46
+ /**
47
+ * Whether or not this payment is associated with a payment ID. If it does, we show a different message.
48
+ */
49
+ hasPaymentId?: boolean;
45
50
  }
46
51
 
47
52
  type ViewState = "success" | "detail";
@@ -53,6 +58,7 @@ export function SuccessScreen({
53
58
  onDone,
54
59
  windowAdapter,
55
60
  client,
61
+ hasPaymentId = false,
56
62
  }: SuccessScreenProps) {
57
63
  const theme = useCustomTheme();
58
64
  const [viewState, setViewState] = useState<ViewState>("success");
@@ -120,7 +126,11 @@ export function SuccessScreen({
120
126
  </Text>
121
127
 
122
128
  <Text center color="secondaryText" size="sm">
123
- Your cross-chain payment has been completed successfully.
129
+ {hasPaymentId
130
+ ? "You can now close this page and return to the application."
131
+ : uiOptions.mode === "transaction"
132
+ ? "Click continue to execute your transaction."
133
+ : "Your payment has been completed successfully."}
124
134
  </Text>
125
135
  </Container>
126
136
  <Spacer y="lg" />
@@ -135,9 +145,11 @@ export function SuccessScreen({
135
145
  View Payment Receipt
136
146
  </Button>
137
147
 
138
- <Button fullWidth onClick={onDone} variant="accent">
139
- {uiOptions.mode === "transaction" ? "Continue" : "Done"}
140
- </Button>
148
+ {!hasPaymentId && (
149
+ <Button fullWidth onClick={onDone} variant="accent">
150
+ {uiOptions.mode === "transaction" ? "Continue" : "Done"}
151
+ </Button>
152
+ )}
141
153
  </Container>
142
154
 
143
155
  {/* CSS Animations */}
@@ -222,3 +222,17 @@ export const TransactionPayment: Story = {
222
222
  backgrounds: { default: "light" },
223
223
  },
224
224
  };
225
+
226
+ export const PaymentId: Story = {
227
+ args: {
228
+ client: storyClient,
229
+ completedStatuses: mockBuyCompletedStatuses,
230
+ hasPaymentId: true,
231
+ preparedQuote: simpleBuyQuote,
232
+ theme: "light",
233
+ uiOptions: TRANSACTION_UI_OPTIONS.contractInteraction,
234
+ },
235
+ parameters: {
236
+ backgrounds: { default: "light" },
237
+ },
238
+ };
@@ -1,5 +1,5 @@
1
1
  import { stringify } from "viem";
2
- import type { Token } from "../../bridge/index.js";
2
+ import type { TokenWithPrices } from "../../bridge/types/Token.js";
3
3
  import { base } from "../../chains/chain-definitions/base.js";
4
4
  import { baseSepolia } from "../../chains/chain-definitions/base-sepolia.js";
5
5
  import { polygon } from "../../chains/chain-definitions/polygon.js";
@@ -19,7 +19,7 @@ import { toWei } from "../../utils/units.js";
19
19
  import type { Account, Wallet } from "../../wallets/interfaces/wallet.js";
20
20
  import { storyClient } from "../utils.js";
21
21
 
22
- export const ETH: Token = {
22
+ export const ETH: TokenWithPrices = {
23
23
  address: NATIVE_TOKEN_ADDRESS,
24
24
  chainId: 10,
25
25
  decimals: 18,
@@ -32,7 +32,7 @@ export const ETH: Token = {
32
32
  symbol: "ETH",
33
33
  };
34
34
 
35
- export const USDC: Token = {
35
+ export const USDC: TokenWithPrices = {
36
36
  address: getDefaultToken(base, "USDC")?.address ?? "",
37
37
  chainId: base.id,
38
38
  decimals: 6,
@@ -45,7 +45,7 @@ export const USDC: Token = {
45
45
  symbol: "USDC",
46
46
  };
47
47
 
48
- export const UNI: Token = {
48
+ export const UNI: TokenWithPrices = {
49
49
  address: "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984",
50
50
  chainId: 10,
51
51
  decimals: 18,
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "5.105.37";
1
+ export const version = "5.105.39";
@@ -142,6 +142,7 @@ export async function connectWC(
142
142
  "eth_sign",
143
143
  "personal_sign",
144
144
  "eth_signTypedData",
145
+ "eth_signTypedData_v4",
145
146
  "wallet_switchEthereumChain",
146
147
  "wallet_addEthereumChain",
147
148
  ],
@@ -185,8 +186,8 @@ export async function connectWC(
185
186
  }
186
187
  }
187
188
 
188
- if (wcOptions?.onDisplayUri) {
189
- provider.events.removeListener("display_uri", wcOptions.onDisplayUri);
189
+ if (onDisplayUri) {
190
+ provider.events.removeListener("display_uri", onDisplayUri);
190
191
  }
191
192
 
192
193
  return onConnect(