Skip to content

Commit fb0da30

Browse files
committed
wip
1 parent 91ed788 commit fb0da30

33 files changed

Lines changed: 1284 additions & 956 deletions

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
debot-browser/pkg:
2+
cd builder && cargo run --release
3+
demo/node_modules:
4+
cd demo && npm install
5+
release-pkg: debot-browser/pkg
6+
cd debot-browser/pkg && npm publish --access public
7+
gh-local:
8+
git clone --depth=1 --branch=demo git@github.com:ever-guild/debot-browser.git gh-local
9+
release-demo: debot-browser/pkg demo/node_modules gh-local
10+
cd demo && npm run build
11+
git -C gh-local rm -rf .
12+
git clean -C gh-local -fxd
13+
cp -r demo/dist/ gh-pages/
14+
start: debot-browser/pkg test-server/node_modules
15+
cd test-server && npm run start

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
<div align="center">
2-
3-
<h1><code>Cli Debot Browser</code></h1>
4-
5-
<strong>A standalone console Debot Browser written in Rust and compiled as WebAssembly.</strong>
6-
2+
<h1><code>Debot browser</code></h1>
3+
<strong>A standalone console Debot browser written in Rust and compiled as WebAssembly.</strong>
74
</div>
85

96
## How to use

debot-browser/Cargo.toml

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
[package]
2-
authors = ["TON Labs <support@tonlabs.io>"]
2+
authors = ["Ever Guild"]
33
edition = "2018"
44
name = "debot-browser"
5-
version = "0.5.5"
6-
description = "Standalone cli DeBot Browser"
7-
repository = "https://github.com/tonlabs/rust-debot-browser"
5+
version = "0.6.0-rc.0"
6+
description = "Standalone debot browser"
7+
repository = "https://github.com/ever-guild/debot-browser"
88
license = "Apache-2.0"
99
keywords = [
1010
"debot browser",
1111
"debot",
1212
"browser",
1313
"wasm",
14-
"tonlabs",
15-
"Surf",
16-
"Everscale",
14+
"tvm",
1715
]
1816

1917
[lib]
2018
crate-type = ["cdylib", "rlib"]
2119

2220
[features]
23-
default = [] # "console_error_panic_hook",
21+
default = [] # "console_error_panic_hook",
2422

2523
[dependencies.web-sys]
2624
version = "0.3"
@@ -34,32 +32,27 @@ base64 = '0.10.1'
3432
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
3533
# code size when deploying.
3634
console_error_panic_hook = { version = "0.1.6", optional = true }
37-
hex = "0.3.2"
38-
js-sys = "0.3.55"
39-
lazy_static = "1.1.0"
40-
log = { version = "0.4.11", features = ["std"] }
41-
num-bigint = "0.4"
42-
num-traits = "0.2"
43-
serde = { version = "1.0", features = ["derive"] }
44-
serde_derive = "1.0"
45-
serde_json = "1.0"
46-
rand = "0.7.3"
47-
regex = "1.5.4"
48-
serde-wasm-bindgen = "0.3.1"
49-
tokio = { version = "0.2.13", features = [
50-
"sync",
51-
"stream",
52-
], default-features = false }
53-
54-
ton_client = { git = 'https://github.com/tonlabs/TON-SDK.git', tag = '1.32.0', default-features = false, features = [
35+
hex = "0.4.3"
36+
js-sys = "0.3.62"
37+
lazy_static = "1.4.0"
38+
log = { version = "0.4.17", features = ["std"] }
39+
num-bigint = "0.4.3"
40+
num-traits = "0.2.15"
41+
serde = { version = "1.0.163", features = ["derive"] }
42+
serde_derive = "1.0.163"
43+
serde_json = "1.0.96"
44+
rand = "0.8.5"
45+
regex = "1.8.1"
46+
serde-wasm-bindgen = "0.5.0"
47+
tokio = "^1"
48+
wasm-bindgen = "0.2.85"
49+
wasm-bindgen-futures = "0.4.35"
50+
ton_client = { git = 'https://github.com/tonlabs/ever-sdk.git', tag = '1.42.1', default-features = false, features = [
5551
"wasm",
5652
] }
5753

58-
wasm-bindgen = "0.2.77"
59-
wasm-bindgen-futures = "0.4.27"
60-
6154
[dev-dependencies]
62-
wasm-bindgen-test = "0.3.26"
55+
wasm-bindgen-test = "0.3.35"
6356

6457
[package.metadata.wasm-pack.profile.release]
6558
wasm-opt = ['-Os']
@@ -71,4 +64,4 @@ opt-level = "s"
7164

7265
[dependencies.clear_on_drop]
7366
features = ["no_cc"]
74-
version = "0.2" #This version should match the version that the ed25519-dalek crate depends on.
67+
version = "0.2" # This version should match the version that the ed25519-dalek crate depends on.

debot-browser/README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1+
<p align="center">
2+
<a href="https://github.com/ever-guild/debots">
3+
<img src="https://raw.githubusercontent.com/ever-guild/debot/main/asset/debot.svg" height="60"/>
4+
</a>
5+
</p>
16
<h1 align="center">
2-
<code>Standalone cli DeBot Browser</code>
7+
<code>Debot browser</code>
38
</h1>
49

510
<p align="center">
6-
Standalone DeBot Browser written in Rust and compiled as WebAssembly
7-
<br />
8-
<br />
9-
11+
Standalone Debot browser written in Rust and compiled as WebAssembly
1012
</p>
1113

12-
# Cli DeBot Browser
14+
# Debot Browser
1315

1416
## Purpose
1517

@@ -19,8 +21,8 @@ Run any DeBot in your website using DeBot Browser as Service.
1921

2022
To get started, install `debot-browser`:
2123

22-
```sh
23-
npm i debot-browser
24+
```shell
25+
npm install @ever-guild/debot-browser
2426
```
2527

2628
Run DeBot:
@@ -158,4 +160,4 @@ let manifest = `{
158160
await browser.destroy_browser(browserHandle);
159161

160162
});
161-
```
163+
```

debot-browser/src/crypto.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,7 @@
1313
use crate::helpers::{create_client_local, WORD_COUNT, HD_PATH};
1414
#[cfg(not(target_arch = "wasm32"))]
1515
use crate::helpers::read_keys;
16-
use ton_client::crypto::{
17-
KeyPair,
18-
mnemonic_from_random,
19-
hdkey_xprv_from_mnemonic,
20-
hdkey_secret_from_xprv,
21-
nacl_sign_keypair_from_secret_key,
22-
hdkey_derive_from_xprv_path,
23-
ParamsOfHDKeySecretFromXPrv,
24-
ParamsOfHDKeyDeriveFromXPrvPath,
25-
ParamsOfHDKeyXPrvFromMnemonic,
26-
ParamsOfNaclSignKeyPairFromSecret,
27-
ParamsOfMnemonicFromRandom
28-
};
16+
use ton_client::crypto::{KeyPair, mnemonic_from_random, hdkey_xprv_from_mnemonic, hdkey_secret_from_xprv, nacl_sign_keypair_from_secret_key, hdkey_derive_from_xprv_path, ParamsOfHDKeySecretFromXPrv, ParamsOfHDKeyDeriveFromXPrvPath, ParamsOfHDKeyXPrvFromMnemonic, ParamsOfNaclSignKeyPairFromSecret, ParamsOfMnemonicFromRandom, MnemonicDictionary};
2917

3018
#[cfg(not(target_arch = "wasm32"))]
3119
pub fn load_keypair(keys: &str) -> Result<KeyPair, String> {
@@ -48,7 +36,7 @@ pub fn gen_seed_phrase() -> Result<String, String> {
4836
mnemonic_from_random(
4937
client,
5038
ParamsOfMnemonicFromRandom {
51-
dictionary: Some(1),
39+
dictionary: Some(MnemonicDictionary::English),
5240
word_count: Some(WORD_COUNT),
5341
..Default::default()
5442
},
@@ -62,7 +50,7 @@ pub fn generate_keypair_from_mnemonic(mnemonic: &str) -> Result<KeyPair, String>
6250
let hdk_master = hdkey_xprv_from_mnemonic(
6351
client.clone(),
6452
ParamsOfHDKeyXPrvFromMnemonic {
65-
dictionary: Some(1),
53+
dictionary: Some(MnemonicDictionary::English),
6654
word_count: Some(WORD_COUNT),
6755
phrase: mnemonic.to_string(),
6856
..Default::default()

debot-browser/src/helpers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::config::Config;
1414
use std::sync::Arc;
1515
use ton_client::abi::{
1616
Abi, AbiConfig, AbiContract};
17-
use ton_client::crypto::{CryptoConfig};
17+
use ton_client::crypto::{CryptoConfig, MnemonicDictionary};
1818
use ton_client::{ClientConfig, ClientContext};
1919

2020
pub const HD_PATH: &str = "m/44'/396'/0'/0/0";
@@ -53,7 +53,7 @@ pub fn create_client(conf: &Config) -> Result<TonClient, String> {
5353
message_expiration_timeout_grow_factor: 1.3,
5454
},
5555
crypto: CryptoConfig {
56-
mnemonic_dictionary: 1,
56+
mnemonic_dictionary: MnemonicDictionary::English,
5757
mnemonic_word_count: WORD_COUNT,
5858
hdkey_derivation_path: HD_PATH.to_string(),
5959
},

debot-browser/src/term_browser.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct DebotEntry {
3636

3737
/// Top level object. Created only once.
3838
pub struct TerminalBrowser {
39-
/// Instance of SDK client.
39+
/// Instance of SDK client.
4040
pub client: TonClient,
4141
/// User Information used by UserInfo interface
4242
pub user_settings: SharedUserSettings,
@@ -51,7 +51,7 @@ pub struct TerminalBrowser {
5151
callbacks: Arc<Callbacks>,
5252
/// Set of intrefaces implemented by current DBrowser.
5353
interfaces: SupportedInterfaces,
54-
/// Input chain Processor for Debot Manifest
54+
/// Input chain Processor for Debot Manifest
5555
processor: Arc<tokio::sync::RwLock<ChainProcessor>>,
5656
/// Indicates if Browser will interact with the user or not.
5757
interactive: bool,
@@ -66,7 +66,7 @@ impl TerminalBrowser {
6666
addr: String,
6767
) -> Result<Self, String> {
6868
let processor = Arc::new(tokio::sync::RwLock::new(ChainProcessor::new()));
69-
69+
7070
let callbacks = Arc::new(
7171
Callbacks::new(
7272
client.clone(),
@@ -77,14 +77,14 @@ impl TerminalBrowser {
7777
let user_settings = make_shared_settings(user_settings);
7878

7979
let interfaces = SupportedInterfaces::new(
80-
client.clone(),
80+
client.clone(),
8181
user_settings.clone(),
8282
processor.clone(),
8383
);
8484

8585
// TODO remove clone
8686
let main_debot_addr = addr.clone();
87-
87+
8888
let mut browser = Self {
8989
client,
9090
user_settings,
@@ -121,7 +121,7 @@ impl TerminalBrowser {
121121
let abi_version = info.dabi_version.clone();
122122
let abi_ref = info.dabi.as_ref();
123123
let abi = load_abi(&abi_ref.ok_or(format!("DeBot ABI is not defined"))?)?;
124-
124+
125125
if call_start {
126126
let mut run_debot = autorun;
127127
if !autorun {
@@ -233,7 +233,7 @@ impl TerminalBrowser {
233233

234234
if wc == DEBOT_WC {
235235
if id == BROWSER_ID {
236-
info!("Message from DeBot to Browser");
236+
info!("Message from DeBot to Browser");
237237
self.set_exit_arg(msg, msg_src).await?;
238238
} else {
239239
self.call_interface(msg, &id, msg_src).await?;
@@ -251,13 +251,13 @@ impl TerminalBrowser {
251251
let (start, call_set, mut init_message) = {
252252
let mut processor = self.processor.write().await;
253253
processor.load_manifest(manifest);
254-
(
254+
(
255255
processor.default_start(),
256256
processor.initial_call_set(),
257257
processor.initial_msg()
258258
)
259259
};
260-
260+
261261
self.exit_arg = None;
262262

263263
let abi = self.bots.get(&self.main_debot_addr)
@@ -297,7 +297,7 @@ impl TerminalBrowser {
297297
println!("DeBot Info:");
298298
fn print<'a>(field: &'a Option<String>) -> &'a str {
299299
field.as_ref().map(|v| v.as_str()).unwrap_or("None")
300-
}
300+
}
301301
println!("Name : {}", print(&info.name));
302302
println!("Version: {}", print(&info.version));
303303
println!("Author : {}", print(&info.author));
@@ -312,7 +312,7 @@ impl TerminalBrowser {
312312
let arg = if let Some(abi) = abi {
313313
let decoded = decode_message(
314314
self.client.clone(),
315-
ParamsOfDecodeMessage { abi, message },
315+
ParamsOfDecodeMessage { abi, message, allow_partial: false, function_name: None, data_layout: None },
316316
).await.map_err(|e| format!("{}", e))?;
317317
decoded.value.unwrap_or(json!({}))
318318
} else {

demo/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

demo/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="https://raw.githubusercontent.com/ever-guild/debot/main/asset/debot.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Debot browser</title>
8+
</head>
9+
<body>
10+
<div id="app"></div>
11+
<script type="module" src="/src/main.ts"></script>
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)