@mezo-org/passport 0.4.0-dev.82 → 0.4.0-dev.84
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/src/components/Dropdown/Content.d.ts +0 -15
- package/dist/src/components/Dropdown/Content.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Content.js +3 -3
- package/dist/src/components/Dropdown/Content.js.map +1 -1
- package/dist/src/components/Dropdown/Dropdown.d.ts +0 -4
- package/dist/src/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Dropdown.js +10 -36
- package/dist/src/components/Dropdown/Dropdown.js.map +1 -1
- package/dist/src/components/Dropdown/ListingItem.d.ts +8 -7
- package/dist/src/components/Dropdown/ListingItem.d.ts.map +1 -1
- package/dist/src/components/Dropdown/ListingItem.js +36 -28
- package/dist/src/components/Dropdown/ListingItem.js.map +1 -1
- package/dist/src/components/Dropdown/NestedViewLayout.d.ts +2 -1
- package/dist/src/components/Dropdown/NestedViewLayout.d.ts.map +1 -1
- package/dist/src/components/Dropdown/NestedViewLayout.js +13 -15
- package/dist/src/components/Dropdown/NestedViewLayout.js.map +1 -1
- package/dist/src/components/Dropdown/Receive/Receive.d.ts +1 -4
- package/dist/src/components/Dropdown/Receive/Receive.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Receive/Receive.js +30 -19
- package/dist/src/components/Dropdown/Receive/Receive.js.map +1 -1
- package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts +2 -5
- package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Root/AccountAddressActions.js +13 -12
- package/dist/src/components/Dropdown/Root/AccountAddressActions.js.map +1 -1
- package/dist/src/components/Dropdown/Root/AccountBalance.d.ts +2 -4
- package/dist/src/components/Dropdown/Root/AccountBalance.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Root/AccountBalance.js +24 -8
- package/dist/src/components/Dropdown/Root/AccountBalance.js.map +1 -1
- package/dist/src/components/Dropdown/Root/AccountBtcListing.d.ts +6 -0
- package/dist/src/components/Dropdown/Root/AccountBtcListing.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountBtcListing.js +27 -0
- package/dist/src/components/Dropdown/Root/AccountBtcListing.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountError.d.ts +8 -0
- package/dist/src/components/Dropdown/Root/AccountError.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountError.js +17 -0
- package/dist/src/components/Dropdown/Root/AccountError.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountMusdListing.d.ts +4 -0
- package/dist/src/components/Dropdown/Root/AccountMusdListing.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountMusdListing.js +21 -0
- package/dist/src/components/Dropdown/Root/AccountMusdListing.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts +2 -3
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.js +34 -39
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.js.map +1 -1
- package/dist/src/components/Dropdown/Root/Root.d.ts +0 -15
- package/dist/src/components/Dropdown/Root/Root.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Root/Root.js +22 -34
- package/dist/src/components/Dropdown/Root/Root.js.map +1 -1
- package/dist/src/components/Dropdown/Root/WalletAddress.d.ts +2 -6
- package/dist/src/components/Dropdown/Root/WalletAddress.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Root/WalletAddress.js +37 -34
- package/dist/src/components/Dropdown/Root/WalletAddress.js.map +1 -1
- package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts +2 -4
- package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Root/WelcomeBlock.js +60 -16
- package/dist/src/components/Dropdown/Root/WelcomeBlock.js.map +1 -1
- package/dist/src/components/Dropdown/SlotNumber.d.ts +19 -0
- package/dist/src/components/Dropdown/SlotNumber.d.ts.map +1 -0
- package/dist/src/components/Dropdown/SlotNumber.js +67 -0
- package/dist/src/components/Dropdown/SlotNumber.js.map +1 -0
- package/dist/src/config.d.ts +0 -1
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +1 -9
- package/dist/src/config.js.map +1 -1
- package/dist/src/hooks/useAssetsConversionRates.d.ts +8 -13
- package/dist/src/hooks/useAssetsConversionRates.d.ts.map +1 -1
- package/dist/src/hooks/useAssetsConversionRates.js +44 -67
- package/dist/src/hooks/useAssetsConversionRates.js.map +1 -1
- package/dist/src/hooks/useAuthenticateWithWallet.d.ts.map +1 -1
- package/dist/src/hooks/useAuthenticateWithWallet.js +1 -1
- package/dist/src/hooks/useAuthenticateWithWallet.js.map +1 -1
- package/dist/src/hooks/useBorrowData.d.ts +30 -4
- package/dist/src/hooks/useBorrowData.d.ts.map +1 -1
- package/dist/src/hooks/useBorrowData.js +53 -11
- package/dist/src/hooks/useBorrowData.js.map +1 -1
- package/dist/src/hooks/useCreateAccount.d.ts.map +1 -1
- package/dist/src/hooks/useCreateAccount.js +3 -3
- package/dist/src/hooks/useCreateAccount.js.map +1 -1
- package/dist/src/hooks/useGetCurrentAccount.d.ts.map +1 -1
- package/dist/src/hooks/useGetCurrentAccount.js +4 -6
- package/dist/src/hooks/useGetCurrentAccount.js.map +1 -1
- package/dist/src/hooks/useLinkAccount.d.ts.map +1 -1
- package/dist/src/hooks/useLinkAccount.js +3 -3
- package/dist/src/hooks/useLinkAccount.js.map +1 -1
- package/dist/src/hooks/useTokensBalances.d.ts +36 -35
- package/dist/src/hooks/useTokensBalances.d.ts.map +1 -1
- package/dist/src/hooks/useTokensBalances.js +93 -52
- package/dist/src/hooks/useTokensBalances.js.map +1 -1
- package/dist/src/hooks/useWalletAccount.d.ts +8 -6
- package/dist/src/hooks/useWalletAccount.d.ts.map +1 -1
- package/dist/src/hooks/useWalletAccount.js +9 -6
- package/dist/src/hooks/useWalletAccount.js.map +1 -1
- package/dist/src/lib/contracts/index.d.ts +1 -1
- package/dist/src/lib/contracts/index.d.ts.map +1 -1
- package/dist/src/lib/contracts/index.js +4 -0
- package/dist/src/lib/contracts/index.js.map +1 -1
- package/dist/src/provider.d.ts +7 -1
- package/dist/src/provider.d.ts.map +1 -1
- package/dist/src/provider.js +4 -1
- package/dist/src/provider.js.map +1 -1
- package/dist/src/utils/assets.d.ts +145 -0
- package/dist/src/utils/assets.d.ts.map +1 -0
- package/dist/src/utils/assets.js +100 -0
- package/dist/src/utils/assets.js.map +1 -0
- package/dist/src/utils/assets.test.d.ts +2 -0
- package/dist/src/utils/assets.test.d.ts.map +1 -0
- package/dist/src/utils/assets.test.js +46 -0
- package/dist/src/utils/assets.test.js.map +1 -0
- package/dist/src/utils/currency.d.ts +6 -3
- package/dist/src/utils/currency.d.ts.map +1 -1
- package/dist/src/utils/currency.js +13 -10
- package/dist/src/utils/currency.js.map +1 -1
- package/dist/src/utils/currency.test.js +44 -2
- package/dist/src/utils/currency.test.js.map +1 -1
- package/dist/src/utils/numbers.d.ts +13 -53
- package/dist/src/utils/numbers.d.ts.map +1 -1
- package/dist/src/utils/numbers.js +16 -118
- package/dist/src/utils/numbers.js.map +1 -1
- package/dist/src/utils/numbers.test.js +24 -142
- package/dist/src/utils/numbers.test.js.map +1 -1
- package/package.json +2 -1
- package/src/components/Dropdown/Content.tsx +3 -48
- package/src/components/Dropdown/Dropdown.tsx +7 -58
- package/src/components/Dropdown/ListingItem.tsx +155 -59
- package/src/components/Dropdown/NestedViewLayout.tsx +32 -20
- package/src/components/Dropdown/Receive/Receive.tsx +57 -32
- package/src/components/Dropdown/Root/AccountAddressActions.tsx +33 -35
- package/src/components/Dropdown/Root/AccountBalance.tsx +54 -16
- package/src/components/Dropdown/Root/AccountBtcListing.tsx +52 -0
- package/src/components/Dropdown/Root/AccountError.tsx +34 -0
- package/src/components/Dropdown/Root/AccountMusdListing.tsx +45 -0
- package/src/components/Dropdown/Root/AccountOtherAssets.tsx +63 -46
- package/src/components/Dropdown/Root/Root.tsx +28 -98
- package/src/components/Dropdown/Root/WalletAddress.tsx +87 -89
- package/src/components/Dropdown/Root/WelcomeBlock.tsx +112 -30
- package/src/components/Dropdown/SlotNumber.tsx +131 -0
- package/src/config.ts +1 -11
- package/src/hooks/useAssetsConversionRates.ts +49 -67
- package/src/hooks/useAuthenticateWithWallet.ts +7 -5
- package/src/hooks/useBorrowData.ts +71 -12
- package/src/hooks/useCreateAccount.ts +5 -4
- package/src/hooks/useGetCurrentAccount.ts +5 -7
- package/src/hooks/useLinkAccount.ts +5 -4
- package/src/hooks/useTokensBalances.ts +152 -74
- package/src/hooks/useWalletAccount.ts +19 -13
- package/src/lib/contracts/index.ts +8 -1
- package/src/provider.ts +11 -3
- package/src/utils/assets.test.ts +57 -0
- package/src/utils/assets.ts +103 -0
- package/src/utils/currency.test.ts +76 -2
- package/src/utils/currency.ts +20 -15
- package/src/utils/numbers.test.ts +29 -180
- package/src/utils/numbers.ts +22 -171
- package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts +0 -11
- package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts.map +0 -1
- package/dist/src/components/Dropdown/Root/AccountAssetItem.js +0 -9
- package/dist/src/components/Dropdown/Root/AccountAssetItem.js.map +0 -1
- package/dist/src/hooks/useDropdownData.d.ts +0 -47
- package/dist/src/hooks/useDropdownData.d.ts.map +0 -1
- package/dist/src/hooks/useDropdownData.js +0 -97
- package/dist/src/hooks/useDropdownData.js.map +0 -1
- package/dist/src/utils/cryptoAssets.d.ts +0 -44
- package/dist/src/utils/cryptoAssets.d.ts.map +0 -1
- package/dist/src/utils/cryptoAssets.js +0 -129
- package/dist/src/utils/cryptoAssets.js.map +0 -1
- package/dist/src/utils/cryptoAssets.test.d.ts +0 -2
- package/dist/src/utils/cryptoAssets.test.d.ts.map +0 -1
- package/dist/src/utils/cryptoAssets.test.js +0 -67
- package/dist/src/utils/cryptoAssets.test.js.map +0 -1
- package/src/components/Dropdown/Root/AccountAssetItem.tsx +0 -26
- package/src/hooks/useDropdownData.ts +0 -152
- package/src/utils/cryptoAssets.test.ts +0 -79
- package/src/utils/cryptoAssets.ts +0 -171
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useDropdownData.js","sourceRoot":"","sources":["../../../src/hooks/useDropdownData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,GAAG,CAAA;AACxC,OAAO,EAEL,cAAc,EACd,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,kCAAkC,EAAE,MAAM,0BAA0B,CAAA;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAOhD,MAAM,kBAAkB,GAAG;IACzB,UAAU,EAAE,EAAE;IACd,gBAAgB,EAAE,QAAQ;IAC1B,UAAU,EAAE,CAAC;IACb,mBAAmB,EAAE,OAAO;CAC7B,CAAA;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EACtC,0BAA0B,GAAG,KAAK,EAClC,4BAA4B,GAAG,KAAK,GACrC;IACC,MAAM,EACJ,aAAa,EACb,cAAc,EACd,aAAa,EAAE,UAAU,GAC1B,GAAG,gBAAg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AAM,aAAa,GAAG,YAAY,CAChC,IAAI,EAAE,UAAU,IAAI,EAAE,EACtB,cAAc,CAAC,MAAM,CAAC,CAAC,QAAQ,EAC/B,qBAAqB,CAAC,GAAG,CAAC,KAAK,EAC/B,qBAAqB,CAAC,GAAG,CAAC,QAAQ,CACnC,CAAA;IAED,MAAM,YAAY,GAAG,cAAc,CAAC,IAAI,EAAE,SAAS,IAAI,EAAE,EAAE,EAAE,CAAC,CAAA;IAE9D,MAAM,eAAe,GACnB,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,GAAG,GAAG,UAAU,EAAE,CAAC,CAAC;QACnE,aAAa,CAAA;IAEf,OAAO;QACL,MAAM;QACN,WAAW;QACX,cAAc;QACd,aAAa;QACb,UAAU;QACV,eAAe;QACf,YAAY;QACZ,aAAa;QACb,MAAM;QACN,gBAAgB;QAChB,mBAAmB;KACpB,CAAA;AACH,CAAC"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { IconProps } from "@mezo-org/mezo-clay";
|
|
2
|
-
import { FC } from "react";
|
|
3
|
-
import { MezoChainToken } from "../lib/contracts";
|
|
4
|
-
export type CryptoAssetKey = MezoChainToken | "BTC" | "ETH";
|
|
5
|
-
export type CryptoAsset = {
|
|
6
|
-
name: string;
|
|
7
|
-
symbol: string;
|
|
8
|
-
icon: FC<IconProps>;
|
|
9
|
-
decimals: number;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Gets details of given crypto asset
|
|
13
|
-
* @param key The key of crypto asset
|
|
14
|
-
* @returns The crypto asset details
|
|
15
|
-
*/
|
|
16
|
-
export declare function getCryptoAsset(key: CryptoAssetKey): CryptoAsset;
|
|
17
|
-
/**
|
|
18
|
-
* Checks if given crypto asset is Bitcoin-like
|
|
19
|
-
* @param key The key of crypto asset
|
|
20
|
-
* @returns True if crypto asset is Bitcoin-like
|
|
21
|
-
*/
|
|
22
|
-
export declare function isBitcoinLikeCryptoAsset(key: CryptoAssetKey): boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Checks if given crypto asset is USD-like
|
|
25
|
-
* @param key The key of crypto asset
|
|
26
|
-
* @returns True if crypto asset is USD-like
|
|
27
|
-
*/
|
|
28
|
-
export declare function isUsdLikeCryptoAsset(key: CryptoAssetKey): boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Formats crypto asset to balance details (balance in USD and decimals)
|
|
31
|
-
* @param type The type of crypto asset
|
|
32
|
-
* @param balance The balance of crypto asset
|
|
33
|
-
* @param usdConversionRate The USD conversion rate
|
|
34
|
-
* @returns The balance details
|
|
35
|
-
*/
|
|
36
|
-
export declare function mapCryptoAssetToDetails(type: CryptoAssetKey, balance: bigint, usdConversionRate: bigint, usdConversionRateDecimals: number): {
|
|
37
|
-
type: CryptoAssetKey;
|
|
38
|
-
rawBalance: bigint;
|
|
39
|
-
formattedBalance: string;
|
|
40
|
-
usdBalance: number;
|
|
41
|
-
formattedUsdBalance: string;
|
|
42
|
-
};
|
|
43
|
-
export type DetailedCryptoAsset = ReturnType<typeof mapCryptoAssetToDetails>;
|
|
44
|
-
//# sourceMappingURL=cryptoAssets.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cryptoAssets.d.ts","sourceRoot":"","sources":["../../../src/utils/cryptoAssets.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,EAGV,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAIjD,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG,KAAK,GAAG,KAAK,CAAA;AAE3D,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAqFD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,cAAc,eAEjD;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,cAAc,WAE3D;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,cAAc,WAEvD;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,MAAM,EACf,iBAAiB,EAAE,MAAM,EACzB,yBAAyB,EAAE,MAAM;;;;;;EA0BlC;AAED,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAA"}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { BitcoinCircle, EthCircle, MUsdCircle02, Cryptocurrency04, } from "@mezo-org/mezo-clay";
|
|
2
|
-
import { convertToUsd, formatUsd } from "./currency";
|
|
3
|
-
import { fromFixedPointToString } from "./numbers";
|
|
4
|
-
// TODO: Add actual icons for the assets
|
|
5
|
-
const CRYPTO_ASSETS = {
|
|
6
|
-
BTC: {
|
|
7
|
-
name: "Bitcoin",
|
|
8
|
-
symbol: "BTC",
|
|
9
|
-
icon: BitcoinCircle,
|
|
10
|
-
decimals: 18,
|
|
11
|
-
},
|
|
12
|
-
ETH: {
|
|
13
|
-
name: "Ethereum",
|
|
14
|
-
symbol: "ETH",
|
|
15
|
-
icon: EthCircle,
|
|
16
|
-
decimals: 18,
|
|
17
|
-
},
|
|
18
|
-
MUSD: {
|
|
19
|
-
name: "MUSD",
|
|
20
|
-
symbol: "MUSD",
|
|
21
|
-
icon: MUsdCircle02,
|
|
22
|
-
decimals: 18,
|
|
23
|
-
},
|
|
24
|
-
mDAI: {
|
|
25
|
-
name: "mDAI",
|
|
26
|
-
symbol: "mDAI",
|
|
27
|
-
icon: Cryptocurrency04,
|
|
28
|
-
decimals: 18,
|
|
29
|
-
},
|
|
30
|
-
mFBTC: {
|
|
31
|
-
name: "mFBTC",
|
|
32
|
-
symbol: "mFBTC",
|
|
33
|
-
icon: BitcoinCircle,
|
|
34
|
-
decimals: 8,
|
|
35
|
-
},
|
|
36
|
-
mcbBTC: {
|
|
37
|
-
name: "mcbBTC",
|
|
38
|
-
symbol: "mcbBTC",
|
|
39
|
-
icon: BitcoinCircle,
|
|
40
|
-
decimals: 8,
|
|
41
|
-
},
|
|
42
|
-
mSolvBTC: {
|
|
43
|
-
name: "mSolvBTC",
|
|
44
|
-
symbol: "mSolvBTC",
|
|
45
|
-
icon: BitcoinCircle,
|
|
46
|
-
decimals: 18,
|
|
47
|
-
},
|
|
48
|
-
mswBTC: {
|
|
49
|
-
name: "mswBTC",
|
|
50
|
-
symbol: "mswBTC",
|
|
51
|
-
icon: BitcoinCircle,
|
|
52
|
-
decimals: 8,
|
|
53
|
-
},
|
|
54
|
-
mT: {
|
|
55
|
-
name: "mT",
|
|
56
|
-
symbol: "mT",
|
|
57
|
-
icon: Cryptocurrency04,
|
|
58
|
-
decimals: 18,
|
|
59
|
-
},
|
|
60
|
-
mUSDC: {
|
|
61
|
-
name: "mUSDC",
|
|
62
|
-
symbol: "mUSDC",
|
|
63
|
-
icon: Cryptocurrency04,
|
|
64
|
-
decimals: 6,
|
|
65
|
-
},
|
|
66
|
-
mUSDe: {
|
|
67
|
-
name: "mUSDe",
|
|
68
|
-
symbol: "mUSDe",
|
|
69
|
-
icon: Cryptocurrency04,
|
|
70
|
-
decimals: 18,
|
|
71
|
-
},
|
|
72
|
-
mUSDT: {
|
|
73
|
-
name: "mUSDT",
|
|
74
|
-
symbol: "mUSDT",
|
|
75
|
-
icon: Cryptocurrency04,
|
|
76
|
-
decimals: 6,
|
|
77
|
-
},
|
|
78
|
-
mxSolvBTC: {
|
|
79
|
-
name: "mxSolvBTC",
|
|
80
|
-
symbol: "mxSolvBTC",
|
|
81
|
-
icon: BitcoinCircle,
|
|
82
|
-
decimals: 18,
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
/**
|
|
86
|
-
* Gets details of given crypto asset
|
|
87
|
-
* @param key The key of crypto asset
|
|
88
|
-
* @returns The crypto asset details
|
|
89
|
-
*/
|
|
90
|
-
export function getCryptoAsset(key) {
|
|
91
|
-
return CRYPTO_ASSETS[key];
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Checks if given crypto asset is Bitcoin-like
|
|
95
|
-
* @param key The key of crypto asset
|
|
96
|
-
* @returns True if crypto asset is Bitcoin-like
|
|
97
|
-
*/
|
|
98
|
-
export function isBitcoinLikeCryptoAsset(key) {
|
|
99
|
-
return /(btc)/i.test(key);
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Checks if given crypto asset is USD-like
|
|
103
|
-
* @param key The key of crypto asset
|
|
104
|
-
* @returns True if crypto asset is USD-like
|
|
105
|
-
*/
|
|
106
|
-
export function isUsdLikeCryptoAsset(key) {
|
|
107
|
-
return /(usd|dai)/i.test(key);
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Formats crypto asset to balance details (balance in USD and decimals)
|
|
111
|
-
* @param type The type of crypto asset
|
|
112
|
-
* @param balance The balance of crypto asset
|
|
113
|
-
* @param usdConversionRate The USD conversion rate
|
|
114
|
-
* @returns The balance details
|
|
115
|
-
*/
|
|
116
|
-
export function mapCryptoAssetToDetails(type, balance, usdConversionRate, usdConversionRateDecimals) {
|
|
117
|
-
const { decimals } = getCryptoAsset(type);
|
|
118
|
-
const formattedBalance = fromFixedPointToString(balance, decimals, isUsdLikeCryptoAsset(type) ? 2 : 4);
|
|
119
|
-
const usdBalance = convertToUsd(balance, decimals, usdConversionRate, usdConversionRateDecimals);
|
|
120
|
-
const formattedUsdBalance = formatUsd(usdBalance);
|
|
121
|
-
return {
|
|
122
|
-
type,
|
|
123
|
-
rawBalance: balance,
|
|
124
|
-
formattedBalance,
|
|
125
|
-
usdBalance,
|
|
126
|
-
formattedUsdBalance,
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
//# sourceMappingURL=cryptoAssets.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cryptoAssets.js","sourceRoot":"","sources":["../../../src/utils/cryptoAssets.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,SAAS,EAET,YAAY,EACZ,gBAAgB,GACjB,MAAM,qBAAqB,CAAA;AAG5B,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAA;AAWlD,wCAAwC;AAExC,MAAM,aAAa,GAAwC;IACzD,GAAG,EAAE;QACH,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,aAAa;QACnB,QAAQ,EAAE,EAAE;KACb;IACD,GAAG,EAAE;QACH,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,EAAE;KACb;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,YAAY;QAClB,QAAQ,EAAE,EAAE;KACb;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,gBAAgB;QACtB,QAAQ,EAAE,EAAE;KACb;IACD,KAAK,EAAE;QACL,IAAI,EAAE,OAAO;QACb,MAAM,EAAE,OAAO;QACf,IAAI,EAAE,aAAa;QACnB,QAAQ,EAAE,CAAC;KACZ;IACD,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,aAAa;QACnB,QAAQ,EAAE,CAAC;KACZ;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,UAAU;QAClB,IAAI,EAAE,aAAa;QACnB,QAAQ,EAAE,EAAE;KACb;IACD,M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AEzC,MAAM,gBAAgB,GAAG,sBAAsB,CAC7C,OAAO,EACP,QAAQ,EACR,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CACnC,CAAA;IAED,MAAM,UAAU,GAAG,YAAY,CAC7B,OAAO,EACP,QAAQ,EACR,iBAAiB,EACjB,yBAAyB,CAC1B,CAAA;IAED,MAAM,mBAAmB,GAAG,SAAS,CAAC,UAAU,CAAC,CAAA;IAEjD,OAAO;QACL,IAAI;QACJ,UAAU,EAAE,OAAO;QACnB,gBAAgB;QAChB,UAAU;QACV,mBAAmB;KACpB,CAAA;AACH,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cryptoAssets.test.d.ts","sourceRoot":"","sources":["../../../src/utils/cryptoAssets.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { BitcoinCircle, EthCircle, MUsdCircle02 } from "@mezo-org/mezo-clay";
|
|
2
|
-
import { getCryptoAsset, isBitcoinLikeCryptoAsset, isUsdLikeCryptoAsset, } from "./cryptoAssets";
|
|
3
|
-
// FIXME: Test fails if run in full suite (pnpm test) but works when run in isolation (pnpm test cryptoAssets)
|
|
4
|
-
describe("getCryptoAsset", () => {
|
|
5
|
-
it("returns the correct asset for 'BTC (mBTC)'", () => {
|
|
6
|
-
const asset = getCryptoAsset("BTC");
|
|
7
|
-
expect(asset.name).toBe("Bitcoin");
|
|
8
|
-
expect(asset.symbol).toBe("BTC");
|
|
9
|
-
expect(asset.decimals).toBe(18);
|
|
10
|
-
expect(asset.icon).toBe(BitcoinCircle);
|
|
11
|
-
});
|
|
12
|
-
it("returns the correct asset for 'ETH'", () => {
|
|
13
|
-
const asset = getCryptoAsset("ETH");
|
|
14
|
-
expect(asset.name).toBe("Ethereum");
|
|
15
|
-
expect(asset.symbol).toBe("ETH");
|
|
16
|
-
expect(asset.decimals).toBe(18);
|
|
17
|
-
expect(asset.icon).toBe(EthCircle);
|
|
18
|
-
});
|
|
19
|
-
it("returns the correct asset for 'MUSD'", () => {
|
|
20
|
-
const asset = getCryptoAsset("MUSD");
|
|
21
|
-
expect(asset.name).toBe("MUSD");
|
|
22
|
-
expect(asset.symbol).toBe("MUSD");
|
|
23
|
-
expect(asset.decimals).toBe(18);
|
|
24
|
-
expect(asset.icon).toBe(MUsdCircle02);
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
describe("isBitcoinLikeCryptoAsset", () => {
|
|
28
|
-
const cases = [
|
|
29
|
-
{ input: "mcbBTC", expected: true },
|
|
30
|
-
{ input: "mDAI", expected: false },
|
|
31
|
-
{ input: "mFBTC", expected: true },
|
|
32
|
-
{ input: "mSolvBTC", expected: true },
|
|
33
|
-
{ input: "mswBTC", expected: true },
|
|
34
|
-
{ input: "mT", expected: false },
|
|
35
|
-
{ input: "mUSDC", expected: false },
|
|
36
|
-
{ input: "mUSDe", expected: false },
|
|
37
|
-
{ input: "mUSDT", expected: false },
|
|
38
|
-
{ input: "mxSolvBTC", expected: true },
|
|
39
|
-
{ input: "MUSD", expected: false },
|
|
40
|
-
];
|
|
41
|
-
cases.forEach(({ input, expected }) => {
|
|
42
|
-
it(`returns ${expected} for ${input}`, () => {
|
|
43
|
-
expect(isBitcoinLikeCryptoAsset(input)).toBe(expected);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
describe("isUsdLikeCryptoAsset", () => {
|
|
48
|
-
const cases = [
|
|
49
|
-
{ input: "mcbBTC", expected: false },
|
|
50
|
-
{ input: "mDAI", expected: true },
|
|
51
|
-
{ input: "mFBTC", expected: false },
|
|
52
|
-
{ input: "mSolvBTC", expected: false },
|
|
53
|
-
{ input: "mswBTC", expected: false },
|
|
54
|
-
{ input: "mT", expected: false },
|
|
55
|
-
{ input: "mUSDC", expected: true },
|
|
56
|
-
{ input: "mUSDe", expected: true },
|
|
57
|
-
{ input: "mUSDT", expected: true },
|
|
58
|
-
{ input: "mxSolvBTC", expected: false },
|
|
59
|
-
{ input: "MUSD", expected: true },
|
|
60
|
-
];
|
|
61
|
-
cases.forEach(({ input, expected }) => {
|
|
62
|
-
it(`returns ${expected} for ${input}`, () => {
|
|
63
|
-
expect(isUsdLikeCryptoAsset(input)).toBe(expected);
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
//# sourceMappingURL=cryptoAssets.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cryptoAssets.test.js","sourceRoot":"","sources":["../../../src/utils/cryptoAssets.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAC5E,OAAO,EAEL,cAAc,EACd,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,gBAAgB,CAAA;AAEvB,8GAA8G;AAE9G,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACpD,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC,CAAA;QACnC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QAClC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAChC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAC/B,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;IACxC,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC7C,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC,CAAA;QACnC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;Q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AE,KAAK,EAAE;QACvC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;KAClC,CAAA;IAED,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;QACpC,EAAE,CAAC,WAAW,QAAQ,QAAQ,KAAK,EAAE,EAAE,GAAG,EAAE;YAC1C,MAAM,CAAC,oBAAoB,CAAC,KAAuB,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACtE,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React from "react"
|
|
2
|
-
import { CryptoAssetKey, getCryptoAsset } from "../../../utils/cryptoAssets"
|
|
3
|
-
import ListingItem from "../ListingItem"
|
|
4
|
-
|
|
5
|
-
type AccountAssetItemProps = {
|
|
6
|
-
type: CryptoAssetKey
|
|
7
|
-
amount: string
|
|
8
|
-
subLabel: string
|
|
9
|
-
subValue: string
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export default function AccountAssetItem(props: AccountAssetItemProps) {
|
|
13
|
-
const { type, amount, subLabel, subValue } = props
|
|
14
|
-
|
|
15
|
-
const { icon: Icon, name: label } = getCryptoAsset(type)
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<ListingItem
|
|
19
|
-
icon={Icon}
|
|
20
|
-
label={label}
|
|
21
|
-
subLabel={subLabel}
|
|
22
|
-
value={amount}
|
|
23
|
-
subValue={subValue}
|
|
24
|
-
/>
|
|
25
|
-
)
|
|
26
|
-
}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { useBalance } from "wagmi"
|
|
2
|
-
import { useGetCurrentAccount } from "."
|
|
3
|
-
import {
|
|
4
|
-
CryptoAssetKey,
|
|
5
|
-
getCryptoAsset,
|
|
6
|
-
isBitcoinLikeCryptoAsset,
|
|
7
|
-
mapCryptoAssetToDetails,
|
|
8
|
-
} from "../utils/cryptoAssets"
|
|
9
|
-
import { fromFixedPoint } from "../utils/numbers"
|
|
10
|
-
import { useAssetsConversionRates } from "./useAssetsConversionRates"
|
|
11
|
-
import useWalletAccount from "./useWalletAccount"
|
|
12
|
-
import { useTokensBalances } from "./useTokensBalances"
|
|
13
|
-
import { useBorrowData } from "./useBorrowData"
|
|
14
|
-
import { CHAIN_ID } from "../constants"
|
|
15
|
-
import { usePassportContext } from "./usePassportContext"
|
|
16
|
-
import { useWatchTransferEventsForAllTokens } from "./useWatchTransferEvents"
|
|
17
|
-
import { convertToUsd } from "../utils/currency"
|
|
18
|
-
|
|
19
|
-
export type DropdownCryptoAsset<T = CryptoAssetKey> = {
|
|
20
|
-
type: T
|
|
21
|
-
balance: bigint
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const DEFAULT_ASSET_DATA = {
|
|
25
|
-
rawBalance: 0n,
|
|
26
|
-
formattedBalance: "0.0000",
|
|
27
|
-
usdBalance: 0,
|
|
28
|
-
formattedUsdBalance: "$0.00",
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Aggregates dropdown data for Dropdown component.
|
|
33
|
-
* @param {accountDataRefetchInterval: number, nativeBalanceRefetchInterval: number }
|
|
34
|
-
* Object containing refetch intervals time (in milliseconds) for account data
|
|
35
|
-
* (like mats or mezo id) and for native balance. After that time the specific
|
|
36
|
-
* value should be marked as stale and re-fetched. Default value for both is
|
|
37
|
-
* 90000 (90 secs).
|
|
38
|
-
* @returns Dropdown data.
|
|
39
|
-
* @dev This hook is for internal use only.
|
|
40
|
-
*/
|
|
41
|
-
export default function useDropdownData({
|
|
42
|
-
accountDataRefetchInterval = 90000,
|
|
43
|
-
nativeBalanceRefetchInterval = 90000,
|
|
44
|
-
}) {
|
|
45
|
-
const {
|
|
46
|
-
walletAddress,
|
|
47
|
-
accountAddress,
|
|
48
|
-
networkFamily: walletType,
|
|
49
|
-
} = useWalletAccount()
|
|
50
|
-
const { environment = "mainnet" } = usePassportContext()
|
|
51
|
-
const { data: btcBalance } = useBalance({
|
|
52
|
-
address: accountAddress,
|
|
53
|
-
chainId: CHAIN_ID[environment],
|
|
54
|
-
query: {
|
|
55
|
-
staleTime: nativeBalanceRefetchInterval,
|
|
56
|
-
refetchInterval: nativeBalanceRefetchInterval,
|
|
57
|
-
},
|
|
58
|
-
})
|
|
59
|
-
const { data: passportAccount } = useGetCurrentAccount({
|
|
60
|
-
staleTime: accountDataRefetchInterval,
|
|
61
|
-
refetchInterval: accountDataRefetchInterval,
|
|
62
|
-
enabled: !!accountAddress,
|
|
63
|
-
})
|
|
64
|
-
const { data: assetsConversionRates } = useAssetsConversionRates()
|
|
65
|
-
const { data: tokensBalances } = useTokensBalances()
|
|
66
|
-
const { data: debt } = useBorrowData()
|
|
67
|
-
|
|
68
|
-
useWatchTransferEventsForAllTokens()
|
|
69
|
-
|
|
70
|
-
const mezoId = passportAccount?.mezoId
|
|
71
|
-
|
|
72
|
-
const detailedAssets = [
|
|
73
|
-
["BTC", btcBalance?.value ?? 0n],
|
|
74
|
-
...Object.entries(tokensBalances ?? {}),
|
|
75
|
-
].map((asset) => {
|
|
76
|
-
const [type, balance] = asset as [CryptoAssetKey, bigint]
|
|
77
|
-
|
|
78
|
-
if (isBitcoinLikeCryptoAsset(type)) {
|
|
79
|
-
return mapCryptoAssetToDetails(
|
|
80
|
-
type,
|
|
81
|
-
balance,
|
|
82
|
-
assetsConversionRates.btc.price,
|
|
83
|
-
assetsConversionRates.btc.decimals,
|
|
84
|
-
)
|
|
85
|
-
}
|
|
86
|
-
if (type === "mT") {
|
|
87
|
-
return mapCryptoAssetToDetails(
|
|
88
|
-
type,
|
|
89
|
-
balance,
|
|
90
|
-
assetsConversionRates.t.price,
|
|
91
|
-
assetsConversionRates.t.decimals,
|
|
92
|
-
)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return mapCryptoAssetToDetails(type, balance, 1n, 0)
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
const btcData = detailedAssets.find(({ type }) => type === "BTC")!
|
|
99
|
-
const musdData = detailedAssets.find(({ type }) => type === "MUSD")!
|
|
100
|
-
const otherAssetsData = detailedAssets.filter(
|
|
101
|
-
({ type }) => !["BTC", "MUSD"].includes(type),
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
const otherAssetsCount = otherAssetsData.filter(
|
|
105
|
-
(asset) => asset.rawBalance !== 0n,
|
|
106
|
-
).length
|
|
107
|
-
|
|
108
|
-
const assets = {
|
|
109
|
-
btc: btcData || {
|
|
110
|
-
type: "BTC",
|
|
111
|
-
...DEFAULT_ASSET_DATA,
|
|
112
|
-
},
|
|
113
|
-
musd: musdData || {
|
|
114
|
-
type: "mUSD",
|
|
115
|
-
...DEFAULT_ASSET_DATA,
|
|
116
|
-
},
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const otherAssetsUsdTotal = otherAssetsData.reduce(
|
|
120
|
-
(sum, { usdBalance }) => sum + usdBalance,
|
|
121
|
-
0,
|
|
122
|
-
)
|
|
123
|
-
|
|
124
|
-
const matsBalance = passportAccount?.mats.totalMats || 0
|
|
125
|
-
|
|
126
|
-
const usdCollateral = convertToUsd(
|
|
127
|
-
debt?.collateral ?? 0n,
|
|
128
|
-
getCryptoAsset("MUSD").decimals,
|
|
129
|
-
assetsConversionRates.btc.price,
|
|
130
|
-
assetsConversionRates.btc.decimals,
|
|
131
|
-
)
|
|
132
|
-
|
|
133
|
-
const usdTroveDebt = fromFixedPoint(debt?.troveDebt ?? 0n, 18)
|
|
134
|
-
|
|
135
|
-
const usdTotalBalance =
|
|
136
|
-
detailedAssets.reduce((sum, { usdBalance }) => sum + usdBalance, 0) +
|
|
137
|
-
usdCollateral
|
|
138
|
-
|
|
139
|
-
return {
|
|
140
|
-
mezoId,
|
|
141
|
-
matsBalance,
|
|
142
|
-
accountAddress,
|
|
143
|
-
walletAddress,
|
|
144
|
-
walletType,
|
|
145
|
-
usdTotalBalance,
|
|
146
|
-
usdTroveDebt,
|
|
147
|
-
usdCollateral,
|
|
148
|
-
assets,
|
|
149
|
-
otherAssetsCount,
|
|
150
|
-
otherAssetsUsdTotal,
|
|
151
|
-
}
|
|
152
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { BitcoinCircle, EthCircle, MUsdCircle02 } from "@mezo-org/mezo-clay"
|
|
2
|
-
import {
|
|
3
|
-
CryptoAssetKey,
|
|
4
|
-
getCryptoAsset,
|
|
5
|
-
isBitcoinLikeCryptoAsset,
|
|
6
|
-
isUsdLikeCryptoAsset,
|
|
7
|
-
} from "./cryptoAssets"
|
|
8
|
-
|
|
9
|
-
// FIXME: Test fails if run in full suite (pnpm test) but works when run in isolation (pnpm test cryptoAssets)
|
|
10
|
-
|
|
11
|
-
describe("getCryptoAsset", () => {
|
|
12
|
-
it("returns the correct asset for 'BTC (mBTC)'", () => {
|
|
13
|
-
const asset = getCryptoAsset("BTC")
|
|
14
|
-
expect(asset.name).toBe("Bitcoin")
|
|
15
|
-
expect(asset.symbol).toBe("BTC")
|
|
16
|
-
expect(asset.decimals).toBe(18)
|
|
17
|
-
expect(asset.icon).toBe(BitcoinCircle)
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
it("returns the correct asset for 'ETH'", () => {
|
|
21
|
-
const asset = getCryptoAsset("ETH")
|
|
22
|
-
expect(asset.name).toBe("Ethereum")
|
|
23
|
-
expect(asset.symbol).toBe("ETH")
|
|
24
|
-
expect(asset.decimals).toBe(18)
|
|
25
|
-
expect(asset.icon).toBe(EthCircle)
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
it("returns the correct asset for 'MUSD'", () => {
|
|
29
|
-
const asset = getCryptoAsset("MUSD")
|
|
30
|
-
expect(asset.name).toBe("MUSD")
|
|
31
|
-
expect(asset.symbol).toBe("MUSD")
|
|
32
|
-
expect(asset.decimals).toBe(18)
|
|
33
|
-
expect(asset.icon).toBe(MUsdCircle02)
|
|
34
|
-
})
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
describe("isBitcoinLikeCryptoAsset", () => {
|
|
38
|
-
const cases = [
|
|
39
|
-
{ input: "mcbBTC", expected: true },
|
|
40
|
-
{ input: "mDAI", expected: false },
|
|
41
|
-
{ input: "mFBTC", expected: true },
|
|
42
|
-
{ input: "mSolvBTC", expected: true },
|
|
43
|
-
{ input: "mswBTC", expected: true },
|
|
44
|
-
{ input: "mT", expected: false },
|
|
45
|
-
{ input: "mUSDC", expected: false },
|
|
46
|
-
{ input: "mUSDe", expected: false },
|
|
47
|
-
{ input: "mUSDT", expected: false },
|
|
48
|
-
{ input: "mxSolvBTC", expected: true },
|
|
49
|
-
{ input: "MUSD", expected: false },
|
|
50
|
-
]
|
|
51
|
-
|
|
52
|
-
cases.forEach(({ input, expected }) => {
|
|
53
|
-
it(`returns ${expected} for ${input}`, () => {
|
|
54
|
-
expect(isBitcoinLikeCryptoAsset(input as CryptoAssetKey)).toBe(expected)
|
|
55
|
-
})
|
|
56
|
-
})
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
describe("isUsdLikeCryptoAsset", () => {
|
|
60
|
-
const cases = [
|
|
61
|
-
{ input: "mcbBTC", expected: false },
|
|
62
|
-
{ input: "mDAI", expected: true },
|
|
63
|
-
{ input: "mFBTC", expected: false },
|
|
64
|
-
{ input: "mSolvBTC", expected: false },
|
|
65
|
-
{ input: "mswBTC", expected: false },
|
|
66
|
-
{ input: "mT", expected: false },
|
|
67
|
-
{ input: "mUSDC", expected: true },
|
|
68
|
-
{ input: "mUSDe", expected: true },
|
|
69
|
-
{ input: "mUSDT", expected: true },
|
|
70
|
-
{ input: "mxSolvBTC", expected: false },
|
|
71
|
-
{ input: "MUSD", expected: true },
|
|
72
|
-
]
|
|
73
|
-
|
|
74
|
-
cases.forEach(({ input, expected }) => {
|
|
75
|
-
it(`returns ${expected} for ${input}`, () => {
|
|
76
|
-
expect(isUsdLikeCryptoAsset(input as CryptoAssetKey)).toBe(expected)
|
|
77
|
-
})
|
|
78
|
-
})
|
|
79
|
-
})
|