@@ -31,6 +31,7 @@ import {
31
31
GetLogs ,
32
32
Perm ,
33
33
TransferStatusCode ,
34
+ ErrorCode ,
34
35
} from '../../../types' ;
35
36
import {
36
37
numberToBigNumber ,
@@ -422,8 +423,12 @@ export default class VestingEscrowWalletWrapper extends ModuleWrapper {
422
423
}
423
424
424
425
public unpause = async ( params : TxParams ) => {
425
- assert . assert ( await this . paused ( ) , 'Controller not currently paused' ) ;
426
- assert . assert ( await this . isCallerTheSecurityTokenOwner ( params . txData ) , 'Sender is not owner' ) ;
426
+ assert . assert ( await this . paused ( ) , ErrorCode . PreconditionRequired , 'Controller not currently paused' ) ;
427
+ assert . assert (
428
+ await this . isCallerTheSecurityTokenOwner ( params . txData ) ,
429
+ ErrorCode . Unauthorized ,
430
+ 'Sender is not owner' ,
431
+ ) ;
427
432
return ( await this . contract ) . unpause . sendTransactionAsync ( params . txData , params . safetyFactor ) ;
428
433
} ;
429
434
@@ -432,8 +437,12 @@ export default class VestingEscrowWalletWrapper extends ModuleWrapper {
432
437
} ;
433
438
434
439
public pause = async ( params : TxParams ) => {
435
- assert . assert ( ! ( await this . paused ( ) ) , 'Controller currently paused' ) ;
436
- assert . assert ( await this . isCallerTheSecurityTokenOwner ( params . txData ) , 'Sender is not owner' ) ;
440
+ assert . assert ( ! ( await this . paused ( ) ) , ErrorCode . ContractPaused , 'Controller currently paused' ) ;
441
+ assert . assert (
442
+ await this . isCallerTheSecurityTokenOwner ( params . txData ) ,
443
+ ErrorCode . Unauthorized ,
444
+ 'Sender is not owner' ,
445
+ ) ;
437
446
return ( await this . contract ) . pause . sendTransactionAsync ( params . txData , params . safetyFactor ) ;
438
447
} ;
439
448
@@ -471,7 +480,11 @@ export default class VestingEscrowWalletWrapper extends ModuleWrapper {
471
480
* Used to change the treasury wallet address
472
481
*/
473
482
public changeTreasuryWallet = async ( params : ChangeTreasuryWalletParams ) => {
474
- assert . assert ( await this . isCallerTheSecurityTokenOwner ( params . txData ) , 'The caller must be the ST owner' ) ;
483
+ assert . assert (
484
+ await this . isCallerTheSecurityTokenOwner ( params . txData ) ,
485
+ ErrorCode . Unauthorized ,
486
+ 'The caller must be the ST owner' ,
487
+ ) ;
475
488
return ( await this . contract ) . changeTreasuryWallet . sendTransactionAsync (
476
489
params . newTreasuryWallet ,
477
490
params . txData ,
@@ -483,17 +496,25 @@ export default class VestingEscrowWalletWrapper extends ModuleWrapper {
483
496
* Used to deposit tokens from treasury wallet to the vesting escrow wallet
484
497
*/
485
498
public depositTokens = async ( params : DepositTokensParams ) => {
486
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
499
+ assert . assert (
500
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
501
+ ErrorCode . Unauthorized ,
502
+ 'Caller is not allowed' ,
503
+ ) ;
487
504
488
- assert . assert ( params . numberOfTokens . toNumber ( ) > 0 , 'Number of tokens should be > 0' ) ;
505
+ assert . assert ( params . numberOfTokens . toNumber ( ) > 0 , ErrorCode . InvalidData , 'Number of tokens should be > 0' ) ;
489
506
const decimals = await ( await this . securityTokenContract ( ) ) . decimals . callAsync ( ) ;
490
507
const canTransferFromResult = await ( await this . securityTokenContract ( ) ) . canTransferFrom . callAsync (
491
508
await this . getCallerAddress ( params . txData ) ,
492
509
await this . address ( ) ,
493
510
valueToWei ( params . numberOfTokens , decimals ) ,
494
511
'0x00' ,
495
512
) ;
496
- assert . assert ( canTransferFromResult [ 0 ] === TransferStatusCode . TransferSuccess , 'Failed transferFrom' ) ;
513
+ assert . assert (
514
+ canTransferFromResult [ 0 ] === TransferStatusCode . TransferSuccess ,
515
+ ErrorCode . InvalidTransfer ,
516
+ 'Failed transferFrom' ,
517
+ ) ;
497
518
498
519
return ( await this . contract ) . depositTokens . sendTransactionAsync (
499
520
valueToWei ( params . numberOfTokens , decimals ) ,
@@ -506,13 +527,18 @@ export default class VestingEscrowWalletWrapper extends ModuleWrapper {
506
527
* Sends unassigned tokens to the treasury wallet
507
528
*/
508
529
public sendToTreasury = async ( params : SendToTreasuryParams ) => {
509
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Operator ) , 'Caller is not allowed' ) ;
510
- assert . assert ( params . amount . toNumber ( ) > 0 , 'Amount cannot be zero' ) ;
530
+ assert . assert (
531
+ await this . isCallerAllowed ( params . txData , Perm . Operator ) ,
532
+ ErrorCode . Unauthorized ,
533
+ 'Caller is not allowed' ,
534
+ ) ;
535
+ assert . assert ( params . amount . toNumber ( ) > 0 , ErrorCode . InvalidData , 'Amount cannot be zero' ) ;
511
536
512
537
const unassignedTokens = await this . unassignedTokens ( ) ;
513
538
const decimals = await ( await this . securityTokenContract ( ) ) . decimals . callAsync ( ) ;
514
539
assert . assert (
515
540
params . amount . isLessThanOrEqualTo ( valueToWei ( unassignedTokens , decimals ) ) ,
541
+ ErrorCode . InvalidData ,
516
542
'Amount is greater than unassigned tokens' ,
517
543
) ;
518
544
@@ -521,7 +547,11 @@ export default class VestingEscrowWalletWrapper extends ModuleWrapper {
521
547
valueToWei ( params . amount , decimals ) ,
522
548
'0x00' ,
523
549
) ;
524
- assert . assert ( canTransferResult [ 0 ] === TransferStatusCode . TransferSuccess , 'Transfer failed' ) ;
550
+ assert . assert (
551
+ canTransferResult [ 0 ] === TransferStatusCode . TransferSuccess ,
552
+ ErrorCode . InvalidTransfer ,
553
+ 'Transfer failed' ,
554
+ ) ;
525
555
526
556
return ( await this . contract ) . sendToTreasury . sendTransactionAsync (
527
557
valueToWei ( params . amount , decimals ) ,
@@ -541,7 +571,11 @@ export default class VestingEscrowWalletWrapper extends ModuleWrapper {
541
571
* Pushes available tokens to the beneficiary's address
542
572
*/
543
573
public pushAvailableTokens = async ( params : PushAvailableTokensParams ) => {
544
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Operator ) , 'Caller is not allowed' ) ;
574
+ assert . assert (
575
+ await this . isCallerAllowed ( params . txData , Perm . Operator ) ,
576
+ ErrorCode . Unauthorized ,
577
+ 'Caller is not allowed' ,
578
+ ) ;
545
579
546
580
return ( await this . contract ) . pushAvailableTokens . sendTransactionAsync (
547
581
params . beneficiary ,
@@ -554,17 +588,25 @@ export default class VestingEscrowWalletWrapper extends ModuleWrapper {
554
588
* Used to withdraw available tokens by beneficiary
555
589
*/
556
590
public pullAvailableTokens = async ( params : TxParams ) => {
557
- assert . assert ( ! ( await this . paused ( ) ) , 'Contract currently paused' ) ;
591
+ assert . assert ( ! ( await this . paused ( ) ) , ErrorCode . ContractPaused , 'Contract currently paused' ) ;
558
592
return ( await this . contract ) . pullAvailableTokens . sendTransactionAsync ( params . txData , params . safetyFactor ) ;
559
593
} ;
560
594
561
595
/**
562
596
* Adds template that can be used for creating schedule
563
597
*/
564
598
public addTemplate = async ( params : AddTemplateParams ) => {
565
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
566
- assert . assert ( params . name !== '' , 'Invalid name' ) ;
567
- assert . assert ( ! ( await this . getAllTemplateNames ( ) ) . includes ( params . name ) , 'Template name already exists' ) ;
599
+ assert . assert (
600
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
601
+ ErrorCode . Unauthorized ,
602
+ 'Caller is not allowed' ,
603
+ ) ;
604
+ assert . assert ( params . name !== '' , ErrorCode . InvalidData , 'Invalid name' ) ;
605
+ assert . assert (
606
+ ! ( await this . getAllTemplateNames ( ) ) . includes ( params . name ) ,
607
+ ErrorCode . AlreadyExists ,
608
+ 'Template name already exists' ,
609
+ ) ;
568
610
await this . validateTemplate ( params . numberOfTokens , params . duration , params . frequency ) ;
569
611
const decimals = await ( await this . securityTokenContract ( ) ) . decimals . callAsync ( ) ;
570
612
return ( await this . contract ) . addTemplate . sendTransactionAsync (
@@ -581,9 +623,13 @@ export default class VestingEscrowWalletWrapper extends ModuleWrapper {
581
623
* Removes template with a given name
582
624
*/
583
625
public removeTemplate = async ( params : RemoveTemplateParams ) => {
584
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
585
- assert . assert ( params . name !== '' , 'Invalid name' ) ;
586
- assert . assert ( ( await this . getAllTemplateNames ( ) ) . includes ( params . name ) , 'Template not found' ) ;
626
+ assert . assert (
627
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
628
+ ErrorCode . Unauthorized ,
629
+ 'Caller is not allowed' ,
630
+ ) ;
631
+ assert . assert ( params . name !== '' , ErrorCode . InvalidData , 'Invalid name' ) ;
632
+ assert . assert ( ( await this . getAllTemplateNames ( ) ) . includes ( params . name ) , ErrorCode . NotFound , 'Template not found' ) ;
587
633
// TODO 3.1: require(templateToUsers[_name].length == 0, "Template is used");
588
634
return ( await this . contract ) . removeTemplate . sendTransactionAsync (
589
635
stringToBytes32 ( params . name ) ,
@@ -614,9 +660,17 @@ export default class VestingEscrowWalletWrapper extends ModuleWrapper {
614
660
* Adds a vesting schedule for the beneficiary address
615
661
*/
616
662
public addSchedule = async ( params : AddScheduleParams ) => {
617
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
618
- assert . assert ( params . templateName !== '' , 'Invalid name' ) ;
619
- assert . assert ( ! ( await this . getAllTemplateNames ( ) ) . includes ( params . templateName ) , 'Template name already exists' ) ;
663
+ assert . assert (
664
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
665
+ ErrorCode . Unauthorized ,
666
+ 'Caller is not allowed' ,
667
+ ) ;
668
+ assert . assert ( params . templateName !== '' , ErrorCode . InvalidData , 'Invalid name' ) ;
669
+ assert . assert (
670
+ ! ( await this . getAllTemplateNames ( ) ) . includes ( params . templateName ) ,
671
+ ErrorCode . AlreadyExists ,
672
+ 'Template name already exists' ,
673
+ ) ;
620
674
await this . validateTemplate ( params . numberOfTokens , params . duration , params . frequency ) ;
621
675
await this . validateAddSchedule ( params . beneficiary , params . templateName , params . startTime ) ;
622
676
const decimals = await ( await this . securityTokenContract ( ) ) . decimals . callAsync ( ) ;
@@ -636,7 +690,11 @@ export default class VestingEscrowWalletWrapper extends ModuleWrapper {
636
690
* Adds a vesting schedule for the beneficiary address from a template
637
691
*/
638
692
public addScheduleFromTemplate = async ( params : AddScheduleFromTemplateParams ) => {
639
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
693
+ assert . assert (
694
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
695
+ ErrorCode . Unauthorized ,
696
+ 'Caller is not allowed' ,
697
+ ) ;
640
698
await this . validateAddScheduleFromTemplate ( params . beneficiary , params . templateName , params . startTime ) ;
641
699
return ( await this . contract ) . addScheduleFromTemplate . sendTransactionAsync (
642
700
params . beneficiary ,
@@ -651,9 +709,13 @@ export default class VestingEscrowWalletWrapper extends ModuleWrapper {
651
709
* Modifies a vesting schedule for a beneficiary address
652
710
*/
653
711
public modifySchedule = async ( params : ModifyScheduleParams ) => {
654
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
712
+ assert . assert (
713
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
714
+ ErrorCode . Unauthorized ,
715
+ 'Caller is not allowed' ,
716
+ ) ;
655
717
this . checkSchedule ( params . beneficiary ) ;
656
- assert . assert ( params . startTime . getTime ( ) > Date . now ( ) , 'Date in the past' ) ;
718
+ assert . assert ( params . startTime . getTime ( ) > Date . now ( ) , ErrorCode . TooEarly , 'Date in the past' ) ;
657
719
// TODO: require(now < schedule.startTime, "Schedule started");
658
720
return ( await this . contract ) . modifySchedule . sendTransactionAsync (
659
721
params . beneficiary ,
@@ -668,7 +730,11 @@ export default class VestingEscrowWalletWrapper extends ModuleWrapper {
668
730
* Revokes a vesting schedule with a given template name for a given beneficiary
669
731
*/
670
732
public revokeSchedule = async ( params : RevokeScheduleParams ) => {
671
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
733
+ assert . assert (
734
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
735
+ ErrorCode . Unauthorized ,
736
+ 'Caller is not allowed' ,
737
+ ) ;
672
738
this . checkSchedule ( params . beneficiary ) ;
673
739
// TODO: _sendTokensPerSchedule assert
674
740
return ( await this . contract ) . revokeSchedule . sendTransactionAsync (
@@ -683,7 +749,11 @@ export default class VestingEscrowWalletWrapper extends ModuleWrapper {
683
749
* Revokes all vesting schedules for a given beneficiary address
684
750
*/
685
751
public revokeAllSchedules = async ( params : RevokeAllSchedulesParams ) => {
686
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
752
+ assert . assert (
753
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
754
+ ErrorCode . Unauthorized ,
755
+ 'Caller is not allowed' ,
756
+ ) ;
687
757
assert . isNonZeroETHAddressHex ( 'beneficiary' , params . beneficiary ) ;
688
758
return ( await this . contract ) . revokeAllSchedules . sendTransactionAsync (
689
759
params . beneficiary ,
@@ -756,7 +826,11 @@ export default class VestingEscrowWalletWrapper extends ModuleWrapper {
756
826
* Used to bulk add vesting schedules for each of the beneficiaries
757
827
*/
758
828
public pushAvailableTokensMulti = async ( params : PushAvailableTokensMultiParams ) => {
759
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Operator ) , 'Caller is not allowed' ) ;
829
+ assert . assert (
830
+ await this . isCallerAllowed ( params . txData , Perm . Operator ) ,
831
+ ErrorCode . Unauthorized ,
832
+ 'Caller is not allowed' ,
833
+ ) ;
760
834
// TODO: require(_toIndex < beneficiaries.length, "Array out of bound");
761
835
return ( await this . contract ) . pushAvailableTokensMulti . sendTransactionAsync (
762
836
numberToBigNumber ( params . fromIndex ) ,
@@ -770,21 +844,26 @@ export default class VestingEscrowWalletWrapper extends ModuleWrapper {
770
844
* Used to bulk add vesting schedules for each of beneficiary
771
845
*/
772
846
public addScheduleMulti = async ( params : AddScheduleMultiParams ) => {
773
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
847
+ assert . assert (
848
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
849
+ ErrorCode . Unauthorized ,
850
+ 'Caller is not allowed' ,
851
+ ) ;
774
852
assert . assert (
775
853
params . beneficiaries . length === params . templateNames . length &&
776
854
params . beneficiaries . length === params . numberOfTokens . length &&
777
855
params . beneficiaries . length === params . durations . length &&
778
856
params . beneficiaries . length === params . frequencies . length &&
779
857
params . beneficiaries . length === params . startTimes . length ,
858
+ ErrorCode . MismatchedArrayLength ,
780
859
'Arrays sizes mismatch' ,
781
860
) ;
782
861
783
862
const resultGetAllTemplatesNames = [ ] ;
784
863
const resultValidateTemplate = [ ] ;
785
864
const resultValidateAddScheduleFromTemplate = [ ] ;
786
865
for ( let i = 0 ; i < params . beneficiaries . length ; i += 1 ) {
787
- assert . assert ( params . templateNames [ i ] !== '' , 'Invalid name' ) ;
866
+ assert . assert ( params . templateNames [ i ] !== '' , ErrorCode . InvalidData , 'Invalid name' ) ;
788
867
resultGetAllTemplatesNames . push ( this . getAllTemplateNames ( ) ) ;
789
868
resultValidateTemplate . push (
790
869
this . validateTemplate ( params . numberOfTokens [ i ] , params . durations [ i ] , params . frequencies [ i ] ) ,
@@ -795,7 +874,11 @@ export default class VestingEscrowWalletWrapper extends ModuleWrapper {
795
874
}
796
875
const getAllTemplatesNames = await Promise . all ( resultGetAllTemplatesNames ) ;
797
876
getAllTemplatesNames . forEach ( ( templateName , i ) => {
798
- assert . assert ( ! templateName . includes ( params . templateNames [ i ] ) , 'Template name already exists' ) ;
877
+ assert . assert (
878
+ ! templateName . includes ( params . templateNames [ i ] ) ,
879
+ ErrorCode . AlreadyExists ,
880
+ 'Template name already exists' ,
881
+ ) ;
799
882
} ) ;
800
883
await Promise . all ( resultValidateTemplate ) ;
801
884
await Promise . all ( resultValidateAddScheduleFromTemplate ) ;
@@ -826,7 +909,11 @@ export default class VestingEscrowWalletWrapper extends ModuleWrapper {
826
909
* Used to bulk add vesting schedules from templates for each of the beneficiary addresses
827
910
*/
828
911
public addScheduleFromTemplateMulti = async ( params : AddScheduleFromTemplateMultiParams ) => {
829
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
912
+ assert . assert (
913
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
914
+ ErrorCode . Unauthorized ,
915
+ 'Caller is not allowed' ,
916
+ ) ;
830
917
const resultsValidateAddScheduleFromTemplate = [ ] ;
831
918
for ( let i = 0 ; i < params . beneficiaries . length ; i += 1 ) {
832
919
resultsValidateAddScheduleFromTemplate . push (
@@ -851,7 +938,11 @@ export default class VestingEscrowWalletWrapper extends ModuleWrapper {
851
938
* Used to bulk revoke vesting schedules for each of the beneficiaries
852
939
*/
853
940
public revokeSchedulesMulti = async ( params : RevokeSchedulesMultiParams ) => {
854
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
941
+ assert . assert (
942
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
943
+ ErrorCode . Unauthorized ,
944
+ 'Caller is not allowed' ,
945
+ ) ;
855
946
params . beneficiaries . forEach ( beneficiary => {
856
947
assert . isNonZeroETHAddressHex ( 'beneficiary' , beneficiary ) ;
857
948
} ) ;
@@ -866,16 +957,21 @@ export default class VestingEscrowWalletWrapper extends ModuleWrapper {
866
957
* Used to bulk modify vesting schedules for each of the beneficiaries
867
958
*/
868
959
public modifyScheduleMulti = async ( params : ModifyScheduleMultiParams ) => {
869
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
960
+ assert . assert (
961
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
962
+ ErrorCode . Unauthorized ,
963
+ 'Caller is not allowed' ,
964
+ ) ;
870
965
assert . assert (
871
966
params . beneficiaries . length === params . templateNames . length &&
872
967
params . beneficiaries . length === params . startTimes . length ,
968
+ ErrorCode . MismatchedArrayLength ,
873
969
'Arrays sizes mismatch' ,
874
970
) ;
875
971
876
972
for ( let i = 0 ; i < params . beneficiaries . length ; i += 1 ) {
877
973
this . checkSchedule ( params . beneficiaries [ i ] ) ;
878
- assert . assert ( params . startTimes [ i ] . getTime ( ) > Date . now ( ) , 'Date in the past' ) ;
974
+ assert . assert ( params . startTimes [ i ] . getTime ( ) > Date . now ( ) , ErrorCode . TooEarly , 'Date in the past' ) ;
879
975
}
880
976
881
977
return ( await this . contract ) . modifyScheduleMulti . sendTransactionAsync (
@@ -892,26 +988,26 @@ export default class VestingEscrowWalletWrapper extends ModuleWrapper {
892
988
} ;
893
989
894
990
private validateTemplate = async ( numberOfTokens : BigNumber , duration : number , frequency : number ) => {
895
- assert . assert ( numberOfTokens . toNumber ( ) > 0 , 'Zero amount' ) ;
896
- assert . assert ( duration % frequency === 0 , 'Invalid frequency' ) ;
991
+ assert . assert ( numberOfTokens . toNumber ( ) > 0 , ErrorCode . InvalidData , 'Zero amount' ) ;
992
+ assert . assert ( duration % frequency === 0 , ErrorCode . InvalidData , 'Invalid frequency' ) ;
897
993
const periodCount = duration / frequency ;
898
- assert . assert ( numberOfTokens . toNumber ( ) % periodCount === 0 , 'Invalid period count' ) ;
994
+ assert . assert ( numberOfTokens . toNumber ( ) % periodCount === 0 , ErrorCode . InvalidData , 'Invalid period count' ) ;
899
995
const amountPerPeriod = numberOfTokens . toNumber ( ) / periodCount ;
900
996
const granularity = await ( await this . securityTokenContract ( ) ) . granularity . callAsync ( ) ;
901
- assert . assert ( amountPerPeriod % granularity . toNumber ( ) === 0 , 'Invalid granularity' ) ;
997
+ assert . assert ( amountPerPeriod % granularity . toNumber ( ) === 0 , ErrorCode . InvalidData , 'Invalid granularity' ) ;
902
998
} ;
903
999
904
1000
private validateAddSchedule = async ( beneficiary : string , templateName : string , startTime : Date ) => {
905
1001
assert . isNonZeroETHAddressHex ( 'beneficiary' , beneficiary ) ;
906
- assert . assert ( ( await this . getScheduleCount ( { beneficiary } ) ) === 0 , 'Already added' ) ;
907
- assert . assert ( startTime . getTime ( ) > Date . now ( ) , 'Date in the past' ) ;
1002
+ assert . assert ( ( await this . getScheduleCount ( { beneficiary } ) ) === 0 , ErrorCode . AlreadyExists , 'Already added' ) ;
1003
+ assert . assert ( startTime . getTime ( ) > Date . now ( ) , ErrorCode . TooEarly , 'Date in the past' ) ;
908
1004
} ;
909
1005
910
1006
private validateAddScheduleFromTemplate = async ( beneficiary : string , templateName : string , startTime : Date ) => {
911
1007
assert . isNonZeroETHAddressHex ( 'beneficiary' , beneficiary ) ;
912
- assert . assert ( ( await this . getAllTemplateNames ( ) ) . includes ( templateName ) , 'Template not found' ) ;
913
- assert . assert ( ( await this . getScheduleCount ( { beneficiary } ) ) === 0 , 'Already added' ) ;
914
- assert . assert ( startTime . getTime ( ) > Date . now ( ) , 'Date in the past' ) ;
1008
+ assert . assert ( ( await this . getAllTemplateNames ( ) ) . includes ( templateName ) , ErrorCode . NotFound , 'Template not found' ) ;
1009
+ assert . assert ( ( await this . getScheduleCount ( { beneficiary } ) ) === 0 , ErrorCode . AlreadyExists , 'Already added' ) ;
1010
+ assert . assert ( startTime . getTime ( ) > Date . now ( ) , ErrorCode . TooEarly , 'Date in the past' ) ;
915
1011
} ;
916
1012
917
1013
private checkSchedule = ( beneficiary : string ) => {
0 commit comments