mirror of https://github.com/ghostfolio/ghostfolio
committed by
GitHub
10 changed files with 65 additions and 31 deletions
@ -0,0 +1,9 @@ |
|||||
|
import { Module } from '@nestjs/common'; |
||||
|
|
||||
|
import { CryptocurrencyService } from './cryptocurrency.service'; |
||||
|
|
||||
|
@Module({ |
||||
|
providers: [CryptocurrencyService], |
||||
|
exports: [CryptocurrencyService] |
||||
|
}) |
||||
|
export class CryptocurrencyModule {} |
@ -0,0 +1,28 @@ |
|||||
|
import { Injectable } from '@nestjs/common'; |
||||
|
|
||||
|
const cryptocurrencies = require('cryptocurrencies'); |
||||
|
|
||||
|
const customCryptocurrencies = require('./custom-cryptocurrencies.json'); |
||||
|
|
||||
|
@Injectable() |
||||
|
export class CryptocurrencyService { |
||||
|
private combinedCryptocurrencies: string[]; |
||||
|
|
||||
|
public constructor() {} |
||||
|
|
||||
|
public isCrypto(aSymbol = '') { |
||||
|
const cryptocurrencySymbol = aSymbol.substring(0, aSymbol.length - 3); |
||||
|
return this.getCryptocurrencies().includes(cryptocurrencySymbol); |
||||
|
} |
||||
|
|
||||
|
private getCryptocurrencies() { |
||||
|
if (!this.combinedCryptocurrencies) { |
||||
|
this.combinedCryptocurrencies = [ |
||||
|
...cryptocurrencies.symbols(), |
||||
|
...Object.keys(customCryptocurrencies) |
||||
|
]; |
||||
|
} |
||||
|
|
||||
|
return this.combinedCryptocurrencies; |
||||
|
} |
||||
|
} |
@ -0,0 +1,6 @@ |
|||||
|
{ |
||||
|
"1INCH": "1inch", |
||||
|
"AVAX": "Avalanche", |
||||
|
"MATIC": "Polygon", |
||||
|
"SHIB": "Shiba Inu" |
||||
|
} |
@ -1,11 +0,0 @@ |
|||||
{ |
|
||||
"SHIB": "SHIBA INU USD", |
|
||||
"SOL1": "Solana", |
|
||||
"DOT1": "Polkadot", |
|
||||
"LUNA1": "Terra", |
|
||||
"AVAX": "Avalanche", |
|
||||
"MATIC": "MaticNetwork", |
|
||||
"ATOM1": "Cosmos", |
|
||||
"FTT1": "FTXToken", |
|
||||
"1INCH": "1inch" |
|
||||
} |
|
Loading…
Reference in new issue