Skip to content

Commit

Permalink
refactor: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mennatnaga committed Dec 1, 2023
1 parent 87e92ad commit b4b6ed7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ func NewApp(

randomnessQueryPlugin := keeper.NewQuerierImpl(app.RandomnessKeeper)
queryPluginOpt := wasmkeeper.WithQueryPlugins(&wasmkeeper.QueryPlugins{
Custom: keeper.CustomQuerier(randomnessQueryPlugin),
Custom: keeper.SeedQueryPlugin(randomnessQueryPlugin),
})
wasmOpts = append([]wasm.Option{queryPluginOpt}, wasmOpts...)

Expand Down
10 changes: 1 addition & 9 deletions x/randomness/keeper/query_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,25 @@ package keeper

import (
"encoding/json"
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/sedaprotocol/seda-chain/x/randomness/types"
)

func CustomQuerier(randomnessKeeper *Querier) func(ctx sdk.Context, request json.RawMessage) ([]byte, error) {
func SeedQueryPlugin(randomnessKeeper *Querier) func(ctx sdk.Context, request json.RawMessage) ([]byte, error) {
return func(ctx sdk.Context, request json.RawMessage) ([]byte, error) {
ctx.Logger().Info("Received request")
ctx.Logger().Info(fmt.Sprintf("% x", string(request)))

var contractQuery types.QuerySeedRequest
if err := json.Unmarshal(request, &contractQuery); err != nil {
return nil, sdkerrors.Wrap(err, "seed query")
}

ctx.Logger().Info("Parsed json")

seedQueryResponse, err := randomnessKeeper.Seed(ctx, &contractQuery)
if err != nil {
return nil, sdkerrors.Wrap(err, "seed query")
}

ctx.Logger().Info("Get seed")
ctx.Logger().Info(seedQueryResponse.Seed)

bz, err := json.Marshal(seedQueryResponse)
if err != nil {
return nil, sdkerrors.Wrap(err, "seed query response")
Expand Down

0 comments on commit b4b6ed7

Please sign in to comment.