Skip to content
This repository was archived by the owner on Feb 27, 2023. It is now read-only.

Commit c4944ec

Browse files
author
guidota
authored
feat: add third party ID to WearablesRequest (#258)
* feat: add third party ID to WearablesRequest * fix: add thirdPartyId to filters deserialization
1 parent 1ab8e83 commit c4944ec

5 files changed

Lines changed: 148 additions & 31 deletions

File tree

package-lock.json

Lines changed: 129 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"@types/redux-logger": "^3.0.9",
8686
"bignumber.js": "^9.0.1",
8787
"blob-to-buffer": "^1.2.8",
88-
"dcl-catalyst-client": "^11.1.0",
88+
"dcl-catalyst-client": "^11.2.0",
8989
"dcl-crypto": "^2.3.0",
9090
"dcl-quests-client": "^2.10.0",
9191
"dcl-scene-writer": "^1.1.2",

packages/shared/catalogs/sagas.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,13 @@ function* fetchWearablesFromCatalyst(filters: WearablesRequestFilters) {
118118
result.push(...v2Wearables)
119119
}
120120
} else {
121-
const ownedWearables: OwnedWearablesWithDefinition[] = yield call(
122-
fetchOwnedWearables,
123-
filters.ownedByUser,
124-
client
125-
)
121+
let ownedWearables: OwnedWearablesWithDefinition[]
122+
if (filters.thirdPartyId) {
123+
ownedWearables = yield call(fetchOwnedThirdPartyWearables, filters.ownedByUser, filters.thirdPartyId, client)
124+
} else {
125+
ownedWearables = yield call(fetchOwnedWearables, filters.ownedByUser, client)
126+
}
127+
126128
for (const { amount, definition } of ownedWearables) {
127129
if (definition) {
128130
for (let i = 0; i < amount; i++) {
@@ -170,6 +172,10 @@ function* fetchWearablesFromCatalyst(filters: WearablesRequestFilters) {
170172
.filter((wearable) => !!wearable)
171173
}
172174

175+
function fetchOwnedThirdPartyWearables(ethAddress: string, thirdPartyId: string, client: CatalystClient) {
176+
return client.fetchOwnedThirdPartyWearables(ethAddress, thirdPartyId, true)
177+
}
178+
173179
function fetchOwnedWearables(ethAddress: string, client: CatalystClient) {
174180
return client.fetchOwnedWearables(ethAddress, true)
175181
}
@@ -315,6 +321,10 @@ function areFiltersValid(filters: WearablesRequestFilters) {
315321
filtersSet += 1
316322
}
317323

324+
if (filters.thirdPartyId && !filters.ownedByUser) {
325+
ok = false
326+
}
327+
318328
return filtersSet === 1 && ok
319329
}
320330

packages/shared/catalogs/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,5 @@ export type WearablesRequestFilters = {
114114
ownedByUser?: string
115115
wearableIds?: WearableId[]
116116
collectionIds?: string[]
117+
thirdPartyId?: string
117118
}

packages/unity-interface/BrowserInterface.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,12 +708,14 @@ export class BrowserInterface {
708708
ownedByUser: string | null
709709
wearableIds?: string[] | null
710710
collectionIds?: string[] | null
711+
thirdPartyId?: string | null
711712
}
712713
context?: string
713714
}) {
714715
const { filters, context } = data
715716
const newFilters: WearablesRequestFilters = {
716717
ownedByUser: filters.ownedByUser ?? undefined,
718+
thirdPartyId: filters.thirdPartyId ?? undefined,
717719
wearableIds: arrayCleanup(filters.wearableIds),
718720
collectionIds: arrayCleanup(filters.collectionIds)
719721
}

0 commit comments

Comments
 (0)