Skip to content

Commit

Permalink
change readme.md && add disassemble examples
Browse files Browse the repository at this point in the history
  • Loading branch information
wow-sven committed Oct 2, 2022
1 parent 4f6a70b commit 28300b2
Show file tree
Hide file tree
Showing 19 changed files with 845 additions and 33 deletions.
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# move-js

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

## Features
- Compiling move package into blob
- Disassemble contract

## Example

Expand Down Expand Up @@ -35,4 +36,31 @@ const startWasiTask = async () => {
}

startWasiTask()
```

```ts
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)
const
```
24 changes: 24 additions & 0 deletions examples/disassemble/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
15 changes: 15 additions & 0 deletions examples/disassemble/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions examples/disassemble/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
20 changes: 20 additions & 0 deletions examples/disassemble/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "disassemble",
"private": true,
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"devDependencies": {
"typescript": "^4.5.4",
"vite": "^2.9.9"
},
"dependencies": {
"@wasmer/wasi": "^0.12.0",
"@wasmer/wasm-transformer": "^0.10.0",
"@wasmer/wasmfs": "^0.12.0",
"@starcoin/move-js": "../../"
}
}
Binary file added examples/disassemble/public/data/my-counter.zip
Binary file not shown.
Binary file not shown.
29 changes: 29 additions & 0 deletions examples/disassemble/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import './style.css'

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
//0x1::Account::AccountScripts
const account_scripts = "0xa11ceb0b040000000601000403040f051307071a60087a100c8a011800000001000200010000030001000104020100010c0002060c010e4163636f756e7453637269707473074163636f756e741964697361626c655f6175746f5f6163636570745f746f6b656e18656e61626c655f6175746f5f6163636570745f746f6b656e157365745f6175746f5f6163636570745f746f6b656e000000000000000000000000000000010002000001040e00091102020102000001040e000811020200"

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)



8 changes: 8 additions & 0 deletions examples/disassemble/src/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
1 change: 1 addition & 0 deletions examples/disassemble/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
Loading

0 comments on commit 28300b2

Please sign in to comment.