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
93d240df
Commit
93d240df
authored
Apr 26, 2016
by
chriseth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #151 from axic/patch/account-cleanup
Cosmetic cleanup of the account code
parents
2875a5bb
f48306ca
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
17 deletions
+16
-17
app.js
assets/js/app.js
+2
-7
universal-dapp.js
assets/js/universal-dapp.js
+14
-10
No files found.
assets/js/app.js
View file @
93d240df
...
...
@@ -890,11 +890,7 @@ $(document).ready(function() {
}
else
$txOrigin
.
val
(
'unknown'
);
}
if
(
executionContext
===
'vm'
)
{
dapp
.
getAccounts
(
renderAccounts
);
}
else
{
web3
.
eth
.
getAccounts
(
renderAccounts
);
}
dapp
.
getAccounts
(
renderAccounts
);
$contractOutput
.
find
(
'.title'
).
click
(
function
(
ev
){
$
(
this
).
closest
(
'.contract'
).
toggleClass
(
'hide'
);
});
$
(
'#output'
).
append
(
$contractOutput
);
...
...
@@ -994,4 +990,4 @@ $(document).ready(function() {
syncStorage
()
});
\ No newline at end of file
});
assets/js/universal-dapp.js
View file @
93d240df
...
...
@@ -25,22 +25,26 @@ function UniversalDApp (contracts, options) {
}
UniversalDApp
.
prototype
.
addAccount
=
function
(
privateKey
,
balance
)
{
if
(
this
.
accounts
)
{
privateKey
=
new
Buffer
(
privateKey
,
'hex'
)
var
address
=
EthJS
.
Util
.
privateToAddress
(
privateKey
);
if
(
this
.
accounts
)
{
privateKey
=
new
Buffer
(
privateKey
,
'hex'
)
var
address
=
EthJS
.
Util
.
privateToAddress
(
privateKey
);
var
account
=
new
EthJS
.
Account
();
account
.
balance
=
balance
||
'f00000000000000001'
;
this
.
vm
.
stateManager
.
trie
.
put
(
address
,
account
.
serialize
());
var
account
=
new
EthJS
.
Account
();
account
.
balance
=
balance
||
'f00000000000000001'
;
this
.
vm
.
stateManager
.
trie
.
put
(
address
,
account
.
serialize
());
this
.
accounts
[
'0x'
+
address
.
toString
(
'hex'
)]
=
{
privateKey
:
privateKey
,
nonce
:
0
};
}
this
.
accounts
[
'0x'
+
address
.
toString
(
'hex'
)]
=
{
privateKey
:
privateKey
,
nonce
:
0
};
}
};
UniversalDApp
.
prototype
.
getAccounts
=
function
(
cb
)
{
if
(
!
this
.
accounts
)
return
cb
(
"No accounts?"
);
if
(
!
this
.
vm
)
{
web3
.
eth
.
getAccounts
(
cb
);
}
else
{
if
(
!
this
.
accounts
)
return
cb
(
"No accounts?"
);
cb
(
null
,
Object
.
keys
(
this
.
accounts
));
cb
(
null
,
Object
.
keys
(
this
.
accounts
));
}
};
UniversalDApp
.
prototype
.
render
=
function
()
{
...
...
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