Skip to content

Commit

Permalink
added genesis export/init for plans and projects modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Yarom Swisa authored and Yarom Swisa committed Jun 18, 2023
1 parent e7416e8 commit 5cec4d9
Show file tree
Hide file tree
Showing 13 changed files with 696 additions and 57 deletions.
25 changes: 25 additions & 0 deletions common/fixation_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,3 +730,28 @@ func NewFixationStore(storeKey sdk.StoreKey, cdc codec.BinaryCodec, prefix strin

return &fs
}

func (fs *FixationStore) Export(ctx sdk.Context) []types.RawMessage {
store := prefix.NewStore(
ctx.KVStore(fs.storeKey),
types.KeyPrefix(fs.prefix))
iterator := sdk.KVStorePrefixIterator(store, []byte{})
defer iterator.Close()

data := []types.RawMessage{}
for ; iterator.Valid(); iterator.Next() {
data = append(data, types.RawMessage{Key: iterator.Key(), Value: iterator.Value()})
}

return data
}

func (fs *FixationStore) Init(ctx sdk.Context, data []types.RawMessage) {
store := prefix.NewStore(
ctx.KVStore(fs.storeKey),
types.KeyPrefix(fs.prefix))

for _, data := range data {
store.Set(data.Key, data.Value)
}
}
261 changes: 244 additions & 17 deletions common/types/fixationEntry.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5cec4d9

Please sign in to comment.