Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add off chain marketplace to contract settings #2370

Merged
merged 2 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions webapp/src/components/SettingsPage/SettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ const SettingsPage = (props: Props) => {
network: Network.MATIC
})

const offChainMarketplaceEthereum = getContract({
name: contractNames.OFF_CHAIN_MARKETPLACE,
network: Network.ETHEREUM
})

const offChainMarketplaceMatic = getContract({
name: contractNames.OFF_CHAIN_MARKETPLACE,
network: Network.MATIC
})

const bidsEthereum = getContract({
name: contractNames.BIDS,
network: Network.ETHEREUM
Expand Down Expand Up @@ -75,6 +85,8 @@ const SettingsPage = (props: Props) => {
!collectionStore ||
!marketplaceEthereum ||
!marketplaceMatic ||
!offChainMarketplaceEthereum ||
!offChainMarketplaceMatic ||
!bidsEthereum ||
!bidsMatic ||
!manaEthereum ||
Expand Down Expand Up @@ -180,6 +192,26 @@ const SettingsPage = (props: Props) => {
type: AuthorizationType.ALLOWANCE
}}
/>
<Authorization
authorization={{
address: wallet.address,
authorizedAddress: offChainMarketplaceEthereum.address,
contractAddress: manaEthereum.address,
contractName: ContractName.MANAToken,
chainId: manaEthereum.chainId,
type: AuthorizationType.ALLOWANCE
}}
/>
<Authorization
authorization={{
address: wallet.address,
authorizedAddress: offChainMarketplaceMatic.address,
contractAddress: manaMatic.address,
contractName: ContractName.MANAToken,
chainId: manaMatic.chainId,
type: AuthorizationType.ALLOWANCE
}}
/>
<Authorization
authorization={{
address: wallet.address,
Expand Down
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
42 changes: 34 additions & 8 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 @@ -68,6 +67,16 @@ export function* handleFetchContractsSuccess() {
network: Network.MATIC
})) as ReturnType<typeof getContract>

const offChainMarketplaceEthereum: Contract | null = (yield select(getContract, {
name: contractNames.OFF_CHAIN_MARKETPLACE,
network: Network.ETHEREUM
})) as ReturnType<typeof getContract>

const offChainMarketplaceMatic: Contract | null = (yield select(getContract, {
name: contractNames.OFF_CHAIN_MARKETPLACE,
network: Network.MATIC
})) as ReturnType<typeof getContract>

const legacyMarketplaceMatic: Contract | null = (yield select(getContract, {
name: contractNames.LEGACY_MARKETPLACE,
network: Network.MATIC
Expand Down Expand Up @@ -105,6 +114,28 @@ export function* handleFetchContractsSuccess() {

let authorizations: Authorization[] = []

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

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

if (marketplaceEthereum && manaEthereum) {
authorizations.push({
address,
Expand Down Expand Up @@ -233,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
33 changes: 33 additions & 0 deletions webapp/src/modules/vendor/decentraland/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const LEGACY_MARKETPLACE_MAINNET_CONTRACT = '0xb3bca6f5052c7e24726b44da74
export enum ContractName {
MANA = 'MANA',
MARKETPLACE = 'Marketplace',
OFF_CHAIN_MARKETPLACE = 'OffChainMarketplace',
LEGACY_MARKETPLACE = 'LegacyMarketplace',
BIDS = 'Bids',
COLLECTION_STORE = 'CollectionStore',
Expand Down Expand Up @@ -466,6 +467,14 @@ const localContracts = {
network: Network.ETHEREUM,
chainId: ChainId.ETHEREUM_SEPOLIA
},
{
name: ContractName.OFF_CHAIN_MARKETPLACE,
address: getContract(CN.OffChainMarketplace, ChainId.ETHEREUM_SEPOLIA).address,
vendor: 'decentraland',
category: null,
network: Network.ETHEREUM,
chainId: ChainId.ETHEREUM_SEPOLIA
},
{
name: ContractName.BIDS,
address: getContract(CN.Bid, ChainId.ETHEREUM_SEPOLIA).address,
Expand Down Expand Up @@ -499,6 +508,14 @@ const localContracts = {
network: Network.MATIC,
chainId: ChainId.MATIC_AMOY
},
{
name: ContractName.OFF_CHAIN_MARKETPLACE,
address: getContract(CN.OffChainMarketplace, ChainId.MATIC_AMOY).address,
vendor: 'decentraland',
category: null,
network: Network.MATIC,
chainId: ChainId.MATIC_AMOY
},
{
name: ContractName.LEGACY_MARKETPLACE,
address: getContract(CN.Marketplace, ChainId.MATIC_MUMBAI).address,
Expand Down Expand Up @@ -618,6 +635,14 @@ const localContracts = {
network: Network.ETHEREUM,
chainId: ChainId.ETHEREUM_MAINNET
},
{
name: ContractName.OFF_CHAIN_MARKETPLACE,
address: getContract(CN.OffChainMarketplace, ChainId.ETHEREUM_MAINNET).address,
vendor: 'decentraland',
category: null,
network: Network.ETHEREUM,
chainId: ChainId.ETHEREUM_MAINNET
},
{
name: ContractName.BIDS,
address: getContract(CN.Bid, ChainId.ETHEREUM_MAINNET).address,
Expand Down Expand Up @@ -650,6 +675,14 @@ const localContracts = {
network: Network.MATIC,
chainId: ChainId.MATIC_MAINNET
},
{
name: ContractName.OFF_CHAIN_MARKETPLACE,
address: getContract(CN.OffChainMarketplace, ChainId.MATIC_MAINNET).address,
vendor: 'decentraland',
category: null,
network: Network.MATIC,
chainId: ChainId.MATIC_MAINNET
},
{
name: ContractName.LEGACY_MARKETPLACE,
address: getContract(CN.Marketplace, ChainId.MATIC_MAINNET).address,
Expand Down
Loading