adapt for the request specific amount. Clean comments and code, and more.
This commit is contained in:
parent
2c0432e292
commit
dd59169d5f
4 changed files with 126 additions and 120 deletions
|
|
@ -18,10 +18,10 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
|
||||||
$scope.displayBalanceAsFiat = true;
|
$scope.displayBalanceAsFiat = true;
|
||||||
|
|
||||||
$scope.requestSpecificAmount = function() {
|
$scope.requestSpecificAmount = function() {
|
||||||
sendFlowService.pushState({
|
sendFlowService.start({
|
||||||
toWalletId: $scope.wallet.credentials.walletId
|
toWalletId: $scope.wallet.credentials.walletId,
|
||||||
|
isRequestAmount: true
|
||||||
});
|
});
|
||||||
$state.go('tabs.paymentRequest.amount');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.setAddress = function(newAddr, copyAddress) {
|
$scope.setAddress = function(newAddr, copyAddress) {
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,7 @@ angular.module('copayApp.services').factory('incomingData', function(bitcoinUriS
|
||||||
|
|
||||||
sendFlowService.start(params);
|
sendFlowService.start(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
// data extensions for Payment Protocol with non-backwards-compatible request
|
// data extensions for Payment Protocol with non-backwards-compatible request
|
||||||
if (allParsed.isValid && allParsed.coin && allParsed.url && !allParsed.testnet) {
|
if (allParsed.isValid && allParsed.coin && allParsed.url && !allParsed.testnet) {
|
||||||
var coin = allParsed.coin;
|
var coin = allParsed.coin;
|
||||||
|
|
@ -373,20 +374,12 @@ angular.module('copayApp.services').factory('incomingData', function(bitcoinUriS
|
||||||
};
|
};
|
||||||
|
|
||||||
function goToAmountPage(toAddress, coin) {
|
function goToAmountPage(toAddress, coin) {
|
||||||
$state.go('tabs.send', {}, {
|
|
||||||
'reload': true,
|
|
||||||
'notify': $state.current.name == 'tabs.send' ? false : true
|
|
||||||
});
|
|
||||||
$timeout(function() {
|
|
||||||
var stateParams = {
|
var stateParams = {
|
||||||
toAddress: toAddress,
|
toAddress: toAddress,
|
||||||
displayAddress: toAddress,
|
displayAddress: toAddress,
|
||||||
coin: coin,
|
coin: coin,
|
||||||
noPrefix: 1
|
|
||||||
};
|
};
|
||||||
sendFlowService.pushState(stateParams);
|
sendFlowService.start(stateParams);
|
||||||
$state.transitionTo('tabs.send.origin');
|
|
||||||
}, 100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handlePayPro(payProData, coin) {
|
function handlePayPro(payProData, coin) {
|
||||||
|
|
@ -447,15 +440,7 @@ angular.module('copayApp.services').factory('incomingData', function(bitcoinUriS
|
||||||
}
|
}
|
||||||
|
|
||||||
scannerService.pausePreview();
|
scannerService.pausePreview();
|
||||||
$state.go('tabs.send', {}, {
|
sendFlowService.start(stateParams);
|
||||||
'reload': true,
|
|
||||||
'notify': $state.current.name == 'tabs.send' ? false : true
|
|
||||||
}).then(function() {
|
|
||||||
$timeout(function() {
|
|
||||||
sendFlowService.pushState(stateParams); // Need to do more here
|
|
||||||
$state.transitionTo('tabs.send.origin');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,11 @@ angular
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function start() {
|
function start() {
|
||||||
|
var state = sendFlowStateService.state;
|
||||||
|
|
||||||
|
if (state.isRequestAmount) {
|
||||||
|
$state.go('tabs.paymentRequest.amount');
|
||||||
|
} else {
|
||||||
if ($state.current.name != 'tabs.send') {
|
if ($state.current.name != 'tabs.send') {
|
||||||
$state.go('tabs.home').then(function () {
|
$state.go('tabs.home').then(function () {
|
||||||
$ionicHistory.clearHistory();
|
$ionicHistory.clearHistory();
|
||||||
|
|
@ -40,6 +45,7 @@ angular
|
||||||
goNext();
|
goNext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Strategy
|
* Strategy
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ angular
|
||||||
|
|
||||||
function sendFlowService(
|
function sendFlowService(
|
||||||
sendFlowStateService, sendFlowRouterService
|
sendFlowStateService, sendFlowRouterService
|
||||||
, bitcoinUriService, payproService
|
, bitcoinUriService, payproService, bitcoinCashJsService
|
||||||
, popupService
|
, popupService
|
||||||
, $state
|
, $state
|
||||||
) {
|
) {
|
||||||
|
|
@ -30,11 +30,10 @@ angular
|
||||||
/**
|
/**
|
||||||
* Clears all previous state
|
* Clears all previous state
|
||||||
*/
|
*/
|
||||||
async function start(params) {
|
function start(params) {
|
||||||
console.log('start()');
|
console.log('start()');
|
||||||
|
|
||||||
if (params) {
|
if (params && params.data) {
|
||||||
if (params.data) {
|
|
||||||
var res = bitcoinUriService.parse(params.data);
|
var res = bitcoinUriService.parse(params.data);
|
||||||
|
|
||||||
if (res.isValid) {
|
if (res.isValid) {
|
||||||
|
|
@ -45,7 +44,6 @@ angular
|
||||||
if (res.url) {
|
if (res.url) {
|
||||||
var url = res.url;
|
var url = res.url;
|
||||||
var coin = res.coin || '';
|
var coin = res.coin || '';
|
||||||
await new Promise(function (resolve) {
|
|
||||||
payproService.getPayProDetails(url, coin, function onGetPayProDetails(err, payProData) {
|
payproService.getPayProDetails(url, coin, function onGetPayProDetails(err, payProData) {
|
||||||
if (err) {
|
if (err) {
|
||||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||||
|
|
@ -95,16 +93,40 @@ angular
|
||||||
/**
|
/**
|
||||||
* Resolve
|
* Resolve
|
||||||
*/
|
*/
|
||||||
resolve();
|
_next();
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
if (res.coin) {
|
||||||
|
params.coin = res.coin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (res.amount) {
|
||||||
|
params.amount = res.amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (res.publicAddress) {
|
||||||
|
var prefix = res.testnet ? 'bchtest:' : 'bitcoincash:';
|
||||||
|
params.displayAddress = (prefix + res.publicAddress.cashAddr) || res.publicAddress.legacy || res.publicAddress.bitpay;
|
||||||
|
params.toAddress = bitcoinCashJsService.readAddress(params.displayAddress).legacy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_next();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_next();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_next();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Next used for sync the async task
|
||||||
|
function _next() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init the state if params is defined
|
* Init the state if params is defined
|
||||||
*/
|
*/
|
||||||
|
if (params) {
|
||||||
sendFlowStateService.init(params);
|
sendFlowStateService.init(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -113,6 +135,7 @@ angular
|
||||||
*/
|
*/
|
||||||
sendFlowRouterService.start();
|
sendFlowRouterService.start();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function goNext(state) {
|
function goNext(state) {
|
||||||
/**
|
/**
|
||||||
|
|
@ -121,25 +144,17 @@ angular
|
||||||
state.route = $state.current.name;
|
state.route = $state.current.name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Push the new state
|
* Save the state and redirect the user
|
||||||
*/
|
*/
|
||||||
sendFlowStateService.push(state);
|
sendFlowStateService.push(state);
|
||||||
|
|
||||||
/**
|
|
||||||
* Go next
|
|
||||||
*/
|
|
||||||
sendFlowRouterService.goNext();
|
sendFlowRouterService.goNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
function goBack() {
|
function goBack() {
|
||||||
/**
|
/**
|
||||||
* Pop the current state
|
* Remove the state on top and redirect the user
|
||||||
*/
|
*/
|
||||||
sendFlowStateService.pop();
|
sendFlowStateService.pop();
|
||||||
|
|
||||||
/**
|
|
||||||
* Go back
|
|
||||||
*/
|
|
||||||
sendFlowRouterService.goBack();
|
sendFlowRouterService.goBack();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue