Skip to content

Commit

Permalink
Merge pull request #26 from timewave-computer/dowlandaiello/refactor-…
Browse files Browse the repository at this point in the history
…addrsperchain

Differentiate all contract deployments by chain
  • Loading branch information
dowlandaiello authored Sep 1, 2024
2 parents a00b840 + 873d25c commit a8351bc
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 57 deletions.
26 changes: 14 additions & 12 deletions src/utils/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use crate::{

use super::{
super::{
error::Error, AUCTION_CONTRACT_NAME, FACTORY_NAME, NEUTRON_CHAIN_NAME, OSMOSIS_CHAIN_NAME,
PAIR_NAME, PRICE_ORACLE_NAME, STABLE_PAIR_NAME, TX_HASH_QUERY_PAUSE_SEC,
TX_HASH_QUERY_RETRIES,
error::Error, AUCTIONS_MANAGER_CONTRACT_NAME, AUCTION_CONTRACT_NAME, FACTORY_NAME,
NEUTRON_CHAIN_NAME, OSMOSIS_CHAIN_NAME, PAIR_NAME, PRICE_ORACLE_NAME, STABLE_PAIR_NAME,
TX_HASH_QUERY_PAUSE_SEC, TX_HASH_QUERY_RETRIES,
},
test_context::TestContext,
};
Expand Down Expand Up @@ -84,18 +84,20 @@ impl TestContext {
pub fn get_auctions_manager(&self) -> Result<CosmWasm, Error> {
let neutron = self.get_chain(NEUTRON_CHAIN_NAME);

let contract_info = self
.auctions_manager
.as_ref()
.ok_or(Error::MissingContextVariable(String::from(
"auctions_manager",
)))?;
let contract_addr = neutron
.contract_addrs
.get(AUCTIONS_MANAGER_CONTRACT_NAME)
.unwrap();
let code_id = neutron
.contract_codes
.get(AUCTIONS_MANAGER_CONTRACT_NAME)
.unwrap();

Ok(CosmWasm::new_from_existing(
&neutron.rb,
Some(contract_info.artifact_path.clone()),
Some(contract_info.code_id),
Some(contract_info.address.clone()),
None,
Some(*code_id),
Some(contract_addr.clone()),
))
}

Expand Down
22 changes: 2 additions & 20 deletions src/utils/setup/astroport.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use super::super::{
super::{
error::Error, types::contract::DeployedContractInfo, DEFAULT_KEY, FACTORY_NAME,
NEUTRON_CHAIN_ADMIN_ADDR, NEUTRON_CHAIN_NAME, PAIR_NAME, STABLE_PAIR_NAME, TOKEN_NAME,
TOKEN_REGISTRY_NAME, WHITELIST_NAME,
error::Error, DEFAULT_KEY, FACTORY_NAME, NEUTRON_CHAIN_ADMIN_ADDR, NEUTRON_CHAIN_NAME,
PAIR_NAME, STABLE_PAIR_NAME, TOKEN_NAME, TOKEN_REGISTRY_NAME, WHITELIST_NAME,
},
test_context::TestContext,
};
Expand Down Expand Up @@ -218,11 +217,6 @@ impl TestContext {
owner_addr: impl Into<String>,
) -> Result<(), Error> {
let mut contract_a = self.get_contract(TOKEN_REGISTRY_NAME)?;
let code_id = contract_a
.code_id
.ok_or(Error::MissingContextVariable(String::from(
"astroport_token_registry::code_id",
)))?;

let contract = contract_a.instantiate(
key,
Expand All @@ -235,25 +229,13 @@ impl TestContext {
"--gas 1000000",
)?;
let addr = contract.address;
let artifact_path =
contract_a
.file_path
.ok_or(Error::MissingContextVariable(String::from(
"astroport_token_registry::artifact_path",
)))?;

let neutron = self.get_mut_chain(NEUTRON_CHAIN_NAME);

neutron
.contract_addrs
.insert(TOKEN_REGISTRY_NAME.to_owned(), addr.clone());

self.astroport_token_registry = Some(DeployedContractInfo {
code_id,
address: addr,
artifact_path,
});

Ok(())
}

Expand Down
15 changes: 1 addition & 14 deletions src/utils/setup/valence.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use super::super::{
super::{
error::Error,
types::contract::{
AuctionStrategy, ChainHaltConfig, DeployedContractInfo, MinAmount,
PriceFreshnessStrategy,
},
types::contract::{AuctionStrategy, ChainHaltConfig, MinAmount, PriceFreshnessStrategy},
AUCTIONS_MANAGER_CONTRACT_NAME, AUCTION_CONTRACT_NAME, DEFAULT_AUCTION_LABEL, DEFAULT_KEY,
NEUTRON_CHAIN_ADMIN_ADDR, NEUTRON_CHAIN_NAME, PRICE_ORACLE_NAME,
},
Expand Down Expand Up @@ -423,16 +420,6 @@ impl TestContext {
"",
)?;

self.auctions_manager = Some(DeployedContractInfo {
code_id: contract_a.code_id.ok_or(Error::Misc(format!(
"contract '{AUCTIONS_MANAGER_CONTRACT_NAME}' has no code ID"
)))?,
address: contract.address.clone(),
artifact_path: contract_a.file_path.ok_or(Error::Misc(format!(
"contract '{AUCTIONS_MANAGER_CONTRACT_NAME}' has no file path"
)))?,
});

let chain = self.get_mut_chain(NEUTRON_CHAIN_NAME);

chain
Expand Down
11 changes: 0 additions & 11 deletions src/utils/test_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use super::super::{
error::Error,
types::{
config::{ConfigChain, Logs},
contract::DeployedContractInfo,
ibc::Channel as QueryChannel,
},
ICTEST_HOME_VAR, LOCAL_IC_API_URL, NEUTRON_CHAIN_NAME, TRANSFER_PORT,
Expand Down Expand Up @@ -353,9 +352,6 @@ impl TestContextBuilder {
artifacts_dir: artifacts_dir
.clone()
.ok_or(Error::MissingBuilderParam(String::from("artifacts_dir")))?,
auctions_manager: None,
astroport_token_registry: None,
astroport_factory: None,
unwrap_logs: *unwrap_raw_logs,
log_file,
})
Expand All @@ -376,13 +372,6 @@ pub struct TestContext {
/// The path to .wasm contract artifacts
pub artifacts_dir: String,

/// Valence deployment info
pub auctions_manager: Option<DeployedContractInfo>,

/// Astroport deployment info
pub astroport_token_registry: Option<DeployedContractInfo>,
pub astroport_factory: Option<DeployedContractInfo>,

/// Whether or not logs should be expected and guarded for each tx
pub unwrap_logs: bool,

Expand Down

0 comments on commit a8351bc

Please sign in to comment.