From 9d38648dfc6c338b86dcab07f075a3ce679a73eb Mon Sep 17 00:00:00 2001 From: wywywywy Date: Wed, 4 Oct 2023 08:12:29 +0100 Subject: [PATCH] feat: Use fawazahmed0/currency-api for currency exchange (#1043) * feat: Use fawazahmed0/currency-api * docs: replace provider url --- README.md | 2 +- .../translation/czech-translation-set.ts | 2 +- .../translation/english-translation-set.ts | 2 +- .../translation/finnish-translation-set.ts | 2 +- .../translation/german-translation-set.ts | 2 +- .../translation/hindi-translation-set.ts | 2 +- .../translation/italian-translation-set.ts | 2 +- .../translation/japanese-translation-set.ts | 2 +- .../translation/korean-translation-set.ts | 2 +- .../translation/portuguese-translation-set.ts | 2 +- .../translation/russian-translation-set.ts | 2 +- .../simplified-chinese-translation-set.ts | 2 +- .../translation/spanish-translation-set.ts | 2 +- .../traditional-chinese-translation-set.ts | 2 +- .../translation/turkish-translation-set.ts | 2 +- .../translation/ukrainian-translation-set.ts | 2 +- .../conversion-api-result.ts | 9 +- .../currency-code.ts | 368 +++++++++++++++++- .../currency-converter.ts | 6 +- 19 files changed, 392 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index ab82bf9f8..438aae22e 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ This plugin enables you to quickly find control panel items. ### Currency Converter -This plugin enables you to quickly convert currencies. The latest conversion rates are provided by https://exchangerate.host/. +This plugin enables you to quickly convert currencies. The latest conversion rates are provided by https://github.com/fawazahmed0/currency-api/. ![currency-converter](assets/feature-currency-converter.png) diff --git a/src/common/translation/czech-translation-set.ts b/src/common/translation/czech-translation-set.ts index 44aa2c8f3..612557dbc 100644 --- a/src/common/translation/czech-translation-set.ts +++ b/src/common/translation/czech-translation-set.ts @@ -298,7 +298,7 @@ export const englishTranslationSet: TranslationSet = { currencyConverter: "Převodník měn", currencyConverterDescription: - "Tento plugin umožňuje rychle převádět měny. Nejnovější kurzy jsou uvedeny na adrese https://exchangerate.host/.", + "Tento plugin umožňuje rychle převádět měny. Nejnovější kurzy jsou uvedeny na adrese https://github.com/fawazahmed0/currency-api/.", currencyConverterPrecision: "Přesnost", currencyConverterCopyToClipboard: "Stisknutím klávesy Enter zkopírujete do schránky", diff --git a/src/common/translation/english-translation-set.ts b/src/common/translation/english-translation-set.ts index 4a4a64189..deb74d036 100755 --- a/src/common/translation/english-translation-set.ts +++ b/src/common/translation/english-translation-set.ts @@ -300,7 +300,7 @@ export const englishTranslationSet: TranslationSet = { currencyConverter: "Currency Converter", currencyConverterDescription: - "This plugin enables you to quickly convert currencies. The latest conversion rates are provided by https://exchangerate.host/.", + "This plugin enables you to quickly convert currencies. The latest conversion rates are provided by https://github.com/fawazahmed0/currency-api/.", currencyConverterPrecision: "Precision", currencyConverterCopyToClipboard: "Press enter to copy to clipboard", diff --git a/src/common/translation/finnish-translation-set.ts b/src/common/translation/finnish-translation-set.ts index 82ffb0d6e..8251e124c 100644 --- a/src/common/translation/finnish-translation-set.ts +++ b/src/common/translation/finnish-translation-set.ts @@ -301,7 +301,7 @@ export const finnishTranslationSet: TranslationSet = { currencyConverter: "Valuuttamuunnin", currencyConverterDescription: - "Tämän lisäosan avulla voit tehdä nopeasti valuuttamuunnoksia. Nykyiset valuuttakurssit tarjoaa https://exchangerate.host/.", + "Tämän lisäosan avulla voit tehdä nopeasti valuuttamuunnoksia. Nykyiset valuuttakurssit tarjoaa https://github.com/fawazahmed0/currency-api/.", currencyConverterPrecision: "Tarkkuus", currencyConverterCopyToClipboard: "Paina Enteriä kopioidaksesi leikepöydälle", diff --git a/src/common/translation/german-translation-set.ts b/src/common/translation/german-translation-set.ts index 1c35ffb2a..97a98bb70 100755 --- a/src/common/translation/german-translation-set.ts +++ b/src/common/translation/german-translation-set.ts @@ -303,7 +303,7 @@ export const germanTranslationSet: TranslationSet = { currencyConverter: "Währungsumrechnung", currencyConverterDescription: - "Dieses Plugin erlaubt es dir schnell Währungsumrechnungen zu machen. Aktuelle Wechselkurse werden von https://exchangerate.host/ bereit gestellt.", + "Dieses Plugin erlaubt es dir schnell Währungsumrechnungen zu machen. Aktuelle Wechselkurse werden von https://github.com/fawazahmed0/currency-api/ bereit gestellt.", currencyConverterPrecision: "Präzision", currencyConverterCopyToClipboard: "Drücke Enter um in die Zwischenablage zu kopieren", diff --git a/src/common/translation/hindi-translation-set.ts b/src/common/translation/hindi-translation-set.ts index 700d4bb1f..02ec6f0c6 100644 --- a/src/common/translation/hindi-translation-set.ts +++ b/src/common/translation/hindi-translation-set.ts @@ -303,7 +303,7 @@ export const hindiTranslationSet: TranslationSet = { currencyConverter: "मुद्रा परिवर्तक", currencyConverterDescription: - "यह प्लगइन आपको मुद्राओं को जल्दी से बदलने में सक्षम बनाता है। नवीनतम रूपांतरण दरें https://exchangerate.host/ द्वारा प्रदान की जाती हैं।", + "यह प्लगइन आपको मुद्राओं को जल्दी से बदलने में सक्षम बनाता है। नवीनतम रूपांतरण दरें https://github.com/fawazahmed0/currency-api/ द्वारा प्रदान की जाती हैं।", currencyConverterPrecision: "सटीक", currencyConverterCopyToClipboard: "क्लिपबोर्ड पर कॉपी करने के लिए एंटर दबाएं", diff --git a/src/common/translation/italian-translation-set.ts b/src/common/translation/italian-translation-set.ts index 87c5efb22..51a3f31ca 100644 --- a/src/common/translation/italian-translation-set.ts +++ b/src/common/translation/italian-translation-set.ts @@ -308,7 +308,7 @@ export const italianTranslationSet: TranslationSet = { openNewMail: "Crea nuova email", currencyConverter: "Convertitore di valuta", currencyConverterDescription: - "Questo plugin ti consente di convertire rapidamente le valute. Gli ultimi tassi di conversione sono forniti da https://exchangerate.host/.", + "Questo plugin ti consente di convertire rapidamente le valute. Gli ultimi tassi di conversione sono forniti da https://github.com/fawazahmed0/currency-api/.", currencyConverterPrecision: "Precisione", currencyConverterCopyToClipboard: "Premi Invio per copiare negli appunti", workflows: "Flussi di lavoro", diff --git a/src/common/translation/japanese-translation-set.ts b/src/common/translation/japanese-translation-set.ts index 4c9147c07..7c7783470 100644 --- a/src/common/translation/japanese-translation-set.ts +++ b/src/common/translation/japanese-translation-set.ts @@ -298,7 +298,7 @@ export const japaneseTranslationSet: TranslationSet = { currencyConverter: "通貨コンバーター", currencyConverterDescription: - "このプラグインは素早く通貨を変換することができます。最新の交換レートは https://exchangerate.host/ より提供されます。", + "このプラグインは素早く通貨を変換することができます。最新の交換レートは https://github.com/fawazahmed0/currency-api/ より提供されます。", currencyConverterPrecision: "精度", currencyConverterCopyToClipboard: "エンターを押下してクリップボードにコピー", diff --git a/src/common/translation/korean-translation-set.ts b/src/common/translation/korean-translation-set.ts index 9ea29137f..634223ad6 100644 --- a/src/common/translation/korean-translation-set.ts +++ b/src/common/translation/korean-translation-set.ts @@ -296,7 +296,7 @@ export const koreanTranslationSet: TranslationSet = { currencyConverter: "통화 변환기", currencyConverterDescription: - "이 플러그인을 사용하면 통화를 빠르게 변환할 수 있습니다. 최신 환율은 https://exchangerate.host/ 에서 제공합니다.", + "이 플러그인을 사용하면 통화를 빠르게 변환할 수 있습니다. 최신 환율은 https://github.com/fawazahmed0/currency-api/ 에서 제공합니다.", currencyConverterPrecision: "정밀도", currencyConverterCopyToClipboard: "Enter를 눌러 계산 결과를 클립보드에 복사", diff --git a/src/common/translation/portuguese-translation-set.ts b/src/common/translation/portuguese-translation-set.ts index 46e52610c..8a3454cbf 100644 --- a/src/common/translation/portuguese-translation-set.ts +++ b/src/common/translation/portuguese-translation-set.ts @@ -304,7 +304,7 @@ export const portugueseTranslationSet: TranslationSet = { currencyConverter: "Converter moeda", currencyConverterDescription: - "Este plugin te habilita a converter moedas rapidamente. As taxas de conversão são providas por https://exchangerate.host/.", + "Este plugin te habilita a converter moedas rapidamente. As taxas de conversão são providas por https://github.com/fawazahmed0/currency-api/.", currencyConverterPrecision: "Precisão", currencyConverterCopyToClipboard: "Pressione Enter para copiar para a área de transferência", diff --git a/src/common/translation/russian-translation-set.ts b/src/common/translation/russian-translation-set.ts index d24e48726..ca6a66385 100755 --- a/src/common/translation/russian-translation-set.ts +++ b/src/common/translation/russian-translation-set.ts @@ -297,7 +297,7 @@ export const russianTranslationSet: TranslationSet = { currencyConverter: "Конвертация валют", currencyConverterDescription: - "Этот плагин позволяет быстро конвертировать валюты. Актуальные курсы валют предоставлены https://exchangerate.host/.", + "Этот плагин позволяет быстро конвертировать валюты. Актуальные курсы валют предоставлены https://github.com/fawazahmed0/currency-api/.", currencyConverterPrecision: "Точность", currencyConverterCopyToClipboard: "Нажмите enter, чтобы скопировать", diff --git a/src/common/translation/simplified-chinese-translation-set.ts b/src/common/translation/simplified-chinese-translation-set.ts index 96003b17e..9791159e5 100644 --- a/src/common/translation/simplified-chinese-translation-set.ts +++ b/src/common/translation/simplified-chinese-translation-set.ts @@ -293,7 +293,7 @@ export const simplifiedChineseTranslationSet: TranslationSet = { openNewMail: "打开新邮件", currencyConverter: "货币换算", - currencyConverterDescription: "根据 https://exchangerate.host/ 数据来转换货币", + currencyConverterDescription: "根据 https://github.com/fawazahmed0/currency-api/ 数据来转换货币", currencyConverterPrecision: "精度", currencyConverterCopyToClipboard: "按 Enter 复制到剪贴板", diff --git a/src/common/translation/spanish-translation-set.ts b/src/common/translation/spanish-translation-set.ts index 1c2d89d4b..34bd1f329 100644 --- a/src/common/translation/spanish-translation-set.ts +++ b/src/common/translation/spanish-translation-set.ts @@ -305,7 +305,7 @@ export const spanishTranslationSet: TranslationSet = { currencyConverter: "Conversor de divisa", currencyConverterDescription: - "Este plugin te permite convertir divisa de forma rápida. Los últimos ratios de conversión están provistos por https://exchangerate.host/.", + "Este plugin te permite convertir divisa de forma rápida. Los últimos ratios de conversión están provistos por https://github.com/fawazahmed0/currency-api/.", currencyConverterPrecision: "Precisión", currencyConverterCopyToClipboard: "Presiona enter para copiar al portapapeles", diff --git a/src/common/translation/traditional-chinese-translation-set.ts b/src/common/translation/traditional-chinese-translation-set.ts index d72ce1a00..09f5eadcb 100644 --- a/src/common/translation/traditional-chinese-translation-set.ts +++ b/src/common/translation/traditional-chinese-translation-set.ts @@ -293,7 +293,7 @@ export const traditionalChineseTranslationSet: TranslationSet = { openNewMail: "打開新電郵", currencyConverter: "貨幣換算", - currencyConverterDescription: "根據 https://exchangerate.host/ 提供的匯率來轉換貨幣。", + currencyConverterDescription: "根據 https://github.com/fawazahmed0/currency-api/ 提供的匯率來轉換貨幣。", currencyConverterPrecision: "精確度", currencyConverterCopyToClipboard: "按 Enter 複製到剪貼簿", diff --git a/src/common/translation/turkish-translation-set.ts b/src/common/translation/turkish-translation-set.ts index 82699c6c0..f45706bff 100755 --- a/src/common/translation/turkish-translation-set.ts +++ b/src/common/translation/turkish-translation-set.ts @@ -304,7 +304,7 @@ export const turkishTranslationSet: TranslationSet = { currencyConverter: "Döviz Çevirici", currencyConverterDescription: - "Bu eklenti para birimlerini hızlıca dönüştürmenizi sağlar. En son dönüşüm oranları https://exchangerate.host/ tarafından sağlanmaktadır..", + "Bu eklenti para birimlerini hızlıca dönüştürmenizi sağlar. En son dönüşüm oranları https://github.com/fawazahmed0/currency-api/ tarafından sağlanmaktadır..", currencyConverterPrecision: "Hassas", currencyConverterCopyToClipboard: "Panoya kopyalamak için enter tuşuna basın", diff --git a/src/common/translation/ukrainian-translation-set.ts b/src/common/translation/ukrainian-translation-set.ts index 54fa2d4e6..e2af79fed 100644 --- a/src/common/translation/ukrainian-translation-set.ts +++ b/src/common/translation/ukrainian-translation-set.ts @@ -300,7 +300,7 @@ export const ukrainianTranslationSet: TranslationSet = { currencyConverter: "Конвертація валют", currencyConverterDescription: - "Цей плагін дозволяє швидко конвертувати валюти. Актуальні курси валют надані https://exchangerate.host/.", + "Цей плагін дозволяє швидко конвертувати валюти. Актуальні курси валют надані https://github.com/fawazahmed0/currency-api/.", currencyConverterPrecision: "Точність", currencyConverterCopyToClipboard: "Натисніть клавішу enter, щоб скопіювати", diff --git a/src/main/plugins/currency-converter-plugin/conversion-api-result.ts b/src/main/plugins/currency-converter-plugin/conversion-api-result.ts index 5d86a93d2..59ceaaf34 100644 --- a/src/main/plugins/currency-converter-plugin/conversion-api-result.ts +++ b/src/main/plugins/currency-converter-plugin/conversion-api-result.ts @@ -1,4 +1,7 @@ -export interface ConversionApiResult { - success: boolean; - result: number; +interface ConversionApiResultDate { + date: string; } +interface ConversionApiResultValue { + [key: string]: number; +} +export type ConversionApiResult = ConversionApiResultDate & ConversionApiResultValue; diff --git a/src/main/plugins/currency-converter-plugin/currency-code.ts b/src/main/plugins/currency-converter-plugin/currency-code.ts index f7aa6afa4..0ac50b8d2 100644 --- a/src/main/plugins/currency-converter-plugin/currency-code.ts +++ b/src/main/plugins/currency-converter-plugin/currency-code.ts @@ -1,173 +1,539 @@ export enum CurrencyCode { + "00" = "00", + "1INCH" = "1INCH", + AAVE = "AAVE", + ABT = "ABT", + ACH = "ACH", + ACS = "ACS", + ADA = "ADA", AED = "AED", + AERGO = "AERGO", AFN = "AFN", + AGLD = "AGLD", + AIOZ = "AIOZ", + AKT = "AKT", + ALCX = "ALCX", + ALEPH = "ALEPH", + ALGO = "ALGO", + ALICE = "ALICE", ALL = "ALL", AMD = "AMD", + AMP = "AMP", ANG = "ANG", + ANKR = "ANKR", + ANT = "ANT", AOA = "AOA", + APE = "APE", + API3 = "API3", + APT = "APT", + AR = "AR", + ARB = "ARB", + ARPA = "ARPA", ARS = "ARS", + ASM = "ASM", + AST = "AST", + ATA = "ATA", + ATOM = "ATOM", + ATS = "ATS", + AUCTION = "AUCTION", AUD = "AUD", + AUDIO = "AUDIO", + AURORA = "AURORA", + AVAX = "AVAX", + AVT = "AVT", AWG = "AWG", + AXL = "AXL", + AXS = "AXS", + AZM = "AZM", AZN = "AZN", + BADGER = "BADGER", + BAKE = "BAKE", + BAL = "BAL", BAM = "BAM", + BAND = "BAND", + BAT = "BAT", BBD = "BBD", + BCH = "BCH", BDT = "BDT", + BEF = "BEF", BGN = "BGN", BHD = "BHD", + BICO = "BICO", BIF = "BIF", + BIT = "BIT", + BLUR = "BLUR", + BLZ = "BLZ", BMD = "BMD", + BNB = "BNB", BND = "BND", + BNT = "BNT", BOB = "BOB", + BOBA = "BOBA", + BOND = "BOND", BRL = "BRL", BSD = "BSD", + BSV = "BSV", + BSW = "BSW", BTC = "BTC", + BTCB = "BTCB", + BTG = "BTG", BTN = "BTN", + BTRST = "BTRST", + BTT = "BTT", + BUSD = "BUSD", BWP = "BWP", BYN = "BYN", + BYR = "BYR", BZD = "BZD", + C98 = "C98", CAD = "CAD", + CAKE = "CAKE", + CBETH = "CBETH", CDF = "CDF", + CELO = "CELO", + CELR = "CELR", + CFX = "CFX", + CGLD = "CGLD", CHF = "CHF", - CLF = "CLF", + CHZ = "CHZ", CLP = "CLP", + CLV = "CLV", CNH = "CNH", CNY = "CNY", + COMP = "COMP", COP = "COP", + COTI = "COTI", + COVAL = "COVAL", CRC = "CRC", + CRO = "CRO", + CRPT = "CRPT", + CRV = "CRV", + CSPR = "CSPR", + CTSI = "CTSI", + CTX = "CTX", CUC = "CUC", CUP = "CUP", + CVC = "CVC", CVE = "CVE", + CVX = "CVX", + CYP = "CYP", CZK = "CZK", + DAI = "DAI", + DAR = "DAR", + DASH = "DASH", + DCR = "DCR", + DDX = "DDX", + DEM = "DEM", + DESO = "DESO", + DEXT = "DEXT", + DFI = "DFI", + DIA = "DIA", + DIMO = "DIMO", DJF = "DJF", DKK = "DKK", + DNT = "DNT", + DOGE = "DOGE", DOP = "DOP", + DOT = "DOT", + DREP = "DREP", + DYDX = "DYDX", + DYP = "DYP", DZD = "DZD", + EEK = "EEK", + EGLD = "EGLD", EGP = "EGP", + ELA = "ELA", + ENJ = "ENJ", + ENS = "ENS", + EOS = "EOS", ERN = "ERN", + ESP = "ESP", ETB = "ETB", + ETC = "ETC", + ETH = "ETH", + ETH2 = "ETH2", EUR = "EUR", + EUROC = "EUROC", + FARM = "FARM", + FEI = "FEI", + FET = "FET", + FIDA = "FIDA", + FIL = "FIL", + FIM = "FIM", + FIS = "FIS", FJD = "FJD", FKP = "FKP", + FLOW = "FLOW", + FLR = "FLR", + FORT = "FORT", + FORTH = "FORTH", + FOX = "FOX", + FRAX = "FRAX", + FRF = "FRF", + FTM = "FTM", + FTT = "FTT", + FX = "FX", + FXS = "FXS", + GAL = "GAL", + GALA = "GALA", GBP = "GBP", GEL = "GEL", + GFI = "GFI", GGP = "GGP", + GHC = "GHC", GHS = "GHS", + GHST = "GHST", GIP = "GIP", + GLM = "GLM", GMD = "GMD", + GMT = "GMT", + GMX = "GMX", GNF = "GNF", + GNO = "GNO", + GNT = "GNT", + GODS = "GODS", + GRD = "GRD", + GRT = "GRT", + GST = "GST", + GT = "GT", + GTC = "GTC", GTQ = "GTQ", + GUSD = "GUSD", GYD = "GYD", + GYEN = "GYEN", + HBAR = "HBAR", + HFT = "HFT", + HIGH = "HIGH", HKD = "HKD", HNL = "HNL", + HNT = "HNT", + HOPR = "HOPR", + HOT = "HOT", HRK = "HRK", + HT = "HT", HTG = "HTG", HUF = "HUF", + ICP = "ICP", + IDEX = "IDEX", IDR = "IDR", + IEP = "IEP", ILS = "ILS", + ILV = "ILV", IMP = "IMP", + IMX = "IMX", + INDEX = "INDEX", + INJ = "INJ", INR = "INR", + INV = "INV", + IOTX = "IOTX", IQD = "IQD", IRR = "IRR", ISK = "ISK", + ITL = "ITL", + JASMY = "JASMY", JEP = "JEP", JMD = "JMD", JOD = "JOD", JPY = "JPY", + JUP = "JUP", + KAS = "KAS", + KAVA = "KAVA", + KCS = "KCS", + KDA = "KDA", + KEEP = "KEEP", KES = "KES", KGS = "KGS", KHR = "KHR", + KLAY = "KLAY", KMF = "KMF", + KNC = "KNC", KPW = "KPW", + KRL = "KRL", KRW = "KRW", + KSM = "KSM", KWD = "KWD", KYD = "KYD", KZT = "KZT", LAK = "LAK", LBP = "LBP", + LCX = "LCX", + LDO = "LDO", + LEO = "LEO", + LINK = "LINK", + LIT = "LIT", LKR = "LKR", + LOKA = "LOKA", + LOOM = "LOOM", + LPT = "LPT", + LQTY = "LQTY", + LRC = "LRC", LRD = "LRD", + LSETH = "LSETH", LSL = "LSL", + LTC = "LTC", + LTL = "LTL", + LUF = "LUF", + LUNA = "LUNA", + LUNC = "LUNC", + LVL = "LVL", LYD = "LYD", MAD = "MAD", + MAGIC = "MAGIC", + MANA = "MANA", + MASK = "MASK", + MATH = "MATH", + MATIC = "MATIC", + MCO2 = "MCO2", MDL = "MDL", + MDT = "MDT", + MEDIA = "MEDIA", + METIS = "METIS", MGA = "MGA", + MGF = "MGF", + MINA = "MINA", + MIOTA = "MIOTA", + MIR = "MIR", MKD = "MKD", + MKR = "MKR", + MLN = "MLN", MMK = "MMK", + MNDE = "MNDE", MNT = "MNT", + MONA = "MONA", MOP = "MOP", + MPL = "MPL", MRO = "MRO", MRU = "MRU", + MSOL = "MSOL", + MTL = "MTL", + MULTI = "MULTI", MUR = "MUR", + MUSD = "MUSD", + MUSE = "MUSE", MVR = "MVR", MWK = "MWK", + MXC = "MXC", MXN = "MXN", + MXV = "MXV", MYR = "MYR", + MZM = "MZM", MZN = "MZN", NAD = "NAD", + NCT = "NCT", + NEAR = "NEAR", + NEO = "NEO", + NEST = "NEST", + NEXO = "NEXO", + NFT = "NFT", NGN = "NGN", NIO = "NIO", + NKN = "NKN", + NLG = "NLG", + NMR = "NMR", NOK = "NOK", NPR = "NPR", + NU = "NU", NZD = "NZD", + OCEAN = "OCEAN", + OGN = "OGN", + OKB = "OKB", + OMG = "OMG", OMR = "OMR", + ONE = "ONE", + OOKI = "OOKI", + OP = "OP", + ORCA = "ORCA", + ORN = "ORN", + OSMO = "OSMO", + OXT = "OXT", PAB = "PAB", + PAX = "PAX", + PAXG = "PAXG", PEN = "PEN", + PEPE = "PEPE", + PERP = "PERP", PGK = "PGK", PHP = "PHP", PKR = "PKR", + PLA = "PLA", PLN = "PLN", + PLU = "PLU", + PNG = "PNG", + POLS = "POLS", + POLY = "POLY", + POND = "POND", + POWR = "POWR", + PRIME = "PRIME", + PRO = "PRO", + PRQ = "PRQ", + PTE = "PTE", + PUNDIX = "PUNDIX", PYG = "PYG", + PYR = "PYR", + PYUSD = "PYUSD", QAR = "QAR", + QI = "QI", + QNT = "QNT", + QSP = "QSP", + QTUM = "QTUM", + QUICK = "QUICK", + RAD = "RAD", + RAI = "RAI", + RARE = "RARE", + RARI = "RARI", + RBN = "RBN", + REN = "REN", + REP = "REP", + REPV2 = "REPV2", + REQ = "REQ", + RGT = "RGT", + RLC = "RLC", + RLY = "RLY", + RNDR = "RNDR", + ROL = "ROL", RON = "RON", + ROSE = "ROSE", + RPL = "RPL", RSD = "RSD", RUB = "RUB", + RUNE = "RUNE", + RVN = "RVN", RWF = "RWF", + SAND = "SAND", SAR = "SAR", SBD = "SBD", SCR = "SCR", + SDD = "SDD", SDG = "SDG", + SEI = "SEI", SEK = "SEK", SGD = "SGD", + SHIB = "SHIB", SHP = "SHP", + SHPING = "SHPING", + SIT = "SIT", + SKK = "SKK", + SKL = "SKL", + SLE = "SLE", SLL = "SLL", + SNT = "SNT", + SNX = "SNX", + SOL = "SOL", SOS = "SOS", + SPA = "SPA", + SPELL = "SPELL", + SPL = "SPL", SRD = "SRD", + SRG = "SRG", SSP = "SSP", STD = "STD", + STG = "STG", STN = "STN", + STORJ = "STORJ", + STX = "STX", + SUI = "SUI", + SUKU = "SUKU", + SUPER = "SUPER", + SUSHI = "SUSHI", SVC = "SVC", + SWFTC = "SWFTC", + SYLO = "SYLO", + SYN = "SYN", SYP = "SYP", SZL = "SZL", + T = "T", THB = "THB", + THETA = "THETA", + TIME = "TIME", TJS = "TJS", + TMM = "TMM", TMT = "TMT", TND = "TND", + TON = "TON", + TONE = "TONE", TOP = "TOP", + TRAC = "TRAC", + TRB = "TRB", + TRIBE = "TRIBE", + TRL = "TRL", + TRU = "TRU", + TRX = "TRX", TRY = "TRY", TTD = "TTD", + TTT = "TTT", + TUSD = "TUSD", + TVD = "TVD", + TVK = "TVK", TWD = "TWD", + TWT = "TWT", TZS = "TZS", UAH = "UAH", UGX = "UGX", + UMA = "UMA", + UNFI = "UNFI", + UNI = "UNI", + UPI = "UPI", USD = "USD", + USDC = "USDC", + USDD = "USDD", + USDP = "USDP", + USDT = "USDT", + UST = "UST", UYU = "UYU", UZS = "UZS", + VAL = "VAL", + VARA = "VARA", + VEB = "VEB", + VED = "VED", VEF = "VEF", VES = "VES", + VET = "VET", + VGX = "VGX", VND = "VND", + VOXEL = "VOXEL", + VTHO = "VTHO", VUV = "VUV", + WAMPL = "WAMPL", + WAVES = "WAVES", + WAXL = "WAXL", + WBTC = "WBTC", + WCFG = "WCFG", + WEMIX = "WEMIX", + WLUNA = "WLUNA", + WOO = "WOO", WST = "WST", XAF = "XAF", XAG = "XAG", XAU = "XAU", + XAUT = "XAUT", + XBT = "XBT", XCD = "XCD", + XCH = "XCH", + XCN = "XCN", + XDC = "XDC", XDR = "XDR", + XEC = "XEC", + XEM = "XEM", + XLM = "XLM", + XMON = "XMON", + XMR = "XMR", XOF = "XOF", XPD = "XPD", XPF = "XPF", XPT = "XPT", + XRP = "XRP", + XTZ = "XTZ", + XYO = "XYO", YER = "YER", + YFI = "YFI", + YFII = "YFII", ZAR = "ZAR", + ZEC = "ZEC", + ZEN = "ZEN", + ZIL = "ZIL", + ZMK = "ZMK", ZMW = "ZMW", + ZRX = "ZRX", + ZWD = "ZWD", ZWL = "ZWL", } diff --git a/src/main/plugins/currency-converter-plugin/currency-converter.ts b/src/main/plugins/currency-converter-plugin/currency-converter.ts index 000880223..48ed2aaed 100644 --- a/src/main/plugins/currency-converter-plugin/currency-converter.ts +++ b/src/main/plugins/currency-converter-plugin/currency-converter.ts @@ -5,7 +5,7 @@ import { CurrencyConversion } from "./currency-conversion"; export class CurrencyConverter { public static convert(conversion: CurrencyConversion, precision: number): Promise { return new Promise((resolve, reject) => { - const url = `https://api.exchangerate.host/convert?from=${conversion.base.toUpperCase()}&to=${conversion.target.toUpperCase()}`; + const url = `https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/${conversion.base.toLowerCase()}/${conversion.target.toLowerCase()}.min.json`; axios .get(url, { timeout: 5000 }) .then((response: AxiosResponse) => { @@ -16,11 +16,11 @@ export class CurrencyConverter { return; } const conversionResult: ConversionApiResult = response.data; - if (!conversionResult.success || conversionResult.result == null) { + if (!conversionResult[conversion.target.toLowerCase()]) { reject(`Unable to get exchange rate. Result: ${conversionResult}`); return; } - const rate = conversionResult.result; + const rate = conversionResult[conversion.target.toLowerCase()]; const converted = Number.parseFloat(`${conversion.value * rate}`).toFixed(Number(precision)); resolve(Number(converted)); })