add develop.md

This commit is contained in:
CaiHQ 2023-03-15 10:06:49 +08:00
parent 3ee7b5bfc7
commit 08da9c63f0
3 changed files with 33 additions and 5 deletions

15
DEVELOP.md Normal file
View File

@ -0,0 +1,15 @@
# Development Guide
1. install http-server to enable debug at local.
```bash
npm install -g http-server
```
2. run `npm install` to build the project.
3. in `./` folder, use `http-server` to start server
4. open the following link to debug.
please note, the server address should be checked in the source code of `xxx.html`!
```
http://127.0.0.1:8080/test/ws.html
http://127.0.0.1:8080/test/http.html
```

View File

@ -1,6 +1,6 @@
{ {
"name": "@bdware/bdcontract-sdk", "name": "@bdware/bdcontract-sdk",
"version": "0.3.0-alpha.14", "version": "0.3.0-alpha.15",
"description": "BDContract SDK for Node.js and browsers", "description": "BDContract SDK for Node.js and browsers",
"license": "MIT", "license": "MIT",
"keywords": [ "keywords": [
@ -47,5 +47,14 @@
"shx": "^0.3.4", "shx": "^0.3.4",
"sucrase": "^3.25.0", "sucrase": "^3.25.0",
"typescript": "^4.8.2" "typescript": "^4.8.2"
} },
"directories": {
"lib": "lib",
"test": "test"
},
"repository": {
"type": "git",
"url": "git@gitea.internetapi.cn:bdware/bdcontract-sdk-javascript.git"
},
"author": "caihq@pku.edu.cn"
} }

View File

@ -10,18 +10,20 @@
document.write(`${string}\n\n`) document.write(`${string}\n\n`)
} }
const url = 'ws://39.104.201.40:18010/SCIDE/SCExecutor' const url = 'ws://127.0.0.1:18000/SCIDE/SCExecutor'
const client = new bdcontract.WsClient( const client = new bdcontract.WsClient(
url, url,
(ev) => { (ev) => {
console.log(JSON.stringify(ev)) console.log("onOpen:"+JSON.stringify(ev))
invokeContract()
}, },
(ev, ws) => { (ev, ws) => {
console.log(ev.data) console.log(ev.data)
}, },
) )
setTimeout(async () => { function invokeContract(){
setTimeout(async () => {
const status = client.status() const status = client.status()
console.log(status) console.log(status)
try { try {
@ -42,6 +44,8 @@
print(JSON.stringify(data)) print(JSON.stringify(data))
} }
}, 1000) }, 1000)
}
</script> </script>
<link rel="icon" type="image/svg+xml" href="favicon.svg"/> <link rel="icon" type="image/svg+xml" href="favicon.svg"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"/>