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
61544ab3
Commit
61544ab3
authored
Jun 02, 2016
by
Alex Beregszaszi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use web3 passed as a constructor option in udapp
parent
8bfd64a7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
9 deletions
+11
-9
renderer.js
src/app/renderer.js
+1
-0
universal-dapp.js
src/universal-dapp.js
+10
-9
No files found.
src/app/renderer.js
View file @
61544ab3
...
...
@@ -101,6 +101,7 @@ function Renderer(web3, editor, compiler, updateFiles) {
var
dapp
=
new
UniversalDApp
(
udappContracts
,
{
vm
:
executionContext
===
'vm'
,
web3
:
executionContext
!==
'vm'
?
web3
:
null
,
removable
:
false
,
getAddress
:
function
(){
return
$
(
'#txorigin'
).
val
();
},
getValue
:
function
(){
...
...
src/universal-dapp.js
View file @
61544ab3
...
...
@@ -5,7 +5,6 @@ var ethJSUtil = require('ethereumjs-util');
var
EthJSTX
=
require
(
'ethereumjs-tx'
);
var
ethJSABI
=
require
(
'ethereumjs-abi'
);
var
EthJSBlock
=
require
(
'ethereumjs-block'
);
var
web3
=
require
(
'./web3-adapter.js'
);
function
UniversalDApp
(
contracts
,
options
)
{
this
.
options
=
options
||
{};
...
...
@@ -22,6 +21,8 @@ function UniversalDApp (contracts, options) {
this
.
addAccount
(
'3cd7232cd6f3fc66a57a6bedc1a8ed6c228fff0a327e169c2bcc5e869ed49511'
);
this
.
addAccount
(
'2ac6c190b09897cd8987869cc7b918cfea07ee82038d492abce033c75c1b1d0c'
);
}
else
if
(
options
.
web3
)
{
this
.
web3
=
options
.
web3
;
}
}
...
...
@@ -39,7 +40,7 @@ UniversalDApp.prototype.addAccount = function (privateKey, balance) {
UniversalDApp
.
prototype
.
getAccounts
=
function
(
cb
)
{
if
(
!
this
.
vm
)
{
web3
.
eth
.
getAccounts
(
cb
);
this
.
web3
.
eth
.
getAccounts
(
cb
);
}
else
{
if
(
!
this
.
accounts
)
return
cb
(
"No accounts?"
);
...
...
@@ -51,7 +52,7 @@ UniversalDApp.prototype.getBalance = function (address, cb) {
address
=
ethJSUtil
.
stripHexPrefix
(
address
);
if
(
!
this
.
vm
)
{
web3
.
eth
.
getBalance
(
address
,
function
(
err
,
res
)
{
this
.
web3
.
eth
.
getBalance
(
address
,
function
(
err
,
res
)
{
if
(
err
)
{
cb
(
err
);
}
else
{
...
...
@@ -159,7 +160,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
if
(
a
.
constant
==
true
)
return
-
1
;
else
return
1
;
});
var
web3contract
=
web3
.
eth
.
contract
(
abi
);
var
web3contract
=
this
.
web3
.
eth
.
contract
(
abi
);
var
funABI
=
this
.
getConstructorInterface
(
abi
);
var
$createInterface
=
$
(
'<div class="createContract"/>'
);
...
...
@@ -442,7 +443,7 @@ UniversalDApp.prototype.getCallButton = function(args) {
}
else
{
function
tryTillResponse
(
txhash
,
done
)
{
web3
.
eth
.
getTransactionReceipt
(
result
,
testResult
);
this
.
web3
.
eth
.
getTransactionReceipt
(
result
,
testResult
);
function
testResult
(
err
,
address
)
{
if
(
!
err
&&
!
address
)
{
...
...
@@ -556,18 +557,18 @@ UniversalDApp.prototype.runTx = function( data, args, cb) {
var
tx
;
if
(
!
this
.
vm
)
{
tx
=
{
from
:
self
.
options
.
getAddress
?
self
.
options
.
getAddress
()
:
web3
.
eth
.
accounts
[
0
],
from
:
self
.
options
.
getAddress
?
self
.
options
.
getAddress
()
:
this
.
web3
.
eth
.
accounts
[
0
],
to
:
to
,
data
:
data
,
gas
:
gas
,
value
:
value
};
if
(
constant
&&
!
isConstructor
)
{
web3
.
eth
.
call
(
tx
,
cb
);
this
.
web3
.
eth
.
call
(
tx
,
cb
);
}
else
{
web3
.
eth
.
estimateGas
(
tx
,
function
(
err
,
resp
){
this
.
web3
.
eth
.
estimateGas
(
tx
,
function
(
err
,
resp
){
tx
.
gas
=
resp
;
if
(
!
err
)
web3
.
eth
.
sendTransaction
(
tx
,
cb
);
if
(
!
err
)
self
.
web3
.
eth
.
sendTransaction
(
tx
,
cb
);
else
cb
(
err
,
resp
);
});
}
...
...
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