@volr/react-ui 0.2.8 → 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 +376 -274
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -2
- package/dist/index.d.ts +36 -2
- package/dist/index.js +133 -34
- 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
|
|
|
@@ -499,6 +499,40 @@ declare function useSwitchNetwork(): (chainId: number) => Promise<void>;
|
|
|
499
499
|
*/
|
|
500
500
|
declare function getCurrentChainId(): Promise<number>;
|
|
501
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
|
+
|
|
502
536
|
/**
|
|
503
537
|
* useVolrPay hook - Payment with UI integration
|
|
504
538
|
*
|
|
@@ -598,4 +632,4 @@ interface UseVolrPayReturn {
|
|
|
598
632
|
}
|
|
599
633
|
declare function useVolrPay(): UseVolrPayReturn;
|
|
600
634
|
|
|
601
|
-
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
|
|
|
@@ -499,6 +499,40 @@ declare function useSwitchNetwork(): (chainId: number) => Promise<void>;
|
|
|
499
499
|
*/
|
|
500
500
|
declare function getCurrentChainId(): Promise<number>;
|
|
501
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
|
+
|
|
502
536
|
/**
|
|
503
537
|
* useVolrPay hook - Payment with UI integration
|
|
504
538
|
*
|
|
@@ -598,4 +632,4 @@ interface UseVolrPayReturn {
|
|
|
598
632
|
}
|
|
599
633
|
declare function useVolrPay(): UseVolrPayReturn;
|
|
600
634
|
|
|
601
|
-
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';
|
|
@@ -1966,7 +1966,7 @@ var variantMap = {
|
|
|
1966
1966
|
ghost: { backgroundColor: "transparent", color: "var(--volr-text-secondary)", border: "none" },
|
|
1967
1967
|
outline: { backgroundColor: "transparent", color: "var(--volr-text-secondary)", border: "1px solid var(--volr-border)" }
|
|
1968
1968
|
};
|
|
1969
|
-
var Button =
|
|
1969
|
+
var Button = React16.forwardRef(
|
|
1970
1970
|
({ variant = "primary", size = "md", fullWidth, className, style, disabled, children, ...props }, ref) => {
|
|
1971
1971
|
const { accentColor } = useVolrUI();
|
|
1972
1972
|
const sizeStyle = sizeMap[size];
|
|
@@ -3810,7 +3810,7 @@ function AssetSelectView({
|
|
|
3810
3810
|
}) })
|
|
3811
3811
|
] });
|
|
3812
3812
|
}
|
|
3813
|
-
var TextLinkButton =
|
|
3813
|
+
var TextLinkButton = React16.forwardRef(({ showArrow = false, className, children, ...props }, ref) => {
|
|
3814
3814
|
return /* @__PURE__ */ jsxs(
|
|
3815
3815
|
"button",
|
|
3816
3816
|
{
|
|
@@ -4878,6 +4878,111 @@ function DepositModalBody({
|
|
|
4878
4878
|
}
|
|
4879
4879
|
);
|
|
4880
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
|
+
}
|
|
4881
4986
|
function DepositIcon() {
|
|
4882
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(
|
|
4883
4988
|
"path",
|
|
@@ -4933,12 +5038,8 @@ function AccountMainView({
|
|
|
4933
5038
|
isRefreshing
|
|
4934
5039
|
}) {
|
|
4935
5040
|
const { t } = useI18n();
|
|
4936
|
-
const
|
|
4937
|
-
|
|
4938
|
-
currency: "USD",
|
|
4939
|
-
minimumFractionDigits: 2,
|
|
4940
|
-
maximumFractionDigits: 2
|
|
4941
|
-
});
|
|
5041
|
+
const currencyCtx = usePreferredCurrencyOptional();
|
|
5042
|
+
const formattedUsd = isLoading ? "\u2014" : currencyCtx ? currencyCtx.formatAmount(totalUsd) : formatCurrency(totalUsd, "USD");
|
|
4942
5043
|
const lastUpdatedLabel = lastUpdatedAt ? lastUpdatedAt.toLocaleTimeString(void 0, {
|
|
4943
5044
|
hour: "2-digit",
|
|
4944
5045
|
minute: "2-digit"
|
|
@@ -5031,6 +5132,8 @@ function AccountMainView({
|
|
|
5031
5132
|
] });
|
|
5032
5133
|
}
|
|
5033
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;
|
|
5034
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: [
|
|
5035
5138
|
/* @__PURE__ */ jsxs("div", { className: "volr:flex volr:items-center volr:gap-3", children: [
|
|
5036
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(
|
|
@@ -5051,10 +5154,7 @@ function TokenRow({ token }) {
|
|
|
5051
5154
|
] }),
|
|
5052
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: [
|
|
5053
5156
|
/* @__PURE__ */ jsx("p", { className: "volr:text-sm volr:font-medium volr:text-slate-900", children: token.balance }),
|
|
5054
|
-
|
|
5055
|
-
"$",
|
|
5056
|
-
token.balanceUsd.toFixed(2)
|
|
5057
|
-
] })
|
|
5157
|
+
formattedBalanceUsd && /* @__PURE__ */ jsx("p", { className: "volr:text-xs volr:text-slate-400", children: formattedBalanceUsd })
|
|
5058
5158
|
] }) })
|
|
5059
5159
|
] });
|
|
5060
5160
|
}
|
|
@@ -5081,7 +5181,7 @@ function BalanceDetailView({
|
|
|
5081
5181
|
/* @__PURE__ */ jsx("div", { children: balances.map((token) => /* @__PURE__ */ jsx(TokenRow, { token }, token.id)) })
|
|
5082
5182
|
] });
|
|
5083
5183
|
}
|
|
5084
|
-
var Input =
|
|
5184
|
+
var Input = React16.forwardRef(
|
|
5085
5185
|
({ leftIcon, error, className, style, disabled, ...props }, ref) => {
|
|
5086
5186
|
return /* @__PURE__ */ jsxs("div", { className: "volr:relative", children: [
|
|
5087
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 }),
|
|
@@ -5469,6 +5569,7 @@ function ChevronRightIcon({ className }) {
|
|
|
5469
5569
|
}
|
|
5470
5570
|
function PaymentRow({ payment, onClick }) {
|
|
5471
5571
|
const { t } = useI18n();
|
|
5572
|
+
const currencyCtx = usePreferredCurrencyOptional();
|
|
5472
5573
|
const date = new Date(payment.createdAt);
|
|
5473
5574
|
const formattedDate = date.toLocaleDateString(void 0, {
|
|
5474
5575
|
month: "short",
|
|
@@ -5483,6 +5584,7 @@ function PaymentRow({ payment, onClick }) {
|
|
|
5483
5584
|
CANCELLED: "volr:bg-slate-100 volr:text-slate-500",
|
|
5484
5585
|
EXPIRED: "volr:bg-slate-100 volr:text-slate-500"
|
|
5485
5586
|
};
|
|
5587
|
+
const formattedUsd = payment.totalUsd ? currencyCtx ? currencyCtx.formatAmount(parseFloat(payment.totalUsd)) : formatCurrency(parseFloat(payment.totalUsd), "USD") : null;
|
|
5486
5588
|
return /* @__PURE__ */ jsxs(
|
|
5487
5589
|
"button",
|
|
5488
5590
|
{
|
|
@@ -5510,10 +5612,7 @@ function PaymentRow({ payment, onClick }) {
|
|
|
5510
5612
|
" ",
|
|
5511
5613
|
payment.token.symbol
|
|
5512
5614
|
] }),
|
|
5513
|
-
|
|
5514
|
-
"$",
|
|
5515
|
-
parseFloat(payment.totalUsd).toFixed(2)
|
|
5516
|
-
] })
|
|
5615
|
+
formattedUsd && /* @__PURE__ */ jsx("p", { className: "volr:text-xs volr:text-slate-400", children: formattedUsd })
|
|
5517
5616
|
] }),
|
|
5518
5617
|
/* @__PURE__ */ jsx(ChevronRightIcon, { className: "volr:w-4 volr:h-4 volr:text-slate-300" })
|
|
5519
5618
|
] })
|
|
@@ -5583,6 +5682,8 @@ function DetailRow({ label, value, copyable, mono, copyText }) {
|
|
|
5583
5682
|
}
|
|
5584
5683
|
function PaymentDetailView({ payment }) {
|
|
5585
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;
|
|
5586
5687
|
const createdDate = new Date(payment.createdAt);
|
|
5587
5688
|
const formattedCreatedAt = createdDate.toLocaleString(void 0, {
|
|
5588
5689
|
year: "numeric",
|
|
@@ -5631,10 +5732,9 @@ function PaymentDetailView({ payment }) {
|
|
|
5631
5732
|
" ",
|
|
5632
5733
|
payment.token.symbol
|
|
5633
5734
|
] }),
|
|
5634
|
-
|
|
5635
|
-
"\u2248
|
|
5636
|
-
|
|
5637
|
-
" USD"
|
|
5735
|
+
formattedUsd && /* @__PURE__ */ jsxs("p", { className: "volr:text-sm volr:text-slate-500", children: [
|
|
5736
|
+
"\u2248 ",
|
|
5737
|
+
formattedUsd
|
|
5638
5738
|
] })
|
|
5639
5739
|
] }),
|
|
5640
5740
|
/* @__PURE__ */ jsxs("div", { className: "volr:space-y-1", children: [
|
|
@@ -7210,9 +7310,11 @@ var PaymentResultView = ({
|
|
|
7210
7310
|
onReport
|
|
7211
7311
|
}) => {
|
|
7212
7312
|
const { t } = useI18n();
|
|
7313
|
+
const currencyCtx = usePreferredCurrencyOptional();
|
|
7213
7314
|
const isSuccess = payment.status === "CONFIRMED";
|
|
7214
7315
|
payment.status === "FAILED" || !!error;
|
|
7215
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;
|
|
7216
7318
|
const handleOpenExternalBrowser = () => {
|
|
7217
7319
|
if (typeof window === "undefined") return;
|
|
7218
7320
|
window.open(window.location.href, "_system");
|
|
@@ -7266,12 +7368,9 @@ var PaymentResultView = ({
|
|
|
7266
7368
|
payment.token.symbol
|
|
7267
7369
|
] })
|
|
7268
7370
|
] }),
|
|
7269
|
-
|
|
7371
|
+
formattedUsd && /* @__PURE__ */ jsxs("div", { className: "volr:flex volr:justify-between volr:text-sm", children: [
|
|
7270
7372
|
/* @__PURE__ */ jsx("span", { className: "volr:text-slate-500", children: t("payment.result.usdValueLabel") }),
|
|
7271
|
-
/* @__PURE__ */
|
|
7272
|
-
"$",
|
|
7273
|
-
parseFloat(payment.totalUsd).toFixed(2)
|
|
7274
|
-
] })
|
|
7373
|
+
/* @__PURE__ */ jsx("span", { className: "volr:text-slate-600", children: formattedUsd })
|
|
7275
7374
|
] }),
|
|
7276
7375
|
/* @__PURE__ */ jsxs("div", { className: "volr:flex volr:justify-between volr:text-sm", children: [
|
|
7277
7376
|
/* @__PURE__ */ jsx("span", { className: "volr:text-slate-500", children: t("payment.result.transactionLabel") }),
|
|
@@ -7488,8 +7587,8 @@ var PaymentModal = ({
|
|
|
7488
7587
|
const resolvedPermitType = selectedToken?.permitType ?? (selectedToken?.permitSupported ? "EIP2612" : "NONE");
|
|
7489
7588
|
const externalWalletTokenSupported = selectedToken && selectedToken.address !== "native" && resolvedPermitType === "EIP2612";
|
|
7490
7589
|
const showExternalWalletOption = externalWalletAllowed && externalWalletTokenSupported;
|
|
7491
|
-
const permit2WarnedRef =
|
|
7492
|
-
|
|
7590
|
+
const permit2WarnedRef = React16.useRef(false);
|
|
7591
|
+
React16.useEffect(() => {
|
|
7493
7592
|
if (!permit2WarnedRef.current && externalWalletAllowed && resolvedPermitType === "PERMIT2" && !selectedToken?.permit2Address) {
|
|
7494
7593
|
console.warn(
|
|
7495
7594
|
`[volr/react-ui] External wallet payment hidden: permit2Address is not configured for chain ${selectedToken?.chainId}.`
|
|
@@ -7971,7 +8070,7 @@ function WalletRequiredModal() {
|
|
|
7971
8070
|
}
|
|
7972
8071
|
);
|
|
7973
8072
|
}
|
|
7974
|
-
var VolrUIContext =
|
|
8073
|
+
var VolrUIContext = React16.createContext(null);
|
|
7975
8074
|
function getCurrentRpId() {
|
|
7976
8075
|
if (typeof window === "undefined") return "localhost";
|
|
7977
8076
|
return window.location.hostname;
|
|
@@ -8599,8 +8698,8 @@ function OnboardingChecker({
|
|
|
8599
8698
|
}) {
|
|
8600
8699
|
const { user, provider, isLoading } = useVolrContext();
|
|
8601
8700
|
const { isOpen: isModalOpen } = useVolrModal();
|
|
8602
|
-
const modalWasOpened =
|
|
8603
|
-
const pendingMismatchOnboarding =
|
|
8701
|
+
const modalWasOpened = React16.useRef(false);
|
|
8702
|
+
const pendingMismatchOnboarding = React16.useRef(false);
|
|
8604
8703
|
useEffect(() => {
|
|
8605
8704
|
if (isModalOpen) {
|
|
8606
8705
|
modalWasOpened.current = true;
|
|
@@ -8798,6 +8897,6 @@ function useVolrPay() {
|
|
|
8798
8897
|
};
|
|
8799
8898
|
}
|
|
8800
8899
|
|
|
8801
|
-
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 };
|
|
8802
8901
|
//# sourceMappingURL=index.js.map
|
|
8803
8902
|
//# sourceMappingURL=index.js.map
|