From 17431e29c510af0e03fbcc114fe71b4ce414a66b Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Sun, 20 Apr 2014 21:23:53 -0300 Subject: [PATCH 1/2] fix set sent --- js/models/core/TxProposals.js | 9 +++++---- js/models/core/Wallet.js | 6 ++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/js/models/core/TxProposals.js b/js/models/core/TxProposals.js index e056d9e8f..26935583b 100644 --- a/js/models/core/TxProposals.js +++ b/js/models/core/TxProposals.js @@ -29,6 +29,11 @@ TxProposal.prototype.toObj = function() { return o; }; + +TxProposal.prototype.setSent = function() { + this.sentTs = Date.now();; +}; + TxProposal.fromObj = function(o) { var t = new TxProposal(o); var b = new Builder.fromObj(o.builderObj); @@ -36,10 +41,6 @@ TxProposal.fromObj = function(o) { return t; }; -TxProposal.setSent = function() { - this.sentTs = Date.now();; -}; - TxProposal.getSentTs = function() { return this.sentTs; }; diff --git a/js/models/core/Wallet.js b/js/models/core/Wallet.js index 45e62301b..e368850c3 100644 --- a/js/models/core/Wallet.js +++ b/js/models/core/Wallet.js @@ -348,8 +348,14 @@ Wallet.prototype.sendTx = function(ntxid) { var self = this; this.blockchain.sendRawTransaction(txHex, function(txid) { self.log('BITCOND txid:',txid); //TODO + +console.log('[Wallet.js.351]'); //TODO if (txid) { +console.log('[Wallet.js.354]',self); //TODO self.txProposals.setSent(ntxid); + +console.log('[Wallet.js.353]', self.txProposals); //TODO + self.sendTxProposals(); self.store(); } From 616429a355de0b60fc2bd844d3fc52d41daad1d8 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Sun, 20 Apr 2014 21:53:54 -0300 Subject: [PATCH 2/2] fixes in ux --- index.html | 10 +++++++++- js/controllers/transactions.js | 26 +++++++++++++++++++------- js/models/core/TxProposals.js | 2 +- js/models/core/Wallet.js | 14 ++++---------- 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/index.html b/index.html index 0aaa11793..f88cd7e19 100644 --- a/index.html +++ b/index.html @@ -286,6 +286,13 @@
+ + Transaction ready. + + + Sent at {{tx.sentTs | date:'medium'}} @@ -299,8 +306,8 @@
-
+
diff --git a/js/controllers/transactions.js b/js/controllers/transactions.js index c140160b0..39bf65282 100644 --- a/js/controllers/transactions.js +++ b/js/controllers/transactions.js @@ -43,6 +43,7 @@ console.log('[transactions.js.10:_updateTxs:]'); //TODO }); $scope.txs = txs; console.log('[transactions.js.55] SET HANDL+'); //TODO + w.removeListener('txProposalsUpdated',_updateTxs) w.once('txProposalsUpdated',_updateTxs); }; @@ -58,6 +59,20 @@ console.log('[transactions.js.55] SET HANDL+'); //TODO socket.on('connect', controllerUtils.handleTransactionByAddress($scope)); } + + $scope.send = function (ntxid) { + var w = $rootScope.wallet; + w.sendTx(ntxid, function(txid) { +console.log('[transactions.js.68:txid:] SENTTX CALLBACK',txid); //TODO + $rootScope.flashMessage = txid + ? {type:'success', message: 'Transactions SENT! txid:' + txid} + : {type:'error', message: 'There was an error sending the Transaction'} + ; + _updateTxs(); + $rootScope.$digest(); + }); + }; + $scope.sign = function (ntxid) { var w = $rootScope.wallet; var ret = w.sign(ntxid); @@ -65,19 +80,16 @@ console.log('[transactions.js.55] SET HANDL+'); //TODO var p = w.getTxProposal(ntxid); if (p.txp.builder.isFullySigned()) { - w.sendTx(ntxid, function(txid) { - $rootScope.flashMessage = txid - ? {type:'success', message: 'Transactions SENT! txid:' + txid} - : {type:'error', message: 'There was an error sending the Transaction'} - ; - }); + $scope.send(ntxid); } else { $rootScope.flashMessage = ret ? {type:'success', message: 'Transactions signed'} : {type:'error', message: 'There was an error signing the Transaction'} ; + _updateTxs(); + $rootScope.$digest(); } - _updateTxs(); }; + }); diff --git a/js/models/core/TxProposals.js b/js/models/core/TxProposals.js index 26935583b..28f9dadbe 100644 --- a/js/models/core/TxProposals.js +++ b/js/models/core/TxProposals.js @@ -19,7 +19,7 @@ function TxProposal(opts) { this.seenBy = opts.seenBy || {}; this.signedBy = opts.signedBy || {}; this.builder = opts.builder; - this.sentTs = null; + this.sentTs = opts.sentTs || null; } TxProposal.prototype.toObj = function() { diff --git a/js/models/core/Wallet.js b/js/models/core/Wallet.js index e368850c3..e82bff825 100644 --- a/js/models/core/Wallet.js +++ b/js/models/core/Wallet.js @@ -334,7 +334,7 @@ Wallet.prototype.sign = function(ntxid) { return ret; }; -Wallet.prototype.sendTx = function(ntxid) { +Wallet.prototype.sendTx = function(ntxid, cb) { var txp = this.txProposals.txps[ntxid]; if (!txp) return; @@ -348,18 +348,12 @@ Wallet.prototype.sendTx = function(ntxid) { var self = this; this.blockchain.sendRawTransaction(txHex, function(txid) { self.log('BITCOND txid:',txid); //TODO - -console.log('[Wallet.js.351]'); //TODO if (txid) { -console.log('[Wallet.js.354]',self); //TODO self.txProposals.setSent(ntxid); - -console.log('[Wallet.js.353]', self.txProposals); //TODO - - self.sendTxProposals(); - self.store(); } - return (txid); + self.sendTxProposals(); + self.store(); + return cb(txid); }); };