-
Notifications
You must be signed in to change notification settings - Fork 23
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
Add Identity Update Builder #632
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
568a2cf
to
4174ba6
Compare
a93bfe6
to
b4e75e4
Compare
b4e75e4
to
9c2569e
Compare
self.signature_text.clone() | ||
} | ||
|
||
pub fn build_identity_update(&self) -> Result<IdentityUpdate, SignatureRequestError> { |
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.
Can we consume self
here, or is there a benefit to keeping the intermediate builder around?
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.
Good call. I don't think you'll want the builder once this is done, so might as well consume self.
actions: Vec<PendingIdentityAction>, | ||
} | ||
|
||
impl IdentityUpdateBuilder { |
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.
Would it make sense to rename this SignatureRequestBuilder
Right now it looks like
let x = IdentityUpdateBuilder::new()
let x = x.to_signature_request()
x.build_identity_update()
But to me it makes more sense to build a SignatureRequest
from a SignatureRequestBuilder
which then resolves into a IdentityUpdate
like
let x = SignatureRequestBuilder::new()
let x = x.build()
/* platform SDK magic */
let identity_update = x.resolve()
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 think that's a good suggestion. I'll rename.
} | ||
|
||
#[derive(Clone, PartialEq, Hash, Eq)] | ||
enum SignatureField { |
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.
The SignatureField
enum here is a little confusing --
in IdentityUpdateBuilder
we assign a PendingSignature
with a SignatureField
so that later in build_action
we can retrieve the correct PendingSignature
address/identity to compare it with the recovered signer from the given Signature
.
I guess I'm ok with this, although i wish there was a more clear way to express/organize that code-wise. Will keep thinking about it, would be nice to have some docs explaining it on SignatureField
though
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.
Agree it's not the most intuitive. Batch signatures in general are a little confusing.
At the very least, I'll add some clarifying comments. And if we find a better way to structure the code we can refactor later.
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.
This is a really elegant way to implement batch signatures. Seconding @insipx's comments to make it easier for others to understand.
Also, from the example code:
for missing_signature in signature_request.missing_signatures() {
signature_request.add_signature(somehow_get_signature_maybe_this_happens_over_ffi()).expect("should succeed")?;
}
I think we can build higher-level API's over this before exposing to FFI. Rough sketch:
register_inbox_and_installation_key(Option<RecoveryAddress>): TextToSign; // installation key signature handled internally. Does not register inbox if inbox already exists
associate_external_wallet(): TextToSign; // installation key signature handled internally
... etc.
Oof, didn't realize it was auto-merge @neekolas |
tl;dr
IdentityUpdateBuilder
andSignatureRequest
structs, used to create batched Identity UpdatesDesign decisions
There were a few constraints on the design that made this a tricky one to implement.
libxmtp
, so they may have to prompt the user before they can get a signature. The most versatile solution is to have a "signature request" that goes over the FFI barrier to platform SDKs, and have the SDKs return the serialized bytes.Usage