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

Check wallet daemon approval #99

Merged
merged 1 commit into from
Sep 23, 2024

Conversation

enjinabner
Copy link
Contributor

@enjinabner enjinabner commented Sep 22, 2024

PR Type

enhancement


Description

  • Enhanced the batch processing logic by introducing a check for collection approval using the CollectionService.
  • Modified the logic for determining the source in transfer parameters, utilizing a match expression for better clarity and functionality.
  • Added a new import for CollectionService to support the new approval check functionality.

Changes walkthrough 📝

Relevant files
Enhancement
BatchProcess.php
Enhance batch processing with collection approval check   

src/Commands/BatchProcess.php

  • Added import for CollectionService.
  • Introduced a new variable daemon to store the daemon public key.
  • Modified logic for determining the source in transfer parameters using
    a match expression.
  • Included a check for collection approval using CollectionService.
  • +7/-3     

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    @enjinabner enjinabner added the enhancement New feature or request label Sep 22, 2024
    @enjinabner enjinabner self-assigned this Sep 22, 2024
    Copy link

    PR Reviewer Guide 🔍

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Key issues to review

    Code Clarity
    The match expression in line 164-168 could be simplified or better documented for clarity. The logic determining the source based on multiple conditions might be confusing without proper comments or simpler structure.

    Copy link

    github-actions bot commented Sep 22, 2024

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Performance
    Improve performance by using dependency injection for CollectionService

    Replace the resolve function with direct dependency injection for CollectionService
    in the method signature to improve performance and maintainability. Using dependency
    injection is more efficient than resolving services in the body of methods.

    src/Commands/BatchProcess.php [164-168]

     'source' => match(true) {
    -    resolve(CollectionService::class)->approvalExistsInCollection($collectionId, $daemon) => $daemon,
    +    $this->collectionService->approvalExistsInCollection($collectionId, $daemon) => $daemon,
         $daemon !== $claim->collection->owner->public_key => $claim->collection->owner->public_key,
         default => null
     },
     
    Suggestion importance[1-10]: 8

    Why: The suggestion to use dependency injection instead of the resolve function improves performance and maintainability by making the dependency explicit and reducing runtime overhead.

    8
    Possible bug
    Add null checks to prevent potential runtime errors in the match expression

    Ensure that the match expression handles potential null values gracefully to avoid
    runtime errors. Specifically, add a condition to check if the
    approvalExistsInCollection method returns a non-null value before assigning it.

    src/Commands/BatchProcess.php [164-168]

     'source' => match(true) {
    -    resolve(CollectionService::class)->approvalExistsInCollection($collectionId, $daemon) => $daemon,
    +    $this->collectionService->approvalExistsInCollection($collectionId, $daemon) && $daemon => $daemon,
         $daemon !== $claim->collection->owner->public_key => $claim->collection->owner->public_key,
         default => null
     },
     
    Suggestion importance[1-10]: 7

    Why: Adding null checks in the match expression enhances robustness by preventing potential runtime errors, although the original code already handles null values with the default case.

    7

    @enjinabner enjinabner requested a review from pawell67 September 22, 2024 22:17
    @enjinabner enjinabner marked this pull request as ready for review September 22, 2024 22:17
    @enjinabner enjinabner merged commit 5521d60 into master Sep 23, 2024
    3 of 5 checks passed
    @enjinabner enjinabner deleted the feature/pla-2005/batch-transfer-sender branch September 23, 2024 05:52
    enjinabner added a commit that referenced this pull request Sep 23, 2024
    enjinabner added a commit that referenced this pull request Oct 9, 2024
    enjinabner added a commit that referenced this pull request Oct 9, 2024
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    Development

    Successfully merging this pull request may close these issues.

    2 participants