ergoplatform / ergoplatform/sigma-rust
JS value to `Constant` conversion in Wasm
Open
- Dominant language
- Rust
- Stars
- 78
- Forks
- 63
- Avg merge
- 22h 5m
- Merged PRs (30d)
- 3
Description
from #311
Encode JS value of arbitrary structure into `Constant`.
Since JS types does not have one-to-one conversion with ErgoScript the type should be provided.
Add the following methods to `Constant`:
```rust
pub fn from_js(o: JsValue, type: String) -> Result {}
pub fn to_js(&self) -> Result {}
```
where `type` is an ErgoScript type provided as string, e.g. `Coll[Long]`, `Coll[(Int, Boolean)]`, etc. Type parser from `ergoscript-compiler` crate should be used.
If JS array is not represented as `JsValue` add a pair of methods to accommodate it (` fn from_js_array(o: Box<[JsValue]>...`).
Contributor guide
Assessment
This issue has not been assessed yet.