Skip to content

Commit f0a29d6

Browse files
authored
Merge commit from fork
* fix: add send restriction to distribution module only receive the ubbn denom * chore: set error and bank restriction as unexported * chore: move special error to top of the file * chore: add release v1.1.0 to cl
1 parent cb5d0ec commit f0a29d6

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
3737

3838
## Unreleased
3939

40+
## v1.1.0
41+
4042
### Bug fixes
4143

4244
- [#860](https://github.com/babylonlabs-io/babylon/pull/860) fix: ensure active fps have signing info after finality resumption proposal.

app/keepers/keepers.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package keepers
22

33
import (
4+
"context"
5+
"fmt"
46
"path/filepath"
7+
"strings"
58

69
"cosmossdk.io/log"
710
storetypes "cosmossdk.io/store/types"
@@ -20,6 +23,7 @@ import (
2023
"github.com/cosmos/cosmos-sdk/codec"
2124
"github.com/cosmos/cosmos-sdk/runtime"
2225
servertypes "github.com/cosmos/cosmos-sdk/server/types"
26+
"github.com/cosmos/cosmos-sdk/types"
2327
authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec"
2428
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
2529
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
@@ -80,6 +84,8 @@ import (
8084
monitortypes "github.com/babylonlabs-io/babylon/x/monitor/types"
8185
)
8286

87+
var errBankRestrictionDistribution = fmt.Errorf("the distribution address %s can only receive bond denom %s", appparams.AccDistribution.String(), appparams.DefaultBondDenom)
88+
8389
// Capabilities of the IBC wasm contracts
8490
func WasmCapabilities() []string {
8591
// The last arguments can contain custom message handlers, and custom query handlers,
@@ -228,6 +234,7 @@ func (ak *AppKeepers) InitKeepers(
228234
appparams.AccGov.String(),
229235
logger,
230236
)
237+
bankKeeper.AppendSendRestriction(bankSendRestrictionOnlyBondDenomToDistribution)
231238

232239
stakingKeeper := stakingkeeper.NewKeeper(
233240
appCodec,
@@ -597,3 +604,23 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
597604

598605
return paramsKeeper
599606
}
607+
608+
// bankSendRestrictionOnlyBondDenomToDistribution restricts that only the default bond denom should be allowed to send to distribution mod acc.
609+
func bankSendRestrictionOnlyBondDenomToDistribution(ctx context.Context, fromAddr, toAddr types.AccAddress, amt types.Coins) (newToAddr types.AccAddress, err error) {
610+
if toAddr.Equals(appparams.AccDistribution) {
611+
denoms := amt.Denoms()
612+
switch len(denoms) {
613+
case 0:
614+
return toAddr, nil
615+
case 1:
616+
denom := denoms[0]
617+
if !strings.EqualFold(denom, appparams.DefaultBondDenom) {
618+
return nil, errBankRestrictionDistribution
619+
}
620+
default: // more than one length
621+
return nil, errBankRestrictionDistribution
622+
}
623+
}
624+
625+
return toAddr, nil
626+
}

app/params/addr.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ package params
22

33
import (
44
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
5+
dstrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
56
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
67
)
78

89
var (
910
AccGov = authtypes.NewModuleAddress(govtypes.ModuleName)
11+
AccDistribution = authtypes.NewModuleAddress(dstrtypes.ModuleName)
1012
AccFeeCollector = authtypes.NewModuleAddress(authtypes.FeeCollectorName)
1113
)

0 commit comments

Comments
 (0)