Skip to content

Commit 23b7472

Browse files
authored
Merge pull request #168 from ethereum/gasEstimation
Fix gas estimation translation
2 parents ac8b1bc + 73faa20 commit 23b7472

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

translate.js

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

6262
var gasEstimates = contractInput['gasEstimates'];
63+
var translatedGasEstimates = {};
64+
65+
if (gasEstimates['creation']) {
66+
translatedGasEstimates['creation'] = {
67+
'codeDepositCost': translateGasEstimates(gasEstimates['creation'][1]),
68+
'executionCost': translateGasEstimates(gasEstimates['creation'][0])
69+
};
70+
}
71+
if (gasEstimates['internal']) {
72+
translatedGasEstimates['internal'] = translateGasEstimates(gasEstimates['internal']);
73+
}
74+
if (gasEstimates['external']) {
75+
translatedGasEstimates['external'] = translateGasEstimates(gasEstimates['external']);
76+
}
6377

6478
var contractOutput = {
6579
'abi': JSON.parse(contractInput['interface']),
@@ -76,14 +90,7 @@ function translateJsonCompilerOutput (output) {
7690
'sourceMap': contractInput['srcmapRuntime']
7791
},
7892
'methodIdentifiers': contractInput['functionHashes'],
79-
'gasEstimates': {
80-
'creation': {
81-
'codeDepositCost': translateGasEstimates(gasEstimates['creation'][1]),
82-
'executionCost': translateGasEstimates(gasEstimates['creation'][0])
83-
},
84-
'internal': translateGasEstimates(gasEstimates['internal']),
85-
'external': translateGasEstimates(gasEstimates['external'])
86-
}
93+
'gasEstimates': translatedGasEstimates
8794
}
8895
};
8996

0 commit comments

Comments
 (0)