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
5b164fc0
Unverified
Commit
5b164fc0
authored
Feb 02, 2018
by
yann300
Committed by
GitHub
Feb 02, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1030 from ethereum/refactor/remove_execution_ui_dependency
remove UI dependency from execution context
parents
06b773ea
5b03403b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
30 deletions
+50
-30
app.js
src/app.js
+16
-1
run-tab.js
src/app/tabs/run-tab.js
+23
-6
execution-context.js
src/execution-context.js
+11
-23
No files found.
src/app.js
View file @
5b164fc0
...
@@ -784,7 +784,22 @@ function run () {
...
@@ -784,7 +784,22 @@ function run () {
runCompiler
()
runCompiler
()
if
(
queryParams
.
get
().
context
)
{
if
(
queryParams
.
get
().
context
)
{
executionContext
.
setContext
(
queryParams
.
get
().
context
,
queryParams
.
get
().
endpointurl
)
let
context
=
queryParams
.
get
().
context
let
endPointUrl
=
queryParams
.
get
().
endPointUrl
executionContext
.
setContext
(
context
,
endPointUrl
,
()
=>
{
modalDialogCustom
.
confirm
(
null
,
'Are you sure you want to connect to an ethereum node?'
,
()
=>
{
if
(
!
endPointUrl
)
{
endPointUrl
=
'http://localhost:8545'
}
modalDialogCustom
.
prompt
(
null
,
'Web3 Provider Endpoint'
,
endPointUrl
,
(
target
)
=>
{
executionContext
.
setProviderFromEndpoint
(
target
,
context
)
},
()
=>
{})
},
()
=>
{})
},
(
alertMsg
)
=>
{
modalDialogCustom
.
alert
(
alertMsg
)
})
}
}
if
(
queryParams
.
get
().
debugtx
)
{
if
(
queryParams
.
get
().
debugtx
)
{
...
...
src/app/tabs/run-tab.js
View file @
5b164fc0
...
@@ -238,13 +238,30 @@ function runTab (container, appAPI, appEvents, opts) {
...
@@ -238,13 +238,30 @@ function runTab (container, appAPI, appEvents, opts) {
// DROPDOWN
// DROPDOWN
var
selectExEnv
=
el
.
querySelector
(
'#selectExEnvOptions'
)
var
selectExEnv
=
el
.
querySelector
(
'#selectExEnvOptions'
)
function
setFinalContext
()
{
// set the final context. Cause it is possible that this is not the one we've originaly selected
selectExEnv
.
value
=
executionContext
.
getProvider
()
fillAccountsList
(
appAPI
,
el
)
events
.
trigger
(
'clearInstance'
,
[])
}
selectExEnv
.
addEventListener
(
'change'
,
function
(
event
)
{
selectExEnv
.
addEventListener
(
'change'
,
function
(
event
)
{
executionContext
.
executionContextChange
(
selectExEnv
.
options
[
selectExEnv
.
selectedIndex
].
value
,
null
,
()
=>
{
let
context
=
selectExEnv
.
options
[
selectExEnv
.
selectedIndex
].
value
// set the final context. Cause it is possible that this is not the one we've originaly selected
executionContext
.
executionContextChange
(
context
,
null
,
()
=>
{
selectExEnv
.
value
=
executionContext
.
getProvider
()
modalDialogCustom
.
confirm
(
null
,
'Are you sure you want to connect to an ethereum node?'
,
()
=>
{
fillAccountsList
(
appAPI
,
el
)
modalDialogCustom
.
prompt
(
null
,
'Web3 Provider Endpoint'
,
'http://localhost:8545'
,
(
target
)
=>
{
events
.
trigger
(
'clearInstance'
,
[])
executionContext
.
setProviderFromEndpoint
(
target
,
context
,
(
alertMsg
)
=>
{
})
if
(
alertMsg
)
{
modalDialogCustom
.
alert
(
alertMsg
)
}
setFinalContext
()
})
},
setFinalContext
)
},
setFinalContext
)
},
(
alertMsg
)
=>
{
modalDialogCustom
.
alert
(
alertMsg
)
},
setFinalContext
)
})
})
selectExEnv
.
value
=
executionContext
.
getProvider
()
selectExEnv
.
value
=
executionContext
.
getProvider
()
fillAccountsList
(
appAPI
,
el
)
fillAccountsList
(
appAPI
,
el
)
...
...
src/execution-context.js
View file @
5b164fc0
...
@@ -8,7 +8,6 @@ var ethUtil = require('ethereumjs-util')
...
@@ -8,7 +8,6 @@ var ethUtil = require('ethereumjs-util')
var
StateManager
=
require
(
'ethereumjs-vm/lib/stateManager'
)
var
StateManager
=
require
(
'ethereumjs-vm/lib/stateManager'
)
var
Web3VMProvider
=
remixLib
.
vm
.
Web3VMProvider
var
Web3VMProvider
=
remixLib
.
vm
.
Web3VMProvider
var
rlp
=
ethUtil
.
rlp
var
rlp
=
ethUtil
.
rlp
var
modalDialogCustom
=
require
(
'./app/ui/modal-dialog-custom'
)
var
injectedProvider
var
injectedProvider
...
@@ -145,23 +144,13 @@ function ExecutionContext () {
...
@@ -145,23 +144,13 @@ function ExecutionContext () {
return
vm
return
vm
}
}
this
.
setContext
=
function
(
context
,
endPointUrl
)
{
this
.
setContext
=
function
(
context
,
endPointUrl
,
confirmCb
,
infoCb
)
{
executionContext
=
context
executionContext
=
context
this
.
executionContextChange
(
context
,
endPointUrl
)
this
.
executionContextChange
(
context
,
endPointUrl
,
confirmCb
,
infoCb
)
}
}
this
.
executionContextChange
=
function
(
context
,
endPointUrl
,
cb
)
{
this
.
executionContextChange
=
function
(
context
,
endPointUrl
,
c
onfirmCb
,
infoCb
,
c
b
)
{
if
(
!
cb
)
cb
=
()
=>
{}
if
(
!
cb
)
cb
=
()
=>
{}
function
runPrompt
()
{
if
(
!
endPointUrl
)
{
endPointUrl
=
'http://localhost:8545'
}
modalDialogCustom
.
prompt
(
null
,
'Web3 Provider Endpoint'
,
endPointUrl
,
(
target
)
=>
{
setProviderFromEndpoint
(
target
,
context
,
cb
)
},
()
=>
{
cb
()
})
}
if
(
context
===
'vm'
)
{
if
(
context
===
'vm'
)
{
executionContext
=
context
executionContext
=
context
...
@@ -169,7 +158,7 @@ function ExecutionContext () {
...
@@ -169,7 +158,7 @@ function ExecutionContext () {
vm
.
stateManager
.
checkpoint
()
vm
.
stateManager
.
checkpoint
()
})
})
self
.
event
.
trigger
(
'contextChanged'
,
[
'vm'
])
self
.
event
.
trigger
(
'contextChanged'
,
[
'vm'
])
cb
()
return
cb
()
}
}
if
(
context
===
'injected'
)
{
if
(
context
===
'injected'
)
{
...
@@ -177,20 +166,18 @@ function ExecutionContext () {
...
@@ -177,20 +166,18 @@ function ExecutionContext () {
var
alertMsg
=
'No injected Web3 provider found. '
var
alertMsg
=
'No injected Web3 provider found. '
alertMsg
+=
'Make sure your provider (e.g. MetaMask) is active and running '
alertMsg
+=
'Make sure your provider (e.g. MetaMask) is active and running '
alertMsg
+=
'(when recently activated you may have to reload the page).'
alertMsg
+=
'(when recently activated you may have to reload the page).'
modalDialogCustom
.
alert
(
alertMsg
)
infoCb
(
alertMsg
)
cb
()
return
cb
()
}
else
{
}
else
{
executionContext
=
context
executionContext
=
context
web3
.
setProvider
(
injectedProvider
)
web3
.
setProvider
(
injectedProvider
)
self
.
event
.
trigger
(
'contextChanged'
,
[
'injected'
])
self
.
event
.
trigger
(
'contextChanged'
,
[
'injected'
])
cb
()
return
cb
()
}
}
}
}
if
(
context
===
'web3'
)
{
if
(
context
===
'web3'
)
{
modalDialogCustom
.
confirm
(
null
,
'Are you sure you want to connect to an ethereum node?'
,
confirmCb
(
cb
)
()
=>
{
runPrompt
(
endPointUrl
)
},
()
=>
{
cb
()
}
)
}
}
}
}
...
@@ -213,6 +200,7 @@ function ExecutionContext () {
...
@@ -213,6 +200,7 @@ function ExecutionContext () {
}
}
},
15000
)
},
15000
)
// TODO: not used here anymore and needs to be moved
function
setProviderFromEndpoint
(
endpoint
,
context
,
cb
)
{
function
setProviderFromEndpoint
(
endpoint
,
context
,
cb
)
{
var
oldProvider
=
web3
.
currentProvider
var
oldProvider
=
web3
.
currentProvider
...
@@ -230,10 +218,10 @@ function ExecutionContext () {
...
@@ -230,10 +218,10 @@ function ExecutionContext () {
web3
.
setProvider
(
oldProvider
)
web3
.
setProvider
(
oldProvider
)
var
alertMsg
=
'Not possible to connect to the Web3 provider. '
var
alertMsg
=
'Not possible to connect to the Web3 provider. '
alertMsg
+=
'Make sure the provider is running and a connection is open (via IPC or RPC).'
alertMsg
+=
'Make sure the provider is running and a connection is open (via IPC or RPC).'
modalDialogCustom
.
alert
(
alertMsg
)
cb
(
alertMsg
)
cb
()
}
}
}
}
this
.
setProviderFromEndpoint
=
setProviderFromEndpoint
}
}
module
.
exports
=
new
ExecutionContext
()
module
.
exports
=
new
ExecutionContext
()
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