Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
4fbebfca
Commit
4fbebfca
authored
Dec 10, 2017
by
ninabreznik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add gas estimation for constructor
parent
ca35e270
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
3 deletions
+10
-3
contextView.js
src/app/editor/contextView.js
+1
-1
contextualListener.js
src/app/editor/contextualListener.js
+9
-2
No files found.
src/app/editor/contextView.js
View file @
4fbebfca
...
@@ -173,7 +173,7 @@ class ContextView {
...
@@ -173,7 +173,7 @@ class ContextView {
function
showGasEstimation
()
{
function
showGasEstimation
()
{
var
estimatedGas
=
self
.
_api
.
contextualListener
.
gasEstimation
(
node
)
+
' gas'
var
estimatedGas
=
self
.
_api
.
contextualListener
.
gasEstimation
(
node
)
+
' gas'
if
(
node
.
name
===
'FunctionDefinition'
&&
!
node
.
attributes
.
isConstructor
)
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>`
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
return
el
}
}
}
}
...
...
src/app/editor/contextualListener.js
View file @
4fbebfca
...
@@ -92,13 +92,17 @@ class ContextualListener {
...
@@ -92,13 +92,17 @@ class ContextualListener {
}
}
_getGasEstimation
(
results
)
{
_getGasEstimation
(
results
)
{
this
.
results
=
results
this
.
contractName
=
Object
.
keys
(
results
.
data
.
contracts
[
results
.
source
.
target
])[
0
]
this
.
contractName
=
Object
.
keys
(
results
.
data
.
contracts
[
results
.
source
.
target
])[
0
]
this
.
target
=
results
.
data
.
contracts
[
results
.
source
.
target
]
this
.
target
=
results
.
data
.
contracts
[
results
.
source
.
target
]
this
.
functions
=
Object
.
keys
(
this
.
target
[
this
.
contractName
].
evm
.
gasEstimates
.
external
)
this
.
functions
=
Object
.
keys
(
this
.
target
[
this
.
contractName
].
evm
.
gasEstimates
.
external
)
this
.
creationCost
=
this
.
target
[
this
.
contractName
].
evm
.
gasEstimates
.
creation
.
totalCost
}
}
gasEstimation
(
node
)
{
gasEstimation
(
node
)
{
if
(
node
.
name
===
'FunctionDefinition'
)
{
if
(
node
.
name
===
'FunctionDefinition'
)
{
var
estimation
if
(
!
node
.
attributes
.
isConstructor
)
{
var
functionName
=
node
.
attributes
.
name
var
functionName
=
node
.
attributes
.
name
var
fn
var
fn
for
(
var
x
in
this
.
functions
)
{
for
(
var
x
in
this
.
functions
)
{
...
@@ -107,10 +111,13 @@ class ContextualListener {
...
@@ -107,10 +111,13 @@ class ContextualListener {
break
break
}
}
}
}
var
estimation
=
this
.
target
[
this
.
contractName
].
evm
.
gasEstimates
.
external
[
fn
]
estimation
=
this
.
target
[
this
.
contractName
].
evm
.
gasEstimates
.
external
[
fn
]
return
estimation
}
else
{
estimation
=
this
.
creationCost
}
}
}
}
return
estimation
}
_highlight
(
node
,
compilationResult
)
{
_highlight
(
node
,
compilationResult
)
{
if
(
!
node
)
return
if
(
!
node
)
return
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment