diff --git a/deps/concordium-base b/deps/concordium-base index 9d4d2c62f..62df0c52e 160000 --- a/deps/concordium-base +++ b/deps/concordium-base @@ -1 +1 @@ -Subproject commit 9d4d2c62f19e80ca27f5c68cbb96862b03b97219 +Subproject commit 62df0c52e7113b01f997c0c4e405351990adad61 diff --git a/package.json b/package.json index e5fe5a88b..e3bc3bf10 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,6 @@ "lint-staged": { "*.ts": "yarn lint-fix" }, - "packageManager": "yarn@berry", "repository": { "type": "git", "url": "https://github.com/Concordium/concordium-node-sdk-js" diff --git a/packages/common/src/schemaHelpers.ts b/packages/common/src/schemaHelpers.ts index 67036993a..327a480ce 100644 --- a/packages/common/src/schemaHelpers.ts +++ b/packages/common/src/schemaHelpers.ts @@ -42,3 +42,15 @@ export function getUpdateContractParameterSchema( ); return Buffer.from(parameterSchema, 'hex'); } + +/** + * @param rawSchema the schema for the type + * @returns JSON template of the schema + */ +export function displayTypeSchemaTemplate( + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + rawSchema: Buffer +): string { + const value = wasm.displayTypeSchemaTemplate(rawSchema.toString('hex')); + return value; +} diff --git a/packages/rust-bindings/CHANGELOG.md b/packages/rust-bindings/CHANGELOG.md index 991d0531f..73d39d210 100644 --- a/packages/rust-bindings/CHANGELOG.md +++ b/packages/rust-bindings/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 1.1.0 + +### Added + +- `display_type_schema_template` + ## 1.0.0 ### Breaking changes diff --git a/packages/rust-bindings/Cargo.lock b/packages/rust-bindings/Cargo.lock index 2159e7dac..05e02c40f 100644 --- a/packages/rust-bindings/Cargo.lock +++ b/packages/rust-bindings/Cargo.lock @@ -234,6 +234,7 @@ dependencies = [ name = "concordium-contracts-common" version = "7.0.0" dependencies = [ + "base64", "bs58", "chrono", "concordium-contracts-common-derive", diff --git a/packages/rust-bindings/package.json b/packages/rust-bindings/package.json index fb80af966..c80539fab 100644 --- a/packages/rust-bindings/package.json +++ b/packages/rust-bindings/package.json @@ -1,6 +1,6 @@ { "name": "@concordium/rust-bindings", - "version": "1.0.0", + "version": "1.1.0", "license": "Apache-2.0", "engines": { "node": ">=14.16.0" diff --git a/packages/rust-bindings/src/aux_functions.rs b/packages/rust-bindings/src/aux_functions.rs index 19cfbee33..646fa0118 100644 --- a/packages/rust-bindings/src/aux_functions.rs +++ b/packages/rust-bindings/src/aux_functions.rs @@ -774,6 +774,12 @@ fn deserialize_type_value( } } +pub fn display_type_schema_template_aux(schema: HexString) -> Result { + let value_type: Type = from_bytes(&hex::decode(schema)?)?; + let v = value_type.to_json_template(); + Ok(to_string(&v)?) +} + #[derive(SerdeSerialize, SerdeDeserialize)] #[serde(rename_all = "camelCase")] pub struct IdProofInput { diff --git a/packages/rust-bindings/src/external_functions.rs b/packages/rust-bindings/src/external_functions.rs index 91941c7f1..2be3b77ab 100644 --- a/packages/rust-bindings/src/external_functions.rs +++ b/packages/rust-bindings/src/external_functions.rs @@ -403,3 +403,9 @@ pub fn deserialize_type_value_ext( ) .map_err(|e| JsError::new(&format!("Unable to deserialize value due to: {}", e))) } + +#[wasm_bindgen(js_name = displayTypeSchemaTemplate)] +pub fn display_type_schema_template(schema: HexString) -> JsResult { + display_type_schema_template_aux(schema) + .map_err(|e| JsError::new(&format!("Unable to get template of schema: {}", e))) +}