@b3dotfun/sdk 0.0.42 → 0.0.43-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/react/components/AnySpend.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/AnySpend.js +11 -4
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +43 -3
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +2 -2
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +5 -3
- package/dist/cjs/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +12 -0
- package/dist/cjs/anyspend/types/api.d.ts +2 -10
- package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +1 -1
- package/dist/cjs/global-account/react/components/index.d.ts +8 -7
- package/dist/cjs/global-account/react/components/index.js +29 -23
- package/dist/cjs/global-account/react/components/ui/dropdown-menu.d.ts +27 -0
- package/dist/cjs/global-account/react/components/ui/dropdown-menu.js +100 -0
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +5 -1
- package/dist/cjs/shared/constants/currency.d.ts +1 -0
- package/dist/cjs/shared/constants/currency.js +5 -0
- package/dist/cjs/shared/constants/index.d.ts +1 -0
- package/dist/cjs/shared/constants/index.js +15 -0
- package/dist/cjs/shared/react/components/CurrencySelector.d.ts +7 -0
- package/dist/cjs/shared/react/components/CurrencySelector.js +14 -0
- package/dist/cjs/shared/react/components/FormattedCurrency.d.ts +12 -0
- package/dist/cjs/shared/react/components/FormattedCurrency.js +60 -0
- package/dist/cjs/shared/react/components/index.d.ts +2 -0
- package/dist/cjs/shared/react/components/index.js +18 -0
- package/dist/cjs/shared/react/hooks/__tests__/useCurrencyConversion.test.d.ts +1 -0
- package/dist/cjs/shared/react/hooks/__tests__/useCurrencyConversion.test.js +245 -0
- package/dist/cjs/shared/react/hooks/index.d.ts +1 -0
- package/dist/cjs/shared/react/hooks/index.js +1 -0
- package/dist/cjs/shared/react/hooks/useCurrencyConversion.d.ts +35 -0
- package/dist/cjs/shared/react/hooks/useCurrencyConversion.js +200 -0
- package/dist/cjs/shared/react/index.d.ts +2 -0
- package/dist/cjs/shared/react/index.js +2 -0
- package/dist/cjs/shared/react/stores/currencyModalStore.d.ts +7 -0
- package/dist/cjs/shared/react/stores/currencyModalStore.js +9 -0
- package/dist/cjs/shared/react/stores/currencyStore.d.ts +51 -0
- package/dist/cjs/shared/react/stores/currencyStore.js +57 -0
- package/dist/cjs/shared/react/stores/index.d.ts +2 -0
- package/dist/cjs/shared/react/stores/index.js +18 -0
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +1 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +11 -4
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +10 -3
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +1 -0
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +2 -2
- package/dist/esm/anyspend/react/components/common/PanelOnramp.d.ts +2 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +5 -3
- package/dist/esm/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +12 -0
- package/dist/esm/anyspend/types/api.d.ts +2 -10
- package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +1 -1
- package/dist/esm/global-account/react/components/index.d.ts +8 -7
- package/dist/esm/global-account/react/components/index.js +8 -7
- package/dist/esm/global-account/react/components/ui/dropdown-menu.d.ts +27 -0
- package/dist/esm/global-account/react/components/ui/dropdown-menu.js +60 -0
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +5 -1
- package/dist/esm/shared/constants/currency.d.ts +1 -0
- package/dist/esm/shared/constants/currency.js +2 -0
- package/dist/esm/shared/constants/index.d.ts +1 -0
- package/dist/esm/shared/constants/index.js +1 -0
- package/dist/esm/shared/react/components/CurrencySelector.d.ts +7 -0
- package/dist/esm/shared/react/components/CurrencySelector.js +11 -0
- package/dist/esm/shared/react/components/FormattedCurrency.d.ts +12 -0
- package/dist/esm/shared/react/components/FormattedCurrency.js +57 -0
- package/dist/esm/shared/react/components/index.d.ts +2 -0
- package/dist/esm/shared/react/components/index.js +2 -0
- package/dist/esm/shared/react/hooks/__tests__/useCurrencyConversion.test.d.ts +1 -0
- package/dist/esm/shared/react/hooks/__tests__/useCurrencyConversion.test.js +243 -0
- package/dist/esm/shared/react/hooks/index.d.ts +1 -0
- package/dist/esm/shared/react/hooks/index.js +1 -0
- package/dist/esm/shared/react/hooks/useCurrencyConversion.d.ts +35 -0
- package/dist/esm/shared/react/hooks/useCurrencyConversion.js +197 -0
- package/dist/esm/shared/react/index.d.ts +2 -0
- package/dist/esm/shared/react/index.js +2 -0
- package/dist/esm/shared/react/stores/currencyModalStore.d.ts +7 -0
- package/dist/esm/shared/react/stores/currencyModalStore.js +6 -0
- package/dist/esm/shared/react/stores/currencyStore.d.ts +51 -0
- package/dist/esm/shared/react/stores/currencyStore.js +54 -0
- package/dist/esm/shared/react/stores/index.d.ts +2 -0
- package/dist/esm/shared/react/stores/index.js +2 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/AnySpend.d.ts +1 -0
- package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +1 -0
- package/dist/types/anyspend/react/components/common/PanelOnramp.d.ts +2 -1
- package/dist/types/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +12 -0
- package/dist/types/anyspend/types/api.d.ts +2 -10
- package/dist/types/global-account/react/components/index.d.ts +8 -7
- package/dist/types/global-account/react/components/ui/dropdown-menu.d.ts +27 -0
- package/dist/types/global-account/react/stores/useModalStore.d.ts +5 -1
- package/dist/types/shared/constants/currency.d.ts +1 -0
- package/dist/types/shared/constants/index.d.ts +1 -0
- package/dist/types/shared/react/components/CurrencySelector.d.ts +7 -0
- package/dist/types/shared/react/components/FormattedCurrency.d.ts +12 -0
- package/dist/types/shared/react/components/index.d.ts +2 -0
- package/dist/types/shared/react/hooks/__tests__/useCurrencyConversion.test.d.ts +1 -0
- package/dist/types/shared/react/hooks/index.d.ts +1 -0
- package/dist/types/shared/react/hooks/useCurrencyConversion.d.ts +35 -0
- package/dist/types/shared/react/index.d.ts +2 -0
- package/dist/types/shared/react/stores/currencyModalStore.d.ts +7 -0
- package/dist/types/shared/react/stores/currencyStore.d.ts +51 -0
- package/dist/types/shared/react/stores/index.d.ts +2 -0
- package/package.json +29 -3
- package/src/anyspend/react/components/AnySpend.tsx +15 -2
- package/src/anyspend/react/components/AnySpendCustom.tsx +11 -2
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +3 -0
- package/src/anyspend/react/components/common/PanelOnramp.tsx +19 -15
- package/src/anyspend/types/api.ts +2 -10
- package/src/global-account/react/components/SignInWithB3/SignIn.tsx +2 -7
- package/src/global-account/react/components/index.ts +19 -12
- package/src/global-account/react/components/ui/dropdown-menu.tsx +132 -0
- package/src/global-account/react/stores/useModalStore.ts +5 -1
- package/src/shared/constants/currency.ts +2 -0
- package/src/shared/constants/index.ts +2 -0
- package/src/shared/react/components/CurrencySelector.tsx +71 -0
- package/src/shared/react/components/FormattedCurrency.tsx +106 -0
- package/src/shared/react/components/index.ts +2 -0
- package/src/shared/react/hooks/__tests__/useCurrencyConversion.test.ts +308 -0
- package/src/shared/react/hooks/index.ts +1 -0
- package/src/shared/react/hooks/useCurrencyConversion.ts +211 -0
- package/src/shared/react/index.ts +2 -0
- package/src/shared/react/stores/currencyModalStore.ts +13 -0
- package/src/shared/react/stores/currencyStore.ts +82 -0
- package/src/shared/react/stores/index.ts +2 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.DropdownMenu = DropdownMenu;
|
|
38
|
+
exports.DropdownMenuTrigger = DropdownMenuTrigger;
|
|
39
|
+
exports.DropdownMenuContent = DropdownMenuContent;
|
|
40
|
+
exports.DropdownMenuItem = DropdownMenuItem;
|
|
41
|
+
exports.DropdownMenuSeparator = DropdownMenuSeparator;
|
|
42
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
43
|
+
const utils_1 = require("../../../../shared/utils");
|
|
44
|
+
const React = __importStar(require("react"));
|
|
45
|
+
const DropdownMenuContext = React.createContext({
|
|
46
|
+
isOpen: false,
|
|
47
|
+
setIsOpen: () => { },
|
|
48
|
+
});
|
|
49
|
+
function DropdownMenu({ children }) {
|
|
50
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
51
|
+
React.useEffect(() => {
|
|
52
|
+
const handleClickOutside = (event) => {
|
|
53
|
+
const target = event.target;
|
|
54
|
+
if (!target.closest("[data-dropdown-menu]")) {
|
|
55
|
+
setIsOpen(false);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
if (isOpen) {
|
|
59
|
+
document.addEventListener("click", handleClickOutside);
|
|
60
|
+
return () => document.removeEventListener("click", handleClickOutside);
|
|
61
|
+
}
|
|
62
|
+
}, [isOpen]);
|
|
63
|
+
return ((0, jsx_runtime_1.jsx)(DropdownMenuContext.Provider, { value: { isOpen, setIsOpen }, children: (0, jsx_runtime_1.jsx)("div", { className: "relative", "data-dropdown-menu": true, children: children }) }));
|
|
64
|
+
}
|
|
65
|
+
function DropdownMenuTrigger({ children, asChild }) {
|
|
66
|
+
const { isOpen, setIsOpen } = React.useContext(DropdownMenuContext);
|
|
67
|
+
const handleClick = () => {
|
|
68
|
+
setIsOpen(!isOpen);
|
|
69
|
+
};
|
|
70
|
+
if (asChild) {
|
|
71
|
+
if (React.isValidElement(children)) {
|
|
72
|
+
return React.cloneElement(children, {
|
|
73
|
+
onClick: handleClick,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return (0, jsx_runtime_1.jsx)("button", { onClick: handleClick, children: children });
|
|
78
|
+
}
|
|
79
|
+
function DropdownMenuContent({ children, align = "start", className }) {
|
|
80
|
+
const { isOpen } = React.useContext(DropdownMenuContext);
|
|
81
|
+
if (!isOpen)
|
|
82
|
+
return null;
|
|
83
|
+
const alignmentClasses = {
|
|
84
|
+
start: "left-0",
|
|
85
|
+
center: "left-1/2 -translate-x-1/2",
|
|
86
|
+
end: "right-0",
|
|
87
|
+
};
|
|
88
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)("bg-popover text-popover-foreground absolute top-full z-50 mt-1 min-w-32 overflow-hidden rounded-md border p-1 shadow-md", "border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-800", alignmentClasses[align], className), children: children }));
|
|
89
|
+
}
|
|
90
|
+
function DropdownMenuItem({ children, onClick, className }) {
|
|
91
|
+
const { setIsOpen } = React.useContext(DropdownMenuContext);
|
|
92
|
+
const handleClick = () => {
|
|
93
|
+
onClick?.();
|
|
94
|
+
setIsOpen(false);
|
|
95
|
+
};
|
|
96
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)("hover:bg-accent hover:text-accent-foreground relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50", "hover:bg-gray-100 dark:hover:bg-gray-700", className), onClick: handleClick, children: children }));
|
|
97
|
+
}
|
|
98
|
+
function DropdownMenuSeparator({ className }) {
|
|
99
|
+
return (0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)("bg-muted -mx-1 my-1 h-px", "bg-gray-200 dark:bg-gray-600", className) });
|
|
100
|
+
}
|
|
@@ -117,11 +117,13 @@ export interface AnySpendModalProps extends BaseModalProps {
|
|
|
117
117
|
/** Whether to hide the transaction history button */
|
|
118
118
|
hideTransactionHistoryButton?: boolean;
|
|
119
119
|
/** Callback function called when the transaction is successful */
|
|
120
|
-
onSuccess?: () => void;
|
|
120
|
+
onSuccess?: (txHash?: string) => void;
|
|
121
121
|
/** Token address of the destination token to buy (enables buy mode) */
|
|
122
122
|
destinationTokenAddress?: string;
|
|
123
123
|
/** Chain ID where the destination token exists (enables buy mode) */
|
|
124
124
|
destinationTokenChainId?: number;
|
|
125
|
+
/** Custom USD input values for quick amount buttons in fiat onramp */
|
|
126
|
+
customUsdInputValues?: string[];
|
|
125
127
|
}
|
|
126
128
|
/**
|
|
127
129
|
* Props for the AnySpend NFT modal
|
|
@@ -290,6 +292,8 @@ export interface AnySpendDepositHypeProps extends BaseModalProps {
|
|
|
290
292
|
mainFooter?: React.ReactNode;
|
|
291
293
|
/** Callback function called when the deposit is successful */
|
|
292
294
|
onSuccess?: (amount?: string) => void;
|
|
295
|
+
/** Custom USD input values for quick amount buttons in fiat onramp */
|
|
296
|
+
customUsdInputValues?: string[];
|
|
293
297
|
}
|
|
294
298
|
export interface AvatarEditorModalProps extends BaseModalProps {
|
|
295
299
|
/** Modal type identifier */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const B3_COIN_IMAGE_URL = "https://cdn.b3.fun/b3-coin-3d.png";
|
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
17
|
exports.PUBLIC_BASE_RPC_URL = exports.ENS_GATEWAY_URL = exports.B3_AUTH_COOKIE_NAME = exports.CLIENT_APP_BUNDLE_ID = exports.THIRDWEB_CLIENT_ID = exports.THIRDWEB_SECRET_KEY = exports.tokenIcons = exports.ecosystemWalletId = exports.b3CoinIcon = exports.siteURL = void 0;
|
|
18
|
+
__exportStar(require("./currency"), exports);
|
|
4
19
|
exports.siteURL = "https://basement.fun";
|
|
5
20
|
exports.b3CoinIcon = "https://cdn.b3.fun/b3-coin-3d.png";
|
|
6
21
|
exports.ecosystemWalletId = (process.env.NEXT_PUBLIC_THIRDWEB_ECOSYSTEM_ID ||
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface CurrencySelectorProps {
|
|
2
|
+
labelClassName?: string;
|
|
3
|
+
buttonVariant?: "dark" | "primary" | "ghost" | "gold";
|
|
4
|
+
label?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function CurrencySelector({ labelClassName, buttonVariant, label }: CurrencySelectorProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.CurrencySelector = CurrencySelector;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const utils_1 = require("../../../shared/utils");
|
|
7
|
+
const button_1 = require("../../../global-account/react/components/ui/button");
|
|
8
|
+
const dropdown_menu_1 = require("../../../global-account/react/components/ui/dropdown-menu");
|
|
9
|
+
const currencyStore_1 = require("../stores/currencyStore");
|
|
10
|
+
const currencies = ["B3", "ETH", "SOL", "USD", "EUR", "GBP", "KRW", "JPY", "CAD", "AUD"];
|
|
11
|
+
function CurrencySelector({ labelClassName, buttonVariant = "dark", label }) {
|
|
12
|
+
const { selectedCurrency, setSelectedCurrency } = (0, currencyStore_1.useCurrencyStore)();
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "flex items-center gap-2", children: (0, jsx_runtime_1.jsxs)(dropdown_menu_1.DropdownMenu, { children: [(0, jsx_runtime_1.jsx)(dropdown_menu_1.DropdownMenuTrigger, { asChild: true, children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-3", children: [label && ((0, jsx_runtime_1.jsx)("span", { className: (0, utils_1.cn)("text-foreground text-sm font-medium leading-none tracking-tight sm:text-base", labelClassName), children: label })), (0, jsx_runtime_1.jsxs)(button_1.Button, { variant: buttonVariant, className: "flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-sm font-medium", children: currencyStore_1.CURRENCY_NAMES[selectedCurrency] }), (0, jsx_runtime_1.jsx)("svg", { className: "h-4 w-4", fill: "currentColor", viewBox: "0 0 20 20", children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", d: "M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z", clipRule: "evenodd" }) })] })] }) }), (0, jsx_runtime_1.jsx)(dropdown_menu_1.DropdownMenuContent, { align: "end", className: "z-[100] min-w-[200px]", children: currencies.map(currency => ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)(dropdown_menu_1.DropdownMenuItem, { onClick: () => setSelectedCurrency(currency), className: `flex cursor-pointer items-center justify-between gap-3 px-3 py-2.5 transition-colors ${selectedCurrency === currency ? "bg-accent" : "hover:bg-accent/50"}`, children: [(0, jsx_runtime_1.jsx)("span", { className: "text-foreground text-sm font-medium", children: currencyStore_1.CURRENCY_NAMES[currency] }), (0, jsx_runtime_1.jsx)("span", { className: "text-muted-foreground text-xs font-medium", children: currencyStore_1.CURRENCY_SYMBOLS[currency] })] }), currency === "SOL" && (0, jsx_runtime_1.jsx)(dropdown_menu_1.DropdownMenuSeparator, { className: "bg-border my-1" }, "separator")] }, currency))) })] }) }));
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface FormattedCurrencyProps {
|
|
2
|
+
amount: number;
|
|
3
|
+
showChange?: boolean;
|
|
4
|
+
showColor?: boolean;
|
|
5
|
+
className?: string;
|
|
6
|
+
subB3Icon?: boolean;
|
|
7
|
+
clickable?: boolean;
|
|
8
|
+
decimals?: number;
|
|
9
|
+
currency?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function FormattedCurrency({ amount, showChange, showColor, className, subB3Icon, clickable, decimals, currency, }: FormattedCurrencyProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.FormattedCurrency = FormattedCurrency;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const currency_1 = require("../../../shared/constants/currency");
|
|
7
|
+
const utils_1 = require("../../../shared/utils");
|
|
8
|
+
const tooltip_1 = require("../../../global-account/react/components/ui/tooltip");
|
|
9
|
+
const useCurrencyConversion_1 = require("../hooks/useCurrencyConversion");
|
|
10
|
+
const currencyModalStore_1 = require("../stores/currencyModalStore");
|
|
11
|
+
function FormattedCurrency({ amount, showChange = false, showColor = false, className, subB3Icon = true, clickable = true, decimals, currency, }) {
|
|
12
|
+
const { formatCurrencyValue, formatTooltipValue, selectedCurrency, baseCurrency } = (0, useCurrencyConversion_1.useCurrencyConversion)();
|
|
13
|
+
const { openModal } = (0, currencyModalStore_1.useCurrencyModalStore)();
|
|
14
|
+
// Use passed currency or fall back to selected currency
|
|
15
|
+
const activeCurrency = currency || selectedCurrency;
|
|
16
|
+
const isPositive = amount >= 0;
|
|
17
|
+
// Get the formatted value (using absolute value for negative numbers when showing change)
|
|
18
|
+
const baseAmount = showChange ? Math.abs(amount) : amount;
|
|
19
|
+
// Use centralized formatting from hook with optional overrides
|
|
20
|
+
const formattedValue = formatCurrencyValue(baseAmount, {
|
|
21
|
+
decimals,
|
|
22
|
+
currency,
|
|
23
|
+
});
|
|
24
|
+
// Generate tooltip using the centralized hook function
|
|
25
|
+
const baseTooltipValue = formatTooltipValue(amount, currency);
|
|
26
|
+
// Add change indicator if needed
|
|
27
|
+
const tooltipValue = showChange ? `${isPositive ? "+" : "-"}${baseTooltipValue}` : baseTooltipValue;
|
|
28
|
+
// Determine color class
|
|
29
|
+
let colorClass = "";
|
|
30
|
+
if (showColor) {
|
|
31
|
+
if (isPositive) {
|
|
32
|
+
colorClass = "text-green-400";
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
colorClass = "text-red-400";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// Add change indicator
|
|
39
|
+
let displayValue = formattedValue;
|
|
40
|
+
if (showChange) {
|
|
41
|
+
if (isPositive) {
|
|
42
|
+
displayValue = `+${formattedValue}`;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
displayValue = `-${formattedValue}`;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const handleClick = () => {
|
|
49
|
+
if (clickable) {
|
|
50
|
+
openModal();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
return ((0, jsx_runtime_1.jsxs)(tooltip_1.Tooltip, { children: [(0, jsx_runtime_1.jsx)(tooltip_1.TooltipTrigger, { asChild: true, children: (0, jsx_runtime_1.jsxs)("span", { onClick: handleClick, className: (0, utils_1.cn)("inline-flex items-center gap-1 whitespace-nowrap", colorClass, className, clickable && "cursor-pointer transition-opacity hover:opacity-80"), children: [subB3Icon &&
|
|
54
|
+
(currency === baseCurrency || (!currency && activeCurrency === baseCurrency)) &&
|
|
55
|
+
baseCurrency === "B3"
|
|
56
|
+
? displayValue.split(" ")[0]
|
|
57
|
+
: displayValue, subB3Icon &&
|
|
58
|
+
(currency === baseCurrency || (!currency && activeCurrency === baseCurrency)) &&
|
|
59
|
+
baseCurrency === "B3" && ((0, jsx_runtime_1.jsx)("img", { src: currency_1.B3_COIN_IMAGE_URL, className: "inline-block h-4 w-4 align-middle", alt: "B3 coin" }))] }) }), (0, jsx_runtime_1.jsx)(tooltip_1.TooltipContent, { children: tooltipValue })] }));
|
|
60
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./CurrencySelector"), exports);
|
|
18
|
+
__exportStar(require("./FormattedCurrency"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const react_1 = require("@testing-library/react");
|
|
5
|
+
const useCurrencyConversion_1 = require("../useCurrencyConversion");
|
|
6
|
+
// Mock the external dependencies
|
|
7
|
+
// Store mock rates for different quote currencies
|
|
8
|
+
const mockRates = {};
|
|
9
|
+
// Mock store state
|
|
10
|
+
const mockStoreState = {
|
|
11
|
+
selectedCurrency: "B3",
|
|
12
|
+
baseCurrency: "B3",
|
|
13
|
+
setSelectedCurrency: vitest_1.vi.fn(),
|
|
14
|
+
setBaseCurrency: vitest_1.vi.fn(),
|
|
15
|
+
};
|
|
16
|
+
vitest_1.vi.mock("@b3dotfun/sdk/global-account/react", () => ({
|
|
17
|
+
useExchangeRate: vitest_1.vi.fn((params) => {
|
|
18
|
+
const rate = mockRates[params?.quoteCurrency];
|
|
19
|
+
return { rate };
|
|
20
|
+
}),
|
|
21
|
+
}));
|
|
22
|
+
vitest_1.vi.mock("@b3dotfun/sdk/shared/utils/number", () => ({
|
|
23
|
+
formatDisplayNumber: vitest_1.vi.fn((value) => {
|
|
24
|
+
const num = Number(value);
|
|
25
|
+
if (isNaN(num))
|
|
26
|
+
return "0";
|
|
27
|
+
return num.toLocaleString("en-US", { maximumFractionDigits: 6 });
|
|
28
|
+
}),
|
|
29
|
+
}));
|
|
30
|
+
vitest_1.vi.mock("../../stores/currencyStore", () => ({
|
|
31
|
+
useCurrencyStore: vitest_1.vi.fn((selector) => {
|
|
32
|
+
if (selector) {
|
|
33
|
+
return selector(mockStoreState);
|
|
34
|
+
}
|
|
35
|
+
return mockStoreState;
|
|
36
|
+
}),
|
|
37
|
+
CURRENCY_SYMBOLS: {
|
|
38
|
+
B3: "B3",
|
|
39
|
+
USD: "$",
|
|
40
|
+
EUR: "€",
|
|
41
|
+
GBP: "£",
|
|
42
|
+
JPY: "¥",
|
|
43
|
+
CAD: "C$",
|
|
44
|
+
AUD: "A$",
|
|
45
|
+
ETH: "ETH",
|
|
46
|
+
SOL: "SOL",
|
|
47
|
+
KRW: "₩",
|
|
48
|
+
},
|
|
49
|
+
}));
|
|
50
|
+
(0, vitest_1.describe)("useCurrencyConversion", () => {
|
|
51
|
+
(0, vitest_1.beforeEach)(() => {
|
|
52
|
+
vitest_1.vi.clearAllMocks();
|
|
53
|
+
// Reset mock rates to default
|
|
54
|
+
Object.keys(mockRates).forEach(key => delete mockRates[key]);
|
|
55
|
+
mockRates.USD = 1.0;
|
|
56
|
+
// Reset store state
|
|
57
|
+
mockStoreState.selectedCurrency = "B3";
|
|
58
|
+
mockStoreState.baseCurrency = "B3";
|
|
59
|
+
});
|
|
60
|
+
(0, vitest_1.describe)("formatCurrencyValue", () => {
|
|
61
|
+
(0, vitest_1.it)("should format base currency (B3) without conversion", () => {
|
|
62
|
+
mockStoreState.selectedCurrency = "B3";
|
|
63
|
+
mockStoreState.baseCurrency = "B3";
|
|
64
|
+
const { result } = (0, react_1.renderHook)(() => (0, useCurrencyConversion_1.useCurrencyConversion)());
|
|
65
|
+
const formatted = result.current.formatCurrencyValue(100);
|
|
66
|
+
(0, vitest_1.expect)(formatted).toContain("B3");
|
|
67
|
+
(0, vitest_1.expect)(formatted).toContain("100");
|
|
68
|
+
});
|
|
69
|
+
(0, vitest_1.it)("should show base currency when exchange rate is unavailable", () => {
|
|
70
|
+
mockRates.USD = undefined;
|
|
71
|
+
mockStoreState.selectedCurrency = "USD";
|
|
72
|
+
mockStoreState.baseCurrency = "B3";
|
|
73
|
+
const { result } = (0, react_1.renderHook)(() => (0, useCurrencyConversion_1.useCurrencyConversion)());
|
|
74
|
+
const formatted = result.current.formatCurrencyValue(100);
|
|
75
|
+
(0, vitest_1.expect)(formatted).toContain("B3");
|
|
76
|
+
(0, vitest_1.expect)(formatted).not.toContain("$");
|
|
77
|
+
});
|
|
78
|
+
(0, vitest_1.it)("should format USD with prefix symbol", () => {
|
|
79
|
+
mockRates.USD = 2.0;
|
|
80
|
+
mockStoreState.selectedCurrency = "USD";
|
|
81
|
+
mockStoreState.baseCurrency = "B3";
|
|
82
|
+
const { result } = (0, react_1.renderHook)(() => (0, useCurrencyConversion_1.useCurrencyConversion)());
|
|
83
|
+
const formatted = result.current.formatCurrencyValue(100);
|
|
84
|
+
(0, vitest_1.expect)(formatted).toMatch(/^\$/);
|
|
85
|
+
(0, vitest_1.expect)(formatted).toContain("200");
|
|
86
|
+
});
|
|
87
|
+
(0, vitest_1.it)("should format EUR with prefix symbol", () => {
|
|
88
|
+
mockRates.EUR = 1.8;
|
|
89
|
+
mockRates.USD = 2.0;
|
|
90
|
+
mockStoreState.selectedCurrency = "EUR";
|
|
91
|
+
mockStoreState.baseCurrency = "B3";
|
|
92
|
+
const { result } = (0, react_1.renderHook)(() => (0, useCurrencyConversion_1.useCurrencyConversion)());
|
|
93
|
+
const formatted = result.current.formatCurrencyValue(100);
|
|
94
|
+
(0, vitest_1.expect)(formatted).toMatch(/^€/);
|
|
95
|
+
});
|
|
96
|
+
(0, vitest_1.it)("should format JPY without decimals", () => {
|
|
97
|
+
mockRates.JPY = 150;
|
|
98
|
+
mockRates.USD = 2.0;
|
|
99
|
+
mockStoreState.selectedCurrency = "JPY";
|
|
100
|
+
mockStoreState.baseCurrency = "B3";
|
|
101
|
+
const { result } = (0, react_1.renderHook)(() => (0, useCurrencyConversion_1.useCurrencyConversion)());
|
|
102
|
+
const formatted = result.current.formatCurrencyValue(100);
|
|
103
|
+
(0, vitest_1.expect)(formatted).toContain("¥");
|
|
104
|
+
(0, vitest_1.expect)(formatted).not.toContain(".");
|
|
105
|
+
});
|
|
106
|
+
(0, vitest_1.it)("should format KRW without decimals", () => {
|
|
107
|
+
mockRates.KRW = 1300;
|
|
108
|
+
mockRates.USD = 2.0;
|
|
109
|
+
mockStoreState.selectedCurrency = "KRW";
|
|
110
|
+
mockStoreState.baseCurrency = "B3";
|
|
111
|
+
const { result } = (0, react_1.renderHook)(() => (0, useCurrencyConversion_1.useCurrencyConversion)());
|
|
112
|
+
const formatted = result.current.formatCurrencyValue(100);
|
|
113
|
+
(0, vitest_1.expect)(formatted).toContain("₩");
|
|
114
|
+
(0, vitest_1.expect)(formatted).not.toContain(".");
|
|
115
|
+
});
|
|
116
|
+
(0, vitest_1.it)("should format ETH with suffix symbol", () => {
|
|
117
|
+
mockRates.ETH = 0.0005;
|
|
118
|
+
mockRates.USD = 2.0;
|
|
119
|
+
mockStoreState.selectedCurrency = "ETH";
|
|
120
|
+
mockStoreState.baseCurrency = "B3";
|
|
121
|
+
const { result } = (0, react_1.renderHook)(() => (0, useCurrencyConversion_1.useCurrencyConversion)());
|
|
122
|
+
const formatted = result.current.formatCurrencyValue(100);
|
|
123
|
+
(0, vitest_1.expect)(formatted).toContain("ETH");
|
|
124
|
+
(0, vitest_1.expect)(formatted).not.toMatch(/^ETH/);
|
|
125
|
+
});
|
|
126
|
+
(0, vitest_1.it)("should format SOL with suffix symbol", () => {
|
|
127
|
+
mockRates.SOL = 0.05;
|
|
128
|
+
mockRates.USD = 2.0;
|
|
129
|
+
mockStoreState.selectedCurrency = "SOL";
|
|
130
|
+
mockStoreState.baseCurrency = "B3";
|
|
131
|
+
const { result } = (0, react_1.renderHook)(() => (0, useCurrencyConversion_1.useCurrencyConversion)());
|
|
132
|
+
const formatted = result.current.formatCurrencyValue(100);
|
|
133
|
+
(0, vitest_1.expect)(formatted).toContain("SOL");
|
|
134
|
+
(0, vitest_1.expect)(formatted).not.toMatch(/^SOL/);
|
|
135
|
+
});
|
|
136
|
+
(0, vitest_1.it)("should handle small USD amounts with proper conversion", () => {
|
|
137
|
+
mockRates.USD = 1.5;
|
|
138
|
+
mockStoreState.selectedCurrency = "USD";
|
|
139
|
+
mockStoreState.baseCurrency = "B3";
|
|
140
|
+
const { result } = (0, react_1.renderHook)(() => (0, useCurrencyConversion_1.useCurrencyConversion)());
|
|
141
|
+
const formatted = result.current.formatCurrencyValue(10);
|
|
142
|
+
// 10 * 1.5 = 15
|
|
143
|
+
(0, vitest_1.expect)(formatted).toMatch(/^\$/);
|
|
144
|
+
(0, vitest_1.expect)(formatted).toContain("15");
|
|
145
|
+
});
|
|
146
|
+
(0, vitest_1.it)("should apply correct exchange rate conversion", () => {
|
|
147
|
+
const testRate = 3.5;
|
|
148
|
+
mockRates.USD = testRate;
|
|
149
|
+
mockStoreState.selectedCurrency = "USD";
|
|
150
|
+
mockStoreState.baseCurrency = "B3";
|
|
151
|
+
const { result } = (0, react_1.renderHook)(() => (0, useCurrencyConversion_1.useCurrencyConversion)());
|
|
152
|
+
const inputValue = 100;
|
|
153
|
+
const formatted = result.current.formatCurrencyValue(inputValue);
|
|
154
|
+
(0, vitest_1.expect)(formatted).toContain("350");
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
(0, vitest_1.describe)("return values", () => {
|
|
158
|
+
(0, vitest_1.it)("should return selected currency", () => {
|
|
159
|
+
mockStoreState.selectedCurrency = "USD";
|
|
160
|
+
mockStoreState.baseCurrency = "B3";
|
|
161
|
+
const { result } = (0, react_1.renderHook)(() => (0, useCurrencyConversion_1.useCurrencyConversion)());
|
|
162
|
+
(0, vitest_1.expect)(result.current.selectedCurrency).toBe("USD");
|
|
163
|
+
});
|
|
164
|
+
(0, vitest_1.it)("should return base currency", () => {
|
|
165
|
+
mockStoreState.selectedCurrency = "USD";
|
|
166
|
+
mockStoreState.baseCurrency = "B3";
|
|
167
|
+
const { result } = (0, react_1.renderHook)(() => (0, useCurrencyConversion_1.useCurrencyConversion)());
|
|
168
|
+
(0, vitest_1.expect)(result.current.baseCurrency).toBe("B3");
|
|
169
|
+
});
|
|
170
|
+
(0, vitest_1.it)("should return exchange rate", () => {
|
|
171
|
+
const testRate = 2.5;
|
|
172
|
+
mockRates.USD = testRate;
|
|
173
|
+
mockStoreState.selectedCurrency = "USD";
|
|
174
|
+
mockStoreState.baseCurrency = "B3";
|
|
175
|
+
const { result } = (0, react_1.renderHook)(() => (0, useCurrencyConversion_1.useCurrencyConversion)());
|
|
176
|
+
(0, vitest_1.expect)(result.current.exchangeRate).toBe(testRate);
|
|
177
|
+
});
|
|
178
|
+
(0, vitest_1.it)("should return correct currency symbols", () => {
|
|
179
|
+
mockStoreState.selectedCurrency = "EUR";
|
|
180
|
+
mockStoreState.baseCurrency = "B3";
|
|
181
|
+
const { result } = (0, react_1.renderHook)(() => (0, useCurrencyConversion_1.useCurrencyConversion)());
|
|
182
|
+
(0, vitest_1.expect)(result.current.selectedCurrencySymbol).toBe("€");
|
|
183
|
+
(0, vitest_1.expect)(result.current.baseCurrencySymbol).toBe("B3");
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
(0, vitest_1.describe)("formatTooltipValue", () => {
|
|
187
|
+
(0, vitest_1.it)("should show USD equivalent when displaying base currency", () => {
|
|
188
|
+
mockRates.USD = 1.5;
|
|
189
|
+
mockStoreState.selectedCurrency = "B3";
|
|
190
|
+
mockStoreState.baseCurrency = "B3";
|
|
191
|
+
const { result } = (0, react_1.renderHook)(() => (0, useCurrencyConversion_1.useCurrencyConversion)());
|
|
192
|
+
const tooltip = result.current.formatTooltipValue(100);
|
|
193
|
+
(0, vitest_1.expect)(tooltip).toContain("USD");
|
|
194
|
+
(0, vitest_1.expect)(tooltip).toContain("150");
|
|
195
|
+
});
|
|
196
|
+
(0, vitest_1.it)("should show base currency when displaying other currency", () => {
|
|
197
|
+
mockRates.EUR = 0.9;
|
|
198
|
+
mockRates.USD = 1.2;
|
|
199
|
+
mockStoreState.selectedCurrency = "EUR";
|
|
200
|
+
mockStoreState.baseCurrency = "B3";
|
|
201
|
+
const { result } = (0, react_1.renderHook)(() => (0, useCurrencyConversion_1.useCurrencyConversion)());
|
|
202
|
+
const tooltip = result.current.formatTooltipValue(100);
|
|
203
|
+
(0, vitest_1.expect)(tooltip).toContain("B3");
|
|
204
|
+
(0, vitest_1.expect)(tooltip).toContain("100");
|
|
205
|
+
});
|
|
206
|
+
(0, vitest_1.it)("should handle custom currency for base currency", () => {
|
|
207
|
+
mockRates.USD = 2.0;
|
|
208
|
+
mockRates.EUR = 1.8;
|
|
209
|
+
mockStoreState.selectedCurrency = "EUR";
|
|
210
|
+
mockStoreState.baseCurrency = "B3";
|
|
211
|
+
const { result } = (0, react_1.renderHook)(() => (0, useCurrencyConversion_1.useCurrencyConversion)());
|
|
212
|
+
const tooltip = result.current.formatTooltipValue(100, "B3");
|
|
213
|
+
(0, vitest_1.expect)(tooltip).toContain("USD");
|
|
214
|
+
(0, vitest_1.expect)(tooltip).toContain("200");
|
|
215
|
+
});
|
|
216
|
+
(0, vitest_1.it)("should handle custom currency for non-base currency", () => {
|
|
217
|
+
mockRates.USD = 2.0;
|
|
218
|
+
mockStoreState.selectedCurrency = "USD";
|
|
219
|
+
mockStoreState.baseCurrency = "B3";
|
|
220
|
+
const { result } = (0, react_1.renderHook)(() => (0, useCurrencyConversion_1.useCurrencyConversion)());
|
|
221
|
+
const tooltip = result.current.formatTooltipValue(50, "ETH");
|
|
222
|
+
(0, vitest_1.expect)(tooltip).toContain("ETH");
|
|
223
|
+
(0, vitest_1.expect)(tooltip).toContain("50");
|
|
224
|
+
});
|
|
225
|
+
(0, vitest_1.it)("should handle absolute values for negative amounts", () => {
|
|
226
|
+
mockRates.USD = 1.5;
|
|
227
|
+
mockStoreState.selectedCurrency = "B3";
|
|
228
|
+
mockStoreState.baseCurrency = "B3";
|
|
229
|
+
const { result } = (0, react_1.renderHook)(() => (0, useCurrencyConversion_1.useCurrencyConversion)());
|
|
230
|
+
const tooltip = result.current.formatTooltipValue(-100);
|
|
231
|
+
(0, vitest_1.expect)(tooltip).toContain("USD");
|
|
232
|
+
(0, vitest_1.expect)(tooltip).toContain("150");
|
|
233
|
+
(0, vitest_1.expect)(tooltip).not.toContain("-");
|
|
234
|
+
});
|
|
235
|
+
(0, vitest_1.it)("should handle exchange rate unavailable", () => {
|
|
236
|
+
mockRates.USD = undefined;
|
|
237
|
+
mockStoreState.selectedCurrency = "B3";
|
|
238
|
+
mockStoreState.baseCurrency = "B3";
|
|
239
|
+
const { result } = (0, react_1.renderHook)(() => (0, useCurrencyConversion_1.useCurrencyConversion)());
|
|
240
|
+
const tooltip = result.current.formatTooltipValue(100);
|
|
241
|
+
(0, vitest_1.expect)(tooltip).toContain("USD");
|
|
242
|
+
(0, vitest_1.expect)(tooltip).toContain("100");
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
});
|
|
@@ -14,4 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./useCurrencyConversion"), exports);
|
|
17
18
|
__exportStar(require("./useNavigation"), exports);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook for currency conversion and formatting with real-time exchange rates.
|
|
3
|
+
*
|
|
4
|
+
* This hook provides currency conversion functionality using live exchange rates
|
|
5
|
+
* and formats values according to currency-specific rules (decimals, symbols, etc.).
|
|
6
|
+
*
|
|
7
|
+
* @returns Currency conversion utilities and state
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* function PriceDisplay({ amount }: { amount: number }) {
|
|
12
|
+
* const { formatCurrencyValue, selectedCurrency } = useCurrencyConversion();
|
|
13
|
+
* return <div>{formatCurrencyValue(amount)}</div>;
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare function useCurrencyConversion(): {
|
|
18
|
+
/** Currently selected display currency */
|
|
19
|
+
selectedCurrency: import("../stores/currencyStore").SupportedCurrency;
|
|
20
|
+
/** Base currency used for conversion (typically B3) */
|
|
21
|
+
baseCurrency: import("../stores/currencyStore").SupportedCurrency;
|
|
22
|
+
/** Current exchange rate from base to selected currency (undefined while loading) */
|
|
23
|
+
exchangeRate: number;
|
|
24
|
+
/** Format a value with currency conversion and proper symbol/decimal handling */
|
|
25
|
+
formatCurrencyValue: (value: number, options?: {
|
|
26
|
+
decimals?: number;
|
|
27
|
+
currency?: string;
|
|
28
|
+
}) => string;
|
|
29
|
+
/** Format a tooltip value showing alternate currency representation */
|
|
30
|
+
formatTooltipValue: (value: number, customCurrency?: string) => string;
|
|
31
|
+
/** Symbol for the currently selected currency (e.g., "$", "€", "ETH") */
|
|
32
|
+
selectedCurrencySymbol: string;
|
|
33
|
+
/** Symbol for the base currency */
|
|
34
|
+
baseCurrencySymbol: string;
|
|
35
|
+
};
|