Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions workers/loc.api/errors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ class ObjectMappingError extends BaseError {
}

class CurrencyConversionDataFindingError extends BaseError {
constructor (message = 'ERR_DATA_IS_NOT_FOUND_TO_CONVERT_CURRENCY') {
super(message)
constructor (data, message = 'ERR_DATA_IS_NOT_FOUND_TO_CONVERT_CURRENCY') {
super({ data, message })
}
}

Expand Down
24 changes: 18 additions & 6 deletions workers/loc.api/sync/currency.converter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,17 +348,25 @@ class CurrencyConverter {
if (typeof symbol !== 'string') {
return ''
}
if (symbol.length < 8) {
if (symbol.length < 6) {
return symbol
}

const hasFlag = (
symbol.startsWith('t') ||
symbol.startsWith('f')
)
const flag = hasFlag
? symbol[0]
: 't'

if (
symbol[0] !== 't' &&
symbol[0] !== 'f'
symbol.length === 7 &&
hasFlag
) {
return symbol
}

const flag = symbol[0]
const [firstSymb, lastSymb] = splitSymbolPairs(symbol)
const _firstSymb = this._getConvertingSymb(firstSymb)
const _lastSymb = this._getConvertingSymb(lastSymb)
Expand Down Expand Up @@ -1031,7 +1039,9 @@ class CurrencyConverter {
)

if (!Number.isFinite(price)) {
throw new CurrencyConversionDataFindingError()
throw new CurrencyConversionDataFindingError(
{ symbol: reqSymb, mts }
)
}

return price
Expand Down Expand Up @@ -1082,7 +1092,9 @@ class CurrencyConverter {
)
}

throw new CurrencyConversionDataFindingError()
throw new CurrencyConversionDataFindingError(
{ symbol: reqSymb, mts: end }
)
}

async convertManyByCandles (data, convSchema) {
Expand Down