mirror of https://github.com/ghostfolio/ghostfolio
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
902 B
31 lines
902 B
import { DEFAULT_CURRENCY } from '@ghostfolio/common/config';
|
|
|
|
import { Injectable } from '@nestjs/common';
|
|
|
|
const cryptocurrencies = require('../../assets/cryptocurrencies/cryptocurrencies.json');
|
|
const customCryptocurrencies = require('../../assets/cryptocurrencies/custom.json');
|
|
|
|
@Injectable()
|
|
export class CryptocurrencyService {
|
|
private combinedCryptocurrencies: string[];
|
|
|
|
public isCryptocurrency(aSymbol = '') {
|
|
const cryptocurrencySymbol = aSymbol.substring(0, aSymbol.length - 3);
|
|
|
|
return (
|
|
aSymbol.endsWith(DEFAULT_CURRENCY) &&
|
|
this.getCryptocurrencies().includes(cryptocurrencySymbol)
|
|
);
|
|
}
|
|
|
|
private getCryptocurrencies() {
|
|
if (!this.combinedCryptocurrencies) {
|
|
this.combinedCryptocurrencies = [
|
|
...Object.keys(cryptocurrencies),
|
|
...Object.keys(customCryptocurrencies)
|
|
];
|
|
}
|
|
|
|
return this.combinedCryptocurrencies;
|
|
}
|
|
}
|
|
|