Skip to content

Commit

Permalink
fix: address generation of the empty coins in x/foundation (backport #…
Browse files Browse the repository at this point in the history
…952) (#1072)

* Revert "fix: revert #952 (#984)"

This reverts commit ea50f75.

* Update CHANGELOG.md
  • Loading branch information
0Tech authored Aug 16, 2023
1 parent 2d437b0 commit 6bf0b53
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Improvements
* (third_party/proto) [\#1037](https://github.com/Finschia/finschia-sdk/pull/1037) change the proof.proto path to third_party/proto/confio
* (ostracon) [\#1057](https://github.com/Finschia/finschia-sdk/pull/1057) Bump up Ostracon from to v1.1.1
* (x/foundation) [\#1072](https://github.com/Finschia/finschia-sdk/pull/1072) Address generation of the empty coins in x/foundation (backport #952)

### Bug Fixes
* (ledger) [\#1040](https://github.com/Finschia/finschia-sdk/pull/1040) fix a bug(unable to connect nano S plus ledger on ubuntu)
Expand Down
2 changes: 1 addition & 1 deletion client/grpc/tmservice/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (s IntegrationTestSuite) TestQueryBlockResultsByHeight() {
s.Require().Equal(0, len(txResult))

beginBlock := blockResultsRes.GetResBeginBlock()
s.Require().Equal(11, len(beginBlock.Events)) // coinbase event (6) + transfer mintModule to feeCollectorName(5)
s.Require().Equal(7, len(beginBlock.Events)) // coinbase event (6) + transfer mintModule to feeCollectorName(5) - foundation abci (4)

endBlock := blockResultsRes.GetResEndBlock()
s.Require().Equal(0, len(endBlock.Events))
Expand Down
6 changes: 6 additions & 0 deletions x/foundation/keeper/internal/treasury.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@ import (
func (k Keeper) CollectFoundationTax(ctx sdk.Context) error {
feeCollector := k.authKeeper.GetModuleAccount(ctx, k.feeCollectorName).GetAddress()
feesCollectedInt := k.bankKeeper.GetAllBalances(ctx, feeCollector)
if feesCollectedInt.Empty() {
return nil
}
feesCollected := sdk.NewDecCoinsFromCoins(feesCollectedInt...)

// calculate the tax
taxRatio := k.GetFoundationTax(ctx)
tax, _ := feesCollected.MulDecTruncate(taxRatio).TruncateDecimal()
if tax.Empty() {
return nil
}

// collect the tax
if err := k.FundTreasury(ctx, feeCollector, tax); err != nil {
Expand Down

0 comments on commit 6bf0b53

Please sign in to comment.