kaspanet / rusty-kaspa

Kaspa full-node and related libraries in the Rust programming language. This is a stable version at the initial rollout phases.
ISC License
371 stars 118 forks source link

[WIP] Implementation of WASM Bindings for TypeScript #349

Closed andreidev1 closed 5 months ago

andreidev1 commented 6 months ago

At this moment most of the rust bindings that have been already implemented point to Nodejs. By default these types are declared as being any. The purpose of this PR is to create rust bindings for TypeScript so other developers will not get confused anymore.

KaffinPX commented 6 months ago

I believe this is not the correct solution...

aspect commented 6 months ago

This is the correct solution. There are two ways of doing this. One by binding rust generated types and another is by using this approach. Rust generated types are very inflexible (you can't have Address[] | string[] bounds to a single type). Due to that inflexibility we had to use JsValue with run-time analysis of arguments. JsValue comes across as 'any'. So we are gradually working to re-seat all WASM32 bindings across the entire project onto TS-declared type definitions.

The problem presented itself when developers started to integrate bindings into TypeScript projects. Our examples were built in JS assuming that TS will just work (which it does) but the lack of TS types is problematic, hence this refactoring is gradually taking place across multiple branches.

Also in case of RPC that uses serde-wasm-bindgen typing is not possible in any other way than this.

aspect commented 5 months ago

This was folded into #349. Closing.