fix: 优化天河链确认策略

This commit is contained in:
Nixevol
2026-07-06 19:43:00 +08:00
parent 628a5a4465
commit 7480e4d256
9 changed files with 107 additions and 22 deletions
@@ -78,4 +78,23 @@ export class AttestationService {
await this.queue.add('onchain', { proofId });
return { success: true };
}
async confirm(proofId: number) {
const proof = await this.prisma.blockchainProof.findUnique({ where: { id: proofId } });
if (!proof) throw new BusinessException(ErrorCode.NOT_FOUND, '存证记录不存在', 404);
if (proof.status === ProofStatus.ONCHAIN) return { success: true };
if (!proof.txHash) throw new BusinessException(ErrorCode.BAD_REQUEST, '缺少交易哈希,无法重新确认');
await this.prisma.blockchainProof.update({
where: { id: proofId },
data: {
status: ProofStatus.CONFIRMING,
rawResponse: {
...(proof.rawResponse && typeof proof.rawResponse === 'object' ? (proof.rawResponse as object) : {}),
manualConfirmQueuedAt: new Date().toISOString(),
},
},
});
await this.queue.add('confirm-onchain', { proofId, action: 'confirm', confirmAttempt: 1, manual: true });
return { success: true };
}
}