Skip to content

Commit

Permalink
Merge pull request WalletConnect#836 from WalletConnect/develop
Browse files Browse the repository at this point in the history
1.6.0
  • Loading branch information
llbartekll authored May 16, 2023
2 parents cd55d28 + 999c5db commit 3e23e95
Show file tree
Hide file tree
Showing 184 changed files with 2,615 additions and 323 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build_artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ on:
jobs:
build:
runs-on: macos-12
timeout-minutes: 15

steps:
- uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
test:
needs: prepare
runs-on: macos-12
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
Expand Down
20 changes: 11 additions & 9 deletions Example/DApp/Auth/AuthView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,39 @@ import SwiftUI
struct AuthView: View {

@ObservedObject var viewModel: AuthViewModel

var body: some View {
VStack(spacing: 16.0) {

Spacer()

Image(uiImage: viewModel.qrImage ?? UIImage())
.interpolation(.none)
.resizable()
.frame(width: 300, height: 300)

signingLabel()
.frame(maxWidth: .infinity)

Spacer()

Button("Connect Wallet", action: { })
.buttonStyle(CircleButtonStyle())

Button("Copy URI", action: { viewModel.copyDidPressed() })
.buttonStyle(CircleButtonStyle())

Button("Deeplink", action: { viewModel.deeplinkPressed() })
.buttonStyle(CircleButtonStyle())


}
.padding(16.0)
.onAppear { Task(priority: .userInitiated) {
try await viewModel.setupInitialState()
}}
}

@ViewBuilder
private func signingLabel() -> some View {
switch viewModel.state {
Expand Down
42 changes: 38 additions & 4 deletions Example/ExampleApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
84474A0129B9EB74005F520B /* Starscream in Frameworks */ = {isa = PBXBuildFile; productRef = 84474A0029B9EB74005F520B /* Starscream */; };
84474A0229B9ECA2005F520B /* DefaultSocketFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5629AEF2877F73000094373 /* DefaultSocketFactory.swift */; };
8448F1D427E4726F0000B866 /* WalletConnect in Frameworks */ = {isa = PBXBuildFile; productRef = 8448F1D327E4726F0000B866 /* WalletConnect */; };
84536D6E29EEAE1F008EA8DB /* Web3InboxModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84536D6D29EEAE1F008EA8DB /* Web3InboxModule.swift */; };
84536D7029EEAE28008EA8DB /* Web3InboxRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84536D6F29EEAE28008EA8DB /* Web3InboxRouter.swift */; };
84536D7229EEAE32008EA8DB /* Web3InboxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84536D7129EEAE32008EA8DB /* Web3InboxViewController.swift */; };
84536D7429EEBCF0008EA8DB /* Web3Inbox in Frameworks */ = {isa = PBXBuildFile; productRef = 84536D7329EEBCF0008EA8DB /* Web3Inbox */; };
845B8D8C2934B36C0084A966 /* Account.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845B8D8B2934B36C0084A966 /* Account.swift */; };
847BD1D62989492500076C90 /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 847BD1D12989492500076C90 /* MainViewController.swift */; };
847BD1D82989492500076C90 /* MainModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 847BD1D32989492500076C90 /* MainModule.swift */; };
Expand Down Expand Up @@ -272,6 +276,7 @@
CF1A594D29E5876600AAC16B /* App.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF1A594429E5876600AAC16B /* App.swift */; };
CF6704DF29E59DDC003326A4 /* XCUIElementQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF6704DE29E59DDC003326A4 /* XCUIElementQuery.swift */; };
CF6704E129E5A014003326A4 /* XCTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF6704E029E5A014003326A4 /* XCTestCase.swift */; };
CF9C7E4A2A01802F0037C006 /* Web3Modal in Frameworks */ = {isa = PBXBuildFile; productRef = CF9C7E492A01802F0037C006 /* Web3Modal */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -338,6 +343,9 @@
8439CB88293F658E00F2F2E2 /* PushMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PushMessage.swift; sourceTree = "<group>"; };
844749F329B9E5B9005F520B /* RelayIntegrationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RelayIntegrationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
844749F529B9E5B9005F520B /* RelayClientEndToEndTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelayClientEndToEndTests.swift; sourceTree = "<group>"; };
84536D6D29EEAE1F008EA8DB /* Web3InboxModule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Web3InboxModule.swift; sourceTree = "<group>"; };
84536D6F29EEAE28008EA8DB /* Web3InboxRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Web3InboxRouter.swift; sourceTree = "<group>"; };
84536D7129EEAE32008EA8DB /* Web3InboxViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Web3InboxViewController.swift; sourceTree = "<group>"; };
845AA7D929BA1EBA00F33739 /* IntegrationTests.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; name = IntegrationTests.xctestplan; path = ExampleApp.xcodeproj/IntegrationTests.xctestplan; sourceTree = "<group>"; };
845AA7DC29BB424800F33739 /* SmokeTests.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = SmokeTests.xctestplan; sourceTree = "<group>"; };
845B8D8B2934B36C0084A966 /* Account.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Account.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -611,6 +619,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
CF9C7E4A2A01802F0037C006 /* Web3Modal in Frameworks */,
A58EC618299D665A00F3452A /* Web3Inbox in Frameworks */,
A5629AEA2877F2D600094373 /* WalletConnectChat in Frameworks */,
A59FAEC928B7B93A002BB66F /* Web3 in Frameworks */,
Expand Down Expand Up @@ -647,6 +656,7 @@
files = (
C56EE27D293F56F8004840D1 /* WalletConnectChat in Frameworks */,
C5133A78294125CC00A8314C /* Web3 in Frameworks */,
84536D7429EEBCF0008EA8DB /* Web3Inbox in Frameworks */,
C5B2F7052970573D000DBA0E /* SolanaSwift in Frameworks */,
C55D349929630D440004314A /* Web3Wallet in Frameworks */,
84E6B85429787AAE00428BAF /* WalletConnectPush in Frameworks */,
Expand Down Expand Up @@ -730,6 +740,16 @@
path = RelayIntegrationTests;
sourceTree = "<group>";
};
84536D6C29EEAE0D008EA8DB /* Web3Inbox */ = {
isa = PBXGroup;
children = (
84536D6D29EEAE1F008EA8DB /* Web3InboxModule.swift */,
84536D6F29EEAE28008EA8DB /* Web3InboxRouter.swift */,
84536D7129EEAE32008EA8DB /* Web3InboxViewController.swift */,
);
path = Web3Inbox;
sourceTree = "<group>";
};
847BD1DB2989493F00076C90 /* Main */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1439,6 +1459,7 @@
C56EE229293F5668004840D1 /* Wallet */ = {
isa = PBXGroup;
children = (
84536D6C29EEAE0D008EA8DB /* Web3Inbox */,
847BD1DB2989493F00076C90 /* Main */,
C55D3477295DD4AA0004314A /* Welcome */,
C55D3474295DCB850004314A /* AuthRequest */,
Expand Down Expand Up @@ -1751,6 +1772,7 @@
A59FAEC828B7B93A002BB66F /* Web3 */,
A58EC610299D57B800F3452A /* AsyncButton */,
A58EC617299D665A00F3452A /* Web3Inbox */,
CF9C7E492A01802F0037C006 /* Web3Modal */,
);
productName = Showcase;
productReference = A58E7CE828729F550082D443 /* Showcase.app */;
Expand Down Expand Up @@ -1823,6 +1845,7 @@
C55D349829630D440004314A /* Web3Wallet */,
C5B2F7042970573D000DBA0E /* SolanaSwift */,
84E6B85329787AAE00428BAF /* WalletConnectPush */,
84536D7329EEBCF0008EA8DB /* Web3Inbox */,
);
productName = ChatWallet;
productReference = C56EE21B293F55ED004840D1 /* WalletApp.app */;
Expand Down Expand Up @@ -2165,6 +2188,8 @@
C55D34B12965FB750004314A /* SessionProposalInteractor.swift in Sources */,
C56EE247293F566D004840D1 /* ScanModule.swift in Sources */,
C56EE28D293F5757004840D1 /* AppearanceConfigurator.swift in Sources */,
84536D6E29EEAE1F008EA8DB /* Web3InboxModule.swift in Sources */,
84536D7029EEAE28008EA8DB /* Web3InboxRouter.swift in Sources */,
847BD1D82989492500076C90 /* MainModule.swift in Sources */,
847BD1E7298A806800076C90 /* NotificationsInteractor.swift in Sources */,
C56EE241293F566D004840D1 /* WalletModule.swift in Sources */,
Expand Down Expand Up @@ -2192,6 +2217,7 @@
C55D347F295DD7140004314A /* AuthRequestModule.swift in Sources */,
C56EE242293F566D004840D1 /* ScanPresenter.swift in Sources */,
C56EE28B293F5757004840D1 /* SceneDelegate.swift in Sources */,
84536D7229EEAE32008EA8DB /* Web3InboxViewController.swift in Sources */,
C56EE276293F56D7004840D1 /* UIViewController.swift in Sources */,
C56EE275293F56D7004840D1 /* InputConfig.swift in Sources */,
C55D3493295DFA750004314A /* WelcomeModule.swift in Sources */,
Expand Down Expand Up @@ -2369,7 +2395,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -2427,7 +2453,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = NO;
Expand Down Expand Up @@ -2494,7 +2520,7 @@
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = UIInterfaceOrientationPortrait;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -2528,7 +2554,7 @@
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = UIInterfaceOrientationPortrait;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -3001,6 +3027,10 @@
isa = XCSwiftPackageProductDependency;
productName = WalletConnect;
};
84536D7329EEBCF0008EA8DB /* Web3Inbox */ = {
isa = XCSwiftPackageProductDependency;
productName = Web3Inbox;
};
847CF3AE28E3141700F1D760 /* WalletConnectPush */ = {
isa = XCSwiftPackageProductDependency;
productName = WalletConnectPush;
Expand Down Expand Up @@ -3111,6 +3141,10 @@
isa = XCSwiftPackageProductDependency;
productName = Web3Wallet;
};
CF9C7E492A01802F0037C006 /* Web3Modal */ = {
isa = XCSwiftPackageProductDependency;
productName = Web3Modal;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 764E1D3426F8D3FC00A1FB15 /* Project object */;
Expand Down
13 changes: 7 additions & 6 deletions Example/IntegrationTests/Auth/AuthTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Combine
@testable import Auth
import WalletConnectPairing
import WalletConnectNetworking
import WalletConnectVerify

final class AuthTests: XCTestCase {
var appPairingClient: PairingClient!
Expand Down Expand Up @@ -86,9 +87,9 @@ final class AuthTests: XCTestCase {
Task(priority: .high) {
let signerFactory = DefaultSignerFactory()
let signer = MessageSignerFactory(signerFactory: signerFactory).create(projectId: InputConfig.projectId)
let payload = try! request.payload.cacaoPayload(address: walletAccount.address)
let payload = try! request.0.payload.cacaoPayload(address: walletAccount.address)
let signature = try! signer.sign(payload: payload, privateKey: prvKey, type: .eip191)
try! await walletAuthClient.respond(requestId: request.id, signature: signature, from: walletAccount)
try! await walletAuthClient.respond(requestId: request.0.id, signature: signature, from: walletAccount)
}
}
.store(in: &publishers)
Expand Down Expand Up @@ -123,7 +124,7 @@ final class AuthTests: XCTestCase {
walletAuthClient.authRequestPublisher.sink { [unowned self] request in
Task(priority: .high) {
let signature = CacaoSignature(t: .eip1271, s: eip1271Signature)
try! await walletAuthClient.respond(requestId: request.id, signature: signature, from: account)
try! await walletAuthClient.respond(requestId: request.0.id, signature: signature, from: account)
}
}
.store(in: &publishers)
Expand All @@ -144,7 +145,7 @@ final class AuthTests: XCTestCase {
walletAuthClient.authRequestPublisher.sink { [unowned self] request in
Task(priority: .high) {
let signature = CacaoSignature(t: .eip1271, s: eip1271Signature)
try! await walletAuthClient.respond(requestId: request.id, signature: signature, from: walletAccount)
try! await walletAuthClient.respond(requestId: request.0.id, signature: signature, from: walletAccount)
}
}
.store(in: &publishers)
Expand All @@ -164,7 +165,7 @@ final class AuthTests: XCTestCase {
try! await walletPairingClient.pair(uri: uri)
walletAuthClient.authRequestPublisher.sink { [unowned self] request in
Task(priority: .high) {
try! await walletAuthClient.reject(requestId: request.id)
try! await walletAuthClient.reject(requestId: request.0.id)
}
}
.store(in: &publishers)
Expand All @@ -187,7 +188,7 @@ final class AuthTests: XCTestCase {
Task(priority: .high) {
let invalidSignature = "438effc459956b57fcd9f3dac6c675f9cee88abf21acab7305e8e32aa0303a883b06dcbd956279a7a2ca21ffa882ff55cc22e8ab8ec0f3fe90ab45f306938cfa1b"
let cacaoSignature = CacaoSignature(t: .eip191, s: invalidSignature)
try! await walletAuthClient.respond(requestId: request.id, signature: cacaoSignature, from: walletAccount)
try! await walletAuthClient.respond(requestId: request.0.id, signature: cacaoSignature, from: walletAccount)
}
}
.store(in: &publishers)
Expand Down
45 changes: 44 additions & 1 deletion Example/IntegrationTests/Push/PushTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,50 @@ final class PushTests: XCTestCase {
wait(for: [expectation], timeout: InputConfig.defaultTimeout)
}

private func sign(_ message: String) -> SigningResult {
// Push Subscribe
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)
walletPushClient.subscriptionsPublisher
.first()
.sink { [unowned self] subscriptions in
XCTAssertNotNil(subscriptions.first)
Task { try! await walletPushClient.deleteSubscription(topic: subscriptions.first!.topic) }
expectation.fulfill()
}.store(in: &publishers)
wait(for: [expectation], timeout: InputConfig.defaultTimeout)
}

func testWalletCreatesAndUpdatesSubscription() async {
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<NotificationScope> = [NotificationScope.alerts]
try! await walletPushClient.subscribe(metadata: metadata, account: Account.stub(), onSign: sign)
walletPushClient.subscriptionsPublisher
.first()
.sink { [unowned self] subscriptions in
Task { try! await walletPushClient.update(topic: subscriptions.first!.topic, scope: updateScope) }
}
.store(in: &publishers)

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

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

}


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
8 changes: 4 additions & 4 deletions Example/IntegrationTests/Sign/Helpers/ClientDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ class ClientDelegate {
self.onConnected?()
}.store(in: &publishers)

client.sessionProposalPublisher.sink { proposal in
self.onSessionProposal?(proposal)
client.sessionProposalPublisher.sink { result in
self.onSessionProposal?(result.proposal)
}.store(in: &publishers)

client.sessionRequestPublisher.sink { request in
self.onSessionRequest?(request)
client.sessionRequestPublisher.sink { result in
self.onSessionRequest?(result.request)
}.store(in: &publishers)

client.sessionResponsePublisher.sink { response in
Expand Down
2 changes: 1 addition & 1 deletion Example/IntegrationTests/Sign/SignClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ final class SignClientTests: XCTestCase {
let uri = try await dapp.client.connect(requiredNamespaces: requiredNamespaces)!
try await wallet.client.pair(uri: uri)

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

func testSessionRequest() async throws {
Expand Down
2 changes: 1 addition & 1 deletion Example/IntegrationTests/Stubs/PushMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import WalletConnectPush

extension PushMessage {
static func stub() -> PushMessage {
return PushMessage(title: "test_push_message", body: "", icon: "", url: "")
return PushMessage(title: "test_push_message", body: "", icon: "", url: "", type: "")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import WalletConnectChat
final class ChatListRouter {

weak var viewController: UIViewController!

private let app: Application

init(app: Application) {
Expand Down Expand Up @@ -33,3 +33,4 @@ final class ChatListRouter {
WelcomeModule.create(app: app).present()
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class Web3InboxViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

Web3Inbox.configure(account: importAccount.account, onSign: onSing)
Web3Inbox.configure(account: importAccount.account, config: [.pushEnabled: false], onSign: onSing, environment: .sandbox)

edgesForExtendedLayout = []
navigationItem.title = "Web3Inbox SDK"
Expand Down
Loading

0 comments on commit 3e23e95

Please sign in to comment.