GithubHelp home page GithubHelp logo

movefuns / move-js Goto Github PK

View Code? Open in Web Editor NEW
21.0 17.0 8.0 15.29 MB

Javascript version of the Move language compiler, supports compiling Move code into Move bytecode in the browser.

License: Apache License 2.0

TypeScript 44.11% JavaScript 12.70% Rust 43.19%

move-js's Introduction

move-js

Javascript version of the move language compiler and disassemble

Features

  • Compiling move package into blob
  • Disassemble contract

Example

  • Compiling move package into blob example
import { WasmFs } from '@wasmer/wasmfs'
import { Git, MovePackage } from '@starcoin/move-js'

const startWasiTask = async () => {
    const wasmfs = new WasmFs()
    const git = new Git(wasmfs)

    await git.download("/data/starcoin-framework.zip", "/workspace/starcoin-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([
        ["StarcoinFramework", "/workspace/starcoin-framework"]
      ]),
      initFunction: "0xABCDE::MyCounter::init"
    })
    
    await mp.build()

    const blobBuf = wasmfs.fs.readFileSync("/workspace/my-counter/target/starcoin/release/package.blob")
    const base64Data = blobBuf.toString("base64")
    console.log("my-counter blob:", base64Data)
}

startWasiTask()
  • Disassemble contract example
import { WasmFs } from '@wasmer/wasmfs'
import { Disassemble } from '@starcoin/move-js'

const startDisassembleTask = async (app: HTMLDivElement) => {
  const wasmfs = new WasmFs()

  const dp = new Disassemble(wasmfs)

  // Chain code
  const account_scripts = "you code"

  dp.disassemble("account_scripts", account_scripts, (ok: boolean, data: string) => {
    console.log(ok)
    console.log(data)
  })

  app.innerHTML = `
      <h1>view disassemble in console:</h1>
    `
}

const app = document.querySelector<HTMLDivElement>('#app')!
startDisassembleTask(app)

move-js's People

Contributors

yubing744 avatar wow-sven avatar

Stargazers

 avatar QZQ avatar Takaya Imagawa avatar Max Mohammadi avatar  avatar Yukai Huang avatar Jiege avatar  avatar Bo Wu avatar MoeMoeFish avatar  avatar  avatar Tao Xu avatar crazybits avatar luxebeng avatar  avatar Matteo avatar WillQ avatar  avatar jiangplus avatar jolestar avatar

Watchers

jolestar avatar  avatar  avatar caojiafeng avatar 0xa avatar Bob Ong avatar nk_ysg avatar Xudong Wang avatar  avatar  avatar crazybits avatar Logan Wang avatar  avatar  avatar 李大狗 avatar Triplex avatar  avatar

move-js's Issues

feat: Support Aptos

Feature Request

Describe the Feature Request

Support Aptos Move adapter and framework

feat: Support Run Move VM and execute function in browser

Feature Request

Describe the Feature Request

Support Run Move VM and execute function in browser

Describe Preferred Solution

Describe Alternatives

Related Code

Additional Context

If the feature request is approved, would you be willing to submit a PR?
Yes / No (Help can be provided if you need assistance submitting a PR)

feat: Supports parsing Move files and obtaining syntax trees for IDE identification of test cases

Feature Request

Supports parsing Move files and obtaining syntax trees for IDE identification of test cases

Describe Preferred Solution

Use rust move to parse the syntax tree and return it to js

Describe Alternatives

Related Code

Additional Context

If the feature request is approved, would you be willing to submit a PR?
Yes / No (Help can be provided if you need assistance submitting a PR)

feat: Support multi move chain adapter and framework

Feature Request

Describe the Feature Request

Support multi move chain adapters and frameworks

  • Aptos #9
  • Sui

Describe Preferred Solution

Describe Alternatives

Related Code

Additional Context

If the feature request is approved, would you be willing to submit a PR?
Yes / No (Help can be provided if you need assistance submitting a PR)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.