Skip to content

Commit

Permalink
update linting configurations (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalojoec authored Oct 24, 2024
1 parent c62c2bd commit 045f161
Show file tree
Hide file tree
Showing 18 changed files with 30 additions and 43 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion clients/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ license-file = "../../LICENSE"
[features]
anchor = ["dep:anchor-lang"]
test-sbf = []
serde = ["dep:serde", "dep:serde_with"]
serde = ["dep:serde", "dep:serde_with", "kaigan/serde"]

[dependencies]
anchor-lang = { version = "0.30.0", optional = true }
Expand Down
25 changes: 0 additions & 25 deletions clients/rust/src/generated/accounts/address_lookup_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,28 +62,3 @@ impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for AddressLook
Self::deserialize(&mut data)
}
}

#[cfg(feature = "anchor")]
impl anchor_lang::AccountDeserialize for AddressLookupTable {
fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result<Self> {
Ok(Self::deserialize(buf)?)
}
}

#[cfg(feature = "anchor")]
impl anchor_lang::AccountSerialize for AddressLookupTable {}

#[cfg(feature = "anchor")]
impl anchor_lang::Owner for AddressLookupTable {
fn owner() -> Pubkey {
crate::ADDRESS_LOOKUP_TABLE_ID
}
}

#[cfg(feature = "anchor-idl-build")]
impl anchor_lang::IdlBuild for AddressLookupTable {}

#[cfg(feature = "anchor-idl-build")]
impl anchor_lang::Discriminator for AddressLookupTable {
const DISCRIMINATOR: [u8; 8] = [0; 8];
}
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl<'a, 'b> CloseLookupTableCpi<'a, 'b> {
accounts,
data,
};
let mut account_infos = Vec::with_capacity(3 + 1 + remaining_accounts.len());
let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len());
account_infos.push(self.__program.clone());
account_infos.push(self.address.clone());
account_infos.push(self.authority.clone());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ impl<'a, 'b> CreateLookupTableCpi<'a, 'b> {
accounts,
data,
};
let mut account_infos = Vec::with_capacity(4 + 1 + remaining_accounts.len());
let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len());
account_infos.push(self.__program.clone());
account_infos.push(self.address.clone());
account_infos.push(self.authority.clone());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl<'a, 'b> DeactivateLookupTableCpi<'a, 'b> {
accounts,
data,
};
let mut account_infos = Vec::with_capacity(2 + 1 + remaining_accounts.len());
let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len());
account_infos.push(self.__program.clone());
account_infos.push(self.address.clone());
account_infos.push(self.authority.clone());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ impl<'a, 'b> ExtendLookupTableCpi<'a, 'b> {
accounts,
data,
};
let mut account_infos = Vec::with_capacity(4 + 1 + remaining_accounts.len());
let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len());
account_infos.push(self.__program.clone());
account_infos.push(self.address.clone());
account_infos.push(self.authority.clone());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl<'a, 'b> FreezeLookupTableCpi<'a, 'b> {
accounts,
data,
};
let mut account_infos = Vec::with_capacity(2 + 1 + remaining_accounts.len());
let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len());
account_infos.push(self.__program.clone());
account_infos.push(self.address.clone());
account_infos.push(self.authority.clone());
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"devDependencies": {
"@codama/renderers-js": "^1.0.0",
"@codama/renderers-rust": "^1.0.0",
"@codama/renderers-rust": "^1.0.3",
"@iarna/toml": "^2.2.5",
"codama": "^1.0.0",
"typescript": "^5.5.2",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@ crate-type = ["cdylib", "lib"]

[build-dependencies]
rustc_version = "0.4"

[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = [
'cfg(target_os, values("solana"))',
'cfg(feature, values("min_specialization"))',
'cfg(RUSTC_WITH_SPECIALIZATION)',
]
2 changes: 1 addition & 1 deletion program/tests/create_lookup_table_ix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn test_create_lookup_table_idempotent() {
lookup_table_account.lamports(),
Rent::default().minimum_balance(LOOKUP_TABLE_META_SIZE)
);
let lookup_table = AddressLookupTable::deserialize(&lookup_table_account.data()).unwrap();
let lookup_table = AddressLookupTable::deserialize(lookup_table_account.data()).unwrap();
assert_eq!(lookup_table.meta.deactivation_slot, Slot::MAX);
assert_eq!(lookup_table.meta.authority, Some(authority));
assert_eq!(lookup_table.meta.last_extended_slot, 0);
Expand Down
2 changes: 1 addition & 1 deletion program/tests/deactivate_lookup_table_ix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn test_deactivate_lookup_table() {

let lookup_table_account = result.get_account(&lookup_table_address).unwrap();

let lookup_table = AddressLookupTable::deserialize(&lookup_table_account.data()).unwrap();
let lookup_table = AddressLookupTable::deserialize(lookup_table_account.data()).unwrap();
assert_eq!(lookup_table.meta.deactivation_slot, 0);

// Check that only the deactivation slot changed
Expand Down
2 changes: 1 addition & 1 deletion program/tests/extend_lookup_table_ix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn run_test_case(mollusk: &Mollusk, test_case: TestCase) {
assert!(matches!(result.program_result, ProgramResult::Success));

let table_account = result.get_account(&test_case.lookup_table_address).unwrap();
let lookup_table = AddressLookupTable::deserialize(&table_account.data()).unwrap();
let lookup_table = AddressLookupTable::deserialize(table_account.data()).unwrap();
assert_eq!(lookup_table, expected_account.state);
assert_eq!(table_account.lamports(), expected_account.lamports);
assert_eq!(table_account.data().len(), expected_account.data_len);
Expand Down
2 changes: 1 addition & 1 deletion program/tests/freeze_lookup_table_ix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn test_freeze_lookup_table() {
);

let lookup_table_account = result.get_account(&lookup_table_address).unwrap();
let lookup_table = AddressLookupTable::deserialize(&lookup_table_account.data()).unwrap();
let lookup_table = AddressLookupTable::deserialize(lookup_table_account.data()).unwrap();

assert_eq!(lookup_table.meta.authority, None);

Expand Down
2 changes: 2 additions & 0 deletions scripts/client/lint-rust.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
// Configure arguments here.
const lintArgs = [
'-Zunstable-options',
'--all-targets',
'--all-features',
'--',
'--deny=warnings',
...cliArguments(),
Expand Down
1 change: 1 addition & 0 deletions scripts/generate-clients.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ codama.accept(
const rustClient = path.join(__dirname, '..', 'clients', 'rust');
codama.accept(
renderRustVisitor(path.join(rustClient, 'src', 'generated'), {
anchorTraits: false,
formatCode: true,
crateFolder: rustClient,
toolchain: getToolchainArgument('format'),
Expand Down
4 changes: 2 additions & 2 deletions scripts/program/lint.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
// Configure arguments here.
const lintArgs = [
'-Zunstable-options',
'--features',
'bpf-entrypoint,test-sbf',
'--all-targets',
'--all-features',
'--',
'--deny=warnings',
'--deny=clippy::arithmetic_side_effects',
Expand Down

0 comments on commit 045f161

Please sign in to comment.