display wallet icon, m&n, account number - refactor

This commit is contained in:
Javier 2017-01-04 19:22:33 -03:00 committed by Matias Alejo Garcia
parent 57251c0b31
commit 6fc0ed2327
No known key found for this signature in database
GPG Key ID: 02470DB551277AB3
3 changed files with 24 additions and 31 deletions

View File

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.services')
.factory('hwWallet', function($log, bwcService) {
.factory('hwWallet', function($log, bwcService) {
var root = {};
// Ledger magic number to get xPub without user confirmation
@ -11,8 +11,7 @@ angular.module('copayApp.services')
root.LIVENET_PATH = 0;
root._err = function(data) {
var msg = 'Hardware Wallet Error: ' + (data.error || data.message || 'unknown');
$log.warn(msg);
var msg = data.error || data.message || 'unknown';
return msg;
};
@ -21,13 +20,13 @@ angular.module('copayApp.services')
if (!isMultisig) return root.UNISIG_ROOTPATH;
// Compat
if (device == 'ledger' && account ==0) return root.UNISIG_ROOTPATH;
if (device == 'ledger' && account == 0) return root.UNISIG_ROOTPATH;
return root.MULTISIG_ROOTPATH;
};
root.getAddressPath = function(device, isMultisig, account) {
return root.getRootPath(device,isMultisig,account) + "'/" + root.LIVENET_PATH + "'/" + account + "'";
return root.getRootPath(device, isMultisig, account) + "'/" + root.LIVENET_PATH + "'/" + account + "'";
}
root.getEntropyPath = function(device, isMultisig, account) {
@ -35,9 +34,9 @@ angular.module('copayApp.services')
// Old ledger wallet compat
if (device == 'ledger' && account == 0)
return root.ENTROPY_INDEX_PATH + "0'";
return root.ENTROPY_INDEX_PATH + "0'";
return root.ENTROPY_INDEX_PATH + root.getRootPath(device,isMultisig,account) + "'/" + account + "'";
return root.ENTROPY_INDEX_PATH + root.getRootPath(device, isMultisig, account) + "'/" + account + "'";
};
root.pubKeyToEntropySource = function(xPubKey) {

View File

@ -17,7 +17,7 @@ angular.module('copayApp.services')
if (!data.success)
return callback(hwWallet._err(data));
return callback(null, hwWallet.pubKeyToEntropySource(data.xpubkey));
return callback(null, hwWallet.pubKeyToEntropySource(data.xpubkey));
});
};
@ -27,21 +27,18 @@ angular.module('copayApp.services')
root._messageAfterSession({
command: "get_xpubkey",
path: path
})
});
};
root.getInfoForNewWallet = function(isMultisig, account, callback) {
var opts = {};
root.getEntropySource(isMultisig, account, function(err, entropySource) {
if (err) return callback(err);
opts.entropySource = entropySource;
root.getXPubKey(hwWallet.getAddressPath('ledger', isMultisig, account), function(data) {
if (!data.success) {
$log.warn(data.message);
return callback(data);
}
if (!data.success) return callback(data);
var opts = {};
opts.entropySource = entropySource;
opts.extendedPublicKey = data.xpubkey;
opts.externalSource = 'ledger';
opts.account = account;
@ -130,7 +127,7 @@ angular.module('copayApp.services')
root._should_poll_session = false;
} else if (typeof root.callbacks[data.command] == "function") {
root.callbacks[data.command](data);
}
} else {}
} else {
root._should_poll_session = false;
Object.keys(root.callbacks).forEach(function(key) {

View File

@ -1,19 +1,16 @@
<span ng-show="wallet.isShared" class="size-12"><span translate>{{wallet.m}}-of-{{wallet.n}}</span></span>
<span ng-show="wallet.isSingleAddress" class="size-12"><span translate>Auditable</span></span>
<img style="height:0.6em; margin-right: 1px;" ng-show="wallet.network != 'livenet'" src="img/icon-testnet-white.svg">
<img style="height:0.6em; margin-right: 1px;" ng-show="!wallet.canSign() && !wallet.isPrivKeyExternal()"
src="img/icon-read-only-white.svg">
<span ng-show="wallet.status.wallet.singleAddress" class="size-12"><span translate>Auditable</span></span>
<img style="height:0.6em; margin-right: 1px;" ng-show="wallet.network != 'livenet'" src="img/icon-testnet-white.svg">
<img style="height:0.6em; margin-right: 1px;" ng-show="!wallet.canSign() && !wallet.isPrivKeyExternal()" src="img/icon-read-only-white.svg">
<img style="height:0.6em; margin-right: 1px;" ng-show="wallet.getPrivKeyExternalSourceName() == 'trezor'"
src="img/icon-trezor-white.svg">
<img style="height:0.6em; margin-right: 1px;" ng-show="wallet.getPrivKeyExternalSourceName() == 'ledger'"
src="img/icon-ledger-white.svg">
<span class="size-12 dib" style="height:0.6em; margin-right: 1px;" ng-show="wallet.account">#{{wallet.account || 0}} </span>
<img style="height:0.6em; margin-right: 1px;" ng-show="wallet.getPrivKeyExternalSourceName() == 'trezor'" src="img/icon-trezor-white.svg">
<img style="height:0.6em; margin-right: 1px;" ng-show="wallet.getPrivKeyExternalSourceName() == 'ledger'" src="img/icon-ledger-white.svg">
<span ng-show="wallet.credentials.n > 1" class="size-12"><span translate>{{wallet.m}}-of-{{wallet.n}}</span></span>
<span class="size-12 dib" style="height:0.6em; margin-right: 1px;" ng-show="wallet.credentials.account">#{{wallet.credentials.account || 0}} </span>
<img style="height:0.6em; margin-right: 1px;" ng-show="wallet.isPrivKeyEncrypted()" src="img/icon-lock-white.svg">
<img style="height:0.6em; margin-right: 1px;" ng-show="wallet.isPrivKeyEncrypted()" src="img/icon-lock-white.svg">
<!-- <img style="height:1em" ng&#45;show="wallet.preferences.email" src="img/icon&#45;email.svg"> -->
<img style="height:0.6em; margin-right: 1px;" ng-show="wallet.usingCustomBWS" src="img/icon-bws-white.svg">
<!-- <img style="height:1em" ng&#45;show="wallet.preferences.email" src="img/icon&#45;email.svg"> -->
<img style="height:0.6em; margin-right: 1px;" ng-show="wallet.usingCustomBWS" src="img/icon-bws-white.svg">
<img style="height:0.6em" ng-show="updatingTxHistory" src="img/icon-sync-white.svg">
<img style="height:0.6em" ng-show="updatingTxHistory" src="img/icon-sync-white.svg">