@mezo-org/passport 0.4.0-dev.20 → 0.4.0-dev.21

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 (131) hide show
  1. package/README.md +18 -22
  2. package/dist/src/api/portal.d.ts +1 -0
  3. package/dist/src/api/portal.d.ts.map +1 -1
  4. package/dist/src/api/portal.js.map +1 -1
  5. package/dist/src/components/Dropdown/Content.d.ts +16 -2
  6. package/dist/src/components/Dropdown/Content.d.ts.map +1 -1
  7. package/dist/src/components/Dropdown/Content.js +5 -3
  8. package/dist/src/components/Dropdown/Content.js.map +1 -1
  9. package/dist/src/components/Dropdown/Dropdown.d.ts +1 -5
  10. package/dist/src/components/Dropdown/Dropdown.d.ts.map +1 -1
  11. package/dist/src/components/Dropdown/Dropdown.js +7 -6
  12. package/dist/src/components/Dropdown/Dropdown.js.map +1 -1
  13. package/dist/src/components/Dropdown/ListingItem.d.ts +13 -0
  14. package/dist/src/components/Dropdown/ListingItem.d.ts.map +1 -0
  15. package/dist/src/components/Dropdown/ListingItem.js +34 -0
  16. package/dist/src/components/Dropdown/ListingItem.js.map +1 -0
  17. package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts +11 -0
  18. package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts.map +1 -0
  19. package/dist/src/components/Dropdown/Root/AccountAssetItem.js +9 -0
  20. package/dist/src/components/Dropdown/Root/AccountAssetItem.js.map +1 -0
  21. package/dist/src/components/Dropdown/Root/AccountBalance.d.ts +2 -1
  22. package/dist/src/components/Dropdown/Root/AccountBalance.d.ts.map +1 -1
  23. package/dist/src/components/Dropdown/Root/AccountBalance.js +7 -8
  24. package/dist/src/components/Dropdown/Root/AccountBalance.js.map +1 -1
  25. package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts +9 -0
  26. package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts.map +1 -0
  27. package/dist/src/components/Dropdown/Root/AccountOtherAssets.js +47 -0
  28. package/dist/src/components/Dropdown/Root/AccountOtherAssets.js.map +1 -0
  29. package/dist/src/components/Dropdown/Root/Root.d.ts +17 -2
  30. package/dist/src/components/Dropdown/Root/Root.d.ts.map +1 -1
  31. package/dist/src/components/Dropdown/Root/Root.js +15 -22
  32. package/dist/src/components/Dropdown/Root/Root.js.map +1 -1
  33. package/dist/src/components/Dropdown/Root/WalletAddress.js +5 -6
  34. package/dist/src/components/Dropdown/Root/WalletAddress.js.map +1 -1
  35. package/dist/src/components/Dropdown/Root/WelcomeBlock.js +4 -3
  36. package/dist/src/components/Dropdown/Root/WelcomeBlock.js.map +1 -1
  37. package/dist/src/components/Dropdown/TestnetTopBanner.d.ts +3 -0
  38. package/dist/src/components/Dropdown/TestnetTopBanner.d.ts.map +1 -0
  39. package/dist/src/components/Dropdown/TestnetTopBanner.js +14 -0
  40. package/dist/src/components/Dropdown/TestnetTopBanner.js.map +1 -0
  41. package/dist/src/config.js +2 -2
  42. package/dist/src/config.js.map +1 -1
  43. package/dist/src/constants.d.ts +2 -1
  44. package/dist/src/constants.d.ts.map +1 -1
  45. package/dist/src/constants.js +5 -4
  46. package/dist/src/constants.js.map +1 -1
  47. package/dist/src/hooks/index.d.ts +2 -0
  48. package/dist/src/hooks/index.d.ts.map +1 -1
  49. package/dist/src/hooks/index.js +2 -0
  50. package/dist/src/hooks/index.js.map +1 -1
  51. package/dist/src/hooks/useAssetsConversionRates.d.ts +7 -0
  52. package/dist/src/hooks/useAssetsConversionRates.d.ts.map +1 -0
  53. package/dist/src/hooks/{useAssetsUSDConversion.js → useAssetsConversionRates.js} +8 -5
  54. package/dist/src/hooks/useAssetsConversionRates.js.map +1 -0
  55. package/dist/src/hooks/useAuthenticateWithWallet.d.ts.map +1 -1
  56. package/dist/src/hooks/useAuthenticateWithWallet.js +4 -4
  57. package/dist/src/hooks/useAuthenticateWithWallet.js.map +1 -1
  58. package/dist/src/hooks/useBorrowData.d.ts +1418 -0
  59. package/dist/src/hooks/useBorrowData.d.ts.map +1 -0
  60. package/dist/src/hooks/useBorrowData.js +65 -0
  61. package/dist/src/hooks/useBorrowData.js.map +1 -0
  62. package/dist/src/hooks/useDropdownData.d.ts +28 -34
  63. package/dist/src/hooks/useDropdownData.d.ts.map +1 -1
  64. package/dist/src/hooks/useDropdownData.js +48 -65
  65. package/dist/src/hooks/useDropdownData.js.map +1 -1
  66. package/dist/src/hooks/useTokensBalances.d.ts +74 -0
  67. package/dist/src/hooks/useTokensBalances.d.ts.map +1 -0
  68. package/dist/src/hooks/useTokensBalances.js +140 -0
  69. package/dist/src/hooks/useTokensBalances.js.map +1 -0
  70. package/dist/src/hooks/useWalletAccount.d.ts +2 -1
  71. package/dist/src/hooks/useWalletAccount.d.ts.map +1 -1
  72. package/dist/src/hooks/useWalletAccount.js +2 -1
  73. package/dist/src/hooks/useWalletAccount.js.map +1 -1
  74. package/dist/src/lib/contracts/index.d.ts +10 -0
  75. package/dist/src/lib/contracts/index.d.ts.map +1 -0
  76. package/dist/src/lib/contracts/index.js +49 -0
  77. package/dist/src/lib/contracts/index.js.map +1 -0
  78. package/dist/src/lib/contracts/musd.d.ts +107 -0
  79. package/dist/src/lib/contracts/musd.d.ts.map +1 -0
  80. package/dist/src/lib/contracts/musd.js +1070 -0
  81. package/dist/src/lib/contracts/musd.js.map +1 -0
  82. package/dist/src/lib/contracts/troveManager.d.ts +1401 -0
  83. package/dist/src/lib/contracts/troveManager.d.ts.map +1 -0
  84. package/dist/src/lib/contracts/troveManager.js +1820 -0
  85. package/dist/src/lib/contracts/troveManager.js.map +1 -0
  86. package/dist/src/utils/cryptoAssets.d.ts +17 -1
  87. package/dist/src/utils/cryptoAssets.d.ts.map +1 -1
  88. package/dist/src/utils/cryptoAssets.js +88 -30
  89. package/dist/src/utils/cryptoAssets.js.map +1 -1
  90. package/dist/src/utils/cryptoAssets.test.js +47 -30
  91. package/dist/src/utils/cryptoAssets.test.js.map +1 -1
  92. package/dist/src/utils/numbers.d.ts +13 -0
  93. package/dist/src/utils/numbers.d.ts.map +1 -1
  94. package/dist/src/utils/numbers.js +46 -0
  95. package/dist/src/utils/numbers.js.map +1 -1
  96. package/package.json +6 -5
  97. package/src/api/portal.ts +1 -0
  98. package/src/components/Dropdown/Content.tsx +47 -11
  99. package/src/components/Dropdown/Dropdown.tsx +28 -13
  100. package/src/components/Dropdown/ListingItem.tsx +80 -0
  101. package/src/components/Dropdown/README.md +0 -14
  102. package/src/components/Dropdown/Root/AccountAssetItem.tsx +26 -0
  103. package/src/components/Dropdown/Root/AccountBalance.tsx +13 -18
  104. package/src/components/Dropdown/Root/AccountOtherAssets.tsx +63 -0
  105. package/src/components/Dropdown/Root/Root.tsx +59 -53
  106. package/src/components/Dropdown/Root/WalletAddress.tsx +7 -7
  107. package/src/components/Dropdown/Root/WelcomeBlock.tsx +3 -3
  108. package/src/components/Dropdown/TestnetTopBanner.tsx +32 -0
  109. package/src/config.ts +2 -2
  110. package/src/constants.ts +5 -4
  111. package/src/hooks/index.ts +5 -0
  112. package/src/hooks/{useAssetsUSDConversion.ts → useAssetsConversionRates.ts} +8 -7
  113. package/src/hooks/useAuthenticateWithWallet.ts +11 -7
  114. package/src/hooks/useBorrowData.ts +79 -0
  115. package/src/hooks/useDropdownData.ts +64 -123
  116. package/src/hooks/useTokensBalances.ts +187 -0
  117. package/src/hooks/useWalletAccount.ts +4 -2
  118. package/src/lib/contracts/index.ts +75 -0
  119. package/src/lib/contracts/musd.ts +1071 -0
  120. package/src/lib/contracts/troveManager.ts +1819 -0
  121. package/src/utils/cryptoAssets.test.ts +52 -34
  122. package/src/utils/cryptoAssets.ts +114 -34
  123. package/src/utils/numbers.ts +68 -0
  124. package/dist/src/components/Dropdown/Root/AccountAssets.d.ts +0 -13
  125. package/dist/src/components/Dropdown/Root/AccountAssets.d.ts.map +0 -1
  126. package/dist/src/components/Dropdown/Root/AccountAssets.js +0 -43
  127. package/dist/src/components/Dropdown/Root/AccountAssets.js.map +0 -1
  128. package/dist/src/hooks/useAssetsUSDConversion.d.ts +0 -8
  129. package/dist/src/hooks/useAssetsUSDConversion.d.ts.map +0 -1
  130. package/dist/src/hooks/useAssetsUSDConversion.js.map +0 -1
  131. package/src/components/Dropdown/Root/AccountAssets.tsx +0 -108
@@ -5,27 +5,21 @@ import {
5
5
  useStyletron,
6
6
  } from "@mezo-org/mezo-clay"
7
7
  import { useConnectModal } from "@rainbow-me/rainbowkit"
8
- import React, { useEffect } from "react"
8
+ import React, { useEffect, useMemo } from "react"
9
9
  import { useDisconnect } from "wagmi"
10
10
  import DefaultAvatar from "../../assets/DefaultAvatar"
11
- import useDropdownData, {
12
- DropdownCryptoAsset,
13
- } from "../../hooks/useDropdownData"
14
11
  import useWalletAccount from "../../hooks/useWalletAccount"
15
12
  import ConnectedTrigger from "./ConnectedTrigger"
16
13
  import Content from "./Content"
17
14
  import DisconnectedTrigger from "./DisconnectedTrigger"
18
15
  import { useSignInWithWallet } from "../../hooks"
16
+ import useDropdownData from "../../hooks/useDropdownData"
19
17
 
20
18
  export type DropdownProps = {
21
19
  /** The callback to be called when the user clicks the sign-out button */
22
20
  onSignOut?: () => void
23
21
  /** The callback to be called when the user clicks the button in sign-in state */
24
22
  onSignIn?: () => void
25
- /** The set of EVM native assets to be displayed in the dropdown */
26
- evmNativeAssets?: DropdownCryptoAsset<"tbtc" | "wbtc">[]
27
- /** The set of Matsnet assets to be displayed in the dropdown */
28
- matsnetAssets?: DropdownCryptoAsset<"mbtc" | "musd">[]
29
23
  /** The props to be passed to the trigger button */
30
24
  triggerProps?: {
31
25
  signedIn?: Omit<ButtonProps, "onClick" | "size"> & {
@@ -33,6 +27,7 @@ export type DropdownProps = {
33
27
  }
34
28
  signedOut?: Omit<ButtonProps, "onClick">
35
29
  }
30
+ onOtherAssetsClick?: () => void
36
31
  } & Omit<StatefulPopoverProps, "children" | "content">
37
32
 
38
33
  /**
@@ -46,16 +41,20 @@ export function Dropdown(props: DropdownProps) {
46
41
  animateOutTime = 120,
47
42
  onSignIn,
48
43
  onSignOut,
49
- evmNativeAssets,
50
- matsnetAssets,
51
44
  overrides,
52
45
  triggerProps,
46
+ onOtherAssetsClick,
53
47
  ...restProps
54
48
  } = props
55
49
 
56
50
  const [, theme] = useStyletron()
57
51
 
58
- const dropdownData = useDropdownData({ evmNativeAssets, matsnetAssets })
52
+ const data = useDropdownData()
53
+
54
+ const isCriticalDropdownDataLoaded = useMemo(
55
+ () => Boolean(data.mezoId && data.accountAddress && data.walletAddress),
56
+ [data],
57
+ )
59
58
 
60
59
  const { openConnectModal } = useConnectModal()
61
60
 
@@ -81,7 +80,7 @@ export function Dropdown(props: DropdownProps) {
81
80
  handleSignIn()
82
81
  }, [disconnectAsync, isConnected, onSignIn, signInWithWalletAsync])
83
82
 
84
- if (!dropdownData || !isConnected) {
83
+ if (!isConnected || !isCriticalDropdownDataLoaded) {
85
84
  return (
86
85
  <DisconnectedTrigger
87
86
  // If connect wallet flow is not provided it fallbacks to RainbowKit's
@@ -97,7 +96,23 @@ export function Dropdown(props: DropdownProps) {
97
96
 
98
97
  return (
99
98
  <StatefulPopover
100
- content={<Content data={dropdownData} onSignOut={onSignOut} />}
99
+ content={
100
+ <Content
101
+ mezoId={data.mezoId!}
102
+ matsBalance={data.matsBalance}
103
+ accountAddress={data.accountAddress!}
104
+ walletAddress={data.walletAddress!}
105
+ walletType={data.walletType}
106
+ usdTotalBalance={data.usdTotalBalance}
107
+ usdTroveDebt={data.usdTroveDebt}
108
+ usdCollateral={data.usdCollateral}
109
+ assets={data.assets}
110
+ otherAssetsCount={data.otherAssetsCount}
111
+ otherAssetsUsdTotal={data.otherAssetsUsdTotal}
112
+ onSignOut={onSignOut}
113
+ onOtherAssetsClick={onOtherAssetsClick}
114
+ />
115
+ }
101
116
  placement={placement}
102
117
  animateOutTime={animateOutTime}
103
118
  overrides={{
@@ -0,0 +1,80 @@
1
+ import {
2
+ ListItem,
3
+ ListItemLabel,
4
+ mergeOverrides,
5
+ ListItemLabelProps,
6
+ IconProps,
7
+ ListItemProps,
8
+ } from "@mezo-org/mezo-clay"
9
+ import React, { FC } from "react"
10
+
11
+ const SHARED_LABEL_OVERRIDES: ListItemLabelProps["overrides"] = {
12
+ LabelDescription: {
13
+ style: {
14
+ color: "#4B4B4B", // contentSecondary
15
+ },
16
+ },
17
+ }
18
+
19
+ type ListingItemProps = {
20
+ icon?: FC<IconProps>
21
+ label: string
22
+ subLabel?: string
23
+ value: string
24
+ subValue?: string
25
+ overrides?: ListItemProps["overrides"]
26
+ }
27
+
28
+ export default function ListingItem(props: ListingItemProps) {
29
+ const {
30
+ icon: Icon,
31
+ label,
32
+ subLabel = "",
33
+ value,
34
+ subValue = "",
35
+ overrides,
36
+ } = props
37
+
38
+ return (
39
+ <ListItem
40
+ artwork={Icon}
41
+ // eslint-disable-next-line react/no-unstable-nested-components
42
+ endEnhancer={() => (
43
+ <ListItemLabel
44
+ description={subValue}
45
+ overrides={mergeOverrides(
46
+ {
47
+ LabelRoot: {
48
+ style: {
49
+ textAlign: "right",
50
+ },
51
+ },
52
+ },
53
+ SHARED_LABEL_OVERRIDES,
54
+ )}
55
+ >
56
+ {value}
57
+ </ListItemLabel>
58
+ )}
59
+ overrides={mergeOverrides(
60
+ {
61
+ Root: {
62
+ style: {
63
+ backgroundColor: "transparent",
64
+ },
65
+ },
66
+ Content: {
67
+ style: {
68
+ border: 0,
69
+ },
70
+ },
71
+ },
72
+ overrides,
73
+ )}
74
+ >
75
+ <ListItemLabel description={subLabel} overrides={SHARED_LABEL_OVERRIDES}>
76
+ {label}
77
+ </ListItemLabel>
78
+ </ListItem>
79
+ )
80
+ }
@@ -14,20 +14,6 @@ component. It allows to establish the session and interact with the API.
14
14
  - `onSignOut` (`() => void`) - The callback to be executed on click of the
15
15
  **Sign out** button. It's optional since by default it disconnects the current
16
16
  wallet connector and closes the Passport session. - **optional**
17
- - `evmNativeAssets` (`Asset<"tbtc" | "wbtc">[]`) - Array of Matsnet assets. -
18
- **optional**
19
- - `matsnetAssets` (`Asset<"mbtc" | "musd">[]`) - Array of Matsnet assets. -
20
- **optional**
21
- ```ts
22
- type Asset = {
23
- type: "btc" | "tbtc" | "wbtc" | "mbtc" | "musd"
24
- decimals: number
25
- amount: {
26
- token: bigint
27
- usd: number
28
- }
29
- }
30
- ```
31
17
  - `triggerProps.signedIn` (`ButtonProps`) - Props to be passed to the trigger
32
18
  button in signed-in state.
33
19
  - `triggerProps.signedOut` (`ButtonProps`) - Props to be passed to the trigger
@@ -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
+ }
@@ -1,35 +1,30 @@
1
- import {
2
- Block,
3
- HeadingSmall,
4
- ParagraphSmall,
5
- useStyletron,
6
- } from "@mezo-org/mezo-clay"
7
1
  import React from "react"
2
+ import { useStyletron } from "@mezo-org/mezo-clay"
3
+ import ListingItem from "../ListingItem"
8
4
 
9
5
  type AccountBalanceProps = {
10
- amount: string
6
+ totalBalance: string
7
+ totalDebt: string
11
8
  }
12
9
 
13
10
  export default function AccountBalance(props: AccountBalanceProps) {
14
- const { amount } = props
11
+ const { totalBalance, totalDebt } = props
15
12
 
16
13
  const [, theme] = useStyletron()
17
14
 
18
15
  return (
19
- <Block
20
- padding={theme.sizing.scale500}
16
+ <ListingItem
17
+ label="Total assets"
18
+ value={totalBalance}
19
+ subLabel="Total liabilities"
20
+ subValue={totalDebt}
21
21
  overrides={{
22
- Block: {
22
+ Root: {
23
23
  style: {
24
- borderBottom: `1px solid ${theme.colors.backgroundPrimary}`,
24
+ borderBottom: `1px solid ${theme.colors.borderInverseSelected}`,
25
25
  },
26
26
  },
27
27
  }}
28
- >
29
- <ParagraphSmall margin={0} color={theme.colors.gray800}>
30
- Available balance
31
- </ParagraphSmall>
32
- <HeadingSmall margin={0}>{amount}</HeadingSmall>
33
- </Block>
28
+ />
34
29
  )
35
30
  }
@@ -0,0 +1,63 @@
1
+ import React, { useMemo } from "react"
2
+ import { Block, useStyletron } 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
+ // TODO: Implement icon in Clay
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
+ Content: {
55
+ style: {
56
+ minHeight: theme.sizing.scale1200,
57
+ },
58
+ },
59
+ }}
60
+ />
61
+ </Block>
62
+ )
63
+ }
@@ -1,43 +1,34 @@
1
- import {
2
- Block,
3
- Button,
4
- LogOut01,
5
- Mats,
6
- ParagraphSmall,
7
- useStyletron,
8
- } from "@mezo-org/mezo-clay"
1
+ import { Block, Button, LogOut01, useStyletron } from "@mezo-org/mezo-clay"
9
2
  import React, { useCallback } from "react"
10
3
  import { useDisconnect } from "wagmi"
11
4
  import { useSignOut } from "../../../hooks"
12
- import { DropdownData } from "../../../hooks/useDropdownData"
13
5
  import WalletAddress from "./WalletAddress"
14
- import AccountAssets from "./AccountAssets"
15
6
  import AccountBalance from "./AccountBalance"
16
7
  import WelcomeBlock from "./WelcomeBlock"
17
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"
18
14
 
19
- function MatsnetLabel() {
20
- const [, theme] = useStyletron()
21
- return (
22
- <ParagraphSmall color={theme.colors.contentTertiary}>
23
- <Mats
24
- color="currentColor"
25
- size={theme.sizing.scale400}
26
- overrides={{
27
- Svg: {
28
- style: {
29
- marginRight: theme.sizing.scale300,
30
- },
31
- },
32
- }}
33
- />
34
- Matsnet Assets
35
- </ParagraphSmall>
36
- )
37
- }
38
-
39
- type RootProps = DropdownData & {
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
40
30
  onSignOut?: () => void
31
+ onOtherAssetsClick?: () => void
41
32
  }
42
33
 
43
34
  export default function Root(props: RootProps) {
@@ -46,10 +37,15 @@ export default function Root(props: RootProps) {
46
37
  walletAddress,
47
38
  accountAddress,
48
39
  walletType,
49
- totalBalanceInUsd,
50
- formattedNativeAssets,
51
- matsnet,
40
+ usdTotalBalance,
41
+ usdTroveDebt,
42
+ usdCollateral,
43
+ matsBalance,
44
+ assets,
45
+ otherAssetsCount,
46
+ otherAssetsUsdTotal,
52
47
  onSignOut,
48
+ onOtherAssetsClick,
53
49
  } = props
54
50
 
55
51
  const [, theme] = useStyletron()
@@ -67,13 +63,18 @@ export default function Root(props: RootProps) {
67
63
  disconnect()
68
64
  }, [signOut, disconnect, onSignOut])
69
65
 
66
+ const formattedMatsBalance = formatNumberToCompactString(matsBalance, 2)
67
+ const formattedUsdTotalBalance = formatUsd(usdTotalBalance)
68
+ const formattedUsdTroveDebt = formatUsd(usdTroveDebt)
69
+ const formattedUsdCollateral = formatUsd(usdCollateral)
70
+
70
71
  return (
71
72
  <Block
72
73
  display="inline-flex"
73
74
  flexDirection="column"
74
75
  padding={theme.sizing.scale600}
75
76
  >
76
- <WelcomeBlock mezoId={mezoId} matsBalance={matsnet.mats} />
77
+ <WelcomeBlock mezoId={mezoId} matsBalance={formattedMatsBalance} />
77
78
 
78
79
  <AccountAddressActions address={accountAddress} />
79
80
 
@@ -88,26 +89,31 @@ export default function Root(props: RootProps) {
88
89
  >
89
90
  <WalletAddress address={walletAddress} type={walletType} />
90
91
 
91
- <AccountBalance amount={totalBalanceInUsd} />
92
+ <AccountBalance
93
+ totalBalance={formattedUsdTotalBalance}
94
+ totalDebt={formattedUsdTroveDebt}
95
+ />
92
96
 
93
- <AccountAssets label="Assets" assets={formattedNativeAssets} />
94
- </Block>
97
+ <AccountAssetItem
98
+ type="BTC"
99
+ amount={assets.btc.formattedUsdBalance}
100
+ subLabel="Locked collateral"
101
+ subValue={formattedUsdCollateral}
102
+ />
95
103
 
96
- {matsnet.formattedAssets.length > 0 && (
97
- <Block
98
- marginTop={theme.sizing.scale600}
99
- backgroundColor={theme.colors.backgroundSecondary}
100
- overflow="hidden"
101
- overrides={{
102
- Block: { style: { borderRadius: theme.borders.radius300 } },
103
- }}
104
- >
105
- <AccountAssets
106
- label={<MatsnetLabel />}
107
- assets={matsnet.formattedAssets}
108
- />
109
- </Block>
110
- )}
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>
111
117
 
112
118
  <Block
113
119
  marginTop={theme.sizing.scale700}
@@ -27,7 +27,7 @@ export default function WalletAddress(props: WalletAddressProps) {
27
27
  )
28
28
  const trimmedAddress = trimAddress(address)
29
29
  const { icon: accountIcon } = getCryptoAsset(
30
- type === "bitcoin" ? "btc" : "eth",
30
+ type === "bitcoin" ? "BTC" : "ETH",
31
31
  )
32
32
 
33
33
  const [, theme] = useStyletron()
@@ -67,15 +67,15 @@ export default function WalletAddress(props: WalletAddressProps) {
67
67
  {isCopiedMessageVisible ? (
68
68
  <ParagraphSmall
69
69
  margin={0}
70
- marginLeft={theme.sizing.scale300}
71
- color={theme.colors.gray800}
70
+ marginLeft={theme.sizing.scale500}
71
+ color={theme.colors.contentPrimary}
72
72
  >
73
73
  Copied address to clipboard
74
74
  </ParagraphSmall>
75
75
  ) : (
76
76
  <Block
77
77
  as="a"
78
- marginLeft={theme.sizing.scale300}
78
+ marginLeft={theme.sizing.scale500}
79
79
  href={blockExplorerUrl}
80
80
  target="_blank"
81
81
  overrides={{
@@ -94,7 +94,7 @@ export default function WalletAddress(props: WalletAddressProps) {
94
94
  display="flex"
95
95
  alignItems="center"
96
96
  margin={0}
97
- color={theme.colors.gray800}
97
+ color={theme.colors.contentPrimary}
98
98
  >
99
99
  {trimmedAddress}
100
100
  <LinkIcon
@@ -104,7 +104,7 @@ export default function WalletAddress(props: WalletAddressProps) {
104
104
  Svg: {
105
105
  style: {
106
106
  stroke: "currentColor",
107
- marginLeft: theme.sizing.scale200,
107
+ marginLeft: theme.sizing.scale300,
108
108
  },
109
109
  },
110
110
  }}
@@ -114,11 +114,11 @@ export default function WalletAddress(props: WalletAddressProps) {
114
114
  )}
115
115
  <CopyIcon
116
116
  size={theme.sizing.scale550}
117
+ color={theme.colors.contentPrimary}
117
118
  overrides={{
118
119
  Svg: {
119
120
  style: {
120
121
  marginLeft: "auto",
121
- stroke: "currentColor",
122
122
  },
123
123
  },
124
124
  }}
@@ -74,16 +74,16 @@ export default function WelcomeBlock(props: WelcomeBlockProps) {
74
74
  overrides={{
75
75
  Block: {
76
76
  style: {
77
- gap: theme.sizing.scale300,
77
+ gap: theme.sizing.scale400,
78
78
  },
79
79
  },
80
80
  }}
81
81
  >
82
82
  <Mats
83
83
  color={theme.colors.contentPrimary}
84
- size={theme.sizing.scale600}
84
+ size={theme.sizing.scale500}
85
85
  />
86
- {matsBalance}
86
+ {matsBalance} mats
87
87
  </LabelSmall>
88
88
  </Block>
89
89
  </Block>
@@ -0,0 +1,32 @@
1
+ import React from "react"
2
+ import {
3
+ Block,
4
+ InfoCircle,
5
+ LabelSmall,
6
+ useStyletron,
7
+ } from "@mezo-org/mezo-clay"
8
+ import { usePassportContext } from "../../hooks/usePassportContext"
9
+
10
+ export default function TestnetTopBanner() {
11
+ const [, theme] = useStyletron()
12
+
13
+ const { environment } = usePassportContext()
14
+
15
+ if (environment !== "testnet") {
16
+ return null
17
+ }
18
+
19
+ return (
20
+ <Block
21
+ display="flex"
22
+ alignItems="center"
23
+ padding={`${theme.sizing.scale700} ${theme.sizing.scale600}`}
24
+ backgroundColor={theme.colors.warning}
25
+ >
26
+ <InfoCircle size={theme.sizing.scale550} />
27
+ <LabelSmall marginLeft={theme.sizing.scale500}>
28
+ You are using testnet funds.
29
+ </LabelSmall>
30
+ </Block>
31
+ )
32
+ }
package/src/config.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { http } from "viem"
2
2
  import { Chain, getDefaultConfig, WalletList } from "@rainbow-me/rainbowkit"
3
3
  import { Config, CreateConfigParameters } from "wagmi"
4
- import { CHAIN_ID, mezoMatsnetTestnet, RPC_BY_NETWORK } from "./constants"
4
+ import { CHAIN_ID, mezoTestnet, RPC_BY_NETWORK } from "./constants"
5
5
  import { getOKXWallet, getUnisatWallet, getXverseWallet } from "./wallet"
6
6
 
7
7
  type WagmiConfigParameters = Omit<
@@ -34,7 +34,7 @@ export const defaultConfig: Required<
34
34
  > = {
35
35
  transports,
36
36
  walletConnectProjectId: "",
37
- chains: [mezoMatsnetTestnet],
37
+ chains: [mezoTestnet],
38
38
  multiInjectedProviderDiscovery: true,
39
39
  }
40
40
 
package/src/constants.ts CHANGED
@@ -1,11 +1,12 @@
1
- import { mezoMatsnetTestnet } from "@mezo-org/orangekit"
1
+ import { mezoTestnet } from "@mezo-org/orangekit"
2
2
 
3
- export { mezoMatsnetTestnet } from "@mezo-org/orangekit"
3
+ export { mezoTestnet } from "@mezo-org/orangekit"
4
4
 
5
5
  export const CHAIN_ID = {
6
- testnet: mezoMatsnetTestnet.id,
6
+ testnet: mezoTestnet.id,
7
+ mainnet: undefined,
7
8
  }
8
9
 
9
10
  export const RPC_BY_NETWORK = {
10
- testnet: mezoMatsnetTestnet.rpcUrls.default.http[0],
11
+ testnet: mezoTestnet.rpcUrls.default.http[0],
11
12
  }
@@ -6,6 +6,7 @@ export {
6
6
  useSubscribeToConnectorEvent,
7
7
  useSubscribeToWalletNetworkDoesNotMatchProviderChain,
8
8
  } from "@mezo-org/orangekit"
9
+ export { useInvalidateBorrowData, useResetBorrowData } from "./useBorrowData"
9
10
  export * from "./useGetAccountByAddress"
10
11
  export * from "./useGetAccountByMezoId"
11
12
  export * from "./useGetCurrentAccount"
@@ -15,5 +16,9 @@ export * from "./useSignInWithDiscord"
15
16
  export * from "./useSignInWithWallet"
16
17
  export * from "./useSignOut"
17
18
  export * from "./useSignUpWithWallet"
19
+ export {
20
+ useInvalidateTokensBalances,
21
+ useResetTokensBalances,
22
+ } from "./useTokensBalances"
18
23
  export * from "./useUpdateMezoId"
19
24
  export * from "./useRefreshPassport"