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
0553a65a
Unverified
Commit
0553a65a
authored
May 20, 2021
by
yann300
Committed by
GitHub
May 20, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1192 from ethereum/fixDecodingCallData
Fix nested array calldata decoding
parents
d0f0b7fe
2e8787ae
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
152 additions
and
36 deletions
+152
-36
RefType.ts
libs/remix-debug/src/solidity-decoder/types/RefType.ts
+27
-9
calldata.ts
libs/remix-debug/test/decoder/contracts/calldata.ts
+14
-0
localDecoder.ts
libs/remix-debug/test/decoder/localDecoder.ts
+13
-10
calldata.ts
libs/remix-debug/test/decoder/localsTests/calldata.ts
+62
-0
int.ts
libs/remix-debug/test/decoder/localsTests/int.ts
+6
-3
misc.ts
libs/remix-debug/test/decoder/localsTests/misc.ts
+6
-3
misc2.ts
libs/remix-debug/test/decoder/localsTests/misc2.ts
+6
-3
structArray.ts
libs/remix-debug/test/decoder/localsTests/structArray.ts
+6
-3
mapping.ts
libs/remix-debug/test/decoder/stateTests/mapping.ts
+4
-3
vmCall.ts
libs/remix-debug/test/decoder/vmCall.ts
+8
-2
No files found.
libs/remix-debug/src/solidity-decoder/types/RefType.ts
View file @
0553a65a
...
@@ -52,27 +52,45 @@ export class RefType {
...
@@ -52,27 +52,45 @@ export class RefType {
offset
=
parseInt
(
offset
,
16
)
offset
=
parseInt
(
offset
,
16
)
return
this
.
decodeFromMemoryInternal
(
offset
,
memory
,
cursor
)
return
this
.
decodeFromMemoryInternal
(
offset
,
memory
,
cursor
)
}
else
if
(
this
.
isInCallData
())
{
}
else
if
(
this
.
isInCallData
())
{
return
this
.
_decodeFromCallData
(
variableDetails
,
calldata
)
}
else
{
return
{
error
:
'<decoding failed - no decoder for '
+
this
.
location
+
'>'
,
type
:
this
.
typeName
}
}
}
_decodeFromCallData
(
variableDetails
,
calldata
)
{
calldata
=
calldata
.
length
>
0
?
calldata
[
0
]
:
'0x'
calldata
=
calldata
.
length
>
0
?
calldata
[
0
]
:
'0x'
const
ethersAbi
=
new
ethers
.
utils
.
Interface
(
variableDetails
.
abi
)
const
ethersAbi
=
new
ethers
.
utils
.
Interface
(
variableDetails
.
abi
)
const
fnSign
=
calldata
.
substr
(
0
,
10
)
const
fnSign
=
calldata
.
substr
(
0
,
10
)
const
decodedData
=
ethersAbi
.
decodeFunctionData
(
ethersAbi
.
getFunction
(
fnSign
),
calldata
)
const
decodedData
=
ethersAbi
.
decodeFunctionData
(
ethersAbi
.
getFunction
(
fnSign
),
calldata
)
le
t
decodedValue
=
decodedData
[
variableDetails
.
name
]
cons
t
decodedValue
=
decodedData
[
variableDetails
.
name
]
const
isArray
=
Array
.
isArray
(
decodedValue
)
const
isArray
=
Array
.
isArray
(
decodedValue
)
if
(
isArray
)
{
if
(
isArray
)
{
decodedValue
=
decodedValue
.
map
((
el
)
=>
{
return
this
.
_decodeCallDataArray
(
decodedValue
,
this
)
return
{
value
:
el
.
toString
(),
type
:
this
.
underlyingType
.
typeName
}
})
}
}
return
{
return
{
length
:
Array
.
isArray
(
decodedValue
)
?
'0x'
+
decodedValue
.
length
.
toString
(
16
)
:
undefined
,
length
:
isArray
?
'0x'
+
decodedValue
.
length
.
toString
(
16
)
:
undefined
,
value
:
decodedValue
,
value
:
decodedValue
,
type
:
this
.
typeName
type
:
this
.
typeName
}
}
}
_decodeCallDataArray
(
value
,
type
)
{
const
isArray
=
Array
.
isArray
(
value
)
if
(
isArray
)
{
value
=
value
.
map
((
el
)
=>
{
return
this
.
_decodeCallDataArray
(
el
,
this
.
underlyingType
)
})
return
{
length
:
value
.
length
.
toString
(
16
),
value
:
value
,
type
:
type
.
typeName
}
}
else
{
}
else
{
return
{
error
:
'<decoding failed - no decoder for '
+
this
.
location
+
'>'
,
type
:
this
.
typeName
}
return
{
value
:
value
.
toString
(),
type
:
(
type
.
underlyingType
&&
type
.
underlyingType
.
typeName
)
||
type
.
typeName
}
}
}
}
}
...
...
libs/remix-debug/test/decoder/contracts/calldata.ts
0 → 100644
View file @
0553a65a
'use strict'
module
.
exports
=
{
contract
:
`
pragma experimental ABIEncoderV2;
contract calldataLocal {
constructor () public {
}
function level11(uint8[1] calldata foo, string[2][1] calldata boo) public {
uint p = 45;
}
}
`
}
libs/remix-debug/test/decoder/localDecoder.ts
View file @
0553a65a
...
@@ -4,37 +4,40 @@ var compiler = require('solc')
...
@@ -4,37 +4,40 @@ var compiler = require('solc')
var
intLocal
=
require
(
'./contracts/intLocal'
)
var
intLocal
=
require
(
'./contracts/intLocal'
)
var
miscLocal
=
require
(
'./contracts/miscLocal'
)
var
miscLocal
=
require
(
'./contracts/miscLocal'
)
var
structArrayLocal
=
require
(
'./contracts/structArrayLocal'
)
var
structArrayLocal
=
require
(
'./contracts/structArrayLocal'
)
var
calldataLocal
=
require
(
'./contracts/calldata'
)
var
vmCall
=
require
(
'./vmCall'
)
var
vmCall
=
require
(
'./vmCall'
)
var
intLocalTest
=
require
(
'./localsTests/int'
)
var
intLocalTest
=
require
(
'./localsTests/int'
)
var
miscLocalTest
=
require
(
'./localsTests/misc'
)
var
miscLocalTest
=
require
(
'./localsTests/misc'
)
var
misc2LocalTest
=
require
(
'./localsTests/misc2'
)
var
misc2LocalTest
=
require
(
'./localsTests/misc2'
)
var
structArrayLocalTest
=
require
(
'./localsTests/structArray'
)
var
structArrayLocalTest
=
require
(
'./localsTests/structArray'
)
var
calldataLocalTest
=
require
(
'./localsTests/calldata'
)
var
compilerInput
=
require
(
'../helpers/compilerHelper'
).
compilerInput
var
compilerInput
=
require
(
'../helpers/compilerHelper'
).
compilerInput
tape
(
'solidity'
,
function
(
t
)
{
tape
(
'solidity'
,
function
(
t
)
{
t
.
test
(
'local decoder'
,
async
function
(
st
)
{
t
.
test
(
'local decoder'
,
async
function
(
st
)
{
var
privateKey
=
Buffer
.
from
(
'dae9801649ba2d95a21e688b56f77905e5667c44ce868ec83f82e838712a2c7a'
,
'hex'
)
var
privateKey
=
Buffer
.
from
(
'dae9801649ba2d95a21e688b56f77905e5667c44ce868ec83f82e838712a2c7a'
,
'hex'
)
var
vm
=
await
vmCall
.
initVM
(
st
,
privateKey
)
var
vm
=
await
vmCall
.
initVM
(
st
,
privateKey
)
test
(
st
,
vm
,
privateKey
)
await
test
(
st
,
vm
,
privateKey
)
})
})
})
})
function
test
(
st
,
vm
,
privateKey
)
{
async
function
test
(
st
,
vm
,
privateKey
)
{
var
output
=
compiler
.
compile
(
compilerInput
(
intLocal
.
contract
))
var
output
=
compiler
.
compile
(
compilerInput
(
intLocal
.
contract
))
output
=
JSON
.
parse
(
output
)
output
=
JSON
.
parse
(
output
)
intLocalTest
(
st
,
vm
,
privateKey
,
output
.
contracts
[
'test.sol'
][
'intLocal'
].
evm
.
bytecode
.
object
,
output
,
function
()
{
await
intLocalTest
(
st
,
vm
,
privateKey
,
output
.
contracts
[
'test.sol'
][
'intLocal'
].
evm
.
bytecode
.
object
,
output
)
output
=
compiler
.
compile
(
compilerInput
(
miscLocal
.
contract
))
output
=
compiler
.
compile
(
compilerInput
(
miscLocal
.
contract
))
output
=
JSON
.
parse
(
output
)
output
=
JSON
.
parse
(
output
)
miscLocalTest
(
st
,
vm
,
privateKey
,
output
.
contracts
[
'test.sol'
][
'miscLocal'
].
evm
.
bytecode
.
object
,
output
,
function
()
{
await
miscLocalTest
(
st
,
vm
,
privateKey
,
output
.
contracts
[
'test.sol'
][
'miscLocal'
].
evm
.
bytecode
.
object
,
output
)
output
=
compiler
.
compile
(
compilerInput
(
miscLocal
.
contract
))
output
=
compiler
.
compile
(
compilerInput
(
miscLocal
.
contract
))
output
=
JSON
.
parse
(
output
)
output
=
JSON
.
parse
(
output
)
misc2LocalTest
(
st
,
vm
,
privateKey
,
output
.
contracts
[
'test.sol'
][
'miscLocal2'
].
evm
.
bytecode
.
object
,
output
,
function
()
{
await
misc2LocalTest
(
st
,
vm
,
privateKey
,
output
.
contracts
[
'test.sol'
][
'miscLocal2'
].
evm
.
bytecode
.
object
,
output
)
output
=
compiler
.
compile
(
compilerInput
(
structArrayLocal
.
contract
))
output
=
compiler
.
compile
(
compilerInput
(
structArrayLocal
.
contract
))
output
=
JSON
.
parse
(
output
)
output
=
JSON
.
parse
(
output
)
structArrayLocalTest
(
st
,
vm
,
privateKey
,
output
.
contracts
[
'test.sol'
][
'structArrayLocal'
].
evm
.
bytecode
.
object
,
output
,
function
()
{
await
structArrayLocalTest
(
st
,
vm
,
privateKey
,
output
.
contracts
[
'test.sol'
][
'structArrayLocal'
].
evm
.
bytecode
.
object
,
output
)
output
=
compiler
.
compile
(
compilerInput
(
calldataLocal
.
contract
))
output
=
JSON
.
parse
(
output
)
await
calldataLocalTest
(
st
,
vm
,
privateKey
,
output
.
contracts
[
'test.sol'
][
'calldataLocal'
].
evm
.
bytecode
.
object
,
output
)
st
.
end
()
st
.
end
()
})
})
})
})
}
}
libs/remix-debug/test/decoder/localsTests/calldata.ts
0 → 100644
View file @
0553a65a
'use strict'
import
deepequal
from
'deep-equal'
import
{
sendTx
}
from
'../vmCall'
import
{
TraceManager
}
from
'../../../src/trace/traceManager'
import
{
CodeManager
}
from
'../../../src/code/codeManager'
import
{
SolidityProxy
}
from
'../../../src/solidity-decoder/solidityProxy'
import
{
InternalCallTree
}
from
'../../../src/solidity-decoder/internalCallTree'
import
{
EventManager
}
from
'../../../src/eventManager'
import
*
as
helper
from
'./helper'
module
.
exports
=
async
function
(
st
,
vm
,
privateKey
,
contractBytecode
,
compilationResult
)
{
let
txHash
try
{
let
data
=
await
sendTx
(
vm
,
{
nonce
:
0
,
privateKey
:
privateKey
},
null
,
0
,
contractBytecode
)
const
to
=
(
data
as
any
).
result
.
createdAddress
.
toString
()
// call to level11
data
=
await
sendTx
(
vm
,
{
nonce
:
1
,
privateKey
:
privateKey
},
to
,
0
,
'a372a595000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001520000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000015400000000000000000000000000000000000000000000000000000000000000'
)
txHash
=
(
data
as
any
).
hash
}
catch
(
e
)
{
return
st
.
fail
(
e
)
}
return
new
Promise
((
resolve
)
=>
{
vm
.
web3
.
eth
.
getTransaction
(
txHash
,
function
(
error
,
tx
)
{
if
(
error
)
{
return
st
.
fail
(
error
)
}
var
traceManager
=
new
TraceManager
({
web3
:
vm
.
web3
})
var
codeManager
=
new
CodeManager
(
traceManager
)
codeManager
.
clear
()
var
solidityProxy
=
new
SolidityProxy
({
getCurrentCalledAddressAt
:
traceManager
.
getCurrentCalledAddressAt
.
bind
(
traceManager
),
getCode
:
codeManager
.
getCode
.
bind
(
codeManager
)
})
solidityProxy
.
reset
(
compilationResult
)
var
debuggerEvent
=
new
EventManager
()
var
callTree
=
new
InternalCallTree
(
debuggerEvent
,
traceManager
,
solidityProxy
,
codeManager
,
{
includeLocalVariables
:
true
})
callTree
.
event
.
register
(
'callTreeBuildFailed'
,
(
error
)
=>
{
st
.
fail
(
error
)
})
callTree
.
event
.
register
(
'callTreeNotReady'
,
(
reason
)
=>
{
st
.
fail
(
reason
)
})
callTree
.
event
.
register
(
'callTreeReady'
,
(
scopes
,
scopeStarts
)
=>
{
helper
.
decodeLocals
(
st
,
140
,
traceManager
,
callTree
,
function
(
locals
)
{
try
{
const
expected
=
{
"p"
:{
"value"
:
"45"
,
"type"
:
"uint256"
},
"foo"
:{
"length"
:
"1"
,
"value"
:[{
"value"
:
"3"
,
"type"
:
"uint8"
}],
"type"
:
"uint8[1]"
},
"boo"
:{
"length"
:
"1"
,
"value"
:[{
"length"
:
"2"
,
"value"
:[{
"value"
:
"R"
,
"type"
:
"string"
},{
"value"
:
"T"
,
"type"
:
"string"
}],
"type"
:
"string[2]"
}],
"type"
:
"string[2][1]"
}}
st
.
deepEqual
(
locals
,
expected
)
}
catch
(
e
)
{
st
.
fail
(
e
.
message
)
}
resolve
({})
})
})
traceManager
.
resolveTrace
(
tx
).
then
(()
=>
{
debuggerEvent
.
trigger
(
'newTraceLoaded'
,
[
traceManager
.
trace
])
}).
catch
((
error
)
=>
{
st
.
fail
(
error
)
})
})
})
}
\ No newline at end of file
libs/remix-debug/test/decoder/localsTests/int.ts
View file @
0553a65a
...
@@ -9,11 +9,13 @@ import { InternalCallTree } from '../../../src/solidity-decoder/internalCallTree
...
@@ -9,11 +9,13 @@ import { InternalCallTree } from '../../../src/solidity-decoder/internalCallTree
import
{
EventManager
}
from
'../../../src/eventManager'
import
{
EventManager
}
from
'../../../src/eventManager'
import
*
as
helper
from
'./helper'
import
*
as
helper
from
'./helper'
module
.
exports
=
function
(
st
,
vm
,
privateKey
,
contractBytecode
,
compilationResult
,
cb
)
{
module
.
exports
=
function
(
st
,
vm
,
privateKey
,
contractBytecode
,
compilationResult
)
{
sendTx
(
vm
,
{
nonce
:
0
,
privateKey
:
privateKey
},
null
,
0
,
contractBytecode
,
function
(
error
,
txHash
)
{
return
new
Promise
((
resolve
)
=>
{
sendTx
(
vm
,
{
nonce
:
0
,
privateKey
:
privateKey
},
null
,
0
,
contractBytecode
,
function
(
error
,
data
)
{
if
(
error
)
{
if
(
error
)
{
return
st
.
fail
(
error
)
return
st
.
fail
(
error
)
}
}
const
txHash
=
data
.
hash
vm
.
web3
.
eth
.
getTransaction
(
txHash
,
function
(
error
,
tx
)
{
vm
.
web3
.
eth
.
getTransaction
(
txHash
,
function
(
error
,
tx
)
{
if
(
error
)
{
if
(
error
)
{
return
st
.
fail
(
error
)
return
st
.
fail
(
error
)
...
@@ -113,7 +115,7 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu
...
@@ -113,7 +115,7 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu
}
catch
(
e
)
{
}
catch
(
e
)
{
st
.
fail
(
e
.
message
)
st
.
fail
(
e
.
message
)
}
}
cb
(
)
resolve
({}
)
})
})
})
})
traceManager
.
resolveTrace
(
tx
).
then
(()
=>
{
traceManager
.
resolveTrace
(
tx
).
then
(()
=>
{
...
@@ -123,5 +125,6 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu
...
@@ -123,5 +125,6 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu
})
})
})
})
})
})
})
}
}
libs/remix-debug/test/decoder/localsTests/misc.ts
View file @
0553a65a
...
@@ -8,11 +8,13 @@ import * as helper from './helper'
...
@@ -8,11 +8,13 @@ import * as helper from './helper'
import
{
TraceManager
}
from
'../../../src/trace/traceManager'
import
{
TraceManager
}
from
'../../../src/trace/traceManager'
import
{
CodeManager
}
from
'../../../src/code/codeManager'
import
{
CodeManager
}
from
'../../../src/code/codeManager'
module
.
exports
=
function
(
st
,
vm
,
privateKey
,
contractBytecode
,
compilationResult
,
cb
)
{
module
.
exports
=
function
(
st
,
vm
,
privateKey
,
contractBytecode
,
compilationResult
)
{
sendTx
(
vm
,
{
nonce
:
0
,
privateKey
:
privateKey
},
null
,
0
,
contractBytecode
,
function
(
error
,
txHash
)
{
return
new
Promise
((
resolve
)
=>
{
sendTx
(
vm
,
{
nonce
:
0
,
privateKey
:
privateKey
},
null
,
0
,
contractBytecode
,
function
(
error
,
data
)
{
if
(
error
)
{
if
(
error
)
{
return
st
.
fail
(
error
)
return
st
.
fail
(
error
)
}
}
const
txHash
=
data
.
hash
vm
.
web3
.
eth
.
getTransaction
(
txHash
,
function
(
error
,
tx
)
{
vm
.
web3
.
eth
.
getTransaction
(
txHash
,
function
(
error
,
tx
)
{
if
(
error
)
{
if
(
error
)
{
return
st
.
fail
(
error
)
return
st
.
fail
(
error
)
...
@@ -60,7 +62,7 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu
...
@@ -60,7 +62,7 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu
}
catch
(
e
)
{
}
catch
(
e
)
{
st
.
fail
(
e
.
message
)
st
.
fail
(
e
.
message
)
}
}
cb
(
)
resolve
({}
)
})
})
})
})
traceManager
.
resolveTrace
(
tx
).
then
(()
=>
{
traceManager
.
resolveTrace
(
tx
).
then
(()
=>
{
...
@@ -70,4 +72,5 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu
...
@@ -70,4 +72,5 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu
})
})
})
})
})
})
})
}
}
libs/remix-debug/test/decoder/localsTests/misc2.ts
View file @
0553a65a
...
@@ -8,11 +8,13 @@ import * as helper from './helper'
...
@@ -8,11 +8,13 @@ import * as helper from './helper'
import
{
TraceManager
}
from
'../../../src/trace/traceManager'
import
{
TraceManager
}
from
'../../../src/trace/traceManager'
import
{
CodeManager
}
from
'../../../src/code/codeManager'
import
{
CodeManager
}
from
'../../../src/code/codeManager'
module
.
exports
=
function
(
st
,
vm
,
privateKey
,
contractBytecode
,
compilationResult
,
cb
)
{
module
.
exports
=
function
(
st
,
vm
,
privateKey
,
contractBytecode
,
compilationResult
)
{
sendTx
(
vm
,
{
nonce
:
0
,
privateKey
:
privateKey
},
null
,
0
,
contractBytecode
,
function
(
error
,
txHash
)
{
return
new
Promise
((
resolve
)
=>
{
sendTx
(
vm
,
{
nonce
:
0
,
privateKey
:
privateKey
},
null
,
0
,
contractBytecode
,
function
(
error
,
data
)
{
if
(
error
)
{
if
(
error
)
{
return
st
.
fail
(
error
)
return
st
.
fail
(
error
)
}
}
const
txHash
=
data
.
hash
vm
.
web3
.
eth
.
getTransaction
(
txHash
,
function
(
error
,
tx
)
{
vm
.
web3
.
eth
.
getTransaction
(
txHash
,
function
(
error
,
tx
)
{
if
(
error
)
{
if
(
error
)
{
return
st
.
fail
(
error
)
return
st
.
fail
(
error
)
...
@@ -46,7 +48,7 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu
...
@@ -46,7 +48,7 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu
}
catch
(
e
)
{
}
catch
(
e
)
{
st
.
fail
(
e
.
message
)
st
.
fail
(
e
.
message
)
}
}
cb
(
)
resolve
({}
)
})
})
})
})
traceManager
.
resolveTrace
(
tx
).
then
(()
=>
{
traceManager
.
resolveTrace
(
tx
).
then
(()
=>
{
...
@@ -56,4 +58,5 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu
...
@@ -56,4 +58,5 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu
})
})
})
})
})
})
})
}
}
libs/remix-debug/test/decoder/localsTests/structArray.ts
View file @
0553a65a
...
@@ -8,11 +8,13 @@ import * as helper from './helper'
...
@@ -8,11 +8,13 @@ import * as helper from './helper'
import
{
TraceManager
}
from
'../../../src/trace/traceManager'
import
{
TraceManager
}
from
'../../../src/trace/traceManager'
import
{
CodeManager
}
from
'../../../src/code/codeManager'
import
{
CodeManager
}
from
'../../../src/code/codeManager'
module
.
exports
=
function
(
st
,
vm
,
privateKey
,
contractBytecode
,
compilationResult
,
cb
)
{
module
.
exports
=
function
(
st
,
vm
,
privateKey
,
contractBytecode
,
compilationResult
)
{
sendTx
(
vm
,
{
nonce
:
0
,
privateKey
:
privateKey
},
null
,
0
,
contractBytecode
,
function
(
error
,
txHash
)
{
return
new
Promise
((
resolve
)
=>
{
sendTx
(
vm
,
{
nonce
:
0
,
privateKey
:
privateKey
},
null
,
0
,
contractBytecode
,
function
(
error
,
data
)
{
if
(
error
)
{
if
(
error
)
{
return
st
.
fail
(
error
)
return
st
.
fail
(
error
)
}
}
const
txHash
=
data
.
hash
vm
.
web3
.
eth
.
getTransaction
(
txHash
,
function
(
error
,
tx
)
{
vm
.
web3
.
eth
.
getTransaction
(
txHash
,
function
(
error
,
tx
)
{
if
(
error
)
{
if
(
error
)
{
return
st
.
fail
(
error
)
return
st
.
fail
(
error
)
...
@@ -104,7 +106,7 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu
...
@@ -104,7 +106,7 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu
}
catch
(
e
)
{
}
catch
(
e
)
{
st
.
fail
(
e
.
message
)
st
.
fail
(
e
.
message
)
}
}
cb
(
)
resolve
({}
)
})
})
})
})
traceManager
.
resolveTrace
(
tx
).
then
(()
=>
{
traceManager
.
resolveTrace
(
tx
).
then
(()
=>
{
...
@@ -114,4 +116,5 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu
...
@@ -114,4 +116,5 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu
})
})
})
})
})
})
})
}
}
libs/remix-debug/test/decoder/stateTests/mapping.ts
View file @
0553a65a
...
@@ -12,11 +12,12 @@ module.exports = async function testMappingStorage (st, cb) {
...
@@ -12,11 +12,12 @@ module.exports = async function testMappingStorage (st, cb) {
var
vm
=
await
initVM
(
st
,
privateKey
)
var
vm
=
await
initVM
(
st
,
privateKey
)
var
output
=
compile
(
compilerInput
(
mappingStorage
.
contract
))
var
output
=
compile
(
compilerInput
(
mappingStorage
.
contract
))
output
=
JSON
.
parse
(
output
)
output
=
JSON
.
parse
(
output
)
sendTx
(
vm
,
{
nonce
:
0
,
privateKey
:
privateKey
},
null
,
0
,
output
.
contracts
[
'test.sol'
][
'SimpleMappingState'
].
evm
.
bytecode
.
object
,
function
(
error
,
txHash
)
{
sendTx
(
vm
,
{
nonce
:
0
,
privateKey
:
privateKey
},
null
,
0
,
output
.
contracts
[
'test.sol'
][
'SimpleMappingState'
].
evm
.
bytecode
.
object
,
function
(
error
,
data
)
{
if
(
error
)
{
if
(
error
)
{
console
.
log
(
error
)
console
.
log
(
error
)
st
.
end
(
error
)
st
.
end
(
error
)
}
else
{
}
else
{
const
txHash
=
data
.
hash
vm
.
web3
.
eth
.
getTransaction
(
txHash
,
(
error
,
tx
)
=>
{
vm
.
web3
.
eth
.
getTransaction
(
txHash
,
(
error
,
tx
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
log
(
error
)
console
.
log
(
error
)
...
@@ -31,12 +32,12 @@ module.exports = async function testMappingStorage (st, cb) {
...
@@ -31,12 +32,12 @@ module.exports = async function testMappingStorage (st, cb) {
function
testMapping
(
st
,
vm
,
privateKey
,
contractAddress
,
output
,
cb
)
{
function
testMapping
(
st
,
vm
,
privateKey
,
contractAddress
,
output
,
cb
)
{
sendTx
(
vm
,
{
nonce
:
1
,
privateKey
:
privateKey
},
contractAddress
,
0
,
'2fd0a83a00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001074686973206973206120737472696e6700000000000000000000000000000000'
,
sendTx
(
vm
,
{
nonce
:
1
,
privateKey
:
privateKey
},
contractAddress
,
0
,
'2fd0a83a00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001074686973206973206120737472696e6700000000000000000000000000000000'
,
function
(
error
,
txHash
)
{
function
(
error
,
data
)
{
if
(
error
)
{
if
(
error
)
{
console
.
log
(
error
)
console
.
log
(
error
)
st
.
end
(
error
)
st
.
end
(
error
)
}
else
{
}
else
{
cons
ole
.
log
(
txHash
)
cons
t
txHash
=
data
.
hash
vm
.
web3
.
eth
.
getTransaction
(
txHash
,
(
error
,
tx
)
=>
{
vm
.
web3
.
eth
.
getTransaction
(
txHash
,
(
error
,
tx
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
log
(
error
)
console
.
log
(
error
)
...
...
libs/remix-debug/test/decoder/vmCall.ts
View file @
0553a65a
...
@@ -6,7 +6,9 @@ import { vm as remixlibVM } from '@remix-project/remix-lib'
...
@@ -6,7 +6,9 @@ import { vm as remixlibVM } from '@remix-project/remix-lib'
import
VM
from
'@ethereumjs/vm'
import
VM
from
'@ethereumjs/vm'
import
Common
from
'@ethereumjs/common'
import
Common
from
'@ethereumjs/common'
export
function
sendTx
(
vm
,
from
,
to
,
value
,
data
,
cb
)
{
export
function
sendTx
(
vm
,
from
,
to
,
value
,
data
,
cb
?)
{
cb
=
cb
||
(()
=>
{})
return
new
Promise
((
resolve
,
reject
)
=>
{
var
tx
=
new
Tx
({
var
tx
=
new
Tx
({
nonce
:
new
BN
(
from
.
nonce
++
),
nonce
:
new
BN
(
from
.
nonce
++
),
gasPrice
:
new
BN
(
1
),
gasPrice
:
new
BN
(
1
),
...
@@ -27,15 +29,19 @@ export function sendTx (vm, from, to, value, data, cb) {
...
@@ -27,15 +29,19 @@ export function sendTx (vm, from, to, value, data, cb) {
try
{
try
{
vm
.
runTx
({
block
:
block
,
tx
:
tx
,
skipBalance
:
true
,
skipNonce
:
true
}).
then
(
function
(
result
)
{
vm
.
runTx
({
block
:
block
,
tx
:
tx
,
skipBalance
:
true
,
skipNonce
:
true
}).
then
(
function
(
result
)
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
cb
(
null
,
bufferToHex
(
tx
.
hash
()))
const
hash
=
bufferToHex
(
tx
.
hash
())
cb
(
null
,
{
hash
,
result
})
resolve
({
hash
,
result
})
},
500
)
},
500
)
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
error
(
error
)
console
.
error
(
error
)
cb
(
error
)
cb
(
error
)
reject
(
error
)
})
})
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
error
(
e
)
console
.
error
(
e
)
}
}
})
}
}
async
function
createVm
(
hardfork
)
{
async
function
createVm
(
hardfork
)
{
...
...
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