Skip to content

Commit 77224d1

Browse files
authored
Merge pull request #410 from ethereum/change-lowlevel-api
Change lowlevel API to also expect a callback object
2 parents af0aaef + 12bf856 commit 77224d1

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

test/compiler.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ function runTests (solc, versionText) {
169169
return { error: 'File not found' };
170170
}
171171
}
172-
var output = JSON.parse(solc.lowlevel.compileCallback(JSON.stringify({sources: input}), 0, findImports));
172+
var output = JSON.parse(solc.lowlevel.compileCallback(JSON.stringify({sources: input}), 0, { import: findImports }));
173173
var x = getBytecode(output, 'cont.sol', 'x');
174174
var L = getBytecode(output, 'lib.sol', 'L');
175175
st.ok(typeof x === 'string');
@@ -193,7 +193,7 @@ function runTests (solc, versionText) {
193193
function findImports (path) {
194194
return { error: 'File not found' };
195195
}
196-
var output = JSON.parse(solc.lowlevel.compileCallback(JSON.stringify({sources: input}), 0, findImports));
196+
var output = JSON.parse(solc.lowlevel.compileCallback(JSON.stringify({sources: input}), 0, { import: findImports }));
197197
st.plan(3);
198198
st.ok('errors' in output);
199199
// Check if the ParserError exists, but allow others too
@@ -224,7 +224,7 @@ function runTests (solc, versionText) {
224224
throw new Error('Could not implement this interface properly...');
225225
}
226226
st.throws(function () {
227-
solc.lowlevel.compileCallback(JSON.stringify({sources: input}), 0, findImports);
227+
solc.lowlevel.compileCallback(JSON.stringify({sources: input}), 0, { import: findImports });
228228
}, /^Error: Could not implement this interface properly.../);
229229
st.end();
230230
});
@@ -242,7 +242,7 @@ function runTests (solc, versionText) {
242242
};
243243
st.throws(function () {
244244
solc.lowlevel.compileCallback(JSON.stringify({sources: input}), 0, "this isn't a callback");
245-
}, /Invalid callback specified./);
245+
}, /Invalid callback object specified./);
246246
st.end();
247247
});
248248

@@ -387,7 +387,7 @@ function runTests (solc, versionText) {
387387
}
388388
}
389389

390-
var output = JSON.parse(solc.lowlevel.compileStandard(JSON.stringify(input), findImports));
390+
var output = JSON.parse(solc.lowlevel.compileStandard(JSON.stringify(input), { import: findImports }));
391391
st.ok(bytecodeExists(output, 'cont.sol', 'x'));
392392
st.ok(bytecodeExists(output, 'lib.sol', 'L'));
393393
st.end();
@@ -462,16 +462,13 @@ function runTests (solc, versionText) {
462462
}
463463
}
464464

465-
var output = JSON.parse(solc.compile(JSON.stringify(input), findImports));
465+
var output = JSON.parse(solc.compile(JSON.stringify(input), { import: findImports }));
466466
var x = getBytecodeStandard(output, 'cont.sol', 'x');
467467
st.ok(typeof x === 'string');
468468
st.ok(x.length > 0);
469469
var L = getBytecodeStandard(output, 'lib.sol', 'L');
470470
st.ok(typeof L === 'string');
471471
st.ok(L.length > 0);
472-
473-
var outputNewApi = JSON.parse(solc.compile(JSON.stringify(input), { import: findImports }));
474-
st.deepEqual(output, outputNewApi);
475472
st.end();
476473
});
477474

wrapper.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ function setupMethods (soljson) {
5050

5151
// This calls compile() with args || cb
5252
var runWithReadCallback = function (readCallback, compile, args) {
53-
// Forward compatibility with 0.6.x
54-
if (typeof readCallback === 'object') {
53+
if (readCallback) {
54+
assert(typeof readCallback === 'object', 'Invalid callback object specified.');
5555
readCallback = readCallback.import;
5656
}
5757

@@ -132,15 +132,6 @@ function setupMethods (soljson) {
132132
});
133133
}
134134

135-
// Forward compatibility with 0.6.x
136-
if (typeof readCallback === 'object') {
137-
readCallback = readCallback.import;
138-
}
139-
140-
if (readCallback !== undefined) {
141-
assert(typeof readCallback === 'function', 'Invalid callback specified.');
142-
}
143-
144135
try {
145136
input = JSON.parse(input);
146137
} catch (e) {

0 commit comments

Comments
 (0)