Skip to content

Commit

Permalink
feat(@nftx/core): support base
Browse files Browse the repository at this point in the history
  • Loading branch information
jackmellis committed May 13, 2024
1 parent 349bf16 commit 42d8bd7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 74 deletions.
45 changes: 8 additions & 37 deletions packages/core/src/assets/fetchUserHoldings/fetchErc1155s.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import config from '@nftx/config';
import { createQuery, gql, querySubgraph } from '@nftx/subgraph';
import { createQuery, querySubgraph } from '@nftx/subgraph';
import type { Address, ERC1155, TokenId } from '@nftx/types';
import { getChainConstant } from '@nftx/utils';
import { createCursor, parseCursor } from './cursor';
import type { Holding } from './types';
import { Network } from '@nftx/constants';

type QuerySubgraph = typeof querySubgraph;

const fetchErc1155sMainnet = async ({
const fetchErc1155s = async ({
userAddress,
lastId,
network,
Expand Down Expand Up @@ -60,10 +59,6 @@ const fetchErc1155sMainnet = async ({
return [holdings, nextId] as const;
};

const fetchErc1155sSepolia = fetchErc1155sMainnet;

const fetchErc1155sArbitrum = fetchErc1155sMainnet;

export const makeFetchErc1155s =
({ querySubgraph }: { querySubgraph: QuerySubgraph }) =>
async ({
Expand All @@ -79,37 +74,13 @@ export const makeFetchErc1155s =
cursor?: string;
}> => {
const { lastId } = parseCursor('1155', cursor);
let holdings: Array<Holding> = [];
let nextId: string | undefined;

switch (network) {
case Network.Mainnet:
[holdings, nextId] = await fetchErc1155sMainnet({
lastId,
network,
userAddress,
querySubgraph,
});
break;
case Network.Sepolia:
[holdings, nextId] = await fetchErc1155sSepolia({
lastId,
network,
userAddress,
querySubgraph,
});
break;
case Network.Arbitrum:
[holdings, nextId] = await fetchErc1155sArbitrum({
lastId,
network,
userAddress,
querySubgraph,
});
break;
default:
break;
}
const [holdings, nextId] = await fetchErc1155s({
lastId,
network,
querySubgraph,
userAddress,
});

return {
holdings,
Expand Down
45 changes: 8 additions & 37 deletions packages/core/src/assets/fetchUserHoldings/fetchErc721s.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { Address, ERC721, TokenId } from '@nftx/types';
import { createCursor, parseCursor } from './cursor';
import { Network } from '@nftx/constants';
import { createQuery, gql, querySubgraph } from '@nftx/subgraph';
import { createQuery, querySubgraph } from '@nftx/subgraph';
import { getChainConstant } from '@nftx/utils';
import config from '@nftx/config';
import type { Holding } from './types';

type QuerySubgraph = typeof querySubgraph;

const fetchErc721sMainnet = async ({
const fetchErc721s = async ({
lastId,
network,
userAddress,
Expand Down Expand Up @@ -50,10 +49,6 @@ const fetchErc721sMainnet = async ({
return [holdings, nextId] as const;
};

const fetchErc721sSepolia = fetchErc721sMainnet;

const fetchErc721sArbitrum = fetchErc721sMainnet;

export const makeFetchErc721s =
({ querySubgraph }: { querySubgraph: QuerySubgraph }) =>
async ({
Expand All @@ -69,37 +64,13 @@ export const makeFetchErc721s =
cursor?: string;
}> => {
const { lastId } = parseCursor('721', cursor);
let holdings: Array<Holding> = [];
let nextId: string | undefined;

switch (network) {
case Network.Mainnet:
[holdings, nextId] = await fetchErc721sMainnet({
lastId,
network,
userAddress,
querySubgraph,
});
break;
case Network.Sepolia:
[holdings, nextId] = await fetchErc721sSepolia({
lastId,
network,
userAddress,
querySubgraph,
});
break;
case Network.Arbitrum:
[holdings, nextId] = await fetchErc721sArbitrum({
lastId,
network,
userAddress,
querySubgraph,
});
break;
default:
break;
}
const [holdings, nextId] = await fetchErc721s({
lastId,
network,
querySubgraph,
userAddress,
});

return {
holdings,
Expand Down

0 comments on commit 42d8bd7

Please sign in to comment.