Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.6.11 #939

Merged
merged 25 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4705b54
Expose sessionProperties and requiredNamespaces to Session
alexander-lsvk Jun 27, 2023
8de9e2f
add relay client factory
llbartekll Jun 28, 2023
e52e345
fix integration tests
llbartekll Jun 28, 2023
122df50
fix unit tests
llbartekll Jun 28, 2023
788eaf4
CodableStore to SyncStore
flypaper0 Jun 16, 2023
f7fe1c3
Sync store integrated
flypaper0 Jun 16, 2023
5d05f4a
Redundant import
flypaper0 Jun 16, 2023
7ea7e6d
Sync create store
flypaper0 Jun 16, 2023
3d82139
Sync register
flypaper0 Jun 19, 2023
cedfd36
remove duplicated storage
llbartekll Jun 29, 2023
8233760
fix relay tests
llbartekll Jun 29, 2023
b8ad336
podspec updated
flypaper0 Jun 29, 2023
75bc40d
Push: sync integration
flypaper0 Jun 29, 2023
39494ba
Merge pull request #932 from WalletConnect/relay-factory
llbartekll Jun 29, 2023
09bd78e
Add topic to AuthRequest
alexander-lsvk Jun 29, 2023
160d6d2
Merge pull request #934 from WalletConnect/feature/cocoapods-w3w-by-d…
flypaper0 Jun 29, 2023
e98a05f
Merge pull request #915 from WalletConnect/feature/sync-subscriptions
flypaper0 Jun 29, 2023
27c29e7
Allow empty optional events
alexander-lsvk Jun 30, 2023
e767d4f
Update tests
alexander-lsvk Jun 30, 2023
57b56f9
Merge pull request #937 from WalletConnect/allow-empty-optional-events
Jul 1, 2023
b341e5b
Update tests
alexander-lsvk Jul 2, 2023
a0a853a
Update tests
alexander-lsvk Jul 2, 2023
40397a9
Merge branch 'develop' into aprove-session-properties
alexander-lsvk Jul 3, 2023
dfd5be0
Merge pull request #936 from WalletConnect/aprove-session-properties
Jul 3, 2023
b4ad15e
Set User Agent
alexander-lsvk Jul 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Example/ExampleApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 54;
objectVersion = 52;
objects = {

/* Begin PBXBuildFile section */
Expand Down
10 changes: 8 additions & 2 deletions Example/IntegrationTests/Auth/AuthTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,15 @@ final class AuthTests: XCTestCase {

func makeClients(prefix: String, iatProvider: IATProvider) -> (PairingClient, AuthClient) {
let logger = ConsoleLogger(suffix: prefix, loggingLevel: .debug)
let keychain = KeychainStorageMock()
let relayClient = RelayClient(relayHost: InputConfig.relayHost, projectId: InputConfig.projectId, keychainStorage: keychain, socketFactory: DefaultSocketFactory(), logger: logger)
let keyValueStorage = RuntimeKeyValueStorage()
let keychain = KeychainStorageMock()
let relayClient = RelayClientFactory.create(
relayHost: InputConfig.relayHost,
projectId: InputConfig.projectId,
keyValueStorage: keyValueStorage,
keychainStorage: keychain,
socketFactory: DefaultSocketFactory(),
logger: logger)

let networkingClient = NetworkingClientFactory.create(
relayClient: relayClient,
Expand Down
11 changes: 9 additions & 2 deletions Example/IntegrationTests/Chat/ChatTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,16 @@ final class ChatTests: XCTestCase {
func makeClient(prefix: String, account: Account) -> ChatClient {
let keyserverURL = URL(string: "https://keys.walletconnect.com")!
let logger = ConsoleLogger(suffix: prefix, loggingLevel: .debug)
let keychain = KeychainStorageMock()
let relayClient = RelayClient(relayHost: InputConfig.relayHost, projectId: InputConfig.projectId, keychainStorage: keychain, socketFactory: DefaultSocketFactory(), logger: logger)
let keyValueStorage = RuntimeKeyValueStorage()
let keychain = KeychainStorageMock()
let relayClient = RelayClientFactory.create(
relayHost: InputConfig.relayHost,
projectId: InputConfig.projectId,
keyValueStorage: keyValueStorage,
keychainStorage: keychain,
socketFactory: DefaultSocketFactory(),
logger: logger)

let networkingInteractor = NetworkingClientFactory.create(
relayClient: relayClient,
logger: logger,
Expand Down
2 changes: 1 addition & 1 deletion Example/IntegrationTests/History/HistoryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class HistoryTests: XCTestCase {
}

private func makeRelayClient(prefix: String, keychain: KeychainStorageProtocol) -> RelayClient {
return RelayClient(
return RelayClientFactory.create(
relayHost: InputConfig.relayHost,
projectId: InputConfig.projectId,
keyValueStorage: RuntimeKeyValueStorage(),
Expand Down
27 changes: 16 additions & 11 deletions Example/IntegrationTests/Pairing/PairingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import WalletConnectNetworking
import WalletConnectEcho
@testable import WalletConnectPush
@testable import WalletConnectPairing
@testable import WalletConnectSync

final class PairingTests: XCTestCase {

Expand All @@ -21,15 +22,15 @@ final class PairingTests: XCTestCase {

private var publishers = [AnyCancellable]()

func makeClientDependencies(prefix: String) -> (PairingClient, NetworkInteracting, KeychainStorageProtocol, KeyValueStorage) {
func makeClientDependencies(prefix: String) -> (PairingClient, NetworkInteracting, SyncClient, KeychainStorageProtocol, KeyValueStorage) {
let keychain = KeychainStorageMock()
let keyValueStorage = RuntimeKeyValueStorage()

let relayLogger = ConsoleLogger(suffix: prefix + " [Relay]", loggingLevel: .debug)
let pairingLogger = ConsoleLogger(suffix: prefix + " [Pairing]", loggingLevel: .debug)
let networkingLogger = ConsoleLogger(suffix: prefix + " [Networking]", loggingLevel: .debug)

let relayClient = RelayClient(
let relayClient = RelayClientFactory.create(
relayHost: InputConfig.relayHost,
projectId: InputConfig.projectId,
keyValueStorage: RuntimeKeyValueStorage(),
Expand All @@ -49,27 +50,30 @@ final class PairingTests: XCTestCase {
keychainStorage: keychain,
networkingClient: networkingClient)

let syncClient = SyncClientFactory.create(networkInteractor: networkingClient, bip44: DefaultBIP44Provider(), keychain: keychain)

let clientId = try! networkingClient.getClientId()
networkingLogger.debug("My client id is: \(clientId)")

return (pairingClient, networkingClient, keychain, keyValueStorage)
return (pairingClient, networkingClient, syncClient, keychain, keyValueStorage)
}

func makeDappClients() {
let prefix = "🤖 Dapp: "
let (pairingClient, networkingInteractor, keychain, keyValueStorage) = makeClientDependencies(prefix: prefix)
let (pairingClient, networkingInteractor, syncClient, keychain, keyValueStorage) = makeClientDependencies(prefix: prefix)
let pushLogger = ConsoleLogger(suffix: prefix + " [Push]", loggingLevel: .debug)
appPairingClient = pairingClient
appPushClient = DappPushClientFactory.create(metadata: AppMetadata(name: name, description: "", url: "", icons: [""]),
logger: pushLogger,
keyValueStorage: keyValueStorage,
keychainStorage: keychain,
networkInteractor: networkingInteractor)
logger: pushLogger,
keyValueStorage: keyValueStorage,
keychainStorage: keychain,
networkInteractor: networkingInteractor,
syncClient: syncClient)
}

func makeWalletClients() {
let prefix = "🐶 Wallet: "
let (pairingClient, networkingInteractor, keychain, keyValueStorage) = makeClientDependencies(prefix: prefix)
let (pairingClient, networkingInteractor, syncClient, keychain, keyValueStorage) = makeClientDependencies(prefix: prefix)
let pushLogger = ConsoleLogger(suffix: prefix + " [Push]", loggingLevel: .debug)
walletPairingClient = pairingClient
let echoClient = EchoClientFactory.create(projectId: "",
Expand All @@ -84,12 +88,13 @@ final class PairingTests: XCTestCase {
groupKeychainStorage: KeychainStorageMock(),
networkInteractor: networkingInteractor,
pairingRegisterer: pairingClient,
echoClient: echoClient)
echoClient: echoClient,
syncClient: syncClient)
}

func makeWalletPairingClient() {
let prefix = "🐶 Wallet: "
let (pairingClient, _, _, _) = makeClientDependencies(prefix: prefix)
let (pairingClient, _, _, _, _) = makeClientDependencies(prefix: prefix)
walletPairingClient = pairingClient
}

Expand Down
50 changes: 34 additions & 16 deletions Example/IntegrationTests/Push/PushTests.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import Foundation
import XCTest
import WalletConnectUtils
import Web3
@testable import WalletConnectKMS
import WalletConnectRelay
import Combine
import WalletConnectNetworking
import WalletConnectEcho
@testable import WalletConnectPush
@testable import WalletConnectPairing
@testable import WalletConnectSync
import WalletConnectIdentity
import WalletConnectSigner

Expand All @@ -21,21 +23,30 @@ final class PushTests: XCTestCase {

var pairingStorage: PairingStorage!

let pk = try! EthereumPrivateKey()

var privateKey: Data {
return Data(pk.rawPrivateKey)
}

var account: Account {
return Account("eip155:1:" + pk.address.hex(eip55: true))!
}

private var publishers = [AnyCancellable]()

func makeClientDependencies(prefix: String) -> (PairingClient, NetworkInteracting, KeychainStorageProtocol, KeyValueStorage) {
func makeClientDependencies(prefix: String) -> (PairingClient, NetworkInteracting, SyncClient, KeychainStorageProtocol, KeyValueStorage) {
let keychain = KeychainStorageMock()
let keyValueStorage = RuntimeKeyValueStorage()

let relayLogger = ConsoleLogger(suffix: prefix + " [Relay]", loggingLevel: .debug)
let pairingLogger = ConsoleLogger(suffix: prefix + " [Pairing]", loggingLevel: .debug)
let networkingLogger = ConsoleLogger(suffix: prefix + " [Networking]", loggingLevel: .debug)

let relayClient = RelayClient(
let relayClient = RelayClientFactory.create(
relayHost: InputConfig.relayHost,
projectId: InputConfig.projectId,
keyValueStorage: RuntimeKeyValueStorage(),
keyValueStorage: keyValueStorage,
keychainStorage: keychain,
socketFactory: DefaultSocketFactory(),
logger: relayLogger)
Expand All @@ -52,26 +63,29 @@ final class PushTests: XCTestCase {
keychainStorage: keychain,
networkingClient: networkingClient)

let syncClient = SyncClientFactory.create(networkInteractor: networkingClient, bip44: DefaultBIP44Provider(), keychain: keychain)

let clientId = try! networkingClient.getClientId()
networkingLogger.debug("My client id is: \(clientId)")
return (pairingClient, networkingClient, keychain, keyValueStorage)
return (pairingClient, networkingClient, syncClient, keychain, keyValueStorage)
}

func makeDappClients() {
let prefix = "🦄 Dapp: "
let (pairingClient, networkingInteractor, keychain, keyValueStorage) = makeClientDependencies(prefix: prefix)
let (pairingClient, networkingInteractor, syncClient, keychain, keyValueStorage) = makeClientDependencies(prefix: prefix)
let pushLogger = ConsoleLogger(suffix: prefix + " [Push]", loggingLevel: .debug)
dappPairingClient = pairingClient
dappPushClient = DappPushClientFactory.create(metadata: AppMetadata(name: "GM Dapp", description: "", url: "https://gm-dapp-xi.vercel.app/", icons: []),
logger: pushLogger,
keyValueStorage: keyValueStorage,
keychainStorage: keychain,
networkInteractor: networkingInteractor)
networkInteractor: networkingInteractor,
syncClient: syncClient)
}

func makeWalletClients() {
let prefix = "🦋 Wallet: "
let (pairingClient, networkingInteractor, keychain, keyValueStorage) = makeClientDependencies(prefix: prefix)
let (pairingClient, networkingInteractor, syncClient, keychain, keyValueStorage) = makeClientDependencies(prefix: prefix)
let pushLogger = ConsoleLogger(suffix: prefix + " [Push]", loggingLevel: .debug)
walletPairingClient = pairingClient
let echoClient = EchoClientFactory.create(projectId: "",
Expand All @@ -86,7 +100,8 @@ final class PushTests: XCTestCase {
groupKeychainStorage: KeychainStorageMock(),
networkInteractor: networkingInteractor,
pairingRegisterer: pairingClient,
echoClient: echoClient)
echoClient: echoClient,
syncClient: syncClient)
}

override func setUp() {
Expand All @@ -99,7 +114,8 @@ final class PushTests: XCTestCase {

let uri = try! await dappPairingClient.create()
try! await walletPairingClient.pair(uri: uri)
try! await dappPushClient.propose(account: Account.stub(), topic: uri.topic)
try! await walletPushClient.enableSync(account: account, onSign: sign)
try! await dappPushClient.propose(account: account, topic: uri.topic)

walletPushClient.requestPublisher.sink { [unowned self] (id, _, _) in
Task(priority: .high) { try! await walletPushClient.approve(id: id, onSign: sign) }
Expand All @@ -121,7 +137,7 @@ final class PushTests: XCTestCase {

let uri = try! await dappPairingClient.create()
try! await walletPairingClient.pair(uri: uri)
try! await dappPushClient.propose(account: Account.stub(), topic: uri.topic)
try! await dappPushClient.propose(account: account, topic: uri.topic)

walletPushClient.requestPublisher.sink { [unowned self] (id, _, _) in
Task(priority: .high) { try! await walletPushClient.reject(id: id) }
Expand All @@ -141,7 +157,8 @@ final class PushTests: XCTestCase {
func testWalletCreatesSubscription() async {
let expectation = expectation(description: "expects to create push subscription")
let metadata = AppMetadata(name: "GM Dapp", description: "", url: "https://gm-dapp-xi.vercel.app/", icons: [])
try! await walletPushClient.subscribe(metadata: metadata, account: Account.stub(), onSign: sign)
try! await walletPushClient.enableSync(account: account, onSign: sign)
try! await walletPushClient.subscribe(metadata: metadata, account: account, onSign: sign)
walletPushClient.subscriptionsPublisher
.first()
.sink { [unowned self] subscriptions in
Expand All @@ -152,12 +169,12 @@ final class PushTests: XCTestCase {
wait(for: [expectation], timeout: InputConfig.defaultTimeout)
}


func testDeletePushSubscription() async {
let expectation = expectation(description: "expects to delete push subscription")
let uri = try! await dappPairingClient.create()
try! await walletPairingClient.pair(uri: uri)
try! await dappPushClient.propose(account: Account.stub(), topic: uri.topic)
try! await walletPushClient.enableSync(account: account, onSign: sign)
try! await dappPushClient.propose(account: account, topic: uri.topic)
var subscriptionTopic: String!

walletPushClient.requestPublisher.sink { [unowned self] (id, _, _) in
Expand Down Expand Up @@ -185,7 +202,8 @@ final class PushTests: XCTestCase {
let expectation = expectation(description: "expects to create and update push subscription")
let metadata = AppMetadata(name: "GM Dapp", description: "", url: "https://gm-dapp-xi.vercel.app/", icons: [])
let updateScope: Set<String> = ["alerts"]
try! await walletPushClient.subscribe(metadata: metadata, account: Account.stub(), onSign: sign)
try! await walletPushClient.enableSync(account: account, onSign: sign)
try! await walletPushClient.subscribe(metadata: metadata, account: account, onSign: sign)
walletPushClient.subscriptionsPublisher
.first()
.sink { [unowned self] subscriptions in
Expand All @@ -212,7 +230,8 @@ final class PushTests: XCTestCase {
let pushMessage = PushMessage.stub()

let metadata = AppMetadata(name: "GM Dapp", description: "", url: "https://gm-dapp-xi.vercel.app/", icons: [])
try! await walletPushClient.subscribe(metadata: metadata, account: Account.stub(), onSign: sign)
try! await walletPushClient.enableSync(account: account, onSign: sign)
try! await walletPushClient.subscribe(metadata: metadata, account: account, onSign: sign)
var subscription: PushSubscription!
walletPushClient.subscriptionsPublisher
.first()
Expand All @@ -239,7 +258,6 @@ final class PushTests: XCTestCase {

private extension PushTests {
func sign(_ message: String) -> SigningResult {
let privateKey = Data(hex: "305c6cde3846927892cd32762f6120539f3ec74c9e3a16b9b798b1e85351ae2a")
let signer = MessageSignerFactory(signerFactory: DefaultSignerFactory()).create(projectId: InputConfig.projectId)
return .signed(try! signer.sign(message: message, privateKey: privateKey, type: .eip191))
}
Expand Down
7 changes: 3 additions & 4 deletions Example/IntegrationTests/Sign/SignClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ final class SignClientTests: XCTestCase {
static private func makeClientDelegate(name: String) -> ClientDelegate {
let logger = ConsoleLogger(suffix: name, loggingLevel: .debug)
let keychain = KeychainStorageMock()
let relayClient = RelayClient(
let keyValueStorage = RuntimeKeyValueStorage()
let relayClient = RelayClientFactory.create(
relayHost: InputConfig.relayHost,
projectId: InputConfig.projectId,
keyValueStorage: RuntimeKeyValueStorage(),
keyValueStorage: keyValueStorage,
keychainStorage: keychain,
socketFactory: DefaultSocketFactory(),
socketConnectionType: .automatic,
logger: logger
)
let keyValueStorage = RuntimeKeyValueStorage()

let networkingClient = NetworkingClientFactory.create(
relayClient: relayClient,
Expand Down
8 changes: 7 additions & 1 deletion Example/IntegrationTests/Sync/SyncTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ final class SyncTests: XCTestCase {
let kms = KeyManagementService(keychain: keychain)
let derivationService = SyncDerivationService(syncStorage: syncSignatureStore, bip44: DefaultBIP44Provider(), kms: kms)
let logger = ConsoleLogger(suffix: suffix, loggingLevel: .debug)
let relayClient = RelayClient(relayHost: InputConfig.relayHost, projectId: InputConfig.projectId, keychainStorage: keychain, socketFactory: DefaultSocketFactory(), logger: logger)
let relayClient = RelayClientFactory.create(
relayHost: InputConfig.relayHost,
projectId: InputConfig.projectId,
keyValueStorage: RuntimeKeyValueStorage(),
keychainStorage: keychain,
socketFactory: DefaultSocketFactory(),
logger: logger)
let networkingInteractor = NetworkingClientFactory.create(
relayClient: relayClient,
logger: logger,
Expand Down
12 changes: 11 additions & 1 deletion Example/RelayIntegrationTests/RelayClientEndToEndTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,17 @@ final class RelayClientEndToEndTests: XCTestCase {
socketConnectionType: .manual,
logger: logger
)
let relayClient = RelayClient(dispatcher: dispatcher, logger: logger, keyValueStorage: RuntimeKeyValueStorage(), clientIdStorage: clientIdStorage)
let keychain = KeychainStorageMock()
let keyValueStorage = RuntimeKeyValueStorage()
let relayClient = RelayClientFactory.create(
relayHost: InputConfig.relayHost,
projectId: InputConfig.projectId,
keyValueStorage: keyValueStorage,
keychainStorage: keychain,
socketFactory: DefaultSocketFactory(),
socketConnectionType: .manual,
logger: logger
)
let clientId = try! relayClient.getClientId()
logger.debug("My client id is: \(clientId)")

Expand Down
2 changes: 1 addition & 1 deletion Example/WalletApp/ApplicationLayer/EthKeyStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class EthKeyStore {
let privateKey: EthereumPrivateKey

var address: String {
return privateKey.address.hex(eip55: false)
return privateKey.address.hex(eip55: true)
}

var privateKeyRaw: Data {
Expand Down
Loading