Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable whitelist stableswap #289

Merged
merged 4 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import (
"github.com/initia-labs/initia/app/keepers"
"github.com/initia-labs/initia/app/params"
cryptocodec "github.com/initia-labs/initia/crypto/codec"
initiatx "github.com/initia-labs/initia/tx"
moveconfig "github.com/initia-labs/initia/x/move/config"
movetypes "github.com/initia-labs/initia/x/move/types"
rewardtypes "github.com/initia-labs/initia/x/reward/types"
Expand Down Expand Up @@ -439,6 +440,9 @@ func (app *InitiaApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.API
// Register new tx routes from grpc-gateway.
authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

// Register new tx query routes from grpc-gateway.
initiatx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

// Register new tendermint queries routes from grpc-gateway.
cmtservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

Expand All @@ -463,10 +467,8 @@ func (app *InitiaApp) Simulate(txBytes []byte) (sdk.GasInfo, *sdk.Result, error)

// RegisterTxService implements the Application.RegisterTxService method.
func (app *InitiaApp) RegisterTxService(clientCtx client.Context) {
authtx.RegisterTxService(
app.BaseApp.GRPCQueryRouter(), clientCtx,
app.Simulate, app.interfaceRegistry,
)
authtx.RegisterTxService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.Simulate, app.interfaceRegistry)
initiatx.RegisterTxQuery(app.GRPCQueryRouter(), app.MoveKeeper.DexKeeper())
}

// RegisterTendermintService implements the Application.RegisterTendermintService method.
Expand Down
3 changes: 3 additions & 0 deletions client/docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@
"Params": "MarketMapParams"
}
}
},
{
"url": "./tmp-swagger-gen/initia/tx/v1/query.swagger.json"
}
]
}
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

152 changes: 152 additions & 0 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54808,6 +54808,120 @@ paths:
format: byte
tags:
- Query
/initia/tx/v1/gas_prices:
get:
summary: GasPrices returns the gas prices for the network.
operationId: GasPrices
responses:
'200':
description: A successful response.
schema:
type: object
properties:
gas_prices:
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
DecCoin defines a token with a denomination and a decimal
amount.


NOTE: The amount field is an Dec which implements the custom
method

signatures required by gogoproto.
description: >-
QueryGasPricesResponse is the response type for the
Query/GasPrices RPC method.
default:
description: An unexpected error response.
schema:
type: object
properties:
error:
type: string
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
type_url:
type: string
value:
type: string
format: byte
tags:
- Query
/initia/tx/v1/gas_prices/{denom}:
get:
summary: GasPrice returns the gas price for the network.
operationId: GasPrice
responses:
'200':
description: A successful response.
schema:
type: object
properties:
gas_price:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
DecCoin defines a token with a denomination and a decimal
amount.


NOTE: The amount field is an Dec which implements the custom
method

signatures required by gogoproto.
description: >-
QueryGasPriceResponse is the response type for the Query/GasPrice
RPC method.
default:
description: An unexpected error response.
schema:
type: object
properties:
error:
type: string
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
type_url:
type: string
value:
type: string
format: byte
parameters:
- name: denom
description: denom defines the denomination of the gas price to query.
in: path
required: true
type: string
tags:
- Query
definitions:
cosmos.auth.v1beta1.AddressBytesToStringResponse:
type: object
Expand Down Expand Up @@ -89727,3 +89841,41 @@ definitions:
feed is scaled to a number of decimal places and has a minimum number of

providers required to consider the ticker valid.
initia.tx.v1.QueryGasPriceResponse:
type: object
properties:
gas_price:
type: object
properties:
denom:
type: string
amount:
type: string
description: |-
DecCoin defines a token with a denomination and a decimal amount.

NOTE: The amount field is an Dec which implements the custom method
signatures required by gogoproto.
description: >-
QueryGasPriceResponse is the response type for the Query/GasPrice RPC
method.
initia.tx.v1.QueryGasPricesResponse:
type: object
properties:
gas_prices:
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: |-
DecCoin defines a token with a denomination and a decimal amount.

NOTE: The amount field is an Dec which implements the custom method
signatures required by gogoproto.
description: >-
QueryGasPricesResponse is the response type for the Query/GasPrices RPC
method.
47 changes: 47 additions & 0 deletions proto/initia/tx/v1/query.proto
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";
beer-1 marked this conversation as resolved.
Show resolved Hide resolved
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
];
}
54 changes: 54 additions & 0 deletions tx/service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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) {
_ = txtypes.RegisterQueryHandlerClient(context.Background(), mux, txtypes.NewQueryClient(clientConn))
}
Loading
Loading