|
1 | 1 | import { useMemo, useState } from 'react'; |
2 | 2 | import type { DeploymentResult, TokenDeployParams, WalletState } from '../../types'; |
3 | 3 | import { useTokenDeploy } from '../../hooks/useTokenDeploy'; |
| 4 | +import { useFactoryState } from '../../hooks/useFactoryState'; |
4 | 5 | import { formatXLM, truncateAddress } from '../../utils/formatting'; |
5 | 6 | import { BasicInfoStep, type BasicInfoData } from './BasicInfoStep'; |
6 | 7 | import { FeeDisplay } from './FeeDisplay'; |
@@ -30,6 +31,9 @@ export function TokenDeployForm({ |
30 | 31 |
|
31 | 32 | const { deploy, reset, status, statusMessage, isDeploying, error, getFeeBreakdown } = |
32 | 33 | useTokenDeploy(wallet.network); |
| 34 | + |
| 35 | + const { isPaused, loading: pauseLoading, error: pauseError, refresh: refreshPauseState } = |
| 36 | + useFactoryState({ network: wallet.network, pollingInterval: 30000 }); |
33 | 37 |
|
34 | 38 | const hasMetadataInput = Boolean(metadataDescription.trim() || metadataImage); |
35 | 39 | const feeBreakdown = useMemo( |
@@ -175,6 +179,48 @@ export function TokenDeployForm({ |
175 | 179 | </p> |
176 | 180 | </div> |
177 | 181 |
|
| 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 | + |
178 | 224 | {!wallet.connected ? ( |
179 | 225 | <div className="rounded-lg border border-yellow-200 bg-yellow-50 p-4"> |
180 | 226 | <p className="text-sm text-yellow-800">Connect your wallet to continue deployment.</p> |
@@ -269,10 +315,11 @@ export function TokenDeployForm({ |
269 | 315 | loading={isDeploying} |
270 | 316 | loadingText={status === 'uploading' ? 'Uploading...' : 'Deploying...'} |
271 | 317 | className="w-full" |
272 | | - disabled={!wallet.connected} |
| 318 | + disabled={!wallet.connected || isPaused || pauseLoading} |
273 | 319 | data-tutorial="deploy-button" |
| 320 | + title={isPaused ? 'Protocol is paused for maintenance' : undefined} |
274 | 321 | > |
275 | | - Deploy Token |
| 322 | + {isPaused ? 'Protocol Paused' : 'Deploy Token'} |
276 | 323 | </LoadingButton> |
277 | 324 | </div> |
278 | 325 | </div> |
|
0 commit comments