added bitcoin and bitcoin cash aliases to config and use them everywhere
This commit is contained in:
parent
a358ea69f3
commit
a730c8e2d2
9 changed files with 41 additions and 12 deletions
|
|
@ -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(),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -310,7 +308,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
||||||
$scope.alternativeAmount = txFormatService.formatAmount(a * unitToSatoshi, true);
|
$scope.alternativeAmount = txFormatService.formatAmount(a * unitToSatoshi, true);
|
||||||
} else {
|
} else {
|
||||||
if (result) {
|
if (result) {
|
||||||
$scope.alternativeAmount = 'N/A';
|
$scope.alternativeAmount = 'N/A';
|
||||||
} else {
|
} else {
|
||||||
$scope.alternativeAmount = null;
|
$scope.alternativeAmount = null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
<i class="icon"><img src="img/icon-warning.png" width="20px"></i>
|
<i class="icon"><img src="img/icon-warning.png" width="20px"></i>
|
||||||
<span class="comment" translate>Amount too low to spend</span>
|
<span class="comment" translate>Amount too low to spend</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-show="btx.action == 'sent'" class="ellipsis">
|
<div ng-show="btx.action == 'sent'" class="ellipsis">
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue