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

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 (76) hide show
  1. package/dist/src/components/Dropdown/Content.d.ts +3 -3
  2. package/dist/src/components/Dropdown/Content.d.ts.map +1 -1
  3. package/dist/src/components/Dropdown/Content.js +16 -60
  4. package/dist/src/components/Dropdown/Content.js.map +1 -1
  5. package/dist/src/components/Dropdown/Dropdown.js +1 -1
  6. package/dist/src/components/Dropdown/Dropdown.js.map +1 -1
  7. package/dist/src/components/Dropdown/NestedViewLayout.d.ts +7 -0
  8. package/dist/src/components/Dropdown/NestedViewLayout.d.ts.map +1 -0
  9. package/dist/src/components/Dropdown/NestedViewLayout.js +34 -0
  10. package/dist/src/components/Dropdown/NestedViewLayout.js.map +1 -0
  11. package/dist/src/components/Dropdown/Receive/Receive.d.ts +7 -0
  12. package/dist/src/components/Dropdown/Receive/Receive.d.ts.map +1 -0
  13. package/dist/src/components/Dropdown/Receive/Receive.js +53 -0
  14. package/dist/src/components/Dropdown/Receive/Receive.js.map +1 -0
  15. package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts +7 -0
  16. package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts.map +1 -0
  17. package/dist/src/components/Dropdown/Root/AccountAddressActions.js +48 -0
  18. package/dist/src/components/Dropdown/Root/AccountAddressActions.js.map +1 -0
  19. package/dist/src/components/Dropdown/{AccountAssets.d.ts → Root/AccountAssets.d.ts} +1 -1
  20. package/dist/src/components/Dropdown/Root/AccountAssets.d.ts.map +1 -0
  21. package/dist/src/components/Dropdown/{AccountAssets.js → Root/AccountAssets.js} +1 -1
  22. package/dist/src/components/Dropdown/Root/AccountAssets.js.map +1 -0
  23. package/dist/src/components/Dropdown/Root/AccountBalance.d.ts.map +1 -0
  24. package/dist/src/components/Dropdown/Root/AccountBalance.js.map +1 -0
  25. package/dist/src/components/Dropdown/Root/Root.d.ts +8 -0
  26. package/dist/src/components/Dropdown/Root/Root.d.ts.map +1 -0
  27. package/dist/src/components/Dropdown/Root/Root.js +64 -0
  28. package/dist/src/components/Dropdown/Root/Root.js.map +1 -0
  29. package/dist/src/components/Dropdown/Root/WalletAddress.d.ts +8 -0
  30. package/dist/src/components/Dropdown/Root/WalletAddress.d.ts.map +1 -0
  31. package/dist/src/components/Dropdown/{AccountAddress.js → Root/WalletAddress.js} +5 -6
  32. package/dist/src/components/Dropdown/Root/WalletAddress.js.map +1 -0
  33. package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts.map +1 -0
  34. package/dist/src/components/Dropdown/{WelcomeBlock.js → Root/WelcomeBlock.js} +1 -1
  35. package/dist/src/components/Dropdown/Root/WelcomeBlock.js.map +1 -0
  36. package/dist/src/hooks/useDropdownData.d.ts +2 -1
  37. package/dist/src/hooks/useDropdownData.d.ts.map +1 -1
  38. package/dist/src/hooks/useDropdownData.js +5 -3
  39. package/dist/src/hooks/useDropdownData.js.map +1 -1
  40. package/dist/src/stores/dropdownStore.d.ts +12 -0
  41. package/dist/src/stores/dropdownStore.d.ts.map +1 -0
  42. package/dist/src/stores/dropdownStore.js +13 -0
  43. package/dist/src/stores/dropdownStore.js.map +1 -0
  44. package/dist/src/utils/address.d.ts +1 -1
  45. package/dist/src/utils/address.d.ts.map +1 -1
  46. package/dist/src/utils/address.js +2 -0
  47. package/dist/src/utils/address.js.map +1 -1
  48. package/dist/src/utils/address.test.js +8 -0
  49. package/dist/src/utils/address.test.js.map +1 -1
  50. package/package.json +4 -2
  51. package/src/components/Dropdown/Content.tsx +32 -118
  52. package/src/components/Dropdown/Dropdown.tsx +1 -1
  53. package/src/components/Dropdown/NestedViewLayout.tsx +75 -0
  54. package/src/components/Dropdown/Receive/Receive.tsx +119 -0
  55. package/src/components/Dropdown/Root/AccountAddressActions.tsx +101 -0
  56. package/src/components/Dropdown/{AccountAssets.tsx → Root/AccountAssets.tsx} +1 -1
  57. package/src/components/Dropdown/Root/Root.tsx +141 -0
  58. package/src/components/Dropdown/{AccountAddress.tsx → Root/WalletAddress.tsx} +5 -7
  59. package/src/components/Dropdown/{WelcomeBlock.tsx → Root/WelcomeBlock.tsx} +1 -1
  60. package/src/hooks/useDropdownData.ts +14 -4
  61. package/src/stores/dropdownStore.ts +20 -0
  62. package/src/utils/address.test.ts +10 -0
  63. package/src/utils/address.ts +5 -3
  64. package/dist/src/components/Dropdown/AccountAddress.d.ts +0 -8
  65. package/dist/src/components/Dropdown/AccountAddress.d.ts.map +0 -1
  66. package/dist/src/components/Dropdown/AccountAddress.js.map +0 -1
  67. package/dist/src/components/Dropdown/AccountAssets.d.ts.map +0 -1
  68. package/dist/src/components/Dropdown/AccountAssets.js.map +0 -1
  69. package/dist/src/components/Dropdown/AccountBalance.d.ts.map +0 -1
  70. package/dist/src/components/Dropdown/AccountBalance.js.map +0 -1
  71. package/dist/src/components/Dropdown/WelcomeBlock.d.ts.map +0 -1
  72. package/dist/src/components/Dropdown/WelcomeBlock.js.map +0 -1
  73. /package/dist/src/components/Dropdown/{AccountBalance.d.ts → Root/AccountBalance.d.ts} +0 -0
  74. /package/dist/src/components/Dropdown/{AccountBalance.js → Root/AccountBalance.js} +0 -0
  75. /package/dist/src/components/Dropdown/{WelcomeBlock.d.ts → Root/WelcomeBlock.d.ts} +0 -0
  76. /package/src/components/Dropdown/{AccountBalance.tsx → Root/AccountBalance.tsx} +0 -0
@@ -0,0 +1,12 @@
1
+ export declare enum DropdownView {
2
+ ROOT = "ROOT",
3
+ RECEIVE = "RECEIVE"
4
+ }
5
+ interface DropdownStore {
6
+ view: DropdownView;
7
+ setView: (view: DropdownView) => void;
8
+ isNestedView: () => boolean;
9
+ }
10
+ declare const useDropdownStore: import("zustand").UseBoundStore<import("zustand").StoreApi<DropdownStore>>;
11
+ export default useDropdownStore;
12
+ //# sourceMappingURL=dropdownStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dropdownStore.d.ts","sourceRoot":"","sources":["../../../src/stores/dropdownStore.ts"],"names":[],"mappings":"AAEA,oBAAY,YAAY;IACtB,IAAI,SAAS;IACb,OAAO,YAAY;CACpB;AAED,UAAU,aAAa;IACrB,IAAI,EAAE,YAAY,CAAA;IAClB,OAAO,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAA;IACrC,YAAY,EAAE,MAAM,OAAO,CAAA;CAC5B;AAED,QAAA,MAAM,gBAAgB,4EAInB,CAAA;AAEH,eAAe,gBAAgB,CAAA"}
@@ -0,0 +1,13 @@
1
+ import { create } from "zustand";
2
+ export var DropdownView;
3
+ (function (DropdownView) {
4
+ DropdownView["ROOT"] = "ROOT";
5
+ DropdownView["RECEIVE"] = "RECEIVE";
6
+ })(DropdownView || (DropdownView = {}));
7
+ const useDropdownStore = create((set, get) => ({
8
+ view: DropdownView.ROOT,
9
+ setView: (view) => set({ view }),
10
+ isNestedView: () => get().view !== DropdownView.ROOT,
11
+ }));
12
+ export default useDropdownStore;
13
+ //# sourceMappingURL=dropdownStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dropdownStore.js","sourceRoot":"","sources":["../../../src/stores/dropdownStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEhC,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,6BAAa,CAAA;IACb,mCAAmB,CAAA;AACrB,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB;AAQD,MAAM,gBAAgB,GAAG,MAAM,CAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;IAC5D,IAAI,EAAE,YAAY,CAAC,IAAI;IACvB,OAAO,EAAE,CAAC,IAAkB,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC;IAC9C,YAAY,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,IAAI,KAAK,YAAY,CAAC,IAAI;CACrD,CAAC,CAAC,CAAA;AAEH,eAAe,gBAAgB,CAAA"}
@@ -11,5 +11,5 @@ export declare function trimAddress(address: string): string;
11
11
  * @param isTestnet - Whether the address is on testnet.
12
12
  * @returns The URL of the block explorer page for the address.
13
13
  */
14
- export declare function getAddressExplorerUrl(address: string, chainType: "bitcoin" | "evm", isTestnet: boolean): string;
14
+ export declare function getAddressExplorerUrl(address: string, chainType: "bitcoin" | "evm" | "mezo", isTestnet: boolean): string;
15
15
  //# sourceMappingURL=address.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../../src/utils/address.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMnD;AAYD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,SAAS,GAAG,KAAK,EAC5B,SAAS,EAAE,OAAO,UASnB"}
1
+ {"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../../src/utils/address.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMnD;AAcD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,SAAS,GAAG,KAAK,GAAG,MAAM,EACrC,SAAS,EAAE,OAAO,UASnB"}
@@ -12,10 +12,12 @@ export function trimAddress(address) {
12
12
  const MAINNET_EXPLORER_URLS = {
13
13
  bitcoin: "https://mempool.space",
14
14
  evm: "https://etherscan.io",
15
+ mezo: "https://explorer.mezo.org",
15
16
  };
16
17
  const TESTNET_EXPLORER_URLS = {
17
18
  bitcoin: "https://mempool.space/testnet",
18
19
  evm: "https://sepolia.etherscan.io",
20
+ mezo: "https://explorer.test.mezo.org",
19
21
  };
20
22
  /**
21
23
  * Get the URL of the block explorer page for an address.
@@ -1 +1 @@
1
- {"version":3,"file":"address.js","sourceRoot":"","sources":["../../../src/utils/address.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,IAAI,OAAO,CAAC,MAAM,GAAG,EAAE;QAAE,OAAO,OAAO,CAAA;IAEvC,MAAM,cAAc,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAEtE,OAAO,cAAc,CAAA;AACvB,CAAC;AAED,MAAM,qBAAqB,GAAsC;IAC/D,OAAO,EAAE,uBAAuB;IAChC,GAAG,EAAE,sBAAsB;CAC5B,CAAA;AAED,MAAM,qBAAqB,GAAsC;IAC/D,OAAO,EAAE,+BAA+B;IACxC,GAAG,EAAE,8BAA8B;CACpC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAAe,EACf,SAA4B,EAC5B,SAAkB;IAElB,MAAM,aAAa,GAAG,SAAS;QAC7B,CAAC,CAAC,qBAAqB;QACvB,CAAC,CAAC,qBAAqB,CAAA;IACzB,MAAM,OAAO,GAAG,aAAa,CAAC,SAAS,CAAC,CAAA;IACxC,MAAM,QAAQ,GAAG,WAAW,OAAO,EAAE,CAAA;IAErC,OAAO,GAAG,OAAO,IAAI,QAAQ,EAAE,CAAA;AACjC,CAAC"}
1
+ {"version":3,"file":"address.js","sourceRoot":"","sources":["../../../src/utils/address.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,IAAI,OAAO,CAAC,MAAM,GAAG,EAAE;QAAE,OAAO,OAAO,CAAA;IAEvC,MAAM,cAAc,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAEtE,OAAO,cAAc,CAAA;AACvB,CAAC;AAED,MAAM,qBAAqB,GAA+C;IACxE,OAAO,EAAE,uBAAuB;IAChC,GAAG,EAAE,sBAAsB;IAC3B,IAAI,EAAE,2BAA2B;CAClC,CAAA;AAED,MAAM,qBAAqB,GAA+C;IACxE,OAAO,EAAE,+BAA+B;IACxC,GAAG,EAAE,8BAA8B;IACnC,IAAI,EAAE,gCAAgC;CACvC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAAe,EACf,SAAqC,EACrC,SAAkB;IAElB,MAAM,aAAa,GAAG,SAAS;QAC7B,CAAC,CAAC,qBAAqB;QACvB,CAAC,CAAC,qBAAqB,CAAA;IACzB,MAAM,OAAO,GAAG,aAAa,CAAC,SAAS,CAAC,CAAA;IACxC,MAAM,QAAQ,GAAG,WAAW,OAAO,EAAE,CAAA;IAErC,OAAO,GAAG,OAAO,IAAI,QAAQ,EAAE,CAAA;AACjC,CAAC"}
@@ -28,5 +28,13 @@ describe("getAddressExplorerUrl", () => {
28
28
  const url = getAddressExplorerUrl(evmAddress, "evm", true);
29
29
  expect(url).toBe(`https://sepolia.etherscan.io/address/${evmAddress}`);
30
30
  });
31
+ it("returns correct mainnet Mezo explorer URL", () => {
32
+ const url = getAddressExplorerUrl(evmAddress, "mezo", false);
33
+ expect(url).toBe(`https://explorer.mezo.org/address/${evmAddress}`);
34
+ });
35
+ it("returns correct testnet Mezo explorer URL", () => {
36
+ const url = getAddressExplorerUrl(evmAddress, "mezo", true);
37
+ expect(url).toBe(`https://explorer.test.mezo.org/address/${evmAddress}`);
38
+ });
31
39
  });
32
40
  //# sourceMappingURL=address.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"address.test.js","sourceRoot":"","sources":["../../../src/utils/address.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE9D,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,EAAE,CAAC,gDAAgD,EAAE,GAA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src/index.js",
5
5
  "license": "GPL-3.0-only",
6
6
  "scripts": {
@@ -39,7 +39,9 @@
39
39
  "dependencies": {
40
40
  "@mezo-org/mezo-clay": "0.1.0-dev.26",
41
41
  "@mezo-org/orangekit": "1.0.0-beta.40-dev.1",
42
- "@mezo-org/sign-in-with-wallet": "1.0.0-beta.8"
42
+ "@mezo-org/sign-in-with-wallet": "1.0.0-beta.8",
43
+ "qrcode.react": "^4.2.0",
44
+ "zustand": "^5.0.3"
43
45
  },
44
46
  "peerDependencies": {
45
47
  "@rainbow-me/rainbowkit": "2.0.2",
@@ -1,78 +1,35 @@
1
- import {
2
- Block,
3
- Button,
4
- LogOut01,
5
- Mats,
6
- ParagraphSmall,
7
- useStyletron,
8
- } from "@mezo-org/mezo-clay"
9
- import React, { useCallback } from "react"
10
- import { useDisconnect } from "wagmi"
11
- import { useSignOut } from "../../hooks"
1
+ import { Block, useStyletron } from "@mezo-org/mezo-clay"
2
+ import React, { useEffect } from "react"
12
3
  import { DropdownData } from "../../hooks/useDropdownData"
13
- import AccountAddress from "./AccountAddress"
14
- import AccountAssets from "./AccountAssets"
15
- import AccountBalance from "./AccountBalance"
16
- import WelcomeBlock from "./WelcomeBlock"
4
+ import useDropdownStore, { DropdownView } from "../../stores/dropdownStore"
5
+ import Root from "./Root/Root"
6
+ import Receive from "./Receive/Receive"
17
7
 
18
- function MatsnetLabel() {
19
- const [, theme] = useStyletron()
20
- return (
21
- <ParagraphSmall color={theme.colors.contentTertiary}>
22
- <Mats
23
- color="currentColor"
24
- size={theme.sizing.scale400}
25
- overrides={{
26
- Svg: {
27
- style: {
28
- marginRight: theme.sizing.scale300,
29
- },
30
- },
31
- }}
32
- />
33
- Matsnet Assets
34
- </ParagraphSmall>
35
- )
36
- }
37
-
38
- type DropdownContentProps = {
8
+ type ContentProps = {
39
9
  data: DropdownData
40
10
  onSignOut?: () => void
41
11
  }
42
12
 
43
- export default function DropdownContent(props: DropdownContentProps) {
13
+ function Content(props: ContentProps) {
44
14
  const { data, onSignOut } = props
45
15
 
46
- const [, theme] = useStyletron()
47
-
48
- const {
49
- mezoId,
50
- address,
51
- walletType,
52
- totalBalanceInUsd,
53
- formattedNativeAssets,
54
- matsnet,
55
- } = data
56
-
57
- const { disconnect } = useDisconnect()
58
- const { signOut } = useSignOut()
16
+ const [_, theme] = useStyletron()
59
17
 
60
- const handleLogOut = useCallback(() => {
61
- if (onSignOut) {
62
- onSignOut()
63
- return
64
- }
18
+ const currentView = useDropdownStore((state) => state.view)
19
+ const setView = useDropdownStore((state) => state.setView)
65
20
 
66
- signOut()
67
- disconnect()
68
- }, [signOut, disconnect, onSignOut])
21
+ useEffect(
22
+ () => () => {
23
+ setView(DropdownView.ROOT)
24
+ },
25
+ [setView],
26
+ )
69
27
 
70
28
  return (
71
29
  <Block
72
30
  display="inline-flex"
73
31
  flexDirection="column"
74
32
  backgroundColor={theme.colors.backgroundPrimary}
75
- padding={theme.sizing.scale500}
76
33
  width="100%"
77
34
  overrides={{
78
35
  Block: {
@@ -82,67 +39,24 @@ export default function DropdownContent(props: DropdownContentProps) {
82
39
  },
83
40
  }}
84
41
  >
85
- <WelcomeBlock mezoId={mezoId} matsBalance={matsnet.mats} />
86
-
87
- <Block
88
- display="flex"
89
- flexDirection="column"
90
- backgroundColor={theme.colors.backgroundSecondary}
91
- overflow="hidden"
92
- overrides={{
93
- Block: { style: { borderRadius: theme.borders.radius300 } },
94
- }}
95
- >
96
- <AccountAddress address={address} type={walletType} />
97
-
98
- <AccountBalance amount={totalBalanceInUsd} />
99
-
100
- <AccountAssets label="Assets" assets={formattedNativeAssets} />
101
- </Block>
102
-
103
- {matsnet.formattedAssets.length > 0 && (
104
- <Block
105
- marginTop={theme.sizing.scale600}
106
- backgroundColor={theme.colors.backgroundSecondary}
107
- overflow="hidden"
108
- overrides={{
109
- Block: { style: { borderRadius: theme.borders.radius300 } },
110
- }}
111
- >
112
- <AccountAssets
113
- label={<MatsnetLabel />}
114
- assets={matsnet.formattedAssets}
115
- />
116
- </Block>
42
+ {currentView === DropdownView.ROOT && (
43
+ <Root
44
+ mezoId={data.mezoId}
45
+ accountAddress={data.accountAddress}
46
+ walletAddress={data.walletAddress}
47
+ walletType={data.walletType}
48
+ totalBalanceInUsd={data.totalBalanceInUsd}
49
+ formattedNativeAssets={data.formattedNativeAssets}
50
+ matsnet={data.matsnet}
51
+ onSignOut={onSignOut}
52
+ />
117
53
  )}
118
54
 
119
- <Block
120
- marginTop={theme.sizing.scale700}
121
- padding={`0 ${theme.sizing.scale100}`}
122
- >
123
- <Button
124
- size="small"
125
- kind="tertiary"
126
- startEnhancer={<LogOut01 color="currentColor" size={12} />}
127
- onClick={() => handleLogOut()}
128
- overrides={{
129
- Root: {
130
- style: {
131
- ":hover": {
132
- backgroundColor: theme.colors.backgroundSecondary,
133
- boxShadow: "none",
134
- },
135
- ":active": {
136
- backgroundColor: theme.colors.backgroundSecondary,
137
- color: theme.colors.contentPrimary,
138
- },
139
- },
140
- },
141
- }}
142
- >
143
- Log out
144
- </Button>
145
- </Block>
55
+ {currentView === DropdownView.RECEIVE && (
56
+ <Receive address={data.accountAddress} />
57
+ )}
146
58
  </Block>
147
59
  )
148
60
  }
61
+
62
+ export default Content
@@ -105,7 +105,7 @@ export function Dropdown(props: DropdownProps) {
105
105
  Body: {
106
106
  ...overrides?.Body,
107
107
  style: {
108
- minWidth: "396px",
108
+ width: "396px",
109
109
  borderRadius: theme.borders.radius500,
110
110
  boxShadow: theme.lighting.shadow500,
111
111
  overflow: "hidden",
@@ -0,0 +1,75 @@
1
+ import {
2
+ ArrowLeft,
3
+ Block,
4
+ ButtonIcon,
5
+ LabelMedium,
6
+ useStyletron,
7
+ } from "@mezo-org/mezo-clay"
8
+ import React, { ReactNode, useCallback } from "react"
9
+ import useDropdownStore, { DropdownView } from "../../stores/dropdownStore"
10
+
11
+ const getHeaderTitle = (view: DropdownView) => {
12
+ const titleMap: Partial<Record<DropdownView, string>> = {
13
+ [DropdownView.RECEIVE]: "Receive",
14
+ }
15
+ return titleMap[view]!
16
+ }
17
+
18
+ type NestedViewLayoutProps = {
19
+ children: ReactNode
20
+ }
21
+
22
+ function NestedViewLayout(props: NestedViewLayoutProps) {
23
+ const { children, ...restProps } = props
24
+
25
+ const currentView = useDropdownStore((state) => state.view)
26
+ const setView = useDropdownStore((state) => state.setView)
27
+ const isNested = useDropdownStore((state) => state.isNestedView())
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
+ padding={theme.sizing.scale700}
41
+ paddingTop={0}
42
+ {...restProps}
43
+ >
44
+ <Block
45
+ display="flex"
46
+ alignItems="center"
47
+ paddingTop={theme.sizing.scale600}
48
+ paddingBottom={theme.sizing.scale600}
49
+ marginBottom={theme.sizing.scale300}
50
+ >
51
+ <ButtonIcon
52
+ onClick={handleOnButtonClick}
53
+ shape="circle"
54
+ size="small"
55
+ overrides={{
56
+ BaseButton: {
57
+ style: {
58
+ background: theme.colors.backgroundPrimary,
59
+ marginRight: isNested ? theme.sizing.scale300 : undefined,
60
+ },
61
+ },
62
+ }}
63
+ >
64
+ <ArrowLeft size={theme.sizing.scale700} />
65
+ </ButtonIcon>
66
+
67
+ <LabelMedium>{getHeaderTitle(currentView)}</LabelMedium>
68
+ </Block>
69
+
70
+ {children}
71
+ </Block>
72
+ )
73
+ }
74
+
75
+ export default NestedViewLayout
@@ -0,0 +1,119 @@
1
+ import {
2
+ Block,
3
+ Button,
4
+ LabelMedium,
5
+ MonoLabelXSmall,
6
+ ParagraphSmall,
7
+ useStyletron,
8
+ } from "@mezo-org/mezo-clay"
9
+ import React, { useCallback, useState } from "react"
10
+ import { useCopyToClipboard } from "usehooks-ts"
11
+ import { QRCodeSVG } from "qrcode.react"
12
+ import NestedViewLayout from "../NestedViewLayout"
13
+ import { getAddressExplorerUrl } from "../../../utils/address"
14
+ import { usePassportContext } from "../../../hooks/usePassportContext"
15
+ import useWalletAccount from "../../../hooks/useWalletAccount"
16
+
17
+ type ReceiveProps = {
18
+ address: string
19
+ }
20
+
21
+ function Receive(props: ReceiveProps) {
22
+ const { address } = props
23
+
24
+ const { environment } = usePassportContext()
25
+
26
+ const blockExplorerUrl = getAddressExplorerUrl(
27
+ address,
28
+ "mezo",
29
+ environment === "testnet",
30
+ )
31
+
32
+ const [, theme] = useStyletron()
33
+
34
+ const [, copy] = useCopyToClipboard()
35
+ const [isCopiedMessageVisible, setIsCopiedMessageVisible] = useState(false)
36
+ const handleCopyAddress = useCallback(() => {
37
+ copy(address)
38
+ setIsCopiedMessageVisible(true)
39
+
40
+ setTimeout(() => {
41
+ setIsCopiedMessageVisible(false)
42
+ }, 2000)
43
+ }, [copy, address])
44
+
45
+ const { networkFamily } = useWalletAccount()
46
+
47
+ return (
48
+ <NestedViewLayout>
49
+ <LabelMedium>Receive assets on Mezo</LabelMedium>
50
+
51
+ <ParagraphSmall
52
+ marginTop={theme.sizing.scale300}
53
+ marginBottom={theme.sizing.scale600}
54
+ color={theme.colors.contentTertiary}
55
+ >
56
+ {networkFamily === "bitcoin" ? (
57
+ <>
58
+ Mezo automatically created a smart account that&apos;s fully
59
+ controlled by your connected Bitcoin wallet. Use this address to
60
+ receive assets on Mezo.
61
+ </>
62
+ ) : (
63
+ <>
64
+ Your connected wallet address is your Mezo address. Use this address
65
+ to receive assets on Mezo.
66
+ </>
67
+ )}
68
+ </ParagraphSmall>
69
+
70
+ <Block
71
+ as={QRCodeSVG}
72
+ value={address}
73
+ flex={1}
74
+ overrides={{
75
+ Block: {
76
+ style: {
77
+ aspectRatio: 1,
78
+ width: "fit-content",
79
+ margin: "0 auto",
80
+ },
81
+ },
82
+ }}
83
+ />
84
+
85
+ <MonoLabelXSmall
86
+ marginTop={theme.sizing.scale800}
87
+ marginBottom={theme.sizing.scale800}
88
+ overrides={{
89
+ Block: {
90
+ style: {
91
+ textAlign: "center",
92
+ },
93
+ },
94
+ }}
95
+ >
96
+ {address}
97
+ </MonoLabelXSmall>
98
+
99
+ <Button
100
+ onClick={handleCopyAddress}
101
+ overrides={{
102
+ BaseButton: {
103
+ style: {
104
+ marginBottom: theme.sizing.scale400,
105
+ },
106
+ },
107
+ }}
108
+ >
109
+ {isCopiedMessageVisible ? "Copied!" : "Copy Mezo Address"}
110
+ </Button>
111
+
112
+ <Button kind="secondary" $as="a" href={blockExplorerUrl} target="_blank">
113
+ View Explorer
114
+ </Button>
115
+ </NestedViewLayout>
116
+ )
117
+ }
118
+
119
+ export default Receive
@@ -0,0 +1,101 @@
1
+ import {
2
+ ArrowNarrowLeft,
3
+ Block,
4
+ Button,
5
+ ButtonProps,
6
+ Cube01,
7
+ useStyletron,
8
+ } from "@mezo-org/mezo-clay"
9
+ import React, { useCallback } from "react"
10
+ import { usePassportContext } from "../../../hooks/usePassportContext"
11
+ import { getAddressExplorerUrl } from "../../../utils/address"
12
+ import useDropdownStore, { DropdownView } from "../../../stores/dropdownStore"
13
+
14
+ type AccountAddressActionsProps = {
15
+ address: string
16
+ }
17
+
18
+ const buttonStartEnhancerSize = 12
19
+
20
+ const commonButtonProps: Partial<ButtonProps> = {
21
+ kind: "secondary",
22
+ size: "xsmall",
23
+ overrides: {
24
+ BaseButton: {
25
+ style: {
26
+ flex: 1,
27
+ },
28
+ },
29
+ StartEnhancer: {
30
+ style: {
31
+ stroke: "currentColor",
32
+ },
33
+ },
34
+ },
35
+ }
36
+
37
+ export default function AccountAddressActions(
38
+ props: AccountAddressActionsProps,
39
+ ) {
40
+ const { address } = props
41
+
42
+ const [, theme] = useStyletron()
43
+
44
+ const { environment } = usePassportContext()
45
+ const blockExplorerUrl = getAddressExplorerUrl(
46
+ address,
47
+ "mezo",
48
+ environment === "testnet",
49
+ )
50
+
51
+ const setDropdownView = useDropdownStore((state) => state.setView)
52
+
53
+ const handleReceiveClick = useCallback(() => {
54
+ setDropdownView(DropdownView.RECEIVE)
55
+ }, [setDropdownView])
56
+
57
+ return (
58
+ <Block
59
+ display="flex"
60
+ alignItems="center"
61
+ backgroundColor="transparent"
62
+ marginBottom={theme.sizing.scale600}
63
+ overrides={{
64
+ Block: {
65
+ style: {
66
+ gap: theme.sizing.scale600,
67
+ },
68
+ },
69
+ }}
70
+ >
71
+ <Button
72
+ startEnhancer={<Cube01 size={buttonStartEnhancerSize} />}
73
+ $as="a"
74
+ href={blockExplorerUrl}
75
+ target="_blank"
76
+ {...commonButtonProps}
77
+ >
78
+ View Mezo Explorer
79
+ </Button>
80
+
81
+ <Button
82
+ onClick={handleReceiveClick}
83
+ startEnhancer={
84
+ <ArrowNarrowLeft
85
+ size={buttonStartEnhancerSize}
86
+ overrides={{
87
+ Svg: {
88
+ style: {
89
+ transform: "rotate(-45deg)",
90
+ },
91
+ },
92
+ }}
93
+ />
94
+ }
95
+ {...commonButtonProps}
96
+ >
97
+ Receive
98
+ </Button>
99
+ </Block>
100
+ )
101
+ }
@@ -5,7 +5,7 @@ import {
5
5
  useStyletron,
6
6
  } from "@mezo-org/mezo-clay"
7
7
  import React, { useMemo } from "react"
8
- import { CryptoAssetKey, getCryptoAsset } from "../../utils/cryptoAssets"
8
+ import { CryptoAssetKey, getCryptoAsset } from "../../../utils/cryptoAssets"
9
9
 
10
10
  type AccountAssetsProps = {
11
11
  label: string | React.ReactNode