From 300bf4ac3475517d7aa1798515c0245f8dae5f9d Mon Sep 17 00:00:00 2001 From: Sale Djenic Date: Wed, 20 Nov 2024 08:31:26 +0100 Subject: [PATCH] chore(general): preparing signals to be able to handle tx status change --- .../core/signals/remote_signals/community.nim | 4 +++- .../core/signals/remote_signals/connector.nim | 4 ++++ .../core/signals/remote_signals/messages.nim | 1 + src/app/core/signals/remote_signals/node.nim | 3 ++- .../core/signals/remote_signals/pairing.nim | 1 + .../remote_signals/waku_backed_up_keypair.nim | 1 + .../remote_signals/waku_backed_up_profile.nim | 5 +++-- .../waku_backed_up_settings.nim | 5 +++-- .../waku_backed_up_watch_only_account.nim | 1 + .../waku_fetching_backup_progress.nim | 3 ++- .../core/signals/remote_signals/wallet.nim | 21 ++++++++++++++----- .../signals/remote_signals/whisper_filter.nim | 2 ++ src/app/core/signals/signals_manager.nim | 7 +++---- vendor/status-go | 2 +- 14 files changed, 43 insertions(+), 17 deletions(-) diff --git a/src/app/core/signals/remote_signals/community.nim b/src/app/core/signals/remote_signals/community.nim index 2b4ee29318..043756ac38 100644 --- a/src/app/core/signals/remote_signals/community.nim +++ b/src/app/core/signals/remote_signals/community.nim @@ -213,7 +213,7 @@ proc fromEvent*(T: type CommunityMemberReevaluationStatusSignal, event: JsonNode result = CommunityMemberReevaluationStatusSignal() result.signalType = SignalType.MemberReevaluationStatus result.communityId = event["event"]{"communityId"}.getStr() - + result.status = CommunityMemberReevaluationStatus.None var statusInt: int if (event["event"].getProp("status", statusInt) and (statusInt >= ord(low(CommunityMemberReevaluationStatus)) and @@ -275,6 +275,7 @@ proc downloadingHistoryArchivesFinishedFromEvent*(T: type HistoryArchivesSignal, proc fromEvent*(T: type CommunityTokenTransactionStatusChangedSignal, event: JsonNode): CommunityTokenTransactionStatusChangedSignal = result = CommunityTokenTransactionStatusChangedSignal() + result.signalType = SignalType.CommunityTokenTransactionStatusChanged result.transactionType = event["event"]{"transactionType"}.getStr() result.success = event["event"]{"success"}.getBool() result.hash = event["event"]{"hash"}.getStr() @@ -289,6 +290,7 @@ proc fromEvent*(T: type CommunityTokenTransactionStatusChangedSignal, event: Jso proc fromEvent*(T: type CommunityTokenActionSignal, event: JsonNode): CommunityTokenActionSignal = result = CommunityTokenActionSignal() + result.signalType = SignalType.CommunityTokenAction result.actionType = CommunityTokenActionType.Unknown if event["event"].hasKey("communityToken"): result.communityToken = toCommunityTokenDto(event["event"]{"communityToken"}) diff --git a/src/app/core/signals/remote_signals/connector.nim b/src/app/core/signals/remote_signals/connector.nim index d7825d3905..0492905b4d 100644 --- a/src/app/core/signals/remote_signals/connector.nim +++ b/src/app/core/signals/remote_signals/connector.nim @@ -29,6 +29,7 @@ type ConnectorRevokeDAppPermissionSignal* = ref object of Signal proc fromEvent*(T: type ConnectorSendRequestAccountsSignal, event: JsonNode): ConnectorSendRequestAccountsSignal = result = ConnectorSendRequestAccountsSignal() + result.signalType = SignalType.ConnectorSendRequestAccounts result.url = event["event"]{"url"}.getStr() result.name = event["event"]{"name"}.getStr() result.iconUrl = event["event"]{"iconUrl"}.getStr() @@ -36,6 +37,7 @@ proc fromEvent*(T: type ConnectorSendRequestAccountsSignal, event: JsonNode): Co proc fromEvent*(T: type ConnectorSendTransactionSignal, event: JsonNode): ConnectorSendTransactionSignal = result = ConnectorSendTransactionSignal() + result.signalType = SignalType.ConnectorSendTransaction result.url = event["event"]{"url"}.getStr() result.name = event["event"]{"name"}.getStr() result.iconUrl = event["event"]{"iconUrl"}.getStr() @@ -45,12 +47,14 @@ proc fromEvent*(T: type ConnectorSendTransactionSignal, event: JsonNode): Connec proc fromEvent*(T: type ConnectorGrantDAppPermissionSignal, event: JsonNode): ConnectorGrantDAppPermissionSignal = result = ConnectorGrantDAppPermissionSignal() + result.signalType = SignalType.ConnectorGrantDAppPermission result.url = event["event"]{"url"}.getStr() result.name = event["event"]{"name"}.getStr() result.iconUrl = event["event"]{"iconUrl"}.getStr() proc fromEvent*(T: type ConnectorRevokeDAppPermissionSignal, event: JsonNode): ConnectorRevokeDAppPermissionSignal = result = ConnectorRevokeDAppPermissionSignal() + result.signalType = SignalType.ConnectorRevokeDAppPermission result.url = event["event"]{"url"}.getStr() result.name = event["event"]{"name"}.getStr() result.iconUrl = event["event"]{"iconUrl"}.getStr() diff --git a/src/app/core/signals/remote_signals/messages.nim b/src/app/core/signals/remote_signals/messages.nim index 1d1a866672..4814367db7 100644 --- a/src/app/core/signals/remote_signals/messages.nim +++ b/src/app/core/signals/remote_signals/messages.nim @@ -48,6 +48,7 @@ proc fromEvent*(T: type MessageDeliveredSignal, event: JsonNode): MessageDeliver proc fromEvent*(T: type MessageSignal, event: JsonNode): MessageSignal = var signal:MessageSignal = MessageSignal() + signal.signalType = SignalType.Message signal.messages = @[] signal.contacts = @[] diff --git a/src/app/core/signals/remote_signals/node.nim b/src/app/core/signals/remote_signals/node.nim index 4fa13f3a27..035d1ac623 100644 --- a/src/app/core/signals/remote_signals/node.nim +++ b/src/app/core/signals/remote_signals/node.nim @@ -10,8 +10,9 @@ type NodeSignal* = ref object of Signal account*: AccountDto settings*: SettingsDto -proc fromEvent*(T: type NodeSignal, event: JsonNode): NodeSignal = +proc fromEvent*(T: type NodeSignal, signalType: SignalType, event: JsonNode): NodeSignal = result = NodeSignal() + result.signalType = signalType if not event.contains("event") or event["event"].kind == JNull: return diff --git a/src/app/core/signals/remote_signals/pairing.nim b/src/app/core/signals/remote_signals/pairing.nim index 692a333c61..f14afa06fd 100644 --- a/src/app/core/signals/remote_signals/pairing.nim +++ b/src/app/core/signals/remote_signals/pairing.nim @@ -15,6 +15,7 @@ type LocalPairingSignal* = ref object of Signal proc fromEvent*(T: type LocalPairingSignal, event: JsonNode): LocalPairingSignal = result = LocalPairingSignal() + result.signalType = SignalType.LocalPairing let e = event["event"] if e.contains("type"): result.eventType = e["type"].getStr().parse() diff --git a/src/app/core/signals/remote_signals/waku_backed_up_keypair.nim b/src/app/core/signals/remote_signals/waku_backed_up_keypair.nim index ea78cc98bb..7ca2134740 100644 --- a/src/app/core/signals/remote_signals/waku_backed_up_keypair.nim +++ b/src/app/core/signals/remote_signals/waku_backed_up_keypair.nim @@ -8,6 +8,7 @@ type WakuBackedUpKeypairSignal* = ref object of Signal proc fromEvent*(T: type WakuBackedUpKeypairSignal, event: JsonNode): WakuBackedUpKeypairSignal = result = WakuBackedUpKeypairSignal() + result.signalType = SignalType.WakuBackedUpKeypair let e = event["event"] if e.contains("backedUpKeypair"): diff --git a/src/app/core/signals/remote_signals/waku_backed_up_profile.nim b/src/app/core/signals/remote_signals/waku_backed_up_profile.nim index 25bc0e5730..065583a230 100644 --- a/src/app/core/signals/remote_signals/waku_backed_up_profile.nim +++ b/src/app/core/signals/remote_signals/waku_backed_up_profile.nim @@ -8,7 +8,8 @@ type WakuBackedUpProfileSignal* = ref object of Signal proc fromEvent*(T: type WakuBackedUpProfileSignal, event: JsonNode): WakuBackedUpProfileSignal = result = WakuBackedUpProfileSignal() - + result.signalType = SignalType.WakuBackedUpProfile + let e = event["event"] if e.contains("backedUpProfile"): - result.backedUpProfile = e["backedUpProfile"].toWakuBackedUpProfileDto() + result.backedUpProfile = e["backedUpProfile"].toWakuBackedUpProfileDto() diff --git a/src/app/core/signals/remote_signals/waku_backed_up_settings.nim b/src/app/core/signals/remote_signals/waku_backed_up_settings.nim index bbee1a7e28..fd223c2249 100644 --- a/src/app/core/signals/remote_signals/waku_backed_up_settings.nim +++ b/src/app/core/signals/remote_signals/waku_backed_up_settings.nim @@ -8,7 +8,8 @@ type WakuBackedUpSettingsSignal* = ref object of Signal proc fromEvent*(T: type WakuBackedUpSettingsSignal, event: JsonNode): WakuBackedUpSettingsSignal = result = WakuBackedUpSettingsSignal() - + result.signalType = SignalType.WakuBackedUpSettings + let e = event["event"] if e.contains("backedUpSettings"): - result.backedUpSettings = e["backedUpSettings"].toSettingsDto() + result.backedUpSettings = e["backedUpSettings"].toSettingsDto() diff --git a/src/app/core/signals/remote_signals/waku_backed_up_watch_only_account.nim b/src/app/core/signals/remote_signals/waku_backed_up_watch_only_account.nim index 8f142845ea..0bbbb89309 100644 --- a/src/app/core/signals/remote_signals/waku_backed_up_watch_only_account.nim +++ b/src/app/core/signals/remote_signals/waku_backed_up_watch_only_account.nim @@ -8,6 +8,7 @@ type WakuBackedUpWatchOnlyAccountSignal* = ref object of Signal proc fromEvent*(T: type WakuBackedUpWatchOnlyAccountSignal, event: JsonNode): WakuBackedUpWatchOnlyAccountSignal = result = WakuBackedUpWatchOnlyAccountSignal() + result.signalType = SignalType.WakuBackedUpWatchOnlyAccount let e = event["event"] if e.contains("backedUpWatchOnlyAccount"): diff --git a/src/app/core/signals/remote_signals/waku_fetching_backup_progress.nim b/src/app/core/signals/remote_signals/waku_fetching_backup_progress.nim index 43a90c298d..f9ab26c393 100644 --- a/src/app/core/signals/remote_signals/waku_fetching_backup_progress.nim +++ b/src/app/core/signals/remote_signals/waku_fetching_backup_progress.nim @@ -3,7 +3,7 @@ import base type WakuFetchingBackupProgress* = object dataNumber*: int - totalNumber*: int + totalNumber*: int type WakuFetchingBackupProgressSignal* = ref object of Signal clock*: uint64 @@ -11,6 +11,7 @@ type WakuFetchingBackupProgressSignal* = ref object of Signal proc fromEvent*(T: type WakuFetchingBackupProgressSignal, event: JsonNode): WakuFetchingBackupProgressSignal = result = WakuFetchingBackupProgressSignal() + result.signalType = SignalType.WakuFetchingBackupProgress result.fetchingBackupProgress = initTable[string, WakuFetchingBackupProgress]() let e = event["event"] diff --git a/src/app/core/signals/remote_signals/wallet.nim b/src/app/core/signals/remote_signals/wallet.nim index 805565e82c..90c52fc7fe 100644 --- a/src/app/core/signals/remote_signals/wallet.nim +++ b/src/app/core/signals/remote_signals/wallet.nim @@ -6,7 +6,9 @@ import signal_type import app_service/service/transaction/dtoV2 import app_service/service/transaction/router_transactions_dto -const SignTransactionsEventType* = "sing-transactions" +const + EventPendingTransactionUpdate* = "pending-transaction-update" + EventPendingTransactionStatusChanged* = "pending-transaction-status-changed" type WalletSignal* = ref object of Signal content*: string @@ -33,7 +35,7 @@ type WalletSignal* = ref object of Signal proc fromEvent*(T: type WalletSignal, signalType: SignalType, jsonSignal: JsonNode): WalletSignal = result = WalletSignal() - result.signalType = SignalType.Wallet + result.signalType = signalType let event = jsonSignal["event"] if event.kind == JNull: return @@ -52,6 +54,18 @@ proc fromEvent*(T: type WalletSignal, signalType: SignalType, jsonSignal: JsonNo const requestIdName = "requestId" if event.contains(requestIdName): result.requestId = some(event[requestIdName].getInt()) + + ## handling tx status change + if result.eventType == EventPendingTransactionStatusChanged: + result.signalType = SignalType.WalletTransactionStatusChanged + if result.message.len == 0: + return + var statusChangedPayload: JsonNode + try: + statusChangedPayload = result.message.parseJson + except CatchableError: + return + result.transactionStatusChange = toTransactionStatusChange(statusChangedPayload) return if signalType == SignalType.WalletSignTransactions: if event.kind != JArray: @@ -73,9 +87,6 @@ proc fromEvent*(T: type WalletSignal, signalType: SignalType, jsonSignal: JsonNo result.routerTransactionsSendingDetails = toSendDetailsDto(event) return if signalType == SignalType.WalletTransactionStatusChanged: - if event.kind != JObject: - return - result.transactionStatusChange = toTransactionStatusChange(event) return if signalType == SignalType.WalletSuggestedRoutes: try: diff --git a/src/app/core/signals/remote_signals/whisper_filter.nim b/src/app/core/signals/remote_signals/whisper_filter.nim index 7098530070..ef9114779c 100644 --- a/src/app/core/signals/remote_signals/whisper_filter.nim +++ b/src/app/core/signals/remote_signals/whisper_filter.nim @@ -24,6 +24,8 @@ proc toFilter(jsonMsg: JsonNode): Filter = ) proc fromEvent*(T: type WhisperFilterSignal, event: JsonNode): WhisperFilterSignal = + result = WhisperFilterSignal() + result.signalType = SignalType.WhisperFilterAdded if event["event"]{"filters"} != nil: for jsonMsg in event["event"]["filters"]: result.filters.add(jsonMsg.toFilter) diff --git a/src/app/core/signals/signals_manager.nim b/src/app/core/signals/signals_manager.nim index 55b1b83bbe..792bdd021b 100644 --- a/src/app/core/signals/signals_manager.nim +++ b/src/app/core/signals/signals_manager.nim @@ -92,7 +92,7 @@ QtObject: SignalType.NodeStarted, SignalType.NodeStopped, SignalType.NodeLogin: - NodeSignal.fromEvent(jsonSignal) + NodeSignal.fromEvent(signalType, jsonSignal) of SignalType.PeerStats: PeerStatsSignal.fromEvent(jsonSignal) of SignalType.DiscoverySummary: DiscoverySummarySignal.fromEvent(jsonSignal) of SignalType.MailserverRequestCompleted: MailserverRequestCompletedSignal.fromEvent(jsonSignal) @@ -144,6 +144,5 @@ QtObject: of SignalType.ConnectorSendTransaction: ConnectorSendTransactionSignal.fromEvent(jsonSignal) of SignalType.ConnectorGrantDAppPermission: ConnectorGrantDAppPermissionSignal.fromEvent(jsonSignal) of SignalType.ConnectorRevokeDAppPermission: ConnectorRevokeDAppPermissionSignal.fromEvent(jsonSignal) - else: Signal() - - result.signalType = signalType + else: + Signal(signalType: signalType) diff --git a/vendor/status-go b/vendor/status-go index 7ee45bab1c..5657a614ac 160000 --- a/vendor/status-go +++ b/vendor/status-go @@ -1 +1 @@ -Subproject commit 7ee45bab1cc6ef6da24ade1826f11152153d4783 +Subproject commit 5657a614ac63083515586fbc7304ed1868ec285c