Skip to content

Commit

Permalink
Add display type schema template rust binding
Browse files Browse the repository at this point in the history
  • Loading branch information
DOBEN committed Jul 4, 2023
1 parent aa05be9 commit 4744321
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion deps/concordium-base
Submodule concordium-base updated 62 files
+5 −1 .diff-wat-wasm.sh
+0 −42 CHANGELOG.md
+1 −1 concordium-contracts-common
+21 −0 haskell-src/Concordium/Cost.hs
+11 −0 haskell-src/Concordium/Genesis/Data.hs
+69 −1 haskell-src/Concordium/Genesis/Data/P6.hs
+5 −0 haskell-src/Concordium/ID/Types.hs
+1 −0 haskell-src/Concordium/Types/InvokeContract.hs
+34 −0 haskell-src/Concordium/Types/Migration.hs
+43 −0 haskell-src/Concordium/Types/ProtocolVersion.hs
+17 −4 haskell-src/Concordium/Types/SeedState.hs
+21 −9 haskell-src/Concordium/Types/Transactions.hs
+1 −0 identity-provider-service/Cargo.lock
+1 −0 idiss/Cargo.lock
+1 −0 mobile_wallet/Cargo.lock
+1 −0 rust-bins/Cargo.lock
+1 −0 rust-src/Cargo.lock
+ smart-contracts/testdata/contracts/global-data-section-test.wasm
+23 −0 smart-contracts/testdata/contracts/global-data-section-test.wat
+ smart-contracts/testdata/contracts/global-element-section-test.wasm
+24 −0 smart-contracts/testdata/contracts/global-element-section-test.wat
+ smart-contracts/testdata/contracts/v1/account-signature-checks.wasm
+52 −0 smart-contracts/testdata/contracts/v1/account-signature-checks.wat
+ smart-contracts/testdata/contracts/v1/checkpointing-2.wasm
+265 −0 smart-contracts/testdata/contracts/v1/checkpointing-2.wat
+ smart-contracts/testdata/contracts/v1/i32.extend16_s.wasm
+8 −0 smart-contracts/testdata/contracts/v1/i32.extend16_s.wat
+ smart-contracts/testdata/contracts/v1/i32.extend8_s.wasm
+8 −0 smart-contracts/testdata/contracts/v1/i32.extend8_s.wat
+ smart-contracts/testdata/contracts/v1/i64.extend16_s.wasm
+8 −0 smart-contracts/testdata/contracts/v1/i64.extend16_s.wat
+ smart-contracts/testdata/contracts/v1/i64.extend32_s.wasm
+8 −0 smart-contracts/testdata/contracts/v1/i64.extend32_s.wat
+ smart-contracts/testdata/contracts/v1/i64.extend8_s.wasm
+8 −0 smart-contracts/testdata/contracts/v1/i64.extend8_s.wat
+ smart-contracts/testdata/contracts/v1/upgrading_1_with_custom_section.wasm
+12 −0 smart-contracts/wasm-chain-integration/CHANGELOG.md
+494 −338 smart-contracts/wasm-chain-integration/Cargo.lock
+ smart-contracts/wasm-chain-integration/benches/code/loop-energy.wasm
+34 −0 smart-contracts/wasm-chain-integration/benches/code/loop-energy.wat
+5 −1 smart-contracts/wasm-chain-integration/benches/v1-host-functions.rs
+74 −20 smart-contracts/wasm-chain-integration/benches/wasm.rs
+17 −6 smart-contracts/wasm-chain-integration/src/utils.rs
+11 −2 smart-contracts/wasm-chain-integration/src/v0/ffi.rs
+17 −4 smart-contracts/wasm-chain-integration/src/v0/mod.rs
+3 −1 smart-contracts/wasm-chain-integration/src/v1/crypto_primitives_tests.rs
+34 −7 smart-contracts/wasm-chain-integration/src/v1/ffi.rs
+125 −14 smart-contracts/wasm-chain-integration/src/v1/mod.rs
+64 −11 smart-contracts/wasm-chain-integration/src/validation_tests.rs
+7 −3 smart-contracts/wasm-test/src/main.rs
+9 −0 smart-contracts/wasm-transform/CHANGELOG.md
+22 −0 smart-contracts/wasm-transform/src/artifact.rs
+2 −0 smart-contracts/wasm-transform/src/lib.rs
+5 −0 smart-contracts/wasm-transform/src/machine.rs
+5 −0 smart-contracts/wasm-transform/src/metering_transformation.rs
+94 −24 smart-contracts/wasm-transform/src/parse.rs
+65 −0 smart-contracts/wasm-transform/src/tests.rs
+8 −0 smart-contracts/wasm-transform/src/types.rs
+31 −6 smart-contracts/wasm-transform/src/utils.rs
+58 −7 smart-contracts/wasm-transform/src/validate.rs
+ smart-contracts/wasm-transform/testdata/sign-ext-instructions.wasm
+62 −0 smart-contracts/wasm-transform/testdata/sign-ext-instructions.wat
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 12 additions & 0 deletions packages/common/src/schemaHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
6 changes: 6 additions & 0 deletions packages/rust-bindings/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 1.1.0

### Added

- `display_type_schema_template`

## 1.0.0

### Breaking changes
Expand Down
1 change: 1 addition & 0 deletions packages/rust-bindings/Cargo.lock

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

2 changes: 1 addition & 1 deletion packages/rust-bindings/package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 6 additions & 0 deletions packages/rust-bindings/src/aux_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,12 @@ fn deserialize_type_value(
}
}

pub fn display_type_schema_template_aux(schema: HexString) -> Result<JsonString> {
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 {
Expand Down
6 changes: 6 additions & 0 deletions packages/rust-bindings/src/external_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
}

0 comments on commit 4744321

Please sign in to comment.