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
27c3ee29
Commit
27c3ee29
authored
Oct 09, 2015
by
chriseth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #42 from d11e9/ethvm
Ethvm
parents
083df317
9fdaa698
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
7 deletions
+10
-7
universal-dapp.js
libs/universal-dapp.js
+10
-7
No files found.
libs/universal-dapp.js
View file @
27c3ee29
...
...
@@ -7,19 +7,18 @@ function UniversalDApp (contracts, options) {
if
(
!
options
.
vm
&&
web3
.
currentProvider
)
{
}
else
if
(
options
.
vm
)
{
this
.
stateTrie
=
new
EthVm
.
Trie
();
this
.
vm
=
new
EthVm
.
VM
(
this
.
stateTrie
);
this
.
vm
=
new
EthVm
();
//@todo this does not calculate the gas costs correctly but gets the job done.
this
.
identityCode
=
'return { gasUsed: 1, return: opts.data, exception: 1 };'
;
this
.
identityAddr
=
ethUtil
.
pad
(
new
Buffer
(
'04'
,
'hex'
),
20
)
this
.
vm
.
load
Prec
ompiled
(
this
.
identityAddr
,
this
.
identityCode
);
this
.
vm
.
load
C
ompiled
(
this
.
identityAddr
,
this
.
identityCode
);
this
.
secretKey
=
'3cd7232cd6f3fc66a57a6bedc1a8ed6c228fff0a327e169c2bcc5e869ed49511'
this
.
publicKey
=
'0406cc661590d48ee972944b35ad13ff03c7876eae3fd191e8a2f77311b0a3c6613407b5005e63d7d8d76b89d5f900cde691497688bb281e07a5052ff61edebdc0'
this
.
address
=
ethUtil
.
pubToAddress
(
new
Buffer
(
this
.
publicKey
,
'hex'
));
this
.
account
=
new
EthVm
.
Account
();
this
.
account
=
new
Account
();
this
.
account
.
balance
=
'f00000000000000001'
;
this
.
nonce
=
0
;
this
.
stateT
rie
.
put
(
this
.
address
,
this
.
account
.
serialize
());
this
.
vm
.
stateManager
.
t
rie
.
put
(
this
.
address
,
this
.
account
.
serialize
());
}
else
{
var
host
=
options
.
host
||
"localhost"
;
var
port
=
options
.
port
||
"8545"
;
...
...
@@ -134,7 +133,11 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
});
$events
=
$
(
'<div class="events"/>'
);
if
(
!
self
.
options
.
vm
){
if
(
self
.
options
.
vm
){
self
.
vm
.
on
(
'afterTx'
,
function
(
response
){
// TODO: parse/use reponse.vm.logs
});
}
else
{
var
jsInterface
=
web3
.
eth
.
contract
(
abi
).
at
(
address
)
var
eventFilter
=
jsInterface
.
allEvents
();
eventFilter
.
watch
(
function
(
err
,
response
){
...
...
@@ -404,7 +407,7 @@ UniversalDApp.prototype.runTx = function( data, args, cb) {
}
}
else
{
try
{
var
tx
=
new
EthVm
.
Transaction
({
var
tx
=
new
Tx
({
nonce
:
new
Buffer
([
this
.
nonce
++
]),
//@todo count beyond 255
gasPrice
:
'01'
,
gasLimit
:
'3000000000'
,
//plenty
...
...
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