@@ -40,7 +40,7 @@ describe('SBTProxy', () => {
40
40
return { sbt, sbtImplementation, sbtProxy, sbtImplementationB }
41
41
}
42
42
43
- describe ( 'SBT proxy tests' , ( ) => {
43
+ describe ( '---- SBT proxy tests------------ ' , ( ) => {
44
44
describe ( 'admin' , ( ) => {
45
45
it ( 'Should return admin correctly if signer is proxyAdmin' , async ( ) => {
46
46
const signers = await getSigners ( )
@@ -460,8 +460,24 @@ describe('SBTProxy', () => {
460
460
} )
461
461
} )
462
462
463
- describe ( 'SBT logic tests' , ( ) => {
463
+ describe ( '---- SBT logic tests------------ ' , ( ) => {
464
464
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
+
465
481
it ( 'The initialize function can only be executed once' , async ( ) => {
466
482
const { sbt } = await init ( )
467
483
await expect (
@@ -474,6 +490,17 @@ describe('SBTProxy', () => {
474
490
} )
475
491
476
492
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
+
477
504
it ( 'The addMinter function can be executed by minterUpdater' , async ( ) => {
478
505
const { sbt } = await init ( )
479
506
const signers = await getSigners ( )
@@ -502,6 +529,17 @@ describe('SBTProxy', () => {
502
529
} )
503
530
504
531
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
+
505
543
it ( 'The removeMinter function can be executed by minterUpdater' , async ( ) => {
506
544
const { sbt } = await init ( )
507
545
const signers = await getSigners ( )
@@ -532,6 +570,18 @@ describe('SBTProxy', () => {
532
570
} )
533
571
534
572
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
+
535
585
it ( 'The mint function should function correctly' , async ( ) => {
536
586
const { sbt } = await init ( )
537
587
const signers = await getSigners ( )
@@ -713,6 +763,26 @@ describe('SBTProxy', () => {
713
763
} )
714
764
715
765
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
+
716
786
it ( 'The transfer function should not work if owner' , async ( ) => {
717
787
const { sbt } = await init ( )
718
788
const signers = await getSigners ( )
@@ -773,6 +843,26 @@ describe('SBTProxy', () => {
773
843
} )
774
844
775
845
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
+
776
866
it ( 'The transfer to address(0) should not work if owner' , async ( ) => {
777
867
const { sbt } = await init ( )
778
868
const signers = await getSigners ( )
@@ -833,6 +923,30 @@ describe('SBTProxy', () => {
833
923
} )
834
924
835
925
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
+
836
950
it ( 'The safeTransfer function should not work if owner' , async ( ) => {
837
951
const sbtContractFactory = await ethers . getContractFactory ( 'SBT' )
838
952
const sbt = sbtContractFactory . attach ( ( await init ( ) ) . sbt . address )
@@ -906,6 +1020,35 @@ describe('SBTProxy', () => {
906
1020
} )
907
1021
908
1022
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
+
909
1052
it ( 'The setTokenURI function should function correctly for no attributes' , async ( ) => {
910
1053
const { sbt } = await init ( )
911
1054
const signers = await getSigners ( )
0 commit comments