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
09690338
Commit
09690338
authored
Jun 08, 2016
by
Alex Beregszaszi
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #68 from ethereum/codestyle-formatting
Codestyle formatting (Part 1)
parents
e382840f
504e6d78
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
87 additions
and
89 deletions
+87
-89
ballot.sol.js
assets/js/ballot.sol.js
+2
-2
background.js
background.js
+5
-6
app.js
src/app.js
+0
-0
compiler-worker.js
src/app/compiler-worker.js
+37
-38
compiler.js
src/app/compiler.js
+14
-14
editor.js
src/app/editor.js
+2
-0
execution-context.js
src/app/execution-context.js
+2
-0
gist-handler.js
src/app/gist-handler.js
+2
-0
query-params.js
src/app/query-params.js
+2
-3
renderer.js
src/app/renderer.js
+15
-18
storage-handler.js
src/app/storage-handler.js
+5
-6
index.js
src/index.js
+1
-2
universal-dapp.js
src/universal-dapp.js
+0
-0
No files found.
assets/js/ballot.sol.js
View file @
09690338
...
...
@@ -22,9 +22,9 @@
* THE SOFTWARE.
*/
var
multi
=
function
(
func
)
{
return
func
.
toString
().
match
(
/
[^]
*
\/\*([^]
*
)\*\/\}
$/
)[
1
];
}
var
multi
=
function
(
func
)
{
return
func
.
toString
().
match
(
/
[^]
*
\/\*([^]
*
)\*\/\}
$/
)[
1
];
};
var
BALLOT_EXAMPLE
=
multi
(
function
(){
/*contract Ballot {
var
BALLOT_EXAMPLE
=
multi
(
function
()
{
/*contract Ballot {
struct Voter {
uint weight;
...
...
background.js
View file @
09690338
chrome
.
browserAction
.
onClicked
.
addListener
(
function
(
tab
)
{
chrome
.
storage
.
sync
.
set
({
'chrome-app-sync'
:
true
});
/* global chrome */
chrome
.
browserAction
.
onClicked
.
addListener
(
function
(
tab
)
{
chrome
.
storage
.
sync
.
set
({
'chrome-app-sync'
:
true
});
chrome
.
tabs
.
create
({
'url'
:
chrome
.
extension
.
getURL
(
'index.html'
)
},
function
(
tab
)
{
chrome
.
tabs
.
create
({
'url'
:
chrome
.
extension
.
getURL
(
'index.html'
)
},
function
(
tab
)
{
// tab opened
});
});
});
src/app.js
View file @
09690338
This diff is collapsed.
Click to expand it.
src/app/compiler-worker.js
View file @
09690338
var
version
=
function
()
{
return
'(loading)'
;
}
var
compileJSON
=
function
()
{
return
''
;
}
var
version
=
function
()
{
return
'(loading)'
;
};
var
compileJSON
=
function
()
{
return
''
;
};
var
missingInputs
=
[];
module
.
exports
=
function
(
self
)
{
self
.
addEventListener
(
'message'
,
function
(
e
)
{
var
data
=
e
.
data
;
switch
(
data
.
cmd
)
{
case
'loadVersion'
:
delete
Module
;
version
=
null
;
compileJSON
=
null
;
self
.
addEventListener
(
'message'
,
function
(
e
)
{
var
data
=
e
.
data
;
switch
(
data
.
cmd
)
{
case
'loadVersion'
:
delete
Module
;
version
=
null
;
compileJSON
=
null
;
importScripts
(
data
.
data
);
version
=
Module
.
cwrap
(
"version"
,
"string"
,
[]);
if
(
'_compileJSONCallback'
in
Module
)
{
compileJSONInternal
=
Module
.
cwrap
(
"compileJSONCallback"
,
"string"
,
[
"string"
,
"number"
,
"number"
]);
var
missingInputCallback
=
Module
.
Runtime
.
addFunction
(
function
(
path
)
{
missingInputs
.
push
(
Module
.
Pointer_stringify
(
path
));
});
compileJSON
=
function
(
input
,
optimize
)
{
return
compileJSONInternal
(
input
,
optimize
,
missingInputCallback
);
};
}
else
if
(
'_compileJSONMulti'
in
Module
)
compileJSON
=
Module
.
cwrap
(
"compileJSONMulti"
,
"string"
,
[
"string"
,
"number"
]);
else
compileJSON
=
Module
.
cwrap
(
"compileJSON"
,
"string"
,
[
"string"
,
"number"
]);
postMessage
({
cmd
:
'versionLoaded'
,
data
:
version
(),
acceptsMultipleFiles
:
(
'_compileJSONMulti'
in
Module
)
});
break
;
case
'compile'
:
missingInputs
.
length
=
0
;
postMessage
({
cmd
:
'compiled'
,
data
:
compileJSON
(
data
.
source
,
data
.
optimize
),
missingInputs
:
missingInputs
});
break
;
}
},
false
);
}
importScripts
(
data
.
data
);
version
=
Module
.
cwrap
(
'version'
,
'string'
,
[]);
if
(
'_compileJSONCallback'
in
Module
)
{
var
compileJSONInternal
=
Module
.
cwrap
(
'compileJSONCallback'
,
'string'
,
[
'string'
,
'number'
,
'number'
]);
var
missingInputCallback
=
Module
.
Runtime
.
addFunction
(
function
(
path
)
{
missingInputs
.
push
(
Module
.
Pointer_stringify
(
path
));
});
compileJSON
=
function
(
input
,
optimize
)
{
return
compileJSONInternal
(
input
,
optimize
,
missingInputCallback
);
};
}
else
if
(
'_compileJSONMulti'
in
Module
)
{
compileJSON
=
Module
.
cwrap
(
'compileJSONMulti'
,
'string'
,
[
'string'
,
'number'
]);
}
else
{
compileJSON
=
Module
.
cwrap
(
'compileJSON'
,
'string'
,
[
'string'
,
'number'
]);
}
postMessage
({
cmd
:
'versionLoaded'
,
data
:
version
(),
acceptsMultipleFiles
:
(
'_compileJSONMulti'
in
Module
)
});
break
;
case
'compile'
:
missingInputs
.
length
=
0
;
postMessage
({
cmd
:
'compiled'
,
data
:
compileJSON
(
data
.
source
,
data
.
optimize
),
missingInputs
:
missingInputs
});
break
;
}
},
false
);
};
src/app/compiler.js
View file @
09690338
...
...
@@ -42,7 +42,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
sourceAnnotations
=
[];
outputField
.
empty
();
var
input
=
editor
.
getValue
();
editor
.
setCacheFileContent
(
input
)
editor
.
setCacheFileContent
(
input
)
;
var
files
=
{};
files
[
editor
.
getCacheFile
()]
=
input
;
...
...
@@ -148,7 +148,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
function
loadInternal
(
url
,
setVersionText
)
{
Module
=
null
;
// Set a safe fallback until the new one is loaded
compileJSON
=
function
(
source
,
optimize
)
{
compilationFinished
(
'{}'
);
};
compileJSON
=
function
(
source
,
optimize
)
{
compilationFinished
(
'{}'
);
};
var
newScript
=
document
.
createElement
(
'script'
);
newScript
.
type
=
'text/javascript'
;
...
...
@@ -171,14 +171,14 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
worker
.
addEventListener
(
'message'
,
function
(
msg
)
{
var
data
=
msg
.
data
;
switch
(
data
.
cmd
)
{
case
'versionLoaded'
:
compilerAcceptsMultipleFiles
=
!!
data
.
acceptsMultipleFiles
;
onCompilerLoaded
(
setVersionText
,
data
.
data
);
break
;
case
'compiled'
:
compilationFinished
(
data
.
data
,
data
.
missingInputs
);
break
;
}
;
case
'versionLoaded'
:
compilerAcceptsMultipleFiles
=
!!
data
.
acceptsMultipleFiles
;
onCompilerLoaded
(
setVersionText
,
data
.
data
);
break
;
case
'compiled'
:
compilationFinished
(
data
.
data
,
data
.
missingInputs
);
break
;
}
});
worker
.
onerror
=
function
(
msg
)
{
console
.
log
(
msg
.
data
);
};
worker
.
addEventListener
(
'error'
,
function
(
msg
)
{
console
.
log
(
msg
.
data
);
});
...
...
@@ -186,7 +186,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
worker
.
postMessage
({
cmd
:
'compile'
,
source
:
source
,
optimize
:
optimize
});
};
worker
.
postMessage
({
cmd
:
'loadVersion'
,
data
:
url
});
}
;
}
function
gatherImports
(
files
,
importHints
,
cb
)
{
importHints
=
importHints
||
[];
...
...
@@ -201,7 +201,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
reloop
=
false
;
for
(
var
fileName
in
files
)
{
var
match
;
while
(
match
=
importRegex
.
exec
(
files
[
fileName
]
))
{
while
(
(
match
=
importRegex
.
exec
(
files
[
fileName
])
))
{
importHints
.
push
(
match
[
1
]);
}
}
...
...
@@ -219,7 +219,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
}
else
if
(
m
in
cachedRemoteFiles
)
{
files
[
m
]
=
cachedRemoteFiles
[
m
];
reloop
=
true
;
}
else
if
(
githubMatch
=
/^
(
https
?
:
\/\/)?(
www.
)?
github.com
\/([^\/]
*
\/[^\/]
*
)\/(
.*
)
/
.
exec
(
m
))
{
}
else
if
(
(
githubMatch
=
/^
(
https
?
:
\/\/)?(
www.
)?
github.com
\/([^\/]
*
\/[^\/]
*
)\/(
.*
)
/
.
exec
(
m
)
))
{
handleGithubCall
(
githubMatch
[
3
],
githubMatch
[
4
],
function
(
result
)
{
if
(
'content'
in
result
)
{
var
content
=
Base64
.
decode
(
result
.
content
);
...
...
@@ -243,4 +243,4 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
}
}
module
.
exports
=
Compiler
module
.
exports
=
Compiler
;
src/app/editor.js
View file @
09690338
/* global BALLOT_EXAMPLE, FileReader */
var
utils
=
require
(
'./utils'
);
var
ace
=
require
(
'brace'
);
...
...
src/app/execution-context.js
View file @
09690338
/* global confirm */
var
$
=
require
(
'jquery'
);
var
Web3
=
require
(
'web3'
);
...
...
src/app/gist-handler.js
View file @
09690338
/* global prompt */
var
queryParams
=
require
(
'./query-params'
);
function
handleLoad
(
cb
)
{
...
...
src/app/query-params.js
View file @
09690338
...
...
@@ -34,5 +34,5 @@ function updateQueryParams (params) {
module
.
exports
=
{
get
:
getQueryParams
,
update
:
updateQueryParams
,
};
\ No newline at end of file
update
:
updateQueryParams
};
src/app/renderer.js
View file @
09690338
...
...
@@ -6,7 +6,6 @@ var utils = require('./utils');
var
ExecutionContext
=
require
(
'./execution-context'
);
function
Renderer
(
editor
,
compiler
,
updateFiles
)
{
var
detailsOpen
=
{};
var
executionContext
=
new
ExecutionContext
(
compiler
);
...
...
@@ -33,7 +32,7 @@ function Renderer (editor, compiler, updateFiles) {
// Switch to file
editor
.
setCacheFile
(
errFile
);
updateFiles
();
// @TODO could show some error icon in files with errors
// @TODO could show some error icon in files with errors
}
editor
.
handleErrorClick
(
errLine
,
errCol
);
});
...
...
@@ -43,7 +42,7 @@ function Renderer (editor, compiler, updateFiles) {
return
false
;
});
}
}
;
}
this
.
error
=
renderError
;
var
combined
=
function
(
contractName
,
jsonInterface
,
bytecode
)
{
...
...
@@ -51,7 +50,6 @@ function Renderer (editor, compiler, updateFiles) {
};
function
renderContracts
(
data
,
source
)
{
var
udappContracts
=
[];
for
(
var
contractName
in
data
.
contracts
)
{
var
contract
=
data
.
contracts
[
contractName
];
...
...
@@ -105,7 +103,7 @@ function Renderer (editor, compiler, updateFiles) {
$contractOutput
.
find
(
'.title'
).
click
(
function
(
ev
)
{
$
(
this
).
closest
(
'.contract'
).
toggleClass
(
'hide'
);
});
$
(
'#output'
).
append
(
$contractOutput
);
$
(
'.col2 input,textarea'
).
click
(
function
()
{
this
.
select
();
});
}
;
}
this
.
contracts
=
renderContracts
;
var
tableRowItems
=
function
(
first
,
second
,
cls
)
{
...
...
@@ -132,8 +130,9 @@ function Renderer (editor, compiler, updateFiles) {
.
append
(
tableRow
(
'Solidity Interface'
,
contract
.
solidity_interface
))
.
append
(
tableRow
(
'Opcodes'
,
contract
.
opcodes
));
var
funHashes
=
''
;
for
(
var
fun
in
contract
.
functionHashes
)
for
(
var
fun
in
contract
.
functionHashes
)
{
funHashes
+=
contract
.
functionHashes
[
fun
]
+
' '
+
fun
+
'
\
n'
;
}
details
.
append
(
$
(
'<span class="col1">Functions</span>'
));
details
.
append
(
$
(
'<pre/>'
).
text
(
funHashes
));
details
.
append
(
$
(
'<span class="col1">Gas Estimates</span>'
));
...
...
@@ -154,7 +153,7 @@ function Renderer (editor, compiler, updateFiles) {
};
var
formatGasEstimates
=
function
(
data
)
{
var
gasToText
=
function
(
g
)
{
return
g
===
null
?
'unknown'
:
g
;
}
var
gasToText
=
function
(
g
)
{
return
g
===
null
?
'unknown'
:
g
;
}
;
var
text
=
''
;
var
fun
;
if
(
'creation'
in
data
)
{
...
...
@@ -217,16 +216,15 @@ function Renderer (editor, compiler, updateFiles) {
});
code
+=
'
\
n {'
+
'
\
n from: web3.eth.accounts[0], '
+
'
\
n data:
\'
'
+
bytecode
+
'
\'
, '
+
'
\
n gas: 3000000'
+
'
\
n }, function (e, contract){'
+
'
\
n console.log(e, contract);'
+
'
\
n if (typeof contract.address !==
\'
undefined
\'
) {'
+
'
\
n console.log(
\'
Contract mined! address:
\'
+ contract.address +
\'
transactionHash:
\'
+ contract.transactionHash);'
+
'
\
n }'
+
'
\
n })'
;
'
\
n from: web3.eth.accounts[0], '
+
'
\
n data:
\'
'
+
bytecode
+
'
\'
, '
+
'
\
n gas: 3000000'
+
'
\
n }, function (e, contract){'
+
'
\
n console.log(e, contract);'
+
'
\
n if (typeof contract.address !==
\'
undefined
\'
) {'
+
'
\
n console.log(
\'
Contract mined! address:
\'
+ contract.address +
\'
transactionHash:
\'
+ contract.transactionHash);'
+
'
\
n }'
+
'
\
n })'
;
return
code
;
}
...
...
@@ -241,7 +239,6 @@ function Renderer (editor, compiler, updateFiles) {
}
return
funABI
;
}
}
module
.
exports
=
Renderer
;
src/app/storage-handler.js
View file @
09690338
/* global chrome, confirm, localStorage */
var
utils
=
require
(
'./utils'
);
function
StorageHandler
(
updateFiles
)
{
this
.
sync
=
function
()
{
if
(
typeof
chrome
===
'undefined'
||
!
chrome
||
!
chrome
.
storage
||
!
chrome
.
storage
.
sync
)
{
return
;
}
var
obj
=
{};
var
done
=
false
;
var
count
=
0
var
dont
=
0
;
var
count
=
0
;
function
check
(
key
)
{
chrome
.
storage
.
sync
.
get
(
key
,
function
(
resp
)
{
...
...
@@ -28,9 +27,9 @@ function StorageHandler (updateFiles) {
if
(
done
>=
count
)
{
chrome
.
storage
.
sync
.
set
(
obj
,
function
()
{
console
.
log
(
'updated cloud files with: '
,
obj
,
this
,
arguments
);
})
})
;
}
})
})
;
}
for
(
var
y
in
window
.
localStorage
)
{
...
...
src/index.js
View file @
09690338
...
...
@@ -2,4 +2,4 @@ require('es6-shim');
var
app
=
require
(
'./app.js'
);
var
$
=
require
(
'jquery'
);
$
(
document
).
ready
(
function
()
{
app
.
run
();
});
\ No newline at end of file
$
(
document
).
ready
(
function
()
{
app
.
run
();
});
src/universal-dapp.js
View file @
09690338
This diff is collapsed.
Click to expand it.
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