Skip to content

Commit

Permalink
chore: clean up wasm && web
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-melnychuk committed Sep 3, 2024
1 parent 20c7e40 commit b3be902
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 89 deletions.
2 changes: 1 addition & 1 deletion web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ cd web/beerus-web
wasm-pack build --target web
cd .. # go back to 'web'
npm i ./beerus-web/pkg
npx parcel build index.html
http-server dist/
Expand All @@ -14,3 +13,4 @@ node proxy.js &
## Now open localhost:8080 in a browser
```

cd beerus-web && wasm-pack build --target web && cd .. && npx parcel build index.html && http-server dist/
36 changes: 17 additions & 19 deletions web/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
import init, { get_state } from './node_modules/beerus/beerus_web.js';
import init, { get_state } from './beerus-web/pkg/beerus_web.js';

async function run() {
function dump(div, text, style) {
let p = document.createElement('p');
if (style != undefined) {
p.className = style;
}
if (style === 'error') {
console.error(text);
} else {
console.log(text);
}
p.innerText = text;
div.appendChild(p);
}

(async function () {
await init();
const div = document.getElementById('log');

Expand All @@ -16,20 +30,4 @@ async function run() {
} catch (err) {
dump(div, "Error: " + err, 'error');
}
}

function dump(div, text, style) {
let p = document.createElement('p');
if (style != undefined) {
p.className = style;
}
if (style === 'error') {
console.error(text);
} else {
console.log(text);
}
p.innerText = text;
div.appendChild(p);
}

run();
})();
23 changes: 2 additions & 21 deletions web/beerus-web/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion web/beerus-web/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ crate-type = ["cdylib", "rlib"]

[dependencies]
beerus = { path = "../..", default-features = false }
reqwest = { version = "0.12.3", default-features = false, features = ["json", "blocking"] }
reqwest = { version = "0.12.3", default-features = false, features = ["json"] }
serde = "1.0.209"
serde_json = "1.0.127"

tokio = { version = "1", features = ["sync", "macros", "io-util", "rt", "time"] }

wasm-timer = "0.2.5"
web-sys = "0.3.69"
wasm-bindgen = "0.2.92"
wasm-bindgen-futures = "0.4.37"

ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "3bf1a9e0d698e9fdfc91d0353878901af5a5c5ef" }
helios = { git = "https://github.com/sergey-melnychuk/helios", branch = "beerus-wasm", default-features = false, features = ["beerus-wasm"] }
js-sys = "0.3.70"
2 changes: 1 addition & 1 deletion web/beerus-web/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub async fn get_state(config_json: &str) -> Result<String, JsValue> {
root: state.root.as_ref().to_owned(),
};

let client = beerus::gen::client::blocking::Client::new(&config.starknet_rpc, beerus::client::Http(reqwest::Client::new()));
let client = beerus::gen::client::blocking::Client::new(&config.starknet_rpc, beerus::client::Http::new());
web_sys::console::log_1(&"beerus: rpc client ready".into());
let json = serde_json::json!({
"calldata": [],
Expand Down
30 changes: 0 additions & 30 deletions web/package-lock.json

This file was deleted.

16 changes: 0 additions & 16 deletions web/package.json

This file was deleted.

0 comments on commit b3be902

Please sign in to comment.