@@ -20,6 +20,7 @@ import {
20
20
GetLogs ,
21
21
Subscribe ,
22
22
Perm ,
23
+ ErrorCode ,
23
24
} from '../../../types' ;
24
25
import {
25
26
numberToBigNumber ,
@@ -160,10 +161,18 @@ export default class GeneralPermissionManagerWrapper extends ModuleWrapper {
160
161
} ;
161
162
162
163
public addDelegate = async ( params : AddDelegateParams ) => {
163
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
164
+ assert . assert (
165
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
166
+ ErrorCode . Unauthorized ,
167
+ 'Caller is not allowed' ,
168
+ ) ;
164
169
assert . isNonZeroETHAddressHex ( 'delegate' , params . delegate ) ;
165
- assert . assert ( params . details . length > 0 , '0 value not allowed' ) ;
166
- assert . assert ( ! ( await ( await this . contract ) . checkDelegate . callAsync ( params . delegate ) ) , 'Delegate already present' ) ;
170
+ assert . assert ( params . details . length > 0 , ErrorCode . InvalidData , '0 value not allowed' ) ;
171
+ assert . assert (
172
+ ! ( await ( await this . contract ) . checkDelegate . callAsync ( params . delegate ) ) ,
173
+ ErrorCode . PreconditionRequired ,
174
+ 'Delegate already present' ,
175
+ ) ;
167
176
return ( await this . contract ) . addDelegate . sendTransactionAsync (
168
177
params . delegate ,
169
178
stringToBytes32 ( params . details ) ,
@@ -173,9 +182,17 @@ export default class GeneralPermissionManagerWrapper extends ModuleWrapper {
173
182
} ;
174
183
175
184
public deleteDelegate = async ( params : DelegateTxParams ) => {
176
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
185
+ assert . assert (
186
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
187
+ ErrorCode . Unauthorized ,
188
+ 'Caller is not allowed' ,
189
+ ) ;
177
190
assert . isNonZeroETHAddressHex ( 'delegate' , params . delegate ) ;
178
- assert . assert ( await ( await this . contract ) . checkDelegate . callAsync ( params . delegate ) , 'Delegate does not exist' ) ;
191
+ assert . assert (
192
+ await ( await this . contract ) . checkDelegate . callAsync ( params . delegate ) ,
193
+ ErrorCode . InvalidDelegate ,
194
+ 'Delegate does not exist' ,
195
+ ) ;
179
196
return ( await this . contract ) . deleteDelegate . sendTransactionAsync (
180
197
params . delegate ,
181
198
params . txData ,
@@ -189,7 +206,11 @@ export default class GeneralPermissionManagerWrapper extends ModuleWrapper {
189
206
} ;
190
207
191
208
public changePermission = async ( params : ChangePermissionParams ) => {
192
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
209
+ assert . assert (
210
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
211
+ ErrorCode . Unauthorized ,
212
+ 'Caller is not allowed' ,
213
+ ) ;
193
214
assert . isNonZeroETHAddressHex ( 'delegate' , params . delegate ) ;
194
215
assert . isETHAddressHex ( 'module' , params . module ) ;
195
216
return ( await this . contract ) . changePermission . sendTransactionAsync (
@@ -203,12 +224,24 @@ export default class GeneralPermissionManagerWrapper extends ModuleWrapper {
203
224
} ;
204
225
205
226
public changePermissionMulti = async ( params : ChangePermissionMultiParams ) => {
206
- assert . assert ( await this . isCallerAllowed ( params . txData , Perm . Admin ) , 'Caller is not allowed' ) ;
227
+ assert . assert (
228
+ await this . isCallerAllowed ( params . txData , Perm . Admin ) ,
229
+ ErrorCode . Unauthorized ,
230
+ 'Caller is not allowed' ,
231
+ ) ;
207
232
assert . isNonZeroETHAddressHex ( 'delegate' , params . delegate ) ;
208
233
params . modules . forEach ( address => assert . isETHAddressHex ( 'modules' , address ) ) ;
209
- assert . assert ( params . modules . length > 0 , '0 length is not allowed' ) ;
210
- assert . assert ( params . modules . length === params . perms . length , 'Array length mismatch' ) ;
211
- assert . assert ( params . valids . length === params . perms . length , 'Array length mismatch' ) ;
234
+ assert . assert ( params . modules . length > 0 , ErrorCode . InvalidData , '0 length is not allowed' ) ;
235
+ assert . assert (
236
+ params . modules . length === params . perms . length ,
237
+ ErrorCode . MismatchedArrayLength ,
238
+ 'Array length mismatch' ,
239
+ ) ;
240
+ assert . assert (
241
+ params . valids . length === params . perms . length ,
242
+ ErrorCode . MismatchedArrayLength ,
243
+ 'Array length mismatch' ,
244
+ ) ;
212
245
return ( await this . contract ) . changePermissionMulti . sendTransactionAsync (
213
246
params . delegate ,
214
247
params . modules ,
0 commit comments