@mezo-org/passport 0.4.0-dev.8 → 0.4.0-dev.80

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.
Files changed (262) hide show
  1. package/README.md +18 -22
  2. package/dist/src/api/auth.d.ts +7 -3
  3. package/dist/src/api/auth.d.ts.map +1 -1
  4. package/dist/src/api/auth.js +3 -1
  5. package/dist/src/api/auth.js.map +1 -1
  6. package/dist/src/api/client.d.ts +4 -1
  7. package/dist/src/api/client.d.ts.map +1 -1
  8. package/dist/src/api/client.js +9 -2
  9. package/dist/src/api/client.js.map +1 -1
  10. package/dist/src/api/portal.d.ts +3 -9
  11. package/dist/src/api/portal.d.ts.map +1 -1
  12. package/dist/src/api/portal.js +8 -5
  13. package/dist/src/api/portal.js.map +1 -1
  14. package/dist/src/components/Dropdown/ConnectedTrigger.d.ts +2 -1
  15. package/dist/src/components/Dropdown/ConnectedTrigger.d.ts.map +1 -1
  16. package/dist/src/components/Dropdown/ConnectedTrigger.js +29 -20
  17. package/dist/src/components/Dropdown/ConnectedTrigger.js.map +1 -1
  18. package/dist/src/components/Dropdown/Content.d.ts +19 -5
  19. package/dist/src/components/Dropdown/Content.d.ts.map +1 -1
  20. package/dist/src/components/Dropdown/Content.js +19 -61
  21. package/dist/src/components/Dropdown/Content.js.map +1 -1
  22. package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts.map +1 -1
  23. package/dist/src/components/Dropdown/DisconnectedTrigger.js +2 -2
  24. package/dist/src/components/Dropdown/DisconnectedTrigger.js.map +1 -1
  25. package/dist/src/components/Dropdown/Dropdown.d.ts +13 -6
  26. package/dist/src/components/Dropdown/Dropdown.d.ts.map +1 -1
  27. package/dist/src/components/Dropdown/Dropdown.js +32 -9
  28. package/dist/src/components/Dropdown/Dropdown.js.map +1 -1
  29. package/dist/src/components/Dropdown/ListingItem.d.ts +13 -0
  30. package/dist/src/components/Dropdown/ListingItem.d.ts.map +1 -0
  31. package/dist/src/components/Dropdown/ListingItem.js +34 -0
  32. package/dist/src/components/Dropdown/ListingItem.js.map +1 -0
  33. package/dist/src/components/Dropdown/NestedViewLayout.d.ts +7 -0
  34. package/dist/src/components/Dropdown/NestedViewLayout.d.ts.map +1 -0
  35. package/dist/src/components/Dropdown/NestedViewLayout.js +34 -0
  36. package/dist/src/components/Dropdown/NestedViewLayout.js.map +1 -0
  37. package/dist/src/components/Dropdown/Receive/Receive.d.ts +7 -0
  38. package/dist/src/components/Dropdown/Receive/Receive.d.ts.map +1 -0
  39. package/dist/src/components/Dropdown/Receive/Receive.js +53 -0
  40. package/dist/src/components/Dropdown/Receive/Receive.js.map +1 -0
  41. package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts +7 -0
  42. package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts.map +1 -0
  43. package/dist/src/components/Dropdown/Root/AccountAddressActions.js +48 -0
  44. package/dist/src/components/Dropdown/Root/AccountAddressActions.js.map +1 -0
  45. package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts +11 -0
  46. package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts.map +1 -0
  47. package/dist/src/components/Dropdown/Root/AccountAssetItem.js +9 -0
  48. package/dist/src/components/Dropdown/Root/AccountAssetItem.js.map +1 -0
  49. package/dist/src/components/Dropdown/{AccountBalance.d.ts → Root/AccountBalance.d.ts} +2 -1
  50. package/dist/src/components/Dropdown/Root/AccountBalance.d.ts.map +1 -0
  51. package/dist/src/components/Dropdown/Root/AccountBalance.js +15 -0
  52. package/dist/src/components/Dropdown/Root/AccountBalance.js.map +1 -0
  53. package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts +9 -0
  54. package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts.map +1 -0
  55. package/dist/src/components/Dropdown/Root/AccountOtherAssets.js +48 -0
  56. package/dist/src/components/Dropdown/Root/AccountOtherAssets.js.map +1 -0
  57. package/dist/src/components/Dropdown/Root/Root.d.ts +23 -0
  58. package/dist/src/components/Dropdown/Root/Root.d.ts.map +1 -0
  59. package/dist/src/components/Dropdown/Root/Root.js +57 -0
  60. package/dist/src/components/Dropdown/Root/Root.js.map +1 -0
  61. package/dist/src/components/Dropdown/Root/WalletAddress.d.ts +8 -0
  62. package/dist/src/components/Dropdown/Root/WalletAddress.d.ts.map +1 -0
  63. package/dist/src/components/Dropdown/{AccountAddress.js → Root/WalletAddress.js} +21 -15
  64. package/dist/src/components/Dropdown/Root/WalletAddress.js.map +1 -0
  65. package/dist/src/components/Dropdown/{WelcomeBlock.d.ts → Root/WelcomeBlock.d.ts} +1 -1
  66. package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts.map +1 -0
  67. package/dist/src/components/Dropdown/{WelcomeBlock.js → Root/WelcomeBlock.js} +5 -5
  68. package/dist/src/components/Dropdown/Root/WelcomeBlock.js.map +1 -0
  69. package/dist/src/components/Dropdown/TestnetTopBanner.d.ts +3 -0
  70. package/dist/src/components/Dropdown/TestnetTopBanner.d.ts.map +1 -0
  71. package/dist/src/components/Dropdown/TestnetTopBanner.js +14 -0
  72. package/dist/src/components/Dropdown/TestnetTopBanner.js.map +1 -0
  73. package/dist/src/config.d.ts +18 -5
  74. package/dist/src/config.d.ts.map +1 -1
  75. package/dist/src/config.js +45 -14
  76. package/dist/src/config.js.map +1 -1
  77. package/dist/src/constants.d.ts +11 -3
  78. package/dist/src/constants.d.ts.map +1 -1
  79. package/dist/src/constants.js +12 -4
  80. package/dist/src/constants.js.map +1 -1
  81. package/dist/src/hooks/index.d.ts +4 -0
  82. package/dist/src/hooks/index.d.ts.map +1 -1
  83. package/dist/src/hooks/index.js +4 -0
  84. package/dist/src/hooks/index.js.map +1 -1
  85. package/dist/src/hooks/useAssetsConversionRates.d.ts +23 -0
  86. package/dist/src/hooks/useAssetsConversionRates.d.ts.map +1 -0
  87. package/dist/src/hooks/useAssetsConversionRates.js +90 -0
  88. package/dist/src/hooks/useAssetsConversionRates.js.map +1 -0
  89. package/dist/src/hooks/useAuthenticateWithWallet.d.ts +13 -13
  90. package/dist/src/hooks/useAuthenticateWithWallet.d.ts.map +1 -1
  91. package/dist/src/hooks/useAuthenticateWithWallet.js +8 -7
  92. package/dist/src/hooks/useAuthenticateWithWallet.js.map +1 -1
  93. package/dist/src/hooks/useBorrowData.d.ts +82 -0
  94. package/dist/src/hooks/useBorrowData.d.ts.map +1 -0
  95. package/dist/src/hooks/useBorrowData.js +159 -0
  96. package/dist/src/hooks/useBorrowData.js.map +1 -0
  97. package/dist/src/hooks/useCreateAccount.d.ts.map +1 -1
  98. package/dist/src/hooks/useCreateAccount.js +22 -1
  99. package/dist/src/hooks/useCreateAccount.js.map +1 -1
  100. package/dist/src/hooks/useDropdownData.d.ts +37 -34
  101. package/dist/src/hooks/useDropdownData.d.ts.map +1 -1
  102. package/dist/src/hooks/useDropdownData.js +85 -61
  103. package/dist/src/hooks/useDropdownData.js.map +1 -1
  104. package/dist/src/hooks/useLinkAccount.d.ts +19 -13
  105. package/dist/src/hooks/useLinkAccount.d.ts.map +1 -1
  106. package/dist/src/hooks/useLinkAccount.js +20 -1
  107. package/dist/src/hooks/useLinkAccount.js.map +1 -1
  108. package/dist/src/hooks/useRefreshPassport.d.ts +19 -0
  109. package/dist/src/hooks/useRefreshPassport.d.ts.map +1 -0
  110. package/dist/src/hooks/useRefreshPassport.js +44 -0
  111. package/dist/src/hooks/useRefreshPassport.js.map +1 -0
  112. package/dist/src/hooks/useSignInWithWallet.d.ts +13 -13
  113. package/dist/src/hooks/useSignInWithWallet.d.ts.map +1 -1
  114. package/dist/src/hooks/useSignUpWithWallet.d.ts +13 -13
  115. package/dist/src/hooks/useSignUpWithWallet.d.ts.map +1 -1
  116. package/dist/src/hooks/useTokensBalances.d.ts +74 -0
  117. package/dist/src/hooks/useTokensBalances.d.ts.map +1 -0
  118. package/dist/src/hooks/useTokensBalances.js +140 -0
  119. package/dist/src/hooks/useTokensBalances.js.map +1 -0
  120. package/dist/src/hooks/useValidateMezoId.d.ts +8 -0
  121. package/dist/src/hooks/useValidateMezoId.d.ts.map +1 -0
  122. package/dist/src/hooks/useValidateMezoId.js +24 -0
  123. package/dist/src/hooks/useValidateMezoId.js.map +1 -0
  124. package/dist/src/hooks/useWalletAccount.d.ts +2 -1
  125. package/dist/src/hooks/useWalletAccount.d.ts.map +1 -1
  126. package/dist/src/hooks/useWalletAccount.js +19 -15
  127. package/dist/src/hooks/useWalletAccount.js.map +1 -1
  128. package/dist/src/hooks/useWatchTransferEvents.d.ts +5 -0
  129. package/dist/src/hooks/useWatchTransferEvents.d.ts.map +1 -0
  130. package/dist/src/hooks/useWatchTransferEvents.js +63 -0
  131. package/dist/src/hooks/useWatchTransferEvents.js.map +1 -0
  132. package/dist/src/index.d.ts +2 -1
  133. package/dist/src/index.d.ts.map +1 -1
  134. package/dist/src/index.js +2 -1
  135. package/dist/src/index.js.map +1 -1
  136. package/dist/src/lib/contracts/index.d.ts +13 -0
  137. package/dist/src/lib/contracts/index.d.ts.map +1 -0
  138. package/dist/src/lib/contracts/index.js +62 -0
  139. package/dist/src/lib/contracts/index.js.map +1 -0
  140. package/dist/src/lib/contracts/priceOracle.d.ts +43 -0
  141. package/dist/src/lib/contracts/priceOracle.d.ts.map +1 -0
  142. package/dist/src/lib/contracts/priceOracle.js +52 -0
  143. package/dist/src/lib/contracts/priceOracle.js.map +1 -0
  144. package/dist/src/provider.js +1 -1
  145. package/dist/src/provider.js.map +1 -1
  146. package/dist/src/stores/dropdownStore.d.ts +12 -0
  147. package/dist/src/stores/dropdownStore.d.ts.map +1 -0
  148. package/dist/src/stores/dropdownStore.js +13 -0
  149. package/dist/src/stores/dropdownStore.js.map +1 -0
  150. package/dist/src/utils/address.d.ts +1 -1
  151. package/dist/src/utils/address.d.ts.map +1 -1
  152. package/dist/src/utils/address.js +2 -0
  153. package/dist/src/utils/address.js.map +1 -1
  154. package/dist/src/utils/address.test.js +8 -5
  155. package/dist/src/utils/address.test.js.map +1 -1
  156. package/dist/src/utils/cryptoAssets.d.ts +17 -1
  157. package/dist/src/utils/cryptoAssets.d.ts.map +1 -1
  158. package/dist/src/utils/cryptoAssets.js +87 -31
  159. package/dist/src/utils/cryptoAssets.js.map +1 -1
  160. package/dist/src/utils/cryptoAssets.test.js +51 -33
  161. package/dist/src/utils/cryptoAssets.test.js.map +1 -1
  162. package/dist/src/utils/currency.d.ts +8 -0
  163. package/dist/src/utils/currency.d.ts.map +1 -1
  164. package/dist/src/utils/currency.js +11 -0
  165. package/dist/src/utils/currency.js.map +1 -1
  166. package/dist/src/utils/currency.test.js +1 -0
  167. package/dist/src/utils/currency.test.js.map +1 -1
  168. package/dist/src/utils/mezoId.d.ts +7 -0
  169. package/dist/src/utils/mezoId.d.ts.map +1 -0
  170. package/dist/src/utils/mezoId.js +41 -0
  171. package/dist/src/utils/mezoId.js.map +1 -0
  172. package/dist/src/utils/numbers.d.ts +39 -17
  173. package/dist/src/utils/numbers.d.ts.map +1 -1
  174. package/dist/src/utils/numbers.js +91 -33
  175. package/dist/src/utils/numbers.js.map +1 -1
  176. package/dist/src/utils/numbers.test.js +144 -22
  177. package/dist/src/utils/numbers.test.js.map +1 -1
  178. package/dist/src/utils/siww.d.ts +1 -0
  179. package/dist/src/utils/siww.d.ts.map +1 -1
  180. package/dist/src/utils/siww.js +50 -12
  181. package/dist/src/utils/siww.js.map +1 -1
  182. package/dist/src/utils/wagmi.d.ts +3 -0
  183. package/dist/src/utils/wagmi.d.ts.map +1 -0
  184. package/dist/src/utils/wagmi.js +7 -0
  185. package/dist/src/utils/wagmi.js.map +1 -0
  186. package/dist/src/wallet/index.d.ts +1 -1
  187. package/dist/src/wallet/index.d.ts.map +1 -1
  188. package/dist/src/wallet/index.js +1 -1
  189. package/dist/src/wallet/index.js.map +1 -1
  190. package/package.json +10 -8
  191. package/src/api/auth.ts +8 -4
  192. package/src/api/client.ts +11 -2
  193. package/src/api/portal.ts +11 -14
  194. package/src/components/Dropdown/ConnectedTrigger.tsx +52 -32
  195. package/src/components/Dropdown/Content.tsx +67 -117
  196. package/src/components/Dropdown/DisconnectedTrigger.tsx +2 -1
  197. package/src/components/Dropdown/Dropdown.tsx +75 -15
  198. package/src/components/Dropdown/ListingItem.tsx +80 -0
  199. package/src/components/Dropdown/NestedViewLayout.tsx +75 -0
  200. package/src/components/Dropdown/README.md +10 -18
  201. package/src/components/Dropdown/Receive/Receive.tsx +119 -0
  202. package/src/components/Dropdown/Root/AccountAddressActions.tsx +101 -0
  203. package/src/components/Dropdown/Root/AccountAssetItem.tsx +26 -0
  204. package/src/components/Dropdown/Root/AccountBalance.tsx +30 -0
  205. package/src/components/Dropdown/Root/AccountOtherAssets.tsx +68 -0
  206. package/src/components/Dropdown/Root/Root.tsx +147 -0
  207. package/src/components/Dropdown/Root/WalletAddress.tsx +128 -0
  208. package/src/components/Dropdown/{WelcomeBlock.tsx → Root/WelcomeBlock.tsx} +5 -6
  209. package/src/components/Dropdown/TestnetTopBanner.tsx +32 -0
  210. package/src/config.ts +73 -20
  211. package/src/constants.ts +12 -4
  212. package/src/hooks/index.ts +7 -0
  213. package/src/hooks/useAssetsConversionRates.ts +97 -0
  214. package/src/hooks/useAuthenticateWithWallet.ts +33 -12
  215. package/src/hooks/useBorrowData.ts +187 -0
  216. package/src/hooks/useCreateAccount.ts +28 -2
  217. package/src/hooks/useDropdownData.ts +119 -97
  218. package/src/hooks/useLinkAccount.ts +36 -4
  219. package/src/hooks/useRefreshPassport.ts +56 -0
  220. package/src/hooks/useSignInWithWallet.ts +2 -2
  221. package/src/hooks/useSignUpWithWallet.ts +2 -2
  222. package/src/hooks/useTokensBalances.ts +187 -0
  223. package/src/hooks/useValidateMezoId.ts +31 -0
  224. package/src/hooks/useWalletAccount.ts +29 -19
  225. package/src/hooks/useWatchTransferEvents.ts +74 -0
  226. package/src/index.ts +12 -1
  227. package/src/lib/contracts/index.ts +92 -0
  228. package/src/lib/contracts/priceOracle.ts +53 -0
  229. package/src/provider.ts +1 -1
  230. package/src/stores/dropdownStore.ts +20 -0
  231. package/src/utils/address.test.ts +10 -6
  232. package/src/utils/address.ts +5 -3
  233. package/src/utils/cryptoAssets.test.ts +57 -37
  234. package/src/utils/cryptoAssets.ts +113 -35
  235. package/src/utils/currency.test.ts +2 -0
  236. package/src/utils/currency.ts +21 -0
  237. package/src/utils/mezoId.ts +51 -0
  238. package/src/utils/numbers.test.ts +181 -23
  239. package/src/utils/numbers.ts +121 -34
  240. package/src/utils/siww.ts +71 -16
  241. package/src/utils/wagmi.ts +12 -0
  242. package/src/wallet/index.ts +3 -2
  243. package/dist/src/components/Dropdown/AccountAddress.d.ts +0 -8
  244. package/dist/src/components/Dropdown/AccountAddress.d.ts.map +0 -1
  245. package/dist/src/components/Dropdown/AccountAddress.js.map +0 -1
  246. package/dist/src/components/Dropdown/AccountAssets.d.ts +0 -14
  247. package/dist/src/components/Dropdown/AccountAssets.d.ts.map +0 -1
  248. package/dist/src/components/Dropdown/AccountAssets.js +0 -44
  249. package/dist/src/components/Dropdown/AccountAssets.js.map +0 -1
  250. package/dist/src/components/Dropdown/AccountBalance.d.ts.map +0 -1
  251. package/dist/src/components/Dropdown/AccountBalance.js +0 -18
  252. package/dist/src/components/Dropdown/AccountBalance.js.map +0 -1
  253. package/dist/src/components/Dropdown/WelcomeBlock.d.ts.map +0 -1
  254. package/dist/src/components/Dropdown/WelcomeBlock.js.map +0 -1
  255. package/dist/src/hooks/useAssetsUSDConversion.d.ts +0 -8
  256. package/dist/src/hooks/useAssetsUSDConversion.d.ts.map +0 -1
  257. package/dist/src/hooks/useAssetsUSDConversion.js +0 -21
  258. package/dist/src/hooks/useAssetsUSDConversion.js.map +0 -1
  259. package/src/components/Dropdown/AccountAddress.tsx +0 -111
  260. package/src/components/Dropdown/AccountAssets.tsx +0 -110
  261. package/src/components/Dropdown/AccountBalance.tsx +0 -38
  262. package/src/hooks/useAssetsUSDConversion.ts +0 -31
@@ -1,32 +1,33 @@
1
1
  import { useSignMessage } from "wagmi";
2
- import { useMutation } from "@tanstack/react-query";
2
+ import { useMutation, } from "@tanstack/react-query";
3
3
  import { useCreateAccount } from "./useCreateAccount";
4
4
  import { useCreateSession } from "./useCreateSession";
5
5
  import { useEnsureNoSessionAndFetchNonce } from "./useEnsureNoSessionAndFetchNonce";
6
- import { createSignInWithWalletMessage } from "../utils/siww";
6
+ import { createSignInWithWalletMessage, verifyDomainInSignInWithWalletMessage, } from "../utils/siww";
7
7
  import { useGetAccountByAddress } from "./useGetAccountByAddress";
8
8
  import useWalletAccount from "./useWalletAccount";
9
9
  function useAuthenticateWithWallet(shouldCreateAccount = false, mutationOptions = {}) {
10
- const { address, chainId, connector, networkFamily } = useWalletAccount();
10
+ const { walletAddress, chainId: walletChainId, connector, networkFamily, } = useWalletAccount();
11
11
  const { ensureNoSessionAndFetchNonce } = useEnsureNoSessionAndFetchNonce();
12
12
  const { createSessionAsync } = useCreateSession();
13
13
  const { createAccountAsync } = useCreateAccount();
14
14
  const { signMessageAsync } = useSignMessage();
15
- const { refetch: getAccountByAddress } = useGetAccountByAddress(address, {
15
+ const { refetch: getAccountByAddress } = useGetAccountByAddress(walletAddress, {
16
16
  enabled: false,
17
17
  retry: false,
18
18
  });
19
19
  const { mutate, mutateAsync, ...signInMutationRestParameters } = useMutation({
20
- mutationFn: async () => {
21
- if (!address) {
20
+ mutationFn: async (chainId) => {
21
+ if (!walletAddress) {
22
22
  throw new Error("Sign in error: Wallet not connected!");
23
23
  }
24
24
  const nonce = await ensureNoSessionAndFetchNonce();
25
- const messageResult = createSignInWithWalletMessage(address, nonce, networkFamily, chainId);
25
+ const messageResult = createSignInWithWalletMessage(walletAddress, nonce, networkFamily, chainId ?? walletChainId);
26
26
  const signatureResult = await signMessageAsync({
27
27
  message: messageResult,
28
28
  connector,
29
29
  });
30
+ await verifyDomainInSignInWithWalletMessage(messageResult, signatureResult, nonce);
30
31
  if (shouldCreateAccount) {
31
32
  const getAccountByAddressResult = await getAccountByAddress();
32
33
  if (getAccountByAddressResult.data) {
@@ -1 +1 @@
1
- {"version":3,"file":"useAu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kB,CAAC;gBAC/B,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,aAAa;gBACtB,SAAS,EAAE,eAAe;aAC3B,CAAC,CAAY,CAAA;YACd,0EAA0E;QAC5E,CAAC;QACD,GAAG,eAAe;KACnB,CAAC,CAAA;IAEF,OAAO;QACL,sBAAsB,EAAE,MAAM;QAC9B,2BAA2B,EAAE,WAAW;QACxC,GAAG,4BAA4B;KAChC,CAAA;AACH,CAAC;AAED,OAAO,EAAE,yBAAyB,EAAE,CAAA"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Query hook for getting borrow data. Returns collateral and trove debt for the
3
+ * connected account, based on it's evm address.
4
+ * @param queryOptions Query options passed to the underlying `useQuery` hook.
5
+ */
6
+ export declare function useBorrowData(queryOptions?: {}): import("wagmi").UseReadContractsReturnType<readonly [{
7
+ readonly abi: readonly [{
8
+ readonly inputs: readonly [{
9
+ readonly internalType: "address";
10
+ readonly name: "_borrower";
11
+ readonly type: "address";
12
+ }];
13
+ readonly name: "getEntireDebtAndColl";
14
+ readonly outputs: readonly [{
15
+ readonly internalType: "uint256";
16
+ readonly name: "coll";
17
+ readonly type: "uint256";
18
+ }, {
19
+ readonly internalType: "uint256";
20
+ readonly name: "principal";
21
+ readonly type: "uint256";
22
+ }, {
23
+ readonly internalType: "uint256";
24
+ readonly name: "interest";
25
+ readonly type: "uint256";
26
+ }, {
27
+ readonly internalType: "uint256";
28
+ readonly name: "pendingCollateral";
29
+ readonly type: "uint256";
30
+ }, {
31
+ readonly internalType: "uint256";
32
+ readonly name: "pendingPrincipal";
33
+ readonly type: "uint256";
34
+ }, {
35
+ readonly internalType: "uint256";
36
+ readonly name: "pendingInterest";
37
+ readonly type: "uint256";
38
+ }];
39
+ readonly stateMutability: "view";
40
+ readonly type: "function";
41
+ }];
42
+ readonly address: `0x${string}`;
43
+ readonly functionName: "getEntireDebtAndColl";
44
+ readonly args: [`0x${string}`];
45
+ readonly chainId: number;
46
+ }, {
47
+ readonly abi: readonly [{
48
+ readonly inputs: readonly [];
49
+ readonly name: "MUSD_GAS_COMPENSATION";
50
+ readonly outputs: readonly [{
51
+ readonly internalType: "uint256";
52
+ readonly name: "";
53
+ readonly type: "uint256";
54
+ }];
55
+ readonly stateMutability: "view";
56
+ readonly type: "function";
57
+ }];
58
+ readonly address: `0x${string}`;
59
+ readonly functionName: "MUSD_GAS_COMPENSATION";
60
+ readonly args: [];
61
+ readonly chainId: number;
62
+ }], true, {
63
+ collateral: bigint;
64
+ troveDebt: bigint;
65
+ } | undefined>;
66
+ /**
67
+ * Hook for for invalidating current user's borrow data. Can be used to
68
+ * invalidate borrow data manually, which forces the data to be re-fetched.
69
+ * @returns Function `invalidateBorrowData` for invalidating the borrow data
70
+ */
71
+ export declare function useInvalidateBorrowData(): {
72
+ invalidateBorrowData: () => Promise<void>;
73
+ };
74
+ /**
75
+ * Hook for for resetting current user's borrow data. Can be used to reset
76
+ * borrow data manually, which forces the data to be re-fetched.
77
+ * @returns Function `resetBorrowData` for resetting the borrow data
78
+ */
79
+ export declare function useResetBorrowData(): {
80
+ resetBorrowData: () => Promise<void>;
81
+ };
82
+ //# sourceMappingURL=useBorrowData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBorrowData.d.ts","sourceRoot":"","sources":["../../../src/hooks/useBorrowData.ts"],"names":[],"mappings":"AAiFA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,YAAY,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA4D9C;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB;;EAatC;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB;;EAajC"}
@@ -0,0 +1,159 @@
1
+ import { useAccount, useReadContracts } from "wagmi";
2
+ import { useCallback, useMemo } from "react";
3
+ import { useQueryClient } from "@tanstack/react-query";
4
+ import { ONE_MINUTE_MS } from "../utils/time";
5
+ import { mainnetBorrowContracts, testnetBorrowContracts, } from "../lib/contracts";
6
+ import { usePassportContext } from "./usePassportContext";
7
+ import { CHAIN_ID } from "../constants";
8
+ import { bigIntMax } from "../utils/numbers";
9
+ // Wagmi handles typesafety with ABI const assertions. TypeScript doesn't
10
+ // support importing JSON as const yet so types cannot be inferred from the
11
+ // imported contract. As a workaround there is minimal ABI definition that can
12
+ // be asserted types from.
13
+ // Ref: https://wagmi.sh/core/typescript#const-assert-abis-typed-data
14
+ const TROVE_MANAGER_ABI = [
15
+ {
16
+ inputs: [
17
+ {
18
+ internalType: "address",
19
+ name: "_borrower",
20
+ type: "address",
21
+ },
22
+ ],
23
+ name: "getEntireDebtAndColl",
24
+ outputs: [
25
+ {
26
+ internalType: "uint256",
27
+ name: "coll",
28
+ type: "uint256",
29
+ },
30
+ {
31
+ internalType: "uint256",
32
+ name: "principal",
33
+ type: "uint256",
34
+ },
35
+ {
36
+ internalType: "uint256",
37
+ name: "interest",
38
+ type: "uint256",
39
+ },
40
+ {
41
+ internalType: "uint256",
42
+ name: "pendingCollateral",
43
+ type: "uint256",
44
+ },
45
+ {
46
+ internalType: "uint256",
47
+ name: "pendingPrincipal",
48
+ type: "uint256",
49
+ },
50
+ {
51
+ internalType: "uint256",
52
+ name: "pendingInterest",
53
+ type: "uint256",
54
+ },
55
+ ],
56
+ stateMutability: "view",
57
+ type: "function",
58
+ },
59
+ ];
60
+ const BORROWER_OPERATIONS_ABI = [
61
+ {
62
+ inputs: [],
63
+ name: "MUSD_GAS_COMPENSATION",
64
+ outputs: [
65
+ {
66
+ internalType: "uint256",
67
+ name: "",
68
+ type: "uint256",
69
+ },
70
+ ],
71
+ stateMutability: "view",
72
+ type: "function",
73
+ },
74
+ ];
75
+ /**
76
+ * Query hook for getting borrow data. Returns collateral and trove debt for the
77
+ * connected account, based on it's evm address.
78
+ * @param queryOptions Query options passed to the underlying `useQuery` hook.
79
+ */
80
+ export function useBorrowData(queryOptions = {}) {
81
+ const { environment = "mainnet" } = usePassportContext();
82
+ const { address } = useAccount();
83
+ const contractAddress = useMemo(() => {
84
+ if (environment === "mainnet") {
85
+ return {
86
+ troveManager: mainnetBorrowContracts.TroveManager.address,
87
+ borrowerOperations: mainnetBorrowContracts.BorrowerOperations.address,
88
+ };
89
+ }
90
+ return {
91
+ troveManager: testnetBorrowContracts.TroveManager.address,
92
+ borrowerOperations: testnetBorrowContracts.BorrowerOperations.address,
93
+ };
94
+ }, [environment]);
95
+ const chainId = CHAIN_ID[environment];
96
+ return useReadContracts({
97
+ contracts: [
98
+ {
99
+ abi: TROVE_MANAGER_ABI,
100
+ address: contractAddress.troveManager,
101
+ functionName: "getEntireDebtAndColl",
102
+ args: [address || "0x"],
103
+ chainId,
104
+ },
105
+ {
106
+ abi: BORROWER_OPERATIONS_ABI,
107
+ address: contractAddress.borrowerOperations,
108
+ functionName: "MUSD_GAS_COMPENSATION",
109
+ args: [],
110
+ chainId,
111
+ },
112
+ ],
113
+ query: {
114
+ enabled: !!address,
115
+ staleTime: 5 * ONE_MINUTE_MS,
116
+ retry: 1,
117
+ select: (data) => {
118
+ if (!data || data.some((item) => !item.result))
119
+ return undefined;
120
+ const [collateral, principal, interest] = data[0].result;
121
+ const gasCompensation = data[1].result;
122
+ const troveDebt = bigIntMax(principal + interest - gasCompensation, 0n);
123
+ return {
124
+ collateral,
125
+ // Principal includes gas compensation value which is not
126
+ troveDebt,
127
+ };
128
+ },
129
+ ...queryOptions,
130
+ },
131
+ });
132
+ }
133
+ /**
134
+ * Hook for for invalidating current user's borrow data. Can be used to
135
+ * invalidate borrow data manually, which forces the data to be re-fetched.
136
+ * @returns Function `invalidateBorrowData` for invalidating the borrow data
137
+ */
138
+ export function useInvalidateBorrowData() {
139
+ const queryClient = useQueryClient();
140
+ const { queryKey } = useBorrowData();
141
+ const invalidateBorrowDataHandler = useCallback(() => queryClient.invalidateQueries({ queryKey }), [queryClient, queryKey]);
142
+ return {
143
+ invalidateBorrowData: invalidateBorrowDataHandler,
144
+ };
145
+ }
146
+ /**
147
+ * Hook for for resetting current user's borrow data. Can be used to reset
148
+ * borrow data manually, which forces the data to be re-fetched.
149
+ * @returns Function `resetBorrowData` for resetting the borrow data
150
+ */
151
+ export function useResetBorrowData() {
152
+ const queryClient = useQueryClient();
153
+ const { queryKey } = useBorrowData();
154
+ const resetBorrowDataHandler = useCallback(() => queryClient.resetQueries({ queryKey }), [queryClient, queryKey]);
155
+ return {
156
+ resetBorrowData: resetBorrowDataHandler,
157
+ };
158
+ }
159
+ //# sourceMappingURL=useBorrowData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBorrowData.js","sourceRoot":"","sources":["../../../src/hooks/useBorrowData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EACL,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAE5C,yEAAyE;AACzE,2EAA2E;AAC3E,8EAA8E;AAC9E,0BAA0B;AAC1B,qEAAqE;AAErE,MAAM,iBAAiB,GAAG;IACxB;QACE,MAAM,EAAE;YACN;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,SAAS;aAChB;SACF;QACD,IAAI,EAAE,sBAAsB;QAC5B,OAAO,EAAE;YACP;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,SAAS;aAChB;YACD;gBACE,YAAY,EAAE,SAAS;gBACvB,IA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WAAW,GAAG,cAAc,EAAE,CAAA;IAEpC,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAa,EAAE,CAAA;IAEpC,MAAM,2BAA2B,GAAG,WAAW,CAC7C,GAAG,EAAE,CAAC,WAAW,CAAC,iBAAiB,CAAC,EAAE,QAAQ,EAAE,CAAC,EACjD,CAAC,WAAW,EAAE,QAAQ,CAAC,CACxB,CAAA;IAED,OAAO;QACL,oBAAoB,EAAE,2BAA2B;KAClD,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB;IAChC,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;IAEpC,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAa,EAAE,CAAA;IAEpC,MAAM,sBAAsB,GAAG,WAAW,CACxC,GAAG,EAAE,CAAC,WAAW,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,CAAC,EAC5C,CAAC,WAAW,EAAE,QAAQ,CAAC,CACxB,CAAA;IAED,OAAO;QACL,eAAe,EAAE,sBAAsB;KACxC,CAAA;AACH,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useCreateAccount.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCreateAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EACf,YAAY,EACb,MAAM,uBAAuB,CAAA;AAG9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAA;AAEzE,wBAAgB,gBAAgB,CAC9B,eAAe,GAAE,IAAI,CACnB,eAAe,CAAC,qBAAqB,EAAE,YAAY,EAAE,oBAAoB,CAAC,EAC1E,YAAY,GAAG,aAAa,CACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqBP"}
1
+ {"version":3,"file":"useCreateAccount.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCreateAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EACf,YAAY,EACb,MAAM,uBAAuB,CAAA;AAG9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAA;AAIzE,wBAAgB,gBAAgB,CAC9B,eAAe,GAAE,IAAI,CACnB,eAAe,CAAC,qBAAqB,EAAE,YAAY,EAAE,oBAAoB,CAAC,EAC1E,YAAY,GAAG,aAAa,CACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6CP"}
@@ -1,12 +1,33 @@
1
1
  import { useQueryClient, useMutation, } from "@tanstack/react-query";
2
2
  import { useAuthApiClient } from "./useAuthApiClient";
3
3
  import { QUERY_KEYS } from "./constants";
4
+ import useWalletAccount from "./useWalletAccount";
5
+ import { getBitcoinPublicKeyFromConnector } from "../utils/wagmi";
4
6
  export function useCreateAccount(mutationOptions = {}) {
5
7
  const queryClient = useQueryClient();
6
8
  const authApiClient = useAuthApiClient();
9
+ const { connector } = useWalletAccount();
7
10
  const { onSuccess: customOnSuccess, ...restMutationOptions } = mutationOptions;
8
11
  const { mutate, mutateAsync, ...rest } = useMutation({
9
- mutationFn: (createAccountRequest) => authApiClient.createAccount(createAccountRequest),
12
+ mutationFn: async (createAccountMutationFnParameters) => {
13
+ if (createAccountMutationFnParameters.type === "wallet") {
14
+ if (!connector) {
15
+ throw new Error("Connector not defined.");
16
+ }
17
+ const bitcoinPublicKey = await getBitcoinPublicKeyFromConnector(connector);
18
+ // Creating bitcoin mezo account
19
+ if (bitcoinPublicKey) {
20
+ return authApiClient.createAccount({
21
+ ...createAccountMutationFnParameters,
22
+ bitcoinPublicKey,
23
+ });
24
+ }
25
+ }
26
+ // Creating evm mezo account
27
+ return authApiClient.createAccount({
28
+ ...createAccountMutationFnParameters,
29
+ });
30
+ },
10
31
  onSuccess: (data, variables, context) => {
11
32
  queryClient.resetQueries({
12
33
  queryKey: [QUERY_KEYS.ACCOUNT],
@@ -1 +1 @@
1
- {"version":3,"file":"useCreateAccount.js","sourceRoot":"","sources":["../../../src/hooks/useCreateAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,WAAW,GAGZ,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGxC,MAAM,UAAU,gBAAgB,CAC9B,kBAGI,EAAE;IAEN,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;IACpC,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAA;IAExC,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,GAAG,mBAAmB,EAAE,GAAG,eAAe,CAAA;IAE9E,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,GAAG,WAAW,CAAC;QACnD,UAAU,EAAE,CAAC,oBAA0C,EAAE,EAAE,CACzD,aAAa,CAAC,aAAa,CAAC,oBAAoB,CAAC;QACnD,SAAS,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE;YACtC,WAAW,CAAC,YAAY,CAAC;gBACvB,QAAQ,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC;aAC/B,CAAC,CAAA;YAEF,IAAI,eAAe;gBAAE,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;QAChE,CAAC;QACD,GAAG,mBAAmB;KACvB,CAAC,CAAA;IAEF,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,kBAAkB,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,CAAA;AAC5E,CAAC"}
1
+ {"version":3,"file":"useCreateAccount.js","sourceRoot":"","sources":["../../../src/hooks/useCreateAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc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,QAAQ,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC;aAC/B,CAAC,CAAA;YAEF,IAAI,eAAe;gBAAE,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;QAChE,CAAC;QACD,GAAG,mBAAmB;KACvB,CAAC,CAAA;IAEF,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,kBAAkB,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,CAAA;AAC5E,CAAC"}
@@ -1,44 +1,47 @@
1
1
  import { CryptoAssetKey } from "../utils/cryptoAssets";
2
- /**
3
- * Formats crypto asset to balance details (balance in USD and decimals)
4
- * @param type The type of crypto asset
5
- * @param balance The balance of crypto asset
6
- * @param btcUsdConversionRate The USD conversion rate
7
- * @returns The balance details
8
- */
9
- export declare function formatCryptoAsset(type: CryptoAssetKey, balance: bigint, btcUsdConversionRate: number): {
10
- type: CryptoAssetKey;
11
- balance: number;
12
- balanceInUsd: number;
13
- decimals: number;
14
- };
15
2
  export type DropdownCryptoAsset<T = CryptoAssetKey> = {
16
3
  type: T;
17
4
  balance: bigint;
18
5
  };
19
- type DropdownDetailedCryptoAsset = ReturnType<typeof formatCryptoAsset>;
20
- export type DropdownData = {
21
- mezoId: string;
22
- address: string;
23
- walletType: "bitcoin" | "evm";
24
- totalBalanceInUsd: number;
25
- formattedNativeAssets: DropdownDetailedCryptoAsset[];
26
- matsnet: {
27
- mats: number;
28
- formattedAssets: DropdownDetailedCryptoAsset[];
29
- };
30
- };
31
- type UseDropdownDataOptions = {
32
- evmNativeAssets?: DropdownCryptoAsset[];
33
- matsnetAssets?: DropdownCryptoAsset[];
34
- };
35
6
  /**
36
7
  * Aggregates dropdown data for Dropdown component.
37
- * @param options - Options for the dropdown data.
38
- * @param options.evmNativeAssets - Native assets for EVM wallet.
39
- * @param options.matsnetAssets - Matsnet tokens. Rendered as separate section.
8
+ * @param {accountDataRefetchInterval: number, nativeBalanceRefetchInterval: number }
9
+ * Object containing refetch intervals time (in milliseconds) for account data
10
+ * (like mats or mezo id) and for native balance. After that time the specific
11
+ * value should be marked as stale and re-fetched. Default value for both is
12
+ * 90000 (90 secs).
40
13
  * @returns Dropdown data.
14
+ * @dev This hook is for internal use only.
41
15
  */
42
- export default function useDropdownData(options?: UseDropdownDataOptions): DropdownData | null;
43
- export {};
16
+ export default function useDropdownData({ accountDataRefetchInterval, nativeBalanceRefetchInterval, }: {
17
+ accountDataRefetchInterval?: number | undefined;
18
+ nativeBalanceRefetchInterval?: number | undefined;
19
+ }): {
20
+ mezoId: string | undefined;
21
+ matsBalance: number;
22
+ accountAddress: `0x${string}` | undefined;
23
+ walletAddress: string | undefined;
24
+ walletType: "bitcoin" | "evm";
25
+ usdTotalBalance: number;
26
+ usdTroveDebt: number;
27
+ usdCollateral: number;
28
+ assets: {
29
+ btc: {
30
+ type: CryptoAssetKey;
31
+ rawBalance: bigint;
32
+ formattedBalance: string;
33
+ usdBalance: number;
34
+ formattedUsdBalance: string;
35
+ };
36
+ musd: {
37
+ type: CryptoAssetKey;
38
+ rawBalance: bigint;
39
+ formattedBalance: string;
40
+ usdBalance: number;
41
+ formattedUsdBalance: string;
42
+ };
43
+ };
44
+ otherAssetsCount: number;
45
+ otherAssetsUsdTotal: number;
46
+ };
44
47
  //# sourceMappingURL=useDropdownData.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDropdownData.d.ts","sourceRoot":"","sources":["../../../src/hooks/useDropdownData.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,cAAc,EAIf,MAAM,uBAAuB,CAAA;AAK9B;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,MAAM,EACf,oBAAoB,EAAE,MAAM;;;;;EAmB7B;AAED,MAAM,MAAM,mBAAmB,CAAC,CAAC,GAAG,cAAc,IAAI;IACpD,IAAI,EAAE,CAAC,CAAA;IACP,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,KAAK,2BAA2B,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAEvE,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,SAAS,GAAG,KAAK,CAAA;IAC7B,iBAAiB,EAAE,MAAM,CAAA;IACzB,qBAAqB,EAAE,2BAA2B,EAAE,CAAA;IACpD,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAA;QACZ,eAAe,EAAE,2BAA2B,EAAE,CAAA;KAC/C,CAAA;CACF,CAAA;AAED,KAAK,sBAAsB,GAAG;IAE5B,eAAe,CAAC,EAAE,mBAAmB,EAAE,CAAA;IACvC,aAAa,CAAC,EAAE,mBAAmB,EAAE,CAAA;CACtC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,OAAO,CAAC,EAAE,sBAAsB,GAC/B,YAAY,GAAG,IAAI,CAoDrB"}
1
+ {"version":3,"file":"useDropdownData.d.ts","sourceRoot":"","sources":["../../../src/hooks/useDropdownData.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,cAAc,EAIf,MAAM,uBAAuB,CAAA;AAW9B,MAAM,MAAM,mBAAmB,CAAC,CAAC,GAAG,cAAc,IAAI;IACpD,IAAI,EAAE,CAAC,CAAA;IACP,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AASD;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EACtC,0BAAkC,EAClC,4BAAoC,GACrC;;;CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4GA"}
@@ -1,73 +1,97 @@
1
- import { useBitcoinAccount } from "@mezo-org/orangekit";
1
+ import { useBalance } from "wagmi";
2
2
  import { useGetCurrentAccount } from ".";
3
- import { getCryptoAsset, isBitcoinLikeCryptoAsset, isUsdLikeCryptoAsset, } from "../utils/cryptoAssets";
3
+ import { getCryptoAsset, isBitcoinLikeCryptoAsset, mapCryptoAssetToDetails, } from "../utils/cryptoAssets";
4
4
  import { fromFixedPoint } from "../utils/numbers";
5
- import { useAssetsUsdConversion } from "./useAssetsUSDConversion";
5
+ import { useAssetsConversionRates } from "./useAssetsConversionRates";
6
6
  import useWalletAccount from "./useWalletAccount";
7
- /**
8
- * Formats crypto asset to balance details (balance in USD and decimals)
9
- * @param type The type of crypto asset
10
- * @param balance The balance of crypto asset
11
- * @param btcUsdConversionRate The USD conversion rate
12
- * @returns The balance details
13
- */
14
- export function formatCryptoAsset(type, balance, btcUsdConversionRate) {
15
- const { decimals } = getCryptoAsset(type);
16
- const nativeBalance = fromFixedPoint(balance, decimals, 4);
17
- let balanceInUsd = 0;
18
- if (isBitcoinLikeCryptoAsset(type)) {
19
- balanceInUsd = nativeBalance * btcUsdConversionRate;
20
- }
21
- if (isUsdLikeCryptoAsset(type)) {
22
- balanceInUsd = nativeBalance;
23
- }
24
- return {
25
- type,
26
- balance: nativeBalance,
27
- balanceInUsd,
28
- decimals,
29
- };
30
- }
7
+ import { useTokensBalances } from "./useTokensBalances";
8
+ import { useBorrowData } from "./useBorrowData";
9
+ import { CHAIN_ID } from "../constants";
10
+ import { usePassportContext } from "./usePassportContext";
11
+ import { useWatchTransferEventsForAllTokens } from "./useWatchTransferEvents";
12
+ import { convertToUsd } from "../utils/currency";
13
+ const DEFAULT_ASSET_DATA = {
14
+ rawBalance: 0n,
15
+ formattedBalance: "0.0000",
16
+ usdBalance: 0,
17
+ formattedUsdBalance: "$0.00",
18
+ };
31
19
  /**
32
20
  * Aggregates dropdown data for Dropdown component.
33
- * @param options - Options for the dropdown data.
34
- * @param options.evmNativeAssets - Native assets for EVM wallet.
35
- * @param options.matsnetAssets - Matsnet tokens. Rendered as separate section.
21
+ * @param {accountDataRefetchInterval: number, nativeBalanceRefetchInterval: number }
22
+ * Object containing refetch intervals time (in milliseconds) for account data
23
+ * (like mats or mezo id) and for native balance. After that time the specific
24
+ * value should be marked as stale and re-fetched. Default value for both is
25
+ * 90000 (90 secs).
36
26
  * @returns Dropdown data.
27
+ * @dev This hook is for internal use only.
37
28
  */
38
- export default function useDropdownData(options) {
39
- const { evmNativeAssets = [], matsnetAssets = [] } = options || {};
40
- const { btcBalance } = useBitcoinAccount();
41
- const { address, networkFamily, isConnected } = useWalletAccount();
42
- const { data: passportAccount } = useGetCurrentAccount();
43
- const { data: assetsUsdConversion } = useAssetsUsdConversion();
44
- if (!address || !isConnected || !passportAccount) {
45
- return null;
46
- }
47
- const mezoId = passportAccount.mezoId;
48
- const nativeAssets = networkFamily === "bitcoin"
49
- ? [
50
- {
51
- type: "btc",
52
- balance: BigInt(btcBalance?.total ?? 0),
53
- },
54
- ]
55
- : evmNativeAssets;
56
- const btcUsdConversionRate = Number(assetsUsdConversion?.btcUsd ?? 0);
57
- const formattedNativeAssets = nativeAssets.map((asset) => formatCryptoAsset(asset.type, asset.balance, btcUsdConversionRate));
58
- const totalBalanceInUsd = formattedNativeAssets.reduce((sum, value) => sum + value.balanceInUsd, 0);
59
- const matsBalance = passportAccount.mats.totalMats;
60
- const matsnetFormattedAssets = matsnetAssets.map((asset) => formatCryptoAsset(asset.type, asset.balance, btcUsdConversionRate));
29
+ export default function useDropdownData({ accountDataRefetchInterval = 90000, nativeBalanceRefetchInterval = 90000, }) {
30
+ const { walletAddress, accountAddress, networkFamily: walletType, } = useWalletAccount();
31
+ const { environment = "mainnet" } = usePassportContext();
32
+ const { data: btcBalance } = useBalance({
33
+ address: accountAddress,
34
+ chainId: CHAIN_ID[environment],
35
+ query: {
36
+ staleTime: nativeBalanceRefetchInterval,
37
+ refetchInterval: nativeBalanceRefetchInterval,
38
+ },
39
+ });
40
+ const { data: passportAccount } = useGetCurrentAccount({
41
+ staleTime: accountDataRefetchInterval,
42
+ refetchInterval: accountDataRefetchInterval,
43
+ enabled: !!accountAddress,
44
+ });
45
+ const { data: assetsConversionRates } = useAssetsConversionRates();
46
+ const { data: tokensBalances } = useTokensBalances();
47
+ const { data: debt } = useBorrowData();
48
+ useWatchTransferEventsForAllTokens();
49
+ const mezoId = passportAccount?.mezoId;
50
+ const detailedAssets = [
51
+ ["BTC", btcBalance?.value ?? 0n],
52
+ ...Object.entries(tokensBalances ?? {}),
53
+ ].map((asset) => {
54
+ const [type, balance] = asset;
55
+ if (isBitcoinLikeCryptoAsset(type)) {
56
+ return mapCryptoAssetToDetails(type, balance, assetsConversionRates.btc.price, assetsConversionRates.btc.decimals);
57
+ }
58
+ if (type === "mT") {
59
+ return mapCryptoAssetToDetails(type, balance, assetsConversionRates.t.price, assetsConversionRates.t.decimals);
60
+ }
61
+ return mapCryptoAssetToDetails(type, balance, 1n, 0);
62
+ });
63
+ const btcData = detailedAssets.find(({ type }) => type === "BTC");
64
+ const musdData = detailedAssets.find(({ type }) => type === "MUSD");
65
+ const otherAssetsData = detailedAssets.filter(({ type }) => !["BTC", "MUSD"].includes(type));
66
+ const otherAssetsCount = otherAssetsData.filter((asset) => asset.rawBalance !== 0n).length;
67
+ const assets = {
68
+ btc: btcData || {
69
+ type: "BTC",
70
+ ...DEFAULT_ASSET_DATA,
71
+ },
72
+ musd: musdData || {
73
+ type: "mUSD",
74
+ ...DEFAULT_ASSET_DATA,
75
+ },
76
+ };
77
+ const otherAssetsUsdTotal = otherAssetsData.reduce((sum, { usdBalance }) => sum + usdBalance, 0);
78
+ const matsBalance = passportAccount?.mats.totalMats || 0;
79
+ const usdCollateral = convertToUsd(debt?.collateral ?? 0n, getCryptoAsset("MUSD").decimals, assetsConversionRates.btc.price, assetsConversionRates.btc.decimals);
80
+ const usdTroveDebt = fromFixedPoint(debt?.troveDebt ?? 0n, 18);
81
+ const usdTotalBalance = detailedAssets.reduce((sum, { usdBalance }) => sum + usdBalance, 0) +
82
+ usdCollateral;
61
83
  return {
62
84
  mezoId,
63
- address,
64
- walletType: networkFamily,
65
- totalBalanceInUsd,
66
- formattedNativeAssets,
67
- matsnet: {
68
- mats: matsBalance,
69
- formattedAssets: matsnetFormattedAssets,
70
- },
85
+ matsBalance,
86
+ accountAddress,
87
+ walletAddress,
88
+ walletType,
89
+ usdTotalBalance,
90
+ usdTroveDebt,
91
+ usdCollateral,
92
+ assets,
93
+ otherAssetsCount,
94
+ otherAssetsUsdTotal,
71
95
  };
72
96
  }
73
97
  //# sourceMappingURL=useDropdownData.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDropdownData.js","sourceRoot":"","sources":["../../../src/hooks/useDropdownData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,GAAG,CAAA;AACxC,OAAO,EAEL,cAAc,EACd,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AAEjD;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAC/B,IAAoB,EACpB,OAAe,EACf,oBAA4B;IAE5B,MAAM,EAAE,QAAQ,EAAE,GAAG,cAAc,CAAC,IAAI,CAAC,CAAA;IAEzC,MAAM,aAAa,GAAG,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAA;IAC1D,IAAI,YAAY,GAAG,CAAC,CAAA;IACpB,IAAI,wBAAwB,CAAC,IAAI,CAAC,EAAE,CAAC;QACnC,YAAY,GAAG,aAAa,GAAG,oBAAoB,CAAA;IACrD,CAAC;IACD,IAAI,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/B,YAAY,GAAG,aAAa,CAAA;IAC9B,CAAC;IAED,OAAO;QACL,IAAI;QACJ,OAAO,EAAE,aAAa;QACtB,YAAY;QACZ,QAAQ;KACT,CAAA;AACH,CAAC;AA2BD;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,eAA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