Merge branch 'develop' into cwgoes/slashing-period-spec
This commit is contained in:
commit
32263ffe4d
|
@ -490,11 +490,11 @@
|
||||||
version = "v0.23.0"
|
version = "v0.23.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
digest = "1:2ea7665579c64cda1873a395de97a2af02df1d06f4cb52128caf57f13249303c"
|
digest = "1:4dcb0dd65feecb068ce23a234d1a07c7868a1e39f52a6defcae0bb371d03abf6"
|
||||||
name = "github.com/zondax/ledger-goclient"
|
name = "github.com/zondax/ledger-goclient"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
pruneopts = "UT"
|
pruneopts = "UT"
|
||||||
revision = "a05312e1c998ad831b70eea41d009654f7f95985"
|
revision = "4296ee5701e945f9b3a7dbe51f402e0b9be57259"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
|
|
||||||
[[constraint]]
|
[[constraint]]
|
||||||
name = "github.com/zondax/ledger-goclient"
|
name = "github.com/zondax/ledger-goclient"
|
||||||
revision = "a05312e1c998ad831b70eea41d009654f7f95985"
|
revision = "4296ee5701e945f9b3a7dbe51f402e0b9be57259"
|
||||||
|
|
||||||
[prune]
|
[prune]
|
||||||
go-tests = true
|
go-tests = true
|
||||||
|
|
10
Makefile
10
Makefile
|
@ -5,6 +5,7 @@ BUILD_TAGS = netgo ledger
|
||||||
BUILD_FLAGS = -tags "${BUILD_TAGS}" -ldflags "-X github.com/cosmos/cosmos-sdk/version.GitCommit=${COMMIT_HASH}"
|
BUILD_FLAGS = -tags "${BUILD_TAGS}" -ldflags "-X github.com/cosmos/cosmos-sdk/version.GitCommit=${COMMIT_HASH}"
|
||||||
GCC := $(shell command -v gcc 2> /dev/null)
|
GCC := $(shell command -v gcc 2> /dev/null)
|
||||||
LEDGER_ENABLED ?= true
|
LEDGER_ENABLED ?= true
|
||||||
|
UNAME_S := $(shell uname -s)
|
||||||
all: get_tools get_vendor_deps install install_examples install_cosmos-sdk-cli test_lint test
|
all: get_tools get_vendor_deps install install_examples install_cosmos-sdk-cli test_lint test
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
|
@ -17,8 +18,14 @@ ci: get_tools get_vendor_deps install test_cover test_lint test
|
||||||
|
|
||||||
check-ledger:
|
check-ledger:
|
||||||
ifeq ($(LEDGER_ENABLED),true)
|
ifeq ($(LEDGER_ENABLED),true)
|
||||||
|
ifeq ($(UNAME_S),OpenBSD)
|
||||||
|
$(info "OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988)")
|
||||||
|
TMP_BUILD_TAGS := $(BUILD_TAGS)
|
||||||
|
BUILD_TAGS = $(filter-out ledger, $(TMP_BUILD_TAGS))
|
||||||
|
else
|
||||||
ifndef GCC
|
ifndef GCC
|
||||||
$(error "gcc not installed for ledger support, please install")
|
$(error "gcc not installed for ledger support, please install or set LEDGER_ENABLED to false in the Makefile")
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
TMP_BUILD_TAGS := $(BUILD_TAGS)
|
TMP_BUILD_TAGS := $(BUILD_TAGS)
|
||||||
|
@ -100,6 +107,7 @@ get_dev_tools:
|
||||||
|
|
||||||
get_vendor_deps:
|
get_vendor_deps:
|
||||||
@echo "--> Running dep ensure"
|
@echo "--> Running dep ensure"
|
||||||
|
@rm -rf .vendor-new
|
||||||
@dep ensure -v
|
@dep ensure -v
|
||||||
|
|
||||||
draw_deps:
|
draw_deps:
|
||||||
|
|
|
@ -9,7 +9,7 @@ maintaining a validator address to pubkey map, and using time.Time instead of in
|
||||||
|
|
||||||
BREAKING CHANGES
|
BREAKING CHANGES
|
||||||
* API
|
* API
|
||||||
- \#1880 [x/stake] changed the endpoints to be more REST-ful
|
- \#1880 and \#2000 [x/stake] changed the endpoints to be more REST-ful
|
||||||
* Update to tendermint v0.22.5. This involves changing all of the cryptography imports. [Ref](https://github.com/tendermint/tendermint/pull/1966)
|
* Update to tendermint v0.22.5. This involves changing all of the cryptography imports. [Ref](https://github.com/tendermint/tendermint/pull/1966)
|
||||||
* [baseapp] Msgs are no longer run on CheckTx, removed `ctx.IsCheckTx()`
|
* [baseapp] Msgs are no longer run on CheckTx, removed `ctx.IsCheckTx()`
|
||||||
* [x/gov] CLI flag changed from `proposalID` to `proposal-id`
|
* [x/gov] CLI flag changed from `proposalID` to `proposal-id`
|
||||||
|
@ -38,6 +38,7 @@ BREAKING CHANGES
|
||||||
* [types] sdk.NewCoin now takes sdk.Int, sdk.NewInt64Coin takes int64
|
* [types] sdk.NewCoin now takes sdk.Int, sdk.NewInt64Coin takes int64
|
||||||
* [cli] #1551: Officially removed `--name` from CLI commands
|
* [cli] #1551: Officially removed `--name` from CLI commands
|
||||||
* [cli] Genesis/key creation (`init`) now supports user-provided key passwords
|
* [cli] Genesis/key creation (`init`) now supports user-provided key passwords
|
||||||
|
* [cli] unsafe_reset_all, show_validator, and show_node_id have been renamed to unsafe-reset-all, show-validator, and show-node-id
|
||||||
|
|
||||||
FEATURES
|
FEATURES
|
||||||
* [lcd] Can now query governance proposals by ProposalStatus
|
* [lcd] Can now query governance proposals by ProposalStatus
|
||||||
|
@ -72,8 +73,11 @@ IMPROVEMENTS
|
||||||
* [x/gov] Initial governance parameters can now be set in the genesis file
|
* [x/gov] Initial governance parameters can now be set in the genesis file
|
||||||
* [x/stake] \#1815 Sped up the processing of `EditValidator` txs.
|
* [x/stake] \#1815 Sped up the processing of `EditValidator` txs.
|
||||||
* [server] \#1930 Transactions indexer indexes all tags by default.
|
* [server] \#1930 Transactions indexer indexes all tags by default.
|
||||||
|
* [x/stake] \#2000 Added tests for new staking endpoints
|
||||||
|
* [tools] Make get_vendor_deps deletes `.vendor-new` directories, in case scratch files are present.
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
* \#1988 Make us compile on OpenBSD (disable ledger) [#1988] (https://github.com/cosmos/cosmos-sdk/issues/1988)
|
||||||
* \#1666 Add intra-tx counter to the genesis validators
|
* \#1666 Add intra-tx counter to the genesis validators
|
||||||
* \#1797 Fix off-by-one error in slashing for downtime
|
* \#1797 Fix off-by-one error in slashing for downtime
|
||||||
* \#1787 Fixed bug where Tally fails due to revoked/unbonding validator
|
* \#1787 Fixed bug where Tally fails due to revoked/unbonding validator
|
||||||
|
|
|
@ -385,64 +385,70 @@ func TestValidatorQuery(t *testing.T) {
|
||||||
|
|
||||||
func TestBonding(t *testing.T) {
|
func TestBonding(t *testing.T) {
|
||||||
name, password, denom := "test", "1234567890", "steak"
|
name, password, denom := "test", "1234567890", "steak"
|
||||||
addr, seed := CreateAddr(t, "test", password, GetKeyBase(t))
|
addr, seed := CreateAddr(t, name, password, GetKeyBase(t))
|
||||||
cleanup, pks, port := InitializeTestLCD(t, 1, []sdk.AccAddress{addr})
|
cleanup, pks, port := InitializeTestLCD(t, 1, []sdk.AccAddress{addr})
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
validator1Owner := sdk.AccAddress(pks[0].Address())
|
validator1Owner := sdk.AccAddress(pks[0].Address())
|
||||||
|
validator := getValidator(t, port, validator1Owner)
|
||||||
|
|
||||||
// create bond TX
|
resultTx := doDelegate(t, port, seed, name, password, addr, validator1Owner, 60)
|
||||||
resultTx := doDelegate(t, port, seed, name, password, addr, validator1Owner)
|
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
// check if tx was committed
|
|
||||||
require.Equal(t, uint32(0), resultTx.CheckTx.Code)
|
require.Equal(t, uint32(0), resultTx.CheckTx.Code)
|
||||||
require.Equal(t, uint32(0), resultTx.DeliverTx.Code)
|
require.Equal(t, uint32(0), resultTx.DeliverTx.Code)
|
||||||
|
|
||||||
// query sender
|
|
||||||
acc := getAccount(t, port, addr)
|
acc := getAccount(t, port, addr)
|
||||||
coins := acc.GetCoins()
|
coins := acc.GetCoins()
|
||||||
|
|
||||||
require.Equal(t, int64(40), coins.AmountOf(denom).Int64())
|
require.Equal(t, int64(40), coins.AmountOf(denom).Int64())
|
||||||
|
|
||||||
// query validator
|
|
||||||
bond := getDelegation(t, port, addr, validator1Owner)
|
bond := getDelegation(t, port, addr, validator1Owner)
|
||||||
require.Equal(t, "60.0000000000", bond.Shares)
|
require.Equal(t, "60.0000000000", bond.Shares)
|
||||||
|
|
||||||
|
summary := getDelegationSummary(t, port, addr)
|
||||||
|
|
||||||
|
require.Len(t, summary.Delegations, 1, "Delegation summary holds all delegations")
|
||||||
|
require.Equal(t, "60.0000000000", summary.Delegations[0].Shares)
|
||||||
|
require.Len(t, summary.UnbondingDelegations, 0, "Delegation summary holds all unbonding-delegations")
|
||||||
|
|
||||||
|
bondedValidators := getDelegatorValidators(t, port, addr)
|
||||||
|
require.Len(t, bondedValidators, 1)
|
||||||
|
require.Equal(t, validator1Owner, bondedValidators[0].Owner)
|
||||||
|
require.Equal(t, validator.DelegatorShares.Add(sdk.NewRat(60)).FloatString(), bondedValidators[0].DelegatorShares.FloatString())
|
||||||
|
|
||||||
|
bondedValidator := getDelegatorValidator(t, port, addr, validator1Owner)
|
||||||
|
require.Equal(t, validator1Owner, bondedValidator.Owner)
|
||||||
|
|
||||||
//////////////////////
|
//////////////////////
|
||||||
// testing unbonding
|
// testing unbonding
|
||||||
|
|
||||||
// create unbond TX
|
resultTx = doBeginUnbonding(t, port, seed, name, password, addr, validator1Owner, 60)
|
||||||
resultTx = doBeginUnbonding(t, port, seed, name, password, addr, validator1Owner)
|
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
// query validator
|
|
||||||
bond = getDelegation(t, port, addr, validator1Owner)
|
|
||||||
require.Equal(t, "30.0000000000", bond.Shares)
|
|
||||||
|
|
||||||
// check if tx was committed
|
|
||||||
require.Equal(t, uint32(0), resultTx.CheckTx.Code)
|
require.Equal(t, uint32(0), resultTx.CheckTx.Code)
|
||||||
require.Equal(t, uint32(0), resultTx.DeliverTx.Code)
|
require.Equal(t, uint32(0), resultTx.DeliverTx.Code)
|
||||||
|
|
||||||
// should the sender should have not received any coins as the unbonding has only just begun
|
// sender should have not received any coins as the unbonding has only just begun
|
||||||
// query sender
|
|
||||||
acc = getAccount(t, port, addr)
|
acc = getAccount(t, port, addr)
|
||||||
coins = acc.GetCoins()
|
coins = acc.GetCoins()
|
||||||
require.Equal(t, int64(40), coins.AmountOf("steak").Int64())
|
require.Equal(t, int64(40), coins.AmountOf("steak").Int64())
|
||||||
|
|
||||||
// query unbonding delegation
|
unbondings := getUndelegations(t, port, addr, validator1Owner)
|
||||||
validatorAddr := sdk.AccAddress(pks[0].Address())
|
require.Len(t, unbondings, 1, "Unbondings holds all unbonding-delegations")
|
||||||
unbondings := getUndelegations(t, port, addr, validatorAddr)
|
require.Equal(t, "60", unbondings[0].Balance.Amount.String())
|
||||||
assert.Len(t, unbondings, 1, "Unbondings holds all unbonding-delegations")
|
|
||||||
assert.Equal(t, "30", unbondings[0].Balance.Amount.String())
|
|
||||||
|
|
||||||
// query summary
|
summary = getDelegationSummary(t, port, addr)
|
||||||
summary := getDelegationSummary(t, port, addr)
|
|
||||||
|
|
||||||
assert.Len(t, summary.Delegations, 1, "Delegation summary holds all delegations")
|
require.Len(t, summary.Delegations, 0, "Delegation summary holds all delegations")
|
||||||
assert.Equal(t, "30.0000000000", summary.Delegations[0].Shares)
|
require.Len(t, summary.UnbondingDelegations, 1, "Delegation summary holds all unbonding-delegations")
|
||||||
assert.Len(t, summary.UnbondingDelegations, 1, "Delegation summary holds all unbonding-delegations")
|
require.Equal(t, "60", summary.UnbondingDelegations[0].Balance.Amount.String())
|
||||||
assert.Equal(t, "30", summary.UnbondingDelegations[0].Balance.Amount.String())
|
|
||||||
|
bondedValidators = getDelegatorValidators(t, port, addr)
|
||||||
|
require.Len(t, bondedValidators, 0, "There's no delegation as the user withdraw all funds")
|
||||||
|
|
||||||
|
// TODO Undonding status not currently implemented
|
||||||
|
// require.Equal(t, sdk.Unbonding, bondedValidators[0].Status)
|
||||||
|
|
||||||
// TODO add redelegation, need more complex capabilities such to mock context and
|
// TODO add redelegation, need more complex capabilities such to mock context and
|
||||||
// TODO check summary for redelegation
|
// TODO check summary for redelegation
|
||||||
|
@ -757,64 +763,89 @@ func getSigningInfo(t *testing.T, port string, validatorPubKey string) slashing.
|
||||||
// ============= Stake Module ================
|
// ============= Stake Module ================
|
||||||
|
|
||||||
func getDelegation(t *testing.T, port string, delegatorAddr, validatorAddr sdk.AccAddress) rest.DelegationWithoutRat {
|
func getDelegation(t *testing.T, port string, delegatorAddr, validatorAddr sdk.AccAddress) rest.DelegationWithoutRat {
|
||||||
|
|
||||||
// get the account to get the sequence
|
|
||||||
res, body := Request(t, port, "GET", fmt.Sprintf("/stake/delegators/%s/delegations/%s", delegatorAddr, validatorAddr), nil)
|
res, body := Request(t, port, "GET", fmt.Sprintf("/stake/delegators/%s/delegations/%s", delegatorAddr, validatorAddr), nil)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
|
||||||
var bond rest.DelegationWithoutRat
|
var bond rest.DelegationWithoutRat
|
||||||
|
|
||||||
err := cdc.UnmarshalJSON([]byte(body), &bond)
|
err := cdc.UnmarshalJSON([]byte(body), &bond)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
return bond
|
return bond
|
||||||
}
|
}
|
||||||
|
|
||||||
func getUndelegations(t *testing.T, port string, delegatorAddr, validatorAddr sdk.AccAddress) []stake.UnbondingDelegation {
|
func getUndelegations(t *testing.T, port string, delegatorAddr, validatorAddr sdk.AccAddress) []stake.UnbondingDelegation {
|
||||||
|
|
||||||
// get the account to get the sequence
|
|
||||||
res, body := Request(t, port, "GET", fmt.Sprintf("/stake/delegators/%s/unbonding_delegations/%s", delegatorAddr, validatorAddr), nil)
|
res, body := Request(t, port, "GET", fmt.Sprintf("/stake/delegators/%s/unbonding_delegations/%s", delegatorAddr, validatorAddr), nil)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
|
||||||
var unbondings []stake.UnbondingDelegation
|
var unbondings []stake.UnbondingDelegation
|
||||||
|
|
||||||
err := cdc.UnmarshalJSON([]byte(body), &unbondings)
|
err := cdc.UnmarshalJSON([]byte(body), &unbondings)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
return unbondings
|
return unbondings
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDelegationSummary(t *testing.T, port string, delegatorAddr sdk.AccAddress) rest.DelegationSummary {
|
func getDelegationSummary(t *testing.T, port string, delegatorAddr sdk.AccAddress) rest.DelegationSummary {
|
||||||
|
|
||||||
// get the account to get the sequence
|
|
||||||
res, body := Request(t, port, "GET", fmt.Sprintf("/stake/delegators/%s", delegatorAddr), nil)
|
res, body := Request(t, port, "GET", fmt.Sprintf("/stake/delegators/%s", delegatorAddr), nil)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
|
||||||
var summary rest.DelegationSummary
|
var summary rest.DelegationSummary
|
||||||
|
|
||||||
err := cdc.UnmarshalJSON([]byte(body), &summary)
|
err := cdc.UnmarshalJSON([]byte(body), &summary)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
return summary
|
return summary
|
||||||
}
|
}
|
||||||
|
|
||||||
func getBondingTxs(t *testing.T, port string, delegatorAddr sdk.AccAddress, query string) []tx.Info {
|
func getBondingTxs(t *testing.T, port string, delegatorAddr sdk.AccAddress, query string) []tx.Info {
|
||||||
|
|
||||||
// get the account to get the sequence
|
|
||||||
var res *http.Response
|
var res *http.Response
|
||||||
var body string
|
var body string
|
||||||
|
|
||||||
if len(query) > 0 {
|
if len(query) > 0 {
|
||||||
res, body = Request(t, port, "GET", fmt.Sprintf("/stake/delegators/%s/txs?type=%s", delegatorAddr, query), nil)
|
res, body = Request(t, port, "GET", fmt.Sprintf("/stake/delegators/%s/txs?type=%s", delegatorAddr, query), nil)
|
||||||
} else {
|
} else {
|
||||||
res, body = Request(t, port, "GET", fmt.Sprintf("/stake/delegators/%s/txs", delegatorAddr), nil)
|
res, body = Request(t, port, "GET", fmt.Sprintf("/stake/delegators/%s/txs", delegatorAddr), nil)
|
||||||
}
|
}
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
|
||||||
var txs []tx.Info
|
var txs []tx.Info
|
||||||
|
|
||||||
err := cdc.UnmarshalJSON([]byte(body), &txs)
|
err := cdc.UnmarshalJSON([]byte(body), &txs)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
return txs
|
return txs
|
||||||
}
|
}
|
||||||
|
|
||||||
func doDelegate(t *testing.T, port, seed, name, password string, delegatorAddr, validatorAddr sdk.AccAddress) (resultTx ctypes.ResultBroadcastTxCommit) {
|
func getDelegatorValidators(t *testing.T, port string, delegatorAddr sdk.AccAddress) []stake.BechValidator {
|
||||||
// get the account to get the sequence
|
res, body := Request(t, port, "GET", fmt.Sprintf("/stake/delegators/%s/validators", delegatorAddr), nil)
|
||||||
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
|
||||||
|
var bondedValidators []stake.BechValidator
|
||||||
|
|
||||||
|
err := cdc.UnmarshalJSON([]byte(body), &bondedValidators)
|
||||||
|
require.Nil(t, err)
|
||||||
|
|
||||||
|
return bondedValidators
|
||||||
|
}
|
||||||
|
|
||||||
|
func getDelegatorValidator(t *testing.T, port string, delegatorAddr sdk.AccAddress, validatorAddr sdk.AccAddress) stake.BechValidator {
|
||||||
|
res, body := Request(t, port, "GET", fmt.Sprintf("/stake/delegators/%s/validators/%s", delegatorAddr, validatorAddr), nil)
|
||||||
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
|
||||||
|
var bondedValidator stake.BechValidator
|
||||||
|
err := cdc.UnmarshalJSON([]byte(body), &bondedValidator)
|
||||||
|
require.Nil(t, err)
|
||||||
|
|
||||||
|
return bondedValidator
|
||||||
|
}
|
||||||
|
|
||||||
|
func doDelegate(t *testing.T, port, seed, name, password string, delegatorAddr, validatorAddr sdk.AccAddress, amount int64) (resultTx ctypes.ResultBroadcastTxCommit) {
|
||||||
acc := getAccount(t, port, delegatorAddr)
|
acc := getAccount(t, port, delegatorAddr)
|
||||||
accnum := acc.GetAccountNumber()
|
accnum := acc.GetAccountNumber()
|
||||||
sequence := acc.GetSequence()
|
sequence := acc.GetSequence()
|
||||||
|
|
||||||
chainID := viper.GetString(client.FlagChainID)
|
chainID := viper.GetString(client.FlagChainID)
|
||||||
|
|
||||||
// send
|
|
||||||
jsonStr := []byte(fmt.Sprintf(`{
|
jsonStr := []byte(fmt.Sprintf(`{
|
||||||
"name": "%s",
|
"name": "%s",
|
||||||
"password": "%s",
|
"password": "%s",
|
||||||
|
@ -826,14 +857,15 @@ func doDelegate(t *testing.T, port, seed, name, password string, delegatorAddr,
|
||||||
{
|
{
|
||||||
"delegator_addr": "%s",
|
"delegator_addr": "%s",
|
||||||
"validator_addr": "%s",
|
"validator_addr": "%s",
|
||||||
"delegation": { "denom": "%s", "amount": "60" }
|
"delegation": { "denom": "%s", "amount": "%d" }
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"begin_unbondings": [],
|
"begin_unbondings": [],
|
||||||
"complete_unbondings": [],
|
"complete_unbondings": [],
|
||||||
"begin_redelegates": [],
|
"begin_redelegates": [],
|
||||||
"complete_redelegates": []
|
"complete_redelegates": []
|
||||||
}`, name, password, accnum, sequence, chainID, delegatorAddr, validatorAddr, "steak"))
|
}`, name, password, accnum, sequence, chainID, delegatorAddr, validatorAddr, "steak", amount))
|
||||||
|
|
||||||
res, body := Request(t, port, "POST", fmt.Sprintf("/stake/delegators/%s/delegations", delegatorAddr), jsonStr)
|
res, body := Request(t, port, "POST", fmt.Sprintf("/stake/delegators/%s/delegations", delegatorAddr), jsonStr)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
|
||||||
|
@ -845,16 +877,13 @@ func doDelegate(t *testing.T, port, seed, name, password string, delegatorAddr,
|
||||||
}
|
}
|
||||||
|
|
||||||
func doBeginUnbonding(t *testing.T, port, seed, name, password string,
|
func doBeginUnbonding(t *testing.T, port, seed, name, password string,
|
||||||
delegatorAddr, validatorAddr sdk.AccAddress) (resultTx ctypes.ResultBroadcastTxCommit) {
|
delegatorAddr, validatorAddr sdk.AccAddress, amount int64) (resultTx ctypes.ResultBroadcastTxCommit) {
|
||||||
|
|
||||||
// get the account to get the sequence
|
|
||||||
acc := getAccount(t, port, delegatorAddr)
|
acc := getAccount(t, port, delegatorAddr)
|
||||||
accnum := acc.GetAccountNumber()
|
accnum := acc.GetAccountNumber()
|
||||||
sequence := acc.GetSequence()
|
sequence := acc.GetSequence()
|
||||||
|
|
||||||
chainID := viper.GetString(client.FlagChainID)
|
chainID := viper.GetString(client.FlagChainID)
|
||||||
|
|
||||||
// send
|
|
||||||
jsonStr := []byte(fmt.Sprintf(`{
|
jsonStr := []byte(fmt.Sprintf(`{
|
||||||
"name": "%s",
|
"name": "%s",
|
||||||
"password": "%s",
|
"password": "%s",
|
||||||
|
@ -867,13 +896,14 @@ func doBeginUnbonding(t *testing.T, port, seed, name, password string,
|
||||||
{
|
{
|
||||||
"delegator_addr": "%s",
|
"delegator_addr": "%s",
|
||||||
"validator_addr": "%s",
|
"validator_addr": "%s",
|
||||||
"shares": "30"
|
"shares": "%d"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"complete_unbondings": [],
|
"complete_unbondings": [],
|
||||||
"begin_redelegates": [],
|
"begin_redelegates": [],
|
||||||
"complete_redelegates": []
|
"complete_redelegates": []
|
||||||
}`, name, password, accnum, sequence, chainID, delegatorAddr, validatorAddr))
|
}`, name, password, accnum, sequence, chainID, delegatorAddr, validatorAddr, amount))
|
||||||
|
|
||||||
res, body := Request(t, port, "POST", fmt.Sprintf("/stake/delegators/%s/delegations", delegatorAddr), jsonStr)
|
res, body := Request(t, port, "POST", fmt.Sprintf("/stake/delegators/%s/delegations", delegatorAddr), jsonStr)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
|
||||||
|
@ -887,14 +917,12 @@ func doBeginUnbonding(t *testing.T, port, seed, name, password string,
|
||||||
func doBeginRedelegation(t *testing.T, port, seed, name, password string,
|
func doBeginRedelegation(t *testing.T, port, seed, name, password string,
|
||||||
delegatorAddr, validatorSrcAddr, validatorDstAddr sdk.AccAddress) (resultTx ctypes.ResultBroadcastTxCommit) {
|
delegatorAddr, validatorSrcAddr, validatorDstAddr sdk.AccAddress) (resultTx ctypes.ResultBroadcastTxCommit) {
|
||||||
|
|
||||||
// get the account to get the sequence
|
|
||||||
acc := getAccount(t, port, delegatorAddr)
|
acc := getAccount(t, port, delegatorAddr)
|
||||||
accnum := acc.GetAccountNumber()
|
accnum := acc.GetAccountNumber()
|
||||||
sequence := acc.GetSequence()
|
sequence := acc.GetSequence()
|
||||||
|
|
||||||
chainID := viper.GetString(client.FlagChainID)
|
chainID := viper.GetString(client.FlagChainID)
|
||||||
|
|
||||||
// send
|
|
||||||
jsonStr := []byte(fmt.Sprintf(`{
|
jsonStr := []byte(fmt.Sprintf(`{
|
||||||
"name": "%s",
|
"name": "%s",
|
||||||
"password": "%s",
|
"password": "%s",
|
||||||
|
@ -915,6 +943,7 @@ func doBeginRedelegation(t *testing.T, port, seed, name, password string,
|
||||||
],
|
],
|
||||||
"complete_redelegates": []
|
"complete_redelegates": []
|
||||||
}`, name, password, accnum, sequence, chainID, delegatorAddr, validatorSrcAddr, validatorDstAddr))
|
}`, name, password, accnum, sequence, chainID, delegatorAddr, validatorSrcAddr, validatorDstAddr))
|
||||||
|
|
||||||
res, body := Request(t, port, "POST", fmt.Sprintf("/stake/delegators/%s/delegations", delegatorAddr), jsonStr)
|
res, body := Request(t, port, "POST", fmt.Sprintf("/stake/delegators/%s/delegations", delegatorAddr), jsonStr)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
|
||||||
|
@ -926,7 +955,6 @@ func doBeginRedelegation(t *testing.T, port, seed, name, password string,
|
||||||
}
|
}
|
||||||
|
|
||||||
func getValidators(t *testing.T, port string) []stake.BechValidator {
|
func getValidators(t *testing.T, port string) []stake.BechValidator {
|
||||||
// get the account to get the sequence
|
|
||||||
res, body := Request(t, port, "GET", "/stake/validators", nil)
|
res, body := Request(t, port, "GET", "/stake/validators", nil)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
var validators []stake.BechValidator
|
var validators []stake.BechValidator
|
||||||
|
@ -936,7 +964,6 @@ func getValidators(t *testing.T, port string) []stake.BechValidator {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getValidator(t *testing.T, port string, validatorAddr sdk.AccAddress) stake.BechValidator {
|
func getValidator(t *testing.T, port string, validatorAddr sdk.AccAddress) stake.BechValidator {
|
||||||
// get the account to get the sequence
|
|
||||||
res, body := Request(t, port, "GET", fmt.Sprintf("/stake/validators/%s", validatorAddr.String()), nil)
|
res, body := Request(t, port, "GET", fmt.Sprintf("/stake/validators/%s", validatorAddr.String()), nil)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
var validator stake.BechValidator
|
var validator stake.BechValidator
|
||||||
|
@ -1034,7 +1061,7 @@ func getProposalsFilterStatus(t *testing.T, port string, status gov.ProposalStat
|
||||||
}
|
}
|
||||||
|
|
||||||
func doSubmitProposal(t *testing.T, port, seed, name, password string, proposerAddr sdk.AccAddress) (resultTx ctypes.ResultBroadcastTxCommit) {
|
func doSubmitProposal(t *testing.T, port, seed, name, password string, proposerAddr sdk.AccAddress) (resultTx ctypes.ResultBroadcastTxCommit) {
|
||||||
// get the account to get the sequence
|
|
||||||
acc := getAccount(t, port, proposerAddr)
|
acc := getAccount(t, port, proposerAddr)
|
||||||
accnum := acc.GetAccountNumber()
|
accnum := acc.GetAccountNumber()
|
||||||
sequence := acc.GetSequence()
|
sequence := acc.GetSequence()
|
||||||
|
@ -1068,7 +1095,7 @@ func doSubmitProposal(t *testing.T, port, seed, name, password string, proposerA
|
||||||
}
|
}
|
||||||
|
|
||||||
func doDeposit(t *testing.T, port, seed, name, password string, proposerAddr sdk.AccAddress, proposalID int64) (resultTx ctypes.ResultBroadcastTxCommit) {
|
func doDeposit(t *testing.T, port, seed, name, password string, proposerAddr sdk.AccAddress, proposalID int64) (resultTx ctypes.ResultBroadcastTxCommit) {
|
||||||
// get the account to get the sequence
|
|
||||||
acc := getAccount(t, port, proposerAddr)
|
acc := getAccount(t, port, proposerAddr)
|
||||||
accnum := acc.GetAccountNumber()
|
accnum := acc.GetAccountNumber()
|
||||||
sequence := acc.GetSequence()
|
sequence := acc.GetSequence()
|
||||||
|
|
|
@ -34,7 +34,7 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGaiaCLISend(t *testing.T) {
|
func TestGaiaCLISend(t *testing.T) {
|
||||||
tests.ExecuteT(t, fmt.Sprintf("gaiad --home=%s unsafe_reset_all", gaiadHome), "")
|
tests.ExecuteT(t, fmt.Sprintf("gaiad --home=%s unsafe-reset-all", gaiadHome), "")
|
||||||
executeWrite(t, fmt.Sprintf("gaiacli keys delete --home=%s foo", gaiacliHome), app.DefaultKeyPass)
|
executeWrite(t, fmt.Sprintf("gaiacli keys delete --home=%s foo", gaiacliHome), app.DefaultKeyPass)
|
||||||
executeWrite(t, fmt.Sprintf("gaiacli keys delete --home=%s bar", gaiacliHome), app.DefaultKeyPass)
|
executeWrite(t, fmt.Sprintf("gaiacli keys delete --home=%s bar", gaiacliHome), app.DefaultKeyPass)
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ func TestGaiaCLISend(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGaiaCLICreateValidator(t *testing.T) {
|
func TestGaiaCLICreateValidator(t *testing.T) {
|
||||||
tests.ExecuteT(t, fmt.Sprintf("gaiad --home=%s unsafe_reset_all", gaiadHome), "")
|
tests.ExecuteT(t, fmt.Sprintf("gaiad --home=%s unsafe-reset-all", gaiadHome), "")
|
||||||
executeWrite(t, fmt.Sprintf("gaiacli keys delete --home=%s foo", gaiacliHome), app.DefaultKeyPass)
|
executeWrite(t, fmt.Sprintf("gaiacli keys delete --home=%s foo", gaiacliHome), app.DefaultKeyPass)
|
||||||
executeWrite(t, fmt.Sprintf("gaiacli keys delete --home=%s bar", gaiacliHome), app.DefaultKeyPass)
|
executeWrite(t, fmt.Sprintf("gaiacli keys delete --home=%s bar", gaiacliHome), app.DefaultKeyPass)
|
||||||
chainID := executeInit(t, fmt.Sprintf("gaiad init -o --name=foo --home=%s --home-client=%s", gaiadHome, gaiacliHome))
|
chainID := executeInit(t, fmt.Sprintf("gaiad init -o --name=foo --home=%s --home-client=%s", gaiadHome, gaiacliHome))
|
||||||
|
@ -153,7 +153,7 @@ func TestGaiaCLICreateValidator(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGaiaCLISubmitProposal(t *testing.T) {
|
func TestGaiaCLISubmitProposal(t *testing.T) {
|
||||||
tests.ExecuteT(t, fmt.Sprintf("gaiad --home=%s unsafe_reset_all", gaiadHome), "")
|
tests.ExecuteT(t, fmt.Sprintf("gaiad --home=%s unsafe-reset-all", gaiadHome), "")
|
||||||
executeWrite(t, fmt.Sprintf("gaiacli keys delete --home=%s foo", gaiacliHome), app.DefaultKeyPass)
|
executeWrite(t, fmt.Sprintf("gaiacli keys delete --home=%s foo", gaiacliHome), app.DefaultKeyPass)
|
||||||
executeWrite(t, fmt.Sprintf("gaiacli keys delete --home=%s bar", gaiacliHome), app.DefaultKeyPass)
|
executeWrite(t, fmt.Sprintf("gaiacli keys delete --home=%s bar", gaiacliHome), app.DefaultKeyPass)
|
||||||
chainID := executeInit(t, fmt.Sprintf("gaiad init -o --name=foo --home=%s --home-client=%s", gaiadHome, gaiacliHome))
|
chainID := executeInit(t, fmt.Sprintf("gaiad init -o --name=foo --home=%s --home-client=%s", gaiadHome, gaiacliHome))
|
||||||
|
|
|
@ -493,6 +493,49 @@ paths:
|
||||||
500:
|
500:
|
||||||
description: Internal Server Error
|
description: Internal Server Error
|
||||||
|
|
||||||
|
/stake/delegators/{delegatorAddr}/validators:
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: delegatorAddr
|
||||||
|
description: Bech32 AccAddress of Delegator
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
get:
|
||||||
|
summary: Query all validators that a delegator is bonded to
|
||||||
|
tags:
|
||||||
|
- stake
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: OK
|
||||||
|
404:
|
||||||
|
description: Not Found
|
||||||
|
|
||||||
|
/stake/delegators/{delegatorAddr}/validators/{validatorAddr}:
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: delegatorAddr
|
||||||
|
description: Bech32 AccAddress of Delegator
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
- in: path
|
||||||
|
name: validatorAddr
|
||||||
|
description: Bech32 ValAddress of Delegator
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
get:
|
||||||
|
summary: Query a validator that a delegator is bonded to
|
||||||
|
tags:
|
||||||
|
- stake
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: OK
|
||||||
|
404:
|
||||||
|
description: Not Found
|
||||||
|
|
||||||
/stake/delegators/{delegatorAddr}/txs:
|
/stake/delegators/{delegatorAddr}/txs:
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
|
|
|
@ -41,7 +41,7 @@ First, remove the outdated files and reset the data.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
rm $HOME/.gaiad/config/addrbook.json $HOME/.gaiad/config/genesis.json
|
rm $HOME/.gaiad/config/addrbook.json $HOME/.gaiad/config/genesis.json
|
||||||
gaiad unsafe_reset_all
|
gaiad unsafe-reset-all
|
||||||
```
|
```
|
||||||
|
|
||||||
Your node is now in a pristine state while keeping the original `priv_validator.json` and `config.toml`. If you had any sentry nodes or full nodes setup before,
|
Your node is now in a pristine state while keeping the original `priv_validator.json` and `config.toml`. If you had any sentry nodes or full nodes setup before,
|
||||||
|
|
|
@ -479,6 +479,62 @@ Returns on error:
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### /stake/delegators/{delegatorAddr}/validators - GET
|
||||||
|
|
||||||
|
url: /stake/delegators/{delegatorAddr}/validators
|
||||||
|
|
||||||
|
Functionality: Query all validators that a delegator is bonded to.
|
||||||
|
|
||||||
|
Returns on success:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"rest api":"2.0",
|
||||||
|
"code":200,
|
||||||
|
"error":"",
|
||||||
|
"result":{}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns on failure:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"rest api":"2.0",
|
||||||
|
"code":500,
|
||||||
|
"error":"TODO",
|
||||||
|
"result":{}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### /stake/delegators/{delegatorAddr}/validators/{validatorAddr} - GET
|
||||||
|
|
||||||
|
url: /stake/delegators/{delegatorAddr}/validators/{validatorAddr}
|
||||||
|
|
||||||
|
Functionality: Query a validator that a delegator is bonded to
|
||||||
|
|
||||||
|
Returns on success:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"rest api":"2.0",
|
||||||
|
"code":200,
|
||||||
|
"error":"",
|
||||||
|
"result":{}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns on failure:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"rest api":"2.0",
|
||||||
|
"code":500,
|
||||||
|
"error":"TODO",
|
||||||
|
"result":{}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### /stake/delegators/{delegatorAddr}/txs - GET
|
### /stake/delegators/{delegatorAddr}/txs - GET
|
||||||
|
|
||||||
url: /stake/delegators/{delegatorAddr}/txs
|
url: /stake/delegators/{delegatorAddr}/txs
|
||||||
|
|
|
@ -323,6 +323,14 @@ return KeyOutput{
|
||||||
|
|
||||||
TODO
|
TODO
|
||||||
|
|
||||||
|
### [/stake/delegators/{delegatorAddr}/validators](api.md#stakedelegatorsdelegatorAddrvalidators---get)
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
### [/stake/delegators/{delegatorAddr}/validators/{validatorAddr}](api.md#stakedelegatorsdelegatorAddrvalidatorsvalidatorAddr---get)
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
### [/stake/delegators/{delegatorAddr}/txs](api.md#stakedelegatorsdelegatorAddrtxs---get)
|
### [/stake/delegators/{delegatorAddr}/txs](api.md#stakedelegatorsdelegatorAddrtxs---get)
|
||||||
|
|
||||||
TODO
|
TODO
|
||||||
|
|
|
@ -29,7 +29,7 @@ There are three types of key representations that are used:
|
||||||
|
|
||||||
- `cosmosvalpub`
|
- `cosmosvalpub`
|
||||||
- Generated when the node is created with `gaiad init`.
|
- Generated when the node is created with `gaiad init`.
|
||||||
- Get this value with `gaiad tendermint show_validator`
|
- Get this value with `gaiad tendermint show-validator`
|
||||||
- e.g. `cosmosvalpub1zcjduc3qcyj09qc03elte23zwshdx92jm6ce88fgc90rtqhjx8v0608qh5ssp0w94c`
|
- e.g. `cosmosvalpub1zcjduc3qcyj09qc03elte23zwshdx92jm6ce88fgc90rtqhjx8v0608qh5ssp0w94c`
|
||||||
|
|
||||||
### Generate Keys
|
### Generate Keys
|
||||||
|
@ -59,7 +59,7 @@ gaiacli keys list
|
||||||
View the validator pubkey for your node by typing:
|
View the validator pubkey for your node by typing:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
gaiad tendermint show_validator
|
gaiad tendermint show-validator
|
||||||
```
|
```
|
||||||
|
|
||||||
::: danger Warning
|
::: danger Warning
|
||||||
|
@ -120,7 +120,7 @@ On the testnet, we delegate `steak` instead of `atom`. Here's how you can bond t
|
||||||
```bash
|
```bash
|
||||||
gaiacli stake delegate \
|
gaiacli stake delegate \
|
||||||
--amount=10steak \
|
--amount=10steak \
|
||||||
--address-validator=$(gaiad tendermint show_validator) \
|
--address-validator=$(gaiad tendermint show-validator) \
|
||||||
--name=<key_name> \
|
--name=<key_name> \
|
||||||
--chain-id=gaia-7005
|
--chain-id=gaia-7005
|
||||||
```
|
```
|
||||||
|
@ -137,7 +137,7 @@ If for any reason the validator misbehaves, or you want to unbond a certain amou
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
gaiacli stake unbond begin \
|
gaiacli stake unbond begin \
|
||||||
--address-validator=$(gaiad tendermint show_validator) \
|
--address-validator=$(gaiad tendermint show-validator) \
|
||||||
--shares=MAX \
|
--shares=MAX \
|
||||||
--name=<key_name> \
|
--name=<key_name> \
|
||||||
--chain-id=gaia-7005
|
--chain-id=gaia-7005
|
||||||
|
@ -152,7 +152,7 @@ gaiacli account <account_cosmosaccaddr>
|
||||||
|
|
||||||
gaiacli stake delegation \
|
gaiacli stake delegation \
|
||||||
--address-delegator=<account_cosmosaccaddr> \
|
--address-delegator=<account_cosmosaccaddr> \
|
||||||
--address-validator=$(gaiad tendermint show_validator) \
|
--address-validator=$(gaiad tendermint show-validator) \
|
||||||
--chain-id=gaia-7005
|
--chain-id=gaia-7005
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ If you want to become a validator for the Hub's `mainnet`, you should [research
|
||||||
Your `cosmosvalpub` can be used to create a new validator by staking tokens. You can find your validator pubkey by running:
|
Your `cosmosvalpub` can be used to create a new validator by staking tokens. You can find your validator pubkey by running:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
gaiad tendermint show_validator
|
gaiad tendermint show-validator
|
||||||
```
|
```
|
||||||
|
|
||||||
Next, craft your `gaiacli stake create-validator` command:
|
Next, craft your `gaiacli stake create-validator` command:
|
||||||
|
@ -31,7 +31,7 @@ Don't use more `steak` thank you have! You can always get more by using the [Fau
|
||||||
```bash
|
```bash
|
||||||
gaiacli stake create-validator \
|
gaiacli stake create-validator \
|
||||||
--amount=5steak \
|
--amount=5steak \
|
||||||
--pubkey=$(gaiad tendermint show_validator) \
|
--pubkey=$(gaiad tendermint show-validator) \
|
||||||
--address-validator=<account_cosmosaccaddr>
|
--address-validator=<account_cosmosaccaddr>
|
||||||
--moniker="choose a moniker" \
|
--moniker="choose a moniker" \
|
||||||
--chain-id=gaia-7005 \
|
--chain-id=gaia-7005 \
|
||||||
|
@ -70,7 +70,7 @@ gaiacli stake validator \
|
||||||
Your validator is active if the following command returns anything:
|
Your validator is active if the following command returns anything:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
gaiacli advanced tendermint validator-set | grep "$(gaiad tendermint show_validator)"
|
gaiacli advanced tendermint validator-set | grep "$(gaiad tendermint show-validator)"
|
||||||
```
|
```
|
||||||
|
|
||||||
You should also be able to see your validator on the [Explorer](https://explorecosmos.network/validators). You are looking for the `bech32` encoded `address` in the `~/.gaiad/config/priv_validator.json` file.
|
You should also be able to see your validator on the [Explorer](https://explorecosmos.network/validators). You are looking for the `bech32` encoded `address` in the `~/.gaiad/config/priv_validator.json` file.
|
||||||
|
|
|
@ -179,7 +179,7 @@ starting this tutorial again or trying something new), the following
|
||||||
commands are run:
|
commands are run:
|
||||||
|
|
||||||
```
|
```
|
||||||
basecoind unsafe_reset_all
|
basecoind unsafe-reset-all
|
||||||
rm -rf ~/.basecoind
|
rm -rf ~/.basecoind
|
||||||
rm -rf ~/.basecli
|
rm -rf ~/.basecli
|
||||||
```
|
```
|
||||||
|
|
|
@ -24,6 +24,6 @@
|
||||||
|
|
||||||
- name: Reset network
|
- name: Reset network
|
||||||
when: UNSAFE_RESET_ALL | default(false) | bool
|
when: UNSAFE_RESET_ALL | default(false) | bool
|
||||||
command: "sudo -u gaiad gaiad unsafe_reset_all"
|
command: "sudo -u gaiad gaiad unsafe-reset-all"
|
||||||
notify: restart gaiad
|
notify: restart gaiad
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ import (
|
||||||
// ShowNodeIDCmd - ported from Tendermint, dump node ID to stdout
|
// ShowNodeIDCmd - ported from Tendermint, dump node ID to stdout
|
||||||
func ShowNodeIDCmd(ctx *Context) *cobra.Command {
|
func ShowNodeIDCmd(ctx *Context) *cobra.Command {
|
||||||
return &cobra.Command{
|
return &cobra.Command{
|
||||||
Use: "show_node_id",
|
Use: "show-node-id",
|
||||||
Short: "Show this node's ID",
|
Short: "Show this node's ID",
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
cfg := ctx.Config
|
cfg := ctx.Config
|
||||||
|
@ -34,7 +34,7 @@ func ShowNodeIDCmd(ctx *Context) *cobra.Command {
|
||||||
func ShowValidatorCmd(ctx *Context) *cobra.Command {
|
func ShowValidatorCmd(ctx *Context) *cobra.Command {
|
||||||
flagJSON := "json"
|
flagJSON := "json"
|
||||||
cmd := cobra.Command{
|
cmd := cobra.Command{
|
||||||
Use: "show_validator",
|
Use: "show-validator",
|
||||||
Short: "Show this node's tendermint validator info",
|
Short: "Show this node's tendermint validator info",
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ func ShowValidatorCmd(ctx *Context) *cobra.Command {
|
||||||
// UnsafeResetAllCmd - extension of the tendermint command, resets initialization
|
// UnsafeResetAllCmd - extension of the tendermint command, resets initialization
|
||||||
func UnsafeResetAllCmd(ctx *Context) *cobra.Command {
|
func UnsafeResetAllCmd(ctx *Context) *cobra.Command {
|
||||||
return &cobra.Command{
|
return &cobra.Command{
|
||||||
Use: "unsafe_reset_all",
|
Use: "unsafe-reset-all",
|
||||||
Short: "Reset blockchain database, priv_validator.json file, and the logger",
|
Short: "Reset blockchain database, priv_validator.json file, and the logger",
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
cfg := ctx.Config
|
cfg := ctx.Config
|
||||||
|
|
|
@ -20,41 +20,54 @@ const storeName = "stake"
|
||||||
|
|
||||||
func registerQueryRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *wire.Codec) {
|
func registerQueryRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *wire.Codec) {
|
||||||
|
|
||||||
// GET /stake/delegators/{delegatorAddr} // Get all delegations (delegation, undelegation and redelegation) from a delegator
|
// Get all delegations (delegation, undelegation and redelegation) from a delegator
|
||||||
r.HandleFunc(
|
r.HandleFunc(
|
||||||
"/stake/delegators/{delegatorAddr}",
|
"/stake/delegators/{delegatorAddr}",
|
||||||
delegatorHandlerFn(cliCtx, cdc),
|
delegatorHandlerFn(cliCtx, cdc),
|
||||||
).Methods("GET")
|
).Methods("GET")
|
||||||
|
|
||||||
// GET /stake/delegators/{delegatorAddr}/txs?type=<bond/unbond/redelegate> // Get all staking txs (i.e msgs) from a delegator
|
// Get all staking txs (i.e msgs) from a delegator
|
||||||
r.HandleFunc(
|
r.HandleFunc(
|
||||||
"/stake/delegators/{delegatorAddr}/txs",
|
"/stake/delegators/{delegatorAddr}/txs",
|
||||||
delegatorTxsHandlerFn(cliCtx, cdc),
|
delegatorTxsHandlerFn(cliCtx, cdc),
|
||||||
).Methods("GET")
|
).Methods("GET")
|
||||||
|
|
||||||
// GET /stake/delegators/{delegatorAddr}/delegations/{validatorAddr} // Query a delegation between a delegator and a validator
|
// Query all validators that a delegator is bonded to
|
||||||
|
r.HandleFunc(
|
||||||
|
"/stake/delegators/{delegatorAddr}/validators",
|
||||||
|
delegatorValidatorsHandlerFn(cliCtx, cdc),
|
||||||
|
).Methods("GET")
|
||||||
|
|
||||||
|
// Query a validator that a delegator is bonded to
|
||||||
|
r.HandleFunc(
|
||||||
|
"/stake/delegators/{delegatorAddr}/validators/{validatorAddr}",
|
||||||
|
delegatorValidatorHandlerFn(cliCtx, cdc),
|
||||||
|
).Methods("GET")
|
||||||
|
|
||||||
|
// Query a delegation between a delegator and a validator
|
||||||
r.HandleFunc(
|
r.HandleFunc(
|
||||||
"/stake/delegators/{delegatorAddr}/delegations/{validatorAddr}",
|
"/stake/delegators/{delegatorAddr}/delegations/{validatorAddr}",
|
||||||
delegationHandlerFn(cliCtx, cdc),
|
delegationHandlerFn(cliCtx, cdc),
|
||||||
).Methods("GET")
|
).Methods("GET")
|
||||||
|
|
||||||
// GET /stake/delegators/{delegatorAddr}/unbonding_delegations/{validatorAddr} // Query all unbonding_delegations between a delegator and a validator
|
// Query all unbonding_delegations between a delegator and a validator
|
||||||
r.HandleFunc(
|
r.HandleFunc(
|
||||||
"/stake/delegators/{delegatorAddr}/unbonding_delegations/{validatorAddr}",
|
"/stake/delegators/{delegatorAddr}/unbonding_delegations/{validatorAddr}",
|
||||||
unbondingDelegationsHandlerFn(cliCtx, cdc),
|
unbondingDelegationsHandlerFn(cliCtx, cdc),
|
||||||
).Methods("GET")
|
).Methods("GET")
|
||||||
|
|
||||||
// GET /stake/validators/
|
// Get all validators
|
||||||
r.HandleFunc(
|
r.HandleFunc(
|
||||||
"/stake/validators",
|
"/stake/validators",
|
||||||
validatorsHandlerFn(cliCtx, cdc),
|
validatorsHandlerFn(cliCtx, cdc),
|
||||||
).Methods("GET")
|
).Methods("GET")
|
||||||
|
|
||||||
// GET /stake/validators/{addr}
|
// Get a single validator info
|
||||||
r.HandleFunc(
|
r.HandleFunc(
|
||||||
"/stake/validators/{addr}",
|
"/stake/validators/{addr}",
|
||||||
validatorHandlerFn(cliCtx, cdc),
|
validatorHandlerFn(cliCtx, cdc),
|
||||||
).Methods("GET")
|
).Methods("GET")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// already resolve the rational shares to not handle this in the client
|
// already resolve the rational shares to not handle this in the client
|
||||||
|
|
|
@ -29,7 +29,6 @@ func contains(stringSlice []string, txType string) bool {
|
||||||
func getDelegatorValidator(cliCtx context.CLIContext, cdc *wire.Codec, delegatorAddr sdk.AccAddress, validatorAccAddr sdk.AccAddress) (
|
func getDelegatorValidator(cliCtx context.CLIContext, cdc *wire.Codec, delegatorAddr sdk.AccAddress, validatorAccAddr sdk.AccAddress) (
|
||||||
validator types.BechValidator, httpStatusCode int, errMsg string, err error) {
|
validator types.BechValidator, httpStatusCode int, errMsg string, err error) {
|
||||||
|
|
||||||
// check if the delegator is bonded or redelegated to the validator
|
|
||||||
keyDel := stake.GetDelegationKey(delegatorAddr, validatorAccAddr)
|
keyDel := stake.GetDelegationKey(delegatorAddr, validatorAccAddr)
|
||||||
|
|
||||||
res, err := cliCtx.QueryStore(keyDel, storeName)
|
res, err := cliCtx.QueryStore(keyDel, storeName)
|
||||||
|
@ -46,7 +45,6 @@ func getDelegatorValidator(cliCtx context.CLIContext, cdc *wire.Codec, delegator
|
||||||
return types.BechValidator{}, http.StatusInternalServerError, "Error: ", err
|
return types.BechValidator{}, http.StatusInternalServerError, "Error: ", err
|
||||||
}
|
}
|
||||||
if len(kvs) == 0 {
|
if len(kvs) == 0 {
|
||||||
// the query will return empty if there are no delegations
|
|
||||||
return types.BechValidator{}, http.StatusNoContent, "", nil
|
return types.BechValidator{}, http.StatusNoContent, "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +63,6 @@ func getDelegatorDelegations(cliCtx context.CLIContext, cdc *wire.Codec, delegat
|
||||||
return DelegationWithoutRat{}, http.StatusInternalServerError, "couldn't query delegation. Error: ", err
|
return DelegationWithoutRat{}, http.StatusInternalServerError, "couldn't query delegation. Error: ", err
|
||||||
}
|
}
|
||||||
|
|
||||||
// the query will return empty if there is no data for this record
|
|
||||||
if len(marshalledDelegation) == 0 {
|
if len(marshalledDelegation) == 0 {
|
||||||
return DelegationWithoutRat{}, http.StatusNoContent, "", nil
|
return DelegationWithoutRat{}, http.StatusNoContent, "", nil
|
||||||
}
|
}
|
||||||
|
@ -93,7 +90,6 @@ func getDelegatorUndelegations(cliCtx context.CLIContext, cdc *wire.Codec, deleg
|
||||||
return types.UnbondingDelegation{}, http.StatusInternalServerError, "couldn't query unbonding-delegation. Error: ", err
|
return types.UnbondingDelegation{}, http.StatusInternalServerError, "couldn't query unbonding-delegation. Error: ", err
|
||||||
}
|
}
|
||||||
|
|
||||||
// the query will return empty if there is no data for this record
|
|
||||||
if len(marshalledUnbondingDelegation) == 0 {
|
if len(marshalledUnbondingDelegation) == 0 {
|
||||||
return types.UnbondingDelegation{}, http.StatusNoContent, "", nil
|
return types.UnbondingDelegation{}, http.StatusNoContent, "", nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue