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
61e8922f
Commit
61e8922f
authored
Aug 28, 2019
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add eth_getStorageAt
parent
a1d4be80
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
189 additions
and
3 deletions
+189
-3
README.md
remix-simulator/README.md
+1
-1
accounts.js
remix-simulator/src/methods/accounts.js
+1
-1
blocks.js
remix-simulator/src/methods/blocks.js
+15
-1
blocks.js
remix-simulator/test/blocks.js
+172
-0
No files found.
remix-simulator/README.md
View file @
61e8922f
...
@@ -16,7 +16,7 @@ Implemented:
...
@@ -16,7 +16,7 @@ Implemented:
*
[
~
]
eth_accounts
*
[
~
]
eth_accounts
*
[
X
]
eth_blockNumber
*
[
X
]
eth_blockNumber
*
[
X
]
eth_getBalance
*
[
X
]
eth_getBalance
*
[
_
]
eth_getStorageAt
*
[
~
]
eth_getStorageAt
*
[
X
]
eth_getTransactionCount
*
[
X
]
eth_getTransactionCount
*
[
X
]
eth_getBlockTransactionCountByHash
*
[
X
]
eth_getBlockTransactionCountByHash
*
[
X
]
eth_getBlockTransactionCountByNumber
*
[
X
]
eth_getBlockTransactionCountByNumber
...
...
remix-simulator/src/methods/accounts.js
View file @
61e8922f
...
@@ -65,7 +65,7 @@ Accounts.prototype.eth_sign = function (payload, cb) {
...
@@ -65,7 +65,7 @@ Accounts.prototype.eth_sign = function (payload, cb) {
let
message
=
payload
.
params
[
1
]
let
message
=
payload
.
params
[
1
]
let
privateKey
=
this
.
accountsKeys
[
address
]
let
privateKey
=
this
.
accountsKeys
[
address
]
let
account
=
W
eb3
.
eth
.
accounts
.
privateKeyToAccount
(
privateKey
)
let
account
=
this
.
w
eb3
.
eth
.
accounts
.
privateKeyToAccount
(
privateKey
)
let
data
=
account
.
sign
(
message
)
let
data
=
account
.
sign
(
message
)
...
...
remix-simulator/src/methods/blocks.js
View file @
61e8922f
...
@@ -17,7 +17,8 @@ Blocks.prototype.methods = function () {
...
@@ -17,7 +17,8 @@ Blocks.prototype.methods = function () {
eth_getBlockTransactionCountByHash
:
this
.
eth_getBlockTransactionCountByHash
.
bind
(
this
),
eth_getBlockTransactionCountByHash
:
this
.
eth_getBlockTransactionCountByHash
.
bind
(
this
),
eth_getBlockTransactionCountByNumber
:
this
.
eth_getBlockTransactionCountByNumber
.
bind
(
this
),
eth_getBlockTransactionCountByNumber
:
this
.
eth_getBlockTransactionCountByNumber
.
bind
(
this
),
eth_getUncleCountByBlockHash
:
this
.
eth_getUncleCountByBlockHash
.
bind
(
this
),
eth_getUncleCountByBlockHash
:
this
.
eth_getUncleCountByBlockHash
.
bind
(
this
),
eth_getUncleCountByBlockNumber
:
this
.
eth_getUncleCountByBlockNumber
.
bind
(
this
)
eth_getUncleCountByBlockNumber
:
this
.
eth_getUncleCountByBlockNumber
.
bind
(
this
),
eth_getStorageAt
:
this
.
eth_getStorageAt
.
bind
(
this
)
}
}
}
}
...
@@ -117,4 +118,17 @@ Blocks.prototype.eth_getUncleCountByBlockNumber = function (payload, cb) {
...
@@ -117,4 +118,17 @@ Blocks.prototype.eth_getUncleCountByBlockNumber = function (payload, cb) {
cb
(
null
,
0
)
cb
(
null
,
0
)
}
}
Blocks
.
prototype
.
eth_getStorageAt
=
function
(
payload
,
cb
)
{
const
[
address
,
position
,
blockNumber
]
=
payload
.
params
executionContext
.
web3
().
debug
.
storageRangeAt
(
blockNumber
,
'latest'
,
address
.
toLowerCase
(),
position
,
1
,
(
err
,
result
)
=>
{
if
(
err
||
(
result
.
storage
&&
Object
.
values
(
result
.
storage
).
length
===
0
))
{
return
cb
(
err
,
''
)
}
let
value
=
Object
.
values
(
result
.
storage
)[
0
].
value
cb
(
err
,
value
)
})
}
module
.
exports
=
Blocks
module
.
exports
=
Blocks
remix-simulator/test/blocks.js
View file @
61e8922f
...
@@ -12,6 +12,7 @@ describe('blocks', function () {
...
@@ -12,6 +12,7 @@ describe('blocks', function () {
web3
.
setProvider
(
provider
)
web3
.
setProvider
(
provider
)
})
})
describe
(
'eth_getBlockByNumber'
,
()
=>
{
it
(
'should get block given its number'
,
async
function
()
{
it
(
'should get block given its number'
,
async
function
()
{
let
block
=
await
web3
.
eth
.
getBlock
(
0
)
let
block
=
await
web3
.
eth
.
getBlock
(
0
)
...
@@ -38,14 +39,185 @@ describe('blocks', function () {
...
@@ -38,14 +39,185 @@ describe('blocks', function () {
assert
.
deepEqual
(
block
,
expectedBlock
)
assert
.
deepEqual
(
block
,
expectedBlock
)
})
})
})
describe
(
'eth_getGasPrice'
,
()
=>
{
it
(
'should get gas price'
,
async
function
()
{
it
(
'should get gas price'
,
async
function
()
{
let
gasPrice
=
await
web3
.
eth
.
getGasPrice
()
let
gasPrice
=
await
web3
.
eth
.
getGasPrice
()
assert
.
equal
(
gasPrice
,
1
)
assert
.
equal
(
gasPrice
,
1
)
})
})
})
describe
(
'eth_coinbase'
,
()
=>
{
it
(
'should get coinbase'
,
async
function
()
{
it
(
'should get coinbase'
,
async
function
()
{
let
coinbase
=
await
web3
.
eth
.
getCoinbase
()
let
coinbase
=
await
web3
.
eth
.
getCoinbase
()
assert
.
equal
(
coinbase
,
'0x0000000000000000000000000000000000000001'
)
assert
.
equal
(
coinbase
,
'0x0000000000000000000000000000000000000001'
)
})
})
})
describe
(
'eth_blockNumber'
,
()
=>
{
it
(
'should get current block number'
,
async
function
()
{
let
number
=
await
web3
.
eth
.
getBlockNumber
()
assert
.
equal
(
number
,
0
)
})
})
describe
(
'eth_getBlockByHash'
,
()
=>
{
it
(
'should get block given its hash'
,
async
function
()
{
let
correctBlock
=
await
web3
.
eth
.
getBlock
(
0
)
let
block
=
await
web3
.
eth
.
getBlock
(
correctBlock
.
hash
)
assert
.
deepEqual
(
block
,
correctBlock
)
})
})
describe
(
'eth_getBlockTransactionCountByHash'
,
()
=>
{
it
(
'should get block given its hash'
,
async
function
()
{
let
correctBlock
=
await
web3
.
eth
.
getBlock
(
0
)
let
numberTransactions
=
await
web3
.
eth
.
getBlockTransactionCount
(
correctBlock
.
hash
)
assert
.
deepEqual
(
numberTransactions
,
0
)
})
})
describe
(
'eth_getBlockTransactionCountByNumber'
,
()
=>
{
it
(
'should get block given its hash'
,
async
function
()
{
let
numberTransactions
=
await
web3
.
eth
.
getBlockTransactionCount
(
0
)
assert
.
deepEqual
(
numberTransactions
,
0
)
})
})
describe
(
'eth_getUncleCountByBlockHash'
,
()
=>
{
it
(
'should get block given its hash'
,
async
function
()
{
let
correctBlock
=
await
web3
.
eth
.
getBlock
(
0
)
let
numberTransactions
=
await
(
new
Promise
((
resolve
,
reject
)
=>
{
web3
.
_requestManager
.
send
({
method
:
'eth_getUncleCountByBlockHash'
,
params
:
[
correctBlock
.
hash
]},
(
err
,
numberTransactions
)
=>
{
if
(
err
)
return
reject
(
err
)
resolve
(
numberTransactions
)
})
}))
assert
.
deepEqual
(
numberTransactions
,
correctBlock
.
uncles
.
length
)
})
})
describe
(
'eth_getUncleCountByBlockNumber'
,
()
=>
{
it
(
'should get block given its number'
,
async
function
()
{
let
correctBlock
=
await
web3
.
eth
.
getBlock
(
0
)
let
numberTransactions
=
await
(
new
Promise
((
resolve
,
reject
)
=>
{
web3
.
_requestManager
.
send
({
method
:
'eth_getUncleCountByBlockHash'
,
params
:
[
0
]},
(
err
,
numberTransactions
)
=>
{
if
(
err
)
return
reject
(
err
)
resolve
(
numberTransactions
)
})
}))
assert
.
deepEqual
(
numberTransactions
,
correctBlock
.
uncles
.
length
)
})
})
describe
(
'eth_getStorageAt'
,
()
=>
{
it
(
'should get storage at position at given address'
,
async
function
()
{
let
abi
=
[
{
'constant'
:
false
,
'inputs'
:
[
{
'name'
:
'x'
,
'type'
:
'uint256'
}
],
'name'
:
'set'
,
'outputs'
:
[],
'payable'
:
false
,
'stateMutability'
:
'nonpayable'
,
'type'
:
'function'
},
{
'constant'
:
false
,
'inputs'
:
[
{
'name'
:
'x'
,
'type'
:
'uint256'
}
],
'name'
:
'set2'
,
'outputs'
:
[],
'payable'
:
false
,
'stateMutability'
:
'nonpayable'
,
'type'
:
'function'
},
{
'inputs'
:
[
{
'name'
:
'initialValue'
,
'type'
:
'uint256'
}
],
'payable'
:
false
,
'stateMutability'
:
'nonpayable'
,
'type'
:
'constructor'
},
{
'anonymous'
:
false
,
'inputs'
:
[
{
'indexed'
:
true
,
'name'
:
'value'
,
'type'
:
'uint256'
}
],
'name'
:
'Test'
,
'type'
:
'event'
},
{
'constant'
:
true
,
'inputs'
:
[],
'name'
:
'get'
,
'outputs'
:
[
{
'name'
:
'retVal'
,
'type'
:
'uint256'
}
],
'payable'
:
false
,
'stateMutability'
:
'view'
,
'type'
:
'function'
},
{
'constant'
:
true
,
'inputs'
:
[],
'name'
:
'storedData'
,
'outputs'
:
[
{
'name'
:
''
,
'type'
:
'uint256'
}
],
'payable'
:
false
,
'stateMutability'
:
'view'
,
'type'
:
'function'
}
]
let
code
=
'0x608060405234801561001057600080fd5b506040516020806102018339810180604052602081101561003057600080fd5b810190808051906020019092919050505080600081905550506101a9806100586000396000f3fe60806040526004361061005c576000357c0100000000000000000000000000000000000000000000000000000000900480632a1afcd91461006157806360fe47b11461008c5780636d4ce63c146100c7578063ce01e1ec146100f2575b600080fd5b34801561006d57600080fd5b5061007661012d565b6040518082815260200191505060405180910390f35b34801561009857600080fd5b506100c5600480360360208110156100af57600080fd5b8101908080359060200190929190505050610133565b005b3480156100d357600080fd5b506100dc61013d565b6040518082815260200191505060405180910390f35b3480156100fe57600080fd5b5061012b6004803603602081101561011557600080fd5b8101908080359060200190929190505050610146565b005b60005481565b8060008190555050565b60008054905090565b80600081905550807f63a242a632efe33c0e210e04e4173612a17efa4f16aa4890bc7e46caece80de060405160405180910390a25056fea165627a7a7230582063160eb16dc361092a85ced1a773eed0b63738b83bea1e1c51cf066fa90e135d0029'
const
contract
=
new
web3
.
eth
.
Contract
(
abi
)
const
accounts
=
await
web3
.
eth
.
getAccounts
()
const
contractInstance
=
await
contract
.
deploy
({
data
:
code
,
arguments
:
[
100
]
}).
send
({
from
:
accounts
[
0
],
gas
:
400000
})
contractInstance
.
currentProvider
=
web3
.
eth
.
currentProvider
contractInstance
.
givenProvider
=
web3
.
eth
.
currentProvider
await
contractInstance
.
methods
.
set
(
100
).
send
({
from
:
accounts
[
0
],
gas
:
400000
})
let
storage
=
await
web3
.
eth
.
getStorageAt
(
contractInstance
.
options
.
address
,
0
)
assert
.
deepEqual
(
storage
,
'0x64'
)
await
contractInstance
.
methods
.
set
(
200
).
send
({
from
:
accounts
[
0
],
gas
:
400000
})
storage
=
await
web3
.
eth
.
getStorageAt
(
contractInstance
.
options
.
address
,
0
)
assert
.
deepEqual
(
storage
,
'0x64'
)
await
contractInstance
.
methods
.
set
(
200
).
send
({
from
:
accounts
[
0
],
gas
:
400000
})
storage
=
await
web3
.
eth
.
getStorageAt
(
contractInstance
.
options
.
address
,
0
)
assert
.
deepEqual
(
storage
,
'0xc8'
)
})
})
})
})
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