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
6b765f95
Commit
6b765f95
authored
Apr 16, 2019
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make linter happy; remove getBlock call for now
parent
d20d81dd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
22 deletions
+27
-22
accounts.js
remix-simulator/src/methods/accounts.js
+7
-4
blocks.js
remix-simulator/src/methods/blocks.js
+2
-2
transactions.js
remix-simulator/src/methods/transactions.js
+18
-16
No files found.
remix-simulator/src/methods/accounts.js
View file @
6b765f95
...
@@ -15,9 +15,12 @@ var Accounts = function () {
...
@@ -15,9 +15,12 @@ var Accounts = function () {
for
(
let
_account
of
this
.
accountsList
)
{
for
(
let
_account
of
this
.
accountsList
)
{
this
.
accountsKeys
[
_account
.
address
.
toLowerCase
()]
=
_account
.
privateKey
this
.
accountsKeys
[
_account
.
address
.
toLowerCase
()]
=
_account
.
privateKey
this
.
accounts
[
_account
.
address
.
toLowerCase
()]
=
{
privateKey
:
Buffer
.
from
(
_account
.
privateKey
.
replace
(
"0x"
,
""
),
'hex'
),
nonce
:
0
}
this
.
accounts
[
_account
.
address
.
toLowerCase
()]
=
{
privateKey
:
Buffer
.
from
(
_account
.
privateKey
.
replace
(
'0x'
,
''
),
'hex'
),
nonce
:
0
}
executionContext
.
vm
().
stateManager
.
getAccount
(
Buffer
.
from
(
_account
.
address
.
toLowerCase
().
replace
(
"0x"
,
""
),
'hex'
),
(
err
,
account
)
=>
{
executionContext
.
vm
().
stateManager
.
getAccount
(
Buffer
.
from
(
_account
.
address
.
toLowerCase
().
replace
(
'0x'
,
''
),
'hex'
),
(
err
,
account
)
=>
{
if
(
err
)
{
throw
new
Error
(
err
)
}
var
balance
=
'0x56BC75E2D63100000'
var
balance
=
'0x56BC75E2D63100000'
account
.
balance
=
balance
||
'0xf00000000000000001'
account
.
balance
=
balance
||
'0xf00000000000000001'
})
})
...
@@ -42,7 +45,7 @@ Accounts.prototype.eth_getBalance = function (payload, cb) {
...
@@ -42,7 +45,7 @@ Accounts.prototype.eth_getBalance = function (payload, cb) {
executionContext
.
vm
().
stateManager
.
getAccount
(
Buffer
.
from
(
address
,
'hex'
),
(
err
,
account
)
=>
{
executionContext
.
vm
().
stateManager
.
getAccount
(
Buffer
.
from
(
address
,
'hex'
),
(
err
,
account
)
=>
{
if
(
err
)
{
if
(
err
)
{
return
cb
(
'Account not found'
)
return
cb
(
err
)
}
}
cb
(
null
,
new
BN
(
account
.
balance
).
toString
(
10
))
cb
(
null
,
new
BN
(
account
.
balance
).
toString
(
10
))
})
})
...
@@ -53,7 +56,7 @@ Accounts.prototype.eth_sign = function (payload, cb) {
...
@@ -53,7 +56,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
=
W
eb3
.
eth
.
accounts
.
privateKeyToAccount
(
privateKey
)
let
data
=
account
.
sign
(
message
)
let
data
=
account
.
sign
(
message
)
...
...
remix-simulator/src/methods/blocks.js
View file @
6b765f95
var
Web3
=
require
(
"web3"
)
var
Web3
=
require
(
'web3'
)
var
Blocks
=
function
(
_options
)
{
var
Blocks
=
function
(
_options
)
{
const
options
=
_options
||
{}
const
options
=
_options
||
{}
this
.
coinbase
=
options
.
coinbase
||
"0x0000000000000000000000000000000000000000"
this
.
coinbase
=
options
.
coinbase
||
'0x0000000000000000000000000000000000000000'
this
.
blockNumber
=
0
this
.
blockNumber
=
0
}
}
...
...
remix-simulator/src/methods/transactions.js
View file @
6b765f95
...
@@ -2,8 +2,9 @@ var RemixLib = require('remix-lib')
...
@@ -2,8 +2,9 @@ var RemixLib = require('remix-lib')
var
executionContext
=
RemixLib
.
execution
.
executionContext
var
executionContext
=
RemixLib
.
execution
.
executionContext
var
ethJSUtil
=
require
(
'ethereumjs-util'
)
var
ethJSUtil
=
require
(
'ethereumjs-util'
)
var
processTx
=
require
(
'./txProcess.js'
)
var
processTx
=
require
(
'./txProcess.js'
)
var
BN
=
ethJSUtil
.
BN
function
hexConvert
(
ints
)
{
function
hexConvert
(
ints
)
{
var
ret
=
'0x'
var
ret
=
'0x'
for
(
var
i
=
0
;
i
<
ints
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
ints
.
length
;
i
++
)
{
var
h
=
ints
[
i
]
var
h
=
ints
[
i
]
...
@@ -37,12 +38,10 @@ Transactions.prototype.eth_sendTransaction = function (payload, cb) {
...
@@ -37,12 +38,10 @@ Transactions.prototype.eth_sendTransaction = function (payload, cb) {
}
}
Transactions
.
prototype
.
eth_getTransactionReceipt
=
function
(
payload
,
cb
)
{
Transactions
.
prototype
.
eth_getTransactionReceipt
=
function
(
payload
,
cb
)
{
const
self
=
this
executionContext
.
web3
().
eth
.
getTransactionReceipt
(
payload
.
params
[
0
],
(
error
,
receipt
)
=>
{
executionContext
.
web3
().
eth
.
getTransactionReceipt
(
payload
.
params
[
0
],
(
error
,
receipt
)
=>
{
if
(
error
)
{
if
(
error
)
{
return
cb
(
error
)
return
cb
(
error
)
}
}
//self.deployedContracts[receipt.contractAddress] = receipt.data
var
r
=
{
var
r
=
{
'transactionHash'
:
receipt
.
hash
,
'transactionHash'
:
receipt
.
hash
,
...
@@ -82,6 +81,9 @@ Transactions.prototype.eth_getTransactionCount = function (payload, cb) {
...
@@ -82,6 +81,9 @@ Transactions.prototype.eth_getTransactionCount = function (payload, cb) {
let
address
=
payload
.
params
[
0
]
let
address
=
payload
.
params
[
0
]
executionContext
.
vm
().
stateManager
.
getAccount
(
address
,
(
err
,
account
)
=>
{
executionContext
.
vm
().
stateManager
.
getAccount
(
address
,
(
err
,
account
)
=>
{
if
(
err
)
{
return
cb
(
err
)
}
let
nonce
=
new
BN
(
account
.
nonce
).
toString
(
10
)
let
nonce
=
new
BN
(
account
.
nonce
).
toString
(
10
)
cb
(
null
,
nonce
)
cb
(
null
,
nonce
)
})
})
...
@@ -95,23 +97,23 @@ Transactions.prototype.eth_getTransactionByHash = function (payload, cb) {
...
@@ -95,23 +97,23 @@ Transactions.prototype.eth_getTransactionByHash = function (payload, cb) {
return
cb
(
error
)
return
cb
(
error
)
}
}
web3
.
eth
.
getBlock
(
receipt
.
hash
).
then
((
block
)
=>
{
//executionContext.web3()
.eth.getBlock(receipt.hash).then((block) => {
const
r
=
{
const
r
=
{
"hash"
:
receipt
.
transactionHash
,
'hash'
:
receipt
.
transactionHash
,
//"nonce": 2,
//
"nonce": 2,
"blockHash"
:
receipt
.
hash
,
'blockHash'
:
receipt
.
hash
,
"blockNumber"
:
block
.
number
,
//'blockNumber'
: block.number,
//"transactionIndex": 0,
//
"transactionIndex": 0,
"from"
:
receipt
.
from
,
'from'
:
receipt
.
from
,
"to"
:
receipt
.
to
,
'to'
:
receipt
.
to
,
"value"
:
receipt
.
value
,
'value'
:
receipt
.
value
,
"gas"
:
receipt
.
gas
,
'gas'
:
receipt
.
gas
,
"gasPrice"
:
'2000000000000'
,
'gasPrice'
:
'2000000000000'
,
"input"
:
receipt
.
input
'input'
:
receipt
.
input
}
}
cb
(
null
,
r
)
cb
(
null
,
r
)
})
//
})
})
})
}
}
...
...
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