Skip to content

Commit

Permalink
Merge pull request #286 from ethereum/new-breaking-api
Browse files Browse the repository at this point in the history
New breaking api, compile() is an alias to compileStandardWrapper()
  • Loading branch information
chriseth authored Nov 13, 2018
2 parents 04ff205 + e64ba8d commit a3798af
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ for (var contractName in output.contracts) {

#### From version 0.1.6

**Not available since 0.5.0**

Starting from version 0.1.6, multiple files are supported with automatic import resolution by the compiler as follows:

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

#### From version 0.2.1

**Not available since 0.5.0**

Starting from version 0.2.1, a callback is supported to resolve missing imports as follows:

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

#### From version 0.5.0

Starting from version 0.5.0, `compile`, `compileStandard` and `compileStandardWrapper` all do the same thing - what `compileStandardWrapper` used to do.

*Note*: with 0.5.1, `compileStandard` and `compileStandardWrapper` will be removed.

Starting from version 0.5.0 the low-level functions are also exposed:
- `solc.lowlevel.compileSingle`: the original entry point, supports only a single file
- `solc.lowlevel.compileMulti`: this supports multiple files, introduced in 0.1.6
Expand Down
14 changes: 11 additions & 3 deletions test/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ tape('Compilation', function (t) {
}
};

var output = JSON.parse(solc.compileStandardWrapper(JSON.stringify(input)));
var output = JSON.parse(solc.compile(JSON.stringify(input)));
var x = getBytecodeStandard(output, 'cont.sol', 'x');
st.ok(x);
st.ok(x.length > 0);
Expand Down Expand Up @@ -428,7 +428,7 @@ tape('Compilation', function (t) {
}
};

var output = JSON.parse(solc.compileStandardWrapper(JSON.stringify(input)));
var output = JSON.parse(solc.compile(JSON.stringify(input)));
var x = getBytecodeStandard(output, 'cont.sol', 'x');
st.ok(x);
st.ok(x.length > 0);
Expand Down Expand Up @@ -508,10 +508,18 @@ tape('Loading Legacy Versions', function (t) {
}
}
};
var output = JSON.parse(solcSnapshot.compileStandardWrapper(JSON.stringify(input)));
var output = JSON.parse(solcSnapshot.compile(JSON.stringify(input)));
var x = getBytecodeStandard(output, 'cont.sol', 'x');
st.ok(x);
st.ok(x.length > 0);
});
});
});

tape('API backwards compatibility', function (t) {
t.test('compileStandard and compileStandardWrapper exists', function (st) {
st.equal(solc.compile, solc.compileStandard);
st.equal(solc.compile, solc.compileStandardWrapper);
st.end();
});
});
24 changes: 4 additions & 20 deletions wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,6 @@ function setupMethods (soljson) {
};
}

var compile = function (input, optimise, readCallback) {
var result = '';
if (readCallback !== undefined && compileJSONCallback !== null) {
result = compileJSONCallback(JSON.stringify(input), optimise, readCallback);
} else if (typeof input !== 'string' && compileJSONMulti !== null) {
result = compileJSONMulti(JSON.stringify(input), optimise);
} else if (compileJSON !== null) {
result = compileJSON(input, optimise);
} else {
return { errors: 'No suitable compiler interface found.' };
}
return JSON.parse(result);
};

// Expects a Standard JSON I/O but supports old compilers
var compileStandardWrapper = function (input, readCallback) {
if (compileStandard !== null) {
Expand Down Expand Up @@ -237,13 +223,11 @@ function setupMethods (soljson) {
importCallback: compileJSONCallback !== null || compileStandard !== null,
nativeStandardJSON: compileStandard !== null
},
compile: compile,
compileStandard: compileStandard,
compile: compileStandardWrapper,
// Temporary wrappers to minimise breaking with other projects.
// NOTE: to be removed in 0.5.1
compileStandard: compileStandardWrapper,
compileStandardWrapper: compileStandardWrapper,
supportsSingle: compileJSON !== null,
supportsMulti: compileJSONMulti !== null,
supportsImportCallback: compileJSONCallback !== null,
supportsStandard: compileStandard !== null,
// Loads the compiler of the given version from the github repository
// instead of from the local filesystem.
loadRemoteVersion: function (versionString, cb) {
Expand Down

0 comments on commit a3798af

Please sign in to comment.