Skip to content

Commit

Permalink
fix: Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LautaroPetaccio committed Feb 8, 2025
1 parent 654220e commit 9a19a59
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 22 deletions.
48 changes: 48 additions & 0 deletions webapp/src/modules/contract/sagas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,24 @@ describe('when handling the fetch contracts request', () => {
vendor: VendorName.DECENTRALAND
}

const offChainMarketplaceEthereum: Contract = {
address: 'offChainMarketplaceEthereumAddress',
category: null,
chainId: ChainId.ETHEREUM_MAINNET,
name: contractNames.OFF_CHAIN_MARKETPLACE,
network: Network.ETHEREUM,
vendor: VendorName.DECENTRALAND
}

const offChainMarketplaceMatic: Contract = {
address: 'offChainMarketplaceMaticAddress',
category: null,
chainId: ChainId.MATIC_MAINNET,
name: contractNames.OFF_CHAIN_MARKETPLACE,
network: Network.MATIC,
vendor: VendorName.DECENTRALAND
}

const legacyMarketplace: Contract = {
address: 'legacyMarketplaceAddress',
category: null,
Expand Down Expand Up @@ -142,6 +160,20 @@ describe('when handling the fetch contracts request', () => {
}),
marketplaceMatic
],
[
select(getContract, {
name: contractNames.OFF_CHAIN_MARKETPLACE,
network: Network.ETHEREUM
}),
offChainMarketplaceEthereum
],
[
select(getContract, {
name: contractNames.OFF_CHAIN_MARKETPLACE,
network: Network.MATIC
}),
offChainMarketplaceMatic
],
[
select(getContract, {
name: contractNames.LEGACY_MARKETPLACE,
Expand Down Expand Up @@ -208,6 +240,22 @@ describe('when handling the fetch contracts request', () => {
.put(fetchContractsSuccess([]))
.put(
fetchAuthorizationsRequest([
{
address,
authorizedAddress: offChainMarketplaceEthereum.address,
contractAddress: manaEthereum.address,
contractName: ContractName.MANAToken,
chainId: ChainId.ETHEREUM_GOERLI,
type: AuthorizationType.ALLOWANCE
},
{
address,
authorizedAddress: offChainMarketplaceMatic.address,
contractAddress: manaMatic.address,
contractName: ContractName.MANAToken,
chainId: ChainId.MATIC_AMOY,
type: AuthorizationType.ALLOWANCE
},
{
address,
authorizedAddress: marketplaceEthereum.address,
Expand Down
38 changes: 16 additions & 22 deletions webapp/src/modules/contract/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import { getAuthorizationKey } from './utils'
export function* contractSaga() {
yield takeEvery(FETCH_CONTRACTS_REQUEST, handleFetchContractsRequest)
yield takeEvery(FETCH_CONTRACTS_SUCCESS, handleFetchContractsSuccess)
yield takeEvery(CHANGE_ACCOUNT, handleChangeAccount)
yield takeEvery(CONNECT_WALLET_SUCCESS, handleConnectWalletSuccess)
yield takeEvery([CHANGE_ACCOUNT, CONNECT_WALLET_SUCCESS], handleWalletChange)
yield takeEvery(FETCH_TRANSACTION_SUCCESS, handleFetchTransactionSuccess)
}

Expand Down Expand Up @@ -115,54 +114,54 @@ export function* handleFetchContractsSuccess() {

let authorizations: Authorization[] = []

if (marketplaceEthereum && manaEthereum) {
if (offChainMarketplaceEthereum && manaEthereum) {
authorizations.push({
address,
authorizedAddress: marketplaceEthereum.address,
authorizedAddress: offChainMarketplaceEthereum.address,
contractAddress: manaEthereum.address,
contractName: ContractName.MANAToken,
chainId: manaEthereum.chainId,
type: AuthorizationType.ALLOWANCE
})
}

if (offChainMarketplaceEthereum && manaEthereum) {
if (offChainMarketplaceMatic && manaMatic) {
authorizations.push({
address,
authorizedAddress: offChainMarketplaceEthereum.address,
contractAddress: manaEthereum.address,
authorizedAddress: offChainMarketplaceMatic.address,
contractAddress: manaMatic.address,
contractName: ContractName.MANAToken,
chainId: manaEthereum.chainId,
chainId: manaMatic.chainId,
type: AuthorizationType.ALLOWANCE
})
}

if (marketplaceMatic && manaMatic) {
if (marketplaceEthereum && manaEthereum) {
authorizations.push({
address,
authorizedAddress: marketplaceMatic.address,
contractAddress: manaMatic.address,
authorizedAddress: marketplaceEthereum.address,
contractAddress: manaEthereum.address,
contractName: ContractName.MANAToken,
chainId: manaMatic.chainId,
chainId: manaEthereum.chainId,
type: AuthorizationType.ALLOWANCE
})
}

if (legacyMarketplaceMatic && manaMatic) {
if (marketplaceMatic && manaMatic) {
authorizations.push({
address,
authorizedAddress: legacyMarketplaceMatic.address,
authorizedAddress: marketplaceMatic.address,
contractAddress: manaMatic.address,
contractName: ContractName.MANAToken,
chainId: manaMatic.chainId,
type: AuthorizationType.ALLOWANCE
})
}

if (offChainMarketplaceMatic && manaMatic) {
if (legacyMarketplaceMatic && manaMatic) {
authorizations.push({
address,
authorizedAddress: offChainMarketplaceMatic.address,
authorizedAddress: legacyMarketplaceMatic.address,
contractAddress: manaMatic.address,
contractName: ContractName.MANAToken,
chainId: manaMatic.chainId,
Expand Down Expand Up @@ -265,15 +264,10 @@ export function* handleFetchContractsSuccess() {
)

authorizations = authorizations.filter(authorization => !storeAuthorizationsMap.has(getAuthorizationKey(authorization)))

yield put(fetchAuthorizationsRequest(authorizations))
}

function* handleChangeAccount() {
yield put(resetHasFetched())
}

function* handleConnectWalletSuccess() {
function* handleWalletChange() {
yield put(resetHasFetched())
}

Expand Down

0 comments on commit 9a19a59

Please sign in to comment.