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

Remove the usage of crashing initialiser of IdentifiedArray #1077

Merged
merged 6 commits into from
Apr 8, 2024

Conversation

GhenadieVP
Copy link
Contributor

Jira ticket: https://radixdlt.atlassian.net/browse/ABW-3148

Description

We have several crash reports relating to transaction that did contain proofs, and a problems seem to be having multiple identical proofs which caused the app to crash:

Screenshot 2024-04-08 at 12 27 50

The problem was the usage of the crashing initialiser of IdentifiedArray. I went a bit overboard and replaced all these usages with safe asIdentifiable.

@@ -16,21 +16,21 @@ final class GatewaySettingsFeatureTests: TestCase {

func test_whenViewAppeared_thenCurrentGatewayAndGatewayListIsLoaded() async throws {
// given
let otherGateways: [Radix.Gateway] = [.stokenet, .rcnet]
let otherGateways: [Radix.Gateway] = [.stokenet, .rcnet].asIdentifiable()
Copy link
Contributor

Choose a reason for hiding this comment

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

use validating instead, which is throwing, and we are in a throwing context

@@ -79,16 +79,16 @@ final class GatewaySettingsFeatureTests: TestCase {
func test_whenNonCurrentGatewayRemovalIsConfirmed_removeGateway() async throws {
// given
let gatewayToBeDeleted = GatewayRow.State(gateway: .rcnet, isSelected: false, canBeDeleted: true)
let otherGateways: [Radix.Gateway] = [.stokenet, .rcnet]
let otherGateways: [Radix.Gateway] = [.stokenet, .rcnet].asIdentifiable()
Copy link
Contributor

Choose a reason for hiding this comment

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

use validating

@@ -141,7 +141,7 @@ public struct PersonasCoordinator: Sendable, FeatureReducer {
return .run { send in
let dApps = try await authorizedDappsClient.getDappsAuthorizedByPersona(persona.id)
.map(PersonaDetails.State.DappInfo.init)
let personaDetailsState = PersonaDetails.State(.general(persona, dApps: .init(uniqueElements: dApps)))
let personaDetailsState = PersonaDetails.State(.general(persona, dApps: dApps.asIdentifiable()))
Copy link
Contributor

Choose a reason for hiding this comment

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

should maybe use validating here, since it is a throwing context, and we wanna find those bugs...

@@ -74,7 +74,7 @@ public struct PersonaList: Sendable, FeatureReducer {
guard result.count == ids.count else {
throw UpdatePersonaError.personasMissingFromClient(ids.subtracting(result.map(\.id)))
}
await send(.internal(.personasLoaded(.init(uniqueElements: result))))
await send(.internal(.personasLoaded(result.asIdentifiable())))
Copy link
Contributor

Choose a reason for hiding this comment

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

validating instead I think

@@ -286,7 +286,7 @@ public struct PersonaDetails: Sendable, FeatureReducer {
let dApps = try await authorizedDappsClient.getDappsAuthorizedByPersona(oldPersona.id)
.map(State.DappInfo.init)

return await .general(persona, dApps: addingDappMetadata(to: .init(uniqueElements: dApps)))
return await .general(persona, dApps: addingDappMetadata(to: dApps.asIdentifiable()))
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe validating here too

@@ -266,7 +266,7 @@ struct DappInteractionFlow: Sendable, FeatureReducer {
setAccountsResponse(
to: ongoingAccountsWithoutProofOfOwnership.requestItem,
accessKind: .ongoing,
chosenAccounts: .withoutProofOfOwnership(.init(uniqueElements: ongoingAccountsWithoutProofOfOwnership.accounts)),
chosenAccounts: .withoutProofOfOwnership(ongoingAccountsWithoutProofOfOwnership.accounts.asIdentifiable()),
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe validating here ? if we can throw, not sure.

lastLogin: persona == lastLoggedInPersona ? authorizedPersonaSimple?.lastLogin : nil
)
}
.asIdentifiable()
Copy link
Contributor

Choose a reason for hiding this comment

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

validating?

Copy link
Contributor

@CyonAlexRDX CyonAlexRDX left a comment

Choose a reason for hiding this comment

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

LGTM

@GhenadieVP GhenadieVP merged commit 2c097a1 into main Apr 8, 2024
6 checks passed
@GhenadieVP GhenadieVP deleted the fix_proof_crash branch April 8, 2024 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants