Skip to content

Commit

Permalink
Merge branch 'master' of github.com:decentraland/marketplace into cho…
Browse files Browse the repository at this point in the history
…re/update-eslint
  • Loading branch information
LautaroPetaccio committed Mar 11, 2024
2 parents 75117e6 + a2ca82b commit d7347bc
Show file tree
Hide file tree
Showing 21 changed files with 107 additions and 182 deletions.
10 changes: 5 additions & 5 deletions webapp/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 webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"dcl-catalyst-commons": "^9.0.1",
"decentraland-connect": "^6.2.0",
"decentraland-crypto-fetch": "^1.0.3",
"decentraland-dapps": "^18.5.0",
"decentraland-dapps": "^19.0.0",
"decentraland-transactions": "^2.3.1",
"decentraland-ui": "^5.8.0",
"ethers": "^5.6.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ const Transaction = (props: Props) => {
/>
}
tx={tx}
isCrossChain={tx.actionType === BUY_ITEM_CROSS_CHAIN_SUCCESS}
/>
)}
</AssetProvider>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { useEffect, useState } from 'react'
import React from 'react'
import { Link } from 'react-router-dom'
import { Loader, Icon } from 'decentraland-ui'
import { Network } from '@dcl/schemas'
import { getChainConfiguration } from 'decentraland-dapps/dist/lib/chainConfiguration'
import { t } from 'decentraland-dapps/dist/modules/translation/utils'
import { isPending, getTransactionHref } from 'decentraland-dapps/dist/modules/transaction/utils'
import { TransactionStatus, Transaction } from 'decentraland-dapps/dist/modules/transaction/types'
import { isPending } from 'decentraland-dapps/dist/modules/transaction/utils'
import { TransactionStatus } from 'decentraland-dapps/dist/modules/transaction/types'
import { formatDistanceToNow } from '../../../../lib/date'
import { getAssetUrl } from '../../../../modules/asset/utils'
import { AssetImage } from '../../../AssetImage'
Expand All @@ -15,24 +15,9 @@ import { Mana } from '../../../Mana'
import { Props } from './TransactionDetail.types'
import './TransactionDetail.css'

const getHref = (tx: Transaction) => {
if (tx.status === null) {
return
}
return getTransactionHref({ txHash: tx.replacedBy || tx.hash }, tx.chainId)
}

const TransactionDetail = (props: Props) => {
const { asset, text, tx, isCrossChain = false } = props
const [txLink, setTxLink] = useState(getHref(tx))
useEffect(() => {
;(async () => {
if (isCrossChain) {
const { AxelarProvider } = await import('decentraland-transactions/crossChain')
setTxLink(await AxelarProvider.getTxLink(tx.hash))
}
})()
})
const { asset, text, tx } = props

return (
<Row className="TransactionDetail">
<Column align="left" grow={true}>
Expand All @@ -53,7 +38,7 @@ const TransactionDetail = (props: Props) => {
</div>
</Column>
<Column align="right">
<a href={txLink} className={tx.status ? 'status ' + tx.status : 'status'} target="_blank" rel="noopener noreferrer">
<a href={tx.url} className={tx.status ? 'status ' + tx.status : 'status'} target="_blank" rel="noopener noreferrer">
<div className="description">{tx.status || t('global.loading')}</div>
{isPending(tx.status) ? (
<div className="spinner">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export type Props = {
asset?: Asset | null
text: React.ReactNode
tx: Transaction
isCrossChain?: boolean
}

export type MapStateProps = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export const BuyWithCryptoModal = (props: Props) => {
)
)
setProviderTokens(supportedTokens.filter(t => crossChainSupportedChains.current.includes(+t.chainId)))
setProviderTokens(supportedTokens.filter(t => crossChainSupportedChains.current.includes(+t.chainId)))
}
} catch (error) {
console.log('error: ', error)
Expand Down
5 changes: 1 addition & 4 deletions webapp/src/components/SuccessPage/SuccessPage.container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@ import { SuccessPage } from './SuccessPage'

const mapState = (state: RootState): MapStateProps => {
const search = new URLSearchParams(getSearch(state))
const isCrossChain = search.get('isCrossChain') === 'true'
const transaction = getTransaction(state, search.get('txHash') || '')
const destinationTx = isCrossChain ? getTransaction(state, search.get('destinationTxHash') || '') : null
const address = getAddress(state)
const isLoadingTx = Boolean(transaction && transaction.status !== TransactionStatus.CONFIRMED)
const isDestinationTxLoading = Boolean(destinationTx && destinationTx.status !== TransactionStatus.CONFIRMED)
return {
isLoading: isCrossChain ? isLoadingTx || isDestinationTxLoading : isLoadingTx,
isLoading: isLoadingTx,
mintedTokenId: getTokenIdFromLogs(ChainId.MATIC_MUMBAI, transaction?.receipt?.logs),
profile: address ? getProfileOfAddress(state, address) : undefined
}
Expand Down
1 change: 1 addition & 0 deletions webapp/src/config/env/dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"SUBGRAPH_WORKER": "https://subgraph.decentraland.zone",
"SENTRY_DSN": "https://1dc401149e1c819b8477565c9cdd9b70@o4504361728212992.ingest.sentry.io/4505743351676928",
"SQUID_API_URL": "https://testnet.v2.api.squidrouter.com/",
"SQUID_RETRY_DELAY": "2000",
"DCL_LISTS_SERVER": "https://dcl-lists.decentraland.zone",
"AUTH_URL": "/auth",
"WERT_URL": "https://sandbox.wert.io",
Expand Down
1 change: 1 addition & 0 deletions webapp/src/config/env/prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"SUBGRAPH_WORKER": "https://subgraph.decentraland.org",
"SENTRY_DSN": "https://1dc401149e1c819b8477565c9cdd9b70@o4504361728212992.ingest.sentry.io/4505743351676928",
"SQUID_API_URL": "https://apiplus.squidrouter.com/api",
"SQUID_RETRY_DELAY": "2000",
"DCL_LISTS_SERVER": "https://dcl-lists.decentraland.org",
"AUTH_URL": "/auth",
"WERT_URL": "https://widget.wert.io",
Expand Down
1 change: 1 addition & 0 deletions webapp/src/config/env/stg.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"SUBGRAPH_WORKER": "https://subgraph.decentraland.today",
"SENTRY_DSN": "https://1dc401149e1c819b8477565c9cdd9b70@o4504361728212992.ingest.sentry.io/4505743351676928",
"SQUID_API_URL": "https://apiplus.squidrouter.com/api",
"SQUID_RETRY_DELAY": "2000",
"DCL_LISTS_SERVER": "https://dcl-lists.decentraland.org",
"AUTH_URL": "/auth",
"WERT_URL": "https://widget.wert.io",
Expand Down
17 changes: 2 additions & 15 deletions webapp/src/modules/ens/sagas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { call, select } from 'redux-saga/effects'
import { ethers, BigNumber } from 'ethers'
import { Route, AxelarProvider } from 'decentraland-transactions/crossChain'
import { getSigner, getConnectedProvider } from 'decentraland-dapps/dist/lib/eth'
import { TRANSACTION_ACTION_FLAG, waitForTx } from 'decentraland-dapps/dist/modules/transaction/utils'
import { waitForTx } from 'decentraland-dapps/dist/modules/transaction/utils'
import { Wallet } from 'decentraland-dapps/dist/modules/wallet/types'
import { closeModal } from 'decentraland-dapps/dist/modules/modal/actions'
import { ensSaga } from './sagas'
Expand All @@ -16,7 +16,6 @@ import {
claimNameFailure,
claimNameTransactionSubmitted,
claimNameRequest,
CLAIM_NAME_TRANSACTION_SUBMITTED,
claimNameCrossChainRequest,
claimNameCrossChainFailure,
claimNameCrossChainSuccess
Expand Down Expand Up @@ -219,19 +218,7 @@ describe('ENS Saga', () => {
mockTransaction = {
hash: '0xTransactionHash'
} as ethers.ContractTransaction
mockAction = {
type: CLAIM_NAME_TRANSACTION_SUBMITTED,
payload: {
[TRANSACTION_ACTION_FLAG]: {
chainId: mockWallet.chainId,
hash: mockTransaction.hash,
payload: {
address: mockWallet.address,
subdomain: mockName
}
}
}
}
mockAction = claimNameTransactionSubmitted(mockName, mockWallet.address, ChainId.ARBITRUM_MAINNET, mockTransaction.hash)
mockTokenId = BigNumber.from(1)
dclRegistrarContract = { address: '0xAnAddress' }
mockENS = {
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/modules/ens/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { BigNumber, ethers } from 'ethers'
import { call, put, select, takeEvery } from 'redux-saga/effects'
import { getConnectedProvider, getSigner } from 'decentraland-dapps/dist/lib/eth'
import { Provider, Wallet } from 'decentraland-dapps/dist/modules/wallet/types'
import { TRANSACTION_ACTION_FLAG, waitForTx } from 'decentraland-dapps/dist/modules/transaction/utils'
import { waitForTx } from 'decentraland-dapps/dist/modules/transaction/utils'
import { TRANSACTION_ACTION_FLAG } from 'decentraland-dapps/dist/modules/transaction/types'
import { t } from 'decentraland-dapps/dist/modules/translation'
import { closeModal } from 'decentraland-dapps/dist/modules/modal/actions'
import { DCLController } from '../../contracts'
Expand Down
14 changes: 6 additions & 8 deletions webapp/src/modules/item/actions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { ChainId, Item, ItemFilters, Order } from '@dcl/schemas'
import { NFTPurchase } from 'decentraland-dapps/dist/modules/gateway/types'
import { buildTransactionWithFromPayload, buildTransactionWithReceiptPayload } from 'decentraland-dapps/dist/modules/transaction/utils'
import {
buildCrossChainTransactionFromPayload,
buildTransactionWithFromPayload,
buildTransactionWithReceiptPayload
} from 'decentraland-dapps/dist/modules/transaction/utils'
import type { Route } from 'decentraland-transactions/crossChain'
import { action } from 'typesafe-actions'
import { formatWeiMANA } from '../../lib/mana'
Expand Down Expand Up @@ -86,7 +90,6 @@ export type BuyItemSuccessAction = ReturnType<typeof buyItemSuccess>
export type BuyItemFailureAction = ReturnType<typeof buyItemFailure>

// Buy Item Cross Chain
export const TRACK_CROSS_CHAIN_TX_REQUEST = '[Request] Track Buy item cross-chain tx'
export const BUY_ITEM_CROSS_CHAIN_REQUEST = '[Request] Buy item cross-chain'
export const BUY_ITEM_CROSS_CHAIN_SUCCESS = '[Success] Buy item cross-chain'
export const BUY_ITEM_CROSS_CHAIN_FAILURE = '[Failure] Buy item cross-chain'
Expand All @@ -100,7 +103,7 @@ export const buyItemCrossChainSuccess = (route: Route, chainId: ChainId, txHash:
item,
txHash,
order,
...buildTransactionWithReceiptPayload(chainId, txHash, {
...buildCrossChainTransactionFromPayload(chainId, Number(route.route.params.toChain) as ChainId, txHash, route.requestId ?? 'Unknown', {
itemId: item.itemId,
contractAddress: item.contractAddress,
network: item.network,
Expand All @@ -109,11 +112,6 @@ export const buyItemCrossChainSuccess = (route: Route, chainId: ChainId, txHash:
})
})

export const trackCrossChainTx = (chainId: ChainId, txHash: string) =>
action(TRACK_CROSS_CHAIN_TX_REQUEST, {
...buildTransactionWithReceiptPayload(chainId, txHash)
})

export const buyItemCrossChainFailure = (route: Route, item: Item, price: string, error: string) =>
action(BUY_ITEM_CROSS_CHAIN_FAILURE, { route, item, price, error })

Expand Down
65 changes: 3 additions & 62 deletions webapp/src/modules/item/sagas.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getLocation, push } from 'connected-react-router'
import { getLocation } from 'connected-react-router'
import { expectSaga } from 'redux-saga-test-plan'
import * as matchers from 'redux-saga-test-plan/matchers'
import { call, delay, select, take } from 'redux-saga/effects'
import { call, select, take } from 'redux-saga/effects'
import { ChainId, Item, Network, Rarity } from '@dcl/schemas'
import { Wallet } from 'decentraland-dapps/dist/modules/wallet/types'
import { sendTransaction } from 'decentraland-dapps/dist/modules/wallet/utils'
Expand Down Expand Up @@ -38,20 +38,14 @@ import {
fetchCollectionItemsRequest,
fetchCollectionItemsSuccess,
fetchCollectionItemsFailure,
FETCH_ITEMS_CANCELLED_ERROR_MESSAGE,
buyItemCrossChainSuccess,
trackCrossChainTx
FETCH_ITEMS_CANCELLED_ERROR_MESSAGE
} from './actions'
import { AxelarProvider, RouteResponse, StatusResponse } from 'decentraland-transactions/crossChain'
import { CANCEL_FETCH_ITEMS, itemSaga } from './sagas'
import { getData as getItems } from './selectors'
import { getItem } from './utils'
import { ItemBrowseOptions } from './types'
import { getIsMarketplaceServerEnabled } from '../features/selectors'
import { waitForFeatureFlagsToBeLoaded } from '../features/utils'
import { AssetType } from '../asset/types'
import { showToast } from 'decentraland-dapps/dist/modules/toast/actions'
import { getCrossChainTransactionSuccessToast } from '../toast/toasts'

const item = {
itemId: 'anItemId',
Expand Down Expand Up @@ -626,56 +620,3 @@ describe('when handling the fetch trending items request action', () => {
})
})
})

describe('when handling the buy item cross chain success action', () => {
let route: RouteResponse
let chainId: ChainId
let txHash: string
let statusResponse: StatusResponse
beforeEach(() => {
chainId = ChainId.ETHEREUM_MAINNET
txHash = 'aHash'
})
describe('and its an actual cross chain purchase', () => {
beforeEach(() => {
route = {
requestId: 'aRequestId',
route: {
params: {
fromChain: ChainId.ETHEREUM_MAINNET.toString(),
toChain: ChainId.MATIC_MAINNET.toString()
}
}
} as RouteResponse
statusResponse = {
status: 'success',
toChain: {
transactionId: 'destinationChainTx'
}
} as StatusResponse
})
it('should get the status of the transaction and put the trackCrossChainTx action, put location success and put the cross chain success toast', () => {
return expectSaga(itemSaga, getIdentity)
.provide([
[matchers.call.fn(AxelarProvider.prototype.getStatus), statusResponse],
[delay(1000), void 0]
])
.put(trackCrossChainTx(parseInt(route.route.params.toChain) as ChainId, statusResponse.toChain!.transactionId))
.put(showToast(getCrossChainTransactionSuccessToast(AxelarProvider.getTxLink(txHash))))
.put(
push(
locations.success({
txHash,
destinationTxHash: statusResponse.toChain?.transactionId,
tokenId: item.itemId,
assetType: AssetType.ITEM,
contractAddress: item.contractAddress,
isCrossChain: 'true'
})
)
)
.dispatch(buyItemCrossChainSuccess(route, chainId, txHash, item))
.run({ silenceTimeout: true })
})
})
})
Loading

0 comments on commit d7347bc

Please sign in to comment.