Merge pull request #18 from Denton-L/minor-corrections

Minor Corrections
pull/1/head
chriseth 9 years ago
commit cf6d828b6f
  1. 28
      assets/css/styles.css
  2. 2
      background.js
  3. 10
      index.html
  4. 2
      manifest.json
  5. 44
      src/app.js
  6. 26
      src/mode-solidity.js
  7. 20
      src/universal-dapp.js

@ -71,7 +71,7 @@ code, pre {
pre { pre {
padding:8px 15px; padding:8px 15px;
background: #f8f8f8; background: #f8f8f8;
border-radius:5px; border-radius:5px;
border:1px solid #e5e5e5; border:1px solid #e5e5e5;
overflow-x: auto; overflow-x: auto;
@ -110,9 +110,9 @@ header {
header ul { header ul {
list-style:none; list-style:none;
height:40px; height:40px;
padding:0; padding:0;
background: #eee; background: #eee;
background: -moz-linear-gradient(top, #f8f8f8 0%, #dddddd 100%); background: -moz-linear-gradient(top, #f8f8f8 0%, #dddddd 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#dddddd)); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#dddddd));
@ -120,7 +120,7 @@ header ul {
background: -o-linear-gradient(top, #f8f8f8 0%,#dddddd 100%); background: -o-linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
background: -ms-linear-gradient(top, #f8f8f8 0%,#dddddd 100%); background: -ms-linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
background: linear-gradient(top, #f8f8f8 0%,#dddddd 100%); background: linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
border-radius:5px; border-radius:5px;
border:1px solid #d2d2d2; border:1px solid #d2d2d2;
box-shadow:inset #fff 0 1px 0, inset rgba(0,0,0,0.03) 0 -1px 0; box-shadow:inset #fff 0 1px 0, inset rgba(0,0,0,0.03) 0 -1px 0;
@ -214,33 +214,33 @@ footer {
} }
@media print, screen and (max-width: 960px) { @media print, screen and (max-width: 960px) {
div.wrapper { div.wrapper {
width:auto; width:auto;
margin:0; margin:0;
} }
header, section, footer { header, section, footer {
float:none; float:none;
position:static; position:static;
width:auto; width:auto;
} }
header { header {
padding-right:320px; padding-right:320px;
} }
section { section {
border:1px solid #e5e5e5; border:1px solid #e5e5e5;
border-width:1px 0; border-width:1px 0;
padding:20px 0; padding:20px 0;
margin:0 0 20px; margin:0 0 20px;
} }
header a small { header a small {
display:inline; display:inline;
} }
header ul { header ul {
position:absolute; position:absolute;
right:50px; right:50px;
@ -252,15 +252,15 @@ footer {
body { body {
word-wrap:break-word; word-wrap:break-word;
} }
header { header {
padding:0; padding:0;
} }
header ul, header p.view { header ul, header p.view {
position:static; position:static;
} }
pre, code { pre, code {
word-wrap:normal; word-wrap:normal;
} }
@ -270,7 +270,7 @@ footer {
body { body {
padding:15px; padding:15px;
} }
header ul { header ul {
display:none; display:none;
} }

@ -4,7 +4,7 @@ chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.create({'url': chrome.extension.getURL('index.html')}, function(tab) { chrome.tabs.create({'url': chrome.extension.getURL('index.html')}, function(tab) {
// tab opened // tab opened
}); });
}); });

@ -41,7 +41,7 @@
</head> </head>
<body> <body>
<div id="editor"> <div id="editor">
<span class="newFile" title="New File"><i class="fa fa-file-code-o"></i></span> <span class="newFile" title="New File"><i class="fa fa-file-code-o"></i></span>
@ -107,20 +107,20 @@
<label for="web3"> <label for="web3">
<input id="web3" type="radio" value="web3" name="executionContext"> <input id="web3" type="radio" value="web3" name="executionContext">
<strong>Web3 Provider</strong> <strong>Web3 Provider</strong>
<p>Execution environment connects to node at localhost (or via IPC if available), transactions will be sent to the network and can cause loss of money or worse!<br/> <p>Execution environment connects to node at localhost (or via IPC if available), transactions will be sent to the network and can cause loss of money or worse!<br/>
<b>If this page is served via https and you access your node via http, it might not work. In this case, try cloning the repository and serving it via http.</b></p> <b>If this page is served via https and you access your node via http, it might not work. In this case, try cloning the repository and serving it via http.</b></p>
<label for="web3Endpoint"> <label for="web3Endpoint">
<strong>Web3 Provider Endpoint</strong>: <input type="text" id="web3Endpoint" value="http://localhost:8545"> <strong>Web3 Provider Endpoint</strong>: <input type="text" id="web3Endpoint" value="http://localhost:8545">
</label> </label>
</label> </label>
</span> </span>
</div> </div>
</div> </div>
</div> </div>
<div id="output"></div> <div id="output"></div>
</div> </div>
<script src="build/app.js"></script> <script src="build/app.js"></script>
</body> </body>
</html> </html>

@ -24,7 +24,7 @@
"https://ajax.googleapis.com/", "https://ajax.googleapis.com/",
"webRequest", "webRequest",
"webRequestBlocking", "webRequestBlocking",
"\u003Call_urls>" "<all_urls>"
], ],
"content_security_policy": "script-src 'self' https://ethereum.github.io/solc-bin/bin/; object-src 'self'" "content_security_policy": "script-src 'self' https://ethereum.github.io/solc-bin/bin/; object-src 'self'"

@ -181,7 +181,7 @@ var run = function() {
var untitledCount = ''; var untitledCount = '';
if (!getFiles().length || window.localStorage['sol-cache']) { if (!getFiles().length || window.localStorage['sol-cache']) {
if(loadingFromGist) return; if(loadingFromGist) return;
// Backwards-compatibility // Backwards-compatibility
while (window.localStorage[SOL_CACHE_UNTITLED + untitledCount]) while (window.localStorage[SOL_CACHE_UNTITLED + untitledCount])
untitledCount = (untitledCount - 0) + 1; untitledCount = (untitledCount - 0) + 1;
SOL_CACHE_FILE = SOL_CACHE_UNTITLED + untitledCount; SOL_CACHE_FILE = SOL_CACHE_UNTITLED + untitledCount;
@ -262,7 +262,7 @@ var run = function() {
// ------------------ gist publish -------------- // ------------------ gist publish --------------
var packageFiles = function() { var packageFiles = function() {
var files = {}; var files = {};
var filesArr = getFiles(); var filesArr = getFiles();
@ -272,16 +272,16 @@ var run = function() {
content: localStorage[filesArr[f]] content: localStorage[filesArr[f]]
}; };
} }
return files; return files;
}; };
$('#gist').click(function(){ $('#gist').click(function(){
if (confirm("Are you sure you want to publish all your files anonymously as a public gist on github.com?")) { if (confirm("Are you sure you want to publish all your files anonymously as a public gist on github.com?")) {
var files = packageFiles(); var files = packageFiles();
var description = "Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. \n Load this file by pasting this gists URL or ID at https://chriseth.github.io/browser-solidity/#version=" + getQueryParams().version + "&optimize="+ getQueryParams().optimize +"&gist="; var description = "Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. \n Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=" + getQueryParams().version + "&optimize="+ getQueryParams().optimize +"&gist=";
$.ajax({ $.ajax({
url: 'https://api.github.com/gists', url: 'https://api.github.com/gists',
type: 'POST', type: 'POST',
data: JSON.stringify({ data: JSON.stringify({
@ -397,7 +397,7 @@ var run = function() {
for (var f in files) { for (var f in files) {
$filesEl.append(fileTabTemplate(files[f])); $filesEl.append(fileTabTemplate(files[f]));
} }
if (SOL_CACHE_FILE) { if (SOL_CACHE_FILE) {
var active = fileTabFromKey(SOL_CACHE_FILE); var active = fileTabFromKey(SOL_CACHE_FILE);
active.addClass('active'); active.addClass('active');
@ -511,9 +511,9 @@ var run = function() {
updateQueryParams({version: $('#versionSelector').val() }); updateQueryParams({version: $('#versionSelector').val() });
loadVersion($('#versionSelector').val()); loadVersion($('#versionSelector').val());
}); });
// ----------------- resizeable ui --------------- // ----------------- resizeable ui ---------------
var EDITOR_SIZE_CACHE_KEY = "editor-size-cache"; var EDITOR_SIZE_CACHE_KEY = "editor-size-cache";
var dragging = false; var dragging = false;
$('#dragbar').mousedown(function(e){ $('#dragbar').mousedown(function(e){
@ -566,13 +566,13 @@ var run = function() {
var hidingRHP = false; var hidingRHP = false;
$('.toggleRHP').click(function(){ $('.toggleRHP').click(function(){
hidingRHP = !hidingRHP; hidingRHP = !hidingRHP;
setEditorSize( hidingRHP ? 0 : window.localStorage[EDITOR_SIZE_CACHE_KEY] ); setEditorSize( hidingRHP ? 0 : window.localStorage[EDITOR_SIZE_CACHE_KEY] );
$('.toggleRHP i').toggleClass('fa-angle-double-right', !hidingRHP); $('.toggleRHP i').toggleClass('fa-angle-double-right', !hidingRHP);
$('.toggleRHP i').toggleClass('fa-angle-double-left', hidingRHP); $('.toggleRHP i').toggleClass('fa-angle-double-left', hidingRHP);
if (!hidingRHP) compile(); if (!hidingRHP) compile();
}); });
// ----------------- editor resize --------------- // ----------------- editor resize ---------------
@ -595,7 +595,7 @@ var run = function() {
document.querySelector('#editor').addEventListener('change', onResize); document.querySelector('#editor').addEventListener('change', onResize);
document.querySelector('#editorWrap').addEventListener('change', onResize); document.querySelector('#editorWrap').addEventListener('change', onResize);
// ----------------- compiler ---------------------- // ----------------- compiler ----------------------
var compileJSON; var compileJSON;
@ -637,13 +637,13 @@ var run = function() {
if (errortype(err) !== 'warning') noFatalErrors = false; if (errortype(err) !== 'warning') noFatalErrors = false;
}); });
} }
if (missingInputs !== undefined && missingInputs.length > 0) if (missingInputs !== undefined && missingInputs.length > 0)
compile(missingInputs); compile(missingInputs);
else if (noFatalErrors && !hidingRHP) else if (noFatalErrors && !hidingRHP)
renderContracts(data, editor.getValue()); renderContracts(data, editor.getValue());
}; };
var compileTimeout = null; var compileTimeout = null;
var onChange = function() { var onChange = function() {
var input = editor.getValue(); var input = editor.getValue();
@ -860,18 +860,18 @@ var run = function() {
code += "var " + contractName + "Contract = web3.eth.contract(" + interface.replace("\n","") + ");" code += "var " + contractName + "Contract = web3.eth.contract(" + interface.replace("\n","") + ");"
+"\nvar " + contractName + " = " + contractName + "Contract.new("; +"\nvar " + contractName + " = " + contractName + "Contract.new(";
$.each(funABI.inputs, function(i, inp) { $.each(funABI.inputs, function(i, inp) {
code += "\n " + inp.name + ","; code += "\n " + inp.name + ",";
}); });
code += "\n {"+ code += "\n {"+
"\n from: web3.eth.accounts[0], "+ "\n from: web3.eth.accounts[0], "+
"\n data: '"+bytecode+"', "+ "\n data: '"+bytecode+"', "+
"\n gas: 3000000"+ "\n gas: 3000000"+
"\n }, function(e, contract){"+ "\n }, function(e, contract){"+
"\n console.log(e, contract);"+ "\n console.log(e, contract);"+
"\n if (typeof contract.address != 'undefined') {"+ "\n if (typeof contract.address != 'undefined') {"+
"\n console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);" + "\n console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);" +
"\n }" + "\n }" +
"\n })"; "\n })";
@ -1010,7 +1010,7 @@ var run = function() {
return text; return text;
}; };
$('.asmOutput button').click(function() {$(this).parent().find('pre').toggle(); }); $('.asmOutput button').click(function() {$(this).parent().find('pre').toggle(); });
var getConstructorInterface = function(abi) { var getConstructorInterface = function(abi) {
@ -1029,4 +1029,4 @@ var run = function() {
module.exports = { module.exports = {
'run': run 'run': run
}; };

@ -11,7 +11,7 @@ var DocCommentHighlightRules = function() {
"start" : [ { "start" : [ {
token : "comment.doc.tag", token : "comment.doc.tag",
regex : "@[\\w\\d_]+" // TODO: fix email addresses regex : "@[\\w\\d_]+" // TODO: fix email addresses
}, },
DocCommentHighlightRules.getTagRule(), DocCommentHighlightRules.getTagRule(),
{ {
defaultToken : "comment.doc", defaultToken : "comment.doc",
@ -341,8 +341,8 @@ var JavaScriptHighlightRules = function(options) {
} }
] ]
}; };
if (!options || !options.noES6) { if (!options || !options.noES6) {
this.$rules.no_regex.unshift({ this.$rules.no_regex.unshift({
regex: "[{}]", onMatch: function(val, state, stack) { regex: "[{}]", onMatch: function(val, state, stack) {
@ -379,10 +379,10 @@ var JavaScriptHighlightRules = function(options) {
}] }]
}); });
} }
this.embedRules(DocCommentHighlightRules, "doc-", this.embedRules(DocCommentHighlightRules, "doc-",
[ DocCommentHighlightRules.getEndRule("no_regex") ]); [ DocCommentHighlightRules.getEndRule("no_regex") ]);
this.normalizeRules(); this.normalizeRules();
}; };
@ -717,7 +717,7 @@ var CstyleBehaviour = function() {
}; };
CstyleBehaviour.isSaneInsertion = function(editor, session) { CstyleBehaviour.isSaneInsertion = function(editor, session) {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var iterator = new TokenIterator(session, cursor.row, cursor.column); var iterator = new TokenIterator(session, cursor.row, cursor.column);
@ -821,16 +821,16 @@ oop.inherits(FoldMode, BaseFoldMode);
if (match[1]) if (match[1])
return this.openingBracketBlock(session, match[1], row, i); return this.openingBracketBlock(session, match[1], row, i);
var range = session.getCommentFoldRange(row, i + match[0].length, 1); var range = session.getCommentFoldRange(row, i + match[0].length, 1);
if (range && !range.isMultiLine()) { if (range && !range.isMultiLine()) {
if (forceMultiline) { if (forceMultiline) {
range = this.getSectionRange(session, row); range = this.getSectionRange(session, row);
} else if (foldStyle != "all") } else if (foldStyle != "all")
range = null; range = null;
} }
return range; return range;
} }
@ -847,7 +847,7 @@ oop.inherits(FoldMode, BaseFoldMode);
return session.getCommentFoldRange(row, i, -1); return session.getCommentFoldRange(row, i, -1);
} }
}; };
this.getSectionRange = function(session, row) { this.getSectionRange = function(session, row) {
var line = session.getLine(row); var line = session.getLine(row);
var startIndent = line.search(/\S/); var startIndent = line.search(/\S/);
@ -864,7 +864,7 @@ oop.inherits(FoldMode, BaseFoldMode);
if (startIndent > indent) if (startIndent > indent)
break; break;
var subRange = this.getFoldWidgetRange(session, "all", row); var subRange = this.getFoldWidgetRange(session, "all", row);
if (subRange) { if (subRange) {
if (subRange.start.row <= startRow) { if (subRange.start.row <= startRow) {
break; break;
@ -876,7 +876,7 @@ oop.inherits(FoldMode, BaseFoldMode);
} }
endRow = row; endRow = row;
} }
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length); return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
}; };
@ -898,7 +898,7 @@ var CStyleFoldMode = acequire("./folding/cstyle").FoldMode;
var Mode = function() { var Mode = function() {
this.HighlightRules = JavaScriptHighlightRules; this.HighlightRules = JavaScriptHighlightRules;
this.$outdent = new MatchingBraceOutdent(); this.$outdent = new MatchingBraceOutdent();
this.$behaviour = new CstyleBehaviour(); this.$behaviour = new CstyleBehaviour();
this.foldingRules = new CStyleFoldMode(); this.foldingRules = new CStyleFoldMode();

@ -150,7 +150,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
var $createInterface = $('<div class="createContract"/>'); var $createInterface = $('<div class="createContract"/>');
var appendFunctions = function (address, $el){ var appendFunctions = function (address, $el){
var $instance = $('<div class="instance"/>'); var $instance = $('<div class="instance"/>');
if (self.options.removable_instances) { if (self.options.removable_instances) {
var $close = $('<div class="udapp-close" />') var $close = $('<div class="udapp-close" />')
@ -185,8 +185,8 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
$.each(abi, function(i, funABI) { $.each(abi, function(i, funABI) {
if (funABI.type !== 'event') return; if (funABI.type !== 'event') return;
var hash = ethJSABI.eventID(funABI.name, funABI.inputs.map(function(item) { return item.type })) var hash = ethJSABI.eventID(funABI.name, funABI.inputs.map(function(item) { return item.type }))
eventABI[hash.toString('hex')] = { event: funABI.name, inputs: funABI.inputs }; eventABI[hash.toString('hex')] = { event: funABI.name, inputs: funABI.inputs };
}); });
self.vm.on('afterTx', function(response){ self.vm.on('afterTx', function(response){
@ -254,7 +254,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
} else { } else {
appendFunctions( address, $target ); appendFunctions( address, $target );
} }
return $createInterface; return $createInterface;
} }
@ -330,7 +330,7 @@ UniversalDApp.prototype.getCallButton = function(args) {
var handleCallButtonClick = function(ev, $result) { var handleCallButtonClick = function(ev, $result) {
if (!$result) { if (!$result) {
$result = getOutput(); $result = getOutput();
if (lookupOnly && !inputs.length) if (lookupOnly && !inputs.length)
$outputOverride.empty().append( $result ); $outputOverride.empty().append( $result );
else else
@ -423,7 +423,7 @@ UniversalDApp.prototype.getCallButton = function(args) {
} else if (args.abi.constant && !isConstructor) { } else if (args.abi.constant && !isConstructor) {
replaceOutput($result, getReturnOutput(result)); replaceOutput($result, getReturnOutput(result));
} else { } else {
function tryTillResponse (txhash, done) { function tryTillResponse (txhash, done) {
web3.eth.getTransactionReceipt(result, testResult ); web3.eth.getTransactionReceipt(result, testResult );
@ -444,7 +444,7 @@ UniversalDApp.prototype.getCallButton = function(args) {
$result.append(getReturnOutput(result)).append(getGasUsedOutput(result)); $result.append(getReturnOutput(result)).append(getGasUsedOutput(result));
} }
}) })
} }
}); });
} }
@ -517,7 +517,7 @@ UniversalDApp.prototype.clickNewContract = function ( self, $contract, contract
} }
UniversalDApp.prototype.clickContractAt = function ( self, $output, contract ) { UniversalDApp.prototype.clickContractAt = function ( self, $output, contract ) {
var address = prompt( "What Address is this contract at in the Blockchain? ie: '0xdeadbeaf...'" ) var address = prompt( "What Address is this contract at in the Blockchain? ie: '0xdeadbeaf...'" )
self.getInstanceInterface(contract, address, $output ); self.getInstanceInterface(contract, address, $output );
} }
@ -539,7 +539,7 @@ UniversalDApp.prototype.runTx = function( data, args, cb) {
return cb(e); return cb(e);
} }
} }
if (!this.vm) { if (!this.vm) {
var tx = { var tx = {
from: self.options.getAddress ? self.options.getAddress() : web3.eth.accounts[0], from: self.options.getAddress ? self.options.getAddress() : web3.eth.accounts[0],
@ -585,4 +585,4 @@ UniversalDApp.prototype.runTx = function( data, args, cb) {
} }
} }
module.exports = UniversalDApp; module.exports = UniversalDApp;

Loading…
Cancel
Save