-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathkill.js
46 lines (38 loc) · 1.59 KB
/
kill.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
const { types } = require('@algo-builder/web');
const { issue } = require('./issue');
const { executeTransaction, fundAccount } = require('../common/common');
const accounts = require('../common/accounts');
async function kill (deployer) {
const owner = deployer.accountsByName.get(accounts.owner);
await fundAccount(deployer, owner);
/*
* tx - Call to controller stateful smart contract with application arg: 'kill'
* Only token manager can kill a token. If token is killed then all token transfers
* (eg. issue, transfer(a, b)) are rejected. Token holder can only do opt-out txn after
* token is killed.
*/
const tesla = deployer.asa.get('tesla');
const controllerAppInfo = deployer.getApp('controller.py', 'clear_state_program.py');
const killParams = {
type: types.TransactionType.CallNoOpSSC,
sign: types.SignType.SecretKey,
fromAccount: owner,
appID: controllerAppInfo.appID,
payFlags: { totalFee: 1000 },
appArgs: ['str:kill'],
foreignAssets: [tesla.assetIndex]
};
console.log('* Kill Token: tesla *');
await executeTransaction(deployer, killParams);
}
async function run (runtimeEnv, deployer) {
const elon = deployer.accountsByName.get('elon-musk');
await fundAccount(deployer, elon); // fund elon
// transaction pass (issue 15 tokens to elon)
await deployer.optInAcountToASA('tesla', elon.name, {});
await issue(deployer, elon.addr, 15);
await kill(deployer); // kill token 'tesla'
// transaction FAIL: token is killed, we can't issue tokens
await issue(deployer, elon.addr, 15);
}
module.exports = { default: run, kill: kill };