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
def263f6
Commit
def263f6
authored
May 24, 2016
by
Alex Beregszaszi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use VM.stateManager.get/putAccountBalance
parent
6731cb5f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
6 deletions
+4
-6
universal-dapp.js
src/universal-dapp.js
+4
-6
No files found.
src/universal-dapp.js
View file @
def263f6
...
...
@@ -39,10 +39,8 @@ UniversalDApp.prototype.addAccount = function (privateKey, balance) {
privateKey
=
new
Buffer
(
privateKey
,
'hex'
)
var
address
=
ethJSUtil
.
privateToAddress
(
privateKey
);
var
account
=
new
EthJSAccount
();
account
.
balance
=
balance
||
'f00000000000000001'
;
this
.
vm
.
stateManager
.
trie
.
put
(
address
,
account
.
serialize
());
// FIXME: we don't care about the callback, but we should still make this proper
this
.
vm
.
stateManager
.
putAccountBalance
(
address
,
balance
||
'f00000000000000001'
,
function
cb
()
{}
);
this
.
accounts
[
'0x'
+
address
.
toString
(
'hex'
)]
=
{
privateKey
:
privateKey
,
nonce
:
0
};
}
...
...
@@ -72,11 +70,11 @@ UniversalDApp.prototype.getBalance = function (address, cb) {
}
else
{
if
(
!
this
.
accounts
)
return
cb
(
"No accounts?"
);
this
.
vm
.
stateManager
.
trie
.
get
(
new
Buffer
(
address
,
'hex'
),
function
(
err
,
res
)
{
this
.
vm
.
stateManager
.
getAccountBalance
(
new
Buffer
(
address
,
'hex'
),
function
(
err
,
res
)
{
if
(
err
)
{
cb
(
"Account not found"
);
}
else
{
cb
(
null
,
new
ethJSUtil
.
BN
(
new
EthJSAccount
(
res
).
toString
(),
16
).
toString
(
10
));
cb
(
null
,
new
ethJSUtil
.
BN
(
res
).
toString
(
10
));
}
});
}
...
...
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