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

Just works #1281

Merged
merged 112 commits into from
Jan 26, 2024
Merged
Changes from 1 commit
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
cc7a1f5
add pairingExpirationPublisher
llbartekll Jan 6, 2024
0f3a29d
fix build
llbartekll Jan 6, 2024
77c7472
remove loader on session request
llbartekll Jan 6, 2024
300ecea
remove loader on session proposal
llbartekll Jan 6, 2024
cc1ce09
Merge branch 'fix-dapp-keychain-socket-issue' of github.com:WalletCon…
llbartekll Jan 7, 2024
916b528
add expiry monitor for sequence store
llbartekll Jan 7, 2024
de0a0a0
add pairing state publisher
llbartekll Jan 7, 2024
6e07c1e
integrate pairing publisher
llbartekll Jan 7, 2024
aff3a8a
remove inactive pairing on reject
llbartekll Jan 7, 2024
6f70d10
activate pairing on request
llbartekll Jan 9, 2024
69d5781
fix build
llbartekll Jan 9, 2024
e71c6d7
add ActivityIndicatorManager
llbartekll Jan 9, 2024
e6553e5
add alert presenter
llbartekll Jan 9, 2024
7d01cc0
savepoint
llbartekll Jan 9, 2024
1aadaeb
present alert for w3w error messages
llbartekll Jan 9, 2024
b62568d
fix activity indicator manager
llbartekll Jan 9, 2024
abb4bd1
add dismiss button to session request screen
llbartekll Jan 9, 2024
adc4d0f
savepoint
llbartekll Jan 9, 2024
638bf76
add activity indicator on delete
llbartekll Jan 10, 2024
9be087e
fix request expiry logic
llbartekll Jan 10, 2024
c5dfdee
add ActivityIndicatorManager to a dapp
llbartekll Jan 10, 2024
51d81b2
savepoint
llbartekll Jan 10, 2024
399bdac
savepoint - add response view
llbartekll Jan 10, 2024
7dcf7db
add socket status to dapp
llbartekll Jan 10, 2024
1c497f7
display alert for sign errors
llbartekll Jan 11, 2024
095355d
fix tests, add namespaces test
llbartekll Jan 11, 2024
4f89222
remove url from client authenticator
llbartekll Jan 11, 2024
2218816
savepoint
llbartekll Jan 11, 2024
c244e8b
savepoint
llbartekll Jan 11, 2024
6fee695
present pairing expired message in a wallet
llbartekll Jan 11, 2024
f1b7da1
Add expiry to session proposal
llbartekll Jan 11, 2024
9feefe2
add backward compatibility tests for session proposal
llbartekll Jan 11, 2024
a45b70d
savepoint
llbartekll Jan 12, 2024
3f05c79
add ProposalExpiryWatcher
llbartekll Jan 12, 2024
185de33
savepoint
llbartekll Jan 12, 2024
91a7dff
reorganise stubs
llbartekll Jan 12, 2024
74bf429
update proposal expiry watcher
llbartekll Jan 12, 2024
a6a77f8
add localised description for errors
llbartekll Jan 12, 2024
e7f90aa
add dismiss button to proposal screen
llbartekll Jan 12, 2024
777cac9
add PendingProposalsProvider
llbartekll Jan 12, 2024
ee79af8
dismiss on session proposal expired
llbartekll Jan 12, 2024
82ef9aa
fix crash
llbartekll Jan 12, 2024
dc3ae63
remove pending proposals from history service
llbartekll Jan 12, 2024
2a6e7d0
remove tabbar from dapp
llbartekll Jan 15, 2024
cf10686
walletapp - fix session proposal dismiss on expiry
llbartekll Jan 15, 2024
94cea98
fix, present request screen when proposal still active
llbartekll Jan 15, 2024
f3cc074
revert session response small modal
llbartekll Jan 15, 2024
0e6b23c
revert activate pairing logic
llbartekll Jan 15, 2024
befdfab
change pairing state publisher logic
llbartekll Jan 15, 2024
ae36fa6
Add RequestsExpiryWatcher
llbartekll Jan 15, 2024
497cff6
expose request expiry publisher
llbartekll Jan 15, 2024
bc881ea
publish pairing state on change only
llbartekll Jan 15, 2024
dc3c972
dismiss request screen on expiry
llbartekll Jan 15, 2024
3606015
add alert on request expiry
llbartekll Jan 15, 2024
f325146
update Request and its tests
llbartekll Jan 16, 2024
9cbab48
remove the commented namespace test
llbartekll Jan 16, 2024
fd25d8a
Add check for empty session namespaces
llbartekll Jan 16, 2024
00d1080
add check for empty session namespaces
llbartekll Jan 16, 2024
3f50f72
add localised description for namespaces error
llbartekll Jan 16, 2024
94c2a02
savepoint
llbartekll Jan 16, 2024
69d4b4c
integrate loaders in a dapp
llbartekll Jan 16, 2024
53b760c
dapp - add alert on expired request
llbartekll Jan 16, 2024
2d77e48
update min expiry to 10 minutes
llbartekll Jan 17, 2024
8f76ed7
add padding to sing view list
llbartekll Jan 17, 2024
5a6f237
fix encoded uri parsing
llbartekll Jan 17, 2024
a38716c
fix tests build
llbartekll Jan 17, 2024
6482f1a
remove showcase garbage
llbartekll Jan 17, 2024
1a94a20
add loading view
llbartekll Jan 17, 2024
feeca0c
approve idempotency
llbartekll Jan 18, 2024
258b4e0
integrate relayack publish
llbartekll Jan 18, 2024
6530fdc
add more loaders
llbartekll Jan 18, 2024
330429b
change expiry to expiryTimestamp
llbartekll Jan 18, 2024
808b114
fix testSessionReject
llbartekll Jan 18, 2024
a93ba0b
change min ttl for request
llbartekll Jan 18, 2024
7680f68
add message when pairing takes too long
llbartekll Jan 18, 2024
ff1d34a
savepoint
llbartekll Jan 18, 2024
ff18241
Merge branch 'feature/rpc-delete-on-resolve' of github.com:WalletConn…
llbartekll Jan 18, 2024
ce65f53
Merge branch 'feature/rpc-delete-on-resolve' of github.com:WalletConn…
llbartekll Jan 19, 2024
d084975
refactor sign tests
llbartekll Jan 19, 2024
3b3ebcc
savepoint
llbartekll Jan 19, 2024
a25e2cf
Add expiry to pairing uri
llbartekll Jan 22, 2024
10cbba3
add deprecated uri init
llbartekll Jan 22, 2024
e20094f
fix crash
llbartekll Jan 22, 2024
97eb2d9
remove getSessionRequestRecord
llbartekll Jan 22, 2024
9eb7a3d
use expiry from uri in wcpairing
llbartekll Jan 22, 2024
f9dfc2b
Merge branch 'develop' of github.com:WalletConnect/WalletConnectSwift…
llbartekll Jan 22, 2024
f5dac53
not create a session when propose response fails
llbartekll Jan 22, 2024
5f8ab62
add localised description
llbartekll Jan 22, 2024
93d132c
dismiss proposal on pairing expiry
llbartekll Jan 22, 2024
bff243f
show alerts on pairing expiry
llbartekll Jan 22, 2024
abe3f15
savepoint
llbartekll Jan 23, 2024
bce0e68
refactor activityindicator
llbartekll Jan 23, 2024
9c2a9da
savepoint
llbartekll Jan 23, 2024
cd0f67f
add review suggestions
llbartekll Jan 23, 2024
5fdb29a
fix wc modal tests
llbartekll Jan 23, 2024
3e9b7fc
fix sign tests
llbartekll Jan 23, 2024
bb2f36d
fix compatibility issue
llbartekll Jan 23, 2024
a05be87
NetworkMonitor in Dispatcher
flypaper0 Jan 23, 2024
6489245
protectedSend logic fixed
flypaper0 Jan 23, 2024
8f54f0b
Integration tests repaired
flypaper0 Jan 23, 2024
ff5a895
Relayer tests updated
flypaper0 Jan 23, 2024
c8fd167
RelayClientEndToEndTests repaired
flypaper0 Jan 23, 2024
78f6fae
Merge branch 'develop' of github.com:WalletConnect/WalletConnectSwift…
llbartekll Jan 23, 2024
e05bce5
Update RelayClientEndToEndTests.swift
flypaper0 Jan 23, 2024
14cbe52
Unsubscribe optional completion
flypaper0 Jan 23, 2024
5774ada
RPCHistory cleanup on error
flypaper0 Jan 23, 2024
cbd7639
Merge branch 'feature/network-monitor-in-dispatcher' of github.com:Wa…
llbartekll Jan 24, 2024
39085d5
saveopint
llbartekll Jan 24, 2024
ce749eb
add alert on uri expired
llbartekll Jan 24, 2024
65aaf21
fix build
llbartekll Jan 24, 2024
ea96e8d
fix tests build
llbartekll Jan 24, 2024
2dce12f
remove dependency pairing dependency in notify
llbartekll Jan 24, 2024
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
Prev Previous commit
Next Next commit
NetworkMonitor in Dispatcher
  • Loading branch information
flypaper0 committed Jan 23, 2024
commit a05be877ef7a744bcb8dabc96cb573fb0620de76
5 changes: 1 addition & 4 deletions Sources/WalletConnectNetworking/NetworkingInteractor.swift
Original file line number Diff line number Diff line change
@@ -30,8 +30,6 @@ public class NetworkingInteractor: NetworkInteracting {
public var networkConnectionStatusPublisher: AnyPublisher<NetworkConnectionStatus, Never>
public var socketConnectionStatusPublisher: AnyPublisher<SocketConnectionStatus, Never>

private let networkMonitor: NetworkMonitoring

public init(
relayClient: RelayClient,
serializer: Serializing,
@@ -43,8 +41,7 @@ public class NetworkingInteractor: NetworkInteracting {
self.rpcHistory = rpcHistory
self.logger = logger
self.socketConnectionStatusPublisher = relayClient.socketConnectionStatusPublisher
self.networkMonitor = NetworkMonitor()
self.networkConnectionStatusPublisher = networkMonitor.networkConnectionStatusPublisher
self.networkConnectionStatusPublisher = relayClient.networkConnectionStatusPublisher
setupRelaySubscribtion()
}

16 changes: 12 additions & 4 deletions Sources/WalletConnectRelay/Dispatching.swift
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ import Combine

protocol Dispatching {
var onMessage: ((String) -> Void)? { get set }
var networkConnectionStatusPublisher: AnyPublisher<NetworkConnectionStatus, Never> { get }
var socketConnectionStatusPublisher: AnyPublisher<SocketConnectionStatus, Never> { get }
func send(_ string: String, completion: @escaping (Error?) -> Void)
func protectedSend(_ string: String, completion: @escaping (Error?) -> Void)
@@ -17,8 +18,9 @@ final class Dispatcher: NSObject, Dispatching {
var socketConnectionHandler: SocketConnectionHandler

private let relayUrlFactory: RelayUrlFactory
private let networkMonitor: NetworkMonitoring
private let logger: ConsoleLogging

private let defaultTimeout: Int = 5
/// The property is used to determine whether relay.walletconnect.org will be used
/// in case relay.walletconnect.com doesn't respond for some reason (most likely due to being blocked in the user's location).
@@ -30,15 +32,21 @@ final class Dispatcher: NSObject, Dispatching {
socketConnectionStatusPublisherSubject.eraseToAnyPublisher()
}

var networkConnectionStatusPublisher: AnyPublisher<NetworkConnectionStatus, Never> {
networkMonitor.networkConnectionStatusPublisher
}

private let concurrentQueue = DispatchQueue(label: "com.walletconnect.sdk.dispatcher", attributes: .concurrent)

init(
socketFactory: WebSocketFactory,
relayUrlFactory: RelayUrlFactory,
networkMonitor: NetworkMonitoring,
socketConnectionType: SocketConnectionType,
logger: ConsoleLogging
) {
self.relayUrlFactory = relayUrlFactory
self.networkMonitor = networkMonitor
self.logger = logger

let socket = socketFactory.create(with: relayUrlFactory.create(fallback: fallback))
@@ -69,13 +77,13 @@ final class Dispatcher: NSObject, Dispatching {
}

func protectedSend(_ string: String, completion: @escaping (Error?) -> Void) {
guard !socket.isConnected else {
guard !socket.isConnected, !networkMonitor.isConnected else {
return send(string, completion: completion)
}

var cancellable: AnyCancellable?
cancellable = socketConnectionStatusPublisher
.filter { $0 == .connected }
cancellable = Publishers.CombineLatest(socketConnectionStatusPublisher, networkConnectionStatusPublisher)
.filter { $0.0 == .connected && $0.1 == .connected }
.setFailureType(to: NetworkError.self)
.timeout(.seconds(defaultTimeout), scheduler: concurrentQueue, customError: { .webSocketNotConnected })
.sink(receiveCompletion: { [unowned self] result in
7 changes: 6 additions & 1 deletion Sources/WalletConnectRelay/NetworkMonitoring.swift
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ public enum NetworkConnectionStatus {
}

public protocol NetworkMonitoring: AnyObject {
var isConnected: Bool { get }
var networkConnectionStatusPublisher: AnyPublisher<NetworkConnectionStatus, Never> { get }
}

@@ -16,7 +17,11 @@ public final class NetworkMonitor: NetworkMonitoring {
private let workerQueue = DispatchQueue(label: "com.walletconnect.sdk.network.monitor")

private let networkConnectionStatusPublisherSubject = CurrentValueSubject<NetworkConnectionStatus, Never>(.connected)


public var isConnected: Bool {
return networkConnectionStatusPublisherSubject.value == .connected
}

public var networkConnectionStatusPublisher: AnyPublisher<NetworkConnectionStatus, Never> {
networkConnectionStatusPublisherSubject
.share()
4 changes: 4 additions & 0 deletions Sources/WalletConnectRelay/RelayClient.swift
Original file line number Diff line number Diff line change
@@ -27,6 +27,10 @@ public final class RelayClient {
dispatcher.socketConnectionStatusPublisher
}

public var networkConnectionStatusPublisher: AnyPublisher<NetworkConnectionStatus, Never> {
dispatcher.networkConnectionStatusPublisher
}

private let messagePublisherSubject = PassthroughSubject<(topic: String, message: String, publishedAt: Date), Never>()

private let subscriptionResponsePublisherSubject = PassthroughSubject<(RPCID?, [String]), Never>()
8 changes: 7 additions & 1 deletion Sources/WalletConnectRelay/RelayClientFactory.swift
Original file line number Diff line number Diff line change
@@ -20,13 +20,16 @@ public struct RelayClientFactory {

let logger = ConsoleLogger(prefix: "🚄" ,loggingLevel: .off)

let networkMonitor = NetworkMonitor()

return RelayClientFactory.create(
relayHost: relayHost,
projectId: projectId,
keyValueStorage: keyValueStorage,
keychainStorage: keychainStorage,
socketFactory: socketFactory,
socketConnectionType: socketConnectionType,
networkMonitor: networkMonitor,
logger: logger
)
}
@@ -39,6 +42,7 @@ public struct RelayClientFactory {
keychainStorage: KeychainStorageProtocol,
socketFactory: WebSocketFactory,
socketConnectionType: SocketConnectionType = .automatic,
networkMonitor: NetworkMonitoring,
logger: ConsoleLogging
) -> RelayClient {

@@ -52,9 +56,11 @@ public struct RelayClientFactory {
projectId: projectId,
socketAuthenticator: socketAuthenticator
)

let dispatcher = Dispatcher(
socketFactory: socketFactory,
relayUrlFactory: relayUrlFactory,
relayUrlFactory: relayUrlFactory,
networkMonitor: networkMonitor,
socketConnectionType: socketConnectionType,
logger: logger
)