fix: 优化天河链确认策略
This commit is contained in:
@@ -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 };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user