All files / src/accounts/actions permissions.ts

88.23% Statements 15/17
75% Branches 3/4
50% Functions 2/4
87.5% Lines 14/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 471x     1x     1x                                           1x 1x   2x 1x 1x 1x 1x     1x 1x 1x         2x  
import {Authority, AuthorityType, Name, NameType, Struct} from '@greymass/eosio'
 
// Temporarily use a custom version of Contract class.
import {Contract} from '../../tmp/contract'
 
class PermissionActions extends Contract {
    static account = Name.from('eosio')
 
    async updateAuth(
        permissionData: {
            account: NameType
            permission: NameType
            parent: NameType
            auth: AuthorityType
        },
        sessionData?: any
    ) {
        return this.call('updateauth', PermissionActions.Types.UpdateAuth.from(permissionData))
    }
 
    async deleteAuth(account: NameType, permission: NameType, sessionData?: any) {
        return this.call(
            'deleteauth',
            PermissionActions.Types.DeleteAuth.from({account, permission})
        )
    }
}
 
namespace PermissionActions {
    export namespace Types {
        @Struct.type('updateauth')
        export class UpdateAuth extends Struct {
            @Struct.field('name') declare account: Name
            @Struct.field('name') declare permission: Name
            @Struct.field('string') declare parent: Name
            @Struct.field('authorization_object') declare auth: Authority
        }
 
        export class DeleteAuth extends Struct {
            @Struct.field('name') declare account: Name
            @Struct.field('name') declare permission: Name
        }
    }
}
 
export {PermissionActions}