@@ -40,7 +40,7 @@ describe('SBTProxy', () => {
4040 return { sbt, sbtImplementation, sbtProxy, sbtImplementationB }
4141 }
4242
43- describe ( 'SBT proxy tests' , ( ) => {
43+ describe ( '---- SBT proxy tests------------ ' , ( ) => {
4444 describe ( 'admin' , ( ) => {
4545 it ( 'Should return admin correctly if signer is proxyAdmin' , async ( ) => {
4646 const signers = await getSigners ( )
@@ -460,8 +460,24 @@ describe('SBTProxy', () => {
460460 } )
461461 } )
462462
463- describe ( 'SBT logic tests' , ( ) => {
463+ describe ( '---- SBT logic tests------------ ' , ( ) => {
464464 describe ( 'initialize' , ( ) => {
465+ it ( 'Proxy admin should not be able to call implementation functions' , async ( ) => {
466+ const { sbt } = await init ( )
467+ const { proxyAdmin } = await getSigners ( )
468+
469+ await expect (
470+ sbt
471+ . connect ( proxyAdmin )
472+ . initialize ( constants . AddressZero , [
473+ constants . AddressZero ,
474+ constants . AddressZero ,
475+ ] )
476+ ) . to . be . revertedWith (
477+ 'TransparentUpgradeableProxy: admin cannot fallback to proxy target'
478+ )
479+ } )
480+
465481 it ( 'The initialize function can only be executed once' , async ( ) => {
466482 const { sbt } = await init ( )
467483 await expect (
@@ -474,6 +490,17 @@ describe('SBTProxy', () => {
474490 } )
475491
476492 describe ( 'addMinter' , ( ) => {
493+ it ( 'Proxy admin should not be able to call implementation functions' , async ( ) => {
494+ const { sbt } = await init ( )
495+ const signers = await getSigners ( )
496+
497+ await expect (
498+ sbt . connect ( signers . proxyAdmin ) . addMinter ( signers . minterC . address )
499+ ) . to . be . revertedWith (
500+ 'TransparentUpgradeableProxy: admin cannot fallback to proxy target'
501+ )
502+ } )
503+
477504 it ( 'The addMinter function can be executed by minterUpdater' , async ( ) => {
478505 const { sbt } = await init ( )
479506 const signers = await getSigners ( )
@@ -502,6 +529,17 @@ describe('SBTProxy', () => {
502529 } )
503530
504531 describe ( 'removeMinter' , ( ) => {
532+ it ( 'Proxy admin should not be able to call implementation functions' , async ( ) => {
533+ const { sbt } = await init ( )
534+ const signers = await getSigners ( )
535+
536+ await expect (
537+ sbt . connect ( signers . proxyAdmin ) . removeMinter ( signers . minterA . address )
538+ ) . to . be . revertedWith (
539+ 'TransparentUpgradeableProxy: admin cannot fallback to proxy target'
540+ )
541+ } )
542+
505543 it ( 'The removeMinter function can be executed by minterUpdater' , async ( ) => {
506544 const { sbt } = await init ( )
507545 const signers = await getSigners ( )
@@ -532,6 +570,18 @@ describe('SBTProxy', () => {
532570 } )
533571
534572 describe ( 'mint' , ( ) => {
573+ it ( 'Proxy admin should not be able to call implementation functions' , async ( ) => {
574+ const { sbt } = await init ( )
575+ const signers = await getSigners ( )
576+
577+ const metadata = await getDummyEncodedMetadata ( sbt )
578+ await expect (
579+ sbt . connect ( signers . proxyAdmin ) . mint ( signers . userA . address , metadata )
580+ ) . to . be . revertedWith (
581+ 'TransparentUpgradeableProxy: admin cannot fallback to proxy target'
582+ )
583+ } )
584+
535585 it ( 'The mint function should function correctly' , async ( ) => {
536586 const { sbt } = await init ( )
537587 const signers = await getSigners ( )
@@ -713,6 +763,26 @@ describe('SBTProxy', () => {
713763 } )
714764
715765 describe ( 'transfer' , ( ) => {
766+ it ( 'Proxy admin should not be able to call implementation functions' , async ( ) => {
767+ const { sbt } = await init ( )
768+ const signers = await getSigners ( )
769+
770+ const metadata = await getDummyEncodedMetadata ( sbt )
771+ await expect (
772+ sbt . connect ( signers . minterA ) . mint ( signers . userA . address , metadata )
773+ )
774+ . to . emit ( sbt , 'Minted' )
775+ . withArgs ( 1 , signers . userA . address )
776+
777+ await expect (
778+ sbt
779+ . connect ( signers . proxyAdmin )
780+ . transferFrom ( signers . userA . address , signers . userB . address , 1 )
781+ ) . to . be . revertedWith (
782+ 'TransparentUpgradeableProxy: admin cannot fallback to proxy target'
783+ )
784+ } )
785+
716786 it ( 'The transfer function should not work if owner' , async ( ) => {
717787 const { sbt } = await init ( )
718788 const signers = await getSigners ( )
@@ -773,6 +843,26 @@ describe('SBTProxy', () => {
773843 } )
774844
775845 describe ( 'burn' , ( ) => {
846+ it ( 'Proxy admin should not be able to call implementation functions' , async ( ) => {
847+ const { sbt } = await init ( )
848+ const signers = await getSigners ( )
849+
850+ const metadata = await getDummyEncodedMetadata ( sbt )
851+ await expect (
852+ sbt . connect ( signers . minterA ) . mint ( signers . userA . address , metadata )
853+ )
854+ . to . emit ( sbt , 'Minted' )
855+ . withArgs ( 1 , signers . userA . address )
856+
857+ await expect (
858+ sbt
859+ . connect ( signers . proxyAdmin )
860+ . transferFrom ( signers . userA . address , constants . AddressZero , 1 )
861+ ) . to . be . revertedWith (
862+ 'TransparentUpgradeableProxy: admin cannot fallback to proxy target'
863+ )
864+ } )
865+
776866 it ( 'The transfer to address(0) should not work if owner' , async ( ) => {
777867 const { sbt } = await init ( )
778868 const signers = await getSigners ( )
@@ -833,6 +923,30 @@ describe('SBTProxy', () => {
833923 } )
834924
835925 describe ( 'safeTransfer' , ( ) => {
926+ it ( 'Proxy admin should not be able to call implementation functions' , async ( ) => {
927+ const { sbt } = await init ( )
928+ const signers = await getSigners ( )
929+
930+ const metadata = await getDummyEncodedMetadata ( sbt )
931+ await expect (
932+ sbt . connect ( signers . minterA ) . mint ( signers . userA . address , metadata )
933+ )
934+ . to . emit ( sbt , 'Minted' )
935+ . withArgs ( 1 , signers . userA . address )
936+
937+ await expect (
938+ sbt
939+ . connect ( signers . proxyAdmin )
940+ [ 'safeTransferFrom(address,address,uint256)' ] (
941+ signers . userA . address ,
942+ signers . userB . address ,
943+ 1
944+ )
945+ ) . to . be . revertedWith (
946+ 'TransparentUpgradeableProxy: admin cannot fallback to proxy target'
947+ )
948+ } )
949+
836950 it ( 'The safeTransfer function should not work if owner' , async ( ) => {
837951 const sbtContractFactory = await ethers . getContractFactory ( 'SBT' )
838952 const sbt = sbtContractFactory . attach ( ( await init ( ) ) . sbt . address )
@@ -906,6 +1020,35 @@ describe('SBTProxy', () => {
9061020 } )
9071021
9081022 describe ( 'setTokenURI' , ( ) => {
1023+ it ( 'Proxy admin should not be able to call implementation functions' , async ( ) => {
1024+ const { sbt } = await init ( )
1025+ const signers = await getSigners ( )
1026+
1027+ const metadata = {
1028+ name : 'Proof of service NFT' ,
1029+ description :
1030+ 'This is a proof of service NFT, which indicates your contribution to the project' ,
1031+ tokenURIImage :
1032+ 'https://i.guim.co.uk/img/media/ef8492feb3715ed4de705727d9f513c168a8b196/37_0_1125_675/master/1125.jpg?width=1200&height=1200&quality=85&auto=format&fit=crop&s=d456a2af571d980d8b2985472c262b31' ,
1033+ stringAttributes : [ ] ,
1034+ numberAttributes : [ ] ,
1035+ }
1036+ const encodedMetadata = await getEncodedMetadata ( sbt , metadata )
1037+ await expect (
1038+ sbt
1039+ . connect ( signers . minterA )
1040+ . mint ( signers . userA . address , encodedMetadata )
1041+ )
1042+ . to . emit ( sbt , 'Minted' )
1043+ . withArgs ( 1 , signers . userA . address )
1044+
1045+ await expect (
1046+ sbt . connect ( signers . proxyAdmin ) . tokenURI ( 1 )
1047+ ) . to . be . revertedWith (
1048+ 'TransparentUpgradeableProxy: admin cannot fallback to proxy target'
1049+ )
1050+ } )
1051+
9091052 it ( 'The setTokenURI function should function correctly for no attributes' , async ( ) => {
9101053 const { sbt } = await init ( )
9111054 const signers = await getSigners ( )
0 commit comments