Skip to content

Commit

Permalink
Modified chain name
Browse files Browse the repository at this point in the history
  • Loading branch information
Kayanski committed Apr 29, 2024
1 parent 714198a commit 4bef098
Show file tree
Hide file tree
Showing 18 changed files with 35 additions and 34 deletions.
2 changes: 1 addition & 1 deletion cw-orch-daemon/src/queriers/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ impl EnvironmentQuerier for Daemon {
let state = &self.daemon.sender.daemon_state;
EnvironmentInfo {
chain_id: state.chain_data.chain_id.to_string(),
chain_name: state.chain_data.network_info.id.to_string(),
chain_name: state.chain_data.network_info.chain_name.to_string(),
deployment_id: state.deployment_id.clone(),
}
}
Expand Down
9 changes: 5 additions & 4 deletions cw-orch-daemon/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl DaemonState {
crate::json_file::write(
&state.json_file_path,
&state.chain_data.chain_id.to_string(),
&state.chain_data.network_info.id.to_string(),
&state.chain_data.network_info.chain_name.to_string(),
&state.deployment_id,
);
}
Expand Down Expand Up @@ -142,7 +142,8 @@ impl DaemonState {
pub fn get(&self, key: &str) -> Result<Value, DaemonError> {
let json = self.read_state()?;
Ok(
json[&self.chain_data.network_info.id][&self.chain_data.chain_id.to_string()][key]
json[&self.chain_data.network_info.chain_name][&self.chain_data.chain_id.to_string()]
[key]
.clone(),
)
}
Expand All @@ -160,8 +161,8 @@ impl DaemonState {

let mut json = self.read_state()?;

json[&self.chain_data.network_info.id][&self.chain_data.chain_id.to_string()][key]
[contract_id] = json!(value);
json[&self.chain_data.network_info.chain_name][&self.chain_data.chain_id.to_string()]
[key][contract_id] = json!(value);

serde_json::to_writer_pretty(File::create(&self.json_file_path).unwrap(), &json)?;
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion cw-orch/src/osmosis_test_tube/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub const MOCK_CHAIN_INFO: ChainInfo = ChainInfo {
lcd_url: None,
fcd_url: None,
network_info: NetworkInfo {
id: "osmosis",
chain_name: "osmosis",
pub_address_prefix: "osmo",
coin_type: 118u32,
},
Expand Down
16 changes: 8 additions & 8 deletions packages/cw-orch-core/src/build.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
//! # Build Postfix Format
//! Used to specify the build-postfix for contracts in the `Uploadable` trait.

use crate::environment::{EnvironmentInfo, EnvironmentQuerier};
use crate::environment::{ChainInfoOwned, EnvironmentInfo, EnvironmentQuerier};

/// Build name used for building the contract.
/// See the [Abstract Optimizer](https://github.com/AbstractSDK/rust-optimizer).
pub enum BuildPostfix<'a, T: EnvironmentQuerier = ()> {
pub enum BuildPostfix<'a> {
/// Default, doesn't look for anything but the contract name.
None,
/// Uses the chain to figure out the chain name. I.e. "uni-6" = "juno-1" -> "juno" post-fix on build.
ChainName(&'a T),
ChainName(&'a ChainInfoOwned),
/// Uses the chain name as the build-postfix. I.e. "uni-6", "juno-1", "osmosis-5", ect.
ChainID(&'a T),
ChainID(&'a ChainInfoOwned),
/// Use a custom post-fix to specify the artifact.
Custom(String),
}

impl<T: EnvironmentQuerier> From<BuildPostfix<'_, T>> for String {
fn from(value: BuildPostfix<T>) -> Self {
impl From<BuildPostfix<'_>> for String {
fn from(value: BuildPostfix) -> Self {
match value {
BuildPostfix::None => "".to_string(),
BuildPostfix::ChainName(chain) => chain.env_info().chain_name,
BuildPostfix::ChainID(chain) => chain.env_info().chain_id,
BuildPostfix::ChainName(chain) => chain.network_info.chain_name.clone(),
BuildPostfix::ChainID(chain) => chain.chain_id.clone(),
BuildPostfix::Custom(postfix) => postfix,
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/cw-orch-core/src/contract/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ mod artifacts_dir {

use super::WasmPath;
use crate::{
build::BuildPostfix, env::ARTIFACTS_DIR_ENV_NAME, environment::EnvironmentQuerier,
error::CwEnvError, log::local_target, CoreEnvVars,
build::BuildPostfix, env::ARTIFACTS_DIR_ENV_NAME, error::CwEnvError, log::local_target,
CoreEnvVars,
};

use std::{env, fs, path::PathBuf};
Expand Down Expand Up @@ -160,10 +160,10 @@ mod artifacts_dir {
/// Find a WASM file in the artifacts directory that contains the given contract name AND build post-fix.
/// If a build with the post-fix is not found, the default build will be used.
/// If none of the two are found, an error is returned.
pub fn find_wasm_path_with_build_postfix<T: EnvironmentQuerier>(
pub fn find_wasm_path_with_build_postfix(
&self,
name: &str,
build_postfix: BuildPostfix<T>,
build_postfix: BuildPostfix,
) -> Result<WasmPath, CwEnvError> {
let build_postfix: String = build_postfix.into();
// Found artifacts priority respected
Expand Down
8 changes: 4 additions & 4 deletions packages/cw-orch-core/src/environment/chain_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub type NetworkInfoOwned = NetworkInfoBase<String>;
/// This is used to connect to a chain and to generate transactions.
#[derive(Clone, Debug)]
pub struct ChainInfoBase<StringType: Into<String>, StringArrayType: AsRef<[StringType]>> {
/// Identifier for the network ex. columbus-2
/// Identifier for the network ex. phoenix-2, pisco-1
pub chain_id: StringType,
/// Max gas and denom info
// #[serde(with = "cosm_denom_format")]
Expand All @@ -34,8 +34,8 @@ pub struct ChainInfoBase<StringType: Into<String>, StringArrayType: AsRef<[Strin
/// Information about the underlying network, used for key derivation
#[derive(Clone, Debug, Serialize, Default)]
pub struct NetworkInfoBase<StringType> {
/// network identifier (ex. juno, terra, osmosis, etc)
pub id: StringType,
/// network identifier (ex. juno, terra2, osmosis, etc)
pub chain_name: StringType,
/// address prefix
pub pub_address_prefix: StringType,
/// coin type for key derivation
Expand All @@ -59,7 +59,7 @@ impl From<ChainInfo> for ChainInfoOwned {
impl From<NetworkInfo> for NetworkInfoOwned {
fn from(value: NetworkInfo) -> Self {
NetworkInfoOwned {
id: value.id.to_string(),
chain_name: value.chain_name.to_string(),
pub_address_prefix: value.pub_address_prefix.to_string(),
coin_type: value.coin_type,
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cw-orch-networks/src/networks/archway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::networks::{ChainInfo, ChainKind, NetworkInfo};

// ANCHOR: archway
pub const ARCHWAY_NETWORK: NetworkInfo = NetworkInfo {
id: "archway",
chain_name: "archway",
pub_address_prefix: "archway",
coin_type: 118u32,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/cw-orch-networks/src/networks/doravota.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use cw_orch_core::environment::{ChainInfo, ChainKind, NetworkInfo};

// ANCHOR: juno
pub const DORAVOTA_NETWORK: NetworkInfo = NetworkInfo {
id: "doravota",
chain_name: "doravota",
pub_address_prefix: "dora",
coin_type: 118u32,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/cw-orch-networks/src/networks/injective.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::networks::{ChainInfo, ChainKind, NetworkInfo};

// ANCHOR: injective
pub const INJECTIVE_NETWORK: NetworkInfo = NetworkInfo {
id: "injective",
chain_name: "injective",
pub_address_prefix: "inj",
coin_type: 60u32,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/cw-orch-networks/src/networks/juno.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use cw_orch_core::environment::{ChainInfo, ChainKind, NetworkInfo};

// ANCHOR: juno
pub const JUNO_NETWORK: NetworkInfo = NetworkInfo {
id: "juno",
chain_name: "juno",
pub_address_prefix: "juno",
coin_type: 118u32,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/cw-orch-networks/src/networks/kujira.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::networks::{ChainInfo, ChainKind, NetworkInfo};

// ANCHOR: kujira
pub const KUJIRA_NETWORK: NetworkInfo = NetworkInfo {
id: "kujira",
chain_name: "kujira",
pub_address_prefix: "kujira",
coin_type: 118u32,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/cw-orch-networks/src/networks/migaloo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::networks::{ChainInfo, ChainKind, NetworkInfo};

// ANCHOR: migaloo
pub const MIGALOO_NETWORK: NetworkInfo = NetworkInfo {
id: "migaloo-1",
chain_name: "migaloo-1",
pub_address_prefix: "migaloo",
coin_type: 118u32,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/cw-orch-networks/src/networks/neutron.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::networks::{ChainInfo, ChainKind, NetworkInfo};

// ANCHOR: neutron
pub const NEUTRON_NETWORK: NetworkInfo = NetworkInfo {
id: "neutron",
chain_name: "neutron",
pub_address_prefix: "neutron",
coin_type: 118u32,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/cw-orch-networks/src/networks/nibiru.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use cw_orch_core::environment::{ChainInfo, ChainKind, NetworkInfo};

// ANCHOR: nibiru
pub const NIBIRU_NETWORK: NetworkInfo = NetworkInfo {
id: "nibiru",
chain_name: "nibiru",
pub_address_prefix: "nibi",
coin_type: 118u32,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/cw-orch-networks/src/networks/osmosis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use cw_orch_core::environment::{ChainInfo, ChainKind, NetworkInfo};

// ANCHOR: osmosis
pub const OSMO_NETWORK: NetworkInfo = NetworkInfo {
id: "osmosis",
chain_name: "osmosis",
pub_address_prefix: "osmo",
coin_type: 118u32,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/cw-orch-networks/src/networks/rollkit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use cw_orch_core::environment::{ChainInfo, ChainKind, NetworkInfo};

// ANCHOR: rollkit
pub const ROLLKIT_NETWORK: NetworkInfo = NetworkInfo {
id: "rollkit",
chain_name: "rollkit",
pub_address_prefix: "wasm",
coin_type: 118u32,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/cw-orch-networks/src/networks/sei.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::networks::{ChainInfo, ChainKind, NetworkInfo};

// ANCHOR: sei
pub const SEI_NETWORK: NetworkInfo = NetworkInfo {
id: "sei",
chain_name: "sei",
pub_address_prefix: "sei",
coin_type: 118u32,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/cw-orch-networks/src/networks/terra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use cw_orch_core::environment::{ChainInfo, ChainKind, NetworkInfo};

// ANCHOR: terra
pub const TERRA_NETWORK: NetworkInfo = NetworkInfo {
id: "terra2",
chain_name: "terra2",
pub_address_prefix: "terra",
coin_type: 330u32,
};
Expand Down

0 comments on commit 4bef098

Please sign in to comment.