Skip to content

Commit c4d6e91

Browse files
authored
Merge pull request #3 from nachopiris/master
Sign messages
2 parents 826c61e + 3085682 commit c4d6e91

File tree

10 files changed

+833
-23
lines changed

10 files changed

+833
-23
lines changed

src/App.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
import { AppShell, Box, Burger, Divider, Grid, Group, NativeSelect, NavLink, Title, Text } from '@mantine/core';
22
import { useDisclosure } from '@mantine/hooks';
3-
import { IconCirclePlus, IconEdit, IconFileImport, IconFileUpload, IconHome, IconList, IconListDetails, IconSend2, IconWallet } from '@tabler/icons-react';
3+
import { IconCirclePlus, IconEdit, IconFileImport, IconFileUpload, IconHome, IconList, IconListDetails, IconMessage, IconSend2, IconWallet, IconWritingSign } from '@tabler/icons-react';
44
import { Route, Routes, useLocation, useNavigate } from "react-router-dom"
55
import { Create } from './sections/Create';
66
import { Notifications } from '@mantine/notifications';
77
import { Home } from './sections/Home';
88
import { Wallet } from './sections/Wallet';
99
import { useSelectedWallet } from './stores/Storage';
1010
import { Send } from './sections/Send';
11+
import { Sign } from './sections/Sign';
1112
import { ConnectKitButton } from 'connectkit';
1213
import { Transaction } from './sections/Transaction';
14+
import { Message } from './sections/Message';
1315
import { Transactions } from './sections/Transactions';
1416
import { useImport } from './sections/Import';
1517
import { ImportWallet } from './sections/ImportWallet';
1618
import { useWallets } from './stores/db/Wallets';
1719
import { Update } from './sections/Update';
1820
import { Updates } from './sections/Updates';
1921
import { UpdateDetail } from './sections/UpdateDetail';
22+
import { Messages } from './sections/Messages';
2023

2124
declare var __COMMIT_HASH__: string
2225

@@ -128,6 +131,20 @@ export function App() {
128131
active={pathname === '/updates/' + selectedWalletAddress}
129132
disabled={!selectedWalletAddress}
130133
/>
134+
<NavLink
135+
href={"#sign-message/" + selectedWalletAddress}
136+
label="Sign Message"
137+
leftSection={<IconWritingSign size="1rem" stroke={1.5} />}
138+
active={pathname === '/sign-message/' + selectedWalletAddress}
139+
disabled={!selectedWalletAddress}
140+
/>
141+
<NavLink
142+
href={"#messages/" + selectedWalletAddress}
143+
label="Messages"
144+
leftSection={<IconMessage size="1rem" stroke={1.5} />}
145+
active={pathname === '/messages/' + selectedWalletAddress}
146+
disabled={!selectedWalletAddress}
147+
/>
131148
<Box mt="auto" />
132149
<Box>
133150
<Text size="sm" c="dimmed">
@@ -153,9 +170,12 @@ export function App() {
153170
<Route path="/new-transaction/:address" element={<Send />} />
154171
<Route path="/transactions/:address" element={<Transactions />} />
155172
<Route path="/transaction/:subdigest" element={<Transaction />} />
173+
<Route path="/message/:subdigest" element={<Message />} />
156174
<Route path="/update/:address" element={<Update />} />
157175
<Route path="/updates/:address" element={<Updates />} />
158176
<Route path="/do-update/:subdigest" element={<UpdateDetail />} />
177+
<Route path="/sign-message/:address" element={<Sign />} />
178+
<Route path="/messages/:address" element={<Messages />} />
159179
</Routes>
160180
</AppShell.Main>
161181
</AppShell>

src/components/MiniCard.tsx

Lines changed: 88 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,93 @@
1-
import { Box } from "@mantine/core";
1+
import { Box, Tooltip } from "@mantine/core";
22
import { ReactElement } from "react";
3+
import { notifications } from "@mantine/notifications";
4+
import { IconCopy, IconEye } from "@tabler/icons-react";
5+
6+
export function MiniCard(args: {
7+
title: string;
8+
value: ReactElement | string;
9+
shortValue?: string;
10+
}) {
11+
const copyContent = async () => {
12+
if (typeof args.value === "string") {
13+
try {
14+
await navigator.clipboard.writeText(args.value);
15+
notifications.show({
16+
title: "Text copied",
17+
message: "Text successfully copied to clipboard",
18+
color: "green",
19+
});
20+
} catch (error) {
21+
notifications.show({
22+
title: "Failed to copy text",
23+
message: JSON.stringify(error),
24+
color: "red",
25+
});
26+
}
27+
}
28+
};
329

4-
export function MiniCard(args: { title: string, value: ReactElement | string }) {
530
return (
6-
<Box style={{
7-
border: "1px solid #f0f0f0",
8-
borderRadius: 4,
9-
padding: 16,
10-
marginBottom: 16,
11-
marginLeft: 8,
12-
marginRight: 8
13-
}}>
14-
<div style={{
15-
fontSize: 12,
16-
color: "#666"
17-
}}>{args.title}</div>
18-
<div style={{
19-
fontWeight: 600,
20-
color: "#333"
21-
}}>{args.value}</div>
31+
<Box
32+
style={{
33+
border: "1px solid #f0f0f0",
34+
borderRadius: 4,
35+
padding: 16,
36+
marginBottom: 16,
37+
marginLeft: 8,
38+
marginRight: 8,
39+
}}
40+
>
41+
<div
42+
style={{
43+
fontSize: 12,
44+
color: "#666",
45+
display: "flex",
46+
flexDirection: "row",
47+
justifyContent: "space-between",
48+
}}
49+
>
50+
{args.title}
51+
{args.shortValue && (
52+
<div
53+
style={{
54+
display: "flex",
55+
flexDirection: "row",
56+
columnGap: "10px",
57+
}}
58+
>
59+
<Tooltip
60+
label={
61+
<div
62+
style={{
63+
maxWidth: "800px",
64+
whiteSpace: "normal",
65+
wordWrap: "break-word",
66+
}}
67+
>
68+
{args.value}
69+
</div>
70+
}
71+
>
72+
<IconEye cursor="pointer" size="1rem" stroke={1.5}></IconEye>
73+
</Tooltip>
74+
<IconCopy
75+
cursor="pointer"
76+
onClick={copyContent}
77+
size="1rem"
78+
stroke={1.5}
79+
/>
80+
</div>
81+
)}
82+
</div>
83+
<div
84+
style={{
85+
fontWeight: 600,
86+
color: "#333",
87+
}}
88+
>
89+
{args.shortValue || args.value}
90+
</div>
2291
</Box>
23-
)
92+
);
2493
}

src/sections/Import.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,13 @@ export function Import() {
5555

5656
if (
5757
result.importedSignatures.length === 0 &&
58+
result.importedMessages.length === 0 &&
5859
result.importedTransactions.length === 0 &&
5960
result.importedUpdates.length === 0
6061
) {
6162
notifications.show({
6263
title: 'No data imported',
63-
message: 'No new transactions or signatures found',
64+
message: 'No new transactions, signatures or messages found',
6465
color: 'yellow'
6566
})
6667
} else {
@@ -72,6 +73,14 @@ export function Import() {
7273
})
7374
}
7475

76+
if (result.importedMessages.length > 0) {
77+
notifications.show({
78+
title: 'Messages imported',
79+
message: 'Imported ' + result.importedMessages.length + ' messages',
80+
color: 'green'
81+
})
82+
}
83+
7584
if (result.importedSignatures.length > 0) {
7685
notifications.show({
7786
title: 'Signatures imported',

0 commit comments

Comments
 (0)