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
7acebca2
Commit
7acebca2
authored
Dec 08, 2017
by
ninabreznik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First draft
parent
c6c1b343
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
3 deletions
+38
-3
contextView.js
src/app/editor/contextView.js
+16
-0
contextualListener.js
src/app/editor/contextualListener.js
+22
-3
No files found.
src/app/editor/contextView.js
View file @
7acebca2
...
...
@@ -42,6 +42,15 @@ var css = csjs`
float : right;
margin-left : 15px;
}
.gasEstimation {
margin-left: 15px;
display: flex;
align-items: center;
}
.gasStationIcon {
height: 13px;
margin-right: 5px;
}
`
/*
...
...
@@ -159,7 +168,14 @@ class ContextView {
<span class=
${
css
.
referencesnb
}
>
${
references
}
</span>
<i data-action='previous' class="fa fa-chevron-up
${
css
.
jump
}
" aria-hidden="true" onclick=
${
jump
}
></i>
<i data-action='next' class="fa fa-chevron-down
${
css
.
jump
}
" aria-hidden="true" onclick=
${
jump
}
></i>
${
showGasEstimation
()}
</div>`
function
showGasEstimation
()
{
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>`
return
el
}
}
}
...
...
src/app/editor/contextualListener.js
View file @
7acebca2
...
...
@@ -39,9 +39,6 @@ class ContextualListener {
getActiveHighlights
()
{
return
[...
this
.
_activeHighlights
]
// return [...this._activeHighlights].sort((a,b) => {
// return a.position.start - b.position.start
// })
}
declarationOf
(
node
)
{
...
...
@@ -94,6 +91,27 @@ class ContextualListener {
}
}
_getGasEstimation
(
results
)
{
this
.
contractName
=
Object
.
keys
(
results
.
data
.
contracts
[
results
.
source
.
target
])[
0
]
this
.
target
=
results
.
data
.
contracts
[
results
.
source
.
target
]
this
.
functions
=
Object
.
keys
(
this
.
target
[
this
.
contractName
].
evm
.
gasEstimates
.
external
)
}
gasEstimation
(
node
)
{
if
(
node
.
name
===
'FunctionDefinition'
)
{
var
functionName
=
node
.
attributes
.
name
var
fn
for
(
var
x
in
this
.
functions
)
{
if
(
!!~
this
.
functions
[
x
].
indexOf
(
functionName
))
{
fn
=
this
.
functions
[
x
]
break
}
}
var
estimation
=
this
.
target
[
this
.
contractName
].
evm
.
gasEstimates
.
external
[
fn
]
return
estimation
}
}
_highlight
(
node
,
compilationResult
)
{
if
(
!
node
)
return
var
position
=
this
.
sourceMappingDecoder
.
decode
(
node
.
src
)
...
...
@@ -122,6 +140,7 @@ class ContextualListener {
highlights
(
node
.
id
)
this
.
_highlight
(
node
,
compilationResult
)
}
this
.
_getGasEstimation
(
compilationResult
)
}
_stopHighlighting
()
{
...
...
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