diff --git a/js/src/util/solidity.js b/js/src/util/solidity.js index 40bb2536a..9bdca88fc 100644 --- a/js/src/util/solidity.js +++ b/js/src/util/solidity.js @@ -18,14 +18,14 @@ import solc from 'solc/browser-wrapper'; export default class SolidityUtils { static compile (data, compiler) { - const { sourcecode, build, optimize, files } = data; + const { sourcecode, build, optimize, files, name = '' } = data; const start = Date.now(); console.log('[solidity] compiling...'); const input = { - '': sourcecode + [ name ]: sourcecode }; const findFiles = (path) => { diff --git a/js/src/views/WriteContract/writeContractStore.js b/js/src/views/WriteContract/writeContractStore.js index e77ee9afb..bcea1c403 100644 --- a/js/src/views/WriteContract/writeContractStore.js +++ b/js/src/views/WriteContract/writeContractStore.js @@ -259,10 +259,15 @@ export default class WriteContractStore { } compile = (data) => { + const { name = '' } = this.selectedContract; + if (this.useWorker) { return this.worker.postMessage({ action: 'compile', - data + data: { + ...data, + name + } }); } @@ -271,7 +276,10 @@ export default class WriteContractStore { this .getCompiler(data.build) .then((compiler) => { - return SolidityUtils.compile(data, compiler); + return SolidityUtils.compile({ + ...data, + name + }, compiler); }) .then(resolve) .catch(reject);