-
Notifications
You must be signed in to change notification settings - Fork 216
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
Convert verification request and transaction to protocols #1528
Conversation
a860cea
to
d75c881
Compare
@@ -63,13 +63,13 @@ @interface MXKeyVerificationManager () | |||
dispatch_queue_t cryptoQueue; | |||
|
|||
// All running transactions | |||
MXUsersDevicesMap<MXKeyVerificationTransaction*> *transactions; | |||
MXUsersDevicesMap<MXDefaultKeyVerificationTransaction *> *transactions; |
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.
MXKeyVerificationManager
is accessing some of the internal methods of request and transaction which are defined in _Private.h
header files and not exposed in the protocol. For this reason it is still using implementation types rather than protocol types
Codecov Report
@@ Coverage Diff @@
## develop #1528 +/- ##
========================================
Coverage 12.04% 12.04%
========================================
Files 512 512
Lines 83822 83822
Branches 35786 35786
========================================
+ Hits 10097 10099 +2
+ Misses 73357 73355 -2
Partials 368 368
Continue to review full report at Codecov.
|
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.
Looks good to me 👍
As part of an ongoing work to implement Rust-based device verification I need to prepare the ground by converting existing
MXKeyVerificationRequest
,MXKeyVerificationTransaction
andMXSASTransaction
classes into protocols, so that future PRs can implement these protocols withMatrixCryptoSDK
objects. This is not a full list of classes that need to be hidden behind an interface, only those directly needed for SAS flow.I have previously taken a subclassing approach to solve a similar problem, but this was because refactoring existing code for
MXCrypto
class was too risky without extensive test coverage and it was best to leave this untouched. Swapping request and transaction objects for protocols should be safer, and now validated by some newly enabled integration tests. Subclassing existing implementation on the other hand leaves more technical debt behind and does not safeguard against some methods not being overriden.Regarding naming, I considered both alternatives where protocol adopts existing name (e.g.
MXKeyVerificationRequest
) and subclasses extend this (e.g. Default, V2 ...), as well as naming the protocolMXKeyVerificationRequestProtocol
and leaving the implementation names intact. Reviewing the SDK I did not find many examples of addingProtocol
to protocol definitions so I opted for the first naming variant to preserve consistency. This choice also means that only objective-c files need to perform renames, whereas swift files remain unchanged.