Skip to content
Merged
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
6 changes: 4 additions & 2 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ jobs:
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt
- name: Check formatting
run: cargo fmt -- --check
- name: Check formatting and clippy
run: |
cargo fmt -- --check
cargo clippy --all-targets -- -D warnings
build:
name: Build
runs-on: ubuntu-latest
Expand Down
32 changes: 32 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,35 @@ metrics = { version = "0.24.1", default-features = false }
metrics-exporter-prometheus = { version = "0.16.2", default-features = false }
dotenvy = "0.15.7"
utoipauto = "0.2.0"


[workspace.lints.clippy]
# should make procedural code more readable
needless_return = "allow"
# allow explicit testing
bool_assert_comparison = "allow"
# allow `len() checks`
len_zero = "allow"
# allow to use `match` to make code look consistent
single_match = "allow"
# allow use of base struct; needed for forward compatibility
needless_update = "allow"
# allow explict impl of `Default` trait
derivable_impls = "allow"
# allow +1 comparison
int_plus_one = "allow"
# allow structured `if`
collapsible_if = "allow"
# force use of `Arc::clone(p)` for clarity
clone_on_ref_ptr = "deny"
# prefer `copy` over reference for small types
trivially_copy_pass_by_ref = "deny"
# large error variant kept unboxed to preserve thiserror `#[from]` ergonomics
result_large_err = "allow"

[workspace.lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = [
'cfg(target_os, values("solana"))',
]

9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
.PHONY: run-server-example
.PHONY: cargofix run-server-example

cargofix:
@echo "Run Fmt+Clippy Fix ...."
cargo fix
# might need to use +nightly later if we want more rules
cargo fmt --all
cargo clippy --fix --all-targets -- -D warnings

run-example-server:
@echo "Running RFQ API..."
Expand Down
3 changes: 3 additions & 0 deletions order-engine-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ agave-reserved-account-keys = "~2"
base64 = { workspace = true }
bincode = { workspace = true }
anyhow = { workspace = true }

[lints]
workspace = true
8 changes: 4 additions & 4 deletions order-engine-sdk/src/fill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,14 +569,14 @@ mod tests {
let input_amount = 100;
let expire_at = 1000;
let input_mint = Pubkey::new_unique();
let taker_input_mint_token_account = Some(Pubkey::new_unique());
let taker_input_mint_token_account = Pubkey::new_unique();

let fill_ix = Instruction {
program_id: order_engine::ID,
accounts: order_engine::client::accounts::Fill {
taker,
maker,
taker_input_mint_token_account,
taker_input_mint_token_account: Some(taker_input_mint_token_account),
maker_input_mint_token_account: Some(Pubkey::new_unique()),
taker_output_mint_token_account: Some(Pubkey::new_unique()),
maker_output_mint_token_account: Some(Pubkey::new_unique()),
Expand All @@ -603,8 +603,7 @@ mod tests {
input_amount,
input_mint,
output_mint: fill_ix.accounts[8].pubkey,
taker_input_mint_token_account: taker_input_mint_token_account
.unwrap_or(order_engine::ID),
taker_input_mint_token_account,
expire_at,
};

Expand Down Expand Up @@ -729,6 +728,7 @@ mod tests {
);
}

#[allow(clippy::too_many_arguments)]
fn build_fill_ix(
taker: Pubkey,
maker: Pubkey,
Expand Down
7 changes: 2 additions & 5 deletions programs/order-engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ anchor-debug = []
custom-panic = []
production = []

[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = [
'cfg(target_os, values("solana"))',
]
[lints]
workspace = true

[dependencies]
anchor-lang = { workspace = true }
Expand Down
15 changes: 8 additions & 7 deletions programs/order-engine/tests/test_fill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ async fn prepare_test(test_mode: TestMode) -> TestEnvironment {

let banks_client = Arc::new(Mutex::new(banks_client));
let client = Arc::new(ProgramBanksClient::new_from_client(
banks_client.clone(),
Arc::clone(&banks_client),
ProgramBanksClientProcessTransaction,
));

Expand Down Expand Up @@ -341,7 +341,8 @@ async fn prepare_test(test_mode: TestMode) -> TestEnvironment {
let TestMode {
taker_accounts,
maker_accounts,
expected_error,
// asserted by the caller, which clones it before `prepare_test` consumes `test_mode`
expected_error: _,
input_mint_extensions,
output_mint_extensions,
} = test_mode;
Expand Down Expand Up @@ -460,11 +461,11 @@ async fn prepare_test(test_mode: TestMode) -> TestEnvironment {
anchor_spl::token::ID
};
let token_a = Token::new(
client.clone(),
Arc::<ProgramBanksClient<ProgramBanksClientProcessTransaction>>::clone(&client),
&token_a_program_id,
&mint_a,
Some(9),
payer.clone(),
Arc::<Keypair>::clone(&payer),
);
if let Some(mint_a_keypair) = &mint_a_keypair {
token_a
Expand All @@ -484,11 +485,11 @@ async fn prepare_test(test_mode: TestMode) -> TestEnvironment {
anchor_spl::token::ID
};
let token_b = Token::new(
client.clone(),
Arc::<ProgramBanksClient<ProgramBanksClientProcessTransaction>>::clone(&client),
&token_b_program_id,
&mint_b,
Some(9),
payer.clone(),
Arc::<Keypair>::clone(&payer),
);
if let Some(mint_b_keypair) = &mint_b_keypair {
token_b
Expand Down Expand Up @@ -621,7 +622,7 @@ pub async fn process_instructions(
signers: &[&Keypair],
banks_client: &Mutex<BanksClient>,
) -> std::result::Result<(), BanksClientError> {
let mut banks_client = banks_client.lock().await;
let banks_client = banks_client.lock().await;
let recent_blockhash = banks_client.get_latest_blockhash().await.unwrap();

let mut all_signers = vec![payer];
Expand Down
4 changes: 4 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
[toolchain]
channel = "1.87.0"
components = ["clippy", "rustfmt"]
targets = []
profile = "minimal"

3 changes: 3 additions & 0 deletions server-example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ solana-sdk = { workspace = true }
dotenvy = { workspace = true }
utoipauto = { workspace = true }
solana-rpc-client = { workspace = true }

[lints]
workspace = true
3 changes: 3 additions & 0 deletions squads-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ thiserror = { workspace = true }
[dev-dependencies]
solana-client = { workspace = true }
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }

[lints]
workspace = true
3 changes: 3 additions & 0 deletions webhook-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ serde = { workspace = true }
serde_json = { workspace = true }
strum = { workspace = true }
utoipa = { workspace = true, features = ["debug"] }

[lints]
workspace = true