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

[Dispatcher] Handle fallback to .org #1002

Merged
merged 2 commits into from
Aug 1, 2023
Merged

Conversation

alexander-lsvk
Copy link
Contributor

Description

Resolves # (issue)

How Has This Been Tested?

Due Dilligence

  • Breaking change
  • Requires a documentation update

@alexander-lsvk alexander-lsvk temporarily deployed to internal July 31, 2023 14:12 — with GitHub Actions Inactive
@alexander-lsvk alexander-lsvk requested review from flypaper0, llbartekll and radeknovis and removed request for flypaper0 July 31, 2023 15:08
@@ -20,7 +20,8 @@ final class Dispatcher: NSObject, Dispatching {
private let logger: ConsoleLogging

private let defaultTimeout: Int = 5

private var fallback = false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we describe the purpose of the variable here, so it will be easier to get context later?

@@ -72,10 +73,14 @@ final class Dispatcher: NSObject, Dispatching {
.filter { $0 == .connected }
.setFailureType(to: NetworkError.self)
.timeout(.seconds(defaultTimeout), scheduler: concurrentQueue, customError: { .webSocketNotConnected })
.sink(receiveCompletion: { result in
.sink(receiveCompletion: { [weak self] result in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couldn't be unowned?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want 😁

}

private func handleFallbackIfNeeded(error: NetworkError) {
if error == .webSocketNotConnected && socket.request.url?.host == NetworkConstants.defaultUrl {
Copy link
Contributor

@llbartekll llbartekll Jul 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you help me understand the logic? it will fallback if socket did not connect and url is relay.walletconnect.com?
could the fallback also happen when socket did not connected from different reasons?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check for relay.walletconnect.com is needed to avoid reconnection for the cases when the wallet uses a custom relay server, it's their business then.

Fallback will happen when the connection timeout happens, we just called this error .webSocketNotConnected. Cuz basically there is no error when you try to reach a resource that is not available, it's thrown by timeout, like you have no connection.

var components = URLComponents()
components.scheme = "wss"
components.host = relayHost
components.host = fallback ? NetworkConstants.fallbackUrl : relayHost
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this mean that if a wallet wants to enable fallback, for all it's users regardless of their location the url will be .org for all of them?

Copy link
Contributor Author

@alexander-lsvk alexander-lsvk Aug 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the wallet doesn't have the option to enable/disable fallback. It happens automatically when the end user can't connect to .com. The fallback parameter will be set to true and used only for the current session (until the app is relaunched).

@alexander-lsvk alexander-lsvk temporarily deployed to internal August 1, 2023 07:29 — with GitHub Actions Inactive
@alexander-lsvk alexander-lsvk merged commit 7bae06f into develop Aug 1, 2023
@alexander-lsvk alexander-lsvk deleted the handle-fallback branch August 1, 2023 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants