Skip to content

Commit 9e6567e

Browse files
committed
Link bytecode if libraries were supplied in compileStandardWrapper
1 parent 7b10253 commit 9e6567e

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

translate.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function translateGasEstimates (gasEstimates) {
5959
return gasEstimatesTranslated;
6060
}
6161

62-
function translateJsonCompilerOutput (output) {
62+
function translateJsonCompilerOutput (output, libraries) {
6363
var ret = {};
6464

6565
ret['errors'] = [];
@@ -110,13 +110,13 @@ function translateJsonCompilerOutput (output) {
110110
'evm': {
111111
'legacyAssembly': contractInput['assembly'],
112112
'bytecode': {
113-
'object': contractInput['bytecode'],
113+
'object': linker.linkBytecode(contractInput['bytecode'], libraries),
114114
'opcodes': contractInput['opcodes'],
115115
'sourceMap': contractInput['srcmap'],
116116
'linkReferences': linker.findLinkReferences(contractInput['bytecode'])
117117
},
118118
'deployedBytecode': {
119-
'object': contractInput['runtimeBytecode'],
119+
'object': linker.linkBytecode(contractInput['runtimeBytecode'], libraries),
120120
'sourceMap': contractInput['srcmapRuntime'],
121121
'linkReferences': linker.findLinkReferences(contractInput['runtimeBytecode'])
122122
},

wrapper.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ function setupMethods (soljson) {
135135
return sources;
136136
}
137137

138+
function librariesSupplied (input) {
139+
if (input['settings'] !== null) {
140+
return input['settings']['libraries'];
141+
}
142+
}
143+
138144
function translateOutput (output) {
139145
output = translate.translateJsonCompilerOutput(JSON.parse(output));
140146
if (output == null) {
@@ -148,17 +154,20 @@ function setupMethods (soljson) {
148154
return formatFatalError('Failed to process sources');
149155
}
150156

157+
// Try linking if libraries were supplied
158+
var libraries = librariesSupplied(input);
159+
151160
// Try to wrap around old versions
152161
if (compileJSONCallback !== null) {
153-
return translateOutput(compileJSONCallback(JSON.stringify({ 'sources': sources }), isOptimizerEnabled(input), readCallback));
162+
return translateOutput(compileJSONCallback(JSON.stringify({ 'sources': sources }), isOptimizerEnabled(input), readCallback), libraries);
154163
}
155164

156165
if (compileJSONMulti !== null) {
157-
return translateOutput(compileJSONMulti(JSON.stringify({ 'sources': sources }), isOptimizerEnabled(input)));
166+
return translateOutput(compileJSONMulti(JSON.stringify({ 'sources': sources }), isOptimizerEnabled(input)), libraries);
158167
}
159168

160169
// Try our luck with an ancient compiler
161-
return translateOutput(compileJSON(sources[Object.keys(sources)[0]], isOptimizerEnabled(input)));
170+
return translateOutput(compileJSON(sources[Object.keys(sources)[0]], isOptimizerEnabled(input)), libraries);
162171
};
163172

164173
var version = soljson.cwrap('version', 'string', []);

0 commit comments

Comments
 (0)