-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathmigrate.ts
66 lines (58 loc) · 1.88 KB
/
migrate.ts
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
54
55
56
57
58
59
60
61
62
63
64
65
66
import { Command, flags } from "@oclif/command";
import { LCDClient } from "@terra-money/terra.js";
import { loadConfig, loadConnections } from "../../config";
import { migrate, storeCode } from "../../lib/deployment";
import { getSigner } from "../../lib/signer";
export default class ContractMigrate extends Command {
static description = "Migrate the contract.";
static flags = {
"no-rebuild": flags.boolean({
description: "deploy the wasm bytecode as is.",
default: false,
}),
network: flags.string({ default: "localterra" }),
"config-path": flags.string({ default: "./config.terrain.json" }),
"refs-path": flags.string({ default: "./refs.terrain.json" }),
"keys-path": flags.string({ default: "./keys.terrain.js" }),
"instance-id": flags.string({ default: "default" }),
signer: flags.string({ required: true }),
"code-id": flags.integer({
description:
"target code id for migration",
}),
};
static args = [{ name: "contract" }];
async run() {
const { args, flags } = this.parse(ContractMigrate);
const connections = loadConnections(flags["config-path"]);
const config = loadConfig(flags["config-path"]);
const conf = config(flags.network, args.contract);
// @ts-ignore
const lcd = new LCDClient(connections(flags.network));
const signer = getSigner({
network: flags.network,
signerId: flags.signer,
keysPath: flags["keys-path"],
lcd,
});
const codeId = await storeCode({
conf,
noRebuild: flags["no-rebuild"],
contract: args.contract,
signer,
network: flags.network,
refsPath: flags["refs-path"],
lcd: lcd,
});
migrate({
conf,
signer,
contract: args.contract,
codeId,
network: flags.network,
instanceId: flags["instance-id"],
refsPath: flags["refs-path"],
lcd: lcd,
});
}
}