@mezo-org/passport 0.15.0 → 0.15.1-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 (115) hide show
  1. package/dist/src/hooks/useAuthenticateWithWallet.d.ts +11 -11
  2. package/dist/src/hooks/useSignInWithWallet.d.ts +11 -11
  3. package/dist/src/hooks/useSignUpWithWallet.d.ts +11 -11
  4. package/dist/src/index.d.ts +0 -1
  5. package/dist/src/index.d.ts.map +1 -1
  6. package/dist/src/index.js +0 -1
  7. package/dist/src/index.js.map +1 -1
  8. package/package.json +1 -2
  9. package/src/index.ts +0 -1
  10. package/dist/src/assets/DefaultAvatar.d.ts +0 -5
  11. package/dist/src/assets/DefaultAvatar.d.ts.map +0 -1
  12. package/dist/src/assets/DefaultAvatar.js +0 -21
  13. package/dist/src/assets/DefaultAvatar.js.map +0 -1
  14. package/dist/src/components/Dropdown/ConnectedTrigger.d.ts +0 -8
  15. package/dist/src/components/Dropdown/ConnectedTrigger.d.ts.map +0 -1
  16. package/dist/src/components/Dropdown/ConnectedTrigger.js +0 -39
  17. package/dist/src/components/Dropdown/ConnectedTrigger.js.map +0 -1
  18. package/dist/src/components/Dropdown/Content.d.ts +0 -8
  19. package/dist/src/components/Dropdown/Content.d.ts.map +0 -1
  20. package/dist/src/components/Dropdown/Content.js +0 -27
  21. package/dist/src/components/Dropdown/Content.js.map +0 -1
  22. package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts +0 -7
  23. package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts.map +0 -1
  24. package/dist/src/components/Dropdown/DisconnectedTrigger.js +0 -13
  25. package/dist/src/components/Dropdown/DisconnectedTrigger.js.map +0 -1
  26. package/dist/src/components/Dropdown/Dropdown.d.ts +0 -23
  27. package/dist/src/components/Dropdown/Dropdown.d.ts.map +0 -1
  28. package/dist/src/components/Dropdown/Dropdown.js +0 -45
  29. package/dist/src/components/Dropdown/Dropdown.js.map +0 -1
  30. package/dist/src/components/Dropdown/ListingItem.d.ts +0 -14
  31. package/dist/src/components/Dropdown/ListingItem.d.ts.map +0 -1
  32. package/dist/src/components/Dropdown/ListingItem.js +0 -42
  33. package/dist/src/components/Dropdown/ListingItem.js.map +0 -1
  34. package/dist/src/components/Dropdown/NestedViewLayout.d.ts +0 -8
  35. package/dist/src/components/Dropdown/NestedViewLayout.d.ts.map +0 -1
  36. package/dist/src/components/Dropdown/NestedViewLayout.js +0 -32
  37. package/dist/src/components/Dropdown/NestedViewLayout.js.map +0 -1
  38. package/dist/src/components/Dropdown/Receive/Receive.d.ts +0 -4
  39. package/dist/src/components/Dropdown/Receive/Receive.d.ts.map +0 -1
  40. package/dist/src/components/Dropdown/Receive/Receive.js +0 -64
  41. package/dist/src/components/Dropdown/Receive/Receive.js.map +0 -1
  42. package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts +0 -4
  43. package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts.map +0 -1
  44. package/dist/src/components/Dropdown/Root/AccountAddressActions.js +0 -49
  45. package/dist/src/components/Dropdown/Root/AccountAddressActions.js.map +0 -1
  46. package/dist/src/components/Dropdown/Root/AccountBalance.d.ts +0 -6
  47. package/dist/src/components/Dropdown/Root/AccountBalance.d.ts.map +0 -1
  48. package/dist/src/components/Dropdown/Root/AccountBalance.js +0 -32
  49. package/dist/src/components/Dropdown/Root/AccountBalance.js.map +0 -1
  50. package/dist/src/components/Dropdown/Root/AccountBtcListing.d.ts +0 -6
  51. package/dist/src/components/Dropdown/Root/AccountBtcListing.d.ts.map +0 -1
  52. package/dist/src/components/Dropdown/Root/AccountBtcListing.js +0 -28
  53. package/dist/src/components/Dropdown/Root/AccountBtcListing.js.map +0 -1
  54. package/dist/src/components/Dropdown/Root/AccountError.d.ts +0 -8
  55. package/dist/src/components/Dropdown/Root/AccountError.d.ts.map +0 -1
  56. package/dist/src/components/Dropdown/Root/AccountError.js +0 -17
  57. package/dist/src/components/Dropdown/Root/AccountError.js.map +0 -1
  58. package/dist/src/components/Dropdown/Root/AccountMusdListing.d.ts +0 -4
  59. package/dist/src/components/Dropdown/Root/AccountMusdListing.d.ts.map +0 -1
  60. package/dist/src/components/Dropdown/Root/AccountMusdListing.js +0 -21
  61. package/dist/src/components/Dropdown/Root/AccountMusdListing.js.map +0 -1
  62. package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts +0 -8
  63. package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts.map +0 -1
  64. package/dist/src/components/Dropdown/Root/AccountOtherAssets.js +0 -43
  65. package/dist/src/components/Dropdown/Root/AccountOtherAssets.js.map +0 -1
  66. package/dist/src/components/Dropdown/Root/Root.d.ts +0 -8
  67. package/dist/src/components/Dropdown/Root/Root.d.ts.map +0 -1
  68. package/dist/src/components/Dropdown/Root/Root.js +0 -45
  69. package/dist/src/components/Dropdown/Root/Root.js.map +0 -1
  70. package/dist/src/components/Dropdown/Root/WalletAddress.d.ts +0 -4
  71. package/dist/src/components/Dropdown/Root/WalletAddress.d.ts.map +0 -1
  72. package/dist/src/components/Dropdown/Root/WalletAddress.js +0 -66
  73. package/dist/src/components/Dropdown/Root/WalletAddress.js.map +0 -1
  74. package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts +0 -6
  75. package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts.map +0 -1
  76. package/dist/src/components/Dropdown/Root/WelcomeBlock.js +0 -88
  77. package/dist/src/components/Dropdown/Root/WelcomeBlock.js.map +0 -1
  78. package/dist/src/components/Dropdown/SlotNumber.d.ts +0 -19
  79. package/dist/src/components/Dropdown/SlotNumber.d.ts.map +0 -1
  80. package/dist/src/components/Dropdown/SlotNumber.js +0 -67
  81. package/dist/src/components/Dropdown/SlotNumber.js.map +0 -1
  82. package/dist/src/components/Dropdown/TestnetTopBanner.d.ts +0 -3
  83. package/dist/src/components/Dropdown/TestnetTopBanner.d.ts.map +0 -1
  84. package/dist/src/components/Dropdown/TestnetTopBanner.js +0 -14
  85. package/dist/src/components/Dropdown/TestnetTopBanner.js.map +0 -1
  86. package/dist/src/components/Dropdown/index.d.ts +0 -3
  87. package/dist/src/components/Dropdown/index.d.ts.map +0 -1
  88. package/dist/src/components/Dropdown/index.js +0 -2
  89. package/dist/src/components/Dropdown/index.js.map +0 -1
  90. package/dist/src/components/index.d.ts +0 -2
  91. package/dist/src/components/index.d.ts.map +0 -1
  92. package/dist/src/components/index.js +0 -2
  93. package/dist/src/components/index.js.map +0 -1
  94. package/src/assets/DefaultAvatar.tsx +0 -74
  95. package/src/components/Dropdown/ConnectedTrigger.tsx +0 -76
  96. package/src/components/Dropdown/Content.tsx +0 -53
  97. package/src/components/Dropdown/DisconnectedTrigger.tsx +0 -36
  98. package/src/components/Dropdown/Dropdown.tsx +0 -100
  99. package/src/components/Dropdown/ListingItem.tsx +0 -176
  100. package/src/components/Dropdown/NestedViewLayout.tsx +0 -87
  101. package/src/components/Dropdown/README.md +0 -41
  102. package/src/components/Dropdown/Receive/Receive.tsx +0 -144
  103. package/src/components/Dropdown/Root/AccountAddressActions.tsx +0 -99
  104. package/src/components/Dropdown/Root/AccountBalance.tsx +0 -69
  105. package/src/components/Dropdown/Root/AccountBtcListing.tsx +0 -53
  106. package/src/components/Dropdown/Root/AccountError.tsx +0 -34
  107. package/src/components/Dropdown/Root/AccountMusdListing.tsx +0 -45
  108. package/src/components/Dropdown/Root/AccountOtherAssets.tsx +0 -85
  109. package/src/components/Dropdown/Root/Root.tsx +0 -77
  110. package/src/components/Dropdown/Root/WalletAddress.tsx +0 -123
  111. package/src/components/Dropdown/Root/WelcomeBlock.tsx +0 -173
  112. package/src/components/Dropdown/SlotNumber.tsx +0 -131
  113. package/src/components/Dropdown/TestnetTopBanner.tsx +0 -32
  114. package/src/components/Dropdown/index.ts +0 -2
  115. package/src/components/index.ts +0 -1
@@ -1,176 +0,0 @@
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
- }
@@ -1,87 +0,0 @@
1
- import {
2
- ArrowLeft,
3
- Block,
4
- BlockProps,
5
- ButtonIcon,
6
- HeadingSmall,
7
- useStyletron,
8
- } from "@mezo-org/mezo-clay"
9
- import React, { ReactNode, useCallback } from "react"
10
- import useDropdownStore, { DropdownView } from "../../stores/dropdownStore"
11
-
12
- const getHeaderTitle = (view: DropdownView) => {
13
- const titleMap: Partial<Record<DropdownView, string>> = {
14
- [DropdownView.RECEIVE]: "Scan to receive",
15
- }
16
- return titleMap[view]!
17
- }
18
-
19
- type NestedViewLayoutProps = {
20
- children: ReactNode
21
- } & BlockProps
22
-
23
- function NestedViewLayout(props: NestedViewLayoutProps) {
24
- const { children, ...restProps } = props
25
-
26
- const currentView = useDropdownStore((state) => state.view)
27
- const setView = useDropdownStore((state) => state.setView)
28
-
29
- const [, theme] = useStyletron()
30
-
31
- const handleOnButtonClick = useCallback(() => {
32
- setView(DropdownView.ROOT)
33
- }, [setView])
34
-
35
- return (
36
- <Block
37
- display="flex"
38
- flexDirection="column"
39
- minHeight="588px"
40
- {...restProps}
41
- >
42
- <Block
43
- display="flex"
44
- alignItems="center"
45
- padding={theme.sizing.scale100}
46
- paddingTop={theme.sizing.scale800}
47
- paddingBottom={theme.sizing.scale500}
48
- marginBottom={theme.sizing.scale300}
49
- overrides={{
50
- Block: {
51
- style: {
52
- gap: theme.sizing.scale300,
53
- },
54
- },
55
- }}
56
- >
57
- <ButtonIcon
58
- onClick={handleOnButtonClick}
59
- shape="circle"
60
- size="medium"
61
- kind="tertiary"
62
- >
63
- <ArrowLeft />
64
- </ButtonIcon>
65
-
66
- <HeadingSmall
67
- marginTop={theme.sizing.scale300}
68
- marginBottom={theme.sizing.scale300}
69
- >
70
- {getHeaderTitle(currentView)}
71
- </HeadingSmall>
72
- </Block>
73
-
74
- <Block
75
- display="flex"
76
- flexDirection="column"
77
- padding={theme.sizing.scale600}
78
- paddingTop={0}
79
- flex={1}
80
- >
81
- {children}
82
- </Block>
83
- </Block>
84
- )
85
- }
86
-
87
- export default NestedViewLayout
@@ -1,41 +0,0 @@
1
- # Passport Dropdown component
2
-
3
- This component is a layer of interaction with Passport API in form of Dropdown
4
- component. It allows to establish the session and interact with the API.
5
-
6
- ## Props
7
-
8
- - `onSignIn` (`() => void`) - The callback to be executed on trigger click when
9
- the state is disconnected. It's optional since by default it triggers the
10
- [Rainbow Kit's wallet connection modal](https://www.rainbowkit.com/docs/modal-hooks).
11
- If the callback is not provided it will automatically establish the Passport
12
- Session. If not, you have to handle it manually using `useSignInWithWallet`
13
- hook. - **optional**
14
- - `onSignOut` (`() => void`) - The callback to be executed on click of the
15
- **Sign out** button. It's optional since by default it disconnects the current
16
- wallet connector and closes the Passport session. - **optional**
17
- - `triggerProps.signedIn` (`ButtonProps`) - Props to be passed to the trigger
18
- button in signed-in state.
19
- - `triggerProps.signedOut` (`ButtonProps`) - Props to be passed to the trigger
20
- button in signed-out state
21
-
22
- Besides that, component allows
23
- [Clay's `StatefulPopover` props](https://baseweb.design/components/popover/)
24
- excluding the `children` and `content`.
25
-
26
- ## Overview
27
-
28
- The component has two distinguishable states - disconnected and connected. In
29
- disconnected state the component offers the trigger to initiate the connection
30
- flow. It can be fully customizable by providing your own one. As long as it's
31
- compliant with Wagmi/RainbowKit it will work. Component will automatically
32
- detect connected connector and change the state of component displaying the
33
- avatar thumbnail instead of button.
34
-
35
- Component has the following features:
36
-
37
- - displays wallet address that can be copied,
38
- - displays total balance in USD,
39
- - displays partial balances per asset with token amounts and USD conversions,
40
- - serves _Log out_ button which disconnects the wallet connector and closes
41
- Passport API session.
@@ -1,144 +0,0 @@
1
- import {
2
- Block,
3
- Button,
4
- LabelLarge,
5
- MezoCircle,
6
- MonoLabelXSmall,
7
- ParagraphSmall,
8
- useStyletron,
9
- } from "@mezo-org/mezo-clay"
10
- import React, { useState } from "react"
11
- import { useCopyToClipboard } from "usehooks-ts"
12
- import { QRCodeSVG } from "qrcode.react"
13
- import NestedViewLayout from "../NestedViewLayout"
14
- import { getAddressExplorerUrl } from "../../../utils/address"
15
- import { usePassportContext } from "../../../hooks/usePassportContext"
16
- import useWalletAccount from "../../../hooks/useWalletAccount"
17
-
18
- function Receive() {
19
- const { environment } = usePassportContext()
20
-
21
- const walletAccount = useWalletAccount()
22
-
23
- const [, theme] = useStyletron()
24
-
25
- const [, copy] = useCopyToClipboard()
26
-
27
- const [isCopiedMessageVisible, setIsCopiedMessageVisible] = useState(false)
28
-
29
- const handleCopyAddress = () => {
30
- copy(walletAccount.accountAddress!)
31
- setIsCopiedMessageVisible(true)
32
-
33
- setTimeout(() => {
34
- setIsCopiedMessageVisible(false)
35
- }, 2000)
36
- }
37
-
38
- const blockExplorerUrl = getAddressExplorerUrl(
39
- walletAccount.accountAddress!,
40
- "mezo",
41
- environment === "testnet",
42
- )
43
-
44
- return (
45
- <NestedViewLayout>
46
- <LabelLarge>Your Mezo Address</LabelLarge>
47
-
48
- <ParagraphSmall
49
- marginTop={0}
50
- marginBottom={theme.sizing.scale800}
51
- color={theme.colors.contentTertiary}
52
- >
53
- {walletAccount.networkFamily === "bitcoin" ? (
54
- <>
55
- Mezo automatically created a smart account that&apos;s fully
56
- controlled by your connected Bitcoin wallet. Use this address to
57
- receive assets on Mezo.
58
- </>
59
- ) : (
60
- <>
61
- Your connected wallet address is your Mezo address. Use this address
62
- to receive assets on Mezo.
63
- </>
64
- )}
65
- </ParagraphSmall>
66
-
67
- <Block
68
- as={QRCodeSVG}
69
- value={walletAccount.accountAddress!}
70
- flex={1}
71
- overrides={{
72
- Block: {
73
- style: {
74
- aspectRatio: 1,
75
- width: "fit-content",
76
- margin: "0 auto",
77
- },
78
- },
79
- }}
80
- />
81
-
82
- <Block
83
- display="flex"
84
- alignItems="center"
85
- backgroundColor={theme.colors.backgroundSecondary}
86
- marginTop={theme.sizing.scale800}
87
- marginBottom={theme.sizing.scale600}
88
- padding={theme.sizing.scale300}
89
- overrides={{
90
- Block: {
91
- style: {
92
- gap: theme.sizing.scale300,
93
- borderRadius: theme.borders.radius400,
94
- },
95
- },
96
- }}
97
- >
98
- <MezoCircle
99
- size={theme.sizing.scale700}
100
- color={theme.colors.accent}
101
- symbolColor={theme.colors.white}
102
- overrides={{
103
- Svg: {
104
- style: {
105
- backgroundColor: theme.colors.accent,
106
- overflow: "hidden",
107
- borderRadius: theme.borders.radius200,
108
- flexShrink: 0,
109
- },
110
- },
111
- }}
112
- />
113
-
114
- <MonoLabelXSmall>{walletAccount.accountAddress}</MonoLabelXSmall>
115
- </Block>
116
-
117
- <Button
118
- onClick={handleCopyAddress}
119
- size="medium"
120
- overrides={{
121
- BaseButton: {
122
- style: {
123
- marginBottom: theme.sizing.scale500,
124
- },
125
- },
126
- }}
127
- >
128
- {isCopiedMessageVisible ? "Copied!" : "Copy Mezo address"}
129
- </Button>
130
-
131
- <Button
132
- kind="secondary"
133
- size="medium"
134
- $as="a"
135
- href={blockExplorerUrl}
136
- target="_blank"
137
- >
138
- View Mezo explorer
139
- </Button>
140
- </NestedViewLayout>
141
- )
142
- }
143
-
144
- export default Receive
@@ -1,99 +0,0 @@
1
- import {
2
- ArrowNarrowLeft,
3
- Block,
4
- BlockProps,
5
- Button,
6
- ButtonProps,
7
- mergeOverrides,
8
- useStyletron,
9
- } from "@mezo-org/mezo-clay"
10
- import React from "react"
11
- import { usePassportContext } from "../../../hooks/usePassportContext"
12
- import { getAddressExplorerUrl } from "../../../utils/address"
13
- import useDropdownStore, { DropdownView } from "../../../stores/dropdownStore"
14
- import useWalletAccount from "../../../hooks/useWalletAccount"
15
-
16
- const buttonStartEnhancerSize = 12
17
-
18
- const commonButtonProps: Partial<ButtonProps> = {
19
- kind: "secondary",
20
- size: "small",
21
- shape: "pill",
22
- overrides: {
23
- BaseButton: {
24
- style: {
25
- flex: 1,
26
- },
27
- },
28
- StartEnhancer: {
29
- style: {
30
- stroke: "currentColor",
31
- },
32
- },
33
- },
34
- }
35
-
36
- export default function AccountAddressActions(props: BlockProps) {
37
- const { overrides, ...restProps } = props
38
-
39
- const [, theme] = useStyletron()
40
- const { environment } = usePassportContext()
41
- const setDropdownView = useDropdownStore((state) => state.setView)
42
- const handleReceiveClick = () => setDropdownView(DropdownView.RECEIVE)
43
-
44
- const walletAccount = useWalletAccount()
45
-
46
- const blockExplorerUrl = getAddressExplorerUrl(
47
- walletAccount.accountAddress!,
48
- "mezo",
49
- environment === "testnet",
50
- )
51
-
52
- return (
53
- <Block
54
- display="flex"
55
- alignItems="center"
56
- backgroundColor="transparent"
57
- padding={`0 ${theme.sizing.scale600} ${theme.sizing.scale800}`}
58
- overrides={mergeOverrides(
59
- {
60
- Block: {
61
- style: {
62
- gap: theme.sizing.scale600,
63
- },
64
- },
65
- },
66
- overrides,
67
- )}
68
- {...restProps}
69
- >
70
- <Button
71
- onClick={handleReceiveClick}
72
- startEnhancer={
73
- <ArrowNarrowLeft
74
- size={buttonStartEnhancerSize}
75
- overrides={{
76
- Svg: {
77
- style: {
78
- transform: "rotate(-45deg)",
79
- },
80
- },
81
- }}
82
- />
83
- }
84
- {...commonButtonProps}
85
- >
86
- Receive
87
- </Button>
88
-
89
- <Button
90
- $as="a"
91
- href={blockExplorerUrl}
92
- target="_blank"
93
- {...commonButtonProps}
94
- >
95
- Block Explorer
96
- </Button>
97
- </Block>
98
- )
99
- }
@@ -1,69 +0,0 @@
1
- import React from "react"
2
- import { BlockProps, useStyletron } from "@mezo-org/mezo-clay"
3
- import { formatUnits } from "viem"
4
- import ListingItem from "../ListingItem"
5
- import { useTokensBalances } from "../../../hooks/useTokensBalances"
6
- import { useBorrowData } from "../../../hooks/useBorrowData"
7
- import AccountError from "./AccountError"
8
- import { CONVERSION_RATE_DECIMALS } from "../../../hooks/useAssetsConversionRates"
9
- import { usePassportContext } from "../../../hooks/usePassportContext"
10
-
11
- type AccountBalanceProps = Omit<BlockProps, "children">
12
-
13
- export default function AccountBalance(props: AccountBalanceProps) {
14
- const { overrides, ...restProps } = props
15
- const [, theme] = useStyletron()
16
- const { nativeBalanceRefetchInterval } = usePassportContext()
17
-
18
- const {
19
- data: tokensBalancesData,
20
- isError: isTokensBalancesError,
21
- isPending: isTokensBalancesDataPending,
22
- } = useTokensBalances({
23
- queryOptions: {
24
- staleTime: nativeBalanceRefetchInterval,
25
- refetchInterval: nativeBalanceRefetchInterval,
26
- },
27
- })
28
- const {
29
- data: borrowData,
30
- isError: isBorrowDataError,
31
- isPending: isBorrowDataPending,
32
- } = useBorrowData()
33
-
34
- if (isTokensBalancesDataPending || isBorrowDataPending) {
35
- return <ListingItem isLoading overrides={overrides} />
36
- }
37
-
38
- if (isTokensBalancesError || isBorrowDataError) {
39
- return (
40
- <AccountError
41
- padding={`${theme.sizing.scale500} ${theme.sizing.scale800}`}
42
- topic="account balance"
43
- overrides={overrides}
44
- />
45
- )
46
- }
47
-
48
- const totalBalanceInUsd = Object.values(tokensBalancesData).reduce(
49
- (acc, tokenBalance) => acc + tokenBalance.usd.value,
50
- 0n,
51
- )
52
-
53
- const totalBalanceNumber = Number(
54
- formatUnits(totalBalanceInUsd, CONVERSION_RATE_DECIMALS),
55
- )
56
-
57
- const totalDebtNumber = Number(borrowData.debtInUsd.formatted)
58
-
59
- return (
60
- <ListingItem
61
- label="Total assets"
62
- value={totalBalanceNumber}
63
- subLabel="Total liabilities"
64
- subValue={totalDebtNumber}
65
- overrides={overrides}
66
- {...restProps}
67
- />
68
- )
69
- }
@@ -1,53 +0,0 @@
1
- import React from "react"
2
- import { BitcoinCircle, BlockProps } from "@mezo-org/mezo-clay"
3
- import ListingItem from "../ListingItem"
4
- import { getAsset } from "../../../utils/assets"
5
- import { useBorrowData } from "../../../hooks/useBorrowData"
6
- import { useTokensBalances } from "../../../hooks/useTokensBalances"
7
- import AccountError from "./AccountError"
8
- import { usePassportContext } from "../../../hooks/usePassportContext"
9
-
10
- type AccountBTCListingProps = Omit<BlockProps, "children">
11
-
12
- export default function AccountBTCListing(props: AccountBTCListingProps) {
13
- const { nativeBalanceRefetchInterval } = usePassportContext()
14
-
15
- const {
16
- data: borrowData,
17
- isError: isBorrowDataError,
18
- isPending: isBorrowDataPending,
19
- } = useBorrowData()
20
-
21
- const {
22
- data: tokensBalancesData,
23
- isError: isTokensBalancesError,
24
- isPending: isTokensBalancesPending,
25
- } = useTokensBalances({
26
- queryOptions: {
27
- staleTime: nativeBalanceRefetchInterval,
28
- refetchInterval: nativeBalanceRefetchInterval,
29
- },
30
- })
31
-
32
- if (isTokensBalancesPending || isBorrowDataPending) {
33
- return <ListingItem isLoading />
34
- }
35
-
36
- if (isTokensBalancesError || isBorrowDataError) {
37
- return <AccountError topic="Bitcoin balance" />
38
- }
39
-
40
- const btcBalance = Number(tokensBalancesData.BTC.usd.formatted)
41
- const lockedCollateral = Number(borrowData.collateral.usd.formatted)
42
-
43
- return (
44
- <ListingItem
45
- icon={<BitcoinCircle />}
46
- label={getAsset("BTC").name}
47
- value={btcBalance}
48
- subLabel="Locked collateral"
49
- subValue={lockedCollateral}
50
- {...props}
51
- />
52
- )
53
- }
@@ -1,34 +0,0 @@
1
- import React from "react"
2
- import {
3
- BlockProps,
4
- LabelSmall,
5
- mergeOverrides,
6
- useStyletron,
7
- } from "@mezo-org/mezo-clay"
8
-
9
- type AccountErrorProps = {
10
- topic: string
11
- } & BlockProps
12
-
13
- export default function AccountError(props: AccountErrorProps) {
14
- const { topic, overrides, ...restProps } = props
15
-
16
- const [, theme] = useStyletron()
17
-
18
- return (
19
- <LabelSmall
20
- padding={`${theme.sizing.scale600} ${theme.sizing.scale800}`}
21
- color="negative"
22
- overrides={mergeOverrides(overrides, {
23
- Block: {
24
- style: {
25
- lineHeight: theme.sizing.scale700,
26
- },
27
- },
28
- })}
29
- {...restProps}
30
- >
31
- An error occured loading {topic}.
32
- </LabelSmall>
33
- )
34
- }