From a2f12b64f47138cbc94a856cfd744cb126749fc9 Mon Sep 17 00:00:00 2001 From: Cosmic Vagabond <121588426+cosmic-vagabond@users.noreply.github.com> Date: Fri, 1 Sep 2023 10:10:43 +0200 Subject: [PATCH] feat: use all price response --- app/wasm.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/app/wasm.go b/app/wasm.go index 3fe4fe44b..3c361c7ac 100644 --- a/app/wasm.go +++ b/app/wasm.go @@ -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 @@ -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") } @@ -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"` +}