Skip to content

Commit

Permalink
chore: fork x/gov (but not x/gov/types)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbruyelle committed Aug 23, 2024
1 parent 585767a commit ca0724f
Show file tree
Hide file tree
Showing 45 changed files with 11,812 additions and 28 deletions.
3 changes: 2 additions & 1 deletion app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (

"github.com/cometbft/cometbft/libs/log"

govkeeper "github.com/atomone-hub/atomone/x/gov/keeper"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
Expand All @@ -31,7 +33,6 @@ import (
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
"github.com/cosmos/cosmos-sdk/x/feegrant"
feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
Expand Down
2 changes: 1 addition & 1 deletion app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
feegrantmodule "github.com/cosmos/cosmos-sdk/x/feegrant/module"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
"github.com/cosmos/cosmos-sdk/x/gov"
govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/mint"
Expand All @@ -42,6 +41,7 @@ import (
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

atomoneappparams "github.com/atomone-hub/atomone/app/params"
"github.com/atomone-hub/atomone/x/gov"
)

var maccPerms = map[string][]string{
Expand Down
13 changes: 7 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ go 1.21

require (
cosmossdk.io/api v0.3.1
cosmossdk.io/core v0.5.1
cosmossdk.io/depinject v1.0.0-alpha.4
cosmossdk.io/errors v1.0.1
cosmossdk.io/math v1.3.0
cosmossdk.io/simapp v0.0.0-20230602123434-616841b9704d
Expand All @@ -12,7 +14,7 @@ require (
github.com/cometbft/cometbft-db v0.10.0
github.com/cosmos/cosmos-sdk v0.47.10
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/gogoproto v1.4.10
github.com/golang/mock v1.6.0
github.com/google/gofuzz v1.2.0
github.com/gorilla/mux v1.8.1
github.com/ory/dockertest/v3 v3.10.0
Expand All @@ -22,6 +24,8 @@ require (
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.16.0
github.com/stretchr/testify v1.8.4
golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb
gotest.tools/v3 v3.5.1
)

require (
Expand All @@ -34,12 +38,10 @@ require (
// github.com/gravity-devs/liquidity v1.6.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
google.golang.org/genproto v0.0.0-20240102182953-50ed04b92917 // indirect
google.golang.org/grpc v1.60.1 // indirect
google.golang.org/grpc v1.60.1
)

require (
cosmossdk.io/core v0.5.1 // indirect
cosmossdk.io/depinject v1.0.0-alpha.4 // indirect
cosmossdk.io/log v1.3.1 // indirect
filippo.io/edwards25519 v1.0.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
Expand Down Expand Up @@ -70,6 +72,7 @@ require (
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.4 // indirect
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/gogoproto v1.4.10 // indirect
github.com/cosmos/iavl v0.20.1 // indirect
github.com/cosmos/ledger-cosmos-go v0.12.4 // indirect
github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect
Expand Down Expand Up @@ -101,7 +104,6 @@ require (
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v1.1.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/go-cmp v0.6.0 // indirect
Expand Down Expand Up @@ -186,7 +188,6 @@ require (
go.opentelemetry.io/otel/metric v1.19.0 // indirect
go.opentelemetry.io/otel/trace v1.19.0 // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb // indirect
golang.org/x/mod v0.11.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/oauth2 v0.13.0 // indirect
Expand Down
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1940,7 +1940,6 @@ gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=
Expand Down
29 changes: 10 additions & 19 deletions tests/e2e/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ import (
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
govmigrv3 "github.com/cosmos/cosmos-sdk/x/gov/migrations/v3"
govmigrv4 "github.com/cosmos/cosmos-sdk/x/gov/migrations/v4"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govlegacytypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)

Expand Down Expand Up @@ -129,23 +127,16 @@ func modifyGenesis(path, moniker, amountStr string, addrAll []sdk.AccAddress, de
maxDepositPeriod := 10 * time.Minute
votingPeriod := 15 * time.Second

govStateLegacy := govlegacytypes.NewGenesisState(1,
govlegacytypes.NewDepositParams(sdk.NewCoins(sdk.NewCoin(denom, amnt)), maxDepositPeriod),
govlegacytypes.NewVotingParams(votingPeriod),
govlegacytypes.NewTallyParams(quorum, threshold, govlegacytypes.DefaultVetoThreshold),
govGenState := govv1.NewGenesisState(1,
govv1.NewParams(
sdk.NewCoins(sdk.NewCoin(denom, amnt)), maxDepositPeriod,
votingPeriod,
quorum.String(), threshold.String(), govv1.DefaultVetoThreshold.String(),
sdk.ZeroDec().String(),
false, false, true,
),
)

govStateV3, err := govmigrv3.MigrateJSON(govStateLegacy)
if err != nil {
return fmt.Errorf("failed to migrate v1beta1 gov genesis state to v3: %w", err)
}

govStateV4, err := govmigrv4.MigrateJSON(govStateV3)
if err != nil {
return fmt.Errorf("failed to migrate v1beta1 gov genesis state to v4: %w", err)
}

govGenStateBz, err := cdc.MarshalJSON(govStateV4)
govGenStateBz, err := cdc.MarshalJSON(govGenState)
if err != nil {
return fmt.Errorf("failed to marshal gov genesis state: %w", err)
}
Expand Down
Loading

0 comments on commit ca0724f

Please sign in to comment.