From 1b38229e855bf7f58f460e7c6d7022e00a58918c Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Wed, 27 Nov 2024 14:28:40 +0100 Subject: [PATCH] Use TypeScript polyfill --- packages/cw-schema-codegen/src/rust/mod.rs | 7 +++++-- packages/cw-schema-codegen/src/typescript/mod.rs | 10 ++++++++-- packages/cw-schema-codegen/tests/typescript.rs | 10 +++++----- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/packages/cw-schema-codegen/src/rust/mod.rs b/packages/cw-schema-codegen/src/rust/mod.rs index b87457c74..d651b0e51 100644 --- a/packages/cw-schema-codegen/src/rust/mod.rs +++ b/packages/cw-schema-codegen/src/rust/mod.rs @@ -40,7 +40,10 @@ fn expand_node_name<'a>( } cw_schema::NodeType::Enum { .. } => node.name.as_ref().into(), - cw_schema::NodeType::Decimal { precision: _, signed: _ } => { + cw_schema::NodeType::Decimal { + precision: _, + signed: _, + } => { // ToDo: Actually use a decimal type here "String".into() } @@ -49,7 +52,7 @@ fn expand_node_name<'a>( cw_schema::NodeType::HexBinary => { // ToDo: Actually use a hex-encoded binary type here "String".into() - }, + } cw_schema::NodeType::Timestamp => "cosmrs::tendermint::Time".into(), cw_schema::NodeType::Unit => "()".into(), } diff --git a/packages/cw-schema-codegen/src/typescript/mod.rs b/packages/cw-schema-codegen/src/typescript/mod.rs index 0628f47cb..91608f5da 100644 --- a/packages/cw-schema-codegen/src/typescript/mod.rs +++ b/packages/cw-schema-codegen/src/typescript/mod.rs @@ -39,8 +39,14 @@ fn expand_node_name<'a>( cw_schema::NodeType::Decimal { .. } => "z.string()".into(), cw_schema::NodeType::Address => "z.string()".into(), - cw_schema::NodeType::Checksum => todo!(), - cw_schema::NodeType::HexBinary => todo!(), + cw_schema::NodeType::Checksum => { + // ToDo: Use actual checksum types + "z.string()".into() + } + cw_schema::NodeType::HexBinary => { + // ToDo: Actually use a binary decoding hex type + "z.string()".into() + } cw_schema::NodeType::Timestamp => { // ToDo: Replace with better type "z.string()".into() diff --git a/packages/cw-schema-codegen/tests/typescript.rs b/packages/cw-schema-codegen/tests/typescript.rs index 0400a090e..1057f2db2 100644 --- a/packages/cw-schema-codegen/tests/typescript.rs +++ b/packages/cw-schema-codegen/tests/typescript.rs @@ -135,11 +135,11 @@ fn assert_validity() { // make sure the dependencies are installed let install_status = Command::new("npm") - .arg("i") - .current_dir(&e2e_dir) - .status() - .unwrap(); - assert!(install_status.success()); + .arg("i") + .current_dir(&e2e_dir) + .status() + .unwrap(); + assert!(install_status.success()); let random_data: [u8; 255] = rand::random(); let mut unstructured = arbitrary::Unstructured::new(&random_data);