identity.rs icon indicating copy to clipboard operation
identity.rs copied to clipboard

[Task] Replace deprecated `JsValue::into_serde` in Wasm bindings

Open cycraig opened this issue 2 years ago • 0 comments

Description

Find an alternative to the deprecated JsValue::into_serde calls in the Wasm bindings. It suggests serde-wasm-bindgen or gloo_utils::format::JsValueSerdeExt.

We currently ignore deprecation warnings with #![allow(deprecated)], due to the diffing being deprecated as well.

Motivation

The latest wasm-bindgen update (0.2.83) deprecated JsValue::into_serde,

E.g. https://github.com/iotaledger/identity.rs/pull/1010/checks?check_run_id=8310097028

use of deprecated associated function `wasm_bindgen::JsValue::into_serde`: causes dependency cycles, use `serde-wasm-bindgen` or `gloo_utils::format::JsValueSerdeExt` instead
error: use of deprecated associated function `wasm_bindgen::JsValue::into_serde`: causes dependency cycles, use `serde-wasm-bindgen` or `gloo_utils::format::JsValueSerdeExt` instead
   --> tests/wasm.rs:285:47
    |
285 |   let de: Timestamp = JsValue::from_str(&ser).into_serde().unwrap();
    |                                               ^^^^^^^^^^

Resources

  • wasm-bindgen deprecation PR: https://github.com/rustwasm/wasm-bindgen/pull/3031
  • wasm-bindgen JSON guide: https://rustwasm.github.io/wasm-bindgen/reference/arbitrary-data-with-serde.html#an-alternative-approach---using-json

To-do list

  • [ ] Decide on a replacement.
  • [ ] Update wasm-bindings.
  • [ ] Un-pin wasm-bindgen dependency.

Change checklist

Add an x to the boxes that are relevant to your changes, and delete any items that are not.

  • [ ] The feature or fix is implemented in Rust and across all bindings whereas possible.
  • [ ] The feature or fix has sufficient testing coverage
  • [ ] All tests and examples build and run locally as expected
  • [ ] Every piece of code has been document according to the documentation guidelines.
  • [ ] If conceptual documentation (mdbook) and examples highlighting the feature exist, they are properly updated.
  • [ ] If the feature is not currently documented, a documentation task Issue has been opened to address this.

cycraig avatar Sep 12 '22 16:09 cycraig