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

fix: register codecs on create of clients in android #183

Merged
merged 1 commit into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class XMTPModule : Module() {
signer = reactSigner
val options = ClientOptions(api = apiEnvironments(environment, appVersion))
clients[address] = Client().create(account = reactSigner, options = options)
ContentJson.Companion
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure it's necessary to call Companion here it could be implicitly called without it. But I wanted to explicit that this is triggering the init function that registers the codecs.

signer = null
sendEvent("authed")
}
Expand All @@ -160,6 +161,7 @@ class XMTPModule : Module() {
val privateKey = PrivateKeyBuilder()
val options = ClientOptions(api = apiEnvironments(environment, appVersion))
val randomClient = Client().create(account = privateKey, options = options)
ContentJson.Companion
clients[randomClient.address] = randomClient
randomClient.address
}
Expand All @@ -176,6 +178,7 @@ class XMTPModule : Module() {
)
)
val client = Client().buildFromBundle(bundle = bundle, options = options)
ContentJson.Companion
clients[client.address] = client
client.address
} catch (e: Exception) {
Expand Down
8 changes: 8 additions & 0 deletions example/src/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ test('can make a client', async () => {
env: 'local',
appVersion: 'Testing/0.0.0',
})
client.register(new RemoteAttachmentCodec())
if (Object.keys(client.codecRegistry).length !== 2) {
throw new Error(
`Codecs length should be 2 not ${
Object.keys(client.codecRegistry).length
}`
)
}
return client.address.length > 0
})

Expand Down
Loading