Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
hieuvubk committed Oct 1, 2024
1 parent f19996e commit 3c685f1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion x/bank/v2/depinject.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func InvokeSetSendRestrictions(
return fmt.Errorf("can't find send restriction for module %s", module)
}

keeper.AppendSendRestriction(restriction)
keeper.AppendGlobalSendRestriction(restriction)
}

return nil
Expand Down
15 changes: 0 additions & 15 deletions x/bank/v2/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,18 +258,3 @@ func newBalancesIndexes(sb *collections.SchemaBuilder) BalancesIndexes {
type BalancesIndexes struct {
Denom *indexes.ReversePair[[]byte, string, math.Int]
}

// AppendSendRestriction adds the provided SendRestrictionFn to run after previously provided restrictions.
func (k Keeper) AppendSendRestriction(restriction types.SendRestrictionFn) {
k.sendRestriction.append(restriction)
}

// PrependSendRestriction adds the provided SendRestrictionFn to run before previously provided restrictions.
func (k Keeper) PrependSendRestriction(restriction types.SendRestrictionFn) {
k.sendRestriction.prepend(restriction)
}

// ClearSendRestriction removes the send restriction (if there is one).
func (k Keeper) ClearSendRestriction() {
k.sendRestriction.clear()
}
4 changes: 2 additions & 2 deletions x/bank/v2/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func (suite *KeeperTestSuite) TestSendCoins_WithRestriction() {
}
return to, nil
}
suite.bankKeeper.AppendSendRestriction(addrRestrictFunc)
suite.bankKeeper.AppendGlobalSendRestriction(addrRestrictFunc)

err := suite.bankKeeper.SendCoins(ctx, accAddrs[0], accAddrs[0], sendAmt)
require.Error(err)
Expand All @@ -215,7 +215,7 @@ func (suite *KeeperTestSuite) TestSendCoins_WithRestriction() {
}
return to, nil
}
suite.bankKeeper.AppendSendRestriction(amtRestrictFunc)
suite.bankKeeper.AppendGlobalSendRestriction(amtRestrictFunc)

// Pass the 1st but failt at the 2nd
err = suite.bankKeeper.SendCoins(ctx, accAddrs[0], accAddrs[1], sendAmt)
Expand Down
15 changes: 15 additions & 0 deletions x/bank/v2/keeper/restriction.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,18 @@ func (r *sendRestriction) apply(ctx context.Context, fromAddr, toAddr []byte, am
}
return r.fn(ctx, fromAddr, toAddr, amt)
}

// AppendSendRestriction adds the provided SendRestrictionFn to run after previously provided restrictions.
func (k Keeper) AppendGlobalSendRestriction(restriction types.SendRestrictionFn) {
k.sendRestriction.append(restriction)
}

// PrependSendRestriction adds the provided SendRestrictionFn to run before previously provided restrictions.
func (k Keeper) PrependGlobalSendRestriction(restriction types.SendRestrictionFn) {
k.sendRestriction.prepend(restriction)
}

// ClearSendRestriction removes the send restriction (if there is one).
func (k Keeper) ClearGlobalSendRestriction() {
k.sendRestriction.clear()
}

0 comments on commit 3c685f1

Please sign in to comment.