leonardocustodio / polkadart

Polkadart provides developers the ability to query a node and interact with the Polkadot based chains using Dart.
https://polkadart.dev
Apache License 2.0
39 stars 16 forks source link

Fixes BitArray/BitVec toJson #482

Closed justkawal closed 2 months ago

justkawal commented 2 months ago

User description

Fixes issue with toJson method.


PR Type

Bug fix


Description


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 commented 2 months ago

    CLA assistant check
    All committers have signed the CLA.

    github-actions[bot] commented 2 months ago

    PR Reviewer Guide 🔍

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ No key issues to review
    github-actions[bot] commented 2 months ago

    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]](https://github.com/leonardocustodio/polkadart/pull/482/files#diff-10ae6078673ba818aceee13b0893c519f9eaae49db34469bb61276346542d8d3R41-R41) ```diff } 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
    codecov[bot] commented 2 months ago

    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 4 commits behind head on main.

    Files with missing lines Patch % Lines
    packages/substrate_metadata/lib/utils/to_json.dart 50.00% 1 Missing :warning:
    Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/leonardocustodio/polkadart/pull/482/graphs/tree.svg?width=650&height=150&src=pr&token=HG3K4LW5UN&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Leonardo+Custodio)](https://app.codecov.io/gh/leonardocustodio/polkadart/pull/482?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Leonardo+Custodio) ```diff @@ 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](https://app.codecov.io/gh/leonardocustodio/polkadart/pull/482/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Leonardo+Custodio) | Coverage Δ | | |---|---|---| | [polkadart](https://app.codecov.io/gh/leonardocustodio/polkadart/pull/482/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Leonardo+Custodio) | `15.91% <ø> (ø)` | | | [polkadart_cli](https://app.codecov.io/gh/leonardocustodio/polkadart/pull/482/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Leonardo+Custodio) | `12.02% <ø> (ø)` | | | [polkadart_keyring](https://app.codecov.io/gh/leonardocustodio/polkadart/pull/482/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Leonardo+Custodio) | `65.24% <ø> (ø)` | | | [polkadart_scale_codec](https://app.codecov.io/gh/leonardocustodio/polkadart/pull/482/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Leonardo+Custodio) | `54.93% <ø> (ø)` | | | [secp256k1_ecdsa](https://app.codecov.io/gh/leonardocustodio/polkadart/pull/482/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Leonardo+Custodio) | `89.60% <ø> (ø)` | | | [sr25519](https://app.codecov.io/gh/leonardocustodio/polkadart/pull/482/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Leonardo+Custodio) | `85.91% <ø> (ø)` | | | [ss58](https://app.codecov.io/gh/leonardocustodio/polkadart/pull/482/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Leonardo+Custodio) | `96.87% <ø> (ø)` | | | [substrate_bip39](https://app.codecov.io/gh/leonardocustodio/polkadart/pull/482/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Leonardo+Custodio) | `56.37% <ø> (ø)` | | | [substrate_metadata](https://app.codecov.io/gh/leonardocustodio/polkadart/pull/482/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Leonardo+Custodio) | `87.69% <50.00%> (-0.04%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Leonardo+Custodio#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files with missing lines](https://app.codecov.io/gh/leonardocustodio/polkadart/pull/482?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Leonardo+Custodio) | Coverage Δ | | |---|---|---| | [packages/substrate\_metadata/lib/utils/to\_json.dart](https://app.codecov.io/gh/leonardocustodio/polkadart/pull/482?src=pr&el=tree&filepath=packages%2Fsubstrate_metadata%2Flib%2Futils%2Fto_json.dart&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Leonardo+Custodio#diff-cGFja2FnZXMvc3Vic3RyYXRlX21ldGFkYXRhL2xpYi91dGlscy90b19qc29uLmRhcnQ=) | `76.47% <50.00%> (-1.66%)` | :arrow_down: |