@mezo-org/passport 0.4.0-dev.5 → 0.4.0-dev.50

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 (328) 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/endpoint-error.d.ts +4 -0
  11. package/dist/src/api/endpoint-error.d.ts.map +1 -0
  12. package/dist/src/api/endpoint-error.js +6 -0
  13. package/dist/src/api/endpoint-error.js.map +1 -0
  14. package/dist/src/api/fetch-error copy.d.ts +5 -0
  15. package/dist/src/api/fetch-error copy.d.ts.map +1 -0
  16. package/dist/src/api/fetch-error copy.js +8 -0
  17. package/dist/src/api/fetch-error copy.js.map +1 -0
  18. package/dist/src/api/fetch-error.d.ts +5 -0
  19. package/dist/src/api/fetch-error.d.ts.map +1 -0
  20. package/dist/src/api/fetch-error.js +8 -0
  21. package/dist/src/api/fetch-error.js.map +1 -0
  22. package/dist/src/api/index.d.ts +3 -0
  23. package/dist/src/api/index.d.ts.map +1 -0
  24. package/dist/src/api/index.js +3 -0
  25. package/dist/src/api/index.js.map +1 -0
  26. package/dist/src/api/portal.d.ts +26 -0
  27. package/dist/src/api/portal.d.ts.map +1 -0
  28. package/dist/src/api/portal.js +23 -0
  29. package/dist/src/api/portal.js.map +1 -0
  30. package/dist/src/assets/DefaultAvatar.d.ts +5 -0
  31. package/dist/src/assets/DefaultAvatar.d.ts.map +1 -0
  32. package/dist/src/assets/DefaultAvatar.js +21 -0
  33. package/dist/src/assets/DefaultAvatar.js.map +1 -0
  34. package/dist/src/components/Dropdown/ConnectedTrigger.d.ts +8 -0
  35. package/dist/src/components/Dropdown/ConnectedTrigger.d.ts.map +1 -0
  36. package/dist/src/components/Dropdown/ConnectedTrigger.js +39 -0
  37. package/dist/src/components/Dropdown/ConnectedTrigger.js.map +1 -0
  38. package/dist/src/components/Dropdown/Content.d.ts +23 -0
  39. package/dist/src/components/Dropdown/Content.d.ts.map +1 -0
  40. package/dist/src/components/Dropdown/Content.js +27 -0
  41. package/dist/src/components/Dropdown/Content.js.map +1 -0
  42. package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts +7 -0
  43. package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts.map +1 -0
  44. package/dist/src/components/Dropdown/DisconnectedTrigger.js +13 -0
  45. package/dist/src/components/Dropdown/DisconnectedTrigger.js.map +1 -0
  46. package/dist/src/components/Dropdown/Dropdown.d.ts +27 -0
  47. package/dist/src/components/Dropdown/Dropdown.d.ts.map +1 -0
  48. package/dist/src/components/Dropdown/Dropdown.js +68 -0
  49. package/dist/src/components/Dropdown/Dropdown.js.map +1 -0
  50. package/dist/src/components/Dropdown/ListingItem.d.ts +13 -0
  51. package/dist/src/components/Dropdown/ListingItem.d.ts.map +1 -0
  52. package/dist/src/components/Dropdown/ListingItem.js +34 -0
  53. package/dist/src/components/Dropdown/ListingItem.js.map +1 -0
  54. package/dist/src/components/Dropdown/NestedViewLayout.d.ts +7 -0
  55. package/dist/src/components/Dropdown/NestedViewLayout.d.ts.map +1 -0
  56. package/dist/src/components/Dropdown/NestedViewLayout.js +34 -0
  57. package/dist/src/components/Dropdown/NestedViewLayout.js.map +1 -0
  58. package/dist/src/components/Dropdown/Receive/Receive.d.ts +7 -0
  59. package/dist/src/components/Dropdown/Receive/Receive.d.ts.map +1 -0
  60. package/dist/src/components/Dropdown/Receive/Receive.js +53 -0
  61. package/dist/src/components/Dropdown/Receive/Receive.js.map +1 -0
  62. package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts +7 -0
  63. package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts.map +1 -0
  64. package/dist/src/components/Dropdown/Root/AccountAddressActions.js +48 -0
  65. package/dist/src/components/Dropdown/Root/AccountAddressActions.js.map +1 -0
  66. package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts +11 -0
  67. package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts.map +1 -0
  68. package/dist/src/components/Dropdown/Root/AccountAssetItem.js +9 -0
  69. package/dist/src/components/Dropdown/Root/AccountAssetItem.js.map +1 -0
  70. package/dist/src/components/Dropdown/Root/AccountBalance.d.ts +8 -0
  71. package/dist/src/components/Dropdown/Root/AccountBalance.d.ts.map +1 -0
  72. package/dist/src/components/Dropdown/Root/AccountBalance.js +15 -0
  73. package/dist/src/components/Dropdown/Root/AccountBalance.js.map +1 -0
  74. package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts +9 -0
  75. package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts.map +1 -0
  76. package/dist/src/components/Dropdown/Root/AccountOtherAssets.js +48 -0
  77. package/dist/src/components/Dropdown/Root/AccountOtherAssets.js.map +1 -0
  78. package/dist/src/components/Dropdown/Root/Root.d.ts +23 -0
  79. package/dist/src/components/Dropdown/Root/Root.d.ts.map +1 -0
  80. package/dist/src/components/Dropdown/Root/Root.js +57 -0
  81. package/dist/src/components/Dropdown/Root/Root.js.map +1 -0
  82. package/dist/src/components/Dropdown/Root/WalletAddress.d.ts +8 -0
  83. package/dist/src/components/Dropdown/Root/WalletAddress.d.ts.map +1 -0
  84. package/dist/src/components/Dropdown/Root/WalletAddress.js +64 -0
  85. package/dist/src/components/Dropdown/Root/WalletAddress.js.map +1 -0
  86. package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts +8 -0
  87. package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts.map +1 -0
  88. package/dist/src/components/Dropdown/Root/WelcomeBlock.js +44 -0
  89. package/dist/src/components/Dropdown/Root/WelcomeBlock.js.map +1 -0
  90. package/dist/src/components/Dropdown/TestnetTopBanner.d.ts +3 -0
  91. package/dist/src/components/Dropdown/TestnetTopBanner.d.ts.map +1 -0
  92. package/dist/src/components/Dropdown/TestnetTopBanner.js +14 -0
  93. package/dist/src/components/Dropdown/TestnetTopBanner.js.map +1 -0
  94. package/dist/src/components/Dropdown/index.d.ts +3 -0
  95. package/dist/src/components/Dropdown/index.d.ts.map +1 -0
  96. package/dist/src/components/Dropdown/index.js +2 -0
  97. package/dist/src/components/Dropdown/index.js.map +1 -0
  98. package/dist/src/components/index.d.ts +2 -0
  99. package/dist/src/components/index.d.ts.map +1 -0
  100. package/dist/src/components/index.js +2 -0
  101. package/dist/src/components/index.js.map +1 -0
  102. package/dist/src/config.d.ts +17 -5
  103. package/dist/src/config.d.ts.map +1 -1
  104. package/dist/src/config.js +51 -14
  105. package/dist/src/config.js.map +1 -1
  106. package/dist/src/constants.d.ts +11 -3
  107. package/dist/src/constants.d.ts.map +1 -1
  108. package/dist/src/constants.js +12 -4
  109. package/dist/src/constants.js.map +1 -1
  110. package/dist/src/hooks/constants.d.ts +1 -0
  111. package/dist/src/hooks/constants.d.ts.map +1 -1
  112. package/dist/src/hooks/constants.js +1 -0
  113. package/dist/src/hooks/constants.js.map +1 -1
  114. package/dist/src/hooks/index.d.ts +3 -1
  115. package/dist/src/hooks/index.d.ts.map +1 -1
  116. package/dist/src/hooks/index.js +3 -1
  117. package/dist/src/hooks/index.js.map +1 -1
  118. package/dist/src/hooks/useAssetsConversionRates.d.ts +23 -0
  119. package/dist/src/hooks/useAssetsConversionRates.d.ts.map +1 -0
  120. package/dist/src/hooks/useAssetsConversionRates.js +85 -0
  121. package/dist/src/hooks/useAssetsConversionRates.js.map +1 -0
  122. package/dist/src/hooks/useAuthApiClient.d.ts +1 -1
  123. package/dist/src/hooks/useAuthApiClient.d.ts.map +1 -1
  124. package/dist/src/hooks/useAuthenticateWithWallet.d.ts +12 -102
  125. package/dist/src/hooks/useAuthenticateWithWallet.d.ts.map +1 -1
  126. package/dist/src/hooks/useAuthenticateWithWallet.js +28 -17
  127. package/dist/src/hooks/useAuthenticateWithWallet.js.map +1 -1
  128. package/dist/src/hooks/useBitcoinPriceConversion copy.d.ts +2 -0
  129. package/dist/src/hooks/useBitcoinPriceConversion copy.d.ts.map +1 -0
  130. package/dist/src/hooks/useBitcoinPriceConversion copy.js +43 -0
  131. package/dist/src/hooks/useBitcoinPriceConversion copy.js.map +1 -0
  132. package/dist/src/hooks/useBitcoinPriceConversion.d.ts +103 -0
  133. package/dist/src/hooks/useBitcoinPriceConversion.d.ts.map +1 -0
  134. package/dist/src/hooks/useBitcoinPriceConversion.js +50 -0
  135. package/dist/src/hooks/useBitcoinPriceConversion.js.map +1 -0
  136. package/dist/src/hooks/useBitcoinPriceFeed.d.ts +15 -0
  137. package/dist/src/hooks/useBitcoinPriceFeed.d.ts.map +1 -0
  138. package/dist/src/hooks/useBitcoinPriceFeed.js +67 -0
  139. package/dist/src/hooks/useBitcoinPriceFeed.js.map +1 -0
  140. package/dist/src/hooks/useBorrowData.d.ts +60 -0
  141. package/dist/src/hooks/useBorrowData.d.ts.map +1 -0
  142. package/dist/src/hooks/useBorrowData.js +122 -0
  143. package/dist/src/hooks/useBorrowData.js.map +1 -0
  144. package/dist/src/hooks/useCreateAccount.d.ts +23 -173
  145. package/dist/src/hooks/useCreateAccount.d.ts.map +1 -1
  146. package/dist/src/hooks/useCreateAccount.js +7 -4
  147. package/dist/src/hooks/useCreateAccount.js.map +1 -1
  148. package/dist/src/hooks/useCreateSession.d.ts +12 -101
  149. package/dist/src/hooks/useCreateSession.d.ts.map +1 -1
  150. package/dist/src/hooks/useCreateSession.js +10 -8
  151. package/dist/src/hooks/useCreateSession.js.map +1 -1
  152. package/dist/src/hooks/useDropdownData.d.ts +47 -0
  153. package/dist/src/hooks/useDropdownData.d.ts.map +1 -0
  154. package/dist/src/hooks/useDropdownData.js +99 -0
  155. package/dist/src/hooks/useDropdownData.js.map +1 -0
  156. package/dist/src/hooks/useGetAccountByAddress.d.ts +2 -2
  157. package/dist/src/hooks/useGetAccountByAddress.d.ts.map +1 -1
  158. package/dist/src/hooks/useGetAccountByMezoId.d.ts +2 -2
  159. package/dist/src/hooks/useGetAccountByMezoId.d.ts.map +1 -1
  160. package/dist/src/hooks/useGetCurrentAccount.d.ts +16 -2
  161. package/dist/src/hooks/useGetCurrentAccount.d.ts.map +1 -1
  162. package/dist/src/hooks/useGetCurrentAccount.js +25 -3
  163. package/dist/src/hooks/useGetCurrentAccount.js.map +1 -1
  164. package/dist/src/hooks/useGetSession.d.ts +1 -1
  165. package/dist/src/hooks/useGetSession.d.ts.map +1 -1
  166. package/dist/src/hooks/useLinkAccount.d.ts +15 -175
  167. package/dist/src/hooks/useLinkAccount.d.ts.map +1 -1
  168. package/dist/src/hooks/useLinkAccount.js +7 -4
  169. package/dist/src/hooks/useLinkAccount.js.map +1 -1
  170. package/dist/src/hooks/usePortalApiClient.d.ts +2 -0
  171. package/dist/src/hooks/usePortalApiClient.d.ts.map +1 -0
  172. package/dist/src/hooks/usePortalApiClient.js +6 -0
  173. package/dist/src/hooks/usePortalApiClient.js.map +1 -0
  174. package/dist/src/hooks/useRefreshPassport.d.ts +19 -0
  175. package/dist/src/hooks/useRefreshPassport.d.ts.map +1 -0
  176. package/dist/src/hooks/useRefreshPassport.js +44 -0
  177. package/dist/src/hooks/useRefreshPassport.js.map +1 -0
  178. package/dist/src/hooks/useSignInWithDiscord.d.ts +12 -100
  179. package/dist/src/hooks/useSignInWithDiscord.d.ts.map +1 -1
  180. package/dist/src/hooks/useSignInWithDiscord.js +6 -3
  181. package/dist/src/hooks/useSignInWithDiscord.js.map +1 -1
  182. package/dist/src/hooks/useSignInWithWallet.d.ts +12 -100
  183. package/dist/src/hooks/useSignInWithWallet.d.ts.map +1 -1
  184. package/dist/src/hooks/useSignInWithWallet.js +2 -2
  185. package/dist/src/hooks/useSignInWithWallet.js.map +1 -1
  186. package/dist/src/hooks/useSignOut.d.ts +12 -28
  187. package/dist/src/hooks/useSignOut.d.ts.map +1 -1
  188. package/dist/src/hooks/useSignOut.js +7 -4
  189. package/dist/src/hooks/useSignOut.js.map +1 -1
  190. package/dist/src/hooks/useSignUpWithWallet.d.ts +12 -100
  191. package/dist/src/hooks/useSignUpWithWallet.d.ts.map +1 -1
  192. package/dist/src/hooks/useSignUpWithWallet.js +2 -2
  193. package/dist/src/hooks/useSignUpWithWallet.js.map +1 -1
  194. package/dist/src/hooks/useTokensBalances.d.ts +74 -0
  195. package/dist/src/hooks/useTokensBalances.d.ts.map +1 -0
  196. package/dist/src/hooks/useTokensBalances.js +140 -0
  197. package/dist/src/hooks/useTokensBalances.js.map +1 -0
  198. package/dist/src/hooks/useUpdateMezoId.d.ts +30 -136
  199. package/dist/src/hooks/useUpdateMezoId.d.ts.map +1 -1
  200. package/dist/src/hooks/useUpdateMezoId.js +7 -4
  201. package/dist/src/hooks/useUpdateMezoId.js.map +1 -1
  202. package/dist/src/hooks/useWalletAccount.d.ts +13 -0
  203. package/dist/src/hooks/useWalletAccount.d.ts.map +1 -0
  204. package/dist/src/hooks/useWalletAccount.js +29 -0
  205. package/dist/src/hooks/useWalletAccount.js.map +1 -0
  206. package/dist/src/hooks/useWatchTransferEvents.d.ts +5 -0
  207. package/dist/src/hooks/useWatchTransferEvents.d.ts.map +1 -0
  208. package/dist/src/hooks/useWatchTransferEvents.js +63 -0
  209. package/dist/src/hooks/useWatchTransferEvents.js.map +1 -0
  210. package/dist/src/index.d.ts +2 -1
  211. package/dist/src/index.d.ts.map +1 -1
  212. package/dist/src/index.js +2 -1
  213. package/dist/src/index.js.map +1 -1
  214. package/dist/src/lib/contracts/index.d.ts +13 -0
  215. package/dist/src/lib/contracts/index.d.ts.map +1 -0
  216. package/dist/src/lib/contracts/index.js +58 -0
  217. package/dist/src/lib/contracts/index.js.map +1 -0
  218. package/dist/src/lib/contracts/price-oracle.d.ts +43 -0
  219. package/dist/src/lib/contracts/price-oracle.d.ts.map +1 -0
  220. package/dist/src/lib/contracts/price-oracle.js +52 -0
  221. package/dist/src/lib/contracts/price-oracle.js.map +1 -0
  222. package/dist/src/lib/contracts/priceOracle.d.ts +43 -0
  223. package/dist/src/lib/contracts/priceOracle.d.ts.map +1 -0
  224. package/dist/src/lib/contracts/priceOracle.js +52 -0
  225. package/dist/src/lib/contracts/priceOracle.js.map +1 -0
  226. package/dist/src/provider.d.ts +10 -13
  227. package/dist/src/provider.d.ts.map +1 -1
  228. package/dist/src/provider.js +11 -20
  229. package/dist/src/provider.js.map +1 -1
  230. package/dist/src/stores/dropdownStore.d.ts +12 -0
  231. package/dist/src/stores/dropdownStore.d.ts.map +1 -0
  232. package/dist/src/stores/dropdownStore.js +13 -0
  233. package/dist/src/stores/dropdownStore.js.map +1 -0
  234. package/dist/src/utils/address.d.ts +15 -0
  235. package/dist/src/utils/address.d.ts.map +1 -0
  236. package/dist/src/utils/address.js +37 -0
  237. package/dist/src/utils/address.js.map +1 -0
  238. package/dist/src/utils/address.test.d.ts +2 -0
  239. package/dist/src/utils/address.test.d.ts.map +1 -0
  240. package/dist/src/utils/address.test.js +40 -0
  241. package/dist/src/utils/address.test.js.map +1 -0
  242. package/dist/src/utils/cryptoAssets.d.ts +44 -0
  243. package/dist/src/utils/cryptoAssets.d.ts.map +1 -0
  244. package/dist/src/utils/cryptoAssets.js +132 -0
  245. package/dist/src/utils/cryptoAssets.js.map +1 -0
  246. package/dist/src/utils/cryptoAssets.test.d.ts +2 -0
  247. package/dist/src/utils/cryptoAssets.test.d.ts.map +1 -0
  248. package/dist/src/utils/cryptoAssets.test.js +67 -0
  249. package/dist/src/utils/cryptoAssets.test.js.map +1 -0
  250. package/dist/src/utils/currency.d.ts +14 -0
  251. package/dist/src/utils/currency.d.ts.map +1 -0
  252. package/dist/src/utils/currency.js +27 -0
  253. package/dist/src/utils/currency.js.map +1 -0
  254. package/dist/src/utils/currency.test.d.ts +2 -0
  255. package/dist/src/utils/currency.test.d.ts.map +1 -0
  256. package/dist/src/utils/currency.test.js +34 -0
  257. package/dist/src/utils/currency.test.js.map +1 -0
  258. package/dist/src/utils/numbers.d.ts +58 -0
  259. package/dist/src/utils/numbers.d.ts.map +1 -0
  260. package/dist/src/utils/numbers.js +132 -0
  261. package/dist/src/utils/numbers.js.map +1 -0
  262. package/dist/src/utils/numbers.test.d.ts +2 -0
  263. package/dist/src/utils/numbers.test.d.ts.map +1 -0
  264. package/dist/src/utils/numbers.test.js +170 -0
  265. package/dist/src/utils/numbers.test.js.map +1 -0
  266. package/package.json +14 -8
  267. package/src/api/auth.ts +73 -128
  268. package/src/api/client.ts +87 -0
  269. package/src/api/fetch-error.ts +8 -0
  270. package/src/api/index.ts +2 -0
  271. package/src/api/portal.ts +53 -0
  272. package/src/assets/DefaultAvatar.tsx +74 -0
  273. package/src/components/Dropdown/ConnectedTrigger.tsx +76 -0
  274. package/src/components/Dropdown/Content.tsx +98 -0
  275. package/src/components/Dropdown/DisconnectedTrigger.tsx +36 -0
  276. package/src/components/Dropdown/Dropdown.tsx +148 -0
  277. package/src/components/Dropdown/ListingItem.tsx +80 -0
  278. package/src/components/Dropdown/NestedViewLayout.tsx +75 -0
  279. package/src/components/Dropdown/README.md +41 -0
  280. package/src/components/Dropdown/Receive/Receive.tsx +119 -0
  281. package/src/components/Dropdown/Root/AccountAddressActions.tsx +101 -0
  282. package/src/components/Dropdown/Root/AccountAssetItem.tsx +26 -0
  283. package/src/components/Dropdown/Root/AccountBalance.tsx +30 -0
  284. package/src/components/Dropdown/Root/AccountOtherAssets.tsx +68 -0
  285. package/src/components/Dropdown/Root/Root.tsx +147 -0
  286. package/src/components/Dropdown/Root/WalletAddress.tsx +128 -0
  287. package/src/components/Dropdown/Root/WelcomeBlock.tsx +91 -0
  288. package/src/components/Dropdown/TestnetTopBanner.tsx +32 -0
  289. package/src/components/Dropdown/index.ts +2 -0
  290. package/src/components/index.ts +1 -0
  291. package/src/config.ts +77 -20
  292. package/src/constants.ts +12 -4
  293. package/src/hooks/constants.ts +1 -0
  294. package/src/hooks/index.ts +6 -1
  295. package/src/hooks/useAssetsConversionRates.ts +92 -0
  296. package/src/hooks/useAuthenticateWithWallet.ts +44 -23
  297. package/src/hooks/useBorrowData.ts +143 -0
  298. package/src/hooks/useCreateAccount.ts +19 -5
  299. package/src/hooks/useCreateSession.ts +22 -9
  300. package/src/hooks/useDropdownData.ts +149 -0
  301. package/src/hooks/useGetAccountByAddress.ts +2 -2
  302. package/src/hooks/useGetAccountByMezoId.ts +2 -2
  303. package/src/hooks/useGetCurrentAccount.ts +46 -6
  304. package/src/hooks/useGetSession.ts +1 -1
  305. package/src/hooks/useLinkAccount.ts +18 -5
  306. package/src/hooks/usePortalApiClient.ts +6 -0
  307. package/src/hooks/useRefreshPassport.ts +56 -0
  308. package/src/hooks/useSignInWithDiscord.ts +14 -5
  309. package/src/hooks/useSignInWithWallet.ts +9 -2
  310. package/src/hooks/useSignOut.ts +18 -4
  311. package/src/hooks/useSignUpWithWallet.ts +9 -2
  312. package/src/hooks/useTokensBalances.ts +187 -0
  313. package/src/hooks/useUpdateMezoId.ts +19 -4
  314. package/src/hooks/useWalletAccount.ts +55 -0
  315. package/src/hooks/useWatchTransferEvents.ts +74 -0
  316. package/src/index.ts +12 -1
  317. package/src/lib/contracts/index.ts +90 -0
  318. package/src/lib/contracts/priceOracle.ts +53 -0
  319. package/src/provider.ts +30 -37
  320. package/src/stores/dropdownStore.ts +20 -0
  321. package/src/utils/address.test.ts +48 -0
  322. package/src/utils/address.ts +45 -0
  323. package/src/utils/cryptoAssets.test.ts +79 -0
  324. package/src/utils/cryptoAssets.ts +173 -0
  325. package/src/utils/currency.test.ts +38 -0
  326. package/src/utils/currency.ts +32 -0
  327. package/src/utils/numbers.test.ts +220 -0
  328. package/src/utils/numbers.ts +188 -0
@@ -1,13 +1,15 @@
1
1
  export { useBitcoinAccount, useSendBitcoin, useSendTransaction, useSubscribeToConnectedToUnsupportedBitcoinAddress, useSubscribeToConnectorEvent, useSubscribeToWalletNetworkDoesNotMatchProviderChain, } from "@mezo-org/orangekit";
2
- export * from "./useCreateAccount";
2
+ export { useInvalidateBorrowData, useResetBorrowData } from "./useBorrowData";
3
3
  export * from "./useGetAccountByAddress";
4
4
  export * from "./useGetAccountByMezoId";
5
5
  export * from "./useGetCurrentAccount";
6
6
  export * from "./useGetSession";
7
7
  export * from "./useLinkAccount";
8
+ export * from "./useRefreshPassport";
8
9
  export * from "./useSignInWithDiscord";
9
10
  export * from "./useSignInWithWallet";
10
11
  export * from "./useSignOut";
11
12
  export * from "./useSignUpWithWallet";
13
+ export { useInvalidateTokensBalances, useResetTokensBalances, } from "./useTokensBalances";
12
14
  export * from "./useUpdateMezoId";
13
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,kDAAkD,EAClD,4BAA4B,EAC5B,oDAAoD,GACrD,MAAM,qBAAqB,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,uBAAuB,CAAA;AACrC,cAAc,mBAAmB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,kDAAkD,EAClD,4BAA4B,EAC5B,oDAAoD,GACrD,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAC7E,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,uBAAuB,CAAA;AACrC,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,qBAAqB,CAAA;AAC5B,cAAc,mBAAmB,CAAA"}
@@ -1,13 +1,15 @@
1
1
  export { useBitcoinAccount, useSendBitcoin, useSendTransaction, useSubscribeToConnectedToUnsupportedBitcoinAddress, useSubscribeToConnectorEvent, useSubscribeToWalletNetworkDoesNotMatchProviderChain, } from "@mezo-org/orangekit";
2
- export * from "./useCreateAccount";
2
+ export { useInvalidateBorrowData, useResetBorrowData } from "./useBorrowData";
3
3
  export * from "./useGetAccountByAddress";
4
4
  export * from "./useGetAccountByMezoId";
5
5
  export * from "./useGetCurrentAccount";
6
6
  export * from "./useGetSession";
7
7
  export * from "./useLinkAccount";
8
+ export * from "./useRefreshPassport";
8
9
  export * from "./useSignInWithDiscord";
9
10
  export * from "./useSignInWithWallet";
10
11
  export * from "./useSignOut";
11
12
  export * from "./useSignUpWithWallet";
13
+ export { useInvalidateTokensBalances, useResetTokensBalances, } from "./useTokensBalances";
12
14
  export * from "./useUpdateMezoId";
13
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,kDAAkD,EAClD,4BAA4B,EAC5B,oDAAoD,GACrD,MAAM,qBAAqB,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,uBAAuB,CAAA;AACrC,cAAc,mBAAmB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,kDAAkD,EAClD,4BAA4B,EAC5B,oDAAoD,GACrD,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAC7E,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,uBAAuB,CAAA;AACrC,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,qBAAqB,CAAA;AAC5B,cAAc,mBAAmB,CAAA"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Hook to fetch assets conversion rates.
3
+ * @see https://github.com/mezo-org/musd/blob/f0b2030315f0d8b0fc11a9fc778856fe4673051f/solidity/contracts/PriceFeed.sol
4
+ * @returns {}.data.{}.price - The latest asset price.
5
+ * @returns {}.data.{}.digits - The latest asset price digits.
6
+ * @returns {}.isPending - Whether the request is pending.
7
+ * @returns {}.isError - Whether there was an error fetching the price.
8
+ */
9
+ export declare function useAssetsConversionRates(): {
10
+ data: {
11
+ t: {
12
+ price: bigint;
13
+ decimals: number;
14
+ };
15
+ btc: {
16
+ price: bigint;
17
+ decimals: number;
18
+ };
19
+ };
20
+ isPending: boolean;
21
+ isError: boolean;
22
+ };
23
+ //# sourceMappingURL=useAssetsConversionRates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAssetsConversionRates.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAssetsConversionRates.ts"],"names":[],"mappings":"AA+BA;;;;;;;GAOG;AACH,wBAAgB,wBAAwB;;;;;;;;;;;;;EAoDvC"}
@@ -0,0 +1,85 @@
1
+ import { useQuery } from "@tanstack/react-query";
2
+ import { useReadContract } from "wagmi";
3
+ import { ONE_SECOND_MS } from "../utils/time";
4
+ import { QUERY_KEYS } from "./constants";
5
+ import { usePortalApiClient } from "./usePortalApiClient";
6
+ import { priceOracleContract } from "../lib/contracts";
7
+ import { fromFloatToBigInt } from "../utils/numbers";
8
+ const BTC_TARGET_DIGITS = 18;
9
+ const T_TARGET_DIGITS = 10;
10
+ // If the oracle has not been updated in at least 60 seconds, it is stale.
11
+ const MAX_PRICE_DELAY = 60 * ONE_SECOND_MS;
12
+ /**
13
+ * Scales the price by the number of digits.
14
+ * @dev Oracles returns prices with variable number of digits. This function
15
+ * scales the price to a fixed number of digits ensuring consistency.
16
+ * @param price - The price to scale.
17
+ * @param priceDigits - The number of digits in the price.
18
+ * @returns The scaled price.
19
+ */
20
+ function scalePriceByDigits(price, priceDigits) {
21
+ if (priceDigits > BTC_TARGET_DIGITS) {
22
+ return price / 10n ** BigInt(priceDigits - BTC_TARGET_DIGITS);
23
+ }
24
+ if (priceDigits < BTC_TARGET_DIGITS) {
25
+ return price * 10n ** BigInt(BTC_TARGET_DIGITS - priceDigits);
26
+ }
27
+ return price;
28
+ }
29
+ /**
30
+ * Hook to fetch assets conversion rates.
31
+ * @see https://github.com/mezo-org/musd/blob/f0b2030315f0d8b0fc11a9fc778856fe4673051f/solidity/contracts/PriceFeed.sol
32
+ * @returns {}.data.{}.price - The latest asset price.
33
+ * @returns {}.data.{}.digits - The latest asset price digits.
34
+ * @returns {}.isPending - Whether the request is pending.
35
+ * @returns {}.isError - Whether there was an error fetching the price.
36
+ */
37
+ export function useAssetsConversionRates() {
38
+ const portalApiClient = usePortalApiClient();
39
+ const btcPrice = useReadContract({
40
+ ...priceOracleContract,
41
+ functionName: "latestRoundData",
42
+ query: {
43
+ refetchInterval: ({ state }) => {
44
+ if (!state.data)
45
+ return MAX_PRICE_DELAY;
46
+ const [, , , updatedAt] = state.data ?? [];
47
+ if (!updatedAt)
48
+ return MAX_PRICE_DELAY;
49
+ const age = Date.now() - Number(updatedAt) * 1000;
50
+ return age > MAX_PRICE_DELAY
51
+ ? // If the data is stale, we want to refetch as soon as possible, but
52
+ // not faster than once per second, to avoid excessive requests.
53
+ // Math.max ensures the interval is at least 1 second.
54
+ Math.max(ONE_SECOND_MS, MAX_PRICE_DELAY - age)
55
+ : MAX_PRICE_DELAY - age;
56
+ },
57
+ select: (data) => {
58
+ const [, answer] = data;
59
+ return scalePriceByDigits(answer, BTC_TARGET_DIGITS);
60
+ },
61
+ },
62
+ });
63
+ const tPrice = useQuery({
64
+ queryKey: [QUERY_KEYS.ASSETS_USD_CONVERSION],
65
+ queryFn: () => portalApiClient.getPortalStatistics(),
66
+ select: (data) => fromFloatToBigInt(data.currentUsdPerTToken, T_TARGET_DIGITS),
67
+ refetchInterval: MAX_PRICE_DELAY,
68
+ throwOnError: true,
69
+ });
70
+ return {
71
+ data: {
72
+ t: {
73
+ price: tPrice.data ?? 0n,
74
+ decimals: T_TARGET_DIGITS,
75
+ },
76
+ btc: {
77
+ price: btcPrice.data ?? 0n,
78
+ decimals: BTC_TARGET_DIGITS,
79
+ },
80
+ },
81
+ isPending: tPrice.isPending || btcPrice.isPending,
82
+ isError: tPrice.isError || btcPrice.isError,
83
+ };
84
+ }
85
+ //# sourceMappingURL=useAssetsConversionRates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAssetsConversionRates.js","sourceRoot":"","sources":["../../../src/hooks/useAssetsConversionRates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,O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-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"}
@@ -1,6 +1,6 @@
1
- declare function useAuthenticateWithWallet({ signUp, }?: {
2
- signUp?: boolean;
3
- }): {
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
4
  data: undefined;
5
5
  variables: undefined;
6
6
  error: null;
@@ -15,28 +15,8 @@ declare function useAuthenticateWithWallet({ signUp, }?: {
15
15
  failureReason: Error | null;
16
16
  isPaused: boolean;
17
17
  submittedAt: number;
18
- authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<{
19
- expiresIn: number;
20
- expiresAt: number;
21
- sessionLinks: {
22
- _links: {
23
- account: "/session/account";
24
- };
25
- };
26
- } | {
27
- redirectTo: string;
28
- }, Error, void, unknown>;
29
- authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
30
- expiresIn: number;
31
- expiresAt: number;
32
- sessionLinks: {
33
- _links: {
34
- account: "/session/account";
35
- };
36
- };
37
- } | {
38
- redirectTo: string;
39
- }, Error, void, unknown>;
18
+ authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, void, unknown>;
19
+ authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, void, unknown>;
40
20
  } | {
41
21
  data: undefined;
42
22
  variables: void;
@@ -52,28 +32,8 @@ declare function useAuthenticateWithWallet({ signUp, }?: {
52
32
  failureReason: Error | null;
53
33
  isPaused: boolean;
54
34
  submittedAt: number;
55
- authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<{
56
- expiresIn: number;
57
- expiresAt: number;
58
- sessionLinks: {
59
- _links: {
60
- account: "/session/account";
61
- };
62
- };
63
- } | {
64
- redirectTo: string;
65
- }, Error, void, unknown>;
66
- authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
67
- expiresIn: number;
68
- expiresAt: number;
69
- sessionLinks: {
70
- _links: {
71
- account: "/session/account";
72
- };
73
- };
74
- } | {
75
- redirectTo: string;
76
- }, Error, void, unknown>;
35
+ authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, void, unknown>;
36
+ authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, void, unknown>;
77
37
  } | {
78
38
  data: undefined;
79
39
  error: Error;
@@ -89,40 +49,10 @@ declare function useAuthenticateWithWallet({ signUp, }?: {
89
49
  failureReason: Error | null;
90
50
  isPaused: boolean;
91
51
  submittedAt: number;
92
- authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<{
93
- expiresIn: number;
94
- expiresAt: number;
95
- sessionLinks: {
96
- _links: {
97
- account: "/session/account";
98
- };
99
- };
100
- } | {
101
- redirectTo: string;
102
- }, Error, void, unknown>;
103
- authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
104
- expiresIn: number;
105
- expiresAt: number;
106
- sessionLinks: {
107
- _links: {
108
- account: "/session/account";
109
- };
110
- };
111
- } | {
112
- redirectTo: string;
113
- }, Error, void, unknown>;
52
+ authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, void, unknown>;
53
+ authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, void, unknown>;
114
54
  } | {
115
- data: {
116
- expiresIn: number;
117
- expiresAt: number;
118
- sessionLinks: {
119
- _links: {
120
- account: "/session/account";
121
- };
122
- };
123
- } | {
124
- redirectTo: string;
125
- };
55
+ data: Session;
126
56
  error: null;
127
57
  variables: void;
128
58
  isError: false;
@@ -136,28 +66,8 @@ declare function useAuthenticateWithWallet({ signUp, }?: {
136
66
  failureReason: Error | null;
137
67
  isPaused: boolean;
138
68
  submittedAt: number;
139
- authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<{
140
- expiresIn: number;
141
- expiresAt: number;
142
- sessionLinks: {
143
- _links: {
144
- account: "/session/account";
145
- };
146
- };
147
- } | {
148
- redirectTo: string;
149
- }, Error, void, unknown>;
150
- authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
151
- expiresIn: number;
152
- expiresAt: number;
153
- sessionLinks: {
154
- _links: {
155
- account: "/session/account";
156
- };
157
- };
158
- } | {
159
- redirectTo: string;
160
- }, Error, void, unknown>;
69
+ authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, void, unknown>;
70
+ authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, void, unknown>;
161
71
  };
162
72
  export { useAuthenticateWithWallet };
163
73
  //# sourceMappingURL=useAuthenticateWithWallet.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAuthenticateWithWallet.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAuthenticateWithWallet.ts"],"names":[],"mappings":"AAUA,iBAAS,yBAAyB,CAAC,EACjC,MAAc,GACf,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkE3B;AAED,OAAO,EAAE,yBAAyB,EAAE,CAAA"}
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"}
@@ -1,52 +1,63 @@
1
- import { useAccount, useSignMessage } from "wagmi";
2
- import { useBitcoinAccount } from "@mezo-org/orangekit";
1
+ import { useSignMessage } from "wagmi";
3
2
  import { useMutation } from "@tanstack/react-query";
4
- import { useMemo } from "react";
5
3
  import { useCreateAccount } from "./useCreateAccount";
6
4
  import { useCreateSession } from "./useCreateSession";
7
5
  import { useEnsureNoSessionAndFetchNonce } from "./useEnsureNoSessionAndFetchNonce";
8
6
  import { createSignInWithWalletMessage } from "../utils/siww";
9
7
  import { useGetAccountByAddress } from "./useGetAccountByAddress";
10
- function useAuthenticateWithWallet({ signUp = false, } = {}) {
11
- const { chainId, address, connector } = useAccount();
12
- const { btcAddress } = useBitcoinAccount();
8
+ import useWalletAccount from "./useWalletAccount";
9
+ function useAuthenticateWithWallet(shouldCreateAccount = false, mutationOptions = {}) {
10
+ const { walletAddress, chainId, connector, networkFamily } = useWalletAccount();
13
11
  const { ensureNoSessionAndFetchNonce } = useEnsureNoSessionAndFetchNonce();
14
12
  const { createSessionAsync } = useCreateSession();
15
13
  const { createAccountAsync } = useCreateAccount();
16
14
  const { signMessageAsync } = useSignMessage();
17
- const walletAddress = useMemo(() => (connector?.type === "orangekit" ? btcAddress : address), [btcAddress, address, connector]);
18
- const { refetch: getAccountByAddress } = useGetAccountByAddress(walletAddress, { enabled: false, retry: false });
15
+ const { refetch: getAccountByAddress } = useGetAccountByAddress(walletAddress, {
16
+ enabled: false,
17
+ retry: false,
18
+ });
19
19
  const { mutate, mutateAsync, ...signInMutationRestParameters } = useMutation({
20
20
  mutationFn: async () => {
21
- if (!address) {
21
+ if (!walletAddress) {
22
22
  throw new Error("Sign in error: Wallet not connected!");
23
23
  }
24
24
  const nonce = await ensureNoSessionAndFetchNonce();
25
- const networkFamily = btcAddress ? "bitcoin" : "evm";
26
- const messageResult = createSignInWithWalletMessage(btcAddress ? btcAddress : address, nonce, networkFamily, chainId);
25
+ const messageResult = createSignInWithWalletMessage(walletAddress, nonce, networkFamily, chainId);
27
26
  const signatureResult = await signMessageAsync({
28
27
  message: messageResult,
29
28
  connector,
30
29
  });
31
- if (signUp) {
32
- const getAcountByAddressResult = await getAccountByAddress();
33
- if (!getAcountByAddressResult.data) {
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 {
34
40
  const createAccountResult = await createAccountAsync({
35
41
  type: "wallet",
36
42
  message: messageResult,
37
43
  signature: signatureResult,
38
44
  });
39
45
  if (!createAccountResult) {
40
- throw new Error("Sign in error: Failed to create new account");
46
+ throw new Error("Failed to create new account");
41
47
  }
42
48
  }
49
+ catch (error) {
50
+ throw new Error(`Wallet authentication failed: Account creation failed: ${error}`);
51
+ }
43
52
  }
44
- return createSessionAsync({
53
+ return (await createSessionAsync({
45
54
  type: "wallet",
46
55
  message: messageResult,
47
56
  signature: signatureResult,
48
- });
57
+ }));
58
+ // ^ By passing type: "wallet" we know for sure the return type is Session
49
59
  },
60
+ ...mutationOptions,
50
61
  });
51
62
  return {
52
63
  authenticateWithWallet: mutate,
@@ -1 +1 @@
1
- {"version":3,"file":"useAuthenticateWithWallet.js","sourceRoot":"","sources":["../../../src/hooks/useAuthenticateWithWallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,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,SAAS,yBAAyB,CAAC,EACjC,MAAM,GAAG,KAAK,MACU,EAAE;IAC1B,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,UAAU,EAAE,CAAA;IACpD,MAAM,EAAE,UAAU,EAAE,GAAG,iBAAiB,EAAE,CAAA;IAC1C,MAAM,EAAE,4BAA4B,EAAE,GAAG,+BAA+B,EAAE,CAAA;IAC1E,MAAM,EAAE,kBAAkB,EAAE,GAAG,gBAAgB,EAAE,CAAA;IACjD,MAAM,EAAE,kBAAkB,EAAE,GAAG,gBAAgB,EAAE,CAAA;IACjD,MAAM,EAAE,gBAAgB,EAAE,GAAG,cAAc,EAAE,CAAA;IAC7C,MAAM,aAAa,GAAG,OAAO,CAC3B,GAAG,EAAE,CAAC,CAAC,SAAS,EAAE,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CA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K,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,2 @@
1
+ export default function useBitcoinPriceFeed(): void;
2
+ //# sourceMappingURL=useBitcoinPriceConversion%20copy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBitcoinPriceConversion copy.d.ts","sourceRoot":"","sources":["../../../src/hooks/useBitcoinPriceConversion copy.ts"],"names":[],"mappings":"AAsBA,MAAM,CAAC,OAAO,UAAU,mBAAmB,SAyB1C"}
@@ -0,0 +1,43 @@
1
+ import { useReadContracts } from "wagmi";
2
+ import { priceOracleContract } from "../lib/contracts";
3
+ import { useCallback } from "react";
4
+ /**
5
+ @dev Used to convert an oracle price answer to an 18-digit precision uint
6
+ */
7
+ const TARGET_DIGITS = 18;
8
+ /**
9
+ * @dev Scales oracle's response up/down to 1e18 precisoin.
10
+ */
11
+ function scalePriceByDigits(_price, _priceDigits) {
12
+ if (_priceDigits > TARGET_DIGITS) {
13
+ return _price / 10n ** BigInt(_priceDigits - TARGET_DIGITS);
14
+ }
15
+ if (_priceDigits < TARGET_DIGITS) {
16
+ return _price * 10n ** BigInt(TARGET_DIGITS - _priceDigits);
17
+ }
18
+ return _price;
19
+ }
20
+ export default function useBitcoinPriceFeed() {
21
+ const { data, isPending, isError } = useReadContracts({
22
+ contracts: [
23
+ {
24
+ ...priceOracleContract,
25
+ functionName: "latestRoundData",
26
+ },
27
+ {
28
+ ...priceOracleContract,
29
+ functionName: "decimals",
30
+ },
31
+ ],
32
+ });
33
+ const convertBitcointoUsd = useCallback((btcAmount) => {
34
+ if (isError || isPending)
35
+ return 0n;
36
+ if (data.some((r) => r.status !== "success"))
37
+ return 0n;
38
+ const [latestRoundData, decimals] = data;
39
+ const [, btcPrice] = latestRoundData.result;
40
+ const decimalsValue = decimals.result;
41
+ }, [data, isPending, isError]);
42
+ }
43
+ //# sourceMappingURL=useBitcoinPriceConversion%20copy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBitcoinPriceConversion copy.js","sourceRoot":"","sources":["../../../src/hooks/useBitcoinPriceConversion copy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAEnC;;EAEE;AACF,MAAM,aAAa,GAAG,EAAE,CAAA;AAExB;;GAEG;AACH,SAAS,kBAAkB,CAAC,MAAc,EAAE,YAAoB;IAC9D,IAAI,YAAY,GAAG,aAAa,EAAE,CAAC;QACjC,OAAO,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,YAAY,GAAG,aAAa,CAAC,CAAA;IAC7D,CAAC;IACD,IAAI,YAAY,GAAG,aAAa,EAAE,CAAC;QACjC,OAAO,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,aAAa,GAAG,YAAY,CAAC,CAAA;IAC7D,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,mBAAmB;IACzC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,gBAAgB,CAAC;QACpD,SAAS,EAAE;YACT;gBACE,GAAG,mBAAmB;gBACtB,YAAY,EAAE,iBAAiB;aAChC;YACD;gBACE,GAAG,mBAAmB;gBACtB,YAAY,EAAE,UAAU;aACzB;SACF;KACF,CAAC,CAAA;IAEF,MAAM,mBAAmB,GAAG,WAAW,CACrC,CAAC,SAAiB,EAAE,EAAE;QACpB,IAAI,OAAO,IAAI,SAAS;YAAE,OAAO,EAAE,CAAA;QACnC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC;YAAE,OAAO,EAAE,CAAA;QAEvD,MAAM,CAAC,eAAe,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAA;QACxC,MAAM,CAAC,EAAE,QAAQ,CAAC,GAAG,eAAe,CAAC,MAA6B,CAAA;QAClE,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAgB,CAAA;IACjD,CAAC,EACD,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAC3B,CAAA;AACH,CAAC"}
@@ -0,0 +1,103 @@
1
+ import { UseBaseQueryOptions } from "@tanstack/react-query";
2
+ type AssetsUsdConversion = {
3
+ usd: Record<"btc" | "eth" | "t", number>;
4
+ };
5
+ export default function useAssetsConversionRates(useQueryOptions?: Partial<UseBaseQueryOptions<AssetsUsdConversion>>): import("wagmi").UseReadContractsReturnType<readonly [{
6
+ readonly functionName: "latestRoundData";
7
+ readonly address: import("viem").Address;
8
+ readonly abi: readonly [{
9
+ readonly inputs: readonly [];
10
+ readonly name: "decimals";
11
+ readonly outputs: readonly [{
12
+ readonly internalType: "uint8";
13
+ readonly name: "";
14
+ readonly type: "uint8";
15
+ }];
16
+ readonly stateMutability: "view";
17
+ readonly type: "function";
18
+ }, {
19
+ readonly inputs: readonly [];
20
+ readonly name: "latestRoundData";
21
+ readonly outputs: readonly [{
22
+ readonly internalType: "uint80";
23
+ readonly name: "roundId";
24
+ readonly type: "uint80";
25
+ }, {
26
+ readonly internalType: "int256";
27
+ readonly name: "answer";
28
+ readonly type: "int256";
29
+ }, {
30
+ readonly internalType: "uint256";
31
+ readonly name: "startedAt";
32
+ readonly type: "uint256";
33
+ }, {
34
+ readonly internalType: "uint256";
35
+ readonly name: "updatedAt";
36
+ readonly type: "uint256";
37
+ }, {
38
+ readonly internalType: "uint80";
39
+ readonly name: "answeredInRound";
40
+ readonly type: "uint80";
41
+ }];
42
+ readonly stateMutability: "view";
43
+ readonly type: "function";
44
+ }];
45
+ }, {
46
+ readonly functionName: "decimals";
47
+ readonly address: import("viem").Address;
48
+ readonly abi: readonly [{
49
+ readonly inputs: readonly [];
50
+ readonly name: "decimals";
51
+ readonly outputs: readonly [{
52
+ readonly internalType: "uint8";
53
+ readonly name: "";
54
+ readonly type: "uint8";
55
+ }];
56
+ readonly stateMutability: "view";
57
+ readonly type: "function";
58
+ }, {
59
+ readonly inputs: readonly [];
60
+ readonly name: "latestRoundData";
61
+ readonly outputs: readonly [{
62
+ readonly internalType: "uint80";
63
+ readonly name: "roundId";
64
+ readonly type: "uint80";
65
+ }, {
66
+ readonly internalType: "int256";
67
+ readonly name: "answer";
68
+ readonly type: "int256";
69
+ }, {
70
+ readonly internalType: "uint256";
71
+ readonly name: "startedAt";
72
+ readonly type: "uint256";
73
+ }, {
74
+ readonly internalType: "uint256";
75
+ readonly name: "updatedAt";
76
+ readonly type: "uint256";
77
+ }, {
78
+ readonly internalType: "uint80";
79
+ readonly name: "answeredInRound";
80
+ readonly type: "uint80";
81
+ }];
82
+ readonly stateMutability: "view";
83
+ readonly type: "function";
84
+ }];
85
+ }], true, [{
86
+ error: Error;
87
+ result?: undefined;
88
+ status: "failure";
89
+ } | {
90
+ error?: undefined;
91
+ result: readonly [bigint, bigint, bigint, bigint, bigint];
92
+ status: "success";
93
+ }, {
94
+ error: Error;
95
+ result?: undefined;
96
+ status: "failure";
97
+ } | {
98
+ error?: undefined;
99
+ result: number;
100
+ status: "success";
101
+ }]>;
102
+ export {};
103
+ //# sourceMappingURL=useBitcoinPriceConversion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBitcoinPriceConversion.d.ts","sourceRoot":"","sources":["../../../src/hooks/useBitcoinPriceConversion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAY,MAAM,uBAAuB,CAAA;AAQrE,KAAK,mBAAmB,GAAG;IACzB,GAAG,EAAE,MAAM,CAAC,KAAK,GAAG,KAAK,GAAG,GAAG,EAAE,MAAM,CAAC,CAAA;CACzC,CAAA;AAED,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAC9C,eAAe,GAAE,OAAO,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,CAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAoDxE"}
@@ -0,0 +1,50 @@
1
+ import { useReadContracts } from "wagmi";
2
+ import { priceOracleContract } from "../lib/contracts";
3
+ export default function useAssetsConversionRates(useQueryOptions = {}) {
4
+ // const portalApiClient = usePortalApiClient()
5
+ // const config = useConfig()
6
+ return useReadContracts({
7
+ contracts: [
8
+ {
9
+ ...priceOracleContract,
10
+ functionName: "latestRoundData",
11
+ },
12
+ {
13
+ ...priceOracleContract,
14
+ functionName: "decimals",
15
+ },
16
+ ],
17
+ });
18
+ // return useQuery({
19
+ // queryKey: [QUERY_KEYS.ASSETS_USD_CONVERSION],
20
+ // queryFn: async () => {
21
+ // const { currentUsdPerBtc, currentUsdPerEth, currentUsdPerTToken } =
22
+ // await portalApiClient.getPortalStatistics()
23
+ // const [latestRoundData, decimals] = await readContracts(config, {
24
+ // contracts: [
25
+ // {
26
+ // ...priceOracleContract,
27
+ // functionName: "latestRoundData",
28
+ // },
29
+ // {
30
+ // ...priceOracleContract,
31
+ // functionName: "decimals",
32
+ // },
33
+ // ],
34
+ // })
35
+ // const [, btcPrice = 0n] = latestRoundData.result ?? []
36
+ // const decimalsValue = decimals.result ?? 0
37
+ // return {
38
+ // usd: {
39
+ // btc: Number(currentUsdPerBtc),
40
+ // eth: Number(currentUsdPerEth),
41
+ // t: Number(currentUsdPerTToken),
42
+ // },
43
+ // }
44
+ // },
45
+ // staleTime: 30 * ONE_MINUTE_MS,
46
+ // retry: 1,
47
+ // ...useQueryOptions,
48
+ // })
49
+ }
50
+ //# sourceMappingURL=useBitcoinPriceConversion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBitcoinPriceConversion.js","sourceRoot":"","sources":["../../../src/hooks/useBitcoinPriceConversion.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,gBAAgB,EAAE,MAAM,OAAO,CAAA;AAKnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAMtD,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAC9C,kBAAqE,EAAE;IAEvE,+CAA+C;IAC/C,6BAA6B;IAE7B,OAAO,gBAAgB,CAAC;QACtB,SAAS,EAAE;YACT;gBACE,GAAG,mBAAmB;gBACtB,YAAY,EAAE,iBAAiB;aAChC;YACD;gBACE,GAAG,mBAAmB;gBACtB,YAAY,EAAE,UAAU;aACzB;SACF;KACF,CAAC,CAAA;IAEF,sBAAsB;IACtB,oDAAoD;IACpD,6BAA6B;IAC7B,4EAA4E;IAC5E,sDAAsD;IAEtD,0EAA0E;IAC1E,uBAAuB;IACvB,cAAc;IACd,sCAAsC;IACtC,+CAA+C;IAC/C,eAAe;IACf,cAAc;IACd,sCAAsC;IACtC,wCAAwC;IACxC,eAAe;IACf,aAAa;IACb,WAAW;IAEX,+DAA+D;IAC/D,mDAAmD;IAEnD,iBAAiB;IACjB,iBAAiB;IACjB,2CAA2C;IAC3C,2CAA2C;IAC3C,4CAA4C;IAC5C,aAAa;IACb,UAAU;IACV,SAAS;IACT,qCAAqC;IACrC,gBAAgB;IAChB,0BAA0B;IAC1B,OAAO;AACT,CAAC"}