Merge branch 'master' into add-faq

This commit is contained in:
hunicus
2022-04-12 16:03:28 -04:00
committed by GitHub
77 changed files with 2909 additions and 1401 deletions

View File

@@ -4,12 +4,14 @@ import { Pipe, PipeTransform } from '@angular/core';
name: 'amountShortener'
})
export class AmountShortenerPipe implements PipeTransform {
transform(num: number, ...args: number[]): unknown {
transform(num: number, ...args: any[]): unknown {
const digits = args[0] || 1;
const unit = args[1] || undefined;
if (num < 1000) {
return num;
return num.toFixed(digits);
}
const digits = args[0] || 1;
const lookup = [
{ value: 1, symbol: '' },
{ value: 1e3, symbol: 'k' },
@@ -20,7 +22,12 @@ export class AmountShortenerPipe implements PipeTransform {
{ value: 1e18, symbol: 'E' }
];
const rx = /\.0+$|(\.[0-9]*[1-9])0+$/;
var item = lookup.slice().reverse().find((item) => num >= item.value);
return item ? (num / item.value).toFixed(digits).replace(rx, '$1') + item.symbol : '0';
const item = lookup.slice().reverse().find((item) => num >= item.value);
if (unit !== undefined) {
return item ? (num / item.value).toFixed(digits).replace(rx, '$1') + ' ' + item.symbol + unit : '0';
} else {
return item ? (num / item.value).toFixed(digits).replace(rx, '$1') + item.symbol : '0';
}
}
}

View File

@@ -264,6 +264,7 @@ export class AsmStylerPipe implements PipeTransform {
case 'LESSTHAN':
case 'GREATERTHAN':
case 'LESSTHANOREQUAL':
case 'GREATERTHANOREQUAL':
case 'MIN':
case 'MAX':
case 'WITHIN':
@@ -279,12 +280,13 @@ export class AsmStylerPipe implements PipeTransform {
case 'CHECKSIG':
case 'CHECKSIGVERIFY':
case 'CHECKMULTISIG':
case 'CHCEKMULTISIGVERIFY':
case 'CHECKMULTISIGVERIFY':
case 'CHECKSIGADD':
style = 'crypto';
break;
case 'CHECKLOCKTIMEVERIFY':
case 'CHECKSEQUENCEVERIFY':
case 'CLTV':
case 'CSV':
style = 'locktime';
break;