From 261a65a382730d4f47fabcd1ba4e4de437876078 Mon Sep 17 00:00:00 2001 From: Mahmoud Date: Thu, 16 Nov 2023 18:36:28 +0200 Subject: [PATCH 1/5] added featured apps api util --- api/xverse.ts | 14 +++++++++++--- types/api/xverse/appConfig.ts | 13 +++++++++++++ types/index.ts | 1 + 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 types/api/xverse/appConfig.ts diff --git a/api/xverse.ts b/api/xverse.ts index c07ba236..9bd763b4 100644 --- a/api/xverse.ts +++ b/api/xverse.ts @@ -19,6 +19,8 @@ import { StackingPoolInfo, SupportedCurrency, TokenFiatRateResponse, + FeaturedDapp, + AppConfig, } from '../types'; import { handleAxiosError } from './error'; import { fetchBtcOrdinalsData } from './ordinals'; @@ -270,8 +272,14 @@ export async function getInscription( return response.data; } -export async function getAppConfig(network: NetworkType) { +export async function getAppConfig(network: NetworkType): Promise { const appConfigUrl = `${XVERSE_API_BASE_URL(network)}/v1/app-config`; - const appConfig = await axios.get(appConfigUrl); - return appConfig; + const response = await axios.get(appConfigUrl); + return response.data.appConfig; +} + +export async function getFeaturedDapps(): Promise { + const url = `${XVERSE_API_BASE_URL}/v1/featured/dapp`; + const response = await axios.get(url); + return response.data.featuredDapp; } diff --git a/types/api/xverse/appConfig.ts b/types/api/xverse/appConfig.ts new file mode 100644 index 00000000..42653f70 --- /dev/null +++ b/types/api/xverse/appConfig.ts @@ -0,0 +1,13 @@ +export interface FeaturedDapp { + name: string; + url: string; + image: string; + description: string; + isFeatured: boolean; + order: number; + banner?: string; +} + +export interface AppConfig { + btcApiURL: string; +} diff --git a/types/index.ts b/types/index.ts index 82133ff0..4ff30515 100644 --- a/types/index.ts +++ b/types/index.ts @@ -46,6 +46,7 @@ export * from './api/xverse/sponsor'; export type { Pool, StackerInfo, StackingData, StackingPoolInfo, StackingStateData } from './api/xverse/stacking'; export * from './api/xverse/transaction'; export * from './api/xverse/wallet'; +export * from './api/xverse/appConfig'; export * from './api/xverseInscribe'; export type { SupportedCurrency } from './currency'; export * from './error'; From 083994727bc59b965301cb8a05e500e6050cab62 Mon Sep 17 00:00:00 2001 From: Denys Hriaznov Date: Thu, 8 Feb 2024 20:07:21 +0100 Subject: [PATCH 2/5] Update the getFeaturedDapps method by adding a sectionsEnabled param --- api/xverse.ts | 5 +++-- types/api/xverse/appConfig.ts | 12 ++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/api/xverse.ts b/api/xverse.ts index 13369c6c..5b988907 100644 --- a/api/xverse.ts +++ b/api/xverse.ts @@ -23,6 +23,7 @@ import { TokenFiatRateResponse, FeaturedDapp, AppConfig, + FeaturedDappOld, } from '../types'; import { handleAxiosError } from './error'; import { fetchBtcOrdinalsData } from './ordinals'; @@ -312,9 +313,9 @@ export async function getAppConfig(network: NetworkType): Promise { return response.data.appConfig; } -export async function getFeaturedDapps(): Promise { +export async function getFeaturedDapps(sectionsEnabled = false): Promise<(FeaturedDapp | FeaturedDappOld)[]> { const url = `${XVERSE_API_BASE_URL}/v1/featured/dapp`; - const response = await axios.get(url); + const response = await axios.get(url, { params: { sectionsEnabled } }); return response.data.featuredDapp; } diff --git a/types/api/xverse/appConfig.ts b/types/api/xverse/appConfig.ts index 42653f70..29e0160e 100644 --- a/types/api/xverse/appConfig.ts +++ b/types/api/xverse/appConfig.ts @@ -1,9 +1,17 @@ -export interface FeaturedDapp { +export interface FeaturedDappOld { name: string; url: string; image: string; description: string; - isFeatured: boolean; + order: number; + banner?: string; +} + +export interface FeaturedDapp { + name: string; + url: string; + icon: string; + description: string; order: number; banner?: string; } From d65eb430566c4f39b8a2e13df82fcef189bb3c24 Mon Sep 17 00:00:00 2001 From: Denys Hriaznov Date: Mon, 12 Feb 2024 19:22:25 +0100 Subject: [PATCH 3/5] Add the network param to the getFeaturedDapps function --- api/xverse.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/api/xverse.ts b/api/xverse.ts index 5b988907..c34e867f 100644 --- a/api/xverse.ts +++ b/api/xverse.ts @@ -313,8 +313,11 @@ export async function getAppConfig(network: NetworkType): Promise { return response.data.appConfig; } -export async function getFeaturedDapps(sectionsEnabled = false): Promise<(FeaturedDapp | FeaturedDappOld)[]> { - const url = `${XVERSE_API_BASE_URL}/v1/featured/dapp`; +export async function getFeaturedDapps( + network: NetworkType, + sectionsEnabled = false, +): Promise<(FeaturedDapp | FeaturedDappOld)[]> { + const url = `${XVERSE_API_BASE_URL(network)}/v1/featured/dapp`; const response = await axios.get(url, { params: { sectionsEnabled } }); return response.data.featuredDapp; } From fef4a2121347e1a0ac6421a4577d6f99f17356c9 Mon Sep 17 00:00:00 2001 From: jordankzf Date: Thu, 15 Feb 2024 18:05:49 +0800 Subject: [PATCH 4/5] Use v2 instead of v1 + sectionsEnabled --- api/xverse.ts | 17 +++++++---------- types/api/xverse/appConfig.ts | 17 +++++++---------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/api/xverse.ts b/api/xverse.ts index c34e867f..6251c083 100644 --- a/api/xverse.ts +++ b/api/xverse.ts @@ -21,9 +21,7 @@ import { StackingPoolInfo, SupportedCurrency, TokenFiatRateResponse, - FeaturedDapp, - AppConfig, - FeaturedDappOld, + DappSectionData, } from '../types'; import { handleAxiosError } from './error'; import { fetchBtcOrdinalsData } from './ordinals'; @@ -307,18 +305,17 @@ export async function getInscription( return response.data; } -export async function getAppConfig(network: NetworkType): Promise { +export async function getAppConfig(network: NetworkType) { const appConfigUrl = `${XVERSE_API_BASE_URL(network)}/v1/app-config`; - const response = await axios.get(appConfigUrl); - return response.data.appConfig; + const appConfig = await axios.get(appConfigUrl); + return appConfig; } export async function getFeaturedDapps( network: NetworkType, - sectionsEnabled = false, -): Promise<(FeaturedDapp | FeaturedDappOld)[]> { - const url = `${XVERSE_API_BASE_URL(network)}/v1/featured/dapp`; - const response = await axios.get(url, { params: { sectionsEnabled } }); +): Promise { + const url = `${XVERSE_API_BASE_URL(network)}/v2/featured/dapp`; + const response = await axios.get(url); return response.data.featuredDapp; } diff --git a/types/api/xverse/appConfig.ts b/types/api/xverse/appConfig.ts index 29e0160e..b2e4fdd5 100644 --- a/types/api/xverse/appConfig.ts +++ b/types/api/xverse/appConfig.ts @@ -1,21 +1,18 @@ -export interface FeaturedDappOld { +export type FeaturedDapp = { name: string; url: string; - image: string; + icon: string; description: string; order: number; banner?: string; } -export interface FeaturedDapp { - name: string; - url: string; - icon: string; - description: string; - order: number; - banner?: string; +export type DappSectionData = { + section: string; + view: string; + apps: FeaturedDapp[]; } -export interface AppConfig { +export type AppConfig = { btcApiURL: string; } From f973c332aaf08b1735425d8390dce08d7ecdff03 Mon Sep 17 00:00:00 2001 From: jordankzf Date: Mon, 19 Feb 2024 12:25:19 +0800 Subject: [PATCH 5/5] Prettier --- api/xverse.ts | 4 +--- types/api/xverse/appConfig.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/api/xverse.ts b/api/xverse.ts index 6251c083..7a4d9a19 100644 --- a/api/xverse.ts +++ b/api/xverse.ts @@ -311,9 +311,7 @@ export async function getAppConfig(network: NetworkType) { return appConfig; } -export async function getFeaturedDapps( - network: NetworkType, -): Promise { +export async function getFeaturedDapps(network: NetworkType): Promise { const url = `${XVERSE_API_BASE_URL(network)}/v2/featured/dapp`; const response = await axios.get(url); return response.data.featuredDapp; diff --git a/types/api/xverse/appConfig.ts b/types/api/xverse/appConfig.ts index b2e4fdd5..bc8ec2e8 100644 --- a/types/api/xverse/appConfig.ts +++ b/types/api/xverse/appConfig.ts @@ -5,14 +5,14 @@ export type FeaturedDapp = { description: string; order: number; banner?: string; -} +}; export type DappSectionData = { - section: string; - view: string; - apps: FeaturedDapp[]; -} + section: string; + view: string; + apps: FeaturedDapp[]; +}; export type AppConfig = { btcApiURL: string; -} +};