Commit 612cf1de authored by ninabreznik's avatar ninabreznik

Add codeDepositCost and gasStation img in png

parent 47200304
File added
......@@ -172,10 +172,16 @@ class ContextView {
</div>`
function showGasEstimation () {
var estimatedGas = self._api.contextualListener.gasEstimation(node) + ' gas'
if (node.name === 'FunctionDefinition') var el = yo`<div class=${css.gasEstimation}> <img class=${css.gasStationIcon} title='Estimated gas price' src='https://png.icons8.com/gas-station/win8/50/000000'> ${estimatedGas}</div>`
return el
var result = self._api.contextualListener.gasEstimation(node)
var executionCost = 'Execution cost: ' + result.executionCost + ' gas'
var codeDepositCost = 'Code deposit cost: ' + result.codeDepositCost + ' gas'
var estimatedGas = result.codeDepositCost ? `${codeDepositCost}, ${executionCost}` : `${executionCost}`
return yo`<div class=${css.gasEstimation}>
<img class=${css.gasStationIcon} title='Gas estimation' src='assets/img/gasStation_50.png'>
${estimatedGas}
</div>`
}
}
}
......
......@@ -99,6 +99,7 @@ class ContextualListener {
if (this.estimationObj.external) this.externalFunctions = Object.keys(this.estimationObj.external)
if (this.estimationObj.internal) this.internalFunctions = Object.keys(this.estimationObj.internal)
this.creationCost = this.estimationObj.creation.totalCost
this.codeDepositCost = this.estimationObj.creation.codeDepositCost
}
gasEstimation (node) {
......@@ -106,13 +107,13 @@ class ContextualListener {
if (!node.attributes.isConstructor) {
var functionName = node.attributes.name
if (this.externalFunctions) {
return this.estimationObj.external[this._getFn(this.externalFunctions, functionName)]
return {executionCost: this.estimationObj.external[this._getFn(this.externalFunctions, functionName)]}
}
if (this.internalFunctions) {
return this.estimationObj.internal[this._getFn(this.internalFunctions, functionName)]
return {executionCost: this.estimationObj.internal[this._getFn(this.internalFunctions, functionName)]}
}
} else {
return this.creationCost
return {executionCost: this.creationCost, codeDepositCost: this.codeDepositCost}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment