Skip to content

Commit 8b7b88f

Browse files
committed
Minor fixes, add compile to interactive
1 parent 2fcf569 commit 8b7b88f

12 files changed

+132
-14
lines changed

.solhint.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"error",
1515
140
1616
],
17+
"no-inline-assembly": false,
1718
"compiler-fixed": false
1819
}
1920
}

bin/commands/option.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ exports.OPTIONS = {
2424
optAndUnopt: new Option('optAndUnopt', 'O', 'Run the suit both with optimized and un-opttimized code.'),
2525
extended: new Option('extended', 'E', 'Include the extended tests/performance units.'),
2626
silent: new Option('silent', 'S', 'Do not show a detailed results from tests or perf.'),
27-
diff: new Option('diff', 'D', 'Compare perf results with the results from the previous perf (if any).')
27+
diff: new Option('diff', 'I', 'Compare perf results with the results from the previous perf (if any).')
2828
};
2929
exports.GLOBAL_OPTIONS = {
3030
debug: new Option('debug', 'D', 'Enable debug logging.')

bin/commands/option.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const OPTIONS: { [name: string]: Option } = {
3030
optAndUnopt: new Option('optAndUnopt', 'O', 'Run the suit both with optimized and un-opttimized code.'),
3131
extended: new Option('extended', 'E', 'Include the extended tests/performance units.'),
3232
silent: new Option('silent', 'S', 'Do not show a detailed results from tests or perf.'),
33-
diff: new Option('diff', 'D', 'Compare perf results with the results from the previous perf (if any).')
33+
diff: new Option('diff', 'I', 'Compare perf results with the results from the previous perf (if any).')
3434
};
3535

3636
export const GLOBAL_OPTIONS: { [name: string]: Option } = {

bin/prompt/compile_prompt.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
"use strict";
2+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3+
return new (P || (P = Promise))(function (resolve, reject) {
4+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6+
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7+
step((generator = generator.apply(thisArg, _arguments || [])).next());
8+
});
9+
};
10+
var __generator = (this && this.__generator) || function (thisArg, body) {
11+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13+
function verb(n) { return function (v) { return step([n, v]); }; }
14+
function step(op) {
15+
if (f) throw new TypeError("Generator is already executing.");
16+
while (_) try {
17+
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
18+
if (y = 0, t) op = [0, t.value];
19+
switch (op[0]) {
20+
case 0: case 1: t = op; break;
21+
case 4: _.label++; return { value: op[1], done: false };
22+
case 5: _.label++; y = op[1]; op = [0]; continue;
23+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
24+
default:
25+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29+
if (t[2]) _.ops.pop();
30+
_.trys.pop(); continue;
31+
}
32+
op = body.call(thisArg, _);
33+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35+
}
36+
};
37+
var _this = this;
38+
Object.defineProperty(exports, "__esModule", { value: true });
39+
var utils_1 = require("./utils");
40+
var compile_1 = require("../../script/compile");
41+
exports.compileMenu = function () { return __awaiter(_this, void 0, void 0, function () {
42+
var selected, units, _i, _a, cmpl;
43+
return __generator(this, function (_b) {
44+
switch (_b.label) {
45+
case 0: return [4 /*yield*/, utils_1.prompt(utils_1.librarySelectionData('compile'))];
46+
case 1:
47+
selected = _b.sent();
48+
if (selected.compile.length === 0) {
49+
return [2 /*return*/];
50+
}
51+
units = [];
52+
for (_i = 0, _a = selected.compile; _i < _a.length; _i++) {
53+
cmpl = _a[_i];
54+
if (cmpl[0] instanceof Array) {
55+
units = units.concat(cmpl);
56+
}
57+
else {
58+
units.push(cmpl);
59+
}
60+
}
61+
return [4 /*yield*/, compile_1.compile(units)];
62+
case 2:
63+
_b.sent();
64+
return [4 /*yield*/, exports.compileMenu()];
65+
case 3:
66+
_b.sent();
67+
return [2 /*return*/];
68+
}
69+
});
70+
}); };

bin/prompt/compile_prompt.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import {librarySelectionData, prompt} from "./utils";
2+
import {compile} from "../../script/compile";
3+
4+
export const compileMenu = async (): Promise<void> => {
5+
const selected = await prompt(librarySelectionData('compile'));
6+
if (selected.compile.length === 0) {
7+
return;
8+
}
9+
let units = [];
10+
for (const cmpl of selected.compile) {
11+
if (cmpl[0] instanceof Array) {
12+
units = units.concat(cmpl);
13+
} else {
14+
units.push(cmpl);
15+
}
16+
}
17+
await compile(units);
18+
await compileMenu();
19+
};

bin/prompt/main_prompt.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,17 @@ var docs_prompt_1 = require("./docs_prompt");
4141
var tests_prompt_1 = require("./tests_prompt");
4242
var perf_prompt_1 = require("./perf_prompt");
4343
var logs_prompt_1 = require("./logs_prompt");
44+
var compile_prompt_1 = require("./compile_prompt");
4445
exports.mainPrompt = {
4546
type: 'list',
4647
name: 'main',
4748
message: 'Select an action to perform',
4849
choices: [
50+
{
51+
key: 'c',
52+
name: 'Compile contracts',
53+
value: 'compile'
54+
},
4955
{
5056
key: 't',
5157
name: 'Run tests',
@@ -81,33 +87,39 @@ exports.mainMenu = function () { return __awaiter(_this, void 0, void 0, functio
8187
case "perf": return [3 /*break*/, 4];
8288
case "logs": return [3 /*break*/, 6];
8389
case "docs": return [3 /*break*/, 8];
84-
case "exit": return [3 /*break*/, 10];
90+
case "compile": return [3 /*break*/, 10];
91+
case "exit": return [3 /*break*/, 12];
8592
}
86-
return [3 /*break*/, 11];
93+
return [3 /*break*/, 13];
8794
case 2: // Options
8895
return [4 /*yield*/, tests_prompt_1.testsMenu()];
8996
case 3:
9097
_b.sent();
91-
return [3 /*break*/, 12];
98+
return [3 /*break*/, 14];
9299
case 4: // Options
93100
return [4 /*yield*/, perf_prompt_1.perfMenu()];
94101
case 5:
95102
_b.sent();
96-
return [3 /*break*/, 12];
103+
return [3 /*break*/, 14];
97104
case 6: // Options
98105
return [4 /*yield*/, logs_prompt_1.logsMenu()];
99106
case 7:
100107
_b.sent();
101-
return [3 /*break*/, 12];
108+
return [3 /*break*/, 14];
102109
case 8: // Options
103110
return [4 /*yield*/, docs_prompt_1.docsMenu()];
104111
case 9:
105112
_b.sent();
106-
return [3 /*break*/, 12];
107-
case 10: // Navigation
113+
return [3 /*break*/, 14];
114+
case 10: // Options
115+
return [4 /*yield*/, compile_prompt_1.compileMenu()];
116+
case 11:
117+
_b.sent();
118+
return [3 /*break*/, 14];
119+
case 12: // Navigation
108120
return [2 /*return*/, true];
109-
case 11: return [2 /*return*/, false];
110-
case 12: return [2 /*return*/, false];
121+
case 13: return [2 /*return*/, false];
122+
case 14: return [2 /*return*/, false];
111123
}
112124
});
113125
}); };

bin/prompt/main_prompt.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@ import {docsMenu} from "./docs_prompt";
33
import {testsMenu} from "./tests_prompt";
44
import {perfMenu} from "./perf_prompt";
55
import {logsMenu} from "./logs_prompt";
6+
import {compileMenu} from "./compile_prompt";
67

78
export const mainPrompt = {
89
type: 'list',
910
name: 'main',
1011
message: 'Select an action to perform',
1112
choices: [
13+
{
14+
key: 'c',
15+
name: 'Compile contracts',
16+
value: 'compile'
17+
},
1218
{
1319
key: 't',
1420
name: 'Run tests',
@@ -35,7 +41,7 @@ export const mainPrompt = {
3541
export const mainMenu = async (): Promise<boolean> => {
3642
const selected = await prompt(mainPrompt);
3743
switch (selected.main) {
38-
case "tests": // Options
44+
case "tests": // Options
3945
await testsMenu();
4046
break;
4147
case "perf": // Options
@@ -47,6 +53,9 @@ export const mainMenu = async (): Promise<boolean> => {
4753
case "docs": // Options
4854
await docsMenu();
4955
break;
56+
case "compile": // Options
57+
await compileMenu();
58+
break;
5059
case "exit": // Navigation
5160
return true;
5261
default:

package-lock.json

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
"solstl": "./bin/main.js"
77
},
88
"scripts": {
9-
"lint": "tslint",
109
"test": "jest && node ./bin/main.js tests --silent",
10+
"js-lint": "tslint -p .",
11+
"js-test": "jest",
1112
"contract-lint": "solhint src/**/*.sol",
13+
"contract-compile": "node ./bin/main.js compile",
1214
"contract-tests": "node ./bin/main.js tests",
1315
"contract-perf": "node ./bin/main.js perf"
1416
},

src/bits/Bits.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ pragma solidity ^0.4.16;
22
pragma experimental "v0.5.0";
33
pragma experimental "ABIEncoderV2";
44

5+
56
library Bits {
67

78
uint constant internal ONE = uint(1);

src/math/Math.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ pragma solidity ^0.4.16;
22
pragma experimental "v0.5.0";
33
pragma experimental "ABIEncoderV2";
44

5+
56
library Math {
67

78
uint constant internal UINT_ZERO = 0;

tslint.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@
1111
"no-console": false,
1212
"member-ordering": false
1313
}
14+
1415
}

0 commit comments

Comments
 (0)