-
Notifications
You must be signed in to change notification settings - Fork 153
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
Make number functions accept both int and bigint, use strings instead of Buffer in bytes codec #264
Conversation
# Conflicts: # common/config/rush/pnpm-lock.yaml
… of Buffer in bytes codec
12a4713
to
05afc70
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.
Imho, for codec it's better to work with Uint8Arrays, but generated classes can accept both types and return hex strings
@@ -7,6 +8,8 @@ import type { Codec } from "./codec"; | |||
*/ | |||
export type Pretty<T> = { [K in keyof T]: T[K] } & unknown; | |||
|
|||
export type Hex = `0x${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 don't think this is needed. Will be very annoyning, better to leave only runtime check
const ptr = this.u32(); | ||
this.safeJump(ptr); | ||
const len = this.u32(); | ||
this.assertLength(len); | ||
const val = this.buf.subarray(this.pos, this.pos + len); | ||
this.jumpBack(); | ||
return val; | ||
return `0x${Buffer.from(val).toString("hex")}`; |
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.
better to reuse our tools
export function toHex(data: Uint8Array): string { |
Not exactly sure about this PR. I feel like working with strings is easier for squid users