-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathset-permission-appid.js
35 lines (29 loc) · 1.23 KB
/
set-permission-appid.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
const { types } = require("@algo-builder/web");
const accounts = require("../common/accounts");
const { tryExecuteTx } = require("../common/common");
async function run(runtimeEnv, deployer) {
const controllerAppInfo = deployer.getApp("Controller");
const controllerappID = controllerAppInfo.appID;
const tesla = deployer.asa.get("tesla");
const owner = deployer.accountsByName.get(accounts.owner);
// get new permissions smart contract info
const newPermissionsAppInfo = deployer.getApp("PermissionNewApp");
console.log(
`\n** Setting new permissions smart contract(id = ${newPermissionsAppInfo.appID}) **`
);
const appArgs = ["str:set_permission", `int:${newPermissionsAppInfo.appID}`];
// set new permissions app id in controller smart contract
// note: in current version, this replaces the previous appID in controller
await tryExecuteTx(deployer, [
{
type: types.TransactionType.CallApp,
sign: types.SignType.SecretKey,
fromAccount: owner, // asa manager account
appID: controllerappID,
payFlags: { totalFee: 1000 },
appArgs: appArgs,
foreignAssets: [tesla.assetIndex], // controller smart contract verifies if correct token is being used + asa.manager is correct one
},
]);
}
module.exports = { default: run };