Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge x/supply into x/bank #6010

Merged
merged 29 commits into from
Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
abae2ec
Remove x/supply module
alexanderbez Apr 16, 2020
449bd18
Start migration
alexanderbez Apr 16, 2020
305b2d1
More updates
alexanderbez Apr 16, 2020
14d1f0d
Update codec
alexanderbez Apr 17, 2020
16cf70f
Update x/staking
alexanderbez Apr 17, 2020
c69418d
Update x/mint
alexanderbez Apr 17, 2020
c4fe6c2
Update x/ibc
alexanderbez Apr 17, 2020
5ba82da
Update x/gov
alexanderbez Apr 17, 2020
e6f2e6c
Lint
alexanderbez Apr 17, 2020
cd5b28e
Fix x/ibc
alexanderbez Apr 17, 2020
feb3a16
Update more mods
alexanderbez Apr 17, 2020
974fb33
Update x/auth
alexanderbez Apr 17, 2020
09194de
Update simapp
alexanderbez Apr 17, 2020
b1666d4
Update querier tests
alexanderbez Apr 17, 2020
124d689
Update keeper tests
alexanderbez Apr 17, 2020
3324a00
Merge branch 'master' into bez/5913-remove-supply-mod
alexanderbez Apr 17, 2020
5f9f528
Lint
alexanderbez Apr 17, 2020
dee0da7
Fix tests
alexanderbez Apr 17, 2020
68f0472
Fix TestImportExportQueues
alexanderbez Apr 17, 2020
2152b36
Add changelog entries
alexanderbez Apr 17, 2020
0c21364
Merge branch 'master' into bez/5913-remove-supply-mod
alexanderbez Apr 17, 2020
6c381e3
Merge branch 'master' into bez/5913-remove-supply-mod
alexanderbez Apr 17, 2020
2749dc3
Merge branch 'master' into bez/5913-remove-supply-mod
fedekunze Apr 18, 2020
702805b
Sim updates
alexanderbez Apr 19, 2020
50f0a14
Merge branch 'bez/5913-remove-supply-mod' of github.com:cosmos/cosmos…
alexanderbez Apr 19, 2020
f7c668a
Use module name
alexanderbez Apr 19, 2020
1bb8543
Fix bui;ld
alexanderbez Apr 19, 2020
e499b62
Merge branch 'master' into bez/5913-remove-supply-mod
fedekunze Apr 20, 2020
3e47909
Update x/auth/types/expected_keepers.go
alexanderbez Apr 20, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update x/ibc
  • Loading branch information
alexanderbez committed Apr 17, 2020
commit c4fe6c2a04f17a661a5070f8275038a6bac8ea71
4 changes: 2 additions & 2 deletions x/ibc/20-transfer/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/bank"
connectionexported "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported"
connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported"
Expand All @@ -22,7 +23,6 @@ import (
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types"
"github.com/cosmos/cosmos-sdk/x/staking"
"github.com/cosmos/cosmos-sdk/x/supply"
)

// define constants used for testing
Expand Down Expand Up @@ -111,7 +111,7 @@ func (suite *HandlerTestSuite) TestHandleMsgTransfer() {
suite.Require().Nil(res, "%+v", res) // incorrect denom prefix

msg = transfer.NewMsgTransfer(testPort1, testChannel1, 10, testPrefixedCoins1, testAddr1, testAddr2)
suite.chainA.App.SupplyKeeper.SetSupply(ctx, supply.NewSupply(testPrefixedCoins1))
suite.chainA.App.BankKeeper.SetSupply(ctx, bank.NewSupply(testPrefixedCoins1))
_ = suite.chainA.App.BankKeeper.SetBalances(ctx, testAddr1, testPrefixedCoins1)

res, err = handler(ctx, msg)
Expand Down
13 changes: 5 additions & 8 deletions x/ibc/20-transfer/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
bankexported "github.com/cosmos/cosmos-sdk/x/bank/exported"
"github.com/cosmos/cosmos-sdk/x/capability"
channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel"
channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported"
porttypes "github.com/cosmos/cosmos-sdk/x/ibc/05-port/types"
"github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/types"
ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types"
supplyexported "github.com/cosmos/cosmos-sdk/x/supply/exported"
)

// DefaultPacketTimeout is the default packet timeout relative to the current block height
Expand All @@ -30,20 +30,18 @@ type Keeper struct {
channelKeeper types.ChannelKeeper
portKeeper types.PortKeeper
bankKeeper types.BankKeeper
supplyKeeper types.SupplyKeeper
scopedKeeper capability.ScopedKeeper
}

// NewKeeper creates a new IBC transfer Keeper instance
func NewKeeper(
cdc *codec.Codec, key sdk.StoreKey,
channelKeeper types.ChannelKeeper, portKeeper types.PortKeeper,
bankKeeper types.BankKeeper, supplyKeeper types.SupplyKeeper,
scopedKeeper capability.ScopedKeeper,
bankKeeper types.BankKeeper, scopedKeeper capability.ScopedKeeper,
) Keeper {

// ensure ibc transfer module account is set
if addr := supplyKeeper.GetModuleAddress(types.GetModuleAccountName()); addr == nil {
if addr := bankKeeper.GetModuleAddress(types.GetModuleAccountName()); addr == nil {
panic("the IBC transfer module account has not been set")
}

Expand All @@ -53,7 +51,6 @@ func NewKeeper(
channelKeeper: channelKeeper,
portKeeper: portKeeper,
bankKeeper: bankKeeper,
supplyKeeper: supplyKeeper,
scopedKeeper: scopedKeeper,
}
}
Expand All @@ -64,8 +61,8 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger {
}

// GetTransferAccount returns the ICS20 - transfers ModuleAccount
func (k Keeper) GetTransferAccount(ctx sdk.Context) supplyexported.ModuleAccountI {
return k.supplyKeeper.GetModuleAccount(ctx, types.GetModuleAccountName())
func (k Keeper) GetTransferAccount(ctx sdk.Context) bankexported.ModuleAccountI {
return k.bankKeeper.GetModuleAccount(ctx, types.GetModuleAccountName())
}

// PacketExecuted defines a wrapper function for the channel Keeper's function
Expand Down
12 changes: 6 additions & 6 deletions x/ibc/20-transfer/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ func (k Keeper) createOutgoingPacket(
}

// transfer the coins to the module account and burn them
if err := k.supplyKeeper.SendCoinsFromAccountToModule(
if err := k.bankKeeper.SendCoinsFromAccountToModule(
ctx, sender, types.GetModuleAccountName(), amount,
); err != nil {
return err
}

// burn vouchers from the sender's balance if the source is from another chain
if err := k.supplyKeeper.BurnCoins(
if err := k.bankKeeper.BurnCoins(
ctx, types.GetModuleAccountName(), amount,
); err != nil {
// NOTE: should not happen as the module account was
Expand Down Expand Up @@ -151,14 +151,14 @@ func (k Keeper) OnRecvPacket(ctx sdk.Context, packet channel.Packet, data types.

if source {
// mint new tokens if the source of the transfer is the same chain
if err := k.supplyKeeper.MintCoins(
if err := k.bankKeeper.MintCoins(
ctx, types.GetModuleAccountName(), data.Amount,
); err != nil {
return err
}

// send to receiver
return k.supplyKeeper.SendCoinsFromModuleToAccount(
return k.bankKeeper.SendCoinsFromModuleToAccount(
ctx, types.GetModuleAccountName(), data.Receiver, data.Amount,
)
}
Expand Down Expand Up @@ -219,11 +219,11 @@ func (k Keeper) refundPacketAmount(ctx sdk.Context, packet channel.Packet, data
}

// mint vouchers back to sender
if err := k.supplyKeeper.MintCoins(
if err := k.bankKeeper.MintCoins(
ctx, types.GetModuleAccountName(), data.Amount,
); err != nil {
return err
}

return k.supplyKeeper.SendCoinsFromModuleToAccount(ctx, types.GetModuleAccountName(), data.Sender, data.Amount)
return k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.GetModuleAccountName(), data.Sender, data.Amount)
}
4 changes: 2 additions & 2 deletions x/ibc/20-transfer/keeper/relay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/bank"
connectionexported "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported"
channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported"
channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
"github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/types"
ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types"
"github.com/cosmos/cosmos-sdk/x/supply"
)

func (suite *KeeperTestSuite) TestSendTransfer() {
Expand All @@ -33,7 +33,7 @@ func (suite *KeeperTestSuite) TestSendTransfer() {
}, true, true},
{"successful transfer from external chain", prefixCoins,
func() {
suite.chainA.App.SupplyKeeper.SetSupply(suite.chainA.GetContext(), supply.NewSupply(prefixCoins))
suite.chainA.App.BankKeeper.SetSupply(suite.chainA.GetContext(), bank.NewSupply(prefixCoins))
_, err := suite.chainA.App.BankKeeper.AddCoins(suite.chainA.GetContext(), testAddr1, prefixCoins)
suite.Require().NoError(err)
suite.chainA.CreateClient(suite.chainB)
Expand Down
15 changes: 8 additions & 7 deletions x/ibc/20-transfer/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@ package types

import (
sdk "github.com/cosmos/cosmos-sdk/types"
bankexported "github.com/cosmos/cosmos-sdk/x/bank/exported"
"github.com/cosmos/cosmos-sdk/x/capability"
clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported"
connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection"
channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel"
channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported"
supplyexported "github.com/cosmos/cosmos-sdk/x/supply/exported"
)

// BankKeeper defines the expected bank keeper
type BankKeeper interface {
SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error

GetModuleAddress(name string) sdk.AccAddress
GetModuleAccount(ctx sdk.Context, name string) bankexported.ModuleAccountI
MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error
BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error
SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
}

// ChannelKeeper defines the expected IBC channel keeper
Expand Down Expand Up @@ -41,10 +48,4 @@ type PortKeeper interface {

// SupplyKeeper expected supply keeper
type SupplyKeeper interface {
GetModuleAddress(name string) sdk.AccAddress
GetModuleAccount(ctx sdk.Context, name string) supplyexported.ModuleAccountI
MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error
BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error
SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
}
8 changes: 4 additions & 4 deletions x/staking/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
supplyexported "github.com/cosmos/cosmos-sdk/x/bank/exported"
bankexported "github.com/cosmos/cosmos-sdk/x/bank/exported"
stakingexported "github.com/cosmos/cosmos-sdk/x/staking/exported"
)

Expand All @@ -27,13 +27,13 @@ type BankKeeper interface {
LockedCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins

GetSupply(ctx sdk.Context) supplyexported.SupplyI
GetSupply(ctx sdk.Context) bankexported.SupplyI

GetModuleAddress(name string) sdk.AccAddress
GetModuleAccount(ctx sdk.Context, moduleName string) supplyexported.ModuleAccountI
GetModuleAccount(ctx sdk.Context, moduleName string) bankexported.ModuleAccountI

// TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862
SetModuleAccount(sdk.Context, supplyexported.ModuleAccountI)
SetModuleAccount(sdk.Context, bankexported.ModuleAccountI)

SendCoinsFromModuleToModule(ctx sdk.Context, senderPool, recipientPool string, amt sdk.Coins) error
UndelegateCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
Expand Down