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

update linting configurations #35

Merged
merged 3 commits into from
Oct 24, 2024
Merged

update linting configurations #35

merged 3 commits into from
Oct 24, 2024

Conversation

buffalojoec
Copy link
Contributor

Summary of Changes

Adds a config to the program's manifest for ignoring unexpected_cfg (like target_os = "solana"). Also adjusts the linting scripts to cover all targets and features.

@@ -10,6 +10,7 @@ import {
// Configure arguments here.
const lintArgs = [
'-Zunstable-options',
'--all-targets',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to add --all-features here as well, but looks like maybe we're not configuring kaigan serde support properly?

the trait `generated::accounts::address_lookup_table::_::_serde::Deserialize<'_>` is not implemented for `kaigan::types::U64PrefixVec<solana_program::pubkey::Pubkey>`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nvm, I added the fix for this. But I found another clippy error for the Anchor one.

expected `anchor_lang::prelude::Pubkey`, found `solana_program::pubkey::Pubkey`
   |                   help: change the output type to match the trait: `anchor_lang::prelude::Pubkey`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might need to adjust the renderer @lorisleiva so that it uses more Anchor-compatible types, or can somehow tell rustc that the types are the same. Maybe it's a versioning thing?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'm not sure I understand what you'd like to adjust. Could you share the bit of code that is causing this clippy error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a clippy error that arises if you pass --all-features, which runs lint on the anchor feature.

Looks like it's because Anchor 0.30 runs solana-program v1.16.
https://github.com/coral-xyz/anchor/blob/852fcc77beb6302474a11e0f8e6f1e688021be36/lang/Cargo.toml#L60

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I guess we just have to make sure create-solana-program generates a template with compatible SDK versions for Anchor, or remove the Anchor support from the base template.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see what you mean.

The way create-solana-program figures out versioning is by checking the version of your local binaries. So if you end up with incompatible versions, it should mean that the versions you had locally were incompatible at the time of generating the repo.

Recently, we added a new option on the Rust renderer that turns off any Anchor-related traits so you don't need to have any dependency on Anchor. So maybe we should use that here.

Copy link
Contributor Author

@buffalojoec buffalojoec Oct 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh perfect! I just added the new renderer.

@@ -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"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lorisleiva this optional feature-flag for kaigan is only necessary when the user adds kaigan types to the repository. This is a manual step, right? Would they be configuring Codama to use kaigan as well?

Asking because it doesn't seem like there's a good place to work this into create-solana-program.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is a manual step that you only need to do if you end up using more complex types that are defined in Kaigan.

Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Just a little question about the ignore cfgs

program/Cargo.toml Show resolved Hide resolved
@buffalojoec buffalojoec merged commit 045f161 into main Oct 24, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants