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

[CORE-827] Scaffolding code for x/ibcratelimit #870

Merged
merged 5 commits into from
Dec 11, 2023
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
146 changes: 74 additions & 72 deletions indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,58 +95,59 @@ import * as _105 from "./clob/query.lcd";
import * as _106 from "./delaymsg/query.lcd";
import * as _107 from "./epochs/query.lcd";
import * as _108 from "./feetiers/query.lcd";
import * as _109 from "./perpetuals/query.lcd";
import * as _110 from "./prices/query.lcd";
import * as _111 from "./rewards/query.lcd";
import * as _112 from "./stats/query.lcd";
import * as _113 from "./subaccounts/query.lcd";
import * as _114 from "./vest/query.lcd";
import * as _115 from "./assets/query.rpc.Query";
import * as _116 from "./blocktime/query.rpc.Query";
import * as _117 from "./bridge/query.rpc.Query";
import * as _118 from "./clob/query.rpc.Query";
import * as _119 from "./delaymsg/query.rpc.Query";
import * as _120 from "./epochs/query.rpc.Query";
import * as _121 from "./feetiers/query.rpc.Query";
import * as _122 from "./ibcratelimit/query.rpc.Query";
import * as _123 from "./perpetuals/query.rpc.Query";
import * as _124 from "./prices/query.rpc.Query";
import * as _125 from "./rewards/query.rpc.Query";
import * as _126 from "./sending/query.rpc.Query";
import * as _127 from "./stats/query.rpc.Query";
import * as _128 from "./subaccounts/query.rpc.Query";
import * as _129 from "./vest/query.rpc.Query";
import * as _130 from "./blocktime/tx.rpc.msg";
import * as _131 from "./bridge/tx.rpc.msg";
import * as _132 from "./clob/tx.rpc.msg";
import * as _133 from "./delaymsg/tx.rpc.msg";
import * as _134 from "./feetiers/tx.rpc.msg";
import * as _135 from "./ibcratelimit/tx.rpc.msg";
import * as _136 from "./perpetuals/tx.rpc.msg";
import * as _137 from "./prices/tx.rpc.msg";
import * as _138 from "./rewards/tx.rpc.msg";
import * as _139 from "./sending/tx.rpc.msg";
import * as _140 from "./stats/tx.rpc.msg";
import * as _141 from "./vest/tx.rpc.msg";
import * as _142 from "./lcd";
import * as _143 from "./rpc.query";
import * as _144 from "./rpc.tx";
import * as _109 from "./ibcratelimit/query.lcd";
import * as _110 from "./perpetuals/query.lcd";
import * as _111 from "./prices/query.lcd";
import * as _112 from "./rewards/query.lcd";
import * as _113 from "./stats/query.lcd";
import * as _114 from "./subaccounts/query.lcd";
import * as _115 from "./vest/query.lcd";
import * as _116 from "./assets/query.rpc.Query";
import * as _117 from "./blocktime/query.rpc.Query";
import * as _118 from "./bridge/query.rpc.Query";
import * as _119 from "./clob/query.rpc.Query";
import * as _120 from "./delaymsg/query.rpc.Query";
import * as _121 from "./epochs/query.rpc.Query";
import * as _122 from "./feetiers/query.rpc.Query";
import * as _123 from "./ibcratelimit/query.rpc.Query";
import * as _124 from "./perpetuals/query.rpc.Query";
import * as _125 from "./prices/query.rpc.Query";
import * as _126 from "./rewards/query.rpc.Query";
import * as _127 from "./sending/query.rpc.Query";
import * as _128 from "./stats/query.rpc.Query";
import * as _129 from "./subaccounts/query.rpc.Query";
import * as _130 from "./vest/query.rpc.Query";
import * as _131 from "./blocktime/tx.rpc.msg";
import * as _132 from "./bridge/tx.rpc.msg";
import * as _133 from "./clob/tx.rpc.msg";
import * as _134 from "./delaymsg/tx.rpc.msg";
import * as _135 from "./feetiers/tx.rpc.msg";
import * as _136 from "./ibcratelimit/tx.rpc.msg";
import * as _137 from "./perpetuals/tx.rpc.msg";
import * as _138 from "./prices/tx.rpc.msg";
import * as _139 from "./rewards/tx.rpc.msg";
import * as _140 from "./sending/tx.rpc.msg";
import * as _141 from "./stats/tx.rpc.msg";
import * as _142 from "./vest/tx.rpc.msg";
import * as _143 from "./lcd";
import * as _144 from "./rpc.query";
import * as _145 from "./rpc.tx";
export namespace dydxprotocol {
export const assets = { ..._5,
..._6,
..._7,
..._8,
..._102,
..._115
..._116
};
export const blocktime = { ..._9,
..._10,
..._11,
..._12,
..._13,
..._103,
..._116,
..._130
..._117,
..._131
};
export const bridge = { ..._14,
..._15,
Expand All @@ -155,8 +156,8 @@ export namespace dydxprotocol {
..._18,
..._19,
..._104,
..._117,
..._131
..._118,
..._132
};
export const clob = { ..._20,
..._21,
Expand All @@ -173,8 +174,8 @@ export namespace dydxprotocol {
..._32,
..._33,
..._105,
..._118,
..._132
..._119,
..._133
};
export namespace daemons {
export const bridge = { ..._34
Expand All @@ -190,30 +191,31 @@ export namespace dydxprotocol {
..._40,
..._41,
..._106,
..._119,
..._133
..._120,
..._134
};
export const epochs = { ..._42,
..._43,
..._44,
..._107,
..._120
..._121
};
export const feetiers = { ..._45,
..._46,
..._47,
..._48,
..._108,
..._121,
..._134
..._122,
..._135
};
export const ibcratelimit = { ..._49,
..._50,
..._51,
..._52,
..._53,
..._122,
..._135
..._109,
..._123,
..._136
};
export namespace indexer {
export const events = { ..._54
Expand All @@ -239,62 +241,62 @@ export namespace dydxprotocol {
..._64,
..._65,
..._66,
..._109,
..._123,
..._136
..._110,
..._124,
..._137
};
export const prices = { ..._67,
..._68,
..._69,
..._70,
..._71,
..._110,
..._124,
..._137
..._111,
..._125,
..._138
};
export const rewards = { ..._72,
..._73,
..._74,
..._75,
..._76,
..._111,
..._125,
..._138
..._112,
..._126,
..._139
};
export const sending = { ..._77,
..._78,
..._79,
..._80,
..._126,
..._139
..._127,
..._140
};
export const stats = { ..._81,
..._82,
..._83,
..._84,
..._85,
..._112,
..._127,
..._140
..._113,
..._128,
..._141
};
export const subaccounts = { ..._86,
..._87,
..._88,
..._89,
..._90,
..._113,
..._128
..._114,
..._129
};
export const vest = { ..._91,
..._92,
..._93,
..._94,
..._114,
..._129,
..._141
..._115,
..._130,
..._142
};
export const ClientFactory = { ..._142,
..._143,
..._144
export const ClientFactory = { ..._143,
..._144,
..._145
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { LCDClient } from "@osmonauts/lcd";
import { ListLimitParamsRequest, ListLimitParamsResponseSDKType, QueryCapacityByDenomRequest, QueryCapacityByDenomResponseSDKType } from "./query";
export class LCDQueryClient {
req: LCDClient;

constructor({
requestClient
}: {
requestClient: LCDClient;
}) {
this.req = requestClient;
this.listLimitParams = this.listLimitParams.bind(this);
this.capacityByDenom = this.capacityByDenom.bind(this);
}
/* List all limit params. */


async listLimitParams(_params: ListLimitParamsRequest = {}): Promise<ListLimitParamsResponseSDKType> {
const endpoint = `dydxprotocol/v4/ibcratelimit/list_limit_params`;
return await this.req.get<ListLimitParamsResponseSDKType>(endpoint);
}
/* Query capacity by denom. */


async capacityByDenom(params: QueryCapacityByDenomRequest): Promise<QueryCapacityByDenomResponseSDKType> {
const options: any = {
params: {}
Comment on lines +26 to +27
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The options object in capacityByDenom is typed as any. To take advantage of TypeScript's type safety, define a specific type for the options object.

- const options: any = {
+ interface CapacityByDenomOptions {
+   params: {
+     denom?: string;
+   };
+ }
+ const options: CapacityByDenomOptions = {
    params: {}
  };

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
const options: any = {
params: {}
interface CapacityByDenomOptions {
params: {
denom?: string;
};
}
const options: CapacityByDenomOptions = {
params: {}

};

if (typeof params?.denom !== "undefined") {
options.params.denom = params.denom;
}

const endpoint = `dydxprotocol/v4/ibcratelimit/capacity_by_denom`;
return await this.req.get<QueryCapacityByDenomResponseSDKType>(endpoint, options);
}
Comment on lines +25 to +36
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding error handling within the capacityByDenom method to manage HTTP request failures gracefully and provide more context-specific error messages or handle retries.


}
3 changes: 3 additions & 0 deletions indexer/packages/v4-protos/src/codegen/dydxprotocol/lcd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export const createLCDClient = async ({
feetiers: new (await import("./feetiers/query.lcd")).LCDQueryClient({
requestClient
}),
ibcratelimit: new (await import("./ibcratelimit/query.lcd")).LCDQueryClient({
requestClient
}),
perpetuals: new (await import("./perpetuals/query.lcd")).LCDQueryClient({
requestClient
}),
Expand Down
12 changes: 10 additions & 2 deletions proto/dydxprotocol/ibcratelimit/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,26 @@ syntax = "proto3";
package dydxprotocol.ibcratelimit;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "dydxprotocol/ibcratelimit/limit_params.proto";

option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/ibcratelimit/types";

// Query defines the gRPC querier service.
service Query {
// List all limit params.
rpc ListLimitParams(ListLimitParamsRequest) returns (ListLimitParamsResponse);
rpc ListLimitParams(ListLimitParamsRequest)
returns (ListLimitParamsResponse) {
option (google.api.http).get =
"/dydxprotocol/v4/ibcratelimit/list_limit_params";
}

// Query capacity by denom.
rpc CapacityByDenom(QueryCapacityByDenomRequest)
returns (QueryCapacityByDenomResponse);
returns (QueryCapacityByDenomResponse) {
option (google.api.http).get =
"/dydxprotocol/v4/ibcratelimit/capacity_by_denom";
}
}

// ListLimitParamsRequest is a request type of the ListLimitParams RPC method.
Expand Down
26 changes: 26 additions & 0 deletions protocol/x/ibcratelimit/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package cli

import (
"fmt"

"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"
"github.com/dydxprotocol/v4-chain/protocol/x/ibcratelimit/types"
)

// GetQueryCmd returns the cli query commands for this module
func GetQueryCmd(queryRoute string) *cobra.Command {
// Group ibcratelimit queries under a subcommand
cmd := &cobra.Command{
Use: types.ModuleName,
Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName),
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}

// TODO(CORE-823): implement query for `x/ibcratelimit`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TODO comment indicates that the query command implementation for x/ibcratelimit is pending. Ensure that this is tracked in the project's issue tracking system to avoid missing this implementation in future updates.


return cmd
}
10 changes: 10 additions & 0 deletions protocol/x/ibcratelimit/client/cli/query_params.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package cli

import (
"github.com/spf13/cobra"
)

func CmdQueryParams() *cobra.Command {
// TODO(CORE-823): implement query for `x/ibcratelimit`
return nil
}
15 changes: 15 additions & 0 deletions protocol/x/ibcratelimit/client/cli/query_params_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//go:build all || integration_test

package cli_test

import (
"strconv"
"testing"
)

// Prevent strconv unused error
var _ = strconv.IntSize

func TestQueryParams(t *testing.T) {
// TODO(CORE-823): implement query for `x/ibcratelimit`
}
Comment on lines +13 to +15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TestQueryParams function is currently a placeholder. It's important to implement the actual test cases to ensure the x/ibcratelimit module's query functionality works as expected. This should be prioritized to maintain high code quality and to catch any potential issues early.

Loading
Loading