diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 165e518..056cff9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,6 +19,7 @@ jobs: uses: dtolnay/rust-toolchain@stable with: targets: wasm32v1-none + components: clippy, rustfmt - name: Cache cargo registry and build output uses: actions/cache@v6 @@ -31,6 +32,14 @@ jobs: restore-keys: | ${{ runner.os }}-cargo- + - name: Check formatting + working-directory: soroban + run: cargo fmt --all -- --check + + - name: Run clippy + working-directory: soroban + run: cargo clippy --workspace --all-targets -- -D warnings + - name: Run tests working-directory: soroban run: cargo test --workspace diff --git a/soroban/contracts/factory/src/test.rs b/soroban/contracts/factory/src/test.rs index b703e2b..a2f5e89 100644 --- a/soroban/contracts/factory/src/test.rs +++ b/soroban/contracts/factory/src/test.rs @@ -567,7 +567,7 @@ fn test_get_pool_bumps_pool_record_ttl() { advance_ledgers(&t.env, TTL_EXTEND_TO - TTL_THRESHOLD + 1); assert!(pool_record_ttl(&t.env, &t.factory_addr, id) < TTL_THRESHOLD); - assert_eq!(t.client.try_get_pool(&id).is_ok(), true); + assert!(t.client.try_get_pool(&id).is_ok()); assert_eq!(pool_record_ttl(&t.env, &t.factory_addr, id), TTL_EXTEND_TO); } diff --git a/soroban/contracts/farming-pool/src/lib.rs b/soroban/contracts/farming-pool/src/lib.rs index be5ada0..abbccaa 100644 --- a/soroban/contracts/farming-pool/src/lib.rs +++ b/soroban/contracts/farming-pool/src/lib.rs @@ -216,6 +216,7 @@ impl FarmingPool { bump_instance(&env); env.storage().instance().set(&DataKey::Admin, &new_admin); + #[allow(deprecated)] env.events().publish( (symbol_short!("pool"), symbol_short!("adm_xfr")), (current, new_admin), @@ -250,11 +251,12 @@ impl FarmingPool { let stake_token = get_stake_token(&env)?; token::TokenClient::new(&env, &stake_token).transfer( &user, - &env.current_contract_address(), + env.current_contract_address(), &amount, ); set_position(&env, &user, &position); + #[allow(deprecated)] env.events().publish( (symbol_short!("pool"), symbol_short!("locked")), (user, amount), @@ -295,6 +297,7 @@ impl FarmingPool { set_position(&env, &user, &position); } + #[allow(deprecated)] env.events().publish( (symbol_short!("pool"), symbol_short!("unlocked")), (user, amount, total_credits), @@ -327,6 +330,7 @@ impl FarmingPool { get_admin(&env)?.require_auth(); bump_instance(&env); env.storage().instance().set(&DataKey::Paused, &true); + #[allow(deprecated)] env.events() .publish((symbol_short!("pool"), symbol_short!("paused")), ()); Ok(()) @@ -337,6 +341,7 @@ impl FarmingPool { get_admin(&env)?.require_auth(); bump_instance(&env); env.storage().instance().set(&DataKey::Paused, &false); + #[allow(deprecated)] env.events() .publish((symbol_short!("pool"), symbol_short!("unpaused")), ()); Ok(()) @@ -384,6 +389,7 @@ impl FarmingPool { set_banked_credits(&env, &user, banked_credits); } + #[allow(deprecated)] env.events().publish( (symbol_short!("pool"), symbol_short!("emrg_exit")), (admin, user, total_returned), @@ -427,7 +433,7 @@ impl FarmingPool { let stake_token = get_stake_token(&env)?; token::TokenClient::new(&env, &stake_token).transfer( &from, - &env.current_contract_address(), + env.current_contract_address(), &amount, ); @@ -461,7 +467,7 @@ impl FarmingPool { assert!(!pool_is_paused(&env), "pool is paused"); require_initialized(&env)?; assert!( - allocation_pct >= 1 && allocation_pct <= 100, + (1..=100).contains(&allocation_pct), "allocation_pct must be 1-100" ); bump_instance(&env); @@ -476,6 +482,7 @@ impl FarmingPool { bump_user(&env, &key); let multiplier = read_global_multiplier(&env); + #[allow(deprecated)] env.events().publish( (symbol_short!("boost"), symbol_short!("applied")), (user, allocation_pct, multiplier), @@ -503,6 +510,7 @@ impl FarmingPool { env.storage() .instance() .set(&DataKey::GlobalMultiplier, &multiplier); + #[allow(deprecated)] env.events().publish( (symbol_short!("boost"), symbol_short!("mult_set")), multiplier, @@ -522,6 +530,7 @@ impl FarmingPool { env.storage() .instance() .set(&DataKey::CreditRate, &new_rate); + #[allow(deprecated)] env.events().publish( (symbol_short!("pool"), symbol_short!("rate_set")), (old_rate, new_rate), @@ -538,6 +547,7 @@ impl FarmingPool { env.storage() .instance() .set(&DataKey::MinLockPeriod, &new_period); + #[allow(deprecated)] env.events().publish( (symbol_short!("pool"), symbol_short!("lock_set")), (old_period, new_period),