@mezo-org/passport 0.4.0-dev.4 → 0.4.0-dev.42

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 (303) hide show
  1. package/README.md +18 -22
  2. package/dist/src/api/auth.d.ts +36 -59
  3. package/dist/src/api/auth.d.ts.map +1 -1
  4. package/dist/src/api/auth.js +21 -49
  5. package/dist/src/api/auth.js.map +1 -1
  6. package/dist/src/api/client.d.ts +24 -0
  7. package/dist/src/api/client.d.ts.map +1 -0
  8. package/dist/src/api/client.js +54 -0
  9. package/dist/src/api/client.js.map +1 -0
  10. package/dist/src/api/fetch-error.d.ts +5 -0
  11. package/dist/src/api/fetch-error.d.ts.map +1 -0
  12. package/dist/src/api/fetch-error.js +8 -0
  13. package/dist/src/api/fetch-error.js.map +1 -0
  14. package/dist/src/api/index.d.ts +3 -0
  15. package/dist/src/api/index.d.ts.map +1 -0
  16. package/dist/src/api/index.js +3 -0
  17. package/dist/src/api/index.js.map +1 -0
  18. package/dist/src/api/portal.d.ts +33 -0
  19. package/dist/src/api/portal.d.ts.map +1 -0
  20. package/dist/src/api/portal.js +23 -0
  21. package/dist/src/api/portal.js.map +1 -0
  22. package/dist/src/assets/DefaultAvatar.d.ts +5 -0
  23. package/dist/src/assets/DefaultAvatar.d.ts.map +1 -0
  24. package/dist/src/assets/DefaultAvatar.js +21 -0
  25. package/dist/src/assets/DefaultAvatar.js.map +1 -0
  26. package/dist/src/components/Dropdown/ConnectedTrigger.d.ts +8 -0
  27. package/dist/src/components/Dropdown/ConnectedTrigger.d.ts.map +1 -0
  28. package/dist/src/components/Dropdown/ConnectedTrigger.js +39 -0
  29. package/dist/src/components/Dropdown/ConnectedTrigger.js.map +1 -0
  30. package/dist/src/components/Dropdown/Content.d.ts +23 -0
  31. package/dist/src/components/Dropdown/Content.d.ts.map +1 -0
  32. package/dist/src/components/Dropdown/Content.js +27 -0
  33. package/dist/src/components/Dropdown/Content.js.map +1 -0
  34. package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts +7 -0
  35. package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts.map +1 -0
  36. package/dist/src/components/Dropdown/DisconnectedTrigger.js +13 -0
  37. package/dist/src/components/Dropdown/DisconnectedTrigger.js.map +1 -0
  38. package/dist/src/components/Dropdown/Dropdown.d.ts +27 -0
  39. package/dist/src/components/Dropdown/Dropdown.d.ts.map +1 -0
  40. package/dist/src/components/Dropdown/Dropdown.js +68 -0
  41. package/dist/src/components/Dropdown/Dropdown.js.map +1 -0
  42. package/dist/src/components/Dropdown/ListingItem.d.ts +13 -0
  43. package/dist/src/components/Dropdown/ListingItem.d.ts.map +1 -0
  44. package/dist/src/components/Dropdown/ListingItem.js +34 -0
  45. package/dist/src/components/Dropdown/ListingItem.js.map +1 -0
  46. package/dist/src/components/Dropdown/NestedViewLayout.d.ts +7 -0
  47. package/dist/src/components/Dropdown/NestedViewLayout.d.ts.map +1 -0
  48. package/dist/src/components/Dropdown/NestedViewLayout.js +34 -0
  49. package/dist/src/components/Dropdown/NestedViewLayout.js.map +1 -0
  50. package/dist/src/components/Dropdown/Receive/Receive.d.ts +7 -0
  51. package/dist/src/components/Dropdown/Receive/Receive.d.ts.map +1 -0
  52. package/dist/src/components/Dropdown/Receive/Receive.js +53 -0
  53. package/dist/src/components/Dropdown/Receive/Receive.js.map +1 -0
  54. package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts +7 -0
  55. package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts.map +1 -0
  56. package/dist/src/components/Dropdown/Root/AccountAddressActions.js +48 -0
  57. package/dist/src/components/Dropdown/Root/AccountAddressActions.js.map +1 -0
  58. package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts +11 -0
  59. package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts.map +1 -0
  60. package/dist/src/components/Dropdown/Root/AccountAssetItem.js +9 -0
  61. package/dist/src/components/Dropdown/Root/AccountAssetItem.js.map +1 -0
  62. package/dist/src/components/Dropdown/Root/AccountBalance.d.ts +8 -0
  63. package/dist/src/components/Dropdown/Root/AccountBalance.d.ts.map +1 -0
  64. package/dist/src/components/Dropdown/Root/AccountBalance.js +15 -0
  65. package/dist/src/components/Dropdown/Root/AccountBalance.js.map +1 -0
  66. package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts +9 -0
  67. package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts.map +1 -0
  68. package/dist/src/components/Dropdown/Root/AccountOtherAssets.js +48 -0
  69. package/dist/src/components/Dropdown/Root/AccountOtherAssets.js.map +1 -0
  70. package/dist/src/components/Dropdown/Root/Root.d.ts +23 -0
  71. package/dist/src/components/Dropdown/Root/Root.d.ts.map +1 -0
  72. package/dist/src/components/Dropdown/Root/Root.js +57 -0
  73. package/dist/src/components/Dropdown/Root/Root.js.map +1 -0
  74. package/dist/src/components/Dropdown/Root/WalletAddress.d.ts +8 -0
  75. package/dist/src/components/Dropdown/Root/WalletAddress.d.ts.map +1 -0
  76. package/dist/src/components/Dropdown/Root/WalletAddress.js +64 -0
  77. package/dist/src/components/Dropdown/Root/WalletAddress.js.map +1 -0
  78. package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts +8 -0
  79. package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts.map +1 -0
  80. package/dist/src/components/Dropdown/Root/WelcomeBlock.js +44 -0
  81. package/dist/src/components/Dropdown/Root/WelcomeBlock.js.map +1 -0
  82. package/dist/src/components/Dropdown/TestnetTopBanner.d.ts +3 -0
  83. package/dist/src/components/Dropdown/TestnetTopBanner.d.ts.map +1 -0
  84. package/dist/src/components/Dropdown/TestnetTopBanner.js +14 -0
  85. package/dist/src/components/Dropdown/TestnetTopBanner.js.map +1 -0
  86. package/dist/src/components/Dropdown/index.d.ts +3 -0
  87. package/dist/src/components/Dropdown/index.d.ts.map +1 -0
  88. package/dist/src/components/Dropdown/index.js +2 -0
  89. package/dist/src/components/Dropdown/index.js.map +1 -0
  90. package/dist/src/components/index.d.ts +2 -0
  91. package/dist/src/components/index.d.ts.map +1 -0
  92. package/dist/src/components/index.js +2 -0
  93. package/dist/src/components/index.js.map +1 -0
  94. package/dist/src/config.d.ts +41 -0
  95. package/dist/src/config.d.ts.map +1 -1
  96. package/dist/src/config.js +17 -5
  97. package/dist/src/config.js.map +1 -1
  98. package/dist/src/constants.d.ts +6 -2
  99. package/dist/src/constants.d.ts.map +1 -1
  100. package/dist/src/constants.js +8 -4
  101. package/dist/src/constants.js.map +1 -1
  102. package/dist/src/hooks/constants.d.ts +1 -0
  103. package/dist/src/hooks/constants.d.ts.map +1 -1
  104. package/dist/src/hooks/constants.js +1 -0
  105. package/dist/src/hooks/constants.js.map +1 -1
  106. package/dist/src/hooks/index.d.ts +4 -1
  107. package/dist/src/hooks/index.d.ts.map +1 -1
  108. package/dist/src/hooks/index.js +4 -1
  109. package/dist/src/hooks/index.js.map +1 -1
  110. package/dist/src/hooks/useAssetsConversionRates.d.ts +7 -0
  111. package/dist/src/hooks/useAssetsConversionRates.d.ts.map +1 -0
  112. package/dist/src/hooks/useAssetsConversionRates.js +24 -0
  113. package/dist/src/hooks/useAssetsConversionRates.js.map +1 -0
  114. package/dist/src/hooks/useAuthApiClient.d.ts +1 -1
  115. package/dist/src/hooks/useAuthApiClient.d.ts.map +1 -1
  116. package/dist/src/hooks/useAuthenticateWithWallet.d.ts +73 -0
  117. package/dist/src/hooks/useAuthenticateWithWallet.d.ts.map +1 -0
  118. package/dist/src/hooks/useAuthenticateWithWallet.js +69 -0
  119. package/dist/src/hooks/useAuthenticateWithWallet.js.map +1 -0
  120. package/dist/src/hooks/useBorrowData.d.ts +60 -0
  121. package/dist/src/hooks/useBorrowData.d.ts.map +1 -0
  122. package/dist/src/hooks/useBorrowData.js +122 -0
  123. package/dist/src/hooks/useBorrowData.js.map +1 -0
  124. package/dist/src/hooks/useCreateAccount.d.ts +23 -173
  125. package/dist/src/hooks/useCreateAccount.d.ts.map +1 -1
  126. package/dist/src/hooks/useCreateAccount.js +7 -4
  127. package/dist/src/hooks/useCreateAccount.js.map +1 -1
  128. package/dist/src/hooks/useCreateSession.d.ts +12 -101
  129. package/dist/src/hooks/useCreateSession.d.ts.map +1 -1
  130. package/dist/src/hooks/useCreateSession.js +10 -8
  131. package/dist/src/hooks/useCreateSession.js.map +1 -1
  132. package/dist/src/hooks/useDropdownData.d.ts +47 -0
  133. package/dist/src/hooks/useDropdownData.d.ts.map +1 -0
  134. package/dist/src/hooks/useDropdownData.js +95 -0
  135. package/dist/src/hooks/useDropdownData.js.map +1 -0
  136. package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.d.ts.map +1 -1
  137. package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.js +1 -0
  138. package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.js.map +1 -1
  139. package/dist/src/hooks/useGetAccountByAddress.d.ts +2 -2
  140. package/dist/src/hooks/useGetAccountByAddress.d.ts.map +1 -1
  141. package/dist/src/hooks/useGetAccountByMezoId.d.ts +2 -2
  142. package/dist/src/hooks/useGetAccountByMezoId.d.ts.map +1 -1
  143. package/dist/src/hooks/useGetCurrentAccount.d.ts +16 -2
  144. package/dist/src/hooks/useGetCurrentAccount.d.ts.map +1 -1
  145. package/dist/src/hooks/useGetCurrentAccount.js +25 -3
  146. package/dist/src/hooks/useGetCurrentAccount.js.map +1 -1
  147. package/dist/src/hooks/useGetSession.d.ts +1 -1
  148. package/dist/src/hooks/useGetSession.d.ts.map +1 -1
  149. package/dist/src/hooks/useLinkAccount.d.ts +15 -175
  150. package/dist/src/hooks/useLinkAccount.d.ts.map +1 -1
  151. package/dist/src/hooks/useLinkAccount.js +7 -4
  152. package/dist/src/hooks/useLinkAccount.js.map +1 -1
  153. package/dist/src/hooks/usePortalApiClient.d.ts +2 -0
  154. package/dist/src/hooks/usePortalApiClient.d.ts.map +1 -0
  155. package/dist/src/hooks/usePortalApiClient.js +6 -0
  156. package/dist/src/hooks/usePortalApiClient.js.map +1 -0
  157. package/dist/src/hooks/useRefreshPassport.d.ts +19 -0
  158. package/dist/src/hooks/useRefreshPassport.d.ts.map +1 -0
  159. package/dist/src/hooks/useRefreshPassport.js +44 -0
  160. package/dist/src/hooks/useRefreshPassport.js.map +1 -0
  161. package/dist/src/hooks/useSignInWithDiscord.d.ts +12 -100
  162. package/dist/src/hooks/useSignInWithDiscord.d.ts.map +1 -1
  163. package/dist/src/hooks/useSignInWithDiscord.js +6 -3
  164. package/dist/src/hooks/useSignInWithDiscord.js.map +1 -1
  165. package/dist/src/hooks/useSignInWithWallet.d.ts +12 -100
  166. package/dist/src/hooks/useSignInWithWallet.d.ts.map +1 -1
  167. package/dist/src/hooks/useSignInWithWallet.js +6 -34
  168. package/dist/src/hooks/useSignInWithWallet.js.map +1 -1
  169. package/dist/src/hooks/useSignOut.d.ts +12 -28
  170. package/dist/src/hooks/useSignOut.d.ts.map +1 -1
  171. package/dist/src/hooks/useSignOut.js +7 -4
  172. package/dist/src/hooks/useSignOut.js.map +1 -1
  173. package/dist/src/hooks/useSignUpWithWallet.d.ts +73 -0
  174. package/dist/src/hooks/useSignUpWithWallet.d.ts.map +1 -0
  175. package/dist/src/hooks/useSignUpWithWallet.js +11 -0
  176. package/dist/src/hooks/useSignUpWithWallet.js.map +1 -0
  177. package/dist/src/hooks/useTokensBalances.d.ts +74 -0
  178. package/dist/src/hooks/useTokensBalances.d.ts.map +1 -0
  179. package/dist/src/hooks/useTokensBalances.js +140 -0
  180. package/dist/src/hooks/useTokensBalances.js.map +1 -0
  181. package/dist/src/hooks/useUpdateMezoId.d.ts +30 -136
  182. package/dist/src/hooks/useUpdateMezoId.d.ts.map +1 -1
  183. package/dist/src/hooks/useUpdateMezoId.js +7 -4
  184. package/dist/src/hooks/useUpdateMezoId.js.map +1 -1
  185. package/dist/src/hooks/useWalletAccount.d.ts +13 -0
  186. package/dist/src/hooks/useWalletAccount.d.ts.map +1 -0
  187. package/dist/src/hooks/useWalletAccount.js +29 -0
  188. package/dist/src/hooks/useWalletAccount.js.map +1 -0
  189. package/dist/src/hooks/useWatchTransferEvents.d.ts +5 -0
  190. package/dist/src/hooks/useWatchTransferEvents.d.ts.map +1 -0
  191. package/dist/src/hooks/useWatchTransferEvents.js +63 -0
  192. package/dist/src/hooks/useWatchTransferEvents.js.map +1 -0
  193. package/dist/src/index.d.ts +2 -1
  194. package/dist/src/index.d.ts.map +1 -1
  195. package/dist/src/index.js +2 -1
  196. package/dist/src/index.js.map +1 -1
  197. package/dist/src/lib/contracts/index.d.ts +13 -0
  198. package/dist/src/lib/contracts/index.d.ts.map +1 -0
  199. package/dist/src/lib/contracts/index.js +57 -0
  200. package/dist/src/lib/contracts/index.js.map +1 -0
  201. package/dist/src/provider.d.ts +10 -13
  202. package/dist/src/provider.d.ts.map +1 -1
  203. package/dist/src/provider.js +11 -20
  204. package/dist/src/provider.js.map +1 -1
  205. package/dist/src/stores/dropdownStore.d.ts +12 -0
  206. package/dist/src/stores/dropdownStore.d.ts.map +1 -0
  207. package/dist/src/stores/dropdownStore.js +13 -0
  208. package/dist/src/stores/dropdownStore.js.map +1 -0
  209. package/dist/src/utils/address.d.ts +15 -0
  210. package/dist/src/utils/address.d.ts.map +1 -0
  211. package/dist/src/utils/address.js +37 -0
  212. package/dist/src/utils/address.js.map +1 -0
  213. package/dist/src/utils/address.test.d.ts +2 -0
  214. package/dist/src/utils/address.test.d.ts.map +1 -0
  215. package/dist/src/utils/address.test.js +40 -0
  216. package/dist/src/utils/address.test.js.map +1 -0
  217. package/dist/src/utils/cryptoAssets.d.ts +44 -0
  218. package/dist/src/utils/cryptoAssets.d.ts.map +1 -0
  219. package/dist/src/utils/cryptoAssets.js +131 -0
  220. package/dist/src/utils/cryptoAssets.js.map +1 -0
  221. package/dist/src/utils/cryptoAssets.test.d.ts +2 -0
  222. package/dist/src/utils/cryptoAssets.test.d.ts.map +1 -0
  223. package/dist/src/utils/cryptoAssets.test.js +67 -0
  224. package/dist/src/utils/cryptoAssets.test.js.map +1 -0
  225. package/dist/src/utils/currency.d.ts +14 -0
  226. package/dist/src/utils/currency.d.ts.map +1 -0
  227. package/dist/src/utils/currency.js +27 -0
  228. package/dist/src/utils/currency.js.map +1 -0
  229. package/dist/src/utils/currency.test.d.ts +2 -0
  230. package/dist/src/utils/currency.test.d.ts.map +1 -0
  231. package/dist/src/utils/currency.test.js +34 -0
  232. package/dist/src/utils/currency.test.js.map +1 -0
  233. package/dist/src/utils/numbers.d.ts +58 -0
  234. package/dist/src/utils/numbers.d.ts.map +1 -0
  235. package/dist/src/utils/numbers.js +132 -0
  236. package/dist/src/utils/numbers.js.map +1 -0
  237. package/dist/src/utils/numbers.test.d.ts +2 -0
  238. package/dist/src/utils/numbers.test.d.ts.map +1 -0
  239. package/dist/src/utils/numbers.test.js +170 -0
  240. package/dist/src/utils/numbers.test.js.map +1 -0
  241. package/package.json +13 -5
  242. package/src/api/auth.ts +72 -129
  243. package/src/api/client.ts +78 -0
  244. package/src/api/fetch-error.ts +8 -0
  245. package/src/api/index.ts +2 -0
  246. package/src/api/portal.ts +57 -0
  247. package/src/assets/DefaultAvatar.tsx +74 -0
  248. package/src/components/Dropdown/ConnectedTrigger.tsx +76 -0
  249. package/src/components/Dropdown/Content.tsx +98 -0
  250. package/src/components/Dropdown/DisconnectedTrigger.tsx +36 -0
  251. package/src/components/Dropdown/Dropdown.tsx +148 -0
  252. package/src/components/Dropdown/ListingItem.tsx +80 -0
  253. package/src/components/Dropdown/NestedViewLayout.tsx +75 -0
  254. package/src/components/Dropdown/README.md +41 -0
  255. package/src/components/Dropdown/Receive/Receive.tsx +119 -0
  256. package/src/components/Dropdown/Root/AccountAddressActions.tsx +101 -0
  257. package/src/components/Dropdown/Root/AccountAssetItem.tsx +26 -0
  258. package/src/components/Dropdown/Root/AccountBalance.tsx +30 -0
  259. package/src/components/Dropdown/Root/AccountOtherAssets.tsx +68 -0
  260. package/src/components/Dropdown/Root/Root.tsx +147 -0
  261. package/src/components/Dropdown/Root/WalletAddress.tsx +128 -0
  262. package/src/components/Dropdown/Root/WelcomeBlock.tsx +91 -0
  263. package/src/components/Dropdown/TestnetTopBanner.tsx +32 -0
  264. package/src/components/Dropdown/index.ts +2 -0
  265. package/src/components/index.ts +1 -0
  266. package/src/config.ts +24 -6
  267. package/src/constants.ts +8 -4
  268. package/src/hooks/constants.ts +1 -0
  269. package/src/hooks/index.ts +7 -1
  270. package/src/hooks/useAssetsConversionRates.ts +32 -0
  271. package/src/hooks/useAuthenticateWithWallet.ts +102 -0
  272. package/src/hooks/useBorrowData.ts +143 -0
  273. package/src/hooks/useCreateAccount.ts +19 -5
  274. package/src/hooks/useCreateSession.ts +22 -9
  275. package/src/hooks/useDropdownData.ts +139 -0
  276. package/src/hooks/useEnsureNoSessionAndFetchNonce.ts +1 -0
  277. package/src/hooks/useGetAccountByAddress.ts +2 -2
  278. package/src/hooks/useGetAccountByMezoId.ts +2 -2
  279. package/src/hooks/useGetCurrentAccount.ts +46 -6
  280. package/src/hooks/useGetSession.ts +1 -1
  281. package/src/hooks/useLinkAccount.ts +18 -5
  282. package/src/hooks/usePortalApiClient.ts +6 -0
  283. package/src/hooks/useRefreshPassport.ts +56 -0
  284. package/src/hooks/useSignInWithDiscord.ts +14 -5
  285. package/src/hooks/useSignInWithWallet.ts +14 -42
  286. package/src/hooks/useSignOut.ts +18 -4
  287. package/src/hooks/useSignUpWithWallet.ts +21 -0
  288. package/src/hooks/useTokensBalances.ts +187 -0
  289. package/src/hooks/useUpdateMezoId.ts +19 -4
  290. package/src/hooks/useWalletAccount.ts +55 -0
  291. package/src/hooks/useWatchTransferEvents.ts +74 -0
  292. package/src/index.ts +9 -1
  293. package/src/lib/contracts/index.ts +88 -0
  294. package/src/provider.ts +30 -37
  295. package/src/stores/dropdownStore.ts +20 -0
  296. package/src/utils/address.test.ts +48 -0
  297. package/src/utils/address.ts +45 -0
  298. package/src/utils/cryptoAssets.test.ts +79 -0
  299. package/src/utils/cryptoAssets.ts +173 -0
  300. package/src/utils/currency.test.ts +38 -0
  301. package/src/utils/currency.ts +32 -0
  302. package/src/utils/numbers.test.ts +220 -0
  303. package/src/utils/numbers.ts +188 -0
@@ -0,0 +1,24 @@
1
+ import { useQuery } from "@tanstack/react-query";
2
+ import { ONE_MINUTE_MS } from "../utils/time";
3
+ import { QUERY_KEYS } from "./constants";
4
+ import { usePortalApiClient } from "./usePortalApiClient";
5
+ export default function useAssetsConversionRates(useQueryOptions = {}) {
6
+ const portalApiClient = usePortalApiClient();
7
+ return useQuery({
8
+ queryKey: [QUERY_KEYS.ASSETS_USD_CONVERSION],
9
+ queryFn: async () => {
10
+ const { currentUsdPerBtc, currentUsdPerEth, currentUsdPerTToken } = await portalApiClient.getPortalStatistics();
11
+ return {
12
+ usd: {
13
+ btc: Number(currentUsdPerBtc),
14
+ eth: Number(currentUsdPerEth),
15
+ t: Number(currentUsdPerTToken),
16
+ },
17
+ };
18
+ },
19
+ staleTime: 30 * ONE_MINUTE_MS,
20
+ retry: 1,
21
+ ...useQueryOptions,
22
+ });
23
+ }
24
+ //# sourceMappingURL=useAssetsConversionRates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAssetsConversionRates.js","sourceRoot":"","sources":["../../../src/hooks/useAssetsConversionRates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAMzD,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAC9C,kBAAqE,EAAE;IAEvE,MAAM,eAAe,GAAG,kBAAkB,EAAE,CAAA;IAE5C,OAAO,QAAQ,CAAC;QACd,QAAQ,EAAE,CAAC,UAAU,CAAC,qBAAqB,CAAC;QAC5C,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,GAC/D,MAAM,eAAe,CAAC,mBAAmB,EAAE,CAAA;YAC7C,OAAO;gBACL,GAAG,EAAE;oBACH,GAAG,EAAE,MAAM,CAAC,gBAAgB,CAAC;oBAC7B,GAAG,EAAE,MAAM,CAAC,gBAAgB,CAAC;oBAC7B,CAAC,EAAE,MAAM,CAAC,mBAAmB,CAAC;iBAC/B;aACF,CAAA;QACH,CAAC;QACD,SAAS,EAAE,EAAE,GAAG,aAAa;QAC7B,KAAK,EAAE,CAAC;QACR,GAAG,eAAe;KACnB,CAAC,CAAA;AACJ,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare function useAuthApiClient(): import("../api/auth").AuthApiClient;
1
+ export declare function useAuthApiClient(): import("../api").AuthApiClient;
2
2
  //# sourceMappingURL=useAuthApiClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAuthApiClient.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAuthApiClient.ts"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,wCAG/B"}
1
+ {"version":3,"file":"useAuthApiClient.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAuthApiClient.ts"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,mCAG/B"}
@@ -0,0 +1,73 @@
1
+ import { MutationOptions } from "@tanstack/react-query";
2
+ import type { Session } from "../api";
3
+ declare function useAuthenticateWithWallet(shouldCreateAccount?: boolean, mutationOptions?: Omit<MutationOptions<Session>, "mutationFn" | "mutationKey">): {
4
+ data: undefined;
5
+ variables: undefined;
6
+ error: null;
7
+ isError: false;
8
+ isIdle: true;
9
+ isPending: false;
10
+ isSuccess: false;
11
+ status: "idle";
12
+ reset: () => void;
13
+ context: unknown;
14
+ failureCount: number;
15
+ failureReason: Error | null;
16
+ isPaused: boolean;
17
+ submittedAt: number;
18
+ authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, void, unknown>;
19
+ authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, void, unknown>;
20
+ } | {
21
+ data: undefined;
22
+ variables: void;
23
+ error: null;
24
+ isError: false;
25
+ isIdle: false;
26
+ isPending: true;
27
+ isSuccess: false;
28
+ status: "pending";
29
+ reset: () => void;
30
+ context: unknown;
31
+ failureCount: number;
32
+ failureReason: Error | null;
33
+ isPaused: boolean;
34
+ submittedAt: number;
35
+ authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, void, unknown>;
36
+ authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, void, unknown>;
37
+ } | {
38
+ data: undefined;
39
+ error: Error;
40
+ variables: void;
41
+ isError: true;
42
+ isIdle: false;
43
+ isPending: false;
44
+ isSuccess: false;
45
+ status: "error";
46
+ reset: () => void;
47
+ context: unknown;
48
+ failureCount: number;
49
+ failureReason: Error | null;
50
+ isPaused: boolean;
51
+ submittedAt: number;
52
+ authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, void, unknown>;
53
+ authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, void, unknown>;
54
+ } | {
55
+ data: Session;
56
+ error: null;
57
+ variables: void;
58
+ isError: false;
59
+ isIdle: false;
60
+ isPending: false;
61
+ isSuccess: true;
62
+ status: "success";
63
+ reset: () => void;
64
+ context: unknown;
65
+ failureCount: number;
66
+ failureReason: Error | null;
67
+ isPaused: boolean;
68
+ submittedAt: number;
69
+ authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, void, unknown>;
70
+ authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, void, unknown>;
71
+ };
72
+ export { useAuthenticateWithWallet };
73
+ //# sourceMappingURL=useAuthenticateWithWallet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAuthenticateWithWallet.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAuthenticateWithWallet.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAe,MAAM,uBAAuB,CAAA;AAMpE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAGrC,iBAAS,yBAAyB,CAChC,mBAAmB,UAAQ,EAC3B,eAAe,GAAE,IAAI,CACnB,eAAe,CAAC,OAAO,CAAC,EACxB,YAAY,GAAG,aAAa,CACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoFP;AAED,OAAO,EAAE,yBAAyB,EAAE,CAAA"}
@@ -0,0 +1,69 @@
1
+ import { useSignMessage } from "wagmi";
2
+ import { useMutation } from "@tanstack/react-query";
3
+ import { useCreateAccount } from "./useCreateAccount";
4
+ import { useCreateSession } from "./useCreateSession";
5
+ import { useEnsureNoSessionAndFetchNonce } from "./useEnsureNoSessionAndFetchNonce";
6
+ import { createSignInWithWalletMessage } from "../utils/siww";
7
+ import { useGetAccountByAddress } from "./useGetAccountByAddress";
8
+ import useWalletAccount from "./useWalletAccount";
9
+ function useAuthenticateWithWallet(shouldCreateAccount = false, mutationOptions = {}) {
10
+ const { walletAddress, chainId, connector, networkFamily } = useWalletAccount();
11
+ const { ensureNoSessionAndFetchNonce } = useEnsureNoSessionAndFetchNonce();
12
+ const { createSessionAsync } = useCreateSession();
13
+ const { createAccountAsync } = useCreateAccount();
14
+ const { signMessageAsync } = useSignMessage();
15
+ const { refetch: getAccountByAddress } = useGetAccountByAddress(walletAddress, {
16
+ enabled: false,
17
+ retry: false,
18
+ });
19
+ const { mutate, mutateAsync, ...signInMutationRestParameters } = useMutation({
20
+ mutationFn: async () => {
21
+ if (!walletAddress) {
22
+ throw new Error("Sign in error: Wallet not connected!");
23
+ }
24
+ const nonce = await ensureNoSessionAndFetchNonce();
25
+ const messageResult = createSignInWithWalletMessage(walletAddress, nonce, networkFamily, chainId);
26
+ const signatureResult = await signMessageAsync({
27
+ message: messageResult,
28
+ connector,
29
+ });
30
+ if (shouldCreateAccount) {
31
+ const getAccountByAddressResult = await getAccountByAddress();
32
+ if (getAccountByAddressResult.data) {
33
+ throw new Error("Wallet authentication failed: Account creation failed. Account already exists.");
34
+ }
35
+ if (getAccountByAddressResult.error) {
36
+ throw new Error(`Wallet authentication failed: Account creation failed. Could not verify if account already exists: ${getAccountByAddressResult.error}`);
37
+ }
38
+ // Fetch was successful, but no account was found
39
+ try {
40
+ const createAccountResult = await createAccountAsync({
41
+ type: "wallet",
42
+ message: messageResult,
43
+ signature: signatureResult,
44
+ });
45
+ if (!createAccountResult) {
46
+ throw new Error("Failed to create new account");
47
+ }
48
+ }
49
+ catch (error) {
50
+ throw new Error(`Wallet authentication failed: Account creation failed: ${error}`);
51
+ }
52
+ }
53
+ return (await createSessionAsync({
54
+ type: "wallet",
55
+ message: messageResult,
56
+ signature: signatureResult,
57
+ }));
58
+ // ^ By passing type: "wallet" we know for sure the return type is Session
59
+ },
60
+ ...mutationOptions,
61
+ });
62
+ return {
63
+ authenticateWithWallet: mutate,
64
+ authenticateWithWalletAsync: mutateAsync,
65
+ ...signInMutationRestParameters,
66
+ };
67
+ }
68
+ export { useAuthenticateWithWallet };
69
+ //# sourceMappingURL=useAuthenticateWithWallet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAuthenticateWithWallet.js","sourceRoot":"","sources":["../../../src/hooks/useAuthenticateWithWallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EAAmB,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAA;AACnF,OAAO,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAA;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AAEjE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,yBAAyB,CAAC,KAAK,EAAE,CAAC;oBACpC,MAAM,IAAI,KAAK,CACb,sGAAsG,yBAAyB,CAAC,KAAK,EAAE,CACxI,CAAA;gBACH,CAAC;gBAED,iDAAiD;gBACjD,IAAI,CAAC;oBACH,MAAM,mBAAmB,GAAG,MAAM,kBAAkB,CAAC;wBACnD,IAAI,EAAE,QAAQ;wBACd,OAAO,EAAE,aAAa;wBACtB,SAAS,EAAE,eAAe;qBAC3B,CAAC,CAAA;oBAEF,IAAI,CAAC,mBAAmB,EAAE,CAAC;wBACzB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;oBACjD,CAAC;gBACH,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,IAAI,KAAK,CACb,0DAA0D,KAAK,EAAE,CAClE,CAAA;gBACH,CAAC;YACH,CAAC;YAED,OAAO,CAAC,MAAM,kBAAkB,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,60 @@
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").UseReadContractReturnType<readonly [{
7
+ readonly inputs: readonly [{
8
+ readonly internalType: "address";
9
+ readonly name: "_borrower";
10
+ readonly type: "address";
11
+ }];
12
+ readonly name: "getEntireDebtAndColl";
13
+ readonly outputs: readonly [{
14
+ readonly internalType: "uint256";
15
+ readonly name: "coll";
16
+ readonly type: "uint256";
17
+ }, {
18
+ readonly internalType: "uint256";
19
+ readonly name: "principal";
20
+ readonly type: "uint256";
21
+ }, {
22
+ readonly internalType: "uint256";
23
+ readonly name: "interest";
24
+ readonly type: "uint256";
25
+ }, {
26
+ readonly internalType: "uint256";
27
+ readonly name: "pendingCollateral";
28
+ readonly type: "uint256";
29
+ }, {
30
+ readonly internalType: "uint256";
31
+ readonly name: "pendingPrincipal";
32
+ readonly type: "uint256";
33
+ }, {
34
+ readonly internalType: "uint256";
35
+ readonly name: "pendingInterest";
36
+ readonly type: "uint256";
37
+ }];
38
+ readonly stateMutability: "view";
39
+ readonly type: "function";
40
+ }], "getEntireDebtAndColl", [`0x${string}`], {
41
+ collateral: bigint;
42
+ troveDebt: bigint;
43
+ } | undefined>;
44
+ /**
45
+ * Hook for for invalidating current user's borrow data. Can be used to
46
+ * invalidate borrow data manually, which forces the data to be re-fetched.
47
+ * @returns Function `invalidateBorrowData` for invalidating the borrow data
48
+ */
49
+ export declare function useInvalidateBorrowData(): {
50
+ invalidateBorrowData: () => Promise<void>;
51
+ };
52
+ /**
53
+ * Hook for for resetting current user's borrow data. Can be used to reset
54
+ * borrow data manually, which forces the data to be re-fetched.
55
+ * @returns Function `resetBorrowData` for resetting the borrow data
56
+ */
57
+ export declare function useResetBorrowData(): {
58
+ resetBorrowData: () => Promise<void>;
59
+ };
60
+ //# sourceMappingURL=useBorrowData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBorrowData.d.ts","sourceRoot":"","sources":["../../../src/hooks/useBorrowData.ts"],"names":[],"mappings":"AAgEA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,YAAY,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAiC9C;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB;;EAatC;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB;;EAajC"}
@@ -0,0 +1,122 @@
1
+ import { useAccount, useReadContract } 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
+ // Wagmi handles typesafety with ABI const assertions. TypeScript doesn't
9
+ // support importing JSON as const yet so types cannot be inferred from the
10
+ // imported contract. As a workaround there is minimal ABI definition that can
11
+ // be asserted types from.
12
+ // Ref: https://wagmi.sh/core/typescript#const-assert-abis-typed-data
13
+ const TROVE_MANAGER_ABI = [
14
+ {
15
+ inputs: [
16
+ {
17
+ internalType: "address",
18
+ name: "_borrower",
19
+ type: "address",
20
+ },
21
+ ],
22
+ name: "getEntireDebtAndColl",
23
+ outputs: [
24
+ {
25
+ internalType: "uint256",
26
+ name: "coll",
27
+ type: "uint256",
28
+ },
29
+ {
30
+ internalType: "uint256",
31
+ name: "principal",
32
+ type: "uint256",
33
+ },
34
+ {
35
+ internalType: "uint256",
36
+ name: "interest",
37
+ type: "uint256",
38
+ },
39
+ {
40
+ internalType: "uint256",
41
+ name: "pendingCollateral",
42
+ type: "uint256",
43
+ },
44
+ {
45
+ internalType: "uint256",
46
+ name: "pendingPrincipal",
47
+ type: "uint256",
48
+ },
49
+ {
50
+ internalType: "uint256",
51
+ name: "pendingInterest",
52
+ type: "uint256",
53
+ },
54
+ ],
55
+ stateMutability: "view",
56
+ type: "function",
57
+ },
58
+ ];
59
+ /**
60
+ * Query hook for getting borrow data. Returns collateral and trove debt for the
61
+ * connected account, based on it's evm address.
62
+ * @param queryOptions Query options passed to the underlying `useQuery` hook.
63
+ */
64
+ export function useBorrowData(queryOptions = {}) {
65
+ const { environment = "mainnet" } = usePassportContext();
66
+ const { address } = useAccount();
67
+ const contractAddress = useMemo(() => {
68
+ if (environment === "mainnet") {
69
+ return mainnetBorrowContracts.TroveManager.address;
70
+ }
71
+ return testnetBorrowContracts.TroveManager.address;
72
+ }, [environment]);
73
+ return useReadContract({
74
+ abi: TROVE_MANAGER_ABI,
75
+ address: contractAddress,
76
+ functionName: "getEntireDebtAndColl",
77
+ args: [address || "0x"],
78
+ query: {
79
+ enabled: !!address,
80
+ staleTime: 5 * ONE_MINUTE_MS,
81
+ retry: 1,
82
+ select: (data) => {
83
+ if (!data)
84
+ return undefined;
85
+ const [collateral, principal, interest] = data;
86
+ return {
87
+ collateral,
88
+ troveDebt: principal + interest,
89
+ };
90
+ },
91
+ ...queryOptions,
92
+ },
93
+ chainId: CHAIN_ID[environment],
94
+ });
95
+ }
96
+ /**
97
+ * Hook for for invalidating current user's borrow data. Can be used to
98
+ * invalidate borrow data manually, which forces the data to be re-fetched.
99
+ * @returns Function `invalidateBorrowData` for invalidating the borrow data
100
+ */
101
+ export function useInvalidateBorrowData() {
102
+ const queryClient = useQueryClient();
103
+ const { queryKey } = useBorrowData();
104
+ const invalidateBorrowDataHandler = useCallback(() => queryClient.invalidateQueries({ queryKey }), [queryClient, queryKey]);
105
+ return {
106
+ invalidateBorrowData: invalidateBorrowDataHandler,
107
+ };
108
+ }
109
+ /**
110
+ * Hook for for resetting current user's borrow data. Can be used to reset
111
+ * borrow data manually, which forces the data to be re-fetched.
112
+ * @returns Function `resetBorrowData` for resetting the borrow data
113
+ */
114
+ export function useResetBorrowData() {
115
+ const queryClient = useQueryClient();
116
+ const { queryKey } = useBorrowData();
117
+ const resetBorrowDataHandler = useCallback(() => queryClient.resetQueries({ queryKey }), [queryClient, queryKey]);
118
+ return {
119
+ resetBorrowData: resetBorrowDataHandler,
120
+ };
121
+ }
122
+ //# 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,eAAe,EAAE,MAAM,OAAO,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,OAAO,E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AAE,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,4 +1,6 @@
1
- export declare function useCreateAccount(useMutationOptions?: {}): {
1
+ import { MutationOptions, DefaultError } from "@tanstack/react-query";
2
+ import type { CreateAccountRequest, CreateAccountResponse } from "../api";
3
+ export declare function useCreateAccount(mutationOptions?: Omit<MutationOptions<CreateAccountResponse, DefaultError, CreateAccountRequest>, "mutationFn" | "mutationKey">): {
2
4
  data: undefined;
3
5
  variables: undefined;
4
6
  error: null;
@@ -16,52 +18,16 @@ export declare function useCreateAccount(useMutationOptions?: {}): {
16
18
  createAccount: import("@tanstack/react-query").UseMutateFunction<{
17
19
  mezoId: string;
18
20
  hasModifiedMezoId: boolean;
19
- linkedAccounts: import("../api/auth").LinkedAccount[];
20
- authUser: {
21
- id: string;
22
- app_metadata: {
23
- provider: "wallet" | "discord" | "email";
24
- providers: ("wallet" | "discord" | "email")[];
25
- };
26
- user_metadata: {
27
- mezoId?: string | undefined;
28
- btcAddress: string;
29
- evmAddress: string;
30
- };
31
- };
32
- }, Error, {
33
- type: "wallet";
34
- message: string;
35
- signature: string;
36
- }, unknown>;
21
+ linkedAccounts: import("../api").LinkedAccount[];
22
+ }, Error, CreateAccountRequest, unknown>;
37
23
  createAccountAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
38
24
  mezoId: string;
39
25
  hasModifiedMezoId: boolean;
40
- linkedAccounts: import("../api/auth").LinkedAccount[];
41
- authUser: {
42
- id: string;
43
- app_metadata: {
44
- provider: "wallet" | "discord" | "email";
45
- providers: ("wallet" | "discord" | "email")[];
46
- };
47
- user_metadata: {
48
- mezoId?: string | undefined;
49
- btcAddress: string;
50
- evmAddress: string;
51
- };
52
- };
53
- }, Error, {
54
- type: "wallet";
55
- message: string;
56
- signature: string;
57
- }, unknown>;
26
+ linkedAccounts: import("../api").LinkedAccount[];
27
+ }, Error, CreateAccountRequest, unknown>;
58
28
  } | {
59
29
  data: undefined;
60
- variables: {
61
- type: "wallet";
62
- message: string;
63
- signature: string;
64
- };
30
+ variables: CreateAccountRequest;
65
31
  error: null;
66
32
  isError: false;
67
33
  isIdle: false;
@@ -77,53 +43,17 @@ export declare function useCreateAccount(useMutationOptions?: {}): {
77
43
  createAccount: import("@tanstack/react-query").UseMutateFunction<{
78
44
  mezoId: string;
79
45
  hasModifiedMezoId: boolean;
80
- linkedAccounts: import("../api/auth").LinkedAccount[];
81
- authUser: {
82
- id: string;
83
- app_metadata: {
84
- provider: "wallet" | "discord" | "email";
85
- providers: ("wallet" | "discord" | "email")[];
86
- };
87
- user_metadata: {
88
- mezoId?: string | undefined;
89
- btcAddress: string;
90
- evmAddress: string;
91
- };
92
- };
93
- }, Error, {
94
- type: "wallet";
95
- message: string;
96
- signature: string;
97
- }, unknown>;
46
+ linkedAccounts: import("../api").LinkedAccount[];
47
+ }, Error, CreateAccountRequest, unknown>;
98
48
  createAccountAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
99
49
  mezoId: string;
100
50
  hasModifiedMezoId: boolean;
101
- linkedAccounts: import("../api/auth").LinkedAccount[];
102
- authUser: {
103
- id: string;
104
- app_metadata: {
105
- provider: "wallet" | "discord" | "email";
106
- providers: ("wallet" | "discord" | "email")[];
107
- };
108
- user_metadata: {
109
- mezoId?: string | undefined;
110
- btcAddress: string;
111
- evmAddress: string;
112
- };
113
- };
114
- }, Error, {
115
- type: "wallet";
116
- message: string;
117
- signature: string;
118
- }, unknown>;
51
+ linkedAccounts: import("../api").LinkedAccount[];
52
+ }, Error, CreateAccountRequest, unknown>;
119
53
  } | {
120
54
  data: undefined;
121
55
  error: Error;
122
- variables: {
123
- type: "wallet";
124
- message: string;
125
- signature: string;
126
- };
56
+ variables: CreateAccountRequest;
127
57
  isError: true;
128
58
  isIdle: false;
129
59
  isPending: false;
@@ -138,69 +68,21 @@ export declare function useCreateAccount(useMutationOptions?: {}): {
138
68
  createAccount: import("@tanstack/react-query").UseMutateFunction<{
139
69
  mezoId: string;
140
70
  hasModifiedMezoId: boolean;
141
- linkedAccounts: import("../api/auth").LinkedAccount[];
142
- authUser: {
143
- id: string;
144
- app_metadata: {
145
- provider: "wallet" | "discord" | "email";
146
- providers: ("wallet" | "discord" | "email")[];
147
- };
148
- user_metadata: {
149
- mezoId?: string | undefined;
150
- btcAddress: string;
151
- evmAddress: string;
152
- };
153
- };
154
- }, Error, {
155
- type: "wallet";
156
- message: string;
157
- signature: string;
158
- }, unknown>;
71
+ linkedAccounts: import("../api").LinkedAccount[];
72
+ }, Error, CreateAccountRequest, unknown>;
159
73
  createAccountAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
160
74
  mezoId: string;
161
75
  hasModifiedMezoId: boolean;
162
- linkedAccounts: import("../api/auth").LinkedAccount[];
163
- authUser: {
164
- id: string;
165
- app_metadata: {
166
- provider: "wallet" | "discord" | "email";
167
- providers: ("wallet" | "discord" | "email")[];
168
- };
169
- user_metadata: {
170
- mezoId?: string | undefined;
171
- btcAddress: string;
172
- evmAddress: string;
173
- };
174
- };
175
- }, Error, {
176
- type: "wallet";
177
- message: string;
178
- signature: string;
179
- }, unknown>;
76
+ linkedAccounts: import("../api").LinkedAccount[];
77
+ }, Error, CreateAccountRequest, unknown>;
180
78
  } | {
181
79
  data: {
182
80
  mezoId: string;
183
81
  hasModifiedMezoId: boolean;
184
- linkedAccounts: import("../api/auth").LinkedAccount[];
185
- authUser: {
186
- id: string;
187
- app_metadata: {
188
- provider: "wallet" | "discord" | "email";
189
- providers: ("wallet" | "discord" | "email")[];
190
- };
191
- user_metadata: {
192
- mezoId?: string | undefined;
193
- btcAddress: string;
194
- evmAddress: string;
195
- };
196
- };
82
+ linkedAccounts: import("../api").LinkedAccount[];
197
83
  };
198
84
  error: null;
199
- variables: {
200
- type: "wallet";
201
- message: string;
202
- signature: string;
203
- };
85
+ variables: CreateAccountRequest;
204
86
  isError: false;
205
87
  isIdle: false;
206
88
  isPending: false;
@@ -215,44 +97,12 @@ export declare function useCreateAccount(useMutationOptions?: {}): {
215
97
  createAccount: import("@tanstack/react-query").UseMutateFunction<{
216
98
  mezoId: string;
217
99
  hasModifiedMezoId: boolean;
218
- linkedAccounts: import("../api/auth").LinkedAccount[];
219
- authUser: {
220
- id: string;
221
- app_metadata: {
222
- provider: "wallet" | "discord" | "email";
223
- providers: ("wallet" | "discord" | "email")[];
224
- };
225
- user_metadata: {
226
- mezoId?: string | undefined;
227
- btcAddress: string;
228
- evmAddress: string;
229
- };
230
- };
231
- }, Error, {
232
- type: "wallet";
233
- message: string;
234
- signature: string;
235
- }, unknown>;
100
+ linkedAccounts: import("../api").LinkedAccount[];
101
+ }, Error, CreateAccountRequest, unknown>;
236
102
  createAccountAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
237
103
  mezoId: string;
238
104
  hasModifiedMezoId: boolean;
239
- linkedAccounts: import("../api/auth").LinkedAccount[];
240
- authUser: {
241
- id: string;
242
- app_metadata: {
243
- provider: "wallet" | "discord" | "email";
244
- providers: ("wallet" | "discord" | "email")[];
245
- };
246
- user_metadata: {
247
- mezoId?: string | undefined;
248
- btcAddress: string;
249
- evmAddress: string;
250
- };
251
- };
252
- }, Error, {
253
- type: "wallet";
254
- message: string;
255
- signature: string;
256
- }, unknown>;
105
+ linkedAccounts: import("../api").LinkedAccount[];
106
+ }, Error, CreateAccountRequest, unknown>;
257
107
  };
258
108
  //# sourceMappingURL=useCreateAccount.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCreateAccount.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCreateAccount.ts"],"names":[],"mappings":"AAKA,wBAAgB,gBAAgB,CAAC,kBAAkB,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgBvD"}
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,17 +1,20 @@
1
- import { useQueryClient, useMutation } from "@tanstack/react-query";
1
+ import { useQueryClient, useMutation, } from "@tanstack/react-query";
2
2
  import { useAuthApiClient } from "./useAuthApiClient";
3
3
  import { QUERY_KEYS } from "./constants";
4
- export function useCreateAccount(useMutationOptions = {}) {
4
+ export function useCreateAccount(mutationOptions = {}) {
5
5
  const queryClient = useQueryClient();
6
6
  const authApiClient = useAuthApiClient();
7
+ const { onSuccess: customOnSuccess, ...restMutationOptions } = mutationOptions;
7
8
  const { mutate, mutateAsync, ...rest } = useMutation({
8
9
  mutationFn: (createAccountRequest) => authApiClient.createAccount(createAccountRequest),
9
- onSuccess: () => {
10
+ onSuccess: (data, variables, context) => {
10
11
  queryClient.resetQueries({
11
12
  queryKey: [QUERY_KEYS.ACCOUNT],
12
13
  });
14
+ if (customOnSuccess)
15
+ customOnSuccess(data, variables, context);
13
16
  },
14
- ...useMutationOptions,
17
+ ...restMutationOptions,
15
18
  });
16
19
  return { createAccount: mutate, createAccountAsync: mutateAsync, ...rest };
17
20
  }