feat!: change Coin storage model (#9832)
<!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## Description Closes: #9361 <!-- Add a description of the changes that this PR introduces and the files that are the most critical to review. --> --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [x] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
This commit is contained in:
@@ -171,7 +171,7 @@ func (s *paginationTestSuite) TestReverseFilteredPaginations() {
|
||||
}
|
||||
|
||||
func ExampleFilteredPaginate() {
|
||||
app, ctx, appCodec := setupTest()
|
||||
app, ctx, _ := setupTest()
|
||||
|
||||
var balances sdk.Coins
|
||||
for i := 0; i < numBalances; i++ {
|
||||
@@ -200,16 +200,16 @@ func ExampleFilteredPaginate() {
|
||||
|
||||
var balResult sdk.Coins
|
||||
pageRes, err := query.FilteredPaginate(accountStore, pageReq, func(key []byte, value []byte, accumulate bool) (bool, error) {
|
||||
var bal sdk.Coin
|
||||
err := appCodec.Unmarshal(value, &bal)
|
||||
var amount sdk.Int
|
||||
err := amount.Unmarshal(value)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
// filter balances with amount greater than 100
|
||||
if bal.Amount.Int64() > int64(100) {
|
||||
// filter amount greater than 100
|
||||
if amount.Int64() > int64(100) {
|
||||
if accumulate {
|
||||
balResult = append(balResult, bal)
|
||||
balResult = append(balResult, sdk.NewCoin(string(key), amount))
|
||||
}
|
||||
|
||||
return true, nil
|
||||
@@ -232,16 +232,16 @@ func execFilterPaginate(store sdk.KVStore, pageReq *query.PageRequest, appCodec
|
||||
|
||||
var balResult sdk.Coins
|
||||
res, err = query.FilteredPaginate(accountStore, pageReq, func(key []byte, value []byte, accumulate bool) (bool, error) {
|
||||
var bal sdk.Coin
|
||||
err := appCodec.Unmarshal(value, &bal)
|
||||
var amount sdk.Int
|
||||
err := amount.Unmarshal(value)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
// filter balances with amount greater than 100
|
||||
if bal.Amount.Int64() > int64(100) {
|
||||
// filter amount greater than 100
|
||||
if amount.Int64() > int64(100) {
|
||||
if accumulate {
|
||||
balResult = append(balResult, bal)
|
||||
balResult = append(balResult, sdk.NewCoin(string(key), amount))
|
||||
}
|
||||
|
||||
return true, nil
|
||||
|
||||
@@ -319,12 +319,12 @@ func ExamplePaginate() {
|
||||
balancesStore := prefix.NewStore(authStore, types.BalancesPrefix)
|
||||
accountStore := prefix.NewStore(balancesStore, address.MustLengthPrefix(addr1))
|
||||
pageRes, err := query.Paginate(accountStore, request.Pagination, func(key []byte, value []byte) error {
|
||||
var tempRes sdk.Coin
|
||||
err := app.AppCodec().Unmarshal(value, &tempRes)
|
||||
var amount sdk.Int
|
||||
err := amount.Unmarshal(value)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
balResult = append(balResult, tempRes)
|
||||
balResult = append(balResult, sdk.NewCoin(string(key), amount))
|
||||
return nil
|
||||
})
|
||||
if err != nil { // should return no error
|
||||
|
||||
Reference in New Issue
Block a user