Skip to content

Commit

Permalink
Public CoinTransferrer interface
Browse files Browse the repository at this point in the history
  • Loading branch information
alpe committed Mar 24, 2021
1 parent 408bba1 commit 55ac19b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions x/wasm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type Messenger interface {
DispatchMsg(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg wasmvmtypes.CosmosMsg) (events []sdk.Event, data [][]byte, err error)
}

type coinTransferrer interface {
type CoinTransferrer interface {
// TransferCoins sends the coin amounts from the source to the destination with rules applied.
TransferCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error
}
Expand All @@ -72,7 +72,7 @@ type Keeper struct {
storeKey sdk.StoreKey
cdc codec.Marshaler
accountKeeper types.AccountKeeper
bank coinTransferrer
bank CoinTransferrer
portKeeper types.PortKeeper
capabilityKeeper types.CapabilityKeeper
wasmVM types.WasmerEngine
Expand Down Expand Up @@ -1027,21 +1027,21 @@ func (k Keeper) QueryGasLimit() sdk.Gas {
return k.queryGasLimit
}

// CoinTransferrer replicates the cosmos-sdk behaviour as in
// BankCoinTransferrer replicates the cosmos-sdk behaviour as in
// https://github.com/cosmos/cosmos-sdk/blob/v0.41.4/x/bank/keeper/msg_server.go#L26
type CoinTransferrer struct {
type BankCoinTransferrer struct {
keeper types.BankKeeper
}

func NewBankCoinTransferrer(keeper types.BankKeeper) CoinTransferrer {
return CoinTransferrer{
func NewBankCoinTransferrer(keeper types.BankKeeper) BankCoinTransferrer {
return BankCoinTransferrer{
keeper: keeper,
}
}

// TransferCoins transfers coins from source to destination account when coin send was enabled for them and the recipient
// is not in the blocked address list.
func (c CoinTransferrer) TransferCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error {
func (c BankCoinTransferrer) TransferCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error {
if err := c.keeper.SendEnabledCoins(ctx, amt...); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion x/wasm/keeper/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func WithMessageEncoders(x *MessageEncoders) Option {
}

// WithCoinTransferrer is an optional constructor parameter to set a custom coin transferrer
func WithCoinTransferrer(x coinTransferrer) Option {
func WithCoinTransferrer(x CoinTransferrer) Option {
return optsFn(func(k *Keeper) {
k.bank = x
})
Expand Down

0 comments on commit 55ac19b

Please sign in to comment.