Skip to content

Commit 73faa20

Browse files
committed
Avoid creating invalid gasEstimates table
1 parent f3a9871 commit 73faa20

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

translate.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,19 @@ function translateJsonCompilerOutput (output) {
6060
var contractInput = output['contracts'][contract];
6161

6262
var gasEstimates = contractInput['gasEstimates'];
63-
// FIXME: support undefined or a nicer way in translateGasEstimates
64-
if (!gasEstimates['creation']) {
65-
gasEstimates['creation'] = [ null, null ];
63+
var translatedGasEstimates = {};
64+
65+
if (gasEstimates['creation']) {
66+
translatedGasEstimates['creation'] = {
67+
'codeDepositCost': translateGasEstimates(gasEstimates['creation'][1]),
68+
'executionCost': translateGasEstimates(gasEstimates['creation'][0])
69+
};
6670
}
67-
if (!gasEstimates['internal']) {
68-
gasEstimates['internal'] = null;
71+
if (gasEstimates['internal']) {
72+
translatedGasEstimates['internal'] = translateGasEstimates(gasEstimates['internal']);
6973
}
70-
if (!gasEstimates['external']) {
71-
gasEstimates['external'] = null;
74+
if (gasEstimates['external']) {
75+
translatedGasEstimates['external'] = translateGasEstimates(gasEstimates['external']);
7276
}
7377

7478
var contractOutput = {
@@ -86,14 +90,7 @@ function translateJsonCompilerOutput (output) {
8690
'sourceMap': contractInput['srcmapRuntime']
8791
},
8892
'methodIdentifiers': contractInput['functionHashes'],
89-
'gasEstimates': {
90-
'creation': {
91-
'codeDepositCost': translateGasEstimates(gasEstimates['creation'][1]),
92-
'executionCost': translateGasEstimates(gasEstimates['creation'][0])
93-
},
94-
'internal': translateGasEstimates(gasEstimates['internal']),
95-
'external': translateGasEstimates(gasEstimates['external'])
96-
}
93+
'gasEstimates': translatedGasEstimates
9794
}
9895
};
9996

0 commit comments

Comments
 (0)