-
Notifications
You must be signed in to change notification settings - Fork 620
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(08-wasm): querier plugins implemented (#5345)
* imp: moved gas to internal * fix: fixed compiler complaints * feat: added 'QueryRouter' interface * imp: passing the queryRouter to keeper * Revert "fix: fixed compiler complaints" This reverts commit 208e314. * Revert "imp: moved gas to internal" This reverts commit b45b605. * fix(test): fixed keeper_test.go * imp: initial querier template * imp: moved querier to types * fix: compiler complaints * imp: removed querier from keeper * feat: including default querier * imp: added options * feat: querier implemented fully * docs: improved godocs * imp: improved the querier * style: improved styling of querier * fix: fixed options * fix: fixed options not being passed with config * style: renamed variables * imp: added review items * imp: review items * imp: set and get query plugins made private * docs: added more godocs * fix: default plugin not set * imp: review items * docs: added a godoc --------- Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
- Loading branch information
Showing
13 changed files
with
574 additions
and
78 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 was deleted.
Oops, something went wrong.
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
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
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,32 @@ | ||
package keeper | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/internal/ibcwasm" | ||
"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types" | ||
) | ||
|
||
// Option is an extension point to instantiate keeper with non default values | ||
type Option interface { | ||
apply(*Keeper) | ||
} | ||
|
||
type optsFn func(*Keeper) | ||
|
||
func (f optsFn) apply(keeper *Keeper) { | ||
f(keeper) | ||
} | ||
|
||
// WithQueryPlugins is an optional constructor parameter to pass custom query plugins for wasmVM requests. | ||
// Missing fields will be filled with default queriers. | ||
func WithQueryPlugins(plugins *types.QueryPlugins) Option { | ||
return optsFn(func(_ *Keeper) { | ||
currentPlugins, ok := ibcwasm.GetQueryPlugins().(*types.QueryPlugins) | ||
if !ok { | ||
panic(errors.New("invalid query plugins type")) | ||
} | ||
newPlugins := currentPlugins.Merge(plugins) | ||
ibcwasm.SetQueryPlugins(&newPlugins) | ||
}) | ||
} |
Oops, something went wrong.