-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate data type conversion utils functions from 1.x #4405
Conversation
cae2258
to
e5830a7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There aren't any tests for BigDecimal
tether: expo10(30), | ||
}; | ||
|
||
const errorMessage = (value: unknown, error: string) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would think this should be defined in errors.ts
to be used by all the inline errors below
Since we are replacing As it looks like we are removing the |
@luu-alex Yes we are replacing |
if (numberOfZerosInDenomination <= 0) { | ||
return number.toString(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what's happening here, could you clarify with a comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I think I understand, this handles if the provided unit
is wei
or noether
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes you are right.
|
||
// value in wei would always be integer | ||
// 13456789, 1234 | ||
const value = String(toNumber(number)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is all the casting necessary? Above you just do number.toString()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The input number
is of type Numbers
which is better to be casted with toNumber
as it could include HexString
as well.
Description
Create conversion functions for
web3-utils
Fixes #4350
Type of change
Checklist:
npm run dtslint
with success and extended the tests and types if necessary.npm run test:unit
with success.npm run test:cov
and my test cases cover all the lines and branches of the added code.npm run build
and testeddist/web3.min.js
in a browser.CHANGELOG.md
file in the root folder.