feat: 接入天河链延时确认

This commit is contained in:
Nixevol
2026-07-06 19:30:31 +08:00
parent e6caed498f
commit 628a5a4465
14 changed files with 243 additions and 12 deletions
@@ -37,5 +37,32 @@ describe('TianheProvider', () => {
expect(result.explorerUrl).toBe(response.data.url);
expect(result.raw.digest).toBe(response.data.digest);
expect(result.raw.transactionStatus).toBe('submitted');
expect(result.confirmationRequired).toBe(true);
});
it('按交易状态接口确认链上区块信息', async () => {
const response = {
code: 0,
message: 'success',
data: {
status: '0x0',
blockHash: '0xblockhash',
blockNum: 12345,
transactionHash: '0x1234567890abcdef',
tokenId: -999,
},
};
jest.spyOn(globalThis, 'fetch').mockResolvedValue({
ok: true,
text: async () => JSON.stringify(response),
} as Response);
const result = await provider.confirmTransaction(response.data.transactionHash);
expect(result.confirmed).toBe(true);
expect(result.txHash).toBe(response.data.transactionHash);
expect(result.blockHash).toBe(response.data.blockHash);
expect(result.blockHeight).toBe(response.data.blockNum);
expect(result.raw.transactionStatus).toBe('confirmed');
});
});