-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathkill.js
49 lines (41 loc) · 1.67 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
47
48
49
const { types } = require("@algo-builder/web");
const { issue } = require("./issue");
const { tryExecuteTx, 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");
const killParams = [
{
type: types.TransactionType.CallApp,
sign: types.SignType.SecretKey,
fromAccount: owner,
appID: controllerAppInfo.appID,
payFlags: { totalFee: 1000 },
appArgs: ["str:kill"],
foreignAssets: [tesla.assetIndex],
},
];
console.log("* Kill Token: tesla *");
await tryExecuteTx(deployer, killParams);
}
async function run(runtimeEnv, deployer) {
const elon = deployer.accountsByName.get("elon-musk");
await fundAccount(deployer, elon); // fund elon
// (in scripts flow we already issue the tokens before kill, so uncomment if another sequence is followed)
// transaction pass (issue 15 tokens to elon)
// await deployer.optInAccountToASA("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).catch((error) => console.log(error));
}
module.exports = { default: run, kill: kill };