-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustodianList.tsx
98 lines (93 loc) · 2.87 KB
/
CustodianList.tsx
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
import {
Heading,
Box,
Container,
Text,
Button,
Footer,
Section,
Image,
Link,
} from '@metamask/snaps-sdk/jsx';
import type { SnapComponent, SnapElement } from '@metamask/snaps-sdk/jsx';
import bitgoLogo from '../../../../images/bitgo.svg';
import cactusLogo from '../../../../images/cactus.svg';
import fireblocksLogo from '../../../../images/fireblocks.svg';
import gk8Logo from '../../../../images/gk8.svg';
import icon from '../../../../images/icon.svg';
import mpcvaultLogo from '../../../../images/mpcvault.svg';
import neptuneLogo from '../../../../images/neptune.svg';
import safeLogo from '../../../../images/safe.svg';
import zodiaLogo from '../../../../images/zodia.svg';
import type { CustodianMetadata } from '../../../lib/custodian-types/custodianMetadata';
import { custodianMetadata } from '../../../lib/custodian-types/custodianMetadata';
import type { CustodialKeyringAccount } from '../../../lib/types/CustodialKeyringAccount';
import { HomePageNames, HomePagePrefixes } from '../types';
const custodianLogos: Record<string, string> = {
'bitgo-prod': bitgoLogo,
'gk8-prod': gk8Logo,
'gk8-eca3-prod': gk8Logo,
'safe-prod': safeLogo,
'mpcvault-prod': mpcvaultLogo,
'fireblocks-prod': fireblocksLogo,
'neptune-custody-dev': neptuneLogo,
'zodia-prod': zodiaLogo,
cactus: cactusLogo,
};
type CustodianListProps = {
accounts?: CustodialKeyringAccount[];
};
export const CustodianList: SnapComponent<CustodianListProps> = ({
accounts,
}): SnapElement => {
const renderSelect = (custodian: CustodianMetadata) => {
if (
custodian.name.startsWith('gk8') ||
custodian.name.startsWith('neptune')
) {
return (
<Button name={`${HomePagePrefixes.SelectCustodian}${custodian.name}`}>
Select
</Button>
);
}
if (custodian.onboardingUrl) {
return <Link href={custodian.onboardingUrl}>Select</Link>;
}
return null;
};
return (
<Container>
<Box>
<Heading>Select custodian</Heading>
<Text>
Connect your existing accounts or select a custody or self-custody
solution
</Text>
{custodianMetadata
.filter((custodian) => custodian.production)
.map((custodian) => (
<Section
key={custodian.name}
direction="horizontal"
alignment="space-between"
>
<Box direction="horizontal">
<Image src={custodianLogos[custodian.name] ?? icon} />
<Text>{custodian.displayName}</Text>
</Box>
{renderSelect(custodian)}
</Section>
))}
</Box>
<Footer>
<Button
name={HomePageNames.RemoveCustodianToken}
disabled={!accounts?.length}
>
Remove custodian token
</Button>
</Footer>
</Container>
) as SnapElement;
};