Glidera
This commit is contained in:
parent
ea3ea2686f
commit
ecdc3d2057
19 changed files with 1127 additions and 931 deletions
|
|
@ -1,26 +1,89 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('buyGlideraController',
|
||||
function($scope, $timeout, $ionicModal, profileService, addressService, glideraService, bwcError, lodash, ongoingProcess) {
|
||||
function($scope, $timeout, $log, $ionicModal, profileService, walletService, glideraService, bwcError, lodash, ongoingProcess) {
|
||||
|
||||
var wallet;
|
||||
var self = this;
|
||||
this.show2faCodeInput = null;
|
||||
this.error = null;
|
||||
this.success = null;
|
||||
|
||||
this.init = function(testnet) {
|
||||
self.allWallets = profileService.getWallets(testnet ? 'testnet' : 'livenet');
|
||||
$scope.init = function(accessToken) {
|
||||
$scope.network = glideraService.getEnvironment();
|
||||
|
||||
var client = profileService.focusedClient;
|
||||
if (client) {
|
||||
$scope.token = accessToken;
|
||||
$scope.error = null;
|
||||
$scope.permissions = null;
|
||||
$scope.email = null;
|
||||
$scope.personalInfo = null;
|
||||
$scope.txs = null;
|
||||
$scope.status = null;
|
||||
$scope.limits = null;
|
||||
|
||||
ongoingProcess.set('connectingGlidera', true);
|
||||
glideraService.init($scope.token, function(err, glidera) {
|
||||
ongoingProcess.set('connectingGlidera');
|
||||
if (err || !glidera) {
|
||||
$scope.error = err;
|
||||
return;
|
||||
}
|
||||
$scope.token = glidera.token;
|
||||
$scope.permissions = glidera.permissions;
|
||||
$scope.update({fullUpdate: true});
|
||||
});
|
||||
|
||||
self.allWallets = profileService.getWallets({
|
||||
network: $scope.network,
|
||||
n: 1,
|
||||
onlyComplete: true
|
||||
});
|
||||
if (lodash.isEmpty(self.allWallets)) return;
|
||||
|
||||
wallet = self.allWallets[0];
|
||||
if (wallet) {
|
||||
$timeout(function() {
|
||||
self.selectedWalletId = client.credentials.walletId;
|
||||
self.selectedWalletName = client.credentials.walletName;
|
||||
self.selectedWalletId = wallet.credentials.walletId;
|
||||
self.selectedWalletName = wallet.credentials.walletName;
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
}
|
||||
};
|
||||
|
||||
$scope.update = function(opts) {
|
||||
if (!$scope.token || !$scope.permissions) return;
|
||||
$log.debug('Updating Glidera Account...');
|
||||
var accessToken = $scope.token;
|
||||
var permissions = $scope.permissions;
|
||||
|
||||
opts = opts || {};
|
||||
|
||||
glideraService.getStatus(accessToken, function(err, data) {
|
||||
$scope.status = data;
|
||||
});
|
||||
|
||||
glideraService.getLimits(accessToken, function(err, limits) {
|
||||
$scope.limits = limits;
|
||||
});
|
||||
|
||||
if (permissions.transaction_history) {
|
||||
glideraService.getTransactions(accessToken, function(err, data) {
|
||||
$scope.txs = data;
|
||||
});
|
||||
}
|
||||
|
||||
if (permissions.view_email_address && opts.fullUpdate) {
|
||||
glideraService.getEmail(accessToken, function(err, data) {
|
||||
$scope.email = data.email;
|
||||
});
|
||||
}
|
||||
if (permissions.personal_info && opts.fullUpdate) {
|
||||
glideraService.getPersonalInfo(accessToken, function(err, data) {
|
||||
$scope.personalInfo = data;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.openWalletsModal = function(wallets) {
|
||||
self.error = null;
|
||||
|
||||
|
|
@ -39,9 +102,9 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
|
|||
|
||||
$scope.$on('walletSelected', function(ev, walletId) {
|
||||
$timeout(function() {
|
||||
var client = profileService.getClient(walletId);
|
||||
wallet = profileService.getClient(walletId);
|
||||
self.selectedWalletId = walletId;
|
||||
self.selectedWalletName = client.credentials.walletName;
|
||||
self.selectedWalletName = wallet.credentials.walletName;
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
$scope.walletsModal.hide();
|
||||
|
|
@ -87,7 +150,7 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
|
|||
self.error = null;
|
||||
ongoingProcess.set('Buying Bitcoin...', true);
|
||||
$timeout(function() {
|
||||
addressService.getAddress(self.selectedWalletId, false, function(err, walletAddr) {
|
||||
walletService.getAddress(wallet, false, function(err, walletAddr) {
|
||||
if (err) {
|
||||
ongoingProcess.set('Buying Bitcoin...', false);
|
||||
self.error = bwcError.cb(err, 'Could not create address');
|
||||
|
|
|
|||
|
|
@ -1,33 +1,98 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('glideraController',
|
||||
function($rootScope, $scope, $timeout, $ionicModal, profileService, configService, storageService, glideraService, lodash, ongoingProcess, platformInfo) {
|
||||
function($rootScope, $scope, $timeout, $ionicModal, $log, profileService, storageService, glideraService, lodash, ongoingProcess, platformInfo, nodeWebkit) {
|
||||
|
||||
if (platformInfo.isCordova && StatusBar.isVisible) {
|
||||
StatusBar.backgroundColorByHexString("#4B6178");
|
||||
}
|
||||
|
||||
$scope.openExternalLink = function(url, target) {
|
||||
if (platformInfo.isNW) {
|
||||
nodeWebkit.openExternalLink(url);
|
||||
} else {
|
||||
target = target || '_blank';
|
||||
var ref = window.open(url, target, 'location=no');
|
||||
}
|
||||
};
|
||||
|
||||
$scope.init = function(accessToken) {
|
||||
$scope.network = glideraService.getEnvironment();
|
||||
|
||||
$scope.token = null;
|
||||
$scope.error = null;
|
||||
$scope.permissions = null;
|
||||
$scope.email = null;
|
||||
$scope.personalInfo = null;
|
||||
$scope.txs = null;
|
||||
$scope.status = null;
|
||||
$scope.limits = null;
|
||||
|
||||
ongoingProcess.set('connectingGlidera', true);
|
||||
glideraService.init($scope.token, function(err, glidera) {
|
||||
ongoingProcess.set('connectingGlidera');
|
||||
if (err || !glidera) {
|
||||
$scope.error = err;
|
||||
return;
|
||||
}
|
||||
$scope.token = glidera.token;
|
||||
$scope.permissions = glidera.permissions;
|
||||
$scope.update({fullUpdate: true});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.update = function(opts) {
|
||||
if (!$scope.token || !$scope.permissions) return;
|
||||
$log.debug('Updating Glidera Account...');
|
||||
var accessToken = $scope.token;
|
||||
var permissions = $scope.permissions;
|
||||
|
||||
opts = opts || {};
|
||||
|
||||
glideraService.getStatus(accessToken, function(err, data) {
|
||||
$scope.status = data;
|
||||
});
|
||||
|
||||
glideraService.getLimits(accessToken, function(err, limits) {
|
||||
$scope.limits = limits;
|
||||
});
|
||||
|
||||
if (permissions.transaction_history) {
|
||||
glideraService.getTransactions(accessToken, function(err, data) {
|
||||
$scope.txs = data;
|
||||
});
|
||||
}
|
||||
|
||||
if (permissions.view_email_address && opts.fullUpdate) {
|
||||
glideraService.getEmail(accessToken, function(err, data) {
|
||||
$scope.email = data.email;
|
||||
});
|
||||
}
|
||||
if (permissions.personal_info && opts.fullUpdate) {
|
||||
glideraService.getPersonalInfo(accessToken, function(err, data) {
|
||||
$scope.personalInfo = data;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
this.getAuthenticateUrl = function() {
|
||||
return glideraService.getOauthCodeUrl();
|
||||
};
|
||||
|
||||
this.submitOauthCode = function(code) {
|
||||
var self = this;
|
||||
var glideraTestnet = configService.getSync().glidera.testnet;
|
||||
var network = glideraTestnet ? 'testnet' : 'livenet';
|
||||
ongoingProcess.set('connectingGlidera', true);
|
||||
this.error = null;
|
||||
$scope.error = null;
|
||||
$timeout(function() {
|
||||
glideraService.getToken(code, function(err, data) {
|
||||
ongoingProcess.set('connectingGlidera', false);
|
||||
if (err) {
|
||||
self.error = err;
|
||||
$scope.error = err;
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
} else if (data && data.access_token) {
|
||||
storageService.setGlideraToken(network, data.access_token, function() {
|
||||
$scope.$emit('Local/GlideraUpdated', data.access_token);
|
||||
storageService.setGlideraToken($scope.network, data.access_token, function() {
|
||||
$scope.init(data.access_token);
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('glideraConfirmationController', function($scope, $timeout, storageService, applicationService) {
|
||||
angular.module('copayApp.controllers').controller('glideraConfirmationController', function($scope, $timeout, $state, glideraService) {
|
||||
|
||||
$scope.ok = function() {
|
||||
storageService.removeGlideraToken($scope.network, function() {
|
||||
glideraService.removeToken(function() {
|
||||
$timeout(function() {
|
||||
applicationService.restart();
|
||||
$state.go('glidera.main');
|
||||
}, 100);
|
||||
});
|
||||
$scope.cancel();
|
||||
|
|
|
|||
|
|
@ -1,43 +1,70 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('preferencesGlideraController',
|
||||
function($scope, $timeout, $ionicModal, profileService, applicationService, glideraService, storageService) {
|
||||
function($scope, $log, $ionicModal, ongoingProcess, glideraService) {
|
||||
|
||||
this.getEmail = function(token) {
|
||||
var self = this;
|
||||
glideraService.getEmail(token, function(error, data) {
|
||||
self.email = data;
|
||||
$scope.init = function(accessToken) {
|
||||
$scope.network = glideraService.getEnvironment();
|
||||
|
||||
$scope.token = accessToken;
|
||||
$scope.error = null;
|
||||
$scope.permissions = null;
|
||||
$scope.email = null;
|
||||
$scope.personalInfo = null;
|
||||
$scope.txs = null;
|
||||
$scope.status = null;
|
||||
$scope.limits = null;
|
||||
|
||||
ongoingProcess.set('connectingGlidera', true);
|
||||
glideraService.init($scope.token, function(err, glidera) {
|
||||
ongoingProcess.set('connectingGlidera');
|
||||
if (err || !glidera) {
|
||||
$scope.error = err;
|
||||
return;
|
||||
}
|
||||
$scope.token = glidera.token;
|
||||
$scope.permissions = glidera.permissions;
|
||||
$scope.update({fullUpdate: true});
|
||||
});
|
||||
};
|
||||
|
||||
this.getPersonalInfo = function(token) {
|
||||
var self = this;
|
||||
glideraService.getPersonalInfo(token, function(error, info) {
|
||||
self.personalInfo = info;
|
||||
$scope.update = function(opts) {
|
||||
if (!$scope.token || !$scope.permissions) return;
|
||||
$log.debug('Updating Glidera Account...');
|
||||
var accessToken = $scope.token;
|
||||
var permissions = $scope.permissions;
|
||||
|
||||
opts = opts || {};
|
||||
|
||||
glideraService.getStatus(accessToken, function(err, data) {
|
||||
$scope.status = data;
|
||||
});
|
||||
|
||||
glideraService.getLimits(accessToken, function(err, limits) {
|
||||
$scope.limits = limits;
|
||||
});
|
||||
|
||||
if (permissions.transaction_history) {
|
||||
glideraService.getTransactions(accessToken, function(err, data) {
|
||||
$scope.txs = data;
|
||||
});
|
||||
}
|
||||
|
||||
if (permissions.view_email_address && opts.fullUpdate) {
|
||||
glideraService.getEmail(accessToken, function(err, data) {
|
||||
$scope.email = data.email;
|
||||
});
|
||||
}
|
||||
if (permissions.personal_info && opts.fullUpdate) {
|
||||
glideraService.getPersonalInfo(accessToken, function(err, data) {
|
||||
$scope.personalInfo = data;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
this.getStatus = function(token) {
|
||||
var self = this;
|
||||
glideraService.getStatus(token, function(error, data) {
|
||||
self.status = data;
|
||||
});
|
||||
};
|
||||
|
||||
this.getLimits = function(token) {
|
||||
var self = this;
|
||||
glideraService.getLimits(token, function(error, limits) {
|
||||
self.limits = limits;
|
||||
});
|
||||
};
|
||||
|
||||
this.revokeToken = function(testnet) {
|
||||
$scope.network = testnet ? 'testnet' : 'livenet';
|
||||
$scope.loading = false;
|
||||
|
||||
$scope.revokeToken = function() {
|
||||
$ionicModal.fromTemplateUrl('views/modals/glidera-confirmation.html', {
|
||||
scope: $scope,
|
||||
animation: 'slide-in-up'
|
||||
scope: $scope
|
||||
}).then(function(modal) {
|
||||
$scope.glideraConfirmationModal = modal;
|
||||
$scope.glideraConfirmationModal.show();
|
||||
|
|
|
|||
|
|
@ -1,38 +1,97 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('sellGlideraController',
|
||||
function($rootScope, $scope, $timeout, $ionicModal, $log, configService, profileService, addressService, feeService, glideraService, bwcError, lodash, walletService, fingerprintService, ongoingProcess, go) {
|
||||
function($rootScope, $scope, $timeout, $ionicModal, $log, profileService, glideraService, bwcError, lodash, walletService, fingerprintService, configService, ongoingProcess) {
|
||||
|
||||
var self = this;
|
||||
var config = configService.getSync();
|
||||
this.data = {};
|
||||
this.show2faCodeInput = null;
|
||||
this.success = null;
|
||||
this.error = null;
|
||||
var client;
|
||||
var wallet;
|
||||
|
||||
var handleEncryptedWallet = function(client, cb) {
|
||||
if (!walletService.isEncrypted(client)) return cb();
|
||||
var handleEncryptedWallet = function(wallet, cb) {
|
||||
if (!walletService.isEncrypted(wallet)) return cb();
|
||||
$rootScope.$emit('Local/NeedsPassword', false, function(err, password) {
|
||||
if (err) return cb(err);
|
||||
return cb(walletService.unlock(client, password));
|
||||
return cb(walletService.unlock(wallet, password));
|
||||
});
|
||||
};
|
||||
|
||||
this.init = function(testnet) {
|
||||
self.allWallets = profileService.getWallets(testnet ? 'testnet' : 'livenet', 1);
|
||||
$scope.init = function(accessToken) {
|
||||
$scope.network = glideraService.getEnvironment();
|
||||
|
||||
client = profileService.focusedClient;
|
||||
if (client && client.credentials.m == 1) {
|
||||
$scope.token = accessToken;
|
||||
$scope.error = null;
|
||||
$scope.permissions = null;
|
||||
$scope.email = null;
|
||||
$scope.personalInfo = null;
|
||||
$scope.txs = null;
|
||||
$scope.status = null;
|
||||
$scope.limits = null;
|
||||
|
||||
ongoingProcess.set('connectingGlidera', true);
|
||||
glideraService.init($scope.token, function(err, glidera) {
|
||||
ongoingProcess.set('connectingGlidera');
|
||||
if (err || !glidera) {
|
||||
$scope.error = err;
|
||||
return;
|
||||
}
|
||||
$scope.token = glidera.token;
|
||||
$scope.permissions = glidera.permissions;
|
||||
$scope.update({fullUpdate: true});
|
||||
});
|
||||
|
||||
self.allWallets = profileService.getWallets({
|
||||
network: $scope.network,
|
||||
n: 1,
|
||||
onlyComplete: true
|
||||
});
|
||||
if (lodash.isEmpty(self.allWallets)) return;
|
||||
|
||||
wallet = self.allWallets[0];
|
||||
if (wallet) {
|
||||
$timeout(function() {
|
||||
self.selectedWalletId = client.credentials.walletId;
|
||||
self.selectedWalletName = client.credentials.walletName;
|
||||
self.selectedWalletId = wallet.credentials.walletId;
|
||||
self.selectedWalletName = wallet.credentials.walletName;
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
}
|
||||
};
|
||||
|
||||
$scope.update = function(opts) {
|
||||
if (!$scope.token || !$scope.permissions) return;
|
||||
$log.debug('Updating Glidera Account...');
|
||||
var accessToken = $scope.token;
|
||||
var permissions = $scope.permissions;
|
||||
|
||||
opts = opts || {};
|
||||
|
||||
glideraService.getStatus(accessToken, function(err, data) {
|
||||
$scope.status = data;
|
||||
});
|
||||
|
||||
glideraService.getLimits(accessToken, function(err, limits) {
|
||||
$scope.limits = limits;
|
||||
});
|
||||
|
||||
if (permissions.transaction_history) {
|
||||
glideraService.getTransactions(accessToken, function(err, data) {
|
||||
$scope.txs = data;
|
||||
});
|
||||
}
|
||||
|
||||
if (permissions.view_email_address && opts.fullUpdate) {
|
||||
glideraService.getEmail(accessToken, function(err, data) {
|
||||
$scope.email = data.email;
|
||||
});
|
||||
}
|
||||
if (permissions.personal_info && opts.fullUpdate) {
|
||||
glideraService.getPersonalInfo(accessToken, function(err, data) {
|
||||
$scope.personalInfo = data;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.openWalletsModal = function(wallets) {
|
||||
self.error = null;
|
||||
|
|
@ -52,9 +111,9 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
|
|||
|
||||
$scope.$on('walletSelected', function(ev, walletId) {
|
||||
$timeout(function() {
|
||||
client = profileService.getClient(walletId);
|
||||
wallet = profileService.getClient(walletId);
|
||||
self.selectedWalletId = walletId;
|
||||
self.selectedWalletName = client.credentials.walletName;
|
||||
self.selectedWalletName = wallet.credentials.walletName;
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
$scope.walletsModal.hide();
|
||||
|
|
@ -98,16 +157,17 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
|
|||
var self = this;
|
||||
self.error = null;
|
||||
var outputs = [];
|
||||
var config = configService.getSync();
|
||||
var configWallet = config.wallet;
|
||||
var walletSettings = configWallet.settings;
|
||||
|
||||
if (!client) {
|
||||
if (!wallet) {
|
||||
self.error = 'No wallet selected';
|
||||
return;
|
||||
}
|
||||
|
||||
ongoingProcess.set('creatingTx', true);
|
||||
addressService.getAddress(client.credentials.walletId, null, function(err, refundAddress) {
|
||||
walletService.getAddress(wallet, null, function(err, refundAddress) {
|
||||
if (!refundAddress) {
|
||||
|
||||
ongoingProcess.clear();
|
||||
|
|
@ -142,71 +202,62 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
|
|||
}
|
||||
};
|
||||
|
||||
walletService.createTx(client, txp, function(err, createdTxp) {
|
||||
walletService.createTx(wallet, txp, function(err, createdTxp) {
|
||||
ongoingProcess.clear();
|
||||
if (err) {
|
||||
self.error = err.message || bwcError.msg(err);
|
||||
return;
|
||||
}
|
||||
$scope.$emit('Local/NeedsConfirmation', createdTxp, function(accept) {
|
||||
if (accept) {
|
||||
fingerprintService.check(client, function(err) {
|
||||
fingerprintService.check(wallet, function(err) {
|
||||
if (err) {
|
||||
self.error = err.message || bwcError.msg(err);
|
||||
return;
|
||||
}
|
||||
|
||||
handleEncryptedWallet(wallet, function(err) {
|
||||
if (err) {
|
||||
self.error = err.message || bwcError.msg(err);
|
||||
return;
|
||||
}
|
||||
|
||||
ongoingProcess.set('signingTx', true);
|
||||
walletService.publishTx(wallet, createdTxp, function(err, publishedTxp) {
|
||||
if (err) {
|
||||
ongoingProcess.clear();
|
||||
self.error = err.message || bwcError.msg(err);
|
||||
return;
|
||||
}
|
||||
|
||||
handleEncryptedWallet(client, function(err) {
|
||||
walletService.signTx(wallet, publishedTxp, function(err, signedTxp) {
|
||||
walletService.lock(wallet);
|
||||
walletService.removeTx(wallet, signedTxp, function(err) {
|
||||
if (err) $log.debug(err);
|
||||
});
|
||||
ongoingProcess.clear();
|
||||
if (err) {
|
||||
self.error = err.message || bwcError.msg(err);
|
||||
return;
|
||||
}
|
||||
|
||||
ongoingProcess.set('signingTx', true);
|
||||
walletService.publishTx(client, createdTxp, function(err, publishedTxp) {
|
||||
var rawTx = signedTxp.raw;
|
||||
var data = {
|
||||
refundAddress: refundAddress,
|
||||
signedTransaction: rawTx,
|
||||
priceUuid: self.sellPrice.priceUuid,
|
||||
useCurrentPrice: self.sellPrice.priceUuid ? false : true,
|
||||
ip: null
|
||||
};
|
||||
ongoingProcess.set('Seling Bitcoin', true);
|
||||
glideraService.sell(token, twoFaCode, data, function(err, data) {
|
||||
ongoingProcess.clear();
|
||||
if (err) {
|
||||
ongoingProcess.clear();
|
||||
self.error = err.message || bwcError.msg(err);
|
||||
return;
|
||||
}
|
||||
|
||||
walletService.signTx(client, publishedTxp, function(err, signedTxp) {
|
||||
walletService.lock(client);
|
||||
walletService.removeTx(client, signedTxp, function(err) {
|
||||
if (err) $log.debug(err);
|
||||
});
|
||||
ongoingProcess.clear();
|
||||
if (err) {
|
||||
self.error = err.message || bwcError.msg(err);
|
||||
return;
|
||||
}
|
||||
var rawTx = signedTxp.raw;
|
||||
var data = {
|
||||
refundAddress: refundAddress,
|
||||
signedTransaction: rawTx,
|
||||
priceUuid: self.sellPrice.priceUuid,
|
||||
useCurrentPrice: self.sellPrice.priceUuid ? false : true,
|
||||
ip: null
|
||||
};
|
||||
ongoingProcess.set('Seling Bitcoin', true);
|
||||
glideraService.sell(token, twoFaCode, data, function(err, data) {
|
||||
ongoingProcess.clear();
|
||||
if (err) {
|
||||
self.error = err.message || bwcError.msg(err);
|
||||
$timeout(function() {
|
||||
$scope.$emit('Local/GlideraError');
|
||||
}, 100);
|
||||
return;
|
||||
}
|
||||
self.success = data;
|
||||
$scope.$emit('Local/GlideraTx');
|
||||
});
|
||||
});
|
||||
self.success = data;
|
||||
$scope.update();
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
go.path('glidera');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -162,10 +162,9 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
|
||||
configService.whenAvailable(function() {
|
||||
var config = configService.getSync();
|
||||
var glideraEnabled = config.glidera.enabled;
|
||||
var coinbaseEnabled = config.coinbase.enabled;
|
||||
var isWindowsPhoneApp = platformInfo.isWP && isCordova;
|
||||
$scope.buyAndSellEnabled = !isWindowsPhoneApp && (glideraEnabled || coinbaseEnabled);
|
||||
$scope.glideraEnabled = config.glidera.enabled && !isWindowsPhoneApp;
|
||||
$scope.coinbaseEnabled = config.coinbase.enabled && !isWindowsPhoneApp;
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
|||
192
src/js/routes.js
192
src/js/routes.js
|
|
@ -103,25 +103,21 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
*/
|
||||
|
||||
.state('uri', {
|
||||
url: '/uri/:url',
|
||||
needProfile: true,
|
||||
views: {
|
||||
'main': {
|
||||
templateUrl: 'views/uri.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('uripayment', {
|
||||
url: '/uri-payment/:url',
|
||||
templateUrl: 'views/paymentUri.html',
|
||||
views: {
|
||||
'main': {
|
||||
templateUrl: 'views/paymentUri.html',
|
||||
},
|
||||
},
|
||||
needProfile: true
|
||||
})
|
||||
|
||||
url: '/uri/:url',
|
||||
templateUrl: 'views/uri.html'
|
||||
})
|
||||
.state('uripayment', {
|
||||
url: '/uri-payment/:url',
|
||||
templateUrl: 'views/paymentUri.html'
|
||||
})
|
||||
.state('uriglidera', {
|
||||
url: '/uri-glidera/:url',
|
||||
templateUrl: 'views/glideraUri.html'
|
||||
})
|
||||
.state('uricoinbase', {
|
||||
url: '/uri-coinbase/:url',
|
||||
templateUrl: 'views/coinbaseUri.html'
|
||||
})
|
||||
|
||||
/*
|
||||
*
|
||||
|
|
@ -528,27 +524,97 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
*
|
||||
* Glidera
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
.state('uriglidera', {
|
||||
url: '/uri-glidera/:url',
|
||||
templateUrl: 'views/glideraUri.html'
|
||||
})
|
||||
.state('glidera', {
|
||||
url: '/glidera',
|
||||
templateUrl: 'views/glidera.html'
|
||||
abstract: true,
|
||||
template: '<ion-nav-view name="glidera"></ion-nav-view>'
|
||||
})
|
||||
.state('buyGlidera', {
|
||||
.state('glidera.main', {
|
||||
url: '/main',
|
||||
views: {
|
||||
'glidera': {
|
||||
templateUrl: 'views/glidera.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('glidera.buy', {
|
||||
url: '/buy',
|
||||
templateUrl: 'views/buyGlidera.html'
|
||||
views: {
|
||||
'glidera': {
|
||||
templateUrl: 'views/buyGlidera.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('sellGlidera', {
|
||||
.state('glidera.sell', {
|
||||
url: '/sell',
|
||||
templateUrl: 'views/sellGlidera.html'
|
||||
views: {
|
||||
'glidera': {
|
||||
templateUrl: 'views/sellGlidera.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('preferencesGlidera', {
|
||||
url: '/preferencesGlidera',
|
||||
templateUrl: 'views/preferencesGlidera.html'
|
||||
.state('glidera.preferences', {
|
||||
url: '/preferences',
|
||||
views: {
|
||||
'glidera': {
|
||||
templateUrl: 'views/preferencesGlidera.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
/*
|
||||
*
|
||||
* Coinbase
|
||||
*
|
||||
*/
|
||||
|
||||
.state('coinbase', {
|
||||
url: '/coinbase',
|
||||
templateUrl: 'views/coinbase.html'
|
||||
})
|
||||
.state('preferencesCoinbase', {
|
||||
url: '/preferencesCoinbase',
|
||||
templateUrl: 'views/preferencesCoinbase.html'
|
||||
})
|
||||
.state('buyCoinbase', {
|
||||
url: '/buycoinbase',
|
||||
templateUrl: 'views/buyCoinbase.html'
|
||||
})
|
||||
.state('sellCoinbase', {
|
||||
url: '/sellcoinbase',
|
||||
templateUrl: 'views/sellCoinbase.html'
|
||||
})
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Amazon Gift Card
|
||||
*
|
||||
*/
|
||||
|
||||
.state('amazon', {
|
||||
url: '/amazon',
|
||||
abstract: true,
|
||||
template: '<ion-nav-view name="amazon"></ion-nav-view>'
|
||||
})
|
||||
.state('amazon.main', {
|
||||
url: '/main',
|
||||
views: {
|
||||
'amazon': {
|
||||
templateUrl: 'views/amazon.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('amazon.buy', {
|
||||
url: '/buy',
|
||||
views: {
|
||||
'amazon': {
|
||||
templateUrl: 'views/buyAmazon.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
/*
|
||||
|
|
@ -577,70 +643,6 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
templateUrl: 'views/preferencesBitpayCard.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
/*
|
||||
*
|
||||
* Coinbase
|
||||
*
|
||||
*/
|
||||
|
||||
.state('coinbase', {
|
||||
url: '/coinbase',
|
||||
templateUrl: 'views/coinbase.html'
|
||||
})
|
||||
.state('preferencesCoinbase', {
|
||||
url: '/preferencesCoinbase',
|
||||
templateUrl: 'views/preferencesCoinbase.html'
|
||||
})
|
||||
.state('uricoinbase', {
|
||||
url: '/uri-coinbase/:url',
|
||||
templateUrl: 'views/coinbaseUri.html'
|
||||
})
|
||||
.state('buyCoinbase', {
|
||||
url: '/buycoinbase',
|
||||
templateUrl: 'views/buyCoinbase.html'
|
||||
})
|
||||
.state('sellCoinbase', {
|
||||
url: '/sellcoinbase',
|
||||
templateUrl: 'views/sellCoinbase.html'
|
||||
})
|
||||
.state('buyandsell', {
|
||||
url: '/buyandsell',
|
||||
templateUrl: 'views/buyAndSell.html',
|
||||
controller: function(platformInfo) {
|
||||
if (platformInfo.isCordova && StatusBar.isVisible) {
|
||||
StatusBar.backgroundColorByHexString("#4B6178");
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
/*
|
||||
*
|
||||
* Amazon Gift Card
|
||||
*
|
||||
*/
|
||||
|
||||
.state('amazon', {
|
||||
url: '/amazon',
|
||||
abstract: true,
|
||||
template: '<ion-nav-view name="amazon"></ion-nav-view>'
|
||||
})
|
||||
.state('amazon.main', {
|
||||
url: '/main',
|
||||
views: {
|
||||
'amazon': {
|
||||
templateUrl: 'views/amazon.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('amazon.buy', {
|
||||
url: '/buy',
|
||||
views: {
|
||||
'amazon': {
|
||||
templateUrl: 'views/buyAmazon.html'
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
.run(function($rootScope, $state, $location, $log, $timeout, $ionicHistory, $ionicPlatform, lodash, platformInfo, profileService, uxLanguage, gettextCatalog) {
|
||||
|
|
|
|||
|
|
@ -123,11 +123,6 @@ angular.module('copayApp.services').factory('configService', function(storageSer
|
|||
configCache.colorFor = configCache.colorFor || {};
|
||||
configCache.aliasFor = configCache.aliasFor || {};
|
||||
|
||||
|
||||
// Glidera
|
||||
// Disabled for testnet
|
||||
configCache.glidera.testnet = false;
|
||||
|
||||
// Coinbase
|
||||
// Disabled for testnet
|
||||
configCache.coinbase.testnet = false;
|
||||
|
|
|
|||
|
|
@ -4,11 +4,15 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
|
|||
var root = {};
|
||||
var credentials = {};
|
||||
var isCordova = platformInfo.isCordova;
|
||||
//
|
||||
//
|
||||
|
||||
root.setCredentials = function(network) {
|
||||
if (network == 'testnet') {
|
||||
var _setCredentials = function() {
|
||||
/*
|
||||
* Development: 'testnet'
|
||||
* Production: 'livenet'
|
||||
*/
|
||||
credentials.NETWORK = 'livenet';
|
||||
|
||||
if (credentials.NETWORK == 'testnet') {
|
||||
credentials.HOST = 'https://sandbox.glidera.io';
|
||||
if (isCordova) {
|
||||
credentials.REDIRECT_URI = 'copay://glidera';
|
||||
|
|
@ -33,11 +37,25 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
|
|||
};
|
||||
};
|
||||
|
||||
root.getEnvironment = function() {
|
||||
_setCredentials();
|
||||
return credentials.NETWORK;
|
||||
};
|
||||
|
||||
root.getOauthCodeUrl = function() {
|
||||
_setCredentials();
|
||||
return credentials.HOST + '/oauth2/auth?response_type=code&client_id=' + credentials.CLIENT_ID + '&redirect_uri=' + credentials.REDIRECT_URI;
|
||||
};
|
||||
|
||||
root.removeToken = function(cb) {
|
||||
_setCredentials();
|
||||
storageService.removeGlideraToken(credentials.NETWORK, function() {
|
||||
return cb();
|
||||
});
|
||||
};
|
||||
|
||||
root.getToken = function(code, cb) {
|
||||
_setCredentials();
|
||||
var req = {
|
||||
method: 'POST',
|
||||
url: credentials.HOST + '/api/v1/oauth/token',
|
||||
|
|
@ -64,6 +82,7 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
|
|||
};
|
||||
|
||||
var _get = function(endpoint, token) {
|
||||
_setCredentials();
|
||||
return {
|
||||
method: 'GET',
|
||||
url: credentials.HOST + '/api/v1' + endpoint,
|
||||
|
|
@ -176,6 +195,7 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
|
|||
};
|
||||
|
||||
var _post = function(endpoint, token, twoFaCode, data) {
|
||||
_setCredentials();
|
||||
return {
|
||||
method: 'POST',
|
||||
url: credentials.HOST + '/api/v1' + endpoint,
|
||||
|
|
@ -251,91 +271,39 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
|
|||
});
|
||||
};
|
||||
|
||||
root.init = function(accessToken) {
|
||||
root.glideraEnabled = configService.getSync().glidera.enabled;
|
||||
root.glideraTestnet = configService.getSync().glidera.testnet;
|
||||
var network = root.glideraTestnet ? 'testnet' : 'livenet';
|
||||
root.init = function(accessToken, cb) {
|
||||
_setCredentials();
|
||||
$log.debug('Init Glidera...');
|
||||
|
||||
root.glideraToken = null;
|
||||
root.glideraError = null;
|
||||
root.glideraPermissions = null;
|
||||
root.glideraEmail = null;
|
||||
root.glideraPersonalInfo = null;
|
||||
root.glideraTxs = null;
|
||||
root.glideraStatus = null;
|
||||
|
||||
if (!root.glideraEnabled) return;
|
||||
|
||||
root.setCredentials(network);
|
||||
var glidera = {
|
||||
token: null,
|
||||
permissions: null
|
||||
}
|
||||
|
||||
var getToken = function(cb) {
|
||||
if (accessToken) {
|
||||
cb(null, accessToken);
|
||||
} else {
|
||||
storageService.getGlideraToken(network, cb);
|
||||
storageService.getGlideraToken(credentials.NETWORK, cb);
|
||||
}
|
||||
};
|
||||
|
||||
getToken(function(err, accessToken) {
|
||||
if (err || !accessToken) return;
|
||||
if (err || !accessToken) return cb();
|
||||
else {
|
||||
root.getAccessTokenPermissions(accessToken, function(err, p) {
|
||||
if (err) {
|
||||
root.glideraError = err;
|
||||
return cb(err);
|
||||
} else {
|
||||
root.glideraToken = accessToken;
|
||||
root.glideraPermissions = p;
|
||||
root.update({
|
||||
fullUpdate: true
|
||||
});
|
||||
glidera.token = accessToken;
|
||||
glidera.permissions = p;
|
||||
return cb(null, glidera);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
root.update = function(opts) {
|
||||
if (!root.glideraToken || !root.glideraPermissions) return;
|
||||
var accessToken = root.glideraToken;
|
||||
var permissions = root.glideraPermissions;
|
||||
|
||||
opts = opts || {};
|
||||
|
||||
root.getStatus(accessToken, function(err, data) {
|
||||
root.glideraStatus = data;
|
||||
});
|
||||
|
||||
root.getLimits(accessToken, function(err, limits) {
|
||||
root.glideraLimits = limits;
|
||||
});
|
||||
|
||||
if (permissions.transaction_history) {
|
||||
root.getTransactions(accessToken, function(err, data) {
|
||||
root.glideraTxs = data;
|
||||
});
|
||||
}
|
||||
|
||||
if (permissions.view_email_address && opts.fullUpdate) {
|
||||
root.getEmail(accessToken, function(err, data) {
|
||||
root.glideraEmail = data.email;
|
||||
});
|
||||
}
|
||||
if (permissions.personal_info && opts.fullUpdate) {
|
||||
root.getPersonalInfo(accessToken, function(err, data) {
|
||||
root.glideraPersonalInfo = data;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
configService.whenAvailable(function() {
|
||||
$log.debug('Init Glidera Service...');
|
||||
root.init();
|
||||
});
|
||||
|
||||
$rootScope.$on('NewBlock', function() {
|
||||
root.update();
|
||||
});
|
||||
|
||||
return root;
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ angular.module('copayApp.services').factory('ongoingProcess', function($log, $ti
|
|||
window.plugins.spinnerDialog.show(null, showName, true);
|
||||
} else {
|
||||
|
||||
var tmpl = '<ion-spinner class="spinner-stable" icon="lines"></ion-spinner>' + showName;
|
||||
var tmpl = '<div class="item-icon-left">' + showName + '<ion-spinner class="spinner-stable" icon="lines"></ion-spinner></div>';
|
||||
$ionicLoading.show({
|
||||
template: tmpl
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1055,3 +1055,14 @@ input[type=number] {
|
|||
}
|
||||
}
|
||||
|
||||
/* Spinner */
|
||||
|
||||
.item-icon-left ion-spinner {
|
||||
float: left;
|
||||
margin-left: -3.2em;
|
||||
margin-right: 1em;
|
||||
margin-top: -0.2em;
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue