show first 5 addresses with balance
This commit is contained in:
parent
7e7fedc402
commit
b676c5e37e
3 changed files with 31 additions and 13 deletions
|
|
@ -1,11 +1,22 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('addressesController', function($scope, $stateParams, $timeout, $ionicScrollDelegate, ongoingProcess, lodash, profileService, walletService) {
|
angular.module('copayApp.controllers').controller('addressesController', function($scope, $stateParams, $timeout, $ionicScrollDelegate, configService, popupService, gettextCatalog, ongoingProcess, lodash, profileService, walletService) {
|
||||||
var ADDRESS_LIMIT = 5;
|
var ADDRESS_LIMIT = 5;
|
||||||
|
var config;
|
||||||
|
var unitName;
|
||||||
|
var unitToSatoshi;
|
||||||
|
var satToUnit;
|
||||||
|
var unitDecimals;
|
||||||
$scope.wallet = profileService.getWallet($stateParams.walletId);
|
$scope.wallet = profileService.getWallet($stateParams.walletId);
|
||||||
$scope.showInfo = false;
|
$scope.showInfo = false;
|
||||||
|
|
||||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||||
|
config = configService.getSync().wallet.settings;
|
||||||
|
unitToSatoshi = config.unitToSatoshi;
|
||||||
|
satToUnit = 1 / unitToSatoshi;
|
||||||
|
unitName = config.unitName;
|
||||||
|
unitDecimals = config.unitDecimals;
|
||||||
|
|
||||||
// $scope.unusedAddresses = getUnusedAddreses(); No backend support TODO
|
// $scope.unusedAddresses = getUnusedAddreses(); No backend support TODO
|
||||||
$scope.unusedAddresses = [{
|
$scope.unusedAddresses = [{
|
||||||
createdOn: 1479138140,
|
createdOn: 1479138140,
|
||||||
|
|
@ -14,17 +25,17 @@ angular.module('copayApp.controllers').controller('addressesController', functio
|
||||||
}];
|
}];
|
||||||
|
|
||||||
ongoingProcess.set('extractingWalletInfo', true);
|
ongoingProcess.set('extractingWalletInfo', true);
|
||||||
walletService.getMainAddresses($scope.wallet, ADDRESS_LIMIT, function(err, addresses) {
|
walletService.getBalance($scope.wallet, {}, function(err, resp) {
|
||||||
ongoingProcess.set('extractingWalletInfo', false);
|
ongoingProcess.set('extractingWalletInfo', false);
|
||||||
$scope.addresses = lodash.map(addresses, function(addr) {
|
if (err) {
|
||||||
return {
|
return popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||||
createdOn: addr.createdOn,
|
}
|
||||||
address: addr.address,
|
|
||||||
path: addr.path.replace(/^m/g, 'xpub')
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log($scope.addresses);
|
$scope.addresses = lodash.slice(resp.byAddress, 0, ADDRESS_LIMIT);
|
||||||
|
lodash.each($scope.addresses, function(a) {
|
||||||
|
a.balanceStr = (a.amount * satToUnit).toFixed(unitDecimals) + ' ' + unitName;
|
||||||
|
});
|
||||||
|
$scope.$digest();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -784,6 +784,13 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
root.getBalance = function(wallet, opts, cb) {
|
||||||
|
opts = opts || {};
|
||||||
|
wallet.getBalance(opts, function(err, resp) {
|
||||||
|
return cb(err, resp);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
root.getAddress = function(wallet, forceNew, cb) {
|
root.getAddress = function(wallet, forceNew, cb) {
|
||||||
storageService.getLastAddress(wallet.id, function(err, addr) {
|
storageService.getLastAddress(wallet.id, function(err, addr) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,10 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-if="unusedAddresses[0]">
|
<div ng-if="unusedAddresses[0]">
|
||||||
<div class="item" ng-repeat="uAddr in unusedAddresses track by $index">
|
<div class="item" ng-repeat="uAddress in unusedAddresses track by $index">
|
||||||
{{uAddr.address}}
|
{{uAddress.address}}
|
||||||
<span class="item-note">
|
<span class="item-note">
|
||||||
{{uAddr.path}} {{uAddr.createdOn * 1000 | amDateFormat:'MMMM Do YYYY, hh:mm a'}}
|
{{uAddress.path}} {{uAddress.createdOn * 1000 | amDateFormat:'MMMM Do YYYY, hh:mm a'}}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue