@@ -273,19 +273,30 @@ task("app:deploy", "Deploy AppAuth with a UUPS proxy")
273
273
const proxyAddress = await appAuth . getAddress ( ) ;
274
274
const tx = await kmsContract . registerApp ( proxyAddress ) ;
275
275
const receipt = await waitTx ( tx ) ;
276
+
276
277
// Parse the AppRegistered event from the logs
277
- const appRegisteredEvent = receipt . logs
278
- . filter ( ( log : any ) => log . fragment ?. name === 'AppRegistered' )
279
- . map ( ( log : any ) => {
280
- const { appId } = log . args ;
281
- return { appId } ;
282
- } ) [ 0 ] ;
278
+ let appRegisteredEvent = null ;
279
+ for ( const log of receipt . logs ) {
280
+ try {
281
+ const parsedLog = kmsContract . interface . parseLog ( {
282
+ topics : log . topics ,
283
+ data : log . data
284
+ } ) ;
285
+
286
+ if ( parsedLog ?. name === 'AppRegistered' ) {
287
+ appRegisteredEvent = parsedLog . args ;
288
+ break ;
289
+ }
290
+ } catch ( e ) {
291
+ continue ;
292
+ }
293
+ }
283
294
284
295
if ( appRegisteredEvent ) {
285
296
console . log ( "App registered in KMS successfully" ) ;
286
297
console . log ( "Registered AppId:" , appRegisteredEvent . appId ) ;
287
298
} else {
288
- console . log ( "App registered in KMS successfully (event not found )" ) ;
299
+ console . log ( "App registered in KMS successfully (event not parsed )" ) ;
289
300
}
290
301
} ) ;
291
302
@@ -330,12 +341,22 @@ task("app:deploy-with-data", "Deploy AppAuth with initial device and compose has
330
341
const receipt = await waitTx ( tx ) ;
331
342
332
343
// Parse the AppRegistered event from the logs
333
- const appRegisteredEvent = receipt . logs
334
- . filter ( ( log : any ) => log . fragment ?. name === 'AppRegistered' )
335
- . map ( ( log : any ) => {
336
- const { appId } = log . args ;
337
- return { appId } ;
338
- } ) [ 0 ] ;
344
+ let appRegisteredEvent = null ;
345
+ for ( const log of receipt . logs ) {
346
+ try {
347
+ const parsedLog = kmsContract . interface . parseLog ( {
348
+ topics : log . topics ,
349
+ data : log . data
350
+ } ) ;
351
+
352
+ if ( parsedLog ?. name === 'AppRegistered' ) {
353
+ appRegisteredEvent = parsedLog . args ;
354
+ break ;
355
+ }
356
+ } catch ( e ) {
357
+ continue ;
358
+ }
359
+ }
339
360
340
361
if ( appRegisteredEvent ) {
341
362
console . log ( "App registered in KMS successfully" ) ;
@@ -345,7 +366,7 @@ task("app:deploy-with-data", "Deploy AppAuth with initial device and compose has
345
366
const hasHash = composeHash !== "0x0000000000000000000000000000000000000000000000000000000000000000" ;
346
367
console . log ( `Deployed with ${ hasDevice ? "1" : "0" } initial device and ${ hasHash ? "1" : "0" } initial compose hash` ) ;
347
368
} else {
348
- console . log ( "App registered in KMS successfully (event not found )" ) ;
369
+ console . log ( "App registered in KMS successfully (event not parsed )" ) ;
349
370
}
350
371
} ) ;
351
372
@@ -380,14 +401,27 @@ task("app:deploy-factory", "Deploy AppAuth via KMS factory method (single transa
380
401
381
402
const receipt = await waitTx ( tx ) ;
382
403
383
- // Parse events
384
- const factoryEvent = receipt . logs
385
- . filter ( ( log : any ) => log . fragment ?. name === 'AppDeployedViaFactory' )
386
- . map ( ( log : any ) => log . args ) [ 0 ] ;
387
-
388
- const registeredEvent = receipt . logs
389
- . filter ( ( log : any ) => log . fragment ?. name === 'AppRegistered' )
390
- . map ( ( log : any ) => log . args ) [ 0 ] ;
404
+ // Parse events using contract interface
405
+ let factoryEvent = null ;
406
+ let registeredEvent = null ;
407
+
408
+ for ( const log of receipt . logs ) {
409
+ try {
410
+ const parsedLog = kmsAuth . interface . parseLog ( {
411
+ topics : log . topics ,
412
+ data : log . data
413
+ } ) ;
414
+
415
+ if ( parsedLog ?. name === 'AppDeployedViaFactory' ) {
416
+ factoryEvent = parsedLog . args ;
417
+ } else if ( parsedLog ?. name === 'AppRegistered' ) {
418
+ registeredEvent = parsedLog . args ;
419
+ }
420
+ } catch ( e ) {
421
+ // Skip logs that can't be parsed by this contract
422
+ continue ;
423
+ }
424
+ }
391
425
392
426
if ( factoryEvent && registeredEvent ) {
393
427
console . log ( "✅ App deployed and registered in single transaction!" ) ;
@@ -400,7 +434,20 @@ task("app:deploy-factory", "Deploy AppAuth via KMS factory method (single transa
400
434
const hasHash = composeHash !== "0x0000000000000000000000000000000000000000000000000000000000000000" ;
401
435
console . log ( `Deployed with ${ hasDevice ? "1" : "0" } initial device and ${ hasHash ? "1" : "0" } initial compose hash` ) ;
402
436
} else {
403
- console . log ( "App deployed successfully (events not found)" ) ;
437
+ console . log ( "✅ App deployed successfully!" ) ;
438
+ console . log ( "Transaction hash:" , tx . hash ) ;
439
+
440
+ // Try to get app ID from the transaction return values if events failed
441
+ try {
442
+ const result = await tx . wait ( ) ;
443
+ console . log ( "Transaction confirmed in block:" , result . blockNumber ) ;
444
+
445
+ // If we can't parse events, suggest manual verification
446
+ console . log ( "💡 To verify deployment, use:" ) ;
447
+ console . log ( `cast call ${ KMS_CONTRACT_ADDRESS } "nextAppSequence(address)" "${ deployerAddress } " --rpc-url \${RPC_URL}` ) ;
448
+ } catch ( e ) {
449
+ console . log ( "Could not parse transaction details" ) ;
450
+ }
404
451
}
405
452
} ) ;
406
453
0 commit comments