Basically, pull the existing permission, change only what you need to change, then pass everything back to updateauth ..
async function getNewPermissions(accountName) {
const account = await eos.getAccount(accountName)
const perms = JSON.parse(JSON.stringify(account.permissions))
return perms
}
const perms = await getNewPermissions(accountName)
console.log('New permissions =>', JSON.stringify(perms))
const updateAuthResult = await eos.transaction(tr => {
for(const perm of perms) {
tr.updateauth({
account: accountName,
permission: perm.perm_name,
parent: perm.parent,
auth: perm.required_auth
}, {authorization: `${accountName}@owner`})
}
})
console.log('Success =>', JSON.stringify(updateAuthResult));
I hope this will help. Thank You.