-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy.mjs
51 lines (40 loc) · 1.35 KB
/
deploy.mjs
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
import Arweave from "arweave";
import assert from "assert";
import fs from "fs";
const walletFile = process.argv[2];
console.log("Wallet file:", walletFile);
const pkg = JSON.parse(fs.readFileSync("./package.json"));
assert(walletFile, "Wallet required!");
try {
const jwk = JSON.parse(fs.readFileSync(walletFile).toString());
const arweave = Arweave.init({
host: "arweave.net",
port: 443,
protocol: "https",
timeout: 20000,
logging: false,
});
const data = fs.readFileSync("./dist/widget.js");
const tags = [
{ name: "Content-Type", value: "application/javascript" },
{ name: "App-Name", value: "Permapage-Widget" },
{ name: "App-Version", value: "0.0.1" },
{ name: "Widget-Id", value: "latest-arprofile" },
{ name: "Widget-Name", value: pkg.name },
{ name: "Widget-Version", value: pkg.version },
{ name: "Widget-Desc", value: pkg.description },
{
name: "Widget-Docs",
value: "https://github.com/MetaweaveTeam/laa-widget",
},
];
const tx = await arweave.createTransaction({ data }, jwk);
tags.forEach((tag) => tx.addTag(tag.name, tag.value));
await arweave.transactions.sign(tx, jwk);
const result = await arweave.transactions.post(tx);
console.log("Deployed!");
console.log("result: ", result);
console.log("TransactionId: ", tx.id);
} catch (e) {
console.log("ERROR: ", e);
}