feat(bank)!: Move the bank module SendEnabled info into state (from Params). (#11977)

* go mod tidy everything.

* Add some third_party proto files that are imported but not included.

* [11859]: Add a new key for the SendEnabled flags and keeper methods for getting, setting, and deleting them.

* [11859]: Remove the send_enabled field from the bank Params proto.

* Revert "Add some third_party proto files that are imported but not included."

This reverts commit 8b7acf89f27825ba25bfef3379fd422a307a5e1b.

* [11859]: Regenerate the bank params stuff from the changed proto.

* [11859]: Add a send_enabled field to the bank genesis proto.

* Revert "[11859]: Remove the send_enabled field from the bank Params proto."

This reverts commit 0bd904c1f6ac0ea2d6e5b7dd43911d596cbf3ac9.

* Revert "[11859]: Regenerate the bank params stuff from the changed proto."

This reverts commit 33d4652696d2c3aefc6937dbf281525c1f86f79e.

* [11859]: Deprecate the bank Params send_enabled field.

* [11859]: Regenerate the bank go code from the updated protos.

* [11859]: Reduce the number of times the store is recreated during IsSendEnabledCoins. Store creation has some overhead.

* [11859]: Add the SendEnabled stuff to the genesis methods. Make a couple TODO notes. Create a way to iterate over the SendEnabled entries and get all of them.

* [11859]: Update the bank sim genesis stuff to create random SendEnabled entries similar to when they were params.

* Remove some of the bank params methods that are no longer meaningful.

* Add a comment about why we're calling a mutation method in a Validate function.

* [11859]: Add some more TODO notes and make the SendEnabled.String() function significantlly simpler.

* [11859]: Get rid of the SendEnabledParams type.

* Fix up a few comments.

* [11859]: Update the bank keeper test due to recent changes.

* [11859]: Tweak the bank Params and SendEnabled String funcs. Params no longer returns {} when there aren't any SendEnabled entries and the default is false. SendEnabled is back to outputting a yaml format.

* [11859]: Fix the params tests and add some new ones to it and key_test.

* [11859]: Create a 1-store method for updating several SendEnabled entries at once.

* [11859]: Create a migration for both the module and genesis state.

* [11859]: Create a new MsgSetSendEnabled for governanance proposals to set SendEnabled.

* [11859]: Add SetAllSendEnabled to the SendKeeper interface.

* [11859]: Add an authority to the bank keeper and create the handler for MsgSetSendEnabled.

* [11859]: Add an rpc endpoint for querying SendEnabled.

* [11859]: Implement the SendEnabled query.

* [11859]: Add a function for decoding a --page-key base64 value so that pagination can work as expected.

* [11859]: Implement a CLI command for querying SendEnabled.

* [11859]: Move the v047 store migration stuff into Migrate3to4 directly to prevent a circular dependency between 047 and the keeper. Not using the keeper for that would be a significant pain in the butt.

* [11869]: Implement the Msg interface for MsgSetSendEnabled.

* [11859]: Fix some unit tests that I broke along the way.

* [11859]: Reorg the funcs added to the SendKeeper interface.

* [11859]: Fix the return values of a couple of the MsgSetSendEnabled LegacyMsg funcs.

* [11859]: Tweak MigrateSendEnabled to add stuff to the existing slice (if there's anything to add). And then use that in the MigrateGenState function.

* [11859]: Don't set the Pagination field when looking up specific entries.

* [11859]: Put validateSendEnabledParams back to the way it was to allow reading the old Params without error.

* [11859]: Write up a bunch of unit tests.

* [11859]: Update the MsgSetSendEnabled.ValidateBasic() function with some extra failure points. Write up some tests.

* Update a test I fixed then broke.

* [11859]: Have the run-tests make target exit with a non-zero status if any of the tests fail.

* [11859]: Add changelog entries.

* [11859]: Add a missing func comment.

* [11859]: Only do a couple assertions if the elements exist to do so.

* [11859]: Add some more missing function comments.

* [11859]: Update the bank spec documentation.

* [11859]: Change name of WithPageKeyDecoded to FlagSetWithPageKeyDecoded, have it return an error and make MustFlagSetWithPageKeyDecoded for the one-liner.

* [11859]: Update the documentation on the SendEnabled query.

* [11859]: Add final newline to query.proto.

* [11859]: Remove the SetSendEnabled msg and endpoint.

* [11859]: Use nil instead of an empty slice of SendEnabled for defaults and where called for.

* [11859]: Update SetParams to migrate entries too.

* [11859]: Remove the spec doc info about the MsgSetSendEnabled that's part of another PR.

* [11859]: Update the changelog.

* Revert "[11859]: Update the changelog."

This reverts commit 85052b8579ec6bfac3411970a1597363329d6d66.

* [11859]: Rename the QuerySendEnabled message to QuerySendEnabledRequest to match the other messages in that proto.

* [11859]: Remove the authority field that is only needed for governance stuff (in the other PR).

* [11859]: Add a version to the deprecation message.

* [11859]: Update the comment on the now-deprecated SendEnabled params proto field to reference 0.46 instead of 0.47.

* Add some spacing to GetCmdQuerySendEnabled -> RunE.

* [11859]: Create banktypes.GenesisState.GetAllSendEnabled() to house the combination logic of the SendEnabled field and Params.SendEnabled. Have MigrateSendEnabled() use that. Remove some calls to MigrateSendEnabled and use GetAllSendEnabled in those cases.

* [11859]: Update Bank's ConsensusVersion to 4.

* [11859]: Add 'Since' comments to the new proto stuff.

* [11859]: Fix a unit test that broke because it assumed the bank module's version was 3.

* [11859]: Remove an empty line.

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

* [11859]: Remove movement of SendEnabled from the `ExportGenesis` function too.

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

* [11859]: Add a function for getting an entry so that users can differentiate between a missing entry and one that's using the default value.

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
This commit is contained in:
Daniel Wedul 2022-06-10 13:40:57 -06:00 committed by GitHub
parent 05966feea2
commit 7feae9c4dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
48 changed files with 4474 additions and 613 deletions

View File

@ -195,6 +195,11 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [\#11334](https://github.com/cosmos/cosmos-sdk/pull/11334) Move `x/gov/types/v1beta2` to `x/gov/types/v1`.
* (x/auth/middleware) [#11413](https://github.com/cosmos/cosmos-sdk/pull/11413) Refactor tx middleware to be extensible on tx fee logic. Merged `MempoolFeeMiddleware` and `TxPriorityMiddleware` functionalities into `DeductFeeMiddleware`, make the logic extensible using the `TxFeeChecker` option, the current fee logic is preserved by the default `checkTxFeeWithValidatorMinGasPrices` implementation. Change `RejectExtensionOptionsMiddleware` to `NewExtensionOptionsMiddleware` which is extensible with the `ExtensionOptionChecker` option. Unpack the tx extension options `Any`s to interface `TxExtensionOptionI`.
* (migrations) [#11556](https://github.com/cosmos/cosmos-sdk/pull/11556#issuecomment-1091385011) Remove migration code from 0.42 and below. To use previous migrations, checkout previous versions of the cosmos-sdk.
* (x/bank) [\#11859](https://github.com/cosmos/cosmos-sdk/pull/11859) Move the SendEnabled information out of the Params and into the state store directly.
The information can now be accessed using the BankKeeper.
Setting can be done using MsgSetSendEnabled as a governance proposal.
A SendEnabled query has been added to both GRPC and CLI.
### Client Breaking Changes
@ -337,11 +342,16 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/authz,x/feegrant) [\#11214](https://github.com/cosmos/cosmos-sdk/pull/11214) Fix Amino JSON encoding of authz and feegrant Msgs to be consistent with other modules.
* (authz)[\#11060](https://github.com/cosmos/cosmos-sdk/pull/11060) Support grant with no expire time.
* (x/gov) [\#10868](https://github.com/cosmos/cosmos-sdk/pull/10868) Bump gov to v1.
* (x/bank) [\#11859](https://github.com/cosmos/cosmos-sdk/pull/11859) Move the SendEnabled information out of the Params and into the state store directly.
### Deprecated
* (x/upgrade) [\#9906](https://github.com/cosmos/cosmos-sdk/pull/9906) Deprecate `UpgradeConsensusState` gRPC query since this functionality is only used for IBC, which now has its own [IBC replacement](https://github.com/cosmos/ibc-go/blob/2c880a22e9f9cc75f62b527ca94aa75ce1106001/proto/ibc/core/client/v1/query.proto#L54)
* (types) [\#10948](https://github.com/cosmos/cosmos-sdk/issues/10948) Deprecate the types.DBBackend variable and types.NewLevelDB function. They are replaced by a new entry in `app.toml`: `app-db-backend` and `tendermint/tm-db`s `NewDB` function. If `app-db-backend` is defined, then it is used. Otherwise, if `types.DBBackend` is defined, it is used (until removed: [\#11241](https://github.com/cosmos/cosmos-sdk/issues/11241)). Otherwise, Tendermint config's `db-backend` is used.
* (x/bank) [\#11859](https://github.com/cosmos/cosmos-sdk/pull/11859) The Params.SendEnabled field is deprecated and unusable.
The information can now be accessed using the BankKeeper.
Setting can be done using MsgSetSendEnabled as a governance proposal.
A SendEnabled query has been added to both GRPC and CLI.
## [v0.45.3](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.45.3) - 2022-04-12

View File

@ -244,18 +244,26 @@ CURRENT_DIR = $(shell pwd)
run-tests:
ifneq (,$(shell which tparse 2>/dev/null))
@echo "Starting unit tests"; \
finalec=0; \
for module in $(SUB_MODULES); do \
cd ${CURRENT_DIR}/$$module; \
echo "Running unit tests for module $$module"; \
go test -mod=readonly -json $(ARGS) $(TEST_PACKAGES) ./... | tparse; \
done
ec=$$?; \
if [ "$$ec" -ne '0' ]; then finalec=$$ec; fi; \
done; \
exit $$finalec
else
@echo "Starting unit tests"; \
finalec=0; \
for module in $(SUB_MODULES); do \
cd ${CURRENT_DIR}/$$module; \
echo "Running unit tests for module $$module"; \
go test -mod=readonly $(ARGS) $(TEST_PACKAGES) ./... ; \
done
ec=$$?; \
if [ "$$ec" -ne '0' ]; then finalec=$$ec; fi; \
done; \
exit $$finalec
endif
.PHONY: run-tests test test-all $(TEST_TARGETS)

View File

@ -4201,6 +4201,13 @@ type Params struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Deprecated: Use of SendEnabled in params is deprecated.
// For genesis, use the newly added send_enabled field in the genesis object.
// Storage, lookup, and manipulation of this information is now in the keeper.
//
// As of cosmos-sdk 0.47, this only exists for backwards compatibility of genesis files.
//
// Deprecated: Do not use.
SendEnabled []*SendEnabled `protobuf:"bytes,1,rep,name=send_enabled,json=sendEnabled,proto3" json:"send_enabled,omitempty"`
DefaultSendEnabled bool `protobuf:"varint,2,opt,name=default_send_enabled,json=defaultSendEnabled,proto3" json:"default_send_enabled,omitempty"`
}
@ -4225,6 +4232,7 @@ func (*Params) Descriptor() ([]byte, []int) {
return file_cosmos_bank_v1beta1_bank_proto_rawDescGZIP(), []int{0}
}
// Deprecated: Do not use.
func (x *Params) GetSendEnabled() []*SendEnabled {
if x != nil {
return x.SendEnabled
@ -4596,89 +4604,89 @@ var file_cosmos_bank_v1beta1_bank_proto_rawDesc = []byte{
0x61, 0x73, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x63, 0x6f, 0x69, 0x6e,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x6d,
0x73, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
0x85, 0x01, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x43, 0x0a, 0x0c, 0x73, 0x65,
0x89, 0x01, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x47, 0x0a, 0x0c, 0x73, 0x65,
0x6e, 0x64, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b,
0x32, 0x20, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x6e, 0x6b, 0x2e, 0x76,
0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c,
0x65, 0x64, 0x52, 0x0b, 0x73, 0x65, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12,
0x30, 0x0a, 0x14, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x73, 0x65, 0x6e, 0x64, 0x5f,
0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x12, 0x64,
0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x53, 0x65, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65,
0x64, 0x3a, 0x04, 0x98, 0xa0, 0x1f, 0x00, 0x22, 0x47, 0x0a, 0x0b, 0x53, 0x65, 0x6e, 0x64, 0x45,
0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x12, 0x18, 0x0a, 0x07,
0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x65,
0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x3a, 0x08, 0x98, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x01,
0x22, 0xb4, 0x01, 0x0a, 0x05, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x12, 0x32, 0x0a, 0x07, 0x61, 0x64,
0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d,
0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53,
0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x61,
0x0a, 0x05, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e,
0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65,
0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x30, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf,
0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73,
0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74,
0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x52, 0x05, 0x63, 0x6f, 0x69, 0x6e,
0x73, 0x3a, 0x14, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x82, 0xe7, 0xb0, 0x2a, 0x07,
0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0xa9, 0x01, 0x0a, 0x06, 0x4f, 0x75, 0x74, 0x70,
0x75, 0x74, 0x12, 0x32, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e,
0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x61,
0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x61, 0x0a, 0x05, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0x18,
0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62,
0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e,
0x42, 0x30, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62,
0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d,
0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69,
0x6e, 0x73, 0x52, 0x05, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0x3a, 0x08, 0x88, 0xa0, 0x1f, 0x00, 0xe8,
0xa0, 0x1f, 0x00, 0x22, 0xb7, 0x01, 0x0a, 0x06, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x79, 0x12, 0x61,
0x0a, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e,
0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65,
0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x30, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf,
0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73,
0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74,
0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x52, 0x05, 0x74, 0x6f, 0x74, 0x61,
0x6c, 0x3a, 0x4a, 0x18, 0x01, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x01, 0xca, 0xb4, 0x2d,
0x3c, 0x2a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73,
0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x78,
0x2f, 0x62, 0x61, 0x6e, 0x6b, 0x2f, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73,
0x2f, 0x76, 0x30, 0x34, 0x30, 0x2e, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x79, 0x49, 0x22, 0x57, 0x0a,
0x09, 0x44, 0x65, 0x6e, 0x6f, 0x6d, 0x55, 0x6e, 0x69, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x64, 0x65,
0x65, 0x64, 0x42, 0x02, 0x18, 0x01, 0x52, 0x0b, 0x73, 0x65, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62,
0x6c, 0x65, 0x64, 0x12, 0x30, 0x0a, 0x14, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x73,
0x65, 0x6e, 0x64, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28,
0x08, 0x52, 0x12, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x53, 0x65, 0x6e, 0x64, 0x45, 0x6e,
0x61, 0x62, 0x6c, 0x65, 0x64, 0x3a, 0x04, 0x98, 0xa0, 0x1f, 0x00, 0x22, 0x47, 0x0a, 0x0b, 0x53,
0x65, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x64, 0x65,
0x6e, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x64, 0x65, 0x6e, 0x6f, 0x6d,
0x12, 0x1a, 0x0a, 0x08, 0x65, 0x78, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01,
0x28, 0x0d, 0x52, 0x08, 0x65, 0x78, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x12, 0x18, 0x0a, 0x07,
0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x61,
0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x22, 0x8a, 0x02, 0x0a, 0x08, 0x4d, 0x65, 0x74, 0x61, 0x64,
0x61, 0x74, 0x61, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69,
0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69,
0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3f, 0x0a, 0x0b, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x5f, 0x75,
0x6e, 0x69, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x63, 0x6f, 0x73,
0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x6e, 0x6b, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31,
0x2e, 0x44, 0x65, 0x6e, 0x6f, 0x6d, 0x55, 0x6e, 0x69, 0x74, 0x52, 0x0a, 0x64, 0x65, 0x6e, 0x6f,
0x6d, 0x55, 0x6e, 0x69, 0x74, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x61, 0x73, 0x65, 0x18, 0x03,
0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x69,
0x73, 0x70, 0x6c, 0x61, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, 0x69, 0x73,
0x70, 0x6c, 0x61, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01,
0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x79, 0x6d, 0x62,
0x6f, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c,
0x12, 0x19, 0x0a, 0x03, 0x75, 0x72, 0x69, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xe2,
0xde, 0x1f, 0x03, 0x55, 0x52, 0x49, 0x52, 0x03, 0x75, 0x72, 0x69, 0x12, 0x26, 0x0a, 0x08, 0x75,
0x72, 0x69, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0b, 0xe2,
0xde, 0x1f, 0x07, 0x55, 0x52, 0x49, 0x48, 0x61, 0x73, 0x68, 0x52, 0x07, 0x75, 0x72, 0x69, 0x48,
0x61, 0x73, 0x68, 0x42, 0xc4, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d,
0x6f, 0x73, 0x2e, 0x62, 0x61, 0x6e, 0x6b, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42,
0x09, 0x42, 0x61, 0x6e, 0x6b, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f,
0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63,
0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x6e, 0x6b, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74,
0x61, 0x31, 0x3b, 0x62, 0x61, 0x6e, 0x6b, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02,
0x03, 0x43, 0x42, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x42, 0x61,
0x6e, 0x6b, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x13, 0x43, 0x6f, 0x73,
0x6d, 0x6f, 0x73, 0x5c, 0x42, 0x61, 0x6e, 0x6b, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31,
0xe2, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x42, 0x61, 0x6e, 0x6b, 0x5c, 0x56,
0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61,
0x74, 0x61, 0xea, 0x02, 0x15, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x42, 0x61, 0x6e,
0x6b, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28,
0x08, 0x52, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x3a, 0x08, 0x98, 0xa0, 0x1f, 0x00,
0xe8, 0xa0, 0x1f, 0x01, 0x22, 0xb4, 0x01, 0x0a, 0x05, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x12, 0x32,
0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42,
0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72,
0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65,
0x73, 0x73, 0x12, 0x61, 0x0a, 0x05, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28,
0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e,
0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x30, 0xc8, 0xde,
0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d,
0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73,
0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x52, 0x05,
0x63, 0x6f, 0x69, 0x6e, 0x73, 0x3a, 0x14, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x82,
0xe7, 0xb0, 0x2a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0xa9, 0x01, 0x0a, 0x06,
0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x12, 0x32, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73,
0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73,
0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e,
0x67, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x61, 0x0a, 0x05, 0x63, 0x6f,
0x69, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d,
0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e,
0x43, 0x6f, 0x69, 0x6e, 0x42, 0x30, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69,
0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f,
0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73,
0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x52, 0x05, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0x3a, 0x08, 0x88,
0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x22, 0xb7, 0x01, 0x0a, 0x06, 0x53, 0x75, 0x70, 0x70,
0x6c, 0x79, 0x12, 0x61, 0x0a, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x03, 0x28,
0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e,
0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x30, 0xc8, 0xde,
0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d,
0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73,
0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x52, 0x05,
0x74, 0x6f, 0x74, 0x61, 0x6c, 0x3a, 0x4a, 0x18, 0x01, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f,
0x01, 0xca, 0xb4, 0x2d, 0x3c, 0x2a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d,
0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73,
0x64, 0x6b, 0x2f, 0x78, 0x2f, 0x62, 0x61, 0x6e, 0x6b, 0x2f, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x76, 0x30, 0x34, 0x30, 0x2e, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x79,
0x49, 0x22, 0x57, 0x0a, 0x09, 0x44, 0x65, 0x6e, 0x6f, 0x6d, 0x55, 0x6e, 0x69, 0x74, 0x12, 0x14,
0x0a, 0x05, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x64,
0x65, 0x6e, 0x6f, 0x6d, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x78, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74,
0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x65, 0x78, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74,
0x12, 0x18, 0x0a, 0x07, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28,
0x09, 0x52, 0x07, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x22, 0x8a, 0x02, 0x0a, 0x08, 0x4d,
0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72,
0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65,
0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3f, 0x0a, 0x0b, 0x64, 0x65, 0x6e,
0x6f, 0x6d, 0x5f, 0x75, 0x6e, 0x69, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e,
0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x6e, 0x6b, 0x2e, 0x76, 0x31, 0x62,
0x65, 0x74, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6e, 0x6f, 0x6d, 0x55, 0x6e, 0x69, 0x74, 0x52, 0x0a,
0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x55, 0x6e, 0x69, 0x74, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x61,
0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, 0x12, 0x18,
0x0a, 0x07, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52,
0x07, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65,
0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06,
0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x79,
0x6d, 0x62, 0x6f, 0x6c, 0x12, 0x19, 0x0a, 0x03, 0x75, 0x72, 0x69, 0x18, 0x07, 0x20, 0x01, 0x28,
0x09, 0x42, 0x07, 0xe2, 0xde, 0x1f, 0x03, 0x55, 0x52, 0x49, 0x52, 0x03, 0x75, 0x72, 0x69, 0x12,
0x26, 0x0a, 0x08, 0x75, 0x72, 0x69, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x08, 0x20, 0x01, 0x28,
0x09, 0x42, 0x0b, 0xe2, 0xde, 0x1f, 0x07, 0x55, 0x52, 0x49, 0x48, 0x61, 0x73, 0x68, 0x52, 0x07,
0x75, 0x72, 0x69, 0x48, 0x61, 0x73, 0x68, 0x42, 0xc4, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e,
0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x6e, 0x6b, 0x2e, 0x76, 0x31, 0x62, 0x65,
0x74, 0x61, 0x31, 0x42, 0x09, 0x42, 0x61, 0x6e, 0x6b, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01,
0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61,
0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x6e, 0x6b, 0x2f, 0x76,
0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x62, 0x61, 0x6e, 0x6b, 0x76, 0x31, 0x62, 0x65, 0x74,
0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x42, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f,
0x73, 0x2e, 0x42, 0x61, 0x6e, 0x6b, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02,
0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x42, 0x61, 0x6e, 0x6b, 0x5c, 0x56, 0x31, 0x62,
0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x42, 0x61,
0x6e, 0x6b, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65,
0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x15, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a,
0x3a, 0x42, 0x61, 0x6e, 0x6b, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (

View File

@ -168,12 +168,64 @@ func (x *_GenesisState_4_list) IsValid() bool {
return x.list != nil
}
var _ protoreflect.List = (*_GenesisState_5_list)(nil)
type _GenesisState_5_list struct {
list *[]*SendEnabled
}
func (x *_GenesisState_5_list) Len() int {
if x.list == nil {
return 0
}
return len(*x.list)
}
func (x *_GenesisState_5_list) Get(i int) protoreflect.Value {
return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect())
}
func (x *_GenesisState_5_list) Set(i int, value protoreflect.Value) {
valueUnwrapped := value.Message()
concreteValue := valueUnwrapped.Interface().(*SendEnabled)
(*x.list)[i] = concreteValue
}
func (x *_GenesisState_5_list) Append(value protoreflect.Value) {
valueUnwrapped := value.Message()
concreteValue := valueUnwrapped.Interface().(*SendEnabled)
*x.list = append(*x.list, concreteValue)
}
func (x *_GenesisState_5_list) AppendMutable() protoreflect.Value {
v := new(SendEnabled)
*x.list = append(*x.list, v)
return protoreflect.ValueOfMessage(v.ProtoReflect())
}
func (x *_GenesisState_5_list) Truncate(n int) {
for i := n; i < len(*x.list); i++ {
(*x.list)[i] = nil
}
*x.list = (*x.list)[:n]
}
func (x *_GenesisState_5_list) NewElement() protoreflect.Value {
v := new(SendEnabled)
return protoreflect.ValueOfMessage(v.ProtoReflect())
}
func (x *_GenesisState_5_list) IsValid() bool {
return x.list != nil
}
var (
md_GenesisState protoreflect.MessageDescriptor
fd_GenesisState_params protoreflect.FieldDescriptor
fd_GenesisState_balances protoreflect.FieldDescriptor
fd_GenesisState_supply protoreflect.FieldDescriptor
fd_GenesisState_denom_metadata protoreflect.FieldDescriptor
fd_GenesisState_send_enabled protoreflect.FieldDescriptor
)
func init() {
@ -183,6 +235,7 @@ func init() {
fd_GenesisState_balances = md_GenesisState.Fields().ByName("balances")
fd_GenesisState_supply = md_GenesisState.Fields().ByName("supply")
fd_GenesisState_denom_metadata = md_GenesisState.Fields().ByName("denom_metadata")
fd_GenesisState_send_enabled = md_GenesisState.Fields().ByName("send_enabled")
}
var _ protoreflect.Message = (*fastReflection_GenesisState)(nil)
@ -274,6 +327,12 @@ func (x *fastReflection_GenesisState) Range(f func(protoreflect.FieldDescriptor,
return
}
}
if len(x.SendEnabled) != 0 {
value := protoreflect.ValueOfList(&_GenesisState_5_list{list: &x.SendEnabled})
if !f(fd_GenesisState_send_enabled, value) {
return
}
}
}
// Has reports whether a field is populated.
@ -297,6 +356,8 @@ func (x *fastReflection_GenesisState) Has(fd protoreflect.FieldDescriptor) bool
return len(x.Supply) != 0
case "cosmos.bank.v1beta1.GenesisState.denom_metadata":
return len(x.DenomMetadata) != 0
case "cosmos.bank.v1beta1.GenesisState.send_enabled":
return len(x.SendEnabled) != 0
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.bank.v1beta1.GenesisState"))
@ -321,6 +382,8 @@ func (x *fastReflection_GenesisState) Clear(fd protoreflect.FieldDescriptor) {
x.Supply = nil
case "cosmos.bank.v1beta1.GenesisState.denom_metadata":
x.DenomMetadata = nil
case "cosmos.bank.v1beta1.GenesisState.send_enabled":
x.SendEnabled = nil
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.bank.v1beta1.GenesisState"))
@ -358,6 +421,12 @@ func (x *fastReflection_GenesisState) Get(descriptor protoreflect.FieldDescripto
}
listValue := &_GenesisState_4_list{list: &x.DenomMetadata}
return protoreflect.ValueOfList(listValue)
case "cosmos.bank.v1beta1.GenesisState.send_enabled":
if len(x.SendEnabled) == 0 {
return protoreflect.ValueOfList(&_GenesisState_5_list{})
}
listValue := &_GenesisState_5_list{list: &x.SendEnabled}
return protoreflect.ValueOfList(listValue)
default:
if descriptor.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.bank.v1beta1.GenesisState"))
@ -392,6 +461,10 @@ func (x *fastReflection_GenesisState) Set(fd protoreflect.FieldDescriptor, value
lv := value.List()
clv := lv.(*_GenesisState_4_list)
x.DenomMetadata = *clv.list
case "cosmos.bank.v1beta1.GenesisState.send_enabled":
lv := value.List()
clv := lv.(*_GenesisState_5_list)
x.SendEnabled = *clv.list
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.bank.v1beta1.GenesisState"))
@ -435,6 +508,12 @@ func (x *fastReflection_GenesisState) Mutable(fd protoreflect.FieldDescriptor) p
}
value := &_GenesisState_4_list{list: &x.DenomMetadata}
return protoreflect.ValueOfList(value)
case "cosmos.bank.v1beta1.GenesisState.send_enabled":
if x.SendEnabled == nil {
x.SendEnabled = []*SendEnabled{}
}
value := &_GenesisState_5_list{list: &x.SendEnabled}
return protoreflect.ValueOfList(value)
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.bank.v1beta1.GenesisState"))
@ -460,6 +539,9 @@ func (x *fastReflection_GenesisState) NewField(fd protoreflect.FieldDescriptor)
case "cosmos.bank.v1beta1.GenesisState.denom_metadata":
list := []*Metadata{}
return protoreflect.ValueOfList(&_GenesisState_4_list{list: &list})
case "cosmos.bank.v1beta1.GenesisState.send_enabled":
list := []*SendEnabled{}
return protoreflect.ValueOfList(&_GenesisState_5_list{list: &list})
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.bank.v1beta1.GenesisState"))
@ -551,6 +633,12 @@ func (x *fastReflection_GenesisState) ProtoMethods() *protoiface.Methods {
n += 1 + l + runtime.Sov(uint64(l))
}
}
if len(x.SendEnabled) > 0 {
for _, e := range x.SendEnabled {
l = options.Size(e)
n += 1 + l + runtime.Sov(uint64(l))
}
}
if x.unknownFields != nil {
n += len(x.unknownFields)
}
@ -580,6 +668,22 @@ func (x *fastReflection_GenesisState) ProtoMethods() *protoiface.Methods {
i -= len(x.unknownFields)
copy(dAtA[i:], x.unknownFields)
}
if len(x.SendEnabled) > 0 {
for iNdEx := len(x.SendEnabled) - 1; iNdEx >= 0; iNdEx-- {
encoded, err := options.Marshal(x.SendEnabled[iNdEx])
if err != nil {
return protoiface.MarshalOutput{
NoUnkeyedLiterals: input.NoUnkeyedLiterals,
Buf: input.Buf,
}, err
}
i -= len(encoded)
copy(dAtA[i:], encoded)
i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded)))
i--
dAtA[i] = 0x2a
}
}
if len(x.DenomMetadata) > 0 {
for iNdEx := len(x.DenomMetadata) - 1; iNdEx >= 0; iNdEx-- {
encoded, err := options.Marshal(x.DenomMetadata[iNdEx])
@ -829,6 +933,40 @@ func (x *fastReflection_GenesisState) ProtoMethods() *protoiface.Methods {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err
}
iNdEx = postIndex
case 5:
if wireType != 2 {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SendEnabled", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow
}
if iNdEx >= l {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
}
if postIndex > l {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
}
x.SendEnabled = append(x.SendEnabled, &SendEnabled{})
if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.SendEnabled[len(x.SendEnabled)-1]); err != nil {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := runtime.Skip(dAtA[iNdEx:])
@ -1441,15 +1579,19 @@ type GenesisState struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// params defines all the paramaters of the module.
// params defines all the parameters of the module.
Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"`
// balances is an array containing the balances of all the accounts.
Balances []*Balance `protobuf:"bytes,2,rep,name=balances,proto3" json:"balances,omitempty"`
// supply represents the total supply. If it is left empty, then supply will be calculated based on the provided
// balances. Otherwise, it will be used to validate that the sum of the balances equals this amount.
Supply []*v1beta1.Coin `protobuf:"bytes,3,rep,name=supply,proto3" json:"supply,omitempty"`
// denom_metadata defines the metadata of the differents coins.
// denom_metadata defines the metadata of the different coins.
DenomMetadata []*Metadata `protobuf:"bytes,4,rep,name=denom_metadata,json=denomMetadata,proto3" json:"denom_metadata,omitempty"`
// send_enabled defines the denoms where send is enabled or disabled.
//
// Since: cosmos-sdk 0.47
SendEnabled []*SendEnabled `protobuf:"bytes,5,rep,name=send_enabled,json=sendEnabled,proto3" json:"send_enabled,omitempty"`
}
func (x *GenesisState) Reset() {
@ -1500,6 +1642,13 @@ func (x *GenesisState) GetDenomMetadata() []*Metadata {
return nil
}
func (x *GenesisState) GetSendEnabled() []*SendEnabled {
if x != nil {
return x.SendEnabled
}
return nil
}
// Balance defines an account address and balance pair used in the bank module's
// genesis state.
type Balance struct {
@ -1560,7 +1709,7 @@ var file_cosmos_bank_v1beta1_genesis_proto_rawDesc = []byte{
0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x6e, 0x6b, 0x2f, 0x76, 0x31, 0x62, 0x65,
0x74, 0x61, 0x31, 0x2f, 0x62, 0x61, 0x6e, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19,
0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x73,
0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xba, 0x02, 0x0a, 0x0c, 0x47, 0x65,
0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x85, 0x03, 0x0a, 0x0c, 0x47, 0x65,
0x6e, 0x65, 0x73, 0x69, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x39, 0x0a, 0x06, 0x70, 0x61,
0x72, 0x61, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x63, 0x6f, 0x73,
0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x6e, 0x6b, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31,
@ -1580,31 +1729,35 @@ var file_cosmos_bank_v1beta1_genesis_proto_rawDesc = []byte{
0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x6e, 0x6b,
0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74,
0x61, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x0d, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x4d, 0x65,
0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x22, 0xaa, 0x01, 0x0a, 0x07, 0x42, 0x61, 0x6c, 0x61, 0x6e,
0x63, 0x65, 0x12, 0x32, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e,
0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x61,
0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x61, 0x0a, 0x05, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0x18,
0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62,
0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e,
0x42, 0x30, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62,
0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d,
0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69,
0x6e, 0x73, 0x52, 0x05, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0x3a, 0x08, 0x88, 0xa0, 0x1f, 0x00, 0xe8,
0xa0, 0x1f, 0x00, 0x42, 0xc7, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d,
0x6f, 0x73, 0x2e, 0x62, 0x61, 0x6e, 0x6b, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42,
0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a,
0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70,
0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x6e, 0x6b, 0x2f, 0x76, 0x31,
0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x62, 0x61, 0x6e, 0x6b, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61,
0x31, 0xa2, 0x02, 0x03, 0x43, 0x42, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73,
0x2e, 0x42, 0x61, 0x6e, 0x6b, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x13,
0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x42, 0x61, 0x6e, 0x6b, 0x5c, 0x56, 0x31, 0x62, 0x65,
0x74, 0x61, 0x31, 0xe2, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x42, 0x61, 0x6e,
0x6b, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74,
0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x15, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a,
0x42, 0x61, 0x6e, 0x6b, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x49, 0x0a, 0x0c, 0x73, 0x65, 0x6e, 0x64, 0x5f, 0x65,
0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x63,
0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x6e, 0x6b, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74,
0x61, 0x31, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x42, 0x04,
0xc8, 0xde, 0x1f, 0x00, 0x52, 0x0b, 0x73, 0x65, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65,
0x64, 0x22, 0xaa, 0x01, 0x0a, 0x07, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x32, 0x0a,
0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18,
0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65,
0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73,
0x73, 0x12, 0x61, 0x0a, 0x05, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b,
0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76,
0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x30, 0xc8, 0xde, 0x1f,
0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f,
0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64,
0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x52, 0x05, 0x63,
0x6f, 0x69, 0x6e, 0x73, 0x3a, 0x08, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x42, 0xc7,
0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61,
0x6e, 0x6b, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0c, 0x47, 0x65, 0x6e, 0x65,
0x73, 0x69, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d,
0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73,
0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x6e, 0x6b, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31,
0x3b, 0x62, 0x61, 0x6e, 0x6b, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43,
0x42, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x42, 0x61, 0x6e, 0x6b,
0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f,
0x73, 0x5c, 0x42, 0x61, 0x6e, 0x6b, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02,
0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x42, 0x61, 0x6e, 0x6b, 0x5c, 0x56, 0x31, 0x62,
0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61,
0xea, 0x02, 0x15, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x42, 0x61, 0x6e, 0x6b, 0x3a,
0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -1626,18 +1779,20 @@ var file_cosmos_bank_v1beta1_genesis_proto_goTypes = []interface{}{
(*Params)(nil), // 2: cosmos.bank.v1beta1.Params
(*v1beta1.Coin)(nil), // 3: cosmos.base.v1beta1.Coin
(*Metadata)(nil), // 4: cosmos.bank.v1beta1.Metadata
(*SendEnabled)(nil), // 5: cosmos.bank.v1beta1.SendEnabled
}
var file_cosmos_bank_v1beta1_genesis_proto_depIdxs = []int32{
2, // 0: cosmos.bank.v1beta1.GenesisState.params:type_name -> cosmos.bank.v1beta1.Params
1, // 1: cosmos.bank.v1beta1.GenesisState.balances:type_name -> cosmos.bank.v1beta1.Balance
3, // 2: cosmos.bank.v1beta1.GenesisState.supply:type_name -> cosmos.base.v1beta1.Coin
4, // 3: cosmos.bank.v1beta1.GenesisState.denom_metadata:type_name -> cosmos.bank.v1beta1.Metadata
3, // 4: cosmos.bank.v1beta1.Balance.coins:type_name -> cosmos.base.v1beta1.Coin
5, // [5:5] is the sub-list for method output_type
5, // [5:5] is the sub-list for method input_type
5, // [5:5] is the sub-list for extension type_name
5, // [5:5] is the sub-list for extension extendee
0, // [0:5] is the sub-list for field type_name
5, // 4: cosmos.bank.v1beta1.GenesisState.send_enabled:type_name -> cosmos.bank.v1beta1.SendEnabled
3, // 5: cosmos.bank.v1beta1.Balance.coins:type_name -> cosmos.base.v1beta1.Coin
6, // [6:6] is the sub-list for method output_type
6, // [6:6] is the sub-list for method input_type
6, // [6:6] is the sub-list for extension type_name
6, // [6:6] is the sub-list for extension extendee
0, // [0:6] is the sub-list for field type_name
}
func init() { file_cosmos_bank_v1beta1_genesis_proto_init() }

File diff suppressed because it is too large Load Diff

View File

@ -47,6 +47,14 @@ type QueryClient interface {
//
// Since: cosmos-sdk 0.46
DenomOwners(ctx context.Context, in *QueryDenomOwnersRequest, opts ...grpc.CallOption) (*QueryDenomOwnersResponse, error)
// SendEnabled queries for SendEnabled entries.
//
// This query only returns denominations that have specific SendEnabled settings.
// Any denomination that does not have a specific setting will use the default
// params.default_send_enabled, and will not be returned by this query.
//
// Since: cosmos-sdk 0.47
SendEnabled(ctx context.Context, in *QuerySendEnabledRequest, opts ...grpc.CallOption) (*QuerySendEnabledResponse, error)
}
type queryClient struct {
@ -138,6 +146,15 @@ func (c *queryClient) DenomOwners(ctx context.Context, in *QueryDenomOwnersReque
return out, nil
}
func (c *queryClient) SendEnabled(ctx context.Context, in *QuerySendEnabledRequest, opts ...grpc.CallOption) (*QuerySendEnabledResponse, error) {
out := new(QuerySendEnabledResponse)
err := c.cc.Invoke(ctx, "/cosmos.bank.v1beta1.Query/SendEnabled", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// QueryServer is the server API for Query service.
// All implementations must embed UnimplementedQueryServer
// for forward compatibility
@ -167,6 +184,14 @@ type QueryServer interface {
//
// Since: cosmos-sdk 0.46
DenomOwners(context.Context, *QueryDenomOwnersRequest) (*QueryDenomOwnersResponse, error)
// SendEnabled queries for SendEnabled entries.
//
// This query only returns denominations that have specific SendEnabled settings.
// Any denomination that does not have a specific setting will use the default
// params.default_send_enabled, and will not be returned by this query.
//
// Since: cosmos-sdk 0.47
SendEnabled(context.Context, *QuerySendEnabledRequest) (*QuerySendEnabledResponse, error)
mustEmbedUnimplementedQueryServer()
}
@ -201,6 +226,9 @@ func (UnimplementedQueryServer) DenomsMetadata(context.Context, *QueryDenomsMeta
func (UnimplementedQueryServer) DenomOwners(context.Context, *QueryDenomOwnersRequest) (*QueryDenomOwnersResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method DenomOwners not implemented")
}
func (UnimplementedQueryServer) SendEnabled(context.Context, *QuerySendEnabledRequest) (*QuerySendEnabledResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method SendEnabled not implemented")
}
func (UnimplementedQueryServer) mustEmbedUnimplementedQueryServer() {}
// UnsafeQueryServer may be embedded to opt out of forward compatibility for this service.
@ -376,6 +404,24 @@ func _Query_DenomOwners_Handler(srv interface{}, ctx context.Context, dec func(i
return interceptor(ctx, in, info, handler)
}
func _Query_SendEnabled_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(QuerySendEnabledRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QueryServer).SendEnabled(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cosmos.bank.v1beta1.Query/SendEnabled",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QueryServer).SendEnabled(ctx, req.(*QuerySendEnabledRequest))
}
return interceptor(ctx, in, info, handler)
}
// Query_ServiceDesc is the grpc.ServiceDesc for Query service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@ -419,6 +465,10 @@ var Query_ServiceDesc = grpc.ServiceDesc{
MethodName: "DenomOwners",
Handler: _Query_DenomOwners_Handler,
},
{
MethodName: "SendEnabled",
Handler: _Query_SendEnabled_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "cosmos/bank/v1beta1/query.proto",

View File

@ -1,6 +1,7 @@
package client
import (
"encoding/base64"
"github.com/spf13/pflag"
rpchttp "github.com/tendermint/tendermint/rpc/client/http"
@ -76,3 +77,37 @@ func ReadPageRequest(flagSet *pflag.FlagSet) (*query.PageRequest, error) {
func NewClientFromNode(nodeURI string) (*rpchttp.HTTP, error) {
return rpchttp.New(nodeURI)
}
// FlagSetWithPageKeyDecoded returns the provided flagSet with the page-key value base64 decoded (if it exists).
// This is for when the page-key is provided as a base64 string (e.g. from the CLI).
// ReadPageRequest expects it to be the raw bytes.
//
// Common usage:
// fs, err := client.FlagSetWithPageKeyDecoded(cmd.Flags())
// pageReq, err := client.ReadPageRequest(fs)
func FlagSetWithPageKeyDecoded(flagSet *pflag.FlagSet) (*pflag.FlagSet, error) {
encoded, err := flagSet.GetString(flags.FlagPageKey)
if err != nil {
return flagSet, err
}
if len(encoded) > 0 {
var raw []byte
raw, err = base64.StdEncoding.DecodeString(encoded)
if err != nil {
return flagSet, err
}
_ = flagSet.Set(flags.FlagPageKey, string(raw))
}
return flagSet, nil
}
// MustFlagSetWithPageKeyDecoded calls FlagSetWithPageKeyDecoded and panics on error.
//
// Common usage: pageReq, err := client.ReadPageRequest(client.MustFlagSetWithPageKeyDecoded(cmd.Flags()))
func MustFlagSetWithPageKeyDecoded(flagSet *pflag.FlagSet) *pflag.FlagSet {
rv, err := FlagSetWithPageKeyDecoded(flagSet)
if err != nil {
panic(err.Error())
}
return rv
}

View File

@ -3,6 +3,7 @@ module github.com/cosmos/cosmos-sdk/client/v2
go 1.18
require (
github.com/cosmos/cosmos-proto v1.0.0-alpha7
github.com/cosmos/cosmos-sdk/api v0.1.0
github.com/iancoleman/strcase v0.2.0
github.com/spf13/cobra v1.4.0
@ -13,7 +14,6 @@ require (
)
require (
github.com/cosmos/cosmos-proto v1.0.0-alpha7 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.6 // indirect
@ -22,5 +22,6 @@ require (
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect
golang.org/x/text v0.3.5 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb // indirect
)

View File

@ -10,8 +10,13 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/bank/types";
// Params defines the parameters for the bank module.
message Params {
option (gogoproto.goproto_stringer) = false;
repeated SendEnabled send_enabled = 1;
option (gogoproto.goproto_stringer) = false;
// Deprecated: Use of SendEnabled in params is deprecated.
// For genesis, use the newly added send_enabled field in the genesis object.
// Storage, lookup, and manipulation of this information is now in the keeper.
//
// As of cosmos-sdk 0.47, this only exists for backwards compatibility of genesis files.
repeated SendEnabled send_enabled = 1 [deprecated = true];
bool default_send_enabled = 2;
}

View File

@ -10,7 +10,7 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/bank/types";
// GenesisState defines the bank module's genesis state.
message GenesisState {
// params defines all the paramaters of the module.
// params defines all the parameters of the module.
Params params = 1 [(gogoproto.nullable) = false];
// balances is an array containing the balances of all the accounts.
@ -21,8 +21,13 @@ message GenesisState {
repeated cosmos.base.v1beta1.Coin supply = 3
[(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.nullable) = false];
// denom_metadata defines the metadata of the differents coins.
// denom_metadata defines the metadata of the different coins.
repeated Metadata denom_metadata = 4 [(gogoproto.nullable) = false];
// send_enabled defines the denoms where send is enabled or disabled.
//
// Since: cosmos-sdk 0.47
repeated SendEnabled send_enabled = 5 [(gogoproto.nullable) = false];
}
// Balance defines an account address and balance pair used in the bank module's

View File

@ -63,6 +63,17 @@ service Query {
rpc DenomOwners(QueryDenomOwnersRequest) returns (QueryDenomOwnersResponse) {
option (google.api.http).get = "/cosmos/bank/v1beta1/denom_owners/{denom}";
}
// SendEnabled queries for SendEnabled entries.
//
// This query only returns denominations that have specific SendEnabled settings.
// Any denomination that does not have a specific setting will use the default
// params.default_send_enabled, and will not be returned by this query.
//
// Since: cosmos-sdk 0.47
rpc SendEnabled(QuerySendEnabledRequest) returns (QuerySendEnabledResponse) {
option (google.api.http).get = "/cosmos/bank/v1beta1/send_enabled";
}
}
// QueryBalanceRequest is the request type for the Query/Balance RPC method.
@ -241,3 +252,22 @@ message QueryDenomOwnersResponse {
// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
// QuerySendEnabledRequest defines the RPC request for looking up SendEnabled entries.
//
// Since: cosmos-sdk 0.47
message QuerySendEnabledRequest {
// denoms is the specific denoms you want look up. Leave empty to get all entries.
repeated string denoms = 1;
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 99;
}
// QuerySendEnabledResponse defines the RPC response of a SendEnable query.
//
// Since: cosmos-sdk 0.47
message QuerySendEnabledResponse {
repeated SendEnabled send_enabled = 1;
// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 99;
}

View File

@ -46,3 +46,4 @@ message MsgMultiSend {
// MsgMultiSendResponse defines the Msg/MultiSend response type.
message MsgMultiSendResponse {}

View File

@ -105,6 +105,7 @@ func TestRunMigrations(t *testing.T) {
name string
moduleName string
fromVersion uint64
toVersion uint64
expRegErr bool // errors while registering migration
expRegErrMsg string
expRunErr bool // errors while running migration
@ -113,33 +114,33 @@ func TestRunMigrations(t *testing.T) {
}{
{
"cannot register migration for version 0",
"bank", 0,
"bank", 0, 1,
true, "module migration versions should start at 1: invalid version", false, "", 0,
},
{
"throws error on RunMigrations if no migration registered for bank",
"", 1,
"", 1, 2,
false, "", true, "no migrations found for module bank: not found", 0,
},
{
"can register 1->2 migration handler for x/bank, cannot run migration",
"bank", 1,
"bank", 1, 2,
false, "", true, "no migration found for module bank from version 2 to version 3: not found", 0,
},
{
"can register 2->3 migration handler for x/bank, can run migration",
"bank", 2,
false, "", false, "", 1,
"bank", 2, bank.AppModule{}.ConsensusVersion(),
false, "", false, "", int(bank.AppModule{}.ConsensusVersion() - 2), // minus 2 because 1-2 is run in the previous test case.
},
{
"cannot register migration handler for same module & fromVersion",
"bank", 1,
"bank", 1, 2,
true, "another migration for module bank and version 1 already exists: internal logic error", false, "", 0,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
t.Run(tc.name, func(tt *testing.T) {
var err error
// Since it's very hard to test actual in-place store migrations in
@ -149,20 +150,23 @@ func TestRunMigrations(t *testing.T) {
called := 0
if tc.moduleName != "" {
// Register migration for module from version `fromVersion` to `fromVersion+1`.
err = configurator.RegisterMigration(tc.moduleName, tc.fromVersion, func(sdk.Context) error {
called++
for i := tc.fromVersion; i < tc.toVersion; i++ {
// Register migration for module from version `fromVersion` to `fromVersion+1`.
tt.Logf("Registering migration for %q v%d", tc.moduleName, i)
err = configurator.RegisterMigration(tc.moduleName, i, func(sdk.Context) error {
called++
return nil
})
return nil
})
if tc.expRegErr {
require.EqualError(t, err, tc.expRegErrMsg)
if tc.expRegErr {
require.EqualError(tt, err, tc.expRegErrMsg)
return
return
}
require.NoError(tt, err, "registering migration")
}
}
require.NoError(t, err)
// Run migrations only for bank. That's why we put the initial
// version for bank as 1, and for all other modules, we put as
@ -190,11 +194,11 @@ func TestRunMigrations(t *testing.T) {
},
)
if tc.expRunErr {
require.EqualError(t, err, tc.expRunErrMsg)
require.EqualError(tt, err, tc.expRunErrMsg, "running migration")
} else {
require.NoError(t, err)
require.NoError(tt, err, "running migration")
// Make sure bank's migration is called.
require.Equal(t, tc.expCalled, called)
require.Equal(tt, tc.expCalled, called)
}
})
}

View File

@ -186,7 +186,7 @@ func genesisStateWithValSet(t *testing.T,
})
// update total supply
bankGenesis := banktypes.NewGenesisState(banktypes.DefaultGenesisState().Params, balances, totalSupply, []banktypes.Metadata{})
bankGenesis := banktypes.NewGenesisState(banktypes.DefaultGenesisState().Params, balances, totalSupply, []banktypes.Metadata{}, []banktypes.SendEnabled{})
genesisState[banktypes.ModuleName] = app.AppCodec().MustMarshalJSON(bankGenesis)
return genesisState

View File

@ -33,6 +33,7 @@ func GetQueryCmd() *cobra.Command {
GetBalancesCmd(),
GetCmdQueryTotalSupply(),
GetCmdDenomsMetadata(),
GetCmdQuerySendEnabled(),
)
return cmd
@ -213,3 +214,58 @@ To query for the total supply of a specific coin denomination use:
return cmd
}
func GetCmdQuerySendEnabled() *cobra.Command {
cmd := &cobra.Command{
Use: "send-enabled [denom1 ...]",
Short: "Query for send enabled entries",
Long: strings.TrimSpace(`Query for send enabled entries that have been specifically set.
To look up one or more specific denoms, supply them as arguments to this command.
To look up all denoms, do not provide any arguemnts.
`,
),
Example: strings.TrimSpace(
fmt.Sprintf(`Getting one specific entry:
$ %[1]s query %[2]s send-enabled foocoin
Getting two specific entries:
$ %[1]s query %[2]s send-enabled foocoin barcoin
Getting all entries:
$ %[1]s query %[2]s send-enabled
`,
version.AppName, types.ModuleName,
),
),
RunE: func(cmd *cobra.Command, args []string) error {
reqPag, err := client.ReadPageRequest(client.MustFlagSetWithPageKeyDecoded(cmd.Flags()))
if err != nil {
return err
}
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
req := &types.QuerySendEnabledRequest{
Denoms: args,
Pagination: reqPag,
}
res, err := queryClient.SendEnabled(cmd.Context(), req)
if err != nil {
return err
}
return clientCtx.PrintProto(res)
},
}
flags.AddQueryFlagsToCmd(cmd)
flags.AddPaginationFlagsToCmd(cmd, "send enabled entries")
return cmd
}

View File

@ -12,6 +12,10 @@ import (
func (k BaseKeeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) {
k.SetParams(ctx, genState.Params)
for _, se := range genState.GetAllSendEnabled() {
k.SetSendEnabled(ctx, se.Denom, se.Enabled)
}
totalSupply := sdk.Coins{}
genState.Balances = types.SanitizeGenesisBalances(genState.Balances)
@ -45,10 +49,12 @@ func (k BaseKeeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
panic(fmt.Errorf("unable to fetch total supply %v", err))
}
return types.NewGenesisState(
rv := types.NewGenesisState(
k.GetParams(ctx),
k.GetAccountsBalances(ctx),
totalSupply,
k.GetAllDenomMetaData(ctx),
k.GetAllSendEnabledEntries(ctx),
)
return rv
}

View File

@ -92,17 +92,17 @@ func (suite *IntegrationTestSuite) TestTotalSupply() {
}{
{
"calculation NOT matching genesis Supply field",
types.NewGenesisState(defaultGenesis.Params, balances, sdk.NewCoins(sdk.NewCoin("wrongcoin", sdk.NewInt(1))), defaultGenesis.DenomMetadata),
types.NewGenesisState(defaultGenesis.Params, balances, sdk.NewCoins(sdk.NewCoin("wrongcoin", sdk.NewInt(1))), defaultGenesis.DenomMetadata, defaultGenesis.SendEnabled),
nil, true, "genesis supply is incorrect, expected 1wrongcoin, got 21barcoin,11foocoin",
},
{
"calculation matches genesis Supply field",
types.NewGenesisState(defaultGenesis.Params, balances, totalSupply, defaultGenesis.DenomMetadata),
types.NewGenesisState(defaultGenesis.Params, balances, totalSupply, defaultGenesis.DenomMetadata, defaultGenesis.SendEnabled),
totalSupply, false, "",
},
{
"calculation is correct, empty genesis Supply field",
types.NewGenesisState(defaultGenesis.Params, balances, nil, defaultGenesis.DenomMetadata),
types.NewGenesisState(defaultGenesis.Params, balances, nil, defaultGenesis.DenomMetadata, defaultGenesis.SendEnabled),
totalSupply, false, "",
},
}

View File

@ -244,3 +244,36 @@ func (k BaseKeeper) DenomOwners(
return &types.QueryDenomOwnersResponse{DenomOwners: denomOwners, Pagination: pageRes}, nil
}
func (k BaseKeeper) SendEnabled(goCtx context.Context, req *types.QuerySendEnabledRequest) (*types.QuerySendEnabledResponse, error) {
if req == nil {
return nil, status.Errorf(codes.InvalidArgument, "empty request")
}
ctx := sdk.UnwrapSDKContext(goCtx)
resp := &types.QuerySendEnabledResponse{}
if len(req.Denoms) > 0 {
store := ctx.KVStore(k.storeKey)
for _, denom := range req.Denoms {
if se, ok := k.getSendEnabled(store, denom); ok {
resp.SendEnabled = append(resp.SendEnabled, types.NewSendEnabled(denom, se))
}
}
} else {
store := k.getSendEnabledPrefixStore(ctx)
var err error
resp.Pagination, err = query.FilteredPaginate(
store,
req.Pagination,
func(key []byte, value []byte, accumulate bool) (bool, error) {
if accumulate {
resp.SendEnabled = append(resp.SendEnabled, types.NewSendEnabled(string(key), types.IsTrueB(value)))
}
return true, nil
},
)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
}
return resp, nil
}

View File

@ -453,3 +453,133 @@ func (suite *IntegrationTestSuite) TestGRPCDenomOwners() {
suite.Require().True(true)
}
func (suite *IntegrationTestSuite) TestQuerySendEnabled() {
ctx, bankKeeper := suite.ctx, suite.app.BankKeeper
bankKeeper.SetSendEnabled(ctx, "falsestcoin", false)
bankKeeper.SetSendEnabled(ctx, "truestcoin", true)
tests := []struct {
name string
req *types.QuerySendEnabledRequest
exp *types.QuerySendEnabledResponse
}{
{
name: "nil denoms list",
req: &types.QuerySendEnabledRequest{Denoms: []string{}},
exp: &types.QuerySendEnabledResponse{
SendEnabled: []*types.SendEnabled{
{"falsestcoin", false},
{"truestcoin", true},
},
Pagination: &query.PageResponse{
NextKey: nil,
Total: 2,
},
},
},
{
name: "empty denoms list",
req: &types.QuerySendEnabledRequest{Denoms: []string{}},
exp: &types.QuerySendEnabledResponse{
SendEnabled: []*types.SendEnabled{
{"falsestcoin", false},
{"truestcoin", true},
},
Pagination: &query.PageResponse{
NextKey: nil,
Total: 2,
},
},
},
{
name: "limit 1",
req: &types.QuerySendEnabledRequest{
Pagination: &query.PageRequest{
Limit: 1,
CountTotal: true,
},
},
exp: &types.QuerySendEnabledResponse{
SendEnabled: []*types.SendEnabled{
{"falsestcoin", false},
},
Pagination: &query.PageResponse{
NextKey: []byte("truestcoin"),
Total: 2,
},
},
},
{
name: "just truestcoin",
req: &types.QuerySendEnabledRequest{Denoms: []string{"truestcoin"}},
exp: &types.QuerySendEnabledResponse{
SendEnabled: []*types.SendEnabled{
{"truestcoin", true},
},
Pagination: nil,
},
},
{
name: "just falsestcoin",
req: &types.QuerySendEnabledRequest{Denoms: []string{"falsestcoin"}},
exp: &types.QuerySendEnabledResponse{
SendEnabled: []*types.SendEnabled{
{"falsestcoin", false},
},
Pagination: nil,
},
},
{
name: "just an unknown coin",
req: &types.QuerySendEnabledRequest{Denoms: []string{"unknowniercoin"}},
exp: &types.QuerySendEnabledResponse{
SendEnabled: nil,
Pagination: nil,
},
},
{
name: "both truestcoin falsestcoin",
req: &types.QuerySendEnabledRequest{Denoms: []string{"truestcoin", "falsestcoin"}},
exp: &types.QuerySendEnabledResponse{
SendEnabled: []*types.SendEnabled{
{"truestcoin", true},
{"falsestcoin", false},
},
Pagination: nil,
},
},
{
name: "both truestcoin falsestcoin and an unknown",
req: &types.QuerySendEnabledRequest{Denoms: []string{"truestcoin", "falsestcoin", "unknownestcoin"}},
exp: &types.QuerySendEnabledResponse{
SendEnabled: []*types.SendEnabled{
{"truestcoin", true},
{"falsestcoin", false},
},
Pagination: nil,
},
},
}
for _, tc := range tests {
suite.Run(tc.name, func() {
resp, err := suite.queryClient.SendEnabled(gocontext.Background(), tc.req)
suite.Require().NoError(err)
if !suite.Assert().Equal(tc.exp, resp) {
if !suite.Assert().Len(resp.SendEnabled, len(tc.exp.SendEnabled)) {
for i := range tc.exp.SendEnabled {
suite.Assert().Equal(tc.exp.SendEnabled[i].Denom, resp.SendEnabled[i].Denom, fmt.Sprintf("SendEnabled[%d].Denom", i))
suite.Assert().Equal(tc.exp.SendEnabled[i].Enabled, resp.SendEnabled[i].Enabled, fmt.Sprintf("SendEnabled[%d].Enabled", i))
}
}
if !suite.Assert().Equal(tc.exp.Pagination, resp.Pagination, "Pagination") && tc.exp.Pagination != nil && resp.Pagination != nil {
suite.Assert().Equal(tc.exp.Pagination.NextKey, resp.Pagination.NextKey, "Pagination.NextKey")
suite.Assert().Equal(tc.exp.Pagination.Total, resp.Pagination.Total, "Pagination.Total")
}
}
suite.Require().Equal(tc.exp, resp)
})
}
}

View File

@ -2,10 +2,14 @@ package keeper_test
import (
"fmt"
"strings"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/libs/time"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
@ -506,8 +510,8 @@ func (suite *IntegrationTestSuite) TestSendEnabled() {
// Set default send_enabled to !enabled, add a foodenom that overrides default as enabled
params.DefaultSendEnabled = !enabled
params = params.SetSendEnabledParam(fooCoin.Denom, enabled)
app.BankKeeper.SetParams(ctx, params)
app.BankKeeper.SetSendEnabled(ctx, fooCoin.Denom, enabled)
// Expect our specific override to be enabled, others to be !enabled.
suite.Require().Equal(enabled, app.BankKeeper.IsSendEnabledCoin(ctx, fooCoin))
@ -1054,7 +1058,8 @@ func (suite *IntegrationTestSuite) TestBalanceTrackingEvents() {
)
suite.app.BankKeeper = keeper.NewBaseKeeper(suite.app.AppCodec(), suite.app.GetKey(types.StoreKey),
suite.app.AccountKeeper, suite.app.GetSubspace(types.ModuleName), nil)
suite.app.AccountKeeper, suite.app.GetSubspace(types.ModuleName), nil,
)
// set account with multiple permissions
suite.app.AccountKeeper.SetModuleAccount(suite.ctx, multiPermAcc)
@ -1215,7 +1220,8 @@ func (suite *IntegrationTestSuite) TestMintCoinRestrictions() {
for _, test := range tests {
suite.app.BankKeeper = keeper.NewBaseKeeper(suite.app.AppCodec(), suite.app.GetKey(types.StoreKey),
suite.app.AccountKeeper, suite.app.GetSubspace(types.ModuleName), nil).WithMintCoinsRestriction(keeper.MintingRestrictionFn(test.restrictionFn))
suite.app.AccountKeeper, suite.app.GetSubspace(types.ModuleName), nil,
).WithMintCoinsRestriction(keeper.MintingRestrictionFn(test.restrictionFn))
for _, testCase := range test.testCases {
if testCase.expectPass {
suite.Require().NoError(
@ -1238,6 +1244,404 @@ func (suite *IntegrationTestSuite) TestMintCoinRestrictions() {
}
}
func (suite *IntegrationTestSuite) TestIsSendEnabledDenom() {
ctx, bankKeeper := suite.ctx, suite.app.BankKeeper
defaultCoin := "defaultCoin"
enabledCoin := "enabledCoin"
disabledCoin := "disabledCoin"
bankKeeper.DeleteSendEnabled(ctx, defaultCoin)
bankKeeper.SetSendEnabled(ctx, enabledCoin, true)
bankKeeper.SetSendEnabled(ctx, disabledCoin, false)
tests := []struct {
denom string
exp bool
expDef bool
}{
{
denom: "defaultCoin",
expDef: true,
},
{
denom: enabledCoin,
exp: true,
},
{
denom: disabledCoin,
exp: false,
},
}
for _, def := range []bool{true, false} {
params := types.Params{DefaultSendEnabled: def}
bankKeeper.SetParams(ctx, params)
for _, tc := range tests {
suite.T().Run(fmt.Sprintf("%s default %t", tc.denom, def), func(t *testing.T) {
actual := suite.app.BankKeeper.IsSendEnabledDenom(suite.ctx, tc.denom)
exp := tc.exp
if tc.expDef {
exp = def
}
assert.Equal(t, exp, actual)
})
}
}
}
func (suite *IntegrationTestSuite) TestGetSendEnabledEntry() {
ctx, bankKeeper := suite.ctx, suite.app.BankKeeper
bankKeeper.SetAllSendEnabled(ctx, []*types.SendEnabled{
{Denom: "gettruecoin", Enabled: true},
{Denom: "getfalsecoin", Enabled: false},
})
tests := []struct {
denom string
expSE types.SendEnabled
expF bool
}{
{
denom: "missing",
expSE: types.SendEnabled{},
expF: false,
},
{
denom: "gettruecoin",
expSE: types.SendEnabled{Denom: "gettruecoin", Enabled: true},
expF: true,
},
{
denom: "getfalsecoin",
expSE: types.SendEnabled{Denom: "getfalsecoin", Enabled: false},
expF: true,
},
}
for _, tc := range tests {
suite.T().Run(tc.denom, func(t *testing.T) {
actualSE, actualF := bankKeeper.GetSendEnabledEntry(ctx, tc.denom)
assert.Equal(t, tc.expF, actualF, "found")
assert.Equal(t, tc.expSE, actualSE, "SendEnabled")
})
}
}
func (suite *IntegrationTestSuite) TestSetSendEnabled() {
ctx, bankKeeper := suite.ctx, suite.app.BankKeeper
tests := []struct {
name string
denom string
value bool
}{
{
name: "very short denom true",
denom: "f",
value: true,
},
{
name: "very short denom false",
denom: "f",
value: true,
},
{
name: "falseFirstCoin false",
denom: "falseFirstCoin",
value: false,
},
{
name: "falseFirstCoin true",
denom: "falseFirstCoin",
value: true,
},
{
name: "falseFirstCoin true again",
denom: "falseFirstCoin",
value: true,
},
{
name: "trueFirstCoin true",
denom: "falseFirstCoin",
value: false,
},
{
name: "trueFirstCoin false",
denom: "falseFirstCoin",
value: false,
},
{
name: "trueFirstCoin false again",
denom: "falseFirstCoin",
value: false,
},
}
for _, def := range []bool{true, false} {
params := types.Params{DefaultSendEnabled: def}
bankKeeper.SetParams(ctx, params)
for _, tc := range tests {
suite.T().Run(fmt.Sprintf("%s default %t", tc.name, def), func(t *testing.T) {
bankKeeper.SetSendEnabled(ctx, tc.denom, tc.value)
actual := bankKeeper.IsSendEnabledDenom(ctx, tc.denom)
assert.Equal(t, tc.value, actual)
})
}
}
}
func (suite *IntegrationTestSuite) TestSetAllSendEnabled() {
ctx, bankKeeper := suite.ctx, suite.app.BankKeeper
tests := []struct {
name string
sendEnableds []*types.SendEnabled
}{
{
name: "nil",
sendEnableds: nil,
},
{
name: "empty",
sendEnableds: []*types.SendEnabled{},
},
{
name: "one true",
sendEnableds: []*types.SendEnabled{
{"aonecoin", true},
},
},
{
name: "one false",
sendEnableds: []*types.SendEnabled{
{"bonecoin", false},
},
},
{
name: "two true",
sendEnableds: []*types.SendEnabled{
{"conecoin", true},
{"ctwocoin", true},
},
},
{
name: "two true false",
sendEnableds: []*types.SendEnabled{
{"donecoin", true},
{"dtwocoin", false},
},
},
{
name: "two false true",
sendEnableds: []*types.SendEnabled{
{"eonecoin", false},
{"etwocoin", true},
},
},
{
name: "two false",
sendEnableds: []*types.SendEnabled{
{"fonecoin", false},
{"ftwocoin", false},
},
},
}
for _, def := range []bool{true, false} {
params := types.Params{DefaultSendEnabled: def}
bankKeeper.SetParams(ctx, params)
for _, tc := range tests {
suite.T().Run(fmt.Sprintf("%s default %t", tc.name, def), func(t *testing.T) {
bankKeeper.SetAllSendEnabled(ctx, tc.sendEnableds)
for _, se := range tc.sendEnableds {
actual := bankKeeper.IsSendEnabledDenom(ctx, se.Denom)
assert.Equal(t, se.Enabled, actual, se.Denom)
}
})
}
}
}
func (suite *IntegrationTestSuite) TestDeleteSendEnabled() {
ctx, bankKeeper := suite.ctx, suite.app.BankKeeper
for _, def := range []bool{true, false} {
params := types.Params{DefaultSendEnabled: def}
bankKeeper.SetParams(ctx, params)
suite.T().Run(fmt.Sprintf("default %t", def), func(t *testing.T) {
denom := fmt.Sprintf("somerand%tcoin", !def)
bankKeeper.SetSendEnabled(ctx, denom, !def)
require.Equal(t, !def, bankKeeper.IsSendEnabledDenom(ctx, denom))
bankKeeper.DeleteSendEnabled(ctx, denom)
require.Equal(t, def, bankKeeper.IsSendEnabledDenom(ctx, denom))
})
}
}
func (suite *IntegrationTestSuite) TestIterateSendEnabledEntries() {
ctx, bankKeeper := suite.ctx, suite.app.BankKeeper
suite.T().Run("no entries to iterate", func(t *testing.T) {
count := 0
bankKeeper.IterateSendEnabledEntries(ctx, func(denom string, sendEnabled bool) (stop bool) {
count++
return false
})
assert.Equal(t, 0, count)
})
alpha := strings.Split("abcdefghijklmnopqrstuvwxyz", "")
denoms := make([]string, len(alpha)*2)
for i, l := range alpha {
denoms[i*2] = fmt.Sprintf("%sitercointrue", l)
denoms[i*2+1] = fmt.Sprintf("%sitercoinfalse", l)
bankKeeper.SetSendEnabled(ctx, denoms[i*2], true)
bankKeeper.SetSendEnabled(ctx, denoms[i*2+1], false)
}
for _, def := range []bool{true, false} {
params := types.Params{DefaultSendEnabled: def}
bankKeeper.SetParams(ctx, params)
var seen []string
suite.T().Run(fmt.Sprintf("all denoms have expected values default %t", def), func(t *testing.T) {
bankKeeper.IterateSendEnabledEntries(ctx, func(denom string, sendEnabled bool) (stop bool) {
seen = append(seen, denom)
exp := true
if strings.HasSuffix(denom, "false") {
exp = false
}
assert.Equal(t, exp, sendEnabled, denom)
return false
})
})
suite.T().Run(fmt.Sprintf("all denoms were seen default %t", def), func(t *testing.T) {
assert.ElementsMatch(t, denoms, seen)
})
}
for _, denom := range denoms {
bankKeeper.DeleteSendEnabled(ctx, denom)
}
suite.T().Run("no entries to iterate again after deleting all of them", func(t *testing.T) {
count := 0
bankKeeper.IterateSendEnabledEntries(ctx, func(denom string, sendEnabled bool) (stop bool) {
count++
return false
})
assert.Equal(t, 0, count)
})
}
func (suite *IntegrationTestSuite) TestGetAllSendEnabledEntries() {
ctx, bankKeeper := suite.ctx, suite.app.BankKeeper
suite.T().Run("no entries", func(t *testing.T) {
actual := bankKeeper.GetAllSendEnabledEntries(ctx)
assert.Len(t, actual, 0)
})
alpha := strings.Split("abcdefghijklmnopqrstuvwxyz", "")
denoms := make([]string, len(alpha)*2)
for i, l := range alpha {
denoms[i*2] = fmt.Sprintf("%sitercointrue", l)
denoms[i*2+1] = fmt.Sprintf("%sitercoinfalse", l)
bankKeeper.SetSendEnabled(ctx, denoms[i*2], true)
bankKeeper.SetSendEnabled(ctx, denoms[i*2+1], false)
}
for _, def := range []bool{true, false} {
params := types.Params{DefaultSendEnabled: def}
bankKeeper.SetParams(ctx, params)
var seen []string
suite.T().Run(fmt.Sprintf("all denoms have expected values default %t", def), func(t *testing.T) {
actual := bankKeeper.GetAllSendEnabledEntries(ctx)
for _, se := range actual {
seen = append(seen, se.Denom)
exp := true
if strings.HasSuffix(se.Denom, "false") {
exp = false
}
assert.Equal(t, exp, se.Enabled, se.Denom)
}
})
suite.T().Run(fmt.Sprintf("all denoms were seen default %t", def), func(t *testing.T) {
assert.ElementsMatch(t, denoms, seen)
})
}
for _, denom := range denoms {
bankKeeper.DeleteSendEnabled(ctx, denom)
}
suite.T().Run("no entries again after deleting all of them", func(t *testing.T) {
actual := bankKeeper.GetAllSendEnabledEntries(ctx)
assert.Len(t, actual, 0)
})
}
func (suite *IntegrationTestSuite) TestMigrator_Migrate3to4() {
ctx, bankKeeper := suite.ctx, suite.app.BankKeeper
for _, def := range []bool{true, false} {
params := types.Params{DefaultSendEnabled: def}
bankKeeper.SetParams(ctx, params)
suite.T().Run(fmt.Sprintf("default %t does not change", def), func(t *testing.T) {
migrator := keeper.NewMigrator(bankKeeper.(keeper.BaseKeeper))
require.NoError(t, migrator.Migrate3to4(ctx))
actual := bankKeeper.GetParams(ctx)
assert.Equal(t, params.DefaultSendEnabled, actual.DefaultSendEnabled)
})
}
for _, def := range []bool{true, false} {
params := types.Params{
SendEnabled: []*types.SendEnabled{
{fmt.Sprintf("truecoin%t", def), true},
{fmt.Sprintf("falsecoin%t", def), false},
},
}
bankKeeper.SetParams(ctx, params)
suite.T().Run(fmt.Sprintf("default %t send enabled info moved to store", def), func(t *testing.T) {
migrator := keeper.NewMigrator(bankKeeper.(keeper.BaseKeeper))
require.NoError(t, migrator.Migrate3to4(ctx))
newParams := bankKeeper.GetParams(ctx)
assert.Len(t, newParams.SendEnabled, 0)
for _, se := range params.SendEnabled {
actual := bankKeeper.IsSendEnabledDenom(ctx, se.Denom)
assert.Equal(t, se.Enabled, actual, se.Denom)
}
})
}
}
func (suite *IntegrationTestSuite) TestSetParams() {
ctx, bankKeeper := suite.ctx, suite.app.BankKeeper
params := types.NewParams(true)
params.SendEnabled = []*types.SendEnabled{
{"paramscointrue", true},
{"paramscoinfalse", false},
}
bankKeeper.SetParams(ctx, params)
suite.Run("stored params are as expected", func() {
actual := bankKeeper.GetParams(ctx)
suite.Assert().True(actual.DefaultSendEnabled, "DefaultSendEnabled")
suite.Assert().Len(actual.SendEnabled, 0, "SendEnabled")
})
suite.Run("send enabled params converted to store", func() {
actual := bankKeeper.GetAllSendEnabledEntries(ctx)
if suite.Assert().Len(actual, 2) {
suite.Equal("paramscoinfalse", actual[0].Denom, "actual[0].Denom")
suite.False(actual[0].Enabled, "actual[0].Enabled")
suite.Equal("paramscointrue", actual[1].Denom, "actual[1].Denom")
suite.True(actual[1].Enabled, "actual[1].Enabled")
}
})
}
func TestKeeperTestSuite(t *testing.T) {
suite.Run(t, new(IntegrationTestSuite))
}

View File

@ -4,6 +4,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
v043 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v043"
v046 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v046"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
)
// Migrator is a struct for handling in-place store migrations.
@ -25,3 +26,11 @@ func (m Migrator) Migrate1to2(ctx sdk.Context) error {
func (m Migrator) Migrate2to3(ctx sdk.Context) error {
return v046.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc)
}
// Migrate3to4 migrates x/bank storage from version 3 to 4.
func (m Migrator) Migrate3to4(ctx sdk.Context) error {
oldParams := m.keeper.GetParams(ctx)
m.keeper.SetAllSendEnabled(ctx, oldParams.GetSendEnabled())
m.keeper.SetParams(ctx, banktypes.NewParams(oldParams.DefaultSendEnabled))
return nil
}

View File

@ -23,6 +23,14 @@ type SendKeeper interface {
GetParams(ctx sdk.Context) types.Params
SetParams(ctx sdk.Context, params types.Params)
IsSendEnabledDenom(ctx sdk.Context, denom string) bool
GetSendEnabledEntry(ctx sdk.Context, denom string) (types.SendEnabled, bool)
SetSendEnabled(ctx sdk.Context, denom string, value bool)
SetAllSendEnabled(ctx sdk.Context, sendEnableds []*types.SendEnabled)
DeleteSendEnabled(ctx sdk.Context, denom string)
IterateSendEnabledEntries(ctx sdk.Context, cb func(denom string, sendEnabled bool) (stop bool))
GetAllSendEnabledEntries(ctx sdk.Context) []types.SendEnabled
IsSendEnabledCoin(ctx sdk.Context, coin sdk.Coin) bool
IsSendEnabledCoins(ctx sdk.Context, coins ...sdk.Coin) error
@ -67,12 +75,16 @@ func (k BaseSendKeeper) GetParams(ctx sdk.Context) (params types.Params) {
// SetParams sets the total set of bank parameters.
func (k BaseSendKeeper) SetParams(ctx sdk.Context, params types.Params) {
k.paramSpace.SetParamSet(ctx, &params)
if len(params.SendEnabled) > 0 {
k.SetAllSendEnabled(ctx, params.SendEnabled)
}
p := types.NewParams(params.DefaultSendEnabled)
k.paramSpace.SetParamSet(ctx, &p)
}
// InputOutputCoins performs multi-send functionality. It accepts a series of
// inputs that correspond to a series of outputs. It returns an error if the
// inputs and outputs don't lineup or if any single transfer of tokens fails.
// inputs and outputs don't line up or if any single transfer of tokens fails.
func (k BaseSendKeeper) InputOutputCoins(ctx sdk.Context, inputs []types.Input, outputs []types.Output) error {
// Safety check ensuring that when sending coins the keeper must maintain the
// Check supply invariant and validity of Coins.
@ -305,9 +317,22 @@ func (k BaseSendKeeper) setBalance(ctx sdk.Context, addr sdk.AccAddress, balance
// any of the coins are not configured for sending. Returns nil if sending is enabled
// for all provided coin
func (k BaseSendKeeper) IsSendEnabledCoins(ctx sdk.Context, coins ...sdk.Coin) error {
if len(coins) == 0 {
return nil
}
store := ctx.KVStore(k.storeKey)
haveDefault := false
var defaultVal bool
getDefault := func() bool {
if !haveDefault {
defaultVal = k.GetParams(ctx).DefaultSendEnabled
haveDefault = true
}
return defaultVal
}
for _, coin := range coins {
if !k.IsSendEnabledCoin(ctx, coin) {
return sdkerrors.Wrapf(types.ErrSendDisabled, "%s transfers are currently disabled", coin.Denom)
if !k.getSendEnabledOrDefault(store, coin.Denom, getDefault) {
return types.ErrSendDisabled.Wrapf("%s transfers are currently disabled", coin.Denom)
}
}
return nil
@ -315,7 +340,7 @@ func (k BaseSendKeeper) IsSendEnabledCoins(ctx sdk.Context, coins ...sdk.Coin) e
// IsSendEnabledCoin returns the current SendEnabled status of the provided coin's denom
func (k BaseSendKeeper) IsSendEnabledCoin(ctx sdk.Context, coin sdk.Coin) bool {
return k.GetParams(ctx).SendEnabledDenom(coin.Denom)
return k.IsSendEnabledDenom(ctx, coin.Denom)
}
// BlockedAddr checks if a given address is restricted from
@ -328,3 +353,113 @@ func (k BaseSendKeeper) BlockedAddr(addr sdk.AccAddress) bool {
func (k BaseSendKeeper) GetBlockedAddresses() map[string]bool {
return k.blockedAddrs
}
// IsSendEnabledDenom returns the current SendEnabled status of the provided denom.
func (k BaseSendKeeper) IsSendEnabledDenom(ctx sdk.Context, denom string) bool {
return k.getSendEnabledOrDefault(ctx.KVStore(k.storeKey), denom, func() bool { return k.GetParams(ctx).DefaultSendEnabled })
}
// GetSendEnabledEntry gets a SendEnabled entry for the given denom.
// The second return argument is true iff a specific entry exists for the given denom.
func (k BaseSendKeeper) GetSendEnabledEntry(ctx sdk.Context, denom string) (types.SendEnabled, bool) {
sendEnabled, found := k.getSendEnabled(ctx.KVStore(k.storeKey), denom)
if !found {
return types.SendEnabled{}, false
}
return types.SendEnabled{Denom: denom, Enabled: sendEnabled}, true
}
// SetSendEnabled sets the SendEnabled flag for a denom to the provided value.
func (k BaseSendKeeper) SetSendEnabled(ctx sdk.Context, denom string, value bool) {
store := ctx.KVStore(k.storeKey)
k.setSendEnabledEntry(store, denom, value)
}
// SetAllSendEnabled sets all the provided SendEnabled entries in the bank store.
func (k BaseSendKeeper) SetAllSendEnabled(ctx sdk.Context, sendEnableds []*types.SendEnabled) {
store := ctx.KVStore(k.storeKey)
for _, se := range sendEnableds {
k.setSendEnabledEntry(store, se.Denom, se.Enabled)
}
}
// setSendEnabledEntry sets SendEnabled for the given denom to the give value in the provided store.
func (k BaseSendKeeper) setSendEnabledEntry(store sdk.KVStore, denom string, value bool) {
key := types.CreateSendEnabledKey(denom)
val := types.ToBoolB(value)
store.Set(key, []byte{val})
}
// DeleteSendEnabled deletes a SendEnabled flag for a denom.
func (k BaseSendKeeper) DeleteSendEnabled(ctx sdk.Context, denom string) {
store := ctx.KVStore(k.storeKey)
store.Delete(types.CreateSendEnabledKey(denom))
}
// getSendEnabledPrefixStore gets a prefix store for the SendEnabled entries.
func (k BaseSendKeeper) getSendEnabledPrefixStore(ctx sdk.Context) sdk.KVStore {
return prefix.NewStore(ctx.KVStore(k.storeKey), types.SendEnabledPrefix)
}
// IterateSendEnabledEntries iterates over all the SendEnabled entries.
func (k BaseSendKeeper) IterateSendEnabledEntries(ctx sdk.Context, cb func(denom string, sendEnabled bool) bool) {
seStore := k.getSendEnabledPrefixStore(ctx)
iterator := seStore.Iterator(nil, nil)
defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {
denom := string(iterator.Key())
val := types.IsTrueB(iterator.Value())
if cb(denom, val) {
break
}
}
}
// GetAllSendEnabledEntries gets all the SendEnabled entries that are stored.
// Any denoms not returned use the default value (set in Params).
func (k BaseSendKeeper) GetAllSendEnabledEntries(ctx sdk.Context) []types.SendEnabled {
var rv []types.SendEnabled
k.IterateSendEnabledEntries(ctx, func(denom string, sendEnabled bool) bool {
rv = append(rv, types.SendEnabled{Denom: denom, Enabled: sendEnabled})
return false
})
return rv
}
// getSendEnabled returns whether send is enabled and whether that flag was set for a denom.
//
// Example usage:
// store := ctx.KVStore(k.storeKey)
// sendEnabled, found := getSendEnabled(store, "atom")
// if !found {
// sendEnabled = DefaultSendEnabled
// }
func (k BaseSendKeeper) getSendEnabled(store sdk.KVStore, denom string) (bool, bool) {
key := types.CreateSendEnabledKey(denom)
if !store.Has(key) {
return false, false
}
v := store.Get(key)
if len(v) != 1 {
return false, false
}
switch v[0] {
case types.TrueB:
return true, true
case types.FalseB:
return false, true
default:
return false, false
}
}
// getSendEnabledOrDefault gets the send_enabled value for a denom. If it's not in the store, this will return the result of the getDefault function.
func (k BaseSendKeeper) getSendEnabledOrDefault(store sdk.KVStore, denom string, getDefault func() bool) bool {
sendEnabled, found := k.getSendEnabled(store, denom)
if found {
return sendEnabled
}
return getDefault()
}

View File

@ -77,6 +77,7 @@ func TestMigrateJSON(t *testing.T) {
"default_send_enabled": false,
"send_enabled": []
},
"send_enabled": [],
"supply": [
{
"amount": "20",

View File

@ -0,0 +1,14 @@
package v047
import (
"github.com/cosmos/cosmos-sdk/x/bank/types"
)
// MigrateGenState accepts exported v0.43 x/bank genesis state and migrates it to
// v0.47 x/bank genesis state. The migration includes:
// - Move the SendEnabled entries from Params to the new GenesisState.SendEnabled field.
func MigrateGenState(oldState *types.GenesisState) *types.GenesisState {
newState := *oldState
newState.MigrateSendEnabled()
return &newState
}

View File

@ -0,0 +1,158 @@
package v047
import (
"testing"
"github.com/stretchr/testify/assert"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/bank/types"
)
func TestMigrateGenState(t *testing.T) {
tests := []struct {
name string
oldState *types.GenesisState
newState *types.GenesisState
}{
{
name: "Balances supply metadata all unchanged",
oldState: &types.GenesisState{
Params: types.Params{},
Balances: []types.Balance{{
Address: "balance1",
Coins: sdk.Coins{sdk.NewCoin("balance1coin", sdk.NewInt(8))},
}},
Supply: sdk.Coins{sdk.NewCoin("supplycoin", sdk.NewInt(800))},
DenomMetadata: []types.Metadata{{
Description: "metadesk",
DenomUnits: nil,
Base: "meta",
Display: "meta",
Name: "foo",
Symbol: "META",
URI: "",
URIHash: "",
}},
SendEnabled: []types.SendEnabled{},
},
newState: &types.GenesisState{
Params: types.Params{},
Balances: []types.Balance{{
Address: "balance1",
Coins: sdk.Coins{sdk.NewCoin("balance1coin", sdk.NewInt(8))},
}},
Supply: sdk.Coins{sdk.NewCoin("supplycoin", sdk.NewInt(800))},
DenomMetadata: []types.Metadata{{
Description: "metadesk",
DenomUnits: nil,
Base: "meta",
Display: "meta",
Name: "foo",
Symbol: "META",
URI: "",
URIHash: "",
}},
SendEnabled: []types.SendEnabled{},
},
},
{
name: "default send enabled true not changed",
oldState: &types.GenesisState{
Params: types.Params{DefaultSendEnabled: true},
},
newState: &types.GenesisState{
Params: types.Params{DefaultSendEnabled: true},
},
},
{
name: "default send enabled false not changed",
oldState: &types.GenesisState{
Params: types.Params{DefaultSendEnabled: false, SendEnabled: []*types.SendEnabled{}},
},
newState: &types.GenesisState{
Params: types.Params{DefaultSendEnabled: false},
},
},
{
name: "send enabled entries moved",
oldState: &types.GenesisState{
Params: types.Params{
SendEnabled: []*types.SendEnabled{
{"movecointrue", true},
{"movecoinfalse", false},
},
},
},
newState: &types.GenesisState{
Params: types.Params{},
SendEnabled: []types.SendEnabled{
{"movecointrue", true},
{"movecoinfalse", false},
},
},
},
{
name: "params entries added to existing",
oldState: &types.GenesisState{
Params: types.Params{
SendEnabled: []*types.SendEnabled{
{"movecointrue", true},
{"movecoinfalse", false},
},
},
SendEnabled: []types.SendEnabled{
{"staycoin", true},
},
},
newState: &types.GenesisState{
Params: types.Params{},
SendEnabled: []types.SendEnabled{
{"staycoin", true},
{"movecointrue", true},
{"movecoinfalse", false},
},
},
},
{
name: "conflicting params ignored",
oldState: &types.GenesisState{
Params: types.Params{
SendEnabled: []*types.SendEnabled{
{"staycoin", false},
},
},
SendEnabled: []types.SendEnabled{
{"staycoin", true},
},
},
newState: &types.GenesisState{
Params: types.Params{},
SendEnabled: []types.SendEnabled{
{"staycoin", true},
},
},
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
actual := MigrateGenState(tc.oldState)
assert.Equal(t, tc.newState, actual)
})
}
t.Run("ensure original not changed", func(t *testing.T) {
origState := types.GenesisState{
Params: types.Params{
SendEnabled: []*types.SendEnabled{
{"movecointrue", true},
{"movecoinfalse", false},
},
},
}
_ = MigrateGenState(&origState)
assert.Len(t, origState.Params.SendEnabled, 2)
})
}

View File

@ -114,6 +114,10 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
if err := cfg.RegisterMigration(types.ModuleName, 2, m.Migrate2to3); err != nil {
panic(fmt.Sprintf("failed to migrate x/bank from version 2 to 3: %v", err))
}
if err := cfg.RegisterMigration(types.ModuleName, 3, m.Migrate3to4); err != nil {
panic(fmt.Sprintf("failed to migrate x/bank from version 3 to 4: %v", err))
}
}
// NewAppModule creates a new AppModule object
@ -166,7 +170,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
}
// ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return 3 }
func (AppModule) ConsensusVersion() uint64 { return 4 }
// BeginBlock performs a no-op.
func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}

View File

@ -12,27 +12,46 @@ import (
"github.com/cosmos/cosmos-sdk/x/bank/types"
)
// RandomGenesisDefaultSendParam computes randomized allow all send transfers param for the bank module
func RandomGenesisDefaultSendParam(r *rand.Rand) bool {
// 90% chance of transfers being enable or P(a) = 0.9 for success
return r.Int63n(101) <= 90
// RandomGenesisDefaultSendEnabledParam computes randomized allow all send transfers param for the bank module
func RandomGenesisDefaultSendEnabledParam(r *rand.Rand) bool {
// 90% chance of transfers being enabled or P(a) = 0.9 for success
return r.Int63n(100) < 90
}
// RandomGenesisSendParams randomized Parameters for the bank module
func RandomGenesisSendParams(r *rand.Rand) types.SendEnabledParams {
params := types.DefaultParams()
// 90% chance of transfers being DefaultSendEnabled=true or P(a) = 0.9 for success
// 50% of the time add an additional denom specific record (P(b) = 0.475 = 0.5 * 0.95)
if r.Int63n(101) <= 50 {
// set send enabled 95% of the time
bondEnabled := r.Int63n(101) <= 95
params = params.SetSendEnabledParam(
sdk.DefaultBondDenom,
bondEnabled)
// RandomGenesisSendEnabled creates randomized values for the SendEnabled slice.
func RandomGenesisSendEnabled(r *rand.Rand) []types.SendEnabled {
rv := make([]types.SendEnabled, 0, 2)
// 60% of the time, add a denom specific record.
if r.Int63n(100) < 60 {
// 75% of the those times, set send enabled to true.
bondEnabled := r.Int63n(100) < 75
rv = append(rv, types.SendEnabled{sdk.DefaultBondDenom, bondEnabled})
}
// Probabilities:
// P(a) = 60.0% = There's SendEnable entry for the bond denom = .600
// P(a)' = 40.0% = There is NOT a SendEnable entry for the bond denom = 1 - P(a) = 1 - .600 = .400
// P(b) = 75.0% = The SendEnable entry is true (if there is such an entry) = .750
// P(b)' = 25.0% = The SendEnable entry is false (if there is such an entry) = 1 - P(b) = 1 - .750 = .250
// P(c) = 90.0% = The default send enabled is true (defined in RandomGenesisDefaultSendEnabledParam) = .900
// P(c)' = 10.0% = The default send enabled is false = 1 - P(c) = 1 - .900 = .100
//
// P(st) = 45.0% = There's a SendEnable entry that's true = P(a)*P(b) = .600*.750 = .450
// P(sf) = 15.0% = There's a SendEnable entry that's false = P(a)*P(b)' = .600*.250 = .150
//
// P(a'c) = 36.0% = No SendEnabled entry AND default is true = P(a)'*P(c) = .400*.900 = .360
// P(a'c') = 4.0% = No SendEnabled entry AND default is false = P(a)'*P(c)' = .400*.100 = .040
// P(stc) = 40.5% = SendEnabled entry is true AND default is true = P(st)*P(c) = .450*.900 = .405
// P(stc') = 4.5% = SendEnabled entry is true AND default is false = P(st)*P(c)' = .450*.100 = .045
// P(sfc) = 13.5% = SendEnabled entry is false AND default is true = P(sf)*P(c) = .150*.900 = .135
// P(sfc') = 1.5% = SendEnabled entry is false AND default is false = P(sf)*P(c)' = .150*.100 = .015
//
// P(set) = 42.0% = SendEnabled entry that equals the default = P(stc) + P(sfc') = .405 + .015 = .420
// P(sef) = 18.0% = SendEnabled entry that does not equal the default = P(stc') + P(sfc) = .045 + .135 = .180
//
// P(t) = 81.0% = Bond denom is sendable = P(a'c) + P(st) = .360 + .450 = .810
// P(f) = 19.0% = Bond demon is NOT sendable = P(a'c') + P(sf) = .040 + .150 = .190
// overall probability of enabled for bond denom is 94.75% (P(a)+P(b) - P(a)*P(b))
return params.SendEnabled
return rv
}
// RandomGenesisBalances returns a slice of account balances. Each account has
@ -52,29 +71,24 @@ func RandomGenesisBalances(simState *module.SimulationState) []types.Balance {
// RandomizedGenState generates a random GenesisState for bank
func RandomizedGenState(simState *module.SimulationState) {
var sendEnabledParams types.SendEnabledParams
simState.AppParams.GetOrGenerate(
simState.Cdc, string(types.KeySendEnabled), &sendEnabledParams, simState.Rand,
func(r *rand.Rand) { sendEnabledParams = RandomGenesisSendParams(r) },
)
var defaultSendEnabledParam bool
simState.AppParams.GetOrGenerate(
simState.Cdc, string(types.KeyDefaultSendEnabled), &defaultSendEnabledParam, simState.Rand,
func(r *rand.Rand) { defaultSendEnabledParam = RandomGenesisDefaultSendParam(r) },
func(r *rand.Rand) { defaultSendEnabledParam = RandomGenesisDefaultSendEnabledParam(r) },
)
sendEnabled := RandomGenesisSendEnabled(simState.Rand)
numAccs := int64(len(simState.Accounts))
totalSupply := simState.InitialStake.Mul(sdk.NewInt((numAccs + simState.NumBonded)))
supply := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, totalSupply))
bankGenesis := types.GenesisState{
Params: types.Params{
SendEnabled: sendEnabledParams,
DefaultSendEnabled: defaultSendEnabledParam,
},
Balances: RandomGenesisBalances(simState),
Supply: supply,
Params: types.NewParams(defaultSendEnabledParam),
Balances: RandomGenesisBalances(simState),
Supply: supply,
SendEnabled: sendEnabled,
}
paramsBytes, err := json.MarshalIndent(&bankGenesis.Params, "", " ")

View File

@ -5,6 +5,7 @@ import (
"math/rand"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
sdkmath "cosmossdk.io/math"
@ -39,12 +40,16 @@ func TestRandomizedGenState(t *testing.T) {
var bankGenesis types.GenesisState
simState.Cdc.MustUnmarshalJSON(simState.GenState[types.ModuleName], &bankGenesis)
require.Equal(t, true, bankGenesis.Params.GetDefaultSendEnabled())
require.Len(t, bankGenesis.Params.GetSendEnabled(), 1)
require.Len(t, bankGenesis.Balances, 3)
require.Equal(t, "cosmos1ghekyjucln7y67ntx7cf27m9dpuxxemn4c8g4r", bankGenesis.Balances[2].GetAddress().String())
require.Equal(t, "1000stake", bankGenesis.Balances[2].GetCoins().String())
require.Equal(t, "6000stake", bankGenesis.Supply.String())
assert.Equal(t, true, bankGenesis.Params.GetDefaultSendEnabled(), "Params.GetDefaultSendEnabled")
assert.Len(t, bankGenesis.Params.GetSendEnabled(), 0, "Params.GetSendEnabled")
if assert.Len(t, bankGenesis.Balances, 3) {
assert.Equal(t, "cosmos1ghekyjucln7y67ntx7cf27m9dpuxxemn4c8g4r", bankGenesis.Balances[2].GetAddress().String(), "Balances[2] address")
assert.Equal(t, "1000stake", bankGenesis.Balances[2].GetCoins().String(), "Balances[2] coins")
}
assert.Equal(t, "6000stake", bankGenesis.Supply.String(), "Supply")
if assert.Len(t, bankGenesis.SendEnabled, 1, "SendEnabled") {
assert.Equal(t, true, bankGenesis.SendEnabled[0].Enabled, "SendEnabled[0] value")
}
}
// TestRandomizedGenState tests abnormal scenarios of applying RandomizedGenState.

View File

@ -3,7 +3,6 @@ package simulation
// DONTCOVER
import (
"encoding/json"
"fmt"
"math/rand"
@ -17,18 +16,9 @@ import (
// on the simulation
func ParamChanges(r *rand.Rand) []simtypes.ParamChange {
return []simtypes.ParamChange{
simulation.NewSimParamChange(types.ModuleName, string(types.KeySendEnabled),
func(r *rand.Rand) string {
paramsBytes, err := json.Marshal(RandomGenesisSendParams(r))
if err != nil {
panic(err)
}
return string(paramsBytes)
},
),
simulation.NewSimParamChange(types.ModuleName, string(types.KeyDefaultSendEnabled),
func(r *rand.Rand) string {
return fmt.Sprintf("%v", RandomGenesisDefaultSendParam(r))
return fmt.Sprintf("%v", RandomGenesisDefaultSendEnabledParam(r))
},
),
}

View File

@ -19,13 +19,12 @@ func TestParamChanges(t *testing.T) {
simValue string
subspace string
}{
{"bank/SendEnabled", "SendEnabled", "[]", "bank"},
{"bank/DefaultSendEnabled", "DefaultSendEnabled", "true", "bank"},
}
paramChanges := simulation.ParamChanges(r)
require.Len(t, paramChanges, 2)
require.Len(t, paramChanges, len(expected))
for i, p := range paramChanges {
require.Equal(t, expected[i].composedKey, p.ComposedKey())

View File

@ -4,11 +4,12 @@ order: 1
# State
The `x/bank` module keeps state of three primary objects:
The `x/bank` module keeps state of the following primary objects:
1. Account balances
2. Denomination metadata
3. The total supply of all balances
4. Information on which denominations are allowed to be sent.
In addition, the `x/bank` module keeps the following indexes to manage the
aforementioned state:

View File

@ -61,15 +61,17 @@ Restricted permission to mint per module could be achieved by using baseKeeper w
// between accounts.
type Keeper interface {
SendKeeper
WithMintCoinsRestriction(NewRestrictionFn BankMintingRestrictionFn) BaseKeeper
WithMintCoinsRestriction(MintingRestrictionFn) BaseKeeper
InitGenesis(sdk.Context, *types.GenesisState)
ExportGenesis(sdk.Context) *types.GenesisState
GetSupply(ctx sdk.Context, denom string) sdk.Coin
HasSupply(ctx sdk.Context, denom string) bool
GetPaginatedTotalSupply(ctx sdk.Context, pagination *query.PageRequest) (sdk.Coins, *query.PageResponse, error)
IterateTotalSupply(ctx sdk.Context, cb func(sdk.Coin) bool)
GetDenomMetaData(ctx sdk.Context, denom string) (types.Metadata, bool)
HasDenomMetaData(ctx sdk.Context, denom string) bool
SetDenomMetaData(ctx sdk.Context, denomMetaData types.Metadata)
IterateAllDenomMetaData(ctx sdk.Context, cb func(types.Metadata) bool)
@ -84,6 +86,9 @@ type Keeper interface {
DelegateCoins(ctx sdk.Context, delegatorAddr, moduleAccAddr sdk.AccAddress, amt sdk.Coins) error
UndelegateCoins(ctx sdk.Context, moduleAccAddr, delegatorAddr sdk.AccAddress, amt sdk.Coins) error
// GetAuthority Gets the address capable of executing governance proposal messages. Usually the gov module account.
GetAuthority() string
types.QueryServer
}
```
@ -105,6 +110,13 @@ type SendKeeper interface {
GetParams(ctx sdk.Context) types.Params
SetParams(ctx sdk.Context, params types.Params)
IsSendEnabledDenom(ctx sdk.Context, denom string) bool
SetSendEnabled(ctx sdk.Context, denom string, value bool)
SetAllSendEnabled(ctx sdk.Context, sendEnableds []*types.SendEnabled)
DeleteSendEnabled(ctx sdk.Context, denom string)
IterateSendEnabledEntries(ctx sdk.Context, cb func(denom string, sendEnabled bool) (stop bool))
GetAllSendEnabledEntries(ctx sdk.Context) []types.SendEnabled
IsSendEnabledCoin(ctx sdk.Context, coin sdk.Coin) bool
IsSendEnabledCoins(ctx sdk.Context, coins ...sdk.Coin) error

View File

@ -6,16 +6,16 @@ order: 5
The bank module contains the following parameters:
| Key | Type | Example |
| ------------------ | ------------- | ---------------------------------- |
| SendEnabled | []SendEnabled | [{denom: "stake", enabled: true }] |
| DefaultSendEnabled | bool | true |
| Key | Type | Example |
| ------------------ | ------------- |--------------|
| SendEnabled | []SendEnabled | (deprecated) |
| DefaultSendEnabled | bool | true |
## SendEnabled
The send enabled parameter is an array of SendEnabled entries mapping coin
denominations to their send_enabled status. Entries in this list take
precedence over the `DefaultSendEnabled` setting.
The SendEnabled parameter is now deprecated and not to be use. It is replaced
with state store records.
## DefaultSendEnabled

View File

@ -91,6 +91,32 @@ amount: "10000000000"
denom: stake
```
#### send-enabled
The `send-enabled` command allows users to query for all or some SendEnabled entries.
```sh
simd query bank send-enabled [denom1 ...] [flags]
```
Example:
```sh
simd query bank send-enabled
```
Example output:
```yml
send_enabled:
- denom: foocoin
enabled: true
- denom: barcoin
pagination:
next-key: null
total: 2
```
### Transactions
The `tx` commands allow users to interact with the `bank` module.
@ -388,3 +414,41 @@ Example Output:
}
}
```
### SendEnabled
The `SendEnabled` enpoints allows users to query the SendEnabled entries of the `bank` module.
Any denominations NOT returned, use the `Params.DefaultSendEnabled` value.
```sh
cosmos.bank.v1beta1.Query/SendEnabled
```
Example:
```sh
grpcurl -plaintext \
localhost:9090 \
cosmos.bank.v1beta1.Query/SendEnabled
```
Example Output:
```json
{
"send_enabled": [
{
"denom": "foocoin",
"enabled": true
},
{
"denom": "barcoin"
}
],
"pagination": {
"next-key": null,
"total": 2
}
}
```

View File

@ -29,7 +29,12 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// Params defines the parameters for the bank module.
type Params struct {
SendEnabled []*SendEnabled `protobuf:"bytes,1,rep,name=send_enabled,json=sendEnabled,proto3" json:"send_enabled,omitempty"`
// Deprecated: Use of SendEnabled in params is deprecated.
// For genesis, use the newly added send_enabled field in the genesis object.
// Storage, lookup, and manipulation of this information is now in the keeper.
//
// As of cosmos-sdk 0.47, this only exists for backwards compatibility of genesis files.
SendEnabled []*SendEnabled `protobuf:"bytes,1,rep,name=send_enabled,json=sendEnabled,proto3" json:"send_enabled,omitempty"` // Deprecated: Do not use.
DefaultSendEnabled bool `protobuf:"varint,2,opt,name=default_send_enabled,json=defaultSendEnabled,proto3" json:"default_send_enabled,omitempty"`
}
@ -65,6 +70,7 @@ func (m *Params) XXX_DiscardUnknown() {
var xxx_messageInfo_Params proto.InternalMessageInfo
// Deprecated: Do not use.
func (m *Params) GetSendEnabled() []*SendEnabled {
if m != nil {
return m.SendEnabled
@ -454,48 +460,48 @@ func init() {
func init() { proto.RegisterFile("cosmos/bank/v1beta1/bank.proto", fileDescriptor_dd052eee12edf988) }
var fileDescriptor_dd052eee12edf988 = []byte{
// 649 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x54, 0x41, 0x6b, 0x13, 0x41,
0x14, 0xce, 0x34, 0x4d, 0xb2, 0x9d, 0xe8, 0x65, 0x0c, 0x3a, 0xed, 0x61, 0x13, 0xf6, 0x20, 0xb1,
0xd0, 0x24, 0xad, 0x9e, 0x82, 0x20, 0xb6, 0x8a, 0x46, 0x10, 0x65, 0x4b, 0x11, 0xbc, 0x84, 0x49,
0x76, 0x4c, 0x86, 0xee, 0xce, 0x2c, 0x3b, 0xb3, 0xa5, 0xb9, 0x0a, 0x82, 0x78, 0xf2, 0xe8, 0xb1,
0x57, 0x3d, 0x79, 0x28, 0xf8, 0x17, 0x8a, 0xa7, 0xe2, 0xc9, 0x53, 0x95, 0xf4, 0xa0, 0x3f, 0x43,
0x66, 0x66, 0x37, 0x4d, 0xa1, 0x8a, 0x07, 0x0f, 0x9e, 0xf6, 0x7d, 0xef, 0x7b, 0xf3, 0xbd, 0xef,
0xed, 0xbc, 0x5d, 0xe8, 0x0e, 0x85, 0x8c, 0x84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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x54, 0x31, 0x6f, 0x13, 0x49,
0x14, 0xf6, 0xd8, 0xb1, 0xbd, 0x19, 0xdf, 0x35, 0x73, 0xd6, 0xdd, 0x24, 0xc5, 0xda, 0xda, 0xe2,
0x64, 0x22, 0xc5, 0x76, 0x02, 0x95, 0x85, 0x84, 0x70, 0x40, 0xc1, 0x48, 0x08, 0xb4, 0x51, 0x84,
0x44, 0x63, 0x8d, 0xbd, 0x83, 0x3d, 0xca, 0xee, 0xcc, 0x6a, 0x67, 0x36, 0x8a, 0x5b, 0x2a, 0xa0,
0xa2, 0xa4, 0x4c, 0x0b, 0x15, 0x45, 0x24, 0xfe, 0x42, 0x44, 0x15, 0x51, 0x51, 0x05, 0xe4, 0x14,
0xf0, 0x33, 0xd0, 0xcc, 0xec, 0x3a, 0x89, 0x14, 0x10, 0x05, 0x05, 0xd5, 0xbe, 0xf7, 0xbe, 0x37,
0xdf, 0xfb, 0xfc, 0xe6, 0x1b, 0x43, 0x77, 0x2c, 0x64, 0x24, 0x64, 0x67, 0x44, 0xf8, 0x5e, 0x67,
0x7f, 0x63, 0x44, 0x15, 0xd9, 0x30, 0x49, 0x3b, 0x4e, 0x84, 0x12, 0xe8, 0x1f, 0x8b, 0xb7, 0x4d,
0x29, 0xc3, 0x57, 0xeb, 0x13, 0x31, 0x11, 0x06, 0xef, 0xe8, 0xc8, 0xb6, 0xae, 0xae, 0xd8, 0xd6,
0xa1, 0x05, 0xb2, 0x73, 0x16, 0x3a, 0x9f, 0x22, 0xe9, 0x62, 0xca, 0x58, 0x30, 0x9e, 0xe1, 0xff,
0x65, 0x78, 0x24, 0x27, 0x9d, 0xfd, 0x0d, 0xfd, 0xb1, 0x80, 0xf7, 0x02, 0xc0, 0xca, 0x23, 0x92,
0x90, 0x48, 0xa2, 0x6d, 0xf8, 0x97, 0xa4, 0x3c, 0x18, 0x52, 0x4e, 0x46, 0x21, 0x0d, 0x30, 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 0x0c,
0xad, 0xc0, 0x52, 0x9a, 0x30, 0x5c, 0x35, 0xce, 0xab, 0xce, 0x4f, 0x1b, 0xa5, 0x5d, 0x7f, 0xe0,
0xeb, 0x1a, 0xfa, 0x1f, 0x3a, 0x69, 0xc2, 0x86, 0x53, 0x22, 0xa7, 0xd8, 0x31, 0x78, 0x6d, 0x7e,
0xda, 0xa8, 0xee, 0xfa, 0x83, 0x7b, 0x44, 0x4e, 0xfd, 0x6a, 0x9a, 0x30, 0x1d, 0xf4, 0xb7, 0x8e,
0xe7, 0x2e, 0x38, 0x99, 0xbb, 0xe0, 0xcb, 0xdc, 0x05, 0xaf, 0xce, 0xdc, 0xc2, 0xc9, 0x99, 0x5b,
0xf8, 0x74, 0xe6, 0x16, 0x9e, 0x5c, 0xfb, 0x95, 0xeb, 0x33, 0x1e, 0x18, 0x55, 0xcc, 0x7f, 0xd4,
0xf5, 0xef, 0x01, 0x00, 0x00, 0xff, 0xff, 0xec, 0xf7, 0xce, 0x43, 0x44, 0x05, 0x00, 0x00,
}
func (this *SendEnabled) Equal(that interface{}) bool {

View File

@ -2,6 +2,7 @@ package types
import (
"encoding/json"
"errors"
"fmt"
"github.com/cosmos/cosmos-sdk/codec"
@ -11,15 +12,30 @@ import (
// Validate performs basic validation of supply genesis data returning an
// error for any failed validation criteria.
func (gs GenesisState) Validate() error {
if len(gs.Params.SendEnabled) > 0 && len(gs.SendEnabled) > 0 {
return errors.New("send_enabled defined in both the send_enabled field and in params (deprecated)")
}
if err := gs.Params.Validate(); err != nil {
return err
}
seenSendEnabled := make(map[string]bool)
seenBalances := make(map[string]bool)
seenMetadatas := make(map[string]bool)
totalSupply := sdk.Coins{}
for _, p := range gs.GetAllSendEnabled() {
if _, exists := seenSendEnabled[p.Denom]; exists {
return fmt.Errorf("duplicate send enabled found: '%s'", p.Denom)
}
if err := p.Validate(); err != nil {
return err
}
seenSendEnabled[p.Denom] = true
}
for _, balance := range gs.Balances {
if seenBalances[balance.Address] {
return fmt.Errorf("duplicate balance for address %s", balance.Address)
@ -62,18 +78,21 @@ func (gs GenesisState) Validate() error {
}
// NewGenesisState creates a new genesis state.
func NewGenesisState(params Params, balances []Balance, supply sdk.Coins, denomMetaData []Metadata) *GenesisState {
return &GenesisState{
func NewGenesisState(params Params, balances []Balance, supply sdk.Coins, denomMetaData []Metadata, sendEnabled []SendEnabled) *GenesisState {
rv := &GenesisState{
Params: params,
Balances: balances,
Supply: supply,
DenomMetadata: denomMetaData,
SendEnabled: sendEnabled,
}
rv.MigrateSendEnabled()
return rv
}
// DefaultGenesisState returns a default bank module genesis state.
func DefaultGenesisState() *GenesisState {
return NewGenesisState(DefaultParams(), []Balance{}, sdk.Coins{}, []Metadata{})
return NewGenesisState(DefaultParams(), []Balance{}, sdk.Coins{}, []Metadata{}, []SendEnabled{})
}
// GetGenesisStateFromAppState returns x/bank GenesisState given raw application
@ -87,3 +106,32 @@ func GetGenesisStateFromAppState(cdc codec.JSONCodec, appState map[string]json.R
return &genesisState
}
// MigrateSendEnabled moves the SendEnabled info from Params into the GenesisState.SendEnabled field and removes them from Params.
// If the Params.SendEnabled slice is empty, this is a noop.
// If the main SendEnabled slice already has entries, the Params.SendEnabled entries are added.
// In case of the same demon in both, preference is given to the existing (main GenesisState field) entry.
func (g *GenesisState) MigrateSendEnabled() {
g.SendEnabled = g.GetAllSendEnabled()
g.Params.SendEnabled = nil
}
// GetAllSendEnabled returns all the SendEnabled entries from both the SendEnabled field and the Params.
// If a denom has an entry in both, the entry in the SendEnabled field takes precedence over one in Params.
func (g GenesisState) GetAllSendEnabled() []SendEnabled {
if len(g.Params.SendEnabled) == 0 {
return g.SendEnabled
}
rv := make([]SendEnabled, len(g.SendEnabled))
knownSendEnabled := map[string]bool{}
for i, se := range g.SendEnabled {
rv[i] = se
knownSendEnabled[se.Denom] = true
}
for _, se := range g.Params.SendEnabled {
if _, known := knownSendEnabled[se.Denom]; !known {
rv = append(rv, *se)
}
}
return rv
}

View File

@ -28,15 +28,19 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// GenesisState defines the bank module's genesis state.
type GenesisState struct {
// params defines all the paramaters of the module.
// params defines all the parameters of the module.
Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
// balances is an array containing the balances of all the accounts.
Balances []Balance `protobuf:"bytes,2,rep,name=balances,proto3" json:"balances"`
// supply represents the total supply. If it is left empty, then supply will be calculated based on the provided
// balances. Otherwise, it will be used to validate that the sum of the balances equals this amount.
Supply github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=supply,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"supply"`
// denom_metadata defines the metadata of the differents coins.
// denom_metadata defines the metadata of the different coins.
DenomMetadata []Metadata `protobuf:"bytes,4,rep,name=denom_metadata,json=denomMetadata,proto3" json:"denom_metadata"`
// send_enabled defines the denoms where send is enabled or disabled.
//
// Since: cosmos-sdk 0.47
SendEnabled []SendEnabled `protobuf:"bytes,5,rep,name=send_enabled,json=sendEnabled,proto3" json:"send_enabled"`
}
func (m *GenesisState) Reset() { *m = GenesisState{} }
@ -100,6 +104,13 @@ func (m *GenesisState) GetDenomMetadata() []Metadata {
return nil
}
func (m *GenesisState) GetSendEnabled() []SendEnabled {
if m != nil {
return m.SendEnabled
}
return nil
}
// Balance defines an account address and balance pair used in the bank module's
// genesis state.
type Balance struct {
@ -150,32 +161,34 @@ func init() {
func init() { proto.RegisterFile("cosmos/bank/v1beta1/genesis.proto", fileDescriptor_8f007de11b420c6e) }
var fileDescriptor_8f007de11b420c6e = []byte{
// 395 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x92, 0x3f, 0x4f, 0xfa, 0x40,
0x18, 0xc7, 0x5b, 0xe0, 0x07, 0xfc, 0x0e, 0x75, 0xa8, 0x0c, 0x05, 0xb5, 0x45, 0x26, 0x1c, 0x68,
0x05, 0x27, 0x1d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x51, 0x34, 0x1c, 0xab,
0x59, 0x46, 0x57, 0xbe, 0x68, 0x82, 0x52, 0xba, 0x83, 0xfd, 0xd0, 0x3a, 0x4c, 0xd0, 0xe9, 0x9b,
0xde, 0xf0, 0x7c, 0x7a, 0x33, 0xb2, 0x0d, 0x07, 0x07, 0x62, 0x2e, 0xf1, 0x68, 0x12, 0x77, 0x60,
0xd2, 0x71, 0x84, 0x08, 0x03, 0x48, 0x57, 0x44, 0x2b, 0x17, 0x60, 0xcb, 0x45, 0x21, 0x0e, 0xfa,
0x01, 0xa2, 0xd0, 0x85, 0x14, 0xaa, 0x39, 0x56, 0x6c, 0x6f, 0x6d, 0xab, 0x97, 0xc2, 0x24, 0x7a,
0xdd, 0x64, 0xe8, 0xea, 0x67, 0x7d, 0x2a, 0x83, 0x82, 0x18, 0x46, 0x69, 0x83, 0x02, 0x74, 0xdd,
0x18, 0x11, 0x7e, 0x70, 0xff, 0x2d, 0xf5, 0xf9, 0xb1, 0x59, 0x16, 0x99, 0x67, 0x5c, 0xe9, 0xd1,
0xd8, 0x0f, 0xbd, 0xee, 0xca, 0xa8, 0x40, 0xf0, 0x2f, 0xb9, 0xc5, 0xd5, 0x69, 0xfd, 0xe9, 0xbc,
0x3c, 0xf9, 0xa4, 0x78, 0x3f, 0xd1, 0xa5, 0x8f, 0x89, 0x2e, 0x59, 0x9d, 0xd9, 0x42, 0x93, 0xe7,
0x0b, 0x4d, 0x7e, 0x5f, 0x68, 0xf2, 0xc3, 0x52, 0x93, 0xe6, 0x4b, 0x4d, 0x7a, 0x59, 0x6a, 0xd2,
0xf5, 0xc1, 0xaf, 0xa1, 0x77, 0x7c, 0xad, 0x58, 0xb6, 0x9d, 0x67, 0x5b, 0x73, 0xf4, 0x19, 0x00,
0x00, 0xff, 0xff, 0x78, 0xd8, 0xf3, 0x7f, 0xe0, 0x02, 0x00, 0x00,
// 425 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 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6d, 0x1e, 0x8e, 0xb6, 0xf9,
0xe7, 0x68, 0x9b, 0xdf, 0x4e, 0xb6, 0x71, 0x38, 0xd9, 0xc6, 0xcf, 0x93, 0x6d, 0x7c, 0x78, 0x7c,
0x2d, 0xf4, 0xb3, 0xda, 0x50, 0xc9, 0x0e, 0xea, 0x72, 0x01, 0x9f, 0xfe, 0x0b, 0x00, 0x00, 0xff,
0xff, 0x80, 0xd6, 0xfd, 0xac, 0x2b, 0x03, 0x00, 0x00,
}
func (m *GenesisState) Marshal() (dAtA []byte, err error) {
@ -198,6 +211,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if len(m.SendEnabled) > 0 {
for iNdEx := len(m.SendEnabled) - 1; iNdEx >= 0; iNdEx-- {
{
size, err := m.SendEnabled[iNdEx].MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x2a
}
}
if len(m.DenomMetadata) > 0 {
for iNdEx := len(m.DenomMetadata) - 1; iNdEx >= 0; iNdEx-- {
{
@ -334,6 +361,12 @@ func (m *GenesisState) Size() (n int) {
n += 1 + l + sovGenesis(uint64(l))
}
}
if len(m.SendEnabled) > 0 {
for _, e := range m.SendEnabled {
l = e.Size()
n += 1 + l + sovGenesis(uint64(l))
}
}
return n
}
@ -526,6 +559,40 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error {
return err
}
iNdEx = postIndex
case 5:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field SendEnabled", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.SendEnabled = append(m.SendEnabled, SendEnabled{})
if err := m.SendEnabled[len(m.SendEnabled)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipGenesis(dAtA[iNdEx:])

View File

@ -3,6 +3,7 @@ package types
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -144,14 +145,364 @@ func TestGenesisStateValidate(t *testing.T) {
for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Run(tc.name, func(tt *testing.T) {
err := tc.genesisState.Validate()
if tc.expErr {
require.Error(t, err)
require.Error(tt, err)
} else {
require.NoError(t, err)
require.NoError(tt, err)
}
})
}
}
func TestMigrateSendEnabled(t *testing.T) {
tests := []struct {
name string
oldState *GenesisState
newState *GenesisState
}{
{
name: "Balances supply metadata all unchanged",
oldState: &GenesisState{
Params: Params{},
Balances: []Balance{{
Address: "balance1",
Coins: sdk.Coins{sdk.NewCoin("balance1coin", sdk.NewInt(8))},
}},
Supply: sdk.Coins{sdk.NewCoin("supplycoin", sdk.NewInt(800))},
DenomMetadata: []Metadata{{
Description: "metadesk",
DenomUnits: nil,
Base: "meta",
Display: "meta",
Name: "foo",
Symbol: "META",
URI: "",
URIHash: "",
}},
},
newState: &GenesisState{
Params: Params{},
Balances: []Balance{{
Address: "balance1",
Coins: sdk.Coins{sdk.NewCoin("balance1coin", sdk.NewInt(8))},
}},
Supply: sdk.Coins{sdk.NewCoin("supplycoin", sdk.NewInt(800))},
DenomMetadata: []Metadata{{
Description: "metadesk",
DenomUnits: nil,
Base: "meta",
Display: "meta",
Name: "foo",
Symbol: "META",
URI: "",
URIHash: "",
}},
},
},
{
name: "default send enabled true not changed",
oldState: &GenesisState{
Params: Params{DefaultSendEnabled: true},
},
newState: &GenesisState{
Params: Params{DefaultSendEnabled: true},
},
},
{
name: "default send enabled false not changed",
oldState: &GenesisState{
Params: Params{DefaultSendEnabled: false, SendEnabled: []*SendEnabled{}},
},
newState: &GenesisState{
Params: Params{DefaultSendEnabled: false},
},
},
{
name: "send enabled entries moved",
oldState: &GenesisState{
Params: Params{
SendEnabled: []*SendEnabled{
{"movecointrue", true},
{"movecoinfalse", false},
},
},
},
newState: &GenesisState{
Params: Params{},
SendEnabled: []SendEnabled{
{"movecointrue", true},
{"movecoinfalse", false},
},
},
},
{
name: "params entries added to existing",
oldState: &GenesisState{
Params: Params{
SendEnabled: []*SendEnabled{
{"movecointrue", true},
{"movecoinfalse", false},
},
},
SendEnabled: []SendEnabled{
{"staycoin", true},
},
},
newState: &GenesisState{
Params: Params{},
SendEnabled: []SendEnabled{
{"staycoin", true},
{"movecointrue", true},
{"movecoinfalse", false},
},
},
},
{
name: "conflicting params ignored",
oldState: &GenesisState{
Params: Params{
SendEnabled: []*SendEnabled{
{"staycoin", false},
},
},
SendEnabled: []SendEnabled{
{"staycoin", true},
},
},
newState: &GenesisState{
Params: Params{},
SendEnabled: []SendEnabled{
{"staycoin", true},
},
},
},
}
for _, tc := range tests {
t.Run(tc.name, func(tt *testing.T) {
tc.oldState.MigrateSendEnabled()
assert.Equal(tt, tc.newState, tc.oldState)
})
}
}
func TestGetAllSendEnabled(t *testing.T) {
tests := []struct {
name string
gs GenesisState
exp []SendEnabled
}{
{
name: "nil and nil",
gs: GenesisState{
SendEnabled: nil,
Params: Params{
SendEnabled: nil,
},
},
exp: nil,
},
{
name: "nil and empty",
gs: GenesisState{
SendEnabled: nil,
Params: Params{
SendEnabled: []*SendEnabled{},
},
},
exp: nil,
},
{
name: "empty and nil",
gs: GenesisState{
SendEnabled: []SendEnabled{},
Params: Params{
SendEnabled: nil,
},
},
exp: []SendEnabled{},
},
{
name: "empty and empty",
gs: GenesisState{
SendEnabled: []SendEnabled{},
Params: Params{
SendEnabled: []*SendEnabled{},
},
},
exp: []SendEnabled{},
},
{
name: "one and nil",
gs: GenesisState{
SendEnabled: []SendEnabled{{"onenilcoin", true}},
Params: Params{
SendEnabled: nil,
},
},
exp: []SendEnabled{{"onenilcoin", true}},
},
{
name: "one and empty",
gs: GenesisState{
SendEnabled: []SendEnabled{{"oneemptycoin", true}},
Params: Params{
SendEnabled: []*SendEnabled{},
},
},
exp: []SendEnabled{{"oneemptycoin", true}},
},
{
name: "nil and one",
gs: GenesisState{
SendEnabled: nil,
Params: Params{
SendEnabled: []*SendEnabled{{"nilonecoin", true}},
},
},
exp: []SendEnabled{{"nilonecoin", true}},
},
{
name: "empty and one",
gs: GenesisState{
SendEnabled: []SendEnabled{},
Params: Params{
SendEnabled: []*SendEnabled{{"emptyonecoin", true}},
},
},
exp: []SendEnabled{{"emptyonecoin", true}},
},
{
name: "one and one different denoms",
gs: GenesisState{
SendEnabled: []SendEnabled{{"oneonediff1coin", true}},
Params: Params{
SendEnabled: []*SendEnabled{{"oneonediff2coin", false}},
},
},
exp: []SendEnabled{{"oneonediff1coin", true}, {"oneonediff2coin", false}},
},
{
name: "one and one same denoms true",
gs: GenesisState{
SendEnabled: []SendEnabled{{"oneonesametruecoin", true}},
Params: Params{
SendEnabled: []*SendEnabled{{"oneonesametruecoin", false}},
},
},
exp: []SendEnabled{{"oneonesametruecoin", true}},
},
{
name: "one and one same denoms false",
gs: GenesisState{
SendEnabled: []SendEnabled{{"oneonesamefalsecoin", false}},
Params: Params{
SendEnabled: []*SendEnabled{{"oneonesamefalsecoin", true}},
},
},
exp: []SendEnabled{{"oneonesamefalsecoin", false}},
},
{
name: "three and three with one same denom",
gs: GenesisState{
SendEnabled: []SendEnabled{
{"threethree1coin", true},
{"threethree2coin", true},
{"threethree3coin", true},
},
Params: Params{
SendEnabled: []*SendEnabled{
{"threethree4coin", true},
{"threethree2coin", false},
{"threethree5coin", true},
},
},
},
exp: []SendEnabled{
{"threethree1coin", true},
{"threethree2coin", true},
{"threethree3coin", true},
{"threethree4coin", true},
{"threethree5coin", true},
},
},
{
name: "three and three all overlap",
gs: GenesisState{
SendEnabled: []SendEnabled{
{"threethreedup1coin", false},
{"threethreedup2coin", true},
{"threethreedup3coin", false},
},
Params: Params{
SendEnabled: []*SendEnabled{
{"threethreedup1coin", true},
{"threethreedup2coin", false},
{"threethreedup3coin", true},
},
},
},
exp: []SendEnabled{
{"threethreedup1coin", false},
{"threethreedup2coin", true},
{"threethreedup3coin", false},
},
},
{
name: "three and three no overlap",
gs: GenesisState{
SendEnabled: []SendEnabled{
{"threethreediff1coin", true},
{"threethreediff2coin", false},
{"threethreediff3coin", true},
},
Params: Params{
SendEnabled: []*SendEnabled{
{"threethreediff4coin", false},
{"threethreediff5coin", true},
{"threethreediff6coin", false},
},
},
},
exp: []SendEnabled{
{"threethreediff1coin", true},
{"threethreediff2coin", false},
{"threethreediff3coin", true},
{"threethreediff4coin", false},
{"threethreediff5coin", true},
{"threethreediff6coin", false},
},
},
{
name: "one and three with overlap",
gs: GenesisState{
SendEnabled: []SendEnabled{
{"onethreeover1coin", false},
},
Params: Params{
SendEnabled: []*SendEnabled{
{"onethreeover1coin", true},
{"onethreeover2coin", true},
{"onethreeover3coin", false},
},
},
},
exp: []SendEnabled{
{"onethreeover1coin", false},
{"onethreeover2coin", true},
{"onethreeover3coin", false},
},
},
}
for _, tc := range tests {
t.Run(tc.name, func(tt *testing.T) {
actual := tc.gs.GetAllSendEnabled()
assert.Equal(tt, tc.exp, actual)
})
}
}

View File

@ -29,6 +29,16 @@ var (
// BalancesPrefix is the prefix for the account balances store. We use a byte
// (instead of `[]byte("balances")` to save some disk space).
BalancesPrefix = []byte{0x02}
// SendEnabledPrefix is the prefix for the SendDisabled flags for a Denom.
SendEnabledPrefix = []byte{0x04}
)
const (
// TrueB is a byte with value 1 that represents true.
TrueB = byte(0x01)
// FalseB is a byte with value 0 that represents false.
FalseB = byte(0x00)
)
// AddressAndDenomFromBalancesStore returns an account address and denom from a balances prefix
@ -67,3 +77,24 @@ func CreateDenomAddressPrefix(denom string) []byte {
copy(key[len(DenomAddressPrefix):], denom)
return key
}
// CreateSendEnabledKey creates the key of the SendDisabled flag for a denom.
func CreateSendEnabledKey(denom string) []byte {
key := make([]byte, len(SendEnabledPrefix)+len(denom))
copy(key, SendEnabledPrefix)
copy(key[len(SendEnabledPrefix):], denom)
return key
}
// IsTrueB returns true if the provided byte slice has exactly one byte, and it is equal to TrueB.
func IsTrueB(bz []byte) bool {
return len(bz) == 1 && bz[0] == TrueB
}
// ToBoolB returns TrueB if v is true, and FalseB if it's false.
func ToBoolB(v bool) byte {
if v {
return TrueB
}
return FalseB
}

View File

@ -68,3 +68,66 @@ func TestCreateDenomAddressPrefix(t *testing.T) {
require.Len(key, len(types.DenomAddressPrefix)+4)
require.Equal(append(types.DenomAddressPrefix, 'a', 'b', 'c', 0), key)
}
func TestCreateSendEnabledKey(t *testing.T) {
denom := "bazcoin"
expected := cloneAppend(types.SendEnabledPrefix, []byte(denom))
actual := types.CreateSendEnabledKey(denom)
assert.Equal(t, expected, actual, "full byte slice")
assert.Equal(t, types.SendEnabledPrefix, actual[:len(types.SendEnabledPrefix)], "prefix")
assert.Equal(t, []byte(denom), actual[len(types.SendEnabledPrefix):], "denom part")
}
func TestIsTrueB(t *testing.T) {
tests := []struct {
name string
bz []byte
exp bool
}{
{
name: "empty bz",
bz: []byte{},
exp: false,
},
{
name: "nil bz",
bz: nil,
exp: false,
},
{
name: "one byte zero",
bz: []byte{0x00},
exp: false,
},
{
name: "one byte one",
bz: []byte{0x01},
exp: true,
},
{
name: "one byte two",
bz: []byte{0x02},
exp: false,
},
{
name: "two bytes one zero",
bz: []byte{0x01, 0x00},
exp: false,
},
}
for _, tc := range tests {
t.Run(tc.name, func(tt *testing.T) {
actual := types.IsTrueB(tc.bz)
assert.Equal(t, tc.exp, actual)
})
}
}
func TestToBoolB(t *testing.T) {
t.Run("true", func(t *testing.T) {
assert.Equal(t, types.TrueB, types.ToBoolB(true))
})
t.Run("false", func(t *testing.T) {
assert.Equal(t, types.FalseB, types.ToBoolB(false))
})
}

View File

@ -7,8 +7,9 @@ import (
// bank message types
const (
TypeMsgSend = "send"
TypeMsgMultiSend = "multisend"
TypeMsgSend = "send"
TypeMsgMultiSend = "multisend"
TypeMsgSetSendEnabled = "set-send-enabled"
)
var _ sdk.Msg = &MsgSend{}

View File

@ -6,7 +6,6 @@ import (
"github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/cosmos/cosmos-sdk/types"
)
func TestMsgSendRoute(t *testing.T) {
@ -223,7 +222,7 @@ func TestMsgMultiSendValidation(t *testing.T) {
{
true,
MsgMultiSend{
Inputs: []Input{NewInput(addr2, atom123.MulInt(types.NewInt(2)))},
Inputs: []Input{NewInput(addr2, atom123.MulInt(sdk.NewInt(2)))},
Outputs: []Output{output1, output1},
},
},

View File

@ -1,22 +1,23 @@
package types
import (
"errors"
"fmt"
"sigs.k8s.io/yaml"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)
const (
// DefaultSendEnabled enabled
DefaultSendEnabled = true
var (
// DefaultDefaultSendEnabled is the value that DefaultSendEnabled will have from DefaultParams().
DefaultDefaultSendEnabled = true
)
var (
// KeySendEnabled is store's key for SendEnabled Params
// Deprecated: Use the SendEnabled functionality in the keeper.
KeySendEnabled = []byte("SendEnabled")
// KeyDefaultSendEnabled is store's key for the DefaultSendEnabled option
KeyDefaultSendEnabled = []byte("DefaultSendEnabled")
@ -28,9 +29,9 @@ func ParamKeyTable() paramtypes.KeyTable {
}
// NewParams creates a new parameter configuration for the bank module
func NewParams(defaultSendEnabled bool, sendEnabledParams SendEnabledParams) Params {
func NewParams(defaultSendEnabled bool) Params {
return Params{
SendEnabled: sendEnabledParams,
SendEnabled: nil,
DefaultSendEnabled: defaultSendEnabled,
}
}
@ -38,47 +39,27 @@ func NewParams(defaultSendEnabled bool, sendEnabledParams SendEnabledParams) Par
// DefaultParams is the default parameter configuration for the bank module
func DefaultParams() Params {
return Params{
SendEnabled: SendEnabledParams{},
// The default send enabled value allows send transfers for all coin denoms
DefaultSendEnabled: true,
SendEnabled: nil,
DefaultSendEnabled: DefaultDefaultSendEnabled,
}
}
// Validate all bank module parameters
func (p Params) Validate() error {
if err := validateSendEnabledParams(p.SendEnabled); err != nil {
return err
if len(p.SendEnabled) > 0 {
return errors.New("use of send_enabled in params is no longer supported")
}
return validateIsBool(p.DefaultSendEnabled)
}
// String implements the Stringer interface.
func (p Params) String() string {
out, _ := yaml.Marshal(p)
return string(out)
}
// SendEnabledDenom returns true if the given denom is enabled for sending
func (p Params) SendEnabledDenom(denom string) bool {
for _, pse := range p.SendEnabled {
if pse.Denom == denom {
return pse.Enabled
}
sendEnabled, _ := yaml.Marshal(p.SendEnabled)
d := " "
if len(sendEnabled) > 0 && sendEnabled[0] == '-' {
d = "\n"
}
return p.DefaultSendEnabled
}
// SetSendEnabledParam returns an updated set of Parameters with the given denom
// send enabled flag set.
func (p Params) SetSendEnabledParam(denom string, sendEnabled bool) Params {
var sendParams SendEnabledParams
for _, p := range p.SendEnabled {
if p.Denom != denom {
sendParams = append(sendParams, NewSendEnabled(p.Denom, p.Enabled))
}
}
sendParams = append(sendParams, NewSendEnabled(denom, sendEnabled))
return NewParams(p.DefaultSendEnabled, sendParams)
return fmt.Sprintf("default_send_enabled: %t\nsend_enabled:%s%s", p.DefaultSendEnabled, d, sendEnabled)
}
// ParamSetPairs implements params.ParamSet
@ -89,9 +70,12 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
}
}
// SendEnabledParams is a collection of parameters indicating if a coin denom is enabled for sending
type SendEnabledParams []*SendEnabled
// Validate gets any errors with this SendEnabled entry.
func (se SendEnabled) Validate() error {
return sdk.ValidateDenom(se.Denom)
}
// validateSendEnabledParams is used by the x/params module to validate the params for the bank module.
func validateSendEnabledParams(i interface{}) error {
params, ok := i.([]*SendEnabled)
if !ok {
@ -120,29 +104,21 @@ func NewSendEnabled(denom string, sendEnabled bool) *SendEnabled {
}
}
// String implements stringer insterface
// String implements stringer interface
func (se SendEnabled) String() string {
bz, err := codec.ProtoMarshalJSON(&se, nil)
if err != nil {
panic(err)
}
out, err := yaml.JSONToYAML(bz)
if err != nil {
panic(err)
}
return string(out)
return fmt.Sprintf("denom: %s\nenabled: %t\n", se.Denom, se.Enabled)
}
// validateSendEnabled is used by the x/params module to validate a single SendEnabled entry.
func validateSendEnabled(i interface{}) error {
param, ok := i.(SendEnabled)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
return sdk.ValidateDenom(param.Denom)
return param.Validate()
}
// validateIsBool is used by the x/params module to validate that a thing is a bool.
func validateIsBool(i interface{}) error {
_, ok := i.(bool)
if !ok {

View File

@ -3,6 +3,7 @@ package types
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -48,67 +49,97 @@ func Test_sendParamEqual(t *testing.T) {
require.False(t, ok)
}
func Test_sendParamString(t *testing.T) {
paramString := "denom: foo\nenabled: false\n"
param := NewSendEnabled("foo", false)
func Test_SendEnabledString(t *testing.T) {
paramStringTrue := "denom: foo\nenabled: true\n"
paramTrue := NewSendEnabled("foo", true)
assert.Equal(t, paramStringTrue, paramTrue.String(), "true")
paramStringFalse := "denom: bar\nenabled: false\n"
paramFalse := NewSendEnabled("bar", false)
assert.Equal(t, paramStringFalse, paramFalse.String(), "false")
}
require.Equal(t, paramString, param.String())
func Test_ParamsString(t *testing.T) {
tests := []struct {
name string
params Params
expected string
}{
{
name: "default true empty send enabled",
params: Params{[]*SendEnabled{}, true},
expected: "default_send_enabled: true\nsend_enabled: []\n",
},
{
name: "default false empty send enabled",
params: Params{[]*SendEnabled{}, false},
expected: "default_send_enabled: false\nsend_enabled: []\n",
},
{
name: "default true one true send enabled",
params: Params{[]*SendEnabled{{"foocoin", true}}, true},
expected: "default_send_enabled: true\nsend_enabled:\n- denom: foocoin\n enabled: true\n",
},
{
name: "default true one false send enabled",
params: Params{[]*SendEnabled{{"barcoin", false}}, true},
expected: "default_send_enabled: true\nsend_enabled:\n- denom: barcoin\n",
},
}
for _, tc := range tests {
t.Run(tc.name, func(tt *testing.T) {
actual := tc.params.String()
assert.Equal(tt, tc.expected, actual)
})
}
}
func Test_validateParams(t *testing.T) {
params := DefaultParams()
// default params have no error
require.NoError(t, params.Validate())
// default case is all denoms are enabled for sending
require.True(t, params.SendEnabledDenom(sdk.DefaultBondDenom))
require.True(t, params.SendEnabledDenom("foodenom"))
params.DefaultSendEnabled = false
params = params.SetSendEnabledParam("foodenom", true)
require.NoError(t, validateSendEnabledParams(params.SendEnabled))
require.True(t, params.SendEnabledDenom("foodenom"))
require.False(t, params.SendEnabledDenom(sdk.DefaultBondDenom))
params.DefaultSendEnabled = true
params = params.SetSendEnabledParam("foodenom", false)
require.NoError(t, validateSendEnabledParams(params.SendEnabled))
require.False(t, params.SendEnabledDenom("foodenom"))
require.True(t, params.SendEnabledDenom(sdk.DefaultBondDenom))
params = params.SetSendEnabledParam("foodenom", true)
require.True(t, params.SendEnabledDenom("foodenom"))
params = params.SetSendEnabledParam("foodenom", false)
require.False(t, params.SendEnabledDenom("foodenom"))
require.True(t, params.SendEnabledDenom("foodenom2"))
params = params.SetSendEnabledParam("foodenom2", false)
require.True(t, params.SendEnabledDenom(""))
require.True(t, params.SendEnabledDenom(sdk.DefaultBondDenom))
require.False(t, params.SendEnabledDenom("foodenom2"))
paramYaml := "default_send_enabled: true\nsend_enabled:\n- denom: foodenom\n- denom: foodenom2\n"
require.Equal(t, paramYaml, params.String())
// Ensure proper format of yaml output when false
params.DefaultSendEnabled = false
paramYaml = "send_enabled:\n- denom: foodenom\n- denom: foodenom2\n"
require.Equal(t, paramYaml, params.String())
params = NewParams(true, SendEnabledParams{
NewSendEnabled("foodenom", false),
NewSendEnabled("foodenom", true), // this is not allowed
})
// fails due to duplicate entries.
require.Error(t, params.Validate())
// fails due to invalid type
require.Error(t, validateSendEnabledParams(NewSendEnabled("foodenom", true)))
require.Error(t, validateSendEnabledParams(SendEnabledParams{NewSendEnabled("INVALIDDENOM", true)}))
assert.NoError(t, DefaultParams().Validate(), "default")
assert.NoError(t, NewParams(true).Validate(), "true")
assert.NoError(t, NewParams(false).Validate(), "false")
assert.Error(t, Params{[]*SendEnabled{{"foocoing", false}}, true}.Validate(), "with SendEnabled entry")
}
func Test_validateSendEnabledParams(t *testing.T) {
tests := []struct {
name string
arg interface{}
exp string
}{
{
name: "ok",
arg: []*SendEnabled{},
exp: "",
},
{
name: "has entry",
arg: []*SendEnabled{{"foocoin", false}},
exp: "",
},
{
name: "not a slice",
arg: &SendEnabled{},
exp: "invalid parameter type: *types.SendEnabled",
},
{
name: "not a slice of refs",
arg: []SendEnabled{},
exp: "invalid parameter type: []types.SendEnabled",
},
{
name: "not a slice of send enabled",
arg: []*Params{},
exp: "invalid parameter type: []*types.Params",
},
}
for _, tc := range tests {
t.Run(tc.name, func(tt *testing.T) {
actual := validateSendEnabledParams(tc.arg)
if len(tc.exp) == 0 {
assert.NoError(tt, actual)
} else {
assert.EqualError(tt, actual, tc.exp)
}
})
}
}

View File

@ -960,6 +960,119 @@ func (m *QueryDenomOwnersResponse) GetPagination() *query.PageResponse {
return nil
}
// QuerySendEnabledRequest defines the RPC request for looking up SendEnabled entries.
//
// Since: cosmos-sdk 0.47
type QuerySendEnabledRequest struct {
// denoms is the specific denoms you want look up. Leave empty to get all entries.
Denoms []string `protobuf:"bytes,1,rep,name=denoms,proto3" json:"denoms,omitempty"`
// pagination defines an optional pagination for the request.
Pagination *query.PageRequest `protobuf:"bytes,99,opt,name=pagination,proto3" json:"pagination,omitempty"`
}
func (m *QuerySendEnabledRequest) Reset() { *m = QuerySendEnabledRequest{} }
func (m *QuerySendEnabledRequest) String() string { return proto.CompactTextString(m) }
func (*QuerySendEnabledRequest) ProtoMessage() {}
func (*QuerySendEnabledRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_9c6fc1939682df13, []int{19}
}
func (m *QuerySendEnabledRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *QuerySendEnabledRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_QuerySendEnabledRequest.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *QuerySendEnabledRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_QuerySendEnabledRequest.Merge(m, src)
}
func (m *QuerySendEnabledRequest) XXX_Size() int {
return m.Size()
}
func (m *QuerySendEnabledRequest) XXX_DiscardUnknown() {
xxx_messageInfo_QuerySendEnabledRequest.DiscardUnknown(m)
}
var xxx_messageInfo_QuerySendEnabledRequest proto.InternalMessageInfo
func (m *QuerySendEnabledRequest) GetDenoms() []string {
if m != nil {
return m.Denoms
}
return nil
}
func (m *QuerySendEnabledRequest) GetPagination() *query.PageRequest {
if m != nil {
return m.Pagination
}
return nil
}
// QuerySendEnabledResponse defines the RPC response of a SendEnable query.
//
// Since: cosmos-sdk 0.47
type QuerySendEnabledResponse struct {
SendEnabled []*SendEnabled `protobuf:"bytes,1,rep,name=send_enabled,json=sendEnabled,proto3" json:"send_enabled,omitempty"`
// pagination defines the pagination in the response.
Pagination *query.PageResponse `protobuf:"bytes,99,opt,name=pagination,proto3" json:"pagination,omitempty"`
}
func (m *QuerySendEnabledResponse) Reset() { *m = QuerySendEnabledResponse{} }
func (m *QuerySendEnabledResponse) String() string { return proto.CompactTextString(m) }
func (*QuerySendEnabledResponse) ProtoMessage() {}
func (*QuerySendEnabledResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_9c6fc1939682df13, []int{20}
}
func (m *QuerySendEnabledResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *QuerySendEnabledResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_QuerySendEnabledResponse.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *QuerySendEnabledResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_QuerySendEnabledResponse.Merge(m, src)
}
func (m *QuerySendEnabledResponse) XXX_Size() int {
return m.Size()
}
func (m *QuerySendEnabledResponse) XXX_DiscardUnknown() {
xxx_messageInfo_QuerySendEnabledResponse.DiscardUnknown(m)
}
var xxx_messageInfo_QuerySendEnabledResponse proto.InternalMessageInfo
func (m *QuerySendEnabledResponse) GetSendEnabled() []*SendEnabled {
if m != nil {
return m.SendEnabled
}
return nil
}
func (m *QuerySendEnabledResponse) GetPagination() *query.PageResponse {
if m != nil {
return m.Pagination
}
return nil
}
func init() {
proto.RegisterType((*QueryBalanceRequest)(nil), "cosmos.bank.v1beta1.QueryBalanceRequest")
proto.RegisterType((*QueryBalanceResponse)(nil), "cosmos.bank.v1beta1.QueryBalanceResponse")
@ -980,75 +1093,83 @@ func init() {
proto.RegisterType((*QueryDenomOwnersRequest)(nil), "cosmos.bank.v1beta1.QueryDenomOwnersRequest")
proto.RegisterType((*DenomOwner)(nil), "cosmos.bank.v1beta1.DenomOwner")
proto.RegisterType((*QueryDenomOwnersResponse)(nil), "cosmos.bank.v1beta1.QueryDenomOwnersResponse")
proto.RegisterType((*QuerySendEnabledRequest)(nil), "cosmos.bank.v1beta1.QuerySendEnabledRequest")
proto.RegisterType((*QuerySendEnabledResponse)(nil), "cosmos.bank.v1beta1.QuerySendEnabledResponse")
}
func init() { proto.RegisterFile("cosmos/bank/v1beta1/query.proto", fileDescriptor_9c6fc1939682df13) }
var fileDescriptor_9c6fc1939682df13 = []byte{
// 1008 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x57, 0xbf, 0x6f, 0x23, 0x45,
0x14, 0xf6, 0x04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 0xf5, 0x76, 0x45, 0x42, 0x7b,
0x86, 0x6e, 0xce, 0x86, 0x86, 0x53, 0x40, 0x6b, 0x58, 0xbb, 0x7e, 0x7a, 0x56, 0x22, 0xf7, 0xce,
0x4a, 0xe4, 0xb7, 0xb3, 0x12, 0xf9, 0xf8, 0xbc, 0x94, 0xbb, 0x77, 0x5e, 0xca, 0xfd, 0x7c, 0x5e,
0xca, 0xbd, 0xb9, 0x99, 0xfa, 0xa2, 0x7c, 0x4f, 0xc5, 0x96, 0x0f, 0xcb, 0x66, 0x5e, 0xfe, 0x9b,
0xbb, 0xfb, 0x67, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8d, 0xb5, 0x9c, 0x3a, 0xd9, 0x0f, 0x00, 0x00,
// 1102 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x58, 0xcf, 0x6f, 0xe3, 0xc4,
0x17, 0xcf, 0xf4, 0xfb, 0xdd, 0xb4, 0x7d, 0x29, 0x48, 0xcc, 0x06, 0x68, 0x5d, 0x9a, 0x2c, 0x5e,
0xb4, 0x6d, 0x96, 0xd6, 0x6e, 0x52, 0x24, 0x28, 0x17, 0xd4, 0x94, 0x1f, 0x07, 0x84, 0xb6, 0xa4,
0x9c, 0x90, 0x50, 0xe4, 0xc4, 0x43, 0x88, 0x9a, 0xd8, 0xd9, 0x8c, 0xc3, 0x12, 0x55, 0x2b, 0x21,
0x4e, 0xdc, 0x16, 0x09, 0x21, 0x21, 0x21, 0xc4, 0x72, 0x60, 0xf9, 0x71, 0x46, 0xe2, 0x5f, 0xe8,
0x81, 0xc3, 0x6a, 0xb9, 0x70, 0x02, 0xd4, 0x72, 0xe0, 0xcf, 0x40, 0x99, 0x79, 0x93, 0xd8, 0xc9,
0xc4, 0x35, 0x25, 0x48, 0x70, 0x6a, 0x3c, 0x7e, 0x3f, 0x3e, 0x9f, 0xcf, 0xbc, 0x99, 0xf7,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e1, 0x9b, 0xec, 0x6c, 0x71, 0xf8, 0x34, 0xbd, 0xc8, 0x2c, 0x08, 0x7c, 0x57,
0xe9, 0x93, 0xfa, 0xa3, 0x10, 0x6a, 0x53, 0xe5, 0xfd, 0x93, 0xd3, 0x1c, 0xb9, 0x7f, 0x9a, 0x23,
0xbf, 0x9d, 0xe6, 0xc8, 0x47, 0x67, 0xb9, 0xd4, 0xfd, 0xb3, 0x5c, 0xea, 0xe7, 0xb3, 0x5c, 0xea,
0xcd, 0x42, 0xec, 0xf7, 0xc0, 0x7b, 0x32, 0xa6, 0xf8, 0x2c, 0xa8, 0xa5, 0xc5, 0x3f, 0x29, 0x76,
0xfe, 0x0c, 0x00, 0x00, 0xff, 0xff, 0x83, 0xa6, 0x47, 0x80, 0x97, 0x11, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
@ -1088,6 +1209,14 @@ type QueryClient interface {
//
// Since: cosmos-sdk 0.46
DenomOwners(ctx context.Context, in *QueryDenomOwnersRequest, opts ...grpc.CallOption) (*QueryDenomOwnersResponse, error)
// SendEnabled queries for SendEnabled entries.
//
// This query only returns denominations that have specific SendEnabled settings.
// Any denomination that does not have a specific setting will use the default
// params.default_send_enabled, and will not be returned by this query.
//
// Since: cosmos-sdk 0.47
SendEnabled(ctx context.Context, in *QuerySendEnabledRequest, opts ...grpc.CallOption) (*QuerySendEnabledResponse, error)
}
type queryClient struct {
@ -1179,6 +1308,15 @@ func (c *queryClient) DenomOwners(ctx context.Context, in *QueryDenomOwnersReque
return out, nil
}
func (c *queryClient) SendEnabled(ctx context.Context, in *QuerySendEnabledRequest, opts ...grpc.CallOption) (*QuerySendEnabledResponse, error) {
out := new(QuerySendEnabledResponse)
err := c.cc.Invoke(ctx, "/cosmos.bank.v1beta1.Query/SendEnabled", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// QueryServer is the server API for Query service.
type QueryServer interface {
// Balance queries the balance of a single coin for a single account.
@ -1206,6 +1344,14 @@ type QueryServer interface {
//
// Since: cosmos-sdk 0.46
DenomOwners(context.Context, *QueryDenomOwnersRequest) (*QueryDenomOwnersResponse, error)
// SendEnabled queries for SendEnabled entries.
//
// This query only returns denominations that have specific SendEnabled settings.
// Any denomination that does not have a specific setting will use the default
// params.default_send_enabled, and will not be returned by this query.
//
// Since: cosmos-sdk 0.47
SendEnabled(context.Context, *QuerySendEnabledRequest) (*QuerySendEnabledResponse, error)
}
// UnimplementedQueryServer can be embedded to have forward compatible implementations.
@ -1239,6 +1385,9 @@ func (*UnimplementedQueryServer) DenomsMetadata(ctx context.Context, req *QueryD
func (*UnimplementedQueryServer) DenomOwners(ctx context.Context, req *QueryDenomOwnersRequest) (*QueryDenomOwnersResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method DenomOwners not implemented")
}
func (*UnimplementedQueryServer) SendEnabled(ctx context.Context, req *QuerySendEnabledRequest) (*QuerySendEnabledResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method SendEnabled not implemented")
}
func RegisterQueryServer(s grpc1.Server, srv QueryServer) {
s.RegisterService(&_Query_serviceDesc, srv)
@ -1406,6 +1555,24 @@ func _Query_DenomOwners_Handler(srv interface{}, ctx context.Context, dec func(i
return interceptor(ctx, in, info, handler)
}
func _Query_SendEnabled_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(QuerySendEnabledRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QueryServer).SendEnabled(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cosmos.bank.v1beta1.Query/SendEnabled",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QueryServer).SendEnabled(ctx, req.(*QuerySendEnabledRequest))
}
return interceptor(ctx, in, info, handler)
}
var _Query_serviceDesc = grpc.ServiceDesc{
ServiceName: "cosmos.bank.v1beta1.Query",
HandlerType: (*QueryServer)(nil),
@ -1446,6 +1613,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{
MethodName: "DenomOwners",
Handler: _Query_DenomOwners_Handler,
},
{
MethodName: "SendEnabled",
Handler: _Query_SendEnabled_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "cosmos/bank/v1beta1/query.proto",
@ -2186,6 +2357,103 @@ func (m *QueryDenomOwnersResponse) MarshalToSizedBuffer(dAtA []byte) (int, error
return len(dAtA) - i, nil
}
func (m *QuerySendEnabledRequest) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *QuerySendEnabledRequest) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *QuerySendEnabledRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if m.Pagination != nil {
{
size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintQuery(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x6
i--
dAtA[i] = 0x9a
}
if len(m.Denoms) > 0 {
for iNdEx := len(m.Denoms) - 1; iNdEx >= 0; iNdEx-- {
i -= len(m.Denoms[iNdEx])
copy(dAtA[i:], m.Denoms[iNdEx])
i = encodeVarintQuery(dAtA, i, uint64(len(m.Denoms[iNdEx])))
i--
dAtA[i] = 0xa
}
}
return len(dAtA) - i, nil
}
func (m *QuerySendEnabledResponse) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *QuerySendEnabledResponse) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *QuerySendEnabledResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if m.Pagination != nil {
{
size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintQuery(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x6
i--
dAtA[i] = 0x9a
}
if len(m.SendEnabled) > 0 {
for iNdEx := len(m.SendEnabled) - 1; iNdEx >= 0; iNdEx-- {
{
size, err := m.SendEnabled[iNdEx].MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintQuery(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0xa
}
}
return len(dAtA) - i, nil
}
func encodeVarintQuery(dAtA []byte, offset int, v uint64) int {
offset -= sovQuery(v)
base := offset
@ -2482,6 +2750,44 @@ func (m *QueryDenomOwnersResponse) Size() (n int) {
return n
}
func (m *QuerySendEnabledRequest) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if len(m.Denoms) > 0 {
for _, s := range m.Denoms {
l = len(s)
n += 1 + l + sovQuery(uint64(l))
}
}
if m.Pagination != nil {
l = m.Pagination.Size()
n += 2 + l + sovQuery(uint64(l))
}
return n
}
func (m *QuerySendEnabledResponse) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if len(m.SendEnabled) > 0 {
for _, e := range m.SendEnabled {
l = e.Size()
n += 1 + l + sovQuery(uint64(l))
}
}
if m.Pagination != nil {
l = m.Pagination.Size()
n += 2 + l + sovQuery(uint64(l))
}
return n
}
func sovQuery(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
}
@ -4392,6 +4698,244 @@ func (m *QueryDenomOwnersResponse) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *QuerySendEnabledRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowQuery
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: QuerySendEnabledRequest: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: QuerySendEnabledRequest: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Denoms", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowQuery
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthQuery
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthQuery
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Denoms = append(m.Denoms, string(dAtA[iNdEx:postIndex]))
iNdEx = postIndex
case 99:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowQuery
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthQuery
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthQuery
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Pagination == nil {
m.Pagination = &query.PageRequest{}
}
if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipQuery(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthQuery
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *QuerySendEnabledResponse) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowQuery
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: QuerySendEnabledResponse: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: QuerySendEnabledResponse: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field SendEnabled", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowQuery
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthQuery
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthQuery
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.SendEnabled = append(m.SendEnabled, &SendEnabled{})
if err := m.SendEnabled[len(m.SendEnabled)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 99:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowQuery
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthQuery
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthQuery
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Pagination == nil {
m.Pagination = &query.PageResponse{}
}
if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipQuery(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthQuery
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipQuery(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0

View File

@ -501,6 +501,42 @@ func local_request_Query_DenomOwners_0(ctx context.Context, marshaler runtime.Ma
}
var (
filter_Query_SendEnabled_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
)
func request_Query_SendEnabled_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QuerySendEnabledRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_SendEnabled_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.SendEnabled(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_SendEnabled_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QuerySendEnabledRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_SendEnabled_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.SendEnabled(ctx, &protoReq)
return msg, metadata, err
}
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
// UnaryRPC :call QueryServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
@ -714,6 +750,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
})
mux.Handle("GET", pattern_Query_SendEnabled_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Query_SendEnabled_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_SendEnabled_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
@ -935,6 +994,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
})
mux.Handle("GET", pattern_Query_SendEnabled_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Query_SendEnabled_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_SendEnabled_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
@ -956,6 +1035,8 @@ var (
pattern_Query_DenomsMetadata_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "bank", "v1beta1", "denoms_metadata"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_Query_DenomOwners_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "bank", "v1beta1", "denom_owners", "denom"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_Query_SendEnabled_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "bank", "v1beta1", "send_enabled"}, "", runtime.AssumeColonVerbOpt(false)))
)
var (
@ -976,4 +1057,6 @@ var (
forward_Query_DenomsMetadata_0 = runtime.ForwardResponseMessage
forward_Query_DenomOwners_0 = runtime.ForwardResponseMessage
forward_Query_SendEnabled_0 = runtime.ForwardResponseMessage
)

View File

@ -16,6 +16,7 @@ import (
"github.com/cosmos/cosmos-sdk/version"
v043 "github.com/cosmos/cosmos-sdk/x/genutil/migrations/v043"
v046 "github.com/cosmos/cosmos-sdk/x/genutil/migrations/v046"
v047 "github.com/cosmos/cosmos-sdk/x/genutil/migrations/v047"
"github.com/cosmos/cosmos-sdk/x/genutil/types"
)
@ -27,6 +28,7 @@ const flagGenesisTime = "genesis-time"
var migrationMap = types.MigrationMap{
"v0.43": v043.Migrate, // NOTE: v0.43, v0.44 and v0.45 are genesis compatible.
"v0.46": v046.Migrate,
"v0.47": v047.Migrate,
}
// GetMigrationCallback returns a MigrationCallback for a given version.

View File

@ -0,0 +1,21 @@
package v047
import (
"github.com/cosmos/cosmos-sdk/client"
bankv047 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v047"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/genutil/types"
)
// Migrate migrates exported state from v0.46 to a v0.47 genesis state.
func Migrate(appState types.AppMap, clientCtx client.Context) types.AppMap {
// Migrate x/bank.
bankState := appState[banktypes.ModuleName]
if len(bankState) > 0 {
var oldBankState *banktypes.GenesisState
clientCtx.Codec.MustUnmarshalJSON(bankState, oldBankState)
newBankState := bankv047.MigrateGenState(oldBankState)
appState[banktypes.ModuleName] = clientCtx.Codec.MustMarshalJSON(newBankState)
}
return appState
}