chore(general): preparing signals to be able to handle tx status change
This commit is contained in:
parent
707db9dcea
commit
300bf4ac34
|
@ -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"})
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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 = @[]
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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"):
|
||||
|
|
|
@ -8,6 +8,7 @@ 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"):
|
||||
|
|
|
@ -8,6 +8,7 @@ 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"):
|
||||
|
|
|
@ -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"):
|
||||
|
|
|
@ -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"]
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 7ee45bab1cc6ef6da24ade1826f11152153d4783
|
||||
Subproject commit 5657a614ac63083515586fbc7304ed1868ec285c
|
Loading…
Reference in New Issue