Skip to content

Commit

Permalink
Fix neutron example.
Browse files Browse the repository at this point in the history
  • Loading branch information
dowlandaiello committed Sep 6, 2024
1 parent 7e13dc9 commit c4e3772
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 6 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added examples/contracts_osmosis/auction.wasm
Binary file not shown.
Binary file added examples/contracts_osmosis/auctions_manager.wasm
Binary file not shown.
Binary file added examples/contracts_osmosis/cw1_whitelist.wasm
Binary file not shown.
Binary file added examples/contracts_osmosis/cw20_base.wasm
Binary file not shown.
Binary file added examples/contracts_osmosis/price_oracle.wasm
Binary file not shown.
4 changes: 2 additions & 2 deletions examples/neutron.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const ARTIFACTS_DIR: &str = "contracts";
const ACC_0_ADDR: &str = "neutron1hj5fveer5cjtn4wd6wstzugjfdxzl0xpznmsky";
const LOCAL_CODE_ID_CACHE_PATH: &str = "code_id_cache.json";

const TEST_TOKEN_1_NAME: &str = "bruhtoken3";
const TEST_TOKEN_2_NAME: &str = "amoguscoin3";
const TEST_TOKEN_1_NAME: &str = "bruhtokent13";
const TEST_TOKEN_2_NAME: &str = "amoguscoin13";

/// Demonstrates using localic-utils for neutron.
fn main() -> Result<(), Box<dyn Error>> {
Expand Down
36 changes: 32 additions & 4 deletions src/utils/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ impl<'a> TestContextQuery<'a> {
pub fn get_cw(self) -> CosmWasm<'a> {
match self.query_type {
QueryType::Contract => self.get_contract(),
QueryType::Factory
| QueryType::Auction
| QueryType::PriceOracle
| QueryType::AuctionsManager => self.get_deployed_contract(),
QueryType::Auction => self.get_auction(),
QueryType::Factory | QueryType::PriceOracle | QueryType::AuctionsManager => {
self.get_deployed_contract()
}
QueryType::AstroPool => self.get_astro_pool(),
QueryType::TransferChannel
| QueryType::Connection
Expand Down Expand Up @@ -408,6 +408,34 @@ impl<'a> TestContextQuery<'a> {
))
}

fn get_auction(&self) -> Option<CosmWasm<'a>> {
let auction_manager = self
.context
.get_auctions_manager()
.src(self.src_chain.as_deref()?)
.get_cw();
let denoms = (self.offer_asset.as_deref()?, self.ask_asset.as_deref()?);

let resp = auction_manager.query(
&serde_json::to_string(&serde_json::json!({
"get_pair_addr": {
"pair": denoms,
}}
))
.unwrap(),
);

let mut cw = self
.context
.get_contract()
.contract(PAIR_NAME)
.src(self.src_chain.as_deref()?)
.get_cw();
cw.contract_addr = Some(resp["data"].as_str()?.to_owned());

Some(cw)
}

fn get_astro_pool(&self) -> Option<CosmWasm<'a>> {
let (denom_a, denom_b) = self.denoms.as_ref()?;
let factory = self
Expand Down

0 comments on commit c4e3772

Please sign in to comment.