forked from permaweb/ao-cookbook
-
Notifications
You must be signed in to change notification settings - Fork 4
/
deploy.js
50 lines (39 loc) · 1.34 KB
/
deploy.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
import { readFileSync } from "node:fs";
import { WarpFactory, defaultCacheOptions } from "warp-contracts";
import Arweave from "arweave";
function env(key) {
if (!process.env[key]) {
throw new Error(`Error with ENV VAR: ${key}`);
}
return process.env[key];
}
const actions = {
async UPDATE_ARNS() {
const WALLET = env("WALLET");
const MANIFEST_ID = env("MANIFEST_ID");
const jwk = JSON.parse(readFileSync(WALLET));
/**
* The ao ANT Contract
* See https://sonar.warp.cc/?#/app/contract/uOf4TMgQxdaSXgcZ778PZR13UQPKJoZVK2ZvLAE90Xg?network=mainnet%23
*/
const ANT = "uOf4TMgQxdaSXgcZ778PZR13UQPKJoZVK2ZvLAE90Xg";
const arweave = Arweave.init({
host: "arweave.net",
port: 443,
protocol: "https",
});
const warp = WarpFactory.forMainnet(defaultCacheOptions, true, arweave);
// Update the ao ANT Contract to point to the new install script
const aoAntContract = warp.contract(ANT).connect(jwk);
const antUpdate = await aoAntContract.writeInteraction({
function: "setRecord",
subDomain: "cookbook",
transactionId: MANIFEST_ID,
});
console.log("Updated ao ANT record", antUpdate.interactionTx);
return MANIFEST_ID;
},
};
const ACTION = env("ACTION");
if (!actions[ACTION]) throw new Error(`'${ACTION}' is not a valid action`);
actions[ACTION]();