Repository navigation
Conversation
…ectMBO#570 part 1) The Maestro spec marks plutus_cost_models.plutus_v3, a UTxO's datum and reference_script, a datum's bytes/json, next_cursor and delegated_pool optional/nullable, but the schemas required them (several via NullOr, which rejects a missing key) — one absent or null field failed the whole call. They are now Schema.optionalWith(..., { nullable: true }); the transforms already handled null, and a missing/null plutus_v3 maps to an empty cost model. The three protocol parameters the public ProtocolParameters type requires (delegate_representative_deposit, governance_action_deposit, min_fee_reference_scripts) also decode as null/missing, and the transform then fails with a clear error naming the field — no default is invented. getProtocolParameters converts that throw into a ProviderError via Effect.flatMap + Effect.try; a throw inside Effect.map would have been a defect. Part 2 of IntersectMBO#570 (the protocol-parameters path) is left out: the issue says it needs an API-key check before switching. Six new tests, each verified red on unmodified main. Maestro file 16/16; full suite 1684 passed / 75 skipped / 0 failed.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Part 1 of #570: Maestro responses that the provider schemas reject when a field the Maestro spec marks optional/nullable arrives
nullor missing.The spec (
maestro-org/maestro-api-specifications, per the issue) does not require these fields, but the schemas inMaestro.tsdid — several viaSchema.NullOr(...), which acceptsnullbut not a missing key — so any of them arriving absent or null failed the whole call with a schema decode error:plutus_cost_models.plutus_v3(the spec requires onlyplutus_v1andplutus_v2)datum,reference_script, and a datum'sbytes/jsonnext_cursoron paginated responses,delegated_poolon accountsFix
All of the above are now
Schema.optionalWith(X, { nullable: true }). The transforms needed almost no change —transformDatumOption,transformScriptRef,transformDelegation, and the pagination loop already handle null/undefined — except the cost models, where a missing/nullplutus_v3now maps via?? []to an emptyPlutusV3model.For the three protocol parameters the issue flags separately —
delegate_representative_deposit,governance_action_deposit, andmin_fee_reference_scripts, all required by the publicProtocolParameterstype — I chose the issue's "fail with a clear error" option over a default: a deposit or fee figure of 0 would be a silent wrong value, not a fallback. The schema accepts them as null/missing, andtransformProtocolParametersthen throws a clear error naming the field (required field "delegate_representative_deposit" arrived null or missing…).MaestroEffect.getProtocolParametersnow converts that throw into aProviderErrorviaEffect.flatMap+Effect.try— a throw insideEffect.mapwould have surfaced as a defect, not theProviderErrorthe function promises.Deliberately left out
Part 2 of #570 — the protocol-parameters path (
/protocol-parametersvs the spec's/general/protocol-parameters). The issue itself says the old path "may still work" and needs a check with an API key before switching; I don't have a Maestro key to verify with, so I haven't touched the path.Tests
Six new tests in
Maestro.test.ts, each verified red on unmodified main first (schemaProviderError/ decode failure) and green after:plutus_v3and nullplutus_v3both decode and map to an emptyPlutusV3modelProviderError(assertedCause.Fail, notDie) whose cause chain carries the deliberaterequired field "…"wording — the test asserts that wording specifically because a bare ParseError also names the fielddatum/reference_scriptkeys missing and nonext_cursorkey decodes (existing fixtures always send those keys, as null)bytes/jsonkeys are missing decodes to its datum hashdelegated_poolkey missing decodes topoolId: nullMaestro test file: 16/16. Full package suite: 1684 passed / 75 skipped / 0 failed (test files 101 passed / 1 skipped of 102 — main's baseline of 1678 plus the 6 new tests).
tsc --noEmitand eslint clean on the touched files; prettier drift on the two touched files is byte-identical to unmodified main (both were already flagged there — I matched the surrounding style in my hunks rather than reformatting unrelated code). A patch changeset is included.Independent builder — not affiliated with the Cardano Foundation, IOG or Intersect.
@Kshot9000 (https://x.com/kshot9000) · ADA donations: addr1q8hnl6vl5a6k3rw3n5g3jtte696zcl76kfatzv7gpswa9r0dj7fma6klq55y4ffm7tf0em09udnyhuk4ah92pl5x9jpqjae44v
cc @cardano-foundation @IntersectMBO