pub fn keypair_file(&self) -> Result<WithPath<File>> {
        let deploy_dir_path = "target/deploy/";
        fs::create_dir_all(deploy_dir_path)
            .with_context(|| format!("Error creating directory with path: {}", deploy_dir_path))?;
        let path = std::env::current_dir()
            .expect("Must have current dir")
            .join(format!("target/deploy/{}-keypair.json", self.lib_name));
        if path.exists() {
            return Ok(WithPath::new(
                File::open(&path)
                    .with_context(|| format!("Error opening file with path: {}", path.display()))?,
                path,
            ));
        }
        let program_kp = Keypair::generate(&mut rand::rngs::OsRng);
        let mut file = File::create(&path)
            .with_context(|| format!("Error creating file with path: {}", path.display()))?;
        file.write_all(format!("{:?}", &program_kp.to_bytes()).as_bytes())?;
        Ok(WithPath::new(file, path))
    }
// Lazily initializes the keypair file with a new key if it doesn't exist.
Lazily initializes the keypair file with a new key if it doesn't exist.
Lazily initializes the keypair file with a new key if it doesn ' t exist .
pub fn keypair_file(&self) -> Result<WithPath<File>> {
        let deploy_dir_path = "target/deploy/";
        fs::create_dir_all(deploy_dir_path)
            .with_context(|| format!("Error creating directory with path: {}", deploy_dir_path))?;
        let path = std::env::current_dir()
            .expect("Must have current dir")
            .join(format!("target/deploy/{}-keypair.json", self.lib_name));
        if path.exists() {
            return Ok(WithPath::new(
                File::open(&path)
                    .with_context(|| format!("Error opening file with path: {}", path.display()))?,
                path,
            ));
        }
        let program_kp = Keypair::generate(&mut rand::rngs::OsRng);
        let mut file = File::create(&path)
            .with_context(|| format!("Error creating file with path: {}", path.display()))?;
        file.write_all(format!("{:?}", &program_kp.to_bytes()).as_bytes())?;
        Ok(WithPath::new(file, path))
    }
pub fn keypair_file ( & self ) -> Result < WithPath < File > > { let deploy_dir_path = " " ; fs :: create_dir_all ( deploy_dir_path ) . with_context ( | | format ! ( " " deploy_dir_path ) ) ? ; let path = std :: env :: current_dir ( ) . expect ( " " ) . join ( format ! ( " " self lib_name ) ) ; if path . exists ( ) { return Ok ( WithPath :: new ( File :: open ( & path ) . with_context ( | | format ! ( " " path display ( ) ) ) ? , path , ) ) ; } let program_kp = Keypair :: generate ( & mut rand :: rngs :: OsRng ) ; let mut file = File :: create ( & path ) . with_context ( | | format ! ( " " path display ( ) ) ) ? ; file . write_all ( format ! ( " " program_kp to_bytes ( ) ) . as_bytes ( ) ) ? ; Ok ( WithPath :: new ( file , path ) ) }
Lazily initializes the keypair file with a new key if it doesn't exist.
Lazily initializes the keypair file with a new key if it doesn ' t exist .
&self