Skip to content

Commit

Permalink
feat: Support custom govgen gov module
Browse files Browse the repository at this point in the history
  • Loading branch information
clockworkgr committed Feb 26, 2024
1 parent c25d77d commit b667855
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 33 deletions.
2 changes: 1 addition & 1 deletion cmd/parse/gov/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
modulestypes "github.com/forbole/bdjuno/v4/modules/types"
"github.com/rs/zerolog/log"

govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/atomone-hub/govgen/x/gov/types"
parsecmdtypes "github.com/forbole/juno/v5/cmd/parse/types"
"github.com/forbole/juno/v5/types/config"
"github.com/spf13/cobra"
Expand Down
4 changes: 1 addition & 3 deletions database/gov.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"
"time"

govtypes "github.com/atomone-hub/govgen/x/gov/types"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/gogo/protobuf/proto"

Expand All @@ -19,7 +19,6 @@ import (

// SaveGovParams saves the given x/gov parameters inside the database
func (db *Db) SaveGovParams(params *types.GovParams) error {

depositParamsBz, err := json.Marshal(&params.DepositParams)
if err != nil {
return fmt.Errorf("error while marshaling deposit params: %s", err)
Expand Down Expand Up @@ -412,7 +411,6 @@ WHERE proposal_validator_status_snapshot.height <= excluded.height`

// SaveSoftwareUpgradePlan allows to save the given software upgrade plan with its proposal id
func (db *Db) SaveSoftwareUpgradePlan(proposalID uint64, plan upgradetypes.Plan, height int64) error {

stmt := `
INSERT INTO software_upgrade_plan(proposal_id, plan_name, upgrade_height, info, height)
VALUES ($1, $2, $3, $4, $5)
Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/forbole/bdjuno/v4
go 1.19

require (
github.com/atomone-hub/govgen v0.0.0-20240216125422-eb7bce76c600
github.com/atomone-hub/govgen v1.0.0
github.com/cometbft/cometbft v0.37.2
github.com/cosmos/cosmos-sdk v0.45.16
github.com/cosmos/go-bip39 v1.0.0 // indirect
Expand Down Expand Up @@ -86,7 +86,6 @@ require (
github.com/cosmos/gogoproto v1.4.11 // indirect
github.com/cosmos/gorocksdb v1.2.0 // indirect
github.com/cosmos/iavl v0.19.5 // indirect
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4 v4.1.1 // indirect
github.com/cosmos/ledger-cosmos-go v0.12.4 // indirect
github.com/curioswitch/go-reassign v0.2.0 // indirect
github.com/daixiang0/gci v0.11.2 // indirect
Expand Down Expand Up @@ -158,7 +157,6 @@ require (
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 // indirect
github.com/hexops/gotextdiff v1.0.3 // indirect
github.com/iancoleman/orderedmap v0.2.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jgautheron/goconst v1.6.0 // indirect
github.com/jingyugao/rowserrcheck v1.1.1 // indirect
Expand Down
13 changes: 2 additions & 11 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ github.com/ashanbrown/forbidigo v1.6.0 h1:D3aewfM37Yb3pxHujIPSpTf6oQk9sc9WZi8ger
github.com/ashanbrown/forbidigo v1.6.0/go.mod h1:Y8j9jy9ZYAEHXdu723cUlraTqbzjKF1MUyfOKL+AjcU=
github.com/ashanbrown/makezero v1.1.1 h1:iCQ87C0V0vSyO+M9E/FZYbu65auqH0lnsOkf5FcB28s=
github.com/ashanbrown/makezero v1.1.1/go.mod h1:i1bJLCRSCHOcOa9Y6MyF2FTfMZMFdHvxKHxgO5Z1axI=
github.com/atomone-hub/govgen v0.0.0-20240216125422-eb7bce76c600 h1:aLy3ieeJ8+1R169gQgj7y9sOLfSlYPk29SYEV35n+XU=
github.com/atomone-hub/govgen v0.0.0-20240216125422-eb7bce76c600/go.mod h1:3HvxM7XDgCAXnAPTIuRQVD3o1XYSdlhtx/+e784jdBI=
github.com/atomone-hub/govgen v1.0.0 h1:IRRoCflROmdKqSBjdZePBLziyb/yswg3rp7fMLZAJlQ=
github.com/atomone-hub/govgen v1.0.0/go.mod h1:y6BIlaIfVoloBw+rHtvsbeEJ+GiScUVdwFda1czL/+4=
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
Expand Down Expand Up @@ -183,8 +183,6 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn
github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag=
github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/clockworkgr/govgen v0.0.0-20240216093636-431a6f0d0500 h1:nxCgYT1jrLn2oFkYb0pAK1thKcM/zLHbwCyJ9GR6O4Y=
github.com/clockworkgr/govgen v0.0.0-20240216093636-431a6f0d0500/go.mod h1:3HvxM7XDgCAXnAPTIuRQVD3o1XYSdlhtx/+e784jdBI=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
Expand Down Expand Up @@ -226,8 +224,6 @@ github.com/cosmos/cosmos-proto v1.0.0-beta.1 h1:iDL5qh++NoXxG8hSy93FdYJut4XfgbSh
github.com/cosmos/cosmos-proto v1.0.0-beta.1/go.mod h1:8k2GNZghi5sDRFw/scPL8gMSowT1vDA+5ouxL8GjaUE=
github.com/cosmos/cosmos-sdk v0.45.16-ics-lsm h1:Cld5lg+lXvqT8plyy0l5Aytir4PdxWMHNLyFbOE3iMs=
github.com/cosmos/cosmos-sdk v0.45.16-ics-lsm/go.mod h1:bScuNwWAP0TZJpUf+SHXRU3xGoUPp+X9nAzfeIXts40=
github.com/cosmos/gaia/v14 v14.1.0 h1:aETug4HFGdc2n3GhAEUFQq22JwvkYMdFIXx1uIRtQF4=
github.com/cosmos/gaia/v14 v14.1.0/go.mod h1:W1BE1sGsKudo/Igt+ttz1/ouWS6/1TuaHpA0xelQeew=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
Expand All @@ -237,8 +233,6 @@ github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4
github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw=
github.com/cosmos/iavl v0.19.5 h1:rGA3hOrgNxgRM5wYcSCxgQBap7fW82WZgY78V9po/iY=
github.com/cosmos/iavl v0.19.5/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw=
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4 v4.1.1 h1:TeiMKG56Kg+lqw/+08dfusInebjVagr9v75sP2GJo6w=
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4 v4.1.1/go.mod h1:mFk2qfXAm7ndXQQuXUGm9tlC2OM9jxPQb5PRKEHNU5I=
github.com/cosmos/ibc-go/v4 v4.5.1 h1:+P73X7aIikGAXBUJ9vP9rEbvdSuekt3KGXmAWCSYets=
github.com/cosmos/ibc-go/v4 v4.5.1/go.mod h1:2EOi40Bx/j6rJrtP1ui8k8yUAMpGybmL1EjakYqYv5U=
github.com/cosmos/interchain-security/v2 v2.4.0-lsm h1:1BQ94GQD4TVOLfL2/jJn2Vgro6ph+tVgChk5ziy/JOA=
Expand Down Expand Up @@ -570,8 +564,6 @@ github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSo
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/hydrogen18/memlistener v0.0.0-20141126152155-54553eb933fb/go.mod h1:qEIFzExnS6016fRpRfxrExeVn2gbClQA99gQhnIcdhE=
github.com/hydrogen18/memlistener v0.0.0-20200120041712-dcc25e7acd91/go.mod h1:qEIFzExnS6016fRpRfxrExeVn2gbClQA99gQhnIcdhE=
github.com/iancoleman/orderedmap v0.2.0 h1:sq1N/TFpYH++aViPcaKjys3bDClUEU7s5B+z6jq8pNA=
github.com/iancoleman/orderedmap v0.2.0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA=
Expand Down Expand Up @@ -783,7 +775,6 @@ github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJ
github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs=
github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo=
github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc=
github.com/oxyno-zeta/gomock-extra-matcher v1.1.0 h1:Yyk5ov0ZPKBXtVEeIWtc4J2XVrHuNoIK+0F2BUJgtsc=
github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY=
github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
Expand Down
2 changes: 1 addition & 1 deletion modules/gov/handle_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/forbole/bdjuno/v4/types"

govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/atomone-hub/govgen/x/gov/types"
"github.com/rs/zerolog/log"
)

Expand Down
5 changes: 2 additions & 3 deletions modules/gov/handle_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ package gov

import (
"fmt"
"time"

"strconv"
"time"

"github.com/cosmos/cosmos-sdk/x/authz"

"github.com/forbole/bdjuno/v4/types"

govtypes "github.com/atomone-hub/govgen/x/gov/types"
sdk "github.com/cosmos/cosmos-sdk/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
juno "github.com/forbole/juno/v5/types"
)

Expand Down
6 changes: 2 additions & 4 deletions modules/gov/source/remote/source.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package remote

import (
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/atomone-hub/govgen/x/gov/types"
"github.com/forbole/juno/v5/node/remote"

govsource "github.com/forbole/bdjuno/v4/modules/gov/source"
)

var (
_ govsource.Source = &Source{}
)
var _ govsource.Source = &Source{}

// Source implements govsource.Source using a remote node
type Source struct {
Expand Down
2 changes: 1 addition & 1 deletion modules/gov/source/source.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package source

import govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
import govtypes "github.com/atomone-hub/govgen/x/gov/types"

type Source interface {
Proposal(height int64, id uint64) (govtypes.Proposal, error)
Expand Down
4 changes: 2 additions & 2 deletions modules/gov/utils_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
ccvprovidertypes "github.com/cosmos/interchain-security/v2/x/ccv/provider/types"

govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/atomone-hub/govgen/x/gov/types"
)

func (m *Module) UpdateProposal(height int64, blockTime time.Time, id uint64) error {
Expand Down Expand Up @@ -227,7 +227,7 @@ func (m *Module) updateProposalValidatorStatusesSnapshot(
return fmt.Errorf("error while getting validator statuses: %s", err)
}

var snapshots = make([]types.ProposalValidatorStatusSnapshot, len(validators))
snapshots := make([]types.ProposalValidatorStatusSnapshot, len(validators))
for index, validator := range validators {
consAddr, err := validator.GetConsAddr()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion modules/types/sources.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"github.com/cosmos/cosmos-sdk/simapp/params"
"github.com/forbole/juno/v5/node/remote"

govtypes "github.com/atomone-hub/govgen/x/gov/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
Expand Down
16 changes: 13 additions & 3 deletions types/gov.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"

govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/atomone-hub/govgen/x/gov/types"
)

const (
Expand All @@ -28,13 +28,23 @@ func NewDepositParam(d govtypes.DepositParams) DepositParams {

// VotingParams contains the voting parameters of the x/gov module
type VotingParams struct {
VotingPeriod int64 `json:"voting_period,omitempty" yaml:"voting_period"`
VotingPeriodDefault int64 `json:"voting_period_default,omitempty" yaml:"voting_period_default"`
// Length of the voting period for parameter change proposal.
VotingPeriodParameterChange int64 `json:"voting_period_parameter_change,omitempty" yaml:"voting_period_parameter_change"`
// Length of the voting period for software upgrade and cancel software
// upgrade proposal.
VotingPeriodSoftwareUpgrade int64 `json:"voting_period_software_upgrade,omitempty" yaml:"voting_period_software_upgrade"`
// Length of the voting period for text proposal.
VotingPeriodText int64 `json:"voting_period_text,omitempty" yaml:"voting_period_text"`
}

// NewVotingParams allows to build a new VotingParams instance
func NewVotingParams(v govtypes.VotingParams) VotingParams {
return VotingParams{
VotingPeriod: v.VotingPeriod.Nanoseconds(),
VotingPeriodDefault: v.VotingPeriodDefault.Nanoseconds(),
VotingPeriodParameterChange: v.VotingPeriodParameterChange.Nanoseconds(),
VotingPeriodSoftwareUpgrade: v.VotingPeriodSoftwareUpgrade.Nanoseconds(),
VotingPeriodText: v.VotingPeriodText.Nanoseconds(),
}
}

Expand Down

0 comments on commit b667855

Please sign in to comment.