@@ -11,7 +11,7 @@ import {
1111 encodeSessionCallSignatureForJson ,
1212 encodeSessionSignature ,
1313 ExplicitSessionCallSignature ,
14- hashCallWithReplayProtection ,
14+ hashPayloadWithCallIdx ,
1515 ImplicitSessionCallSignature ,
1616 isExplicitSessionCallSignature ,
1717 isImplicitSessionCallSignature ,
@@ -445,24 +445,24 @@ describe('Session Signature', () => {
445445 } )
446446
447447 describe ( 'Helper Functions' , ( ) => {
448- describe ( 'hashCallWithReplayProtection ' , ( ) => {
448+ describe ( 'hashPayloadWithCallIdx ' , ( ) => {
449449 it ( 'should hash call with replay protection parameters' , ( ) => {
450- const result = hashCallWithReplayProtection ( testAddress1 , samplePayload , 0 , testChainId )
450+ const result = hashPayloadWithCallIdx ( testAddress1 , samplePayload , 0 , testChainId )
451451
452452 expect ( result ) . toMatch ( / ^ 0 x [ 0 - 9 a - f ] { 64 } $ / ) // 32-byte hex string
453453 expect ( Hex . size ( result ) ) . toBe ( 32 )
454454 } )
455455
456456 it ( 'should produce different hashes for different chain IDs' , ( ) => {
457- const hash1 = hashCallWithReplayProtection ( testAddress1 , samplePayload , 0 , ChainId . MAINNET )
458- const hash2 = hashCallWithReplayProtection ( testAddress1 , samplePayload , 0 , ChainId . POLYGON )
457+ const hash1 = hashPayloadWithCallIdx ( testAddress1 , samplePayload , 0 , ChainId . MAINNET )
458+ const hash2 = hashPayloadWithCallIdx ( testAddress1 , samplePayload , 0 , ChainId . POLYGON )
459459
460460 expect ( hash1 ) . not . toBe ( hash2 )
461461 } )
462462
463463 it ( 'should produce different hashes for different spaces' , ( ) => {
464- const hash1 = hashCallWithReplayProtection ( testAddress1 , samplePayload , 0 , testChainId )
465- const hash2 = hashCallWithReplayProtection (
464+ const hash1 = hashPayloadWithCallIdx ( testAddress1 , samplePayload , 0 , testChainId )
465+ const hash2 = hashPayloadWithCallIdx (
466466 testAddress1 ,
467467 { ...samplePayload , space : samplePayload . space + 1n } ,
468468 0 ,
@@ -473,8 +473,8 @@ describe('Session Signature', () => {
473473 } )
474474
475475 it ( 'should produce different hashes for different nonces' , ( ) => {
476- const hash1 = hashCallWithReplayProtection ( testAddress1 , samplePayload , 0 , testChainId )
477- const hash2 = hashCallWithReplayProtection (
476+ const hash1 = hashPayloadWithCallIdx ( testAddress1 , samplePayload , 0 , testChainId )
477+ const hash2 = hashPayloadWithCallIdx (
478478 testAddress1 ,
479479 { ...samplePayload , nonce : samplePayload . nonce + 1n } ,
480480 0 ,
@@ -491,17 +491,17 @@ describe('Session Signature', () => {
491491 }
492492 const payload2 = { ...samplePayload , calls : [ call2 ] }
493493
494- const hash1 = hashCallWithReplayProtection ( testAddress1 , samplePayload , 0 , testChainId )
495- const hash2 = hashCallWithReplayProtection ( testAddress1 , payload2 , 0 , testChainId )
494+ const hash1 = hashPayloadWithCallIdx ( testAddress1 , samplePayload , 0 , testChainId )
495+ const hash2 = hashPayloadWithCallIdx ( testAddress1 , payload2 , 0 , testChainId )
496496
497497 expect ( hash1 ) . not . toBe ( hash2 )
498498 } )
499499
500500 it ( 'should produce different hashes for different wallets' , ( ) => {
501501 const payload = { ...samplePayload , calls : [ sampleCall , sampleCall ] }
502502
503- const hash1 = hashCallWithReplayProtection ( testAddress1 , payload , 0 , testChainId )
504- const hash2 = hashCallWithReplayProtection ( testAddress2 , payload , 0 , testChainId )
503+ const hash1 = hashPayloadWithCallIdx ( testAddress1 , payload , 0 , testChainId )
504+ const hash2 = hashPayloadWithCallIdx ( testAddress2 , payload , 0 , testChainId )
505505
506506 expect ( hash1 ) . not . toBe ( hash2 )
507507 } )
@@ -511,8 +511,8 @@ describe('Session Signature', () => {
511511 // This is exploitable and should not be used in practice
512512 const payload = { ...samplePayload , calls : [ sampleCall , sampleCall ] }
513513
514- const hash1 = hashCallWithReplayProtection ( testAddress1 , payload , 0 , testChainId , Extensions . Dev1 . sessions )
515- const hash2 = hashCallWithReplayProtection ( testAddress2 , payload , 0 , testChainId , Extensions . Dev2 . sessions )
514+ const hash1 = hashPayloadWithCallIdx ( testAddress1 , payload , 0 , testChainId , Extensions . Dev1 . sessions )
515+ const hash2 = hashPayloadWithCallIdx ( testAddress2 , payload , 0 , testChainId , Extensions . Dev2 . sessions )
516516
517517 expect ( hash1 ) . toBe ( hash2 )
518518 } )
@@ -522,9 +522,9 @@ describe('Session Signature', () => {
522522 // This is exploitable and should not be used in practice
523523 const payload = { ...samplePayload , calls : [ sampleCall , sampleCall ] }
524524
525- const hash1 = hashCallWithReplayProtection ( testAddress1 , payload , 0 , testChainId , Extensions . Dev1 . sessions )
526- const hash2 = hashCallWithReplayProtection ( testAddress2 , payload , 0 , testChainId , Extensions . Rc3 . sessions )
527- const hash3 = hashCallWithReplayProtection ( testAddress2 , payload , 0 , testChainId )
525+ const hash1 = hashPayloadWithCallIdx ( testAddress1 , payload , 0 , testChainId , Extensions . Dev1 . sessions )
526+ const hash2 = hashPayloadWithCallIdx ( testAddress2 , payload , 0 , testChainId , Extensions . Rc3 . sessions )
527+ const hash3 = hashPayloadWithCallIdx ( testAddress2 , payload , 0 , testChainId )
528528
529529 expect ( hash1 ) . not . toBe ( hash2 )
530530 expect ( hash1 ) . not . toBe ( hash3 )
@@ -534,8 +534,8 @@ describe('Session Signature', () => {
534534 it ( 'should produce different hashes for same call at different index' , ( ) => {
535535 const payload = { ...samplePayload , calls : [ sampleCall , sampleCall ] }
536536
537- const hash1 = hashCallWithReplayProtection ( testAddress1 , payload , 0 , testChainId )
538- const hash2 = hashCallWithReplayProtection ( testAddress1 , payload , 1 , testChainId )
537+ const hash1 = hashPayloadWithCallIdx ( testAddress1 , payload , 0 , testChainId )
538+ const hash2 = hashPayloadWithCallIdx ( testAddress1 , payload , 1 , testChainId )
539539
540540 expect ( hash1 ) . not . toBe ( hash2 )
541541 } )
@@ -545,15 +545,15 @@ describe('Session Signature', () => {
545545 // This is exploitable and should not be used in practice
546546 const payload = { ...samplePayload , calls : [ sampleCall , sampleCall ] }
547547
548- const hash1 = hashCallWithReplayProtection ( testAddress1 , payload , 0 , testChainId , Extensions . Dev1 . sessions )
549- const hash2 = hashCallWithReplayProtection ( testAddress1 , payload , 1 , testChainId , Extensions . Dev1 . sessions )
548+ const hash1 = hashPayloadWithCallIdx ( testAddress1 , payload , 0 , testChainId , Extensions . Dev1 . sessions )
549+ const hash2 = hashPayloadWithCallIdx ( testAddress1 , payload , 1 , testChainId , Extensions . Dev1 . sessions )
550550
551551 expect ( hash1 ) . toBe ( hash2 )
552552 } )
553553
554554 it ( 'should be deterministic' , ( ) => {
555- const hash1 = hashCallWithReplayProtection ( testAddress1 , samplePayload , 0 , testChainId )
556- const hash2 = hashCallWithReplayProtection ( testAddress1 , samplePayload , 0 , testChainId )
555+ const hash1 = hashPayloadWithCallIdx ( testAddress1 , samplePayload , 0 , testChainId )
556+ const hash2 = hashPayloadWithCallIdx ( testAddress1 , samplePayload , 0 , testChainId )
557557
558558 expect ( hash1 ) . toBe ( hash2 )
559559 } )
@@ -563,7 +563,7 @@ describe('Session Signature', () => {
563563 const largeSpace = 2n ** 16n
564564 const largeNonce = 2n ** 24n
565565
566- const result = hashCallWithReplayProtection (
566+ const result = hashPayloadWithCallIdx (
567567 testAddress1 ,
568568 { ...samplePayload , space : largeSpace , nonce : largeNonce } ,
569569 0 ,
@@ -573,7 +573,7 @@ describe('Session Signature', () => {
573573 } )
574574
575575 it ( 'should handle zero values' , ( ) => {
576- const result = hashCallWithReplayProtection ( testAddress1 , { ...samplePayload , space : 0n , nonce : 0n } , 0 , 0 )
576+ const result = hashPayloadWithCallIdx ( testAddress1 , { ...samplePayload , space : 0n , nonce : 0n } , 0 , 0 )
577577 expect ( result ) . toMatch ( / ^ 0 x [ 0 - 9 a - f ] { 64 } $ / )
578578 } )
579579
@@ -584,7 +584,7 @@ describe('Session Signature', () => {
584584 }
585585 const payload = { ...samplePayload , calls : [ callWithEmptyData ] }
586586
587- const result = hashCallWithReplayProtection ( testAddress1 , payload , 0 , testChainId )
587+ const result = hashPayloadWithCallIdx ( testAddress1 , payload , 0 , testChainId )
588588 expect ( result ) . toMatch ( / ^ 0 x [ 0 - 9 a - f ] { 64 } $ / )
589589 } )
590590
@@ -595,8 +595,8 @@ describe('Session Signature', () => {
595595 }
596596 const payload = { ...samplePayload , calls : [ delegateCall ] }
597597
598- const hash1 = hashCallWithReplayProtection ( testAddress1 , samplePayload , 0 , testChainId )
599- const hash2 = hashCallWithReplayProtection ( testAddress1 , payload , 0 , testChainId )
598+ const hash1 = hashPayloadWithCallIdx ( testAddress1 , samplePayload , 0 , testChainId )
599+ const hash2 = hashPayloadWithCallIdx ( testAddress1 , payload , 0 , testChainId )
600600
601601 expect ( hash1 ) . not . toBe ( hash2 )
602602 } )
@@ -780,7 +780,7 @@ describe('Session Signature', () => {
780780
781781 // Generate hashes for each call
782782 const hashes = calls . map ( ( call ) =>
783- hashCallWithReplayProtection ( testAddress1 , payload , calls . indexOf ( call ) , testChainId ) ,
783+ hashPayloadWithCallIdx ( testAddress1 , payload , calls . indexOf ( call ) , testChainId ) ,
784784 )
785785
786786 // All hashes should be valid and different
0 commit comments