Skip to content

Commit

Permalink
Tauri (#732)
Browse files Browse the repository at this point in the history
* patch

* makefile

* testnet genesis fixtures

* fixtures

* cleanup testnet defaults

* devnet fixtures

* tx_params in stubmit_tx needed an option for wallet library

* get txs params from keypair

* get_tx_params_from_keypair api change

* patch miner tests
  • Loading branch information
0o-de-lally authored Oct 8, 2021
1 parent 0957e6d commit 8b4457a
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 13 deletions.
5 changes: 3 additions & 2 deletions ol/miner/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ fn test_mine_genesis() {
// if no file is found, the block height is 0
//let blocks_dir = Path::new("./test_blocks");
let configs_fixture = test_make_configs_fixture();
dbg!(&configs_fixture);

//clear from sideffects.
test_helper_clear_block_dir(&configs_fixture.get_block_dir());
Expand Down Expand Up @@ -364,7 +365,7 @@ pub fn test_make_configs_fixture() -> AppCfg {
cfg.workspace.block_dir = "test_blocks_temp_1".to_owned();
cfg.chain_info.chain_id = "0L testnet".to_owned();
cfg.profile.auth_key =
"3e4629ba1e63114b59a161e89ad4a083b3a31b5fd59e39757c493e96398e4df2".to_string();
"3e4629ba1e63114b59a161e89ad4a083b3a31b5fd59e39757c493e96398e4df2".parse().unwrap();
cfg
}

Expand All @@ -376,7 +377,7 @@ pub fn genesis_preimage(cfg: &AppCfg) -> Vec<u8> {

let mut preimage: Vec<u8> = vec![];

let mut padded_key_bytes = match decode(cfg.profile.auth_key.clone()) {
let mut padded_key_bytes = match decode(cfg.profile.auth_key.clone().to_string()) {
Err(x) => panic!("Invalid 0L Auth Key: {}", x),
Ok(key_bytes) => {
if key_bytes.len() != AUTH_KEY_BYTES {
Expand Down
2 changes: 1 addition & 1 deletion ol/onboard/src/commands/files_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub fn genesis_files(
) {
let home_dir = miner_config.workspace.node_home.to_owned();
// 0L convention is for the namespace of the operator to be appended by '-oper'
let namespace = miner_config.profile.auth_key.clone() + "-oper";
let namespace = miner_config.profile.auth_key.clone().to_string() + "-oper";

ol_node_files::write_node_config_files(
home_dir.clone(),
Expand Down
6 changes: 3 additions & 3 deletions ol/onboard/src/commands/fix_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ impl Runnable for FixCmd {
status_info!("\nOnboard fix", "migrating account.json");
let cfg = app_config();
let home_dir = &cfg.workspace.node_home;
let namespace = &cfg.profile.auth_key;
let namespace = cfg.profile.auth_key.to_string();
// set the waypoint
if let Some(w) = self.waypoint {
key::set_waypoint(home_dir, namespace, w);
key::set_waypoint(home_dir, &namespace, w);
}
if self.operator {
key::set_operator_key(home_dir, namespace);
key::set_operator_key(home_dir, &namespace);
}

if self.account {
Expand Down
2 changes: 1 addition & 1 deletion ol/onboard/src/commands/wizard_fn_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl Runnable for FnWizardCmd {

let home_dir = cfg.workspace.node_home.to_owned();
// 0L convention is for the namespace of the operator to be appended by '-oper'
let namespace = cfg.profile.auth_key.clone() + "-oper";
let namespace = cfg.profile.auth_key.clone().to_string() + "-oper";

ol_node_files::write_node_config_files(
home_dir.clone(),
Expand Down
2 changes: 1 addition & 1 deletion ol/onboard/src/commands/wizard_fork_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl Runnable for ForkCmd {

let home_dir = app_config.workspace.node_home.to_owned();
// 0L convention is for the namespace of the operator to be appended by '-oper'
let namespace = app_config.profile.auth_key.clone() + "-oper";
let namespace = app_config.profile.auth_key.clone().to_string() + "-oper";

// TODO: use node_config to get the seed peers and then write upstream_node vec in 0L.toml from that.
ol_node_files::write_node_config_files(
Expand Down
2 changes: 1 addition & 1 deletion ol/onboard/src/commands/wizard_user_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn wizard(path: PathBuf, block_zero: &Option<PathBuf>) {

// Where to save block_0
app_cfg.workspace.node_home = path.clone();
app_cfg.profile.auth_key = authkey.to_string();
app_cfg.profile.auth_key = authkey;
app_cfg.profile.account = account;

// Create block zero, if there isn't one.
Expand Down
2 changes: 1 addition & 1 deletion ol/onboard/src/commands/wizard_val_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl Runnable for ValWizardCmd {

let home_dir = app_config.workspace.node_home.to_owned();
// 0L convention is for the namespace of the operator to be appended by '-oper'
let namespace = app_config.profile.auth_key.clone() + "-oper";
let namespace = app_config.profile.auth_key.clone().to_string() + "-oper";

// TODO: use node_config to get the seed peers and then write upstream_node vec in 0L.toml from that.
ol_node_files::write_node_config_files(
Expand Down
37 changes: 37 additions & 0 deletions ol/txs/src/submit_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,43 @@ pub fn get_tx_params_from_toml(
Ok(tx_params)
}


/// Gets transaction params from the 0L project root.
pub fn get_tx_params_from_keypair(
config: AppCfg,
tx_type: TxType,
keypair: KeyPair<Ed25519PrivateKey, Ed25519PublicKey>,
wp: Option<Waypoint>,
use_upstream_url: bool,
is_swarm: bool,
) -> Result<TxParams, Error> {

let waypoint = wp.unwrap_or_else(|| {
config.get_waypoint(None).unwrap()
});

let chain_id = if is_swarm {
ChainId::new(4)
} else {
// main net id
ChainId::new(1)
};

let tx_params = TxParams {
auth_key: config.profile.auth_key,
signer_address: config.profile.account,
owner_address: config.profile.account,
url: config.what_url(use_upstream_url),
waypoint,
keypair,
tx_cost: config.tx_configs.get_cost(tx_type),
chain_id,
};

Ok(tx_params)
}


/// Wait for the response from the diem RPC.
pub fn wait_for_tx(
signer_address: AccountAddress,
Expand Down
6 changes: 3 additions & 3 deletions ol/types/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl AppCfg {
) -> AppCfg {
// TODO: Check if configs exist and warn on overwrite.
let mut default_config = AppCfg::default();
default_config.profile.auth_key = authkey.to_string();
default_config.profile.auth_key = authkey;
default_config.profile.account = account;

// Get statement which goes into genesis block
Expand Down Expand Up @@ -385,7 +385,7 @@ pub struct Profile {
pub account: AccountAddress,

/// Miner Authorization Key for 0L Blockchain. Note: not the same as public key, nor account.
pub auth_key: String,
pub auth_key: AuthenticationKey,

/// An opportunity for the Miner to write a message on their genesis block.
pub statement: String,
Expand All @@ -403,8 +403,8 @@ pub struct Profile {
impl Default for Profile {
fn default() -> Self {
Self {
auth_key: "".to_owned(),
account: AccountAddress::from_hex_literal("0x0").unwrap(),
auth_key: AuthenticationKey::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(),
statement: "Protests rage across the nation".to_owned(),
ip: "0.0.0.0".parse().unwrap(),
default_node: Some("http://localhost:8080".parse().expect("parse url")),
Expand Down

0 comments on commit 8b4457a

Please sign in to comment.