diff --git a/Cargo.lock b/Cargo.lock index 634bc9ef1..f4c0645da 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1582,9 +1582,7 @@ checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", - "js-sys", "num-traits", - "wasm-bindgen", "windows-targets 0.52.6", ] @@ -5172,7 +5170,7 @@ dependencies = [ "thiserror", "tokio", "tracing", - "typeshare", + "wasm-bindgen-utils", ] [[package]] @@ -6016,6 +6014,17 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-wasm-bindgen" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8302e169f0eddcc139c70f139d19d6467353af16f9fce27e8c30158036a1e16b" +dependencies = [ + "js-sys", + "serde", + "wasm-bindgen", +] + [[package]] name = "serde_bytes" version = "0.11.15" @@ -6036,6 +6045,17 @@ dependencies = [ "syn 2.0.74", ] +[[package]] +name = "serde_derive_internals" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.74", +] + [[package]] name = "serde_json" version = "1.0.125" @@ -6867,6 +6887,30 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "tsify-next" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8bf7232b89b86f63b5f0ef22c64960f9cf4fb52c6698f1e7f60de93bc3292f" +dependencies = [ + "serde", + "serde-wasm-bindgen", + "tsify-next-macros", + "wasm-bindgen", +] + +[[package]] +name = "tsify-next-macros" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab2d85ebe93eedca20d3fe6d65814c856467a649674aa7763ebd42e3bb815fec" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.74", +] + [[package]] name = "tungstenite" version = "0.20.1" @@ -6913,26 +6957,6 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" -[[package]] -name = "typeshare" -version = "1.0.1" -source = "git+https://github.com/tomjw64/typeshare?rev=556b44aafd5304eedf17206800f69834e3820b7c#556b44aafd5304eedf17206800f69834e3820b7c" -dependencies = [ - "chrono", - "serde", - "serde_json", - "typeshare-annotation", -] - -[[package]] -name = "typeshare-annotation" -version = "1.0.2" -source = "git+https://github.com/tomjw64/typeshare?rev=556b44aafd5304eedf17206800f69834e3820b7c#556b44aafd5304eedf17206800f69834e3820b7c" -dependencies = [ - "quote", - "syn 1.0.109", -] - [[package]] name = "ucd-trie" version = "0.1.6" @@ -7120,24 +7144,24 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ "cfg-if", "once_cell", + "rustversion", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", "syn 2.0.74", @@ -7158,9 +7182,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -7168,9 +7192,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", @@ -7181,9 +7205,27 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wasm-bindgen-utils" +version = "0.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "aecd97a6b3b5a0a1119c10896a92c0211136dab9ee0a86094aa2997d1064a8eb" +dependencies = [ + "js-sys", + "paste", + "serde", + "serde-wasm-bindgen", + "tsify-next", + "wasm-bindgen", + "wasm-bindgen-futures", +] [[package]] name = "web-sys" diff --git a/Cargo.toml b/Cargo.toml index 298014afe..9d5645a06 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,6 @@ once_cell = "1.17.1" alloy-ethers-typecast = { git = "https://github.com/rainlanguage/alloy-ethers-typecast", rev = "65a68f207287d024cba934bf1e3c8b3f63d2834a" } eyre = "0.6" rain-error-decoding = { git = "https://github.com/rainlanguage/rain.error", rev = "72d9577fdaf7135113847027ba951f9a43b41827" } -typeshare = { git = "https://github.com/tomjw64/typeshare", rev = "556b44aafd5304eedf17206800f69834e3820b7c" } [workspace.dependencies.rain_interpreter_parser] path = "crates/parser" diff --git a/crates/eval/Cargo.toml b/crates/eval/Cargo.toml index f29c0ad2c..3d659fc60 100644 --- a/crates/eval/Cargo.toml +++ b/crates/eval/Cargo.toml @@ -16,12 +16,14 @@ reqwest = { workspace = true } once_cell = { workspace = true } eyre = { workspace = true } rain-error-decoding = { workspace = true } -typeshare = { workspace = true } [target.'cfg(not(target_family = "wasm"))'.dependencies] foundry-evm = { workspace = true } revm = { workspace = true } +[target.'cfg(target_family = "wasm")'.dependencies] +wasm-bindgen-utils = "0.0" + [dev-dependencies] tokio = { version = "1.28.0", features = ["full"] } tracing = { workspace = true } diff --git a/crates/eval/src/trace.rs b/crates/eval/src/trace.rs index 6955f022c..2056b6e61 100644 --- a/crates/eval/src/trace.rs +++ b/crates/eval/src/trace.rs @@ -5,7 +5,8 @@ use rain_interpreter_bindings::IInterpreterV3::{eval3Call, eval3Return}; use serde::{Deserialize, Serialize}; use std::ops::{Deref, DerefMut}; use thiserror::Error; -use typeshare::typeshare; +#[cfg(target_family = "wasm")] +use wasm_bindgen_utils::{impl_wasm_traits, prelude::*}; pub const RAIN_TRACER_ADDRESS: &str = "0xF06Cd48c98d7321649dB7D8b2C396A81A2046555"; @@ -15,7 +16,7 @@ pub enum RainEvalResultError { CorruptTraces, } -#[typeshare(serialized_as = "Vec")] +#[cfg_attr(target_family = "wasm", tsify_next::declare(type = "string[]"))] type RainStack = Vec; /// A struct representing a single trace from a Rain source. Intended to be decoded @@ -169,12 +170,14 @@ impl DerefMut for RainEvalResults { } } -#[typeshare] #[derive(Debug, Serialize, Deserialize)] +#[cfg_attr(target_family = "wasm", derive(Tsify))] pub struct RainEvalResultsTable { pub column_names: Vec, pub rows: Vec, } +#[cfg(target_family = "wasm")] +impl_wasm_traits!(RainEvalResultsTable); impl RainEvalResults { pub fn into_flattened_table(&self) -> Result { diff --git a/lib/rain.metadata b/lib/rain.metadata index 653c6bc26..e52b69c78 160000 --- a/lib/rain.metadata +++ b/lib/rain.metadata @@ -1 +1 @@ -Subproject commit 653c6bc26e582596e9972bc09138a8d452f37b7e +Subproject commit e52b69c7875accd62ea24f16e676c063d204e152