Skip to content

Commit

Permalink
Rebase with develop
Browse files Browse the repository at this point in the history
  • Loading branch information
flypaper0 committed Aug 19, 2022
1 parent a556e59 commit 0396e44
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Example/IntegrationTests/Auth/AuthTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ final class AuthTests: XCTestCase {
Task(priority: .high) {
let signature = try! MessageSigner(signer: Signer()).sign(message: message, privateKey: prvKey)
let cacaoSignature = CacaoSignature(t: "eip191", s: signature)
try! await wallet.respond(.success(RespondParams(id: id, signature: cacaoSignature)))
try! await wallet.respond(requestId: id, result: .success(cacaoSignature))
}
}
.store(in: &publishers)
Expand All @@ -79,6 +79,6 @@ final class AuthTests: XCTestCase {
responseExpectation.fulfill()
}
.store(in: &publishers)
wait(for: [responseExpectation], timeout: 2)
wait(for: [responseExpectation], timeout: .infinity)
}
}
8 changes: 4 additions & 4 deletions Sources/Auth/Services/Wallet/WalletRequestSubscriber.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import WalletConnectKMS
class WalletRequestSubscriber {
private let networkingInteractor: NetworkInteracting
private let logger: ConsoleLogging
private let kms: KeyManagementService
private let kms: KeyManagementServiceProtocol
private let address: String?
private var publishers = [AnyCancellable]()
private let messageFormatter: SIWEMessageFormatting
var onRequest: ((_ id: RPCID, _ message: String) -> Void)?

init(networkingInteractor: NetworkInteracting,
logger: ConsoleLogging,
kms: KeyManagementService,
kms: KeyManagementServiceProtocol,
messageFormatter: SIWEMessageFormatting,
address: String?) {
self.networkingInteractor = networkingInteractor
Expand All @@ -27,12 +27,12 @@ class WalletRequestSubscriber {
}

private func subscribeForRequest() {
guard let address = address else { return }

networkingInteractor.requestPublisher.sink { [unowned self] payload in

logger.debug("WalletRequestSubscriber: Received request")

guard let address = address else { return }

guard let requestId = payload.request.id, payload.request.method == "wc_authRequest"
else { return }

Expand Down
4 changes: 2 additions & 2 deletions Sources/Auth/Services/Wallet/WalletRespondService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ actor WalletRespondService {
}

private func generateAgreementKeys(requestParams: AuthRequestParams) throws -> (topic: String, keys: AgreementKeys) {
let peerPubKey = requestParams.requester.publicKey
let peerPubKey = try AgreementPublicKey(hex: requestParams.requester.publicKey)
let topic = peerPubKey.rawRepresentation.sha256().toHexString()
let selfPubKey = try kms.createX25519KeyPair()
let keys = try kms.performKeyAgreement(selfPublicKey: selfPubKey, peerPublicKey: peerPubKey)
let keys = try kms.performKeyAgreement(selfPublicKey: selfPubKey, peerPublicKey: peerPubKey.hexRepresentation)
return (topic, keys)
}
}
7 changes: 4 additions & 3 deletions Tests/AuthTests/AuthRequstSubscriberTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ class AuthRequstSubscriberTests: XCTestCase {
override func setUp() {
networkingInteractor = NetworkingInteractorMock()
messageFormatter = SIWEMessageFormatterMock()
// sut = WalletRequestSubscriber(networkingInteractor: networkingInteractor,
// logger: ConsoleLoggerMock(),
// messageFormatter: messageFormatter, address: "")
sut = WalletRequestSubscriber(networkingInteractor: networkingInteractor,
logger: ConsoleLoggerMock(),
kms: KeyManagementServiceMock(),
messageFormatter: messageFormatter, address: "")
}

func testSubscribeRequest() {
Expand Down

0 comments on commit 0396e44

Please sign in to comment.