Skip to content

Commit

Permalink
client/utils/ reorganization (cosmos#3487)
Browse files Browse the repository at this point in the history
  • Loading branch information
alessio authored and jackzampolin committed Feb 4, 2019
1 parent 1ae7cee commit c04c696
Show file tree
Hide file tree
Showing 24 changed files with 404 additions and 377 deletions.
1 change: 1 addition & 0 deletions PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ BREAKING CHANGES
* Gaia

* SDK
* [\#3487](https://github.com/cosmos/cosmos-sdk/pull/3487) Move HTTP/REST utilities out of client/utils into a new dedicated client/rest package.

* Tendermint

Expand Down
12 changes: 6 additions & 6 deletions client/lcd/lcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import (

ctypes "github.com/tendermint/tendermint/rpc/core/types"

client "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/rest"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/client/utils"
"github.com/cosmos/cosmos-sdk/cmd/gaia/app"

"github.com/cosmos/cosmos-sdk/crypto/keys/mintkey"
tests "github.com/cosmos/cosmos-sdk/tests"
"github.com/cosmos/cosmos-sdk/tests"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth"
Expand Down Expand Up @@ -212,7 +212,7 @@ func TestCoinSend(t *testing.T) {
res, body, _ = doTransferWithGas(t, port, seed, name1, memo, pw, addr, "10000", 1.0, true, false, fees)
require.Equal(t, http.StatusOK, res.StatusCode, body)

var gasEstResp utils.GasEstimateResponse
var gasEstResp rest.GasEstimateResponse
require.Nil(t, cdc.UnmarshalJSON([]byte(body), &gasEstResp))
require.NotZero(t, gasEstResp.GasEstimate)

Expand Down Expand Up @@ -288,7 +288,7 @@ func TestCoinSendGenerateSignAndBroadcast(t *testing.T) {
res, body, _ := doTransferWithGas(t, port, seed, name1, memo, "", addr, client.GasFlagAuto, 1, true, false, fees)
require.Equal(t, http.StatusOK, res.StatusCode, body)

var gasEstResp utils.GasEstimateResponse
var gasEstResp rest.GasEstimateResponse
require.Nil(t, cdc.UnmarshalJSON([]byte(body), &gasEstResp))
require.NotZero(t, gasEstResp.GasEstimate)

Expand All @@ -315,7 +315,7 @@ func TestCoinSendGenerateSignAndBroadcast(t *testing.T) {

payload := authrest.SignBody{
Tx: msg,
BaseReq: utils.NewBaseReq(
BaseReq: rest.NewBaseReq(
name1, pw, "", viper.GetString(client.FlagChainID), "", "",
accnum, sequence, nil, nil, false, false,
),
Expand Down
40 changes: 20 additions & 20 deletions client/lcd/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import (

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/client/rest"
"github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/client/utils"
gapp "github.com/cosmos/cosmos-sdk/cmd/gaia/app"
"github.com/cosmos/cosmos-sdk/codec"
crkeys "github.com/cosmos/cosmos-sdk/crypto/keys"
Expand Down Expand Up @@ -646,7 +646,7 @@ func doSign(t *testing.T, port, name, password, chainID string, accnum, sequence
var signedMsg auth.StdTx
payload := authrest.SignBody{
Tx: msg,
BaseReq: utils.NewBaseReq(
BaseReq: rest.NewBaseReq(
name, password, "", chainID, "", "", accnum, sequence, nil, nil, false, false,
),
}
Expand Down Expand Up @@ -712,7 +712,7 @@ func doTransferWithGas(
from = addr.String()
}

baseReq := utils.NewBaseReq(
baseReq := rest.NewBaseReq(
from, password, memo, chainID, gas,
fmt.Sprintf("%f", gasAdjustment), accnum, sequence, fees, nil,
generateOnly, simulate,
Expand Down Expand Up @@ -746,7 +746,7 @@ func doTransferWithGasAccAuto(
receiveAddr = sdk.AccAddress(receiveInfo.GetPubKey().Address())
chainID := viper.GetString(client.FlagChainID)

baseReq := utils.NewBaseReq(
baseReq := rest.NewBaseReq(
from, password, memo, chainID, gas,
fmt.Sprintf("%f", gasAdjustment), 0, 0, fees, nil, generateOnly, simulate,
)
Expand All @@ -764,8 +764,8 @@ func doTransferWithGasAccAuto(
}

type sendReq struct {
Amount sdk.Coins `json:"amount"`
BaseReq utils.BaseReq `json:"base_req"`
Amount sdk.Coins `json:"amount"`
BaseReq rest.BaseReq `json:"base_req"`
}

// ----------------------------------------------------------------------
Expand All @@ -779,7 +779,7 @@ func doDelegate(t *testing.T, port, name, password string,
accnum := acc.GetAccountNumber()
sequence := acc.GetSequence()
chainID := viper.GetString(client.FlagChainID)
baseReq := utils.NewBaseReq(name, password, "", chainID, "", "", accnum, sequence, fees, nil, false, false)
baseReq := rest.NewBaseReq(name, password, "", chainID, "", "", accnum, sequence, fees, nil, false, false)
msg := msgDelegationsInput{
BaseReq: baseReq,
DelegatorAddr: delAddr,
Expand All @@ -799,7 +799,7 @@ func doDelegate(t *testing.T, port, name, password string,
}

type msgDelegationsInput struct {
BaseReq utils.BaseReq `json:"base_req"`
BaseReq rest.BaseReq `json:"base_req"`
DelegatorAddr sdk.AccAddress `json:"delegator_addr"` // in bech32
ValidatorAddr sdk.ValAddress `json:"validator_addr"` // in bech32
Delegation sdk.Coin `json:"delegation"`
Expand All @@ -813,7 +813,7 @@ func doUndelegate(t *testing.T, port, name, password string,
accnum := acc.GetAccountNumber()
sequence := acc.GetSequence()
chainID := viper.GetString(client.FlagChainID)
baseReq := utils.NewBaseReq(name, password, "", chainID, "", "", accnum, sequence, fees, nil, false, false)
baseReq := rest.NewBaseReq(name, password, "", chainID, "", "", accnum, sequence, fees, nil, false, false)
msg := msgUndelegateInput{
BaseReq: baseReq,
DelegatorAddr: delAddr,
Expand All @@ -834,7 +834,7 @@ func doUndelegate(t *testing.T, port, name, password string,
}

type msgUndelegateInput struct {
BaseReq utils.BaseReq `json:"base_req"`
BaseReq rest.BaseReq `json:"base_req"`
DelegatorAddr sdk.AccAddress `json:"delegator_addr"` // in bech32
ValidatorAddr sdk.ValAddress `json:"validator_addr"` // in bech32
SharesAmount sdk.Dec `json:"shares"`
Expand All @@ -849,7 +849,7 @@ func doBeginRedelegation(t *testing.T, port, name, password string,
sequence := acc.GetSequence()

chainID := viper.GetString(client.FlagChainID)
baseReq := utils.NewBaseReq(name, password, "", chainID, "", "", accnum, sequence, fees, nil, false, false)
baseReq := rest.NewBaseReq(name, password, "", chainID, "", "", accnum, sequence, fees, nil, false, false)

msg := msgBeginRedelegateInput{
BaseReq: baseReq,
Expand All @@ -872,7 +872,7 @@ func doBeginRedelegation(t *testing.T, port, name, password string,
}

type msgBeginRedelegateInput struct {
BaseReq utils.BaseReq `json:"base_req"`
BaseReq rest.BaseReq `json:"base_req"`
DelegatorAddr sdk.AccAddress `json:"delegator_addr"` // in bech32
ValidatorSrcAddr sdk.ValAddress `json:"validator_src_addr"` // in bech32
ValidatorDstAddr sdk.ValAddress `json:"validator_dst_addr"` // in bech32
Expand Down Expand Up @@ -1080,7 +1080,7 @@ func doSubmitProposal(t *testing.T, port, seed, name, password string, proposerA
accnum := acc.GetAccountNumber()
sequence := acc.GetSequence()
chainID := viper.GetString(client.FlagChainID)
baseReq := utils.NewBaseReq(name, password, "", chainID, "", "", accnum, sequence, fees, nil, false, false)
baseReq := rest.NewBaseReq(name, password, "", chainID, "", "", accnum, sequence, fees, nil, false, false)

pr := postProposalReq{
Title: "Test",
Expand All @@ -1106,7 +1106,7 @@ func doSubmitProposal(t *testing.T, port, seed, name, password string, proposerA
}

type postProposalReq struct {
BaseReq utils.BaseReq `json:"base_req"`
BaseReq rest.BaseReq `json:"base_req"`
Title string `json:"title"` // Title of the proposal
Description string `json:"description"` // Description of the proposal
ProposalType string `json:"proposal_type"` // Type of proposal. Initial set {PlainTextProposal, SoftwareUpgradeProposal}
Expand Down Expand Up @@ -1176,7 +1176,7 @@ func doDeposit(t *testing.T, port, seed, name, password string, proposerAddr sdk
accnum := acc.GetAccountNumber()
sequence := acc.GetSequence()
chainID := viper.GetString(client.FlagChainID)
baseReq := utils.NewBaseReq(name, password, "", chainID, "", "", accnum, sequence, fees, nil, false, false)
baseReq := rest.NewBaseReq(name, password, "", chainID, "", "", accnum, sequence, fees, nil, false, false)

dr := depositReq{
Depositor: proposerAddr,
Expand All @@ -1198,7 +1198,7 @@ func doDeposit(t *testing.T, port, seed, name, password string, proposerAddr sdk
}

type depositReq struct {
BaseReq utils.BaseReq `json:"base_req"`
BaseReq rest.BaseReq `json:"base_req"`
Depositor sdk.AccAddress `json:"depositor"` // Address of the depositor
Amount sdk.Coins `json:"amount"` // Coins to add to the proposal's deposit
}
Expand Down Expand Up @@ -1230,7 +1230,7 @@ func doVote(t *testing.T, port, seed, name, password string, proposerAddr sdk.Ac
accnum := acc.GetAccountNumber()
sequence := acc.GetSequence()
chainID := viper.GetString(client.FlagChainID)
baseReq := utils.NewBaseReq(name, password, "", chainID, "", "", accnum, sequence, fees, nil, false, false)
baseReq := rest.NewBaseReq(name, password, "", chainID, "", "", accnum, sequence, fees, nil, false, false)

vr := voteReq{
Voter: proposerAddr,
Expand All @@ -1252,7 +1252,7 @@ func doVote(t *testing.T, port, seed, name, password string, proposerAddr sdk.Ac
}

type voteReq struct {
BaseReq utils.BaseReq `json:"base_req"`
BaseReq rest.BaseReq `json:"base_req"`
Voter sdk.AccAddress `json:"voter"` // address of the voter
Option string `json:"option"` // option from OptionSet chosen by the voter
}
Expand Down Expand Up @@ -1362,7 +1362,7 @@ func getSigningInfo(t *testing.T, port string, validatorPubKey string) slashing.
func doUnjail(t *testing.T, port, seed, name, password string,
valAddr sdk.ValAddress, fees sdk.Coins) (resultTx ctypes.ResultBroadcastTxCommit) {
chainID := viper.GetString(client.FlagChainID)
baseReq := utils.NewBaseReq(name, password, "", chainID, "", "", 1, 1, fees, nil, false, false)
baseReq := rest.NewBaseReq(name, password, "", chainID, "", "", 1, 1, fees, nil, false, false)

ur := unjailReq{
BaseReq: baseReq,
Expand All @@ -1380,5 +1380,5 @@ func doUnjail(t *testing.T, port, seed, name, password string,
}

type unjailReq struct {
BaseReq utils.BaseReq `json:"base_req"`
BaseReq rest.BaseReq `json:"base_req"`
}
Loading

0 comments on commit c04c696

Please sign in to comment.