From e34ab74de728843c08436acd3aeb24f0769ac67b Mon Sep 17 00:00:00 2001 From: Ivan Grachev Date: Thu, 9 Jun 2022 15:07:33 +0300 Subject: [PATCH] Validate NEAR transactions request --- Shared/Services/DappRequestProcessor.swift | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Shared/Services/DappRequestProcessor.swift b/Shared/Services/DappRequestProcessor.swift index 88443162..8a49e889 100644 --- a/Shared/Services/DappRequestProcessor.swift +++ b/Shared/Services/DappRequestProcessor.swift @@ -73,14 +73,13 @@ struct DappRequestProcessor { } return .selectAccount(action) case .signAndSendTransactions: - guard let account = account else { + guard let account = account, let transactions = body.transactions, !transactions.isEmpty else { respond(to: request, error: Strings.somethingWentWrong, completion: completion) return .none } let meta: String - if let transactions = body.transactions, - let jsonObject: Any = transactions.count == 1 ? transactions.first : transactions, + if let jsonObject: Any = transactions.count == 1 ? transactions.first : transactions, let data = try? JSONSerialization.data(withJSONObject: jsonObject, options: .prettyPrinted), let string = String(data: data, encoding: .utf8) { meta = string @@ -90,7 +89,7 @@ struct DappRequestProcessor { let action = SignMessageAction(provider: request.provider, subject: .approveTransaction, account: account, meta: meta, peerMeta: peerMeta) { approved in if approved, let privateKey = privateKey { - near.signAndSendTransactions(body.transactions, account: account, privateKey: privateKey) { result in + near.signAndSendTransactions(transactions, account: account, privateKey: privateKey) { result in switch result { case let .success(response): let body = ResponseToExtension.Near(response: response)