@mezo-org/passport 0.15.1-dev.6 → 0.16.0-dev.0

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 (63) hide show
  1. package/dist/src/components/Dropdown/Dropdown.js +1 -1
  2. package/dist/src/components/Dropdown/Dropdown.js.map +1 -1
  3. package/dist/src/components/Dropdown/Receive/Receive.js +1 -1
  4. package/dist/src/components/Dropdown/Receive/Receive.js.map +1 -1
  5. package/dist/src/components/Dropdown/Root/AccountAddressActions.js +1 -1
  6. package/dist/src/components/Dropdown/Root/AccountAddressActions.js.map +1 -1
  7. package/dist/src/components/Dropdown/Root/WalletAddress.js +1 -1
  8. package/dist/src/components/Dropdown/Root/WalletAddress.js.map +1 -1
  9. package/dist/src/config.d.ts +2 -2
  10. package/dist/src/config.d.ts.map +1 -1
  11. package/dist/src/config.js +1 -1
  12. package/dist/src/config.js.map +1 -1
  13. package/dist/src/hooks/index.d.ts +0 -1
  14. package/dist/src/hooks/index.d.ts.map +1 -1
  15. package/dist/src/hooks/index.js +0 -1
  16. package/dist/src/hooks/index.js.map +1 -1
  17. package/dist/src/hooks/useAuthenticateWithWallet.js +1 -1
  18. package/dist/src/hooks/useAuthenticateWithWallet.js.map +1 -1
  19. package/dist/src/hooks/useBorrowData.js +1 -1
  20. package/dist/src/hooks/useBorrowData.js.map +1 -1
  21. package/dist/src/hooks/useCollateralPrice.js +1 -1
  22. package/dist/src/hooks/useCollateralPrice.js.map +1 -1
  23. package/dist/src/hooks/useCreateAccount.js +1 -1
  24. package/dist/src/hooks/useCreateAccount.js.map +1 -1
  25. package/dist/src/hooks/useLinkAccount.js +1 -1
  26. package/dist/src/hooks/useLinkAccount.js.map +1 -1
  27. package/dist/src/hooks/useTokensBalances.d.ts.map +1 -1
  28. package/dist/src/hooks/useTokensBalances.js +10 -2
  29. package/dist/src/hooks/useTokensBalances.js.map +1 -1
  30. package/dist/src/hooks/useWalletAccount.d.ts +1 -1
  31. package/dist/src/hooks/useWalletAccount.d.ts.map +1 -1
  32. package/dist/src/hooks/useWalletAccount.js +4 -6
  33. package/dist/src/hooks/useWalletAccount.js.map +1 -1
  34. package/dist/src/hooks/useWatchTransferEvents.d.ts.map +1 -1
  35. package/dist/src/hooks/useWatchTransferEvents.js +1 -0
  36. package/dist/src/hooks/useWatchTransferEvents.js.map +1 -1
  37. package/dist/src/lib/contracts/artifacts/MEZO.json +428 -0
  38. package/dist/src/lib/contracts/index.d.ts +1 -1
  39. package/dist/src/lib/contracts/index.d.ts.map +1 -1
  40. package/dist/src/lib/contracts/index.js +3 -0
  41. package/dist/src/lib/contracts/index.js.map +1 -1
  42. package/dist/src/utils/assets.d.ts +15 -0
  43. package/dist/src/utils/assets.d.ts.map +1 -1
  44. package/dist/src/utils/assets.js +13 -0
  45. package/dist/src/utils/assets.js.map +1 -1
  46. package/package.json +7 -7
  47. package/src/components/Dropdown/Dropdown.tsx +1 -1
  48. package/src/components/Dropdown/Receive/Receive.tsx +1 -1
  49. package/src/components/Dropdown/Root/AccountAddressActions.tsx +1 -1
  50. package/src/components/Dropdown/Root/WalletAddress.tsx +1 -1
  51. package/src/config.ts +3 -3
  52. package/src/hooks/index.ts +0 -1
  53. package/src/hooks/useAuthenticateWithWallet.ts +1 -1
  54. package/src/hooks/useBorrowData.ts +1 -1
  55. package/src/hooks/useCollateralPrice.ts +1 -1
  56. package/src/hooks/useCreateAccount.ts +1 -1
  57. package/src/hooks/useLinkAccount.ts +1 -1
  58. package/src/hooks/useTokensBalances.ts +10 -1
  59. package/src/hooks/useWalletAccount.ts +5 -13
  60. package/src/hooks/useWatchTransferEvents.ts +1 -0
  61. package/src/lib/contracts/artifacts/MEZO.json +428 -0
  62. package/src/lib/contracts/index.ts +4 -0
  63. package/src/utils/assets.ts +14 -0
@@ -9,7 +9,7 @@ import {
9
9
  import { usePassportContext } from "./usePassportContext"
10
10
  import { CHAIN_ID } from "../constants"
11
11
  import { bigIntMax, normalizePrecision } from "../utils/numbers"
12
- import { useWalletAccount } from "./useWalletAccount"
12
+ import useWalletAccount from "./useWalletAccount"
13
13
  import { getAsset } from "../utils/assets"
14
14
  import { convertToUsd } from "../utils/currency"
15
15
  import { useCollateralPrice } from "./useCollateralPrice"
@@ -6,7 +6,7 @@ import {
6
6
  } from "../lib/contracts"
7
7
  import { usePassportContext } from "./usePassportContext"
8
8
  import { CHAIN_ID } from "../constants"
9
- import { useWalletAccount } from "./useWalletAccount"
9
+ import useWalletAccount from "./useWalletAccount"
10
10
 
11
11
  // Wagmi handles typesafety with ABI const assertions. TypeScript doesn't
12
12
  // support importing JSON as const yet so types cannot be inferred from the
@@ -7,7 +7,7 @@ import {
7
7
  import { useAuthApiClient } from "./useAuthApiClient"
8
8
  import { QUERY_KEYS } from "./constants"
9
9
  import type { CreateAccountRequest, CreateAccountResponse } from "../api"
10
- import { useWalletAccount } from "./useWalletAccount"
10
+ import useWalletAccount from "./useWalletAccount"
11
11
  import { getBitcoinPublicKeyFromConnector } from "../utils/wagmi"
12
12
 
13
13
  export function useCreateAccount(
@@ -7,7 +7,7 @@ import {
7
7
  import { useAuthApiClient } from "./useAuthApiClient"
8
8
  import type { LinkAccountResponse, SignatureData } from "../api"
9
9
  import { QUERY_KEYS } from "./constants"
10
- import { useWalletAccount } from "./useWalletAccount"
10
+ import useWalletAccount from "./useWalletAccount"
11
11
  import { getBitcoinPublicKeyFromConnector } from "../utils/wagmi"
12
12
 
13
13
  type LinkAccountMutationFnParameters =
@@ -13,11 +13,12 @@ import {
13
13
  MezoChainToken,
14
14
  testnetTokenContracts,
15
15
  } from "../lib/contracts"
16
- import { useWalletAccount } from "./useWalletAccount"
16
+ import useWalletAccount from "./useWalletAccount"
17
17
  import {
18
18
  getAsset,
19
19
  isBitcoinLikeCryptoAsset,
20
20
  isTTokenCryptoAsset,
21
+ isMezoCryptoAsset,
21
22
  } from "../utils/assets"
22
23
  import { convertToUsd } from "../utils/currency"
23
24
  import { CHAIN_ID, mezoMainnet, mezoTestnet } from "../constants"
@@ -65,6 +66,7 @@ const BALANCE_TOKENS: MezoChainToken[] = [
65
66
  "mUSDT",
66
67
  "mxSolvBTC",
67
68
  "MUSD",
69
+ "MEZO",
68
70
  ]
69
71
 
70
72
  type UseMezoChainTokensBalancesOptions<T extends MezoChainToken[]> = {
@@ -219,6 +221,13 @@ export function useTokensBalances<T extends MezoChainToken[]>(
219
221
  conversion.decimals,
220
222
  )
221
223
  }
224
+ // TODO: Provide MEZO oracle to get accurate token price
225
+ if (isMezoCryptoAsset(tokenBalance.symbol)) {
226
+ usd = {
227
+ value: 0n,
228
+ formatted: "0",
229
+ }
230
+ }
222
231
 
223
232
  return { ...tokenBalance, usd }
224
233
  })
@@ -13,14 +13,10 @@ type UseWalletAccountReturn = {
13
13
  chainId?: number
14
14
  }
15
15
 
16
- export function useWalletAccount(): UseWalletAccountReturn {
17
- const {
18
- address: evmAddress,
19
- connector,
20
- chainId,
21
- isConnected,
22
- ...rest
23
- } = useAccount()
16
+ // TODO: Invesitgate race conditions and refactor
17
+
18
+ export default function useWalletAccount(): UseWalletAccountReturn {
19
+ const { address: evmAddress, connector, chainId } = useAccount()
24
20
 
25
21
  const networkFamily = useMemo(
26
22
  () => (connector?.type !== "orangekit" ? "evm" : "bitcoin"),
@@ -42,7 +38,6 @@ export function useWalletAccount(): UseWalletAccountReturn {
42
38
  balance,
43
39
  }
44
40
  },
45
- enabled: networkFamily === "bitcoin" && !!connector,
46
41
  })
47
42
 
48
43
  const { address: btcAddress } = btcData || {}
@@ -50,12 +45,9 @@ export function useWalletAccount(): UseWalletAccountReturn {
50
45
  return {
51
46
  accountAddress: evmAddress,
52
47
  walletAddress: btcAddress ?? evmAddress,
53
- isConnected:
54
- isConnected &&
55
- (networkFamily === "bitcoin" ? !!btcAddress : !!evmAddress),
48
+ isConnected: networkFamily === "bitcoin" ? !!btcAddress : !!evmAddress,
56
49
  networkFamily,
57
50
  connector,
58
51
  chainId,
59
- ...rest,
60
52
  }
61
53
  }
@@ -69,6 +69,7 @@ function useWatchTransferEventsForAllTokens() {
69
69
  useWatchTransferEvents("mUSDT")
70
70
  useWatchTransferEvents("mxSolvBTC")
71
71
  useWatchTransferEvents("MUSD")
72
+ useWatchTransferEvents("MEZO")
72
73
  }
73
74
 
74
75
  export { useWatchTransferEvents, useWatchTransferEventsForAllTokens }
@@ -0,0 +1,428 @@
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
+ }
@@ -29,6 +29,7 @@ import priceFeed from "@mezo-org/musd-contracts/deployments/mainnet/PriceFeed.js
29
29
  import priceFeedTestnet from "@mezo-org/musd-contracts/deployments/matsnet/PriceFeed.json"
30
30
 
31
31
  import { Abi, Address } from "viem"
32
+ import mezoArtifact from "./artifacts/MEZO.json"
32
33
 
33
34
  export type MezoChainToken =
34
35
  | "mcbBTC"
@@ -42,6 +43,7 @@ export type MezoChainToken =
42
43
  | "mUSDT"
43
44
  | "mxSolvBTC"
44
45
  | "MUSD"
46
+ | "MEZO"
45
47
 
46
48
  export type MezoBorrowContract =
47
49
  | "TroveManager"
@@ -68,6 +70,7 @@ export const testnetTokenContracts = {
68
70
  mUSDT: usdtTestnet,
69
71
  mxSolvBTC: xsolvbtcTestnet,
70
72
  MUSD: musdTestnet,
73
+ MEZO: mezoArtifact,
71
74
  } as unknown as ContractsMap<MezoChainToken>
72
75
 
73
76
  export const mainnetTokenContracts = {
@@ -82,6 +85,7 @@ export const mainnetTokenContracts = {
82
85
  mUSDT: usdtMainnet,
83
86
  mxSolvBTC: xsolvbtcMainnet,
84
87
  MUSD: musdMainnet,
88
+ MEZO: mezoArtifact,
85
89
  } as unknown as ContractsMap<MezoChainToken>
86
90
 
87
91
  export const mainnetBorrowContracts = {
@@ -64,6 +64,11 @@ const ASSETS = {
64
64
  symbol: "mxSolvBTC",
65
65
  decimals: 18,
66
66
  },
67
+ MEZO: {
68
+ name: "MEZO",
69
+ symbol: "MEZO",
70
+ decimals: 18,
71
+ },
67
72
  }
68
73
 
69
74
  /**
@@ -101,3 +106,12 @@ export function isUsdLikeCryptoAsset(key: string) {
101
106
  export function isTTokenCryptoAsset(key: string) {
102
107
  return /^(mt|t)$/i.test(key)
103
108
  }
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
+ }