Skip to content

Commit

Permalink
Merge pull request #22 from decentraland/feat/catalog-query-updates
Browse files Browse the repository at this point in the history
feat: Latest catalog updates based on substreams changes
  • Loading branch information
juanmahidalgo committed Aug 3, 2023
2 parents 40aeaf6 + ba1638f commit a0b7a0d
Show file tree
Hide file tree
Showing 7 changed files with 306 additions and 192 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"typescript": "^4.9.5"
},
"dependencies": {
"@dcl/schemas": "^7.5.0",
"@dcl/schemas": "^8.2.2",
"@well-known-components/env-config-provider": "^1.1.1",
"@well-known-components/http-server": "^1.1.6",
"@well-known-components/interfaces": "^1.2.0",
Expand Down
45 changes: 45 additions & 0 deletions src/logic/contracts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ChainId, Contract, Network, NFTCategory } from '@dcl/schemas'
import { getPolygonChainId } from './chainIds'

export function getMarketplaceContracts(chainId: ChainId): Contract[] {
switch (chainId) {
Expand Down Expand Up @@ -353,7 +354,51 @@ export function getMarketplaceContracts(chainId: ChainId): Contract[] {
}
]
}
case ChainId.ETHEREUM_SEPOLIA: {
return [
{
name: 'LAND',
address: '0x42f4ba48791e2de32f5fbf553441c2672864bb33',
category: NFTCategory.PARCEL,
network: Network.ETHEREUM,
chainId: ChainId.ETHEREUM_GOERLI
},
{
name: 'Estates',
address: '0x369a7fbe718c870c79f99fb423882e8dd8b20486',
category: NFTCategory.ESTATE,
network: Network.ETHEREUM,
chainId: ChainId.ETHEREUM_GOERLI
},
{
name: 'Names',
address: '0x7518456ae93eb98f3e64571b689c626616bb7f30',
category: NFTCategory.ENS,
network: Network.ETHEREUM,
chainId: ChainId.ETHEREUM_GOERLI
},
{
name: 'Exclusive Masks',
address: '0x11a970e744ff69db8f461c2d0fc91d4293914301',
network: Network.ETHEREUM,
chainId: ChainId.ETHEREUM_GOERLI,
category: NFTCategory.WEARABLE
}
]
}
default:
return []
}
}

export const getCollectionStoreAddress = () => {
const chainId = getPolygonChainId()
switch (chainId) {
case ChainId.MATIC_MAINNET:
return '0x214ffc0f0103735728dc66b61a22e4f163e275ae'
case ChainId.MATIC_MUMBAI:
return '0x6ddf1b1924dad850adbc1c02026535464be06b0c'
default:
return ''
}
}
6 changes: 4 additions & 2 deletions src/ports/catalog/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export async function createCatalogComponent(components: Pick<AppComponents, 'da
let total = 0
const client = await database.getPool().connect()
try {
const sources = (network ? [network] : creator ? [Network.MATIC] : [Network.ETHEREUM, Network.MATIC]).reduce((acc, curr) => {
const networks = network ? [network] : creator && creator.length ? [Network.MATIC] : [Network.ETHEREUM, Network.MATIC]
const sources = networks.reduce((acc, curr) => {
acc[curr] = getChainName(curr === Network.ETHEREUM ? marketplaceChainId : collectionsChainId) || ''
return acc
}, {} as Record<string, string>)
Expand Down Expand Up @@ -45,7 +46,8 @@ export async function createCatalogComponent(components: Pick<AppComponents, 'da
filters.ids = [...(filters.ids ?? []), ...filteredItemsById.rows.map(({ id }) => id)]
}
}
const results = await client.query<CollectionsItemDBResult>(getCatalogQuery(reducedSchemas, filters))
const query = getCatalogQuery(reducedSchemas, filters)
const results = await client.query<CollectionsItemDBResult>(query)
catalogItems = results.rows.map(res => fromCollectionsItemDbResultToCatalogItem(res, network))
total = results.rows[0]?.total ?? results.rows[0]?.total_rows ?? 0

Expand Down
Loading

0 comments on commit a0b7a0d

Please sign in to comment.