-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathoptimize.ts
49 lines (42 loc) · 1.65 KB
/
optimize.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
import { Command } from '@oclif/command';
import dedent from 'dedent';
import { optimize } from '../../lib/deployment';
import { CONFIG_FILE_NAME, loadGlobalConfig } from '../../config';
import runCommand from '../../lib/runCommand';
import defaultErrorCheck from '../../lib/defaultErrorCheck';
import TerrainCLI from '../../TerrainCLI';
export default class Optimize extends Command {
static description = 'Optimize wasm bytecode.';
static args = [{ name: 'contract', required: true }];
async run() {
const { args } = this.parse(Optimize);
// Command to be performed.
const command = async () => {
const globalConfig = loadGlobalConfig();
await optimize({
contract: args.contract,
useCargoWorkspace: globalConfig.useCargoWorkspace,
});
};
// Message to be displayed upon successful command execution.
const successMessage = () => {
TerrainCLI.success(
dedent`
The Wasm bytecode for contract "${args.contract}" was successfully optimized.\n
The next step is to store the Wasm bytecode on a Terra network:\n
"terrain contract:store ${args.contract} --signer <signer-wallet>" "--network <desired-network>"\n
"NOTE:" To store your contract on the "LocalTerra" network utilizing the preconfigured test wallet "test1" as the signer, use the following command:\n
"terrain contract:store ${args.contract}"
`,
'Wasm Bytecode Optimized',
);
};
// Attempt to execute command while backtracking through file tree.
await runCommand(
CONFIG_FILE_NAME,
command,
defaultErrorCheck(args.contract),
successMessage,
);
}
}