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
fc5f3829
Commit
fc5f3829
authored
Aug 11, 2021
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
display global variables while debugging
parent
7f7276c6
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
49 additions
and
2 deletions
+49
-2
blocks.ts
libs/remix-simulator/src/methods/blocks.ts
+2
-0
transactions.ts
libs/remix-simulator/src/methods/transactions.ts
+3
-0
blocks.ts
libs/remix-simulator/test/blocks.ts
+1
-0
debugger-ui.tsx
libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx
+11
-1
global-variables.tsx
...x-ui/debugger-ui/src/lib/vm-debugger/global-variables.tsx
+28
-0
vm-debugger-head.tsx
...x-ui/debugger-ui/src/lib/vm-debugger/vm-debugger-head.tsx
+1
-0
vm-debugger.tsx
.../remix-ui/debugger-ui/src/lib/vm-debugger/vm-debugger.tsx
+3
-1
No files found.
libs/remix-simulator/src/methods/blocks.ts
View file @
fc5f3829
...
...
@@ -41,6 +41,7 @@ export class Blocks {
}
const
b
=
{
baseFeePerGas
:
'0x01'
,
number
:
this
.
toHex
(
block
.
header
.
number
),
hash
:
this
.
toHex
(
block
.
hash
()),
parentHash
:
this
.
toHex
(
block
.
header
.
parentHash
),
...
...
@@ -73,6 +74,7 @@ export class Blocks {
const
block
=
this
.
vmContext
.
blocks
[
payload
.
params
[
0
]]
const
b
=
{
baseFeePerGas
:
'0x01'
,
number
:
this
.
toHex
(
block
.
header
.
number
),
hash
:
this
.
toHex
(
block
.
hash
()),
parentHash
:
this
.
toHex
(
block
.
header
.
parentHash
),
...
...
libs/remix-simulator/src/methods/transactions.ts
View file @
fc5f3829
...
...
@@ -193,6 +193,7 @@ export class Transactions {
blockNumber
:
'0x'
+
txBlock
.
header
.
number
.
toString
(
'hex'
),
from
:
receipt
.
from
,
gas
:
Web3
.
utils
.
toHex
(
receipt
.
gas
),
chainId
:
'0xb'
,
// 'gasPrice': '2000000000000', // 0x123
gasPrice
:
'0x4a817c800'
,
// 20000000000
hash
:
receipt
.
transactionHash
,
...
...
@@ -239,6 +240,7 @@ export class Transactions {
blockNumber
:
'0x'
+
txBlock
.
header
.
number
.
toString
(
'hex'
),
from
:
receipt
.
from
,
gas
:
Web3
.
utils
.
toHex
(
receipt
.
gas
),
chainId
:
'0xb'
,
// 'gasPrice': '2000000000000', // 0x123
gasPrice
:
'0x4a817c800'
,
// 20000000000
hash
:
receipt
.
transactionHash
,
...
...
@@ -282,6 +284,7 @@ export class Transactions {
from
:
receipt
.
from
,
gas
:
Web3
.
utils
.
toHex
(
receipt
.
gas
),
// 'gasPrice': '2000000000000', // 0x123
chainId
:
'0xb'
,
gasPrice
:
'0x4a817c800'
,
// 20000000000
hash
:
receipt
.
transactionHash
,
input
:
receipt
.
input
,
...
...
libs/remix-simulator/test/blocks.ts
View file @
fc5f3829
...
...
@@ -18,6 +18,7 @@ describe('blocks', () => {
const
block
=
await
web3
.
eth
.
getBlock
(
0
)
const
expectedBlock
=
{
baseFeePerGas
:
'0x01'
,
difficulty
:
'69762765929000'
,
extraData
:
'0x0'
,
gasLimit
:
8000000
,
...
...
libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx
View file @
fc5f3829
...
...
@@ -20,6 +20,8 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
contractAddress
:
null
,
to
:
null
},
currentBlock
:
null
,
currentTransaction
:
null
,
blockNumber
:
null
,
txNumber
:
''
,
debugging
:
false
,
...
...
@@ -137,6 +139,8 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
contractAddress
:
null
,
to
:
null
},
currentBlock
:
null
,
currentTransaction
:
null
,
blockNumber
:
null
,
ready
:
{
vmDebugger
:
false
,
...
...
@@ -182,8 +186,12 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
console
.
error
(
e
)
}
let
currentReceipt
let
currentBlock
let
currentTransaction
try
{
currentReceipt
=
await
web3
.
eth
.
getTransactionReceipt
(
txNumber
)
currentBlock
=
await
web3
.
eth
.
getBlock
(
currentReceipt
.
blockHash
)
currentTransaction
=
await
web3
.
eth
.
getTransaction
(
txNumber
)
}
catch
(
e
)
{
setState
(
prevState
=>
{
return
{
...
...
@@ -220,6 +228,8 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
txNumber
,
debugging
:
true
,
currentReceipt
,
currentBlock
,
currentTransaction
,
debugger
:
debuggerInstance
,
toastMessage
:
`debugging
${
txNumber
}
`
,
validationError
:
''
...
...
@@ -293,7 +303,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
{
state
.
debugging
&&
<
StepManager
stepManager=
{
stepManager
}
/>
}
{
state
.
debugging
&&
<
VmDebuggerHead
vmDebugger=
{
vmDebugger
}
/>
}
</
div
>
{
state
.
debugging
&&
<
VmDebugger
vmDebugger=
{
vmDebugger
}
/>
}
{
state
.
debugging
&&
<
VmDebugger
vmDebugger=
{
vmDebugger
}
currentBlock=
{
state
.
currentBlock
}
currentReceipt=
{
state
.
currentReceipt
}
currentTransaction=
{
state
.
currentTransaction
}
/>
}
</
div
>
)
}
...
...
libs/remix-ui/debugger-ui/src/lib/vm-debugger/global-variables.tsx
0 → 100644
View file @
fc5f3829
import
React
from
'react'
// eslint-disable-line
import
DropdownPanel
from
'./dropdown-panel'
// eslint-disable-line
import
{
BN
}
from
'ethereumjs-util'
export
const
GlobalVariables
=
({
block
,
receipt
,
tx
})
=>
{
console
.
log
(
block
,
receipt
,
tx
)
// see https://docs.soliditylang.org/en/latest/units-and-global-variables.html#block-and-transaction-properties
const
globals
=
{
'block.basefee'
:
(
new
BN
(
block
.
baseFeePerGas
.
replace
(
'0x'
,
''
),
'hex'
)).
toString
(
10
)
+
` Wei (
${
block
.
baseFeePerGas
}
)`
,
'block.chainid'
:
tx
.
chainId
,
'block.coinbase'
:
block
.
miner
,
'block.difficulty'
:
block
.
difficulty
,
'block.gaslimit'
:
block
.
gasLimit
,
'block.number'
:
block
.
number
,
'block.timestamp'
:
block
.
timestamp
,
'msg.sender'
:
tx
.
from
,
'msg.sig'
:
tx
.
input
.
substring
(
0
,
10
),
'msg.value'
:
tx
.
value
+
' Wei'
,
'tx.origin'
:
tx
.
from
}
return
(
<
div
id=
'globalvariable'
data
-
id=
'globalvariable'
>
<
DropdownPanel
hexHighlight=
{
false
}
bodyStyle=
{
{
fontFamily
:
'monospace'
}
}
dropdownName=
'Global Variables'
calldata=
{
globals
||
{}
}
/>
</
div
>
)
}
export
default
GlobalVariables
libs/remix-ui/debugger-ui/src/lib/vm-debugger/vm-debugger-head.tsx
View file @
fc5f3829
...
...
@@ -15,6 +15,7 @@ export const VmDebuggerHead = ({ vmDebugger: { registerEvent, triggerEvent } })
'remaining gas'
:
'-'
,
'loaded address'
:
'-'
})
const
[
solidityState
,
setSolidityState
]
=
useState
({
calldata
:
null
,
message
:
null
...
...
libs/remix-ui/debugger-ui/src/lib/vm-debugger/vm-debugger.tsx
View file @
fc5f3829
...
...
@@ -6,8 +6,9 @@ import StackPanel from './stack-panel' // eslint-disable-line
import
StoragePanel
from
'./storage-panel'
// eslint-disable-line
import
ReturnValuesPanel
from
'./dropdown-panel'
// eslint-disable-line
import
FullStoragesChangesPanel
from
'./full-storages-changes'
// eslint-disable-line
import
GlobalVariables
from
'./global-variables'
// eslint-disable-line
export
const
VmDebugger
=
({
vmDebugger
:
{
registerEvent
}
})
=>
{
export
const
VmDebugger
=
({
vmDebugger
:
{
registerEvent
}
,
currentBlock
,
currentReceipt
,
currentTransaction
})
=>
{
const
[
calldataPanel
,
setCalldataPanel
]
=
useState
(
null
)
const
[
memoryPanel
,
setMemoryPanel
]
=
useState
(
null
)
const
[
callStackPanel
,
setCallStackPanel
]
=
useState
(
null
)
...
...
@@ -58,6 +59,7 @@ export const VmDebugger = ({ vmDebugger: { registerEvent } }) => {
<
StoragePanel
calldata=
{
storagePanel
.
calldata
}
header=
{
storagePanel
.
header
}
/>
<
CallstackPanel
calldata=
{
callStackPanel
}
/>
<
CalldataPanel
calldata=
{
calldataPanel
}
/>
<
GlobalVariables
block=
{
currentBlock
}
receipt=
{
currentReceipt
}
tx=
{
currentTransaction
}
/>
<
ReturnValuesPanel
dropdownName=
'Return Value'
calldata=
{
returnValuesPanel
||
{}
}
/>
<
FullStoragesChangesPanel
calldata=
{
fullStoragesChangesPanel
}
/>
</
div
>
...
...
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