@mezo-org/passport 0.4.0-dev.82 → 0.4.0-dev.83
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/api/auth.d.ts +1 -1
- package/dist/src/api/auth.d.ts.map +1 -1
- 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 +36 -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 +28 -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 +43 -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 +31 -5
- 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 +2 -2
- 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 -10
- package/dist/src/hooks/useWalletAccount.d.ts.map +1 -1
- package/dist/src/hooks/useWalletAccount.js +22 -19
- 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/api/auth.ts +1 -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 +69 -32
- package/src/components/Dropdown/Root/AccountAddressActions.tsx +64 -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 +95 -89
- package/src/components/Dropdown/Root/WelcomeBlock.tsx +109 -29
- 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 +27 -36
- 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,171 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BitcoinCircle,
|
|
3
|
-
EthCircle,
|
|
4
|
-
IconProps,
|
|
5
|
-
MUsdCircle02,
|
|
6
|
-
Cryptocurrency04,
|
|
7
|
-
} from "@mezo-org/mezo-clay"
|
|
8
|
-
import { FC } from "react"
|
|
9
|
-
import { MezoChainToken } from "../lib/contracts"
|
|
10
|
-
import { convertToUsd, formatUsd } from "./currency"
|
|
11
|
-
import { fromFixedPointToString } from "./numbers"
|
|
12
|
-
|
|
13
|
-
export type CryptoAssetKey = MezoChainToken | "BTC" | "ETH"
|
|
14
|
-
|
|
15
|
-
export type CryptoAsset = {
|
|
16
|
-
name: string
|
|
17
|
-
symbol: string
|
|
18
|
-
icon: FC<IconProps>
|
|
19
|
-
decimals: number
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// TODO: Add actual icons for the assets
|
|
23
|
-
|
|
24
|
-
const CRYPTO_ASSETS: Record<CryptoAssetKey, CryptoAsset> = {
|
|
25
|
-
BTC: {
|
|
26
|
-
name: "Bitcoin",
|
|
27
|
-
symbol: "BTC",
|
|
28
|
-
icon: BitcoinCircle,
|
|
29
|
-
decimals: 18,
|
|
30
|
-
},
|
|
31
|
-
ETH: {
|
|
32
|
-
name: "Ethereum",
|
|
33
|
-
symbol: "ETH",
|
|
34
|
-
icon: EthCircle,
|
|
35
|
-
decimals: 18,
|
|
36
|
-
},
|
|
37
|
-
MUSD: {
|
|
38
|
-
name: "MUSD",
|
|
39
|
-
symbol: "MUSD",
|
|
40
|
-
icon: MUsdCircle02,
|
|
41
|
-
decimals: 18,
|
|
42
|
-
},
|
|
43
|
-
mDAI: {
|
|
44
|
-
name: "mDAI",
|
|
45
|
-
symbol: "mDAI",
|
|
46
|
-
icon: Cryptocurrency04,
|
|
47
|
-
decimals: 18,
|
|
48
|
-
},
|
|
49
|
-
mFBTC: {
|
|
50
|
-
name: "mFBTC",
|
|
51
|
-
symbol: "mFBTC",
|
|
52
|
-
icon: BitcoinCircle,
|
|
53
|
-
decimals: 8,
|
|
54
|
-
},
|
|
55
|
-
mcbBTC: {
|
|
56
|
-
name: "mcbBTC",
|
|
57
|
-
symbol: "mcbBTC",
|
|
58
|
-
icon: BitcoinCircle,
|
|
59
|
-
decimals: 8,
|
|
60
|
-
},
|
|
61
|
-
mSolvBTC: {
|
|
62
|
-
name: "mSolvBTC",
|
|
63
|
-
symbol: "mSolvBTC",
|
|
64
|
-
icon: BitcoinCircle,
|
|
65
|
-
decimals: 18,
|
|
66
|
-
},
|
|
67
|
-
mswBTC: {
|
|
68
|
-
name: "mswBTC",
|
|
69
|
-
symbol: "mswBTC",
|
|
70
|
-
icon: BitcoinCircle,
|
|
71
|
-
decimals: 8,
|
|
72
|
-
},
|
|
73
|
-
mT: {
|
|
74
|
-
name: "mT",
|
|
75
|
-
symbol: "mT",
|
|
76
|
-
icon: Cryptocurrency04,
|
|
77
|
-
decimals: 18,
|
|
78
|
-
},
|
|
79
|
-
mUSDC: {
|
|
80
|
-
name: "mUSDC",
|
|
81
|
-
symbol: "mUSDC",
|
|
82
|
-
icon: Cryptocurrency04,
|
|
83
|
-
decimals: 6,
|
|
84
|
-
},
|
|
85
|
-
mUSDe: {
|
|
86
|
-
name: "mUSDe",
|
|
87
|
-
symbol: "mUSDe",
|
|
88
|
-
icon: Cryptocurrency04,
|
|
89
|
-
decimals: 18,
|
|
90
|
-
},
|
|
91
|
-
mUSDT: {
|
|
92
|
-
name: "mUSDT",
|
|
93
|
-
symbol: "mUSDT",
|
|
94
|
-
icon: Cryptocurrency04,
|
|
95
|
-
decimals: 6,
|
|
96
|
-
},
|
|
97
|
-
mxSolvBTC: {
|
|
98
|
-
name: "mxSolvBTC",
|
|
99
|
-
symbol: "mxSolvBTC",
|
|
100
|
-
icon: BitcoinCircle,
|
|
101
|
-
decimals: 18,
|
|
102
|
-
},
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Gets details of given crypto asset
|
|
107
|
-
* @param key The key of crypto asset
|
|
108
|
-
* @returns The crypto asset details
|
|
109
|
-
*/
|
|
110
|
-
export function getCryptoAsset(key: CryptoAssetKey) {
|
|
111
|
-
return CRYPTO_ASSETS[key]
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Checks if given crypto asset is Bitcoin-like
|
|
116
|
-
* @param key The key of crypto asset
|
|
117
|
-
* @returns True if crypto asset is Bitcoin-like
|
|
118
|
-
*/
|
|
119
|
-
export function isBitcoinLikeCryptoAsset(key: CryptoAssetKey) {
|
|
120
|
-
return /(btc)/i.test(key)
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Checks if given crypto asset is USD-like
|
|
125
|
-
* @param key The key of crypto asset
|
|
126
|
-
* @returns True if crypto asset is USD-like
|
|
127
|
-
*/
|
|
128
|
-
export function isUsdLikeCryptoAsset(key: CryptoAssetKey) {
|
|
129
|
-
return /(usd|dai)/i.test(key)
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Formats crypto asset to balance details (balance in USD and decimals)
|
|
134
|
-
* @param type The type of crypto asset
|
|
135
|
-
* @param balance The balance of crypto asset
|
|
136
|
-
* @param usdConversionRate The USD conversion rate
|
|
137
|
-
* @returns The balance details
|
|
138
|
-
*/
|
|
139
|
-
export function mapCryptoAssetToDetails(
|
|
140
|
-
type: CryptoAssetKey,
|
|
141
|
-
balance: bigint,
|
|
142
|
-
usdConversionRate: bigint,
|
|
143
|
-
usdConversionRateDecimals: number,
|
|
144
|
-
) {
|
|
145
|
-
const { decimals } = getCryptoAsset(type)
|
|
146
|
-
|
|
147
|
-
const formattedBalance = fromFixedPointToString(
|
|
148
|
-
balance,
|
|
149
|
-
decimals,
|
|
150
|
-
isUsdLikeCryptoAsset(type) ? 2 : 4,
|
|
151
|
-
)
|
|
152
|
-
|
|
153
|
-
const usdBalance = convertToUsd(
|
|
154
|
-
balance,
|
|
155
|
-
decimals,
|
|
156
|
-
usdConversionRate,
|
|
157
|
-
usdConversionRateDecimals,
|
|
158
|
-
)
|
|
159
|
-
|
|
160
|
-
const formattedUsdBalance = formatUsd(usdBalance)
|
|
161
|
-
|
|
162
|
-
return {
|
|
163
|
-
type,
|
|
164
|
-
rawBalance: balance,
|
|
165
|
-
formattedBalance,
|
|
166
|
-
usdBalance,
|
|
167
|
-
formattedUsdBalance,
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
export type DetailedCryptoAsset = ReturnType<typeof mapCryptoAssetToDetails>
|