removed unused vars + changes for wallet to wallet transfer
This commit is contained in:
parent
4093e2ba71
commit
b88329fbb3
3 changed files with 54 additions and 60 deletions
|
|
@ -10,16 +10,10 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
// Config Related values
|
// Config Related values
|
||||||
var config = configService.getSync();
|
var config = configService.getSync();
|
||||||
var walletConfig = config.wallet;
|
var walletConfig = config.wallet;
|
||||||
var unitToSatoshi = walletConfig.settings.unitToSatoshi;
|
|
||||||
var unitDecimals = walletConfig.settings.unitDecimals;
|
|
||||||
var satToUnit = 1 / unitToSatoshi;
|
|
||||||
var configFeeLevel = walletConfig.settings.feeLevel ? walletConfig.settings.feeLevel : 'normal';
|
var configFeeLevel = walletConfig.settings.feeLevel ? walletConfig.settings.feeLevel : 'normal';
|
||||||
|
|
||||||
|
|
||||||
// Platform info
|
// Platform info
|
||||||
var isChromeApp = platformInfo.isChromeApp;
|
|
||||||
var isCordova = platformInfo.isCordova;
|
var isCordova = platformInfo.isCordova;
|
||||||
var isWindowsPhoneApp = platformInfo.isCordova && platformInfo.isWP;
|
|
||||||
|
|
||||||
//custom fee flag
|
//custom fee flag
|
||||||
var usingCustomFee = false;
|
var usingCustomFee = false;
|
||||||
|
|
@ -31,7 +25,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
}, 10);
|
}, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$scope.showWalletSelector = function() {
|
$scope.showWalletSelector = function() {
|
||||||
$scope.walletSelector = true;
|
$scope.walletSelector = true;
|
||||||
refresh();
|
refresh();
|
||||||
|
|
@ -45,7 +38,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
$ionicConfig.views.swipeBackEnabled(false);
|
$ionicConfig.views.swipeBackEnabled(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function exitWithError(err) {
|
function exitWithError(err) {
|
||||||
$log.info('Error setting wallet selector:' + err);
|
$log.info('Error setting wallet selector:' + err);
|
||||||
popupService.showAlert(gettextCatalog.getString(), bwcError.msg(err), function() {
|
popupService.showAlert(gettextCatalog.getString(), bwcError.msg(err), function() {
|
||||||
|
|
@ -125,49 +117,8 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||||
// Setup $scope
|
$scope.fromWallet = profileService.getWallet(data.stateParams.fromWalletId); // Wallet to send from
|
||||||
|
|
||||||
var B = data.stateParams.coin == 'bch' ? bitcoreCash : bitcore;
|
|
||||||
var networkName;
|
|
||||||
$scope.fromWallet = profileService.getWallet(data.stateParams.fromWalletId);
|
|
||||||
$scope.recipientType = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (data.stateParams.toWalletId) {
|
|
||||||
$scope.recipientType = 'wallet'; // set type to wallet-to-wallet
|
|
||||||
$ionicLoading.show();
|
|
||||||
var wallet = profileService.getWallet(data.stateParams.toWalletId);
|
|
||||||
walletService.getAddress(wallet, true, function (err, addr) {
|
|
||||||
$ionicLoading.hide();
|
|
||||||
data.stateParams.toAddress = addr;
|
|
||||||
networkName = (new B.Address(data.stateParams.toAddress)).network.name;
|
|
||||||
vanityTx(networkName, data);
|
|
||||||
});
|
|
||||||
} else if (data.stateParams.toAddress) {
|
|
||||||
networkName = (new B.Address(data.stateParams.toAddress)).network.name;
|
|
||||||
vanityTx(networkName, data);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
var message = gettextCatalog.getString('Invalid address');
|
|
||||||
var backText = gettextCatalog.getString('Go back');
|
|
||||||
var learnText = gettextCatalog.getString('Learn more');
|
|
||||||
popupService.showConfirm(null, message, backText, learnText, function (back) {
|
|
||||||
$ionicHistory.nextViewOptions({
|
|
||||||
disableAnimate: true,
|
|
||||||
historyRoot: true
|
|
||||||
});
|
|
||||||
$state.go('tabs.send').then(function () {
|
|
||||||
$ionicHistory.clearHistory();
|
|
||||||
if (!back) {
|
|
||||||
var url = 'https://support.bitpay.com/hc/en-us/articles/115004671663';
|
|
||||||
externalLinkService.open(url);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
var vanityTx = function(networkName, data) {
|
|
||||||
// Grab stateParams
|
// Grab stateParams
|
||||||
tx = {
|
tx = {
|
||||||
amount: parseInt(data.stateParams.amount),
|
amount: parseInt(data.stateParams.amount),
|
||||||
|
|
@ -179,10 +130,10 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
|
|
||||||
// Vanity tx info (not in the real tx)
|
// Vanity tx info (not in the real tx)
|
||||||
recipientType: $scope.recipientType || null,
|
recipientType: $scope.recipientType || null,
|
||||||
toName: data.stateParams.toName,
|
toName: null,
|
||||||
toEmail: data.stateParams.toEmail,
|
toEmail: null,
|
||||||
toColor: data.stateParams.toColor,
|
toColor: null,
|
||||||
network: networkName,
|
network: false,
|
||||||
coin: $scope.fromWallet.coin,
|
coin: $scope.fromWallet.coin,
|
||||||
txp: {},
|
txp: {},
|
||||||
};
|
};
|
||||||
|
|
@ -192,10 +143,52 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
tx.feeRate = parseInt(data.stateParams.requiredFeeRate);
|
tx.feeRate = parseInt(data.stateParams.requiredFeeRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tx.coin && tx.coin == 'bch') {
|
if (tx.coin && tx.coin === 'bch') {
|
||||||
tx.feeLevel = 'normal';
|
tx.feeLevel = 'normal';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var B = data.stateParams.coin === 'bch' ? bitcoreCash : bitcore;
|
||||||
|
var networkName;
|
||||||
|
$scope.recipientType = null;
|
||||||
|
try {
|
||||||
|
if (data.stateParams.toWalletId) { // There is a toWalletId, so we presume this is a wallet-to-wallet transfer
|
||||||
|
$scope.recipientType = 'wallet'; // set transaction type to wallet-to-wallet
|
||||||
|
$ionicLoading.show();
|
||||||
|
|
||||||
|
var toWallet = profileService.getWallet(data.stateParams.toWalletId);
|
||||||
|
tx.toColor = toWallet.color;
|
||||||
|
tx.toName = toWallet.name;
|
||||||
|
|
||||||
|
// We need an address to send to, so we ask the walletService to create a new address for the toWallet.
|
||||||
|
walletService.getAddress(toWallet, true, function (err, addr) {
|
||||||
|
$ionicLoading.hide();
|
||||||
|
tx.toAddress = addr;
|
||||||
|
networkName = (new B.Address(tx.toAddress)).network.name;
|
||||||
|
tx.network = networkName;
|
||||||
|
setupTx(tx);
|
||||||
|
});
|
||||||
|
} else { // This is a Wallet-to-address transfer
|
||||||
|
networkName = (new B.Address(tx.toAddress)).network.name;
|
||||||
|
tx.network = networkName;
|
||||||
|
setupTx(tx);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
var message = gettextCatalog.getString('Invalid address');
|
||||||
|
popupService.showAlert(null, message, function () {
|
||||||
|
$ionicHistory.nextViewOptions({
|
||||||
|
disableAnimate: true,
|
||||||
|
historyRoot: true
|
||||||
|
});
|
||||||
|
$state.go('tabs.send').then(function () {
|
||||||
|
$ionicHistory.clearHistory();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var setupTx = function(networkName, data) {
|
||||||
|
|
||||||
// Other Scope vars
|
// Other Scope vars
|
||||||
$scope.isCordova = isCordova;
|
$scope.isCordova = isCordova;
|
||||||
$scope.showAddress = false;
|
$scope.showAddress = false;
|
||||||
|
|
@ -410,19 +403,19 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
function setButtonText(isMultisig, isPayPro) {
|
function setButtonText(isMultisig, isPayPro) {
|
||||||
|
|
||||||
if (isPayPro) {
|
if (isPayPro) {
|
||||||
if (isCordova && !isWindowsPhoneApp) {
|
if (isCordova) {
|
||||||
$scope.buttonText = gettextCatalog.getString('Slide to pay');
|
$scope.buttonText = gettextCatalog.getString('Slide to pay');
|
||||||
} else {
|
} else {
|
||||||
$scope.buttonText = gettextCatalog.getString('Click to pay');
|
$scope.buttonText = gettextCatalog.getString('Click to pay');
|
||||||
}
|
}
|
||||||
} else if (isMultisig) {
|
} else if (isMultisig) {
|
||||||
if (isCordova && !isWindowsPhoneApp) {
|
if (isCordova) {
|
||||||
$scope.buttonText = gettextCatalog.getString('Slide to accept');
|
$scope.buttonText = gettextCatalog.getString('Slide to accept');
|
||||||
} else {
|
} else {
|
||||||
$scope.buttonText = gettextCatalog.getString('Click to accept');
|
$scope.buttonText = gettextCatalog.getString('Click to accept');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (isCordova && !isWindowsPhoneApp) {
|
if (isCordova) {
|
||||||
$scope.buttonText = gettextCatalog.getString('Slide to send');
|
$scope.buttonText = gettextCatalog.getString('Slide to send');
|
||||||
} else {
|
} else {
|
||||||
$scope.buttonText = gettextCatalog.getString('Click to send');
|
$scope.buttonText = gettextCatalog.getString('Click to send');
|
||||||
|
|
|
||||||
|
|
@ -105,13 +105,13 @@
|
||||||
</ion-content>
|
</ion-content>
|
||||||
<click-to-accept
|
<click-to-accept
|
||||||
ng-click="approve(tx, wallet, statusChangeHandler)"
|
ng-click="approve(tx, wallet, statusChangeHandler)"
|
||||||
ng-if="(!isCordova || isWindowsPhoneApp) && wallet"
|
ng-if="(!isCordova) && wallet"
|
||||||
click-send-status="sendStatus"
|
click-send-status="sendStatus"
|
||||||
is-disabled="!wallet">
|
is-disabled="!wallet">
|
||||||
{{buttonText}}
|
{{buttonText}}
|
||||||
</click-to-accept>
|
</click-to-accept>
|
||||||
<slide-to-accept
|
<slide-to-accept
|
||||||
ng-if="isCordova && !isWindowsPhoneApp && wallet"
|
ng-if="isCordova && wallet"
|
||||||
slide-on-confirm="approve(tx, wallet, statusChangeHandler)"
|
slide-on-confirm="approve(tx, wallet, statusChangeHandler)"
|
||||||
slide-send-status="sendStatus"
|
slide-send-status="sendStatus"
|
||||||
is-disabled="!wallet">
|
is-disabled="!wallet">
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
<ion-view id="wallet-origin-destination" show-tabs>
|
<ion-view id="wallet-origin-destination" show-tabs>
|
||||||
<ion-nav-bar class="bar-royal">
|
<ion-nav-bar class="bar-royal">
|
||||||
<ion-nav-title>{{'Wallet to wallet transfer' | translate}}</ion-nav-title>
|
<ion-nav-title>{{'Wallet to wallet transfer' | translate}}</ion-nav-title>
|
||||||
|
<ion-nav-back-button ng-click="goBack()"></ion-nav-back-button>
|
||||||
</ion-nav-bar>
|
</ion-nav-bar>
|
||||||
<ion-content>
|
<ion-content>
|
||||||
<div class="header--request" ng-if="isPaymentRequest">
|
<div class="header--request" ng-if="isPaymentRequest">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue