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

Bugs fixes #55

Merged
merged 6 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let package = Package(
dependencies: [
.package(
url: "https://github.com/WalletConnect/WalletConnectSwiftV2",
from: "1.10.0"
from: "1.13.0"
),
.package(
url: "https://github.com/WalletConnect/QRCode",
Expand Down
31 changes: 21 additions & 10 deletions Sample/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/* Begin PBXBuildFile section */
23F6FD03919B41DE98CAFCD3 /* Sentry in Frameworks */ = {isa = PBXBuildFile; productRef = BD206AA550964C49AE94A3CA /* Sentry */; };
84D9CCC02B95C277001EDEE3 /* Starscream in Frameworks */ = {isa = PBXBuildFile; productRef = 84D9CCBF2B95C277001EDEE3 /* Starscream */; };
CF0BCCE52AB0886400A2866C /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF0BCCE42AB0886400A2866C /* ContentView.swift */; };
CF25F3A22B40C7070030B3DC /* Web3Modal in Frameworks */ = {isa = PBXBuildFile; productRef = CF25F3A12B40C7070030B3DC /* Web3Modal */; };
CF25F3A42B40C7070030B3DC /* Web3ModalUI in Frameworks */ = {isa = PBXBuildFile; productRef = CF25F3A32B40C7070030B3DC /* Web3ModalUI */; };
Expand Down Expand Up @@ -43,6 +44,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
84D9CCC02B95C277001EDEE3 /* Starscream in Frameworks */,
CF3B9AD02ACDBA3A00984D53 /* Web3Modal in Frameworks */,
CFD6A70F2ADE8DE2002B402C /* Atlantis in Frameworks */,
CF25F3A42B40C7070030B3DC /* Web3ModalUI in Frameworks */,
Expand Down Expand Up @@ -130,6 +132,7 @@
BD206AA550964C49AE94A3CA /* Sentry */,
CF25F3A12B40C7070030B3DC /* Web3Modal */,
CF25F3A32B40C7070030B3DC /* Web3ModalUI */,
84D9CCBF2B95C277001EDEE3 /* Starscream */,
);
productName = Example;
productReference = CFD720742A9CC60600636CAF /* Example.app */;
Expand Down Expand Up @@ -163,6 +166,7 @@
CFD6A70D2ADE8DE2002B402C /* XCRemoteSwiftPackageReference "atlantis" */,
CF25F3A02B40C7070030B3DC /* XCLocalSwiftPackageReference ".." */,
F4A0329B6CFF49E682D3DFE7 /* XCRemoteSwiftPackageReference "sentry-cocoa" */,
84D9CCBE2B95C277001EDEE3 /* XCRemoteSwiftPackageReference "Starscream" */,
);
productRefGroup = CFD720752A9CC60600636CAF /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -347,14 +351,12 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = Example/Example.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 16;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_ASSET_PATHS = "\"Example/Preview Content\"";
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = W5R8AG9K22;
DEVELOPMENT_TEAM = W5R8AG9K22;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -381,7 +383,6 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROJECT_ID = "$(PROJECT_ID)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "match AppStore com.walletconnect.web3modal.sample";
SDKROOT = auto;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
Expand All @@ -399,14 +400,12 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = Example/Example.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 16;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_ASSET_PATHS = "\"Example/Preview Content\"";
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = W5R8AG9K22;
DEVELOPMENT_TEAM = W5R8AG9K22;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -433,7 +432,6 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROJECT_ID = "$(PROJECT_ID)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "match AppStore com.walletconnect.web3modal.sample";
SDKROOT = auto;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
Expand Down Expand Up @@ -474,6 +472,14 @@
/* End XCLocalSwiftPackageReference section */

/* Begin XCRemoteSwiftPackageReference section */
84D9CCBE2B95C277001EDEE3 /* XCRemoteSwiftPackageReference "Starscream" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/daltoniam/Starscream";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 3.1.2;
};
};
CFD6A70D2ADE8DE2002B402C /* XCRemoteSwiftPackageReference "atlantis" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/ProxymanApp/atlantis";
Expand All @@ -493,6 +499,11 @@
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
84D9CCBF2B95C277001EDEE3 /* Starscream */ = {
isa = XCSwiftPackageProductDependency;
package = 84D9CCBE2B95C277001EDEE3 /* XCRemoteSwiftPackageReference "Starscream" */;
productName = Starscream;
};
BD206AA550964C49AE94A3CA /* Sentry */ = {
isa = XCSwiftPackageProductDependency;
package = F4A0329B6CFF49E682D3DFE7 /* XCRemoteSwiftPackageReference "sentry-cocoa" */;
Expand Down
17 changes: 7 additions & 10 deletions Sample/Example/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import Web3Modal

struct ContentView: View {
@State var showUIComponents: Bool = false
@State var socketConnected: Bool = false

@EnvironmentObject var socketConnectionManager: SocketConnectionManager


var body: some View {
NavigationView {
VStack {
Expand Down Expand Up @@ -32,19 +33,15 @@ struct ContentView: View {
.overlay(
HStack {
Circle()
.fill(socketConnected ? Color.Success100 : Color.Error100)
.fill(socketConnectionManager.socketConnected ? Color.Success100 : Color.Error100)
.frame(width: 10, height: 10)
Text("Socket \(socketConnected ? "Connected" : "Disconnected")")

Text("Socket \(socketConnectionManager.socketConnected ? "Connected" : "Disconnected")")
.font(.system(size: 12, weight: .semibold))
.foregroundColor(socketConnected ? Color.Success100 : Color.Error100)
.foregroundColor(socketConnectionManager.socketConnected ? Color.Success100 : Color.Error100)
},
alignment: .top
)
.onReceive(Web3Modal.instance.socketConnectionStatusPublisher, perform: { status in
socketConnected = status == .connected
print("🧦 \(status)")
})
}
}

Expand Down
35 changes: 27 additions & 8 deletions Sample/Example/ExampleApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@ import Web3Modal
import Atlantis
#endif


class SocketConnectionManager: ObservableObject {
@Published var socketConnected: Bool = false
}

@main
struct ExampleApp: App {
class ExampleApp: App {
private var disposeBag = Set<AnyCancellable>()
private var socketConnectionManager = SocketConnectionManager()


@State var alertMessage: String = ""

init() {
required init() {
#if DEBUG
Atlantis.start()
#endif
Expand Down Expand Up @@ -44,7 +51,7 @@ struct ExampleApp: App {
Networking.configure(
groupIdentifier: "group.com.walletconnect.web3modal",
projectId: projectId,
socketFactory: WalletConnectSocketClientFactory()
socketFactory: DefaultSocketFactory()
)

Web3Modal.configure(
Expand All @@ -65,19 +72,31 @@ struct ExampleApp: App {

print(error)
}
setup()

}

func setup() {
Web3Modal.instance.socketConnectionStatusPublisher.receive(on: DispatchQueue.main).sink { [unowned self] status in
print("Socket connection status: \(status)")
self.socketConnectionManager.socketConnected = (status == .connected)

}.store(in: &disposeBag)
Web3Modal.instance.logger.setLogging(level: .debug)
}

var body: some Scene {
WindowGroup {
WindowGroup { [unowned self] in
ContentView()
.environmentObject(socketConnectionManager)
.onOpenURL { url in
Web3Modal.instance.handleDeeplink(url)
}
.alert(
"Response",
isPresented: .init(
get: { !alertMessage.isEmpty },
set: { _ in alertMessage = "" }
get: { !self.alertMessage.isEmpty },
set: { _ in self.alertMessage = "" }
)
) {
Button("Dismiss", role: .cancel) {}
Expand All @@ -87,9 +106,9 @@ struct ExampleApp: App {
.onReceive(Web3Modal.instance.sessionResponsePublisher, perform: { response in
switch response.result {
case let .response(value):
alertMessage = "Session response: \(value.stringRepresentation)"
self.alertMessage = "Session response: \(value.stringRepresentation)"
case let .error(error):
alertMessage = "Session error: \(error)"
self.alertMessage = "Session error: \(error)"
}
})
}
Expand Down
Loading
Loading