-
Notifications
You must be signed in to change notification settings - Fork 9
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-2214] Shared persona data not persisted in profile #734
[ABW-2214] Shared persona data not persisted in profile #734
Conversation
… ProfileSnapshot versoin to 48 force upgrading users to hammunet
…n_profile # Conflicts: # Sources/Core/SharedTestingModels/TestVectorsSharedByMultipleTargets/profile_snapshot.json # Sources/Profile/Snapshot/ProfileSnapshot+Header.swift
Sources/Profile/Logic/OnNetwork/OnNetwork+AuthorizedDapp+AuthorizedPersonas.swift
Show resolved
Hide resolved
Sources/Features/AuthorizedDAppsFeature/AuthorizedDApps/AuthorizedDApps.swift
Show resolved
Hide resolved
Sources/Features/DappInteractionFeature/Coordinator/DappInteractionFlow.swift
Show resolved
Hide resolved
Sources/Features/DappInteractionFeature/Coordinator/DappInteractionFlow.swift
Show resolved
Hide resolved
Sources/Features/DappInteractionFeature/Coordinator/DappInteractionFlow.swift
Show resolved
Hide resolved
Sources/Features/DappInteractionFeature/Coordinator/DappInteractionFlow.swift
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM,
added some suggestions, will perform some tests also.
@@ -103,18 +116,19 @@ public struct AuthorizedDapps: Sendable, FeatureReducer { | |||
case .presentedDapp(.presented(.delegate(.dAppForgotten))): | |||
return .run { send in | |||
await send(.child(.presentedDapp(.dismiss))) | |||
await send(loadAuthorizedDapps()) | |||
} | |||
}.concatenate(with: loadAuthorizedDapps()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: move on next line.
return nil | ||
} | ||
let personaDataEntries = personaData[keyPath: personaDataKeyPath] | ||
let set = try OrderedSet<T>(validating: personaDataEntries.map(\.value)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better use something like personaDataEntriesSet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100% agree
let expectedQuantity = numberOfRequestedElements.quantity | ||
switch numberOfRequestedElements.quantifier { | ||
case .atLeast: | ||
guard set.count >= expectedQuantity else { | ||
return nil | ||
} | ||
case .exactly: | ||
guard set.count == expectedQuantity else { | ||
return nil | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could func satisfies(_ requestedNumber: RequestedNumber)
be used instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If not, it should be generalised, and either way it could operate on Collection rather than OrderedSet.
Sources/Features/AuthorizedDAppsFeature/AuthorizedDApps/AuthorizedDApps.swift
Show resolved
Hide resolved
forgetAuthorizedDapp: { toForget, networkID in | ||
try await getProfileStore().updating { | ||
forgetAuthorizedDapp: { toForget, maybeNetworkID in | ||
let currentNetworkID = await getProfileStore().profile.networkID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're doing this in any case, what is the purpose of even allowing caller to submit a networkID? It's not performance, so is it the case that you might want to use some other networkID?
Either way, might as well do
let networkID = maybeNetworkID ?? await getProfileStore().profile.networkID
And I would also rename maybeNetworkID
to explicitNetworkID
, if that is the purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if let numberOfRequestedPhoneNumbers = personaDataRequested.numberOfRequestedPhoneNumbers { | ||
guard | ||
let phoneNumbers = responseItem.phoneNumbers, | ||
phoneNumbers.satisfies(numberOfRequestedPhoneNumbers) | ||
else { | ||
throw RequiredPersonaDataFieldsNotPresentInResponse( | ||
missingEntryKind: .phoneNumber | ||
) | ||
} | ||
} | ||
|
||
// FIXME: Handle dateOfBirth | ||
// FIXME: Handle companyName | ||
// FIXME: Handle urls | ||
// FIXME: Handle postalAddresses | ||
// FIXME: Handle creditCards |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the requirement we're checking here is always the number, we could abstract the check into a general function so that each field becomes a one-liner
Sources/Clients/AuthorizedDappsClient/AuthorizedDappsClient+Interface.swift
Outdated
Show resolved
Hide resolved
Sources/Clients/AuthorizedDappsClient/AuthorizedDappsClient+Interface.swift
Outdated
Show resolved
Hide resolved
Sources/Clients/AuthorizedDappsClient/AuthorizedDappsClient+Interface.swift
Outdated
Show resolved
Hide resolved
collection.ids.contains(id) | ||
else { return } | ||
collection.ids.remove(id) | ||
switch collection.request.quantifier { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we need to check the count in the exact case? And why can't we keep what we have, even if it's not enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because we KNOW it cannot pass, when exactly
is required, we know we can delete the whole collection, because we just decreased the number of IDs by one, thus exactly
cannot be fulfilled, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can add a clarifying comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, presuming it has been correctly checked previously, which is probably a reasonable assumption, but in other places here we seem to be very defensive.
But what is the high level idea, why do we need to delete anything at all? What's the harm in keeping it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kugel3 we dont want the ids
to contradict request
ever, so we have to delete it if it does.
// The only purpose of this switch is to make sure we get a compilation error when we add a new PersonaData.Entry kind, so | ||
// we do not forget to handle it here. | ||
switch PersonaData.Entry.Kind.fullName { | ||
case .fullName, .dateOfBirth, .companyName, .emailAddress, .phoneNumber, .url, .postalAddress, .creditCard: break | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally this should be covered by tests, instead of sprinkling this switch over the codebase...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree 100% with you :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when all other tickets are merged today and soundness check of a binary looks promising I can start write tests, but ATM no time :/ :/ :/
Demo
See 8 min video on Slack