Skip to content

Commit

Permalink
Return nft-marketplace
Browse files Browse the repository at this point in the history
  • Loading branch information
faizov committed Jul 2, 2024
1 parent c97156b commit fa9fd0f
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 31 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/Release-nft-marketplace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/STG-nft-marketplace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions frontend/apps/nft-marketplace/.env.example
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 2 additions & 4 deletions frontend/apps/nft-marketplace/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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} \
Expand Down
3 changes: 1 addition & 2 deletions frontend/apps/nft-marketplace/src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
11 changes: 1 addition & 10 deletions frontend/apps/nft-marketplace/src/hocs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -15,14 +14,6 @@ function ApiProvider({ children }: ProviderProps) {
return <GearApiProvider initialArgs={{ endpoint: ADDRESS.NODE }}>{children}</GearApiProvider>;
}

function DnsProvider({ children }: ProviderProps) {
return (
<SharedDnsProvider names={{ programId: ADDRESS.DNS_NAME }} dnsApiUrl={ADDRESS.DNS_API_URL}>
{children}
</SharedDnsProvider>
);
}

function AlertProvider({ children }: ProviderProps) {
return (
<GearAlertProvider template={Alert} containerClassName={alertStyles.root}>
Expand All @@ -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) => <Provider>{children}</Provider>, <Component />);
Expand Down
7 changes: 2 additions & 5 deletions frontend/apps/nft-marketplace/src/hooks/marketplace.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -20,10 +19,9 @@ function useMarketplaceStateBuffer() {
function useMarketplaceWasmState<T>(functionName: string, argument: AnyJson) {
const programMetadata = useMarketplaceMeta();
const buffer = useMarketplaceStateBuffer();
const { programId } = useDnsProgramIds();

return useReadWasmState<T>({
programId,
programId: ADDRESS.MARKETPLACE_CONTRACT,
wasm: buffer,
functionName,
payload: '0x',
Expand All @@ -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) {
Expand Down
4 changes: 1 addition & 3 deletions frontend/apps/nft-marketplace/src/hooks/merge-nft.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -55,7 +54,6 @@ function useMergedNFTs() {
function useMergedOwnerNFTs() {
const { api } = useApi();
const alert = useAlert();
const { programId } = useDnsProgramIds();

const { NFTs: ownerNFTs } = useOwnersNft();
const marketplaceStateBuffer = useMarketplaceStateBuffer();
Expand All @@ -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 },
Expand Down
2 changes: 1 addition & 1 deletion frontend/apps/nft-marketplace/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit fa9fd0f

Please sign in to comment.