@@ -4,9 +4,14 @@ import { Contract } from './Contract';
4
4
import { Context } from './LowLevel' ;
5
5
import { isAddress , getOptions } from './utils' ;
6
6
7
- import { GenericContract } from './types' ;
8
- import { PolymathError } from '~/PolymathError' ;
9
- import { ErrorCodes } from '~/types' ;
7
+ import {
8
+ GenericContract ,
9
+ AddDelegateArgs ,
10
+ ChangePermissionArgs ,
11
+ GetAllDelegatesWithPermArgs ,
12
+ } from './types' ;
13
+ import { PolymathError } from '../PolymathError' ;
14
+ import { ErrorCodes } from '../types' ;
10
15
11
16
interface GeneralPermissionManagerContract extends GenericContract {
12
17
methods : {
@@ -17,6 +22,8 @@ interface GeneralPermissionManagerContract extends GenericContract {
17
22
perm : string ,
18
23
valid : boolean
19
24
) => TransactionObject < void > ;
25
+ getAllDelegates : ( ) => TransactionObject < string [ ] > ;
26
+ getAllDelegatesWithPerm : ( module : string , perm : string ) => TransactionObject < string [ ] > ;
20
27
} ;
21
28
}
22
29
@@ -29,7 +36,15 @@ export class GeneralPermissionManager extends Contract<GeneralPermissionManagerC
29
36
} ) ;
30
37
}
31
38
32
- public addDelegate = async ( delegate : string , details : string ) => {
39
+ public getAllDelegates = async ( ) => {
40
+ return await this . contract . methods . getAllDelegates ( ) . call ( ) ;
41
+ } ;
42
+
43
+ public getAllDelegatesWithPerm = async ( { module, perm } : GetAllDelegatesWithPermArgs ) => {
44
+ return await this . contract . methods . getAllDelegatesWithPerm ( module , perm ) . call ( ) ;
45
+ } ;
46
+
47
+ public addDelegate = async ( { delegate, details } : AddDelegateArgs ) => {
33
48
if ( ! isAddress ( delegate ) )
34
49
throw new PolymathError ( {
35
50
code : ErrorCodes . InvalidAddress ,
@@ -41,19 +56,14 @@ export class GeneralPermissionManager extends Contract<GeneralPermissionManagerC
41
56
return ( ) => method . send ( options ) ;
42
57
} ;
43
58
44
- public changePermission = async (
45
- delegate : string ,
46
- module : string ,
47
- perm : string ,
48
- valid : boolean
49
- ) => {
59
+ public changePermission = async ( { delegate, module, perm, enabled } : ChangePermissionArgs ) => {
50
60
if ( ! isAddress ( delegate ) )
51
61
throw new PolymathError ( {
52
62
code : ErrorCodes . InvalidAddress ,
53
63
message : `Delegate address is invalid: $delegate = ${ delegate } ` ,
54
64
} ) ;
55
65
56
- const method = this . contract . methods . changePermission ( delegate , module , perm , valid ) ;
66
+ const method = this . contract . methods . changePermission ( delegate , module , perm , enabled ) ;
57
67
const options = await getOptions ( method , { from : this . context . account } ) ;
58
68
return ( ) => method . send ( options ) ;
59
69
} ;
0 commit comments