Skip to content

Commit

Permalink
enable whitelist stableswap
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Oct 22, 2024
1 parent 2c304ca commit b6fedbe
Show file tree
Hide file tree
Showing 31 changed files with 2,520 additions and 429 deletions.
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)

Check warning on line 445 in app/app.go

View check run for this annotation

Codecov / codecov/patch

app/app.go#L443-L445

Added lines #L443 - L445 were not covered by tests
// 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())

Check warning on line 471 in app/app.go

View check run for this annotation

Codecov / codecov/patch

app/app.go#L470-L471

Added lines #L470 - L471 were not covered by tests
}

// 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";
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
];
}
57 changes: 57 additions & 0 deletions tx/service.go
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}

Check warning on line 23 in tx/service.go

View check run for this annotation

Codecov / codecov/patch

tx/service.go#L22-L23

Added lines #L22 - L23 were not covered by tests
}

// 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
}

Check warning on line 31 in tx/service.go

View check run for this annotation

Codecov / codecov/patch

tx/service.go#L27-L31

Added lines #L27 - L31 were not covered by tests

return &txtypes.QueryGasPricesResponse{GasPrices: prices}, nil

Check warning on line 33 in tx/service.go

View check run for this annotation

Codecov / codecov/patch

tx/service.go#L33

Added line #L33 was not covered by tests
}

// 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
}

Check warning on line 41 in tx/service.go

View check run for this annotation

Codecov / codecov/patch

tx/service.go#L37-L41

Added lines #L37 - L41 were not covered by tests

return &txtypes.QueryGasPriceResponse{GasPrice: price}, nil

Check warning on line 43 in tx/service.go

View check run for this annotation

Codecov / codecov/patch

tx/service.go#L43

Added line #L43 was not covered by tests
}

// RegisterTxQuery registers the tx query on the gRPC router.
func RegisterTxQuery(qrt gogogrpc.Server, gpk GasPriceKeeper) {
txtypes.RegisterQueryServer(qrt, NewTxServer(gpk))

Check warning on line 48 in tx/service.go

View check run for this annotation

Codecov / codecov/patch

tx/service.go#L47-L48

Added lines #L47 - L48 were not covered by tests
}

// 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)

Check warning on line 55 in tx/service.go

View check run for this annotation

Codecov / codecov/patch

tx/service.go#L52-L55

Added lines #L52 - L55 were not covered by tests
}
}
Loading

0 comments on commit b6fedbe

Please sign in to comment.