Fix missing wallet state_changed events (#13200)

* Fixed an issue where some of the wallet state_changed events were not notified to subscribers

* Fixed a lint error
This commit is contained in:
Izumi Hoshino
2022-08-29 22:19:25 -05:00
committed by GitHub
parent 95ca86cba8
commit 4e6fac243a
2 changed files with 18 additions and 4 deletions
+17 -1
View File
@@ -187,7 +187,23 @@ class WalletRpcApi:
# 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
+1 -3
View File
@@ -490,13 +490,11 @@ class WalletStateManager:
"""
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: