t upshMerge branch 'ref/design' of github.com:matiu/copay into ref/design
This commit is contained in:
commit
72fa77dbef
2 changed files with 3 additions and 17 deletions
|
|
@ -95,11 +95,6 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.state('disclaimer', {
|
|
||||||
url: '/disclaimer',
|
|
||||||
templateUrl: 'views/disclaimer.html',
|
|
||||||
})
|
|
||||||
|
|
||||||
.state('unsupported', {
|
.state('unsupported', {
|
||||||
url: '/unsupported',
|
url: '/unsupported',
|
||||||
templateUrl: 'views/unsupported.html'
|
templateUrl: 'views/unsupported.html'
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,6 @@
|
||||||
angular.module('copayApp.services').factory('addressbookService', function(bitcore, storageService, lodash) {
|
angular.module('copayApp.services').factory('addressbookService', function(bitcore, storageService, lodash) {
|
||||||
var root = {};
|
var root = {};
|
||||||
|
|
||||||
var getNetwork = function(addr) {
|
|
||||||
var Address = bitcore.Address;
|
|
||||||
if (Address.isValid(addr, 'livenet')) {
|
|
||||||
return 'livenet';
|
|
||||||
}
|
|
||||||
if (Address.isValid(addr, 'testnet')) {
|
|
||||||
return 'testnet';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
root.getLabel = function(addr, cb) {
|
root.getLabel = function(addr, cb) {
|
||||||
storageService.getAddressbook('testnet', function(err, ab) {
|
storageService.getAddressbook('testnet', function(err, ab) {
|
||||||
if (ab && ab[addr]) return cb(ab[addr]);
|
if (ab && ab[addr]) return cb(ab[addr]);
|
||||||
|
|
@ -41,11 +31,12 @@ angular.module('copayApp.services').factory('addressbookService', function(bitco
|
||||||
};
|
};
|
||||||
|
|
||||||
root.add = function(entry, cb) {
|
root.add = function(entry, cb) {
|
||||||
var network = getNetwork(entry.address);
|
var network = (new bitcore.Address(entry.address)).network.name;
|
||||||
storageService.getAddressbook(network, function(err, ab) {
|
storageService.getAddressbook(network, function(err, ab) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
if (ab) ab = JSON.parse(ab);
|
if (ab) ab = JSON.parse(ab);
|
||||||
ab = ab || {};
|
ab = ab || {};
|
||||||
|
if (lodash.isArray(ab)) ab = {}; // No array
|
||||||
if (ab[entry.address]) return cb('Entry already exist');
|
if (ab[entry.address]) return cb('Entry already exist');
|
||||||
ab[entry.address] = entry.label;
|
ab[entry.address] = entry.label;
|
||||||
storageService.setAddressbook(network, JSON.stringify(ab), function(err, ab) {
|
storageService.setAddressbook(network, JSON.stringify(ab), function(err, ab) {
|
||||||
|
|
@ -58,7 +49,7 @@ angular.module('copayApp.services').factory('addressbookService', function(bitco
|
||||||
};
|
};
|
||||||
|
|
||||||
root.remove = function(addr, cb) {
|
root.remove = function(addr, cb) {
|
||||||
var network = getNetwork(addr);
|
var network = (new bitcore.Address(addr)).network.name;
|
||||||
storageService.getAddressbook(network, function(err, ab) {
|
storageService.getAddressbook(network, function(err, ab) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
if (ab) ab = JSON.parse(ab);
|
if (ab) ab = JSON.parse(ab);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue