-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
2,520 additions
and
429 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 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 |
---|---|---|
|
@@ -271,6 +271,9 @@ | |
"Params": "MarketMapParams" | ||
} | ||
} | ||
}, | ||
{ | ||
"url": "./tmp-swagger-gen/initia/tx/v1/query.swagger.json" | ||
} | ||
] | ||
} |
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
syntax = "proto3"; | ||
package initia.tx.v1; | ||
|
||
import "cosmos/base/v1beta1/coin.proto"; | ||
import "gogoproto/gogo.proto"; | ||
import "google/api/annotations.proto"; | ||
|
||
option go_package = "github.com/initia-labs/initia/tx/types"; | ||
|
||
// Query provides defines the gRPC querier service. | ||
service Query { | ||
// GasPrices returns the gas prices for the network. | ||
rpc GasPrices(QueryGasPricesRequest) returns (QueryGasPricesResponse) { | ||
option (google.api.http).get = "/initia/tx/v1/gas_prices"; | ||
} | ||
// GasPrice returns the gas price for the network. | ||
rpc GasPrice(QueryGasPriceRequest) returns (QueryGasPriceResponse) { | ||
option (google.api.http).get = "/initia/tx/v1/gas_prices/{denom}"; | ||
} | ||
} | ||
|
||
// QueryGasPricesRequest is the request type for the Query/GasPrices RPC method. | ||
message QueryGasPricesRequest {} | ||
|
||
// QueryGasPricesResponse is the response type for the Query/GasPrices RPC method. | ||
message QueryGasPricesResponse { | ||
repeated cosmos.base.v1beta1.DecCoin gas_prices = 1 [ | ||
(gogoproto.moretags) = "yaml:\"gas_prices\"", | ||
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", | ||
(gogoproto.nullable) = false | ||
]; | ||
} | ||
|
||
// QueryGasPriceRequest is the request type for the Query/GasPrice RPC method. | ||
message QueryGasPriceRequest { | ||
// denom defines the denomination of the gas price to query. | ||
string denom = 1; | ||
} | ||
|
||
// QueryGasPriceResponse is the response type for the Query/GasPrice RPC method. | ||
message QueryGasPriceResponse { | ||
cosmos.base.v1beta1.DecCoin gas_price = 1 [ | ||
(gogoproto.moretags) = "yaml:\"gas_price\"", | ||
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.DecCoin", | ||
(gogoproto.nullable) = false | ||
]; | ||
} |
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,57 @@ | ||
package tx | ||
|
||
import ( | ||
"context" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
gogogrpc "github.com/cosmos/gogoproto/grpc" | ||
"github.com/grpc-ecosystem/grpc-gateway/runtime" | ||
|
||
txtypes "github.com/initia-labs/initia/tx/types" | ||
) | ||
|
||
type txServer struct { | ||
gpk GasPriceKeeper | ||
} | ||
|
||
type GasPriceKeeper interface { | ||
GasPrices(ctx context.Context) (sdk.DecCoins, error) | ||
GasPrice(ctx context.Context, denom string) (sdk.DecCoin, error) | ||
} | ||
|
||
func NewTxServer(k GasPriceKeeper) txtypes.QueryServer { | ||
return &txServer{gpk: k} | ||
} | ||
|
||
// GasPrices implements QueryServer. | ||
func (t *txServer) GasPrices(ctx context.Context, req *txtypes.QueryGasPricesRequest) (*txtypes.QueryGasPricesResponse, error) { | ||
prices, err := t.gpk.GasPrices(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &txtypes.QueryGasPricesResponse{GasPrices: prices}, nil | ||
} | ||
|
||
// GasPrice implements QueryServer. | ||
func (t *txServer) GasPrice(ctx context.Context, req *txtypes.QueryGasPriceRequest) (*txtypes.QueryGasPriceResponse, error) { | ||
price, err := t.gpk.GasPrice(ctx, req.Denom) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &txtypes.QueryGasPriceResponse{GasPrice: price}, nil | ||
} | ||
|
||
// RegisterTxQuery registers the tx query on the gRPC router. | ||
func RegisterTxQuery(qrt gogogrpc.Server, gpk GasPriceKeeper) { | ||
txtypes.RegisterQueryServer(qrt, NewTxServer(gpk)) | ||
} | ||
|
||
// RegisterGRPCGatewayRoutes mounts the tx query's GRPC-gateway routes on the given Mux. | ||
func RegisterGRPCGatewayRoutes(clientConn gogogrpc.ClientConn, mux *runtime.ServeMux) { | ||
err := txtypes.RegisterQueryHandlerClient(context.Background(), mux, txtypes.NewQueryClient(clientConn)) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} |
Oops, something went wrong.