Skip to content

Commit

Permalink
rm typeshare and add wasm bindgen
Browse files Browse the repository at this point in the history
  • Loading branch information
rouzwelt committed Feb 12, 2025
1 parent cdf1955 commit efb9f09
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 40 deletions.
110 changes: 76 additions & 34 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 3 additions & 1 deletion crates/eval/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
9 changes: 6 additions & 3 deletions crates/eval/src/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -15,7 +16,7 @@ pub enum RainEvalResultError {
CorruptTraces,
}

#[typeshare(serialized_as = "Vec<String>")]
#[cfg_attr(target_family = "wasm", tsify_next::declare(type = "string[]"))]
type RainStack = Vec<U256>;

/// A struct representing a single trace from a Rain source. Intended to be decoded
Expand Down Expand Up @@ -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<String>,
pub rows: Vec<RainStack>,
}
#[cfg(target_family = "wasm")]
impl_wasm_traits!(RainEvalResultsTable);

impl RainEvalResults {
pub fn into_flattened_table(&self) -> Result<RainEvalResultsTable, RainEvalResultError> {
Expand Down
2 changes: 1 addition & 1 deletion lib/rain.metadata

0 comments on commit efb9f09

Please sign in to comment.