Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR updates the Koios provider to align with the
IFetcherinterface and improve error messaging. The changes address issue #618 by:Fixed
fetchCollectionAssetsmethod signature: Added the missingcursorparameter andnextreturn field to match theIFetcherinterface. Implemented proper pagination support using Koios API'slimitandoffsetparameters. The cursor parameter is used as the offset, with a default limit of 500 records per request (Koios API maximum). The method now correctly returns the next cursor when more results are available.Improved
fetchGovernanceProposalerror message: Updated the error message to clearly document that governance proposal queries are not supported by Koios API, making it consistent with other providers (Maestro, Yaci, U5C) and providing better developer feedback.These changes ensure the Koios provider fully implements the
IFetcherinterface and properly supports pagination for collection assets.Affect components
@meshsdk/providerType of Change
Related Issues
Checklist
npm run test)npm run build)Additional Information
Changes Made:
fetchCollectionAssetsmethod (lines 286-311):cursor?: number | stringparameter to matchIFetcherinterfacenext?: string | number | nulllimitandoffsetparameterslimit=500(Koios API maximum) and convertscursortooffsetnextcursor: returnsoffset + limitwhen more results are available,nullotherwisenext: nullon errorfetchGovernanceProposalmethod (lines 459-466):Technical Details:
Pagination Implementation:
limitandoffsetparameterslimitis 500 records per requestcursorparameter is converted tooffset(supports both number and string formats)data.length === limit, there may be more results, sonextis set tooffset + limitdata.length < limit, all results have been fetched, sonextis set tonullExample Usage:
// First page (offset 0)
const page1 = await provider.fetchCollectionAssets(policyId);
// page1.next = 500 if more results exist
// Next page (offset 500)
const page2 = await provider.fetchCollectionAssets(policyId, page1.next);
// Continue until next is null