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

Pull v3 client into its own PR #233

Merged
merged 5 commits into from
Feb 5, 2024
Merged

Pull v3 client into its own PR #233

merged 5 commits into from
Feb 5, 2024

Conversation

nakajima
Copy link
Contributor

@nakajima nakajima commented Feb 5, 2024

Contains the client related changes from #229.

@nakajima nakajima marked this pull request as ready for review February 5, 2024 18:36
@nakajima nakajima requested a review from a team as a code owner February 5, 2024 18:36
let v3Client: FfiXmtpClient?

if options?.enableAlphaMLS == true && options?.api.env == .local {
let dbURL = URL.documentsDirectory.appendingPathComponent("xmtp-\(options?.api.env.rawValue ?? "")-\(address).db3")
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know how rawValue works but in Android this would return the actual value so 10.2.2.2 or whatever. I was thinking this would return just enum name like local, dev, or prod. Atleast thats how we do it in android. 🤷‍♀️ Not a huge deal tho.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ya I'm ok with it just returning hostnames.

Comment on lines 243 to 250
if let v3Client, let textToSign = v3Client.textToSign() {
guard let signingKey else {
throw ClientError.creationError("No v3 keys found, you must pass a SigningKey in order to enable alpha MLS features")
}

let signature = try await signingKey.sign(message: textToSign)
try await v3Client.registerIdentity(recoverableWalletSignature: signature.rawData)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this check is required for V3 client creation I think it should move into the above method. And the above method should take an optional signer.

Copy link
Contributor

Choose a reason for hiding this comment

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

I also think the logic here is incorrect if there is no text to sign that just means a V3 identity already exists but you still need to call registerIdentity on it. If there is text to sign you sign it and call register identity. Otherwise then error.

        if (v3Client.textToSign() == null) {
            v3Client.registerIdentity(null)
        } else if (account != null) {
            v3Client.textToSign()?.let {
                v3Client.registerIdentity(account.sign(it))
            }
        } else {
            Log.i(TAG, "No signer passed but signer was required.")
        }

Comment on lines +254 to +256
for codec in options.codecs {
result.register(codec: codec)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason you added this here? Feels like if we didn't have it before than it doesn't make sense to add it now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was busted before.

}
}


Copy link
Contributor

Choose a reason for hiding this comment

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

Might be nice to add a test for the creating with a bundle scenario since it's a bit of an outlier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added in 327b000.

Comment on lines +155 to +157
for codec in (options?.codecs ?? []) {
client.register(codec: codec)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Same about the codec code? Was this meant to be committed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was actually not working before.

@nakajima nakajima merged commit 61d2eb8 into main Feb 5, 2024
1 check passed
@nakajima nakajima deleted the v3-client branch February 5, 2024 22:07
kele-leanes pushed a commit that referenced this pull request Feb 19, 2024
* Pull v3 client into its own PR

* Add tests

* rename mls alpha

* cleanup

* bring back skip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants