All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Note: Version 0 of Semantic Versioning is handled differently from version 1 and above. The minor version will be incremented upon a breaking change and the patch version will be incremented for features.
assert (#2535).async feature flag to use an asynchronous anchor-client (#2488).approve_collection_authority, bubblegum_set_collection_size, burn_edition_nft, burn_nft, revoke_collection_authority, set_token_standard, utilize, unverify_sized_collection_item, unverify_collection (#2430)token_program constraint to Token, Mint, and AssociatedToken accounts in order to override required token_program fields and use different token interface implementations in the same instruction (#2460)anchor init and anchor new take an option --solidity which creates solidity code rather than rust. anchor build and anchor test work accordingly (#2421)idl set-buffer, idl set-authority and idl close take an option --print-only. which prints transaction in a base64 Borsh compatible format but not sent to the cluster. It's helpful when managing authority under a multisig, e.g., a user can create a proposal for a Custom Instruction in SPL Governance (#2486).emit_cpi! and #[event_cpi] macros(behind event-cpi feature flag) to store event logs in transaction metadata (#2438).keys sync command to sync program id declarations (#2505).1.16.0 and specify maximum version of <1.17.0 (#2512).anchor deploy command's --program-name argument accepts program lib names (#2519).AccountClient type to it's appropriate account type (#2440)program_id, accounts, ix_data, remaining_accounts in instruction arguments (#2464)metadata.address generation in IDL after deploying with a custom keypair (#2485)anchor new not updating Anchor.toml (#2516).program_id, accounts, ix_data, remaining_accounts) have been renamed with __ prefix (#2464)metadata::create_metadata_account_v2 deprecated wrapper since it was removed from token metadata program (#2480)MasterEditionAccount account deserialization to spl metadata (#2393).InitSpace derive macro to automatically calculate the space at the initialization of an account (#2346).env option to verifiable builds (#2325).idl close command to close a program's IDL account (#2329).idl init now supports very large IDL files (#2329).transfer_checked function (#2353).approve_checked function (#2401).--skip-build option to the verify command (#2387).--multithreaded (#2321).async_rpc a method which returns a nonblocking solana rpc client (#2322).rustls-tls feature of reqwest so that users don't need OpenSSL installed (#2385).VersionedTransaction support. Methods in the Provider class and Wallet interface now use the argument tx: Transaction | VersionedTransaction (#2427).--arch sbf option to compile programs using cargo build-sbf (#2398).Interface and InterfaceAccount types, related to token-2022 (#2386).AccountClient.fetchMultiple match the account type being fetched (#2390)provider.simulate will send the transaction with sigVerify: false if no signers are present (#2331).CpiAccount, Loader and ProgramAccount (#2375).state and interface attributes (#2285).#[account(constraint = {})] (#2379).account(zero_copy) and zero_copy attributes now derive the bytemuck::Pod and bytemuck::Zeroable traits instead of using unsafe impl (#2330). This imposes useful restrictions on the type, like not having padding bytes and all fields being Pod themselves. See bytemuck::Pod for details. This change requires adding bytemuck = { version = "1.4.0", features = ["derive", "min_const_generics"]} to your cargo.toml. Legacy applications can still use #[account(zero_copy(unsafe))] and #[zero_copy(unsafe)] for the old behavior.createProgramAddressSync, findProgramAddressSync (now available in @solana/web3.js) and update associatedAddress to be synchronous (#2357).--run to anchor test for running a subset of test suites (#1828).transaction functions to RequestBuilder (#1958).create_metadata_accounts_v3 and set_collection_size wrappers (#2119).MetadataAccount account deserialization. (#2014).update_primary_sale_happened_via_token wrapper (#2173).sign_metadata and remove_creator_verification wrappers (#2175).initialize_account3 and initialize_mint2 (#2265).serum-dex to openbook-dex (#2308).has_one relations inference so accounts mapped via has_one relationships no longer need to be provided (#2160)..prepare() to builder pattern (#2160).freeze_delegated_account and thaw_delegated_account wrappers (#2164).feePayer check to AnchorProvider methods, so that anchor writes the provider's wallet as fee payer if fee payer isn't already set (#2186).AccountsClose to make it safe to call manually (#2209).test.validator.geyser_plugin_config support (#2016).account subcommand to cli (#1923)ticks_per_slot option to Validator args (#1875).seed generation for byte string literals (#2125)..fetchNullable() to be robust towards accounts only holding a balance (#2301).rent from constraints (#2265).rent from associated_token::Create (#2265).Discriminator and Owner trait implementation for structures representing instructions (#1997).yarn build in packages/anchor, see #2299 and #2306.Optional<Account<'info, T>>. Shouldn't affect existing programs but may be a breaking change to tools that use the anchor generated IDL. #2101.@project-serum/anchor to the @coral-xyz/anchor package #2318.realloc, realloc::payer, and realloc::zero as a new constraint group for program accounts (#1986).PartialEq and Eq for anchor_lang::Error (#1544).--skip-build to anchor publish (#1786).--program-keypair to anchor deploy (#1786).build now adds docs to idl. This can be turned off with --no-docs (#1561).b and t aliases for build and test respectively (#1823).TokenAccount to Mint (#1818).sync_native token program CPI wrapper function (#1833).anchor run (#1914).program.coder.types for encoding/decoding user-defined types (#1931).send_with_spinner_and_config function to RequestBuilder (#1926).ANCHOR_WALLET variable when using NodeWallet.local() (#1958).MethodsBuilder#accountsStrict for strict typing on ix account input (#2019).anchor keys list reading the target folder in the wrong path (#2063).overflow-checks into workspace Cargo.toml so that it will not be ignored by compiler (#1806).init or zero (#1800).BROWSER env variable to ANCHOR_BROWSER (#1233).EventCallback parameters (#1851).EventParser#parseLogs implementation to be a generator instead of callback function (#2018).&mut reallocs: BTreeSet<Pubkey> argument to Accounts::try_accounts (#1986).returns being serialized as null instead of undefined in IDL (#1782).anchor build failing if Test.toml included a relative path that didn't exist yet because it's created by anchor build (#1772).AnchorProvider class (#1770).avm update command to update the Anchor CLI to the latest version (#1670).program.methods syntax (#1732).anchor init now come with the prettier formatter and scripts included (#1741).pubkeys function to methods builder to get all instruction account addresses (#1733).LangErrorCode and LangErrorMessage from error.ts (#1756).avm install no longer downloads the version if already installed in the machine (#1670).anchor test fail when used with --skip-deploy option and without --skip-local-validator option but there already is a running validator (#1675).(Account)Loader (#1678).@types/bn.js to devDependencies in cli template (#1712).avm install switches to the newly installed version after installation finishes (#1670).spl_token crate (#1665).Program type now deserializes programdata_address only on demand (#1723).Provider an interface and adjust its signatures and add AnchorProvider implementor class (#1707).token::burn (#1080).anchor clean command that's the same as cargo clean but preserves keypairs inside target/deploy (#1470).anchor init now initializes a new git repository for the workspace. This can be disabled with the --no-git flag (#1605).anchor idl fetch to work outside anchor workspace (#1509).AccountSysvarMismatch error code and test cases for sysvars (#1535).std::io::Cursor with a custom Write impl that uses the Solana mem syscalls (#1589).require_neq, require_keys_neq, require_gt, and require_gte comparison macros (#1622).Spl.token factory method (#1597).methods namespace on builder functions (#1539).spl/governance to use new errors (#1582).Cluster's FromStr implementation (#1362).Key for Pubkey again, so associated_token::* constraints can use pubkey targets again (#1601).#[error_code] works with just importing anchor_lang::error_code (#1610).spl-token coder account parsing (#1604).npm install fallback if yarn install doesn't work (#1643).owner = <target> would not compile because of missing type annotation (#1648).send and simulate functions in provider.ts, so they use the return value of Wallet.signTransaction(#1527).transaction, instruction, simulate and rpc program namespaces as deprecated in favor of methods (#1539).methods#accounts(). ([#1548][https://github.com/coral-xyz/anchor/pull/1548])sol_log_data syscall (#1608).#[derive(Default)] (#1519).require_eq and require_keys_eq macros. Add default error code to require macro (#1572).system_program CPI wrapper functions. Make system_program module public instead of re-exporting system_program::System(#1629).avm use no long prompts [y/n] if an install is needed first - it just tells the user to avm install (#1565)AnchorError with program stack and also a program stack for non-AnchorError errors (#1640). AnchorError is not returned for processed tx that have skipPreflight set to true (it falls back to ProgramError or the raw solana library error).--skip-lint option to disable check linting introduced in (#1452) for rapid prototyping (#1482).Option<T> mapped types (#1428).mut (#1271).error! and err! macro and Result type (#1462).
This change will break most programs. Do the following to upgrade:
_ change all ProgramResult's to Result<()>
_ change #[error] to #[error_code]
_ change all Err(MyError::SomeError.into()) to Err(error!(MyError::SomeError)) and all Err(ProgramError::SomeProgramError) to Err(ProgramError::SomeProgramError.into()) or Err(Error::from(ProgramError::SomeProgramError).with_source(source!())) to provide file and line source of the error (with_source is most useful with ProgramErrors. error! already adds source information for custom and anchor internal errors).
_ change all solana_program::program::invoke() to solana_program::program::invoke().map_err(Into::into) and solana_program::program::invoke_signed() to solana_program::program::invoke_signed().map_err(Into::into)Wallet / NodeWallet class (#1363).Option<T> and Vec<String> types (#1393).seeds::program constraint for specifying which program_id to use when deriving PDAs (#1197).Context now has a new bumps: BTree<String, u8> argument, mapping account name to bump seed "found" by the accounts context. This allows one to access bump seeds without having to pass them in from the client or recalculate them in the handler (#1367).methods namespace to the program client, introducing a more ergonomic builder API (#1324).init_if_needed behind a feature flag to decrease wrong usage (#1258).loader_account module to account_loader module (#1279)Accounts trait's try_accounts method now has an additional bumps: &mut BTreeMap<String, u8> argument, which accumulates bump seeds (#1367).bump = <target> targets with init will now error. On init only, it is required to use bump without a target and access the seed inside function handlers via ctx.bumps.get("<pda-account-name"). For subsequent seeds constraints (without init), it is recommended to store the bump on your account and use it as a bump = <target> target to minimize compute units used (#1380).Coder is now an interface and the existing class has been renamed to BorshCoder. This change allows the generation of Anchor clients for non anchor programs (#1259).init constraint(#1257)init_if_needed now checks rent exemption when init is not needed (#1250).associated_token::authority is used (#1240).workspace and Wallet exports (#1137).recent to processed and max to finalized (#1128)translateAddress which currently leads to failing browser code. Now uses PublicKey constructor instead of prototype chain constructor name checking which doesn't work in the presence of code minifying/mangling(#1138)init_if_needed and init is not needed(#1221)programdata_address: Option<Pubkey> field to Program account. Will be populated if account is a program owned by the upgradable bpf loader (#1125)serialize function because it has a default impl now. Similarly, they no longer have to implement try_deserialize which now delegates to try_deserialize_unchecked by default(#1156).set_inner method to Account<'a, T> to enable easy updates (#1177).fetch and fetchMultiple (#1171).AsRef<T> for Account<'a, T>(#1173)anchor expand command which wraps around cargo expand (#1160)Rc<dyn Signer> instead of Keypair (#975).#[repr(packed)] to #[repr(C)] for zero copy accounts (#1106).prelude module or the accounts module but not longer directly under the root.
Deprecated account types are no longer imported by the prelude (#1208).deprecated attribute to ProgramAccount (#1014).Cargo.toml into extracted IDL (#1061).deprecated attribute to Loader(#1078).init_if_needed attribute now checks that given attributes (e.g. space, owner, token::authority etc.) are validated even when init is not needed (#1096).ErrorCode::AccountNotInitialized error to separate the situation when the account has the wrong owner from when it does not exist (#1024).no-log-ix-name flag (#1057).ProgramData and UpgradableLoaderState can now be passed into Account as generics. see UpgradeableLoaderState. UpgradableLoaderState can also be matched on to get ProgramData, but when ProgramData is used instead, anchor does the serialization and checking that it is actually program data for you (#1095).postInstructions and preInstructions as a replacement for (the now deprecated) instructions (#1007).getAccountInfo helper method to account namespace/client (#1084).SystemAccount<'info> account type for generic wallet addresses or accounts owned by the system program (#954)idl parse subcommand (#941).os and cpu to npm package @project-serum/anchor-cli (#976).solana-test-validator in Anchor.toml (#834).target/types directory now created on build to store a TypeScript types file for each program's IDL (#795).Program<T> can now be typed with an IDL type (#795).mint::freeze_authority keyword for mint initialization within #[derive(Accounts)] (#835).AccountLoader type for zero_copy accounts with support for CPI (#792).#[account(init_if_needed)] keyword for allowing one to invoke the same instruction even if the account was created already (#906).signer, mut, has_one, owner, raw constraints and address (#905, #913).#[account(signer)] constraint now enforce signer when the "cpi" feature is enabled (#849).localnet command for starting a local solana-test-validator with the workspace deployed (#820).CpiContext accounts must now be used with the accounts struct generated in the crate::cpi::accounts::* module. These structs correspond to the accounts context for each instruction, except that each field is of type AccountInfo (#824).--detach flag to anchor test (#770).associated_token keyword for initializing associated token accounts within #[derive(Accounts)] (#790).AccountMetas for Rust clients now properly set the isSigner field (#762).Signer type now sets isSigner to true in the IDL (#750).Program type introduced for executable accounts (#705).Signer type introduced for signing accounts where data is not used (#705).UncheckedAccount type introduced as a preferred alias for AccountInfo (#745).#[account(owner = <pubkey>)] now requires a Pubkey instead of an account (#691).Account type to replace ProgramAccount and CpiAccount, both of which are deprecated (#686).Box can be used with Account types to reduce stack usage (#686).Owner trait, which is automatically implemented by all #[account] structs (#686).anchor-debug only) (#681).declare_id! (#686).Unnamed structs instead of panic (#605).#[account(init, seeds = [...], mint::decimals = <expr>, mint::authority = <expr>)] (#562).AsRef<AccountInfo> for AccountInfo wrappers (#652).trait Key by removing AccountInfo cloning (#652).#[account(init, seeds = [...], token = <expr>, authority = <expr>)] to #[account(init, token::mint = <expr> token::authority = <expr>)] (#562).#[associated] and #[account(associated = <target>, with = <target>)] are both removed (#612).anchor launch command (#634).#[account(init)] now creates the account inside the same instruction to be consistent with initializing PDAs. To maintain the old behavior of init, replace it with #[account(zero)] (#641).bump must be provided when using the seeds constraint. This has been added as an extra safety constraint to ensure that whenever a PDA is initialized via a constraint the bump used is the one created by Pubkey::find_program_address (#641).try_from_init has been removed from Loader, ProgramAccount, and CpiAccount and replaced with try_from_unchecked (#641).AccountsInit trait (#641).try_from methods for ProgramAccount, Loader, and ProgramState now take in an additional program_id: &Pubkey parameter (#660).anchor init command "Workspace not found" regression (#598).[registry] section in the Anchor toml (#570).anchor login <api-token> command (#570).anchor publish <package> command (#570).anchor_version field to the Anchor.toml for specifying the anchor docker image to use for verifiable builds (#570).solana_version field to the Anchor.toml for specifying the solana toolchain to use for verifiable builds (#570).init (#587).[clusters.<network>] Anchor.toml section has been renamed to [programs.<network>] (#570).[workspace] member and exclude arrays must now be filepaths relative to the workpsace root (#570).members / exclude in config programs section (#546).clusters.localnet (#554).hex by default for decoding Instruction (#547).CpiAccount::reload mutates the existing struct instead of returning a new one (#526).[scripts] test command (#550).require macro for specifying assertions that return error codes on failure (#483).bump keyword is added to the accounts constraints, which is used to add an optional bump seed to the end of a seeds array. When used in conjunction with both init and seeds, then the program executes find_program_address to assert that the given bump is the canonical bump (#483)..spec suffix on TypeScript tests files (#441).belongs_to constraint (#459).#[account(address = <expr>)] constraint for asserting the address of an account (#400).#[account(init, token = <mint-target>, authority = <token-owner-target>...)] constraint for initializing SPL token accounts as program derived addresses for the program. Can be used when initialized via seeds or associated (#400).associated_seeds! macro for generating signer seeds for CPIs signed by an #[account(associated = <target>)] account (#400).[scripts] section to the Anchor.toml for specifying workspace scripts that can be run via anchor run <script> (#400).[clusters.<network>] table entries can now also use { address = <base58-str>, idl = <filepath-str> } to specify workspace programs (#400).--yarn flag in favor of using npx (#432).&[u8] parameter (#386).--program-name option for build command to build a single program at a time (#362).#[account(close = <destination>)] constraint for closing accounts and sending the rent exemption lamports to a specified destination account (#371).remaining_accounts with CpiContext by implementing the ToAccountMetas trait on CpiContext (#351).SetAuthority instruction (#307).constraint = <expression> added as a replacement for (the now deprecated) string literal constraints (#341).anchor.workspace clients (#310).<program>.account.<my-account> and <program>.state namespaces now require explicitly invoking the fetch API. For example, program.account.myAccount(<adddress>) and program.state() is now program.account.myAccount.fetch(<address>) and program.state.fetch() (#322).#[account(associated)] now requires init to be provided to create an associated account. If not provided, then the address will be assumed to exist, and a constraint will be added to ensure the correctness of the address (#318).#[state] account discriminator to be namespaced by "state:" (#320).: to be consistent with accounts (#321).mut (#341).space constraints must now be literal integers instead of literal strings (#341).program.simulate namespace (#266).Address type, allowing one to use Base 58 encoded strings in public APIs (#304).web3.Account with web3.Signer in public APIs (#296).anchor.workspace clients can now be customized per network with [cluster.<slug>] in the Anchor.toml (#308).--skip-build flag to test command (301).anchor shell command to spawn a node shell populated with an Anchor.toml based environment (#303).wallet and cluster settings must now be under the [provider] table (#305).decode API changed to decode strings directly instead of buffers (#292).encode API removed (#292).anchor-debug feature flag for logging (#253).RequestBuilder::new to RequestBuilder::from (#248).instruction::state::Ctor struct to instruction::state::New (#248).with targets when creating associated acconts (#197).#[account(owner = <program>)] constraint (#178).#[account(associated = <target>)] and #[associated] attributes for creating associated program accounts within programs. The TypeScript package can fetch these accounts with a new <program>.account.<account-name>.associated (and associatedAddress) method (#186).#[account]s are now parsed into the IDL correctly (#177).#[state] account's size (#121).#[account(executable)] attribute (#140).Cluster struct when constructing clients (#89).IdlAccount to be namespaced by "internal" (#128).-#![feature(proc_macro_hygiene)]. (#139).IdlInstruction::Clear (#107)..anchor/program-logs directory when testing (ce5ca7).Initial release.
anchor-lang crate providing a Rust eDSL for Solana.anchor-spl crate providing CPI clients for Anchor programs.anchor-client crate providing Rust clients for Anchor programs.@project-serum/anchor package for generating TypeScript clients.