thirdweb 5.64.2 → 5.64.3-nightly-ddec3dadcc260e0d4d0ed2b43c502e0915a14203-20241029000326
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js +19 -1
- package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +27 -78
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js +27 -13
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js +50 -19
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.js +0 -2
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js +21 -32
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.js +138 -0
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.js.map +1 -0
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js +1 -0
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/formatTokenBalance.js +2 -2
- package/dist/cjs/react/web/ui/ConnectWallet/screens/formatTokenBalance.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/cjs/wallets/smart/lib/bundler.js +3 -1
- package/dist/cjs/wallets/smart/lib/bundler.js.map +1 -1
- package/dist/esm/react/core/hooks/transaction/useSendTransaction.js +19 -1
- package/dist/esm/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +29 -80
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js +28 -14
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js +50 -19
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.js +0 -2
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js +21 -32
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.js +135 -0
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.js.map +1 -0
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/formatTokenBalance.js +2 -2
- package/dist/esm/react/web/ui/ConnectWallet/screens/formatTokenBalance.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/esm/wallets/smart/lib/bundler.js +3 -1
- package/dist/esm/wallets/smart/lib/bundler.js.map +1 -1
- package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.d.ts +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.d.ts +12 -8
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/types.d.ts +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/types.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.d.ts +0 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.d.ts +1 -2
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.d.ts +30 -0
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.d.ts.map +1 -0
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.d.ts +1 -0
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/formatTokenBalance.d.ts +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/formatTokenBalance.d.ts.map +1 -1
- package/dist/types/react/web/ui/components/token/TokenSymbol.d.ts +1 -1
- package/dist/types/react/web/ui/components/token/TokenSymbol.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/dist/types/wallets/smart/lib/bundler.d.ts.map +1 -1
- package/dist/types/wallets/smart/types.d.ts +1 -1
- package/dist/types/wallets/smart/types.d.ts.map +1 -1
- package/package.json +11 -11
- package/src/extensions/unstoppable-domains/read/resolveName.test.ts +20 -17
- package/src/react/core/hooks/transaction/useSendTransaction.ts +34 -4
- package/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +35 -148
- package/src/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.tsx +62 -31
- package/src/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.tsx +136 -48
- package/src/react/web/ui/ConnectWallet/screens/Buy/main/types.ts +1 -1
- package/src/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.ts +0 -4
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.tsx +57 -71
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.tsx +251 -0
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.ts +1 -1
- package/src/react/web/ui/ConnectWallet/screens/formatTokenBalance.ts +2 -1
- package/src/react/web/ui/components/token/TokenSymbol.tsx +2 -2
- package/src/version.ts +1 -1
- package/src/wallets/smart/lib/bundler.ts +4 -1
- package/src/wallets/smart/smart-wallet-dev.test.ts +23 -4
- package/src/wallets/smart/types.ts +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/icons/GenericWalletIcon.js +0 -12
- package/dist/cjs/react/web/ui/ConnectWallet/icons/GenericWalletIcon.js.map +0 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.js +0 -34
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.js.map +0 -1
- package/dist/esm/react/web/ui/ConnectWallet/icons/GenericWalletIcon.js +0 -8
- package/dist/esm/react/web/ui/ConnectWallet/icons/GenericWalletIcon.js.map +0 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.js +0 -31
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.js.map +0 -1
- package/dist/types/react/web/ui/ConnectWallet/icons/GenericWalletIcon.d.ts +0 -6
- package/dist/types/react/web/ui/ConnectWallet/icons/GenericWalletIcon.d.ts.map +0 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.d.ts +0 -14
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.d.ts.map +0 -1
- package/src/react/web/ui/ConnectWallet/icons/GenericWalletIcon.tsx +0 -22
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.tsx +0 -83
@@ -1,7 +1,5 @@
|
|
1
|
-
import { IdCardIcon } from "@radix-ui/react-icons";
|
2
1
|
import { useQueryClient } from "@tanstack/react-query";
|
3
2
|
import { useCallback, useMemo, useState } from "react";
|
4
|
-
import { trackPayEvent } from "../../../../../../analytics/track/pay.js";
|
5
3
|
import type { Chain } from "../../../../../../chains/types.js";
|
6
4
|
import type { ThirdwebClient } from "../../../../../../client/client.js";
|
7
5
|
import { NATIVE_TOKEN_ADDRESS } from "../../../../../../constants/addresses.js";
|
@@ -14,7 +12,6 @@ import type { Account } from "../../../../../../wallets/interfaces/wallet.js";
|
|
14
12
|
import type { WalletId } from "../../../../../../wallets/wallet-types.js";
|
15
13
|
import {
|
16
14
|
type Theme,
|
17
|
-
iconSize,
|
18
15
|
spacing,
|
19
16
|
} from "../../../../../core/design-system/index.js";
|
20
17
|
import type {
|
@@ -44,7 +41,6 @@ import { Text } from "../../../components/text.js";
|
|
44
41
|
import { TokenSymbol } from "../../../components/token/TokenSymbol.js";
|
45
42
|
import { ConnectButton } from "../../ConnectButton.js";
|
46
43
|
import { ChainButton, NetworkSelectorContent } from "../../NetworkSelector.js";
|
47
|
-
import { CoinsIcon } from "../../icons/CoinsIcon.js";
|
48
44
|
import type { ConnectLocale } from "../../locale/types.js";
|
49
45
|
import { TokenSelector } from "../TokenSelector.js";
|
50
46
|
import { WalletSwitcherConnectionScreen } from "../WalletSwitcherConnectionScreen.js";
|
@@ -54,7 +50,6 @@ import { EstimatedTimeAndFees } from "./EstimatedTimeAndFees.js";
|
|
54
50
|
import { PayTokenIcon } from "./PayTokenIcon.js";
|
55
51
|
import { PayWithCreditCard } from "./PayWIthCreditCard.js";
|
56
52
|
import { TransactionModeScreen } from "./TransactionModeScreen.js";
|
57
|
-
import { WalletSelectorButton } from "./WalletSelectorButton.js";
|
58
53
|
import { CurrencySelection } from "./fiat/CurrencySelection.js";
|
59
54
|
import { FiatFlow } from "./fiat/FiatFlow.js";
|
60
55
|
import type { CurrencyMeta } from "./fiat/currencies.js";
|
@@ -71,10 +66,10 @@ import {
|
|
71
66
|
import { openOnrampPopup } from "./openOnRamppopup.js";
|
72
67
|
import { BuyTokenInput } from "./swap/BuyTokenInput.js";
|
73
68
|
import { FiatFees, SwapFees } from "./swap/Fees.js";
|
74
|
-
import {
|
69
|
+
import { PayWithCryptoQuoteInfo } from "./swap/PayWithCrypto.js";
|
70
|
+
import { PaymentSelectionScreen } from "./swap/PaymentSelectionScreen.js";
|
75
71
|
import { SwapFlow } from "./swap/SwapFlow.js";
|
76
72
|
import { TransferFlow } from "./swap/TransferFlow.js";
|
77
|
-
import { WalletSwitcherDrawerContent } from "./swap/WalletSwitcherDrawerContent.js";
|
78
73
|
import { addPendingTx } from "./swap/pendingSwapTx.js";
|
79
74
|
import {
|
80
75
|
type SupportedChainAndTokens,
|
@@ -222,7 +217,6 @@ function BuyScreenContent(props: BuyScreenContentProps) {
|
|
222
217
|
});
|
223
218
|
|
224
219
|
const payDisabled =
|
225
|
-
enabledPaymentMethods.showPaymentSelection === false &&
|
226
220
|
enabledPaymentMethods.buyWithCryptoEnabled === false &&
|
227
221
|
enabledPaymentMethods.buyWithFiatEnabled === false;
|
228
222
|
|
@@ -515,7 +509,6 @@ function BuyScreenContent(props: BuyScreenContentProps) {
|
|
515
509
|
)}
|
516
510
|
|
517
511
|
{(screen.id === "select-payment-method" ||
|
518
|
-
screen.id === "select-wallet" ||
|
519
512
|
screen.id === "buy-with-crypto" ||
|
520
513
|
screen.id === "buy-with-fiat") &&
|
521
514
|
payer && (
|
@@ -527,44 +520,43 @@ function BuyScreenContent(props: BuyScreenContentProps) {
|
|
527
520
|
client={client}
|
528
521
|
onBack={() => {
|
529
522
|
if (
|
530
|
-
enabledPaymentMethods.
|
531
|
-
|
532
|
-
screen.id === "buy-with-fiat")
|
523
|
+
enabledPaymentMethods.buyWithCryptoEnabled &&
|
524
|
+
screen.id === "buy-with-fiat"
|
533
525
|
) {
|
534
526
|
setScreen({ id: "select-payment-method" });
|
535
527
|
} else if (screen.id === "buy-with-crypto") {
|
536
|
-
setScreen({ id: "select-
|
528
|
+
setScreen({ id: "select-payment-method" });
|
537
529
|
} else {
|
538
530
|
setScreen({ id: "main" });
|
539
531
|
}
|
540
532
|
}}
|
541
533
|
>
|
542
534
|
{screen.id === "select-payment-method" && (
|
543
|
-
<
|
544
|
-
mode={payOptions.mode}
|
545
|
-
client={client}
|
546
|
-
walletAddress={payer.account.address}
|
547
|
-
walletType={payer.wallet.id}
|
548
|
-
setScreen={(id) => setScreen({ id })}
|
549
|
-
/>
|
550
|
-
)}
|
551
|
-
|
552
|
-
{screen.id === "select-wallet" && (
|
553
|
-
<WalletSwitcherDrawerContent
|
535
|
+
<PaymentSelectionScreen
|
554
536
|
client={client}
|
537
|
+
mode={payOptions.mode}
|
538
|
+
sourceSupportedTokens={sourceSupportedTokens}
|
555
539
|
hiddenWallets={props.hiddenWallets}
|
556
|
-
|
557
|
-
|
540
|
+
payWithFiatEnabled={props.payOptions.buyWithFiat !== false}
|
541
|
+
toChain={toChain}
|
542
|
+
toToken={toToken}
|
543
|
+
tokenAmount={tokenAmount}
|
544
|
+
onSelect={(w, token, chain) => {
|
558
545
|
const account = w.getAccount();
|
559
|
-
if (
|
546
|
+
if (account) {
|
560
547
|
setPayer({
|
561
548
|
account,
|
562
549
|
chain,
|
563
550
|
wallet: w,
|
564
551
|
});
|
552
|
+
setFromToken(token);
|
553
|
+
setFromChain(chain);
|
565
554
|
setScreen({ id: "buy-with-crypto" });
|
566
555
|
}
|
567
556
|
}}
|
557
|
+
onSelectFiat={() => {
|
558
|
+
setScreen({ id: "buy-with-fiat" });
|
559
|
+
}}
|
568
560
|
showAllWallets={!!props.connectOptions?.showAllWallets}
|
569
561
|
wallets={props.connectOptions?.wallets}
|
570
562
|
onBack={() => {
|
@@ -574,11 +566,10 @@ function BuyScreenContent(props: BuyScreenContentProps) {
|
|
574
566
|
setScreen({
|
575
567
|
id: "connect-payer-wallet",
|
576
568
|
backScreen: {
|
577
|
-
id: "select-
|
569
|
+
id: "select-payment-method",
|
578
570
|
},
|
579
571
|
});
|
580
572
|
}}
|
581
|
-
selectedAddress={payer.account.address}
|
582
573
|
/>
|
583
574
|
)}
|
584
575
|
|
@@ -736,8 +727,7 @@ function MainScreen(props: {
|
|
736
727
|
enabledPaymentMethods,
|
737
728
|
} = props;
|
738
729
|
|
739
|
-
const {
|
740
|
-
enabledPaymentMethods;
|
730
|
+
const { buyWithCryptoEnabled, buyWithFiatEnabled } = enabledPaymentMethods;
|
741
731
|
const disableContinue = !tokenAmount;
|
742
732
|
|
743
733
|
switch (payOptions.mode) {
|
@@ -755,15 +745,10 @@ function MainScreen(props: {
|
|
755
745
|
setFromChain(toChain);
|
756
746
|
setFromToken(toToken);
|
757
747
|
setToToken(toToken);
|
758
|
-
if (
|
759
|
-
props.setScreen({ id: "select-payment-method" });
|
760
|
-
} else if (buyWithCryptoEnabled) {
|
761
|
-
props.setScreen({ id: "select-wallet" });
|
762
|
-
} else if (buyWithFiatEnabled) {
|
748
|
+
if (buyWithFiatEnabled && !buyWithCryptoEnabled) {
|
763
749
|
props.setScreen({ id: "buy-with-fiat" });
|
764
750
|
} else {
|
765
|
-
|
766
|
-
props.setScreen({ id: "select-wallet" });
|
751
|
+
props.setScreen({ id: "select-payment-method" });
|
767
752
|
}
|
768
753
|
}}
|
769
754
|
/>
|
@@ -783,15 +768,10 @@ function MainScreen(props: {
|
|
783
768
|
setFromChain(toChain);
|
784
769
|
setFromToken(toToken);
|
785
770
|
setToToken(toToken);
|
786
|
-
if (
|
787
|
-
props.setScreen({ id: "select-payment-method" });
|
788
|
-
} else if (buyWithCryptoEnabled) {
|
789
|
-
props.setScreen({ id: "buy-with-crypto" });
|
790
|
-
} else if (buyWithFiatEnabled) {
|
771
|
+
if (buyWithFiatEnabled && !buyWithCryptoEnabled) {
|
791
772
|
props.setScreen({ id: "buy-with-fiat" });
|
792
773
|
} else {
|
793
|
-
|
794
|
-
props.setScreen({ id: "select-wallet" });
|
774
|
+
props.setScreen({ id: "select-payment-method" });
|
795
775
|
}
|
796
776
|
}}
|
797
777
|
/>
|
@@ -846,14 +826,10 @@ function MainScreen(props: {
|
|
846
826
|
disabled={disableContinue}
|
847
827
|
data-disabled={disableContinue}
|
848
828
|
onClick={() => {
|
849
|
-
if (
|
850
|
-
props.setScreen({ id: "select-payment-method" });
|
851
|
-
} else if (buyWithCryptoEnabled) {
|
852
|
-
props.setScreen({ id: "buy-with-crypto" });
|
853
|
-
} else if (buyWithFiatEnabled) {
|
829
|
+
if (buyWithFiatEnabled && !buyWithCryptoEnabled) {
|
854
830
|
props.setScreen({ id: "buy-with-fiat" });
|
855
831
|
} else {
|
856
|
-
|
832
|
+
props.setScreen({ id: "select-payment-method" });
|
857
833
|
}
|
858
834
|
}}
|
859
835
|
>
|
@@ -909,87 +885,6 @@ function TokenSelectedLayout(props: {
|
|
909
885
|
);
|
910
886
|
}
|
911
887
|
|
912
|
-
function PaymentMethodSelection(props: {
|
913
|
-
client: ThirdwebClient;
|
914
|
-
walletAddress: string;
|
915
|
-
walletType: string;
|
916
|
-
setScreen: (screenId: "select-wallet" | "buy-with-fiat") => void;
|
917
|
-
mode?: "transaction" | "direct_payment" | "fund_wallet";
|
918
|
-
}) {
|
919
|
-
return (
|
920
|
-
<Container animate="fadein">
|
921
|
-
{/* Credit Card */}
|
922
|
-
<Container flex="column" gap="sm">
|
923
|
-
<Button
|
924
|
-
variant="outline"
|
925
|
-
bg="tertiaryBg"
|
926
|
-
onClick={() => {
|
927
|
-
trackPayEvent({
|
928
|
-
event: `pay_with_credit_card_${props.mode || "unknown"}_mode`,
|
929
|
-
client: props.client,
|
930
|
-
walletAddress: props.walletAddress,
|
931
|
-
walletType: props.walletType,
|
932
|
-
});
|
933
|
-
props.setScreen("buy-with-fiat");
|
934
|
-
}}
|
935
|
-
gap="sm"
|
936
|
-
style={{
|
937
|
-
justifyContent: "flex-start",
|
938
|
-
textAlign: "left",
|
939
|
-
}}
|
940
|
-
>
|
941
|
-
<Container color="secondaryText" flex="row" center="both">
|
942
|
-
<IdCardIcon
|
943
|
-
style={{
|
944
|
-
width: iconSize.md,
|
945
|
-
height: iconSize.md,
|
946
|
-
}}
|
947
|
-
/>
|
948
|
-
</Container>
|
949
|
-
|
950
|
-
<Container flex="column" gap="xxs">
|
951
|
-
<Text size="md" color="primaryText">
|
952
|
-
Credit Card
|
953
|
-
</Text>
|
954
|
-
<Text size="xs">Securely pay with credit card</Text>
|
955
|
-
</Container>
|
956
|
-
</Button>
|
957
|
-
|
958
|
-
{/* Crypto */}
|
959
|
-
<Button
|
960
|
-
variant="outline"
|
961
|
-
bg="tertiaryBg"
|
962
|
-
onClick={() => {
|
963
|
-
trackPayEvent({
|
964
|
-
event: `pay_with_crypto_${props.mode || "unknown"}_mode`,
|
965
|
-
client: props.client,
|
966
|
-
walletAddress: props.walletAddress,
|
967
|
-
walletType: props.walletType,
|
968
|
-
});
|
969
|
-
|
970
|
-
props.setScreen("select-wallet");
|
971
|
-
}}
|
972
|
-
style={{
|
973
|
-
justifyContent: "flex-start",
|
974
|
-
}}
|
975
|
-
gap="sm"
|
976
|
-
>
|
977
|
-
<Container color="secondaryText" flex="row" center="both">
|
978
|
-
<CoinsIcon size={iconSize.md} />
|
979
|
-
</Container>
|
980
|
-
|
981
|
-
<Container flex="column" gap="xxs">
|
982
|
-
<Text size="md" color="primaryText">
|
983
|
-
Crypto
|
984
|
-
</Text>
|
985
|
-
<Text size="xs">Pay with your connected wallet</Text>
|
986
|
-
</Container>
|
987
|
-
</Button>
|
988
|
-
</Container>
|
989
|
-
</Container>
|
990
|
-
);
|
991
|
-
}
|
992
|
-
|
993
888
|
function SwapScreenContent(props: {
|
994
889
|
setScreen: (screen: SelectedScreen) => void;
|
995
890
|
tokenAmount: string;
|
@@ -1020,7 +915,6 @@ function SwapScreenContent(props: {
|
|
1020
915
|
toToken,
|
1021
916
|
fromChain,
|
1022
917
|
fromToken,
|
1023
|
-
showFromTokenSelector,
|
1024
918
|
payOptions,
|
1025
919
|
disableTokenSelection,
|
1026
920
|
} = props;
|
@@ -1194,22 +1088,8 @@ function SwapScreenContent(props: {
|
|
1194
1088
|
|
1195
1089
|
{/* Quote info */}
|
1196
1090
|
<div>
|
1197
|
-
<
|
1198
|
-
client={props.client}
|
1199
|
-
onClick={() => {
|
1200
|
-
setScreen({ id: "select-wallet" });
|
1201
|
-
}}
|
1202
|
-
address={props.payer.account.address}
|
1203
|
-
walletId={props.payer.wallet.id}
|
1204
|
-
containerStyle={{
|
1205
|
-
borderBottomRightRadius: 0,
|
1206
|
-
borderBottomLeftRadius: 0,
|
1207
|
-
}}
|
1208
|
-
/>
|
1209
|
-
|
1210
|
-
<PayWithCrypto
|
1091
|
+
<PayWithCryptoQuoteInfo
|
1211
1092
|
value={sourceTokenAmount || ""}
|
1212
|
-
onSelectToken={showFromTokenSelector}
|
1213
1093
|
chain={fromChain}
|
1214
1094
|
token={fromToken}
|
1215
1095
|
isLoading={quoteQuery.isLoading && !sourceTokenAmount}
|
@@ -1550,6 +1430,13 @@ function createSupportedTokens(
|
|
1550
1430
|
|
1551
1431
|
for (const x of data) {
|
1552
1432
|
tokens[x.chain.id] = x.tokens.filter((t) => {
|
1433
|
+
// for source tokens, data is not provided, so we include all of them
|
1434
|
+
if (
|
1435
|
+
t.buyWithCryptoEnabled === undefined &&
|
1436
|
+
t.buyWithFiatEnabled === undefined
|
1437
|
+
) {
|
1438
|
+
return true;
|
1439
|
+
}
|
1553
1440
|
// it token supports both - include it
|
1554
1441
|
if (t.buyWithCryptoEnabled && t.buyWithFiatEnabled) {
|
1555
1442
|
return true;
|
@@ -6,23 +6,32 @@ import { formatNumber } from "../../../../../../utils/formatNumber.js";
|
|
6
6
|
import { toTokens } from "../../../../../../utils/units.js";
|
7
7
|
import type { Account } from "../../../../../../wallets/interfaces/wallet.js";
|
8
8
|
import { useCustomTheme } from "../../../../../core/design-system/CustomThemeProvider.js";
|
9
|
-
import {
|
9
|
+
import { fontSize, spacing } from "../../../../../core/design-system/index.js";
|
10
10
|
import type { PayUIOptions } from "../../../../../core/hooks/connection/ConnectButtonProps.js";
|
11
11
|
import { useChainMetadata } from "../../../../../core/hooks/others/useChainQuery.js";
|
12
|
+
import { useWalletBalance } from "../../../../../core/hooks/others/useWalletBalance.js";
|
13
|
+
import { useActiveAccount } from "../../../../../core/hooks/wallets/useActiveAccount.js";
|
12
14
|
import { useActiveWallet } from "../../../../../core/hooks/wallets/useActiveWallet.js";
|
13
15
|
import { hasSponsoredTransactionsEnabled } from "../../../../../core/utils/wallet.js";
|
14
16
|
import { LoadingScreen } from "../../../../wallets/shared/LoadingScreen.js";
|
15
17
|
import type { PayEmbedConnectOptions } from "../../../PayEmbed.js";
|
16
18
|
import { ChainIcon } from "../../../components/ChainIcon.js";
|
17
19
|
import { Img } from "../../../components/Img.js";
|
20
|
+
import { Skeleton } from "../../../components/Skeleton.js";
|
18
21
|
import { Spacer } from "../../../components/Spacer.js";
|
19
22
|
import { TokenIcon } from "../../../components/TokenIcon.js";
|
20
|
-
import { WalletImage } from "../../../components/WalletImage.js";
|
21
23
|
import { Container, Line, ModalHeader } from "../../../components/basic.js";
|
22
24
|
import { Button } from "../../../components/buttons.js";
|
23
25
|
import { Text } from "../../../components/text.js";
|
26
|
+
import { TokenSymbol } from "../../../components/token/TokenSymbol.js";
|
24
27
|
import { ConnectButton } from "../../ConnectButton.js";
|
25
|
-
import
|
28
|
+
import { formatTokenBalance } from "../formatTokenBalance.js";
|
29
|
+
import {
|
30
|
+
type ERC20OrNativeToken,
|
31
|
+
NATIVE_TOKEN,
|
32
|
+
isNativeToken,
|
33
|
+
} from "../nativeToken.js";
|
34
|
+
import { WalletRow } from "./WalletSelectorButton.js";
|
26
35
|
import { useTransactionCostAndData } from "./main/useBuyTxStates.js";
|
27
36
|
import type { SupportedChainAndTokens } from "./swap/useSwapSupportedChains.js";
|
28
37
|
|
@@ -54,8 +63,22 @@ export function TransactionModeScreen(props: {
|
|
54
63
|
});
|
55
64
|
const theme = useCustomTheme();
|
56
65
|
const activeWallet = useActiveWallet();
|
66
|
+
const activeAccount = useActiveAccount();
|
57
67
|
const sponsoredTransactionsEnabled =
|
58
68
|
hasSponsoredTransactionsEnabled(activeWallet);
|
69
|
+
const balanceQuery = useWalletBalance(
|
70
|
+
{
|
71
|
+
address: activeAccount?.address,
|
72
|
+
chain: payUiOptions.transaction.chain,
|
73
|
+
tokenAddress: isNativeToken(transactionCostAndData?.token || NATIVE_TOKEN)
|
74
|
+
? undefined
|
75
|
+
: transactionCostAndData?.token.address,
|
76
|
+
client: props.client,
|
77
|
+
},
|
78
|
+
{
|
79
|
+
enabled: !!transactionCostAndData,
|
80
|
+
},
|
81
|
+
);
|
59
82
|
|
60
83
|
if (!transactionCostAndData || !chainData) {
|
61
84
|
return <LoadingScreen />;
|
@@ -74,39 +97,47 @@ export function TransactionModeScreen(props: {
|
|
74
97
|
style={{
|
75
98
|
width: "100%",
|
76
99
|
borderRadius: spacing.md,
|
100
|
+
border: `1px solid ${theme.colors.borderColor}`,
|
77
101
|
backgroundColor: theme.colors.tertiaryBg,
|
78
102
|
}}
|
79
103
|
/>
|
80
|
-
) :
|
81
|
-
<Container
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
borderRadius: spacing.md,
|
88
|
-
backgroundColor: theme.colors.tertiaryBg,
|
89
|
-
}}
|
90
|
-
>
|
91
|
-
<WalletImage
|
92
|
-
size={iconSize.xl}
|
93
|
-
id={activeWallet.id}
|
94
|
-
client={client}
|
95
|
-
/>
|
96
|
-
<div
|
104
|
+
) : activeAccount ? (
|
105
|
+
<Container flex="column" gap="sm">
|
106
|
+
<Text size="sm" color="danger" style={{ textAlign: "center" }}>
|
107
|
+
Insufficient funds
|
108
|
+
</Text>
|
109
|
+
<Container
|
110
|
+
flex="row"
|
97
111
|
style={{
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
112
|
+
justifyContent: "space-between",
|
113
|
+
padding: spacing.sm,
|
114
|
+
marginBottom: spacing.sm,
|
115
|
+
borderRadius: spacing.md,
|
116
|
+
backgroundColor: theme.colors.tertiaryBg,
|
117
|
+
border: `1px solid ${theme.colors.borderColor}`,
|
103
118
|
}}
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
119
|
+
>
|
120
|
+
<WalletRow
|
121
|
+
address={activeAccount?.address}
|
122
|
+
iconSize="md"
|
123
|
+
client={client}
|
124
|
+
/>
|
125
|
+
{balanceQuery.data ? (
|
126
|
+
<Container flex="row" gap="3xs" center="y">
|
127
|
+
<Text size="xs" color="secondaryText" weight={500}>
|
128
|
+
{formatTokenBalance(balanceQuery.data, false, 3)}
|
129
|
+
</Text>
|
130
|
+
<TokenSymbol
|
131
|
+
token={transactionCostAndData.token}
|
132
|
+
chain={payUiOptions.transaction.chain}
|
133
|
+
size="xs"
|
134
|
+
color="secondaryText"
|
135
|
+
/>
|
136
|
+
</Container>
|
137
|
+
) : (
|
138
|
+
<Skeleton width="70px" height={fontSize.xs} />
|
139
|
+
)}
|
140
|
+
</Container>
|
110
141
|
</Container>
|
111
142
|
) : null}
|
112
143
|
<Spacer y="md" />
|