Skip to content
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

Check sign flag for i{8, 16, 32, ...} conversions #1867

Merged
merged 16 commits into from
Aug 22, 2023

Conversation

jacogr
Copy link
Member

@jacogr jacogr commented Aug 21, 2023

Replaces #1866

@@ -23,7 +23,7 @@ export function u8aToBigInt (value: Uint8Array, { isLe = true, isNegative = fals
: value.slice().reverse();
const count = u8a.length;

if (isNegative && (!count || (u8a[count - 1] & 0x80))) {
if (isNegative && count && (u8a[count - 1] & 0x80)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So to understand this, isNegative will not indicate if we want to convert a signed value, correct?
If so maybe it would be good to refactor the name to isSigned and deprecate isNegative option?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming isNegative is indeed very unfortunate, it does mean isSigned and should have been named such 5 year ago. Got it right eventually in the api.

The timelines for deprecation (at least 6 months and then in the next major) and then the additional clutches it brings code & maintenance wise to support old/new has newer seemed to be worth the effort. So it is a wart.

@jacogr jacogr added the -auto CI only tag. label Aug 22, 2023
@polkadot-js-bot polkadot-js-bot merged commit 55ebc4f into master Aug 22, 2023
6 checks passed
@polkadot-js-bot polkadot-js-bot deleted the jg-signed-unsigned branch August 22, 2023 17:08
@polkadot-js-bot
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@polkadot-js polkadot-js locked as resolved and limited conversation to collaborators Aug 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
-auto CI only tag.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants