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
45d38adf
Commit
45d38adf
authored
Dec 14, 2020
by
aniket-engg
Committed by
Aniket
Dec 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
solidity decoder src updated
parent
9fc2291d
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
55 additions
and
40 deletions
+55
-40
astHelper.ts
libs/remix-debug/src/solidity-decoder/astHelper.ts
+5
-11
decodeInfo.ts
libs/remix-debug/src/solidity-decoder/decodeInfo.ts
+11
-11
index.ts
libs/remix-debug/src/solidity-decoder/index.ts
+1
-1
internalCallTree.ts
libs/remix-debug/src/solidity-decoder/internalCallTree.ts
+17
-3
localDecoder.ts
libs/remix-debug/src/solidity-decoder/localDecoder.ts
+1
-3
solidityProxy.ts
libs/remix-debug/src/solidity-decoder/solidityProxy.ts
+14
-3
stateDecoder.ts
libs/remix-debug/src/solidity-decoder/stateDecoder.ts
+6
-8
No files found.
libs/remix-debug/src/solidity-decoder/astHelper.ts
View file @
45d38adf
'use strict'
'use strict'
const
{
AstWalker
}
=
require
(
'@remix-project/remix-astwalker'
)
import
{
AstWalker
}
from
'@remix-project/remix-astwalker'
/**
/**
* return all contract definitions of the given @astList
* return all contract definitions of the given @astList
...
@@ -7,7 +7,7 @@ const { AstWalker } = require('@remix-project/remix-astwalker')
...
@@ -7,7 +7,7 @@ const { AstWalker } = require('@remix-project/remix-astwalker')
* @param {Object} sourcesList - sources list (containing root AST node)
* @param {Object} sourcesList - sources list (containing root AST node)
* @return {Object} - returns a mapping from AST node ids to AST nodes for the contracts
* @return {Object} - returns a mapping from AST node ids to AST nodes for the contracts
*/
*/
function
extractContractDefinitions
(
sourcesList
)
{
export
function
extractContractDefinitions
(
sourcesList
)
{
const
ret
=
{
const
ret
=
{
contractsById
:
{},
contractsById
:
{},
contractsByName
:
{},
contractsByName
:
{},
...
@@ -33,7 +33,7 @@ function extractContractDefinitions (sourcesList) {
...
@@ -33,7 +33,7 @@ function extractContractDefinitions (sourcesList) {
* @param {Map} contracts - all contracts defined in the current context
* @param {Map} contracts - all contracts defined in the current context
* @return {Array} - array of base contracts in derived to base order as AST nodes.
* @return {Array} - array of base contracts in derived to base order as AST nodes.
*/
*/
function
getLinearizedBaseContracts
(
id
,
contractsById
)
{
export
function
getLinearizedBaseContracts
(
id
,
contractsById
)
{
return
contractsById
[
id
].
linearizedBaseContracts
.
map
(
function
(
id
)
{
return
contractsById
[
id
]
})
return
contractsById
[
id
].
linearizedBaseContracts
.
map
(
function
(
id
)
{
return
contractsById
[
id
]
})
}
}
...
@@ -46,7 +46,7 @@ function getLinearizedBaseContracts (id, contractsById) {
...
@@ -46,7 +46,7 @@ function getLinearizedBaseContracts (id, contractsById) {
* @return {Object} - return an object containing: stateItems - list of all the children node of the @arg contractName
* @return {Object} - return an object containing: stateItems - list of all the children node of the @arg contractName
* stateVariables - list of all the variable declaration of the @arg contractName
* stateVariables - list of all the variable declaration of the @arg contractName
*/
*/
function
extractStateDefinitions
(
contractName
,
sourcesList
,
contracts
)
{
export
function
extractStateDefinitions
(
contractName
,
sourcesList
,
contracts
)
{
if
(
!
contracts
)
{
if
(
!
contracts
)
{
contracts
=
extractContractDefinitions
(
sourcesList
)
contracts
=
extractContractDefinitions
(
sourcesList
)
}
}
...
@@ -78,7 +78,7 @@ function extractStateDefinitions (contractName, sourcesList, contracts) {
...
@@ -78,7 +78,7 @@ function extractStateDefinitions (contractName, sourcesList, contracts) {
* @param {Object} [contracts] - map of contract definitions (contains contractsById, contractsByName)
* @param {Object} [contracts] - map of contract definitions (contains contractsById, contractsByName)
* @return {Object} - returns a mapping between contract name and contract state
* @return {Object} - returns a mapping between contract name and contract state
*/
*/
function
extractStatesDefinitions
(
sourcesList
,
contracts
)
{
export
function
extractStatesDefinitions
(
sourcesList
,
contracts
)
{
if
(
!
contracts
)
{
if
(
!
contracts
)
{
contracts
=
extractContractDefinitions
(
sourcesList
)
contracts
=
extractContractDefinitions
(
sourcesList
)
}
}
...
@@ -94,9 +94,3 @@ function extractStatesDefinitions (sourcesList, contracts) {
...
@@ -94,9 +94,3 @@ function extractStatesDefinitions (sourcesList, contracts) {
return
ret
return
ret
}
}
module
.
exports
=
{
extractStatesDefinitions
:
extractStatesDefinitions
,
extractStateDefinitions
:
extractStateDefinitions
,
extractContractDefinitions
:
extractContractDefinitions
,
getLinearizedBaseContracts
:
getLinearizedBaseContracts
}
libs/remix-debug/src/solidity-decoder/decodeInfo.ts
View file @
45d38adf
...
@@ -368,17 +368,17 @@ function computeOffsets (types, stateDefinitions, contractName, location) {
...
@@ -368,17 +368,17 @@ function computeOffsets (types, stateDefinitions, contractName, location) {
}
}
}
}
module
.
exports
=
{
export
{
parseType
,
parseType
,
computeOffsets
,
computeOffsets
,
Uint
:
u
int
,
uint
as
U
int
,
Address
:
a
ddress
,
address
as
A
ddress
,
Bool
:
b
ool
,
bool
as
B
ool
,
DynamicByteArray
:
d
ynamicByteArray
,
dynamicByteArray
as
D
ynamicByteArray
,
FixedByteArray
:
f
ixedByteArray
,
fixedByteArray
as
F
ixedByteArray
,
Int
:
i
nt
,
int
as
I
nt
,
String
:
stringType
,
stringType
as
String
,
Array
:
a
rray
,
array
as
A
rray
,
Enum
:
enumType
,
enumType
as
Enum
,
Struct
:
s
truct
struct
as
S
truct
}
}
libs/remix-debug/src/solidity-decoder/index.ts
View file @
45d38adf
...
@@ -3,4 +3,4 @@ const stateDecoder = require('./stateDecoder')
...
@@ -3,4 +3,4 @@ const stateDecoder = require('./stateDecoder')
const
localDecoder
=
require
(
'./localDecoder'
)
const
localDecoder
=
require
(
'./localDecoder'
)
const
InternalCallTree
=
require
(
'./internalCallTree'
)
const
InternalCallTree
=
require
(
'./internalCallTree'
)
module
.
exports
=
{
SolidityProxy
,
stateDecoder
,
localDecoder
,
InternalCallTree
}
export
{
SolidityProxy
,
stateDecoder
,
localDecoder
,
InternalCallTree
}
libs/remix-debug/src/solidity-decoder/internalCallTree.ts
View file @
45d38adf
...
@@ -14,7 +14,23 @@ const typesUtil = require('./types/util.js')
...
@@ -14,7 +14,23 @@ const typesUtil = require('./types/util.js')
* Triggers `callTreeReady` event when tree is ready
* Triggers `callTreeReady` event when tree is ready
* Triggers `callTreeBuildFailed` event when tree fails to build
* Triggers `callTreeBuildFailed` event when tree fails to build
*/
*/
class
InternalCallTree
{
export
class
InternalCallTree
{
includeLocalVariables
debugWithGeneratedSources
event
solidityProxy
traceManager
sourceLocationTracker
scopes
scopeStarts
functionCallStack
functionDefinitionsByScope
variableDeclarationByFile
functionDefinitionByFile
astWalker
reducedTrace
/**
/**
* constructor
* constructor
*
*
...
@@ -375,5 +391,3 @@ function addParams (parameterList, tree, scopeId, states, contractName, sourceLo
...
@@ -375,5 +391,3 @@ function addParams (parameterList, tree, scopeId, states, contractName, sourceLo
}
}
return
params
return
params
}
}
module
.
exports
=
InternalCallTree
libs/remix-debug/src/solidity-decoder/localDecoder.ts
View file @
45d38adf
'use strict'
'use strict'
async
function
solidityLocals
(
vmtraceIndex
,
internalTreeCall
,
stack
,
memory
,
storageResolver
,
currentSourceLocation
,
cursor
)
{
export
async
function
solidityLocals
(
vmtraceIndex
,
internalTreeCall
,
stack
,
memory
,
storageResolver
,
currentSourceLocation
,
cursor
)
{
const
scope
=
internalTreeCall
.
findScope
(
vmtraceIndex
)
const
scope
=
internalTreeCall
.
findScope
(
vmtraceIndex
)
if
(
!
scope
)
{
if
(
!
scope
)
{
const
error
=
{
'message'
:
'Can
\'
t display locals. reason: compilation result might not have been provided'
}
const
error
=
{
'message'
:
'Can
\'
t display locals. reason: compilation result might not have been provided'
}
...
@@ -34,5 +34,3 @@ function formatMemory (memory) {
...
@@ -34,5 +34,3 @@ function formatMemory (memory) {
}
}
return
memory
return
memory
}
}
module
.
exports
=
{
solidityLocals
}
libs/remix-debug/src/solidity-decoder/solidityProxy.ts
View file @
45d38adf
...
@@ -5,7 +5,14 @@ const stateDecoder = require('./stateDecoder')
...
@@ -5,7 +5,14 @@ const stateDecoder = require('./stateDecoder')
const
astHelper
=
require
(
'./astHelper'
)
const
astHelper
=
require
(
'./astHelper'
)
const
util
=
remixLib
.
util
const
util
=
remixLib
.
util
class
SolidityProxy
{
export
class
SolidityProxy
{
cache
getCurrentCalledAddressAt
getCode
sources
contracts
constructor
({
getCurrentCalledAddressAt
,
getCode
})
{
constructor
({
getCurrentCalledAddressAt
,
getCode
})
{
this
.
cache
=
new
Cache
()
this
.
cache
=
new
Cache
()
this
.
reset
({})
this
.
reset
({})
...
@@ -133,6 +140,12 @@ function contractObjectFromCode (contracts, code, address) {
...
@@ -133,6 +140,12 @@ function contractObjectFromCode (contracts, code, address) {
}
}
class
Cache
{
class
Cache
{
contractObjectByAddress
stateVariablesByContractName
contractDeclarations
statesDefinitions
constructor
()
{
constructor
()
{
this
.
reset
()
this
.
reset
()
}
}
...
@@ -143,5 +156,3 @@ class Cache {
...
@@ -143,5 +156,3 @@ class Cache {
this
.
statesDefinitions
=
null
this
.
statesDefinitions
=
null
}
}
}
}
module
.
exports
=
SolidityProxy
libs/remix-debug/src/solidity-decoder/stateDecoder.ts
View file @
45d38adf
const
astHelper
=
require
(
'./astHelper'
)
import
{
extractStatesDefinitions
}
from
'./astHelper'
const
{
computeOffsets
}
=
require
(
'./decodeInfo'
)
import
{
computeOffsets
}
from
'./decodeInfo'
/**
/**
* decode the contract state storage
* decode the contract state storage
...
@@ -8,7 +8,7 @@ const {computeOffsets} = require('./decodeInfo')
...
@@ -8,7 +8,7 @@ const {computeOffsets} = require('./decodeInfo')
* @param {Object} storageResolver - resolve storage queries
* @param {Object} storageResolver - resolve storage queries
* @return {Map} - decoded state variable
* @return {Map} - decoded state variable
*/
*/
async
function
decodeState
(
stateVars
,
storageResolver
)
{
export
async
function
decodeState
(
stateVars
,
storageResolver
)
{
const
ret
=
{}
const
ret
=
{}
for
(
var
k
in
stateVars
)
{
for
(
var
k
in
stateVars
)
{
var
stateVar
=
stateVars
[
k
]
var
stateVar
=
stateVars
[
k
]
...
@@ -34,8 +34,8 @@ async function decodeState (stateVars, storageResolver) {
...
@@ -34,8 +34,8 @@ async function decodeState (stateVars, storageResolver) {
* @param {Object} sourcesList - sources list
* @param {Object} sourcesList - sources list
* @return {Object} - return the location of all contract variables in the storage
* @return {Object} - return the location of all contract variables in the storage
*/
*/
function
extractStateVariables
(
contractName
,
sourcesList
)
{
export
function
extractStateVariables
(
contractName
,
sourcesList
)
{
const
states
=
astHelper
.
extractStatesDefinitions
(
sourcesList
)
const
states
=
extractStatesDefinitions
(
sourcesList
,
null
)
if
(
!
states
[
contractName
])
{
if
(
!
states
[
contractName
])
{
return
[]
return
[]
}
}
...
@@ -55,7 +55,7 @@ function extractStateVariables (contractName, sourcesList) {
...
@@ -55,7 +55,7 @@ function extractStateVariables (contractName, sourcesList) {
* @param {String} contractName - contract for which state var should be resolved
* @param {String} contractName - contract for which state var should be resolved
* @return {Map} - return the state of the contract
* @return {Map} - return the state of the contract
*/
*/
async
function
solidityState
(
storageResolver
,
astList
,
contractName
)
{
export
async
function
solidityState
(
storageResolver
,
astList
,
contractName
)
{
const
stateVars
=
extractStateVariables
(
contractName
,
astList
)
const
stateVars
=
extractStateVariables
(
contractName
,
astList
)
try
{
try
{
return
await
decodeState
(
stateVars
,
storageResolver
)
return
await
decodeState
(
stateVars
,
storageResolver
)
...
@@ -63,5 +63,3 @@ async function solidityState (storageResolver, astList, contractName) {
...
@@ -63,5 +63,3 @@ async function solidityState (storageResolver, astList, contractName) {
return
'<decoding failed - '
+
e
.
message
+
'>'
return
'<decoding failed - '
+
e
.
message
+
'>'
}
}
}
}
module
.
exports
=
{
solidityState
,
extractStateVariables
,
decodeState
}
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