@@ -258,14 +258,17 @@ class TestBarz {
258
258
259
259
@Test
260
260
fun testBarzTransferAccountDeployedV07 () {
261
+ val chainIdByteArray = " 0x7A69" .toHexByteArray() // 31337
262
+ val wallet = " 0x174a240e5147D02dE4d7724D5D3E1c1bF11cE029"
263
+
261
264
val transfer = Ethereum .Transaction .Transfer .newBuilder().apply {
262
265
amount = ByteString .copyFrom(" 0x2386f26fc10000" .toHexByteArray())
263
266
data = ByteString .EMPTY
264
267
}.build()
265
268
266
269
val userOpV07 = Ethereum .UserOperationV0_7 .newBuilder().apply {
267
270
entryPoint = " 0x0000000071727De22E5E9d8BAf0edAc6f37da032"
268
- sender = " 0x174a240e5147D02dE4d7724D5D3E1c1bF11cE029 "
271
+ sender = wallet
269
272
preVerificationGas = ByteString .copyFrom(" 0xF4240" .toHexByteArray()) // 1000000
270
273
verificationGasLimit = ByteString .copyFrom(" 0x186A0" .toHexByteArray()) // 100000
271
274
factory = " 0xf471789937856d80e589f5996cf8b0511ddd9de4"
@@ -282,7 +285,7 @@ class TestBarz {
282
285
// Create signing input
283
286
val signingInput = Ethereum .SigningInput .newBuilder().apply {
284
287
privateKey = ByteString .copyFrom(PrivateKey (" 3c90badc15c4d35733769093d3733501e92e7f16e101df284cee9a310d36c483" .toHexByteArray()).data())
285
- chainId = ByteString .copyFrom(" 0x7A69 " .toHexByteArray() ) // 31337
288
+ chainId = ByteString .copyFrom(chainIdByteArray ) // 31337
286
289
nonce = ByteString .copyFrom(" 0x00" .toHexByteArray())
287
290
txMode = Ethereum .TransactionMode .UserOp
288
291
gasLimit = ByteString .copyFrom(" 0x186A0" .toHexByteArray()) // 100000
@@ -303,6 +306,26 @@ class TestBarz {
303
306
" 0xf177858c1c500e51f38ffe937bed7e4d3a8678725900be4682d3ce04d97071eb" ,
304
307
Numeric .toHexString(output.preHash.toByteArray())
305
308
)
306
- }
307
309
310
+ val version = " v0.1.0"
311
+ val typeHash = " 0x4f51e7a567f083a31264743067875fc6a7ae45c32c5bd71f6a998c4625b13867"
312
+ val domainSeparatorHash = " 0x293ce8821a350a49f08b53d14e10112c36c7fbf3b8eb7078497893f3ea477f6b"
313
+ val hash = " 0xf177858c1c500e51f38ffe937bed7e4d3a8678725900be4682d3ce04d97071eb"
314
+
315
+ val encodedHash = WCBarz .getEncodedHash(chainIdByteArray, wallet, version, typeHash, domainSeparatorHash, hash)
316
+ assertEquals(
317
+ " 0x59ebb8c4e48c115eeaf2ea7d3a0802754462761c5019df8d2a38effb226191d5" ,
318
+ Numeric .toHexString(encodedHash)
319
+ )
320
+
321
+ val privateKey = " 0x947dd69af402e7f48da1b845dfc1df6be593d01a0d8274bd03ec56712e7164e8"
322
+ val signedHash = WCBarz .getSignedHash(
323
+ " 0x59ebb8c4e48c115eeaf2ea7d3a0802754462761c5019df8d2a38effb226191d5" ,
324
+ privateKey
325
+ )
326
+ assertEquals(
327
+ " 0x34a7792a140f52358925a57bca8ea936d70133b285396040ac0507597ed5c70a3148964ba1e0b32b8f59fbd9c098a4ec2b9ae5e5739ce4aeccae0f73279d50da1b" ,
328
+ Numeric .toHexString(signedHash)
329
+ )
330
+ }
308
331
}
0 commit comments