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
d3537b31
Commit
d3537b31
authored
Jun 20, 2017
by
yann300
Committed by
GitHub
Jun 20, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #598 from ethereum/resetValue
Reset value field to 0 after each transaction
parents
2c6d1316
aeda1db5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
109 additions
and
99 deletions
+109
-99
app.js
src/app.js
+90
-77
contract-tab.js
src/app/contract-tab.js
+14
-0
execution-context.js
src/app/execution-context.js
+2
-15
righthand-panel.js
src/app/righthand-panel.js
+1
-6
universal-dapp.js
src/universal-dapp.js
+2
-1
No files found.
src/app.js
View file @
d3537b31
...
@@ -479,20 +479,106 @@ var run = function () {
...
@@ -479,20 +479,106 @@ var run = function () {
}
}
var
renderer
=
new
Renderer
(
rendererAPI
,
compiler
.
event
)
var
renderer
=
new
Renderer
(
rendererAPI
,
compiler
.
event
)
// ------------------------------------------------------------
var
executionContext
=
new
ExecutionContext
()
// ----------------- UniversalDApp -----------------
var
udapp
=
new
UniversalDApp
(
executionContext
,
{
removable
:
false
,
removable_instances
:
true
})
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'
)
}
Object
.
keys
(
metadata
.
sources
).
forEach
(
function
(
fileName
)
{
// find hash
var
hash
try
{
hash
=
metadata
.
sources
[
fileName
].
urls
[
0
].
match
(
'bzzr://(.+)'
)[
1
]
}
catch
(
e
)
{
return
cb
(
'Metadata inconsistency'
)
}
sources
.
push
({
content
:
files
.
get
(
fileName
),
hash
:
hash
})
})
// 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
)
{
alert
(
'Failed to publish metadata: '
+
err
)
}
else
{
alert
(
'Metadata published successfully'
)
}
})
})
// ---------------- Righthand-panel --------------------
// ---------------- Righthand-panel --------------------
var
rhpAPI
=
{
var
rhpAPI
=
{
config
:
config
,
config
:
config
,
onResize
:
onResize
,
onResize
:
onResize
,
reAdjust
:
reAdjust
,
reAdjust
:
reAdjust
,
renderer
:
renderer
warnCompilerLoading
:
(
msg
)
=>
{
renderer
.
clear
()
if
(
msg
)
{
renderer
.
error
(
msg
,
$
(
'#output'
),
{
type
:
'warning'
})
}
},
executionContextChange
:
(
context
)
=>
{
return
executionContext
.
executionContextChange
(
context
)
},
executionContextProvider
:
()
=>
{
return
executionContext
.
getProvider
()
}
}
}
var
rhpEvents
=
{
var
rhpEvents
=
{
compiler
:
compiler
.
event
,
compiler
:
compiler
.
event
,
app
:
self
.
event
app
:
self
.
event
,
udapp
:
udapp
.
event
}
}
var
righthandPanel
=
new
RighthandPanel
(
document
.
body
,
rhpAPI
,
rhpEvents
,
{})
// eslint-disable-line
var
righthandPanel
=
new
RighthandPanel
(
document
.
body
,
rhpAPI
,
rhpEvents
,
{})
// eslint-disable-line
// ------------------------------------------------------------
var
executionContext
=
new
ExecutionContext
()
// ----------------- editor resize ---------------
// ----------------- editor resize ---------------
function
onResize
()
{
function
onResize
()
{
...
@@ -635,79 +721,6 @@ var run = function () {
...
@@ -635,79 +721,6 @@ var run = function () {
transactionDebugger
.
addProvider
(
'web3'
,
executionContext
.
web3
())
transactionDebugger
.
addProvider
(
'web3'
,
executionContext
.
web3
())
transactionDebugger
.
switchProvider
(
executionContext
.
getProvider
())
transactionDebugger
.
switchProvider
(
executionContext
.
getProvider
())
// ----------------- UniversalDApp -----------------
var
udapp
=
new
UniversalDApp
(
executionContext
,
{
removable
:
false
,
removable_instances
:
true
})
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'
)
}
Object
.
keys
(
metadata
.
sources
).
forEach
(
function
(
fileName
)
{
// find hash
var
hash
try
{
hash
=
metadata
.
sources
[
fileName
].
urls
[
0
].
match
(
'bzzr://(.+)'
)[
1
]
}
catch
(
e
)
{
return
cb
(
'Metadata inconsistency'
)
}
sources
.
push
({
content
:
files
.
get
(
fileName
),
hash
:
hash
})
})
// 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
)
{
alert
(
'Failed to publish metadata: '
+
err
)
}
else
{
alert
(
'Metadata published successfully'
)
}
})
})
// ----------------- StaticAnalysis -----------------
// ----------------- StaticAnalysis -----------------
var
staticAnalysisAPI
=
{
var
staticAnalysisAPI
=
{
renderWarning
:
(
label
,
warningContainer
,
type
)
=>
{
renderWarning
:
(
label
,
warningContainer
,
type
)
=>
{
...
...
src/app/contract-tab.js
View file @
d3537b31
...
@@ -107,5 +107,19 @@ function contractTab (container, appAPI, appEvents, opts) {
...
@@ -107,5 +107,19 @@ function contractTab (container, appAPI, appEvents, opts) {
<div id="output" class="
${
css
.
contract
}
"></div>
<div id="output" class="
${
css
.
contract
}
"></div>
</div>
</div>
`
`
appEvents
.
udapp
.
register
(
'transactionExecuted'
,
(
to
,
data
,
lookupOnly
,
txResult
)
=>
{
if
(
!
lookupOnly
)
el
.
querySelector
(
'#value'
).
value
=
'0'
})
/* ---------------------------------------------------------------------------
DROPDOWN
--------------------------------------------------------------------------- */
var
selectExEnv
=
el
.
querySelector
(
'#selectExEnvOptions'
)
selectExEnv
.
addEventListener
(
'change'
,
function
(
event
)
{
if
(
!
appAPI
.
executionContextChange
(
selectExEnv
.
options
[
selectExEnv
.
selectedIndex
].
value
))
{
selectExEnv
.
value
=
appAPI
.
executionContextProvider
()
}
})
selectExEnv
.
value
=
appAPI
.
executionContextProvider
()
container
.
appendChild
(
el
)
container
.
appendChild
(
el
)
}
}
src/app/execution-context.js
View file @
d3537b31
...
@@ -91,10 +91,10 @@ function ExecutionContext () {
...
@@ -91,10 +91,10 @@ function ExecutionContext () {
this
.
setContext
=
function
(
context
,
endPointUrl
)
{
this
.
setContext
=
function
(
context
,
endPointUrl
)
{
executionContext
=
context
executionContext
=
context
executionContextChange
(
context
,
endPointUrl
)
this
.
executionContextChange
(
context
,
endPointUrl
)
}
}
function
executionContextChange
(
context
,
endPointUrl
)
{
this
.
executionContextChange
=
function
(
context
,
endPointUrl
)
{
if
(
context
===
'web3'
&&
!
confirm
(
'Are you sure you want to connect to an ethereum node?'
))
{
if
(
context
===
'web3'
&&
!
confirm
(
'Are you sure you want to connect to an ethereum node?'
))
{
return
false
return
false
}
else
if
(
context
===
'injected'
&&
injectedProvider
===
undefined
)
{
}
else
if
(
context
===
'injected'
&&
injectedProvider
===
undefined
)
{
...
@@ -131,19 +131,6 @@ function ExecutionContext () {
...
@@ -131,19 +131,6 @@ function ExecutionContext () {
}
}
self
.
event
.
trigger
(
'web3EndpointChanged'
)
self
.
event
.
trigger
(
'web3EndpointChanged'
)
}
}
/* ---------------------------------------------------------------------------
DROPDOWN
--------------------------------------------------------------------------- */
var
selectExEnv
=
document
.
querySelector
(
'#selectExEnvOptions'
)
selectExEnv
.
addEventListener
(
'change'
,
function
(
event
)
{
if
(
!
executionContextChange
(
selectExEnv
.
options
[
selectExEnv
.
selectedIndex
].
value
))
{
selectExEnv
.
value
=
executionContext
}
})
selectExEnv
.
value
=
executionContext
}
}
module
.
exports
=
ExecutionContext
module
.
exports
=
ExecutionContext
src/app/righthand-panel.js
View file @
d3537b31
...
@@ -67,12 +67,7 @@ function RighthandPanel (container, appAPI, events, opts) {
...
@@ -67,12 +67,7 @@ function RighthandPanel (container, appAPI, events, opts) {
// ----------------- tabbed menu -----------------
// ----------------- tabbed menu -----------------
var
tabbedMenuAPI
=
{
var
tabbedMenuAPI
=
{
warnCompilerLoading
:
function
(
msg
)
{
warnCompilerLoading
:
appAPI
.
warnCompilerLoading
appAPI
.
renderer
.
clear
()
if
(
msg
)
{
appAPI
.
renderer
.
error
(
msg
,
$
(
'#output'
),
{
type
:
'warning'
})
}
}
}
}
// load tabbed menu component
// load tabbed menu component
var
tabContainer
// @TODO
var
tabContainer
// @TODO
...
...
src/universal-dapp.js
View file @
d3537b31
...
@@ -686,6 +686,7 @@ UniversalDApp.prototype.getCallButton = function (args) {
...
@@ -686,6 +686,7 @@ UniversalDApp.prototype.getCallButton = function (args) {
var
decoded
var
decoded
self
.
runTx
({
to
:
args
.
address
,
data
:
data
,
useCall
:
lookupOnly
},
function
(
err
,
txResult
)
{
self
.
runTx
({
to
:
args
.
address
,
data
:
data
,
useCall
:
lookupOnly
},
function
(
err
,
txResult
)
{
self
.
event
.
trigger
(
'transactionExecuted'
,
[
args
.
address
,
data
,
lookupOnly
,
txResult
])
if
(
!
txResult
)
{
if
(
!
txResult
)
{
replaceOutput
(
$result
,
$
(
'<span/>'
).
text
(
'callback contain no result '
+
err
).
addClass
(
'error'
))
replaceOutput
(
$result
,
$
(
'<span/>'
).
text
(
'callback contain no result '
+
err
).
addClass
(
'error'
))
return
return
...
@@ -865,7 +866,7 @@ UniversalDApp.prototype.runTx = function (args, cb) {
...
@@ -865,7 +866,7 @@ UniversalDApp.prototype.runTx = function (args, cb) {
// query value
// query value
function
(
callback
)
{
function
(
callback
)
{
tx
.
value
=
0
tx
.
value
=
0
if
(
tx
.
useCall
)
return
callback
()
if
(
self
.
transactionContextAPI
.
getValue
)
{
if
(
self
.
transactionContextAPI
.
getValue
)
{
self
.
transactionContextAPI
.
getValue
(
function
(
err
,
ret
)
{
self
.
transactionContextAPI
.
getValue
(
function
(
err
,
ret
)
{
if
(
err
)
{
if
(
err
)
{
...
...
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