OpenZeppelin / OpenZeppelin/ui-builder

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

Open
#263 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement midnight
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
  1. Reduced cognitive load - Users don't need to understand this implementation detail
  2. Fewer errors - No typos, no accidentally reusing IDs
  3. Smoother onboarding - One less required field
  4. Automatic state restoration - Same user + same contract = same private state (deterministic)
Implementation Notes
  • Remove privateStateId from getContractDefinitionInputs() 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 from getContractDefinitionInputs()
  • 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.