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

Require only 1 signature to add a wallet #337

Merged
merged 2 commits into from
Nov 22, 2024
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 @@ -419,8 +419,8 @@ class ClientTest {
val fixtures = fixtures()
val alix2Wallet = PrivateKeyBuilder()
val alix3Wallet = PrivateKeyBuilder()
runBlocking { fixtures.alixClient.addAccount(fixtures.alixAccount, alix2Wallet) }
runBlocking { fixtures.alixClient.addAccount(fixtures.alixAccount, alix3Wallet) }
runBlocking { fixtures.alixClient.addAccount(alix2Wallet) }
runBlocking { fixtures.alixClient.addAccount(alix3Wallet) }

val state = runBlocking { fixtures.alixClient.inboxState(true) }
assertEquals(state.installations.size, 1)
Expand All @@ -441,8 +441,8 @@ class ClientTest {
val fixtures = fixtures()
val alix2Wallet = PrivateKeyBuilder()
val alix3Wallet = PrivateKeyBuilder()
runBlocking { fixtures.alixClient.addAccount(fixtures.alixAccount, alix2Wallet) }
runBlocking { fixtures.alixClient.addAccount(fixtures.alixAccount, alix3Wallet) }
runBlocking { fixtures.alixClient.addAccount(alix2Wallet) }
runBlocking { fixtures.alixClient.addAccount(alix3Wallet) }

var state = runBlocking { fixtures.alixClient.inboxState(true) }
assertEquals(state.addresses.size, 3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ class SmartContractWalletTest {
val davonEOA = PrivateKeyBuilder()
val davonSCW2 = FakeSCWWallet.generate(ANVIL_TEST_PRIVATE_KEY_3)

runBlocking { davonSCWClient.addAccount(davonSCW, davonEOA) }
runBlocking { davonSCWClient.addAccount(davonSCW, davonSCW2) }
runBlocking { davonSCWClient.addAccount(davonEOA) }
runBlocking { davonSCWClient.addAccount(davonSCW2) }

var state = runBlocking { davonSCWClient.inboxState(true) }
assertEquals(state.installations.size, 1)
Expand Down
4 changes: 2 additions & 2 deletions library/src/main/java/libxmtp-version.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: cbff7296
Version: d07fb2bf
Branch: main
Date: 2024-11-21 17:51:27 +0000
Date: 2024-11-22 18:36:31 +0000
5 changes: 2 additions & 3 deletions library/src/main/java/org/xmtp/android/library/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,9 @@ class Client() {
ffiClient.applySignatureRequest(signatureRequest)
}

suspend fun addAccount(recoverAccount: SigningKey, newAccount: SigningKey) {
suspend fun addAccount(newAccount: SigningKey) {
val signatureRequest =
ffiClient.addWallet(address.lowercase(), newAccount.address.lowercase())
handleSignature(signatureRequest, recoverAccount)
ffiClient.addWallet(newAccount.address.lowercase())
handleSignature(signatureRequest, newAccount)
ffiClient.applySignatureRequest(signatureRequest)
}
Expand Down
21 changes: 6 additions & 15 deletions library/src/main/java/xmtpv3.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1430,9 +1430,7 @@ internal interface UniffiLib : Library {
): Unit

fun uniffi_xmtpv3_fn_method_ffixmtpclient_add_wallet(
`ptr`: Pointer,
`existingWalletAddress`: RustBuffer.ByValue,
`newWalletAddress`: RustBuffer.ByValue,
`ptr`: Pointer, `newWalletAddress`: RustBuffer.ByValue,
): Long

fun uniffi_xmtpv3_fn_method_ffixmtpclient_addresses_from_inbox_id(
Expand Down Expand Up @@ -2572,7 +2570,7 @@ private fun uniffiCheckApiChecksums(lib: UniffiLib) {
if (lib.uniffi_xmtpv3_checksum_method_ffiv2subscriptioncallback_on_error() != 24930.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_xmtpv3_checksum_method_ffixmtpclient_add_wallet() != 23786.toShort()) {
if (lib.uniffi_xmtpv3_checksum_method_ffixmtpclient_add_wallet() != 24482.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_xmtpv3_checksum_method_ffixmtpclient_addresses_from_inbox_id() != 29264.toShort()) {
Expand Down Expand Up @@ -8240,12 +8238,9 @@ public object FfiConverterTypeFfiV2SubscriptionCallback :
public interface FfiXmtpClientInterface {

/**
* Adds an identity - really a wallet address - to the existing client
* Adds a wallet address to the existing client
*/
suspend fun `addWallet`(
`existingWalletAddress`: kotlin.String,
`newWalletAddress`: kotlin.String,
): FfiSignatureRequest
suspend fun `addWallet`(`newWalletAddress`: kotlin.String): FfiSignatureRequest

/**
* * Get the inbox state for each `inbox_id`.
Expand Down Expand Up @@ -8417,19 +8412,15 @@ open class FfiXmtpClient : Disposable, AutoCloseable, FfiXmtpClientInterface {


/**
* Adds an identity - really a wallet address - to the existing client
* Adds a wallet address to the existing client
*/
@Throws(GenericException::class)
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")
override suspend fun `addWallet`(
`existingWalletAddress`: kotlin.String,
`newWalletAddress`: kotlin.String,
): FfiSignatureRequest {
override suspend fun `addWallet`(`newWalletAddress`: kotlin.String): FfiSignatureRequest {
return uniffiRustCallAsync(
callWithPointer { thisPtr ->
UniffiLib.INSTANCE.uniffi_xmtpv3_fn_method_ffixmtpclient_add_wallet(
thisPtr,
FfiConverterString.lower(`existingWalletAddress`),
FfiConverterString.lower(`newWalletAddress`),
)
},
Expand Down
Binary file modified library/src/main/jniLibs/arm64-v8a/libuniffi_xmtpv3.so
Binary file not shown.
Binary file modified library/src/main/jniLibs/armeabi-v7a/libuniffi_xmtpv3.so
Binary file not shown.
Binary file modified library/src/main/jniLibs/x86/libuniffi_xmtpv3.so
Binary file not shown.
Binary file modified library/src/main/jniLibs/x86_64/libuniffi_xmtpv3.so
Binary file not shown.
Loading