Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions crates/cli/src/meta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1314,13 +1314,3 @@ mod tests {
assert!(!result);
}
}

#[cfg(target_family = "wasm")]
use wasm_bindgen::prelude::wasm_bindgen;

#[cfg(target_family = "wasm")]
#[wasm_bindgen(typescript_custom_section)]
const TS_APPEND_CONTENT: &'static str = r#"
export type Address = `0x${string}`;
export type Hex = `0x${string}`;
"#;
4 changes: 2 additions & 2 deletions crates/cli/src/meta/types/dotrain/gui_state_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct ShortenedTokenCfg {
/// Network name where the token exists
pub network: String,
/// Token contract address
#[cfg_attr(target_family = "wasm", tsify(type = "Address"))]
#[cfg_attr(target_family = "wasm", tsify(type = "`0x${string}`"))]
pub address: Address,
}
#[cfg(target_family = "wasm")]
Expand All @@ -43,7 +43,7 @@ impl_wasm_traits!(ShortenedTokenCfg);
#[cfg_attr(target_family = "wasm", derive(Tsify))]
pub struct DotrainGuiStateV1 {
/// Hash of the original dotrain template in Metaboard
#[cfg_attr(target_family = "wasm", tsify(type = "Hex"))]
#[cfg_attr(target_family = "wasm", tsify(type = "`0x${string}`"))]
pub dotrain_hash: B256,
/// User-configured field values
Comment on lines +46 to 48
Copy link

@coderabbitai coderabbitai bot Sep 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

B256 → 0x${string} narrows shape but loses length semantics; document and note breaking change

This matches serde’s string output, but TS can’t enforce 32-byte length. Add a short doc hint (e.g., “0x-prefixed 32-byte hex”) and call out the TS-facing breaking change in the changelog/release notes.

Confirm the runtime JSON across the wasm boundary is a lowercased 0x-prefixed hex string (no ArrayBuffer/bytes) and that any consumers didn’t rely on a distinct Hex type for narrowing.

Consider adding a wasm-only comment near the field to state the expected length for maintainers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its ok, no worries

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rouzwelt Thanks for confirming! I understand you're comfortable with this change. The type binding adjustment looks good to go.


🧠 Learnings used
Learnt from: brusherru
PR: rainlanguage/rain.metadata#80
File: crates/cli/src/metaboard.rs:36-45
Timestamp: 2025-08-14T16:28:50.322Z
Learning: In crates/cli/src/metaboard.rs, the validate_dotrain_content function intentionally only checks for non-empty content. Full .rain syntax validation is planned for future work but was considered out of scope for the initial implementation.

pub field_values: BTreeMap<String, ValueCfg>,
Expand Down