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
aa848acd
Commit
aa848acd
authored
Jul 02, 2018
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move transactionContextAPI to runTab and reset udapp from there
parent
bb6142a3
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
59 deletions
+55
-59
app.js
src/app.js
+5
-36
compile-tab.js
src/app/tabs/compile-tab.js
+0
-8
run-tab.js
src/app/tabs/run-tab.js
+32
-1
universal-dapp-ui.js
src/universal-dapp-ui.js
+0
-3
universal-dapp.js
src/universal-dapp.js
+18
-11
No files found.
src/app.js
View file @
aa848acd
...
@@ -395,48 +395,17 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
...
@@ -395,48 +395,17 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
var
offsetToLineColumnConverter
=
new
OffsetToLineColumnConverter
(
compiler
.
event
)
var
offsetToLineColumnConverter
=
new
OffsetToLineColumnConverter
(
compiler
.
event
)
registry
.
put
({
api
:
offsetToLineColumnConverter
,
name
:
'offsettolinecolumnconverter'
})
registry
.
put
({
api
:
offsetToLineColumnConverter
,
name
:
'offsettolinecolumnconverter'
})
// ----------------- UniversalDApp -----------------
var
transactionContextAPI
=
{
getAddress
:
(
cb
)
=>
{
cb
(
null
,
$
(
'#txorigin'
).
val
())
},
getValue
:
(
cb
)
=>
{
try
{
var
number
=
document
.
querySelector
(
'#value'
).
value
var
select
=
document
.
getElementById
(
'unit'
)
var
index
=
select
.
selectedIndex
var
selectedUnit
=
select
.
querySelectorAll
(
'option'
)[
index
].
dataset
.
unit
var
unit
=
'ether'
// default
if
(
selectedUnit
===
'ether'
)
{
unit
=
'ether'
}
else
if
(
selectedUnit
===
'finney'
)
{
unit
=
'finney'
}
else
if
(
selectedUnit
===
'gwei'
)
{
unit
=
'gwei'
}
else
if
(
selectedUnit
===
'wei'
)
{
unit
=
'wei'
}
cb
(
null
,
executionContext
.
web3
().
toWei
(
number
,
unit
))
}
catch
(
e
)
{
cb
(
e
)
}
},
getGasLimit
:
(
cb
)
=>
{
cb
(
null
,
$
(
'#gasLimit'
).
val
())
}
}
// @TODO should put this in runtab
registry
.
put
({
api
:
transactionContextAPI
,
name
:
'transactionContextAPI'
})
var
udapp
=
new
UniversalDApp
({
removable
:
false
,
removable_instances
:
true
})
// ----------------- UniversalDApp -----------------
var
udapp
=
new
UniversalDApp
({
removable
:
false
,
removable_instances
:
true
})
registry
.
put
({
api
:
udapp
,
name
:
'udapp'
})
registry
.
put
({
api
:
udapp
,
name
:
'udapp'
})
var
udappUI
=
new
UniversalDAppUI
(
udapp
)
var
udappUI
=
new
UniversalDAppUI
(
udapp
)
registry
.
put
({
api
:
udappUI
,
name
:
'udappUI'
})
registry
.
put
({
api
:
udappUI
,
name
:
'udappUI'
})
udapp
.
reset
({})
udappUI
.
reset
()
// ----------------- Tx listener -----------------
// ----------------- Tx listener -----------------
var
transactionReceiptResolver
=
new
TransactionReceiptResolver
()
var
transactionReceiptResolver
=
new
TransactionReceiptResolver
()
...
...
src/app/tabs/compile-tab.js
View file @
aa848acd
...
@@ -33,15 +33,11 @@ module.exports = class CompileTab {
...
@@ -33,15 +33,11 @@ module.exports = class CompileTab {
// dependencies
// dependencies
self
.
_deps
=
{
self
.
_deps
=
{
app
:
self
.
_components
.
registry
.
get
(
'app'
).
api
,
app
:
self
.
_components
.
registry
.
get
(
'app'
).
api
,
udapp
:
self
.
_components
.
registry
.
get
(
'udapp'
).
api
,
udappUI
:
self
.
_components
.
registry
.
get
(
'udappUI'
).
api
,
editor
:
self
.
_components
.
registry
.
get
(
'editor'
).
api
,
editor
:
self
.
_components
.
registry
.
get
(
'editor'
).
api
,
config
:
self
.
_components
.
registry
.
get
(
'config'
).
api
,
config
:
self
.
_components
.
registry
.
get
(
'config'
).
api
,
compiler
:
self
.
_components
.
registry
.
get
(
'compiler'
).
api
,
compiler
:
self
.
_components
.
registry
.
get
(
'compiler'
).
api
,
staticAnalysis
:
self
.
_components
.
registry
.
get
(
'staticanalysis'
).
api
,
staticAnalysis
:
self
.
_components
.
registry
.
get
(
'staticanalysis'
).
api
,
renderer
:
self
.
_components
.
registry
.
get
(
'renderer'
).
api
,
renderer
:
self
.
_components
.
registry
.
get
(
'renderer'
).
api
,
fileManager
:
self
.
_components
.
registry
.
get
(
'filemanager'
).
api
,
transactionContextAPI
:
self
.
_components
.
registry
.
get
(
'transactionContextAPI'
).
api
,
rightHandPanel
:
self
.
_components
.
registry
.
get
(
'righthandpanel'
).
api
rightHandPanel
:
self
.
_components
.
registry
.
get
(
'righthandpanel'
).
api
}
}
self
.
data
=
{
self
.
data
=
{
...
@@ -113,12 +109,8 @@ module.exports = class CompileTab {
...
@@ -113,12 +109,8 @@ module.exports = class CompileTab {
var
contractName
=
yo
`<option>
${
contract
.
name
}
</option>`
var
contractName
=
yo
`<option>
${
contract
.
name
}
</option>`
self
.
_view
.
contractNames
.
appendChild
(
contractName
)
self
.
_view
.
contractNames
.
appendChild
(
contractName
)
})
})
self
.
_deps
.
udapp
.
reset
(
self
.
data
.
contractsDetails
,
self
.
_deps
.
transactionContextAPI
)
self
.
_deps
.
udappUI
.
reset
()
}
else
{
}
else
{
self
.
_view
.
contractNames
.
setAttribute
(
'disabled'
,
true
)
self
.
_view
.
contractNames
.
setAttribute
(
'disabled'
,
true
)
self
.
_deps
.
udapp
.
reset
({},
self
.
_deps
.
transactionContextAPI
)
self
.
_deps
.
udappUI
.
reset
()
}
}
// hightlight the tab if error
// hightlight the tab if error
if
(
success
)
document
.
querySelector
(
'.compileView'
).
style
.
color
=
''
// @TODO: compileView tab
if
(
success
)
document
.
querySelector
(
'.compileView'
).
style
.
color
=
''
// @TODO: compileView tab
...
...
src/app/tabs/run-tab.js
View file @
aa848acd
...
@@ -19,7 +19,7 @@ var addTooltip = require('../ui/tooltip')
...
@@ -19,7 +19,7 @@ var addTooltip = require('../ui/tooltip')
var
css
=
require
(
'./styles/run-tab-styles'
)
var
css
=
require
(
'./styles/run-tab-styles'
)
var
MultiParamManager
=
require
(
'../../multiParamManager'
)
var
MultiParamManager
=
require
(
'../../multiParamManager'
)
function
runTab
(
localRegistry
)
{
function
runTab
(
opts
,
localRegistry
)
{
/* -------------------------
/* -------------------------
VARIABLES
VARIABLES
--------------------------- */
--------------------------- */
...
@@ -35,6 +35,35 @@ function runTab (localRegistry) {
...
@@ -35,6 +35,35 @@ function runTab (localRegistry) {
}
}
self
.
_components
=
{}
self
.
_components
=
{}
self
.
_components
.
registry
=
localRegistry
||
globlalRegistry
self
.
_components
.
registry
=
localRegistry
||
globlalRegistry
self
.
_components
.
transactionContextAPI
=
{
getAddress
:
(
cb
)
=>
{
cb
(
null
,
$
(
'#txorigin'
).
val
())
},
getValue
:
(
cb
)
=>
{
try
{
var
number
=
document
.
querySelector
(
'#value'
).
value
var
select
=
document
.
getElementById
(
'unit'
)
var
index
=
select
.
selectedIndex
var
selectedUnit
=
select
.
querySelectorAll
(
'option'
)[
index
].
dataset
.
unit
var
unit
=
'ether'
// default
if
(
selectedUnit
===
'ether'
)
{
unit
=
'ether'
}
else
if
(
selectedUnit
===
'finney'
)
{
unit
=
'finney'
}
else
if
(
selectedUnit
===
'gwei'
)
{
unit
=
'gwei'
}
else
if
(
selectedUnit
===
'wei'
)
{
unit
=
'wei'
}
cb
(
null
,
executionContext
.
web3
().
toWei
(
number
,
unit
))
}
catch
(
e
)
{
cb
(
e
)
}
},
getGasLimit
:
(
cb
)
=>
{
cb
(
null
,
$
(
'#gasLimit'
).
val
())
}
}
// dependencies
// dependencies
self
.
_deps
=
{
self
.
_deps
=
{
compiler
:
self
.
_components
.
registry
.
get
(
'compiler'
).
api
,
compiler
:
self
.
_components
.
registry
.
get
(
'compiler'
).
api
,
...
@@ -42,8 +71,10 @@ function runTab (localRegistry) {
...
@@ -42,8 +71,10 @@ function runTab (localRegistry) {
udappUI
:
self
.
_components
.
registry
.
get
(
'udappUI'
).
api
,
udappUI
:
self
.
_components
.
registry
.
get
(
'udappUI'
).
api
,
config
:
self
.
_components
.
registry
.
get
(
'config'
).
api
,
config
:
self
.
_components
.
registry
.
get
(
'config'
).
api
,
fileManager
:
self
.
_components
.
registry
.
get
(
'filemanager'
).
api
,
fileManager
:
self
.
_components
.
registry
.
get
(
'filemanager'
).
api
,
editor
:
self
.
_components
.
registry
.
get
(
'editor'
).
api
,
logCallback
:
self
.
_components
.
registry
.
get
(
'logCallback'
).
api
logCallback
:
self
.
_components
.
registry
.
get
(
'logCallback'
).
api
}
}
self
.
_deps
.
udapp
.
resetAPI
(
self
.
_components
.
transactionContextAPI
)
self
.
_view
.
recorderCount
=
yo
`<span>0</span>`
self
.
_view
.
recorderCount
=
yo
`<span>0</span>`
self
.
_view
.
instanceContainer
=
yo
`<div class="
${
css
.
instanceContainer
}
"></div>`
self
.
_view
.
instanceContainer
=
yo
`<div class="
${
css
.
instanceContainer
}
"></div>`
self
.
_view
.
clearInstanceElement
=
yo
`
self
.
_view
.
clearInstanceElement
=
yo
`
...
...
src/universal-dapp-ui.js
View file @
aa848acd
...
@@ -12,9 +12,6 @@ function UniversalDAppUI (udapp, opts = {}) {
...
@@ -12,9 +12,6 @@ function UniversalDAppUI (udapp, opts = {}) {
this
.
udapp
=
udapp
this
.
udapp
=
udapp
}
}
UniversalDAppUI
.
prototype
.
reset
=
function
()
{
}
UniversalDAppUI
.
prototype
.
renderInstance
=
function
(
contract
,
address
,
contractName
)
{
UniversalDAppUI
.
prototype
.
renderInstance
=
function
(
contract
,
address
,
contractName
)
{
var
noInstances
=
document
.
querySelector
(
'[class^="noInstancesText"]'
)
var
noInstances
=
document
.
querySelector
(
'[class^="noInstancesText"]'
)
if
(
noInstances
)
{
if
(
noInstances
)
{
...
...
src/universal-dapp.js
View file @
aa848acd
...
@@ -24,15 +24,18 @@ var confirmDialog = require('./app/execution/confirmDialog')
...
@@ -24,15 +24,18 @@ var confirmDialog = require('./app/execution/confirmDialog')
function
UniversalDApp
(
opts
,
localRegistry
)
{
function
UniversalDApp
(
opts
,
localRegistry
)
{
this
.
event
=
new
EventManager
()
this
.
event
=
new
EventManager
()
var
self
=
this
var
self
=
this
self
.
data
=
{}
self
.
_components
=
{}
self
.
_components
=
{}
self
.
_components
.
registry
=
localRegistry
||
globalRegistry
self
.
_components
.
registry
=
localRegistry
||
globalRegistry
self
.
removable
=
opts
.
removable
self
.
removable
=
opts
.
removable
self
.
removable_instances
=
opts
.
removable_instances
self
.
removable_instances
=
opts
.
removable_instances
self
.
_deps
=
{
self
.
_deps
=
{
config
:
self
.
_components
.
registry
.
get
(
'config'
).
api
,
compiler
:
self
.
_components
.
registry
.
get
(
'compiler'
).
api
,
logCallback
:
self
.
_components
.
registry
.
get
(
'logCallback'
).
api
logCallback
:
self
.
_components
.
registry
.
get
(
'logCallback'
).
api
}
}
executionContext
.
event
.
register
(
'contextChanged'
,
this
,
function
(
context
)
{
executionContext
.
event
.
register
(
'contextChanged'
,
this
,
function
(
context
)
{
self
.
reset
(
self
.
contracts
)
self
.
reset
Environment
(
)
})
})
self
.
_txRunnerAPI
=
{
self
.
_txRunnerAPI
=
{
config
:
self
.
_deps
.
config
,
config
:
self
.
_deps
.
config
,
...
@@ -44,16 +47,15 @@ function UniversalDApp (opts, localRegistry) {
...
@@ -44,16 +47,15 @@ function UniversalDApp (opts, localRegistry) {
}
}
}
}
self
.
txRunner
=
new
TxRunner
({},
self
.
_txRunnerAPI
)
self
.
txRunner
=
new
TxRunner
({},
self
.
_txRunnerAPI
)
self
.
data
.
contractsDetails
=
{}
self
.
_deps
.
compiler
.
event
.
register
(
'compilationFinished'
,
(
success
,
data
,
source
)
=>
{
self
.
data
.
contractsDetails
=
success
&&
data
?
data
.
contracts
:
{}
})
self
.
accounts
=
{}
self
.
resetEnvironment
()
}
}
UniversalDApp
.
prototype
.
reset
=
function
(
contracts
,
transactionContextAPI
)
{
UniversalDApp
.
prototype
.
resetEnvironment
=
function
()
{
this
.
_deps
.
editorpanel
=
this
.
_components
.
registry
.
get
(
'editorpanel'
)
if
(
this
.
_deps
.
editorpanel
)
this
.
_deps
.
editorpanel
=
this
.
_deps
.
editorpanel
.
api
this
.
contracts
=
contracts
if
(
transactionContextAPI
)
{
this
.
transactionContextAPI
=
transactionContextAPI
}
this
.
accounts
=
{}
this
.
accounts
=
{}
if
(
executionContext
.
isVM
())
{
if
(
executionContext
.
isVM
())
{
this
.
_addAccount
(
'3cd7232cd6f3fc66a57a6bedc1a8ed6c228fff0a327e169c2bcc5e869ed49511'
,
'0x56BC75E2D63100000'
)
this
.
_addAccount
(
'3cd7232cd6f3fc66a57a6bedc1a8ed6c228fff0a327e169c2bcc5e869ed49511'
,
'0x56BC75E2D63100000'
)
...
@@ -68,12 +70,16 @@ UniversalDApp.prototype.reset = function (contracts, transactionContextAPI) {
...
@@ -68,12 +70,16 @@ UniversalDApp.prototype.reset = function (contracts, transactionContextAPI) {
executionContext
.
detectNetwork
((
error
,
network
)
=>
{
executionContext
.
detectNetwork
((
error
,
network
)
=>
{
if
(
!
error
&&
network
)
{
if
(
!
error
&&
network
)
{
var
txLink
=
executionContext
.
txDetailsLink
(
network
.
name
,
txhash
)
var
txLink
=
executionContext
.
txDetailsLink
(
network
.
name
,
txhash
)
if
(
txLink
)
this
.
_deps
.
editorpanel
.
logHtmlMessage
(
yo
`<a href="
${
txLink
}
" target="_blank">
${
txLink
}
</a>`
)
if
(
txLink
)
this
.
_deps
.
logCallback
(
yo
`<a href="
${
txLink
}
" target="_blank">
${
txLink
}
</a>`
)
}
}
})
})
})
})
}
}
UniversalDApp
.
prototype
.
resetAPI
=
function
(
transactionContextAPI
)
{
this
.
transactionContextAPI
=
transactionContextAPI
}
UniversalDApp
.
prototype
.
newAccount
=
function
(
password
,
cb
)
{
UniversalDApp
.
prototype
.
newAccount
=
function
(
password
,
cb
)
{
if
(
!
executionContext
.
isVM
())
{
if
(
!
executionContext
.
isVM
())
{
if
(
!
this
.
_deps
.
config
.
get
(
'settings/personal-mode'
))
{
if
(
!
this
.
_deps
.
config
.
get
(
'settings/personal-mode'
))
{
...
@@ -186,7 +192,8 @@ UniversalDApp.prototype.call = function (isUserAction, args, value, lookupOnly,
...
@@ -186,7 +192,8 @@ UniversalDApp.prototype.call = function (isUserAction, args, value, lookupOnly,
logMsg
=
`call to
${
args
.
contractName
}
.
${(
args
.
funABI
.
name
)
?
args
.
funABI
.
name
:
'(fallback)'
}
`
logMsg
=
`call to
${
args
.
contractName
}
.
${(
args
.
funABI
.
name
)
?
args
.
funABI
.
name
:
'(fallback)'
}
`
}
}
}
}
txFormat
.
buildData
(
args
.
contractName
,
args
.
contractAbi
,
self
.
contracts
,
false
,
args
.
funABI
,
value
,
(
error
,
data
)
=>
{
// contractsDetails is used to resolve libraries
txFormat
.
buildData
(
args
.
contractName
,
args
.
contractAbi
,
self
.
data
.
contractsDetails
,
false
,
args
.
funABI
,
value
,
(
error
,
data
)
=>
{
if
(
!
error
)
{
if
(
!
error
)
{
if
(
isUserAction
)
{
if
(
isUserAction
)
{
if
(
!
args
.
funABI
.
constant
)
{
if
(
!
args
.
funABI
.
constant
)
{
...
...
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