Skip to content

Commit

Permalink
Merge pull request #557 from MrXJC/jiacheng/deps2
Browse files Browse the repository at this point in the history
Fix all rest api
  • Loading branch information
HaoyangLiu authored Nov 9, 2018
2 parents cecfa18 + eb05a9c commit 3354164
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ update_irislcd_swagger_docs:
install: update_irislcd_swagger_docs
go install $(BUILD_FLAGS) ./cmd/iris
go install $(BUILD_FLAGS) ./cmd/iriscli
# go install $(BUILD_FLAGS) ./cmd/irislcd
go install $(BUILD_FLAGS) ./cmd/irislcd
# go install $(BUILD_FLAGS) ./cmd/irismon

install_debug:
Expand Down
2 changes: 1 addition & 1 deletion client/bank/lcd/sendtx.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func SendTxRequestHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http.Ha
var sig = make([]auth.StdSignature, len(sendTxBody.Signatures))
for index, s := range sendTxBody.Signatures {
var pubkey crypto.PubKey
if err := cdc.UnMarshalBinaryLengthPrefixedBare(s.PubKey, &pubkey); err != nil {
if err := cdc.UnmarshalBinaryBare(s.PubKey, &pubkey); err != nil {
utils.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
return
}
Expand Down
6 changes: 3 additions & 3 deletions client/distribution/lcd/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func QueryDelegatorDistInfoHandlerFn(storeName string, cliCtx context.CLIContext
var ddiList []types.DelegationDistInfo
for _, kv := range resKVs {
var ddi types.DelegationDistInfo
err = cliCtx.Codec.UnMarshalBinaryLengthPrefixed(kv.Value, &ddi)
err = cliCtx.Codec.UnmarshalBinaryLengthPrefixed(kv.Value, &ddi)
if err != nil {
utils.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
return
Expand Down Expand Up @@ -105,7 +105,7 @@ func QueryDelegationDistInfoHandlerFn(storeName string, cliCtx context.CLIContex
}

var ddi types.DelegationDistInfo
err = cliCtx.Codec.UnMarshalBinaryLengthPrefixed(res, &ddi)
err = cliCtx.Codec.UnmarshalBinaryLengthPrefixed(res, &ddi)
if err != nil {
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
Expand Down Expand Up @@ -139,7 +139,7 @@ func QueryValidatorDistInfoHandlerFn(storeName string, cliCtx context.CLIContext
}

var vdi types.ValidatorDistInfo
err = cliCtx.Codec.UnMarshalBinaryLengthPrefixed(res, &vdi)
err = cliCtx.Codec.UnmarshalBinaryLengthPrefixed(res, &vdi)
if err != nil {
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
Expand Down
5 changes: 5 additions & 0 deletions client/lcd/swaggerui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,11 @@ paths:
description: proposal status, valid values can be `"DepositPeriod"`, `"VotingPeriod"`, `"Passed"`, `"Rejected"`
required: false
type: string
- in: query
name: limit
description: limit to latest [number] proposals. Defaults to all proposals
required: false
type: string
responses:
200:
description: OK
Expand Down
28 changes: 14 additions & 14 deletions client/lcd/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,37 @@ import (
"strings"
"testing"

"github.com/cosmos/cosmos-sdk/codec"
crkeys "github.com/cosmos/cosmos-sdk/crypto/keys"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/tests"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/x/auth"

"github.com/spf13/viper"
"github.com/stretchr/testify/require"

txbuilder "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
"github.com/cosmos/cosmos-sdk/x/stake"
irisapp "github.com/irisnet/irishub/app"
"github.com/irisnet/irishub/client"
"github.com/irisnet/irishub/client/keys"
"github.com/irisnet/irishub/modules/gov"
"github.com/irisnet/irishub/modules/upgrade"
abci "github.com/tendermint/tendermint/abci/types"
tmcfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
"github.com/tendermint/tendermint/crypto/secp256k1"
"github.com/tendermint/tendermint/libs/cli"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
nm "github.com/tendermint/tendermint/node"
"github.com/tendermint/tendermint/p2p"
pvm "github.com/tendermint/tendermint/privval"
"github.com/tendermint/tendermint/proxy"
tmrpc "github.com/tendermint/tendermint/rpc/lib/server"
tmtypes "github.com/tendermint/tendermint/types"
"github.com/irisnet/irishub/client/keys"
irisapp "github.com/irisnet/irishub/app"
"github.com/irisnet/irishub/client"
"github.com/tendermint/tendermint/p2p"
"github.com/tendermint/tendermint/crypto/secp256k1"
"github.com/cosmos/cosmos-sdk/x/stake"
txbuilder "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
"github.com/irisnet/irishub/modules/gov"
"github.com/irisnet/irishub/modules/upgrade"
)

// makePathname creates a unique pathname for each test. It will panic if it
Expand Down Expand Up @@ -173,7 +173,7 @@ func InitializeTestLCD(
msg := stake.NewMsgCreateValidator(
sdk.ValAddress(operAddr),
pubKey,
sdk.NewCoin("iris-atto",sdk.NewIntWithDecimal(1,delegation)),
sdk.NewCoin("iris-atto", sdk.NewIntWithDecimal(1, delegation)),
stake.Description{Moniker: fmt.Sprintf("validator-%d", i+1)},
stake.NewCommissionMsg(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()),
)
Expand All @@ -191,16 +191,16 @@ func InitializeTestLCD(
valOperAddrs = append(valOperAddrs, sdk.ValAddress(operAddr))
}

genesisState, err := irisapp.IrisAppGenState(cdc, genTxs)
genesisState, err := irisapp.IrisAppGenState(cdc, *genDoc, genTxs)
require.NoError(t, err)

// add some tokens to init accounts
for _, addr := range initAddrs {
accAuth := auth.NewBaseAccountWithAddress(addr)
accAuth.Coins = sdk.Coins{sdk.NewCoin("iris-atto",sdk.NewIntWithDecimal(1,20))}
accAuth.Coins = sdk.Coins{sdk.NewCoin("iris-atto", sdk.NewIntWithDecimal(1, 20))}
acc := irisapp.NewGenesisAccount(&accAuth)
genesisState.Accounts = append(genesisState.Accounts, acc)
genesisState.StakeData.Pool.LooseTokens = genesisState.StakeData.Pool.LooseTokens.Add(sdk.NewDecFromInt(sdk.NewIntWithDecimal(1,20)))
genesisState.StakeData.Pool.LooseTokens = genesisState.StakeData.Pool.LooseTokens.Add(sdk.NewDecFromInt(sdk.NewIntWithDecimal(1, 20)))
}

genesisState.GovData = gov.DefaultGenesisStateForLCDTest()
Expand Down
2 changes: 1 addition & 1 deletion client/slashing/lcd/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func signingInfoHandlerFn(cliCtx context.CLIContext, storeName string, cdc *code

var signingInfo slashing.ValidatorSigningInfo

err = cdc.UnMarshalBinaryLengthPrefixed(res, &signingInfo)
err = cdc.UnmarshalBinaryLengthPrefixed(res, &signingInfo)
if err != nil {
utils.WriteErrorResponse(w, http.StatusInternalServerError, fmt.Sprintf("couldn't decode signing info. Error: %s", err.Error()))
return
Expand Down
27 changes: 14 additions & 13 deletions modules/gov/keeper.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package gov

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/bank"
"github.com/irisnet/irishub/modules/gov/params"
"github.com/irisnet/irishub/iparam"
"github.com/irisnet/irishub/modules/gov/params"
"github.com/tendermint/tendermint/crypto"
"time"
)
Expand All @@ -15,6 +15,7 @@ var (
DepositedCoinsAccAddr = sdk.AccAddress(crypto.AddressHash([]byte("govDepositedCoins")))
BurnedDepositCoinsAccAddr = sdk.AccAddress(crypto.AddressHash([]byte("govBurnedDepositCoins")))
)

// Governance Keeper
type Keeper struct {

Expand Down Expand Up @@ -42,14 +43,14 @@ type Keeper struct {
// - depositing funds into proposals, and activating upon sufficient funds being deposited
// - users voting on proposals, with weight proportional to stake in the system
// - and tallying the result of the vote.
func NewKeeper(cdc *codec.Codec, key sdk.StoreKey,ck bank.Keeper, ds sdk.DelegationSet, codespace sdk.CodespaceType) Keeper {
func NewKeeper(cdc *codec.Codec, key sdk.StoreKey, ck bank.Keeper, ds sdk.DelegationSet, codespace sdk.CodespaceType) Keeper {
return Keeper{
storeKey: key,
ck: ck,
ds: ds,
vs: ds.GetValidatorSet(),
cdc: cdc,
codespace: codespace,
storeKey: key,
ck: ck,
ds: ds,
vs: ds.GetValidatorSet(),
cdc: cdc,
codespace: codespace,
}
}

Expand All @@ -68,8 +69,8 @@ func (keeper Keeper) NewProposal(ctx sdk.Context, title string, description stri
}
return nil
}
//////////////////// iris end /////////////////////////////

//////////////////// iris end /////////////////////////////

// =====================================================
// Proposals
Expand Down Expand Up @@ -154,8 +155,8 @@ func (keeper Keeper) NewUpgradeProposal(ctx sdk.Context, title string, descripti
keeper.InsertInactiveProposalQueue(ctx, proposal.GetDepositEndTime(), proposalID)
return proposal
}
//////////////////// iris end /////////////////////////////

//////////////////// iris end /////////////////////////////

// Get Proposal from store by ProposalID
func (keeper Keeper) GetProposal(ctx sdk.Context, proposalID uint64) Proposal {
Expand Down Expand Up @@ -197,7 +198,7 @@ func (keeper Keeper) GetProposalsFiltered(ctx sdk.Context, voterAddr sdk.AccAddr

matchingProposals := []Proposal{}

if numLatest == 0 {
if numLatest == 0 || maxProposalID < numLatest {
numLatest = maxProposalID
}

Expand Down Expand Up @@ -495,4 +496,4 @@ func (keeper Keeper) InsertInactiveProposalQueue(ctx sdk.Context, endTime time.T
func (keeper Keeper) RemoveFromInactiveProposalQueue(ctx sdk.Context, endTime time.Time, proposalID uint64) {
store := ctx.KVStore(keeper.storeKey)
store.Delete(KeyInactiveProposalQueueProposal(endTime, proposalID))
}
}

0 comments on commit 3354164

Please sign in to comment.