Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions packages/mesh-provider/src/koios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,23 +283,30 @@ export class KoiosProvider
* @param cursor The cursor for pagination
* @returns The list of assets and the next cursor
*/
async fetchCollectionAssets(policyId: string): Promise<{ assets: Asset[] }> {
async fetchCollectionAssets(
policyId: string,
cursor?: number | string,
): Promise<{ assets: Asset[]; next?: string | number | null }> {
try {
// Note: Koios API doesn't support pagination for policy_asset_info endpoint
// We return all assets and set next to null to match the interface
const { data, status } = await this._axiosInstance.get(
`policy_asset_info?_asset_policy=${policyId}`,
);

if (status === 200)
if (status === 200) {
return {
assets: data.map((asset: KoiosAsset) => ({
unit: `${asset.policy_id}${asset.asset_name}`,
quantity: asset.total_supply,
})),
next: null, // Koios doesn't support pagination for this endpoint
};
}

throw parseHttpError(data);
} catch (error) {
throw parseHttpError(error);
return { assets: [], next: null };
}
}

Expand Down Expand Up @@ -430,6 +437,7 @@ export class KoiosProvider
_assets: true,
_scripts: true,
_bytecode: true,
_datums: true,
});

if (status === 200) {
Expand All @@ -453,7 +461,9 @@ export class KoiosProvider
txHash: string,
certIndex: number,
): Promise<GovernanceProposalInfo> {
throw new Error("Method not implemented");
// Koios API doesn't currently support governance proposal queries
// This is consistent with other providers like Maestro, Yaci, and U5C
throw new Error("Governance proposal queries are not supported by Koios API");
}

/**
Expand Down Expand Up @@ -650,11 +660,13 @@ export class KoiosProvider
});

if (status === 200 || status === 202) {
if (!data.result || !data.result.length) {
if (!data.result) {
return [];
}

return data.result.map((val: any) => {
// Koios Ogmios endpoint returns result as an object, not an array
// Use Object.values() to convert to array, matching Ogmios provider behavior
return Object.values(data.result).map((val: any) => {
if (!val.validator || !val.budget) {
throw new Error("Invalid response format");
}
Expand Down