@@ -117,8 +117,12 @@ class TestBarz {
117
117
}.build()
118
118
119
119
transaction = Ethereum .Transaction .newBuilder().apply {
120
- transfer = Ethereum .Transaction .Transfer .newBuilder().apply {
121
- amount = ByteString .copyFrom(" 0x2386f26fc10000" .toHexByteArray())
120
+ scwExecute = Ethereum .Transaction .SCWalletExecute .newBuilder().apply {
121
+ transaction = Ethereum .Transaction .newBuilder().apply {
122
+ transfer = Ethereum .Transaction .Transfer .newBuilder().apply {
123
+ amount = ByteString .copyFrom(" 0x2386f26fc10000" .toHexByteArray())
124
+ }.build()
125
+ }.build()
122
126
}.build()
123
127
}.build()
124
128
}
@@ -159,8 +163,12 @@ class TestBarz {
159
163
}.build()
160
164
161
165
transaction = Ethereum .Transaction .newBuilder().apply {
162
- transfer = Ethereum .Transaction .Transfer .newBuilder().apply {
163
- amount = ByteString .copyFrom(" 0x2386f26fc10000" .toHexByteArray())
166
+ scwExecute = Ethereum .Transaction .SCWalletExecute .newBuilder().apply {
167
+ transaction = Ethereum .Transaction .newBuilder().apply {
168
+ transfer = Ethereum .Transaction .Transfer .newBuilder().apply {
169
+ amount = ByteString .copyFrom(" 0x2386f26fc10000" .toHexByteArray())
170
+ }.build()
171
+ }.build()
164
172
}.build()
165
173
}.build()
166
174
}
@@ -204,14 +212,14 @@ class TestBarz {
204
212
}.build()
205
213
206
214
transaction = Ethereum .Transaction .newBuilder().apply {
207
- batch = Ethereum .Transaction .Batch .newBuilder().apply {
215
+ scwBatch = Ethereum .Transaction .SCWalletBatch .newBuilder().apply {
208
216
addAllCalls(listOf (
209
- Ethereum .Transaction .Batch .BatchedCall .newBuilder().apply {
217
+ Ethereum .Transaction .SCWalletBatch .BatchedCall .newBuilder().apply {
210
218
address = " 0x03bBb5660B8687C2aa453A0e42dCb6e0732b1266"
211
219
amount = ByteString .copyFrom(" 0x00" .toHexByteArray())
212
220
payload = ByteString .copyFrom(approveCall)
213
221
}.build(),
214
- Ethereum .Transaction .Batch .BatchedCall .newBuilder().apply {
222
+ Ethereum .Transaction .SCWalletBatch .BatchedCall .newBuilder().apply {
215
223
address = " 0x03bBb5660B8687C2aa453A0e42dCb6e0732b1266"
216
224
amount = ByteString .copyFrom(" 0x00" .toHexByteArray())
217
225
payload = ByteString .copyFrom(transferCall)
@@ -254,15 +262,16 @@ class TestBarz {
254
262
maxInclusionFeePerGas = ByteString .copyFrom(" 0x3b9aca00" .toHexByteArray())
255
263
256
264
transaction = Ethereum .Transaction .newBuilder().apply {
257
- batch = Ethereum .Transaction .Batch .newBuilder().apply {
265
+ scwBatch = Ethereum .Transaction .SCWalletBatch .newBuilder().apply {
266
+ walletType = Ethereum .SCWalletType .Biz
258
267
addAllCalls(listOf (
259
- Ethereum .Transaction .Batch .BatchedCall .newBuilder().apply {
268
+ Ethereum .Transaction .SCWalletBatch .BatchedCall .newBuilder().apply {
260
269
// TWT
261
270
address = " 0x4B0F1812e5Df2A09796481Ff14017e6005508003"
262
271
amount = ByteString .copyFrom(" 0x00" .toHexByteArray())
263
272
payload = ByteString .copyFrom(transferPayload1)
264
273
}.build(),
265
- Ethereum .Transaction .Batch .BatchedCall .newBuilder().apply {
274
+ Ethereum .Transaction .SCWalletBatch .BatchedCall .newBuilder().apply {
266
275
// TWT
267
276
address = " 0x4B0F1812e5Df2A09796481Ff14017e6005508003"
268
277
amount = ByteString .copyFrom(" 0x00" .toHexByteArray())
@@ -272,7 +281,6 @@ class TestBarz {
272
281
}.build()
273
282
}.build()
274
283
275
- userOperationMode = Ethereum .SCAccountType .Biz
276
284
eip7702Authority = Ethereum .Authority .newBuilder().apply {
277
285
address = " 0x117BC8454756456A0f83dbd130Bb94D793D3F3F7"
278
286
}.build()
@@ -284,6 +292,42 @@ class TestBarz {
284
292
assertEquals(Numeric.toHexString(output.encoded.toByteArray()), "0x04f9030f3812843b9aca00843b9aca00830186a0945132829820b44dc3e8586cec926a16fca0a5608480b9024434fcd5be00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001200000000000000000000000004b0f1812e5df2a09796481ff14017e6005508003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044a9059cbb0000000000000000000000002ef648d7c03412b832726fd4683e2625dea047ba00000000000000000000000000000000000000000000000000005af3107a4000000000000000000000000000000000000000000000000000000000000000000000000000000000004b0f1812e5df2a09796481ff14017e6005508003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044a9059cbb00000000000000000000000095dc01ebd10b6dccf1cc329af1a3f73806117c2e0000000000000000000000000000000000000000000000000001c6bf5263400000000000000000000000000000000000000000000000000000000000c0f85cf85a3894117bc8454756456a0f83dbd130bb94d793d3f3f71380a0073afc661c158a2dccf4183f87e1e4d62b4d406af418cfd69959368ec9bec2a6a064292fd61d4d16b840470a86fc4f7a89413f9126d897f2268eb76a1d887c6d7a01a0e8bcbd96323c9d3e67b74366b2f43299100996d9e8874a6fd87186ac8f580d4ca07c25b4f0619af77fb953e8f0e4372bfbee62616ad419697516108eeb9bcebb28")
285
293
}
286
294
295
+ // https://bscscan.com/tx/0x6f8b2c8d50e8bb543d7124703b75d9e495832116a1a61afabf40b9b0ac43c980
296
+ @Test
297
+ fun testSignEnvelopedBiz () {
298
+ val signingInput = Ethereum .SigningInput .newBuilder()
299
+ signingInput.apply {
300
+ privateKey = ByteString .copyFrom(PrivateKey (" 0xe762e91cc4889a9fce79b2d2ffc079f86c48331f57b2cd16a33bee060fe448e1" .toHexByteArray()).data())
301
+ chainId = ByteString .copyFrom(" 0x38" .toHexByteArray())
302
+ nonce = ByteString .copyFrom(" 0x02" .toHexByteArray())
303
+ txMode = TransactionMode .Enveloped
304
+
305
+ gasLimit = ByteString .copyFrom(" 0x186a0" .toHexByteArray())
306
+ maxFeePerGas = ByteString .copyFrom(" 0x3b9aca00" .toHexByteArray())
307
+ maxInclusionFeePerGas = ByteString .copyFrom(" 0x3b9aca00" .toHexByteArray())
308
+
309
+ transaction = Ethereum .Transaction .newBuilder().apply {
310
+ scwExecute = Ethereum .Transaction .SCWalletExecute .newBuilder().apply {
311
+ walletType = Ethereum .SCWalletType .Biz
312
+ transaction = Ethereum .Transaction .newBuilder().apply {
313
+ erc20Transfer = Ethereum .Transaction .ERC20Transfer .newBuilder().apply {
314
+ to = " 0x95dc01ebd10b6dccf1cc329af1a3f73806117c2e"
315
+ amount = ByteString .copyFrom(" 0xb5e620f48000" .toHexByteArray())
316
+ }.build()
317
+ }.build()
318
+ }.build()
319
+ }.build()
320
+
321
+ // TWT token.
322
+ toAddress = " 0x4B0F1812e5Df2A09796481Ff14017e6005508003"
323
+ }
324
+
325
+ val output = AnySigner .sign(signingInput.build(), ETHEREUM , SigningOutput .parser())
326
+
327
+ assertEquals(Numeric .toHexString(output.preHash.toByteArray()), " 0x60260356568ae70838bd80085b971e1e4ebe42046688fd8511a268986e522121" )
328
+ assertEquals(Numeric .toHexString(output.encoded.toByteArray()), " 0x02f901503802843b9aca00843b9aca00830186a0946e860086bba8fdeafb553815af0f09a854cc887a80b8e4b61d27f60000000000000000000000004b0f1812e5df2a09796481ff14017e6005508003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044a9059cbb00000000000000000000000095dc01ebd10b6dccf1cc329af1a3f73806117c2e0000000000000000000000000000000000000000000000000000b5e620f4800000000000000000000000000000000000000000000000000000000000c080a0fb45762a262f4c32090576e9de087482d25cd00b6ea2522eb7d5a40f435acdbaa0151dbd48a4f4bf06080313775fe32ececd68869d721518a92bf292e4a84322f9" )
329
+ }
330
+
287
331
@Test
288
332
fun testAuthorizationHash () {
289
333
val chainId = " 0x01" .toHexByteArray()
@@ -351,7 +395,11 @@ class TestBarz {
351
395
toAddress = " 0x61061fCAE11fD5461535e134EfF67A98CFFF44E9"
352
396
353
397
transaction = Ethereum .Transaction .newBuilder().apply {
354
- this .transfer = transfer
398
+ scwExecute = Ethereum .Transaction .SCWalletExecute .newBuilder().apply {
399
+ transaction = Ethereum .Transaction .newBuilder().apply {
400
+ this .transfer = transfer
401
+ }.build()
402
+ }.build()
355
403
}.build()
356
404
357
405
userOperationV07 = userOpV07
0 commit comments