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

Fixes BitArray/BitVec toJson #482

Merged
merged 1 commit into from
Sep 3, 2024
Merged

Conversation

justkawal
Copy link
Collaborator

@justkawal justkawal commented Sep 3, 2024

User description

Fixes issue with toJson method.


PR Type

Bug fix


Description

  • Fixed issue toJson Issue #481 by adding support for BitArray type in the _encodeJson function.
  • Ensures BitArray objects are correctly converted to JSON using their toJson method.

Changes walkthrough 📝

Relevant files
Bug fix
to_json.dart
Add BitArray handling in JSON encoding function                   

packages/substrate_metadata/lib/utils/to_json.dart

  • Added handling for BitArray type in _encodeJson function.
  • Converts BitArray to JSON using toJson method.
  • +2/-0     

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

    @CLAassistant
    Copy link

    CLA assistant check
    Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
    You have signed the CLA already but the status is still pending? Let us recheck it.

    Copy link

    github-actions bot commented Sep 3, 2024

    PR Reviewer Guide 🔍

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

    Copy link

    github-actions bot commented Sep 3, 2024

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Possible bug
    Ensure BitArray has a toJson method to prevent runtime errors

    Ensure that the BitArray class has a toJson method implemented. If BitArray does not
    have a toJson method, this line will cause a runtime error when it is called. If the
    method is not implemented, consider adding a toJson method in the BitArray class or
    handling the serialization differently here.

    packages/substrate_metadata/lib/utils/to_json.dart [41]

     } else if (value is BitArray) {
    -  return value.toJson();
    +  return value.toJson();  // Ensure `BitArray` has this method
     
    Suggestion importance[1-10]: 9

    Why: The suggestion correctly identifies a potential runtime error if the BitArray class does not implement a toJson method. Ensuring this method exists is crucial for the code to function correctly, making this a high-priority suggestion.

    9

    Copy link

    codecov bot commented Sep 3, 2024

    Codecov Report

    Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

    Project coverage is 48.47%. Comparing base (c3d0122) to head (3de2db0).
    Report is 1 commits behind head on main.

    Files with missing lines Patch % Lines
    packages/substrate_metadata/lib/utils/to_json.dart 50.00% 1 Missing ⚠️
    Additional details and impacted files

    Impacted file tree graph

    @@           Coverage Diff           @@
    ##             main     #482   +/-   ##
    =======================================
      Coverage   48.46%   48.47%           
    =======================================
      Files         181      181           
      Lines        9575     9577    +2     
    =======================================
    + Hits         4641     4642    +1     
    - Misses       4934     4935    +1     
    Flag Coverage Δ
    polkadart 15.91% <ø> (ø)
    polkadart_cli 12.02% <ø> (ø)
    polkadart_keyring 65.24% <ø> (ø)
    polkadart_scale_codec 54.93% <ø> (ø)
    secp256k1_ecdsa 89.60% <ø> (ø)
    sr25519 85.91% <ø> (ø)
    ss58 96.87% <ø> (ø)
    substrate_bip39 56.37% <ø> (ø)
    substrate_metadata 87.69% <50.00%> (-0.04%) ⬇️

    Flags with carried forward coverage won't be shown. Click here to find out more.

    Files with missing lines Coverage Δ
    packages/substrate_metadata/lib/utils/to_json.dart 76.47% <50.00%> (-1.66%) ⬇️

    @leonardocustodio leonardocustodio changed the title Fix #481 Fixes BitArray/BitVec toJson Sep 3, 2024
    @leonardocustodio leonardocustodio merged commit 9e390b6 into main Sep 3, 2024
    13 of 14 checks passed
    @leonardocustodio leonardocustodio deleted the justkawal/fix-toJson branch September 3, 2024 22:36
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    3 participants