@mezo-org/passport 0.15.1-dev.7 → 0.16.0-dev.1

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 (170) hide show
  1. package/dist/src/api/auth.d.ts +9 -0
  2. package/dist/src/api/auth.d.ts.map +1 -1
  3. package/dist/src/api/auth.js +7 -0
  4. package/dist/src/api/auth.js.map +1 -1
  5. package/dist/src/assets/DefaultAvatar.d.ts +5 -0
  6. package/dist/src/assets/DefaultAvatar.d.ts.map +1 -0
  7. package/dist/src/assets/DefaultAvatar.js +21 -0
  8. package/dist/src/assets/DefaultAvatar.js.map +1 -0
  9. package/dist/src/assets/EditIcon.d.ts +5 -0
  10. package/dist/src/assets/EditIcon.d.ts.map +1 -0
  11. package/dist/src/assets/EditIcon.js +10 -0
  12. package/dist/src/assets/EditIcon.js.map +1 -0
  13. package/dist/src/components/Dropdown/ConnectedTrigger.d.ts +8 -0
  14. package/dist/src/components/Dropdown/ConnectedTrigger.d.ts.map +1 -0
  15. package/dist/src/components/Dropdown/ConnectedTrigger.js +39 -0
  16. package/dist/src/components/Dropdown/ConnectedTrigger.js.map +1 -0
  17. package/dist/src/components/Dropdown/Content.d.ts +8 -0
  18. package/dist/src/components/Dropdown/Content.d.ts.map +1 -0
  19. package/dist/src/components/Dropdown/Content.js +29 -0
  20. package/dist/src/components/Dropdown/Content.js.map +1 -0
  21. package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts +7 -0
  22. package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts.map +1 -0
  23. package/dist/src/components/Dropdown/DisconnectedTrigger.js +13 -0
  24. package/dist/src/components/Dropdown/DisconnectedTrigger.js.map +1 -0
  25. package/dist/src/components/Dropdown/Dropdown.d.ts +23 -0
  26. package/dist/src/components/Dropdown/Dropdown.d.ts.map +1 -0
  27. package/dist/src/components/Dropdown/Dropdown.js +45 -0
  28. package/dist/src/components/Dropdown/Dropdown.js.map +1 -0
  29. package/dist/src/components/Dropdown/ListingItem.d.ts +14 -0
  30. package/dist/src/components/Dropdown/ListingItem.d.ts.map +1 -0
  31. package/dist/src/components/Dropdown/ListingItem.js +42 -0
  32. package/dist/src/components/Dropdown/ListingItem.js.map +1 -0
  33. package/dist/src/components/Dropdown/NestedViewLayout.d.ts +8 -0
  34. package/dist/src/components/Dropdown/NestedViewLayout.d.ts.map +1 -0
  35. package/dist/src/components/Dropdown/NestedViewLayout.js +33 -0
  36. package/dist/src/components/Dropdown/NestedViewLayout.js.map +1 -0
  37. package/dist/src/components/Dropdown/Receive/Receive.d.ts +4 -0
  38. package/dist/src/components/Dropdown/Receive/Receive.d.ts.map +1 -0
  39. package/dist/src/components/Dropdown/Receive/Receive.js +64 -0
  40. package/dist/src/components/Dropdown/Receive/Receive.js.map +1 -0
  41. package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts +4 -0
  42. package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts.map +1 -0
  43. package/dist/src/components/Dropdown/Root/AccountAddressActions.js +49 -0
  44. package/dist/src/components/Dropdown/Root/AccountAddressActions.js.map +1 -0
  45. package/dist/src/components/Dropdown/Root/AccountBalance.d.ts +6 -0
  46. package/dist/src/components/Dropdown/Root/AccountBalance.d.ts.map +1 -0
  47. package/dist/src/components/Dropdown/Root/AccountBalance.js +32 -0
  48. package/dist/src/components/Dropdown/Root/AccountBalance.js.map +1 -0
  49. package/dist/src/components/Dropdown/Root/AccountBtcListing.d.ts +6 -0
  50. package/dist/src/components/Dropdown/Root/AccountBtcListing.d.ts.map +1 -0
  51. package/dist/src/components/Dropdown/Root/AccountBtcListing.js +28 -0
  52. package/dist/src/components/Dropdown/Root/AccountBtcListing.js.map +1 -0
  53. package/dist/src/components/Dropdown/Root/AccountError.d.ts +8 -0
  54. package/dist/src/components/Dropdown/Root/AccountError.d.ts.map +1 -0
  55. package/dist/src/components/Dropdown/Root/AccountError.js +17 -0
  56. package/dist/src/components/Dropdown/Root/AccountError.js.map +1 -0
  57. package/dist/src/components/Dropdown/Root/AccountMusdListing.d.ts +4 -0
  58. package/dist/src/components/Dropdown/Root/AccountMusdListing.d.ts.map +1 -0
  59. package/dist/src/components/Dropdown/Root/AccountMusdListing.js +21 -0
  60. package/dist/src/components/Dropdown/Root/AccountMusdListing.js.map +1 -0
  61. package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts +8 -0
  62. package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts.map +1 -0
  63. package/dist/src/components/Dropdown/Root/AccountOtherAssets.js +43 -0
  64. package/dist/src/components/Dropdown/Root/AccountOtherAssets.js.map +1 -0
  65. package/dist/src/components/Dropdown/Root/Root.d.ts +8 -0
  66. package/dist/src/components/Dropdown/Root/Root.d.ts.map +1 -0
  67. package/dist/src/components/Dropdown/Root/Root.js +49 -0
  68. package/dist/src/components/Dropdown/Root/Root.js.map +1 -0
  69. package/dist/src/components/Dropdown/Root/WalletAddress.d.ts +4 -0
  70. package/dist/src/components/Dropdown/Root/WalletAddress.d.ts.map +1 -0
  71. package/dist/src/components/Dropdown/Root/WalletAddress.js +66 -0
  72. package/dist/src/components/Dropdown/Root/WalletAddress.js.map +1 -0
  73. package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts +6 -0
  74. package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts.map +1 -0
  75. package/dist/src/components/Dropdown/Root/WelcomeBlock.js +88 -0
  76. package/dist/src/components/Dropdown/Root/WelcomeBlock.js.map +1 -0
  77. package/dist/src/components/Dropdown/Settings/InlineEditField.d.ts +12 -0
  78. package/dist/src/components/Dropdown/Settings/InlineEditField.d.ts.map +1 -0
  79. package/dist/src/components/Dropdown/Settings/InlineEditField.js +95 -0
  80. package/dist/src/components/Dropdown/Settings/InlineEditField.js.map +1 -0
  81. package/dist/src/components/Dropdown/Settings/Settings.d.ts +4 -0
  82. package/dist/src/components/Dropdown/Settings/Settings.d.ts.map +1 -0
  83. package/dist/src/components/Dropdown/Settings/Settings.js +36 -0
  84. package/dist/src/components/Dropdown/Settings/Settings.js.map +1 -0
  85. package/dist/src/components/Dropdown/SlotNumber.d.ts +19 -0
  86. package/dist/src/components/Dropdown/SlotNumber.d.ts.map +1 -0
  87. package/dist/src/components/Dropdown/SlotNumber.js +67 -0
  88. package/dist/src/components/Dropdown/SlotNumber.js.map +1 -0
  89. package/dist/src/components/Dropdown/TestnetTopBanner.d.ts +3 -0
  90. package/dist/src/components/Dropdown/TestnetTopBanner.d.ts.map +1 -0
  91. package/dist/src/components/Dropdown/TestnetTopBanner.js +14 -0
  92. package/dist/src/components/Dropdown/TestnetTopBanner.js.map +1 -0
  93. package/dist/src/components/Dropdown/index.d.ts +3 -0
  94. package/dist/src/components/Dropdown/index.d.ts.map +1 -0
  95. package/dist/src/components/Dropdown/index.js +2 -0
  96. package/dist/src/components/Dropdown/index.js.map +1 -0
  97. package/dist/src/components/index.d.ts +2 -0
  98. package/dist/src/components/index.d.ts.map +1 -0
  99. package/dist/src/components/index.js +2 -0
  100. package/dist/src/components/index.js.map +1 -0
  101. package/dist/src/hooks/index.d.ts +1 -0
  102. package/dist/src/hooks/index.d.ts.map +1 -1
  103. package/dist/src/hooks/index.js +1 -0
  104. package/dist/src/hooks/index.js.map +1 -1
  105. package/dist/src/hooks/useAcceptDocuments.d.ts +18 -0
  106. package/dist/src/hooks/useAcceptDocuments.d.ts.map +1 -1
  107. package/dist/src/hooks/useAuthenticateWithWallet.d.ts +11 -11
  108. package/dist/src/hooks/useCreateAccount.d.ts +18 -0
  109. package/dist/src/hooks/useCreateAccount.d.ts.map +1 -1
  110. package/dist/src/hooks/useSignInWithWallet.d.ts +11 -11
  111. package/dist/src/hooks/useSignUpWithWallet.d.ts +11 -11
  112. package/dist/src/hooks/useUpdateMezoId.d.ts +18 -0
  113. package/dist/src/hooks/useUpdateMezoId.d.ts.map +1 -1
  114. package/dist/src/hooks/useUpdateUserProfile.d.ts +171 -0
  115. package/dist/src/hooks/useUpdateUserProfile.d.ts.map +1 -0
  116. package/dist/src/hooks/useUpdateUserProfile.js +19 -0
  117. package/dist/src/hooks/useUpdateUserProfile.js.map +1 -0
  118. package/dist/src/hooks/useWalletAccount.d.ts +2 -5
  119. package/dist/src/hooks/useWalletAccount.d.ts.map +1 -1
  120. package/dist/src/hooks/useWalletAccount.js.map +1 -1
  121. package/dist/src/index.d.ts +1 -0
  122. package/dist/src/index.d.ts.map +1 -1
  123. package/dist/src/index.js +1 -0
  124. package/dist/src/index.js.map +1 -1
  125. package/dist/src/stores/dropdownStore.d.ts +2 -1
  126. package/dist/src/stores/dropdownStore.d.ts.map +1 -1
  127. package/dist/src/stores/dropdownStore.js +1 -0
  128. package/dist/src/stores/dropdownStore.js.map +1 -1
  129. package/dist/src/utils/validation.d.ts +13 -0
  130. package/dist/src/utils/validation.d.ts.map +1 -0
  131. package/dist/src/utils/validation.js +34 -0
  132. package/dist/src/utils/validation.js.map +1 -0
  133. package/dist/src/utils/validation.test.d.ts +2 -0
  134. package/dist/src/utils/validation.test.d.ts.map +1 -0
  135. package/dist/src/utils/validation.test.js +63 -0
  136. package/dist/src/utils/validation.test.js.map +1 -0
  137. package/package.json +10 -7
  138. package/src/api/auth.ts +22 -0
  139. package/src/assets/DefaultAvatar.tsx +74 -0
  140. package/src/assets/EditIcon.tsx +33 -0
  141. package/src/components/Dropdown/ConnectedTrigger.tsx +76 -0
  142. package/src/components/Dropdown/Content.tsx +56 -0
  143. package/src/components/Dropdown/DisconnectedTrigger.tsx +36 -0
  144. package/src/components/Dropdown/Dropdown.tsx +100 -0
  145. package/src/components/Dropdown/ListingItem.tsx +176 -0
  146. package/src/components/Dropdown/NestedViewLayout.tsx +88 -0
  147. package/src/components/Dropdown/README.md +41 -0
  148. package/src/components/Dropdown/Receive/Receive.tsx +144 -0
  149. package/src/components/Dropdown/Root/AccountAddressActions.tsx +99 -0
  150. package/src/components/Dropdown/Root/AccountBalance.tsx +69 -0
  151. package/src/components/Dropdown/Root/AccountBtcListing.tsx +53 -0
  152. package/src/components/Dropdown/Root/AccountError.tsx +34 -0
  153. package/src/components/Dropdown/Root/AccountMusdListing.tsx +45 -0
  154. package/src/components/Dropdown/Root/AccountOtherAssets.tsx +85 -0
  155. package/src/components/Dropdown/Root/Root.tsx +104 -0
  156. package/src/components/Dropdown/Root/WalletAddress.tsx +123 -0
  157. package/src/components/Dropdown/Root/WelcomeBlock.tsx +173 -0
  158. package/src/components/Dropdown/Settings/InlineEditField.tsx +212 -0
  159. package/src/components/Dropdown/Settings/Settings.tsx +87 -0
  160. package/src/components/Dropdown/SlotNumber.tsx +131 -0
  161. package/src/components/Dropdown/TestnetTopBanner.tsx +32 -0
  162. package/src/components/Dropdown/index.ts +2 -0
  163. package/src/components/index.ts +1 -0
  164. package/src/hooks/index.ts +1 -0
  165. package/src/hooks/useUpdateUserProfile.ts +34 -0
  166. package/src/hooks/useWalletAccount.ts +2 -8
  167. package/src/index.ts +1 -0
  168. package/src/stores/dropdownStore.ts +1 -0
  169. package/src/utils/validation.test.ts +97 -0
  170. package/src/utils/validation.ts +35 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mezo-org/passport",
3
- "version": "0.15.1-dev.7",
3
+ "version": "0.16.0-dev.1",
4
4
  "main": "dist/src/index.js",
5
5
  "license": "GPL-3.0-only",
6
6
  "scripts": {
@@ -34,24 +34,27 @@
34
34
  "prettier": "^3.2.5",
35
35
  "ts-jest": "^29.1.2",
36
36
  "ts-node": "^10.9.2",
37
- "typescript": "^5.4.3"
37
+ "typescript": "^5.8.2"
38
38
  },
39
39
  "dependencies": {
40
+ "@mezo-org/mezo-clay": "0.1.0-dev.37",
40
41
  "@mezo-org/mezod-contracts": "^1.0.0",
41
42
  "@mezo-org/musd-contracts": "^1.0.1",
42
- "@mezo-org/orangekit": "1.0.0-beta.40-dev.28",
43
+ "@mezo-org/orangekit": "1.0.0-beta.40",
43
44
  "@mezo-org/sign-in-with-wallet": "1.0.0-beta.8",
45
+ "@rainbow-me/rainbowkit": "2.0.2",
46
+ "@tanstack/react-query": "^5.28.4",
47
+ "motion": "^12.23.6",
44
48
  "qrcode.react": "^4.2.0",
45
49
  "styletron-engine-monolithic": "^1.0.0",
46
50
  "usehooks-ts": "^3.1.1",
47
- "motion": "^12.23.6",
48
51
  "zustand": "^5.0.3"
49
52
  },
50
53
  "peerDependencies": {
51
54
  "@rainbow-me/rainbowkit": "^2.0.2",
52
55
  "@tanstack/react-query": "^5.28.4",
53
- "react": ">=18",
54
- "viem": "2.x",
55
- "wagmi": "2.x"
56
+ "react": "^18.2.0",
57
+ "viem": "^2.22.8",
58
+ "wagmi": "^2.5.12"
56
59
  }
57
60
  }
package/src/api/auth.ts CHANGED
@@ -31,6 +31,8 @@ type Account = {
31
31
  hasModifiedMezoId: boolean
32
32
  linkedAccounts: LinkedAccount[]
33
33
  documents?: Record<DocumentType, UserDocumentStatus>
34
+ email?: string
35
+ telegram?: string
34
36
  }
35
37
 
36
38
  export type Session = {
@@ -94,6 +96,14 @@ export type AcceptDocumentsRequest = Partial<
94
96
  Record<DocumentType, { acceptedVersion: string }>
95
97
  >
96
98
 
99
+ export type UpdateAccountRequest = {
100
+ mezoId?: string
101
+ email?: string
102
+ telegram?: string
103
+ }
104
+
105
+ export type UpdateAccountResponse = Account
106
+
97
107
  export const AUTH_API_ENDPOINTS_BY_ENV = {
98
108
  mainnet: "https://api.mezo.org",
99
109
  testnet: "https://api.test.mezo.org",
@@ -222,4 +232,16 @@ export class AuthApiClient extends ApiClient {
222
232
 
223
233
  return data
224
234
  }
235
+
236
+ async updateAccount(updates: UpdateAccountRequest) {
237
+ const data = await this.handleRequest<UpdateAccountResponse>(
238
+ "/session/account",
239
+ {
240
+ method: "PATCH",
241
+ body: updates,
242
+ },
243
+ )
244
+
245
+ return data
246
+ }
225
247
  }
@@ -0,0 +1,74 @@
1
+ import { Block, BlockProps } from "@mezo-org/mezo-clay"
2
+ import React, { SVGProps } from "react"
3
+
4
+ function DefaultAvatar(props: SVGProps<SVGSVGElement>) {
5
+ return (
6
+ <svg viewBox="0 0 214 214" fill="none" {...props}>
7
+ <rect y="-0.478027" width="166.379" height="81.7091" fill="#FF004D" />
8
+ <rect x="166" y="-0.478027" width="48" height="82" fill="black" />
9
+ <rect
10
+ x="166.379"
11
+ y="81.231"
12
+ width="24.1044"
13
+ height="132.291"
14
+ fill="#DFFF80"
15
+ />
16
+ <rect
17
+ x="118.758"
18
+ y="81.231"
19
+ width="24.1044"
20
+ height="132.291"
21
+ fill="#FF5500"
22
+ />
23
+ <rect
24
+ x="71.1372"
25
+ y="81.231"
26
+ width="24.1044"
27
+ height="132.291"
28
+ fill="#5A59A7"
29
+ />
30
+ <rect
31
+ x="23.5166"
32
+ y="81.231"
33
+ width="24.1044"
34
+ height="132.291"
35
+ fill="#47B5FF"
36
+ />
37
+ <rect y="81.231" width="23.5165" height="132.291" fill="#A3C238" />
38
+ <rect
39
+ x="190.483"
40
+ y="81.231"
41
+ width="23.5165"
42
+ height="132.291"
43
+ fill="#6E6E70"
44
+ />
45
+ <rect
46
+ x="142.863"
47
+ y="81.231"
48
+ width="23.5165"
49
+ height="132.291"
50
+ fill="#0A3C01"
51
+ />
52
+ <rect
53
+ x="95.2417"
54
+ y="81.231"
55
+ width="23.5165"
56
+ height="132.291"
57
+ fill="#F2A91F"
58
+ />
59
+ <rect
60
+ x="47.6211"
61
+ y="81.231"
62
+ width="23.5165"
63
+ height="132.291"
64
+ fill="#6B3D01"
65
+ />
66
+ </svg>
67
+ )
68
+ }
69
+
70
+ function DefaultAvatarComponent(props: BlockProps) {
71
+ return <Block as={DefaultAvatar} {...props} />
72
+ }
73
+
74
+ export default DefaultAvatarComponent
@@ -0,0 +1,33 @@
1
+ import { Icon, IconProps } from "@mezo-org/mezo-clay"
2
+ import React, { forwardRef, Ref } from "react"
3
+
4
+ function EditIcon(props: IconProps, ref: Ref<SVGSVGElement>) {
5
+ const { title, size = 16, color = "black", ...restProps } = props
6
+
7
+ return (
8
+ <Icon
9
+ ref={ref}
10
+ viewBox="0 0 24 24"
11
+ title={title ?? "Edit"}
12
+ size={size}
13
+ color={color}
14
+ role="graphics-symbol"
15
+ {...restProps}
16
+ >
17
+ <path
18
+ d="M18 10L21 7L17 3L14 6M18 10L8 20H4V16L14 6M18 10L14 6"
19
+ stroke={color}
20
+ strokeWidth="2"
21
+ strokeLinecap="round"
22
+ strokeLinejoin="round"
23
+ fill="none"
24
+ />
25
+ </Icon>
26
+ )
27
+ }
28
+
29
+ const ForwardedEditIcon: React.ForwardRefExoticComponent<
30
+ IconProps & React.RefAttributes<SVGSVGElement>
31
+ > = forwardRef<SVGSVGElement, IconProps>(EditIcon)
32
+
33
+ export default ForwardedEditIcon
@@ -0,0 +1,76 @@
1
+ import { Block, Button, ButtonProps, useStyletron } from "@mezo-org/mezo-clay"
2
+ import React, { forwardRef, ReactNode, useMemo } from "react"
3
+
4
+ type ConnectedTriggerProps = Omit<ButtonProps, "children" | "size"> & {
5
+ avatar: ReactNode
6
+ size?: "medium" | "large"
7
+ }
8
+
9
+ const ConnectedTrigger = forwardRef<HTMLButtonElement, ConnectedTriggerProps>(
10
+ (props, ref) => {
11
+ const { onClick, avatar, size = "medium", ...restProps } = props
12
+
13
+ const [, theme] = useStyletron()
14
+
15
+ const avatarSize = useMemo(() => {
16
+ const sizeMap = {
17
+ medium: theme.sizing.scale950,
18
+ large: theme.sizing.scale1400,
19
+ }
20
+
21
+ return sizeMap[size]
22
+ }, [theme, size])
23
+
24
+ const buttonPadding = useMemo(() => {
25
+ const paddingMap = {
26
+ medium: theme.sizing.scale0,
27
+ large: theme.sizing.scale100,
28
+ }
29
+
30
+ return paddingMap[size]
31
+ }, [theme, size])
32
+
33
+ return (
34
+ <Button
35
+ overrides={{
36
+ BaseButton: {
37
+ props: { ref, ...restProps },
38
+ style: {
39
+ borderRadius: "100%",
40
+ overflow: "hidden",
41
+ padding: buttonPadding,
42
+ },
43
+ },
44
+ }}
45
+ onClick={onClick}
46
+ >
47
+ {typeof avatar === "string" ? (
48
+ <Block
49
+ width={avatarSize}
50
+ height={avatarSize}
51
+ as="img"
52
+ src={avatar}
53
+ alt=""
54
+ />
55
+ ) : (
56
+ <Block
57
+ width={avatarSize}
58
+ height={avatarSize}
59
+ overrides={{
60
+ Block: {
61
+ style: {
62
+ borderRadius: "100%",
63
+ overflow: "hidden",
64
+ },
65
+ },
66
+ }}
67
+ >
68
+ {avatar}
69
+ </Block>
70
+ )}
71
+ </Button>
72
+ )
73
+ },
74
+ )
75
+
76
+ export default ConnectedTrigger
@@ -0,0 +1,56 @@
1
+ import { Block, useStyletron } from "@mezo-org/mezo-clay"
2
+ import React, { useEffect } from "react"
3
+ import useDropdownStore, { DropdownView } from "../../stores/dropdownStore"
4
+ import Root from "./Root/Root"
5
+ import Receive from "./Receive/Receive"
6
+ import Settings from "./Settings/Settings"
7
+ import TestnetTopBanner from "./TestnetTopBanner"
8
+
9
+ type ContentProps = {
10
+ onSignOut?: () => void
11
+ onOtherAssetsClick?: () => void
12
+ }
13
+
14
+ function Content(props: ContentProps) {
15
+ const { onSignOut, onOtherAssetsClick } = props
16
+
17
+ const [_, theme] = useStyletron()
18
+
19
+ const currentView = useDropdownStore((state) => state.view)
20
+ const setView = useDropdownStore((state) => state.setView)
21
+
22
+ useEffect(
23
+ () => () => {
24
+ setView(DropdownView.ROOT)
25
+ },
26
+ [setView],
27
+ )
28
+
29
+ return (
30
+ <Block
31
+ display="inline-flex"
32
+ flexDirection="column"
33
+ backgroundColor={theme.colors.backgroundPrimary}
34
+ width="100%"
35
+ overrides={{
36
+ Block: {
37
+ style: {
38
+ boxSizing: "border-box",
39
+ },
40
+ },
41
+ }}
42
+ >
43
+ <TestnetTopBanner />
44
+
45
+ {currentView === DropdownView.ROOT && (
46
+ <Root onSignOut={onSignOut} onOtherAssetsClick={onOtherAssetsClick} />
47
+ )}
48
+
49
+ {currentView === DropdownView.RECEIVE && <Receive />}
50
+
51
+ {currentView === DropdownView.SETTINGS && <Settings />}
52
+ </Block>
53
+ )
54
+ }
55
+
56
+ export default Content
@@ -0,0 +1,36 @@
1
+ import { Button, ButtonProps, LogIn01, useStyletron } from "@mezo-org/mezo-clay"
2
+ import React, { forwardRef } from "react"
3
+
4
+ type DisconnectedTriggerProps = Omit<ButtonProps, "children"> & {
5
+ children: string
6
+ }
7
+
8
+ const DisconnectedTrigger = forwardRef<
9
+ HTMLButtonElement,
10
+ DisconnectedTriggerProps
11
+ >((props, ref) => {
12
+ const { onClick, children, ...restProps } = props
13
+
14
+ const [, theme] = useStyletron()
15
+
16
+ return (
17
+ <Button
18
+ startEnhancer={
19
+ <LogIn01 color="currentColor" size={theme.sizing.scale600} />
20
+ }
21
+ overrides={{
22
+ Root: {
23
+ props: { ref },
24
+ },
25
+ }}
26
+ size="small"
27
+ shape="pill"
28
+ onClick={onClick}
29
+ {...restProps}
30
+ >
31
+ {children}
32
+ </Button>
33
+ )
34
+ })
35
+
36
+ export default DisconnectedTrigger
@@ -0,0 +1,100 @@
1
+ import {
2
+ ButtonProps,
3
+ StatefulPopover,
4
+ StatefulPopoverProps,
5
+ useStyletron,
6
+ } from "@mezo-org/mezo-clay"
7
+ import { useConnectModal } from "@rainbow-me/rainbowkit"
8
+ import React from "react"
9
+ import DefaultAvatar from "../../assets/DefaultAvatar"
10
+ import ConnectedTrigger from "./ConnectedTrigger"
11
+ import Content from "./Content"
12
+ import DisconnectedTrigger from "./DisconnectedTrigger"
13
+ import { useWalletAccount } from "../../hooks/useWalletAccount"
14
+ import { useWatchTransferEventsForAllTokens } from "../../hooks/useWatchTransferEvents"
15
+
16
+ export type DropdownProps = {
17
+ /** The callback to be called when the user clicks the sign-out button */
18
+ onSignOut?: () => void
19
+ /** The callback to be called when the user clicks the button in sign-in state */
20
+ onSignIn?: () => void
21
+ /** The props to be passed to the trigger button */
22
+ triggerProps?: {
23
+ signedIn?: Omit<ButtonProps, "onClick" | "size"> & {
24
+ size: "medium" | "large"
25
+ }
26
+ signedOut?: Omit<ButtonProps, "onClick">
27
+ }
28
+ onOtherAssetsClick?: () => void
29
+ } & Omit<StatefulPopoverProps, "children" | "content">
30
+
31
+ /**
32
+ * Passport Dropdown component that displays user's wallet and assets information.
33
+ * @param {DropdownProps} props - Component props.
34
+ * @returns {JSX.Element}
35
+ */
36
+ export function Dropdown(props: DropdownProps) {
37
+ const {
38
+ placement = "bottomRight",
39
+ animateOutTime = 120,
40
+ onSignIn,
41
+ onSignOut,
42
+ overrides,
43
+ triggerProps,
44
+ onOtherAssetsClick,
45
+ ...restProps
46
+ } = props
47
+
48
+ const [, theme] = useStyletron()
49
+
50
+ const walletAccount = useWalletAccount()
51
+
52
+ useWatchTransferEventsForAllTokens()
53
+
54
+ const { openConnectModal } = useConnectModal()
55
+
56
+ if (!walletAccount?.isConnected) {
57
+ return (
58
+ <DisconnectedTrigger
59
+ // If connect wallet flow is not provided it fallbacks to RainbowKit's
60
+ // connect modal
61
+ onClick={onSignIn || openConnectModal}
62
+ {...triggerProps?.signedOut}
63
+ >
64
+ Sign in
65
+ </DisconnectedTrigger>
66
+ )
67
+ }
68
+
69
+ return (
70
+ <StatefulPopover
71
+ content={
72
+ <Content
73
+ onSignOut={onSignOut}
74
+ onOtherAssetsClick={onOtherAssetsClick}
75
+ />
76
+ }
77
+ placement={placement}
78
+ animateOutTime={animateOutTime}
79
+ overrides={{
80
+ ...overrides,
81
+ Body: {
82
+ ...overrides?.Body,
83
+ style: {
84
+ width: "402px",
85
+ borderRadius: theme.borders.radius500,
86
+ boxShadow: theme.lighting.shadow500,
87
+ overflow: "hidden",
88
+ ...overrides?.Body?.style,
89
+ },
90
+ },
91
+ }}
92
+ {...restProps}
93
+ >
94
+ <ConnectedTrigger
95
+ avatar={<DefaultAvatar />}
96
+ {...triggerProps?.signedIn}
97
+ />
98
+ </StatefulPopover>
99
+ )
100
+ }
@@ -0,0 +1,176 @@
1
+ import {
2
+ mergeOverrides,
3
+ Block,
4
+ useStyletron,
5
+ BlockProps,
6
+ Skeleton,
7
+ LabelMedium,
8
+ ParagraphSmall,
9
+ } from "@mezo-org/mezo-clay"
10
+ import React, { ReactNode } from "react"
11
+ import SlotNumber from "./SlotNumber"
12
+ import { formatUsd } from "../../utils/currency"
13
+
14
+ type ListingItemLayoutProps = Omit<BlockProps, "children"> & {
15
+ icon: ReactNode
16
+ label: ReactNode
17
+ value: ReactNode
18
+ subLabel: ReactNode
19
+ subValue: ReactNode
20
+ }
21
+
22
+ function ListingItemLayout(props: ListingItemLayoutProps) {
23
+ const { icon, label, value, subLabel, subValue, overrides, ...restProps } =
24
+ props
25
+ const [, theme] = useStyletron()
26
+
27
+ return (
28
+ <Block
29
+ display="flex"
30
+ alignItems="center"
31
+ paddingLeft={theme.sizing.scale600}
32
+ paddingRight={theme.sizing.scale600}
33
+ overrides={mergeOverrides(
34
+ {
35
+ Block: {
36
+ style: {
37
+ gap: theme.sizing.scale600,
38
+ minHeight: "72px",
39
+ },
40
+ },
41
+ },
42
+ overrides,
43
+ )}
44
+ {...restProps}
45
+ >
46
+ {icon && icon}
47
+
48
+ <Block display="flex" flexDirection="column" alignItems="flex-start">
49
+ {label && label}
50
+ {subLabel && subLabel}
51
+ </Block>
52
+
53
+ <Block
54
+ display="flex"
55
+ flexDirection="column"
56
+ alignItems="flex-end"
57
+ marginLeft="auto"
58
+ >
59
+ {value && value}
60
+ {subValue && subValue}
61
+ </Block>
62
+ </Block>
63
+ )
64
+ }
65
+
66
+ type ListingItemProps = {
67
+ icon?: ReactNode
68
+ label?: string
69
+ subLabel?: string
70
+ value?: number
71
+ subValue?: number
72
+ overrides?: BlockProps["overrides"]
73
+ isLoading?: boolean
74
+ }
75
+
76
+ export default function ListingItem(props: ListingItemProps) {
77
+ const {
78
+ icon,
79
+ label,
80
+ subLabel,
81
+ value,
82
+ subValue,
83
+ overrides,
84
+ isLoading = false,
85
+ } = props
86
+
87
+ const [, theme] = useStyletron()
88
+
89
+ if (isLoading) {
90
+ return (
91
+ <ListingItemLayout
92
+ icon={
93
+ <Skeleton
94
+ animation
95
+ width={theme.sizing.scale800}
96
+ height={theme.sizing.scale800}
97
+ />
98
+ }
99
+ label={
100
+ <Skeleton
101
+ animation
102
+ width={theme.sizing.scale2400}
103
+ height={theme.sizing.scale600}
104
+ overrides={{
105
+ Root: {
106
+ style: { marginBottom: theme.sizing.scale100 },
107
+ },
108
+ }}
109
+ />
110
+ }
111
+ subLabel={
112
+ <Skeleton
113
+ animation
114
+ width={theme.sizing.scale1600}
115
+ height={theme.sizing.scale550}
116
+ />
117
+ }
118
+ value={
119
+ <Skeleton
120
+ animation
121
+ width={theme.sizing.scale2400}
122
+ height={theme.sizing.scale600}
123
+ overrides={{
124
+ Root: {
125
+ style: { marginBottom: theme.sizing.scale100 },
126
+ },
127
+ }}
128
+ />
129
+ }
130
+ subValue={
131
+ <Skeleton
132
+ animation
133
+ width={theme.sizing.scale1600}
134
+ height={theme.sizing.scale550}
135
+ />
136
+ }
137
+ overrides={overrides}
138
+ />
139
+ )
140
+ }
141
+
142
+ return (
143
+ <ListingItemLayout
144
+ icon={icon}
145
+ label={<LabelMedium>{label}</LabelMedium>}
146
+ subLabel={
147
+ <ParagraphSmall
148
+ margin={0}
149
+ as="div"
150
+ color={theme.colors.contentSecondary}
151
+ >
152
+ {subLabel}
153
+ </ParagraphSmall>
154
+ }
155
+ value={
156
+ value !== undefined && (
157
+ <LabelMedium>
158
+ <SlotNumber formatFunction={formatUsd}>{value}</SlotNumber>
159
+ </LabelMedium>
160
+ )
161
+ }
162
+ subValue={
163
+ subValue !== undefined && (
164
+ <ParagraphSmall
165
+ margin={0}
166
+ as="div"
167
+ color={theme.colors.contentSecondary}
168
+ >
169
+ <SlotNumber formatFunction={formatUsd}>{subValue}</SlotNumber>
170
+ </ParagraphSmall>
171
+ )
172
+ }
173
+ overrides={overrides}
174
+ />
175
+ )
176
+ }