diff --git a/packages/mesh-provider/src/koios.ts b/packages/mesh-provider/src/koios.ts index 168e93fa2..44c58df3e 100644 --- a/packages/mesh-provider/src/koios.ts +++ b/packages/mesh-provider/src/koios.ts @@ -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 }; } } @@ -453,7 +460,9 @@ export class KoiosProvider txHash: string, certIndex: number, ): Promise { - 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"); } /** @@ -650,11 +659,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"); }