@lifi/widget 4.0.0-alpha.1 → 4.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/i18n/zh.json DELETED
@@ -1,357 +0,0 @@
1
- {
2
- "language": {
3
- "name": "中文",
4
- "title": "语言"
5
- },
6
- "format": {
7
- "currency": "{{value, currencyExt(currency: USD)}}",
8
- "number": "{{value, number(maximumFractionDigits: 9)}}",
9
- "percent": "{{value, percent(maximumFractionDigits: 2)}}",
10
- "tokenAmount": "{{value, numberExt}}"
11
- },
12
- "button": {
13
- "auto": "自动",
14
- "bookmark": "收藏",
15
- "bookmarks": "收藏夹",
16
- "bridge": "跨链",
17
- "bridgeReview": "查看跨链详情",
18
- "buy": "购买",
19
- "cancel": "取消",
20
- "checkoutReview": "查看购买详情",
21
- "close": "关闭",
22
- "confirm": "确认",
23
- "connectAnotherWallet": "连接另一个钱包",
24
- "connectChainWallet": "",
25
- "connectWallet": "关联钱包",
26
- "contactSupport": "联系技术支持",
27
- "continue": "继续",
28
- "copyAddress": "复制地址",
29
- "dark": "深色主题",
30
- "delete": "删除",
31
- "deposit": "存款",
32
- "depositReview": "查看存款详情",
33
- "disconnect": "断开连接",
34
- "done": "确认",
35
- "exchange": "兑换",
36
- "getGas": "开始兑换燃气费",
37
- "learnMore": "了解更多",
38
- "light": "浅色主题",
39
- "max": "",
40
- "ok": "确认",
41
- "options": "选项",
42
- "removeTransaction": "删除交易",
43
- "reset": "重置",
44
- "resetSettings": "恢复默认设置",
45
- "seeDetails": "查看详情",
46
- "showAll": "显示所有",
47
- "startBridging": "开始跨链",
48
- "startSwapping": "开始兑换",
49
- "swap": "兑换",
50
- "swapReview": "查看兑换详情",
51
- "system": "",
52
- "tryAgain": "重试",
53
- "viewCoverage": "查看我们的覆盖范围",
54
- "viewOnExplorer": "在区块链浏览器上查看"
55
- },
56
- "header": {
57
- "activeTransactions": "进行中的交易",
58
- "amount": "金额",
59
- "bookmarkedWallets": "已收藏的钱包",
60
- "bridge": "跨链",
61
- "checkout": "支付",
62
- "checkoutDetails": "交易细节",
63
- "deposit": "存款",
64
- "depositDetails": "存款详情",
65
- "depositTo": "充币至",
66
- "exchange": "兑换",
67
- "from": "兑换自",
68
- "gas": "燃气费",
69
- "payWith": "支付方式",
70
- "receive": "接收",
71
- "received": "",
72
- "recentWallets": "最近使用的钱包",
73
- "refunded": "",
74
- "selectChain": "选择网络",
75
- "selectWallet": "选择你的钱包",
76
- "send": "发送",
77
- "sendToWallet": "发送到该钱包",
78
- "settings": "设置",
79
- "swap": "兑换",
80
- "to": "兑换为",
81
- "transactionDetails": "交易详情",
82
- "transactionHistory": "交易记录",
83
- "walletConnected": "连接钱包",
84
- "youGet": "您获得",
85
- "youPay": "需要支付"
86
- },
87
- "info": {
88
- "message": {
89
- "accountDeployedMessage": "",
90
- "autoRefuel": "您在 {{chainName}} 链上的燃气费很低。如果启用该选项,您将获得足够的燃气费完成此次兑换。",
91
- "emptyActiveTransactions": "正在进行的兑换将在这里显示。一旦完成,你可在兑换记录中找到它们。",
92
- "emptyBridgesList": "我们找不到任何匹配的桥",
93
- "emptyChainList": "我们找不到任何匹配的链",
94
- "emptyExchangesList": "我们找不到任何匹配的交易所",
95
- "emptyTokenListAllNetworks": "",
96
- "emptyTransactionHistory": "交易记录只存储在本地,如果您清除浏览器数据,交易记录将被删除。",
97
- "routeNotFound": "导致其的原因可能是:流动性低,所选定代币的数额太低,燃气费过高,或者当前没有合适的交易路径。",
98
- "toAddressIsRequired": "需要目标钱包地址来继续转帐。",
99
- "missingRouteRequiredAccount": ""
100
- },
101
- "title": {
102
- "autoRefuel": "获得 {{chainName}} 链的燃气费",
103
- "emptyActiveTransactions": "没有正在进行的交易",
104
- "emptyTransactionHistory": "近期无交易",
105
- "routeNotFound": "没有可用的路由"
106
- }
107
- },
108
- "success": {
109
- "message": {
110
- "exchangePartiallySuccessful": "我们尝试执行这笔交易,但是因为滑点设置的问题或者 {{tokenSymbol}} 代币流动性不足,{{tool}} 无法完成交易"
111
- },
112
- "title": {
113
- "bridgePartiallySuccessful": "跨链部分成功",
114
- "bridgeSuccessful": "跨链成功",
115
- "depositSuccessful": "存款成功",
116
- "checkoutSuccessful": "购买成功",
117
- "refundIssued": "退款已受理",
118
- "swapPartiallySuccessful": "兑换部分完成",
119
- "swapSuccessful": "兑换成功"
120
- }
121
- },
122
- "warning": {
123
- "message": {
124
- "accountNotDeployedMessage": "",
125
- "lowAddressActivity": "此地址在 {{chainName}} 网络上的活跃度较低。请确认您发送到了正确的地址和网络,以防止潜在的资金损失。",
126
- "deleteActiveTransactions": "正在进行的交易记录只存储在本地,如果删除它们,我们将无法恢复这些记录。",
127
- "deleteTransactionHistory": "交易记录只存储在本地,如果你删除它,我们将无法恢复这些记录。",
128
- "fundsLossPrevention": "总是确保在目的地链上适当建立智能合同账户,并避免直接转给交易所,以防止资金损失。",
129
- "highValueLoss": "收到的代币的价值明显低于要被兑换的代币和交易成本。",
130
- "unverifiedToken": "",
131
- "insufficientFunds": "你没有足够的资金来完成这笔交易。",
132
- "insufficientGas": "您没有足够的燃气费来完成此次交易。您至少需要添加:",
133
- "minFromAmountUSD": "",
134
- "rateChanged": "兑换比例已经改变,如果继续兑换,您将接受新的兑换比例。",
135
- "resetSettings": "这将重置您的路由优先级,滑点,燃气费,选中的跨链桥和链上交易所。",
136
- "slippageOutsideRecommendedLimits": "过高的滑点可能会导致交易被抢跑,造成财产损失",
137
- "slippageUnderRecommendedLimits": "低幻灯片宽度可能会导致交易延迟或失败。"
138
- },
139
- "title": {
140
- "deleteActiveTransactions": "确定要删除所有正在进行的交易吗?",
141
- "deleteTransaction": "确定要删除该交易吗?",
142
- "deleteTransactionHistory": "确定要清空交易记录吗?",
143
- "highValueLoss": "大额资金损失",
144
- "insufficientGas": "燃气费不足",
145
- "rateChanged": "兑换比例变动",
146
- "resetSettings": "确定要恢复默认设置吗?",
147
- "lowAddressActivity": "低活动地址"
148
- }
149
- },
150
- "error": {
151
- "message": {
152
- "allowanceRequired": "{{tokenSymbol}} 的转账金额超过了您设置的支出上限。请提高该代币的支出上限,然后重试。",
153
- "insufficientFunds": "您没有足够的燃气费支付该交易。",
154
- "rateLimitExceeded": "",
155
- "remainInYourWallet": "",
156
- "signatureRejected": "",
157
- "slippageThreshold": "滑点大于预设值,请选择其他路由并获取新的价格。",
158
- "thirdPartyError": "",
159
- "transactionCanceled": "交易已被取消。",
160
- "transactionConflict": "交易无法处理,因为它与使用相同资金的另一个待处理交易相冲突。 请等待交易确认或检查您的交易历史,然后再次尝试。",
161
- "transactionExpired": "区块高度已超过允许的最大值,或者交易哈希值已经过期。",
162
- "transactionRejected": "",
163
- "transactionFailed": "请查看区块浏览器以了解更多信息。",
164
- "transactionNotSent": "交易未能发送。",
165
- "transactionSimulationFailed": "该交易模拟执行失败。",
166
- "unknown": "请再试一次或者联系支持。",
167
- "walletChangedDuringExecution": "询价的钱包地址与试图签署交易的钱包地址不匹配,请确保在整个交易执行过程中使用相同的钱包地址。"
168
- },
169
- "title": {
170
- "allowanceRequired": "余额不足",
171
- "balanceIsTooLow": "余额太低",
172
- "bookmarkAlreadyExists": "钱包: {{name}},已被收藏",
173
- "bookmarkNameRequired": "请输入收藏钱包的名称",
174
- "chainSwitch": "请切换当前网络",
175
- "exchangeRateUpdateCanceled": "兑换率更新已取消",
176
- "gasLimitIsTooLow": "燃气费设置过低",
177
- "insufficientFunds": "资金不足",
178
- "insufficientGas": "",
179
- "rateLimitExceeded": "",
180
- "signatureRejected": "交易需要签名。",
181
- "slippageNotMet": "滑点未满足",
182
- "thirdPartyError": "",
183
- "transactionCanceled": "交易取消",
184
- "transactionConflict": "交易冲突",
185
- "transactionExpired": "交易过期",
186
- "transactionFailed": "交易失败",
187
- "transactionRejected": "",
188
- "transactionSimulationFailed": "交易模拟失败",
189
- "transactionUnderpriced": "交易定价过低",
190
- "transactionUnprepared": "无法开始该交易",
191
- "unknown": "未知错误",
192
- "walletAddressInvalid": "钱包地址或域名无效",
193
- "walletAddressInvalid_chain": "钱包地址或者域名在所选中的 {{chainName}} 链无效",
194
- "walletAddressRequired": "请输入钱包地址。",
195
- "walletChainTypeInvalid": "钱包地址与所选中目标的 {{chainName}} 链不匹配",
196
- "walletMismatch": "钱包地址不匹配"
197
- }
198
- },
199
- "tooltip": {
200
- "deselectAll": "取消全选",
201
- "estimatedTime": "",
202
- "feeCollection": "",
203
- "minReceived": "在签署兑换或者跨链交易之前, 预估的最低代币数量可能会变化,对于两步交易,这适用于第二步交易签署之前。",
204
- "notFound": {
205
- "text": "我们找不到这个页面。",
206
- "title": "404"
207
- },
208
- "multistep": "",
209
- "gasless": "",
210
- "numberOfSteps": "每次代币兑换包含了一到两次需要签名的交易。",
211
- "priceImpact": "源代币和目标代币之间的估计差值。",
212
- "progressToNextUpdate": "数据将在{{value}} 秒后自动刷新,点击这里可以手动更新。",
213
- "selectAll": "全选",
214
- "settingsModified": "设置(已修改)",
215
- "slippage": "真实的成交价位与预设的成交价位间相差的最大百分比。该值可以在设置中更改。"
216
- },
217
- "main": {
218
- "allNetworks": "",
219
- "allTokens": "所有代币",
220
- "bridgeStepDetails": "通过 {{tool}} 把资产从 {{from}} 链跨到 {{to}} 链上",
221
- "checkoutStepDetails": "通过 {{tool}} 购买",
222
- "currentAmount": "当前余额",
223
- "depositStepDetails": "通过 {{tool}} 存入资金",
224
- "featuredTokens": "精选代币",
225
- "fees": {
226
- "defaultIntegrator": "集成商费用",
227
- "relayerService": "",
228
- "estimated": "预估总费用",
229
- "free": "",
230
- "network": "网络费用",
231
- "paid": "已支付的费用",
232
- "provider": "供应商费用"
233
- },
234
- "from": "从",
235
- "inProgress": "进行中",
236
- "maxSlippage": "最大滑点",
237
- "minReceived": "最少收到",
238
- "myTokens": "我的代币",
239
- "onChain": "在{{chainName}} 上",
240
- "ownedBy": "属于",
241
- "pinnedTokens": "",
242
- "popularTokens": "热门代币",
243
- "priceImpact": "价格冲击",
244
- "process": {
245
- "bridge": {
246
- "actionRequired": "",
247
- "messageRequired": "",
248
- "done": "跨链交易已确认",
249
- "pending": "",
250
- "started": "准备执行跨链交易"
251
- },
252
- "checkout": {
253
- "done": "购买完成"
254
- },
255
- "deposit": {
256
- "done": "已完成存款"
257
- },
258
- "receivingChain": {
259
- "done": "跨链完成",
260
- "partial": "跨链部分完成",
261
- "pending": "等待接收链回应",
262
- "refunded": "跨链交易资产已退还"
263
- },
264
- "swap": {
265
- "actionRequired": "",
266
- "messageRequired": "",
267
- "done": "兑换完成",
268
- "pending": "",
269
- "started": "准备兑换"
270
- },
271
- "permit": {
272
- "actionRequired": "",
273
- "done": "",
274
- "pending": "",
275
- "started": ""
276
- },
277
- "tokenAllowance": {
278
- "actionRequired": "",
279
- "resetRequired": "",
280
- "done": "",
281
- "pending": "",
282
- "started": ""
283
- }
284
- },
285
- "quotedAmount": "报价金额",
286
- "rateChange": "波动率",
287
- "receiving": "接收",
288
- "refuelStepDetails": "通过 {{tool}} 获取燃气费",
289
- "selectChain": "选择网络",
290
- "selectChainAndToken": "选择链和代币",
291
- "selectToken": "选择代币",
292
- "sendToAddress": "发送到{{address}}",
293
- "sendToWallet": "发送到另外的钱包",
294
- "sending": "发送中",
295
- "sentToAddress": "发送到{{address}}",
296
- "stepBridge": "跨链",
297
- "stepBridgeAndBuy": "跨链并购买",
298
- "stepBridgeAndDeposit": "跨链并存款",
299
- "stepBuy": "购买",
300
- "stepDeposit": "存款",
301
- "stepDetails": "通过 LI.FI {{tool}}",
302
- "stepSwap": "兑换",
303
- "stepSwapAndBridge": "兑换和跨链",
304
- "stepSwapAndBuy": "兑换并购买",
305
- "stepSwapAndDeposit": "兑换并存款",
306
- "swapStepDetails": "通过{{tool}}在{{chain}}链上兑换代币",
307
- "transferId": "交易 ID",
308
- "tags": {
309
- "cheapest": "最佳报价",
310
- "fastest": "速度最快",
311
- "gasless": "",
312
- "multistep": ""
313
- },
314
- "to": "到",
315
- "tokenOnChain": "{{chainName}}链上的{{tokenSymbol}}",
316
- "tokenOnChainAmount": "",
317
- "tokenSearch": "",
318
- "valueLoss": "资金损失",
319
- "searchBridges": "搜索跨链桥",
320
- "searchExchanges": "搜索交易所",
321
- "searchNetwork": ""
322
- },
323
- "settings": {
324
- "appearance": "",
325
- "enabledBridges": "跨链桥",
326
- "enabledExchanges": "交易所",
327
- "gasPrice": {
328
- "fast": "快速",
329
- "normal": "正常",
330
- "slow": "缓慢",
331
- "title": "燃气费"
332
- },
333
- "routePriority": "路由优先级",
334
- "slippage": "最大滑点",
335
- "custom": "自定义",
336
- "resetSettings": "您正在使用自定义设置来过滤可用路由。",
337
- "hideSmallBalances": ""
338
- },
339
- "sendToWallet": {
340
- "addBookmark": "添加到收藏",
341
- "bookmarkWallet": "已收藏的钱包",
342
- "confirmWalletAddress": "确认钱包地址",
343
- "connectedWallets": "已连接的钱包",
344
- "enterAddress_long": "请输入地址或钱包域名",
345
- "enterAddress_short": "请输入钱包地址",
346
- "enterName": "输入名称",
347
- "noBookmarkedWallets": "没有收藏的钱包",
348
- "noConnectedWallets": "没有已连接的钱包",
349
- "noRecentWallets": "没有最近使用的钱包"
350
- },
351
- "tokenMetric": {
352
- "currentPrice": "",
353
- "contractAddress": "",
354
- "marketCap": "",
355
- "volume24h": ""
356
- }
357
- }
@@ -1,67 +0,0 @@
1
- import { describe, expect, it } from 'vitest'
2
- import { compactNumberFormatter } from './compactNumberFormatter.js'
3
-
4
- describe('Compact Number Formatter', () => {
5
- describe('basic formatting', () => {
6
- const testCases = [
7
- { input: '0.123456789', expected: '0.123456' },
8
- { input: '0.0123456', expected: '0.012345' },
9
- { input: '0.00123456', expected: '0.001234' },
10
- { input: '0.000123456', expected: '0.000123' },
11
- { input: '0.06942', expected: '0.06942' },
12
- { input: '0.006942', expected: '0.006942' },
13
- { input: '0.0006942', expected: '0.000694' },
14
- { input: '0.00006942', expected: '0.0₄6942' },
15
- { input: '0.00000123456', expected: '0.0₅1234' },
16
- { input: '0.000006942', expected: '0.0₅6942' },
17
- { input: '0.00000000001', expected: '0.0₁₀1' },
18
- { input: '0.00000006942', expected: '0.0₇6942' },
19
- { input: '0.0000000694269', expected: '0.0₇6942' },
20
- { input: '0.0000000694069', expected: '0.0₇694' },
21
- { input: '0.000000006942', expected: '0.0₈6942' },
22
- {
23
- input: '0.000000000000006942',
24
- expected: '0.0₁₄6942',
25
- },
26
- { input: '-0.0000042', expected: '-0.0₅42' },
27
- { input: '-0.000000042', expected: '-0.0₇42' },
28
- { input: '1.0000000042', expected: '1.0₈42' },
29
- { input: '123456789.00042', expected: '123456789.00042' },
30
- {
31
- input: '123456789.000042',
32
- expected: '123456789.0₄42',
33
- },
34
- {
35
- input: '123456789.0000042',
36
- expected: '123456789.0₅42',
37
- },
38
- { input: '1234567.000000042', expected: '1234567.0₇42' },
39
- {
40
- input: '1234567.000000042',
41
- expected: '1,234,567.0₇42',
42
- lng: 'en',
43
- useGrouping: true,
44
- },
45
- {
46
- input: '1234567.987654321',
47
- expected: '1,234,567.987654',
48
- lng: 'en',
49
- useGrouping: true,
50
- },
51
- {
52
- input: '1234567.000000042',
53
- expected: '1.234.567,0₇42',
54
- lng: 'de',
55
- useGrouping: true,
56
- },
57
- ]
58
-
59
- testCases.forEach(({ input, expected, lng, useGrouping = false }) => {
60
- it(`should format ${input} correctly`, () => {
61
- expect(compactNumberFormatter(lng, { useGrouping })(input)).toBe(
62
- expected
63
- )
64
- })
65
- })
66
- })
67
- })
@@ -1,53 +0,0 @@
1
- import { describe, expect, it } from 'vitest'
2
- import { formatInputAmount } from './format.js'
3
-
4
- describe('formatInputAmount', () => {
5
- it('should handle empty input', () => {
6
- expect(formatInputAmount('')).toBe('')
7
- })
8
-
9
- it('should handle whitespace input', () => {
10
- expect(formatInputAmount(' ')).toBe('')
11
- })
12
-
13
- it('should limit decimals', () => {
14
- expect(formatInputAmount('123.456789', 2, true)).toBe('123.45')
15
- expect(formatInputAmount('123.456789', 2, false)).toBe('123.45')
16
- })
17
-
18
- it('should handle leading and trailing zeros', () => {
19
- expect(formatInputAmount('00123', 2, true)).toBe('00123')
20
- expect(formatInputAmount('00123', 2, false)).toBe('123')
21
- expect(formatInputAmount('123.45000', 6, true)).toBe('123.45000')
22
- expect(formatInputAmount('123.45000', 6, false)).toBe('123.45')
23
- })
24
-
25
- it('should handle invalid input', () => {
26
- expect(formatInputAmount('abc')).toBe('')
27
- expect(formatInputAmount('-')).toBe('')
28
- expect(formatInputAmount('123.456789abc', 2, true)).toBe('123.45')
29
- expect(formatInputAmount('123.456789abc', 2, false)).toBe('123.45')
30
- })
31
-
32
- it('should normalize input (trim, commas, multiple dots)', () => {
33
- expect(formatInputAmount(' 1,23 ', null, true)).toBe('1.23')
34
- expect(formatInputAmount(' 1,23 ', null, false)).toBe('1.23')
35
- expect(formatInputAmount('1.2.3', null, true)).toBe('1.23')
36
- expect(formatInputAmount('1.2.3', null, false)).toBe('1.23')
37
- expect(formatInputAmount('..5', null, true)).toBe('.5')
38
- expect(formatInputAmount('..5', null, false)).toBe('0.5')
39
- })
40
-
41
- it('should handle zero input', () => {
42
- expect(formatInputAmount('0', null, true)).toBe('0')
43
- expect(formatInputAmount('00', null, true)).toBe('00')
44
- expect(formatInputAmount('0.00', 2, true)).toBe('0.00')
45
- expect(formatInputAmount('.0', 2, true)).toBe('.0')
46
- expect(formatInputAmount('0..', 2, true)).toBe('0.')
47
- expect(formatInputAmount('0', null, false)).toBe('')
48
- expect(formatInputAmount('00', null, false)).toBe('')
49
- expect(formatInputAmount('0.00', 2, false)).toBe('')
50
- expect(formatInputAmount('.0', 2, false)).toBe('')
51
- expect(formatInputAmount('0..', 2, false)).toBe('')
52
- })
53
- })
package/tsconfig.json DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "composite": true,
5
- "declaration": true,
6
- "sourceMap": true,
7
- "outDir": "dist/esm",
8
- "rootDir": "./src",
9
- "module": "ESNext",
10
- "moduleResolution": "Bundler",
11
- "skipLibCheck": true
12
- },
13
- "include": ["./src/**/*", "./src/**/*.json"],
14
- "references": [{ "path": "../wallet-management" }]
15
- }