Skip to content

Commit

Permalink
we don't want to run the null check on a blocking thread if it is null
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Dec 16, 2023
1 parent 1b93063 commit c0a3317
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
6 changes: 4 additions & 2 deletions library/src/main/java/org/xmtp/android/library/SigningKey.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ fun SigningKey.createIdentity(
secp256K1Uncompressed = identity.publicKey.secp256K1Uncompressed
}.build()

runBlocking {
preCreateIdentityCallback?.invoke()
preCreateIdentityCallback?.let {
runBlocking {
it.invoke()
}
}

val signatureClass = Signature.newBuilder().build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ fun EncryptedPrivateKeyBundle.decrypted(
key: SigningKey,
preEnableIdentityCallback: PreEventCallback? = null,
): PrivateKeyBundle {
runBlocking {
preEnableIdentityCallback?.invoke()
preEnableIdentityCallback?.let {
runBlocking {
it.invoke()
}
}

val signature = runBlocking {
key.sign(
message = Signature.newBuilder().build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ fun PrivateKeyBundle.encrypted(
): EncryptedPrivateKeyBundle {
val bundleBytes = toByteArray()
val walletPreKey = SecureRandom().generateSeed(32)
runBlocking {
preEnableIdentityCallback?.invoke()

preEnableIdentityCallback?.let {
runBlocking {
it.invoke()
}
}

val signature =
runBlocking {
key.sign(
Expand Down

0 comments on commit c0a3317

Please sign in to comment.