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
5dfd594a
Commit
5dfd594a
authored
Apr 20, 2018
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move other methods to their own modules
parent
1c9a1b7e
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
23 deletions
+56
-23
accounts.js
remix-simulator/src/methods/accounts.js
+22
-0
blocks.js
remix-simulator/src/methods/blocks.js
+4
-0
misc.js
remix-simulator/src/methods/misc.js
+16
-0
transactions.js
remix-simulator/src/methods/transactions.js
+6
-1
provider.js
remix-simulator/src/provider.js
+8
-22
No files found.
remix-simulator/src/methods/accounts.js
0 → 100644
View file @
5dfd594a
var
Web3
=
require
(
'web3'
)
var
Accounts
=
function
(
web3
)
{
this
.
web3
=
new
Web3
()
// TODO: make it random and/or use remix-libs
this
.
accounts
=
[
this
.
web3
.
eth
.
accounts
.
create
([
'abcd'
])]
this
.
accounts
[
this
.
accounts
[
0
].
address
.
toLowerCase
()]
=
this
.
accounts
[
0
]
this
.
accounts
[
this
.
accounts
[
0
].
address
.
toLowerCase
()].
privateKey
=
Buffer
.
from
(
this
.
accounts
[
this
.
accounts
[
0
].
address
.
toLowerCase
()].
privateKey
.
slice
(
2
),
'hex'
)
}
Accounts
.
prototype
.
methods
=
function
()
{
return
{
eth_accounts
:
this
.
eth_accounts
.
bind
(
this
)
}
}
Accounts
.
prototype
.
eth_accounts
=
function
(
payload
,
cb
)
{
return
cb
(
null
,
this
.
accounts
.
map
((
x
)
=>
x
.
address
))
}
module
.
exports
=
Accounts
;
remix-simulator/src/methods/blocks.js
View file @
5dfd594a
...
...
@@ -34,4 +34,8 @@ Blocks.prototype.eth_getBlockByNumber = function (payload, cb) {
cb
(
null
,
b
)
}
Blocks
.
prototype
.
eth_gasPrice
=
function
(
payload
,
cb
)
{
cb
(
null
,
1
)
}
module
.
exports
=
Blocks
;
remix-simulator/src/methods/misc.js
0 → 100644
View file @
5dfd594a
var
Misc
=
function
()
{
}
Misc
.
prototype
.
methods
=
function
()
{
return
{
web3_clientVersion
:
'web3_clientVersion'
}
}
Misc
.
prototype
.
web3_clientVersion
=
function
(
payload
,
cb
)
{
cb
(
null
,
'Remix Simulator/0.0.1'
)
}
module
.
exports
=
Misc
;
remix-simulator/src/methods/transactions.js
View file @
5dfd594a
...
...
@@ -13,7 +13,8 @@ Transactions.prototype.methods = function () {
eth_sendTransaction
:
this
.
eth_sendTransaction
.
bind
(
this
),
eth_getTransactionReceipt
:
this
.
eth_getTransactionReceipt
.
bind
(
this
),
eth_getCode
:
this
.
eth_getCode
.
bind
(
this
),
eth_call
:
this
.
eth_call
.
bind
(
this
)
eth_call
:
this
.
eth_call
.
bind
(
this
),
eth_estimateGas
:
this
.
eth_estimateGas
.
bind
(
this
)
}
}
...
...
@@ -45,6 +46,10 @@ Transactions.prototype.eth_getTransactionReceipt = function(payload, cb) {
})
}
Transactions
.
prototype
.
eth_estimateGas
=
function
(
payload
,
cb
)
{
cb
(
null
,
3000000
)
}
Transactions
.
prototype
.
eth_getCode
=
function
(
payload
,
cb
)
{
let
address
=
payload
.
params
[
0
]
...
...
remix-simulator/src/provider.js
View file @
5dfd594a
var
Web3
=
require
(
'web3'
)
var
RemixLib
=
require
(
'remix-lib'
)
const
log
=
require
(
'fancy-log'
)
const
Accounts
=
require
(
'./methods/accounts.js'
)
const
Blocks
=
require
(
'./methods/blocks.js'
)
const
Misc
=
require
(
'./methods/misc.js'
)
const
Transactions
=
require
(
'./methods/transactions.js'
)
const
Whisper
=
require
(
'./methods/whisper.js'
)
const
merge
=
require
(
'merge'
)
...
...
@@ -10,17 +12,14 @@ function jsonRPCResponse (id, result) {
}
var
Provider
=
function
()
{
this
.
web3
=
new
Web3
()
// TODO: make it random
this
.
accounts
=
[
this
.
web3
.
eth
.
accounts
.
create
([
'abcd'
])]
this
.
accounts
[
this
.
accounts
[
0
].
address
.
toLowerCase
()]
=
this
.
accounts
[
0
]
this
.
accounts
[
this
.
accounts
[
0
].
address
.
toLowerCase
()].
privateKey
=
Buffer
.
from
(
this
.
accounts
[
this
.
accounts
[
0
].
address
.
toLowerCase
()].
privateKey
.
slice
(
2
),
'hex'
)
this
.
Accounts
=
new
Accounts
();
this
.
methods
=
{}
this
.
methods
=
merge
(
this
.
methods
,
(
new
Transactions
(
this
.
accounts
)).
methods
())
this
.
methods
=
merge
(
this
.
methods
,
(
new
Whisper
()).
methods
())
this
.
methods
=
merge
(
this
.
methods
,
this
.
Accounts
.
methods
())
this
.
methods
=
merge
(
this
.
methods
,
(
new
Blocks
()).
methods
())
this
.
methods
=
merge
(
this
.
methods
,
(
new
Misc
()).
methods
())
this
.
methods
=
merge
(
this
.
methods
,
(
new
Transactions
(
this
.
Accounts
.
accounts
)).
methods
())
this
.
methods
=
merge
(
this
.
methods
,
(
new
Whisper
()).
methods
())
log
.
dir
(
this
.
methods
)
}
...
...
@@ -29,19 +28,6 @@ Provider.prototype.sendAsync = function (payload, callback) {
log
.
dir
(
'payload method is '
)
log
.
dir
(
payload
.
method
)
if
(
payload
.
method
===
'eth_accounts'
)
{
log
.
dir
(
'eth_accounts'
)
return
callback
(
null
,
jsonRPCResponse
(
payload
.
id
,
this
.
accounts
.
map
((
x
)
=>
x
.
address
)))
}
if
(
payload
.
method
===
'eth_estimateGas'
)
{
callback
(
null
,
jsonRPCResponse
(
payload
.
id
,
3000000
))
}
if
(
payload
.
method
===
'eth_gasPrice'
)
{
callback
(
null
,
jsonRPCResponse
(
payload
.
id
,
1
))
}
if
(
payload
.
method
===
'web3_clientVersion'
)
{
callback
(
null
,
jsonRPCResponse
(
payload
.
id
,
'Remix Simulator/0.0.1'
))
}
let
method
=
this
.
methods
[
payload
.
method
]
if
(
method
)
{
return
method
.
call
(
method
,
payload
,
(
err
,
result
)
=>
{
...
...
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