fix: 统一追溯码并修正天河链存证跳转

This commit is contained in:
Nixevol
2026-07-13 07:06:43 +08:00
parent 61d813a096
commit 09b9887a30
21 changed files with 79 additions and 98 deletions
@@ -22,7 +22,7 @@ function mockHttpsRequestOnce(responseJson: unknown, statusCode = 200) {
// 放在 jest.mock 之后导入,确保 provider 拿到被 mock 的 https
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { TianheProvider } = require('./tianhe.provider') as typeof import('./tianhe.provider');
const { TianheProvider, buildTianheExplorerTxUrl } = require('./tianhe.provider') as typeof import('./tianhe.provider');
describe('TianheProvider', () => {
const provider = new TianheProvider({
@@ -37,6 +37,16 @@ describe('TianheProvider', () => {
jest.restoreAllMocks();
});
it('按天河环境生成 DApp 浏览器交易详情地址', () => {
const txHash = '0xabc/123';
expect(buildTianheExplorerTxUrl('https://test.api.tichain.tianhecloud.com', txHash)).toBe(
'https://test.explorer.tianhecloud.com/#/tiChain/transDetail?hash=0xabc%2F123',
);
expect(
buildTianheExplorerTxUrl('https://custom-api.example.com', txHash, 'production'),
).toBe('https://explorer.tianhecloud.com/#/tiChain/transDetail?hash=0xabc%2F123');
});
it('按天河链 upload 文档映射交易哈希、存证链接和文件哈希', async () => {
const response = {
code: 0,