Closed lucanicoladebiasi closed 1 month ago
Lines | Statements | Branches | Functions |
---|---|---|---|
100% (3390/3390) | 100% (783/783) | 100% (701/701) |
Title | Tests | Skipped | Failures | Errors | Time |
---|---|---|---|---|---|
core | 485 | 0 :zzz: | 0 :x: | 0 :fire: | 1m 4s :stopwatch: |
network | 660 | 0 :zzz: | 0 :x: | 0 :fire: | 3m 43s :stopwatch: |
errors | 48 | 0 :zzz: | 0 :x: | 0 :fire: | 11.237s :stopwatch: |
Description
The code fixes a bug in the function
unitsUtils.parseUnits
in the file packages/core/src/utils/units/units.ts leading to include non meaningful digits in BigNumber conversion tostring
to be parsed asbigint
.New tests are introduced to compare
ethers
behaviour with the drop-in functions provided byunitUtils
, the latter are based onbignumber.js
library.The
bignumberjs
library configures its setting - specifically about the fixed digits precision and rounding methods - globally: this means if some code using this SDK needs to changeBigNumber
settings, the behaviour ofunitUtils
functions is altered in a potentially incorrect way.This code stores the configuration of
BigNumber
, at the beginning of the execution of the format/parse functions, set it as needed to assure 80 meaningful digits andBigNumber.ROUND_HALF_UP
rounding methods prescribed by Ethereum specifications, restoring the configuration when the functions return. This enhancement preventBigNumber
global settings collides withunitUtils
needed setting.Fixes # 928.
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
yarn:unit
yarn:solo
Test Configuration:
Checklist: