Web Assembly (WASM) Parser
We offer developers various options to decode Solana instructions, including Typescript and Rust-based Web Assembly, providing flexibility for those familiar with Rust to easily import their existing structs and decoding methods.
Getting started
Before running this project, you are required to install the following dependencies.
Prerequisites
Build
wasm-pack build --out-dir ../explorerkit-wasm-package --release
After running the aboe command, the compiled Web Assembly file will be generated and saved in the pkg folder. This file can be used by the Typescript application to decode Solana instructions, as well as by any other programming language that supports Web Assembly (WASM) for decoding purposes.
Preparation for unit-test
Update the the following file packages/explorerkit-wasm-package/package.json
after the build and include the following two lines
{
"name": "explorerkit-wasm-translator",
"version": "0.1.0",
"files": [
"explorerkit_wasm_translator_bg.wasm",
"explorerkit_wasm_translator.js",
"explorerkit_wasm_translator_bg.js",
"explorerkit_wasm_translator.d.ts"
],
"main": "explorerkit_wasm_translator.js",
"type": "module",
"module": "explorerkit_wasm_translator.js",
"types": "explorerkit_wasm_translator.d.ts",
"sideEffects": false
}
[ ] TODO: add script to automate creation of properties main
and type
Typescript types
To generate typescript definitions for the generated Web Assembly file, run the following command:
cargo test
./scripts/compile-types.sh
After running the command to generate typescript definitions for the Web Assembly file, a new folder named bindings
will be created. This folder will contain all the exported structs that can be inferred, meaning that the TypeScript compiler will be able to detect the types of these structs automatically, allowing for more streamlined development.