-
Notifications
You must be signed in to change notification settings - Fork 0
/
upgrade-software.mjs
executable file
·53 lines (45 loc) · 1.11 KB
/
upgrade-software.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
52
53
#!/usr/bin/env zx
$.verbose = false;
import { spinner } from "zx/experimental";
import { binary, feesFlags, flags, blockFlag } from "./helpers/flags.mjs";
import { getBlockHeight } from "./helpers/getBlockHeight.mjs";
const {
version = null,
height = null,
waitNBlocks = 300,
deposit = "1000000000rowan",
} = argv;
if (!version) {
console.log("--version is missing");
process.exit();
}
if (version[0] === "v") {
console.log("--version should not be prefixed with 'v'.");
process.exit();
}
let currentHeight = height;
if (!currentHeight) {
currentHeight = await getBlockHeight();
if (!currentHeight) {
console.log(
"failed to retrieve current block height, use --height instead."
);
process.exit();
}
}
await spinner("Upgrade software ", () =>
within(async () => {
$.verbose = true;
await $`\
${binary} tx gov submit-proposal software-upgrade \
${version} \
--deposit=${deposit} \
--upgrade-height=${currentHeight + waitNBlocks} \
--title=v${version} \
--description=v${version} \
${flags} \
${feesFlags} \
${blockFlag} \
`;
})
);