Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove kaspa prefix from NetworkId, refactor and stabilize JavaScript examples. Introduce wasm::Network type for WASM bindings. #251

Merged
merged 8 commits into from
Aug 29, 2023

Conversation

aspect
Copy link
Collaborator

@aspect aspect commented Aug 26, 2023

This is a general PR that overhauls NetworkId type removing kaspa prefix and refactoring / stabilizing related JavaScript examples.

This PR introduces the following changes:

  • removes kapsa prefix from the NetworkId and introduces NetworkId::from_prefixed() and NetworkId::to_prefixed(). The prefix is retained within gRPC protowire conversions, and in parameters needed for p2p comms. The prefix is currently removed from folder names (can be resurrected during the review).
  • kaspa_consensus_core::network_type is renamed to kaspa_consensus_core::network as it contains NetworkType and NetworkId
  • A new Network type is introduced inside of the network::wasm module:
    kaspa_consensus_core::network::wasm::Network. This type is specific to WASM bindings allowing functions to receive either a NetworkType or NetworkId (it effectively allows passing NetworkId where NetworkType is required).
    It contains the following TypeScript signature:
    NetworkType | NetworkId | string.
    This simplifies the usage of network ids/types within the JavaScript SDK.
  • All current JavaScript examples have been stabilized after the above-mentioned changes (and few other related bugfixes). JavaScript examples will need another review pass before they are considered production-ready.
  • Mnemonic::toSeed() has been changed to not require a password
  • Additional JavaScript examples have been migrated from nodejs/refactoring/ to nodejs/ (namely mnemonic and derivation)

@michaelsutton michaelsutton merged commit cec2472 into kaspanet:master Aug 29, 2023
smartgoo pushed a commit to smartgoo/rusty-kaspa that referenced this pull request Jun 18, 2024
…pt examples. Introduce `wasm::Network` type for WASM bindings. (kaspanet#251)

* unify NetworkId implementations, remove prefix from the default NetworkId implementation

* modify params to return NetworkId::to_prefixed()

* propagate wasm::Network through WASM APIs

* fix derivation path JsValue conversion; allow Mnemonic::toSeed() without arguments (via Option).

* Refactor and stabilize JavaScript examples using the new Network type

* fix unit tests & simplify creation in Args

* use prefixed names for log/db sub-folders

---------

Co-authored-by: Michael Sutton <[email protected]>
Co-authored-by: Michael Sutton <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants