You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,6 +37,7 @@ The minor version will be incremented upon a breaking change and the patch versi
37
37
- cli: Replace `anchor verify` to use `solana-verify` under the hood, adding automatic installation via AVM, local path support, and future-proof argument passing ([#3768](https://github.com/solana-foundation/anchor/pull/3768)).
38
38
- lang: Replace `solana-program` crate with smaller crates ([#3819](https://github.com/solana-foundation/anchor/pull/3819)).
39
39
- cli: Make `anchor deploy` to upload the IDL to the cluster by default unless `--no-idl` is passed ([#3863](https://github.com/solana-foundation/anchor/pull/3863)).
40
+
- lang: Add generic program validation support to `Program` type allowing `Program<'info>` for executable-only validation ([#3878](https://github.com/solana-foundation/anchor/pull/3878)).
40
41
- lang: Use `solana-invoke` instead of `solana_cpi::invoke` ([#3900](https://github.com/solana-foundation/anchor/pull/3900)).
41
42
- client: remove `solana-client` from `anchor-client` and `cli` ([#3877](https://github.com/solana-foundation/anchor/pull/3877)).
42
43
- idl: Build IDL on stable Rustc ([#3842](https://github.com/solana-foundation/anchor/pull/3842)).
Copy file name to clipboardExpand all lines: lang/src/accounts/program.rs
+34-3Lines changed: 34 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -21,15 +21,24 @@ use std::ops::Deref;
21
21
///
22
22
/// # Table of Contents
23
23
/// - [Basic Functionality](#basic-functionality)
24
+
/// - [Generic Program Validation](#generic-program-validation)
24
25
/// - [Out of the Box Types](#out-of-the-box-types)
25
26
///
26
27
/// # Basic Functionality
27
28
///
29
+
/// For `Program<'info, T>` where T implements Id:
28
30
/// Checks:
29
31
///
30
32
/// - `account_info.key == expected_program`
31
33
/// - `account_info.executable == true`
32
34
///
35
+
/// # Generic Program Validation
36
+
///
37
+
/// For `Program<'info>` (without type parameter):
38
+
/// - Only checks: `account_info.executable == true`
39
+
/// - Use this when you only need to verify that an address is executable,
40
+
/// without validating against a specific program ID.
41
+
///
33
42
/// # Example
34
43
/// ```ignore
35
44
/// #[program]
@@ -65,6 +74,16 @@ use std::ops::Deref;
65
74
/// - `program_data`'s constraint checks that its upgrade authority is the `authority` account.
66
75
/// - Finally, `authority` needs to sign the transaction.
67
76
///
77
+
/// ## Generic Program Example
78
+
/// ```ignore
79
+
/// #[derive(Accounts)]
80
+
/// pub struct ValidateExecutableProgram<'info> {
81
+
/// // Only validates that the provided account is executable
82
+
/// pub any_program: Program<'info>,
83
+
/// pub authority: Signer<'info>,
84
+
/// }
85
+
/// ```
86
+
///
68
87
/// # Out of the Box Types
69
88
///
70
89
/// Between the [`anchor_lang`](https://docs.rs/anchor-lang/latest/anchor_lang) and [`anchor_spl`](https://docs.rs/anchor_spl/latest/anchor_spl) crates,
0 commit comments