Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] Refactor Queries.rs to All TestContextQuery #25

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2021"
[dependencies]
localic-std = { git = "https://github.com/strangelove-ventures/interchaintest", branch = "main" }
cosmwasm-std = "1.5.5"
osmosis-std = "0.25.0"
serde = { version = "1.0.204", features = ["derive"] }
serde_json = "1.0.120"
thiserror = "1.0.61"
Expand All @@ -14,6 +15,7 @@ log = "0.4.22"
astroport = "5.1.0"
reqwest = { version = "0.11.20", features = ["rustls-tls"] }
sha2 = "0.10.8"
base64 = "0.22.1"

[dev-dependencies]
env_logger = "0.11.3"
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ Note that most `tx_*` helper functions expose a `.with_key(key: &str)` builder f
* `.with_msg(msg: serde_json::Value)`
* `.with_label(label: &str)`
* Notable optional builder calls:
* `.with_chain_name(chain_name: impl Into<String>)` - Should be one of `"osmosis" | "neutron"` or one of the registered chain names from `.with_chain`
* `.with_chain(chain_name: impl Into<String>)` - Should be one of `"osmosis" | "neutron"` or one of the registered chain names from `.with_chain`

#### Tokens

* `.build_tx_create_tokenfactory_token` - Creates a tokenfactory token from `acc0` on Neutron by default.
* Required builder calls:
* `.with_subdenom(subdenom: &str)`
* Notable optional builder calls:
* `.with_chain_name(chain_name: impl Into<String>)` - Should be one of `"osmosis" | "neutron" | "stride"` or one of the registered chain names from `.with_chain`
* `.with_chain(chain_name: impl Into<String>)` - Should be one of `"osmosis" | "neutron" | "stride"` or one of the registered chain names from `.with_chain`
* `.get_tokenfactory_denom(key: &str, subdenom: &str)` - Gets the tokenfactory denom of a tokenfactory token given its subdenom and key
* `.build_tx_mint_tokenfactory_token` - Mints a tokenfactory token from `acc0` on Neutron by default.
* Required builder calls
Expand All @@ -124,7 +124,7 @@ Note that most `tx_*` helper functions expose a `.with_key(key: &str)` builder f
* Required builder calls for osmosis
* `.with_recipient_addr(addr: &str)` - Specifies a recipient of the minted tokens on Osmosis. This builder call does nothing on Neutron.
* Notable optional builder calls:
* `.with_chain_name(chain_name: impl Into<String>)` - Specifies which chain to mint the tokens on. See previous notes about chain names.
* `.with_chain(chain_name: impl Into<String>)` - Specifies which chain to mint the tokens on. See previous notes about chain names.

#### Auctions

Expand Down
16 changes: 14 additions & 2 deletions examples/chains/neutron_gaia.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
"binary": "osmosisd",
"bech32_prefix": "osmo",
"docker_image": {
"version": "v25.0.4",
"version": "v21.0.0",
"repository": "ghcr.io/strangelove-ventures/heighliner/osmosis"
},
"gas_prices": "0.0025%DENOM%",
Expand All @@ -177,15 +177,27 @@
"1317": "1319",
"9090": "9092"
},
"config_file_overrides": [
{
"file": "config/app.toml",
"paths": {
"osmosis-mempool.max-gas-wanted-per-tx": "10000000000"
}
}
],
"genesis": {
"modify": [
{
"key": "consensus_params.block.max_gas",
"value": "10000000000"
},
{
"key": "app_state.gov.params.voting_period",
"value": "3s"
},
{
"key": "app_state.gov.params.max_deposit_period",
"value": "15s"
"value": "3s"
},
{
"key": "app_state.gov.params.min_deposit.0.denom",
Expand Down
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.
65 changes: 46 additions & 19 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 = "bruhtoken";
const TEST_TOKEN_2_NAME: &str = "amoguscoin";

/// Demonstrates using localic-utils for neutron.
fn main() -> Result<(), Box<dyn Error>> {
Expand Down 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
Loading
Loading