-
Notifications
You must be signed in to change notification settings - Fork 18
Description
Background
PR #1861 changes Participants from Vec<(AccountId, ParticipantId, ParticipantInfo)> to BTreeMap<AccountId, ParticipantData> for O(log n) lookups. To maintain JSON backward compatibility, we need to introduce DTO serialization types (ParticipantId, ParticipantInfo, ParticipantData, ParticipantsJson, ParticipantsField, ParticipantsJsonDeserialize) in the contract-interface crate.
As identified in Kevin's review, we need to:
- Use the DTO types in the actual contract interface — the contract should no longer serialize
Participantsdirectly; instead, it should convert to the DTO type via an.into_dto_type()(or similar) method. - Move additional types to
contract-interface—Participantsis embedded inThresholdParameters, which appears in the protocol contract states (Running,Initializing,Resharing), which are returned by thestate()view function. These types must also be represented in thecontract-interfacecrate to ensure backward compatibility is enforced at the DTO boundary.
This is significant but mostly mechanical/boilerplate work — defining DTO mirrors of the internal types and wiring up conversions.
User Story
As a contract developer, I need all types that appear in contract method inputs/outputs to be defined in the contract-interface crate, so that internal type changes (like the Participants Vec→BTreeMap migration in #1861) cannot accidentally break the JSON API.
Acceptance Criteria
- The
ParticipantsDTO types from feat(dtos): add Participants JSON serialization types to contract-interface #1990 are used in the contract's public interface (not the internalParticipantsstruct) - An
.into_dto_type()(orFrom/Intoimpl) conversion exists from internalParticipantsto the DTO type -
ThresholdParameters(or its DTO equivalent) is defined incontract-interface - Protocol state types (
Running,Initializing,Resharing) that are returned by thestate()view function have DTO representations incontract-interface - The
state()view function serializes using the DTO types, not the internal types - Existing JSON output format is preserved (backward compatible) — validated by unit tests
Resources & Additional Notes
- Parent PR: #1861 — feat: change Participants from Vec to BTreeMap
- DTO types PR: #1990 — feat(dtos): add Participants JSON serialization types to contract-interface
- Kevin's review comment with full context on the
contract-interfacecrate purpose and required work: #1990 review - The
contract-interfacecrate's purpose: ensure backward compatibility by having all contract I/O types defined there, decoupled from internal types - This is largely boilerplate work and a good candidate for LLM-assisted development (per Kevin's note)