@@ -24,6 +24,7 @@ import {
24
24
Subscribe ,
25
25
SubscribeAsyncParams ,
26
26
TxParams ,
27
+ ErrorCode ,
27
28
} from '../../types' ;
28
29
import {
29
30
bytes32ArrayToStringArray ,
@@ -211,7 +212,7 @@ export default class ModuleFactoryWrapper extends ContractWrapper {
211
212
*/
212
213
public changeTitle = async ( params : ChangeTitleParams ) => {
213
214
await this . checkOnlyOwner ( params . txData ) ;
214
- assert . assert ( params . title . length > 0 , 'Invalid title' ) ;
215
+ assert . assert ( params . title . length > 0 , ErrorCode . InvalidData , 'Invalid title' ) ;
215
216
return ( await this . contract ) . changeTitle . sendTransactionAsync ( params . title , params . txData , params . safetyFactor ) ;
216
217
} ;
217
218
@@ -220,7 +221,7 @@ export default class ModuleFactoryWrapper extends ContractWrapper {
220
221
*/
221
222
public changeDescription = async ( params : ChangeDescriptionParams ) => {
222
223
await this . checkOnlyOwner ( params . txData ) ;
223
- assert . assert ( params . description . length > 0 , 'Invalid description' ) ;
224
+ assert . assert ( params . description . length > 0 , ErrorCode . InvalidData , 'Invalid description' ) ;
224
225
return ( await this . contract ) . changeDescription . sendTransactionAsync (
225
226
params . description ,
226
227
params . txData ,
@@ -233,7 +234,7 @@ export default class ModuleFactoryWrapper extends ContractWrapper {
233
234
*/
234
235
public changeName = async ( params : ChangeNameParams ) => {
235
236
await this . checkOnlyOwner ( params . txData ) ;
236
- assert . assert ( params . name . length > 0 , 'Invalid name' ) ;
237
+ assert . assert ( params . name . length > 0 , ErrorCode . InvalidData , 'Invalid name' ) ;
237
238
return ( await this . contract ) . changeName . sendTransactionAsync (
238
239
stringToBytes32 ( params . name ) ,
239
240
params . txData ,
@@ -246,7 +247,7 @@ export default class ModuleFactoryWrapper extends ContractWrapper {
246
247
*/
247
248
public changeTags = async ( params : ChangeTagsParams ) => {
248
249
await this . checkOnlyOwner ( params . txData ) ;
249
- assert . assert ( params . tags . length > 0 , 'Invalid, must provide one or more tags' ) ;
250
+ assert . assert ( params . tags . length > 0 , ErrorCode . InvalidData , 'Invalid, must provide one or more tags' ) ;
250
251
return ( await this . contract ) . changeTags . sendTransactionAsync (
251
252
stringArrayToBytes32Array ( params . tags ) ,
252
253
params . txData ,
@@ -261,9 +262,14 @@ export default class ModuleFactoryWrapper extends ContractWrapper {
261
262
await this . checkOnlyOwner ( params . txData ) ;
262
263
assert . assert (
263
264
params . boundType === BoundType . LowerBound || params . boundType === BoundType . UpperBound ,
265
+ ErrorCode . InvalidBound ,
264
266
'Invalid bound type' ,
265
267
) ;
266
- assert . assert ( params . newVersion . length === 3 , 'Invalid version, number array must have 3 elements' ) ;
268
+ assert . assert (
269
+ params . newVersion . length === 3 ,
270
+ ErrorCode . InvalidVersion ,
271
+ 'Invalid version, number array must have 3 elements' ,
272
+ ) ;
267
273
const currentBound =
268
274
BoundType . LowerBound === params . boundType
269
275
? await this . getLowerSTVersionBounds ( )
@@ -273,11 +279,13 @@ export default class ModuleFactoryWrapper extends ContractWrapper {
273
279
if ( params . boundType === BoundType . LowerBound ) {
274
280
assert . assert (
275
281
semver . lte ( newBoundVer , currentBoundVer ) ,
282
+ ErrorCode . InvalidBound ,
276
283
'New Lower ST Bounds must be less than or equal to current' ,
277
284
) ;
278
285
} else {
279
286
assert . assert (
280
287
semver . gte ( newBoundVer , currentBoundVer ) ,
288
+ ErrorCode . InvalidBound ,
281
289
'New Upper ST Bounds must be greater than or equal to current' ,
282
290
) ;
283
291
}
@@ -361,6 +369,7 @@ export default class ModuleFactoryWrapper extends ContractWrapper {
361
369
private checkOnlyOwner = async ( txData : Partial < TxData > | undefined ) => {
362
370
assert . assert (
363
371
functionsUtils . checksumAddressComparision ( await this . owner ( ) , await this . getCallerAddress ( txData ) ) ,
372
+ ErrorCode . Unauthorized ,
364
373
'Msg sender must be owner' ,
365
374
) ;
366
375
} ;
0 commit comments