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
b9921e63
Commit
b9921e63
authored
Aug 25, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
executionContext
parent
5612e799
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
82 additions
and
106 deletions
+82
-106
app.js
src/app.js
+6
-42
debugger.js
src/app/debugger/debugger.js
+3
-2
txFormat.js
src/app/execution/txFormat.js
+7
-7
txListener.js
src/app/execution/txListener.js
+9
-7
txLogger.js
src/app/execution/txLogger.js
+2
-1
txRunner.js
src/app/execution/txRunner.js
+14
-16
run-tab.js
src/app/tabs/run-tab.js
+6
-5
execution-context.js
src/execution-context.js
+13
-2
universal-dapp.js
src/universal-dapp.js
+22
-24
No files found.
src/app.js
View file @
b9921e63
...
@@ -21,7 +21,7 @@ var Config = require('./config')
...
@@ -21,7 +21,7 @@ var Config = require('./config')
var
Editor
=
require
(
'./app/editor/editor'
)
var
Editor
=
require
(
'./app/editor/editor'
)
var
Renderer
=
require
(
'./app/ui/renderer'
)
var
Renderer
=
require
(
'./app/ui/renderer'
)
var
Compiler
=
require
(
'./app/compiler/compiler'
)
var
Compiler
=
require
(
'./app/compiler/compiler'
)
var
E
xecutionContext
=
require
(
'./execution-context'
)
var
e
xecutionContext
=
require
(
'./execution-context'
)
var
Debugger
=
require
(
'./app/debugger/debugger'
)
var
Debugger
=
require
(
'./app/debugger/debugger'
)
var
StaticAnalysis
=
require
(
'./app/staticanalysis/staticAnalysisView'
)
var
StaticAnalysis
=
require
(
'./app/staticanalysis/staticAnalysisView'
)
var
FilePanel
=
require
(
'./app/panels/file-panel'
)
var
FilePanel
=
require
(
'./app/panels/file-panel'
)
...
@@ -32,7 +32,6 @@ var modalDialogCustom = require('./app/ui/modal-dialog-custom')
...
@@ -32,7 +32,6 @@ var modalDialogCustom = require('./app/ui/modal-dialog-custom')
var
Txlistener
=
require
(
'./app/execution/txListener'
)
var
Txlistener
=
require
(
'./app/execution/txListener'
)
var
TxLogger
=
require
(
'./app/execution/txLogger'
)
var
TxLogger
=
require
(
'./app/execution/txLogger'
)
var
EventsDecoder
=
require
(
'./app/execution/eventsDecoder'
)
var
EventsDecoder
=
require
(
'./app/execution/eventsDecoder'
)
var
Web3VMProvider
=
remix
.
web3
.
web3VMProvider
var
handleImports
=
require
(
'./app/compiler/compiler-imports'
)
var
handleImports
=
require
(
'./app/compiler/compiler-imports'
)
var
FileManager
=
require
(
'./app/files/fileManager'
)
var
FileManager
=
require
(
'./app/files/fileManager'
)
...
@@ -169,22 +168,14 @@ module.exports = App
...
@@ -169,22 +168,14 @@ module.exports = App
function
run
()
{
function
run
()
{
var
self
=
this
var
self
=
this
// ------------------------------------------------------------
var
executionContext
=
new
ExecutionContext
()
// ----------------- editor ----------------------------
// ----------------- editor ----------------------------
this
.
_components
.
editor
=
new
Editor
({})
// @TODO: put into editorpanel
this
.
_components
.
editor
=
new
Editor
({})
// @TODO: put into editorpanel
// ----------------- editor panel ----------------------
// ----------------- editor panel ----------------------
this
.
_components
.
editorpanel
=
new
EditorPanel
({
this
.
_components
.
editorpanel
=
new
EditorPanel
({
api
:
{
api
:
{
editor
:
self
.
_components
.
editor
,
editor
:
self
.
_components
.
editor
,
config
:
self
.
_api
.
config
,
config
:
self
.
_api
.
config
web3
:
()
=>
{
}
return
executionContext
.
web3
()
},
context
:
()
=>
{
return
executionContext
.
getProvider
()
}}
})
})
this
.
_components
.
editorpanel
.
event
.
register
(
'resize'
,
direction
=>
self
.
_adjustLayout
(
direction
))
this
.
_components
.
editorpanel
.
event
.
register
(
'resize'
,
direction
=>
self
.
_adjustLayout
(
direction
))
...
@@ -351,7 +342,7 @@ function run () {
...
@@ -351,7 +342,7 @@ function run () {
}
}
}
}
var
udapp
=
new
UniversalDApp
(
executionContext
,
{
var
udapp
=
new
UniversalDApp
({
removable
:
false
,
removable
:
false
,
removable_instances
:
true
removable_instances
:
true
})
})
...
@@ -369,12 +360,6 @@ function run () {
...
@@ -369,12 +360,6 @@ function run () {
document
.
querySelector
(
`.
${
css
.
dragbar2
}
`
).
style
.
right
=
delta
+
'px'
document
.
querySelector
(
`.
${
css
.
dragbar2
}
`
).
style
.
right
=
delta
+
'px'
onResize
()
onResize
()
},
},
executionContextChange
:
(
context
)
=>
{
return
executionContext
.
executionContextChange
(
context
)
},
executionContextProvider
:
()
=>
{
return
executionContext
.
getProvider
()
},
getContracts
:
()
=>
{
getContracts
:
()
=>
{
if
(
compiler
.
lastCompilationResult
&&
compiler
.
lastCompilationResult
.
data
)
{
if
(
compiler
.
lastCompilationResult
&&
compiler
.
lastCompilationResult
.
data
)
{
return
compiler
.
lastCompilationResult
.
data
.
contracts
return
compiler
.
lastCompilationResult
.
data
.
contracts
...
@@ -384,9 +369,6 @@ function run () {
...
@@ -384,9 +369,6 @@ function run () {
udapp
:
()
=>
{
udapp
:
()
=>
{
return
udapp
return
udapp
},
},
executionContext
:
()
=>
{
return
executionContext
},
fileProviderOf
:
(
path
)
=>
{
fileProviderOf
:
(
path
)
=>
{
return
fileManager
.
fileProviderOf
(
path
)
return
fileManager
.
fileProviderOf
(
path
)
},
},
...
@@ -483,7 +465,7 @@ function run () {
...
@@ -483,7 +465,7 @@ function run () {
return
offsetToLineColumnConverter
.
offsetToLineColumn
(
location
,
file
,
compiler
.
lastCompilationResult
)
return
offsetToLineColumnConverter
.
offsetToLineColumn
(
location
,
file
,
compiler
.
lastCompilationResult
)
}
}
}
}
var
transactionDebugger
=
new
Debugger
(
'#debugger'
,
debugAPI
,
e
xecutionContext
.
event
,
e
ditor
.
event
)
var
transactionDebugger
=
new
Debugger
(
'#debugger'
,
debugAPI
,
editor
.
event
)
transactionDebugger
.
addProvider
(
'vm'
,
executionContext
.
vm
())
transactionDebugger
.
addProvider
(
'vm'
,
executionContext
.
vm
())
transactionDebugger
.
addProvider
(
'injected'
,
executionContext
.
web3
())
transactionDebugger
.
addProvider
(
'injected'
,
executionContext
.
web3
())
transactionDebugger
.
addProvider
(
'web3'
,
executionContext
.
web3
())
transactionDebugger
.
addProvider
(
'web3'
,
executionContext
.
web3
())
...
@@ -503,15 +485,6 @@ function run () {
...
@@ -503,15 +485,6 @@ function run () {
node
.
insertBefore
(
staticanalysis
.
render
(),
node
.
childNodes
[
0
])
node
.
insertBefore
(
staticanalysis
.
render
(),
node
.
childNodes
[
0
])
// ----------------- Tx listener -----------------
// ----------------- Tx listener -----------------
// not used right now
// TODO the following should be put in execution context
var
web3VM
=
new
Web3VMProvider
()
web3VM
.
setVM
(
executionContext
.
vm
())
var
currentWeb3
=
function
()
{
return
executionContext
.
isVM
()
?
web3VM
:
executionContext
.
web3
()
}
var
transactionReceiptResolver
=
{
var
transactionReceiptResolver
=
{
_transactionReceipts
:
{},
_transactionReceipts
:
{},
...
@@ -519,7 +492,7 @@ function run () {
...
@@ -519,7 +492,7 @@ function run () {
if
(
this
.
_transactionReceipts
[
tx
.
hash
])
{
if
(
this
.
_transactionReceipts
[
tx
.
hash
])
{
return
cb
(
null
,
this
.
_transactionReceipts
[
tx
.
hash
])
return
cb
(
null
,
this
.
_transactionReceipts
[
tx
.
hash
])
}
}
currentW
eb3
().
eth
.
getTransactionReceipt
(
tx
.
hash
,
(
error
,
receipt
)
=>
{
executionContext
.
w
eb3
().
eth
.
getTransactionReceipt
(
tx
.
hash
,
(
error
,
receipt
)
=>
{
if
(
!
error
)
{
if
(
!
error
)
{
this
.
_transactionReceipts
[
tx
.
hash
]
=
receipt
this
.
_transactionReceipts
[
tx
.
hash
]
=
receipt
cb
(
null
,
receipt
)
cb
(
null
,
receipt
)
...
@@ -539,18 +512,12 @@ function run () {
...
@@ -539,18 +512,12 @@ function run () {
var
txlistener
=
new
Txlistener
({
var
txlistener
=
new
Txlistener
({
api
:
{
api
:
{
web3
:
function
()
{
return
currentWeb3
()
},
isVM
:
function
()
{
return
executionContext
.
isVM
()
},
contracts
:
compiledContracts
,
contracts
:
compiledContracts
,
context
:
function
()
{
return
executionContext
.
getProvider
()
},
resolveReceipt
:
function
(
tx
,
cb
)
{
resolveReceipt
:
function
(
tx
,
cb
)
{
transactionReceiptResolver
.
resolve
(
tx
,
cb
)
transactionReceiptResolver
.
resolve
(
tx
,
cb
)
}
}
},
},
event
:
{
event
:
{
executionContext
:
executionContext
.
event
,
udapp
:
udapp
.
event
udapp
:
udapp
.
event
}})
}})
...
@@ -575,9 +542,6 @@ function run () {
...
@@ -575,9 +542,6 @@ function run () {
},
},
compiledContracts
:
function
()
{
compiledContracts
:
function
()
{
return
compiledContracts
()
return
compiledContracts
()
},
context
:
function
()
{
return
executionContext
.
getProvider
()
}
}
},
},
events
:
{
events
:
{
...
...
src/app/debugger/debugger.js
View file @
b9921e63
'use strict'
'use strict'
var
remix
=
require
(
'ethereum-remix'
)
var
remix
=
require
(
'ethereum-remix'
)
var
executionContext
=
require
(
'../../execution-context'
)
/**
/**
* Manage remix and source highlighting
* Manage remix and source highlighting
*/
*/
function
Debugger
(
id
,
appAPI
,
e
xecutionContextEvent
,
e
ditorEvent
)
{
function
Debugger
(
id
,
appAPI
,
editorEvent
)
{
this
.
el
=
document
.
querySelector
(
id
)
this
.
el
=
document
.
querySelector
(
id
)
this
.
debugger
=
new
remix
.
ui
.
Debugger
()
this
.
debugger
=
new
remix
.
ui
.
Debugger
()
this
.
sourceMappingDecoder
=
new
remix
.
util
.
SourceMappingDecoder
()
this
.
sourceMappingDecoder
=
new
remix
.
util
.
SourceMappingDecoder
()
...
@@ -30,7 +31,7 @@ function Debugger (id, appAPI, executionContextEvent, editorEvent) {
...
@@ -30,7 +31,7 @@ function Debugger (id, appAPI, executionContextEvent, editorEvent) {
this
.
breakPointManager
.
add
({
fileName
:
fileName
,
row
:
row
})
this
.
breakPointManager
.
add
({
fileName
:
fileName
,
row
:
row
})
})
})
executionContext
E
vent
.
register
(
'contextChanged'
,
this
,
function
(
context
)
{
executionContext
.
e
vent
.
register
(
'contextChanged'
,
this
,
function
(
context
)
{
self
.
switchProvider
(
context
)
self
.
switchProvider
(
context
)
})
})
...
...
src/app/execution/txFormat.js
View file @
b9921e63
...
@@ -5,6 +5,7 @@ var ethJSUtil = require('ethereumjs-util')
...
@@ -5,6 +5,7 @@ var ethJSUtil = require('ethereumjs-util')
var
BN
=
ethJSUtil
.
BN
var
BN
=
ethJSUtil
.
BN
var
helper
=
require
(
'./txHelper'
)
var
helper
=
require
(
'./txHelper'
)
var
TreeView
=
require
(
'ethereum-remix'
).
ui
.
TreeView
var
TreeView
=
require
(
'ethereum-remix'
).
ui
.
TreeView
var
executionContext
=
require
(
'../../execution-context'
)
module
.
exports
=
{
module
.
exports
=
{
/**
/**
...
@@ -16,10 +17,9 @@ module.exports = {
...
@@ -16,10 +17,9 @@ module.exports = {
* @param {Object} funAbi - abi definition of the function to call. null if building data for the ctor.
* @param {Object} funAbi - abi definition of the function to call. null if building data for the ctor.
* @param {Object} params - input paramater of the function to call
* @param {Object} params - input paramater of the function to call
* @param {Object} udapp - udapp
* @param {Object} udapp - udapp
* @param {Object} executionContext - executionContext
* @param {Function} callback - callback
* @param {Function} callback - callback
*/
*/
buildData
:
function
(
contract
,
contracts
,
isConstructor
,
funAbi
,
params
,
udapp
,
executionContext
,
callback
)
{
buildData
:
function
(
contract
,
contracts
,
isConstructor
,
funAbi
,
params
,
udapp
,
callback
)
{
var
funArgs
=
''
var
funArgs
=
''
try
{
try
{
funArgs
=
$
.
parseJSON
(
'['
+
params
+
']'
)
funArgs
=
$
.
parseJSON
(
'['
+
params
+
']'
)
...
@@ -47,7 +47,7 @@ module.exports = {
...
@@ -47,7 +47,7 @@ module.exports = {
if
(
isConstructor
)
{
if
(
isConstructor
)
{
var
bytecodeToDeploy
=
contract
.
bytecode
var
bytecodeToDeploy
=
contract
.
bytecode
if
(
bytecodeToDeploy
.
indexOf
(
'_'
)
>=
0
)
{
if
(
bytecodeToDeploy
.
indexOf
(
'_'
)
>=
0
)
{
this
.
linkBytecode
(
contract
,
contracts
,
executionContext
,
udapp
,
(
err
,
bytecode
)
=>
{
this
.
linkBytecode
(
contract
,
contracts
,
udapp
,
(
err
,
bytecode
)
=>
{
if
(
err
)
{
if
(
err
)
{
callback
(
'Error deploying required libraries: '
+
err
)
callback
(
'Error deploying required libraries: '
+
err
)
}
else
{
}
else
{
...
@@ -67,7 +67,7 @@ module.exports = {
...
@@ -67,7 +67,7 @@ module.exports = {
atAddress
:
function
()
{},
atAddress
:
function
()
{},
linkBytecode
:
function
(
contract
,
contracts
,
executionContext
,
udapp
,
callback
)
{
linkBytecode
:
function
(
contract
,
contracts
,
udapp
,
callback
)
{
var
bytecode
=
contract
.
bytecode
var
bytecode
=
contract
.
bytecode
if
(
bytecode
.
indexOf
(
'_'
)
<
0
)
{
if
(
bytecode
.
indexOf
(
'_'
)
<
0
)
{
return
callback
(
null
,
bytecode
)
return
callback
(
null
,
bytecode
)
...
@@ -81,7 +81,7 @@ module.exports = {
...
@@ -81,7 +81,7 @@ module.exports = {
if
(
!
libraryabi
)
{
if
(
!
libraryabi
)
{
return
callback
(
'Library '
+
libraryName
+
' not found.'
)
return
callback
(
'Library '
+
libraryName
+
' not found.'
)
}
}
this
.
deployLibrary
(
libraryabi
,
executionContext
,
udapp
,
(
err
,
address
)
=>
{
this
.
deployLibrary
(
libraryabi
,
udapp
,
(
err
,
address
)
=>
{
if
(
err
)
{
if
(
err
)
{
return
callback
(
err
)
return
callback
(
err
)
}
}
...
@@ -95,11 +95,11 @@ module.exports = {
...
@@ -95,11 +95,11 @@ module.exports = {
bytecode
=
bytecode
.
replace
(
libLabel
,
hexAddress
)
bytecode
=
bytecode
.
replace
(
libLabel
,
hexAddress
)
}
}
contract
.
bytecode
=
bytecode
contract
.
bytecode
=
bytecode
this
.
linkBytecode
(
contract
,
contracts
,
executionContext
,
udapp
,
callback
)
this
.
linkBytecode
(
contract
,
contracts
,
udapp
,
callback
)
})
})
},
},
deployLibrary
:
function
(
libraryName
,
library
,
executionContext
,
udapp
,
callback
)
{
deployLibrary
:
function
(
libraryName
,
library
,
udapp
,
callback
)
{
var
address
=
library
.
address
var
address
=
library
.
address
if
(
address
)
{
if
(
address
)
{
return
callback
(
null
,
address
)
return
callback
(
null
,
address
)
...
...
src/app/execution/txListener.js
View file @
b9921e63
...
@@ -5,6 +5,7 @@ var ethJSUtil = require('ethereumjs-util')
...
@@ -5,6 +5,7 @@ var ethJSUtil = require('ethereumjs-util')
var
EventManager
=
require
(
'ethereum-remix'
).
lib
.
EventManager
var
EventManager
=
require
(
'ethereum-remix'
).
lib
.
EventManager
var
remix
=
require
(
'ethereum-remix'
)
var
remix
=
require
(
'ethereum-remix'
)
var
codeUtil
=
remix
.
util
.
code
var
codeUtil
=
remix
.
util
.
code
var
executionContext
=
require
(
'../../execution-context'
)
/**
/**
* poll web3 each 2s if web3
* poll web3 each 2s if web3
...
@@ -20,15 +21,15 @@ class TxListener {
...
@@ -20,15 +21,15 @@ class TxListener {
this
.
_resolvedTransactions
=
{}
this
.
_resolvedTransactions
=
{}
this
.
_resolvedContracts
=
{}
this
.
_resolvedContracts
=
{}
this
.
init
()
this
.
init
()
opt
.
event
.
executionContex
t
.
register
(
'contextChanged'
,
(
context
)
=>
{
executionContext
.
even
t
.
register
(
'contextChanged'
,
(
context
)
=>
{
if
(
this
.
loopId
)
{
if
(
this
.
loopId
)
{
this
.
startListening
(
context
)
this
.
startListening
(
context
)
}
}
})
})
opt
.
event
.
udapp
.
register
(
'transactionExecuted'
,
(
error
,
to
,
data
,
lookupOnly
,
txResult
)
=>
{
opt
.
event
.
udapp
.
register
(
'transactionExecuted'
,
(
error
,
to
,
data
,
lookupOnly
,
txResult
)
=>
{
if
(
error
)
return
if
(
error
)
return
if
(
this
.
loopId
&&
this
.
_api
.
isVM
())
{
if
(
this
.
loopId
&&
executionContext
.
isVM
())
{
this
.
_api
.
web3
().
eth
.
getTransaction
(
txResult
.
transactionHash
,
(
error
,
tx
)
=>
{
executionContext
.
web3
().
eth
.
getTransaction
(
txResult
.
transactionHash
,
(
error
,
tx
)
=>
{
if
(
error
)
return
console
.
log
(
error
)
if
(
error
)
return
console
.
log
(
error
)
this
.
_newBlock
({
this
.
_newBlock
({
type
:
'VM'
,
type
:
'VM'
,
...
@@ -57,16 +58,16 @@ class TxListener {
...
@@ -57,16 +58,16 @@ class TxListener {
startListening
()
{
startListening
()
{
this
.
stopListening
()
this
.
stopListening
()
this
.
init
()
this
.
init
()
if
(
this
.
_api
.
context
()
===
'vm'
)
{
if
(
executionContext
.
getProvider
()
===
'vm'
)
{
this
.
loopId
=
'vm-listener'
this
.
loopId
=
'vm-listener'
}
else
{
}
else
{
this
.
loopId
=
setInterval
(()
=>
{
this
.
loopId
=
setInterval
(()
=>
{
this
.
_api
.
web3
().
eth
.
getBlockNumber
((
error
,
blockNumber
)
=>
{
executionContext
.
web3
().
eth
.
getBlockNumber
((
error
,
blockNumber
)
=>
{
if
(
this
.
loopId
===
null
||
this
.
loopId
===
'vm-listener'
)
return
if
(
this
.
loopId
===
null
||
this
.
loopId
===
'vm-listener'
)
return
if
(
error
)
return
console
.
log
(
error
)
if
(
error
)
return
console
.
log
(
error
)
if
(
!
this
.
lastBlock
||
blockNumber
>
this
.
lastBlock
)
{
if
(
!
this
.
lastBlock
||
blockNumber
>
this
.
lastBlock
)
{
this
.
lastBlock
=
blockNumber
this
.
lastBlock
=
blockNumber
this
.
_api
.
web3
().
eth
.
getBlock
(
this
.
lastBlock
,
true
,
(
error
,
result
)
=>
{
executionContext
.
web3
().
eth
.
getBlock
(
this
.
lastBlock
,
true
,
(
error
,
result
)
=>
{
if
(
!
error
)
{
if
(
!
error
)
{
this
.
_newBlock
(
Object
.
assign
({
type
:
'web3'
},
result
))
this
.
_newBlock
(
Object
.
assign
({
type
:
'web3'
},
result
))
}
}
...
@@ -131,6 +132,7 @@ class TxListener {
...
@@ -131,6 +132,7 @@ class TxListener {
}
}
_resolveTx
(
tx
,
cb
)
{
_resolveTx
(
tx
,
cb
)
{
console
.
log
(
tx
)
var
contracts
=
this
.
_api
.
contracts
()
var
contracts
=
this
.
_api
.
contracts
()
if
(
!
contracts
)
return
cb
()
if
(
!
contracts
)
return
cb
()
var
contractName
var
contractName
...
@@ -158,7 +160,7 @@ class TxListener {
...
@@ -158,7 +160,7 @@ class TxListener {
// first check known contract, resolve against the `runtimeBytecode` if not known
// first check known contract, resolve against the `runtimeBytecode` if not known
contractName
=
this
.
_resolvedContracts
[
tx
.
to
]
contractName
=
this
.
_resolvedContracts
[
tx
.
to
]
if
(
!
contractName
)
{
if
(
!
contractName
)
{
this
.
_api
.
web3
().
eth
.
getCode
(
tx
.
to
,
(
error
,
code
)
=>
{
executionContext
.
web3
().
eth
.
getCode
(
tx
.
to
,
(
error
,
code
)
=>
{
if
(
error
)
return
cb
(
error
)
if
(
error
)
return
cb
(
error
)
if
(
code
)
{
if
(
code
)
{
var
contractName
=
this
.
_tryResolveContract
(
code
,
contracts
,
'runtimeBytecode'
)
var
contractName
=
this
.
_tryResolveContract
(
code
,
contracts
,
'runtimeBytecode'
)
...
...
src/app/execution/txLogger.js
View file @
b9921e63
...
@@ -5,6 +5,7 @@ var EventManager = remix.lib.EventManager
...
@@ -5,6 +5,7 @@ var EventManager = remix.lib.EventManager
var
helper
=
require
(
'../../lib/helper'
)
var
helper
=
require
(
'../../lib/helper'
)
var
ethJSUtil
=
require
(
'ethereumjs-util'
)
var
ethJSUtil
=
require
(
'ethereumjs-util'
)
var
BN
=
ethJSUtil
.
BN
var
BN
=
ethJSUtil
.
BN
var
executionContext
=
require
(
'../../execution-context'
)
/**
/**
* This just export a function that register to `newTransaction` and forward them to the logger.
* This just export a function that register to `newTransaction` and forward them to the logger.
...
@@ -66,7 +67,7 @@ function renderUnknownTransaction (self, data) {
...
@@ -66,7 +67,7 @@ function renderUnknownTransaction (self, data) {
}
}
function
context
(
self
,
tx
)
{
function
context
(
self
,
tx
)
{
if
(
self
.
opts
.
api
.
context
()
===
'vm'
)
{
if
(
executionContext
.
getProvider
()
===
'vm'
)
{
return
yo
`<span>(vm)</span>`
return
yo
`<span>(vm)</span>`
}
else
{
}
else
{
return
yo
`<span>block:
${
tx
.
blockNumber
}
, txIndex:
${
tx
.
transactionIndex
}
`
return
yo
`<span>block:
${
tx
.
blockNumber
}
, txIndex:
${
tx
.
transactionIndex
}
`
...
...
src/app/execution/txRunner.js
View file @
b9921e63
...
@@ -3,15 +3,13 @@ var EthJSTX = require('ethereumjs-tx')
...
@@ -3,15 +3,13 @@ var EthJSTX = require('ethereumjs-tx')
var
EthJSBlock
=
require
(
'ethereumjs-block'
)
var
EthJSBlock
=
require
(
'ethereumjs-block'
)
var
ethJSUtil
=
require
(
'ethereumjs-util'
)
var
ethJSUtil
=
require
(
'ethereumjs-util'
)
var
BN
=
ethJSUtil
.
BN
var
BN
=
ethJSUtil
.
BN
var
executionContext
=
require
(
'../../execution-context'
)
function
TxRunner
(
executionContext
,
vmaccounts
,
opts
)
{
function
TxRunner
(
vmaccounts
,
opts
)
{
this
.
executionContext
=
executionContext
this
.
web3
=
executionContext
.
web3
()
this
.
vm
=
executionContext
.
vm
()
this
.
queueTxs
=
opts
.
queueTxs
this
.
queueTxs
=
opts
.
queueTxs
this
.
personalMode
=
opts
.
personalMode
this
.
personalMode
=
opts
.
personalMode
this
.
blockNumber
=
0
this
.
blockNumber
=
0
if
(
this
.
executionContext
.
isVM
())
{
if
(
executionContext
.
isVM
())
{
this
.
blockNumber
=
1150000
// The VM is running in Homestead mode, which started at this block.
this
.
blockNumber
=
1150000
// The VM is running in Homestead mode, which started at this block.
}
}
this
.
pendingTxs
=
{}
this
.
pendingTxs
=
{}
...
@@ -35,7 +33,7 @@ TxRunner.prototype.execute = function (args, callback) {
...
@@ -35,7 +33,7 @@ TxRunner.prototype.execute = function (args, callback) {
var
gasLimit
=
args
.
gasLimit
var
gasLimit
=
args
.
gasLimit
var
tx
var
tx
if
(
!
self
.
executionContext
.
isVM
())
{
if
(
!
executionContext
.
isVM
())
{
tx
=
{
tx
=
{
from
:
from
,
from
:
from
,
to
:
to
,
to
:
to
,
...
@@ -44,18 +42,18 @@ TxRunner.prototype.execute = function (args, callback) {
...
@@ -44,18 +42,18 @@ TxRunner.prototype.execute = function (args, callback) {
}
}
if
(
args
.
useCall
)
{
if
(
args
.
useCall
)
{
tx
.
gas
=
gasLimit
tx
.
gas
=
gasLimit
self
.
web3
.
eth
.
call
(
tx
,
function
(
error
,
result
)
{
executionContext
.
web3
()
.
eth
.
call
(
tx
,
function
(
error
,
result
)
{
callback
(
error
,
{
callback
(
error
,
{
result
:
result
,
result
:
result
,
transactionHash
:
result
.
transactionHash
transactionHash
:
result
.
transactionHash
})
})
})
})
}
else
{
}
else
{
self
.
web3
.
eth
.
estimateGas
(
tx
,
function
(
err
,
gasEstimation
)
{
executionContext
.
web3
()
.
eth
.
estimateGas
(
tx
,
function
(
err
,
gasEstimation
)
{
if
(
err
)
{
if
(
err
)
{
return
callback
(
err
,
gasEstimation
)
return
callback
(
err
,
gasEstimation
)
}
}
var
blockGasLimit
=
self
.
executionContext
.
currentblockGasLimit
()
var
blockGasLimit
=
executionContext
.
currentblockGasLimit
()
// NOTE: estimateGas very likely will return a large limit if execution of the code failed
// NOTE: estimateGas very likely will return a large limit if execution of the code failed
// we want to be able to run the code in order to debug and find the cause for the failure
// we want to be able to run the code in order to debug and find the cause for the failure
if
(
gasEstimation
>
gasLimit
)
{
if
(
gasEstimation
>
gasLimit
)
{
...
@@ -65,7 +63,7 @@ TxRunner.prototype.execute = function (args, callback) {
...
@@ -65,7 +63,7 @@ TxRunner.prototype.execute = function (args, callback) {
return
callback
(
'Gas required exceeds block gas limit: '
+
gasLimit
)
return
callback
(
'Gas required exceeds block gas limit: '
+
gasLimit
)
}
}
tx
.
gas
=
gasEstimation
tx
.
gas
=
gasEstimation
var
sendTransaction
=
self
.
personalMode
?
self
.
web3
.
personal
.
sendTransaction
:
self
.
web3
.
eth
.
sendTransaction
var
sendTransaction
=
self
.
personalMode
?
executionContext
.
web3
().
personal
.
sendTransaction
:
executionContext
.
web3
()
.
eth
.
sendTransaction
sendTransaction
(
tx
,
function
(
err
,
resp
)
{
sendTransaction
(
tx
,
function
(
err
,
resp
)
{
if
(
err
)
{
if
(
err
)
{
return
callback
(
err
,
resp
)
return
callback
(
err
,
resp
)
...
@@ -107,12 +105,12 @@ TxRunner.prototype.execute = function (args, callback) {
...
@@ -107,12 +105,12 @@ TxRunner.prototype.execute = function (args, callback) {
if
(
!
args
.
useCall
)
{
if
(
!
args
.
useCall
)
{
++
self
.
blockNumber
++
self
.
blockNumber
}
else
{
}
else
{
self
.
vm
.
stateManager
.
checkpoint
()
executionContext
.
vm
()
.
stateManager
.
checkpoint
()
}
}
self
.
vm
.
runTx
({
block
:
block
,
tx
:
tx
,
skipBalance
:
true
,
skipNonce
:
true
},
function
(
err
,
result
)
{
executionContext
.
vm
()
.
runTx
({
block
:
block
,
tx
:
tx
,
skipBalance
:
true
,
skipNonce
:
true
},
function
(
err
,
result
)
{
if
(
args
.
useCall
)
{
if
(
args
.
useCall
)
{
self
.
vm
.
stateManager
.
revert
(
function
()
{})
executionContext
.
vm
()
.
stateManager
.
revert
(
function
()
{})
}
}
err
=
err
?
err
.
message
:
err
err
=
err
?
err
.
message
:
err
callback
(
err
,
{
callback
(
err
,
{
...
@@ -126,11 +124,11 @@ TxRunner.prototype.execute = function (args, callback) {
...
@@ -126,11 +124,11 @@ TxRunner.prototype.execute = function (args, callback) {
}
}
}
}
function
tryTillResponse
(
web3
,
txhash
,
done
)
{
function
tryTillResponse
(
txhash
,
done
)
{
web3
.
eth
.
getTransactionReceipt
(
txhash
,
function
(
err
,
result
)
{
executionContext
.
web3
()
.
eth
.
getTransactionReceipt
(
txhash
,
function
(
err
,
result
)
{
if
(
!
err
&&
!
result
)
{
if
(
!
err
&&
!
result
)
{
// Try again with a bit of delay
// Try again with a bit of delay
setTimeout
(
function
()
{
tryTillResponse
(
web3
,
txhash
,
done
)
},
500
)
setTimeout
(
function
()
{
tryTillResponse
(
txhash
,
done
)
},
500
)
}
else
{
}
else
{
done
(
err
,
{
done
(
err
,
{
result
:
result
,
result
:
result
,
...
...
src/app/tabs/run-tab.js
View file @
b9921e63
...
@@ -6,6 +6,7 @@ var txExecution = require('../execution/txExecution')
...
@@ -6,6 +6,7 @@ var txExecution = require('../execution/txExecution')
var
txFormat
=
require
(
'../execution/txFormat'
)
var
txFormat
=
require
(
'../execution/txFormat'
)
var
txHelper
=
require
(
'../execution/txHelper'
)
var
txHelper
=
require
(
'../execution/txHelper'
)
var
modalDialogCustom
=
require
(
'../ui/modal-dialog-custom'
)
var
modalDialogCustom
=
require
(
'../ui/modal-dialog-custom'
)
var
executionContext
=
require
(
'../../execution-context'
)
const
copy
=
require
(
'clipboard-copy'
)
const
copy
=
require
(
'clipboard-copy'
)
// -------------- styling ----------------------
// -------------- styling ----------------------
...
@@ -200,15 +201,15 @@ function runTab (container, appAPI, appEvents, opts) {
...
@@ -200,15 +201,15 @@ function runTab (container, appAPI, appEvents, opts) {
// DROPDOWN
// DROPDOWN
var
selectExEnv
=
el
.
querySelector
(
'#selectExEnvOptions'
)
var
selectExEnv
=
el
.
querySelector
(
'#selectExEnvOptions'
)
selectExEnv
.
addEventListener
(
'change'
,
function
(
event
)
{
selectExEnv
.
addEventListener
(
'change'
,
function
(
event
)
{
if
(
!
appAPI
.
executionContextChange
(
selectExEnv
.
options
[
selectExEnv
.
selectedIndex
].
value
))
{
if
(
!
executionContext
.
executionContextChange
(
selectExEnv
.
options
[
selectExEnv
.
selectedIndex
].
value
))
{
selectExEnv
.
value
=
appAPI
.
executionContex
tProvider
()
selectExEnv
.
value
=
executionContext
.
ge
tProvider
()
}
}
fillAccountsList
(
appAPI
,
el
)
fillAccountsList
(
appAPI
,
el
)
instanceContainer
.
innerHTML
=
''
// clear the instances list
instanceContainer
.
innerHTML
=
''
// clear the instances list
noInstancesText
.
style
.
display
=
'block'
noInstancesText
.
style
.
display
=
'block'
instanceContainer
.
appendChild
(
noInstancesText
)
instanceContainer
.
appendChild
(
noInstancesText
)
})
})
selectExEnv
.
value
=
appAPI
.
executionContex
tProvider
()
selectExEnv
.
value
=
executionContext
.
ge
tProvider
()
fillAccountsList
(
appAPI
,
el
)
fillAccountsList
(
appAPI
,
el
)
setInterval
(()
=>
{
setInterval
(()
=>
{
updateAccountBalances
(
container
,
appAPI
)
updateAccountBalances
(
container
,
appAPI
)
...
@@ -299,11 +300,11 @@ function contractDropdown (appAPI, appEvents, instanceContainer) {
...
@@ -299,11 +300,11 @@ function contractDropdown (appAPI, appEvents, instanceContainer) {
var
contract
=
appAPI
.
getContracts
()[
contractNames
.
children
[
contractNames
.
selectedIndex
].
innerHTML
]
var
contract
=
appAPI
.
getContracts
()[
contractNames
.
children
[
contractNames
.
selectedIndex
].
innerHTML
]
var
constructor
=
txHelper
.
getConstructorInterface
(
contract
.
interface
)
var
constructor
=
txHelper
.
getConstructorInterface
(
contract
.
interface
)
var
args
=
createButtonInput
.
value
var
args
=
createButtonInput
.
value
txFormat
.
buildData
(
contract
,
contracts
,
true
,
constructor
,
args
,
appAPI
.
udapp
(),
appAPI
.
executionContext
(),
(
error
,
data
)
=>
{
txFormat
.
buildData
(
contract
,
contracts
,
true
,
constructor
,
args
,
appAPI
.
udapp
(),
(
error
,
data
)
=>
{
if
(
!
error
)
{
if
(
!
error
)
{
txExecution
.
createContract
(
data
,
appAPI
.
udapp
(),
(
error
,
txResult
)
=>
{
txExecution
.
createContract
(
data
,
appAPI
.
udapp
(),
(
error
,
txResult
)
=>
{
if
(
!
error
)
{
if
(
!
error
)
{
var
isVM
=
appAPI
.
executionContext
()
.
isVM
()
var
isVM
=
executionContext
.
isVM
()
if
(
isVM
)
{
if
(
isVM
)
{
var
vmError
=
txExecution
.
checkVMError
(
txResult
)
var
vmError
=
txExecution
.
checkVMError
(
txResult
)
if
(
vmError
.
error
)
{
if
(
vmError
.
error
)
{
...
...
src/execution-context.js
View file @
b9921e63
...
@@ -6,6 +6,8 @@ var EventManager = require('ethereum-remix').lib.EventManager
...
@@ -6,6 +6,8 @@ var EventManager = require('ethereum-remix').lib.EventManager
var
EthJSVM
=
require
(
'ethereumjs-vm'
)
var
EthJSVM
=
require
(
'ethereumjs-vm'
)
var
ethUtil
=
require
(
'ethereumjs-util'
)
var
ethUtil
=
require
(
'ethereumjs-util'
)
var
StateManager
=
require
(
'ethereumjs-vm/lib/stateManager'
)
var
StateManager
=
require
(
'ethereumjs-vm/lib/stateManager'
)
var
remix
=
require
(
'ethereum-remix'
)
var
Web3VMProvider
=
remix
.
web3
.
web3VMProvider
var
injectedProvider
var
injectedProvider
...
@@ -17,6 +19,8 @@ if (typeof window.web3 !== 'undefined') {
...
@@ -17,6 +19,8 @@ if (typeof window.web3 !== 'undefined') {
web3
=
new
Web3
(
new
Web3
.
providers
.
HttpProvider
(
'http://localhost:8545'
))
web3
=
new
Web3
(
new
Web3
.
providers
.
HttpProvider
(
'http://localhost:8545'
))
}
}
var
blankWeb3
=
new
Web3
()
/*
/*
extend vm state manager and instanciate VM
extend vm state manager and instanciate VM
*/
*/
...
@@ -65,6 +69,9 @@ vm.blockchain = stateManager.blockchain
...
@@ -65,6 +69,9 @@ vm.blockchain = stateManager.blockchain
vm
.
trie
=
stateManager
.
trie
vm
.
trie
=
stateManager
.
trie
vm
.
stateManager
.
checkpoint
()
vm
.
stateManager
.
checkpoint
()
var
web3VM
=
new
Web3VMProvider
()
web3VM
.
setVM
(
vm
)
/*
/*
trigger contextChanged, web3EndpointChanged
trigger contextChanged, web3EndpointChanged
*/
*/
...
@@ -82,7 +89,11 @@ function ExecutionContext () {
...
@@ -82,7 +89,11 @@ function ExecutionContext () {
}
}
this
.
web3
=
function
()
{
this
.
web3
=
function
()
{
return
web3
return
this
.
isVM
()
?
web3VM
:
web3
}
this
.
blankWeb3
=
function
()
{
return
blankWeb3
}
}
this
.
vm
=
function
()
{
this
.
vm
=
function
()
{
...
@@ -150,4 +161,4 @@ function ExecutionContext () {
...
@@ -150,4 +161,4 @@ function ExecutionContext () {
}
}
}
}
module
.
exports
=
ExecutionContext
module
.
exports
=
new
ExecutionContext
()
src/universal-dapp.js
View file @
b9921e63
...
@@ -14,6 +14,7 @@ var txHelper = require('./app/execution/txHelper')
...
@@ -14,6 +14,7 @@ var txHelper = require('./app/execution/txHelper')
var
txExecution
=
require
(
'./app/execution/txExecution'
)
var
txExecution
=
require
(
'./app/execution/txExecution'
)
var
helper
=
require
(
'./lib/helper'
)
var
helper
=
require
(
'./lib/helper'
)
var
modalDialogCustom
=
require
(
'./app/ui/modal-dialog-custom'
)
var
modalDialogCustom
=
require
(
'./app/ui/modal-dialog-custom'
)
var
executionContext
=
require
(
'./execution-context'
)
// copy to copyToClipboard
// copy to copyToClipboard
const
copy
=
require
(
'clipboard-copy'
)
const
copy
=
require
(
'clipboard-copy'
)
...
@@ -95,7 +96,7 @@ var css = csjs`
...
@@ -95,7 +96,7 @@ var css = csjs`
/*
/*
trigger debugRequested
trigger debugRequested
*/
*/
function
UniversalDApp
(
executionContext
,
options
)
{
function
UniversalDApp
(
options
)
{
this
.
event
=
new
EventManager
()
this
.
event
=
new
EventManager
()
var
self
=
this
var
self
=
this
...
@@ -104,13 +105,10 @@ function UniversalDApp (executionContext, options) {
...
@@ -104,13 +105,10 @@ function UniversalDApp (executionContext, options) {
self
.
personalMode
=
self
.
options
.
personalMode
||
false
self
.
personalMode
=
self
.
options
.
personalMode
||
false
self
.
contracts
self
.
contracts
self
.
transactionContextAPI
self
.
transactionContextAPI
self
.
web3
=
executionContext
.
web3
()
executionContext
.
event
.
register
(
'contextChanged'
,
this
,
function
(
context
)
{
self
.
vm
=
executionContext
.
vm
()
self
.
executionContext
=
executionContext
self
.
executionContext
.
event
.
register
(
'contextChanged'
,
this
,
function
(
context
)
{
self
.
reset
(
self
.
contracts
)
self
.
reset
(
self
.
contracts
)
})
})
self
.
txRunner
=
new
TxRunner
(
executionContext
,
{},
{
self
.
txRunner
=
new
TxRunner
({},
{
queueTxs
:
true
,
queueTxs
:
true
,
personalMode
:
this
.
personalMode
personalMode
:
this
.
personalMode
})
})
...
@@ -121,26 +119,26 @@ UniversalDApp.prototype.reset = function (contracts, transactionContextAPI) {
...
@@ -121,26 +119,26 @@ UniversalDApp.prototype.reset = function (contracts, transactionContextAPI) {
this
.
contracts
=
contracts
this
.
contracts
=
contracts
this
.
transactionContextAPI
=
transactionContextAPI
this
.
transactionContextAPI
=
transactionContextAPI
this
.
accounts
=
{}
this
.
accounts
=
{}
if
(
this
.
executionContext
.
isVM
())
{
if
(
executionContext
.
isVM
())
{
this
.
_addAccount
(
'3cd7232cd6f3fc66a57a6bedc1a8ed6c228fff0a327e169c2bcc5e869ed49511'
,
'0x56BC75E2D63100000'
)
this
.
_addAccount
(
'3cd7232cd6f3fc66a57a6bedc1a8ed6c228fff0a327e169c2bcc5e869ed49511'
,
'0x56BC75E2D63100000'
)
this
.
_addAccount
(
'2ac6c190b09897cd8987869cc7b918cfea07ee82038d492abce033c75c1b1d0c'
,
'0x56BC75E2D63100000'
)
this
.
_addAccount
(
'2ac6c190b09897cd8987869cc7b918cfea07ee82038d492abce033c75c1b1d0c'
,
'0x56BC75E2D63100000'
)
this
.
_addAccount
(
'dae9801649ba2d95a21e688b56f77905e5667c44ce868ec83f82e838712a2c7a'
,
'0x56BC75E2D63100000'
)
this
.
_addAccount
(
'dae9801649ba2d95a21e688b56f77905e5667c44ce868ec83f82e838712a2c7a'
,
'0x56BC75E2D63100000'
)
this
.
_addAccount
(
'd74aa6d18aa79a05f3473dd030a97d3305737cbc8337d940344345c1f6b72eea'
,
'0x56BC75E2D63100000'
)
this
.
_addAccount
(
'd74aa6d18aa79a05f3473dd030a97d3305737cbc8337d940344345c1f6b72eea'
,
'0x56BC75E2D63100000'
)
this
.
_addAccount
(
'71975fbf7fe448e004ac7ae54cad0a383c3906055a65468714156a07385e96ce'
,
'0x56BC75E2D63100000'
)
this
.
_addAccount
(
'71975fbf7fe448e004ac7ae54cad0a383c3906055a65468714156a07385e96ce'
,
'0x56BC75E2D63100000'
)
this
.
vm
.
stateManager
.
cache
.
flush
(
function
()
{})
executionContext
.
vm
()
.
stateManager
.
cache
.
flush
(
function
()
{})
}
}
this
.
txRunner
=
new
TxRunner
(
this
.
executionContext
,
this
.
accounts
,
{
this
.
txRunner
=
new
TxRunner
(
this
.
accounts
,
{
queueTxs
:
true
,
queueTxs
:
true
,
personalMode
:
this
.
personalMode
personalMode
:
this
.
personalMode
})
})
}
}
UniversalDApp
.
prototype
.
newAccount
=
function
(
password
,
cb
)
{
UniversalDApp
.
prototype
.
newAccount
=
function
(
password
,
cb
)
{
if
(
!
this
.
executionContext
.
isVM
())
{
if
(
!
executionContext
.
isVM
())
{
if
(
!
this
.
personalMode
)
{
if
(
!
this
.
personalMode
)
{
return
cb
(
'Not running in personal mode'
)
return
cb
(
'Not running in personal mode'
)
}
}
this
.
web3
.
personal
.
newAccount
(
password
,
cb
)
executionContext
.
web3
()
.
personal
.
newAccount
(
password
,
cb
)
}
else
{
}
else
{
var
privateKey
var
privateKey
do
{
do
{
...
@@ -154,7 +152,7 @@ UniversalDApp.prototype.newAccount = function (password, cb) {
...
@@ -154,7 +152,7 @@ UniversalDApp.prototype.newAccount = function (password, cb) {
UniversalDApp
.
prototype
.
_addAccount
=
function
(
privateKey
,
balance
)
{
UniversalDApp
.
prototype
.
_addAccount
=
function
(
privateKey
,
balance
)
{
var
self
=
this
var
self
=
this
if
(
!
self
.
executionContext
.
isVM
())
{
if
(
!
executionContext
.
isVM
())
{
throw
new
Error
(
'_addAccount() cannot be called in non-VM mode'
)
throw
new
Error
(
'_addAccount() cannot be called in non-VM mode'
)
}
}
...
@@ -163,7 +161,7 @@ UniversalDApp.prototype._addAccount = function (privateKey, balance) {
...
@@ -163,7 +161,7 @@ UniversalDApp.prototype._addAccount = function (privateKey, balance) {
var
address
=
ethJSUtil
.
privateToAddress
(
privateKey
)
var
address
=
ethJSUtil
.
privateToAddress
(
privateKey
)
// FIXME: we don't care about the callback, but we should still make this proper
// FIXME: we don't care about the callback, but we should still make this proper
self
.
vm
.
stateManager
.
putAccountBalance
(
address
,
balance
||
'0xf00000000000000001'
,
function
cb
()
{})
executionContext
.
vm
()
.
stateManager
.
putAccountBalance
(
address
,
balance
||
'0xf00000000000000001'
,
function
cb
()
{})
self
.
accounts
[
'0x'
+
address
.
toString
(
'hex'
)]
=
{
privateKey
:
privateKey
,
nonce
:
0
}
self
.
accounts
[
'0x'
+
address
.
toString
(
'hex'
)]
=
{
privateKey
:
privateKey
,
nonce
:
0
}
}
}
}
}
...
@@ -171,13 +169,13 @@ UniversalDApp.prototype._addAccount = function (privateKey, balance) {
...
@@ -171,13 +169,13 @@ UniversalDApp.prototype._addAccount = function (privateKey, balance) {
UniversalDApp
.
prototype
.
getAccounts
=
function
(
cb
)
{
UniversalDApp
.
prototype
.
getAccounts
=
function
(
cb
)
{
var
self
=
this
var
self
=
this
if
(
!
self
.
executionContext
.
isVM
())
{
if
(
!
executionContext
.
isVM
())
{
// Weirdness of web3: listAccounts() is sync, `getListAccounts()` is async
// Weirdness of web3: listAccounts() is sync, `getListAccounts()` is async
// See: https://github.com/ethereum/web3.js/issues/442
// See: https://github.com/ethereum/web3.js/issues/442
if
(
self
.
personalMode
)
{
if
(
self
.
personalMode
)
{
self
.
web3
.
personal
.
getListAccounts
(
cb
)
executionContext
.
web3
()
.
personal
.
getListAccounts
(
cb
)
}
else
{
}
else
{
self
.
web3
.
eth
.
getAccounts
(
cb
)
executionContext
.
web3
()
.
eth
.
getAccounts
(
cb
)
}
}
}
else
{
}
else
{
if
(
!
self
.
accounts
)
{
if
(
!
self
.
accounts
)
{
...
@@ -193,8 +191,8 @@ UniversalDApp.prototype.getBalance = function (address, cb) {
...
@@ -193,8 +191,8 @@ UniversalDApp.prototype.getBalance = function (address, cb) {
address
=
ethJSUtil
.
stripHexPrefix
(
address
)
address
=
ethJSUtil
.
stripHexPrefix
(
address
)
if
(
!
self
.
executionContext
.
isVM
())
{
if
(
!
executionContext
.
isVM
())
{
self
.
web3
.
eth
.
getBalance
(
address
,
function
(
err
,
res
)
{
executionContext
.
web3
()
.
eth
.
getBalance
(
address
,
function
(
err
,
res
)
{
if
(
err
)
{
if
(
err
)
{
cb
(
err
)
cb
(
err
)
}
else
{
}
else
{
...
@@ -206,7 +204,7 @@ UniversalDApp.prototype.getBalance = function (address, cb) {
...
@@ -206,7 +204,7 @@ UniversalDApp.prototype.getBalance = function (address, cb) {
return
cb
(
'No accounts?'
)
return
cb
(
'No accounts?'
)
}
}
self
.
vm
.
stateManager
.
getAccountBalance
(
new
Buffer
(
address
,
'hex'
),
function
(
err
,
res
)
{
executionContext
.
vm
()
.
stateManager
.
getAccountBalance
(
new
Buffer
(
address
,
'hex'
),
function
(
err
,
res
)
{
if
(
err
)
{
if
(
err
)
{
cb
(
'Account not found'
)
cb
(
'Account not found'
)
}
else
{
}
else
{
...
@@ -223,7 +221,7 @@ UniversalDApp.prototype.getBalance = function (address, cb) {
...
@@ -223,7 +221,7 @@ UniversalDApp.prototype.getBalance = function (address, cb) {
UniversalDApp
.
prototype
.
renderInstance
=
function
(
contract
,
address
,
contractName
)
{
UniversalDApp
.
prototype
.
renderInstance
=
function
(
contract
,
address
,
contractName
)
{
function
remove
()
{
$instance
.
remove
()
}
function
remove
()
{
$instance
.
remove
()
}
var
$instance
=
$
(
`<div class="instance
${
css
.
instance
}
"/>`
)
var
$instance
=
$
(
`<div class="instance
${
css
.
instance
}
"/>`
)
var
context
=
this
.
executionContext
.
isVM
()
?
'memory'
:
'blockchain'
var
context
=
executionContext
.
isVM
()
?
'memory'
:
'blockchain'
address
=
(
address
.
slice
(
0
,
2
)
===
'0x'
?
''
:
'0x'
)
+
address
.
toString
(
'hex'
)
address
=
(
address
.
slice
(
0
,
2
)
===
'0x'
?
''
:
'0x'
)
+
address
.
toString
(
'hex'
)
var
shortAddress
=
helper
.
shortenAddress
(
address
)
var
shortAddress
=
helper
.
shortenAddress
(
address
)
...
@@ -306,11 +304,11 @@ UniversalDApp.prototype.getCallButton = function (args) {
...
@@ -306,11 +304,11 @@ UniversalDApp.prototype.getCallButton = function (args) {
})
})
function
call
()
{
function
call
()
{
txFormat
.
buildData
(
args
.
contractAbi
,
self
.
contracts
,
false
,
args
.
funABI
,
inputField
.
val
(),
self
,
self
.
executionContext
,
(
error
,
data
)
=>
{
txFormat
.
buildData
(
args
.
contractAbi
,
self
.
contracts
,
false
,
args
.
funABI
,
inputField
.
val
(),
self
,
(
error
,
data
)
=>
{
if
(
!
error
)
{
if
(
!
error
)
{
txExecution
.
callFunction
(
args
.
address
,
data
,
args
.
funABI
,
self
,
(
error
,
txResult
)
=>
{
txExecution
.
callFunction
(
args
.
address
,
data
,
args
.
funABI
,
self
,
(
error
,
txResult
)
=>
{
if
(
!
error
)
{
if
(
!
error
)
{
var
isVM
=
self
.
executionContext
.
isVM
()
var
isVM
=
executionContext
.
isVM
()
if
(
isVM
)
{
if
(
isVM
)
{
var
vmError
=
txExecution
.
checkVMError
(
txResult
)
var
vmError
=
txExecution
.
checkVMError
(
txResult
)
if
(
vmError
.
error
)
{
if
(
vmError
.
error
)
{
...
@@ -319,7 +317,7 @@ UniversalDApp.prototype.getCallButton = function (args) {
...
@@ -319,7 +317,7 @@ UniversalDApp.prototype.getCallButton = function (args) {
}
}
}
}
if
(
lookupOnly
)
{
if
(
lookupOnly
)
{
txFormat
.
decodeResponse
(
self
.
executionContext
.
isVM
()
?
txResult
.
result
.
vm
.
return
:
ethJSUtil
.
toBuffer
(
txResult
.
result
),
args
.
funABI
,
(
error
,
decoded
)
=>
{
txFormat
.
decodeResponse
(
executionContext
.
isVM
()
?
txResult
.
result
.
vm
.
return
:
ethJSUtil
.
toBuffer
(
txResult
.
result
),
args
.
funABI
,
(
error
,
decoded
)
=>
{
$outputOverride
.
html
(
error
?
'error'
+
error
:
decoded
)
$outputOverride
.
html
(
error
?
'error'
+
error
:
decoded
)
})
})
}
}
...
@@ -429,7 +427,7 @@ UniversalDApp.prototype.runTx = function (args, cb) {
...
@@ -429,7 +427,7 @@ UniversalDApp.prototype.runTx = function (args, cb) {
return
callback
(
'No accounts available'
)
return
callback
(
'No accounts available'
)
}
}
if
(
self
.
executionContext
.
isVM
()
&&
!
self
.
accounts
[
ret
[
0
]])
{
if
(
executionContext
.
isVM
()
&&
!
self
.
accounts
[
ret
[
0
]])
{
return
callback
(
'Invalid account selected'
)
return
callback
(
'Invalid account selected'
)
}
}
...
...
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