connected stake cli
This commit is contained in:
parent
f8e44b5b00
commit
f7437fd899
|
@ -15,6 +15,7 @@ import (
|
||||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||||
"github.com/cosmos/cosmos-sdk/x/ibc"
|
"github.com/cosmos/cosmos-sdk/x/ibc"
|
||||||
"github.com/cosmos/cosmos-sdk/x/simplestake"
|
"github.com/cosmos/cosmos-sdk/x/simplestake"
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/stake"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/examples/basecoin/types"
|
"github.com/cosmos/cosmos-sdk/examples/basecoin/types"
|
||||||
)
|
)
|
||||||
|
@ -32,7 +33,7 @@ type BasecoinApp struct {
|
||||||
capKeyMainStore *sdk.KVStoreKey
|
capKeyMainStore *sdk.KVStoreKey
|
||||||
capKeyAccountStore *sdk.KVStoreKey
|
capKeyAccountStore *sdk.KVStoreKey
|
||||||
capKeyIBCStore *sdk.KVStoreKey
|
capKeyIBCStore *sdk.KVStoreKey
|
||||||
capKeyStakingStore *sdk.KVStoreKey
|
capKeyStakeStore *sdk.KVStoreKey
|
||||||
|
|
||||||
// Manage getting and setting accounts
|
// Manage getting and setting accounts
|
||||||
accountMapper sdk.AccountMapper
|
accountMapper sdk.AccountMapper
|
||||||
|
@ -53,7 +54,7 @@ func NewBasecoinApp(logger log.Logger, db dbm.DB) *BasecoinApp {
|
||||||
capKeyMainStore: sdk.NewKVStoreKey("main"),
|
capKeyMainStore: sdk.NewKVStoreKey("main"),
|
||||||
capKeyAccountStore: sdk.NewKVStoreKey("acc"),
|
capKeyAccountStore: sdk.NewKVStoreKey("acc"),
|
||||||
capKeyIBCStore: sdk.NewKVStoreKey("ibc"),
|
capKeyIBCStore: sdk.NewKVStoreKey("ibc"),
|
||||||
capKeyStakingStore: sdk.NewKVStoreKey("stake"),
|
capKeyStakeStore: sdk.NewKVStoreKey("stake"),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define the accountMapper.
|
// Define the accountMapper.
|
||||||
|
@ -70,7 +71,7 @@ func NewBasecoinApp(logger log.Logger, db dbm.DB) *BasecoinApp {
|
||||||
app.Router().
|
app.Router().
|
||||||
AddRoute("bank", bank.NewHandler(coinKeeper)).
|
AddRoute("bank", bank.NewHandler(coinKeeper)).
|
||||||
AddRoute("ibc", ibc.NewHandler(ibcMapper, coinKeeper)).
|
AddRoute("ibc", ibc.NewHandler(ibcMapper, coinKeeper)).
|
||||||
AddRoute("simplestake", simplestake.NewHandler(stakeKeeper))
|
AddRoute("stake", stake.NewHandler(stakeKeeper))
|
||||||
|
|
||||||
// Define the feeHandler.
|
// Define the feeHandler.
|
||||||
app.feeHandler = auth.BurnFeeHandler
|
app.feeHandler = auth.BurnFeeHandler
|
||||||
|
|
|
@ -143,7 +143,7 @@ func TestSortGenesis(t *testing.T) {
|
||||||
// Note the order: the coins are unsorted!
|
// Note the order: the coins are unsorted!
|
||||||
coinDenom1, coinDenom2 := "foocoin", "barcoin"
|
coinDenom1, coinDenom2 := "foocoin", "barcoin"
|
||||||
|
|
||||||
genState := fmt.Sprintf(`{
|
str := `{
|
||||||
"accounts": [{
|
"accounts": [{
|
||||||
"address": "%s",
|
"address": "%s",
|
||||||
"coins": [
|
"coins": [
|
||||||
|
@ -157,7 +157,8 @@ func TestSortGenesis(t *testing.T) {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}]
|
}]
|
||||||
}`, addr1.String(), coinDenom1, coinDenom2)
|
}`
|
||||||
|
genState := fmt.Sprintf(str, addr1.String(), coinDenom1, coinDenom2)
|
||||||
|
|
||||||
// Initialize the chain
|
// Initialize the chain
|
||||||
vals := []abci.Validator{}
|
vals := []abci.Validator{}
|
||||||
|
|
|
@ -17,7 +17,7 @@ import (
|
||||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/commands"
|
authcmd "github.com/cosmos/cosmos-sdk/x/auth/commands"
|
||||||
bankcmd "github.com/cosmos/cosmos-sdk/x/bank/commands"
|
bankcmd "github.com/cosmos/cosmos-sdk/x/bank/commands"
|
||||||
ibccmd "github.com/cosmos/cosmos-sdk/x/ibc/commands"
|
ibccmd "github.com/cosmos/cosmos-sdk/x/ibc/commands"
|
||||||
simplestakingcmd "github.com/cosmos/cosmos-sdk/x/simplestake/commands"
|
stakecmd "github.com/cosmos/cosmos-sdk/x/stake/commands"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/examples/basecoin/app"
|
"github.com/cosmos/cosmos-sdk/examples/basecoin/app"
|
||||||
"github.com/cosmos/cosmos-sdk/examples/basecoin/types"
|
"github.com/cosmos/cosmos-sdk/examples/basecoin/types"
|
||||||
|
@ -52,23 +52,20 @@ func main() {
|
||||||
rootCmd.AddCommand(
|
rootCmd.AddCommand(
|
||||||
client.GetCommands(
|
client.GetCommands(
|
||||||
authcmd.GetAccountCmd("main", cdc, types.GetAccountDecoder(cdc)),
|
authcmd.GetAccountCmd("main", cdc, types.GetAccountDecoder(cdc)),
|
||||||
|
stakecmd.GetCmdQueryCandidates("stake", cdc),
|
||||||
|
stakecmd.GetCmdQueryCandidate("stake", cdc),
|
||||||
|
stakecmd.GetCmdQueryDelegatorBond("stake", cdc),
|
||||||
|
stakecmd.GetCmdQueryDelegatorBonds("stake", cdc),
|
||||||
)...)
|
)...)
|
||||||
rootCmd.AddCommand(
|
rootCmd.AddCommand(
|
||||||
client.PostCommands(
|
client.PostCommands(
|
||||||
bankcmd.SendTxCmd(cdc),
|
bankcmd.SendTxCmd(cdc),
|
||||||
)...)
|
|
||||||
rootCmd.AddCommand(
|
|
||||||
client.PostCommands(
|
|
||||||
ibccmd.IBCTransferCmd(cdc),
|
ibccmd.IBCTransferCmd(cdc),
|
||||||
)...)
|
|
||||||
rootCmd.AddCommand(
|
|
||||||
client.PostCommands(
|
|
||||||
ibccmd.IBCRelayCmd(cdc),
|
ibccmd.IBCRelayCmd(cdc),
|
||||||
simplestakingcmd.BondTxCmd(cdc),
|
stakecmd.GetCmdDeclareCandidacy(cdc),
|
||||||
)...)
|
stakecmd.GetCmdEditCandidacy(cdc),
|
||||||
rootCmd.AddCommand(
|
stakecmd.GetCmdDelegate(cdc),
|
||||||
client.PostCommands(
|
stakecmd.GetCmdUnbond(cdc),
|
||||||
simplestakingcmd.UnbondTxCmd(cdc),
|
|
||||||
)...)
|
)...)
|
||||||
|
|
||||||
// add proxy, version and key info
|
// add proxy, version and key info
|
||||||
|
|
|
@ -38,7 +38,7 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// create command to query for all candidates
|
// create command to query for all candidates
|
||||||
func GetCmdQueryCandidates(cdc *wire.Codec, storeName string) *cobra.Command {
|
func GetCmdQueryCandidates(storeName string, cdc *wire.Codec) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "candidates",
|
Use: "candidates",
|
||||||
Short: "Query for the set of validator-candidates pubkeys",
|
Short: "Query for the set of validator-candidates pubkeys",
|
||||||
|
@ -74,7 +74,7 @@ func GetCmdQueryCandidates(cdc *wire.Codec, storeName string) *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the command to query a candidate
|
// get the command to query a candidate
|
||||||
func GetCmdQueryCandidate(cdc *wire.Codec, storeName string) *cobra.Command {
|
func GetCmdQueryCandidate(storeName string, cdc *wire.Codec) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "candidate",
|
Use: "candidate",
|
||||||
Short: "Query a validator-candidate account",
|
Short: "Query a validator-candidate account",
|
||||||
|
@ -116,7 +116,7 @@ func GetCmdQueryCandidate(cdc *wire.Codec, storeName string) *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the command to query a single delegator bond
|
// get the command to query a single delegator bond
|
||||||
func GetCmdQueryDelegatorBond(cdc *wire.Codec, storeName string) *cobra.Command {
|
func GetCmdQueryDelegatorBond(storeName string, cdc *wire.Codec) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "delegator-bond",
|
Use: "delegator-bond",
|
||||||
Short: "Query a delegators bond based on address and candidate pubkey",
|
Short: "Query a delegators bond based on address and candidate pubkey",
|
||||||
|
@ -165,7 +165,7 @@ func GetCmdQueryDelegatorBond(cdc *wire.Codec, storeName string) *cobra.Command
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the command to query all the candidates bonded to a delegator
|
// get the command to query all the candidates bonded to a delegator
|
||||||
func GetCmdQueryDelegatorBonds(cdc *wire.Codec, storeName string) *cobra.Command {
|
func GetCmdQueryDelegatorBonds(storeName string, cdc *wire.Codec) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "delegator-candidates",
|
Use: "delegator-candidates",
|
||||||
Short: "Query all delegators candidates' pubkeys based on address",
|
Short: "Query all delegators candidates' pubkeys based on address",
|
||||||
|
|
|
@ -20,8 +20,8 @@ import (
|
||||||
|
|
||||||
// nolint
|
// nolint
|
||||||
const (
|
const (
|
||||||
FlagAddressDelegator = "addressD"
|
FlagAddressDelegator = "address-delegator"
|
||||||
FlagAddressCandidate = "addressC"
|
FlagAddressCandidate = "address-candidate"
|
||||||
FlagPubKey = "pubkey"
|
FlagPubKey = "pubkey"
|
||||||
FlagAmount = "amount"
|
FlagAmount = "amount"
|
||||||
FlagShares = "shares"
|
FlagShares = "shares"
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
|
||||||
abci "github.com/tendermint/abci/types"
|
abci "github.com/tendermint/abci/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -18,7 +17,7 @@ const (
|
||||||
|
|
||||||
//_______________________________________________________________________
|
//_______________________________________________________________________
|
||||||
|
|
||||||
func NewHandler(k Keeper, ck bank.CoinKeeper) sdk.Handler {
|
func NewHandler(k Keeper) sdk.Handler {
|
||||||
return func(ctx sdk.Context, msg sdk.Msg) sdk.Result {
|
return func(ctx sdk.Context, msg sdk.Msg) sdk.Result {
|
||||||
// NOTE msg already has validate basic run
|
// NOTE msg already has validate basic run
|
||||||
switch msg := msg.(type) {
|
switch msg := msg.(type) {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
"github.com/cosmos/cosmos-sdk/wire"
|
||||||
)
|
)
|
||||||
|
|
||||||
// XXX complete
|
// TODO complete when go-amino is ported
|
||||||
func RegisterWire(cdc *wire.Codec) {
|
func RegisterWire(cdc *wire.Codec) {
|
||||||
// TODO include option to always include prefix bytes.
|
// TODO include option to always include prefix bytes.
|
||||||
//cdc.RegisterConcrete(SendMsg{}, "cosmos-sdk/SendMsg", nil)
|
//cdc.RegisterConcrete(SendMsg{}, "cosmos-sdk/SendMsg", nil)
|
||||||
|
|
Loading…
Reference in New Issue