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
e3a83e42
Commit
e3a83e42
authored
Aug 08, 2017
by
yann300
Committed by
GitHub
Aug 08, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #664 from ethereum/compileRunTab7
Compile run tab 7 - (app.js)
parents
3b17684e
06115a3f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
119 deletions
+63
-119
app.js
src/app.js
+63
-119
No files found.
src/app.js
View file @
e3a83e42
...
...
@@ -479,23 +479,6 @@ function run () {
var
offsetToLineColumnConverter
=
new
OffsetToLineColumnConverter
(
compiler
.
event
)
// ----------------- Renderer -----------------
var
transactionContextAPI
=
{
getAddress
:
(
cb
)
=>
{
cb
(
null
,
$
(
'#txorigin'
).
val
())
},
getValue
:
(
cb
)
=>
{
try
{
var
comp
=
$
(
'#value'
).
val
().
split
(
' '
)
cb
(
null
,
executionContext
.
web3
().
toWei
(
comp
[
0
],
comp
.
slice
(
1
).
join
(
' '
)))
}
catch
(
e
)
{
cb
(
e
)
}
},
getGasLimit
:
(
cb
)
=>
{
cb
(
null
,
$
(
'#gasLimit'
).
val
())
}
}
var
rendererAPI
=
{
error
:
(
file
,
error
)
=>
{
if
(
file
===
config
.
get
(
'currentFile'
))
{
...
...
@@ -507,124 +490,48 @@ function run () {
switchToFile
(
errFile
)
}
editor
.
gotoLine
(
errLine
,
errCol
)
},
currentCompiledSourceCode
:
()
=>
{
if
(
compiler
.
lastCompilationResult
.
source
)
{
return
compiler
.
lastCompilationResult
.
source
.
sources
[
compiler
.
lastCompilationResult
.
source
.
target
]
}
return
''
},
resetDapp
:
(
udappContracts
,
renderOutputModifier
)
=>
{
udapp
.
reset
(
udappContracts
,
transactionContextAPI
,
renderOutputModifier
)
},
renderDapp
:
()
=>
{
return
udapp
.
render
()
},
getAccounts
:
(
callback
)
=>
{
udapp
.
getAccounts
(
callback
)
},
getBalance
:
(
address
,
callback
)
=>
{
udapp
.
getBalance
(
address
,
(
error
,
balance
)
=>
{
if
(
error
)
{
callback
(
error
)
}
else
{
callback
(
null
,
executionContext
.
web3
().
fromWei
(
balance
,
'ether'
))
}
})
},
currentblockGasLimit
:
()
=>
{
return
executionContext
.
currentblockGasLimit
()
}
}
}
var
renderer
=
new
Renderer
(
rendererAPI
,
compiler
.
event
)
var
renderer
=
new
Renderer
(
rendererAPI
)
// ------------------------------------------------------------
var
executionContext
=
new
ExecutionContext
()
// ----------------- UniversalDApp -----------------
var
transactionContextAPI
=
{
getAddress
:
(
cb
)
=>
{
cb
(
null
,
$
(
'#txorigin'
).
val
())
},
getValue
:
(
cb
)
=>
{
try
{
var
comp
=
$
(
'#value'
).
val
().
split
(
' '
)
cb
(
null
,
executionContext
.
web3
().
toWei
(
comp
[
0
],
comp
.
slice
(
1
).
join
(
' '
)))
}
catch
(
e
)
{
cb
(
e
)
}
},
getGasLimit
:
(
cb
)
=>
{
cb
(
null
,
$
(
'#gasLimit'
).
val
())
}
}
var
udapp
=
new
UniversalDApp
(
executionContext
,
{
removable
:
false
,
removable_instances
:
true
})
udapp
.
reset
({},
transactionContextAPI
)
udapp
.
event
.
register
(
'debugRequested'
,
this
,
function
(
txResult
)
{
startdebugging
(
txResult
.
transactionHash
)
})
function
swarmVerifiedPublish
(
content
,
expectedHash
,
cb
)
{
swarmgw
.
put
(
content
,
function
(
err
,
ret
)
{
if
(
err
)
{
cb
(
err
)
}
else
if
(
ret
!==
expectedHash
)
{
cb
(
'Hash mismatch'
)
}
else
{
cb
()
}
})
}
function
publishOnSwarm
(
contract
,
cb
)
{
// gather list of files to publish
var
sources
=
[]
sources
.
push
({
content
:
contract
.
metadata
,
hash
:
contract
.
metadataHash
})
var
metadata
try
{
metadata
=
JSON
.
parse
(
contract
.
metadata
)
}
catch
(
e
)
{
return
cb
(
e
)
}
if
(
metadata
===
undefined
)
{
return
cb
(
'No metadata'
)
}
async
.
eachSeries
(
Object
.
keys
(
metadata
.
sources
),
function
(
fileName
,
cb
)
{
// find hash
var
hash
try
{
hash
=
metadata
.
sources
[
fileName
].
urls
[
0
].
match
(
'bzzr://(.+)'
)[
1
]
}
catch
(
e
)
{
return
cb
(
'Metadata inconsistency'
)
}
fileProviderOf
(
fileName
).
get
(
fileName
,
(
error
,
content
)
=>
{
if
(
error
)
{
console
.
log
(
error
)
}
else
{
sources
.
push
({
content
:
content
,
hash
:
hash
})
}
cb
()
})
},
function
()
{
// publish the list of sources in order, fail if any failed
async
.
eachSeries
(
sources
,
function
(
item
,
cb
)
{
swarmVerifiedPublish
(
item
.
content
,
item
.
hash
,
cb
)
},
cb
)
})
}
udapp
.
event
.
register
(
'publishContract'
,
this
,
function
(
contract
)
{
publishOnSwarm
(
contract
,
function
(
err
)
{
if
(
err
)
{
modalDialogCustom
.
alert
(
'Failed to publish metadata: '
+
err
)
}
else
{
modalDialogCustom
.
alert
(
'Metadata published successfully'
)
}
})
})
// ---------------- Righthand-panel --------------------
var
rhpAPI
=
{
config
:
config
,
warnCompilerLoading
:
(
msg
)
=>
{
renderer
.
clear
()
if
(
msg
)
renderer
.
error
(
msg
,
$
(
'#output'
),
{
type
:
'warning'
})
setEditorSize
(
delta
)
{
$
(
'#righthand-panel'
).
css
(
'width'
,
delta
)
self
.
_view
.
centerpanel
.
style
.
right
=
delta
+
'px'
document
.
querySelector
(
`.
${
css
.
dragbar2
}
`
).
style
.
right
=
delta
+
'px'
onResize
()
},
executionContextChange
:
(
context
)
=>
{
return
executionContext
.
executionContextChange
(
context
)
...
...
@@ -634,12 +541,49 @@ function run () {
},
packageFiles
:
(
cb
)
=>
{
packageFiles
(
cb
)
},
getContracts
:
()
=>
{
if
(
compiler
.
lastCompilationResult
&&
compiler
.
lastCompilationResult
.
data
)
{
return
compiler
.
lastCompilationResult
.
data
.
contracts
}
return
null
},
udapp
:
()
=>
{
return
udapp
},
executionContext
:
()
=>
{
return
executionContext
},
fileProviderOf
:
(
path
)
=>
{
return
fileProviderOf
(
path
)
},
getBalance
:
(
address
,
callback
)
=>
{
udapp
.
getBalance
(
address
,
(
error
,
balance
)
=>
{
if
(
error
)
{
callback
(
error
)
}
else
{
callback
(
null
,
executionContext
.
web3
().
fromWei
(
balance
,
'ether'
))
}
})
},
compilationMessage
:
(
message
,
container
,
options
)
=>
{
renderer
.
error
(
message
,
container
,
options
)
},
currentCompiledSourceCode
:
()
=>
{
if
(
compiler
.
lastCompilationResult
.
source
)
{
return
compiler
.
lastCompilationResult
.
source
.
sources
[
compiler
.
lastCompilationResult
.
source
.
target
]
}
return
''
},
resetDapp
:
(
contracts
)
=>
{
udapp
.
reset
(
contracts
,
transactionContextAPI
)
}
}
var
rhpEvents
=
{
compiler
:
compiler
.
event
,
app
:
self
.
event
,
udapp
:
udapp
.
event
udapp
:
udapp
.
event
,
editor
:
editor
.
event
}
self
.
_components
.
righthandpanel
=
new
RighthandPanel
(
rhpAPI
,
rhpEvents
,
{})
self
.
_view
.
rightpanel
.
appendChild
(
self
.
_components
.
righthandpanel
.
render
())
...
...
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