Skip to content

Commit

Permalink
Update API bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
carina-akaia committed Nov 28, 2024
1 parent c83198a commit 7448da5
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 50 deletions.
42 changes: 0 additions & 42 deletions api-codegen.config.cjs

This file was deleted.

29 changes: 27 additions & 2 deletions api.config.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
//? NOTE: Orval does not support ESM configs at the moment
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { resolve } = require("path");

const apiPath = resolve(__dirname, "./src/common/api");
const clientPath = "internal/client.generated.ts";

const targetPaths = {
indexer: "./src/common/api/indexer/internal/client.generated.ts",
indexer: resolve(apiPath, "indexer", clientPath),
prices: resolve(apiPath, "prices", clientPath),
};

module.exports = {
Expand All @@ -8,10 +16,27 @@ module.exports = {
*/
indexer: {
input: "https://test-dev.potlock.io/api/schema",
output: { target: targetPaths.indexer, client: "swr" },

output: {
target: targetPaths.indexer,
client: "swr",
},

hooks: {
afterAllFilesWrite: `eslint --fix ${targetPaths.indexer}`,
},
},

prices: {
input: "https://prices.intear.tech/openapi",

output: {
target: targetPaths.prices,
client: "swr",
},

hooks: {
afterAllFilesWrite: `eslint --fix ${targetPaths.prices}`,
},
},
};
6 changes: 3 additions & 3 deletions src/common/api/prices/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { ByTokenId } from "@/common/types";

import { PRICES_REQUEST_CONFIG } from "./config";
import * as swrBindings from "./generated/client";
import * as generatedClient from "./internal/client.generated";
import { PRICES_REQUEST_CONFIG } from "./internal/config";

/**
* https://prices.intear.tech/swagger-ui/#/Token%20Prices/get_get_token_price
*/
export const useTokenUsdPrice = ({ tokenId }: Partial<ByTokenId>) => {
const queryResult = swrBindings.useGetGetTokenPrice(
const queryResult = generatedClient.useGetGetTokenPrice(
{ token_id: tokenId ?? "unknown" },

{
Expand Down
4 changes: 2 additions & 2 deletions src/common/api/prices/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { PRICES_REQUEST_CONFIG } from "./config";
export * as pricesClient from "./generated/client";
export { PRICES_REQUEST_CONFIG } from "./internal/config";
export * as pricesClient from "./internal/client.generated";
export * as prices from "./hooks";
export * from "./types";
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/common/api/prices/types.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export type * from "./generated/client";
export type * from "./internal/client.generated";

0 comments on commit 7448da5

Please sign in to comment.