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
d9eecd08
Commit
d9eecd08
authored
Jun 04, 2016
by
chriseth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #50 from ethereum/web3-cleanup
Web3 cleanup
parents
c38cb424
f08850dd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
20 deletions
+18
-20
app.js
src/app.js
+1
-2
compiler.js
src/app/compiler.js
+2
-2
renderer.js
src/app/renderer.js
+3
-1
universal-dapp.js
src/universal-dapp.js
+12
-15
No files found.
src/app.js
View file @
d9eecd08
var
$
=
require
(
'jquery'
);
var
$
=
require
(
'jquery'
);
var
web3
=
require
(
'./web3-adapter.js'
);
var
utils
=
require
(
'./app/utils'
);
var
utils
=
require
(
'./app/utils'
);
var
queryParams
=
require
(
'./app/query-params'
);
var
queryParams
=
require
(
'./app/query-params'
);
...
@@ -407,7 +406,7 @@ var run = function() {
...
@@ -407,7 +406,7 @@ var run = function() {
return
$
.
getJSON
(
'https://api.github.com/repos/'
+
root
+
'/contents/'
+
path
,
cb
);
return
$
.
getJSON
(
'https://api.github.com/repos/'
+
root
+
'/contents/'
+
path
,
cb
);
}
}
var
compiler
=
new
Compiler
(
web3
,
editor
,
handleGithubCall
,
$
(
'#output'
),
getHidingRHP
,
updateFiles
);
var
compiler
=
new
Compiler
(
editor
,
handleGithubCall
,
$
(
'#output'
),
getHidingRHP
,
updateFiles
);
function
setVersionText
(
text
)
{
function
setVersionText
(
text
)
{
$
(
'#version'
).
text
(
text
);
$
(
'#version'
).
text
(
text
);
...
...
src/app/compiler.js
View file @
d9eecd08
...
@@ -4,8 +4,8 @@ var Renderer = require('./renderer');
...
@@ -4,8 +4,8 @@ var Renderer = require('./renderer');
var
Base64
=
require
(
'js-base64'
).
Base64
;
var
Base64
=
require
(
'js-base64'
).
Base64
;
function
Compiler
(
web3
,
editor
,
handleGithubCall
,
outputField
,
hidingRHP
,
updateFiles
)
{
function
Compiler
(
editor
,
handleGithubCall
,
outputField
,
hidingRHP
,
updateFiles
)
{
var
renderer
=
new
Renderer
(
web3
,
editor
,
this
,
updateFiles
);
var
renderer
=
new
Renderer
(
editor
,
this
,
updateFiles
);
var
compileJSON
;
var
compileJSON
;
var
compilerAcceptsMultipleFiles
;
var
compilerAcceptsMultipleFiles
;
...
...
src/app/renderer.js
View file @
d9eecd08
var
$
=
require
(
'jquery'
);
var
$
=
require
(
'jquery'
);
var
web3
=
require
(
'../web3-adapter.js'
);
var
UniversalDApp
=
require
(
'../universal-dapp.js'
);
var
UniversalDApp
=
require
(
'../universal-dapp.js'
);
var
utils
=
require
(
'./utils'
);
var
utils
=
require
(
'./utils'
);
function
Renderer
(
web3
,
editor
,
compiler
,
updateFiles
)
{
function
Renderer
(
editor
,
compiler
,
updateFiles
)
{
var
detailsOpen
=
{};
var
detailsOpen
=
{};
var
executionContext
=
'vm'
;
var
executionContext
=
'vm'
;
...
@@ -101,6 +102,7 @@ function Renderer(web3, editor, compiler, updateFiles) {
...
@@ -101,6 +102,7 @@ function Renderer(web3, editor, compiler, updateFiles) {
var
dapp
=
new
UniversalDApp
(
udappContracts
,
{
var
dapp
=
new
UniversalDApp
(
udappContracts
,
{
vm
:
executionContext
===
'vm'
,
vm
:
executionContext
===
'vm'
,
web3
:
executionContext
!==
'vm'
?
web3
:
null
,
removable
:
false
,
removable
:
false
,
getAddress
:
function
(){
return
$
(
'#txorigin'
).
val
();
},
getAddress
:
function
(){
return
$
(
'#txorigin'
).
val
();
},
getValue
:
function
(){
getValue
:
function
(){
...
...
src/universal-dapp.js
View file @
d9eecd08
...
@@ -5,7 +5,6 @@ var ethJSUtil = require('ethereumjs-util');
...
@@ -5,7 +5,6 @@ var ethJSUtil = require('ethereumjs-util');
var
EthJSTX
=
require
(
'ethereumjs-tx'
);
var
EthJSTX
=
require
(
'ethereumjs-tx'
);
var
ethJSABI
=
require
(
'ethereumjs-abi'
);
var
ethJSABI
=
require
(
'ethereumjs-abi'
);
var
EthJSBlock
=
require
(
'ethereumjs-block'
);
var
EthJSBlock
=
require
(
'ethereumjs-block'
);
var
web3
=
require
(
'./web3-adapter.js'
);
function
UniversalDApp
(
contracts
,
options
)
{
function
UniversalDApp
(
contracts
,
options
)
{
this
.
options
=
options
||
{};
this
.
options
=
options
||
{};
...
@@ -22,13 +21,11 @@ function UniversalDApp (contracts, options) {
...
@@ -22,13 +21,11 @@ function UniversalDApp (contracts, options) {
this
.
addAccount
(
'3cd7232cd6f3fc66a57a6bedc1a8ed6c228fff0a327e169c2bcc5e869ed49511'
);
this
.
addAccount
(
'3cd7232cd6f3fc66a57a6bedc1a8ed6c228fff0a327e169c2bcc5e869ed49511'
);
this
.
addAccount
(
'2ac6c190b09897cd8987869cc7b918cfea07ee82038d492abce033c75c1b1d0c'
);
this
.
addAccount
(
'2ac6c190b09897cd8987869cc7b918cfea07ee82038d492abce033c75c1b1d0c'
);
}
else
if
(
!
web3
.
currentProvider
)
{
}
else
if
(
options
.
web3
)
{
var
host
=
options
.
host
||
"localhost"
;
this
.
web3
=
options
.
web3
;
var
port
=
options
.
port
||
"8545"
;
}
else
{
var
rpc_url
=
options
.
getWeb3endpoint
?
options
.
getWeb3endpoint
()
:
(
'http://'
+
host
+
':'
+
port
);
throw
new
Error
(
"Either VM or Web3 mode must be selected"
);
web3
.
setProvider
(
new
web3
.
providers
.
HttpProvider
(
rpc_url
)
);
}
}
}
}
UniversalDApp
.
prototype
.
addAccount
=
function
(
privateKey
,
balance
)
{
UniversalDApp
.
prototype
.
addAccount
=
function
(
privateKey
,
balance
)
{
...
@@ -45,7 +42,7 @@ UniversalDApp.prototype.addAccount = function (privateKey, balance) {
...
@@ -45,7 +42,7 @@ UniversalDApp.prototype.addAccount = function (privateKey, balance) {
UniversalDApp
.
prototype
.
getAccounts
=
function
(
cb
)
{
UniversalDApp
.
prototype
.
getAccounts
=
function
(
cb
)
{
if
(
!
this
.
vm
)
{
if
(
!
this
.
vm
)
{
web3
.
eth
.
getAccounts
(
cb
);
this
.
web3
.
eth
.
getAccounts
(
cb
);
}
else
{
}
else
{
if
(
!
this
.
accounts
)
return
cb
(
"No accounts?"
);
if
(
!
this
.
accounts
)
return
cb
(
"No accounts?"
);
...
@@ -57,7 +54,7 @@ UniversalDApp.prototype.getBalance = function (address, cb) {
...
@@ -57,7 +54,7 @@ UniversalDApp.prototype.getBalance = function (address, cb) {
address
=
ethJSUtil
.
stripHexPrefix
(
address
);
address
=
ethJSUtil
.
stripHexPrefix
(
address
);
if
(
!
this
.
vm
)
{
if
(
!
this
.
vm
)
{
web3
.
eth
.
getBalance
(
address
,
function
(
err
,
res
)
{
this
.
web3
.
eth
.
getBalance
(
address
,
function
(
err
,
res
)
{
if
(
err
)
{
if
(
err
)
{
cb
(
err
);
cb
(
err
);
}
else
{
}
else
{
...
@@ -165,7 +162,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
...
@@ -165,7 +162,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
if
(
a
.
constant
==
true
)
return
-
1
;
if
(
a
.
constant
==
true
)
return
-
1
;
else
return
1
;
else
return
1
;
});
});
var
web3contract
=
web3
.
eth
.
contract
(
abi
);
var
web3contract
=
this
.
web3
.
eth
.
contract
(
abi
);
var
funABI
=
this
.
getConstructorInterface
(
abi
);
var
funABI
=
this
.
getConstructorInterface
(
abi
);
var
$createInterface
=
$
(
'<div class="createContract"/>'
);
var
$createInterface
=
$
(
'<div class="createContract"/>'
);
...
@@ -454,7 +451,7 @@ UniversalDApp.prototype.getCallButton = function(args) {
...
@@ -454,7 +451,7 @@ UniversalDApp.prototype.getCallButton = function(args) {
}
else
{
}
else
{
function
tryTillResponse
(
txhash
,
done
)
{
function
tryTillResponse
(
txhash
,
done
)
{
web3
.
eth
.
getTransactionReceipt
(
result
,
testResult
);
this
.
web3
.
eth
.
getTransactionReceipt
(
result
,
testResult
);
function
testResult
(
err
,
address
)
{
function
testResult
(
err
,
address
)
{
if
(
!
err
&&
!
address
)
{
if
(
!
err
&&
!
address
)
{
...
@@ -568,18 +565,18 @@ UniversalDApp.prototype.runTx = function( data, args, cb) {
...
@@ -568,18 +565,18 @@ UniversalDApp.prototype.runTx = function( data, args, cb) {
var
tx
;
var
tx
;
if
(
!
this
.
vm
)
{
if
(
!
this
.
vm
)
{
tx
=
{
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
,
to
:
to
,
data
:
data
,
data
:
data
,
gas
:
gas
,
gas
:
gas
,
value
:
value
value
:
value
};
};
if
(
constant
&&
!
isConstructor
)
{
if
(
constant
&&
!
isConstructor
)
{
web3
.
eth
.
call
(
tx
,
cb
);
this
.
web3
.
eth
.
call
(
tx
,
cb
);
}
else
{
}
else
{
web3
.
eth
.
estimateGas
(
tx
,
function
(
err
,
resp
){
this
.
web3
.
eth
.
estimateGas
(
tx
,
function
(
err
,
resp
){
tx
.
gas
=
resp
;
tx
.
gas
=
resp
;
if
(
!
err
)
web3
.
eth
.
sendTransaction
(
tx
,
cb
);
if
(
!
err
)
self
.
web3
.
eth
.
sendTransaction
(
tx
,
cb
);
else
cb
(
err
,
resp
);
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