Commit 09690338 authored by Alex Beregszaszi's avatar Alex Beregszaszi

Merge pull request #68 from ethereum/codestyle-formatting

Codestyle formatting (Part 1)
parents e382840f 504e6d78
...@@ -22,9 +22,9 @@ ...@@ -22,9 +22,9 @@
* THE SOFTWARE. * 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 { struct Voter {
uint weight; uint weight;
......
chrome.browserAction.onClicked.addListener(function (tab) { /* global chrome */
chrome.storage.sync.set({ 'chrome-app-sync' : true });
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 // tab opened
}); });
}); });
/* global alert, confirm, prompt, Option, Worker, soljsonSources */
var $ = require('jquery'); var $ = require('jquery');
var utils = require('./app/utils'); var utils = require('./app/utils');
...@@ -19,14 +21,12 @@ window.addEventListener('message', function (ev) { ...@@ -19,14 +21,12 @@ window.addEventListener('message', function (ev) {
}, false); }, false);
var run = function () { var run = function () {
function loadFiles (files) { function loadFiles (files) {
for (var f in files) { for (var f in files) {
var key = utils.fileKey(f); var key = utils.fileKey(f);
var content = files[f].content; var content = files[f].content;
if (key in window.localStorage && window.localStorage[key] !== content) { if (key in window.localStorage && window.localStorage[key] !== content) {
var count = ''; var count = '';
var otherKey = key + count;
while ((key + count) in window.localStorage) count = count - 1; while ((key + count) in window.localStorage) count = count - 1;
window.localStorage[key + count] = window.localStorage[key]; window.localStorage[key + count] = window.localStorage[key];
} }
...@@ -44,7 +44,6 @@ var run = function () { ...@@ -44,7 +44,6 @@ var run = function () {
loadFiles(filesToLoad); loadFiles(filesToLoad);
} }
// ------------------ query params (hash) ---------------- // ------------------ query params (hash) ----------------
function syncQueryParams () { function syncQueryParams () {
...@@ -55,8 +54,9 @@ var run = function () { ...@@ -55,8 +54,9 @@ var run = function () {
syncQueryParams(); syncQueryParams();
// -------- check file upload capabilities ------- // -------- check file upload capabilities -------
if (!(window.File || window.FileReader || window.FileList || window.Blob)) { if (!(window.File || window.FileReader || window.FileList || window.Blob)) {
$(".uploadFile").remove(); $('.uploadFile').remove();
} }
// ------------------ gist load ---------------- // ------------------ gist load ----------------
...@@ -78,19 +78,16 @@ var run = function () { ...@@ -78,19 +78,16 @@ var run = function () {
}); });
}); });
// ----------------- storage -------------------- // ----------------- storage --------------------
var storageHandler = new StorageHandler(updateFiles); var storageHandler = new StorageHandler(updateFiles);
window.syncStorage = storageHandler.sync; window.syncStorage = storageHandler.sync;
storageHandler.sync(); storageHandler.sync();
// ----------------- editor ---------------------- // ----------------- editor ----------------------
var editor = new Editor(loadingFromGist); var editor = new Editor(loadingFromGist);
// ----------------- tabbed menu ------------------- // ----------------- tabbed menu -------------------
$('#options li').click(function (ev) { $('#options li').click(function (ev) {
...@@ -108,12 +105,10 @@ var run = function () { ...@@ -108,12 +105,10 @@ var run = function () {
} }
}); });
// ------------------ gist publish -------------- // ------------------ gist publish --------------
$('#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 = editor.packageFiles(); var files = editor.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://ethereum.github.io/browser-solidity/#version=' + queryParams.get().version + '&optimize=' + queryParams.get().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=' + queryParams.get().version + '&optimize=' + queryParams.get().optimize + '&gist=';
...@@ -142,7 +137,7 @@ var run = function () { ...@@ -142,7 +137,7 @@ var run = function () {
return; return;
} }
var files = editor.packageFiles(); var files = editor.packageFiles();
var iframe = $('<iframe/>', {src: target, style: 'display:none;', load: function () { $('<iframe/>', {src: target, style: 'display:none;', load: function () {
this.contentWindow.postMessage(['loadFiles', files], '*'); this.contentWindow.postMessage(['loadFiles', files], '*');
}}).appendTo('body'); }}).appendTo('body');
}); });
...@@ -237,7 +232,6 @@ var run = function () { ...@@ -237,7 +232,6 @@ var run = function () {
return $('#files .file').filter(function () { return $(this).find('.name').text() === name; }); return $('#files .file').filter(function () { return $(this).find('.name').text() === name; });
} }
function updateFiles () { function updateFiles () {
var $filesEl = $('#files'); var $filesEl = $('#files');
var files = editor.getFiles(); var files = editor.getFiles();
...@@ -276,9 +270,9 @@ var run = function () { ...@@ -276,9 +270,9 @@ var run = function () {
return itemsWidth; return itemsWidth;
} }
function widthOfHidden () { // function widthOfHidden () {
return ($filesWrapper.outerWidth() - widthOfList() - getLeftPosi()); // return ($filesWrapper.outerWidth() - widthOfList() - getLeftPosi());
} // }
function widthOfVisible () { function widthOfVisible () {
return $filesWrapper.outerWidth(); return $filesWrapper.outerWidth();
...@@ -295,7 +289,7 @@ var run = function () { ...@@ -295,7 +289,7 @@ var run = function () {
} }
function reAdjust () { function reAdjust () {
if (widthOfList() + getLeftPosi() > + widthOfVisible()) { if (widthOfList() + getLeftPosi() > widthOfVisible()) {
$scrollerRight.fadeIn('fast'); $scrollerRight.fadeIn('fast');
} else { } else {
$scrollerRight.fadeOut('fast'); $scrollerRight.fadeOut('fast');
...@@ -390,7 +384,6 @@ var run = function () { ...@@ -390,7 +384,6 @@ var run = function () {
if (cachedSize) setEditorSize(cachedSize); if (cachedSize) setEditorSize(cachedSize);
else getEditorSize(); else getEditorSize();
// ----------------- toggle right hand panel ----------------- // ----------------- toggle right hand panel -----------------
var hidingRHP = false; var hidingRHP = false;
...@@ -416,12 +409,10 @@ var run = function () { ...@@ -416,12 +409,10 @@ 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 output renderer ---------------------- // ----------------- compiler output renderer ----------------------
$('.asmOutput button').click(function () { $(this).parent().find('pre').toggle(); }); $('.asmOutput button').click(function () { $(this).parent().find('pre').toggle(); });
// ----------------- compiler ---------------------- // ----------------- compiler ----------------------
function handleGithubCall (root, path, cb) { function handleGithubCall (root, path, cb) {
...@@ -452,7 +443,7 @@ var run = function () { ...@@ -452,7 +443,7 @@ var run = function () {
loadVersion(queryParams.get().version || 'soljson-latest.js'); loadVersion(queryParams.get().version || 'soljson-latest.js');
document.querySelector('#optimize').addEventListener('change', function () { document.querySelector('#optimize').addEventListener('change', function () {
queryParams.update({optimize: document.querySelector('#optimize').checked }); queryParams.update({ optimize: document.querySelector('#optimize').checked });
compiler.compile(); compiler.compile();
}); });
......
var version = function() { return '(loading)'; } var version = function () { return '(loading)'; };
var compileJSON = function() { return ''; } var compileJSON = function () { return ''; };
var missingInputs = []; var missingInputs = [];
module.exports = function (self) { module.exports = function (self) {
self.addEventListener('message', function(e) { self.addEventListener('message', function (e) {
var data = e.data; var data = e.data;
switch (data.cmd) { switch (data.cmd) {
case 'loadVersion': case 'loadVersion':
...@@ -12,21 +12,20 @@ module.exports = function (self) { ...@@ -12,21 +12,20 @@ module.exports = function (self) {
compileJSON = null; compileJSON = null;
importScripts(data.data); importScripts(data.data);
version = Module.cwrap("version", "string", []); version = Module.cwrap('version', 'string', []);
if ('_compileJSONCallback' in Module) if ('_compileJSONCallback' in Module) {
{ var compileJSONInternal = Module.cwrap('compileJSONCallback', 'string', ['string', 'number', 'number']);
compileJSONInternal = Module.cwrap("compileJSONCallback", "string", ["string", "number", "number"]); var missingInputCallback = Module.Runtime.addFunction(function (path) {
var missingInputCallback = Module.Runtime.addFunction(function(path) {
missingInputs.push(Module.Pointer_stringify(path)); missingInputs.push(Module.Pointer_stringify(path));
}); });
compileJSON = function(input, optimize) { compileJSON = function (input, optimize) {
return compileJSONInternal(input, optimize, missingInputCallback); 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']);
} }
else if ('_compileJSONMulti' in Module)
compileJSON = Module.cwrap("compileJSONMulti", "string", ["string", "number"]);
else
compileJSON = Module.cwrap("compileJSON", "string", ["string", "number"]);
postMessage({ postMessage({
cmd: 'versionLoaded', cmd: 'versionLoaded',
data: version(), data: version(),
...@@ -39,4 +38,4 @@ module.exports = function (self) { ...@@ -39,4 +38,4 @@ module.exports = function (self) {
break; break;
} }
}, false); }, false);
} };
...@@ -42,7 +42,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles ...@@ -42,7 +42,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
sourceAnnotations = []; sourceAnnotations = [];
outputField.empty(); outputField.empty();
var input = editor.getValue(); var input = editor.getValue();
editor.setCacheFileContent(input) editor.setCacheFileContent(input);
var files = {}; var files = {};
files[editor.getCacheFile()] = input; files[editor.getCacheFile()] = input;
...@@ -148,7 +148,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles ...@@ -148,7 +148,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
function loadInternal (url, setVersionText) { function loadInternal (url, setVersionText) {
Module = null; Module = null;
// Set a safe fallback until the new one is loaded // 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'); var newScript = document.createElement('script');
newScript.type = 'text/javascript'; newScript.type = 'text/javascript';
...@@ -178,7 +178,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles ...@@ -178,7 +178,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
case 'compiled': case 'compiled':
compilationFinished(data.data, data.missingInputs); compilationFinished(data.data, data.missingInputs);
break; break;
}; }
}); });
worker.onerror = function (msg) { console.log(msg.data); }; worker.onerror = function (msg) { console.log(msg.data); };
worker.addEventListener('error', 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 ...@@ -186,7 +186,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
worker.postMessage({cmd: 'compile', source: source, optimize: optimize}); worker.postMessage({cmd: 'compile', source: source, optimize: optimize});
}; };
worker.postMessage({cmd: 'loadVersion', data: url}); worker.postMessage({cmd: 'loadVersion', data: url});
}; }
function gatherImports (files, importHints, cb) { function gatherImports (files, importHints, cb) {
importHints = importHints || []; importHints = importHints || [];
...@@ -201,7 +201,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles ...@@ -201,7 +201,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
reloop = false; reloop = false;
for (var fileName in files) { for (var fileName in files) {
var match; var match;
while (match = importRegex.exec(files[fileName])) { while ((match = importRegex.exec(files[fileName]))) {
importHints.push(match[1]); importHints.push(match[1]);
} }
} }
...@@ -219,7 +219,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles ...@@ -219,7 +219,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
} else if (m in cachedRemoteFiles) { } else if (m in cachedRemoteFiles) {
files[m] = cachedRemoteFiles[m]; files[m] = cachedRemoteFiles[m];
reloop = true; 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) { handleGithubCall(githubMatch[3], githubMatch[4], function (result) {
if ('content' in result) { if ('content' in result) {
var content = Base64.decode(result.content); var content = Base64.decode(result.content);
...@@ -243,4 +243,4 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles ...@@ -243,4 +243,4 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
} }
} }
module.exports = Compiler module.exports = Compiler;
/* global BALLOT_EXAMPLE, FileReader */
var utils = require('./utils'); var utils = require('./utils');
var ace = require('brace'); var ace = require('brace');
......
/* global confirm */
var $ = require('jquery'); var $ = require('jquery');
var Web3 = require('web3'); var Web3 = require('web3');
......
/* global prompt */
var queryParams = require('./query-params'); var queryParams = require('./query-params');
function handleLoad (cb) { function handleLoad (cb) {
......
...@@ -34,5 +34,5 @@ function updateQueryParams (params) { ...@@ -34,5 +34,5 @@ function updateQueryParams (params) {
module.exports = { module.exports = {
get: getQueryParams, get: getQueryParams,
update: updateQueryParams, update: updateQueryParams
}; };
...@@ -6,7 +6,6 @@ var utils = require('./utils'); ...@@ -6,7 +6,6 @@ var utils = require('./utils');
var ExecutionContext = require('./execution-context'); var ExecutionContext = require('./execution-context');
function Renderer (editor, compiler, updateFiles) { function Renderer (editor, compiler, updateFiles) {
var detailsOpen = {}; var detailsOpen = {};
var executionContext = new ExecutionContext(compiler); var executionContext = new ExecutionContext(compiler);
...@@ -43,7 +42,7 @@ function Renderer (editor, compiler, updateFiles) { ...@@ -43,7 +42,7 @@ function Renderer (editor, compiler, updateFiles) {
return false; return false;
}); });
} }
}; }
this.error = renderError; this.error = renderError;
var combined = function (contractName, jsonInterface, bytecode) { var combined = function (contractName, jsonInterface, bytecode) {
...@@ -51,7 +50,6 @@ function Renderer (editor, compiler, updateFiles) { ...@@ -51,7 +50,6 @@ function Renderer (editor, compiler, updateFiles) {
}; };
function renderContracts (data, source) { function renderContracts (data, source) {
var udappContracts = []; var udappContracts = [];
for (var contractName in data.contracts) { for (var contractName in data.contracts) {
var contract = data.contracts[contractName]; var contract = data.contracts[contractName];
...@@ -105,7 +103,7 @@ function Renderer (editor, compiler, updateFiles) { ...@@ -105,7 +103,7 @@ function Renderer (editor, compiler, updateFiles) {
$contractOutput.find('.title').click(function (ev) { $(this).closest('.contract').toggleClass('hide'); }); $contractOutput.find('.title').click(function (ev) { $(this).closest('.contract').toggleClass('hide'); });
$('#output').append($contractOutput); $('#output').append($contractOutput);
$('.col2 input,textarea').click(function () { this.select(); }); $('.col2 input,textarea').click(function () { this.select(); });
}; }
this.contracts = renderContracts; this.contracts = renderContracts;
var tableRowItems = function (first, second, cls) { var tableRowItems = function (first, second, cls) {
...@@ -132,8 +130,9 @@ function Renderer (editor, compiler, updateFiles) { ...@@ -132,8 +130,9 @@ function Renderer (editor, compiler, updateFiles) {
.append(tableRow('Solidity Interface', contract.solidity_interface)) .append(tableRow('Solidity Interface', contract.solidity_interface))
.append(tableRow('Opcodes', contract.opcodes)); .append(tableRow('Opcodes', contract.opcodes));
var funHashes = ''; var funHashes = '';
for (var fun in contract.functionHashes) for (var fun in contract.functionHashes) {
funHashes += contract.functionHashes[fun] + ' ' + fun + '\n'; funHashes += contract.functionHashes[fun] + ' ' + fun + '\n';
}
details.append($('<span class="col1">Functions</span>')); details.append($('<span class="col1">Functions</span>'));
details.append($('<pre/>').text(funHashes)); details.append($('<pre/>').text(funHashes));
details.append($('<span class="col1">Gas Estimates</span>')); details.append($('<span class="col1">Gas Estimates</span>'));
...@@ -154,7 +153,7 @@ function Renderer (editor, compiler, updateFiles) { ...@@ -154,7 +153,7 @@ function Renderer (editor, compiler, updateFiles) {
}; };
var formatGasEstimates = function (data) { 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 text = '';
var fun; var fun;
if ('creation' in data) { if ('creation' in data) {
...@@ -227,7 +226,6 @@ function Renderer (editor, compiler, updateFiles) { ...@@ -227,7 +226,6 @@ function Renderer (editor, compiler, updateFiles) {
'\n }' + '\n }' +
'\n })'; '\n })';
return code; return code;
} }
...@@ -241,7 +239,6 @@ function Renderer (editor, compiler, updateFiles) { ...@@ -241,7 +239,6 @@ function Renderer (editor, compiler, updateFiles) {
} }
return funABI; return funABI;
} }
} }
module.exports = Renderer; module.exports = Renderer;
/* global chrome, confirm, localStorage */
var utils = require('./utils'); var utils = require('./utils');
function StorageHandler (updateFiles) { function StorageHandler (updateFiles) {
this.sync = function () { this.sync = function () {
if (typeof chrome === 'undefined' || !chrome || !chrome.storage || !chrome.storage.sync) { if (typeof chrome === 'undefined' || !chrome || !chrome.storage || !chrome.storage.sync) {
return; return;
} }
var obj = {}; var obj = {};
var done = false; var done = false;
var count = 0 var count = 0;
var dont = 0;
function check (key) { function check (key) {
chrome.storage.sync.get(key, function (resp) { chrome.storage.sync.get(key, function (resp) {
...@@ -28,9 +27,9 @@ function StorageHandler (updateFiles) { ...@@ -28,9 +27,9 @@ function StorageHandler (updateFiles) {
if (done >= count) { if (done >= count) {
chrome.storage.sync.set(obj, function () { chrome.storage.sync.set(obj, function () {
console.log('updated cloud files with: ', obj, this, arguments); console.log('updated cloud files with: ', obj, this, arguments);
}) });
} }
}) });
} }
for (var y in window.localStorage) { for (var y in window.localStorage) {
......
/* global prompt */
var $ = require('jquery'); var $ = require('jquery');
var EthJSVM = require('ethereumjs-vm'); var EthJSVM = require('ethereumjs-vm');
var ethJSUtil = require('ethereumjs-util'); var ethJSUtil = require('ethereumjs-util');
...@@ -83,7 +85,6 @@ UniversalDApp.prototype.render = function () { ...@@ -83,7 +85,6 @@ UniversalDApp.prototype.render = function () {
if (this.contracts.length === 0) { if (this.contracts.length === 0) {
this.$el.append(this.getABIInputForm()); this.$el.append(this.getABIInputForm());
} else { } else {
for (var c in this.contracts) { for (var c in this.contracts) {
var $contractEl = $('<div class="contract"/>'); var $contractEl = $('<div class="contract"/>');
...@@ -145,7 +146,6 @@ UniversalDApp.prototype.getABIInputForm = function (cb) { ...@@ -145,7 +146,6 @@ UniversalDApp.prototype.getABIInputForm = function (cb) {
return $el; return $el;
}; };
UniversalDApp.prototype.getCreateInterface = function ($container, contract) { UniversalDApp.prototype.getCreateInterface = function ($container, contract) {
var self = this; var self = this;
var $createInterface = $('<div class="create"/>'); var $createInterface = $('<div class="create"/>');
...@@ -179,7 +179,6 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar ...@@ -179,7 +179,6 @@ 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" />');
...@@ -343,13 +342,14 @@ UniversalDApp.prototype.getCallButton = function (args) { ...@@ -343,13 +342,14 @@ UniversalDApp.prototype.getCallButton = function (args) {
var getGasUsedOutput = function (result, vmResult) { var getGasUsedOutput = function (result, vmResult) {
var $gasUsed = $('<div class="gasUsed">'); var $gasUsed = $('<div class="gasUsed">');
var caveat = lookupOnly ? '<em>(<span class="caveat" title="Cost only applies when called by a contract">caveat</span>)</em>' : ''; var caveat = lookupOnly ? '<em>(<span class="caveat" title="Cost only applies when called by a contract">caveat</span>)</em>' : '';
var gas;
if (result.gasUsed) { if (result.gasUsed) {
var gas = result.gasUsed.toString(10); gas = result.gasUsed.toString(10);
$gasUsed.html('<strong>Transaction cost:</strong> ' + gas + ' gas. ' + caveat); $gasUsed.html('<strong>Transaction cost:</strong> ' + gas + ' gas. ' + caveat);
} }
if (vmResult.gasUsed) { if (vmResult.gasUsed) {
var $callGasUsed = $('<div class="gasUsed">'); var $callGasUsed = $('<div class="gasUsed">');
var gas = vmResult.gasUsed.toString(10); gas = vmResult.gasUsed.toString(10);
$callGasUsed.append('<strong>Execution cost:</strong> ' + gas + ' gas.'); $callGasUsed.append('<strong>Execution cost:</strong> ' + gas + ' gas.');
$gasUsed.append($callGasUsed); $gasUsed.append($callGasUsed);
} }
...@@ -454,8 +454,10 @@ UniversalDApp.prototype.getCallButton = function (args) { ...@@ -454,8 +454,10 @@ UniversalDApp.prototype.getCallButton = function (args) {
// Only decode if there supposed to be fields // Only decode if there supposed to be fields
if (args.abi.outputs.length > 0) { if (args.abi.outputs.length > 0) {
try { try {
var i;
var outputTypes = []; var outputTypes = [];
for (var i = 0; i < args.abi.outputs.length; i++) { for (i = 0; i < args.abi.outputs.length; i++) {
outputTypes.push(args.abi.outputs[i].type); outputTypes.push(args.abi.outputs[i].type);
} }
...@@ -464,7 +466,7 @@ UniversalDApp.prototype.getCallButton = function (args) { ...@@ -464,7 +466,7 @@ UniversalDApp.prototype.getCallButton = function (args) {
// format decoded data // format decoded data
decodedObj = ethJSABI.stringify(outputTypes, decodedObj); decodedObj = ethJSABI.stringify(outputTypes, decodedObj);
for (var i = 0; i < outputTypes.length; i++) { for (i = 0; i < outputTypes.length; i++) {
var name = args.abi.outputs[i].name; var name = args.abi.outputs[i].name;
if (name.length > 0) { if (name.length > 0) {
decodedObj[i] = outputTypes[i] + ' ' + name + ': ' + decodedObj[i]; decodedObj[i] = outputTypes[i] + ' ' + name + ': ' + decodedObj[i];
...@@ -492,7 +494,6 @@ UniversalDApp.prototype.getCallButton = function (args) { ...@@ -492,7 +494,6 @@ UniversalDApp.prototype.getCallButton = function (args) {
$result.append(getReturnOutput(result)).append(getGasUsedOutput(result)); $result.append(getReturnOutput(result)).append(getGasUsedOutput(result));
} }
}); });
} }
}); });
}; };
...@@ -569,7 +570,7 @@ UniversalDApp.prototype.deployLibrary = function (contractName, cb) { ...@@ -569,7 +570,7 @@ UniversalDApp.prototype.deployLibrary = function (contractName, cb) {
self.getContractByName(contractName).address = result.createdAddress; self.getContractByName(contractName).address = result.createdAddress;
cb(err, result.createdAddress); cb(err, result.createdAddress);
} else { } else {
tryTillResponse(self.web3, result, function(err, finalResult) { tryTillResponse(self.web3, result, function (err, finalResult) {
if (err) return cb(err); if (err) return cb(err);
self.getContractByName(contractName).address = finalResult.contractAddress; self.getContractByName(contractName).address = finalResult.contractAddress;
cb(null, finalResult.contractAddress); cb(null, finalResult.contractAddress);
...@@ -630,7 +631,7 @@ UniversalDApp.prototype.runTx = function (data, args, cb) { ...@@ -630,7 +631,7 @@ UniversalDApp.prototype.runTx = function (data, args, cb) {
var address = this.options.getAddress ? this.options.getAddress() : this.getAccounts()[0]; var address = this.options.getAddress ? this.options.getAddress() : this.getAccounts()[0];
var account = this.accounts[address]; var account = this.accounts[address];
tx = new EthJSTX({ tx = new EthJSTX({
nonce: new Buffer([account.nonce++]), //@todo count beyond 255 nonce: new Buffer([account.nonce++]), // @todo count beyond 255
gasPrice: 1, gasPrice: 1,
gasLimit: 3000000000, // plenty gasLimit: 3000000000, // plenty
to: to, to: to,
...@@ -663,7 +664,6 @@ function tryTillResponse (web3, txhash, done) { ...@@ -663,7 +664,6 @@ function tryTillResponse (web3, txhash, done) {
done(err, address); done(err, address);
} }
} }
} }
module.exports = UniversalDApp; module.exports = UniversalDApp;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment