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

[JSHooks] Cannot output an object containing a value of type bigint with trace #416

Open
tequdev opened this issue Dec 24, 2024 · 1 comment
Labels

Comments

@tequdev
Copy link
Collaborator

tequdev commented Dec 24, 2024

const Hook = (arg) => {
  trace("number", 1, false)
  trace("bigint", 1n, false)
  trace("object-number", { a: 1 }, false)
  trace("object-bigint", { a: 1n }, false)
  return accept('.', 1)
}

output

HookTrace[rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn-rPMh7Pi9ct699iZUTWaytJUoHcJ7cgyziK]: number: 1
HookTrace[rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn-rPMh7Pi9ct699iZUTWaytJUoHcJ7cgyziK]: bigint: 1
HookTrace[rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn-rPMh7Pi9ct699iZUTWaytJUoHcJ7cgyziK]: object-number: {"a":1}
HookTrace[rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn-rPMh7Pi9ct699iZUTWaytJUoHcJ7cgyziK]: object-bigint: 
@tequdev
Copy link
Collaborator Author

tequdev commented Dec 24, 2024

Even in javascript itself, JSON.stringify cannot handle bigint by default. It can be handled with the following code.

JSON.stringify(this, (key, value) => typeof value === 'bigint' ? value.toString(): value)

In JSHooks, this issue can be solved by doing the same process in JS_JSONStringify

https://github.com/xahau/xahaud/blob/jshooks/src/ripple/app/hook/impl/applyHook.cpp#L1717

https://github.com/xahau/xahaud/blob/jshooks/src/quickjs/quickjs.c#L45561

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant