Merge PR #5649: Update x/params to follow module standards
This commit is contained in:
parent
4aa078b5f3
commit
434f539bff
|
@ -26,6 +26,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/x/mint"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
|
||||
paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
"github.com/cosmos/cosmos-sdk/x/supply"
|
||||
|
@ -202,7 +203,7 @@ func NewSimApp(
|
|||
// register the proposal types
|
||||
govRouter := gov.NewRouter()
|
||||
govRouter.AddRoute(gov.RouterKey, gov.ProposalHandler).
|
||||
AddRoute(params.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
|
||||
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
|
||||
AddRoute(distr.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
|
||||
AddRoute(upgrade.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper))
|
||||
app.GovKeeper = gov.NewKeeper(
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
dbm "github.com/tendermint/tm-db"
|
||||
|
@ -20,7 +21,7 @@ import (
|
|||
distr "github.com/cosmos/cosmos-sdk/x/distribution"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
|
@ -152,7 +153,7 @@ func TestAppImportExport(t *testing.T) {
|
|||
{app.keys[mint.StoreKey], newApp.keys[mint.StoreKey], [][]byte{}},
|
||||
{app.keys[distr.StoreKey], newApp.keys[distr.StoreKey], [][]byte{}},
|
||||
{app.keys[supply.StoreKey], newApp.keys[supply.StoreKey], [][]byte{}},
|
||||
{app.keys[params.StoreKey], newApp.keys[params.StoreKey], [][]byte{}},
|
||||
{app.keys[paramtypes.StoreKey], newApp.keys[paramtypes.StoreKey], [][]byte{}},
|
||||
{app.keys[gov.StoreKey], newApp.keys[gov.StoreKey], [][]byte{}},
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/subspace"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
// AccountKeeper encodes/decodes accounts using the go-amino (binary)
|
||||
|
@ -19,7 +19,7 @@ import (
|
|||
type AccountKeeper struct {
|
||||
key sdk.StoreKey
|
||||
cdc types.Codec
|
||||
paramSubspace subspace.Subspace
|
||||
paramSubspace paramtypes.Subspace
|
||||
|
||||
// The prototypical Account constructor.
|
||||
proto func() exported.Account
|
||||
|
@ -28,7 +28,7 @@ type AccountKeeper struct {
|
|||
// NewAccountKeeper returns a new sdk.AccountKeeper that uses go-amino to
|
||||
// (binary) encode and decode concrete sdk.Accounts.
|
||||
func NewAccountKeeper(
|
||||
cdc types.Codec, key sdk.StoreKey, paramstore subspace.Subspace, proto func() exported.Account,
|
||||
cdc types.Codec, key sdk.StoreKey, paramstore paramtypes.Subspace, proto func() exported.Account,
|
||||
) AccountKeeper {
|
||||
|
||||
return AccountKeeper{
|
||||
|
|
|
@ -3,9 +3,9 @@ package types
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/subspace"
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
// DefaultParamspace defines the default auth module parameter subspace
|
||||
|
@ -29,7 +29,7 @@ var (
|
|||
KeySigVerifyCostSecp256k1 = []byte("SigVerifyCostSecp256k1")
|
||||
)
|
||||
|
||||
var _ subspace.ParamSet = &Params{}
|
||||
var _ paramtypes.ParamSet = &Params{}
|
||||
|
||||
// NewParams creates a new Params object
|
||||
func NewParams(
|
||||
|
@ -46,20 +46,20 @@ func NewParams(
|
|||
}
|
||||
|
||||
// ParamKeyTable for auth module
|
||||
func ParamKeyTable() subspace.KeyTable {
|
||||
return subspace.NewKeyTable().RegisterParamSet(&Params{})
|
||||
func ParamKeyTable() paramtypes.KeyTable {
|
||||
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
|
||||
}
|
||||
|
||||
// ParamSetPairs implements the ParamSet interface and returns all the key/value pairs
|
||||
// pairs of auth module's parameters.
|
||||
// nolint
|
||||
func (p *Params) ParamSetPairs() subspace.ParamSetPairs {
|
||||
return subspace.ParamSetPairs{
|
||||
params.NewParamSetPair(KeyMaxMemoCharacters, &p.MaxMemoCharacters, validateMaxMemoCharacters),
|
||||
params.NewParamSetPair(KeyTxSigLimit, &p.TxSigLimit, validateTxSigLimit),
|
||||
params.NewParamSetPair(KeyTxSizeCostPerByte, &p.TxSizeCostPerByte, validateTxSizeCostPerByte),
|
||||
params.NewParamSetPair(KeySigVerifyCostED25519, &p.SigVerifyCostED25519, validateSigVerifyCostED25519),
|
||||
params.NewParamSetPair(KeySigVerifyCostSecp256k1, &p.SigVerifyCostSecp256k1, validateSigVerifyCostSecp256k1),
|
||||
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
|
||||
return paramtypes.ParamSetPairs{
|
||||
paramtypes.NewParamSetPair(KeyMaxMemoCharacters, &p.MaxMemoCharacters, validateMaxMemoCharacters),
|
||||
paramtypes.NewParamSetPair(KeyTxSigLimit, &p.TxSigLimit, validateTxSigLimit),
|
||||
paramtypes.NewParamSetPair(KeyTxSizeCostPerByte, &p.TxSizeCostPerByte, validateTxSizeCostPerByte),
|
||||
paramtypes.NewParamSetPair(KeySigVerifyCostED25519, &p.SigVerifyCostED25519, validateSigVerifyCostED25519),
|
||||
paramtypes.NewParamSetPair(KeySigVerifyCostSecp256k1, &p.SigVerifyCostSecp256k1, validateSigVerifyCostSecp256k1),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
vestexported "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
var _ Keeper = (*BaseKeeper)(nil)
|
||||
|
@ -31,11 +31,11 @@ type BaseKeeper struct {
|
|||
BaseSendKeeper
|
||||
|
||||
ak types.AccountKeeper
|
||||
paramSpace params.Subspace
|
||||
paramSpace paramtypes.Subspace
|
||||
}
|
||||
|
||||
func NewBaseKeeper(
|
||||
cdc *codec.Codec, storeKey sdk.StoreKey, ak types.AccountKeeper, paramSpace params.Subspace, blacklistedAddrs map[string]bool,
|
||||
cdc *codec.Codec, storeKey sdk.StoreKey, ak types.AccountKeeper, paramSpace paramtypes.Subspace, blacklistedAddrs map[string]bool,
|
||||
) BaseKeeper {
|
||||
|
||||
ps := paramSpace.WithKeyTable(types.ParamKeyTable())
|
||||
|
@ -149,14 +149,14 @@ type BaseSendKeeper struct {
|
|||
cdc *codec.Codec
|
||||
ak types.AccountKeeper
|
||||
storeKey sdk.StoreKey
|
||||
paramSpace params.Subspace
|
||||
paramSpace paramtypes.Subspace
|
||||
|
||||
// list of addresses that are restricted from receiving transactions
|
||||
blacklistedAddrs map[string]bool
|
||||
}
|
||||
|
||||
func NewBaseSendKeeper(
|
||||
cdc *codec.Codec, storeKey sdk.StoreKey, ak types.AccountKeeper, paramSpace params.Subspace, blacklistedAddrs map[string]bool,
|
||||
cdc *codec.Codec, storeKey sdk.StoreKey, ak types.AccountKeeper, paramSpace paramtypes.Subspace, blacklistedAddrs map[string]bool,
|
||||
) BaseSendKeeper {
|
||||
|
||||
return BaseSendKeeper{
|
||||
|
|
|
@ -3,7 +3,7 @@ package types
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -17,9 +17,9 @@ const (
|
|||
var ParamStoreKeySendEnabled = []byte("sendenabled")
|
||||
|
||||
// ParamKeyTable type declaration for parameters
|
||||
func ParamKeyTable() params.KeyTable {
|
||||
return params.NewKeyTable(
|
||||
params.NewParamSetPair(ParamStoreKeySendEnabled, false, validateSendEnabled),
|
||||
func ParamKeyTable() paramtypes.KeyTable {
|
||||
return paramtypes.NewKeyTable(
|
||||
paramtypes.NewParamSetPair(ParamStoreKeySendEnabled, false, validateSendEnabled),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -8,13 +8,13 @@ import (
|
|||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/crisis/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
// Keeper - crisis keeper
|
||||
type Keeper struct {
|
||||
routes []types.InvarRoute
|
||||
paramSpace params.Subspace
|
||||
paramSpace paramtypes.Subspace
|
||||
invCheckPeriod uint
|
||||
|
||||
supplyKeeper types.SupplyKeeper
|
||||
|
@ -24,7 +24,7 @@ type Keeper struct {
|
|||
|
||||
// NewKeeper creates a new Keeper object
|
||||
func NewKeeper(
|
||||
paramSpace params.Subspace, invCheckPeriod uint, supplyKeeper types.SupplyKeeper,
|
||||
paramSpace paramtypes.Subspace, invCheckPeriod uint, supplyKeeper types.SupplyKeeper,
|
||||
feeCollectorName string,
|
||||
) Keeper {
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
// Default parameter namespace
|
||||
|
@ -18,9 +18,9 @@ var (
|
|||
)
|
||||
|
||||
// type declaration for parameters
|
||||
func ParamKeyTable() params.KeyTable {
|
||||
return params.NewKeyTable(
|
||||
params.NewParamSetPair(ParamStoreKeyConstantFee, sdk.Coin{}, validateConstantFee),
|
||||
func ParamKeyTable() paramtypes.KeyTable {
|
||||
return paramtypes.NewKeyTable(
|
||||
paramtypes.NewParamSetPair(ParamStoreKeyConstantFee, sdk.Coin{}, validateConstantFee),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -3,20 +3,20 @@ package keeper
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
// Keeper of the distribution store
|
||||
type Keeper struct {
|
||||
storeKey sdk.StoreKey
|
||||
cdc codec.Marshaler
|
||||
paramSpace params.Subspace
|
||||
paramSpace paramtypes.Subspace
|
||||
bankKeeper types.BankKeeper
|
||||
stakingKeeper types.StakingKeeper
|
||||
supplyKeeper types.SupplyKeeper
|
||||
|
@ -28,7 +28,7 @@ type Keeper struct {
|
|||
|
||||
// NewKeeper creates a new distribution Keeper instance
|
||||
func NewKeeper(
|
||||
cdc codec.Marshaler, key sdk.StoreKey, paramSpace params.Subspace, bk types.BankKeeper,
|
||||
cdc codec.Marshaler, key sdk.StoreKey, paramSpace paramtypes.Subspace, bk types.BankKeeper,
|
||||
sk types.StakingKeeper, supplyKeeper types.SupplyKeeper, feeCollectorName string,
|
||||
blacklistedAddrs map[string]bool,
|
||||
) Keeper {
|
||||
|
|
|
@ -18,7 +18,8 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/keeper"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
"github.com/cosmos/cosmos-sdk/x/supply"
|
||||
)
|
||||
|
@ -88,7 +89,7 @@ func CreateTestInputDefault(t *testing.T, isCheckTx bool, initPower int64) (
|
|||
// hogpodge of all sorts of input required for testing
|
||||
func CreateTestInputAdvanced(
|
||||
t *testing.T, isCheckTx bool, initPower int64, communityTax sdk.Dec,
|
||||
) (sdk.Context, auth.AccountKeeper, bank.Keeper, Keeper, staking.Keeper, params.Keeper, types.SupplyKeeper,
|
||||
) (sdk.Context, auth.AccountKeeper, bank.Keeper, Keeper, staking.Keeper, keeper.Keeper, types.SupplyKeeper,
|
||||
) {
|
||||
|
||||
initTokens := sdk.TokensFromConsensusPower(initPower)
|
||||
|
@ -98,8 +99,8 @@ func CreateTestInputAdvanced(
|
|||
keyStaking := sdk.NewKVStoreKey(staking.StoreKey)
|
||||
keyAcc := sdk.NewKVStoreKey(auth.StoreKey)
|
||||
keySupply := sdk.NewKVStoreKey(supply.StoreKey)
|
||||
keyParams := sdk.NewKVStoreKey(params.StoreKey)
|
||||
tkeyParams := sdk.NewTransientStoreKey(params.TStoreKey)
|
||||
keyParams := sdk.NewKVStoreKey(paramtypes.StoreKey)
|
||||
tkeyParams := sdk.NewTransientStoreKey(paramtypes.TStoreKey)
|
||||
|
||||
db := dbm.NewMemDB()
|
||||
ms := store.NewCommitMultiStore(db)
|
||||
|
@ -127,7 +128,7 @@ func CreateTestInputAdvanced(
|
|||
|
||||
cdc := MakeTestCodec()
|
||||
appCodec := simappcodec.NewAppCodec(cdc)
|
||||
pk := params.NewKeeper(params.ModuleCdc, keyParams, tkeyParams)
|
||||
pk := keeper.NewKeeper(appCodec, keyParams, tkeyParams)
|
||||
|
||||
ctx := sdk.NewContext(ms, abci.Header{ChainID: "foochainid"}, isCheckTx, log.NewNopLogger())
|
||||
accountKeeper := auth.NewAccountKeeper(appCodec, keyAcc, pk.Subspace(auth.DefaultParamspace), auth.ProtoBaseAccount)
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"gopkg.in/yaml.v2"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -23,8 +23,8 @@ var (
|
|||
)
|
||||
|
||||
// ParamKeyTable returns the parameter key table.
|
||||
func ParamKeyTable() params.KeyTable {
|
||||
return params.NewKeyTable().RegisterParamSet(&Params{})
|
||||
func ParamKeyTable() paramtypes.KeyTable {
|
||||
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
|
||||
}
|
||||
|
||||
// DefaultParams returns default distribution parameters
|
||||
|
@ -43,12 +43,12 @@ func (p Params) String() string {
|
|||
}
|
||||
|
||||
// ParamSetPairs returns the parameter set pairs.
|
||||
func (p *Params) ParamSetPairs() params.ParamSetPairs {
|
||||
return params.ParamSetPairs{
|
||||
params.NewParamSetPair(ParamStoreKeyCommunityTax, &p.CommunityTax, validateCommunityTax),
|
||||
params.NewParamSetPair(ParamStoreKeyBaseProposerReward, &p.BaseProposerReward, validateBaseProposerReward),
|
||||
params.NewParamSetPair(ParamStoreKeyBonusProposerReward, &p.BonusProposerReward, validateBonusProposerReward),
|
||||
params.NewParamSetPair(ParamStoreKeyWithdrawAddrEnabled, &p.WithdrawAddrEnabled, validateWithdrawAddrEnabled),
|
||||
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
|
||||
return paramtypes.ParamSetPairs{
|
||||
paramtypes.NewParamSetPair(ParamStoreKeyCommunityTax, &p.CommunityTax, validateCommunityTax),
|
||||
paramtypes.NewParamSetPair(ParamStoreKeyBaseProposerReward, &p.BaseProposerReward, validateBaseProposerReward),
|
||||
paramtypes.NewParamSetPair(ParamStoreKeyBonusProposerReward, &p.BonusProposerReward, validateBonusProposerReward),
|
||||
paramtypes.NewParamSetPair(ParamStoreKeyWithdrawAddrEnabled, &p.WithdrawAddrEnabled, validateWithdrawAddrEnabled),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
// Keeper defines the evidence module's keeper. The keeper is responsible for
|
||||
|
@ -21,14 +21,14 @@ import (
|
|||
type Keeper struct {
|
||||
cdc *codec.Codec
|
||||
storeKey sdk.StoreKey
|
||||
paramSpace params.Subspace
|
||||
paramSpace paramtypes.Subspace
|
||||
router types.Router
|
||||
stakingKeeper types.StakingKeeper
|
||||
slashingKeeper types.SlashingKeeper
|
||||
}
|
||||
|
||||
func NewKeeper(
|
||||
cdc *codec.Codec, storeKey sdk.StoreKey, paramSpace params.Subspace,
|
||||
cdc *codec.Codec, storeKey sdk.StoreKey, paramSpace paramtypes.Subspace,
|
||||
stakingKeeper types.StakingKeeper, slashingKeeper types.SlashingKeeper,
|
||||
) *Keeper {
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@ import (
|
|||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
// DONTCOVER
|
||||
|
@ -32,8 +32,8 @@ type Params struct {
|
|||
}
|
||||
|
||||
// ParamKeyTable returns the parameter key table.
|
||||
func ParamKeyTable() params.KeyTable {
|
||||
return params.NewKeyTable().RegisterParamSet(&Params{})
|
||||
func ParamKeyTable() paramtypes.KeyTable {
|
||||
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
|
||||
}
|
||||
|
||||
func (p Params) String() string {
|
||||
|
@ -42,9 +42,9 @@ func (p Params) String() string {
|
|||
}
|
||||
|
||||
// ParamSetPairs returns the parameter set pairs.
|
||||
func (p *Params) ParamSetPairs() params.ParamSetPairs {
|
||||
return params.ParamSetPairs{
|
||||
params.NewParamSetPair(KeyMaxEvidenceAge, &p.MaxEvidenceAge, validateMaxEvidenceAge),
|
||||
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
|
||||
return paramtypes.ParamSetPairs{
|
||||
paramtypes.NewParamSetPair(KeyMaxEvidenceAge, &p.MaxEvidenceAge, validateMaxEvidenceAge),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,8 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/keeper"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
"github.com/cosmos/cosmos-sdk/x/supply"
|
||||
)
|
||||
|
@ -102,8 +103,8 @@ func createTestInput(
|
|||
keyGov := sdk.NewKVStoreKey(types.StoreKey)
|
||||
keyStaking := sdk.NewKVStoreKey(staking.StoreKey)
|
||||
keySupply := sdk.NewKVStoreKey(supply.StoreKey)
|
||||
keyParams := sdk.NewKVStoreKey(params.StoreKey)
|
||||
tkeyParams := sdk.NewTransientStoreKey(params.TStoreKey)
|
||||
keyParams := sdk.NewKVStoreKey(paramtypes.StoreKey)
|
||||
tkeyParams := sdk.NewTransientStoreKey(paramtypes.TStoreKey)
|
||||
|
||||
db := dbm.NewMemDB()
|
||||
ms := store.NewCommitMultiStore(db)
|
||||
|
@ -148,7 +149,7 @@ func createTestInput(
|
|||
blacklistedAddrs[notBondedPool.GetAddress().String()] = true
|
||||
blacklistedAddrs[bondPool.GetAddress().String()] = true
|
||||
|
||||
pk := params.NewKeeper(params.ModuleCdc, keyParams, tkeyParams)
|
||||
pk := keeper.NewKeeper(appCodec, keyParams, tkeyParams)
|
||||
accountKeeper := auth.NewAccountKeeper(appCodec, keyAcc, pk.Subspace(auth.DefaultParamspace), auth.ProtoBaseAccount)
|
||||
bankKeeper := bank.NewBaseKeeper(cdc, keyBank, accountKeeper, pk.Subspace(bank.DefaultParamspace), blacklistedAddrs)
|
||||
supplyKeeper := supply.NewKeeper(appCodec, keySupply, accountKeeper, bankKeeper, maccPerms)
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"time"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
params "github.com/cosmos/cosmos-sdk/x/params/subspace"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
// Default period for deposits & voting
|
||||
|
@ -29,11 +29,11 @@ var (
|
|||
)
|
||||
|
||||
// ParamKeyTable - Key declaration for parameters
|
||||
func ParamKeyTable() params.KeyTable {
|
||||
return params.NewKeyTable(
|
||||
params.NewParamSetPair(ParamStoreKeyDepositParams, DepositParams{}, validateDepositParams),
|
||||
params.NewParamSetPair(ParamStoreKeyVotingParams, VotingParams{}, validateVotingParams),
|
||||
params.NewParamSetPair(ParamStoreKeyTallyParams, TallyParams{}, validateTallyParams),
|
||||
func ParamKeyTable() paramtypes.KeyTable {
|
||||
return paramtypes.NewKeyTable(
|
||||
paramtypes.NewParamSetPair(ParamStoreKeyDepositParams, DepositParams{}, validateDepositParams),
|
||||
paramtypes.NewParamSetPair(ParamStoreKeyVotingParams, VotingParams{}, validateVotingParams),
|
||||
paramtypes.NewParamSetPair(ParamStoreKeyTallyParams, TallyParams{}, validateTallyParams),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -8,14 +8,14 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
// Keeper of the mint store
|
||||
type Keeper struct {
|
||||
cdc *codec.Codec
|
||||
storeKey sdk.StoreKey
|
||||
paramSpace params.Subspace
|
||||
paramSpace paramtypes.Subspace
|
||||
sk types.StakingKeeper
|
||||
supplyKeeper types.SupplyKeeper
|
||||
feeCollectorName string
|
||||
|
@ -23,7 +23,7 @@ type Keeper struct {
|
|||
|
||||
// NewKeeper creates a new mint Keeper instance
|
||||
func NewKeeper(
|
||||
cdc *codec.Codec, key sdk.StoreKey, paramSpace params.Subspace,
|
||||
cdc *codec.Codec, key sdk.StoreKey, paramSpace paramtypes.Subspace,
|
||||
sk types.StakingKeeper, supplyKeeper types.SupplyKeeper, feeCollectorName string,
|
||||
) Keeper {
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"strings"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
// Parameter store keys
|
||||
|
@ -30,8 +30,8 @@ type Params struct {
|
|||
}
|
||||
|
||||
// ParamTable for minting module.
|
||||
func ParamKeyTable() params.KeyTable {
|
||||
return params.NewKeyTable().RegisterParamSet(&Params{})
|
||||
func ParamKeyTable() paramtypes.KeyTable {
|
||||
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
|
||||
}
|
||||
|
||||
func NewParams(
|
||||
|
@ -106,14 +106,14 @@ func (p Params) String() string {
|
|||
}
|
||||
|
||||
// Implements params.ParamSet
|
||||
func (p *Params) ParamSetPairs() params.ParamSetPairs {
|
||||
return params.ParamSetPairs{
|
||||
params.NewParamSetPair(KeyMintDenom, &p.MintDenom, validateMintDenom),
|
||||
params.NewParamSetPair(KeyInflationRateChange, &p.InflationRateChange, validateInflationRateChange),
|
||||
params.NewParamSetPair(KeyInflationMax, &p.InflationMax, validateInflationMax),
|
||||
params.NewParamSetPair(KeyInflationMin, &p.InflationMin, validateInflationMin),
|
||||
params.NewParamSetPair(KeyGoalBonded, &p.GoalBonded, validateGoalBonded),
|
||||
params.NewParamSetPair(KeyBlocksPerYear, &p.BlocksPerYear, validateBlocksPerYear),
|
||||
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
|
||||
return paramtypes.ParamSetPairs{
|
||||
paramtypes.NewParamSetPair(KeyMintDenom, &p.MintDenom, validateMintDenom),
|
||||
paramtypes.NewParamSetPair(KeyInflationRateChange, &p.InflationRateChange, validateInflationRateChange),
|
||||
paramtypes.NewParamSetPair(KeyInflationMax, &p.InflationMax, validateInflationMax),
|
||||
paramtypes.NewParamSetPair(KeyInflationMin, &p.InflationMin, validateInflationMin),
|
||||
paramtypes.NewParamSetPair(KeyGoalBonded, &p.GoalBonded, validateGoalBonded),
|
||||
paramtypes.NewParamSetPair(KeyBlocksPerYear, &p.BlocksPerYear, validateBlocksPerYear),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,47 +3,26 @@ package params
|
|||
// nolint
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/x/params/subspace"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
const (
|
||||
StoreKey = subspace.StoreKey
|
||||
TStoreKey = subspace.TStoreKey
|
||||
ModuleName = types.ModuleName
|
||||
RouterKey = types.RouterKey
|
||||
ProposalTypeChange = types.ProposalTypeChange
|
||||
StoreKey = types.StoreKey
|
||||
TStoreKey = types.TStoreKey
|
||||
)
|
||||
|
||||
var (
|
||||
// functions aliases
|
||||
NewParamSetPair = subspace.NewParamSetPair
|
||||
NewSubspace = subspace.NewSubspace
|
||||
NewKeyTable = subspace.NewKeyTable
|
||||
RegisterCodec = types.RegisterCodec
|
||||
ErrUnknownSubspace = types.ErrUnknownSubspace
|
||||
ErrSettingParameter = types.ErrSettingParameter
|
||||
ErrEmptyChanges = types.ErrEmptyChanges
|
||||
ErrEmptySubspace = types.ErrEmptySubspace
|
||||
ErrEmptyKey = types.ErrEmptyKey
|
||||
ErrEmptyValue = types.ErrEmptyValue
|
||||
NewParameterChangeProposal = types.NewParameterChangeProposal
|
||||
NewParamChange = types.NewParamChange
|
||||
ValidateChanges = types.ValidateChanges
|
||||
NewCodec = types.NewCodec
|
||||
|
||||
// variable aliases
|
||||
ModuleCdc = types.ModuleCdc
|
||||
NewKeeper = keeper.NewKeeper
|
||||
)
|
||||
|
||||
type (
|
||||
Codec = types.Codec
|
||||
ParamSetPair = subspace.ParamSetPair
|
||||
ParamSetPairs = subspace.ParamSetPairs
|
||||
ParamSet = subspace.ParamSet
|
||||
Subspace = subspace.Subspace
|
||||
ReadOnlySubspace = subspace.ReadOnlySubspace
|
||||
KeyTable = subspace.KeyTable
|
||||
ParameterChangeProposal = types.ParameterChangeProposal
|
||||
ParamChange = types.ParamChange
|
||||
Keeper = keeper.Keeper
|
||||
ParamSetPair = types.ParamSetPair
|
||||
ParamSetPairs = types.ParamSetPairs
|
||||
ParamSet = types.ParamSet
|
||||
Subspace = types.Subspace
|
||||
ReadOnlySubspace = types.ReadOnlySubspace
|
||||
KeyTable = types.KeyTable
|
||||
)
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
paramscutils "github.com/cosmos/cosmos-sdk/x/params/client/utils"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
|
||||
)
|
||||
|
||||
// GetCmdSubmitProposal implements a command handler for submitting a parameter
|
||||
|
@ -75,7 +75,7 @@ Where proposal.json contains:
|
|||
}
|
||||
|
||||
from := cliCtx.GetFromAddress()
|
||||
content := types.NewParameterChangeProposal(proposal.Title, proposal.Description, proposal.Changes.ToParamChanges())
|
||||
content := paramproposal.NewParameterChangeProposal(proposal.Title, proposal.Description, proposal.Changes.ToParamChanges())
|
||||
|
||||
msg := govtypes.NewMsgSubmitProposal(content, proposal.Deposit, from)
|
||||
if err := msg.ValidateBasic(); err != nil {
|
||||
|
|
|
@ -9,8 +9,8 @@ import (
|
|||
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
|
||||
govrest "github.com/cosmos/cosmos-sdk/x/gov/client/rest"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
paramscutils "github.com/cosmos/cosmos-sdk/x/params/client/utils"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/types/proposal"
|
||||
)
|
||||
|
||||
// ProposalRESTHandler returns a ProposalRESTHandler that exposes the param
|
||||
|
@ -34,7 +34,7 @@ func postProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
|
|||
return
|
||||
}
|
||||
|
||||
content := params.NewParameterChangeProposal(req.Title, req.Description, req.Changes.ToParamChanges())
|
||||
content := proposal.NewParameterChangeProposal(req.Title, req.Description, req.Changes.ToParamChanges())
|
||||
|
||||
msg := govtypes.NewMsgSubmitProposal(content, req.Deposit, req.Proposer)
|
||||
if err := msg.ValidateBasic(); err != nil {
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/rest"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/types/proposal"
|
||||
)
|
||||
|
||||
type (
|
||||
|
@ -49,14 +49,14 @@ func NewParamChangeJSON(subspace, key string, value json.RawMessage) ParamChange
|
|||
}
|
||||
|
||||
// ToParamChange converts a ParamChangeJSON object to ParamChange.
|
||||
func (pcj ParamChangeJSON) ToParamChange() params.ParamChange {
|
||||
return params.NewParamChange(pcj.Subspace, pcj.Key, string(pcj.Value))
|
||||
func (pcj ParamChangeJSON) ToParamChange() proposal.ParamChange {
|
||||
return proposal.NewParamChange(pcj.Subspace, pcj.Key, string(pcj.Value))
|
||||
}
|
||||
|
||||
// ToParamChanges converts a slice of ParamChangeJSON objects to a slice of
|
||||
// ParamChange.
|
||||
func (pcj ParamChangesJSON) ToParamChanges() []params.ParamChange {
|
||||
res := make([]params.ParamChange, len(pcj))
|
||||
func (pcj ParamChangesJSON) ToParamChanges() []proposal.ParamChange {
|
||||
res := make([]proposal.ParamChange, len(pcj))
|
||||
for i, pc := range pcj {
|
||||
res[i] = pc.ToParamChange()
|
||||
}
|
||||
|
|
|
@ -1,16 +1,26 @@
|
|||
// nolint:deadcode,unused
|
||||
package params
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
dbm "github.com/tendermint/tm-db"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/store"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/types/proposal"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
dbm "github.com/tendermint/tm-db"
|
||||
)
|
||||
|
||||
func testComponents() (codec.Marshaler, sdk.Context, sdk.StoreKey, sdk.StoreKey, paramskeeper.Keeper) {
|
||||
cdc := createTestCodec()
|
||||
mkey := sdk.NewKVStoreKey("test")
|
||||
tkey := sdk.NewTransientStoreKey("transient_test")
|
||||
ctx := defaultContext(mkey, tkey)
|
||||
keeper := paramskeeper.NewKeeper(cdc, mkey, tkey)
|
||||
|
||||
return cdc, ctx, mkey, tkey, keeper
|
||||
}
|
||||
|
||||
type invalid struct{}
|
||||
|
||||
type s struct {
|
||||
|
@ -22,7 +32,7 @@ func createTestCodec() codec.Marshaler {
|
|||
sdk.RegisterCodec(cdc)
|
||||
cdc.RegisterConcrete(s{}, "test/s", nil)
|
||||
cdc.RegisterConcrete(invalid{}, "test/invalid", nil)
|
||||
return NewCodec(cdc)
|
||||
return proposal.NewCodec(cdc)
|
||||
}
|
||||
|
||||
func defaultContext(key sdk.StoreKey, tkey sdk.StoreKey) sdk.Context {
|
||||
|
@ -37,13 +47,3 @@ func defaultContext(key sdk.StoreKey, tkey sdk.StoreKey) sdk.Context {
|
|||
ctx := sdk.NewContext(cms, abci.Header{}, false, log.NewNopLogger())
|
||||
return ctx
|
||||
}
|
||||
|
||||
func testComponents() (codec.Marshaler, sdk.Context, sdk.StoreKey, sdk.StoreKey, Keeper) {
|
||||
cdc := createTestCodec()
|
||||
mkey := sdk.NewKVStoreKey("test")
|
||||
tkey := sdk.NewTransientStoreKey("transient_test")
|
||||
ctx := defaultContext(mkey, tkey)
|
||||
keeper := NewKeeper(cdc, mkey, tkey)
|
||||
|
||||
return cdc, ctx, mkey, tkey, keeper
|
||||
}
|
|
@ -1,14 +1,14 @@
|
|||
package params
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/subspace"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/types/proposal"
|
||||
)
|
||||
|
||||
// Keeper of the global paramstore
|
||||
|
@ -16,7 +16,7 @@ type Keeper struct {
|
|||
cdc codec.Marshaler
|
||||
key sdk.StoreKey
|
||||
tkey sdk.StoreKey
|
||||
spaces map[string]*Subspace
|
||||
spaces map[string]*types.Subspace
|
||||
}
|
||||
|
||||
// NewKeeper constructs a params keeper
|
||||
|
@ -25,17 +25,17 @@ func NewKeeper(cdc codec.Marshaler, key, tkey sdk.StoreKey) Keeper {
|
|||
cdc: cdc,
|
||||
key: key,
|
||||
tkey: tkey,
|
||||
spaces: make(map[string]*Subspace),
|
||||
spaces: make(map[string]*types.Subspace),
|
||||
}
|
||||
}
|
||||
|
||||
// Logger returns a module-specific logger.
|
||||
func (k Keeper) Logger(ctx sdk.Context) log.Logger {
|
||||
return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName))
|
||||
return ctx.Logger().With("module", fmt.Sprintf("x/%s", proposal.ModuleName))
|
||||
}
|
||||
|
||||
// Allocate subspace used for keepers
|
||||
func (k Keeper) Subspace(s string) Subspace {
|
||||
func (k Keeper) Subspace(s string) types.Subspace {
|
||||
_, ok := k.spaces[s]
|
||||
if ok {
|
||||
panic("subspace already occupied")
|
||||
|
@ -45,17 +45,17 @@ func (k Keeper) Subspace(s string) Subspace {
|
|||
panic("cannot use empty string for subspace")
|
||||
}
|
||||
|
||||
space := subspace.NewSubspace(k.cdc, k.key, k.tkey, s)
|
||||
space := types.NewSubspace(k.cdc, k.key, k.tkey, s)
|
||||
k.spaces[s] = &space
|
||||
|
||||
return space
|
||||
}
|
||||
|
||||
// Get existing substore from keeper
|
||||
func (k Keeper) GetSubspace(s string) (Subspace, bool) {
|
||||
func (k Keeper) GetSubspace(s string) (types.Subspace, bool) {
|
||||
space, ok := k.spaces[s]
|
||||
if !ok {
|
||||
return Subspace{}, false
|
||||
return types.Subspace{}, false
|
||||
}
|
||||
return *space, ok
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package params
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func validateNoOp(_ interface{}) error { return nil }
|
||||
|
@ -26,16 +26,16 @@ func TestKeeper(t *testing.T) {
|
|||
{"key7", 9058701},
|
||||
}
|
||||
|
||||
table := NewKeyTable(
|
||||
NewParamSetPair([]byte("key1"), int64(0), validateNoOp),
|
||||
NewParamSetPair([]byte("key2"), int64(0), validateNoOp),
|
||||
NewParamSetPair([]byte("key3"), int64(0), validateNoOp),
|
||||
NewParamSetPair([]byte("key4"), int64(0), validateNoOp),
|
||||
NewParamSetPair([]byte("key5"), int64(0), validateNoOp),
|
||||
NewParamSetPair([]byte("key6"), int64(0), validateNoOp),
|
||||
NewParamSetPair([]byte("key7"), int64(0), validateNoOp),
|
||||
NewParamSetPair([]byte("extra1"), bool(false), validateNoOp),
|
||||
NewParamSetPair([]byte("extra2"), string(""), validateNoOp),
|
||||
table := types.NewKeyTable(
|
||||
types.NewParamSetPair([]byte("key1"), int64(0), validateNoOp),
|
||||
types.NewParamSetPair([]byte("key2"), int64(0), validateNoOp),
|
||||
types.NewParamSetPair([]byte("key3"), int64(0), validateNoOp),
|
||||
types.NewParamSetPair([]byte("key4"), int64(0), validateNoOp),
|
||||
types.NewParamSetPair([]byte("key5"), int64(0), validateNoOp),
|
||||
types.NewParamSetPair([]byte("key6"), int64(0), validateNoOp),
|
||||
types.NewParamSetPair([]byte("key7"), int64(0), validateNoOp),
|
||||
types.NewParamSetPair([]byte("extra1"), bool(false), validateNoOp),
|
||||
types.NewParamSetPair([]byte("extra2"), string(""), validateNoOp),
|
||||
)
|
||||
|
||||
cdc, ctx, skey, _, keeper := testComponents()
|
||||
|
@ -136,19 +136,19 @@ func TestSubspace(t *testing.T) {
|
|||
{"struct", s{1}, s{0}, new(s)},
|
||||
}
|
||||
|
||||
table := NewKeyTable(
|
||||
NewParamSetPair([]byte("string"), string(""), validateNoOp),
|
||||
NewParamSetPair([]byte("bool"), bool(false), validateNoOp),
|
||||
NewParamSetPair([]byte("int16"), int16(0), validateNoOp),
|
||||
NewParamSetPair([]byte("int32"), int32(0), validateNoOp),
|
||||
NewParamSetPair([]byte("int64"), int64(0), validateNoOp),
|
||||
NewParamSetPair([]byte("uint16"), uint16(0), validateNoOp),
|
||||
NewParamSetPair([]byte("uint32"), uint32(0), validateNoOp),
|
||||
NewParamSetPair([]byte("uint64"), uint64(0), validateNoOp),
|
||||
NewParamSetPair([]byte("int"), sdk.Int{}, validateNoOp),
|
||||
NewParamSetPair([]byte("uint"), sdk.Uint{}, validateNoOp),
|
||||
NewParamSetPair([]byte("dec"), sdk.Dec{}, validateNoOp),
|
||||
NewParamSetPair([]byte("struct"), s{}, validateNoOp),
|
||||
table := types.NewKeyTable(
|
||||
types.NewParamSetPair([]byte("string"), "", validateNoOp),
|
||||
types.NewParamSetPair([]byte("bool"), false, validateNoOp),
|
||||
types.NewParamSetPair([]byte("int16"), int16(0), validateNoOp),
|
||||
types.NewParamSetPair([]byte("int32"), int32(0), validateNoOp),
|
||||
types.NewParamSetPair([]byte("int64"), int64(0), validateNoOp),
|
||||
types.NewParamSetPair([]byte("uint16"), uint16(0), validateNoOp),
|
||||
types.NewParamSetPair([]byte("uint32"), uint32(0), validateNoOp),
|
||||
types.NewParamSetPair([]byte("uint64"), uint64(0), validateNoOp),
|
||||
types.NewParamSetPair([]byte("int"), sdk.Int{}, validateNoOp),
|
||||
types.NewParamSetPair([]byte("uint"), sdk.Uint{}, validateNoOp),
|
||||
types.NewParamSetPair([]byte("dec"), sdk.Dec{}, validateNoOp),
|
||||
types.NewParamSetPair([]byte("struct"), s{}, validateNoOp),
|
||||
)
|
||||
|
||||
store := prefix.NewStore(ctx.KVStore(key), []byte("test/"))
|
||||
|
@ -202,7 +202,7 @@ func TestJSONUpdate(t *testing.T) {
|
|||
|
||||
key := []byte("key")
|
||||
|
||||
space := keeper.Subspace("test").WithKeyTable(NewKeyTable(NewParamSetPair(key, paramJSON{}, validateNoOp)))
|
||||
space := keeper.Subspace("test").WithKeyTable(types.NewKeyTable(types.NewParamSetPair(key, paramJSON{}, validateNoOp)))
|
||||
|
||||
var param paramJSON
|
||||
|
|
@ -12,7 +12,7 @@ import (
|
|||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/types/proposal"
|
||||
sim "github.com/cosmos/cosmos-sdk/x/simulation"
|
||||
)
|
||||
|
||||
|
@ -26,12 +26,12 @@ type AppModuleBasic struct{}
|
|||
|
||||
// Name returns the params module's name.
|
||||
func (AppModuleBasic) Name() string {
|
||||
return ModuleName
|
||||
return proposal.ModuleName
|
||||
}
|
||||
|
||||
// RegisterCodec registers the params module's types for the given codec.
|
||||
func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) {
|
||||
types.RegisterCodec(cdc)
|
||||
proposal.RegisterCodec(cdc)
|
||||
}
|
||||
|
||||
// DefaultGenesis returns default genesis state as raw bytes for the params
|
||||
|
|
|
@ -6,13 +6,15 @@ import (
|
|||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/types/proposal"
|
||||
)
|
||||
|
||||
// NewParamChangeProposalHandler creates a new governance Handler for a ParamChangeProposal
|
||||
func NewParamChangeProposalHandler(k Keeper) govtypes.Handler {
|
||||
func NewParamChangeProposalHandler(k keeper.Keeper) govtypes.Handler {
|
||||
return func(ctx sdk.Context, content govtypes.Content) error {
|
||||
switch c := content.(type) {
|
||||
case ParameterChangeProposal:
|
||||
case proposal.ParameterChangeProposal:
|
||||
return handleParameterChangeProposal(ctx, k, c)
|
||||
|
||||
default:
|
||||
|
@ -21,11 +23,11 @@ func NewParamChangeProposalHandler(k Keeper) govtypes.Handler {
|
|||
}
|
||||
}
|
||||
|
||||
func handleParameterChangeProposal(ctx sdk.Context, k Keeper, p ParameterChangeProposal) error {
|
||||
func handleParameterChangeProposal(ctx sdk.Context, k keeper.Keeper, p proposal.ParameterChangeProposal) error {
|
||||
for _, c := range p.Changes {
|
||||
ss, ok := k.GetSubspace(c.Subspace)
|
||||
if !ok {
|
||||
return sdkerrors.Wrap(ErrUnknownSubspace, c.Subspace)
|
||||
return sdkerrors.Wrap(proposal.ErrUnknownSubspace, c.Subspace)
|
||||
}
|
||||
|
||||
k.Logger(ctx).Info(
|
||||
|
@ -33,7 +35,7 @@ func handleParameterChangeProposal(ctx sdk.Context, k Keeper, p ParameterChangeP
|
|||
)
|
||||
|
||||
if err := ss.Update(ctx, []byte(c.Key), []byte(c.Value)); err != nil {
|
||||
return sdkerrors.Wrapf(ErrSettingParameter, "key: %s, value: %s, err: %s", c.Key, c.Value, err.Error())
|
||||
return sdkerrors.Wrapf(proposal.ErrSettingParameter, "key: %s, value: %s, err: %s", c.Key, c.Value, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,17 +4,18 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
|
||||
dbm "github.com/tendermint/tm-db"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/store"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/subspace"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/types/proposal"
|
||||
)
|
||||
|
||||
func validateNoOp(_ interface{}) error { return nil }
|
||||
|
@ -22,11 +23,11 @@ func validateNoOp(_ interface{}) error { return nil }
|
|||
type testInput struct {
|
||||
ctx sdk.Context
|
||||
cdc *codec.Codec
|
||||
keeper params.Keeper
|
||||
keeper keeper.Keeper
|
||||
}
|
||||
|
||||
var (
|
||||
_ subspace.ParamSet = (*testParams)(nil)
|
||||
_ types.ParamSet = (*testParams)(nil)
|
||||
|
||||
keyMaxValidators = "MaxValidators"
|
||||
keySlashingRate = "SlashingRate"
|
||||
|
@ -43,15 +44,15 @@ type testParams struct {
|
|||
SlashingRate testParamsSlashingRate `json:"slashing_rate" yaml:"slashing_rate"`
|
||||
}
|
||||
|
||||
func (tp *testParams) ParamSetPairs() subspace.ParamSetPairs {
|
||||
return subspace.ParamSetPairs{
|
||||
params.NewParamSetPair([]byte(keyMaxValidators), &tp.MaxValidators, validateNoOp),
|
||||
params.NewParamSetPair([]byte(keySlashingRate), &tp.SlashingRate, validateNoOp),
|
||||
func (tp *testParams) ParamSetPairs() types.ParamSetPairs {
|
||||
return types.ParamSetPairs{
|
||||
types.NewParamSetPair([]byte(keyMaxValidators), &tp.MaxValidators, validateNoOp),
|
||||
types.NewParamSetPair([]byte(keySlashingRate), &tp.SlashingRate, validateNoOp),
|
||||
}
|
||||
}
|
||||
|
||||
func testProposal(changes ...params.ParamChange) params.ParameterChangeProposal {
|
||||
return params.NewParameterChangeProposal(
|
||||
func testProposal(changes ...proposal.ParamChange) proposal.ParameterChangeProposal {
|
||||
return proposal.NewParameterChangeProposal(
|
||||
"Test",
|
||||
"description",
|
||||
changes,
|
||||
|
@ -60,7 +61,7 @@ func testProposal(changes ...params.ParamChange) params.ParameterChangeProposal
|
|||
|
||||
func newTestInput(t *testing.T) testInput {
|
||||
cdc := codec.New()
|
||||
types.RegisterCodec(cdc)
|
||||
proposal.RegisterCodec(cdc)
|
||||
|
||||
db := dbm.NewMemDB()
|
||||
cms := store.NewCommitMultiStore(db)
|
||||
|
@ -74,7 +75,7 @@ func newTestInput(t *testing.T) testInput {
|
|||
err := cms.LoadLatestVersion()
|
||||
require.Nil(t, err)
|
||||
|
||||
keeper := params.NewKeeper(types.ModuleCdc, keyParams, tKeyParams)
|
||||
keeper := keeper.NewKeeper(proposal.ModuleCdc, keyParams, tKeyParams)
|
||||
ctx := sdk.NewContext(cms, abci.Header{}, false, log.NewNopLogger())
|
||||
|
||||
return testInput{ctx, cdc, keeper}
|
||||
|
@ -83,10 +84,10 @@ func newTestInput(t *testing.T) testInput {
|
|||
func TestProposalHandlerPassed(t *testing.T) {
|
||||
input := newTestInput(t)
|
||||
ss := input.keeper.Subspace(testSubspace).WithKeyTable(
|
||||
params.NewKeyTable().RegisterParamSet(&testParams{}),
|
||||
types.NewKeyTable().RegisterParamSet(&testParams{}),
|
||||
)
|
||||
|
||||
tp := testProposal(params.NewParamChange(testSubspace, keyMaxValidators, "1"))
|
||||
tp := testProposal(proposal.NewParamChange(testSubspace, keyMaxValidators, "1"))
|
||||
hdlr := params.NewParamChangeProposalHandler(input.keeper)
|
||||
require.NoError(t, hdlr(input.ctx, tp))
|
||||
|
||||
|
@ -98,10 +99,10 @@ func TestProposalHandlerPassed(t *testing.T) {
|
|||
func TestProposalHandlerFailed(t *testing.T) {
|
||||
input := newTestInput(t)
|
||||
ss := input.keeper.Subspace(testSubspace).WithKeyTable(
|
||||
params.NewKeyTable().RegisterParamSet(&testParams{}),
|
||||
types.NewKeyTable().RegisterParamSet(&testParams{}),
|
||||
)
|
||||
|
||||
tp := testProposal(params.NewParamChange(testSubspace, keyMaxValidators, "invalidType"))
|
||||
tp := testProposal(proposal.NewParamChange(testSubspace, keyMaxValidators, "invalidType"))
|
||||
hdlr := params.NewParamChangeProposalHandler(input.keeper)
|
||||
require.Error(t, hdlr(input.ctx, tp))
|
||||
|
||||
|
@ -111,19 +112,19 @@ func TestProposalHandlerFailed(t *testing.T) {
|
|||
func TestProposalHandlerUpdateOmitempty(t *testing.T) {
|
||||
input := newTestInput(t)
|
||||
ss := input.keeper.Subspace(testSubspace).WithKeyTable(
|
||||
params.NewKeyTable().RegisterParamSet(&testParams{}),
|
||||
types.NewKeyTable().RegisterParamSet(&testParams{}),
|
||||
)
|
||||
|
||||
hdlr := params.NewParamChangeProposalHandler(input.keeper)
|
||||
var param testParamsSlashingRate
|
||||
|
||||
tp := testProposal(params.NewParamChange(testSubspace, keySlashingRate, `{"downtime": 7}`))
|
||||
tp := testProposal(proposal.NewParamChange(testSubspace, keySlashingRate, `{"downtime": 7}`))
|
||||
require.NoError(t, hdlr(input.ctx, tp))
|
||||
|
||||
ss.Get(input.ctx, []byte(keySlashingRate), ¶m)
|
||||
require.Equal(t, testParamsSlashingRate{0, 7}, param)
|
||||
|
||||
tp = testProposal(params.NewParamChange(testSubspace, keySlashingRate, `{"double_sign": 10}`))
|
||||
tp = testProposal(proposal.NewParamChange(testSubspace, keySlashingRate, `{"double_sign": 10}`))
|
||||
require.NoError(t, hdlr(input.ctx, tp))
|
||||
|
||||
ss.Get(input.ctx, []byte(keySlashingRate), ¶m)
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/types/proposal"
|
||||
"github.com/cosmos/cosmos-sdk/x/simulation"
|
||||
)
|
||||
|
||||
|
@ -21,7 +21,7 @@ func SimulateParamChangeProposalContent(paramChangePool []simulation.ParamChange
|
|||
}
|
||||
|
||||
numChanges := simulation.RandIntBetween(r, 1, lenParamChange)
|
||||
paramChanges := make([]types.ParamChange, numChanges)
|
||||
paramChanges := make([]proposal.ParamChange, numChanges)
|
||||
|
||||
// map from key to empty struct; used only for look-up of the keys of the
|
||||
// parameters that are already in the random set of changes.
|
||||
|
@ -40,10 +40,10 @@ func SimulateParamChangeProposalContent(paramChangePool []simulation.ParamChange
|
|||
// add a new distinct parameter to the set of changes and register the key
|
||||
// to avoid further duplicates
|
||||
paramChangesKeys[spc.ComposedKey()] = struct{}{}
|
||||
paramChanges[i] = types.NewParamChange(spc.Subspace, spc.Key, spc.SimValue(r))
|
||||
paramChanges[i] = proposal.NewParamChange(spc.Subspace, spc.Key, spc.SimValue(r))
|
||||
}
|
||||
|
||||
return types.NewParameterChangeProposal(
|
||||
return proposal.NewParameterChangeProposal(
|
||||
simulation.RandStringOfLength(r, 140), // title
|
||||
simulation.RandStringOfLength(r, 5000), // description
|
||||
paramChanges, // set of changes
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
package subspace_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/params/subspace"
|
||||
)
|
||||
|
||||
func TestKeyTable(t *testing.T) {
|
||||
table := subspace.NewKeyTable()
|
||||
|
||||
require.Panics(t, func() { table.RegisterType(subspace.ParamSetPair{[]byte(""), nil, nil}) })
|
||||
require.Panics(t, func() { table.RegisterType(subspace.ParamSetPair{[]byte("!@#$%"), nil, nil}) })
|
||||
require.Panics(t, func() { table.RegisterType(subspace.ParamSetPair{[]byte("hello,"), nil, nil}) })
|
||||
require.Panics(t, func() { table.RegisterType(subspace.ParamSetPair{[]byte("hello"), nil, nil}) })
|
||||
|
||||
require.NotPanics(t, func() {
|
||||
table.RegisterType(subspace.ParamSetPair{keyBondDenom, string("stake"), validateBondDenom})
|
||||
})
|
||||
require.NotPanics(t, func() {
|
||||
table.RegisterType(subspace.ParamSetPair{keyMaxValidators, uint16(100), validateMaxValidators})
|
||||
})
|
||||
require.Panics(t, func() {
|
||||
table.RegisterType(subspace.ParamSetPair{keyUnbondingTime, time.Duration(1), nil})
|
||||
})
|
||||
require.NotPanics(t, func() {
|
||||
table.RegisterType(subspace.ParamSetPair{keyUnbondingTime, time.Duration(1), validateMaxValidators})
|
||||
})
|
||||
require.NotPanics(t, func() {
|
||||
newTable := subspace.NewKeyTable()
|
||||
newTable.RegisterParamSet(¶ms{})
|
||||
})
|
||||
|
||||
require.Panics(t, func() { table.RegisterParamSet(¶ms{}) })
|
||||
require.Panics(t, func() { subspace.NewKeyTable(subspace.ParamSetPair{[]byte(""), nil, nil}) })
|
||||
|
||||
require.NotPanics(t, func() {
|
||||
subspace.NewKeyTable(
|
||||
subspace.ParamSetPair{[]byte("test"), string("stake"), validateBondDenom},
|
||||
subspace.ParamSetPair{[]byte("test2"), uint16(100), validateMaxValidators},
|
||||
)
|
||||
})
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package subspace_test
|
||||
package types_test
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
@ -6,7 +6,7 @@ import (
|
|||
"time"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/subspace"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -59,14 +59,14 @@ func validateBondDenom(i interface{}) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (p *params) ParamSetPairs() subspace.ParamSetPairs {
|
||||
return subspace.ParamSetPairs{
|
||||
func (p *params) ParamSetPairs() types.ParamSetPairs {
|
||||
return types.ParamSetPairs{
|
||||
{keyUnbondingTime, &p.UnbondingTime, validateUnbondingTime},
|
||||
{keyMaxValidators, &p.MaxValidators, validateMaxValidators},
|
||||
{keyBondDenom, &p.BondDenom, validateBondDenom},
|
||||
}
|
||||
}
|
||||
|
||||
func paramKeyTable() subspace.KeyTable {
|
||||
return subspace.NewKeyTable().RegisterParamSet(¶ms{})
|
||||
func paramKeyTable() types.KeyTable {
|
||||
return types.NewKeyTable().RegisterParamSet(¶ms{})
|
||||
}
|
|
@ -10,4 +10,4 @@ respective parameters safely. Keeper can be treated as master permission for all
|
|||
Subspaces (via Keeper.GetSubspace), so should be passed to proper modules
|
||||
(ex. x/governance).
|
||||
*/
|
||||
package subspace
|
||||
package types
|
|
@ -1,4 +1,4 @@
|
|||
package subspace
|
||||
package types
|
||||
|
||||
type (
|
||||
ValueValidatorFn func(value interface{}) error
|
|
@ -1,4 +1,4 @@
|
|||
package types
|
||||
package proposal
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
|
@ -1,4 +1,4 @@
|
|||
package types
|
||||
package proposal
|
||||
|
||||
import (
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
@ -1,4 +1,4 @@
|
|||
package types
|
||||
package proposal
|
||||
|
||||
const (
|
||||
// ModuleName defines the name of the module
|
|
@ -1,4 +1,4 @@
|
|||
package types
|
||||
package proposal
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -1,4 +1,4 @@
|
|||
package types
|
||||
package proposal
|
||||
|
||||
import (
|
||||
"testing"
|
|
@ -1,7 +1,7 @@
|
|||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: x/params/types/types.proto
|
||||
// source: x/params/types/proposal/types.proto
|
||||
|
||||
package types
|
||||
package proposal
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
|
@ -34,7 +34,7 @@ type ParameterChangeProposal struct {
|
|||
func (m *ParameterChangeProposal) Reset() { *m = ParameterChangeProposal{} }
|
||||
func (*ParameterChangeProposal) ProtoMessage() {}
|
||||
func (*ParameterChangeProposal) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ed04c33aa1766c78, []int{0}
|
||||
return fileDescriptor_0ab50f1d22a2cb61, []int{0}
|
||||
}
|
||||
func (m *ParameterChangeProposal) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
|
@ -73,7 +73,7 @@ type ParamChange struct {
|
|||
func (m *ParamChange) Reset() { *m = ParamChange{} }
|
||||
func (*ParamChange) ProtoMessage() {}
|
||||
func (*ParamChange) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ed04c33aa1766c78, []int{1}
|
||||
return fileDescriptor_0ab50f1d22a2cb61, []int{1}
|
||||
}
|
||||
func (m *ParamChange) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
|
@ -128,28 +128,32 @@ func init() {
|
|||
proto.RegisterType((*ParamChange)(nil), "cosmos_sdk.x.params.v1.ParamChange")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("x/params/types/types.proto", fileDescriptor_ed04c33aa1766c78) }
|
||||
func init() {
|
||||
proto.RegisterFile("x/params/types/proposal/types.proto", fileDescriptor_0ab50f1d22a2cb61)
|
||||
}
|
||||
|
||||
var fileDescriptor_ed04c33aa1766c78 = []byte{
|
||||
// 287 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xaa, 0xd0, 0x2f, 0x48,
|
||||
0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2f, 0xa9, 0x2c, 0x48, 0x85, 0x92, 0x7a, 0x05, 0x45, 0xf9, 0x25,
|
||||
0xf9, 0x42, 0x62, 0xc9, 0xf9, 0xc5, 0xb9, 0xf9, 0xc5, 0xf1, 0xc5, 0x29, 0xd9, 0x7a, 0x15, 0x7a,
|
||||
0x10, 0x65, 0x7a, 0x65, 0x86, 0x52, 0x6a, 0x25, 0x19, 0x99, 0x45, 0x29, 0xf1, 0x05, 0x89, 0x45,
|
||||
0x25, 0x95, 0xfa, 0x60, 0xa5, 0xfa, 0xe9, 0xf9, 0xe9, 0xf9, 0x08, 0x16, 0x44, 0xbf, 0xd2, 0x02,
|
||||
0x46, 0x2e, 0xf1, 0x00, 0x90, 0xae, 0xd4, 0x92, 0xd4, 0x22, 0xe7, 0x8c, 0xc4, 0xbc, 0xf4, 0xd4,
|
||||
0x80, 0xa2, 0xfc, 0x82, 0xfc, 0xe2, 0xc4, 0x1c, 0x21, 0x11, 0x2e, 0xd6, 0x92, 0xcc, 0x92, 0x9c,
|
||||
0x54, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x08, 0x47, 0x48, 0x81, 0x8b, 0x3b, 0x25, 0xb5,
|
||||
0x38, 0xb9, 0x28, 0xb3, 0xa0, 0x24, 0x33, 0x3f, 0x4f, 0x82, 0x09, 0x2c, 0x87, 0x2c, 0x24, 0xe4,
|
||||
0xcc, 0xc5, 0x9e, 0x0c, 0x36, 0xa9, 0x58, 0x82, 0x59, 0x81, 0x59, 0x83, 0xdb, 0x48, 0x59, 0x0f,
|
||||
0xbb, 0x2b, 0xf5, 0xc0, 0x36, 0x43, 0x6c, 0x75, 0x62, 0x39, 0x71, 0x4f, 0x9e, 0x21, 0x08, 0xa6,
|
||||
0xd3, 0x8a, 0xa3, 0x63, 0x81, 0x3c, 0xc3, 0x8c, 0x05, 0xf2, 0x0c, 0x4a, 0xe1, 0x5c, 0xdc, 0x48,
|
||||
0xea, 0x84, 0xa4, 0xb8, 0x38, 0x8a, 0x4b, 0x93, 0x8a, 0x0b, 0x12, 0x93, 0x61, 0x0e, 0x83, 0xf3,
|
||||
0x85, 0x04, 0xb8, 0x98, 0xb3, 0x53, 0x2b, 0xa1, 0x6e, 0x02, 0x31, 0x41, 0x7e, 0x28, 0x4b, 0xcc,
|
||||
0x29, 0x4d, 0x95, 0x60, 0x86, 0xf8, 0x01, 0xcc, 0xb1, 0x62, 0x01, 0x19, 0xec, 0x24, 0x7f, 0xe2,
|
||||
0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70,
|
||||
0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0xac, 0xe0, 0x20, 0x4e, 0x62, 0x03, 0x87,
|
||||
0x91, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x83, 0x64, 0xb6, 0xa5, 0x81, 0x01, 0x00, 0x00,
|
||||
var fileDescriptor_0ab50f1d22a2cb61 = []byte{
|
||||
// 313 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xae, 0xd0, 0x2f, 0x48,
|
||||
0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2f, 0x28, 0xca, 0x2f, 0xc8,
|
||||
0x2f, 0x4e, 0xcc, 0x81, 0x70, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0xc4, 0x92, 0xf3, 0x8b,
|
||||
0x73, 0xf3, 0x8b, 0xe3, 0x8b, 0x53, 0xb2, 0xf5, 0x2a, 0xf4, 0x20, 0xea, 0xf5, 0xca, 0x0c, 0xa5,
|
||||
0xd4, 0x4a, 0x32, 0x32, 0x8b, 0x52, 0xe2, 0x0b, 0x12, 0x8b, 0x4a, 0x2a, 0xf5, 0xc1, 0x4a, 0xf5,
|
||||
0xd3, 0xf3, 0xd3, 0xf3, 0x11, 0x2c, 0x88, 0x7e, 0xa5, 0x05, 0x8c, 0x5c, 0xe2, 0x01, 0x20, 0x5d,
|
||||
0xa9, 0x25, 0xa9, 0x45, 0xce, 0x19, 0x89, 0x79, 0xe9, 0xa9, 0x01, 0x50, 0x7b, 0x84, 0x44, 0xb8,
|
||||
0x58, 0x4b, 0x32, 0x4b, 0x72, 0x52, 0x25, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0x20, 0x1c, 0x21,
|
||||
0x05, 0x2e, 0xee, 0x94, 0xd4, 0xe2, 0xe4, 0xa2, 0xcc, 0x82, 0x92, 0xcc, 0xfc, 0x3c, 0x09, 0x26,
|
||||
0xb0, 0x1c, 0xb2, 0x90, 0x90, 0x33, 0x17, 0x7b, 0x32, 0xd8, 0xa4, 0x62, 0x09, 0x66, 0x05, 0x66,
|
||||
0x0d, 0x6e, 0x23, 0x65, 0x3d, 0xec, 0xae, 0xd4, 0x03, 0xdb, 0x0c, 0xb1, 0xd5, 0x89, 0xe5, 0xc4,
|
||||
0x3d, 0x79, 0x86, 0x20, 0x98, 0x4e, 0x2b, 0x8e, 0x8e, 0x05, 0xf2, 0x0c, 0x33, 0x16, 0xc8, 0x33,
|
||||
0x28, 0x85, 0x73, 0x71, 0x23, 0xa9, 0x13, 0x92, 0xe2, 0xe2, 0x28, 0x2e, 0x4d, 0x2a, 0x2e, 0x48,
|
||||
0x4c, 0x86, 0x39, 0x0c, 0xce, 0x17, 0x12, 0xe0, 0x62, 0xce, 0x4e, 0xad, 0x84, 0xba, 0x09, 0xc4,
|
||||
0x04, 0xf9, 0xa1, 0x2c, 0x31, 0xa7, 0x34, 0x55, 0x82, 0x19, 0xe2, 0x07, 0x30, 0xc7, 0x8a, 0x05,
|
||||
0x64, 0xb0, 0x93, 0xdf, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7,
|
||||
0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x99, 0xa4,
|
||||
0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0x9c, 0x0e, 0xa5, 0x74, 0x8b,
|
||||
0x53, 0xb2, 0xf5, 0x71, 0xc4, 0x4b, 0x12, 0x1b, 0x38, 0x48, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff,
|
||||
0xff, 0x11, 0x0a, 0x5a, 0xe0, 0xb9, 0x01, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *ParameterChangeProposal) Marshal() (dAtA []byte, err error) {
|
|
@ -1,7 +1,7 @@
|
|||
syntax = "proto3";
|
||||
package cosmos_sdk.x.params.v1;
|
||||
|
||||
option go_package = "types";
|
||||
option go_package = "github.com/cosmos/cosmos-sdk/x/params/types/proposal";
|
||||
|
||||
import "third_party/proto/gogoproto/gogo.proto";
|
||||
|
|
@ -1,13 +1,12 @@
|
|||
package subspace
|
||||
package types
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
const (
|
|
@ -1,4 +1,4 @@
|
|||
package subspace_test
|
||||
package types_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
@ -13,8 +13,8 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/store"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/subspace"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/types/proposal"
|
||||
)
|
||||
|
||||
type SubspaceTestSuite struct {
|
||||
|
@ -22,11 +22,11 @@ type SubspaceTestSuite struct {
|
|||
|
||||
cdc codec.Marshaler
|
||||
ctx sdk.Context
|
||||
ss subspace.Subspace
|
||||
ss types.Subspace
|
||||
}
|
||||
|
||||
func (suite *SubspaceTestSuite) SetupTest() {
|
||||
cdc := types.ModuleCdc
|
||||
cdc := proposal.ModuleCdc
|
||||
db := dbm.NewMemDB()
|
||||
|
||||
ms := store.NewCommitMultiStore(db)
|
||||
|
@ -34,7 +34,7 @@ func (suite *SubspaceTestSuite) SetupTest() {
|
|||
ms.MountStoreWithDB(tkey, sdk.StoreTypeTransient, db)
|
||||
suite.NoError(ms.LoadLatestVersion())
|
||||
|
||||
ss := subspace.NewSubspace(cdc, key, tkey, "testsubspace")
|
||||
ss := types.NewSubspace(cdc, key, tkey, "testsubspace")
|
||||
|
||||
suite.cdc = cdc
|
||||
suite.ctx = sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger())
|
||||
|
@ -47,7 +47,7 @@ func (suite *SubspaceTestSuite) TestKeyTable() {
|
|||
suite.ss.WithKeyTable(paramKeyTable())
|
||||
})
|
||||
suite.Require().NotPanics(func() {
|
||||
ss := subspace.NewSubspace(types.ModuleCdc, key, tkey, "testsubspace2")
|
||||
ss := types.NewSubspace(proposal.ModuleCdc, key, tkey, "testsubspace2")
|
||||
ss = ss.WithKeyTable(paramKeyTable())
|
||||
})
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ func (suite *SubspaceTestSuite) TestGetParamSet() {
|
|||
func (suite *SubspaceTestSuite) TestSetParamSet() {
|
||||
testCases := []struct {
|
||||
name string
|
||||
ps subspace.ParamSet
|
||||
ps types.ParamSet
|
||||
}{
|
||||
{"invalid unbonding time", ¶ms{time.Hour * 1, 100, "stake"}},
|
||||
{"invalid bond denom", ¶ms{time.Hour * 48, 100, ""}},
|
|
@ -1,4 +1,4 @@
|
|||
package subspace
|
||||
package types
|
||||
|
||||
import (
|
||||
"reflect"
|
|
@ -0,0 +1,45 @@
|
|||
package types_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestKeyTable(t *testing.T) {
|
||||
table := types.NewKeyTable()
|
||||
|
||||
require.Panics(t, func() { table.RegisterType(types.ParamSetPair{[]byte(""), nil, nil}) })
|
||||
require.Panics(t, func() { table.RegisterType(types.ParamSetPair{[]byte("!@#$%"), nil, nil}) })
|
||||
require.Panics(t, func() { table.RegisterType(types.ParamSetPair{[]byte("hello,"), nil, nil}) })
|
||||
require.Panics(t, func() { table.RegisterType(types.ParamSetPair{[]byte("hello"), nil, nil}) })
|
||||
|
||||
require.NotPanics(t, func() {
|
||||
table.RegisterType(types.ParamSetPair{keyBondDenom, string("stake"), validateBondDenom})
|
||||
})
|
||||
require.NotPanics(t, func() {
|
||||
table.RegisterType(types.ParamSetPair{keyMaxValidators, uint16(100), validateMaxValidators})
|
||||
})
|
||||
require.Panics(t, func() {
|
||||
table.RegisterType(types.ParamSetPair{keyUnbondingTime, time.Duration(1), nil})
|
||||
})
|
||||
require.NotPanics(t, func() {
|
||||
table.RegisterType(types.ParamSetPair{keyUnbondingTime, time.Duration(1), validateMaxValidators})
|
||||
})
|
||||
require.NotPanics(t, func() {
|
||||
newTable := types.NewKeyTable()
|
||||
newTable.RegisterParamSet(¶ms{})
|
||||
})
|
||||
|
||||
require.Panics(t, func() { table.RegisterParamSet(¶ms{}) })
|
||||
require.Panics(t, func() { types.NewKeyTable(types.ParamSetPair{[]byte(""), nil, nil}) })
|
||||
|
||||
require.NotPanics(t, func() {
|
||||
types.NewKeyTable(
|
||||
types.ParamSetPair{[]byte("test"), string("stake"), validateBondDenom},
|
||||
types.ParamSetPair{[]byte("test2"), uint16(100), validateMaxValidators},
|
||||
)
|
||||
})
|
||||
}
|
|
@ -22,7 +22,8 @@ import (
|
|||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/keeper"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
"github.com/cosmos/cosmos-sdk/x/supply"
|
||||
|
@ -56,14 +57,14 @@ func createTestCodec() *codec.Codec {
|
|||
return cdc
|
||||
}
|
||||
|
||||
func CreateTestInput(t *testing.T, defaults types.Params) (sdk.Context, bank.Keeper, staking.Keeper, params.Subspace, Keeper) {
|
||||
func CreateTestInput(t *testing.T, defaults types.Params) (sdk.Context, bank.Keeper, staking.Keeper, paramtypes.Subspace, Keeper) {
|
||||
keyAcc := sdk.NewKVStoreKey(auth.StoreKey)
|
||||
keyBank := sdk.NewKVStoreKey(bank.StoreKey)
|
||||
keyStaking := sdk.NewKVStoreKey(staking.StoreKey)
|
||||
keySlashing := sdk.NewKVStoreKey(types.StoreKey)
|
||||
keySupply := sdk.NewKVStoreKey(supply.StoreKey)
|
||||
keyParams := sdk.NewKVStoreKey(params.StoreKey)
|
||||
tkeyParams := sdk.NewTransientStoreKey(params.TStoreKey)
|
||||
keyParams := sdk.NewKVStoreKey(paramtypes.StoreKey)
|
||||
tkeyParams := sdk.NewTransientStoreKey(paramtypes.TStoreKey)
|
||||
|
||||
db := dbm.NewMemDB()
|
||||
|
||||
|
@ -92,7 +93,7 @@ func CreateTestInput(t *testing.T, defaults types.Params) (sdk.Context, bank.Kee
|
|||
blacklistedAddrs[notBondedPool.GetAddress().String()] = true
|
||||
blacklistedAddrs[bondPool.GetAddress().String()] = true
|
||||
|
||||
paramsKeeper := params.NewKeeper(params.ModuleCdc, keyParams, tkeyParams)
|
||||
paramsKeeper := keeper.NewKeeper(appCodec, keyParams, tkeyParams)
|
||||
accountKeeper := auth.NewAccountKeeper(appCodec, keyAcc, paramsKeeper.Subspace(auth.DefaultParamspace), auth.ProtoBaseAccount)
|
||||
|
||||
bk := bank.NewBaseKeeper(cdc, keyBank, accountKeeper, paramsKeeper.Subspace(bank.DefaultParamspace), blacklistedAddrs)
|
||||
|
|
|
@ -5,7 +5,7 @@ package types
|
|||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
stakingexported "github.com/cosmos/cosmos-sdk/x/staking/exported"
|
||||
)
|
||||
|
||||
|
@ -26,10 +26,10 @@ type BankKeeper interface {
|
|||
|
||||
// ParamSubspace defines the expected Subspace interfacace
|
||||
type ParamSubspace interface {
|
||||
WithKeyTable(table params.KeyTable) params.Subspace
|
||||
WithKeyTable(table paramtypes.KeyTable) paramtypes.Subspace
|
||||
Get(ctx sdk.Context, key []byte, ptr interface{})
|
||||
GetParamSet(ctx sdk.Context, ps params.ParamSet)
|
||||
SetParamSet(ctx sdk.Context, ps params.ParamSet)
|
||||
GetParamSet(ctx sdk.Context, ps paramtypes.ParamSet)
|
||||
SetParamSet(ctx sdk.Context, ps paramtypes.ParamSet)
|
||||
}
|
||||
|
||||
// StakingKeeper expected staking keeper
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"time"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
// Default parameter namespace
|
||||
|
@ -31,8 +31,8 @@ var (
|
|||
)
|
||||
|
||||
// ParamKeyTable for slashing module
|
||||
func ParamKeyTable() params.KeyTable {
|
||||
return params.NewKeyTable().RegisterParamSet(&Params{})
|
||||
func ParamKeyTable() paramtypes.KeyTable {
|
||||
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
|
||||
}
|
||||
|
||||
// Params - used for initializing default parameter for slashing at genesis
|
||||
|
@ -73,13 +73,13 @@ func (p Params) String() string {
|
|||
}
|
||||
|
||||
// ParamSetPairs - Implements params.ParamSet
|
||||
func (p *Params) ParamSetPairs() params.ParamSetPairs {
|
||||
return params.ParamSetPairs{
|
||||
params.NewParamSetPair(KeySignedBlocksWindow, &p.SignedBlocksWindow, validateSignedBlocksWindow),
|
||||
params.NewParamSetPair(KeyMinSignedPerWindow, &p.MinSignedPerWindow, validateMinSignedPerWindow),
|
||||
params.NewParamSetPair(KeyDowntimeJailDuration, &p.DowntimeJailDuration, validateDowntimeJailDuration),
|
||||
params.NewParamSetPair(KeySlashFractionDoubleSign, &p.SlashFractionDoubleSign, validateSlashFractionDoubleSign),
|
||||
params.NewParamSetPair(KeySlashFractionDowntime, &p.SlashFractionDowntime, validateSlashFractionDowntime),
|
||||
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
|
||||
return paramtypes.ParamSetPairs{
|
||||
paramtypes.NewParamSetPair(KeySignedBlocksWindow, &p.SignedBlocksWindow, validateSignedBlocksWindow),
|
||||
paramtypes.NewParamSetPair(KeyMinSignedPerWindow, &p.MinSignedPerWindow, validateMinSignedPerWindow),
|
||||
paramtypes.NewParamSetPair(KeyDowntimeJailDuration, &p.DowntimeJailDuration, validateDowntimeJailDuration),
|
||||
paramtypes.NewParamSetPair(KeySlashFractionDoubleSign, &p.SlashFractionDoubleSign, validateSlashFractionDoubleSign),
|
||||
paramtypes.NewParamSetPair(KeySlashFractionDowntime, &p.SlashFractionDowntime, validateSlashFractionDowntime),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
)
|
||||
|
||||
|
@ -27,14 +27,14 @@ type Keeper struct {
|
|||
bankKeeper types.BankKeeper
|
||||
supplyKeeper types.SupplyKeeper
|
||||
hooks types.StakingHooks
|
||||
paramstore params.Subspace
|
||||
paramstore paramtypes.Subspace
|
||||
validatorCache map[string]cachedValidator
|
||||
validatorCacheList *list.List
|
||||
}
|
||||
|
||||
// NewKeeper creates a new staking Keeper instance
|
||||
func NewKeeper(
|
||||
cdc codec.Marshaler, key sdk.StoreKey, bk types.BankKeeper, sk types.SupplyKeeper, ps params.Subspace,
|
||||
cdc codec.Marshaler, key sdk.StoreKey, bk types.BankKeeper, sk types.SupplyKeeper, ps paramtypes.Subspace,
|
||||
) Keeper {
|
||||
|
||||
// ensure bonded and not bonded module accounts are set
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"time"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
)
|
||||
|
||||
|
@ -14,8 +14,8 @@ const (
|
|||
)
|
||||
|
||||
// ParamTable for staking module
|
||||
func ParamKeyTable() params.KeyTable {
|
||||
return params.NewKeyTable().RegisterParamSet(&types.Params{})
|
||||
func ParamKeyTable() paramtypes.KeyTable {
|
||||
return paramtypes.NewKeyTable().RegisterParamSet(&types.Params{})
|
||||
}
|
||||
|
||||
// UnbondingTime
|
||||
|
|
|
@ -24,7 +24,9 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/keeper"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/types/proposal"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/supply"
|
||||
)
|
||||
|
@ -85,8 +87,8 @@ func CreateTestInput(t *testing.T, isCheckTx bool, initPower int64) (sdk.Context
|
|||
keyStaking := sdk.NewKVStoreKey(types.StoreKey)
|
||||
keyAcc := sdk.NewKVStoreKey(auth.StoreKey)
|
||||
bankKey := sdk.NewKVStoreKey(bank.StoreKey)
|
||||
keyParams := sdk.NewKVStoreKey(params.StoreKey)
|
||||
tkeyParams := sdk.NewTransientStoreKey(params.TStoreKey)
|
||||
keyParams := sdk.NewKVStoreKey(paramtypes.StoreKey)
|
||||
tkeyParams := sdk.NewTransientStoreKey(paramtypes.TStoreKey)
|
||||
keySupply := sdk.NewKVStoreKey(supply.StoreKey)
|
||||
|
||||
db := dbm.NewMemDB()
|
||||
|
@ -121,7 +123,7 @@ func CreateTestInput(t *testing.T, isCheckTx bool, initPower int64) (sdk.Context
|
|||
blacklistedAddrs[notBondedPool.GetAddress().String()] = true
|
||||
blacklistedAddrs[bondPool.GetAddress().String()] = true
|
||||
|
||||
pk := params.NewKeeper(params.ModuleCdc, keyParams, tkeyParams)
|
||||
pk := keeper.NewKeeper(proposal.ModuleCdc, keyParams, tkeyParams)
|
||||
|
||||
accountKeeper := auth.NewAccountKeeper(
|
||||
appCodec,
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
|
@ -39,7 +39,7 @@ var (
|
|||
KeyHistoricalEntries = []byte("HistoricalEntries")
|
||||
)
|
||||
|
||||
var _ params.ParamSet = (*Params)(nil)
|
||||
var _ paramtypes.ParamSet = (*Params)(nil)
|
||||
|
||||
// NewParams creates a new Params instance
|
||||
func NewParams(
|
||||
|
@ -56,13 +56,13 @@ func NewParams(
|
|||
}
|
||||
|
||||
// Implements params.ParamSet
|
||||
func (p *Params) ParamSetPairs() params.ParamSetPairs {
|
||||
return params.ParamSetPairs{
|
||||
params.NewParamSetPair(KeyUnbondingTime, &p.UnbondingTime, validateUnbondingTime),
|
||||
params.NewParamSetPair(KeyMaxValidators, &p.MaxValidators, validateMaxValidators),
|
||||
params.NewParamSetPair(KeyMaxEntries, &p.MaxEntries, validateMaxEntries),
|
||||
params.NewParamSetPair(KeyHistoricalEntries, &p.HistoricalEntries, validateHistoricalEntries),
|
||||
params.NewParamSetPair(KeyBondDenom, &p.BondDenom, validateBondDenom),
|
||||
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
|
||||
return paramtypes.ParamSetPairs{
|
||||
paramtypes.NewParamSetPair(KeyUnbondingTime, &p.UnbondingTime, validateUnbondingTime),
|
||||
paramtypes.NewParamSetPair(KeyMaxValidators, &p.MaxValidators, validateMaxValidators),
|
||||
paramtypes.NewParamSetPair(KeyMaxEntries, &p.MaxEntries, validateMaxEntries),
|
||||
paramtypes.NewParamSetPair(KeyHistoricalEntries, &p.HistoricalEntries, validateHistoricalEntries),
|
||||
paramtypes.NewParamSetPair(KeyBondDenom, &p.BondDenom, validateBondDenom),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue