thirdweb 5.115.0-nightly-9e43da4ec0f88f32e988e445257fb518454c4c81-20251203000341 → 5.115.1

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 (116) hide show
  1. package/dist/cjs/react/core/hooks/usePaymentMethods.js +16 -7
  2. package/dist/cjs/react/core/hooks/usePaymentMethods.js.map +1 -1
  3. package/dist/cjs/react/core/hooks/useStepExecutor.js +73 -3
  4. package/dist/cjs/react/core/hooks/useStepExecutor.js.map +1 -1
  5. package/dist/cjs/react/web/ui/Bridge/BuyWidget.js +56 -13
  6. package/dist/cjs/react/web/ui/Bridge/BuyWidget.js.map +1 -1
  7. package/dist/cjs/react/web/ui/Bridge/CheckoutWidget.js +52 -13
  8. package/dist/cjs/react/web/ui/Bridge/CheckoutWidget.js.map +1 -1
  9. package/dist/cjs/react/web/ui/Bridge/ErrorBanner.js +12 -12
  10. package/dist/cjs/react/web/ui/Bridge/ErrorBanner.js.map +1 -1
  11. package/dist/cjs/react/web/ui/Bridge/QuoteLoader.js +1 -21
  12. package/dist/cjs/react/web/ui/Bridge/QuoteLoader.js.map +1 -1
  13. package/dist/cjs/react/web/ui/Bridge/TransactionWidget.js +52 -12
  14. package/dist/cjs/react/web/ui/Bridge/TransactionWidget.js.map +1 -1
  15. package/dist/cjs/react/web/ui/Bridge/UnsupportedTokenScreen.js +13 -12
  16. package/dist/cjs/react/web/ui/Bridge/UnsupportedTokenScreen.js.map +1 -1
  17. package/dist/cjs/react/web/ui/Bridge/bridge-widget/bridge-widget.js +10 -11
  18. package/dist/cjs/react/web/ui/Bridge/bridge-widget/bridge-widget.js.map +1 -1
  19. package/dist/cjs/react/web/ui/Bridge/payment-details/PaymentDetails.js +0 -28
  20. package/dist/cjs/react/web/ui/Bridge/payment-details/PaymentDetails.js.map +1 -1
  21. package/dist/cjs/react/web/ui/Bridge/payment-selection/PaymentSelection.js +8 -13
  22. package/dist/cjs/react/web/ui/Bridge/payment-selection/PaymentSelection.js.map +1 -1
  23. package/dist/cjs/react/web/ui/Bridge/payment-selection/TokenSelection.js +1 -4
  24. package/dist/cjs/react/web/ui/Bridge/payment-selection/TokenSelection.js.map +1 -1
  25. package/dist/cjs/react/web/ui/Bridge/payment-success/SuccessScreen.js +35 -33
  26. package/dist/cjs/react/web/ui/Bridge/payment-success/SuccessScreen.js.map +1 -1
  27. package/dist/cjs/react/web/ui/Bridge/swap-widget/SwapWidget.js +21 -11
  28. package/dist/cjs/react/web/ui/Bridge/swap-widget/SwapWidget.js.map +1 -1
  29. package/dist/cjs/version.js +1 -1
  30. package/dist/cjs/version.js.map +1 -1
  31. package/dist/cjs/wallets/eip5792/wait-for-calls-receipt.js +3 -2
  32. package/dist/cjs/wallets/eip5792/wait-for-calls-receipt.js.map +1 -1
  33. package/dist/cjs/wallets/injected/index.js +4 -1
  34. package/dist/cjs/wallets/injected/index.js.map +1 -1
  35. package/dist/cjs/wallets/utils/getWalletBalance.js +3 -1
  36. package/dist/cjs/wallets/utils/getWalletBalance.js.map +1 -1
  37. package/dist/esm/react/core/hooks/usePaymentMethods.js +16 -7
  38. package/dist/esm/react/core/hooks/usePaymentMethods.js.map +1 -1
  39. package/dist/esm/react/core/hooks/useStepExecutor.js +73 -3
  40. package/dist/esm/react/core/hooks/useStepExecutor.js.map +1 -1
  41. package/dist/esm/react/web/ui/Bridge/BuyWidget.js +57 -14
  42. package/dist/esm/react/web/ui/Bridge/BuyWidget.js.map +1 -1
  43. package/dist/esm/react/web/ui/Bridge/CheckoutWidget.js +53 -14
  44. package/dist/esm/react/web/ui/Bridge/CheckoutWidget.js.map +1 -1
  45. package/dist/esm/react/web/ui/Bridge/ErrorBanner.js +12 -12
  46. package/dist/esm/react/web/ui/Bridge/ErrorBanner.js.map +1 -1
  47. package/dist/esm/react/web/ui/Bridge/QuoteLoader.js +1 -21
  48. package/dist/esm/react/web/ui/Bridge/QuoteLoader.js.map +1 -1
  49. package/dist/esm/react/web/ui/Bridge/TransactionWidget.js +53 -13
  50. package/dist/esm/react/web/ui/Bridge/TransactionWidget.js.map +1 -1
  51. package/dist/esm/react/web/ui/Bridge/UnsupportedTokenScreen.js +13 -12
  52. package/dist/esm/react/web/ui/Bridge/UnsupportedTokenScreen.js.map +1 -1
  53. package/dist/esm/react/web/ui/Bridge/bridge-widget/bridge-widget.js +11 -12
  54. package/dist/esm/react/web/ui/Bridge/bridge-widget/bridge-widget.js.map +1 -1
  55. package/dist/esm/react/web/ui/Bridge/payment-details/PaymentDetails.js +0 -28
  56. package/dist/esm/react/web/ui/Bridge/payment-details/PaymentDetails.js.map +1 -1
  57. package/dist/esm/react/web/ui/Bridge/payment-selection/PaymentSelection.js +8 -13
  58. package/dist/esm/react/web/ui/Bridge/payment-selection/PaymentSelection.js.map +1 -1
  59. package/dist/esm/react/web/ui/Bridge/payment-selection/TokenSelection.js +1 -4
  60. package/dist/esm/react/web/ui/Bridge/payment-selection/TokenSelection.js.map +1 -1
  61. package/dist/esm/react/web/ui/Bridge/payment-success/SuccessScreen.js +37 -35
  62. package/dist/esm/react/web/ui/Bridge/payment-success/SuccessScreen.js.map +1 -1
  63. package/dist/esm/react/web/ui/Bridge/swap-widget/SwapWidget.js +22 -12
  64. package/dist/esm/react/web/ui/Bridge/swap-widget/SwapWidget.js.map +1 -1
  65. package/dist/esm/version.js +1 -1
  66. package/dist/esm/version.js.map +1 -1
  67. package/dist/esm/wallets/eip5792/wait-for-calls-receipt.js +3 -2
  68. package/dist/esm/wallets/eip5792/wait-for-calls-receipt.js.map +1 -1
  69. package/dist/esm/wallets/injected/index.js +4 -1
  70. package/dist/esm/wallets/injected/index.js.map +1 -1
  71. package/dist/esm/wallets/utils/getWalletBalance.js +3 -1
  72. package/dist/esm/wallets/utils/getWalletBalance.js.map +1 -1
  73. package/dist/scripts/bridge-widget.js +114 -114
  74. package/dist/types/react/core/hooks/usePaymentMethods.d.ts +2 -2
  75. package/dist/types/react/core/hooks/usePaymentMethods.d.ts.map +1 -1
  76. package/dist/types/react/core/hooks/useStepExecutor.d.ts.map +1 -1
  77. package/dist/types/react/web/ui/Bridge/BuyWidget.d.ts.map +1 -1
  78. package/dist/types/react/web/ui/Bridge/CheckoutWidget.d.ts.map +1 -1
  79. package/dist/types/react/web/ui/Bridge/ErrorBanner.d.ts.map +1 -1
  80. package/dist/types/react/web/ui/Bridge/QuoteLoader.d.ts +1 -1
  81. package/dist/types/react/web/ui/Bridge/QuoteLoader.d.ts.map +1 -1
  82. package/dist/types/react/web/ui/Bridge/TransactionWidget.d.ts.map +1 -1
  83. package/dist/types/react/web/ui/Bridge/bridge-widget/bridge-widget.d.ts.map +1 -1
  84. package/dist/types/react/web/ui/Bridge/payment-details/PaymentDetails.d.ts.map +1 -1
  85. package/dist/types/react/web/ui/Bridge/payment-selection/PaymentSelection.d.ts +2 -2
  86. package/dist/types/react/web/ui/Bridge/payment-selection/PaymentSelection.d.ts.map +1 -1
  87. package/dist/types/react/web/ui/Bridge/payment-selection/TokenSelection.d.ts.map +1 -1
  88. package/dist/types/react/web/ui/Bridge/payment-success/SuccessScreen.d.ts.map +1 -1
  89. package/dist/types/react/web/ui/Bridge/swap-widget/SwapWidget.d.ts.map +1 -1
  90. package/dist/types/react/web/ui/Bridge/types.d.ts +2 -1
  91. package/dist/types/react/web/ui/Bridge/types.d.ts.map +1 -1
  92. package/dist/types/version.d.ts +1 -1
  93. package/dist/types/version.d.ts.map +1 -1
  94. package/dist/types/wallets/eip5792/wait-for-calls-receipt.d.ts.map +1 -1
  95. package/dist/types/wallets/injected/index.d.ts.map +1 -1
  96. package/dist/types/wallets/utils/getWalletBalance.d.ts.map +1 -1
  97. package/package.json +5 -5
  98. package/src/react/core/hooks/usePaymentMethods.ts +25 -11
  99. package/src/react/core/hooks/useStepExecutor.ts +94 -6
  100. package/src/react/web/ui/Bridge/BuyWidget.tsx +63 -14
  101. package/src/react/web/ui/Bridge/CheckoutWidget.tsx +61 -14
  102. package/src/react/web/ui/Bridge/ErrorBanner.tsx +11 -12
  103. package/src/react/web/ui/Bridge/QuoteLoader.tsx +1 -24
  104. package/src/react/web/ui/Bridge/TransactionWidget.tsx +61 -13
  105. package/src/react/web/ui/Bridge/UnsupportedTokenScreen.tsx +12 -12
  106. package/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx +10 -12
  107. package/src/react/web/ui/Bridge/payment-details/PaymentDetails.tsx +0 -35
  108. package/src/react/web/ui/Bridge/payment-selection/PaymentSelection.tsx +10 -16
  109. package/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx +1 -4
  110. package/src/react/web/ui/Bridge/payment-success/SuccessScreen.tsx +37 -35
  111. package/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx +22 -12
  112. package/src/react/web/ui/Bridge/types.ts +2 -1
  113. package/src/version.ts +1 -1
  114. package/src/wallets/eip5792/wait-for-calls-receipt.ts +3 -2
  115. package/src/wallets/injected/index.ts +4 -1
  116. package/src/wallets/utils/getWalletBalance.ts +5 -1
@@ -1,7 +1,6 @@
1
1
  "use client";
2
2
 
3
- import { useQuery } from "@tanstack/react-query";
4
- import { useCallback, useMemo, useState } from "react";
3
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
5
4
  import { trackPayEvent } from "../../../../analytics/track/pay.js";
6
5
  import type { TokenWithPrices } from "../../../../bridge/index.js";
7
6
  import type { Chain } from "../../../../chains/types.js";
@@ -335,18 +334,17 @@ function CheckoutWidgetContentWrapper(props: CheckoutWidgetProps) {
335
334
  client: props.client,
336
335
  });
337
336
 
338
- useQuery({
339
- queryFn: () => {
340
- trackPayEvent({
341
- client: props.client,
342
- event: "ub:ui:checkout_widget:render",
343
- toChainId: props.chain.id,
344
- toToken: props.tokenAddress,
345
- });
346
- return true;
347
- },
348
- queryKey: ["checkout_widget:render"],
349
- });
337
+ const hasFiredRenderEvent = useRef(false);
338
+ useEffect(() => {
339
+ if (hasFiredRenderEvent.current) return;
340
+ hasFiredRenderEvent.current = true;
341
+ trackPayEvent({
342
+ client: props.client,
343
+ event: "ub:ui:checkout_widget:render",
344
+ toChainId: props.chain.id,
345
+ toToken: props.tokenAddress,
346
+ });
347
+ }, [props.client, props.chain.id, props.tokenAddress]);
350
348
 
351
349
  // if branding is disabled for widget, disable it for connect options too
352
350
  const connectOptions = useMemo(() => {
@@ -522,6 +520,12 @@ function CheckoutWidgetContent(
522
520
  buttonLabel={props.buttonLabel}
523
521
  // others
524
522
  onContinue={(destinationAmount, destinationToken, receiverAddress) => {
523
+ trackPayEvent({
524
+ client: props.client,
525
+ event: "payment_selection",
526
+ toChainId: destinationToken.chainId,
527
+ toToken: destinationToken.address,
528
+ });
525
529
  setScreen({
526
530
  id: "2:methodSelection",
527
531
  destinationAmount,
@@ -556,6 +560,20 @@ function CheckoutWidgetContent(
556
560
  handleError(error, undefined);
557
561
  }}
558
562
  onPaymentMethodSelected={(paymentMethod) => {
563
+ trackPayEvent({
564
+ chainId:
565
+ paymentMethod.type === "wallet"
566
+ ? paymentMethod.originToken.chainId
567
+ : undefined,
568
+ client: props.client,
569
+ event: "ub:ui:loading_quote:direct_payment",
570
+ fromToken:
571
+ paymentMethod.type === "wallet"
572
+ ? paymentMethod.originToken.address
573
+ : undefined,
574
+ toChainId: screen.destinationToken.chainId,
575
+ toToken: screen.destinationToken.address,
576
+ });
559
577
  setScreen({
560
578
  ...screen,
561
579
  id: "3:load-quote",
@@ -589,6 +607,35 @@ function CheckoutWidgetContent(
589
607
  handleError(error, undefined);
590
608
  }}
591
609
  onQuoteReceived={(preparedQuote, request) => {
610
+ if (
611
+ preparedQuote.type === "buy" ||
612
+ preparedQuote.type === "sell" ||
613
+ preparedQuote.type === "transfer"
614
+ ) {
615
+ trackPayEvent({
616
+ chainId:
617
+ preparedQuote.type === "transfer"
618
+ ? preparedQuote.intent.chainId
619
+ : preparedQuote.intent.originChainId,
620
+ client: props.client,
621
+ event: "payment_details",
622
+ fromToken:
623
+ preparedQuote.type === "transfer"
624
+ ? preparedQuote.intent.tokenAddress
625
+ : preparedQuote.intent.originTokenAddress,
626
+ toChainId:
627
+ preparedQuote.type === "transfer"
628
+ ? preparedQuote.intent.chainId
629
+ : preparedQuote.intent.destinationChainId,
630
+ toToken:
631
+ preparedQuote.type === "transfer"
632
+ ? preparedQuote.intent.tokenAddress
633
+ : preparedQuote.intent.destinationTokenAddress,
634
+ walletAddress:
635
+ screen.paymentMethod.payerWallet?.getAccount()?.address,
636
+ walletType: screen.paymentMethod.payerWallet?.id,
637
+ });
638
+ }
592
639
  setScreen({
593
640
  ...screen,
594
641
  id: "4:preview",
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { CrossCircledIcon } from "@radix-ui/react-icons";
3
- import { useQuery } from "@tanstack/react-query";
3
+ import { useEffect, useRef } from "react";
4
4
  import { trackPayEvent } from "../../../../analytics/track/pay.js";
5
5
  import type { ThirdwebClient } from "../../../../client/client.js";
6
6
  import { useCustomTheme } from "../../../core/design-system/CustomThemeProvider.js";
@@ -38,17 +38,16 @@ export function ErrorBanner({
38
38
 
39
39
  const { userMessage } = useBridgeError({ error });
40
40
 
41
- useQuery({
42
- queryFn: () => {
43
- trackPayEvent({
44
- client,
45
- error: error.message,
46
- event: "ub:ui:error",
47
- });
48
- return true;
49
- },
50
- queryKey: ["error_banner", userMessage],
51
- });
41
+ const hasFiredErrorEvent = useRef(false);
42
+ useEffect(() => {
43
+ if (hasFiredErrorEvent.current) return;
44
+ hasFiredErrorEvent.current = true;
45
+ trackPayEvent({
46
+ client,
47
+ error: error.message,
48
+ event: "ub:ui:error",
49
+ });
50
+ }, [client, error.message]);
52
51
 
53
52
  return (
54
53
  <Container flex="column" fullHeight gap="md" p="md">
@@ -1,7 +1,5 @@
1
1
  "use client";
2
- import { useQuery } from "@tanstack/react-query";
3
2
  import { useEffect } from "react";
4
- import { trackPayEvent } from "../../../../analytics/track/pay.js";
5
3
  import type { Token } from "../../../../bridge/types/Token.js";
6
4
  import type { ThirdwebClient } from "../../../../client/client.js";
7
5
  import type { PurchaseData } from "../../../../pay/types.js";
@@ -92,7 +90,7 @@ export function QuoteLoader({
92
90
  purchaseData,
93
91
  paymentLinkId,
94
92
  feePayer,
95
- mode,
93
+ mode: _mode,
96
94
  }: QuoteLoaderProps) {
97
95
  const request: BridgePrepareRequest = getBridgeParams({
98
96
  amount,
@@ -107,27 +105,6 @@ export function QuoteLoader({
107
105
  });
108
106
  const prepareQuery = useBridgePrepare(request);
109
107
 
110
- useQuery({
111
- queryFn: () => {
112
- trackPayEvent({
113
- chainId:
114
- paymentMethod.type === "wallet"
115
- ? paymentMethod.originToken.chainId
116
- : undefined,
117
- client,
118
- event: `ub:ui:loading_quote:${mode}`,
119
- fromToken:
120
- paymentMethod.type === "wallet"
121
- ? paymentMethod.originToken.address
122
- : undefined,
123
- toChainId: destinationToken.chainId,
124
- toToken: destinationToken.address,
125
- });
126
- return true;
127
- },
128
- queryKey: ["loading_quote", paymentMethod.type],
129
- });
130
-
131
108
  // Handle successful quote
132
109
  useEffect(() => {
133
110
  if (prepareQuery.data) {
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  import { useQuery } from "@tanstack/react-query";
4
- import { useCallback, useMemo, useState } from "react";
4
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
5
5
  import { trackPayEvent } from "../../../../analytics/track/pay.js";
6
6
  import type { TokenWithPrices } from "../../../../bridge/index.js";
7
7
  import type { Chain } from "../../../../chains/types.js";
@@ -349,18 +349,17 @@ type TransactionQueryResult =
349
349
  };
350
350
 
351
351
  export function TransactionWidgetContentWrapper(props: TransactionWidgetProps) {
352
- useQuery({
353
- queryFn: () => {
354
- trackPayEvent({
355
- chainId: props.transaction.chain.id,
356
- client: props.client,
357
- event: "ub:ui:transaction_widget:render",
358
- toToken: props.tokenAddress,
359
- });
360
- return true;
361
- },
362
- queryKey: ["transaction_widget:render"],
363
- });
352
+ const hasFiredRenderEvent = useRef(false);
353
+ useEffect(() => {
354
+ if (hasFiredRenderEvent.current) return;
355
+ hasFiredRenderEvent.current = true;
356
+ trackPayEvent({
357
+ chainId: props.transaction.chain.id,
358
+ client: props.client,
359
+ event: "ub:ui:transaction_widget:render",
360
+ toToken: props.tokenAddress,
361
+ });
362
+ }, [props.client, props.transaction.chain.id, props.tokenAddress]);
364
363
 
365
364
  const localQuery = useConnectLocale(props.locale || "en_US");
366
365
 
@@ -573,6 +572,12 @@ function TransactionWidgetContent(
573
572
  }}
574
573
  connectOptions={props.connectOptions}
575
574
  onContinue={(destinationAmount, destinationToken, receiverAddress) => {
575
+ trackPayEvent({
576
+ client: props.client,
577
+ event: "payment_selection",
578
+ toChainId: destinationToken.chainId,
579
+ toToken: destinationToken.address,
580
+ });
576
581
  setScreen({
577
582
  id: "buy:1.methodSelection",
578
583
  destinationAmount,
@@ -618,6 +623,20 @@ function TransactionWidgetContent(
618
623
  handleError(error);
619
624
  }}
620
625
  onPaymentMethodSelected={(paymentMethod) => {
626
+ trackPayEvent({
627
+ chainId:
628
+ paymentMethod.type === "wallet"
629
+ ? paymentMethod.originToken.chainId
630
+ : undefined,
631
+ client: props.client,
632
+ event: "ub:ui:loading_quote:transaction",
633
+ fromToken:
634
+ paymentMethod.type === "wallet"
635
+ ? paymentMethod.originToken.address
636
+ : undefined,
637
+ toChainId: screen.destinationToken.chainId,
638
+ toToken: screen.destinationToken.address,
639
+ });
621
640
  setScreen({
622
641
  ...screen,
623
642
  id: "buy:2.load-quote",
@@ -651,6 +670,35 @@ function TransactionWidgetContent(
651
670
  handleError(error);
652
671
  }}
653
672
  onQuoteReceived={(preparedQuote, request) => {
673
+ if (
674
+ preparedQuote.type === "buy" ||
675
+ preparedQuote.type === "sell" ||
676
+ preparedQuote.type === "transfer"
677
+ ) {
678
+ trackPayEvent({
679
+ chainId:
680
+ preparedQuote.type === "transfer"
681
+ ? preparedQuote.intent.chainId
682
+ : preparedQuote.intent.originChainId,
683
+ client: props.client,
684
+ event: "payment_details",
685
+ fromToken:
686
+ preparedQuote.type === "transfer"
687
+ ? preparedQuote.intent.tokenAddress
688
+ : preparedQuote.intent.originTokenAddress,
689
+ toChainId:
690
+ preparedQuote.type === "transfer"
691
+ ? preparedQuote.intent.chainId
692
+ : preparedQuote.intent.destinationChainId,
693
+ toToken:
694
+ preparedQuote.type === "transfer"
695
+ ? preparedQuote.intent.tokenAddress
696
+ : preparedQuote.intent.destinationTokenAddress,
697
+ walletAddress:
698
+ screen.paymentMethod.payerWallet?.getAccount()?.address,
699
+ walletType: screen.paymentMethod.payerWallet?.id,
700
+ });
701
+ }
654
702
  setScreen({
655
703
  ...screen,
656
704
  id: "buy:3.preview",
@@ -1,4 +1,4 @@
1
- import { useQuery } from "@tanstack/react-query";
1
+ import { useEffect, useRef } from "react";
2
2
  import { trackPayEvent } from "../../../../analytics/track/pay.js";
3
3
  import type { Chain } from "../../../../chains/types.js";
4
4
  import type { ThirdwebClient } from "../../../../client/client.js";
@@ -27,17 +27,17 @@ export function UnsupportedTokenScreen(props: UnsupportedTokenScreenProps) {
27
27
 
28
28
  const { data: chainMetadata } = useChainMetadata(chain);
29
29
 
30
- useQuery({
31
- queryFn: () => {
32
- trackPayEvent({
33
- chainId: chain.id,
34
- client,
35
- event: "ub:ui:unsupported_token",
36
- fromToken: tokenAddress,
37
- });
38
- },
39
- queryKey: ["unsupported_token"],
40
- });
30
+ const hasFiredUnsupportedEvent = useRef(false);
31
+ useEffect(() => {
32
+ if (hasFiredUnsupportedEvent.current) return;
33
+ hasFiredUnsupportedEvent.current = true;
34
+ trackPayEvent({
35
+ chainId: chain.id,
36
+ client,
37
+ event: "ub:ui:unsupported_token",
38
+ fromToken: tokenAddress,
39
+ });
40
+ }, [chain.id, client, tokenAddress]);
41
41
 
42
42
  if (chainMetadata?.testnet) {
43
43
  return (
@@ -1,5 +1,4 @@
1
- import { useQuery } from "@tanstack/react-query";
2
- import { useState } from "react";
1
+ import { useEffect, useRef, useState } from "react";
3
2
  import { trackPayEvent } from "../../../../../analytics/track/pay.js";
4
3
  import { defineChain } from "../../../../../chains/utils.js";
5
4
  import type { ThirdwebClient } from "../../../../../client/client.js";
@@ -251,16 +250,15 @@ export type BridgeWidgetProps = {
251
250
  export function BridgeWidget(props: BridgeWidgetProps) {
252
251
  const [tab, setTab] = useState<"swap" | "buy">("swap");
253
252
 
254
- useQuery({
255
- queryFn: () => {
256
- trackPayEvent({
257
- client: props.client,
258
- event: "ub:ui:bridge_widget:render",
259
- });
260
- return true;
261
- },
262
- queryKey: ["bridge_widget:render"],
263
- });
253
+ const hasFiredRenderEvent = useRef(false);
254
+ useEffect(() => {
255
+ if (hasFiredRenderEvent.current) return;
256
+ hasFiredRenderEvent.current = true;
257
+ trackPayEvent({
258
+ client: props.client,
259
+ event: "ub:ui:bridge_widget:render",
260
+ });
261
+ }, [props.client]);
264
262
 
265
263
  return (
266
264
  <CustomThemeProvider theme={props.theme}>
@@ -1,7 +1,5 @@
1
1
  "use client";
2
- import { useQuery } from "@tanstack/react-query";
3
2
  import { useMemo } from "react";
4
- import { trackPayEvent } from "../../../../../analytics/track/pay.js";
5
3
  import { defineChain } from "../../../../../chains/utils.js";
6
4
  import type { ThirdwebClient } from "../../../../../client/client.js";
7
5
  import type { SupportedFiatCurrency } from "../../../../../pay/convert/type.js";
@@ -82,39 +80,6 @@ export function PaymentDetails({
82
80
  }
83
81
  };
84
82
 
85
- useQuery({
86
- queryFn: () => {
87
- if (
88
- preparedQuote.type === "buy" ||
89
- preparedQuote.type === "sell" ||
90
- preparedQuote.type === "transfer"
91
- ) {
92
- trackPayEvent({
93
- chainId:
94
- preparedQuote.type === "transfer"
95
- ? preparedQuote.intent.chainId
96
- : preparedQuote.intent.originChainId,
97
- client,
98
- event: "payment_details",
99
- fromToken:
100
- preparedQuote.type === "transfer"
101
- ? preparedQuote.intent.tokenAddress
102
- : preparedQuote.intent.originTokenAddress,
103
- toChainId:
104
- preparedQuote.type === "transfer"
105
- ? preparedQuote.intent.chainId
106
- : preparedQuote.intent.destinationChainId,
107
- toToken:
108
- preparedQuote.type === "transfer"
109
- ? preparedQuote.intent.tokenAddress
110
- : preparedQuote.intent.destinationTokenAddress,
111
- });
112
- }
113
- return true;
114
- },
115
- queryKey: ["payment_details", preparedQuote.type],
116
- });
117
-
118
83
  const chainsQuery = useChainsQuery(
119
84
  preparedQuote.steps.flatMap((s) => [
120
85
  defineChain(s.originToken.chainId),
@@ -1,8 +1,7 @@
1
1
  "use client";
2
- import { useQuery } from "@tanstack/react-query";
3
2
  import { useEffect, useState } from "react";
4
3
  import { trackPayEvent } from "../../../../../analytics/track/pay.js";
5
- import type { Token } from "../../../../../bridge/types/Token.js";
4
+ import type { TokenWithPrices } from "../../../../../bridge/types/Token.js";
6
5
  import { defineChain } from "../../../../../chains/utils.js";
7
6
  import type { ThirdwebClient } from "../../../../../client/client.js";
8
7
  import type { SupportedFiatCurrency } from "../../../../../pay/convert/type.js";
@@ -27,7 +26,7 @@ type PaymentSelectionProps = {
27
26
  /**
28
27
  * The destination token to bridge to
29
28
  */
30
- destinationToken: Token;
29
+ destinationToken: TokenWithPrices;
31
30
 
32
31
  /**
33
32
  * The destination amount to bridge
@@ -129,19 +128,6 @@ export function PaymentSelection({
129
128
 
130
129
  const [currentStep, setCurrentStep] = useState<Step>(initialStep);
131
130
 
132
- useQuery({
133
- queryFn: () => {
134
- trackPayEvent({
135
- client,
136
- event: "payment_selection",
137
- toChainId: destinationToken.chainId,
138
- toToken: destinationToken.address,
139
- });
140
- return true;
141
- },
142
- queryKey: ["payment_selection"],
143
- });
144
-
145
131
  const payerWallet =
146
132
  currentStep.type === "tokenSelection"
147
133
  ? currentStep.selectedWallet
@@ -174,6 +160,10 @@ export function PaymentSelection({
174
160
  };
175
161
 
176
162
  const handleWalletSelected = (wallet: Wallet) => {
163
+ trackPayEvent({
164
+ client,
165
+ event: "ub:ui:token_selection",
166
+ });
177
167
  setCurrentStep({ selectedWallet: wallet, type: "tokenSelection" });
178
168
  };
179
169
 
@@ -182,6 +172,10 @@ export function PaymentSelection({
182
172
  };
183
173
 
184
174
  const handleFiatSelected = () => {
175
+ trackPayEvent({
176
+ client,
177
+ event: "ub:ui:fiat_provider_selection",
178
+ });
185
179
  setCurrentStep({ type: "fiatProviderSelection" });
186
180
  };
187
181
 
@@ -47,10 +47,7 @@ function PaymentMethodTokenRow({
47
47
  }: PaymentMethodTokenRowProps) {
48
48
  const theme = useCustomTheme();
49
49
 
50
- const displayOriginAmount = paymentMethod.quote.originAmount;
51
- const hasEnoughBalance = displayOriginAmount
52
- ? paymentMethod.balance >= displayOriginAmount
53
- : false;
50
+ const hasEnoughBalance = paymentMethod.hasEnoughBalance;
54
51
  const currencyPrice = paymentMethod.originToken.prices[currency || "USD"];
55
52
 
56
53
  return (
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { CheckIcon } from "@radix-ui/react-icons";
3
- import { useQuery, useQueryClient } from "@tanstack/react-query";
4
- import { useState } from "react";
3
+ import { useQueryClient } from "@tanstack/react-query";
4
+ import { useEffect, useRef, useState } from "react";
5
5
  import { trackPayEvent } from "../../../../../analytics/track/pay.js";
6
6
  import type { ThirdwebClient } from "../../../../../client/client.js";
7
7
  import type { WindowAdapter } from "../../../../core/adapters/WindowAdapter.js";
@@ -63,41 +63,43 @@ export function SuccessScreen({
63
63
  const [viewState, setViewState] = useState<ViewState>("success");
64
64
  const queryClient = useQueryClient();
65
65
 
66
- useQuery({
67
- queryFn: () => {
68
- if (preparedQuote.type === "buy" || preparedQuote.type === "sell") {
69
- trackPayEvent({
70
- chainId: preparedQuote.intent.originChainId,
71
- client: client,
72
- event: "ub:ui:success_screen",
73
- fromToken: preparedQuote.intent.originTokenAddress,
74
- toChainId: preparedQuote.intent.destinationChainId,
75
- toToken: preparedQuote.intent.destinationTokenAddress,
76
- });
77
- }
78
- if (preparedQuote.type === "transfer") {
79
- trackPayEvent({
80
- chainId: preparedQuote.intent.chainId,
81
- client: client,
82
- event: "ub:ui:success_screen",
83
- fromToken: preparedQuote.intent.tokenAddress,
84
- toChainId: preparedQuote.intent.chainId,
85
- toToken: preparedQuote.intent.tokenAddress,
86
- });
87
- }
88
- queryClient.invalidateQueries({
89
- queryKey: ["bridge/v1/wallets"],
66
+ const hasFiredSuccessEvent = useRef(false);
67
+ useEffect(() => {
68
+ if (hasFiredSuccessEvent.current) return;
69
+ hasFiredSuccessEvent.current = true;
70
+
71
+ if (preparedQuote.type === "buy" || preparedQuote.type === "sell") {
72
+ trackPayEvent({
73
+ chainId: preparedQuote.intent.originChainId,
74
+ client: client,
75
+ event: "ub:ui:success_screen",
76
+ fromToken: preparedQuote.intent.originTokenAddress,
77
+ toChainId: preparedQuote.intent.destinationChainId,
78
+ toToken: preparedQuote.intent.destinationTokenAddress,
79
+ walletAddress: preparedQuote.intent.sender,
90
80
  });
91
- queryClient.invalidateQueries({
92
- queryKey: ["walletBalance"],
81
+ }
82
+ if (preparedQuote.type === "transfer") {
83
+ trackPayEvent({
84
+ chainId: preparedQuote.intent.chainId,
85
+ client: client,
86
+ event: "ub:ui:success_screen",
87
+ fromToken: preparedQuote.intent.tokenAddress,
88
+ toChainId: preparedQuote.intent.chainId,
89
+ toToken: preparedQuote.intent.tokenAddress,
90
+ walletAddress: preparedQuote.intent.sender,
93
91
  });
94
- queryClient.invalidateQueries({
95
- queryKey: ["payment-methods"],
96
- });
97
- return true;
98
- },
99
- queryKey: ["success_screen", preparedQuote.type],
100
- });
92
+ }
93
+ queryClient.invalidateQueries({
94
+ queryKey: ["bridge/v1/wallets"],
95
+ });
96
+ queryClient.invalidateQueries({
97
+ queryKey: ["walletBalance"],
98
+ });
99
+ queryClient.invalidateQueries({
100
+ queryKey: ["payment-methods"],
101
+ });
102
+ }, [client, preparedQuote, queryClient]);
101
103
 
102
104
  if (viewState === "detail") {
103
105
  return (
@@ -1,7 +1,6 @@
1
1
  "use client";
2
2
 
3
- import { useQuery } from "@tanstack/react-query";
4
- import { useCallback, useEffect, useState } from "react";
3
+ import { useCallback, useEffect, useRef, useState } from "react";
5
4
  import { trackPayEvent } from "../../../../../analytics/track/pay.js";
6
5
  import type { Buy, Sell } from "../../../../../bridge/index.js";
7
6
  import type { TokenWithPrices } from "../../../../../bridge/types/Token.js";
@@ -246,16 +245,15 @@ export type SwapWidgetProps = {
246
245
  * @bridge
247
246
  */
248
247
  export function SwapWidget(props: SwapWidgetProps) {
249
- useQuery({
250
- queryFn: () => {
251
- trackPayEvent({
252
- client: props.client,
253
- event: "ub:ui:swap_widget:render",
254
- });
255
- return true;
256
- },
257
- queryKey: ["swap_widget:render"],
258
- });
248
+ const hasFiredRenderEvent = useRef(false);
249
+ useEffect(() => {
250
+ if (hasFiredRenderEvent.current) return;
251
+ hasFiredRenderEvent.current = true;
252
+ trackPayEvent({
253
+ client: props.client,
254
+ event: "ub:ui:swap_widget:render",
255
+ });
256
+ }, [props.client]);
259
257
 
260
258
  return (
261
259
  <SwapWidgetContainer
@@ -401,6 +399,17 @@ function SwapWidgetContent(
401
399
  amountSelection={amountSelection}
402
400
  setAmountSelection={setAmountSelection}
403
401
  onSwap={(data) => {
402
+ trackPayEvent({
403
+ chainId: data.result.intent.originChainId,
404
+ client: props.client,
405
+ event: "payment_details",
406
+ fromToken: data.result.intent.originTokenAddress,
407
+ toChainId: data.result.intent.destinationChainId,
408
+ toToken: data.result.intent.destinationTokenAddress,
409
+ walletAddress:
410
+ activeWalletInfo?.activeWallet?.getAccount()?.address,
411
+ walletType: activeWalletInfo?.activeWallet?.id,
412
+ });
404
413
  setScreen({
405
414
  id: "2:preview",
406
415
  buyToken: data.buyToken,
@@ -442,6 +451,7 @@ function SwapWidgetContent(
442
451
  balance: screen.sellTokenBalance,
443
452
  originToken: screen.sellToken,
444
453
  action: screen.mode,
454
+ hasEnoughBalance: true,
445
455
  }}
446
456
  preparedQuote={screen.preparedQuote}
447
457
  currency={props.currency}
@@ -37,7 +37,8 @@ export type PaymentMethod =
37
37
  payerWallet: Wallet;
38
38
  originToken: TokenWithPrices;
39
39
  balance: bigint;
40
- quote: Quote;
40
+ quote?: Quote;
41
+ hasEnoughBalance: boolean;
41
42
  }
42
43
  | {
43
44
  type: "fiat";
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "5.115.0-nightly-9e43da4ec0f88f32e988e445257fb518454c4c81-20251203000341";
1
+ export const version = "5.115.1";
@@ -94,8 +94,9 @@ export function waitForCallsReceipt(
94
94
  resolve(result);
95
95
  return;
96
96
  }
97
- } catch {
98
- // noop, we'll try again on the next blocks
97
+ } catch (error) {
98
+ // we'll try again on the next blocks
99
+ console.error("waitForCallsReceipt error", error);
99
100
  }
100
101
  },
101
102
  });