Skip to content

Conversation

@Kolezhniuk
Copy link
Collaborator

Streamline state handling in PubSignalsVerifier and EthStateStorage. Improve error handling and enforce required fields in StateInfo. Introduce a utility function for clarity and add tests to ensure proper caching behavior for genesis states. Update version to 1.38.8.

…eStorage

- Removed unnecessary checks for genesis state in PubSignalsVerifier.
- Enhanced error handling in EthStateStorage to cache genesis state correctly.
- Updated StateInfo interface to enforce id as a required field.
- Introduced getIsGenesisStateById utility function for better clarity.
- Added tests for EthStateStorage to ensure proper caching behavior for genesis states.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors state handling in the Polygon ID SDK to streamline genesis state verification and improve caching behavior. The main changes move genesis state validation logic from PubSignalsVerifier into EthStateStorage, consolidate duplicate code into a utility function, and enforce stricter type requirements.

Key Changes

  • Extracted getIsGenesisStateById utility function to eliminate code duplication and improve maintainability
  • Enhanced EthStateStorage.getStateInfoByIdAndState to handle genesis states that don't exist in the smart contract by verifying if the state is a valid genesis state
  • Simplified PubSignalsVerifier.resolve by delegating genesis state logic to the storage layer
  • Made StateInfo.id a required field (was optional) to improve type safety

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/storage/eth-state-storage.test.ts New test file validating genesis state caching behavior
tests/proofs/sig-onchain.test.ts Added explicit type annotation for merklizeOpts
tests/handlers/auth.test.ts Added explicit type annotation for merklizeOpts
tests/credentials/credential-validation.test.ts Updated mock StateInfo to include required id field
src/utils/did-helper.ts Extracted getIsGenesisStateById utility function
src/storage/entities/state.ts Made id field required in StateInfo interface
src/storage/blockchain/state.ts Enhanced genesis state handling with error checking and caching; introduced defaultStateInfo constant
src/proof/verifiers/pub-signals-verifier.ts Simplified resolve method by removing genesis state logic
package.json Version bumped to 1.38.8
package-lock.json Dependency tree updates

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@vmidyllic vmidyllic merged commit fc4d306 into main Dec 30, 2025
2 checks passed
@vmidyllic vmidyllic deleted the fix/genesis-state-cache branch December 30, 2025 20:27
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.

4 participants