mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-14 06:02:36 +03:00
feat: Frontage service code review
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@orionprotocol/sdk",
|
||||
"version": "0.20.79-rc16",
|
||||
"version": "0.20.79-rc17",
|
||||
"description": "Orion Protocol SDK",
|
||||
"main": "./lib/index.cjs",
|
||||
"module": "./lib/index.js",
|
||||
|
||||
@@ -18,15 +18,15 @@ export class Frontage {
|
||||
offset,
|
||||
limit,
|
||||
}: { searchValue: string } & TickersBaseSearchParams) => {
|
||||
const queryParams = [
|
||||
`searchValue=${encodeURIComponent(searchValue)}`,
|
||||
currentNetwork !== undefined ? `¤tNetwork=${encodeURIComponent(currentNetwork).toUpperCase()}` : '',
|
||||
targetNetwork !== undefined ? `&targetNetwork=${encodeURIComponent(targetNetwork).toUpperCase()}` : '',
|
||||
sortBy !== undefined ? `&sortBy=${encodeURIComponent(sortBy)}` : '',
|
||||
sortType !== undefined ? `&sortType=${encodeURIComponent(sortType)}` : '',
|
||||
offset !== undefined ? `&offset=${offset}` : '',
|
||||
limit !== undefined ? `&limit=${limit}` : '',
|
||||
].filter(Boolean).join('&');
|
||||
const queryParams = new URLSearchParams({
|
||||
searchValue: encodeURIComponent(searchValue),
|
||||
currentNetwork: currentNetwork !== undefined ? encodeURIComponent(currentNetwork).toUpperCase() : '',
|
||||
targetNetwork: targetNetwork !== undefined ? encodeURIComponent(targetNetwork).toUpperCase() : '',
|
||||
sortBy: sortBy !== undefined ? encodeURIComponent(sortBy) : '',
|
||||
sortType: sortType !== undefined ? encodeURIComponent(sortType) : '',
|
||||
offset: offset !== undefined ? offset.toString() : '',
|
||||
limit: limit !== undefined ? limit.toString() : '',
|
||||
}).toString();
|
||||
|
||||
return fetchWithValidation(
|
||||
`${this.apiUrl}/api/v1/tickers/search?${queryParams}`,
|
||||
@@ -44,15 +44,15 @@ export class Frontage {
|
||||
limit,
|
||||
tickers,
|
||||
}: { category: TickersCategories, tickers?: string } & TickersBaseSearchParams) => {
|
||||
const queryParams = [
|
||||
category === 'FAVORITES' && tickers !== undefined ? `tickers=${encodeURIComponent(tickers)}` : `category=${encodeURIComponent(category)}`,
|
||||
currentNetwork !== undefined ? `¤tNetwork=${encodeURIComponent(currentNetwork).toUpperCase()}` : '',
|
||||
targetNetwork !== undefined ? `&targetNetwork=${encodeURIComponent(targetNetwork).toUpperCase()}` : '',
|
||||
sortBy !== undefined ? `&sortBy=${encodeURIComponent(sortBy)}` : '',
|
||||
sortType !== undefined ? `&sortType=${encodeURIComponent(sortType)}` : '',
|
||||
offset !== undefined ? `&offset=${offset}` : '',
|
||||
limit !== undefined ? `&limit=${limit}` : '',
|
||||
].filter(Boolean).join('&');
|
||||
const queryParams = new URLSearchParams({
|
||||
category: category === 'FAVORITES' && tickers !== undefined ? `tickers=${encodeURIComponent(tickers)}` : `category=${encodeURIComponent(category)}`,
|
||||
currentNetwork: currentNetwork !== undefined ? encodeURIComponent(currentNetwork).toUpperCase() : '',
|
||||
targetNetwork: targetNetwork !== undefined ? encodeURIComponent(targetNetwork).toUpperCase() : '',
|
||||
sortBy: sortBy !== undefined ? encodeURIComponent(sortBy) : '',
|
||||
sortType: sortType !== undefined ? encodeURIComponent(sortType) : '',
|
||||
offset: offset !== undefined ? offset.toString() : '',
|
||||
limit: limit !== undefined ? limit.toString() : '',
|
||||
}).toString();
|
||||
|
||||
const url = category === 'FAVORITES' && tickers !== undefined
|
||||
? `${this.apiUrl}/api/v1/tickers/get/favourites?${queryParams}`
|
||||
@@ -63,31 +63,6 @@ export class Frontage {
|
||||
tickersSchema
|
||||
);
|
||||
};
|
||||
|
||||
getFavorites = ({
|
||||
tickers,
|
||||
currentNetwork,
|
||||
targetNetwork,
|
||||
sortBy,
|
||||
sortType,
|
||||
offset,
|
||||
limit,
|
||||
}: { tickers: string } & TickersBaseSearchParams) => {
|
||||
const queryParams = [
|
||||
`tickers=${encodeURIComponent(tickers)}`,
|
||||
currentNetwork !== undefined ? `¤tNetwork=${encodeURIComponent(currentNetwork).toUpperCase()}` : '',
|
||||
targetNetwork !== undefined ? `&targetNetwork=${encodeURIComponent(targetNetwork).toUpperCase()}` : '',
|
||||
sortBy !== undefined ? `&sortBy=${encodeURIComponent(sortBy)}` : '',
|
||||
sortType !== undefined ? `&sortType=${encodeURIComponent(sortType)}` : '',
|
||||
offset !== undefined ? `&offset=${offset}` : '',
|
||||
limit !== undefined ? `&limit=${limit}` : '',
|
||||
].filter(Boolean).join('&');
|
||||
|
||||
return fetchWithValidation(
|
||||
`${this.apiUrl}/api/v1/tickers/get/favourites?${queryParams}`,
|
||||
tickersSchema
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
export * as schemas from './schemas/index.js';
|
||||
|
||||
Reference in New Issue
Block a user