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
4dddb109
Commit
4dddb109
authored
Dec 14, 2017
by
ninabreznik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add input params and construct entire signature
parent
ac741534
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
51 deletions
+53
-51
contextualListener.js
src/app/editor/contextualListener.js
+53
-51
No files found.
src/app/editor/contextualListener.js
View file @
4dddb109
...
@@ -92,57 +92,6 @@ class ContextualListener {
...
@@ -92,57 +92,6 @@ class ContextualListener {
}
}
}
}
_getGasEstimation
(
contract
)
{
this
.
contract
=
this
.
results
.
data
.
contracts
[
this
.
results
.
source
.
target
][
contract
.
attributes
.
name
]
this
.
estimationObj
=
this
.
contract
.
evm
.
gasEstimates
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
}
_getContract
(
node
)
{
for
(
var
i
in
this
.
nodes
)
{
if
(
this
.
nodes
[
i
].
id
===
node
.
attributes
.
scope
)
{
var
contract
=
this
.
_getGasEstimation
(
this
.
nodes
[
i
])
break
}
}
return
contract
}
gasEstimation
(
node
)
{
this
.
_getContract
(
node
)
var
executionCost
var
codeDepositCost
if
(
node
.
name
===
'FunctionDefinition'
)
{
if
(
!
node
.
attributes
.
isConstructor
)
{
var
functionName
=
node
.
attributes
.
name
if
(
node
.
attributes
.
visibility
===
'public'
)
{
executionCost
=
this
.
estimationObj
.
external
[
this
.
_getFn
(
this
.
externalFunctions
,
functionName
)]
}
else
if
(
node
.
attributes
.
visibility
===
'internal'
)
{
executionCost
=
this
.
estimationObj
.
internal
[
this
.
_getFn
(
this
.
internalFunctions
,
functionName
)]
}
}
else
{
executionCost
=
this
.
creationCost
codeDepositCost
=
this
.
codeDepositCost
}
}
else
{
executionCost
=
'-'
}
return
{
executionCost
,
codeDepositCost
}
}
_getFn
(
functions
,
name
)
{
for
(
var
x
in
functions
)
{
if
(
~
functions
[
x
].
indexOf
(
name
))
{
var
fn
=
functions
[
x
]
break
}
}
return
fn
}
_highlight
(
node
,
compilationResult
)
{
_highlight
(
node
,
compilationResult
)
{
if
(
!
node
)
return
if
(
!
node
)
return
var
position
=
this
.
sourceMappingDecoder
.
decode
(
node
.
src
)
var
position
=
this
.
sourceMappingDecoder
.
decode
(
node
.
src
)
...
@@ -180,6 +129,59 @@ class ContextualListener {
...
@@ -180,6 +129,59 @@ class ContextualListener {
}
}
this
.
_activeHighlights
=
[]
this
.
_activeHighlights
=
[]
}
}
// GET GAS ESTIMATION
_getGasEstimation
(
contract
)
{
this
.
contract
=
this
.
results
.
data
.
contracts
[
this
.
results
.
source
.
target
][
contract
.
attributes
.
name
]
this
.
estimationObj
=
this
.
contract
.
evm
.
gasEstimates
this
.
creationCost
=
this
.
estimationObj
.
creation
.
totalCost
this
.
codeDepositCost
=
this
.
estimationObj
.
creation
.
codeDepositCost
}
gasEstimation
(
node
)
{
this
.
_getContract
(
node
)
var
executionCost
var
codeDepositCost
if
(
node
.
name
===
'FunctionDefinition'
)
{
if
(
!
node
.
attributes
.
isConstructor
)
{
var
fnName
=
node
.
attributes
.
name
var
fn
=
fnName
+
this
.
_getInputParams
(
fnName
)
if
(
node
.
attributes
.
visibility
===
'public'
)
{
executionCost
=
this
.
estimationObj
.
external
[
fn
]
}
else
if
(
node
.
attributes
.
visibility
===
'internal'
)
{
executionCost
=
this
.
estimationObj
.
internal
[
fn
]
}
}
else
{
executionCost
=
this
.
creationCost
codeDepositCost
=
this
.
codeDepositCost
}
}
else
{
executionCost
=
'-'
}
return
{
executionCost
,
codeDepositCost
}
}
_getContract
(
node
)
{
for
(
var
i
in
this
.
nodes
)
{
if
(
this
.
nodes
[
i
].
id
===
node
.
attributes
.
scope
)
{
var
contract
=
this
.
_getGasEstimation
(
this
.
nodes
[
i
])
break
}
}
return
contract
}
_getInputParams
(
fnName
)
{
var
abi
=
this
.
contract
.
abi
for
(
var
i
in
abi
)
{
if
(
abi
[
i
].
name
===
fnName
)
{
var
inputs
=
abi
[
i
].
inputs
var
inputParams
=
inputs
.
length
?
'('
+
inputs
[
0
].
type
+
')'
:
'()'
break
}
}
return
inputParams
}
}
}
module
.
exports
=
ContextualListener
module
.
exports
=
ContextualListener
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