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
13a65fab
Commit
13a65fab
authored
Apr 10, 2019
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add eth_sign & eth_getCompilers
parent
c3a5040f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
5 deletions
+42
-5
README.md
remix-simulator/README.md
+18
-2
accounts.js
remix-simulator/src/methods/accounts.js
+18
-2
misc.js
remix-simulator/src/methods/misc.js
+6
-1
No files found.
remix-simulator/README.md
View file @
13a65fab
...
...
@@ -23,7 +23,7 @@ Implemented:
*
[
_
]
eth_getUncleCountByBlockHash
*
[
_
]
eth_getUncleCountByBlockNumber
*
[
~
]
eth_getCode
*
[
_
]
eth_sign
*
[
~
]
eth_sign
*
[
X
]
eth_sendTransaction
*
[
_
]
eth_sendRawTransaction
*
[
X
]
eth_call
...
...
@@ -36,7 +36,7 @@ Implemented:
*
[
~
]
eth_getTransactionReceipt
*
[
_
]
eth_getUncleByBlockHashAndIndex
*
[
_
]
eth_getUncleByBlockNumberAndIndex
*
[
_
]
eth_getCompilers (DEPRECATED)
*
[
X
]
eth_getCompilers (DEPRECATED)
*
[
_
]
eth_compileSolidity (DEPRECATED)
*
[
_
]
eth_compileLLL (DEPRECATED)
*
[
_
]
eth_compileSerpent (DEPRECATED)
...
...
@@ -65,4 +65,20 @@ Implemented:
*
[
_
]
shh_uninstallFilter
*
[
_
]
shh_getFilterChanges
*
[
_
]
shh_getMessages
*
[
_
]
bzz_hive (stub)
*
[
_
]
bzz_info (stub)
*
[
_
]
debug_traceTransaction
*
[
_
]
eth_subscribe
*
[
_
]
eth_unsubscribe
*
[
_
]
miner_start
*
[
_
]
miner_stop
*
[
_
]
personal_listAccounts
*
[
_
]
personal_lockAccount
*
[
_
]
personal_newAccount
*
[
_
]
personal_importRawKey
*
[
_
]
personal_unlockAccount
*
[
_
]
personal_sendTransaction
*
[
_
]
rpc_modules
*
[
_
]
web3_clientVersion
*
[
_
]
web3_sha3
remix-simulator/src/methods/accounts.js
View file @
13a65fab
...
...
@@ -8,10 +8,13 @@ var Accounts = function () {
this
.
web3
=
new
Web3
()
// TODO: make it random and/or use remix-libs
this
.
accounts
=
[
this
.
web3
.
eth
.
accounts
.
create
([
'abcd'
]),
this
.
web3
.
eth
.
accounts
.
create
([
'ef12'
]),
this
.
web3
.
eth
.
accounts
.
create
([
'ef34'
])]
this
.
accountsKeys
=
{}
executionContext
.
init
({
get
:
()
=>
{
return
true
}})
for
(
let
_account
of
this
.
accounts
)
{
this
.
accountsKeys
[
_account
.
address
.
toLowerCase
()]
=
_account
.
privateKey
executionContext
.
vm
().
stateManager
.
getAccount
(
Buffer
.
from
(
_account
.
address
.
toLowerCase
().
replace
(
"0x"
,
""
),
'hex'
),
(
err
,
account
)
=>
{
var
balance
=
'0x56BC75E2D63100000'
account
.
balance
=
balance
||
'0xf00000000000000001'
...
...
@@ -22,7 +25,8 @@ var Accounts = function () {
Accounts
.
prototype
.
methods
=
function
()
{
return
{
eth_accounts
:
this
.
eth_accounts
.
bind
(
this
),
eth_getBalance
:
this
.
eth_getBalance
.
bind
(
this
)
eth_getBalance
:
this
.
eth_getBalance
.
bind
(
this
),
eth_sign
:
this
.
eth_sign
.
bind
(
this
)
}
}
...
...
@@ -34,7 +38,7 @@ Accounts.prototype.eth_getBalance = function (payload, cb) {
let
address
=
payload
.
params
[
0
]
address
=
ethJSUtil
.
stripHexPrefix
(
address
)
executionContext
.
vm
().
stateManager
.
getAccount
(
Buffer
.
from
(
address
,
'hex'
),
function
(
err
,
account
)
{
executionContext
.
vm
().
stateManager
.
getAccount
(
Buffer
.
from
(
address
,
'hex'
),
(
err
,
account
)
=>
{
if
(
err
)
{
return
cb
(
'Account not found'
)
}
...
...
@@ -42,4 +46,16 @@ Accounts.prototype.eth_getBalance = function (payload, cb) {
})
}
Accounts
.
prototype
.
eth_sign
=
function
(
payload
,
cb
)
{
let
address
=
payload
.
params
[
0
]
let
message
=
payload
.
params
[
1
]
let
privateKey
=
this
.
accountsKeys
[
address
]
let
account
=
web3
.
eth
.
accounts
.
privateKeyToAccount
(
privateKey
)
let
data
=
account
.
sign
(
message
)
cb
(
null
,
data
.
signature
)
}
module
.
exports
=
Accounts
remix-simulator/src/methods/misc.js
View file @
13a65fab
...
...
@@ -11,7 +11,8 @@ Misc.prototype.methods = function () {
eth_syncing
:
this
.
eth_syncing
.
bind
(
this
),
eth_mining
:
this
.
eth_mining
.
bind
(
this
),
eth_hashrate
:
this
.
eth_hashrate
.
bind
(
this
),
web3_sha3
:
this
.
web3_sha3
.
bind
(
this
)
web3_sha3
:
this
.
web3_sha3
.
bind
(
this
),
eth_getCompilers
:
this
.
eth_getCompilers
.
bind
(
this
)
}
}
...
...
@@ -41,4 +42,8 @@ Misc.prototype.web3_sha3 = function (payload, cb) {
cb
(
null
,
web3
.
utils
.
sha3
(
str
))
}
Misc
.
prototype
.
eth_getCompilers
=
function
(
payload
,
cb
)
{
cb
(
null
,
[])
}
module
.
exports
=
Misc
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