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
8022b16b
Commit
8022b16b
authored
Feb 02, 2018
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move UI part of executionContext change and set to the caller
parent
06b773ea
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
26 deletions
+54
-26
app.js
src/app.js
+19
-1
run-tab.js
src/app/tabs/run-tab.js
+24
-5
execution-context.js
src/execution-context.js
+11
-20
No files found.
src/app.js
View file @
8022b16b
...
...
@@ -784,7 +784,25 @@ function run () {
runCompiler
()
if
(
queryParams
.
get
().
context
)
{
executionContext
.
setContext
(
queryParams
.
get
().
context
,
queryParams
.
get
().
endpointurl
)
executionContext
.
setContext
(
queryParams
.
get
().
context
,
queryParams
.
get
().
endpointurl
,
()
=>
{
modalDialogCustom
.
confirm
(
null
,
'Are you sure you want to connect to an ethereum node?'
,
()
=>
{
let
context
=
queryParams
.
get
().
context
;
let
endPointUrl
=
queryParams
.
get
().
endPointUrl
;
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
)
{
...
...
src/app/tabs/run-tab.js
View file @
8022b16b
...
...
@@ -238,13 +238,32 @@ function runTab (container, appAPI, appEvents, opts) {
// DROPDOWN
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
)
{
executionContext
.
executionContextChange
(
selectExEnv
.
options
[
selectExEnv
.
selectedIndex
].
value
,
null
,
()
=>
{
// 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'
,
[])
})
modalDialogCustom
.
confirm
(
null
,
'Are you sure you want to connect to an ethereum node?'
,
()
=>
{
let
endPointUrl
=
null
;
let
context
=
selectExEnv
.
options
[
selectExEnv
.
selectedIndex
].
value
;
if
(
!
endPointUrl
)
{
endPointUrl
=
'http://localhost:8545'
}
modalDialogCustom
.
prompt
(
null
,
'Web3 Provider Endpoint'
,
endPointUrl
,
(
target
)
=>
{
executionContext
.
setProviderFromEndpoint
(
target
,
context
,
setFinalContext
)
},
setFinalContext
)
},
setFinalContext
)
},
(
alertMsg
)
=>
{
modalDialogCustom
.
alert
(
alertMsg
)
},
setFinalContext
)
})
selectExEnv
.
value
=
executionContext
.
getProvider
()
fillAccountsList
(
appAPI
,
el
)
...
...
src/execution-context.js
View file @
8022b16b
...
...
@@ -145,23 +145,13 @@ function ExecutionContext () {
return
vm
}
this
.
setContext
=
function
(
context
,
endPointUrl
)
{
this
.
setContext
=
function
(
context
,
endPointUrl
,
confirmCb
,
infoCb
)
{
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
=
()
=>
{}
function
runPrompt
()
{
if
(
!
endPointUrl
)
{
endPointUrl
=
'http://localhost:8545'
}
modalDialogCustom
.
prompt
(
null
,
'Web3 Provider Endpoint'
,
endPointUrl
,
(
target
)
=>
{
setProviderFromEndpoint
(
target
,
context
,
cb
)
},
()
=>
{
cb
()
})
}
if
(
context
===
'vm'
)
{
executionContext
=
context
...
...
@@ -169,7 +159,7 @@ function ExecutionContext () {
vm
.
stateManager
.
checkpoint
()
})
self
.
event
.
trigger
(
'contextChanged'
,
[
'vm'
])
cb
()
return
cb
()
}
if
(
context
===
'injected'
)
{
...
...
@@ -177,20 +167,18 @@ function ExecutionContext () {
var
alertMsg
=
'No injected Web3 provider found. '
alertMsg
+=
'Make sure your provider (e.g. MetaMask) is active and running '
alertMsg
+=
'(when recently activated you may have to reload the page).'
modalDialogCustom
.
alert
(
alertMsg
)
cb
()
infoCb
(
alertMsg
);
return
cb
()
}
else
{
executionContext
=
context
web3
.
setProvider
(
injectedProvider
)
self
.
event
.
trigger
(
'contextChanged'
,
[
'injected'
])
cb
()
return
cb
()
}
}
if
(
context
===
'web3'
)
{
modalDialogCustom
.
confirm
(
null
,
'Are you sure you want to connect to an ethereum node?'
,
()
=>
{
runPrompt
(
endPointUrl
)
},
()
=>
{
cb
()
}
)
confirmCb
(
cb
);
}
}
...
...
@@ -213,7 +201,9 @@ function ExecutionContext () {
}
},
15000
)
// TODO: not used here anymore and needs to be moved
function
setProviderFromEndpoint
(
endpoint
,
context
,
cb
)
{
if
(
!
cb
)
cb
=
()
=>
{}
var
oldProvider
=
web3
.
currentProvider
if
(
endpoint
===
'ipc'
)
{
...
...
@@ -234,6 +224,7 @@ function ExecutionContext () {
cb
()
}
}
this
.
setProviderFromEndpoint
=
setProviderFromEndpoint
;
}
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