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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (303) hide show
  1. package/README.md +18 -22
  2. package/dist/src/api/auth.d.ts +36 -59
  3. package/dist/src/api/auth.d.ts.map +1 -1
  4. package/dist/src/api/auth.js +21 -49
  5. package/dist/src/api/auth.js.map +1 -1
  6. package/dist/src/api/client.d.ts +24 -0
  7. package/dist/src/api/client.d.ts.map +1 -0
  8. package/dist/src/api/client.js +54 -0
  9. package/dist/src/api/client.js.map +1 -0
  10. package/dist/src/api/fetch-error.d.ts +5 -0
  11. package/dist/src/api/fetch-error.d.ts.map +1 -0
  12. package/dist/src/api/fetch-error.js +8 -0
  13. package/dist/src/api/fetch-error.js.map +1 -0
  14. package/dist/src/api/index.d.ts +3 -0
  15. package/dist/src/api/index.d.ts.map +1 -0
  16. package/dist/src/api/index.js +3 -0
  17. package/dist/src/api/index.js.map +1 -0
  18. package/dist/src/api/portal.d.ts +33 -0
  19. package/dist/src/api/portal.d.ts.map +1 -0
  20. package/dist/src/api/portal.js +23 -0
  21. package/dist/src/api/portal.js.map +1 -0
  22. package/dist/src/assets/DefaultAvatar.d.ts +5 -0
  23. package/dist/src/assets/DefaultAvatar.d.ts.map +1 -0
  24. package/dist/src/assets/DefaultAvatar.js +21 -0
  25. package/dist/src/assets/DefaultAvatar.js.map +1 -0
  26. package/dist/src/components/Dropdown/ConnectedTrigger.d.ts +8 -0
  27. package/dist/src/components/Dropdown/ConnectedTrigger.d.ts.map +1 -0
  28. package/dist/src/components/Dropdown/ConnectedTrigger.js +39 -0
  29. package/dist/src/components/Dropdown/ConnectedTrigger.js.map +1 -0
  30. package/dist/src/components/Dropdown/Content.d.ts +23 -0
  31. package/dist/src/components/Dropdown/Content.d.ts.map +1 -0
  32. package/dist/src/components/Dropdown/Content.js +27 -0
  33. package/dist/src/components/Dropdown/Content.js.map +1 -0
  34. package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts +7 -0
  35. package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts.map +1 -0
  36. package/dist/src/components/Dropdown/DisconnectedTrigger.js +13 -0
  37. package/dist/src/components/Dropdown/DisconnectedTrigger.js.map +1 -0
  38. package/dist/src/components/Dropdown/Dropdown.d.ts +27 -0
  39. package/dist/src/components/Dropdown/Dropdown.d.ts.map +1 -0
  40. package/dist/src/components/Dropdown/Dropdown.js +68 -0
  41. package/dist/src/components/Dropdown/Dropdown.js.map +1 -0
  42. package/dist/src/components/Dropdown/ListingItem.d.ts +13 -0
  43. package/dist/src/components/Dropdown/ListingItem.d.ts.map +1 -0
  44. package/dist/src/components/Dropdown/ListingItem.js +34 -0
  45. package/dist/src/components/Dropdown/ListingItem.js.map +1 -0
  46. package/dist/src/components/Dropdown/NestedViewLayout.d.ts +7 -0
  47. package/dist/src/components/Dropdown/NestedViewLayout.d.ts.map +1 -0
  48. package/dist/src/components/Dropdown/NestedViewLayout.js +34 -0
  49. package/dist/src/components/Dropdown/NestedViewLayout.js.map +1 -0
  50. package/dist/src/components/Dropdown/Receive/Receive.d.ts +7 -0
  51. package/dist/src/components/Dropdown/Receive/Receive.d.ts.map +1 -0
  52. package/dist/src/components/Dropdown/Receive/Receive.js +53 -0
  53. package/dist/src/components/Dropdown/Receive/Receive.js.map +1 -0
  54. package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts +7 -0
  55. package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts.map +1 -0
  56. package/dist/src/components/Dropdown/Root/AccountAddressActions.js +48 -0
  57. package/dist/src/components/Dropdown/Root/AccountAddressActions.js.map +1 -0
  58. package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts +11 -0
  59. package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts.map +1 -0
  60. package/dist/src/components/Dropdown/Root/AccountAssetItem.js +9 -0
  61. package/dist/src/components/Dropdown/Root/AccountAssetItem.js.map +1 -0
  62. package/dist/src/components/Dropdown/Root/AccountBalance.d.ts +8 -0
  63. package/dist/src/components/Dropdown/Root/AccountBalance.d.ts.map +1 -0
  64. package/dist/src/components/Dropdown/Root/AccountBalance.js +15 -0
  65. package/dist/src/components/Dropdown/Root/AccountBalance.js.map +1 -0
  66. package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts +9 -0
  67. package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts.map +1 -0
  68. package/dist/src/components/Dropdown/Root/AccountOtherAssets.js +48 -0
  69. package/dist/src/components/Dropdown/Root/AccountOtherAssets.js.map +1 -0
  70. package/dist/src/components/Dropdown/Root/Root.d.ts +23 -0
  71. package/dist/src/components/Dropdown/Root/Root.d.ts.map +1 -0
  72. package/dist/src/components/Dropdown/Root/Root.js +57 -0
  73. package/dist/src/components/Dropdown/Root/Root.js.map +1 -0
  74. package/dist/src/components/Dropdown/Root/WalletAddress.d.ts +8 -0
  75. package/dist/src/components/Dropdown/Root/WalletAddress.d.ts.map +1 -0
  76. package/dist/src/components/Dropdown/Root/WalletAddress.js +64 -0
  77. package/dist/src/components/Dropdown/Root/WalletAddress.js.map +1 -0
  78. package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts +8 -0
  79. package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts.map +1 -0
  80. package/dist/src/components/Dropdown/Root/WelcomeBlock.js +44 -0
  81. package/dist/src/components/Dropdown/Root/WelcomeBlock.js.map +1 -0
  82. package/dist/src/components/Dropdown/TestnetTopBanner.d.ts +3 -0
  83. package/dist/src/components/Dropdown/TestnetTopBanner.d.ts.map +1 -0
  84. package/dist/src/components/Dropdown/TestnetTopBanner.js +14 -0
  85. package/dist/src/components/Dropdown/TestnetTopBanner.js.map +1 -0
  86. package/dist/src/components/Dropdown/index.d.ts +3 -0
  87. package/dist/src/components/Dropdown/index.d.ts.map +1 -0
  88. package/dist/src/components/Dropdown/index.js +2 -0
  89. package/dist/src/components/Dropdown/index.js.map +1 -0
  90. package/dist/src/components/index.d.ts +2 -0
  91. package/dist/src/components/index.d.ts.map +1 -0
  92. package/dist/src/components/index.js +2 -0
  93. package/dist/src/components/index.js.map +1 -0
  94. package/dist/src/config.d.ts +41 -0
  95. package/dist/src/config.d.ts.map +1 -1
  96. package/dist/src/config.js +20 -5
  97. package/dist/src/config.js.map +1 -1
  98. package/dist/src/constants.d.ts +6 -2
  99. package/dist/src/constants.d.ts.map +1 -1
  100. package/dist/src/constants.js +8 -4
  101. package/dist/src/constants.js.map +1 -1
  102. package/dist/src/hooks/constants.d.ts +1 -0
  103. package/dist/src/hooks/constants.d.ts.map +1 -1
  104. package/dist/src/hooks/constants.js +1 -0
  105. package/dist/src/hooks/constants.js.map +1 -1
  106. package/dist/src/hooks/index.d.ts +4 -1
  107. package/dist/src/hooks/index.d.ts.map +1 -1
  108. package/dist/src/hooks/index.js +4 -1
  109. package/dist/src/hooks/index.js.map +1 -1
  110. package/dist/src/hooks/useAssetsConversionRates.d.ts +7 -0
  111. package/dist/src/hooks/useAssetsConversionRates.d.ts.map +1 -0
  112. package/dist/src/hooks/useAssetsConversionRates.js +24 -0
  113. package/dist/src/hooks/useAssetsConversionRates.js.map +1 -0
  114. package/dist/src/hooks/useAuthApiClient.d.ts +1 -1
  115. package/dist/src/hooks/useAuthApiClient.d.ts.map +1 -1
  116. package/dist/src/hooks/useAuthenticateWithWallet.d.ts +73 -0
  117. package/dist/src/hooks/useAuthenticateWithWallet.d.ts.map +1 -0
  118. package/dist/src/hooks/useAuthenticateWithWallet.js +69 -0
  119. package/dist/src/hooks/useAuthenticateWithWallet.js.map +1 -0
  120. package/dist/src/hooks/useBorrowData.d.ts +60 -0
  121. package/dist/src/hooks/useBorrowData.d.ts.map +1 -0
  122. package/dist/src/hooks/useBorrowData.js +122 -0
  123. package/dist/src/hooks/useBorrowData.js.map +1 -0
  124. package/dist/src/hooks/useCreateAccount.d.ts +23 -173
  125. package/dist/src/hooks/useCreateAccount.d.ts.map +1 -1
  126. package/dist/src/hooks/useCreateAccount.js +7 -4
  127. package/dist/src/hooks/useCreateAccount.js.map +1 -1
  128. package/dist/src/hooks/useCreateSession.d.ts +12 -101
  129. package/dist/src/hooks/useCreateSession.d.ts.map +1 -1
  130. package/dist/src/hooks/useCreateSession.js +10 -8
  131. package/dist/src/hooks/useCreateSession.js.map +1 -1
  132. package/dist/src/hooks/useDropdownData.d.ts +47 -0
  133. package/dist/src/hooks/useDropdownData.d.ts.map +1 -0
  134. package/dist/src/hooks/useDropdownData.js +95 -0
  135. package/dist/src/hooks/useDropdownData.js.map +1 -0
  136. package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.d.ts.map +1 -1
  137. package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.js +1 -0
  138. package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.js.map +1 -1
  139. package/dist/src/hooks/useGetAccountByAddress.d.ts +2 -2
  140. package/dist/src/hooks/useGetAccountByAddress.d.ts.map +1 -1
  141. package/dist/src/hooks/useGetAccountByMezoId.d.ts +2 -2
  142. package/dist/src/hooks/useGetAccountByMezoId.d.ts.map +1 -1
  143. package/dist/src/hooks/useGetCurrentAccount.d.ts +16 -2
  144. package/dist/src/hooks/useGetCurrentAccount.d.ts.map +1 -1
  145. package/dist/src/hooks/useGetCurrentAccount.js +25 -3
  146. package/dist/src/hooks/useGetCurrentAccount.js.map +1 -1
  147. package/dist/src/hooks/useGetSession.d.ts +1 -1
  148. package/dist/src/hooks/useGetSession.d.ts.map +1 -1
  149. package/dist/src/hooks/useLinkAccount.d.ts +15 -175
  150. package/dist/src/hooks/useLinkAccount.d.ts.map +1 -1
  151. package/dist/src/hooks/useLinkAccount.js +7 -4
  152. package/dist/src/hooks/useLinkAccount.js.map +1 -1
  153. package/dist/src/hooks/usePortalApiClient.d.ts +2 -0
  154. package/dist/src/hooks/usePortalApiClient.d.ts.map +1 -0
  155. package/dist/src/hooks/usePortalApiClient.js +6 -0
  156. package/dist/src/hooks/usePortalApiClient.js.map +1 -0
  157. package/dist/src/hooks/useRefreshPassport.d.ts +19 -0
  158. package/dist/src/hooks/useRefreshPassport.d.ts.map +1 -0
  159. package/dist/src/hooks/useRefreshPassport.js +44 -0
  160. package/dist/src/hooks/useRefreshPassport.js.map +1 -0
  161. package/dist/src/hooks/useSignInWithDiscord.d.ts +12 -100
  162. package/dist/src/hooks/useSignInWithDiscord.d.ts.map +1 -1
  163. package/dist/src/hooks/useSignInWithDiscord.js +6 -3
  164. package/dist/src/hooks/useSignInWithDiscord.js.map +1 -1
  165. package/dist/src/hooks/useSignInWithWallet.d.ts +12 -100
  166. package/dist/src/hooks/useSignInWithWallet.d.ts.map +1 -1
  167. package/dist/src/hooks/useSignInWithWallet.js +6 -34
  168. package/dist/src/hooks/useSignInWithWallet.js.map +1 -1
  169. package/dist/src/hooks/useSignOut.d.ts +12 -28
  170. package/dist/src/hooks/useSignOut.d.ts.map +1 -1
  171. package/dist/src/hooks/useSignOut.js +7 -4
  172. package/dist/src/hooks/useSignOut.js.map +1 -1
  173. package/dist/src/hooks/useSignUpWithWallet.d.ts +73 -0
  174. package/dist/src/hooks/useSignUpWithWallet.d.ts.map +1 -0
  175. package/dist/src/hooks/useSignUpWithWallet.js +11 -0
  176. package/dist/src/hooks/useSignUpWithWallet.js.map +1 -0
  177. package/dist/src/hooks/useTokensBalances.d.ts +74 -0
  178. package/dist/src/hooks/useTokensBalances.d.ts.map +1 -0
  179. package/dist/src/hooks/useTokensBalances.js +140 -0
  180. package/dist/src/hooks/useTokensBalances.js.map +1 -0
  181. package/dist/src/hooks/useUpdateMezoId.d.ts +30 -136
  182. package/dist/src/hooks/useUpdateMezoId.d.ts.map +1 -1
  183. package/dist/src/hooks/useUpdateMezoId.js +7 -4
  184. package/dist/src/hooks/useUpdateMezoId.js.map +1 -1
  185. package/dist/src/hooks/useWalletAccount.d.ts +13 -0
  186. package/dist/src/hooks/useWalletAccount.d.ts.map +1 -0
  187. package/dist/src/hooks/useWalletAccount.js +29 -0
  188. package/dist/src/hooks/useWalletAccount.js.map +1 -0
  189. package/dist/src/hooks/useWatchTransferEvents.d.ts +5 -0
  190. package/dist/src/hooks/useWatchTransferEvents.d.ts.map +1 -0
  191. package/dist/src/hooks/useWatchTransferEvents.js +63 -0
  192. package/dist/src/hooks/useWatchTransferEvents.js.map +1 -0
  193. package/dist/src/index.d.ts +2 -1
  194. package/dist/src/index.d.ts.map +1 -1
  195. package/dist/src/index.js +2 -1
  196. package/dist/src/index.js.map +1 -1
  197. package/dist/src/lib/contracts/index.d.ts +13 -0
  198. package/dist/src/lib/contracts/index.d.ts.map +1 -0
  199. package/dist/src/lib/contracts/index.js +57 -0
  200. package/dist/src/lib/contracts/index.js.map +1 -0
  201. package/dist/src/provider.d.ts +10 -13
  202. package/dist/src/provider.d.ts.map +1 -1
  203. package/dist/src/provider.js +11 -20
  204. package/dist/src/provider.js.map +1 -1
  205. package/dist/src/stores/dropdownStore.d.ts +12 -0
  206. package/dist/src/stores/dropdownStore.d.ts.map +1 -0
  207. package/dist/src/stores/dropdownStore.js +13 -0
  208. package/dist/src/stores/dropdownStore.js.map +1 -0
  209. package/dist/src/utils/address.d.ts +15 -0
  210. package/dist/src/utils/address.d.ts.map +1 -0
  211. package/dist/src/utils/address.js +37 -0
  212. package/dist/src/utils/address.js.map +1 -0
  213. package/dist/src/utils/address.test.d.ts +2 -0
  214. package/dist/src/utils/address.test.d.ts.map +1 -0
  215. package/dist/src/utils/address.test.js +40 -0
  216. package/dist/src/utils/address.test.js.map +1 -0
  217. package/dist/src/utils/cryptoAssets.d.ts +44 -0
  218. package/dist/src/utils/cryptoAssets.d.ts.map +1 -0
  219. package/dist/src/utils/cryptoAssets.js +131 -0
  220. package/dist/src/utils/cryptoAssets.js.map +1 -0
  221. package/dist/src/utils/cryptoAssets.test.d.ts +2 -0
  222. package/dist/src/utils/cryptoAssets.test.d.ts.map +1 -0
  223. package/dist/src/utils/cryptoAssets.test.js +67 -0
  224. package/dist/src/utils/cryptoAssets.test.js.map +1 -0
  225. package/dist/src/utils/currency.d.ts +14 -0
  226. package/dist/src/utils/currency.d.ts.map +1 -0
  227. package/dist/src/utils/currency.js +27 -0
  228. package/dist/src/utils/currency.js.map +1 -0
  229. package/dist/src/utils/currency.test.d.ts +2 -0
  230. package/dist/src/utils/currency.test.d.ts.map +1 -0
  231. package/dist/src/utils/currency.test.js +34 -0
  232. package/dist/src/utils/currency.test.js.map +1 -0
  233. package/dist/src/utils/numbers.d.ts +58 -0
  234. package/dist/src/utils/numbers.d.ts.map +1 -0
  235. package/dist/src/utils/numbers.js +132 -0
  236. package/dist/src/utils/numbers.js.map +1 -0
  237. package/dist/src/utils/numbers.test.d.ts +2 -0
  238. package/dist/src/utils/numbers.test.d.ts.map +1 -0
  239. package/dist/src/utils/numbers.test.js +170 -0
  240. package/dist/src/utils/numbers.test.js.map +1 -0
  241. package/package.json +13 -5
  242. package/src/api/auth.ts +72 -129
  243. package/src/api/client.ts +78 -0
  244. package/src/api/fetch-error.ts +8 -0
  245. package/src/api/index.ts +2 -0
  246. package/src/api/portal.ts +57 -0
  247. package/src/assets/DefaultAvatar.tsx +74 -0
  248. package/src/components/Dropdown/ConnectedTrigger.tsx +76 -0
  249. package/src/components/Dropdown/Content.tsx +98 -0
  250. package/src/components/Dropdown/DisconnectedTrigger.tsx +36 -0
  251. package/src/components/Dropdown/Dropdown.tsx +148 -0
  252. package/src/components/Dropdown/ListingItem.tsx +80 -0
  253. package/src/components/Dropdown/NestedViewLayout.tsx +75 -0
  254. package/src/components/Dropdown/README.md +41 -0
  255. package/src/components/Dropdown/Receive/Receive.tsx +119 -0
  256. package/src/components/Dropdown/Root/AccountAddressActions.tsx +101 -0
  257. package/src/components/Dropdown/Root/AccountAssetItem.tsx +26 -0
  258. package/src/components/Dropdown/Root/AccountBalance.tsx +30 -0
  259. package/src/components/Dropdown/Root/AccountOtherAssets.tsx +68 -0
  260. package/src/components/Dropdown/Root/Root.tsx +147 -0
  261. package/src/components/Dropdown/Root/WalletAddress.tsx +128 -0
  262. package/src/components/Dropdown/Root/WelcomeBlock.tsx +91 -0
  263. package/src/components/Dropdown/TestnetTopBanner.tsx +32 -0
  264. package/src/components/Dropdown/index.ts +2 -0
  265. package/src/components/index.ts +1 -0
  266. package/src/config.ts +27 -6
  267. package/src/constants.ts +8 -4
  268. package/src/hooks/constants.ts +1 -0
  269. package/src/hooks/index.ts +7 -1
  270. package/src/hooks/useAssetsConversionRates.ts +32 -0
  271. package/src/hooks/useAuthenticateWithWallet.ts +102 -0
  272. package/src/hooks/useBorrowData.ts +143 -0
  273. package/src/hooks/useCreateAccount.ts +19 -5
  274. package/src/hooks/useCreateSession.ts +22 -9
  275. package/src/hooks/useDropdownData.ts +139 -0
  276. package/src/hooks/useEnsureNoSessionAndFetchNonce.ts +1 -0
  277. package/src/hooks/useGetAccountByAddress.ts +2 -2
  278. package/src/hooks/useGetAccountByMezoId.ts +2 -2
  279. package/src/hooks/useGetCurrentAccount.ts +46 -6
  280. package/src/hooks/useGetSession.ts +1 -1
  281. package/src/hooks/useLinkAccount.ts +18 -5
  282. package/src/hooks/usePortalApiClient.ts +6 -0
  283. package/src/hooks/useRefreshPassport.ts +56 -0
  284. package/src/hooks/useSignInWithDiscord.ts +14 -5
  285. package/src/hooks/useSignInWithWallet.ts +14 -42
  286. package/src/hooks/useSignOut.ts +18 -4
  287. package/src/hooks/useSignUpWithWallet.ts +21 -0
  288. package/src/hooks/useTokensBalances.ts +187 -0
  289. package/src/hooks/useUpdateMezoId.ts +19 -4
  290. package/src/hooks/useWalletAccount.ts +55 -0
  291. package/src/hooks/useWatchTransferEvents.ts +74 -0
  292. package/src/index.ts +9 -1
  293. package/src/lib/contracts/index.ts +88 -0
  294. package/src/provider.ts +30 -37
  295. package/src/stores/dropdownStore.ts +20 -0
  296. package/src/utils/address.test.ts +48 -0
  297. package/src/utils/address.ts +45 -0
  298. package/src/utils/cryptoAssets.test.ts +79 -0
  299. package/src/utils/cryptoAssets.ts +173 -0
  300. package/src/utils/currency.test.ts +38 -0
  301. package/src/utils/currency.ts +32 -0
  302. package/src/utils/numbers.test.ts +220 -0
  303. package/src/utils/numbers.ts +188 -0
@@ -0,0 +1,75 @@
1
+ import {
2
+ ArrowLeft,
3
+ Block,
4
+ ButtonIcon,
5
+ LabelMedium,
6
+ useStyletron,
7
+ } from "@mezo-org/mezo-clay"
8
+ import React, { ReactNode, useCallback } from "react"
9
+ import useDropdownStore, { DropdownView } from "../../stores/dropdownStore"
10
+
11
+ const getHeaderTitle = (view: DropdownView) => {
12
+ const titleMap: Partial<Record<DropdownView, string>> = {
13
+ [DropdownView.RECEIVE]: "Receive",
14
+ }
15
+ return titleMap[view]!
16
+ }
17
+
18
+ type NestedViewLayoutProps = {
19
+ children: ReactNode
20
+ }
21
+
22
+ function NestedViewLayout(props: NestedViewLayoutProps) {
23
+ const { children, ...restProps } = props
24
+
25
+ const currentView = useDropdownStore((state) => state.view)
26
+ const setView = useDropdownStore((state) => state.setView)
27
+ const isNested = useDropdownStore((state) => state.isNestedView())
28
+
29
+ const [, theme] = useStyletron()
30
+
31
+ const handleOnButtonClick = useCallback(() => {
32
+ setView(DropdownView.ROOT)
33
+ }, [setView])
34
+
35
+ return (
36
+ <Block
37
+ display="flex"
38
+ flexDirection="column"
39
+ minHeight="588px"
40
+ padding={theme.sizing.scale700}
41
+ paddingTop={0}
42
+ {...restProps}
43
+ >
44
+ <Block
45
+ display="flex"
46
+ alignItems="center"
47
+ paddingTop={theme.sizing.scale600}
48
+ paddingBottom={theme.sizing.scale600}
49
+ marginBottom={theme.sizing.scale300}
50
+ >
51
+ <ButtonIcon
52
+ onClick={handleOnButtonClick}
53
+ shape="circle"
54
+ size="small"
55
+ overrides={{
56
+ BaseButton: {
57
+ style: {
58
+ background: theme.colors.backgroundPrimary,
59
+ marginRight: isNested ? theme.sizing.scale300 : undefined,
60
+ },
61
+ },
62
+ }}
63
+ >
64
+ <ArrowLeft size={theme.sizing.scale700} />
65
+ </ButtonIcon>
66
+
67
+ <LabelMedium>{getHeaderTitle(currentView)}</LabelMedium>
68
+ </Block>
69
+
70
+ {children}
71
+ </Block>
72
+ )
73
+ }
74
+
75
+ export default NestedViewLayout
@@ -0,0 +1,41 @@
1
+ # Passport Dropdown component
2
+
3
+ This component is a layer of interaction with Passport API in form of Dropdown
4
+ component. It allows to establish the session and interact with the API.
5
+
6
+ ## Props
7
+
8
+ - `onSignIn` (`() => void`) - The callback to be executed on trigger click when
9
+ the state is disconnected. It's optional since by default it triggers the
10
+ [Rainbow Kit's wallet connection modal](https://www.rainbowkit.com/docs/modal-hooks).
11
+ If the callback is not provided it will automatically establish the Passport
12
+ Session. If not, you have to handle it manually using `useSignInWithWallet`
13
+ hook. - **optional**
14
+ - `onSignOut` (`() => void`) - The callback to be executed on click of the
15
+ **Sign out** button. It's optional since by default it disconnects the current
16
+ wallet connector and closes the Passport session. - **optional**
17
+ - `triggerProps.signedIn` (`ButtonProps`) - Props to be passed to the trigger
18
+ button in signed-in state.
19
+ - `triggerProps.signedOut` (`ButtonProps`) - Props to be passed to the trigger
20
+ button in signed-out state
21
+
22
+ Besides that, component allows
23
+ [Clay's `StatefulPopover` props](https://baseweb.design/components/popover/)
24
+ excluding the `children` and `content`.
25
+
26
+ ## Overview
27
+
28
+ The component has two distinguishable states - disconnected and connected. In
29
+ disconnected state the component offers the trigger to initiate the connection
30
+ flow. It can be fully customizable by providing your own one. As long as it's
31
+ compliant with Wagmi/RainbowKit it will work. Component will automatically
32
+ detect connected connector and change the state of component displaying the
33
+ avatar thumbnail instead of button.
34
+
35
+ Component has the following features:
36
+
37
+ - displays wallet address that can be copied,
38
+ - displays total balance in USD,
39
+ - displays partial balances per asset with token amounts and USD conversions,
40
+ - serves _Log out_ button which disconnects the wallet connector and closes
41
+ Passport API session.
@@ -0,0 +1,119 @@
1
+ import {
2
+ Block,
3
+ Button,
4
+ LabelMedium,
5
+ MonoLabelXSmall,
6
+ ParagraphSmall,
7
+ useStyletron,
8
+ } from "@mezo-org/mezo-clay"
9
+ import React, { useCallback, useState } from "react"
10
+ import { useCopyToClipboard } from "usehooks-ts"
11
+ import { QRCodeSVG } from "qrcode.react"
12
+ import NestedViewLayout from "../NestedViewLayout"
13
+ import { getAddressExplorerUrl } from "../../../utils/address"
14
+ import { usePassportContext } from "../../../hooks/usePassportContext"
15
+ import useWalletAccount from "../../../hooks/useWalletAccount"
16
+
17
+ type ReceiveProps = {
18
+ address: string
19
+ }
20
+
21
+ function Receive(props: ReceiveProps) {
22
+ const { address } = props
23
+
24
+ const { environment } = usePassportContext()
25
+
26
+ const blockExplorerUrl = getAddressExplorerUrl(
27
+ address,
28
+ "mezo",
29
+ environment === "testnet",
30
+ )
31
+
32
+ const [, theme] = useStyletron()
33
+
34
+ const [, copy] = useCopyToClipboard()
35
+ const [isCopiedMessageVisible, setIsCopiedMessageVisible] = useState(false)
36
+ const handleCopyAddress = useCallback(() => {
37
+ copy(address)
38
+ setIsCopiedMessageVisible(true)
39
+
40
+ setTimeout(() => {
41
+ setIsCopiedMessageVisible(false)
42
+ }, 2000)
43
+ }, [copy, address])
44
+
45
+ const { networkFamily } = useWalletAccount()
46
+
47
+ return (
48
+ <NestedViewLayout>
49
+ <LabelMedium>Receive assets on Mezo</LabelMedium>
50
+
51
+ <ParagraphSmall
52
+ marginTop={theme.sizing.scale300}
53
+ marginBottom={theme.sizing.scale600}
54
+ color={theme.colors.contentTertiary}
55
+ >
56
+ {networkFamily === "bitcoin" ? (
57
+ <>
58
+ Mezo automatically created a smart account that&apos;s fully
59
+ controlled by your connected Bitcoin wallet. Use this address to
60
+ receive assets on Mezo.
61
+ </>
62
+ ) : (
63
+ <>
64
+ Your connected wallet address is your Mezo address. Use this address
65
+ to receive assets on Mezo.
66
+ </>
67
+ )}
68
+ </ParagraphSmall>
69
+
70
+ <Block
71
+ as={QRCodeSVG}
72
+ value={address}
73
+ flex={1}
74
+ overrides={{
75
+ Block: {
76
+ style: {
77
+ aspectRatio: 1,
78
+ width: "fit-content",
79
+ margin: "0 auto",
80
+ },
81
+ },
82
+ }}
83
+ />
84
+
85
+ <MonoLabelXSmall
86
+ marginTop={theme.sizing.scale800}
87
+ marginBottom={theme.sizing.scale800}
88
+ overrides={{
89
+ Block: {
90
+ style: {
91
+ textAlign: "center",
92
+ },
93
+ },
94
+ }}
95
+ >
96
+ {address}
97
+ </MonoLabelXSmall>
98
+
99
+ <Button
100
+ onClick={handleCopyAddress}
101
+ overrides={{
102
+ BaseButton: {
103
+ style: {
104
+ marginBottom: theme.sizing.scale400,
105
+ },
106
+ },
107
+ }}
108
+ >
109
+ {isCopiedMessageVisible ? "Copied!" : "Copy Mezo Address"}
110
+ </Button>
111
+
112
+ <Button kind="secondary" $as="a" href={blockExplorerUrl} target="_blank">
113
+ View Explorer
114
+ </Button>
115
+ </NestedViewLayout>
116
+ )
117
+ }
118
+
119
+ export default Receive
@@ -0,0 +1,101 @@
1
+ import {
2
+ ArrowNarrowLeft,
3
+ Block,
4
+ Button,
5
+ ButtonProps,
6
+ Cube01,
7
+ useStyletron,
8
+ } from "@mezo-org/mezo-clay"
9
+ import React, { useCallback } from "react"
10
+ import { usePassportContext } from "../../../hooks/usePassportContext"
11
+ import { getAddressExplorerUrl } from "../../../utils/address"
12
+ import useDropdownStore, { DropdownView } from "../../../stores/dropdownStore"
13
+
14
+ type AccountAddressActionsProps = {
15
+ address: string
16
+ }
17
+
18
+ const buttonStartEnhancerSize = 12
19
+
20
+ const commonButtonProps: Partial<ButtonProps> = {
21
+ kind: "secondary",
22
+ size: "xsmall",
23
+ overrides: {
24
+ BaseButton: {
25
+ style: {
26
+ flex: 1,
27
+ },
28
+ },
29
+ StartEnhancer: {
30
+ style: {
31
+ stroke: "currentColor",
32
+ },
33
+ },
34
+ },
35
+ }
36
+
37
+ export default function AccountAddressActions(
38
+ props: AccountAddressActionsProps,
39
+ ) {
40
+ const { address } = props
41
+
42
+ const [, theme] = useStyletron()
43
+
44
+ const { environment } = usePassportContext()
45
+ const blockExplorerUrl = getAddressExplorerUrl(
46
+ address,
47
+ "mezo",
48
+ environment === "testnet",
49
+ )
50
+
51
+ const setDropdownView = useDropdownStore((state) => state.setView)
52
+
53
+ const handleReceiveClick = useCallback(() => {
54
+ setDropdownView(DropdownView.RECEIVE)
55
+ }, [setDropdownView])
56
+
57
+ return (
58
+ <Block
59
+ display="flex"
60
+ alignItems="center"
61
+ backgroundColor="transparent"
62
+ marginBottom={theme.sizing.scale600}
63
+ overrides={{
64
+ Block: {
65
+ style: {
66
+ gap: theme.sizing.scale600,
67
+ },
68
+ },
69
+ }}
70
+ >
71
+ <Button
72
+ startEnhancer={<Cube01 size={buttonStartEnhancerSize} />}
73
+ $as="a"
74
+ href={blockExplorerUrl}
75
+ target="_blank"
76
+ {...commonButtonProps}
77
+ >
78
+ View Mezo Explorer
79
+ </Button>
80
+
81
+ <Button
82
+ onClick={handleReceiveClick}
83
+ startEnhancer={
84
+ <ArrowNarrowLeft
85
+ size={buttonStartEnhancerSize}
86
+ overrides={{
87
+ Svg: {
88
+ style: {
89
+ transform: "rotate(-45deg)",
90
+ },
91
+ },
92
+ }}
93
+ />
94
+ }
95
+ {...commonButtonProps}
96
+ >
97
+ Receive
98
+ </Button>
99
+ </Block>
100
+ )
101
+ }
@@ -0,0 +1,26 @@
1
+ import React from "react"
2
+ import { CryptoAssetKey, getCryptoAsset } from "../../../utils/cryptoAssets"
3
+ import ListingItem from "../ListingItem"
4
+
5
+ type AccountAssetItemProps = {
6
+ type: CryptoAssetKey
7
+ amount: string
8
+ subLabel: string
9
+ subValue: string
10
+ }
11
+
12
+ export default function AccountAssetItem(props: AccountAssetItemProps) {
13
+ const { type, amount, subLabel, subValue } = props
14
+
15
+ const { icon: Icon, name: label } = getCryptoAsset(type)
16
+
17
+ return (
18
+ <ListingItem
19
+ icon={Icon}
20
+ label={label}
21
+ subLabel={subLabel}
22
+ value={amount}
23
+ subValue={subValue}
24
+ />
25
+ )
26
+ }
@@ -0,0 +1,30 @@
1
+ import React from "react"
2
+ import { useStyletron } from "@mezo-org/mezo-clay"
3
+ import ListingItem from "../ListingItem"
4
+
5
+ type AccountBalanceProps = {
6
+ totalBalance: string
7
+ totalDebt: string
8
+ }
9
+
10
+ export default function AccountBalance(props: AccountBalanceProps) {
11
+ const { totalBalance, totalDebt } = props
12
+
13
+ const [, theme] = useStyletron()
14
+
15
+ return (
16
+ <ListingItem
17
+ label="Total assets"
18
+ value={totalBalance}
19
+ subLabel="Total liabilities"
20
+ subValue={totalDebt}
21
+ overrides={{
22
+ Root: {
23
+ style: {
24
+ borderBottom: `1px solid ${theme.colors.borderInverseSelected}`,
25
+ },
26
+ },
27
+ }}
28
+ />
29
+ )
30
+ }
@@ -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
+ }