thirdweb 5.88.5-nightly-0574eac02c832c382972fd545df79c36e11796e1-20250217000342 → 5.88.6-nightly-b182302f590e75c9881cebd0ca1cc8b1425d50b8-20250218000338

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 (141) hide show
  1. package/dist/cjs/contract/deployment/zksync/zkDeployDeterministic.js +5 -1
  2. package/dist/cjs/contract/deployment/zksync/zkDeployDeterministic.js.map +1 -1
  3. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +53 -71
  4. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
  5. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js +2 -2
  6. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js.map +1 -1
  7. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.js +1 -1
  8. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.js.map +1 -1
  9. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.js +1 -1
  10. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.js.map +1 -1
  11. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.js +4 -14
  12. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.js.map +1 -1
  13. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js +2 -32
  14. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js.map +1 -1
  15. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js +9 -3
  16. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js.map +1 -1
  17. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapScreenContent.js +15 -8
  18. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapScreenContent.js.map +1 -1
  19. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapSummary.js +39 -0
  20. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapSummary.js.map +1 -0
  21. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.js +58 -53
  22. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.js.map +1 -1
  23. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js +3 -10
  24. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js.map +1 -1
  25. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js +35 -0
  26. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js.map +1 -0
  27. package/dist/cjs/react/web/ui/ConnectWallet/screens/TokenSelector.js +1 -2
  28. package/dist/cjs/react/web/ui/ConnectWallet/screens/TokenSelector.js.map +1 -1
  29. package/dist/cjs/react/web/ui/ConnectWallet/screens/nativeToken.js +4 -2
  30. package/dist/cjs/react/web/ui/ConnectWallet/screens/nativeToken.js.map +1 -1
  31. package/dist/cjs/react/web/ui/components/token/TokenRow.js +11 -4
  32. package/dist/cjs/react/web/ui/components/token/TokenRow.js.map +1 -1
  33. package/dist/cjs/utils/any-evm/compute-deployment-address.js +4 -1
  34. package/dist/cjs/utils/any-evm/compute-deployment-address.js.map +1 -1
  35. package/dist/cjs/utils/any-evm/compute-published-contract-deploy-info.js +1 -0
  36. package/dist/cjs/utils/any-evm/compute-published-contract-deploy-info.js.map +1 -1
  37. package/dist/cjs/utils/any-evm/get-init-bytecode-with-salt.js +3 -1
  38. package/dist/cjs/utils/any-evm/get-init-bytecode-with-salt.js.map +1 -1
  39. package/dist/cjs/utils/any-evm/zksync/computeDeploymentAddress.js +6 -1
  40. package/dist/cjs/utils/any-evm/zksync/computeDeploymentAddress.js.map +1 -1
  41. package/dist/cjs/version.js +1 -1
  42. package/dist/cjs/wallets/connection/autoConnect.js +3 -4
  43. package/dist/cjs/wallets/connection/autoConnect.js.map +1 -1
  44. package/dist/esm/contract/deployment/zksync/zkDeployDeterministic.js +6 -2
  45. package/dist/esm/contract/deployment/zksync/zkDeployDeterministic.js.map +1 -1
  46. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +55 -73
  47. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
  48. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js +1 -1
  49. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js.map +1 -1
  50. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.js +1 -1
  51. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.js.map +1 -1
  52. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.js +1 -1
  53. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.js.map +1 -1
  54. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.js +4 -14
  55. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.js.map +1 -1
  56. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js +4 -34
  57. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js.map +1 -1
  58. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js +9 -3
  59. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js.map +1 -1
  60. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapScreenContent.js +15 -8
  61. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapScreenContent.js.map +1 -1
  62. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapSummary.js +36 -0
  63. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapSummary.js.map +1 -0
  64. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.js +59 -53
  65. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.js.map +1 -1
  66. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js +4 -11
  67. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js.map +1 -1
  68. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js +32 -0
  69. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js.map +1 -0
  70. package/dist/esm/react/web/ui/ConnectWallet/screens/TokenSelector.js +1 -2
  71. package/dist/esm/react/web/ui/ConnectWallet/screens/TokenSelector.js.map +1 -1
  72. package/dist/esm/react/web/ui/ConnectWallet/screens/nativeToken.js +4 -2
  73. package/dist/esm/react/web/ui/ConnectWallet/screens/nativeToken.js.map +1 -1
  74. package/dist/esm/react/web/ui/components/token/TokenRow.js +11 -4
  75. package/dist/esm/react/web/ui/components/token/TokenRow.js.map +1 -1
  76. package/dist/esm/utils/any-evm/compute-deployment-address.js +4 -1
  77. package/dist/esm/utils/any-evm/compute-deployment-address.js.map +1 -1
  78. package/dist/esm/utils/any-evm/compute-published-contract-deploy-info.js +1 -0
  79. package/dist/esm/utils/any-evm/compute-published-contract-deploy-info.js.map +1 -1
  80. package/dist/esm/utils/any-evm/get-init-bytecode-with-salt.js +4 -2
  81. package/dist/esm/utils/any-evm/get-init-bytecode-with-salt.js.map +1 -1
  82. package/dist/esm/utils/any-evm/zksync/computeDeploymentAddress.js +6 -1
  83. package/dist/esm/utils/any-evm/zksync/computeDeploymentAddress.js.map +1 -1
  84. package/dist/esm/version.js +1 -1
  85. package/dist/esm/wallets/connection/autoConnect.js +2 -2
  86. package/dist/esm/wallets/connection/autoConnect.js.map +1 -1
  87. package/dist/types/contract/deployment/zksync/zkDeployDeterministic.d.ts.map +1 -1
  88. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.d.ts.map +1 -1
  89. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.d.ts.map +1 -1
  90. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.d.ts +2 -2
  91. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.d.ts.map +1 -1
  92. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.d.ts.map +1 -1
  93. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.d.ts +2 -2
  94. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.d.ts.map +1 -1
  95. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/SwapScreenContent.d.ts +2 -2
  96. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/SwapScreenContent.d.ts.map +1 -1
  97. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/SwapSummary.d.ts +15 -0
  98. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/SwapSummary.d.ts.map +1 -0
  99. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.d.ts +2 -16
  100. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.d.ts.map +1 -1
  101. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.d.ts.map +1 -1
  102. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.d.ts +9 -0
  103. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.d.ts.map +1 -0
  104. package/dist/types/react/web/ui/ConnectWallet/screens/TokenSelector.d.ts.map +1 -1
  105. package/dist/types/react/web/ui/ConnectWallet/screens/nativeToken.d.ts +1 -1
  106. package/dist/types/react/web/ui/ConnectWallet/screens/nativeToken.d.ts.map +1 -1
  107. package/dist/types/react/web/ui/components/token/TokenRow.d.ts +2 -2
  108. package/dist/types/react/web/ui/components/token/TokenRow.d.ts.map +1 -1
  109. package/dist/types/utils/any-evm/compute-deployment-address.d.ts.map +1 -1
  110. package/dist/types/utils/any-evm/compute-published-contract-deploy-info.d.ts +3 -0
  111. package/dist/types/utils/any-evm/compute-published-contract-deploy-info.d.ts.map +1 -1
  112. package/dist/types/utils/any-evm/get-init-bytecode-with-salt.d.ts.map +1 -1
  113. package/dist/types/utils/any-evm/zksync/computeDeploymentAddress.d.ts +1 -1
  114. package/dist/types/utils/any-evm/zksync/computeDeploymentAddress.d.ts.map +1 -1
  115. package/dist/types/version.d.ts +1 -1
  116. package/dist/types/wallets/connection/autoConnect.d.ts +2 -2
  117. package/dist/types/wallets/connection/autoConnect.d.ts.map +1 -1
  118. package/package.json +1 -1
  119. package/src/contract/deployment/deploy-deterministic.test.ts +45 -2
  120. package/src/contract/deployment/zksync/zkDeployDeterministic.ts +10 -2
  121. package/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +70 -157
  122. package/src/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.tsx +1 -1
  123. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.tsx +1 -0
  124. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.tsx +1 -1
  125. package/src/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.ts +4 -18
  126. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.tsx +20 -161
  127. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.tsx +25 -14
  128. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/SwapScreenContent.tsx +58 -34
  129. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/SwapSummary.tsx +134 -0
  130. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.tsx +134 -128
  131. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.tsx +18 -48
  132. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.tsx +70 -0
  133. package/src/react/web/ui/ConnectWallet/screens/TokenSelector.tsx +1 -3
  134. package/src/react/web/ui/ConnectWallet/screens/nativeToken.ts +5 -3
  135. package/src/react/web/ui/components/token/TokenRow.tsx +38 -14
  136. package/src/utils/any-evm/compute-deployment-address.ts +4 -1
  137. package/src/utils/any-evm/compute-published-contract-deploy-info.ts +1 -0
  138. package/src/utils/any-evm/get-init-bytecode-with-salt.ts +5 -2
  139. package/src/utils/any-evm/zksync/computeDeploymentAddress.ts +6 -2
  140. package/src/version.ts +1 -1
  141. package/src/wallets/connection/autoConnect.ts +3 -3
@@ -8,11 +8,9 @@ import type { BuyWithFiatStatus } from "../../../../../../pay/buyWithFiat/getSta
8
8
  import { formatNumber } from "../../../../../../utils/formatNumber.js";
9
9
  import type { Account } from "../../../../../../wallets/interfaces/wallet.js";
10
10
  import type { WalletId } from "../../../../../../wallets/wallet-types.js";
11
- import { useCustomTheme } from "../../../../../core/design-system/CustomThemeProvider.js";
12
11
  import {
13
12
  type Theme,
14
13
  fontSize,
15
- radius,
16
14
  spacing,
17
15
  } from "../../../../../core/design-system/index.js";
18
16
  import type {
@@ -27,10 +25,9 @@ import { LoadingScreen } from "../../../../wallets/shared/LoadingScreen.js";
27
25
  import type { PayEmbedConnectOptions } from "../../../PayEmbed.js";
28
26
  import { ChainName } from "../../../components/ChainName.js";
29
27
  import { Spacer } from "../../../components/Spacer.js";
30
- import { Container, ModalHeader } from "../../../components/basic.js";
28
+ import { Container, Line, ModalHeader } from "../../../components/basic.js";
31
29
  import { Button } from "../../../components/buttons.js";
32
30
  import { Input } from "../../../components/formElements.js";
33
- import { Text } from "../../../components/text.js";
34
31
  import { TokenSymbol } from "../../../components/token/TokenSymbol.js";
35
32
  import { ConnectButton } from "../../ConnectButton.js";
36
33
  import { ChainButton, NetworkSelectorContent } from "../../NetworkSelector.js";
@@ -432,67 +429,6 @@ function BuyScreenContent(props: BuyScreenContentProps) {
432
429
  );
433
430
  }
434
431
 
435
- if (
436
- screen.id === "select-from-token" &&
437
- supportedSourcesQuery.data &&
438
- sourceSupportedTokens
439
- ) {
440
- const chains = supportedSourcesQuery.data.map((x) => x.chain);
441
- const goBack = () => setScreen(screen.backScreen);
442
- // if token selection is disabled - only show network selector screen
443
- if (
444
- payOptions.buyWithCrypto !== false &&
445
- payOptions.buyWithCrypto?.prefillSource?.allowEdits?.token === false
446
- ) {
447
- return (
448
- <ChainSelectionScreen
449
- chains={chains}
450
- client={props.client}
451
- connectLocale={props.connectLocale}
452
- setChain={setFromChain}
453
- goBack={goBack}
454
- />
455
- );
456
- }
457
-
458
- return (
459
- <TokenSelectorScreen
460
- onBack={goBack}
461
- onConnect={() => {
462
- setScreen({
463
- id: "connect-payer-wallet",
464
- backScreen: screen,
465
- });
466
- }}
467
- modalTitle="Available tokens"
468
- connectLocale={props.connectLocale}
469
- client={props.client}
470
- sourceTokens={sourceSupportedTokens}
471
- sourceSupportedTokens={sourceSupportedTokens}
472
- toChain={toChain}
473
- toToken={toToken}
474
- tokenAmount={tokenAmount}
475
- fromChain={fromChain}
476
- fromToken={fromToken}
477
- mode={payOptions.mode}
478
- hiddenWallets={props.hiddenWallets}
479
- onSelect={(w, token, chain) => {
480
- const account = w.getAccount();
481
- if (account) {
482
- setPayer({
483
- account,
484
- chain,
485
- wallet: w,
486
- });
487
- setFromToken(token);
488
- setFromChain(chain);
489
- }
490
- goBack();
491
- }}
492
- />
493
- );
494
- }
495
-
496
432
  return (
497
433
  <Container animate="fadein">
498
434
  <div>
@@ -526,19 +462,10 @@ function BuyScreenContent(props: BuyScreenContentProps) {
526
462
 
527
463
  {(screen.id === "select-payment-method" ||
528
464
  screen.id === "buy-with-crypto" ||
529
- screen.id === "buy-with-fiat") &&
465
+ screen.id === "buy-with-fiat" ||
466
+ screen.id === "select-from-token") &&
530
467
  payer && (
531
468
  <TokenSelectedLayout
532
- isBuyWithFiatEnabled={enabledPaymentMethods.buyWithFiatEnabled}
533
- isBuyWithCryptoEnabled={
534
- enabledPaymentMethods.buyWithCryptoEnabled
535
- }
536
- mode={screen.id === "buy-with-fiat" ? "buy" : "swap"}
537
- onModeChange={(mode) => {
538
- setScreen({
539
- id: mode === "swap" ? "buy-with-crypto" : "buy-with-fiat",
540
- });
541
- }}
542
469
  disabled={
543
470
  ("prefillBuy" in payOptions &&
544
471
  payOptions.prefillBuy?.allowEdits?.amount === false) ||
@@ -551,7 +478,19 @@ function BuyScreenContent(props: BuyScreenContentProps) {
551
478
  setTokenAmount={setTokenAmount}
552
479
  client={client}
553
480
  onBack={() => {
554
- setScreen({ id: "main" });
481
+ if (
482
+ screen.id === "buy-with-crypto" ||
483
+ screen.id === "buy-with-fiat"
484
+ ) {
485
+ setScreen({
486
+ id: "select-from-token",
487
+ backScreen: { id: "main" },
488
+ });
489
+ } else if (screen.id === "select-from-token") {
490
+ setScreen(screen.backScreen);
491
+ } else {
492
+ setScreen({ id: "main" });
493
+ }
555
494
  }}
556
495
  >
557
496
  {screen.id === "buy-with-crypto" && activeAccount && (
@@ -614,6 +553,45 @@ function BuyScreenContent(props: BuyScreenContentProps) {
614
553
  setHasEditedAmount={setHasEditedAmount}
615
554
  />
616
555
  )}
556
+
557
+ {screen.id === "select-from-token" &&
558
+ supportedSourcesQuery.data &&
559
+ sourceSupportedTokens && (
560
+ <TokenSelectorScreen
561
+ client={props.client}
562
+ sourceTokens={sourceSupportedTokens}
563
+ sourceSupportedTokens={sourceSupportedTokens}
564
+ toChain={toChain}
565
+ toToken={toToken}
566
+ tokenAmount={tokenAmount}
567
+ mode={payOptions.mode}
568
+ hiddenWallets={props.hiddenWallets}
569
+ onConnect={() => {
570
+ setScreen({
571
+ id: "connect-payer-wallet",
572
+ backScreen: screen,
573
+ });
574
+ }}
575
+ onPayWithFiat={() => {
576
+ setScreen({
577
+ id: "buy-with-fiat",
578
+ });
579
+ }}
580
+ onSelectToken={(w, token, chain) => {
581
+ const account = w.getAccount();
582
+ if (account) {
583
+ setPayer({
584
+ account,
585
+ chain,
586
+ wallet: w,
587
+ });
588
+ setFromToken(token);
589
+ setFromChain(chain);
590
+ }
591
+ setScreen({ id: "buy-with-crypto" });
592
+ }}
593
+ />
594
+ )}
617
595
  </TokenSelectedLayout>
618
596
  )}
619
597
  </div>
@@ -802,7 +780,10 @@ function MainScreen(props: {
802
780
  if (buyWithFiatEnabled && !buyWithCryptoEnabled) {
803
781
  props.setScreen({ id: "buy-with-fiat" });
804
782
  } else {
805
- props.setScreen({ id: "buy-with-crypto" });
783
+ props.setScreen({
784
+ id: "select-from-token",
785
+ backScreen: { id: "main" },
786
+ });
806
787
  }
807
788
  }}
808
789
  />
@@ -825,7 +806,10 @@ function MainScreen(props: {
825
806
  if (buyWithFiatEnabled && !buyWithCryptoEnabled) {
826
807
  props.setScreen({ id: "buy-with-fiat" });
827
808
  } else {
828
- props.setScreen({ id: "buy-with-crypto" });
809
+ props.setScreen({
810
+ id: "select-from-token",
811
+ backScreen: { id: "main" },
812
+ });
829
813
  }
830
814
  }}
831
815
  />
@@ -888,7 +872,10 @@ function MainScreen(props: {
888
872
  if (buyWithFiatEnabled && !buyWithCryptoEnabled) {
889
873
  props.setScreen({ id: "buy-with-fiat" });
890
874
  } else {
891
- props.setScreen({ id: "buy-with-crypto" });
875
+ props.setScreen({
876
+ id: "select-from-token",
877
+ backScreen: { id: "main" },
878
+ });
892
879
  }
893
880
  }}
894
881
  >
@@ -912,12 +899,7 @@ function TokenSelectedLayout(props: {
912
899
  client: ThirdwebClient;
913
900
  onBack: () => void;
914
901
  disabled?: boolean;
915
- mode: "buy" | "swap";
916
- onModeChange: (mode: "buy" | "swap") => void;
917
- isBuyWithFiatEnabled: boolean;
918
- isBuyWithCryptoEnabled: boolean;
919
902
  }) {
920
- const theme = useCustomTheme();
921
903
  return (
922
904
  <Container>
923
905
  <Container p="lg">
@@ -940,78 +922,9 @@ function TokenSelectedLayout(props: {
940
922
  disabled={props.disabled}
941
923
  />
942
924
 
943
- <Spacer y="lg" />
944
- <Container flex="row" gap="md" center="y">
945
- <Text size="sm"> Pay with </Text>
946
- {props.isBuyWithFiatEnabled && props.isBuyWithCryptoEnabled && (
947
- <Container
948
- flex="row"
949
- style={{
950
- flex: 1,
951
- justifyContent: "center",
952
- borderRadius: radius.xl,
953
- border: `1px solid ${theme.colors.borderColor}`,
954
- alignItems: "stretch",
955
- }}
956
- >
957
- <Button
958
- variant="ghost"
959
- style={{
960
- flex: 1,
961
- background:
962
- props.mode === "swap"
963
- ? theme.colors.tertiaryBg
964
- : "transparent",
965
- borderRadius: radius.xl,
966
- borderTopRightRadius: 0,
967
- borderBottomRightRadius: 0,
968
- padding: spacing.xs,
969
- }}
970
- onClick={() => props.onModeChange("swap")}
971
- >
972
- <Text
973
- size="sm"
974
- color={
975
- props.mode === "swap" ? "primaryText" : "secondaryText"
976
- }
977
- >
978
- Crypto
979
- </Text>
980
- </Button>
981
- <div
982
- style={{
983
- width: "1px",
984
- background: theme.colors.borderColor,
985
- }}
986
- />
987
- <Button
988
- variant="ghost"
989
- style={{
990
- flex: 1,
991
- background:
992
- props.mode === "buy"
993
- ? theme.colors.tertiaryBg
994
- : "transparent",
995
- borderRadius: radius.xl,
996
- borderTopLeftRadius: 0,
997
- borderBottomLeftRadius: 0,
998
- padding: spacing.xs,
999
- }}
1000
- onClick={() => props.onModeChange("buy")}
1001
- >
1002
- <Text
1003
- size="sm"
1004
- color={props.mode === "buy" ? "primaryText" : "secondaryText"}
1005
- >
1006
- Card
1007
- </Text>
1008
- </Button>
1009
- </Container>
1010
- )}
1011
- </Container>
1012
-
1013
- <Spacer y="lg" />
1014
-
925
+ <Spacer y="sm" />
926
+ <Line />
927
+ <Spacer y="sm" />
1015
928
  {props.children}
1016
929
  </Container>
1017
930
  </Container>
@@ -33,7 +33,7 @@ import {
33
33
  isNativeToken,
34
34
  } from "../nativeToken.js";
35
35
  import { useTransactionCostAndData } from "./main/useBuyTxStates.js";
36
- import { WalletRow } from "./swap/TokenSelectorScreen.js";
36
+ import { WalletRow } from "./swap/WalletRow.js";
37
37
  import type { SupportedChainAndTokens } from "./swap/useSwapSupportedChains.js";
38
38
 
39
39
  export function TransactionModeScreen(props: {
@@ -199,6 +199,7 @@ export function FiatScreenContent(props: {
199
199
  )}
200
200
 
201
201
  <Container flex="column" gap="sm">
202
+ <Text size="sm">Pay with credit card</Text>
202
203
  <div>
203
204
  <PayWithCreditCard
204
205
  isLoading={fiatQuoteQuery.isLoading}
@@ -62,7 +62,7 @@ export function OnRampTxDetailsTable(props: {
62
62
  justifyContent: "space-between",
63
63
  }}
64
64
  >
65
- <Text>Pay</Text>
65
+ <Text size="sm">Pay</Text>
66
66
  <Container
67
67
  flex="column"
68
68
  gap="xxs"
@@ -76,14 +76,9 @@ export function useFromTokenSelectionStates(options: {
76
76
  payOptions: PayUIOptions;
77
77
  supportedSources: SupportedSourcesInputData[];
78
78
  }) {
79
- const { payOptions, supportedSources } = options;
79
+ const { payOptions } = options;
80
80
 
81
- // --------------------------------------------------------------------------
82
- const firstSupportedSource = supportedSources?.length
83
- ? supportedSources.length === 1
84
- ? supportedSources[0]
85
- : supportedSources.find((x) => x.chain.id !== 1) // dont use mainnet as a default source, unless its the only source
86
- : undefined;
81
+ // TODO (pay) - auto select token based on connected wallet balances
87
82
 
88
83
  // Source token and chain selection ---------------------------------------------------
89
84
  const [fromChain_, setFromChain] = useState<Chain>();
@@ -95,12 +90,7 @@ export function useFromTokenSelectionStates(options: {
95
90
  (payOptions.mode === "transaction" && payOptions.transaction?.chain) ||
96
91
  (payOptions.mode === "direct_payment" && payOptions.paymentInfo?.chain);
97
92
 
98
- const fromChainFromApi = firstSupportedSource?.chain
99
- ? firstSupportedSource.chain
100
- : undefined;
101
-
102
- const fromChain =
103
- fromChain_ || fromChainDevSpecified || fromChainFromApi || polygon;
93
+ const fromChain = fromChain_ || fromChainDevSpecified || undefined;
104
94
 
105
95
  const [fromToken_, setFromToken] = useState<ERC20OrNativeToken>();
106
96
 
@@ -110,12 +100,8 @@ export function useFromTokenSelectionStates(options: {
110
100
  payOptions.buyWithCrypto?.prefillSource?.token) ||
111
101
  (payOptions.mode === "direct_payment" && payOptions.paymentInfo.token);
112
102
 
113
- // May be updated in the future
114
- const fromTokenFromApi = NATIVE_TOKEN;
115
-
116
103
  // supported tokens query in here
117
- const fromToken =
118
- fromToken_ || fromTokenDevSpecified || fromTokenFromApi || NATIVE_TOKEN;
104
+ const fromToken = fromToken_ || fromTokenDevSpecified || undefined;
119
105
 
120
106
  return {
121
107
  fromChain,
@@ -12,29 +12,20 @@ import {
12
12
  type WaitForReceiptOptions,
13
13
  waitForReceipt,
14
14
  } from "../../../../../../../transaction/actions/wait-for-tx-receipt.js";
15
- import { shortenAddress } from "../../../../../../../utils/address.js";
16
- import { formatNumber } from "../../../../../../../utils/formatNumber.js";
17
15
  import { useCustomTheme } from "../../../../../../core/design-system/CustomThemeProvider.js";
18
- import {
19
- fontSize,
20
- iconSize,
21
- } from "../../../../../../core/design-system/index.js";
22
- import { useChainName } from "../../../../../../core/hooks/others/useChainQuery.js";
23
- import { useEnsName } from "../../../../../../core/utils/wallet.js";
24
- import { Skeleton } from "../../../../components/Skeleton.js";
16
+ import { iconSize } from "../../../../../../core/design-system/index.js";
25
17
  import { Spacer } from "../../../../components/Spacer.js";
26
18
  import { Spinner } from "../../../../components/Spinner.js";
27
19
  import { StepBar } from "../../../../components/StepBar.js";
28
20
  import { SwitchNetworkButton } from "../../../../components/SwitchNetwork.js";
29
- import { Container, Line, ModalHeader } from "../../../../components/basic.js";
21
+ import { Container, ModalHeader } from "../../../../components/basic.js";
30
22
  import { Button } from "../../../../components/buttons.js";
31
23
  import { Text } from "../../../../components/text.js";
32
24
  import { StyledDiv } from "../../../../design-system/elements.js";
33
25
  import type { ERC20OrNativeToken } from "../../nativeToken.js";
34
- import { PayTokenIcon } from "../PayTokenIcon.js";
35
26
  import { Step } from "../Stepper.js";
36
27
  import type { PayerInfo } from "../types.js";
37
- import { formatSeconds } from "./formatSeconds.js";
28
+ import { SwapSummary } from "./SwapSummary.js";
38
29
  import { addPendingTx } from "./pendingSwapTx.js";
39
30
 
40
31
  /**
@@ -74,9 +65,6 @@ export function SwapConfirmationScreen(props: {
74
65
 
75
66
  const receiver = props.quote.swapDetails.toAddress;
76
67
  const sender = props.quote.swapDetails.fromAddress;
77
- const isDifferentRecipient = receiver.toLowerCase() !== sender.toLowerCase();
78
-
79
- const ensName = useEnsName({ client: props.client, address: receiver });
80
68
 
81
69
  return (
82
70
  <Container p="lg">
@@ -94,58 +82,26 @@ export function SwapConfirmationScreen(props: {
94
82
  <Spacer y="md" />
95
83
  </>
96
84
  ) : (
97
- <Spacer y="lg" />
98
- )}
99
-
100
- {/* Pay */}
101
- <ConfirmItem label="Pay">
102
- <RenderTokenInfo
103
- chain={props.fromChain}
104
- amount={String(formatNumber(Number(props.fromAmount), 6))}
105
- symbol={props.fromTokenSymbol || ""}
106
- token={props.fromToken}
107
- client={props.client}
108
- />
109
- </ConfirmItem>
110
-
111
- {/* Receive */}
112
- {!isDifferentRecipient && (
113
- <ConfirmItem label="Receive">
114
- <RenderTokenInfo
115
- chain={props.toChain}
116
- amount={String(formatNumber(Number(props.toAmount), 6))}
117
- symbol={props.toTokenSymbol}
118
- token={props.toToken}
119
- client={props.client}
120
- />
121
- </ConfirmItem>
85
+ <>
86
+ <Spacer y="lg" />
87
+ <Text size="sm">Confirm payment</Text>
88
+ <Spacer y="md" />
89
+ </>
122
90
  )}
123
91
 
124
- {/* Fees */}
125
- <ConfirmItem label="Fees">
126
- <SwapFeesRightAligned quote={props.quote} />
127
- </ConfirmItem>
128
-
129
- {/* Time */}
130
- <ConfirmItem label="Time">
131
- <Text size="sm" color="primaryText">
132
- ~
133
- {formatSeconds(
134
- props.quote.swapDetails.estimated.durationSeconds || 0,
135
- )}
136
- </Text>
137
- </ConfirmItem>
138
-
139
- {/* Send to */}
140
- {isDifferentRecipient && (
141
- <ConfirmItem label="Receiver">
142
- <Text color="primaryText" size="sm">
143
- {ensName.data || shortenAddress(receiver)}
144
- </Text>
145
- </ConfirmItem>
146
- )}
92
+ <SwapSummary
93
+ sender={sender}
94
+ receiver={receiver}
95
+ client={props.client}
96
+ fromToken={props.fromToken}
97
+ fromChain={props.fromChain}
98
+ toToken={props.toToken}
99
+ toChain={props.toChain}
100
+ fromAmount={props.fromAmount}
101
+ toAmount={props.toAmount}
102
+ />
147
103
 
148
- <Spacer y="xl" />
104
+ <Spacer y="md" />
149
105
 
150
106
  {/* Show 2 steps - Approve and confirm */}
151
107
  {needsApprovalStep && (
@@ -348,100 +304,3 @@ export const ConnectorLine = /* @__PURE__ */ StyledDiv(() => {
348
304
  flex: 1,
349
305
  };
350
306
  });
351
-
352
- function RenderTokenInfo(props: {
353
- chain: Chain;
354
- token: ERC20OrNativeToken;
355
- amount: string;
356
- symbol: string;
357
- client: ThirdwebClient;
358
- }) {
359
- const { name } = useChainName(props.chain);
360
- return (
361
- <Container
362
- flex="column"
363
- gap="xxs"
364
- style={{
365
- alignItems: "flex-end",
366
- }}
367
- >
368
- <Container flex="row" center="y" gap="xs">
369
- <Text color="primaryText" size="sm">
370
- {props.amount} {props.symbol}
371
- </Text>
372
- <PayTokenIcon
373
- token={props.token}
374
- chain={props.chain}
375
- size="xs"
376
- client={props.client}
377
- />
378
- </Container>
379
-
380
- {name ? (
381
- <Text size="xs">{name}</Text>
382
- ) : (
383
- <Skeleton width="100px" height={fontSize.xs} />
384
- )}
385
- </Container>
386
- );
387
- }
388
-
389
- function ConfirmItem(props: {
390
- label: string;
391
- children: React.ReactNode;
392
- }) {
393
- return (
394
- <>
395
- <Container
396
- flex="row"
397
- gap="md"
398
- py="md"
399
- style={{
400
- justifyContent: "space-between",
401
- }}
402
- >
403
- <Text size="sm" color="secondaryText">
404
- {props.label}
405
- </Text>
406
- {props.children}
407
- </Container>
408
- <Line />
409
- </>
410
- );
411
- }
412
-
413
- /**
414
- * @internal
415
- */
416
- function SwapFeesRightAligned(props: {
417
- quote: BuyWithCryptoQuote;
418
- }) {
419
- return (
420
- <Container
421
- flex="column"
422
- gap="xs"
423
- style={{
424
- alignItems: "flex-end",
425
- }}
426
- >
427
- {props.quote.processingFees.map((fee) => {
428
- const feeAmount = formatNumber(Number(fee.amount), 6);
429
- return (
430
- <Container
431
- key={`${fee.token.chainId}_${fee.token.tokenAddress}_${feeAmount}`}
432
- flex="row"
433
- gap="xxs"
434
- >
435
- <Text color="primaryText" size="sm">
436
- {feeAmount === 0 ? "~" : ""}
437
- {feeAmount} {fee.token.symbol}
438
- </Text>
439
- <Text color="secondaryText" size="sm">
440
- (${(fee.amountUSDCents / 100).toFixed(2)})
441
- </Text>
442
- </Container>
443
- );
444
- })}
445
- </Container>
446
- );
447
- }
@@ -16,7 +16,7 @@ import { TokenRow } from "../../../../components/token/TokenRow.js";
16
16
  import { TokenSymbol } from "../../../../components/token/TokenSymbol.js";
17
17
  import { formatTokenBalance } from "../../formatTokenBalance.js";
18
18
  import { type NativeToken, isNativeToken } from "../../nativeToken.js";
19
- import { WalletRow } from "./TokenSelectorScreen.js";
19
+ import { WalletRow } from "./WalletRow.js";
20
20
 
21
21
  /**
22
22
  * Shows an amount "value" and renders the selected token and chain
@@ -26,8 +26,8 @@ import { WalletRow } from "./TokenSelectorScreen.js";
26
26
  */
27
27
  export function PayWithCryptoQuoteInfo(props: {
28
28
  value: string;
29
- chain: Chain;
30
- token: TokenInfo | NativeToken;
29
+ chain: Chain | undefined;
30
+ token: TokenInfo | NativeToken | undefined;
31
31
  isLoading: boolean;
32
32
  client: ThirdwebClient;
33
33
  freezeChainAndTokenSelection?: boolean;
@@ -36,12 +36,19 @@ export function PayWithCryptoQuoteInfo(props: {
36
36
  onSelectToken: () => void;
37
37
  }) {
38
38
  const theme = useCustomTheme();
39
- const balanceQuery = useWalletBalance({
40
- address: props.payerAccount.address,
41
- chain: props.chain,
42
- tokenAddress: isNativeToken(props.token) ? undefined : props.token.address,
43
- client: props.client,
44
- });
39
+ const balanceQuery = useWalletBalance(
40
+ {
41
+ address: props.payerAccount.address,
42
+ chain: props.chain,
43
+ tokenAddress: isNativeToken(props.token)
44
+ ? undefined
45
+ : props.token?.address,
46
+ client: props.client,
47
+ },
48
+ {
49
+ enabled: !!props.chain && !!props.token,
50
+ },
51
+ );
45
52
 
46
53
  return (
47
54
  <Container
@@ -69,10 +76,10 @@ export function PayWithCryptoQuoteInfo(props: {
69
76
  }}
70
77
  >
71
78
  <WalletRow client={props.client} address={props.payerAccount.address} />
72
- {balanceQuery.data ? (
79
+ {props.token && props.chain && balanceQuery.data ? (
73
80
  <Container flex="row" gap="3xs" center="y">
74
81
  <Text size="xs" color="secondaryText" weight={500}>
75
- {formatTokenBalance(balanceQuery.data, false)}
82
+ {formatTokenBalance(balanceQuery.data, false, 4)}
76
83
  </Text>
77
84
  <TokenSymbol
78
85
  token={props.token}
@@ -81,11 +88,11 @@ export function PayWithCryptoQuoteInfo(props: {
81
88
  color="secondaryText"
82
89
  />
83
90
  </Container>
84
- ) : (
91
+ ) : props.token && props.chain && balanceQuery.isLoading ? (
85
92
  <Skeleton width="70px" height={fontSize.xs} />
86
- )}
93
+ ) : null}
87
94
  </Container>
88
- {/* Quoted price */}
95
+ {/* Quoted price & token selector */}
89
96
  <TokenRow
90
97
  token={props.token}
91
98
  chain={props.chain}
@@ -96,6 +103,10 @@ export function PayWithCryptoQuoteInfo(props: {
96
103
  style={{
97
104
  border: "none",
98
105
  borderRadius: 0,
106
+ borderBottomLeftRadius:
107
+ !props.token || !props.chain || !props.swapRequired ? radius.lg : 0,
108
+ borderBottomRightRadius:
109
+ !props.token || !props.chain || !props.swapRequired ? radius.lg : 0,
99
110
  }}
100
111
  />
101
112
  </Container>