Merge PR #2802: Correct the usage of misspelling of English word 'depositor'.
Throughout the codebase the misspelling 'depositer' of the English word 'depositor' has been used. This commit applies a global search and replace to correct the misspelling.
This commit is contained in:
parent
3e68e44063
commit
f09fa33cfd
|
@ -18,6 +18,7 @@ BREAKING CHANGES
|
||||||
* [\#2752](https://github.com/cosmos/cosmos-sdk/pull/2752) Don't hardcode bondable denom.
|
* [\#2752](https://github.com/cosmos/cosmos-sdk/pull/2752) Don't hardcode bondable denom.
|
||||||
* [\#2019](https://github.com/cosmos/cosmos-sdk/issues/2019) Cap total number of signatures. Current per-transaction limit is 7, and if that is exceeded transaction is rejected.
|
* [\#2019](https://github.com/cosmos/cosmos-sdk/issues/2019) Cap total number of signatures. Current per-transaction limit is 7, and if that is exceeded transaction is rejected.
|
||||||
* [\#2801](https://github.com/cosmos/cosmos-sdk/pull/2801) Remove AppInit structure.
|
* [\#2801](https://github.com/cosmos/cosmos-sdk/pull/2801) Remove AppInit structure.
|
||||||
|
* [\#2798](https://github.com/cosmos/cosmos-sdk/issues/2798) Governance API has miss-spelled English word in JSON response ('depositer' -> 'depositor')
|
||||||
|
|
||||||
* Tendermint
|
* Tendermint
|
||||||
|
|
||||||
|
|
|
@ -830,11 +830,11 @@ func TestProposalsQuery(t *testing.T) {
|
||||||
require.Equal(t, proposalID3, (proposals[2]).GetProposalID())
|
require.Equal(t, proposalID3, (proposals[2]).GetProposalID())
|
||||||
|
|
||||||
// Test query deposited by addr1
|
// Test query deposited by addr1
|
||||||
proposals = getProposalsFilterDepositer(t, port, addrs[0])
|
proposals = getProposalsFilterDepositor(t, port, addrs[0])
|
||||||
require.Equal(t, proposalID1, (proposals[0]).GetProposalID())
|
require.Equal(t, proposalID1, (proposals[0]).GetProposalID())
|
||||||
|
|
||||||
// Test query deposited by addr2
|
// Test query deposited by addr2
|
||||||
proposals = getProposalsFilterDepositer(t, port, addrs[1])
|
proposals = getProposalsFilterDepositor(t, port, addrs[1])
|
||||||
require.Equal(t, proposalID2, (proposals[0]).GetProposalID())
|
require.Equal(t, proposalID2, (proposals[0]).GetProposalID())
|
||||||
require.Equal(t, proposalID3, (proposals[1]).GetProposalID())
|
require.Equal(t, proposalID3, (proposals[1]).GetProposalID())
|
||||||
|
|
||||||
|
@ -848,7 +848,7 @@ func TestProposalsQuery(t *testing.T) {
|
||||||
require.Equal(t, proposalID3, (proposals[0]).GetProposalID())
|
require.Equal(t, proposalID3, (proposals[0]).GetProposalID())
|
||||||
|
|
||||||
// Test query voted and deposited by addr1
|
// Test query voted and deposited by addr1
|
||||||
proposals = getProposalsFilterVoterDepositer(t, port, addrs[0], addrs[0])
|
proposals = getProposalsFilterVoterDepositor(t, port, addrs[0], addrs[0])
|
||||||
require.Equal(t, proposalID2, (proposals[0]).GetProposalID())
|
require.Equal(t, proposalID2, (proposals[0]).GetProposalID())
|
||||||
|
|
||||||
// Test query votes on Proposal 2
|
// Test query votes on Proposal 2
|
||||||
|
@ -1315,8 +1315,8 @@ func getDeposits(t *testing.T, port string, proposalID uint64) []gov.Deposit {
|
||||||
return deposits
|
return deposits
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDeposit(t *testing.T, port string, proposalID uint64, depositerAddr sdk.AccAddress) gov.Deposit {
|
func getDeposit(t *testing.T, port string, proposalID uint64, depositorAddr sdk.AccAddress) gov.Deposit {
|
||||||
res, body := Request(t, port, "GET", fmt.Sprintf("/gov/proposals/%d/deposits/%s", proposalID, depositerAddr), nil)
|
res, body := Request(t, port, "GET", fmt.Sprintf("/gov/proposals/%d/deposits/%s", proposalID, depositorAddr), nil)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
var deposit gov.Deposit
|
var deposit gov.Deposit
|
||||||
err := cdc.UnmarshalJSON([]byte(body), &deposit)
|
err := cdc.UnmarshalJSON([]byte(body), &deposit)
|
||||||
|
@ -1361,8 +1361,8 @@ func getProposalsAll(t *testing.T, port string) []gov.Proposal {
|
||||||
return proposals
|
return proposals
|
||||||
}
|
}
|
||||||
|
|
||||||
func getProposalsFilterDepositer(t *testing.T, port string, depositerAddr sdk.AccAddress) []gov.Proposal {
|
func getProposalsFilterDepositor(t *testing.T, port string, depositorAddr sdk.AccAddress) []gov.Proposal {
|
||||||
res, body := Request(t, port, "GET", fmt.Sprintf("/gov/proposals?depositer=%s", depositerAddr), nil)
|
res, body := Request(t, port, "GET", fmt.Sprintf("/gov/proposals?depositor=%s", depositorAddr), nil)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
|
||||||
var proposals []gov.Proposal
|
var proposals []gov.Proposal
|
||||||
|
@ -1381,8 +1381,8 @@ func getProposalsFilterVoter(t *testing.T, port string, voterAddr sdk.AccAddress
|
||||||
return proposals
|
return proposals
|
||||||
}
|
}
|
||||||
|
|
||||||
func getProposalsFilterVoterDepositer(t *testing.T, port string, voterAddr, depositerAddr sdk.AccAddress) []gov.Proposal {
|
func getProposalsFilterVoterDepositor(t *testing.T, port string, voterAddr, depositorAddr sdk.AccAddress) []gov.Proposal {
|
||||||
res, body := Request(t, port, "GET", fmt.Sprintf("/gov/proposals?depositer=%s&voter=%s", depositerAddr, voterAddr), nil)
|
res, body := Request(t, port, "GET", fmt.Sprintf("/gov/proposals?depositor=%s&voter=%s", depositorAddr, voterAddr), nil)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
|
||||||
var proposals []gov.Proposal
|
var proposals []gov.Proposal
|
||||||
|
@ -1444,7 +1444,7 @@ func doDeposit(t *testing.T, port, seed, name, password string, proposerAddr sdk
|
||||||
|
|
||||||
// deposit on proposal
|
// deposit on proposal
|
||||||
jsonStr := []byte(fmt.Sprintf(`{
|
jsonStr := []byte(fmt.Sprintf(`{
|
||||||
"depositer": "%s",
|
"depositor": "%s",
|
||||||
"amount": [{ "denom": "%s", "amount": "%d" }],
|
"amount": [{ "denom": "%s", "amount": "%d" }],
|
||||||
"base_req": {
|
"base_req": {
|
||||||
"name": "%s",
|
"name": "%s",
|
||||||
|
|
|
@ -1226,8 +1226,8 @@ paths:
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
- in: query
|
- in: query
|
||||||
name: depositer
|
name: depositor
|
||||||
description: depositer address
|
description: depositor address
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
- in: query
|
- in: query
|
||||||
|
@ -1281,7 +1281,7 @@ paths:
|
||||||
properties:
|
properties:
|
||||||
base_req:
|
base_req:
|
||||||
"$ref": "#/definitions/BaseReq"
|
"$ref": "#/definitions/BaseReq"
|
||||||
depositer:
|
depositor:
|
||||||
"$ref": "#/definitions/Address"
|
"$ref": "#/definitions/Address"
|
||||||
amount:
|
amount:
|
||||||
type: array
|
type: array
|
||||||
|
@ -1441,10 +1441,10 @@ paths:
|
||||||
description: Invalid proposal id
|
description: Invalid proposal id
|
||||||
500:
|
500:
|
||||||
description: Internal Server Error
|
description: Internal Server Error
|
||||||
/gov/proposals/{proposalId}/deposits/{depositer}:
|
/gov/proposals/{proposalId}/deposits/{depositor}:
|
||||||
get:
|
get:
|
||||||
summary: Query deposit
|
summary: Query deposit
|
||||||
description: Query deposit by proposalId and depositer address
|
description: Query deposit by proposalId and depositor address
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
tags:
|
tags:
|
||||||
|
@ -1456,8 +1456,8 @@ paths:
|
||||||
required: true
|
required: true
|
||||||
in: path
|
in: path
|
||||||
- type: string
|
- type: string
|
||||||
description: Bech32 depositer address
|
description: Bech32 depositor address
|
||||||
name: depositer
|
name: depositor
|
||||||
required: true
|
required: true
|
||||||
in: path
|
in: path
|
||||||
responses:
|
responses:
|
||||||
|
@ -1466,7 +1466,7 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/definitions/Deposit"
|
$ref: "#/definitions/Deposit"
|
||||||
400:
|
400:
|
||||||
description: Invalid proposal id or depositer address
|
description: Invalid proposal id or depositor address
|
||||||
404:
|
404:
|
||||||
description: Found no deposit
|
description: Found no deposit
|
||||||
500:
|
500:
|
||||||
|
@ -1934,7 +1934,7 @@ definitions:
|
||||||
"$ref": "#/definitions/Coin"
|
"$ref": "#/definitions/Coin"
|
||||||
proposal_id:
|
proposal_id:
|
||||||
type: integer
|
type: integer
|
||||||
depositer:
|
depositor:
|
||||||
"$ref": "#/definitions/Address"
|
"$ref": "#/definitions/Address"
|
||||||
TallyResult:
|
TallyResult:
|
||||||
type: object
|
type: object
|
||||||
|
|
|
@ -365,7 +365,7 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
|
||||||
require.Equal(t, " 1 - Test", proposalsQuery)
|
require.Equal(t, " 1 - Test", proposalsQuery)
|
||||||
|
|
||||||
deposit := executeGetDeposit(t,
|
deposit := executeGetDeposit(t,
|
||||||
fmt.Sprintf("gaiacli query gov deposit --proposal-id=1 --depositer=%s --output=json %v",
|
fmt.Sprintf("gaiacli query gov deposit --proposal-id=1 --depositor=%s --output=json %v",
|
||||||
fooAddr, flags))
|
fooAddr, flags))
|
||||||
require.Equal(t, int64(5), deposit.Amount.AmountOf(stakeTypes.DefaultBondDenom).Int64())
|
require.Equal(t, int64(5), deposit.Amount.AmountOf(stakeTypes.DefaultBondDenom).Int64())
|
||||||
|
|
||||||
|
@ -394,7 +394,7 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
|
||||||
require.Equal(t, int64(15), deposits[0].Amount.AmountOf(stakeTypes.DefaultBondDenom).Int64())
|
require.Equal(t, int64(15), deposits[0].Amount.AmountOf(stakeTypes.DefaultBondDenom).Int64())
|
||||||
|
|
||||||
deposit = executeGetDeposit(t,
|
deposit = executeGetDeposit(t,
|
||||||
fmt.Sprintf("gaiacli query gov deposit --proposal-id=1 --depositer=%s --output=json %v",
|
fmt.Sprintf("gaiacli query gov deposit --proposal-id=1 --depositor=%s --output=json %v",
|
||||||
fooAddr, flags))
|
fooAddr, flags))
|
||||||
require.Equal(t, int64(15), deposit.Amount.AmountOf(stakeTypes.DefaultBondDenom).Int64())
|
require.Equal(t, int64(15), deposit.Amount.AmountOf(stakeTypes.DefaultBondDenom).Int64())
|
||||||
|
|
||||||
|
|
|
@ -24,10 +24,12 @@ There are three types of key representations that are used:
|
||||||
- Derived from account keys generated by `gaiacli keys add`
|
- Derived from account keys generated by `gaiacli keys add`
|
||||||
- Used to receive funds
|
- Used to receive funds
|
||||||
- e.g. `cosmos15h6vd5f0wqps26zjlwrc6chah08ryu4hzzdwhc`
|
- e.g. `cosmos15h6vd5f0wqps26zjlwrc6chah08ryu4hzzdwhc`
|
||||||
|
|
||||||
* `cosmosvaloper`
|
* `cosmosvaloper`
|
||||||
* Used to associate a validator to it's operator
|
- Used to associate a validator to it's operator
|
||||||
* Used to invoke staking commands
|
- Used to invoke staking commands
|
||||||
* e.g. `cosmosvaloper1carzvgq3e6y3z5kz5y6gxp3wpy3qdrv928vyah`
|
- e.g. `cosmosvaloper1carzvgq3e6y3z5kz5y6gxp3wpy3qdrv928vyah`
|
||||||
|
|
||||||
- `cosmospub`
|
- `cosmospub`
|
||||||
- Derived from account keys generated by `gaiacli keys add`
|
- Derived from account keys generated by `gaiacli keys add`
|
||||||
- e.g. `cosmospub1zcjduc3q7fu03jnlu2xpl75s2nkt7krm6grh4cc5aqth73v0zwmea25wj2hsqhlqzm`
|
- e.g. `cosmospub1zcjduc3q7fu03jnlu2xpl75s2nkt7krm6grh4cc5aqth73v0zwmea25wj2hsqhlqzm`
|
||||||
|
@ -72,7 +74,7 @@ View the validator pubkey for your node by typing:
|
||||||
gaiad tendermint show-validator
|
gaiad tendermint show-validator
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that this is the Tendermint signing key, *not* the operator key you will use in delegation transactions.
|
Note that this is the Tendermint signing key, _not_ the operator key you will use in delegation transactions.
|
||||||
|
|
||||||
::: danger Warning
|
::: danger Warning
|
||||||
We strongly recommend _NOT_ using the same passphrase for multiple keys. The Tendermint team and the Interchain Foundation will not be responsible for the loss of funds.
|
We strongly recommend _NOT_ using the same passphrase for multiple keys. The Tendermint team and the Interchain Foundation will not be responsible for the loss of funds.
|
||||||
|
@ -211,7 +213,7 @@ gaiacli query stake validator <account_cosmosval>
|
||||||
|
|
||||||
#### Bond Tokens
|
#### Bond Tokens
|
||||||
|
|
||||||
On the testnet, we delegate `steak` instead of `atom`. Here's how you can bond tokens to a testnet validator (*i.e.* delegate):
|
On the testnet, we delegate `steak` instead of `atom`. Here's how you can bond tokens to a testnet validator (_i.e._ delegate):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
gaiacli tx stake delegate \
|
gaiacli tx stake delegate \
|
||||||
|
@ -367,6 +369,7 @@ With the `pool` command you will get the values for:
|
||||||
##### Query Delegations To Validator
|
##### Query Delegations To Validator
|
||||||
|
|
||||||
You can also query all of the delegations to a particular validator:
|
You can also query all of the delegations to a particular validator:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
gaiacli query delegations-to <account_cosmosval>
|
gaiacli query delegations-to <account_cosmosval>
|
||||||
```
|
```
|
||||||
|
@ -418,7 +421,7 @@ Or query all available proposals:
|
||||||
gaiacli query gov proposals
|
gaiacli query gov proposals
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also query proposals filtered by `voter` or `depositer` by using the corresponding flags.
|
You can also query proposals filtered by `voter` or `depositor` by using the corresponding flags.
|
||||||
|
|
||||||
#### Increase deposit
|
#### Increase deposit
|
||||||
|
|
||||||
|
@ -447,7 +450,7 @@ You can also query a deposit submitted by a specific address:
|
||||||
```bash
|
```bash
|
||||||
gaiacli query gov deposit \
|
gaiacli query gov deposit \
|
||||||
--proposal-id=<proposal_id> \
|
--proposal-id=<proposal_id> \
|
||||||
--depositer=<account_cosmos>
|
--depositor=<account_cosmos>
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Vote on a proposal
|
#### Vote on a proposal
|
||||||
|
|
|
@ -42,7 +42,7 @@ If proposal's deposit does not reach `MinDeposit` before `MaxDepositPeriod`, pro
|
||||||
There is one instance where Atom holders that deposits can be refunded:
|
There is one instance where Atom holders that deposits can be refunded:
|
||||||
* If the proposal is accepted.
|
* If the proposal is accepted.
|
||||||
|
|
||||||
Then, deposits will automatically be refunded to their respective depositer.
|
Then, deposits will automatically be refunded to their respective depositor.
|
||||||
|
|
||||||
### Proposal types
|
### Proposal types
|
||||||
|
|
||||||
|
|
|
@ -68,8 +68,8 @@ const (
|
||||||
|
|
||||||
```go
|
```go
|
||||||
type Deposit struct {
|
type Deposit struct {
|
||||||
Amount sdk.Coins // Amount of coins deposited by depositer
|
Amount sdk.Coins // Amount of coins deposited by depositor
|
||||||
Depositer crypto.address // Address of depositer
|
Depositor crypto.address // Address of depositor
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -185,8 +185,8 @@ And the pseudocode for the `ProposalProcessingQueue`:
|
||||||
// proposal was accepted at the end of the voting period
|
// proposal was accepted at the end of the voting period
|
||||||
// refund deposits (non-voters already punished)
|
// refund deposits (non-voters already punished)
|
||||||
proposal.CurrentStatus = ProposalStatusAccepted
|
proposal.CurrentStatus = ProposalStatusAccepted
|
||||||
for each (amount, depositer) in proposal.Deposits
|
for each (amount, depositor) in proposal.Deposits
|
||||||
depositer.AtomBalance += amount
|
depositor.AtomBalance += amount
|
||||||
|
|
||||||
else
|
else
|
||||||
// proposal was rejected
|
// proposal was rejected
|
||||||
|
|
|
@ -48,23 +48,23 @@ func GetCmdQueryProposals(queryRoute string, cdc *codec.Codec) *cobra.Command {
|
||||||
Use: "proposals",
|
Use: "proposals",
|
||||||
Short: "Query proposals with optional filters",
|
Short: "Query proposals with optional filters",
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
bechDepositerAddr := viper.GetString(flagDepositer)
|
bechDepositorAddr := viper.GetString(flagDepositor)
|
||||||
bechVoterAddr := viper.GetString(flagVoter)
|
bechVoterAddr := viper.GetString(flagVoter)
|
||||||
strProposalStatus := viper.GetString(flagStatus)
|
strProposalStatus := viper.GetString(flagStatus)
|
||||||
numLimit := uint64(viper.GetInt64(flagNumLimit))
|
numLimit := uint64(viper.GetInt64(flagNumLimit))
|
||||||
|
|
||||||
var depositerAddr sdk.AccAddress
|
var depositorAddr sdk.AccAddress
|
||||||
var voterAddr sdk.AccAddress
|
var voterAddr sdk.AccAddress
|
||||||
var proposalStatus gov.ProposalStatus
|
var proposalStatus gov.ProposalStatus
|
||||||
|
|
||||||
params := gov.NewQueryProposalsParams(proposalStatus, numLimit, voterAddr, depositerAddr)
|
params := gov.NewQueryProposalsParams(proposalStatus, numLimit, voterAddr, depositorAddr)
|
||||||
|
|
||||||
if len(bechDepositerAddr) != 0 {
|
if len(bechDepositorAddr) != 0 {
|
||||||
depositerAddr, err := sdk.AccAddressFromBech32(bechDepositerAddr)
|
depositorAddr, err := sdk.AccAddressFromBech32(bechDepositorAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
params.Depositer = depositerAddr
|
params.Depositor = depositorAddr
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(bechVoterAddr) != 0 {
|
if len(bechVoterAddr) != 0 {
|
||||||
|
@ -115,7 +115,7 @@ func GetCmdQueryProposals(queryRoute string, cdc *codec.Codec) *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Flags().String(flagNumLimit, "", "(optional) limit to latest [number] proposals. Defaults to all proposals")
|
cmd.Flags().String(flagNumLimit, "", "(optional) limit to latest [number] proposals. Defaults to all proposals")
|
||||||
cmd.Flags().String(flagDepositer, "", "(optional) filter by proposals deposited on by depositer")
|
cmd.Flags().String(flagDepositor, "", "(optional) filter by proposals deposited on by depositor")
|
||||||
cmd.Flags().String(flagVoter, "", "(optional) filter by proposals voted on by voted")
|
cmd.Flags().String(flagVoter, "", "(optional) filter by proposals voted on by voted")
|
||||||
cmd.Flags().String(flagStatus, "", "(optional) filter proposals by proposal status, status: deposit_period/voting_period/passed/rejected")
|
cmd.Flags().String(flagStatus, "", "(optional) filter proposals by proposal status, status: deposit_period/voting_period/passed/rejected")
|
||||||
|
|
||||||
|
@ -199,12 +199,12 @@ func GetCmdQueryDeposit(queryRoute string, cdc *codec.Codec) *cobra.Command {
|
||||||
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
||||||
proposalID := uint64(viper.GetInt64(flagProposalID))
|
proposalID := uint64(viper.GetInt64(flagProposalID))
|
||||||
|
|
||||||
depositerAddr, err := sdk.AccAddressFromBech32(viper.GetString(flagDepositer))
|
depositorAddr, err := sdk.AccAddressFromBech32(viper.GetString(flagDepositor))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
params := gov.NewQueryDepositParams(proposalID, depositerAddr)
|
params := gov.NewQueryDepositParams(proposalID, depositorAddr)
|
||||||
bz, err := cdc.MarshalJSON(params)
|
bz, err := cdc.MarshalJSON(params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -221,7 +221,7 @@ func GetCmdQueryDeposit(queryRoute string, cdc *codec.Codec) *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Flags().String(flagProposalID, "", "proposalID of proposal deposited on")
|
cmd.Flags().String(flagProposalID, "", "proposalID of proposal deposited on")
|
||||||
cmd.Flags().String(flagDepositer, "", "bech32 depositer address")
|
cmd.Flags().String(flagDepositor, "", "bech32 depositor address")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ const (
|
||||||
flagDeposit = "deposit"
|
flagDeposit = "deposit"
|
||||||
flagVoter = "voter"
|
flagVoter = "voter"
|
||||||
flagOption = "option"
|
flagOption = "option"
|
||||||
flagDepositer = "depositer"
|
flagDepositor = "depositor"
|
||||||
flagStatus = "status"
|
flagStatus = "status"
|
||||||
flagNumLimit = "limit"
|
flagNumLimit = "limit"
|
||||||
flagProposal = "proposal"
|
flagProposal = "proposal"
|
||||||
|
@ -165,7 +165,7 @@ func GetCmdDeposit(cdc *codec.Codec) *cobra.Command {
|
||||||
WithCodec(cdc).
|
WithCodec(cdc).
|
||||||
WithAccountDecoder(cdc)
|
WithAccountDecoder(cdc)
|
||||||
|
|
||||||
depositerAddr, err := cliCtx.GetFromAddress()
|
depositorAddr, err := cliCtx.GetFromAddress()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@ func GetCmdDeposit(cdc *codec.Codec) *cobra.Command {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg := gov.NewMsgDeposit(depositerAddr, proposalID, amount)
|
msg := gov.NewMsgDeposit(depositorAddr, proposalID, amount)
|
||||||
err = msg.ValidateBasic()
|
err = msg.ValidateBasic()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
const (
|
const (
|
||||||
RestParamsType = "type"
|
RestParamsType = "type"
|
||||||
RestProposalID = "proposal-id"
|
RestProposalID = "proposal-id"
|
||||||
RestDepositer = "depositer"
|
RestDepositor = "depositor"
|
||||||
RestVoter = "voter"
|
RestVoter = "voter"
|
||||||
RestProposalStatus = "status"
|
RestProposalStatus = "status"
|
||||||
RestNumLimit = "limit"
|
RestNumLimit = "limit"
|
||||||
|
@ -41,7 +41,7 @@ func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *codec.Codec)
|
||||||
r.HandleFunc("/gov/proposals", queryProposalsWithParameterFn(cdc, cliCtx)).Methods("GET")
|
r.HandleFunc("/gov/proposals", queryProposalsWithParameterFn(cdc, cliCtx)).Methods("GET")
|
||||||
r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}", RestProposalID), queryProposalHandlerFn(cdc, cliCtx)).Methods("GET")
|
r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}", RestProposalID), queryProposalHandlerFn(cdc, cliCtx)).Methods("GET")
|
||||||
r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}/deposits", RestProposalID), queryDepositsHandlerFn(cdc, cliCtx)).Methods("GET")
|
r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}/deposits", RestProposalID), queryDepositsHandlerFn(cdc, cliCtx)).Methods("GET")
|
||||||
r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}/deposits/{%s}", RestProposalID, RestDepositer), queryDepositHandlerFn(cdc, cliCtx)).Methods("GET")
|
r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}/deposits/{%s}", RestProposalID, RestDepositor), queryDepositHandlerFn(cdc, cliCtx)).Methods("GET")
|
||||||
r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}/tally", RestProposalID), queryTallyOnProposalHandlerFn(cdc, cliCtx)).Methods("GET")
|
r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}/tally", RestProposalID), queryTallyOnProposalHandlerFn(cdc, cliCtx)).Methods("GET")
|
||||||
r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}/votes", RestProposalID), queryVotesOnProposalHandlerFn(cdc, cliCtx)).Methods("GET")
|
r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}/votes", RestProposalID), queryVotesOnProposalHandlerFn(cdc, cliCtx)).Methods("GET")
|
||||||
r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}/votes/{%s}", RestProposalID, RestVoter), queryVoteHandlerFn(cdc, cliCtx)).Methods("GET")
|
r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}/votes/{%s}", RestProposalID, RestVoter), queryVoteHandlerFn(cdc, cliCtx)).Methods("GET")
|
||||||
|
@ -58,7 +58,7 @@ type postProposalReq struct {
|
||||||
|
|
||||||
type depositReq struct {
|
type depositReq struct {
|
||||||
BaseReq utils.BaseReq `json:"base_req"`
|
BaseReq utils.BaseReq `json:"base_req"`
|
||||||
Depositer sdk.AccAddress `json:"depositer"` // Address of the depositer
|
Depositor sdk.AccAddress `json:"depositor"` // Address of the depositor
|
||||||
Amount sdk.Coins `json:"amount"` // Coins to add to the proposal's deposit
|
Amount sdk.Coins `json:"amount"` // Coins to add to the proposal's deposit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ func depositHandlerFn(cdc *codec.Codec, cliCtx context.CLIContext) http.HandlerF
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the message
|
// create the message
|
||||||
msg := gov.NewMsgDeposit(req.Depositer, proposalID, req.Amount)
|
msg := gov.NewMsgDeposit(req.Depositor, proposalID, req.Amount)
|
||||||
err = msg.ValidateBasic()
|
err = msg.ValidateBasic()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
utils.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
||||||
|
@ -267,7 +267,7 @@ func queryDepositHandlerFn(cdc *codec.Codec, cliCtx context.CLIContext) http.Han
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
strProposalID := vars[RestProposalID]
|
strProposalID := vars[RestProposalID]
|
||||||
bechDepositerAddr := vars[RestDepositer]
|
bechDepositorAddr := vars[RestDepositor]
|
||||||
|
|
||||||
if len(strProposalID) == 0 {
|
if len(strProposalID) == 0 {
|
||||||
err := errors.New("proposalId required but not specified")
|
err := errors.New("proposalId required but not specified")
|
||||||
|
@ -280,13 +280,13 @@ func queryDepositHandlerFn(cdc *codec.Codec, cliCtx context.CLIContext) http.Han
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(bechDepositerAddr) == 0 {
|
if len(bechDepositorAddr) == 0 {
|
||||||
err := errors.New("depositer address required but not specified")
|
err := errors.New("depositor address required but not specified")
|
||||||
utils.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
utils.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
depositerAddr, err := sdk.AccAddressFromBech32(bechDepositerAddr)
|
depositorAddr, err := sdk.AccAddressFromBech32(bechDepositorAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
utils.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
||||||
return
|
return
|
||||||
|
@ -294,7 +294,7 @@ func queryDepositHandlerFn(cdc *codec.Codec, cliCtx context.CLIContext) http.Han
|
||||||
|
|
||||||
params := gov.QueryDepositParams{
|
params := gov.QueryDepositParams{
|
||||||
ProposalID: proposalID,
|
ProposalID: proposalID,
|
||||||
Depositer: depositerAddr,
|
Depositor: depositorAddr,
|
||||||
}
|
}
|
||||||
|
|
||||||
bz, err := cdc.MarshalJSON(params)
|
bz, err := cdc.MarshalJSON(params)
|
||||||
|
@ -318,7 +318,7 @@ func queryDepositHandlerFn(cdc *codec.Codec, cliCtx context.CLIContext) http.Han
|
||||||
utils.WriteErrorResponse(w, http.StatusNotFound, err.Error())
|
utils.WriteErrorResponse(w, http.StatusNotFound, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = errors.Errorf("depositer [%s] did not deposit on proposalID [%d]", bechDepositerAddr, proposalID)
|
err = errors.Errorf("depositor [%s] did not deposit on proposalID [%d]", bechDepositorAddr, proposalID)
|
||||||
utils.WriteErrorResponse(w, http.StatusNotFound, err.Error())
|
utils.WriteErrorResponse(w, http.StatusNotFound, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -433,7 +433,7 @@ func queryVotesOnProposalHandlerFn(cdc *codec.Codec, cliCtx context.CLIContext)
|
||||||
func queryProposalsWithParameterFn(cdc *codec.Codec, cliCtx context.CLIContext) http.HandlerFunc {
|
func queryProposalsWithParameterFn(cdc *codec.Codec, cliCtx context.CLIContext) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
bechVoterAddr := r.URL.Query().Get(RestVoter)
|
bechVoterAddr := r.URL.Query().Get(RestVoter)
|
||||||
bechDepositerAddr := r.URL.Query().Get(RestDepositer)
|
bechDepositorAddr := r.URL.Query().Get(RestDepositor)
|
||||||
strProposalStatus := r.URL.Query().Get(RestProposalStatus)
|
strProposalStatus := r.URL.Query().Get(RestProposalStatus)
|
||||||
strNumLimit := r.URL.Query().Get(RestNumLimit)
|
strNumLimit := r.URL.Query().Get(RestNumLimit)
|
||||||
|
|
||||||
|
@ -448,13 +448,13 @@ func queryProposalsWithParameterFn(cdc *codec.Codec, cliCtx context.CLIContext)
|
||||||
params.Voter = voterAddr
|
params.Voter = voterAddr
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(bechDepositerAddr) != 0 {
|
if len(bechDepositorAddr) != 0 {
|
||||||
depositerAddr, err := sdk.AccAddressFromBech32(bechDepositerAddr)
|
depositorAddr, err := sdk.AccAddressFromBech32(bechDepositorAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
utils.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
params.Depositer = depositerAddr
|
params.Depositor = depositorAddr
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(strProposalStatus) != 0 {
|
if len(strProposalStatus) != 0 {
|
||||||
|
|
|
@ -28,14 +28,14 @@ func (voteA Vote) Empty() bool {
|
||||||
|
|
||||||
// Deposit
|
// Deposit
|
||||||
type Deposit struct {
|
type Deposit struct {
|
||||||
Depositer sdk.AccAddress `json:"depositer"` // Address of the depositer
|
Depositor sdk.AccAddress `json:"depositor"` // Address of the depositor
|
||||||
ProposalID uint64 `json:"proposal_id"` // proposalID of the proposal
|
ProposalID uint64 `json:"proposal_id"` // proposalID of the proposal
|
||||||
Amount sdk.Coins `json:"amount"` // Deposit amount
|
Amount sdk.Coins `json:"amount"` // Deposit amount
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns whether 2 deposits are equal
|
// Returns whether 2 deposits are equal
|
||||||
func (depositA Deposit) Equals(depositB Deposit) bool {
|
func (depositA Deposit) Equals(depositB Deposit) bool {
|
||||||
return depositA.Depositer.Equals(depositB.Depositer) && depositA.ProposalID == depositB.ProposalID && depositA.Amount.IsEqual(depositB.Amount)
|
return depositA.Depositor.Equals(depositB.Depositor) && depositA.ProposalID == depositB.ProposalID && depositA.Amount.IsEqual(depositB.Amount)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns whether a deposit is empty
|
// Returns whether a deposit is empty
|
||||||
|
|
|
@ -69,7 +69,7 @@ func InitGenesis(ctx sdk.Context, k Keeper, data GenesisState) {
|
||||||
k.setVotingParams(ctx, data.VotingParams)
|
k.setVotingParams(ctx, data.VotingParams)
|
||||||
k.setTallyParams(ctx, data.TallyParams)
|
k.setTallyParams(ctx, data.TallyParams)
|
||||||
for _, deposit := range data.Deposits {
|
for _, deposit := range data.Deposits {
|
||||||
k.setDeposit(ctx, deposit.ProposalID, deposit.Deposit.Depositer, deposit.Deposit)
|
k.setDeposit(ctx, deposit.ProposalID, deposit.Deposit.Depositor, deposit.Deposit)
|
||||||
}
|
}
|
||||||
for _, vote := range data.Votes {
|
for _, vote := range data.Votes {
|
||||||
k.setVote(ctx, vote.ProposalID, vote.Vote.Voter, vote.Vote)
|
k.setVote(ctx, vote.ProposalID, vote.Vote.Voter, vote.Vote)
|
||||||
|
|
|
@ -53,7 +53,7 @@ func handleMsgSubmitProposal(ctx sdk.Context, keeper Keeper, msg MsgSubmitPropos
|
||||||
|
|
||||||
func handleMsgDeposit(ctx sdk.Context, keeper Keeper, msg MsgDeposit) sdk.Result {
|
func handleMsgDeposit(ctx sdk.Context, keeper Keeper, msg MsgDeposit) sdk.Result {
|
||||||
|
|
||||||
err, votingStarted := keeper.AddDeposit(ctx, msg.ProposalID, msg.Depositer, msg.Amount)
|
err, votingStarted := keeper.AddDeposit(ctx, msg.ProposalID, msg.Depositor, msg.Amount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err.Result()
|
return err.Result()
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ func handleMsgDeposit(ctx sdk.Context, keeper Keeper, msg MsgDeposit) sdk.Result
|
||||||
// TODO: Add tag for if voting period started
|
// TODO: Add tag for if voting period started
|
||||||
resTags := sdk.NewTags(
|
resTags := sdk.NewTags(
|
||||||
tags.Action, tags.ActionDeposit,
|
tags.Action, tags.ActionDeposit,
|
||||||
tags.Depositer, []byte(msg.Depositer.String()),
|
tags.Depositor, []byte(msg.Depositor.String()),
|
||||||
tags.ProposalID, proposalIDBytes,
|
tags.ProposalID, proposalIDBytes,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ func (keeper Keeper) DeleteProposal(ctx sdk.Context, proposalID uint64) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get Proposal from store by ProposalID
|
// Get Proposal from store by ProposalID
|
||||||
func (keeper Keeper) GetProposalsFiltered(ctx sdk.Context, voterAddr sdk.AccAddress, depositerAddr sdk.AccAddress, status ProposalStatus, numLatest uint64) []Proposal {
|
func (keeper Keeper) GetProposalsFiltered(ctx sdk.Context, voterAddr sdk.AccAddress, depositorAddr sdk.AccAddress, status ProposalStatus, numLatest uint64) []Proposal {
|
||||||
|
|
||||||
maxProposalID, err := keeper.peekCurrentProposalID(ctx)
|
maxProposalID, err := keeper.peekCurrentProposalID(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -160,8 +160,8 @@ func (keeper Keeper) GetProposalsFiltered(ctx sdk.Context, voterAddr sdk.AccAddr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if depositerAddr != nil && len(depositerAddr) != 0 {
|
if depositorAddr != nil && len(depositorAddr) != 0 {
|
||||||
_, found := keeper.GetDeposit(ctx, proposalID, depositerAddr)
|
_, found := keeper.GetDeposit(ctx, proposalID, depositorAddr)
|
||||||
if !found {
|
if !found {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -340,10 +340,10 @@ func (keeper Keeper) deleteVote(ctx sdk.Context, proposalID uint64, voterAddr sd
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// Deposits
|
// Deposits
|
||||||
|
|
||||||
// Gets the deposit of a specific depositer on a specific proposal
|
// Gets the deposit of a specific depositor on a specific proposal
|
||||||
func (keeper Keeper) GetDeposit(ctx sdk.Context, proposalID uint64, depositerAddr sdk.AccAddress) (Deposit, bool) {
|
func (keeper Keeper) GetDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress) (Deposit, bool) {
|
||||||
store := ctx.KVStore(keeper.storeKey)
|
store := ctx.KVStore(keeper.storeKey)
|
||||||
bz := store.Get(KeyDeposit(proposalID, depositerAddr))
|
bz := store.Get(KeyDeposit(proposalID, depositorAddr))
|
||||||
if bz == nil {
|
if bz == nil {
|
||||||
return Deposit{}, false
|
return Deposit{}, false
|
||||||
}
|
}
|
||||||
|
@ -352,15 +352,15 @@ func (keeper Keeper) GetDeposit(ctx sdk.Context, proposalID uint64, depositerAdd
|
||||||
return deposit, true
|
return deposit, true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (keeper Keeper) setDeposit(ctx sdk.Context, proposalID uint64, depositerAddr sdk.AccAddress, deposit Deposit) {
|
func (keeper Keeper) setDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress, deposit Deposit) {
|
||||||
store := ctx.KVStore(keeper.storeKey)
|
store := ctx.KVStore(keeper.storeKey)
|
||||||
bz := keeper.cdc.MustMarshalBinaryLengthPrefixed(deposit)
|
bz := keeper.cdc.MustMarshalBinaryLengthPrefixed(deposit)
|
||||||
store.Set(KeyDeposit(proposalID, depositerAddr), bz)
|
store.Set(KeyDeposit(proposalID, depositorAddr), bz)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adds or updates a deposit of a specific depositer on a specific proposal
|
// Adds or updates a deposit of a specific depositor on a specific proposal
|
||||||
// Activates voting period when appropriate
|
// Activates voting period when appropriate
|
||||||
func (keeper Keeper) AddDeposit(ctx sdk.Context, proposalID uint64, depositerAddr sdk.AccAddress, depositAmount sdk.Coins) (sdk.Error, bool) {
|
func (keeper Keeper) AddDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress, depositAmount sdk.Coins) (sdk.Error, bool) {
|
||||||
// Checks to see if proposal exists
|
// Checks to see if proposal exists
|
||||||
proposal := keeper.GetProposal(ctx, proposalID)
|
proposal := keeper.GetProposal(ctx, proposalID)
|
||||||
if proposal == nil {
|
if proposal == nil {
|
||||||
|
@ -372,8 +372,8 @@ func (keeper Keeper) AddDeposit(ctx sdk.Context, proposalID uint64, depositerAdd
|
||||||
return ErrAlreadyFinishedProposal(keeper.codespace, proposalID), false
|
return ErrAlreadyFinishedProposal(keeper.codespace, proposalID), false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send coins from depositer's account to DepositedCoinsAccAddr account
|
// Send coins from depositor's account to DepositedCoinsAccAddr account
|
||||||
_, err := keeper.ck.SendCoins(ctx, depositerAddr, DepositedCoinsAccAddr, depositAmount)
|
_, err := keeper.ck.SendCoins(ctx, depositorAddr, DepositedCoinsAccAddr, depositAmount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err, false
|
return err, false
|
||||||
}
|
}
|
||||||
|
@ -391,13 +391,13 @@ func (keeper Keeper) AddDeposit(ctx sdk.Context, proposalID uint64, depositerAdd
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add or update deposit object
|
// Add or update deposit object
|
||||||
currDeposit, found := keeper.GetDeposit(ctx, proposalID, depositerAddr)
|
currDeposit, found := keeper.GetDeposit(ctx, proposalID, depositorAddr)
|
||||||
if !found {
|
if !found {
|
||||||
newDeposit := Deposit{depositerAddr, proposalID, depositAmount}
|
newDeposit := Deposit{depositorAddr, proposalID, depositAmount}
|
||||||
keeper.setDeposit(ctx, proposalID, depositerAddr, newDeposit)
|
keeper.setDeposit(ctx, proposalID, depositorAddr, newDeposit)
|
||||||
} else {
|
} else {
|
||||||
currDeposit.Amount = currDeposit.Amount.Plus(depositAmount)
|
currDeposit.Amount = currDeposit.Amount.Plus(depositAmount)
|
||||||
keeper.setDeposit(ctx, proposalID, depositerAddr, currDeposit)
|
keeper.setDeposit(ctx, proposalID, depositorAddr, currDeposit)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, activatedVotingPeriod
|
return nil, activatedVotingPeriod
|
||||||
|
@ -418,7 +418,7 @@ func (keeper Keeper) RefundDeposits(ctx sdk.Context, proposalID uint64) {
|
||||||
deposit := &Deposit{}
|
deposit := &Deposit{}
|
||||||
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(depositsIterator.Value(), deposit)
|
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(depositsIterator.Value(), deposit)
|
||||||
|
|
||||||
_, err := keeper.ck.SendCoins(ctx, DepositedCoinsAccAddr, deposit.Depositer, deposit.Amount)
|
_, err := keeper.ck.SendCoins(ctx, DepositedCoinsAccAddr, deposit.Depositor, deposit.Amount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("should not happen")
|
panic("should not happen")
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,8 @@ func KeyProposal(proposalID uint64) []byte {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Key for getting a specific deposit from the store
|
// Key for getting a specific deposit from the store
|
||||||
func KeyDeposit(proposalID uint64, depositerAddr sdk.AccAddress) []byte {
|
func KeyDeposit(proposalID uint64, depositorAddr sdk.AccAddress) []byte {
|
||||||
return []byte(fmt.Sprintf("deposits:%d:%d", proposalID, depositerAddr))
|
return []byte(fmt.Sprintf("deposits:%d:%d", proposalID, depositorAddr))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Key for getting a specific vote from the store
|
// Key for getting a specific vote from the store
|
||||||
|
|
|
@ -93,7 +93,7 @@ func TestDeposits(t *testing.T) {
|
||||||
deposit, found = keeper.GetDeposit(ctx, proposalID, addrs[0])
|
deposit, found = keeper.GetDeposit(ctx, proposalID, addrs[0])
|
||||||
require.True(t, found)
|
require.True(t, found)
|
||||||
require.Equal(t, fourSteak, deposit.Amount)
|
require.Equal(t, fourSteak, deposit.Amount)
|
||||||
require.Equal(t, addrs[0], deposit.Depositer)
|
require.Equal(t, addrs[0], deposit.Depositor)
|
||||||
require.Equal(t, fourSteak, keeper.GetProposal(ctx, proposalID).GetTotalDeposit())
|
require.Equal(t, fourSteak, keeper.GetProposal(ctx, proposalID).GetTotalDeposit())
|
||||||
require.Equal(t, addr0Initial.Minus(fourSteak), keeper.ck.GetCoins(ctx, addrs[0]))
|
require.Equal(t, addr0Initial.Minus(fourSteak), keeper.ck.GetCoins(ctx, addrs[0]))
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ func TestDeposits(t *testing.T) {
|
||||||
deposit, found = keeper.GetDeposit(ctx, proposalID, addrs[0])
|
deposit, found = keeper.GetDeposit(ctx, proposalID, addrs[0])
|
||||||
require.True(t, found)
|
require.True(t, found)
|
||||||
require.Equal(t, fourSteak.Plus(fiveSteak), deposit.Amount)
|
require.Equal(t, fourSteak.Plus(fiveSteak), deposit.Amount)
|
||||||
require.Equal(t, addrs[0], deposit.Depositer)
|
require.Equal(t, addrs[0], deposit.Depositor)
|
||||||
require.Equal(t, fourSteak.Plus(fiveSteak), keeper.GetProposal(ctx, proposalID).GetTotalDeposit())
|
require.Equal(t, fourSteak.Plus(fiveSteak), keeper.GetProposal(ctx, proposalID).GetTotalDeposit())
|
||||||
require.Equal(t, addr0Initial.Minus(fourSteak).Minus(fiveSteak), keeper.ck.GetCoins(ctx, addrs[0]))
|
require.Equal(t, addr0Initial.Minus(fourSteak).Minus(fiveSteak), keeper.ck.GetCoins(ctx, addrs[0]))
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ func TestDeposits(t *testing.T) {
|
||||||
require.True(t, votingStarted)
|
require.True(t, votingStarted)
|
||||||
deposit, found = keeper.GetDeposit(ctx, proposalID, addrs[1])
|
deposit, found = keeper.GetDeposit(ctx, proposalID, addrs[1])
|
||||||
require.True(t, found)
|
require.True(t, found)
|
||||||
require.Equal(t, addrs[1], deposit.Depositer)
|
require.Equal(t, addrs[1], deposit.Depositor)
|
||||||
require.Equal(t, fourSteak, deposit.Amount)
|
require.Equal(t, fourSteak, deposit.Amount)
|
||||||
require.Equal(t, fourSteak.Plus(fiveSteak).Plus(fourSteak), keeper.GetProposal(ctx, proposalID).GetTotalDeposit())
|
require.Equal(t, fourSteak.Plus(fiveSteak).Plus(fourSteak), keeper.GetProposal(ctx, proposalID).GetTotalDeposit())
|
||||||
require.Equal(t, addr1Initial.Minus(fourSteak), keeper.ck.GetCoins(ctx, addrs[1]))
|
require.Equal(t, addr1Initial.Minus(fourSteak), keeper.ck.GetCoins(ctx, addrs[1]))
|
||||||
|
@ -126,11 +126,11 @@ func TestDeposits(t *testing.T) {
|
||||||
depositsIterator := keeper.GetDeposits(ctx, proposalID)
|
depositsIterator := keeper.GetDeposits(ctx, proposalID)
|
||||||
require.True(t, depositsIterator.Valid())
|
require.True(t, depositsIterator.Valid())
|
||||||
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(depositsIterator.Value(), &deposit)
|
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(depositsIterator.Value(), &deposit)
|
||||||
require.Equal(t, addrs[0], deposit.Depositer)
|
require.Equal(t, addrs[0], deposit.Depositor)
|
||||||
require.Equal(t, fourSteak.Plus(fiveSteak), deposit.Amount)
|
require.Equal(t, fourSteak.Plus(fiveSteak), deposit.Amount)
|
||||||
depositsIterator.Next()
|
depositsIterator.Next()
|
||||||
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(depositsIterator.Value(), &deposit)
|
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(depositsIterator.Value(), &deposit)
|
||||||
require.Equal(t, addrs[1], deposit.Depositer)
|
require.Equal(t, addrs[1], deposit.Depositor)
|
||||||
require.Equal(t, fourSteak, deposit.Amount)
|
require.Equal(t, fourSteak, deposit.Amount)
|
||||||
depositsIterator.Next()
|
depositsIterator.Next()
|
||||||
require.False(t, depositsIterator.Valid())
|
require.False(t, depositsIterator.Valid())
|
||||||
|
|
|
@ -85,14 +85,14 @@ func (msg MsgSubmitProposal) GetSigners() []sdk.AccAddress {
|
||||||
// MsgDeposit
|
// MsgDeposit
|
||||||
type MsgDeposit struct {
|
type MsgDeposit struct {
|
||||||
ProposalID uint64 `json:"proposal_id"` // ID of the proposal
|
ProposalID uint64 `json:"proposal_id"` // ID of the proposal
|
||||||
Depositer sdk.AccAddress `json:"depositer"` // Address of the depositer
|
Depositor sdk.AccAddress `json:"depositor"` // Address of the depositor
|
||||||
Amount sdk.Coins `json:"amount"` // Coins to add to the proposal's deposit
|
Amount sdk.Coins `json:"amount"` // Coins to add to the proposal's deposit
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMsgDeposit(depositer sdk.AccAddress, proposalID uint64, amount sdk.Coins) MsgDeposit {
|
func NewMsgDeposit(depositor sdk.AccAddress, proposalID uint64, amount sdk.Coins) MsgDeposit {
|
||||||
return MsgDeposit{
|
return MsgDeposit{
|
||||||
ProposalID: proposalID,
|
ProposalID: proposalID,
|
||||||
Depositer: depositer,
|
Depositor: depositor,
|
||||||
Amount: amount,
|
Amount: amount,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,8 +104,8 @@ func (msg MsgDeposit) Type() string { return "deposit" }
|
||||||
|
|
||||||
// Implements Msg.
|
// Implements Msg.
|
||||||
func (msg MsgDeposit) ValidateBasic() sdk.Error {
|
func (msg MsgDeposit) ValidateBasic() sdk.Error {
|
||||||
if len(msg.Depositer) == 0 {
|
if len(msg.Depositor) == 0 {
|
||||||
return sdk.ErrInvalidAddress(msg.Depositer.String())
|
return sdk.ErrInvalidAddress(msg.Depositor.String())
|
||||||
}
|
}
|
||||||
if !msg.Amount.IsValid() {
|
if !msg.Amount.IsValid() {
|
||||||
return sdk.ErrInvalidCoins(msg.Amount.String())
|
return sdk.ErrInvalidCoins(msg.Amount.String())
|
||||||
|
@ -120,7 +120,7 @@ func (msg MsgDeposit) ValidateBasic() sdk.Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (msg MsgDeposit) String() string {
|
func (msg MsgDeposit) String() string {
|
||||||
return fmt.Sprintf("MsgDeposit{%s=>%v: %v}", msg.Depositer, msg.ProposalID, msg.Amount)
|
return fmt.Sprintf("MsgDeposit{%s=>%v: %v}", msg.Depositor, msg.ProposalID, msg.Amount)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements Msg.
|
// Implements Msg.
|
||||||
|
@ -139,7 +139,7 @@ func (msg MsgDeposit) GetSignBytes() []byte {
|
||||||
|
|
||||||
// Implements Msg.
|
// Implements Msg.
|
||||||
func (msg MsgDeposit) GetSigners() []sdk.AccAddress {
|
func (msg MsgDeposit) GetSigners() []sdk.AccAddress {
|
||||||
return []sdk.AccAddress{msg.Depositer}
|
return []sdk.AccAddress{msg.Depositor}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
||||||
|
|
|
@ -57,7 +57,7 @@ func TestMsgDeposit(t *testing.T) {
|
||||||
_, addrs, _, _ := mock.CreateGenAccounts(1, sdk.Coins{})
|
_, addrs, _, _ := mock.CreateGenAccounts(1, sdk.Coins{})
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
proposalID uint64
|
proposalID uint64
|
||||||
depositerAddr sdk.AccAddress
|
depositorAddr sdk.AccAddress
|
||||||
depositAmount sdk.Coins
|
depositAmount sdk.Coins
|
||||||
expectPass bool
|
expectPass bool
|
||||||
}{
|
}{
|
||||||
|
@ -68,7 +68,7 @@ func TestMsgDeposit(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, tc := range tests {
|
for i, tc := range tests {
|
||||||
msg := NewMsgDeposit(tc.depositerAddr, tc.proposalID, tc.depositAmount)
|
msg := NewMsgDeposit(tc.depositorAddr, tc.proposalID, tc.depositAmount)
|
||||||
if tc.expectPass {
|
if tc.expectPass {
|
||||||
require.NoError(t, msg.ValidateBasic(), "test: %v", i)
|
require.NoError(t, msg.ValidateBasic(), "test: %v", i)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -113,14 +113,14 @@ func queryProposal(ctx sdk.Context, path []string, req abci.RequestQuery, keeper
|
||||||
// Params for query 'custom/gov/deposit'
|
// Params for query 'custom/gov/deposit'
|
||||||
type QueryDepositParams struct {
|
type QueryDepositParams struct {
|
||||||
ProposalID uint64
|
ProposalID uint64
|
||||||
Depositer sdk.AccAddress
|
Depositor sdk.AccAddress
|
||||||
}
|
}
|
||||||
|
|
||||||
// creates a new instance of QueryDepositParams
|
// creates a new instance of QueryDepositParams
|
||||||
func NewQueryDepositParams(proposalID uint64, depositer sdk.AccAddress) QueryDepositParams {
|
func NewQueryDepositParams(proposalID uint64, depositor sdk.AccAddress) QueryDepositParams {
|
||||||
return QueryDepositParams{
|
return QueryDepositParams{
|
||||||
ProposalID: proposalID,
|
ProposalID: proposalID,
|
||||||
Depositer: depositer,
|
Depositor: depositor,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ func queryDeposit(ctx sdk.Context, path []string, req abci.RequestQuery, keeper
|
||||||
return nil, sdk.ErrUnknownRequest(sdk.AppendMsgToErr("incorrectly formatted request data", err.Error()))
|
return nil, sdk.ErrUnknownRequest(sdk.AppendMsgToErr("incorrectly formatted request data", err.Error()))
|
||||||
}
|
}
|
||||||
|
|
||||||
deposit, _ := keeper.GetDeposit(ctx, params.ProposalID, params.Depositer)
|
deposit, _ := keeper.GetDeposit(ctx, params.ProposalID, params.Depositor)
|
||||||
bz, err := codec.MarshalJSONIndent(keeper.cdc, deposit)
|
bz, err := codec.MarshalJSONIndent(keeper.cdc, deposit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, sdk.ErrInternal(sdk.AppendMsgToErr("could not marshal result to JSON", err.Error()))
|
return nil, sdk.ErrInternal(sdk.AppendMsgToErr("could not marshal result to JSON", err.Error()))
|
||||||
|
@ -253,16 +253,16 @@ func queryVotes(ctx sdk.Context, path []string, req abci.RequestQuery, keeper Ke
|
||||||
// Params for query 'custom/gov/proposals'
|
// Params for query 'custom/gov/proposals'
|
||||||
type QueryProposalsParams struct {
|
type QueryProposalsParams struct {
|
||||||
Voter sdk.AccAddress
|
Voter sdk.AccAddress
|
||||||
Depositer sdk.AccAddress
|
Depositor sdk.AccAddress
|
||||||
ProposalStatus ProposalStatus
|
ProposalStatus ProposalStatus
|
||||||
Limit uint64
|
Limit uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
// creates a new instance of QueryProposalsParams
|
// creates a new instance of QueryProposalsParams
|
||||||
func NewQueryProposalsParams(status ProposalStatus, limit uint64, voter, depositer sdk.AccAddress) QueryProposalsParams {
|
func NewQueryProposalsParams(status ProposalStatus, limit uint64, voter, depositor sdk.AccAddress) QueryProposalsParams {
|
||||||
return QueryProposalsParams{
|
return QueryProposalsParams{
|
||||||
Voter: voter,
|
Voter: voter,
|
||||||
Depositer: depositer,
|
Depositor: depositor,
|
||||||
ProposalStatus: status,
|
ProposalStatus: status,
|
||||||
Limit: limit,
|
Limit: limit,
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,7 @@ func queryProposals(ctx sdk.Context, path []string, req abci.RequestQuery, keepe
|
||||||
return nil, sdk.ErrUnknownRequest(sdk.AppendMsgToErr("incorrectly formatted request data", err.Error()))
|
return nil, sdk.ErrUnknownRequest(sdk.AppendMsgToErr("incorrectly formatted request data", err.Error()))
|
||||||
}
|
}
|
||||||
|
|
||||||
proposals := keeper.GetProposalsFiltered(ctx, params.Voter, params.Depositer, params.ProposalStatus, params.Limit)
|
proposals := keeper.GetProposalsFiltered(ctx, params.Voter, params.Depositor, params.ProposalStatus, params.Limit)
|
||||||
|
|
||||||
bz, err := codec.MarshalJSONIndent(keeper.cdc, proposals)
|
bz, err := codec.MarshalJSONIndent(keeper.cdc, proposals)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -69,10 +69,10 @@ func getQueriedProposal(t *testing.T, ctx sdk.Context, cdc *codec.Codec, querier
|
||||||
return proposal
|
return proposal
|
||||||
}
|
}
|
||||||
|
|
||||||
func getQueriedProposals(t *testing.T, ctx sdk.Context, cdc *codec.Codec, querier sdk.Querier, depositer, voter sdk.AccAddress, status ProposalStatus, limit uint64) []Proposal {
|
func getQueriedProposals(t *testing.T, ctx sdk.Context, cdc *codec.Codec, querier sdk.Querier, depositor, voter sdk.AccAddress, status ProposalStatus, limit uint64) []Proposal {
|
||||||
query := abci.RequestQuery{
|
query := abci.RequestQuery{
|
||||||
Path: strings.Join([]string{"custom", "gov", QueryProposals}, "/"),
|
Path: strings.Join([]string{"custom", "gov", QueryProposals}, "/"),
|
||||||
Data: cdc.MustMarshalJSON(NewQueryProposalsParams(status, limit, voter, depositer)),
|
Data: cdc.MustMarshalJSON(NewQueryProposalsParams(status, limit, voter, depositor)),
|
||||||
}
|
}
|
||||||
|
|
||||||
bz, err := querier(ctx, []string{QueryProposal}, query)
|
bz, err := querier(ctx, []string{QueryProposal}, query)
|
||||||
|
@ -85,10 +85,10 @@ func getQueriedProposals(t *testing.T, ctx sdk.Context, cdc *codec.Codec, querie
|
||||||
return proposals
|
return proposals
|
||||||
}
|
}
|
||||||
|
|
||||||
func getQueriedDeposit(t *testing.T, ctx sdk.Context, cdc *codec.Codec, querier sdk.Querier, proposalID uint64, depositer sdk.AccAddress) Deposit {
|
func getQueriedDeposit(t *testing.T, ctx sdk.Context, cdc *codec.Codec, querier sdk.Querier, proposalID uint64, depositor sdk.AccAddress) Deposit {
|
||||||
query := abci.RequestQuery{
|
query := abci.RequestQuery{
|
||||||
Path: strings.Join([]string{"custom", "gov", QueryDeposit}, "/"),
|
Path: strings.Join([]string{"custom", "gov", QueryDeposit}, "/"),
|
||||||
Data: cdc.MustMarshalJSON(NewQueryDepositParams(proposalID, depositer)),
|
Data: cdc.MustMarshalJSON(NewQueryDepositParams(proposalID, depositor)),
|
||||||
}
|
}
|
||||||
|
|
||||||
bz, err := querier(ctx, []string{QueryDeposits}, query)
|
bz, err := querier(ctx, []string{QueryDeposits}, query)
|
||||||
|
|
|
@ -17,6 +17,6 @@ var (
|
||||||
Proposer = "proposer"
|
Proposer = "proposer"
|
||||||
ProposalID = "proposal-id"
|
ProposalID = "proposal-id"
|
||||||
VotingPeriodStart = "voting-period-start"
|
VotingPeriodStart = "voting-period-start"
|
||||||
Depositer = "depositer"
|
Depositor = "depositor"
|
||||||
Voter = "voter"
|
Voter = "voter"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue