Skip to content

Commit

Permalink
Merge pull request #5 from kleros/chore/migrate-subgraph
Browse files Browse the repository at this point in the history
chore: migrate-subgraph
  • Loading branch information
kemuru authored May 30, 2024
2 parents d618ea0 + 24832ad commit d0ddefc
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 21 additions & 11 deletions src/tag-fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -33,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()
Expand Down Expand Up @@ -60,26 +65,31 @@ 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
}
}
}
`,
}
const response = await fetch(subgraphEndpoint, {
method: "POST",
body: JSON.stringify(subgraphQuery),
headers: {
'Content-Type': 'application/json',
},
})

const { data } = await response.json()
Expand All @@ -98,7 +108,7 @@ const itemToTag = async (
registryType: "addressTags" | "tokens" | "domains"
): Promise<Tag> => {
// 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,
Expand All @@ -114,7 +124,7 @@ const nonTokensFromDomains = async (domainItems: Item[]): Promise<Item[]> => {
const nonTokenDomains: Item[] = []
for (const item of domainItems) {
const tagMatches = await fetchTagsByAddressInRegistry(
item.key0,
item?.metadata?.key0,
"tokens",
conf.XDAI_GTCR_SUBGRAPH_URL
)
Expand Down
12 changes: 7 additions & 5 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d0ddefc

Please sign in to comment.