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

[ABW-3666] Fix Add gateway crash #1266

Merged
merged 4 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
public typealias AddGateway = @Sendable (Gateway) async throws -> Void
public typealias RemoveGateway = @Sendable (Gateway) async throws -> Void
public typealias ChangeGateway = @Sendable (Gateway) async throws -> Void
public typealias HasGateway = @Sendable (Url) async -> Bool
public typealias HasGateway = @Sendable (FfiUrl) async -> Bool

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Unit test

cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Unit test

cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Unit test

cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Unit test

cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Unit test

cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Unit test

cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Unit test

cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Unit test

cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Unit test

cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Unit test

cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Xcode test results

error

Cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Xcode test results

error

Cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Xcode test results

error

Cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Xcode test results

error

Cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Xcode test results

error

Cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Xcode test results

error

Cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Xcode test results

error

Cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Xcode test results

error

Cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Xcode test results

error

Cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Xcode test results

error

Cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Xcode test results

error

Cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Xcode test results

error

Cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Xcode test results

error

Cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Xcode test results

error

Cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Xcode test results

error

Cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Xcode test results

error

Cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Xcode test results

error

Cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Xcode test results

error

Cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Xcode test results

error

Cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Xcode test results

error

Cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Xcode test results

error

Cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Xcode test results

error

Cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Xcode test results

error

Cannot find type 'FfiUrl' in scope

Check failure on line 44 in RadixWallet/Clients/GatewaysClient/GatewaysClient+Interface.swift

View workflow job for this annotation

GitHub Actions / Xcode test results

error

Cannot find type 'FfiUrl' in scope
}

extension GatewaysClient {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public struct AddNewGateway: Sendable, FeatureReducer {
var inputtedURL: String = ""
var errorText: String?
var addGatewayButtonState: ControlState = .disabled
fileprivate var ffiUrl: FfiUrl?

public init() {}
}
Expand Down Expand Up @@ -56,14 +57,14 @@ public struct AddNewGateway: Sendable, FeatureReducer {
}

case .addNewGatewayButtonTapped:
guard let url = URL(string: state.inputtedURL)?.httpsURL else { return .none }
guard let ffiUrl = state.ffiUrl else { return .none }

return .run { send in
let hasGateway = await gatewaysClient.hasGateway(url)
let hasGateway = await gatewaysClient.hasGateway(ffiUrl)
if hasGateway {
await send(.internal(.showDuplicateURLError))
} else {
await send(.internal(.validateNewGateway(url)))
await send(.internal(.validateNewGateway(ffiUrl.url)))
}
}

Expand All @@ -75,8 +76,13 @@ public struct AddNewGateway: Sendable, FeatureReducer {
case let .textFieldChanged(inputtedURL):
state.inputtedURL = inputtedURL
state.errorText = nil
let url = URL(string: inputtedURL)
state.addGatewayButtonState = url != nil ? .enabled : .disabled
if let url = URL(string: state.inputtedURL)?.httpsURL, let ffiUrl = try? FfiUrl(urlPath: url.absoluteString) {
GhenadieVP marked this conversation as resolved.
Show resolved Hide resolved
state.ffiUrl = ffiUrl
state.addGatewayButtonState = .enabled
} else {
state.ffiUrl = nil
state.addGatewayButtonState = .disabled
}
return .none
}
}
Expand Down
Loading