Skip to content

Commit

Permalink
Migrate testcontext queries to query builder pattern.
Browse files Browse the repository at this point in the history
  • Loading branch information
dowlandaiello committed Sep 1, 2024
1 parent a00b840 commit 7e13dc9
Show file tree
Hide file tree
Showing 8 changed files with 633 additions and 495 deletions.
61 changes: 44 additions & 17 deletions examples/neutron.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,16 @@ fn main() -> Result<(), Box<dyn Error>> {
.with_subdenom(TEST_TOKEN_2_NAME)
.send()?;

let bruhtoken = ctx.get_tokenfactory_denom(ACC_0_ADDR, TEST_TOKEN_1_NAME);
let amoguscoin = ctx.get_tokenfactory_denom(ACC_0_ADDR, TEST_TOKEN_2_NAME);
let bruhtoken = ctx
.get_tokenfactory_denom()
.creator(ACC_0_ADDR)
.subdenom(TEST_TOKEN_1_NAME.to_owned())
.get();
let amoguscoin = ctx
.get_tokenfactory_denom()
.creator(ACC_0_ADDR)
.subdenom(TEST_TOKEN_2_NAME.to_owned())
.get();

// Deploy valence auctions
ctx.build_tx_create_auctions_manager()
Expand Down Expand Up @@ -81,14 +89,26 @@ fn main() -> Result<(), Box<dyn Error>> {
.with_amount_offer_asset(10000)
.send()?;

ctx.get_auction((
"untrn",
ctx.get_tokenfactory_denom(ACC_0_ADDR, TEST_TOKEN_1_NAME),
))?;
ctx.get_auction((
"untrn",
ctx.get_tokenfactory_denom(ACC_0_ADDR, TEST_TOKEN_2_NAME),
))?;
let _ = ctx
.get_auction()
.offer_asset("untrn")
.ask_asset(
&ctx.get_tokenfactory_denom()
.creator(ACC_0_ADDR)
.subdenom(TEST_TOKEN_1_NAME.to_owned())
.get(),
)
.get_cw();
let _ = ctx
.get_auction()
.offer_asset("untrn")
.ask_asset(
&ctx.get_tokenfactory_denom()
.creator(ACC_0_ADDR)
.subdenom(TEST_TOKEN_2_NAME.to_owned())
.get(),
)
.get_cw();

ctx.build_tx_create_token_registry()
.with_owner(ACC_0_ADDR)
Expand All @@ -105,10 +125,16 @@ fn main() -> Result<(), Box<dyn Error>> {
.with_denom_b(bruhtoken)
.send()?;

let pool = ctx.get_astroport_pool(
"untrn",
ctx.get_tokenfactory_denom(ACC_0_ADDR, TEST_TOKEN_2_NAME),
)?;
let pool = ctx
.get_astro_pool()
.denoms(
"untrn".to_owned(),
ctx.get_tokenfactory_denom()
.creator(ACC_0_ADDR)
.subdenom(TEST_TOKEN_2_NAME.to_owned())
.get(),
)
.get_cw();

assert!(pool
.query_value(&serde_json::json!({
Expand Down Expand Up @@ -140,8 +166,9 @@ fn main() -> Result<(), Box<dyn Error>> {
.send()?;

let factory_contract_code_id = ctx
.get_contract("astroport_whitelist")
.unwrap()
.get_contract()
.contract("astroport_whitelist")
.get_cw()
.code_id
.unwrap();

Expand All @@ -165,7 +192,7 @@ fn main() -> Result<(), Box<dyn Error>> {
.salt_hex_encoded(hex::encode("examplesalt").as_str())
.get();

let mut cw = ctx.get_contract("astroport_whitelist").unwrap();
let mut cw = ctx.get_contract().contract("astroport_whitelist").get_cw();
cw.contract_addr = Some(addr);

cw.execute(
Expand Down
25 changes: 21 additions & 4 deletions examples/neutron_osmosis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ fn main() -> Result<(), Box<dyn Error>> {
.with_chain_name("neutron")
.with_subdenom("bruhtoken")
.send()?;
let bruhtoken = ctx.get_tokenfactory_denom(NEUTRON_ACC_0_ADDR, "bruhtoken");
let bruhtoken = ctx
.get_tokenfactory_denom()
.creator(NEUTRON_ACC_0_ADDR)
.subdenom("bruhtoken".into())
.get();
ctx.build_tx_mint_tokenfactory_token()
.with_chain_name("neutron")
.with_amount(10000000000000000000)
Expand All @@ -53,8 +57,18 @@ fn main() -> Result<(), Box<dyn Error>> {
.with_amount(1000000)
.send()?;

let ibc_bruhtoken = ctx.get_ibc_denom(&bruhtoken, "neutron", "osmosis");
let ibc_neutron = ctx.get_ibc_denom("untrn", "neutron", "osmosis");
let ibc_bruhtoken = ctx
.get_ibc_denom()
.base_denom(bruhtoken.clone())
.src("neutron")
.dest("osmosis")
.get();
let ibc_neutron = ctx
.get_ibc_denom()
.base_denom("untrn".into())
.src("neutron")
.dest("osmosis")
.get();

// Create an osmosis pool
ctx.build_tx_create_osmo_pool()
Expand All @@ -65,7 +79,10 @@ fn main() -> Result<(), Box<dyn Error>> {
.send()?;

// Get its id
let pool_id = ctx.get_osmo_pool(&ibc_neutron, &ibc_bruhtoken)?;
let pool_id = ctx
.get_osmo_pool()
.denoms(ibc_neutron.clone(), ibc_bruhtoken.clone())
.get_u64();

// Fund the pool
ctx.build_tx_fund_osmo_pool()
Expand Down
11 changes: 9 additions & 2 deletions examples/osmosis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ fn main() -> Result<(), Box<dyn Error>> {
.with_chain_name(OSMOSIS_CHAIN_NAME)
.with_subdenom("bruhtoken")
.send()?;
let bruhtoken = ctx.get_tokenfactory_denom(ACC_0_ADDR, "bruhtoken");
let bruhtoken = ctx
.get_tokenfactory_denom()
.creator(ACC_0_ADDR)
.subdenom("bruhtoken".into())
.get();
ctx.build_tx_mint_tokenfactory_token()
.with_chain_name(OSMOSIS_CHAIN_NAME)
.with_amount(10000000000000000000)
Expand All @@ -38,7 +42,10 @@ fn main() -> Result<(), Box<dyn Error>> {
.send()?;

// Get its id
let pool_id = ctx.get_osmo_pool("uosmo", &bruhtoken)?;
let pool_id = ctx
.get_osmo_pool()
.denoms("uosmo".into(), bruhtoken.clone())
.get_u64();

// Fund the pool
ctx.build_tx_fund_osmo_pool()
Expand Down
Loading

0 comments on commit 7e13dc9

Please sign in to comment.