@@ -45,6 +45,7 @@ import {
45
45
Perm ,
46
46
RestrictionType ,
47
47
PERCENTAGE_DECIMALS ,
48
+ ErrorCode ,
48
49
} from '../../../types' ;
49
50
50
51
interface ChangedExemptWalletListSubscribeAsyncParams extends SubscribeAsyncParams {
@@ -354,8 +355,12 @@ export default class VolumeRestrictionTransferManagerWrapper extends ModuleWrapp
354
355
}
355
356
356
357
public unpause = async ( params : TxParams ) => {
357
- assert . assert ( await this . paused ( ) , 'Controller not currently paused' ) ;
358
- assert . assert ( await this . isCallerTheSecurityTokenOwner ( params . txData ) , 'Sender is not owner' ) ;
358
+ assert . assert ( await this . paused ( ) , ErrorCode . PreconditionRequired , 'Controller not currently paused' ) ;
359
+ assert . assert (
360
+ await this . isCallerTheSecurityTokenOwner ( params . txData ) ,
361
+ ErrorCode . Unauthorized ,
362
+ 'Sender is not owner' ,
363
+ ) ;
359
364
return ( await this . contract ) . unpause . sendTransactionAsync ( params . txData , params . safetyFactor ) ;
360
365
} ;
361
366
@@ -364,8 +369,12 @@ export default class VolumeRestrictionTransferManagerWrapper extends ModuleWrapp
364
369
} ;
365
370
366
371
public pause = async ( params : TxParams ) => {
367
- assert . assert ( ! ( await this . paused ( ) ) , 'Controller currently paused' ) ;
368
- assert . assert ( await this . isCallerTheSecurityTokenOwner ( params . txData ) , 'Sender is not owner' ) ;
372
+ assert . assert ( ! ( await this . paused ( ) ) , ErrorCode . ContractPaused , 'Controller currently paused' ) ;
373
+ assert . assert (
374
+ await this . isCallerTheSecurityTokenOwner ( params . txData ) ,
375
+ ErrorCode . Unauthorized ,
376
+ 'Sender is not owner' ,
377
+ ) ;
369
378
return ( await this . contract ) . pause . sendTransactionAsync ( params . txData , params . safetyFactor ) ;
370
379
} ;
371
380
@@ -454,6 +463,7 @@ export default class VolumeRestrictionTransferManagerWrapper extends ModuleWrapp
454
463
assert . isNonZeroETHAddressHex ( 'wallet' , params . wallet ) ;
455
464
assert . assert (
456
465
! ( await this . getExemptAddress ( ) ) . includes ( params . wallet ) === params . change ,
466
+ ErrorCode . PreconditionRequired ,
457
467
'There will be no change to exempt list' ,
458
468
) ;
459
469
return ( await this . contract ) . changeExemptWalletList . sendTransactionAsync (
@@ -465,9 +475,17 @@ export default class VolumeRestrictionTransferManagerWrapper extends ModuleWrapp
465
475
} ;
466
476
467
477
public addIndividualRestriction = async ( params : IndividualRestrictionParams ) => {
468
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
478
+ assert . assert (
479
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
480
+ ErrorCode . Unauthorized ,
481
+ 'Caller is not allowed' ,
482
+ ) ;
469
483
assert . isNonZeroETHAddressHex ( 'holder' , params . holder ) ;
470
- assert . assert ( ! ( await this . getExemptAddress ( ) ) . includes ( params . holder ) , 'Holder is exempt from restriction' ) ;
484
+ assert . assert (
485
+ ! ( await this . getExemptAddress ( ) ) . includes ( params . holder ) ,
486
+ ErrorCode . PreconditionRequired ,
487
+ 'Holder is exempt from restriction' ,
488
+ ) ;
471
489
this . checkRestrictionInputParams (
472
490
params . startTime ,
473
491
params . endTime ,
@@ -489,7 +507,11 @@ export default class VolumeRestrictionTransferManagerWrapper extends ModuleWrapp
489
507
} ;
490
508
491
509
public addIndividualDailyRestriction = async ( params : IndividualRestrictionParams ) => {
492
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
510
+ assert . assert (
511
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
512
+ ErrorCode . Unauthorized ,
513
+ 'Caller is not allowed' ,
514
+ ) ;
493
515
assert . isNonZeroETHAddressHex ( 'holder' , params . holder ) ;
494
516
this . checkRestrictionInputParams ( params . startTime , params . endTime , params . allowedTokens , params . restrictionType , 1 ) ;
495
517
const decimals = await this . decimalsByRestrictionType ( params . restrictionType ) ;
@@ -505,13 +527,18 @@ export default class VolumeRestrictionTransferManagerWrapper extends ModuleWrapp
505
527
} ;
506
528
507
529
public addIndividualDailyRestrictionMulti = async ( params : IndividualDailyRestrictionMultiParams ) => {
508
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
530
+ assert . assert (
531
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
532
+ ErrorCode . Unauthorized ,
533
+ 'Caller is not allowed' ,
534
+ ) ;
509
535
params . holders . forEach ( address => assert . isNonZeroETHAddressHex ( 'holders' , address ) ) ;
510
536
assert . assert (
511
537
params . startTimes . length === params . allowedTokens . length &&
512
538
params . startTimes . length === params . restrictionTypes . length &&
513
539
params . startTimes . length === params . holders . length &&
514
540
params . startTimes . length === params . endTimes . length ,
541
+ ErrorCode . MismatchedArrayLength ,
515
542
'Array lengths missmatch' ,
516
543
) ;
517
544
let restrictions = [ ] ;
@@ -542,11 +569,16 @@ export default class VolumeRestrictionTransferManagerWrapper extends ModuleWrapp
542
569
} ;
543
570
544
571
public addIndividualRestrictionMulti = async ( params : IndividualRestrictionMultiParams ) => {
545
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
572
+ assert . assert (
573
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
574
+ ErrorCode . Unauthorized ,
575
+ 'Caller is not allowed' ,
576
+ ) ;
546
577
params . holders . forEach ( address => assert . isNonZeroETHAddressHex ( 'holders' , address ) ) ;
547
578
const exemptAddress = await this . getExemptAddress ( ) ;
548
579
assert . assert (
549
580
! exemptAddress . some ( address => params . holders . includes ( address ) ) ,
581
+ ErrorCode . PreconditionRequired ,
550
582
'Holder is exempt from restriction' ,
551
583
) ;
552
584
assert . assert (
@@ -555,6 +587,7 @@ export default class VolumeRestrictionTransferManagerWrapper extends ModuleWrapp
555
587
params . startTimes . length === params . rollingPeriodInDays . length &&
556
588
params . startTimes . length === params . holders . length &&
557
589
params . startTimes . length === params . endTimes . length ,
590
+ ErrorCode . MismatchedArrayLength ,
558
591
'Array lengths missmatch' ,
559
592
) ;
560
593
let restrictions = [ ] ;
@@ -586,7 +619,11 @@ export default class VolumeRestrictionTransferManagerWrapper extends ModuleWrapp
586
619
} ;
587
620
588
621
public addDefaultRestriction = async ( params : RestrictionParams ) => {
589
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
622
+ assert . assert (
623
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
624
+ ErrorCode . Unauthorized ,
625
+ 'Caller is not allowed' ,
626
+ ) ;
590
627
this . checkRestrictionInputParams (
591
628
params . startTime ,
592
629
params . endTime ,
@@ -607,7 +644,11 @@ export default class VolumeRestrictionTransferManagerWrapper extends ModuleWrapp
607
644
} ;
608
645
609
646
public addDefaultDailyRestriction = async ( params : DailyRestrictionParams ) => {
610
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
647
+ assert . assert (
648
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
649
+ ErrorCode . Unauthorized ,
650
+ 'Caller is not allowed' ,
651
+ ) ;
611
652
this . checkRestrictionInputParams ( params . startTime , params . endTime , params . allowedTokens , params . restrictionType , 1 ) ;
612
653
const decimals = await this . decimalsByRestrictionType ( params . restrictionType ) ;
613
654
return ( await this . contract ) . addDefaultDailyRestriction . sendTransactionAsync (
@@ -621,7 +662,11 @@ export default class VolumeRestrictionTransferManagerWrapper extends ModuleWrapp
621
662
} ;
622
663
623
664
public removeIndividualRestriction = async ( params : HolderIndividualRestrictionParams ) => {
624
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
665
+ assert . assert (
666
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
667
+ ErrorCode . Unauthorized ,
668
+ 'Caller is not allowed' ,
669
+ ) ;
625
670
assert . isNotDateZero (
626
671
( await this . getIndividualRestriction ( { investor : params . investor } ) ) . endTime ,
627
672
'Individual Restriction not set with end time' ,
@@ -635,7 +680,11 @@ export default class VolumeRestrictionTransferManagerWrapper extends ModuleWrapp
635
680
} ;
636
681
637
682
public removeIndividualRestrictionMulti = async ( params : RemoveIndividualRestrictionMultiParams ) => {
638
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
683
+ assert . assert (
684
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
685
+ ErrorCode . Unauthorized ,
686
+ 'Caller is not allowed' ,
687
+ ) ;
639
688
params . holders . forEach ( address => assert . isNonZeroETHAddressHex ( 'holders' , address ) ) ;
640
689
await Promise . all (
641
690
params . holders . map ( async holder =>
@@ -653,7 +702,11 @@ export default class VolumeRestrictionTransferManagerWrapper extends ModuleWrapp
653
702
} ;
654
703
655
704
public removeIndividualDailyRestriction = async ( params : HolderIndividualRestrictionParams ) => {
656
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
705
+ assert . assert (
706
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
707
+ ErrorCode . Unauthorized ,
708
+ 'Caller is not allowed' ,
709
+ ) ;
657
710
assert . isNotDateZero (
658
711
( await this . getIndividualDailyRestriction ( { investor : params . investor } ) ) . endTime ,
659
712
'Individual Daily Restriction not set with end time' ,
@@ -667,7 +720,11 @@ export default class VolumeRestrictionTransferManagerWrapper extends ModuleWrapp
667
720
} ;
668
721
669
722
public removeIndividualDailyRestrictionMulti = async ( params : RemoveIndividualRestrictionMultiParams ) => {
670
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
723
+ assert . assert (
724
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
725
+ ErrorCode . Unauthorized ,
726
+ 'Caller is not allowed' ,
727
+ ) ;
671
728
await Promise . all (
672
729
params . holders . map ( async holder =>
673
730
assert . isNotDateZero (
@@ -685,13 +742,21 @@ export default class VolumeRestrictionTransferManagerWrapper extends ModuleWrapp
685
742
} ;
686
743
687
744
public removeDefaultRestriction = async ( params : TxParams ) => {
688
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
745
+ assert . assert (
746
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
747
+ ErrorCode . Unauthorized ,
748
+ 'Caller is not allowed' ,
749
+ ) ;
689
750
assert . isNotDateZero ( ( await this . getDefaultRestriction ( ) ) . endTime , 'Individual Restriction not set with end time' ) ;
690
751
return ( await this . contract ) . removeDefaultRestriction . sendTransactionAsync ( params . txData , params . safetyFactor ) ;
691
752
} ;
692
753
693
754
public removeDefaultDailyRestriction = async ( params : TxParams ) => {
694
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
755
+ assert . assert (
756
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
757
+ ErrorCode . Unauthorized ,
758
+ 'Caller is not allowed' ,
759
+ ) ;
695
760
assert . isNotDateZero (
696
761
( await this . getDefaultDailyRestriction ( ) ) . endTime ,
697
762
'Individual Restriction not set with end time' ,
@@ -700,7 +765,11 @@ export default class VolumeRestrictionTransferManagerWrapper extends ModuleWrapp
700
765
} ;
701
766
702
767
public modifyIndividualRestriction = async ( params : IndividualRestrictionParams ) => {
703
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
768
+ assert . assert (
769
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
770
+ ErrorCode . Unauthorized ,
771
+ 'Caller is not allowed' ,
772
+ ) ;
704
773
assert . isNonZeroETHAddressHex ( 'holder' , params . holder ) ;
705
774
this . checkRestrictionInputParams (
706
775
params . startTime ,
@@ -723,7 +792,11 @@ export default class VolumeRestrictionTransferManagerWrapper extends ModuleWrapp
723
792
} ;
724
793
725
794
public modifyIndividualDailyRestriction = async ( params : IndividualDailyRestrictionParams ) => {
726
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
795
+ assert . assert (
796
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
797
+ ErrorCode . Unauthorized ,
798
+ 'Caller is not allowed' ,
799
+ ) ;
727
800
assert . isNonZeroETHAddressHex ( 'holder' , params . holder ) ;
728
801
this . checkRestrictionInputParams ( params . startTime , params . endTime , params . allowedTokens , params . restrictionType , 1 ) ;
729
802
const decimals = await this . decimalsByRestrictionType ( params . restrictionType ) ;
@@ -739,13 +812,18 @@ export default class VolumeRestrictionTransferManagerWrapper extends ModuleWrapp
739
812
} ;
740
813
741
814
public modifyIndividualDailyRestrictionMulti = async ( params : IndividualDailyRestrictionMultiParams ) => {
742
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
815
+ assert . assert (
816
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
817
+ ErrorCode . Unauthorized ,
818
+ 'Caller is not allowed' ,
819
+ ) ;
743
820
params . holders . forEach ( address => assert . isNonZeroETHAddressHex ( 'holders' , address ) ) ;
744
821
assert . assert (
745
822
params . startTimes . length === params . allowedTokens . length &&
746
823
params . startTimes . length === params . restrictionTypes . length &&
747
824
params . startTimes . length === params . holders . length &&
748
825
params . startTimes . length === params . endTimes . length ,
826
+ ErrorCode . MismatchedArrayLength ,
749
827
'Array lengths missmatch' ,
750
828
) ;
751
829
let restrictions = [ ] ;
@@ -776,14 +854,19 @@ export default class VolumeRestrictionTransferManagerWrapper extends ModuleWrapp
776
854
} ;
777
855
778
856
public modifyIndividualRestrictionMulti = async ( params : IndividualRestrictionMultiParams ) => {
779
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
857
+ assert . assert (
858
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
859
+ ErrorCode . Unauthorized ,
860
+ 'Caller is not allowed' ,
861
+ ) ;
780
862
params . holders . forEach ( address => assert . isNonZeroETHAddressHex ( 'holders' , address ) ) ;
781
863
assert . assert (
782
864
params . startTimes . length === params . allowedTokens . length &&
783
865
params . startTimes . length === params . restrictionTypes . length &&
784
866
params . startTimes . length === params . rollingPeriodInDays . length &&
785
867
params . startTimes . length === params . holders . length &&
786
868
params . startTimes . length === params . endTimes . length ,
869
+ ErrorCode . MismatchedArrayLength ,
787
870
'Array lengths missmatch' ,
788
871
) ;
789
872
let restrictions = [ ] ;
@@ -815,7 +898,11 @@ export default class VolumeRestrictionTransferManagerWrapper extends ModuleWrapp
815
898
} ;
816
899
817
900
public modifyDefaultRestriction = async ( params : RestrictionParams ) => {
818
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
901
+ assert . assert (
902
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
903
+ ErrorCode . Unauthorized ,
904
+ 'Caller is not allowed' ,
905
+ ) ;
819
906
this . checkRestrictionInputParams (
820
907
params . startTime ,
821
908
params . endTime ,
@@ -836,7 +923,11 @@ export default class VolumeRestrictionTransferManagerWrapper extends ModuleWrapp
836
923
} ;
837
924
838
925
public modifyDefaultDailyRestriction = async ( params : DailyRestrictionParams ) => {
839
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
926
+ assert . assert (
927
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
928
+ ErrorCode . Unauthorized ,
929
+ 'Caller is not allowed' ,
930
+ ) ;
840
931
this . checkRestrictionInputParams ( params . startTime , params . endTime , params . allowedTokens , params . restrictionType , 1 ) ;
841
932
const decimals = await this . decimalsByRestrictionType ( params . restrictionType ) ;
842
933
return ( await this . contract ) . modifyDefaultDailyRestriction . sendTransactionAsync (
@@ -963,10 +1054,15 @@ export default class VolumeRestrictionTransferManagerWrapper extends ModuleWrapp
963
1054
if ( restrictionType === RestrictionType . Percentage ) {
964
1055
assert . isPercentage ( 'allowed tokens' , allowedTokens ) ;
965
1056
}
966
- assert . assert ( rollingPeriodInDays <= 365 && rollingPeriodInDays >= 1 , 'Invalid number of days in rolling period' ) ;
1057
+ assert . assert (
1058
+ rollingPeriodInDays <= 365 && rollingPeriodInDays >= 1 ,
1059
+ ErrorCode . InvalidData ,
1060
+ 'Invalid number of days in rolling period' ,
1061
+ ) ;
967
1062
const diffDays = Math . ceil ( Math . abs ( endTime . getTime ( ) - startTime . getTime ( ) ) / ( 1000 * 3600 * 24 ) ) ;
968
1063
assert . assert (
969
1064
new BigNumber ( diffDays ) . isGreaterThanOrEqualTo ( rollingPeriodInDays ) ,
1065
+ ErrorCode . InvalidData ,
970
1066
'Invalid times, rollingPeriodInDays must have less days than the duration' ,
971
1067
) ;
972
1068
} ;
0 commit comments