Skip to content

Commit 3cfcdd0

Browse files
committed
Support the new solc public methods (solidity_compile/solidity_version/solidity_license)
1 parent e5419cc commit 3cfcdd0

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

wrapper.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function setupMethods (soljson) {
1313
}
1414
var compileJSONCallback = null;
1515
var compileStandard = null;
16-
if (('_compileJSONCallback' in soljson) || ('_compileStandard' in soljson)) {
16+
if (('_compileJSONCallback' in soljson) || ('_compileStandard' in soljson) || ('_solidity_compile' in soljson)) {
1717
var copyString = function (str, ptr) {
1818
var length = soljson.lengthBytesUTF8(str);
1919
var buffer = soljson._malloc(length + 1);
@@ -65,6 +65,12 @@ function setupMethods (soljson) {
6565
return runWithReadCallback(readCallback, compileStandardInternal, [ input ]);
6666
};
6767
}
68+
if ('_solidity_compile' in soljson) {
69+
var solidityCompile = soljson.cwrap('solidity_compile', 'string', ['string', 'number']);
70+
compileStandard = function (input, readCallback) {
71+
return runWithReadCallback(readCallback, solidityCompile, [ input ]);
72+
};
73+
}
6874
}
6975

7076
var compile = function (input, optimise, readCallback) {
@@ -170,7 +176,12 @@ function setupMethods (soljson) {
170176
return translateOutput(compileJSON(sources[Object.keys(sources)[0]], isOptimizerEnabled(input)), libraries);
171177
};
172178

173-
var version = soljson.cwrap('version', 'string', []);
179+
var version;
180+
if ('_solidity_version' in soljson) {
181+
version = soljson.cwrap('solidity_version', 'string', []);
182+
} else {
183+
version = soljson.cwrap('version', 'string', []);
184+
}
174185

175186
var versionToSemver = function () {
176187
return translate.versionToSemver(version());
@@ -180,7 +191,9 @@ function setupMethods (soljson) {
180191
// return undefined
181192
};
182193

183-
if ('_license' in soljson) {
194+
if ('_solidity_license' in soljson) {
195+
license = soljson.cwrap('solidity_license', 'string', []);
196+
} else if ('_license' in soljson) {
184197
license = soljson.cwrap('license', 'string', []);
185198
}
186199

0 commit comments

Comments
 (0)