@imcoding.online/js-move-playground
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

JS MOVE PLAYGROUND

Wrapper move playground by pontem. Only support Browser environment.

Demo

imcoding.online

Install

npm i @imcoding.online/js-move-playground

Use

import { setup, openProject } from "@imcoding.online/js-move-playground";

// must setup first
await setup();

// create or open project
const demo = await openProject("demo");

// create or open module
const module = demo.openModule("math.move");
demo.setContent(module, `
module 0x01::Math {
  public fun sum(a: u64, b: u64): u64 {
      a + b
  }
}
  `);

// create or open script
let script = demo.openScript("plus.move");
demo.setContent(script, `
script {
   use 0x01::Math::sum;

   fun plus(a: u64, b: u64) {
     assert!(sum(a, b) == 15, 101);
   }
}
`);

await demo.runScript("plus(10, 5)"); // execute success

await demo.runScript("plus(8, 3)"); // throw Error

// rename file
script = demo.renameFile(script, "plus_v2.move");

// remove file
demo.removeFile(script);

// remove project
await demo.remove();

Package Sidebar

Install

npm i @imcoding.online/js-move-playground

Weekly Downloads

0

Version

1.0.3

License

MIT

Unpacked Size

11.2 MB

Total Files

6

Last publish

Collaborators

  • imcoding.online