Skip to content

Commit

Permalink
Merge pull request #1197 from WalletConnect/develop
Browse files Browse the repository at this point in the history
1.9.1
  • Loading branch information
flypaper0 authored Oct 24, 2023
2 parents 99e12a7 + 6c7c129 commit f22bcf4
Show file tree
Hide file tree
Showing 30 changed files with 358 additions and 31 deletions.
14 changes: 9 additions & 5 deletions .github/actions/run_tests_without_building/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ inputs:
required: false
default: 'relay.walletconnect.com'
notify-endpoint:
description: 'The endpoint of the notify server e.g. cast.walletconnect.com'
description: 'The endpoint of the notify server e.g. notify.walletconnect.com'
required: false
default: 'cast.walletconnect.com'
default: 'notify.walletconnect.com'
explorer-endpoint:
description: 'The endpoint of the explorer server e.g. explorer-api.walletconnect.com'
required: false
default: 'explorer-api.walletconnect.com'
project-id:
description: 'WalletConnect project id'
required: true
Expand Down Expand Up @@ -59,13 +63,13 @@ runs:
- name: Run integration tests
if: inputs.type == 'integration-tests'
shell: bash
run: make integration_tests RELAY_HOST=${{ inputs.relay-endpoint }} PROJECT_ID=${{ inputs.project-id }} CAST_HOST=${{ inputs.notify-endpoint }} GM_DAPP_PROJECT_ID=${{ inputs.gm-dapp-project-id }} GM_DAPP_PROJECT_SECRET=${{ inputs.gm-dapp-project-secret }} GM_DAPP_HOST=${{ inputs.gm-dapp-host }} JS_CLIENT_API_HOST=${{ inputs.js-client-api-host }}
run: make integration_tests RELAY_HOST=${{ inputs.relay-endpoint }} PROJECT_ID=${{ inputs.project-id }} CAST_HOST=${{ inputs.notify-endpoint }} EXPLORER_HOST=${{ inputs.explorer-endpoint }} GM_DAPP_PROJECT_ID=${{ inputs.gm-dapp-project-id }} GM_DAPP_PROJECT_SECRET=${{ inputs.gm-dapp-project-secret }} GM_DAPP_HOST=${{ inputs.gm-dapp-host }} JS_CLIENT_API_HOST=${{ inputs.js-client-api-host }}

# Relay Integration tests
- name: Run Relay integration tests
if: inputs.type == 'relay-tests'
shell: bash
run: make relay_tests RELAY_HOST=${{ inputs.relay-endpoint }} PROJECT_ID=${{ inputs.project-id }} CAST_HOST=${{ inputs.notify-endpoint }}
run: make relay_tests RELAY_HOST=${{ inputs.relay-endpoint }} PROJECT_ID=${{ inputs.project-id }} CAST_HOST=${{ inputs.notify-endpoint }} EXPLORER_HOST=${{ inputs.explorer-endpoint }}

# Smoke tests
- name: Run smoke tests
Expand All @@ -77,7 +81,7 @@ runs:
- name: Run notify tests
if: inputs.type == 'notify-tests'
shell: bash
run: make notify_tests RELAY_HOST=${{ inputs.relay-endpoint }} PROJECT_ID=${{ inputs.project-id }} CAST_HOST=${{ inputs.notify-endpoint }} GM_DAPP_PROJECT_ID=${{ inputs.gm-dapp-project-id }} GM_DAPP_PROJECT_SECRET=${{ inputs.gm-dapp-project-secret }} GM_DAPP_HOST=${{ inputs.gm-dapp-host }}
run: make notify_tests RELAY_HOST=${{ inputs.relay-endpoint }} PROJECT_ID=${{ inputs.project-id }} CAST_HOST=${{ inputs.notify-endpoint }} EXPLORER_HOST=${{ inputs.explorer-endpoint }} GM_DAPP_PROJECT_ID=${{ inputs.gm-dapp-project-id }} GM_DAPP_PROJECT_SECRET=${{ inputs.gm-dapp-project-secret }} GM_DAPP_HOST=${{ inputs.gm-dapp-host }}

- name: Run x-platform protocol tests
if: inputs.type == 'x-platform-protocol-tests'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
- name: Run integration tests
if: matrix.type == 'integration-tests'
shell: bash
run: make integration_tests RELAY_HOST=relay.walletconnect.com PROJECT_ID=${{ secrets.PROJECT_ID }} CAST_HOST=notify.walletconnect.com GM_DAPP_PROJECT_ID=${{ secrets.GM_DAPP_PROJECT_ID }} GM_DAPP_PROJECT_SECRET=${{ secrets.GM_DAPP_PROJECT_SECRET }} GM_DAPP_HOST=gm.walletconnect.com JS_CLIENT_API_HOST=test-automation-api.walletconnect.com
run: make integration_tests RELAY_HOST=relay.walletconnect.com PROJECT_ID=${{ secrets.PROJECT_ID }} CAST_HOST=notify.walletconnect.com EXPLORER_HOST=explorer-api.walletconnect.com GM_DAPP_PROJECT_ID=${{ secrets.GM_DAPP_PROJECT_ID }} GM_DAPP_PROJECT_SECRET=${{ secrets.GM_DAPP_PROJECT_SECRET }} GM_DAPP_HOST=gm.walletconnect.com JS_CLIENT_API_HOST=test-automation-api.walletconnect.com

# Relay Integration tests
- name: Run Relay integration tests
Expand Down
6 changes: 4 additions & 2 deletions Configuration.xcconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
RELAY_HOST = relay.walletconnect.com

CAST_HOST = notify.walletconnect.com

EXPLORER_HOST = explorer-api.walletconnect.com

// Uncomment next line and paste your project id. Get this on: https://cloud.walletconnect.com/sign-in
// PROJECT_ID = YOUR_PROJECT_ID

Expand All @@ -18,5 +22,3 @@ RELAY_HOST = relay.walletconnect.com
// WALLETAPP_SENTRY_DSN = WALLETAPP_SENTRY_DSN

// MIXPANEL_TOKEN = MIXPANEL_TOKEN

CAST_HOST = notify.walletconnect.com
4 changes: 4 additions & 0 deletions Example/ExampleApp.xcodeproj/IntegrationTests.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
"key" : "RELAY_HOST",
"value" : "$(RELAY_HOST)"
},
{
"key" : "EXPLORER_HOST",
"value" : "$(EXPLORER_HOST)"
},
{
"key" : "GM_DAPP_HOST",
"value" : "$(GM_DAPP_HOST)"
Expand Down
54 changes: 53 additions & 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 Expand Up @@ -305,6 +305,13 @@
C5F32A322954816C00A6476E /* ConnectionDetailsPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5F32A312954816C00A6476E /* ConnectionDetailsPresenter.swift */; };
C5F32A342954817600A6476E /* ConnectionDetailsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5F32A332954817600A6476E /* ConnectionDetailsView.swift */; };
C5F32A362954FE3C00A6476E /* Colors.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C5F32A352954FE3C00A6476E /* Colors.xcassets */; };
C5FFEA762ADD8956007282A2 /* BrowserModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5FFEA752ADD8956007282A2 /* BrowserModule.swift */; };
C5FFEA782ADD896E007282A2 /* BrowserPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5FFEA772ADD896E007282A2 /* BrowserPresenter.swift */; };
C5FFEA7A2ADD8974007282A2 /* BrowserRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5FFEA792ADD8974007282A2 /* BrowserRouter.swift */; };
C5FFEA7C2ADD897C007282A2 /* BrowserInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5FFEA7B2ADD897C007282A2 /* BrowserInteractor.swift */; };
C5FFEA7E2ADD8985007282A2 /* BrowserView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5FFEA7D2ADD8985007282A2 /* BrowserView.swift */; };
C5FFEA812ADDACD7007282A2 /* WebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5FFEA802ADDACD7007282A2 /* WebView.swift */; };
C5FFEA842ADDAD6D007282A2 /* SafariViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5FFEA832ADDAD6D007282A2 /* SafariViewController.swift */; };
CF1A594529E5876600AAC16B /* XCUIElement.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF1A593A29E5876600AAC16B /* XCUIElement.swift */; };
CF1A594629E5876600AAC16B /* PushNotificationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF1A593C29E5876600AAC16B /* PushNotificationTests.swift */; };
CF1A594829E5876600AAC16B /* Engine.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF1A593F29E5876600AAC16B /* Engine.swift */; };
Expand Down Expand Up @@ -634,6 +641,13 @@
C5F32A312954816C00A6476E /* ConnectionDetailsPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionDetailsPresenter.swift; sourceTree = "<group>"; };
C5F32A332954817600A6476E /* ConnectionDetailsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionDetailsView.swift; sourceTree = "<group>"; };
C5F32A352954FE3C00A6476E /* Colors.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Colors.xcassets; sourceTree = "<group>"; };
C5FFEA752ADD8956007282A2 /* BrowserModule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrowserModule.swift; sourceTree = "<group>"; };
C5FFEA772ADD896E007282A2 /* BrowserPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrowserPresenter.swift; sourceTree = "<group>"; };
C5FFEA792ADD8974007282A2 /* BrowserRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrowserRouter.swift; sourceTree = "<group>"; };
C5FFEA7B2ADD897C007282A2 /* BrowserInteractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrowserInteractor.swift; sourceTree = "<group>"; };
C5FFEA7D2ADD8985007282A2 /* BrowserView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrowserView.swift; sourceTree = "<group>"; };
C5FFEA802ADDACD7007282A2 /* WebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebView.swift; sourceTree = "<group>"; };
C5FFEA832ADDAD6D007282A2 /* SafariViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariViewController.swift; sourceTree = "<group>"; };
CF1A593029E5873D00AAC16B /* EchoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = EchoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
CF1A593A29E5876600AAC16B /* XCUIElement.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XCUIElement.swift; sourceTree = "<group>"; };
CF1A593C29E5876600AAC16B /* PushNotificationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PushNotificationTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1606,6 +1620,7 @@
C56EE229293F5668004840D1 /* Wallet */ = {
isa = PBXGroup;
children = (
C5FFEA742ADD8942007282A2 /* Browser */,
A50D53BB2ABA053600A4FD8B /* NotifySettings */,
A51811992A52E82100A52B15 /* Settings */,
847BD1DB2989493F00076C90 /* Main */,
Expand Down Expand Up @@ -1799,6 +1814,36 @@
path = ConnectionDetails;
sourceTree = "<group>";
};
C5FFEA742ADD8942007282A2 /* Browser */ = {
isa = PBXGroup;
children = (
C5FFEA822ADDAD5B007282A2 /* SafariViewController */,
C5FFEA7F2ADDACCC007282A2 /* WebView */,
C5FFEA752ADD8956007282A2 /* BrowserModule.swift */,
C5FFEA772ADD896E007282A2 /* BrowserPresenter.swift */,
C5FFEA792ADD8974007282A2 /* BrowserRouter.swift */,
C5FFEA7B2ADD897C007282A2 /* BrowserInteractor.swift */,
C5FFEA7D2ADD8985007282A2 /* BrowserView.swift */,
);
path = Browser;
sourceTree = "<group>";
};
C5FFEA7F2ADDACCC007282A2 /* WebView */ = {
isa = PBXGroup;
children = (
C5FFEA802ADDACD7007282A2 /* WebView.swift */,
);
path = WebView;
sourceTree = "<group>";
};
C5FFEA822ADDAD5B007282A2 /* SafariViewController */ = {
isa = PBXGroup;
children = (
C5FFEA832ADDAD6D007282A2 /* SafariViewController.swift */,
);
path = SafariViewController;
sourceTree = "<group>";
};
CF1A593129E5873D00AAC16B /* EchoUITests */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -2384,6 +2429,7 @@
847BD1E4298A806800076C90 /* NotificationsModule.swift in Sources */,
C55D348C295DD8CA0004314A /* PasteUriInteractor.swift in Sources */,
847BD1D92989492500076C90 /* MainPresenter.swift in Sources */,
C5FFEA842ADDAD6D007282A2 /* SafariViewController.swift in Sources */,
C55D3497295DFA750004314A /* WelcomeView.swift in Sources */,
A57879722A4F225E00F8D10B /* ImportAccount.swift in Sources */,
C5B2F71029705827000DBA0E /* EthereumTransaction.swift in Sources */,
Expand Down Expand Up @@ -2415,6 +2461,7 @@
C56EE243293F566D004840D1 /* ScanView.swift in Sources */,
84310D05298BC980000C15B6 /* MainInteractor.swift in Sources */,
C56EE288293F5757004840D1 /* ThirdPartyConfigurator.swift in Sources */,
C5FFEA7E2ADD8985007282A2 /* BrowserView.swift in Sources */,
847BD1D62989492500076C90 /* MainViewController.swift in Sources */,
C5B2F6FA29705293000DBA0E /* SessionRequestInteractor.swift in Sources */,
C55D34AE2965FB750004314A /* SessionProposalModule.swift in Sources */,
Expand All @@ -2435,9 +2482,12 @@
A5B4F7C32ABB20AE0099AF7C /* SubscriptionInteractor.swift in Sources */,
A50D53C52ABA055700A4FD8B /* NotifyPreferencesView.swift in Sources */,
C56EE246293F566D004840D1 /* ScanRouter.swift in Sources */,
C5FFEA7A2ADD8974007282A2 /* BrowserRouter.swift in Sources */,
C55D3481295DD7140004314A /* AuthRequestRouter.swift in Sources */,
C5FFEA812ADDACD7007282A2 /* WebView.swift in Sources */,
C5B2F6F829705293000DBA0E /* SessionRequestView.swift in Sources */,
C56EE28C293F5757004840D1 /* Configurator.swift in Sources */,
C5FFEA782ADD896E007282A2 /* BrowserPresenter.swift in Sources */,
C55D3489295DD8CA0004314A /* PasteUriModule.swift in Sources */,
C55D3494295DFA750004314A /* WelcomePresenter.swift in Sources */,
C5B2F6F929705293000DBA0E /* SessionRequestPresenter.swift in Sources */,
Expand All @@ -2456,11 +2506,13 @@
C55D3496295DFA750004314A /* WelcomeInteractor.swift in Sources */,
C5B2F6FC297055B0000DBA0E /* SOLSigner.swift in Sources */,
A518119F2A52E83100A52B15 /* SettingsModule.swift in Sources */,
C5FFEA7C2ADD897C007282A2 /* BrowserInteractor.swift in Sources */,
8487A9482A83AD680003D5AF /* LoggingService.swift in Sources */,
C55D348D295DD8CA0004314A /* PasteUriView.swift in Sources */,
C5F32A2C2954814200A6476E /* ConnectionDetailsModule.swift in Sources */,
C56EE249293F566D004840D1 /* ScanInteractor.swift in Sources */,
C56EE28A293F5757004840D1 /* AppDelegate.swift in Sources */,
C5FFEA762ADD8956007282A2 /* BrowserModule.swift in Sources */,
C56EE2A3293F6BAF004840D1 /* UIPasteboardWrapper.swift in Sources */,
C5B2F6F629705293000DBA0E /* SessionRequestModule.swift in Sources */,
C56EE24E293F566D004840D1 /* WalletInteractor.swift in Sources */,
Expand Down
35 changes: 26 additions & 9 deletions Example/IntegrationTests/Push/NotifyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ final class NotifyTests: XCTestCase {
keychainStorage: keychain,
environment: .sandbox)
let keyserverURL = URL(string: "https://keys.walletconnect.com")!
let client = NotifyClientFactory.create(projectId: InputConfig.projectId,
// Note:- prod project_id do not exists on staging, we can use gmDappProjectId
let client = NotifyClientFactory.create(projectId: InputConfig.gmDappProjectId,
keyserverURL: keyserverURL,
logger: notifyLogger,
keyValueStorage: keyValueStorage,
Expand All @@ -84,7 +85,8 @@ final class NotifyTests: XCTestCase {
pairingRegisterer: pairingClient,
pushClient: pushClient,
crypto: DefaultCryptoProvider(),
notifyHost: InputConfig.notifyHost)
notifyHost: InputConfig.notifyHost,
explorerHost: InputConfig.explorerHost)
return client
}

Expand Down Expand Up @@ -152,19 +154,25 @@ final class NotifyTests: XCTestCase {

func testWalletCreatesAndUpdatesSubscription() async {
let expectation = expectation(description: "expects to create and update notify subscription")
let updateScope: Set<String> = ["8529aae8-cb26-4d49-922e-eb099044bebe"]
expectation.assertForOverFulfill = false

var updateScope: Set<String>!
var didUpdate = false

walletNotifyClientA.subscriptionsPublisher
.sink { [unowned self] subscriptions in
guard let subscription = subscriptions.first else { return }
guard
let subscription = subscriptions.first,
let scope = subscription.scope.keys.first
else { return }

let updatedScope = Set(subscription.scope.filter { $0.value.enabled == true }.keys)

if !didUpdate {
updateScope = Set([scope])
didUpdate = true
Task(priority: .high) {
try await walletNotifyClientA.update(topic: subscription.topic, scope: updateScope)
try await walletNotifyClientA.update(topic: subscription.topic, scope: Set([scope]))
}
}
if updateScope == updatedScope {
Expand All @@ -184,25 +192,34 @@ final class NotifyTests: XCTestCase {
func testNotifyServerSubscribeAndNotifies() async throws {
let subscribeExpectation = expectation(description: "creates notify subscription")
let messageExpectation = expectation(description: "receives a notify message")
let notifyMessage = NotifyMessage.stub(type: "8529aae8-cb26-4d49-922e-eb099044bebe")

var notifyMessage: NotifyMessage!

var didNotify = false
walletNotifyClientA.subscriptionsPublisher
.sink { subscriptions in
guard let subscription = subscriptions.first else { return }
guard
let subscription = subscriptions.first,
let scope = subscription.scope.keys.first
else { return }

let notifier = Publisher()
if !didNotify {
didNotify = true

let message = NotifyMessage.stub(type: scope)
notifyMessage = message

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

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

Task(priority: .high) {
try await walletNotifyClientA.deleteSubscription(topic: notifyMessageRecord.topic)
Expand Down
4 changes: 4 additions & 0 deletions Example/Shared/Tests/InputConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ struct InputConfig {
return config(for: "CAST_HOST")!
}

static var explorerHost: String {
return config(for: "EXPLORER_HOST")!
}

static var relayUrl: String {
return "wss://\(relayHost)"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
final class BrowserInteractor {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import SwiftUI

final class BrowserModule {
@discardableResult
static func create(app: Application) -> UIViewController {
let router = BrowserRouter(app: app)
let interactor = BrowserInteractor()
let presenter = BrowserPresenter(interactor: interactor, router: router)
let view = BrowserView().environmentObject(presenter)
let viewController = SceneViewController(viewModel: presenter, content: view)

router.viewController = viewController

return viewController
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import UIKit
import Combine
import WebKit

import WalletConnectNetworking

final class BrowserPresenter: ObservableObject {
private let interactor: BrowserInteractor
private let router: BrowserRouter

weak var webView: WKWebView?

@Published var urlString = "https://react-app.walletconnect.com"

private var disposeBag = Set<AnyCancellable>()

init(interactor: BrowserInteractor, router: BrowserRouter) {
defer { setupInitialState() }
self.interactor = interactor
self.router = router
}

func loadURLString() {
if let url = URL(string: urlString) {
webView?.load(URLRequest(url: url.sanitise))
}
}

func reload() {
webView?.reload()
}
}

// MARK: SceneViewModel
extension BrowserPresenter: SceneViewModel {
var sceneTitle: String? {
return "Browser"
}

var largeTitleDisplayMode: UINavigationItem.LargeTitleDisplayMode {
return .always
}
}

// MARK: Privates
private extension BrowserPresenter {
func setupInitialState() {

}
}

extension URL {
var sanitise: URL {
if var components = URLComponents(url: self, resolvingAgainstBaseURL: false) {
if components.scheme == nil {
components.scheme = "https"
}
return components.url ?? self
}
return self
}
}
Loading

0 comments on commit f22bcf4

Please sign in to comment.