Skip to content

feat(koios): replace Schema.Object with typed Schema.Struct for voting_procedures and proposal_procedures#165

Open
Mechack08 wants to merge 2 commits intoIntersectMBO:mainfrom
Mechack08:feat/koios-schema-structs
Open

feat(koios): replace Schema.Object with typed Schema.Struct for voting_procedures and proposal_procedures#165
Mechack08 wants to merge 2 commits intoIntersectMBO:mainfrom
Mechack08:feat/koios-schema-structs

Conversation

@Mechack08
Copy link

Summary

The voting_procedures and proposal_procedures fields in TxInfoSchema had two //TODO: add Schema.Struct comments, leaving them as unvalidated Schema.Array(Schema.Object) and Schema.Object. This PR replaces both with proper typed Schema.Struct definitions, improving runtime safety when parsing Koios /tx_info responses.

Changes

packages/evolution/src/sdk/provider/internal/Koios.ts

  • voting_procedures: Changed from Schema.Array(Schema.Object) to a typed Schema.NullOr(Schema.Array(Schema.Struct(...))) with:

    • voter_role: Schema.Literal("ConstitutionalCommittee", "DRep", "SPO")
    • vote: Schema.Literal("Yes", "No", "Abstain")
    • All remaining fields typed as Schema.String / Schema.Number
  • proposal_procedures: Changed from Schema.Object to a typed Schema.NullOr(Schema.Array(Schema.Struct(...))) with:

    • type: Schema.Literal("ParameterChange", "HardForkInitiation", "TreasuryWithdrawals", "NoConfidence", "NewCommittee", "NewConstitution", "InfoAction")
    • withdrawal: nested Schema.NullOr(Schema.Array(Schema.Struct(...)))
    • param_proposal: Schema.NullOr(Schema.Object) (intentionally loose — shape varies per proposal type)

Both fields are now NullOr arrays, matching the Koios OpenAPI spec (anyOf: [array, null]).

Schema source: https://preprod.koios.rest/#post-/tx_info

packages/evolution/test/Koios.schema.test.ts (new file)

Added 12 tests covering:

  • Valid and null inputs for both fields
  • All valid literal union values (voter_role, vote, proposal type)
  • Rejection of unknown/invalid enum values
  • Rejection of missing required fields

Test Results

Related

Resolves the two //TODO: add Schema.Struct comments in TxInfoSchema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant