├── vendor-deps ├── docs ├── concepts │ ├── keeper.md │ ├── store │ │ └── README.md │ ├── tx-lifecycle.md │ ├── handler.md │ ├── querier.md │ ├── encoding.md │ ├── genesis.md │ ├── interfaces.md │ ├── module-interfaces.md │ ├── invariants.md │ ├── fees-signature.md │ ├── modules.md │ └── node.md ├── spec │ ├── store │ │ └── README.md │ ├── addresses │ │ └── README.md │ ├── _ics │ │ └── README.md │ ├── _proposals │ │ ├── README.md │ │ └── f1-fee-distribution │ │ │ └── f1_fee_distr.pdf │ ├── bank │ │ ├── 05_params.md │ │ ├── 01_state.md │ │ ├── 03_messages.md │ │ ├── 04_events.md │ │ └── README.md │ ├── reserve-pool │ │ └── TODO.md │ ├── ibc │ │ └── README.md │ ├── supply │ │ ├── 02_state.md │ │ ├── 03_future_improvements.md │ │ └── README.md │ ├── crisis │ │ ├── 04_params.md │ │ ├── 03_events.md │ │ ├── 01_state.md │ │ ├── README.md │ │ └── 02_messages.md │ ├── mint │ │ ├── 05_events.md │ │ ├── README.md │ │ ├── 04_params.md │ │ ├── 02_state.md │ │ └── 01_concepts.md │ ├── staking │ │ ├── 07_params.md │ │ └── 05_hooks.md │ ├── auth │ │ └── 07_params.md │ ├── distribution │ │ ├── 07_params.md │ │ └── 05_hooks.md │ ├── slashing │ │ ├── 08_params.md │ │ ├── 05_hooks.md │ │ └── 06_events.md │ ├── params │ │ ├── 01_keeper.md │ │ └── README.md │ └── circuit-breaker │ │ └── 01_concepts.md ├── translations │ ├── kr │ │ ├── concepts │ │ │ └── store │ │ │ │ └── README.md │ │ ├── cosmos-docs.jpg │ │ ├── clients │ │ │ ├── cli.md │ │ │ ├── lite │ │ │ │ ├── pics │ │ │ │ │ ├── C2H.png │ │ │ │ │ ├── H2C.png │ │ │ │ │ ├── MA.png │ │ │ │ │ ├── absence1.png │ │ │ │ │ ├── absence2.png │ │ │ │ │ ├── absence3.png │ │ │ │ │ ├── deposit.png │ │ │ │ │ ├── transfer.png │ │ │ │ │ ├── withdraw.png │ │ │ │ │ ├── existProof.png │ │ │ │ │ ├── high-level.png │ │ │ │ │ ├── architecture.png │ │ │ │ │ ├── changeProcess.png │ │ │ │ │ ├── substoreProof.png │ │ │ │ │ ├── commitValidation.png │ │ │ │ │ ├── create-account.png │ │ │ │ │ ├── simpleMerkleTree.png │ │ │ │ │ ├── transfer-tokens.png │ │ │ │ │ ├── trustPropagate.png │ │ │ │ │ ├── loadbalanceDiagram.png │ │ │ │ │ ├── validatorSetChange.png │ │ │ │ │ ├── updateValidatorToHeight.png │ │ │ │ │ └── light-client-architecture.png │ │ │ │ └── getting_started.md │ │ │ └── README.md │ │ └── cosmos-sdk-image.png │ └── cn │ │ ├── clients │ │ ├── cli.md │ │ ├── README.md │ │ └── lite │ │ │ └── getting_started.md │ │ └── README.md ├── cosmos-sdk-image.jpg ├── clients │ ├── lite │ │ └── pics │ │ │ ├── MA.png │ │ │ ├── C2H.png │ │ │ ├── H2C.png │ │ │ ├── deposit.png │ │ │ ├── absence1.png │ │ │ ├── absence2.png │ │ │ ├── absence3.png │ │ │ ├── transfer.png │ │ │ ├── withdraw.png │ │ │ ├── architecture.png │ │ │ ├── existProof.png │ │ │ ├── high-level.png │ │ │ ├── changeProcess.png │ │ │ ├── create-account.png │ │ │ ├── substoreProof.png │ │ │ ├── trustPropagate.png │ │ │ ├── commitValidation.png │ │ │ ├── simpleMerkleTree.png │ │ │ ├── transfer-tokens.png │ │ │ ├── loadbalanceDiagram.png │ │ │ ├── validatorSetChange.png │ │ │ ├── updateValidatorToHeight.png │ │ │ └── light-client-architecture.png │ ├── cli.md │ └── README.md └── .vuepress │ ├── enhanceApp.js │ └── override.styl ├── .gitattributes ├── crypto ├── keys │ ├── keys.toml │ ├── keys.go │ ├── codec.go │ └── mintkey │ │ └── mintkey_bench_test.go ├── amino.go ├── ledger_notavail.go └── ledger_real.go ├── .dockerignore ├── .pending ├── features │ ├── sdk │ │ ├── 4271-Implement-Coins │ │ ├── 4144-Configurable-Be │ │ ├── 4250-New-BaseApp-Set │ │ ├── 3850-Add-rewards-and-commission-to-distribution-tx-tags │ │ ├── Community-pool-spend │ │ ├── 4570-Move-bank-balan │ │ ├── 4318-Support-height- │ │ ├── 4263-Add---read-time │ │ ├── 3981-Add-support-to-gracefully-halt-a-node-at-a-given-height │ │ ├── 2020-New-keys-export │ │ ├── 3565-Implement-parameter-change-proposal-support │ │ └── 4409-migration-scrip │ └── gaia │ │ └── 4373-Don-t-Burn-Depo ├── improvements │ ├── sdk │ │ ├── 4379-close-db-write- │ │ ├── 4556-Added-IsValid-f │ │ ├── 4501-Support-height- │ │ ├── 4439-add-governance- │ │ ├── 2286-Improve-perform │ │ ├── 4465-Unknown-subcomm │ │ ├── 3512-Implement-Logge │ │ ├── 4573-adds-height-in- │ │ ├── 4595-supply-queriers │ │ ├── Remove---print-respo │ │ ├── 3655-Improve-signatu │ │ ├── 3774-add-category-tag │ │ ├── 4235-Add-parameter-c │ │ ├── 4415-clienr-refactor │ │ ├── 4553-undelegate-max-entries-check-first │ │ ├── 4384-WithdrawalTxSplitting │ │ ├── 4564-Allow-empty-ans │ │ ├── 4629-Added-event-that-get │ │ ├── 4194-ValidatorSignin │ │ ├── 4305-The---generate- │ │ ├── 4676-expose-simapp-f │ │ ├── 4536-cli-context-que │ │ ├── 4580-remove-block-he │ │ ├── 4190-Client-response │ │ ├── 4601-Implement-gener │ │ ├── 4535-improve-sim-err │ │ ├── Revert-2284-https-gi │ │ ├── 3914-Implement-invariant-benchmarks-and-add-target-to-makefile │ │ ├── 3928-remove-types-staking │ │ ├── 4466-Commission-vali │ │ ├── 3978-Return-ErrUnknownRequest-in-message-handlers-for-unknown │ │ ├── 4259-Coins-that-are- │ │ ├── 4235-Update-the-mint │ │ ├── 4584-Update-bank-Kee │ │ ├── 4403-parameter-chang │ │ ├── Add-SetAddressVerifi │ │ ├── Add-an-additional-pa │ │ └── 4706-Simplify-context │ └── tendermint │ │ ├── Upgrade-tendermint-i │ │ ├── Upgrade-tendermint-t │ │ └── 4290-Upgrade-tenderm ├── bugfixes │ └── sdk │ │ ├── 4362-simulation-setu │ │ ├── 4654-validator-slash │ │ ├── 4273-Fix-usage-of-Ap │ │ ├── 4455-Print-null-whil │ │ ├── 4194-Fix-pagination- │ │ ├── 4303-Fix-NewCoins-un │ │ ├── 4230-Properly-set-an │ │ ├── 4271-Fix-addGenesisA │ │ ├── 4383---currentStakeR │ │ ├── 4394-Fix-signature-c │ │ ├── 1351-https-github-co │ │ ├── 4598-fix-check-bond- │ │ ├── 4493-Fix-validator-o │ │ ├── 4681-mint-check │ │ ├── 4619-Close-iterators │ │ ├── 3705-Return-instead-of-null-when-querying-delegator-rewards │ │ ├── 4234-https-github-co │ │ ├── 3966-fixed-multiple- │ │ └── 4307-https-github-co └── breaking │ └── sdk │ ├── 4525-Remove---cors-f │ ├── 4649-Refactor-x-cris │ ├── 3775-unify-sender-tag │ ├── 4159-create-the-defa │ ├── 4262-GoSumHash-is-no │ ├── 4521-Flatten-x-bank- │ ├── 4263-RestServer-Star │ ├── 4305-GenerateOrBroad │ ├── 4633-Update-old-Tx-s │ ├── 4104-Gaia-has-been-m │ ├── 4437-bytes-gov-keys │ ├── 3985-ValidatorPowerR │ ├── 4230-Change-the-type │ ├── 4342-https-github-co │ ├── 4104-Rename-gaiad-to │ ├── 4479-Remove-codec-ar │ ├── 4351-AddGenesisAccou │ ├── 4602-client-input-Bu │ ├── 4536-The-auth-accoun │ ├── 4543-Account-getters │ ├── 4488-client-s-tx-res │ ├── 4250-BaseApp-Query-r │ ├── refactor-bank-keeper │ ├── 3565-Updates-to-the-governance-module │ ├── 4588-Context-does-no │ ├── 4451-Improve-modular │ ├── The-default-signatur │ ├── 3972-supply │ └── 4387-Refactor-the-us ├── x ├── mock │ └── doc.go ├── crisis │ ├── internal │ │ ├── types │ │ │ ├── keys.go │ │ │ ├── events.go │ │ │ ├── expected_keepers.go │ │ │ ├── codec.go │ │ │ ├── params.go │ │ │ ├── route.go │ │ │ ├── errors.go │ │ │ └── genesis.go │ │ └── keeper │ │ │ └── params.go │ ├── abci.go │ └── genesis.go ├── slashing │ ├── client │ │ ├── cli │ │ │ └── flags.go │ │ └── rest │ │ │ └── rest.go │ ├── types │ │ ├── codec.go │ │ ├── msg_test.go │ │ ├── events.go │ │ ├── querier.go │ │ └── msg.go │ ├── querier_test.go │ └── simulation │ │ └── msgs.go ├── bank │ ├── internal │ │ ├── types │ │ │ ├── key.go │ │ │ ├── events.go │ │ │ ├── querier.go │ │ │ ├── codec.go │ │ │ ├── params.go │ │ │ ├── expected_keepers.go │ │ │ └── errors.go │ │ └── keeper │ │ │ └── invariants.go │ ├── handler_test.go │ └── genesis.go ├── params │ ├── types │ │ ├── keys.go │ │ └── codec.go │ ├── client │ │ └── proposal_handler.go │ └── subspace │ │ ├── paramset.go │ │ ├── doc.go │ │ └── table_test.go ├── auth │ ├── client │ │ ├── utils │ │ │ └── errors.go │ │ ├── cli │ │ │ └── tx.go │ │ └── rest │ │ │ └── rest.go │ ├── types │ │ ├── params_test.go │ │ ├── expected_keepers.go │ │ ├── querier.go │ │ ├── stdsignmsg.go │ │ ├── keys.go │ │ └── codec.go │ └── genesis.go ├── genaccounts │ ├── codec.go │ ├── doc.go │ ├── expected.go │ ├── init.go │ └── export.go ├── mint │ ├── internal │ │ └── types │ │ │ ├── codec.go │ │ │ ├── events.go │ │ │ ├── keys.go │ │ │ └── expected_keepers.go │ └── client │ │ └── rest │ │ └── rest.go ├── supply │ ├── exported │ │ └── exported.go │ ├── internal │ │ ├── types │ │ │ ├── key.go │ │ │ ├── genesis.go │ │ │ ├── codec.go │ │ │ ├── supply_test.go │ │ │ ├── querier.go │ │ │ └── expected_keepers.go │ │ └── keeper │ │ │ ├── key.go │ │ │ └── keeper_test.go │ └── genesis.go ├── staking │ ├── client │ │ ├── rest │ │ │ └── rest.go │ │ └── cli │ │ │ └── utils.go │ ├── types │ │ ├── params_test.go │ │ ├── test_utils.go │ │ ├── codec.go │ │ └── events.go │ └── keeper │ │ └── keeper_test.go ├── genutil │ ├── doc.go │ ├── types.go │ ├── gentx_test.go │ ├── utils_test.go │ ├── init.go │ ├── codec.go │ └── expected.go ├── distribution │ ├── client │ │ ├── proposal_handler.go │ │ ├── rest │ │ │ └── utils.go │ │ ├── common │ │ │ └── common_test.go │ │ └── cli │ │ │ └── utils.go │ ├── types │ │ ├── fee_pool_test.go │ │ ├── keys.go │ │ ├── events.go │ │ ├── fee_pool.go │ │ ├── codec.go │ │ ├── test_common.go │ │ └── delegator.go │ └── keeper │ │ ├── proposal_handler.go │ │ ├── alias_functions.go │ │ └── fee_pool.go ├── gov │ ├── handler_test.go │ ├── types │ │ ├── proposals_test.go │ │ ├── events.go │ │ └── codec.go │ └── client │ │ ├── proposal_handler.go │ │ └── cli │ │ └── parse.go └── simulation │ └── event_stats.go ├── client ├── lcd │ ├── swagger-ui │ │ ├── favicon-16x16.png │ │ └── favicon-32x32.png │ └── statik │ │ └── init.go ├── routes.go ├── keys │ ├── root_test.go │ ├── codec.go │ ├── parse_test.go │ ├── list.go │ ├── export_test.go │ ├── root.go │ ├── import.go │ ├── update.go │ ├── export.go │ └── import_test.go ├── utils.go ├── context │ └── errors.go └── cmd.go ├── store ├── iavl │ └── wire.go ├── rootmulti │ ├── wire.go │ └── dbadapter.go ├── types │ ├── validity.go │ └── pruning.go ├── transient │ ├── store_test.go │ └── store.go ├── store.go ├── errors │ └── errors.go ├── dbadapter │ └── store.go └── firstlast.go ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── bug-report.md │ └── feature-request.md └── PULL_REQUEST_TEMPLATE.md ├── .clog.yaml ├── tests ├── knownValues.go ├── test_cover.sh ├── io.go └── mocks │ └── account_retriever.go ├── types ├── bytes.go ├── codec.go ├── queryable.go ├── router.go ├── handler.go ├── module │ └── module_test.go ├── result_test.go ├── invariant.go ├── store_test.go └── abci.go ├── baseapp ├── doc.go ├── router_test.go ├── queryrouter_test.go ├── helpers.go ├── router.go └── queryrouter.go ├── scripts ├── README.md └── install │ ├── install_sdk_arm.sh │ └── install_sdk_ubuntu.sh ├── server ├── config │ └── config_test.go ├── constructors_test.go ├── mock │ ├── store_test.go │ └── helpers.go └── util_test.go ├── .golangci.yml ├── .gitignore ├── .codecov.yml ├── simapp ├── genesis.go └── app_test.go ├── contrib ├── devtools │ └── install-golangci-lint.sh └── migrate │ └── lib.py └── version └── command.go /vendor-deps: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/concepts/keeper.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/spec/store/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/concepts/store/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/concepts/tx-lifecycle.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/concepts/handler.md: -------------------------------------------------------------------------------- 1 | # Handlers -------------------------------------------------------------------------------- /docs/concepts/querier.md: -------------------------------------------------------------------------------- 1 | # Queriers 2 | 3 | TODO -------------------------------------------------------------------------------- /docs/translations/kr/concepts/store/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/concepts/encoding.md: -------------------------------------------------------------------------------- 1 | # Encoding 2 | 3 | TODO -------------------------------------------------------------------------------- /docs/concepts/genesis.md: -------------------------------------------------------------------------------- 1 | # Genesis File 2 | 3 | TODO -------------------------------------------------------------------------------- /docs/concepts/interfaces.md: -------------------------------------------------------------------------------- 1 | # Interfaces 2 | 3 | TODO -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | client/lcd/swagger-ui/* linguist-vendored 2 | -------------------------------------------------------------------------------- /crypto/keys/keys.toml: -------------------------------------------------------------------------------- 1 | output = "text" 2 | keydir = ".mykeys" 3 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | Dockerfile 2 | Vagrantfile 3 | 4 | build/ 5 | coverage.txt 6 | -------------------------------------------------------------------------------- /.pending/features/sdk/4271-Implement-Coins: -------------------------------------------------------------------------------- 1 | #4271 Implement Coins#IsAnyGT 2 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/4379-close-db-write-: -------------------------------------------------------------------------------- 1 | #4379 close db write batch. 2 | -------------------------------------------------------------------------------- /docs/spec/addresses/README.md: -------------------------------------------------------------------------------- 1 | # Addresses spec 2 | 3 | - [Bech32](./bech32.md) -------------------------------------------------------------------------------- /.pending/improvements/sdk/4556-Added-IsValid-f: -------------------------------------------------------------------------------- 1 | #4556 Added IsValid function to Coin -------------------------------------------------------------------------------- /docs/concepts/module-interfaces.md: -------------------------------------------------------------------------------- 1 | # Module Interfaces 2 | 3 | ## CLI 4 | 5 | ## REST -------------------------------------------------------------------------------- /.pending/bugfixes/sdk/4362-simulation-setu: -------------------------------------------------------------------------------- 1 | #4362 simulation setup bugfix for multisim 7601778 -------------------------------------------------------------------------------- /.pending/improvements/sdk/4501-Support-height-: -------------------------------------------------------------------------------- 1 | #4501 Support height queriers in rest client -------------------------------------------------------------------------------- /.pending/improvements/tendermint/Upgrade-tendermint-i: -------------------------------------------------------------------------------- 1 | #4718 Upgrade tendermint/iavl to v0.12.3 -------------------------------------------------------------------------------- /.pending/improvements/tendermint/Upgrade-tendermint-t: -------------------------------------------------------------------------------- 1 | #4138 Upgrade tendermint to v0.31.5 2 | -------------------------------------------------------------------------------- /.pending/breaking/sdk/4525-Remove---cors-f: -------------------------------------------------------------------------------- 1 | #4525 Remove --cors flag, the feature is long gone. 2 | -------------------------------------------------------------------------------- /.pending/breaking/sdk/4649-Refactor-x-cris: -------------------------------------------------------------------------------- 1 | #4649 Refactor x/crisis as per modules new specs. 2 | -------------------------------------------------------------------------------- /.pending/bugfixes/sdk/4654-validator-slash: -------------------------------------------------------------------------------- 1 | #4654 validator slash event stored by period and height -------------------------------------------------------------------------------- /.pending/improvements/sdk/4439-add-governance-: -------------------------------------------------------------------------------- 1 | #4439 Implement governance module iterators. 2 | -------------------------------------------------------------------------------- /.pending/improvements/tendermint/4290-Upgrade-tenderm: -------------------------------------------------------------------------------- 1 | #4290 Upgrade tendermint/iavl to v0.12.2 2 | -------------------------------------------------------------------------------- /.pending/breaking/sdk/3775-unify-sender-tag: -------------------------------------------------------------------------------- 1 | #3775 unify sender transaction tag for ease of querying 2 | -------------------------------------------------------------------------------- /.pending/breaking/sdk/4159-create-the-defa: -------------------------------------------------------------------------------- 1 | #4159 create the default module patterns and module manager -------------------------------------------------------------------------------- /.pending/bugfixes/sdk/4273-Fix-usage-of-Ap: -------------------------------------------------------------------------------- 1 | #4273 Fix usage of AppendTags in x/staking/handler.go 2 | -------------------------------------------------------------------------------- /.pending/bugfixes/sdk/4455-Print-null-whil: -------------------------------------------------------------------------------- 1 | #4455 Use `QueryWithData()` to query unbonding delegations. -------------------------------------------------------------------------------- /.pending/improvements/sdk/2286-Improve-perform: -------------------------------------------------------------------------------- 1 | #2286 Improve performance of CacheKVStore iterator. 2 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/4465-Unknown-subcomm: -------------------------------------------------------------------------------- 1 | #4465 Unknown subcommands print relevant error message -------------------------------------------------------------------------------- /docs/concepts/invariants.md: -------------------------------------------------------------------------------- 1 | # Invariants 2 | 3 | ## What is an invariant 4 | 5 | ## Invariant Registry -------------------------------------------------------------------------------- /.pending/breaking/sdk/4262-GoSumHash-is-no: -------------------------------------------------------------------------------- 1 | #4262 GoSumHash is no longer returned by the version command. 2 | -------------------------------------------------------------------------------- /.pending/breaking/sdk/4521-Flatten-x-bank-: -------------------------------------------------------------------------------- 1 | #4521 Flatten x/bank structure by hiding module internals. 2 | -------------------------------------------------------------------------------- /.pending/features/sdk/4144-Configurable-Be: -------------------------------------------------------------------------------- 1 | #4144 Allow for configurable BIP44 HD path and coin type. 2 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/3512-Implement-Logge: -------------------------------------------------------------------------------- 1 | #3512 Implement Logger method on each module's keeper. 2 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/4573-adds-height-in-: -------------------------------------------------------------------------------- 1 | #4573 Returns height in response for query endpoints. 2 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/4595-supply-queriers: -------------------------------------------------------------------------------- 1 | #4082 supply module queriers for CLI and REST endpoints 2 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/Remove---print-respo: -------------------------------------------------------------------------------- 1 | Remove `--print-response` flag as it is no longer used. 2 | -------------------------------------------------------------------------------- /docs/concepts/fees-signature.md: -------------------------------------------------------------------------------- 1 | # Fees and Signatures 2 | 3 | ## Signatures 4 | 5 | ## Fees 6 | 7 | ## Gas -------------------------------------------------------------------------------- /docs/cosmos-sdk-image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/cosmos-sdk-image.jpg -------------------------------------------------------------------------------- /docs/spec/_ics/README.md: -------------------------------------------------------------------------------- 1 | # Cosmos ICS 2 | 3 | - [ICS030 - Signed Messages](./ics-030-signed-messages.md) -------------------------------------------------------------------------------- /.pending/breaking/sdk/4263-RestServer-Star: -------------------------------------------------------------------------------- 1 | #4263 RestServer#Start now takes read and write timeout arguments. 2 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/3655-Improve-signatu: -------------------------------------------------------------------------------- 1 | #3655 Improve signature verification failure error message. 2 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/3774-add-category-tag: -------------------------------------------------------------------------------- 1 | #3774 add category tag to transactions for ease of filtering 2 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/4235-Add-parameter-c: -------------------------------------------------------------------------------- 1 | #4235 Add parameter change proposal messages to simulation. 2 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/4415-clienr-refactor: -------------------------------------------------------------------------------- 1 | #4415 /client refactor, reduce genutil dependancy on staking 2 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/4553-undelegate-max-entries-check-first: -------------------------------------------------------------------------------- 1 | #4553 undelegate max entries check first 2 | -------------------------------------------------------------------------------- /docs/clients/lite/pics/MA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/clients/lite/pics/MA.png -------------------------------------------------------------------------------- /x/mock/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package mock provides utility methods to ease writing tests. 3 | */ 4 | package mock 5 | -------------------------------------------------------------------------------- /.pending/breaking/sdk/4305-GenerateOrBroad: -------------------------------------------------------------------------------- 1 | #4305 `GenerateOrBroadcastMsgs` no longer takes an `offline` parameter. 2 | -------------------------------------------------------------------------------- /.pending/bugfixes/sdk/4194-Fix-pagination-: -------------------------------------------------------------------------------- 1 | #4194 Fix pagination and results returned from /slashing/signing_infos 2 | -------------------------------------------------------------------------------- /.pending/bugfixes/sdk/4303-Fix-NewCoins-un: -------------------------------------------------------------------------------- 1 | #4303 Fix NewCoins() underlying function for duplicate coins detection. 2 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/4384-WithdrawalTxSplitting: -------------------------------------------------------------------------------- 1 | #4384- Allow splitting withdrawal transaction in several chunks -------------------------------------------------------------------------------- /.pending/improvements/sdk/4564-Allow-empty-ans: -------------------------------------------------------------------------------- 1 | #4564 client/input.GetConfirmation()'s default is changed to No. 2 | -------------------------------------------------------------------------------- /docs/clients/cli.md: -------------------------------------------------------------------------------- 1 | # CLI 2 | 3 | > TODO: Rewrite this section to explain how CLI works for a generic SDK app. 4 | -------------------------------------------------------------------------------- /docs/clients/lite/pics/C2H.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/clients/lite/pics/C2H.png -------------------------------------------------------------------------------- /docs/clients/lite/pics/H2C.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/clients/lite/pics/H2C.png -------------------------------------------------------------------------------- /.pending/breaking/sdk/4633-Update-old-Tx-s: -------------------------------------------------------------------------------- 1 | #4633 Update old Tx search by tags APIs to use new Events 2 | nomenclature. 3 | -------------------------------------------------------------------------------- /.pending/bugfixes/sdk/4230-Properly-set-an: -------------------------------------------------------------------------------- 1 | #4230 Properly set and display the message index through the TxResponse. 2 | -------------------------------------------------------------------------------- /.pending/features/gaia/4373-Don-t-Burn-Depo: -------------------------------------------------------------------------------- 1 | #4373 Don't burn deposits for rejected governance proposals unless vetoed. 2 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/4629-Added-event-that-get: -------------------------------------------------------------------------------- 1 | #4629 Added warning event that gets emitted if validator misses a block. -------------------------------------------------------------------------------- /docs/clients/lite/pics/deposit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/clients/lite/pics/deposit.png -------------------------------------------------------------------------------- /docs/spec/_proposals/README.md: -------------------------------------------------------------------------------- 1 | # Spec Proposals 2 | 3 | - [F1 Fee Distribution](./f1-fee-distribution/f1_fee_distr.pdf) -------------------------------------------------------------------------------- /x/crisis/internal/types/keys.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | const ( 4 | // module name 5 | ModuleName = "crisis" 6 | ) 7 | -------------------------------------------------------------------------------- /x/slashing/client/cli/flags.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | // nolint 4 | const ( 5 | FlagAddressValidator = "validator" 6 | ) 7 | -------------------------------------------------------------------------------- /.pending/breaking/sdk/4104-Gaia-has-been-m: -------------------------------------------------------------------------------- 1 | #4104 Gaia has been moved to its own repository: https://github.com/cosmos/gaia 2 | -------------------------------------------------------------------------------- /.pending/breaking/sdk/4437-bytes-gov-keys: -------------------------------------------------------------------------------- 1 | #4437 Replace governance module store keys to use `[]byte` instead of `string`. 2 | -------------------------------------------------------------------------------- /.pending/bugfixes/sdk/4271-Fix-addGenesisA: -------------------------------------------------------------------------------- 1 | #4271 Fix addGenesisAccount by using Coins#IsAnyGT for vesting amount validation. 2 | -------------------------------------------------------------------------------- /.pending/features/sdk/4250-New-BaseApp-Set: -------------------------------------------------------------------------------- 1 | #4250 New BaseApp.{,Set}AppVersion() methods to get/set app's version string. 2 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/4194-ValidatorSignin: -------------------------------------------------------------------------------- 1 | #4194 ValidatorSigningInfo now includes the validator's consensus address. 2 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/4305-The---generate-: -------------------------------------------------------------------------------- 1 | #4305 The `--generate-only` CLI flag fully respects offline tx processing. 2 | -------------------------------------------------------------------------------- /docs/clients/lite/pics/absence1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/clients/lite/pics/absence1.png -------------------------------------------------------------------------------- /docs/clients/lite/pics/absence2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/clients/lite/pics/absence2.png -------------------------------------------------------------------------------- /docs/clients/lite/pics/absence3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/clients/lite/pics/absence3.png -------------------------------------------------------------------------------- /docs/clients/lite/pics/transfer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/clients/lite/pics/transfer.png -------------------------------------------------------------------------------- /docs/clients/lite/pics/withdraw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/clients/lite/pics/withdraw.png -------------------------------------------------------------------------------- /docs/translations/kr/cosmos-docs.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/translations/kr/cosmos-docs.jpg -------------------------------------------------------------------------------- /.pending/breaking/sdk/3985-ValidatorPowerR: -------------------------------------------------------------------------------- 1 | #3985 `ValidatorPowerRank` uses potential consensus power instead of tendermint power 2 | -------------------------------------------------------------------------------- /.pending/breaking/sdk/4230-Change-the-type: -------------------------------------------------------------------------------- 1 | #4230 Change the type of ABCIMessageLog#MsgIndex to uint16 for proper serialization. 2 | -------------------------------------------------------------------------------- /.pending/breaking/sdk/4342-https-github-co: -------------------------------------------------------------------------------- 1 | [#4342](https://github.com/cosmos/cosmos-sdk/pull/4342) Upgrade go-amino to v0.15.0 2 | -------------------------------------------------------------------------------- /.pending/bugfixes/sdk/4383---currentStakeR: -------------------------------------------------------------------------------- 1 | #4383 - currentStakeRoundUp is now always atleast currentStake + smallest-decimal-precision -------------------------------------------------------------------------------- /.pending/bugfixes/sdk/4394-Fix-signature-c: -------------------------------------------------------------------------------- 1 | #4394 Fix signature count check to use the TxSigLimit param instead of 2 | a default. 3 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/4676-expose-simapp-f: -------------------------------------------------------------------------------- 1 | #4674 Export `Simapp` genState generators and util functions by making them public 2 | -------------------------------------------------------------------------------- /client/lcd/swagger-ui/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/client/lcd/swagger-ui/favicon-16x16.png -------------------------------------------------------------------------------- /client/lcd/swagger-ui/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/client/lcd/swagger-ui/favicon-32x32.png -------------------------------------------------------------------------------- /docs/clients/lite/pics/architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/clients/lite/pics/architecture.png -------------------------------------------------------------------------------- /docs/clients/lite/pics/existProof.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/clients/lite/pics/existProof.png -------------------------------------------------------------------------------- /docs/clients/lite/pics/high-level.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/clients/lite/pics/high-level.png -------------------------------------------------------------------------------- /docs/translations/kr/clients/cli.md: -------------------------------------------------------------------------------- 1 | # CLI 2 | 3 | > TODO: Rewrite this section to explain how CLI works for a generic SDK app. 4 | -------------------------------------------------------------------------------- /store/iavl/wire.go: -------------------------------------------------------------------------------- 1 | package iavl 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/codec" 5 | ) 6 | 7 | var cdc = codec.New() 8 | -------------------------------------------------------------------------------- /.pending/bugfixes/sdk/1351-https-github-co: -------------------------------------------------------------------------------- 1 | [\#1351](https://github.com/cosmos/cosmos-sdk/issues/1351) Stable AppHash allows no_empty_blocks -------------------------------------------------------------------------------- /.pending/improvements/sdk/4536-cli-context-que: -------------------------------------------------------------------------------- 1 | #4536 cli context queries return query height and accounts are returned with query height -------------------------------------------------------------------------------- /docs/.vuepress/enhanceApp.js: -------------------------------------------------------------------------------- 1 | export default ({ router }) => { 2 | router.addRoutes([{ path: "/testnet/", redirect: "/" }]) 3 | } 4 | -------------------------------------------------------------------------------- /docs/.vuepress/override.styl: -------------------------------------------------------------------------------- 1 | $accentColor = #304DE9 2 | $textColor = #15192C 3 | $borderColor = #eaecef 4 | $codeBgColor = #282c34 5 | -------------------------------------------------------------------------------- /docs/clients/lite/pics/changeProcess.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/clients/lite/pics/changeProcess.png -------------------------------------------------------------------------------- /docs/clients/lite/pics/create-account.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/clients/lite/pics/create-account.png -------------------------------------------------------------------------------- /docs/clients/lite/pics/substoreProof.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/clients/lite/pics/substoreProof.png -------------------------------------------------------------------------------- /docs/clients/lite/pics/trustPropagate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/clients/lite/pics/trustPropagate.png -------------------------------------------------------------------------------- /docs/translations/cn/clients/cli.md: -------------------------------------------------------------------------------- 1 | # CLI 2 | 3 | > TODO: Rewrite this section to explain how CLI works for a generic SDK app. 4 | 5 | -------------------------------------------------------------------------------- /docs/translations/kr/cosmos-sdk-image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/translations/kr/cosmos-sdk-image.png -------------------------------------------------------------------------------- /.pending/bugfixes/sdk/4598-fix-check-bond-: -------------------------------------------------------------------------------- 1 | #4598 Fix redelegation and undelegation txs that were not checking for the correct bond denomination. -------------------------------------------------------------------------------- /.pending/features/sdk/3850-Add-rewards-and-commission-to-distribution-tx-tags: -------------------------------------------------------------------------------- 1 | #3850 Add `rewards` and `commission` to distribution tx tags. 2 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/4580-remove-block-he: -------------------------------------------------------------------------------- 1 | #4580 Update `Context#BlockHeight` to properly set the block height via `WithBlockHeader`. 2 | -------------------------------------------------------------------------------- /docs/clients/lite/pics/commitValidation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/clients/lite/pics/commitValidation.png -------------------------------------------------------------------------------- /docs/clients/lite/pics/simpleMerkleTree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/clients/lite/pics/simpleMerkleTree.png -------------------------------------------------------------------------------- /docs/clients/lite/pics/transfer-tokens.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/clients/lite/pics/transfer-tokens.png -------------------------------------------------------------------------------- /store/rootmulti/wire.go: -------------------------------------------------------------------------------- 1 | package rootmulti 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/codec" 5 | ) 6 | 7 | var cdc = codec.New() 8 | -------------------------------------------------------------------------------- /.pending/bugfixes/sdk/4493-Fix-validator-o: -------------------------------------------------------------------------------- 1 | #4493 Fix validator-outstanding-rewards command. It now takes as an argument 2 | a validator address. 3 | -------------------------------------------------------------------------------- /.pending/bugfixes/sdk/4681-mint-check: -------------------------------------------------------------------------------- 1 | #4681 panic on invalid amount on `MintCoins` and `BurnCoins` 2 | - skip minting if inflation is set to zero -------------------------------------------------------------------------------- /.pending/features/sdk/Community-pool-spend: -------------------------------------------------------------------------------- 1 | Community pool spend proposal per Cosmos Hub governance proposal #7 "Activate the Community Pool" 2 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/4190-Client-response: -------------------------------------------------------------------------------- 1 | #4190 Client responses that return (re)delegation(s) now return balances 2 | instead of shares. 3 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/4601-Implement-gener: -------------------------------------------------------------------------------- 1 | #4601 Implement generic pangination helper function to be used in 2 | REST handlers and queriers. 3 | -------------------------------------------------------------------------------- /docs/clients/lite/pics/loadbalanceDiagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/clients/lite/pics/loadbalanceDiagram.png -------------------------------------------------------------------------------- /docs/clients/lite/pics/validatorSetChange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/clients/lite/pics/validatorSetChange.png -------------------------------------------------------------------------------- /docs/translations/kr/clients/lite/pics/C2H.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/translations/kr/clients/lite/pics/C2H.png -------------------------------------------------------------------------------- /docs/translations/kr/clients/lite/pics/H2C.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/translations/kr/clients/lite/pics/H2C.png -------------------------------------------------------------------------------- /docs/translations/kr/clients/lite/pics/MA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/translations/kr/clients/lite/pics/MA.png -------------------------------------------------------------------------------- /x/bank/internal/types/key.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | const ( 4 | // module name 5 | ModuleName = "bank" 6 | QuerierRoute = ModuleName 7 | ) 8 | -------------------------------------------------------------------------------- /.pending/breaking/sdk/4104-Rename-gaiad-to: -------------------------------------------------------------------------------- 1 | #4104 Rename gaiad.toml to app.toml. The internal contents of the application 2 | config remain unchanged. 3 | -------------------------------------------------------------------------------- /.pending/bugfixes/sdk/4619-Close-iterators: -------------------------------------------------------------------------------- 1 | #4619 Close iterators in `GetAllMatureValidatorQueue` and `UnbondAllMatureValidatorQueue` 2 | methods. 3 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/4535-improve-sim-err: -------------------------------------------------------------------------------- 1 | #4535 Improve import-export simulation errors by decoding the `KVPair.Value` into its 2 | respective type -------------------------------------------------------------------------------- /.pending/improvements/sdk/Revert-2284-https-gi: -------------------------------------------------------------------------------- 1 | Revert (#2284)[https://github.com/cosmos/cosmos-sdk/pull/2284] to allow create_empty_blocks in the config -------------------------------------------------------------------------------- /client/lcd/statik/init.go: -------------------------------------------------------------------------------- 1 | package statik 2 | 3 | //This just for fixing the error in importing empty github.com/cosmos/cosmos-sdk/client/lcd/statik 4 | -------------------------------------------------------------------------------- /.pending/breaking/sdk/4479-Remove-codec-ar: -------------------------------------------------------------------------------- 1 | #4479 Remove codec argument redundency in client usage where 2 | the CLIContext's codec should be used instead. 3 | -------------------------------------------------------------------------------- /.pending/bugfixes/sdk/3705-Return-instead-of-null-when-querying-delegator-rewards: -------------------------------------------------------------------------------- 1 | #3705 Return `[]` instead of `null` when querying delegator rewards. 2 | -------------------------------------------------------------------------------- /.pending/features/sdk/4570-Move-bank-balan: -------------------------------------------------------------------------------- 1 | #4570 Move /bank/balances/{address} REST handler to x/bank/client/rest. The exposed interface is unchanged. 2 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/3914-Implement-invariant-benchmarks-and-add-target-to-makefile: -------------------------------------------------------------------------------- 1 | #3914 Implement invariant benchmarks and add target to makefile. 2 | -------------------------------------------------------------------------------- /docs/clients/lite/pics/updateValidatorToHeight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/clients/lite/pics/updateValidatorToHeight.png -------------------------------------------------------------------------------- /docs/translations/kr/clients/lite/pics/absence1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/translations/kr/clients/lite/pics/absence1.png -------------------------------------------------------------------------------- /docs/translations/kr/clients/lite/pics/absence2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/translations/kr/clients/lite/pics/absence2.png -------------------------------------------------------------------------------- /docs/translations/kr/clients/lite/pics/absence3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/translations/kr/clients/lite/pics/absence3.png -------------------------------------------------------------------------------- /docs/translations/kr/clients/lite/pics/deposit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/translations/kr/clients/lite/pics/deposit.png -------------------------------------------------------------------------------- /docs/translations/kr/clients/lite/pics/transfer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/translations/kr/clients/lite/pics/transfer.png -------------------------------------------------------------------------------- /docs/translations/kr/clients/lite/pics/withdraw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/translations/kr/clients/lite/pics/withdraw.png -------------------------------------------------------------------------------- /.pending/features/sdk/4318-Support-height-: -------------------------------------------------------------------------------- 1 | #4318 Support height queries. Queries against nodes that have the queried 2 | height pruned will return an error. 3 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/3928-remove-types-staking: -------------------------------------------------------------------------------- 1 | #3928 remove staking references from types package 2 | #1528 define local module interfaces instead of /types -------------------------------------------------------------------------------- /docs/clients/lite/pics/light-client-architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/clients/lite/pics/light-client-architecture.png -------------------------------------------------------------------------------- /docs/concepts/modules.md: -------------------------------------------------------------------------------- 1 | # SDK Modules 2 | 3 | Todo: Intro concept docs on modules 4 | 5 | ## Application Module Interface 6 | 7 | ## Module Manager 8 | 9 | -------------------------------------------------------------------------------- /docs/translations/kr/clients/lite/pics/existProof.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/translations/kr/clients/lite/pics/existProof.png -------------------------------------------------------------------------------- /docs/translations/kr/clients/lite/pics/high-level.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/translations/kr/clients/lite/pics/high-level.png -------------------------------------------------------------------------------- /.pending/breaking/sdk/4351-AddGenesisAccou: -------------------------------------------------------------------------------- 1 | #4351 InitCmd, AddGenesisAccountCmd, and CollectGenTxsCmd take node's and client's default home directories as arguments. 2 | -------------------------------------------------------------------------------- /.pending/breaking/sdk/4602-client-input-Bu: -------------------------------------------------------------------------------- 1 | #4602 client/input.{Buffer,Override}Stdin() functions are removed. Thanks to cobra's new release they are now redundant. 2 | -------------------------------------------------------------------------------- /.pending/bugfixes/sdk/4234-https-github-co: -------------------------------------------------------------------------------- 1 | [#4234](https://github.com/cosmos/cosmos-sdk/pull/4234) Allow `tx send --generate-only` to 2 | actually work offline. 3 | -------------------------------------------------------------------------------- /docs/translations/kr/clients/lite/pics/architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/translations/kr/clients/lite/pics/architecture.png -------------------------------------------------------------------------------- /docs/translations/kr/clients/lite/pics/changeProcess.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/translations/kr/clients/lite/pics/changeProcess.png -------------------------------------------------------------------------------- /docs/translations/kr/clients/lite/pics/substoreProof.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/translations/kr/clients/lite/pics/substoreProof.png -------------------------------------------------------------------------------- /.pending/breaking/sdk/4536-The-auth-accoun: -------------------------------------------------------------------------------- 1 | #4536 The `/auth/accounts/{address}` now returns a `height` in the response. 2 | The account is now nested under `account`. 3 | -------------------------------------------------------------------------------- /.pending/features/sdk/4263-Add---read-time: -------------------------------------------------------------------------------- 1 | #4263 Add `--read-timeout` and `--write-timeout` args to the `rest-server` command 2 | to support custom RPC R/W timeouts. 3 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/4466-Commission-vali: -------------------------------------------------------------------------------- 1 | #4466 Commission validation added to validate basic of MsgCreateValidator by changing CommissionMsg to CommissionRates 2 | -------------------------------------------------------------------------------- /docs/spec/_proposals/f1-fee-distribution/f1_fee_distr.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/spec/_proposals/f1-fee-distribution/f1_fee_distr.pdf -------------------------------------------------------------------------------- /docs/translations/kr/clients/lite/pics/commitValidation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/translations/kr/clients/lite/pics/commitValidation.png -------------------------------------------------------------------------------- /docs/translations/kr/clients/lite/pics/create-account.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/translations/kr/clients/lite/pics/create-account.png -------------------------------------------------------------------------------- /docs/translations/kr/clients/lite/pics/simpleMerkleTree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/translations/kr/clients/lite/pics/simpleMerkleTree.png -------------------------------------------------------------------------------- /docs/translations/kr/clients/lite/pics/transfer-tokens.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/translations/kr/clients/lite/pics/transfer-tokens.png -------------------------------------------------------------------------------- /docs/translations/kr/clients/lite/pics/trustPropagate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/translations/kr/clients/lite/pics/trustPropagate.png -------------------------------------------------------------------------------- /docs/translations/kr/clients/lite/pics/loadbalanceDiagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/translations/kr/clients/lite/pics/loadbalanceDiagram.png -------------------------------------------------------------------------------- /docs/translations/kr/clients/lite/pics/validatorSetChange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/translations/kr/clients/lite/pics/validatorSetChange.png -------------------------------------------------------------------------------- /.pending/breaking/sdk/4543-Account-getters: -------------------------------------------------------------------------------- 1 | #4543 Account getters are no longer part of client.CLIContext() and have now moved 2 | to reside in the auth-specific AccountRetriever. 3 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # CODEOWNERS: https://help.github.com/articles/about-codeowners/ 2 | 3 | # Primary repo maintainers 4 | * @rigelrozanski @alexanderbez @jackzampolin @alessio 5 | -------------------------------------------------------------------------------- /.pending/bugfixes/sdk/3966-fixed-multiple-: -------------------------------------------------------------------------------- 1 | #3966 fixed multiple assigns to action tags 2 | #3793 add delegator tag for MsgCreateValidator and deleted unused moniker and identity tags 3 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/3978-Return-ErrUnknownRequest-in-message-handlers-for-unknown: -------------------------------------------------------------------------------- 1 | #3978 Return ErrUnknownRequest in message handlers for unknown 2 | or invalid routed messages. 3 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/4259-Coins-that-are-: -------------------------------------------------------------------------------- 1 | #4259 `Coins` that are `nil` are now JSON encoded as an empty array `[]`. 2 | Decoding remains unchanged and behavior is left intact. 3 | -------------------------------------------------------------------------------- /docs/translations/kr/clients/lite/pics/updateValidatorToHeight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/translations/kr/clients/lite/pics/updateValidatorToHeight.png -------------------------------------------------------------------------------- /.pending/breaking/sdk/4488-client-s-tx-res: -------------------------------------------------------------------------------- 1 | #4488 Decouple client tx, REST, and ultil packages from auth. These packages have 2 | been restructured and retrofitted into the `x/auth` module. 3 | -------------------------------------------------------------------------------- /.pending/bugfixes/sdk/4307-https-github-co: -------------------------------------------------------------------------------- 1 | [#4307](https://github.com/cosmos/cosmos-sdk/pull/4307) Don't pass height to RPC calls as 2 | Tendermint will automatically use the latest height. 3 | -------------------------------------------------------------------------------- /docs/translations/kr/clients/lite/pics/light-client-architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa8x/cosmos-sdk/master/docs/translations/kr/clients/lite/pics/light-client-architecture.png -------------------------------------------------------------------------------- /.clog.yaml: -------------------------------------------------------------------------------- 1 | sections: 2 | breaking: Breaking Changes 3 | features: Features 4 | improvements: Improvements 5 | bugfixes: Bugfixes 6 | 7 | tags: 8 | - sdk 9 | - tendermint 10 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/4235-Update-the-mint: -------------------------------------------------------------------------------- 1 | #4235 Update the minting module params to implement params.ParamSet so 2 | individual keys can be set via proposals instead of passing a struct. 3 | -------------------------------------------------------------------------------- /.pending/features/sdk/3981-Add-support-to-gracefully-halt-a-node-at-a-given-height: -------------------------------------------------------------------------------- 1 | #3981 Add support to gracefully halt a node at a given height 2 | via the node's `halt-height` config or CLI value. 3 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/4584-Update-bank-Kee: -------------------------------------------------------------------------------- 1 | #4584 Update bank Keeper to use expected keeper interface of the AccountKeeper. 2 | #4584 Move `Account` and `VestingAccount` interface types to `x/auth/exported`. 3 | -------------------------------------------------------------------------------- /docs/concepts/node.md: -------------------------------------------------------------------------------- 1 | # Node Client (Daemon) 2 | 3 | ## Pre-Requisite Reading 4 | 5 | ## `main` function 6 | 7 | TODO 8 | 9 | ## `start` command 10 | 11 | TODO 12 | 13 | ## Light-Client Daemon (LCD) 14 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/4403-parameter-chang: -------------------------------------------------------------------------------- 1 | #4403 Allow for parameter change proposals to supply only desired fields to be updated 2 | in objects instead of the entire object (only applies to values that are objects). -------------------------------------------------------------------------------- /docs/spec/bank/05_params.md: -------------------------------------------------------------------------------- 1 | # Parameters 2 | 3 | The bank module contains the following parameters: 4 | 5 | | Key | Type | Example | 6 | |-------------|------|---------| 7 | | sendenabled | bool | true | 8 | 9 | -------------------------------------------------------------------------------- /tests/knownValues.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | const ( 4 | // Tests expect a ledger device initialized to the following mnemonic 5 | TestMnemonic = "equip will roof matter pink blind book anxiety banner elbow sun young" 6 | ) 7 | -------------------------------------------------------------------------------- /.pending/features/sdk/2020-New-keys-export: -------------------------------------------------------------------------------- 1 | #2020 New keys export/import command line utilities to export/import private keys in ASCII format 2 | that rely on Keybase's new underlying ExportPrivKey()/ImportPrivKey() API calls. 3 | -------------------------------------------------------------------------------- /types/bytes.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // copy bytes 4 | func CopyBytes(bz []byte) (ret []byte) { 5 | if bz == nil { 6 | return nil 7 | } 8 | ret = make([]byte, len(bz)) 9 | copy(ret, bz) 10 | return ret 11 | } 12 | -------------------------------------------------------------------------------- /x/crisis/internal/types/events.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // Crisis module event types 4 | var ( 5 | EventTypeInvariant = "invariant" 6 | 7 | AttributeValueCrisis = ModuleName 8 | AttributeKeyRoute = "route" 9 | ) 10 | -------------------------------------------------------------------------------- /.pending/breaking/sdk/4250-BaseApp-Query-r: -------------------------------------------------------------------------------- 1 | #4250 BaseApp.Query() returns app's version string set via BaseApp.SetAppVersion() 2 | when handling /app/version queries instead of the version string passed as build 3 | flag at compile time. 4 | -------------------------------------------------------------------------------- /.pending/breaking/sdk/refactor-bank-keeper: -------------------------------------------------------------------------------- 1 | #4663 Refactor bank keeper by removing private functions 2 | - `InputOutputCoins`, `SetCoins`, `SubtractCoins` and `AddCoins` are now part of the `SendKeeper` instead of the `Keeper` interface 3 | -------------------------------------------------------------------------------- /.pending/features/sdk/3565-Implement-parameter-change-proposal-support: -------------------------------------------------------------------------------- 1 | #3565 Implement parameter change proposal support. 2 | Parameter change proposals can be submitted through the CLI 3 | or a REST endpoint. See docs for further usage. 4 | -------------------------------------------------------------------------------- /x/params/types/keys.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | const ( 4 | // ModuleKey defines the name of the module 5 | ModuleName = "params" 6 | 7 | // RouterKey defines the routing key for a ParameterChangeProposal 8 | RouterKey = "params" 9 | ) 10 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/Add-SetAddressVerifi: -------------------------------------------------------------------------------- 1 | #3685 Add `SetAddressVerifier` and `GetAddressVerifier` to `sdk.Config` to allow SDK users to configure custom address format verification logic (to override the default limitation of 20-byte addresses). 2 | -------------------------------------------------------------------------------- /docs/spec/reserve-pool/TODO.md: -------------------------------------------------------------------------------- 1 | TODO 2 | 3 | The reserve pool is the pool of collected funds for use by governance taken via the `CommunityTax`. 4 | Currently with the SDK, tokens collected by the CommunityTax are accounted for but unspendable. 5 | 6 | -------------------------------------------------------------------------------- /x/auth/client/utils/errors.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import "errors" 4 | 5 | var ( 6 | errInvalidSigner = errors.New("tx intended signer does not match the given signer") 7 | errInvalidGasAdjustment = errors.New("invalid gas adjustment") 8 | ) 9 | -------------------------------------------------------------------------------- /.pending/features/sdk/4409-migration-scrip: -------------------------------------------------------------------------------- 1 | #4409 Implement a command that migrates exported state from one version to the next. 2 | The `migrate` command currently supports migrating from v0.34 to v0.36 by implementing 3 | necessary types for both versions. 4 | -------------------------------------------------------------------------------- /.pending/breaking/sdk/3565-Updates-to-the-governance-module: -------------------------------------------------------------------------------- 1 | #3565 Updates to the governance module: 2 | * Rename JSON field from `proposal_content` to `content` 3 | * Rename JSON field from `proposal_id` to `id` 4 | * Disable `ProposalTypeSoftwareUpgrade` temporarily 5 | -------------------------------------------------------------------------------- /types/codec.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import "github.com/cosmos/cosmos-sdk/codec" 4 | 5 | // Register the sdk message type 6 | func RegisterCodec(cdc *codec.Codec) { 7 | cdc.RegisterInterface((*Msg)(nil), nil) 8 | cdc.RegisterInterface((*Tx)(nil), nil) 9 | } 10 | -------------------------------------------------------------------------------- /x/bank/internal/types/events.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // Bank module event types 4 | var ( 5 | EventTypeTransfer = "transfer" 6 | 7 | AttributeKeyRecipient = "recipient" 8 | AttributeKeySender = "sender" 9 | 10 | AttributeValueCategory = ModuleName 11 | ) 12 | -------------------------------------------------------------------------------- /types/queryable.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import abci "github.com/tendermint/tendermint/abci/types" 4 | 5 | // Type for querier functions on keepers to implement to handle custom queries 6 | type Querier = func(ctx Context, path []string, req abci.RequestQuery) (res []byte, err Error) 7 | -------------------------------------------------------------------------------- /client/routes.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/gorilla/mux" 5 | 6 | "github.com/cosmos/cosmos-sdk/client/context" 7 | ) 8 | 9 | // Register routes 10 | func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router) { 11 | RegisterRPCRoutes(cliCtx, r) 12 | } 13 | -------------------------------------------------------------------------------- /baseapp/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package baseapp contains data structures that provide basic data storage 3 | functionality and act as a bridge between the ABCI interface and the SDK 4 | abstractions. 5 | 6 | BaseApp has no state except the CommitMultiStore you provide upon init. 7 | */ 8 | package baseapp 9 | -------------------------------------------------------------------------------- /docs/spec/ibc/README.md: -------------------------------------------------------------------------------- 1 | # Cosmos Inter-Blockchain Communication (IBC) Protocol 2 | 3 | __Disclaimer__ This module has been removed from the repository for the time being. If you would like to follow the process of IBC, go to [ICS repo](https://github.com/cosmos/ics), there you will find the standard and updates. -------------------------------------------------------------------------------- /docs/spec/supply/02_state.md: -------------------------------------------------------------------------------- 1 | # State 2 | 3 | ## Supply 4 | 5 | The `Supply` is a passive tracker of the supply of the chain: 6 | 7 | - Supply: `0x0 -> amino(Supply)` 8 | 9 | ```go 10 | type Supply struct { 11 | Total sdk.Coins // total supply of tokens registered on the chain 12 | } 13 | ``` 14 | -------------------------------------------------------------------------------- /scripts/README.md: -------------------------------------------------------------------------------- 1 | Generally we should avoid shell scripting and write tests purely in Golang. 2 | However, some libraries are not Goroutine-safe (e.g. app simulations cannot be run safely in parallel), 3 | and OS-native threading may be more efficient for many parallel simulations, so we use shell scripts here. 4 | -------------------------------------------------------------------------------- /.pending/breaking/sdk/4588-Context-does-no: -------------------------------------------------------------------------------- 1 | #4588 Context does not depend on x/auth anymore. client/context is stripped out of the following features: 2 | - GetAccountDecoder() 3 | - CLIContext.WithAccountDecoder() 4 | - CLIContext.WithAccountStore() 5 | 6 | x/auth.AccountDecoder is unnecessary and consequently removed. 7 | -------------------------------------------------------------------------------- /.pending/breaking/sdk/4451-Improve-modular: -------------------------------------------------------------------------------- 1 | #4451 Improve modularization of clients and modules: 2 | * Module directory structure improved and standardized 3 | * Aliases autogenerated 4 | * Auth and bank related commands are now mounted under the respective moduels 5 | * Client initialization and mounting standardized 6 | -------------------------------------------------------------------------------- /docs/spec/crisis/04_params.md: -------------------------------------------------------------------------------- 1 | # Parameters 2 | 3 | The crisis module contains the following parameters: 4 | 5 | | Key | Type | Example | 6 | |-------------|---------------|-----------------------------------| 7 | | ConstantFee | object (coin) | {"denom":"uatom","amount":"1000"} | 8 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/Add-an-additional-pa: -------------------------------------------------------------------------------- 1 | #3685 Add an additional parameter to NewAnteHandler for a custom `SignatureVerificationGasConsumer` (the default logic is now in `DefaultSigVerificationGasConsumer). This allows SDK users to configure their own logic for which key types are accepted and how those key types consume gas. 2 | -------------------------------------------------------------------------------- /x/genaccounts/codec.go: -------------------------------------------------------------------------------- 1 | package genaccounts 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/codec" 5 | ) 6 | 7 | // generic sealed codec to be used throughout this module 8 | var moduleCdc *codec.Codec 9 | 10 | func init() { 11 | moduleCdc = codec.New() 12 | codec.RegisterCrypto(moduleCdc) 13 | moduleCdc.Seal() 14 | } 15 | -------------------------------------------------------------------------------- /x/auth/types/params_test.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | ) 8 | 9 | func TestParamsEqual(t *testing.T) { 10 | p1 := DefaultParams() 11 | p2 := DefaultParams() 12 | require.Equal(t, p1, p2) 13 | 14 | p1.TxSigLimit += 10 15 | require.NotEqual(t, p1, p2) 16 | } 17 | -------------------------------------------------------------------------------- /x/mint/internal/types/codec.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/codec" 5 | ) 6 | 7 | // generic sealed codec to be used throughout this module 8 | var ModuleCdc *codec.Codec 9 | 10 | func init() { 11 | ModuleCdc = codec.New() 12 | codec.RegisterCrypto(ModuleCdc) 13 | ModuleCdc.Seal() 14 | } 15 | -------------------------------------------------------------------------------- /.pending/breaking/sdk/The-default-signatur: -------------------------------------------------------------------------------- 1 | #3685 The default signature verification gas logic (`DefaultSigVerificationGasConsumer`) now specifies explicit key types rather than string pattern matching. This means that zones that depended on string matching to allow other keys will need to write a custom `SignatureVerificationGasConsumer` function. 2 | -------------------------------------------------------------------------------- /client/keys/root_test.go: -------------------------------------------------------------------------------- 1 | package keys 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | ) 8 | 9 | func TestCommands(t *testing.T) { 10 | rootCommands := Commands() 11 | assert.NotNil(t, rootCommands) 12 | 13 | // Commands are registered 14 | assert.Equal(t, 10, len(rootCommands.Commands())) 15 | } 16 | -------------------------------------------------------------------------------- /docs/spec/supply/03_future_improvements.md: -------------------------------------------------------------------------------- 1 | # Future improvements 2 | 3 | The current supply module only keeps track of the total supply of coins held in the network. 4 | 5 | Future improvements may also include other types of supply such as: 6 | 7 | * **Register Supply:** Register a concrete supply type in order to track it passively on the chain. 8 | -------------------------------------------------------------------------------- /x/mint/internal/types/events.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // Minting module event types 4 | const ( 5 | EventTypeMint = ModuleName 6 | 7 | AttributeKeyBondedRatio = "bonded_ratio" 8 | AttributeKeyInflation = "inflation" 9 | AttributeKeyAnnualProvisions = "annual_provisions" 10 | AttributeKeyAmount = "amount" 11 | ) 12 | -------------------------------------------------------------------------------- /docs/spec/supply/README.md: -------------------------------------------------------------------------------- 1 | # Supply Specification 2 | 3 | ## Contents 4 | 5 | 1. **[Concept](./01_concepts.md)** 6 | - [Supply](./01_concepts.md#supply) 7 | - [Module Accounts](./01_concepts.md#module-accounts) 8 | 2. **[State](./02_state.md)** 9 | - [Supply](./02_state.md#supply) 10 | 3. **[Future Improvements](./03_future_improvements.md)** 11 | -------------------------------------------------------------------------------- /x/mint/client/rest/rest.go: -------------------------------------------------------------------------------- 1 | package rest 2 | 3 | import ( 4 | "github.com/gorilla/mux" 5 | 6 | "github.com/cosmos/cosmos-sdk/client/context" 7 | ) 8 | 9 | // RegisterRoutes registers minting module REST handlers on the provided router. 10 | func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router) { 11 | registerQueryRoutes(cliCtx, r) 12 | } 13 | -------------------------------------------------------------------------------- /store/types/validity.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // Check if the key is valid(key is not nil) 4 | func AssertValidKey(key []byte) { 5 | if key == nil { 6 | panic("key is nil") 7 | } 8 | } 9 | 10 | // Check if the value is valid(value is not nil) 11 | func AssertValidValue(value []byte) { 12 | if value == nil { 13 | panic("value is nil") 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /x/supply/exported/exported.go: -------------------------------------------------------------------------------- 1 | package exported 2 | 3 | import "github.com/cosmos/cosmos-sdk/x/auth/exported" 4 | 5 | // ModuleAccountI defines an account interface for modules that hold tokens in an escrow 6 | type ModuleAccountI interface { 7 | exported.Account 8 | GetName() string 9 | GetPermissions() []string 10 | HasPermission(string) bool 11 | } 12 | -------------------------------------------------------------------------------- /x/crisis/internal/types/expected_keepers.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | ) 6 | 7 | // SupplyKeeper defines the expected supply keeper (noalias) 8 | type SupplyKeeper interface { 9 | SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) sdk.Error 10 | } 11 | -------------------------------------------------------------------------------- /x/genaccounts/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package genaccounts contains specialized functionality for initializing 3 | accounts from genesis including: 4 | - genesis account validation, 5 | - initchain processing of genesis accounts, 6 | - export processing (to genesis) of accounts, 7 | - server command for adding accounts to the genesis file. 8 | */ 9 | package genaccounts 10 | -------------------------------------------------------------------------------- /x/slashing/client/rest/rest.go: -------------------------------------------------------------------------------- 1 | package rest 2 | 3 | import ( 4 | "github.com/gorilla/mux" 5 | 6 | "github.com/cosmos/cosmos-sdk/client/context" 7 | ) 8 | 9 | // RegisterRoutes registers staking-related REST handlers to a router 10 | func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router) { 11 | registerQueryRoutes(cliCtx, r) 12 | registerTxRoutes(cliCtx, r) 13 | } 14 | -------------------------------------------------------------------------------- /x/staking/client/rest/rest.go: -------------------------------------------------------------------------------- 1 | package rest 2 | 3 | import ( 4 | "github.com/gorilla/mux" 5 | 6 | "github.com/cosmos/cosmos-sdk/client/context" 7 | ) 8 | 9 | // RegisterRoutes registers staking-related REST handlers to a router 10 | func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router) { 11 | registerQueryRoutes(cliCtx, r) 12 | registerTxRoutes(cliCtx, r) 13 | } 14 | -------------------------------------------------------------------------------- /x/crisis/abci.go: -------------------------------------------------------------------------------- 1 | package crisis 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | ) 6 | 7 | // check all registered invariants 8 | func EndBlocker(ctx sdk.Context, k Keeper) { 9 | if k.InvCheckPeriod() == 0 || ctx.BlockHeight()%int64(k.InvCheckPeriod()) != 0 { 10 | // skip running the invariant check 11 | return 12 | } 13 | k.AssertInvariants(ctx) 14 | } 15 | -------------------------------------------------------------------------------- /types/router.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // Router provides handlers for each transaction type. 4 | type Router interface { 5 | AddRoute(r string, h Handler) Router 6 | Route(path string) Handler 7 | } 8 | 9 | // QueryRouter provides queryables for each query path. 10 | type QueryRouter interface { 11 | AddRoute(r string, h Querier) QueryRouter 12 | Route(path string) Querier 13 | } 14 | -------------------------------------------------------------------------------- /x/genutil/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package genutil contains a variety of genesis utility functionality 3 | for usage within a blockchain application. Namely: 4 | - Genesis transactions related (gentx) 5 | - commands for collection and creation of gentxs 6 | - initchain processing of gentxs 7 | - Genesis file validation 8 | - Tendermint related initialization 9 | */ 10 | package genutil 11 | -------------------------------------------------------------------------------- /docs/spec/bank/01_state.md: -------------------------------------------------------------------------------- 1 | # State 2 | 3 | Presently, the bank module has no inherent state — it simply reads and writes accounts using the `AccountKeeper` from the `auth` module. 4 | 5 | This implementation choice is intended to minimize necessary state reads/writes, since we expect most transactions to involve coin amounts (for fees), so storing coin data in the account saves reading it separately. 6 | -------------------------------------------------------------------------------- /x/params/client/proposal_handler.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | govclient "github.com/cosmos/cosmos-sdk/x/gov/client" 5 | "github.com/cosmos/cosmos-sdk/x/params/client/cli" 6 | "github.com/cosmos/cosmos-sdk/x/params/client/rest" 7 | ) 8 | 9 | // param change proposal handler 10 | var ProposalHandler = govclient.NewProposalHandler(cli.GetCmdSubmitProposal, rest.ProposalRESTHandler) 11 | -------------------------------------------------------------------------------- /types/handler.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // Handler defines the core of the state transition function of an application. 4 | type Handler func(ctx Context, msg Msg) Result 5 | 6 | // AnteHandler authenticates transactions, before their internal messages are handled. 7 | // If newCtx.IsZero(), ctx is used instead. 8 | type AnteHandler func(ctx Context, tx Tx, simulate bool) (newCtx Context, result Result, abort bool) 9 | -------------------------------------------------------------------------------- /docs/translations/cn/clients/README.md: -------------------------------------------------------------------------------- 1 | # 客户端 2 | 3 | 本节说明包含区块链 SDK 的客户端的信息。 4 | 5 | > *注*:此部分仍在开发中。 6 | 7 | ##轻客户端 8 | 9 | 轻客户端使用户能够与您的应用程序进行交互,且无需下载整个状态历史记录,但具有良好的安全性。 10 | 11 | - [轻客户端概述](./lite/README.md) 12 | - [启动轻客户端服务器](./lite/getting_started.md) 13 | - [轻客户端规范](./lite/specification.md) 14 | 15 | ##其他客户端 16 | 17 | - [区块链 SDK 的 CLI](./cli.md) 18 | - [服务提供商文档](./service-providers.md) 19 | 20 | -------------------------------------------------------------------------------- /x/distribution/client/proposal_handler.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/x/distribution/client/cli" 5 | "github.com/cosmos/cosmos-sdk/x/distribution/client/rest" 6 | govclient "github.com/cosmos/cosmos-sdk/x/gov/client" 7 | ) 8 | 9 | // param change proposal handler 10 | var ProposalHandler = govclient.NewProposalHandler(cli.GetCmdSubmitProposal, rest.ProposalRESTHandler) 11 | -------------------------------------------------------------------------------- /x/genaccounts/expected.go: -------------------------------------------------------------------------------- 1 | package genaccounts 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | "github.com/cosmos/cosmos-sdk/x/auth" 6 | ) 7 | 8 | // expected account keeper 9 | type AccountKeeper interface { 10 | NewAccount(sdk.Context, auth.Account) auth.Account 11 | SetAccount(sdk.Context, auth.Account) 12 | IterateAccounts(ctx sdk.Context, process func(auth.Account) (stop bool)) 13 | } 14 | -------------------------------------------------------------------------------- /x/params/subspace/paramset.go: -------------------------------------------------------------------------------- 1 | package subspace 2 | 3 | // Used for associating paramsubspace key and field of param structs 4 | type ParamSetPair struct { 5 | Key []byte 6 | Value interface{} 7 | } 8 | 9 | // Slice of KeyFieldPair 10 | type ParamSetPairs []ParamSetPair 11 | 12 | // Interface for structs containing parameters for a module 13 | type ParamSet interface { 14 | ParamSetPairs() ParamSetPairs 15 | } 16 | -------------------------------------------------------------------------------- /x/supply/internal/types/key.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | const ( 4 | // ModuleName is the module name constant used in many places 5 | ModuleName = "supply" 6 | 7 | // StoreKey is the store key string for supply 8 | StoreKey = ModuleName 9 | 10 | // RouterKey is the message route for supply 11 | RouterKey = ModuleName 12 | 13 | // QuerierRoute is the querier route for supply 14 | QuerierRoute = ModuleName 15 | ) 16 | -------------------------------------------------------------------------------- /types/module/module_test.go: -------------------------------------------------------------------------------- 1 | package module 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | "github.com/stretchr/testify/require" 8 | ) 9 | 10 | func TestSetOrderBeginBlockers(t *testing.T) { 11 | mm := NewManager() 12 | mm.SetOrderBeginBlockers("a", "b", "c") 13 | obb := mm.OrderBeginBlockers 14 | require.Equal(t, 3, len(obb)) 15 | assert.Equal(t, []string{"a", "b", "c"}, obb) 16 | } 17 | -------------------------------------------------------------------------------- /x/staking/types/params_test.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | ) 8 | 9 | func TestParamsEqual(t *testing.T) { 10 | p1 := DefaultParams() 11 | p2 := DefaultParams() 12 | 13 | ok := p1.Equal(p2) 14 | require.True(t, ok) 15 | 16 | p2.UnbondingTime = 60 * 60 * 24 * 2 17 | p2.BondDenom = "soup" 18 | 19 | ok = p1.Equal(p2) 20 | require.False(t, ok) 21 | } 22 | -------------------------------------------------------------------------------- /docs/spec/mint/05_events.md: -------------------------------------------------------------------------------- 1 | # Events 2 | 3 | The minting module emits the following events: 4 | 5 | ## BeginBlocker 6 | 7 | | Type | Attribute Key | Attribute Value | 8 | |------|-------------------|--------------------| 9 | | mint | bonded_ratio | {bondedRatio} | 10 | | mint | inflation | {inflation} | 11 | | mint | annual_provisions | {annualProvisions} | 12 | | mint | amount | {amount} | 13 | -------------------------------------------------------------------------------- /tests/test_cover.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | PKGS=$(go list ./... | grep -v '/simulation') 5 | 6 | set -e 7 | echo "mode: atomic" > coverage.txt 8 | for pkg in ${PKGS[@]}; do 9 | go test -v -timeout 30m -race -coverprofile=profile.out -covermode=atomic -tags='ledger test_ledger_mock' "$pkg" 10 | if [ -f profile.out ]; then 11 | tail -n +2 profile.out >> coverage.txt; 12 | rm profile.out 13 | fi 14 | done 15 | -------------------------------------------------------------------------------- /store/transient/store_test.go: -------------------------------------------------------------------------------- 1 | package transient 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | ) 8 | 9 | var k, v = []byte("hello"), []byte("world") 10 | 11 | func TestTransientStore(t *testing.T) { 12 | tstore := NewStore() 13 | 14 | require.Nil(t, tstore.Get(k)) 15 | 16 | tstore.Set(k, v) 17 | 18 | require.Equal(t, v, tstore.Get(k)) 19 | 20 | tstore.Commit() 21 | 22 | require.Nil(t, tstore.Get(k)) 23 | } 24 | -------------------------------------------------------------------------------- /x/distribution/types/fee_pool_test.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | 8 | sdk "github.com/cosmos/cosmos-sdk/types" 9 | ) 10 | 11 | func TestValidateGenesis(t *testing.T) { 12 | 13 | fp := InitialFeePool() 14 | require.Nil(t, fp.ValidateGenesis()) 15 | 16 | fp2 := FeePool{CommunityPool: sdk.DecCoins{{"stake", sdk.NewDec(-1)}}} 17 | require.NotNil(t, fp2.ValidateGenesis()) 18 | 19 | } 20 | -------------------------------------------------------------------------------- /x/supply/internal/keeper/key.go: -------------------------------------------------------------------------------- 1 | package keeper 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | "github.com/cosmos/cosmos-sdk/x/supply/internal/types" 6 | ) 7 | 8 | // DefaultCodespace from the supply module 9 | var DefaultCodespace sdk.CodespaceType = types.ModuleName 10 | 11 | // Keys for supply store 12 | // Items are stored with the following key: values 13 | // 14 | // - 0x00: Supply 15 | var ( 16 | SupplyKey = []byte{0x00} 17 | ) 18 | -------------------------------------------------------------------------------- /crypto/keys/keys.go: -------------------------------------------------------------------------------- 1 | package keys 2 | 3 | // SigningAlgo defines an algorithm to derive key-pairs which can be used for cryptographic signing. 4 | type SigningAlgo string 5 | 6 | const ( 7 | // Secp256k1 uses the Bitcoin secp256k1 ECDSA parameters. 8 | Secp256k1 = SigningAlgo("secp256k1") 9 | // Ed25519 represents the Ed25519 signature system. 10 | // It is currently not supported for end-user keys (wallets/ledgers). 11 | Ed25519 = SigningAlgo("ed25519") 12 | ) 13 | -------------------------------------------------------------------------------- /docs/spec/crisis/03_events.md: -------------------------------------------------------------------------------- 1 | # Events 2 | 3 | The crisis module emits the following events: 4 | 5 | ## Handlers 6 | 7 | ### MsgVerifyInvariance 8 | 9 | | Type | Attribute Key | Attribute Value | 10 | |-----------|---------------|------------------| 11 | | invariant | route | {invariantRoute} | 12 | | message | module | crisis | 13 | | message | action | verify_invariant | 14 | | message | sender | {senderAddress} | 15 | -------------------------------------------------------------------------------- /docs/spec/staking/07_params.md: -------------------------------------------------------------------------------- 1 | # Parameters 2 | 3 | The staking module contains the following parameters: 4 | 5 | | Key | Type | Example | 6 | |---------------|------------------|-------------------| 7 | | UnbondingTime | string (time ns) | "259200000000000" | 8 | | MaxValidators | uint16 | 100 | 9 | | KeyMaxEntries | uint16 | 7 | 10 | | BondDenom | string | "uatom" | 11 | -------------------------------------------------------------------------------- /x/genutil/types.go: -------------------------------------------------------------------------------- 1 | package genutil 2 | 3 | import ( 4 | "encoding/json" 5 | ) 6 | 7 | type ( 8 | // AppMap map modules names with their json raw representation 9 | AppMap map[string]json.RawMessage 10 | // MigrationCallback converts a genesis map from the previous version to the targeted one 11 | MigrationCallback func(AppMap) AppMap 12 | // MigrationMap defines a mapping from a version to a MigrationCallback 13 | MigrationMap map[string]MigrationCallback 14 | ) 15 | -------------------------------------------------------------------------------- /x/bank/internal/types/querier.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | ) 6 | 7 | // QueryBalanceParams defines the params for querying an account balance. 8 | type QueryBalanceParams struct { 9 | Address sdk.AccAddress 10 | } 11 | 12 | // NewQueryBalanceParams creates a new instance of QueryBalanceParams. 13 | func NewQueryBalanceParams(addr sdk.AccAddress) QueryBalanceParams { 14 | return QueryBalanceParams{Address: addr} 15 | } 16 | -------------------------------------------------------------------------------- /client/keys/codec.go: -------------------------------------------------------------------------------- 1 | package keys 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/codec" 5 | ) 6 | 7 | var cdc *codec.Codec 8 | 9 | func init() { 10 | cdc = codec.New() 11 | codec.RegisterCrypto(cdc) 12 | cdc.Seal() 13 | } 14 | 15 | // marshal keys 16 | func MarshalJSON(o interface{}) ([]byte, error) { 17 | return cdc.MarshalJSON(o) 18 | } 19 | 20 | // unmarshal json 21 | func UnmarshalJSON(bz []byte, ptr interface{}) error { 22 | return cdc.UnmarshalJSON(bz, ptr) 23 | } 24 | -------------------------------------------------------------------------------- /x/slashing/types/codec.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/codec" 5 | ) 6 | 7 | // Register concrete types on codec codec 8 | func RegisterCodec(cdc *codec.Codec) { 9 | cdc.RegisterConcrete(MsgUnjail{}, "cosmos-sdk/MsgUnjail", nil) 10 | } 11 | 12 | // module codec 13 | var ModuleCdc *codec.Codec 14 | 15 | func init() { 16 | ModuleCdc = codec.New() 17 | RegisterCodec(ModuleCdc) 18 | codec.RegisterCrypto(ModuleCdc) 19 | ModuleCdc.Seal() 20 | } 21 | -------------------------------------------------------------------------------- /x/params/types/codec.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/codec" 5 | ) 6 | 7 | // module codec 8 | var ModuleCdc *codec.Codec 9 | 10 | func init() { 11 | ModuleCdc = codec.New() 12 | RegisterCodec(ModuleCdc) 13 | ModuleCdc.Seal() 14 | } 15 | 16 | // RegisterCodec registers all necessary param module types with a given codec. 17 | func RegisterCodec(cdc *codec.Codec) { 18 | cdc.RegisterConcrete(ParameterChangeProposal{}, "cosmos-sdk/ParameterChangeProposal", nil) 19 | } 20 | -------------------------------------------------------------------------------- /x/slashing/types/msg_test.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | 8 | sdk "github.com/cosmos/cosmos-sdk/types" 9 | ) 10 | 11 | func TestMsgUnjailGetSignBytes(t *testing.T) { 12 | addr := sdk.AccAddress("abcd") 13 | msg := NewMsgUnjail(sdk.ValAddress(addr)) 14 | bytes := msg.GetSignBytes() 15 | require.Equal( 16 | t, 17 | `{"type":"cosmos-sdk/MsgUnjail","value":{"address":"cosmosvaloper1v93xxeqhg9nn6"}}`, 18 | string(bytes), 19 | ) 20 | } 21 | -------------------------------------------------------------------------------- /docs/spec/auth/07_params.md: -------------------------------------------------------------------------------- 1 | # Parameters 2 | 3 | The auth module contains the following parameters: 4 | 5 | | Key | Type | Example | 6 | |------------------------|-----------------|---------| 7 | | MaxMemoCharacters | string (uint64) | "256" | 8 | | TxSigLimit | string (uint64) | "7" | 9 | | TxSizeCostPerByte | string (uint64) | "10" | 10 | | SigVerifyCostED25519 | string (uint64) | "590" | 11 | | SigVerifyCostSecp256k1 | string (uint64) | "1000" | 12 | -------------------------------------------------------------------------------- /x/bank/internal/types/codec.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/codec" 5 | ) 6 | 7 | // Register concrete types on codec codec 8 | func RegisterCodec(cdc *codec.Codec) { 9 | cdc.RegisterConcrete(MsgSend{}, "cosmos-sdk/MsgSend", nil) 10 | cdc.RegisterConcrete(MsgMultiSend{}, "cosmos-sdk/MsgMultiSend", nil) 11 | } 12 | 13 | // module codec 14 | var ModuleCdc *codec.Codec 15 | 16 | func init() { 17 | ModuleCdc = codec.New() 18 | RegisterCodec(ModuleCdc) 19 | ModuleCdc.Seal() 20 | } 21 | -------------------------------------------------------------------------------- /docs/spec/distribution/07_params.md: -------------------------------------------------------------------------------- 1 | # Parameters 2 | 3 | The distribution module contains the following parameters: 4 | 5 | | Key | Type | Example | 6 | |---------------------|--------------|------------------------| 7 | | communitytax | string (dec) | "0.020000000000000000" | 8 | | baseproposerreward | string (dec) | "0.010000000000000000" | 9 | | bonusproposerreward | string (dec) | "0.040000000000000000" | 10 | | withdrawaddrenabled | bool | true | 11 | -------------------------------------------------------------------------------- /x/bank/handler_test.go: -------------------------------------------------------------------------------- 1 | package bank 2 | 3 | import ( 4 | "strings" 5 | "testing" 6 | 7 | sdk "github.com/cosmos/cosmos-sdk/types" 8 | abci "github.com/tendermint/tendermint/abci/types" 9 | 10 | "github.com/stretchr/testify/require" 11 | ) 12 | 13 | func TestInvalidMsg(t *testing.T) { 14 | h := NewHandler(nil) 15 | 16 | res := h(sdk.NewContext(nil, abci.Header{}, false, nil), sdk.NewTestMsg()) 17 | require.False(t, res.IsOK()) 18 | require.True(t, strings.Contains(res.Log, "unrecognized bank message type")) 19 | } 20 | -------------------------------------------------------------------------------- /x/supply/internal/types/genesis.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // GenesisState is the supply state that must be provided at genesis. 4 | type GenesisState struct { 5 | Supply Supply `json:"supply" yaml:"supply"` 6 | } 7 | 8 | // NewGenesisState creates a new genesis state. 9 | func NewGenesisState(supply Supply) GenesisState { 10 | return GenesisState{supply} 11 | } 12 | 13 | // DefaultGenesisState returns a default genesis state 14 | func DefaultGenesisState() GenesisState { 15 | return NewGenesisState(DefaultSupply()) 16 | } 17 | -------------------------------------------------------------------------------- /docs/translations/kr/clients/README.md: -------------------------------------------------------------------------------- 1 | # 클라이언트 2 | 3 | 이 항목은 SDK 기반 블록체인을 위한 클라이언트에 대한 정보가 포함되어있습니다. 4 | 5 | >*참고*: 이 항목은 작업이 진행중입니다. 6 | 7 | ## 라이트 클라이언트(Light-client) 8 | 9 | 라이트 클라이언트는 유저가 특정 블록체인 상태 전체를 다운로드 받지 않고도 안전성이 확보될 수 있는 환경에서 블록체인 애플리케이션과 소통할 수 있게 합니다. 10 | 11 | - [라이트 클라이언트 개요](./lite/README.md) 12 | - [라이트 클라이언트 서버 구동하기](./lite/getting_started.md) 13 | - [라이트 클라이언트 스펙](./lite/specification.md) 14 | 15 | ## 다른 클라이언트 16 | 17 | - [SDK 기반 블록체인을 위한 커맨드 라인 기반 인터페이스](./cli.md) 18 | - [서비스 제공자 문서](./service-providers.md) 19 | -------------------------------------------------------------------------------- /x/genutil/gentx_test.go: -------------------------------------------------------------------------------- 1 | package genutil 2 | 3 | import "testing" 4 | 5 | func TestGenTx(t *testing.T) { 6 | 7 | // TODO test that key overwrite flags work / no overwrites if set off 8 | // TODO test validator created has provided pubkey 9 | // TODO test the account created has the correct pubkey 10 | 11 | // TODO test must provide at least genesis transaction 12 | // TODO test with both one and two genesis transactions: 13 | // TODO correct: genesis account created, canididates created, pool token variance 14 | } 15 | -------------------------------------------------------------------------------- /crypto/amino.go: -------------------------------------------------------------------------------- 1 | package crypto 2 | 3 | import ( 4 | amino "github.com/tendermint/go-amino" 5 | cryptoAmino "github.com/tendermint/tendermint/crypto/encoding/amino" 6 | ) 7 | 8 | var cdc = amino.NewCodec() 9 | 10 | func init() { 11 | RegisterAmino(cdc) 12 | cryptoAmino.RegisterAmino(cdc) 13 | } 14 | 15 | // RegisterAmino registers all go-crypto related types in the given (amino) codec. 16 | func RegisterAmino(cdc *amino.Codec) { 17 | cdc.RegisterConcrete(PrivKeyLedgerSecp256k1{}, 18 | "tendermint/PrivKeyLedgerSecp256k1", nil) 19 | } 20 | -------------------------------------------------------------------------------- /server/config/config_test.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | 8 | sdk "github.com/cosmos/cosmos-sdk/types" 9 | ) 10 | 11 | func TestDefaultConfig(t *testing.T) { 12 | cfg := DefaultConfig() 13 | require.True(t, cfg.GetMinGasPrices().IsZero()) 14 | } 15 | 16 | func TestSetMinimumFees(t *testing.T) { 17 | cfg := DefaultConfig() 18 | cfg.SetMinGasPrices(sdk.DecCoins{sdk.NewInt64DecCoin("foo", 5)}) 19 | require.Equal(t, "5.000000000000000000foo", cfg.MinGasPrices) 20 | } 21 | -------------------------------------------------------------------------------- /x/auth/types/expected_keepers.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | "github.com/cosmos/cosmos-sdk/x/supply/exported" 6 | ) 7 | 8 | // SupplyKeeper defines the expected supply Keeper (noalias) 9 | type SupplyKeeper interface { 10 | SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) sdk.Error 11 | GetModuleAccount(ctx sdk.Context, moduleName string) exported.ModuleAccountI 12 | GetModuleAddress(moduleName string) sdk.AccAddress 13 | } 14 | -------------------------------------------------------------------------------- /x/crisis/internal/types/codec.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/codec" 5 | ) 6 | 7 | // Register concrete types on codec codec 8 | func RegisterCodec(cdc *codec.Codec) { 9 | cdc.RegisterConcrete(MsgVerifyInvariant{}, "cosmos-sdk/MsgVerifyInvariant", nil) 10 | } 11 | 12 | // generic sealed codec to be used throughout module 13 | var ModuleCdc *codec.Codec 14 | 15 | func init() { 16 | ModuleCdc = codec.New() 17 | RegisterCodec(ModuleCdc) 18 | codec.RegisterCrypto(ModuleCdc) 19 | ModuleCdc.Seal() 20 | } 21 | -------------------------------------------------------------------------------- /x/genutil/utils_test.go: -------------------------------------------------------------------------------- 1 | package genutil 2 | 3 | import ( 4 | "encoding/json" 5 | "path/filepath" 6 | "testing" 7 | "time" 8 | 9 | "github.com/cosmos/cosmos-sdk/tests" 10 | 11 | "github.com/stretchr/testify/require" 12 | ) 13 | 14 | func TestExportGenesisFileWithTime(t *testing.T) { 15 | t.Parallel() 16 | dir, cleanup := tests.NewTestCaseDir(t) 17 | defer cleanup() 18 | 19 | fname := filepath.Join(dir, "genesis.json") 20 | require.NoError(t, ExportGenesisFileWithTime(fname, "test", nil, json.RawMessage(""), time.Now())) 21 | } 22 | -------------------------------------------------------------------------------- /x/gov/handler_test.go: -------------------------------------------------------------------------------- 1 | package gov 2 | 3 | import ( 4 | "strings" 5 | "testing" 6 | 7 | sdk "github.com/cosmos/cosmos-sdk/types" 8 | abci "github.com/tendermint/tendermint/abci/types" 9 | 10 | "github.com/stretchr/testify/require" 11 | ) 12 | 13 | func TestInvalidMsg(t *testing.T) { 14 | k := Keeper{} 15 | h := NewHandler(k) 16 | 17 | res := h(sdk.NewContext(nil, abci.Header{}, false, nil), sdk.NewTestMsg()) 18 | require.False(t, res.IsOK()) 19 | require.True(t, strings.Contains(res.Log, "unrecognized gov message type")) 20 | } 21 | -------------------------------------------------------------------------------- /tests/io.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import ( 4 | "bytes" 5 | "strings" 6 | 7 | "github.com/spf13/cobra" 8 | ) 9 | 10 | // ApplyMockIO replaces stdin/out/err with buffers that can be used during testing. 11 | func ApplyMockIO(c *cobra.Command) (*strings.Reader, *bytes.Buffer, *bytes.Buffer) { 12 | mockIn := strings.NewReader("") 13 | mockOut := bytes.NewBufferString("") 14 | mockErr := bytes.NewBufferString("") 15 | c.SetIn(mockIn) 16 | c.SetOut(mockOut) 17 | c.SetErr(mockErr) 18 | return mockIn, mockOut, mockErr 19 | } 20 | 21 | // DONTCOVER 22 | -------------------------------------------------------------------------------- /x/distribution/types/keys.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | const ( 4 | // ModuleName is the module name constant used in many places 5 | ModuleName = "distribution" 6 | 7 | // StoreKey is the store key string for distribution 8 | StoreKey = ModuleName 9 | 10 | // TStoreKey is the transient store key for distribution 11 | TStoreKey = "transient_" + ModuleName 12 | 13 | // RouterKey is the message route for distribution 14 | RouterKey = ModuleName 15 | 16 | // QuerierRoute is the querier route for distribution 17 | QuerierRoute = ModuleName 18 | ) 19 | -------------------------------------------------------------------------------- /crypto/ledger_notavail.go: -------------------------------------------------------------------------------- 1 | // +build !cgo !ledger 2 | // test_ledger_mock 3 | 4 | package crypto 5 | 6 | import ( 7 | "github.com/pkg/errors" 8 | ) 9 | 10 | // If ledger support (build tag) has been enabled, which implies a CGO dependency, 11 | // set the discoverLedger function which is responsible for loading the Ledger 12 | // device at runtime or returning an error. 13 | func init() { 14 | discoverLedger = func() (LedgerSECP256K1, error) { 15 | return nil, errors.New("support for ledger devices is not available in this executable") 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /docs/spec/crisis/01_state.md: -------------------------------------------------------------------------------- 1 | # State 2 | 3 | ## ConstantFee 4 | 5 | Due to the anticipated large gas cost requirement to verify an invariant (and 6 | potential to exceed the maximum allowable block gas limit) a constant fee is 7 | used instead of the standard gas consumption method. The constant fee is 8 | intended to be larger than the anticipated gas cost of running the invariant 9 | with the standard gas consumption method. 10 | 11 | The ConstantFee param is held in the global params store. 12 | 13 | - Params: `mint/params -> amino(sdk.Coin)` 14 | 15 | -------------------------------------------------------------------------------- /x/crisis/internal/types/params.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | "github.com/cosmos/cosmos-sdk/x/params" 6 | ) 7 | 8 | // Default parameter namespace 9 | const ( 10 | DefaultParamspace = ModuleName 11 | ) 12 | 13 | var ( 14 | // key for constant fee parameter 15 | ParamStoreKeyConstantFee = []byte("ConstantFee") 16 | ) 17 | 18 | // type declaration for parameters 19 | func ParamKeyTable() params.KeyTable { 20 | return params.NewKeyTable( 21 | ParamStoreKeyConstantFee, sdk.Coin{}, 22 | ) 23 | } 24 | -------------------------------------------------------------------------------- /x/auth/types/querier.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | ) 6 | 7 | // query endpoints supported by the auth Querier 8 | const ( 9 | QueryAccount = "account" 10 | ) 11 | 12 | // QueryAccountParams defines the params for querying accounts. 13 | type QueryAccountParams struct { 14 | Address sdk.AccAddress 15 | } 16 | 17 | // NewQueryAccountParams creates a new instance of QueryAccountParams. 18 | func NewQueryAccountParams(addr sdk.AccAddress) QueryAccountParams { 19 | return QueryAccountParams{Address: addr} 20 | } 21 | -------------------------------------------------------------------------------- /.golangci.yml: -------------------------------------------------------------------------------- 1 | linters: 2 | disable-all: true 3 | enable: 4 | - errcheck 5 | - golint 6 | - ineffassign 7 | - unconvert 8 | - misspell 9 | - govet 10 | - unused 11 | - deadcode 12 | - goconst 13 | - gosec 14 | - staticcheck 15 | linters-settings: 16 | gocyclo: 17 | min-complexity: 11 18 | errcheck: 19 | ignore: fmt:.*,io/ioutil:^Read.*,github.com/spf13/cobra:MarkFlagRequired,github.com/spf13/viper:BindPFlag 20 | golint: 21 | min-confidence: 1.1 22 | issues: 23 | exclude: 24 | - composite 25 | run: 26 | tests: false 27 | -------------------------------------------------------------------------------- /docs/spec/bank/03_messages.md: -------------------------------------------------------------------------------- 1 | # Messages 2 | 3 | ## MsgSend 4 | 5 | ```golang 6 | type MsgSend struct { 7 | Inputs []Input 8 | Outputs []Output 9 | } 10 | ``` 11 | 12 | `handleMsgSend` just runs `inputOutputCoins`. 13 | 14 | ``` 15 | handleMsgSend(msg MsgSend) 16 | inputSum = 0 17 | for input in inputs 18 | inputSum += input.Amount 19 | outputSum = 0 20 | for output in outputs 21 | outputSum += output.Amount 22 | if inputSum != outputSum: 23 | fail with "input/output amount mismatch" 24 | 25 | return inputOutputCoins(msg.Inputs, msg.Outputs) 26 | ``` 27 | -------------------------------------------------------------------------------- /x/genaccounts/init.go: -------------------------------------------------------------------------------- 1 | package genaccounts 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/codec" 5 | sdk "github.com/cosmos/cosmos-sdk/types" 6 | ) 7 | 8 | // initialize accounts and deliver genesis transactions 9 | func InitGenesis(ctx sdk.Context, _ *codec.Codec, accountKeeper AccountKeeper, genesisState GenesisState) { 10 | genesisState.Sanitize() 11 | 12 | // load the accounts 13 | for _, gacc := range genesisState { 14 | acc := gacc.ToAccount() 15 | acc = accountKeeper.NewAccount(ctx, acc) // set account number 16 | accountKeeper.SetAccount(ctx, acc) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /x/slashing/types/events.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // Slashing module event types 4 | var ( 5 | EventTypeSlash = "slash" 6 | EventTypeLiveness = "liveness" 7 | 8 | AttributeKeyAddress = "address" 9 | AttributeKeyHeight = "height" 10 | AttributeKeyPower = "power" 11 | AttributeKeyReason = "reason" 12 | AttributeKeyJailed = "jailed" 13 | AttributeKeyMissedBlocks = "missed_blocks" 14 | 15 | AttributeValueDoubleSign = "double_sign" 16 | AttributeValueMissingSignature = "missing_signature" 17 | AttributeValueCategory = ModuleName 18 | ) 19 | -------------------------------------------------------------------------------- /crypto/ledger_real.go: -------------------------------------------------------------------------------- 1 | // +build cgo,ledger,!test_ledger_mock 2 | 3 | package crypto 4 | 5 | import ledger "github.com/cosmos/ledger-cosmos-go" 6 | 7 | // If ledger support (build tag) has been enabled, which implies a CGO dependency, 8 | // set the discoverLedger function which is responsible for loading the Ledger 9 | // device at runtime or returning an error. 10 | func init() { 11 | discoverLedger = func() (LedgerSECP256K1, error) { 12 | device, err := ledger.FindLedgerCosmosUserApp() 13 | if err != nil { 14 | return nil, err 15 | } 16 | 17 | return device, nil 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /docs/spec/mint/README.md: -------------------------------------------------------------------------------- 1 | # Mint Specification 2 | 3 | ## Contents 4 | 5 | 1. **[Concept](01_concept.md)** 6 | 2. **[State](02_state.md)** 7 | - [Minter](02_state.md#minter) 8 | - [Params](02_state.md#params) 9 | 3. **[Begin-Block](03_begin_block.md)** 10 | - [NextInflationRate](03_begin_block.md#nextinflationrate) 11 | - [NextAnnualProvisions](03_begin_block.md#nextannualprovisions) 12 | - [BlockProvision](03_begin_block.md#blockprovision) 13 | 4. **[Parameters](04_params.md)** 14 | 5. **[Events](05_events.md)** 15 | - [BeginBlocker](05_events.md#beginblocker) 16 | 17 | -------------------------------------------------------------------------------- /docs/spec/crisis/README.md: -------------------------------------------------------------------------------- 1 | # Crisis 2 | 3 | ## Overview 4 | 5 | The crisis module halts the blockchain under the circumstance that a blockchain 6 | invariant is broken. Invariants can be registered with the application during the 7 | application initialization process. 8 | 9 | ## Contents 10 | 11 | 1. **[State](01_state.md)** 12 | - [ConstantFee](01_state.md#constantfee) 13 | 2. **[Messages](02_messages.md)** 14 | - [MsgVerifyInvariant](02_messages.md#msgverifyinvariant) 15 | 3. **[Events](03_events.md)** 16 | - [Handlers](03_events.md#handlers) 17 | 4. **[Parameters](04_params.md)** 18 | -------------------------------------------------------------------------------- /x/bank/internal/types/params.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/x/params" 5 | ) 6 | 7 | const ( 8 | // DefaultParamspace for params keeper 9 | DefaultParamspace = ModuleName 10 | // DefaultSendEnabled enabled 11 | DefaultSendEnabled = true 12 | ) 13 | 14 | // ParamStoreKeySendEnabled is store's key for SendEnabled 15 | var ParamStoreKeySendEnabled = []byte("sendenabled") 16 | 17 | // ParamKeyTable type declaration for parameters 18 | func ParamKeyTable() params.KeyTable { 19 | return params.NewKeyTable( 20 | ParamStoreKeySendEnabled, false, 21 | ) 22 | } 23 | -------------------------------------------------------------------------------- /x/distribution/types/events.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // Distribution module event types 4 | var ( 5 | EventTypeSetWithdrawAddress = "set_withdraw_address" 6 | EventTypeRewards = "rewards" 7 | EventTypeCommission = "commission" 8 | EventTypeWithdrawRewards = "withdraw_rewards" 9 | EventTypeWithdrawCommission = "withdraw_commission" 10 | EventTypeProposerReward = "proposer_reward" 11 | 12 | AttributeKeyWithdrawAddress = "withdraw_address" 13 | AttributeKeyAmount = "amount" 14 | AttributeKeyValidator = "validator" 15 | 16 | AttributeValueCategory = ModuleName 17 | ) 18 | -------------------------------------------------------------------------------- /x/params/subspace/doc.go: -------------------------------------------------------------------------------- 1 | package subspace 2 | 3 | /* 4 | To prevent namespace collision between consumer modules, we define type 5 | "space". A Space can only be generated by the keeper, and the keeper checks 6 | the existence of the space having the same name before generating the 7 | space. 8 | 9 | Consumer modules must take a space (via Keeper.Subspace), not the keeper 10 | itself. This isolates each modules from the others and make them modify the 11 | parameters safely. Keeper can be treated as master permission for all 12 | subspaces (via Keeper.GetSubspace), so should be passed to proper modules 13 | (ex. gov) 14 | */ 15 | -------------------------------------------------------------------------------- /.pending/improvements/sdk/4706-Simplify-context: -------------------------------------------------------------------------------- 1 | 4706 - Simplify context 2 | 3 | Replace complex Context construct with a simpler immutible struct. 4 | Only breaking change is not to support `Value` and `GetValue` as first class calls. 5 | We do embed ctx.Context() as a raw context.Context instead to be used as you see fit. 6 | 7 | Migration guide: 8 | `ctx = ctx.WithValue(contextKeyBadProposal, false)` -> 9 | `ctx = ctx.WithContext(context.WithValue(ctx.Context(), contextKeyBadProposal, false))` 10 | A bit more verbose, but also allows `context.WithTimeout()`, etc and only used 11 | in one function in this repo, in test code. 12 | -------------------------------------------------------------------------------- /x/crisis/internal/keeper/params.go: -------------------------------------------------------------------------------- 1 | package keeper 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | "github.com/cosmos/cosmos-sdk/x/crisis/internal/types" 6 | ) 7 | 8 | // GetConstantFee get's the constant fee from the paramSpace 9 | func (k Keeper) GetConstantFee(ctx sdk.Context) (constantFee sdk.Coin) { 10 | k.paramSpace.Get(ctx, types.ParamStoreKeyConstantFee, &constantFee) 11 | return 12 | } 13 | 14 | // GetConstantFee set's the constant fee in the paramSpace 15 | func (k Keeper) SetConstantFee(ctx sdk.Context, constantFee sdk.Coin) { 16 | k.paramSpace.Set(ctx, types.ParamStoreKeyConstantFee, constantFee) 17 | } 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OS 2 | .DS_Store 3 | *.swp 4 | *.swo 5 | *.swl 6 | *.swm 7 | *.swn 8 | .vscode 9 | .idea 10 | *.pyc 11 | 12 | # Build 13 | vendor 14 | build 15 | tools/bin/* 16 | examples/build/* 17 | docs/_build 18 | docs/tutorial 19 | dist 20 | tools-stamp 21 | 22 | # Data - ideally these don't exist 23 | baseapp/data/* 24 | client/lcd/keys/* 25 | mytestnet 26 | 27 | # Testing 28 | coverage.txt 29 | profile.out 30 | sim_log_file 31 | 32 | # Vagrant 33 | .vagrant/ 34 | *.box 35 | *.log 36 | vagrant 37 | 38 | # IDE 39 | .idea/ 40 | *.iml 41 | 42 | # Graphviz 43 | dependency-graph.png 44 | 45 | # Latex 46 | *.aux 47 | *.out 48 | *.synctex.gz 49 | -------------------------------------------------------------------------------- /store/store.go: -------------------------------------------------------------------------------- 1 | package store 2 | 3 | import ( 4 | dbm "github.com/tendermint/tendermint/libs/db" 5 | 6 | "github.com/cosmos/cosmos-sdk/store/rootmulti" 7 | "github.com/cosmos/cosmos-sdk/store/types" 8 | ) 9 | 10 | func NewCommitMultiStore(db dbm.DB) types.CommitMultiStore { 11 | return rootmulti.NewStore(db) 12 | } 13 | 14 | func NewPruningOptionsFromString(strategy string) (opt PruningOptions) { 15 | switch strategy { 16 | case "nothing": 17 | opt = PruneNothing 18 | case "everything": 19 | opt = PruneEverything 20 | case "syncable": 21 | opt = PruneSyncable 22 | default: 23 | opt = PruneSyncable 24 | } 25 | return 26 | } 27 | -------------------------------------------------------------------------------- /x/genutil/init.go: -------------------------------------------------------------------------------- 1 | package genutil 2 | 3 | import ( 4 | abci "github.com/tendermint/tendermint/abci/types" 5 | 6 | "github.com/cosmos/cosmos-sdk/codec" 7 | sdk "github.com/cosmos/cosmos-sdk/types" 8 | ) 9 | 10 | // initialize accounts and deliver genesis transactions 11 | func InitGenesis(ctx sdk.Context, cdc *codec.Codec, stakingKeeper StakingKeeper, 12 | deliverTx deliverTxfn, genesisState GenesisState) []abci.ValidatorUpdate { 13 | 14 | var validators []abci.ValidatorUpdate 15 | if len(genesisState.GenTxs) > 0 { 16 | validators = DeliverGenTxs(ctx, cdc, genesisState.GenTxs, stakingKeeper, deliverTx) 17 | } 18 | return validators 19 | } 20 | -------------------------------------------------------------------------------- /x/crisis/internal/types/route.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | ) 6 | 7 | // invariant route 8 | type InvarRoute struct { 9 | ModuleName string 10 | Route string 11 | Invar sdk.Invariant 12 | } 13 | 14 | // NewInvarRoute - create an InvarRoute object 15 | func NewInvarRoute(moduleName, route string, invar sdk.Invariant) InvarRoute { 16 | return InvarRoute{ 17 | ModuleName: moduleName, 18 | Route: route, 19 | Invar: invar, 20 | } 21 | } 22 | 23 | // get the full invariance route 24 | func (i InvarRoute) FullRoute() string { 25 | return i.ModuleName + "/" + i.Route 26 | } 27 | -------------------------------------------------------------------------------- /x/auth/genesis.go: -------------------------------------------------------------------------------- 1 | package auth 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | ) 6 | 7 | // InitGenesis - Init store state from genesis data 8 | // 9 | // CONTRACT: old coins from the FeeCollectionKeeper need to be transferred through 10 | // a genesis port script to the new fee collector account 11 | func InitGenesis(ctx sdk.Context, ak AccountKeeper, data GenesisState) { 12 | ak.SetParams(ctx, data.Params) 13 | } 14 | 15 | // ExportGenesis returns a GenesisState for a given context and keeper 16 | func ExportGenesis(ctx sdk.Context, ak AccountKeeper) GenesisState { 17 | params := ak.GetParams(ctx) 18 | return NewGenesisState(params) 19 | } 20 | -------------------------------------------------------------------------------- /x/crisis/genesis.go: -------------------------------------------------------------------------------- 1 | package crisis 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | "github.com/cosmos/cosmos-sdk/x/crisis/internal/keeper" 6 | "github.com/cosmos/cosmos-sdk/x/crisis/internal/types" 7 | ) 8 | 9 | // new crisis genesis 10 | func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, data types.GenesisState) { 11 | keeper.SetConstantFee(ctx, data.ConstantFee) 12 | } 13 | 14 | // ExportGenesis returns a GenesisState for a given context and keeper. 15 | func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) types.GenesisState { 16 | constantFee := keeper.GetConstantFee(ctx) 17 | return types.NewGenesisState(constantFee) 18 | } 19 | -------------------------------------------------------------------------------- /x/genaccounts/export.go: -------------------------------------------------------------------------------- 1 | package genaccounts 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | "github.com/cosmos/cosmos-sdk/x/auth" 6 | ) 7 | 8 | // export genesis for all accounts 9 | func ExportGenesis(ctx sdk.Context, accountKeeper AccountKeeper) GenesisState { 10 | 11 | // iterate to get the accounts 12 | accounts := []GenesisAccount{} 13 | accountKeeper.IterateAccounts(ctx, 14 | func(acc auth.Account) (stop bool) { 15 | account, err := NewGenesisAccountI(acc) 16 | if err != nil { 17 | panic(err) 18 | } 19 | accounts = append(accounts, account) 20 | return false 21 | }, 22 | ) 23 | 24 | return accounts 25 | } 26 | -------------------------------------------------------------------------------- /x/gov/types/proposals_test.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | 7 | "github.com/stretchr/testify/require" 8 | ) 9 | 10 | func TestProposalStatus_Format(t *testing.T) { 11 | statusDepositPeriod, _ := ProposalStatusFromString("DepositPeriod") 12 | tests := []struct { 13 | pt ProposalStatus 14 | sprintFArgs string 15 | expectedStringOutput string 16 | }{ 17 | {statusDepositPeriod, "%s", "DepositPeriod"}, 18 | {statusDepositPeriod, "%v", "1"}, 19 | } 20 | for _, tt := range tests { 21 | got := fmt.Sprintf(tt.sprintFArgs, tt.pt) 22 | require.Equal(t, tt.expectedStringOutput, got) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /.codecov.yml: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # This codecov.yml is the default configuration for 4 | # all repositories on Codecov. You may adjust the settings 5 | # below in your own codecov.yml in your repository. 6 | # 7 | coverage: 8 | precision: 2 9 | round: down 10 | range: 70...100 11 | 12 | status: 13 | # Learn more at https://codecov.io/docs#yaml_default_commit_status 14 | project: 15 | default: 16 | threshold: 1% # allow this much decrease on project 17 | changes: false 18 | 19 | comment: 20 | layout: "header, diff" 21 | behavior: default # update if exists else create new 22 | 23 | ignore: 24 | - "docs" 25 | - "*.md" 26 | - "*.rst" 27 | -------------------------------------------------------------------------------- /docs/spec/mint/04_params.md: -------------------------------------------------------------------------------- 1 | # Parameters 2 | 3 | The minting module contains the following parameters: 4 | 5 | | Key | Type | Example | 6 | |---------------------|-----------------|------------------------| 7 | | MintDenom | string | "uatom" | 8 | | InflationRateChange | string (dec) | "0.130000000000000000" | 9 | | InflationMax | string (dec) | "0.200000000000000000" | 10 | | InflationMin | string (dec) | "0.070000000000000000" | 11 | | GoalBonded | string (dec) | "0.670000000000000000" | 12 | | BlocksPerYear | string (uint64) | "6311520" | 13 | -------------------------------------------------------------------------------- /x/supply/internal/types/codec.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/codec" 5 | "github.com/cosmos/cosmos-sdk/x/supply/exported" 6 | ) 7 | 8 | // RegisterCodec registers the account types and interface 9 | func RegisterCodec(cdc *codec.Codec) { 10 | cdc.RegisterInterface((*exported.ModuleAccountI)(nil), nil) 11 | cdc.RegisterConcrete(&ModuleAccount{}, "cosmos-sdk/ModuleAccount", nil) 12 | } 13 | 14 | // ModuleCdc generic sealed codec to be used throughout module 15 | var ModuleCdc *codec.Codec 16 | 17 | func init() { 18 | cdc := codec.New() 19 | RegisterCodec(cdc) 20 | codec.RegisterCrypto(cdc) 21 | ModuleCdc = cdc.Seal() 22 | } 23 | -------------------------------------------------------------------------------- /x/genutil/codec.go: -------------------------------------------------------------------------------- 1 | package genutil 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/codec" 5 | sdk "github.com/cosmos/cosmos-sdk/types" 6 | "github.com/cosmos/cosmos-sdk/x/auth" 7 | "github.com/cosmos/cosmos-sdk/x/staking" 8 | ) 9 | 10 | // generic sealed codec to be used throughout this module 11 | var moduleCdc *codec.Codec 12 | 13 | // TODO abstract genesis transactions registration back to staking 14 | // required for genesis transactions 15 | func init() { 16 | moduleCdc = codec.New() 17 | staking.RegisterCodec(moduleCdc) 18 | auth.RegisterCodec(moduleCdc) 19 | sdk.RegisterCodec(moduleCdc) 20 | codec.RegisterCrypto(moduleCdc) 21 | moduleCdc.Seal() 22 | } 23 | -------------------------------------------------------------------------------- /x/mint/internal/types/keys.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // the one key to use for the keeper store 4 | var MinterKey = []byte{0x00} 5 | 6 | // nolint 7 | const ( 8 | // module name 9 | ModuleName = "mint" 10 | 11 | // default paramspace for params keeper 12 | DefaultParamspace = ModuleName 13 | 14 | // StoreKey is the default store key for mint 15 | StoreKey = ModuleName 16 | 17 | // QuerierRoute is the querier route for the minting store. 18 | QuerierRoute = StoreKey 19 | 20 | // Query endpoints supported by the minting querier 21 | QueryParameters = "parameters" 22 | QueryInflation = "inflation" 23 | QueryAnnualProvisions = "annual_provisions" 24 | ) 25 | -------------------------------------------------------------------------------- /x/bank/internal/types/expected_keepers.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | "github.com/cosmos/cosmos-sdk/x/auth/exported" 6 | ) 7 | 8 | // AccountKeeper defines the account contract that must be fulfilled when 9 | // creating a x/bank keeper. 10 | type AccountKeeper interface { 11 | NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) exported.Account 12 | 13 | GetAccount(ctx sdk.Context, addr sdk.AccAddress) exported.Account 14 | GetAllAccounts(ctx sdk.Context) []exported.Account 15 | SetAccount(ctx sdk.Context, acc exported.Account) 16 | 17 | IterateAccounts(ctx sdk.Context, process func(exported.Account) bool) 18 | } 19 | -------------------------------------------------------------------------------- /x/staking/types/test_utils.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "github.com/tendermint/tendermint/crypto" 5 | "github.com/tendermint/tendermint/crypto/ed25519" 6 | 7 | sdk "github.com/cosmos/cosmos-sdk/types" 8 | ) 9 | 10 | // nolint: deadcode unused 11 | var ( 12 | pk1 = ed25519.GenPrivKey().PubKey() 13 | pk2 = ed25519.GenPrivKey().PubKey() 14 | pk3 = ed25519.GenPrivKey().PubKey() 15 | addr1 = pk1.Address() 16 | addr2 = pk2.Address() 17 | addr3 = pk3.Address() 18 | valAddr1 = sdk.ValAddress(addr1) 19 | valAddr2 = sdk.ValAddress(addr2) 20 | valAddr3 = sdk.ValAddress(addr3) 21 | 22 | emptyAddr sdk.ValAddress 23 | emptyPubkey crypto.PubKey 24 | ) 25 | -------------------------------------------------------------------------------- /x/staking/keeper/keeper_test.go: -------------------------------------------------------------------------------- 1 | package keeper 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | 8 | "github.com/cosmos/cosmos-sdk/x/staking/types" 9 | ) 10 | 11 | func TestParams(t *testing.T) { 12 | ctx, _, keeper, _ := CreateTestInput(t, false, 0) 13 | expParams := types.DefaultParams() 14 | 15 | //check that the empty keeper loads the default 16 | resParams := keeper.GetParams(ctx) 17 | require.True(t, expParams.Equal(resParams)) 18 | 19 | //modify a params, save, and retrieve 20 | expParams.MaxValidators = 777 21 | keeper.SetParams(ctx, expParams) 22 | resParams = keeper.GetParams(ctx) 23 | require.True(t, expParams.Equal(resParams)) 24 | } 25 | -------------------------------------------------------------------------------- /x/distribution/keeper/proposal_handler.go: -------------------------------------------------------------------------------- 1 | package keeper 2 | 3 | import ( 4 | "fmt" 5 | 6 | sdk "github.com/cosmos/cosmos-sdk/types" 7 | "github.com/cosmos/cosmos-sdk/x/distribution/types" 8 | ) 9 | 10 | // HandleCommunityPoolSpendProposal is a handler for executing a passed community spend proposal 11 | func HandleCommunityPoolSpendProposal(ctx sdk.Context, k Keeper, p types.CommunityPoolSpendProposal) sdk.Error { 12 | err := k.DistributeFromFeePool(ctx, p.Amount, p.Recipient) 13 | if err != nil { 14 | return err 15 | } 16 | 17 | logger := k.Logger(ctx) 18 | logger.Info(fmt.Sprintf("transferred %s from the community pool to recipient %s", p.Amount, p.Recipient)) 19 | return nil 20 | } 21 | -------------------------------------------------------------------------------- /types/result_test.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | ) 8 | 9 | func TestResult(t *testing.T) { 10 | var res Result 11 | require.True(t, res.IsOK()) 12 | 13 | res.Data = []byte("data") 14 | require.True(t, res.IsOK()) 15 | 16 | res.Code = CodeType(1) 17 | require.False(t, res.IsOK()) 18 | } 19 | 20 | func TestParseABCILog(t *testing.T) { 21 | logs := `[{"log":"","msg_index":1,"success":true}]` 22 | 23 | res, err := ParseABCILogs(logs) 24 | require.NoError(t, err) 25 | require.Len(t, res, 1) 26 | require.Equal(t, res[0].Log, "") 27 | require.Equal(t, res[0].MsgIndex, uint16(1)) 28 | require.True(t, res[0].Success) 29 | } 30 | -------------------------------------------------------------------------------- /x/simulation/event_stats.go: -------------------------------------------------------------------------------- 1 | package simulation 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "sort" 7 | ) 8 | 9 | type eventStats map[string]uint 10 | 11 | func newEventStats() eventStats { 12 | events := make(map[string]uint) 13 | return events 14 | } 15 | 16 | func (es eventStats) tally(eventDesc string) { 17 | es[eventDesc]++ 18 | } 19 | 20 | // Pretty-print events as a table 21 | func (es eventStats) Print(w io.Writer) { 22 | var keys []string 23 | for key := range es { 24 | keys = append(keys, key) 25 | } 26 | 27 | sort.Strings(keys) 28 | fmt.Fprintf(w, "Event statistics: \n") 29 | 30 | for _, key := range keys { 31 | fmt.Fprintf(w, " % 60s => %d\n", key, es[key]) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /docs/spec/slashing/08_params.md: -------------------------------------------------------------------------------- 1 | # Parameters 2 | 3 | The slashing module contains the following parameters: 4 | 5 | | Key | Type | Example | 6 | |-------------------------|------------------|------------------------| 7 | | MaxEvidenceAge | string (time ns) | "120000000000" | 8 | | SignedBlocksWindow | string (int64) | "100" | 9 | | MinSignedPerWindow | string (dec) | "0.500000000000000000" | 10 | | DowntimeJailDuration | string (time ns) | "600000000000" | 11 | | SlashFractionDoubleSign | string (dec) | "0.050000000000000000" | 12 | | SlashFractionDowntime | string (dec) | "0.010000000000000000" | 13 | -------------------------------------------------------------------------------- /baseapp/router_test.go: -------------------------------------------------------------------------------- 1 | package baseapp 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | 8 | sdk "github.com/cosmos/cosmos-sdk/types" 9 | ) 10 | 11 | var testHandler = func(_ sdk.Context, _ sdk.Msg) sdk.Result { 12 | return sdk.Result{} 13 | } 14 | 15 | func TestRouter(t *testing.T) { 16 | rtr := NewRouter() 17 | 18 | // require panic on invalid route 19 | require.Panics(t, func() { 20 | rtr.AddRoute("*", testHandler) 21 | }) 22 | 23 | rtr.AddRoute("testRoute", testHandler) 24 | h := rtr.Route("testRoute") 25 | require.NotNil(t, h) 26 | 27 | // require panic on duplicate route 28 | require.Panics(t, func() { 29 | rtr.AddRoute("testRoute", testHandler) 30 | }) 31 | } 32 | -------------------------------------------------------------------------------- /store/errors/errors.go: -------------------------------------------------------------------------------- 1 | package errors 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | ) 6 | 7 | // nolint - reexport 8 | const ( 9 | CodeOK = sdk.CodeOK 10 | CodeInternal = sdk.CodeInternal 11 | CodeTxDecode = sdk.CodeTxDecode 12 | CodeUnknownRequest = sdk.CodeUnknownRequest 13 | 14 | CodespaceRoot = sdk.CodespaceRoot 15 | ) 16 | 17 | // nolint - reexport 18 | type Error = sdk.Error 19 | 20 | // nolint - reexport 21 | func ErrInternal(msg string) Error { 22 | return sdk.ErrInternal(msg) 23 | } 24 | func ErrTxDecode(msg string) Error { 25 | return sdk.ErrTxDecode(msg) 26 | } 27 | func ErrUnknownRequest(msg string) Error { 28 | return sdk.ErrUnknownRequest(msg) 29 | } 30 | -------------------------------------------------------------------------------- /x/supply/internal/types/supply_test.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | 7 | "gopkg.in/yaml.v2" 8 | 9 | sdk "github.com/cosmos/cosmos-sdk/types" 10 | 11 | "github.com/stretchr/testify/require" 12 | ) 13 | 14 | func TestSupplyMarshalYAML(t *testing.T) { 15 | supply := DefaultSupply() 16 | coins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.OneInt())) 17 | supply.Inflate(coins) 18 | 19 | bz, err := yaml.Marshal(supply) 20 | require.NoError(t, err) 21 | bzCoins, err := yaml.Marshal(coins) 22 | require.NoError(t, err) 23 | 24 | want := fmt.Sprintf(`total_supply: 25 | %s`, string(bzCoins)) 26 | 27 | require.Equal(t, want, string(bz)) 28 | require.Equal(t, want, supply.String()) 29 | } 30 | -------------------------------------------------------------------------------- /x/auth/client/cli/tx.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | import ( 4 | "github.com/spf13/cobra" 5 | 6 | "github.com/cosmos/cosmos-sdk/client" 7 | "github.com/cosmos/cosmos-sdk/codec" 8 | "github.com/cosmos/cosmos-sdk/x/auth/types" 9 | ) 10 | 11 | // GetTxCmd returns the transaction commands for this module 12 | func GetTxCmd(cdc *codec.Codec) *cobra.Command { 13 | txCmd := &cobra.Command{ 14 | Use: types.ModuleName, 15 | Short: "Auth transaction subcommands", 16 | DisableFlagParsing: true, 17 | SuggestionsMinimumDistance: 2, 18 | RunE: client.ValidateCmd, 19 | } 20 | txCmd.AddCommand( 21 | GetMultiSignCommand(cdc), 22 | GetSignCommand(cdc), 23 | ) 24 | return txCmd 25 | } 26 | -------------------------------------------------------------------------------- /docs/spec/params/01_keeper.md: -------------------------------------------------------------------------------- 1 | # Keeper 2 | 3 | In the app initialization stage, `Keeper.Subspace(Paramspace)` is passed to the user modules, and the subspaces are stored in `Keeper.spaces`. Later it can be retrieved with `Keeper.GetSubspace`, so the keepers holding `Keeper` can access to any subspace. For example, Gov module can take `Keeper` as its argument and modify parameter of any subspace when a `ParameterChangeProposal` is accepted. 4 | 5 | Example: 6 | 7 | ```go 8 | type MasterKeeper struct { 9 | pk params.Keeper 10 | } 11 | 12 | func (k MasterKeeper) SetParam(ctx sdk.Context, space string, key string, param interface{}) { 13 | space, ok := k.ps.GetSubspace(space) 14 | if !ok { 15 | return 16 | } 17 | space.Set(ctx, key, param) 18 | } 19 | ``` 20 | -------------------------------------------------------------------------------- /crypto/keys/codec.go: -------------------------------------------------------------------------------- 1 | package keys 2 | 3 | import ( 4 | cryptoAmino "github.com/tendermint/tendermint/crypto/encoding/amino" 5 | 6 | "github.com/cosmos/cosmos-sdk/codec" 7 | "github.com/cosmos/cosmos-sdk/crypto/keys/hd" 8 | ) 9 | 10 | var cdc *codec.Codec 11 | 12 | func init() { 13 | cdc = codec.New() 14 | cryptoAmino.RegisterAmino(cdc) 15 | cdc.RegisterInterface((*Info)(nil), nil) 16 | cdc.RegisterConcrete(hd.BIP44Params{}, "crypto/keys/hd/BIP44Params", nil) 17 | cdc.RegisterConcrete(localInfo{}, "crypto/keys/localInfo", nil) 18 | cdc.RegisterConcrete(ledgerInfo{}, "crypto/keys/ledgerInfo", nil) 19 | cdc.RegisterConcrete(offlineInfo{}, "crypto/keys/offlineInfo", nil) 20 | cdc.RegisterConcrete(multiInfo{}, "crypto/keys/multiInfo", nil) 21 | cdc.Seal() 22 | } 23 | -------------------------------------------------------------------------------- /x/distribution/types/fee_pool.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "fmt" 5 | 6 | sdk "github.com/cosmos/cosmos-sdk/types" 7 | ) 8 | 9 | // global fee pool for distribution 10 | type FeePool struct { 11 | CommunityPool sdk.DecCoins `json:"community_pool" yaml:"community_pool"` // pool for community funds yet to be spent 12 | } 13 | 14 | // zero fee pool 15 | func InitialFeePool() FeePool { 16 | return FeePool{ 17 | CommunityPool: sdk.DecCoins{}, 18 | } 19 | } 20 | 21 | // ValidateGenesis validates the fee pool for a genesis state 22 | func (f FeePool) ValidateGenesis() error { 23 | if f.CommunityPool.IsAnyNegative() { 24 | return fmt.Errorf("negative CommunityPool in distribution fee pool, is %v", 25 | f.CommunityPool) 26 | } 27 | 28 | return nil 29 | } 30 | -------------------------------------------------------------------------------- /crypto/keys/mintkey/mintkey_bench_test.go: -------------------------------------------------------------------------------- 1 | package mintkey 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | 7 | "github.com/stretchr/testify/require" 8 | "github.com/tendermint/crypto/bcrypt" 9 | 10 | "github.com/tendermint/tendermint/crypto" 11 | ) 12 | 13 | func BenchmarkBcryptGenerateFromPassword(b *testing.B) { 14 | passphrase := []byte("passphrase") 15 | for securityParam := 9; securityParam < 16; securityParam++ { 16 | param := securityParam 17 | b.Run(fmt.Sprintf("benchmark-security-param-%d", param), func(b *testing.B) { 18 | saltBytes := crypto.CRandBytes(16) 19 | b.ResetTimer() 20 | for i := 0; i < b.N; i++ { 21 | _, err := bcrypt.GenerateFromPassword(saltBytes, passphrase, param) 22 | require.Nil(b, err) 23 | } 24 | }) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /simapp/genesis.go: -------------------------------------------------------------------------------- 1 | package simapp 2 | 3 | import ( 4 | "encoding/json" 5 | ) 6 | 7 | // The genesis state of the blockchain is represented here as a map of raw json 8 | // messages key'd by a identifier string. 9 | // The identifier is used to determine which module genesis information belongs 10 | // to so it may be appropriately routed during init chain. 11 | // Within this application default genesis information is retrieved from 12 | // the ModuleBasicManager which populates json from each BasicModule 13 | // object provided to it during init. 14 | type GenesisState map[string]json.RawMessage 15 | 16 | // NewDefaultGenesisState generates the default state for the application. 17 | func NewDefaultGenesisState() GenesisState { 18 | return ModuleBasics.DefaultGenesis() 19 | } 20 | -------------------------------------------------------------------------------- /client/keys/parse_test.go: -------------------------------------------------------------------------------- 1 | package keys 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | ) 8 | 9 | func TestParseKey(t *testing.T) { 10 | bech32str := "cosmos104ytdpvrx9284zd50v9ep8c6j7pua7dkk0x3ek" 11 | hexstr := "EB5AE9872103497EC092EF901027049E4F39200C60040D3562CD7F104A39F62E6E5A39A818F4" 12 | 13 | tests := []struct { 14 | name string 15 | args []string 16 | wantErr bool 17 | }{ 18 | {"empty input", []string{""}, true}, 19 | {"invalid input", []string{"invalid"}, true}, 20 | {"bech32", []string{bech32str}, false}, 21 | {"hex", []string{hexstr}, false}, 22 | } 23 | for _, tt := range tests { 24 | t.Run(tt.name, func(t *testing.T) { 25 | require.Equal(t, tt.wantErr, parseKey(nil, tt.args) != nil) 26 | }) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /docs/spec/circuit-breaker/01_concepts.md: -------------------------------------------------------------------------------- 1 | # Concepts 2 | 3 | The intention of the circuit breaker is to have a contingency plan for a 4 | running network which maintains network liveness. This can be achieved through 5 | selectively "pausing" functionality of specific modules on a running network. 6 | The circuit breaker is intended to be enabled through either: 7 | 8 | - governance 9 | - for emergencies a special subset of accounts selected by the state machine 10 | - a transaction which proves the expected behaviour is broken 11 | 12 | ## Pause state 13 | 14 | The basic pause state of any module simply disables all message routes to 15 | that module. Beyond that, it may be a appropriate for different modules to 16 | process begin-block/end-block in an altered "safe" way. 17 | 18 | -------------------------------------------------------------------------------- /server/constructors_test.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "path/filepath" 5 | "testing" 6 | 7 | "github.com/stretchr/testify/require" 8 | 9 | "github.com/cosmos/cosmos-sdk/tests" 10 | ) 11 | 12 | func Test_openDB(t *testing.T) { 13 | t.Parallel() 14 | dir, cleanup := tests.NewTestCaseDir(t) 15 | defer cleanup() 16 | _, err := openDB(dir) 17 | require.NoError(t, err) 18 | } 19 | 20 | func Test_openTraceWriter(t *testing.T) { 21 | t.Parallel() 22 | dir, cleanup := tests.NewTestCaseDir(t) 23 | defer cleanup() 24 | fname := filepath.Join(dir, "logfile") 25 | w, err := openTraceWriter(fname) 26 | require.NoError(t, err) 27 | require.NotNil(t, w) 28 | 29 | // test no-op 30 | w, err = openTraceWriter("") 31 | require.NoError(t, err) 32 | require.Nil(t, w) 33 | } 34 | -------------------------------------------------------------------------------- /x/slashing/types/querier.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | ) 6 | 7 | // QuerySigningInfoParams defines the params for the following queries: 8 | // - 'custom/slashing/signingInfo' 9 | type QuerySigningInfoParams struct { 10 | ConsAddress sdk.ConsAddress 11 | } 12 | 13 | func NewQuerySigningInfoParams(consAddr sdk.ConsAddress) QuerySigningInfoParams { 14 | return QuerySigningInfoParams{consAddr} 15 | } 16 | 17 | // QuerySigningInfosParams defines the params for the following queries: 18 | // - 'custom/slashing/signingInfos' 19 | type QuerySigningInfosParams struct { 20 | Page, Limit int 21 | } 22 | 23 | func NewQuerySigningInfosParams(page, limit int) QuerySigningInfosParams { 24 | return QuerySigningInfosParams{page, limit} 25 | } 26 | -------------------------------------------------------------------------------- /x/crisis/internal/types/errors.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | ) 6 | 7 | const ( 8 | // default codespace for crisis module 9 | DefaultCodespace sdk.CodespaceType = ModuleName 10 | 11 | // CodeInvalidInput is the codetype for invalid input for the crisis module 12 | CodeInvalidInput sdk.CodeType = 103 13 | ) 14 | 15 | // ErrNilSender - no sender provided for the input 16 | func ErrNilSender(codespace sdk.CodespaceType) sdk.Error { 17 | return sdk.NewError(codespace, CodeInvalidInput, "sender address is nil") 18 | } 19 | 20 | // ErrUnknownInvariant - unknown invariant provided 21 | func ErrUnknownInvariant(codespace sdk.CodespaceType) sdk.Error { 22 | return sdk.NewError(codespace, CodeInvalidInput, "unknown invariant") 23 | } 24 | -------------------------------------------------------------------------------- /client/keys/list.go: -------------------------------------------------------------------------------- 1 | package keys 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/client/flags" 5 | "github.com/spf13/cobra" 6 | ) 7 | 8 | func listKeysCmd() *cobra.Command { 9 | cmd := &cobra.Command{ 10 | Use: "list", 11 | Short: "List all keys", 12 | Long: `Return a list of all public keys stored by this key manager 13 | along with their associated name and address.`, 14 | RunE: runListCmd, 15 | } 16 | cmd.Flags().Bool(flags.FlagIndentResponse, false, "Add indent to JSON response") 17 | return cmd 18 | } 19 | 20 | func runListCmd(cmd *cobra.Command, args []string) error { 21 | kb, err := NewKeyBaseFromHomeFlag() 22 | if err != nil { 23 | return err 24 | } 25 | 26 | infos, err := kb.List() 27 | if err == nil { 28 | printInfos(infos) 29 | } 30 | return err 31 | } 32 | -------------------------------------------------------------------------------- /x/distribution/client/rest/utils.go: -------------------------------------------------------------------------------- 1 | package rest 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | "github.com/cosmos/cosmos-sdk/types/rest" 6 | ) 7 | 8 | type ( 9 | // CommunityPoolSpendProposalReq defines a community pool spend proposal request body. 10 | CommunityPoolSpendProposalReq struct { 11 | BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` 12 | 13 | Title string `json:"title" yaml:"title"` 14 | Description string `json:"description" yaml:"description"` 15 | Recipient sdk.AccAddress `json:"recipient" yaml:"recipient"` 16 | Amount sdk.Coins `json:"amount" yaml:"amount"` 17 | Proposer sdk.AccAddress `json:"proposer" yaml:"proposer"` 18 | Deposit sdk.Coins `json:"deposit" yaml:"deposit"` 19 | } 20 | ) 21 | -------------------------------------------------------------------------------- /contrib/devtools/install-golangci-lint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -euo pipefail 4 | 5 | f_sha256() { 6 | local l_file 7 | l_file=$1 8 | python -sBc "import hashlib;print(hashlib.sha256(open('$l_file','rb').read()).hexdigest())" 9 | } 10 | 11 | installer="$(mktemp)" 12 | trap "rm -f ${installer}" EXIT 13 | 14 | GOBIN="${1}" 15 | VERSION="${2}" 16 | HASHSUM="${3}" 17 | CURL="$(which curl)" 18 | 19 | echo "Downloading golangci-lint ${VERSION} installer ..." >&2 20 | "${CURL}" -sfL "https://raw.githubusercontent.com/golangci/golangci-lint/${VERSION}/install.sh" > "${installer}" 21 | 22 | echo "Checking hashsum ..." >&2 23 | [ "${HASHSUM}" = "$(f_sha256 ${installer})" ] 24 | chmod +x "${installer}" 25 | 26 | echo "Launching installer ..." >&2 27 | exec "${installer}" -d -b "${GOBIN}" "${VERSION}" 28 | -------------------------------------------------------------------------------- /docs/spec/bank/04_events.md: -------------------------------------------------------------------------------- 1 | # Events 2 | 3 | The bank module emits the following events: 4 | 5 | ## Handlers 6 | 7 | ### MsgSend 8 | 9 | | Type | Attribute Key | Attribute Value | 10 | |----------|---------------|--------------------| 11 | | transfer | recipient | {recipientAddress} | 12 | | message | module | bank | 13 | | message | action | send | 14 | | message | sender | {senderAddress} | 15 | 16 | ### MsgMultiSend 17 | 18 | | Type | Attribute Key | Attribute Value | 19 | |----------|---------------|--------------------| 20 | | transfer | recipient | {recipientAddress} | 21 | | message | module | bank | 22 | | message | action | multisend | 23 | | message | sender | {senderAddress} | 24 | -------------------------------------------------------------------------------- /.pending/breaking/sdk/3972-supply: -------------------------------------------------------------------------------- 1 | #4255 Add supply module that passively tracks the supplies of a chain 2 | - Renamed `x/distribution` `ModuleName` 3 | - Genesis JSON and CLI now use `distribution` instead of `distr` 4 | - Introduce `ModuleAccount` type, which tracks the flow of coins held within a module 5 | - Replaced `FeeCollectorKeeper` for a `ModuleAccount` 6 | - Replaced the staking `Pool`, which coins are now held by the `BondedPool` and `NotBonded` module accounts 7 | - The `NotBonded` module account now only keeps track of the not bonded tokens within staking, instead of the whole chain 8 | - #3628 Replaced governance's burn and deposit accounts for a `ModuleAccount` 9 | - Added a `ModuleAccount` for the distribution module 10 | - Added a `ModuleAccount` for the mint module 11 | #4472 validation for crisis genesis -------------------------------------------------------------------------------- /.pending/breaking/sdk/4387-Refactor-the-us: -------------------------------------------------------------------------------- 1 | #4387 Refactor the usage of tags (now called events) to reflect the 2 | new ABCI events semantics: 3 | 4 | - Move `x/{module}/tags/tags.go` => `x/{module}/types/events.go` 5 | - Update `docs/specs` 6 | - Refactor tags in favor of new `Event(s)` type(s) 7 | - Update `Context` to use new `EventManager` 8 | - (Begin|End)Blocker no longer return tags, but rather uses new `EventManager` 9 | - Message handlers no longer return tags, but rather uses new `EventManager` 10 | 11 | Any component (e.g. BeginBlocker, message handler, etc...) wishing to emit an event must do so 12 | through `ctx.EventManger().EmitEvent(s)`. 13 | 14 | To reset or wipe emitted events: `ctx = ctx.WithEventManager(sdk.NewEventManager())` 15 | To get all emitted events: `events := ctx.EventManager().Events()` 16 | -------------------------------------------------------------------------------- /baseapp/queryrouter_test.go: -------------------------------------------------------------------------------- 1 | package baseapp 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | 8 | abci "github.com/tendermint/tendermint/abci/types" 9 | 10 | sdk "github.com/cosmos/cosmos-sdk/types" 11 | ) 12 | 13 | var testQuerier = func(_ sdk.Context, _ []string, _ abci.RequestQuery) (res []byte, err sdk.Error) { 14 | return nil, nil 15 | } 16 | 17 | func TestQueryRouter(t *testing.T) { 18 | qr := NewQueryRouter() 19 | 20 | // require panic on invalid route 21 | require.Panics(t, func() { 22 | qr.AddRoute("*", testQuerier) 23 | }) 24 | 25 | qr.AddRoute("testRoute", testQuerier) 26 | q := qr.Route("testRoute") 27 | require.NotNil(t, q) 28 | 29 | // require panic on duplicate route 30 | require.Panics(t, func() { 31 | qr.AddRoute("testRoute", testQuerier) 32 | }) 33 | } 34 | -------------------------------------------------------------------------------- /server/mock/store_test.go: -------------------------------------------------------------------------------- 1 | package mock 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | 8 | dbm "github.com/tendermint/tendermint/libs/db" 9 | 10 | sdk "github.com/cosmos/cosmos-sdk/types" 11 | ) 12 | 13 | func TestStore(t *testing.T) { 14 | db := dbm.NewMemDB() 15 | cms := NewCommitMultiStore() 16 | 17 | key := sdk.NewKVStoreKey("test") 18 | cms.MountStoreWithDB(key, sdk.StoreTypeIAVL, db) 19 | err := cms.LoadLatestVersion() 20 | require.Nil(t, err) 21 | 22 | store := cms.GetKVStore(key) 23 | require.NotNil(t, store) 24 | 25 | k := []byte("hello") 26 | v := []byte("world") 27 | require.False(t, store.Has(k)) 28 | store.Set(k, v) 29 | require.True(t, store.Has(k)) 30 | require.Equal(t, v, store.Get(k)) 31 | store.Delete(k) 32 | require.False(t, store.Has(k)) 33 | } 34 | -------------------------------------------------------------------------------- /x/distribution/keeper/alias_functions.go: -------------------------------------------------------------------------------- 1 | package keeper 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | "github.com/cosmos/cosmos-sdk/x/distribution/types" 6 | "github.com/cosmos/cosmos-sdk/x/supply/exported" 7 | ) 8 | 9 | // get outstanding rewards 10 | func (k Keeper) GetValidatorOutstandingRewardsCoins(ctx sdk.Context, val sdk.ValAddress) sdk.DecCoins { 11 | return k.GetValidatorOutstandingRewards(ctx, val) 12 | } 13 | 14 | // get the community coins 15 | func (k Keeper) GetFeePoolCommunityCoins(ctx sdk.Context) sdk.DecCoins { 16 | return k.GetFeePool(ctx).CommunityPool 17 | } 18 | 19 | // GetDistributionAccount returns the distribution ModuleAccount 20 | func (k Keeper) GetDistributionAccount(ctx sdk.Context) exported.ModuleAccountI { 21 | return k.supplyKeeper.GetModuleAccount(ctx, types.ModuleName) 22 | } 23 | -------------------------------------------------------------------------------- /docs/spec/slashing/05_hooks.md: -------------------------------------------------------------------------------- 1 | ## Hooks 2 | 3 | In this section we describe the "hooks" - slashing module code that runs when other events happen. 4 | 5 | ### Validator Bonded 6 | 7 | Upon successful first-time bonding of a new validator, we create a new `ValidatorSigningInfo` structure for the 8 | now-bonded validator, which `StartHeight` of the current block. 9 | 10 | ``` 11 | onValidatorBonded(address sdk.ValAddress) 12 | 13 | signingInfo, found = getValidatorSigningInfo(address) 14 | if !found { 15 | signingInfo = ValidatorSigningInfo { 16 | StartHeight : CurrentHeight, 17 | IndexOffset : 0, 18 | JailedUntil : time.Unix(0, 0), 19 | Tombstone : false, 20 | MissedBloskCounter : 0 21 | } 22 | setValidatorSigningInfo(signingInfo) 23 | } 24 | 25 | return 26 | ``` 27 | -------------------------------------------------------------------------------- /x/staking/types/codec.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/codec" 5 | ) 6 | 7 | // Register concrete types on codec codec 8 | func RegisterCodec(cdc *codec.Codec) { 9 | cdc.RegisterConcrete(MsgCreateValidator{}, "cosmos-sdk/MsgCreateValidator", nil) 10 | cdc.RegisterConcrete(MsgEditValidator{}, "cosmos-sdk/MsgEditValidator", nil) 11 | cdc.RegisterConcrete(MsgDelegate{}, "cosmos-sdk/MsgDelegate", nil) 12 | cdc.RegisterConcrete(MsgUndelegate{}, "cosmos-sdk/MsgUndelegate", nil) 13 | cdc.RegisterConcrete(MsgBeginRedelegate{}, "cosmos-sdk/MsgBeginRedelegate", nil) 14 | } 15 | 16 | // generic sealed codec to be used throughout this module 17 | var ModuleCdc *codec.Codec 18 | 19 | func init() { 20 | ModuleCdc = codec.New() 21 | RegisterCodec(ModuleCdc) 22 | codec.RegisterCrypto(ModuleCdc) 23 | ModuleCdc.Seal() 24 | } 25 | -------------------------------------------------------------------------------- /x/distribution/types/codec.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/codec" 5 | ) 6 | 7 | // Register concrete types on codec codec 8 | func RegisterCodec(cdc *codec.Codec) { 9 | cdc.RegisterConcrete(MsgWithdrawDelegatorReward{}, "cosmos-sdk/MsgWithdrawDelegationReward", nil) 10 | cdc.RegisterConcrete(MsgWithdrawValidatorCommission{}, "cosmos-sdk/MsgWithdrawValidatorCommission", nil) 11 | cdc.RegisterConcrete(MsgSetWithdrawAddress{}, "cosmos-sdk/MsgModifyWithdrawAddress", nil) 12 | cdc.RegisterConcrete(CommunityPoolSpendProposal{}, "cosmos-sdk/CommunityPoolSpendProposal", nil) 13 | } 14 | 15 | // generic sealed codec to be used throughout module 16 | var ModuleCdc *codec.Codec 17 | 18 | func init() { 19 | ModuleCdc = codec.New() 20 | RegisterCodec(ModuleCdc) 21 | codec.RegisterCrypto(ModuleCdc) 22 | ModuleCdc.Seal() 23 | } 24 | -------------------------------------------------------------------------------- /x/auth/types/stdsignmsg.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | ) 6 | 7 | // StdSignMsg is a convenience structure for passing along 8 | // a Msg with the other requirements for a StdSignDoc before 9 | // it is signed. For use in the CLI. 10 | type StdSignMsg struct { 11 | ChainID string `json:"chain_id" yaml:"chain_id"` 12 | AccountNumber uint64 `json:"account_number" yaml:"account_number"` 13 | Sequence uint64 `json:"sequence" yaml:"sequence"` 14 | Fee StdFee `json:"fee" yaml:"fee"` 15 | Msgs []sdk.Msg `json:"msgs" yaml:"msgs"` 16 | Memo string `json:"memo" yaml:"memo"` 17 | } 18 | 19 | // get message bytes 20 | func (msg StdSignMsg) Bytes() []byte { 21 | return StdSignBytes(msg.ChainID, msg.AccountNumber, msg.Sequence, msg.Fee, msg.Msgs, msg.Memo) 22 | } 23 | -------------------------------------------------------------------------------- /client/utils.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | // Paginate returns the correct starting and ending index for a paginated query, 4 | // given that client provides a desired page and limit of objects and the handler 5 | // provides the total number of objects. If the start page is invalid, non-positive 6 | // values are returned signaling the request is invalid. 7 | // 8 | // NOTE: The start page is assumed to be 1-indexed. 9 | func Paginate(numObjs, page, limit, defLimit int) (start, end int) { 10 | if page == 0 { 11 | // invalid start page 12 | return -1, -1 13 | } else if limit == 0 { 14 | limit = defLimit 15 | } 16 | 17 | start = (page - 1) * limit 18 | end = limit + start 19 | 20 | if end >= numObjs { 21 | end = numObjs 22 | } 23 | 24 | if start >= numObjs { 25 | // page is out of bounds 26 | return -1, -1 27 | } 28 | 29 | return start, end 30 | } 31 | -------------------------------------------------------------------------------- /server/mock/helpers.go: -------------------------------------------------------------------------------- 1 | package mock 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "os" 7 | 8 | abci "github.com/tendermint/tendermint/abci/types" 9 | "github.com/tendermint/tendermint/libs/log" 10 | ) 11 | 12 | // SetupApp returns an application as well as a clean-up function 13 | // to be used to quickly setup a test case with an app 14 | func SetupApp() (abci.Application, func(), error) { 15 | logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)). 16 | With("module", "mock") 17 | rootDir, err := ioutil.TempDir("", "mock-sdk") 18 | if err != nil { 19 | return nil, nil, err 20 | } 21 | 22 | cleanup := func() { 23 | err := os.RemoveAll(rootDir) 24 | if err != nil { 25 | fmt.Printf("could not delete %s, had error %s\n", rootDir, err.Error()) 26 | } 27 | } 28 | 29 | app, err := NewApp(rootDir, logger) 30 | return app, cleanup, err 31 | } 32 | -------------------------------------------------------------------------------- /x/auth/client/rest/rest.go: -------------------------------------------------------------------------------- 1 | package rest 2 | 3 | import ( 4 | "github.com/gorilla/mux" 5 | 6 | "github.com/cosmos/cosmos-sdk/client/context" 7 | ) 8 | 9 | // RegisterRoutes registers the auth module REST routes. 10 | func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, storeName string) { 11 | r.HandleFunc( 12 | "/auth/accounts/{address}", QueryAccountRequestHandlerFn(storeName, cliCtx), 13 | ).Methods("GET") 14 | } 15 | 16 | // RegisterTxRoutes registers all transaction routes on the provided router. 17 | func RegisterTxRoutes(cliCtx context.CLIContext, r *mux.Router) { 18 | r.HandleFunc("/txs/{hash}", QueryTxRequestHandlerFn(cliCtx)).Methods("GET") 19 | r.HandleFunc("/txs", QueryTxsByEventsRequestHandlerFn(cliCtx)).Methods("GET") 20 | r.HandleFunc("/txs", BroadcastTxRequest(cliCtx)).Methods("POST") 21 | r.HandleFunc("/txs/encode", EncodeTxRequestHandlerFn(cliCtx)).Methods("POST") 22 | } 23 | -------------------------------------------------------------------------------- /client/keys/export_test.go: -------------------------------------------------------------------------------- 1 | package keys 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/spf13/viper" 7 | "github.com/stretchr/testify/assert" 8 | 9 | "github.com/cosmos/cosmos-sdk/client/flags" 10 | "github.com/cosmos/cosmos-sdk/tests" 11 | ) 12 | 13 | func Test_runExportCmd(t *testing.T) { 14 | exportKeyCommand := exportKeyCommand() 15 | 16 | // Now add a temporary keybase 17 | kbHome, cleanUp := tests.NewTestCaseDir(t) 18 | defer cleanUp() 19 | viper.Set(flags.FlagHome, kbHome) 20 | 21 | // create a key 22 | kb, err := NewKeyBaseFromHomeFlag() 23 | assert.NoError(t, err) 24 | _, err = kb.CreateAccount("keyname1", tests.TestMnemonic, "", "123456789", 0, 0) 25 | assert.NoError(t, err) 26 | 27 | mockIn, _, _ := tests.ApplyMockIO(exportKeyCommand) 28 | mockIn.Reset("123456789\n123456789\n") 29 | // Now enter password 30 | assert.NoError(t, runExportCmd(exportKeyCommand, []string{"keyname1"})) 31 | } 32 | -------------------------------------------------------------------------------- /x/auth/types/keys.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | ) 6 | 7 | const ( 8 | // module name 9 | ModuleName = "auth" 10 | 11 | // StoreKey is string representation of the store key for auth 12 | StoreKey = "acc" 13 | 14 | // FeeCollectorName the root string for the fee collector account address 15 | FeeCollectorName = "FeeCollector" 16 | 17 | // QuerierRoute is the querier route for acc 18 | QuerierRoute = StoreKey 19 | ) 20 | 21 | var ( 22 | // AddressStoreKeyPrefix prefix for account-by-address store 23 | AddressStoreKeyPrefix = []byte{0x01} 24 | 25 | // param key for global account number 26 | GlobalAccountNumberKey = []byte("globalAccountNumber") 27 | ) 28 | 29 | // AddressStoreKey turn an address to key used to get it from the account store 30 | func AddressStoreKey(addr sdk.AccAddress) []byte { 31 | return append(AddressStoreKeyPrefix, addr.Bytes()...) 32 | } 33 | -------------------------------------------------------------------------------- /x/gov/client/proposal_handler.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/spf13/cobra" 5 | 6 | "github.com/cosmos/cosmos-sdk/client/context" 7 | "github.com/cosmos/cosmos-sdk/codec" 8 | "github.com/cosmos/cosmos-sdk/x/gov/client/rest" 9 | ) 10 | 11 | // function to create the rest handler 12 | type RESTHandlerFn func(context.CLIContext) rest.ProposalRESTHandler 13 | 14 | // function to create the cli handler 15 | type CLIHandlerFn func(*codec.Codec) *cobra.Command 16 | 17 | // The combined type for a proposal handler for both cli and rest 18 | type ProposalHandler struct { 19 | CLIHandler CLIHandlerFn 20 | RESTHandler RESTHandlerFn 21 | } 22 | 23 | // NewProposalHandler creates a new ProposalHandler object 24 | func NewProposalHandler(cliHandler CLIHandlerFn, restHandler RESTHandlerFn) ProposalHandler { 25 | return ProposalHandler{ 26 | CLIHandler: cliHandler, 27 | RESTHandler: restHandler, 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /docs/spec/mint/02_state.md: -------------------------------------------------------------------------------- 1 | # State 2 | 3 | ## Minter 4 | 5 | The minter is a space for holding current inflation information. 6 | 7 | - Minter: `0x00 -> amino(minter)` 8 | 9 | ```go 10 | type Minter struct { 11 | Inflation sdk.Dec // current annual inflation rate 12 | AnnualProvisions sdk.Dec // current annual exptected provisions 13 | } 14 | ``` 15 | 16 | ## Params 17 | 18 | Minting params are held in the global params store. 19 | 20 | - Params: `mint/params -> amino(params)` 21 | 22 | ```go 23 | type Params struct { 24 | MintDenom string // type of coin to mint 25 | InflationRateChange sdk.Dec // maximum annual change in inflation rate 26 | InflationMax sdk.Dec // maximum inflation rate 27 | InflationMin sdk.Dec // minimum inflation rate 28 | GoalBonded sdk.Dec // goal of percent bonded atoms 29 | BlocksPerYear uint64 // expected blocks per year 30 | } 31 | ``` 32 | -------------------------------------------------------------------------------- /client/context/errors.go: -------------------------------------------------------------------------------- 1 | package context 2 | 3 | import ( 4 | "fmt" 5 | 6 | sdk "github.com/cosmos/cosmos-sdk/types" 7 | ) 8 | 9 | // ErrInvalidAccount returns a standardized error reflecting that a given 10 | // account address does not exist. 11 | func ErrInvalidAccount(addr sdk.AccAddress) error { 12 | return fmt.Errorf(`No account with address %s was found in the state. 13 | Are you sure there has been a transaction involving it?`, addr) 14 | } 15 | 16 | // ErrVerifyCommit returns a common error reflecting that the blockchain commit at a given 17 | // height can't be verified. The reason is that the base checkpoint of the certifier is 18 | // newer than the given height 19 | func ErrVerifyCommit(height int64) error { 20 | return fmt.Errorf(`The height of base truststore in the light client is higher than height %d. 21 | Can't verify blockchain proof at this height. Please set --trust-node to true and try again`, height) 22 | } 23 | -------------------------------------------------------------------------------- /docs/spec/crisis/02_messages.md: -------------------------------------------------------------------------------- 1 | # Messages 2 | 3 | In this section we describe the processing of the crisis messages and the 4 | corresponding updates to the state. 5 | 6 | ## MsgVerifyInvariant 7 | 8 | Blockchain invariants can be checked using the `MsgVerifyInvariant` message. 9 | 10 | ```golang 11 | type MsgVerifyInvariant struct { 12 | Sender sdk.AccAddress 13 | InvariantRoute string 14 | } 15 | ``` 16 | 17 | This message is expected to fail if: 18 | - the sender does not have enough coins for the constant fee 19 | - the invariant route is not registered 20 | 21 | This message checks the invariant provided, and if the invariant is broken it 22 | panics, halting the blockchain. If the invariant is broken, the constant fee is 23 | never deducted as the transaction is never committed to a block (equivalent to 24 | being refunded). However, if the invariant is not broken, the constant fee will 25 | not be refunded. 26 | -------------------------------------------------------------------------------- /docs/spec/params/README.md: -------------------------------------------------------------------------------- 1 | # Params module specification 2 | 3 | ## Abstract 4 | 5 | Package params provides a globally available parameter store. 6 | 7 | There are two main types, Keeper and Subspace. Subspace is an isolated namespace for a 8 | paramstore, where keys are prefixed by preconfigured spacename. Keeper has a 9 | permission to access all existing spaces. 10 | 11 | Subspace can be used by the individual keepers, who needs a private parameter store 12 | that the other keeper cannot modify. Keeper can be used by the Governance keeper, 13 | who need to modify any parameter in case of the proposal passes. 14 | 15 | The following contents explains how to use params module for master and user modules. 16 | 17 | ## Contents 18 | 19 | 1. **[Keeper](01_keeper.md)** 20 | 2. **[Subspace](02_subspace.md)** 21 | - [Key](02_subspace.md#key) 22 | - [KeyTable](02_subspace.md#keytable) 23 | - [ParamSet](02_subspace.md#paramset) 24 | -------------------------------------------------------------------------------- /x/staking/client/cli/utils.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | import ( 4 | "errors" 5 | 6 | sdk "github.com/cosmos/cosmos-sdk/types" 7 | "github.com/cosmos/cosmos-sdk/x/staking/types" 8 | ) 9 | 10 | func buildCommissionRates(rateStr, maxRateStr, maxChangeRateStr string) (commission types.CommissionRates, err error) { 11 | if rateStr == "" || maxRateStr == "" || maxChangeRateStr == "" { 12 | return commission, errors.New("must specify all validator commission parameters") 13 | } 14 | 15 | rate, err := sdk.NewDecFromStr(rateStr) 16 | if err != nil { 17 | return commission, err 18 | } 19 | 20 | maxRate, err := sdk.NewDecFromStr(maxRateStr) 21 | if err != nil { 22 | return commission, err 23 | } 24 | 25 | maxChangeRate, err := sdk.NewDecFromStr(maxChangeRateStr) 26 | if err != nil { 27 | return commission, err 28 | } 29 | 30 | commission = types.NewCommissionRates(rate, maxRate, maxChangeRate) 31 | return commission, nil 32 | } 33 | -------------------------------------------------------------------------------- /x/staking/types/events.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // Staking module event types 4 | var ( 5 | EventTypeCompleteUnbonding = "complete_unbonding" 6 | EventTypeCompleteRedelegation = "complete_redelegation" 7 | EventTypeCreateValidator = "create_validator" 8 | EventTypeEditValidator = "edit_validator" 9 | EventTypeDelegate = "delegate" 10 | EventTypeUnbond = "unbond" 11 | EventTypeRedelegate = "redelegate" 12 | 13 | AttributeKeyValidator = "validator" 14 | AttributeKeyCommissionRate = "commission_rate" 15 | AttributeKeyMinSelfDelegation = "min_self_delegation" 16 | AttributeKeySrcValidator = "source_validator" 17 | AttributeKeyDstValidator = "destination_validator" 18 | AttributeKeyDelegator = "delegator" 19 | AttributeKeyAmount = "amount" 20 | AttributeKeyCompletionTime = "completion_time" 21 | AttributeValueCategory = ModuleName 22 | ) 23 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Create a report to help us squash bugs! 4 | 5 | --- 6 | 7 | 12 | 13 | ## Summary of Bug 14 | 15 | 16 | 17 | ## Version 18 | 19 | 20 | 21 | ## Steps to Reproduce 22 | 23 | 24 | 25 | ____ 26 | 27 | #### For Admin Use 28 | 29 | - [ ] Not duplicate issue 30 | - [ ] Appropriate labels applied 31 | - [ ] Appropriate contributors tagged 32 | - [ ] Contributor assigned/self-assigned 33 | -------------------------------------------------------------------------------- /store/rootmulti/dbadapter.go: -------------------------------------------------------------------------------- 1 | package rootmulti 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/store/dbadapter" 5 | "github.com/cosmos/cosmos-sdk/store/types" 6 | ) 7 | 8 | var commithash = []byte("FAKE_HASH") 9 | 10 | //---------------------------------------- 11 | // commitDBStoreWrapper should only be used for simulation/debugging, 12 | // as it doesn't compute any commit hash, and it cannot load older state. 13 | 14 | // Wrapper type for dbm.Db with implementation of KVStore 15 | type commitDBStoreAdapter struct { 16 | dbadapter.Store 17 | } 18 | 19 | func (cdsa commitDBStoreAdapter) Commit() types.CommitID { 20 | return types.CommitID{ 21 | Version: -1, 22 | Hash: commithash, 23 | } 24 | } 25 | 26 | func (cdsa commitDBStoreAdapter) LastCommitID() types.CommitID { 27 | return types.CommitID{ 28 | Version: -1, 29 | Hash: commithash, 30 | } 31 | } 32 | 33 | func (cdsa commitDBStoreAdapter) SetPruning(_ types.PruningOptions) {} 34 | -------------------------------------------------------------------------------- /x/slashing/querier_test.go: -------------------------------------------------------------------------------- 1 | package slashing 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | abci "github.com/tendermint/tendermint/abci/types" 8 | 9 | "github.com/cosmos/cosmos-sdk/codec" 10 | ) 11 | 12 | func TestNewQuerier(t *testing.T) { 13 | ctx, _, _, _, keeper := createTestInput(t, keeperTestParams()) 14 | querier := NewQuerier(keeper) 15 | 16 | query := abci.RequestQuery{ 17 | Path: "", 18 | Data: []byte{}, 19 | } 20 | 21 | _, err := querier(ctx, []string{"parameters"}, query) 22 | require.NoError(t, err) 23 | } 24 | 25 | func TestQueryParams(t *testing.T) { 26 | cdc := codec.New() 27 | ctx, _, _, _, keeper := createTestInput(t, keeperTestParams()) 28 | 29 | var params Params 30 | 31 | res, errRes := queryParams(ctx, keeper) 32 | require.NoError(t, errRes) 33 | 34 | err := cdc.UnmarshalJSON(res, ¶ms) 35 | require.NoError(t, err) 36 | require.Equal(t, keeper.GetParams(ctx), params) 37 | } 38 | -------------------------------------------------------------------------------- /client/keys/root.go: -------------------------------------------------------------------------------- 1 | package keys 2 | 3 | import ( 4 | "github.com/spf13/cobra" 5 | 6 | "github.com/cosmos/cosmos-sdk/client/flags" 7 | ) 8 | 9 | // Commands registers a sub-tree of commands to interact with 10 | // local private key storage. 11 | func Commands() *cobra.Command { 12 | cmd := &cobra.Command{ 13 | Use: "keys", 14 | Short: "Add or view local private keys", 15 | Long: `Keys allows you to manage your local keystore for tendermint. 16 | 17 | These keys may be in any format supported by go-crypto and can be 18 | used by light-clients, full nodes, or any other application that 19 | needs to sign with a private key.`, 20 | } 21 | cmd.AddCommand( 22 | mnemonicKeyCommand(), 23 | addKeyCommand(), 24 | exportKeyCommand(), 25 | importKeyCommand(), 26 | listKeysCmd(), 27 | showKeysCmd(), 28 | flags.LineBreak, 29 | deleteKeyCommand(), 30 | updateKeyCommand(), 31 | parseKeyStringCommand(), 32 | ) 33 | return cmd 34 | } 35 | -------------------------------------------------------------------------------- /types/invariant.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import "fmt" 4 | 5 | // An Invariant is a function which tests a particular invariant. 6 | // The invariant returns a descriptive message about what happened 7 | // and a boolean indicating whether the invariant has been broken. 8 | // The simulator will then halt and print the logs. 9 | type Invariant func(ctx Context) (string, bool) 10 | 11 | // Invariants defines a group of invariants 12 | type Invariants []Invariant 13 | 14 | // expected interface for registering invariants 15 | type InvariantRegistry interface { 16 | RegisterRoute(moduleName, route string, invar Invariant) 17 | } 18 | 19 | // FormatInvariant returns a standardized invariant message along with 20 | // a boolean indicating whether the invariant has been broken. 21 | func FormatInvariant(module, name, msg string, broken bool) (string, bool) { 22 | return fmt.Sprintf("%s: %s invariant\n%sinvariant broken: %v\n", 23 | module, name, msg, broken), broken 24 | } 25 | -------------------------------------------------------------------------------- /x/crisis/internal/types/genesis.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "fmt" 5 | 6 | sdk "github.com/cosmos/cosmos-sdk/types" 7 | ) 8 | 9 | // GenesisState - crisis genesis state 10 | type GenesisState struct { 11 | ConstantFee sdk.Coin `json:"constant_fee" yaml:"constant_fee"` 12 | } 13 | 14 | // NewGenesisState creates a new GenesisState object 15 | func NewGenesisState(constantFee sdk.Coin) GenesisState { 16 | return GenesisState{ 17 | ConstantFee: constantFee, 18 | } 19 | } 20 | 21 | // DefaultGenesisState creates a default GenesisState object 22 | func DefaultGenesisState() GenesisState { 23 | return GenesisState{ 24 | ConstantFee: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1000)), 25 | } 26 | } 27 | 28 | // ValidateGenesis - validate crisis genesis data 29 | func ValidateGenesis(data GenesisState) error { 30 | if !data.ConstantFee.IsPositive() { 31 | return fmt.Errorf("constant fee must be positive: %s", data.ConstantFee) 32 | } 33 | return nil 34 | } 35 | -------------------------------------------------------------------------------- /docs/clients/README.md: -------------------------------------------------------------------------------- 1 | # Clients 2 | 3 | This section explains contains information on clients for SDK based blockchain. 4 | 5 | >*NOTE*: This section is a WIP. 6 | 7 | ## Light-client 8 | 9 | Light-clients enable users to interact with your application without having to download the entire state history but with a good level of security. 10 | 11 | - [Overview of light clients](./lite/README.md) 12 | - [Starting a light-client server](./lite/getting_started.md) 13 | - [Light-client specification](./lite/specification.md) 14 | 15 | ## Other clients 16 | 17 | - [Command-Line interface for SDK-based blockchain](./cli.md) 18 | - [Service provider doc](./service-providers.md) 19 | 20 | ## Genesis upgrade 21 | 22 | If you need to upgrade your node you could export the genesis and migrate it to the new version through this script: 23 | 24 | ```bash 25 | migrate v0.36 genesis_0_34.json [--time "2019-04-22T17:00:11Z"] [--chain-id test] > ~/.gaiad/genesis.json 26 | ``` 27 | -------------------------------------------------------------------------------- /x/genutil/expected.go: -------------------------------------------------------------------------------- 1 | package genutil 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | abci "github.com/tendermint/tendermint/abci/types" 7 | 8 | "github.com/cosmos/cosmos-sdk/codec" 9 | sdk "github.com/cosmos/cosmos-sdk/types" 10 | "github.com/cosmos/cosmos-sdk/x/auth" 11 | ) 12 | 13 | // expected staking keeper 14 | type StakingKeeper interface { 15 | ApplyAndReturnValidatorSetUpdates(sdk.Context) (updates []abci.ValidatorUpdate) 16 | } 17 | 18 | // expected account keeper 19 | type AccountKeeper interface { 20 | NewAccount(sdk.Context, auth.Account) auth.Account 21 | SetAccount(sdk.Context, auth.Account) 22 | IterateAccounts(ctx sdk.Context, process func(auth.Account) (stop bool)) 23 | } 24 | 25 | // The expected interface for iterating genesis accounts object 26 | type GenesisAccountsIterator interface { 27 | IterateGenesisAccounts( 28 | cdc *codec.Codec, 29 | appGenesis map[string]json.RawMessage, 30 | iterateFn func(auth.Account) (stop bool), 31 | ) 32 | } 33 | -------------------------------------------------------------------------------- /docs/translations/cn/clients/lite/getting_started.md: -------------------------------------------------------------------------------- 1 | # 入门 2 | 3 | 要启动 REST 服务器,我们需要指定以下参数: 4 | 5 | | 参数 | 类型 | 默认值 | 必填 | 描述 | 6 | | ----------- | --------- | ----------------------- | ----- | ---------------------------- | 7 | | chain-id | string | null | true | 要链接全节点的 chain id | 8 | | node | URL | "tcp://localhost:46657" | true | 要链接全节点的地址和端口号 | 9 | | laddr | URL | "tcp://localhost:1317" | true | 提供 REST 服务的地址和端口号 | 10 | | trust-node | bool | "false" | true | 是否信任 LCD 连接的全节点 | 11 | | trust-store | DIRECTORY | "$HOME/.lcd" | false | 保存检查点和验证人集的目录 | 12 | 13 | 示例: 14 | 15 | ```bash 16 | gaiacli rest-server --chain-id=test \ 17 | --laddr=tcp://localhost:1317 \ 18 | --node tcp://localhost:26657 \ 19 | --trust-node=false 20 | ``` 21 | 22 | 有关Gaia-Lite RPC的更多信息,请参阅 [swagger documentation](https://cosmos.network/rpc/) 23 | 24 | -------------------------------------------------------------------------------- /contrib/migrate/lib.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import json 5 | import sys 6 | 7 | 8 | def init_default_argument_parser(prog_desc, default_chain_id, default_start_time): 9 | parser = argparse.ArgumentParser(description=prog_desc) 10 | parser.add_argument( 11 | 'exported_genesis', 12 | help='exported genesis.json file', 13 | type=argparse.FileType('r'), default=sys.stdin, 14 | ) 15 | parser.add_argument('--chain-id', type=str, default=default_chain_id) 16 | parser.add_argument('--start-time', type=str, default=default_start_time) 17 | return parser 18 | 19 | 20 | def main(argument_parser, process_genesis_func): 21 | args = argument_parser.parse_args() 22 | if args.chain_id.strip() == '': 23 | sys.exit('chain-id required') 24 | 25 | genesis = json.loads(args.exported_genesis.read()) 26 | 27 | print(json.dumps(process_genesis_func( 28 | genesis=genesis, parsed_args=args,), indent=True)) 29 | -------------------------------------------------------------------------------- /store/dbadapter/store.go: -------------------------------------------------------------------------------- 1 | package dbadapter 2 | 3 | import ( 4 | "io" 5 | 6 | dbm "github.com/tendermint/tendermint/libs/db" 7 | 8 | "github.com/cosmos/cosmos-sdk/store/cachekv" 9 | "github.com/cosmos/cosmos-sdk/store/tracekv" 10 | "github.com/cosmos/cosmos-sdk/store/types" 11 | ) 12 | 13 | // Wrapper type for dbm.Db with implementation of KVStore 14 | type Store struct { 15 | dbm.DB 16 | } 17 | 18 | // GetStoreType returns the type of the store. 19 | func (Store) GetStoreType() types.StoreType { 20 | return types.StoreTypeDB 21 | } 22 | 23 | // CacheWrap cache wraps the underlying store. 24 | func (dsa Store) CacheWrap() types.CacheWrap { 25 | return cachekv.NewStore(dsa) 26 | } 27 | 28 | // CacheWrapWithTrace implements KVStore. 29 | func (dsa Store) CacheWrapWithTrace(w io.Writer, tc types.TraceContext) types.CacheWrap { 30 | return cachekv.NewStore(tracekv.NewStore(dsa, w, tc)) 31 | } 32 | 33 | // dbm.DB implements KVStore so we can CacheKVStore it. 34 | var _ types.KVStore = Store{} 35 | -------------------------------------------------------------------------------- /x/gov/types/events.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // Governance module event types 4 | const ( 5 | EventTypeSubmitProposal = "submit_proposal" 6 | EventTypeProposalDeposit = "proposal_deposit" 7 | EventTypeProposalVote = "proposal_vote" 8 | EventTypeInactiveProposal = "inactive_proposal" 9 | EventTypeActiveProposal = "active_proposal" 10 | 11 | AttributeKeyProposalResult = "proposal_result" 12 | AttributeKeyAmount = "amount" 13 | AttributeKeyOption = "option" 14 | AttributeKeyProposalID = "proposal_id" 15 | AttributeKeyVotingPeriodStart = "voting_period_start" 16 | AttributeValueCategory = "governance" 17 | AttributeValueProposalDropped = "proposal_dropped" // didn't meet min deposit 18 | AttributeValueProposalPassed = "proposal_passed" // met vote quorum 19 | AttributeValueProposalRejected = "proposal_rejected" // didn't meet vote quorum 20 | AttributeValueProposalFailed = "proposal_failed" // error on proposal handler 21 | ) 22 | -------------------------------------------------------------------------------- /x/auth/types/codec.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/codec" 5 | "github.com/cosmos/cosmos-sdk/x/auth/exported" 6 | ) 7 | 8 | // RegisterCodec registers concrete types on the codec 9 | func RegisterCodec(cdc *codec.Codec) { 10 | cdc.RegisterInterface((*exported.Account)(nil), nil) 11 | cdc.RegisterConcrete(&BaseAccount{}, "cosmos-sdk/Account", nil) 12 | cdc.RegisterInterface((*exported.VestingAccount)(nil), nil) 13 | cdc.RegisterConcrete(&BaseVestingAccount{}, "cosmos-sdk/BaseVestingAccount", nil) 14 | cdc.RegisterConcrete(&ContinuousVestingAccount{}, "cosmos-sdk/ContinuousVestingAccount", nil) 15 | cdc.RegisterConcrete(&DelayedVestingAccount{}, "cosmos-sdk/DelayedVestingAccount", nil) 16 | cdc.RegisterConcrete(StdTx{}, "cosmos-sdk/StdTx", nil) 17 | } 18 | 19 | // module wide codec 20 | var ModuleCdc *codec.Codec 21 | 22 | func init() { 23 | ModuleCdc = codec.New() 24 | RegisterCodec(ModuleCdc) 25 | codec.RegisterCrypto(ModuleCdc) 26 | ModuleCdc.Seal() 27 | } 28 | -------------------------------------------------------------------------------- /x/distribution/types/test_common.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "github.com/tendermint/tendermint/crypto" 5 | "github.com/tendermint/tendermint/crypto/ed25519" 6 | 7 | sdk "github.com/cosmos/cosmos-sdk/types" 8 | ) 9 | 10 | // nolint: deadcode unused 11 | var ( 12 | delPk1 = ed25519.GenPrivKey().PubKey() 13 | delPk2 = ed25519.GenPrivKey().PubKey() 14 | delPk3 = ed25519.GenPrivKey().PubKey() 15 | delAddr1 = sdk.AccAddress(delPk1.Address()) 16 | delAddr2 = sdk.AccAddress(delPk2.Address()) 17 | delAddr3 = sdk.AccAddress(delPk3.Address()) 18 | emptyDelAddr sdk.AccAddress 19 | 20 | valPk1 = ed25519.GenPrivKey().PubKey() 21 | valPk2 = ed25519.GenPrivKey().PubKey() 22 | valPk3 = ed25519.GenPrivKey().PubKey() 23 | valAddr1 = sdk.ValAddress(valPk1.Address()) 24 | valAddr2 = sdk.ValAddress(valPk2.Address()) 25 | valAddr3 = sdk.ValAddress(valPk3.Address()) 26 | emptyValAddr sdk.ValAddress 27 | 28 | emptyPubkey crypto.PubKey 29 | ) 30 | -------------------------------------------------------------------------------- /x/mint/internal/types/expected_keepers.go: -------------------------------------------------------------------------------- 1 | package types // noalias 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | "github.com/cosmos/cosmos-sdk/x/supply/exported" 6 | ) 7 | 8 | // StakingKeeper defines the expected staking keeper 9 | type StakingKeeper interface { 10 | StakingTokenSupply(ctx sdk.Context) sdk.Int 11 | BondedRatio(ctx sdk.Context) sdk.Dec 12 | } 13 | 14 | // SupplyKeeper defines the expected supply keeper 15 | type SupplyKeeper interface { 16 | GetModuleAddress(name string) sdk.AccAddress 17 | 18 | // TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862 19 | SetModuleAccount(sdk.Context, exported.ModuleAccountI) 20 | 21 | SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) sdk.Error 22 | SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) sdk.Error 23 | MintCoins(ctx sdk.Context, name string, amt sdk.Coins) sdk.Error 24 | } 25 | -------------------------------------------------------------------------------- /x/supply/internal/types/querier.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // query endpoints supported by the supply Querier 4 | const ( 5 | QueryTotalSupply = "total_supply" 6 | QuerySupplyOf = "supply_of" 7 | ) 8 | 9 | // QueryTotalSupply defines the params for the following queries: 10 | // 11 | // - 'custom/supply/totalSupply' 12 | type QueryTotalSupplyParams struct { 13 | Page, Limit int 14 | } 15 | 16 | // NewQueryTotalSupplyParams creates a new instance to query the total supply 17 | func NewQueryTotalSupplyParams(page, limit int) QueryTotalSupplyParams { 18 | return QueryTotalSupplyParams{page, limit} 19 | } 20 | 21 | // QuerySupplyOfParams defines the params for the following queries: 22 | // 23 | // - 'custom/supply/totalSupplyOf' 24 | type QuerySupplyOfParams struct { 25 | Denom string 26 | } 27 | 28 | // NewQuerySupplyOfParams creates a new instance to query the total supply 29 | // of a given denomination 30 | func NewQuerySupplyOfParams(denom string) QuerySupplyOfParams { 31 | return QuerySupplyOfParams{denom} 32 | } 33 | -------------------------------------------------------------------------------- /client/keys/import.go: -------------------------------------------------------------------------------- 1 | package keys 2 | 3 | import ( 4 | "bufio" 5 | "io/ioutil" 6 | 7 | "github.com/cosmos/cosmos-sdk/client/input" 8 | "github.com/spf13/cobra" 9 | ) 10 | 11 | func importKeyCommand() *cobra.Command { 12 | cmd := &cobra.Command{ 13 | Use: "import ", 14 | Short: "Import private keys into the local keybase", 15 | Long: "Import a ASCII armored private key into the local keybase.", 16 | Args: cobra.ExactArgs(2), 17 | RunE: runImportCmd, 18 | } 19 | return cmd 20 | } 21 | 22 | func runImportCmd(cmd *cobra.Command, args []string) error { 23 | kb, err := NewKeyBaseFromHomeFlag() 24 | if err != nil { 25 | return err 26 | } 27 | 28 | bz, err := ioutil.ReadFile(args[1]) 29 | if err != nil { 30 | return err 31 | } 32 | 33 | buf := bufio.NewReader(cmd.InOrStdin()) 34 | passphrase, err := input.GetPassword("Enter passphrase to decrypt your key:", buf) 35 | if err != nil { 36 | return err 37 | } 38 | 39 | return kb.ImportPrivKey(args[0], string(bz), passphrase) 40 | } 41 | -------------------------------------------------------------------------------- /client/cmd.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/pkg/errors" 7 | "github.com/spf13/cobra" 8 | ) 9 | 10 | // ValidateCmd returns unknown command error or Help display if help flag set 11 | func ValidateCmd(cmd *cobra.Command, args []string) error { 12 | var cmds []string 13 | var help bool 14 | 15 | // construct array of commands and search for help flag 16 | for _, arg := range args { 17 | if arg == "--help" || arg == "-h" { 18 | help = true 19 | } else if len(arg) > 0 && !(arg[0] == '-') { 20 | cmds = append(cmds, arg) 21 | } 22 | } 23 | 24 | if !help && len(cmds) > 0 { 25 | err := fmt.Sprintf("unknown command \"%s\" for \"%s\"", cmds[0], cmd.CalledAs()) 26 | 27 | // build suggestions for unknown argument 28 | if suggestions := cmd.SuggestionsFor(cmds[0]); len(suggestions) > 0 { 29 | err += "\n\nDid you mean this?\n" 30 | for _, s := range suggestions { 31 | err += fmt.Sprintf("\t%v\n", s) 32 | } 33 | } 34 | return errors.New(err) 35 | } 36 | 37 | return cmd.Help() 38 | } 39 | -------------------------------------------------------------------------------- /scripts/install/install_sdk_arm.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # change this to a specific release or branch 4 | BRANCH=master 5 | REPO=github.com/cosmos/cosmos-sdk 6 | 7 | GO_VERSION=1.12.5 8 | 9 | sudo apt-get update -y 10 | sudo apt-get upgrade -y 11 | sudo apt-get install -y make 12 | 13 | # get and unpack golang 14 | curl -O https://dl.google.com/go/go$GO_VERSION.linux-armv6l.tar.gz 15 | tar -xvf go$GO_VERSION.linux-armv6l.tar.gz 16 | 17 | # move go binary and add to path 18 | sudo mv go /usr/local 19 | echo "export PATH=\$PATH:/usr/local/go/bin" >> ~/.profile 20 | 21 | # create the go directory, set GOPATH, and put it on PATH 22 | mkdir go 23 | echo "export GOPATH=$HOME/go" >> ~/.profile 24 | echo "export PATH=\$PATH:\$GOPATH/bin" >> ~/.profile 25 | echo "export GO111MODULE=on" >> ~/.profile 26 | source ~/.profile 27 | 28 | # get the code and move into repo 29 | go get $REPO 30 | cd $GOPATH/src/$REPO 31 | 32 | # build & install master 33 | git checkout $BRANCH 34 | LEDGER_ENABLED=false make tools 35 | LEDGER_ENABLED=false make install 36 | 37 | source ~/.profile 38 | -------------------------------------------------------------------------------- /docs/spec/bank/README.md: -------------------------------------------------------------------------------- 1 | # Bank module specification 2 | 3 | ## Abstract 4 | 5 | This document specifies the bank module of the Cosmos SDK. 6 | 7 | The bank module is responsible for handling multi-asset coin transfers between 8 | accounts and tracking special-case pseudo-transfers which must work differently 9 | with particular kinds of accounts (notably delegating/undelegating for vesting 10 | accounts). It exposes several interfaces with varying capabilities for secure 11 | interaction with other modules which must alter user balances. 12 | 13 | This module will be used in the Cosmos Hub. 14 | 15 | ## Contents 16 | 17 | 1. **[State](01_state.md)** 18 | 2. **[Keepers](02_keepers.md)** 19 | - [Common Types](02_keepers.md#common-types) 20 | - [BaseKeeper](02_keepers.md#basekeeper) 21 | - [SendKeeper](02_keepers.md#sendkeeper) 22 | - [ViewKeeper](02_keepers.md#viewkeeper) 23 | 3. **[Messages](03_messages.md)** 24 | - [MsgSend](03_messages.md#msgsend) 25 | 4. **[Events](04_events.md)** 26 | - [Handlers](04_events.md#handlers) 27 | 5. **[Parameters](05_params.md)** 28 | -------------------------------------------------------------------------------- /docs/translations/kr/clients/lite/getting_started.md: -------------------------------------------------------------------------------- 1 | # REST 서버 시작하기 2 | 3 | REST 서버를 가동하기 위해서는 다음과 같은 파라미터 값을 정의해야 합니다: 4 | 5 | 6 | | 파라미터 | 형태 | 기본 값 | 필수/선택 | 설명 | 7 | | ----------- | --------- | ----------------------- | -------- | ---------------------------------------------------- | 8 | | chain-id | string | null | 필수 | 연결할 체인의 chain-id | 9 | | node | URL | "tcp://localhost:46657" | 필수 | 연결할 풀노드의 주소 | 10 | | laddr | URL | "tcp://localhost:1317" | 필수 | REST 서버를 가동할 주소 | 11 | | trust-node | bool | "false" | 필수 | 연결할 풀노드의 신뢰가능 여부 | 12 | | trust-store | DIRECTORY | "$HOME/.lcd" | 선택 | 체크포인트와 검증인 세트를 저장할 디렉터리 | 13 | 14 | 예를 들어:: 15 | 16 | ```bash 17 | gaiacli rest-server --chain-id=test \ 18 | --laddr=tcp://localhost:1317 \ 19 | --node tcp://localhost:26657 \ 20 | --trust-node=false 21 | ``` 22 | 23 | Gaia-Lite RPC에 대한 추가적인 정보를 원하시면 [Swagger 문서](https://cosmos.network/rpc/)를 확인하세요. 24 | -------------------------------------------------------------------------------- /server/util_test.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "encoding/json" 5 | "testing" 6 | 7 | "github.com/stretchr/testify/require" 8 | 9 | "github.com/cosmos/cosmos-sdk/codec" 10 | ) 11 | 12 | func TestInsertKeyJSON(t *testing.T) { 13 | cdc := codec.New() 14 | 15 | foo := map[string]string{"foo": "foofoo"} 16 | bar := map[string]string{"barInner": "barbar"} 17 | 18 | // create raw messages 19 | bz, err := cdc.MarshalJSON(foo) 20 | require.NoError(t, err) 21 | fooRaw := json.RawMessage(bz) 22 | 23 | bz, err = cdc.MarshalJSON(bar) 24 | require.NoError(t, err) 25 | barRaw := json.RawMessage(bz) 26 | 27 | // make the append 28 | appBz, err := InsertKeyJSON(cdc, fooRaw, "barOuter", barRaw) 29 | require.NoError(t, err) 30 | 31 | // test the append 32 | var appended map[string]json.RawMessage 33 | err = cdc.UnmarshalJSON(appBz, &appended) 34 | require.NoError(t, err) 35 | 36 | var resBar map[string]string 37 | err = cdc.UnmarshalJSON(appended["barOuter"], &resBar) 38 | require.NoError(t, err) 39 | 40 | require.Equal(t, bar, resBar, "appended: %v", appended) 41 | } 42 | -------------------------------------------------------------------------------- /x/slashing/simulation/msgs.go: -------------------------------------------------------------------------------- 1 | package simulation 2 | 3 | import ( 4 | "fmt" 5 | "math/rand" 6 | 7 | "github.com/cosmos/cosmos-sdk/baseapp" 8 | sdk "github.com/cosmos/cosmos-sdk/types" 9 | "github.com/cosmos/cosmos-sdk/x/simulation" 10 | "github.com/cosmos/cosmos-sdk/x/slashing" 11 | ) 12 | 13 | // SimulateMsgUnjail 14 | func SimulateMsgUnjail(k slashing.Keeper) simulation.Operation { 15 | return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, 16 | accs []simulation.Account) (opMsg simulation.OperationMsg, fOps []simulation.FutureOperation, err error) { 17 | 18 | acc := simulation.RandomAcc(r, accs) 19 | address := sdk.ValAddress(acc.Address) 20 | msg := slashing.NewMsgUnjail(address) 21 | if msg.ValidateBasic() != nil { 22 | return simulation.NoOpMsg(), nil, fmt.Errorf("expected msg to pass ValidateBasic: %s", msg.GetSignBytes()) 23 | } 24 | ctx, write := ctx.CacheContext() 25 | ok := slashing.NewHandler(k)(ctx, msg).IsOK() 26 | if ok { 27 | write() 28 | } 29 | opMsg = simulation.NewOperationMsg(msg, ok, "") 30 | return opMsg, nil, nil 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /version/command.go: -------------------------------------------------------------------------------- 1 | package version 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | 7 | "github.com/spf13/cobra" 8 | "github.com/spf13/viper" 9 | "gopkg.in/yaml.v2" 10 | 11 | "github.com/tendermint/tendermint/libs/cli" 12 | ) 13 | 14 | const flagLong = "long" 15 | 16 | func init() { 17 | Cmd.Flags().Bool(flagLong, false, "Print long version information") 18 | } 19 | 20 | // Cmd prints out the application's version information passed via build flags. 21 | var Cmd = &cobra.Command{ 22 | Use: "version", 23 | Short: "Print the app version", 24 | RunE: func(_ *cobra.Command, _ []string) error { 25 | verInfo := newVersionInfo() 26 | 27 | if !viper.GetBool(flagLong) { 28 | fmt.Println(verInfo.Version) 29 | return nil 30 | } 31 | 32 | var bz []byte 33 | var err error 34 | 35 | switch viper.GetString(cli.OutputFlag) { 36 | case "json": 37 | bz, err = json.Marshal(verInfo) 38 | default: 39 | bz, err = yaml.Marshal(&verInfo) 40 | } 41 | 42 | if err != nil { 43 | return err 44 | } 45 | 46 | _, err = fmt.Println(string(bz)) 47 | return err 48 | }, 49 | } 50 | -------------------------------------------------------------------------------- /store/firstlast.go: -------------------------------------------------------------------------------- 1 | package store 2 | 3 | import ( 4 | "bytes" 5 | 6 | cmn "github.com/tendermint/tendermint/libs/common" 7 | 8 | "github.com/cosmos/cosmos-sdk/store/types" 9 | ) 10 | 11 | // Gets the first item. 12 | func First(st KVStore, start, end []byte) (kv cmn.KVPair, ok bool) { 13 | iter := st.Iterator(start, end) 14 | if !iter.Valid() { 15 | return kv, false 16 | } 17 | defer iter.Close() 18 | 19 | return cmn.KVPair{Key: iter.Key(), Value: iter.Value()}, true 20 | } 21 | 22 | // Gets the last item. `end` is exclusive. 23 | func Last(st KVStore, start, end []byte) (kv cmn.KVPair, ok bool) { 24 | iter := st.ReverseIterator(end, start) 25 | if !iter.Valid() { 26 | if v := st.Get(start); v != nil { 27 | return cmn.KVPair{Key: types.Cp(start), Value: types.Cp(v)}, true 28 | } 29 | return kv, false 30 | } 31 | defer iter.Close() 32 | 33 | if bytes.Equal(iter.Key(), end) { 34 | // Skip this one, end is exclusive. 35 | iter.Next() 36 | if !iter.Valid() { 37 | return kv, false 38 | } 39 | } 40 | 41 | return cmn.KVPair{Key: iter.Key(), Value: iter.Value()}, true 42 | } 43 | -------------------------------------------------------------------------------- /store/transient/store.go: -------------------------------------------------------------------------------- 1 | package transient 2 | 3 | import ( 4 | dbm "github.com/tendermint/tendermint/libs/db" 5 | 6 | "github.com/cosmos/cosmos-sdk/store/types" 7 | 8 | "github.com/cosmos/cosmos-sdk/store/dbadapter" 9 | ) 10 | 11 | var _ types.Committer = (*Store)(nil) 12 | var _ types.KVStore = (*Store)(nil) 13 | 14 | // Store is a wrapper for a MemDB with Commiter implementation 15 | type Store struct { 16 | dbadapter.Store 17 | } 18 | 19 | // Constructs new MemDB adapter 20 | func NewStore() *Store { 21 | return &Store{dbadapter.Store{dbm.NewMemDB()}} 22 | } 23 | 24 | // Implements CommitStore 25 | // Commit cleans up Store. 26 | func (ts *Store) Commit() (id types.CommitID) { 27 | ts.Store = dbadapter.Store{dbm.NewMemDB()} 28 | return 29 | } 30 | 31 | // Implements CommitStore 32 | func (ts *Store) SetPruning(pruning types.PruningOptions) { 33 | } 34 | 35 | // Implements CommitStore 36 | func (ts *Store) LastCommitID() (id types.CommitID) { 37 | return 38 | } 39 | 40 | // Implements Store. 41 | func (ts *Store) GetStoreType() types.StoreType { 42 | return types.StoreTypeTransient 43 | } 44 | -------------------------------------------------------------------------------- /types/store_test.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | ) 8 | 9 | func TestPrefixEndBytes(t *testing.T) { 10 | var testCases = []struct { 11 | prefix []byte 12 | expected []byte 13 | }{ 14 | {[]byte{byte(55), byte(255), byte(255), byte(0)}, []byte{byte(55), byte(255), byte(255), byte(1)}}, 15 | {[]byte{byte(55), byte(255), byte(255), byte(15)}, []byte{byte(55), byte(255), byte(255), byte(16)}}, 16 | {[]byte{byte(55), byte(200), byte(255)}, []byte{byte(55), byte(201)}}, 17 | {[]byte{byte(55), byte(255), byte(255)}, []byte{byte(56)}}, 18 | {[]byte{byte(255), byte(255), byte(255)}, nil}, 19 | {[]byte{byte(255)}, nil}, 20 | {nil, nil}, 21 | } 22 | 23 | for _, test := range testCases { 24 | end := PrefixEndBytes(test.prefix) 25 | require.Equal(t, test.expected, end) 26 | } 27 | } 28 | 29 | func TestCommitID(t *testing.T) { 30 | var empty CommitID 31 | require.True(t, empty.IsZero()) 32 | 33 | var nonempty = CommitID{ 34 | Version: 1, 35 | Hash: []byte("testhash"), 36 | } 37 | require.False(t, nonempty.IsZero()) 38 | } 39 | -------------------------------------------------------------------------------- /x/distribution/keeper/fee_pool.go: -------------------------------------------------------------------------------- 1 | package keeper 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | "github.com/cosmos/cosmos-sdk/x/distribution/types" 6 | ) 7 | 8 | // DistributeFromFeePool distributes funds from the distribution module account to 9 | // a receiver address while updating the community pool 10 | func (k Keeper) DistributeFromFeePool(ctx sdk.Context, amount sdk.Coins, receiveAddr sdk.AccAddress) sdk.Error { 11 | feePool := k.GetFeePool(ctx) 12 | 13 | // NOTE the community pool isn't a module account, however its coins 14 | // are held in the distribution module account. Thus the community pool 15 | // must be reduced separately from the SendCoinsFromModuleToAccount call 16 | newPool, negative := feePool.CommunityPool.SafeSub(sdk.NewDecCoins(amount)) 17 | if negative { 18 | return types.ErrBadDistribution(k.codespace) 19 | } 20 | feePool.CommunityPool = newPool 21 | 22 | err := k.supplyKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, receiveAddr, amount) 23 | if err != nil { 24 | return err 25 | } 26 | 27 | k.SetFeePool(ctx, feePool) 28 | return nil 29 | } 30 | -------------------------------------------------------------------------------- /client/keys/update.go: -------------------------------------------------------------------------------- 1 | package keys 2 | 3 | import ( 4 | "bufio" 5 | 6 | "github.com/spf13/cobra" 7 | 8 | "github.com/cosmos/cosmos-sdk/client/input" 9 | ) 10 | 11 | func updateKeyCommand() *cobra.Command { 12 | cmd := &cobra.Command{ 13 | Use: "update ", 14 | Short: "Change the password used to protect private key", 15 | RunE: runUpdateCmd, 16 | Args: cobra.ExactArgs(1), 17 | } 18 | return cmd 19 | } 20 | 21 | func runUpdateCmd(cmd *cobra.Command, args []string) error { 22 | name := args[0] 23 | 24 | buf := bufio.NewReader(cmd.InOrStdin()) 25 | kb, err := NewKeyBaseFromHomeFlag() 26 | if err != nil { 27 | return err 28 | } 29 | oldpass, err := input.GetPassword("Enter the current passphrase:", buf) 30 | if err != nil { 31 | return err 32 | } 33 | 34 | getNewpass := func() (string, error) { 35 | return input.GetCheckPassword( 36 | "Enter the new passphrase:", 37 | "Repeat the new passphrase:", buf) 38 | } 39 | if err := kb.Update(name, oldpass, getNewpass); err != nil { 40 | return err 41 | } 42 | 43 | cmd.PrintErrln("Password successfully updated!") 44 | return nil 45 | } 46 | -------------------------------------------------------------------------------- /docs/spec/distribution/05_hooks.md: -------------------------------------------------------------------------------- 1 | # Hooks 2 | 3 | ## Create or modify delegation distribution 4 | 5 | - triggered-by: `staking.MsgDelegate`, `staking.MsgBeginRedelegate`, `staking.MsgUndelegate` 6 | 7 | The pool of a new delegator bond will be 0 for the height at which the bond was 8 | added, or the withdrawal has taken place. This is achieved by setting 9 | `DelegationDistInfo.WithdrawalHeight` to the height of the triggering transaction. 10 | 11 | ## Commission rate change 12 | 13 | - triggered-by: `staking.MsgEditValidator` 14 | 15 | If a validator changes its commission rate, all commission on fees must be 16 | simultaneously withdrawn using the transaction `TxWithdrawValidator`. 17 | Additionally the change and associated height must be recorded in a 18 | `ValidatorUpdate` state record. 19 | 20 | ## Change in Validator State 21 | 22 | - triggered-by: `staking.Slash`, `staking.UpdateValidator` 23 | 24 | Whenever a validator is slashed or enters/leaves the validator group all of the 25 | validator entitled reward tokens must be simultaneously withdrawn from 26 | `Global.Pool` and added to `ValidatorDistInfo.Pool`. 27 | -------------------------------------------------------------------------------- /types/abci.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import abci "github.com/tendermint/tendermint/abci/types" 4 | 5 | // InitChainer initializes application state at genesis 6 | type InitChainer func(ctx Context, req abci.RequestInitChain) abci.ResponseInitChain 7 | 8 | // BeginBlocker runs code before the transactions in a block 9 | // 10 | // Note: applications which set create_empty_blocks=false will not have regular block timing and should use 11 | // e.g. BFT timestamps rather than block height for any periodic BeginBlock logic 12 | type BeginBlocker func(ctx Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock 13 | 14 | // EndBlocker runs code after the transactions in a block and return updates to the validator set 15 | // 16 | // Note: applications which set create_empty_blocks=false will not have regular block timing and should use 17 | // e.g. BFT timestamps rather than block height for any periodic EndBlock logic 18 | type EndBlocker func(ctx Context, req abci.RequestEndBlock) abci.ResponseEndBlock 19 | 20 | // PeerFilter responds to p2p filtering queries from Tendermint 21 | type PeerFilter func(info string) abci.ResponseQuery 22 | -------------------------------------------------------------------------------- /x/gov/client/cli/parse.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "io/ioutil" 7 | 8 | "github.com/spf13/viper" 9 | 10 | govutils "github.com/cosmos/cosmos-sdk/x/gov/client/utils" 11 | ) 12 | 13 | func parseSubmitProposalFlags() (*proposal, error) { 14 | proposal := &proposal{} 15 | proposalFile := viper.GetString(FlagProposal) 16 | 17 | if proposalFile == "" { 18 | proposal.Title = viper.GetString(FlagTitle) 19 | proposal.Description = viper.GetString(FlagDescription) 20 | proposal.Type = govutils.NormalizeProposalType(viper.GetString(flagProposalType)) 21 | proposal.Deposit = viper.GetString(FlagDeposit) 22 | return proposal, nil 23 | } 24 | 25 | for _, flag := range ProposalFlags { 26 | if viper.GetString(flag) != "" { 27 | return nil, fmt.Errorf("--%s flag provided alongside --proposal, which is a noop", flag) 28 | } 29 | } 30 | 31 | contents, err := ioutil.ReadFile(proposalFile) 32 | if err != nil { 33 | return nil, err 34 | } 35 | 36 | err = json.Unmarshal(contents, proposal) 37 | if err != nil { 38 | return nil, err 39 | } 40 | 41 | return proposal, nil 42 | } 43 | -------------------------------------------------------------------------------- /x/supply/internal/types/expected_keepers.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | "github.com/cosmos/cosmos-sdk/x/auth/exported" 6 | ) 7 | 8 | // AccountKeeper defines the expected account keeper (noalias) 9 | type AccountKeeper interface { 10 | IterateAccounts(ctx sdk.Context, process func(exported.Account) (stop bool)) 11 | GetAccount(sdk.Context, sdk.AccAddress) exported.Account 12 | SetAccount(sdk.Context, exported.Account) 13 | NewAccount(sdk.Context, exported.Account) exported.Account 14 | } 15 | 16 | // BankKeeper defines the expected bank keeper (noalias) 17 | type BankKeeper interface { 18 | SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) sdk.Error 19 | DelegateCoins(ctx sdk.Context, fromAdd, toAddr sdk.AccAddress, amt sdk.Coins) sdk.Error 20 | UndelegateCoins(ctx sdk.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) sdk.Error 21 | 22 | SubtractCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) (sdk.Coins, sdk.Error) 23 | AddCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) (sdk.Coins, sdk.Error) 24 | } 25 | -------------------------------------------------------------------------------- /baseapp/helpers.go: -------------------------------------------------------------------------------- 1 | package baseapp 2 | 3 | import ( 4 | "regexp" 5 | 6 | abci "github.com/tendermint/tendermint/abci/types" 7 | 8 | sdk "github.com/cosmos/cosmos-sdk/types" 9 | ) 10 | 11 | var isAlphaNumeric = regexp.MustCompile(`^[a-zA-Z0-9]+$`).MatchString 12 | 13 | // nolint - Mostly for testing 14 | func (app *BaseApp) Check(tx sdk.Tx) (result sdk.Result) { 15 | return app.runTx(runTxModeCheck, nil, tx) 16 | } 17 | 18 | // nolint - full tx execution 19 | func (app *BaseApp) Simulate(txBytes []byte, tx sdk.Tx) (result sdk.Result) { 20 | return app.runTx(runTxModeSimulate, txBytes, tx) 21 | } 22 | 23 | // nolint 24 | func (app *BaseApp) Deliver(tx sdk.Tx) (result sdk.Result) { 25 | return app.runTx(runTxModeDeliver, nil, tx) 26 | } 27 | 28 | // Context with current {check, deliver}State of the app 29 | // used by tests 30 | func (app *BaseApp) NewContext(isCheckTx bool, header abci.Header) sdk.Context { 31 | if isCheckTx { 32 | return sdk.NewContext(app.checkState.ms, header, true, app.logger). 33 | WithMinGasPrices(app.minGasPrices) 34 | } 35 | 36 | return sdk.NewContext(app.deliverState.ms, header, false, app.logger) 37 | } 38 | -------------------------------------------------------------------------------- /docs/translations/cn/README.md: -------------------------------------------------------------------------------- 1 | # Cosmos SDK 文档 2 | 3 | ## 开始 4 | 5 | - **[SDK 介绍](./intro/README.md)**:从“高层”了解Cosmos SDK. 6 | - **[SDK 开发教程](https://github.com/cosmos/sdk-application-tutorial)**: 一个学习 SDK 的教程。它展示了如何从头开始基于 sdk 构建区块链, 并在此过程中解释了 SDK 的基本原理。 7 | 8 | 9 | ## 开发资源 10 | 11 | - [规范](./spec/README.md): Cosmos SDK 的模块及其他规范。 12 | - [SDK API 参考](https://godoc.org/github.com/cosmos/cosmos-sdk): Cosmos SDK Godocs 文档 。 13 | - [REST API 规范](https://cosmos.network/rpc/): 通过 REST 与 `gaia` 全节点交互的 API 列表。 14 | 15 | ## 创建新的 SDK 项目 16 | 17 | 若要创建新项目, 以下两个方法任选其一: 18 | 19 | - 克隆这个 [教程](https://github.com/cosmos/sdk-application-tutorial/),如果不需要, 请不要忘记从各种文件中删除 `nameservice` 模块。 20 | - 使用社区工具, 如 [chainkit](https://github.com/blocklayerhq/chainkit). 21 | 22 | ## Cosmos Hub 23 | 24 | Cosmos Hub (名为 `gaia`) 文档已经迁移到[这里](https://github.com/cosmos/gaia/tree/master/docs). 25 | 26 | ## 开发语言 27 | 28 | Cosmos-SDK 目前是用 [Golang](https://golang.org/)编写的, 尽管该框架同样可以在其他语言中实现。请联系我们获取有关资助其他语言实现的信息。 29 | 30 | ## 贡献 31 | 32 | 参考 [文档说明](https://github.com/cosmos/cosmos-sdk/blob/master/docs/DOCS_README.md) 了解构建细节及更新时注意事项。 33 | 34 | ## 版本 35 | 36 | 这份文档通过以下提交构建: 37 | -------------------------------------------------------------------------------- /x/supply/internal/keeper/keeper_test.go: -------------------------------------------------------------------------------- 1 | package keeper 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | 8 | sdk "github.com/cosmos/cosmos-sdk/types" 9 | ) 10 | 11 | func TestSupply(t *testing.T) { 12 | initialPower := int64(100) 13 | initTokens := sdk.TokensFromConsensusPower(initialPower) 14 | nAccs := int64(4) 15 | 16 | ctx, _, keeper := createTestInput(t, false, initialPower, nAccs) 17 | 18 | total := keeper.GetSupply(ctx).Total 19 | expectedTotal := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initTokens.MulRaw(nAccs))) 20 | 21 | require.Equal(t, expectedTotal, total) 22 | } 23 | 24 | func TestValidatePermissions(t *testing.T) { 25 | nAccs := int64(0) 26 | initialPower := int64(100) 27 | _, _, keeper := createTestInput(t, false, initialPower, nAccs) 28 | 29 | err := keeper.ValidatePermissions(multiPermAcc) 30 | require.NoError(t, err) 31 | 32 | err = keeper.ValidatePermissions(randomPermAcc) 33 | require.NoError(t, err) 34 | 35 | // add unregistered permissions 36 | randomPermAcc.AddPermissions("other") 37 | err = keeper.ValidatePermissions(randomPermAcc) 38 | require.Error(t, err) 39 | } 40 | -------------------------------------------------------------------------------- /x/bank/internal/types/errors.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | ) 6 | 7 | // Bank errors reserve 100 ~ 199. 8 | const ( 9 | DefaultCodespace sdk.CodespaceType = ModuleName 10 | 11 | CodeSendDisabled sdk.CodeType = 101 12 | CodeInvalidInputsOutputs sdk.CodeType = 102 13 | ) 14 | 15 | // ErrNoInputs is an error 16 | func ErrNoInputs(codespace sdk.CodespaceType) sdk.Error { 17 | return sdk.NewError(codespace, CodeInvalidInputsOutputs, "no inputs to send transaction") 18 | } 19 | 20 | // ErrNoOutputs is an error 21 | func ErrNoOutputs(codespace sdk.CodespaceType) sdk.Error { 22 | return sdk.NewError(codespace, CodeInvalidInputsOutputs, "no outputs to send transaction") 23 | } 24 | 25 | // ErrInputOutputMismatch is an error 26 | func ErrInputOutputMismatch(codespace sdk.CodespaceType) sdk.Error { 27 | return sdk.NewError(codespace, CodeInvalidInputsOutputs, "sum inputs != sum outputs") 28 | } 29 | 30 | // ErrSendDisabled is an error 31 | func ErrSendDisabled(codespace sdk.CodespaceType) sdk.Error { 32 | return sdk.NewError(codespace, CodeSendDisabled, "send transactions are currently disabled") 33 | } 34 | -------------------------------------------------------------------------------- /x/distribution/client/common/common_test.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | 8 | "github.com/cosmos/cosmos-sdk/client/context" 9 | "github.com/cosmos/cosmos-sdk/codec" 10 | ) 11 | 12 | func TestQueryDelegationRewardsAddrValidation(t *testing.T) { 13 | cdc := codec.New() 14 | ctx := context.NewCLIContext().WithCodec(cdc) 15 | type args struct { 16 | delAddr string 17 | valAddr string 18 | } 19 | tests := []struct { 20 | name string 21 | args args 22 | want []byte 23 | wantErr bool 24 | }{ 25 | {"invalid delegator address", args{"invalid", ""}, nil, true}, 26 | {"empty delegator address", args{"", ""}, nil, true}, 27 | {"invalid validator address", args{"cosmos1zxcsu7l5qxs53lvp0fqgd09a9r2g6kqrk2cdpa", "invalid"}, nil, true}, 28 | {"empty validator address", args{"cosmos1zxcsu7l5qxs53lvp0fqgd09a9r2g6kqrk2cdpa", ""}, nil, true}, 29 | } 30 | for _, tt := range tests { 31 | t.Run(tt.name, func(t *testing.T) { 32 | _, err := QueryDelegationRewards(ctx, "", tt.args.delAddr, tt.args.valAddr) 33 | require.True(t, err != nil, tt.wantErr) 34 | }) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /x/params/subspace/table_test.go: -------------------------------------------------------------------------------- 1 | package subspace 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | ) 8 | 9 | type testparams struct { 10 | i int64 11 | b bool 12 | } 13 | 14 | func (tp *testparams) ParamSetPairs() ParamSetPairs { 15 | return ParamSetPairs{ 16 | {[]byte("i"), &tp.i}, 17 | {[]byte("b"), &tp.b}, 18 | } 19 | } 20 | 21 | func TestKeyTable(t *testing.T) { 22 | table := NewKeyTable() 23 | 24 | require.Panics(t, func() { table.RegisterType([]byte(""), nil) }) 25 | require.Panics(t, func() { table.RegisterType([]byte("!@#$%"), nil) }) 26 | require.Panics(t, func() { table.RegisterType([]byte("hello,"), nil) }) 27 | require.Panics(t, func() { table.RegisterType([]byte("hello"), nil) }) 28 | 29 | require.NotPanics(t, func() { table.RegisterType([]byte("hello"), bool(false)) }) 30 | require.NotPanics(t, func() { table.RegisterType([]byte("world"), int64(0)) }) 31 | require.Panics(t, func() { table.RegisterType([]byte("hello"), bool(false)) }) 32 | 33 | require.NotPanics(t, func() { table.RegisterParamSet(&testparams{}) }) 34 | require.Panics(t, func() { table.RegisterParamSet(&testparams{}) }) 35 | } 36 | -------------------------------------------------------------------------------- /docs/spec/slashing/06_events.md: -------------------------------------------------------------------------------- 1 | # Tags 2 | 3 | The slashing module emits the following events/tags: 4 | 5 | ## BeginBlocker 6 | 7 | | Type | Attribute Key | Attribute Value | 8 | |-------|---------------|-----------------------------| 9 | | slash | address | {validatorConsensusAddress} | 10 | | slash | power | {validatorPower} | 11 | | slash | reason | {slashReason} | 12 | | slash | jailed [0] | {validatorConsensusAddress} | 13 | 14 | - [0] Only included if the validator is jailed. 15 | 16 | | Type | Attribute Key | Attribute Value | 17 | |----------|---------------|-----------------------------| 18 | | liveness | address | {validatorConsensusAddress} | 19 | | liveness | missed_blocks | {missedBlocksCounter} | 20 | | liveness | height | {blockHeight} | 21 | 22 | ## Handlers 23 | 24 | ### MsgUnjail 25 | 26 | | Type | Attribute Key | Attribute Value | 27 | |---------|---------------|-----------------| 28 | | message | module | slashing | 29 | | message | action | unjail | 30 | | message | sender | {senderAddress} | 31 | -------------------------------------------------------------------------------- /client/keys/export.go: -------------------------------------------------------------------------------- 1 | package keys 2 | 3 | import ( 4 | "bufio" 5 | 6 | "github.com/spf13/cobra" 7 | 8 | "github.com/cosmos/cosmos-sdk/client/input" 9 | ) 10 | 11 | func exportKeyCommand() *cobra.Command { 12 | cmd := &cobra.Command{ 13 | Use: "export ", 14 | Short: "Export private keys", 15 | Long: `Export a private key from the local keybase in ASCII-armored encrypted format.`, 16 | Args: cobra.ExactArgs(1), 17 | RunE: runExportCmd, 18 | } 19 | return cmd 20 | } 21 | 22 | func runExportCmd(cmd *cobra.Command, args []string) error { 23 | kb, err := NewKeyBaseFromHomeFlag() 24 | if err != nil { 25 | return err 26 | } 27 | 28 | buf := bufio.NewReader(cmd.InOrStdin()) 29 | decryptPassword, err := input.GetPassword("Enter passphrase to decrypt your key:", buf) 30 | if err != nil { 31 | return err 32 | } 33 | encryptPassword, err := input.GetPassword("Enter passphrase to encrypt the exported key:", buf) 34 | if err != nil { 35 | return err 36 | } 37 | 38 | armored, err := kb.ExportPrivKey(args[0], decryptPassword, encryptPassword) 39 | if err != nil { 40 | return err 41 | } 42 | 43 | cmd.Println(armored) 44 | return nil 45 | } 46 | -------------------------------------------------------------------------------- /scripts/install/install_sdk_ubuntu.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # XXX: this script is intended to be run from 4 | # a fresh Digital Ocean droplet with Ubuntu 5 | 6 | # change this to a specific release or branch 7 | BRANCH=master 8 | REPO=github.com/cosmos/cosmos-sdk 9 | 10 | GO_VERSION=1.12.5 11 | 12 | sudo apt-get update -y 13 | sudo apt-get upgrade -y 14 | sudo apt-get install -y make 15 | 16 | # get and unpack golang 17 | curl -O https://dl.google.com/go/go$GO_VERSION.linux-amd64.tar.gz 18 | tar -xvf go$GO_VERSION.linux-amd64.tar.gz 19 | 20 | # move go binary and add to path 21 | mv go /usr/local 22 | echo "export PATH=\$PATH:/usr/local/go/bin" >> ~/.profile 23 | 24 | # create the go directory, set GOPATH, and put it on PATH 25 | mkdir go 26 | echo "export GOPATH=$HOME/go" >> ~/.profile 27 | echo "export PATH=\$PATH:\$GOPATH/bin" >> ~/.profile 28 | echo "export GO111MODULE=on" >> ~/.profile 29 | source ~/.profile 30 | 31 | # get the code and move into repo 32 | go get $REPO 33 | cd $GOPATH/src/$REPO 34 | 35 | # build & install master 36 | git checkout $BRANCH 37 | LEDGER_ENABLED=false make tools 38 | LEDGER_ENABLED=false make install 39 | 40 | source ~/.profile 41 | -------------------------------------------------------------------------------- /baseapp/router.go: -------------------------------------------------------------------------------- 1 | package baseapp 2 | 3 | import ( 4 | "fmt" 5 | 6 | sdk "github.com/cosmos/cosmos-sdk/types" 7 | ) 8 | 9 | type router struct { 10 | routes map[string]sdk.Handler 11 | } 12 | 13 | var _ sdk.Router = NewRouter() 14 | 15 | // NewRouter returns a reference to a new router. 16 | // 17 | // TODO: Either make the function private or make return type (router) public. 18 | func NewRouter() *router { // nolint: golint 19 | return &router{ 20 | routes: make(map[string]sdk.Handler), 21 | } 22 | } 23 | 24 | // AddRoute adds a route path to the router with a given handler. The route must 25 | // be alphanumeric. 26 | func (rtr *router) AddRoute(path string, h sdk.Handler) sdk.Router { 27 | if !isAlphaNumeric(path) { 28 | panic("route expressions can only contain alphanumeric characters") 29 | } 30 | if rtr.routes[path] != nil { 31 | panic(fmt.Sprintf("route %s has already been initialized", path)) 32 | } 33 | 34 | rtr.routes[path] = h 35 | return rtr 36 | } 37 | 38 | // Route returns a handler for a given route path. 39 | // 40 | // TODO: Handle expressive matches. 41 | func (rtr *router) Route(path string) sdk.Handler { 42 | return rtr.routes[path] 43 | } 44 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 6 | 7 | - Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/cosmos-sdk/blob/develop/CONTRIBUTING.md#pr-targeting)) 8 | 9 | - [ ] Linked to github-issue with discussion and accepted design OR link to spec that describes this work. 10 | - [ ] Wrote tests 11 | - [ ] Updated relevant documentation (`docs/`) 12 | - [ ] Added a relevant changelog entry: `clog add [section] [stanza] [message]` 13 | - [ ] rereviewed `Files changed` in the github PR explorer 14 | 15 | ______ 16 | 17 | For Admin Use: 18 | - Added appropriate labels to PR (ex. wip, ready-for-review, docs) 19 | - Reviewers Assigned 20 | - Squashed all commits, uses message "Merge pull request #XYZ: [title]" ([coding standards](https://github.com/tendermint/coding/blob/master/README.md#merging-a-pr)) 21 | -------------------------------------------------------------------------------- /simapp/app_test.go: -------------------------------------------------------------------------------- 1 | package simapp 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | 7 | "github.com/stretchr/testify/require" 8 | "github.com/tendermint/tendermint/libs/db" 9 | "github.com/tendermint/tendermint/libs/log" 10 | 11 | "github.com/cosmos/cosmos-sdk/codec" 12 | 13 | abci "github.com/tendermint/tendermint/abci/types" 14 | ) 15 | 16 | func TestSimAppExport(t *testing.T) { 17 | db := db.NewMemDB() 18 | app := NewSimApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0) 19 | 20 | genesisState := NewDefaultGenesisState() 21 | stateBytes, err := codec.MarshalJSONIndent(app.cdc, genesisState) 22 | require.NoError(t, err) 23 | 24 | // Initialize the chain 25 | app.InitChain( 26 | abci.RequestInitChain{ 27 | Validators: []abci.ValidatorUpdate{}, 28 | AppStateBytes: stateBytes, 29 | }, 30 | ) 31 | app.Commit() 32 | 33 | // Making a new app object with the db, so that initchain hasn't been called 34 | app2 := NewSimApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0) 35 | _, _, err = app2.ExportAppStateAndValidators(false, []string{}) 36 | require.NoError(t, err, "ExportAppStateAndValidators should not have an error") 37 | } 38 | -------------------------------------------------------------------------------- /x/slashing/types/msg.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | ) 6 | 7 | // verify interface at compile time 8 | var _ sdk.Msg = &MsgUnjail{} 9 | 10 | // MsgUnjail - struct for unjailing jailed validator 11 | type MsgUnjail struct { 12 | ValidatorAddr sdk.ValAddress `json:"address" yaml:"address"` // address of the validator operator 13 | } 14 | 15 | func NewMsgUnjail(validatorAddr sdk.ValAddress) MsgUnjail { 16 | return MsgUnjail{ 17 | ValidatorAddr: validatorAddr, 18 | } 19 | } 20 | 21 | //nolint 22 | func (msg MsgUnjail) Route() string { return RouterKey } 23 | func (msg MsgUnjail) Type() string { return "unjail" } 24 | func (msg MsgUnjail) GetSigners() []sdk.AccAddress { 25 | return []sdk.AccAddress{sdk.AccAddress(msg.ValidatorAddr)} 26 | } 27 | 28 | // get the bytes for the message signer to sign on 29 | func (msg MsgUnjail) GetSignBytes() []byte { 30 | bz := ModuleCdc.MustMarshalJSON(msg) 31 | return sdk.MustSortJSON(bz) 32 | } 33 | 34 | // quick validity check 35 | func (msg MsgUnjail) ValidateBasic() sdk.Error { 36 | if msg.ValidatorAddr.Empty() { 37 | return ErrBadValidatorAddr(DefaultCodespace) 38 | } 39 | return nil 40 | } 41 | -------------------------------------------------------------------------------- /docs/spec/mint/01_concepts.md: -------------------------------------------------------------------------------- 1 | # Concepts 2 | 3 | ## The Minting Mechanism 4 | 5 | The minting mechanism was designed to: 6 | - allow for a flexible inflation rate determined by market demand targeting a particular bonded-stake ratio 7 | - effect a balance between market liquidity and staked supply 8 | 9 | In order to best determine the appropriate market rate for inflation rewards, a 10 | moving change rate is used. The moving change rate mechanism ensures that if 11 | the % bonded is either over or under the goal %-bonded, the inflation rate will 12 | adjust to further incentivize or disincentivize being bonded, respectively. Setting the goal 13 | %-bonded at less than 100% encourages the network to maintain some non-staked tokens 14 | which should help provide some liquidity. 15 | 16 | It can be broken down in the following way: 17 | - If the inflation rate is below the goal %-bonded the inflation rate will 18 | increase until a maximum value is reached 19 | - If the goal % bonded (67% in Cosmos-Hub) is maintained, then the inflation 20 | rate will stay constant 21 | - If the inflation rate is above the goal %-bonded the inflation rate will 22 | decrease until a minimum value is reached 23 | -------------------------------------------------------------------------------- /x/bank/genesis.go: -------------------------------------------------------------------------------- 1 | package bank 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | ) 6 | 7 | // GenesisState is the bank state that must be provided at genesis. 8 | type GenesisState struct { 9 | SendEnabled bool `json:"send_enabled" yaml:"send_enabled"` 10 | } 11 | 12 | // NewGenesisState creates a new genesis state. 13 | func NewGenesisState(sendEnabled bool) GenesisState { 14 | return GenesisState{SendEnabled: sendEnabled} 15 | } 16 | 17 | // DefaultGenesisState returns a default genesis state 18 | func DefaultGenesisState() GenesisState { return NewGenesisState(true) } 19 | 20 | // InitGenesis sets distribution information for genesis. 21 | func InitGenesis(ctx sdk.Context, keeper Keeper, data GenesisState) { 22 | keeper.SetSendEnabled(ctx, data.SendEnabled) 23 | } 24 | 25 | // ExportGenesis returns a GenesisState for a given context and keeper. 26 | func ExportGenesis(ctx sdk.Context, keeper Keeper) GenesisState { 27 | return NewGenesisState(keeper.GetSendEnabled(ctx)) 28 | } 29 | 30 | // ValidateGenesis performs basic validation of bank genesis data returning an 31 | // error for any failed validation criteria. 32 | func ValidateGenesis(data GenesisState) error { return nil } 33 | -------------------------------------------------------------------------------- /x/gov/types/codec.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/codec" 5 | ) 6 | 7 | // module codec 8 | var ModuleCdc = codec.New() 9 | 10 | // RegisterCodec registers all the necessary types and interfaces for 11 | // governance. 12 | func RegisterCodec(cdc *codec.Codec) { 13 | cdc.RegisterInterface((*Content)(nil), nil) 14 | 15 | cdc.RegisterConcrete(MsgSubmitProposal{}, "cosmos-sdk/MsgSubmitProposal", nil) 16 | cdc.RegisterConcrete(MsgDeposit{}, "cosmos-sdk/MsgDeposit", nil) 17 | cdc.RegisterConcrete(MsgVote{}, "cosmos-sdk/MsgVote", nil) 18 | 19 | cdc.RegisterConcrete(TextProposal{}, "cosmos-sdk/TextProposal", nil) 20 | cdc.RegisterConcrete(SoftwareUpgradeProposal{}, "cosmos-sdk/SoftwareUpgradeProposal", nil) 21 | } 22 | 23 | // RegisterProposalTypeCodec registers an external proposal content type defined 24 | // in another module for the internal ModuleCdc. This allows the MsgSubmitProposal 25 | // to be correctly Amino encoded and decoded. 26 | func RegisterProposalTypeCodec(o interface{}, name string) { 27 | ModuleCdc.RegisterConcrete(o, name, nil) 28 | } 29 | 30 | // TODO determine a good place to seal this codec 31 | func init() { 32 | RegisterCodec(ModuleCdc) 33 | } 34 | -------------------------------------------------------------------------------- /docs/spec/staking/05_hooks.md: -------------------------------------------------------------------------------- 1 | # Hooks 2 | 3 | Other modules may register operations to execute when a certain event has 4 | occurred within staking. These events can be registered to execute either 5 | right `Before` or `After` the staking event (as per the hook name). The 6 | following hooks can registered with staking: 7 | 8 | - `AfterValidatorCreated(Context, ValAddress)` 9 | - called when a validator is created 10 | - `BeforeValidatorModified(Context, ValAddress)` 11 | - called when a validator's state is changed 12 | - `AfterValidatorRemoved(Context, ConsAddress, ValAddress)` 13 | - called when a validator is deleted 14 | - `AfterValidatorBonded(Context, ConsAddress, ValAddress)` 15 | - called when a validator is bonded 16 | - `AfterValidatorBeginUnbonding(Context, ConsAddress, ValAddress)` 17 | - called when a validator begins unbonding 18 | - `BeforeDelegationCreated(Context, AccAddress, ValAddress)` 19 | - called when a delegation is created 20 | - `BeforeDelegationSharesModified(Context, AccAddress, ValAddress)` 21 | - called when a delegation's shares are modified 22 | - `BeforeDelegationRemoved(Context, AccAddress, ValAddress)` 23 | - called when a delegation is removed 24 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Create a proposal to request a feature 4 | 5 | --- 6 | 7 | 13 | 14 | ## Summary 15 | 16 | 17 | 18 | ## Problem Definition 19 | 20 | 24 | 25 | ## Proposal 26 | 27 | 28 | 29 | ____ 30 | 31 | #### For Admin Use 32 | 33 | - [ ] Not duplicate issue 34 | - [ ] Appropriate labels applied 35 | - [ ] Appropriate contributors tagged 36 | - [ ] Contributor assigned/self-assigned 37 | -------------------------------------------------------------------------------- /client/keys/import_test.go: -------------------------------------------------------------------------------- 1 | package keys 2 | 3 | import ( 4 | "io/ioutil" 5 | "path/filepath" 6 | "testing" 7 | 8 | "github.com/spf13/viper" 9 | "github.com/stretchr/testify/assert" 10 | "github.com/stretchr/testify/require" 11 | 12 | "github.com/cosmos/cosmos-sdk/client/flags" 13 | "github.com/cosmos/cosmos-sdk/tests" 14 | ) 15 | 16 | func Test_runImportCmd(t *testing.T) { 17 | importKeyCommand := importKeyCommand() 18 | 19 | // Now add a temporary keybase 20 | kbHome, cleanUp := tests.NewTestCaseDir(t) 21 | defer cleanUp() 22 | viper.Set(flags.FlagHome, kbHome) 23 | 24 | keyfile := filepath.Join(kbHome, "key.asc") 25 | armoredKey := `-----BEGIN TENDERMINT PRIVATE KEY----- 26 | salt: A790BB721D1C094260EA84F5E5B72289 27 | kdf: bcrypt 28 | 29 | HbP+c6JmeJy9JXe2rbbF1QtCX1gLqGcDQPBXiCtFvP7/8wTZtVOPj8vREzhZ9ElO 30 | 3P7YnrzPQThG0Q+ZnRSbl9MAS8uFAM4mqm5r/Ys= 31 | =f3l4 32 | -----END TENDERMINT PRIVATE KEY----- 33 | ` 34 | require.NoError(t, ioutil.WriteFile(keyfile, []byte(armoredKey), 0644)) 35 | 36 | // Now enter password 37 | mockIn, _, _ := tests.ApplyMockIO(importKeyCommand) 38 | mockIn.Reset("123456789\n") 39 | assert.NoError(t, runImportCmd(importKeyCommand, []string{"keyname1", keyfile})) 40 | } 41 | -------------------------------------------------------------------------------- /x/bank/internal/keeper/invariants.go: -------------------------------------------------------------------------------- 1 | package keeper 2 | 3 | import ( 4 | "fmt" 5 | 6 | sdk "github.com/cosmos/cosmos-sdk/types" 7 | "github.com/cosmos/cosmos-sdk/x/bank/internal/types" 8 | ) 9 | 10 | // register bank invariants 11 | func RegisterInvariants(ir sdk.InvariantRegistry, ak types.AccountKeeper) { 12 | ir.RegisterRoute(types.ModuleName, "nonnegative-outstanding", 13 | NonnegativeBalanceInvariant(ak)) 14 | } 15 | 16 | // NonnegativeBalanceInvariant checks that all accounts in the application have non-negative balances 17 | func NonnegativeBalanceInvariant(ak types.AccountKeeper) sdk.Invariant { 18 | return func(ctx sdk.Context) (string, bool) { 19 | var msg string 20 | var count int 21 | 22 | accts := ak.GetAllAccounts(ctx) 23 | for _, acc := range accts { 24 | coins := acc.GetCoins() 25 | if coins.IsAnyNegative() { 26 | count++ 27 | msg += fmt.Sprintf("\t%s has a negative denomination of %s\n", 28 | acc.GetAddress().String(), 29 | coins.String()) 30 | } 31 | } 32 | broken := count != 0 33 | 34 | return sdk.FormatInvariant(types.ModuleName, "nonnegative-outstanding", 35 | fmt.Sprintf("amount of negative accounts found %d\n%s", count, msg), broken) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /x/distribution/client/cli/utils.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | import ( 4 | "io/ioutil" 5 | 6 | "github.com/cosmos/cosmos-sdk/codec" 7 | sdk "github.com/cosmos/cosmos-sdk/types" 8 | ) 9 | 10 | type ( 11 | // CommunityPoolSpendProposalJSON defines a CommunityPoolSpendProposal with a deposit 12 | CommunityPoolSpendProposalJSON struct { 13 | Title string `json:"title" yaml:"title"` 14 | Description string `json:"description" yaml:"description"` 15 | Recipient sdk.AccAddress `json:"recipient" yaml:"recipient"` 16 | Amount sdk.Coins `json:"amount" yaml:"amount"` 17 | Deposit sdk.Coins `json:"deposit" yaml:"deposit"` 18 | } 19 | ) 20 | 21 | // ParseCommunityPoolSpendProposalJSON reads and parses a CommunityPoolSpendProposalJSON from a file. 22 | func ParseCommunityPoolSpendProposalJSON(cdc *codec.Codec, proposalFile string) (CommunityPoolSpendProposalJSON, error) { 23 | proposal := CommunityPoolSpendProposalJSON{} 24 | 25 | contents, err := ioutil.ReadFile(proposalFile) 26 | if err != nil { 27 | return proposal, err 28 | } 29 | 30 | if err := cdc.UnmarshalJSON(contents, &proposal); err != nil { 31 | return proposal, err 32 | } 33 | 34 | return proposal, nil 35 | } 36 | -------------------------------------------------------------------------------- /x/supply/genesis.go: -------------------------------------------------------------------------------- 1 | package supply 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | autypes "github.com/cosmos/cosmos-sdk/x/auth" 6 | "github.com/cosmos/cosmos-sdk/x/supply/internal/types" 7 | ) 8 | 9 | // InitGenesis sets supply information for genesis. 10 | func InitGenesis(ctx sdk.Context, keeper Keeper, ak types.AccountKeeper, data GenesisState) { 11 | // manually set the total supply based on accounts if not provided 12 | if data.Supply.Total.Empty() { 13 | var totalSupply sdk.Coins 14 | ak.IterateAccounts(ctx, 15 | func(acc autypes.Account) (stop bool) { 16 | totalSupply = totalSupply.Add(acc.GetCoins()) 17 | return false 18 | }, 19 | ) 20 | data.Supply.Total = totalSupply 21 | } 22 | keeper.SetSupply(ctx, data.Supply) 23 | } 24 | 25 | // ExportGenesis returns a GenesisState for a given context and keeper. 26 | func ExportGenesis(ctx sdk.Context, keeper Keeper) GenesisState { 27 | return NewGenesisState(keeper.GetSupply(ctx)) 28 | } 29 | 30 | // ValidateGenesis performs basic validation of supply genesis data returning an 31 | // error for any failed validation criteria. 32 | func ValidateGenesis(data GenesisState) error { 33 | return data.Supply.ValidateBasic() 34 | } 35 | -------------------------------------------------------------------------------- /tests/mocks/account_retriever.go: -------------------------------------------------------------------------------- 1 | package mocks 2 | 3 | import ( 4 | gomock "github.com/golang/mock/gomock" 5 | reflect "reflect" 6 | ) 7 | 8 | type MockNodeQuerier struct { 9 | ctrl *gomock.Controller 10 | recorder *MockNodeQuerierMockRecorder 11 | } 12 | 13 | type MockNodeQuerierMockRecorder struct { 14 | mock *MockNodeQuerier 15 | } 16 | 17 | func NewMockNodeQuerier(ctrl *gomock.Controller) *MockNodeQuerier { 18 | mock := &MockNodeQuerier{ctrl: ctrl} 19 | mock.recorder = &MockNodeQuerierMockRecorder{mock} 20 | return mock 21 | } 22 | 23 | func (m *MockNodeQuerier) EXPECT() *MockNodeQuerierMockRecorder { 24 | return m.recorder 25 | } 26 | 27 | func (m *MockNodeQuerier) QueryWithData(path string, data []byte) ([]byte, int64, error) { 28 | m.ctrl.T.Helper() 29 | ret := m.ctrl.Call(m, "QueryWithData", path, data) 30 | ret0, _ := ret[0].([]byte) 31 | ret1, _ := ret[1].(int64) 32 | ret2, _ := ret[2].(error) 33 | return ret0, ret1, ret2 34 | } 35 | 36 | func (mr *MockNodeQuerierMockRecorder) QueryWithData(path, data interface{}) *gomock.Call { 37 | mr.mock.ctrl.T.Helper() 38 | return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "QueryWithData", reflect.TypeOf((*MockNodeQuerier)(nil).QueryWithData), path, data) 39 | } 40 | -------------------------------------------------------------------------------- /baseapp/queryrouter.go: -------------------------------------------------------------------------------- 1 | package baseapp 2 | 3 | import ( 4 | "fmt" 5 | 6 | sdk "github.com/cosmos/cosmos-sdk/types" 7 | ) 8 | 9 | type queryRouter struct { 10 | routes map[string]sdk.Querier 11 | } 12 | 13 | var _ sdk.QueryRouter = NewQueryRouter() 14 | 15 | // NewQueryRouter returns a reference to a new queryRouter. 16 | // 17 | // TODO: Either make the function private or make return type (queryRouter) public. 18 | func NewQueryRouter() *queryRouter { // nolint: golint 19 | return &queryRouter{ 20 | routes: map[string]sdk.Querier{}, 21 | } 22 | } 23 | 24 | // AddRoute adds a query path to the router with a given Querier. It will panic 25 | // if a duplicate route is given. The route must be alphanumeric. 26 | func (qrt *queryRouter) AddRoute(path string, q sdk.Querier) sdk.QueryRouter { 27 | if !isAlphaNumeric(path) { 28 | panic("route expressions can only contain alphanumeric characters") 29 | } 30 | if qrt.routes[path] != nil { 31 | panic(fmt.Sprintf("route %s has already been initialized", path)) 32 | } 33 | 34 | qrt.routes[path] = q 35 | return qrt 36 | } 37 | 38 | // Route returns the Querier for a given query route path. 39 | func (qrt *queryRouter) Route(path string) sdk.Querier { 40 | return qrt.routes[path] 41 | } 42 | -------------------------------------------------------------------------------- /x/distribution/types/delegator.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | ) 6 | 7 | // starting info for a delegator reward period 8 | // tracks the previous validator period, the delegation's amount 9 | // of staking token, and the creation height (to check later on 10 | // if any slashes have occurred) 11 | // NOTE that even though validators are slashed to whole staking tokens, the 12 | // delegators within the validator may be left with less than a full token, 13 | // thus sdk.Dec is used 14 | type DelegatorStartingInfo struct { 15 | PreviousPeriod uint64 `json:"previous_period" yaml:"previous_period"` // period at which the delegation should withdraw starting from 16 | Stake sdk.Dec `json:"stake" yaml:"stake"` // amount of staking token delegated 17 | Height uint64 `json:"creation_height" yaml:"creation_height"` // height at which delegation was created 18 | } 19 | 20 | // create a new DelegatorStartingInfo 21 | func NewDelegatorStartingInfo(previousPeriod uint64, stake sdk.Dec, height uint64) DelegatorStartingInfo { 22 | return DelegatorStartingInfo{ 23 | PreviousPeriod: previousPeriod, 24 | Stake: stake, 25 | Height: height, 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /store/types/pruning.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // PruningStrategy specifies how old states will be deleted over time where 4 | // keepRecent can be used with keepEvery to create a pruning "strategy". 5 | type PruningOptions struct { 6 | keepRecent int64 7 | keepEvery int64 8 | } 9 | 10 | func NewPruningOptions(keepRecent, keepEvery int64) PruningOptions { 11 | return PruningOptions{ 12 | keepRecent: keepRecent, 13 | keepEvery: keepEvery, 14 | } 15 | } 16 | 17 | // How much recent state will be kept. Older state will be deleted. 18 | func (po PruningOptions) KeepRecent() int64 { 19 | return po.keepRecent 20 | } 21 | 22 | // Keeps every N stated, deleting others. 23 | func (po PruningOptions) KeepEvery() int64 { 24 | return po.keepEvery 25 | } 26 | 27 | // default pruning strategies 28 | var ( 29 | // PruneEverything means all saved states will be deleted, storing only the current state 30 | PruneEverything = NewPruningOptions(0, 0) 31 | // PruneNothing means all historic states will be saved, nothing will be deleted 32 | PruneNothing = NewPruningOptions(0, 1) 33 | // PruneSyncable means only those states not needed for state syncing will be deleted (keeps last 100 + every 10000th) 34 | PruneSyncable = NewPruningOptions(100, 10000) 35 | ) 36 | --------------------------------------------------------------------------------