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
72949186
Unverified
Commit
72949186
authored
May 15, 2018
by
yann300
Committed by
GitHub
May 15, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1244 from ethereum/refactor_app.js
Refactor app.js
parents
64b2ec99
bc0a9937
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
48 deletions
+41
-48
app.js
src/app.js
+3
-17
editor.js
src/app/editor/editor.js
+13
-6
compile-tab.js
src/app/tabs/compile-tab.js
+8
-8
run-tab.js
src/app/tabs/run-tab.js
+7
-7
settings-tab.js
src/app/tabs/settings-tab.js
+8
-8
recorder.js
src/recorder.js
+2
-2
No files found.
src/app.js
View file @
72949186
...
@@ -698,28 +698,12 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
...
@@ -698,28 +698,12 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
// ---------------- Righthand-panel --------------------
// ---------------- Righthand-panel --------------------
var
rhpAPI
=
{
var
rhpAPI
=
{
config
:
config
,
setEditorSize
(
delta
)
{
setEditorSize
(
delta
)
{
$
(
'#righthand-panel'
).
css
(
'width'
,
delta
)
$
(
'#righthand-panel'
).
css
(
'width'
,
delta
)
self
.
_view
.
centerpanel
.
style
.
right
=
delta
+
'px'
self
.
_view
.
centerpanel
.
style
.
right
=
delta
+
'px'
document
.
querySelector
(
`.
${
css
.
dragbar2
}
`
).
style
.
right
=
delta
+
'px'
document
.
querySelector
(
`.
${
css
.
dragbar2
}
`
).
style
.
right
=
delta
+
'px'
onResize
()
onResize
()
},
},
getAccounts
:
(
cb
)
=>
{
udapp
.
getAccounts
(
cb
)
},
getSource
:
(
fileName
)
=>
{
return
compiler
.
getSource
(
fileName
)
},
editorContent
:
()
=>
{
return
editor
.
get
(
editor
.
current
())
},
currentFile
:
()
=>
{
return
config
.
get
(
'currentFile'
)
},
visitContracts
:
(
cb
)
=>
{
compiler
.
visitContracts
(
cb
)
},
switchFile
:
function
(
path
)
{
switchFile
:
function
(
path
)
{
fileManager
.
switchFile
(
path
)
fileManager
.
switchFile
(
path
)
},
},
...
@@ -775,7 +759,9 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
...
@@ -775,7 +759,9 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
udapp
:
udapp
,
udapp
:
udapp
,
udappUI
:
udappUI
,
udappUI
:
udappUI
,
compiler
:
compiler
,
compiler
:
compiler
,
renderer
:
renderer
renderer
:
renderer
,
editor
:
editor
,
config
:
config
}
}
self
.
_components
.
righthandpanel
=
new
RighthandPanel
(
rhpAPI
,
rhpEvents
,
rhpOpts
)
self
.
_components
.
righthandpanel
=
new
RighthandPanel
(
rhpAPI
,
rhpEvents
,
rhpOpts
)
...
...
src/app/editor/editor.js
View file @
72949186
...
@@ -170,17 +170,25 @@ function Editor (opts = {}) {
...
@@ -170,17 +170,25 @@ function Editor (opts = {}) {
}
}
/**
/**
* returns the content of the specified session @arg path
* returns the content of the current session
* if @arg path is not provided, the content of the current editing session is returned
*
* @return {String} content of the file referenced by @arg path
*/
this
.
currentContent
=
function
()
{
return
this
.
get
(
this
.
current
())
}
/**
* returns the content of the session targeted by @arg path
* if @arg path is null, the content of the current session is returned
*
*
* @param {String} path - path of th file in edition
* @return {String} content of the file referenced by @arg path
* @return {String} content of the file referenced by @arg path
*/
*/
this
.
get
=
function
(
path
)
{
this
.
get
=
function
(
path
)
{
if
(
!
path
||
currentSession
===
path
)
{
if
(
!
path
||
currentSession
===
path
)
{
return
editor
.
getValue
()
return
editor
.
getValue
()
}
else
if
(
sessions
[
path
])
{
}
else
if
(
sessions
[
path
])
{
sessions
[
path
].
getValue
()
return
sessions
[
path
].
getValue
()
}
}
}
}
...
@@ -188,8 +196,7 @@ function Editor (opts = {}) {
...
@@ -188,8 +196,7 @@ function Editor (opts = {}) {
* returns the path of the currently editing file
* returns the path of the currently editing file
* returns `undefined` if no session is being editer
* returns `undefined` if no session is being editer
*
*
* @param {String} path - path of th file in edition
* @return {String} path of the current session
* @return {String} content of the file referenced by @arg path
*/
*/
this
.
current
=
function
()
{
this
.
current
=
function
()
{
if
(
editor
.
getSession
()
===
emptySession
)
{
if
(
editor
.
getSession
()
===
emptySession
)
{
...
...
src/app/tabs/compile-tab.js
View file @
72949186
...
@@ -36,7 +36,7 @@ function compileTab (appAPI = {}, appEvents = {}, opts = {}) {
...
@@ -36,7 +36,7 @@ function compileTab (appAPI = {}, appEvents = {}, opts = {}) {
var
compileTimeout
=
null
var
compileTimeout
=
null
function
scheduleCompilation
()
{
function
scheduleCompilation
()
{
if
(
!
appAPI
.
config
.
get
(
'autoCompile'
))
{
if
(
!
opts
.
config
.
get
(
'autoCompile'
))
{
return
return
}
}
...
@@ -59,16 +59,16 @@ function compileTab (appAPI = {}, appEvents = {}, opts = {}) {
...
@@ -59,16 +59,16 @@ function compileTab (appAPI = {}, appEvents = {}, opts = {}) {
// ----------------- autoCompile -----------------
// ----------------- autoCompile -----------------
var
autoCompileInput
=
compileContainer
.
querySelector
(
'#autoCompile'
)
var
autoCompileInput
=
compileContainer
.
querySelector
(
'#autoCompile'
)
var
autoCompile
=
false
var
autoCompile
=
false
if
(
appAPI
.
config
.
exists
(
'autoCompile'
))
{
if
(
opts
.
config
.
exists
(
'autoCompile'
))
{
autoCompile
=
appAPI
.
config
.
get
(
'autoCompile'
)
autoCompile
=
opts
.
config
.
get
(
'autoCompile'
)
}
}
appAPI
.
config
.
set
(
'autoCompile'
,
autoCompile
)
opts
.
config
.
set
(
'autoCompile'
,
autoCompile
)
if
(
autoCompile
)
{
if
(
autoCompile
)
{
autoCompileInput
.
setAttribute
(
'checked'
,
autoCompile
)
autoCompileInput
.
setAttribute
(
'checked'
,
autoCompile
)
}
}
autoCompileInput
.
addEventListener
(
'change'
,
function
()
{
autoCompileInput
.
addEventListener
(
'change'
,
function
()
{
appAPI
.
config
.
set
(
'autoCompile'
,
autoCompileInput
.
checked
)
opts
.
config
.
set
(
'autoCompile'
,
autoCompileInput
.
checked
)
})
})
// REGISTER EVENTS
// REGISTER EVENTS
...
@@ -156,7 +156,7 @@ function compileTab (appAPI = {}, appEvents = {}, opts = {}) {
...
@@ -156,7 +156,7 @@ function compileTab (appAPI = {}, appEvents = {}, opts = {}) {
}
}
if
(
!
error
)
{
if
(
!
error
)
{
if
(
data
.
contracts
)
{
if
(
data
.
contracts
)
{
appAPI
.
visitContracts
((
contract
)
=>
{
opts
.
compiler
.
visitContracts
((
contract
)
=>
{
opts
.
renderer
.
error
(
contract
.
name
,
$
(
errorContainer
),
{
type
:
'success'
})
opts
.
renderer
.
error
(
contract
.
name
,
$
(
errorContainer
),
{
type
:
'success'
})
})
})
}
}
...
@@ -190,8 +190,8 @@ function compileTab (appAPI = {}, appEvents = {}, opts = {}) {
...
@@ -190,8 +190,8 @@ function compileTab (appAPI = {}, appEvents = {}, opts = {}) {
contractNames
.
innerHTML
=
''
contractNames
.
innerHTML
=
''
if
(
success
)
{
if
(
success
)
{
contractNames
.
removeAttribute
(
'disabled'
)
contractNames
.
removeAttribute
(
'disabled'
)
appAPI
.
visitContracts
((
contract
)
=>
{
opts
.
compiler
.
visitContracts
((
contract
)
=>
{
contractsDetails
[
contract
.
name
]
=
parseContracts
(
contract
.
name
,
contract
.
object
,
appAPI
.
getSource
(
contract
.
file
))
contractsDetails
[
contract
.
name
]
=
parseContracts
(
contract
.
name
,
contract
.
object
,
opts
.
compiler
.
getSource
(
contract
.
file
))
var
contractName
=
yo
`
var
contractName
=
yo
`
<option>
<option>
${
contract
.
name
}
${
contract
.
name
}
...
...
src/app/tabs/run-tab.js
View file @
72949186
...
@@ -187,7 +187,7 @@ function updateAccountBalances (container, appAPI) {
...
@@ -187,7 +187,7 @@ function updateAccountBalances (container, appAPI) {
RECORDER
RECORDER
------------------------------------------------ */
------------------------------------------------ */
function
makeRecorder
(
appAPI
,
appEvents
,
opts
,
self
)
{
function
makeRecorder
(
appAPI
,
appEvents
,
opts
,
self
)
{
var
recorder
=
new
Recorder
(
opts
.
compiler
,
{
var
recorder
=
new
Recorder
(
opts
.
compiler
,
opts
.
udapp
,
{
events
:
{
events
:
{
udapp
:
appEvents
.
udapp
,
udapp
:
appEvents
.
udapp
,
executioncontext
:
executionContext
.
event
,
executioncontext
:
executionContext
.
event
,
...
@@ -240,7 +240,7 @@ function makeRecorder (appAPI, appEvents, opts, self) {
...
@@ -240,7 +240,7 @@ function makeRecorder (appAPI, appEvents, opts, self) {
update account address in scenario.json
update account address in scenario.json
popup if scenario.json not open - "Open a file with transactions you want to replay and click play again"
popup if scenario.json not open - "Open a file with transactions you want to replay and click play again"
*/
*/
var
currentFile
=
appAPI
.
config
.
get
(
'currentFile'
)
var
currentFile
=
opts
.
config
.
get
(
'currentFile'
)
appAPI
.
fileProviderOf
(
currentFile
).
get
(
currentFile
,
(
error
,
json
)
=>
{
appAPI
.
fileProviderOf
(
currentFile
).
get
(
currentFile
,
(
error
,
json
)
=>
{
if
(
error
)
{
if
(
error
)
{
modalDialogCustom
.
alert
(
'Invalid Scenario File '
+
error
)
modalDialogCustom
.
alert
(
'Invalid Scenario File '
+
error
)
...
@@ -319,7 +319,7 @@ function contractDropdown (events, appAPI, appEvents, opts, self) {
...
@@ -319,7 +319,7 @@ function contractDropdown (events, appAPI, appEvents, opts, self) {
${
createPanel
}
${
createPanel
}
<div class="
${
css
.
button
}
">
<div class="
${
css
.
button
}
">
${
atAddressButtonInput
}
${
atAddressButtonInput
}
<div class="
${
css
.
atAddress
}
" onclick=
${
function
()
{
loadFromAddress
(
appAPI
)
}
}>Acc
ess</div>
<div class="
${
css
.
atAddress
}
" onclick=
${
function
()
{
loadFromAddress
(
opts
.
editor
,
opts
.
config
)
}
}>At Addr
ess</div>
</div>
</div>
</div>
</div>
</div>
</div>
...
@@ -384,7 +384,7 @@ function contractDropdown (events, appAPI, appEvents, opts, self) {
...
@@ -384,7 +384,7 @@ function contractDropdown (events, appAPI, appEvents, opts, self) {
}
}
// ACCESS DEPLOYED INSTANCE
// ACCESS DEPLOYED INSTANCE
function
loadFromAddress
(
appAPI
)
{
function
loadFromAddress
(
editor
,
config
)
{
var
noInstancesText
=
self
.
_view
.
noInstancesText
var
noInstancesText
=
self
.
_view
.
noInstancesText
if
(
noInstancesText
.
parentNode
)
{
noInstancesText
.
parentNode
.
removeChild
(
noInstancesText
)
}
if
(
noInstancesText
.
parentNode
)
{
noInstancesText
.
parentNode
.
removeChild
(
noInstancesText
)
}
var
contractNames
=
document
.
querySelector
(
`.
${
css
.
contractNames
.
classNames
[
0
]}
`
)
var
contractNames
=
document
.
querySelector
(
`.
${
css
.
contractNames
.
classNames
[
0
]}
`
)
...
@@ -395,11 +395,11 @@ function contractDropdown (events, appAPI, appEvents, opts, self) {
...
@@ -395,11 +395,11 @@ function contractDropdown (events, appAPI, appEvents, opts, self) {
if
(
/
[
a-f
]
/
.
test
(
address
)
&&
/
[
A-F
]
/
.
test
(
address
)
&&
!
ethJSUtil
.
isValidChecksumAddress
(
address
))
{
if
(
/
[
a-f
]
/
.
test
(
address
)
&&
/
[
A-F
]
/
.
test
(
address
)
&&
!
ethJSUtil
.
isValidChecksumAddress
(
address
))
{
return
modalDialogCustom
.
alert
(
'Invalid checksum address.'
)
return
modalDialogCustom
.
alert
(
'Invalid checksum address.'
)
}
}
if
(
/.
(
.abi
)
$/
.
exec
(
appAPI
.
currentFile
(
)))
{
if
(
/.
(
.abi
)
$/
.
exec
(
config
.
get
(
'currentFile'
)))
{
modalDialogCustom
.
confirm
(
null
,
'Do you really want to interact with '
+
address
+
' using the current ABI definition ?'
,
()
=>
{
modalDialogCustom
.
confirm
(
null
,
'Do you really want to interact with '
+
address
+
' using the current ABI definition ?'
,
()
=>
{
var
abi
var
abi
try
{
try
{
abi
=
JSON
.
parse
(
appAPI
.
editor
Content
())
abi
=
JSON
.
parse
(
editor
.
current
Content
())
}
catch
(
e
)
{
}
catch
(
e
)
{
return
modalDialogCustom
.
alert
(
'Failed to parse the current file as JSON ABI.'
)
return
modalDialogCustom
.
alert
(
'Failed to parse the current file as JSON ABI.'
)
}
}
...
@@ -417,7 +417,7 @@ function contractDropdown (events, appAPI, appEvents, opts, self) {
...
@@ -417,7 +417,7 @@ function contractDropdown (events, appAPI, appEvents, opts, self) {
contractNames
.
innerHTML
=
''
contractNames
.
innerHTML
=
''
if
(
success
)
{
if
(
success
)
{
selectContractNames
.
removeAttribute
(
'disabled'
)
selectContractNames
.
removeAttribute
(
'disabled'
)
appAPI
.
visitContracts
((
contract
)
=>
{
opts
.
compiler
.
visitContracts
((
contract
)
=>
{
contractNames
.
appendChild
(
yo
`<option>
${
contract
.
name
}
</option>`
)
contractNames
.
appendChild
(
yo
`<option>
${
contract
.
name
}
</option>`
)
})
})
}
else
{
}
else
{
...
...
src/app/tabs/settings-tab.js
View file @
72949186
...
@@ -56,16 +56,16 @@ module.exports = class SettingsTab {
...
@@ -56,16 +56,16 @@ module.exports = class SettingsTab {
// Gist settings
// Gist settings
var
gistAccessToken
=
yo
`<input id="gistaccesstoken" type="password">`
var
gistAccessToken
=
yo
`<input id="gistaccesstoken" type="password">`
var
token
=
self
.
_
api
.
config
.
get
(
'settings/gist-access-token'
)
var
token
=
self
.
_
opts
.
config
.
get
(
'settings/gist-access-token'
)
if
(
token
)
gistAccessToken
.
value
=
token
if
(
token
)
gistAccessToken
.
value
=
token
var
gistAddToken
=
yo
`<input class="
${
css
.
savegisttoken
}
" id="savegisttoken" onclick=
${()
=>
{
self
.
_
api
.
config
.
set
(
'settings/gist-access-token'
,
gistAccessToken
.
value
);
tooltip
(
'Access token saved'
)
}}
value
=
"Save"
type
=
"button"
>
`
var
gistAddToken
=
yo
`<input class="
${
css
.
savegisttoken
}
" id="savegisttoken" onclick=
${()
=>
{
self
.
_
opts
.
config
.
set
(
'settings/gist-access-token'
,
gistAccessToken
.
value
);
tooltip
(
'Access token saved'
)
}}
value
=
"Save"
type
=
"button"
>
`
var gistRemoveToken = yo`
<
input
id
=
"removegisttoken"
onclick
=
$
{()
=>
{
gistAccessToken
.
value
=
''
;
self
.
_
api
.
config
.
set
(
'settings/gist-access-token'
,
''
);
tooltip
(
'Access token removed'
)
}}
value
=
"Remove"
type
=
"button"
>
`
var gistRemoveToken = yo`
<
input
id
=
"removegisttoken"
onclick
=
$
{()
=>
{
gistAccessToken
.
value
=
''
;
self
.
_
opts
.
config
.
set
(
'settings/gist-access-token'
,
''
);
tooltip
(
'Access token removed'
)
}}
value
=
"Remove"
type
=
"button"
>
`
self._view.gistToken = yo`
<
div
class
=
"${css.checkboxText}"
>
$
{
gistAccessToken
}${
copyToClipboard
(()
=>
self
.
_
api
.
config
.
get
(
'settings/gist-access-token'
))}${
gistAddToken
}${
gistRemoveToken
}
</div>`
self._view.gistToken = yo`
<
div
class
=
"${css.checkboxText}"
>
$
{
gistAccessToken
}${
copyToClipboard
(()
=>
self
.
_
opts
.
config
.
get
(
'settings/gist-access-token'
))}${
gistAddToken
}${
gistRemoveToken
}
</div>`
//
//
self
.
_view
.
optionVM
=
yo
`<input onchange=
${
onchangeOption
}
id="alwaysUseVM" type="checkbox">`
self
.
_view
.
optionVM
=
yo
`<input onchange=
${
onchangeOption
}
id="alwaysUseVM" type="checkbox">`
if
(
self
.
_
api
.
config
.
get
(
'settings/always-use-vm'
))
self
.
_view
.
optionVM
.
setAttribute
(
'checked'
,
''
)
if
(
self
.
_
opts
.
config
.
get
(
'settings/always-use-vm'
))
self
.
_view
.
optionVM
.
setAttribute
(
'checked'
,
''
)
self
.
_view
.
personal
=
yo
`<input onchange=
${
onchangePersonal
}
id="personal" type="checkbox">`
self
.
_view
.
personal
=
yo
`<input onchange=
${
onchangePersonal
}
id="personal" type="checkbox">`
if
(
self
.
_
api
.
config
.
get
(
'settings/personal-mode'
))
self
.
_view
.
personal
.
setAttribute
(
'checked'
,
''
)
if
(
self
.
_
opts
.
config
.
get
(
'settings/personal-mode'
))
self
.
_view
.
personal
.
setAttribute
(
'checked'
,
''
)
self
.
_view
.
optimize
=
yo
`<input onchange=
${
onchangeOptimize
}
id="optimize" type="checkbox">`
self
.
_view
.
optimize
=
yo
`<input onchange=
${
onchangeOptimize
}
id="optimize" type="checkbox">`
if
(
self
.
data
.
optimize
)
self
.
_view
.
optimize
.
setAttribute
(
'checked'
,
''
)
if
(
self
.
data
.
optimize
)
self
.
_view
.
optimize
.
setAttribute
(
'checked'
,
''
)
var
warnText
=
`Transaction sent over Web3 will use the web3.personal API - be sure the endpoint is opened before enabling it.
var
warnText
=
`Transaction sent over Web3 will use the web3.personal API - be sure the endpoint is opened before enabling it.
...
@@ -187,7 +187,7 @@ module.exports = class SettingsTab {
...
@@ -187,7 +187,7 @@ module.exports = class SettingsTab {
${
self
.
_view
.
config
.
localremixd
}
${
self
.
_view
.
config
.
localremixd
}
</div>`
</div>`
function
onchangeOption
(
event
)
{
function
onchangeOption
(
event
)
{
self
.
_
api
.
config
.
set
(
'settings/always-use-vm'
,
!
self
.
_api
.
config
.
get
(
'settings/always-use-vm'
))
self
.
_
opts
.
config
.
set
(
'settings/always-use-vm'
,
!
self
.
_opts
.
config
.
get
(
'settings/always-use-vm'
))
}
}
function
onloadPlugin
(
event
)
{
function
onloadPlugin
(
event
)
{
try
{
try
{
...
@@ -216,7 +216,7 @@ module.exports = class SettingsTab {
...
@@ -216,7 +216,7 @@ module.exports = class SettingsTab {
self
.
_updateVersionSelector
()
self
.
_updateVersionSelector
()
}
}
function
onchangePersonal
(
event
)
{
function
onchangePersonal
(
event
)
{
self
.
_
api
.
config
.
set
(
'settings/personal-mode'
,
!
self
.
_api
.
config
.
get
(
'settings/personal-mode'
))
self
.
_
opts
.
config
.
set
(
'settings/personal-mode'
,
!
self
.
_opts
.
config
.
get
(
'settings/personal-mode'
))
}
}
return
self
.
_view
.
el
return
self
.
_view
.
el
}
}
...
...
src/recorder.js
View file @
72949186
...
@@ -13,7 +13,7 @@ var modal = require('./app/ui/modal-dialog-custom')
...
@@ -13,7 +13,7 @@ var modal = require('./app/ui/modal-dialog-custom')
*
*
*/
*/
class
Recorder
{
class
Recorder
{
constructor
(
compiler
,
opts
=
{})
{
constructor
(
compiler
,
udapp
,
opts
=
{})
{
var
self
=
this
var
self
=
this
self
.
_api
=
opts
.
api
self
.
_api
=
opts
.
api
self
.
event
=
new
EventManager
()
self
.
event
=
new
EventManager
()
...
@@ -61,7 +61,7 @@ class Recorder {
...
@@ -61,7 +61,7 @@ class Recorder {
record
.
name
=
payLoad
.
funAbi
.
name
record
.
name
=
payLoad
.
funAbi
.
name
record
.
type
=
payLoad
.
funAbi
.
type
record
.
type
=
payLoad
.
funAbi
.
type
self
.
_api
.
getAccounts
((
error
,
accounts
)
=>
{
udapp
.
getAccounts
((
error
,
accounts
)
=>
{
if
(
error
)
return
console
.
log
(
error
)
if
(
error
)
return
console
.
log
(
error
)
record
.
from
=
`account{
${
accounts
.
indexOf
(
from
)}
}`
record
.
from
=
`account{
${
accounts
.
indexOf
(
from
)}
}`
self
.
data
.
_usedAccounts
[
record
.
from
]
=
from
self
.
data
.
_usedAccounts
[
record
.
from
]
=
from
...
...
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