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

Feature: include JS Hooks SDK @ quickjs engine #333

Open
WietseWind opened this issue May 31, 2024 · 2 comments
Open

Feature: include JS Hooks SDK @ quickjs engine #333

WietseWind opened this issue May 31, 2024 · 2 comments
Labels

Comments

@WietseWind
Copy link
Contributor

WietseWind commented May 31, 2024

The QuickJS CLI (qjs.c) lib has the -I option which allows for 'injecting' (preloading) JS that will be available in the runtime.

Under the hood it does this:
https:/bellard/quickjs/blob/master/qjs.c#L502

Goal:

Limit the size of JS Hooks using a simple Hook SDK

Proposal:

Inject a "JS Hook SDK" @ the engine, so many helper fns I'm currently writing don't have to be part of every compiled Hook, as they are globally defined.

Implementation:

Proposed:

  1. The HookSDK JS becomes part of the xahaud package, so new versions are part of the release & if they refer to native HookJS API's, they will always be available because they are part of the same xahaud release. Obviously the .bc version (compiled HookJS) should be included (?)

  2. For development purposes: if config stanza is present to refer to an external .bc-like compiled JS Hook SDK, this one will be used instead of the embedded one, so we can locally add and test things by changing the JS Hook SDK, TS to JS, JS to BC, and then refer the local config to that .BC so we can immediately test the new SDK fns.

@tequdev
Copy link
Collaborator

tequdev commented Jun 20, 2024

In order to make the same Hook code available to multiple Hooks Enabled networks, it is desirable to be able to access TransactionType, sf fields, etc. by field name rather than by number.

like

`ttURITokenMint` in jshook code -> (xahaud package) -> `ttURITokenMint` -> 45
`ttURITokenMint` in jshook code -> (rippled package) -> `ttURITokenMint` -> another code

to avoid the following

`ttURITokenMint` -> 45 in jshook code -> (xahaud package) -> 45 -> `ttURITokenMInt`
`ttURITokenMint` -> 45 in jshook code -> (rippled package) -> 45 -> `ttXCHAIN_ADD_CLAIM_ATTESTATION`

@WietseWind
Copy link
Contributor Author

Definitely true @tequdev - all to be added to the core lib :)

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

2 participants