-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathupdateauth.js
More file actions
39 lines (31 loc) · 935 Bytes
/
updateauth.js
File metadata and controls
39 lines (31 loc) · 935 Bytes
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
// 更改账号权限
// 在 keys.json 文件里放入你的私钥
var EOS = require('./eosClient.js');
var eos = EOS();
// 替换 xxxxxaccount yyyyyaccount 为你的账号
const user = {
'account': 'xxxxxaccount'
};
async function getNewPermissions(accountName) {
const account = await eos.getAccount(accountName);
const perms = JSON.parse(JSON.stringify(account.permissions));
return perms;
}
async function updateauth() {
// 复制 源 账号的所有权限
const perms = await getNewPermissions('yyyyyaccount');
const updateAuthResult = await eos.transaction(tr => {
for (const perm of perms) {
tr.updateauth({
account: user.account,
permission: perm.perm_name,
parent: perm.parent,
auth: perm.required_auth
}, {
authorization: `${user.account}@owner`
});
}
});
console.log('Success =>', JSON.stringify(updateAuthResult));
}
updateauth();