Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit 29626e5

Browse files
author
Alex Luu
committed
add changelog and update tests
1 parent 077bb3a commit 29626e5

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

packages/web3-utils/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,4 +224,5 @@ Documentation:
224224

225225
### Fixed
226226

227-
- `toWei` support numbers in scientific notation (#6908)
227+
- `toWei` support numbers in scientific notation (#6908)
228+
- `toWei` and `fromWei` trims according to ether unit successfuly (#7044)

packages/web3-utils/test/fixtures/converters.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,17 @@ const conversionBaseData: [[Numbers, EtherUnits], string][] = [
292292
[['879123456788877661', 'tether'], '0.000000000000879123456788877661'],
293293
];
294294

295-
export const fromWeiValidData: [[Numbers, EtherUnits], string][] = [
295+
export const fromWeiValidData: [[Numbers, EtherUnits], Numbers][] = [
296296
...conversionBaseData,
297297
[['0xff', 'wei'], '255'],
298298
[[1e+22, 'ether'], '10000'],
299299
[[19999999999999991611392, 'ether'], '19999.999999999991611392'],
300300
[[1.9999999999999991611392e+22, 'ether'], '19999.999999999991611392'],
301+
[['1000000', 'ether'], 0.000000000001],
302+
[['1123456789123456789', 'ether'], '1.123456789123456789'],
303+
[['1123', 'kwei'], '1.123'],
304+
[['1234100' ,'kwei'], '1234.1'],
305+
[['3308685546611893', 'ether'], '0.003308685546611893']
301306
];
302307

303308
export const toWeiValidData: [[Numbers, EtherUnits], Numbers][] = [
@@ -309,7 +314,8 @@ export const toWeiValidData: [[Numbers, EtherUnits], Numbers][] = [
309314
[['1123456789123456789', 'ether'], '1.123456789123456789123'],
310315
[['1123', 'kwei'], '1.12345'],
311316
[['1234100' ,'kwei'], '1234.1'],
312-
[['3308685546611893', 'ether'], '0.0033086855466118933']
317+
[['3308685546611893', 'ether'], '0.0033086855466118933'],
318+
[['1123', 'kwei'], 1.12345],
313319

314320
];
315321

0 commit comments

Comments
 (0)