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

Monorepo #9

Merged
merged 15 commits into from
Sep 16, 2024
2 changes: 1 addition & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:

- name: Lint CocoaPods
run: |
pod lib lint --verbose --no-clean --quick --allow-warnings --platforms=ios WalletConnectSwiftV2.podspec
pod lib lint --verbose --no-clean --quick --allow-warnings --platforms=ios reown-swift.podspec
21 changes: 6 additions & 15 deletions Example/ExampleApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2343,11 +2343,9 @@
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CODE_SIGN_ENTITLEMENTS = DApp/DApp.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 184;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = W5R8AG9K22;
DEVELOPMENT_TEAM = W5R8AG9K22;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = DApp/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = dApp;
Expand All @@ -2367,7 +2365,6 @@
PRODUCT_BUNDLE_IDENTIFIER = com.walletconnect.dapp;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "match AppStore com.walletconnect.dapp";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down Expand Up @@ -2419,11 +2416,9 @@
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CODE_SIGN_ENTITLEMENTS = PNDecryptionService/PNDecryptionService.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 184;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = W5R8AG9K22;
DEVELOPMENT_TEAM = W5R8AG9K22;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = PNDecryptionService/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = PNDecryptionService;
Expand All @@ -2438,7 +2433,6 @@
PRODUCT_BUNDLE_IDENTIFIER = com.walletconnect.walletapp.PNDecryptionService;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "match AppStore com.walletconnect.walletapp.PNDecryptionService";
SKIP_INSTALL = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
Expand Down Expand Up @@ -2564,11 +2558,9 @@
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CODE_SIGN_ENTITLEMENTS = WalletApp/WalletApp.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 184;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = W5R8AG9K22;
DEVELOPMENT_TEAM = W5R8AG9K22;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = WalletApp/Other/Info.plist;
Expand All @@ -2587,7 +2579,6 @@
PRODUCT_BUNDLE_IDENTIFIER = com.walletconnect.walletapp;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "match AppStore com.walletconnect.walletapp";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
6 changes: 6 additions & 0 deletions Example/IntegrationTests/Sign/SignClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,14 @@ final class SignClientTests: XCTestCase {
}

override func tearDown() {
// Synchronously wait for 0.1 seconds
Thread.sleep(forTimeInterval: 0.1)

// Now set properties to nil
dapp = nil
wallet = nil

super.tearDown() // Ensure superclass tearDown is called
}

func testSessionPropose() async throws {
Expand Down
7 changes: 6 additions & 1 deletion Example/RelayIntegrationTests/RelayClientEndToEndTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ final class RelayClientEndToEndTests: XCTestCase {
)

let socketStatusProvider = SocketStatusProvider(socket: socket, logger: logger)
let socketConnectionHandler = AutomaticSocketConnectionHandler(socket: socket, subscriptionsTracker: SubscriptionsTracker(), logger: logger, socketStatusProvider: socketStatusProvider)
let socketConnectionHandler = AutomaticSocketConnectionHandler(socket: socket, subscriptionsTracker: SubscriptionsTracker(logger: logger), logger: logger, socketStatusProvider: socketStatusProvider)
let dispatcher = Dispatcher(
socketFactory: webSocketFactory,
relayUrlFactory: urlFactory,
Expand All @@ -80,6 +80,11 @@ final class RelayClientEndToEndTests: XCTestCase {
return relayClient
}

override func tearDown() {
Thread.sleep(forTimeInterval: 0.3)
super.tearDown()
}

func testSubscribe() {
let relayClient = makeRelayClient(prefix: "")

Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import PackageDescription

let package = Package(
name: "WalletConnect",
name: "reown",
platforms: [
.iOS(.v13),
.macOS(.v11),
Expand Down
2 changes: 1 addition & 1 deletion Sources/ReownAppKit/Core/AppKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class AppKit {
return "swift-\(version)"
}()

static let sdkType = "w3m"
static let sdkType = "appkit"

let projectId: String
var metadata: AppMetadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Foundation

actor WalletPairService {
enum Errors: Error {
case noPendingRequestsForPairing(topic: String)
case networkNotConnected
}

Expand Down Expand Up @@ -70,13 +71,15 @@ extension WalletPairService {
guard let pairing = pairingStorage.getPairing(forTopic: topic), pairing.requestReceived else {
return false
}

let pendingRequests = history.getPending()
.compactMap { record -> RPCRequest? in
(record.topic == pairing.topic) ? record.request : nil
}

guard !pendingRequests.isEmpty else { return false }
guard !pendingRequests.isEmpty else {
throw Errors.noPendingRequestsForPairing(topic: topic)
}
pendingRequests.forEach { request in
eventsClient.saveTraceEvent(PairingExecutionTraceEvents.emitSessionProposal)
networkingInteractor.handleHistoryRequest(topic: topic, request: request)
Expand All @@ -103,6 +106,7 @@ extension WalletPairService {
extension WalletPairService.Errors: LocalizedError {
var errorDescription: String? {
switch self {
case .noPendingRequestsForPairing(let topic): return "No pending requests for pairing, topic: \(topic)"
case .networkNotConnected: return "Pairing failed. You seem to be offline"
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/WalletConnectRelay/BundleFinder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ private class BundleFinder {}
extension Foundation.Bundle {
/// Returns the resource bundle associated with the current Swift module.
static var resourceBundle: Bundle = {
let bundleName = "WalletConnect_WalletConnectRelay"
let bundleName = "reown_WalletConnectRelay"

let candidates = [
// Bundle should be present here when the package is linked into an App.
Expand Down
5 changes: 5 additions & 0 deletions Sources/WalletConnectRelay/Dispatching.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,26 @@ final class Dispatcher: NSObject, Dispatching {
}

func protectedSend(_ string: String, completion: @escaping (Error?) -> Void) {
logger.debug("will try to send a socket frame")
// Check if the socket is already connected and ready to send
if socket.isConnected && networkMonitor.isConnected {
logger.debug("sending a socket frame")
send(string, completion: completion)
return
}

logger.debug("Socket is not connected, will try to connect to send a frame")
// Start the connection process if not already connected
Task {
do {
// Await the connection handler to establish the connection
try await socketConnectionHandler.handleInternalConnect()

logger.debug("internal connect successful, will try to send a socket frame")
// If successful, send the message
send(string, completion: completion)
} catch {
logger.debug("failed to handle internal connect")
// If an error occurs during connection, complete with that error
completion(error)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/WalletConnectRelay/RelayClientFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public struct RelayClientFactory {
if let bundleId = Bundle.main.bundleIdentifier {
socket.request.addValue(bundleId, forHTTPHeaderField: "Origin")
}
let subscriptionsTracker = SubscriptionsTracker()
let subscriptionsTracker = SubscriptionsTracker(logger: logger)

let socketStatusProvider = SocketStatusProvider(socket: socket, logger: logger)
var socketConnectionHandler: SocketConnectionHandler!
Expand Down
Loading
Loading