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
3763ae7a
Commit
3763ae7a
authored
May 30, 2019
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement/fix eth_getTransactionByBlockNumber and eth_getBlockByHash
parent
e1fa7df4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
38 deletions
+55
-38
execution-context.js
remix-lib/src/execution/execution-context.js
+4
-0
web3VmProvider.js
remix-lib/src/web3Provider/web3VmProvider.js
+1
-0
blocks.js
remix-simulator/src/methods/blocks.js
+50
-38
No files found.
remix-lib/src/execution/execution-context.js
View file @
3763ae7a
...
...
@@ -281,7 +281,11 @@ function ExecutionContext () {
}
this
.
addBlock
=
function
(
block
)
{
let
blockNumber
=
"0x"
+
block
.
header
.
number
.
toString
(
'hex'
)
blockNumber
=
web3
.
toHex
(
web3
.
toBigNumber
(
blockNumber
))
self
.
blocks
[
"0x"
+
block
.
hash
().
toString
(
'hex'
)]
=
block
self
.
blocks
[
blockNumber
]
=
block
}
this
.
trackTx
=
function
(
tx
,
block
)
{
...
...
remix-lib/src/web3Provider/web3VmProvider.js
View file @
3763ae7a
...
...
@@ -40,6 +40,7 @@ function web3VmProvider () {
this
.
toWei
=
function
()
{
return
self
.
web3
.
toWei
.
apply
(
self
.
web3
,
arguments
)
}
this
.
toBigNumber
=
function
()
{
return
self
.
web3
.
toBigNumber
.
apply
(
self
.
web3
,
arguments
)
}
this
.
isAddress
=
function
()
{
return
self
.
web3
.
isAddress
.
apply
(
self
.
web3
,
arguments
)
}
this
.
utils
=
Web3
.
utils
||
[]
}
web3VmProvider
.
prototype
.
setVM
=
function
(
vm
)
{
...
...
remix-simulator/src/methods/blocks.js
View file @
3763ae7a
...
...
@@ -19,31 +19,40 @@ Blocks.prototype.methods = function () {
}
Blocks
.
prototype
.
eth_getBlockByNumber
=
function
(
payload
,
cb
)
{
var
block
=
executionContext
.
blocks
[
payload
.
params
[
0
]]
let
b
=
{
'difficulty'
:
'0x0'
,
'extraData'
:
'0x'
,
'gasLimit'
:
'0x7a1200'
,
'gasUsed'
:
'0x0'
,
'hash'
:
'0xdb731f3622ef37b4da8db36903de029220dba74c41185f8429f916058b86559f'
,
'logsBloom'
:
'0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
,
'number'
:
toHex
(
block
.
header
.
number
),
"hash"
:
toHex
(
block
.
hash
()),
'parentHash'
:
toHex
(
block
.
header
.
parentHash
),
'nonce'
:
toHex
(
block
.
header
.
nonce
),
"sha3Uncles"
:
"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
,
"logsBloom"
:
"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331"
,
"transactionsRoot"
:
"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
,
"stateRoot"
:
toHex
(
block
.
header
.
stateRoot
),
'miner'
:
this
.
coinbase
,
'mixHash'
:
'0x0000000000000000000000000000000000000000000000000000000000000000'
,
'nonce'
:
'0x0000000000000042'
,
'number'
:
Web3
.
utils
.
toHex
(
this
.
blockNumber
),
'parentHash'
:
'0x0000000000000000000000000000000000000000000000000000000000000000'
,
'receiptsRoot'
:
'0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'
,
'sha3Uncles'
:
'0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347'
,
'size'
:
'0x1f8'
,
'stateRoot'
:
'0xb7917653f92e62394d2207d0f39a1320ff1cb93d1cee80d3c492627e00b219ff'
,
'timestamp'
:
'0x0'
,
'totalDifficulty'
:
'0x0'
,
'transactions'
:
[],
'transactionsRoot'
:
'0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'
,
'uncles'
:
[]
'difficulty'
:
toHex
(
block
.
header
.
difficulty
),
"totalDifficulty"
:
toHex
(
block
.
header
.
totalDifficulty
),
'extraData'
:
toHex
(
block
.
header
.
extraData
),
"size"
:
"0x027f07"
,
// 163591
'gasLimit'
:
toHex
(
block
.
header
.
gasLimit
),
'gasUsed'
:
toHex
(
block
.
header
.
gasUsed
),
"timestamp"
:
toHex
(
block
.
header
.
timestamp
),
// TODO: add transactions
// block.transactions
"transactions"
:
[],
"uncles"
:
[]
}
cb
(
null
,
b
)
}
function
toHex
(
value
)
{
if
(
!
value
)
return
"0x0"
let
v
=
value
.
toString
(
'hex'
)
return
((
v
===
"0x"
||
v
===
""
)
?
"0x0"
:
(
"0x"
+
v
))
}
Blocks
.
prototype
.
eth_getBlockByHash
=
function
(
payload
,
cb
)
{
console
.
dir
(
"eth_getBlockByHash"
)
console
.
dir
(
payload
)
...
...
@@ -51,28 +60,31 @@ Blocks.prototype.eth_getBlockByHash = function (payload, cb) {
console
.
dir
(
"== toJSON"
)
console
.
dir
(
executionContext
.
blocks
[
payload
.
params
[
0
]].
toJSON
())
var
block
=
executionContext
.
blocks
[
payload
.
params
[
0
]]
let
b
=
{
'difficulty'
:
'0x0'
,
'extraData'
:
'0x'
,
'gasLimit'
:
'0x7a1200'
,
'gasUsed'
:
'0x0'
,
'hash'
:
'0xdb731f3622ef37b4da8db36903de029220dba74c41185f8429f916058b86559f'
,
'logsBloom'
:
'0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
,
'number'
:
toHex
(
block
.
header
.
number
),
"hash"
:
toHex
(
block
.
hash
()),
'parentHash'
:
toHex
(
block
.
header
.
parentHash
),
'nonce'
:
toHex
(
block
.
header
.
nonce
),
"sha3Uncles"
:
"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
,
"logsBloom"
:
"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331"
,
"transactionsRoot"
:
"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
,
"stateRoot"
:
toHex
(
block
.
header
.
stateRoot
),
'miner'
:
this
.
coinbase
,
'mixHash'
:
'0x0000000000000000000000000000000000000000000000000000000000000000'
,
'nonce'
:
'0x0000000000000042'
,
'number'
:
Web3
.
utils
.
toHex
(
this
.
blockNumber
),
'parentHash'
:
'0x0000000000000000000000000000000000000000000000000000000000000000'
,
'receiptsRoot'
:
'0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'
,
'sha3Uncles'
:
'0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347'
,
'size'
:
'0x1f8'
,
'stateRoot'
:
'0xb7917653f92e62394d2207d0f39a1320ff1cb93d1cee80d3c492627e00b219ff'
,
'timestamp'
:
'0x0'
,
'totalDifficulty'
:
'0x0'
,
'transactions'
:
[],
'transactionsRoot'
:
'0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'
,
'uncles'
:
[]
'difficulty'
:
toHex
(
block
.
header
.
difficulty
),
"totalDifficulty"
:
toHex
(
block
.
header
.
totalDifficulty
),
'extraData'
:
toHex
(
block
.
header
.
extraData
),
"size"
:
"0x027f07"
,
// 163591
'gasLimit'
:
toHex
(
block
.
header
.
gasLimit
),
'gasUsed'
:
toHex
(
block
.
header
.
gasUsed
),
"timestamp"
:
toHex
(
block
.
header
.
timestamp
),
// TODO: add transactions
// block.transactions
"transactions"
:
[],
"uncles"
:
[]
}
cb
(
null
,
b
)
}
...
...
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