@@ -37,6 +37,7 @@ import {
37
37
Perm ,
38
38
TransferType ,
39
39
Partition ,
40
+ ErrorCode ,
40
41
} from '../../../types' ;
41
42
42
43
const ONE_HUNDRED = new BigNumber ( 100 ) ;
@@ -340,8 +341,12 @@ export default class GeneralTransferManagerWrapper extends ModuleWrapper {
340
341
}
341
342
342
343
public unpause = async ( params : TxParams ) => {
343
- assert . assert ( await this . paused ( ) , 'Controller not currently paused' ) ;
344
- assert . assert ( await this . isCallerTheSecurityTokenOwner ( params . txData ) , 'Sender is not owner' ) ;
344
+ assert . assert ( await this . paused ( ) , ErrorCode . PreconditionRequired , 'Controller not currently paused' ) ;
345
+ assert . assert (
346
+ await this . isCallerTheSecurityTokenOwner ( params . txData ) ,
347
+ ErrorCode . Unauthorized ,
348
+ 'Sender is not owner' ,
349
+ ) ;
345
350
return ( await this . contract ) . unpause . sendTransactionAsync ( params . txData , params . safetyFactor ) ;
346
351
} ;
347
352
@@ -350,8 +355,12 @@ export default class GeneralTransferManagerWrapper extends ModuleWrapper {
350
355
} ;
351
356
352
357
public pause = async ( params : TxParams ) => {
353
- assert . assert ( ! ( await this . paused ( ) ) , 'Controller currently paused' ) ;
354
- assert . assert ( await this . isCallerTheSecurityTokenOwner ( params . txData ) , 'Sender is not owner' ) ;
358
+ assert . assert ( ! ( await this . paused ( ) ) , ErrorCode . ContractPaused , 'Controller currently paused' ) ;
359
+ assert . assert (
360
+ await this . isCallerTheSecurityTokenOwner ( params . txData ) ,
361
+ ErrorCode . Unauthorized ,
362
+ 'Sender is not owner' ,
363
+ ) ;
355
364
return ( await this . contract ) . pause . sendTransactionAsync ( params . txData , params . safetyFactor ) ;
356
365
} ;
357
366
@@ -374,7 +383,11 @@ export default class GeneralTransferManagerWrapper extends ModuleWrapper {
374
383
} ;
375
384
376
385
public changeDefaults = async ( params : ChangeDefaultsParams ) => {
377
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
386
+ assert . assert (
387
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
388
+ ErrorCode . Unauthorized ,
389
+ 'Caller is not allowed' ,
390
+ ) ;
378
391
return ( await this . contract ) . changeDefaults . sendTransactionAsync (
379
392
dateToBigNumber ( params . defaultFromTime ) ,
380
393
dateToBigNumber ( params . defaultToTime ) ,
@@ -385,7 +398,11 @@ export default class GeneralTransferManagerWrapper extends ModuleWrapper {
385
398
386
399
public changeIssuanceAddress = async ( params : ChangeIssuanceAddressParams ) => {
387
400
assert . isETHAddressHex ( 'issuanceAddress' , params . issuanceAddress ) ;
388
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
401
+ assert . assert (
402
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
403
+ ErrorCode . Unauthorized ,
404
+ 'Caller is not allowed' ,
405
+ ) ;
389
406
return ( await this . contract ) . changeIssuanceAddress . sendTransactionAsync (
390
407
params . issuanceAddress ,
391
408
params . txData ,
@@ -395,7 +412,11 @@ export default class GeneralTransferManagerWrapper extends ModuleWrapper {
395
412
396
413
public modifyKYCData = async ( params : ModifyKYCDataParams ) => {
397
414
assert . isNonZeroETHAddressHex ( 'investor' , params . investor ) ;
398
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
415
+ assert . assert (
416
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
417
+ ErrorCode . Unauthorized ,
418
+ 'Caller is not allowed' ,
419
+ ) ;
399
420
assert . isLessThanMax64BytesDate ( 'canSendAfter' , params . canSendAfter ) ;
400
421
assert . isLessThanMax64BytesDate ( 'canReceiveAfter' , params . canReceiveAfter ) ;
401
422
assert . isLessThanMax64BytesDate ( 'expiryTime' , params . expiryTime ) ;
@@ -522,14 +543,19 @@ export default class GeneralTransferManagerWrapper extends ModuleWrapper {
522
543
523
544
public modifyKYCDataSigned = async ( params : ModifyKYCDataSignedParams ) => {
524
545
assert . isNonZeroETHAddressHex ( 'investor' , params . investor ) ;
525
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
546
+ assert . assert (
547
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
548
+ ErrorCode . Unauthorized ,
549
+ 'Caller is not allowed' ,
550
+ ) ;
526
551
assert . isLessThanMax64BytesDate ( 'canSendAfter' , params . canSendAfter ) ;
527
552
assert . isLessThanMax64BytesDate ( 'canReceiveAfter' , params . canReceiveAfter ) ;
528
553
assert . isLessThanMax64BytesDate ( 'expiryTime' , params . expiryTime ) ;
529
554
assert . isPastDate ( params . validFrom , 'ValidFrom date must be in the past' ) ;
530
555
assert . isFutureDate ( params . validTo , 'ValidTo date must be in the future' ) ;
531
556
assert . assert (
532
557
! ( await this . nonceMap ( { address : params . investor , nonce : params . nonce } ) ) ,
558
+ ErrorCode . AlreadyAdded ,
533
559
'Already used signature of investor address and nonce' ,
534
560
) ;
535
561
return ( await this . contract ) . modifyKYCDataSigned . sendTransactionAsync (
@@ -550,7 +576,11 @@ export default class GeneralTransferManagerWrapper extends ModuleWrapper {
550
576
* Used to modify investor Flag.
551
577
*/
552
578
public modifyInvestorFlag = async ( params : ModifyInvestorFlag ) => {
553
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
579
+ assert . assert (
580
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
581
+ ErrorCode . Unauthorized ,
582
+ 'Caller is not allowed' ,
583
+ ) ;
554
584
assert . isNonZeroETHAddressHex ( 'investor' , params . investor ) ;
555
585
return ( await this . contract ) . modifyInvestorFlag . sendTransactionAsync (
556
586
params . investor ,
@@ -565,9 +595,14 @@ export default class GeneralTransferManagerWrapper extends ModuleWrapper {
565
595
* Used to modify investor data.
566
596
*/
567
597
public modifyInvestorFlagMulti = async ( params : ModifyInvestorFlagMulti ) => {
568
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
598
+ assert . assert (
599
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
600
+ ErrorCode . Unauthorized ,
601
+ 'Caller is not allowed' ,
602
+ ) ;
569
603
assert . assert (
570
604
params . investors . length === params . flag . length && params . flag . length === params . value . length ,
605
+ ErrorCode . MismatchedArrayLength ,
571
606
'Mismatched input lengths' ,
572
607
) ;
573
608
return ( await this . contract ) . modifyInvestorFlagMulti . sendTransactionAsync (
@@ -631,12 +666,17 @@ export default class GeneralTransferManagerWrapper extends ModuleWrapper {
631
666
* Modifies the successful checks required for transfers.
632
667
*/
633
668
public modifyTransferRequirementsMulti = async ( params : ModifyTransferRequirementsMulti ) => {
634
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
669
+ assert . assert (
670
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
671
+ ErrorCode . Unauthorized ,
672
+ 'Caller is not allowed' ,
673
+ ) ;
635
674
assert . assert (
636
675
params . transferTypes . length === params . fromValidKYC . length &&
637
676
params . fromValidKYC . length === params . toValidKYC . length &&
638
677
params . toValidKYC . length === params . fromRestricted . length &&
639
678
params . fromRestricted . length === params . toRestricted . length ,
679
+ ErrorCode . MismatchedArrayLength ,
640
680
'Mismatched input lengths' ,
641
681
) ;
642
682
return ( await this . contract ) . modifyTransferRequirementsMulti . sendTransactionAsync (
@@ -654,11 +694,16 @@ export default class GeneralTransferManagerWrapper extends ModuleWrapper {
654
694
* Add or remove KYC info of an investor.
655
695
*/
656
696
public modifyKYCDataMulti = async ( params : ModifyKYCDataMulti ) => {
657
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
697
+ assert . assert (
698
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
699
+ ErrorCode . Unauthorized ,
700
+ 'Caller is not allowed' ,
701
+ ) ;
658
702
assert . assert (
659
703
params . investors . length === params . canSendAfter . length &&
660
704
params . canSendAfter . length === params . canReceiveAfter . length &&
661
705
params . canReceiveAfter . length === params . expiryTime . length ,
706
+ ErrorCode . MismatchedArrayLength ,
662
707
'Mismatched input lengths' ,
663
708
) ;
664
709
0 commit comments