Skip to main content
The StackBuilder struct is a new primitive for wiring middleware in a simpler and less error-prone manner. It is not a breaking change thus the existing method of wiring middleware still works, though it is highly recommended to transition to the new wiring method. Refer to the integration guide to understand how to use this new middleware to improve middleware wiring in the chain application setup.

Migrations for Application Developers

In order to be wired with the new StackBuilder primitive, applications and middlewares must implement new methods as part of their respective interfaces. IBC Applications must implement a new SetICS4Wrapper which will set the ICS4Wrapper through which the application will call SendPacket and WriteAcknowledgement. It is recommended that IBC applications are initialized first with the IBC ChannelKeeper directly, and then modified with a middleware ICS4Wrapper during the stack wiring.
Many applications have a stateful keeper that executes the logic for sending packets and writing acknowledgements. In this case, the keeper in the application must be a pointer reference so that it can be modified in place after initialization. The initialization should be modified to no longer take in an addition ics4Wrapper as this gets modified later by SetICS4Wrapper. The constructor function must also return a pointer reference so that it may be modified in-place by the stack builder. Below is an example IBCModule that supports the stack builder wiring. E.g.

Migration for Middleware Developers

Since Middleware is itself implement the IBC application interface, it must also implement SetICS4Wrapper in the same way as IBC applications. Additionally, IBC Middleware has an underlying IBC application that it calls into as well. Previously this application would be set in the middleware upon construction. With the stack builder primitive, the application is only set during upon calling stack.Build(). Thus, middleware is additionally responsible for implementing the new method: SetUnderlyingApplication:
The initialization should not include the ICS4Wrapper and application as this gets set later. The constructor function for Middlewares must be modified to return a pointer reference so that it can be modified in place by the stack builder. Below is an example middleware setup: