-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathpolicy.js
72 lines (63 loc) · 1.98 KB
/
policy.js
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
require('dotenv').config();
const { client, selectSp, generateString } = require('../client');
const { ACCOUNT_ADDRESS, ACCOUNT_PRIVATEKEY } = require('../env');
(async () => {
const GROUP_NAME = generateString(10);
const EXTRA = generateString(10);
// create group tx
const createGroupTx = await client.group.createGroup({
creator: ACCOUNT_ADDRESS,
extra: EXTRA,
groupName: GROUP_NAME,
tags: {
tags: [],
},
});
const createGroupTxSimulateInfo = await createGroupTx.simulate({
denom: 'BNB',
});
console.log('createGroupTxSimulateInfo', createGroupTxSimulateInfo);
const createGroupTxRes = await createGroupTx.broadcast({
denom: 'BNB',
gasLimit: Number(createGroupTxSimulateInfo?.gasLimit),
gasPrice: createGroupTxSimulateInfo?.gasPrice || '5000000000',
payer: ACCOUNT_ADDRESS,
granter: '',
privateKey: ACCOUNT_PRIVATEKEY,
});
// update group tx
const newExtra = generateString(10);
const updateGroupTx = await client.group.updateGroupExtra({
groupName: GROUP_NAME,
groupOwner: ACCOUNT_ADDRESS,
operator: ACCOUNT_ADDRESS,
extra: newExtra,
});
const updateGroupExtraSimulateInfo = await updateGroupTx.simulate({
denom: 'BNB',
});
const updateGroupTxRes = await updateGroupTx.broadcast({
denom: 'BNB',
gasLimit: Number(updateGroupExtraSimulateInfo.gasLimit),
gasPrice: updateGroupExtraSimulateInfo.gasPrice,
granter: '',
payer: ACCOUNT_ADDRESS,
privateKey: ACCOUNT_PRIVATEKEY,
});
// delete group tx
const deleteGroupTx = await client.group.deleteGroup({
groupName: GROUP_NAME,
operator: ACCOUNT_ADDRESS,
});
const deleteGroupTxSimulateInfo = await deleteGroupTx.simulate({
denom: 'BNB',
});
const deleteGroupTxRes = await deleteGroupTx.broadcast({
denom: 'BNB',
gasLimit: Number(deleteGroupTxSimulateInfo.gasLimit),
gasPrice: deleteGroupTxSimulateInfo.gasPrice,
granter: '',
payer: ACCOUNT_ADDRESS,
privateKey: ACCOUNT_PRIVATEKEY,
});
})();