-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path01-compile.js
More file actions
executable file
·53 lines (43 loc) · 1.61 KB
/
01-compile.js
File metadata and controls
executable file
·53 lines (43 loc) · 1.61 KB
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 node
import { Logger } from './util/logger.js';
import FILE_PATHS from './util/file-paths.js';
const logger = new Logger();
await logger.init();
async function step01Compile() {
await logger.logScriptBegin('compile');
await logger.loggerJumpToFileLine(FILE_PATHS.counterSol);
await logger.logSection('Run compiler', logger.f.italic('npx hardhat compile'));
await logger.logProcess('npx hardhat compile');
await logger.loggerJumpToFileLine(FILE_PATHS.counterAbi);
await logger.log('Compilation completed!', 'check the "artifacts" directory to see compiled outputs.');
await logger.logInfoBox(
'What have we accomplished?',
`
1. Install the version of solc needed by the project.
(automatic via hardhat)
2. Run solc, via hardhat, using the Counter.sol file as input.
3. Observe the outputs produced by solc in the "Counter.json" artifacts file:
- EVM ABI (JSON): "abi"
- EVM bytecode (hexadecimal): "bytecode"
`
);
}
process.once('SIGINT', async () => {
await logger.logError('compile', 'sigint');
});
process.once('SIGTERM', async () => {
await logger.logError('compile', 'sigterm');
});
step01Compile().then(async () => {
await logger.logScriptEnd('compile');
console.log('To continue, run the following command for the next step:\n', logger.f.bold('./02-test.js'));
}).catch(async (err) => {
if (err.stdout || err.stderr) {
await logger.logError('compile', err.message);
console.log(err.stdout);
console.log(err.stderr);
} else {
await logger.logError('compile', err.message);
console.log(err);
}
});