-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'ics29-fee-middleware' into feat/fee-middleware-proto
- Loading branch information
Showing
37 changed files
with
1,079 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package cli | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
) | ||
|
||
// GetQueryCmd returns the query commands for 29-fee | ||
func GetQueryCmd() *cobra.Command { | ||
queryCmd := &cobra.Command{ | ||
Use: "ibc-fee", | ||
Short: "", // TODO | ||
DisableFlagParsing: true, | ||
SuggestionsMinimumDistance: 2, | ||
} | ||
|
||
queryCmd.AddCommand( | ||
// TODO | ||
) | ||
|
||
return queryCmd | ||
} | ||
|
||
// NewTxCmd returns the transaction commands for 29-fee | ||
func NewTxCmd() *cobra.Command { | ||
txCmd := &cobra.Command{ | ||
Use: "ibc-fee", | ||
Short: "", // TODO | ||
DisableFlagParsing: true, | ||
SuggestionsMinimumDistance: 2, | ||
RunE: client.ValidateCmd, | ||
} | ||
|
||
txCmd.AddCommand( | ||
// TODO | ||
) | ||
|
||
return txCmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package cli | ||
|
||
// TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package cli | ||
|
||
// TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package keeper | ||
|
||
/* | ||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
// InitGenesis | ||
func (k Keeper) InitGenesis(ctx sdk.Context, state types.GenesisState) { | ||
} | ||
// ExportGenesis | ||
func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { | ||
return &types.GenesisState{} | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package keeper | ||
|
||
// TODO | ||
|
||
//var _ types.QueryServer = Keeper{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package keeper | ||
|
||
/* | ||
import ( | ||
"github.com/tendermint/tendermint/libs/log" | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" | ||
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" | ||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" | ||
"github.com/cosmos/ibc-go/modules/apps/transfer/types" | ||
host "github.com/cosmos/ibc-go/modules/core/24-host" | ||
) | ||
// Keeper defines the IBC fungible transfer keeper | ||
type Keeper struct { | ||
storeKey sdk.StoreKey | ||
cdc codec.BinaryCodec | ||
channelKeeper types.ChannelKeeper | ||
portKeeper types.PortKeeper | ||
authKeeper types.AccountKeeper | ||
bankKeeper types.BankKeeper | ||
scopedKeeper capabilitykeeper.ScopedKeeper | ||
} | ||
// NewKeeper creates a new 29-fee Keeper instance | ||
func NewKeeper( | ||
cdc codec.BinaryCodec, key sdk.StoreKey, paramSpace paramtypes.Subspace, | ||
channelKeeper types.ChannelKeeper, portKeeper types.PortKeeper, | ||
authKeeper types.AccountKeeper, bankKeeper types.BankKeeper, scopedKeeper capabilitykeeper.ScopedKeeper, | ||
) Keeper { | ||
return Keeper{ | ||
cdc: cdc, | ||
storeKey: key, | ||
channelKeeper: channelKeeper, | ||
portKeeper: portKeeper, | ||
authKeeper: authKeeper, | ||
bankKeeper: bankKeeper, | ||
scopedKeeper: scopedKeeper, | ||
} | ||
} | ||
// Logger returns a module-specific logger. | ||
func (k Keeper) Logger(ctx sdk.Context) log.Logger { | ||
return ctx.Logger().With("module", "x/"+host.ModuleName+"-"+types.ModuleName) | ||
} | ||
// IsBound checks if the transfer module is already bound to the desired port | ||
func (k Keeper) IsBound(ctx sdk.Context, portID string) bool { | ||
_, ok := k.scopedKeeper.GetCapability(ctx, host.PortPath(portID)) | ||
return ok | ||
} | ||
// BindPort defines a wrapper function for the ort Keeper's function in | ||
// order to expose it to module's InitGenesis function | ||
func (k Keeper) BindPort(ctx sdk.Context, portID string) error { | ||
cap := k.portKeeper.BindPort(ctx, portID) | ||
return k.ClaimCapability(ctx, cap, host.PortPath(portID)) | ||
} | ||
// GetPort returns the portID for the transfer module. Used in ExportGenesis | ||
func (k Keeper) GetPort(ctx sdk.Context) string { | ||
store := ctx.KVStore(k.storeKey) | ||
return string(store.Get(types.PortKey)) | ||
} | ||
// SetPort sets the portID for the transfer module. Used in InitGenesis | ||
func (k Keeper) SetPort(ctx sdk.Context, portID string) { | ||
store := ctx.KVStore(k.storeKey) | ||
store.Set(types.PortKey, []byte(portID)) | ||
} | ||
// AuthenticateCapability wraps the scopedKeeper's AuthenticateCapability function | ||
func (k Keeper) AuthenticateCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) bool { | ||
return k.scopedKeeper.AuthenticateCapability(ctx, cap, name) | ||
} | ||
// ClaimCapability allows the transfer module that can claim a capability that IBC module | ||
// passes to it | ||
func (k Keeper) ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error { | ||
return k.scopedKeeper.ClaimCapability(ctx, cap, name) | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package keeper_test | ||
|
||
/* | ||
import ( | ||
"testing" | ||
"github.com/stretchr/testify/suite" | ||
"github.com/tendermint/tendermint/crypto" | ||
"github.com/cosmos/cosmos-sdk/baseapp" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/ibc-go/modules/apps/transfer/types" | ||
ibctesting "github.com/cosmos/ibc-go/testing" | ||
) | ||
type KeeperTestSuite struct { | ||
suite.Suite | ||
coordinator *ibctesting.Coordinator | ||
// testing chains used for convenience and readability | ||
chainA *ibctesting.TestChain | ||
chainB *ibctesting.TestChain | ||
chainC *ibctesting.TestChain | ||
} | ||
func (suite *KeeperTestSuite) SetupTest() { | ||
suite.coordinator = ibctesting.NewCoordinator(suite.T(), 3) | ||
suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(0)) | ||
suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(1)) | ||
suite.chainC = suite.coordinator.GetChain(ibctesting.GetChainID(2)) | ||
} | ||
func NewFeePath(chainA, chainB *ibctesting.TestChain) *ibctesting.Path { | ||
path := ibctesting.NewPath(chainA, chainB) | ||
path.EndpointA.ChannelConfig.PortID = ibctesting.FeePort | ||
path.EndpointB.ChannelConfig.PortID = ibctesting.FeePort | ||
return path | ||
} | ||
func TestKeeperTestSuite(t *testing.T) { | ||
suite.Run(t, new(KeeperTestSuite)) | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package keeper | ||
|
||
// TODO | ||
//var _ types.MsgServer = Keeper{} |
Oops, something went wrong.