From d27d9c41cdf3d2085e0bbaef937fa8eb51ebe52b Mon Sep 17 00:00:00 2001 From: Harman-singh-waraich Date: Mon, 25 Aug 2025 19:07:27 +0530 Subject: [PATCH 1/2] chore: envio-query-migration --- src/utils/get-tokens.ts | 48 +++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/src/utils/get-tokens.ts b/src/utils/get-tokens.ts index 2483610..4f1ce50 100644 --- a/src/utils/get-tokens.ts +++ b/src/utils/get-tokens.ts @@ -8,9 +8,7 @@ export interface Prop { } export interface Item { - metadata: { - props: Prop[] - } | null + props: Prop[] id: string } @@ -20,32 +18,23 @@ const fetchTokensBatch = async (id: string): Promise => { } const subgraphQuery = { query: ` - { - litems(where: { - registryAddress: "${process.env.KLEROS_TOKENS_REGISTRY_ADDRESS}", - status_in: [Registered, ClearingRequested], - id_gt: "${id}" - }, first: 1000) { - id - metadata { - props { - label - value - } - } - } + { + litems: LItem( + where: {registryAddress: {_eq: "${process.env.KLEROS_TOKENS_REGISTRY_ADDRESS}"}, status: {_in: [Registered, ClearingRequested]}, id: {_gt: "${id}}"}} + limit: 1000 + ) { + id + props { + label + value } + } + } `, } const response = await fetch(process.env.CURATE_GRAPH_URL, { method: 'POST', body: JSON.stringify(subgraphQuery), - headers: { - 'Content-Type': 'application/json', - ...(process.env.GRAPH_API_KEY - ? { Authorization: `Bearer ${process.env.GRAPH_API_KEY}` } - : {}), - }, }) const { data } = await response.json() @@ -89,16 +78,13 @@ export default async function getTokens(): Promise { const tokens: Map = new Map() for (const token of tokensFromSubgraph) { - const caipAddress = token?.metadata?.props.find( - (p) => p.label === 'Address', - )?.value as string - const name = token?.metadata?.props.find((p) => p.label === 'Name') - ?.value as string - const symbol = token?.metadata?.props.find((p) => p.label === 'Symbol') + const caipAddress = token?.props.find((p) => p.label === 'Address') ?.value as string - const logo = token?.metadata?.props.find((p) => p.label === 'Logo') + const name = token?.props.find((p) => p.label === 'Name')?.value as string + const symbol = token?.props.find((p) => p.label === 'Symbol') ?.value as string - const decimals = token?.metadata?.props.find((p) => p.label === 'Decimals') + const logo = token?.props.find((p) => p.label === 'Logo')?.value as string + const decimals = token?.props.find((p) => p.label === 'Decimals') ?.value as string if (!caipAddress || !name || !symbol || !decimals) { From 8399734e078d194f16cd8212085d8b71bec9463b Mon Sep 17 00:00:00 2001 From: Harman-singh-waraich Date: Tue, 28 Oct 2025 14:05:39 +0530 Subject: [PATCH 2/2] chore: specify-content-type --- src/utils/get-tokens.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/utils/get-tokens.ts b/src/utils/get-tokens.ts index 4f1ce50..a435254 100644 --- a/src/utils/get-tokens.ts +++ b/src/utils/get-tokens.ts @@ -35,6 +35,9 @@ const fetchTokensBatch = async (id: string): Promise => { const response = await fetch(process.env.CURATE_GRAPH_URL, { method: 'POST', body: JSON.stringify(subgraphQuery), + headers: { + 'Content-Type': 'application/json', + }, }) const { data } = await response.json()