From ce22e10806523a690abfedd3b112b672eeeaf230 Mon Sep 17 00:00:00 2001 From: blavenie <benoit.lavenier@e-is.pro> Date: Thu, 25 Aug 2016 08:49:54 +0200 Subject: [PATCH] - Wallet: fix #115 and #109 (pending TX always appears in error) - ES : registry : fix #116 (display send monney button if a pubkey has been set) --- www/js/services/wallet-services.js | 21 ++++++++----------- .../es/js/services/registry-services.js | 2 +- .../es/templates/registry/view_record.html | 8 ++----- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/www/js/services/wallet-services.js b/www/js/services/wallet-services.js index 08e64ea6d..cd0c792c6 100644 --- a/www/js/services/wallet-services.js +++ b/www/js/services/wallet-services.js @@ -326,13 +326,10 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser // Get transactions BMA.tx.sources({pubkey: data.pubkey}) .then(function(res){ - if (!data.sources) { - data.sources=[]; - } var sources = []; var sourcesIndexByKey = []; var balance = 0; - if (!!res.sources && res.sources.length > 0) { + if (res.sources) { _.forEach(res.sources, function(src) { var srcKey = src.type+':'+src.identifier+':'+src.noffset; src.consumed = false; @@ -442,23 +439,23 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser var balance = data.balance; _.forEach(data.tx.history, function(tx) { // process TX history - var uid = uids[tx.pubkey]; - tx.uid = (uid ? uid : null); + tx.uid = uids[tx.pubkey] || null; }); _.forEach(data.tx.pendings, function(tx) { // process TX pendings - var uid = uids[tx.pubkey]; - tx.uid = (uid ? uid : null); + tx.uid = uids[tx.pubkey] || null; var sources = []; var valid = true; - if (tx.issuer !== data.pubkey) { // do not check sources from received TX + if (tx.amount > 0) { // do not check sources from received TX valid = false; + // TODO get sources from the issuer ? } else { _.forEach(tx.inputs, function(input) { - var srcIndex = data.sourcesIndexByKey[input]; - if (srcIndex !== undefined) { + var inputKey = input.split(':').slice(2).join(':'); + var srcIndex = data.sourcesIndexByKey[inputKey]; + if (!angular.isUndefined(srcIndex)) { sources.push(data.sources[srcIndex]); } else { @@ -843,7 +840,7 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser locktime: 0, block_number: null }); - store(); // save the wallet + store(); // save pendings in local storage resolve(result); }).catch(function(err){reject(err);}); }); diff --git a/www/plugins/es/js/services/registry-services.js b/www/plugins/es/js/services/registry-services.js index 656e98760..154f37ea2 100644 --- a/www/plugins/es/js/services/registry-services.js +++ b/www/plugins/es/js/services/registry-services.js @@ -8,7 +8,7 @@ angular.module('cesium.es.registry.services', ['ngResource', 'cesium.services', var categories = [], fields = { - commons: ["category", "title", "description", "issuer", "time", "address", "city", "thumbnail", "picturesCount", "type", "socials"], + commons: ["category", "title", "description", "issuer", "time", "address", "city", "thumbnail", "picturesCount", "type", "socials", "pubkey"], comment: { commons: ["issuer", "time", "message"], } diff --git a/www/plugins/es/templates/registry/view_record.html b/www/plugins/es/templates/registry/view_record.html index 78c090d32..3901696fe 100644 --- a/www/plugins/es/templates/registry/view_record.html +++ b/www/plugins/es/templates/registry/view_record.html @@ -149,13 +149,9 @@ </ion-content> <button class="button button-fab button-fab-bottom-right button-assertive icon ion-android-send visible-xs visible-sm" - ng-click="transfer(formData.issuer, formData.title)"> + ng-if="formData.pubkey" + ng-click="showTransferModal({pubkey: formData.pubkey, uid: formData.title})"> </button> - <button class="button button-fab button-fab-bottom-right button-assertive icon ion-ribbon-b visible-xs visible-sm" - ng-click="certifyIdentity()" - ng-if="hasSelf" - style="bottom:78px;"> - </button> </ion-view> -- GitLab