feat: 天河链 API 调用链路控制台日志(URL/方法/发送/返回,密钥脱敏)

- TianheProvider 三个传输方法统一打印请求与响应,appKey/userKey 脱敏
- OnchainProcessor 补确认查询开始/结果/失败日志,attest 成功带 txHash 与存证链接
This commit is contained in:
Nixevol
2026-07-10 10:13:11 +08:00
parent 6813d5bb34
commit 6e0db6eeb9
3 changed files with 46 additions and 4 deletions
+10 -2
View File
@@ -77,9 +77,9 @@ export class OnchainProcessor extends WorkerHost {
});
if (result.confirmationRequired) {
await this.scheduleConfirm(proofId, 1, FIRST_CONFIRM_DELAY_MS);
this.logger.log(`存证 ${proofId} 已提交链上,等待确认`);
this.logger.log(`存证 ${proofId} 已提交链上,等待确认:txHash=${result.txHash} 存证链接=${result.explorerUrl ?? '-'}`);
} else {
this.logger.log(`存证 ${proofId} 上链成功`);
this.logger.log(`存证 ${proofId} 上链成功:txHash=${result.txHash} blockHeight=${result.blockHeight ?? '-'}`);
}
} catch (e) {
const message = (e as Error).message;
@@ -107,8 +107,14 @@ export class OnchainProcessor extends WorkerHost {
return;
}
this.logger.log(`存证 ${proofId} 开始链上确认查询(第 ${attempt} 次${manual ? ',手动' : ''}):txHash=${proof.txHash}`);
try {
const result = await this.blockchain.confirmTransaction(proof.txHash);
this.logger.log(
`存证 ${proofId} 链上查询结果:confirmed=${result.confirmed} blockHash=${result.blockHash ?? '-'} ` +
`blockHeight=${result.blockHeight ?? '-'} status=${(result.raw as { status?: string })?.status ?? '-'} ` +
`响应=${JSON.stringify((result.raw as { response?: unknown })?.response ?? result.raw).slice(0, 300)}`,
);
if (result.confirmed) {
await this.prisma.blockchainProof.update({
where: { id: proofId },
@@ -141,8 +147,10 @@ export class OnchainProcessor extends WorkerHost {
await this.scheduleConfirm(proofId, attempt + 1, SECOND_CONFIRM_DELAY_MS);
} catch (e) {
const message = (e as Error).message;
this.logger.warn(`存证 ${proofId} 链上确认查询失败(第 ${attempt} 次):${message}`);
if (manual || attempt >= MAX_AUTO_CONFIRM_ATTEMPTS) {
await this.recordWaiting(proofId, proof.rawResponse, { error: message }, attempt, manual);
this.logger.warn(`存证 ${proofId} 自动确认已达上限,等待手动重新确认`);
return;
}
await this.recordWaiting(proofId, proof.rawResponse, { error: message }, attempt, manual);