From 41b688dda1c4b12d8cd8a236295a118f72a5b67d Mon Sep 17 00:00:00 2001 From: hunterlester Date: Thu, 8 Dec 2016 22:52:44 -0800 Subject: [PATCH 1/3] save progress on getting submit proposal command and progressing UI confirmations --- index.html | 8 ++++++++ js/txListener.js | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 9ccfc51..ec3e9ee 100755 --- a/index.html +++ b/index.html @@ -100,6 +100,8 @@ $('#feeTxid').on('input', function() { + var proposal = new ProposalGenerator(gov); + var transaction = $(this).val(); var txListener = new TXListener(socket, provider, transaction); @@ -121,9 +123,15 @@ txListener.confirmations = res.confirmations; txListener.initSocket(function() { + console.log("callback called, step 4"); + $('#walletCommandsSubmit').removeClass('hidden'); document.getElementById('step_four').click(); document.getElementsByClassName('progress-bar')[0].style.width = "100%"; document.getElementsByClassName('progress-bar')[0].innerText = "Proposal ready for submission"; + + var submitCommand = "gobject submit " + $('#parentHash').val() + " " + $('#revision').val() + " " + $('#time').val() + " " + proposal.gov.serialize() + " " + $(this).val(); + console.log(submitCommand); + $('textarea#submitProposal').val(submitCommand); }); // callback issued after tx confirmations >= 6 } diff --git a/js/txListener.js b/js/txListener.js index cdcd35a..3cdd7be 100755 --- a/js/txListener.js +++ b/js/txListener.js @@ -20,8 +20,14 @@ TXListener.prototype.initSocket = function(cb) { if (err) console.log("error fetching block: " + data); self.confirmations = (res.height - self.blockheight) + 1; // compare blockHeight against transaction blockHeight + var confirmation_count = (res.height - self.confirmations) + 1; + console.log("res: ", res); + console.log("self: ", self); + console.log(confirmation_count); - if (self.confirmations >= 6) cb(); + if (confirmation_count >= 6) { + cb(); + }; $("#progressbar").progressbar({value: ((100 / 6) * self.confirmations)}); console.log('confirmations: ' + self.confirmations); @@ -41,6 +47,7 @@ TXListener.prototype.getTx = function(cb) { format: "json" } }; + console.log(opts); this._fetch(opts, cb); }; @@ -83,4 +90,4 @@ TXListener.prototype._fetch = function(opts,cb) { } else { cb('missing parameter',null); } -}; \ No newline at end of file +}; From 97b41dc065374083680d3dcb8e1bdc8895ee2f6b Mon Sep 17 00:00:00 2001 From: hunterlester Date: Sun, 11 Dec 2016 22:19:05 -0800 Subject: [PATCH 2/3] confirmations counted, transitions to final step --- index.html | 1 - js/txListener.js | 14 ++++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/index.html b/index.html index ec3e9ee..429061a 100755 --- a/index.html +++ b/index.html @@ -123,7 +123,6 @@ txListener.confirmations = res.confirmations; txListener.initSocket(function() { - console.log("callback called, step 4"); $('#walletCommandsSubmit').removeClass('hidden'); document.getElementById('step_four').click(); document.getElementsByClassName('progress-bar')[0].style.width = "100%"; diff --git a/js/txListener.js b/js/txListener.js index 3cdd7be..7ef1bb9 100755 --- a/js/txListener.js +++ b/js/txListener.js @@ -12,6 +12,7 @@ function TXListener(socket, provider, transaction) { TXListener.prototype.initSocket = function(cb) { var self = this; var socket = this.socket; + var confirmations = 0; socket.on('block', function(data) { console.log('block: '+ data); @@ -19,18 +20,15 @@ TXListener.prototype.initSocket = function(cb) { self.getBlock(data, function(err, res) { if (err) console.log("error fetching block: " + data); - self.confirmations = (res.height - self.blockheight) + 1; // compare blockHeight against transaction blockHeight - var confirmation_count = (res.height - self.confirmations) + 1; - console.log("res: ", res); - console.log("self: ", self); - console.log(confirmation_count); + //self.confirmations = (res.height - self.blockheight) + 1; // compare blockHeight against transaction blockHeight + confirmations++; - if (confirmation_count >= 6) { + if (confirmations >= 6) { cb(); }; - $("#progressbar").progressbar({value: ((100 / 6) * self.confirmations)}); + $("#progressbar").progressbar({value: ((100 / 6) * confirmations)}); - console.log('confirmations: ' + self.confirmations); + console.log('confirmations: ' + confirmations); }); }); From 640abf07add2728994489a0e75073fab0a90c8be Mon Sep 17 00:00:00 2001 From: hunterlester Date: Sun, 11 Dec 2016 23:32:43 -0800 Subject: [PATCH 3/3] fee transaction id appends to submit command, step four complete --- index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 429061a..63ce9e4 100755 --- a/index.html +++ b/index.html @@ -127,8 +127,8 @@ document.getElementById('step_four').click(); document.getElementsByClassName('progress-bar')[0].style.width = "100%"; document.getElementsByClassName('progress-bar')[0].innerText = "Proposal ready for submission"; - - var submitCommand = "gobject submit " + $('#parentHash').val() + " " + $('#revision').val() + " " + $('#time').val() + " " + proposal.gov.serialize() + " " + $(this).val(); + console.log($('#feeTxid').val()); + var submitCommand = "gobject submit " + $('#parentHash').val() + " " + $('#revision').val() + " " + $('#time').val() + " " + proposal.gov.serialize() + " " + $('#feeTxid').val(); console.log(submitCommand); $('textarea#submitProposal').val(submitCommand); }); // callback issued after tx confirmations >= 6