Skip to content

Commit

Permalink
feat: use all price response
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmic-vagabond committed Sep 1, 2023
1 parent 29af992 commit a2f12b6
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions app/wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
query "github.com/cosmos/cosmos-sdk/types/query"
oraclekeeper "github.com/elys-network/elys/x/oracle/keeper"
"github.com/elys-network/elys/x/oracle/types"
oracletypes "github.com/elys-network/elys/x/oracle/types"
)

// AllCapabilities returns all capabilities available with the current wasmvm
Expand Down Expand Up @@ -66,13 +66,18 @@ func CustomQuerier(qp *QueryPlugin) func(ctx sdk.Context, request json.RawMessag
pagination := contractQuery.PriceAll.Pagination

// Calling the PriceAll function and handling its response
priceResponse, err := qp.oracleKeeper.PriceAll(ctx, &types.QueryAllPriceRequest{Pagination: pagination})
priceResponse, err := qp.oracleKeeper.PriceAll(ctx, &oracletypes.QueryAllPriceRequest{Pagination: pagination})
if err != nil {
return nil, errorsmod.Wrap(err, "failed to get all prices")
}

res := AllPriceResponse{
Price: priceResponse.Price,
Pagination: priceResponse.Pagination,
}

// Serializing the response to a JSON byte array
responseBytes, err := json.Marshal(*priceResponse)
responseBytes, err := json.Marshal(res)
if err != nil {
return nil, errorsmod.Wrap(err, "failed to serialize price response")
}
Expand All @@ -90,6 +95,10 @@ type ElysQuery struct {
}

type PriceAll struct {
// oracletypes.QueryAllPriceRequest
Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"`
}

type AllPriceResponse struct {
Price []oracletypes.Price `protobuf:"bytes,1,rep,name=price,proto3" json:"price"`
Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
}

0 comments on commit a2f12b6

Please sign in to comment.