fiatConversion higher precedence on currencyUnit

fiatConversion higher precedence on currencyUnit
pull/260/head
Shahana Farooqui 4 years ago
parent 2ffc513e77
commit 4c5c38ec1b

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -12,5 +12,5 @@
<link rel="stylesheet" href="styles.913955e0bafa4525ff05.css"></head> <link rel="stylesheet" href="styles.913955e0bafa4525ff05.css"></head>
<body> <body>
<rtl-app></rtl-app> <rtl-app></rtl-app>
<script src="runtime.80956de7b8d3d70e5793.js" defer></script><script src="polyfills-es5.acd0700da9b9f555b1f8.js" nomodule defer></script><script src="polyfills.69620c10d7f64d0a6eb1.js" defer></script><script src="main.b8ed5f83f0d35a4beee7.js" defer></script></body> <script src="runtime.4ff0bbfaf29a3d13cb90.js" defer></script><script src="polyfills-es5.acd0700da9b9f555b1f8.js" nomodule defer></script><script src="polyfills.69620c10d7f64d0a6eb1.js" defer></script><script src="main.6b938c32029d812e186b.js" defer></script></body>
</html> </html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1 +1 @@
!function(e){function r(r){for(var n,a,i=r[0],c=r[1],l=r[2],p=0,s=[];p<i.length;p++)a=i[p],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&s.push(o[a][0]),o[a]=0;for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(e[n]=c[n]);for(f&&f(r);s.length;)s.shift()();return u.push.apply(u,l||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++)0!==o[t[i]]&&(n=!1);n&&(u.splice(r--,1),e=a(a.s=t[0]))}return e}var n={},o={0:0},u=[];function a(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.e=function(e){var r=[],t=o[e];if(0!==t)if(t)r.push(t[2]);else{var n=new Promise((function(r,n){t=o[e]=[r,n]}));r.push(t[2]=n);var u,i=document.createElement("script");i.charset="utf-8",i.timeout=120,a.nc&&i.setAttribute("nonce",a.nc),i.src=function(e){return a.p+""+({}[e]||e)+"."+{1:"05df06d0408441a851d7",6:"16bab1d95279b8901fb6",7:"a845cabd9973c1596925"}[e]+".js"}(e);var c=new Error;u=function(r){i.onerror=i.onload=null,clearTimeout(l);var t=o[e];if(0!==t){if(t){var n=r&&("load"===r.type?"missing":r.type),u=r&&r.target&&r.target.src;c.message="Loading chunk "+e+" failed.\n("+n+": "+u+")",c.name="ChunkLoadError",c.type=n,c.request=u,t[1](c)}o[e]=void 0}};var l=setTimeout((function(){u({type:"timeout",target:i})}),12e4);i.onerror=i.onload=u,document.head.appendChild(i)}return Promise.all(r)},a.m=e,a.c=n,a.d=function(e,r,t){a.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,r){if(1&r&&(e=a(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(a.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)a.d(t,n,(function(r){return e[r]}).bind(null,n));return t},a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,"a",r),r},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.p="",a.oe=function(e){throw console.error(e),e};var i=window.webpackJsonp=window.webpackJsonp||[],c=i.push.bind(i);i.push=r,i=i.slice();for(var l=0;l<i.length;l++)r(i[l]);var f=c;t()}([]); !function(e){function r(r){for(var n,a,i=r[0],c=r[1],f=r[2],p=0,s=[];p<i.length;p++)a=i[p],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&s.push(o[a][0]),o[a]=0;for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(e[n]=c[n]);for(l&&l(r);s.length;)s.shift()();return u.push.apply(u,f||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++)0!==o[t[i]]&&(n=!1);n&&(u.splice(r--,1),e=a(a.s=t[0]))}return e}var n={},o={0:0},u=[];function a(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.e=function(e){var r=[],t=o[e];if(0!==t)if(t)r.push(t[2]);else{var n=new Promise((function(r,n){t=o[e]=[r,n]}));r.push(t[2]=n);var u,i=document.createElement("script");i.charset="utf-8",i.timeout=120,a.nc&&i.setAttribute("nonce",a.nc),i.src=function(e){return a.p+""+({}[e]||e)+"."+{1:"28d29f71939fa32ee3cd",6:"94592ba65133dd317f14",7:"c16224c36ecb9ac35069"}[e]+".js"}(e);var c=new Error;u=function(r){i.onerror=i.onload=null,clearTimeout(f);var t=o[e];if(0!==t){if(t){var n=r&&("load"===r.type?"missing":r.type),u=r&&r.target&&r.target.src;c.message="Loading chunk "+e+" failed.\n("+n+": "+u+")",c.name="ChunkLoadError",c.type=n,c.request=u,t[1](c)}o[e]=void 0}};var f=setTimeout((function(){u({type:"timeout",target:i})}),12e4);i.onerror=i.onload=u,document.head.appendChild(i)}return Promise.all(r)},a.m=e,a.c=n,a.d=function(e,r,t){a.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,r){if(1&r&&(e=a(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(a.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)a.d(t,n,(function(r){return e[r]}).bind(null,n));return t},a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,"a",r),r},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.p="",a.oe=function(e){throw console.error(e),e};var i=window.webpackJsonp=window.webpackJsonp||[],c=i.push.bind(i);i.push=r,i=i.slice();for(var f=0;f<i.length;f++)r(i[f]);var l=c;t()}([]);

@ -35,6 +35,7 @@ export class CLOnChainSendComponent implements OnInit, OnDestroy {
public transaction: OnChainCL = {}; public transaction: OnChainCL = {};
public feeRateTypes = FEE_RATE_TYPES; public feeRateTypes = FEE_RATE_TYPES;
public flgMinConf = false; public flgMinConf = false;
public fiatConversion = false;
public amountUnits = CURRENCY_UNITS; public amountUnits = CURRENCY_UNITS;
public selAmountUnit = CURRENCY_UNITS[0]; public selAmountUnit = CURRENCY_UNITS[0];
public currConvertorRate = {}; public currConvertorRate = {};
@ -48,6 +49,7 @@ export class CLOnChainSendComponent implements OnInit, OnDestroy {
this.store.select('root') this.store.select('root')
.pipe(takeUntil(this.unSubs[0])) .pipe(takeUntil(this.unSubs[0]))
.subscribe((rootStore) => { .subscribe((rootStore) => {
this.fiatConversion = rootStore.selNode.settings.fiatConversion;
this.amountUnits = rootStore.selNode.settings.currencyUnits; this.amountUnits = rootStore.selNode.settings.currencyUnits;
this.appConfig = rootStore.appConfig; this.appConfig = rootStore.appConfig;
this.nodeData = rootStore.nodeData; this.nodeData = rootStore.nodeData;
@ -58,7 +60,7 @@ export class CLOnChainSendComponent implements OnInit, OnDestroy {
onSendFunds() { onSendFunds() {
if(this.invalidValues) { return true; } if(this.invalidValues) { return true; }
if(this.transaction.satoshis && this.selAmountUnit !== CurrencyUnitEnum.SATS) { if(this.transaction.satoshis && this.selAmountUnit !== CurrencyUnitEnum.SATS) {
this.commonService.convertCurrency(this.transaction.satoshis, this.selAmountUnit === this.amountUnits[2] ? CurrencyUnitEnum.OTHER : this.selAmountUnit, this.amountUnits[2]) this.commonService.convertCurrency(this.transaction.satoshis, this.selAmountUnit === this.amountUnits[2] ? CurrencyUnitEnum.OTHER : this.selAmountUnit, this.amountUnits[2], this.fiatConversion)
.pipe(takeUntil(this.unSubs[1])) .pipe(takeUntil(this.unSubs[1]))
.subscribe(data => { .subscribe(data => {
this.transaction.satoshis = parseInt(data[CurrencyUnitEnum.SATS]); this.transaction.satoshis = parseInt(data[CurrencyUnitEnum.SATS]);
@ -116,7 +118,7 @@ export class CLOnChainSendComponent implements OnInit, OnDestroy {
let prevSelectedUnit = (this.selAmountUnit === this.amountUnits[2]) ? CurrencyUnitEnum.OTHER : this.selAmountUnit; let prevSelectedUnit = (this.selAmountUnit === this.amountUnits[2]) ? CurrencyUnitEnum.OTHER : this.selAmountUnit;
let currSelectedUnit = event.value === this.amountUnits[2] ? CurrencyUnitEnum.OTHER : event.value; let currSelectedUnit = event.value === this.amountUnits[2] ? CurrencyUnitEnum.OTHER : event.value;
if(this.transaction.satoshis && this.selAmountUnit !== event.value) { if(this.transaction.satoshis && this.selAmountUnit !== event.value) {
this.commonService.convertCurrency(this.transaction.satoshis, prevSelectedUnit, this.amountUnits[2]) this.commonService.convertCurrency(this.transaction.satoshis, prevSelectedUnit, this.amountUnits[2], this.fiatConversion)
.pipe(takeUntil(this.unSubs[4])) .pipe(takeUntil(this.unSubs[4]))
.subscribe(data => { .subscribe(data => {
self.transaction.satoshis = +self.decimalPipe.transform(data[currSelectedUnit], self.currencyUnitFormats[currSelectedUnit]).replace(/,/g, ''); self.transaction.satoshis = +self.decimalPipe.transform(data[currSelectedUnit], self.currencyUnitFormats[currSelectedUnit]).replace(/,/g, '');

@ -172,7 +172,7 @@ export class CLLightningInvoicesComponent implements OnInit, OnDestroy {
onInvoiceValueChange() { onInvoiceValueChange() {
if(this.selNode.fiatConversion && this.invoiceValue > 99) { if(this.selNode.fiatConversion && this.invoiceValue > 99) {
this.invoiceValueHint = ''; this.invoiceValueHint = '';
this.commonService.convertCurrency(this.invoiceValue, CurrencyUnitEnum.SATS, this.selNode.currencyUnits[2]) this.commonService.convertCurrency(this.invoiceValue, CurrencyUnitEnum.SATS, this.selNode.currencyUnits[2], this.selNode.fiatConversion)
.pipe(takeUntil(this.unSubs[1])) .pipe(takeUntil(this.unSubs[1]))
.subscribe(data => { .subscribe(data => {
this.invoiceValueHint = '= ' + data.symbol + this.decimalPipe.transform(data.OTHER, CURRENCY_UNIT_FORMATS.OTHER) + ' ' + data.unit; this.invoiceValueHint = '= ' + data.symbol + this.decimalPipe.transform(data.OTHER, CURRENCY_UNIT_FORMATS.OTHER) + ' ' + data.unit;

@ -190,7 +190,7 @@ export class CLLightningPaymentsComponent implements OnInit, OnDestroy {
this.lndEffects.setDecodedPaymentCL.subscribe(decodedPayment => { this.lndEffects.setDecodedPaymentCL.subscribe(decodedPayment => {
this.paymentDecoded = decodedPayment; this.paymentDecoded = decodedPayment;
if(this.paymentDecoded.msatoshi) { if(this.paymentDecoded.msatoshi) {
this.commonService.convertCurrency(+this.paymentDecoded.msatoshi, CurrencyUnitEnum.SATS, this.selNode.currencyUnits[2]) this.commonService.convertCurrency(+this.paymentDecoded.msatoshi, CurrencyUnitEnum.SATS, this.selNode.currencyUnits[2], this.selNode.fiatConversion)
.pipe(takeUntil(this.unSubs[1])) .pipe(takeUntil(this.unSubs[1]))
.subscribe(data => { .subscribe(data => {
if(this.selNode.fiatConversion) { if(this.selNode.fiatConversion) {

@ -47,6 +47,7 @@ export class OnChainSendComponent implements OnInit, OnDestroy {
public transaction: ChannelsTransaction = {}; public transaction: ChannelsTransaction = {};
public transTypes = [{id: '1', name: 'Target Confirmation Blocks'}, {id: '2', name: 'Fee'}]; public transTypes = [{id: '1', name: 'Target Confirmation Blocks'}, {id: '2', name: 'Fee'}];
public selTransType = '1'; public selTransType = '1';
public fiatConversion = false;
public amountUnits = CURRENCY_UNITS; public amountUnits = CURRENCY_UNITS;
public selAmountUnit = CURRENCY_UNITS[0]; public selAmountUnit = CURRENCY_UNITS[0];
public currConvertorRate = {}; public currConvertorRate = {};
@ -60,6 +61,7 @@ export class OnChainSendComponent implements OnInit, OnDestroy {
this.store.select('root') this.store.select('root')
.pipe(takeUntil(this.unSubs[0])) .pipe(takeUntil(this.unSubs[0]))
.subscribe((rootStore) => { .subscribe((rootStore) => {
this.fiatConversion = rootStore.selNode.settings.fiatConversion;
this.amountUnits = rootStore.selNode.settings.currencyUnits; this.amountUnits = rootStore.selNode.settings.currencyUnits;
this.appConfig = rootStore.appConfig; this.appConfig = rootStore.appConfig;
this.nodeData = rootStore.nodeData; this.nodeData = rootStore.nodeData;
@ -70,7 +72,7 @@ export class OnChainSendComponent implements OnInit, OnDestroy {
onSendFunds() { onSendFunds() {
if(this.invalidValues) { return true; } if(this.invalidValues) { return true; }
if(this.transaction.amount && this.selAmountUnit !== CurrencyUnitEnum.SATS) { if(this.transaction.amount && this.selAmountUnit !== CurrencyUnitEnum.SATS) {
this.commonService.convertCurrency(this.transaction.amount, this.selAmountUnit === this.amountUnits[2] ? CurrencyUnitEnum.OTHER : this.selAmountUnit, this.amountUnits[2]) this.commonService.convertCurrency(this.transaction.amount, this.selAmountUnit === this.amountUnits[2] ? CurrencyUnitEnum.OTHER : this.selAmountUnit, this.amountUnits[2], this.fiatConversion)
.pipe(takeUntil(this.unSubs[1])) .pipe(takeUntil(this.unSubs[1]))
.subscribe(data => { .subscribe(data => {
this.transaction.amount = parseInt(data[CurrencyUnitEnum.SATS]); this.transaction.amount = parseInt(data[CurrencyUnitEnum.SATS]);
@ -176,7 +178,7 @@ export class OnChainSendComponent implements OnInit, OnDestroy {
let currSelectedUnit = event.value === this.amountUnits[2] ? CurrencyUnitEnum.OTHER : event.value; let currSelectedUnit = event.value === this.amountUnits[2] ? CurrencyUnitEnum.OTHER : event.value;
if(this.transaction.amount && this.selAmountUnit !== event.value) { if(this.transaction.amount && this.selAmountUnit !== event.value) {
let amount = (this.sweepAll) ? this.sweepBalance : this.transaction.amount; let amount = (this.sweepAll) ? this.sweepBalance : this.transaction.amount;
this.commonService.convertCurrency(amount, prevSelectedUnit, this.amountUnits[2]) this.commonService.convertCurrency(amount, prevSelectedUnit, this.amountUnits[2], this.fiatConversion)
.pipe(takeUntil(this.unSubs[4])) .pipe(takeUntil(this.unSubs[4]))
.subscribe(data => { .subscribe(data => {
self.transaction.amount = +self.decimalPipe.transform(data[currSelectedUnit], self.currencyUnitFormats[currSelectedUnit]).replace(/,/g, ''); self.transaction.amount = +self.decimalPipe.transform(data[currSelectedUnit], self.currencyUnitFormats[currSelectedUnit]).replace(/,/g, '');

@ -158,7 +158,7 @@ export class LightningInvoicesComponent implements OnInit, OnDestroy {
onInvoiceValueChange() { onInvoiceValueChange() {
if(this.selNode.fiatConversion && this.invoiceValue > 99) { if(this.selNode.fiatConversion && this.invoiceValue > 99) {
this.invoiceValueHint = ''; this.invoiceValueHint = '';
this.commonService.convertCurrency(this.invoiceValue, CurrencyUnitEnum.SATS, this.selNode.currencyUnits[2]) this.commonService.convertCurrency(this.invoiceValue, CurrencyUnitEnum.SATS, this.selNode.currencyUnits[2], this.selNode.fiatConversion)
.pipe(takeUntil(this.unSubs[1])) .pipe(takeUntil(this.unSubs[1]))
.subscribe(data => { .subscribe(data => {
this.invoiceValueHint = '= ' + data.symbol + this.decimalPipe.transform(data.OTHER, CURRENCY_UNIT_FORMATS.OTHER) + ' ' + data.unit; this.invoiceValueHint = '= ' + data.symbol + this.decimalPipe.transform(data.OTHER, CURRENCY_UNIT_FORMATS.OTHER) + ' ' + data.unit;

@ -196,7 +196,7 @@ export class LightningPaymentsComponent implements OnInit, OnDestroy {
this.lndEffects.setDecodedPayment.subscribe(decodedPayment => { this.lndEffects.setDecodedPayment.subscribe(decodedPayment => {
this.paymentDecoded = decodedPayment; this.paymentDecoded = decodedPayment;
if(this.paymentDecoded.num_satoshis) { if(this.paymentDecoded.num_satoshis) {
this.commonService.convertCurrency(+this.paymentDecoded.num_satoshis, CurrencyUnitEnum.SATS, this.selNode.currencyUnits[2]) this.commonService.convertCurrency(+this.paymentDecoded.num_satoshis, CurrencyUnitEnum.SATS, this.selNode.currencyUnits[2], this.selNode.fiatConversion)
.pipe(takeUntil(this.unSubs[1])) .pipe(takeUntil(this.unSubs[1]))
.subscribe(data => { .subscribe(data => {
if(this.selNode.fiatConversion) { if(this.selNode.fiatConversion) {

@ -55,7 +55,7 @@ export class CurrencyUnitConverterComponent implements OnInit, OnChanges, OnDest
getCurrencyValues(values) { getCurrencyValues(values) {
values.forEach(value => { values.forEach(value => {
if(value.dataValue > 0) { if(value.dataValue > 0) {
this.commonService.convertCurrency(value.dataValue, CurrencyUnitEnum.SATS, this.currencyUnits[2]) this.commonService.convertCurrency(value.dataValue, CurrencyUnitEnum.SATS, this.currencyUnits[2], this.fiatConversion)
.pipe(takeUntil(this.unSubs[1])) .pipe(takeUntil(this.unSubs[1]))
.subscribe(data => { .subscribe(data => {
value[CurrencyUnitEnum.BTC] = data.BTC; value[CurrencyUnitEnum.BTC] = data.BTC;

@ -49,11 +49,9 @@ export class CommonService implements OnInit, OnDestroy {
this.containerWidthChanged.next(fieldType); this.containerWidthChanged.next(fieldType);
} }
convertCurrency(value: number, from: string, otherCurrencyUnit: string): Observable<any> { convertCurrency(value: number, from: string, otherCurrencyUnit: string, fiatConversion: boolean): Observable<any> {
let latest_date = new Date().valueOf(); let latest_date = new Date().valueOf();
if(!otherCurrencyUnit) { if(fiatConversion && otherCurrencyUnit) {
return of(this.convertWithoutFiat(value, from));
} else {
if(this.conversionData.data && this.conversionData.last_fetched && (latest_date < (this.conversionData.last_fetched.valueOf() + 300000))) { if(this.conversionData.data && this.conversionData.last_fetched && (latest_date < (this.conversionData.last_fetched.valueOf() + 300000))) {
return of(this.convertWithFiat(value, from, otherCurrencyUnit)); return of(this.convertWithFiat(value, from, otherCurrencyUnit));
} else { } else {
@ -65,6 +63,8 @@ export class CommonService implements OnInit, OnDestroy {
return this.convertWithFiat(value, from, otherCurrencyUnit); return this.convertWithFiat(value, from, otherCurrencyUnit);
})); }));
} }
} else {
return of(this.convertWithoutFiat(value, from));
} }
} }

@ -345,8 +345,8 @@ export class RTLEffects implements OnDestroy {
initializeNode(node: any, isInitialSetup: boolean) { initializeNode(node: any, isInitialSetup: boolean) {
const landingPage = isInitialSetup ? '' : 'HOME'; const landingPage = isInitialSetup ? '' : 'HOME';
let selNode = {}; let selNode = {};
if(node.settings.currencyUnit) { if(node.settings.fiatConversion && node.settings.currencyUnit) {
selNode = { userPersona: node.settings.userPersona, channelBackupPath: node.settings.channelBackupPath, satsToBTC: node.settings.satsToBTC, selCurrencyUnit: node.settings.currencyUnit, currencyUnits: [...CURRENCY_UNITS, node.settings.currencyUnit], fiatConversion: node.settings.fiatConversion }; selNode = { userPersona: node.settings.userPersona, channelBackupPath: node.settings.channelBackupPath, satsToBTC: node.settings.satsToBTC, selCurrencyUnit: node.settings.currencyUnit, currencyUnits: [...CURRENCY_UNITS, node.settings.currencyUnit], fiatConversion: node.settings.fiatConversion };
} else { } else {
selNode = { userPersona: node.settings.userPersona, channelBackupPath: node.settings.channelBackupPath, satsToBTC: node.settings.satsToBTC, selCurrencyUnit: node.settings.currencyUnit, currencyUnits: CURRENCY_UNITS, fiatConversion: node.settings.fiatConversion }; selNode = { userPersona: node.settings.userPersona, channelBackupPath: node.settings.channelBackupPath, satsToBTC: node.settings.satsToBTC, selCurrencyUnit: node.settings.currencyUnit, currencyUnits: CURRENCY_UNITS, fiatConversion: node.settings.fiatConversion };
} }

Loading…
Cancel
Save