feat(swaptrade): 添加数量显示尾随零去除功能

- 在 swapPricePrecisionHelper 中实现 trimTailZeros 选项支持
- 修改 formatCommon 函数以支持尾随零去除逻辑
- 在 swapTradeView 中为数量类型添加 trimTailZeros 配置
- 添加测试用例验证数量显示的尾随零去除功能
- 确保配置精度在尾随零去除后保持不变
This commit is contained in:
张名锐
2026-08-07 17:57:16 +08:00
parent d78d1f48e7
commit 486f02dcd9
3 changed files with 13 additions and 2 deletions
@@ -135,6 +135,13 @@ describe('swap price precision common wiring', () => {
expect(helper.getCommonInputFormat('quantity', { append: '' }).grouping).toBe(false);
});
test('quantity display can trim trailing zeros without changing configured precision', () => {
const helper = loadHelper({ common: { quantity: { precision: 8, grouping: true } } });
expect(helper.formatCommon('quantity', '10000.12345600', { trimTailZeros: true }))
.toBe('10,000.123456');
expect(helper.formatCommon('quantity', '10000.12345600')).toBe('10,000.12345600');
});
test('missing or invalid asset quantity precision falls back to common quantity precision', () => {
const helper = loadHelper({
common: { quantity: { precision: 3, grouping: true } },