Skip to content

Commit a3798af

Browse files
authored
Merge pull request #286 from ethereum/new-breaking-api
New breaking api, compile() is an alias to compileStandardWrapper()
2 parents 04ff205 + e64ba8d commit a3798af

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ for (var contractName in output.contracts) {
4949

5050
#### From version 0.1.6
5151

52+
**Not available since 0.5.0**
53+
5254
Starting from version 0.1.6, multiple files are supported with automatic import resolution by the compiler as follows:
5355

5456
```javascript
@@ -66,6 +68,8 @@ Note that all input files that are imported have to be supplied, the compiler wi
6668

6769
#### From version 0.2.1
6870

71+
**Not available since 0.5.0**
72+
6973
Starting from version 0.2.1, a callback is supported to resolve missing imports as follows:
7074

7175
```javascript
@@ -107,6 +111,10 @@ Starting from version 0.4.20 a Semver compatible version number can be retrieved
107111

108112
#### From version 0.5.0
109113

114+
Starting from version 0.5.0, `compile`, `compileStandard` and `compileStandardWrapper` all do the same thing - what `compileStandardWrapper` used to do.
115+
116+
*Note*: with 0.5.1, `compileStandard` and `compileStandardWrapper` will be removed.
117+
110118
Starting from version 0.5.0 the low-level functions are also exposed:
111119
- `solc.lowlevel.compileSingle`: the original entry point, supports only a single file
112120
- `solc.lowlevel.compileMulti`: this supports multiple files, introduced in 0.1.6

test/package.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ tape('Compilation', function (t) {
386386
}
387387
};
388388

389-
var output = JSON.parse(solc.compileStandardWrapper(JSON.stringify(input)));
389+
var output = JSON.parse(solc.compile(JSON.stringify(input)));
390390
var x = getBytecodeStandard(output, 'cont.sol', 'x');
391391
st.ok(x);
392392
st.ok(x.length > 0);
@@ -428,7 +428,7 @@ tape('Compilation', function (t) {
428428
}
429429
};
430430

431-
var output = JSON.parse(solc.compileStandardWrapper(JSON.stringify(input)));
431+
var output = JSON.parse(solc.compile(JSON.stringify(input)));
432432
var x = getBytecodeStandard(output, 'cont.sol', 'x');
433433
st.ok(x);
434434
st.ok(x.length > 0);
@@ -508,10 +508,18 @@ tape('Loading Legacy Versions', function (t) {
508508
}
509509
}
510510
};
511-
var output = JSON.parse(solcSnapshot.compileStandardWrapper(JSON.stringify(input)));
511+
var output = JSON.parse(solcSnapshot.compile(JSON.stringify(input)));
512512
var x = getBytecodeStandard(output, 'cont.sol', 'x');
513513
st.ok(x);
514514
st.ok(x.length > 0);
515515
});
516516
});
517517
});
518+
519+
tape('API backwards compatibility', function (t) {
520+
t.test('compileStandard and compileStandardWrapper exists', function (st) {
521+
st.equal(solc.compile, solc.compileStandard);
522+
st.equal(solc.compile, solc.compileStandardWrapper);
523+
st.end();
524+
});
525+
});

wrapper.js

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,6 @@ function setupMethods (soljson) {
7979
};
8080
}
8181

82-
var compile = function (input, optimise, readCallback) {
83-
var result = '';
84-
if (readCallback !== undefined && compileJSONCallback !== null) {
85-
result = compileJSONCallback(JSON.stringify(input), optimise, readCallback);
86-
} else if (typeof input !== 'string' && compileJSONMulti !== null) {
87-
result = compileJSONMulti(JSON.stringify(input), optimise);
88-
} else if (compileJSON !== null) {
89-
result = compileJSON(input, optimise);
90-
} else {
91-
return { errors: 'No suitable compiler interface found.' };
92-
}
93-
return JSON.parse(result);
94-
};
95-
9682
// Expects a Standard JSON I/O but supports old compilers
9783
var compileStandardWrapper = function (input, readCallback) {
9884
if (compileStandard !== null) {
@@ -237,13 +223,11 @@ function setupMethods (soljson) {
237223
importCallback: compileJSONCallback !== null || compileStandard !== null,
238224
nativeStandardJSON: compileStandard !== null
239225
},
240-
compile: compile,
241-
compileStandard: compileStandard,
226+
compile: compileStandardWrapper,
227+
// Temporary wrappers to minimise breaking with other projects.
228+
// NOTE: to be removed in 0.5.1
229+
compileStandard: compileStandardWrapper,
242230
compileStandardWrapper: compileStandardWrapper,
243-
supportsSingle: compileJSON !== null,
244-
supportsMulti: compileJSONMulti !== null,
245-
supportsImportCallback: compileJSONCallback !== null,
246-
supportsStandard: compileStandard !== null,
247231
// Loads the compiler of the given version from the github repository
248232
// instead of from the local filesystem.
249233
loadRemoteVersion: function (versionString, cb) {

0 commit comments

Comments
 (0)