1use anyhow::{anyhow, Context as _};
2use penumbra_sdk_app::genesis::{AppState, Content};
3use serde_json::Value;
4
5const GENESIS_NO_CONTENT_ERROR: &'static str = r#"
6Error: using an upgrade genesis file instead of an initial genesis file.
7
8This genesis file only contains a checkpoint hash of the state,
9rather than information about how the initial state of the chain was initialized,
10at the very first genesis.
11
12Make sure that you're using the very first genesis file, before any upgrades.
13"#;
14
15pub fn parse_content(data: Value) -> anyhow::Result<Content> {
21 let app_state: AppState = serde_json::from_value(data)
22 .context("error decoding app_state json: make sure that this is a penumbra genesis file")?;
23 let content = app_state
24 .content()
25 .ok_or(anyhow!(GENESIS_NO_CONTENT_ERROR))?;
26 Ok(content.clone())
27}