feat(collections): implement appmodule.HasGenesis interface (#17021)
This commit is contained in:
parent
5442197d6b
commit
2102074024
@ -35,14 +35,18 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
* [#17024](https://github.com/cosmos/cosmos-sdk/pull/17024) - Introduces `Triple`, a composite key with three keys.
|
||||
|
||||
### Improvements
|
||||
|
||||
* [#17021](https://github.com/cosmos/cosmos-sdk/pull/17021) Make collections implement the `appmodule.HasGenesis` interface.
|
||||
|
||||
## [v0.3.0](https://github.com/cosmos/cosmos-sdk/releases/tag/collections%2Fv0.3.0)
|
||||
|
||||
### Features
|
||||
|
||||
* [#16074](https://github.com/cosmos/cosmos-sdk/pull/16607) - Introduces `Clear` method for `Map` and `KeySet`
|
||||
* [#16773](https://github.com/cosmos/cosmos-sdk/pull/16773)
|
||||
* Adds `AltValueCodec` which provides a way to decode a value in two ways.
|
||||
* Adds the possibility to specify an alternative way to decode the values of `KeySet`, `indexes.Multi`, `indexes.ReversePair`.
|
||||
* Adds `AltValueCodec` which provides a way to decode a value in two ways.
|
||||
* Adds the possibility to specify an alternative way to decode the values of `KeySet`, `indexes.Multi`, `indexes.ReversePair`.
|
||||
|
||||
## [v0.2.0](https://github.com/cosmos/cosmos-sdk/releases/tag/collections%2Fv0.2.0)
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ package collections
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
@ -39,6 +40,13 @@ func (m Map[K, V]) exportGenesis(ctx context.Context, writer io.Writer) error {
|
||||
|
||||
it, err := m.Iterate(ctx, nil)
|
||||
if err != nil {
|
||||
// if the iterator is invalid, the state can be empty
|
||||
// and we can just return an empty array.
|
||||
if errors.Is(err, ErrInvalidIterator) {
|
||||
_, err = io.WriteString(writer, "]")
|
||||
return err
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
defer it.Close()
|
||||
|
||||
@ -161,6 +161,12 @@ func NewSchemaFromAccessor(accessor func(context.Context) store.KVStore) Schema
|
||||
}
|
||||
}
|
||||
|
||||
// IsOnePerModuleType implements the depinject.OnePerModuleType interface.
|
||||
func (s Schema) IsOnePerModuleType() {}
|
||||
|
||||
// IsAppModule implements the appmodule.AppModule interface.
|
||||
func (s Schema) IsAppModule() {}
|
||||
|
||||
// DefaultGenesis implements the appmodule.HasGenesis.DefaultGenesis method.
|
||||
func (s Schema) DefaultGenesis(target appmodule.GenesisTarget) error {
|
||||
for _, name := range s.collectionsOrdered {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user