@@ -775,6 +775,7 @@ test.describe('Legacy/Unwrapped Name Extension with Referrer', () => {
775775
776776 const profilePage = makePageObject ( 'ProfilePage' )
777777 const transactionModal = makePageObject ( 'TransactionModal' )
778+ const extendNamesModal = makePageObject ( 'ExtendNamesModal' )
778779
779780 await page . goto ( `/${ name } ?referrer=${ referrerAddress } ` )
780781 await login . connect ( )
@@ -787,12 +788,12 @@ test.describe('Legacy/Unwrapped Name Extension with Referrer', () => {
787788
788789 // Set extension and proceed
789790 await expect ( page . getByTestId ( 'plus-minus-control-label' ) ) . toHaveText ( '1 year' )
790- await page . locator ( 'button:has-text("Next")' ) . click ( )
791+ await extendNamesModal . getExtendButton . click ( )
791792
792793 // Complete transaction
793794 await transactionModal . confirm ( )
794795
795- await expect ( page . getByText ( 'Your "Extend Names " transaction was successful' ) ) . toBeVisible ( {
796+ await expect ( page . getByText ( 'Your "Extend names " transaction was successful' ) ) . toBeVisible ( {
796797 timeout : 10000 ,
797798 } )
798799
@@ -817,6 +818,7 @@ test.describe('Legacy/Unwrapped Name Extension with Referrer', () => {
817818
818819 const profilePage = makePageObject ( 'ProfilePage' )
819820 const transactionModal = makePageObject ( 'TransactionModal' )
821+ const extendNamesModal = makePageObject ( 'ExtendNamesModal' )
820822
821823 await page . goto ( `/${ name } ` )
822824 await login . connect ( )
@@ -829,7 +831,7 @@ test.describe('Legacy/Unwrapped Name Extension with Referrer', () => {
829831
830832 // Set extension and proceed
831833 await expect ( page . getByTestId ( 'plus-minus-control-label' ) ) . toHaveText ( '1 year' )
832- await page . locator ( 'button:has-text("Next")' ) . click ( )
834+ await extendNamesModal . getExtendButton . click ( )
833835
834836 // Complete transaction
835837 await transactionModal . confirm ( )
@@ -856,6 +858,7 @@ test.describe('Legacy/Unwrapped Name Extension with Referrer', () => {
856858
857859 const profilePage = makePageObject ( 'ProfilePage' )
858860 const transactionModal = makePageObject ( 'TransactionModal' )
861+ const extendNamesModal = makePageObject ( 'ExtendNamesModal' )
859862
860863 await profilePage . goto ( name )
861864 await login . connect ( )
@@ -871,7 +874,7 @@ test.describe('Legacy/Unwrapped Name Extension with Referrer', () => {
871874
872875 // Set extension and proceed
873876 await expect ( page . getByTestId ( 'plus-minus-control-label' ) ) . toHaveText ( '1 year' )
874- await page . locator ( 'button:has-text("Next")' ) . click ( )
877+ await extendNamesModal . getExtendButton . click ( )
875878
876879 // Complete transaction
877880 await transactionModal . confirm ( )
@@ -885,6 +888,66 @@ test.describe('Legacy/Unwrapped Name Extension with Referrer', () => {
885888 const referrerHex = addressToBytes32 ( referrerAddress )
886889 expect ( latestTransaction . input ) . toContain ( referrerHex . slice ( 2 ) ) // Remove '0x' prefix for comparison
887890 } )
891+
892+ test ( 'should extend unwrapped name with ENS name as referrer' , async ( {
893+ page,
894+ login,
895+ accounts,
896+ makeName,
897+ makePageObject,
898+ } ) => {
899+ // Create an ENS name that will be used as referrer (has an ETH address record)
900+ const referrerName = await makeName ( {
901+ label : 'legacy-ens-referrer-name' ,
902+ type : 'legacy' ,
903+ owner : 'user2' ,
904+ records : {
905+ coins : [
906+ {
907+ coin : 'ETH' ,
908+ value : accounts . getAddress ( 'user2' ) ,
909+ } ,
910+ ] ,
911+ } ,
912+ } )
913+
914+ const name = await makeName ( {
915+ label : 'legacy-with-ens-referrer' ,
916+ type : 'legacy' ,
917+ owner : 'user' ,
918+ } )
919+
920+ const profilePage = makePageObject ( 'ProfilePage' )
921+ const transactionModal = makePageObject ( 'TransactionModal' )
922+ const extendNamesModal = makePageObject ( 'ExtendNamesModal' )
923+
924+ await page . goto ( `/${ name } ?referrer=${ referrerName } ` )
925+ await login . connect ( )
926+
927+ // Verify referrer is in URL
928+ expect ( page . url ( ) ) . toContain ( `referrer=${ referrerName } ` )
929+
930+ // Click extend button
931+ await profilePage . getExtendButton . click ( )
932+
933+ // Set extension and proceed
934+ await page . getByTestId ( 'plus-minus-control-plus' ) . click ( )
935+ // Wait for referrer to be resolved before clicking
936+ await expect ( extendNamesModal . getExtendButton ) . toBeEnabled ( { timeout : 10000 } )
937+ await extendNamesModal . getExtendButton . click ( )
938+
939+ await transactionModal . confirm ( )
940+
941+ await expect ( page . getByText ( 'Your "Extend names" transaction was successful' ) ) . toBeVisible ( {
942+ timeout : 10000 ,
943+ } )
944+
945+ // Verify resolved referrer address in transaction calldata
946+ const latestTransaction = await publicClient . getTransaction ( { blockTag : 'latest' , index : 0 } )
947+ // The ENS name should have resolved to user2's address
948+ const referrerHex = addressToBytes32 ( accounts . getAddress ( 'user2' ) )
949+ expect ( latestTransaction . input ) . toContain ( referrerHex . slice ( 2 ) ) // Remove '0x' prefix for comparison
950+ } )
888951} )
889952
890953test . describe ( 'Wrapped Name Renewal with Referrer' , ( ) => {
@@ -903,6 +966,7 @@ test.describe('Wrapped Name Renewal with Referrer', () => {
903966 } )
904967
905968 const transactionModal = makePageObject ( 'TransactionModal' )
969+ const extendNamesModal = makePageObject ( 'ExtendNamesModal' )
906970
907971 // Add referrer parameter to URL
908972 const referrerAddress = '0x1234567890123456789012345678901234567890'
@@ -917,7 +981,7 @@ test.describe('Wrapped Name Renewal with Referrer', () => {
917981 await expect ( page . getByTestId ( 'plus-minus-control-label' ) ) . toHaveText ( '1 year' )
918982
919983 // Proceed to transaction
920- await page . locator ( 'button:has-text("Next")' ) . click ( )
984+ await extendNamesModal . getExtendButton . click ( )
921985
922986 // Complete transaction
923987 await transactionModal . confirm ( )
@@ -947,6 +1011,7 @@ test.describe('Wrapped Name Renewal with Referrer', () => {
9471011 } )
9481012
9491013 const transactionModal = makePageObject ( 'TransactionModal' )
1014+ const extendNamesModal = makePageObject ( 'ExtendNamesModal' )
9501015 const referrerAddress = '0x1234567890123456789012345678901234567890'
9511016
9521017 // Start on profile page with referrer
@@ -982,7 +1047,7 @@ test.describe('Wrapped Name Renewal with Referrer', () => {
9821047 await expect ( page . getByTestId ( 'plus-minus-control-label' ) ) . toHaveText ( '2 years' )
9831048
9841049 // Proceed
985- await page . locator ( 'button:has-text("Next")' ) . click ( )
1050+ await extendNamesModal . getExtendButton . click ( )
9861051
9871052 // Verify referrer persisted
9881053 expect ( page . url ( ) ) . toContain ( `referrer=${ referrerAddress } ` )
@@ -1009,6 +1074,7 @@ test.describe('Wrapped Name Renewal with Referrer', () => {
10091074 } )
10101075
10111076 const transactionModal = makePageObject ( 'TransactionModal' )
1077+ const extendNamesModal = makePageObject ( 'ExtendNamesModal' )
10121078
10131079 // Navigate without referrer parameter
10141080 await page . goto ( `/${ name } ` )
@@ -1018,7 +1084,7 @@ test.describe('Wrapped Name Renewal with Referrer', () => {
10181084
10191085 await expect ( page . getByTestId ( 'plus-minus-control-label' ) ) . toHaveText ( '1 year' )
10201086
1021- await page . locator ( 'button:has-text("Next")' ) . click ( )
1087+ await extendNamesModal . getExtendButton . click ( )
10221088
10231089 await transactionModal . confirm ( )
10241090
@@ -1028,6 +1094,68 @@ test.describe('Wrapped Name Renewal with Referrer', () => {
10281094 } )
10291095 } )
10301096
1097+ test ( 'should extend wrapped name with ENS name as referrer' , async ( {
1098+ page,
1099+ login,
1100+ accounts,
1101+ makeName,
1102+ makePageObject,
1103+ } ) => {
1104+ // Create an ENS name that will be used as referrer (has an ETH address record)
1105+ const referrerName = await makeName ( {
1106+ label : 'extend-referrer' ,
1107+ type : 'legacy' ,
1108+ owner : 'user2' ,
1109+ records : {
1110+ coins : [
1111+ {
1112+ coin : 'ETH' ,
1113+ value : accounts . getAddress ( 'user2' ) ,
1114+ } ,
1115+ ] ,
1116+ } ,
1117+ } )
1118+
1119+ const name = await makeName ( {
1120+ label : 'wrapped-ens-referrer' ,
1121+ type : 'wrapped' ,
1122+ owner : 'user' ,
1123+ duration : daysToSeconds ( 30 ) ,
1124+ } )
1125+
1126+ const transactionModal = makePageObject ( 'TransactionModal' )
1127+ const extendNamesModal = makePageObject ( 'ExtendNamesModal' )
1128+
1129+ await page . goto ( `/${ name } ?referrer=${ referrerName } ` )
1130+ await login . connect ( )
1131+
1132+ // Verify referrer is in URL
1133+ expect ( page . url ( ) ) . toContain ( `referrer=${ referrerName } ` )
1134+
1135+ // Click extend button
1136+ await page . getByTestId ( 'extend-button' ) . click ( )
1137+
1138+ // Set extension and proceed
1139+ await page . getByTestId ( 'plus-minus-control-plus' ) . click ( )
1140+ await expect ( page . getByTestId ( 'plus-minus-control-label' ) ) . toHaveText ( '2 years' )
1141+
1142+ // Wait for referrer to be resolved before clicking
1143+ await expect ( extendNamesModal . getExtendButton ) . toBeEnabled ( { timeout : 10000 } )
1144+ await extendNamesModal . getExtendButton . click ( )
1145+
1146+ await transactionModal . confirm ( )
1147+
1148+ await expect ( page . getByText ( 'Your "Extend names" transaction was successful' ) ) . toBeVisible ( {
1149+ timeout : 10000 ,
1150+ } )
1151+
1152+ // Verify resolved referrer address in transaction calldata
1153+ const latestTransaction = await publicClient . getTransaction ( { blockTag : 'latest' , index : 0 } )
1154+ // The ENS name should have resolved to user2's address
1155+ const referrerHex = addressToBytes32 ( accounts . getAddress ( 'user2' ) )
1156+ expect ( latestTransaction . input ) . toContain ( referrerHex . slice ( 2 ) ) // Remove '0x' prefix for comparison
1157+ } )
1158+
10311159 test ( 'should use correct contract for wrapped vs unwrapped names' , async ( {
10321160 page,
10331161 login,
@@ -1050,12 +1178,13 @@ test.describe('Wrapped Name Renewal with Referrer', () => {
10501178 } )
10511179
10521180 const transactionModal = makePageObject ( 'TransactionModal' )
1181+ const extendNamesModal = makePageObject ( 'ExtendNamesModal' )
10531182
10541183 // Test wrapped name renewal
10551184 await page . goto ( `/${ wrappedName } ` )
10561185 await login . connect ( )
10571186 await page . getByTestId ( 'extend-button' ) . click ( )
1058- await page . locator ( 'button:has-text("Next")' ) . click ( )
1187+ await extendNamesModal . getExtendButton . click ( )
10591188
10601189 // Note: In a real test, we would inspect the transaction data to verify
10611190 // it's calling the correct contract (UniversalRegistrarRenewalWithReferrer)
@@ -1068,7 +1197,7 @@ test.describe('Wrapped Name Renewal with Referrer', () => {
10681197 // Test legacy name renewal
10691198 await page . goto ( `/${ legacyName } ` )
10701199 await page . getByTestId ( 'extend-button' ) . click ( )
1071- await page . locator ( 'button:has-text("Next")' ) . click ( )
1200+ await extendNamesModal . getExtendButton . click ( )
10721201
10731202 // Note: This should use the standard ETHRegistrarController
10741203 await transactionModal . confirm ( )
@@ -1110,6 +1239,7 @@ test.describe('Wrapped Name Renewal with Referrer', () => {
11101239 const address = accounts . getAddress ( 'user' )
11111240 const addressPage = makePageObject ( 'AddressPage' )
11121241 const transactionModal = makePageObject ( 'TransactionModal' )
1242+ const extendNamesModal = makePageObject ( 'ExtendNamesModal' )
11131243
11141244 await page . goto ( `/my/names?address=${ address } ` )
11151245 await login . connect ( )
@@ -1134,7 +1264,7 @@ test.describe('Wrapped Name Renewal with Referrer', () => {
11341264 // Check that we're extending at least 3 names (the ones we created)
11351265 await expect ( page . getByText ( / E x t e n d 3 N a m e s / ) ) . toBeVisible ( )
11361266
1137- await page . locator ( 'button:has-text("Next")' ) . click ( )
1267+ await extendNamesModal . getExtendButton . click ( )
11381268
11391269 // Complete transaction
11401270 await transactionModal . confirm ( )
0 commit comments