Skip to content

Commit 6f46945

Browse files
authored
Merge pull request Emmyt24#664 from Macnelson9/feature/factory-pause-awareness
Feature/factory pause awareness
2 parents dbf0d37 + 207104f commit 6f46945

6 files changed

Lines changed: 749 additions & 3 deletions

File tree

frontend/src/components/TokenDeployForm/TokenDeployForm.tsx

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useMemo, useState } from 'react';
22
import type { DeploymentResult, TokenDeployParams, WalletState } from '../../types';
33
import { useTokenDeploy } from '../../hooks/useTokenDeploy';
4+
import { useFactoryState } from '../../hooks/useFactoryState';
45
import { formatXLM, truncateAddress } from '../../utils/formatting';
56
import { BasicInfoStep, type BasicInfoData } from './BasicInfoStep';
67
import { FeeDisplay } from './FeeDisplay';
@@ -30,6 +31,9 @@ export function TokenDeployForm({
3031

3132
const { deploy, reset, status, statusMessage, isDeploying, error, getFeeBreakdown } =
3233
useTokenDeploy(wallet.network);
34+
35+
const { isPaused, loading: pauseLoading, error: pauseError, refresh: refreshPauseState } =
36+
useFactoryState({ network: wallet.network, pollingInterval: 30000 });
3337

3438
const hasMetadataInput = Boolean(metadataDescription.trim() || metadataImage);
3539
const feeBreakdown = useMemo(
@@ -175,6 +179,48 @@ export function TokenDeployForm({
175179
</p>
176180
</div>
177181

182+
{isPaused && !pauseLoading && (
183+
<div className="rounded-lg border border-orange-200 bg-orange-50 p-4">
184+
<div className="flex items-start">
185+
<div className="flex-shrink-0">
186+
<svg className="h-5 w-5 text-orange-400" viewBox="0 0 20 20" fill="currentColor">
187+
<path fillRule="evenodd" d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" clipRule="evenodd" />
188+
</svg>
189+
</div>
190+
<div className="ml-3 flex-1">
191+
<h3 className="text-sm font-medium text-orange-800">Protocol Maintenance</h3>
192+
<p className="mt-2 text-sm text-orange-700">
193+
The factory contract on <span className="font-semibold">{wallet.network}</span> is currently paused for maintenance.
194+
Token deployment and admin actions are temporarily disabled.
195+
</p>
196+
<p className="mt-2 text-sm text-orange-700">
197+
Please check back later or contact support for more information.
198+
</p>
199+
<button
200+
onClick={() => void refreshPauseState()}
201+
className="mt-3 text-sm font-medium text-orange-800 hover:text-orange-900 underline"
202+
>
203+
Check Status Again
204+
</button>
205+
</div>
206+
</div>
207+
</div>
208+
)}
209+
210+
{pauseError && !pauseLoading && (
211+
<div className="rounded-lg border border-yellow-200 bg-yellow-50 p-4">
212+
<p className="text-sm text-yellow-800">
213+
Unable to verify protocol status. You may proceed, but deployment might fail if the protocol is paused.
214+
</p>
215+
<button
216+
onClick={() => void refreshPauseState()}
217+
className="mt-2 text-sm font-medium text-yellow-800 hover:text-yellow-900 underline"
218+
>
219+
Retry Status Check
220+
</button>
221+
</div>
222+
)}
223+
178224
{!wallet.connected ? (
179225
<div className="rounded-lg border border-yellow-200 bg-yellow-50 p-4">
180226
<p className="text-sm text-yellow-800">Connect your wallet to continue deployment.</p>
@@ -269,10 +315,11 @@ export function TokenDeployForm({
269315
loading={isDeploying}
270316
loadingText={status === 'uploading' ? 'Uploading...' : 'Deploying...'}
271317
className="w-full"
272-
disabled={!wallet.connected}
318+
disabled={!wallet.connected || isPaused || pauseLoading}
273319
data-tutorial="deploy-button"
320+
title={isPaused ? 'Protocol is paused for maintenance' : undefined}
274321
>
275-
Deploy Token
322+
{isPaused ? 'Protocol Paused' : 'Deploy Token'}
276323
</LoadingButton>
277324
</div>
278325
</div>

frontend/src/components/UI/HandledErrorAlert.tsx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ErrorHandler } from '../../utils/errors';
22
import type { AppError } from '../../types';
3+
import { ErrorCode } from '../../types';
34
import { Button } from './Button';
45

56
interface HandledErrorAlertProps {
@@ -32,6 +33,18 @@ function toError(input: unknown): Error {
3233
return new Error('An unknown error occurred');
3334
}
3435

36+
function isPauseError(error: unknown): boolean {
37+
if (typeof error === 'object' && error !== null) {
38+
const appError = error as AppError;
39+
if (appError.code === ErrorCode.CONTRACT_ERROR) {
40+
const message = appError.message?.toLowerCase() || '';
41+
const details = appError.details?.toLowerCase() || '';
42+
return message.includes('paused') || details.includes('paused');
43+
}
44+
}
45+
return false;
46+
}
47+
3548
export function HandledErrorAlert({
3649
error,
3750
title = 'Something went wrong',
@@ -41,6 +54,35 @@ export function HandledErrorAlert({
4154
}: HandledErrorAlertProps) {
4255
const normalizedError = toError(error);
4356
const handled = ErrorHandler.toHandledError(normalizedError);
57+
const isPaused = isPauseError(error);
58+
59+
// Custom styling and messaging for pause errors
60+
if (isPaused) {
61+
return (
62+
<div className={`rounded-lg border border-orange-200 bg-orange-50 p-4 ${className}`} role="alert">
63+
<div className="flex items-start">
64+
<div className="flex-shrink-0">
65+
<svg className="h-5 w-5 text-orange-400" viewBox="0 0 20 20" fill="currentColor">
66+
<path fillRule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM9.555 7.168A1 1 0 008 8v4a1 1 0 001.555.832l3-2a1 1 0 000-1.664l-3-2z" clipRule="evenodd" />
67+
</svg>
68+
</div>
69+
<div className="ml-3 flex-1">
70+
<h4 className="font-medium text-orange-800">Protocol Maintenance</h4>
71+
<p className="mt-2 text-sm text-orange-700">{handled.message}</p>
72+
<p className="mt-2 text-sm text-orange-700">
73+
<span className="font-medium">What to do:</span> The protocol is temporarily paused for maintenance.
74+
Please wait a few minutes and try again, or contact support if the issue persists.
75+
</p>
76+
{onRecoveryAction && (
77+
<Button className="mt-3" variant="outline" onClick={onRecoveryAction}>
78+
Check Status Again
79+
</Button>
80+
)}
81+
</div>
82+
</div>
83+
</div>
84+
);
85+
}
4486

4587
return (
4688
<div className={`rounded-lg border border-red-200 bg-red-50 p-4 ${className}`} role="alert">

0 commit comments

Comments
 (0)