-
Notifications
You must be signed in to change notification settings - Fork 629
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
scaffolding for 29-fee #274
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package cli | ||
|
||
// TODO |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package cli | ||
|
||
// TODO |
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{} | ||
} | ||
*/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package keeper | ||
|
||
// TODO | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. uncomment |
||
|
||
//var _ types.QueryServer = Keeper{} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package keeper | ||
|
||
/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. uncomment |
||
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) | ||
} | ||
*/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package keeper_test | ||
|
||
/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. uncomment |
||
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)) | ||
} | ||
*/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package keeper | ||
|
||
// TODO | ||
//var _ types.MsgServer = Keeper{} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. uncomment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uncomment