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;
}
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 {
if (network === 'BSC') return 'BEP20 · BSC';
if (network === 'TRON') return 'TRC20 · TRON';
@ -277,7 +283,9 @@ export function TreasuryAdminPage() {
id: string;
txId: string;
isGas?: boolean;
network?: string;
} | null>(null);
const [confirmError, setConfirmError] = useState<string | null>(null);
const [pendingMsg, setPendingMsg] = useState<string | null>(null);
const [fundingError, setFundingError] = 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 }),
onSuccess: () => {
setConfirmFunding(null);
setConfirmError(null);
setPendingMsg(t('admin.treasury.fundingConfirmed'));
void qc.invalidateQueries({ queryKey: ['admin-treasury-overview'] });
},
onError: (err) => {
setConfirmError(apiErrorMessage(err, t('admin.treasury.confirmFailed')));
},
});
const cancelFundingMut = useMutation({
@ -1083,7 +1096,13 @@ export function TreasuryAdminPage() {
<Button
size="small"
onClick={() =>
setConfirmFunding({ id: f.id, txId: '', isGas })
setConfirmFunding({
id: f.id,
txId: '',
isGas,
network: wt?.network,
})
setConfirmError(null);
}
>
{t('admin.treasury.confirmTx')}
@ -1337,44 +1356,78 @@ export function TreasuryAdminPage() {
</Stack>
)}
<PermissionGate permission="admin.treasury.manage">
<Dialog open={!!confirmFunding} onClose={() => setConfirmFunding(null)} maxWidth="sm" fullWidth>
<DialogTitle>{t('admin.treasury.confirmDialogTitle')}</DialogTitle>
<DialogContent>
<Typography variant="body2" sx={{ opacity: 0.7, mb: 1.5 }}>
{confirmFunding?.isGas
? t('admin.treasury.confirmDialogHintGas')
: t('admin.treasury.confirmDialogHint')}
</Typography>
<TextField
fullWidth
label={t('admin.treasury.blockchainTxId')}
margin="dense"
value={confirmFunding?.txId ?? ''}
onChange={(e) =>
setConfirmFunding((c) => (c ? { ...c, txId: e.target.value } : null))
<Dialog
open={!!confirmFunding}
onClose={() => {
setConfirmFunding(null);
setConfirmError(null);
}}
maxWidth="sm"
fullWidth
>
<DialogTitle>{t('admin.treasury.confirmDialogTitle')}</DialogTitle>
<DialogContent>
<Typography variant="body2" sx={{ opacity: 0.7, mb: 1.5 }}>
{confirmFunding?.isGas
? t('admin.treasury.confirmDialogHintGas')
: t('admin.treasury.confirmDialogHint')}
</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…"
/>
</DialogContent>
<DialogActions>
<Button onClick={() => setConfirmFunding(null)}>{t('common.cancel')}</Button>
<Button
variant="contained"
disabled={!confirmFunding?.txId || confirmFundingMut.isPending}
onClick={() =>
confirmFunding &&
void confirmFundingMut.mutateAsync({
id: confirmFunding.id,
blockchainTxId: confirmFunding.txId.trim(),
})
}
>
{t('common.confirm')}
</Button>
</DialogActions>
</Dialog>
</PermissionGate>
confirmFundingMut.mutate({
id: confirmFunding.id,
blockchainTxId: hash,
});
}}
>
{confirmFundingMut.isPending ? t('common.sending') : t('common.confirm')}
</Button>
</DialogActions>
</Dialog>
<Snackbar
open={!!copyToast}

View File

@ -1614,6 +1614,13 @@ export const en = {
amountRawCol: 'Amount (raw)',
confirmDialogTitle: 'Confirm cold → hot transfer',
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',
sweepPending:
'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',
confirmDialogHint:
'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',
sweepPending:
'Lot(s) de sweep soumis — approuvez sous Approvals pour diffuser l’USDT vers le cold.',