Merge branch 'develop' into cwgoes/update-tendermint-upstream
This commit is contained in:
commit
f95d26aec1
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
auth "github.com/cosmos/cosmos-sdk/x/auth"
|
||||
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
|
||||
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -52,13 +52,13 @@ func ParseFloat64OrReturnBadRequest(w http.ResponseWriter, s string, defaultIfEm
|
|||
}
|
||||
|
||||
// WriteGenerateStdTxResponse writes response for the generate_only mode.
|
||||
func WriteGenerateStdTxResponse(w http.ResponseWriter, txCtx authctx.TxContext, msgs []sdk.Msg) {
|
||||
stdMsg, err := txCtx.Build(msgs)
|
||||
func WriteGenerateStdTxResponse(w http.ResponseWriter, txBldr authtxb.TxBuilder, msgs []sdk.Msg) {
|
||||
stdMsg, err := txBldr.Build(msgs)
|
||||
if err != nil {
|
||||
WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
output, err := txCtx.Codec.MarshalJSON(auth.NewStdTx(stdMsg.Msgs, stdMsg.Fee, nil, stdMsg.Memo))
|
||||
output, err := txBldr.Codec.MarshalJSON(auth.NewStdTx(stdMsg.Msgs, stdMsg.Fee, nil, stdMsg.Memo))
|
||||
if err != nil {
|
||||
WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
|
|
|
@ -9,28 +9,28 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/client/keys"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
auth "github.com/cosmos/cosmos-sdk/x/auth"
|
||||
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
|
||||
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||
amino "github.com/tendermint/go-amino"
|
||||
"github.com/tendermint/tendermint/libs/common"
|
||||
)
|
||||
|
||||
// SendTx implements a auxiliary handler that facilitates sending a series of
|
||||
// messages in a signed transaction given a TxContext and a QueryContext. It
|
||||
// messages in a signed transaction given a TxBuilder and a QueryContext. It
|
||||
// ensures that the account exists, has a proper number and sequence set. In
|
||||
// addition, it builds and signs a transaction with the supplied messages.
|
||||
// Finally, it broadcasts the signed transaction to a node.
|
||||
func SendTx(txCtx authctx.TxContext, cliCtx context.CLIContext, msgs []sdk.Msg) error {
|
||||
txCtx, err := prepareTxContext(txCtx, cliCtx)
|
||||
func SendTx(txBldr authtxb.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg) error {
|
||||
txBldr, err := prepareTxContext(txBldr, cliCtx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
autogas := cliCtx.DryRun || (cliCtx.Gas == 0)
|
||||
if autogas {
|
||||
txCtx, err = EnrichCtxWithGas(txCtx, cliCtx, cliCtx.FromAddressName, msgs)
|
||||
txBldr, err = EnrichCtxWithGas(txBldr, cliCtx, cliCtx.FromAddressName, msgs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, "estimated gas = %v\n", txCtx.Gas)
|
||||
fmt.Fprintf(os.Stderr, "estimated gas = %v\n", txBldr.Gas)
|
||||
}
|
||||
if cliCtx.DryRun {
|
||||
return nil
|
||||
|
@ -42,7 +42,7 @@ func SendTx(txCtx authctx.TxContext, cliCtx context.CLIContext, msgs []sdk.Msg)
|
|||
}
|
||||
|
||||
// build and sign the transaction
|
||||
txBytes, err := txCtx.BuildAndSign(cliCtx.FromAddressName, passphrase, msgs)
|
||||
txBytes, err := txBldr.BuildAndSign(cliCtx.FromAddressName, passphrase, msgs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -51,8 +51,8 @@ func SendTx(txCtx authctx.TxContext, cliCtx context.CLIContext, msgs []sdk.Msg)
|
|||
}
|
||||
|
||||
// SimulateMsgs simulates the transaction and returns the gas estimate and the adjusted value.
|
||||
func SimulateMsgs(txCtx authctx.TxContext, cliCtx context.CLIContext, name string, msgs []sdk.Msg, gas int64) (estimated, adjusted int64, err error) {
|
||||
txBytes, err := txCtx.WithGas(gas).BuildWithPubKey(name, msgs)
|
||||
func SimulateMsgs(txBldr authtxb.TxBuilder, cliCtx context.CLIContext, name string, msgs []sdk.Msg, gas int64) (estimated, adjusted int64, err error) {
|
||||
txBytes, err := txBldr.WithGas(gas).BuildWithPubKey(name, msgs)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -62,19 +62,19 @@ func SimulateMsgs(txCtx authctx.TxContext, cliCtx context.CLIContext, name strin
|
|||
|
||||
// EnrichCtxWithGas calculates the gas estimate that would be consumed by the
|
||||
// transaction and set the transaction's respective value accordingly.
|
||||
func EnrichCtxWithGas(txCtx authctx.TxContext, cliCtx context.CLIContext, name string, msgs []sdk.Msg) (authctx.TxContext, error) {
|
||||
_, adjusted, err := SimulateMsgs(txCtx, cliCtx, name, msgs, 0)
|
||||
func EnrichCtxWithGas(txBldr authtxb.TxBuilder, cliCtx context.CLIContext, name string, msgs []sdk.Msg) (authtxb.TxBuilder, error) {
|
||||
_, adjusted, err := SimulateMsgs(txBldr, cliCtx, name, msgs, 0)
|
||||
if err != nil {
|
||||
return txCtx, err
|
||||
return txBldr, err
|
||||
}
|
||||
return txCtx.WithGas(adjusted), nil
|
||||
return txBldr.WithGas(adjusted), nil
|
||||
}
|
||||
|
||||
// CalculateGas simulates the execution of a transaction and returns
|
||||
// both the estimate obtained by the query and the adjusted amount.
|
||||
func CalculateGas(queryFunc func(string, common.HexBytes) ([]byte, error), cdc *amino.Codec, txBytes []byte, adjustment float64) (estimate, adjusted int64, err error) {
|
||||
// run a simulation (via /app/simulate query) to
|
||||
// estimate gas and update TxContext accordingly
|
||||
// estimate gas and update TxBuilder accordingly
|
||||
rawRes, err := queryFunc("/app/simulate", txBytes)
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -88,12 +88,12 @@ func CalculateGas(queryFunc func(string, common.HexBytes) ([]byte, error), cdc *
|
|||
}
|
||||
|
||||
// PrintUnsignedStdTx builds an unsigned StdTx and prints it to os.Stdout.
|
||||
func PrintUnsignedStdTx(txCtx authctx.TxContext, cliCtx context.CLIContext, msgs []sdk.Msg) (err error) {
|
||||
stdTx, err := buildUnsignedStdTx(txCtx, cliCtx, msgs)
|
||||
func PrintUnsignedStdTx(txBldr authtxb.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg) (err error) {
|
||||
stdTx, err := buildUnsignedStdTx(txBldr, cliCtx, msgs)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
json, err := txCtx.Codec.MarshalJSON(stdTx)
|
||||
json, err := txBldr.Codec.MarshalJSON(stdTx)
|
||||
if err == nil {
|
||||
fmt.Printf("%s\n", json)
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ func PrintUnsignedStdTx(txCtx authctx.TxContext, cliCtx context.CLIContext, msgs
|
|||
|
||||
// SignStdTx appends a signature to a StdTx and returns a copy of a it. If appendSig
|
||||
// is false, it replaces the signatures already attached with the new signature.
|
||||
func SignStdTx(txCtx authctx.TxContext, cliCtx context.CLIContext, name string, stdTx auth.StdTx, appendSig bool) (auth.StdTx, error) {
|
||||
func SignStdTx(txBldr authtxb.TxBuilder, cliCtx context.CLIContext, name string, stdTx auth.StdTx, appendSig bool) (auth.StdTx, error) {
|
||||
var signedStdTx auth.StdTx
|
||||
|
||||
keybase, err := keys.GetKeyBase()
|
||||
|
@ -120,27 +120,27 @@ func SignStdTx(txCtx authctx.TxContext, cliCtx context.CLIContext, name string,
|
|||
fmt.Fprintf(os.Stderr, "WARNING: The generated transaction's intended signer does not match the given signer: '%v'", name)
|
||||
}
|
||||
|
||||
if txCtx.AccountNumber == 0 {
|
||||
if txBldr.AccountNumber == 0 {
|
||||
accNum, err := cliCtx.GetAccountNumber(addr)
|
||||
if err != nil {
|
||||
return signedStdTx, err
|
||||
}
|
||||
txCtx = txCtx.WithAccountNumber(accNum)
|
||||
txBldr = txBldr.WithAccountNumber(accNum)
|
||||
}
|
||||
|
||||
if txCtx.Sequence == 0 {
|
||||
if txBldr.Sequence == 0 {
|
||||
accSeq, err := cliCtx.GetAccountSequence(addr)
|
||||
if err != nil {
|
||||
return signedStdTx, err
|
||||
}
|
||||
txCtx = txCtx.WithSequence(accSeq)
|
||||
txBldr = txBldr.WithSequence(accSeq)
|
||||
}
|
||||
|
||||
passphrase, err := keys.GetPassphrase(name)
|
||||
if err != nil {
|
||||
return signedStdTx, err
|
||||
}
|
||||
return txCtx.SignStdTx(name, passphrase, stdTx, appendSig)
|
||||
return txBldr.SignStdTx(name, passphrase, stdTx, appendSig)
|
||||
}
|
||||
|
||||
func adjustGasEstimate(estimate int64, adjustment float64) int64 {
|
||||
|
@ -155,53 +155,53 @@ func parseQueryResponse(cdc *amino.Codec, rawRes []byte) (int64, error) {
|
|||
return simulationResult.GasUsed, nil
|
||||
}
|
||||
|
||||
func prepareTxContext(txCtx authctx.TxContext, cliCtx context.CLIContext) (authctx.TxContext, error) {
|
||||
func prepareTxContext(txBldr authtxb.TxBuilder, cliCtx context.CLIContext) (authtxb.TxBuilder, error) {
|
||||
if err := cliCtx.EnsureAccountExists(); err != nil {
|
||||
return txCtx, err
|
||||
return txBldr, err
|
||||
}
|
||||
|
||||
from, err := cliCtx.GetFromAddress()
|
||||
if err != nil {
|
||||
return txCtx, err
|
||||
return txBldr, err
|
||||
}
|
||||
|
||||
// TODO: (ref #1903) Allow for user supplied account number without
|
||||
// automatically doing a manual lookup.
|
||||
if txCtx.AccountNumber == 0 {
|
||||
if txBldr.AccountNumber == 0 {
|
||||
accNum, err := cliCtx.GetAccountNumber(from)
|
||||
if err != nil {
|
||||
return txCtx, err
|
||||
return txBldr, err
|
||||
}
|
||||
txCtx = txCtx.WithAccountNumber(accNum)
|
||||
txBldr = txBldr.WithAccountNumber(accNum)
|
||||
}
|
||||
|
||||
// TODO: (ref #1903) Allow for user supplied account sequence without
|
||||
// automatically doing a manual lookup.
|
||||
if txCtx.Sequence == 0 {
|
||||
if txBldr.Sequence == 0 {
|
||||
accSeq, err := cliCtx.GetAccountSequence(from)
|
||||
if err != nil {
|
||||
return txCtx, err
|
||||
return txBldr, err
|
||||
}
|
||||
txCtx = txCtx.WithSequence(accSeq)
|
||||
txBldr = txBldr.WithSequence(accSeq)
|
||||
}
|
||||
return txCtx, nil
|
||||
return txBldr, nil
|
||||
}
|
||||
|
||||
// buildUnsignedStdTx builds a StdTx as per the parameters passed in the
|
||||
// contexts. Gas is automatically estimated if gas wanted is set to 0.
|
||||
func buildUnsignedStdTx(txCtx authctx.TxContext, cliCtx context.CLIContext, msgs []sdk.Msg) (stdTx auth.StdTx, err error) {
|
||||
txCtx, err = prepareTxContext(txCtx, cliCtx)
|
||||
func buildUnsignedStdTx(txBldr authtxb.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg) (stdTx auth.StdTx, err error) {
|
||||
txBldr, err = prepareTxContext(txBldr, cliCtx)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if txCtx.Gas == 0 {
|
||||
txCtx, err = EnrichCtxWithGas(txCtx, cliCtx, cliCtx.FromAddressName, msgs)
|
||||
if txBldr.Gas == 0 {
|
||||
txBldr, err = EnrichCtxWithGas(txBldr, cliCtx, cliCtx.FromAddressName, msgs)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, "estimated gas = %v\n", txCtx.Gas)
|
||||
fmt.Fprintf(os.Stderr, "estimated gas = %v\n", txBldr.Gas)
|
||||
}
|
||||
stdSignMsg, err := txCtx.Build(msgs)
|
||||
stdSignMsg, err := txBldr.Build(msgs)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ type GaiaApp struct {
|
|||
// Manage getting and setting accounts
|
||||
accountMapper auth.AccountMapper
|
||||
feeCollectionKeeper auth.FeeCollectionKeeper
|
||||
coinKeeper bank.Keeper
|
||||
bankKeeper bank.Keeper
|
||||
ibcMapper ibc.Mapper
|
||||
stakeKeeper stake.Keeper
|
||||
slashingKeeper slashing.Keeper
|
||||
|
@ -89,19 +89,19 @@ func NewGaiaApp(logger log.Logger, db dbm.DB, traceStore io.Writer, baseAppOptio
|
|||
)
|
||||
|
||||
// add handlers
|
||||
app.coinKeeper = bank.NewKeeper(app.accountMapper)
|
||||
app.bankKeeper = bank.NewKeeper(app.accountMapper)
|
||||
app.ibcMapper = ibc.NewMapper(app.cdc, app.keyIBC, app.RegisterCodespace(ibc.DefaultCodespace))
|
||||
app.paramsKeeper = params.NewKeeper(app.cdc, app.keyParams)
|
||||
app.stakeKeeper = stake.NewKeeper(app.cdc, app.keyStake, app.coinKeeper, app.RegisterCodespace(stake.DefaultCodespace))
|
||||
app.stakeKeeper = stake.NewKeeper(app.cdc, app.keyStake, app.bankKeeper, app.RegisterCodespace(stake.DefaultCodespace))
|
||||
app.slashingKeeper = slashing.NewKeeper(app.cdc, app.keySlashing, app.stakeKeeper, app.paramsKeeper.Getter(), app.RegisterCodespace(slashing.DefaultCodespace))
|
||||
app.stakeKeeper = app.stakeKeeper.WithValidatorHooks(app.slashingKeeper.ValidatorHooks())
|
||||
app.govKeeper = gov.NewKeeper(app.cdc, app.keyGov, app.paramsKeeper.Setter(), app.coinKeeper, app.stakeKeeper, app.RegisterCodespace(gov.DefaultCodespace))
|
||||
app.govKeeper = gov.NewKeeper(app.cdc, app.keyGov, app.paramsKeeper.Setter(), app.bankKeeper, app.stakeKeeper, app.RegisterCodespace(gov.DefaultCodespace))
|
||||
app.feeCollectionKeeper = auth.NewFeeCollectionKeeper(app.cdc, app.keyFeeCollection)
|
||||
|
||||
// register message routes
|
||||
app.Router().
|
||||
AddRoute("bank", bank.NewHandler(app.coinKeeper)).
|
||||
AddRoute("ibc", ibc.NewHandler(app.ibcMapper, app.coinKeeper)).
|
||||
AddRoute("bank", bank.NewHandler(app.bankKeeper)).
|
||||
AddRoute("ibc", ibc.NewHandler(app.ibcMapper, app.bankKeeper)).
|
||||
AddRoute("stake", stake.NewHandler(app.stakeKeeper)).
|
||||
AddRoute("slashing", slashing.NewHandler(app.slashingKeeper)).
|
||||
AddRoute("gov", gov.NewHandler(app.govKeeper))
|
||||
|
|
|
@ -111,7 +111,7 @@ func invariants(app *GaiaApp) []simulation.Invariant {
|
|||
func(t *testing.T, baseapp *baseapp.BaseApp, log string) {
|
||||
banksim.NonnegativeBalanceInvariant(app.accountMapper)(t, baseapp, log)
|
||||
govsim.AllInvariants()(t, baseapp, log)
|
||||
stakesim.AllInvariants(app.coinKeeper, app.stakeKeeper, app.accountMapper)(t, baseapp, log)
|
||||
stakesim.AllInvariants(app.bankKeeper, app.stakeKeeper, app.accountMapper)(t, baseapp, log)
|
||||
slashingsim.AllInvariants()(t, baseapp, log)
|
||||
},
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ type GaiaApp struct {
|
|||
// Manage getting and setting accounts
|
||||
accountMapper auth.AccountMapper
|
||||
feeCollectionKeeper auth.FeeCollectionKeeper
|
||||
coinKeeper bank.Keeper
|
||||
bankKeeper bank.Keeper
|
||||
ibcMapper ibc.Mapper
|
||||
stakeKeeper stake.Keeper
|
||||
slashingKeeper slashing.Keeper
|
||||
|
@ -173,16 +173,16 @@ func NewGaiaApp(logger log.Logger, db dbm.DB, baseAppOptions ...func(*bam.BaseAp
|
|||
)
|
||||
|
||||
// add handlers
|
||||
app.coinKeeper = bank.NewKeeper(app.accountMapper)
|
||||
app.bankKeeper = bank.NewKeeper(app.accountMapper)
|
||||
app.ibcMapper = ibc.NewMapper(app.cdc, app.keyIBC, app.RegisterCodespace(ibc.DefaultCodespace))
|
||||
app.paramsKeeper = params.NewKeeper(app.cdc, app.keyParams)
|
||||
app.stakeKeeper = stake.NewKeeper(app.cdc, app.keyStake, app.coinKeeper, app.RegisterCodespace(stake.DefaultCodespace))
|
||||
app.stakeKeeper = stake.NewKeeper(app.cdc, app.keyStake, app.bankKeeper, app.RegisterCodespace(stake.DefaultCodespace))
|
||||
app.slashingKeeper = slashing.NewKeeper(app.cdc, app.keySlashing, app.stakeKeeper, app.paramsKeeper.Getter(), app.RegisterCodespace(slashing.DefaultCodespace))
|
||||
|
||||
// register message routes
|
||||
app.Router().
|
||||
AddRoute("bank", bank.NewHandler(app.coinKeeper)).
|
||||
AddRoute("ibc", ibc.NewHandler(app.ibcMapper, app.coinKeeper)).
|
||||
AddRoute("bank", bank.NewHandler(app.bankKeeper)).
|
||||
AddRoute("ibc", ibc.NewHandler(app.ibcMapper, app.bankKeeper)).
|
||||
AddRoute("stake", stake.NewHandler(app.stakeKeeper))
|
||||
|
||||
// initialize BaseApp
|
||||
|
|
|
@ -285,7 +285,7 @@ it can't increment sequence numbers, change PubKeys, or otherwise.
|
|||
A `bank.Keeper` is easily instantiated from an `AccountMapper`:
|
||||
|
||||
```go
|
||||
coinKeeper = bank.NewKeeper(accountMapper)
|
||||
bankKeeper = bank.NewKeeper(accountMapper)
|
||||
```
|
||||
|
||||
We can then use it within a handler, instead of working directly with the
|
||||
|
@ -295,7 +295,7 @@ We can then use it within a handler, instead of working directly with the
|
|||
// Finds account with addr in AccountMapper.
|
||||
// Adds coins to account's coin array.
|
||||
// Sets updated account in AccountMapper
|
||||
app.coinKeeper.AddCoins(ctx, addr, coins)
|
||||
app.bankKeeper.AddCoins(ctx, addr, coins)
|
||||
```
|
||||
|
||||
See the [bank.Keeper API
|
||||
|
@ -336,7 +336,7 @@ func NewApp3(logger log.Logger, db dbm.DB) *bapp.BaseApp {
|
|||
|
||||
// Set various mappers/keepers to interact easily with underlying stores
|
||||
accountMapper := auth.NewAccountMapper(cdc, keyAccount, auth.ProtoBaseAccount)
|
||||
coinKeeper := bank.NewKeeper(accountMapper)
|
||||
bankKeeper := bank.NewKeeper(accountMapper)
|
||||
feeKeeper := auth.NewFeeCollectionKeeper(cdc, keyFees)
|
||||
|
||||
app.SetAnteHandler(auth.NewAnteHandler(accountMapper, feeKeeper))
|
||||
|
@ -344,7 +344,7 @@ func NewApp3(logger log.Logger, db dbm.DB) *bapp.BaseApp {
|
|||
// Register message routes.
|
||||
// Note the handler gets access to
|
||||
app.Router().
|
||||
AddRoute("send", bank.NewHandler(coinKeeper))
|
||||
AddRoute("send", bank.NewHandler(bankKeeper))
|
||||
|
||||
// Mount stores and load the latest state.
|
||||
app.MountStoresIAVL(keyAccount, keyFees)
|
||||
|
|
|
@ -31,7 +31,7 @@ func NewApp3(logger log.Logger, db dbm.DB) *bapp.BaseApp {
|
|||
|
||||
// Set various mappers/keepers to interact easily with underlying stores
|
||||
accountMapper := auth.NewAccountMapper(cdc, keyAccount, auth.ProtoBaseAccount)
|
||||
coinKeeper := bank.NewKeeper(accountMapper)
|
||||
bankKeeper := bank.NewKeeper(accountMapper)
|
||||
feeKeeper := auth.NewFeeCollectionKeeper(cdc, keyFees)
|
||||
|
||||
app.SetAnteHandler(auth.NewAnteHandler(accountMapper, feeKeeper))
|
||||
|
@ -39,7 +39,7 @@ func NewApp3(logger log.Logger, db dbm.DB) *bapp.BaseApp {
|
|||
// Register message routes.
|
||||
// Note the handler gets access to
|
||||
app.Router().
|
||||
AddRoute("bank", bank.NewHandler(coinKeeper))
|
||||
AddRoute("bank", bank.NewHandler(bankKeeper))
|
||||
|
||||
// Mount stores and load the latest state.
|
||||
app.MountStoresIAVL(keyAccount, keyFees)
|
||||
|
|
|
@ -29,7 +29,7 @@ func NewApp4(logger log.Logger, db dbm.DB) *bapp.BaseApp {
|
|||
|
||||
// Set various mappers/keepers to interact easily with underlying stores
|
||||
accountMapper := auth.NewAccountMapper(cdc, keyAccount, auth.ProtoBaseAccount)
|
||||
coinKeeper := bank.NewKeeper(accountMapper)
|
||||
bankKeeper := bank.NewKeeper(accountMapper)
|
||||
|
||||
// TODO
|
||||
keyFees := sdk.NewKVStoreKey("fee")
|
||||
|
@ -43,7 +43,7 @@ func NewApp4(logger log.Logger, db dbm.DB) *bapp.BaseApp {
|
|||
// Register message routes.
|
||||
// Note the handler gets access to the account store.
|
||||
app.Router().
|
||||
AddRoute("bank", bank.NewHandler(coinKeeper))
|
||||
AddRoute("bank", bank.NewHandler(bankKeeper))
|
||||
|
||||
// Mount stores and load the latest state.
|
||||
app.MountStoresIAVL(keyAccount, keyFees)
|
||||
|
|
|
@ -33,16 +33,16 @@ var cdc = MakeCodec()
|
|||
- Instantiate the keepers. Note that keepers generally need access to other module's keepers. In this case, make sure you only pass an instance of the keeper for the functionality that is needed. If a keeper only needs to read in another module's store, a read-only keeper should be passed to it.
|
||||
|
||||
```go
|
||||
app.coinKeeper = bank.NewKeeper(app.accountMapper)
|
||||
app.stakeKeeper = simplestake.NewKeeper(app.capKeyStakingStore, app.coinKeeper,app.RegisterCodespace(simplestake.DefaultCodespace))
|
||||
app.simpleGovKeeper = simpleGov.NewKeeper(app.capKeySimpleGovStore, app.coinKeeper, app.stakeKeeper, app.RegisterCodespace(simpleGov.DefaultCodespace))
|
||||
app.bankKeeper = bank.NewKeeper(app.accountMapper)
|
||||
app.stakeKeeper = simplestake.NewKeeper(app.capKeyStakingStore, app.bankKeeper,app.RegisterCodespace(simplestake.DefaultCodespace))
|
||||
app.simpleGovKeeper = simpleGov.NewKeeper(app.capKeySimpleGovStore, app.bankKeeper, app.stakeKeeper, app.RegisterCodespace(simpleGov.DefaultCodespace))
|
||||
```
|
||||
|
||||
- Declare the handlers.
|
||||
|
||||
```go
|
||||
app.Router().
|
||||
AddRoute("bank", bank.NewHandler(app.coinKeeper)).
|
||||
AddRoute("bank", bank.NewHandler(app.bankKeeper)).
|
||||
AddRoute("simplestake", simplestake.NewHandler(app.stakeKeeper)).
|
||||
AddRoute("simpleGov", simpleGov.NewHandler(app.simpleGovKeeper))
|
||||
```
|
||||
|
|
|
@ -38,7 +38,7 @@ type SimpleGovApp struct {
|
|||
|
||||
// keepers
|
||||
feeCollectionKeeper auth.FeeCollectionKeeper
|
||||
coinKeeper bank.Keeper
|
||||
bankKeeper bank.Keeper
|
||||
stakeKeeper simplestake.Keeper
|
||||
simpleGovKeeper simpleGov.Keeper
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ type BasecoinApp struct {
|
|||
// manage getting and setting accounts
|
||||
accountMapper auth.AccountMapper
|
||||
feeCollectionKeeper auth.FeeCollectionKeeper
|
||||
coinKeeper bank.Keeper
|
||||
bankKeeper bank.Keeper
|
||||
ibcMapper ibc.Mapper
|
||||
}
|
||||
|
||||
|
@ -67,13 +67,13 @@ func NewBasecoinApp(logger log.Logger, db dbm.DB, baseAppOptions ...func(*bam.Ba
|
|||
return &types.AppAccount{}
|
||||
},
|
||||
)
|
||||
app.coinKeeper = bank.NewKeeper(app.accountMapper)
|
||||
app.bankKeeper = bank.NewKeeper(app.accountMapper)
|
||||
app.ibcMapper = ibc.NewMapper(app.cdc, app.keyIBC, app.RegisterCodespace(ibc.DefaultCodespace))
|
||||
|
||||
// register message routes
|
||||
app.Router().
|
||||
AddRoute("bank", bank.NewHandler(app.coinKeeper)).
|
||||
AddRoute("ibc", ibc.NewHandler(app.ibcMapper, app.coinKeeper))
|
||||
AddRoute("bank", bank.NewHandler(app.bankKeeper)).
|
||||
AddRoute("ibc", ibc.NewHandler(app.ibcMapper, app.bankKeeper))
|
||||
|
||||
// perform initialization logic
|
||||
app.SetInitChainer(app.initChainer)
|
||||
|
|
|
@ -41,7 +41,7 @@ type DemocoinApp struct {
|
|||
|
||||
// keepers
|
||||
feeCollectionKeeper auth.FeeCollectionKeeper
|
||||
coinKeeper bank.Keeper
|
||||
bankKeeper bank.Keeper
|
||||
coolKeeper cool.Keeper
|
||||
powKeeper pow.Keeper
|
||||
ibcMapper ibc.Mapper
|
||||
|
@ -75,17 +75,17 @@ func NewDemocoinApp(logger log.Logger, db dbm.DB) *DemocoinApp {
|
|||
)
|
||||
|
||||
// Add handlers.
|
||||
app.coinKeeper = bank.NewKeeper(app.accountMapper)
|
||||
app.coolKeeper = cool.NewKeeper(app.capKeyMainStore, app.coinKeeper, app.RegisterCodespace(cool.DefaultCodespace))
|
||||
app.powKeeper = pow.NewKeeper(app.capKeyPowStore, pow.NewConfig("pow", int64(1)), app.coinKeeper, app.RegisterCodespace(pow.DefaultCodespace))
|
||||
app.bankKeeper = bank.NewKeeper(app.accountMapper)
|
||||
app.coolKeeper = cool.NewKeeper(app.capKeyMainStore, app.bankKeeper, app.RegisterCodespace(cool.DefaultCodespace))
|
||||
app.powKeeper = pow.NewKeeper(app.capKeyPowStore, pow.NewConfig("pow", int64(1)), app.bankKeeper, app.RegisterCodespace(pow.DefaultCodespace))
|
||||
app.ibcMapper = ibc.NewMapper(app.cdc, app.capKeyIBCStore, app.RegisterCodespace(ibc.DefaultCodespace))
|
||||
app.stakeKeeper = simplestake.NewKeeper(app.capKeyStakingStore, app.coinKeeper, app.RegisterCodespace(simplestake.DefaultCodespace))
|
||||
app.stakeKeeper = simplestake.NewKeeper(app.capKeyStakingStore, app.bankKeeper, app.RegisterCodespace(simplestake.DefaultCodespace))
|
||||
app.Router().
|
||||
AddRoute("bank", bank.NewHandler(app.coinKeeper)).
|
||||
AddRoute("bank", bank.NewHandler(app.bankKeeper)).
|
||||
AddRoute("cool", cool.NewHandler(app.coolKeeper)).
|
||||
AddRoute("pow", app.powKeeper.Handler).
|
||||
AddRoute("sketchy", sketchy.NewHandler()).
|
||||
AddRoute("ibc", ibc.NewHandler(app.ibcMapper, app.coinKeeper)).
|
||||
AddRoute("ibc", ibc.NewHandler(app.ibcMapper, app.bankKeeper)).
|
||||
AddRoute("simplestake", simplestake.NewHandler(app.stakeKeeper))
|
||||
|
||||
// Initialize BaseApp.
|
||||
|
|
|
@ -49,8 +49,8 @@ func getMockApp(t *testing.T) *mock.App {
|
|||
|
||||
RegisterWire(mapp.Cdc)
|
||||
keyCool := sdk.NewKVStoreKey("cool")
|
||||
coinKeeper := bank.NewKeeper(mapp.AccountMapper)
|
||||
keeper := NewKeeper(keyCool, coinKeeper, mapp.RegisterCodespace(DefaultCodespace))
|
||||
bankKeeper := bank.NewKeeper(mapp.AccountMapper)
|
||||
keeper := NewKeeper(keyCool, bankKeeper, mapp.RegisterCodespace(DefaultCodespace))
|
||||
mapp.Router().AddRoute("cool", NewHandler(keeper))
|
||||
|
||||
mapp.SetInitChainer(getInitChainer(mapp, keeper, "ice-cold"))
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
|
||||
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||
)
|
||||
|
||||
// QuizTxCmd invokes the coolness quiz transaction.
|
||||
|
@ -21,7 +21,7 @@ func QuizTxCmd(cdc *wire.Codec) *cobra.Command {
|
|||
Short: "What's cooler than being cool?",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
txCtx := authctx.NewTxContextFromCLI().WithCodec(cdc)
|
||||
txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
|
||||
cliCtx := context.NewCLIContext().
|
||||
WithCodec(cdc).
|
||||
WithLogger(os.Stdout).
|
||||
|
@ -34,7 +34,7 @@ func QuizTxCmd(cdc *wire.Codec) *cobra.Command {
|
|||
|
||||
msg := cool.NewMsgQuiz(from, args[0])
|
||||
|
||||
return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ func SetTrendTxCmd(cdc *wire.Codec) *cobra.Command {
|
|||
Short: "You're so cool, tell us what is cool!",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
txCtx := authctx.NewTxContextFromCLI().WithCodec(cdc)
|
||||
txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
|
||||
cliCtx := context.NewCLIContext().
|
||||
WithCodec(cdc).
|
||||
WithLogger(os.Stdout).
|
||||
|
@ -59,7 +59,7 @@ func SetTrendTxCmd(cdc *wire.Codec) *cobra.Command {
|
|||
|
||||
msg := cool.NewMsgSetTrend(from, args[0])
|
||||
|
||||
return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,9 +25,9 @@ func getMockApp(t *testing.T) *mock.App {
|
|||
|
||||
RegisterWire(mapp.Cdc)
|
||||
keyPOW := sdk.NewKVStoreKey("pow")
|
||||
coinKeeper := bank.NewKeeper(mapp.AccountMapper)
|
||||
bankKeeper := bank.NewKeeper(mapp.AccountMapper)
|
||||
config := Config{"pow", 1}
|
||||
keeper := NewKeeper(keyPOW, config, coinKeeper, mapp.RegisterCodespace(DefaultCodespace))
|
||||
keeper := NewKeeper(keyPOW, config, bankKeeper, mapp.RegisterCodespace(DefaultCodespace))
|
||||
mapp.Router().AddRoute("pow", keeper.Handler)
|
||||
|
||||
mapp.SetInitChainer(getInitChainer(mapp, keeper))
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
|
||||
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
@ -22,7 +22,7 @@ func MineCmd(cdc *wire.Codec) *cobra.Command {
|
|||
Short: "Mine some coins with proof-of-work!",
|
||||
Args: cobra.ExactArgs(4),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
txCtx := authctx.NewTxContextFromCLI().WithCodec(cdc)
|
||||
txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
|
||||
cliCtx := context.NewCLIContext().
|
||||
WithCodec(cdc).
|
||||
WithLogger(os.Stdout).
|
||||
|
@ -53,7 +53,7 @@ func MineCmd(cdc *wire.Codec) *cobra.Command {
|
|||
|
||||
// Build and sign the transaction, then broadcast to a Tendermint
|
||||
// node.
|
||||
return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
|
||||
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
@ -30,7 +30,7 @@ func BondTxCmd(cdc *wire.Codec) *cobra.Command {
|
|||
Use: "bond",
|
||||
Short: "Bond to a validator",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
txCtx := authctx.NewTxContextFromCLI().WithCodec(cdc)
|
||||
txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
|
||||
cliCtx := context.NewCLIContext().
|
||||
WithCodec(cdc).
|
||||
WithLogger(os.Stdout).
|
||||
|
@ -68,7 +68,7 @@ func BondTxCmd(cdc *wire.Codec) *cobra.Command {
|
|||
|
||||
// Build and sign the transaction, then broadcast to a Tendermint
|
||||
// node.
|
||||
return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ func UnbondTxCmd(cdc *wire.Codec) *cobra.Command {
|
|||
Use: "unbond",
|
||||
Short: "Unbond from a validator",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
txCtx := authctx.NewTxContextFromCLI().WithCodec(cdc)
|
||||
txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
|
||||
cliCtx := context.NewCLIContext().
|
||||
WithCodec(cdc).
|
||||
WithLogger(os.Stdout)
|
||||
|
@ -98,7 +98,7 @@ func UnbondTxCmd(cdc *wire.Codec) *cobra.Command {
|
|||
|
||||
// Build and sign the transaction, then broadcast to a Tendermint
|
||||
// node.
|
||||
return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -21,13 +21,13 @@ type Keeper struct {
|
|||
codespace sdk.CodespaceType
|
||||
}
|
||||
|
||||
func NewKeeper(key sdk.StoreKey, coinKeeper bank.Keeper, codespace sdk.CodespaceType) Keeper {
|
||||
func NewKeeper(key sdk.StoreKey, bankKeeper bank.Keeper, codespace sdk.CodespaceType) Keeper {
|
||||
cdc := wire.NewCodec()
|
||||
wire.RegisterCrypto(cdc)
|
||||
return Keeper{
|
||||
key: key,
|
||||
cdc: cdc,
|
||||
ck: coinKeeper,
|
||||
ck: bankKeeper,
|
||||
codespace: codespace,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,8 +66,8 @@ func TestBonding(t *testing.T) {
|
|||
ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger())
|
||||
|
||||
accountMapper := auth.NewAccountMapper(cdc, authKey, auth.ProtoBaseAccount)
|
||||
coinKeeper := bank.NewKeeper(accountMapper)
|
||||
stakeKeeper := NewKeeper(capKey, coinKeeper, DefaultCodespace)
|
||||
bankKeeper := bank.NewKeeper(accountMapper)
|
||||
stakeKeeper := NewKeeper(capKey, bankKeeper, DefaultCodespace)
|
||||
addr := sdk.AccAddress([]byte("some-address"))
|
||||
privKey := ed25519.GenPrivKey()
|
||||
pubKey := privKey.PubKey()
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/client/utils"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
|
||||
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||
"github.com/spf13/cobra"
|
||||
amino "github.com/tendermint/go-amino"
|
||||
)
|
||||
|
@ -51,9 +51,9 @@ func makeSignCmd(cdc *amino.Codec, decoder auth.AccountDecoder) func(cmd *cobra.
|
|||
|
||||
name := viper.GetString(client.FlagName)
|
||||
cliCtx := context.NewCLIContext().WithCodec(cdc).WithAccountDecoder(decoder)
|
||||
txCtx := authctx.NewTxContextFromCLI()
|
||||
txBldr := authtxb.NewTxBuilderFromCLI()
|
||||
|
||||
newTx, err := utils.SignStdTx(txCtx, cliCtx, name, stdTx, viper.GetBool(flagAppend))
|
||||
newTx, err := utils.SignStdTx(txBldr, cliCtx, name, stdTx, viper.GetBool(flagAppend))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/client/utils"
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
|
||||
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||
)
|
||||
|
||||
// SignBody defines the properties of a sign request's body.
|
||||
|
@ -39,13 +39,13 @@ func SignTxRequestHandlerFn(cdc *wire.Codec, cliCtx context.CLIContext) http.Han
|
|||
return
|
||||
}
|
||||
|
||||
txCtx := authctx.TxContext{
|
||||
txBldr := authtxb.TxBuilder{
|
||||
ChainID: m.ChainID,
|
||||
AccountNumber: m.AccountNumber,
|
||||
Sequence: m.Sequence,
|
||||
}
|
||||
|
||||
signedTx, err := txCtx.SignStdTx(m.LocalAccountName, m.Password, m.Tx, m.AppendSig)
|
||||
signedTx, err := txBldr.SignStdTx(m.LocalAccountName, m.Password, m.Tx, m.AppendSig)
|
||||
if err != nil {
|
||||
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
|
|
|
@ -11,8 +11,8 @@ import (
|
|||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
// TxContext implements a transaction context created in SDK modules.
|
||||
type TxContext struct {
|
||||
// TxBuilder implements a transaction context created in SDK modules.
|
||||
type TxBuilder struct {
|
||||
Codec *wire.Codec
|
||||
AccountNumber int64
|
||||
Sequence int64
|
||||
|
@ -22,9 +22,9 @@ type TxContext struct {
|
|||
Fee string
|
||||
}
|
||||
|
||||
// NewTxContextFromCLI returns a new initialized TxContext with parameters from
|
||||
// NewTxBuilderFromCLI returns a new initialized TxBuilder with parameters from
|
||||
// the command line using Viper.
|
||||
func NewTxContextFromCLI() TxContext {
|
||||
func NewTxBuilderFromCLI() TxBuilder {
|
||||
// if chain ID is not specified manually, read default chain ID
|
||||
chainID := viper.GetString(client.FlagChainID)
|
||||
if chainID == "" {
|
||||
|
@ -34,7 +34,7 @@ func NewTxContextFromCLI() TxContext {
|
|||
}
|
||||
}
|
||||
|
||||
return TxContext{
|
||||
return TxBuilder{
|
||||
ChainID: chainID,
|
||||
Gas: viper.GetInt64(client.FlagGas),
|
||||
AccountNumber: viper.GetInt64(client.FlagAccountNumber),
|
||||
|
@ -45,58 +45,58 @@ func NewTxContextFromCLI() TxContext {
|
|||
}
|
||||
|
||||
// WithCodec returns a copy of the context with an updated codec.
|
||||
func (ctx TxContext) WithCodec(cdc *wire.Codec) TxContext {
|
||||
ctx.Codec = cdc
|
||||
return ctx
|
||||
func (bldr TxBuilder) WithCodec(cdc *wire.Codec) TxBuilder {
|
||||
bldr.Codec = cdc
|
||||
return bldr
|
||||
}
|
||||
|
||||
// WithChainID returns a copy of the context with an updated chainID.
|
||||
func (ctx TxContext) WithChainID(chainID string) TxContext {
|
||||
ctx.ChainID = chainID
|
||||
return ctx
|
||||
func (bldr TxBuilder) WithChainID(chainID string) TxBuilder {
|
||||
bldr.ChainID = chainID
|
||||
return bldr
|
||||
}
|
||||
|
||||
// WithGas returns a copy of the context with an updated gas.
|
||||
func (ctx TxContext) WithGas(gas int64) TxContext {
|
||||
ctx.Gas = gas
|
||||
return ctx
|
||||
func (bldr TxBuilder) WithGas(gas int64) TxBuilder {
|
||||
bldr.Gas = gas
|
||||
return bldr
|
||||
}
|
||||
|
||||
// WithFee returns a copy of the context with an updated fee.
|
||||
func (ctx TxContext) WithFee(fee string) TxContext {
|
||||
ctx.Fee = fee
|
||||
return ctx
|
||||
func (bldr TxBuilder) WithFee(fee string) TxBuilder {
|
||||
bldr.Fee = fee
|
||||
return bldr
|
||||
}
|
||||
|
||||
// WithSequence returns a copy of the context with an updated sequence number.
|
||||
func (ctx TxContext) WithSequence(sequence int64) TxContext {
|
||||
ctx.Sequence = sequence
|
||||
return ctx
|
||||
func (bldr TxBuilder) WithSequence(sequence int64) TxBuilder {
|
||||
bldr.Sequence = sequence
|
||||
return bldr
|
||||
}
|
||||
|
||||
// WithMemo returns a copy of the context with an updated memo.
|
||||
func (ctx TxContext) WithMemo(memo string) TxContext {
|
||||
ctx.Memo = memo
|
||||
return ctx
|
||||
func (bldr TxBuilder) WithMemo(memo string) TxBuilder {
|
||||
bldr.Memo = memo
|
||||
return bldr
|
||||
}
|
||||
|
||||
// WithAccountNumber returns a copy of the context with an account number.
|
||||
func (ctx TxContext) WithAccountNumber(accnum int64) TxContext {
|
||||
ctx.AccountNumber = accnum
|
||||
return ctx
|
||||
func (bldr TxBuilder) WithAccountNumber(accnum int64) TxBuilder {
|
||||
bldr.AccountNumber = accnum
|
||||
return bldr
|
||||
}
|
||||
|
||||
// Build builds a single message to be signed from a TxContext given a set of
|
||||
// Build builds a single message to be signed from a TxBuilder given a set of
|
||||
// messages. It returns an error if a fee is supplied but cannot be parsed.
|
||||
func (ctx TxContext) Build(msgs []sdk.Msg) (auth.StdSignMsg, error) {
|
||||
chainID := ctx.ChainID
|
||||
func (bldr TxBuilder) Build(msgs []sdk.Msg) (auth.StdSignMsg, error) {
|
||||
chainID := bldr.ChainID
|
||||
if chainID == "" {
|
||||
return auth.StdSignMsg{}, errors.Errorf("chain ID required but not specified")
|
||||
}
|
||||
|
||||
fee := sdk.Coin{}
|
||||
if ctx.Fee != "" {
|
||||
parsedFee, err := sdk.ParseCoin(ctx.Fee)
|
||||
if bldr.Fee != "" {
|
||||
parsedFee, err := sdk.ParseCoin(bldr.Fee)
|
||||
if err != nil {
|
||||
return auth.StdSignMsg{}, err
|
||||
}
|
||||
|
@ -105,43 +105,43 @@ func (ctx TxContext) Build(msgs []sdk.Msg) (auth.StdSignMsg, error) {
|
|||
}
|
||||
|
||||
return auth.StdSignMsg{
|
||||
ChainID: ctx.ChainID,
|
||||
AccountNumber: ctx.AccountNumber,
|
||||
Sequence: ctx.Sequence,
|
||||
Memo: ctx.Memo,
|
||||
ChainID: bldr.ChainID,
|
||||
AccountNumber: bldr.AccountNumber,
|
||||
Sequence: bldr.Sequence,
|
||||
Memo: bldr.Memo,
|
||||
Msgs: msgs,
|
||||
Fee: auth.NewStdFee(ctx.Gas, fee),
|
||||
Fee: auth.NewStdFee(bldr.Gas, fee),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Sign signs a transaction given a name, passphrase, and a single message to
|
||||
// signed. An error is returned if signing fails.
|
||||
func (ctx TxContext) Sign(name, passphrase string, msg auth.StdSignMsg) ([]byte, error) {
|
||||
func (bldr TxBuilder) Sign(name, passphrase string, msg auth.StdSignMsg) ([]byte, error) {
|
||||
sig, err := MakeSignature(name, passphrase, msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ctx.Codec.MarshalBinary(auth.NewStdTx(msg.Msgs, msg.Fee, []auth.StdSignature{sig}, msg.Memo))
|
||||
return bldr.Codec.MarshalBinary(auth.NewStdTx(msg.Msgs, msg.Fee, []auth.StdSignature{sig}, msg.Memo))
|
||||
}
|
||||
|
||||
// BuildAndSign builds a single message to be signed, and signs a transaction
|
||||
// with the built message given a name, passphrase, and a set of
|
||||
// messages.
|
||||
func (ctx TxContext) BuildAndSign(name, passphrase string, msgs []sdk.Msg) ([]byte, error) {
|
||||
msg, err := ctx.Build(msgs)
|
||||
func (bldr TxBuilder) BuildAndSign(name, passphrase string, msgs []sdk.Msg) ([]byte, error) {
|
||||
msg, err := bldr.Build(msgs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return ctx.Sign(name, passphrase, msg)
|
||||
return bldr.Sign(name, passphrase, msg)
|
||||
}
|
||||
|
||||
// BuildWithPubKey builds a single message to be signed from a TxContext given a set of
|
||||
// BuildWithPubKey builds a single message to be signed from a TxBuilder given a set of
|
||||
// messages and attach the public key associated to the given name.
|
||||
// It returns an error if a fee is supplied but cannot be parsed or the key cannot be
|
||||
// retrieved.
|
||||
func (ctx TxContext) BuildWithPubKey(name string, msgs []sdk.Msg) ([]byte, error) {
|
||||
msg, err := ctx.Build(msgs)
|
||||
func (bldr TxBuilder) BuildWithPubKey(name string, msgs []sdk.Msg) ([]byte, error) {
|
||||
msg, err := bldr.Build(msgs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -162,16 +162,16 @@ func (ctx TxContext) BuildWithPubKey(name string, msgs []sdk.Msg) ([]byte, error
|
|||
PubKey: info.GetPubKey(),
|
||||
}}
|
||||
|
||||
return ctx.Codec.MarshalBinary(auth.NewStdTx(msg.Msgs, msg.Fee, sigs, msg.Memo))
|
||||
return bldr.Codec.MarshalBinary(auth.NewStdTx(msg.Msgs, msg.Fee, sigs, msg.Memo))
|
||||
}
|
||||
|
||||
// SignStdTx appends a signature to a StdTx and returns a copy of a it. If append
|
||||
// is false, it replaces the signatures already attached with the new signature.
|
||||
func (ctx TxContext) SignStdTx(name, passphrase string, stdTx auth.StdTx, appendSig bool) (signedStdTx auth.StdTx, err error) {
|
||||
func (bldr TxBuilder) SignStdTx(name, passphrase string, stdTx auth.StdTx, appendSig bool) (signedStdTx auth.StdTx, err error) {
|
||||
stdSignature, err := MakeSignature(name, passphrase, auth.StdSignMsg{
|
||||
ChainID: ctx.ChainID,
|
||||
AccountNumber: ctx.AccountNumber,
|
||||
Sequence: ctx.Sequence,
|
||||
ChainID: bldr.ChainID,
|
||||
AccountNumber: bldr.AccountNumber,
|
||||
Sequence: bldr.Sequence,
|
||||
Fee: stdTx.Fee,
|
||||
Msgs: stdTx.GetMsgs(),
|
||||
Memo: stdTx.GetMemo(),
|
|
@ -16,8 +16,8 @@ func getBenchmarkMockApp() (*mock.App, error) {
|
|||
mapp := mock.NewApp()
|
||||
|
||||
RegisterWire(mapp.Cdc)
|
||||
coinKeeper := NewKeeper(mapp.AccountMapper)
|
||||
mapp.Router().AddRoute("bank", NewHandler(coinKeeper))
|
||||
bankKeeper := NewKeeper(mapp.AccountMapper)
|
||||
mapp.Router().AddRoute("bank", NewHandler(bankKeeper))
|
||||
|
||||
err := mapp.CompleteSetup([]*sdk.KVStoreKey{})
|
||||
return mapp, err
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
|
||||
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/client"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
@ -27,7 +27,7 @@ func SendTxCmd(cdc *wire.Codec) *cobra.Command {
|
|||
Use: "send",
|
||||
Short: "Create and sign a send tx",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
txCtx := authctx.NewTxContextFromCLI().WithCodec(cdc)
|
||||
txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
|
||||
cliCtx := context.NewCLIContext().
|
||||
WithCodec(cdc).
|
||||
WithLogger(os.Stdout).
|
||||
|
@ -69,10 +69,10 @@ func SendTxCmd(cdc *wire.Codec) *cobra.Command {
|
|||
// build and sign the transaction, then broadcast to Tendermint
|
||||
msg := client.BuildMsg(from, to, coins)
|
||||
if cliCtx.GenerateOnly {
|
||||
return utils.PrintUnsignedStdTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
}
|
||||
|
||||
return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/crypto/keys"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
|
||||
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/client"
|
||||
|
||||
|
@ -80,7 +80,7 @@ func SendRequestHandlerFn(cdc *wire.Codec, kb keys.Keybase, cliCtx context.CLICo
|
|||
return
|
||||
}
|
||||
|
||||
txCtx := authctx.TxContext{
|
||||
txBldr := authtxb.TxBuilder{
|
||||
Codec: cdc,
|
||||
Gas: m.Gas,
|
||||
ChainID: m.ChainID,
|
||||
|
@ -95,24 +95,24 @@ func SendRequestHandlerFn(cdc *wire.Codec, kb keys.Keybase, cliCtx context.CLICo
|
|||
cliCtx = cliCtx.WithGasAdjustment(adjustment)
|
||||
|
||||
if utils.HasDryRunArg(r) || m.Gas == 0 {
|
||||
newCtx, err := utils.EnrichCtxWithGas(txCtx, cliCtx, m.LocalAccountName, []sdk.Msg{msg})
|
||||
newCtx, err := utils.EnrichCtxWithGas(txBldr, cliCtx, m.LocalAccountName, []sdk.Msg{msg})
|
||||
if err != nil {
|
||||
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
if utils.HasDryRunArg(r) {
|
||||
utils.WriteSimulationResponse(w, txCtx.Gas)
|
||||
utils.WriteSimulationResponse(w, txBldr.Gas)
|
||||
return
|
||||
}
|
||||
txCtx = newCtx
|
||||
txBldr = newCtx
|
||||
}
|
||||
|
||||
if utils.HasGenerateOnlyArg(r) {
|
||||
utils.WriteGenerateStdTxResponse(w, txCtx, []sdk.Msg{msg})
|
||||
utils.WriteGenerateStdTxResponse(w, txBldr, []sdk.Msg{msg})
|
||||
return
|
||||
}
|
||||
|
||||
txBytes, err := txCtx.BuildAndSign(m.LocalAccountName, m.Password, []sdk.Msg{msg})
|
||||
txBytes, err := txBldr.BuildAndSign(m.LocalAccountName, m.Password, []sdk.Msg{msg})
|
||||
if err != nil {
|
||||
utils.WriteErrorResponse(w, http.StatusUnauthorized, err.Error())
|
||||
return
|
||||
|
|
|
@ -34,7 +34,7 @@ func TestKeeper(t *testing.T) {
|
|||
|
||||
ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger())
|
||||
accountMapper := auth.NewAccountMapper(cdc, authKey, auth.ProtoBaseAccount)
|
||||
coinKeeper := NewKeeper(accountMapper)
|
||||
bankKeeper := NewKeeper(accountMapper)
|
||||
|
||||
addr := sdk.AccAddress([]byte("addr1"))
|
||||
addr2 := sdk.AccAddress([]byte("addr2"))
|
||||
|
@ -43,57 +43,57 @@ func TestKeeper(t *testing.T) {
|
|||
|
||||
// Test GetCoins/SetCoins
|
||||
accountMapper.SetAccount(ctx, acc)
|
||||
require.True(t, coinKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{}))
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{}))
|
||||
|
||||
coinKeeper.SetCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)})
|
||||
require.True(t, coinKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
|
||||
bankKeeper.SetCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)})
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
|
||||
|
||||
// Test HasCoins
|
||||
require.True(t, coinKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
|
||||
require.True(t, coinKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 5)}))
|
||||
require.False(t, coinKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 15)}))
|
||||
require.False(t, coinKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 5)}))
|
||||
require.True(t, bankKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
|
||||
require.True(t, bankKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 5)}))
|
||||
require.False(t, bankKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 15)}))
|
||||
require.False(t, bankKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 5)}))
|
||||
|
||||
// Test AddCoins
|
||||
coinKeeper.AddCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 15)})
|
||||
require.True(t, coinKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 25)}))
|
||||
bankKeeper.AddCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 15)})
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 25)}))
|
||||
|
||||
coinKeeper.AddCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 15)})
|
||||
require.True(t, coinKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 15), sdk.NewInt64Coin("foocoin", 25)}))
|
||||
bankKeeper.AddCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 15)})
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 15), sdk.NewInt64Coin("foocoin", 25)}))
|
||||
|
||||
// Test SubtractCoins
|
||||
coinKeeper.SubtractCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)})
|
||||
coinKeeper.SubtractCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 5)})
|
||||
require.True(t, coinKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 15)}))
|
||||
bankKeeper.SubtractCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)})
|
||||
bankKeeper.SubtractCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 5)})
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 15)}))
|
||||
|
||||
coinKeeper.SubtractCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 11)})
|
||||
require.True(t, coinKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 15)}))
|
||||
bankKeeper.SubtractCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 11)})
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 15)}))
|
||||
|
||||
coinKeeper.SubtractCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 10)})
|
||||
require.True(t, coinKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 15)}))
|
||||
require.False(t, coinKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 1)}))
|
||||
bankKeeper.SubtractCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 10)})
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 15)}))
|
||||
require.False(t, bankKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 1)}))
|
||||
|
||||
// Test SendCoins
|
||||
coinKeeper.SendCoins(ctx, addr, addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 5)})
|
||||
require.True(t, coinKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
|
||||
require.True(t, coinKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 5)}))
|
||||
bankKeeper.SendCoins(ctx, addr, addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 5)})
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 5)}))
|
||||
|
||||
_, err2 := coinKeeper.SendCoins(ctx, addr, addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 50)})
|
||||
_, err2 := bankKeeper.SendCoins(ctx, addr, addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 50)})
|
||||
assert.Implements(t, (*sdk.Error)(nil), err2)
|
||||
require.True(t, coinKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
|
||||
require.True(t, coinKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 5)}))
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 5)}))
|
||||
|
||||
coinKeeper.AddCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 30)})
|
||||
coinKeeper.SendCoins(ctx, addr, addr2, sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 5)})
|
||||
require.True(t, coinKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 20), sdk.NewInt64Coin("foocoin", 5)}))
|
||||
require.True(t, coinKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 10)}))
|
||||
bankKeeper.AddCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 30)})
|
||||
bankKeeper.SendCoins(ctx, addr, addr2, sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 5)})
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 20), sdk.NewInt64Coin("foocoin", 5)}))
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 10)}))
|
||||
|
||||
// Test InputOutputCoins
|
||||
input1 := NewInput(addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 2)})
|
||||
output1 := NewOutput(addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 2)})
|
||||
coinKeeper.InputOutputCoins(ctx, []Input{input1}, []Output{output1})
|
||||
require.True(t, coinKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 20), sdk.NewInt64Coin("foocoin", 7)}))
|
||||
require.True(t, coinKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 8)}))
|
||||
bankKeeper.InputOutputCoins(ctx, []Input{input1}, []Output{output1})
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 20), sdk.NewInt64Coin("foocoin", 7)}))
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 8)}))
|
||||
|
||||
inputs := []Input{
|
||||
NewInput(addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 3)}),
|
||||
|
@ -104,10 +104,10 @@ func TestKeeper(t *testing.T) {
|
|||
NewOutput(addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 1)}),
|
||||
NewOutput(addr3, sdk.Coins{sdk.NewInt64Coin("barcoin", 2), sdk.NewInt64Coin("foocoin", 5)}),
|
||||
}
|
||||
coinKeeper.InputOutputCoins(ctx, inputs, outputs)
|
||||
require.True(t, coinKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 21), sdk.NewInt64Coin("foocoin", 4)}))
|
||||
require.True(t, coinKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 7), sdk.NewInt64Coin("foocoin", 6)}))
|
||||
require.True(t, coinKeeper.GetCoins(ctx, addr3).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 2), sdk.NewInt64Coin("foocoin", 5)}))
|
||||
bankKeeper.InputOutputCoins(ctx, inputs, outputs)
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 21), sdk.NewInt64Coin("foocoin", 4)}))
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 7), sdk.NewInt64Coin("foocoin", 6)}))
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr3).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 2), sdk.NewInt64Coin("foocoin", 5)}))
|
||||
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ func TestSendKeeper(t *testing.T) {
|
|||
|
||||
ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger())
|
||||
accountMapper := auth.NewAccountMapper(cdc, authKey, auth.ProtoBaseAccount)
|
||||
coinKeeper := NewKeeper(accountMapper)
|
||||
bankKeeper := NewKeeper(accountMapper)
|
||||
sendKeeper := NewSendKeeper(accountMapper)
|
||||
|
||||
addr := sdk.AccAddress([]byte("addr1"))
|
||||
|
@ -131,7 +131,7 @@ func TestSendKeeper(t *testing.T) {
|
|||
accountMapper.SetAccount(ctx, acc)
|
||||
require.True(t, sendKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{}))
|
||||
|
||||
coinKeeper.SetCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)})
|
||||
bankKeeper.SetCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)})
|
||||
require.True(t, sendKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
|
||||
|
||||
// Test HasCoins
|
||||
|
@ -140,7 +140,7 @@ func TestSendKeeper(t *testing.T) {
|
|||
require.False(t, sendKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 15)}))
|
||||
require.False(t, sendKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 5)}))
|
||||
|
||||
coinKeeper.SetCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 15)})
|
||||
bankKeeper.SetCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 15)})
|
||||
|
||||
// Test SendCoins
|
||||
sendKeeper.SendCoins(ctx, addr, addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 5)})
|
||||
|
@ -152,7 +152,7 @@ func TestSendKeeper(t *testing.T) {
|
|||
require.True(t, sendKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
|
||||
require.True(t, sendKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 5)}))
|
||||
|
||||
coinKeeper.AddCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 30)})
|
||||
bankKeeper.AddCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 30)})
|
||||
sendKeeper.SendCoins(ctx, addr, addr2, sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 5)})
|
||||
require.True(t, sendKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 20), sdk.NewInt64Coin("foocoin", 5)}))
|
||||
require.True(t, sendKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 10)}))
|
||||
|
@ -188,7 +188,7 @@ func TestViewKeeper(t *testing.T) {
|
|||
|
||||
ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger())
|
||||
accountMapper := auth.NewAccountMapper(cdc, authKey, auth.ProtoBaseAccount)
|
||||
coinKeeper := NewKeeper(accountMapper)
|
||||
bankKeeper := NewKeeper(accountMapper)
|
||||
viewKeeper := NewViewKeeper(accountMapper)
|
||||
|
||||
addr := sdk.AccAddress([]byte("addr1"))
|
||||
|
@ -198,7 +198,7 @@ func TestViewKeeper(t *testing.T) {
|
|||
accountMapper.SetAccount(ctx, acc)
|
||||
require.True(t, viewKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{}))
|
||||
|
||||
coinKeeper.SetCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)})
|
||||
bankKeeper.SetCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)})
|
||||
require.True(t, viewKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
|
||||
|
||||
// Test HasCoins
|
||||
|
|
|
@ -18,8 +18,8 @@ func TestBankWithRandomMessages(t *testing.T) {
|
|||
|
||||
bank.RegisterWire(mapp.Cdc)
|
||||
mapper := mapp.AccountMapper
|
||||
coinKeeper := bank.NewKeeper(mapper)
|
||||
mapp.Router().AddRoute("bank", bank.NewHandler(coinKeeper))
|
||||
bankKeeper := bank.NewKeeper(mapper)
|
||||
mapp.Router().AddRoute("bank", bank.NewHandler(bankKeeper))
|
||||
|
||||
err := mapp.CompleteSetup([]*sdk.KVStoreKey{})
|
||||
if err != nil {
|
||||
|
|
|
@ -4,7 +4,7 @@ package stake
|
|||
//type Keeper struct {
|
||||
//storeKey sdk.StoreKey
|
||||
//cdc *wire.Codec
|
||||
//coinKeeper bank.Keeper
|
||||
//bankKeeper bank.Keeper
|
||||
|
||||
//// codespace
|
||||
//codespace sdk.CodespaceType
|
||||
|
@ -14,7 +14,7 @@ package stake
|
|||
//keeper := Keeper{
|
||||
//storeKey: key,
|
||||
//cdc: cdc,
|
||||
//coinKeeper: ck,
|
||||
//bankKeeper: ck,
|
||||
//codespace: codespace,
|
||||
//}
|
||||
//return keeper
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
|
||||
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov"
|
||||
|
||||
"encoding/json"
|
||||
|
@ -77,7 +77,7 @@ $ gaiacli gov submit-proposal --title="Test Proposal" --description="My awesome
|
|||
return err
|
||||
}
|
||||
|
||||
txCtx := authctx.NewTxContextFromCLI().WithCodec(cdc)
|
||||
txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
|
||||
cliCtx := context.NewCLIContext().
|
||||
WithCodec(cdc).
|
||||
WithLogger(os.Stdout).
|
||||
|
@ -105,13 +105,13 @@ $ gaiacli gov submit-proposal --title="Test Proposal" --description="My awesome
|
|||
}
|
||||
|
||||
if cliCtx.GenerateOnly {
|
||||
return utils.PrintUnsignedStdTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
}
|
||||
|
||||
// Build and sign the transaction, then broadcast to Tendermint
|
||||
// proposalID must be returned, and it is a part of response.
|
||||
cliCtx.PrintResponse = true
|
||||
return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ func GetCmdDeposit(cdc *wire.Codec) *cobra.Command {
|
|||
Use: "deposit",
|
||||
Short: "deposit tokens for activing proposal",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
txCtx := authctx.NewTxContextFromCLI().WithCodec(cdc)
|
||||
txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
|
||||
cliCtx := context.NewCLIContext().
|
||||
WithCodec(cdc).
|
||||
WithLogger(os.Stdout).
|
||||
|
@ -186,12 +186,12 @@ func GetCmdDeposit(cdc *wire.Codec) *cobra.Command {
|
|||
}
|
||||
|
||||
if cliCtx.GenerateOnly {
|
||||
return utils.PrintUnsignedStdTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
}
|
||||
|
||||
// Build and sign the transaction, then broadcast to a Tendermint
|
||||
// node.
|
||||
return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -207,7 +207,7 @@ func GetCmdVote(cdc *wire.Codec) *cobra.Command {
|
|||
Use: "vote",
|
||||
Short: "vote for an active proposal, options: Yes/No/NoWithVeto/Abstain",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
txCtx := authctx.NewTxContextFromCLI().WithCodec(cdc)
|
||||
txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
|
||||
cliCtx := context.NewCLIContext().
|
||||
WithCodec(cdc).
|
||||
WithLogger(os.Stdout).
|
||||
|
@ -233,7 +233,7 @@ func GetCmdVote(cdc *wire.Codec) *cobra.Command {
|
|||
}
|
||||
|
||||
if cliCtx.GenerateOnly {
|
||||
return utils.PrintUnsignedStdTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
}
|
||||
|
||||
fmt.Printf("Vote[Voter:%s,ProposalID:%d,Option:%s]",
|
||||
|
@ -242,7 +242,7 @@ func GetCmdVote(cdc *wire.Codec) *cobra.Command {
|
|||
|
||||
// Build and sign the transaction, then broadcast to a Tendermint
|
||||
// node.
|
||||
return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/client/utils"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
|
||||
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||
)
|
||||
|
||||
type baseReq struct {
|
||||
|
@ -70,7 +70,7 @@ func (req baseReq) baseReqValidate(w http.ResponseWriter) bool {
|
|||
// (probably should live in client/lcd).
|
||||
func signAndBuild(w http.ResponseWriter, r *http.Request, cliCtx context.CLIContext, baseReq baseReq, msg sdk.Msg, cdc *wire.Codec) {
|
||||
var err error
|
||||
txCtx := authctx.TxContext{
|
||||
txBldr := authtxb.TxBuilder{
|
||||
Codec: cdc,
|
||||
AccountNumber: baseReq.AccountNumber,
|
||||
Sequence: baseReq.Sequence,
|
||||
|
@ -85,24 +85,24 @@ func signAndBuild(w http.ResponseWriter, r *http.Request, cliCtx context.CLICont
|
|||
cliCtx = cliCtx.WithGasAdjustment(adjustment)
|
||||
|
||||
if utils.HasDryRunArg(r) || baseReq.Gas == 0 {
|
||||
newCtx, err := utils.EnrichCtxWithGas(txCtx, cliCtx, baseReq.Name, []sdk.Msg{msg})
|
||||
newCtx, err := utils.EnrichCtxWithGas(txBldr, cliCtx, baseReq.Name, []sdk.Msg{msg})
|
||||
if err != nil {
|
||||
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
if utils.HasDryRunArg(r) {
|
||||
utils.WriteSimulationResponse(w, txCtx.Gas)
|
||||
utils.WriteSimulationResponse(w, txBldr.Gas)
|
||||
return
|
||||
}
|
||||
txCtx = newCtx
|
||||
txBldr = newCtx
|
||||
}
|
||||
|
||||
if utils.HasGenerateOnlyArg(r) {
|
||||
utils.WriteGenerateStdTxResponse(w, txCtx, []sdk.Msg{msg})
|
||||
utils.WriteGenerateStdTxResponse(w, txBldr, []sdk.Msg{msg})
|
||||
return
|
||||
}
|
||||
|
||||
txBytes, err := txCtx.BuildAndSign(baseReq.Name, baseReq.Password, []sdk.Msg{msg})
|
||||
txBytes, err := txBldr.BuildAndSign(baseReq.Name, baseReq.Password, []sdk.Msg{msg})
|
||||
if err != nil {
|
||||
utils.WriteErrorResponse(w, http.StatusUnauthorized, err.Error())
|
||||
return
|
||||
|
|
|
@ -151,6 +151,7 @@ func SimulateMsgVote(k gov.Keeper, sk stake.Keeper) simulation.Operation {
|
|||
return operationSimulateMsgVote(k, sk, nil, -1)
|
||||
}
|
||||
|
||||
// nolint: unparam
|
||||
func operationSimulateMsgVote(k gov.Keeper, sk stake.Keeper, key crypto.PrivKey, proposalID int64) simulation.Operation {
|
||||
return func(tb testing.TB, r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, keys []crypto.PrivKey, log string, event func(string)) (action string, fOp []simulation.FutureOperation, err sdk.Error) {
|
||||
if key == nil {
|
||||
|
|
|
@ -24,13 +24,13 @@ func TestGovWithRandomMessages(t *testing.T) {
|
|||
bank.RegisterWire(mapp.Cdc)
|
||||
gov.RegisterWire(mapp.Cdc)
|
||||
mapper := mapp.AccountMapper
|
||||
coinKeeper := bank.NewKeeper(mapper)
|
||||
bankKeeper := bank.NewKeeper(mapper)
|
||||
stakeKey := sdk.NewKVStoreKey("stake")
|
||||
stakeKeeper := stake.NewKeeper(mapp.Cdc, stakeKey, coinKeeper, stake.DefaultCodespace)
|
||||
stakeKeeper := stake.NewKeeper(mapp.Cdc, stakeKey, bankKeeper, stake.DefaultCodespace)
|
||||
paramKey := sdk.NewKVStoreKey("params")
|
||||
paramKeeper := params.NewKeeper(mapp.Cdc, paramKey)
|
||||
govKey := sdk.NewKVStoreKey("gov")
|
||||
govKeeper := gov.NewKeeper(mapp.Cdc, govKey, paramKeeper.Setter(), coinKeeper, stakeKeeper, gov.DefaultCodespace)
|
||||
govKeeper := gov.NewKeeper(mapp.Cdc, govKey, paramKeeper.Setter(), bankKeeper, stakeKeeper, gov.DefaultCodespace)
|
||||
mapp.Router().AddRoute("gov", gov.NewHandler(govKeeper))
|
||||
mapp.SetEndBlocker(func(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
|
||||
gov.EndBlocker(ctx, govKeeper)
|
||||
|
|
|
@ -21,8 +21,8 @@ func getMockApp(t *testing.T) *mock.App {
|
|||
RegisterWire(mapp.Cdc)
|
||||
keyIBC := sdk.NewKVStoreKey("ibc")
|
||||
ibcMapper := NewMapper(mapp.Cdc, keyIBC, mapp.RegisterCodespace(DefaultCodespace))
|
||||
coinKeeper := bank.NewKeeper(mapp.AccountMapper)
|
||||
mapp.Router().AddRoute("ibc", NewHandler(ibcMapper, coinKeeper))
|
||||
bankKeeper := bank.NewKeeper(mapp.AccountMapper)
|
||||
mapp.Router().AddRoute("ibc", NewHandler(ibcMapper, bankKeeper))
|
||||
|
||||
require.NoError(t, mapp.CompleteSetup([]*sdk.KVStoreKey{keyIBC}))
|
||||
return mapp
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
wire "github.com/cosmos/cosmos-sdk/wire"
|
||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
|
||||
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
@ -28,7 +28,7 @@ func IBCTransferCmd(cdc *wire.Codec) *cobra.Command {
|
|||
cmd := &cobra.Command{
|
||||
Use: "transfer",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
txCtx := authctx.NewTxContextFromCLI().WithCodec(cdc)
|
||||
txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
|
||||
cliCtx := context.NewCLIContext().
|
||||
WithCodec(cdc).
|
||||
WithLogger(os.Stdout).
|
||||
|
@ -44,10 +44,10 @@ func IBCTransferCmd(cdc *wire.Codec) *cobra.Command {
|
|||
return err
|
||||
}
|
||||
if cliCtx.GenerateOnly {
|
||||
return utils.PrintUnsignedStdTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
}
|
||||
|
||||
return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
wire "github.com/cosmos/cosmos-sdk/wire"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
|
||||
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
@ -199,10 +199,10 @@ func (c relayCommander) refine(bz []byte, sequence int64, passphrase string) []b
|
|||
Sequence: sequence,
|
||||
}
|
||||
|
||||
txCtx := authctx.NewTxContextFromCLI().WithSequence(sequence).WithCodec(c.cdc)
|
||||
txBldr := authtxb.NewTxBuilderFromCLI().WithSequence(sequence).WithCodec(c.cdc)
|
||||
cliCtx := context.NewCLIContext()
|
||||
|
||||
res, err := txCtx.BuildAndSign(cliCtx.FromAddressName, passphrase, []sdk.Msg{msg})
|
||||
res, err := txBldr.BuildAndSign(cliCtx.FromAddressName, passphrase, []sdk.Msg{msg})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/crypto/keys"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
|
||||
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
@ -71,7 +71,7 @@ func TransferRequestHandlerFn(cdc *wire.Codec, kb keys.Keybase, cliCtx context.C
|
|||
packet := ibc.NewIBCPacket(sdk.AccAddress(info.GetPubKey().Address()), to, m.Amount, m.SrcChainID, destChainID)
|
||||
msg := ibc.IBCTransferMsg{packet}
|
||||
|
||||
txCtx := authctx.TxContext{
|
||||
txBldr := authtxb.TxBuilder{
|
||||
Codec: cdc,
|
||||
ChainID: m.SrcChainID,
|
||||
AccountNumber: m.AccountNumber,
|
||||
|
@ -86,24 +86,24 @@ func TransferRequestHandlerFn(cdc *wire.Codec, kb keys.Keybase, cliCtx context.C
|
|||
cliCtx = cliCtx.WithGasAdjustment(adjustment)
|
||||
|
||||
if utils.HasDryRunArg(r) || m.Gas == 0 {
|
||||
newCtx, err := utils.EnrichCtxWithGas(txCtx, cliCtx, m.LocalAccountName, []sdk.Msg{msg})
|
||||
newCtx, err := utils.EnrichCtxWithGas(txBldr, cliCtx, m.LocalAccountName, []sdk.Msg{msg})
|
||||
if err != nil {
|
||||
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
if utils.HasDryRunArg(r) {
|
||||
utils.WriteSimulationResponse(w, txCtx.Gas)
|
||||
utils.WriteSimulationResponse(w, txBldr.Gas)
|
||||
return
|
||||
}
|
||||
txCtx = newCtx
|
||||
txBldr = newCtx
|
||||
}
|
||||
|
||||
if utils.HasGenerateOnlyArg(r) {
|
||||
utils.WriteGenerateStdTxResponse(w, txCtx, []sdk.Msg{msg})
|
||||
utils.WriteGenerateStdTxResponse(w, txBldr, []sdk.Msg{msg})
|
||||
return
|
||||
}
|
||||
|
||||
txBytes, err := txCtx.BuildAndSign(m.LocalAccountName, m.Password, []sdk.Msg{msg})
|
||||
txBytes, err := txBldr.BuildAndSign(m.LocalAccountName, m.Password, []sdk.Msg{msg})
|
||||
if err != nil {
|
||||
utils.WriteErrorResponse(w, http.StatusUnauthorized, err.Error())
|
||||
return
|
||||
|
|
|
@ -28,9 +28,9 @@ func getMockApp(t *testing.T) (*mock.App, stake.Keeper, Keeper) {
|
|||
keyStake := sdk.NewKVStoreKey("stake")
|
||||
keySlashing := sdk.NewKVStoreKey("slashing")
|
||||
keyParams := sdk.NewKVStoreKey("params")
|
||||
coinKeeper := bank.NewKeeper(mapp.AccountMapper)
|
||||
bankKeeper := bank.NewKeeper(mapp.AccountMapper)
|
||||
paramsKeeper := params.NewKeeper(mapp.Cdc, keyParams)
|
||||
stakeKeeper := stake.NewKeeper(mapp.Cdc, keyStake, coinKeeper, mapp.RegisterCodespace(stake.DefaultCodespace))
|
||||
stakeKeeper := stake.NewKeeper(mapp.Cdc, keyStake, bankKeeper, mapp.RegisterCodespace(stake.DefaultCodespace))
|
||||
|
||||
keeper := NewKeeper(mapp.Cdc, keySlashing, stakeKeeper, paramsKeeper.Getter(), mapp.RegisterCodespace(DefaultCodespace))
|
||||
mapp.Router().AddRoute("stake", stake.NewHandler(stakeKeeper))
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
|
||||
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
@ -21,7 +21,7 @@ func GetCmdUnjail(cdc *wire.Codec) *cobra.Command {
|
|||
Args: cobra.NoArgs,
|
||||
Short: "unjail validator previously jailed for downtime",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
txCtx := authctx.NewTxContextFromCLI().WithCodec(cdc)
|
||||
txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
|
||||
cliCtx := context.NewCLIContext().
|
||||
WithCodec(cdc).
|
||||
WithLogger(os.Stdout).
|
||||
|
@ -34,9 +34,9 @@ func GetCmdUnjail(cdc *wire.Codec) *cobra.Command {
|
|||
|
||||
msg := slashing.NewMsgUnjail(sdk.ValAddress(valAddr))
|
||||
if cliCtx.GenerateOnly {
|
||||
return utils.PrintUnsignedStdTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
}
|
||||
return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/crypto/keys"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
|
||||
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
@ -70,7 +70,7 @@ func unjailRequestHandlerFn(cdc *wire.Codec, kb keys.Keybase, cliCtx context.CLI
|
|||
return
|
||||
}
|
||||
|
||||
txCtx := authctx.TxContext{
|
||||
txBldr := authtxb.TxBuilder{
|
||||
Codec: cdc,
|
||||
ChainID: m.ChainID,
|
||||
AccountNumber: m.AccountNumber,
|
||||
|
@ -87,24 +87,24 @@ func unjailRequestHandlerFn(cdc *wire.Codec, kb keys.Keybase, cliCtx context.CLI
|
|||
cliCtx = cliCtx.WithGasAdjustment(adjustment)
|
||||
|
||||
if utils.HasDryRunArg(r) || m.Gas == 0 {
|
||||
newCtx, err := utils.EnrichCtxWithGas(txCtx, cliCtx, m.LocalAccountName, []sdk.Msg{msg})
|
||||
newCtx, err := utils.EnrichCtxWithGas(txBldr, cliCtx, m.LocalAccountName, []sdk.Msg{msg})
|
||||
if err != nil {
|
||||
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
if utils.HasDryRunArg(r) {
|
||||
utils.WriteSimulationResponse(w, txCtx.Gas)
|
||||
utils.WriteSimulationResponse(w, txBldr.Gas)
|
||||
return
|
||||
}
|
||||
txCtx = newCtx
|
||||
txBldr = newCtx
|
||||
}
|
||||
|
||||
if utils.HasGenerateOnlyArg(r) {
|
||||
utils.WriteGenerateStdTxResponse(w, txCtx, []sdk.Msg{msg})
|
||||
utils.WriteGenerateStdTxResponse(w, txBldr, []sdk.Msg{msg})
|
||||
return
|
||||
}
|
||||
|
||||
txBytes, err := txCtx.BuildAndSign(m.LocalAccountName, m.Password, []sdk.Msg{msg})
|
||||
txBytes, err := txBldr.BuildAndSign(m.LocalAccountName, m.Password, []sdk.Msg{msg})
|
||||
if err != nil {
|
||||
utils.WriteErrorResponse(w, http.StatusUnauthorized, "Must use own validator address")
|
||||
return
|
||||
|
|
|
@ -34,8 +34,8 @@ func getMockApp(t *testing.T) (*mock.App, Keeper) {
|
|||
RegisterWire(mApp.Cdc)
|
||||
|
||||
keyStake := sdk.NewKVStoreKey("stake")
|
||||
coinKeeper := bank.NewKeeper(mApp.AccountMapper)
|
||||
keeper := NewKeeper(mApp.Cdc, keyStake, coinKeeper, mApp.RegisterCodespace(DefaultCodespace))
|
||||
bankKeeper := bank.NewKeeper(mApp.AccountMapper)
|
||||
keeper := NewKeeper(mApp.Cdc, keyStake, bankKeeper, mApp.RegisterCodespace(DefaultCodespace))
|
||||
|
||||
mApp.Router().AddRoute("stake", NewHandler(keeper))
|
||||
mApp.SetEndBlocker(getEndBlocker(keeper))
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
|
||||
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||
"github.com/cosmos/cosmos-sdk/x/stake"
|
||||
"github.com/cosmos/cosmos-sdk/x/stake/types"
|
||||
|
||||
|
@ -25,7 +25,7 @@ func GetCmdCreateValidator(cdc *wire.Codec) *cobra.Command {
|
|||
Use: "create-validator",
|
||||
Short: "create new validator initialized with a self-delegation to it",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
txCtx := authctx.NewTxContextFromCLI().WithCodec(cdc)
|
||||
txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
|
||||
cliCtx := context.NewCLIContext().
|
||||
WithCodec(cdc).
|
||||
WithLogger(os.Stdout).
|
||||
|
@ -78,10 +78,10 @@ func GetCmdCreateValidator(cdc *wire.Codec) *cobra.Command {
|
|||
msg = stake.NewMsgCreateValidator(sdk.ValAddress(valAddr), pk, amount, description)
|
||||
}
|
||||
if cliCtx.GenerateOnly {
|
||||
return utils.PrintUnsignedStdTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
}
|
||||
// build and sign the transaction, then broadcast to Tendermint
|
||||
return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ func GetCmdEditValidator(cdc *wire.Codec) *cobra.Command {
|
|||
Use: "edit-validator",
|
||||
Short: "edit and existing validator account",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
txCtx := authctx.NewTxContextFromCLI().WithCodec(cdc)
|
||||
txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
|
||||
cliCtx := context.NewCLIContext().
|
||||
WithCodec(cdc).
|
||||
WithLogger(os.Stdout).
|
||||
|
@ -120,10 +120,10 @@ func GetCmdEditValidator(cdc *wire.Codec) *cobra.Command {
|
|||
msg := stake.NewMsgEditValidator(sdk.ValAddress(valAddr), description)
|
||||
|
||||
if cliCtx.GenerateOnly {
|
||||
return utils.PrintUnsignedStdTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
}
|
||||
// build and sign the transaction, then broadcast to Tendermint
|
||||
return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ func GetCmdDelegate(cdc *wire.Codec) *cobra.Command {
|
|||
Use: "delegate",
|
||||
Short: "delegate liquid tokens to an validator",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
txCtx := authctx.NewTxContextFromCLI().WithCodec(cdc)
|
||||
txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
|
||||
cliCtx := context.NewCLIContext().
|
||||
WithCodec(cdc).
|
||||
WithLogger(os.Stdout).
|
||||
|
@ -162,10 +162,10 @@ func GetCmdDelegate(cdc *wire.Codec) *cobra.Command {
|
|||
msg := stake.NewMsgDelegate(delAddr, valAddr, amount)
|
||||
|
||||
if cliCtx.GenerateOnly {
|
||||
return utils.PrintUnsignedStdTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
}
|
||||
// build and sign the transaction, then broadcast to Tendermint
|
||||
return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -197,7 +197,7 @@ func GetCmdBeginRedelegate(storeName string, cdc *wire.Codec) *cobra.Command {
|
|||
Use: "begin",
|
||||
Short: "begin redelegation",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
txCtx := authctx.NewTxContextFromCLI().WithCodec(cdc)
|
||||
txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
|
||||
cliCtx := context.NewCLIContext().
|
||||
WithCodec(cdc).
|
||||
WithLogger(os.Stdout).
|
||||
|
@ -234,10 +234,10 @@ func GetCmdBeginRedelegate(storeName string, cdc *wire.Codec) *cobra.Command {
|
|||
msg := stake.NewMsgBeginRedelegate(delAddr, valSrcAddr, valDstAddr, sharesAmount)
|
||||
|
||||
if cliCtx.GenerateOnly {
|
||||
return utils.PrintUnsignedStdTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
}
|
||||
// build and sign the transaction, then broadcast to Tendermint
|
||||
return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -301,7 +301,7 @@ func GetCmdCompleteRedelegate(cdc *wire.Codec) *cobra.Command {
|
|||
Use: "complete",
|
||||
Short: "complete redelegation",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
txCtx := authctx.NewTxContextFromCLI().WithCodec(cdc)
|
||||
txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
|
||||
cliCtx := context.NewCLIContext().
|
||||
WithCodec(cdc).
|
||||
WithLogger(os.Stdout).
|
||||
|
@ -325,10 +325,10 @@ func GetCmdCompleteRedelegate(cdc *wire.Codec) *cobra.Command {
|
|||
msg := stake.NewMsgCompleteRedelegate(delAddr, valSrcAddr, valDstAddr)
|
||||
|
||||
if cliCtx.GenerateOnly {
|
||||
return utils.PrintUnsignedStdTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
}
|
||||
// build and sign the transaction, then broadcast to Tendermint
|
||||
return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -359,7 +359,7 @@ func GetCmdBeginUnbonding(storeName string, cdc *wire.Codec) *cobra.Command {
|
|||
Use: "begin",
|
||||
Short: "begin unbonding",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
txCtx := authctx.NewTxContextFromCLI().WithCodec(cdc)
|
||||
txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
|
||||
cliCtx := context.NewCLIContext().
|
||||
WithCodec(cdc).
|
||||
WithLogger(os.Stdout).
|
||||
|
@ -389,10 +389,10 @@ func GetCmdBeginUnbonding(storeName string, cdc *wire.Codec) *cobra.Command {
|
|||
msg := stake.NewMsgBeginUnbonding(delAddr, valAddr, sharesAmount)
|
||||
|
||||
if cliCtx.GenerateOnly {
|
||||
return utils.PrintUnsignedStdTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
}
|
||||
// build and sign the transaction, then broadcast to Tendermint
|
||||
return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -408,7 +408,7 @@ func GetCmdCompleteUnbonding(cdc *wire.Codec) *cobra.Command {
|
|||
Use: "complete",
|
||||
Short: "complete unbonding",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
txCtx := authctx.NewTxContextFromCLI().WithCodec(cdc)
|
||||
txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
|
||||
cliCtx := context.NewCLIContext().
|
||||
WithCodec(cdc).
|
||||
WithLogger(os.Stdout).
|
||||
|
@ -427,10 +427,10 @@ func GetCmdCompleteUnbonding(cdc *wire.Codec) *cobra.Command {
|
|||
msg := stake.NewMsgCompleteUnbonding(delAddr, valAddr)
|
||||
|
||||
if cliCtx.GenerateOnly {
|
||||
return utils.PrintUnsignedStdTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
}
|
||||
// build and sign the transaction, then broadcast to Tendermint
|
||||
return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg})
|
||||
return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/crypto/keys"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
authcliCtx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
|
||||
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||
"github.com/cosmos/cosmos-sdk/x/stake"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
@ -263,7 +263,7 @@ func delegationsRequestHandlerFn(cdc *wire.Codec, kb keys.Keybase, cliCtx contex
|
|||
i++
|
||||
}
|
||||
|
||||
txCtx := authcliCtx.TxContext{
|
||||
txBldr := authtxb.TxBuilder{
|
||||
Codec: cdc,
|
||||
ChainID: m.ChainID,
|
||||
Gas: m.Gas,
|
||||
|
@ -273,8 +273,8 @@ func delegationsRequestHandlerFn(cdc *wire.Codec, kb keys.Keybase, cliCtx contex
|
|||
signedTxs := make([][]byte, len(messages[:]))
|
||||
for i, msg := range messages {
|
||||
// increment sequence for each message
|
||||
txCtx = txCtx.WithAccountNumber(m.AccountNumber)
|
||||
txCtx = txCtx.WithSequence(m.Sequence)
|
||||
txBldr = txBldr.WithAccountNumber(m.AccountNumber)
|
||||
txBldr = txBldr.WithSequence(m.Sequence)
|
||||
|
||||
m.Sequence++
|
||||
|
||||
|
@ -285,24 +285,24 @@ func delegationsRequestHandlerFn(cdc *wire.Codec, kb keys.Keybase, cliCtx contex
|
|||
cliCtx = cliCtx.WithGasAdjustment(adjustment)
|
||||
|
||||
if utils.HasDryRunArg(r) || m.Gas == 0 {
|
||||
newCtx, err := utils.EnrichCtxWithGas(txCtx, cliCtx, m.LocalAccountName, []sdk.Msg{msg})
|
||||
newCtx, err := utils.EnrichCtxWithGas(txBldr, cliCtx, m.LocalAccountName, []sdk.Msg{msg})
|
||||
if err != nil {
|
||||
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
if utils.HasDryRunArg(r) {
|
||||
utils.WriteSimulationResponse(w, txCtx.Gas)
|
||||
utils.WriteSimulationResponse(w, txBldr.Gas)
|
||||
return
|
||||
}
|
||||
txCtx = newCtx
|
||||
txBldr = newCtx
|
||||
}
|
||||
|
||||
if utils.HasGenerateOnlyArg(r) {
|
||||
utils.WriteGenerateStdTxResponse(w, txCtx, []sdk.Msg{msg})
|
||||
utils.WriteGenerateStdTxResponse(w, txBldr, []sdk.Msg{msg})
|
||||
return
|
||||
}
|
||||
|
||||
txBytes, err := txCtx.BuildAndSign(m.LocalAccountName, m.Password, []sdk.Msg{msg})
|
||||
txBytes, err := txBldr.BuildAndSign(m.LocalAccountName, m.Password, []sdk.Msg{msg})
|
||||
if err != nil {
|
||||
utils.WriteErrorResponse(w, http.StatusUnauthorized, err.Error())
|
||||
return
|
||||
|
|
|
@ -234,7 +234,7 @@ func (k Keeper) Delegate(ctx sdk.Context, delAddr sdk.AccAddress, bondAmt sdk.Co
|
|||
|
||||
if subtractAccount {
|
||||
// Account new shares, save
|
||||
_, _, err = k.coinKeeper.SubtractCoins(ctx, delegation.DelegatorAddr, sdk.Coins{bondAmt})
|
||||
_, _, err = k.bankKeeper.SubtractCoins(ctx, delegation.DelegatorAddr, sdk.Coins{bondAmt})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -362,7 +362,7 @@ func (k Keeper) BeginUnbonding(ctx sdk.Context,
|
|||
|
||||
// no need to create the ubd object just complete now
|
||||
if completeNow {
|
||||
_, _, err := k.coinKeeper.AddCoins(ctx, delAddr, sdk.Coins{balance})
|
||||
_, _, err := k.bankKeeper.AddCoins(ctx, delAddr, sdk.Coins{balance})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -395,7 +395,7 @@ func (k Keeper) CompleteUnbonding(ctx sdk.Context, delAddr sdk.AccAddress, valAd
|
|||
return types.ErrNotMature(k.Codespace(), "unbonding", "unit-time", ubd.MinTime, ctxTime)
|
||||
}
|
||||
|
||||
_, _, err := k.coinKeeper.AddCoins(ctx, ubd.DelegatorAddr, sdk.Coins{ubd.Balance})
|
||||
_, _, err := k.bankKeeper.AddCoins(ctx, ubd.DelegatorAddr, sdk.Coins{ubd.Balance})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
type Keeper struct {
|
||||
storeKey sdk.StoreKey
|
||||
cdc *wire.Codec
|
||||
coinKeeper bank.Keeper
|
||||
bankKeeper bank.Keeper
|
||||
validatorHooks sdk.ValidatorHooks
|
||||
|
||||
// codespace
|
||||
|
@ -23,7 +23,7 @@ func NewKeeper(cdc *wire.Codec, key sdk.StoreKey, ck bank.Keeper, codespace sdk.
|
|||
keeper := Keeper{
|
||||
storeKey: key,
|
||||
cdc: cdc,
|
||||
coinKeeper: ck,
|
||||
bankKeeper: ck,
|
||||
validatorHooks: nil,
|
||||
codespace: codespace,
|
||||
}
|
||||
|
|
|
@ -21,9 +21,9 @@ func TestStakeWithRandomMessages(t *testing.T) {
|
|||
|
||||
bank.RegisterWire(mapp.Cdc)
|
||||
mapper := mapp.AccountMapper
|
||||
coinKeeper := bank.NewKeeper(mapper)
|
||||
bankKeeper := bank.NewKeeper(mapper)
|
||||
stakeKey := sdk.NewKVStoreKey("stake")
|
||||
stakeKeeper := stake.NewKeeper(mapp.Cdc, stakeKey, coinKeeper, stake.DefaultCodespace)
|
||||
stakeKeeper := stake.NewKeeper(mapp.Cdc, stakeKey, bankKeeper, stake.DefaultCodespace)
|
||||
mapp.Router().AddRoute("stake", stake.NewHandler(stakeKeeper))
|
||||
mapp.SetEndBlocker(func(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
|
||||
validatorUpdates := stake.EndBlocker(ctx, stakeKeeper)
|
||||
|
@ -55,7 +55,7 @@ func TestStakeWithRandomMessages(t *testing.T) {
|
|||
}, []simulation.RandSetup{
|
||||
Setup(mapp, stakeKeeper),
|
||||
}, []simulation.Invariant{
|
||||
AllInvariants(coinKeeper, stakeKeeper, mapp.AccountMapper),
|
||||
AllInvariants(bankKeeper, stakeKeeper, mapp.AccountMapper),
|
||||
}, 10, 100,
|
||||
false,
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue