Javascript version of the Move language compiler, supports compiling Move code into Move bytecode in the browser.
npm install @movefuns/move-jsJavascript version of the move language compiler and disassemble
* Compiling move package into blob example
``ts
import { WasmFs } from '@wasmer/wasmfs'
import { Git, MovePackage } from '@movefuns/move-js'
const startWasiTask = async (app: HTMLDivElement) => {
const wasmfs = new WasmFs()
const git = new Git(wasmfs)
await git.download("/data/framework.zip", "/workspace/framework")
await git.download("/data/my-counter.zip", "/workspace/my-counter")
const mp = new MovePackage(wasmfs, {
packagePath: "/workspace/my-counter",
test: false,
alias: new Map([
["AptosFramework", "/workspace/framework/aptos-framework"]
]),
initFunction: "0xABCDE::MyCounter::init"
})
await mp.build()
const blobBuf = wasmfs.fs.readFileSync("/workspace/my-counter/target/aptos/release/package.blob")
const hash = wasmfs.fs.readFileSync("/workspace/my-counter/target/aptos/release/hash.txt")
const base64Data = blobBuf.toString("base64")
// get hex of blob buf with 0x prefix
const hex = blobBuf.toString("hex").replace(/^/, "0x")
app.innerHTML =
}const app = document.querySelector('#app')!
startWasiTask(app)
`* Disassemble contract example
`ts
import { WasmFs } from '@wasmer/wasmfs'
import { Disassemble } from '@movefuns/move-js'const startDisassembleTask = async (app: HTMLDivElement) => {
const wasmfs = new WasmFs()
const dp = new Disassemble(wasmfs)
//Chain code
const account_scripts = "your code"
dp.disassemble("account_scripts", account_scripts, (ok: boolean, data: string) => {
app.innerHTML =
})
}const app = document.querySelector('#app')!
startDisassembleTask(app)
`Supported Rust Versions
@movefuns/move-js supports the version of Rust (toolchain and targets) specified
in rust-toolchain.toml. At the time of writing, we are
using version 1.77.0. However, this can change at any time if one of our
dependencies changes MSRV or through a new patch version.Building from source
Note: You will need rust installed also for this. https://www.rust-lang.org/tools/install or
`
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
`Then get
@movefuns/move-js source:`
git clone https://github.com/movefuns/move-js
cd move-js
git checkout aptos
`Build the source
`
yarn install
yarn build
`Testing
$3
my-counter (Compiling move package into blob)
`
cd example/my-counter/
yarn install
yarn dev
`disassemble (Disassemble contract from bytecode)
`
cd example/disassemble
yarn install
yarn dev
`$3
`
yarn test
``Licensed under the Apache License, Version 2.0,
see the LICENSE file for more information.