Wallet 2 wallet transfer

This commit is contained in:
Sebastiaan Pasma 2018-07-11 17:31:58 +02:00
commit be32f53668
No known key found for this signature in database
GPG key ID: 9A2B0C8B95A1D26F
2 changed files with 41 additions and 76 deletions

View file

@ -45,12 +45,42 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
return;
}
updateHasFunds();
updateWalletsList();
updateContactsList(function() {
updateList();
});
});
var walletToWalletFrom = false;
var walletToWalletTo = false;
$scope.onWalletSelect = function(wallet) {
if (!$scope.walletToWalletFrom) {
$scope.walletToWalletFrom = wallet;
$scope.walletSelectorTitle = gettextCatalog.getString('Send to');
$timeout(function(){
$scope.showWallets = true;
}, 200);
} else {
$scope.walletToWalletTo = wallet;
walletService.getAddress($scope.walletToWalletFrom, true, function(err, addr) {
return $state.transitionTo('tabs.send.amount', {
displayAddress: $scope.walletToWalletFrom.coin === 'bch' ? bitcoinCashJsService.translateAddresses(addr).cashaddr : addr,
fromWalletId: $scope.walletToWalletFrom.walletId,
toAddress: addr,
coin: $scope.walletToWalletFrom.coin
});
});
}
};
$scope.showWalletSelector = function() {
$scope.walletToWalletFrom = false;
$scope.walletSelectorTitle = gettextCatalog.getString('Send from');
$scope.showWallets = true;
};
$scope.findContact = function(search) {
if (incomingData.redir(search)) {
@ -80,11 +110,6 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
$scope.hasWallets = lodash.isEmpty($scope.wallets) ? false : true;
};
// THIS is ONLY to show the 'buy bitcoins' message
// does not has any other function.
var updateHasFunds = function() {
if ($rootScope.everHasFunds) {
@ -119,52 +144,6 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
});
};
var updateWalletsList = function() {
var config = configService.getSync();
var networkResult = lodash.countBy($scope.wallets, 'network');
$scope.showTransferCard = $scope.hasWallets && (networkResult.livenet > 1 || networkResult.testnet > 1);
if ($scope.showTransferCard) {
var walletsToTransfer = $scope.wallets;
if (!(networkResult.livenet > 1)) {
walletsToTransfer = lodash.filter(walletsToTransfer, function(item) {
return item.network == 'testnet';
});
}
if (!(networkResult.testnet > 1)) {
walletsToTransfer = lodash.filter(walletsToTransfer, function(item) {
return item.network == 'livenet';
});
}
var walletList = [];
lodash.each(walletsToTransfer, function(v) {
var displayBalanceAsFiat =
// BD got v.status as undefined here once during development, just
// after creating a new wallet.
v.status &&
v.status.alternativeBalanceAvailable &&
config.wallet.settings.priceDisplay === 'fiat';
walletList.push({
color: v.color,
name: v.name,
recipientType: 'wallet',
coin: v.coin,
network: v.network,
balanceString: displayBalanceAsFiat ?
v.status.totalBalanceAlternative + ' ' + v.status.alternativeIsoCode :
v.cachedBalance,
getAddress: function(cb) {
walletService.getAddress(v, false, cb);
},
});
});
originalList = originalList.concat(walletList);
}
}
var updateContactsList = function(cb) {
var config = configService.getSync();
var defaults = configService.getDefaults();

View file

@ -22,7 +22,7 @@
</button>
</div>
<div class="col-60">
<button class="button button-standard button-primary button-outline">
<button class="button button-standard button-primary button-outline" ng-click="showWalletSelector()">
<img src="img/icon-w2w.svg"/><br/>
<span translate>Wallet to Wallet Transfer</span>
</button>
@ -113,28 +113,14 @@
</div>
</div>
</div>
<!--<div class="card" ng-if="showTransferCard && hasFunds">-->
<!--<div class="item item-icon-right item-heading" ng-click="toggle('transferToWallet')">-->
<!--<span translate>Transfer to Wallet</span>-->
<!--<i class="icon bp-arrow-up" ng-show="sectionDisplay.transferToWallet"></i>-->
<!--<i class="icon bp-arrow-down" ng-show="!sectionDisplay.transferToWallet"></i>-->
<!--</div>-->
<!--<div class="list" ng-show="sectionDisplay.transferToWallet">-->
<!--<a class="item item-icon-left item-icon-right"-->
<!--ng-repeat="item in list"-->
<!--ng-if="hasWallets && item.recipientType == 'wallet'"-->
<!--ng-click="goToAmount(item)">-->
<!--<i class="icon big-icon-svg" ng-if="item.recipientType == 'wallet'" ng-init="wallet = item"-->
<!--ng-include="'views/includes/walletIcon.html'"></i>-->
<!--{{item.name}}-->
<!--<p>-->
<!--<span>{{item.balanceString}}</span>-->
<!--</p>-->
<!--<i class="icon bp-arrow-right"></i>-->
<!--</a>-->
<!--</div>-->
<!--</div>-->
</ion-content>
<wallet-selector
wallet-selector-title="walletSelectorTitle"
wallet-selector-hide-titles="true"
wallet-selector-wallets="wallets"
wallet-selector-selected-wallet="wallet"
wallet-selector-show="showWallets"
wallet-selector-on-select="onWalletSelect"
wallet-selector-display-balance-as-fiat="displayBalanceAsFiat">
</wallet-selector>
</ion-view>