Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update-subgraph-queries #338

Merged
merged 7 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions src/components/light-search-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const OptionItem = ({ item }) => {
// there are a few ethers queries coming from here.
// they might have to be changed to subgraph queries
// TODO read and figure it out
const { itemID, props, registry } = item
const { itemID, metadata: itemMetadata, registry } = item
const { id: tcrAddress } = registry
const {
gtcrView,
Expand Down Expand Up @@ -111,14 +111,14 @@ const OptionItem = ({ item }) => {
<>
<StyledItemField>
<DisplaySelector
type={props[0].type}
value={props[0].value}
allowedFileTypes={props[0].allowedFileTypes}
type={itemMetadata?.props[0].type}
value={itemMetadata?.props[0].value}
allowedFileTypes={itemMetadata?.props[0].allowedFileTypes}
/>
</StyledItemField>
</>
) : (
props
itemMetadata?.props
.filter(col => col.isIdentifier)
.map((column, j) => (
<StyledItemField key={j}>
Expand All @@ -142,12 +142,14 @@ const OptionItem = ({ item }) => {
OptionItem.propTypes = {
item: PropTypes.shape({
itemID: PropTypes.string,
props: PropTypes.arrayOf(
PropTypes.shape({
type: PropTypes.oneOf(Object.values(ItemTypes)),
value: PropTypes.string.isRequired
})
),
metadata: PropTypes.shape({
props: PropTypes.arrayOf(
PropTypes.shape({
type: PropTypes.oneOf(Object.values(ItemTypes)),
value: PropTypes.string.isRequired
})
)
}),
registry: PropTypes.shape({
id: PropTypes.string
})
Expand Down Expand Up @@ -182,7 +184,7 @@ const LightSearchBar = () => {
}, [itemSearchQuery])

const options = data.map(d => {
const itemLabels = d.props.filter(prop =>
const itemLabels = d.metadata?.props.filter(prop =>
searchableFields.includes(prop.type)
)

Expand Down
18 changes: 9 additions & 9 deletions src/components/request-timelines.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ const Timeline = ({ request, item, metaEvidence }) => {
name: 'Evidence',
timestamp: e.timestamp,
transactionHash: e.txHash,
title: e.title,
description: e.description,
title: e.metadata.title,
description: e.metadata.description,
URI: e.URI,
fileURI: e.fileURI,
fileTypeExtension: e.fileTypeExtension,
fileURI: e.metadata.fileURI,
fileTypeExtension: e.metadata.fileTypeExtension,
party: e.party
}))

Expand All @@ -117,13 +117,13 @@ const Timeline = ({ request, item, metaEvidence }) => {
useEffect(() => {
const evidenceManualFetch = async () => {
const unindexedEvidenceURIs = logs
.filter(e => e.name === 'Evidence')
.filter(e => e.metadata?.name === 'Evidence')
.filter(
e =>
e.title === null &&
e.description === null &&
e.fileURI === null &&
e.fileTypeExtension === null
e.metadata?.title === null &&
e.metadata?.description === null &&
e.metadata?.fileURI === null &&
e.metadata?.fileTypeExtension === null
)
.map(e => e.URI)

Expand Down
6 changes: 4 additions & 2 deletions src/config/tcr-addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ export const txBatcherAddresses = {
} as const

export const subgraphUrl = {
'1': 'https://api.thegraph.com/subgraphs/name/kleros/curate',
'1':
'https://api.studio.thegraph.com/query/61738/legacy-curate-mainnet/version/latest',
'5': 'https://api.thegraph.com/subgraphs/name/kleros/curate-goerli',
'100': 'https://api.thegraph.com/subgraphs/name/kleros/legacy-curate-xdai'
'100':
'https://api.studio.thegraph.com/query/61738/legacy-curate-gnosis/version/latest'
} as const
2 changes: 2 additions & 0 deletions src/hooks/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const useFactory = () => {
const { data } = await (
await fetch(GTCR_SUBGRAPH_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(query)
})
).json()
Expand Down Expand Up @@ -55,6 +56,7 @@ const useFactory = () => {
const { data } = await (
await fetch(GTCR_SUBGRAPH_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(query)
})
).json()
Expand Down
1 change: 1 addition & 0 deletions src/hooks/light-tcr-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const fetchMetaEvidence = async (tcr, networkId) => {

const response = await fetch(subgraphUrl[networkId], {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(query)
})

Expand Down
4 changes: 3 additions & 1 deletion src/hooks/tcr-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ export const fetchMetaEvidence = async (tcr, networkId) => {
}
connectedTCR
}
}`
}`,
variables: {}
}

const response = await fetch(subgraphUrl[networkId], {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(query)
})

Expand Down
19 changes: 11 additions & 8 deletions src/pages/light-item-details/badges/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ const mapToLegacy = items =>
items
.map(item => ({
...item,
decodedData: item.props.map(({ value }) => value),
mergedData: item.props
decodedData: item.metadata?.props.map(({ value }) => value),
mergedData: item.metadata?.props
}))
.map(
({
Expand Down Expand Up @@ -327,12 +327,14 @@ const Badges = ({ connectedTCRAddr, item, tcrAddress }) => {
itemID
status
data
props {
value
type
label
description
isIdentifier
metadata{
props {
value
type
label
description
isIdentifier
}
}
requests(first: 1, orderBy: submissionTime, orderDirection: desc) {
disputed
Expand All @@ -359,6 +361,7 @@ const Badges = ({ connectedTCRAddr, item, tcrAddress }) => {
const { data } = await (
await fetch(GTCR_SUBGRAPH_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(query)
})
).json()
Expand Down
11 changes: 8 additions & 3 deletions src/pages/light-items/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ const Items = () => {
let { litems: items } = data
items = items.map(item => ({
...item,
decodedData: item.props.map(({ value }) => value),
mergedData: item.props
decodedData: item.metadata?.props.map(({ value }) => value),
mergedData: item.metadata?.props
}))
// HACK:
// the graph could have failed to include the props.
Expand All @@ -276,7 +276,12 @@ const Items = () => {
value: item.values[column.label]
}))
const decodedData = mergedData.map(d => d.value)
const newItem = { ...i, mergedData, decodedData, props: mergedData }
const newItem = {
...i,
mergedData,
decodedData,
metadata: { props: mergedData }
}
return newItem
} else return i
})
Expand Down
11 changes: 7 additions & 4 deletions src/utils/graphql/classic-item-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@ const CLASSIC_ITEM_DETAILS_QUERY = gql`
id
evidences(orderBy: number, orderDirection: desc) {
party
title
description
URI
fileURI
number
timestamp
txHash
fileTypeExtension
metadata {
name
title
description
fileURI
fileTypeExtension
}
}
}
rounds(orderBy: creationTime, orderDirection: desc) {
Expand Down
11 changes: 7 additions & 4 deletions src/utils/graphql/item-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@ const LIGHT_ITEM_DETAILS_QUERY = gql`
id
evidences(orderBy: number, orderDirection: desc) {
party
title
description
URI
fileURI
number
timestamp
txHash
fileTypeExtension
metadata {
name
title
description
fileURI
fileTypeExtension
}
}
}
rounds(orderBy: creationTime, orderDirection: desc) {
Expand Down
10 changes: 6 additions & 4 deletions src/utils/graphql/item-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ const ITEM_SEARCH_QUERY = gql`
id
itemID
data
props {
type
value
isIdentifier
metadata {
props {
type
value
isIdentifier
}
}
registry {
id
Expand Down
14 changes: 8 additions & 6 deletions src/utils/graphql/light-items.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ const LIGHT_ITEMS_QUERY = gql`
itemID
status
data
props {
value
type
label
description
isIdentifier
metadata {
props {
value
type
label
description
isIdentifier
}
}
requests(first: 1, orderBy: submissionTime, orderDirection: desc) {
disputed
Expand Down
Loading