Skip to content

imcoding-online/js-move-playground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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();