cosmos-sdk/types
Alex Megalokonomos 96e162b8a3
fix: null guard for tx fee amounts (#10327)
## Description

It is possible to submit a TX with a fees object containing a Coin with a nil amount. This results in a rather cryptic redacted panic response when the basic validation checks fee Coins for negative amounts.

This PR adds an additional check for nil to provide a friendlier error message.

---

### Author Checklist

*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...

- [x] 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
- [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting))
- [x] provided a link to the relevant issue or specification (note: No issue exists)
- [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules)
- [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) (note: First PR against the SDK so please comment with what needs to be done)
- [x] added a changelog entry to `CHANGELOG.md`
- [x] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [x] reviewed "Files changed" and left comments if necessary
- [x] confirmed all CI checks have passed

### Reviewers Checklist

*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)
2021-10-12 09:11:14 +00:00
..
address feat!: Add bech32 prefix to authkeeper (#9759) 2021-08-25 11:17:18 +00:00
bech32 build(deps): Use self-maintained btcutil (#10082) (#10201) 2021-09-30 13:25:44 +00:00
errors feat: Add decimal support to group module (#10035) 2021-09-23 04:32:12 +00:00
grpc Add GRPCBlockHeightHeader in clientCtx gRPC requests (#7021) 2020-08-12 14:42:10 +00:00
kv fix: check store keys length before accessing (#9639) 2021-07-08 13:29:12 +02:00
module feat!: Ensure InitGenesis returns with non-empty validator set (#9697) 2021-10-05 12:02:51 +00:00
msgservice Cleanup remains of ServiceMsg (#9236) 2021-05-07 09:31:20 +00:00
query refactor(test)!: refactor `simapp.Setup` function (#9938) 2021-08-17 00:52:06 +00:00
simulation refactor: Rename x/{mod}/legacy to x/{mod}/migrations (#9628) 2021-07-05 14:55:51 +00:00
tx fix: null guard for tx fee amounts (#10327) 2021-10-12 09:11:14 +00:00
abci.go Merge PR #4613: Only change rootmultistore hash when substore hashes change 2019-06-25 13:11:22 -04:00
abci.pb.go refactor: Implementing sigs.k8s.io YAML to remove .proto yaml annotations (#9780) 2021-09-24 14:37:34 +00:00
address.go refactor: Implementing sigs.k8s.io YAML to remove .proto yaml annotations (#9780) 2021-09-24 14:37:34 +00:00
address_race_test.go cosmos-reflection: extend to support writing by reflection clients (#8965) 2021-04-07 00:33:54 +01:00
address_test.go refactor: Implementing sigs.k8s.io YAML to remove .proto yaml annotations (#9780) 2021-09-24 14:37:34 +00:00
bench_test.go run make format (#8642) 2021-02-19 15:02:53 +00:00
codec.go Remove ServiceMsgs from ADR-031 (#9139) 2021-04-30 11:00:47 +00:00
coin.go fix: null guard for tx fee amounts (#10327) 2021-10-12 09:11:14 +00:00
coin.pb.go feat: Introduce Cosmos Scalars (#9933) 2021-09-21 09:46:29 +00:00
coin_benchmark_test.go test: fix BenchmarkCoinsAdditionIntersect panic (#9904) 2021-08-11 02:13:17 -07:00
coin_internal_test.go add sorted check for the coins sub/add fun parameter (#9240) 2021-05-05 15:55:28 +00:00
coin_test.go fix: null guard for tx fee amounts (#10327) 2021-10-12 09:11:14 +00:00
config.go Deprecate SetFullFundraiserPath in favor of SetPurpose and SetCoinType (#8629) 2021-02-22 15:14:09 +00:00
config_test.go Deprecate SetFullFundraiserPath in favor of SetPurpose and SetCoinType (#8629) 2021-02-22 15:14:09 +00:00
context.go refactor: Remove store type aliases (#10295) 2021-10-04 16:36:38 +00:00
context_test.go feat: add header hash to `Context` (#9390) 2021-05-26 08:36:42 +00:00
dec_coin.go chore: change the inconsistent error message in DecCoin.ParseDecCoin func (#9831) 2021-09-14 14:43:12 +00:00
dec_coin_test.go chore: change the inconsistent error message in DecCoin.ParseDecCoin func (#9831) 2021-09-14 14:43:12 +00:00
decimal.go fix: Handle MAX_INT_256 (#9511) 2021-06-16 14:18:02 +00:00
decimal_internal_test.go types: tests -> test suites migration (#7400) 2020-09-28 12:46:49 +02:00
decimal_test.go refactor: Implementing sigs.k8s.io YAML to remove .proto yaml annotations (#9780) 2021-09-24 14:37:34 +00:00
denom.go cli: convert coins to smallest unit registered (#7777) 2020-11-16 11:34:54 +00:00
denom_internal_test.go cli: convert coins to smallest unit registered (#7777) 2020-11-16 11:34:54 +00:00
events.go feat: add tx fee event (#9860) 2021-08-09 14:50:01 +00:00
events_test.go init: Implement ADR 032 typed events (#7564) 2020-10-28 11:02:39 +00:00
handler.go fix types.ChainAnteDecorators() panic (#5742) 2020-03-03 16:57:33 +00:00
handler_test.go refactor!: Keyring migration (#9695) 2021-09-20 12:02:15 +00:00
int.go types: fix nil pointer panic on `NewIntFromBigInt` (#9627) 2021-07-05 08:36:35 -04:00
int_internal_test.go fix: Handle MAX_INT_256 (#9511) 2021-06-16 14:18:02 +00:00
int_test.go types: fix nil pointer panic on `NewIntFromBigInt` (#9627) 2021-07-05 08:36:35 -04:00
invariant.go Merge PR #4832: print all failed invariants only 2019-08-05 14:21:44 -04:00
invariant_test.go types: tests -> test suites migration (#7405) 2020-09-29 13:29:10 +02:00
proto.go linter: enable nolintlint (#6162) 2020-05-08 08:46:12 +00:00
queryable.go Merge PR #5421: Refactor Error Handling 2019-12-27 12:57:54 -05:00
result.go refactor: Implementing sigs.k8s.io YAML to remove .proto yaml annotations (#9780) 2021-09-24 14:37:34 +00:00
result_test.go Refactor x/bank according to ADR 031 (#7520) 2020-10-13 09:05:46 +00:00
router.go Remove duplicated Module.Route calls (#7716) 2020-10-29 22:01:09 +00:00
router_test.go types: tests -> test suites migration (#7405) 2020-09-29 13:29:10 +02:00
staking.go simply default power reduction definition 2021-03-21 20:29:39 -04:00
staking_test.go on-chain power reduction param conversion basic work 2021-01-27 20:24:00 +10:00
store.go refactor: Remove store type aliases (#10295) 2021-10-04 16:36:38 +00:00
store_internal_test.go refactor: Remove store type aliases (#10295) 2021-10-04 16:36:38 +00:00
store_test.go refactor: Remove store type aliases (#10295) 2021-10-04 16:36:38 +00:00
tx_msg.go refactor!: change GetSigners return type to []sdk.AccAddress (#9915) 2021-08-13 15:34:00 +00:00
tx_msg_test.go refactor!: change GetSigners return type to []sdk.AccAddress (#9915) 2021-08-13 15:34:00 +00:00
uint.go various linter fixes (#8666) 2021-02-23 08:46:01 +00:00
uint_internal_test.go types: tests -> test suites migration (#7405) 2020-09-29 13:29:10 +02:00
uint_test.go types: use (*math/big.Int).BitLen() == 0 to check if value is 0 (#8580) 2021-02-15 10:53:10 +00:00
utils.go tendermint: update to rc3 (#6892) 2020-08-14 13:58:53 -04:00
utils_test.go types: tests -> test suites migration (#7405) 2020-09-29 13:29:10 +02:00