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
9e6f599f
Commit
9e6f599f
authored
Sep 03, 2019
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
async instantiate remix simulator
parent
b7c08cc2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
15 deletions
+35
-15
accounts.js
remix-simulator/src/methods/accounts.js
+18
-9
transactions.js
remix-simulator/src/methods/transactions.js
+3
-1
provider.js
remix-simulator/src/provider.js
+7
-1
server.js
remix-simulator/src/server.js
+1
-0
runTestSources.ts
remix-tests/src/runTestSources.ts
+6
-4
No files found.
remix-simulator/src/methods/accounts.js
View file @
9e6f599f
...
...
@@ -12,19 +12,28 @@ var Accounts = function () {
this
.
accountsKeys
=
{}
executionContext
.
init
({
get
:
()
=>
{
return
true
}})
}
for
(
let
_account
of
this
.
accountsList
)
{
this
.
accountsKeys
[
_account
.
address
.
toLowerCase
()]
=
_account
.
privateKey
this
.
accounts
[
_account
.
address
.
toLowerCase
()]
=
{
privateKey
:
Buffer
.
from
(
_account
.
privateKey
.
replace
(
'0x'
,
''
),
'hex'
),
nonce
:
0
}
Accounts
.
prototype
.
init
=
async
function
()
{
let
setBalance
=
(
account
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
accountsKeys
[
ethJSUtil
.
toChecksumAddress
(
account
.
address
)]
=
account
.
privateKey
this
.
accounts
[
ethJSUtil
.
toChecksumAddress
(
account
.
address
)]
=
{
privateKey
:
Buffer
.
from
(
account
.
privateKey
.
replace
(
'0x'
,
''
),
'hex'
),
nonce
:
0
}
executionContext
.
vm
().
stateManager
.
getAccount
(
Buffer
.
from
(
_account
.
address
.
toLowerCase
().
replace
(
'0x'
,
''
),
'hex'
),
(
err
,
account
)
=>
{
if
(
err
)
{
throw
new
Error
(
err
)
}
var
balance
=
'0x56BC75E2D63100000'
account
.
balance
=
balance
||
'0xf00000000000000001'
executionContext
.
vm
().
stateManager
.
getAccount
(
Buffer
.
from
(
account
.
address
.
toLowerCase
().
replace
(
'0x'
,
''
),
'hex'
),
(
err
,
account
)
=>
{
if
(
err
)
{
throw
new
Error
(
err
)
}
var
balance
=
'0x56BC75E2D63100000'
account
.
balance
=
balance
||
'0xf00000000000000001'
resolve
()
})
})
}
for
(
let
_account
of
this
.
accountsList
)
{
await
setBalance
(
_account
)
}
}
Accounts
.
prototype
.
methods
=
function
()
{
...
...
remix-simulator/src/methods/transactions.js
View file @
9e6f599f
...
...
@@ -5,7 +5,9 @@ var ethJSUtil = require('ethereumjs-util')
var
processTx
=
require
(
'./txProcess.js'
)
var
BN
=
ethJSUtil
.
BN
var
Transactions
=
function
(
accounts
)
{
var
Transactions
=
function
()
{}
Transactions
.
prototype
.
init
=
function
(
accounts
)
{
this
.
accounts
=
accounts
}
...
...
remix-simulator/src/provider.js
View file @
9e6f599f
...
...
@@ -12,18 +12,24 @@ const generateBlock = require('./genesis.js')
var
Provider
=
function
(
options
)
{
this
.
Accounts
=
new
Accounts
()
this
.
Transactions
=
new
Transactions
()
this
.
methods
=
{}
this
.
methods
=
merge
(
this
.
methods
,
this
.
Accounts
.
methods
())
this
.
methods
=
merge
(
this
.
methods
,
(
new
Blocks
(
options
)).
methods
())
this
.
methods
=
merge
(
this
.
methods
,
(
new
Misc
()).
methods
())
this
.
methods
=
merge
(
this
.
methods
,
(
new
Net
()).
methods
())
this
.
methods
=
merge
(
this
.
methods
,
(
new
Transactions
(
this
.
Accounts
.
accounts
)).
methods
(
))
this
.
methods
=
merge
(
this
.
methods
,
(
this
.
Transactions
.
methods
()
))
this
.
methods
=
merge
(
this
.
methods
,
(
new
Whisper
()).
methods
())
generateBlock
()
}
Provider
.
prototype
.
init
=
async
function
()
{
await
this
.
Accounts
.
init
()
this
.
Transactions
.
init
(
this
.
Accounts
.
accounts
)
}
Provider
.
prototype
.
sendAsync
=
function
(
payload
,
callback
)
{
log
.
info
(
'payload method is '
,
payload
.
method
)
...
...
remix-simulator/src/server.js
View file @
9e6f599f
...
...
@@ -8,6 +8,7 @@ const log = require('./utils/logs.js')
class
Server
{
constructor
(
options
)
{
this
.
provider
=
new
Provider
(
options
)
this
.
provider
.
init
()
}
start
(
host
,
port
)
{
...
...
remix-tests/src/runTestSources.ts
View file @
9e6f599f
...
...
@@ -10,15 +10,17 @@ import Web3 = require('web3')
import
{
Provider
}
from
'remix-simulator'
import
{
FinalResult
}
from
'./types'
const
createWeb3Provider
=
function
()
{
const
createWeb3Provider
=
async
function
()
{
let
web3
=
new
Web3
()
web3
.
setProvider
(
new
Provider
())
let
provider
=
new
Provider
()
await
provider
.
init
()
web3
.
setProvider
(
provider
)
return
web3
}
export
function
runTestSources
(
contractSources
,
testCallback
,
resultCallback
,
finalCallback
,
importFileCb
,
opts
)
{
export
async
function
runTestSources
(
contractSources
,
testCallback
,
resultCallback
,
finalCallback
,
importFileCb
,
opts
)
{
opts
=
opts
||
{}
let
web3
=
opts
.
web3
||
createWeb3Provider
()
let
web3
=
opts
.
web3
||
await
createWeb3Provider
()
let
accounts
=
opts
.
accounts
||
null
async
.
waterfall
([
function
getAccountList
(
next
)
{
...
...
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