Skip to content

Conversation

@yug49
Copy link

@yug49 yug49 commented Dec 8, 2025

Problem
When loading a Midnight contract, users were required to manually input a "Private State ID" field. This created unnecessary friction.

Solution
Auto-generate the privateStateId deterministically from contractAddress + walletAddress at transaction execution time.

// Deterministic ID generation
const privateStateId = generatePrivateStateId(contractAddress, walletAddress);
// Output: "midnight_<first12chars_of_sha256_hash>"

Changes

  • Removed privateStateId form field from getContractDefinitionInputs()
  • Made privateStateId optional in MidnightContractArtifacts interface
  • Added generatePrivateStateId() utility using SHA-256 hash
  • Auto-generate ID in EOA execution strategy when wallet is connected
  • Updated all artifact validation paths (ZIP upload, URL loading, trimmed ZIP)
  • Removed privateStateId from exported app artifacts (generated at runtime)

Testing

  • Added unit tests for generatePrivateStateId() utility
  • Updated existing tests to reflect optional privateStateId
  • All 459 tests pass

Closes #263

@yug49 yug49 requested a review from a team as a code owner December 8, 2025 15:10
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.

feat(adapter-midnight): Auto-generate Private State ID for improved UX

1 participant