Skip to content

Commit

Permalink
Scaffolding x/govplus module (#1011)
Browse files Browse the repository at this point in the history
  • Loading branch information
roy-dydx authored Jan 25, 2024
1 parent d400ce9 commit 40b58ab
Show file tree
Hide file tree
Showing 32 changed files with 1,934 additions and 181 deletions.
341 changes: 175 additions & 166 deletions indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import * as _m0 from "protobufjs/minimal";
import { DeepPartial } from "../../helpers";
/** GenesisState defines the govplus module's genesis state. */

export interface GenesisState {}
/** GenesisState defines the govplus module's genesis state. */

export interface GenesisStateSDKType {}

function createBaseGenesisState(): GenesisState {
return {};
}

export const GenesisState = {
encode(_: GenesisState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): GenesisState {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseGenesisState();

while (reader.pos < end) {
const tag = reader.uint32();

switch (tag >>> 3) {
default:
reader.skipType(tag & 7);
break;
}
}

return message;
},

fromPartial(_: DeepPartial<GenesisState>): GenesisState {
const message = createBaseGenesisState();
return message;
}

};
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Rpc } from "../../helpers";
import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate";
/** Query defines the gRPC querier service. */

export interface Query {}
export class QueryClientImpl implements Query {
private readonly rpc: Rpc;

constructor(rpc: Rpc) {
this.rpc = rpc;
}

}
export const createRpcQueryExtension = (base: QueryClient) => {
const rpc = createProtobufRpcClient(base);
const queryService = new QueryClientImpl(rpc);
return {};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const createRPCQueryClient = async ({
delaymsg: (await import("./delaymsg/query.rpc.Query")).createRpcQueryExtension(client),
epochs: (await import("./epochs/query.rpc.Query")).createRpcQueryExtension(client),
feetiers: (await import("./feetiers/query.rpc.Query")).createRpcQueryExtension(client),
govplus: (await import("./govplus/query.rpc.Query")).createRpcQueryExtension(client),
perpetuals: (await import("./perpetuals/query.rpc.Query")).createRpcQueryExtension(client),
prices: (await import("./prices/query.rpc.Query")).createRpcQueryExtension(client),
ratelimit: (await import("./ratelimit/query.rpc.Query")).createRpcQueryExtension(client),
Expand Down
4 changes: 2 additions & 2 deletions indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import * as _95 from "./gogo";
export const gogoproto = { ..._95
import * as _98 from "./gogo";
export const gogoproto = { ..._98
};
24 changes: 12 additions & 12 deletions indexer/packages/v4-protos/src/codegen/google/bundle.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import * as _96 from "./api/annotations";
import * as _97 from "./api/http";
import * as _98 from "./protobuf/descriptor";
import * as _99 from "./protobuf/duration";
import * as _100 from "./protobuf/timestamp";
import * as _101 from "./protobuf/any";
import * as _99 from "./api/annotations";
import * as _100 from "./api/http";
import * as _101 from "./protobuf/descriptor";
import * as _102 from "./protobuf/duration";
import * as _103 from "./protobuf/timestamp";
import * as _104 from "./protobuf/any";
export namespace google {
export const api = { ..._96,
..._97
export const api = { ..._99,
..._100
};
export const protobuf = { ..._98,
..._99,
..._100,
..._101
export const protobuf = { ..._101,
..._102,
..._103,
..._104
};
}
7 changes: 7 additions & 0 deletions proto/dydxprotocol/govplus/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syntax = "proto3";
package dydxprotocol.govplus;

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

// GenesisState defines the govplus module's genesis state.
message GenesisState {}
7 changes: 7 additions & 0 deletions proto/dydxprotocol/govplus/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syntax = "proto3";
package dydxprotocol.govplus;

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

// Query defines the gRPC querier service.
service Query {}
7 changes: 7 additions & 0 deletions proto/dydxprotocol/govplus/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syntax = "proto3";
package dydxprotocol.govplus;

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

// Msg defines the Msg service.
service Msg {}
22 changes: 21 additions & 1 deletion protocol/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package app
import (
"context"
"encoding/json"
custommodule "github.com/dydxprotocol/v4-chain/protocol/app/module"
"io"
"math/big"
"net/http"
Expand All @@ -13,6 +12,8 @@ import (
"sync"
"time"

custommodule "github.com/dydxprotocol/v4-chain/protocol/app/module"

autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
"cosmossdk.io/log"
Expand Down Expand Up @@ -144,6 +145,9 @@ import (
feetiersmodule "github.com/dydxprotocol/v4-chain/protocol/x/feetiers"
feetiersmodulekeeper "github.com/dydxprotocol/v4-chain/protocol/x/feetiers/keeper"
feetiersmoduletypes "github.com/dydxprotocol/v4-chain/protocol/x/feetiers/types"
govplusmodule "github.com/dydxprotocol/v4-chain/protocol/x/govplus"
govplusmodulekeeper "github.com/dydxprotocol/v4-chain/protocol/x/govplus/keeper"
govplusmoduletypes "github.com/dydxprotocol/v4-chain/protocol/x/govplus/types"
perpetualsmodule "github.com/dydxprotocol/v4-chain/protocol/x/perpetuals"
perpetualsmodulekeeper "github.com/dydxprotocol/v4-chain/protocol/x/perpetuals/keeper"
perpetualsmoduletypes "github.com/dydxprotocol/v4-chain/protocol/x/perpetuals/types"
Expand Down Expand Up @@ -252,6 +256,7 @@ type App struct {
RatelimitKeeper ratelimitmodulekeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
ConsensusParamsKeeper consensusparamkeeper.Keeper
GovPlusKeeper govplusmodulekeeper.Keeper

PricesKeeper pricesmodulekeeper.Keeper

Expand Down Expand Up @@ -977,6 +982,16 @@ func New(
app.SubaccountsKeeper,
)

app.GovPlusKeeper = *govplusmodulekeeper.NewKeeper(
appCodec,
keys[govplusmoduletypes.StoreKey],
[]string{
lib.GovModuleAddress.String(),
delaymsgmoduletypes.ModuleAddress.String(),
},
)
govPlusModule := govplusmodule.NewAppModule(appCodec, app.GovPlusKeeper)

/**** Module Options ****/

// NOTE: we may consider parsing `appOpts` inside module constructors. For the moment
Expand Down Expand Up @@ -1039,6 +1054,7 @@ func New(
subaccountsModule,
clobModule,
sendingModule,
govPlusModule,
delayMsgModule,
epochsModule,
rateLimitModule,
Expand Down Expand Up @@ -1083,6 +1099,7 @@ func New(
vestmoduletypes.ModuleName,
rewardsmoduletypes.ModuleName,
sendingmoduletypes.ModuleName,
govplusmoduletypes.ModuleName,
delaymsgmoduletypes.ModuleName,
)

Expand Down Expand Up @@ -1121,6 +1138,7 @@ func New(
vestmoduletypes.ModuleName,
rewardsmoduletypes.ModuleName,
epochsmoduletypes.ModuleName,
govplusmoduletypes.ModuleName,
delaymsgmoduletypes.ModuleName,
blocktimemoduletypes.ModuleName, // Must be last
)
Expand Down Expand Up @@ -1162,6 +1180,7 @@ func New(
vestmoduletypes.ModuleName,
rewardsmoduletypes.ModuleName,
sendingmoduletypes.ModuleName,
govplusmoduletypes.ModuleName,
delaymsgmoduletypes.ModuleName,
)

Expand Down Expand Up @@ -1199,6 +1218,7 @@ func New(
vestmoduletypes.ModuleName,
rewardsmoduletypes.ModuleName,
sendingmoduletypes.ModuleName,
govplusmoduletypes.ModuleName,
delaymsgmoduletypes.ModuleName,

// Auth must be migrated after staking.
Expand Down
2 changes: 2 additions & 0 deletions protocol/app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
delaymsgmodule "github.com/dydxprotocol/v4-chain/protocol/x/delaymsg"
epochsmodule "github.com/dydxprotocol/v4-chain/protocol/x/epochs"
feetiersmodule "github.com/dydxprotocol/v4-chain/protocol/x/feetiers"
govplusmodule "github.com/dydxprotocol/v4-chain/protocol/x/govplus"
perpetualsmodule "github.com/dydxprotocol/v4-chain/protocol/x/perpetuals"
pricesmodule "github.com/dydxprotocol/v4-chain/protocol/x/prices"
ratelimitmodule "github.com/dydxprotocol/v4-chain/protocol/x/ratelimit"
Expand Down Expand Up @@ -213,6 +214,7 @@ func TestModuleBasics(t *testing.T) {
vestmodule.AppModuleBasic{},
rewardsmodule.AppModuleBasic{},
sendingmodule.AppModuleBasic{},
govplusmodule.AppModuleBasic{},
delaymsgmodule.AppModuleBasic{},
epochsmodule.AppModuleBasic{},
ratelimitmodule.AppModuleBasic{},
Expand Down
1 change: 1 addition & 0 deletions protocol/app/testdata/default_genesis_state.json
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@
},
"constitution": ""
},
"govplus": {},
"ibc": {
"client_genesis": {
"clients": [],
Expand Down
2 changes: 2 additions & 0 deletions protocol/app/upgrades/v4.0.0/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
circuittypes "cosmossdk.io/x/circuit/types"
icacontrollertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types"
"github.com/dydxprotocol/v4-chain/protocol/app/upgrades"
govplustypes "github.com/dydxprotocol/v4-chain/protocol/x/govplus/types"
)

const (
Expand All @@ -15,6 +16,7 @@ var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
StoreUpgrades: store.StoreUpgrades{
Added: []string{
govplustypes.StoreKey,
// Add circuittypes as per 0.47 to 0.50 upgrade handler
// https://github.com/cosmos/cosmos-sdk/blob/b7d9d4c8a9b6b8b61716d2023982d29bdc9839a6/simapp/upgrades.go#L21
circuittypes.ModuleName,
Expand Down
1 change: 1 addition & 0 deletions protocol/scripts/genesis/sample_pregenesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,7 @@
"starting_proposal_id": "1",
"votes": []
},
"govplus": {},
"ibc": {
"channel_genesis": {
"ack_sequences": [],
Expand Down
1 change: 1 addition & 0 deletions protocol/testutil/constants/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,7 @@ const GenesisState = `{
"starting_proposal_id": "1",
"votes": []
},
"govplus": {},
"ibc": {
"channel_genesis": {
"ack_sequences": [],
Expand Down
24 changes: 24 additions & 0 deletions protocol/x/govplus/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cli

import (
"fmt"

"github.com/spf13/cobra"

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

// GetQueryCmd returns the cli query commands for this module
func GetQueryCmd(queryRoute string) *cobra.Command {
// Group govplus 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,
}

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

import (
"fmt"
"time"

"github.com/spf13/cobra"

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

var (
DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds())
)

// GetTxCmd returns the transaction commands for this module
func GetTxCmd() *cobra.Command {
cmd := &cobra.Command{
Use: types.ModuleName,
Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName),
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}

return cmd
}
15 changes: 15 additions & 0 deletions protocol/x/govplus/genesis.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package govplus

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/dydxprotocol/v4-chain/protocol/x/govplus/keeper"
"github.com/dydxprotocol/v4-chain/protocol/x/govplus/types"
)

// InitGenesis initializes the govplus module's state from a provided genesis state.
func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) {}

// ExportGenesis returns the govplus module's exported genesis.
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
return &types.GenesisState{}
}
Loading

0 comments on commit 40b58ab

Please sign in to comment.