@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
@@ -0,0 +1,53 @@
1
+ import { Address } from "viem"
2
+
3
+ export default {
4
+ address: "0x7b7c000000000000000000000000000000000015" as Address,
5
+ abi: [
6
+ {
7
+ inputs: [],
8
+ name: "decimals",
9
+ outputs: [
10
+ {
11
+ internalType: "uint8",
12
+ name: "",
13
+ type: "uint8",
14
+ },
15
+ ],
16
+ stateMutability: "view",
17
+ type: "function",
18
+ },
19
+ {
20
+ inputs: [],
21
+ name: "latestRoundData",
22
+ outputs: [
23
+ {
24
+ internalType: "uint80",
25
+ name: "roundId",
26
+ type: "uint80",
27
+ },
28
+ {
29
+ internalType: "int256",
30
+ name: "answer",
31
+ type: "int256",
32
+ },
33
+ {
34
+ internalType: "uint256",
35
+ name: "startedAt",
36
+ type: "uint256",
37
+ },
38
+ {
39
+ internalType: "uint256",
40
+ name: "updatedAt",
41
+ type: "uint256",
42
+ },
43
+ {
44
+ internalType: "uint80",
45
+ name: "answeredInRound",
46
+ type: "uint80",
47
+ },
48
+ ],
49
+ stateMutability: "view",
50
+ type: "function",
51
+ },
52
+ ] as const,
53
+ }
package/src/provider.ts CHANGED
@@ -1,56 +1,49 @@
1
- import { createContext, createElement, useMemo } from "react"
2
- import { API_ENDPOINTS_BY_ENV, AuthApiClient } from "./api/auth"
1
+ import { createContext, createElement } from "react"
2
+ import { AuthApiClient, PortalApiClient } from "./api"
3
3
 
4
4
  export interface PassportContextValue {
5
5
  authApiClient: AuthApiClient
6
+ portalApiClient: PortalApiClient
7
+ environment?: Environment
6
8
  }
7
9
 
8
10
  export const PassportContext = createContext<PassportContextValue | undefined>(
9
11
  undefined,
10
12
  )
11
13
 
12
- interface PassportProviderProps {
13
- // eslint-disable-next-line react/require-default-props
14
- options: {
15
- environment?: keyof typeof API_ENDPOINTS_BY_ENV
16
- apiUrl?: string
17
- } & (
18
- | {
19
- environment: keyof typeof API_ENDPOINTS_BY_ENV
20
- }
21
- | {
22
- apiUrl: string
23
- }
24
- )
14
+ type Environment = "mainnet" | "testnet"
15
+
16
+ type PassportProviderProps = {
25
17
  children: React.ReactNode
18
+ // eslint-disable-next-line react/require-default-props
19
+ environment?: Environment
20
+ // eslint-disable-next-line react/require-default-props
21
+ authApiUrl?: string
22
+ // eslint-disable-next-line react/require-default-props
23
+ portalApiUrl?: string
26
24
  }
27
25
 
28
- export function PassportProvider({ options, children }: PassportProviderProps) {
29
- const { environment, apiUrl } = options
30
-
31
- const finalApiUrl = useMemo(() => {
32
- if (!environment && !apiUrl) {
33
- throw new Error(
34
- "Neither apiUrl or environment are specified in Passport Provider",
35
- )
36
- }
37
- if (apiUrl) return apiUrl
38
-
39
- if (!(environment! in API_ENDPOINTS_BY_ENV)) {
40
- throw new Error("Wrong environment passed to PassportProvider.")
41
- }
42
-
43
- return API_ENDPOINTS_BY_ENV[environment!]
44
- }, [environment, apiUrl])
26
+ export function PassportProvider({
27
+ environment,
28
+ authApiUrl,
29
+ portalApiUrl,
30
+ children,
31
+ }: PassportProviderProps) {
32
+ if (environment && !["mainnet", "testnet"].includes(environment)) {
33
+ throw new Error("Wrong environment passed to PassportProvider.")
34
+ }
45
35
 
46
36
  return createElement(
47
37
  PassportContext.Provider,
48
38
  {
49
- value: finalApiUrl
50
- ? {
51
- authApiClient: new AuthApiClient(finalApiUrl),
52
- }
53
- : undefined,
39
+ value: {
40
+ authApiClient: new AuthApiClient(environment ?? "mainnet", authApiUrl),
41
+ portalApiClient: new PortalApiClient(
42
+ environment ?? "mainnet",
43
+ portalApiUrl,
44
+ ),
45
+ environment,
46
+ },
54
47
  },
55
48
  children,
56
49
  )
@@ -0,0 +1,20 @@
1
+ import { create } from "zustand"
2
+
3
+ export enum DropdownView {
4
+ ROOT = "ROOT",
5
+ RECEIVE = "RECEIVE",
6
+ }
7
+
8
+ interface DropdownStore {
9
+ view: DropdownView
10
+ setView: (view: DropdownView) => void
11
+ isNestedView: () => boolean
12
+ }
13
+
14
+ const useDropdownStore = create<DropdownStore>((set, get) => ({
15
+ view: DropdownView.ROOT,
16
+ setView: (view: DropdownView) => set({ view }),
17
+ isNestedView: () => get().view !== DropdownView.ROOT,
18
+ }))
19
+
20
+ export default useDropdownStore
@@ -0,0 +1,48 @@
1
+ import { getAddressExplorerUrl, trimAddress } from "./address"
2
+
3
+ describe("trimAddress", () => {
4
+ it("returns full address if length is less than 11", () => {
5
+ expect(trimAddress("0x12345")).toBe("0x12345")
6
+ })
7
+
8
+ it("returns trimmed address if length is 11 or more", () => {
9
+ const input = "0x123456789abcdef"
10
+ const expected = "0x123...bcdef"
11
+ expect(trimAddress(input)).toBe(expected)
12
+ })
13
+ })
14
+
15
+ describe("getAddressExplorerUrl", () => {
16
+ const btcAddress = "bc1qxyz123"
17
+ const evmAddress = "0x1234567890abcdef"
18
+
19
+ it("returns correct mainnet Bitcoin explorer URL", () => {
20
+ const url = getAddressExplorerUrl(btcAddress, "bitcoin", false)
21
+ expect(url).toBe(`https://mempool.space/address/${btcAddress}`)
22
+ })
23
+
24
+ it("returns correct testnet Bitcoin explorer URL", () => {
25
+ const url = getAddressExplorerUrl(btcAddress, "bitcoin", true)
26
+ expect(url).toBe(`https://mempool.space/testnet/address/${btcAddress}`)
27
+ })
28
+
29
+ it("returns correct mainnet EVM explorer URL", () => {
30
+ const url = getAddressExplorerUrl(evmAddress, "evm", false)
31
+ expect(url).toBe(`https://etherscan.io/address/${evmAddress}`)
32
+ })
33
+
34
+ it("returns correct testnet EVM explorer URL", () => {
35
+ const url = getAddressExplorerUrl(evmAddress, "evm", true)
36
+ expect(url).toBe(`https://sepolia.etherscan.io/address/${evmAddress}`)
37
+ })
38
+
39
+ it("returns correct mainnet Mezo explorer URL", () => {
40
+ const url = getAddressExplorerUrl(evmAddress, "mezo", false)
41
+ expect(url).toBe(`https://explorer.mezo.org/address/${evmAddress}`)
42
+ })
43
+
44
+ it("returns correct testnet Mezo explorer URL", () => {
45
+ const url = getAddressExplorerUrl(evmAddress, "mezo", true)
46
+ expect(url).toBe(`https://explorer.test.mezo.org/address/${evmAddress}`)
47
+ })
48
+ })
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Trims the address to the first 5 and last 5 characters.
3
+ * @param address The address to trim.
4
+ * @returns The trimmed address.
5
+ */
6
+ export function trimAddress(address: string): string {
7
+ if (address.length < 11) return address
8
+
9
+ const trimmedAddress = `${address.slice(0, 5)}...${address.slice(-5)}`
10
+
11
+ return trimmedAddress
12
+ }
13
+
14
+ const MAINNET_EXPLORER_URLS: Record<"bitcoin" | "evm" | "mezo", string> = {
15
+ bitcoin: "https://mempool.space",
16
+ evm: "https://etherscan.io",
17
+ mezo: "https://explorer.mezo.org",
18
+ }
19
+
20
+ const TESTNET_EXPLORER_URLS: Record<"bitcoin" | "evm" | "mezo", string> = {
21
+ bitcoin: "https://mempool.space/testnet",
22
+ evm: "https://sepolia.etherscan.io",
23
+ mezo: "https://explorer.test.mezo.org",
24
+ }
25
+
26
+ /**
27
+ * Get the URL of the block explorer page for an address.
28
+ * @param address - The address to link to.
29
+ * @param chainType - The chain type of the address.
30
+ * @param isTestnet - Whether the address is on testnet.
31
+ * @returns The URL of the block explorer page for the address.
32
+ */
33
+ export function getAddressExplorerUrl(
34
+ address: string,
35
+ chainType: "bitcoin" | "evm" | "mezo",
36
+ isTestnet: boolean,
37
+ ) {
38
+ const EXPLORER_URLS = isTestnet
39
+ ? TESTNET_EXPLORER_URLS
40
+ : MAINNET_EXPLORER_URLS
41
+ const baseUrl = EXPLORER_URLS[chainType]
42
+ const endpoint = `address/${address}`
43
+
44
+ return `${baseUrl}/${endpoint}`
45
+ }
@@ -0,0 +1,79 @@
1
+ import { BitcoinCircle, EthCircle, MUsdCircle02 } from "@mezo-org/mezo-clay"
2
+ import {
3
+ CryptoAssetKey,
4
+ getCryptoAsset,
5
+ isBitcoinLikeCryptoAsset,
6
+ isUsdLikeCryptoAsset,
7
+ } from "./cryptoAssets"
8
+
9
+ // FIXME: Test fails if run in full suite (pnpm test) but works when run in isolation (pnpm test cryptoAssets)
10
+
11
+ describe("getCryptoAsset", () => {
12
+ it("returns the correct asset for 'BTC (mBTC)'", () => {
13
+ const asset = getCryptoAsset("BTC")
14
+ expect(asset.name).toBe("Bitcoin")
15
+ expect(asset.symbol).toBe("BTC")
16
+ expect(asset.decimals).toBe(18)
17
+ expect(asset.icon).toBe(BitcoinCircle)
18
+ })
19
+
20
+ it("returns the correct asset for 'ETH'", () => {
21
+ const asset = getCryptoAsset("ETH")
22
+ expect(asset.name).toBe("Ethereum")
23
+ expect(asset.symbol).toBe("ETH")
24
+ expect(asset.decimals).toBe(18)
25
+ expect(asset.icon).toBe(EthCircle)
26
+ })
27
+
28
+ it("returns the correct asset for 'MUSD'", () => {
29
+ const asset = getCryptoAsset("MUSD")
30
+ expect(asset.name).toBe("MUSD")
31
+ expect(asset.symbol).toBe("MUSD")
32
+ expect(asset.decimals).toBe(18)
33
+ expect(asset.icon).toBe(MUsdCircle02)
34
+ })
35
+ })
36
+
37
+ describe("isBitcoinLikeCryptoAsset", () => {
38
+ const cases = [
39
+ { input: "mcbBTC", expected: true },
40
+ { input: "mDAI", expected: false },
41
+ { input: "mFBTC", expected: true },
42
+ { input: "mSolvBTC", expected: true },
43
+ { input: "mswBTC", expected: true },
44
+ { input: "mT", expected: false },
45
+ { input: "mUSDC", expected: false },
46
+ { input: "mUSDe", expected: false },
47
+ { input: "mUSDT", expected: false },
48
+ { input: "mxSolvBTC", expected: true },
49
+ { input: "MUSD", expected: false },
50
+ ]
51
+
52
+ cases.forEach(({ input, expected }) => {
53
+ it(`returns ${expected} for ${input}`, () => {
54
+ expect(isBitcoinLikeCryptoAsset(input as CryptoAssetKey)).toBe(expected)
55
+ })
56
+ })
57
+ })
58
+
59
+ describe("isUsdLikeCryptoAsset", () => {
60
+ const cases = [
61
+ { input: "mcbBTC", expected: false },
62
+ { input: "mDAI", expected: true },
63
+ { input: "mFBTC", expected: false },
64
+ { input: "mSolvBTC", expected: false },
65
+ { input: "mswBTC", expected: false },
66
+ { input: "mT", expected: false },
67
+ { input: "mUSDC", expected: true },
68
+ { input: "mUSDe", expected: true },
69
+ { input: "mUSDT", expected: true },
70
+ { input: "mxSolvBTC", expected: false },
71
+ { input: "MUSD", expected: true },
72
+ ]
73
+
74
+ cases.forEach(({ input, expected }) => {
75
+ it(`returns ${expected} for ${input}`, () => {
76
+ expect(isUsdLikeCryptoAsset(input as CryptoAssetKey)).toBe(expected)
77
+ })
78
+ })
79
+ })
@@ -0,0 +1,173 @@
1
+ import {
2
+ BitcoinCircle,
3
+ EthCircle,
4
+ IconProps,
5
+ MUsdCircle02,
6
+ Cryptocurrency04,
7
+ } from "@mezo-org/mezo-clay"
8
+ import { FC } from "react"
9
+ import { MezoChainToken } from "../lib/contracts"
10
+ import { formatUsd } from "./currency"
11
+ import { fromFixedPointToString, fromFixedPoint } from "./numbers"
12
+
13
+ export type CryptoAssetKey = MezoChainToken | "BTC" | "ETH"
14
+
15
+ export type CryptoAsset = {
16
+ name: string
17
+ symbol: string
18
+ icon: FC<IconProps>
19
+ decimals: number
20
+ }
21
+
22
+ // TODO: Add actual icons for the assets
23
+
24
+ const CRYPTO_ASSETS: Record<CryptoAssetKey, CryptoAsset> = {
25
+ BTC: {
26
+ name: "Bitcoin",
27
+ symbol: "BTC",
28
+ icon: BitcoinCircle,
29
+ decimals: 18,
30
+ },
31
+ ETH: {
32
+ name: "Ethereum",
33
+ symbol: "ETH",
34
+ icon: EthCircle,
35
+ decimals: 18,
36
+ },
37
+ MUSD: {
38
+ name: "MUSD",
39
+ symbol: "MUSD",
40
+ icon: MUsdCircle02,
41
+ decimals: 18,
42
+ },
43
+ mDAI: {
44
+ name: "mDAI",
45
+ symbol: "mDAI",
46
+ icon: Cryptocurrency04,
47
+ decimals: 18,
48
+ },
49
+ mFBTC: {
50
+ name: "mFBTC",
51
+ symbol: "mFBTC",
52
+ icon: BitcoinCircle,
53
+ decimals: 8,
54
+ },
55
+ mcbBTC: {
56
+ name: "mcbBTC",
57
+ symbol: "mcbBTC",
58
+ icon: BitcoinCircle,
59
+ decimals: 8,
60
+ },
61
+ mSolvBTC: {
62
+ name: "mSolvBTC",
63
+ symbol: "mSolvBTC",
64
+ icon: BitcoinCircle,
65
+ decimals: 18,
66
+ },
67
+ mswBTC: {
68
+ name: "mswBTC",
69
+ symbol: "mswBTC",
70
+ icon: BitcoinCircle,
71
+ decimals: 8,
72
+ },
73
+ mT: {
74
+ name: "mT",
75
+ symbol: "mT",
76
+ icon: Cryptocurrency04,
77
+ decimals: 18,
78
+ },
79
+ mUSDC: {
80
+ name: "mUSDC",
81
+ symbol: "mUSDC",
82
+ icon: Cryptocurrency04,
83
+ decimals: 6,
84
+ },
85
+ mUSDe: {
86
+ name: "mUSDe",
87
+ symbol: "mUSDe",
88
+ icon: Cryptocurrency04,
89
+ decimals: 18,
90
+ },
91
+ mUSDT: {
92
+ name: "mUSDT",
93
+ symbol: "mUSDT",
94
+ icon: Cryptocurrency04,
95
+ decimals: 6,
96
+ },
97
+ mxSolvBTC: {
98
+ name: "mxSolvBTC",
99
+ symbol: "mxSolvBTC",
100
+ icon: BitcoinCircle,
101
+ decimals: 18,
102
+ },
103
+ }
104
+
105
+ /**
106
+ * Gets details of given crypto asset
107
+ * @param key The key of crypto asset
108
+ * @returns The crypto asset details
109
+ */
110
+ export function getCryptoAsset(key: CryptoAssetKey) {
111
+ return CRYPTO_ASSETS[key]
112
+ }
113
+
114
+ /**
115
+ * Checks if given crypto asset is Bitcoin-like
116
+ * @param key The key of crypto asset
117
+ * @returns True if crypto asset is Bitcoin-like
118
+ */
119
+ export function isBitcoinLikeCryptoAsset(key: CryptoAssetKey) {
120
+ return /(btc)/i.test(key)
121
+ }
122
+
123
+ /**
124
+ * Checks if given crypto asset is USD-like
125
+ * @param key The key of crypto asset
126
+ * @returns True if crypto asset is USD-like
127
+ */
128
+ export function isUsdLikeCryptoAsset(key: CryptoAssetKey) {
129
+ return /(usd|dai)/i.test(key)
130
+ }
131
+
132
+ /**
133
+ * Formats crypto asset to balance details (balance in USD and decimals)
134
+ * @param type The type of crypto asset
135
+ * @param balance The balance of crypto asset
136
+ * @param usdConversionRate The USD conversion rate
137
+ * @returns The balance details
138
+ */
139
+ export function mapCryptoAssetToDetails(
140
+ type: CryptoAssetKey,
141
+ balance: bigint,
142
+ usdConversionRate?: bigint,
143
+ usdConversionRateDecimals?: number,
144
+ ) {
145
+ const { decimals } = getCryptoAsset(type)
146
+
147
+ const formattedBalance = fromFixedPointToString(
148
+ balance,
149
+ decimals,
150
+ isUsdLikeCryptoAsset(type) ? 2 : 4,
151
+ )
152
+
153
+ let usdBalance = fromFixedPoint(balance, decimals)
154
+
155
+ if (usdConversionRate && usdConversionRateDecimals) {
156
+ usdBalance = fromFixedPoint(
157
+ (usdConversionRate * balance) / 10n ** BigInt(decimals),
158
+ usdConversionRateDecimals,
159
+ )
160
+ }
161
+
162
+ const formattedUsdBalance = formatUsd(usdBalance)
163
+
164
+ return {
165
+ type,
166
+ rawBalance: balance,
167
+ formattedBalance,
168
+ usdBalance,
169
+ formattedUsdBalance,
170
+ }
171
+ }
172
+
173
+ export type DetailedCryptoAsset = ReturnType<typeof mapCryptoAssetToDetails>
@@ -0,0 +1,38 @@
1
+ import { formatCurrency, formatUsd } from "./currency"
2
+
3
+ describe("formatCurrency", () => {
4
+ it("formats a number as currency with default options", () => {
5
+ const result = formatCurrency(1234.5, { currency: "EUR" })
6
+ expect(result).toBe("€1,234.50")
7
+ })
8
+
9
+ it("respects minimumFractionDigits (min = 3, max = 3)", () => {
10
+ const result = formatCurrency(1.2, {
11
+ currency: "USD",
12
+ minimumFractionDigits: 3,
13
+ maximumFractionDigits: 3,
14
+ })
15
+ expect(result).toBe("$1.200")
16
+ })
17
+
18
+ it("respects maximumFractionDigits (min = 0, max = 1)", () => {
19
+ const result = formatCurrency(1.234567, {
20
+ currency: "USD",
21
+ minimumFractionDigits: 0,
22
+ maximumFractionDigits: 1,
23
+ })
24
+ expect(result).toBe("$1.2")
25
+ })
26
+ })
27
+
28
+ describe("formatUsd", () => {
29
+ it("formats a number as USD", () => {
30
+ const result = formatUsd(99.99)
31
+ expect(result).toBe("$99.99")
32
+ })
33
+
34
+ it("formats zero", () => {
35
+ const result = formatUsd(0)
36
+ expect(result).toBe("$0.00")
37
+ })
38
+ })
@@ -0,0 +1,32 @@
1
+ const DEFAULT_FORMAT_OPTIONS: Intl.NumberFormatOptions = {
2
+ style: "currency",
3
+ minimumFractionDigits: 2,
4
+ maximumFractionDigits: 2,
5
+ }
6
+
7
+ /**
8
+ * Formats a number as a currency
9
+ * @param value The value to format
10
+ * @param options The options to pass to the formatter
11
+ * @returns The formatted currency
12
+ */
13
+ export function formatCurrency(
14
+ value: number,
15
+ options: Omit<Intl.NumberFormatOptions, "style"> = {},
16
+ ): string {
17
+ const formatter = new Intl.NumberFormat("en-US", {
18
+ ...DEFAULT_FORMAT_OPTIONS,
19
+ ...options,
20
+ })
21
+
22
+ return formatter.format(value)
23
+ }
24
+
25
+ /**
26
+ * Formats a number as a USD currency
27
+ * @param value The value to format
28
+ * @returns The formatted currency
29
+ */
30
+ export function formatUsd(value: number): string {
31
+ return formatCurrency(value, { currency: "USD" })
32
+ }