Skip to content

Commit d0def63

Browse files
committed
chore: apply suggestions from John
1 parent b16c1f7 commit d0def63

6 files changed

Lines changed: 20 additions & 18 deletions

File tree

tests/integration/integration.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ func NewCleanChainAtTime(startTime int64, suiteOpts ...SuiteOpt) *KeeperTestSuit
4141
for _, opt := range suiteOpts {
4242
opt(&s)
4343
}
44+
4445
s.setupApp(startTime)
46+
4547
return &s
4648
}
4749

tests/integration/warp_util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ import (
1313
"github.com/bcp-innovations/hyperlane-cosmos/x/middleware"
1414
"github.com/bcp-innovations/hyperlane-cosmos/x/warp"
1515
sdk "github.com/cosmos/cosmos-sdk/types"
16+
"github.com/cosmos/gogoproto/proto"
1617

1718
"github.com/bcp-innovations/hyperlane-cosmos/util"
1819
"github.com/bcp-innovations/hyperlane-cosmos/x/warp/keeper"
1920
"github.com/bcp-innovations/hyperlane-cosmos/x/warp/types"
20-
"github.com/cosmos/gogoproto/proto"
2121

2222
. "github.com/onsi/gomega"
2323
)
@@ -32,7 +32,7 @@ func (suite *KeeperTestSuite) postBuildOpts() simapp.PostBuildOpts {
3232
}
3333

3434
// setupWarpApps returns a post application build configuration handler to
35-
// register the warp applications on the hyperlane core. If middleware hooks
35+
// register the Warp applications on the Hyperlane core. If middleware hooks
3636
// have been specified in the suite, they are used to wrap the warp keeper.
3737
func (suite *KeeperTestSuite) setupWarpApps() simapp.PostBuildOpt {
3838
// If no custom hooks, use default registration

tests/simapp/warp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func RegisterWarpAppsOpt(warpApps ...warp.WarpApp) PostBuildOpt {
2121
}
2222
}
2323

24-
// RegisterWarpApps allows to register warp applications on the hyperlane
24+
// RegisterWarpApps allows to register Warp applications on the Hyperlane
2525
// core keeper of the main app.
2626
func (app *App) RegisterWarpApps(warpApps ...warp.WarpApp) {
2727
for _, warpApp := range warpApps {

x/middleware/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# Middleware
22

33
This package contains a middleware implementation for a generic `HyperlaneApp`.
4-
The middleware allows to hook
5-
before and after the execution of the application's `Handle` method.
4+
Middleware allows integrators to add custom logic
5+
before and after the execution of an application's `Handle` method.
66

77
## Usage
88

9-
To wrap n Hyperlane application with a middleware, two components are required:
9+
To wrap a Hyperlane application with middleware, two components are required:
1010

1111
- The Hyperlane core keeper.
1212
- A Hyperlane application, like Warp.
1313

1414
Once the Cosmos SDK application has been built,
1515
it is possible to build and register the middleware.
16-
Assuming we want to provide hook functionalities
17-
around the Warp application for the collateral token, we can do as follow.
16+
Assuming we want to provide hook functionalities around the Warp application for collateral tokens,
17+
we can do the following.
1818

1919
Import the required types:
2020

@@ -31,7 +31,7 @@ import (
3131
```
3232

3333
Now we have to create a concrete value implementing the `HandleHook` interface. It is possible to
34-
use the simple hook type already provided in the package:
34+
use the simple hook type already provided:
3535

3636
```go
3737
hook := middleware.NewHandleHook(
@@ -50,7 +50,7 @@ For more complex applications, a custom type can be created.
5050
It is also possible to use another Cosmos SDK module as middleware,
5151
as long as it implements the required methods.
5252
At this point, it is possible to create the middleware. In the example below,
53-
we are going to create two wrapped middlewares around the warp application:
53+
we are going to create two wrapped middlewares around the Warp application:
5454

5555
```go
5656
warpKeeper := &warpkeeper.Keeper{}

x/middleware/hook.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"github.com/bcp-innovations/hyperlane-cosmos/util"
77
)
88

9-
// HandleFn is the signature of the Handle function of an Hyperlane application.
9+
// HandleFn is the signature of the Handle function of a Hyperlane application.
1010
type HandleFn = func(ctx context.Context, mailboxId util.HexAddress, message util.HyperlaneMessage) error
1111

1212
type HandleHook interface {
@@ -17,11 +17,11 @@ type HandleHook interface {
1717
var _ HandleHook = &Hook{}
1818

1919
type Hook struct {
20-
// preHandleHook is the behavior expected from a type that hook BEFORE executing
20+
// preHandleFn is the function expected from a hook type which is executed BEFORE
2121
// the Hyperlane application Handle method.
2222
preHandleFn HandleFn
2323

24-
// postHandleHook is the behavior expected from a type that hook AFTER executing
24+
// postHandleFn is the function expected from a hook type which is executed AFTER
2525
// the Hyperlane application Handle method.
2626
postHandleFn HandleFn
2727
}

x/middleware/middleware.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/bcp-innovations/hyperlane-cosmos/util"
99
)
1010

11-
// AppMiddleware defines the behavior required from an Hyperlane application middleware.
11+
// AppMiddleware defines the behavior required from a Hyperlane application middleware.
1212
type AppMiddleware interface {
1313
util.HyperlaneApp
1414
}
@@ -23,7 +23,7 @@ type Middleware struct {
2323

2424
func New(inner util.HyperlaneApp, hook HandleHook) (*Middleware, error) {
2525
if inner == nil {
26-
return nil, errors.New("inner Hyperlane application cannot be nil")
26+
return nil, errors.New("underlying Hyperlane application cannot be nil")
2727
}
2828
if hook == nil {
2929
return nil, errors.New("hook cannot be nil")
@@ -35,17 +35,17 @@ func New(inner util.HyperlaneApp, hook HandleHook) (*Middleware, error) {
3535
}, nil
3636
}
3737

38-
// Exists dispatches the request to the underlying wrapped Hyperlane application.
38+
// Exists dispatches the request to the underlying Hyperlane application.
3939
func (m *Middleware) Exists(ctx context.Context, recipient util.HexAddress) (bool, error) {
4040
return m.HyperlaneApp.Exists(ctx, recipient)
4141
}
4242

43-
// ReceiverIsmId dispatches the request to the underlying wrapped Hyperlane application.
43+
// ReceiverIsmId dispatches the request to the underlying Hyperlane application.
4444
func (m *Middleware) ReceiverIsmId(ctx context.Context, recipient util.HexAddress) (*util.HexAddress, error) {
4545
return m.HyperlaneApp.ReceiverIsmId(ctx, recipient)
4646
}
4747

48-
// Handle allows to execute middleware hooks before and after the underlying wrapped application.
48+
// Handle allows to execute middleware hooks before and after the underlying application.
4949
func (m *Middleware) Handle(ctx context.Context, mailboxID util.HexAddress, message util.HyperlaneMessage) error {
5050
err := m.hook.PreHandle(ctx, mailboxID, message)
5151
if err != nil {

0 commit comments

Comments
 (0)