Fix/koios evaluator response 610 #788
Open
+17
−6
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 fixes a bug in the Koios provider's
evaluateTxmethod where the response from the Koios Ogmios endpoint was incorrectly handled. The Koios Ogmios endpoint returns the evaluation result as an object (matching the native Ogmios provider format), but the code was treating it as an array, causing evaluation failures or incorrect results.Problem:
data.result.lengthand useddata.result.map()directly, assumingresultwas an arraySolution:
Object.values(data.result)to convert the object to an array before mapping.lengthcheck since objects don't have alengthpropertyObject.values()is used, matching the pattern from the Ogmios provider implementationThis fix ensures the Koios provider correctly implements
IEvaluatorand can be used withMeshTxBuilderfor transaction evaluation.Affect components
@meshsdk/providerType of Change
Related Issues
Checklist
npm run test)npm run build)Additional Information
Changes Made:
File:
packages/mesh-provider/src/koios.tsLine 662: Changed from
if (!data.result || !data.result.length)toif (!data.result).lengthcheck sinceresultis an object, not an arrayLine 666: Changed from
return data.result.map(...)toreturn Object.values(data.result).map(...)Added comment: Explains why
Object.values()is used to handle the object response formatTechnical Details:
The Koios API provides an Ogmios-compatible endpoint at
/ogmiosthat returns evaluation results in the same format as the native Ogmios provider. The response structure is:{
"result": {
"0": { "validator": {...}, "budget": {...} },
"1": { "validator": {...}, "budget": {...} }
}
}