import { EOSManager } from '../eosManager' ; import { Account } from './account' ; import { EosioAction } from './utils' ; export namespace UpdateAuth { export interface PermissionLevel { actor : string ; permission : string ; } interface PermissionLevelWeight { permission : PermissionLevel ; weight : number ; } interface AuthorityToSet { threshold : number ; keys : KeyWait [ ] ; accounts : PermissionLevelWeight [ ] ; waits : WeightWait [ ] ; } export interface WeightWait { seconds : number ; weight : number ; } export interface KeyWait { key : string ; weight : number ; } param authorizations param account param permission param parent param authToSet export async function execUpdateAuth ( authorizations , account , permission , parent , authToSet ) { const actions = [ { account : 'eosio' , name : 'updateauth' , authorization : authorizations , data : { account : account , permission : permission , parent : parent , auth : authToSet , } , } , ] ; await EOSManager . transact ( { actions } ) ; } export namespace AuthorityToSet { export function forContractCode ( account ) { return forAccount ( account , 'eosio.code' ) ; } param account param permission export function forAccount ( account , permission ) { return explicitAuthorities ( 1 , [ { permission : { actor : account . name , permission : permission } , weight : 1 , } , ] ) ; } param threshold param permissionLevelWeights param keyWeights param waitWeights export function explicitAuthorities ( threshold , permissionLevelWeights = [ ] , keyWeights = [ ] , waitWeights = [ ] ) { return { threshold : threshold , accounts : permissionLevelWeights , keys : keyWeights , waits : waitWeights , } ; } } param authorizations param account param code param type param requirement export async function execLinkAuth ( authorizations , account , code , type , requirement ) { const actions = [ { account : 'eosio' , name : 'linkauth' , authorization : authorizations , data : { account : account , code : code , type : type , requirement : requirement , } , } , ] ; await EOSManager . transact ( { actions } ) ; } }