-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix: set default template #4038
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
Merged
jacobcreech
merged 2 commits into
solana-foundation:master
from
Otter-0x4ka5h:anchor#4037
Nov 19, 2025
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| [provider] | ||
| cluster = "localnet" | ||
| wallet = "~/.config/solana/id.json" | ||
|
|
||
| [programs.localnet] | ||
| template_multiple_files = "CwrqeMj2U8tFr1Rhkgwc84tpAsqbt9pTt2a4taoTADPr" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| [workspace] | ||
| members = [ | ||
| "programs/*" | ||
| ] | ||
| resolver = "2" | ||
|
|
||
| [profile.release] | ||
| overflow-checks = true | ||
| lto = "fat" | ||
| codegen-units = 1 | ||
| [profile.release.build-override] | ||
| opt-level = 3 | ||
| incremental = false | ||
| codegen-units = 1 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| [package] | ||
| name = "template" | ||
| version = "0.1.0" | ||
| description = "Test for multiple file template structure" | ||
| edition = "2021" | ||
|
|
||
| [lib] | ||
| crate-type = ["cdylib", "lib"] | ||
| name = "template_multiple_files" | ||
|
|
||
| [features] | ||
| default = [] | ||
| cpi = ["no-entrypoint"] | ||
| no-entrypoint = [] | ||
| no-idl = [] | ||
| no-log-ix-name = [] | ||
| idl-build = ["anchor-lang/idl-build"] | ||
|
|
||
| [dependencies] | ||
| anchor-lang = { path = "../../../../lang" } | ||
|
|
3 changes: 3 additions & 0 deletions
3
tests/post2018-template/programs/template/src/instructions.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| pub mod initialize; | ||
|
|
||
| pub use initialize::*; |
23 changes: 23 additions & 0 deletions
23
tests/post2018-template/programs/template/src/instructions/initialize.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| use anchor_lang::prelude::*; | ||
| use crate::state::*; | ||
|
|
||
| #[derive(Accounts)] | ||
| pub struct Initialize<'info> { | ||
| #[account( | ||
| init, | ||
| payer = user, | ||
| space = 8 + MyAccount::INIT_SPACE | ||
| )] | ||
| pub account: Account<'info, MyAccount>, | ||
| #[account(mut)] | ||
| pub user: Signer<'info>, | ||
| pub system_program: Program<'info, System>, | ||
| } | ||
|
|
||
| pub fn handler(ctx: Context<Initialize>) -> Result<()> { | ||
| let account = &mut ctx.accounts.account; | ||
| account.data = 0; | ||
| msg!("Account initialized with data: {}", account.data); | ||
| Ok(()) | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| pub mod instructions; | ||
| pub mod state; | ||
|
|
||
| use anchor_lang::prelude::*; | ||
|
|
||
| pub use instructions::*; | ||
| pub use state::*; | ||
|
|
||
| declare_id!("CwrqeMj2U8tFr1Rhkgwc84tpAsqbt9pTt2a4taoTADPr"); | ||
|
|
||
| #[program] | ||
| pub mod template_multiple_files { | ||
| use super::*; | ||
|
|
||
| pub fn initialize(ctx: Context<Initialize>) -> Result<()> { | ||
| initialize::handler(ctx) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| pub mod state; | ||
|
|
||
| pub use state::*; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| use anchor_lang::prelude::*; | ||
|
|
||
| #[account] | ||
| #[derive(InitSpace)] | ||
| pub struct MyAccount { | ||
| pub data: u64, | ||
| } | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.