-
Notifications
You must be signed in to change notification settings - Fork 208
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
fix: returned string of BigInt.toHexString #1389
base: main
Are you sure you want to change the base?
Conversation
|
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.
Will not merge in this form, and if AssemblyScript don't accept default parameter, we might even probably close this PR.
packages/ts/common/numbers.ts
Outdated
@@ -115,7 +115,7 @@ export class BigInt extends Uint8Array { | |||
} | |||
|
|||
toHexString(): string { | |||
return typeConversion.bigIntToHex(this); | |||
return "0x" + typeConversion.bigIntToHex(this); |
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.
This will be a major breaking change, while I kind of agree that we could have both I don't think we can merge that.
If AssemblyScript accepts default parameter, maybe we could think of toHexString(format)
where default would be the same as today keeping compatibility and the format could be plain or prefixed or something along this.
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.
Thanks for the review and feedback! I've updated the change with an optional prefix
that does not affect the compatibility.
For The Graph's graph-ts implementation,
BigInt.toHex()
andBigInt.toHexString()
behaves the same.However, in my thoughts
toHex()
should return a string that looks likedeadbeef
whiletoHexString()
should return a string that looks like0xdeadbeef
.So the implementation should be updated into:
Additionally,
toHexString()
is not tracked by The Graph's AssemblyScript API docs.