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

Fix missing wallet state_changed events #13200

Merged
merged 2 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion chia/rpc/wallet_rpc_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,23 @@ async def _state_changed(self, change: str, change_data: Dict[str, Any]) -> List
# Metrics is the only current consumer for this event
payloads.append(create_payload_dict(change, change_data, self.service_name, "metrics"))

if "wallet_id" in change_data or "additional_data" in change_data:
if change in {
"offer_cancelled",
"offer_added",
"wallet_created",
"did_coin_added",
"nft_coin_added",
"nft_coin_removed",
"nft_coin_updated",
"nft_coin_did_set",
"new_block",
"coin_removed",
"coin_added",
"new_derivation_index",
"added_stray_cat",
"pending_transaction",
"tx_update",
}:
payloads.append(create_payload_dict("state_changed", change_data, self.service_name, "wallet_ui"))

return payloads
Expand Down
4 changes: 1 addition & 3 deletions chia/wallet/wallet_state_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,13 +490,11 @@ def state_changed(self, state: str, wallet_id: Optional[int] = None, data_object
"""
if self.state_changed_callback is None:
return None
change_data: Dict[str, Any] = {}
change_data: Dict[str, Any] = {"state": state}
if wallet_id is not None:
change_data["wallet_id"] = wallet_id
if data_object is not None:
change_data["additional_data"] = data_object
if len(change_data) > 0:
change_data["state"] = state
self.state_changed_callback(state, change_data)

def tx_pending_changed(self) -> None:
Expand Down