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
d71e581b
Commit
d71e581b
authored
Nov 20, 2020
by
aniket-engg
Committed by
Aniket
Nov 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
linting passed
parent
533e0626
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
113 additions
and
122 deletions
+113
-122
.eslintrc
libs/remix-simulator/.eslintrc
+3
-1
index.ts
libs/remix-simulator/src/index.ts
+1
-1
accounts.ts
libs/remix-simulator/src/methods/accounts.ts
+6
-9
blocks.ts
libs/remix-simulator/src/methods/blocks.ts
+45
-47
debug.ts
libs/remix-simulator/src/methods/debug.ts
+1
-2
filters.ts
libs/remix-simulator/src/methods/filters.ts
+6
-7
transactions.ts
libs/remix-simulator/src/methods/transactions.ts
+42
-44
txProcess.ts
libs/remix-simulator/src/methods/txProcess.ts
+3
-3
provider.ts
libs/remix-simulator/src/provider.ts
+4
-6
server.ts
libs/remix-simulator/src/server.ts
+1
-1
workspace.json
workspace.json
+1
-1
No files found.
libs/remix-simulator/.eslintrc
View file @
d71e581b
...
@@ -3,7 +3,9 @@
...
@@ -3,7 +3,9 @@
"rules": {
"rules": {
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-unused-vars": "off"
"@typescript-eslint/no-unused-vars": "off",
"camelcase": "off",
"dot-notation": "off"
},
},
"env": {
"env": {
"browser": true,
"browser": true,
...
...
libs/remix-simulator/src/index.ts
View file @
d71e581b
import
{
Provider
}
from
'./provider'
import
{
Provider
}
from
'./provider'
export
{
Provider
}
export
{
Provider
}
libs/remix-simulator/src/methods/accounts.ts
View file @
d71e581b
import
{
BN
,
privateToAddress
,
toChecksumAddress
,
isValidPrivate
}
from
'ethereumjs-util'
import
{
BN
,
privateToAddress
,
toChecksumAddress
,
isValidPrivate
}
from
'ethereumjs-util'
import
{
stripHexPrefix
}
from
'ethjs-util'
import
{
stripHexPrefix
}
from
'ethjs-util'
import
Web3
from
'web3'
import
Web3
from
'web3'
import
*
as
crypto
from
'crypto'
import
*
as
crypto
from
'crypto'
export
class
Accounts
{
export
class
Accounts
{
web3
web3
accounts
accounts
accountsKeys
accountsKeys
executionContext
executionContext
constructor
(
executionContext
)
{
constructor
(
executionContext
)
{
this
.
web3
=
new
Web3
()
this
.
web3
=
new
Web3
()
this
.
executionContext
=
executionContext
this
.
executionContext
=
executionContext
// TODO: make it random and/or use remix-libs
// TODO: make it random and/or use remix-libs
this
.
accounts
=
{}
this
.
accounts
=
{}
this
.
accountsKeys
=
{}
this
.
accountsKeys
=
{}
this
.
executionContext
.
init
({
get
:
()
=>
{
return
true
}
})
this
.
executionContext
.
init
({
get
:
()
=>
{
return
true
}
})
}
}
async
resetAccounts
()
{
async
resetAccounts
()
{
...
@@ -49,7 +48,7 @@ export class Accounts {
...
@@ -49,7 +48,7 @@ export class Accounts {
this
.
accounts
[
toChecksumAddress
(
'0x'
+
address
.
toString
(
'hex'
))]
=
{
privateKey
,
nonce
:
0
}
this
.
accounts
[
toChecksumAddress
(
'0x'
+
address
.
toString
(
'hex'
))]
=
{
privateKey
,
nonce
:
0
}
this
.
accountsKeys
[
toChecksumAddress
(
'0x'
+
address
.
toString
(
'hex'
))]
=
'0x'
+
privateKey
.
toString
(
'hex'
)
this
.
accountsKeys
[
toChecksumAddress
(
'0x'
+
address
.
toString
(
'hex'
))]
=
'0x'
+
privateKey
.
toString
(
'hex'
)
le
t
stateManager
=
this
.
executionContext
.
vm
().
stateManager
cons
t
stateManager
=
this
.
executionContext
.
vm
().
stateManager
stateManager
.
getAccount
(
address
,
(
error
,
account
)
=>
{
stateManager
.
getAccount
(
address
,
(
error
,
account
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
log
(
error
)
console
.
log
(
error
)
...
@@ -60,7 +59,6 @@ export class Accounts {
...
@@ -60,7 +59,6 @@ export class Accounts {
resolve
()
resolve
()
})
})
})
})
}
}
newAccount
(
cb
)
{
newAccount
(
cb
)
{
...
@@ -110,4 +108,4 @@ export class Accounts {
...
@@ -110,4 +108,4 @@ export class Accounts {
cb
(
null
,
data
.
signature
)
cb
(
null
,
data
.
signature
)
}
}
}
}
\ No newline at end of file
libs/remix-simulator/src/methods/blocks.ts
View file @
d71e581b
export
class
Blocks
{
export
class
Blocks
{
executionContext
executionContext
coinbase
coinbase
blockNumber
blockNumber
...
@@ -38,58 +37,58 @@ export class Blocks {
...
@@ -38,58 +37,58 @@ export class Blocks {
return
cb
(
new
Error
(
'block not found'
))
return
cb
(
new
Error
(
'block not found'
))
}
}
le
t
b
=
{
cons
t
b
=
{
'number'
:
this
.
toHex
(
block
.
header
.
number
),
number
:
this
.
toHex
(
block
.
header
.
number
),
'hash'
:
this
.
toHex
(
block
.
hash
()),
hash
:
this
.
toHex
(
block
.
hash
()),
'parentHash'
:
this
.
toHex
(
block
.
header
.
parentHash
),
parentHash
:
this
.
toHex
(
block
.
header
.
parentHash
),
'nonce'
:
this
.
toHex
(
block
.
header
.
nonce
),
nonce
:
this
.
toHex
(
block
.
header
.
nonce
),
'sha3Uncles'
:
'0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347'
,
sha3Uncles
:
'0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347'
,
'logsBloom'
:
'0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331'
,
logsBloom
:
'0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331'
,
'transactionsRoot'
:
'0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'
,
transactionsRoot
:
'0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'
,
'stateRoot'
:
this
.
toHex
(
block
.
header
.
stateRoot
),
stateRoot
:
this
.
toHex
(
block
.
header
.
stateRoot
),
'miner'
:
this
.
coinbase
,
miner
:
this
.
coinbase
,
'difficulty'
:
this
.
toHex
(
block
.
header
.
difficulty
),
difficulty
:
this
.
toHex
(
block
.
header
.
difficulty
),
'totalDifficulty'
:
this
.
toHex
(
block
.
header
.
totalDifficulty
),
totalDifficulty
:
this
.
toHex
(
block
.
header
.
totalDifficulty
),
'extraData'
:
this
.
toHex
(
block
.
header
.
extraData
),
extraData
:
this
.
toHex
(
block
.
header
.
extraData
),
'size'
:
'0x027f07'
,
// 163591
size
:
'0x027f07'
,
// 163591
'gasLimit'
:
this
.
toHex
(
block
.
header
.
gasLimit
),
gasLimit
:
this
.
toHex
(
block
.
header
.
gasLimit
),
'gasUsed'
:
this
.
toHex
(
block
.
header
.
gasUsed
),
gasUsed
:
this
.
toHex
(
block
.
header
.
gasUsed
),
'timestamp'
:
this
.
toHex
(
block
.
header
.
timestamp
),
timestamp
:
this
.
toHex
(
block
.
header
.
timestamp
),
'transactions'
:
block
.
transactions
.
map
((
t
)
=>
'0x'
+
t
.
hash
().
toString
(
'hex'
)),
transactions
:
block
.
transactions
.
map
((
t
)
=>
'0x'
+
t
.
hash
().
toString
(
'hex'
)),
'uncles'
:
[]
uncles
:
[]
}
}
cb
(
null
,
b
)
cb
(
null
,
b
)
}
}
toHex
(
value
)
{
toHex
(
value
)
{
if
(
!
value
)
return
'0x0'
if
(
!
value
)
return
'0x0'
le
t
v
=
value
.
toString
(
'hex'
)
cons
t
v
=
value
.
toString
(
'hex'
)
return
((
v
===
'0x'
||
v
===
''
)
?
'0x0'
:
(
'0x'
+
v
))
return
((
v
===
'0x'
||
v
===
''
)
?
'0x0'
:
(
'0x'
+
v
))
}
}
eth_getBlockByHash
(
payload
,
cb
)
{
eth_getBlockByHash
(
payload
,
cb
)
{
var
block
=
this
.
executionContext
.
blocks
[
payload
.
params
[
0
]]
var
block
=
this
.
executionContext
.
blocks
[
payload
.
params
[
0
]]
le
t
b
=
{
cons
t
b
=
{
'number'
:
this
.
toHex
(
block
.
header
.
number
),
number
:
this
.
toHex
(
block
.
header
.
number
),
'hash'
:
this
.
toHex
(
block
.
hash
()),
hash
:
this
.
toHex
(
block
.
hash
()),
'parentHash'
:
this
.
toHex
(
block
.
header
.
parentHash
),
parentHash
:
this
.
toHex
(
block
.
header
.
parentHash
),
'nonce'
:
this
.
toHex
(
block
.
header
.
nonce
),
nonce
:
this
.
toHex
(
block
.
header
.
nonce
),
'sha3Uncles'
:
'0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347'
,
sha3Uncles
:
'0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347'
,
'logsBloom'
:
'0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331'
,
logsBloom
:
'0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331'
,
'transactionsRoot'
:
'0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'
,
transactionsRoot
:
'0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'
,
'stateRoot'
:
this
.
toHex
(
block
.
header
.
stateRoot
),
stateRoot
:
this
.
toHex
(
block
.
header
.
stateRoot
),
'miner'
:
this
.
coinbase
,
miner
:
this
.
coinbase
,
'difficulty'
:
this
.
toHex
(
block
.
header
.
difficulty
),
difficulty
:
this
.
toHex
(
block
.
header
.
difficulty
),
'totalDifficulty'
:
this
.
toHex
(
block
.
header
.
totalDifficulty
),
totalDifficulty
:
this
.
toHex
(
block
.
header
.
totalDifficulty
),
'extraData'
:
this
.
toHex
(
block
.
header
.
extraData
),
extraData
:
this
.
toHex
(
block
.
header
.
extraData
),
'size'
:
'0x027f07'
,
// 163591
size
:
'0x027f07'
,
// 163591
'gasLimit'
:
this
.
toHex
(
block
.
header
.
gasLimit
),
gasLimit
:
this
.
toHex
(
block
.
header
.
gasLimit
),
'gasUsed'
:
this
.
toHex
(
block
.
header
.
gasUsed
),
gasUsed
:
this
.
toHex
(
block
.
header
.
gasUsed
),
'timestamp'
:
this
.
toHex
(
block
.
header
.
timestamp
),
timestamp
:
this
.
toHex
(
block
.
header
.
timestamp
),
'transactions'
:
block
.
transactions
.
map
((
t
)
=>
'0x'
+
t
.
hash
().
toString
(
'hex'
)),
transactions
:
block
.
transactions
.
map
((
t
)
=>
'0x'
+
t
.
hash
().
toString
(
'hex'
)),
'uncles'
:
[]
uncles
:
[]
}
}
cb
(
null
,
b
)
cb
(
null
,
b
)
...
@@ -135,8 +134,8 @@ export class Blocks {
...
@@ -135,8 +134,8 @@ export class Blocks {
return
cb
(
err
,
''
)
return
cb
(
err
,
''
)
}
}
le
t
value
=
Object
.
values
(
result
.
storage
)[
0
][
'value'
]
cons
t
value
=
Object
.
values
(
result
.
storage
)[
0
][
'value'
]
cb
(
err
,
value
)
cb
(
err
,
value
)
})
})
}
}
}
}
\ No newline at end of file
libs/remix-simulator/src/methods/debug.ts
View file @
d71e581b
export
class
Debug
{
export
class
Debug
{
executionContext
executionContext
constructor
(
executionContext
)
{
constructor
(
executionContext
)
{
...
@@ -10,7 +9,7 @@ export class Debug {
...
@@ -10,7 +9,7 @@ export class Debug {
return
{
return
{
debug_traceTransaction
:
this
.
debug_traceTransaction
.
bind
(
this
),
debug_traceTransaction
:
this
.
debug_traceTransaction
.
bind
(
this
),
debug_preimage
:
this
.
debug_preimage
.
bind
(
this
),
debug_preimage
:
this
.
debug_preimage
.
bind
(
this
),
debug_storageRangeAt
:
this
.
debug_storageRangeAt
.
bind
(
this
)
,
debug_storageRangeAt
:
this
.
debug_storageRangeAt
.
bind
(
this
)
}
}
}
}
...
...
libs/remix-simulator/src/methods/filters.ts
View file @
d71e581b
export
class
Filters
{
export
class
Filters
{
executionContext
executionContext
constructor
(
executionContext
)
{
constructor
(
executionContext
)
{
this
.
executionContext
=
executionContext
this
.
executionContext
=
executionContext
}
}
...
@@ -15,12 +14,12 @@ export class Filters {
...
@@ -15,12 +14,12 @@ export class Filters {
}
}
eth_getLogs
(
payload
,
cb
)
{
eth_getLogs
(
payload
,
cb
)
{
le
t
results
=
this
.
executionContext
.
logsManager
.
getLogsFor
(
payload
.
params
[
0
])
cons
t
results
=
this
.
executionContext
.
logsManager
.
getLogsFor
(
payload
.
params
[
0
])
cb
(
null
,
results
)
cb
(
null
,
results
)
}
}
eth_subscribe
(
payload
,
cb
)
{
eth_subscribe
(
payload
,
cb
)
{
le
t
subscriptionId
=
this
.
executionContext
.
logsManager
.
subscribe
(
payload
.
params
)
cons
t
subscriptionId
=
this
.
executionContext
.
logsManager
.
subscribe
(
payload
.
params
)
cb
(
null
,
subscriptionId
)
cb
(
null
,
subscriptionId
)
}
}
...
@@ -51,13 +50,13 @@ export class Filters {
...
@@ -51,13 +50,13 @@ export class Filters {
eth_getFilterChanges
(
payload
,
cb
)
{
eth_getFilterChanges
(
payload
,
cb
)
{
const
filterId
=
payload
.
params
[
0
]
const
filterId
=
payload
.
params
[
0
]
le
t
results
=
this
.
executionContext
.
logsManager
.
getLogsForFilter
(
filterId
)
cons
t
results
=
this
.
executionContext
.
logsManager
.
getLogsForFilter
(
filterId
)
cb
(
null
,
results
)
cb
(
null
,
results
)
}
}
eth_getFilterLogs
(
payload
,
cb
)
{
eth_getFilterLogs
(
payload
,
cb
)
{
const
filterId
=
payload
.
params
[
0
]
const
filterId
=
payload
.
params
[
0
]
le
t
results
=
this
.
executionContext
.
logsManager
.
getLogsForFilter
(
filterId
,
true
)
cons
t
results
=
this
.
executionContext
.
logsManager
.
getLogsForFilter
(
filterId
,
true
)
cb
(
null
,
results
)
cb
(
null
,
results
)
}
}
}
}
libs/remix-simulator/src/methods/transactions.ts
View file @
d71e581b
...
@@ -2,12 +2,11 @@ import Web3 from 'web3'
...
@@ -2,12 +2,11 @@ import Web3 from 'web3'
import
{
toChecksumAddress
,
BN
}
from
'ethereumjs-util'
import
{
toChecksumAddress
,
BN
}
from
'ethereumjs-util'
import
{
processTx
}
from
'./txProcess'
import
{
processTx
}
from
'./txProcess'
class
Transactions
{
export
class
Transactions
{
executionContext
executionContext
accounts
accounts
constructor
(
executionContext
)
{
constructor
(
executionContext
)
{
this
.
executionContext
=
executionContext
this
.
executionContext
=
executionContext
}
}
...
@@ -46,16 +45,16 @@ class Transactions{
...
@@ -46,16 +45,16 @@ class Transactions{
const
txBlock
=
this
.
executionContext
.
txs
[
receipt
.
hash
]
const
txBlock
=
this
.
executionContext
.
txs
[
receipt
.
hash
]
const
r
=
{
const
r
=
{
'transactionHash'
:
receipt
.
hash
,
transactionHash
:
receipt
.
hash
,
'transactionIndex'
:
'0x00'
,
transactionIndex
:
'0x00'
,
'blockHash'
:
'0x'
+
txBlock
.
hash
().
toString
(
'hex'
),
blockHash
:
'0x'
+
txBlock
.
hash
().
toString
(
'hex'
),
'blockNumber'
:
'0x'
+
txBlock
.
header
.
number
.
toString
(
'hex'
),
blockNumber
:
'0x'
+
txBlock
.
header
.
number
.
toString
(
'hex'
),
'gasUsed'
:
Web3
.
utils
.
toHex
(
receipt
.
gas
),
gasUsed
:
Web3
.
utils
.
toHex
(
receipt
.
gas
),
'cumulativeGasUsed'
:
Web3
.
utils
.
toHex
(
receipt
.
gas
),
cumulativeGasUsed
:
Web3
.
utils
.
toHex
(
receipt
.
gas
),
'contractAddress'
:
receipt
.
contractAddress
,
contractAddress
:
receipt
.
contractAddress
,
'logs'
:
receipt
.
logs
,
logs
:
receipt
.
logs
,
'status'
:
receipt
.
status
,
status
:
receipt
.
status
,
'to'
:
receipt
.
to
to
:
receipt
.
to
}
}
if
(
r
.
blockNumber
===
'0x'
)
{
if
(
r
.
blockNumber
===
'0x'
)
{
...
@@ -71,7 +70,7 @@ class Transactions{
...
@@ -71,7 +70,7 @@ class Transactions{
}
}
eth_getCode
(
payload
,
cb
)
{
eth_getCode
(
payload
,
cb
)
{
le
t
address
=
payload
.
params
[
0
]
cons
t
address
=
payload
.
params
[
0
]
this
.
executionContext
.
web3
().
eth
.
getCode
(
address
,
(
error
,
result
)
=>
{
this
.
executionContext
.
web3
().
eth
.
getCode
(
address
,
(
error
,
result
)
=>
{
if
(
error
)
{
if
(
error
)
{
...
@@ -97,13 +96,13 @@ class Transactions{
...
@@ -97,13 +96,13 @@ class Transactions{
}
}
eth_getTransactionCount
(
payload
,
cb
)
{
eth_getTransactionCount
(
payload
,
cb
)
{
le
t
address
=
payload
.
params
[
0
]
cons
t
address
=
payload
.
params
[
0
]
this
.
executionContext
.
vm
().
stateManager
.
getAccount
(
address
,
(
err
,
account
)
=>
{
this
.
executionContext
.
vm
().
stateManager
.
getAccount
(
address
,
(
err
,
account
)
=>
{
if
(
err
)
{
if
(
err
)
{
return
cb
(
err
)
return
cb
(
err
)
}
}
le
t
nonce
=
new
BN
(
account
.
nonce
).
toString
(
10
)
cons
t
nonce
=
new
BN
(
account
.
nonce
).
toString
(
10
)
cb
(
null
,
nonce
)
cb
(
null
,
nonce
)
})
})
}
}
...
@@ -120,17 +119,17 @@ class Transactions{
...
@@ -120,17 +119,17 @@ class Transactions{
// TODO: params to add later
// TODO: params to add later
const
r
=
{
const
r
=
{
'blockHash'
:
'0x'
+
txBlock
.
hash
().
toString
(
'hex'
),
blockHash
:
'0x'
+
txBlock
.
hash
().
toString
(
'hex'
),
'blockNumber'
:
'0x'
+
txBlock
.
header
.
number
.
toString
(
'hex'
),
blockNumber
:
'0x'
+
txBlock
.
header
.
number
.
toString
(
'hex'
),
'from'
:
receipt
.
from
,
from
:
receipt
.
from
,
'gas'
:
Web3
.
utils
.
toHex
(
receipt
.
gas
),
gas
:
Web3
.
utils
.
toHex
(
receipt
.
gas
),
// 'gasPrice': '2000000000000', // 0x123
// 'gasPrice': '2000000000000', // 0x123
'gasPrice'
:
'0x4a817c800'
,
// 20000000000
gasPrice
:
'0x4a817c800'
,
// 20000000000
'hash'
:
receipt
.
transactionHash
,
hash
:
receipt
.
transactionHash
,
'input'
:
receipt
.
input
,
input
:
receipt
.
input
,
// "nonce": 2, // 0x15
// "nonce": 2, // 0x15
// "transactionIndex": 0,
// "transactionIndex": 0,
'value'
:
receipt
.
value
value
:
receipt
.
value
// "value":"0xf3dbb76162000" // 4290000000000000
// "value":"0xf3dbb76162000" // 4290000000000000
// "v": "0x25", // 37
// "v": "0x25", // 37
// "r": "0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
// "r": "0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
...
@@ -165,18 +164,18 @@ class Transactions{
...
@@ -165,18 +164,18 @@ class Transactions{
}
}
// TODO: params to add later
// TODO: params to add later
le
t
r
=
{
cons
t
r
=
{
'blockHash'
:
'0x'
+
txBlock
.
hash
().
toString
(
'hex'
),
blockHash
:
'0x'
+
txBlock
.
hash
().
toString
(
'hex'
),
'blockNumber'
:
'0x'
+
txBlock
.
header
.
number
.
toString
(
'hex'
),
blockNumber
:
'0x'
+
txBlock
.
header
.
number
.
toString
(
'hex'
),
'from'
:
receipt
.
from
,
from
:
receipt
.
from
,
'gas'
:
Web3
.
utils
.
toHex
(
receipt
.
gas
),
gas
:
Web3
.
utils
.
toHex
(
receipt
.
gas
),
// 'gasPrice': '2000000000000', // 0x123
// 'gasPrice': '2000000000000', // 0x123
'gasPrice'
:
'0x4a817c800'
,
// 20000000000
gasPrice
:
'0x4a817c800'
,
// 20000000000
'hash'
:
receipt
.
transactionHash
,
hash
:
receipt
.
transactionHash
,
'input'
:
receipt
.
input
,
input
:
receipt
.
input
,
// "nonce": 2, // 0x15
// "nonce": 2, // 0x15
// "transactionIndex": 0,
// "transactionIndex": 0,
'value'
:
receipt
.
value
value
:
receipt
.
value
// "value":"0xf3dbb76162000" // 4290000000000000
// "value":"0xf3dbb76162000" // 4290000000000000
// "v": "0x25", // 37
// "v": "0x25", // 37
// "r": "0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
// "r": "0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
...
@@ -208,17 +207,17 @@ class Transactions{
...
@@ -208,17 +207,17 @@ class Transactions{
// TODO: params to add later
// TODO: params to add later
const
r
=
{
const
r
=
{
'blockHash'
:
'0x'
+
txBlock
.
hash
().
toString
(
'hex'
),
blockHash
:
'0x'
+
txBlock
.
hash
().
toString
(
'hex'
),
'blockNumber'
:
'0x'
+
txBlock
.
header
.
number
.
toString
(
'hex'
),
blockNumber
:
'0x'
+
txBlock
.
header
.
number
.
toString
(
'hex'
),
'from'
:
receipt
.
from
,
from
:
receipt
.
from
,
'gas'
:
Web3
.
utils
.
toHex
(
receipt
.
gas
),
gas
:
Web3
.
utils
.
toHex
(
receipt
.
gas
),
// 'gasPrice': '2000000000000', // 0x123
// 'gasPrice': '2000000000000', // 0x123
'gasPrice'
:
'0x4a817c800'
,
// 20000000000
gasPrice
:
'0x4a817c800'
,
// 20000000000
'hash'
:
receipt
.
transactionHash
,
hash
:
receipt
.
transactionHash
,
'input'
:
receipt
.
input
,
input
:
receipt
.
input
,
// "nonce": 2, // 0x15
// "nonce": 2, // 0x15
// "transactionIndex": 0,
// "transactionIndex": 0,
'value'
:
receipt
.
value
value
:
receipt
.
value
// "value":"0xf3dbb76162000" // 4290000000000000
// "value":"0xf3dbb76162000" // 4290000000000000
// "v": "0x25", // 37
// "v": "0x25", // 37
// "r": "0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
// "r": "0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
...
@@ -236,4 +235,4 @@ class Transactions{
...
@@ -236,4 +235,4 @@ class Transactions{
cb
(
null
,
r
)
cb
(
null
,
r
)
})
})
}
}
}
}
\ No newline at end of file
libs/remix-simulator/src/methods/txProcess.ts
View file @
d71e581b
...
@@ -12,7 +12,7 @@ function runCall (payload, from, to, data, value, gasLimit, txRunner, callbacks,
...
@@ -12,7 +12,7 @@ function runCall (payload, from, to, data, value, gasLimit, txRunner, callbacks,
return
callback
(
null
,
toReturn
)
return
callback
(
null
,
toReturn
)
}
}
TxExecution
.
callFunction
(
from
,
to
,
data
,
value
,
gasLimit
,
{
constant
:
true
},
txRunner
,
callbacks
,
finalCallback
,
true
)
TxExecution
.
callFunction
(
from
,
to
,
data
,
value
,
gasLimit
,
{
constant
:
true
},
txRunner
,
callbacks
,
finalCallback
,
true
)
}
}
function
runTx
(
payload
,
from
,
to
,
data
,
value
,
gasLimit
,
txRunner
,
callbacks
,
callback
)
{
function
runTx
(
payload
,
from
,
to
,
data
,
value
,
gasLimit
,
txRunner
,
callbacks
,
callback
)
{
...
@@ -23,7 +23,7 @@ function runTx (payload, from, to, data, value, gasLimit, txRunner, callbacks, c
...
@@ -23,7 +23,7 @@ function runTx (payload, from, to, data, value, gasLimit, txRunner, callbacks, c
callback
(
null
,
result
.
transactionHash
)
callback
(
null
,
result
.
transactionHash
)
}
}
TxExecution
.
callFunction
(
from
,
to
,
data
,
value
,
gasLimit
,
{
constant
:
false
},
txRunner
,
callbacks
,
finalCallback
,
false
)
TxExecution
.
callFunction
(
from
,
to
,
data
,
value
,
gasLimit
,
{
constant
:
false
},
txRunner
,
callbacks
,
finalCallback
,
false
)
}
}
function
createContract
(
payload
,
from
,
data
,
value
,
gasLimit
,
txRunner
,
callbacks
,
callback
)
{
function
createContract
(
payload
,
from
,
data
,
value
,
gasLimit
,
txRunner
,
callbacks
,
callback
)
{
...
@@ -71,7 +71,7 @@ export function processTx (executionContext, accounts, payload, isCall, callback
...
@@ -71,7 +71,7 @@ export function processTx (executionContext, accounts, payload, isCall, callback
let
{
from
,
to
,
data
,
value
,
gas
}
=
payload
.
params
[
0
]
let
{
from
,
to
,
data
,
value
,
gas
}
=
payload
.
params
[
0
]
gas
=
gas
||
3000000
gas
=
gas
||
3000000
le
t
callbacks
=
{
cons
t
callbacks
=
{
confirmationCb
:
(
network
,
tx
,
gasEstimation
,
continueTxExecution
,
cancelCb
)
=>
{
confirmationCb
:
(
network
,
tx
,
gasEstimation
,
continueTxExecution
,
cancelCb
)
=>
{
continueTxExecution
(
null
)
continueTxExecution
(
null
)
},
},
...
...
libs/remix-simulator/src/provider.ts
View file @
d71e581b
import
{
Blocks
}
from
'./methods/blocks'
const
RemixLib
=
require
(
'@remix-project/remix-lib'
)
const
RemixLib
=
require
(
'@remix-project/remix-lib'
)
const
executionContext
=
RemixLib
.
execution
.
executionContext
const
executionContext
=
RemixLib
.
execution
.
executionContext
...
@@ -5,7 +6,6 @@ const log = require('./utils/logs.js')
...
@@ -5,7 +6,6 @@ const log = require('./utils/logs.js')
const
merge
=
require
(
'merge'
)
const
merge
=
require
(
'merge'
)
const
Accounts
=
require
(
'./methods/accounts.js'
)
const
Accounts
=
require
(
'./methods/accounts.js'
)
import
{
Blocks
}
from
'./methods/blocks'
const
Filters
=
require
(
'./methods/filters.js'
)
const
Filters
=
require
(
'./methods/filters.js'
)
const
Misc
=
require
(
'./methods/misc.js'
)
const
Misc
=
require
(
'./methods/misc.js'
)
const
Net
=
require
(
'./methods/net.js'
)
const
Net
=
require
(
'./methods/net.js'
)
...
@@ -15,14 +15,13 @@ const Debug = require('./methods/debug.js')
...
@@ -15,14 +15,13 @@ const Debug = require('./methods/debug.js')
const
generateBlock
=
require
(
'./genesis.js'
)
const
generateBlock
=
require
(
'./genesis.js'
)
export
class
Provider
{
export
class
Provider
{
options
options
executionContext
executionContext
Accounts
Accounts
Transactions
Transactions
methods
methods
constructor
(
options
=
{})
{
constructor
(
options
=
{})
{
this
.
options
=
options
this
.
options
=
options
// TODO: init executionContext here
// TODO: init executionContext here
this
.
executionContext
=
executionContext
this
.
executionContext
=
executionContext
...
@@ -63,7 +62,7 @@ export class Provider {
...
@@ -63,7 +62,7 @@ export class Provider {
if
(
err
)
{
if
(
err
)
{
return
callback
(
err
)
return
callback
(
err
)
}
}
const
response
=
{
'id'
:
payload
.
id
,
'jsonrpc'
:
'2.0'
,
'result'
:
result
}
const
response
=
{
id
:
payload
.
id
,
jsonrpc
:
'2.0'
,
result
:
result
}
callback
(
null
,
response
)
callback
(
null
,
response
)
})
})
}
}
...
@@ -81,4 +80,4 @@ export class Provider {
...
@@ -81,4 +80,4 @@ export class Provider {
on
(
type
,
cb
)
{
on
(
type
,
cb
)
{
this
.
executionContext
.
logsManager
.
addListener
(
type
,
cb
)
this
.
executionContext
.
logsManager
.
addListener
(
type
,
cb
)
}
}
}
}
\ No newline at end of file
libs/remix-simulator/src/server.ts
View file @
d71e581b
...
@@ -21,7 +21,7 @@ class Server {
...
@@ -21,7 +21,7 @@ class Server {
expressWs
(
app
)
expressWs
(
app
)
app
.
use
(
cors
())
app
.
use
(
cors
())
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}))
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}))
app
.
use
(
bodyParser
.
json
())
app
.
use
(
bodyParser
.
json
())
app
.
get
(
'/'
,
(
req
,
res
)
=>
{
app
.
get
(
'/'
,
(
req
,
res
)
=>
{
...
...
workspace.json
View file @
d71e581b
...
@@ -301,7 +301,7 @@
...
@@ -301,7 +301,7 @@
"options"
:
{
"options"
:
{
"linter"
:
"eslint"
,
"linter"
:
"eslint"
,
"config"
:
"libs/remix-simulator/.eslintrc"
,
"config"
:
"libs/remix-simulator/.eslintrc"
,
"
files"
:
[
"libs/remix-simulator/**/*.js
"
],
"
tsConfig"
:
[
"libs/remix-simulator/tsconfig.lib.json
"
],
"exclude"
:
[
"**/node_modules/**"
,
"libs/remix-simulator/test/**/*"
]
"exclude"
:
[
"**/node_modules/**"
,
"libs/remix-simulator/test/**/*"
]
}
}
},
},
...
...
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