@project-serum/anchor
Advanced tools
Changelog
[0.26.0] - 2022-12-15
--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.Changelog
[0.25.0] - 2022-07-05
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).Changelog
[0.24.0] - 2022-04-12
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).Changelog
[0.23.0] - 2022-03-20
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).Changelog
[0.22.0] - 2022-02-20
--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 ProgramError
s. 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)
Changelog
[0.21.0] - 2022-02-07
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).