feat: wrap wallet events API (apply_update_events)#33
Draft
darioAnongba wants to merge 3 commits intomainfrom
Draft
feat: wrap wallet events API (apply_update_events)#33darioAnongba wants to merge 3 commits intomainfrom
darioAnongba wants to merge 3 commits intomainfrom
Conversation
Add WalletEvent type wrapping BDK's WalletEvent enum with JS-friendly getters: - kind: event type string (chain_tip_changed, tx_confirmed, tx_unconfirmed, tx_replaced, tx_dropped) - txid, tx: transaction data (where applicable) - old_tip, new_tip: chain tip changes - block_time, old_block_time: confirmation data Add Wallet::apply_update_events method that returns Vec<WalletEvent> describing what changed after applying an update. Closes #19
darioAnongba
commented
Feb 26, 2026
src/types/event.rs
Outdated
| /// | ||
| /// One of: `"chain_tip_changed"`, `"tx_confirmed"`, `"tx_unconfirmed"`, `"tx_replaced"`, `"tx_dropped"`. | ||
| #[wasm_bindgen(getter)] | ||
| pub fn kind(&self) -> String { |
Collaborator
Author
There was a problem hiding this comment.
can't this return a WalletEventKind, which is a TS enum instead of String? Like we have KeychainKind?
Collaborator
Author
There was a problem hiding this comment.
Done — added WalletEventKind enum following the KeychainKind pattern. The kind() getter now returns it instead of String.
- Fix E0603: use bdk_wallet::event::WalletEvent (public) instead of bdk_wallet::wallet::event::WalletEvent (private) - Fix E0282: explicit type in old_block_time getter to resolve inference - Add WalletEventKind TS enum per review feedback, replacing String return type on kind() getter (follows KeychainKind pattern)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wrap BDK's
WalletEventtype and addWallet::apply_update_eventsso JS consumers can react to wallet state changes after syncing.New API
WalletEventtypeJS-friendly wrapper with getters instead of Rust enum pattern matching:
kindstringchain_tip_changed,tx_confirmed,tx_unconfirmed,tx_replaced,tx_droppedtxidTxid?txTransaction?old_tipBlockId?chain_tip_changedonly)new_tipBlockId?chain_tip_changedonly)block_timeConfirmationBlockTime?tx_confirmedonly)old_block_timeConfirmationBlockTime?Wallet.apply_update_events(update)Like
apply_updatebut returnsWalletEvent[]describing what changed.Example usage
Closes #19