@b3dotfun/sdk 0.0.58-alpha.3 → 0.0.58-test.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/common/CryptoPaymentMethod.js +0 -4
- package/dist/cjs/anyspend/utils/index.d.ts +0 -1
- package/dist/cjs/anyspend/utils/index.js +0 -1
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +0 -17
- package/dist/cjs/global-account/react/hooks/useWagmiConfig.d.ts +1 -441
- package/dist/cjs/global-account/react/hooks/useWagmiConfig.js +0 -2
- package/dist/cjs/shared/react/components/CurrencySelector.js +3 -8
- package/dist/cjs/shared/react/components/FormattedCurrency.d.ts +3 -3
- package/dist/cjs/shared/react/components/FormattedCurrency.js +26 -31
- package/dist/cjs/shared/react/hooks/useCurrencyConversion.d.ts +5 -8
- package/dist/cjs/shared/react/hooks/useCurrencyConversion.js +94 -153
- package/dist/cjs/shared/react/stores/currencyStore.d.ts +8 -83
- package/dist/cjs/shared/react/stores/currencyStore.js +5 -147
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +1 -5
- package/dist/esm/anyspend/utils/index.d.ts +0 -1
- package/dist/esm/anyspend/utils/index.js +0 -1
- package/dist/esm/global-account/react/components/B3DynamicModal.js +0 -17
- package/dist/esm/global-account/react/hooks/useWagmiConfig.d.ts +1 -441
- package/dist/esm/global-account/react/hooks/useWagmiConfig.js +0 -2
- package/dist/esm/shared/react/components/CurrencySelector.js +5 -10
- package/dist/esm/shared/react/components/FormattedCurrency.d.ts +3 -3
- package/dist/esm/shared/react/components/FormattedCurrency.js +26 -31
- package/dist/esm/shared/react/hooks/useCurrencyConversion.d.ts +5 -8
- package/dist/esm/shared/react/hooks/useCurrencyConversion.js +95 -154
- package/dist/esm/shared/react/stores/currencyStore.d.ts +8 -83
- package/dist/esm/shared/react/stores/currencyStore.js +5 -143
- package/dist/types/anyspend/utils/index.d.ts +0 -1
- package/dist/types/global-account/react/hooks/useWagmiConfig.d.ts +1 -441
- package/dist/types/shared/react/components/FormattedCurrency.d.ts +3 -3
- package/dist/types/shared/react/hooks/useCurrencyConversion.d.ts +5 -8
- package/dist/types/shared/react/stores/currencyStore.d.ts +8 -83
- package/package.json +8 -4
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +2 -6
- package/src/anyspend/utils/index.ts +0 -1
- package/src/global-account/react/components/B3DynamicModal.tsx +0 -20
- package/src/global-account/react/hooks/useWagmiConfig.tsx +0 -2
- package/src/shared/react/components/CurrencySelector.tsx +5 -36
- package/src/shared/react/components/FormattedCurrency.tsx +30 -36
- package/src/shared/react/hooks/__tests__/useCurrencyConversion.test.ts +14 -14
- package/src/shared/react/hooks/useCurrencyConversion.ts +96 -163
- package/src/shared/react/stores/currencyStore.ts +10 -216
- package/dist/cjs/anyspend/utils/accountStore.d.ts +0 -7
- package/dist/cjs/anyspend/utils/accountStore.js +0 -8
- package/dist/esm/anyspend/utils/accountStore.d.ts +0 -7
- package/dist/esm/anyspend/utils/accountStore.js +0 -5
- package/dist/types/anyspend/utils/accountStore.d.ts +0 -7
- package/src/anyspend/utils/accountStore.ts +0 -12
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { useGlobalWalletState } from "@b3dotfun/sdk/anyspend/utils";
|
|
4
3
|
import { useAccountWallet } from "@b3dotfun/sdk/global-account/react";
|
|
5
4
|
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
6
5
|
import { shortenAddress } from "@b3dotfun/sdk/shared/utils/formatAddress";
|
|
@@ -10,7 +9,7 @@ import { ChevronLeft, ChevronRightCircle, Wallet, X, ZapIcon } from "lucide-reac
|
|
|
10
9
|
import { useState } from "react";
|
|
11
10
|
import { createPortal } from "react-dom";
|
|
12
11
|
import { toast } from "sonner";
|
|
13
|
-
import {
|
|
12
|
+
import { useSetActiveWallet, useWalletInfo } from "thirdweb/react";
|
|
14
13
|
import { WalletId, createWallet } from "thirdweb/wallets";
|
|
15
14
|
import { useAccount, useConnect, useDisconnect, useWalletClient } from "wagmi";
|
|
16
15
|
|
|
@@ -52,12 +51,10 @@ export function CryptoPaymentMethod({
|
|
|
52
51
|
const { disconnect } = useDisconnect();
|
|
53
52
|
const { data: walletClient } = useWalletClient();
|
|
54
53
|
const [showWalletModal, setShowWalletModal] = useState(false);
|
|
54
|
+
|
|
55
55
|
const setActiveWallet = useSetActiveWallet();
|
|
56
56
|
const { data: eoaWalletInfo } = useWalletInfo(connectedEOAWallet?.id);
|
|
57
57
|
|
|
58
|
-
const activeWallet = useActiveWallet();
|
|
59
|
-
const setGlobalAccountWallet = useGlobalWalletState(state => state.setGlobalAccountWallet);
|
|
60
|
-
|
|
61
58
|
const isConnected = !!connectedEOAWallet;
|
|
62
59
|
const globalAddress = connectedSmartWallet?.getAccount()?.address;
|
|
63
60
|
|
|
@@ -236,7 +233,6 @@ export function CryptoPaymentMethod({
|
|
|
236
233
|
onClick={() => {
|
|
237
234
|
setSelectedPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
238
235
|
onSelectPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
239
|
-
setGlobalAccountWallet(activeWallet);
|
|
240
236
|
setActiveWallet(connectedEOAWallet);
|
|
241
237
|
toast.success(`Selected ${eoaWalletInfo?.name || connector?.name || "wallet"}`);
|
|
242
238
|
}}
|
|
@@ -10,11 +10,9 @@ import {
|
|
|
10
10
|
} from "@b3dotfun/sdk/anyspend/react";
|
|
11
11
|
import { AnySpendDepositHype } from "@b3dotfun/sdk/anyspend/react/components/AnyspendDepositHype";
|
|
12
12
|
import { AnySpendStakeUpside } from "@b3dotfun/sdk/anyspend/react/components/AnySpendStakeUpside";
|
|
13
|
-
import { useGlobalWalletState } from "@b3dotfun/sdk/anyspend/utils";
|
|
14
13
|
import { useIsMobile, useModalStore } from "@b3dotfun/sdk/global-account/react";
|
|
15
14
|
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
16
15
|
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
17
|
-
import { useEffect, useRef } from "react";
|
|
18
16
|
import { AvatarEditor } from "./AvatarEditor/AvatarEditor";
|
|
19
17
|
import { useB3 } from "./B3Provider/useB3";
|
|
20
18
|
import { LinkAccount } from "./LinkAccount/LinkAccount";
|
|
@@ -23,7 +21,6 @@ import { RequestPermissions } from "./RequestPermissions/RequestPermissions";
|
|
|
23
21
|
import { SignInWithB3Flow } from "./SignInWithB3/SignInWithB3Flow";
|
|
24
22
|
import { Dialog, DialogContent, DialogDescription, DialogTitle } from "./ui/dialog";
|
|
25
23
|
import { Drawer, DrawerContent, DrawerDescription, DrawerTitle } from "./ui/drawer";
|
|
26
|
-
import { useSetActiveWallet } from "thirdweb/react";
|
|
27
24
|
|
|
28
25
|
const debug = debugB3React("B3DynamicModal");
|
|
29
26
|
|
|
@@ -31,23 +28,6 @@ export function B3DynamicModal() {
|
|
|
31
28
|
const { isOpen, setB3ModalOpen, contentType, history, navigateBack } = useModalStore();
|
|
32
29
|
const { theme } = useB3();
|
|
33
30
|
const isMobile = useIsMobile();
|
|
34
|
-
const prevIsOpenRef = useRef(isOpen);
|
|
35
|
-
|
|
36
|
-
const globalAccountWallet = useGlobalWalletState(state => state.globalAccountWallet);
|
|
37
|
-
const setGlobalAccountWallet = useGlobalWalletState(state => state.setGlobalAccountWallet);
|
|
38
|
-
const setActiveWallet = useSetActiveWallet();
|
|
39
|
-
|
|
40
|
-
// anyspend cleanup global account chnages by setting account back
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
if (prevIsOpenRef.current && !isOpen) {
|
|
43
|
-
if (globalAccountWallet) {
|
|
44
|
-
setActiveWallet(globalAccountWallet);
|
|
45
|
-
setGlobalAccountWallet(undefined);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
prevIsOpenRef.current = isOpen;
|
|
50
|
-
}, [isOpen, globalAccountWallet, setActiveWallet, setGlobalAccountWallet]);
|
|
51
31
|
|
|
52
32
|
// Define arrays for different modal type groups
|
|
53
33
|
const fullWidthTypes = [
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ecosystemWalletId } from "@b3dotfun/sdk/shared/constants";
|
|
2
2
|
import { supportedChains } from "@b3dotfun/sdk/shared/constants/chains/supported";
|
|
3
3
|
import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
|
|
4
|
-
import { farcasterMiniApp as miniAppConnector } from "@farcaster/miniapp-wagmi-connector";
|
|
5
4
|
import { inAppWalletConnector } from "@thirdweb-dev/wagmi-adapter";
|
|
6
5
|
import { useMemo } from "react";
|
|
7
6
|
import { http } from "viem";
|
|
@@ -35,7 +34,6 @@ export function useWagmiConfig(partnerId: string, rpcUrls?: Record<number, strin
|
|
|
35
34
|
...ecocystemConfig,
|
|
36
35
|
client,
|
|
37
36
|
}),
|
|
38
|
-
miniAppConnector(),
|
|
39
37
|
// injected(),
|
|
40
38
|
// coinbaseWallet({ appName: "HypeDuel" }),
|
|
41
39
|
],
|
|
@@ -9,16 +9,9 @@ import {
|
|
|
9
9
|
DropdownMenuSeparator,
|
|
10
10
|
DropdownMenuTrigger,
|
|
11
11
|
} from "../../../global-account/react/components/ui/dropdown-menu";
|
|
12
|
-
import {
|
|
13
|
-
CURRENCY_NAMES,
|
|
14
|
-
CURRENCY_SYMBOLS,
|
|
15
|
-
SupportedCurrency,
|
|
16
|
-
useCurrencyStore,
|
|
17
|
-
getCurrencyName,
|
|
18
|
-
getCurrencySymbol,
|
|
19
|
-
} from "../stores/currencyStore";
|
|
12
|
+
import { CURRENCY_NAMES, CURRENCY_SYMBOLS, SupportedCurrency, useCurrencyStore } from "../stores/currencyStore";
|
|
20
13
|
|
|
21
|
-
const
|
|
14
|
+
const currencies: SupportedCurrency[] = ["B3", "ETH", "SOL", "USD", "EUR", "GBP", "KRW", "JPY", "CAD", "AUD"];
|
|
22
15
|
|
|
23
16
|
interface CurrencySelectorProps {
|
|
24
17
|
labelClassName?: string;
|
|
@@ -27,13 +20,7 @@ interface CurrencySelectorProps {
|
|
|
27
20
|
}
|
|
28
21
|
|
|
29
22
|
export function CurrencySelector({ labelClassName, buttonVariant = "dark", label }: CurrencySelectorProps) {
|
|
30
|
-
const selectedCurrency = useCurrencyStore(
|
|
31
|
-
const setSelectedCurrency = useCurrencyStore(state => state.setSelectedCurrency);
|
|
32
|
-
const customCurrencies = useCurrencyStore(state => state.customCurrencies);
|
|
33
|
-
|
|
34
|
-
// Separate built-in and custom for better organization
|
|
35
|
-
const customCurrencyCodes = Object.keys(customCurrencies);
|
|
36
|
-
const hasCustomCurrencies = customCurrencyCodes.length > 0;
|
|
23
|
+
const { selectedCurrency, setSelectedCurrency } = useCurrencyStore();
|
|
37
24
|
|
|
38
25
|
return (
|
|
39
26
|
<div className="flex items-center gap-2">
|
|
@@ -51,7 +38,7 @@ export function CurrencySelector({ labelClassName, buttonVariant = "dark", label
|
|
|
51
38
|
</span>
|
|
52
39
|
)}
|
|
53
40
|
<Button variant={buttonVariant as any} className="flex items-center gap-2">
|
|
54
|
-
<span className="text-sm font-medium">{
|
|
41
|
+
<span className="text-sm font-medium">{CURRENCY_NAMES[selectedCurrency]}</span>
|
|
55
42
|
<svg className="h-4 w-4" fill="currentColor" viewBox="0 0 20 20">
|
|
56
43
|
<path
|
|
57
44
|
fillRule="evenodd"
|
|
@@ -63,7 +50,7 @@ export function CurrencySelector({ labelClassName, buttonVariant = "dark", label
|
|
|
63
50
|
</div>
|
|
64
51
|
</DropdownMenuTrigger>
|
|
65
52
|
<DropdownMenuContent align="end" className="z-[100] min-w-[200px]">
|
|
66
|
-
{
|
|
53
|
+
{currencies.map(currency => (
|
|
67
54
|
<div key={currency}>
|
|
68
55
|
<DropdownMenuItem
|
|
69
56
|
onClick={() => setSelectedCurrency(currency)}
|
|
@@ -77,24 +64,6 @@ export function CurrencySelector({ labelClassName, buttonVariant = "dark", label
|
|
|
77
64
|
{currency === "SOL" && <DropdownMenuSeparator key="separator" className="bg-border my-1" />}
|
|
78
65
|
</div>
|
|
79
66
|
))}
|
|
80
|
-
|
|
81
|
-
{hasCustomCurrencies && (
|
|
82
|
-
<>
|
|
83
|
-
<DropdownMenuSeparator className="bg-border my-1" />
|
|
84
|
-
{customCurrencyCodes.map(currency => (
|
|
85
|
-
<DropdownMenuItem
|
|
86
|
-
key={currency}
|
|
87
|
-
onClick={() => setSelectedCurrency(currency)}
|
|
88
|
-
className={`flex cursor-pointer items-center justify-between gap-3 px-3 py-2.5 transition-colors ${
|
|
89
|
-
selectedCurrency === currency ? "bg-accent" : "hover:bg-accent/50"
|
|
90
|
-
}`}
|
|
91
|
-
>
|
|
92
|
-
<span className="text-foreground text-sm font-medium">{getCurrencyName(currency)}</span>
|
|
93
|
-
<span className="text-muted-foreground text-xs font-medium">{getCurrencySymbol(currency)}</span>
|
|
94
|
-
</DropdownMenuItem>
|
|
95
|
-
))}
|
|
96
|
-
</>
|
|
97
|
-
)}
|
|
98
67
|
</DropdownMenuContent>
|
|
99
68
|
</DropdownMenu>
|
|
100
69
|
</div>
|
|
@@ -5,56 +5,47 @@ import { cn } from "@b3dotfun/sdk/shared/utils";
|
|
|
5
5
|
import { Tooltip, TooltipContent, TooltipTrigger } from "../../../global-account/react/components/ui/tooltip";
|
|
6
6
|
import { useCurrencyConversion } from "../hooks/useCurrencyConversion";
|
|
7
7
|
import { useCurrencyModalStore } from "../stores/currencyModalStore";
|
|
8
|
-
import { getCurrencyDecimalPlaces } from "../stores/currencyStore";
|
|
9
8
|
|
|
10
9
|
interface FormattedCurrencyProps {
|
|
11
|
-
amount:
|
|
12
|
-
sourceCurrency: string; // The currency the amount is in (e.g., "WIN", "B3", "USD")
|
|
10
|
+
amount: number;
|
|
13
11
|
showChange?: boolean;
|
|
14
12
|
showColor?: boolean;
|
|
15
13
|
className?: string;
|
|
16
14
|
subB3Icon?: boolean;
|
|
17
15
|
clickable?: boolean;
|
|
18
16
|
decimals?: number;
|
|
17
|
+
currency?: string; // Override currency (e.g., "ETH", "USDC", "B3")
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
export function FormattedCurrency({
|
|
22
21
|
amount,
|
|
23
|
-
sourceCurrency,
|
|
24
22
|
showChange = false,
|
|
25
23
|
showColor = false,
|
|
26
24
|
className,
|
|
27
25
|
subB3Icon = true,
|
|
28
26
|
clickable = true,
|
|
29
27
|
decimals,
|
|
28
|
+
currency,
|
|
30
29
|
}: FormattedCurrencyProps) {
|
|
31
30
|
const { formatCurrencyValue, formatTooltipValue, selectedCurrency, baseCurrency } = useCurrencyConversion();
|
|
32
31
|
const { openModal } = useCurrencyModalStore();
|
|
33
32
|
|
|
34
|
-
//
|
|
35
|
-
const
|
|
36
|
-
const divisor = Math.pow(10, decimalPlaces);
|
|
33
|
+
// Use passed currency or fall back to selected currency
|
|
34
|
+
const activeCurrency = currency || selectedCurrency;
|
|
37
35
|
|
|
38
|
-
|
|
39
|
-
let parsedAmount: number;
|
|
40
|
-
if (typeof amount === "string") {
|
|
41
|
-
// Handle BigInt strings and negative values
|
|
42
|
-
const numericAmount = amount.startsWith("-") ? -Math.abs(parseFloat(amount.replace("-", ""))) : parseFloat(amount);
|
|
43
|
-
parsedAmount = numericAmount / divisor;
|
|
44
|
-
} else {
|
|
45
|
-
parsedAmount = amount / divisor;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const isPositive = parsedAmount >= 0;
|
|
36
|
+
const isPositive = amount >= 0;
|
|
49
37
|
|
|
50
|
-
//
|
|
51
|
-
const
|
|
38
|
+
// Get the formatted value (using absolute value for negative numbers when showing change)
|
|
39
|
+
const baseAmount = showChange ? Math.abs(amount) : amount;
|
|
52
40
|
|
|
53
|
-
//
|
|
54
|
-
const formattedValue = formatCurrencyValue(
|
|
41
|
+
// Use centralized formatting from hook with optional overrides
|
|
42
|
+
const formattedValue = formatCurrencyValue(baseAmount, {
|
|
43
|
+
decimals,
|
|
44
|
+
currency,
|
|
45
|
+
});
|
|
55
46
|
|
|
56
47
|
// Generate tooltip using the centralized hook function
|
|
57
|
-
const baseTooltipValue = formatTooltipValue(
|
|
48
|
+
const baseTooltipValue = formatTooltipValue(amount, currency);
|
|
58
49
|
|
|
59
50
|
// Add change indicator if needed
|
|
60
51
|
const tooltipValue = showChange ? `${isPositive ? "+" : "-"}${baseTooltipValue}` : baseTooltipValue;
|
|
@@ -69,14 +60,14 @@ export function FormattedCurrency({
|
|
|
69
60
|
}
|
|
70
61
|
}
|
|
71
62
|
|
|
72
|
-
//
|
|
63
|
+
// Add change indicator
|
|
73
64
|
let displayValue = formattedValue;
|
|
74
65
|
if (showChange) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
66
|
+
if (isPositive) {
|
|
67
|
+
displayValue = `+${formattedValue}`;
|
|
68
|
+
} else {
|
|
69
|
+
displayValue = `-${formattedValue}`;
|
|
70
|
+
}
|
|
80
71
|
}
|
|
81
72
|
|
|
82
73
|
const handleClick = () => {
|
|
@@ -85,9 +76,6 @@ export function FormattedCurrency({
|
|
|
85
76
|
}
|
|
86
77
|
};
|
|
87
78
|
|
|
88
|
-
// Check if we should show B3 icon (when displaying in B3 and baseCurrency is B3)
|
|
89
|
-
const shouldShowB3Icon = subB3Icon && selectedCurrency === "B3" && baseCurrency === "B3";
|
|
90
|
-
|
|
91
79
|
return (
|
|
92
80
|
<Tooltip>
|
|
93
81
|
<TooltipTrigger asChild>
|
|
@@ -100,10 +88,16 @@ export function FormattedCurrency({
|
|
|
100
88
|
clickable && "cursor-pointer transition-opacity hover:opacity-80",
|
|
101
89
|
)}
|
|
102
90
|
>
|
|
103
|
-
{
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
91
|
+
{subB3Icon &&
|
|
92
|
+
(currency === baseCurrency || (!currency && activeCurrency === baseCurrency)) &&
|
|
93
|
+
baseCurrency === "B3"
|
|
94
|
+
? displayValue.split(" ")[0]
|
|
95
|
+
: displayValue}
|
|
96
|
+
{subB3Icon &&
|
|
97
|
+
(currency === baseCurrency || (!currency && activeCurrency === baseCurrency)) &&
|
|
98
|
+
baseCurrency === "B3" && (
|
|
99
|
+
<img src={B3_COIN_IMAGE_URL} className="inline-block h-4 w-4 align-middle" alt="B3 coin" />
|
|
100
|
+
)}
|
|
107
101
|
</span>
|
|
108
102
|
</TooltipTrigger>
|
|
109
103
|
<TooltipContent>{tooltipValue}</TooltipContent>
|
|
@@ -67,7 +67,7 @@ describe("useCurrencyConversion", () => {
|
|
|
67
67
|
mockStoreState.baseCurrency = "B3";
|
|
68
68
|
|
|
69
69
|
const { result } = renderHook(() => useCurrencyConversion());
|
|
70
|
-
const formatted = result.current.formatCurrencyValue(100
|
|
70
|
+
const formatted = result.current.formatCurrencyValue(100);
|
|
71
71
|
|
|
72
72
|
expect(formatted).toContain("B3");
|
|
73
73
|
expect(formatted).toContain("100");
|
|
@@ -79,7 +79,7 @@ describe("useCurrencyConversion", () => {
|
|
|
79
79
|
mockStoreState.baseCurrency = "B3";
|
|
80
80
|
|
|
81
81
|
const { result } = renderHook(() => useCurrencyConversion());
|
|
82
|
-
const formatted = result.current.formatCurrencyValue(100
|
|
82
|
+
const formatted = result.current.formatCurrencyValue(100);
|
|
83
83
|
|
|
84
84
|
expect(formatted).toContain("B3");
|
|
85
85
|
expect(formatted).not.toContain("$");
|
|
@@ -91,7 +91,7 @@ describe("useCurrencyConversion", () => {
|
|
|
91
91
|
mockStoreState.baseCurrency = "B3";
|
|
92
92
|
|
|
93
93
|
const { result } = renderHook(() => useCurrencyConversion());
|
|
94
|
-
const formatted = result.current.formatCurrencyValue(100
|
|
94
|
+
const formatted = result.current.formatCurrencyValue(100);
|
|
95
95
|
|
|
96
96
|
expect(formatted).toMatch(/^\$/);
|
|
97
97
|
expect(formatted).toContain("200");
|
|
@@ -104,7 +104,7 @@ describe("useCurrencyConversion", () => {
|
|
|
104
104
|
mockStoreState.baseCurrency = "B3";
|
|
105
105
|
|
|
106
106
|
const { result } = renderHook(() => useCurrencyConversion());
|
|
107
|
-
const formatted = result.current.formatCurrencyValue(100
|
|
107
|
+
const formatted = result.current.formatCurrencyValue(100);
|
|
108
108
|
|
|
109
109
|
expect(formatted).toMatch(/^€/);
|
|
110
110
|
});
|
|
@@ -116,7 +116,7 @@ describe("useCurrencyConversion", () => {
|
|
|
116
116
|
mockStoreState.baseCurrency = "B3";
|
|
117
117
|
|
|
118
118
|
const { result } = renderHook(() => useCurrencyConversion());
|
|
119
|
-
const formatted = result.current.formatCurrencyValue(100
|
|
119
|
+
const formatted = result.current.formatCurrencyValue(100);
|
|
120
120
|
|
|
121
121
|
expect(formatted).toContain("¥");
|
|
122
122
|
expect(formatted).not.toContain(".");
|
|
@@ -129,7 +129,7 @@ describe("useCurrencyConversion", () => {
|
|
|
129
129
|
mockStoreState.baseCurrency = "B3";
|
|
130
130
|
|
|
131
131
|
const { result } = renderHook(() => useCurrencyConversion());
|
|
132
|
-
const formatted = result.current.formatCurrencyValue(100
|
|
132
|
+
const formatted = result.current.formatCurrencyValue(100);
|
|
133
133
|
|
|
134
134
|
expect(formatted).toContain("₩");
|
|
135
135
|
expect(formatted).not.toContain(".");
|
|
@@ -142,7 +142,7 @@ describe("useCurrencyConversion", () => {
|
|
|
142
142
|
mockStoreState.baseCurrency = "B3";
|
|
143
143
|
|
|
144
144
|
const { result } = renderHook(() => useCurrencyConversion());
|
|
145
|
-
const formatted = result.current.formatCurrencyValue(100
|
|
145
|
+
const formatted = result.current.formatCurrencyValue(100);
|
|
146
146
|
|
|
147
147
|
expect(formatted).toContain("ETH");
|
|
148
148
|
expect(formatted).not.toMatch(/^ETH/);
|
|
@@ -155,7 +155,7 @@ describe("useCurrencyConversion", () => {
|
|
|
155
155
|
mockStoreState.baseCurrency = "B3";
|
|
156
156
|
|
|
157
157
|
const { result } = renderHook(() => useCurrencyConversion());
|
|
158
|
-
const formatted = result.current.formatCurrencyValue(100
|
|
158
|
+
const formatted = result.current.formatCurrencyValue(100);
|
|
159
159
|
|
|
160
160
|
expect(formatted).toContain("SOL");
|
|
161
161
|
expect(formatted).not.toMatch(/^SOL/);
|
|
@@ -167,7 +167,7 @@ describe("useCurrencyConversion", () => {
|
|
|
167
167
|
mockStoreState.baseCurrency = "B3";
|
|
168
168
|
|
|
169
169
|
const { result } = renderHook(() => useCurrencyConversion());
|
|
170
|
-
const formatted = result.current.formatCurrencyValue(10
|
|
170
|
+
const formatted = result.current.formatCurrencyValue(10);
|
|
171
171
|
|
|
172
172
|
// 10 * 1.5 = 15
|
|
173
173
|
expect(formatted).toMatch(/^\$/);
|
|
@@ -182,7 +182,7 @@ describe("useCurrencyConversion", () => {
|
|
|
182
182
|
|
|
183
183
|
const { result } = renderHook(() => useCurrencyConversion());
|
|
184
184
|
const inputValue = 100;
|
|
185
|
-
const formatted = result.current.formatCurrencyValue(inputValue
|
|
185
|
+
const formatted = result.current.formatCurrencyValue(inputValue);
|
|
186
186
|
|
|
187
187
|
expect(formatted).toContain("350");
|
|
188
188
|
});
|
|
@@ -236,7 +236,7 @@ describe("useCurrencyConversion", () => {
|
|
|
236
236
|
mockStoreState.baseCurrency = "B3";
|
|
237
237
|
|
|
238
238
|
const { result } = renderHook(() => useCurrencyConversion());
|
|
239
|
-
const tooltip = result.current.formatTooltipValue(100
|
|
239
|
+
const tooltip = result.current.formatTooltipValue(100);
|
|
240
240
|
|
|
241
241
|
expect(tooltip).toContain("USD");
|
|
242
242
|
expect(tooltip).toContain("150");
|
|
@@ -249,7 +249,7 @@ describe("useCurrencyConversion", () => {
|
|
|
249
249
|
mockStoreState.baseCurrency = "B3";
|
|
250
250
|
|
|
251
251
|
const { result } = renderHook(() => useCurrencyConversion());
|
|
252
|
-
const tooltip = result.current.formatTooltipValue(100
|
|
252
|
+
const tooltip = result.current.formatTooltipValue(100);
|
|
253
253
|
|
|
254
254
|
expect(tooltip).toContain("B3");
|
|
255
255
|
expect(tooltip).toContain("100");
|
|
@@ -286,7 +286,7 @@ describe("useCurrencyConversion", () => {
|
|
|
286
286
|
mockStoreState.baseCurrency = "B3";
|
|
287
287
|
|
|
288
288
|
const { result } = renderHook(() => useCurrencyConversion());
|
|
289
|
-
const tooltip = result.current.formatTooltipValue(-100
|
|
289
|
+
const tooltip = result.current.formatTooltipValue(-100);
|
|
290
290
|
|
|
291
291
|
expect(tooltip).toContain("USD");
|
|
292
292
|
expect(tooltip).toContain("150");
|
|
@@ -299,7 +299,7 @@ describe("useCurrencyConversion", () => {
|
|
|
299
299
|
mockStoreState.baseCurrency = "B3";
|
|
300
300
|
|
|
301
301
|
const { result } = renderHook(() => useCurrencyConversion());
|
|
302
|
-
const tooltip = result.current.formatTooltipValue(100
|
|
302
|
+
const tooltip = result.current.formatTooltipValue(100);
|
|
303
303
|
|
|
304
304
|
expect(tooltip).toContain("USD");
|
|
305
305
|
expect(tooltip).toContain("100");
|