feat: 实现存储抽象、任务队列与区块链/归属地 Mock 适配
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { Logger } from '@nestjs/common';
|
||||
import { AttestPayload, AttestResult, AttestationProvider } from './blockchain.types';
|
||||
|
||||
export interface TianheOptions {
|
||||
baseUrl: string;
|
||||
appId: string;
|
||||
appKey: string;
|
||||
}
|
||||
|
||||
// 天河链存证适配器(接入细节待确认,预留对接)。
|
||||
// 已知:纯存证接口 POST /api/v2/nfr/upload,appId/appKey 直接鉴权;
|
||||
// 待确认:完整返回字段、存证查询链接、是否需注册托管钱包等。
|
||||
// 确认后在 attest() 内补全真实请求与字段映射即可,对上层 BlockchainService 透明。
|
||||
export class TianheProvider implements AttestationProvider {
|
||||
readonly name = 'tianhe';
|
||||
private readonly logger = new Logger(TianheProvider.name);
|
||||
|
||||
constructor(private readonly opts: TianheOptions) {}
|
||||
|
||||
async attest(_payload: AttestPayload): Promise<AttestResult> {
|
||||
if (!this.opts.appId || !this.opts.appKey || !this.opts.baseUrl) {
|
||||
throw new Error('天河链未配置(TIANHE_APP_ID/APP_KEY/BASE_URL),请在 .env 配置后再启用 BLOCKCHAIN_DRIVER=tianhe');
|
||||
}
|
||||
// TODO: 待天河链接入细节确认后实现真实存证请求与返回字段映射。
|
||||
this.logger.warn('天河链真实接入尚未实现,请先使用 BLOCKCHAIN_DRIVER=mock');
|
||||
throw new Error('天河链真实接入待确认,请暂用 BLOCKCHAIN_DRIVER=mock');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user