mirror of
https://github.com/seigler/govobject-proposal
synced 2025-07-27 06:46:10 +00:00
fix merge conflicts
This commit is contained in:
commit
4bfb68c151
3 changed files with 115 additions and 2 deletions
28
index.html
28
index.html
|
@ -26,19 +26,26 @@
|
||||||
<script src="js/transactionListener.js"></script>
|
<script src="js/transactionListener.js"></script>
|
||||||
<script src="js/formHandler.js"></script>
|
<script src="js/formHandler.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<script src="https://dev-test.dash.org/socket.io/socket.io.js"></script>
|
<script src="https://dev-test.dash.org/socket.io/socket.io.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
var Bitcore = require('bitcore-lib-dash');
|
var Bitcore = require('bitcore-lib-dash');
|
||||||
var provider = 'https://dev-test.dash.org:3001/';
|
var provider = 'https://dev-test.dash.org/';
|
||||||
|
|
||||||
|
var socket = io(provider);
|
||||||
|
|
||||||
|
socket.on('connect', function() {
|
||||||
|
socket.emit('subscribe', 'inv');
|
||||||
|
console.log("socket.io initialized...");
|
||||||
|
});
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var gov = new Bitcore.GovObject.Proposal();
|
var gov = new Bitcore.GovObject.Proposal();
|
||||||
gov.network = 'testnet';
|
gov.network = 'testnet';
|
||||||
|
|
||||||
var paymentCycle = new PaymentCycle(gov);
|
var paymentCycle = new PaymentCycle(gov);
|
||||||
|
|
||||||
paymentCycle.updateDropdowns(); // update dropdown menus based on network and current time
|
paymentCycle.updateDropdowns(); // update dropdown menus based on network and current time
|
||||||
|
|
||||||
$("#time").val(Math.floor((new Date).getTime() / 1000));
|
$("#time").val(Math.floor((new Date).getTime() / 1000));
|
||||||
|
@ -89,6 +96,23 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#feeTxid').on('input', function() {
|
||||||
|
|
||||||
|
var transaction = $(this).val();
|
||||||
|
var txListener = new TXListener(socket, provider, transaction);
|
||||||
|
|
||||||
|
// check if tx exists in insight
|
||||||
|
txListener.getTx(function(err, res) {
|
||||||
|
if(err) console.log(err);
|
||||||
|
if(res) {
|
||||||
|
console.log(res);
|
||||||
|
txListener.blockheight = res.blockheight;
|
||||||
|
txListener.confirmations = res.confirmations;
|
||||||
|
txListener.initSocket();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
function transactionListener(proposal) {
|
function transactionListener(proposal) {
|
||||||
|
|
||||||
$('#feeTxid').on('input', function() {
|
$('#feeTxid').on('input', function() {
|
||||||
|
|
||||||
|
$('.walletCommands#walletCommandsSubmit').removeClass('hidden');
|
||||||
|
|
||||||
if ($(this).val().length > 0) {
|
if ($(this).val().length > 0) {
|
||||||
|
|
||||||
var submitCommand = "gobject submit " + $('#parentHash').val() + " " + $('#revision').val() + " " + $('#time').val() + " " + proposal.gov.serialize() + " " + $(this).val();
|
var submitCommand = "gobject submit " + $('#parentHash').val() + " " + $('#revision').val() + " " + $('#time').val() + " " + proposal.gov.serialize() + " " + $(this).val();
|
||||||
|
@ -28,9 +31,11 @@ function transactionListener(proposal) {
|
||||||
$.getJSON(provider + 'insight-api-dash/tx/' + txidfield.val(), function(data) {
|
$.getJSON(provider + 'insight-api-dash/tx/' + txidfield.val(), function(data) {
|
||||||
txidfield.attr("disabled", true);
|
txidfield.attr("disabled", true);
|
||||||
$('.walletCommands#walletCommandsProgress').removeClass('hidden');
|
$('.walletCommands#walletCommandsProgress').removeClass('hidden');
|
||||||
|
|
||||||
document.getElementById('step_three').click();
|
document.getElementById('step_three').click();
|
||||||
document.getElementsByClassName('progress-bar')[0].style.width = "75%";
|
document.getElementsByClassName('progress-bar')[0].style.width = "75%";
|
||||||
document.getElementsByClassName('progress-bar')[0].innerText = "Awaiting network confirmations...";
|
document.getElementsByClassName('progress-bar')[0].innerText = "Awaiting network confirmations...";
|
||||||
|
|
||||||
var txid = data.tx;
|
var txid = data.tx;
|
||||||
var confirmations = data.confirmations;
|
var confirmations = data.confirmations;
|
||||||
var conftxt;
|
var conftxt;
|
||||||
|
@ -129,6 +134,7 @@ function transactionListener(proposal) {
|
||||||
progbarval = 100;
|
progbarval = 100;
|
||||||
$("#progresstxt").text("Your transaction has " + confirmations + " confirmations. You can now submit the proposal.");
|
$("#progresstxt").text("Your transaction has " + confirmations + " confirmations. You can now submit the proposal.");
|
||||||
$('.walletCommands#walletCommandsSubmit').removeClass('hidden');
|
$('.walletCommands#walletCommandsSubmit').removeClass('hidden');
|
||||||
|
|
||||||
document.getElementById('step_four').click();
|
document.getElementById('step_four').click();
|
||||||
document.getElementsByClassName('progress-bar')[0].style.width = "100%";
|
document.getElementsByClassName('progress-bar')[0].style.width = "100%";
|
||||||
document.getElementsByClassName('progress-bar')[0].innerText = "Success";
|
document.getElementsByClassName('progress-bar')[0].innerText = "Success";
|
||||||
|
|
83
js/txListener.js
Executable file
83
js/txListener.js
Executable file
|
@ -0,0 +1,83 @@
|
||||||
|
function TXListener(socket, provider, transaction) {
|
||||||
|
|
||||||
|
this.socket = socket;
|
||||||
|
this.provider = provider;
|
||||||
|
this.transaction = transaction;
|
||||||
|
|
||||||
|
this.blockheight = null;
|
||||||
|
this.confirmations = null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TXListener.prototype.initSocket = function() {
|
||||||
|
var self = this;
|
||||||
|
var socket = this.socket;
|
||||||
|
|
||||||
|
socket.on('block', function(data) {
|
||||||
|
console.log('block: '+ data);
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
console.log('confirmations: ' + self.confirmations);
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
TXListener.prototype.getTx = function(cb) {
|
||||||
|
var txid = this.transaction;
|
||||||
|
|
||||||
|
var opts = {
|
||||||
|
type: "GET",
|
||||||
|
route: "insight-api-dash/tx/"+txid,
|
||||||
|
data: {
|
||||||
|
format: "json"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this._fetch(opts, cb);
|
||||||
|
};
|
||||||
|
|
||||||
|
TXListener.prototype.getBlock = function(hash, cb) {
|
||||||
|
|
||||||
|
var opts = {
|
||||||
|
type: "GET",
|
||||||
|
route: "insight-api-dash/block/"+hash,
|
||||||
|
data: {
|
||||||
|
format: "json"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this._fetch(opts, cb);
|
||||||
|
};
|
||||||
|
|
||||||
|
TXListener.prototype._fetch = function(opts,cb) {
|
||||||
|
var self = this;
|
||||||
|
var provider = opts.provider || self.provider;
|
||||||
|
|
||||||
|
if(opts.type && opts.route && opts.data) {
|
||||||
|
|
||||||
|
jQuery.ajax({
|
||||||
|
type: opts.type,
|
||||||
|
url: provider + opts.route,
|
||||||
|
data: JSON.stringify(opts.data),
|
||||||
|
contentType: "application/json; charset=utf-8",
|
||||||
|
crossDomain: true,
|
||||||
|
dataType: "json",
|
||||||
|
success: function (data, status, jqXHR) {
|
||||||
|
cb(null, data);
|
||||||
|
},
|
||||||
|
error: function (jqXHR, status, error) {
|
||||||
|
var err = eval("(" + jqXHR.responseText + ")");
|
||||||
|
cb(err, null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
cb('missing parameter',null);
|
||||||
|
}
|
||||||
|
};
|
Loading…
Add table
Add a link
Reference in a new issue