Skip to content

Commit 22c42e8

Browse files
authored
Merge pull request #7 from Harman-singh-waraich/chore/migrate-subgraph
chore: migrate-subgraph
2 parents 308c857 + c8c607e commit 22c42e8

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CURATE_GRAPH_URL=https://api.thegraph.com/subgraphs/name/greenlucid/legacy-curate-xdai
1+
CURATE_GRAPH_URL=https://api.studio.thegraph.com/query/61738/legacy-curate-gnosis/version/latest
22
KLEROS_TOKENS_REGISTRY_ADDRESS=0xee1502e29795ef6c2d60f8d7120596abe3bad990
33

44
ENS_CONTRACT=0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e

src/utils/get-tokens.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ export interface Prop {
88
}
99

1010
export interface Item {
11-
props: Prop[]
11+
metadata : {
12+
props: Prop[]
13+
} | null
1214
id: string
1315
}
1416

@@ -22,16 +24,18 @@ const fetchTokensBatch = async (id: string): Promise<Item[]> => {
2224
id_gt: "${id}"
2325
}, first: 1000) {
2426
id
25-
props {
26-
label
27-
value
27+
metadata {
28+
props {
29+
label
30+
value
31+
}
2832
}
2933
}
3034
}
3135
`,
3236
}
3337
const response = await fetch(
34-
'https://api.thegraph.com/subgraphs/name/greenlucid/legacy-curate-xdai',
38+
'https://api.studio.thegraph.com/query/61738/legacy-curate-gnosis/version/latest',
3539
{
3640
method: 'POST',
3741
body: JSON.stringify(subgraphQuery),
@@ -79,13 +83,13 @@ export default async function getTokens(): Promise<TokenInfo[]> {
7983

8084
const tokens: Map<string, TokenInfo> = new Map()
8185
for (const token of tokensFromSubgraph) {
82-
const caipAddress = token.props.find((p) => p.label === 'Address')
86+
const caipAddress = token?.metadata?.props.find((p) => p.label === 'Address')
8387
?.value as string
84-
const name = token.props.find((p) => p.label === 'Name')?.value as string
85-
const symbol = token.props.find((p) => p.label === 'Symbol')
88+
const name = token?.metadata?.props.find((p) => p.label === 'Name')?.value as string
89+
const symbol = token?.metadata?.props.find((p) => p.label === 'Symbol')
8690
?.value as string
87-
const logo = token.props.find((p) => p.label === 'Logo')?.value as string
88-
const decimals = token.props.find((p) => p.label === 'Decimals')
91+
const logo = token?.metadata?.props.find((p) => p.label === 'Logo')?.value as string
92+
const decimals = token?.metadata?.props.find((p) => p.label === 'Decimals')
8993
?.value as string
9094

9195
const [namespace] = caipAddress.split(':')

0 commit comments

Comments
 (0)