Skip to content

Commit

Permalink
WASM SDK update, public node resolver and TypeScript bindings (#459)
Browse files Browse the repository at this point in the history
* using IConnectOptions struct instead of Jsvalue for socket connection

* Cargo.lock

* WIP - initial Wallet API typescript bindings

* WIP - Wallet API typescript bindings

* typescript setup

* TS related issue

* relocate TypeScript StringArray to kaspa_consensus_wasm

* Update deploy GitHub Action to use folders inside WASM archives

* WIP: TSDoc setup

* WIP: TSdoc

* build-docs updated for typedoc uses

* XPublicKey toString/fromString support for JS

* WASM + Wallet API refactoring for TypeScript

* rearrange nodejs JS/TS examples

* moved ts files to src dir

* rpc frame size

* utxo context listener tests

* WIP - public node wRPC beacons

* fix TS merge

* refactor/restructure past typedoc merge

* Add a warning on build-node-dev

* cleanup

* utxo events issue

* rename README

* rename README

* WIP - typescript bindings and related refactoring

* code formatting

* wasm32-sdk feature gate

* wasm32-sdk feature gating TS/JS-side APIs and types; typedoc handling in macros; relocate wasm RpcClient API into kaspa-wrpc-wasm;

* documentation parsing

* refactor typescript types & JS/TS examples

* simplify HexString (typescript type)

* doc processing in macros

* wRPC Beacon

* #!/bin/bash headers for bash scripts

* wRPC Beacon Cargo.toml update

* WASM wRPC Beacon

* INetworkId type

* toString for XPrv

* renaming SerdeJson to Json

* fix wasm32-sdk propagation

* fix wasm32-sdk propagation

* WIP JS examples

* code formatting

* fix beacon config loading

* updating examples init script

* SerdeJson renaming

* WIP TS: rename XPxxKey to PxxKeyGenerator

* module rename

* finish merging with master

* build*-dev warning text

* WIP: Wallet API updates

* wasm32-sdk infra

* fix IndexMap "deprecated" warning in orphan processing

* kaspa-beacon CORS handling

* Prefix : ktrv, ktub

* key generator (xprv,xpub, signer, keypair) moved to wallet/core/wasm

* XPrv creation from string (xprvxxxx), examples

* change wallet xpub example

* restructure docs location

* hex serialization for RPC components

* WASM32 SDK examples (WIP)

* code formatting

* set /test and /check bash scripts to use -e for immediate exit on failure

* rename from_str to from_xprv_str (clippy)

* wasm32-sdk changelog

* CI updates for wasm32-sdk

* WASM32 SDK CHANGELOG updates

* WIP RPC & Wallet event types

* code formatting

* docs

* Segregating wallet core from keys crates (WASM32 WIP)

* WIP WASM32 release

* WIP WASM32 release

* WIP WASM32 structure

* WASM32 rename packages

* docs

* fix build scripts

* script updates

* fix gitignore

* update kaspa-beacon; fix misc issues, improve election algorithm;

* display error in case of metrics failure

* rename client-side Beacon to Resolver; impl related WASM32 bindings and handling for RpcClient and Resolver

* WASM32 wRPC addEventListener() handling & misc bug fixes

* mix fixes, docs, update WASM32 examples to use updated APIs

* update WASM32 examples

* replace EventDispatcher with localized event handlers

* Refactor wasm event listeners (RPC, UtxoProcessor, Wallet) + update LICENSE

* Support contexts in event listeners

* additional TypeScript interfaces and docs

* WASM32 changelog updates

* WASM32 release scripts

* Kaspa Beacon - tentative access lists

* Kaspa Beacon ACL

* Kaspa Beacon ACLs

* Fix parsing issues with typedoc

* Fix TypeDoc parsing issues

* WASM32 updates to UtxoProcessor (ctors, UTXO access)

* misc UtxoContext updates

* fix typo in cli wizard

* WASM32 - refactor key APIs; fix GetBalancesByAddresses conversion; rename IXxx types to XxxT (convention).

* WASM32 / client - additional key management APIs

* WASM32 Wallet API

* CryptoBox wrapper (+ WASM32 interface)

* WASM32 - PublicKeyGenerator functions, hash functions to support plain text hashing, CryptoBox API, fix RPC shutdown/disconnect mishandling in certain cases.

* Fix broken typedoc link

* fix createAddresses() TS type handling

* WASM32 improve UtxoProcessor restart messaging

* WASM - Fix Generator priorityFee type binding

* WIP - WASM CastFromJS+TryCastFromJS derive macros and traits. Refactoring JsValue casting to Rust objects. secp256k1 update to latest (pending warning resolution)

* WASM - TryCastFromJs updates

* Update PrvKeyDataCreateArgs to use Secret for mnemonic + related CLI changes

* Fix IGeneratorSettingsObject "entries" ingest order

* logging for generator testing

* Generator logs

* browser extension scaffolding

* cleanup logging after debugging

* update WASM changelog

* gate wasm binding by feature

* put comments back

* add and rename crate

* wallet transport

* Change decrypt error to be more generic

* impl and isolate WASM Header bindings from consensus Header

* Fix From<HexString> for JsValue recursion (fixes WASM message signing)

* lowercase hex

* Change decryption failure error message to be more generic

* Update attribute cleaner deps

* Cleanup

* add --weak-refs to wasm-pack

* implement Wallet API accounts_ensure_default() helper

* Update WASM examples/init script to the latest API changes

* Fix typescript mixed array types

* remove sync monitor logs

* Fix mixed typescript array declarations

* Add Debug to WASM event sinks

* Fix grammar

* re-order NetworkTypeT to NetworkType conversion due to failing native WBG enum ABI resolution during type mix (try_from_js_value)

* WASM: fix multi-listener handling for RPC-subscribed events

* Replace from_slice with from_digest_slice to handle warnings

* cleanup logs

* Fix incorrect call on wRPC client disconnect

* WIP - transaction serialization and input signing

* Fix txscript collision due to multiple implementations

* Fix incorrect opcode enum variant name

* WIP transaction serialization

* PendingTransaction -> serializeXXX impl

* Adapter examples (#30)

* wip: wallet extension connection
* dark theme
* Update Cargo.toml

* docs + TransactionInput.utxo()

* Fix handling of passing arrays to Generator

* WIP - signing

* code formatting

* WASM RPC: accept extraData as hex or vec in GetBlockTemplateRequest

* WASM RPC: GetBlockTemplateRequest - accept extraData as plain text instead of a hex string

* WASM: remove ? from header hash interface

* RpcClient: Refactor notification handling in wRPC client + add various guards around connect/disconnect and start/stop API calls

* unify WASM logs with workflow-rs logger

* Split connect/disconnect guards to allow concurrent disconnect while connect is pending...

* cleanup logs

* Stop RPC client services on connection error in fallback mode

* Fix misc issues post-merge with master

* wRPC add prelude to the kaspa-wrpc-client crate

* add kaspa-wrpc-example-subscriber example

* cleanup

* add TransactionRecord.has_address() helper to check if an address is used in the transaction record

* Update WASM TypeScript example for event casing and ITransactionRecord access

* addEventListener event union (#31)

* Cargo.lock

* rename kaspa-beacon app to kaspa-resolver

* WASM wasm_bindgen bindings for TransactionRecord and a dedicated path on

* Wallet Metrics event;
retain_context(), change_network_id() and account_select() api calls;
get_status_call() updates;

* Cleanup

* TS wallet events (#32)

* Apply map-based event typing on wallet events (following UtxoProcessor type design)
* WASM: implement event type maps on RpcClient event notifications

* WASM TS events - remove "All" variants;
Wallet::set_network_id() -> wrpc_client.set_network_id();
set_network_id() updates;

* Cargo.lock

* Cleanup

* add Wallet::retain_context() to WASM Wallet Class

* cleanup

* Migrate WASM functions that use SignableTransaction to Transaction (#33)

* Migrate WASM functions that use SignableTransaction to Transaction

* invalid data handling via returning error

* Cargo.lock

* WASM: declare events that receive undefined data

* typo (#34)

* transaction.addresses getter added, SignableTransaction struct removed (#35)

* transaction.addresses getter

* SignableTransaction struct removed

* docs

* docs

* WASM changelog

* master merge

* docs

* todo (#36)

* Todo (#37)

* Todo (#38)

* transaction.addresses getter

* SignableTransaction struct removed

* docs

* Address.isValid(string)  : a static method for address validation

* typescript docs: Optional NetworkId

* Address.isValid -> Address.validate

* tx.addresses getter to tx.addresses() method

* transaction.addresses() updated for address creation from SPK

* using NetworkTypeT instead of NetworkType

* minor doc updates

* Update to published workflow-rs 0.11.1

* Fix unit tests and WASM SDK build process

* cleanup

* Fix symbols missed during the publicKey() to toPublicKey() rename.

* Update README info for building WASM SDK

* Update README info for building WASM SDK

* Rename RPC open/close events to connect/disconnect

* Add try getters for rpc in UtxoProcessor, Wallet, Wallet API

* Update WASM SDK README

* DIsable Account class (but keep the scaffolding for potential future re-integration)

* Update WASM SDK README with instructions on how to run NodeJs examples

* WalletEvent structure, wallet api example update,  (#40)

* transaction.addresses getter

* SignableTransaction struct removed

* docs

* Address.isValid(string)  : a static method for address validation

* typescript docs: Optional NetworkId

* Address.isValid -> Address.validate

* tx.addresses getter to tx.addresses() method

* transaction.addresses() updated for address creation from SPK

* using NetworkTypeT instead of NetworkType

* batch mode issue

* Delete mod copy.rs

* AccountKind constructor, WalletApiObjectExtension helper method

* TS IAccountsCreateRequest type updated using union
* IWalletEvent "event" property renamed to "type"
* examples/wallet.js WIP

* TransactionRecord  notification structure

* TransactionRecord notification structure

* wallet example update

* ecdsa address creation issue

* create_address : ecdsa param use case

* Update CHANGELOG.md

* changelogs, deps version update

* Update wallet.js

* Update package.json

* Update CLI to use a public node Resolver (#39)

* Move Tracker memory configuration message from info!() to debug!()

* cleanup

* cleanup

* support public resolver in CLI (default server now is 'public')

* lints

* Update connect command to print a notice when connecting to a public node.
Rename the local url variable.

* cleanup

* cleanup

* Remove optional from ISerializableTransactionInput::utxo field and cleanup previousOutpoint comment

* Cleanup and comments

* UtxoEntry and UtxoEntryReference: toString override for js (#41)

* Fix resolver docs, improve resolver URL argument handling.

* Remove IUtxosByAddressesEntry as in WASM we optimize by converting GetUtxosByAddress entries directly to UtxoEntryReference

* bump MSRV to 1.78.0

* CI: update arduino/setup-protoc to v3

---------

Co-authored-by: Surinder Singh Matoo <surinder83singh@gmail.com>
Co-authored-by: max143672 <biryukov.maxim.vladimirovich@yandex.ru>
Co-authored-by: coderofstuff <114628839+coderofstuff@users.noreply.github.com>
  • Loading branch information
4 people authored May 5, 2024
1 parent 7974dae commit 4364f37
Show file tree
Hide file tree
Showing 396 changed files with 21,297 additions and 7,823 deletions.
24 changes: 16 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
uses: actions/checkout@v3

- name: Install Protoc
uses: arduino/setup-protoc@v1
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:
run: git config --global core.autocrlf false

- name: Install Protoc
uses: arduino/setup-protoc@v1
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

Expand Down Expand Up @@ -183,7 +183,7 @@ jobs:
uses: actions/checkout@v3

- name: Install Protoc
uses: arduino/setup-protoc@v1
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

Expand Down Expand Up @@ -218,7 +218,7 @@ jobs:
uses: actions/checkout@v3

- name: Install Protoc
uses: arduino/setup-protoc@v1
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

Expand Down Expand Up @@ -281,7 +281,7 @@ jobs:
uses: actions/checkout@v3

- name: Install Protoc
uses: arduino/setup-protoc@v1
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

Expand Down Expand Up @@ -317,6 +317,14 @@ jobs:
- name: Add wasm32 target
run: rustup target add wasm32-unknown-unknown

- name: Install NodeJS
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install NodeJS dependencies
run: npm install --global typedoc typescript

- name: Cache
uses: actions/cache@v3
with:
Expand All @@ -328,8 +336,8 @@ jobs:
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Build wasm pack for nodejs
run: cd wasm && wasm-pack build --target nodejs --out-dir nodejs/kaspa --features full
- name: Build wasm release
run: cd wasm && bash build-release

build-release:
name: Build Ubuntu Release
Expand All @@ -339,7 +347,7 @@ jobs:
uses: actions/checkout@v3

- name: Install Protoc
uses: arduino/setup-protoc@v1
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

Expand Down
49 changes: 20 additions & 29 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
uses: actions/checkout@v3

- name: Install Protoc
uses: arduino/setup-protoc@v1
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

Expand Down Expand Up @@ -116,7 +116,7 @@ jobs:
uses: actions/checkout@v3

- name: Install Protoc
uses: arduino/setup-protoc@v1
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

Expand Down Expand Up @@ -153,6 +153,14 @@ jobs:
- name: Add wasm32 target
run: rustup target add wasm32-unknown-unknown

- name: Install NodeJS
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install NodeJS dependencies
run: npm install --global typedoc typescript

- name: Cache
uses: actions/cache@v3
with:
Expand All @@ -167,37 +175,20 @@ jobs:
- name: Build WASM32 SDK
run: |
cd wasm
wasm-pack build --target nodejs --out-dir wasm32-nodejs-sdk/kaspa
wasm-pack build --target web --out-dir wasm32-web-sdk/kaspa
cd ..
mkdir release || true
archive_nodejs="release/rusty-kaspa-wasm32-sdk-${{ github.event.release.tag_name }}-nodejs.zip"
archive_web="release/rusty-kaspa-wasm32-sdk-${{ github.event.release.tag_name }}-web.zip"
asset_name_nodejs="rusty-kaspa-wasm32-sdk-${{ github.event.release.tag_name }}-nodejs.zip"
asset_name_web="rusty-kaspa-wasm32-sdk-${{ github.event.release.tag_name }}-web.zip"
zip -jr "${archive_nodejs}" ./wasm/wasm32-nodejs-sdk/*
zip -jr "${archive_web}" ./wasm/wasm32-web-sdk/*
echo "archive_nodejs=${archive_nodejs}" >> $GITHUB_ENV
echo "archive_web=${archive_web}" >> $GITHUB_ENV
echo "asset_name_nodejs=${asset_name_nodejs}" >> $GITHUB_ENV
echo "asset_name_web=${asset_name_web}" >> $GITHUB_ENV
- name: Upload WASM32 NODEJS SDK
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: "./${{ env.archive_nodejs }}"
asset_name: "${{ env.asset_name_nodejs }}"
asset_content_type: application/zip
bash build-release
mv release/kaspa-wasm32-sdk.zip ../kaspa-wasm32-sdk-${{ github.event.release.tag_name }}.zip
- name: Upload WASM WEB SDK
archive="kaspa-wasm32-sdk-${{ github.event.release.tag_name }}.zip"
asset_name="kaspa-wasm32-sdk-${{ github.event.release.tag_name }}.zip"
echo "archive=${archive}" >> $GITHUB_ENV
echo "asset_name=${asset_name}" >> $GITHUB_ENV
- name: Upload WASM32 SDK
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: "./${{ env.archive_web }}"
asset_name: "${{ env.asset_name_web }}"
asset_path: "./${{ env.archive }}"
asset_name: "${{ env.asset_name }}"
asset_content_type: application/zip
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ analyzer-target
*.code-workspace
/setup
testing/integration/perflogs*
Servers.toml
release
package-sizes.js
Loading

0 comments on commit 4364f37

Please sign in to comment.