From cb34b9c3e55d4a1026c7021226fb42544305a667 Mon Sep 17 00:00:00 2001 From: Harman-singh-waraich Date: Mon, 20 May 2024 15:52:50 +0530 Subject: [PATCH 1/2] chore: migrate-subgraph --- .env.example | 2 +- src/tag-fetch.ts | 26 +++++++++++++++----------- src/types.ts | 12 +++++++----- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/.env.example b/.env.example index bf3714a..e83aba2 100644 --- a/.env.example +++ b/.env.example @@ -3,7 +3,7 @@ WALLET_PRIVATE_KEY= STIPEND=100000000000000000000000 MAX_REWARD=1000000000000000000000 PNK=0xcb3231aBA3b451343e0Fddfc45883c842f223846 -XDAI_GTCR_SUBGRAPH_URL=https://api.thegraph.com/subgraphs/name/greenlucid/legacy-curate-xdai +XDAI_GTCR_SUBGRAPH_URL=https://api.studio.thegraph.com/query/61738/legacy-curate-gnosis/version/latest XDAI_REGISTRY_ADDRESS_TAGS=0x66260c69d03837016d88c9877e61e08ef74c59f2 XDAI_REGISTRY_TOKENS=0xee1502e29795ef6c2d60f8d7120596abe3bad990 XDAI_REGISTRY_DOMAINS=0x957a53a994860be4750810131d9c876b2f52d6e1 diff --git a/src/tag-fetch.ts b/src/tag-fetch.ts index 0389c8d..2351ead 100644 --- a/src/tag-fetch.ts +++ b/src/tag-fetch.ts @@ -17,8 +17,10 @@ const fetchTagsByAddressInRegistry = async ( { litems(where: { registry: "${registry}", - key0_starts_with_nocase: "${caipAddress}", - key0_ends_with_nocase: "${caipAddress}" + metadata_: { + key0_starts_with_nocase: "${caipAddress}", + key0_ends_with_nocase: "${caipAddress}" + } }) { status requests { @@ -60,19 +62,21 @@ const fetchTagsBatchByRegistry = async ( latestRequestResolutionTime_lt: ${end} }, first: 1000) { id - props { - value - } latestRequestResolutionTime requests { requester requestType resolutionTime } - key0 - key1 - key2 - key3 + metadata { + props { + value + } + key0 + key1 + key2 + key3 + } } } `, @@ -98,7 +102,7 @@ const itemToTag = async ( registryType: "addressTags" | "tokens" | "domains" ): Promise => { // in all 3 registries, key0 is caip address - const { chain, address } = parseCaip(item.key0) + const { chain, address } = parseCaip(item?.metadata?.key0) const tag: Tag = { id: item.id, registry: registryType, @@ -114,7 +118,7 @@ const nonTokensFromDomains = async (domainItems: Item[]): Promise => { const nonTokenDomains: Item[] = [] for (const item of domainItems) { const tagMatches = await fetchTagsByAddressInRegistry( - item.key0, + item?.metadata?.key0, "tokens", conf.XDAI_GTCR_SUBGRAPH_URL ) diff --git a/src/types.ts b/src/types.ts index f6b267f..d28fbec 100644 --- a/src/types.ts +++ b/src/types.ts @@ -5,16 +5,18 @@ export interface Prop { } export interface Item { - props: Prop[] id: string latestRequestResolutionTime: string registryAddress?: string status?: string requests: ItemRequest[] - key0: string - key1: string - key2: string - key3: string + metadata : { + props: Prop[] + key0: string + key1: string + key2: string + key3: string + } | null } export interface ItemRequest { From 24832adf999143f080b057445c89db673c8fa3cb Mon Sep 17 00:00:00 2001 From: salgozino Date: Wed, 29 May 2024 17:56:42 -0300 Subject: [PATCH 2/2] fix: add missing headers New studio api need Content-Type header to be defined as application/json --- src/tag-fetch.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/tag-fetch.ts b/src/tag-fetch.ts index 2351ead..37850d4 100644 --- a/src/tag-fetch.ts +++ b/src/tag-fetch.ts @@ -35,6 +35,9 @@ const fetchTagsByAddressInRegistry = async ( const response = await fetch(subgraphEndpoint, { method: "POST", body: JSON.stringify(subgraphQuery), + headers: { + 'Content-Type': 'application/json', + }, }) const { data } = await response.json() @@ -84,6 +87,9 @@ const fetchTagsBatchByRegistry = async ( const response = await fetch(subgraphEndpoint, { method: "POST", body: JSON.stringify(subgraphQuery), + headers: { + 'Content-Type': 'application/json', + }, }) const { data } = await response.json()