Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R4R: Supply Module #4255

Merged
merged 176 commits into from
Jun 28, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
176 commits
Select commit Hold shift + click to select a range
e8533ee
supply module
fedekunze May 2, 2019
0866d2e
invariants
fedekunze May 2, 2019
89a54e4
add to gaia, tests, minor fixes
fedekunze May 2, 2019
cf02698
tests
fedekunze May 2, 2019
7f3a5c9
fixes
fedekunze May 2, 2019
e19d098
expected crisis keeper
fedekunze May 2, 2019
d2c13a6
accounts
fedekunze May 5, 2019
bb12b4f
supply bank
fedekunze May 5, 2019
1983151
total supply type and keeper
fedekunze May 5, 2019
ce46707
Apply suggestions from code review
alexanderbez May 5, 2019
26c4804
cleanup app.go
fedekunze May 5, 2019
f67852b
Merge branch 'fedekunze/3972-supply' of https://github.com/cosmos/cos…
fedekunze May 5, 2019
7200d2e
genesis stuff
fedekunze May 5, 2019
8940db4
fix error checks
fedekunze May 5, 2019
eeaa0c3
gov module holder account
fedekunze May 6, 2019
bc314a9
some gov tests
fedekunze May 6, 2019
739673a
remove fee collector keeper and staking pool
fedekunze May 8, 2019
03564c1
more fixes on staking
fedekunze May 8, 2019
d59b287
fix gov supplyKeeper
fedekunze May 10, 2019
249ae59
remove staking pool fixes
fedekunze May 10, 2019
1dda132
fix mock mod
fedekunze May 10, 2019
06c65d7
more staking pool changes
fedekunze May 13, 2019
1186198
more changes in tests
fedekunze May 14, 2019
fe1e028
remove fee pool from store
fedekunze May 14, 2019
7afdfad
extend pool accs to use DecCoins instead of Coins
fedekunze May 14, 2019
310f566
revert DecCoins
fedekunze May 14, 2019
6f38715
some build fixes
fedekunze May 14, 2019
1cf75b6
revert changes from distr
fedekunze May 14, 2019
a93874c
cleanup supply module's bank logic
fedekunze May 14, 2019
8fe8afb
cleanup supply, remove inflate/deflate exported funcs
fedekunze May 15, 2019
859c1bb
remove inflate
fedekunze May 15, 2019
c5f8b91
more fixes
fedekunze May 16, 2019
6f45043
@rigelrozanski gen modularization PR changes
fedekunze May 16, 2019
f6d73e7
golangci bot and rename distr module name
fedekunze May 16, 2019
212cc2a
supply module.go changes
fedekunze May 16, 2019
32942d0
add supply to gaia
fedekunze May 16, 2019
8dc60dc
register account types and interfaces in x/auth
fedekunze May 16, 2019
a0c95c1
fix some tests
fedekunze May 16, 2019
68cf00e
fix tests part 2
fedekunze May 17, 2019
dbaab38
remove gaia changes
fedekunze May 22, 2019
71537bd
not bonded pool only holds coins from staking
fedekunze May 23, 2019
27d9c7e
fix tests pt 3
fedekunze May 23, 2019
1fee72e
more tests fixes
fedekunze May 23, 2019
6dc28a4
genesis changes when module accs are not set
fedekunze May 24, 2019
f8aa29c
Fix all amino codec related panics for Fede (#4407)
liamsi May 24, 2019
ae28518
test fixes and changes
fedekunze May 24, 2019
bec358d
revert query staking pool to use sdk.Int
fedekunze May 24, 2019
8007eb1
remove err from GetAccs
fedekunze May 24, 2019
668b64d
supply keeper tests
fedekunze May 24, 2019
797939b
rename PoolAccount to ModuleAccount
fedekunze May 24, 2019
c23f219
edit supply account
fedekunze May 24, 2019
9240934
rename bank supply funcs
fedekunze May 24, 2019
86f328e
fix tests and add getters for module accs
fedekunze May 26, 2019
2d7f208
burn tokens removed from validator
fedekunze May 26, 2019
9979dc3
fixes
fedekunze May 26, 2019
1029eb4
fix ante and mint
fedekunze May 27, 2019
16bfc2e
fix sig verification
fedekunze May 27, 2019
ac6477e
fix fast sim
fedekunze May 27, 2019
6f3aa19
update genesis account to support module accs
fedekunze May 27, 2019
6f466fc
lint
fedekunze May 27, 2019
1c326ea
fix conflicts w/ master
fedekunze May 27, 2019
b57c103
renamings and other minor changes
fedekunze May 28, 2019
b3e32bb
few minor changes
fedekunze May 28, 2019
32fdfe0
update invariants to be consistent with genesis
fedekunze May 28, 2019
84493fd
refactor gov keys
fedekunze May 31, 2019
91e9c68
iterators and renamings
fedekunze May 31, 2019
de49818
invert queue key order
fedekunze May 31, 2019
8194039
changelog
fedekunze May 31, 2019
1df9b17
fix tests
fedekunze May 31, 2019
0215c8a
update alias.go
fedekunze May 31, 2019
e314157
update alias.go
fedekunze May 31, 2019
b9a7d88
Apply suggestions from code review
fedekunze Jun 3, 2019
01fcfdf
rename keys
fedekunze Jun 3, 2019
0e649f0
rename functions
fedekunze Jun 3, 2019
0fe446c
merge in master
fedekunze Jun 3, 2019
9acdca4
conflicts
fedekunze Jun 3, 2019
a4d0029
merge gov iterators PR
fedekunze Jun 3, 2019
e4f1fc3
gov invariant
fedekunze Jun 3, 2019
02b69f0
Apply suggestions from code review
fedekunze Jun 3, 2019
c0d0c04
address Aleks' comments
fedekunze Jun 3, 2019
476a606
fix test
fedekunze Jun 3, 2019
7fec55e
Merge branch 'fedekunze/gov-fixes' of https://github.com/cosmos/cosmo…
fedekunze Jun 3, 2019
3d5fb26
fix invariants simulation
fedekunze Jun 3, 2019
6ae7647
update staking tests
fedekunze Jun 4, 2019
7c6a6af
improved simulation logs
fedekunze Jun 4, 2019
76f77ae
fix account number error
fedekunze Jun 4, 2019
a96936d
fix conflicts with master
fedekunze Jun 5, 2019
dc89796
leftover changes
fedekunze Jun 5, 2019
444e191
fix merge conflicts and tests
fedekunze Jun 6, 2019
6e78171
merge master
fedekunze Jun 6, 2019
b59a40f
Delete LOCK
fedekunze Jun 6, 2019
f19ffda
Delete LOG
fedekunze Jun 6, 2019
80f2efa
minor changes
fedekunze Jun 6, 2019
29adde8
Merge branch 'fedekunze/3972-supply' of https://github.com/cosmos/cos…
fedekunze Jun 6, 2019
11e96b3
reduce invariance amount
fedekunze Jun 7, 2019
6e9f686
minor changes
fedekunze Jun 10, 2019
b411d79
update supply keeper to use bank keeper
fedekunze Jun 10, 2019
89ab360
reaname GetPools
fedekunze Jun 10, 2019
8b35156
use supply (un)delegateCoins
fedekunze Jun 10, 2019
801d265
fix benchmark invariants
fedekunze Jun 10, 2019
3002808
merge master and resolve conflicts
fedekunze Jun 11, 2019
6a00e9c
fixed simulations !
fedekunze Jun 11, 2019
26260f3
Apply suggestions from code review
fedekunze Jun 12, 2019
ae4cf68
addressed minor comments from code reviews
fedekunze Jun 12, 2019
3810674
move validator funcs back to types
fedekunze Jun 13, 2019
b0f5953
update (un)delegateCoins
fedekunze Jun 13, 2019
e357b60
fix panic
fedekunze Jun 13, 2019
a61e7b4
set maccs on simapp, panic on genesis and make feeCollector a macc
fedekunze Jun 15, 2019
0b289d6
populate module account coins on genesis
fedekunze Jun 15, 2019
173f086
more updates (broken)
fedekunze Jun 16, 2019
0de237e
fix test_cover
rigelrozanski Jun 16, 2019
2153e24
work through a bunch of core changes
rigelrozanski Jun 16, 2019
c79e804
fix some tests
fedekunze Jun 17, 2019
c8438d5
working debugging make test
rigelrozanski Jun 17, 2019
8aa7500
fix make test
rigelrozanski Jun 17, 2019
931c163
misspell
rigelrozanski Jun 17, 2019
05d672b
minor changes
fedekunze Jun 18, 2019
67a62db
sendDelegatedCoins
fedekunze Jun 18, 2019
3777eb1
update (un)delegate coins
fedekunze Jun 18, 2019
1a663e7
merge changes from master
fedekunze Jun 19, 2019
7a399a5
update alias
fedekunze Jun 19, 2019
06fec07
minor updates
fedekunze Jun 19, 2019
ffcf962
fix TestUpdateValidatorByPowerIndex
rigelrozanski Jun 20, 2019
8668af8
fix TestGetValidatorsEdgeCases
rigelrozanski Jun 20, 2019
9ff5736
supply refactors (#4604)
rigelrozanski Jun 25, 2019
bd072bb
Merge remote-tracking branch 'origin/master' into fedekunze/3972-supply
rigelrozanski Jun 25, 2019
9cc078d
build conflicts fixed
rigelrozanski Jun 25, 2019
6738963
fix TestAnteHandlerFees
rigelrozanski Jun 25, 2019
ee22929
linting
rigelrozanski Jun 25, 2019
877e228
remove retrieveSimLog
rigelrozanski Jun 25, 2019
0d95280
add logger for mint and burn
fedekunze Jun 25, 2019
5df3f65
log fixes / working on removing embedded module addresses
rigelrozanski Jun 25, 2019
2c6eeed
remove all references to Module Addresses
rigelrozanski Jun 25, 2019
e201cee
simulation changes
rigelrozanski Jun 25, 2019
a6e73cd
fix yaml
fedekunze Jun 25, 2019
937327d
Merge branch 'fedekunze/3972-supply' of https://github.com/cosmos/cos…
fedekunze Jun 25, 2019
a27e948
HandleCommunityPoolSpendProposal common code refactor
rigelrozanski Jun 25, 2019
9594ed6
redelegation dstValidator slashing supply fix
rigelrozanski Jun 25, 2019
02daec9
typo
rigelrozanski Jun 25, 2019
15c2f93
remove panic
fedekunze Jun 25, 2019
b1e6dbc
minor fix
fedekunze Jun 25, 2019
f78b468
resolve conflicts
fedekunze Jun 26, 2019
62b897c
fix tests
fedekunze Jun 26, 2019
7dd0e1e
lint
fedekunze Jun 26, 2019
7767d1c
minor changes
fedekunze Jun 26, 2019
a8bac8a
unused export
rigelrozanski Jun 26, 2019
effd5d8
Apply suggestions from code review
fedekunze Jun 26, 2019
05c7952
address @alexanderbez comments
fedekunze Jun 26, 2019
4f073d4
merge supply
fedekunze Jun 26, 2019
63c9a35
move fee deduction to the original place in ante-handler
rigelrozanski Jun 26, 2019
0eed53f
rename holder permission and address some comments from Rigel
fedekunze Jun 27, 2019
d1309f5
pass fee collector name; fix sim bug
fedekunze Jun 27, 2019
f1787eb
remove fee collector name from core module logic
fedekunze Jun 27, 2019
cfbbba6
set account before return
fedekunze Jun 27, 2019
f609ad6
panic if not a module account
rigelrozanski Jun 27, 2019
0bf09f7
proper module account creation
rigelrozanski Jun 27, 2019
e9e7acc
fix make test
rigelrozanski Jun 27, 2019
cecbb34
fix make test
rigelrozanski Jun 27, 2019
01b4891
sim test util
fedekunze Jun 27, 2019
6b91a29
Merge branch 'fedekunze/3972-supply' of https://github.com/cosmos/cos…
fedekunze Jun 27, 2019
f46dbd8
lint fix
rigelrozanski Jun 27, 2019
50d5de7
resolve import export bug
rigelrozanski Jun 27, 2019
687fa79
fix conflicts with master
fedekunze Jun 28, 2019
69b48a1
cha-cha-cha
fedekunze Jun 28, 2019
ae281ad
Update simapp/sim_test.go
fedekunze Jun 28, 2019
92d0702
Update x/slashing/keeper.go
fedekunze Jun 28, 2019
5f1f0e9
Update x/slashing/keeper.go
fedekunze Jun 28, 2019
16ff6df
Update x/slashing/keeper.go
fedekunze Jun 28, 2019
6224dda
Update x/slashing/keeper.go
fedekunze Jun 28, 2019
ef2c8c2
Update x/slashing/keeper.go
fedekunze Jun 28, 2019
8b29a19
Update x/slashing/keeper.go
fedekunze Jun 28, 2019
d7a9ca0
Update x/slashing/keeper.go
fedekunze Jun 28, 2019
c78f378
Update x/slashing/keeper.go
fedekunze Jun 28, 2019
bdeea26
address final @alexanderbez comments
fedekunze Jun 28, 2019
a1d0001
Merge branch 'fedekunze/3972-supply' of https://github.com/cosmos/cos…
fedekunze Jun 28, 2019
4691d19
fix conflicts
fedekunze Jun 28, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
supply refactors (#4604)
* Refactors from Rigel
  • Loading branch information
rigelrozanski authored and fedekunze committed Jun 25, 2019
commit 9ff5736b3d51ccb70bc094960567820208412e1a
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ linters:
- unconvert
- misspell
- govet
- unused
- deadcode
- goconst
linters-settings:
gocyclo:
min-complexity: 11
Expand Down
2 changes: 2 additions & 0 deletions .pending/breaking/sdk/4543-Account-getters
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#4543 Account getters are no longer part of client.CLIContext() and have now moved
to reside in the auth-specific AccountRetriever.
6 changes: 6 additions & 0 deletions .pending/breaking/sdk/4588-Context-does-no
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#4588 Context does not depend on x/auth anymore. client/context is stripped out of the following features:
- GetAccountDecoder()
- CLIContext.WithAccountDecoder()
- CLIContext.WithAccountStore()

x/auth.AccountDecoder is unnecessary and consequently removed.
1 change: 1 addition & 0 deletions .pending/breaking/sdk/4602-client-input-Bu
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4602 client/input.{Buffer,Override}Stdin() functions are removed. Thanks to cobra's new release they are now redundant.
1 change: 1 addition & 0 deletions .pending/bugfixes/sdk/4598-fix-check-bond-
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4598 Fix redelegation and undelegation txs that were not checking for the correct bond denomination.
2 changes: 2 additions & 0 deletions .pending/improvements/sdk/4584-Update-bank-Kee
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#4584 Update bank Keeper to use expected keeper interface of the AccountKeeper.
#4584 Move `Account` and `VestingAccount` interface types to `x/auth/exported`.
1 change: 1 addition & 0 deletions .pending/improvements/sdk/Remove---print-respo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove `--print-response` flag as it is no longer used.
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ COMMIT := $(shell git log -1 --format='%H')
LEDGER_ENABLED ?= true
BINDIR ?= $(GOPATH)/bin
SIMAPP = github.com/cosmos/cosmos-sdk/simapp
MOCKS_DIR = $(CURDIR)/tests/mocks

export GO111MODULE = on

Expand All @@ -33,6 +34,12 @@ dist:
@bash publish/dist.sh
@bash publish/publish.sh

mocks: $(MOCKS_DIR)
mockgen -source=x/auth/types/account_retriever.go -package mocks -destination tests/mocks/account_retriever.go

$(MOCKS_DIR):
mkdir -p $(MOCKS_DIR)

########################################
### Tools & dependencies

Expand Down Expand Up @@ -186,7 +193,7 @@ snapcraft-local.yaml: snapcraft-local.yaml.in
# To avoid unintended conflicts with file names, always add to .PHONY
# unless there is a reason not to.
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
.PHONY: build dist clean test test_unit test_cover lint \
.PHONY: build dist clean test test_unit test_cover lint mocks \
benchmark devdoc_init devdoc devdoc_save devdoc_update runsim \
format test_sim_app_nondeterminism test_sim_modules test_sim_app_fast \
test_sim_app_custom_genesis_fast test_sim_app_custom_genesis_multi_seed \
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

[![version](https://img.shields.io/github/tag/cosmos/cosmos-sdk.svg)](https://github.com/cosmos/cosmos-sdk/releases/latest)
[![CircleCI](https://circleci.com/gh/cosmos/cosmos-sdk/tree/master.svg?style=shield)](https://circleci.com/gh/cosmos/cosmos-sdk/tree/master)
[![Snap Status](https://build.snapcraft.io/badge/cosmos/cosmos-sdk.svg)](https://build.snapcraft.io/user/cosmos/cosmos-sdk)
[![codecov](https://codecov.io/gh/cosmos/cosmos-sdk/branch/master/graph/badge.svg)](https://codecov.io/gh/cosmos/cosmos-sdk)
[![Go Report Card](https://goreportcard.com/badge/github.com/cosmos/cosmos-sdk)](https://goreportcard.com/report/github.com/cosmos/cosmos-sdk)
[![license](https://img.shields.io/github/license/cosmos/cosmos-sdk.svg)](https://github.com/cosmos/cosmos-sdk/blob/master/LICENSE)
Expand Down
4 changes: 0 additions & 4 deletions client/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ const (
FlagFees = flags.FlagFees
FlagGasPrices = flags.FlagGasPrices
FlagBroadcastMode = flags.FlagBroadcastMode
FlagPrintResponse = flags.FlagPrintResponse
FlagDryRun = flags.FlagDryRun
FlagGenerateOnly = flags.FlagGenerateOnly
FlagIndentResponse = flags.FlagIndentResponse
Expand All @@ -67,7 +66,6 @@ var (
// functions aliases
NewCLIContextWithFrom = context.NewCLIContextWithFrom
NewCLIContext = context.NewCLIContext
GetAccountDecoder = context.GetAccountDecoder
GetFromFields = context.GetFromFields
ErrInvalidAccount = context.ErrInvalidAccount
ErrVerifyCommit = context.ErrVerifyCommit
Expand Down Expand Up @@ -105,8 +103,6 @@ var (
GetValidators = rpc.GetValidators
ValidatorSetRequestHandlerFn = rpc.ValidatorSetRequestHandlerFn
LatestValidatorSetRequestHandlerFn = rpc.LatestValidatorSetRequestHandlerFn
BufferStdin = input.BufferStdin
OverrideStdin = input.OverrideStdin
GetPassword = input.GetPassword
GetCheckPassword = input.GetCheckPassword
GetConfirmation = input.GetConfirmation
Expand Down
31 changes: 0 additions & 31 deletions client/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
cryptokeys "github.com/cosmos/cosmos-sdk/crypto/keys"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)

var (
Expand All @@ -34,19 +33,16 @@ var (
// transaction handling and queries.
type CLIContext struct {
Codec *codec.Codec
AccDecoder authtypes.AccountDecoder
Client rpcclient.Client
Keybase cryptokeys.Keybase
Output io.Writer
OutputFormat string
Height int64
NodeURI string
From string
AccountStore string
TrustNode bool
UseLedger bool
BroadcastMode string
PrintResponse bool
Verifier tmlite.Verifier
VerifierHome string
Simulate bool
Expand Down Expand Up @@ -88,14 +84,12 @@ func NewCLIContextWithFrom(from string) CLIContext {
Client: rpc,
Output: os.Stdout,
NodeURI: nodeURI,
AccountStore: authtypes.StoreKey,
From: viper.GetString(flags.FlagFrom),
OutputFormat: viper.GetString(cli.OutputFlag),
Height: viper.GetInt64(flags.FlagHeight),
TrustNode: viper.GetBool(flags.FlagTrustNode),
UseLedger: viper.GetBool(flags.FlagUseLedger),
BroadcastMode: viper.GetString(flags.FlagBroadcastMode),
PrintResponse: viper.GetBool(flags.FlagPrintResponse),
Verifier: verifier,
Simulate: viper.GetBool(flags.FlagDryRun),
GenerateOnly: genOnly,
Expand Down Expand Up @@ -162,37 +156,12 @@ func (ctx CLIContext) WithCodec(cdc *codec.Codec) CLIContext {
return ctx
}

// GetAccountDecoder gets the account decoder for auth.DefaultAccount.
func GetAccountDecoder(cdc *codec.Codec) authtypes.AccountDecoder {
return func(accBytes []byte) (acct authtypes.Account, err error) {
err = cdc.UnmarshalBinaryBare(accBytes, &acct)
if err != nil {
panic(err)
}

return acct, err
}
}

// WithAccountDecoder returns a copy of the context with an updated account
// decoder.
func (ctx CLIContext) WithAccountDecoder(cdc *codec.Codec) CLIContext {
ctx.AccDecoder = GetAccountDecoder(cdc)
return ctx
}

// WithOutput returns a copy of the context with an updated output writer (e.g. stdout).
func (ctx CLIContext) WithOutput(w io.Writer) CLIContext {
ctx.Output = w
return ctx
}

// WithAccountStore returns a copy of the context with an updated AccountStore.
func (ctx CLIContext) WithAccountStore(accountStore string) CLIContext {
ctx.AccountStore = accountStore
return ctx
}

// WithFrom returns a copy of the context with an updated from address or name.
func (ctx CLIContext) WithFrom(from string) CLIContext {
ctx.From = from
Expand Down
76 changes: 0 additions & 76 deletions client/context/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (

"github.com/cosmos/cosmos-sdk/store/rootmulti"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)

// GetNode returns an RPC client. If the context's client is not defined, an
Expand Down Expand Up @@ -63,26 +62,6 @@ func (ctx CLIContext) QuerySubspace(subspace []byte, storeName string) (res []sd
return
}

// GetAccount queries for an account given an address and a block height. An
// error is returned if the query or decoding fails.
func (ctx CLIContext) GetAccount(address []byte) (authtypes.Account, error) {
if ctx.AccDecoder == nil {
return nil, errors.New("account decoder required but not provided")
}

res, err := ctx.queryAccount(address)
if err != nil {
return nil, err
}

var account authtypes.Account
if err := ctx.Codec.UnmarshalJSON(res, &account); err != nil {
return nil, err
}

return account, nil
}

// GetFromAddress returns the from address from the context's name.
func (ctx CLIContext) GetFromAddress() sdk.AccAddress {
return ctx.FromAddress
Expand All @@ -93,61 +72,6 @@ func (ctx CLIContext) GetFromName() string {
return ctx.FromName
}

// GetAccountNumber returns the next account number for the given account
// address.
func (ctx CLIContext) GetAccountNumber(address []byte) (uint64, error) {
account, err := ctx.GetAccount(address)
if err != nil {
return 0, err
}

return account.GetAccountNumber(), nil
}

// GetAccountSequence returns the sequence number for the given account
// address.
func (ctx CLIContext) GetAccountSequence(address []byte) (uint64, error) {
account, err := ctx.GetAccount(address)
if err != nil {
return 0, err
}

return account.GetSequence(), nil
}

// EnsureAccountExists ensures that an account exists for a given context. An
// error is returned if it does not.
func (ctx CLIContext) EnsureAccountExists() error {
addr := ctx.GetFromAddress()
return ctx.EnsureAccountExistsFromAddr(addr)
}

// EnsureAccountExistsFromAddr ensures that an account exists for a given
// address. Instead of using the context's from name, a direct address is
// given. An error is returned if it does not.
func (ctx CLIContext) EnsureAccountExistsFromAddr(addr sdk.AccAddress) error {
_, err := ctx.queryAccount(addr)
return err
}

// queryAccount queries an account using custom query endpoint of auth module
// returns an error if result is `null` otherwise account data
func (ctx CLIContext) queryAccount(addr sdk.AccAddress) ([]byte, error) {
bz, err := ctx.Codec.MarshalJSON(authtypes.NewQueryAccountParams(addr))
if err != nil {
return nil, err
}

route := fmt.Sprintf("custom/%s/%s", ctx.AccountStore, authtypes.QueryAccount)

res, _, err := ctx.query(route, bz)
if err != nil {
return nil, err
}

return res, nil
}

// query performs a query to a Tendermint node with the provided store name
// and path. It returns the result and height of the query upon success
// or an error if the query fails.
Expand Down
2 changes: 0 additions & 2 deletions client/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ const (
FlagFees = "fees"
FlagGasPrices = "gas-prices"
FlagBroadcastMode = "broadcast-mode"
FlagPrintResponse = "print-response"
FlagDryRun = "dry-run"
FlagGenerateOnly = "generate-only"
FlagIndentResponse = "indent"
Expand Down Expand Up @@ -96,7 +95,6 @@ func PostCommands(cmds ...*cobra.Command) []*cobra.Command {
c.Flags().Bool(FlagUseLedger, false, "Use a connected Ledger device")
c.Flags().Float64(FlagGasAdjustment, DefaultGasAdjustment, "adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored ")
c.Flags().StringP(FlagBroadcastMode, "b", BroadcastSync, "Transaction broadcasting mode (sync|async|block)")
c.Flags().Bool(FlagPrintResponse, true, "return tx response (only works with async = false)")
c.Flags().Bool(FlagTrustNode, true, "Trust connected full node (don't verify proofs for responses)")
c.Flags().Bool(FlagDryRun, false, "ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it")
c.Flags().Bool(FlagGenerateOnly, false, "Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase is not accessible and the node operates offline)")
Expand Down
22 changes: 0 additions & 22 deletions client/input/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,6 @@ import (
// MinPassLength is the minimum acceptable password length
const MinPassLength = 8

var currentStdin *bufio.Reader

func init() {
currentStdin = bufio.NewReader(os.Stdin)
}

// BufferStdin is used to allow reading prompts for stdin
// multiple times, when we read from non-tty
func BufferStdin() *bufio.Reader {
return currentStdin
}

// OverrideStdin allows to temporarily override stdin
func OverrideStdin(newStdin *bufio.Reader) (cleanUp func()) {
prevStdin := currentStdin
currentStdin = newStdin
cleanUp = func() {
currentStdin = prevStdin
}
return cleanUp
}

// GetPassword will prompt for a password one-time (to sign a tx)
// It enforces the password length
func GetPassword(prompt string, buf *bufio.Reader) (pass string, err error) {
Expand Down
Loading