From fa9fd0f105184305c4064781a73a7b0c7dfb17e0 Mon Sep 17 00:00:00 2001 From: yuriy Date: Tue, 2 Jul 2024 19:52:13 +0300 Subject: [PATCH] Return nft-marketplace --- .github/workflows/Release-nft-marketplace.yml | 3 +-- .github/workflows/STG-nft-marketplace.yml | 3 +-- frontend/apps/nft-marketplace/.env.example | 3 +-- frontend/apps/nft-marketplace/Dockerfile | 6 ++---- frontend/apps/nft-marketplace/src/consts.ts | 3 +-- frontend/apps/nft-marketplace/src/hocs/index.tsx | 11 +---------- .../apps/nft-marketplace/src/hooks/marketplace.ts | 7 ++----- frontend/apps/nft-marketplace/src/hooks/merge-nft.ts | 4 +--- frontend/apps/nft-marketplace/src/index.tsx | 2 +- 9 files changed, 11 insertions(+), 31 deletions(-) diff --git a/.github/workflows/Release-nft-marketplace.yml b/.github/workflows/Release-nft-marketplace.yml index bbcce6fbb..019c38b2b 100644 --- a/.github/workflows/Release-nft-marketplace.yml +++ b/.github/workflows/Release-nft-marketplace.yml @@ -74,8 +74,7 @@ jobs: REACT_APP_IPFS_GATEWAY_ADDRESS=${{ secrets.REACT_APP_IPFS_GATEWAY_ADDRESS }} REACT_APP_IPFS_ADDRESS=${{ secrets.REACT_APP_IPFS_ADDRESS }} REACT_APP_NFT_CONTRACT_ADDRESS=${{ secrets.REACT_APP_NFT_CONTRACT_ADDRESS }} - REACT_APP_DNS_API_URL=${{ secrets.REACT_APP_DNS_API_URL }} - REACT_APP_DNS_NAME=${{ secrets.REACT_APP_DNS_NAME_MARKETPLACE }} + REACT_APP_MARKETPLACE_CONTRACT_ADDRESS=${{ secrets.REACT_APP_MARKETPLACE_CONTRACT_ADDRESS }} REACT_APP_SENTRY_DSN=${{ secrets.REACT_SENTRY_DSN_NFT_MARKETPLACE }} deploy-to-k8s: diff --git a/.github/workflows/STG-nft-marketplace.yml b/.github/workflows/STG-nft-marketplace.yml index d15f7f6e2..f74a365ac 100644 --- a/.github/workflows/STG-nft-marketplace.yml +++ b/.github/workflows/STG-nft-marketplace.yml @@ -79,8 +79,7 @@ jobs: REACT_APP_IPFS_GATEWAY_ADDRESS=${{ secrets.REACT_APP_IPFS_GATEWAY_ADDRESS }} REACT_APP_IPFS_ADDRESS=${{ secrets.REACT_APP_IPFS_ADDRESS }} REACT_APP_NFT_CONTRACT_ADDRESS=${{ secrets.REACT_APP_NFT_CONTRACT_ADDRESS }} - REACT_APP_DNS_API_URL=${{ secrets.REACT_APP_DNS_API_URL }} - REACT_APP_DNS_NAME=${{ secrets.REACT_APP_DNS_NAME_MARKETPLACE }} + REACT_APP_MARKETPLACE_CONTRACT_ADDRESS=${{ secrets.REACT_APP_MARKETPLACE_CONTRACT_ADDRESS }} REACT_APP_SENTRY_DSN=${{ secrets.REACT_SENTRY_DSN_NFT_MARKETPLACE }} deploy-to-k8s: diff --git a/frontend/apps/nft-marketplace/.env.example b/frontend/apps/nft-marketplace/.env.example index 07588a032..bf120e326 100644 --- a/frontend/apps/nft-marketplace/.env.example +++ b/frontend/apps/nft-marketplace/.env.example @@ -1,8 +1,7 @@ REACT_APP_NODE_ADDRESS= REACT_APP_IPFS_ADDRESS= REACT_APP_IPFS_GATEWAY_ADDRESS= -REACT_APP_DNS_API_URL= -REACT_APP_DNS_NAME= +REACT_APP_MARKETPLACE_CONTRACT_ADDRESS= REACT_APP_NFT_CONTRACT_ADDRESS= # optional, specify sentry dsn and targetted domain for error tracking diff --git a/frontend/apps/nft-marketplace/Dockerfile b/frontend/apps/nft-marketplace/Dockerfile index d9217ed67..d93238a76 100644 --- a/frontend/apps/nft-marketplace/Dockerfile +++ b/frontend/apps/nft-marketplace/Dockerfile @@ -17,14 +17,12 @@ RUN apk add xsel ARG REACT_APP_NODE_ADDRESS \ REACT_APP_IPFS_ADDRESS \ REACT_APP_NFT_CONTRACT_ADDRESS \ - REACT_APP_DNS_API_URL \ - REACT_APP_DNS_NAME \ + REACT_APP_MARKETPLACE_CONTRACT_ADDRESS \ REACT_APP_IPFS_GATEWAY_ADDRESS \ REACT_APP_SENTRY_DSN ENV REACT_APP_NODE_ADDRESS=${REACT_APP_NODE_ADDRESS} \ REACT_APP_IPFS_ADDRESS=${REACT_APP_IPFS_ADDRESS} \ - REACT_APP_DNS_API_URL=${REACT_APP_DNS_API_URL} \ - REACT_APP_DNS_NAME=${REACT_APP_DNS_NAME} \ + REACT_APP_MARKETPLACE_CONTRACT_ADDRESS=${REACT_APP_MARKETPLACE_CONTRACT_ADDRESS} \ REACT_APP_NFT_CONTRACT_ADDRESS=${REACT_APP_NFT_CONTRACT_ADDRESS} \ REACT_APP_IPFS_GATEWAY_ADDRESS=${REACT_APP_IPFS_GATEWAY_ADDRESS} \ REACT_APP_SENTRY_DSN=${REACT_APP_SENTRY_DSN} \ diff --git a/frontend/apps/nft-marketplace/src/consts.ts b/frontend/apps/nft-marketplace/src/consts.ts index 0a6c04607..3c1b3221e 100644 --- a/frontend/apps/nft-marketplace/src/consts.ts +++ b/frontend/apps/nft-marketplace/src/consts.ts @@ -4,8 +4,7 @@ const ADDRESS = { NODE: process.env.REACT_APP_NODE_ADDRESS as string, IPFS: process.env.REACT_APP_IPFS_ADDRESS as string, IPFS_GATEWAY: process.env.REACT_APP_IPFS_GATEWAY_ADDRESS as string, - DNS_API_URL: process.env.REACT_APP_DNS_API_URL as string, - DNS_NAME: process.env.REACT_APP_DNS_NAME as string, + MARKETPLACE_CONTRACT: process.env.REACT_APP_MARKETPLACE_CONTRACT_ADDRESS as HexString, NFT_CONTRACT: process.env.REACT_APP_NFT_CONTRACT_ADDRESS as HexString, }; diff --git a/frontend/apps/nft-marketplace/src/hocs/index.tsx b/frontend/apps/nft-marketplace/src/hocs/index.tsx index aaa3715a4..6b3b5faa6 100644 --- a/frontend/apps/nft-marketplace/src/hocs/index.tsx +++ b/frontend/apps/nft-marketplace/src/hocs/index.tsx @@ -4,7 +4,6 @@ import { AccountProvider, ProviderProps, } from '@gear-js/react-hooks'; -import { DnsProvider as SharedDnsProvider } from '@dapps-frontend/hooks'; import { Alert, alertStyles } from '@gear-js/ui'; import { ComponentType } from 'react'; import { BrowserRouter } from 'react-router-dom'; @@ -15,14 +14,6 @@ function ApiProvider({ children }: ProviderProps) { return {children}; } -function DnsProvider({ children }: ProviderProps) { - return ( - - {children} - - ); -} - function AlertProvider({ children }: ProviderProps) { return ( @@ -31,7 +22,7 @@ function AlertProvider({ children }: ProviderProps) { ); } -const providers = [BrowserRouter, IPFSProvider, AlertProvider, ApiProvider, DnsProvider, AccountProvider]; +const providers = [BrowserRouter, IPFSProvider, AlertProvider, ApiProvider, AccountProvider]; function withProviders(Component: ComponentType) { return () => providers.reduceRight((children, Provider) => {children}, ); diff --git a/frontend/apps/nft-marketplace/src/hooks/marketplace.ts b/frontend/apps/nft-marketplace/src/hooks/marketplace.ts index 7b5a7afa7..bc9d2b447 100644 --- a/frontend/apps/nft-marketplace/src/hooks/marketplace.ts +++ b/frontend/apps/nft-marketplace/src/hooks/marketplace.ts @@ -1,4 +1,3 @@ -import { useDnsProgramIds } from '@dapps-frontend/hooks'; import { useReadWasmState, useSendMessageWithGas } from '@gear-js/react-hooks'; import { AnyJson } from '@polkadot/types/types'; import { useMemo } from 'react'; @@ -20,10 +19,9 @@ function useMarketplaceStateBuffer() { function useMarketplaceWasmState(functionName: string, argument: AnyJson) { const programMetadata = useMarketplaceMeta(); const buffer = useMarketplaceStateBuffer(); - const { programId } = useDnsProgramIds(); return useReadWasmState({ - programId, + programId: ADDRESS.MARKETPLACE_CONTRACT, wasm: buffer, functionName, payload: '0x', @@ -48,9 +46,8 @@ function useMarketNft(tokenId: string) { function useMarketplaceMessage() { const metadata = useMarketplaceMeta(); - const { programId } = useDnsProgramIds(); - return useSendMessageWithGas(programId, metadata); + return useSendMessageWithGas(ADDRESS.MARKETPLACE_CONTRACT, metadata); } function useMarketplaceActions(token_id: string, price: MarketNFT['price'] | undefined) { diff --git a/frontend/apps/nft-marketplace/src/hooks/merge-nft.ts b/frontend/apps/nft-marketplace/src/hooks/merge-nft.ts index 32836d7d5..7e16ffcb9 100644 --- a/frontend/apps/nft-marketplace/src/hooks/merge-nft.ts +++ b/frontend/apps/nft-marketplace/src/hooks/merge-nft.ts @@ -1,5 +1,4 @@ import { useAlert, useApi } from '@gear-js/react-hooks'; -import { useDnsProgramIds } from '@dapps-frontend/hooks'; import { ADDRESS } from 'consts'; import { useEffect, useState } from 'react'; import { NFT, MarketNFT, BaseNFT } from 'types'; @@ -55,7 +54,6 @@ function useMergedNFTs() { function useMergedOwnerNFTs() { const { api } = useApi(); const alert = useAlert(); - const { programId } = useDnsProgramIds(); const { NFTs: ownerNFTs } = useOwnersNft(); const marketplaceStateBuffer = useMarketplaceStateBuffer(); @@ -73,7 +71,7 @@ function useMergedOwnerNFTs() { api.programState .readUsingWasm( { - programId, + programId: ADDRESS.MARKETPLACE_CONTRACT, fn_name: 'item_info', wasm: marketplaceStateBuffer, argument: { nft_contract_id: ADDRESS.NFT_CONTRACT, token_id: baseNft.id }, diff --git a/frontend/apps/nft-marketplace/src/index.tsx b/frontend/apps/nft-marketplace/src/index.tsx index 71f3b00e8..58a8f72e9 100644 --- a/frontend/apps/nft-marketplace/src/index.tsx +++ b/frontend/apps/nft-marketplace/src/index.tsx @@ -6,7 +6,7 @@ import { App } from './App'; initAnalytics(); initErrorTracking(); -logPublicEnvs({ nftContract: ADDRESS.NFT_CONTRACT }); +logPublicEnvs({ marketplaceContract: ADDRESS.MARKETPLACE_CONTRACT, nftContract: ADDRESS.NFT_CONTRACT }); const container = document.getElementById('root'); const root = createRoot(container as HTMLElement);