From d8e447aec0cee7072d74a33fbfd10b465da1016b Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Thu, 17 Oct 2024 15:41:52 -0700 Subject: [PATCH] Fix failing SCW test --- dev/local/docker-compose.yml | 9 +++++++++ .../org/xmtp/android/library/TestHelpers.kt | 19 +++++++++++-------- .../java/org/xmtp/android/library/Client.kt | 5 +++-- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/dev/local/docker-compose.yml b/dev/local/docker-compose.yml index 9418154ba..570661926 100644 --- a/dev/local/docker-compose.yml +++ b/dev/local/docker-compose.yml @@ -22,6 +22,15 @@ services: validation: image: ghcr.io/xmtp/mls-validation-service:main platform: linux/amd64 + environment: + ANVIL_URL: "http://anvil:8545" + + anvil: + build: + dockerfile: /Users/nickmolnar/code/xmtp/libxmtp/dev/docker/anvil.Dockerfile + platform: linux/amd64 + ports: + - 8545:8545 db: image: postgres:13 diff --git a/library/src/androidTest/java/org/xmtp/android/library/TestHelpers.kt b/library/src/androidTest/java/org/xmtp/android/library/TestHelpers.kt index e3ae1d421..fc37f1f66 100644 --- a/library/src/androidTest/java/org/xmtp/android/library/TestHelpers.kt +++ b/library/src/androidTest/java/org/xmtp/android/library/TestHelpers.kt @@ -116,7 +116,7 @@ class FakeSCWWallet( return SignatureOuterClass.Signature.newBuilder().also { it.ecdsaCompact = it.ecdsaCompact.toBuilder().also { builder -> - builder.bytes = signatureBytes.toByteString() + builder.bytes = encodedBytes.toByteString() }.build() }.build() } @@ -132,21 +132,24 @@ class FakeSCWWallet( } private fun createSmartContractWallet() { - val factory = CoinbaseSmartWalletFactory.deploy( + val smartWalletContract = CoinbaseSmartWallet.deploy( web3j, credentials, - DefaultGasProvider(), - BigInteger.ZERO, - "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" + DefaultGasProvider() ).send() - CoinbaseSmartWallet.deploy( + val factory = CoinbaseSmartWalletFactory.deploy( web3j, credentials, - DefaultGasProvider() + DefaultGasProvider(), + BigInteger.ZERO, + smartWalletContract.contractAddress ).send() - val owners = listOf(Hash.sha3("eip155:31337:0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266".toByteArray())) + val ownerAddress = ByteArray(32) { 0 }.apply { + System.arraycopy(credentials.address.hexToByteArray(), 0, this, 12, 20) + } + val owners = listOf(ownerAddress) val nonce = BigInteger.ZERO val transactionReceipt = factory.createAccount(owners, nonce, BigInteger.ZERO).send() diff --git a/library/src/main/java/org/xmtp/android/library/Client.kt b/library/src/main/java/org/xmtp/android/library/Client.kt index a5f711903..696165a71 100644 --- a/library/src/main/java/org/xmtp/android/library/Client.kt +++ b/library/src/main/java/org/xmtp/android/library/Client.kt @@ -297,7 +297,8 @@ class Client() { ): Client { this.hasV2Client = false val clientOptions = options ?: ClientOptions(enableV3 = true) - val inboxId = getOrCreateInboxId(clientOptions, address) + val accountAddress = "eip155:31337:" + address.lowercase() + val inboxId = getOrCreateInboxId(clientOptions, accountAddress) return try { val (libXMTPClient, dbPath) = ffiXmtpClient( @@ -305,7 +306,7 @@ class Client() { account, clientOptions.appContext, null, - address, + accountAddress, inboxId )