fn decode_gtc_stable_memory(gtc_pb: PathBuf, output: &Path, rs: &Path) {
    let mut cmd_base = std::process::Command::new("protoc");
    let cmd = cmd_base
        // -I: where to find included protos (transitively)
        .args(&["-I", "nns/governance/proto"])
        .args(&["-I", "rosetta-api/ledger_canister/proto"])
        .args(&["-I", "types/base_types/proto"])
        .args(&["-I", "nns/common/proto"])
        .args(&["-I", "nns/gtc/proto"])
        // Main arg: the main proto file
        .arg("nns/gtc/proto/ic_nns_gtc/pb/v1/gtc.proto")
        // the actual command
        .args(&["--decode", "ic_nns_gtc.pb.v1.Gtc"])
        .current_dir(rs)
        .stdin(File::open(gtc_pb.clone()).unwrap())
        .stdout(File::create(output.join("gtc_stable_memory.textproto")).unwrap());
    let status = cmd.status().unwrap();
    match status.success() {
        true => eprintln!("Wrote gtc_stable_memory.textproto"),
        false => eprintln!(
            "Something went wrong with parsing the gtc proto. The command was: {:?}",
            cmd
        ),
    }

    let mut bytes = Vec::<u8>::new();
    File::open(gtc_pb).unwrap().read_to_end(&mut bytes).unwrap();
    let proto = match GtcProto::decode(bytes.as_slice()) {
        Err(e) => {
            eprintln!("Can't prost-deserialize the gtc proto: {}", e);
            return;
        }
        Ok(p) => p,
    };
    let mut csv_writer = csv::Writer::from_path(output.join("gtc_accounts_EXTRACT.csv")).unwrap();
    let mut records: Vec<GtcAccountRecord> = proto
        .accounts
        .iter()
        .map(|(addr, s)| GtcAccountRecord {
            account_address: addr.to_string(),
            neuron_ids: s
                .neuron_ids
                .iter()
                .map(|id| id.id.to_string())
                .collect::<Vec<String>>()
                .join(";"),
            acount_value_icpts: s.icpts,
            has_claimed: s.has_claimed,
            has_donated: s.has_donated,
        })
        .collect();
    records.sort_by_key(|record| record.account_address.clone());
    for r in records {
        csv_writer.serialize(r).unwrap();
    }
    eprintln!("Wrote gtc_accounts_EXTRACT.csv");
}
/// Decode stable memory for the GTC canister.
Decode stable memory for the GTC canister.
Decode stable memory for the GTC canister .
fn decode_gtc_stable_memory(gtc_pb: PathBuf, output: &Path, rs: &Path) {
    let mut cmd_base = std::process::Command::new("protoc");
    let cmd = cmd_base
        // -I: where to find included protos (transitively)
        .args(&["-I", "nns/governance/proto"])
        .args(&["-I", "rosetta-api/ledger_canister/proto"])
        .args(&["-I", "types/base_types/proto"])
        .args(&["-I", "nns/common/proto"])
        .args(&["-I", "nns/gtc/proto"])
        // Main arg: the main proto file
        .arg("nns/gtc/proto/ic_nns_gtc/pb/v1/gtc.proto")
        // the actual command
        .args(&["--decode", "ic_nns_gtc.pb.v1.Gtc"])
        .current_dir(rs)
        .stdin(File::open(gtc_pb.clone()).unwrap())
        .stdout(File::create(output.join("gtc_stable_memory.textproto")).unwrap());
    let status = cmd.status().unwrap();
    match status.success() {
        true => eprintln!("Wrote gtc_stable_memory.textproto"),
        false => eprintln!(
            "Something went wrong with parsing the gtc proto. The command was: {:?}",
            cmd
        ),
    }
    let mut bytes = Vec::<u8>::new();
    File::open(gtc_pb).unwrap().read_to_end(&mut bytes).unwrap();
    let proto = match GtcProto::decode(bytes.as_slice()) {
        Err(e) => {
            eprintln!("Can't prost-deserialize the gtc proto: {}", e);
            return;
        }
        Ok(p) => p,
    };
    let mut csv_writer = csv::Writer::from_path(output.join("gtc_accounts_EXTRACT.csv")).unwrap();
    let mut records: Vec<GtcAccountRecord> = proto
        .accounts
        .iter()
        .map(|(addr, s)| GtcAccountRecord {
            account_address: addr.to_string(),
            neuron_ids: s
                .neuron_ids
                .iter()
                .map(|id| id.id.to_string())
                .collect::<Vec<String>>()
                .join(";"),
            acount_value_icpts: s.icpts,
            has_claimed: s.has_claimed,
            has_donated: s.has_donated,
        })
        .collect();
    records.sort_by_key(|record| record.account_address.clone());
    for r in records {
        csv_writer.serialize(r).unwrap();
    }
    eprintln!("Wrote gtc_accounts_EXTRACT.csv");
}
fn decode_gtc_stable_memory ( gtc_pb : PathBuf , output : & Path , rs : & Path ) { let mut cmd_base = std :: process :: Command :: new ( " " ) ; let cmd = cmd_base // -I: where to find included protos (transitively) . args ( & [ " " , " " ] ) . args ( & [ " " , " " ] ) . args ( & [ " " , " " ] ) . args ( & [ " " , " " ] ) . args ( & [ " " , " " ] ) // Main arg: the main proto file . arg ( " " ) // the actual command . args ( & [ " " , " " ] ) . current_dir ( rs ) . stdin ( File :: open ( gtc_pb . clone ( ) ) . unwrap ( ) ) . stdout ( File :: create ( output . join ( " " ) ) . unwrap ( ) ) ; let status = cmd . status ( ) . unwrap ( ) ; match status . success ( ) { true => eprintln ! ( " " ) , false => eprintln ! ( " " cmd ) , } let mut bytes = Vec :: < u8 > :: new ( ) ; File :: open ( gtc_pb ) . unwrap ( ) . read_to_end ( & mut bytes ) . unwrap ( ) ; let proto = match GtcProto :: decode ( bytes . as_slice ( ) ) { Err ( e ) => { eprintln ! ( " " e ) ; return ; } Ok ( p ) => p , } ; let mut csv_writer = csv :: Writer :: from_path ( output . join ( " " ) ) . unwrap ( ) ; let mut records : Vec < GtcAccountRecord > = proto . accounts . iter ( ) . map ( | ( addr , s ) | GtcAccountRecord { account_address : addr . to_string ( ) , neuron_ids : s . neuron_ids . iter ( ) . map ( | id | id . id . to_string ( ) ) . collect :: < Vec < String > > ( ) . join ( " " ) , acount_value_icpts : s . icpts , has_claimed : s . has_claimed , has_donated : s . has_donated , } ) . collect ( ) ; records . sort_by_key ( | record | record . account_address . clone ( ) ) ; for r in records { csv_writer . serialize ( r ) . unwrap ( ) ; } eprintln ! ( " " ) ; }
Decode stable memory for the GTC canister.
Decode stable memory for the GTC canister .
gtc_pb
PathBuf
output
&Path
rs
&Path
gtc_pb
PathBuf
output
&Path
rs
&Path