cosmos-sdk/simapp/v2/export.go
Randy Grok aeeaca64da
feat: export genesis in simapp v2 (#21199)
Co-authored-by: marbar3778 <marbar3778@yahoo.com>
2024-08-16 11:15:45 +00:00

30 lines
666 B
Go

package simapp
import (
"context"
v2 "github.com/cosmos/cosmos-sdk/x/genutil/v2"
)
// ExportAppStateAndValidators exports the state of the application for a genesis
// file.
func (app *SimApp[T]) ExportAppStateAndValidators(jailAllowedAddrs []string) (v2.ExportedApp, error) {
// as if they could withdraw from the start of the next block
ctx := context.Background()
latestHeight, err := app.LoadLatestHeight()
if err != nil {
return v2.ExportedApp{}, err
}
genesis, err := app.ExportGenesis(ctx, latestHeight)
if err != nil {
return v2.ExportedApp{}, err
}
return v2.ExportedApp{
AppState: genesis,
Height: int64(latestHeight),
}, nil
}