-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Extract configuration into JSON-file #54 * Remove voters-dir from wallet #54 * Add url into config, add payer to argumenta, use default solana payer if missing in args and config #54 * Use RPC URL from solana cli config by default #54 Co-authored-by: Semen Medvedev <sm@neonlabs.org>
- Loading branch information
1 parent
f13d7e7
commit 13cdf8e
Showing
11 changed files
with
267 additions
and
35 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
use crate::prelude::*; | ||
use { | ||
serde::Deserialize, | ||
}; | ||
|
||
#[derive(Debug,Deserialize)] | ||
#[serde(rename_all = "kebab-case")] | ||
pub struct ConfigFile { | ||
#[serde(default)] | ||
pub payer: String, | ||
|
||
#[serde(default)] | ||
pub url: String, | ||
|
||
pub creator: String, | ||
pub community_mint: String, | ||
|
||
pub governance_program: String, | ||
pub fixed_weight_addin: String, | ||
pub vesting_addin: String, | ||
pub neon_evm_program: String, | ||
pub maintenance_program: String, | ||
|
||
pub testing: bool, | ||
|
||
#[serde(with = "serde_datetime")] | ||
pub start_time: NaiveDateTime, | ||
} | ||
|
||
//mod serde_pubkey { | ||
// use serde::Deserialize; | ||
// use std::str::FromStr; | ||
// use solana_sdk::pubkey::Pubkey; | ||
// | ||
// pub fn deserialize<'de, D>(deserializer: D) -> Result<Pubkey, D::Error> | ||
// where D: serde::Deserializer<'de> | ||
// { | ||
// let s = String::deserialize(deserializer)?; | ||
// Pubkey::from_str(&s).map_err(serde::de::Error::custom) | ||
// } | ||
//} | ||
|
||
mod serde_datetime { | ||
use serde::Deserialize; | ||
use chrono::NaiveDateTime; | ||
|
||
pub fn deserialize<'de, D>(deserializer: D) -> Result<NaiveDateTime, D::Error> | ||
where D: serde::Deserializer<'de> | ||
{ | ||
let s = String::deserialize(deserializer)?; | ||
NaiveDateTime::parse_from_str(&s, "%FT%T").map_err(serde::de::Error::custom) | ||
} | ||
} | ||
|
||
//mod serde_keypair { | ||
// use serde::Deserialize; | ||
// use solana_sdk::signer::keypair::{Keypair, read_keypair_file}; | ||
// | ||
// pub fn deserialize<'de, D>(deserializer: D) -> Result<Keypair, D::Error> | ||
// where D: serde::Deserializer<'de> | ||
// { | ||
// let s = String::deserialize(deserializer)?; | ||
// read_keypair_file(s).map_err(serde::de::Error::custom) | ||
// } | ||
//} | ||
|
||
#[cfg(test)] | ||
mod test { | ||
use super::*; | ||
|
||
#[test] | ||
fn test_deserialize() { | ||
let data = r#"{ | ||
"payer": "../artifacts/payer.keypair", | ||
"creator": "5mAkTXJMyFxvEeUNpfiwAqUfD3qRSRmdh6j6YgXDwqrm", | ||
"community-mint": "../artifacts/community-mint.keypair", | ||
"governance-program": "../artifacts/spl-governance.keypair", | ||
"fixed-weight-addin": "../artifacts/addin-fixed-wights.keypair", | ||
"vesting-addin": "../artifacts/addin-vesting.keypair", | ||
"neon-evm-program": "../artifacts/neon-evm.keypair", | ||
"maintenance-program": "../artifacts/maintenance.keypair", | ||
"start-date": "2022-06-21T00:00:00", | ||
"testing": true | ||
}"#; | ||
|
||
let config_file: ConfigFile = serde_json::from_str(data).unwrap(); | ||
println!("ConfigFile: {:#?}", config_file); | ||
|
||
let data = r#"{ | ||
"creator": "5mAkTXJMyFxvEeUNpfiwAqUfD3qRSRmdh6j6YgXDwqrm", | ||
"community-mint": "EjLGfD8mpxKLwGDi8AiTisAbGtWWM2L3htkJ6MpvS8Hk", | ||
"governance-program": "82pQHEmBbW6CQS8GzLP3WE2pCgMUPSW2XzpuSih3aFDk", | ||
"fixed-weight-addin": "56cFVhzLFKuvRXQW68ACLpcbJonZeUBNDdLdZoo5fGnB", | ||
"vesting-addin": "5tgpCGfXYaZhKWJsrNR4zyp4o4n3wSQ81i5MzPqKEeAK", | ||
"neon-evm-program": "DCPSnJHB38e7vNK6o3AVLswJGRaP87iiNx2zvvapiKBz", | ||
"maintenance-program": "7aPH9mBAvUtJDGV2L1KyvpR5nKF7man5DZzBPaxmisg5", | ||
"start-date": "2022-06-21T00:00:00", | ||
"testing": true | ||
}"#; | ||
|
||
let config_file: ConfigFile = serde_json::from_str(data).unwrap(); | ||
println!("ConfigFile2: {:#?}", config_file); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.