@mezo-org/passport 0.16.0-dev.0 → 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 (126) 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/EditIcon.d.ts +5 -0
  6. package/dist/src/assets/EditIcon.d.ts.map +1 -0
  7. package/dist/src/assets/EditIcon.js +10 -0
  8. package/dist/src/assets/EditIcon.js.map +1 -0
  9. package/dist/src/components/Dropdown/Content.d.ts.map +1 -1
  10. package/dist/src/components/Dropdown/Content.js +3 -1
  11. package/dist/src/components/Dropdown/Content.js.map +1 -1
  12. package/dist/src/components/Dropdown/Dropdown.js +1 -1
  13. package/dist/src/components/Dropdown/Dropdown.js.map +1 -1
  14. package/dist/src/components/Dropdown/NestedViewLayout.d.ts.map +1 -1
  15. package/dist/src/components/Dropdown/NestedViewLayout.js +1 -0
  16. package/dist/src/components/Dropdown/NestedViewLayout.js.map +1 -1
  17. package/dist/src/components/Dropdown/Receive/Receive.js +1 -1
  18. package/dist/src/components/Dropdown/Receive/Receive.js.map +1 -1
  19. package/dist/src/components/Dropdown/Root/AccountAddressActions.js +1 -1
  20. package/dist/src/components/Dropdown/Root/AccountAddressActions.js.map +1 -1
  21. package/dist/src/components/Dropdown/Root/Root.d.ts.map +1 -1
  22. package/dist/src/components/Dropdown/Root/Root.js +6 -2
  23. package/dist/src/components/Dropdown/Root/Root.js.map +1 -1
  24. package/dist/src/components/Dropdown/Root/WalletAddress.js +1 -1
  25. package/dist/src/components/Dropdown/Root/WalletAddress.js.map +1 -1
  26. package/dist/src/components/Dropdown/Settings/InlineEditField.d.ts +12 -0
  27. package/dist/src/components/Dropdown/Settings/InlineEditField.d.ts.map +1 -0
  28. package/dist/src/components/Dropdown/Settings/InlineEditField.js +95 -0
  29. package/dist/src/components/Dropdown/Settings/InlineEditField.js.map +1 -0
  30. package/dist/src/components/Dropdown/Settings/Settings.d.ts +4 -0
  31. package/dist/src/components/Dropdown/Settings/Settings.d.ts.map +1 -0
  32. package/dist/src/components/Dropdown/Settings/Settings.js +36 -0
  33. package/dist/src/components/Dropdown/Settings/Settings.js.map +1 -0
  34. package/dist/src/config.d.ts +3 -4
  35. package/dist/src/config.d.ts.map +1 -1
  36. package/dist/src/config.js +9 -13
  37. package/dist/src/config.js.map +1 -1
  38. package/dist/src/hooks/index.d.ts +2 -0
  39. package/dist/src/hooks/index.d.ts.map +1 -1
  40. package/dist/src/hooks/index.js +2 -0
  41. package/dist/src/hooks/index.js.map +1 -1
  42. package/dist/src/hooks/useAcceptDocuments.d.ts +18 -0
  43. package/dist/src/hooks/useAcceptDocuments.d.ts.map +1 -1
  44. package/dist/src/hooks/useAuthenticateWithWallet.js +1 -1
  45. package/dist/src/hooks/useAuthenticateWithWallet.js.map +1 -1
  46. package/dist/src/hooks/useBorrowData.js +1 -1
  47. package/dist/src/hooks/useBorrowData.js.map +1 -1
  48. package/dist/src/hooks/useCollateralPrice.js +1 -1
  49. package/dist/src/hooks/useCollateralPrice.js.map +1 -1
  50. package/dist/src/hooks/useCreateAccount.d.ts +18 -0
  51. package/dist/src/hooks/useCreateAccount.d.ts.map +1 -1
  52. package/dist/src/hooks/useCreateAccount.js +1 -1
  53. package/dist/src/hooks/useCreateAccount.js.map +1 -1
  54. package/dist/src/hooks/useLinkAccount.js +1 -1
  55. package/dist/src/hooks/useLinkAccount.js.map +1 -1
  56. package/dist/src/hooks/useTokensBalances.d.ts.map +1 -1
  57. package/dist/src/hooks/useTokensBalances.js +2 -10
  58. package/dist/src/hooks/useTokensBalances.js.map +1 -1
  59. package/dist/src/hooks/useUpdateMezoId.d.ts +18 -0
  60. package/dist/src/hooks/useUpdateMezoId.d.ts.map +1 -1
  61. package/dist/src/hooks/useUpdateUserProfile.d.ts +171 -0
  62. package/dist/src/hooks/useUpdateUserProfile.d.ts.map +1 -0
  63. package/dist/src/hooks/useUpdateUserProfile.js +19 -0
  64. package/dist/src/hooks/useUpdateUserProfile.js.map +1 -0
  65. package/dist/src/hooks/useWalletAccount.d.ts +3 -6
  66. package/dist/src/hooks/useWalletAccount.d.ts.map +1 -1
  67. package/dist/src/hooks/useWalletAccount.js +6 -4
  68. package/dist/src/hooks/useWalletAccount.js.map +1 -1
  69. package/dist/src/hooks/useWatchTransferEvents.d.ts.map +1 -1
  70. package/dist/src/hooks/useWatchTransferEvents.js +0 -1
  71. package/dist/src/hooks/useWatchTransferEvents.js.map +1 -1
  72. package/dist/src/index.d.ts +1 -1
  73. package/dist/src/index.d.ts.map +1 -1
  74. package/dist/src/index.js +1 -1
  75. package/dist/src/index.js.map +1 -1
  76. package/dist/src/lib/contracts/index.d.ts +1 -1
  77. package/dist/src/lib/contracts/index.d.ts.map +1 -1
  78. package/dist/src/lib/contracts/index.js +0 -3
  79. package/dist/src/lib/contracts/index.js.map +1 -1
  80. package/dist/src/stores/dropdownStore.d.ts +2 -1
  81. package/dist/src/stores/dropdownStore.d.ts.map +1 -1
  82. package/dist/src/stores/dropdownStore.js +1 -0
  83. package/dist/src/stores/dropdownStore.js.map +1 -1
  84. package/dist/src/utils/assets.d.ts +0 -15
  85. package/dist/src/utils/assets.d.ts.map +1 -1
  86. package/dist/src/utils/assets.js +0 -13
  87. package/dist/src/utils/assets.js.map +1 -1
  88. package/dist/src/utils/validation.d.ts +13 -0
  89. package/dist/src/utils/validation.d.ts.map +1 -0
  90. package/dist/src/utils/validation.js +34 -0
  91. package/dist/src/utils/validation.js.map +1 -0
  92. package/dist/src/utils/validation.test.d.ts +2 -0
  93. package/dist/src/utils/validation.test.d.ts.map +1 -0
  94. package/dist/src/utils/validation.test.js +63 -0
  95. package/dist/src/utils/validation.test.js.map +1 -0
  96. package/package.json +10 -8
  97. package/src/api/auth.ts +22 -0
  98. package/src/assets/EditIcon.tsx +33 -0
  99. package/src/components/Dropdown/Content.tsx +3 -0
  100. package/src/components/Dropdown/Dropdown.tsx +1 -1
  101. package/src/components/Dropdown/NestedViewLayout.tsx +1 -0
  102. package/src/components/Dropdown/Receive/Receive.tsx +1 -1
  103. package/src/components/Dropdown/Root/AccountAddressActions.tsx +1 -1
  104. package/src/components/Dropdown/Root/Root.tsx +29 -2
  105. package/src/components/Dropdown/Root/WalletAddress.tsx +1 -1
  106. package/src/components/Dropdown/Settings/InlineEditField.tsx +212 -0
  107. package/src/components/Dropdown/Settings/Settings.tsx +87 -0
  108. package/src/config.ts +16 -26
  109. package/src/hooks/index.ts +2 -0
  110. package/src/hooks/useAuthenticateWithWallet.ts +1 -1
  111. package/src/hooks/useBorrowData.ts +1 -1
  112. package/src/hooks/useCollateralPrice.ts +1 -1
  113. package/src/hooks/useCreateAccount.ts +1 -1
  114. package/src/hooks/useLinkAccount.ts +1 -1
  115. package/src/hooks/useTokensBalances.ts +1 -10
  116. package/src/hooks/useUpdateUserProfile.ts +34 -0
  117. package/src/hooks/useWalletAccount.ts +15 -10
  118. package/src/hooks/useWatchTransferEvents.ts +0 -1
  119. package/src/index.ts +0 -1
  120. package/src/lib/contracts/index.ts +0 -4
  121. package/src/stores/dropdownStore.ts +1 -0
  122. package/src/utils/assets.ts +0 -14
  123. package/src/utils/validation.test.ts +97 -0
  124. package/src/utils/validation.ts +35 -0
  125. package/dist/src/lib/contracts/artifacts/MEZO.json +0 -428
  126. package/src/lib/contracts/artifacts/MEZO.json +0 -428
@@ -64,11 +64,6 @@ const ASSETS = {
64
64
  symbol: "mxSolvBTC",
65
65
  decimals: 18,
66
66
  },
67
- MEZO: {
68
- name: "MEZO",
69
- symbol: "MEZO",
70
- decimals: 18,
71
- },
72
67
  }
73
68
 
74
69
  /**
@@ -106,12 +101,3 @@ export function isUsdLikeCryptoAsset(key: string) {
106
101
  export function isTTokenCryptoAsset(key: string) {
107
102
  return /^(mt|t)$/i.test(key)
108
103
  }
109
-
110
- /**
111
- * Checks if given crypto asset is MEZO token
112
- * @param key The key of crypto asset
113
- * @returns True if crypto asset is MEZO token
114
- */
115
- export function isMezoCryptoAsset(key: string) {
116
- return /^mezo$/i.test(key)
117
- }
@@ -0,0 +1,97 @@
1
+ import { validateEmail, validateTelegram } from "./validation"
2
+
3
+ describe("validateEmail", () => {
4
+ it("returns null for empty string", () => {
5
+ expect(validateEmail("")).toBeNull()
6
+ })
7
+
8
+ it("returns null for valid email", () => {
9
+ expect(validateEmail("user@example.com")).toBeNull()
10
+ })
11
+
12
+ it("returns null for valid email with subdomain", () => {
13
+ expect(validateEmail("user@mail.example.com")).toBeNull()
14
+ })
15
+
16
+ it("returns null for valid email with plus addressing", () => {
17
+ expect(validateEmail("user+tag@example.com")).toBeNull()
18
+ })
19
+
20
+ it("returns error for email without @", () => {
21
+ expect(validateEmail("userexample.com")).toBe(
22
+ "Please enter a valid email address",
23
+ )
24
+ })
25
+
26
+ it("returns error for email without domain", () => {
27
+ expect(validateEmail("user@")).toBe("Please enter a valid email address")
28
+ })
29
+
30
+ it("returns error for email without TLD", () => {
31
+ expect(validateEmail("user@example")).toBe(
32
+ "Please enter a valid email address",
33
+ )
34
+ })
35
+
36
+ it("returns error for email with spaces", () => {
37
+ expect(validateEmail("user @example.com")).toBe(
38
+ "Please enter a valid email address",
39
+ )
40
+ })
41
+ })
42
+
43
+ describe("validateTelegram", () => {
44
+ it("returns null for empty string", () => {
45
+ expect(validateTelegram("")).toBeNull()
46
+ })
47
+
48
+ it("returns null for valid handle without @", () => {
49
+ expect(validateTelegram("username")).toBeNull()
50
+ })
51
+
52
+ it("returns null for valid handle with @", () => {
53
+ expect(validateTelegram("@username")).toBeNull()
54
+ })
55
+
56
+ it("returns null for handle with numbers", () => {
57
+ expect(validateTelegram("user123")).toBeNull()
58
+ })
59
+
60
+ it("returns null for handle with underscores", () => {
61
+ expect(validateTelegram("user_name")).toBeNull()
62
+ })
63
+
64
+ it("returns null for exactly 5 character handle", () => {
65
+ expect(validateTelegram("abcde")).toBeNull()
66
+ })
67
+
68
+ it("returns error for handle shorter than 5 characters", () => {
69
+ expect(validateTelegram("abcd")).toBe(
70
+ "Telegram handle must be at least 5 characters",
71
+ )
72
+ })
73
+
74
+ it("returns error for handle with @ that is too short", () => {
75
+ expect(validateTelegram("@abcd")).toBe(
76
+ "Telegram handle must be at least 5 characters",
77
+ )
78
+ })
79
+
80
+ it("returns error for handle with special characters", () => {
81
+ expect(validateTelegram("user-name")).toBe(
82
+ "Telegram handle can only contain letters, numbers, and underscores",
83
+ )
84
+ })
85
+
86
+ it("returns error for handle with spaces", () => {
87
+ expect(validateTelegram("user name")).toBe(
88
+ "Telegram handle can only contain letters, numbers, and underscores",
89
+ )
90
+ })
91
+
92
+ it("returns error for handle with dots", () => {
93
+ expect(validateTelegram("user.name")).toBe(
94
+ "Telegram handle can only contain letters, numbers, and underscores",
95
+ )
96
+ })
97
+ })
@@ -0,0 +1,35 @@
1
+ const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
2
+
3
+ /**
4
+ * Validates an email address.
5
+ * @param value - The email address to validate
6
+ * @returns An error message if invalid, null if valid or empty
7
+ */
8
+ export function validateEmail(value: string): string | null {
9
+ if (!value) {
10
+ return null
11
+ }
12
+ if (!EMAIL_REGEX.test(value)) {
13
+ return "Please enter a valid email address"
14
+ }
15
+ return null
16
+ }
17
+
18
+ /**
19
+ * Validates a Telegram handle.
20
+ * @param value - The Telegram handle to validate (with or without @ prefix)
21
+ * @returns An error message if invalid, null if valid or empty
22
+ */
23
+ export function validateTelegram(value: string): string | null {
24
+ if (!value) {
25
+ return null
26
+ }
27
+ const handle = value.startsWith("@") ? value.slice(1) : value
28
+ if (handle.length < 5) {
29
+ return "Telegram handle must be at least 5 characters"
30
+ }
31
+ if (!/^[a-zA-Z0-9_]+$/.test(handle)) {
32
+ return "Telegram handle can only contain letters, numbers, and underscores"
33
+ }
34
+ return null
35
+ }
@@ -1,428 +0,0 @@
1
- {
2
- "address": "0x7B7c000000000000000000000000000000000001",
3
- "abi": [
4
- {
5
- "anonymous": false,
6
- "inputs": [
7
- {
8
- "indexed": true,
9
- "internalType": "address",
10
- "name": "owner",
11
- "type": "address"
12
- },
13
- {
14
- "indexed": true,
15
- "internalType": "address",
16
- "name": "spender",
17
- "type": "address"
18
- },
19
- {
20
- "indexed": false,
21
- "internalType": "uint256",
22
- "name": "value",
23
- "type": "uint256"
24
- }
25
- ],
26
- "name": "Approval",
27
- "type": "event"
28
- },
29
- {
30
- "anonymous": false,
31
- "inputs": [
32
- {
33
- "indexed": true,
34
- "internalType": "address",
35
- "name": "to",
36
- "type": "address"
37
- },
38
- {
39
- "indexed": false,
40
- "internalType": "uint256",
41
- "name": "amount",
42
- "type": "uint256"
43
- }
44
- ],
45
- "name": "Minted",
46
- "type": "event"
47
- },
48
- {
49
- "anonymous": false,
50
- "inputs": [
51
- {
52
- "indexed": true,
53
- "internalType": "address",
54
- "name": "minter",
55
- "type": "address"
56
- }
57
- ],
58
- "name": "MinterSet",
59
- "type": "event"
60
- },
61
- {
62
- "anonymous": false,
63
- "inputs": [
64
- {
65
- "indexed": true,
66
- "internalType": "address",
67
- "name": "from",
68
- "type": "address"
69
- },
70
- {
71
- "indexed": true,
72
- "internalType": "address",
73
- "name": "to",
74
- "type": "address"
75
- },
76
- {
77
- "indexed": false,
78
- "internalType": "uint256",
79
- "name": "value",
80
- "type": "uint256"
81
- }
82
- ],
83
- "name": "Transfer",
84
- "type": "event"
85
- },
86
- {
87
- "inputs": [],
88
- "name": "DOMAIN_SEPARATOR",
89
- "outputs": [
90
- {
91
- "internalType": "bytes32",
92
- "name": "",
93
- "type": "bytes32"
94
- }
95
- ],
96
- "stateMutability": "view",
97
- "type": "function"
98
- },
99
- {
100
- "inputs": [],
101
- "name": "PERMIT_TYPEHASH",
102
- "outputs": [
103
- {
104
- "internalType": "bytes32",
105
- "name": "",
106
- "type": "bytes32"
107
- }
108
- ],
109
- "stateMutability": "pure",
110
- "type": "function"
111
- },
112
- {
113
- "inputs": [
114
- {
115
- "internalType": "address",
116
- "name": "owner",
117
- "type": "address"
118
- },
119
- {
120
- "internalType": "address",
121
- "name": "spender",
122
- "type": "address"
123
- }
124
- ],
125
- "name": "allowance",
126
- "outputs": [
127
- {
128
- "internalType": "uint256",
129
- "name": "",
130
- "type": "uint256"
131
- }
132
- ],
133
- "stateMutability": "view",
134
- "type": "function"
135
- },
136
- {
137
- "inputs": [
138
- {
139
- "internalType": "address",
140
- "name": "spender",
141
- "type": "address"
142
- },
143
- {
144
- "internalType": "uint256",
145
- "name": "value",
146
- "type": "uint256"
147
- }
148
- ],
149
- "name": "approve",
150
- "outputs": [
151
- {
152
- "internalType": "bool",
153
- "name": "",
154
- "type": "bool"
155
- }
156
- ],
157
- "stateMutability": "nonpayable",
158
- "type": "function"
159
- },
160
- {
161
- "inputs": [
162
- {
163
- "internalType": "address",
164
- "name": "account",
165
- "type": "address"
166
- }
167
- ],
168
- "name": "balanceOf",
169
- "outputs": [
170
- {
171
- "internalType": "uint256",
172
- "name": "",
173
- "type": "uint256"
174
- }
175
- ],
176
- "stateMutability": "view",
177
- "type": "function"
178
- },
179
- {
180
- "inputs": [],
181
- "name": "decimals",
182
- "outputs": [
183
- {
184
- "internalType": "uint8",
185
- "name": "",
186
- "type": "uint8"
187
- }
188
- ],
189
- "stateMutability": "view",
190
- "type": "function"
191
- },
192
- {
193
- "inputs": [],
194
- "name": "getMinter",
195
- "outputs": [
196
- {
197
- "internalType": "address",
198
- "name": "",
199
- "type": "address"
200
- }
201
- ],
202
- "stateMutability": "view",
203
- "type": "function"
204
- },
205
- {
206
- "inputs": [
207
- {
208
- "internalType": "address",
209
- "name": "to",
210
- "type": "address"
211
- },
212
- {
213
- "internalType": "uint256",
214
- "name": "amount",
215
- "type": "uint256"
216
- }
217
- ],
218
- "name": "mint",
219
- "outputs": [
220
- {
221
- "internalType": "bool",
222
- "name": "",
223
- "type": "bool"
224
- }
225
- ],
226
- "stateMutability": "nonpayable",
227
- "type": "function"
228
- },
229
- {
230
- "inputs": [],
231
- "name": "name",
232
- "outputs": [
233
- {
234
- "internalType": "string",
235
- "name": "",
236
- "type": "string"
237
- }
238
- ],
239
- "stateMutability": "view",
240
- "type": "function"
241
- },
242
- {
243
- "inputs": [
244
- {
245
- "internalType": "address",
246
- "name": "owner",
247
- "type": "address"
248
- }
249
- ],
250
- "name": "nonce",
251
- "outputs": [
252
- {
253
- "internalType": "uint256",
254
- "name": "",
255
- "type": "uint256"
256
- }
257
- ],
258
- "stateMutability": "view",
259
- "type": "function"
260
- },
261
- {
262
- "inputs": [
263
- {
264
- "internalType": "address",
265
- "name": "owner",
266
- "type": "address"
267
- }
268
- ],
269
- "name": "nonces",
270
- "outputs": [
271
- {
272
- "internalType": "uint256",
273
- "name": "",
274
- "type": "uint256"
275
- }
276
- ],
277
- "stateMutability": "view",
278
- "type": "function"
279
- },
280
- {
281
- "inputs": [
282
- {
283
- "internalType": "address",
284
- "name": "owner",
285
- "type": "address"
286
- },
287
- {
288
- "internalType": "address",
289
- "name": "spender",
290
- "type": "address"
291
- },
292
- {
293
- "internalType": "uint256",
294
- "name": "amount",
295
- "type": "uint256"
296
- },
297
- {
298
- "internalType": "uint256",
299
- "name": "deadline",
300
- "type": "uint256"
301
- },
302
- {
303
- "internalType": "uint8",
304
- "name": "v",
305
- "type": "uint8"
306
- },
307
- {
308
- "internalType": "bytes32",
309
- "name": "r",
310
- "type": "bytes32"
311
- },
312
- {
313
- "internalType": "bytes32",
314
- "name": "s",
315
- "type": "bytes32"
316
- }
317
- ],
318
- "name": "permit",
319
- "outputs": [
320
- {
321
- "internalType": "bool",
322
- "name": "",
323
- "type": "bool"
324
- }
325
- ],
326
- "stateMutability": "nonpayable",
327
- "type": "function"
328
- },
329
- {
330
- "inputs": [
331
- {
332
- "internalType": "address",
333
- "name": "minter",
334
- "type": "address"
335
- }
336
- ],
337
- "name": "setMinter",
338
- "outputs": [
339
- {
340
- "internalType": "bool",
341
- "name": "",
342
- "type": "bool"
343
- }
344
- ],
345
- "stateMutability": "nonpayable",
346
- "type": "function"
347
- },
348
- {
349
- "inputs": [],
350
- "name": "symbol",
351
- "outputs": [
352
- {
353
- "internalType": "string",
354
- "name": "",
355
- "type": "string"
356
- }
357
- ],
358
- "stateMutability": "view",
359
- "type": "function"
360
- },
361
- {
362
- "inputs": [],
363
- "name": "totalSupply",
364
- "outputs": [
365
- {
366
- "internalType": "uint256",
367
- "name": "",
368
- "type": "uint256"
369
- }
370
- ],
371
- "stateMutability": "view",
372
- "type": "function"
373
- },
374
- {
375
- "inputs": [
376
- {
377
- "internalType": "address",
378
- "name": "to",
379
- "type": "address"
380
- },
381
- {
382
- "internalType": "uint256",
383
- "name": "value",
384
- "type": "uint256"
385
- }
386
- ],
387
- "name": "transfer",
388
- "outputs": [
389
- {
390
- "internalType": "bool",
391
- "name": "",
392
- "type": "bool"
393
- }
394
- ],
395
- "stateMutability": "nonpayable",
396
- "type": "function"
397
- },
398
- {
399
- "inputs": [
400
- {
401
- "internalType": "address",
402
- "name": "from",
403
- "type": "address"
404
- },
405
- {
406
- "internalType": "address",
407
- "name": "to",
408
- "type": "address"
409
- },
410
- {
411
- "internalType": "uint256",
412
- "name": "value",
413
- "type": "uint256"
414
- }
415
- ],
416
- "name": "transferFrom",
417
- "outputs": [
418
- {
419
- "internalType": "bool",
420
- "name": "",
421
- "type": "bool"
422
- }
423
- ],
424
- "stateMutability": "nonpayable",
425
- "type": "function"
426
- }
427
- ]
428
- }