Skip to content

Commit

Permalink
chore: remove token_factory feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
kerber0x committed Mar 12, 2024
1 parent 78597cf commit 48ff2d3
Show file tree
Hide file tree
Showing 38 changed files with 147 additions and 393 deletions.
62 changes: 56 additions & 6 deletions .github/workflows/ci-test-fmt-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ env:
CARGO_TERM_COLOR: always

jobs:
test_and_check-token_factory_feature:
name: Test and check Token factory feature
test_and_check-vanilla:
name: Test and check vanilla
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -43,11 +43,61 @@ jobs:
override: true
components: rustfmt, clippy

- name: Run cargo-tarpaulin token_factory feature
- name: Run cargo-tarpaulin vanilla
uses: actions-rs/[email protected]
with:
version: "0.15.0"
args: '--features "token_factory" --locked -- --test-threads 4'
args: '--locked -- --test-threads 4'

- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --locked -- -D warnings

#- name: Run cosmwasm linter
# run: cargo dylint cw_lint --workspace

- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

test_and_check-osmosis_token_factory_feature:
name: Test and check Osmosis Token factory feature
runs-on: ubuntu-latest

steps:
# Cancel any existing runs to save on CI time
# - name: Cancel Previous Runs
# uses: styfle/[email protected]
# with:
# access_token: ${{ github.token }}
# Checkout code, with submodules using PAT
- name: Checkout sources
uses: actions/checkout@v3

# Use Rust Cache to speed up subsequent jobs with no cargo lock changes
- name: Use Rust cache
uses: Swatinem/rust-cache@v2
with:
key: "test"

# Install rust
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.70.0
override: true
components: rustfmt, clippy

- name: Run cargo-tarpaulin osmosis_token_factory feature
uses: actions-rs/[email protected]
with:
version: "0.15.0"
args: '--features "osmosis_token_factory" --locked -- --test-threads 4'

- name: Upload to codecov.io
uses: codecov/codecov-action@v3
Expand All @@ -59,7 +109,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: clippy
args: --locked -- -D warnings
args: --features "osmosis_token_factory" --locked -- -D warnings

#- name: Run cosmwasm linter
# run: cargo dylint cw_lint --workspace
Expand Down Expand Up @@ -115,7 +165,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: clippy
args: --locked -- -D warnings
args: --features "injective" --locked -- -D warnings

#- name: Run cosmwasm linter
# run: cargo dylint cw_lint --workspace
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/release-artifacts-on-tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@ jobs:
uses: actions/checkout@v2
with:
submodules: recursive
- name: Build Artifacts
- name: Build Artifacts vanilla
run: |
$GITHUB_WORKSPACE/scripts/build_release.sh -c vanilla
tar -zcvf cosmwasm-artifacts_no-token-factory.tar.gz artifacts
- name: Build Artifacts osmosis_token_factory
run: |
$GITHUB_WORKSPACE/scripts/build_release.sh -c migaloo
tar -zcvf cosmwasm-artifacts_osmosis_token_factory.tar.gz artifacts
- name: Build Artifacts injective
run: |
$GITHUB_WORKSPACE/scripts/build_release.sh -c injective
tar -zcvf cosmwasm-artifacts_injective.tar.gz artifacts
- name: Get Artifacts Versions
run: $GITHUB_WORKSPACE/scripts/get_artifacts_versions.sh > artifact_versions.txt
- name: Create Release
Expand All @@ -27,4 +35,6 @@ jobs:
generate_release_notes: true
files: |
cosmwasm-artifacts_no-token-factory.tar.gz
cosmwasm-artifacts_osmosis_token_factory.tar.gz
cosmwasm-artifacts_injective.tar.gz
artifact_versions.txt
1 change: 0 additions & 1 deletion contracts/liquidity_hub/epoch-manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ exclude = [
crate-type = ["cdylib", "rlib"]

[features]
token_factory = ["white-whale-std/token_factory"]
osmosis_token_factory = ["white-whale-std/osmosis_token_factory"]
injective = ["white-whale-std/injective"]
osmosis = ["osmosis_token_factory"]
Expand Down
1 change: 0 additions & 1 deletion contracts/liquidity_hub/fee-distributor-mock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ overflow-checks = true
[features]
injective = ["white-whale-std/injective"]
osmosis = ["osmosis_token_factory"]
token_factory = ["white-whale-std/token_factory"]
osmosis_token_factory = ["white-whale-std/osmosis_token_factory"]
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all instantiate/execute/query exports
Expand Down
1 change: 0 additions & 1 deletion contracts/liquidity_hub/fee_collector/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ crate-type = ["cdylib", "rlib"]
[features]
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]
token_factory = ["white-whale-std/token_factory"]
osmosis_token_factory = ["white-whale-std/osmosis_token_factory"]
injective = ["white-whale-std/injective"]
osmosis = ["osmosis_token_factory"]
Expand Down
1 change: 0 additions & 1 deletion contracts/liquidity_hub/fee_distributor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ crate-type = ["cdylib", "rlib"]
[features]
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]
token_factory = ["white-whale-std/token_factory"]
osmosis_token_factory = ["white-whale-std/osmosis_token_factory"]
injective = ["white-whale-std/injective"]
osmosis = ["osmosis_token_factory"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ crate-type = ["cdylib", "rlib"]
[features]
injective = ["white-whale-std/injective"]
osmosis = ["osmosis_token_factory"]
token_factory = ["white-whale-std/token_factory"]
osmosis_token_factory = ["white-whale-std/osmosis_token_factory"]
# for quicker tests, cargo test --lib
# for more explicit tests, cargo test --features=backtraces
Expand Down
1 change: 0 additions & 1 deletion contracts/liquidity_hub/pool-network/incentive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ crate-type = ["cdylib", "rlib"]
[features]
injective = ["white-whale-std/injective"]
osmosis = ["osmosis_token_factory"]
token_factory = ["white-whale-std/token_factory"]
osmosis_token_factory = ["white-whale-std/osmosis_token_factory"]
# for quicker tests, cargo test --lib
# for more explicit tests, cargo test --features=backtraces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ crate-type = ["cdylib", "rlib"]
[features]
injective = ["white-whale-std/injective"]
osmosis = ["osmosis_token_factory"]
token_factory = ["white-whale-std/token_factory"]
osmosis_token_factory = ["white-whale-std/osmosis_token_factory"]
# for quicker tests, cargo test --lib
# for more explicit tests, cargo test --features=backtraces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ crate-type = ["cdylib", "rlib"]
[features]
injective = ["white-whale-std/injective"]
osmosis = ["osmosis_token_factory"]
token_factory = ["white-whale-std/token_factory"]
osmosis_token_factory = ["white-whale-std/osmosis_token_factory"]
# for quicker tests, cargo test --lib
# for more explicit tests, cargo test --features=backtraces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,13 @@ use cosmwasm_std::{
use cw20::{Cw20ExecuteMsg, Cw20ReceiveMsg};

use crate::contract::{MAX_AMP, MAX_AMP_CHANGE, MIN_AMP, MIN_RAMP_BLOCKS};
#[cfg(any(
feature = "token_factory",
feature = "osmosis_token_factory",
feature = "injective"
))]
#[cfg(any(feature = "osmosis_token_factory", feature = "injective"))]
use cosmwasm_std::coins;
#[cfg(any(
feature = "token_factory",
feature = "osmosis_token_factory",
feature = "injective"
))]
#[cfg(any(feature = "osmosis_token_factory", feature = "injective"))]
use white_whale_std::pool_network::asset::is_factory_token;
use white_whale_std::pool_network::asset::{
Asset, AssetInfo, AssetInfoRaw, TrioInfoRaw, MINIMUM_LIQUIDITY_AMOUNT,
};
#[cfg(feature = "token_factory")]
use white_whale_std::pool_network::denom::{Coin, MsgBurn, MsgMint};
#[cfg(feature = "injective")]
use white_whale_std::pool_network::denom_injective::{Coin, MsgBurn, MsgMint};
#[cfg(feature = "osmosis_token_factory")]
Expand Down Expand Up @@ -670,11 +660,7 @@ fn mint_lp_token_msg(
sender: String,
amount: Uint128,
) -> Result<Vec<CosmosMsg>, ContractError> {
#[cfg(any(
feature = "token_factory",
feature = "osmosis_token_factory",
feature = "injective"
))]
#[cfg(any(feature = "osmosis_token_factory", feature = "injective"))]
if is_factory_token(liquidity_token.as_str()) {
let mut messages = vec![];
messages.push(<MsgMint as Into<CosmosMsg>>::into(MsgMint {
Expand All @@ -701,11 +687,7 @@ fn mint_lp_token_msg(
})])
}

#[cfg(all(
not(feature = "token_factory"),
not(feature = "osmosis_token_factory"),
not(feature = "injective")
))]
#[cfg(all(not(feature = "osmosis_token_factory"), not(feature = "injective")))]
Ok(vec![CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: liquidity_token,
msg: to_json_binary(&Cw20ExecuteMsg::Mint { recipient, amount })?,
Expand All @@ -720,11 +702,7 @@ fn burn_lp_token_msg(
sender: String,
amount: Uint128,
) -> Result<CosmosMsg, ContractError> {
#[cfg(any(
feature = "token_factory",
feature = "osmosis_token_factory",
feature = "injective"
))]
#[cfg(any(feature = "osmosis_token_factory", feature = "injective"))]
if is_factory_token(liquidity_token.as_str()) {
Ok(<MsgBurn as Into<CosmosMsg>>::into(MsgBurn {
sender,
Expand All @@ -741,11 +719,7 @@ fn burn_lp_token_msg(
}))
}

#[cfg(all(
not(feature = "token_factory"),
not(feature = "osmosis_token_factory"),
not(feature = "injective")
))]
#[cfg(all(not(feature = "osmosis_token_factory"), not(feature = "injective")))]
Ok(CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: liquidity_token,
msg: to_json_binary(&Cw20ExecuteMsg::Burn { amount })?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,11 @@ use cosmwasm_std::{
use cw20::MinterResponse;
use cw_storage_plus::Item;

#[cfg(any(
feature = "token_factory",
feature = "osmosis_token_factory",
feature = "injective"
))]
#[cfg(any(feature = "osmosis_token_factory", feature = "injective"))]
use cosmwasm_std::CosmosMsg;
#[cfg(any(
feature = "token_factory",
feature = "osmosis_token_factory",
feature = "injective"
))]
#[cfg(any(feature = "osmosis_token_factory", feature = "injective"))]
use white_whale_std::pool_network::asset::is_factory_token;
use white_whale_std::pool_network::asset::{Asset, AssetInfo, AssetInfoRaw};
#[cfg(feature = "token_factory")]
use white_whale_std::pool_network::denom::MsgCreateDenom;
#[cfg(feature = "injective")]
use white_whale_std::pool_network::denom_injective::MsgCreateDenom;
#[cfg(feature = "osmosis_token_factory")]
Expand Down Expand Up @@ -277,11 +267,7 @@ pub fn instantiate_fees(

/// Gets the total supply of the given liquidity token
pub fn get_total_share(deps: &Deps, liquidity_token: String) -> StdResult<Uint128> {
#[cfg(any(
feature = "token_factory",
feature = "osmosis_token_factory",
feature = "injective"
))]
#[cfg(any(feature = "osmosis_token_factory", feature = "injective"))]
let total_share = if is_factory_token(liquidity_token.as_str()) {
//bank query total
deps.querier.query_supply(&liquidity_token)?.amount
Expand All @@ -292,11 +278,7 @@ pub fn get_total_share(deps: &Deps, liquidity_token: String) -> StdResult<Uint12
)?
.total_supply
};
#[cfg(all(
not(feature = "token_factory"),
not(feature = "osmosis_token_factory"),
not(feature = "injective")
))]
#[cfg(all(not(feature = "osmosis_token_factory"), not(feature = "injective")))]
let total_share = query_token_info(
&deps.querier,
deps.api.addr_validate(liquidity_token.as_str())?,
Expand All @@ -322,11 +304,7 @@ pub fn create_lp_token(
Ok(trio_info)
})?;

#[cfg(any(
feature = "token_factory",
feature = "osmosis_token_factory",
feature = "injective"
))]
#[cfg(any(feature = "osmosis_token_factory", feature = "injective"))]
return Ok(
Response::new().add_message(<MsgCreateDenom as Into<CosmosMsg>>::into(
MsgCreateDenom {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::contract::{execute, instantiate, reply};
use crate::error::ContractError;
#[cfg(feature = "token_factory")]
#[cfg(feature = "osmosis_token_factory")]
use crate::state::LP_SYMBOL;
use cosmwasm_std::testing::{mock_env, mock_info, MOCK_CONTRACT_ADDR};
#[cfg(feature = "token_factory")]
#[cfg(feature = "osmosis_token_factory")]
use cosmwasm_std::{coin, BankMsg};
use cosmwasm_std::{
to_json_binary, Coin, CosmosMsg, Decimal, Reply, Response, StdError, SubMsg, SubMsgResponse,
Expand All @@ -12,8 +12,8 @@ use cosmwasm_std::{
use cw20::Cw20ExecuteMsg;
use white_whale_std::fee::Fee;
use white_whale_std::pool_network::asset::{Asset, AssetInfo, MINIMUM_LIQUIDITY_AMOUNT};
#[cfg(feature = "token_factory")]
use white_whale_std::pool_network::denom::MsgMint;
#[cfg(feature = "osmosis_token_factory")]
use white_whale_std::pool_network::denom_osmosis::MsgMint;
use white_whale_std::pool_network::mock_querier::mock_dependencies;
use white_whale_std::pool_network::trio::{ExecuteMsg, InstantiateMsg, PoolFee};

Expand Down Expand Up @@ -548,7 +548,7 @@ fn provide_liquidity_cw20_lp() {
let _res = execute(deps.as_mut(), env, info, msg).unwrap();
}

#[cfg(feature = "token_factory")]
#[cfg(feature = "osmosis_token_factory")]
#[test]
fn provide_liquidity_token_factory_lp() {
let lp_denom = format!("{}/{MOCK_CONTRACT_ADDR}/{LP_SYMBOL}", "factory");
Expand Down Expand Up @@ -661,15 +661,15 @@ fn provide_liquidity_token_factory_lp() {

let mint_initial_lp_msg_expected = <MsgMint as Into<CosmosMsg>>::into(MsgMint {
sender: MOCK_CONTRACT_ADDR.to_string(),
amount: Some(white_whale_std::pool_network::denom::Coin {
amount: Some(white_whale_std::pool_network::denom_osmosis::Coin {
denom: lp_denom.clone(),
amount: (MINIMUM_LIQUIDITY_AMOUNT * Uint128::from(3u8)).to_string(),
}),
});

let mint_msg_expected = <MsgMint as Into<CosmosMsg>>::into(MsgMint {
sender: MOCK_CONTRACT_ADDR.to_string(),
amount: Some(white_whale_std::pool_network::denom::Coin {
amount: Some(white_whale_std::pool_network::denom_osmosis::Coin {
denom: lp_denom.clone(),
amount: "6000".to_string(),
}),
Expand Down
Loading

0 comments on commit 48ff2d3

Please sign in to comment.