Skip to content

Commit

Permalink
add limit and offset to jankle assets endpoint (solana-labs#142)
Browse files Browse the repository at this point in the history
Co-authored-by: Noah Gundotra
  • Loading branch information
ngundotra authored Jul 12, 2022
1 parent 0a99922 commit 8538198
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion contracts/sdk/indexer/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,9 @@ export class NFTDatabaseConnection {
}
}

async getAssetsForOwner(owner: string, treeId?: string) {
async getAssetsForOwner(owner: string, treeId?: string, limit?: number, offset?: number) {
const limitClause = limit ? `LIMIT ${limit}` : "";
const offsetClause = offset ? `OFFSET ${offset}` : "";
const query = `
SELECT
ls.tree_id as treeId,
Expand Down Expand Up @@ -775,6 +777,9 @@ export class NFTDatabaseConnection {
JOIN nft n
ON ls.asset_id = n.asset_id
WHERE owner = ?
ORDER BY n.name
${limitClause}
${offsetClause}
`;

let rawNftMetadata;
Expand Down
2 changes: 1 addition & 1 deletion contracts/sdk/indexer/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ app.get("/proof", async (req, res) => {

app.get("/assets", async (req, res) => {
const owner = req.query.owner;
const assets = await nftDb.getAssetsForOwner(owner, req.query.treeId);
const assets = await nftDb.getAssetsForOwner(owner, req.query.treeId, req.query.limit, req.query.offset);
res.send(JSON.stringify(assets));
});

Expand Down

0 comments on commit 8538198

Please sign in to comment.