Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Action Hash Type Safety #25

Open
Soushi888 opened this issue Oct 28, 2024 · 0 comments
Open

Enhance Action Hash Type Safety #25

Soushi888 opened this issue Oct 28, 2024 · 0 comments

Comments

@Soushi888
Copy link
Collaborator

Soushi888 commented Oct 28, 2024

Description

This issue aims to improve the type safety of action hashes in our Holochain application. We'll focus on both the host code written in Rust and the guest code written in TypeScript. Our primary goal is to prevent bugs caused by sending incorrect action hashes to zome functions.

Proposed Changes

For the Rust Host Code:

  1. Create a custom ActionHash type
  2. Implement discriminated unions for different action hash entities
  3. Add runtime checks for valid action hash types
  4. Provide utility functions for working with action hashes

For the TypeScript Guest Code:

  1. Create a corresponding ActionHash type
  2. Implement type guards for different action hash entities
  3. Add runtime checks for valid action hash types
  4. Provide utility functions for working with action hashes

Implementation Steps

Rust Host Code

  1. Define a custom ActionHash type
  2. Implement a discriminated union for different action hash entities
  3. Create utility functions for parsing and validating action hashes
  4. Modify existing code to use the new ActionHash type
  5. Add runtime checks for valid action hash types

TypeScript Guest Code

  1. Define a corresponding ActionHash type
  2. Implement type guards for different action hash entities
  3. Create utility functions for working with action hashes
  4. Modify existing code to use the new ActionHash type
  5. Add runtime checks for valid action hash types

Benefits

  • Improved type safety for action hashes
  • Reduced likelihood of bugs caused by incorrect action hash types
  • Better error handling and reporting
  • Enhanced maintainability of the codebase

Acceptance Criteria

  • Custom ActionHash type implemented in Rust host code
  • Discriminated union for different action hash entities in Rust
  • Runtime checks for valid action hash types in Rust
  • Corresponding ActionHash type implemented in TypeScript guest code
  • Type guards for different action hash entities in TypeScript
  • Runtime checks for valid action hash types in TypeScript
  • Utility functions for working with action hashes in both languages
  • Existing code modified to use new ActionHash type
  • Comprehensive tests covering various action hash scenarios
@Soushi888 Soushi888 changed the title Better type checking for action hashs Enhance Action Hash Type Safety Oct 28, 2024
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

No branches or pull requests

1 participant