diff --git a/Sources/Relayer/WakuNetworkRelay.swift b/Sources/Relayer/WakuNetworkRelay.swift index 8e1eb99fc..e126b30b9 100644 --- a/Sources/Relayer/WakuNetworkRelay.swift +++ b/Sources/Relayer/WakuNetworkRelay.swift @@ -184,7 +184,7 @@ public final class WakuNetworkRelay { private func acknowledgeSubscription(requestId: Int64) { let response = JSONRPCResponse(id: requestId, result: AnyCodable(true)) let responseJson = try! response.json() - try? jsonRpcSubscriptionsHistory.resolve(response: JsonRpcResponseTypes.response(response)) + _ = try? jsonRpcSubscriptionsHistory.resolve(response: JsonRpcResponseTypes.response(response)) dispatcher.send(responseJson) { [weak self] error in if let error = error { self?.logger.debug("Failed to Respond for request id: \(requestId), error: \(error)") diff --git a/Sources/WalletConnect/Engine/SessionEngine.swift b/Sources/WalletConnect/Engine/SessionEngine.swift index 534de8e24..1c840d270 100644 --- a/Sources/WalletConnect/Engine/SessionEngine.swift +++ b/Sources/WalletConnect/Engine/SessionEngine.swift @@ -44,7 +44,7 @@ final class SessionEngine { restoreSubscriptions() relayer.onResponse = { [weak self] in - self?.handleReponse($0) + self?.handleResponse($0) } } @@ -366,7 +366,7 @@ final class SessionEngine { if let error = error { logger.error(error) } else { - try? sequencesStore.setSequence(session) + sequencesStore.setSequence(session) onSessionUpgrade?(session.topic, newPermissions) } } @@ -502,12 +502,12 @@ final class SessionEngine { }.store(in: &publishers) } - private func handleReponse(_ response: WCResponse) { + private func handleResponse(_ response: WCResponse) { switch response.requestParams { case .pairingPayload(let payloadParams): let proposeParams = payloadParams.request.params handleProposeResponse(topic: response.topic, proposeParams: proposeParams, result: response.result) - case .sessionApprove(let approveParams): + case .sessionApprove: handleApproveResponse(topic: response.topic, result: response.result) default: break diff --git a/Sources/WalletConnect/Relay/WalletConnectRelay.swift b/Sources/WalletConnect/Relay/WalletConnectRelay.swift index 6e3c2c926..ab724572f 100644 --- a/Sources/WalletConnect/Relay/WalletConnectRelay.swift +++ b/Sources/WalletConnect/Relay/WalletConnectRelay.swift @@ -34,7 +34,7 @@ class WalletConnectRelay: WalletConnectRelaying { var onResponse: ((WCResponse) -> Void)? private var networkRelayer: NetworkRelaying - private let jsonRpcSerialiser: JSONRPCSerialising + private let jsonRpcSerializer: JSONRPCSerializing private let jsonRpcHistory: JsonRpcHistoryRecording var transportConnectionPublisher: AnyPublisher { @@ -55,11 +55,11 @@ class WalletConnectRelay: WalletConnectRelaying { let logger: ConsoleLogging init(networkRelayer: NetworkRelaying, - jsonRpcSerialiser: JSONRPCSerialising, + jsonRpcSerializer: JSONRPCSerializing, logger: ConsoleLogging, jsonRpcHistory: JsonRpcHistoryRecording) { self.networkRelayer = networkRelayer - self.jsonRpcSerialiser = jsonRpcSerialiser + self.jsonRpcSerializer = jsonRpcSerializer self.logger = logger self.jsonRpcHistory = jsonRpcHistory setUpPublishers() @@ -72,7 +72,7 @@ class WalletConnectRelay: WalletConnectRelaying { func request(topic: String, payload: WCRequest, completion: ((Result, JSONRPCErrorResponse>)->())?) { do { try jsonRpcHistory.set(topic: topic, request: payload, chainId: getChainId(payload)) - let message = try jsonRpcSerialiser.serialise(topic: topic, encodable: payload) + let message = try jsonRpcSerializer.serialize(topic: topic, encodable: payload) networkRelayer.publish(topic: topic, payload: message) { [weak self] error in guard let self = self else {return} if let error = error { @@ -103,10 +103,10 @@ class WalletConnectRelay: WalletConnectRelaying { func respond(topic: String, response: JsonRpcResponseTypes, completion: @escaping ((Error?)->())) { do { - try jsonRpcHistory.resolve(response: response) - let message = try jsonRpcSerialiser.serialise(topic: topic, encodable: response.value) + _ = try jsonRpcHistory.resolve(response: response) + let message = try jsonRpcSerializer.serialize(topic: topic, encodable: response.value) logger.debug("Responding....topic: \(topic)") - networkRelayer.publish(topic: topic, payload: message) { [weak self] error in + networkRelayer.publish(topic: topic, payload: message) { error in completion(error) } } catch WalletConnectError.internal(.jsonRpcDuplicateDetected) { @@ -145,12 +145,12 @@ class WalletConnectRelay: WalletConnectRelaying { } private func manageSubscription(_ topic: String, _ message: String) { - if let deserialisedJsonRpcRequest: WCRequest = jsonRpcSerialiser.tryDeserialise(topic: topic, message: message) { - handleWCRequest(topic: topic, request: deserialisedJsonRpcRequest) - } else if let deserialisedJsonRpcResponse: JSONRPCResponse = jsonRpcSerialiser.tryDeserialise(topic: topic, message: message) { - handleJsonRpcResponse(response: deserialisedJsonRpcResponse) - } else if let deserialisedJsonRpcError: JSONRPCErrorResponse = jsonRpcSerialiser.tryDeserialise(topic: topic, message: message) { - handleJsonRpcErrorResponse(response: deserialisedJsonRpcError) + if let deserializedJsonRpcRequest: WCRequest = jsonRpcSerializer.tryDeserialize(topic: topic, message: message) { + handleWCRequest(topic: topic, request: deserializedJsonRpcRequest) + } else if let deserializedJsonRpcResponse: JSONRPCResponse = jsonRpcSerializer.tryDeserialize(topic: topic, message: message) { + handleJsonRpcResponse(response: deserializedJsonRpcResponse) + } else if let deserializedJsonRpcError: JSONRPCErrorResponse = jsonRpcSerializer.tryDeserialize(topic: topic, message: message) { + handleJsonRpcErrorResponse(response: deserializedJsonRpcError) } else { logger.warn("Warning: WalletConnect Relay - Received unknown object type from networking relay") } diff --git a/Sources/WalletConnect/Serialiser/JSONRPCSerialiserError.swift b/Sources/WalletConnect/Serialiser/JSONRPCSerialiserError.swift index eadaeec5d..87b10edf9 100644 --- a/Sources/WalletConnect/Serialiser/JSONRPCSerialiserError.swift +++ b/Sources/WalletConnect/Serialiser/JSONRPCSerialiserError.swift @@ -2,6 +2,6 @@ import Foundation -enum JSONRPCSerialiserError: String, Error { +enum JSONRPCSerializerError: String, Error { case messageToShort = "Error: message is too short" } diff --git a/Sources/WalletConnect/Serialiser/JSONRPCSerializing.swift b/Sources/WalletConnect/Serialiser/JSONRPCSerializing.swift index 14e804bc2..6be4a9a2f 100644 --- a/Sources/WalletConnect/Serialiser/JSONRPCSerializing.swift +++ b/Sources/WalletConnect/Serialiser/JSONRPCSerializing.swift @@ -1,12 +1,12 @@ import Foundation -protocol JSONRPCSerialising { - func serialise(topic: String, encodable: Encodable) throws -> String - func tryDeserialise(topic: String, message: String) -> T? +protocol JSONRPCSerializing { + func serialize(topic: String, encodable: Encodable) throws -> String + func tryDeserialize(topic: String, message: String) -> T? var codec: Codec {get} } -class JSONRPCSerialiser: JSONRPCSerialising { +class JSONRPCSerializer: JSONRPCSerializing { private let crypto: Crypto let codec: Codec @@ -16,7 +16,7 @@ class JSONRPCSerialiser: JSONRPCSerialising { self.codec = codec } - func serialise(topic: String, encodable: Encodable) throws -> String { + func serialize(topic: String, encodable: Encodable) throws -> String { let messageJson = try encodable.json() var message: String if let agreementKeys = try? crypto.getAgreementSecret(for: topic) { @@ -27,23 +27,23 @@ class JSONRPCSerialiser: JSONRPCSerialising { return message } - func tryDeserialise(topic: String, message: String) -> T? { + func tryDeserialize(topic: String, message: String) -> T? { do { - let deserialisedJsonRpcRequest: T + let deserializedJsonRpcRequest: T if let agreementKeys = try? crypto.getAgreementSecret(for: topic) { - deserialisedJsonRpcRequest = try deserialise(message: message, symmetricKey: agreementKeys.sharedSecret) + deserializedJsonRpcRequest = try deserialize(message: message, symmetricKey: agreementKeys.sharedSecret) } else { let jsonData = Data(hex: message) - deserialisedJsonRpcRequest = try JSONDecoder().decode(T.self, from: jsonData) + deserializedJsonRpcRequest = try JSONDecoder().decode(T.self, from: jsonData) } - return deserialisedJsonRpcRequest + return deserializedJsonRpcRequest } catch { // logger.debug("Type \(T.self) does not match the payload") return nil } } - func deserialise(message: String, symmetricKey: Data) throws -> T { + func deserialize(message: String, symmetricKey: Data) throws -> T { let JSONRPCData = try decrypt(message: message, symmetricKey: symmetricKey) return try JSONDecoder().decode(T.self, from: JSONRPCData) } @@ -58,7 +58,7 @@ class JSONRPCSerialiser: JSONRPCSerialising { } private func decrypt(message: String, symmetricKey: Data) throws -> Data { - let encryptionPayload = try deserialiseIntoPayload(message: message) + let encryptionPayload = try deserializeIntoPayload(message: message) let decryptedJSONRPC = try codec.decode(payload: encryptionPayload, sharedSecret: symmetricKey) guard let JSONRPCData = decryptedJSONRPC.data(using: .utf8) else { throw DataConversionError.stringToDataFailed @@ -66,10 +66,10 @@ class JSONRPCSerialiser: JSONRPCSerialising { return JSONRPCData } - private func deserialiseIntoPayload(message: String) throws -> EncryptionPayload { + private func deserializeIntoPayload(message: String) throws -> EncryptionPayload { let data = Data(hex: message) guard data.count > EncryptionPayload.ivLength + EncryptionPayload.publicKeyLength + EncryptionPayload.macLength else { - throw JSONRPCSerialiserError.messageToShort + throw JSONRPCSerializerError.messageToShort } let pubKeyRangeStartIndex = EncryptionPayload.ivLength let macStartIndex = pubKeyRangeStartIndex + EncryptionPayload.publicKeyLength diff --git a/Sources/WalletConnect/WalletConnectClient.swift b/Sources/WalletConnect/WalletConnectClient.swift index 9038789ad..5fb5f1f1d 100644 --- a/Sources/WalletConnect/WalletConnectClient.swift +++ b/Sources/WalletConnect/WalletConnectClient.swift @@ -8,7 +8,7 @@ import UIKit /// An Object that expose public API to provide interactions with WalletConnect SDK /// -/// WalletConnect Client is not a singleton but once you create an instance, you should not deinitialise it. Usually only one instance of a client is required in the application. +/// WalletConnect Client is not a singleton but once you create an instance, you should not deinitialize it. Usually only one instance of a client is required in the application. /// /// ```swift /// let metadata = AppMetadata(name: String?, description: String?, url: String?, icons: [String]?) @@ -44,7 +44,7 @@ public final class WalletConnectClient { /// - keyValueStorage: by default WalletConnect SDK will store sequences in UserDefaults but if for some reasons you want to provide your own storage you can inject it here. /// - clientName: if your app requires more than one client you are required to call them with different names to distinguish logs source and prefix storage keys. /// - /// WalletConnect Client is not a singleton but once you create an instance, you should not deinitialise it. Usually only one instance of a client is required in the application. + /// WalletConnect Client is not a singleton but once you create an instance, you should not deinitialize it. Usually only one instance of a client is required in the application. public convenience init(metadata: AppMetadata, projectId: String, isController: Bool, relayHost: String, keyValueStorage: KeyValueStorage = UserDefaults.standard, clientName: String? = nil) { self.init(metadata: metadata, projectId: projectId, isController: isController, relayHost: relayHost, logger: ConsoleLogger(loggingLevel: .off), keychain: KeychainStorage(uniqueIdentifier: clientName), keyValueStorage: keyValueStorage, clientName: clientName) } @@ -58,9 +58,9 @@ public final class WalletConnectClient { self.secureStorage = SecureStorage(keychain: keychain) let relayUrl = WakuNetworkRelay.makeRelayUrl(host: relayHost, projectId: projectId) self.wakuRelay = WakuNetworkRelay(logger: logger, url: relayUrl, keyValueStorage: keyValueStorage, uniqueIdentifier: clientName ?? "") - let serialiser = JSONRPCSerialiser(crypto: crypto) + let serializer = JSONRPCSerializer(crypto: crypto) self.history = JsonRpcHistory(logger: logger, keyValueStore: KeyValueStore(defaults: keyValueStorage, identifier: StorageDomainIdentifiers.jsonRpcHistory(clientName: clientName ?? "_"))) - self.relay = WalletConnectRelay(networkRelayer: wakuRelay, jsonRpcSerialiser: serialiser, logger: logger, jsonRpcHistory: history) + self.relay = WalletConnectRelay(networkRelayer: wakuRelay, jsonRpcSerializer: serializer, logger: logger, jsonRpcHistory: history) let pairingSequencesStore = PairingStorage(storage: SequenceStore(storage: keyValueStorage, identifier: StorageDomainIdentifiers.pairings(clientName: clientName ?? "_"))) let sessionSequencesStore = SessionStorage(storage: SequenceStore(storage: keyValueStorage, identifier: StorageDomainIdentifiers.sessions(clientName: clientName ?? "_"))) self.pairingEngine = PairingEngine(relay: relay, crypto: crypto, subscriber: WCSubscriber(relay: relay, logger: logger), sequencesStore: pairingSequencesStore, isController: isController, metadata: metadata, logger: logger) diff --git a/Sources/WalletConnectUtils/AnyCodable.swift b/Sources/WalletConnectUtils/AnyCodable.swift index 8d0436d6a..98ec034cf 100644 --- a/Sources/WalletConnectUtils/AnyCodable.swift +++ b/Sources/WalletConnectUtils/AnyCodable.swift @@ -75,10 +75,10 @@ extension AnyCodable: Decodable, Encodable { } else if let stringVal = try? container.decode(String.self) { value = stringVal } else { - throw DecodingError.dataCorruptedError(in: container, debugDescription: "the container contains nothing serialisable") + throw DecodingError.dataCorruptedError(in: container, debugDescription: "the container contains nothing serializable") } } else { - throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "Could not serialise")) + throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "Could not serialize")) } } diff --git a/Tests/WalletConnectTests/JSONRPCSerialiserTests.swift b/Tests/WalletConnectTests/JSONRPCSerialiserTests.swift index 2e4740752..f2d4f212b 100644 --- a/Tests/WalletConnectTests/JSONRPCSerialiserTests.swift +++ b/Tests/WalletConnectTests/JSONRPCSerialiserTests.swift @@ -5,33 +5,33 @@ import Foundation import XCTest @testable import WalletConnect -final class JSONRPCSerialiserTests: XCTestCase { - var serialiser: JSONRPCSerialiser! +final class JSONRPCSerializerTests: XCTestCase { + var serializer: JSONRPCSerializer! var codec: MockedCodec! override func setUp() { codec = MockedCodec() - self.serialiser = JSONRPCSerialiser(crypto: Crypto(keychain: KeychainStorageMock()), codec: codec) + self.serializer = JSONRPCSerializer(crypto: Crypto(keychain: KeychainStorageMock()), codec: codec) } override func tearDown() { - serialiser = nil + serializer = nil } - func testSerialise() { - codec.encryptionPayload = EncryptionPayload(iv: SerialiserTestData.iv, - publicKey: SerialiserTestData.publicKey, - mac: SerialiserTestData.mac, - cipherText: SerialiserTestData.cipherText) - let serialisedMessage = try! serialiser.encrypt(json: SerialiserTestData.pairingApproveJSON, agreementKeys: SerialiserTestData.emptyAgreementSecret) - let serialisedMessageSample = SerialiserTestData.serialisedMessage - XCTAssertEqual(serialisedMessage, serialisedMessageSample) + func testSerialize() { + codec.encryptionPayload = EncryptionPayload(iv: SerializerTestData.iv, + publicKey: SerializerTestData.publicKey, + mac: SerializerTestData.mac, + cipherText: SerializerTestData.cipherText) + let serializedMessage = try! serializer.encrypt(json: SerializerTestData.pairingApproveJSON, agreementKeys: SerializerTestData.emptyAgreementSecret) + let serializedMessageSample = SerializerTestData.serializedMessage + XCTAssertEqual(serializedMessage, serializedMessageSample) } - func testDeserialise() { - let serialisedMessageSample = SerialiserTestData.serialisedMessage - codec.decodedJson = SerialiserTestData.pairingApproveJSON - let deserialisedJSONRPC: WCRequest = try! serialiser.deserialise(message: serialisedMessageSample, symmetricKey: Data(hex: "")) - XCTAssertEqual(deserialisedJSONRPC.params, SerialiserTestData.pairingApproveJSONRPCRequest.params) + func testDeserialize() { + let serializedMessageSample = SerializerTestData.serializedMessage + codec.decodedJson = SerializerTestData.pairingApproveJSON + let deserializedJSONRPC: WCRequest = try! serializer.deserialize(message: serializedMessageSample, symmetricKey: Data(hex: "")) + XCTAssertEqual(deserializedJSONRPC.params, SerializerTestData.pairingApproveJSONRPCRequest.params) } } diff --git a/Tests/WalletConnectTests/Mocks/MockedJSONRPCSerialiser.swift b/Tests/WalletConnectTests/Mocks/MockedJSONRPCSerialiser.swift deleted file mode 100644 index 8e7a25968..000000000 --- a/Tests/WalletConnectTests/Mocks/MockedJSONRPCSerialiser.swift +++ /dev/null @@ -1,39 +0,0 @@ -// - -import Foundation -import WalletConnectUtils -@testable import WalletConnect - -class MockedJSONRPCSerialiser: JSONRPCSerialising { - - var codec: Codec - var deserialised: Any! - var serialised: String! - - init(codec: Codec = MockedCodec()) { - self.codec = codec - } - - func serialise(topic: String, encodable: Encodable) throws -> String { - try serialise(json: try encodable.json(), agreementKeys: AgreementSecret(sharedSecret: Data(), publicKey: AgreementPrivateKey().publicKey)) - } - func tryDeserialise(topic: String, message: String) -> T? { - try? deserialise(message: message, symmetricKey: Data()) - } - func deserialiseJsonRpc(topic: String, message: String) throws -> Result, JSONRPCErrorResponse> { - .success(try deserialise(message: message, symmetricKey: Data())) - } - - func deserialise(message: String, symmetricKey: Data) throws -> T where T : Codable { - if let deserialisedModel = deserialised as? T { - return deserialisedModel - } else { - throw NSError.mock() - } - } - - func serialise(json: String, agreementKeys: AgreementSecret) throws -> String { - return serialised - } - -} diff --git a/Tests/WalletConnectTests/Mocks/MockedJSONRPCSerializer.swift b/Tests/WalletConnectTests/Mocks/MockedJSONRPCSerializer.swift new file mode 100644 index 000000000..fbc8c9da7 --- /dev/null +++ b/Tests/WalletConnectTests/Mocks/MockedJSONRPCSerializer.swift @@ -0,0 +1,39 @@ +// + +import Foundation +import WalletConnectUtils +@testable import WalletConnect + +class MockedJSONRPCSerializer: JSONRPCSerializing { + + var codec: Codec + var deserialized: Any! + var serialized: String! + + init(codec: Codec = MockedCodec()) { + self.codec = codec + } + + func serialize(topic: String, encodable: Encodable) throws -> String { + try serialize(json: try encodable.json(), agreementKeys: AgreementSecret(sharedSecret: Data(), publicKey: AgreementPrivateKey().publicKey)) + } + func tryDeserialize(topic: String, message: String) -> T? { + try? deserialize(message: message, symmetricKey: Data()) + } + func deserializeJsonRpc(topic: String, message: String) throws -> Result, JSONRPCErrorResponse> { + .success(try deserialize(message: message, symmetricKey: Data())) + } + + func deserialize(message: String, symmetricKey: Data) throws -> T where T : Codable { + if let deserializedModel = deserialized as? T { + return deserializedModel + } else { + throw NSError.mock() + } + } + + func serialize(json: String, agreementKeys: AgreementSecret) throws -> String { + return serialized + } + +} diff --git a/Tests/WalletConnectTests/Mocks/MockedRelay.swift b/Tests/WalletConnectTests/Mocks/MockedRelay.swift index 171f51770..07f5becb5 100644 --- a/Tests/WalletConnectTests/Mocks/MockedRelay.swift +++ b/Tests/WalletConnectTests/Mocks/MockedRelay.swift @@ -48,7 +48,7 @@ class MockedWCRelay: WalletConnectRelaying { func sendSubscriptionPayloadOn(topic: String) { let payload = WCRequestSubscriptionPayload(topic: topic, - wcRequest: SerialiserTestData.pairingApproveJSONRPCRequest) + wcRequest: SerializerTestData.pairingApproveJSONRPCRequest) wcRequestPublisherSubject.send(payload) } } diff --git a/Tests/WalletConnectTests/TestsData/SerialiserTestData.swift b/Tests/WalletConnectTests/TestsData/SerialiserTestData.swift index f2f4d91e1..452c9eed1 100644 --- a/Tests/WalletConnectTests/TestsData/SerialiserTestData.swift +++ b/Tests/WalletConnectTests/TestsData/SerialiserTestData.swift @@ -3,14 +3,14 @@ import Foundation @testable import WalletConnect -enum SerialiserTestData { +enum SerializerTestData { static let emptyAgreementSecret = AgreementSecret(sharedSecret: Data(hex: ""), publicKey: AgreementPrivateKey().publicKey) static let iv = Data(hex: "f0d00d4274a7e9711e4e0f21820b8877") static let publicKey = Data(hex: "45c59ad0c053925072f4503a39fe579ca8b7b8fa6bf0c7297e6db8f6585ee77f") static let mac = Data(hex: "fc6d3106fa827043279f9db08cd2e29a988c7272fa3cfdb739163bb9606822c7") static let cipherText = Data(hex: "14aa7f6034dd0213be5901b472f461769855ac1e2f6bec6a8ed1157a9da3b2df08802cbd6e0d030d86ff99011040cfc831eec3636c1d46bfc22cbe055560fea3") - static let serialisedMessage = "f0d00d4274a7e9711e4e0f21820b887745c59ad0c053925072f4503a39fe579ca8b7b8fa6bf0c7297e6db8f6585ee77ffc6d3106fa827043279f9db08cd2e29a988c7272fa3cfdb739163bb9606822c714aa7f6034dd0213be5901b472f461769855ac1e2f6bec6a8ed1157a9da3b2df08802cbd6e0d030d86ff99011040cfc831eec3636c1d46bfc22cbe055560fea3" + static let serializedMessage = "f0d00d4274a7e9711e4e0f21820b887745c59ad0c053925072f4503a39fe579ca8b7b8fa6bf0c7297e6db8f6585ee77ffc6d3106fa827043279f9db08cd2e29a988c7272fa3cfdb739163bb9606822c714aa7f6034dd0213be5901b472f461769855ac1e2f6bec6a8ed1157a9da3b2df08802cbd6e0d030d86ff99011040cfc831eec3636c1d46bfc22cbe055560fea3" static let pairingApproveJSONRPCRequest = WCRequest( id: 0, jsonrpc: "2.0", diff --git a/Tests/WalletConnectTests/WCRelayTests.swift b/Tests/WalletConnectTests/WCRelayTests.swift index 37ead33db..50e072d5d 100644 --- a/Tests/WalletConnectTests/WCRelayTests.swift +++ b/Tests/WalletConnectTests/WCRelayTests.swift @@ -9,22 +9,22 @@ import WalletConnectUtils class WalletConnectRelayTests: XCTestCase { var wcRelay: WalletConnectRelay! var networkRelayer: MockedNetworkRelayer! - var serialiser: MockedJSONRPCSerialiser! + var serializer: MockedJSONRPCSerializer! var crypto: Crypto! private var publishers = [AnyCancellable]() override func setUp() { let logger = ConsoleLoggerMock() - serialiser = MockedJSONRPCSerialiser() + serializer = MockedJSONRPCSerializer() networkRelayer = MockedNetworkRelayer() - wcRelay = WalletConnectRelay(networkRelayer: networkRelayer, jsonRpcSerialiser: serialiser, logger: logger, jsonRpcHistory: JsonRpcHistory(logger: logger, keyValueStore: KeyValueStore(defaults: RuntimeKeyValueStorage(), identifier: ""))) + wcRelay = WalletConnectRelay(networkRelayer: networkRelayer, jsonRpcSerializer: serializer, logger: logger, jsonRpcHistory: JsonRpcHistory(logger: logger, keyValueStore: KeyValueStore(defaults: RuntimeKeyValueStorage(), identifier: ""))) } override func tearDown() { wcRelay = nil networkRelayer = nil - serialiser = nil + serializer = nil } func testNotifiesOnEncryptedWCJsonRpcRequest() { @@ -33,7 +33,7 @@ class WalletConnectRelayTests: XCTestCase { wcRelay.wcRequestPublisher.sink { (request) in requestExpectation.fulfill() }.store(in: &publishers) - serialiser.deserialised = SerialiserTestData.pairingApproveJSONRPCRequest + serializer.deserialized = SerializerTestData.pairingApproveJSONRPCRequest networkRelayer.onMessage?(topic, testPayload) waitForExpectations(timeout: 1.001, handler: nil) } @@ -43,8 +43,8 @@ class WalletConnectRelayTests: XCTestCase { let topic = "93293932" let request = getWCSessionPayloadRequest() let sessionPayloadResponse = getWCSessionPayloadResponse() - serialiser.deserialised = sessionPayloadResponse - serialiser.serialised = try! sessionPayloadResponse.json().toHexEncodedString() + serializer.deserialized = sessionPayloadResponse + serializer.serialized = try! sessionPayloadResponse.json().toHexEncodedString() wcRelay.request(topic: topic, payload: request) { result in XCTAssertEqual(result, .success(sessionPayloadResponse)) responseExpectation.fulfill() @@ -60,8 +60,8 @@ class WalletConnectRelayTests: XCTestCase { let topic = "fefc3dc39cacbc562ed58f92b296e2d65a6b07ef08992b93db5b3cb86280635a" let request = getWCSessionPayloadRequest() let sessionPayloadResponse = getWCSessionPayloadResponse() - serialiser.deserialised = sessionPayloadResponse - serialiser.serialised = "encrypted_message" + serializer.deserialized = sessionPayloadResponse + serializer.serialized = "encrypted_message" wcRelay.request(topic: topic, payload: request) { result in XCTAssertEqual(result, .success(sessionPayloadResponse)) responseExpectation.fulfill()