feat(storage): add Account Alias Storage plugin#59
Open
Conversation
Complete feature specification for universal account address aliasing plugin for @openzeppelin/ui-storage package. Includes: - Feature spec with 10 user stories and 31 functional requirements - Implementation plan with constitution check - Data model and Dexie schema definition - TypeScript API contracts - Research decisions for architecture patterns - Quickstart guide for integration - 69 implementation tasks organized by phase - Quality checklists for spec review
Adds optional networkId field matching NetworkConfig.id pattern for multi-network alias support. Changes include: - Composite uniqueness on (address, networkId) instead of address only - New methods: getByAddressAndNetwork(), findByAddress() - NetworkId format aligns with existing patterns (e.g., ethereum-mainnet) - ENS/smart account detection remains out of scope (adapter responsibility)
Implement Phase 1 (Setup) and Phase 2 (Foundational) for the account alias storage plugin: - Add plugin directory structure at plugins/account-alias/ - Create AliasRecord, AliasInput, AliasUpdate types with networkId support - Create AliasStorageOptions with configurable duplicate modes - Create AliasStorageError class with typed error codes - Create ALIAS_SCHEMA with compound [address+networkId] index - Add test setup with fake-indexeddb mocking
Adds the Phase 3 MVP implementation of the account alias storage plugin: - AliasStorage class with save, update, get, and lookup methods - Multi-network support using compound index with sentinel for global aliases - Configurable duplicate handling (strict, warn, allow modes) - Validation for alias length and empty values - Factory function createAliasStorage() - Comprehensive test suite with 50 test cases
Add comprehensive test coverage for AliasStorage delete and list operations including delete, deleteByAddress, deleteByAlias, clear, getAll, count, hasAlias, and aliasExists methods.
Implements Phase 5 (React Hook Integration) of the account alias storage plugin with live reactive queries and CRUD operations: - createUseAliasStorage hook factory with useLiveQuery integration - Full CRUD operations (save, update, remove, clear) - Lookup methods (getByAddress, getByAlias, resolveAlias, etc.) - File I/O (exportAsFile, importFromFile) - Error handling with onError callback support - 28 comprehensive tests covering all functionality
Implements Phase 6 of account alias storage plugin: - Add exportJson() with optional ID filtering - Add importJson() with comprehensive JSON schema validation - Add bulkSave() and bulkDelete() for batch operations - Add 28 new tests covering all import/export functionality
- Add plugin exports to main package index - Add comprehensive README section for Account Alias plugin - Create changeset for minor version bump - Mark all Phase 7 tasks as complete
There was a problem hiding this comment.
Pull request overview
This PR adds a new Account Alias Storage plugin to @openzeppelin/ui-storage, providing a typed, multi-network alias store for blockchain addresses with React hook integration and import/export support.
Changes:
- Introduces the
AliasStorageclass, Dexie schema helpers, error types, and configuration options for address-to-alias mappings, including multi-network support and duplicate-mode handling. - Adds a React hook factory (
createUseAliasStorage) and comprehensive Vitest suites for both the core storage class and the React integration, plus test infrastructure based onfake-indexeddbandjsdom. - Updates storage package exports, README documentation, and changeset metadata to surface the plugin as a first-class part of
@openzeppelin/ui-storage.
Reviewed changes
Copilot reviewed 24 out of 25 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
specs/002-account-alias-storage/tasks.md |
Task breakdown for designing and implementing the alias storage plugin, tests, hooks, and documentation. |
specs/002-account-alias-storage/spec.md |
Functional and non-functional spec for the alias plugin, including user stories, requirements, error codes, logging, React behavior, and import/export schema. |
specs/002-account-alias-storage/research.md |
Design decisions and rationale for architecture, schema, duplicate detection, React integration, and network handling. |
specs/002-account-alias-storage/quickstart.md |
Feature-specific quickstart guide showing how to create the DB, use AliasStorage, and integrate with React. |
specs/002-account-alias-storage/plan.md |
Implementation plan describing structure, constraints, and constitution checks for the feature. |
specs/002-account-alias-storage/data-model.md |
Data model definition for AliasRecord, options, Dexie schema, validation rules, error codes, and query patterns. |
specs/002-account-alias-storage/contracts/types.ts |
Type-level API contract for alias types, options, import/export formats, and error codes at the spec level. |
specs/002-account-alias-storage/contracts/alias-storage-api.ts |
Spec API contract for AliasStorage, factory, and React hook return type and options. |
specs/002-account-alias-storage/contracts/README.md |
Brief index of the spec contracts for the alias plugin. |
specs/002-account-alias-storage/checklists/requirements.md |
High-level requirements completeness checklist for the spec. |
specs/002-account-alias-storage/checklists/full-spec.md |
Detailed checklist validating that the spec covers scenarios, edge cases, NFRs, dependencies, and API quality. |
pnpm-lock.yaml |
Adds testing-related dependencies (@testing-library/react, jsdom, updated @babel/runtime, etc.) and locks their resolved versions. |
packages/storage/src/plugins/account-alias/types.ts |
Runtime alias types (AliasRecord, AliasInput, AliasUpdate), configuration (AliasStorageOptions, DuplicateMode, LogLevel), import/export types, and DEFAULT_OPTIONS. |
packages/storage/src/plugins/account-alias/schema.ts |
Dexie schema constants and helpers (ALIAS_SCHEMA, createAliasSchema, getAliasSchema) for the alias table. |
packages/storage/src/plugins/account-alias/react.ts |
React hook factory createUseAliasStorage, hook return types, error-handling wrapper, file import/export helpers, and getAliasStorageInstance. |
packages/storage/src/plugins/account-alias/index.ts |
Public plugin entry point re-exporting alias types, errors, schema helpers, storage factory, and React hooks. |
packages/storage/src/plugins/account-alias/errors.ts |
Alias-specific error codes, human-readable messages, AliasStorageError class, and helper constructors for common error cases. |
packages/storage/src/plugins/account-alias/__tests__/setup.ts |
Test utilities for alias plugin, including fake-indexeddb setup, logger mocking, and Dexie test DB lifecycle helpers. |
packages/storage/src/plugins/account-alias/__tests__/react.test.tsx |
Vitest+Testing Library tests for the React hook: creation, live updates, CRUD, error handling, file I/O, and multi-instance behavior. |
packages/storage/src/plugins/account-alias/__tests__/AliasStorage.test.ts |
Comprehensive tests for AliasStorage covering CRUD, config, lookups, multi-network behavior, delete/list, bulk ops, and import/export. |
packages/storage/src/plugins/account-alias/AliasStorage.ts |
Core AliasStorage implementation with validation, duplicate handling, multi-network support, CRUD, list/count, bulk ops, import/export, quota handling, and logging. |
packages/storage/src/index.ts |
Wires the alias plugin into the root storage package exports (types, constants, storage class, factories, errors, and React hooks). |
packages/storage/package.json |
Adds dev-time dependencies needed for the new tests (@testing-library/react, @types/react, jsdom). |
packages/storage/README.md |
Extends package README with an “Account Alias Plugin” section explaining setup, usage, React integration, import/export, and error handling. |
.changeset/account-alias-storage-plugin.md |
Changeset entry declaring a minor release for @openzeppelin/ui-storage and summarizing the new plugin’s capabilities. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Fix importFromFile signature to accept File parameter (spec.md, contracts) - Update Bulk Operations docs to reflect partial-success semantics - Clarify schema.ts comment: compound index (not unique), uniqueness at app layer - Remove unused ADDRESS_NOT_FOUND error code - Wrap bulkSave in Dexie transaction for atomicity - Update test to expect transaction rollback behavior
- Refactor createUseAliasStorage to delegate to createRepositoryHook - Use createJsonFileIO for file import/export operations - Update test expectations for generic error messages from createCrudHook - Update spec.md and contracts to document the implementation approach This reduces code duplication and ensures the alias hooks are consistent with other storage hooks in the package.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 24 out of 25 changed files in this pull request and generated 3 comments.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add the Account Alias Storage plugin to
@openzeppelin/ui-storage, providing address-to-alias mapping for blockchain addresses.AliasStorageclass with full CRUD operations for address aliasesnetworkIdmatchingNetworkConfig.id)createUseAliasStoragewith live reactive updates usinguseLiveQueryAliasStorageError)Key Features
save,update,get,deleteoperationsgetByAddress,getByAddressAndNetwork,findByAddressgetByAlias,findByAlias,resolveAlias,resolveAddressbulkSave,bulkDelete,exportJson,importJsonExample Usage
Test plan