* add query to query.proto * add ContractsByCreatorPrefix in keys.go * add ContractCreatorThirdIndex to keeper.go * add querier * cli * fix test * linting * add key test * no need to change creator when migrate * add query test * minor * add migrate logic * add more test * register migration * minor * Update x/wasm/client/cli/query.go Co-authored-by: Alexander Peters <alpe@users.noreply.github.com> * nits * remove IterateAllContract * Update x/wasm/keeper/genesis_test.go Co-authored-by: Alexander Peters <alpe@users.noreply.github.com> * nit * nit: func name * change key * improve TestIteratorContractByCreator * fix test * use IterateContractInfo in migrate2to3 * minor * move key * improve test case * add pagReq in ContractsByCreator query * ordering query * add migrate test * Make ContractsByCreator plural; formatting and minor updates * Comment why AbsoluteTxPositionLen makes sense * Migrate 1 to 2 * Set module version Co-authored-by: Alexander Peters <alpe@users.noreply.github.com> Co-authored-by: khanh-notional <50263489+catShaark@users.noreply.github.com>
28 lines
738 B
Go
28 lines
738 B
Go
package keeper
|
|
|
|
import (
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
"github.com/CosmWasm/wasmd/x/wasm/types"
|
|
)
|
|
|
|
// Migrator is a struct for handling in-place store migrations.
|
|
type Migrator struct {
|
|
keeper Keeper
|
|
}
|
|
|
|
// NewMigrator returns a new Migrator.
|
|
func NewMigrator(keeper Keeper) Migrator {
|
|
return Migrator{keeper: keeper}
|
|
}
|
|
|
|
// Migrate1to2 migrates from version 1 to 2.
|
|
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
|
|
m.keeper.IterateContractInfo(ctx, func(contractAddr sdk.AccAddress, contractInfo types.ContractInfo) bool {
|
|
creator := sdk.MustAccAddressFromBech32(contractInfo.Creator)
|
|
m.keeper.addToContractCreatorSecondaryIndex(ctx, creator, contractInfo.Created, contractAddr)
|
|
return false
|
|
})
|
|
return nil
|
|
}
|