Skip to content

Commit

Permalink
a few more tweaks to the sign functions
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Oct 17, 2024
1 parent 3c1304e commit 89561ff
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ class ClientTest {
val client = runBlocking {
Client().createOrBuild(
account = fakeWallet,
address = fakeWallet.address,
options = options
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class SmartContractWalletTest {
val davonSCWClient = runBlocking {
Client().createOrBuild(
account = davonSCW,
address = davonSCW.walletAddress,
options = ClientOptions(
ClientOptions.Api(XMTPEnvironment.LOCAL, false),
enableV3 = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import org.xmtp.android.library.messages.PrivateKey
import org.xmtp.android.library.messages.PrivateKeyBuilder
import org.xmtp.android.library.messages.Signature
import org.xmtp.android.library.messages.Topic
import org.xmtp.android.library.messages.consentProofText
import org.xmtp.android.library.messages.ethHash
import org.xmtp.android.library.messages.toPublicKeyBundle
import org.xmtp.android.library.messages.walletAddress
import org.xmtp.proto.message.contents.SignatureOuterClass
Expand Down Expand Up @@ -71,7 +73,7 @@ class FakeSCWWallet(
override val isSmartContractWallet: Boolean
get() = true

override var chainId: Long = 1L
override var chainId: Long = 31337L

companion object {
fun generate(
Expand All @@ -91,10 +93,7 @@ class FakeSCWWallet(
DefaultGasProvider()
).send()

val randomHash = ByteArray(32)
SecureRandom().nextBytes(randomHash)

val replaySafeHash = smartWallet.replaySafeHash(randomHash).send()
val replaySafeHash = smartWallet.replaySafeHash(data).send()
val signedHash = Sign.signMessage(replaySafeHash, credentials.ecKeyPair)
val signatureKey = KeyUtil.getSignatureBytes(signedHash)

Expand All @@ -107,7 +106,7 @@ class FakeSCWWallet(
}

override suspend fun sign(message: String): Signature {
val digest = message.toByteArray(Charsets.UTF_8).sha256()
val digest = Signature.newBuilder().build().ethHash(message)
return sign(digest)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class V3ClientTest {
boV3Client = runBlocking {
Client().createOrBuild(
account = boV3Wallet,
address = boV3Wallet.address,
options = ClientOptions(
ClientOptions.Api(XMTPEnvironment.LOCAL, false),
enableV3 = true,
Expand Down

0 comments on commit 89561ff

Please sign in to comment.