parent
8bbeba5b46
commit
cf17549e41
|
@ -37,6 +37,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
|
||||||
|
* (x/feegrant) [\#11813](https://github.com/cosmos/cosmos-sdk/pull/11813) Fix pagination total count in `AllowancesByGranter` query.
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
* [#11796](https://github.com/cosmos/cosmos-sdk/pull/11796) Handle EOF error case in `readLineFromBuf`, which allows successful reading of passphrases from STDIN.
|
* [#11796](https://github.com/cosmos/cosmos-sdk/pull/11796) Handle EOF error case in `readLineFromBuf`, which allows successful reading of passphrases from STDIN.
|
||||||
|
|
|
@ -110,20 +110,23 @@ func (q Keeper) AllowancesByGranter(c context.Context, req *feegrant.QueryAllowa
|
||||||
var grants []*feegrant.Grant
|
var grants []*feegrant.Grant
|
||||||
|
|
||||||
store := ctx.KVStore(q.storeKey)
|
store := ctx.KVStore(q.storeKey)
|
||||||
pageRes, err := query.Paginate(store, req.Pagination, func(key []byte, value []byte) error {
|
prefixStore := prefix.NewStore(store, feegrant.FeeAllowanceKeyPrefix)
|
||||||
var grant feegrant.Grant
|
pageRes, err := query.FilteredPaginate(prefixStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) {
|
||||||
|
// ParseAddressesFromFeeAllowanceKey expects the full key including the prefix.
|
||||||
granter, _ := feegrant.ParseAddressesFromFeeAllowanceKey(key)
|
granter, _ := feegrant.ParseAddressesFromFeeAllowanceKey(append(feegrant.FeeAllowanceKeyPrefix, key...))
|
||||||
if !granter.Equals(granterAddr) {
|
if !granter.Equals(granterAddr) {
|
||||||
return nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := q.cdc.Unmarshal(value, &grant); err != nil {
|
if accumulate {
|
||||||
return err
|
var grant feegrant.Grant
|
||||||
|
if err := q.cdc.Unmarshal(value, &grant); err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
grants = append(grants, &grant)
|
||||||
}
|
}
|
||||||
|
|
||||||
grants = append(grants, &grant)
|
return true, nil
|
||||||
return nil
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -59,7 +59,7 @@ func (suite *KeeperTestSuite) TestFeeAllowance() {
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
func() {
|
func() {
|
||||||
grantFeeAllowance(suite)
|
suite.grantFeeAllowance(suite.addrs[0], suite.addrs[1])
|
||||||
},
|
},
|
||||||
func(response *feegrant.QueryAllowanceResponse) {
|
func(response *feegrant.QueryAllowanceResponse) {
|
||||||
suite.Require().Equal(response.Allowance.Granter, suite.addrs[0].String())
|
suite.Require().Equal(response.Allowance.Granter, suite.addrs[0].String())
|
||||||
|
@ -124,7 +124,7 @@ func (suite *KeeperTestSuite) TestFeeAllowances() {
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
func() {
|
func() {
|
||||||
grantFeeAllowance(suite)
|
suite.grantFeeAllowance(suite.addrs[0], suite.addrs[1])
|
||||||
},
|
},
|
||||||
func(resp *feegrant.QueryAllowancesResponse) {
|
func(resp *feegrant.QueryAllowancesResponse) {
|
||||||
suite.Require().Equal(len(resp.Allowances), 1)
|
suite.Require().Equal(len(resp.Allowances), 1)
|
||||||
|
@ -190,7 +190,7 @@ func (suite *KeeperTestSuite) TestFeeAllowancesByGranter() {
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
func() {
|
func() {
|
||||||
grantFeeAllowance(suite)
|
suite.grantFeeAllowance(suite.addrs[0], suite.addrs[1])
|
||||||
},
|
},
|
||||||
func(resp *feegrant.QueryAllowancesByGranterResponse) {
|
func(resp *feegrant.QueryAllowancesByGranterResponse) {
|
||||||
suite.Require().Equal(len(resp.Allowances), 1)
|
suite.Require().Equal(len(resp.Allowances), 1)
|
||||||
|
@ -214,9 +214,9 @@ func (suite *KeeperTestSuite) TestFeeAllowancesByGranter() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func grantFeeAllowance(suite *KeeperTestSuite) {
|
func (suite *KeeperTestSuite) grantFeeAllowance(granter, grantee sdk.AccAddress) {
|
||||||
exp := suite.sdkCtx.BlockTime().AddDate(1, 0, 0)
|
exp := suite.sdkCtx.BlockTime().AddDate(1, 0, 0)
|
||||||
err := suite.app.FeeGrantKeeper.GrantAllowance(suite.sdkCtx, suite.addrs[0], suite.addrs[1], &feegrant.BasicAllowance{
|
err := suite.app.FeeGrantKeeper.GrantAllowance(suite.sdkCtx, granter, grantee, &feegrant.BasicAllowance{
|
||||||
SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 555)),
|
SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 555)),
|
||||||
Expiration: &exp,
|
Expiration: &exp,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue