-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathConfirmSignMessage.tsx
More file actions
113 lines (107 loc) · 3.4 KB
/
Copy pathConfirmSignMessage.tsx
File metadata and controls
113 lines (107 loc) · 3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import {
Address,
Box,
Button,
Container,
Footer,
Heading,
Icon,
Image,
Section,
Text,
Tooltip,
type SnapComponent,
} from '@metamask/snaps-sdk/jsx';
import { Networks, type Network } from '../../../../core/constants/solana';
import { SOL_IMAGE_SVG } from '../../../../core/test/mocks/solana-image-svg';
import { addressToCaip10 } from '../../../../core/utils/addressToCaip10';
import type { Locale } from '../../../../core/utils/i18n';
import { i18n } from '../../../../core/utils/i18n';
import type { SolanaKeyringAccount } from '../../../../domain';
import { ConfirmSignMessageFormNames } from './events';
export type ConfirmSignMessageProps = {
message: string;
account: SolanaKeyringAccount;
scope: Network;
locale: Locale;
networkImage: string | null;
origin: string;
};
export const ConfirmSignMessage: SnapComponent<ConfirmSignMessageProps> = ({
message,
account,
scope,
locale,
networkImage,
origin,
}) => {
const translate = i18n(locale);
const { address } = account;
const originHostname = origin ? new URL(origin).hostname : null;
const addressCaip10 = addressToCaip10(scope, address);
return (
<Container>
<Box>
<Box alignment="center" center>
<Box>{null}</Box>
<Heading size="lg">
{translate('confirmation.signMessage.title')}
</Heading>
</Box>
<Section>
<Box direction="horizontal" center>
<Text fontWeight="medium">
{translate('confirmation.signMessage.message')}
</Text>
</Box>
<Box alignment="space-between">
<Text>{message}</Text>
</Box>
</Section>
<Section>
{originHostname ? (
<Box alignment="space-between" direction="horizontal">
<Box alignment="space-between" direction="horizontal" center>
<Text fontWeight="medium" color="alternative">
{translate('confirmation.origin')}
</Text>
<Tooltip content={translate('confirmation.origin.tooltip')}>
<Icon name="question" color="muted" />
</Tooltip>
</Box>
<Text>{originHostname}</Text>
</Box>
) : null}
<Box alignment="space-between" direction="horizontal">
<Text fontWeight="medium" color="alternative">
{translate('confirmation.account')}
</Text>
<Address address={addressCaip10} truncate displayName avatar />
</Box>
<Box alignment="space-between" direction="horizontal">
<Text fontWeight="medium" color="alternative">
{translate('confirmation.network')}
</Text>
<Box direction="horizontal" alignment="center">
<Box alignment="center" center>
<Image
borderRadius="medium"
src={networkImage ?? SOL_IMAGE_SVG}
/>
</Box>
<Text>{Networks[scope].name}</Text>
</Box>
</Box>
</Section>
</Box>
<Footer>
<Button name={ConfirmSignMessageFormNames.Cancel}>
{translate('confirmation.cancelButton')}
</Button>
<Button name={ConfirmSignMessageFormNames.Confirm}>
{translate('confirmation.confirmButton')}
</Button>
</Footer>
</Container>
);
};