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

Make number functions accept both int and bigint, use strings instead of Buffer in bytes codec #264

Closed
wants to merge 27 commits into from

Conversation

vanruch
Copy link
Contributor

@vanruch vanruch commented Mar 27, 2024

Not exactly sure about this PR. I feel like working with strings is easier for squid users

@vanruch vanruch force-pushed the evm-codec-broad-types branch from 12a4713 to 05afc70 Compare March 27, 2024 17:09
@vanruch vanruch requested a review from belopash April 2, 2024 09:11
Copy link
Contributor

@belopash belopash left a 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}`;
Copy link
Contributor

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")}`;
Copy link
Contributor

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 {

Base automatically changed from evm-utils to master April 11, 2024 09:49
@vanruch vanruch closed this May 3, 2024
@vanruch vanruch deleted the evm-codec-broad-types branch May 3, 2024 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants