OpenZeppelin / OpenZeppelin/ui-builder
feat(adapter-midnight): Auto-generate Private State ID for improved UX
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 48
- Forks
- 23
- Avg merge
- 3h 1m
- Merged PRs (30d)
- 10
Description
Summary
When loading a Midnight contract, users are currently required to manually input a Private State ID - a field that most users don't understand and shouldn't need to worry about. This creates unnecessary friction in the onboarding flow.
Problem
- Users ask: "What should I put in the Private State ID field?"
- The field is an implementation detail that doesn't provide value to end users
- Manual input increases cognitive load and potential for errors
Proposed Solution
Auto-generate the Private State ID deterministically based on the contract address and wallet address:
// Generate a deterministic ID from contract + wallet
const privateStateId = generateDeterministicId(contractAddress, walletAddress);
// e.g., hash or concatenation like: `${contractAddress}_${walletAddress.slice(-8)}`
Benefits
- Reduced cognitive load - Users don't need to understand this implementation detail
- Fewer errors - No typos, no accidentally reusing IDs
- Smoother onboarding - One less required field
- Automatic state restoration - Same user + same contract = same private state (deterministic)
Implementation Notes
- Remove
privateStateIdfromgetContractDefinitionInputs()in the Midnight adapter - Generate the ID internally when loading/interacting with contracts
- The ID should be deterministic so private state is automatically restored across sessions
- Consider displaying the generated ID in the contract info panel for transparency
Files to Modify
packages/adapter-midnight/src/adapter.ts- Remove field fromgetContractDefinitionInputs()- Transaction/contract loading logic - Add deterministic ID generation
Context
This improvement was identified from user feedback asking what to put in the Private State ID field.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in packages/adapter-midnight/src/adapter.ts at getContractDefinitionInputs(), then trace the transaction and contract-loading logic that currently uses privateStateId. Define how the contract and wallet addresses produce a stable ID and where it is generated. Done means users no longer enter the field and the same contract-wallet pair restores the same private state.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- blockchain
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100