Skip to content

Commit

Permalink
Merge pull request #56 from kleros/chore/migrate-subgraph
Browse files Browse the repository at this point in the history
chore: migrate-subgraph
  • Loading branch information
jaybuidl authored Jun 3, 2024
2 parents c9dd0dc + 0bcac23 commit b445204
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
spec: '@yarnpkg/plugin-workspace-tools'
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
spec: '@yarnpkg/plugin-interactive-tools'

yarnPath: .yarn/releases/yarn-3.3.1.cjs
12 changes: 7 additions & 5 deletions packages/site/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,18 @@ const Index = () => {
useEffect(() => {
const fetchData = async () => {
const response = await axios.post(
'https://api.thegraph.com/subgraphs/name/kleros/legacy-curate-xdai',
'https://api.studio.thegraph.com/query/61738/legacy-curate-gnosis/version/latest',
{
query: `
{
litems(first:1000, where:{registry:"0xfdb66ad9576842945431c27fe8cb5ef8ed5cb8bb", status_in:[Registered], disputed:false})
{
itemID
key0
key1
key2
metadata {
key0
key1
key2
}
}
}
`,
Expand Down Expand Up @@ -187,7 +189,7 @@ const Index = () => {
</Subtext>
<SearchResultList>
{filteredPackages.map((pkg) => {
const isVerified = packages.some((item) => item.key0 === pkg.name);
const isVerified = packages.some((item) => item?.metadata?.key0 === pkg.name);
return (
<SearchResultItem
key={pkg.name}
Expand Down
64 changes: 38 additions & 26 deletions packages/snap/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,34 +51,46 @@ const fetchGraphQLData = async (variables: {
query($targetAddress: String!, $domain: String!) {
addressTags: litems(where:{
registry:"0x66260c69d03837016d88c9877e61e08ef74c59f2",
key0_starts_with_nocase: $targetAddress,
key0_ends_with_nocase: $targetAddress,
metadata_: {
key0_starts_with_nocase: $targetAddress,
key0_ends_with_nocase: $targetAddress,
},
status_in:[Registered, ClearingRequested]
}, first: 1) {
key0
key1
key2
key3
metadata {
key0
key1
key2
key3
}
}
contractDomains: litems(where:{
registry:"0x957a53a994860be4750810131d9c876b2f52d6e1",
key0_starts_with_nocase: $targetAddress,
key0_ends_with_nocase: $targetAddress,
key1: $domain,
metadata_: {
key0_starts_with_nocase: $targetAddress,
key0_ends_with_nocase: $targetAddress,
key1: $domain,
},
status_in:[Registered, ClearingRequested]
}, first: 1) {
key0
key1
metadata {
key0
key1
}
}
tokens: litems(where:{
registry:"0x70533554fe5c17caf77fe530f77eab933b92af60",
key0_starts_with_nocase: $targetAddress,
key0_ends_with_nocase: $targetAddress,
metadata_: {
key0_starts_with_nocase: $targetAddress,
key0_ends_with_nocase: $targetAddress,
},
status_in:[Registered, ClearingRequested]
}, first: 1) {
key0
key1
key2
metadata {
key0
key1
key2
}
}
}
`;
Expand All @@ -87,7 +99,7 @@ const fetchGraphQLData = async (variables: {

try {
const response = await fetch(
'https://api.thegraph.com/subgraphs/name/kleros/legacy-curate-xdai',
'https://api.studio.thegraph.com/query/61738/legacy-curate-gnosis/version/latest',
{
method: 'POST',
headers: {
Expand Down Expand Up @@ -119,26 +131,26 @@ const fetchGraphQLData = async (variables: {

const parsedAddressTag: AddressTag | undefined = result.data.addressTags[0]
? {
caipAddress: mdEscape(result.data.addressTags[0].key0),
publicName: mdEscape(result.data.addressTags[0].key1),
projectName: mdEscape(result.data.addressTags[0].key2),
infoLink: mdEscape(result.data.addressTags[0].key3),
caipAddress: mdEscape(result.data.addressTags[0].metadata.key0),
publicName: mdEscape(result.data.addressTags[0].metadata.key1),
projectName: mdEscape(result.data.addressTags[0].metadata.key2),
infoLink: mdEscape(result.data.addressTags[0].metadata.key3),
}
: undefined;

const parsedContractDomain: ContractDomain | undefined = result.data
.contractDomains[0]
? {
caipAddress: mdEscape(result.data.contractDomains[0].key0),
domain: mdEscape(result.data.contractDomains[0].key1),
caipAddress: mdEscape(result.data.contractDomains[0].metadata.key0),
domain: mdEscape(result.data.contractDomains[0].metadata.key1),
}
: undefined;

const parsedToken: Token | undefined = result.data.tokens[0]
? {
caipAddress: mdEscape(result.data.tokens[0].key0),
name: mdEscape(result.data.tokens[0].key1),
symbol: mdEscape(result.data.tokens[0].key2),
caipAddress: mdEscape(result.data.tokens[0].metadata.key0),
name: mdEscape(result.data.tokens[0].metadata.key1),
symbol: mdEscape(result.data.tokens[0].metadata.key2),
}
: undefined;

Expand Down

0 comments on commit b445204

Please sign in to comment.