Skip to content

Commit

Permalink
Merge pull request #1073 from WalletConnect/develop
Browse files Browse the repository at this point in the history
1.7.1
  • Loading branch information
flypaper0 authored Sep 3, 2023
2 parents a150963 + fdbfd82 commit bd2e5b6
Show file tree
Hide file tree
Showing 42 changed files with 404 additions and 416 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ jobs:
APPLE_KEY_CONTENT: ${{ secrets.APPLE_KEY_CONTENT }}
WALLETAPP_SENTRY_DSN: ${{ secrets.WALLETAPP_SENTRY_DSN }}
run: |
make release_all APPLE_ID=${{ secrets.APPLE_ID }} TOKEN=$(echo -n $GH_USER:$GH_TOKEN | base64) PROJECT_ID=${{ secrets.RELEASE_PROJECT_ID }} WALLETAPP_SENTRY_DSN=${{ secrets.WALLETAPP_SENTRY_DSN }}
make release_all APPLE_ID=${{ secrets.APPLE_ID }} TOKEN=$(echo -n $GH_USER:$GH_TOKEN | base64) PROJECT_ID=${{ secrets.RELEASE_PROJECT_ID }} WALLETAPP_SENTRY_DSN=${{ secrets.WALLETAPP_SENTRY_DSN }} MIXPANEL_TOKEN=${{secrets.MIXPANEL_TOKEN}}
2 changes: 2 additions & 0 deletions Configuration.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ RELAY_HOST = relay.walletconnect.com

// WALLETAPP_SENTRY_DSN = WALLETAPP_SENTRY_DSN

// MIXPANEL_TOKEN = MIXPANEL_TOKEN

CAST_HOST = notify.walletconnect.com
32 changes: 30 additions & 2 deletions 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 Expand Up @@ -34,11 +34,13 @@
847BD1E7298A806800076C90 /* NotificationsInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 847BD1E2298A806800076C90 /* NotificationsInteractor.swift */; };
847BD1E8298A806800076C90 /* NotificationsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 847BD1E3298A806800076C90 /* NotificationsView.swift */; };
847BD1EB298A87AB00076C90 /* SubscriptionsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 847BD1EA298A87AB00076C90 /* SubscriptionsViewModel.swift */; };
847CF3AF28E3141700F1D760 /* WalletConnectPush in Frameworks */ = {isa = PBXBuildFile; productRef = 847CF3AE28E3141700F1D760 /* WalletConnectPush */; settings = {ATTRIBUTES = (Required, ); }; };
847F08012A25DBFF00B2A5A4 /* XPlatformW3WTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 847F08002A25DBFF00B2A5A4 /* XPlatformW3WTests.swift */; };
8487A9442A836C2A0003D5AF /* Sentry in Frameworks */ = {isa = PBXBuildFile; productRef = 8487A9432A836C2A0003D5AF /* Sentry */; };
8487A9462A836C3F0003D5AF /* Sentry in Frameworks */ = {isa = PBXBuildFile; productRef = 8487A9452A836C3F0003D5AF /* Sentry */; };
8487A9482A83AD680003D5AF /* LoggingService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8487A9472A83AD680003D5AF /* LoggingService.swift */; };
84943C7B2A9BA206007EBAC2 /* Mixpanel in Frameworks */ = {isa = PBXBuildFile; productRef = 84943C7A2A9BA206007EBAC2 /* Mixpanel */; };
84943C7D2A9BA328007EBAC2 /* Mixpanel in Frameworks */ = {isa = PBXBuildFile; productRef = 84943C7C2A9BA328007EBAC2 /* Mixpanel */; };
84943C7F2A9BA48C007EBAC2 /* ProfilingService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84943C7E2A9BA48C007EBAC2 /* ProfilingService.swift */; };
849D7A93292E2169006A2BD4 /* NotifyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849D7A92292E2169006A2BD4 /* NotifyTests.swift */; };
84A6E3C32A386BBC008A0571 /* Publisher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84A6E3C22A386BBC008A0571 /* Publisher.swift */; };
84AA01DB28CF0CD7005D48D8 /* XCTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84AA01DA28CF0CD7005D48D8 /* XCTest.swift */; };
Expand Down Expand Up @@ -389,6 +391,7 @@
847F08002A25DBFF00B2A5A4 /* XPlatformW3WTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XPlatformW3WTests.swift; sourceTree = "<group>"; };
8487A92E2A7BD2F30003D5AF /* XPlatformProtocolTests.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; name = XPlatformProtocolTests.xctestplan; path = ../XPlatformProtocolTests.xctestplan; sourceTree = "<group>"; };
8487A9472A83AD680003D5AF /* LoggingService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggingService.swift; sourceTree = "<group>"; };
84943C7E2A9BA48C007EBAC2 /* ProfilingService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfilingService.swift; sourceTree = "<group>"; };
849A4F18298281E300E61ACE /* WalletAppRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = WalletAppRelease.entitlements; sourceTree = "<group>"; };
849A4F19298281F100E61ACE /* PNDecryptionServiceRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = PNDecryptionServiceRelease.entitlements; sourceTree = "<group>"; };
849D7A92292E2169006A2BD4 /* NotifyTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotifyTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -644,6 +647,7 @@
A54195A52934E83F0035AD19 /* Web3 in Frameworks */,
8487A9442A836C2A0003D5AF /* Sentry in Frameworks */,
A5D85228286333E300DAF5C3 /* Starscream in Frameworks */,
84943C7B2A9BA206007EBAC2 /* Mixpanel in Frameworks */,
A573C53929EC365000E3CBFD /* HDWalletKit in Frameworks */,
A5BB7FA328B6A50400707FC6 /* WalletConnectAuth in Frameworks */,
);
Expand Down Expand Up @@ -710,6 +714,7 @@
C56EE255293F569A004840D1 /* Starscream in Frameworks */,
A5B6C0F52A6EAB2800927332 /* WalletConnectNotify in Frameworks */,
C56EE27B293F56F8004840D1 /* WalletConnectAuth in Frameworks */,
84943C7D2A9BA328007EBAC2 /* Mixpanel in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1669,6 +1674,7 @@
84DB38F22983CDAE00BFEE37 /* PushRegisterer.swift */,
A51811972A52E21A00A52B15 /* ConfigurationService.swift */,
8487A9472A83AD680003D5AF /* LoggingService.swift */,
84943C7E2A9BA48C007EBAC2 /* ProfilingService.swift */,
);
path = ApplicationLayer;
sourceTree = "<group>";
Expand Down Expand Up @@ -1823,6 +1829,7 @@
CF25F28A2A432488009C7E49 /* WalletConnectModal */,
8487A9432A836C2A0003D5AF /* Sentry */,
A5B6C0F02A6EAB0800927332 /* WalletConnectNotify */,
84943C7A2A9BA206007EBAC2 /* Mixpanel */,
);
productName = DApp;
productReference = 84CE641C27981DED00142511 /* DApp.app */;
Expand Down Expand Up @@ -1948,6 +1955,7 @@
A573C53C29EC366500E3CBFD /* HDWalletKit */,
8487A9452A836C3F0003D5AF /* Sentry */,
A5B6C0F42A6EAB2800927332 /* WalletConnectNotify */,
84943C7C2A9BA328007EBAC2 /* Mixpanel */,
);
productName = ChatWallet;
productReference = C56EE21B293F55ED004840D1 /* WalletApp.app */;
Expand Down Expand Up @@ -2024,6 +2032,7 @@
A58EC60F299D57B800F3452A /* XCRemoteSwiftPackageReference "swiftui-async-button" */,
A561C7FE29DF32CE00DF540D /* XCRemoteSwiftPackageReference "HDWallet" */,
8487A9422A836C2A0003D5AF /* XCRemoteSwiftPackageReference "sentry-cocoa" */,
84943C792A9BA206007EBAC2 /* XCRemoteSwiftPackageReference "mixpanel-swift" */,
);
productRefGroup = 764E1D3D26F8D3FC00A1FB15 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -2374,6 +2383,7 @@
C5B2F6F929705293000DBA0E /* SessionRequestPresenter.swift in Sources */,
A57879712A4EDC8100F8D10B /* TextFieldView.swift in Sources */,
84DB38F32983CDAE00BFEE37 /* PushRegisterer.swift in Sources */,
84943C7F2A9BA48C007EBAC2 /* ProfilingService.swift in Sources */,
C5B2F6FB297055B0000DBA0E /* ETHSigner.swift in Sources */,
C56EE274293F56D7004840D1 /* SceneViewController.swift in Sources */,
847BD1E5298A806800076C90 /* NotificationsPresenter.swift in Sources */,
Expand Down Expand Up @@ -3105,6 +3115,14 @@
minimumVersion = 8.0.0;
};
};
84943C792A9BA206007EBAC2 /* XCRemoteSwiftPackageReference "mixpanel-swift" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/mixpanel/mixpanel-swift";
requirement = {
branch = master;
kind = branch;
};
};
A5434021291E6A270068F706 /* XCRemoteSwiftPackageReference "solana-swift" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/flypaper0/solana-swift";
Expand Down Expand Up @@ -3175,6 +3193,16 @@
package = 8487A9422A836C2A0003D5AF /* XCRemoteSwiftPackageReference "sentry-cocoa" */;
productName = Sentry;
};
84943C7A2A9BA206007EBAC2 /* Mixpanel */ = {
isa = XCSwiftPackageProductDependency;
package = 84943C792A9BA206007EBAC2 /* XCRemoteSwiftPackageReference "mixpanel-swift" */;
productName = Mixpanel;
};
84943C7C2A9BA328007EBAC2 /* Mixpanel */ = {
isa = XCSwiftPackageProductDependency;
package = 84943C792A9BA206007EBAC2 /* XCRemoteSwiftPackageReference "mixpanel-swift" */;
productName = Mixpanel;
};
84DDB4EC28ABB663003D66ED /* WalletConnectAuth */ = {
isa = XCSwiftPackageProductDependency;
productName = WalletConnectAuth;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@
"version": null
}
},
{
"package": "Mixpanel",
"repositoryURL": "https://github.com/mixpanel/mixpanel-swift",
"state": {
"branch": "master",
"revision": "1ce27d937009d5ecce74dad97d69898ffea49c75",
"version": null
}
},
{
"package": "PromiseKit",
"repositoryURL": "https://github.com/mxcl/PromiseKit.git",
Expand Down
114 changes: 53 additions & 61 deletions Example/IntegrationTests/Push/NotifyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import WalletConnectNetworking
import WalletConnectPush
@testable import WalletConnectNotify
@testable import WalletConnectPairing
@testable import WalletConnectSync
@testable import WalletConnectHistory
import WalletConnectIdentity
import WalletConnectSigner

Expand All @@ -22,8 +20,6 @@ final class NotifyTests: XCTestCase {

let gmDappUrl = "https://notify.gm.walletconnect.com/"

var pairingStorage: PairingStorage!

let pk = try! EthereumPrivateKey()

var privateKey: Data {
Expand All @@ -34,9 +30,9 @@ final class NotifyTests: XCTestCase {
return Account("eip155:1:" + pk.address.hex(eip55: true))!
}

private var publishers = [AnyCancellable]()
private var publishers = Set<AnyCancellable>()

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

Expand Down Expand Up @@ -64,28 +60,21 @@ final class NotifyTests: 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, syncClient, keychain, keyValueStorage)
return (pairingClient, networkingClient, keychain, keyValueStorage)
}

func makeWalletClients() {
let prefix = "🦋 Wallet: "
let (pairingClient, networkingInteractor, syncClient, keychain, keyValueStorage) = makeClientDependencies(prefix: prefix)
let (pairingClient, networkingInteractor, keychain, keyValueStorage) = makeClientDependencies(prefix: prefix)
let notifyLogger = ConsoleLogger(prefix: prefix + " [Notify]", loggingLevel: .debug)
walletPairingClient = pairingClient
let pushClient = PushClientFactory.create(projectId: "",
pushHost: "echo.walletconnect.com",
keychainStorage: keychain,
environment: .sandbox)
let keyserverURL = URL(string: "https://keys.walletconnect.com")!
let historyClient = HistoryClientFactory.create(
historyUrl: "https://history.walletconnect.com",
relayUrl: "wss://relay.walletconnect.com",
keychain: keychain
)
walletNotifyClient = NotifyClientFactory.create(keyserverURL: keyserverURL,
logger: notifyLogger,
keyValueStorage: keyValueStorage,
Expand All @@ -94,8 +83,6 @@ final class NotifyTests: XCTestCase {
networkInteractor: networkingInteractor,
pairingRegisterer: pairingClient,
pushClient: pushClient,
syncClient: syncClient,
historyClient: historyClient,
crypto: DefaultCryptoProvider())
}

Expand All @@ -106,15 +93,18 @@ final class NotifyTests: XCTestCase {
func testWalletCreatesSubscription() async {
let expectation = expectation(description: "expects to create notify subscription")
let metadata = AppMetadata(name: "GM Dapp", description: "", url: gmDappUrl, icons: [])

walletNotifyClient.newSubscriptionPublisher
.sink { [unowned self] subscription in
Task(priority: .high) {
try! await walletNotifyClient.deleteSubscription(topic: subscription.topic)
expectation.fulfill()
}
}.store(in: &publishers)

try! await walletNotifyClient.register(account: account, onSign: sign)
try! await walletNotifyClient.subscribe(metadata: metadata, account: account, onSign: sign)
walletNotifyClient.subscriptionsPublisher
.first()
.sink { [unowned self] subscriptions in
XCTAssertNotNil(subscriptions.first)
Task { try! await walletNotifyClient.deleteSubscription(topic: subscriptions.first!.topic) }
expectation.fulfill()
}.store(in: &publishers)

wait(for: [expectation], timeout: InputConfig.defaultTimeout)
}

Expand All @@ -124,55 +114,57 @@ final class NotifyTests: XCTestCase {
let updateScope: Set<String> = ["alerts"]
try! await walletNotifyClient.register(account: account, onSign: sign)
try! await walletNotifyClient.subscribe(metadata: metadata, account: account, onSign: sign)
walletNotifyClient.subscriptionsPublisher
.first()
.sink { [unowned self] subscriptions in
sleep(1)
Task { try! await walletNotifyClient.update(topic: subscriptions.first!.topic, scope: updateScope) }
walletNotifyClient.newSubscriptionPublisher
.sink { [unowned self] subscription in
Task(priority: .high) {
try! await walletNotifyClient.update(topic: subscription.topic, scope: updateScope)
}
}
.store(in: &publishers)

walletNotifyClient.updateSubscriptionPublisher
.sink { [unowned self] result in
guard case .success(let subscription) = result else { XCTFail(); return }
.sink { [unowned self] subscription in
let updatedScope = Set(subscription.scope.filter{ $0.value.enabled == true }.keys)
XCTAssertEqual(updatedScope, updateScope)
Task { try! await walletNotifyClient.deleteSubscription(topic: subscription.topic) }
expectation.fulfill()
Task(priority: .high) {
try! await walletNotifyClient.deleteSubscription(topic: subscription.topic)
expectation.fulfill()
}
}.store(in: &publishers)

wait(for: [expectation], timeout: InputConfig.defaultTimeout)
}

// func testNotifyServerSubscribeAndNotifies() async throws {
// let subscribeExpectation = expectation(description: "creates notify subscription")
// let messageExpectation = expectation(description: "receives a notify message")
// let notifyMessage = NotifyMessage.stub()
//
// let metadata = AppMetadata(name: "GM Dapp", description: "", url: gmDappUrl, icons: [])
// try! await walletNotifyClient.register(account: account, onSign: sign)
// try! await walletNotifyClient.subscribe(metadata: metadata, account: account, onSign: sign)
// var subscription: NotifySubscription!
// walletNotifyClient.subscriptionsPublisher
// .first()
// .sink { subscriptions in
// XCTAssertNotNil(subscriptions.first)
// subscribeExpectation.fulfill()
// subscription = subscriptions.first!
// let notifier = Publisher()
// sleep(5)
// Task(priority: .high) { try await notifier.notify(topic: subscriptions.first!.topic, account: subscriptions.first!.account, message: notifyMessage) }
// }.store(in: &publishers)
// walletNotifyClient.notifyMessagePublisher
// .sink { notifyMessageRecord in
// XCTAssertEqual(notifyMessage, notifyMessageRecord.message)
// messageExpectation.fulfill()
// }.store(in: &publishers)
//
// wait(for: [subscribeExpectation, messageExpectation], timeout: InputConfig.defaultTimeout)
// try await walletNotifyClient.deleteSubscription(topic: subscription.topic)
// }
func testNotifyServerSubscribeAndNotifies() async throws {
let subscribeExpectation = expectation(description: "creates notify subscription")
let messageExpectation = expectation(description: "receives a notify message")
let notifyMessage = NotifyMessage.stub()

let metadata = AppMetadata(name: "GM Dapp", description: "", url: gmDappUrl, icons: [])
try! await walletNotifyClient.register(account: account, onSign: sign)
try! await walletNotifyClient.subscribe(metadata: metadata, account: account, onSign: sign)

walletNotifyClient.newSubscriptionPublisher
.sink { subscription in
let notifier = Publisher()
Task(priority: .high) {
try await notifier.notify(topic: subscription.topic, account: subscription.account, message: notifyMessage)
subscribeExpectation.fulfill()
}
}.store(in: &publishers)

walletNotifyClient.notifyMessagePublisher
.sink { [unowned self] notifyMessageRecord in
XCTAssertEqual(notifyMessage, notifyMessageRecord.message)

Task(priority: .high) {
try await walletNotifyClient.deleteSubscription(topic: notifyMessageRecord.topic)
messageExpectation.fulfill()
}
}.store(in: &publishers)

wait(for: [subscribeExpectation, messageExpectation], timeout: InputConfig.defaultTimeout)
}
}


Expand Down
2 changes: 2 additions & 0 deletions Example/WalletApp/ApplicationLayer/ConfigurationService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ final class ConfigurationService {
crypto: DefaultCryptoProvider(),
onSign: importAccount.onSign
)
Web3Inbox.instance.setLogging(level: .debug)

if let clientId = try? Networking.interactor.getClientId() {
LoggingService.instance.setUpUser(account: importAccount.account.absoluteString, clientId: clientId)
ProfilingService.instance.setUpProfiling(account: importAccount.account.absoluteString, clientId: clientId)
}
LoggingService.instance.startLogging()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
import Foundation
import Sentry

struct ThirdPartyConfigurator: Configurator {

func configure() {
configureLogging()
}

func configureLogging() {
guard let sentryDsn = InputConfig.sentryDsn, !sentryDsn.isEmpty else { return }
SentrySDK.start { options in
options.dsn = "https://\(sentryDsn)"
// Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
// We recommend adjusting this value in production.
options.tracesSampleRate = 1.0
}
private func configureLogging() {
LoggingService.instance.configure()
}
}
Loading

0 comments on commit bd2e5b6

Please sign in to comment.