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
ac2ebb20
Commit
ac2ebb20
authored
Jun 26, 2018
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UniversalDApp refactor
parent
a68d6fc5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
35 deletions
+38
-35
app.js
src/app.js
+1
-18
editor-panel.js
src/app/panels/editor-panel.js
+4
-0
universal-dapp.js
src/universal-dapp.js
+33
-17
No files found.
src/app.js
View file @
ac2ebb20
...
...
@@ -374,24 +374,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
// @TODO should put this in runtab
registry
.
put
({
api
:
transactionContextAPI
,
name
:
'transactionContextAPI'
})
var
udapp
=
new
UniversalDApp
({
api
:
{
logMessage
:
(
msg
)
=>
{
self
.
_components
.
editorpanel
.
log
({
type
:
'log'
,
value
:
msg
})
},
logHtmlMessage
:
(
msg
)
=>
{
self
.
_components
.
editorpanel
.
log
({
type
:
'html'
,
value
:
msg
})
},
config
:
self
.
_api
.
config
,
detectNetwork
:
(
cb
)
=>
{
executionContext
.
detectNetwork
(
cb
)
},
personalMode
:
()
=>
{
return
self
.
_api
.
config
.
get
(
'settings/personal-mode'
)
}
},
opt
:
{
removable
:
false
,
removable_instances
:
true
}
})
var
udapp
=
new
UniversalDApp
({
removable
:
false
,
removable_instances
:
true
})
registry
.
put
({
api
:
udapp
,
name
:
'udapp'
})
var
udappUI
=
new
UniversalDAppUI
(
udapp
)
...
...
src/app/panels/editor-panel.js
View file @
ac2ebb20
...
...
@@ -100,6 +100,10 @@ class EditorPanel {
var
self
=
this
self
.
log
({
type
:
'log'
,
value
:
msg
})
}
logHtmlMessage
(
msg
)
{
var
self
=
this
self
.
log
({
type
:
'html'
,
value
:
msg
})
}
render
()
{
var
self
=
this
if
(
self
.
_view
.
el
)
return
self
.
_view
.
el
...
...
src/universal-dapp.js
View file @
ac2ebb20
...
...
@@ -15,6 +15,7 @@ var txHelper = remixLib.execution.txHelper
var
executionContext
=
require
(
'./execution-context'
)
var
modalCustom
=
require
(
'./app/ui/modal-dialog-custom'
)
var
uiUtil
=
require
(
'./app/ui/util'
)
var
globalRegistry
=
require
(
'./global/registry'
)
var
modalDialog
=
require
(
'./app/ui/modaldialog'
)
var
typeConversion
=
remixLib
.
execution
.
typeConversion
...
...
@@ -23,20 +24,35 @@ var confirmDialog = require('./app/execution/confirmDialog')
/*
trigger debugRequested
*/
function
UniversalDApp
(
opts
=
{}
)
{
function
UniversalDApp
(
opts
,
localRegistry
)
{
this
.
event
=
new
EventManager
()
var
self
=
this
self
.
_api
=
opts
.
api
self
.
removable
=
opts
.
opt
.
removable
self
.
removable_instances
=
opts
.
opt
.
removable_instances
self
.
_components
=
{}
self
.
_components
.
registry
=
localRegistry
||
globalRegistry
self
.
removable
=
opts
.
removable
self
.
removable_instances
=
opts
.
removable_instances
self
.
_deps
=
{
config
:
self
.
_components
.
registry
.
get
(
'config'
).
api
}
executionContext
.
event
.
register
(
'contextChanged'
,
this
,
function
(
context
)
{
self
.
reset
(
self
.
contracts
)
})
self
.
txRunner
=
new
TxRunner
({},
opts
.
api
)
self
.
_txRunnerAPI
=
{
config
:
self
.
_deps
.
config
,
detectNetwork
:
(
cb
)
=>
{
executionContext
.
detectNetwork
(
cb
)
},
personalMode
:
()
=>
{
return
self
.
_deps
.
config
.
get
(
'settings/personal-mode'
)
}
}
self
.
txRunner
=
new
TxRunner
({},
self
.
_txRunnerAPI
)
}
UniversalDApp
.
prototype
.
reset
=
function
(
contracts
,
transactionContextAPI
)
{
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
...
...
@@ -50,12 +66,12 @@ UniversalDApp.prototype.reset = function (contracts, transactionContextAPI) {
this
.
_addAccount
(
'71975fbf7fe448e004ac7ae54cad0a383c3906055a65468714156a07385e96ce'
,
'0x56BC75E2D63100000'
)
executionContext
.
vm
().
stateManager
.
cache
.
flush
(
function
()
{})
}
this
.
txRunner
=
new
TxRunner
(
this
.
accounts
,
this
.
_
api
)
this
.
txRunner
=
new
TxRunner
(
this
.
accounts
,
this
.
_
txRunnerAPI
)
this
.
txRunner
.
event
.
register
(
'transactionBroadcasted'
,
(
txhash
)
=>
{
this
.
_api
.
detectNetwork
((
error
,
network
)
=>
{
executionContext
.
detectNetwork
((
error
,
network
)
=>
{
if
(
!
error
&&
network
)
{
var
txLink
=
executionContext
.
txDetailsLink
(
network
.
name
,
txhash
)
if
(
txLink
)
this
.
_
api
.
logHtmlMessage
(
yo
`<a href="
${
txLink
}
" target="_blank">
${
txLink
}
</a>`
)
if
(
txLink
)
this
.
_
deps
.
editorpanel
.
logHtmlMessage
(
yo
`<a href="
${
txLink
}
" target="_blank">
${
txLink
}
</a>`
)
}
})
})
...
...
@@ -63,7 +79,7 @@ UniversalDApp.prototype.reset = function (contracts, transactionContextAPI) {
UniversalDApp
.
prototype
.
newAccount
=
function
(
password
,
cb
)
{
if
(
!
executionContext
.
isVM
())
{
if
(
!
this
.
_
api
.
personalMode
(
))
{
if
(
!
this
.
_
deps
.
config
.
get
(
'settings/personal-mode'
))
{
return
cb
(
'Not running in personal mode'
)
}
modalCustom
.
promptPassphraseCreation
((
error
,
passphrase
)
=>
{
...
...
@@ -106,7 +122,7 @@ UniversalDApp.prototype.getAccounts = function (cb) {
if
(
!
executionContext
.
isVM
())
{
// Weirdness of web3: listAccounts() is sync, `getListAccounts()` is async
// See: https://github.com/ethereum/web3.js/issues/442
if
(
this
.
_
api
.
personalMode
(
))
{
if
(
this
.
_
deps
.
config
.
get
(
'settings/personal-mode'
))
{
executionContext
.
web3
().
personal
.
getListAccounts
(
cb
)
}
else
{
executionContext
.
web3
().
eth
.
getAccounts
(
cb
)
...
...
@@ -177,9 +193,9 @@ UniversalDApp.prototype.call = function (isUserAction, args, value, lookupOnly,
if
(
!
error
)
{
if
(
isUserAction
)
{
if
(
!
args
.
funABI
.
constant
)
{
self
.
_
api
.
logMessage
(
`
${
logMsg
}
pending ... `
)
self
.
_
deps
.
editorpanel
.
logMessage
(
`
${
logMsg
}
pending ... `
)
}
else
{
self
.
_
api
.
logMessage
(
`
${
logMsg
}
`
)
self
.
_
deps
.
editorpanel
.
logMessage
(
`
${
logMsg
}
`
)
}
}
self
.
callFunction
(
args
.
address
,
data
,
args
.
funABI
,
(
error
,
txResult
)
=>
{
...
...
@@ -188,7 +204,7 @@ UniversalDApp.prototype.call = function (isUserAction, args, value, lookupOnly,
if
(
isVM
)
{
var
vmError
=
txExecution
.
checkVMError
(
txResult
)
if
(
vmError
.
error
)
{
self
.
_
api
.
logMessage
(
`
${
logMsg
}
errored:
${
vmError
.
message
}
`
)
self
.
_
deps
.
editorpanel
.
logMessage
(
`
${
logMsg
}
errored:
${
vmError
.
message
}
`
)
return
}
}
...
...
@@ -197,14 +213,14 @@ UniversalDApp.prototype.call = function (isUserAction, args, value, lookupOnly,
outputCb
(
decoded
)
}
}
else
{
self
.
_
api
.
logMessage
(
`
${
logMsg
}
errored:
${
error
}
`
)
self
.
_
deps
.
editorpanel
.
logMessage
(
`
${
logMsg
}
errored:
${
error
}
`
)
}
})
}
else
{
self
.
_
api
.
logMessage
(
`
${
logMsg
}
errored:
${
error
}
`
)
self
.
_
deps
.
editorpanel
.
logMessage
(
`
${
logMsg
}
errored:
${
error
}
`
)
}
},
(
msg
)
=>
{
self
.
_
api
.
logMessage
(
msg
)
self
.
_
deps
.
editorpanel
.
logMessage
(
msg
)
},
(
data
,
runTxCallback
)
=>
{
// called for libraries deployment
self
.
runTx
(
data
,
runTxCallback
)
...
...
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