Skip to content

Commit

Permalink
feat: Use marketplace basename (#2057)
Browse files Browse the repository at this point in the history
* feat: Use marketplace basename

* fix: Tests
  • Loading branch information
LautaroPetaccio committed Nov 20, 2023
1 parent c72f7aa commit eab256f
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fireEvent, waitFor } from '@testing-library/react'
import { fireEvent } from '@testing-library/react'
import { t } from 'decentraland-dapps/dist/modules/translation/utils'
import { getAnalytics } from 'decentraland-dapps/dist/modules/analytics/utils'
import { renderWithProviders } from '../../../utils/test'
Expand Down Expand Up @@ -74,7 +74,7 @@ describe('when the share on twitter button is clicked', () => {

it('should open a new page with a twitter message', async () => {
jest.spyOn(window, 'open').mockImplementation(() => null)
const dclUrl = 'https://market.decentraland.zone'
const dclUrl = 'https://decentraland.zone/marketplace'
const locationsUrl =
'/lists/aListId?assetType=item&section=lists&vendor=decentraland&page=1&sortBy=newest'
const twitterURL = `https://twitter.com/intent/tweet?text=${encodeURIComponent(
Expand Down
9 changes: 5 additions & 4 deletions webapp/src/config/env/dev.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"NETWORK": "sepolia",
"CHAIN_ID": "11155111",
"BASE_NAME": "/marketplace",
"NFT_SERVER_URL": "https://nft-api.decentraland.zone/v1",
"MARKETPLACE_SERVER_URL": "https://marketplace-api.decentraland.zone/v1",
"BUILDER_SERVER_URL": "https://builder-api.decentraland.zone/v1",
Expand All @@ -22,7 +23,7 @@
"MOON_PAY_API_KEY": "pk_test_WVS2xVSCnSnR7A7qIueWwCtcKnrGb55p",
"MOON_PAY_POLLING_DELAY": "6000",
"MOON_PAY_WIDGET_URL": "https://buy-staging.moonpay.io",
"BUILDER_URL": "https://builder.decentraland.zone",
"BUILDER_URL": "https://decentraland.zone/builder",
"COINGECKO_API_URL": "https://api.coingecko.com/api/v3",
"DOCS_URL": "https://docs.decentraland.org",
"MARKETPLACE_ADAPTER_FEE_PER_MILLION": "25000",
Expand All @@ -36,9 +37,9 @@
"ENVIRONMENT": "development",
"MIN_SALE_VALUE_IN_WEI": "1000000000000000000",
"EXPLORER_URL": "https://play.decentraland.zone",
"MARKETPLACE_URL": "https://market.decentraland.zone",
"PROFILE_URL": "https://profile.decentraland.zone",
"MARKETPLACE_URL": "https://decentraland.zone/marketplace",
"PROFILE_URL": "https://decentraland.zone/profile",
"SSO_URL": "https://id.decentraland.zone",
"SUBGRAPH_WORKER": "https://subgraph.decentraland.zone",
"SENTRY_DSN": "https://1dc401149e1c819b8477565c9cdd9b70@o4504361728212992.ingest.sentry.io/4505743351676928"
}
}
6 changes: 3 additions & 3 deletions webapp/src/config/env/prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"MOON_PAY_API_KEY": "pk_live_3PEJQj5NyvQBdit7phd48cCyzDSZFGsg",
"MOON_PAY_POLLING_DELAY": "6000",
"MOON_PAY_WIDGET_URL": "https://buy.moonpay.io",
"BUILDER_URL": "https://builder.decentraland.org",
"BUILDER_URL": "https://decentraland.org/builder",
"COINGECKO_API_URL": "https://api.coingecko.com/api/v3",
"DOCS_URL": "https://docs.decentraland.org",
"MARKETPLACE_ADAPTER_FEE_PER_MILLION": "25000",
Expand All @@ -36,8 +36,8 @@
"ENVIRONMENT": "production",
"MIN_SALE_VALUE_IN_WEI": "1000000000000000000",
"EXPLORER_URL": "https://play.decentraland.org",
"MARKETPLACE_URL": "https://market.decentraland.org",
"PROFILE_URL": "https://profile.decentraland.org",
"MARKETPLACE_URL": "https://decentraland.org/marketplace",
"PROFILE_URL": "https://decentraland.org/profile",
"SSO_URL": "https://id.decentraland.org",
"SUBGRAPH_WORKER": "https://subgraph.decentraland.org",
"SENTRY_DSN": "https://1dc401149e1c819b8477565c9cdd9b70@o4504361728212992.ingest.sentry.io/4505743351676928"
Expand Down
7 changes: 4 additions & 3 deletions webapp/src/config/env/stg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"NETWORK": "mainnet",
"CHAIN_ID": "1",
"BASE_NAME": "/marketplace",
"NFT_SERVER_URL": "https://nft-api.decentraland.today/v1",
"MARKETPLACE_SERVER_URL": "https://marketplace-api.decentraland.today/v1",
"BUILDER_SERVER_URL": "https://builder-api.decentraland.today/v1",
Expand All @@ -22,7 +23,7 @@
"MOON_PAY_API_KEY": "pk_test_WVS2xVSCnSnR7A7qIueWwCtcKnrGb55p",
"MOON_PAY_POLLING_DELAY": "6000",
"MOON_PAY_WIDGET_URL": "https://buy-staging.moonpay.io",
"BUILDER_URL": "https://builder.decentraland.today",
"BUILDER_URL": "https://decentraland.today/builder",
"COINGECKO_API_URL": "https://api.coingecko.com/api/v3",
"DOCS_URL": "https://docs.decentraland.org",
"MARKETPLACE_ADAPTER_FEE_PER_MILLION": "25000",
Expand All @@ -36,8 +37,8 @@
"ENVIRONMENT": "staging",
"MIN_SALE_VALUE_IN_WEI": "1000000000000000000",
"EXPLORER_URL": "https://play.decentraland.org",
"MARKETPLACE_URL": "https://market.decentraland.today",
"PROFILE_URL": "https://profile.decentraland.today",
"MARKETPLACE_URL": "https://decentraland.today/marketplace",
"PROFILE_URL": "https://decentraland.today/profile",
"SSO_URL": "https://id.decentraland.today",
"SUBGRAPH_WORKER": "https://subgraph.decentraland.today",
"SENTRY_DSN": "https://1dc401149e1c819b8477565c9cdd9b70@o4504361728212992.ingest.sentry.io/4505743351676928"
Expand Down
7 changes: 5 additions & 2 deletions webapp/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import './modules/analytics/sentry'

import { ScrollToTop } from './components/ScrollToTop'
import * as locales from './modules/translation/locales'
import { initStore, history } from './modules/store'
import { initStore, createHistory } from './modules/store'
import { Routes } from './components/Routes'
import * as modals from './components/Modals'
import { config } from './config'
Expand All @@ -26,9 +26,12 @@ import './index.css'
// It is ideal to do this as soon as possible to avoid any availability issues.
SingleSignOn.init(config.get('SSO_URL'))

const history = createHistory()
const store = initStore(history)

async function main() {
const component = (
<Provider store={initStore()}>
<Provider store={store}>
<TranslationProvider locales={Object.keys(locales)}>
<WalletProvider>
<ConnectedRouter history={history}>
Expand Down
31 changes: 13 additions & 18 deletions webapp/src/modules/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ import { ARCHIVE_BID, UNARCHIVE_BID } from './bid/actions'
import { SET_IS_TRYING_ON } from './ui/preview/actions'
import { getCurrentIdentity } from './identity/selectors'
import { AuthIdentity } from 'decentraland-crypto-fetch'
import { createMemoryHistory, createBrowserHistory, History } from 'history'

export const history = require('history').createBrowserHistory()
export const createHistory = () =>
createBrowserHistory({
basename: config.get('BASE_NAME') ?? undefined
})

export function initStore() {
export function initStore(history: History) {
const anyWindow = window as any

const isDev = config.is(Env.DEVELOPMENT)
Expand All @@ -47,14 +51,9 @@ export function initStore() {
storageKey: 'marketplace-v2', // this is the key used to save the state in localStorage (required)
paths: [
['ui', 'archivedBidIds'],
['ui', 'preview', 'isTryingOn'],
['ui', 'preview', 'isTryingOn']
], // array of paths from state to be persisted (optional)
actions: [
CLEAR_TRANSACTIONS,
ARCHIVE_BID,
UNARCHIVE_BID,
SET_IS_TRYING_ON
], // array of actions types that will trigger a SAVE (optional)
actions: [CLEAR_TRANSACTIONS, ARCHIVE_BID, UNARCHIVE_BID, SET_IS_TRYING_ON], // array of actions types that will trigger a SAVE (optional)
migrations: {} // migration object that will migrate your localstorage (optional)
})
const analyticsMiddleware = createAnalyticsMiddleware(
Expand Down Expand Up @@ -94,27 +93,23 @@ export function initStore() {
}

export function initTestStore(preloadedState = {}) {
const rootReducer = storageReducerWrapper(createRootReducer(history))
const testHistory = createMemoryHistory({ initialEntries: ['/marketplace'] })
const rootReducer = storageReducerWrapper(createRootReducer(testHistory))
const sagasMiddleware = createSagasMiddleware()
const transactionMiddleware = createTransactionMiddleware()
const { storageMiddleware, loadStorageMiddleware } = createStorageMiddleware({
storageKey: 'marketplace-v2', // this is the key used to save the state in localStorage (required)
paths: [
['ui', 'archivedBidIds'],
['ui', 'preview', 'isTryingOn'],
['ui', 'preview', 'isTryingOn']
], // array of paths from state to be persisted (optional)
actions: [
CLEAR_TRANSACTIONS,
ARCHIVE_BID,
UNARCHIVE_BID,
SET_IS_TRYING_ON
], // array of actions types that will trigger a SAVE (optional)
actions: [CLEAR_TRANSACTIONS, ARCHIVE_BID, UNARCHIVE_BID, SET_IS_TRYING_ON], // array of actions types that will trigger a SAVE (optional)
migrations: {} // migration object that will migrate your localstorage (optional)
})

const middleware = applyMiddleware(
sagasMiddleware,
routerMiddleware(history),
routerMiddleware(testHistory),
transactionMiddleware,
storageMiddleware
)
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/utils/tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function renderWithProviders(
translation: { data: locales, locale: 'en' }
})

const history = createMemoryHistory()
const history = createMemoryHistory({ initialEntries: ['/marketplace'] })

function AppProviders({ children }: { children: JSX.Element }) {
return (
Expand Down

0 comments on commit eab256f

Please sign in to comment.