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

Commit

Permalink
feat: add third party ID to WearablesRequest (#258)
Browse files Browse the repository at this point in the history
* feat: add third party ID to WearablesRequest

* fix: add thirdPartyId to filters deserialization
  • Loading branch information
guidota authored Apr 26, 2022
1 parent 1ab8e83 commit c4944ec
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 31 deletions.
154 changes: 129 additions & 25 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 @@ -85,7 +85,7 @@
"@types/redux-logger": "^3.0.9",
"bignumber.js": "^9.0.1",
"blob-to-buffer": "^1.2.8",
"dcl-catalyst-client": "^11.1.0",
"dcl-catalyst-client": "^11.2.0",
"dcl-crypto": "^2.3.0",
"dcl-quests-client": "^2.10.0",
"dcl-scene-writer": "^1.1.2",
Expand Down
20 changes: 15 additions & 5 deletions packages/shared/catalogs/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,13 @@ function* fetchWearablesFromCatalyst(filters: WearablesRequestFilters) {
result.push(...v2Wearables)
}
} else {
const ownedWearables: OwnedWearablesWithDefinition[] = yield call(
fetchOwnedWearables,
filters.ownedByUser,
client
)
let ownedWearables: OwnedWearablesWithDefinition[]
if (filters.thirdPartyId) {
ownedWearables = yield call(fetchOwnedThirdPartyWearables, filters.ownedByUser, filters.thirdPartyId, client)
} else {
ownedWearables = yield call(fetchOwnedWearables, filters.ownedByUser, client)
}

for (const { amount, definition } of ownedWearables) {
if (definition) {
for (let i = 0; i < amount; i++) {
Expand Down Expand Up @@ -170,6 +172,10 @@ function* fetchWearablesFromCatalyst(filters: WearablesRequestFilters) {
.filter((wearable) => !!wearable)
}

function fetchOwnedThirdPartyWearables(ethAddress: string, thirdPartyId: string, client: CatalystClient) {
return client.fetchOwnedThirdPartyWearables(ethAddress, thirdPartyId, true)
}

function fetchOwnedWearables(ethAddress: string, client: CatalystClient) {
return client.fetchOwnedWearables(ethAddress, true)
}
Expand Down Expand Up @@ -315,6 +321,10 @@ function areFiltersValid(filters: WearablesRequestFilters) {
filtersSet += 1
}

if (filters.thirdPartyId && !filters.ownedByUser) {
ok = false
}

return filtersSet === 1 && ok
}

Expand Down
1 change: 1 addition & 0 deletions packages/shared/catalogs/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,5 @@ export type WearablesRequestFilters = {
ownedByUser?: string
wearableIds?: WearableId[]
collectionIds?: string[]
thirdPartyId?: string
}
2 changes: 2 additions & 0 deletions packages/unity-interface/BrowserInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -708,12 +708,14 @@ export class BrowserInterface {
ownedByUser: string | null
wearableIds?: string[] | null
collectionIds?: string[] | null
thirdPartyId?: string | null
}
context?: string
}) {
const { filters, context } = data
const newFilters: WearablesRequestFilters = {
ownedByUser: filters.ownedByUser ?? undefined,
thirdPartyId: filters.thirdPartyId ?? undefined,
wearableIds: arrayCleanup(filters.wearableIds),
collectionIds: arrayCleanup(filters.collectionIds)
}
Expand Down

0 comments on commit c4944ec

Please sign in to comment.