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
874eb299
Commit
874eb299
authored
Dec 26, 2018
by
Iuri Matias
Committed by
yann300
Jan 04, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup settings
parent
6a8c58cd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
27 deletions
+23
-27
settings.js
src/app/tabs/runTab/settings.js
+23
-27
No files found.
src/app/tabs/runTab/settings.js
View file @
874eb299
...
@@ -181,15 +181,23 @@ class SettingsUI {
...
@@ -181,15 +181,23 @@ class SettingsUI {
},
()
=>
{})
},
()
=>
{})
},
},
(
error
,
address
)
=>
{
(
error
,
address
)
=>
{
if
(
!
error
)
{
if
(
error
)
{
addTooltip
(
`account
${
address
}
created`
)
return
addTooltip
(
'Cannot create an account: '
+
error
)
}
else
{
addTooltip
(
'Cannot create an account: '
+
error
)
}
}
addTooltip
(
`account
${
address
}
created`
)
}
}
)
)
}
}
alertSignedData
(
error
,
hash
,
signedData
)
{
if
(
error
&&
error
.
message
!==
''
)
{
console
.
log
(
error
)
addTooltip
(
error
.
message
)
}
else
{
modalDialogCustom
.
alert
(
yo
`<div><b>hash:</b>
${
hash
}
<br><b>signature:</b>
${
signedData
}
</div>`
)
}
}
signMessage
(
event
)
{
signMessage
(
event
)
{
this
.
parentSelf
.
_deps
.
udapp
.
getAccounts
((
err
,
accounts
)
=>
{
this
.
parentSelf
.
_deps
.
udapp
.
getAccounts
((
err
,
accounts
)
=>
{
if
(
err
)
{
addTooltip
(
`Cannot get account list:
${
err
}
`
)
}
if
(
err
)
{
addTooltip
(
`Cannot get account list:
${
err
}
`
)
}
...
@@ -198,14 +206,6 @@ class SettingsUI {
...
@@ -198,14 +206,6 @@ class SettingsUI {
var
account
=
$txOrigin
.
selectedOptions
[
0
].
value
var
account
=
$txOrigin
.
selectedOptions
[
0
].
value
var
isVM
=
executionContext
.
isVM
()
var
isVM
=
executionContext
.
isVM
()
var
isInjected
=
executionContext
.
getProvider
()
===
'injected'
var
isInjected
=
executionContext
.
getProvider
()
===
'injected'
function
alertSignedData
(
error
,
hash
,
signedData
)
{
if
(
error
&&
error
.
message
!==
''
)
{
console
.
log
(
error
)
addTooltip
(
error
.
message
)
}
else
{
modalDialogCustom
.
alert
(
yo
`<div><b>hash:</b>
${
hash
}
<br><b>signature:</b>
${
signedData
}
</div>`
)
}
}
if
(
isVM
)
{
if
(
isVM
)
{
modalDialogCustom
.
promptMulti
(
signMessageDialog
,
(
message
)
=>
{
modalDialogCustom
.
promptMulti
(
signMessageDialog
,
(
message
)
=>
{
const
personalMsg
=
ethJSUtil
.
hashPersonalMessage
(
Buffer
.
from
(
message
))
const
personalMsg
=
ethJSUtil
.
hashPersonalMessage
(
Buffer
.
from
(
message
))
...
@@ -213,7 +213,7 @@ class SettingsUI {
...
@@ -213,7 +213,7 @@ class SettingsUI {
try
{
try
{
var
rsv
=
ethJSUtil
.
ecsign
(
personalMsg
,
privKey
)
var
rsv
=
ethJSUtil
.
ecsign
(
personalMsg
,
privKey
)
var
signedData
=
ethJSUtil
.
toRpcSig
(
rsv
.
v
,
rsv
.
r
,
rsv
.
s
)
var
signedData
=
ethJSUtil
.
toRpcSig
(
rsv
.
v
,
rsv
.
r
,
rsv
.
s
)
alertSignedData
(
null
,
'0x'
+
personalMsg
.
toString
(
'hex'
),
signedData
)
this
.
alertSignedData
(
null
,
'0x'
+
personalMsg
.
toString
(
'hex'
),
signedData
)
}
catch
(
e
)
{
}
catch
(
e
)
{
addTooltip
(
e
.
message
)
addTooltip
(
e
.
message
)
return
return
...
@@ -224,7 +224,7 @@ class SettingsUI {
...
@@ -224,7 +224,7 @@ class SettingsUI {
const
hashedMsg
=
executionContext
.
web3
().
sha3
(
message
)
const
hashedMsg
=
executionContext
.
web3
().
sha3
(
message
)
try
{
try
{
executionContext
.
web3
().
eth
.
sign
(
account
,
hashedMsg
,
(
error
,
signedData
)
=>
{
executionContext
.
web3
().
eth
.
sign
(
account
,
hashedMsg
,
(
error
,
signedData
)
=>
{
alertSignedData
(
error
,
hashedMsg
,
signedData
)
this
.
alertSignedData
(
error
,
hashedMsg
,
signedData
)
})
})
}
catch
(
e
)
{
}
catch
(
e
)
{
addTooltip
(
e
.
message
)
addTooltip
(
e
.
message
)
...
@@ -239,7 +239,7 @@ class SettingsUI {
...
@@ -239,7 +239,7 @@ class SettingsUI {
try
{
try
{
var
personal
=
new
Personal
(
executionContext
.
web3
().
currentProvider
)
var
personal
=
new
Personal
(
executionContext
.
web3
().
currentProvider
)
personal
.
sign
(
hashedMsg
,
account
,
passphrase
,
(
error
,
signedData
)
=>
{
personal
.
sign
(
hashedMsg
,
account
,
passphrase
,
(
error
,
signedData
)
=>
{
alertSignedData
(
error
,
hashedMsg
,
signedData
)
this
.
alertSignedData
(
error
,
hashedMsg
,
signedData
)
})
})
}
catch
(
e
)
{
}
catch
(
e
)
{
addTooltip
(
e
.
message
)
addTooltip
(
e
.
message
)
...
@@ -252,12 +252,11 @@ class SettingsUI {
...
@@ -252,12 +252,11 @@ class SettingsUI {
})
})
}
}
// TODO: cb param doesn't seem to be used
updateNetwork
()
{
updateNetwork
(
cb
)
{
let
self
=
this
let
self
=
this
var
networkcallid
=
0
var
networkcallid
=
0
networkcallid
++
networkcallid
++
(
function
(
callid
)
{
(
(
callid
)
=>
{
executionContext
.
detectNetwork
((
err
,
{
id
,
name
}
=
{})
=>
{
executionContext
.
detectNetwork
((
err
,
{
id
,
name
}
=
{})
=>
{
if
(
networkcallid
>
callid
)
return
if
(
networkcallid
>
callid
)
return
networkcallid
++
networkcallid
++
...
@@ -267,8 +266,6 @@ class SettingsUI {
...
@@ -267,8 +266,6 @@ class SettingsUI {
}
else
{
}
else
{
self
.
netUI
.
innerHTML
=
`<i class="
${
css
.
networkItem
}
fa fa-plug" aria-hidden="true"></i>
${
name
}
(
${
id
||
'-'
}
)`
self
.
netUI
.
innerHTML
=
`<i class="
${
css
.
networkItem
}
fa fa-plug" aria-hidden="true"></i>
${
name
}
(
${
id
||
'-'
}
)`
}
}
// TODO: cb param doesn't seem to be used
if
(
cb
)
cb
(
err
,
{
id
,
name
})
})
})
})(
networkcallid
)
})(
networkcallid
)
}
}
...
@@ -279,7 +276,7 @@ var accountListCallId = 0
...
@@ -279,7 +276,7 @@ var accountListCallId = 0
var
loadedAccounts
=
{}
var
loadedAccounts
=
{}
function
fillAccountsList
(
container
,
self
)
{
function
fillAccountsList
(
container
,
self
)
{
accountListCallId
++
accountListCallId
++
(
function
(
callid
)
{
(
(
callid
)
=>
{
var
txOrigin
=
container
.
querySelector
(
'#txorigin'
)
var
txOrigin
=
container
.
querySelector
(
'#txorigin'
)
self
.
_deps
.
udapp
.
getAccounts
((
err
,
accounts
)
=>
{
self
.
_deps
.
udapp
.
getAccounts
((
err
,
accounts
)
=>
{
if
(
accountListCallId
>
callid
)
return
if
(
accountListCallId
>
callid
)
return
...
@@ -305,12 +302,11 @@ function fillAccountsList (container, self) {
...
@@ -305,12 +302,11 @@ function fillAccountsList (container, self) {
function
updateAccountBalances
(
container
,
self
)
{
function
updateAccountBalances
(
container
,
self
)
{
var
accounts
=
$
(
container
.
querySelector
(
'#txorigin'
)).
children
(
'option'
)
var
accounts
=
$
(
container
.
querySelector
(
'#txorigin'
)).
children
(
'option'
)
accounts
.
each
(
function
(
index
,
value
)
{
accounts
.
each
((
index
,
value
)
=>
{
(
function
(
acc
)
{
((
acc
)
=>
{
self
.
_deps
.
udapp
.
getBalanceInEther
(
accounts
[
acc
].
value
,
function
(
err
,
res
)
{
self
.
_deps
.
udapp
.
getBalanceInEther
(
accounts
[
acc
].
value
,
(
err
,
res
)
=>
{
if
(
!
err
)
{
if
(
err
)
return
accounts
[
acc
].
innerText
=
helper
.
shortenAddress
(
accounts
[
acc
].
value
,
res
)
accounts
[
acc
].
innerText
=
helper
.
shortenAddress
(
accounts
[
acc
].
value
,
res
)
}
})
})
})(
index
)
})(
index
)
})
})
...
...
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