xrpl-hooks-api-assembly-script
v0.2.9
Published
XRPL hooks API exports that you can import into your XRPL hooks project written in AssemblyScript.
Downloads
5
Readme
XRPL Hooks API for AssemblyScript
XRPL hooks API exports that you can import into your hooks project written in AssemblyScript.
While this is currently working, please understand this repo is currently a work in progress. It's likely to be broken for versions prior to 1.0.0. Thanks for your patience. Contact info below if you're having trouble.
Background
This was created based on the work done by RichardAH. He has done some great work for XRPL hooks in C and I wanted to try writing my XRPL Hooks in AssemblyScript.
The contents of this lib are based on the headers he created that represent the XRPL Hooks API.
Of course the folks at XRPL-Labs an many other developers in the #XrpCommunity were a super help too!
XRPL Hooks Docs
- Getting setup to use hooks in your local development environment.
- Learn more about XRPL hooks.
- Learn more about the API that these declarations provide access to.
- Learn more about the GUARD (_g) function passed from the XRPL to your compiled binary here.
Usage
Pull the library into your project.
# From a terminal in the root of your project npm i xrpl-hooks-api-assembly-script -D
import the declarations you want to use into your source code.
# assembly/index.ts import { _g as GUARD } from '../node_modules/xrpl-hooks-api-assembly-script/dist'
Use the new declaration in your hook or cback functions.
# assembly/index.ts export function hook(reserved: i64): i64 { GUARD(1,1) // Unreached code. return 42 }
Compiler Options
In the scripts section of your package.json
using these compiler options are currently working when importing these declarations.
"scripts": {
...
"asbuild:untouched": "asc assembly/index.ts --target debug -O3 --noAssert --runtime minimal -b build/untouched.wasm -t build/untouched.wat -d build/untouched.d.ts",
"asbuild:optimized": "asc assembly/index.ts --target release -O3 --noAssert --runtime minimal -b build/optimized.wasm -t build/optimized.wat -d build/optimized.d.ts",
"asbuild": "npm run asbuild:untouched && npm run asbuild:optimized",
...
}
Contribute
If you want to help out simply fork this repo, make your changes, and submit a PR.
Once your branch is merged to master a new release will be cut and a distribution will be pushed to npmjs.com.
If you just want to share what you found without a PR hit me up on Twitter.
Contact
- https://twitter.com/jfgrissom