refactor: remove collections.ErrInvalidIterator when unecessary (#17364)
This commit is contained in:
parent
66d9be0e10
commit
77be10bd95
@ -2,13 +2,11 @@ package simapp
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
|
||||
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
||||
@ -243,7 +241,7 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
|
||||
}
|
||||
return false, nil
|
||||
})
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,6 @@ go 1.20
|
||||
require (
|
||||
cosmossdk.io/api v0.7.0
|
||||
cosmossdk.io/client/v2 v2.0.0-20230630094428-02b760776860
|
||||
cosmossdk.io/collections v0.3.1-0.20230808102719-f04fefdc7a68
|
||||
cosmossdk.io/core v0.9.0
|
||||
cosmossdk.io/depinject v1.0.0-alpha.4
|
||||
cosmossdk.io/log v1.2.0
|
||||
@ -38,6 +37,7 @@ require (
|
||||
cloud.google.com/go/compute/metadata v0.2.3 // indirect
|
||||
cloud.google.com/go/iam v1.1.1 // indirect
|
||||
cloud.google.com/go/storage v1.31.0 // indirect
|
||||
cosmossdk.io/collections v0.3.1-0.20230808102719-f04fefdc7a68 // indirect
|
||||
cosmossdk.io/errors v1.0.0 // indirect
|
||||
filippo.io/edwards25519 v1.0.0 // indirect
|
||||
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
|
||||
|
||||
@ -2,7 +2,6 @@ package keeper_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
@ -176,7 +175,7 @@ func updateValidatorDelegations(f *fixture, existingValAddr, newValAddr sdk.ValA
|
||||
|
||||
return false, nil
|
||||
})
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,10 +2,8 @@ package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
"cosmossdk.io/core/store"
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
"cosmossdk.io/log"
|
||||
@ -258,7 +256,7 @@ func (k BaseKeeper) IterateAllDenomMetaData(ctx context.Context, cb func(types.M
|
||||
err := k.BaseViewKeeper.DenomMetadata.Walk(ctx, nil, func(_ string, metadata types.Metadata) (stop bool, err error) {
|
||||
return cb(metadata), nil
|
||||
})
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
@ -479,7 +477,7 @@ func (k BaseViewKeeper) IterateTotalSupply(ctx context.Context, cb func(sdk.Coin
|
||||
err := k.Supply.Walk(ctx, nil, func(s string, m math.Int) (bool, error) {
|
||||
return cb(sdk.NewCoin(s, m)), nil
|
||||
})
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -372,7 +372,7 @@ func (k BaseSendKeeper) IterateSendEnabledEntries(ctx context.Context, cb func(d
|
||||
err := k.SendEnabled.Walk(ctx, nil, func(key string, value bool) (stop bool, err error) {
|
||||
return cb(key, value), nil
|
||||
})
|
||||
if err != nil && !errorsmod.IsOf(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,8 +4,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/cockroachdb/errors"
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
"cosmossdk.io/collections/indexes"
|
||||
"cosmossdk.io/core/store"
|
||||
@ -158,7 +156,7 @@ func (k BaseViewKeeper) IterateAccountBalances(ctx context.Context, addr sdk.Acc
|
||||
err := k.Balances.Walk(ctx, collections.NewPrefixedPairRange[sdk.AccAddress, string](addr), func(key collections.Pair[sdk.AccAddress, string], value math.Int) (stop bool, err error) {
|
||||
return cb(sdk.NewCoin(key.K2(), value)), nil
|
||||
})
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
@ -170,7 +168,7 @@ func (k BaseViewKeeper) IterateAllBalances(ctx context.Context, cb func(sdk.AccA
|
||||
err := k.Balances.Walk(ctx, nil, func(key collections.Pair[sdk.AccAddress, string], value math.Int) (stop bool, err error) {
|
||||
return cb(key.K1(), sdk.NewCoin(key.K2(), value)), nil
|
||||
})
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ go 1.20
|
||||
|
||||
require (
|
||||
cosmossdk.io/api v0.7.0
|
||||
cosmossdk.io/collections v0.3.0
|
||||
cosmossdk.io/collections v0.3.1-0.20230808102719-f04fefdc7a68
|
||||
cosmossdk.io/core v0.9.0
|
||||
cosmossdk.io/depinject v1.0.0-alpha.4
|
||||
cosmossdk.io/errors v1.0.0
|
||||
|
||||
@ -37,8 +37,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
|
||||
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
|
||||
cosmossdk.io/api v0.7.0 h1:QsEMIWuv9xWDbF2HZnW4Lpu1/SejCztPu0LQx7t6MN4=
|
||||
cosmossdk.io/api v0.7.0/go.mod h1:kJFAEMLN57y0viszHDPLMmieF0471o5QAwwApa+270M=
|
||||
cosmossdk.io/collections v0.3.0 h1:v0eEqLBxebAV+t+Ahwf9tSJOu95HVLINwROXx2TTZ08=
|
||||
cosmossdk.io/collections v0.3.0/go.mod h1:CHE1+niUElL9ikCpevRZcp0yqQ4TU0TrEEGirN0mvIg=
|
||||
cosmossdk.io/collections v0.3.1-0.20230808102719-f04fefdc7a68 h1:aFHpJtJgdqBH8kRvD86Rl92rvd1+JFpaUpj+5NZNodg=
|
||||
cosmossdk.io/collections v0.3.1-0.20230808102719-f04fefdc7a68/go.mod h1:OK08xZu8fxXLoQcFIfkBDayo2aRokLfC3vVcXX0MB8E=
|
||||
cosmossdk.io/core v0.9.0 h1:30ScAOHDIUOCg1DKAwqkho9wuQJnu7GUrMcg0XLioic=
|
||||
cosmossdk.io/core v0.9.0/go.mod h1:NFgl5r41Q36+RixTvyrfsS6qQ65agCbZ1FTpnN7/G1Y=
|
||||
cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc=
|
||||
|
||||
@ -3,8 +3,6 @@ package keeper
|
||||
import (
|
||||
context "context"
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
"cosmossdk.io/x/circuit/types"
|
||||
)
|
||||
|
||||
@ -27,7 +25,7 @@ func (k *Keeper) ExportGenesis(ctx context.Context) (data *types.GenesisState) {
|
||||
})
|
||||
return false, nil
|
||||
})
|
||||
if err != nil && !errorsmod.IsOf(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@ -35,7 +33,7 @@ func (k *Keeper) ExportGenesis(ctx context.Context) (data *types.GenesisState) {
|
||||
disabledMsgs = append(disabledMsgs, msgUrl)
|
||||
return false, nil
|
||||
})
|
||||
if err != nil && !errorsmod.IsOf(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
|
||||
@ -3,8 +3,6 @@ package keeper
|
||||
import (
|
||||
"context"
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
"cosmossdk.io/x/circuit/types"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
@ -72,7 +70,7 @@ func (qs QueryServer) DisabledList(ctx context.Context, req *types.QueryDisabled
|
||||
msgs = append(msgs, msgUrl)
|
||||
return false, nil
|
||||
})
|
||||
if err != nil && !errorsmod.IsOf(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
@ -118,8 +117,7 @@ func getValHistoricalReferenceCount(k keeper.Keeper, ctx sdk.Context) int {
|
||||
return false, nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
@ -166,7 +165,7 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
|
||||
})
|
||||
return false, nil
|
||||
})
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@ -185,7 +184,7 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
|
||||
return false, nil
|
||||
},
|
||||
)
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@ -197,7 +196,7 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
|
||||
})
|
||||
return false, nil
|
||||
})
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@ -212,7 +211,7 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
|
||||
return false, nil
|
||||
},
|
||||
)
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@ -226,7 +225,7 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
|
||||
return false, nil
|
||||
},
|
||||
)
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@ -239,7 +238,7 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
|
||||
})
|
||||
return false, nil
|
||||
})
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@ -258,7 +257,7 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
@ -57,7 +56,7 @@ func NonNegativeOutstandingInvariant(k Keeper) sdk.Invariant {
|
||||
}
|
||||
return false, nil
|
||||
})
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
return sdk.FormatInvariant(types.ModuleName, "nonnegative outstanding", err.Error()), true
|
||||
}
|
||||
broken := count != 0
|
||||
@ -152,7 +151,7 @@ func ReferenceCountInvariant(k Keeper) sdk.Invariant {
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@ -167,7 +166,7 @@ func ReferenceCountInvariant(k Keeper) sdk.Invariant {
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@ -189,7 +188,7 @@ func ModuleAccountInvariant(k Keeper) sdk.Invariant {
|
||||
expectedCoins = expectedCoins.Add(rewards.Rewards...)
|
||||
return false, nil
|
||||
})
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
return sdk.FormatInvariant(types.ModuleName, "module account coins", err.Error()), true
|
||||
}
|
||||
|
||||
|
||||
@ -257,7 +257,7 @@ func (k Keeper) GetTotalRewards(ctx context.Context) (totalRewards sdk.DecCoins)
|
||||
return false, nil
|
||||
},
|
||||
)
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
|
||||
@ -35,8 +35,7 @@ func (k Keeper) IterateValidatorSlashEventsBetween(ctx context.Context, val sdk.
|
||||
}
|
||||
return false, nil
|
||||
})
|
||||
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@ -1,10 +1,8 @@
|
||||
package evidence
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
"cosmossdk.io/x/evidence/exported"
|
||||
"cosmossdk.io/x/evidence/keeper"
|
||||
"cosmossdk.io/x/evidence/types"
|
||||
@ -46,7 +44,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
|
||||
gs.Evidence = append(gs.Evidence, anyEvi)
|
||||
return false, nil
|
||||
})
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return gs
|
||||
|
||||
@ -9,7 +9,6 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/x/evidence"
|
||||
@ -96,7 +95,7 @@ func (suite *GenesisTestSuite) TestInitGenesis() {
|
||||
false,
|
||||
func() {
|
||||
_, err := suite.keeper.Evidences.Iterate(suite.ctx, nil)
|
||||
suite.Require().ErrorIs(err, collections.ErrInvalidIterator)
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ go 1.20
|
||||
|
||||
require (
|
||||
cosmossdk.io/api v0.7.0
|
||||
cosmossdk.io/collections v0.3.0
|
||||
cosmossdk.io/collections v0.3.1-0.20230808102719-f04fefdc7a68
|
||||
cosmossdk.io/core v0.9.0
|
||||
cosmossdk.io/depinject v1.0.0-alpha.4
|
||||
cosmossdk.io/errors v1.0.0
|
||||
|
||||
@ -37,8 +37,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
|
||||
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
|
||||
cosmossdk.io/api v0.7.0 h1:QsEMIWuv9xWDbF2HZnW4Lpu1/SejCztPu0LQx7t6MN4=
|
||||
cosmossdk.io/api v0.7.0/go.mod h1:kJFAEMLN57y0viszHDPLMmieF0471o5QAwwApa+270M=
|
||||
cosmossdk.io/collections v0.3.0 h1:v0eEqLBxebAV+t+Ahwf9tSJOu95HVLINwROXx2TTZ08=
|
||||
cosmossdk.io/collections v0.3.0/go.mod h1:CHE1+niUElL9ikCpevRZcp0yqQ4TU0TrEEGirN0mvIg=
|
||||
cosmossdk.io/collections v0.3.1-0.20230808102719-f04fefdc7a68 h1:aFHpJtJgdqBH8kRvD86Rl92rvd1+JFpaUpj+5NZNodg=
|
||||
cosmossdk.io/collections v0.3.1-0.20230808102719-f04fefdc7a68/go.mod h1:OK08xZu8fxXLoQcFIfkBDayo2aRokLfC3vVcXX0MB8E=
|
||||
cosmossdk.io/core v0.9.0 h1:30ScAOHDIUOCg1DKAwqkho9wuQJnu7GUrMcg0XLioic=
|
||||
cosmossdk.io/core v0.9.0/go.mod h1:NFgl5r41Q36+RixTvyrfsS6qQ65agCbZ1FTpnN7/G1Y=
|
||||
cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc=
|
||||
|
||||
@ -4,7 +4,7 @@ go 1.20
|
||||
|
||||
require (
|
||||
cosmossdk.io/api v0.7.0
|
||||
cosmossdk.io/collections v0.3.1-0.20230727092431-f0f777fa3cb7
|
||||
cosmossdk.io/collections v0.3.1-0.20230808102719-f04fefdc7a68
|
||||
cosmossdk.io/core v0.9.0
|
||||
cosmossdk.io/depinject v1.0.0-alpha.4
|
||||
cosmossdk.io/errors v1.0.0
|
||||
|
||||
@ -37,8 +37,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
|
||||
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
|
||||
cosmossdk.io/api v0.7.0 h1:QsEMIWuv9xWDbF2HZnW4Lpu1/SejCztPu0LQx7t6MN4=
|
||||
cosmossdk.io/api v0.7.0/go.mod h1:kJFAEMLN57y0viszHDPLMmieF0471o5QAwwApa+270M=
|
||||
cosmossdk.io/collections v0.3.1-0.20230727092431-f0f777fa3cb7 h1:4XhcAIVBXPwCFTT9abOzZZaEadbRaVws8A6UTr2KGIE=
|
||||
cosmossdk.io/collections v0.3.1-0.20230727092431-f0f777fa3cb7/go.mod h1:+KJND4gZHilxE3meopEl/Uet6IAw3PyiSbgeOrFzAZE=
|
||||
cosmossdk.io/collections v0.3.1-0.20230808102719-f04fefdc7a68 h1:aFHpJtJgdqBH8kRvD86Rl92rvd1+JFpaUpj+5NZNodg=
|
||||
cosmossdk.io/collections v0.3.1-0.20230808102719-f04fefdc7a68/go.mod h1:OK08xZu8fxXLoQcFIfkBDayo2aRokLfC3vVcXX0MB8E=
|
||||
cosmossdk.io/core v0.9.0 h1:30ScAOHDIUOCg1DKAwqkho9wuQJnu7GUrMcg0XLioic=
|
||||
cosmossdk.io/core v0.9.0/go.mod h1:NFgl5r41Q36+RixTvyrfsS6qQ65agCbZ1FTpnN7/G1Y=
|
||||
cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc=
|
||||
|
||||
@ -2,7 +2,6 @@ package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
@ -208,8 +207,7 @@ func (k Keeper) IterateAllFeeAllowances(ctx context.Context, cb func(grant feegr
|
||||
err := k.FeeAllowance.Walk(ctx, nil, func(key collections.Pair[sdk.AccAddress, sdk.AccAddress], grant feegrant.Grant) (stop bool, err error) {
|
||||
return cb(grant), nil
|
||||
})
|
||||
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -315,8 +313,7 @@ func (k Keeper) RemoveExpiredAllowances(ctx context.Context) error {
|
||||
|
||||
return false, nil
|
||||
})
|
||||
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package gov
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
@ -68,7 +67,7 @@ func EndBlocker(ctx sdk.Context, keeper *keeper.Keeper) error {
|
||||
|
||||
return false, nil
|
||||
})
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -219,7 +218,7 @@ func EndBlocker(ctx sdk.Context, keeper *keeper.Keeper) error {
|
||||
|
||||
return false, nil
|
||||
})
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package gov
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
@ -98,7 +97,7 @@ func ExportGenesis(ctx sdk.Context, k *keeper.Keeper) (*v1.GenesisState, error)
|
||||
proposals = append(proposals, &value)
|
||||
return false, nil
|
||||
})
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -117,7 +116,7 @@ func ExportGenesis(ctx sdk.Context, k *keeper.Keeper) (*v1.GenesisState, error)
|
||||
proposalsDeposits = append(proposalsDeposits, &value)
|
||||
return false, nil
|
||||
})
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@ -127,7 +126,7 @@ func ExportGenesis(ctx sdk.Context, k *keeper.Keeper) (*v1.GenesisState, error)
|
||||
proposalsVotes = append(proposalsVotes, &value)
|
||||
return false, nil
|
||||
})
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
|
||||
@ -49,10 +49,10 @@ func (keeper Keeper) DeleteAndBurnDeposits(ctx context.Context, proposalID uint6
|
||||
// IterateDeposits iterates over all the proposals deposits and performs a callback function
|
||||
func (keeper Keeper) IterateDeposits(ctx context.Context, proposalID uint64, cb func(key collections.Pair[uint64, sdk.AccAddress], value v1.Deposit) (bool, error)) error {
|
||||
rng := collections.NewPrefixedPairRange[uint64, sdk.AccAddress](proposalID)
|
||||
err := keeper.Deposits.Walk(ctx, rng, cb)
|
||||
if err != nil && !errors.IsOf(err, collections.ErrInvalidIterator) {
|
||||
if err := keeper.Deposits.Walk(ctx, rng, cb); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
@ -26,7 +25,7 @@ func ModuleAccountInvariant(keeper *Keeper, bk types.BankKeeper) sdk.Invariant {
|
||||
expectedDeposits = expectedDeposits.Add(value.Amount...)
|
||||
return false, nil
|
||||
})
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,6 @@ package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
"cosmossdk.io/math"
|
||||
@ -93,7 +92,7 @@ func (keeper Keeper) Tally(ctx context.Context, proposal v1.Proposal) (passes, b
|
||||
return false, keeper.Votes.Remove(ctx, collections.Join(vote.ProposalId, sdk.AccAddress(voter)))
|
||||
})
|
||||
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
return false, false, tallyResults, err
|
||||
}
|
||||
|
||||
|
||||
@ -418,7 +418,7 @@ func TestTally(t *testing.T) {
|
||||
// Assert votes removal after tally
|
||||
rng := collections.NewPrefixedPairRange[uint64, sdk.AccAddress](proposal.Id)
|
||||
_, err = suite.keeper.Votes.Iterate(suite.ctx, rng)
|
||||
assert.Nil(t, err, collections.ErrInvalidIterator, "votes must be removed after tally")
|
||||
assert.NoError(t, err)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,12 +1,10 @@
|
||||
package simulation
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"math"
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
sdkmath "cosmossdk.io/math"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
@ -602,7 +600,7 @@ func randomProposal(r *rand.Rand, k *keeper.Keeper, ctx sdk.Context) *v1.Proposa
|
||||
proposals = append(proposals, &value)
|
||||
return false, nil
|
||||
})
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if len(proposals) == 0 {
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing/types"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
@ -89,7 +85,7 @@ func (keeper Keeper) ExportGenesis(ctx sdk.Context) (data *types.GenesisState) {
|
||||
|
||||
return false, nil
|
||||
})
|
||||
if err != nil && !errors.Is(err, collections.ErrInvalidIterator) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return types.NewGenesisState(params, signingInfos, missedBlocks)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user