Skip to content

feat: id attribute to account#3982

Closed
Otter-0x4ka5h wants to merge 2 commits intosolana-foundation:masterfrom
Otter-0x4ka5h:anchor#3942
Closed

feat: id attribute to account#3982
Otter-0x4ka5h wants to merge 2 commits intosolana-foundation:masterfrom
Otter-0x4ka5h:anchor#3942

Conversation

@Otter-0x4ka5h
Copy link
Copy Markdown
Contributor

  1. Added id field to AccountArgs struct
  2. Added Id variant to AccountArg enum
  3. implemented parsing for id = syntax
  4. Modified Owner trait to use custom ID when provided
  5. Added strong security warnings in documentation

The implementation also demonstrating declare_id! in doctests!

Closes #3942

@vercel
Copy link
Copy Markdown

vercel bot commented Oct 12, 2025

Someone is attempting to deploy a commit to the Solana Foundation Team on Vercel.

A member of the Team first needs to authorize it.

/// **Usage:** `id = <EXPR>`
///
/// **SECURITY WARNING:**
/// This parameter is ONLY intended for doctests and test code.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm not necessarily sure if introducing a new dangerous feature is the solution to a doctest issue. I think at minimum it should be gated and only enabled when building for tests.
Ideally though we'd find a way to make this just work without them needing to know about this special feature

Copy link
Copy Markdown
Contributor Author

@Otter-0x4ka5h Otter-0x4ka5h Oct 14, 2025

Choose a reason for hiding this comment

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

Yeah, i thought the same atm but we can't gate it to test-only((proc macros can't detect context) or doctests cfgs found.
We can just let them use namespace in doctests, but that skips owner trait + cant show declare_id! pattern.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Should I revert all the id parameter changes and just document the namespace workaround instead?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm going to investigate ways of making it work as-is first I think

@swaroop-osec
Copy link
Copy Markdown
Collaborator

Done in #3988

@github-project-automation github-project-automation bot moved this from In Progress to Done in Anchor 1.0 Oct 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

#[account] does not work in doctest

4 participants