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

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 +22 -48
  5. package/dist/src/api/auth.js.map +1 -1
  6. package/dist/src/api/client.d.ts +27 -0
  7. package/dist/src/api/client.d.ts.map +1 -0
  8. package/dist/src/api/client.js +61 -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 +26 -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 +89 -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 +96 -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,68 @@
1
+ import React, { useMemo } from "react"
2
+ import { Block, useStyletron, CoinsStacked02 } from "@mezo-org/mezo-clay"
3
+ import ListingItem from "../ListingItem"
4
+ import { formatUsd } from "../../../utils/currency"
5
+
6
+ type AccountOtherAssetsProps = {
7
+ assetsCount: number
8
+ assetsUsdTotal: number
9
+ onClick?: () => void
10
+ }
11
+
12
+ export default function AccountOtherAssets(props: AccountOtherAssetsProps) {
13
+ const { assetsCount, assetsUsdTotal, onClick } = props
14
+
15
+ const [, theme] = useStyletron()
16
+
17
+ const label = useMemo(() => {
18
+ if (assetsCount === 0) return "No other assets"
19
+ if (assetsCount === 1) return "1 more asset"
20
+ return `${assetsCount} more assets`
21
+ }, [assetsCount])
22
+
23
+ const formattedAssetsUsdTotal = formatUsd(assetsUsdTotal)
24
+
25
+ return (
26
+ <Block
27
+ aria-label={label}
28
+ as="li"
29
+ overrides={{
30
+ Block: {
31
+ style: {
32
+ listStyle: "none",
33
+ borderTop: `1px solid ${theme.colors.borderInverseSelected}`,
34
+ },
35
+ },
36
+ }}
37
+ >
38
+ <ListingItem
39
+ icon={CoinsStacked02}
40
+ label={label}
41
+ value={formattedAssetsUsdTotal}
42
+ overrides={{
43
+ Root: {
44
+ props: {
45
+ $as: "button",
46
+ onClick,
47
+ },
48
+ style: {
49
+ border: 0,
50
+ padding: 0,
51
+ cursor: "pointer",
52
+ },
53
+ },
54
+ ArtworkContainer: {
55
+ style: {
56
+ stroke: theme.colors.contentPrimary,
57
+ },
58
+ },
59
+ Content: {
60
+ style: {
61
+ minHeight: theme.sizing.scale1200,
62
+ },
63
+ },
64
+ }}
65
+ />
66
+ </Block>
67
+ )
68
+ }
@@ -0,0 +1,147 @@
1
+ import { Block, Button, LogOut01, useStyletron } from "@mezo-org/mezo-clay"
2
+ import React, { useCallback } from "react"
3
+ import { useDisconnect } from "wagmi"
4
+ import { useSignOut } from "../../../hooks"
5
+ import WalletAddress from "./WalletAddress"
6
+ import AccountBalance from "./AccountBalance"
7
+ import WelcomeBlock from "./WelcomeBlock"
8
+ import AccountAddressActions from "./AccountAddressActions"
9
+ import AccountAssetItem from "./AccountAssetItem"
10
+ import { DetailedCryptoAsset } from "../../../utils/cryptoAssets"
11
+ import { formatNumberToCompactString } from "../../../utils/numbers"
12
+ import { formatUsd } from "../../../utils/currency"
13
+ import AccountOtherAssets from "./AccountOtherAssets"
14
+
15
+ type RootProps = {
16
+ mezoId: string
17
+ matsBalance: number
18
+ accountAddress: string
19
+ walletAddress: string
20
+ walletType: "bitcoin" | "evm"
21
+ usdTotalBalance: number
22
+ usdTroveDebt: number
23
+ usdCollateral: number
24
+ assets: {
25
+ btc: DetailedCryptoAsset
26
+ musd: DetailedCryptoAsset
27
+ }
28
+ otherAssetsCount: number
29
+ otherAssetsUsdTotal: number
30
+ onSignOut?: () => void
31
+ onOtherAssetsClick?: () => void
32
+ }
33
+
34
+ export default function Root(props: RootProps) {
35
+ const {
36
+ mezoId,
37
+ walletAddress,
38
+ accountAddress,
39
+ walletType,
40
+ usdTotalBalance,
41
+ usdTroveDebt,
42
+ usdCollateral,
43
+ matsBalance,
44
+ assets,
45
+ otherAssetsCount,
46
+ otherAssetsUsdTotal,
47
+ onSignOut,
48
+ onOtherAssetsClick,
49
+ } = props
50
+
51
+ const [, theme] = useStyletron()
52
+
53
+ const { disconnect } = useDisconnect()
54
+ const { signOut } = useSignOut()
55
+
56
+ const handleLogOut = useCallback(() => {
57
+ if (onSignOut) {
58
+ onSignOut()
59
+ return
60
+ }
61
+
62
+ signOut()
63
+ disconnect()
64
+ }, [signOut, disconnect, onSignOut])
65
+
66
+ const formattedMatsBalance = formatNumberToCompactString(matsBalance, 2)
67
+ const formattedUsdTotalBalance = formatUsd(usdTotalBalance)
68
+ const formattedUsdTroveDebt = formatUsd(usdTroveDebt)
69
+ const formattedUsdCollateral = formatUsd(usdCollateral)
70
+
71
+ return (
72
+ <Block
73
+ display="inline-flex"
74
+ flexDirection="column"
75
+ padding={theme.sizing.scale600}
76
+ >
77
+ <WelcomeBlock mezoId={mezoId} matsBalance={formattedMatsBalance} />
78
+
79
+ <AccountAddressActions address={accountAddress} />
80
+
81
+ <Block
82
+ display="flex"
83
+ flexDirection="column"
84
+ backgroundColor={theme.colors.backgroundSecondary}
85
+ overflow="hidden"
86
+ overrides={{
87
+ Block: { style: { borderRadius: theme.borders.radius300 } },
88
+ }}
89
+ >
90
+ <WalletAddress address={walletAddress} type={walletType} />
91
+
92
+ <AccountBalance
93
+ totalBalance={formattedUsdTotalBalance}
94
+ totalDebt={formattedUsdTroveDebt}
95
+ />
96
+
97
+ <AccountAssetItem
98
+ type="BTC"
99
+ amount={assets.btc.formattedUsdBalance}
100
+ subLabel="Locked collateral"
101
+ subValue={formattedUsdCollateral}
102
+ />
103
+
104
+ <AccountAssetItem
105
+ type="MUSD"
106
+ amount={assets.musd.formattedUsdBalance}
107
+ subLabel="Borrowed"
108
+ subValue={formattedUsdTroveDebt}
109
+ />
110
+
111
+ <AccountOtherAssets
112
+ assetsCount={otherAssetsCount}
113
+ assetsUsdTotal={otherAssetsUsdTotal}
114
+ onClick={onOtherAssetsClick}
115
+ />
116
+ </Block>
117
+
118
+ <Block
119
+ marginTop={theme.sizing.scale700}
120
+ padding={`0 ${theme.sizing.scale100}`}
121
+ >
122
+ <Button
123
+ size="small"
124
+ kind="tertiary"
125
+ startEnhancer={<LogOut01 color="currentColor" size={12} />}
126
+ onClick={() => handleLogOut()}
127
+ overrides={{
128
+ Root: {
129
+ style: {
130
+ ":hover": {
131
+ backgroundColor: theme.colors.backgroundSecondary,
132
+ boxShadow: "none",
133
+ },
134
+ ":active": {
135
+ backgroundColor: theme.colors.backgroundSecondary,
136
+ color: theme.colors.contentPrimary,
137
+ },
138
+ },
139
+ },
140
+ }}
141
+ >
142
+ Log out
143
+ </Button>
144
+ </Block>
145
+ </Block>
146
+ )
147
+ }
@@ -0,0 +1,128 @@
1
+ import {
2
+ Block,
3
+ Copy03 as CopyIcon,
4
+ LinkExternal02 as LinkIcon,
5
+ ParagraphSmall,
6
+ useStyletron,
7
+ } from "@mezo-org/mezo-clay"
8
+ import React, { useCallback, useState } from "react"
9
+ import { useCopyToClipboard } from "usehooks-ts"
10
+ import { usePassportContext } from "../../../hooks/usePassportContext"
11
+ import { getAddressExplorerUrl, trimAddress } from "../../../utils/address"
12
+ import { getCryptoAsset } from "../../../utils/cryptoAssets"
13
+
14
+ type WalletAddressProps = {
15
+ address: string
16
+ type: "bitcoin" | "evm"
17
+ }
18
+
19
+ export default function WalletAddress(props: WalletAddressProps) {
20
+ const { address, type } = props
21
+
22
+ const { environment } = usePassportContext()
23
+ const blockExplorerUrl = getAddressExplorerUrl(
24
+ address,
25
+ type,
26
+ environment === "testnet",
27
+ )
28
+ const trimmedAddress = trimAddress(address)
29
+ const { icon: accountIcon } = getCryptoAsset(
30
+ type === "bitcoin" ? "BTC" : "ETH",
31
+ )
32
+
33
+ const [, theme] = useStyletron()
34
+
35
+ const [, copy] = useCopyToClipboard()
36
+ const [isCopiedMessageVisible, setIsCopiedMessageVisible] = useState(false)
37
+ const handleCopyAddress = useCallback(() => {
38
+ copy(address)
39
+ setIsCopiedMessageVisible(true)
40
+
41
+ setTimeout(() => {
42
+ setIsCopiedMessageVisible(false)
43
+ }, 2000)
44
+ }, [copy, address])
45
+
46
+ return (
47
+ <Block
48
+ as="button"
49
+ onClick={handleCopyAddress}
50
+ display="flex"
51
+ alignItems="center"
52
+ backgroundColor="transparent"
53
+ padding={`${theme.sizing.scale600} ${theme.sizing.scale500}`}
54
+ overrides={{
55
+ Block: {
56
+ style: {
57
+ borderWidth: 0,
58
+ cursor: "pointer",
59
+ ":hover": {
60
+ backgroundColor: theme.colors.backgroundTertiary,
61
+ },
62
+ },
63
+ },
64
+ }}
65
+ >
66
+ <Block as={accountIcon} size={theme.sizing.scale600} />
67
+ {isCopiedMessageVisible ? (
68
+ <ParagraphSmall
69
+ margin={0}
70
+ marginLeft={theme.sizing.scale500}
71
+ color={theme.colors.contentPrimary}
72
+ >
73
+ Copied address to clipboard
74
+ </ParagraphSmall>
75
+ ) : (
76
+ <Block
77
+ as="a"
78
+ marginLeft={theme.sizing.scale500}
79
+ href={blockExplorerUrl}
80
+ target="_blank"
81
+ overrides={{
82
+ Block: {
83
+ style: {
84
+ color: "inherit",
85
+ textDecoration: "none",
86
+ ":hover": {
87
+ textDecoration: "underline",
88
+ },
89
+ },
90
+ },
91
+ }}
92
+ >
93
+ <ParagraphSmall
94
+ display="flex"
95
+ alignItems="center"
96
+ margin={0}
97
+ color={theme.colors.contentPrimary}
98
+ >
99
+ {trimmedAddress}
100
+ <LinkIcon
101
+ display="inline"
102
+ size={theme.sizing.scale550}
103
+ overrides={{
104
+ Svg: {
105
+ style: {
106
+ stroke: "currentColor",
107
+ marginLeft: theme.sizing.scale300,
108
+ },
109
+ },
110
+ }}
111
+ />
112
+ </ParagraphSmall>
113
+ </Block>
114
+ )}
115
+ <CopyIcon
116
+ size={theme.sizing.scale550}
117
+ color={theme.colors.contentPrimary}
118
+ overrides={{
119
+ Svg: {
120
+ style: {
121
+ marginLeft: "auto",
122
+ },
123
+ },
124
+ }}
125
+ />
126
+ </Block>
127
+ )
128
+ }
@@ -0,0 +1,91 @@
1
+ import {
2
+ Block,
3
+ HeadingSmall,
4
+ LabelSmall,
5
+ Mats,
6
+ useStyletron,
7
+ } from "@mezo-org/mezo-clay"
8
+ import React from "react"
9
+ import DefaultAvatar from "../../../assets/DefaultAvatar"
10
+
11
+ const DOT_DELIMITER_REGEX = /(?=\.)/
12
+
13
+ type WelcomeBlockProps = {
14
+ mezoId: string
15
+ matsBalance: string
16
+ }
17
+
18
+ export default function WelcomeBlock(props: WelcomeBlockProps) {
19
+ const { mezoId, matsBalance } = props
20
+
21
+ const [name, nameSuffix] = mezoId.split(DOT_DELIMITER_REGEX)
22
+ const [, theme] = useStyletron()
23
+
24
+ return (
25
+ <Block
26
+ display="flex"
27
+ alignItems="center"
28
+ padding={`${theme.sizing.scale600} 0`}
29
+ marginBottom={theme.sizing.scale300}
30
+ overrides={{
31
+ Block: {
32
+ style: {
33
+ gap: theme.sizing.scale600,
34
+ },
35
+ },
36
+ }}
37
+ >
38
+ <Block
39
+ as={DefaultAvatar}
40
+ width={theme.sizing.scale1200}
41
+ height={theme.sizing.scale1200}
42
+ overrides={{
43
+ Block: {
44
+ style: {
45
+ borderRadius: "100%",
46
+ },
47
+ },
48
+ }}
49
+ />
50
+
51
+ <Block
52
+ display="flex"
53
+ flexDirection="column"
54
+ overrides={{
55
+ Block: {
56
+ style: {
57
+ gap: theme.sizing.scale100,
58
+ },
59
+ },
60
+ }}
61
+ >
62
+ <HeadingSmall as="span">
63
+ <Block as="span">{name}</Block>
64
+ <Block as="span" color={theme.colors.gray500}>
65
+ {nameSuffix}
66
+ </Block>
67
+ </HeadingSmall>
68
+
69
+ <LabelSmall
70
+ display="flex"
71
+ alignItems="center"
72
+ margin={0}
73
+ color={theme.colors.contentTertiary}
74
+ overrides={{
75
+ Block: {
76
+ style: {
77
+ gap: theme.sizing.scale400,
78
+ },
79
+ },
80
+ }}
81
+ >
82
+ <Mats
83
+ color={theme.colors.contentPrimary}
84
+ size={theme.sizing.scale500}
85
+ />
86
+ {matsBalance} mats
87
+ </LabelSmall>
88
+ </Block>
89
+ </Block>
90
+ )
91
+ }
@@ -0,0 +1,32 @@
1
+ import React from "react"
2
+ import {
3
+ Block,
4
+ InfoCircle,
5
+ LabelSmall,
6
+ useStyletron,
7
+ } from "@mezo-org/mezo-clay"
8
+ import { usePassportContext } from "../../hooks/usePassportContext"
9
+
10
+ export default function TestnetTopBanner() {
11
+ const [, theme] = useStyletron()
12
+
13
+ const { environment } = usePassportContext()
14
+
15
+ if (environment !== "testnet") {
16
+ return null
17
+ }
18
+
19
+ return (
20
+ <Block
21
+ display="flex"
22
+ alignItems="center"
23
+ padding={`${theme.sizing.scale700} ${theme.sizing.scale600}`}
24
+ backgroundColor={theme.colors.warning}
25
+ >
26
+ <InfoCircle size={theme.sizing.scale550} />
27
+ <LabelSmall marginLeft={theme.sizing.scale500}>
28
+ You are using testnet funds.
29
+ </LabelSmall>
30
+ </Block>
31
+ )
32
+ }
@@ -0,0 +1,2 @@
1
+ export { Dropdown } from "./Dropdown"
2
+ export type { DropdownProps } from "./Dropdown"
@@ -0,0 +1 @@
1
+ export { Dropdown, DropdownProps } from "./Dropdown"
package/src/config.ts CHANGED
@@ -1,7 +1,12 @@
1
- import { http } from "viem"
2
1
  import { Chain, getDefaultConfig, WalletList } from "@rainbow-me/rainbowkit"
3
- import { Config, CreateConfigParameters } from "wagmi"
4
- import { CHAIN_ID, mezoMatsnetTestnet, RPC_BY_NETWORK } from "./constants"
2
+ import {
3
+ Config,
4
+ createConfig,
5
+ CreateConfigParameters,
6
+ http,
7
+ webSocket,
8
+ } from "wagmi"
9
+ import { CHAIN_ID, mezoMainnet, mezoTestnet, RPC_BY_NETWORK } from "./constants"
5
10
  import { getOKXWallet, getUnisatWallet, getXverseWallet } from "./wallet"
6
11
 
7
12
  type WagmiConfigParameters = Omit<
@@ -20,7 +25,8 @@ type GetDefaultConfigParameters = WagmiConfigParameters & {
20
25
  }
21
26
 
22
27
  const transports = {
23
- [CHAIN_ID.testnet]: http(RPC_BY_NETWORK.testnet),
28
+ [CHAIN_ID.mainnet]: http(RPC_BY_NETWORK.mainnet.http),
29
+ [CHAIN_ID.testnet]: http(RPC_BY_NETWORK.testnet.http),
24
30
  } as Pick<CreateConfigParameters, "transports">
25
31
 
26
32
  export const defaultConfig: Required<
@@ -34,39 +40,90 @@ export const defaultConfig: Required<
34
40
  > = {
35
41
  transports,
36
42
  walletConnectProjectId: "",
37
- chains: [mezoMatsnetTestnet],
43
+ chains: [mezoMainnet, mezoTestnet],
38
44
  multiInjectedProviderDiscovery: true,
39
45
  }
40
46
 
41
- const bitcoinWalletConfig = {
42
- rpcUrl: RPC_BY_NETWORK.testnet,
47
+ const bitcoinWalletTestnetConfig = {
48
+ rpcUrl: RPC_BY_NETWORK.testnet.http,
43
49
  chainId: CHAIN_ID.testnet,
44
50
  }
45
51
 
46
- export const unisatWallet = getUnisatWallet(bitcoinWalletConfig)
47
- export const okxWallet = getOKXWallet(bitcoinWalletConfig)
48
- export const xverseWallet = getXverseWallet(bitcoinWalletConfig)
52
+ const bitcoinWalletMainnetConfig = {
53
+ rpcUrl: RPC_BY_NETWORK.mainnet.http,
54
+ chainId: CHAIN_ID.mainnet,
55
+ }
56
+
57
+ export const unisatWalletMezoTestnet = getUnisatWallet(
58
+ bitcoinWalletTestnetConfig,
59
+ )
60
+ export const okxWalletMezoTestnet = getOKXWallet(bitcoinWalletTestnetConfig)
61
+ export const xverseWalletMezoTestnet = getXverseWallet(
62
+ bitcoinWalletTestnetConfig,
63
+ )
49
64
 
50
- export function getDefaultWallets(): WalletList {
65
+ export const unisatWalletMezoMainnet = getUnisatWallet(
66
+ bitcoinWalletMainnetConfig,
67
+ )
68
+ export const okxWalletMezoMainnet = getOKXWallet(bitcoinWalletMainnetConfig)
69
+ export const xverseWalletMezoMainnet = getXverseWallet(
70
+ bitcoinWalletMainnetConfig,
71
+ )
72
+
73
+ export function getDefaultWallets(
74
+ network: "mainnet" | "testnet" = "mainnet",
75
+ ): WalletList {
51
76
  return [
52
77
  {
53
78
  groupName: "Bitcoin",
54
- wallets: [unisatWallet, okxWallet, xverseWallet],
79
+ wallets:
80
+ network === "mainnet"
81
+ ? [
82
+ unisatWalletMezoMainnet,
83
+ okxWalletMezoMainnet,
84
+ xverseWalletMezoMainnet,
85
+ ]
86
+ : [
87
+ unisatWalletMezoTestnet,
88
+ okxWalletMezoTestnet,
89
+ xverseWalletMezoTestnet,
90
+ ],
55
91
  },
56
92
  ]
57
93
  }
58
94
 
59
- export function getConfig({
60
- appName,
61
- bitcoinWallets,
62
- walletConnectProjectId,
63
- ...restParameters
64
- }: GetDefaultConfigParameters): Config {
95
+ export function getConfig(config: GetDefaultConfigParameters): Config {
96
+ const {
97
+ appName,
98
+ walletConnectProjectId = defaultConfig.walletConnectProjectId,
99
+ ...restParameters
100
+ } = config
101
+
102
+ // Wallets don't have to be differentiated by network. Viem will choose proper
103
+ // connector selectively based on the chainId, or by the chainId passed
104
+ // explicitly.
105
+ const wallets = config.bitcoinWallets ?? [
106
+ ...getDefaultWallets("mainnet"),
107
+ ...getDefaultWallets("testnet"),
108
+ ]
109
+
65
110
  return getDefaultConfig({
66
111
  ...defaultConfig,
67
112
  appName,
68
- wallets: [...(bitcoinWallets ?? getDefaultWallets())],
69
- projectId: walletConnectProjectId ?? defaultConfig.walletConnectProjectId,
113
+ wallets,
114
+ projectId: walletConnectProjectId,
70
115
  ...restParameters,
71
116
  })
72
117
  }
118
+
119
+ /**
120
+ * This config is only used to listen for Transfer events on mezo chain.
121
+ * Should not be exported in index for public use.
122
+ */
123
+ export const simpleWssMezoConfig = createConfig({
124
+ chains: [mezoMainnet, mezoTestnet],
125
+ transports: {
126
+ [mezoMainnet.id]: webSocket(RPC_BY_NETWORK.mainnet.webSocket),
127
+ [mezoTestnet.id]: webSocket(RPC_BY_NETWORK.testnet.webSocket),
128
+ },
129
+ })
package/src/constants.ts CHANGED
@@ -1,11 +1,19 @@
1
- import { mezoMatsnetTestnet } from "@mezo-org/orangekit"
1
+ import { mezoMainnet, mezoTestnet } from "@mezo-org/orangekit"
2
2
 
3
- export { mezoMatsnetTestnet } from "@mezo-org/orangekit"
3
+ export { mezoMainnet, mezoTestnet } from "@mezo-org/orangekit"
4
4
 
5
5
  export const CHAIN_ID = {
6
- testnet: mezoMatsnetTestnet.id,
6
+ testnet: mezoTestnet.id,
7
+ mainnet: mezoMainnet.id,
7
8
  }
8
9
 
9
10
  export const RPC_BY_NETWORK = {
10
- testnet: mezoMatsnetTestnet.rpcUrls.default.http[0],
11
+ mainnet: {
12
+ http: mezoMainnet.rpcUrls.default.http[0],
13
+ webSocket: mezoMainnet.rpcUrls.default.webSocket?.[0],
14
+ },
15
+ testnet: {
16
+ http: mezoTestnet.rpcUrls.default.http[0],
17
+ webSocket: mezoTestnet.rpcUrls.default.webSocket?.[0],
18
+ },
11
19
  }
@@ -2,4 +2,5 @@ export const QUERY_KEYS = {
2
2
  ACCOUNT: "account",
3
3
  SESSION: "session",
4
4
  CURRENT: "current",
5
+ ASSETS_USD_CONVERSION: "assetsUsdConversion",
5
6
  }
@@ -6,14 +6,19 @@ export {
6
6
  useSubscribeToConnectorEvent,
7
7
  useSubscribeToWalletNetworkDoesNotMatchProviderChain,
8
8
  } from "@mezo-org/orangekit"
9
- export * from "./useCreateAccount"
9
+ export { useInvalidateBorrowData, useResetBorrowData } from "./useBorrowData"
10
10
  export * from "./useGetAccountByAddress"
11
11
  export * from "./useGetAccountByMezoId"
12
12
  export * from "./useGetCurrentAccount"
13
13
  export * from "./useGetSession"
14
14
  export * from "./useLinkAccount"
15
+ export * from "./useRefreshPassport"
15
16
  export * from "./useSignInWithDiscord"
16
17
  export * from "./useSignInWithWallet"
17
18
  export * from "./useSignOut"
18
19
  export * from "./useSignUpWithWallet"
20
+ export {
21
+ useInvalidateTokensBalances,
22
+ useResetTokensBalances,
23
+ } from "./useTokensBalances"
19
24
  export * from "./useUpdateMezoId"