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

fix: add missing nil checks #1299

Merged
merged 8 commits into from
Mar 26, 2024
Merged

fix: add missing nil checks #1299

merged 8 commits into from
Mar 26, 2024

Conversation

170210
Copy link
Contributor

@170210 170210 commented Mar 26, 2024

Description

There are multiple functions in the codebase missing nil checks and this PR fixed them.

This pr cherry-pick the following upstream prs

Motivation and context

How has this been tested?

Screenshots (if appropriate):

Checklist:

  • I followed the contributing guidelines and code of conduct.
  • I have added a relevant changelog to CHANGELOG.md
  • I have added tests to cover my changes.
  • I have updated the documentation accordingly.
  • I have updated API documentation client/docs/swagger-ui/swagger.yaml

odeke-em and others added 4 commits March 26, 2024 14:58
This change fixes a scenario in which Coin.Validate() would panic when given a nil Amount.
While here, added a fuzz test along with unit/regression tests.

Fixes #15690
Signed-off-by: 170210 <j170210@icloud.com>
Signed-off-by: 170210 <j170210@icloud.com>
…#12903)

Closes: #12902

---

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 3 committers have signed the CLA.

✅ 170210
❌ odeke-em
❌ yun-yeo
You have signed the CLA already but the status is still pending? Let us recheck it.

Signed-off-by: 170210 <j170210@icloud.com>
@170210 170210 requested a review from ulbqb March 26, 2024 06:10
Signed-off-by: 170210 <j170210@icloud.com>
@170210 170210 marked this pull request as ready for review March 26, 2024 06:15
@170210 170210 self-assigned this Mar 26, 2024
@170210 170210 added C:codec and removed C:codec labels Mar 26, 2024
jaeseung-bae
jaeseung-bae previously approved these changes Mar 26, 2024
tkxkd0159
tkxkd0159 previously approved these changes Mar 26, 2024
@170210 170210 dismissed stale reviews from tkxkd0159 and jaeseung-bae via f42103d March 26, 2024 09:24
@170210 170210 added the A: bug Something isn't working label Mar 26, 2024
Copy link

codecov bot commented Mar 26, 2024

Codecov Report

Attention: Patch coverage is 71.42857% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 70.43%. Comparing base (b1c09cf) to head (f42103d).

❗ Current head f42103d differs from pull request most recent head 3bea915. Consider uploading reports for the commit 3bea915 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1299      +/-   ##
==========================================
- Coverage   70.43%   70.43%   -0.01%     
==========================================
  Files         643      643              
  Lines       54720    54724       +4     
==========================================
+ Hits        38542    38544       +2     
- Misses      14008    14009       +1     
- Partials     2170     2171       +1     
Files Coverage Δ
types/coin.go 94.72% <100.00%> (+0.02%) ⬆️
types/dec_coin.go 78.24% <60.00%> (-0.52%) ⬇️

... and 1 file with indirect coverage changes

jaeseung-bae
jaeseung-bae previously approved these changes Mar 26, 2024
0Tech
0Tech previously approved these changes Mar 26, 2024
@170210 170210 merged commit a7a39e5 into Finschia:main Mar 26, 2024
32 of 33 checks passed
mergify bot pushed a commit that referenced this pull request Mar 26, 2024
* fix: types: ensure .Amount is non-nil in Coin.Validate() (#15691)

This change fixes a scenario in which Coin.Validate() would panic when given a nil Amount.
While here, added a fuzz test along with unit/regression tests.

Fixes #15690

* fix: change math.NewInt to sdk.NewInt

Signed-off-by: 170210 <j170210@icloud.com>

* fix: change to finschia-sdk

Signed-off-by: 170210 <j170210@icloud.com>

* fix: prevent nil DecCoin creation when converting Coins to DecCoins (#12903)

Closes: #12902

---

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)

* chore: update CHANGELOG.md

Signed-off-by: 170210 <j170210@icloud.com>

* fix: fix lint

Signed-off-by: 170210 <j170210@icloud.com>

---------

Signed-off-by: 170210 <j170210@icloud.com>
Co-authored-by: Emmanuel T Odeke <emmanuel@orijtech.com>
Co-authored-by: yys <sw.yunsuk@gmail.com>
(cherry picked from commit a7a39e5)

# Conflicts:
#	CHANGELOG.md
0Tech added a commit that referenced this pull request Mar 29, 2024
* fix: add missing nil checks (#1299)

* fix: types: ensure .Amount is non-nil in Coin.Validate() (#15691)

This change fixes a scenario in which Coin.Validate() would panic when given a nil Amount.
While here, added a fuzz test along with unit/regression tests.

Fixes #15690

* fix: change math.NewInt to sdk.NewInt

Signed-off-by: 170210 <j170210@icloud.com>

* fix: change to finschia-sdk

Signed-off-by: 170210 <j170210@icloud.com>

* fix: prevent nil DecCoin creation when converting Coins to DecCoins (#12903)

Closes: #12902

---

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)

* chore: update CHANGELOG.md

Signed-off-by: 170210 <j170210@icloud.com>

* fix: fix lint

Signed-off-by: 170210 <j170210@icloud.com>

---------

Signed-off-by: 170210 <j170210@icloud.com>
Co-authored-by: Emmanuel T Odeke <emmanuel@orijtech.com>
Co-authored-by: yys <sw.yunsuk@gmail.com>
(cherry picked from commit a7a39e5)

# Conflicts:
#	CHANGELOG.md

* Update CHANGELOG.md

---------

Co-authored-by: 170210 <85928898+170210@users.noreply.github.com>
Co-authored-by: Youngtaek Yoon <noreply@yoon.mailer.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: bug Something isn't working backport/v0.48.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants