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
4c0a7417
Commit
4c0a7417
authored
Dec 15, 2020
by
aniket-engg
Committed by
Aniket
Dec 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
solidity decoder imports updated
parent
2dc8d11a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
49 deletions
+46
-49
decodeInfo.ts
libs/remix-debug/src/solidity-decoder/decodeInfo.ts
+16
-16
index.ts
libs/remix-debug/src/solidity-decoder/index.ts
+4
-4
internalCallTree.ts
libs/remix-debug/src/solidity-decoder/internalCallTree.ts
+18
-20
solidityProxy.ts
libs/remix-debug/src/solidity-decoder/solidityProxy.ts
+8
-9
No files found.
libs/remix-debug/src/solidity-decoder/decodeInfo.ts
View file @
4c0a7417
'use strict'
const
AddressType
=
require
(
'./types/Address'
)
const
ArrayType
=
require
(
'./types/ArrayType'
)
const
BoolType
=
require
(
'./types/Bool'
)
const
BytesType
=
require
(
'./types/DynamicByteArray'
)
const
BytesXType
=
require
(
'./types/FixedByteArray'
)
const
EnumType
=
require
(
'./types/Enum'
)
const
StringType
=
require
(
'./types/StringType'
)
const
StructType
=
require
(
'./types/Struct'
)
const
IntType
=
require
(
'./types/Int'
)
const
UintType
=
require
(
'./types/Uint'
)
const
MappingType
=
require
(
'./types/Mapping'
)
const
util
=
require
(
'./types/util'
)
import
{
Address
as
AddressType
}
from
'./types/Address'
import
{
ArrayType
}
from
'./types/ArrayType'
import
{
Bool
as
BoolType
}
from
'./types/Bool'
import
{
DynamicByteArray
as
BytesType
}
from
'./types/DynamicByteArray'
import
{
FixedByteArray
as
BytesXType
}
from
'./types/FixedByteArray'
import
{
Enum
as
EnumType
}
from
'./types/Enum'
import
{
StringType
}
from
'./types/StringType'
import
{
Struct
as
StructType
}
from
'./types/Struct'
import
{
Int
as
IntType
}
from
'./types/Int'
import
{
Uint
as
UintType
}
from
'./types/Uint'
import
{
Mapping
as
MappingType
}
from
'./types/Mapping'
import
{
extractLocation
,
removeLocation
}
from
'./types/util'
/**
* mapping decode the given @arg type
...
...
@@ -31,7 +31,7 @@ function mapping (type, stateDefinitions, contractName) {
'keyType'
:
keyType
,
'valueType'
:
valueType
}
return
new
MappingType
(
underlyingTypes
,
'location'
,
util
.
removeLocation
(
type
))
return
new
MappingType
(
underlyingTypes
,
'location'
,
removeLocation
(
type
))
}
/**
...
...
@@ -89,7 +89,7 @@ function bool (type) {
*/
function
dynamicByteArray
(
type
,
stateDefinitions
,
contractName
,
location
)
{
if
(
!
location
)
{
location
=
util
.
extractLocation
(
type
)
location
=
extractLocation
(
type
)
}
if
(
location
)
{
return
new
BytesType
(
location
)
...
...
@@ -120,7 +120,7 @@ function fixedByteArray (type) {
*/
function
stringType
(
type
,
stateDefinitions
,
contractName
,
location
)
{
if
(
!
location
)
{
location
=
util
.
extractLocation
(
type
)
location
=
extractLocation
(
type
)
}
if
(
location
)
{
return
new
StringType
(
location
)
...
...
@@ -265,7 +265,7 @@ function getStructMembers (type, stateDefinitions, contractName, location) {
* @return {String} returns the token type (used to instanciate the right decoder) (uint[2] storage ref[2] will return 'array', uint256 will return uintX)
*/
function
typeClass
(
fullType
)
{
fullType
=
util
.
removeLocation
(
fullType
)
fullType
=
removeLocation
(
fullType
)
if
(
fullType
.
lastIndexOf
(
']'
)
===
fullType
.
length
-
1
)
{
return
'array'
}
...
...
libs/remix-debug/src/solidity-decoder/index.ts
View file @
4c0a7417
const
SolidityProxy
=
require
(
'./solidityProxy'
)
const
stateDecoder
=
require
(
'./stateDecoder'
)
const
localDecoder
=
require
(
'./localDecoder'
)
const
InternalCallTree
=
require
(
'./internalCallTree'
)
import
{
SolidityProxy
}
from
'./solidityProxy'
import
*
as
stateDecoder
from
'./stateDecoder'
import
*
as
localDecoder
from
'./localDecoder'
import
{
InternalCallTree
}
from
'./internalCallTree'
export
{
SolidityProxy
,
stateDecoder
,
localDecoder
,
InternalCallTree
}
libs/remix-debug/src/solidity-decoder/internalCallTree.ts
View file @
4c0a7417
'use strict'
const
{
AstWalker
}
=
require
(
'@remix-project/remix-astwalker'
)
const
remixLib
=
require
(
'@remix-project/remix-lib'
)
const
SourceLocationTracker
=
require
(
'../source/sourceLocationTracker'
)
const
EventManager
=
require
(
'../eventManager'
)
const
decodeInfo
=
require
(
'./decodeInfo'
)
const
util
=
remixLib
.
util
const
traceHelper
=
require
(
'../trace/traceHelper'
)
const
typesUtil
=
require
(
'./types/util.js'
)
import
{
AstWalker
}
from
'@remix-project/remix-astwalker'
import
{
util
}
from
'@remix-project/remix-lib'
import
{
SourceLocationTracker
}
from
'../source/sourceLocationTracker'
import
{
EventManager
}
from
'../eventManager'
import
{
parseType
}
from
'./decodeInfo'
import
{
isContractCreation
,
isCallInstruction
,
isCreateInstruction
,
isJumpDestInstruction
}
from
'../trace/traceHelper'
import
{
extractLocationFromAstVariable
}
from
'./types/util.js'
/**
* Tree representing internal jump into function.
...
...
@@ -54,7 +52,7 @@ export class InternalCallTree {
}
else
{
// each recursive call to buildTree represent a new context (either call, delegatecall, internal function)
const
calledAddress
=
traceManager
.
getCurrentCalledAddressAt
(
0
)
const
isCreation
=
traceHelper
.
isContractCreation
(
calledAddress
)
const
isCreation
=
isContractCreation
(
calledAddress
)
buildTree
(
this
,
0
,
''
,
true
,
isCreation
).
then
((
result
)
=>
{
if
(
result
.
error
)
{
this
.
event
.
trigger
(
'callTreeBuildFailed'
,
[
result
.
error
])
...
...
@@ -204,12 +202,12 @@ async function buildTree (tree, step, scopeId, isExternalCall, isCreation) {
if
(
!
sourceLocation
)
{
return
{
outStep
:
step
,
error
:
'InternalCallTree - No source Location. '
+
step
}
}
const
isCallInstr
uction
=
traceHelper
.
isCallInstruction
(
tree
.
traceManager
.
trace
[
step
])
const
isCreateInstr
uction
=
traceHelper
.
isCreateInstruction
(
tree
.
traceManager
.
trace
[
step
])
const
isCallInstr
n
=
isCallInstruction
(
tree
.
traceManager
.
trace
[
step
])
const
isCreateInstr
n
=
isCreateInstruction
(
tree
.
traceManager
.
trace
[
step
])
// we are checking if we are jumping in a new CALL or in an internal function
if
(
isCallInstr
uctio
n
||
sourceLocation
.
jump
===
'i'
)
{
if
(
isCallInstrn
||
sourceLocation
.
jump
===
'i'
)
{
try
{
const
externalCallResult
=
await
buildTree
(
tree
,
step
+
1
,
scopeId
===
''
?
subScope
.
toString
()
:
scopeId
+
'.'
+
subScope
,
isCallInstr
uction
,
isCreateInstructio
n
)
const
externalCallResult
=
await
buildTree
(
tree
,
step
+
1
,
scopeId
===
''
?
subScope
.
toString
()
:
scopeId
+
'.'
+
subScope
,
isCallInstr
n
,
isCreateInstr
n
)
if
(
externalCallResult
.
error
)
{
return
{
outStep
:
step
,
error
:
'InternalCallTree - '
+
externalCallResult
.
error
}
}
else
{
...
...
@@ -264,12 +262,12 @@ async function includeVariableDeclaration (tree, step, sourceLocation, scopeId,
// so, either this is the direct value, or the offset in memory. That depends on the type.
if
(
variableDeclaration
.
name
!==
''
)
{
states
=
tree
.
solidityProxy
.
extractStatesDefinitions
()
var
location
=
typesUtil
.
extractLocationFromAstVariable
(
variableDeclaration
)
var
location
=
extractLocationFromAstVariable
(
variableDeclaration
)
location
=
location
===
'default'
?
'storage'
:
location
// we push the new local variable in our tree
tree
.
scopes
[
scopeId
].
locals
[
variableDeclaration
.
name
]
=
{
name
:
variableDeclaration
.
name
,
type
:
decodeInfo
.
parseType
(
variableDeclaration
.
typeDescriptions
.
typeString
,
states
,
contractObj
.
name
,
location
),
type
:
parseType
(
variableDeclaration
.
typeDescriptions
.
typeString
,
states
,
contractObj
.
name
,
location
),
stackDepth
:
stack
.
length
,
sourceLocation
:
sourceLocation
}
...
...
@@ -283,8 +281,8 @@ async function includeVariableDeclaration (tree, step, sourceLocation, scopeId,
const
functionDefinition
=
resolveFunctionDefinition
(
tree
,
previousSourceLocation
,
generatedSources
)
if
(
!
functionDefinition
)
return
const
previousIsJumpDest2
=
traceHelper
.
isJumpDestInstruction
(
tree
.
traceManager
.
trace
[
step
-
2
])
const
previousIsJumpDest1
=
traceHelper
.
isJumpDestInstruction
(
tree
.
traceManager
.
trace
[
step
-
1
])
const
previousIsJumpDest2
=
isJumpDestInstruction
(
tree
.
traceManager
.
trace
[
step
-
2
])
const
previousIsJumpDest1
=
isJumpDestInstruction
(
tree
.
traceManager
.
trace
[
step
-
1
])
const
isConstructor
=
functionDefinition
.
kind
===
'constructor'
if
(
newLocation
&&
(
previousIsJumpDest1
||
previousIsJumpDest2
||
isConstructor
))
{
tree
.
functionCallStack
.
push
(
step
)
...
...
@@ -376,12 +374,12 @@ function addParams (parameterList, tree, scopeId, states, contractName, sourceLo
const
param
=
parameterList
.
parameters
[
inputParam
]
const
stackDepth
=
stackLength
+
(
dir
*
stackPosition
)
if
(
stackDepth
>=
0
)
{
let
location
=
typesUtil
.
extractLocationFromAstVariable
(
param
)
let
location
=
extractLocationFromAstVariable
(
param
)
location
=
location
===
'default'
?
'memory'
:
location
const
attributesName
=
param
.
name
===
''
?
`$
${
inputParam
}
`
:
param
.
name
tree
.
scopes
[
scopeId
].
locals
[
attributesName
]
=
{
name
:
attributesName
,
type
:
decodeInfo
.
parseType
(
param
.
typeDescriptions
.
typeString
,
states
,
contractName
,
location
),
type
:
parseType
(
param
.
typeDescriptions
.
typeString
,
states
,
contractName
,
location
),
stackDepth
:
stackDepth
,
sourceLocation
:
sourceLocation
}
...
...
libs/remix-debug/src/solidity-decoder/solidityProxy.ts
View file @
4c0a7417
'use strict'
const
remixLib
=
require
(
'@remix-project/remix-lib'
)
const
traceHelper
=
require
(
'../trace/traceHelper'
)
const
stateDecoder
=
require
(
'./stateDecoder'
)
const
astHelper
=
require
(
'./astHelper'
)
const
util
=
remixLib
.
util
import
{
util
}
from
'@remix-project/remix-lib'
import
{
isContractCreation
}
from
'../trace/traceHelper'
import
{
extractStateVariables
}
from
'./stateDecoder'
import
{
extractContractDefinitions
,
extractStatesDefinitions
}
from
'./astHelper'
export
class
SolidityProxy
{
...
...
@@ -65,10 +64,10 @@ export class SolidityProxy {
*/
extractStatesDefinitions
()
{
if
(
!
this
.
cache
.
contractDeclarations
)
{
this
.
cache
.
contractDeclarations
=
astHelper
.
extractContractDefinitions
(
this
.
sources
)
this
.
cache
.
contractDeclarations
=
extractContractDefinitions
(
this
.
sources
)
}
if
(
!
this
.
cache
.
statesDefinitions
)
{
this
.
cache
.
statesDefinitions
=
astHelper
.
extractStatesDefinitions
(
this
.
sources
,
this
.
cache
.
contractDeclarations
)
this
.
cache
.
statesDefinitions
=
extractStatesDefinitions
(
this
.
sources
,
this
.
cache
.
contractDeclarations
)
}
return
this
.
cache
.
statesDefinitions
}
...
...
@@ -81,7 +80,7 @@ export class SolidityProxy {
*/
extractStateVariables
(
contractName
)
{
if
(
!
this
.
cache
.
stateVariablesByContractName
[
contractName
])
{
this
.
cache
.
stateVariablesByContractName
[
contractName
]
=
stateDecoder
.
extractStateVariables
(
contractName
,
this
.
sources
)
this
.
cache
.
stateVariablesByContractName
[
contractName
]
=
extractStateVariables
(
contractName
,
this
.
sources
)
}
return
this
.
cache
.
stateVariablesByContractName
[
contractName
]
}
...
...
@@ -127,7 +126,7 @@ export class SolidityProxy {
}
function
contractObjectFromCode
(
contracts
,
code
,
address
)
{
const
isCreation
=
traceHelper
.
isContractCreation
(
address
)
const
isCreation
=
isContractCreation
(
address
)
for
(
let
file
in
contracts
)
{
for
(
let
contract
in
contracts
[
file
])
{
const
bytecode
=
isCreation
?
contracts
[
file
][
contract
].
evm
.
bytecode
.
object
:
contracts
[
file
][
contract
].
evm
.
deployedBytecode
.
object
...
...
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