Skip to content

Commit

Permalink
fix: remove redundant
Browse files Browse the repository at this point in the history
  • Loading branch information
evilpeach committed Jul 8, 2024
1 parent f47f0d4 commit 648f062
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 34 deletions.
34 changes: 18 additions & 16 deletions src/lib/services/nft/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,24 @@ export const getCollections = async (
offset: number,
search?: string
) => {
const expressionNew = getCollectionsExpression(search);
const expressionOld = getCollectionsExpressionOld(search);

try {
const res = await axios.post(indexer, {
query: getCollectionsQuery,
variables: { offset, limit, expression: expressionNew },
variables: {
offset,
limit,
expression: getCollectionsExpression(search),
},
});
return parseWithError(zCollectionsResponse, res.data.data);
} catch {
const res = await axios.post(indexer, {
query: getCollectionsQueryOld,
variables: { offset, limit, expression: expressionOld },
variables: {
offset,
limit,
expression: getCollectionsExpressionOld(search),
},
});
return parseWithError(zCollectionsResponse, res.data.data);
}
Expand Down Expand Up @@ -292,22 +297,16 @@ export const getCollectionActivities = async (
offset: number,
search?: string
) => {
const expressionNew = getCollectionActivitiesExpression(
collectionAddress,
search
);
const expressionOld = getCollectionActivitiesExpressionOld(
collectionAddress,
search
);

try {
const res = await axios.post(indexer, {
query: getCollectionActivitiesQuery,
variables: {
limit,
offset,
expression: expressionNew,
expression: getCollectionActivitiesExpression(
collectionAddress,
search
),
},
});
return parseWithError(
Expand All @@ -320,7 +319,10 @@ export const getCollectionActivities = async (
variables: {
limit,
offset,
expression: expressionOld,
expression: getCollectionActivitiesExpressionOld(
collectionAddress,
search
),
},
});
return parseWithError(
Expand Down
38 changes: 20 additions & 18 deletions src/lib/services/nft/nft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,13 @@ export const getNfts = async (
limit: number,
offset: number
) => {
const expressionNew = getNftsExpression(collectionAddress, search);
const expressionOld = getNftsExpressionOld(collectionAddress, search);

try {
const res = await axios.post(indexer, {
query: getNftsQuery,
variables: {
limit,
offset,
expression: expressionNew,
expression: getNftsExpression(collectionAddress, search),
},
});
return parseWithError(zNft.array(), res.data.data.nfts);
Expand All @@ -105,7 +102,7 @@ export const getNfts = async (
variables: {
limit,
offset,
expression: expressionOld,
expression: getNftsExpressionOld(collectionAddress, search),
},
});
return parseWithError(zNftOld.array(), res.data.data.nfts);
Expand Down Expand Up @@ -372,27 +369,32 @@ export const getNftsByAccount = async (
collectionAddress?: HexAddr32,
search?: string
) => {
const expressionNew = getNftsByAccountExpression(
accountAddress,
collectionAddress,
search
);
const expressionOld = getNftsByAccountExpressionOld(
accountAddress,
collectionAddress,
search
);

try {
const res = await axios.post(indexer, {
query: getNftsByAccountQuery,
variables: { limit, offset, expression: expressionNew },
variables: {
limit,
offset,
expression: getNftsByAccountExpression(
accountAddress,
collectionAddress,
search
),
},
});
return parseWithError(zNftsByAccountResponse, res.data.data);
} catch {
const res = await axios.post(indexer, {
query: getNftsByAccountQueryOld,
variables: { limit, offset, expression: expressionOld },
variables: {
limit,
offset,
expression: getNftsByAccountExpressionOld(
accountAddress,
collectionAddress,
search
),
},
});
return parseWithError(zNftsByAccountResponse, res.data.data);
}
Expand Down

0 comments on commit 648f062

Please sign in to comment.