tomusdrw / rust-web3

Ethereum JSON-RPC multi-transport client. Rust implementation of web3 library. ENS address: rust-web3.eth
MIT License
1.45k stars 465 forks source link

Replace `JsValue::into/from_serde` with `serde-wasm-bindgen` #678

Closed sergeyboyko0791 closed 1 year ago

sergeyboyko0791 commented 1 year ago

wasm-bindgen::serde-serialize feature may lead to a cyclic package dependency like

error: cyclic package dependency: package `wasm-bindgen v0.2.74` depends on itself. Cycle:
package `wasm-bindgen v0.2.74`
    ... which is depended on by `js-sys v0.3.51`
    ... which is depended on by `getrandom v0.2.2`
    ... which is depended on by `ahash v0.7.4`
    ... which is depended on by `hashbrown v0.11.2`
    ... which is depended on by `indexmap v1.7.0`
    ... which is depended on by `serde_json v1.0.57`
    ... which is depended on by `wasm-bindgen v0.2.74`
    ... which is depended on by `getrandom v0.1.14`
    ... which is depended on by `const-random-macro v0.1.8`
    ... which is depended on by `const-random v0.1.8`
    ... which is depended on by `ahash v0.2.18`

Due to this problem, JsValue::into_serde and JsValue::from_serde were deprecated at https://github.com/rustwasm/wasm-bindgen/pull/3031

Motivation: https://github.com/KomodoPlatform/atomicDEX-API/issues/1042#issuecomment-1348375886

sergeyboyko0791 commented 1 year ago

serde-wasm-bindgen likely doesn't handle serde(deny_unknown_fields) attribute properly. Will try to find a workaround.

sergeyboyko0791 commented 1 year ago

I had to disable serde(deny_unknown_fields) due to https://github.com/cloudflare/serde-wasm-bindgen/issues/39

sergeyboyko0791 commented 1 year ago

As a workaround I can follow this advice https://github.com/cloudflare/serde-wasm-bindgen/issues/39#issuecomment-1372332074 Please let me know if it's critical to deny unknown fields.