diff --git a/CHANGELOG.md b/CHANGELOG.md index e90b959..d102e2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to this project will be documented in this file. +## 0.6.0 (2023-05-??) + +* updated dependencies and ever-sdk to 1.42.1 +* rename package to `@ever-guild/debot-browser` + ## 0.5.5 (2022-04-05) ## Fixes @@ -82,4 +87,4 @@ All notable changes to this project will be documented in this file. - MVP of wasm debot browser. - add `run_debot_browser` API function. - - add test server. \ No newline at end of file + - add test server. diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..4922544 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,2223 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aes" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" +dependencies = [ + "cfg-if", + "cipher 0.3.0", + "cpufeatures", + "opaque-debug", +] + +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom 0.2.9", + "once_cell", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" +dependencies = [ + "memchr", +] + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "anyhow" +version = "1.0.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" + +[[package]] +name = "api_derive" +version = "1.42.1" +source = "git+https://github.com/tonlabs/ever-sdk.git?tag=1.42.1#4dbaac8c5c329b87f81fa463ce9e1efbcd6a5353" +dependencies = [ + "api_info", + "proc-macro2", + "quote", + "serde_json", + "syn 1.0.109", +] + +[[package]] +name = "api_info" +version = "1.42.1" +source = "git+https://github.com/tonlabs/ever-sdk.git?tag=1.42.1#4dbaac8c5c329b87f81fa463ce9e1efbcd6a5353" +dependencies = [ + "serde", + "serde_derive", + "serde_json", +] + +[[package]] +name = "arrayref" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" + +[[package]] +name = "async-trait" +version = "0.1.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.16", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "backtrace" +version = "0.3.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide 0.6.2", + "object", + "rustc-demangle", +] + +[[package]] +name = "base58" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" + +[[package]] +name = "base64" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" +dependencies = [ + "byteorder", +] + +[[package]] +name = "base64" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-modes" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cb03d1bed155d89dce0f845b7899b18a9a163e148fd004e1c28421a783e2d8e" +dependencies = [ + "block-padding", + "cipher 0.3.0", +] + +[[package]] +name = "block-padding" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" + +[[package]] +name = "bstr" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" +dependencies = [ + "memchr", +] + +[[package]] +name = "build_const" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ae4235e6dac0694637c763029ecea1a2ec9e4e06ec2729bd21ba4d9c863eb7" + +[[package]] +name = "builder" +version = "0.1.0" +dependencies = [ + "dirs", + "flate2", + "regex", + "serde", + "serde_json", + "wasmprinter", + "wat", +] + +[[package]] +name = "bumpalo" +version = "3.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c6ed94e98ecff0c12dd1b04c15ec0d7d9458ca8fe806cea6f12954efe74c63b" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "cc" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +dependencies = [ + "jobserver", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chacha20" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed8738f14471a99f0e316c327e68fc82a3611cc2895fcb604b89eedaf8f39d95" +dependencies = [ + "cipher 0.2.5", +] + +[[package]] +name = "chrono" +version = "0.4.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-integer", + "num-traits", + "time", + "wasm-bindgen", + "winapi", +] + +[[package]] +name = "cipher" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" +dependencies = [ + "generic-array", +] + +[[package]] +name = "cipher" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +dependencies = [ + "generic-array", +] + +[[package]] +name = "clear_on_drop" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38508a63f4979f0048febc9966fadbd48e5dab31fd0ec6a3f151bbf4a74f7423" +dependencies = [ + "cc", +] + +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if", + "wasm-bindgen", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" + +[[package]] +name = "cpufeatures" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" +dependencies = [ + "libc", +] + +[[package]] +name = "crc" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb" +dependencies = [ + "build_const", +] + +[[package]] +name = "crc" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484" + +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "crypto-mac" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "crypto-mac" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "curve25519-dalek" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core 0.5.1", + "subtle", + "zeroize", +] + +[[package]] +name = "debot-browser" +version = "0.6.0-rc.2" +dependencies = [ + "async-trait", + "base64 0.10.1", + "clear_on_drop", + "console_error_panic_hook", + "hex 0.4.3", + "js-sys", + "lazy_static", + "log", + "num-bigint", + "num-traits", + "rand 0.8.5", + "regex", + "serde", + "serde-wasm-bindgen", + "serde_derive", + "serde_json", + "tokio", + "ton_client", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-bindgen-test", + "web-sys", +] + +[[package]] +name = "diffy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c27ec7cef89a63c063e06570bb861b7d35e406d6885551b346d77c459b34d3db" +dependencies = [ + "ansi_term", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +dependencies = [ + "block-buffer 0.10.4", + "crypto-common", + "subtle", +] + +[[package]] +name = "dirs" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "ed25519" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" +dependencies = [ + "signature", +] + +[[package]] +name = "ed25519-dalek" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" +dependencies = [ + "curve25519-dalek", + "ed25519", + "rand 0.7.3", + "serde", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "extfmt" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a48fe53466ab1f4ea6303bf9d7a0ca8060778590f09fd6c3304cc817aeb9935d" + +[[package]] +name = "failure" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86" +dependencies = [ + "backtrace", + "failure_derive", +] + +[[package]] +name = "failure_derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", + "synstructure", +] + +[[package]] +name = "flate2" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" +dependencies = [ + "crc32fast", + "miniz_oxide 0.7.1", +] + +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" + +[[package]] +name = "futures-executor" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" + +[[package]] +name = "futures-macro" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.16", +] + +[[package]] +name = "futures-sink" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" + +[[package]] +name = "futures-task" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" + +[[package]] +name = "futures-util" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", + "wasm-bindgen", +] + +[[package]] +name = "gimli" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash", +] + +[[package]] +name = "hex" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hmac" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" +dependencies = [ + "crypto-mac 0.8.0", + "digest 0.9.0", +] + +[[package]] +name = "hmac" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +dependencies = [ + "crypto-mac 0.11.1", + "digest 0.9.0", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.6", +] + +[[package]] +name = "hmac-drbg" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" +dependencies = [ + "digest 0.9.0", + "generic-array", + "hmac 0.8.1", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "index-fixed" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161ceaf2f41b6cd3f6502f5da085d4ad4393a51e0c70ed2fce1d5698d798fae" + +[[package]] +name = "indexed_db_futures" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26ac735f676c52305becf53264b91cea9866a8de61ccbf464405b377b9cbca9" +dependencies = [ + "cfg-if", + "js-sys", + "uuid", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "itoa" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" + +[[package]] +name = "jobserver" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" +dependencies = [ + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.62" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68c16e1bfd491478ab155fd8b4896b86f9ede344949b641e61501e07c2b8b4d5" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "leb128" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" + +[[package]] +name = "libc" +version = "0.2.144" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" + +[[package]] +name = "libsecp256k1" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9d220bc1feda2ac231cb78c3d26f27676b8cf82c96971f7aeef3d0cf2797c73" +dependencies = [ + "arrayref", + "base64 0.12.3", + "digest 0.9.0", + "hmac-drbg", + "libsecp256k1-core", + "libsecp256k1-gen-ecmult", + "libsecp256k1-gen-genmult", + "rand 0.7.3", + "serde", + "sha2 0.9.9", + "typenum", +] + +[[package]] +name = "libsecp256k1-core" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0f6ab710cec28cef759c5f18671a27dae2a5f952cdaaee1d8e2908cb2478a80" +dependencies = [ + "crunchy", + "digest 0.9.0", + "subtle", +] + +[[package]] +name = "libsecp256k1-gen-ecmult" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccab96b584d38fac86a83f07e659f0deafd0253dc096dab5a36d53efe653c5c3" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "libsecp256k1-gen-genmult" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67abfe149395e3aa1c48a2beb32b068e2334402df8181f818d3aee2b304c4f5d" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "lockfree" +version = "0.5.1" +source = "git+https://github.com/tonlabs/lockfree.git#bfcb66587dc4ffed9e8e9248995ad2fe8dc3669e" +dependencies = [ + "owned-alloc", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "lru" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999beba7b6e8345721bd280141ed958096a2e4abdf74f67ff4ce49b4b54e47a" +dependencies = [ + "hashbrown", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "miniz_oxide" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" +dependencies = [ + "adler", +] + +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", +] + +[[package]] +name = "num" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + +[[package]] +name = "num-bigint" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-complex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e0d21255c828d6f128a1e41534206671e8c3ea0c62f32291e808dc82cff17d" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-derive" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "object" +version = "0.30.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "ordered-float" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7940cf2ca942593318d07fcf2596cdca60a85c9e7fab408a5e21a4f9dcd40d87" +dependencies = [ + "num-traits", +] + +[[package]] +name = "owned-alloc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30fceb411f9a12ff9222c5f824026be368ff15dc2f13468d850c7d3f502205d6" + +[[package]] +name = "pbkdf2" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa" +dependencies = [ + "crypto-mac 0.11.1", +] + +[[package]] +name = "pbkdf2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" +dependencies = [ + "digest 0.10.6", +] + +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" + +[[package]] +name = "pom" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60f6ce597ecdcc9a098e7fddacb1065093a3d66446fa16c675e7e71d1b5c28e6" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro2" +version = "1.0.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.9", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_users" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +dependencies = [ + "getrandom 0.2.9", + "redox_syscall", + "thiserror", +] + +[[package]] +name = "regex" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" + +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "ryu" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" + +[[package]] +name = "salsa20" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecbd2eb639fd7cab5804a0837fe373cc2172d15437e804c054a9fb885cb923b0" +dependencies = [ + "cipher 0.3.0", +] + +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + +[[package]] +name = "scrypt" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879588d8f90906e73302547e20fffefdd240eb3e0e744e142321f5d49dea0518" +dependencies = [ + "hmac 0.11.0", + "pbkdf2 0.8.0", + "salsa20", + "sha2 0.9.9", +] + +[[package]] +name = "secstr" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cce2c726741c320e5b8f1edd9a21b3c2c292ae94514afd001d41d81ba143dafc" +dependencies = [ + "libc", +] + +[[package]] +name = "serde" +version = "1.0.163" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde-wasm-bindgen" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3b143e2833c57ab9ad3ea280d21fd34e285a42837aeb0ee301f4f41890fa00e" +dependencies = [ + "js-sys", + "serde", + "wasm-bindgen", +] + +[[package]] +name = "serde_derive" +version = "1.0.163" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.16", +] + +[[package]] +name = "serde_json" +version = "1.0.96" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" +dependencies = [ + "indexmap", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_repr" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.16", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "sha2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.6", +] + +[[package]] +name = "signature" +version = "1.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" + +[[package]] +name = "similar" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "420acb44afdae038210c99e69aae24109f32f15500aa708e81d46c9f29d55fcf" +dependencies = [ + "bstr", +] + +[[package]] +name = "slab" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "sodalite" +version = "0.3.0" +source = "git+https://github.com/tonlabs/sodalite.git#667f7f01290c95fdbeadc5bce3e32c1d14b92fe1" +dependencies = [ + "index-fixed", + "rand 0.7.3", +] + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6f671d4b5ffdb8eadec19c0ae67fe2639df8684bd7bc4b83d986b8db549cf01" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", + "unicode-xid", +] + +[[package]] +name = "thiserror" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.16", +] + +[[package]] +name = "time" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" +dependencies = [ + "libc", + "wasi 0.10.0+wasi-snapshot-preview1", + "winapi", +] + +[[package]] +name = "tiny-bip39" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62cc94d358b5a1e84a5cb9109f559aa3c4d634d2b1b4de3d0fa4adc7c78e2861" +dependencies = [ + "anyhow", + "hmac 0.12.1", + "once_cell", + "pbkdf2 0.11.0", + "rand 0.8.5", + "rustc-hash", + "sha2 0.10.6", + "thiserror", + "unicode-normalization", + "wasm-bindgen", + "zeroize", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0aa32867d44e6f2ce3385e89dceb990188b8bb0fb25b0cf576647a6f98ac5105" +dependencies = [ + "autocfg", + "pin-project-lite", + "windows-sys", +] + +[[package]] +name = "tokio-stream" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "ton_abi" +version = "2.3.73" +source = "git+https://github.com/tonlabs/ever-abi.git?tag=2.3.73#cc50dcb6f04e8b2f9300e12d91bb57f15aadd44c" +dependencies = [ + "base64 0.10.1", + "byteorder", + "chrono", + "ed25519", + "ed25519-dalek", + "failure", + "hex 0.3.2", + "num-bigint", + "num-traits", + "serde", + "serde_derive", + "serde_json", + "sha2 0.10.6", + "ton_block 1.9.37", + "ton_types", +] + +[[package]] +name = "ton_api" +version = "0.2.185" +source = "git+https://github.com/tonlabs/ever-tl.git?tag=0.2.185#562c422f3136fe78d99518b4df62f1855eb83958" +dependencies = [ + "byteorder", + "extfmt", + "failure", + "hex 0.4.3", + "lazy_static", + "ordered-float", + "secstr", + "serde", + "serde_derive", + "serde_json", + "ton_block 1.9.37", + "ton_tl_codegen", + "ton_types", +] + +[[package]] +name = "ton_block" +version = "1.9.28" +source = "git+https://github.com/tonlabs/ever-block.git?tag=1.9.28#2d4130374d6b71e51156c51a589bfb92a05121bb" +dependencies = [ + "base64 0.13.1", + "crc 3.0.1", + "ed25519", + "ed25519-dalek", + "failure", + "hex 0.4.3", + "log", + "num", + "num-traits", + "sha2 0.10.6", + "ton_types", +] + +[[package]] +name = "ton_block" +version = "1.9.37" +source = "git+https://github.com/tonlabs/ever-block.git?tag=1.9.37#3a5a1bb0c6c5f20563f678885031e0942cb39c08" +dependencies = [ + "base64 0.13.1", + "crc 3.0.1", + "ed25519", + "ed25519-dalek", + "failure", + "hex 0.4.3", + "log", + "num", + "num-traits", + "sha2 0.10.6", + "ton_types", +] + +[[package]] +name = "ton_block_json" +version = "0.7.105" +source = "git+https://github.com/tonlabs/ever-block-json.git?tag=0.7.105#5405d633afa9638d2dcd89e5e4b1b8332b276ca5" +dependencies = [ + "base64 0.13.1", + "failure", + "hex 0.4.3", + "num", + "num-traits", + "serde", + "serde_derive", + "serde_json", + "ton_api", + "ton_block 1.9.37", + "ton_types", +] + +[[package]] +name = "ton_client" +version = "1.42.1" +source = "git+https://github.com/tonlabs/ever-sdk.git?tag=1.42.1#4dbaac8c5c329b87f81fa463ce9e1efbcd6a5353" +dependencies = [ + "aes", + "api_derive", + "api_info", + "async-trait", + "base58", + "base64 0.10.1", + "bincode", + "block-modes", + "byteorder", + "chacha20", + "chrono", + "crc 3.0.1", + "ed25519-dalek", + "failure", + "futures", + "hex 0.3.2", + "hmac 0.11.0", + "indexed_db_futures", + "js-sys", + "lazy_static", + "libsecp256k1", + "lockfree", + "log", + "lru", + "num-bigint", + "num-derive", + "num-traits", + "pbkdf2 0.8.0", + "rand 0.7.3", + "regex", + "scrypt", + "serde", + "serde_derive", + "serde_json", + "serde_repr", + "sha2 0.9.9", + "sodalite", + "tiny-bip39", + "tokio", + "tokio-stream", + "ton_abi", + "ton_block 1.9.37", + "ton_block_json", + "ton_client_processing", + "ton_executor", + "ton_sdk", + "ton_types", + "ton_vm", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "zeroize", + "zstd", +] + +[[package]] +name = "ton_client_processing" +version = "1.42.1" +source = "git+https://github.com/tonlabs/ever-sdk.git?tag=1.42.1#4dbaac8c5c329b87f81fa463ce9e1efbcd6a5353" +dependencies = [ + "api_derive", + "api_info", + "async-trait", + "base64 0.21.0", + "futures", + "log", + "serde", + "serde_derive", + "serde_json", + "serde_repr", + "tokio", + "ton_block 1.9.28", + "ton_types", +] + +[[package]] +name = "ton_executor" +version = "1.15.185" +source = "git+https://github.com/tonlabs/ever-executor.git?tag=1.15.185#a4de5692586262e61f052b03ce94201acb78c447" +dependencies = [ + "failure", + "lazy_static", + "log", + "ton_block 1.9.37", + "ton_types", + "ton_vm", +] + +[[package]] +name = "ton_sdk" +version = "1.42.1" +source = "git+https://github.com/tonlabs/ever-sdk.git?tag=1.42.1#4dbaac8c5c329b87f81fa463ce9e1efbcd6a5353" +dependencies = [ + "api_derive", + "api_info", + "base64 0.10.1", + "chrono", + "ed25519-dalek", + "failure", + "hex 0.3.2", + "lazy_static", + "log", + "num-bigint", + "num-traits", + "serde", + "serde_derive", + "serde_json", + "sha2 0.9.9", + "ton_abi", + "ton_block 1.9.37", + "ton_types", +] + +[[package]] +name = "ton_tl_codegen" +version = "0.0.2" +source = "git+https://github.com/tonlabs/ever-tl.git?tag=0.2.185#562c422f3136fe78d99518b4df62f1855eb83958" +dependencies = [ + "crc 1.8.1", + "failure", + "pom", + "proc-macro2", + "quote", + "serde", + "serde_derive", + "syn 1.0.109", +] + +[[package]] +name = "ton_types" +version = "1.12.7" +source = "git+https://github.com/tonlabs/ever-types.git?tag=1.12.7#d54c71302d899959fb944a73999d225917a0f769" +dependencies = [ + "base64 0.13.1", + "crc 1.8.1", + "failure", + "hex 0.4.3", + "lazy_static", + "lockfree", + "log", + "num", + "num-derive", + "num-traits", + "rand 0.8.5", + "sha2 0.9.9", + "smallvec", +] + +[[package]] +name = "ton_vm" +version = "1.8.125" +source = "git+https://github.com/tonlabs/ever-vm.git?tag=1.8.125#f9383849449f56d2ed0013f2044e1180c5994870" +dependencies = [ + "diffy", + "ed25519", + "ed25519-dalek", + "failure", + "hex 0.4.3", + "lazy_static", + "log", + "num", + "num-traits", + "rand 0.7.3", + "sha2 0.10.6", + "similar", + "ton_block 1.9.37", + "ton_types", + "zstd", +] + +[[package]] +name = "typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + +[[package]] +name = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + +[[package]] +name = "unicode-ident" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +dependencies = [ + "getrandom 0.2.9", +] + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b6cb788c4e39112fbe1822277ef6fb3c55cd86b95cb3d3c4c1c9597e4ac74b4" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35e522ed4105a9d626d885b35d62501b30d9666283a5c8be12c14a8bdafe7822" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.16", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "083abe15c5d88556b77bdf7aef403625be9e327ad37c62c4e4129af740168163" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "358a79a0cb89d21db8120cbfb91392335913e4890665b1a7981d9e956903b434" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4783ce29f09b9d93134d41297aded3a712b7b979e9c6f28c32cb88c973a94869" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.16", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a901d592cafaa4d711bc324edfaff879ac700b19c3dfd60058d2b445be2691eb" + +[[package]] +name = "wasm-bindgen-test" +version = "0.3.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b27e15b4a3030b9944370ba1d8cec6f21f66a1ad4fd14725c5685600460713ec" +dependencies = [ + "console_error_panic_hook", + "js-sys", + "scoped-tls", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-bindgen-test-macro", +] + +[[package]] +name = "wasm-bindgen-test-macro" +version = "0.3.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dbaa9b9a574eac00c4f3a9c4941ac051f07632ecd0484a8588abd95af6b99d2" +dependencies = [ + "proc-macro2", + "quote", +] + +[[package]] +name = "wasm-encoder" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d05d0b6fcd0aeb98adf16e7975331b3c17222aa815148f5b976370ce589d80ef" +dependencies = [ + "leb128", +] + +[[package]] +name = "wasmparser" +version = "0.104.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a396af81a7c56ad976131d6a35e4b693b78a1ea0357843bd436b4577e254a7d" +dependencies = [ + "indexmap", + "url", +] + +[[package]] +name = "wasmprinter" +version = "0.2.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "731da2505d5437cd5d6feb09457835f76186be13be7677fe00781ae99d5bbe8a" +dependencies = [ + "anyhow", + "wasmparser", +] + +[[package]] +name = "wast" +version = "57.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eb0f5ed17ac4421193c7477da05892c2edafd67f9639e3c11a82086416662dc" +dependencies = [ + "leb128", + "memchr", + "unicode-width", + "wasm-encoder", +] + +[[package]] +name = "wat" +version = "1.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab9ab0d87337c3be2bb6fc5cd331c4ba9fd6bcb4ee85048a0dd59ed9ecf92e53" +dependencies = [ + "wast", +] + +[[package]] +name = "web-sys" +version = "0.3.62" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b5f940c7edfdc6d12126d98c9ef4d1b3d470011c47c76a6581df47ad9ba721" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + +[[package]] +name = "zeroize" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.16", +] + +[[package]] +name = "zstd" +version = "0.11.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "5.0.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" +dependencies = [ + "libc", + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.8+zstd.1.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5556e6ee25d32df2586c098bbfa278803692a20d0ab9565e049480d52707ec8c" +dependencies = [ + "cc", + "libc", + "pkg-config", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..fe28cf2 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["builder", "debot-browser"] + +[profile.release] +opt-level = "s" +lto = true +codegen-units = 1 +strip = true diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5127845 --- /dev/null +++ b/Makefile @@ -0,0 +1,31 @@ +debot-browser/pkg: + cargo run --package builder --profile release +demo/node_modules: + cd demo && npm install +release-pkg: debot-browser/pkg + cp CHANGELOG.md debot-browser/pkg + cd debot-browser/pkg && npm publish --access public +gh-local: + git clone --depth=1 --branch=demo git@github.com:ever-guild/debot-browser.git gh-local +release-demo: debot-browser/pkg demo/node_modules gh-local + cd demo && npm run build + git -C gh-local rm -rf . + cp -r demo/dist/. gh-local + git -C gh-local add . + git -C gh-local commit -m "update demo" + git -C gh-local push origin demo +start: demo/node_modules + cd demo && npm run dev +clean: + cargo clean + rm -rf debot-browser/pkg + rm -rf demo/node_modules + rm -rf gh-local +test: + cargo test +fmt: + cargo fmt +fmt-check: + cargo fmt --all -- --check +lint: + cargo clippy --all-targets diff --git a/README.md b/README.md index a7cf53e..169b441 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,6 @@
- -

Cli Debot Browser

- - A standalone console Debot Browser written in Rust and compiled as WebAssembly. - +

Debot browser

+ A standalone console Debot browser written in Rust and compiled as WebAssembly
## How to use @@ -16,27 +13,24 @@ Read this [readme](./debot-browser/README.md) For building WebAssembly: -- Rust stable >= 1.55. -- [wasm-pack] tool. +- Rust stable >= 1.69.0 +- [wasm-pack] tool - Clang-8 (to successfully build zstd-sys) [wasm-pack]: https://rustwasm.github.io/wasm-pack/installer/ For running test example: -- npm >= 7.22.0 +- node >= 18 ### 🛠️ Compile wasm -```bash -cd builder -cargo run +```shell +make debot-browser/pkg ``` -## How to try + +### How to try ```bash -cd test-server -npm install -npm run start +make start ``` - diff --git a/builder/src/main.rs b/builder/src/main.rs index 188d2af..83ff208 100644 --- a/builder/src/main.rs +++ b/builder/src/main.rs @@ -44,21 +44,17 @@ fn fix_wat(mut wrapper: String) -> String { } fn main() { - let repo_dir = std::env::current_dir() - .unwrap() - .parent() - .unwrap() - .to_path_buf(); - let crate_dir = repo_dir.join(CRATE_NAME); - std::env::set_current_dir(&crate_dir).unwrap(); - - assert!(exec("wasm-pack", &["build", "--release"]).success()); + assert!(exec( + "wasm-pack", + &["build", CRATE_NAME, "--release", "--scope", "ever-guild",] + ) + .success()); + let repo_dir = std::env::current_dir().unwrap(); + let crate_dir = repo_dir.join(CRATE_NAME); let pkg_dir = crate_dir.join("pkg"); - let wasm_path = pkg_dir - .clone() - .join(&format!("{}_bg.wasm", CRATE_NAME).replace('-', "_")); + let wasm_path = pkg_dir.join(format!("{}_bg.wasm", CRATE_NAME).replace('-', "_")); println!("Disassembling wasm..."); let wat = wasmprinter::print_file(&wasm_path).unwrap(); @@ -69,7 +65,6 @@ fn main() { let fixed_wasm = wat::parse_str(fixed_wat).unwrap(); println!("Done."); fs::write(&wasm_path, fixed_wasm).unwrap(); - } pub fn exec(cmd: &str, args: &[&str]) -> ExitStatus { diff --git a/debot-browser/Cargo.toml b/debot-browser/Cargo.toml index 8c18a88..af8985c 100644 --- a/debot-browser/Cargo.toml +++ b/debot-browser/Cargo.toml @@ -1,26 +1,24 @@ [package] -authors = ["TON Labs "] +authors = ["Ever Guild"] edition = "2018" name = "debot-browser" -version = "0.5.5" -description = "Standalone cli DeBot Browser" -repository = "https://github.com/tonlabs/rust-debot-browser" +version = "0.6.0-rc.2" +description = "Standalone debot browser" +repository = "https://github.com/ever-guild/debot-browser" license = "Apache-2.0" keywords = [ "debot browser", "debot", "browser", "wasm", - "tonlabs", - "Surf", - "Everscale", + "tvm", ] [lib] crate-type = ["cdylib", "rlib"] [features] -default = [] # "console_error_panic_hook", +default = [] # "console_error_panic_hook", [dependencies.web-sys] version = "0.3" @@ -34,41 +32,31 @@ base64 = '0.10.1' # all the `std::fmt` and `std::panicking` infrastructure, so isn't great for # code size when deploying. console_error_panic_hook = { version = "0.1.6", optional = true } -hex = "0.3.2" -js-sys = "0.3.55" -lazy_static = "1.1.0" -log = { version = "0.4.11", features = ["std"] } -num-bigint = "0.4" -num-traits = "0.2" -serde = { version = "1.0", features = ["derive"] } -serde_derive = "1.0" -serde_json = "1.0" -rand = "0.7.3" -regex = "1.5.4" -serde-wasm-bindgen = "0.3.1" -tokio = { version = "0.2.13", features = [ - "sync", - "stream", -], default-features = false } - -ton_client = { git = 'https://github.com/tonlabs/TON-SDK.git', tag = '1.32.0', default-features = false, features = [ +hex = "0.4.3" +js-sys = "0.3.62" +lazy_static = "1.4.0" +log = { version = "0.4.17", features = ["std"] } +num-bigint = "0.4.3" +num-traits = "0.2.15" +serde = { version = "1.0.163", features = ["derive"] } +serde_derive = "1.0.163" +serde_json = "1.0.96" +rand = "0.8.5" +regex = "1.8.1" +serde-wasm-bindgen = "0.5.0" +tokio = "^1" +wasm-bindgen = "0.2.85" +wasm-bindgen-futures = "0.4.35" +ton_client = { git = 'https://github.com/tonlabs/ever-sdk.git', tag = '1.42.1', default-features = false, features = [ "wasm", ] } -wasm-bindgen = "0.2.77" -wasm-bindgen-futures = "0.4.27" - [dev-dependencies] -wasm-bindgen-test = "0.3.26" +wasm-bindgen-test = "0.3.35" [package.metadata.wasm-pack.profile.release] -wasm-opt = ['-Os'] - -[profile.release] -#lto = true -# Tell `rustc` to optimize for small code size. -opt-level = "s" +wasm-opt = ["-Oz", "--enable-mutable-globals"] [dependencies.clear_on_drop] features = ["no_cc"] -version = "0.2" #This version should match the version that the ed25519-dalek crate depends on. \ No newline at end of file +version = "0.2" # This version should match the version that the ed25519-dalek crate depends on. diff --git a/debot-browser/README.md b/debot-browser/README.md index 6a699ad..e328eca 100644 --- a/debot-browser/README.md +++ b/debot-browser/README.md @@ -1,32 +1,32 @@ +

+ + + +

- Standalone cli DeBot Browser + Debot browser

- Standalone DeBot Browser written in Rust and compiled as WebAssembly -
-
- + Standalone Debot browser written in Rust and compiled as WebAssembly

-# Cli DeBot Browser - ## Purpose -Run any DeBot in your website using DeBot Browser as Service. +Run any Debot in your website using Debot browser as service. ## Getting Started -To get started, install `debot-browser`: +To get started, install: -```sh -npm i debot-browser +```shell +npm install @ever-guild/debot-browser ``` -Run DeBot: +Run Debot: ```typescript -import * as browser from "debot-browser"; +import * as browser from "@ever-guild/debot-browser"; let defaultWallet = null; // or string with TON address let defaultPubkey = null; // or string with public key @@ -156,6 +156,5 @@ let manifest = `{ await browser.close_signing_box(browserHandle, sboxHandle) await browser.destroy_browser(browserHandle); - }); -``` \ No newline at end of file +``` diff --git a/debot-browser/src/api.rs b/debot-browser/src/api.rs index 69121f2..76505c0 100644 --- a/debot-browser/src/api.rs +++ b/debot-browser/src/api.rs @@ -22,10 +22,12 @@ use lazy_static::lazy_static; use log::{info, LevelFilter, SetLoggerError}; use serde::Serialize; use serde_wasm_bindgen::{from_value, to_value, Serializer}; -use std::sync::Arc; use std::collections::HashMap; +use std::sync::Arc; use tokio::sync::{Mutex, RwLock}; -use ton_client::crypto::{KeyPair, ParamsOfSign, RegisteredSigningBox, ParamsOfGenerateRandomBytes}; +use ton_client::crypto::{ + KeyPair, ParamsOfGenerateRandomBytes, ParamsOfSign, RegisteredSigningBox, +}; use ton_client::{ClientConfig, ClientContext}; use wasm_bindgen::prelude::*; @@ -34,17 +36,21 @@ lazy_static! { } struct BrowserTable { - table: RwLock> > >, + table: RwLock>>>, } impl BrowserTable { fn new() -> Self { - Self { table: RwLock::new(HashMap::new()) } + Self { + table: RwLock::new(HashMap::new()), + } } async fn insert(&self, browser: TerminalBrowser) -> BrowserHandle { let handle = Self::generate_handle(); - self.table.write().await + self.table + .write() + .await .insert(handle.clone(), Arc::new(Mutex::new(browser))); handle } @@ -63,7 +69,7 @@ impl BrowserTable { } pub(crate) fn init_log_() -> Result<(), SetLoggerError> { - log::set_logger(&LOGGER).map(|()| log::set_max_level(LevelFilter::Info)) + log::set_logger(&LOGGER).map(|()| log::set_max_level(LevelFilter::Trace)) } #[wasm_bindgen] @@ -71,6 +77,17 @@ pub fn init_log() -> Result<(), JsValue> { init_log_().map_err(|e| to_value(&e.to_string()).unwrap()) } +// Next let's define a macro that's like `println!`, only it works for +// `console.log`. Note that `println!` doesn't actually work on the wasm target +// because the standard library currently just eats all output. To get +// `println!`-like behavior in your app you'll likely want a macro like this. + +macro_rules! console_log { + // Note that this is using the `log` function imported above during + // `bare_bones` + ($($t:tt)*) => (log(&format_args!($($t)*).to_string())) +} + /// Starts Terminal DeBot Browser with main DeBot. /// /// Fetches DeBot by address from blockchain and runs it according to pipechain. @@ -154,7 +171,8 @@ pub async fn create_browser( #[wasm_bindgen] pub async fn destroy_browser(handle: BrowserHandle) -> Result<(), JsValue> { BROWSER_TABLE - .remove(&handle).await + .remove(&handle) + .await .ok_or(format!("invalid handle"))?; Ok(()) } @@ -167,7 +185,8 @@ pub async fn destroy_browser(handle: BrowserHandle) -> Result<(), JsValue> { pub async fn run_browser(handle: BrowserHandle, manifest: JsValue) -> Result { let manifest: DebotManifest = from_value(manifest).unwrap(); let browser = BROWSER_TABLE - .get(&handle).await + .get(&handle) + .await .ok_or(format!("invalid handle"))?; let result = browser.lock().await.run_manifest(manifest).await?; let serializer = Serializer::new().serialize_maps_as_objects(true); @@ -182,7 +201,8 @@ pub async fn run_browser(handle: BrowserHandle, manifest: JsValue) -> Result Result<(), JsValue> { let browser = BROWSER_TABLE - .get(&handle).await + .get(&handle) + .await .ok_or(format!("invalid handle"))?; let settings: UserSettings = from_value(settings).map_err(|e| JsValue::from_str(&e.to_string()))?; @@ -226,7 +246,8 @@ pub async fn register_signing_box( dapp_box: DAppSigningBox, ) -> Result { let browser = BROWSER_TABLE - .get(&handle).await + .get(&handle) + .await .ok_or(format!("invalid handle"))?; let client = browser.lock().await.client.clone(); @@ -243,7 +264,8 @@ pub async fn close_signing_box( sbox_handle: SigningBoxHandle, ) -> Result<(), JsValue> { let browser = BROWSER_TABLE - .get(&handle).await + .get(&handle) + .await .ok_or(format!("invalid handle"))?; let client = browser.lock().await.client.clone(); @@ -264,7 +286,8 @@ pub async fn signing_box_public_key( sbox_handle: SigningBoxHandle, ) -> Result { let browser = BROWSER_TABLE - .get(&handle).await + .get(&handle) + .await .ok_or(format!("invalid handle"))?; let client = browser.lock().await.client.clone(); @@ -309,14 +332,10 @@ pub fn scrypt(params: JsValue) -> Result { .map(|v| v.key) } - #[wasm_bindgen] pub fn generate_random_bytes(length: u32) -> Result { let ctx = Arc::new(ClientContext::new(ClientConfig::default()).unwrap()); - ton_client::crypto::generate_random_bytes( - ctx, - ParamsOfGenerateRandomBytes{ length } - ) - .map_err(|e| JsValue::from_str(&format!("{}", e))) - .map(|v| v.bytes) -} \ No newline at end of file + ton_client::crypto::generate_random_bytes(ctx, ParamsOfGenerateRandomBytes { length }) + .map_err(|e| JsValue::from_str(&format!("{}", e))) + .map(|v| v.bytes) +} diff --git a/debot-browser/src/callbacks.rs b/debot-browser/src/callbacks.rs index f3b667c..0a01d68 100644 --- a/debot-browser/src/callbacks.rs +++ b/debot-browser/src/callbacks.rs @@ -35,10 +35,7 @@ pub(super) struct Callbacks { } impl Callbacks { - pub fn new( - client: TonClient, - processor: Arc>, - ) -> Self { + pub fn new(client: TonClient, processor: Arc>) -> Self { Self { client, processor, @@ -179,8 +176,7 @@ impl BrowserCallbacks for Callbacks { } info += &format!(" Message signer public key: {}\n", signkey); if setcode { - info += - " Warning: the transaction will change the account's code\n"; + info += " Warning: the transaction will change the account's code\n"; } prompt = "Confirm the transaction (y/n)?"; } diff --git a/debot-browser/src/config.rs b/debot-browser/src/config.rs index aaf14a4..c1c0435 100644 --- a/debot-browser/src/config.rs +++ b/debot-browser/src/config.rs @@ -11,12 +11,12 @@ * limitations under the License. */ use crate::SigningBoxHandle; +use lazy_static::lazy_static; +use regex::Regex; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; use std::sync::Arc; use tokio::sync::RwLock; -use lazy_static::lazy_static; -use regex::Regex; fn default_wc() -> i32 { 0 @@ -38,14 +38,16 @@ fn default_false() -> bool { false } -fn default_true() -> bool { true } +fn default_true() -> bool { + true +} fn default_lifetime() -> u32 { 60 } fn default_endpoints() -> Vec { - return vec!(); + return vec![]; } #[derive(Serialize, Deserialize, Clone)] @@ -128,31 +130,30 @@ impl Config { #[cfg(not(target_arch = "wasm32"))] pub fn from_file(path: &str) -> Option { let conf_str = std::fs::read_to_string(path).ok()?; - let conf: serde_json::error::Result = serde_json::from_str(&conf_str); - conf.map(|c| c.config).or_else(|_| serde_json::from_str(&conf_str)).ok() + let conf: serde_json::error::Result = serde_json::from_str(&conf_str); + conf.map(|c| c.config) + .or_else(|_| serde_json::from_str(&conf_str)) + .ok() } #[cfg(not(target_arch = "wasm32"))] pub fn to_file(path: &str, conf: &Config) -> Result<(), String> { - let mut fconf= FullConfig::from_file(path); + let mut fconf = FullConfig::from_file(path); fconf.config = conf.to_owned(); FullConfig::to_file(path, &fconf) } } - lazy_static! { static ref MAIN_ENDPOINTS: Vec = vec![ "https://main2.ton.dev".to_string(), "https://main3.ton.dev".to_string(), "https://main4.ton.dev".to_string(), ]; - static ref NET_ENDPOINTS: Vec = vec![ "https://net1.ton.dev".to_string(), "https://net5.ton.dev".to_string(), ]; - static ref SE_ENDPOINTS: Vec = vec![ "http://0.0.0.0/".to_string(), "http://127.0.0.1/".to_string(), @@ -171,9 +172,7 @@ pub fn resolve_net_name(url: &str) -> Option { } } } - if url.contains("127.0.0.1") || - url.contains("0.0.0.0") || - url.contains("localhost") { + if url.contains("127.0.0.1") || url.contains("0.0.0.0") || url.contains("localhost") { return Some("http://127.0.0.1/".to_string()); } None @@ -184,7 +183,7 @@ pub(crate) fn resolve_endpoints(url: &str) -> Vec { Some(network) => FullConfig::default_map()[&network].clone(), None => vec![url.to_string()], } -} +} impl FullConfig { pub fn new() -> Self { @@ -194,10 +193,14 @@ impl FullConfig { } } pub fn default_map() -> BTreeMap> { - [("main.ton.dev".to_owned(), MAIN_ENDPOINTS.to_owned()), + [ + ("main.ton.dev".to_owned(), MAIN_ENDPOINTS.to_owned()), ("net.ton.dev".to_owned(), NET_ENDPOINTS.to_owned()), ("http://127.0.0.1/".to_owned(), SE_ENDPOINTS.to_owned()), - ].iter().cloned().collect() + ] + .iter() + .cloned() + .collect() } #[allow(dead_code)] @@ -206,19 +209,22 @@ impl FullConfig { } pub fn from_file(path: &str) -> FullConfig { let conf_str = std::fs::read_to_string(path).ok().unwrap_or_default(); - serde_json::from_str(&conf_str).ok().unwrap_or(FullConfig::new()) + serde_json::from_str(&conf_str) + .ok() + .unwrap_or(FullConfig::new()) } - pub fn to_file(path: &str, fconf: &FullConfig) -> Result<(), String>{ + pub fn to_file(path: &str, fconf: &FullConfig) -> Result<(), String> { let conf_str = serde_json::to_string_pretty(fconf) .map_err(|_| "failed to serialize config object".to_string())?; - std::fs::write(path, conf_str).map_err(|e| format!("failed to write config file: {}", e))?; + std::fs::write(path, conf_str) + .map_err(|e| format!("failed to write config file: {}", e))?; Ok(()) } } #[cfg(test)] mod tests { - use super::{resolve_net_name}; + use super::resolve_net_name; #[test] fn test_endpoints_resolver() { @@ -227,28 +233,73 @@ mod tests { assert_eq!(resolve_net_name("https://rustnet.ton.dev"), None); assert_eq!(resolve_net_name("rustnet.ton.com"), None); assert_eq!(resolve_net_name("https://example.com"), None); - assert_eq!(resolve_net_name("http://localhost"), Some("http://127.0.0.1/".to_owned())); - assert_eq!(resolve_net_name("https://localhost"), Some("http://127.0.0.1/".to_owned())); - assert_eq!(resolve_net_name("localhost"), Some("http://127.0.0.1/".to_owned())); - assert_eq!(resolve_net_name("http://127.0.0.1"), Some("http://127.0.0.1/".to_owned())); - assert_eq!(resolve_net_name("https://127.0.0.1"), Some("http://127.0.0.1/".to_owned())); + assert_eq!( + resolve_net_name("http://localhost"), + Some("http://127.0.0.1/".to_owned()) + ); + assert_eq!( + resolve_net_name("https://localhost"), + Some("http://127.0.0.1/".to_owned()) + ); + assert_eq!( + resolve_net_name("localhost"), + Some("http://127.0.0.1/".to_owned()) + ); + assert_eq!( + resolve_net_name("http://127.0.0.1"), + Some("http://127.0.0.1/".to_owned()) + ); + assert_eq!( + resolve_net_name("https://127.0.0.1"), + Some("http://127.0.0.1/".to_owned()) + ); assert_eq!(resolve_net_name("https://127.0.0.2"), None); assert_eq!(resolve_net_name("https://127.1.0.1"), None); assert_eq!(resolve_net_name("https://0.0.0.1"), None); assert_eq!(resolve_net_name("https://1.0.0.0"), None); - assert_eq!(resolve_net_name("https://main.ton.dev"), Some("main.ton.dev".to_owned())); - assert_eq!(resolve_net_name("http://main.ton.dev"), Some("main.ton.dev".to_owned())); - assert_eq!(resolve_net_name(" http://main.ton.dev "), Some("main.ton.dev".to_owned())); - assert_eq!(resolve_net_name(" https://main.ton.dev "), Some("main.ton.dev".to_owned())); - assert_eq!(resolve_net_name("main.ton.dev"), Some("main.ton.dev".to_owned())); + assert_eq!( + resolve_net_name("https://main.ton.dev"), + Some("main.ton.dev".to_owned()) + ); + assert_eq!( + resolve_net_name("http://main.ton.dev"), + Some("main.ton.dev".to_owned()) + ); + assert_eq!( + resolve_net_name(" http://main.ton.dev "), + Some("main.ton.dev".to_owned()) + ); + assert_eq!( + resolve_net_name(" https://main.ton.dev "), + Some("main.ton.dev".to_owned()) + ); + assert_eq!( + resolve_net_name("main.ton.dev"), + Some("main.ton.dev".to_owned()) + ); assert_eq!(resolve_net_name("main.ton.com"), None); - assert_eq!(resolve_net_name("https://net.ton.dev"), Some("net.ton.dev".to_owned())); - assert_eq!(resolve_net_name("http://net.ton.dev"), Some("net.ton.dev".to_owned())); - assert_eq!(resolve_net_name(" http://net.ton.dev "), Some("net.ton.dev".to_owned())); - assert_eq!(resolve_net_name(" https://net.ton.dev "), Some("net.ton.dev".to_owned())); - assert_eq!(resolve_net_name("net.ton.dev"), Some("net.ton.dev".to_owned())); + assert_eq!( + resolve_net_name("https://net.ton.dev"), + Some("net.ton.dev".to_owned()) + ); + assert_eq!( + resolve_net_name("http://net.ton.dev"), + Some("net.ton.dev".to_owned()) + ); + assert_eq!( + resolve_net_name(" http://net.ton.dev "), + Some("net.ton.dev".to_owned()) + ); + assert_eq!( + resolve_net_name(" https://net.ton.dev "), + Some("net.ton.dev".to_owned()) + ); + assert_eq!( + resolve_net_name("net.ton.dev"), + Some("net.ton.dev".to_owned()) + ); assert_eq!(resolve_net_name("net.ton.com"), None); } } diff --git a/debot-browser/src/crypto.rs b/debot-browser/src/crypto.rs index 24ceb1e..95872f0 100644 --- a/debot-browser/src/crypto.rs +++ b/debot-browser/src/crypto.rs @@ -10,21 +10,14 @@ * See the License for the specific TON DEV software governing permissions and * limitations under the License. */ -use crate::helpers::{create_client_local, WORD_COUNT, HD_PATH}; #[cfg(not(target_arch = "wasm32"))] use crate::helpers::read_keys; +use crate::helpers::{create_client_local, HD_PATH, WORD_COUNT}; 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 + hdkey_derive_from_xprv_path, hdkey_secret_from_xprv, hdkey_xprv_from_mnemonic, + mnemonic_from_random, nacl_sign_keypair_from_secret_key, KeyPair, MnemonicDictionary, + ParamsOfHDKeyDeriveFromXPrvPath, ParamsOfHDKeySecretFromXPrv, ParamsOfHDKeyXPrvFromMnemonic, + ParamsOfMnemonicFromRandom, ParamsOfNaclSignKeyPairFromSecret, }; #[cfg(not(target_arch = "wasm32"))] @@ -48,7 +41,7 @@ pub fn gen_seed_phrase() -> Result { mnemonic_from_random( client, ParamsOfMnemonicFromRandom { - dictionary: Some(1), + dictionary: Some(MnemonicDictionary::English), word_count: Some(WORD_COUNT), ..Default::default() }, @@ -62,12 +55,13 @@ pub fn generate_keypair_from_mnemonic(mnemonic: &str) -> Result let hdk_master = hdkey_xprv_from_mnemonic( client.clone(), ParamsOfHDKeyXPrvFromMnemonic { - dictionary: Some(1), + dictionary: Some(MnemonicDictionary::English), word_count: Some(WORD_COUNT), phrase: mnemonic.to_string(), ..Default::default() }, - ).map_err(|e| format!("{}", e))?; + ) + .map_err(|e| format!("{}", e))?; let hdk_root = hdkey_derive_from_xprv_path( client.clone(), @@ -76,7 +70,8 @@ pub fn generate_keypair_from_mnemonic(mnemonic: &str) -> Result path: HD_PATH.to_string(), ..Default::default() }, - ).map_err(|e| format!("{}", e))?; + ) + .map_err(|e| format!("{}", e))?; let secret = hdkey_secret_from_xprv( client.clone(), @@ -84,7 +79,8 @@ pub fn generate_keypair_from_mnemonic(mnemonic: &str) -> Result xprv: hdk_root.xprv, ..Default::default() }, - ).map_err(|e| format!("{}", e))?; + ) + .map_err(|e| format!("{}", e))?; let mut keypair: KeyPair = nacl_sign_keypair_from_secret_key( client.clone(), @@ -92,11 +88,12 @@ pub fn generate_keypair_from_mnemonic(mnemonic: &str) -> Result secret: secret.secret, ..Default::default() }, - ).map_err(|e| format!("failed to get KeyPair from secret key: {}", e))?; + ) + .map_err(|e| format!("failed to get KeyPair from secret key: {}", e))?; // special case if secret contains public key too. - let secret = hex::decode(&keypair.secret) - .map_err(|e| format!("failed to decode the keypair: {}", e))?; + let secret = + hex::decode(&keypair.secret).map_err(|e| format!("failed to decode the keypair: {}", e))?; if secret.len() > 32 { keypair.secret = hex::encode(&secret[..32]); } @@ -109,15 +106,29 @@ mod tests { #[test] fn test_generate_keypair() { - let mnemonic = "multiply extra monitor fog rocket defy attack right night jaguar hollow enlist"; + let mnemonic = + "multiply extra monitor fog rocket defy attack right night jaguar hollow enlist"; let keypair = generate_keypair_from_mnemonic(mnemonic).unwrap(); - assert_eq!(&keypair.public, "757221fe3d4992e44632e75e700aaf205d799cb7373ee929273daf26adf29e56"); - assert_eq!(&keypair.secret, "30e3bc5e67af2b0a72971bcc11256e83d052c6cb861a69a19a8af88922fadf3a"); + assert_eq!( + &keypair.public, + "757221fe3d4992e44632e75e700aaf205d799cb7373ee929273daf26adf29e56" + ); + assert_eq!( + &keypair.secret, + "30e3bc5e67af2b0a72971bcc11256e83d052c6cb861a69a19a8af88922fadf3a" + ); - let mnemonic = "penalty nut enrich input palace flame safe session torch depth various hunt"; + let mnemonic = + "penalty nut enrich input palace flame safe session torch depth various hunt"; let keypair = generate_keypair_from_mnemonic(mnemonic).unwrap(); - assert_eq!(&keypair.public, "8cf557aab2666867a1174e3147d89ddf28c2041a7322522276cd1cf1df47ae73"); - assert_eq!(&keypair.secret, "f63d3d11e0dc91f730f22d5397f269e01f1a5f984879c8581ac87f099bfd3b3a"); + assert_eq!( + &keypair.public, + "8cf557aab2666867a1174e3147d89ddf28c2041a7322522276cd1cf1df47ae73" + ); + assert_eq!( + &keypair.secret, + "f63d3d11e0dc91f730f22d5397f269e01f1a5f984879c8581ac87f099bfd3b3a" + ); } #[test] @@ -144,5 +155,4 @@ mod tests { assert!(generate_keypair_from_mnemonic(phrase).is_err()); } } - } diff --git a/debot-browser/src/helpers.rs b/debot-browser/src/helpers.rs index a0b4893..4ebd577 100644 --- a/debot-browser/src/helpers.rs +++ b/debot-browser/src/helpers.rs @@ -12,9 +12,8 @@ */ use crate::config::Config; use std::sync::Arc; -use ton_client::abi::{ - Abi, AbiConfig, AbiContract}; -use ton_client::crypto::{CryptoConfig}; +use ton_client::abi::{Abi, AbiConfig, AbiContract}; +use ton_client::crypto::{CryptoConfig, MnemonicDictionary}; use ton_client::{ClientConfig, ClientContext}; pub const HD_PATH: &str = "m/44'/396'/0'/0/0"; @@ -53,7 +52,7 @@ pub fn create_client(conf: &Config) -> Result { message_expiration_timeout_grow_factor: 1.3, }, crypto: CryptoConfig { - mnemonic_dictionary: 1, + mnemonic_dictionary: MnemonicDictionary::English, mnemonic_word_count: WORD_COUNT, hdkey_derivation_path: HD_PATH.to_string(), }, diff --git a/debot-browser/src/interfaces/address_input.rs b/debot-browser/src/interfaces/address_input.rs index ec077c1..e888314 100644 --- a/debot-browser/src/interfaces/address_input.rs +++ b/debot-browser/src/interfaces/address_input.rs @@ -1,7 +1,7 @@ use super::dinterface::{decode_answer_id, decode_prompt}; use crate::helpers::load_ton_address; use crate::term_browser::terminal_input; -use serde_json::{Value, json}; +use serde_json::{json, Value}; use ton_client::abi::Abi; use ton_client::debot::{DebotInterface, InterfaceResult}; diff --git a/debot-browser/src/interfaces/amount_input.rs b/debot-browser/src/interfaces/amount_input.rs index 9be8b12..de92fee 100644 --- a/debot-browser/src/interfaces/amount_input.rs +++ b/debot-browser/src/interfaces/amount_input.rs @@ -1,7 +1,7 @@ use super::dinterface::{decode_answer_id, decode_num_arg, decode_prompt}; use crate::convert; use crate::term_browser::terminal_input; -use serde_json::{Value, json}; +use serde_json::{json, Value}; use ton_client::abi::Abi; use ton_client::debot::{DebotInterface, InterfaceResult}; use ton_client::encoding::decode_abi_number; diff --git a/debot-browser/src/interfaces/confirm_input.rs b/debot-browser/src/interfaces/confirm_input.rs index b0ad866..59ce0c8 100644 --- a/debot-browser/src/interfaces/confirm_input.rs +++ b/debot-browser/src/interfaces/confirm_input.rs @@ -1,6 +1,6 @@ use super::dinterface::{decode_answer_id, decode_prompt}; use crate::term_browser::terminal_input; -use serde_json::{Value, json}; +use serde_json::{json, Value}; use ton_client::abi::Abi; use ton_client::debot::{DebotInterface, InterfaceResult}; diff --git a/debot-browser/src/interfaces/dinterface.rs b/debot-browser/src/interfaces/dinterface.rs index bac186b..4ab26dd 100644 --- a/debot-browser/src/interfaces/dinterface.rs +++ b/debot-browser/src/interfaces/dinterface.rs @@ -1,15 +1,15 @@ use super::echo::Echo; use super::stdout::Stdout; use super::{ - AddressInput, AmountInput, ConfirmInput, EncryptionBoxInput, InputInterface, Menu, - NumberInput, SigningBoxInput, Terminal, UserInfo + AddressInput, AmountInput, ConfirmInput, EncryptionBoxInput, InputInterface, Menu, NumberInput, + SigningBoxInput, Terminal, UserInfo, }; use crate::config::SharedUserSettings; use crate::helpers::TonClient; use crate::ChainProcessor; use num_bigint::BigInt; use num_traits::cast::NumCast; -use serde_json::{Value}; +use serde_json::Value; use std::collections::HashMap; use std::sync::Arc; use tokio::sync::RwLock; @@ -46,13 +46,18 @@ impl InterfaceWrapper { } impl SupportedInterfaces { - pub fn new(client: TonClient, settings: SharedUserSettings, processor: Arc>) -> Self { + pub fn new( + client: TonClient, + settings: SharedUserSettings, + processor: Arc>, + ) -> Self { let mut interfaces = HashMap::new(); - let iw = InterfaceWrapper { processor: processor.clone() }; + let iw = InterfaceWrapper { + processor: processor.clone(), + }; - let iface: Arc = - iw.wrap(Arc::new(AddressInput::new())); + let iface: Arc = iw.wrap(Arc::new(AddressInput::new())); interfaces.insert(iface.get_id(), iface); let iface: Arc = iw.wrap(Arc::new(AmountInput::new())); @@ -71,18 +76,17 @@ impl SupportedInterfaces { interfaces.insert(iface.get_id(), iface); let iface: Arc = - iw.wrap(Arc::new(Terminal::new(Printer {processor}))); + iw.wrap(Arc::new(Terminal::new(Printer { processor }))); interfaces.insert(iface.get_id(), iface); let iface: Arc = iw.wrap(Arc::new(Menu::new())); interfaces.insert(iface.get_id(), iface); - let iface: Arc = Arc::new( - SigningBoxInput::new(client.clone(), iw.processor.clone()) - ); + let iface: Arc = + Arc::new(SigningBoxInput::new(client.clone(), iw.processor.clone())); interfaces.insert(iface.get_id(), iface); - let iface: Arc = + let iface: Arc = Arc::new(UserInfo::new(client.clone(), settings)); interfaces.insert(iface.get_id(), iface); diff --git a/debot-browser/src/interfaces/echo.rs b/debot-browser/src/interfaces/echo.rs index 966add0..81be5e0 100644 --- a/debot-browser/src/interfaces/echo.rs +++ b/debot-browser/src/interfaces/echo.rs @@ -10,7 +10,7 @@ * See the License for the specific TON DEV software governing permissions and * limitations under the License. */ -use serde_json::{Value, json}; +use serde_json::{json, Value}; use ton_client::abi::Abi; use ton_client::debot::{DebotInterface, InterfaceResult}; @@ -48,35 +48,35 @@ pub const ECHO_ABI: &str = r#" pub struct Echo {} impl Echo { - pub fn new() -> Self { - Self {} - } + pub fn new() -> Self { + Self {} + } - fn echo(&self, args: &Value) -> InterfaceResult { - let answer_id = u32::from_str_radix(args["answerId"].as_str().unwrap(), 10).unwrap(); - let request_vec = hex::decode(args["request"].as_str().unwrap()).unwrap(); - let request = std::str::from_utf8(&request_vec).unwrap(); - Ok(( - answer_id, - json!({ "response": hex::encode(request.as_bytes()) }), - )) - } + fn echo(&self, args: &Value) -> InterfaceResult { + let answer_id = u32::from_str_radix(args["answerId"].as_str().unwrap(), 10).unwrap(); + let request_vec = hex::decode(args["request"].as_str().unwrap()).unwrap(); + let request = std::str::from_utf8(&request_vec).unwrap(); + Ok(( + answer_id, + json!({ "response": hex::encode(request.as_bytes()) }), + )) + } } #[async_trait::async_trait] impl DebotInterface for Echo { - fn get_id(&self) -> String { - ECHO_ID.to_string() - } + fn get_id(&self) -> String { + ECHO_ID.to_string() + } - fn get_abi(&self) -> Abi { - Abi::Json(ECHO_ABI.to_owned()) - } + fn get_abi(&self) -> Abi { + Abi::Json(ECHO_ABI.to_owned()) + } - async fn call(&self, func: &str, args: &Value) -> InterfaceResult { - match func { - "echo" => self.echo(args), - _ => Err(format!("function \"{}\" is not implemented", func)), - } - } + async fn call(&self, func: &str, args: &Value) -> InterfaceResult { + match func { + "echo" => self.echo(args), + _ => Err(format!("function \"{}\" is not implemented", func)), + } + } } diff --git a/debot-browser/src/interfaces/encryption_box_input.rs b/debot-browser/src/interfaces/encryption_box_input.rs index 19e71db..d0b6238 100644 --- a/debot-browser/src/interfaces/encryption_box_input.rs +++ b/debot-browser/src/interfaces/encryption_box_input.rs @@ -1,12 +1,14 @@ -use super::dinterface::{decode_answer_id, decode_nonce, decode_prompt, decode_arg, decode_num_arg}; +use super::dinterface::{ + decode_answer_id, decode_arg, decode_nonce, decode_num_arg, decode_prompt, +}; +use crate::helpers::TonClient; use crate::term_encryption_box::{ EncryptionBoxType, ParamsOfTerminalEncryptionBox, TerminalEncryptionBox, }; -use crate::helpers::TonClient; use serde_json::{json, Value}; use tokio::sync::RwLock; -use ton_client::{abi::Abi, crypto::EncryptionBoxHandle}; use ton_client::debot::{DebotInterface, InterfaceResult}; +use ton_client::{abi::Abi, crypto::EncryptionBoxHandle}; const ID: &'static str = "5b5f76b54d976d72f1ada3063d1af2e5352edaf1ba86b3b311170d4d81056d61"; @@ -119,8 +121,12 @@ impl EncryptionBoxInput { box_type: EncryptionBoxType::NaCl, their_pubkey: their_pubkey, nonce: nonce, - }).await; - Ok((answer_id, json!({ "handle": self.insert_box(result).await.0 }))) + }) + .await; + Ok(( + answer_id, + json!({ "handle": self.insert_box(result).await.0 }), + )) } async fn get_nacl_secret_box(&self, args: &Value) -> InterfaceResult { let answer_id = decode_answer_id(args)?; @@ -134,7 +140,10 @@ impl EncryptionBoxInput { nonce: nonce, }) .await; - Ok((answer_id, json!({ "handle": self.insert_box(result).await.0}))) + Ok(( + answer_id, + json!({ "handle": self.insert_box(result).await.0}), + )) } async fn get_chacha20_box(&self, args: &Value) -> InterfaceResult { let answer_id = decode_answer_id(args)?; @@ -148,7 +157,10 @@ impl EncryptionBoxInput { nonce, }) .await; - Ok((answer_id, json!({ "handle": self.insert_box(result).await.0}))) + Ok(( + answer_id, + json!({ "handle": self.insert_box(result).await.0}), + )) } async fn remove_handle(&self, args: &Value) -> InterfaceResult { let answer_id = decode_answer_id(args)?; @@ -173,13 +185,16 @@ impl EncryptionBoxInput { }), )) } - async fn insert_box(&self, result_box: Result) -> EncryptionBoxHandle { + async fn insert_box( + &self, + result_box: Result, + ) -> EncryptionBoxHandle { match result_box { Ok(enc_box) => { let handle = enc_box.handle(); self.handles.write().await.push(enc_box); handle - }, + } Err(_) => 0.into(), } } @@ -206,4 +221,3 @@ impl DebotInterface for EncryptionBoxInput { } } } - diff --git a/debot-browser/src/interfaces/input_interface.rs b/debot-browser/src/interfaces/input_interface.rs index d35469c..29018be 100644 --- a/debot-browser/src/interfaces/input_interface.rs +++ b/debot-browser/src/interfaces/input_interface.rs @@ -14,7 +14,7 @@ use super::dinterface::{decode_answer_id, decode_prompt, decode_string_arg}; use super::menu::{MenuItem, ID as MENU_ID}; use super::terminal::ID as TERMINAL_ID; use crate::{ChainProcessor, ProcessorError}; -use serde_json::{Value, json}; +use serde_json::{json, Value}; use std::sync::Arc; use tokio::sync::RwLock; use ton_client::abi::Abi; @@ -53,12 +53,16 @@ impl DebotInterface for InputInterface { return self.inner_interface.call(func, args).await; } } - let result = self.processor.write().await.next_input(&self.get_id(), func, args); + let result = self + .processor + .write() + .await + .next_input(&self.get_id(), func, args); match result { Err(ProcessorError::InterfaceCallNeeded) => { let res = self.inner_interface.call(func, args).await?; Ok(res) - }, + } Err(e) => Err(format!("{:?}", e))?, Ok(params) => { let prompt = decode_prompt(args); @@ -77,12 +81,14 @@ impl DebotInterface for InputInterface { } } let answer_id = if self.get_id() == MENU_ID { - let n = params["index"].as_u64() + let n = params["index"] + .as_u64() .ok_or(format!("invalid arguments for menu callback"))?; - let menu_items: Vec = serde_json::from_value(args["items"].clone()) - .map_err(|e| e.to_string())?; + let menu_items: Vec = + serde_json::from_value(args["items"].clone()).map_err(|e| e.to_string())?; let menu = menu_items.get(n as usize); - menu.ok_or(format!("menu index is out of range"))?.handler_id + menu.ok_or(format!("menu index is out of range"))? + .handler_id } else { decode_answer_id(args)? }; @@ -90,4 +96,4 @@ impl DebotInterface for InputInterface { } } } -} \ No newline at end of file +} diff --git a/debot-browser/src/interfaces/menu.rs b/debot-browser/src/interfaces/menu.rs index e29cce1..2c088cc 100644 --- a/debot-browser/src/interfaces/menu.rs +++ b/debot-browser/src/interfaces/menu.rs @@ -13,12 +13,13 @@ use super::dinterface::decode_string_arg; use crate::term_browser::action_input; use serde::{de, Deserialize, Deserializer}; -use serde_json::{Value, json}; +use serde_json::{json, Value}; use ton_client::abi::Abi; use ton_client::debot::{DebotInterface, InterfaceResult}; use ton_client::encoding::decode_abi_number; -pub(super) const ID: &'static str = "ac1a4d3ecea232e49783df4a23a81823cdca3205dc58cd20c4db259c25605b48"; +pub(super) const ID: &'static str = + "ac1a4d3ecea232e49783df4a23a81823cdca3205dc58cd20c4db259c25605b48"; const ABI: &str = r#" { @@ -70,7 +71,7 @@ pub struct MenuItem { fn from_abi_num<'de, D>(des: D) -> Result where - D: Deserializer<'de> + D: Deserializer<'de>, { let s: String = Deserialize::deserialize(des)?; decode_abi_number(&s).map_err(de::Error::custom) @@ -78,9 +79,9 @@ where pub struct Menu {} impl Menu { - pub fn new() -> Self { - Self{} - } + pub fn new() -> Self { + Self {} + } fn select(&self, args: &Value) -> InterfaceResult { let menu_items: Vec = serde_json::from_value(args["items"].clone()).unwrap(); @@ -111,7 +112,7 @@ impl Menu { continue; } - return Ok(( menu.unwrap().handler_id, json!({ "index": n - 1 }) )); + return Ok((menu.unwrap().handler_id, json!({ "index": n - 1 }))); } } } diff --git a/debot-browser/src/interfaces/mod.rs b/debot-browser/src/interfaces/mod.rs index f68d8f7..98f9c88 100644 --- a/debot-browser/src/interfaces/mod.rs +++ b/debot-browser/src/interfaces/mod.rs @@ -16,8 +16,8 @@ pub mod amount_input; pub mod confirm_input; pub mod dinterface; pub mod echo; -pub mod input_interface; pub mod encryption_box_input; +pub mod input_interface; pub mod menu; pub mod number_input; pub mod signing_box_input; @@ -27,10 +27,10 @@ pub mod userinfo; pub use address_input::AddressInput; pub use amount_input::AmountInput; pub use confirm_input::ConfirmInput; +pub use encryption_box_input::EncryptionBoxInput; +pub use input_interface::InputInterface; pub use menu::Menu; pub use number_input::NumberInput; pub use signing_box_input::SigningBoxInput; -pub use input_interface::InputInterface; -pub use encryption_box_input::EncryptionBoxInput; pub use terminal::Terminal; -pub use userinfo::UserInfo; \ No newline at end of file +pub use userinfo::UserInfo; diff --git a/debot-browser/src/interfaces/number_input.rs b/debot-browser/src/interfaces/number_input.rs index 0fe1b54..209d15d 100644 --- a/debot-browser/src/interfaces/number_input.rs +++ b/debot-browser/src/interfaces/number_input.rs @@ -1,6 +1,6 @@ use super::dinterface::{decode_answer_id, decode_int256, decode_prompt}; use crate::term_browser::terminal_input; -use serde_json::{Value, json}; +use serde_json::{json, Value}; use ton_client::abi::Abi; use ton_client::debot::{DebotInterface, InterfaceResult}; use ton_client::encoding::decode_abi_bigint; @@ -87,4 +87,4 @@ impl DebotInterface for NumberInput { _ => Err(format!("function \"{}\" is not implemented", func)), } } -} \ No newline at end of file +} diff --git a/debot-browser/src/interfaces/signing_box_input.rs b/debot-browser/src/interfaces/signing_box_input.rs index 18244a9..d7733b2 100644 --- a/debot-browser/src/interfaces/signing_box_input.rs +++ b/debot-browser/src/interfaces/signing_box_input.rs @@ -1,7 +1,7 @@ use super::dinterface::{decode_answer_id, decode_array, decode_prompt}; use crate::helpers::TonClient; use crate::{term_signing_box::TerminalSigningBox, ChainProcessor, ProcessorError}; -use serde_json::{Value, json}; +use serde_json::{json, Value}; use std::sync::Arc; use tokio::sync::RwLock; use ton_client::abi::Abi; @@ -56,35 +56,33 @@ pub struct SigningBoxInput { } impl SigningBoxInput { pub fn new(client: TonClient, processor: Arc>) -> Self { - Self { handles: RwLock::new(vec![]), client, processor } + Self { + handles: RwLock::new(vec![]), + client, + processor, + } } async fn get(&self, args: &Value) -> InterfaceResult { let answer_id = decode_answer_id(args)?; let prompt = decode_prompt(args)?; - let possible_keys = decode_array( - args, - "possiblePublicKeys", - |elem| { - decode_abi_bigint(elem.as_str()?).ok()?; - Some(elem.as_str().unwrap().to_string()) - } - )?; + let possible_keys = decode_array(args, "possiblePublicKeys", |elem| { + decode_abi_bigint(elem.as_str()?).ok()?; + Some(elem.as_str().unwrap().to_string()) + })?; println!("{}", prompt); let result = self.processor.write().await.next_signing_box(); match result { Err(ProcessorError::InterfaceCallNeeded) => { - let signing_box = TerminalSigningBox::new::<&[u8]>( - self.client.clone(), possible_keys, None - ).await?; + let signing_box = + TerminalSigningBox::new::<&[u8]>(self.client.clone(), possible_keys, None) + .await?; let handle = signing_box.handle(); self.handles.write().await.push(signing_box); Ok((answer_id, json!({ "handle": handle.0}))) } Err(e) => Err(format!("{:?}", e))?, - Ok(handle) => { - Ok((answer_id, json!({ "handle": handle}) )) - } + Ok(handle) => Ok((answer_id, json!({ "handle": handle }))), } } } @@ -105,4 +103,4 @@ impl DebotInterface for SigningBoxInput { _ => Err(format!("function \"{}\" is not implemented", func)), } } -} \ No newline at end of file +} diff --git a/debot-browser/src/interfaces/stdout.rs b/debot-browser/src/interfaces/stdout.rs index fcdd9db..0f21b5c 100644 --- a/debot-browser/src/interfaces/stdout.rs +++ b/debot-browser/src/interfaces/stdout.rs @@ -1,4 +1,4 @@ -use serde_json::{Value, json}; +use serde_json::{json, Value}; use ton_client::abi::Abi; use ton_client::debot::{DebotInterface, InterfaceResult}; @@ -32,31 +32,31 @@ pub const STDOUT_ABI: &str = r#"{ pub struct Stdout {} impl Stdout { - pub fn new() -> Self { - Self {} - } - pub fn print(&self, args: &Value) -> InterfaceResult { - let text_vec = hex::decode(args["message"].as_str().unwrap()).unwrap(); - let text = std::str::from_utf8(&text_vec).unwrap(); - println!("{}", text); - Ok((0, json!({}))) - } + pub fn new() -> Self { + Self {} + } + pub fn print(&self, args: &Value) -> InterfaceResult { + let text_vec = hex::decode(args["message"].as_str().unwrap()).unwrap(); + let text = std::str::from_utf8(&text_vec).unwrap(); + println!("{}", text); + Ok((0, json!({}))) + } } #[async_trait::async_trait] impl DebotInterface for Stdout { - fn get_id(&self) -> String { - STDOUT_ID.to_string() - } + fn get_id(&self) -> String { + STDOUT_ID.to_string() + } - fn get_abi(&self) -> Abi { - Abi::Json(STDOUT_ABI.to_owned()) - } + fn get_abi(&self) -> Abi { + Abi::Json(STDOUT_ABI.to_owned()) + } - async fn call(&self, func: &str, args: &Value) -> InterfaceResult { - match func { - "print" => self.print(args), - _ => Err(format!("function \"{}\" is not implemented", func)), - } - } + async fn call(&self, func: &str, args: &Value) -> InterfaceResult { + match func { + "print" => self.print(args), + _ => Err(format!("function \"{}\" is not implemented", func)), + } + } } diff --git a/debot-browser/src/interfaces/terminal.rs b/debot-browser/src/interfaces/terminal.rs index 7a9ba5d..606b37c 100644 --- a/debot-browser/src/interfaces/terminal.rs +++ b/debot-browser/src/interfaces/terminal.rs @@ -3,13 +3,14 @@ use super::dinterface::{ }; use crate::convert::convert_token; use crate::term_browser::terminal_input; -use serde_json::{Value, json}; +use serde_json::{json, Value}; use std::io::Read; use ton_client::abi::Abi; use ton_client::debot::{DebotInterface, InterfaceResult}; use ton_client::encoding::decode_abi_bigint; -pub(super) const ID: &'static str = "8796536366ee21852db56dccb60bc564598b618c865fc50c8b1ab740bba128e3"; +pub(super) const ID: &'static str = + "8796536366ee21852db56dccb60bc564598b618c865fc50c8b1ab740bba128e3"; const ABI: &str = r#" { @@ -77,7 +78,7 @@ pub struct Terminal { impl Terminal { pub fn new(printer: Printer) -> Self { - Self {printer} + Self { printer } } fn input_str(&self, args: &Value) -> InterfaceResult { let answer_id = decode_answer_id(args)?; @@ -91,7 +92,8 @@ impl Terminal { } else { println!("(Ctrl+D to exit)"); } - std::io::stdin().read_to_string(&mut value) + std::io::stdin() + .read_to_string(&mut value) .map_err(|e| format!("input error: {}", e))?; println!(); } else { @@ -146,8 +148,8 @@ impl Terminal { pub async fn print(&self, args: &Value) -> InterfaceResult { let answer_id = decode_answer_id(args)?; let message = decode_string_arg(args, "message")?; - self.printer.print(&message).await; - Ok((answer_id, json!({}))) + self.printer.print(&message).await; + Ok((answer_id, json!({}))) } } @@ -173,4 +175,4 @@ impl DebotInterface for Terminal { _ => Err(format!("function \"{}\" is not implemented", func)), } } -} \ No newline at end of file +} diff --git a/debot-browser/src/interfaces/userinfo.rs b/debot-browser/src/interfaces/userinfo.rs index 733d83f..a485739 100644 --- a/debot-browser/src/interfaces/userinfo.rs +++ b/debot-browser/src/interfaces/userinfo.rs @@ -1,8 +1,8 @@ use super::dinterface::decode_answer_id; use crate::config::SharedUserSettings; -use crate::term_signing_box::TerminalSigningBox; use crate::helpers::TonClient; -use serde_json::{Value, json}; +use crate::term_signing_box::TerminalSigningBox; +use serde_json::{json, Value}; use ton_client::abi::Abi; use ton_client::debot::{DebotInterface, InterfaceResult}; @@ -71,13 +71,18 @@ pub struct UserInfo { } impl UserInfo { pub fn new(client: TonClient, settings: SharedUserSettings) -> Self { - Self { _client: client, settings } + Self { + _client: client, + settings, + } } async fn get_account(&self, args: &Value) -> InterfaceResult { let answer_id = decode_answer_id(args)?; let value = self - .settings.read().await + .settings + .read() + .await .wallet .clone() .unwrap_or_else(|| format!("0:{:064}", 0)); @@ -87,14 +92,15 @@ impl UserInfo { async fn get_public_key(&self, args: &Value) -> InterfaceResult { let answer_id = decode_answer_id(args)?; let value = self - .settings.read().await + .settings + .read() + .await .pubkey .clone() .unwrap_or_else(|| format!("0x{:064}", 0)); Ok((answer_id, json!({ "value": value }))) } - async fn get_signing_box(&self, args: &Value) -> InterfaceResult { let answer_id = decode_answer_id(args)?; let handle = if cfg!(target_arch = "wasm32") { @@ -102,11 +108,8 @@ impl UserInfo { } else { let keys_path = self.settings.read().await.keys_path.clone(); if let Some(keys) = keys_path { - let mut signing_box = TerminalSigningBox::new_with_keypath( - self._client.clone(), - keys, - ) - .await?; + let mut signing_box = + TerminalSigningBox::new_with_keypath(self._client.clone(), keys).await?; Some(signing_box.leak().0) } else { None @@ -114,7 +117,6 @@ impl UserInfo { }; Ok((answer_id, json!({ "handle": handle.unwrap_or_default()}))) } - } #[async_trait::async_trait] diff --git a/debot-browser/src/lib.rs b/debot-browser/src/lib.rs index 1003f02..d2897e9 100644 --- a/debot-browser/src/lib.rs +++ b/debot-browser/src/lib.rs @@ -32,9 +32,9 @@ mod utils; static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; pub use api::{ - close_signing_box, create_browser, destroy_browser, generate_keypair, init_log, - register_signing_box, run_browser, run_debot_browser, sign, signing_box_public_key, - update_user_settings, scrypt, sha256, chacha20, generate_random_bytes + chacha20, close_signing_box, create_browser, destroy_browser, generate_keypair, + generate_random_bytes, init_log, register_signing_box, run_browser, run_debot_browser, scrypt, + sha256, sign, signing_box_public_key, update_user_settings, }; use callbacks::Callbacks; pub use interfaces::dinterface::SupportedInterfaces; diff --git a/debot-browser/src/pipechain.rs b/debot-browser/src/pipechain.rs index 9c36345..a670efc 100644 --- a/debot-browser/src/pipechain.rs +++ b/debot-browser/src/pipechain.rs @@ -2,8 +2,12 @@ use serde::{Deserialize, Serialize}; use serde_json::Value; use std::default::Default; -fn default_init_method() -> String { format!("start") } -fn default_mandatory() -> bool { false } +fn default_init_method() -> String { + format!("start") +} +fn default_mandatory() -> bool { + false +} #[derive(Deserialize, Clone, PartialEq)] pub enum ApproveKind { @@ -52,6 +56,6 @@ pub enum ChainLink { ifeq: Option, }, SigningBox { - handle: u32 + handle: u32, }, -} \ No newline at end of file +} diff --git a/debot-browser/src/processor.rs b/debot-browser/src/processor.rs index a5f0baf..539ff61 100644 --- a/debot-browser/src/processor.rs +++ b/debot-browser/src/processor.rs @@ -1,5 +1,5 @@ +use super::{ApproveKind, ChainLink, DebotManifest}; use serde_json::Value; -use super::{ApproveKind, DebotManifest, ChainLink}; use std::vec::IntoIter; use ton_client::abi::{Abi, CallSet}; use ton_client::debot::DebotActivity; @@ -23,7 +23,10 @@ pub struct ChainProcessor { impl ChainProcessor { pub fn new() -> Self { - Self { manifest: DebotManifest::default(), chain_iter: vec![].into_iter() } + Self { + manifest: DebotManifest::default(), + chain_iter: vec![].into_iter(), + } } pub fn load_manifest(&mut self, mut manifest: DebotManifest) { @@ -62,10 +65,11 @@ impl ChainProcessor { return None; } match &self.manifest.init_args { - Some(args) => CallSet::some_with_function_and_input(&self.manifest.init_method, args.clone()), + Some(args) => { + CallSet::some_with_function_and_input(&self.manifest.init_method, args.clone()) + } None => CallSet::some_with_function(&self.manifest.init_method), } - } pub fn next_input( @@ -74,16 +78,19 @@ impl ChainProcessor { in_method: &str, in_params: &Value, ) -> Result, ProcessorError> { - let chlink = self.chain_iter.next().ok_or( - if self.interactive() { - ProcessorError::InterfaceCallNeeded - } else { - ProcessorError::NoMoreChainlinks - } - )?; - + let chlink = self.chain_iter.next().ok_or(if self.interactive() { + ProcessorError::InterfaceCallNeeded + } else { + ProcessorError::NoMoreChainlinks + })?; + match chlink { - ChainLink::Input {interface, method, params, mandatory} => { + ChainLink::Input { + interface, + method, + params, + mandatory, + } => { if interface != in_interface { if !mandatory { self.next_input(in_interface, in_method, in_params) @@ -95,35 +102,33 @@ impl ChainProcessor { } else { Ok(params.clone()) } - }, + } _ => Err(ProcessorError::UnexpectedChainLinkKind), } } pub fn next_signing_box(&mut self) -> Result { - let chlink = self.chain_iter.next().ok_or( - if self.interactive() { - ProcessorError::InterfaceCallNeeded - } else { - ProcessorError::NoMoreChainlinks - } - )?; + let chlink = self.chain_iter.next().ok_or(if self.interactive() { + ProcessorError::InterfaceCallNeeded + } else { + ProcessorError::NoMoreChainlinks + })?; match chlink { - ChainLink::SigningBox {handle} => { - Ok(handle) - }, + ChainLink::SigningBox { handle } => Ok(handle), _ => Err(ProcessorError::UnexpectedChainLinkKind), } } pub fn next_approve(&mut self, activity: &DebotActivity) -> Result { let app_kind = match activity { - DebotActivity::Transaction {..} => ApproveKind::ApproveOnChainCall, + DebotActivity::Transaction { .. } => ApproveKind::ApproveOnChainCall, }; - let auto_approve = self.manifest.auto_approve.as_ref().and_then(|vec| { - Some(vec.iter().find(|x| **x == app_kind).is_some()) - }); + let auto_approve = self + .manifest + .auto_approve + .as_ref() + .and_then(|vec| Some(vec.iter().find(|x| **x == app_kind).is_some())); let chlink = self.chain_iter.next(); if chlink.is_none() { @@ -141,14 +146,22 @@ impl ChainProcessor { // TODO: ? let chlink = chlink.unwrap(); match chlink { - ChainLink::OnchainCall { approve, iflq: _, ifeq: _ } => { - match activity { - DebotActivity::Transaction {msg: _, dst: _, out: _, fee: _, setcode: _, signkey: _, signing_box_handle: _} => { - Ok(approve.clone()) - } - } + ChainLink::OnchainCall { + approve, + iflq: _, + ifeq: _, + } => match activity { + DebotActivity::Transaction { + msg: _, + dst: _, + out: _, + fee: _, + setcode: _, + signkey: _, + signing_box_handle: _, + } => Ok(approve.clone()), }, - _ => Err(ProcessorError::UnexpectedChainLinkKind) + _ => Err(ProcessorError::UnexpectedChainLinkKind), } } -} \ No newline at end of file +} diff --git a/debot-browser/src/term_browser.rs b/debot-browser/src/term_browser.rs index 5fc889d..a7b53ee 100644 --- a/debot-browser/src/term_browser.rs +++ b/debot-browser/src/term_browser.rs @@ -10,7 +10,7 @@ * See the License for the specific TON DEV software governing permissions and * limitations under the License. */ -use super::config::{make_shared_settings, UserSettings, SharedUserSettings}; +use super::config::{make_shared_settings, SharedUserSettings, UserSettings}; use super::helpers::{load_abi, load_ton_address, TonClient}; use super::{Callbacks, ChainProcessor, DebotManifest, SupportedInterfaces}; use log::info; @@ -36,7 +36,7 @@ struct DebotEntry { /// Top level object. Created only once. pub struct TerminalBrowser { - /// Instance of SDK client. + /// Instance of SDK client. pub client: TonClient, /// User Information used by UserInfo interface pub user_settings: SharedUserSettings, @@ -51,7 +51,7 @@ pub struct TerminalBrowser { callbacks: Arc, /// Set of intrefaces implemented by current DBrowser. interfaces: SupportedInterfaces, - /// Input chain Processor for Debot Manifest + /// Input chain Processor for Debot Manifest processor: Arc>, /// Indicates if Browser will interact with the user or not. interactive: bool, @@ -66,25 +66,17 @@ impl TerminalBrowser { addr: String, ) -> Result { let processor = Arc::new(tokio::sync::RwLock::new(ChainProcessor::new())); - - let callbacks = Arc::new( - Callbacks::new( - client.clone(), - processor.clone(), - ) - ); + + let callbacks = Arc::new(Callbacks::new(client.clone(), processor.clone())); let user_settings = make_shared_settings(user_settings); - let interfaces = SupportedInterfaces::new( - client.clone(), - user_settings.clone(), - processor.clone(), - ); + let interfaces = + SupportedInterfaces::new(client.clone(), user_settings.clone(), processor.clone()); // TODO remove clone let main_debot_addr = addr.clone(); - + let mut browser = Self { client, user_settings, @@ -115,13 +107,13 @@ impl TerminalBrowser { debot_addr.clone(), None, self.client.clone(), - self.callbacks.clone() + self.callbacks.clone(), ); let info: DebotInfo = dengine.init().await?.into(); let abi_version = info.dabi_version.clone(); let abi_ref = info.dabi.as_ref(); let abi = load_abi(&abi_ref.ok_or(format!("DeBot ABI is not defined"))?)?; - + if call_start { let mut run_debot = autorun; if !autorun { @@ -150,7 +142,7 @@ impl TerminalBrowser { dengine, callbacks: callbacks_ref, info, - } + }, ); Ok(abi_version) } @@ -165,11 +157,17 @@ impl TerminalBrowser { .bots .get_mut(debot_addr) .ok_or_else(|| "Internal browser error: debot not found".to_owned())?; - if let Some(result) = self.interfaces.try_execute(&msg, interface_id, &debot.info.dabi_version).await { + if let Some(result) = self + .interfaces + .try_execute(&msg, interface_id, &debot.info.dabi_version) + .await + { let (func_id, return_args) = result?; let call_set = match func_id { 0 => None, - _ => CallSet::some_with_function_and_input(&format!("0x{:x}", func_id), return_args), + _ => { + CallSet::some_with_function_and_input(&format!("0x{:x}", func_id), return_args) + } }; let response_msg = encode_internal_message( self.client.clone(), @@ -179,7 +177,7 @@ impl TerminalBrowser { call_set, value: "1000000000000000".to_owned(), ..Default::default() - } + }, ) .await .map_err(|e| format!("{}", e))? @@ -233,7 +231,7 @@ impl TerminalBrowser { if wc == DEBOT_WC { if id == BROWSER_ID { - info!("Message from DeBot to Browser"); + info!("Message from DeBot to Browser"); self.set_exit_arg(msg, msg_src).await?; } else { self.call_interface(msg, &id, msg_src).await?; @@ -247,22 +245,28 @@ impl TerminalBrowser { Ok(()) } - pub async fn run_manifest(&mut self, manifest: DebotManifest) -> Result, String> { + pub async fn run_manifest( + &mut self, + manifest: DebotManifest, + ) -> Result, String> { let (start, call_set, mut init_message) = { let mut processor = self.processor.write().await; processor.load_manifest(manifest); - ( + ( processor.default_start(), processor.initial_call_set(), - processor.initial_msg() + processor.initial_msg(), ) }; - + self.exit_arg = None; - let abi = self.bots.get(&self.main_debot_addr) + let abi = self + .bots + .get(&self.main_debot_addr) .ok_or_else(|| format!("Starting DeBot not found: {}", &self.main_debot_addr))? - .abi.clone(); + .abi + .clone(); if !start && init_message.is_none() { init_message = Some( @@ -297,7 +301,7 @@ impl TerminalBrowser { println!("DeBot Info:"); fn print<'a>(field: &'a Option) -> &'a str { field.as_ref().map(|v| v.as_str()).unwrap_or("None") - } + } println!("Name : {}", print(&info.name)); println!("Version: {}", print(&info.version)); println!("Author : {}", print(&info.author)); @@ -312,11 +316,19 @@ impl TerminalBrowser { let arg = if let Some(abi) = abi { let decoded = decode_message( self.client.clone(), - ParamsOfDecodeMessage { abi, message }, - ).await.map_err(|e| format!("{}", e))?; + ParamsOfDecodeMessage { + abi, + message, + allow_partial: false, + function_name: None, + data_layout: None, + }, + ) + .await + .map_err(|e| format!("{}", e))?; decoded.value.unwrap_or(json!({})) } else { - json!({"message": message}) + json!({ "message": message }) }; self.exit_arg = Some(arg); Ok(()) @@ -389,7 +401,5 @@ pub fn action_input(max: usize) -> Result<(usize, usize, Vec), String> { Ok((n, argc, argv)) } - - #[cfg(test)] mod tests {} diff --git a/debot-browser/src/term_signing_box.rs b/debot-browser/src/term_signing_box.rs index 821c17c..3f9da72 100644 --- a/debot-browser/src/term_signing_box.rs +++ b/debot-browser/src/term_signing_box.rs @@ -1,7 +1,7 @@ -use crate::helpers::read_keys; use super::crypto::load_keypair; use super::helpers::TonClient; use super::term_browser::input; +use crate::helpers::read_keys; use std::io::{self, BufRead, BufReader, Read, Write}; use ton_client::crypto::{ get_signing_box, remove_signing_box, KeyPair, RegisteredSigningBox, SigningBoxHandle, diff --git a/debot-browser/tests/web.rs b/debot-browser/tests/web.rs index 2868f96..abc2d34 100644 --- a/debot-browser/tests/web.rs +++ b/debot-browser/tests/web.rs @@ -5,11 +5,11 @@ extern crate wasm_bindgen_test; use wasm_bindgen_test::*; extern crate rust_debot_browser; -use rust_debot_browser::{run_debot_browser, DebotManifest, greet}; +use rust_debot_browser::{greet, run_debot_browser, DebotManifest}; wasm_bindgen_test_configure!(run_in_browser); #[wasm_bindgen_test] fn pass() { greet(); -} \ No newline at end of file +} diff --git a/demo/.gitignore b/demo/.gitignore new file mode 100644 index 0000000..a547bf3 --- /dev/null +++ b/demo/.gitignore @@ -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? diff --git a/test-server/debot/ICompleted.sol b/demo/debot/ICompleted.sol similarity index 100% rename from test-server/debot/ICompleted.sol rename to demo/debot/ICompleted.sol diff --git a/test-server/debot/SendDebot.sol b/demo/debot/SendDebot.sol similarity index 100% rename from test-server/debot/SendDebot.sol rename to demo/debot/SendDebot.sol diff --git a/test-server/debot/TestDebot.sol b/demo/debot/TestDebot.sol similarity index 100% rename from test-server/debot/TestDebot.sol rename to demo/debot/TestDebot.sol diff --git a/demo/index.html b/demo/index.html new file mode 100644 index 0000000..0893c4c --- /dev/null +++ b/demo/index.html @@ -0,0 +1,13 @@ + + + + + + + Debot browser + + +
+ + + diff --git a/demo/package-lock.json b/demo/package-lock.json new file mode 100644 index 0000000..a85c348 --- /dev/null +++ b/demo/package-lock.json @@ -0,0 +1,834 @@ +{ + "name": "debot-browser-demo", + "version": "0.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "debot-browser-demo", + "version": "0.0.0", + "devDependencies": { + "@debug/debot-browser": "file:../debot-browser/pkg", + "@ever-guild/debot-browser": "^0.6.0-rc", + "@types/node": "^20.1.4", + "debot-browser": "^0.5.8", + "typescript": "^5.0.2", + "vite": "^4.3.2", + "vite-plugin-top-level-await": "^1.3.0", + "vite-plugin-wasm": "^3.2.2" + } + }, + "../debot-browser/pkg": { + "name": "@ever-guild/debot-browser", + "version": "0.6.0-rc.0", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/@debug/debot-browser": { + "resolved": "../debot-browser/pkg", + "link": true + }, + "node_modules/@esbuild/android-arm": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.17.19.tgz", + "integrity": "sha512-rIKddzqhmav7MSmoFCmDIb6e2W57geRsM94gV2l38fzhXMwq7hZoClug9USI2pFRGL06f4IOPHHpFNOkWieR8A==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.17.19.tgz", + "integrity": "sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.17.19.tgz", + "integrity": "sha512-uUTTc4xGNDT7YSArp/zbtmbhO0uEEK9/ETW29Wk1thYUJBz3IVnvgEiEwEa9IeLyvnpKrWK64Utw2bgUmDveww==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.17.19.tgz", + "integrity": "sha512-80wEoCfF/hFKM6WE1FyBHc9SfUblloAWx6FJkFWTWiCoht9Mc0ARGEM47e67W9rI09YoUxJL68WHfDRYEAvOhg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.17.19.tgz", + "integrity": "sha512-IJM4JJsLhRYr9xdtLytPLSH9k/oxR3boaUIYiHkAawtwNOXKE8KoU8tMvryogdcT8AU+Bflmh81Xn6Q0vTZbQw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.19.tgz", + "integrity": "sha512-pBwbc7DufluUeGdjSU5Si+P3SoMF5DQ/F/UmTSb8HXO80ZEAJmrykPyzo1IfNbAoaqw48YRpv8shwd1NoI0jcQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.17.19.tgz", + "integrity": "sha512-4lu+n8Wk0XlajEhbEffdy2xy53dpR06SlzvhGByyg36qJw6Kpfk7cp45DR/62aPH9mtJRmIyrXAS5UWBrJT6TQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.17.19.tgz", + "integrity": "sha512-cdmT3KxjlOQ/gZ2cjfrQOtmhG4HJs6hhvm3mWSRDPtZ/lP5oe8FWceS10JaSJC13GBd4eH/haHnqf7hhGNLerA==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.17.19.tgz", + "integrity": "sha512-ct1Tg3WGwd3P+oZYqic+YZF4snNl2bsnMKRkb3ozHmnM0dGWuxcPTTntAF6bOP0Sp4x0PjSF+4uHQ1xvxfRKqg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.17.19.tgz", + "integrity": "sha512-w4IRhSy1VbsNxHRQpeGCHEmibqdTUx61Vc38APcsRbuVgK0OPEnQ0YD39Brymn96mOx48Y2laBQGqgZ0j9w6SQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.17.19.tgz", + "integrity": "sha512-2iAngUbBPMq439a+z//gE+9WBldoMp1s5GWsUSgqHLzLJ9WoZLZhpwWuym0u0u/4XmZ3gpHmzV84PonE+9IIdQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.17.19.tgz", + "integrity": "sha512-LKJltc4LVdMKHsrFe4MGNPp0hqDFA1Wpt3jE1gEyM3nKUvOiO//9PheZZHfYRfYl6AwdTH4aTcXSqBerX0ml4A==", + "cpu": [ + "mips64el" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.17.19.tgz", + "integrity": "sha512-/c/DGybs95WXNS8y3Ti/ytqETiW7EU44MEKuCAcpPto3YjQbyK3IQVKfF6nbghD7EcLUGl0NbiL5Rt5DMhn5tg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.17.19.tgz", + "integrity": "sha512-FC3nUAWhvFoutlhAkgHf8f5HwFWUL6bYdvLc/TTuxKlvLi3+pPzdZiFKSWz/PF30TB1K19SuCxDTI5KcqASJqA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.17.19.tgz", + "integrity": "sha512-IbFsFbxMWLuKEbH+7sTkKzL6NJmG2vRyy6K7JJo55w+8xDk7RElYn6xvXtDW8HCfoKBFK69f3pgBJSUSQPr+4Q==", + "cpu": [ + "s390x" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.17.19.tgz", + "integrity": "sha512-68ngA9lg2H6zkZcyp22tsVt38mlhWde8l3eJLWkyLrp4HwMUr3c1s/M2t7+kHIhvMjglIBrFpncX1SzMckomGw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.17.19.tgz", + "integrity": "sha512-CwFq42rXCR8TYIjIfpXCbRX0rp1jo6cPIUPSaWwzbVI4aOfX96OXY8M6KNmtPcg7QjYeDmN+DD0Wp3LaBOLf4Q==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.17.19.tgz", + "integrity": "sha512-cnq5brJYrSZ2CF6c35eCmviIN3k3RczmHz8eYaVlNasVqsNY+JKohZU5MKmaOI+KkllCdzOKKdPs762VCPC20g==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.17.19.tgz", + "integrity": "sha512-vCRT7yP3zX+bKWFeP/zdS6SqdWB8OIpaRq/mbXQxTGHnIxspRtigpkUcDMlSCOejlHowLqII7K2JKevwyRP2rg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.17.19.tgz", + "integrity": "sha512-yYx+8jwowUstVdorcMdNlzklLYhPxjniHWFKgRqH7IFlUEa0Umu3KuYplf1HUZZ422e3NU9F4LGb+4O0Kdcaag==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.17.19.tgz", + "integrity": "sha512-eggDKanJszUtCdlVs0RB+h35wNlb5v4TWEkq4vZcmVt5u/HiDZrTXe2bWFQUez3RgNHwx/x4sk5++4NSSicKkw==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.17.19.tgz", + "integrity": "sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@ever-guild/debot-browser": { + "version": "0.6.0-rc.0", + "resolved": "https://registry.npmjs.org/@ever-guild/debot-browser/-/debot-browser-0.6.0-rc.0.tgz", + "integrity": "sha512-T08voQoIfZ/whL0806clyT/BsMRGOxYZmvTSbkQjDN58msJ9HA4i7+68BpsGEjMsCNBPTq/kzU7SvkTqntKTBw==", + "dev": true + }, + "node_modules/@rollup/plugin-virtual": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@rollup/plugin-virtual/-/plugin-virtual-3.0.1.tgz", + "integrity": "sha512-fK8O0IL5+q+GrsMLuACVNk2x21g3yaw+sG2qn16SnUd3IlBsQyvWxLMGHmCmXRMecPjGRSZ/1LmZB4rjQm68og==", + "dev": true, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@swc/core": { + "version": "1.3.57", + "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.57.tgz", + "integrity": "sha512-gAT80hOVeK5qoi+BRlgXWgJYI9cbQn2oi05A09Tvb6vjFgBsr9SlQGNZB9uMlcXRXspkZFf9l3yyWRtT4we3Yw==", + "dev": true, + "hasInstallScript": true, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/swc" + }, + "optionalDependencies": { + "@swc/core-darwin-arm64": "1.3.57", + "@swc/core-darwin-x64": "1.3.57", + "@swc/core-linux-arm-gnueabihf": "1.3.57", + "@swc/core-linux-arm64-gnu": "1.3.57", + "@swc/core-linux-arm64-musl": "1.3.57", + "@swc/core-linux-x64-gnu": "1.3.57", + "@swc/core-linux-x64-musl": "1.3.57", + "@swc/core-win32-arm64-msvc": "1.3.57", + "@swc/core-win32-ia32-msvc": "1.3.57", + "@swc/core-win32-x64-msvc": "1.3.57" + }, + "peerDependencies": { + "@swc/helpers": "^0.5.0" + }, + "peerDependenciesMeta": { + "@swc/helpers": { + "optional": true + } + } + }, + "node_modules/@swc/core-darwin-arm64": { + "version": "1.3.57", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.57.tgz", + "integrity": "sha512-lhAK9kF/ppZdNTdaxJl2gE0bXubzQXTgxB2Xojme/1sbOipaLTskBbJ3FLySChpmVOzD0QSCTiW8w/dmQxqNIQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-darwin-x64": { + "version": "1.3.57", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.3.57.tgz", + "integrity": "sha512-jsTDH8Et/xdOM/ZCNvtrT6J8FT255OrMhEDvHZQZTgoky4oW/3FHUfji4J2FE97gitJqNJI8MuNuiGq81pIJRw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm-gnueabihf": { + "version": "1.3.57", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.57.tgz", + "integrity": "sha512-MZv3fwcCmppbwfCWaE8cZvzbXOjX7n5SEC1hF2lgItTqp4S04dFk1iX50jKr6xS6xSLlRBPqDxwZH0sBpHaEuA==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-gnu": { + "version": "1.3.57", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.57.tgz", + "integrity": "sha512-wUeqa/qbkOEGl6TaDQZZL7txrQXs1vL7ERjPYhi9El+ywacFY/rTW2pK5DqaNk2eulVnLhbbNjsE1OMGSEWGkQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-musl": { + "version": "1.3.57", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.57.tgz", + "integrity": "sha512-pZfp1B9XfH7ZhDKFjr4qbyM093zU2Ri0IZq2M2A4W9q92+Ivy8oEIqw+gSRO3jwMDqRMEtFD49YuFhkJQakxdA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-gnu": { + "version": "1.3.57", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.57.tgz", + "integrity": "sha512-dvtQnv07NikV+CJ+9PYJ3fqphSigzfvSUH6wRCmb5OzLDDLFnPLMrEO0pGeURvdIWCOhngcHF252C1Hl5uFSzA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-musl": { + "version": "1.3.57", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.57.tgz", + "integrity": "sha512-1TKCSngyQxpzwBYDzF5MrEfYRDhlzt/GN1ZqlSnsJIPGkABOWZxYDvWJuMrkASdIztn3jSTPU2ih7rR7YQ8IIw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-arm64-msvc": { + "version": "1.3.57", + "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.57.tgz", + "integrity": "sha512-HvBYFyf4uBua/jyTrcFLKcq8SIbKVYfz2qWsbgSAZvuQPZvDC1XhN5EDH2tPZmT97F0CJx3fltH5nli6XY1/EQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-ia32-msvc": { + "version": "1.3.57", + "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.57.tgz", + "integrity": "sha512-PS8AtK9e6Rp97S0ek9W5VCZNCbDaHBUasiJUmaYqRVCq/Mn6S7eQlhd0iUDnjsagigQtoCRgMUzkVknd1tarsQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-x64-msvc": { + "version": "1.3.57", + "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.57.tgz", + "integrity": "sha512-A6aX/Rpp0v3g7Spf3LSwR+ivviH8x+1xla612KLZmlc0yymWt9BMd3CmBkzyRBr2e41zGCrkf6tra6wgtCbAwA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@types/node": { + "version": "20.1.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.1.4.tgz", + "integrity": "sha512-At4pvmIOki8yuwLtd7BNHl3CiWNbtclUbNtScGx4OHfBd4/oWoJC8KRCIxXwkdndzhxOsPXihrsOoydxBjlE9Q==", + "dev": true + }, + "node_modules/debot-browser": { + "version": "0.5.8", + "resolved": "https://registry.npmjs.org/debot-browser/-/debot-browser-0.5.8.tgz", + "integrity": "sha512-gP6Tj6T3uqms0y6ap3AD58bCM/hMeBieADz7Sa9LdR7iqMVR9ubTp4jntQUvAjTAKjX+p5EBykQtnni0pjn0bQ==", + "dev": true + }, + "node_modules/esbuild": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.17.19.tgz", + "integrity": "sha512-XQ0jAPFkK/u3LcVRcvVHQcTIqD6E2H1fvZMA5dQPSOWb3suUbWbfbRf94pjc0bNzRYLfIrDRQXr7X+LHIm5oHw==", + "dev": true, + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/android-arm": "0.17.19", + "@esbuild/android-arm64": "0.17.19", + "@esbuild/android-x64": "0.17.19", + "@esbuild/darwin-arm64": "0.17.19", + "@esbuild/darwin-x64": "0.17.19", + "@esbuild/freebsd-arm64": "0.17.19", + "@esbuild/freebsd-x64": "0.17.19", + "@esbuild/linux-arm": "0.17.19", + "@esbuild/linux-arm64": "0.17.19", + "@esbuild/linux-ia32": "0.17.19", + "@esbuild/linux-loong64": "0.17.19", + "@esbuild/linux-mips64el": "0.17.19", + "@esbuild/linux-ppc64": "0.17.19", + "@esbuild/linux-riscv64": "0.17.19", + "@esbuild/linux-s390x": "0.17.19", + "@esbuild/linux-x64": "0.17.19", + "@esbuild/netbsd-x64": "0.17.19", + "@esbuild/openbsd-x64": "0.17.19", + "@esbuild/sunos-x64": "0.17.19", + "@esbuild/win32-arm64": "0.17.19", + "@esbuild/win32-ia32": "0.17.19", + "@esbuild/win32-x64": "0.17.19" + } + }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/nanoid": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", + "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", + "dev": true + }, + "node_modules/postcss": { + "version": "8.4.23", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.23.tgz", + "integrity": "sha512-bQ3qMcpF6A/YjR55xtoTr0jGOlnPOKAIMdOWiv0EIT6HVPEaJiJB4NLljSbiHoC2RX7DN5Uvjtpbg1NPdwv1oA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "nanoid": "^3.3.6", + "picocolors": "^1.0.0", + "source-map-js": "^1.0.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/rollup": { + "version": "3.21.7", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.21.7.tgz", + "integrity": "sha512-KXPaEuR8FfUoK2uHwNjxTmJ18ApyvD6zJpYv9FOJSqLStmt6xOY84l1IjK2dSolQmoXknrhEFRaPRgOPdqCT5w==", + "dev": true, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=14.18.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/source-map-js": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", + "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/typescript": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", + "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=12.20" + } + }, + "node_modules/uuid": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", + "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==", + "dev": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/vite": { + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/vite/-/vite-4.3.5.tgz", + "integrity": "sha512-0gEnL9wiRFxgz40o/i/eTBwm+NEbpUeTWhzKrZDSdKm6nplj+z4lKz8ANDgildxHm47Vg8EUia0aicKbawUVVA==", + "dev": true, + "dependencies": { + "esbuild": "^0.17.5", + "postcss": "^8.4.23", + "rollup": "^3.21.0" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + }, + "peerDependencies": { + "@types/node": ">= 14", + "less": "*", + "sass": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.4.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "less": { + "optional": true + }, + "sass": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + } + } + }, + "node_modules/vite-plugin-top-level-await": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/vite-plugin-top-level-await/-/vite-plugin-top-level-await-1.3.0.tgz", + "integrity": "sha512-owIfsgWudMlQODWJSwp0sQB3AZZu3qsMygeBjZy8CyjEk6OB9AGd8lHqmgwrcEqgvy9N58lYxSBLVk3/4ejEiA==", + "dev": true, + "dependencies": { + "@rollup/plugin-virtual": "^3.0.1", + "@swc/core": "^1.3.10", + "uuid": "^9.0.0" + }, + "peerDependencies": { + "vite": ">=2.8" + } + }, + "node_modules/vite-plugin-wasm": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/vite-plugin-wasm/-/vite-plugin-wasm-3.2.2.tgz", + "integrity": "sha512-cdbBUNR850AEoMd5nvLmnyeq63CSfoP1ctD/L2vLk/5+wsgAPlAVAzUK5nGKWO/jtehNlrSSHLteN+gFQw7VOA==", + "dev": true, + "peerDependencies": { + "vite": "^2 || ^3 || ^4" + } + } + } +} diff --git a/demo/package.json b/demo/package.json new file mode 100644 index 0000000..1a5f5e6 --- /dev/null +++ b/demo/package.json @@ -0,0 +1,21 @@ +{ + "name": "debot-browser-demo", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc && vite build --mode production", + "preview": "vite preview" + }, + "devDependencies": { + "@debug/debot-browser": "file:../debot-browser/pkg", + "@ever-guild/debot-browser": "^0.6.0-rc", + "@types/node": "^20.1.4", + "debot-browser": "^0.5.8", + "typescript": "^5.0.2", + "vite": "^4.3.2", + "vite-plugin-top-level-await": "^1.3.0", + "vite-plugin-wasm": "^3.2.2" + } +} diff --git a/demo/src/browser.ts b/demo/src/browser.ts new file mode 100644 index 0000000..49ac519 --- /dev/null +++ b/demo/src/browser.ts @@ -0,0 +1,75 @@ +// import * as browser from '@ever-guild/debot-browser' +// import * as browser from 'debot-browser' +import * as browser from '@debug/debot-browser' +import defaultManifest from './manifest/default.json' +import sendManifest from './manifest/send.json' + +let keypair = { + public: '9f7fd3df9d72b133fe155c087928c4f9da423076cc20c9f5386614b462e49811', + secret: '607a90aedb5df02a0f712572f0b5aa5d9342e5f3f2c0794df43f4a2a9688aef3', +} +// browser.sign(keypair, unsigned) +const projectId = 'bf520b125fe24b96b4545f4358d2edba' +const network = 'devnet' +const endpoint = `https://${ network }.evercloud.dev/${ projectId }/graphql` +const debotTest = '0:2d2696edfe3d7c0d74e8900b2a43ac362de5a45db6fe6147177e2fcd2abfd3e2' +const debotSend = '0:af5acb55481ebd9c923c11462ea6ab068508a0e05aacd8a9c33bb5b0cabcc33c' +const wallet = '0:2f9f742cd3ed63c39a31c077d5faada4e52ea365a4b4a9e1d6709e6cb0e9d927' +const pubkey = `0x${ keypair.public }` +const callCount = 3 + +export async function setupBrowser(element: HTMLElement) { + const logger = (messge: string): void => { + element.textContent += `${ messge }\n` + } + defaultManifest.debotAddress = debotTest + defaultManifest.initArgs.arg6 = pubkey + sendManifest.debotAddress = debotSend + sendManifest.initArgs.dest = debotSend + logger(`NETWORK=${ network }`) + logger(`DEBOT=${ debotTest }`) + let result + // FIXME Uncaught (in promise) RuntimeError: unreachable + browser.init_log() + logger('Test 1. run_debot_browser') + console.time('Test 1. Run browser (single call)') + result = await browser.run_debot_browser(endpoint, wallet, pubkey, null, defaultManifest) + browser.init_log() + console.timeEnd('Test 1') + logger('Result:') + logger(result) + logger('Test 1. Completed') + + logger(`Test 2. Create, run, destroy browser (${ callCount } calls)`) + const handle = await browser.create_browser(endpoint, debotTest, wallet, pubkey) + console.time('Test 2') + for (let i = 0; i < callCount; i++) { + result = await browser.run_browser(handle, defaultManifest) + } + console.timeEnd('Test 2') + console.log('Result:', result) + logger(JSON.stringify(result)) + await browser.destroy_browser(handle) + logger('Test 2. Completed') + + logger('Test 3. Create 3 browsers in parallel') + console.time('Test 3') + const handle1 = browser.create_browser(endpoint, debotTest, wallet, pubkey) + const handle2 = browser.create_browser(endpoint, debotTest, wallet, pubkey) + const handle3 = browser.create_browser(endpoint, debotTest, wallet, pubkey) + const handles = await Promise.all([handle1, handle2, handle3]) + console.log(`handle1 = ${ handles[0] } handle2 = ${ handles[1] } handle3 = ${ handles[2] }`) + console.timeEnd('Test 3') + logger('Test 3. Completed') + + // const handle = await browser.create_browser(endpoint, debotTest, wallet, pubkey); + // const result = await browser.run_browser(handle, defaultManifest); + // console.log(result) + // let counter = 0 + // const setCounter = (count: number) => { + // counter = count + // element.innerHTML = `count is ${counter}` + // } + // element.addEventListener('click', () => setCounter(counter + 1)) + // setCounter(0) +} diff --git a/demo/src/main.ts b/demo/src/main.ts new file mode 100644 index 0000000..4115a93 --- /dev/null +++ b/demo/src/main.ts @@ -0,0 +1,21 @@ +import './style.css' +import { setupBrowser } from './browser.ts' + +async function main() { + document.querySelector('#app')!.innerHTML = ` +
+ + + +

Bebot browser

+
+
+        
+      
+
+
+` + await setupBrowser(document.querySelector('#log')!) +} + +main().catch(console.error) diff --git a/demo/src/manifest/default.json b/demo/src/manifest/default.json new file mode 100644 index 0000000..6d44c7f --- /dev/null +++ b/demo/src/manifest/default.json @@ -0,0 +1,92 @@ +{ + "version": 0, + "debotAddress": "", + "initMethod": "invokeTest", + "initArgs": { + "arg1": "1500000000", + "arg2": "68656c6c6f20776f726c6421", + "arg3": true, + "arg4": 3, + "arg5": "0:e859a5858fc99c8f6044aa179af68140c2fb9b07b3f52b70bef51e0c799fd2df", + "arg6": "", + "arg7": { + "1": { + "data": "10" + }, + "2": { + "data": "2020" + } + } + }, + "abi": { + "ABI version": 2, + "header": [], + "functions": [ + { + "name": "OnInvokeCompleted", + "inputs": [ + { + "name": "status", + "type": "uint8" + }, + { + "components": [ + { + "name": "data", + "type": "bytes" + } + ], + "name": "ret1", + "type": "map(uint32,tuple)" + } + ], + "outputs": [] + } + ], + "data": [], + "events": [] + }, + "quiet": true, + "chain": [ + { + "type": "Input", + "interface": "a1d347099e29c1624c8890619daf207bde18e92df5220a54bcc6d858309ece84", + "method": "get", + "params": { + "value": "1500000000" + } + }, + { + "type": "Input", + "interface": "8796536366ee21852db56dccb60bc564598b618c865fc50c8b1ab740bba128e3", + "method": "input", + "params": { + "value": "68656c6c6f20776f726c6421" + } + }, + { + "type": "Input", + "interface": "16653eaf34c921467120f2685d425ff963db5cbb5aa676a62a2e33bfc3f6828a", + "method": "get", + "params": { + "value": true + } + }, + { + "type": "Input", + "interface": "ac1a4d3ecea232e49783df4a23a81823cdca3205dc58cd20c4db259c25605b48", + "method": "select", + "params": { + "index": 3 + } + }, + { + "type": "Input", + "interface": "d7ed1bd8e6230871116f4522e58df0a93c5520c56f4ade23ef3d8919a984653b", + "method": "get", + "params": { + "value": "0:e859a5858fc99c8f6044aa179af68140c2fb9b07b3f52b70bef51e0c799fd2df" + } + } + ] +} diff --git a/demo/src/manifest/send.json b/demo/src/manifest/send.json new file mode 100644 index 0000000..37a0b22 --- /dev/null +++ b/demo/src/manifest/send.json @@ -0,0 +1,33 @@ +{ + "version": 0, + "debotAddress": "", + "initMethod": "invokeSend", + "initArgs": { + "dest": "", + "amount": 500000000, + "bounce": false + }, + "quiet": true, + "autoApprove": ["ApproveOnChainCall"], + "abi": { + "ABI version": 2, + "version": "2.2", + "header": ["time"], + "functions": [ + { + "name": "onSend", + "inputs": [ + {"name":"succeed","type":"bool"}, + {"name":"sdkError","type":"uint32"}, + {"name":"exitCode","type":"uint32"} + ], + "outputs": [ + ] + } + ], + "data": [], + "events": [], + "fields": [] + }, + "chain": [] +} diff --git a/demo/src/style.css b/demo/src/style.css new file mode 100644 index 0000000..81532df --- /dev/null +++ b/demo/src/style.css @@ -0,0 +1,93 @@ +:root { + font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; + line-height: 1.5; + font-weight: 400; + + color-scheme: light dark; + color: rgba(255, 255, 255, 0.87); + background-color: #242424; + + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + -webkit-text-size-adjust: 100%; +} + +a { + font-weight: 500; + color: #646cff; + text-decoration: inherit; +} +a:hover { + color: #535bf2; +} + +body { + margin: 0; + display: flex; + min-width: 320px; + min-height: 100vh; +} + +h1 { + font-size: 3.2em; + line-height: 1.1; +} + +#app { + max-width: 1280px; + margin: 0 auto; + padding: 2rem; + text-align: center; +} + +.logo { + height: 6em; + padding: 1.5em; + will-change: filter; + transition: filter 300ms; +} +.logo:hover { + filter: drop-shadow(0 0 2em #3178c6aa); +} + +.card { + padding: 2em; +} + +.read-the-docs { + color: #888; +} + +button { + border-radius: 8px; + border: 1px solid transparent; + padding: 0.6em 1.2em; + font-size: 1em; + font-weight: 500; + font-family: inherit; + background-color: #1a1a1a; + cursor: pointer; + transition: border-color 0.25s; +} +button:hover { + border-color: #646cff; +} +button:focus, +button:focus-visible { + outline: 4px auto -webkit-focus-ring-color; +} + +@media (prefers-color-scheme: light) { + :root { + color: #213547; + background-color: #ffffff; + } + a:hover { + color: #747bff; + } + button { + background-color: #f9f9f9; + } +} diff --git a/demo/src/vite-env.d.ts b/demo/src/vite-env.d.ts new file mode 100644 index 0000000..11f02fe --- /dev/null +++ b/demo/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/demo/tsconfig.json b/demo/tsconfig.json new file mode 100644 index 0000000..75abdef --- /dev/null +++ b/demo/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"] +} diff --git a/demo/vite.config.ts b/demo/vite.config.ts new file mode 100644 index 0000000..c45f616 --- /dev/null +++ b/demo/vite.config.ts @@ -0,0 +1,12 @@ +import { defineConfig } from 'vite' +import wasm from 'vite-plugin-wasm' +import topLevelAwait from 'vite-plugin-top-level-await' +const isProduction = process.argv.includes('production') + +export default defineConfig({ + base: isProduction ? '/debot-browser/' : '/', + plugins: [ + wasm(), + topLevelAwait() + ], +}) diff --git a/test-server/.bin/create-wasm-app.js b/test-server/.bin/create-wasm-app.js deleted file mode 100755 index 2f42973..0000000 --- a/test-server/.bin/create-wasm-app.js +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env node - -const { spawn } = require("child_process"); -const fs = require("fs"); - -let folderName = '.'; - -if (process.argv.length >= 3) { - folderName = process.argv[2]; - if (!fs.existsSync(folderName)) { - fs.mkdirSync(folderName); - } -} - -const clone = spawn("git", ["clone", "https://github.com/rustwasm/create-wasm-app.git", folderName]); - -clone.on("close", code => { - if (code !== 0) { - console.error("cloning the template failed!") - process.exit(code); - } else { - console.log("🦀 Rust + 🕸 Wasm = ❤"); - } -}); diff --git a/test-server/.gitignore b/test-server/.gitignore deleted file mode 100644 index 76b4a9f..0000000 --- a/test-server/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -node_modules -dist -package-lock.json -*.log -*.addr -*.keys.json \ No newline at end of file diff --git a/test-server/.travis.yml b/test-server/.travis.yml deleted file mode 100644 index 04d40b4..0000000 --- a/test-server/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -language: node_js -node_js: "10" - -script: - - ./node_modules/.bin/webpack diff --git a/test-server/LICENSE-APACHE b/test-server/LICENSE-APACHE deleted file mode 100644 index 11069ed..0000000 --- a/test-server/LICENSE-APACHE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/test-server/LICENSE-MIT b/test-server/LICENSE-MIT deleted file mode 100644 index 7079dae..0000000 --- a/test-server/LICENSE-MIT +++ /dev/null @@ -1,25 +0,0 @@ -Copyright (c) [year] [name] - -Permission is hereby granted, free of charge, to any -person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the -Software without restriction, including without -limitation the rights to use, copy, modify, merge, -publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice -shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF -ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. diff --git a/test-server/README.md b/test-server/README.md deleted file mode 100644 index d658bb1..0000000 --- a/test-server/README.md +++ /dev/null @@ -1,67 +0,0 @@ -
- -

create-wasm-app

- - An npm init template for kick starting a project that uses NPM packages containing Rust-generated WebAssembly and bundles them with Webpack. - -

- Build Status -

- -

- Usage - | - Chat -

- - Built with 🦀🕸 by The Rust and WebAssembly Working Group -
- -## About - -This template is designed for depending on NPM packages that contain -Rust-generated WebAssembly and using them to create a Website. - -* Want to create an NPM package with Rust and WebAssembly? [Check out - `wasm-pack-template`.](https://github.com/rustwasm/wasm-pack-template) -* Want to make a monorepo-style Website without publishing to NPM? Check out - [`rust-webpack-template`](https://github.com/rustwasm/rust-webpack-template) - and/or - [`rust-parcel-template`](https://github.com/rustwasm/rust-parcel-template). - -## 🚴 Usage - -``` -npm init wasm-app -``` - -## 🔋 Batteries Included - -- `.gitignore`: ignores `node_modules` -- `LICENSE-APACHE` and `LICENSE-MIT`: most Rust projects are licensed this way, so these are included for you -- `README.md`: the file you are reading now! -- `index.html`: a bare bones html document that includes the webpack bundle -- `index.js`: example js file with a comment showing how to import and use a wasm pkg -- `package.json` and `package-lock.json`: - - pulls in devDependencies for using webpack: - - [`webpack`](https://www.npmjs.com/package/webpack) - - [`webpack-cli`](https://www.npmjs.com/package/webpack-cli) - - [`webpack-dev-server`](https://www.npmjs.com/package/webpack-dev-server) - - defines a `start` script to run `webpack-dev-server` -- `webpack.config.js`: configuration file for bundling your js with webpack - -## License - -Licensed under either of - -* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) -* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) - -at your option. - -### Contribution - -Unless you explicitly state otherwise, any contribution intentionally -submitted for inclusion in the work by you, as defined in the Apache-2.0 -license, shall be dual licensed as above, without any additional terms or -conditions. diff --git a/test-server/bootstrap.js b/test-server/bootstrap.js deleted file mode 100644 index 7934d62..0000000 --- a/test-server/bootstrap.js +++ /dev/null @@ -1,5 +0,0 @@ -// A dependency graph that contains any wasm must all be imported -// asynchronously. This `bootstrap.js` file does the single async import, so -// that no one else needs to worry about it again. -import("./index.js") - .catch(e => console.error("Error importing `index.js`:", e)); diff --git a/test-server/index.html b/test-server/index.html deleted file mode 100644 index 21ac1cf..0000000 --- a/test-server/index.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - Hello wasm-pack! - - - - -
- - - diff --git a/test-server/index.js b/test-server/index.js deleted file mode 100644 index bfdd3fe..0000000 --- a/test-server/index.js +++ /dev/null @@ -1,216 +0,0 @@ -import * as wasm from "debot-browser"; - -// Test key for test multisig (devnet) -let keypair = { - public: "9f7fd3df9d72b133fe155c087928c4f9da423076cc20c9f5386614b462e49811", - secret: "607a90aedb5df02a0f712572f0b5aa5d9342e5f3f2c0794df43f4a2a9688aef3" - } - -function toHexString(byteArray) { - return Array.from(byteArray, function(byte) { - return ('0' + (byte & 0xFF).toString(16)).slice(-2); - }).join('') -} - -let user_sbox = {}; -user_sbox.get_public_key = async () => { - return keypair.public -} - -user_sbox.sign = async (unsigned) => { - const res = wasm.sign(keypair, unsigned) - return res.signature -} - -let network = "net.ton.dev"; -let wallet = "0:2f9f742cd3ed63c39a31c077d5faada4e52ea365a4b4a9e1d6709e6cb0e9d927" -let pubkey = `0x${keypair.public}`; -let testDebotAddress = "0:2d2696edfe3d7c0d74e8900b2a43ac362de5a45db6fe6147177e2fcd2abfd3e2"; -let sendDebotAddress = "0:af5acb55481ebd9c923c11462ea6ab068508a0e05aacd8a9c33bb5b0cabcc33c"; - -let manifest = `{ - "version": 0, - "debotAddress": "${testDebotAddress}", - "initMethod": "invokeTest", - "initArgs": { - "arg1": "1500000000", - "arg2": "68656c6c6f20776f726c6421", - "arg3": true, - "arg4": 3, - "arg5": "0:e859a5858fc99c8f6044aa179af68140c2fb9b07b3f52b70bef51e0c799fd2df", - "arg6": "${pubkey}", - "arg7": { - "1": { - "data": "10" - }, - "2": { - "data": "2020" - } - } - }, - "abi": { - "ABI version": 2, - "header": [], - "functions": [ - { - "name": "OnInvokeCompleted", - "inputs": [ - { - "name": "status", - "type": "uint8" - }, - { - "components": [ - { - "name": "data", - "type": "bytes" - } - ], - "name": "ret1", - "type": "map(uint32,tuple)" - } - ], - "outputs": [] - } - ], - "data": [], - "events": [] - }, - "quiet": true, - "chain": [ - { - "type": "Input", - "interface": "a1d347099e29c1624c8890619daf207bde18e92df5220a54bcc6d858309ece84", - "method": "get", - "params": { - "value": "1500000000" - } - }, - { - "type": "Input", - "interface": "8796536366ee21852db56dccb60bc564598b618c865fc50c8b1ab740bba128e3", - "method": "input", - "params": { - "value": "68656c6c6f20776f726c6421" - } - }, - { - "type": "Input", - "interface": "16653eaf34c921467120f2685d425ff963db5cbb5aa676a62a2e33bfc3f6828a", - "method": "get", - "params": { - "value": true - } - }, - { - "type": "Input", - "interface": "ac1a4d3ecea232e49783df4a23a81823cdca3205dc58cd20c4db259c25605b48", - "method": "select", - "params": { - "index": 3 - } - }, - { - "type": "Input", - "interface": "d7ed1bd8e6230871116f4522e58df0a93c5520c56f4ade23ef3d8919a984653b", - "method": "get", - "params": { - "value": "0:e859a5858fc99c8f6044aa179af68140c2fb9b07b3f52b70bef51e0c799fd2df" - } - } - ] -}`; - -const sendManifest = `{ - "version": 0, - "debotAddress": "${sendDebotAddress}", - "initMethod": "invokeSend", - "initArgs": { - "dest": "${sendDebotAddress}", - "amount": 500000000, - "bounce": false - }, - "quiet": true, - "autoApprove": ["ApproveOnChainCall"], - "abi": { - "ABI version": 2, - "version": "2.2", - "header": ["time"], - "functions": [ - { - "name": "onSend", - "inputs": [ - {"name":"succeed","type":"bool"}, - {"name":"sdkError","type":"uint32"}, - {"name":"exitCode","type":"uint32"} - ], - "outputs": [ - ] - } - ], - "data": [], - "events": [], - "fields": [] - }, - "chain": [] -} -`; - -(async () => { - let logger = document.getElementById("log"); - logger.textContent += `NETWORK=${network}\n`; - logger.textContent += `DEBOT=${testDebotAddress}\n`; - logger.textContent += "Test 1. run_debot_browser\n"; - let result; - //wasm.init_log(); - console.time("Test 1. Run browser (single call)"); - for (let i = 0; i < 10; i++) { - result = await wasm.run_debot_browser(network, wallet, pubkey, null, manifest); - } - console.timeEnd("Test 1"); - logger.textContent += "Result:\n" - logger.textContent += result; - logger.textContent += "\nTest 1. Completed\n" - - logger.textContent += "Test 2. Create, run, destroy browser (3 calls)\n"; - const manifestObj = JSON.parse(manifest); - const handle = await wasm.create_browser(network, testDebotAddress, wallet, pubkey); - console.time("Test 2"); - for (let i = 0; i < 10; i++) { - result = await wasm.run_browser(handle, manifestObj); - } - console.timeEnd("Test 2"); - console.log("run_browser result", result); - logger.textContent += JSON.stringify(result); - await wasm.destroy_browser(handle); - logger.textContent += "\nTest 2. Completed\n"; - - logger.textContent += "\nTest 3. Create 3 browsers in parallel.\n"; - console.time("Test 3"); - const handle1 = wasm.create_browser(network, testDebotAddress, wallet, pubkey); - const handle2 = wasm.create_browser(network, testDebotAddress, wallet, pubkey); - const handle3 = wasm.create_browser(network, testDebotAddress, wallet, pubkey); - - const handles = await Promise.all([handle1, handle2, handle3]); - console.log(`handle1 = ${handles[0].toString(16)} handle2 = ${handles[1].toString(16)} handle3 = ${handles[2].toString(16)}`) - console.timeEnd("Test 3"); - logger.textContent += "Test 3. Completed.\n"; - - logger.textContent += "\nTest 4. Create, register box, update settings, run, destroy.\n"; - console.time("Test 4"); - const handle4 = await wasm.create_browser(network, sendDebotAddress, null, null); - let sbox_handle = await wasm.register_signing_box(handle4, user_sbox) - await wasm.update_user_settings(handle4, { - wallet: wallet, - pubkey: pubkey, - signing_box: sbox_handle - }) - - const res = await wasm.run_browser(handle4, JSON.parse(sendManifest)); - console.log(res) - await wasm.close_signing_box(handle4, sbox_handle) - await wasm.destroy_browser(handle4); - console.timeEnd("Test 5"); - logger.textContent += `Result: ${JSON.stringify(res)}\n`; - logger.textContent += "Test 5. Completed\n"; -})(); \ No newline at end of file diff --git a/test-server/package.json b/test-server/package.json deleted file mode 100644 index 6a3ab6c..0000000 --- a/test-server/package.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "create-wasm-app", - "version": "0.1.0", - "description": "create an app to consume rust-generated wasm packages", - "main": "index.js", - "bin": { - "create-wasm-app": ".bin/create-wasm-app.js" - }, - "scripts": { - "build": "webpack --config webpack.config.js", - "start": "webpack-dev-server" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/rustwasm/create-wasm-app.git" - }, - "keywords": [ - "webassembly", - "wasm", - "rust", - "webpack" - ], - "author": "Ashley Williams ", - "license": "(MIT OR Apache-2.0)", - "devDependencies": { - "hello-wasm-pack": "^0.1.0", - "webpack": "^4.29.3", - "webpack-cli": "^3.1.0", - "webpack-dev-server": "^3.1.5", - "copy-webpack-plugin": "^5.0.0" - }, - "dependencies": { - "debot-browser": "file:../debot-browser/pkg" - } -} diff --git a/test-server/webpack.config.js b/test-server/webpack.config.js deleted file mode 100644 index 80ad814..0000000 --- a/test-server/webpack.config.js +++ /dev/null @@ -1,14 +0,0 @@ -const CopyWebpackPlugin = require("copy-webpack-plugin"); -const path = require('path'); - -module.exports = { - entry: "./bootstrap.js", - output: { - path: path.resolve(__dirname, "dist"), - filename: "bootstrap.js", - }, - mode: "development", - plugins: [ - new CopyWebpackPlugin(['index.html']) - ], -};