Skip to content

Commit

Permalink
refactor: remove usage of global basedenom (#18268)
Browse files Browse the repository at this point in the history
  • Loading branch information
tac0turtle committed Oct 30, 2023
1 parent 15ccdcc commit e6a4c78
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 375 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/mint) [#18283](https://github.com/cosmos/cosmos-sdk/pull/18283) Mint module was moved to its own go.mod `cosmossdk.io/x/mint`
* (x/consensus) [#18041](https://github.com/cosmos/cosmos-sdk/pull/18041) `ToProtoConsensusParams()` returns an error
* (x/slashing) [#18115](https://github.com/cosmos/cosmos-sdk/pull/18115) `NewValidatorSigningInfo` takes strings instead of `sdk.AccAddress`
* (types) [#18268](https://github.com/cosmos/cosmos-sdk/pull/18268) Remove global setting of basedenom. Use the staking module parameter instead

### CLI Breaking Changes

Expand Down
20 changes: 19 additions & 1 deletion types/coin.go
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,8 @@ func ParseCoinNormalized(coinStr string) (coin Coin, err error) {
return Coin{}, err
}

coin, _ = NormalizeDecCoin(decCoin).TruncateDecimal()
coin, _ = NewDecCoinFromDec(decCoin.Denom, decCoin.Amount).TruncateDecimal()

return coin, nil
}

Expand All @@ -900,3 +901,20 @@ func ParseCoinsNormalized(coinStr string) (Coins, error) {
}
return NormalizeCoins(coins), nil
}

// ----------------------------------------------------------------------------

// NormalizeCoins normalize and truncate a list of decimal coins
func NormalizeCoins(coins []DecCoin) Coins {
if coins == nil {
return nil
}
result := make([]Coin, 0, len(coins))

for _, coin := range coins {
newCoin, _ := NewDecCoinFromDec(coin.Denom, coin.Amount).TruncateDecimal()
result = append(result, newCoin)
}

return result
}
160 changes: 0 additions & 160 deletions types/denom.go

This file was deleted.

Loading

0 comments on commit e6a4c78

Please sign in to comment.