Skip to content

Commit

Permalink
fix: KongSwap exchange API breaking changes (#1196)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpeterparker authored Feb 6, 2025
1 parent 1f274e1 commit 52a6322
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/frontend/src/lib/schema/kongswap.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ const DateTimeSchema = z.string().refine(

const KongSwapTokenMetricsSchema = z.object({
market_cap: NumberAsStringSchema.nullable(),
previous_price: NumberAsStringSchema.nullable(),
price: NumberAsStringSchema,
price_change_24h: NumberAsStringSchema,
token_id: z.number(),
total_supply: NumberAsStringSchema.nullable(),
tvl: NumberAsStringSchema,
updated_at: DateTimeSchema,
Expand All @@ -31,6 +33,7 @@ export const KongSwapTokenSchema = z.object({
decimals: z.number(),
fee: z.number(),
fee_fixed: z.string().nullable(),
has_custom_logo: z.boolean(),
icrc1: z.boolean(),
icrc2: z.boolean(),
icrc3: z.boolean(),
Expand All @@ -44,6 +47,9 @@ export const KongSwapTokenSchema = z.object({
});

export const KongSwapTokensSchema = z.object({
tokens: z.array(KongSwapTokenSchema),
total_count: z.number()
items: z.array(KongSwapTokenSchema),
total_pages: z.number(),
total_count: z.number(),
page: z.number(),
limit: z.number()
});
4 changes: 2 additions & 2 deletions src/frontend/src/lib/workers/exchange.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ const findICPToken = async (page = 1): Promise<KongSwapToken | undefined> => {
return undefined;
}

const { tokens, total_count } = kongTokens;
const { items, total_count } = kongTokens;

const icp = tokens.find(({ canister_id }) => canister_id === ICP_LEDGER_CANISTER_ID);
const icp = items.find(({ canister_id }) => canister_id === ICP_LEDGER_CANISTER_ID);

if (nonNullish(icp)) {
return icp;
Expand Down

0 comments on commit 52a6322

Please sign in to comment.