From 9e3cca99900c914e5d1393c51655eb896287a00b Mon Sep 17 00:00:00 2001 From: Nasr Date: Tue, 29 Apr 2025 15:24:19 +0900 Subject: [PATCH] feat(wasm): typed data typescript type --- src/lib.rs | 2 +- src/wasm/mod.rs | 3 --- src/wasm/types.rs | 15 +++++++++++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index fd7abea..61ff93e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,6 +4,6 @@ mod utils; #[cfg(not(target_arch = "wasm32"))] mod c; -#[cfg(target_arch = "wasm32")] +// #[cfg(target_arch = "wasm32")] /// cbindgen:ignore mod wasm; diff --git a/src/wasm/mod.rs b/src/wasm/mod.rs index 429b706..481ac09 100644 --- a/src/wasm/mod.rs +++ b/src/wasm/mod.rs @@ -61,9 +61,6 @@ pub struct SigningKey(starknet::signers::SigningKey); #[wasm_bindgen] pub struct VerifyingKey(starknet::signers::VerifyingKey); -#[wasm_bindgen] -pub struct TypedData(torii_typed_data::TypedData); - #[wasm_bindgen] pub struct ByteArray(cainome::cairo_serde::ByteArray); diff --git a/src/wasm/types.rs b/src/wasm/types.rs index eced59b..e525dfd 100644 --- a/src/wasm/types.rs +++ b/src/wasm/types.rs @@ -427,6 +427,21 @@ pub struct KeysClause { pub models: Vec, } +#[derive(Tsify, Serialize, Deserialize, Debug)] +#[tsify(into_wasm_abi, from_wasm_abi, hashmap_as_object)] +pub struct TypedData { + pub domain: + pub message: String, + pub primary_type: String, + pub types: String, +} + +impl From for torii_typed_data::TypedData { + fn from(value: TypedData) -> Self { + Self { domain: value.domain.into(), message: value.message.into(), primary_type: value.primary_type.into(), types: value.types.into() } + } +} + #[declare] pub type KeysClauses = Vec;