Skip to content

Commit

Permalink
Merge 56f4423 into 097b539
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmahidalgo committed Sep 22, 2023
2 parents 097b539 + 56f4423 commit 1a04ca8
Show file tree
Hide file tree
Showing 12 changed files with 232 additions and 67 deletions.
1 change: 1 addition & 0 deletions webapp/src/components/AssetCard/AssetCard.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
}

.ui.card.AssetCard.catalog {
overflow: hidden;
height: 360px;
}

Expand Down
38 changes: 20 additions & 18 deletions webapp/src/config/env/dev.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
{
"NETWORK": "sepolia",
"CHAIN_ID": "11155111",
"NFT_SERVER_URL": "https://nft-api.decentraland.zone/v1",
"BUILDER_SERVER_URL": "https://builder-api.decentraland.zone/v1",
"ATLAS_SERVER_URL": "https://api.decentraland.zone",
"PEER_URL": "https://peer-ue-2.decentraland.zone",
"SIGNATURES_SERVER_URL": "https://signatures-api.decentraland.zone/v1",
"MARKETPLACE_FAVORITES_SERVER_URL": "https://marketplace-favorites-api.decentraland.zone/v1",
"NETWORK": "mainnet",
"CHAIN_ID": "1",
"NFT_SERVER_URL": "https://nft-api.decentraland.org/v1",
"MARKETPLACE_SERVER_URL": "https://marketplace-api.decentraland.org/v1",
"BUILDER_SERVER_URL": "https://builder-api.decentraland.org/v1",
"ATLAS_SERVER_URL": "https://api.decentraland.org",
"PEER_URL": "https://peer.decentraland.org",
"SIGNATURES_SERVER_URL": "https://signatures-api.decentraland.org/v1",
"MARKETPLACE_FAVORITES_SERVER_URL": "https://marketplace-favorites-api.decentraland.org/v1",
"DEFAULT_FAVORITES_LIST_ID": "70ab6873-4a03-4eb2-b331-4b8be0e0b8af",
"DECENTRALAND_BLOG": "https://decentraland.org/blog",
"REFRESH_SIGNATURES_DELAY": "10000",
"TRANSACTIONS_API_URL": "https://transactions-api.decentraland.zone/v1",
"TRANSAK_API_URL": "https://api-stg.transak.com/partners/api",
"TRANSAK_KEY": "273ac855-3472-40eb-8ee8-840e317f98e6",
"TRANSAK_ENV": "STAGING",
"TRANSACTIONS_API_URL": "https://transactions-api.decentraland.org/v1",
"TRANSAK_API_URL": "https://api.transak.com/partners/api",
"TRANSAK_KEY": "cb87de5f-add2-48a1-bab4-6a9409b811b1",
"TRANSAK_ENV": "PRODUCTION",
"TRANSAK_POLLING_DELAY": "6000",
"TRANSAK_PUSHER_APP_KEY": "1d9ffac87de599c61283",
"TRANSAK_PUSHER_APP_CLUSTER": "ap2",
"MOON_PAY_API_URL": "https://api.moonpay.com",
"MOON_PAY_API_KEY": "pk_test_WVS2xVSCnSnR7A7qIueWwCtcKnrGb55p",
"MOON_PAY_API_KEY": "pk_live_3PEJQj5NyvQBdit7phd48cCyzDSZFGsg",
"MOON_PAY_POLLING_DELAY": "6000",
"MOON_PAY_WIDGET_URL": "https://buy-staging.moonpay.io",
"BUILDER_URL": "https://builder.decentraland.zone",
"MOON_PAY_WIDGET_URL": "https://buy.moonpay.io",
"BUILDER_URL": "https://builder.decentraland.org",
"COINGECKO_API_URL": "https://api.coingecko.com/api/v3",
"DOCS_URL": "https://docs.decentraland.org",
"MARKETPLACE_ADAPTER_FEE_PER_MILLION": "25000",
"MAX_PRICE_INCREASE_PERCENTAGE": "15",
"MANA_ADDRESS": "0x2a8fd99c19271f4f04b1b7b9c4f7cf264b626edb",
"CONVERTER_ADDRESS": "0x2782eb28Dcb1eF4E7632273cd4e347e130Ce4646",
"MANA_ADDRESS": "0x0f5d2fb29fb7d3cfee444a200298f468908cc942",
"CONVERTER_ADDRESS": "0x2859581da59bd4e16a866dd06b461b76d8e489a4",
"CONVERTER_EXCHANGE": "uniswap_v2",
"INTERCOM_APP_ID": "z0h94kay",
"SEGMENT_API_KEY": "gMnkewUBzA6J879kAtMvp2WhohEk36uy",
"SEGMENT_API_KEY": "WijgHCmOGJjV04XBGghZGEadMD4454R3",
"DISCORD_URL": "https://dcl.gg/discord",
"ROLLBAR_ACCESS_TOKEN": "ad890a7699424114a7713o73ee60720ac",
"ENVIRONMENT": "development",
"MIN_SALE_VALUE_IN_WEI": "1000000000000000000",
"EXPLORER_URL": "https://play.decentraland.zone",
Expand Down
123 changes: 92 additions & 31 deletions webapp/src/modules/favorites/sagas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
import { locations } from '../routing/locations'
import { SortDirection } from '../routing/types'
import { CatalogAPI } from '../vendor/decentraland/catalog/api'
import { getIsMarketplaceServerEnabled } from '../features/selectors'
import { getData as getItemsData } from '../item/selectors'
import {
BULK_PICK_SUCCESS,
Expand Down Expand Up @@ -100,7 +101,8 @@ describe('when handling the request for fetching favorited items', () => {
return expectSaga(favoritesSaga, getIdentity)
.provide([
[select(getListId), listId],
[select(getAddress), Promise.reject(error)]
[select(getAddress), Promise.reject(error)],
[select(getIsMarketplaceServerEnabled), true]
])
.put(fetchFavoritedItemsFailure(error.message))
.dispatch(fetchFavoritedItemsRequest(options))
Expand All @@ -114,6 +116,7 @@ describe('when handling the request for fetching favorited items', () => {
.provide([
[select(getListId), listId],
[select(getAddress), address],
[select(getIsMarketplaceServerEnabled), true],
[call(getAccountIdentity), Promise.reject(error)]
])
.put(fetchFavoritedItemsFailure(error.message))
Expand All @@ -129,6 +132,7 @@ describe('when handling the request for fetching favorited items', () => {
.provide([
[select(getListId), listId],
[select(getAddress), address],
[select(getIsMarketplaceServerEnabled), true],
[call(getAccountIdentity), Promise.resolve()],
[
matchers.call.fn(FavoritesAPI.prototype.getPicksByList),
Expand All @@ -149,6 +153,7 @@ describe('when handling the request for fetching favorited items', () => {
let favoritedItemIds: FavoritedItems
let createdAt: Record<string, number>
let total: number
let isMarketplaceFFOn: boolean

describe("and there's more than one favorited item", () => {
beforeEach(() => {
Expand All @@ -157,35 +162,79 @@ describe('when handling the request for fetching favorited items', () => {
total = 1
})

describe('and the call to the items api fails', () => {
it('should dispatch an action signaling the failure of the handled action', () => {
return expectSaga(favoritesSaga, getIdentity)
.provide([
[select(getListId), listId],
[select(getAddress), address],
[call(getAccountIdentity), Promise.resolve()],
[
matchers.call.fn(FavoritesAPI.prototype.getPicksByList),
Promise.resolve({ results: favoritedItemIds, total })
],
[
matchers.call.fn(CatalogAPI.prototype.get),
Promise.reject(error)
]
])
.call.like({
fn: CatalogAPI.prototype.get,
args: [
{
...options.filters,
first: 1,
ids: [favoritedItemIds[0].itemId]
}
]
})
.put(fetchFavoritedItemsFailure(error.message))
.dispatch(fetchFavoritedItemsRequest(options))
.run({ silenceTimeout: true })
describe('and the marketplace-server flag is off', () => {
beforeEach(() => {
isMarketplaceFFOn = false
})
describe('and the call to the items api fails', () => {
it('should dispatch an action signaling the failure of the handled action', () => {
return expectSaga(favoritesSaga, getIdentity)
.provide([
[select(getListId), listId],
[select(getIsMarketplaceServerEnabled), isMarketplaceFFOn],
[select(getAddress), address],
[call(getAccountIdentity), Promise.resolve()],
[
matchers.call.fn(FavoritesAPI.prototype.getPicksByList),
Promise.resolve({ results: favoritedItemIds, total })
],
[
matchers.call.fn(CatalogAPI.prototype.get),
Promise.reject(error)
]
])
.call.like({
fn: CatalogAPI.prototype.get,
args: [
{
...options.filters,
first: 1,
ids: [favoritedItemIds[0].itemId]
}
]
})
.put(fetchFavoritedItemsFailure(error.message))
.dispatch(fetchFavoritedItemsRequest(options))
.run({ silenceTimeout: true })
})
})
})

describe('and the marketplace-server flag is on', () => {
beforeEach(() => {
isMarketplaceFFOn = true
})
describe('and the call to the items api fails', () => {
it('should dispatch an action signaling the failure of the handled action', () => {
return expectSaga(favoritesSaga, getIdentity)
.provide([
[select(getListId), listId],
[select(getIsMarketplaceServerEnabled), isMarketplaceFFOn],
[select(getAddress), address],
[call(getAccountIdentity), Promise.resolve()],
[
matchers.call.fn(FavoritesAPI.prototype.getPicksByList),
Promise.resolve({ results: favoritedItemIds, total })
],
[
matchers.call.fn(CatalogAPI.prototype.get),
Promise.reject(error)
]
])
.call.like({
fn: CatalogAPI.prototype.get,
args: [
{
...options.filters,
first: 1,
ids: [favoritedItemIds[0].itemId]
}
]
})
.put(fetchFavoritedItemsFailure(error.message))
.dispatch(fetchFavoritedItemsRequest(options))
.run({ silenceTimeout: true })
})
})
})

Expand All @@ -202,6 +251,7 @@ describe('when handling the request for fetching favorited items', () => {
.provide([
[select(getListId), listId],
[select(getAddress), address],
[select(getIsMarketplaceServerEnabled), true],
[call(getAccountIdentity), Promise.resolve()],
[
matchers.call.fn(FavoritesAPI.prototype.getPicksByList),
Expand Down Expand Up @@ -256,6 +306,7 @@ describe('when handling the request for fetching favorited items', () => {
.provide([
[select(getListId), listId],
[select(getAddress), address],
[select(getIsMarketplaceServerEnabled), true],
[call(getAccountIdentity), Promise.resolve()],
[
matchers.call.fn(FavoritesAPI.prototype.getPicksByList),
Expand Down Expand Up @@ -296,6 +347,7 @@ describe('when handling the request for fetching favorited items', () => {
.provide([
[select(getListId), listId],
[select(getAddress), null],
[select(getIsMarketplaceServerEnabled), true],
[
matchers.call.fn(FavoritesAPI.prototype.getPicksByList),
Promise.reject(error)
Expand Down Expand Up @@ -329,6 +381,7 @@ describe('when handling the request for fetching favorited items', () => {
.provide([
[select(getListId), listId],
[select(getAddress), null],
[select(getIsMarketplaceServerEnabled), true],
[
matchers.call.fn(FavoritesAPI.prototype.getPicksByList),
Promise.resolve({ results: favoritedItemIds, total })
Expand Down Expand Up @@ -367,6 +420,7 @@ describe('when handling the request for fetching favorited items', () => {
.provide([
[select(getListId), listId],
[select(getAddress), null],
[select(getIsMarketplaceServerEnabled), true],
[
matchers.call.fn(FavoritesAPI.prototype.getPicksByList),
Promise.resolve({ results: favoritedItemIds, total })
Expand Down Expand Up @@ -420,6 +474,7 @@ describe('when handling the request for fetching favorited items', () => {
.provide([
[select(getListId), listId],
[select(getAddress), null],
[select(getIsMarketplaceServerEnabled), true],
[
matchers.call.fn(FavoritesAPI.prototype.getPicksByList),
{ results: favoritedItemIds, total }
Expand Down Expand Up @@ -611,11 +666,12 @@ describe('when handling the request for fetching lists', () => {
]
})

describe('and there are not items in the state', () => {
describe('and there are no items in the state', () => {
it('should dispatch an action signaling the success of the handled action', () => {
return expectSaga(favoritesSaga, getIdentity)
.provide([
[call(getAccountIdentity), Promise.resolve()],
[select(getIsMarketplaceServerEnabled), true],
[
matchers.call.fn(FavoritesAPI.prototype.getLists),
Promise.resolve({ results: lists, total })
Expand Down Expand Up @@ -660,6 +716,7 @@ describe('when handling the request for fetching lists', () => {
return expectSaga(favoritesSaga, getIdentity)
.provide([
[call(getAccountIdentity), Promise.resolve()],
[select(getIsMarketplaceServerEnabled), true],
[
matchers.call.fn(FavoritesAPI.prototype.getLists),
Promise.resolve({ results: lists, total })
Expand Down Expand Up @@ -757,6 +814,7 @@ describe('when handling the request for fetching lists', () => {
return expectSaga(favoritesSaga, getIdentity)
.provide([
[call(getAccountIdentity), Promise.resolve()],
[select(getIsMarketplaceServerEnabled), true],
[
matchers.call.fn(FavoritesAPI.prototype.getLists),
Promise.resolve({ results: lists, total })
Expand Down Expand Up @@ -804,6 +862,7 @@ describe('when handling the request for fetching lists', () => {
return expectSaga(favoritesSaga, getIdentity)
.provide([
[call(getAccountIdentity), Promise.resolve()],
[select(getIsMarketplaceServerEnabled), true],
[
matchers.call.fn(FavoritesAPI.prototype.getLists),
Promise.resolve({ results: lists, total })
Expand Down Expand Up @@ -1034,6 +1093,7 @@ describe('when handling the request for getting a list', () => {
matchers.call.fn(FavoritesAPI.prototype.getList),
Promise.resolve(list)
],
[select(getIsMarketplaceServerEnabled), true],
[select(getItemsData), {}],
[
matchers.call.fn(CatalogAPI.prototype.get),
Expand Down Expand Up @@ -1078,6 +1138,7 @@ describe('when handling the request for getting a list', () => {
matchers.call.fn(FavoritesAPI.prototype.getList),
Promise.resolve(list)
],
[select(getIsMarketplaceServerEnabled), true],
[select(getItemsData), { anotherItemId: {} }],
[
matchers.call.fn(CatalogAPI.prototype.get),
Expand Down
24 changes: 18 additions & 6 deletions webapp/src/modules/favorites/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { getIdentity as getAccountIdentity } from '../identity/utils'
import { CatalogAPI } from '../vendor/decentraland/catalog/api'
import { retryParams } from '../vendor/decentraland/utils'
import { getAddress } from '../wallet/selectors'
import { NFT_SERVER_URL } from '../vendor/decentraland'
import { MARKETPLACE_SERVER_URL, NFT_SERVER_URL } from '../vendor/decentraland'
import { locations } from '../routing/locations'
import { SortDirection } from '../routing/types'
import { ListsSortBy } from '../vendor/decentraland/favorites/types'
Expand Down Expand Up @@ -83,6 +83,7 @@ import {
import { convertListsBrowseSortByIntoApiSortBy } from './utils'
import { List } from './types'
import { getData as getItemsData } from '../item/selectors'
import { getIsMarketplaceServerEnabled } from '../features/selectors'

export function* favoritesSaga(getIdentity: () => AuthIdentity | undefined) {
const API_OPTS = {
Expand All @@ -95,6 +96,10 @@ export function* favoritesSaga(getIdentity: () => AuthIdentity | undefined) {
API_OPTS
)
const catalogAPI = new CatalogAPI(NFT_SERVER_URL, API_OPTS)
const marketplaceServerCatalogAPI = new CatalogAPI(
MARKETPLACE_SERVER_URL,
API_OPTS
)

yield takeEvery(
FETCH_FAVORITED_ITEMS_REQUEST,
Expand All @@ -114,6 +119,13 @@ export function* favoritesSaga(getIdentity: () => AuthIdentity | undefined) {
handleBulkPickSuccessOrFailure
)

function* getCatalogAPI() {
const isMarketplaceServerEnabled: boolean = yield select(
getIsMarketplaceServerEnabled
)
return isMarketplaceServerEnabled ? marketplaceServerCatalogAPI : catalogAPI
}

function* fetchPreviewItems(previewListsItemIds: string[]) {
let previewItems: Item[] = []

Expand All @@ -127,10 +139,8 @@ export function* favoritesSaga(getIdentity: () => AuthIdentity | undefined) {
ids: previewListsItemIds
}

const result: { data: Item[] } = yield call(
[catalogAPI, 'get'],
itemFilters
)
const api: CatalogAPI = yield call(getCatalogAPI)
const result: { data: Item[] } = yield call([api, 'get'], itemFilters)
previewItems = result.data
}
}
Expand Down Expand Up @@ -173,9 +183,11 @@ export function* favoritesSaga(getIdentity: () => AuthIdentity | undefined) {
filters: optionsFilters
}

const api: CatalogAPI = yield call(getCatalogAPI)

if (results.length > 0) {
const result: { data: Item[] } = yield call(
[catalogAPI, 'get'],
[api, 'get'],
optionsFilters
)
items = result.data
Expand Down
Loading

0 comments on commit 1a04ca8

Please sign in to comment.