Merge PR #4757: update x/genutil to match module spec
* reestructure genutil * use auth and staking types packages * cleanup * rename pkg * chacha cha * update clog tags and pending * address comments from code review
This commit is contained in:
parent
231fefadb3
commit
bfb6445b05
|
@ -10,3 +10,4 @@ tags:
|
||||||
- abci
|
- abci
|
||||||
- rest
|
- rest
|
||||||
- cli
|
- cli
|
||||||
|
- modules
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
#4751 update `x/genutils` to match module spec
|
|
@ -5,7 +5,7 @@
|
||||||
package genaccounts
|
package genaccounts
|
||||||
|
|
||||||
import (
|
import (
|
||||||
types "github.com/cosmos/cosmos-sdk/x/genaccounts/internal/types"
|
"github.com/cosmos/cosmos-sdk/x/genaccounts/internal/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
|
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
|
||||||
types "github.com/cosmos/cosmos-sdk/x/genaccounts/internal/types"
|
"github.com/cosmos/cosmos-sdk/x/genaccounts/internal/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// InitGenesis initializes accounts and deliver genesis transactions
|
// InitGenesis initializes accounts and deliver genesis transactions
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package genaccounts
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package genaccounts
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package genaccounts
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package genaccounts
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package genaccounts
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package genaccounts
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/types/module"
|
"github.com/cosmos/cosmos-sdk/types/module"
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth/exported"
|
"github.com/cosmos/cosmos-sdk/x/auth/exported"
|
||||||
types "github.com/cosmos/cosmos-sdk/x/genaccounts/internal/types"
|
"github.com/cosmos/cosmos-sdk/x/genaccounts/internal/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
// nolint
|
||||||
|
// autogenerated code using github.com/rigelrozanski/multitool
|
||||||
|
// aliases generated for the following subdirectories:
|
||||||
|
// ALIASGEN: github.com/cosmos/cosmos-sdk/x/genutil/types
|
||||||
|
package genutil
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ModuleName = types.ModuleName
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// functions aliases
|
||||||
|
NewGenesisState = types.NewGenesisState
|
||||||
|
NewGenesisStateFromStdTx = types.NewGenesisStateFromStdTx
|
||||||
|
NewInitConfig = types.NewInitConfig
|
||||||
|
GetGenesisStateFromAppState = types.GetGenesisStateFromAppState
|
||||||
|
SetGenesisStateInAppState = types.SetGenesisStateInAppState
|
||||||
|
GenesisStateFromGenDoc = types.GenesisStateFromGenDoc
|
||||||
|
GenesisStateFromGenFile = types.GenesisStateFromGenFile
|
||||||
|
ValidateGenesis = types.ValidateGenesis
|
||||||
|
|
||||||
|
// variable aliases
|
||||||
|
ModuleCdc = types.ModuleCdc
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
GenesisState = types.GenesisState
|
||||||
|
AppMap = types.AppMap
|
||||||
|
MigrationCallback = types.MigrationCallback
|
||||||
|
MigrationMap = types.MigrationMap
|
||||||
|
InitConfig = types.InitConfig
|
||||||
|
)
|
|
@ -13,13 +13,14 @@ import (
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/server"
|
"github.com/cosmos/cosmos-sdk/server"
|
||||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
const flagGenTxDir = "gentx-dir"
|
const flagGenTxDir = "gentx-dir"
|
||||||
|
|
||||||
// CollectGenTxsCmd - return the cobra command to collect genesis transactions
|
// CollectGenTxsCmd - return the cobra command to collect genesis transactions
|
||||||
func CollectGenTxsCmd(ctx *server.Context, cdc *codec.Codec,
|
func CollectGenTxsCmd(ctx *server.Context, cdc *codec.Codec,
|
||||||
genAccIterator genutil.GenesisAccountsIterator, defaultNodeHome string) *cobra.Command {
|
genAccIterator types.GenesisAccountsIterator, defaultNodeHome string) *cobra.Command {
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "collect-gentxs",
|
Use: "collect-gentxs",
|
||||||
|
|
|
@ -29,9 +29,10 @@ import (
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// helpers for message building gen-tx command
|
// StakingMsgBuildingHelpers helpers for message building gen-tx command
|
||||||
type StakingMsgBuildingHelpers interface {
|
type StakingMsgBuildingHelpers interface {
|
||||||
CreateValidatorMsgHelpers(ipDefault string) (fs *flag.FlagSet, nodeIDFlag, pubkeyFlag, amountFlag, defaultsDesc string)
|
CreateValidatorMsgHelpers(ipDefault string) (fs *flag.FlagSet, nodeIDFlag, pubkeyFlag, amountFlag, defaultsDesc string)
|
||||||
PrepareFlagsForTxCreateValidator(config *cfg.Config, nodeID, chainID string, valPubKey crypto.PubKey)
|
PrepareFlagsForTxCreateValidator(config *cfg.Config, nodeID, chainID string, valPubKey crypto.PubKey)
|
||||||
|
@ -41,7 +42,7 @@ type StakingMsgBuildingHelpers interface {
|
||||||
// GenTxCmd builds the application's gentx command.
|
// GenTxCmd builds the application's gentx command.
|
||||||
// nolint: errcheck
|
// nolint: errcheck
|
||||||
func GenTxCmd(ctx *server.Context, cdc *codec.Codec, mbm module.BasicManager, smbh StakingMsgBuildingHelpers,
|
func GenTxCmd(ctx *server.Context, cdc *codec.Codec, mbm module.BasicManager, smbh StakingMsgBuildingHelpers,
|
||||||
genAccIterator genutil.GenesisAccountsIterator, defaultNodeHome, defaultCLIHome string) *cobra.Command {
|
genAccIterator types.GenesisAccountsIterator, defaultNodeHome, defaultCLIHome string) *cobra.Command {
|
||||||
|
|
||||||
ipDefault, _ := server.ExternalIP()
|
ipDefault, _ := server.ExternalIP()
|
||||||
fsCreateValidator, flagNodeID, flagPubKey, flagAmount, defaultsDesc := smbh.CreateValidatorMsgHelpers(ipDefault)
|
fsCreateValidator, flagNodeID, flagPubKey, flagAmount, defaultsDesc := smbh.CreateValidatorMsgHelpers(ipDefault)
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
package genutil
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
|
||||||
)
|
|
||||||
|
|
||||||
// generic sealed codec to be used throughout this module
|
|
||||||
var moduleCdc *codec.Codec
|
|
||||||
|
|
||||||
// TODO abstract genesis transactions registration back to staking
|
|
||||||
// required for genesis transactions
|
|
||||||
func init() {
|
|
||||||
moduleCdc = codec.New()
|
|
||||||
staking.RegisterCodec(moduleCdc)
|
|
||||||
auth.RegisterCodec(moduleCdc)
|
|
||||||
sdk.RegisterCodec(moduleCdc)
|
|
||||||
codec.RegisterCrypto(moduleCdc)
|
|
||||||
moduleCdc.Seal()
|
|
||||||
}
|
|
|
@ -13,39 +13,20 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
cfg "github.com/tendermint/tendermint/config"
|
cfg "github.com/tendermint/tendermint/config"
|
||||||
"github.com/tendermint/tendermint/crypto"
|
|
||||||
tmtypes "github.com/tendermint/tendermint/types"
|
tmtypes "github.com/tendermint/tendermint/types"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
|
||||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||||
|
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// common config options for init
|
// GenAppStateFromConfig gets the genesis app state from the config
|
||||||
type InitConfig struct {
|
|
||||||
ChainID string
|
|
||||||
GenTxsDir string
|
|
||||||
Name string
|
|
||||||
NodeID string
|
|
||||||
ValPubKey crypto.PubKey
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewInitConfig creates a new InitConfig object
|
|
||||||
func NewInitConfig(chainID, genTxsDir, name, nodeID string, valPubKey crypto.PubKey) InitConfig {
|
|
||||||
return InitConfig{
|
|
||||||
ChainID: chainID,
|
|
||||||
GenTxsDir: genTxsDir,
|
|
||||||
Name: name,
|
|
||||||
NodeID: nodeID,
|
|
||||||
ValPubKey: valPubKey,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// get the genesis app state from the config
|
|
||||||
func GenAppStateFromConfig(cdc *codec.Codec, config *cfg.Config,
|
func GenAppStateFromConfig(cdc *codec.Codec, config *cfg.Config,
|
||||||
initCfg InitConfig, genDoc tmtypes.GenesisDoc,
|
initCfg InitConfig, genDoc tmtypes.GenesisDoc,
|
||||||
genAccIterator GenesisAccountsIterator,
|
genAccIterator types.GenesisAccountsIterator,
|
||||||
) (appState json.RawMessage, err error) {
|
) (appState json.RawMessage, err error) {
|
||||||
|
|
||||||
// process genesis transactions, else create default genesis.json
|
// process genesis transactions, else create default genesis.json
|
||||||
|
@ -83,30 +64,11 @@ func GenAppStateFromConfig(cdc *codec.Codec, config *cfg.Config,
|
||||||
return appState, err
|
return appState, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the genesis transactions int the app genesis state
|
|
||||||
func SetGenTxsInAppGenesisState(cdc *codec.Codec, appGenesisState map[string]json.RawMessage,
|
|
||||||
genTxs []auth.StdTx) (map[string]json.RawMessage, error) {
|
|
||||||
|
|
||||||
genesisState := GetGenesisStateFromAppState(cdc, appGenesisState)
|
|
||||||
// convert all the GenTxs to JSON
|
|
||||||
var genTxsBz []json.RawMessage
|
|
||||||
for _, genTx := range genTxs {
|
|
||||||
txBz, err := cdc.MarshalJSON(genTx)
|
|
||||||
if err != nil {
|
|
||||||
return appGenesisState, err
|
|
||||||
}
|
|
||||||
genTxsBz = append(genTxsBz, txBz)
|
|
||||||
}
|
|
||||||
|
|
||||||
genesisState.GenTxs = genTxsBz
|
|
||||||
return SetGenesisStateInAppState(cdc, appGenesisState, genesisState), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// CollectStdTxs processes and validates application's genesis StdTxs and returns
|
// CollectStdTxs processes and validates application's genesis StdTxs and returns
|
||||||
// the list of appGenTxs, and persistent peers required to generate genesis.json.
|
// the list of appGenTxs, and persistent peers required to generate genesis.json.
|
||||||
func CollectStdTxs(cdc *codec.Codec, moniker, genTxsDir string,
|
func CollectStdTxs(cdc *codec.Codec, moniker, genTxsDir string,
|
||||||
genDoc tmtypes.GenesisDoc, genAccIterator GenesisAccountsIterator,
|
genDoc tmtypes.GenesisDoc, genAccIterator types.GenesisAccountsIterator,
|
||||||
) (appGenTxs []auth.StdTx, persistentPeers string, err error) {
|
) (appGenTxs []authtypes.StdTx, persistentPeers string, err error) {
|
||||||
|
|
||||||
var fos []os.FileInfo
|
var fos []os.FileInfo
|
||||||
fos, err = ioutil.ReadDir(genTxsDir)
|
fos, err = ioutil.ReadDir(genTxsDir)
|
||||||
|
@ -121,9 +83,9 @@ func CollectStdTxs(cdc *codec.Codec, moniker, genTxsDir string,
|
||||||
return appGenTxs, persistentPeers, err
|
return appGenTxs, persistentPeers, err
|
||||||
}
|
}
|
||||||
|
|
||||||
addrMap := make(map[string]auth.Account)
|
addrMap := make(map[string]authexported.Account)
|
||||||
genAccIterator.IterateGenesisAccounts(cdc, appState,
|
genAccIterator.IterateGenesisAccounts(cdc, appState,
|
||||||
func(acc auth.Account) (stop bool) {
|
func(acc authexported.Account) (stop bool) {
|
||||||
addrMap[acc.GetAddress().String()] = acc
|
addrMap[acc.GetAddress().String()] = acc
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
|
@ -143,7 +105,7 @@ func CollectStdTxs(cdc *codec.Codec, moniker, genTxsDir string,
|
||||||
if jsonRawTx, err = ioutil.ReadFile(filename); err != nil {
|
if jsonRawTx, err = ioutil.ReadFile(filename); err != nil {
|
||||||
return appGenTxs, persistentPeers, err
|
return appGenTxs, persistentPeers, err
|
||||||
}
|
}
|
||||||
var genStdTx auth.StdTx
|
var genStdTx authtypes.StdTx
|
||||||
if err = cdc.UnmarshalJSON(jsonRawTx, &genStdTx); err != nil {
|
if err = cdc.UnmarshalJSON(jsonRawTx, &genStdTx); err != nil {
|
||||||
return appGenTxs, persistentPeers, err
|
return appGenTxs, persistentPeers, err
|
||||||
}
|
}
|
||||||
|
@ -166,7 +128,7 @@ func CollectStdTxs(cdc *codec.Codec, moniker, genTxsDir string,
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO abstract out staking message validation back to staking
|
// TODO abstract out staking message validation back to staking
|
||||||
msg := msgs[0].(staking.MsgCreateValidator)
|
msg := msgs[0].(stakingtypes.MsgCreateValidator)
|
||||||
// validate delegator and validator addresses and funds against the accounts in the state
|
// validate delegator and validator addresses and funds against the accounts in the state
|
||||||
delAddr := msg.DelegatorAddress.String()
|
delAddr := msg.DelegatorAddress.String()
|
||||||
valAddr := sdk.AccAddress(msg.ValidatorAddress).String()
|
valAddr := sdk.AccAddress(msg.ValidatorAddress).String()
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
package genutil
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
|
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
|
||||||
)
|
|
||||||
|
|
||||||
// expected staking keeper
|
|
||||||
type StakingKeeper interface {
|
|
||||||
ApplyAndReturnValidatorSetUpdates(sdk.Context) (updates []abci.ValidatorUpdate)
|
|
||||||
}
|
|
||||||
|
|
||||||
// expected account keeper
|
|
||||||
type AccountKeeper interface {
|
|
||||||
NewAccount(sdk.Context, auth.Account) auth.Account
|
|
||||||
SetAccount(sdk.Context, auth.Account)
|
|
||||||
IterateAccounts(ctx sdk.Context, process func(auth.Account) (stop bool))
|
|
||||||
}
|
|
||||||
|
|
||||||
// The expected interface for iterating genesis accounts object
|
|
||||||
type GenesisAccountsIterator interface {
|
|
||||||
IterateGenesisAccounts(
|
|
||||||
cdc *codec.Codec,
|
|
||||||
appGenesis map[string]json.RawMessage,
|
|
||||||
iterateFn func(auth.Account) (stop bool),
|
|
||||||
)
|
|
||||||
}
|
|
|
@ -5,10 +5,11 @@ import (
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// initialize accounts and deliver genesis transactions
|
// InitGenesis - initialize accounts and deliver genesis transactions
|
||||||
func InitGenesis(ctx sdk.Context, cdc *codec.Codec, stakingKeeper StakingKeeper,
|
func InitGenesis(ctx sdk.Context, cdc *codec.Codec, stakingKeeper types.StakingKeeper,
|
||||||
deliverTx deliverTxfn, genesisState GenesisState) []abci.ValidatorUpdate {
|
deliverTx deliverTxfn, genesisState GenesisState) []abci.ValidatorUpdate {
|
||||||
|
|
||||||
var validators []abci.ValidatorUpdate
|
var validators []abci.ValidatorUpdate
|
|
@ -1,47 +0,0 @@
|
||||||
package genutil
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
pk1 = ed25519.GenPrivKey().PubKey()
|
|
||||||
pk2 = ed25519.GenPrivKey().PubKey()
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestValidateGenesisMultipleMessages(t *testing.T) {
|
|
||||||
|
|
||||||
desc := staking.NewDescription("testname", "", "", "")
|
|
||||||
comm := staking.CommissionRates{}
|
|
||||||
|
|
||||||
msg1 := staking.NewMsgCreateValidator(sdk.ValAddress(pk1.Address()), pk1,
|
|
||||||
sdk.NewInt64Coin(sdk.DefaultBondDenom, 50), desc, comm, sdk.OneInt())
|
|
||||||
|
|
||||||
msg2 := staking.NewMsgCreateValidator(sdk.ValAddress(pk2.Address()), pk2,
|
|
||||||
sdk.NewInt64Coin(sdk.DefaultBondDenom, 50), desc, comm, sdk.OneInt())
|
|
||||||
|
|
||||||
genTxs := auth.NewStdTx([]sdk.Msg{msg1, msg2}, auth.StdFee{}, nil, "")
|
|
||||||
genesisState := NewGenesisStateFromStdTx([]auth.StdTx{genTxs})
|
|
||||||
|
|
||||||
err := ValidateGenesis(genesisState)
|
|
||||||
require.Error(t, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestValidateGenesisBadMessage(t *testing.T) {
|
|
||||||
desc := staking.NewDescription("testname", "", "", "")
|
|
||||||
|
|
||||||
msg1 := staking.NewMsgEditValidator(sdk.ValAddress(pk1.Address()), desc, nil, nil)
|
|
||||||
|
|
||||||
genTxs := auth.NewStdTx([]sdk.Msg{msg1}, auth.StdFee{}, nil, "")
|
|
||||||
genesisState := NewGenesisStateFromStdTx([]auth.StdTx{genTxs})
|
|
||||||
|
|
||||||
err := ValidateGenesis(genesisState)
|
|
||||||
require.Error(t, err)
|
|
||||||
}
|
|
|
@ -10,31 +10,52 @@ import (
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
|
||||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||||
|
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// SetGenTxsInAppGenesisState - sets the genesis transactions in the app genesis state
|
||||||
|
func SetGenTxsInAppGenesisState(cdc *codec.Codec, appGenesisState map[string]json.RawMessage,
|
||||||
|
genTxs []authtypes.StdTx) (map[string]json.RawMessage, error) {
|
||||||
|
|
||||||
|
genesisState := GetGenesisStateFromAppState(cdc, appGenesisState)
|
||||||
|
// convert all the GenTxs to JSON
|
||||||
|
var genTxsBz []json.RawMessage
|
||||||
|
for _, genTx := range genTxs {
|
||||||
|
txBz, err := cdc.MarshalJSON(genTx)
|
||||||
|
if err != nil {
|
||||||
|
return appGenesisState, err
|
||||||
|
}
|
||||||
|
genTxsBz = append(genTxsBz, txBz)
|
||||||
|
}
|
||||||
|
|
||||||
|
genesisState.GenTxs = genTxsBz
|
||||||
|
return SetGenesisStateInAppState(cdc, appGenesisState, genesisState), nil
|
||||||
|
}
|
||||||
|
|
||||||
// ValidateAccountInGenesis checks that the provided key has sufficient
|
// ValidateAccountInGenesis checks that the provided key has sufficient
|
||||||
// coins in the genesis accounts
|
// coins in the genesis accounts
|
||||||
func ValidateAccountInGenesis(appGenesisState map[string]json.RawMessage,
|
func ValidateAccountInGenesis(appGenesisState map[string]json.RawMessage,
|
||||||
genAccIterator GenesisAccountsIterator,
|
genAccIterator types.GenesisAccountsIterator,
|
||||||
key sdk.AccAddress, coins sdk.Coins, cdc *codec.Codec) error {
|
key sdk.AccAddress, coins sdk.Coins, cdc *codec.Codec) error {
|
||||||
|
|
||||||
accountIsInGenesis := false
|
accountIsInGenesis := false
|
||||||
|
|
||||||
// TODO refactor out bond denom to common state area
|
// TODO: refactor out bond denom to common state area
|
||||||
stakingDataBz := appGenesisState[staking.ModuleName]
|
stakingDataBz := appGenesisState[stakingtypes.ModuleName]
|
||||||
var stakingData staking.GenesisState
|
var stakingData stakingtypes.GenesisState
|
||||||
cdc.MustUnmarshalJSON(stakingDataBz, &stakingData)
|
cdc.MustUnmarshalJSON(stakingDataBz, &stakingData)
|
||||||
bondDenom := stakingData.Params.BondDenom
|
bondDenom := stakingData.Params.BondDenom
|
||||||
|
|
||||||
genUtilDataBz := appGenesisState[staking.ModuleName]
|
genUtilDataBz := appGenesisState[stakingtypes.ModuleName]
|
||||||
var genesisState GenesisState
|
var genesisState GenesisState
|
||||||
cdc.MustUnmarshalJSON(genUtilDataBz, &genesisState)
|
cdc.MustUnmarshalJSON(genUtilDataBz, &genesisState)
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
genAccIterator.IterateGenesisAccounts(cdc, appGenesisState,
|
genAccIterator.IterateGenesisAccounts(cdc, appGenesisState,
|
||||||
func(acc auth.Account) (stop bool) {
|
func(acc authexported.Account) (stop bool) {
|
||||||
accAddress := acc.GetAddress()
|
accAddress := acc.GetAddress()
|
||||||
accCoins := acc.GetCoins()
|
accCoins := acc.GetCoins()
|
||||||
|
|
||||||
|
@ -68,12 +89,12 @@ func ValidateAccountInGenesis(appGenesisState map[string]json.RawMessage,
|
||||||
|
|
||||||
type deliverTxfn func(abci.RequestDeliverTx) abci.ResponseDeliverTx
|
type deliverTxfn func(abci.RequestDeliverTx) abci.ResponseDeliverTx
|
||||||
|
|
||||||
// deliver a genesis transaction
|
// DeliverGenTxs - deliver a genesis transaction
|
||||||
func DeliverGenTxs(ctx sdk.Context, cdc *codec.Codec, genTxs []json.RawMessage,
|
func DeliverGenTxs(ctx sdk.Context, cdc *codec.Codec, genTxs []json.RawMessage,
|
||||||
stakingKeeper StakingKeeper, deliverTx deliverTxfn) []abci.ValidatorUpdate {
|
stakingKeeper types.StakingKeeper, deliverTx deliverTxfn) []abci.ValidatorUpdate {
|
||||||
|
|
||||||
for _, genTx := range genTxs {
|
for _, genTx := range genTxs {
|
||||||
var tx auth.StdTx
|
var tx authtypes.StdTx
|
||||||
cdc.MustUnmarshalJSON(genTx, &tx)
|
cdc.MustUnmarshalJSON(genTx, &tx)
|
||||||
bz := cdc.MustMarshalBinaryLengthPrefixed(tx)
|
bz := cdc.MustMarshalBinaryLengthPrefixed(tx)
|
||||||
res := deliverTx(abci.RequestDeliverTx{Tx: bz})
|
res := deliverTx(abci.RequestDeliverTx{Tx: bz})
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/types/module"
|
"github.com/cosmos/cosmos-sdk/types/module"
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -19,9 +20,6 @@ var (
|
||||||
_ module.AppModuleBasic = AppModuleBasic{}
|
_ module.AppModuleBasic = AppModuleBasic{}
|
||||||
)
|
)
|
||||||
|
|
||||||
// module name
|
|
||||||
const ModuleName = "genutil"
|
|
||||||
|
|
||||||
// app module basics object
|
// app module basics object
|
||||||
type AppModuleBasic struct{}
|
type AppModuleBasic struct{}
|
||||||
|
|
||||||
|
@ -35,13 +33,13 @@ func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) {}
|
||||||
|
|
||||||
// default genesis state
|
// default genesis state
|
||||||
func (AppModuleBasic) DefaultGenesis() json.RawMessage {
|
func (AppModuleBasic) DefaultGenesis() json.RawMessage {
|
||||||
return moduleCdc.MustMarshalJSON(GenesisState{})
|
return ModuleCdc.MustMarshalJSON(GenesisState{})
|
||||||
}
|
}
|
||||||
|
|
||||||
// module validate genesis
|
// module validate genesis
|
||||||
func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error {
|
func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error {
|
||||||
var data GenesisState
|
var data GenesisState
|
||||||
err := moduleCdc.UnmarshalJSON(bz, &data)
|
err := ModuleCdc.UnmarshalJSON(bz, &data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -61,14 +59,14 @@ func (AppModuleBasic) GetQueryCmd(_ *codec.Codec) *cobra.Command { return nil }
|
||||||
// app module
|
// app module
|
||||||
type AppModule struct {
|
type AppModule struct {
|
||||||
AppModuleBasic
|
AppModuleBasic
|
||||||
accountKeeper AccountKeeper
|
accountKeeper types.AccountKeeper
|
||||||
stakingKeeper StakingKeeper
|
stakingKeeper types.StakingKeeper
|
||||||
deliverTx deliverTxfn
|
deliverTx deliverTxfn
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewAppModule creates a new AppModule object
|
// NewAppModule creates a new AppModule object
|
||||||
func NewAppModule(accountKeeper AccountKeeper,
|
func NewAppModule(accountKeeper types.AccountKeeper,
|
||||||
stakingKeeper StakingKeeper, deliverTx deliverTxfn) module.AppModule {
|
stakingKeeper types.StakingKeeper, deliverTx deliverTxfn) module.AppModule {
|
||||||
|
|
||||||
return module.NewGenesisOnlyAppModule(AppModule{
|
return module.NewGenesisOnlyAppModule(AppModule{
|
||||||
AppModuleBasic: AppModuleBasic{},
|
AppModuleBasic: AppModuleBasic{},
|
||||||
|
@ -81,8 +79,8 @@ func NewAppModule(accountKeeper AccountKeeper,
|
||||||
// module init-genesis
|
// module init-genesis
|
||||||
func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate {
|
func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate {
|
||||||
var genesisState GenesisState
|
var genesisState GenesisState
|
||||||
moduleCdc.MustUnmarshalJSON(data, &genesisState)
|
ModuleCdc.MustUnmarshalJSON(data, &genesisState)
|
||||||
return InitGenesis(ctx, moduleCdc, am.stakingKeeper, am.deliverTx, genesisState)
|
return InitGenesis(ctx, ModuleCdc, am.stakingKeeper, am.deliverTx, genesisState)
|
||||||
}
|
}
|
||||||
|
|
||||||
// module export genesis
|
// module export genesis
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
package genutil
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
)
|
|
||||||
|
|
||||||
type (
|
|
||||||
// AppMap map modules names with their json raw representation
|
|
||||||
AppMap map[string]json.RawMessage
|
|
||||||
// MigrationCallback converts a genesis map from the previous version to the targeted one
|
|
||||||
MigrationCallback func(AppMap) AppMap
|
|
||||||
// MigrationMap defines a mapping from a version to a MigrationCallback
|
|
||||||
MigrationMap map[string]MigrationCallback
|
|
||||||
)
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package types
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||||
|
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ModuleCdc defines a generic sealed codec to be used throughout this module
|
||||||
|
var ModuleCdc *codec.Codec
|
||||||
|
|
||||||
|
// TODO: abstract genesis transactions registration back to staking
|
||||||
|
// required for genesis transactions
|
||||||
|
func init() {
|
||||||
|
ModuleCdc = codec.New()
|
||||||
|
stakingtypes.RegisterCodec(ModuleCdc)
|
||||||
|
authtypes.RegisterCodec(ModuleCdc)
|
||||||
|
sdk.RegisterCodec(ModuleCdc)
|
||||||
|
codec.RegisterCrypto(ModuleCdc)
|
||||||
|
ModuleCdc.Seal()
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package types
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
|
||||||
|
)
|
||||||
|
|
||||||
|
// StakingKeeper defines the expected staking keeper (noalias)
|
||||||
|
type StakingKeeper interface {
|
||||||
|
ApplyAndReturnValidatorSetUpdates(sdk.Context) (updates []abci.ValidatorUpdate)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AccountKeeper defines the expected account keeper (noalias)
|
||||||
|
type AccountKeeper interface {
|
||||||
|
NewAccount(sdk.Context, authexported.Account) authexported.Account
|
||||||
|
SetAccount(sdk.Context, authexported.Account)
|
||||||
|
IterateAccounts(ctx sdk.Context, process func(authexported.Account) (stop bool))
|
||||||
|
}
|
||||||
|
|
||||||
|
// GenesisAccountsIterator defines the expected iterating genesis accounts object (noalias)
|
||||||
|
type GenesisAccountsIterator interface {
|
||||||
|
IterateGenesisAccounts(
|
||||||
|
cdc *codec.Codec,
|
||||||
|
appGenesis map[string]json.RawMessage,
|
||||||
|
iterateFn func(authexported.Account) (stop bool),
|
||||||
|
)
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package genutil
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
@ -9,11 +9,11 @@ import (
|
||||||
tmtypes "github.com/tendermint/tendermint/types"
|
tmtypes "github.com/tendermint/tendermint/types"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// State to Unmarshal
|
// GenesisState defines the raw genesis transaction in JSON
|
||||||
type GenesisState struct {
|
type GenesisState struct {
|
||||||
GenTxs []json.RawMessage `json:"gentxs" yaml:"gentxs"`
|
GenTxs []json.RawMessage `json:"gentxs" yaml:"gentxs"`
|
||||||
}
|
}
|
||||||
|
@ -27,17 +27,15 @@ func NewGenesisState(genTxs []json.RawMessage) GenesisState {
|
||||||
|
|
||||||
// NewGenesisStateFromStdTx creates a new GenesisState object
|
// NewGenesisStateFromStdTx creates a new GenesisState object
|
||||||
// from auth transactions
|
// from auth transactions
|
||||||
func NewGenesisStateFromStdTx(genTxs []auth.StdTx) GenesisState {
|
func NewGenesisStateFromStdTx(genTxs []authtypes.StdTx) GenesisState {
|
||||||
genTxsBz := make([]json.RawMessage, len(genTxs))
|
genTxsBz := make([]json.RawMessage, len(genTxs))
|
||||||
for i, genTx := range genTxs {
|
for i, genTx := range genTxs {
|
||||||
genTxsBz[i] = moduleCdc.MustMarshalJSON(genTx)
|
genTxsBz[i] = ModuleCdc.MustMarshalJSON(genTx)
|
||||||
}
|
|
||||||
return GenesisState{
|
|
||||||
GenTxs: genTxsBz,
|
|
||||||
}
|
}
|
||||||
|
return NewGenesisState(genTxsBz)
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the genutil genesis state from the expected app state
|
// GetGenesisStateFromAppState gets the genutil genesis state from the expected app state
|
||||||
func GetGenesisStateFromAppState(cdc *codec.Codec, appState map[string]json.RawMessage) GenesisState {
|
func GetGenesisStateFromAppState(cdc *codec.Codec, appState map[string]json.RawMessage) GenesisState {
|
||||||
var genesisState GenesisState
|
var genesisState GenesisState
|
||||||
if appState[ModuleName] != nil {
|
if appState[ModuleName] != nil {
|
||||||
|
@ -46,7 +44,7 @@ func GetGenesisStateFromAppState(cdc *codec.Codec, appState map[string]json.RawM
|
||||||
return genesisState
|
return genesisState
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the genutil genesis state within the expected app state
|
// SetGenesisStateInAppState sets the genutil genesis state within the expected app state
|
||||||
func SetGenesisStateInAppState(cdc *codec.Codec,
|
func SetGenesisStateInAppState(cdc *codec.Codec,
|
||||||
appState map[string]json.RawMessage, genesisState GenesisState) map[string]json.RawMessage {
|
appState map[string]json.RawMessage, genesisState GenesisState) map[string]json.RawMessage {
|
||||||
|
|
||||||
|
@ -55,7 +53,8 @@ func SetGenesisStateInAppState(cdc *codec.Codec,
|
||||||
return appState
|
return appState
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the core parameters for genesis initialization for the application.
|
// GenesisStateFromGenDoc creates the core parameters for genesis initialization
|
||||||
|
// for the application.
|
||||||
//
|
//
|
||||||
// NOTE: The pubkey input is this machines pubkey.
|
// NOTE: The pubkey input is this machines pubkey.
|
||||||
func GenesisStateFromGenDoc(cdc *codec.Codec, genDoc tmtypes.GenesisDoc,
|
func GenesisStateFromGenDoc(cdc *codec.Codec, genDoc tmtypes.GenesisDoc,
|
||||||
|
@ -67,7 +66,8 @@ func GenesisStateFromGenDoc(cdc *codec.Codec, genDoc tmtypes.GenesisDoc,
|
||||||
return genesisState, nil
|
return genesisState, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the core parameters for genesis initialization for the application.
|
// GenesisStateFromGenFile creates the core parameters for genesis initialization
|
||||||
|
// for the application.
|
||||||
//
|
//
|
||||||
// NOTE: The pubkey input is this machines pubkey.
|
// NOTE: The pubkey input is this machines pubkey.
|
||||||
func GenesisStateFromGenFile(cdc *codec.Codec, genFile string,
|
func GenesisStateFromGenFile(cdc *codec.Codec, genFile string,
|
||||||
|
@ -86,11 +86,11 @@ func GenesisStateFromGenFile(cdc *codec.Codec, genFile string,
|
||||||
return genesisState, genDoc, err
|
return genesisState, genDoc, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate GenTx transactions
|
// ValidateGenesis validates GenTx transactions
|
||||||
func ValidateGenesis(genesisState GenesisState) error {
|
func ValidateGenesis(genesisState GenesisState) error {
|
||||||
for i, genTx := range genesisState.GenTxs {
|
for i, genTx := range genesisState.GenTxs {
|
||||||
var tx auth.StdTx
|
var tx authtypes.StdTx
|
||||||
if err := moduleCdc.UnmarshalJSON(genTx, &tx); err != nil {
|
if err := ModuleCdc.UnmarshalJSON(genTx, &tx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,10 +100,10 @@ func ValidateGenesis(genesisState GenesisState) error {
|
||||||
"must provide genesis StdTx with exactly 1 CreateValidator message")
|
"must provide genesis StdTx with exactly 1 CreateValidator message")
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO abstract back to staking
|
// TODO: abstract back to staking
|
||||||
if _, ok := msgs[0].(staking.MsgCreateValidator); !ok {
|
if _, ok := msgs[0].(stakingtypes.MsgCreateValidator); !ok {
|
||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
"Genesis transaction %v does not contain a MsgCreateValidator", i)
|
"genesis transaction %v does not contain a MsgCreateValidator", i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
|
@ -0,0 +1,46 @@
|
||||||
|
package types
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||||
|
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
pk1 = ed25519.GenPrivKey().PubKey()
|
||||||
|
pk2 = ed25519.GenPrivKey().PubKey()
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestValidateGenesisMultipleMessages(t *testing.T) {
|
||||||
|
|
||||||
|
desc := stakingtypes.NewDescription("testname", "", "", "")
|
||||||
|
comm := stakingtypes.CommissionRates{}
|
||||||
|
|
||||||
|
msg1 := stakingtypes.NewMsgCreateValidator(sdk.ValAddress(pk1.Address()), pk1,
|
||||||
|
sdk.NewInt64Coin(sdk.DefaultBondDenom, 50), desc, comm, sdk.OneInt())
|
||||||
|
|
||||||
|
msg2 := stakingtypes.NewMsgCreateValidator(sdk.ValAddress(pk2.Address()), pk2,
|
||||||
|
sdk.NewInt64Coin(sdk.DefaultBondDenom, 50), desc, comm, sdk.OneInt())
|
||||||
|
|
||||||
|
genTxs := authtypes.NewStdTx([]sdk.Msg{msg1, msg2}, authtypes.StdFee{}, nil, "")
|
||||||
|
genesisState := NewGenesisStateFromStdTx([]authtypes.StdTx{genTxs})
|
||||||
|
|
||||||
|
err := ValidateGenesis(genesisState)
|
||||||
|
require.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestValidateGenesisBadMessage(t *testing.T) {
|
||||||
|
desc := stakingtypes.NewDescription("testname", "", "", "")
|
||||||
|
|
||||||
|
msg1 := stakingtypes.NewMsgEditValidator(sdk.ValAddress(pk1.Address()), desc, nil, nil)
|
||||||
|
|
||||||
|
genTxs := authtypes.NewStdTx([]sdk.Msg{msg1}, authtypes.StdFee{}, nil, "")
|
||||||
|
genesisState := NewGenesisStateFromStdTx([]authtypes.StdTx{genTxs})
|
||||||
|
|
||||||
|
err := ValidateGenesis(genesisState)
|
||||||
|
require.Error(t, err)
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package types
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/tendermint/tendermint/crypto"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DONTCOVER
|
||||||
|
|
||||||
|
type (
|
||||||
|
// AppMap map modules names with their json raw representation
|
||||||
|
AppMap map[string]json.RawMessage
|
||||||
|
// MigrationCallback converts a genesis map from the previous version to the targeted one
|
||||||
|
MigrationCallback func(AppMap) AppMap
|
||||||
|
// MigrationMap defines a mapping from a version to a MigrationCallback
|
||||||
|
MigrationMap map[string]MigrationCallback
|
||||||
|
)
|
||||||
|
|
||||||
|
// ModuleName is genutil
|
||||||
|
const ModuleName = "genutil"
|
||||||
|
|
||||||
|
// InitConfig common config options for init
|
||||||
|
type InitConfig struct {
|
||||||
|
ChainID string
|
||||||
|
GenTxsDir string
|
||||||
|
Name string
|
||||||
|
NodeID string
|
||||||
|
ValPubKey crypto.PubKey
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewInitConfig creates a new InitConfig object
|
||||||
|
func NewInitConfig(chainID, genTxsDir, name, nodeID string, valPubKey crypto.PubKey) InitConfig {
|
||||||
|
return InitConfig{
|
||||||
|
ChainID: chainID,
|
||||||
|
GenTxsDir: genTxsDir,
|
||||||
|
Name: name,
|
||||||
|
NodeID: nodeID,
|
||||||
|
ValPubKey: valPubKey,
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue