From 48d3dad4a256ffcf924890906dec664fec950766 Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Fri, 8 Mar 2024 14:38:10 -0500 Subject: [PATCH 1/2] fix: pagination on marketplace ids --- package.json | 2 +- src/api/registry.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4a87393..1d61f7a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "climate-tokenization-engine", - "version": "1.3.18", + "version": "1.3.19", "bin": "./src/server.js", "description": "", "main": "proxy.js", diff --git a/src/api/registry.js b/src/api/registry.js index d3b41dd..e08e8a6 100644 --- a/src/api/registry.js +++ b/src/api/registry.js @@ -688,7 +688,7 @@ const waitForRegistryDataSync = async (options = {}) => { */ const getTokenizedUnitByAssetId = async (assetId) => { try { - const url = `${registryUri}/v1/units?marketplaceIdentifiers=${assetId}`; + const url = `${registryUri}/v1/units?marketplaceIdentifiers=${assetId}&page=1&limit=100`; logger.debug(`GET ${url}`); const response = await superagent.get(url).set(maybeAppendRegistryApiKey()); From c901e1605dedf3b717d5dc2c2f71801700d62142 Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Fri, 8 Mar 2024 14:51:32 -0500 Subject: [PATCH 2/2] fix: pagination on marketplace ids --- src/api/registry.js | 2 +- src/controllers.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/registry.js b/src/api/registry.js index e08e8a6..8e0d474 100644 --- a/src/api/registry.js +++ b/src/api/registry.js @@ -698,7 +698,7 @@ const getTokenizedUnitByAssetId = async (assetId) => { ); } - return response.body; + return response?.body?.data || []; } catch (error) { logger.error(`Could not get tokenized unit by asset id: ${error.message}`); diff --git a/src/controllers.js b/src/controllers.js index 85b9202..c47ada6 100644 --- a/src/controllers.js +++ b/src/controllers.js @@ -109,7 +109,7 @@ const parseDetokFile = async (req, res) => { const unitToBeDetokenizedResponse = await registry.getTokenizedUnitByAssetId(assetId); - let unitToBeDetokenized = JSON.parse(unitToBeDetokenizedResponse); + let unitToBeDetokenized = unitToBeDetokenizedResponse; if (unitToBeDetokenized.length) { unitToBeDetokenized = unitToBeDetokenized[0]; }