Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
@eqlabs/assemblyscript
Advanced tools
HookScript compiles a variant of AssemblyScript (basically TypeScript for WebAssembly) compatible with XRPL Hooks.
Currently only the basic functions (accept, rollback etc.) are supported for use without declaring - patches welcome. As the C conventions of Hook API are inconvenient for HookScript, the functions are generally imported with a prepended '$' sign (e.g. $accept, $rollback) and wrapped in a function with the original name but higher-level arguments (e.g. a string instead of a pointer + length), which also provides basic error handling, calling rollback on API error - so, for example, etxn_reserve is implemented as
// @ts-ignore: decorator
@external("env", "etxn_reserve")
export declare function $etxn_reserve(
count: u32
): i64
@global @inline
export function etxn_reserve(count: u32): void {
let r = $etxn_reserve(count);
if (r != count)
rollback("", r);
}
where rollback is
// @ts-ignore: decorator
@external("env", "rollback")
declare function $rollback(
read_ptr: string,
read_len: u32,
error_code: i64
): i64;
@global @inline
export function rollback(msg: string = "", err: i64 = 0): void {
$rollback(msg, msg.length, err);
// does not return
}
Both imported lower-level and inlined higher-level APIS are callable from user code. The guard function _g is available, but it's probably more convenient to call its wrapper, max_iterations, which takes care of generating a unique first argument to _g (max_iterations also increments the second argument by 1, like the GUARD macro in the C interface).
Some classes (e.g. Account and Amount) were added for high-level Hooks support - see the standard library for details. Note that while most of AssemblyScript standard library is still there, that doesn't mean it's working - hooks require bounded computation with guarding, which the code hadn't been updated (and in some case cannot be updated) to use.
A development environment can be set up by cloning the repository:
git clone https://github.com/eqlabs/assemblyscript.git
cd assemblyscript
After building the compiler, you can invoke it using cli from bin/asc
or directly using the compiled bundles from dist
folder in any browser/server environments.
A docker image can be created using.
docker build -t asc/img .
To create a container and copy built artifacts to the dist
folder.
docker create --name asc-cont asc-img && docker cp asc-cont:/app/dist/ ./
Install NodeJS version >=16
and npm >=6
.
Install dependencies.
npm install
Build the compiler.
npm run build
Watch for changes.
npm run watch
The full process is documented as part of the repository:
FAQs
A TypeScript-like language for WebAssembly.
The npm package @eqlabs/assemblyscript receives a total of 5 weekly downloads. As such, @eqlabs/assemblyscript popularity was classified as not popular.
We found that @eqlabs/assemblyscript demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.