Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

R4R: Replace the old iparam with the new iparam #308

Merged
merged 2 commits into from
Sep 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import (
bam "github.com/irisnet/irishub/baseapp"
"github.com/irisnet/irishub/modules/gov"
"github.com/irisnet/irishub/modules/gov/params"
"github.com/irisnet/irishub/modules/iparams"
"github.com/irisnet/irishub/modules/parameter"
"github.com/irisnet/irishub/modules/iparam"
"github.com/irisnet/irishub/modules/upgrade"
"github.com/irisnet/irishub/modules/upgrade/params"
"github.com/spf13/viper"
Expand Down Expand Up @@ -73,7 +72,6 @@ type IrisApp struct {
slashingKeeper slashing.Keeper
paramsKeeper params.Keeper
govKeeper gov.Keeper
iparamsKeeper iparams.Keeper
upgradeKeeper upgrade.Keeper

// fee manager
Expand Down Expand Up @@ -116,14 +114,13 @@ func NewIrisApp(logger log.Logger, db dbm.DB, traceStore io.Writer, baseAppOptio

// add handlers
app.paramsKeeper = params.NewKeeper(cdc, app.keyParams)
app.iparamsKeeper = iparams.NewKeeper(app.cdc, app.keyIparams)
app.coinKeeper = bank.NewKeeper(app.accountMapper)
app.ibcMapper = ibc.NewMapper(app.cdc, app.keyIBC, app.RegisterCodespace(ibc.DefaultCodespace))
app.stakeKeeper = stake.NewKeeper(app.cdc, app.keyStake, app.coinKeeper, app.RegisterCodespace(stake.DefaultCodespace))
app.slashingKeeper = slashing.NewKeeper(app.cdc, app.keySlashing, app.stakeKeeper, app.paramsKeeper.Getter(), app.RegisterCodespace(slashing.DefaultCodespace))
app.feeCollectionKeeper = auth.NewFeeCollectionKeeper(app.cdc, app.keyFeeCollection)
app.upgradeKeeper = upgrade.NewKeeper(app.cdc, app.keyUpgrade, app.stakeKeeper)
app.govKeeper = gov.NewKeeper(app.cdc, app.keyGov, app.iparamsKeeper.GovSetter(), app.coinKeeper, app.stakeKeeper, app.RegisterCodespace(gov.DefaultCodespace))
app.govKeeper = gov.NewKeeper(app.cdc, app.keyGov, app.coinKeeper, app.stakeKeeper, app.RegisterCodespace(gov.DefaultCodespace))

// register message routes
// need to update each module's msg type
Expand All @@ -135,7 +132,7 @@ func NewIrisApp(logger log.Logger, db dbm.DB, traceStore io.Writer, baseAppOptio
AddRoute("gov", []*sdk.KVStoreKey{app.keyGov, app.keyAccount, app.keyStake, app.keyIparams, app.keyParams}, gov.NewHandler(app.govKeeper)).
AddRoute("upgrade", []*sdk.KVStoreKey{app.keyUpgrade, app.keyStake}, upgrade.NewHandler(app.upgradeKeeper))

app.feeManager = bam.NewFeeManager(app.iparamsKeeper.GlobalGetter(), app.iparamsKeeper.GovGetter())
app.feeManager = bam.NewFeeManager(app.paramsKeeper.Setter())
// initialize BaseApp
app.SetInitChainer(app.initChainer)
app.SetBeginBlocker(app.BeginBlocker)
Expand All @@ -157,14 +154,14 @@ func NewIrisApp(logger log.Logger, db dbm.DB, traceStore io.Writer, baseAppOptio
}

upgrade.RegisterModuleList(app.Router())
parameter.SetParamReadWriter(app.paramsKeeper.Setter(),
iparam.SetParamReadWriter(app.paramsKeeper.Setter(),
&govparams.DepositProcedureParameter,
&govparams.VotingProcedureParameter,
&govparams.TallyingProcedureParameter,
&upgradeparams.CurrentUpgradeProposalIdParameter,
&upgradeparams.ProposalAcceptHeightParameter)

parameter.RegisterGovParamMapping(&govparams.DepositProcedureParameter,
iparam.RegisterGovParamMapping(&govparams.DepositProcedureParameter,
&govparams.VotingProcedureParameter,
&govparams.TallyingProcedureParameter,)

Expand Down Expand Up @@ -257,7 +254,7 @@ func (app *IrisApp) initChainer(ctx sdk.Context, req abci.RequestInitChain) abci
GasPriceThreshold: 20000000000, // 20(glue), 20*10^9, 1 glue = 10^9 lue/gas, 1 iris = 10^18 lue
}

bam.InitGenesis(ctx, app.iparamsKeeper.GlobalSetter(), app.iparamsKeeper.GovSetter(), feeTokenGensisConfig)
bam.InitGenesis(ctx, app.paramsKeeper.Setter(), feeTokenGensisConfig)

// load the address to pubkey map
slashing.InitGenesis(ctx, app.slashingKeeper, genesisState.StakeData)
Expand Down
24 changes: 11 additions & 13 deletions baseapp/fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"errors"
"github.com/irisnet/irishub/types"
"github.com/irisnet/irishub/modules/iparams"
"github.com/cosmos/cosmos-sdk/x/params"
)

var (
Expand Down Expand Up @@ -54,7 +54,7 @@ func NewFeeRefundHandler(am auth.AccountMapper, fck auth.FeeCollectionKeeper, fm
}
// Refund process will also cost gas, but this is compensation for previous fee deduction.
// It is not reasonable to consume users' gas. So the context gas is reset to transaction gas
ctx = ctx.WithGasMeter(sdk.NewGasMeter(stdTx.Fee.Gas))
ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeter())

fee := auth.StdFee{
Gas: stdTx.Fee.Gas,
Expand Down Expand Up @@ -99,19 +99,17 @@ func NewFeeRefundHandler(am auth.AccountMapper, fck auth.FeeCollectionKeeper, fm

// FeeManager do fee tokens preprocess according to fee token configuration
type FeeManager struct {
globalGetter iparams.GlobalGetter
govGetter iparams.GovGetter
ps params.Setter
}

func NewFeeManager(globalGetter iparams.GlobalGetter, govGetter iparams.GovGetter) FeeManager {
func NewFeeManager(ps params.Setter) FeeManager {
return FeeManager{
globalGetter: globalGetter,
govGetter: govGetter,
ps:ps,
}
}

func (fck FeeManager) getNativeFeeToken(ctx sdk.Context, coins sdk.Coins) sdk.Coin {
nativeFeeToken, err := fck.globalGetter.GetString(ctx, nativeFeeTokenKey)
nativeFeeToken, err := fck.ps.GetString(ctx, nativeFeeTokenKey)
if err != nil {
panic(err)
}
Expand All @@ -127,11 +125,11 @@ func (fck FeeManager) feePreprocess(ctx sdk.Context, coins sdk.Coins, gasLimit i
if gasLimit <= 0 {
return sdk.ErrInternal(fmt.Sprintf("gaslimit %d should be larger than 0", gasLimit))
}
nativeFeeToken, err := fck.globalGetter.GetString(ctx, nativeFeeTokenKey)
nativeFeeToken, err := fck.ps.GetString(ctx, nativeFeeTokenKey)
if err != nil {
panic(err)
}
nativeGasPriceThreshold, err := fck.govGetter.GetString(ctx, nativeGasPriceThresholdKey)
nativeGasPriceThreshold, err := fck.ps.GetString(ctx, nativeGasPriceThresholdKey)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -177,7 +175,7 @@ type FeeGenesisStateConfig struct {
GasPriceThreshold int64 `json:"gas_price_threshold"`
}

func InitGenesis(ctx sdk.Context, globalSetter iparams.GlobalSetter, govSetter iparams.GovSetter, data FeeGenesisStateConfig) {
globalSetter.SetString(ctx, nativeFeeTokenKey, data.FeeTokenNative)
govSetter.SetString(ctx, nativeGasPriceThresholdKey, sdk.NewInt(data.GasPriceThreshold).String())
func InitGenesis(ctx sdk.Context, ps params.Setter, data FeeGenesisStateConfig) {
ps.SetString(ctx, nativeFeeTokenKey, data.FeeTokenNative)
ps.SetString(ctx, nativeGasPriceThresholdKey, sdk.NewInt(data.GasPriceThreshold).String())
}
14 changes: 7 additions & 7 deletions client/gov/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
govClient "github.com/irisnet/irishub/client/gov"
"github.com/irisnet/irishub/modules/gov"
"github.com/irisnet/irishub/modules/gov/params"
"github.com/irisnet/irishub/modules/parameter"
"github.com/irisnet/irishub/modules/iparam"
"github.com/spf13/cobra"
"github.com/spf13/viper"
cmn "github.com/tendermint/tendermint/libs/common"
Expand Down Expand Up @@ -287,17 +287,17 @@ func GetCmdQueryGovConfig(storeName string, cdc *wire.Codec) *cobra.Command {
}

if keyStr != "" {
parameter.RegisterGovParamMapping(&govparams.DepositProcedureParameter,
iparam.RegisterGovParamMapping(&govparams.DepositProcedureParameter,
&govparams.VotingProcedureParameter,
&govparams.TallyingProcedureParameter)

res, err := ctx.QueryStore([]byte(keyStr), storeName)
if err == nil {
if p, ok := parameter.ParamMapping[keyStr]; ok {
if p, ok := iparam.ParamMapping[keyStr]; ok {
p.GetValueFromRawData(cdc, res) //.(govparams.TallyingProcedure)
PrintParamStr(p, keyStr)
} else {
return sdk.NewError(parameter.DefaultCodespace, parameter.CodeInvalidTallyingProcedure, fmt.Sprintf(keyStr+" is not found"))
return sdk.NewError(iparam.DefaultCodespace, iparam.CodeInvalidTallyingProcedure, fmt.Sprintf(keyStr+" is not found"))
}
} else {
return err
Expand All @@ -314,7 +314,7 @@ func GetCmdQueryGovConfig(storeName string, cdc *wire.Codec) *cobra.Command {
return cmd
}

func PrintParamStr(p parameter.GovParameter, keyStr string) {
func PrintParamStr(p iparam.GovParameter, keyStr string) {
var param gov.Param
param.Key = keyStr
param.Value = p.ToJson()
Expand Down Expand Up @@ -351,7 +351,7 @@ func (pd *ParameterConfigFile) WriteFile(cdc *wire.Codec, res []sdk.KVPair) erro
case "Gov/gov/TallyingProcedure":
cdc.MustUnmarshalBinary(kv.Value, &pd.Govparams.TallyingProcedure)
default:
return sdk.NewError(parameter.DefaultCodespace, parameter.CodeInvalidTallyingProcedure, fmt.Sprintf(string(kv.Key)+" is not found"))
return sdk.NewError(iparam.DefaultCodespace, iparam.CodeInvalidTallyingProcedure, fmt.Sprintf(string(kv.Key)+" is not found"))
}
}
output, err := cdc.MarshalJSONIndent(pd, "", " ")
Expand Down Expand Up @@ -384,7 +384,7 @@ func (pd *ParameterConfigFile) GetParamFromKey(keyStr string, opStr string) (gov
case "Gov/gov/TallyingProcedure":
jsonBytes, err = json.Marshal(pd.Govparams.TallyingProcedure)
default:
return param, sdk.NewError(parameter.DefaultCodespace, parameter.CodeInvalidTallyingProcedure, fmt.Sprintf(keyStr+" is not found"))
return param, sdk.NewError(iparam.DefaultCodespace, iparam.CodeInvalidTallyingProcedure, fmt.Sprintf(keyStr+" is not found"))
}

if err != nil {
Expand Down
7 changes: 2 additions & 5 deletions cmd/irisdebug/hack.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/stake"

iris "github.com/irisnet/irishub/app"
"github.com/irisnet/irishub/modules/iparams"
"github.com/irisnet/irishub/modules/upgrade"
"github.com/irisnet/irishub/modules/gov"
)
Expand Down Expand Up @@ -151,7 +150,6 @@ type IrisApp struct {
slashingKeeper slashing.Keeper
paramsKeeper params.Keeper
govKeeper gov.Keeper
iparamsKeeper iparams.Keeper
upgradeKeeper upgrade.Keeper

// fee manager
Expand Down Expand Up @@ -189,14 +187,13 @@ func NewIrisApp(logger log.Logger, db dbm.DB, baseAppOptions ...func(*bam.BaseAp

// add handlers
app.paramsKeeper = params.NewKeeper(cdc, app.keyParams)
app.iparamsKeeper = iparams.NewKeeper(app.cdc, app.keyIparams)
app.coinKeeper = bank.NewKeeper(app.accountMapper)
app.ibcMapper = ibc.NewMapper(app.cdc, app.keyIBC, app.RegisterCodespace(ibc.DefaultCodespace))
app.stakeKeeper = stake.NewKeeper(app.cdc, app.keyStake, app.coinKeeper, app.RegisterCodespace(stake.DefaultCodespace))
app.slashingKeeper = slashing.NewKeeper(app.cdc, app.keySlashing, app.stakeKeeper, app.paramsKeeper.Getter(), app.RegisterCodespace(slashing.DefaultCodespace))
app.feeCollectionKeeper = auth.NewFeeCollectionKeeper(app.cdc, app.keyFeeCollection)
app.upgradeKeeper = upgrade.NewKeeper(app.cdc, app.keyUpgrade, app.stakeKeeper, app.iparamsKeeper.GovSetter())
app.govKeeper = gov.NewKeeper(app.cdc, app.keyGov, app.iparamsKeeper.GovSetter(), app.coinKeeper, app.stakeKeeper, app.RegisterCodespace(gov.DefaultCodespace))
app.upgradeKeeper = upgrade.NewKeeper(app.cdc, app.keyUpgrade, app.stakeKeeper)
app.govKeeper = gov.NewKeeper(app.cdc, app.keyGov, app.coinKeeper, app.stakeKeeper, app.RegisterCodespace(gov.DefaultCodespace))

// register message routes
app.Router().
Expand Down
8 changes: 4 additions & 4 deletions modules/gov/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package gov
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/irisnet/irishub/modules/gov/params"
"github.com/irisnet/irishub/modules/parameter"
"github.com/irisnet/irishub/modules/iparam"
)

// GenesisState - all staking state that must be provided at genesis
Expand Down Expand Up @@ -31,9 +31,9 @@ func InitGenesis(ctx sdk.Context, k Keeper, data GenesisState) {
panic(err)
}
//k.setDepositProcedure(ctx, data.DepositProcedure)
parameter.InitGenesisParameter(&govparams.DepositProcedureParameter, ctx, data.DepositProcedure)
parameter.InitGenesisParameter(&govparams.VotingProcedureParameter, ctx, data.VotingProcedure)
parameter.InitGenesisParameter(&govparams.TallyingProcedureParameter, ctx, data.TallyingProcedure)
iparam.InitGenesisParameter(&govparams.DepositProcedureParameter, ctx, data.DepositProcedure)
iparam.InitGenesisParameter(&govparams.VotingProcedureParameter, ctx, data.VotingProcedure)
iparam.InitGenesisParameter(&govparams.TallyingProcedureParameter, ctx, data.TallyingProcedure)

}

Expand Down
6 changes: 1 addition & 5 deletions modules/gov/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@ import (
"github.com/cosmos/cosmos-sdk/wire"
"github.com/cosmos/cosmos-sdk/x/bank"
"github.com/irisnet/irishub/modules/gov/params"
"github.com/irisnet/irishub/modules/iparams"
)

// nolint

// Governance Keeper
type Keeper struct {
// The reference to the ParamSetter to get and set Global Params
ps iparams.GovSetter

// The reference to the CoinKeeper to modify balances
ck bank.Keeper
Expand All @@ -35,10 +32,9 @@ type Keeper struct {
}

// NewGovernanceMapper returns a mapper that uses go-wire to (binary) encode and decode gov types.
func NewKeeper(cdc *wire.Codec, key sdk.StoreKey, ps iparams.GovSetter, ck bank.Keeper, ds sdk.DelegationSet, codespace sdk.CodespaceType) Keeper {
func NewKeeper(cdc *wire.Codec, key sdk.StoreKey, ck bank.Keeper, ds sdk.DelegationSet, codespace sdk.CodespaceType) Keeper {
return Keeper{
storeKey: key,
ps: ps,
ck: ck,
ds: ds,
vs: ds.GetValidatorSet(),
Expand Down
4 changes: 2 additions & 2 deletions modules/gov/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/irisnet/irishub/modules/parameter"
"github.com/irisnet/irishub/modules/iparam"
)

// name to idetify transaction types
Expand Down Expand Up @@ -58,7 +58,7 @@ func (msg MsgSubmitProposal) ValidateBasic() sdk.Error {

if msg.ProposalType == ProposalTypeParameterChange {

if p, ok := parameter.ParamMapping[msg.Param.Key]; ok{
if p, ok := iparam.ParamMapping[msg.Param.Key]; ok{
return p.Valid(msg.Param.Value)
} else {
return ErrInvalidParam(DefaultCodespace)
Expand Down
29 changes: 14 additions & 15 deletions modules/gov/params/gov_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/params"
"github.com/irisnet/irishub/types"
"github.com/irisnet/irishub/modules/parameter"
"github.com/irisnet/irishub/modules/iparam"
"github.com/cosmos/cosmos-sdk/wire"

"strconv"
)

Expand All @@ -22,7 +21,7 @@ var (
const LOWER_BOUND_AMOUNT = 1
const UPPER_BOUND_AMOUNT = 200

var _ parameter.GovParameter = (*DepositProcedureParam)(nil)
var _ iparam.GovParameter = (*DepositProcedureParam)(nil)

type ParamSet struct {
DepositProcedure DepositProcedure `json:"Gov/gov/DepositProcedure"`
Expand Down Expand Up @@ -96,30 +95,30 @@ func (param *DepositProcedureParam) Valid(jsonStr string) sdk.Error {
if err = json.Unmarshal([]byte(jsonStr), &param.Value); err == nil {

if param.Value.MinDeposit[0].Denom != "iris-atto" {
return sdk.NewError(parameter.DefaultCodespace, parameter.CodeInvalidMinDepositDenom, fmt.Sprintf("It should be iris-atto! git"))
return sdk.NewError(iparam.DefaultCodespace, iparam.CodeInvalidMinDepositDenom, fmt.Sprintf("It should be iris-atto! git"))
}

LowerBound, _ := types.NewDefaultCoinType("iris").ConvertToMinCoin(fmt.Sprintf("%d%s", LOWER_BOUND_AMOUNT, "iris"))
UpperBound, _ := types.NewDefaultCoinType("iris").ConvertToMinCoin(fmt.Sprintf("%d%s", UPPER_BOUND_AMOUNT, "iris"))

if param.Value.MinDeposit[0].Amount.LT(LowerBound.Amount) || param.Value.MinDeposit[0].Amount.GT(UpperBound.Amount) {
return sdk.NewError(parameter.DefaultCodespace, parameter.CodeInvalidMinDepositAmount, fmt.Sprintf("MinDepositAmount"+param.Value.MinDeposit[0].String()+" should be larger than 10 and less than 20000"))
return sdk.NewError(iparam.DefaultCodespace, iparam.CodeInvalidMinDepositAmount, fmt.Sprintf("MinDepositAmount"+param.Value.MinDeposit[0].String()+" should be larger than 1iris and less than 20000iris"))

}

if param.Value.MaxDepositPeriod < 20 || param.Value.MaxDepositPeriod > 20000 {
return sdk.NewError(parameter.DefaultCodespace, parameter.CodeInvalidDepositPeriod, fmt.Sprintf("MaxDepositPeriod ("+strconv.Itoa(int(param.Value.MaxDepositPeriod))+") should be larger than 20 and less than 20000"))
return sdk.NewError(iparam.DefaultCodespace, iparam.CodeInvalidDepositPeriod, fmt.Sprintf("MaxDepositPeriod ("+strconv.Itoa(int(param.Value.MaxDepositPeriod))+") should be larger than 20 and less than 20000"))
}

return nil

}
return sdk.NewError(parameter.DefaultCodespace, parameter.CodeInvalidMinDeposit, fmt.Sprintf("Json is not valid"))
return sdk.NewError(iparam.DefaultCodespace, iparam.CodeInvalidMinDeposit, fmt.Sprintf("Json is not valid"))
}


var VotingProcedureParameter VotingProcedureParam
var _ parameter.GovParameter = (*VotingProcedureParam)(nil)
var _ iparam.GovParameter = (*VotingProcedureParam)(nil)

// Procedure around Voting in governance
type VotingProcedure struct {
Expand Down Expand Up @@ -184,17 +183,17 @@ func (param *VotingProcedureParam) Valid(jsonStr string) sdk.Error {
if err = json.Unmarshal([]byte(jsonStr), &param.Value); err == nil {

if param.Value.VotingPeriod < 20 || param.Value.VotingPeriod > 20000 {
return sdk.NewError(parameter.DefaultCodespace, parameter.CodeInvalidVotingPeriod, fmt.Sprintf("VotingPeriod ("+strconv.Itoa(int(param.Value.VotingPeriod))+") should be larger than 20 and less than 20000"))
return sdk.NewError(iparam.DefaultCodespace, iparam.CodeInvalidVotingPeriod, fmt.Sprintf("VotingPeriod ("+strconv.Itoa(int(param.Value.VotingPeriod))+") should be larger than 20 and less than 20000"))
}

return nil

}
return sdk.NewError(parameter.DefaultCodespace, parameter.CodeInvalidVotingProcedure, fmt.Sprintf("Json is not valid"))
return sdk.NewError(iparam.DefaultCodespace, iparam.CodeInvalidVotingProcedure, fmt.Sprintf("Json is not valid"))
}

var TallyingProcedureParameter TallyingProcedureParam
var _ parameter.GovParameter = (*TallyingProcedureParam)(nil)
var _ iparam.GovParameter = (*TallyingProcedureParam)(nil)

// Procedure around Tallying votes in governance
type TallyingProcedure struct {
Expand Down Expand Up @@ -266,19 +265,19 @@ func (param *TallyingProcedureParam) Valid(jsonStr string) sdk.Error {
if err = json.Unmarshal([]byte(jsonStr), &param.Value); err == nil {

if param.Value.Threshold.LT(sdk.NewRat(0)) || param.Value.Threshold.GT(sdk.NewRat(1)) {
return sdk.NewError(parameter.DefaultCodespace, parameter.CodeInvalidThreshold, fmt.Sprintf("VotingPeriod ( "+param.Value.Threshold.String()+" ) should be between 0 and 1"))
return sdk.NewError(iparam.DefaultCodespace, iparam.CodeInvalidThreshold, fmt.Sprintf("VotingPeriod ( "+param.Value.Threshold.String()+" ) should be between 0 and 1"))
}
if param.Value.GovernancePenalty.LT(sdk.NewRat(0)) || param.Value.GovernancePenalty.GT(sdk.NewRat(1)) {
return sdk.NewError(parameter.DefaultCodespace, parameter.CodeInvalidGovernancePenalty, fmt.Sprintf("VotingPeriod ( "+param.Value.GovernancePenalty.String()+" ) should be between 0 and 1"))
return sdk.NewError(iparam.DefaultCodespace, iparam.CodeInvalidGovernancePenalty, fmt.Sprintf("VotingPeriod ( "+param.Value.GovernancePenalty.String()+" ) should be between 0 and 1"))
}
if param.Value.Veto.LT(sdk.NewRat(0)) || param.Value.Veto.GT(sdk.NewRat(1)) {
return sdk.NewError(parameter.DefaultCodespace, parameter.CodeInvalidVeto, fmt.Sprintf("VotingPeriod ( "+param.Value.Veto.String()+" ) should be between 0 and 1"))
return sdk.NewError(iparam.DefaultCodespace, iparam.CodeInvalidVeto, fmt.Sprintf("VotingPeriod ( "+param.Value.Veto.String()+" ) should be between 0 and 1"))
}

return nil

}
return sdk.NewError(parameter.DefaultCodespace, parameter.CodeInvalidTallyingProcedure, fmt.Sprintf("Json is not valid"))
return sdk.NewError(iparam.DefaultCodespace, iparam.CodeInvalidTallyingProcedure, fmt.Sprintf("Json is not valid"))
}


Loading