Skip to content

Commit 672124d

Browse files
committed
Define deployment history types and show in sidebar
Remove warp-ui-specific code from Sidebar and DeploymentDetailsModal
1 parent e97766c commit 672124d

File tree

13 files changed

+183
-315
lines changed

13 files changed

+183
-315
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { DefaultIconProps } from '@hyperlane-xyz/widgets';
2+
import { memo } from 'react';
3+
import { Color } from '../../styles/Color';
4+
5+
// TODO move to widgets lib
6+
function _ConfirmedIcon({ color, ...rest }: DefaultIconProps) {
7+
return (
8+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 26" {...rest}>
9+
<g clip-path="url(#confirmed-icon-clip-path)">
10+
<path
11+
d="M1.93105 13.4815C1.93076 11.6219 2.42129 9.79511 3.35333 8.1846C4.28537 6.57409 5.62608 5.23667 7.24067 4.30678C8.85527 3.37689 10.6869 2.8873 12.5513 2.88723C14.4158 2.88716 16.2474 3.3766 17.8621 4.30637C18.0837 4.43205 18.3462 4.46519 18.5923 4.39857C18.8383 4.33194 19.048 4.17096 19.1754 3.95074C19.3029 3.73052 19.3379 3.46895 19.2727 3.22311C19.2076 2.97727 19.0475 2.76712 18.8276 2.63851C16.4348 1.26067 13.653 0.708778 10.9136 1.06842C8.17424 1.42807 5.63041 2.67916 3.67662 4.62766C1.72282 6.57616 0.468253 9.11318 0.107478 11.8453C-0.253297 14.5774 0.299883 17.3519 1.68123 19.7384C3.06257 22.125 5.19488 23.9903 7.74747 25.0451C10.3001 26.0998 13.1303 26.2851 15.7992 25.5721C18.4681 24.8592 20.8266 23.2878 22.5088 21.1018C24.1911 18.9157 25.1031 16.2372 25.1035 13.4815C25.1035 13.2261 25.0017 12.9812 24.8207 12.8006C24.6396 12.62 24.394 12.5185 24.1379 12.5185C23.8819 12.5185 23.6363 12.62 23.4552 12.8006C23.2741 12.9812 23.1724 13.2261 23.1724 13.4815C23.1724 16.2908 22.0535 18.9851 20.0617 20.9716C18.0699 22.9581 15.3685 24.0741 12.5517 24.0741C9.73495 24.0741 7.03354 22.9581 5.04178 20.9716C3.05001 18.9851 1.93105 16.2908 1.93105 13.4815Z"
12+
fill={color || Color.black}
13+
/>
14+
<path
15+
d="M26.7526 4.53363C26.8424 4.4441 26.9136 4.33781 26.9622 4.22083C27.0108 4.10385 27.0358 3.97847 27.0358 3.85185C27.0358 3.72523 27.0108 3.59986 26.9622 3.48288C26.9136 3.3659 26.8424 3.25961 26.7526 3.17007C26.6629 3.08054 26.5563 3.00952 26.439 2.96107C26.3217 2.91261 26.196 2.88767 26.0691 2.88767C25.9421 2.88767 25.8164 2.91261 25.6991 2.96107C25.5818 3.00952 25.4752 3.08054 25.3855 3.17007L12.5518 15.9717L7.44231 10.8738C7.35254 10.7842 7.24597 10.7132 7.12868 10.6648C7.01139 10.6163 6.88568 10.5914 6.75873 10.5914C6.63178 10.5914 6.50606 10.6163 6.38877 10.6648C6.27148 10.7132 6.16491 10.7842 6.07514 10.8738C5.98537 10.9633 5.91416 11.0696 5.86558 11.1866C5.817 11.3036 5.79199 11.4289 5.79199 11.5556C5.79199 11.6822 5.817 11.8076 5.86558 11.9245C5.91416 12.0415 5.98537 12.1478 6.07514 12.2373L11.8682 18.0151C11.9579 18.1048 12.0645 18.1759 12.1818 18.2245C12.2991 18.273 12.4248 18.298 12.5518 18.298C12.6788 18.298 12.8046 18.273 12.9219 18.2245C13.0392 18.1759 13.1457 18.1048 13.2354 18.0151L26.7526 4.53363Z"
16+
fill={color || Color.black}
17+
/>
18+
</g>
19+
<defs>
20+
<clipPath id="confirmed-icon-clip-path">
21+
<rect width="28" height="26" fill="white" />
22+
</clipPath>
23+
</defs>
24+
</svg>
25+
);
26+
}
27+
28+
export const ConfirmedIcon = memo(_ConfirmedIcon);

src/components/icons/GasIcon.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import { Color } from '../../styles/Color';
66
function _GasIcon({ color, ...rest }: DefaultIconProps) {
77
return (
88
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" {...rest}>
9-
<g clipPath="url(#gas-icon)">
9+
<g clipPath="url(#gas-icon-clip-path)">
1010
<path
1111
fill={color || Color.black}
1212
d="M3.1 6.3A6.3 6.3 0 0 1 9.4 0H28a6.2 6.2 0 0 1 6.3 6.3v25a6.2 6.2 0 0 1 6.2 6.2v1.6a1.6 1.6 0 0 0 3.1 0V25h-1.5a1.6 1.6 0 0 1-1.6-1.6v-9.7a1.6 1.6 0 0 1 1.6-1.6h4.7a10 10 0 0 0-.7-3.8A3 3 0 0 0 45 6.9a5 5 0 0 0-2.8-.7 1.6 1.6 0 0 1 0-3c1.8 0 3.2.3 4.4 1 1.2.7 2 1.7 2.5 2.8.9 2 .9 4.6.9 6.5v10a1.6 1.6 0 0 1-1.6 1.5H47v14a4.7 4.7 0 0 1-9.4 0v-1.5a3.1 3.1 0 0 0-3.1-3.1v12.5H36a1.6 1.6 0 0 1 0 3.1H1.6a1.6 1.6 0 1 1 0-3.1H3V6.3Zm7.8 0a1.6 1.6 0 0 0-1.5 1.5v15.6a1.6 1.6 0 0 0 1.5 1.6h15.7a1.6 1.6 0 0 0 1.5-1.6V7.8a1.6 1.6 0 0 0-1.5-1.5H10.9Z"
1313
/>
1414
</g>
1515
<defs>
16-
<clipPath id="gas-icon">
16+
<clipPath id="gas-icon-clip-path">
1717
<path fill="#fff" d="M0 0h50v50H0z" />
1818
</clipPath>
1919
</defs>

src/components/icons/StopIcon.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import { Color } from '../../styles/Color';
66
function _StopIcon({ color, ...rest }: DefaultIconProps) {
77
return (
88
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 12" {...rest}>
9-
<g clipPath="url(#stop-icon)">
9+
<g clipPath="url(#stop-icon-clip-path)">
1010
<path
1111
fill={color || Color.black}
1212
d="M3.5 12 0 8.5v-5L3.5 0h5L12 3.5v5L8.5 12h-5Zm.6-3.2L6 7l1.9 2 1-1-2-1.9 2-1.9-1-1-1.9 2-1.9-2-1 1 2 1.9-2 1.9 1 1Zm0 1.9h3.8l2.8-2.8V4.1L7.9 1.3H4.1L1.3 4.1v3.8l2.8 2.8Z"
1313
/>
1414
</g>
1515
<defs>
16-
<clipPath id="stop-icon">
16+
<clipPath id="stop-icon-clip-path">
1717
<path fill="#fff" d="M0 0h12v12H0z" />
1818
</clipPath>
1919
</defs>
Lines changed: 33 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,7 @@
1-
import { ProtocolType } from '@hyperlane-xyz/utils';
2-
import {
3-
CopyButton,
4-
Modal,
5-
SpinnerIcon,
6-
useAccountForChain,
7-
useTimeout,
8-
useWalletDetails,
9-
} from '@hyperlane-xyz/widgets';
10-
import Image from 'next/image';
11-
import { useCallback, useMemo, useState } from 'react';
12-
import LinkIcon from '../../images/icons/external-link-icon.svg';
1+
import { Modal } from '@hyperlane-xyz/widgets';
2+
import { useMemo } from 'react';
133
import { formatTimestamp } from '../../utils/date';
14-
import { useMultiProvider } from '../chains/hooks';
15-
import { hasPermissionlessChain } from '../chains/utils';
16-
import { DeploymentContext, DeploymentStatus } from './types';
17-
import {
18-
getDeploymentStatusLabel,
19-
getIconByDeploymentStatus,
20-
isDeploymentFailed,
21-
isDeploymentSent,
22-
} from './utils';
4+
import { DeploymentContext } from './types';
235

246
export function DeploymentsDetailsModal({
257
isOpen,
@@ -30,27 +12,7 @@ export function DeploymentsDetailsModal({
3012
onClose: () => void;
3113
deployment: DeploymentContext;
3214
}) {
33-
const { status, origin, destination, timestamp } = deployment || {};
34-
35-
const multiProvider = useMultiProvider();
36-
37-
const isChainKnown = multiProvider.hasChain(origin);
38-
const account = useAccountForChain(multiProvider, isChainKnown ? origin : undefined);
39-
const walletDetails = useWalletDetails()[account?.protocol || ProtocolType.Ethereum];
40-
41-
const isAccountReady = !!account?.isReady;
42-
const connectorName = walletDetails.name || 'wallet';
43-
const isPermissionlessRoute = hasPermissionlessChain(multiProvider, [destination, origin]);
44-
const isSent = isDeploymentSent(status);
45-
const isFailed = isDeploymentFailed(status);
46-
const isFinal = isSent || isFailed;
47-
const statusDescription = getDeploymentStatusLabel(
48-
status,
49-
connectorName,
50-
isPermissionlessRoute,
51-
isAccountReady,
52-
);
53-
const showSignWarning = useSignIssueWarning(status);
15+
const { status, timestamp } = deployment || {};
5416

5517
const date = useMemo(
5618
() => (timestamp ? formatTimestamp(timestamp) : formatTimestamp(new Date().getTime())),
@@ -59,85 +21,36 @@ export function DeploymentsDetailsModal({
5921

6022
return (
6123
<Modal isOpen={isOpen} close={onClose} panelClassname="p-4 md:p-5 max-w-sm">
62-
{isFinal && (
63-
<div className="flex justify-between">
64-
<h2 className="font-medium text-gray-600">{date}</h2>
65-
<div className="flex items-center font-medium">
66-
{isSent ? (
67-
<h3 className="text-primary-500">Sent</h3>
68-
) : (
69-
<h3 className="text-red-500">Failed</h3>
70-
)}
71-
<Image
72-
src={getIconByDeploymentStatus(status)}
73-
width={25}
74-
height={25}
75-
alt=""
76-
className="ml-2"
77-
/>
78-
</div>
79-
</div>
80-
)}
81-
82-
{isFinal ? (
83-
<div className="mt-5 flex flex-col space-y-4">TODO</div>
84-
) : (
85-
<div className="flex flex-col items-center justify-center py-4">
86-
<SpinnerIcon width={60} height={60} className="mt-3" />
87-
<div
88-
className={`mt-5 text-center text-sm ${isFailed ? 'text-red-600' : 'text-gray-600'}`}
89-
>
90-
{statusDescription}
91-
</div>
92-
{showSignWarning && (
93-
<div className="mt-3 text-center text-sm text-gray-600">
94-
If your wallet does not show a transaction request or never confirms, please try the
95-
deployment again.
96-
</div>
97-
)}
98-
</div>
99-
)}
24+
{status}
25+
{date}
10026
</Modal>
10127
);
10228
}
10329

104-
export function DeploymentProperty({
105-
name,
106-
value,
107-
url,
108-
}: {
109-
name: string;
110-
value: string;
111-
url?: string;
112-
}) {
113-
return (
114-
<div>
115-
<div className="flex items-center justify-between">
116-
<label className="text-sm leading-normal tracking-wider text-gray-350">{name}</label>
117-
<div className="flex items-center space-x-2">
118-
{url && (
119-
<a href={url} target="_blank" rel="noopener noreferrer">
120-
<Image src={LinkIcon} width={14} height={14} alt="" />
121-
</a>
122-
)}
123-
<CopyButton copyValue={value} width={14} height={14} className="opacity-40" />
124-
</div>
125-
</div>
126-
<div className="mt-1 truncate text-sm leading-normal tracking-wider">{value}</div>
127-
</div>
128-
);
129-
}
130-
131-
// https://github.com/wagmi-dev/wagmi/discussions/2928
132-
function useSignIssueWarning(status: DeploymentStatus) {
133-
const [showWarning, setShowWarning] = useState(false);
134-
const warningCallback = useCallback(() => {
135-
if (
136-
status === DeploymentStatus.SigningDeployment ||
137-
status === DeploymentStatus.ConfirmingDeployment
138-
)
139-
setShowWarning(true);
140-
}, [status, setShowWarning]);
141-
useTimeout(warningCallback, 20_000);
142-
return showWarning;
143-
}
30+
// TODO remove?
31+
// function DeploymentProperty({
32+
// name,
33+
// value,
34+
// url,
35+
// }: {
36+
// name: string;
37+
// value: string;
38+
// url?: string;
39+
// }) {
40+
// return (
41+
// <div>
42+
// <div className="flex items-center justify-between">
43+
// <label className="text-sm leading-normal tracking-wider text-gray-350">{name}</label>
44+
// <div className="flex items-center space-x-2">
45+
// {url && (
46+
// <a href={url} target="_blank" rel="noopener noreferrer">
47+
// <Image src={LinkIcon} width={14} height={14} alt="" />
48+
// </a>
49+
// )}
50+
// <CopyButton copyValue={value} width={14} height={14} className="opacity-40" />
51+
// </div>
52+
// </div>
53+
// <div className="mt-1 truncate text-sm leading-normal tracking-wider">{value}</div>
54+
// </div>
55+
// );
56+
// }

src/features/deployment/hooks.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ export function useCoreDeploymentConfig() {
1919
const warpConfig = deploymentConfig?.type === DeploymentType.Core ? deploymentConfig : undefined;
2020
return { deploymentConfig: warpConfig, setDeploymentConfig };
2121
}
22+
23+
export function useDeploymentHistory() {
24+
return useStore((s) => ({
25+
deployments: s.deployments,
26+
addDeployment: s.addDeployment,
27+
updateDeploymentStatus: s.updateDeploymentStatus,
28+
}));
29+
}

src/features/deployment/types.ts

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,33 @@
1-
import { ChainName, WarpRouteDeployConfig } from '@hyperlane-xyz/sdk';
1+
import { ChainName, WarpCoreConfig, WarpRouteDeployConfig } from '@hyperlane-xyz/sdk';
22

33
export enum DeploymentStatus {
4-
Preparing = 'preparing',
5-
CreatingTxs = 'creating-txs',
6-
SigningApprove = 'signing-approve',
7-
ConfirmingApprove = 'confirming-approve',
8-
SigningDeployment = 'signing-deployment',
9-
ConfirmingDeployment = 'confirming-deployment',
10-
ConfirmedDeployment = 'confirmed-deployment',
11-
// TODO
12-
Delivered = 'delivered',
4+
Configured = 'configured',
5+
Deploying = 'deploying',
6+
Complete = 'complete',
7+
Cancelled = 'cancelled',
138
Failed = 'failed',
149
}
1510

16-
// TODO
17-
export const SentDeploymentStatuses = [
18-
DeploymentStatus.ConfirmedDeployment,
19-
DeploymentStatus.Delivered,
20-
];
21-
22-
// Statuses considered not pending
23-
export const FinalDeploymentStatuses = [...SentDeploymentStatuses, DeploymentStatus.Failed];
24-
25-
export interface DeploymentContext {
26-
status: DeploymentStatus;
27-
origin: ChainName;
28-
destination: ChainName;
29-
timestamp: number;
30-
}
31-
3211
export enum DeploymentType {
3312
Warp = 'warp',
3413
Core = 'core',
3514
// Add more here as needed
3615
}
3716

17+
export const FinalDeploymentStatuses = [
18+
DeploymentStatus.Complete,
19+
DeploymentStatus.Cancelled,
20+
DeploymentStatus.Failed,
21+
];
22+
23+
export interface DeploymentContext {
24+
timestamp: number;
25+
status: DeploymentStatus;
26+
type: DeploymentType;
27+
config: DeploymentConfig;
28+
result?: DeploymentResult;
29+
}
30+
3831
interface ConfigBase {
3932
type: DeploymentType;
4033
config: unknown;
@@ -52,3 +45,20 @@ export interface CoreDeploymentConfig extends ConfigBase {
5245
}
5346

5447
export type DeploymentConfig = WarpDeploymentConfig | CoreDeploymentConfig;
48+
49+
interface ResultBase {
50+
type: DeploymentType;
51+
result: unknown;
52+
}
53+
54+
export interface WarpDeploymentResult extends ResultBase {
55+
type: DeploymentType.Warp;
56+
result: WarpCoreConfig;
57+
}
58+
59+
export interface CoreDeploymentResult extends ResultBase {
60+
type: DeploymentType.Core;
61+
config: any; // TODO
62+
}
63+
64+
export type DeploymentResult = WarpDeploymentResult | CoreDeploymentResult;

0 commit comments

Comments
 (0)