Skip to content

Commit

Permalink
feat: Support Exotic rarity
Browse files Browse the repository at this point in the history
  • Loading branch information
LautaroPetaccio committed Apr 3, 2024
1 parent 030cb26 commit 60c4eac
Show file tree
Hide file tree
Showing 20 changed files with 85 additions and 131 deletions.
134 changes: 32 additions & 102 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 @@ -26,7 +26,7 @@
"printWidth": 80
},
"dependencies": {
"@dcl/schemas": "^9.6.0",
"@dcl/schemas": "^11.4.0",
"@well-known-components/env-config-provider": "^1.2.0",
"@well-known-components/http-requests-logger-component": "^2.1.0",
"@well-known-components/http-server": "^1.1.6",
Expand Down
5 changes: 4 additions & 1 deletion src/adapters/handlers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ export const getItemsParams = (params: Params) => {
),
contractAddresses: params.getList('contractAddress'),
itemId: params.getString('itemId'),
network: params.getValue<Network>('network', Network),
network: params.getValue<Network.MATIC | Network.ETHEREUM>('network', {
[Network.MATIC]: Network.MATIC,
[Network.ETHEREUM]: Network.ETHEREUM,
}),
maxPrice: maxPrice
? ethers.utils.parseEther(maxPrice).toString()
: undefined,
Expand Down
2 changes: 1 addition & 1 deletion src/logic/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const getCollectionsQuery = (page: number) => `

export async function getCollectionsContracts(
subgraph: ISubgraphComponent,
network: Network,
network: Network.MATIC | Network.ETHEREUM,
chainId: ChainId
): Promise<Contract[]> {
let page = 0
Expand Down
5 changes: 3 additions & 2 deletions src/ports/bids/component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { BidFilters, ChainId, Network } from '@dcl/schemas'
import { BidFilters, ChainId } from '@dcl/schemas'
import { ISubgraphComponent } from '@well-known-components/thegraph-component'
import { AssetsNetworks } from '../../types'
import { BidFragment, IBidsComponent } from './types'
import { fromBidFragment, getBidsQuery } from './utils'

export function createBidsComponent(options: {
subgraph: ISubgraphComponent
network: Network
network: AssetsNetworks
chainId: ChainId
}): IBidsComponent {
const { subgraph, network, chainId } = options
Expand Down
3 changes: 2 additions & 1 deletion src/ports/bids/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import {
ListingStatus,
Network,
} from '@dcl/schemas'
import { AssetsNetworks } from '../../types'
import { BidFragment } from './types'

export const BID_DEFAULT_SORT_BY = BidSortBy.RECENTLY_OFFERED

export function fromBidFragment(
fragment: BidFragment,
network: Network,
network: AssetsNetworks,
chainId: ChainId
): Bid {
const bid: Bid = {
Expand Down
7 changes: 5 additions & 2 deletions src/ports/catalog/component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IPgComponent } from '@well-known-components/pg-component'
import { Item } from '@dcl/schemas'
import { Item, Network } from '@dcl/schemas'
import { HttpError } from '../../logic/http/response'
import { getLatestSubgraphSchema } from '../../subgraphUtils'
import { enhanceItemsWithPicksStats } from '../../logic/favorites/utils'
Expand Down Expand Up @@ -68,7 +68,10 @@ export function createCatalogComponent(options: {
const query = getCatalogQuery(reducedSchemas, filters)
const results = await client.query<CollectionsItemDBResult>(query)
catalogItems = results.rows.map((res) =>
fromCollectionsItemDbResultToCatalogItem(res, network)
fromCollectionsItemDbResultToCatalogItem(
res,
network as Network.ETHEREUM | Network.MATIC
)
)
total = results.rows[0]?.total ?? results.rows[0]?.total_rows ?? 0

Expand Down
6 changes: 3 additions & 3 deletions src/ports/catalog/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {
CatalogSortBy,
CatalogSortDirection,
Item,
Network,
} from '@dcl/schemas'
import { AssetsNetworks } from '../../types'

export type CollectionsItemDBResult = {
total?: number // for UNION queries, this field will be defined
Expand All @@ -31,7 +31,7 @@ export type CollectionsItemDBResult = {
owners_count: number | null
min_price: string
max_price: string
network?: Network
network?: AssetsNetworks
metadata: {
id: string
description: string
Expand All @@ -40,7 +40,7 @@ export type CollectionsItemDBResult = {
rarity: string
name: string
loop?: boolean
has_sound: boolean,
has_sound: boolean
has_geometry: boolean
}
urn: string
Expand Down
Loading

0 comments on commit 60c4eac

Please sign in to comment.