Skip to content

Commit

Permalink
rename: router -> packetforward
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed Oct 10, 2023
1 parent b1b6db8 commit eb1c464
Show file tree
Hide file tree
Showing 28 changed files with 175 additions and 175 deletions.
8 changes: 4 additions & 4 deletions middleware/packet-forward-middleware/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ cosmovisor:

mocks: $(MOCKS_DIR)
go install go.uber.org/mock/[email protected]
mockgen -package=mock -destination=./test/mock/transfer_keeper.go $(GOMOD)/router/types TransferKeeper
mockgen -package=mock -destination=./test/mock/distribution_keeper.go $(GOMOD)/router/types DistributionKeeper
mockgen -package=mock -destination=./test/mock/bank_keeper.go $(GOMOD)/router/types BankKeeper
mockgen -package=mock -destination=./test/mock/transfer_keeper.go $(GOMOD)/packetforward/types TransferKeeper
mockgen -package=mock -destination=./test/mock/distribution_keeper.go $(GOMOD)/packetforward/types DistributionKeeper
mockgen -package=mock -destination=./test/mock/bank_keeper.go $(GOMOD)/packetforward/types BankKeeper
mockgen -package=mock -destination=./test/mock/channel_keeper.go $(GOMOD)/packetforward/types ChannelKeeper
mockgen -package=mock -destination=./test/mock/ics4_wrapper.go github.com/cosmos/ibc-go/v7/modules/core/05-port/types ICS4Wrapper
mockgen -package=mock -destination=./test/mock/ibc_module.go github.com/cosmos/ibc-go/v7/modules/core/05-port/types IBCModule
mockgen -package=mock -destination=./test/mock/channel_keeper.go $(GOMOD)/router/types ChannelKeeper

.PHONY: mocks

Expand Down
2 changes: 1 addition & 1 deletion middleware/packet-forward-middleware/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ The examples above show the intended usage of the `receiver` field for one or mu

## Implementation details

Flow sequence mainly encoded in [middleware](router/ibc_middleware.go) and in [keeper](router/keeper/keeper.go).
Flow sequence mainly encoded in [middleware](packetforward/ibc_middleware.go) and in [keeper](packetforward/keeper/keeper.go).

Describes `A` sending to `C` via `B` in several scenarios with operational opened channels, enabled denom composition, fees and available to refund, but no retries.

Expand Down
6 changes: 3 additions & 3 deletions middleware/packet-forward-middleware/docs/integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Integration of the PFM should take approximately 20 minutes.

// Import the packet forward middleware
import (
packetforward "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router"
packetforwardkeeper "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router/keeper"
packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router/types"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward"
packetforwardkeeper "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/keeper"
packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"
)

...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ package cli
import (
"fmt"

"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router/types"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"
"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/version"
)

// GetQueryCmd returns the query commands for router
// GetQueryCmd returns the query commands for packetforward
func GetQueryCmd() *cobra.Command {
queryCmd := &cobra.Command{
Use: "ibc-router",
Use: "packetforward",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
}
Expand All @@ -26,14 +26,14 @@ func GetQueryCmd() *cobra.Command {
return queryCmd
}

// GetCmdParams returns the command handler for ibc-router parameter querying.
// GetCmdParams returns the command handler for packetforward parameter querying.
func GetCmdParams() *cobra.Command {
cmd := &cobra.Command{
Use: "params",
Short: "Query the current ibc-router parameters",
Long: "Query the current ibc-router parameters",
Short: "Query the current packetforward parameters",
Long: "Query the current packetforward parameters",
Args: cobra.NoArgs,
Example: fmt.Sprintf("%s query ibc-router params", version.AppName),
Example: fmt.Sprintf("%s query packetforward params", version.AppName),
RunE: func(cmd *cobra.Command, _ []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
Expand All @@ -54,7 +54,7 @@ func GetCmdParams() *cobra.Command {
return cmd
}

// NewTxCmd returns the transaction commands for router
// NewTxCmd returns the transaction commands for packetforward
func NewTxCmd() *cobra.Command {
return nil
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package router
package packetforward

import (
"encoding/json"
Expand All @@ -7,8 +7,8 @@ import (
"time"

"github.com/armon/go-metrics"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router/keeper"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router/types"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/keeper"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"

errorsmod "cosmossdk.io/errors"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package keeper

import (
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router/types"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"

sdk "github.com/cosmos/cosmos-sdk/types"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package keeper
import (
"context"

"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router/types"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"

sdk "github.com/cosmos/cosmos-sdk/types"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"time"

"github.com/armon/go-metrics"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router/types"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"

errorsmod "cosmossdk.io/errors"

Expand Down Expand Up @@ -39,7 +39,7 @@ var (
// DefaultForwardTransferPacketTimeoutTimestamp is the timeout timestamp following IBC defaults
DefaultForwardTransferPacketTimeoutTimestamp = time.Duration(transfertypes.DefaultRelativePacketTimeoutTimestamp) * time.Nanosecond

// DefaultRefundTransferPacketTimeoutTimestamp is a 28-day timeout for refund packets since funds are stuck in router module otherwise.
// DefaultRefundTransferPacketTimeoutTimestamp is a 28-day timeout for refund packets since funds are stuck in packetforward module otherwise.
DefaultRefundTransferPacketTimeoutTimestamp = 28 * 24 * time.Hour
)

Expand Down Expand Up @@ -378,14 +378,14 @@ func (k *Keeper) RetryTimeout(

amount, ok := sdk.NewIntFromString(data.Amount)
if !ok {
k.Logger(ctx).Error("packetForwardMiddleware error parsing amount from string for router retry on timeout",
k.Logger(ctx).Error("packetForwardMiddleware error parsing amount from string for packetforward retry on timeout",
"original-sender-address", inFlightPacket.OriginalSenderAddress,
"refund-channel-id", inFlightPacket.RefundChannelId,
"refund-port-id", inFlightPacket.RefundPortId,
"retries-remaining", inFlightPacket.RetriesRemaining,
"amount", data.Amount,
)
return fmt.Errorf("error parsing amount from string for router retry: %s", data.Amount)
return fmt.Errorf("error parsing amount from string for packetforward retry: %s", data.Amount)
}

denom := transfertypes.ParseDenomTrace(data.Denom).IBCDenom()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package keeper

import (
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router/types"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"

sdk "github.com/cosmos/cosmos-sdk/types"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package router
package packetforward

import (
"context"
"encoding/json"
"fmt"

"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router/client/cli"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router/keeper"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router/types"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/client/cli"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/keeper"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"
"github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
Expand All @@ -28,7 +28,7 @@ var (
_ module.AppModuleSimulation = AppModule{}
)

// AppModuleBasic is the router AppModuleBasic
// AppModuleBasic is the packetforward AppModuleBasic
type AppModuleBasic struct{}

// Name implements AppModuleBasic interface
Expand All @@ -43,12 +43,12 @@ func (AppModuleBasic) RegisterLegacyAminoCodec(_ *codec.LegacyAmino) {}
func (AppModuleBasic) RegisterInterfaces(_ codectypes.InterfaceRegistry) {}

// DefaultGenesis returns default genesis state as raw bytes for the ibc
// router module.
// packetforward module.
func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
return cdc.MustMarshalJSON(types.DefaultGenesisState())
}

// ValidateGenesis performs genesis state validation for the router module.
// ValidateGenesis performs genesis state validation for the packetforward module.
func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error {
var gs types.GenesisState
if err := cdc.UnmarshalJSON(bz, &gs); err != nil {
Expand All @@ -61,7 +61,7 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingCo
// RegisterRESTRoutes implements AppModuleBasic interface
func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {}

// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the ibc-router module.
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the packetforward module.
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
_ = types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx))
}
Expand All @@ -82,7 +82,7 @@ type AppModule struct {
keeper *keeper.Keeper
}

// NewAppModule creates a new router module
// NewAppModule creates a new packetforward module
func NewAppModule(k *keeper.Keeper) AppModule {
return AppModule{
keeper: k,
Expand All @@ -99,7 +99,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterQueryServer(cfg.QueryServer(), am.keeper)
}

// InitGenesis performs genesis initialization for the ibc-router module. It returns
// InitGenesis performs genesis initialization for the packetforward module. It returns
// no validator updates.
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
err := am.ValidateGenesis(cdc, nil, data)
Expand All @@ -113,7 +113,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.
return []abci.ValidatorUpdate{}
}

// ExportGenesis returns the exported genesis state as raw bytes for the ibc-router
// ExportGenesis returns the exported genesis state as raw bytes for the packetforward
// module.
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
gs := am.keeper.ExportGenesis(ctx)
Expand All @@ -133,18 +133,18 @@ func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.Valid

// AppModuleSimulation functions

// GenerateGenesisState creates a randomized GenState of the router module.
// GenerateGenesisState creates a randomized GenState of the packetforward module.
func (AppModule) GenerateGenesisState(_ *module.SimulationState) {}

// ProposalContents doesn't return any content functions for governance proposals.
func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { //nolint:staticcheck // WeightedProposalContent is necessary to satisfy the module interface
return nil
}

// RegisterStoreDecoder registers a decoder for router module's types
// RegisterStoreDecoder registers a decoder for packetforward module's types
func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {}

// WeightedOperations returns the all the router module operations with their respective weights.
// WeightedOperations returns the all the packetforward module operations with their respective weights.
func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation {
return nil
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package router_test
package packetforward_test

import (
"encoding/json"
"fmt"
"testing"

"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router/keeper"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router/types"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/keeper"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/test"
"github.com/iancoleman/orderedmap"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -291,7 +291,7 @@ func TestOnRecvPacket_ForwardNoFee(t *testing.T) {
Return(nil),
)

// chain B with router module receives packet and forwards. ack should be nil so that it is not written yet.
// chain B with packetforward module receives packet and forwards. ack should be nil so that it is not written yet.
ack := forwardMiddleware.OnRecvPacket(ctx, packetOrig, senderAccAddr)
require.Nil(t, ack)

Expand Down Expand Up @@ -352,7 +352,7 @@ func TestOnRecvPacket_ForwardAmountInt256(t *testing.T) {
Return(nil),
)

// chain B with router module receives packet and forwards. ack should be nil so that it is not written yet.
// chain B with packetforward module receives packet and forwards. ack should be nil so that it is not written yet.
ack := forwardMiddleware.OnRecvPacket(ctx, packetOrig, senderAccAddr)
require.Nil(t, ack)

Expand All @@ -371,7 +371,7 @@ func TestOnRecvPacket_ForwardWithFee(t *testing.T) {
forwardMiddleware := setup.ForwardMiddleware

// Set fee param to 10%
setup.Keepers.RouterKeeper.SetParams(ctx, types.NewParams(sdk.NewDecWithPrec(10, 2)))
setup.Keepers.PacketForwardKeeper.SetParams(ctx, types.NewParams(sdk.NewDecWithPrec(10, 2)))

denom := makeIBCDenom(testDestinationPort, testDestinationChannel, testDenom)
senderAccAddr := test.AccAddress()
Expand Down Expand Up @@ -418,7 +418,7 @@ func TestOnRecvPacket_ForwardWithFee(t *testing.T) {
Return(nil),
)

// chain B with router module receives packet and forwards. ack should be nil so that it is not written yet.
// chain B with packetforward module receives packet and forwards. ack should be nil so that it is not written yet.
ack := forwardMiddleware.OnRecvPacket(ctx, packetOrig, senderAccAddr)
require.Nil(t, ack)

Expand Down Expand Up @@ -519,11 +519,11 @@ func TestOnRecvPacket_ForwardMultihopStringNext(t *testing.T) {
Return(nil),
)

// chain B with router module receives packet and forwards. ack should be nil so that it is not written yet.
// chain B with packetforward module receives packet and forwards. ack should be nil so that it is not written yet.
ack := forwardMiddleware.OnRecvPacket(ctx, packetOrig, senderAccAddr)
require.Nil(t, ack)

// chain C with router module receives packet and forwards. ack should be nil so that it is not written yet.
// chain C with packetforward module receives packet and forwards. ack should be nil so that it is not written yet.
ack = forwardMiddleware.OnRecvPacket(ctx, packet2, senderAccAddr2)
require.Nil(t, ack)

Expand Down Expand Up @@ -631,11 +631,11 @@ func TestOnRecvPacket_ForwardMultihopJSONNext(t *testing.T) {
Return(nil),
)

// chain B with router module receives packet and forwards. ack should be nil so that it is not written yet.
// chain B with packetforward module receives packet and forwards. ack should be nil so that it is not written yet.
ack := forwardMiddleware.OnRecvPacket(ctx, packetOrig, senderAccAddr)
require.Nil(t, ack)

// chain C with router module receives packet and forwards. ack should be nil so that it is not written yet.
// chain C with packetforward module receives packet and forwards. ack should be nil so that it is not written yet.
ack = forwardMiddleware.OnRecvPacket(ctx, packet2, senderAccAddr2)
require.Nil(t, ack)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"testing"

"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router/types"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"
"github.com/stretchr/testify/require"
)

Expand Down
Loading

0 comments on commit eb1c464

Please sign in to comment.