added bitcoin and bitcoin cash aliases to config and use them everywhere

This commit is contained in:
Kadir Sekha 2017-11-01 16:26:42 +09:00
commit a730c8e2d2
9 changed files with 41 additions and 12 deletions

View file

@ -27,7 +27,8 @@ angular.module('copayApp.controllers').controller('amountController', function($
var config = configService.getSync().wallet.settings; var config = configService.getSync().wallet.settings;
function setAvailableUnits() { function setAvailableUnits() {
var defaults = configService.getDefaults();
var configCache = configService.getSync();
availableUnits = []; availableUnits = [];
var hasBTCWallets = profileService.getWallets({ var hasBTCWallets = profileService.getWallets({
@ -38,22 +39,19 @@ angular.module('copayApp.controllers').controller('amountController', function($
availableUnits.push({ availableUnits.push({
name: 'Bitcoin', name: 'Bitcoin',
id: 'btc', id: 'btc',
shortName: 'BTC', shortName: (configCache.bitcoinAlias || defaults.bitcoinAlias).toUpperCase(),
}); });
} }
var hasBCHWallets = profileService.getWallets({ var hasBCHWallets = profileService.getWallets({
coin: 'bch' coin: 'bch'
}).length; }).length;
if (hasBCHWallets) { if (hasBCHWallets) {
availableUnits.push({ availableUnits.push({
name: 'Bitcoin Cash', name: 'Bitcoin Cash',
id: 'bch', id: 'bch',
shortName: 'BCH', shortName: (configCache.bitcoinCashAlias || defaults.bitcoinCashAlias).toUpperCase(),
}); });
}; };

View file

@ -24,12 +24,15 @@ angular.module('copayApp.controllers').controller('createController',
$scope.$on("$ionicView.beforeEnter", function(event, data) { $scope.$on("$ionicView.beforeEnter", function(event, data) {
$scope.formData = {}; $scope.formData = {};
var config = configService.getSync(); var config = configService.getSync();
var defaults = configService.getDefaults();
var tc = $state.current.name == 'tabs.add.create-personal' ? 1 : defaults.wallet.totalCopayers; var tc = $state.current.name == 'tabs.add.create-personal' ? 1 : defaults.wallet.totalCopayers;
$scope.formData.account = 1; $scope.formData.account = 1;
$scope.formData.bwsurl = data.stateParams.coin == 'btc' ? defaults.bws.url : defaults.bwscash.url; $scope.formData.bwsurl = data.stateParams.coin == 'btc' ? defaults.bws.url : defaults.bwscash.url;
$scope.TCValues = lodash.range(2, defaults.limits.totalCopayers + 1); $scope.TCValues = lodash.range(2, defaults.limits.totalCopayers + 1);
$scope.formData.derivationPath = derivationPathHelper.default; $scope.formData.derivationPath = derivationPathHelper.default;
$scope.formData.coin = data.stateParams.coin; $scope.formData.coin = data.stateParams.coin;
$scope.bitcoinAlias = (config.bitcoinAlias || defaults.bitcoinAlias).toUpperCase();
$scope.bitcoinCashAlias = (config.bitcoinCashAlias || defaults.bitcoinCashAlias).toUpperCase();
if (config.cashSupport) $scope.enableCash = true; if (config.cashSupport) $scope.enableCash = true;

View file

@ -23,6 +23,9 @@ angular.module('copayApp.controllers').controller('importController',
value: false value: false
}; };
$scope.bitcoinAlias = (config.bitcoinAlias || defaults.bitcoinAlias).toUpperCase();
$scope.bitcoinCashAlias = (config.bitcoinCashAlias || defaults.bitcoinCashAlias).toUpperCase();
if (config.cashSupport) $scope.enableCash = true; if (config.cashSupport) $scope.enableCash = true;
if ($stateParams.code) if ($stateParams.code)

View file

@ -13,6 +13,8 @@ angular.module('copayApp.controllers').controller('joinController',
$scope.formData.account = 1; $scope.formData.account = 1;
$scope.formData.secret = null; $scope.formData.secret = null;
$scope.formData.coin = data.stateParams.coin; $scope.formData.coin = data.stateParams.coin;
$scope.bitcoinAlias = (config.bitcoinAlias || defaults.bitcoinAlias).toUpperCase();
$scope.bitcoinCashAlias = (config.bitcoinCashAlias || defaults.bitcoinCashAlias).toUpperCase();
if (config.cashSupport) $scope.enableCash = true; if (config.cashSupport) $scope.enableCash = true;
resetPasswordFields(); resetPasswordFields();
updateSeedSourceSelect(); updateSeedSourceSelect();

View file

@ -180,6 +180,8 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
$scope.updateTxHistoryError = true; $scope.updateTxHistoryError = true;
return; return;
} }
applyCurrencyAliases(txHistory);
$scope.completeTxHistory = txHistory; $scope.completeTxHistory = txHistory;
$scope.showHistory(); $scope.showHistory();
$timeout(function() { $timeout(function() {
@ -190,6 +192,19 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
}); });
}; };
function applyCurrencyAliases(txHistory) {
var defaults = configService.getDefaults();
var configCache = configService.getSync();
lodash.each(txHistory, function(t) {
t.amountUnitStr = $scope.wallet.coin == 'btc'
? (configCache.bitcoinAlias || defaults.bitcoinAlias)
: (configCache.bitcoinCashAlias || defaults.bitcoinCashAlias);
t.amountUnitStr = t.amountUnitStr.toUpperCase();
});
}
$scope.showHistory = function() { $scope.showHistory = function() {
if ($scope.completeTxHistory) { if ($scope.completeTxHistory) {
$scope.txHistory = $scope.completeTxHistory.slice(0, (currentTxHistoryPage + 1) * HISTORY_SHOW_LIMIT); $scope.txHistory = $scope.completeTxHistory.slice(0, (currentTxHistoryPage + 1) * HISTORY_SHOW_LIMIT);

View file

@ -104,6 +104,9 @@ angular.module('copayApp.services').factory('configService', function(storageSer
log: { log: {
filter: 'debug', filter: 'debug',
}, },
bitcoinAlias: 'btc',
bitcoinCashAlias: 'bcc'
}; };
var configCache = null; var configCache = null;

View file

@ -18,8 +18,13 @@ angular.module('copayApp.services').factory('txFormatService', function($filter,
}; };
root.formatAmountStr = function(coin, satoshis) { root.formatAmountStr = function(coin, satoshis) {
var defaults = configService.getDefaults();
var configCache = configService.getSync();
var c = coin == 'btc' ? (configCache.bitcoinAlias || defaults.bitcoinAlias)
: (configCache.bitcoinCashAlias || defaults.bitcoinCashAlias);
if (isNaN(satoshis)) return; if (isNaN(satoshis)) return;
return root.formatAmount(satoshis) + ' ' + (coin).toUpperCase(); return root.formatAmount(satoshis) + ' ' + (c).toUpperCase();
}; };
root.toFiat = function(coin, satoshis, code, cb) { root.toFiat = function(coin, satoshis, code, cb) {

View file

@ -3,7 +3,7 @@
Coin Coin
</div> </div>
<select ng-model="formData.coin" ng-change="coinChanged()"> <select ng-model="formData.coin" ng-change="coinChanged()">
<option value="btc">BTC</option> <option value="btc">{{bitcoinAlias}}</option>
<option value="bch">BCH</option> <option value="bch">{{bitcoinCashAlias}}</option>
</select> </select>
</label> </label>

View file

@ -65,7 +65,7 @@
(possible double spend) (possible double spend)
</span> </span>
<span ng-if="btx.action != 'invalid'"> <span ng-if="btx.action != 'invalid'">
{{btx.amountStr}} {{btx.amountValueStr}} {{btx.amountUnitStr}}
</span> </span>
</span> </span>
<div> <div>