feat: 优化消费者出证进度弹窗和证书文本
This commit is contained in:
@@ -105,4 +105,15 @@ describe('Consumer certificate lifecycle', () => {
|
||||
expect(row.certificateRequest).toBe(saved);
|
||||
expect(writes).toBe(1);
|
||||
});
|
||||
it('freezes only the artwork title and physical trace code, separated by a newline', async () => {
|
||||
const { service, prisma, row } = fixture('NONE');
|
||||
prisma.traceCode.findUnique.mockResolvedValue({
|
||||
shortCode: '295708006702', status: 'ACTIVE',
|
||||
artwork: { title: '风生水起莲花生肖青蛙手工茶器', status: 'ACTIVE', auditStatus: 'APPROVED' },
|
||||
proofs: [row],
|
||||
} as any);
|
||||
await service.request('295708006702');
|
||||
expect(prisma.blockchainProof.updateMany.mock.calls[0][0].data.certificateRequest.text)
|
||||
.toBe('风生水起莲花生肖青蛙手工茶器\n295708006702');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -81,14 +81,7 @@ export class DepositCertificateService {
|
||||
version: 1, environment, appId: settings.tianheAppId, address: settings.tianheWalletAddress,
|
||||
operateId: `avc${randomBytes(8).toString('hex')}`,
|
||||
// The official TEXT certificate prints this verbatim; use readable labels.
|
||||
text: [
|
||||
`作品:${code.artwork.title}`,
|
||||
`作者:${code.artwork.artist || '未填写'}`,
|
||||
`档案编号:${code.artwork.archiveNo}`,
|
||||
`实物追溯码:${code.shortCode}`,
|
||||
`数字身份交易:${proof.txHash}`,
|
||||
`证据记录时间:${now.toISOString()}`,
|
||||
].join(';'),
|
||||
text: `${code.artwork.title}\n${code.shortCode}`,
|
||||
};
|
||||
// A single conditional write claims this item; concurrent callers cannot
|
||||
// replace the winner's frozen evidence or operation id. No daily quota.
|
||||
|
||||
@@ -31,7 +31,7 @@ describe('V3 deposit protocol', () => {
|
||||
await expect(new DepositProvider('test', 'app', 'key').submit('addr', 'op', 'test')).rejects.toBeInstanceOf(DepositRejected);
|
||||
});
|
||||
it('binds the returned certificate to the exact frozen evidence and preserves reserved characters', async () => {
|
||||
const text = '作品:A&B + 100% #茶器';
|
||||
const text = 'A&B + 100% #茶器\n295708006702';
|
||||
const digest = createHash('sha256').update(text).digest('hex');
|
||||
const value = 'https://test.tichain.tianhecloud.com/#/certificate?depositContent=broken&type=TEXT&address=addr&txHash=0x' + 'a'.repeat(64) + '&digest=' + digest;
|
||||
jest.spyOn(global, 'fetch').mockResolvedValue({ ok: true, json: async () => ({ code: 200, success: true, data: value }) } as any);
|
||||
|
||||
Reference in New Issue
Block a user