@openfort/react 1.1.4 → 1.3.0
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/build/assets/icons.js +1 -1
- package/build/assets/logos.d.ts +15 -0
- package/build/assets/logos.js +9 -0
- package/build/assets/logos.js.map +1 -1
- package/build/components/Common/CopyToClipboard/CopyIconButton.d.ts +3 -1
- package/build/components/Common/CopyToClipboard/CopyIconButton.js +4 -4
- package/build/components/Common/CustomQRCode/index.d.ts +1 -1
- package/build/components/Common/CustomQRCode/index.js +3 -3
- package/build/components/Common/CustomQRCode/styles.d.ts +1 -0
- package/build/components/Common/CustomQRCode/styles.js +4 -4
- package/build/components/Common/CustomQRCode/types.d.ts +2 -0
- package/build/components/Common/Modal/styles.js +4 -1
- package/build/components/Common/Modal/styles.js.map +1 -1
- package/build/components/Common/SolanaChain/index.d.ts +8 -0
- package/build/components/Common/SolanaChain/index.js +40 -0
- package/build/components/Common/SolanaChain/index.js.map +1 -0
- package/build/components/ConnectModal/index.js +16 -2
- package/build/components/ConnectModal/index.js.map +1 -1
- package/build/components/Openfort/OpenfortProvider.js +4 -1
- package/build/components/Openfort/OpenfortProvider.js.map +1 -1
- package/build/components/Openfort/types.d.ts +92 -0
- package/build/components/Openfort/types.js +23 -1
- package/build/components/Openfort/types.js.map +1 -1
- package/build/components/Pages/AssetInventory/SolanaAssetInventory.d.ts +6 -0
- package/build/components/Pages/AssetInventory/SolanaAssetInventory.js +42 -0
- package/build/components/Pages/AssetInventory/SolanaAssetInventory.js.map +1 -0
- package/build/components/Pages/Buy/coinbaseApi.d.ts +1 -1
- package/build/components/Pages/Buy/coinbaseApi.js +2 -13
- package/build/components/Pages/Buy/coinbaseApi.js.map +1 -1
- package/build/components/Pages/Buy/evmCurrencies.d.ts +11 -0
- package/build/components/Pages/Buy/evmCurrencies.js +27 -0
- package/build/components/Pages/Buy/evmCurrencies.js.map +1 -0
- package/build/components/Pages/Buy/index.js +11 -3
- package/build/components/Pages/Buy/index.js.map +1 -1
- package/build/components/Pages/Buy/onrampApi.d.ts +8 -1
- package/build/components/Pages/Buy/onrampApi.js +24 -14
- package/build/components/Pages/Buy/onrampApi.js.map +1 -1
- package/build/components/Pages/Buy/solanaCurrencies.d.ts +9 -0
- package/build/components/Pages/Buy/solanaCurrencies.js +25 -0
- package/build/components/Pages/Buy/solanaCurrencies.js.map +1 -0
- package/build/components/Pages/Buy/stripeApi.d.ts +1 -1
- package/build/components/Pages/Buy/stripeApi.js +2 -13
- package/build/components/Pages/Buy/stripeApi.js.map +1 -1
- package/build/components/Pages/BuyComplete/index.js +7 -1
- package/build/components/Pages/BuyComplete/index.js.map +1 -1
- package/build/components/Pages/BuyProcessing/index.js +9 -5
- package/build/components/Pages/BuyProcessing/index.js.map +1 -1
- package/build/components/Pages/BuySelectProvider/index.js +11 -6
- package/build/components/Pages/BuySelectProvider/index.js.map +1 -1
- package/build/components/Pages/Connected/EthereumConnected.js +8 -32
- package/build/components/Pages/Connected/EthereumConnected.js.map +1 -1
- package/build/components/Pages/Connected/SolanaConnected.js +11 -5
- package/build/components/Pages/Connected/SolanaConnected.js.map +1 -1
- package/build/components/Pages/Deposit/AddressPageLink.d.ts +7 -0
- package/build/components/Pages/Deposit/AddressPageLink.js +17 -0
- package/build/components/Pages/Deposit/AddressPageLink.js.map +1 -0
- package/build/components/Pages/Deposit/AssetChainLogo.d.ts +9 -0
- package/build/components/Pages/Deposit/AssetChainLogo.js +24 -0
- package/build/components/Pages/Deposit/AssetChainLogo.js.map +1 -0
- package/build/components/Pages/Deposit/DepositAddressBlock.d.ts +21 -0
- package/build/components/Pages/Deposit/DepositAddressBlock.js +28 -0
- package/build/components/Pages/Deposit/DepositAddressBlock.js.map +1 -0
- package/build/components/Pages/Deposit/DepositProgress.d.ts +15 -0
- package/build/components/Pages/Deposit/DepositProgress.js +111 -0
- package/build/components/Pages/Deposit/DepositProgress.js.map +1 -0
- package/build/components/Pages/Deposit/DepositStatus.d.ts +9 -0
- package/build/components/Pages/Deposit/DepositStatus.js +43 -0
- package/build/components/Pages/Deposit/DepositStatus.js.map +1 -0
- package/build/components/Pages/Deposit/DepositSuccess.d.ts +6 -0
- package/build/components/Pages/Deposit/DepositSuccess.js +25 -0
- package/build/components/Pages/Deposit/DepositSuccess.js.map +1 -0
- package/build/components/Pages/Deposit/Details.d.ts +12 -0
- package/build/components/Pages/Deposit/Details.js +40 -0
- package/build/components/Pages/Deposit/Details.js.map +1 -0
- package/build/components/Pages/Deposit/LogoSelect.d.ts +12 -0
- package/build/components/Pages/Deposit/LogoSelect.js +95 -0
- package/build/components/Pages/Deposit/LogoSelect.js.map +1 -0
- package/build/components/Pages/Deposit/OrDivider.d.ts +2 -0
- package/build/components/Pages/Deposit/OrDivider.js +10 -0
- package/build/components/Pages/Deposit/OrDivider.js.map +1 -0
- package/build/components/Pages/Deposit/RouteSelectors.d.ts +13 -0
- package/build/components/Pages/Deposit/RouteSelectors.js +19 -0
- package/build/components/Pages/Deposit/RouteSelectors.js.map +1 -0
- package/build/components/Pages/Deposit/cexChains.d.ts +9 -0
- package/build/components/Pages/Deposit/cexChains.js +23 -0
- package/build/components/Pages/Deposit/cexChains.js.map +1 -0
- package/build/components/Pages/Deposit/formStyles.d.ts +24 -0
- package/build/components/Pages/Deposit/formStyles.js +83 -0
- package/build/components/Pages/Deposit/formStyles.js.map +1 -0
- package/build/components/Pages/Deposit/index.d.ts +7 -0
- package/build/components/Pages/Deposit/index.js +114 -0
- package/build/components/Pages/Deposit/index.js.map +1 -0
- package/build/components/Pages/Deposit/paymentOptions.d.ts +49 -0
- package/build/components/Pages/Deposit/paymentOptions.js +63 -0
- package/build/components/Pages/Deposit/paymentOptions.js.map +1 -0
- package/build/components/Pages/Deposit/sources.d.ts +17 -0
- package/build/components/Pages/Deposit/sources.js +22 -0
- package/build/components/Pages/Deposit/sources.js.map +1 -0
- package/build/components/Pages/Deposit/styles.d.ts +25 -0
- package/build/components/Pages/Deposit/styles.js +167 -0
- package/build/components/Pages/Deposit/styles.js.map +1 -0
- package/build/components/Pages/Deposit/useDepositRoute.d.ts +34 -0
- package/build/components/Pages/Deposit/useDepositRoute.js +106 -0
- package/build/components/Pages/Deposit/useDepositRoute.js.map +1 -0
- package/build/components/Pages/Deposit/useFundingTarget.d.ts +11 -0
- package/build/components/Pages/Deposit/useFundingTarget.js +25 -0
- package/build/components/Pages/Deposit/useFundingTarget.js.map +1 -0
- package/build/components/Pages/DepositCex/index.d.ts +11 -0
- package/build/components/Pages/DepositCex/index.js +229 -0
- package/build/components/Pages/DepositCex/index.js.map +1 -0
- package/build/components/Pages/DepositCrypto/index.d.ts +8 -0
- package/build/components/Pages/DepositCrypto/index.js +31 -0
- package/build/components/Pages/DepositCrypto/index.js.map +1 -0
- package/build/components/Pages/DepositWallet/DepositWalletDesktop.d.ts +20 -0
- package/build/components/Pages/DepositWallet/DepositWalletDesktop.js +139 -0
- package/build/components/Pages/DepositWallet/DepositWalletDesktop.js.map +1 -0
- package/build/components/Pages/DepositWallet/index.d.ts +9 -0
- package/build/components/Pages/DepositWallet/index.js +107 -0
- package/build/components/Pages/DepositWallet/index.js.map +1 -0
- package/build/components/Pages/DepositWallet/walletDeeplinks.d.ts +50 -0
- package/build/components/Pages/DepositWallet/walletDeeplinks.js +109 -0
- package/build/components/Pages/DepositWallet/walletDeeplinks.js.map +1 -0
- package/build/components/Pages/ExportKey/index.js +10 -2
- package/build/components/Pages/ExportKey/index.js.map +1 -1
- package/build/components/Pages/NoAssetsAvailable/index.js +5 -21
- package/build/components/Pages/NoAssetsAvailable/index.js.map +1 -1
- package/build/components/Pages/SelectToken/SolanaSelectToken.d.ts +1 -0
- package/build/components/Pages/SelectToken/SolanaSelectToken.js +50 -0
- package/build/components/Pages/SelectToken/SolanaSelectToken.js.map +1 -0
- package/build/components/Pages/SelectToken/index.js +13 -2
- package/build/components/Pages/SelectToken/index.js.map +1 -1
- package/build/components/Pages/SelectToken/styles.js +1 -1
- package/build/components/Pages/Send/SolanaSend.d.ts +1 -0
- package/build/components/Pages/Send/SolanaSend.js +89 -0
- package/build/components/Pages/Send/SolanaSend.js.map +1 -0
- package/build/components/Pages/Send/index.d.ts +2 -1
- package/build/components/Pages/Send/index.js +0 -1
- package/build/components/Pages/Send/index.js.map +1 -1
- package/build/components/Pages/Send/utils.js +4 -1
- package/build/components/Pages/Send/utils.js.map +1 -1
- package/build/components/Pages/SendConfirmation/EstimatedFees.js +5 -3
- package/build/components/Pages/SendConfirmation/EstimatedFees.js.map +1 -1
- package/build/components/Pages/SendConfirmation/SolanaSendConfirmation.d.ts +1 -0
- package/build/components/Pages/SendConfirmation/SolanaSendConfirmation.js +121 -0
- package/build/components/Pages/SendConfirmation/SolanaSendConfirmation.js.map +1 -0
- package/build/components/Pages/SendConfirmation/index.js +4 -3
- package/build/components/Pages/SendConfirmation/index.js.map +1 -1
- package/build/constants/logos.js +1 -0
- package/build/constants/logos.js.map +1 -1
- package/build/ethereum/hooks/useEthereumWalletAssets.js +212 -95
- package/build/ethereum/hooks/useEthereumWalletAssets.js.map +1 -1
- package/build/hooks/openfort/fundingClient.d.ts +34 -0
- package/build/hooks/openfort/fundingClient.js +60 -0
- package/build/hooks/openfort/fundingClient.js.map +1 -0
- package/build/hooks/openfort/useFunding.d.ts +159 -0
- package/build/hooks/openfort/useFunding.js +204 -0
- package/build/hooks/openfort/useFunding.js.map +1 -0
- package/build/hooks/openfort/useFundingChains.d.ts +49 -0
- package/build/hooks/openfort/useFundingChains.js +100 -0
- package/build/hooks/openfort/useFundingChains.js.map +1 -0
- package/build/hooks/useBalance.js +6 -1
- package/build/hooks/useBalance.js.map +1 -1
- package/build/index.d.ts +4 -1
- package/build/index.js +2 -1
- package/build/index.js.map +1 -1
- package/build/shared/hooks/useAsyncData.d.ts +11 -0
- package/build/shared/hooks/useAsyncData.js +73 -13
- package/build/shared/hooks/useAsyncData.js.map +1 -1
- package/build/solana/hooks/useSolanaWalletAssets.d.ts +24 -0
- package/build/solana/hooks/useSolanaWalletAssets.js +86 -0
- package/build/solana/hooks/useSolanaWalletAssets.js.map +1 -0
- package/build/solana/transfer.d.ts +61 -0
- package/build/solana/transfer.js +219 -0
- package/build/solana/transfer.js.map +1 -0
- package/build/solana/types.d.ts +8 -0
- package/build/utils/index.d.ts +2 -1
- package/build/utils/index.js +1 -1
- package/build/version.d.ts +1 -1
- package/build/version.js +1 -1
- package/build/wagmi/defaultConnectors.js +5 -1
- package/build/wagmi/defaultConnectors.js.map +1 -1
- package/package.json +13 -1
|
@@ -5,17 +5,6 @@ const getBackendUrl = () => {
|
|
|
5
5
|
const sdkConfig = SDKConfiguration.getInstance();
|
|
6
6
|
return (sdkConfig === null || sdkConfig === void 0 ? void 0 : sdkConfig.backendUrl) || 'https://api.openfort.io';
|
|
7
7
|
};
|
|
8
|
-
// Map chain IDs to Coinbase network names
|
|
9
|
-
const getNetworkName = (chainId) => {
|
|
10
|
-
const networkMap = {
|
|
11
|
-
1: 'ethereum',
|
|
12
|
-
8453: 'base',
|
|
13
|
-
137: 'polygon',
|
|
14
|
-
42161: 'arbitrum',
|
|
15
|
-
10: 'optimism',
|
|
16
|
-
};
|
|
17
|
-
return networkMap[chainId] || 'base';
|
|
18
|
-
};
|
|
19
8
|
// Coinbase supported currencies (more extensive than Stripe)
|
|
20
9
|
const COINBASE_SUPPORTED_CURRENCIES = [
|
|
21
10
|
'btc',
|
|
@@ -61,7 +50,7 @@ const getCurrencyCode = (token) => {
|
|
|
61
50
|
* 3. One-click with quote: One-click + paymentMethod + country (+ subdivision for US)
|
|
62
51
|
*/
|
|
63
52
|
const createCoinbaseSession = async (params) => {
|
|
64
|
-
const { token,
|
|
53
|
+
const { token, network, publishableKey, ...rest } = params;
|
|
65
54
|
if (!publishableKey) {
|
|
66
55
|
throw new Error('Publishable key is required for authentication');
|
|
67
56
|
}
|
|
@@ -69,7 +58,7 @@ const createCoinbaseSession = async (params) => {
|
|
|
69
58
|
const requestBody = {
|
|
70
59
|
provider: 'coinbase',
|
|
71
60
|
destinationCurrency: getCurrencyCode(token),
|
|
72
|
-
destinationNetwork:
|
|
61
|
+
destinationNetwork: network,
|
|
73
62
|
destinationAddress: rest.destinationAddress,
|
|
74
63
|
};
|
|
75
64
|
// Add optional parameters only if provided
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coinbaseApi.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"coinbaseApi.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Asset } from '../../Openfort/types';
|
|
2
|
+
/**
|
|
3
|
+
* Buyable EVM destination currencies for the fiat onramp. USDC is first so it is
|
|
4
|
+
* the default; both are supported by Coinbase and Stripe. Balances aren't needed
|
|
5
|
+
* (you're buying), so these carry zero balance — only the symbol feeds the onramp
|
|
6
|
+
* `destinationCurrency`. The USDC `address` is Base USDC cast to `Hex` to fit the
|
|
7
|
+
* shared `Asset` type; it's only read by `getAssetSymbol`. Mirrors
|
|
8
|
+
* {@link SOLANA_BUY_CURRENCIES} so the card/Apple Pay picker always has options,
|
|
9
|
+
* even for a freshly created wallet with no indexed token balances.
|
|
10
|
+
*/
|
|
11
|
+
export declare const EVM_BUY_CURRENCIES: Asset[];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DEST_USDC } from '../Deposit/sources.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Buyable EVM destination currencies for the fiat onramp. USDC is first so it is
|
|
5
|
+
* the default; both are supported by Coinbase and Stripe. Balances aren't needed
|
|
6
|
+
* (you're buying), so these carry zero balance — only the symbol feeds the onramp
|
|
7
|
+
* `destinationCurrency`. The USDC `address` is Base USDC cast to `Hex` to fit the
|
|
8
|
+
* shared `Asset` type; it's only read by `getAssetSymbol`. Mirrors
|
|
9
|
+
* {@link SOLANA_BUY_CURRENCIES} so the card/Apple Pay picker always has options,
|
|
10
|
+
* even for a freshly created wallet with no indexed token balances.
|
|
11
|
+
*/
|
|
12
|
+
const EVM_BUY_CURRENCIES = [
|
|
13
|
+
{
|
|
14
|
+
type: 'erc20',
|
|
15
|
+
address: DEST_USDC,
|
|
16
|
+
balance: BigInt(0),
|
|
17
|
+
metadata: { symbol: 'USDC', name: 'USD Coin', decimals: 6 },
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
type: 'native',
|
|
21
|
+
balance: BigInt(0),
|
|
22
|
+
metadata: { symbol: 'ETH', decimals: 18, fiat: { value: 0, currency: 'USD' } },
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
export { EVM_BUY_CURRENCIES };
|
|
27
|
+
//# sourceMappingURL=evmCurrencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evmCurrencies.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { ChainTypeEnum } from '@openfort/openfort-js';
|
|
2
3
|
import { useState, useMemo, useEffect } from 'react';
|
|
3
4
|
import { useEthereumWalletAssets } from '../../../ethereum/hooks/useEthereumWalletAssets.js';
|
|
4
5
|
import useLocales from '../../../hooks/useLocales.js';
|
|
6
|
+
import { useOpenfortCore } from '../../../openfort/useOpenfort.js';
|
|
5
7
|
import Button from '../../Common/Button/index.js';
|
|
6
8
|
import { Arrow, ArrowChevron } from '../../Common/Button/styles.js';
|
|
7
9
|
import { ModalHeading, ModalBody } from '../../Common/Modal/styles.js';
|
|
@@ -9,6 +11,7 @@ import { routes } from '../../Openfort/types.js';
|
|
|
9
11
|
import { useOpenfort } from '../../Openfort/useOpenfort.js';
|
|
10
12
|
import { PageContent } from '../../PageContent/index.js';
|
|
11
13
|
import { sanitizeForParsing, sanitizeAmountInput, isSameToken, getAssetSymbol } from '../Send/utils.js';
|
|
14
|
+
import { SOLANA_BUY_CURRENCIES } from './solanaCurrencies.js';
|
|
12
15
|
import { Section, SectionLabel, AmountCard, CurrencySymbol, AmountInput, PresetList, PresetButton, SelectorButton, SelectorContent, SelectorTitle, SelectorSubtitle, SelectorRight, ContinueButtonWrapper } from './styles.js';
|
|
13
16
|
import { createCurrencyFormatter, getCurrencySymbol } from './utils.js';
|
|
14
17
|
|
|
@@ -17,7 +20,11 @@ const Buy = () => {
|
|
|
17
20
|
var _a;
|
|
18
21
|
const { buyForm, setBuyForm, setRoute, triggerResize } = useOpenfort();
|
|
19
22
|
const locales = useLocales();
|
|
20
|
-
const {
|
|
23
|
+
const { chainType } = useOpenfortCore();
|
|
24
|
+
const { data: ethAssets } = useEthereumWalletAssets();
|
|
25
|
+
// Solana wallets buy Solana currencies (USDC default, then SOL); EVM reads its
|
|
26
|
+
// own assets. Both hooks run unconditionally; the active chain picks the list.
|
|
27
|
+
const assets = chainType === ChainTypeEnum.SVM ? SOLANA_BUY_CURRENCIES : ethAssets;
|
|
21
28
|
const [pressedPreset, setPressedPreset] = useState(null);
|
|
22
29
|
const fiatAmount = useMemo(() => {
|
|
23
30
|
const normalizedAmount = sanitizeForParsing(sanitizeAmountInput(buyForm.amount));
|
|
@@ -77,11 +84,12 @@ const Buy = () => {
|
|
|
77
84
|
setRoute(routes.BUY_SELECT_PROVIDER);
|
|
78
85
|
};
|
|
79
86
|
const handleBack = () => {
|
|
80
|
-
|
|
87
|
+
// Card/Apple Pay is reached via the Add funds hub — back returns there.
|
|
88
|
+
setRoute(routes.DEPOSIT);
|
|
81
89
|
};
|
|
82
90
|
const isPresetSelected = (value) => pressedPreset === value;
|
|
83
91
|
const step1Disabled = fiatAmount === null || fiatAmount <= 0;
|
|
84
|
-
return (jsxs(PageContent, { onBack: handleBack, children: [jsx(ModalHeading, { children: locales.buyScreen_heading }), jsx(ModalBody, { children: locales.buyScreen_subheading }), jsxs(Section, { children: [jsx(SectionLabel, { children: "Amount" }), jsxs(AmountCard, { children: [jsx(CurrencySymbol, { children: currencySymbol }), jsx(AmountInput, { value: buyForm.amount, onChange: handleAmountChange, onBlur: handleAmountBlur, placeholder: "0.00", inputMode: "decimal", autoComplete: "off" })] }), jsx(PresetList, { children: amountPresets.map((preset) => (jsx(PresetButton, { type: "button", onClick: () => handlePresetClick(preset), "$active": isPresetSelected(preset), children: currencyFormatter.format(preset) }, preset))) })] }), jsxs(Section, { children: [jsx(SectionLabel, { children: "
|
|
92
|
+
return (jsxs(PageContent, { onBack: handleBack, children: [jsx(ModalHeading, { children: locales.buyScreen_heading }), jsx(ModalBody, { children: locales.buyScreen_subheading }), jsxs(Section, { children: [jsx(SectionLabel, { children: "Amount" }), jsxs(AmountCard, { children: [jsx(CurrencySymbol, { children: currencySymbol }), jsx(AmountInput, { value: buyForm.amount, onChange: handleAmountChange, onBlur: handleAmountBlur, placeholder: "0.00", inputMode: "decimal", autoComplete: "off" })] }), jsx(PresetList, { children: amountPresets.map((preset) => (jsx(PresetButton, { type: "button", onClick: () => handlePresetClick(preset), "$active": isPresetSelected(preset), children: currencyFormatter.format(preset) }, preset))) })] }), jsxs(Section, { children: [jsx(SectionLabel, { children: "Currency" }), jsxs(SelectorButton, { type: "button", onClick: handleOpenTokenSelector, children: [jsxs(SelectorContent, { children: [jsx(SelectorTitle, { children: tokenSymbol || 'Select currency' }), jsx(SelectorSubtitle, { children: tokenName })] }), jsx(SelectorRight, { children: jsx(Arrow, { width: "13", height: "12", viewBox: "0 0 13 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: jsx(ArrowChevron, { stroke: "currentColor", d: "M7.51431 1.5L11.757 5.74264M7.5 10.4858L11.7426 6.24314", strokeWidth: "2", strokeLinecap: "round" }) }) })] })] }), jsx(ContinueButtonWrapper, { children: jsx(Button, { variant: "primary", onClick: handleContinue, disabled: step1Disabled, children: "Continue" }) })] }));
|
|
85
93
|
};
|
|
86
94
|
|
|
87
95
|
export { Buy as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ChainTypeEnum } from '@openfort/openfort-js';
|
|
1
2
|
import type { Asset } from '../../Openfort/types';
|
|
2
3
|
export type OnrampQuote = {
|
|
3
4
|
provider: string;
|
|
@@ -13,9 +14,15 @@ export type OnrampQuote = {
|
|
|
13
14
|
}>;
|
|
14
15
|
exchangeRate: string;
|
|
15
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Resolve the onramp destination network for the active chain. Solana always
|
|
19
|
+
* resolves to `solana`; an EVM wallet whose `chainId` hasn't loaded yet returns
|
|
20
|
+
* `undefined`, so callers stay gated until the chain is ready.
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveOnrampNetwork(chainType: ChainTypeEnum, chainId?: number): string | undefined;
|
|
16
23
|
type GetAllQuotesParams = {
|
|
17
24
|
token: Asset;
|
|
18
|
-
|
|
25
|
+
network: string;
|
|
19
26
|
publishableKey: string;
|
|
20
27
|
sourceCurrency: string;
|
|
21
28
|
sourceAmount: string;
|
|
@@ -1,21 +1,31 @@
|
|
|
1
|
-
import { SDKConfiguration } from '@openfort/openfort-js';
|
|
1
|
+
import { ChainTypeEnum, SDKConfiguration } from '@openfort/openfort-js';
|
|
2
2
|
import { getAssetSymbol } from '../Send/utils.js';
|
|
3
3
|
|
|
4
4
|
const getBackendUrl = () => {
|
|
5
5
|
const sdkConfig = SDKConfiguration.getInstance();
|
|
6
6
|
return (sdkConfig === null || sdkConfig === void 0 ? void 0 : sdkConfig.backendUrl) || 'https://api.openfort.io';
|
|
7
7
|
};
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
10: 'optimism',
|
|
16
|
-
};
|
|
17
|
-
return networkMap[chainId] || 'base';
|
|
8
|
+
/** EVM chain id → onramp network name. */
|
|
9
|
+
const EVM_NETWORK_MAP = {
|
|
10
|
+
1: 'ethereum',
|
|
11
|
+
8453: 'base',
|
|
12
|
+
137: 'polygon',
|
|
13
|
+
42161: 'arbitrum',
|
|
14
|
+
10: 'optimism',
|
|
18
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Resolve the onramp destination network for the active chain. Solana always
|
|
18
|
+
* resolves to `solana`; an EVM wallet whose `chainId` hasn't loaded yet returns
|
|
19
|
+
* `undefined`, so callers stay gated until the chain is ready.
|
|
20
|
+
*/
|
|
21
|
+
function resolveOnrampNetwork(chainType, chainId) {
|
|
22
|
+
var _a;
|
|
23
|
+
if (chainType === ChainTypeEnum.SVM)
|
|
24
|
+
return 'solana';
|
|
25
|
+
if (chainId == null)
|
|
26
|
+
return undefined;
|
|
27
|
+
return (_a = EVM_NETWORK_MAP[chainId]) !== null && _a !== void 0 ? _a : 'base';
|
|
28
|
+
}
|
|
19
29
|
// Map token symbol to currency code
|
|
20
30
|
const getCurrencyCode = (token) => {
|
|
21
31
|
return getAssetSymbol(token).toLowerCase();
|
|
@@ -25,14 +35,14 @@ const getCurrencyCode = (token) => {
|
|
|
25
35
|
* Calls the backend without specifying a provider to get quotes from all providers
|
|
26
36
|
*/
|
|
27
37
|
const getAllQuotes = async (params) => {
|
|
28
|
-
const { token,
|
|
38
|
+
const { token, network, publishableKey, sourceCurrency, sourceAmount } = params;
|
|
29
39
|
if (!publishableKey) {
|
|
30
40
|
throw new Error('Publishable key is required for authentication');
|
|
31
41
|
}
|
|
32
42
|
// Build request body WITHOUT provider to get all quotes
|
|
33
43
|
const requestBody = {
|
|
34
44
|
destinationCurrency: getCurrencyCode(token),
|
|
35
|
-
destinationNetwork:
|
|
45
|
+
destinationNetwork: network,
|
|
36
46
|
sourceCurrency: sourceCurrency.toLowerCase(),
|
|
37
47
|
sourceAmount,
|
|
38
48
|
};
|
|
@@ -53,5 +63,5 @@ const getAllQuotes = async (params) => {
|
|
|
53
63
|
return Array.isArray(data) ? data : [data];
|
|
54
64
|
};
|
|
55
65
|
|
|
56
|
-
export { getAllQuotes };
|
|
66
|
+
export { getAllQuotes, resolveOnrampNetwork };
|
|
57
67
|
//# sourceMappingURL=onrampApi.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onrampApi.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"onrampApi.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Asset } from '../../Openfort/types';
|
|
2
|
+
/**
|
|
3
|
+
* Buyable Solana destination currencies for the fiat onramp. USDC is first so it
|
|
4
|
+
* is the default; both are supported by Coinbase and Stripe on Solana. Balances
|
|
5
|
+
* aren't needed (you're buying), so these carry zero balance — only the symbol
|
|
6
|
+
* feeds the onramp `destinationCurrency`. The USDC `address` is the SPL mint cast
|
|
7
|
+
* to `Hex` to fit the shared `Asset` type; it's only read by `getAssetSymbol`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const SOLANA_BUY_CURRENCIES: Asset[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DEST_USDC_SOL } from '../Deposit/sources.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Buyable Solana destination currencies for the fiat onramp. USDC is first so it
|
|
5
|
+
* is the default; both are supported by Coinbase and Stripe on Solana. Balances
|
|
6
|
+
* aren't needed (you're buying), so these carry zero balance — only the symbol
|
|
7
|
+
* feeds the onramp `destinationCurrency`. The USDC `address` is the SPL mint cast
|
|
8
|
+
* to `Hex` to fit the shared `Asset` type; it's only read by `getAssetSymbol`.
|
|
9
|
+
*/
|
|
10
|
+
const SOLANA_BUY_CURRENCIES = [
|
|
11
|
+
{
|
|
12
|
+
type: 'erc20',
|
|
13
|
+
address: DEST_USDC_SOL,
|
|
14
|
+
balance: BigInt(0),
|
|
15
|
+
metadata: { symbol: 'USDC', name: 'USD Coin', decimals: 6 },
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
type: 'native',
|
|
19
|
+
balance: BigInt(0),
|
|
20
|
+
metadata: { symbol: 'SOL', decimals: 9, fiat: { value: 0, currency: 'USD' } },
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
export { SOLANA_BUY_CURRENCIES };
|
|
25
|
+
//# sourceMappingURL=solanaCurrencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solanaCurrencies.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -21,7 +21,7 @@ export declare const isStripeSupported: (token: Asset) => boolean;
|
|
|
21
21
|
*/
|
|
22
22
|
export declare const createStripeSession: (params: Omit<CreateStripeSessionParams, "destinationCurrency" | "destinationNetwork"> & {
|
|
23
23
|
token: Asset;
|
|
24
|
-
|
|
24
|
+
network: string;
|
|
25
25
|
publishableKey: string;
|
|
26
26
|
}) => Promise<StripeOnrampResponse>;
|
|
27
27
|
export {};
|
|
@@ -5,17 +5,6 @@ const getBackendUrl = () => {
|
|
|
5
5
|
const sdkConfig = SDKConfiguration.getInstance();
|
|
6
6
|
return (sdkConfig === null || sdkConfig === void 0 ? void 0 : sdkConfig.backendUrl) || 'https://api.openfort.io';
|
|
7
7
|
};
|
|
8
|
-
// Map chain IDs to Stripe network names
|
|
9
|
-
const getNetworkName = (chainId) => {
|
|
10
|
-
const networkMap = {
|
|
11
|
-
1: 'ethereum',
|
|
12
|
-
8453: 'base',
|
|
13
|
-
137: 'polygon',
|
|
14
|
-
42161: 'arbitrum',
|
|
15
|
-
10: 'optimism',
|
|
16
|
-
};
|
|
17
|
-
return networkMap[chainId] || 'base';
|
|
18
|
-
};
|
|
19
8
|
// Stripe supported currencies
|
|
20
9
|
const STRIPE_SUPPORTED_CURRENCIES = ['btc', 'eth', 'xlm', 'matic', 'pol', 'sol', 'usdc', 'avax', 'wld'];
|
|
21
10
|
// Check if a token is supported by Stripe
|
|
@@ -38,12 +27,12 @@ const getCurrencyCode = (token) => {
|
|
|
38
27
|
* Calls backend API to create a prefilled session with wallet addresses and amounts
|
|
39
28
|
*/
|
|
40
29
|
const createStripeSession = async (params) => {
|
|
41
|
-
const { token,
|
|
30
|
+
const { token, network, publishableKey, destinationAddress, sourceAmount, sourceCurrency, redirectUrl } = params;
|
|
42
31
|
if (!publishableKey) {
|
|
43
32
|
throw new Error('Publishable key is required for authentication');
|
|
44
33
|
}
|
|
45
34
|
const destinationCurrency = getCurrencyCode(token);
|
|
46
|
-
const destinationNetwork =
|
|
35
|
+
const destinationNetwork = network;
|
|
47
36
|
// Build request body for backend API
|
|
48
37
|
const requestBody = {
|
|
49
38
|
provider: 'stripe',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stripeApi.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stripeApi.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -39,7 +39,13 @@ const BuyComplete = () => {
|
|
|
39
39
|
const handleBack = () => {
|
|
40
40
|
setRoute(routes.CONNECTED);
|
|
41
41
|
};
|
|
42
|
-
const blockExplorerUrl = address
|
|
42
|
+
const blockExplorerUrl = !address
|
|
43
|
+
? ''
|
|
44
|
+
: chainType === ChainTypeEnum.SVM
|
|
45
|
+
? getExplorerUrl(ChainTypeEnum.SVM, { address, cluster: solanaWallet.cluster })
|
|
46
|
+
: chainId
|
|
47
|
+
? getExplorerUrl(ChainTypeEnum.EVM, { chainId, address })
|
|
48
|
+
: '';
|
|
43
49
|
return (jsx(PageContent, { onBack: handleBack, children: jsxs(ModalContent, { style: { paddingBottom: 18, textAlign: 'center' }, children: [jsx(ModalH1, { children: "Provider Finished" }), jsx(ModalBody, { style: { marginTop: 24 }, children: "The provider flow has been completed. You can view your wallet on the block explorer to check your transactions." }), jsxs(Section, { style: { marginTop: 24 }, children: [blockExplorerUrl && (jsx(ContinueButtonWrapper, { style: { marginTop: 0 }, children: jsx(Button, { variant: "secondary", onClick: () => window.open(blockExplorerUrl, '_blank', 'noopener,noreferrer'), children: jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: '8px' }, children: [jsx("span", { children: "View Wallet Transactions" }), jsx(ExternalLinkIcon, {})] }) }) })), jsx(ContinueButtonWrapper, { style: { marginTop: blockExplorerUrl ? 4 : 0 }, children: jsx(Button, { variant: "primary", onClick: handleDone, children: "Done" }) })] })] }) }));
|
|
44
50
|
};
|
|
45
51
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -13,6 +13,8 @@ import { routes } from '../../Openfort/types.js';
|
|
|
13
13
|
import { useOpenfort } from '../../Openfort/useOpenfort.js';
|
|
14
14
|
import { PageContent } from '../../PageContent/index.js';
|
|
15
15
|
import { createCoinbaseSession } from '../Buy/coinbaseApi.js';
|
|
16
|
+
import { resolveOnrampNetwork } from '../Buy/onrampApi.js';
|
|
17
|
+
import { SOLANA_BUY_CURRENCIES } from '../Buy/solanaCurrencies.js';
|
|
16
18
|
import { createStripeSession } from '../Buy/stripeApi.js';
|
|
17
19
|
import { ContinueButtonWrapper, PendingContainer, StackedButtonWrapper } from '../Buy/styles.js';
|
|
18
20
|
import { isSameToken } from '../Send/utils.js';
|
|
@@ -27,11 +29,13 @@ const BuyProcessing = () => {
|
|
|
27
29
|
const isConnected = wallet.status === 'connected';
|
|
28
30
|
const address = isConnected ? wallet.address : undefined;
|
|
29
31
|
const chainId = isConnected && chainType === ChainTypeEnum.EVM ? wallet.chainId : undefined;
|
|
32
|
+
const network = resolveOnrampNetwork(chainType, chainId);
|
|
30
33
|
const [popupWindow, setPopupWindow] = useState(null);
|
|
31
34
|
const [showContinueButton, setShowContinueButton] = useState(false);
|
|
32
35
|
const [isCreatingSession, setIsCreatingSession] = useState(true);
|
|
33
36
|
const [sessionError, setSessionError] = useState(false);
|
|
34
|
-
const { data:
|
|
37
|
+
const { data: ethAssets } = useEthereumWalletAssets();
|
|
38
|
+
const assets = chainType === ChainTypeEnum.SVM ? SOLANA_BUY_CURRENCIES : ethAssets;
|
|
35
39
|
const matchedToken = useMemo(() => assets === null || assets === void 0 ? void 0 : assets.find((asset) => isSameToken(asset, buyForm.asset)), [assets, buyForm.asset]);
|
|
36
40
|
const selectedTokenOption = matchedToken !== null && matchedToken !== void 0 ? matchedToken : assets === null || assets === void 0 ? void 0 : assets[0];
|
|
37
41
|
const selectedToken = selectedTokenOption !== null && selectedTokenOption !== void 0 ? selectedTokenOption : buyForm.asset;
|
|
@@ -47,7 +51,7 @@ const BuyProcessing = () => {
|
|
|
47
51
|
// Create session and open popup once wallet is ready
|
|
48
52
|
const sessionStartedRef = useRef(false);
|
|
49
53
|
useEffect(() => {
|
|
50
|
-
if (!address || !
|
|
54
|
+
if (!address || !network)
|
|
51
55
|
return;
|
|
52
56
|
if (sessionStartedRef.current)
|
|
53
57
|
return;
|
|
@@ -65,7 +69,7 @@ const BuyProcessing = () => {
|
|
|
65
69
|
if (buyForm.providerId === 'coinbase') {
|
|
66
70
|
const session = await createCoinbaseSession({
|
|
67
71
|
token: selectedToken,
|
|
68
|
-
|
|
72
|
+
network,
|
|
69
73
|
publishableKey,
|
|
70
74
|
destinationAddress: address,
|
|
71
75
|
sourceAmount: fiatAmount.toFixed(2),
|
|
@@ -77,7 +81,7 @@ const BuyProcessing = () => {
|
|
|
77
81
|
else if (buyForm.providerId === 'stripe') {
|
|
78
82
|
const session = await createStripeSession({
|
|
79
83
|
token: selectedToken,
|
|
80
|
-
|
|
84
|
+
network,
|
|
81
85
|
publishableKey,
|
|
82
86
|
destinationAddress: address,
|
|
83
87
|
sourceAmount: fiatAmount.toFixed(2),
|
|
@@ -129,7 +133,7 @@ const BuyProcessing = () => {
|
|
|
129
133
|
}
|
|
130
134
|
};
|
|
131
135
|
createSessionAndOpenPopup();
|
|
132
|
-
}, [address,
|
|
136
|
+
}, [address, network]); // Run when wallet becomes ready
|
|
133
137
|
// Trigger resize on mount and when state changes
|
|
134
138
|
useEffect(() => {
|
|
135
139
|
triggerResize();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -11,8 +11,9 @@ import { routes } from '../../Openfort/types.js';
|
|
|
11
11
|
import { useOpenfort } from '../../Openfort/useOpenfort.js';
|
|
12
12
|
import { PageContent } from '../../PageContent/index.js';
|
|
13
13
|
import { isCoinbaseSupported } from '../Buy/coinbaseApi.js';
|
|
14
|
-
import { getAllQuotes } from '../Buy/onrampApi.js';
|
|
14
|
+
import { resolveOnrampNetwork, getAllQuotes } from '../Buy/onrampApi.js';
|
|
15
15
|
import { getProviders } from '../Buy/providers.js';
|
|
16
|
+
import { SOLANA_BUY_CURRENCIES } from '../Buy/solanaCurrencies.js';
|
|
16
17
|
import { isStripeSupported } from '../Buy/stripeApi.js';
|
|
17
18
|
import { ProviderList, ProviderButton, ProviderInfo, ProviderNameRow, ProviderName, ProviderBadge, ProviderMeta, ProviderRight, ProviderQuote, ProviderFiat, ContinueButtonWrapper } from '../Buy/styles.js';
|
|
18
19
|
import { createCurrencyFormatter, formatTokenAmount } from '../Buy/utils.js';
|
|
@@ -28,6 +29,9 @@ const BuySelectProvider = () => {
|
|
|
28
29
|
const isConnected = wallet.status === 'connected';
|
|
29
30
|
const address = isConnected ? wallet.address : undefined;
|
|
30
31
|
const chainId = isConnected && chainType === ChainTypeEnum.EVM ? wallet.chainId : undefined;
|
|
32
|
+
// The onramp destination network: 'solana' for SVM, else the EVM network (undefined
|
|
33
|
+
// until the EVM chainId resolves, which keeps quote fetching gated as before).
|
|
34
|
+
const network = resolveOnrampNetwork(chainType, chainId);
|
|
31
35
|
const [quotes, setQuotes] = useState({});
|
|
32
36
|
const [isLoadingQuote, setIsLoadingQuote] = useState(false);
|
|
33
37
|
const [coinbaseError, setCoinbaseError] = useState(false);
|
|
@@ -43,7 +47,8 @@ const BuySelectProvider = () => {
|
|
|
43
47
|
return null;
|
|
44
48
|
return numeric;
|
|
45
49
|
}, [buyForm.amount]);
|
|
46
|
-
const { data:
|
|
50
|
+
const { data: ethAssets } = useEthereumWalletAssets();
|
|
51
|
+
const assets = chainType === ChainTypeEnum.SVM ? SOLANA_BUY_CURRENCIES : ethAssets;
|
|
47
52
|
const matchedToken = useMemo(() => assets === null || assets === void 0 ? void 0 : assets.find((asset) => isSameToken(asset, buyForm.asset)), [assets, buyForm.asset]);
|
|
48
53
|
const selectedTokenOption = matchedToken !== null && matchedToken !== void 0 ? matchedToken : assets === null || assets === void 0 ? void 0 : assets[0];
|
|
49
54
|
const selectedToken = selectedTokenOption !== null && selectedTokenOption !== void 0 ? selectedTokenOption : buyForm.asset;
|
|
@@ -77,7 +82,7 @@ const BuySelectProvider = () => {
|
|
|
77
82
|
// Fetch quotes from all providers
|
|
78
83
|
useEffect(() => {
|
|
79
84
|
const fetchQuotes = async () => {
|
|
80
|
-
if (!address || !
|
|
85
|
+
if (!address || !network || !fiatAmount || fiatAmount <= 0) {
|
|
81
86
|
setQuotes({});
|
|
82
87
|
setCoinbaseError(false);
|
|
83
88
|
setStripeError(false);
|
|
@@ -89,7 +94,7 @@ const BuySelectProvider = () => {
|
|
|
89
94
|
try {
|
|
90
95
|
const allQuotes = await getAllQuotes({
|
|
91
96
|
token: selectedToken,
|
|
92
|
-
|
|
97
|
+
network,
|
|
93
98
|
publishableKey,
|
|
94
99
|
sourceAmount: fiatAmount.toFixed(2),
|
|
95
100
|
sourceCurrency: buyForm.currency,
|
|
@@ -120,7 +125,7 @@ const BuySelectProvider = () => {
|
|
|
120
125
|
selectedToken.metadata,
|
|
121
126
|
selectedToken.type,
|
|
122
127
|
buyForm.currency,
|
|
123
|
-
|
|
128
|
+
network,
|
|
124
129
|
address,
|
|
125
130
|
publishableKey,
|
|
126
131
|
refetchTrigger,
|
|
@@ -147,7 +152,7 @@ const BuySelectProvider = () => {
|
|
|
147
152
|
.filter((n) => Number.isFinite(n));
|
|
148
153
|
return amounts.length > 0 ? Math.max(...amounts) : null;
|
|
149
154
|
}, [quotes]);
|
|
150
|
-
return (jsxs(PageContent, { onBack: handleBack, children: [jsx(ModalHeading, { children: "Select Provider" }), jsx(
|
|
155
|
+
return (jsxs(PageContent, { onBack: handleBack, children: [jsx(ModalHeading, { children: "Select Provider" }), jsxs("div", { style: { textAlign: 'center', margin: '6px 0 16px' }, children: [jsx("div", { style: { fontSize: 13, color: 'var(--ck-body-color-muted)' }, children: "You pay" }), jsx("div", { style: { fontSize: 30, fontWeight: 700, lineHeight: 1.1, color: 'var(--ck-body-color)' }, children: formattedFiat || '—' }), targetDestinationAmount !== null && (jsxs("div", { style: { fontSize: 14, fontWeight: 500, color: 'var(--ck-body-color-muted)', marginTop: 4 }, children: ["\u2248 ", targetDestinationAmount.toFixed(2), " ", tokenSymbol] }))] }), jsx(ModalBody, { style: { marginTop: 0, fontSize: '12px', opacity: 0.7 }, children: isLoadingQuote ? 'Loading quotes…' : `Quotes refresh in ${quoteRefreshTimer}s` }), jsx(ProviderList, { children: providers.map((provider) => {
|
|
151
156
|
var _a, _b, _c, _d, _e, _f;
|
|
152
157
|
// Get provider-specific quote data
|
|
153
158
|
const providerQuote = quotes[provider.id];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { ChainTypeEnum } from '@openfort/openfort-js';
|
|
3
|
-
import {
|
|
4
|
-
import { lazy, useEffect, useMemo, useState, Suspense } from 'react';
|
|
3
|
+
import { lazy, useEffect, useMemo, Suspense } from 'react';
|
|
5
4
|
import { formatUnits } from 'viem';
|
|
6
|
-
import { UserRoundIcon, SendIcon, ReceiveIcon
|
|
5
|
+
import { UserRoundIcon, SendIcon, ReceiveIcon } from '../../../assets/icons.js';
|
|
7
6
|
import { useEthereumEmbeddedWallet } from '../../../ethereum/hooks/useEthereumEmbeddedWallet.js';
|
|
8
7
|
import { useEthereumWalletAssets } from '../../../ethereum/hooks/useEthereumWalletAssets.js';
|
|
9
8
|
import { useEthereumBridge } from '../../../ethereum/OpenfortEthereumBridgeContext.js';
|
|
@@ -17,7 +16,6 @@ import Button from '../../Common/Button/index.js';
|
|
|
17
16
|
import { TextLinkButton } from '../../Common/Button/styles.js';
|
|
18
17
|
import Chain from '../../Common/Chain/index.js';
|
|
19
18
|
import { CopyText } from '../../Common/CopyToClipboard/CopyText.js';
|
|
20
|
-
import { ModalBody } from '../../Common/Modal/styles.js';
|
|
21
19
|
import { useThemeContext } from '../../ConnectKitThemeProvider/ConnectKitThemeProvider.js';
|
|
22
20
|
import { routes, defaultSendFormState } from '../../Openfort/types.js';
|
|
23
21
|
import { useOpenfort } from '../../Openfort/useOpenfort.js';
|
|
@@ -32,7 +30,7 @@ function getFirstBalanceAsset(assets) {
|
|
|
32
30
|
return assets === null || assets === void 0 ? void 0 : assets.find((a) => a.balance && a.balance > BigInt(0));
|
|
33
31
|
}
|
|
34
32
|
const EthereumConnected = () => {
|
|
35
|
-
var _a, _b, _c
|
|
33
|
+
var _a, _b, _c;
|
|
36
34
|
const context = useOpenfort();
|
|
37
35
|
const { setHeaderLeftSlot, setRoute, chains } = context;
|
|
38
36
|
const themeContext = useThemeContext();
|
|
@@ -64,7 +62,7 @@ const EthereumConnected = () => {
|
|
|
64
62
|
enabled: isConnected && !!address,
|
|
65
63
|
});
|
|
66
64
|
const ensName = identity.status === 'success' ? identity.name : undefined;
|
|
67
|
-
const { data: assets, isLoading
|
|
65
|
+
const { data: assets, isLoading } = useEthereumWalletAssets();
|
|
68
66
|
const totalBalanceUsd = useMemo(() => {
|
|
69
67
|
if (!assets)
|
|
70
68
|
return 0;
|
|
@@ -79,31 +77,9 @@ const EthereumConnected = () => {
|
|
|
79
77
|
return acc + price * balance;
|
|
80
78
|
}, 0);
|
|
81
79
|
}, [assets]);
|
|
82
|
-
useEffect(() => {
|
|
83
|
-
if (isConnected) {
|
|
84
|
-
refetch();
|
|
85
|
-
}
|
|
86
|
-
}, [isConnected, refetch]);
|
|
87
|
-
const isTestnet = (_b = chain === null || chain === void 0 ? void 0 : chain.testnet) !== null && _b !== void 0 ? _b : false;
|
|
88
|
-
const [showTestnetMessage, setShowTestnetMessage] = useState(false);
|
|
89
80
|
useEffect(() => {
|
|
90
81
|
context.triggerResize();
|
|
91
|
-
|
|
92
|
-
const timer = setTimeout(() => {
|
|
93
|
-
setShowTestnetMessage(false);
|
|
94
|
-
}, 2000);
|
|
95
|
-
return () => clearTimeout(timer);
|
|
96
|
-
}
|
|
97
|
-
}, [showTestnetMessage, context.triggerResize]);
|
|
98
|
-
const handleBuyClick = (e) => {
|
|
99
|
-
if (!chain || isTestnet) {
|
|
100
|
-
e.preventDefault();
|
|
101
|
-
setShowTestnetMessage(true);
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
context.setRoute(routes.BUY);
|
|
105
|
-
}
|
|
106
|
-
};
|
|
82
|
+
}, [context.triggerResize]);
|
|
107
83
|
useEffect(() => {
|
|
108
84
|
if (!address) {
|
|
109
85
|
setHeaderLeftSlot(null);
|
|
@@ -115,11 +91,11 @@ const EthereumConnected = () => {
|
|
|
115
91
|
};
|
|
116
92
|
}, [address, setHeaderLeftSlot, setRoute]);
|
|
117
93
|
const { setSendForm } = context;
|
|
118
|
-
const separator = ['web95', 'rounded', 'minimal'].includes((
|
|
94
|
+
const separator = ['web95', 'rounded', 'minimal'].includes((_c = (_b = themeContext.theme) !== null && _b !== void 0 ? _b : context.uiConfig.theme) !== null && _c !== void 0 ? _c : '')
|
|
119
95
|
? '....'
|
|
120
96
|
: undefined;
|
|
121
97
|
const locales = useLocales();
|
|
122
|
-
const balanceNode =
|
|
98
|
+
const balanceNode = assets && !isLoading ? (jsx(TextLinkButton, { type: "button", onClick: () => {
|
|
123
99
|
const firstBalanceAsset = getFirstBalanceAsset(assets);
|
|
124
100
|
if (!firstBalanceAsset) {
|
|
125
101
|
setRoute(routes.NO_ASSETS_AVAILABLE);
|
|
@@ -136,7 +112,7 @@ const EthereumConnected = () => {
|
|
|
136
112
|
}
|
|
137
113
|
setSendForm({ ...defaultSendFormState, asset: firstBalanceAsset });
|
|
138
114
|
context.setRoute(routes.SEND);
|
|
139
|
-
}, children: "Send" }), jsx(ActionButton, { icon: jsx(ReceiveIcon, {}), onClick: () => context.setRoute(routes.
|
|
115
|
+
}, children: "Send" }), jsx(ActionButton, { icon: jsx(ReceiveIcon, {}), onClick: () => context.setRoute(routes.DEPOSIT), children: "Deposit" })] }), hideBalance: context === null || context === void 0 ? void 0 : context.uiConfig.hideBalance, isBalanceLoading: isLoading, noWalletFallback: noWalletFallback }) }));
|
|
140
116
|
};
|
|
141
117
|
|
|
142
118
|
export { EthereumConnected as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumConnected.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EthereumConnected.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|