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: hide nft market ui #3663

Merged
merged 2 commits into from
Oct 27, 2023
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
4 changes: 0 additions & 4 deletions packages/engine/src/managers/nft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ import { IDecodedTxActionType, IDecodedTxDirection } from '../vaults/types';

import { isAllNetworks } from './network';

export function getNFTListKey(accountId: string, networkId: string) {
return `${accountId.toLowerCase()}-${networkId}`.toLowerCase();
}

export const isCollectibleSupportedChainId = (networkId?: string) => {
if (!networkId) return false;
if (isAllNetworks(networkId)) return true;
Expand Down
171 changes: 2 additions & 169 deletions packages/kit-bg/src/services/ServiceNFT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,19 @@ import simpleDb from '@onekeyhq/engine/src/dbs/simple/simpleDb';
import { getFiatEndpoint } from '@onekeyhq/engine/src/endpoint';
import { OneKeyInternalError } from '@onekeyhq/engine/src/errors';
import * as nft from '@onekeyhq/engine/src/managers/nft';
import { NFTDataType, getNFTListKey } from '@onekeyhq/engine/src/managers/nft';
import type { Account } from '@onekeyhq/engine/src/types/account';
import { NFTDataType } from '@onekeyhq/engine/src/managers/nft';
import type {
Collection,
CollectionAttribute,
MarketPlace,
NFTAsset,
NFTAssetMeta,
NFTBTCAssetModel,
NFTListItems,
NFTMarketCapCollection,
NFTMarketRanking,
NFTPNL,
NFTServiceResp,
NFTTransaction,
} from '@onekeyhq/engine/src/types/nft';
import {
setNFTPriceType,
setNFTSymbolPrice,
} from '@onekeyhq/kit/src/store/reducers/nft';
import { setNFTPriceType } from '@onekeyhq/kit/src/store/reducers/nft';
import { EOverviewScanTaskType } from '@onekeyhq/kit/src/views/Overview/types';
import {
backgroundClass,
Expand Down Expand Up @@ -75,27 +68,6 @@ class ServiceNFT extends ServiceBase {
return data;
}

@backgroundMethod()
async getCollectionAttributes({
chain,
contractAddress,
}: {
chain: string;
contractAddress: string;
}) {
const urlParams = new URLSearchParams({ chain, contractAddress });
const url = `${this.baseUrl}/collection/attributes?${urlParams.toString()}`;

const { data, success } = await this.client
.get<NFTServiceResp<CollectionAttribute[]>>(url)
.then((resp) => resp.data)
.catch(() => ({ success: false, data: [] }));
if (!success) {
return undefined;
}
return data;
}

@backgroundMethod()
async searchCollections({ chain, name }: { chain: string; name: string }) {
const url = `${this.baseUrl}/collection/search?chain=${chain}&name=${name}`;
Expand All @@ -109,61 +81,6 @@ class ServiceNFT extends ServiceBase {
return data;
}

@backgroundMethod()
async getCollectionAssets({
chain,
contractAddress,
cursor,
limit = 50,
}: {
chain: string;
contractAddress: string;
cursor?: string;
limit?: number;
}) {
let url = `${this.baseUrl}/collection/assets?chain=${chain}&contractAddress=${contractAddress}&limit=${limit}`;
if (cursor) {
url += `&cursor=${cursor}`;
}
const { data, success } = await this.client
.get<
NFTServiceResp<{ total: number; next: string; content: NFTAsset[] }>
>(url)
.then((resp) => resp.data)
.catch(() => ({
success: false,
data: { total: 0, next: undefined, content: [] as NFTAsset[] },
}));
if (!success) {
return undefined;
}
return data;
}

@backgroundMethod()
async getAssetsWithAttributes(params: {
chain: string;
contractAddress: string;
attributes: any[];
limit?: number;
cursor?: string;
}) {
const apiUrl = `${this.baseUrl}/assets/attributes`;
const { data, success } = await this.client
.post<
NFTServiceResp<{ total: number; next: string; content: NFTAsset[] }>
>(apiUrl, params)
.then((resp) => resp.data)
.catch(() => ({
success: false,
data: { total: 0, next: undefined, content: [] as NFTAsset[] },
}));
if (!success) {
return undefined;
}
return data;
}

@backgroundMethod()
async getCollectionTransactions({
chain,
Expand Down Expand Up @@ -209,30 +126,6 @@ class ServiceNFT extends ServiceBase {
return data;
}

@backgroundMethod()
async getMarketCapCollection({
chain,
limit,
}: {
chain?: string;
limit?: number;
}) {
let url = `${this.baseUrl}/market/marketCap?chain=${
chain ?? OnekeyNetwork.eth
}`;
if (limit) {
url += `&limit=${limit}`;
}
const { data, success } = await this.client
.get<NFTServiceResp<NFTMarketCapCollection[]>>(url)
.then((resp) => resp.data)
.catch(() => ({ success: false, data: [] as NFTMarketCapCollection[] }));
if (!success) {
return [];
}
return data;
}

@backgroundMethod()
async getMarketRanking({ chain, time }: { chain?: string; time?: string }) {
const url = `${this.baseUrl}/market/ranking?chain=${
Expand All @@ -248,34 +141,6 @@ class ServiceNFT extends ServiceBase {
return data;
}

@backgroundMethod()
async getMarketCollection() {
const url = `${this.baseUrl}/market/collection`;
const { data, success } = await this.client
.get<NFTServiceResp<Collection[]>>(url)
.then((resp) => resp.data)
.catch(() => ({ success: false, data: [] as Collection[] }));
if (!success) {
return [];
}
return data;
}

@backgroundMethod()
async getLiveMinting({ chain, limit }: { chain?: string; limit?: number }) {
const url = `${this.baseUrl}/market/liveMint?chain=${
chain ?? OnekeyNetwork.eth
}&limit=${limit ?? 5}`;
const { data, success } = await this.client
.get<NFTServiceResp<NFTAsset[]>>(url)
.then((resp) => resp.data)
.catch(() => ({ success: false, data: [] as NFTAsset[] }));
if (!success) {
return [];
}
return data;
}

@backgroundMethod()
async batchAsset(params: {
ignoreError?: boolean;
Expand Down Expand Up @@ -326,23 +191,6 @@ class ServiceNFT extends ServiceBase {
return data;
}

@backgroundMethod()
async batchLocalCollection({
networkId,
account,
}: {
networkId: string;
account: Account;
}): Promise<NFTAssetMeta | undefined> {
const key = getNFTListKey(account.address, networkId);
const items = await simpleDb.nft.getNFTs(key);
if (items) {
const { engine } = this.backgroundApi;
const vault = await engine.getVault({ networkId, accountId: account.id });
return vault.getUserNFTAssets({ serviceData: items });
}
}

@backgroundMethod()
async fetchNFT({
accountId,
Expand Down Expand Up @@ -388,21 +236,6 @@ class ServiceNFT extends ServiceBase {
return nft.getAllAssetsFromLocal(params);
}

@backgroundMethod()
async fetchSymbolPrice(networkId: string) {
const price = await nft.getNFTSymbolPrice(networkId);
if (price) {
const { dispatch } = this.backgroundApi;
dispatch(
setNFTSymbolPrice({
networkId,
price,
}),
);
return price;
}
}

@backgroundMethod()
updatePriceType(priceType: 'floorPrice' | 'lastSalePrice') {
const { dispatch } = this.backgroundApi;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { withTabLayout } from '@onekeyhq/components/src/Layout/withTabLayout';
import { toFocusedLazy } from '../../../../../components/LazyRenderWhenFocus';
import BulkSender from '../../../../../views/BulkSender';
import FullTokenList from '../../../../../views/FullTokenList/FullTokenList';
import NFTMarketCollectionScreen from '../../../../../views/NFTMarket/CollectionDetail';
import PNLDetailScreen from '../../../../../views/NFTMarket/PNL/PNLDetail';
import OverviewDefiListScreen from '../../../../../views/Overview';
import RevokePage from '../../../../../views/Revoke';
Expand Down Expand Up @@ -49,10 +48,6 @@ const config: TabRouteConfig = {
name: HomeRoutes.RevokeRedirect2,
component: RevokeRedirectPage,
},
{
name: HomeRoutes.NFTMarketCollectionScreen,
component: NFTMarketCollectionScreen,
},
{
name: HomeRoutes.NFTPNLScreen,
component: PNLDetailScreen,
Expand Down
44 changes: 0 additions & 44 deletions packages/kit/src/routes/Root/Main/Tab/routes/AppRootTabNFT.ts

This file was deleted.

5 changes: 0 additions & 5 deletions packages/kit/src/routes/Root/Modal/NFTMarket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useIsVerticalLayout } from '@onekeyhq/components';

import CalculatorModal from '../../../views/NFTMarket/Modals/Calculator';
import MarketPlaceList from '../../../views/NFTMarket/Modals/Calculator/MarketPlaceList';
import NFTAttributesModal from '../../../views/NFTMarket/Modals/NFTAttributesModal';
import NFTSearchModal from '../../../views/NFTMarket/Modals/NFTSearchModal';
import ShareNFTPNLModal from '../../../views/NFTMarket/Modals/Share';
import { NFTMarketRoutes } from '../../../views/NFTMarket/Modals/type';
Expand All @@ -14,10 +13,6 @@ import type { NFTMarketRoutesParams } from '../../../views/NFTMarket/Modals/type
const NFTMarketNavigator = createStackNavigator<NFTMarketRoutesParams>();

const modalRoutes = [
{
name: NFTMarketRoutes.FilterModal,
component: NFTAttributesModal,
},
{
name: NFTMarketRoutes.SearchModal,
component: NFTSearchModal,
Expand Down
3 changes: 0 additions & 3 deletions packages/kit/src/routes/routesEnum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ export enum HomeRoutes {
BulkSender = 'BulkSender',

// **** NFT Tab
NFTMarketStatsList = 'NFTMarketStatsList',
NFTMarketLiveMintingList = 'NFTMarketLiveMintingList',
NFTMarketCollectionScreen = 'NFTMarketCollectionScreen',
NFTPNLScreen = 'NFTPNLScreen',

// **** Me Tab
Expand Down
8 changes: 0 additions & 8 deletions packages/kit/src/routes/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,6 @@ export type HomeRoutesParams = {
marketTokenId: string;
};
[HomeRoutes.Revoke]: undefined;
[HomeRoutes.NFTMarketStatsList]: { network: Network; selectedIndex?: number };
[HomeRoutes.NFTMarketLiveMintingList]: { network: Network };
[HomeRoutes.NFTMarketCollectionScreen]: {
networkId: string;
contractAddress: string;
collection?: Collection;
title?: string;
};
[HomeRoutes.RevokeRedirect]: undefined;
[HomeRoutes.RevokeRedirect2]: undefined;
[HomeRoutes.NFTPNLScreen]: undefined;
Expand Down
Loading