Skip to content

Conversation

@ertemann
Copy link
Contributor

@ertemann ertemann commented Dec 2, 2025

This PR adds comprehensive unit test coverage, implements a transaction confirmation system, and includes significant code quality improvements across the xion.js monorepo.

Type System Improvements

  • Type Generator: Added script to generate TypeScript types from the Account Abstraction API OpenAPI schema
    • Types are now generated from a single source of truth (AA API schema)
    • Supports testnet, mainnet, and local environments
    • Types centralized in @burnt-labs/signers package for consistency
    • All packages now import types from signers/types instead of maintaining duplicate definitions

Transaction Confirmation System

  • Added optional transaction confirmation polling for account creation
  • Graceful fallback behavior: continues even if confirmation fails or RPC is unavailable
  • Memory-safe timeout cleanup
  • Integrated into createEthWalletAccount() and createSecp256k1Account() functions

Comprehensive Unit Test Coverage

  • 47+ new test files across all core packages:
    • @burnt-labs/test-utils: Shared testing utilities with mocks, builders, and vitest setup
    • @burnt-labs/account-management: 24 test files covering account discovery, grant management, treasury strategies, and orchestrator flows
    • @burnt-labs/signers: 10 test files covering crypto utilities and signer implementations
    • @burnt-labs/abstraxion-core: 13 test files covering authentication, caching, grants, and API clients

Code Quality Improvements

  • Error Handling: Custom error classes (FeeGrantValidationError, InvalidContractGrantError) with detailed error codes
  • Type Safety: Added type guards throughout grant utilities, account management, and core packages
  • Validation: Improved input validation and error messages across grant utilities and account management
  • React Components: Better default context values and error handling in AbstraxionProvider
  • Crypto Utilities: Enhanced signature verification and normalization utilities

Demo App Updates

  • Updated Turnkey hooks (useTurnkeyRawAPI, useTurnkeyViem) for better testing support and consistency

Testing Infrastructure

  • Centralized test utilities package eliminates duplicate mocks
  • Consistent vitest configuration across all packages
  • Shared webauthn mocks and test helpers

- Create new @burnt-labs/test-utils package with shared test utilities, builders, and helpers
- Add vitest configuration for all packages (abstraxion-core, abstraxion, account-management, signers)
- Add integration test setup configuration
- Add mock infrastructure for @burnt-labs/signers and webauthn
- Update CI workflows for vitest-based testing
- Remove deprecated Jest/Babel configs
- Add test setup files
- Add script to generate types from account-abstraction-api
- Create api.ts and account.ts type definitions in signers package
- Remove old api/types.ts file
- Add crypto validation utilities (hex, authenticator, normalize)
- Add signature verification utilities
- Update crypto module exports
- Update tsup config for new type exports
- @burnt-labs/test-utils: Add shared testing utilities including mock strategies,
  GrantBuilder, vitest setup with webauthn mocks, and common test helpers

- @burnt-labs/account-management: Add 24 unit test files covering:
  * Account discovery strategies (composite, empty, numia, rpc, subquery)
  * Grant construction and discovery
  * Treasury strategies (composite, daodao, direct-query)
  * Grant utilities (authz, feegrant, format-permissions, contract-validation)
  * Connection orchestrator flows (account connection, grant creation, redirect, session restoration)
  * Account state management
  * Authenticator utilities
  Includes testing utilities and vitest configuration updates

- @burnt-labs/signers: Add 10 unit test files covering:
  * Crypto utilities (address, authenticator validation, normalize, salt, signature, verify)
  * Signer implementations (direct-signer, eth-signer)
  * API types and circular dependency checks
  Includes testing utilities and vitest configuration

- @burnt-labs/abstraxion-core: Add 13 unit test files covering:
  * AbstraxionAuth and authentication flows
  * Cache management and utilities
  * Grant utilities and validation
  * GranteeSignerClient
  * API clients (createAccount, client)
  * Connector registry and external signer connector
  * Account parser utilities
  Includes vitest configuration with shared test-utils setup

All packages now use shared test-utils for consistent mocking and test setup.
Removed legacy mock files in favor of centralized test-utils package.
Update Turnkey integration hooks to align with improved testing infrastructure:

- useTurnkeyRawAPI: Refactor for better testability and error handling
- useTurnkeyViem: Improve implementation consistency and testing support

These changes ensure the demo app works seamlessly with the updated test
utilities and provides a better reference implementation for testing patterns.
…or handling and validation

Enhance grant-related utilities with improved error handling, type safety, and validation:

- feegrant.ts: Add FeeGrantValidationError class with detailed error codes
  * Return FeeGrantValidationResult type instead of boolean for better error context
  * Add input validation before making HTTP requests
  * Improve error messages with HTTP status codes and network error details

- authz.ts: Add InvalidContractGrantError for better error handling
  * Improve contract grant validation with null/undefined checks
  * Add case-insensitive address comparison (bech32 addresses)
  * Better error messages for malformed contract grant data

- format-permissions.ts: Refactor for better maintainability and type safety
  * Improve code structure and readability
  * Better handling of edge cases

- grant discovery and strategies: Improve error handling and validation
  * Better error propagation in treasury strategies
  * Improved validation in grant creation flow

- grant comparison utilities: Add type guards for better type safety
  * Add isHumanContractExecAuth, isSendAuthorization, isStakeAuthorization, isGenericAuthorization
  * Improve type safety in grant comparison logic

These improvements were made alongside unit test development to ensure robust
error handling and better developer experience.
…agement

Enhance account management core functionality with better error handling and type safety:

- Account discovery strategies: Improve error handling and validation
  * Better error propagation in composite, numia, rpc, and subquery strategies
  * Improved input validation

- Account state management: Enhance state handling
  * Better state transitions and error handling

- Authenticators: Improve type definitions and utilities
  * Better type safety in authenticator handling

- Orchestrator: Minor improvements for consistency

- Type definitions: Enhance type safety across account management types
  * Improve authenticator, indexer, and treasury type definitions

These improvements ensure better reliability and maintainability of account
discovery and management flows.
Enhance abstraxion-core with better type guards and error handling:

- SignArbSecp256k1HdWallet: Add comprehensive type guards
  * Add QuickCrypto type for React Native compatibility
  * Add type guards for serialization root, encrypted serialization, and decrypted documents
  * Improve type safety throughout wallet serialization/deserialization
  * Remove unused assert import

- AbstraxionAuth: Minor improvements for consistency

- Connectors: Improve connector type definitions and error handling
  * Better type safety in ExternalSignerConnector
  * Enhanced connector type definitions

- Types: Add missing type exports

These improvements ensure better type safety and error handling throughout
the core authentication and signing functionality.
…ling

Enhance React components with better error handling and default values:

- AbstraxionContext: Add default context value
  * Provide default context with proper error messages for improper usage
  * All functions throw descriptive errors if called before provider mounts
  * Better initialization error handling (errors handled by controller state machine)

- SignerController: Minor improvements for consistency

- useAbstraxionClient: Improve hook implementation

- Export improvements: Add missing exports

- Vitest config: Update integration test configuration

These improvements ensure better developer experience and error handling
in React components.
Enhance signers package with better error handling and type safety:

- Crypto utilities: Improve signature verification and signing
  * Better error handling in signature operations
  * Improved type safety

- Signer implementations: Enhance direct-signer and passkey-signer
  * Better error handling and validation
  * Improved consistency across signer types

- Signer factory: Improve factory implementation

These improvements ensure better reliability and consistency in signing operations.
Update package.json files and pnpm-lock.yaml with latest dependency versions
aligned with testing infrastructure improvements.
@changeset-bot
Copy link

changeset-bot bot commented Dec 2, 2025

⚠️ No Changeset found

Latest commit: 4ce1fda

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@cloudflare-workers-and-pages
Copy link

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
xion-demo-app 4ce1fda Dec 02 2025, 05:24 PM

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.

2 participants