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

[PLA-1690] Add transaction hash to event data #143

Merged
merged 1 commit into from
Mar 29, 2024

Conversation

enjinabner
Copy link
Contributor

@enjinabner enjinabner commented Mar 28, 2024

Type

enhancement


Description

  • Added the transaction hash to the event broadcast data in Transfer.php, enhancing the data's richness and traceability.

Changes walkthrough

Relevant files
Enhancement
Transfer.php
Add Transaction Hash to Broadcast Data                                     

src/Events/Substrate/Balances/Transfer.php

  • Added 'transactionHash' to the broadcast data array, using the
    'transaction_chain_hash' property from the transaction model.
  • +1/-0     

    PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

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

    PR Description updated to latest commit (adf726a)

    Copy link

    PR Review

    ⏱️ Estimated effort to review [1-5]

    1, because the PR involves a straightforward enhancement by adding a single line of code to include additional data in an array. The change is simple and does not appear to involve complex logic or modifications.

    🧪 Relevant tests

    No

    🔍 Possible issues

    Null Safety: Ensure that the $transaction object is always expected to be non-null when accessing transaction_chain_hash. If there's a possibility for $transaction to be null, this could lead to accessing a property on a null object, causing a runtime error.

    🔒 Security concerns

    No

    Code feedback:
    relevant filesrc/Events/Substrate/Balances/Transfer.php
    suggestion      

    Consider adding a null check for $transaction before accessing transaction_chain_hash to prevent potential runtime errors. This is particularly important if there's any scenario where $transaction could be null. Example:

    'transactionHash' => $transaction ? $transaction->transaction_chain_hash : null,

    [important]

    relevant line'transactionHash' => $transaction?->transaction_chain_hash,


    ✨ Review tool usage guide:

    Overview:
    The review tool scans the PR code changes, and generates a PR review which includes several types of feedbacks, such as possible PR issues, security threats and relevant test in the PR. More feedbacks can be added by configuring the tool.

    The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.

    • When commenting, to edit configurations related to the review tool (pr_reviewer section), use the following template:
    /review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
    
    [pr_reviewer]
    some_config1=...
    some_config2=...
    

    See the review usage page for a comprehensive guide on using this tool.

    Copy link

    PR Code Suggestions

    CategorySuggestions                                                                                                                                                       
    Best practice
    Add a null check for $transaction before accessing its properties.

    Consider checking if $transaction is not null before accessing its properties. While the
    nullsafe operator (?->) is used, ensuring $transaction is not null before the whole
    assignment can improve readability and prevent potential issues if more properties are
    accessed in the future.

    src/Events/Substrate/Balances/Transfer.php [20-21]

    -'idempotencyKey' => $transaction?->idempotency_key,
    -'transactionHash' => $transaction?->transaction_chain_hash,
    +if ($transaction !== null) {
    +    $this->broadcastData = [
    +        'idempotencyKey' => $transaction->idempotency_key,
    +        'transactionHash' => $transaction->transaction_chain_hash,
    +        'from' => $from->address,
    +        'to' => $to->address,
    +        'amount' => $amount,
    +    ];
    +}
     

    ✨ Improve tool usage guide:

    Overview:
    The improve tool scans the PR code changes, and automatically generates suggestions for improving the PR code. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on a PR.

    • When commenting, to edit configurations related to the improve tool (pr_code_suggestions section), use the following template:
    /improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=...
    
    [pr_code_suggestions]
    some_config1=...
    some_config2=...
    

    See the improve usage page for a comprehensive guide on using this tool.

    @enjinabner enjinabner merged commit d252954 into master Mar 29, 2024
    7 checks passed
    @enjinabner enjinabner deleted the feature/pla-1690/add-transaction-hash-data branch March 29, 2024 02:22
    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