After trying to recuparate money from cold wallet6

This commit is contained in:
Your Name 2026-08-28 17:09:37 +02:00
parent bb30e14dfe
commit c4e54dbe14
3 changed files with 105 additions and 38 deletions

View File

@ -167,6 +167,12 @@ function txExplorerUrl(network: string, txId: string): string | null {
return null; return null;
} }
function looksLikeFullTxHash(network: string, hash: string): boolean {
const h = hash.trim();
if (network === 'TRON') return /^[a-fA-F0-9]{64}$/.test(h);
return /^0x[a-fA-F0-9]{64}$/.test(h);
}
function networkLabel(network: string): string { function networkLabel(network: string): string {
if (network === 'BSC') return 'BEP20 · BSC'; if (network === 'BSC') return 'BEP20 · BSC';
if (network === 'TRON') return 'TRC20 · TRON'; if (network === 'TRON') return 'TRC20 · TRON';
@ -277,7 +283,9 @@ export function TreasuryAdminPage() {
id: string; id: string;
txId: string; txId: string;
isGas?: boolean; isGas?: boolean;
network?: string;
} | null>(null); } | null>(null);
const [confirmError, setConfirmError] = useState<string | null>(null);
const [pendingMsg, setPendingMsg] = useState<string | null>(null); const [pendingMsg, setPendingMsg] = useState<string | null>(null);
const [fundingError, setFundingError] = useState<string | null>(null); const [fundingError, setFundingError] = useState<string | null>(null);
const [gasError, setGasError] = useState<string | null>(null); const [gasError, setGasError] = useState<string | null>(null);
@ -419,8 +427,13 @@ export function TreasuryAdminPage() {
api.patch(`/api/v1/admin/treasury/funding/${id}/confirm`, { blockchainTxId }), api.patch(`/api/v1/admin/treasury/funding/${id}/confirm`, { blockchainTxId }),
onSuccess: () => { onSuccess: () => {
setConfirmFunding(null); setConfirmFunding(null);
setConfirmError(null);
setPendingMsg(t('admin.treasury.fundingConfirmed'));
void qc.invalidateQueries({ queryKey: ['admin-treasury-overview'] }); void qc.invalidateQueries({ queryKey: ['admin-treasury-overview'] });
}, },
onError: (err) => {
setConfirmError(apiErrorMessage(err, t('admin.treasury.confirmFailed')));
},
}); });
const cancelFundingMut = useMutation({ const cancelFundingMut = useMutation({
@ -1083,7 +1096,13 @@ export function TreasuryAdminPage() {
<Button <Button
size="small" size="small"
onClick={() => onClick={() =>
setConfirmFunding({ id: f.id, txId: '', isGas }) setConfirmFunding({
id: f.id,
txId: '',
isGas,
network: wt?.network,
})
setConfirmError(null);
} }
> >
{t('admin.treasury.confirmTx')} {t('admin.treasury.confirmTx')}
@ -1337,44 +1356,78 @@ export function TreasuryAdminPage() {
</Stack> </Stack>
)} )}
<PermissionGate permission="admin.treasury.manage"> <Dialog
<Dialog open={!!confirmFunding} onClose={() => setConfirmFunding(null)} maxWidth="sm" fullWidth> open={!!confirmFunding}
<DialogTitle>{t('admin.treasury.confirmDialogTitle')}</DialogTitle> onClose={() => {
<DialogContent> setConfirmFunding(null);
<Typography variant="body2" sx={{ opacity: 0.7, mb: 1.5 }}> setConfirmError(null);
{confirmFunding?.isGas }}
? t('admin.treasury.confirmDialogHintGas') maxWidth="sm"
: t('admin.treasury.confirmDialogHint')} fullWidth
</Typography> >
<TextField <DialogTitle>{t('admin.treasury.confirmDialogTitle')}</DialogTitle>
fullWidth <DialogContent>
label={t('admin.treasury.blockchainTxId')} <Typography variant="body2" sx={{ opacity: 0.7, mb: 1.5 }}>
margin="dense" {confirmFunding?.isGas
value={confirmFunding?.txId ?? ''} ? t('admin.treasury.confirmDialogHintGas')
onChange={(e) => : t('admin.treasury.confirmDialogHint')}
setConfirmFunding((c) => (c ? { ...c, txId: e.target.value } : null)) </Typography>
<Typography variant="body2" sx={{ opacity: 0.7, mb: 1.5 }}>
{t('admin.treasury.confirmDialogCopyHint')}
</Typography>
<TextField
fullWidth
label={t('admin.treasury.blockchainTxId')}
margin="dense"
value={confirmFunding?.txId ?? ''}
onChange={(e) => {
setConfirmError(null);
setConfirmFunding((c) => (c ? { ...c, txId: e.target.value } : null));
}}
placeholder={confirmFunding?.network === 'TRON' ? '64 hex characters' : '0x… (66 characters)'}
helperText={t('admin.treasury.txHashLength', {
count: (confirmFunding?.txId ?? '').trim().length,
expected: confirmFunding?.network === 'TRON' ? 64 : 66,
})}
/>
{confirmError && (
<Alert severity="error" sx={{ mt: 1.5 }} onClose={() => setConfirmError(null)}>
{confirmError}
</Alert>
)}
</DialogContent>
<DialogActions>
<Button
type="button"
onClick={() => {
setConfirmFunding(null);
setConfirmError(null);
}}
>
{t('common.cancel')}
</Button>
<Button
type="button"
variant="contained"
disabled={!confirmFunding?.txId?.trim() || confirmFundingMut.isPending}
onClick={() => {
if (!confirmFunding) return;
const hash = confirmFunding.txId.trim();
const network = confirmFunding.network ?? 'BSC';
if (!looksLikeFullTxHash(network, hash)) {
setConfirmError(t('admin.treasury.invalidTxHash'));
return;
} }
placeholder="0x…" confirmFundingMut.mutate({
/> id: confirmFunding.id,
</DialogContent> blockchainTxId: hash,
<DialogActions> });
<Button onClick={() => setConfirmFunding(null)}>{t('common.cancel')}</Button> }}
<Button >
variant="contained" {confirmFundingMut.isPending ? t('common.sending') : t('common.confirm')}
disabled={!confirmFunding?.txId || confirmFundingMut.isPending} </Button>
onClick={() => </DialogActions>
confirmFunding && </Dialog>
void confirmFundingMut.mutateAsync({
id: confirmFunding.id,
blockchainTxId: confirmFunding.txId.trim(),
})
}
>
{t('common.confirm')}
</Button>
</DialogActions>
</Dialog>
</PermissionGate>
<Snackbar <Snackbar
open={!!copyToast} open={!!copyToast}

View File

@ -1614,6 +1614,13 @@ export const en = {
amountRawCol: 'Amount (raw)', amountRawCol: 'Amount (raw)',
confirmDialogTitle: 'Confirm cold → hot transfer', confirmDialogTitle: 'Confirm cold → hot transfer',
confirmDialogHint: 'Paste the blockchain transaction hash after you sent USDT from cold to hot.', confirmDialogHint: 'Paste the blockchain transaction hash after you sent USDT from cold to hot.',
confirmDialogCopyHint:
'In MetaMask, open the Sent USDT receipt and tap the copy icon next to Transaction ID. Do not type the shortened 0x939e8…a37af value. A BNB hash is 66 characters (0x + 64 hex).',
txHashLength: '{{count}} / {{expected}} characters',
invalidTxHash:
'This is not a full transaction hash. Tap Copy next to Transaction ID in MetaMask, or open “View on block explorer” and copy the complete hash.',
confirmFailed: 'Could not confirm this transfer',
fundingConfirmed: 'Cold → hot transfer recorded.',
blockchainTxId: 'Blockchain transaction ID', blockchainTxId: 'Blockchain transaction ID',
sweepPending: sweepPending:
'Sweep batch(es) submitted — approve under Approvals to broadcast USDT to cold.', 'Sweep batch(es) submitted — approve under Approvals to broadcast USDT to cold.',

View File

@ -1631,6 +1631,13 @@ export const fr = {
confirmDialogTitle: 'Confirmer le transfert cold → hot', confirmDialogTitle: 'Confirmer le transfert cold → hot',
confirmDialogHint: confirmDialogHint:
'Collez le hash de transaction après avoir envoyé l’USDT du cold vers le hot.', 'Collez le hash de transaction après avoir envoyé l’USDT du cold vers le hot.',
confirmDialogCopyHint:
'Dans MetaMask, ouvrez le reçu « Sent USDT » et appuyez sur l’icône copier à côté de Transaction ID. Ne retapez pas la valeur raccourcie 0x939e8…a37af. Un hash BNB fait 66 caractères (0x + 64 hex).',
txHashLength: '{{count}} / {{expected}} caractères',
invalidTxHash:
'Ce n’est pas un hash complet. Copiez-le via l’icône à côté de Transaction ID dans MetaMask, ou via « View on block explorer ».',
confirmFailed: 'Impossible de confirmer ce transfert',
fundingConfirmed: 'Transfert cold → hot enregistré.',
blockchainTxId: 'ID transaction blockchain', blockchainTxId: 'ID transaction blockchain',
sweepPending: sweepPending:
'Lot(s) de sweep soumis — approuvez sous Approvals pour diffuser l’USDT vers le cold.', 'Lot(s) de sweep soumis — approuvez sous Approvals pour diffuser l’USDT vers le cold.',