@@ -30,6 +30,7 @@ import {
30
30
Subscribe ,
31
31
SubscribeAsyncParams ,
32
32
TxParams ,
33
+ ErrorCode ,
33
34
} from '../../types' ;
34
35
import { bytes32ArrayToStringArray } from '../../utils/convert' ;
35
36
import functionsUtils from '../../utils/functions_utils' ;
@@ -228,20 +229,26 @@ export default class ModuleRegistryWrapper extends ContractWrapper {
228
229
assert . assert (
229
230
functionsUtils . checksumAddressComparision ( callerAddress , owner ) ||
230
231
functionsUtils . checksumAddressComparision ( callerAddress , factoryOwner ) ,
232
+ ErrorCode . Unauthorized ,
231
233
'Calling address must be owner or factory owner with custom modules allowed feature status' ,
232
234
) ;
233
235
} else {
234
236
assert . assert (
235
237
functionsUtils . checksumAddressComparision ( callerAddress , owner ) ,
238
+ ErrorCode . Unauthorized ,
236
239
'Calling address must be owner without custom modules allowed feature status' ,
237
240
) ;
238
241
}
239
242
const getTypesResult = await ( await this . moduleFactoryContract ( params . moduleFactory ) ) . getTypes . callAsync ( ) ;
240
243
// Check for duplicates
241
244
if ( getTypesResult . length > 1 ) {
242
- assert . assert ( getTypesResult . length === new Set ( getTypesResult ) . size , 'Type mismatch' ) ;
245
+ assert . assert (
246
+ getTypesResult . length === new Set ( getTypesResult ) . size ,
247
+ ErrorCode . MismatchedLength ,
248
+ 'Type mismatch' ,
249
+ ) ;
243
250
}
244
- assert . assert ( getTypesResult . length > 0 , 'Factory must have type' ) ;
251
+ assert . assert ( getTypesResult . length > 0 , ErrorCode . InvalidData , 'Factory must have type' ) ;
245
252
return ( await this . contract ) . registerModule . sendTransactionAsync (
246
253
params . moduleFactory ,
247
254
params . txData ,
@@ -364,13 +371,13 @@ export default class ModuleRegistryWrapper extends ContractWrapper {
364
371
365
372
public pause = async ( params : TxParams ) => {
366
373
await this . checkMsgSenderIsOwner ( ) ;
367
- assert . assert ( ! ( await this . isPaused ( ) ) , 'Contract is paused' ) ;
374
+ assert . assert ( ! ( await this . isPaused ( ) ) , ErrorCode . ContractPaused , 'Contract is paused' ) ;
368
375
return ( await this . contract ) . pause . sendTransactionAsync ( params . txData , params . safetyFactor ) ;
369
376
} ;
370
377
371
378
public unpause = async ( params : TxParams ) => {
372
379
await this . checkMsgSenderIsOwner ( ) ;
373
- assert . assert ( await this . isPaused ( ) , 'Contract is already not paused' ) ;
380
+ assert . assert ( await this . isPaused ( ) , ErrorCode . PreconditionRequired , 'Contract is already not paused' ) ;
374
381
return ( await this . contract ) . unpause . sendTransactionAsync ( params . txData , params . safetyFactor ) ;
375
382
} ;
376
383
@@ -462,28 +469,38 @@ export default class ModuleRegistryWrapper extends ContractWrapper {
462
469
await this . owner ( ) ,
463
470
( await this . web3Wrapper . getAvailableAddressesAsync ( ) ) [ 0 ] ,
464
471
) ,
472
+ ErrorCode . Unauthorized ,
465
473
'Msg sender must be owner' ,
466
474
) ;
467
475
} ;
468
476
469
477
private checkModuleRegistered = async ( moduleFactory : string ) => {
470
- assert . assert ( await this . checkForRegisteredModule ( moduleFactory ) , 'Module is not registered' ) ;
478
+ assert . assert (
479
+ await this . checkForRegisteredModule ( moduleFactory ) ,
480
+ ErrorCode . PreconditionRequired ,
481
+ 'Module is not registered' ,
482
+ ) ;
471
483
} ;
472
484
473
485
private checkModuleNotRegistered = async ( moduleFactory : string ) => {
474
- assert . assert ( ! ( await this . checkForRegisteredModule ( moduleFactory ) ) , 'Module is already registered' ) ;
486
+ assert . assert (
487
+ ! ( await this . checkForRegisteredModule ( moduleFactory ) ) ,
488
+ ErrorCode . AlreadyExists ,
489
+ 'Module is already registered' ,
490
+ ) ;
475
491
} ;
476
492
477
493
private checkModuleNotPausedOrOwner = async ( ) => {
478
494
assert . assert (
479
495
! ( await this . isPaused ( ) ) ||
480
496
functionsUtils . checksumAddressComparision ( await this . owner ( ) , await this . getCallerAddress ( undefined ) ) ,
497
+ ErrorCode . Unauthorized ,
481
498
'Contract is either paused or the calling address is not the owner' ,
482
499
) ;
483
500
} ;
484
501
485
502
private checkModuleNotPaused = async ( ) => {
486
- assert . assert ( ! ( await this . isPaused ( ) ) , 'Contract is currently paused' ) ;
503
+ assert . assert ( ! ( await this . isPaused ( ) ) , ErrorCode . ContractPaused , 'Contract is currently paused' ) ;
487
504
} ;
488
505
489
506
private checkIsOwnerOrModuleFactoryOwner = async ( moduleFactoryAddress : string ) => {
@@ -493,6 +510,7 @@ export default class ModuleRegistryWrapper extends ContractWrapper {
493
510
assert . assert (
494
511
functionsUtils . checksumAddressComparision ( callerAddress , owner ) ||
495
512
functionsUtils . checksumAddressComparision ( callerAddress , factoryOwner ) ,
513
+ ErrorCode . Unauthorized ,
496
514
'Calling address must be owner or factory owner ' ,
497
515
) ;
498
516
} ;
0 commit comments