@volr/react-ui 0.2.7 → 0.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/dist/index.cjs +402 -275
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +59 -2
- package/dist/index.d.ts +59 -2
- package/dist/index.js +159 -35
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React$1 from 'react';
|
|
2
|
-
import { KeyStorageType, VolrConfig, PayOptions as PayOptions$1, PaymentResult, PaymentHistoryOptions, PaymentHistoryResult } from '@volr/react';
|
|
2
|
+
import { KeyStorageType, VolrConfig, PayOptions as PayOptions$1, PaymentResult, FiatCurrencyInfo, PaymentHistoryOptions, PaymentHistoryResult } from '@volr/react';
|
|
3
3
|
export { EvmChainClient, EvmClient, EvmNamespace, KeyStorageType, OnSignRequest, PaymentHistoryOptions, PaymentHistoryResult, PaymentResult, PaymentStatus, PaymentToken, SendBatchOverloads, SignRequest, SignerType, UseVolrPaymentApiReturn, VolrClient, VolrConfig, VolrProvider, VolrUser, useDepositListener, usePasskeyEnrollment, useVolr, useVolrLogin, useVolrPaymentApi } from '@volr/react';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
5
|
|
|
@@ -213,7 +213,30 @@ declare const en: {
|
|
|
213
213
|
readonly later: "Do it later";
|
|
214
214
|
readonly inProgress: "Setting up...";
|
|
215
215
|
readonly success: "Passkey set up successfully!";
|
|
216
|
+
readonly successTitle: "Migration complete!";
|
|
217
|
+
readonly successMessage: "Your passkey is set up for this site.";
|
|
218
|
+
readonly waitingHint: "Complete the setup in the popup window.";
|
|
216
219
|
readonly error: "Failed to set up passkey. Please try again.";
|
|
220
|
+
readonly source: {
|
|
221
|
+
readonly title: "Verify with existing passkey";
|
|
222
|
+
readonly description: "Verify your identity to move your wallet to {{targetDomain}}.";
|
|
223
|
+
readonly ready: "Ready to verify";
|
|
224
|
+
readonly authenticating: "Verifying...";
|
|
225
|
+
readonly decrypting: "Decrypting wallet data...";
|
|
226
|
+
readonly waiting: "Waiting for registration on the new site...";
|
|
227
|
+
readonly done: "Verification complete!";
|
|
228
|
+
readonly waitingHint: "Complete passkey registration in the new window.";
|
|
229
|
+
};
|
|
230
|
+
readonly target: {
|
|
231
|
+
readonly title: "Register a passkey for this site";
|
|
232
|
+
readonly description: "Register a passkey for secure login on {{currentDomain}}.";
|
|
233
|
+
readonly ready: "Ready to register";
|
|
234
|
+
readonly connecting: "Connecting to the original site...";
|
|
235
|
+
readonly registering: "Registering new passkey...";
|
|
236
|
+
readonly completing: "Finishing setup...";
|
|
237
|
+
readonly success: "Passkey registration complete!";
|
|
238
|
+
readonly closing: "Closing window...";
|
|
239
|
+
};
|
|
217
240
|
};
|
|
218
241
|
};
|
|
219
242
|
readonly success: {
|
|
@@ -476,6 +499,40 @@ declare function useSwitchNetwork(): (chainId: number) => Promise<void>;
|
|
|
476
499
|
*/
|
|
477
500
|
declare function getCurrentChainId(): Promise<number>;
|
|
478
501
|
|
|
502
|
+
interface PreferredCurrencyContextValue {
|
|
503
|
+
/** Current preferred currency code */
|
|
504
|
+
currency: string;
|
|
505
|
+
/** Set preferred currency code */
|
|
506
|
+
setCurrency: (code: string) => void;
|
|
507
|
+
/** List of supported currencies from API */
|
|
508
|
+
supportedCurrencies: FiatCurrencyInfo[];
|
|
509
|
+
/** Loading state for currencies */
|
|
510
|
+
isLoading: boolean;
|
|
511
|
+
/** Format amount in preferred currency */
|
|
512
|
+
formatAmount: (amount: number) => string;
|
|
513
|
+
/** Format amount in specific currency */
|
|
514
|
+
formatInCurrency: (amount: number, currencyCode: string) => string;
|
|
515
|
+
/** Get currency info by code */
|
|
516
|
+
getCurrencyInfo: (code: string) => FiatCurrencyInfo | undefined;
|
|
517
|
+
}
|
|
518
|
+
interface PreferredCurrencyProviderProps {
|
|
519
|
+
children: React$1.ReactNode;
|
|
520
|
+
/** API base URL for fetching currencies */
|
|
521
|
+
apiUrl?: string;
|
|
522
|
+
/** Default currency if none stored */
|
|
523
|
+
defaultCurrency?: string;
|
|
524
|
+
}
|
|
525
|
+
declare function PreferredCurrencyProvider({ children, apiUrl, defaultCurrency, }: PreferredCurrencyProviderProps): react_jsx_runtime.JSX.Element;
|
|
526
|
+
/**
|
|
527
|
+
* Hook to access preferred currency context
|
|
528
|
+
* @throws Error if used outside PreferredCurrencyProvider
|
|
529
|
+
*/
|
|
530
|
+
declare function usePreferredCurrency(): PreferredCurrencyContextValue;
|
|
531
|
+
/**
|
|
532
|
+
* Optional hook that returns null if outside provider
|
|
533
|
+
*/
|
|
534
|
+
declare function usePreferredCurrencyOptional(): PreferredCurrencyContextValue | null;
|
|
535
|
+
|
|
479
536
|
/**
|
|
480
537
|
* useVolrPay hook - Payment with UI integration
|
|
481
538
|
*
|
|
@@ -575,4 +632,4 @@ interface UseVolrPayReturn {
|
|
|
575
632
|
}
|
|
576
633
|
declare function useVolrPay(): UseVolrPayReturn;
|
|
577
634
|
|
|
578
|
-
export { I18nContext, type I18nContextValue, I18nProvider, type I18nProviderProps, type Locale, MpcConnectView, type MpcConnectViewProps, type NetworkWalletConfig, PasskeyEnrollView, type PasskeyEnrollViewProps, type PayOptions, type PaymentError, type PaymentHandle, type PaymentHandlers, type PaymentItem, type Translations, type UseVolrPayReturn, type VolrTheme, type VolrUIConfig, VolrUIProvider, type VolrUIProviderProps, getCurrentChainId, useI18n, useSwitchNetwork, useTranslation, useVolrModal, useVolrPay, useVolrUI, useVolrUIOptional };
|
|
635
|
+
export { I18nContext, type I18nContextValue, I18nProvider, type I18nProviderProps, type Locale, MpcConnectView, type MpcConnectViewProps, type NetworkWalletConfig, PasskeyEnrollView, type PasskeyEnrollViewProps, type PayOptions, type PaymentError, type PaymentHandle, type PaymentHandlers, type PaymentItem, PreferredCurrencyProvider, type Translations, type UseVolrPayReturn, type VolrTheme, type VolrUIConfig, VolrUIProvider, type VolrUIProviderProps, getCurrentChainId, useI18n, usePreferredCurrency, usePreferredCurrencyOptional, useSwitchNetwork, useTranslation, useVolrModal, useVolrPay, useVolrUI, useVolrUIOptional };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React$1 from 'react';
|
|
2
|
-
import { KeyStorageType, VolrConfig, PayOptions as PayOptions$1, PaymentResult, PaymentHistoryOptions, PaymentHistoryResult } from '@volr/react';
|
|
2
|
+
import { KeyStorageType, VolrConfig, PayOptions as PayOptions$1, PaymentResult, FiatCurrencyInfo, PaymentHistoryOptions, PaymentHistoryResult } from '@volr/react';
|
|
3
3
|
export { EvmChainClient, EvmClient, EvmNamespace, KeyStorageType, OnSignRequest, PaymentHistoryOptions, PaymentHistoryResult, PaymentResult, PaymentStatus, PaymentToken, SendBatchOverloads, SignRequest, SignerType, UseVolrPaymentApiReturn, VolrClient, VolrConfig, VolrProvider, VolrUser, useDepositListener, usePasskeyEnrollment, useVolr, useVolrLogin, useVolrPaymentApi } from '@volr/react';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
5
|
|
|
@@ -213,7 +213,30 @@ declare const en: {
|
|
|
213
213
|
readonly later: "Do it later";
|
|
214
214
|
readonly inProgress: "Setting up...";
|
|
215
215
|
readonly success: "Passkey set up successfully!";
|
|
216
|
+
readonly successTitle: "Migration complete!";
|
|
217
|
+
readonly successMessage: "Your passkey is set up for this site.";
|
|
218
|
+
readonly waitingHint: "Complete the setup in the popup window.";
|
|
216
219
|
readonly error: "Failed to set up passkey. Please try again.";
|
|
220
|
+
readonly source: {
|
|
221
|
+
readonly title: "Verify with existing passkey";
|
|
222
|
+
readonly description: "Verify your identity to move your wallet to {{targetDomain}}.";
|
|
223
|
+
readonly ready: "Ready to verify";
|
|
224
|
+
readonly authenticating: "Verifying...";
|
|
225
|
+
readonly decrypting: "Decrypting wallet data...";
|
|
226
|
+
readonly waiting: "Waiting for registration on the new site...";
|
|
227
|
+
readonly done: "Verification complete!";
|
|
228
|
+
readonly waitingHint: "Complete passkey registration in the new window.";
|
|
229
|
+
};
|
|
230
|
+
readonly target: {
|
|
231
|
+
readonly title: "Register a passkey for this site";
|
|
232
|
+
readonly description: "Register a passkey for secure login on {{currentDomain}}.";
|
|
233
|
+
readonly ready: "Ready to register";
|
|
234
|
+
readonly connecting: "Connecting to the original site...";
|
|
235
|
+
readonly registering: "Registering new passkey...";
|
|
236
|
+
readonly completing: "Finishing setup...";
|
|
237
|
+
readonly success: "Passkey registration complete!";
|
|
238
|
+
readonly closing: "Closing window...";
|
|
239
|
+
};
|
|
217
240
|
};
|
|
218
241
|
};
|
|
219
242
|
readonly success: {
|
|
@@ -476,6 +499,40 @@ declare function useSwitchNetwork(): (chainId: number) => Promise<void>;
|
|
|
476
499
|
*/
|
|
477
500
|
declare function getCurrentChainId(): Promise<number>;
|
|
478
501
|
|
|
502
|
+
interface PreferredCurrencyContextValue {
|
|
503
|
+
/** Current preferred currency code */
|
|
504
|
+
currency: string;
|
|
505
|
+
/** Set preferred currency code */
|
|
506
|
+
setCurrency: (code: string) => void;
|
|
507
|
+
/** List of supported currencies from API */
|
|
508
|
+
supportedCurrencies: FiatCurrencyInfo[];
|
|
509
|
+
/** Loading state for currencies */
|
|
510
|
+
isLoading: boolean;
|
|
511
|
+
/** Format amount in preferred currency */
|
|
512
|
+
formatAmount: (amount: number) => string;
|
|
513
|
+
/** Format amount in specific currency */
|
|
514
|
+
formatInCurrency: (amount: number, currencyCode: string) => string;
|
|
515
|
+
/** Get currency info by code */
|
|
516
|
+
getCurrencyInfo: (code: string) => FiatCurrencyInfo | undefined;
|
|
517
|
+
}
|
|
518
|
+
interface PreferredCurrencyProviderProps {
|
|
519
|
+
children: React$1.ReactNode;
|
|
520
|
+
/** API base URL for fetching currencies */
|
|
521
|
+
apiUrl?: string;
|
|
522
|
+
/** Default currency if none stored */
|
|
523
|
+
defaultCurrency?: string;
|
|
524
|
+
}
|
|
525
|
+
declare function PreferredCurrencyProvider({ children, apiUrl, defaultCurrency, }: PreferredCurrencyProviderProps): react_jsx_runtime.JSX.Element;
|
|
526
|
+
/**
|
|
527
|
+
* Hook to access preferred currency context
|
|
528
|
+
* @throws Error if used outside PreferredCurrencyProvider
|
|
529
|
+
*/
|
|
530
|
+
declare function usePreferredCurrency(): PreferredCurrencyContextValue;
|
|
531
|
+
/**
|
|
532
|
+
* Optional hook that returns null if outside provider
|
|
533
|
+
*/
|
|
534
|
+
declare function usePreferredCurrencyOptional(): PreferredCurrencyContextValue | null;
|
|
535
|
+
|
|
479
536
|
/**
|
|
480
537
|
* useVolrPay hook - Payment with UI integration
|
|
481
538
|
*
|
|
@@ -575,4 +632,4 @@ interface UseVolrPayReturn {
|
|
|
575
632
|
}
|
|
576
633
|
declare function useVolrPay(): UseVolrPayReturn;
|
|
577
634
|
|
|
578
|
-
export { I18nContext, type I18nContextValue, I18nProvider, type I18nProviderProps, type Locale, MpcConnectView, type MpcConnectViewProps, type NetworkWalletConfig, PasskeyEnrollView, type PasskeyEnrollViewProps, type PayOptions, type PaymentError, type PaymentHandle, type PaymentHandlers, type PaymentItem, type Translations, type UseVolrPayReturn, type VolrTheme, type VolrUIConfig, VolrUIProvider, type VolrUIProviderProps, getCurrentChainId, useI18n, useSwitchNetwork, useTranslation, useVolrModal, useVolrPay, useVolrUI, useVolrUIOptional };
|
|
635
|
+
export { I18nContext, type I18nContextValue, I18nProvider, type I18nProviderProps, type Locale, MpcConnectView, type MpcConnectViewProps, type NetworkWalletConfig, PasskeyEnrollView, type PasskeyEnrollViewProps, type PayOptions, type PaymentError, type PaymentHandle, type PaymentHandlers, type PaymentItem, PreferredCurrencyProvider, type Translations, type UseVolrPayReturn, type VolrTheme, type VolrUIConfig, VolrUIProvider, type VolrUIProviderProps, getCurrentChainId, useI18n, usePreferredCurrency, usePreferredCurrencyOptional, useSwitchNetwork, useTranslation, useVolrModal, useVolrPay, useVolrUI, useVolrUIOptional };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React16, { createContext, useContext, useState, useCallback, useEffect, useMemo, useRef, useId, useReducer } from 'react';
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
|
-
import { useVolrContext, useInternalAuth, usePasskeyEnrollment, checkPrfCompatibility, getPlatformHint, useMpcConnection, VolrProvider, useVolrAuthCallback, useVolrPaymentApi, completeMigration, requestMigration, decryptEntropyForMigration, listenForSeedRequests, useUserBalances, useVolrLogin, useVolr, useEIP6963, useWithdraw, useDepositListener, createGetNetworkInfo } from '@volr/react';
|
|
3
|
+
import { useVolrContext, useInternalAuth, usePasskeyEnrollment, checkPrfCompatibility, getPlatformHint, useMpcConnection, detectPreferredCurrency, formatCurrency, VolrProvider, useVolrAuthCallback, useVolrPaymentApi, completeMigration, requestMigration, decryptEntropyForMigration, listenForSeedRequests, useUserBalances, useVolrLogin, useVolr, useEIP6963, useWithdraw, useDepositListener, createGetNetworkInfo } from '@volr/react';
|
|
4
4
|
export { VolrProvider, useDepositListener, usePasskeyEnrollment, useVolr, useVolrLogin, useVolrPaymentApi } from '@volr/react';
|
|
5
5
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
6
6
|
import { clsx } from 'clsx';
|
|
@@ -587,7 +587,32 @@ var en = {
|
|
|
587
587
|
later: "Do it later",
|
|
588
588
|
inProgress: "Setting up...",
|
|
589
589
|
success: "Passkey set up successfully!",
|
|
590
|
-
|
|
590
|
+
successTitle: "Migration complete!",
|
|
591
|
+
successMessage: "Your passkey is set up for this site.",
|
|
592
|
+
waitingHint: "Complete the setup in the popup window.",
|
|
593
|
+
error: "Failed to set up passkey. Please try again.",
|
|
594
|
+
// Source popup (domain-a.com)
|
|
595
|
+
source: {
|
|
596
|
+
title: "Verify with existing passkey",
|
|
597
|
+
description: "Verify your identity to move your wallet to {{targetDomain}}.",
|
|
598
|
+
ready: "Ready to verify",
|
|
599
|
+
authenticating: "Verifying...",
|
|
600
|
+
decrypting: "Decrypting wallet data...",
|
|
601
|
+
waiting: "Waiting for registration on the new site...",
|
|
602
|
+
done: "Verification complete!",
|
|
603
|
+
waitingHint: "Complete passkey registration in the new window."
|
|
604
|
+
},
|
|
605
|
+
// Target popup (domain-b.com)
|
|
606
|
+
target: {
|
|
607
|
+
title: "Register a passkey for this site",
|
|
608
|
+
description: "Register a passkey for secure login on {{currentDomain}}.",
|
|
609
|
+
ready: "Ready to register",
|
|
610
|
+
connecting: "Connecting to the original site...",
|
|
611
|
+
registering: "Registering new passkey...",
|
|
612
|
+
completing: "Finishing setup...",
|
|
613
|
+
success: "Passkey registration complete!",
|
|
614
|
+
closing: "Closing window..."
|
|
615
|
+
}
|
|
591
616
|
}
|
|
592
617
|
},
|
|
593
618
|
success: {
|
|
@@ -1941,7 +1966,7 @@ var variantMap = {
|
|
|
1941
1966
|
ghost: { backgroundColor: "transparent", color: "var(--volr-text-secondary)", border: "none" },
|
|
1942
1967
|
outline: { backgroundColor: "transparent", color: "var(--volr-text-secondary)", border: "1px solid var(--volr-border)" }
|
|
1943
1968
|
};
|
|
1944
|
-
var Button =
|
|
1969
|
+
var Button = React16.forwardRef(
|
|
1945
1970
|
({ variant = "primary", size = "md", fullWidth, className, style, disabled, children, ...props }, ref) => {
|
|
1946
1971
|
const { accentColor } = useVolrUI();
|
|
1947
1972
|
const sizeStyle = sizeMap[size];
|
|
@@ -3785,7 +3810,7 @@ function AssetSelectView({
|
|
|
3785
3810
|
}) })
|
|
3786
3811
|
] });
|
|
3787
3812
|
}
|
|
3788
|
-
var TextLinkButton =
|
|
3813
|
+
var TextLinkButton = React16.forwardRef(({ showArrow = false, className, children, ...props }, ref) => {
|
|
3789
3814
|
return /* @__PURE__ */ jsxs(
|
|
3790
3815
|
"button",
|
|
3791
3816
|
{
|
|
@@ -4853,6 +4878,111 @@ function DepositModalBody({
|
|
|
4853
4878
|
}
|
|
4854
4879
|
);
|
|
4855
4880
|
}
|
|
4881
|
+
var STORAGE_KEY = "volr:preferred-currency";
|
|
4882
|
+
var PreferredCurrencyContext = createContext(null);
|
|
4883
|
+
function PreferredCurrencyProvider({
|
|
4884
|
+
children,
|
|
4885
|
+
apiUrl,
|
|
4886
|
+
defaultCurrency
|
|
4887
|
+
}) {
|
|
4888
|
+
const [currency, setCurrencyState] = useState(() => {
|
|
4889
|
+
if (typeof window !== "undefined") {
|
|
4890
|
+
const stored = localStorage.getItem(STORAGE_KEY);
|
|
4891
|
+
if (stored) return stored;
|
|
4892
|
+
}
|
|
4893
|
+
return defaultCurrency || detectPreferredCurrency();
|
|
4894
|
+
});
|
|
4895
|
+
const [supportedCurrencies, setSupportedCurrencies] = useState([]);
|
|
4896
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
4897
|
+
useEffect(() => {
|
|
4898
|
+
const fetchCurrencies = async () => {
|
|
4899
|
+
if (!apiUrl) {
|
|
4900
|
+
setSupportedCurrencies([
|
|
4901
|
+
{ code: "USD", symbol: "$", name: "US Dollar", decimalPlaces: 2 },
|
|
4902
|
+
{ code: "KRW", symbol: "\u20A9", name: "Korean Won", decimalPlaces: 0 },
|
|
4903
|
+
{ code: "EUR", symbol: "\u20AC", name: "Euro", decimalPlaces: 2 }
|
|
4904
|
+
]);
|
|
4905
|
+
setIsLoading(false);
|
|
4906
|
+
return;
|
|
4907
|
+
}
|
|
4908
|
+
try {
|
|
4909
|
+
const response = await fetch(`${apiUrl}/public/fiat-currencies`);
|
|
4910
|
+
if (!response.ok) throw new Error("Failed to fetch currencies");
|
|
4911
|
+
const data = await response.json();
|
|
4912
|
+
if (data.ok && Array.isArray(data.data)) {
|
|
4913
|
+
setSupportedCurrencies(data.data);
|
|
4914
|
+
const currentSupported = data.data.some(
|
|
4915
|
+
(c) => c.code === currency
|
|
4916
|
+
);
|
|
4917
|
+
if (!currentSupported && data.data.length > 0) {
|
|
4918
|
+
const detected = detectPreferredCurrency();
|
|
4919
|
+
const detectedSupported = data.data.find(
|
|
4920
|
+
(c) => c.code === detected
|
|
4921
|
+
);
|
|
4922
|
+
setCurrencyState(detectedSupported?.code || data.data[0].code);
|
|
4923
|
+
}
|
|
4924
|
+
}
|
|
4925
|
+
} catch (error) {
|
|
4926
|
+
console.warn("[PreferredCurrencyProvider] Failed to fetch currencies:", error);
|
|
4927
|
+
setSupportedCurrencies([
|
|
4928
|
+
{ code: "USD", symbol: "$", name: "US Dollar", decimalPlaces: 2 },
|
|
4929
|
+
{ code: "KRW", symbol: "\u20A9", name: "Korean Won", decimalPlaces: 0 },
|
|
4930
|
+
{ code: "EUR", symbol: "\u20AC", name: "Euro", decimalPlaces: 2 }
|
|
4931
|
+
]);
|
|
4932
|
+
} finally {
|
|
4933
|
+
setIsLoading(false);
|
|
4934
|
+
}
|
|
4935
|
+
};
|
|
4936
|
+
fetchCurrencies();
|
|
4937
|
+
}, [apiUrl, currency]);
|
|
4938
|
+
const setCurrency = useCallback((code) => {
|
|
4939
|
+
const normalizedCode = code.toUpperCase();
|
|
4940
|
+
setCurrencyState(normalizedCode);
|
|
4941
|
+
if (typeof window !== "undefined") {
|
|
4942
|
+
localStorage.setItem(STORAGE_KEY, normalizedCode);
|
|
4943
|
+
}
|
|
4944
|
+
}, []);
|
|
4945
|
+
const formatAmount = useCallback(
|
|
4946
|
+
(amount) => {
|
|
4947
|
+
return formatCurrency(amount, currency);
|
|
4948
|
+
},
|
|
4949
|
+
[currency]
|
|
4950
|
+
);
|
|
4951
|
+
const formatInCurrency = useCallback((amount, currencyCode) => {
|
|
4952
|
+
return formatCurrency(amount, currencyCode);
|
|
4953
|
+
}, []);
|
|
4954
|
+
const getCurrencyInfo = useCallback(
|
|
4955
|
+
(code) => {
|
|
4956
|
+
return supportedCurrencies.find((c) => c.code === code.toUpperCase());
|
|
4957
|
+
},
|
|
4958
|
+
[supportedCurrencies]
|
|
4959
|
+
);
|
|
4960
|
+
return /* @__PURE__ */ jsx(
|
|
4961
|
+
PreferredCurrencyContext.Provider,
|
|
4962
|
+
{
|
|
4963
|
+
value: {
|
|
4964
|
+
currency,
|
|
4965
|
+
setCurrency,
|
|
4966
|
+
supportedCurrencies,
|
|
4967
|
+
isLoading,
|
|
4968
|
+
formatAmount,
|
|
4969
|
+
formatInCurrency,
|
|
4970
|
+
getCurrencyInfo
|
|
4971
|
+
},
|
|
4972
|
+
children
|
|
4973
|
+
}
|
|
4974
|
+
);
|
|
4975
|
+
}
|
|
4976
|
+
function usePreferredCurrency() {
|
|
4977
|
+
const context = useContext(PreferredCurrencyContext);
|
|
4978
|
+
if (!context) {
|
|
4979
|
+
throw new Error("usePreferredCurrency must be used within PreferredCurrencyProvider");
|
|
4980
|
+
}
|
|
4981
|
+
return context;
|
|
4982
|
+
}
|
|
4983
|
+
function usePreferredCurrencyOptional() {
|
|
4984
|
+
return useContext(PreferredCurrencyContext);
|
|
4985
|
+
}
|
|
4856
4986
|
function DepositIcon() {
|
|
4857
4987
|
return /* @__PURE__ */ jsx("svg", { className: "volr:w-5 volr:h-5 volr:text-slate-800", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx(
|
|
4858
4988
|
"path",
|
|
@@ -4908,12 +5038,8 @@ function AccountMainView({
|
|
|
4908
5038
|
isRefreshing
|
|
4909
5039
|
}) {
|
|
4910
5040
|
const { t } = useI18n();
|
|
4911
|
-
const
|
|
4912
|
-
|
|
4913
|
-
currency: "USD",
|
|
4914
|
-
minimumFractionDigits: 2,
|
|
4915
|
-
maximumFractionDigits: 2
|
|
4916
|
-
});
|
|
5041
|
+
const currencyCtx = usePreferredCurrencyOptional();
|
|
5042
|
+
const formattedUsd = isLoading ? "\u2014" : currencyCtx ? currencyCtx.formatAmount(totalUsd) : formatCurrency(totalUsd, "USD");
|
|
4917
5043
|
const lastUpdatedLabel = lastUpdatedAt ? lastUpdatedAt.toLocaleTimeString(void 0, {
|
|
4918
5044
|
hour: "2-digit",
|
|
4919
5045
|
minute: "2-digit"
|
|
@@ -5006,6 +5132,8 @@ function AccountMainView({
|
|
|
5006
5132
|
] });
|
|
5007
5133
|
}
|
|
5008
5134
|
function TokenRow({ token }) {
|
|
5135
|
+
const currencyCtx = usePreferredCurrencyOptional();
|
|
5136
|
+
const formattedBalanceUsd = token.balanceUsd !== void 0 && token.balanceUsd > 0 ? currencyCtx ? currencyCtx.formatAmount(token.balanceUsd) : formatCurrency(token.balanceUsd, "USD") : null;
|
|
5009
5137
|
return /* @__PURE__ */ jsxs("div", { className: "volr:flex volr:items-center volr:justify-between volr:py-3 volr:border-b volr:border-slate-100 last:volr:border-b-0", children: [
|
|
5010
5138
|
/* @__PURE__ */ jsxs("div", { className: "volr:flex volr:items-center volr:gap-3", children: [
|
|
5011
5139
|
/* @__PURE__ */ jsx("div", { className: "volr:w-8 volr:h-8 volr:rounded-full volr:bg-slate-100 volr:flex volr:items-center volr:justify-center volr:overflow-hidden volr:shrink-0", children: token.iconUrl ? /* @__PURE__ */ jsx(
|
|
@@ -5026,10 +5154,7 @@ function TokenRow({ token }) {
|
|
|
5026
5154
|
] }),
|
|
5027
5155
|
/* @__PURE__ */ jsx("div", { className: "volr:text-right", children: token.isLoading ? /* @__PURE__ */ jsx("div", { className: "volr:animate-pulse", children: /* @__PURE__ */ jsx("div", { className: "volr:h-4 volr:w-16 volr:bg-slate-200 volr:rounded" }) }) : token.error ? /* @__PURE__ */ jsx("p", { className: "volr:text-xs volr:text-red-500", children: "Error" }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5028
5156
|
/* @__PURE__ */ jsx("p", { className: "volr:text-sm volr:font-medium volr:text-slate-900", children: token.balance }),
|
|
5029
|
-
|
|
5030
|
-
"$",
|
|
5031
|
-
token.balanceUsd.toFixed(2)
|
|
5032
|
-
] })
|
|
5157
|
+
formattedBalanceUsd && /* @__PURE__ */ jsx("p", { className: "volr:text-xs volr:text-slate-400", children: formattedBalanceUsd })
|
|
5033
5158
|
] }) })
|
|
5034
5159
|
] });
|
|
5035
5160
|
}
|
|
@@ -5056,7 +5181,7 @@ function BalanceDetailView({
|
|
|
5056
5181
|
/* @__PURE__ */ jsx("div", { children: balances.map((token) => /* @__PURE__ */ jsx(TokenRow, { token }, token.id)) })
|
|
5057
5182
|
] });
|
|
5058
5183
|
}
|
|
5059
|
-
var Input =
|
|
5184
|
+
var Input = React16.forwardRef(
|
|
5060
5185
|
({ leftIcon, error, className, style, disabled, ...props }, ref) => {
|
|
5061
5186
|
return /* @__PURE__ */ jsxs("div", { className: "volr:relative", children: [
|
|
5062
5187
|
leftIcon && /* @__PURE__ */ jsx("div", { className: "volr:absolute volr:left-3 volr:top-1/2 volr:-translate-y-1/2 volr:pointer-events-none volr-text-muted", children: leftIcon }),
|
|
@@ -5444,6 +5569,7 @@ function ChevronRightIcon({ className }) {
|
|
|
5444
5569
|
}
|
|
5445
5570
|
function PaymentRow({ payment, onClick }) {
|
|
5446
5571
|
const { t } = useI18n();
|
|
5572
|
+
const currencyCtx = usePreferredCurrencyOptional();
|
|
5447
5573
|
const date = new Date(payment.createdAt);
|
|
5448
5574
|
const formattedDate = date.toLocaleDateString(void 0, {
|
|
5449
5575
|
month: "short",
|
|
@@ -5458,6 +5584,7 @@ function PaymentRow({ payment, onClick }) {
|
|
|
5458
5584
|
CANCELLED: "volr:bg-slate-100 volr:text-slate-500",
|
|
5459
5585
|
EXPIRED: "volr:bg-slate-100 volr:text-slate-500"
|
|
5460
5586
|
};
|
|
5587
|
+
const formattedUsd = payment.totalUsd ? currencyCtx ? currencyCtx.formatAmount(parseFloat(payment.totalUsd)) : formatCurrency(parseFloat(payment.totalUsd), "USD") : null;
|
|
5461
5588
|
return /* @__PURE__ */ jsxs(
|
|
5462
5589
|
"button",
|
|
5463
5590
|
{
|
|
@@ -5485,10 +5612,7 @@ function PaymentRow({ payment, onClick }) {
|
|
|
5485
5612
|
" ",
|
|
5486
5613
|
payment.token.symbol
|
|
5487
5614
|
] }),
|
|
5488
|
-
|
|
5489
|
-
"$",
|
|
5490
|
-
parseFloat(payment.totalUsd).toFixed(2)
|
|
5491
|
-
] })
|
|
5615
|
+
formattedUsd && /* @__PURE__ */ jsx("p", { className: "volr:text-xs volr:text-slate-400", children: formattedUsd })
|
|
5492
5616
|
] }),
|
|
5493
5617
|
/* @__PURE__ */ jsx(ChevronRightIcon, { className: "volr:w-4 volr:h-4 volr:text-slate-300" })
|
|
5494
5618
|
] })
|
|
@@ -5558,6 +5682,8 @@ function DetailRow({ label, value, copyable, mono, copyText }) {
|
|
|
5558
5682
|
}
|
|
5559
5683
|
function PaymentDetailView({ payment }) {
|
|
5560
5684
|
const { t } = useI18n();
|
|
5685
|
+
const currencyCtx = usePreferredCurrencyOptional();
|
|
5686
|
+
const formattedUsd = payment.totalUsd ? currencyCtx ? currencyCtx.formatAmount(parseFloat(payment.totalUsd)) : formatCurrency(parseFloat(payment.totalUsd), "USD") : null;
|
|
5561
5687
|
const createdDate = new Date(payment.createdAt);
|
|
5562
5688
|
const formattedCreatedAt = createdDate.toLocaleString(void 0, {
|
|
5563
5689
|
year: "numeric",
|
|
@@ -5606,10 +5732,9 @@ function PaymentDetailView({ payment }) {
|
|
|
5606
5732
|
" ",
|
|
5607
5733
|
payment.token.symbol
|
|
5608
5734
|
] }),
|
|
5609
|
-
|
|
5610
|
-
"\u2248
|
|
5611
|
-
|
|
5612
|
-
" USD"
|
|
5735
|
+
formattedUsd && /* @__PURE__ */ jsxs("p", { className: "volr:text-sm volr:text-slate-500", children: [
|
|
5736
|
+
"\u2248 ",
|
|
5737
|
+
formattedUsd
|
|
5613
5738
|
] })
|
|
5614
5739
|
] }),
|
|
5615
5740
|
/* @__PURE__ */ jsxs("div", { className: "volr:space-y-1", children: [
|
|
@@ -7185,9 +7310,11 @@ var PaymentResultView = ({
|
|
|
7185
7310
|
onReport
|
|
7186
7311
|
}) => {
|
|
7187
7312
|
const { t } = useI18n();
|
|
7313
|
+
const currencyCtx = usePreferredCurrencyOptional();
|
|
7188
7314
|
const isSuccess = payment.status === "CONFIRMED";
|
|
7189
7315
|
payment.status === "FAILED" || !!error;
|
|
7190
7316
|
const isInAppBrowserError = error?.code === "INAPP_BROWSER_NOT_SUPPORTED";
|
|
7317
|
+
const formattedUsd = payment.totalUsd ? currencyCtx ? currencyCtx.formatAmount(parseFloat(payment.totalUsd)) : formatCurrency(parseFloat(payment.totalUsd), "USD") : null;
|
|
7191
7318
|
const handleOpenExternalBrowser = () => {
|
|
7192
7319
|
if (typeof window === "undefined") return;
|
|
7193
7320
|
window.open(window.location.href, "_system");
|
|
@@ -7241,12 +7368,9 @@ var PaymentResultView = ({
|
|
|
7241
7368
|
payment.token.symbol
|
|
7242
7369
|
] })
|
|
7243
7370
|
] }),
|
|
7244
|
-
|
|
7371
|
+
formattedUsd && /* @__PURE__ */ jsxs("div", { className: "volr:flex volr:justify-between volr:text-sm", children: [
|
|
7245
7372
|
/* @__PURE__ */ jsx("span", { className: "volr:text-slate-500", children: t("payment.result.usdValueLabel") }),
|
|
7246
|
-
/* @__PURE__ */
|
|
7247
|
-
"$",
|
|
7248
|
-
parseFloat(payment.totalUsd).toFixed(2)
|
|
7249
|
-
] })
|
|
7373
|
+
/* @__PURE__ */ jsx("span", { className: "volr:text-slate-600", children: formattedUsd })
|
|
7250
7374
|
] }),
|
|
7251
7375
|
/* @__PURE__ */ jsxs("div", { className: "volr:flex volr:justify-between volr:text-sm", children: [
|
|
7252
7376
|
/* @__PURE__ */ jsx("span", { className: "volr:text-slate-500", children: t("payment.result.transactionLabel") }),
|
|
@@ -7463,8 +7587,8 @@ var PaymentModal = ({
|
|
|
7463
7587
|
const resolvedPermitType = selectedToken?.permitType ?? (selectedToken?.permitSupported ? "EIP2612" : "NONE");
|
|
7464
7588
|
const externalWalletTokenSupported = selectedToken && selectedToken.address !== "native" && resolvedPermitType === "EIP2612";
|
|
7465
7589
|
const showExternalWalletOption = externalWalletAllowed && externalWalletTokenSupported;
|
|
7466
|
-
const permit2WarnedRef =
|
|
7467
|
-
|
|
7590
|
+
const permit2WarnedRef = React16.useRef(false);
|
|
7591
|
+
React16.useEffect(() => {
|
|
7468
7592
|
if (!permit2WarnedRef.current && externalWalletAllowed && resolvedPermitType === "PERMIT2" && !selectedToken?.permit2Address) {
|
|
7469
7593
|
console.warn(
|
|
7470
7594
|
`[volr/react-ui] External wallet payment hidden: permit2Address is not configured for chain ${selectedToken?.chainId}.`
|
|
@@ -7946,7 +8070,7 @@ function WalletRequiredModal() {
|
|
|
7946
8070
|
}
|
|
7947
8071
|
);
|
|
7948
8072
|
}
|
|
7949
|
-
var VolrUIContext =
|
|
8073
|
+
var VolrUIContext = React16.createContext(null);
|
|
7950
8074
|
function getCurrentRpId() {
|
|
7951
8075
|
if (typeof window === "undefined") return "localhost";
|
|
7952
8076
|
return window.location.hostname;
|
|
@@ -8574,8 +8698,8 @@ function OnboardingChecker({
|
|
|
8574
8698
|
}) {
|
|
8575
8699
|
const { user, provider, isLoading } = useVolrContext();
|
|
8576
8700
|
const { isOpen: isModalOpen } = useVolrModal();
|
|
8577
|
-
const modalWasOpened =
|
|
8578
|
-
const pendingMismatchOnboarding =
|
|
8701
|
+
const modalWasOpened = React16.useRef(false);
|
|
8702
|
+
const pendingMismatchOnboarding = React16.useRef(false);
|
|
8579
8703
|
useEffect(() => {
|
|
8580
8704
|
if (isModalOpen) {
|
|
8581
8705
|
modalWasOpened.current = true;
|
|
@@ -8773,6 +8897,6 @@ function useVolrPay() {
|
|
|
8773
8897
|
};
|
|
8774
8898
|
}
|
|
8775
8899
|
|
|
8776
|
-
export { I18nContext, I18nProvider, MpcConnectView, PasskeyEnrollView, VolrUIProvider, getCurrentChainId, useI18n, useSwitchNetwork, useTranslation, useVolrModal, useVolrPay, useVolrUI, useVolrUIOptional };
|
|
8900
|
+
export { I18nContext, I18nProvider, MpcConnectView, PasskeyEnrollView, PreferredCurrencyProvider, VolrUIProvider, getCurrentChainId, useI18n, usePreferredCurrency, usePreferredCurrencyOptional, useSwitchNetwork, useTranslation, useVolrModal, useVolrPay, useVolrUI, useVolrUIOptional };
|
|
8777
8901
|
//# sourceMappingURL=index.js.map
|
|
8778
8902
|
//# sourceMappingURL=index.js.map
|