Fix History from URI. Fix paypro. Fix join

This commit is contained in:
Gustavo Maximiliano Cortez 2016-09-17 18:04:54 -03:00
commit d46a53c404
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
5 changed files with 82 additions and 53 deletions

View file

@ -13,37 +13,33 @@
<div class="card list">
<div class="row">
<div class="col">
<label class="item item-input item-stacked-label no-border">
<span class="input-label" translate>Your nickname</span>
<input type="text"
placeholder="{{'John'|translate}}"
name="myName"
ng-model="myName"
ng-required="true">
</label>
</div>
</div>
<label class="item item-input item-stacked-label no-border">
<span class="input-label" translate>Your nickname</span>
<input type="text"
placeholder="{{'John'|translate}}"
name="myName"
ng-model="myName"
ng-required="true">
</label>
<div class="row">
<div class="col col-90">
<label class="item item-input item-stacked-label no-border">
<span class="input-label" translate>Wallet Invitation</span>
<i class="icon ion-checkmark-circled balanced" ng-show="joinForm.secret.$valid && !joinForm.secret.$pristine && secret"></i>
<i class="icon ion-close-circled assertive" ng-show="joinForm.secret.$invalid && !joinForm.secret.$pristine && secret"></i>
<input id="secret"
type="text"
placeholder="{{'Paste invitation here'|translate}}"
name="secret"
ng-model="secret"
wallet-secret required>
</label>
<label class="item item-input item-stacked-label no-border">
<span class="input-label" translate>Wallet Invitation</span>
<div class="input-notification">
<i class="icon ion-checkmark-circled balanced"
ng-show="!joinForm.secret.$invalid"></i>
<i class="icon ion-close-circled assertive"
ng-show="joinForm.secret.$invalid && secret"></i>
</div>
<div class="col text-center">
<div class="qr-scan-icon">
<qr-scanner class="qr-icon size-24" on-scan="join.onQrCodeScanned(data)"></qr-scanner>
<input id="secret"
type="text"
placeholder="{{'Paste invitation here'|translate}}"
name="secret"
ng-model="secret"
wallet-secret required>
</div>
</div>
</label>
<ion-toggle ng-model="showAdv" toggle-class="toggle-stable">
<span translate ng-show="!showAdv">Show advanced options</span>

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('addressbookViewController', function($scope, $state, $timeout, $stateParams, lodash, addressbookService, popupService) {
angular.module('copayApp.controllers').controller('addressbookViewController', function($scope, $state, $timeout, $stateParams, lodash, addressbookService, popupService, $ionicHistory) {
var address = $stateParams.address;
@ -26,9 +26,10 @@ angular.module('copayApp.controllers').controller('addressbookViewController', f
});
$scope.sendTo = function() {
$state.go('^.^.send');
$ionicHistory.clearHistory();
$state.go('tabs.send');
$timeout(function() {
$state.go('.amount', {
$state.transitionTo('tabs.send.amount', {
toAddress: $scope.addressbookEntry.address,
toName: $scope.addressbookEntry.name,
toEmail: $scope.addressbookEntry.email

View file

@ -1,8 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('amountController', function($rootScope, $scope, $filter, $timeout, $ionicHistory, $ionicScrollDelegate, $ionicNavBarDelegate, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService) {
angular.module('copayApp.controllers').controller('amountController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, $ionicNavBarDelegate, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService) {
$ionicNavBarDelegate.title(gettextCatalog.getString('Enter Amount'));
$ionicNavBarDelegate.showBackButton(true);
var unitToSatoshi;
var satToUnit;

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, $ionicNavBarDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, $ionicPopup, gettext, txFormatService, ongoingProcess, $ionicModal, popupService) {
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, $ionicNavBarDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, $ionicPopup, gettext, txFormatService, ongoingProcess, $ionicModal, $ionicHistory, popupService) {
$ionicNavBarDelegate.title(gettextCatalog.getString('Confirm'));
var cachedTxp = {};
var isChromeApp = platformInfo.isChromeApp;
@ -77,6 +77,13 @@ angular.module('copayApp.controllers').controller('confirmController', function(
};
$scope.init = function() {
if ($stateParams.paypro) {
return setFromPayPro($stateParams.paypro, function(err) {
if (err && !isChromeApp) {
showAlert(gettext('Could not fetch payment'));
}
});
}
// TODO (URL , etc)
if (!$stateParams.toAddress || !$stateParams.toAmount) {
$log.error('Bad params at amount')
@ -261,7 +268,8 @@ angular.module('copayApp.controllers').controller('confirmController', function(
if (err) return;
walletService.publishAndSign(wallet, txp, function(err, txp) {
if (err) return setSendError(err);
$state.transitionTo('tabs.home');
$ionicHistory.clearHistory();
$state.go('tabs.home');
});
});
};

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.services').factory('incomingData', function($log, $ionicModal, $state, $window, bitcore) {
angular.module('copayApp.services').factory('incomingData', function($log, $ionicModal, $state, $window, $timeout, bitcore) {
var root = {};
@ -26,7 +26,11 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni
// data extensions for Payment Protocol with non-backwards-compatible request
if ((/^bitcoin:\?r=[\w+]/).exec(data)) {
data = decodeURIComponent(data.replace('bitcoin:?r=', ''));
$state.go('tabs.send.confirm', {paypro: data})
$state.go('tabs.send');
$timeout(function() {
$state.transitionTo('tabs.send.confirm', {paypro: data});
}, 100);
return true;
}
@ -41,44 +45,65 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni
var amount = parsed.amount ? parsed.amount : '';
if (parsed.r) {
$state.go('tabs.send.confirm', {paypro: parsed.r});
} else {
if (amount) {
$state.go('tabs.send.confirm', {toAmount: amount, toAddress: addr, description:message})
$state.go('tabs.send');
$timeout(function() {
if (parsed.r) {
$state.transitionTo('tabs.send.confirm', {paypro: parsed.r});
} else {
$state.go('tabs.send.amount', {toAddress: addr})
if (amount) {
$state.transitionTo('tabs.send.confirm', {toAmount: amount, toAddress: addr, description:message});
} else {
$state.transitionTo('tabs.send.amount', {toAddress: addr});
}
}
}
}, 100);
return true;
// Plain URL
} else if (/^https?:\/\//.test(data)) {
return $state.go('tabs.send.confirm', {paypro: data})
$state.go('tabs.send');
$timeout(function() {
$state.transitionTo('tabs.send.confirm', {paypro: data});
}, 100);
return true;
// Plain Address
} else if (bitcore.Address.isValid(data, 'livenet')) {
return $state.go('tabs.send.amount', {toAddress: data})
$state.go('tabs.send');
$timeout(function() {
$state.transitionTo('tabs.send.amount', {toAddress: data});
}, 100);
return true;
} else if (bitcore.Address.isValid(data, 'testnet')) {
return $state.go('tabs.send.amount', {toAddress: data})
$state.go('tabs.send');
$timeout(function() {
$state.transitionTo('tabs.send.amount', {toAddress: data});
}, 100);
return true;
// Protocol
} else if (data.indexOf($window.appConfig.name + '://glidera')==0) {
return $state.go('uriglidera', {url: data})
return $state.go('uriglidera', {url: data});
} else if (data.indexOf($window.appConfig.name + '://coinbase')==0) {
return $state.go('uricoinbase', {url: data})
return $state.go('uricoinbase', {url: data});
// Join
} else if (data.match(/^copay:[0-9A-HJ-NP-Za-km-z]{70,80}$/)) {
return $state.go('tabs.add.join', {url: data})
$state.go('tabs.home');
$timeout(function() {
$state.transitionTo('tabs.add.join', {url: data});
}, 100);
return true;
// Old join
} else if (data.match(/^[0-9A-HJ-NP-Za-km-z]{70,80}$/)) {
return $state.go('tabs.add.join', {url: data})
$state.go('tabs.home');
$timeout(function() {
$state.transitionTo('tabs.add.join', {url: data});
}, 100);
return true;
}
return false;
};