From 28c467a035d04fe857d29218cbb80337d78343dc Mon Sep 17 00:00:00 2001 From: Jean Marchand Date: Tue, 25 Apr 2023 18:48:34 +0200 Subject: [PATCH 01/11] lang: Remove AccountInfo from Context --- lang/derive/accounts/src/lib.rs | 2 +- lang/src/accounts/account_info.rs | 21 +--- lang/src/system_program.rs | 13 +++ lang/src/vec.rs | 4 +- lang/syn/src/codegen/accounts/constraints.rs | 2 +- lang/syn/src/codegen/accounts/mod.rs | 21 ++-- lang/syn/src/codegen/program/idl.rs | 20 ++-- lang/syn/src/lib.rs | 4 + lang/syn/src/parser/accounts/mod.rs | 27 ++++- lang/syn/src/parser/context.rs | 5 +- lang/tests/generics_test.rs | 2 +- spl/src/associated_token.rs | 1 + spl/src/dex.rs | 7 ++ spl/src/metadata.rs | 24 ++++ spl/src/shmem.rs | 2 + spl/src/stake.rs | 3 + spl/src/token.rs | 97 +++++++-------- spl/src/token_2022.rs | 108 ++++++++--------- .../programs/misc-optional/src/context.rs | 98 ++++++++-------- tests/misc/programs/misc/src/context.rs | 110 +++++++++--------- .../programs/token-proxy/src/lib.rs | 48 ++++---- .../programs/token-wrapper/src/lib.rs | 27 ++--- 22 files changed, 358 insertions(+), 288 deletions(-) diff --git a/lang/derive/accounts/src/lib.rs b/lang/derive/accounts/src/lib.rs index 9a04c866ee..dbb76b852e 100644 --- a/lang/derive/accounts/src/lib.rs +++ b/lang/derive/accounts/src/lib.rs @@ -629,7 +629,7 @@ use syn::parse_macro_input; /// /// /// -#[proc_macro_derive(Accounts, attributes(account, instruction))] +#[proc_macro_derive(Accounts, attributes(account, instruction, only_cpi))] pub fn derive_anchor_deserialize(item: TokenStream) -> TokenStream { parse_macro_input!(item as anchor_syn::AccountsStruct) .to_token_stream() diff --git a/lang/src/accounts/account_info.rs b/lang/src/accounts/account_info.rs index 54d6cc80b5..2cdbe6584c 100644 --- a/lang/src/accounts/account_info.rs +++ b/lang/src/accounts/account_info.rs @@ -2,29 +2,10 @@ //! [Unchecked Account](crate::accounts::unchecked_account::UncheckedAccount) //! should be used instead. -use crate::error::ErrorCode; -use crate::{Accounts, AccountsExit, Key, Result, ToAccountInfos, ToAccountMetas}; +use crate::{AccountsExit, Key, ToAccountInfos, ToAccountMetas}; use solana_program::account_info::AccountInfo; use solana_program::instruction::AccountMeta; use solana_program::pubkey::Pubkey; -use std::collections::{BTreeMap, BTreeSet}; - -impl<'info> Accounts<'info> for AccountInfo<'info> { - fn try_accounts( - _program_id: &Pubkey, - accounts: &mut &[AccountInfo<'info>], - _ix_data: &[u8], - _bumps: &mut BTreeMap, - _reallocs: &mut BTreeSet, - ) -> Result { - if accounts.is_empty() { - return Err(ErrorCode::AccountNotEnoughKeys.into()); - } - let account = &accounts[0]; - *accounts = &accounts[1..]; - Ok(account.clone()) - } -} impl<'info> ToAccountMetas for AccountInfo<'info> { fn to_account_metas(&self, is_signer: Option) -> Vec { diff --git a/lang/src/system_program.rs b/lang/src/system_program.rs index 741a714bce..b11d514ce0 100644 --- a/lang/src/system_program.rs +++ b/lang/src/system_program.rs @@ -32,6 +32,7 @@ pub fn advance_nonce_account<'info>( } #[derive(Accounts)] +#[only_cpi] pub struct AdvanceNonceAccount<'info> { pub nonce: AccountInfo<'info>, pub authorized: AccountInfo<'info>, @@ -55,6 +56,7 @@ pub fn allocate<'info>( } #[derive(Accounts)] +#[only_cpi] pub struct Allocate<'info> { pub account_to_allocate: AccountInfo<'info>, } @@ -81,6 +83,7 @@ pub fn allocate_with_seed<'info>( } #[derive(Accounts)] +#[only_cpi] pub struct AllocateWithSeed<'info> { pub account_to_allocate: AccountInfo<'info>, pub base: AccountInfo<'info>, @@ -103,6 +106,7 @@ pub fn assign<'info>( } #[derive(Accounts)] +#[only_cpi] pub struct Assign<'info> { pub account_to_assign: AccountInfo<'info>, } @@ -127,6 +131,7 @@ pub fn assign_with_seed<'info>( } #[derive(Accounts)] +#[only_cpi] pub struct AssignWithSeed<'info> { pub account_to_assign: AccountInfo<'info>, pub base: AccountInfo<'info>, @@ -150,6 +155,7 @@ pub fn authorize_nonce_account<'info>( } #[derive(Accounts)] +#[only_cpi] pub struct AuthorizeNonceAccount<'info> { pub nonce: AccountInfo<'info>, pub authorized: AccountInfo<'info>, @@ -177,6 +183,7 @@ pub fn create_account<'info>( } #[derive(Accounts)] +#[only_cpi] pub struct CreateAccount<'info> { pub from: AccountInfo<'info>, pub to: AccountInfo<'info>, @@ -207,6 +214,7 @@ pub fn create_account_with_seed<'info>( } #[derive(Accounts)] +#[only_cpi] pub struct CreateAccountWithSeed<'info> { pub from: AccountInfo<'info>, pub to: AccountInfo<'info>, @@ -243,6 +251,7 @@ pub fn create_nonce_account<'info>( } #[derive(Accounts)] +#[only_cpi] pub struct CreateNonceAccount<'info> { pub from: AccountInfo<'info>, pub nonce: AccountInfo<'info>, @@ -287,6 +296,7 @@ pub fn create_nonce_account_with_seed<'info>( } #[derive(Accounts)] +#[only_cpi] pub struct CreateNonceAccountWithSeed<'info> { pub from: AccountInfo<'info>, pub nonce: AccountInfo<'info>, @@ -313,6 +323,7 @@ pub fn transfer<'info>( } #[derive(Accounts)] +#[only_cpi] pub struct Transfer<'info> { pub from: AccountInfo<'info>, pub to: AccountInfo<'info>, @@ -341,6 +352,7 @@ pub fn transfer_with_seed<'info>( } #[derive(Accounts)] +#[only_cpi] pub struct TransferWithSeed<'info> { pub from: AccountInfo<'info>, pub base: AccountInfo<'info>, @@ -372,6 +384,7 @@ pub fn withdraw_nonce_account<'info>( } #[derive(Accounts)] +#[only_cpi] pub struct WithdrawNonceAccount<'info> { pub nonce: AccountInfo<'info>, pub to: AccountInfo<'info>, diff --git a/lang/src/vec.rs b/lang/src/vec.rs index 44c132be6b..52e4d07388 100644 --- a/lang/src/vec.rs +++ b/lang/src/vec.rs @@ -40,12 +40,14 @@ mod tests { use solana_program::clock::Epoch; use solana_program::pubkey::Pubkey; + use crate::{prelude::UncheckedAccount, ToAccountInfo}; + use super::*; #[derive(Accounts)] pub struct Test<'info> { #[account(signer)] - test: AccountInfo<'info>, + test: UncheckedAccount<'info>, } #[test] diff --git a/lang/syn/src/codegen/accounts/constraints.rs b/lang/syn/src/codegen/accounts/constraints.rs index cb92fc24f0..2a515d7116 100644 --- a/lang/syn/src/codegen/accounts/constraints.rs +++ b/lang/syn/src/codegen/accounts/constraints.rs @@ -282,7 +282,7 @@ pub fn generate_constraint_has_one( pub fn generate_constraint_signer(f: &Field, c: &ConstraintSigner) -> proc_macro2::TokenStream { let ident = &f.ident; let info = match f.ty { - Ty::AccountInfo => quote! { #ident }, + Ty::UncheckedAccount => quote! { #ident.to_account_info() }, Ty::Account(_) => quote! { #ident.to_account_info() }, Ty::InterfaceAccount(_) => quote! { #ident.to_account_info() }, Ty::AccountLoader(_) => quote! { #ident.to_account_info() }, diff --git a/lang/syn/src/codegen/accounts/mod.rs b/lang/syn/src/codegen/accounts/mod.rs index 3a239cbe33..fd4a855e66 100644 --- a/lang/syn/src/codegen/accounts/mod.rs +++ b/lang/syn/src/codegen/accounts/mod.rs @@ -22,14 +22,21 @@ pub fn generate(accs: &AccountsStruct) -> proc_macro2::TokenStream { let __client_accounts_mod = __client_accounts::generate(accs); let __cpi_client_accounts_mod = __cpi_client_accounts::generate(accs); - quote! { - #impl_try_accounts - #impl_to_account_infos - #impl_to_account_metas - #impl_exit + if accs.only_cpi { + quote! { + #impl_to_account_infos + #impl_to_account_metas + } + } else { + quote! { + #impl_try_accounts + #impl_to_account_infos + #impl_to_account_metas + #impl_exit - #__client_accounts_mod - #__cpi_client_accounts_mod + #__client_accounts_mod + #__cpi_client_accounts_mod + } } } diff --git a/lang/syn/src/codegen/program/idl.rs b/lang/syn/src/codegen/program/idl.rs index a389de8539..2e4c83f94f 100644 --- a/lang/syn/src/codegen/program/idl.rs +++ b/lang/syn/src/codegen/program/idl.rs @@ -38,20 +38,20 @@ pub fn idl_accounts_and_functions() -> proc_macro2::TokenStream { pub struct IdlCreateAccounts<'info> { // Payer of the transaction. #[account(signer)] - pub from: AccountInfo<'info>, + pub from: UncheckedAccount<'info>, // The deterministically defined "state" account being created via // `create_account_with_seed`. #[account(mut)] - pub to: AccountInfo<'info>, + pub to: UncheckedAccount<'info>, // The program-derived-address signing off on the account creation. // Seeds = &[] + bump seed. #[account(seeds = [], bump)] - pub base: AccountInfo<'info>, + pub base: UncheckedAccount<'info>, // The system program. pub system_program: Program<'info, System>, // The program whose state is being constructed. #[account(executable)] - pub program: AccountInfo<'info>, + pub program: UncheckedAccount<'info>, } // Accounts for Idl instructions. @@ -103,7 +103,7 @@ pub fn idl_accounts_and_functions() -> proc_macro2::TokenStream { #[account(constraint = authority.key != &ERASED_AUTHORITY)] pub authority: Signer<'info>, #[account(mut)] - pub sol_destination: AccountInfo<'info>, + pub sol_destination: UncheckedAccount<'info>, } @@ -163,10 +163,10 @@ pub fn idl_accounts_and_functions() -> proc_macro2::TokenStream { anchor_lang::solana_program::program::invoke_signed( &ix, &[ - accounts.from.clone(), - accounts.to.clone(), - accounts.base.clone(), - accounts.system_program.to_account_info().clone(), + accounts.from.to_account_info(), + accounts.to.to_account_info(), + accounts.base.to_account_info(), + accounts.system_program.to_account_info(), ], &[seeds], )?; @@ -225,7 +225,7 @@ pub fn idl_accounts_and_functions() -> proc_macro2::TokenStream { accounts.system_program.to_account_info(), anchor_lang::system_program::Transfer { from: accounts.authority.to_account_info(), - to: accounts.idl.to_account_info().clone(), + to: accounts.idl.to_account_info(), }, ), new_rent_minimum diff --git a/lang/syn/src/lib.rs b/lang/syn/src/lib.rs index 7bad199db2..210d957dd6 100644 --- a/lang/syn/src/lib.rs +++ b/lang/syn/src/lib.rs @@ -93,6 +93,8 @@ pub struct AccountsStruct { pub fields: Vec, // Instruction data api expression. instruction_api: Option>, + // Used internally to limit the codegen + only_cpi: bool, } impl Parse for AccountsStruct { @@ -119,6 +121,7 @@ impl AccountsStruct { strct: ItemStruct, fields: Vec, instruction_api: Option>, + only_cpi: bool, ) -> Self { let ident = strct.ident.clone(); let generics = strct.generics; @@ -127,6 +130,7 @@ impl AccountsStruct { generics, fields, instruction_api, + only_cpi, } } diff --git a/lang/syn/src/parser/accounts/mod.rs b/lang/syn/src/parser/accounts/mod.rs index d0c8aee763..45018e0a05 100644 --- a/lang/syn/src/parser/accounts/mod.rs +++ b/lang/syn/src/parser/accounts/mod.rs @@ -20,6 +20,7 @@ pub fn parse(strct: &syn::ItemStruct) -> ParseResult { }) .map(|ix_attr| ix_attr.parse_args_with(Punctuated::::parse_terminated)) .transpose()?; + let only_cpi = strct.attrs.iter().any(|a| a.path.is_ident("only_cpi")); let fields = match &strct.fields { syn::Fields::Named(fields) => fields .named @@ -34,9 +35,33 @@ pub fn parse(strct: &syn::ItemStruct) -> ParseResult { } }; + if !only_cpi { + prevent_account_info(&fields)?; + } + constraints_cross_checks(&fields)?; - Ok(AccountsStruct::new(strct.clone(), fields, instruction_api)) + Ok(AccountsStruct::new( + strct.clone(), + fields, + instruction_api, + only_cpi, + )) +} + +fn prevent_account_info(fields: &[AccountField]) -> ParseResult<()> { + let field = fields.iter().find(|f| match f { + AccountField::Field(acc_f) => acc_f.ty == Ty::AccountInfo, + _ => false, + }); + + match field { + Some(f) => Err(ParseError::new( + f.ident().span(), + "AccountInfo can no longer be used in the context. Please use UncheckedAccount instead.", + )), + None => Ok(()), + } } fn constraints_cross_checks(fields: &[AccountField]) -> ParseResult<()> { diff --git a/lang/syn/src/parser/context.rs b/lang/syn/src/parser/context.rs index e659324564..82795b89cd 100644 --- a/lang/syn/src/parser/context.rs +++ b/lang/syn/src/parser/context.rs @@ -240,10 +240,7 @@ impl ParsedModule { syn::Type::Path(syn::TypePath { path: syn::Path { segments, .. }, .. - }) => { - segments.len() == 1 && segments[0].ident == "UncheckedAccount" - || segments[0].ident == "AccountInfo" - } + }) => segments.len() == 1 && segments[0].ident == "UncheckedAccount", _ => false, }) } diff --git a/lang/tests/generics_test.rs b/lang/tests/generics_test.rs index a2c8f270ae..c7b6c8304e 100644 --- a/lang/tests/generics_test.rs +++ b/lang/tests/generics_test.rs @@ -14,7 +14,7 @@ where T: AccountSerialize + AccountDeserialize + Owner + Clone, U: BorshSerialize + BorshDeserialize + Default + Clone, { - pub non_generic: AccountInfo<'info>, + pub non_generic: UncheckedAccount<'info>, pub generic: Account<'info, T>, pub const_generic: AccountLoader<'info, FooAccount>, diff --git a/spl/src/associated_token.rs b/spl/src/associated_token.rs index 51ff96fea3..6e43cd39e0 100644 --- a/spl/src/associated_token.rs +++ b/spl/src/associated_token.rs @@ -54,6 +54,7 @@ pub fn create_idempotent<'info>( } #[derive(Accounts)] +#[only_cpi] pub struct Create<'info> { pub payer: AccountInfo<'info>, pub associated_token: AccountInfo<'info>, diff --git a/spl/src/dex.rs b/spl/src/dex.rs index 7a1cc990db..bfe2965051 100644 --- a/spl/src/dex.rs +++ b/spl/src/dex.rs @@ -203,6 +203,7 @@ pub fn initialize_market<'info>( } #[derive(Accounts)] +#[only_cpi] pub struct NewOrderV3<'info> { pub market: AccountInfo<'info>, pub open_orders: AccountInfo<'info>, @@ -225,6 +226,7 @@ pub struct NewOrderV3<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct CancelOrderV2<'info> { pub market: AccountInfo<'info>, pub market_bids: AccountInfo<'info>, @@ -235,6 +237,7 @@ pub struct CancelOrderV2<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct SettleFunds<'info> { pub market: AccountInfo<'info>, pub open_orders: AccountInfo<'info>, @@ -250,6 +253,7 @@ pub struct SettleFunds<'info> { /// To use an (optional) market authority, add it as the first account of the /// CpiContext's `remaining_accounts` Vec. #[derive(Accounts)] +#[only_cpi] pub struct InitOpenOrders<'info> { pub open_orders: AccountInfo<'info>, pub authority: AccountInfo<'info>, @@ -258,6 +262,7 @@ pub struct InitOpenOrders<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct CloseOpenOrders<'info> { pub open_orders: AccountInfo<'info>, pub authority: AccountInfo<'info>, @@ -266,6 +271,7 @@ pub struct CloseOpenOrders<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct SweepFees<'info> { pub market: AccountInfo<'info>, pub pc_vault: AccountInfo<'info>, @@ -276,6 +282,7 @@ pub struct SweepFees<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct InitializeMarket<'info> { pub market: AccountInfo<'info>, pub coin_mint: AccountInfo<'info>, diff --git a/spl/src/metadata.rs b/spl/src/metadata.rs index 98e1672e65..2f30539b39 100644 --- a/spl/src/metadata.rs +++ b/spl/src/metadata.rs @@ -554,6 +554,7 @@ pub fn unverify_sized_collection_item<'info>( } #[derive(Accounts)] +#[only_cpi] pub struct ApproveCollectionAuthority<'info> { pub collection_authority_record: AccountInfo<'info>, pub new_collection_authority: AccountInfo<'info>, @@ -564,6 +565,7 @@ pub struct ApproveCollectionAuthority<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct BubblegumSetCollectionSize<'info> { pub metadata_account: AccountInfo<'info>, pub update_authority: AccountInfo<'info>, @@ -572,6 +574,7 @@ pub struct BubblegumSetCollectionSize<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct BurnEditionNft<'info> { pub metadata: AccountInfo<'info>, pub owner: AccountInfo<'info>, @@ -586,6 +589,7 @@ pub struct BurnEditionNft<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct BurnNft<'info> { pub metadata: AccountInfo<'info>, pub owner: AccountInfo<'info>, @@ -597,6 +601,7 @@ pub struct BurnNft<'info> { #[deprecated(note = "internal instructions deprecated by Metaplex")] #[derive(Accounts)] +#[only_cpi] pub struct CreateMetadataAccountsV2<'info> { pub metadata: AccountInfo<'info>, pub mint: AccountInfo<'info>, @@ -608,6 +613,7 @@ pub struct CreateMetadataAccountsV2<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct CreateMetadataAccountsV3<'info> { pub metadata: AccountInfo<'info>, pub mint: AccountInfo<'info>, @@ -619,12 +625,14 @@ pub struct CreateMetadataAccountsV3<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct UpdateMetadataAccountsV2<'info> { pub metadata: AccountInfo<'info>, pub update_authority: AccountInfo<'info>, } #[derive(Accounts)] +#[only_cpi] pub struct CreateMasterEditionV3<'info> { pub edition: AccountInfo<'info>, pub mint: AccountInfo<'info>, @@ -638,6 +646,7 @@ pub struct CreateMasterEditionV3<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct MintNewEditionFromMasterEditionViaToken<'info> { pub new_metadata: AccountInfo<'info>, pub new_edition: AccountInfo<'info>, @@ -664,6 +673,7 @@ pub struct MintNewEditionFromMasterEditionViaToken<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct RevokeCollectionAuthority<'info> { pub collection_authority_record: AccountInfo<'info>, pub delegate_authority: AccountInfo<'info>, @@ -673,6 +683,7 @@ pub struct RevokeCollectionAuthority<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct SetCollectionSize<'info> { pub metadata: AccountInfo<'info>, pub mint: AccountInfo<'info>, @@ -681,6 +692,7 @@ pub struct SetCollectionSize<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct SetTokenStandard<'info> { pub metadata_account: AccountInfo<'info>, pub update_authority: AccountInfo<'info>, @@ -688,6 +700,7 @@ pub struct SetTokenStandard<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct VerifyCollection<'info> { pub payer: AccountInfo<'info>, pub metadata: AccountInfo<'info>, @@ -698,6 +711,7 @@ pub struct VerifyCollection<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct VerifySizedCollectionItem<'info> { pub payer: AccountInfo<'info>, pub metadata: AccountInfo<'info>, @@ -708,6 +722,7 @@ pub struct VerifySizedCollectionItem<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct SetAndVerifyCollection<'info> { pub metadata: AccountInfo<'info>, pub collection_authority: AccountInfo<'info>, @@ -719,6 +734,7 @@ pub struct SetAndVerifyCollection<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct SetAndVerifySizedCollectionItem<'info> { pub metadata: AccountInfo<'info>, pub collection_authority: AccountInfo<'info>, @@ -730,6 +746,7 @@ pub struct SetAndVerifySizedCollectionItem<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct FreezeDelegatedAccount<'info> { pub metadata: AccountInfo<'info>, pub delegate: AccountInfo<'info>, @@ -740,6 +757,7 @@ pub struct FreezeDelegatedAccount<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct ThawDelegatedAccount<'info> { pub metadata: AccountInfo<'info>, pub delegate: AccountInfo<'info>, @@ -750,6 +768,7 @@ pub struct ThawDelegatedAccount<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct UpdatePrimarySaleHappenedViaToken<'info> { pub metadata: AccountInfo<'info>, pub owner: AccountInfo<'info>, @@ -757,18 +776,21 @@ pub struct UpdatePrimarySaleHappenedViaToken<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct SignMetadata<'info> { pub creator: AccountInfo<'info>, pub metadata: AccountInfo<'info>, } #[derive(Accounts)] +#[only_cpi] pub struct RemoveCreatorVerification<'info> { pub creator: AccountInfo<'info>, pub metadata: AccountInfo<'info>, } #[derive(Accounts)] +#[only_cpi] pub struct Utilize<'info> { pub metadata: AccountInfo<'info>, pub token_account: AccountInfo<'info>, @@ -778,6 +800,7 @@ pub struct Utilize<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct UnverifyCollection<'info> { pub metadata: AccountInfo<'info>, pub collection_authority: AccountInfo<'info>, @@ -787,6 +810,7 @@ pub struct UnverifyCollection<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct UnverifySizedCollectionItem<'info> { pub metadata: AccountInfo<'info>, pub collection_authority: AccountInfo<'info>, diff --git a/spl/src/shmem.rs b/spl/src/shmem.rs index 450c6806fb..e3de56438a 100644 --- a/spl/src/shmem.rs +++ b/spl/src/shmem.rs @@ -34,6 +34,7 @@ pub fn ret<'a, 'b, 'c, 'info>( } #[derive(Accounts)] +#[only_cpi] pub struct Ret<'info> { #[account(mut)] pub buffer: AccountInfo<'info>, @@ -41,6 +42,7 @@ pub struct Ret<'info> { // A set of accounts that can be used with shared memory. #[derive(Accounts)] +#[only_cpi] pub struct Shmem<'info> { // Shared memory account to write the return value into. #[account(mut, constraint = shmem.owner == shmem_program.key)] diff --git a/spl/src/stake.rs b/spl/src/stake.rs index ce0659c48e..bfbb8de030 100644 --- a/spl/src/stake.rs +++ b/spl/src/stake.rs @@ -81,6 +81,7 @@ pub fn deactivate_stake<'info>( // CPI accounts #[derive(Accounts)] +#[only_cpi] pub struct Authorize<'info> { /// The stake account to be updated pub stake: AccountInfo<'info>, @@ -96,6 +97,7 @@ pub struct Authorize<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct Withdraw<'info> { /// The stake account to be updated pub stake: AccountInfo<'info>, @@ -114,6 +116,7 @@ pub struct Withdraw<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct DeactivateStake<'info> { /// The stake account to be deactivated pub stake: AccountInfo<'info>, diff --git a/spl/src/token.rs b/spl/src/token.rs index fbb501cb9c..44f2f64d05 100644 --- a/spl/src/token.rs +++ b/spl/src/token.rs @@ -23,11 +23,7 @@ pub fn transfer<'info>( )?; solana_program::program::invoke_signed( &ix, - &[ - ctx.accounts.from.clone(), - ctx.accounts.to.clone(), - ctx.accounts.authority.clone(), - ], + &[ctx.accounts.from, ctx.accounts.to, ctx.accounts.authority], ctx.signer_seeds, ) .map_err(Into::into) @@ -51,10 +47,10 @@ pub fn transfer_checked<'info>( solana_program::program::invoke_signed( &ix, &[ - ctx.accounts.from.clone(), - ctx.accounts.mint.clone(), - ctx.accounts.to.clone(), - ctx.accounts.authority.clone(), + ctx.accounts.from, + ctx.accounts.mint, + ctx.accounts.to, + ctx.accounts.authority, ], ctx.signer_seeds, ) @@ -75,11 +71,7 @@ pub fn mint_to<'info>( )?; solana_program::program::invoke_signed( &ix, - &[ - ctx.accounts.to.clone(), - ctx.accounts.mint.clone(), - ctx.accounts.authority.clone(), - ], + &[ctx.accounts.to, ctx.accounts.mint, ctx.accounts.authority], ctx.signer_seeds, ) .map_err(Into::into) @@ -96,11 +88,7 @@ pub fn burn<'info>(ctx: CpiContext<'_, '_, '_, 'info, Burn<'info>>, amount: u64) )?; solana_program::program::invoke_signed( &ix, - &[ - ctx.accounts.from.clone(), - ctx.accounts.mint.clone(), - ctx.accounts.authority.clone(), - ], + &[ctx.accounts.from, ctx.accounts.mint, ctx.accounts.authority], ctx.signer_seeds, ) .map_err(Into::into) @@ -121,9 +109,9 @@ pub fn approve<'info>( solana_program::program::invoke_signed( &ix, &[ - ctx.accounts.to.clone(), - ctx.accounts.delegate.clone(), - ctx.accounts.authority.clone(), + ctx.accounts.to, + ctx.accounts.delegate, + ctx.accounts.authority, ], ctx.signer_seeds, ) @@ -148,10 +136,10 @@ pub fn approve_checked<'info>( solana_program::program::invoke_signed( &ix, &[ - ctx.accounts.to.clone(), - ctx.accounts.mint.clone(), - ctx.accounts.delegate.clone(), - ctx.accounts.authority.clone(), + ctx.accounts.to, + ctx.accounts.mint, + ctx.accounts.delegate, + ctx.accounts.authority, ], ctx.signer_seeds, ) @@ -167,7 +155,7 @@ pub fn revoke<'info>(ctx: CpiContext<'_, '_, '_, 'info, Revoke<'info>>) -> Resul )?; solana_program::program::invoke_signed( &ix, - &[ctx.accounts.source.clone(), ctx.accounts.authority.clone()], + &[ctx.accounts.source, ctx.accounts.authority], ctx.signer_seeds, ) .map_err(Into::into) @@ -185,10 +173,10 @@ pub fn initialize_account<'info>( solana_program::program::invoke_signed( &ix, &[ - ctx.accounts.account.clone(), - ctx.accounts.mint.clone(), - ctx.accounts.authority.clone(), - ctx.accounts.rent.clone(), + ctx.accounts.account, + ctx.accounts.mint, + ctx.accounts.authority, + ctx.accounts.rent, ], ctx.signer_seeds, ) @@ -206,7 +194,7 @@ pub fn initialize_account3<'info>( )?; solana_program::program::invoke_signed( &ix, - &[ctx.accounts.account.clone(), ctx.accounts.mint.clone()], + &[ctx.accounts.account, ctx.accounts.mint], ctx.signer_seeds, ) .map_err(Into::into) @@ -223,9 +211,9 @@ pub fn close_account<'info>(ctx: CpiContext<'_, '_, '_, 'info, CloseAccount<'inf solana_program::program::invoke_signed( &ix, &[ - ctx.accounts.account.clone(), - ctx.accounts.destination.clone(), - ctx.accounts.authority.clone(), + ctx.accounts.account, + ctx.accounts.destination, + ctx.accounts.authority, ], ctx.signer_seeds, ) @@ -245,9 +233,9 @@ pub fn freeze_account<'info>( solana_program::program::invoke_signed( &ix, &[ - ctx.accounts.account.clone(), - ctx.accounts.mint.clone(), - ctx.accounts.authority.clone(), + ctx.accounts.account, + ctx.accounts.mint, + ctx.accounts.authority, ], ctx.signer_seeds, ) @@ -265,9 +253,9 @@ pub fn thaw_account<'info>(ctx: CpiContext<'_, '_, '_, 'info, ThawAccount<'info> solana_program::program::invoke_signed( &ix, &[ - ctx.accounts.account.clone(), - ctx.accounts.mint.clone(), - ctx.accounts.authority.clone(), + ctx.accounts.account, + ctx.accounts.mint, + ctx.accounts.authority, ], ctx.signer_seeds, ) @@ -289,7 +277,7 @@ pub fn initialize_mint<'info>( )?; solana_program::program::invoke_signed( &ix, - &[ctx.accounts.mint.clone(), ctx.accounts.rent.clone()], + &[ctx.accounts.mint, ctx.accounts.rent], ctx.signer_seeds, ) .map_err(Into::into) @@ -308,7 +296,7 @@ pub fn initialize_mint2<'info>( freeze_authority, decimals, )?; - solana_program::program::invoke_signed(&ix, &[ctx.accounts.mint.clone()], ctx.signer_seeds) + solana_program::program::invoke_signed(&ix, &[ctx.accounts.mint], ctx.signer_seeds) .map_err(Into::into) } @@ -332,10 +320,7 @@ pub fn set_authority<'info>( )?; solana_program::program::invoke_signed( &ix, - &[ - ctx.accounts.account_or_mint.clone(), - ctx.accounts.current_authority.clone(), - ], + &[ctx.accounts.account_or_mint, ctx.accounts.current_authority], ctx.signer_seeds, ) .map_err(Into::into) @@ -343,11 +328,12 @@ pub fn set_authority<'info>( pub fn sync_native<'info>(ctx: CpiContext<'_, '_, '_, 'info, SyncNative<'info>>) -> Result<()> { let ix = spl_token::instruction::sync_native(&spl_token::ID, ctx.accounts.account.key)?; - solana_program::program::invoke_signed(&ix, &[ctx.accounts.account.clone()], ctx.signer_seeds) + solana_program::program::invoke_signed(&ix, &[ctx.accounts.account], ctx.signer_seeds) .map_err(Into::into) } #[derive(Accounts)] +#[only_cpi] pub struct Transfer<'info> { pub from: AccountInfo<'info>, pub to: AccountInfo<'info>, @@ -355,6 +341,7 @@ pub struct Transfer<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct TransferChecked<'info> { pub from: AccountInfo<'info>, pub mint: AccountInfo<'info>, @@ -363,6 +350,7 @@ pub struct TransferChecked<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct MintTo<'info> { pub mint: AccountInfo<'info>, pub to: AccountInfo<'info>, @@ -370,6 +358,7 @@ pub struct MintTo<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct Burn<'info> { pub mint: AccountInfo<'info>, pub from: AccountInfo<'info>, @@ -377,6 +366,7 @@ pub struct Burn<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct Approve<'info> { pub to: AccountInfo<'info>, pub delegate: AccountInfo<'info>, @@ -384,6 +374,7 @@ pub struct Approve<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct ApproveChecked<'info> { pub to: AccountInfo<'info>, pub mint: AccountInfo<'info>, @@ -392,12 +383,14 @@ pub struct ApproveChecked<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct Revoke<'info> { pub source: AccountInfo<'info>, pub authority: AccountInfo<'info>, } #[derive(Accounts)] +#[only_cpi] pub struct InitializeAccount<'info> { pub account: AccountInfo<'info>, pub mint: AccountInfo<'info>, @@ -406,6 +399,7 @@ pub struct InitializeAccount<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct InitializeAccount3<'info> { pub account: AccountInfo<'info>, pub mint: AccountInfo<'info>, @@ -413,6 +407,7 @@ pub struct InitializeAccount3<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct CloseAccount<'info> { pub account: AccountInfo<'info>, pub destination: AccountInfo<'info>, @@ -420,6 +415,7 @@ pub struct CloseAccount<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct FreezeAccount<'info> { pub account: AccountInfo<'info>, pub mint: AccountInfo<'info>, @@ -427,6 +423,7 @@ pub struct FreezeAccount<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct ThawAccount<'info> { pub account: AccountInfo<'info>, pub mint: AccountInfo<'info>, @@ -434,23 +431,27 @@ pub struct ThawAccount<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct InitializeMint<'info> { pub mint: AccountInfo<'info>, pub rent: AccountInfo<'info>, } #[derive(Accounts)] +#[only_cpi] pub struct InitializeMint2<'info> { pub mint: AccountInfo<'info>, } #[derive(Accounts)] +#[only_cpi] pub struct SetAuthority<'info> { pub current_authority: AccountInfo<'info>, pub account_or_mint: AccountInfo<'info>, } #[derive(Accounts)] +#[only_cpi] pub struct SyncNative<'info> { pub account: AccountInfo<'info>, } diff --git a/spl/src/token_2022.rs b/spl/src/token_2022.rs index 561c7b3f28..f97c761b40 100644 --- a/spl/src/token_2022.rs +++ b/spl/src/token_2022.rs @@ -26,11 +26,7 @@ pub fn transfer<'info>( )?; solana_program::program::invoke_signed( &ix, - &[ - ctx.accounts.from.clone(), - ctx.accounts.to.clone(), - ctx.accounts.authority.clone(), - ], + &[ctx.accounts.from, ctx.accounts.to, ctx.accounts.authority], ctx.signer_seeds, ) .map_err(Into::into) @@ -54,10 +50,10 @@ pub fn transfer_checked<'info>( solana_program::program::invoke_signed( &ix, &[ - ctx.accounts.from.clone(), - ctx.accounts.mint.clone(), - ctx.accounts.to.clone(), - ctx.accounts.authority.clone(), + ctx.accounts.from, + ctx.accounts.mint, + ctx.accounts.to, + ctx.accounts.authority, ], ctx.signer_seeds, ) @@ -78,11 +74,7 @@ pub fn mint_to<'info>( )?; solana_program::program::invoke_signed( &ix, - &[ - ctx.accounts.to.clone(), - ctx.accounts.mint.clone(), - ctx.accounts.authority.clone(), - ], + &[ctx.accounts.to, ctx.accounts.mint, ctx.accounts.authority], ctx.signer_seeds, ) .map_err(Into::into) @@ -99,11 +91,7 @@ pub fn burn<'info>(ctx: CpiContext<'_, '_, '_, 'info, Burn<'info>>, amount: u64) )?; solana_program::program::invoke_signed( &ix, - &[ - ctx.accounts.from.clone(), - ctx.accounts.mint.clone(), - ctx.accounts.authority.clone(), - ], + &[ctx.accounts.from, ctx.accounts.mint, ctx.accounts.authority], ctx.signer_seeds, ) .map_err(Into::into) @@ -124,9 +112,9 @@ pub fn approve<'info>( solana_program::program::invoke_signed( &ix, &[ - ctx.accounts.to.clone(), - ctx.accounts.delegate.clone(), - ctx.accounts.authority.clone(), + ctx.accounts.to, + ctx.accounts.delegate, + ctx.accounts.authority, ], ctx.signer_seeds, ) @@ -142,7 +130,7 @@ pub fn revoke<'info>(ctx: CpiContext<'_, '_, '_, 'info, Revoke<'info>>) -> Resul )?; solana_program::program::invoke_signed( &ix, - &[ctx.accounts.source.clone(), ctx.accounts.authority.clone()], + &[ctx.accounts.source, ctx.accounts.authority], ctx.signer_seeds, ) .map_err(Into::into) @@ -160,10 +148,10 @@ pub fn initialize_account<'info>( solana_program::program::invoke( &ix, &[ - ctx.accounts.account.clone(), - ctx.accounts.mint.clone(), - ctx.accounts.authority.clone(), - ctx.accounts.rent.clone(), + ctx.accounts.account, + ctx.accounts.mint, + ctx.accounts.authority, + ctx.accounts.rent, ], ) .map_err(Into::into) @@ -178,11 +166,8 @@ pub fn initialize_account3<'info>( ctx.accounts.mint.key, ctx.accounts.authority.key, )?; - solana_program::program::invoke( - &ix, - &[ctx.accounts.account.clone(), ctx.accounts.mint.clone()], - ) - .map_err(Into::into) + solana_program::program::invoke(&ix, &[ctx.accounts.account, ctx.accounts.mint]) + .map_err(Into::into) } pub fn close_account<'info>(ctx: CpiContext<'_, '_, '_, 'info, CloseAccount<'info>>) -> Result<()> { @@ -196,9 +181,9 @@ pub fn close_account<'info>(ctx: CpiContext<'_, '_, '_, 'info, CloseAccount<'inf solana_program::program::invoke_signed( &ix, &[ - ctx.accounts.account.clone(), - ctx.accounts.destination.clone(), - ctx.accounts.authority.clone(), + ctx.accounts.account, + ctx.accounts.destination, + ctx.accounts.authority, ], ctx.signer_seeds, ) @@ -218,9 +203,9 @@ pub fn freeze_account<'info>( solana_program::program::invoke_signed( &ix, &[ - ctx.accounts.account.clone(), - ctx.accounts.mint.clone(), - ctx.accounts.authority.clone(), + ctx.accounts.account, + ctx.accounts.mint, + ctx.accounts.authority, ], ctx.signer_seeds, ) @@ -238,9 +223,9 @@ pub fn thaw_account<'info>(ctx: CpiContext<'_, '_, '_, 'info, ThawAccount<'info> solana_program::program::invoke_signed( &ix, &[ - ctx.accounts.account.clone(), - ctx.accounts.mint.clone(), - ctx.accounts.authority.clone(), + ctx.accounts.account, + ctx.accounts.mint, + ctx.accounts.authority, ], ctx.signer_seeds, ) @@ -260,7 +245,7 @@ pub fn initialize_mint<'info>( freeze_authority, decimals, )?; - solana_program::program::invoke(&ix, &[ctx.accounts.mint.clone(), ctx.accounts.rent.clone()]) + solana_program::program::invoke(&ix, &[ctx.accounts.mint, ctx.accounts.rent]) .map_err(Into::into) } @@ -277,7 +262,7 @@ pub fn initialize_mint2<'info>( freeze_authority, decimals, )?; - solana_program::program::invoke(&ix, &[ctx.accounts.mint.clone()]).map_err(Into::into) + solana_program::program::invoke(&ix, &[ctx.accounts.mint]).map_err(Into::into) } pub fn set_authority<'info>( @@ -300,10 +285,7 @@ pub fn set_authority<'info>( )?; solana_program::program::invoke_signed( &ix, - &[ - ctx.accounts.account_or_mint.clone(), - ctx.accounts.current_authority.clone(), - ], + &[ctx.accounts.account_or_mint, ctx.accounts.current_authority], ctx.signer_seeds, ) .map_err(Into::into) @@ -311,7 +293,7 @@ pub fn set_authority<'info>( pub fn sync_native<'info>(ctx: CpiContext<'_, '_, '_, 'info, SyncNative<'info>>) -> Result<()> { let ix = spl_token_2022::instruction::sync_native(ctx.program.key, ctx.accounts.account.key)?; - solana_program::program::invoke(&ix, &[ctx.accounts.account.clone()]).map_err(Into::into) + solana_program::program::invoke(&ix, &[ctx.accounts.account]).map_err(Into::into) } pub fn get_account_data_size<'info>( @@ -323,7 +305,7 @@ pub fn get_account_data_size<'info>( ctx.accounts.mint.key, extension_types, )?; - solana_program::program::invoke(&ix, &[ctx.accounts.mint.clone()])?; + solana_program::program::invoke(&ix, &[ctx.accounts.mint])?; solana_program::program::get_return_data() .ok_or(solana_program::program_error::ProgramError::InvalidInstructionData) .and_then(|(key, data)| { @@ -347,7 +329,7 @@ pub fn initialize_mint_close_authority<'info>( ctx.accounts.mint.key, close_authority, )?; - solana_program::program::invoke(&ix, &[ctx.accounts.mint.clone()]).map_err(Into::into) + solana_program::program::invoke(&ix, &[ctx.accounts.mint]).map_err(Into::into) } pub fn initialize_immutable_owner<'info>( @@ -357,7 +339,7 @@ pub fn initialize_immutable_owner<'info>( ctx.program.key, ctx.accounts.account.key, )?; - solana_program::program::invoke(&ix, &[ctx.accounts.account.clone()]).map_err(Into::into) + solana_program::program::invoke(&ix, &[ctx.accounts.account]).map_err(Into::into) } pub fn amount_to_ui_amount<'info>( @@ -369,7 +351,7 @@ pub fn amount_to_ui_amount<'info>( ctx.accounts.account.key, amount, )?; - solana_program::program::invoke(&ix, &[ctx.accounts.account.clone()])?; + solana_program::program::invoke(&ix, &[ctx.accounts.account])?; solana_program::program::get_return_data() .ok_or(solana_program::program_error::ProgramError::InvalidInstructionData) .and_then(|(key, data)| { @@ -393,7 +375,7 @@ pub fn ui_amount_to_amount<'info>( ctx.accounts.account.key, ui_amount, )?; - solana_program::program::invoke(&ix, &[ctx.accounts.account.clone()])?; + solana_program::program::invoke(&ix, &[ctx.accounts.account])?; solana_program::program::get_return_data() .ok_or(solana_program::program_error::ProgramError::InvalidInstructionData) .and_then(|(key, data)| { @@ -409,6 +391,7 @@ pub fn ui_amount_to_amount<'info>( } #[derive(Accounts)] +#[only_cpi] pub struct Transfer<'info> { pub from: AccountInfo<'info>, pub to: AccountInfo<'info>, @@ -416,6 +399,7 @@ pub struct Transfer<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct TransferChecked<'info> { pub from: AccountInfo<'info>, pub mint: AccountInfo<'info>, @@ -424,6 +408,7 @@ pub struct TransferChecked<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct MintTo<'info> { pub mint: AccountInfo<'info>, pub to: AccountInfo<'info>, @@ -431,6 +416,7 @@ pub struct MintTo<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct Burn<'info> { pub mint: AccountInfo<'info>, pub from: AccountInfo<'info>, @@ -438,6 +424,7 @@ pub struct Burn<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct Approve<'info> { pub to: AccountInfo<'info>, pub delegate: AccountInfo<'info>, @@ -445,12 +432,14 @@ pub struct Approve<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct Revoke<'info> { pub source: AccountInfo<'info>, pub authority: AccountInfo<'info>, } #[derive(Accounts)] +#[only_cpi] pub struct InitializeAccount<'info> { pub account: AccountInfo<'info>, pub mint: AccountInfo<'info>, @@ -459,6 +448,7 @@ pub struct InitializeAccount<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct InitializeAccount3<'info> { pub account: AccountInfo<'info>, pub mint: AccountInfo<'info>, @@ -466,6 +456,7 @@ pub struct InitializeAccount3<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct CloseAccount<'info> { pub account: AccountInfo<'info>, pub destination: AccountInfo<'info>, @@ -473,6 +464,7 @@ pub struct CloseAccount<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct FreezeAccount<'info> { pub account: AccountInfo<'info>, pub mint: AccountInfo<'info>, @@ -480,6 +472,7 @@ pub struct FreezeAccount<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct ThawAccount<'info> { pub account: AccountInfo<'info>, pub mint: AccountInfo<'info>, @@ -487,48 +480,57 @@ pub struct ThawAccount<'info> { } #[derive(Accounts)] +#[only_cpi] pub struct InitializeMint<'info> { pub mint: AccountInfo<'info>, pub rent: AccountInfo<'info>, } #[derive(Accounts)] +#[only_cpi] pub struct InitializeMint2<'info> { pub mint: AccountInfo<'info>, } #[derive(Accounts)] +#[only_cpi] pub struct SetAuthority<'info> { pub current_authority: AccountInfo<'info>, pub account_or_mint: AccountInfo<'info>, } #[derive(Accounts)] +#[only_cpi] pub struct SyncNative<'info> { pub account: AccountInfo<'info>, } #[derive(Accounts)] +#[only_cpi] pub struct GetAccountDataSize<'info> { pub mint: AccountInfo<'info>, } #[derive(Accounts)] +#[only_cpi] pub struct InitializeMintCloseAuthority<'info> { pub mint: AccountInfo<'info>, } #[derive(Accounts)] +#[only_cpi] pub struct InitializeImmutableOwner<'info> { pub account: AccountInfo<'info>, } #[derive(Accounts)] +#[only_cpi] pub struct AmountToUiAmount<'info> { pub account: AccountInfo<'info>, } #[derive(Accounts)] +#[only_cpi] pub struct UiAmountToAmount<'info> { pub account: AccountInfo<'info>, } diff --git a/tests/misc/programs/misc-optional/src/context.rs b/tests/misc/programs/misc-optional/src/context.rs index 04ec786f49..2375120602 100644 --- a/tests/misc/programs/misc-optional/src/context.rs +++ b/tests/misc/programs/misc-optional/src/context.rs @@ -25,7 +25,7 @@ pub struct TestTokenSeedsInit<'info> { pub my_pda: Option>, #[account(mut)] /// CHECK: - pub authority: Option>, + pub authority: Option>, pub system_program: Option>, pub token_program: Option>, } @@ -61,7 +61,7 @@ pub struct TestInitAssociatedTokenWithTokenProgram<'info> { pub payer: Option>, pub system_program: Option>, /// CHECK: ignore - pub associated_token_token_program: Option>, + pub associated_token_token_program: Option>, pub associated_token_program: Option>, } @@ -74,7 +74,7 @@ pub struct TestValidateAssociatedToken<'info> { pub token: Option>, pub mint: Option>, /// CHECK: - pub wallet: Option>, + pub wallet: Option>, } #[derive(Accounts)] @@ -85,9 +85,9 @@ pub struct TestInstructionConstraint<'info> { bump = nonce, )] /// CHECK: - pub my_pda: Option>, + pub my_pda: Option>, /// CHECK: - pub my_account: Option>, + pub my_account: Option>, } #[derive(Accounts)] @@ -104,7 +104,7 @@ pub struct TestPdaInit<'info> { #[account(mut)] pub my_payer: Option>, /// CHECK: - pub foo: Option>, + pub foo: Option>, pub system_program: Option>, } @@ -132,7 +132,7 @@ pub struct TestPdaMutZeroCopy<'info> { )] pub my_pda: Option>, /// CHECK: - pub my_payer: Option>, + pub my_payer: Option>, } #[derive(Accounts)] @@ -150,23 +150,23 @@ pub struct InitializeSkipRentExempt<'info> { #[derive(Accounts)] pub struct InitializeNoRentExempt<'info> { /// CHECK: - pub data: Option>, + pub data: Option>, } #[derive(Accounts)] pub struct TestOwner<'info> { #[account(owner = *misc.key)] /// CHECK: - pub data: Option>, + pub data: Option>, /// CHECK: - pub misc: AccountInfo<'info>, + pub misc: UncheckedAccount<'info>, } #[derive(Accounts)] pub struct TestExecutable<'info> { #[account(executable)] /// CHECK: - pub program: Option>, + pub program: Option>, } #[derive(Accounts)] @@ -174,7 +174,7 @@ pub struct TestClose<'info> { #[account(mut, close = sol_dest)] pub data: Option>, /// CHECK: - sol_dest: Option>, + sol_dest: Option>, } #[derive(Accounts)] @@ -182,7 +182,7 @@ pub struct TestCloseTwice<'info> { #[account(mut, close = sol_dest)] pub data: Option>, /// CHECK: - pub sol_dest: Option>, + pub sol_dest: Option>, } #[derive(Accounts)] @@ -190,7 +190,7 @@ pub struct TestCloseMut<'info> { #[account(mut)] pub data: Option>, /// CHECK: - pub sol_dest: Option>, + pub sol_dest: Option>, } #[derive(Accounts)] @@ -265,7 +265,7 @@ pub struct TestInitMintWithTokenProgram<'info> { pub payer: Option>, pub system_program: Option>, /// CHECK: ignore - pub mint_token_program: Option>, + pub mint_token_program: Option>, } #[derive(Accounts)] @@ -293,7 +293,7 @@ pub struct TestInitTokenWithTokenProgram<'info> { pub payer: Option>, pub system_program: Option>, /// CHECK: ignore - pub token_token_program: Option>, + pub token_token_program: Option>, } #[derive(Accounts)] @@ -318,7 +318,7 @@ pub struct TestInitWithEmptySeeds<'info> { pub struct TestEmptySeedsConstraint<'info> { #[account(seeds = [], bump)] /// CHECK: - pub pda: Option>, + pub pda: Option>, } #[derive(Accounts)] @@ -349,7 +349,7 @@ pub struct TestInitIfNeededChecksOwner<'info> { pub payer: Option>, pub system_program: Option>, /// CHECK: - pub owner: AccountInfo<'info>, + pub owner: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -373,9 +373,9 @@ pub struct TestInitMintIfNeeded<'info> { pub system_program: Option>, pub token_program: Option>, /// CHECK: - pub mint_authority: Option>, + pub mint_authority: Option>, /// CHECK: - pub freeze_authority: Option>, + pub freeze_authority: Option>, } #[derive(Accounts)] @@ -392,11 +392,11 @@ pub struct TestInitMintIfNeededWithTokenProgram<'info> { pub payer: Option>, pub system_program: Option>, /// CHECK: ignore - pub mint_token_program: Option>, + pub mint_token_program: Option>, /// CHECK: ignore - pub mint_authority: Option>, + pub mint_authority: Option>, /// CHECK: ignore - pub freeze_authority: Option>, + pub freeze_authority: Option>, } #[derive(Accounts)] @@ -409,7 +409,7 @@ pub struct TestInitTokenIfNeeded<'info> { pub system_program: Option>, pub token_program: Option>, /// CHECK: - pub authority: Option>, + pub authority: Option>, } #[derive(Accounts)] @@ -426,9 +426,9 @@ pub struct TestInitTokenIfNeededWithTokenProgram<'info> { pub payer: Option>, pub system_program: Option>, /// CHECK: ignore - pub token_token_program: Option>, + pub token_token_program: Option>, /// CHECK: - pub authority: Option>, + pub authority: Option>, } #[derive(Accounts)] @@ -446,7 +446,7 @@ pub struct TestInitAssociatedTokenIfNeeded<'info> { pub token_program: Option>, pub associated_token_program: Option>, /// CHECK: - pub authority: Option>, + pub authority: Option>, } #[derive(Accounts)] @@ -463,10 +463,10 @@ pub struct TestInitAssociatedTokenIfNeededWithTokenProgram<'info> { pub payer: Option>, pub system_program: Option>, /// CHECK: ignore - pub associated_token_token_program: Option>, + pub associated_token_token_program: Option>, pub associated_token_program: Option>, /// CHECK: ignore - pub authority: Option>, + pub authority: Option>, } #[derive(Accounts)] @@ -496,21 +496,21 @@ pub struct TestMultidimensionalArrayConstSizes<'info> { #[derive(Accounts)] pub struct NoRentExempt<'info> { /// CHECK: - pub data: Option>, + pub data: Option>, } #[derive(Accounts)] pub struct EnforceRentExempt<'info> { #[account(rent_exempt = enforce)] /// CHECK: - pub data: Option>, + pub data: Option>, } #[derive(Accounts)] pub struct InitDecreaseLamports<'info> { #[account(init, payer = user, space = 1000)] /// CHECK: - pub data: Option>, + pub data: Option>, #[account(mut)] pub user: Option>, pub system_program: Option>, @@ -520,7 +520,7 @@ pub struct InitDecreaseLamports<'info> { pub struct InitIfNeededChecksRentExemption<'info> { #[account(init_if_needed, payer = user, space = 1000)] /// CHECK: - pub data: Option>, + pub data: Option>, #[account(mut)] pub user: Option>, pub system_program: Option>, @@ -533,11 +533,11 @@ pub struct TestProgramIdConstraint<'info> { // just deriving like this for testing purposes #[account(seeds = [b"seed"], bump = bump, seeds::program = anchor_spl::associated_token::ID)] /// CHECK: - first: Option>, + first: Option>, #[account(seeds = [b"seed"], bump = second_bump, seeds::program = crate::ID)] /// CHECK: - second: Option>, + second: Option>, } #[derive(Accounts)] @@ -546,11 +546,11 @@ pub struct TestProgramIdConstraintUsingFindPda<'info> { // just deriving like this for testing purposes #[account(seeds = [b"seed"], bump, seeds::program = anchor_spl::associated_token::ID)] /// CHECK: - first: Option>, + first: Option>, #[account(seeds = [b"seed"], bump, seeds::program = crate::ID)] /// CHECK: - second: Option>, + second: Option>, } #[derive(Accounts)] @@ -592,7 +592,7 @@ pub struct TestAuthorityConstraint<'info> { )] pub token: Option>, pub mint: Option>, - pub fake_authority: Option>, + pub fake_authority: Option>, } #[derive(Accounts)] pub struct TestOnlyAuthorityConstraint<'info> { @@ -610,7 +610,7 @@ pub struct TestOnlyTokenProgramConstraint<'info> { token::token_program = token_token_program )] pub token: Option>, - pub token_token_program: Option>, + pub token_token_program: Option>, } #[derive(Accounts)] @@ -631,8 +631,8 @@ pub struct TestMintConstraint<'info> { mint::freeze_authority = freeze_authority )] pub mint: Option>, - pub mint_authority: Option>, - pub freeze_authority: Option>, + pub mint_authority: Option>, + pub freeze_authority: Option>, } #[derive(Accounts)] @@ -651,8 +651,8 @@ pub struct TestMintAuthorityConstraint<'info> { mint::freeze_authority = freeze_authority )] pub mint: Option>, - pub mint_authority: Option>, - pub freeze_authority: Option>, + pub mint_authority: Option>, + pub freeze_authority: Option>, } #[derive(Accounts)] @@ -661,7 +661,7 @@ pub struct TestMintOneAuthorityConstraint<'info> { mint::authority = mint_authority, )] pub mint: Option>, - pub mint_authority: Option>, + pub mint_authority: Option>, } #[derive(Accounts)] @@ -672,7 +672,7 @@ pub struct TestMintMissMintAuthConstraint<'info> { mint::freeze_authority = freeze_authority, )] pub mint: Option>, - pub freeze_authority: Option>, + pub freeze_authority: Option>, } #[derive(Accounts)] @@ -682,7 +682,7 @@ pub struct TestMintOnlyTokenProgramConstraint<'info> { )] pub mint: Option>, /// CHECK: ignore - pub mint_token_program: Option>, + pub mint_token_program: Option>, } #[derive(Accounts)] @@ -693,7 +693,7 @@ pub struct TestAssociatedToken<'info> { )] pub token: Option>, pub mint: Option>, - pub authority: Option>, + pub authority: Option>, } #[derive(Accounts)] @@ -706,7 +706,7 @@ pub struct TestAssociatedTokenWithTokenProgramConstraint<'info> { pub token: Option>, pub mint: Account<'info, Mint>, /// CHECK: ignore - pub authority: AccountInfo<'info>, + pub authority: UncheckedAccount<'info>, /// CHECK: ignore - pub associated_token_token_program: Option>, + pub associated_token_token_program: Option>, } diff --git a/tests/misc/programs/misc/src/context.rs b/tests/misc/programs/misc/src/context.rs index 3ef62f3bbf..583a1b1bcb 100644 --- a/tests/misc/programs/misc/src/context.rs +++ b/tests/misc/programs/misc/src/context.rs @@ -25,7 +25,7 @@ pub struct TestTokenSeedsInit<'info> { pub my_pda: Account<'info, TokenAccount>, #[account(mut)] /// CHECK: - pub authority: AccountInfo<'info>, + pub authority: UncheckedAccount<'info>, pub system_program: Program<'info, System>, pub token_program: Program<'info, Token>, } @@ -62,7 +62,7 @@ pub struct TestInitAssociatedTokenWithTokenProgram<'info> { pub payer: Signer<'info>, pub system_program: Program<'info, System>, /// CHECK: ignore - pub associated_token_token_program: AccountInfo<'info>, + pub associated_token_token_program: UncheckedAccount<'info>, pub associated_token_program: Program<'info, AssociatedToken>, } @@ -75,7 +75,7 @@ pub struct TestValidateAssociatedToken<'info> { pub token: Account<'info, TokenAccount>, pub mint: Account<'info, Mint>, /// CHECK: - pub wallet: AccountInfo<'info>, + pub wallet: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -86,9 +86,9 @@ pub struct TestInstructionConstraint<'info> { bump = nonce, )] /// CHECK: - pub my_pda: AccountInfo<'info>, + pub my_pda: UncheckedAccount<'info>, /// CHECK: - pub my_account: AccountInfo<'info>, + pub my_account: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -105,7 +105,7 @@ pub struct TestPdaInit<'info> { #[account(mut)] pub my_payer: Signer<'info>, /// CHECK: - pub foo: AccountInfo<'info>, + pub foo: UncheckedAccount<'info>, pub system_program: Program<'info, System>, } @@ -133,7 +133,7 @@ pub struct TestPdaMutZeroCopy<'info> { )] pub my_pda: AccountLoader<'info, DataZeroCopy>, /// CHECK: - pub my_payer: AccountInfo<'info>, + pub my_payer: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -157,23 +157,23 @@ pub struct InitializeSkipRentExempt<'info> { #[derive(Accounts)] pub struct InitializeNoRentExempt<'info> { /// CHECK: - pub data: AccountInfo<'info>, + pub data: UncheckedAccount<'info>, } #[derive(Accounts)] pub struct TestOwner<'info> { #[account(owner = *misc.key)] /// CHECK: - pub data: AccountInfo<'info>, + pub data: UncheckedAccount<'info>, /// CHECK: - pub misc: AccountInfo<'info>, + pub misc: UncheckedAccount<'info>, } #[derive(Accounts)] pub struct TestExecutable<'info> { #[account(executable)] /// CHECK: - pub program: AccountInfo<'info>, + pub program: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -181,7 +181,7 @@ pub struct TestClose<'info> { #[account(mut, close = sol_dest)] pub data: Account<'info, Data>, /// CHECK: - sol_dest: AccountInfo<'info>, + sol_dest: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -189,7 +189,7 @@ pub struct TestCloseTwice<'info> { #[account(mut, close = sol_dest)] pub data: Account<'info, Data>, /// CHECK: - pub sol_dest: AccountInfo<'info>, + pub sol_dest: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -197,7 +197,7 @@ pub struct TestCloseMut<'info> { #[account(mut)] pub data: Account<'info, Data>, /// CHECK: - pub sol_dest: AccountInfo<'info>, + pub sol_dest: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -263,7 +263,7 @@ pub struct TestInitMintWithTokenProgram<'info> { pub payer: Signer<'info>, pub system_program: Program<'info, System>, /// CHECK: ignore - pub mint_token_program: AccountInfo<'info>, + pub mint_token_program: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -291,7 +291,7 @@ pub struct TestInitTokenWithTokenProgram<'info> { pub payer: Signer<'info>, pub system_program: Program<'info, System>, /// CHECK: ignore - pub token_token_program: AccountInfo<'info>, + pub token_token_program: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -324,7 +324,7 @@ pub struct TestInitWithEmptySeeds<'info> { pub struct TestEmptySeedsConstraint<'info> { #[account(seeds = [], bump)] /// CHECK: - pub pda: AccountInfo<'info>, + pub pda: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -355,7 +355,7 @@ pub struct TestInitIfNeededChecksOwner<'info> { pub payer: Signer<'info>, pub system_program: Program<'info, System>, /// CHECK: - pub owner: AccountInfo<'info>, + pub owner: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -379,9 +379,9 @@ pub struct TestInitMintIfNeeded<'info> { pub system_program: Program<'info, System>, pub token_program: Program<'info, Token>, /// CHECK: - pub mint_authority: AccountInfo<'info>, + pub mint_authority: UncheckedAccount<'info>, /// CHECK: - pub freeze_authority: AccountInfo<'info>, + pub freeze_authority: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -398,11 +398,11 @@ pub struct TestInitMintIfNeededWithTokenProgram<'info> { pub payer: Signer<'info>, pub system_program: Program<'info, System>, /// CHECK: ignore - pub mint_token_program: AccountInfo<'info>, + pub mint_token_program: UncheckedAccount<'info>, /// CHECK: ignore - pub mint_authority: AccountInfo<'info>, + pub mint_authority: UncheckedAccount<'info>, /// CHECK: ignore - pub freeze_authority: AccountInfo<'info>, + pub freeze_authority: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -415,7 +415,7 @@ pub struct TestInitTokenIfNeeded<'info> { pub system_program: Program<'info, System>, pub token_program: Program<'info, Token>, /// CHECK: - pub authority: AccountInfo<'info>, + pub authority: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -432,9 +432,9 @@ pub struct TestInitTokenIfNeededWithTokenProgram<'info> { pub payer: Signer<'info>, pub system_program: Program<'info, System>, /// CHECK: ignore - pub token_token_program: AccountInfo<'info>, + pub token_token_program: UncheckedAccount<'info>, /// CHECK: - pub authority: AccountInfo<'info>, + pub authority: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -452,7 +452,7 @@ pub struct TestInitAssociatedTokenIfNeeded<'info> { pub token_program: Program<'info, Token>, pub associated_token_program: Program<'info, AssociatedToken>, /// CHECK: - pub authority: AccountInfo<'info>, + pub authority: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -469,10 +469,10 @@ pub struct TestInitAssociatedTokenIfNeededWithTokenProgram<'info> { pub payer: Signer<'info>, pub system_program: Program<'info, System>, /// CHECK: ignore - pub associated_token_token_program: AccountInfo<'info>, + pub associated_token_token_program: UncheckedAccount<'info>, pub associated_token_program: Program<'info, AssociatedToken>, /// CHECK: ignore - pub authority: AccountInfo<'info>, + pub authority: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -502,21 +502,21 @@ pub struct TestMultidimensionalArrayConstSizes<'info> { #[derive(Accounts)] pub struct NoRentExempt<'info> { /// CHECK: - pub data: AccountInfo<'info>, + pub data: UncheckedAccount<'info>, } #[derive(Accounts)] pub struct EnforceRentExempt<'info> { #[account(rent_exempt = enforce)] /// CHECK: - pub data: AccountInfo<'info>, + pub data: UncheckedAccount<'info>, } #[derive(Accounts)] pub struct InitDecreaseLamports<'info> { #[account(init, payer = user, space = 1000)] /// CHECK: - pub data: AccountInfo<'info>, + pub data: UncheckedAccount<'info>, #[account(mut)] pub user: Signer<'info>, pub system_program: Program<'info, System>, @@ -526,7 +526,7 @@ pub struct InitDecreaseLamports<'info> { pub struct InitIfNeededChecksRentExemption<'info> { #[account(init_if_needed, payer = user, space = 1000)] /// CHECK: - pub data: AccountInfo<'info>, + pub data: UncheckedAccount<'info>, #[account(mut)] pub user: Signer<'info>, pub system_program: Program<'info, System>, @@ -539,11 +539,11 @@ pub struct TestProgramIdConstraint<'info> { // just deriving like this for testing purposes #[account(seeds = [b"seed"], bump = bump, seeds::program = anchor_spl::associated_token::ID)] /// CHECK: - first: AccountInfo<'info>, + first: UncheckedAccount<'info>, #[account(seeds = [b"seed"], bump = second_bump, seeds::program = crate::ID)] /// CHECK: - second: AccountInfo<'info>, + second: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -552,11 +552,11 @@ pub struct TestProgramIdConstraintUsingFindPda<'info> { // just deriving like this for testing purposes #[account(seeds = [b"seed"], bump, seeds::program = anchor_spl::associated_token::ID)] /// CHECK: - first: AccountInfo<'info>, + first: UncheckedAccount<'info>, #[account(seeds = [b"seed"], bump, seeds::program = crate::ID)] /// CHECK: - second: AccountInfo<'info>, + second: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -599,7 +599,7 @@ pub struct TestAuthorityConstraint<'info> { pub token: Account<'info, TokenAccount>, pub mint: Account<'info, Mint>, /// CHECK: ignore - pub fake_authority: AccountInfo<'info>, + pub fake_authority: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -618,7 +618,7 @@ pub struct TestOnlyTokenProgramConstraint<'info> { token::token_program = token_token_program )] pub token: Account<'info, TokenAccount>, - pub token_token_program: AccountInfo<'info>, + pub token_token_program: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -640,9 +640,9 @@ pub struct TestMintConstraint<'info> { )] pub mint: Account<'info, Mint>, /// CHECK: ignore - pub mint_authority: AccountInfo<'info>, + pub mint_authority: UncheckedAccount<'info>, /// CHECK: ignore - pub freeze_authority: AccountInfo<'info>, + pub freeze_authority: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -662,9 +662,9 @@ pub struct TestMintAuthorityConstraint<'info> { )] pub mint: Account<'info, Mint>, /// CHECK: ignore - pub mint_authority: AccountInfo<'info>, + pub mint_authority: UncheckedAccount<'info>, /// CHECK: ignore - pub freeze_authority: AccountInfo<'info>, + pub freeze_authority: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -674,7 +674,7 @@ pub struct TestMintOneAuthorityConstraint<'info> { )] pub mint: Account<'info, Mint>, /// CHECK: ignore - pub mint_authority: AccountInfo<'info>, + pub mint_authority: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -686,7 +686,7 @@ pub struct TestMintMissMintAuthConstraint<'info> { )] pub mint: Account<'info, Mint>, /// CHECK: ignore - pub freeze_authority: AccountInfo<'info>, + pub freeze_authority: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -696,7 +696,7 @@ pub struct TestMintOnlyTokenProgramConstraint<'info> { )] pub mint: Account<'info, Mint>, /// CHECK: ignore - pub mint_token_program: AccountInfo<'info>, + pub mint_token_program: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -708,7 +708,7 @@ pub struct TestAssociatedToken<'info> { pub token: Account<'info, TokenAccount>, pub mint: Account<'info, Mint>, /// CHECK: ignore - pub authority: AccountInfo<'info>, + pub authority: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -721,9 +721,9 @@ pub struct TestAssociatedTokenWithTokenProgramConstraint<'info> { pub token: Account<'info, TokenAccount>, pub mint: Account<'info, Mint>, /// CHECK: ignore - pub authority: AccountInfo<'info>, + pub authority: UncheckedAccount<'info>, /// CHECK: ignore - pub associated_token_token_program: AccountInfo<'info>, + pub associated_token_token_program: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -741,30 +741,30 @@ pub struct TestUsedIdentifiers<'info> { constraint = 4 == remaining_accounts, )] /// CHECK: ignore - pub test: AccountInfo<'info>, + pub test: UncheckedAccount<'info>, #[account( seeds = [&[program_id], &[accounts], &[ix_data], &[remaining_accounts]], bump = program_id, )] /// CHECK: ignore - pub test1: AccountInfo<'info>, + pub test1: UncheckedAccount<'info>, #[account( seeds = [&[program_id], &[accounts], &[ix_data], &[remaining_accounts]], bump = accounts, )] /// CHECK: ignore - pub test2: AccountInfo<'info>, + pub test2: UncheckedAccount<'info>, #[account( seeds = [&[program_id], &[accounts], &[ix_data], &[remaining_accounts]], bump = ix_data, )] /// CHECK: ignore - pub test3: AccountInfo<'info>, + pub test3: UncheckedAccount<'info>, #[account( seeds = [&[program_id], &[accounts], &[ix_data], &[remaining_accounts]], bump = remaining_accounts, )] /// CHECK: ignore - pub test4: AccountInfo<'info>, -} \ No newline at end of file + pub test4: UncheckedAccount<'info>, +} diff --git a/tests/spl/token-proxy/programs/token-proxy/src/lib.rs b/tests/spl/token-proxy/programs/token-proxy/src/lib.rs index c609816f5d..264fd61a70 100644 --- a/tests/spl/token-proxy/programs/token-proxy/src/lib.rs +++ b/tests/spl/token-proxy/programs/token-proxy/src/lib.rs @@ -21,19 +21,19 @@ mod token_proxy { if let Some(token_program) = &ctx.accounts.token_program { if let Some(mint) = &ctx.accounts.mint { let cpi_accounts = TransferChecked { - from: ctx.accounts.from.to_account_info().clone(), - mint: mint.to_account_info().clone(), - to: ctx.accounts.to.to_account_info().clone(), - authority: ctx.accounts.authority.clone(), + from: ctx.accounts.from.to_account_info(), + mint: mint.to_account_info(), + to: ctx.accounts.to.to_account_info(), + authority: ctx.accounts.authority.to_account_info(), }; let cpi_program = token_program.to_account_info(); let cpi_context = CpiContext::new(cpi_program, cpi_accounts); token_interface::transfer_checked(cpi_context, amount, mint.decimals) } else { let cpi_accounts = Transfer { - from: ctx.accounts.from.to_account_info().clone(), - to: ctx.accounts.to.to_account_info().clone(), - authority: ctx.accounts.authority.clone(), + from: ctx.accounts.from.to_account_info(), + to: ctx.accounts.to.to_account_info(), + authority: ctx.accounts.authority.to_account_info(), }; let cpi_program = token_program.to_account_info(); let cpi_context = CpiContext::new(cpi_program, cpi_accounts); @@ -92,7 +92,7 @@ pub enum AuthorityType { pub struct ProxyTransfer<'info> { #[account(signer)] /// CHECK: - pub authority: AccountInfo<'info>, + pub authority: UncheckedAccount<'info>, #[account(mut)] pub from: InterfaceAccount<'info, TokenAccount>, #[account(mut)] @@ -104,7 +104,7 @@ pub struct ProxyTransfer<'info> { pub struct ProxyOptionalTransfer<'info> { #[account(signer)] /// CHECK: - pub authority: AccountInfo<'info>, + pub authority: UncheckedAccount<'info>, #[account(mut)] pub from: InterfaceAccount<'info, TokenAccount>, #[account(mut)] @@ -117,7 +117,7 @@ pub struct ProxyOptionalTransfer<'info> { pub struct ProxyMintTo<'info> { #[account(signer)] /// CHECK: - pub authority: AccountInfo<'info>, + pub authority: UncheckedAccount<'info>, #[account(mut)] pub mint: InterfaceAccount<'info, Mint>, #[account(mut)] @@ -129,7 +129,7 @@ pub struct ProxyMintTo<'info> { pub struct ProxyBurn<'info> { #[account(signer)] /// CHECK: - pub authority: AccountInfo<'info>, + pub authority: UncheckedAccount<'info>, #[account(mut)] pub mint: InterfaceAccount<'info, Mint>, #[account(mut)] @@ -141,10 +141,10 @@ pub struct ProxyBurn<'info> { pub struct ProxySetAuthority<'info> { #[account(signer)] /// CHECK: - pub current_authority: AccountInfo<'info>, + pub current_authority: UncheckedAccount<'info>, #[account(mut)] /// CHECK: - pub account_or_mint: AccountInfo<'info>, + pub account_or_mint: UncheckedAccount<'info>, pub token_program: Interface<'info, TokenInterface>, } @@ -204,9 +204,9 @@ impl<'a, 'b, 'c, 'info> From<&mut ProxyTransfer<'info>> { fn from(accounts: &mut ProxyTransfer<'info>) -> CpiContext<'a, 'b, 'c, 'info, Transfer<'info>> { let cpi_accounts = Transfer { - from: accounts.from.to_account_info().clone(), - to: accounts.to.to_account_info().clone(), - authority: accounts.authority.clone(), + from: accounts.from.to_account_info(), + to: accounts.to.to_account_info(), + authority: accounts.authority.to_account_info(), }; let cpi_program = accounts.token_program.to_account_info(); CpiContext::new(cpi_program, cpi_accounts) @@ -218,9 +218,9 @@ impl<'a, 'b, 'c, 'info> From<&mut ProxyMintTo<'info>> { fn from(accounts: &mut ProxyMintTo<'info>) -> CpiContext<'a, 'b, 'c, 'info, MintTo<'info>> { let cpi_accounts = MintTo { - mint: accounts.mint.to_account_info().clone(), - to: accounts.to.to_account_info().clone(), - authority: accounts.authority.clone(), + mint: accounts.mint.to_account_info(), + to: accounts.to.to_account_info(), + authority: accounts.authority.to_account_info(), }; let cpi_program = accounts.token_program.to_account_info(); CpiContext::new(cpi_program, cpi_accounts) @@ -230,9 +230,9 @@ impl<'a, 'b, 'c, 'info> From<&mut ProxyMintTo<'info>> impl<'a, 'b, 'c, 'info> From<&mut ProxyBurn<'info>> for CpiContext<'a, 'b, 'c, 'info, Burn<'info>> { fn from(accounts: &mut ProxyBurn<'info>) -> CpiContext<'a, 'b, 'c, 'info, Burn<'info>> { let cpi_accounts = Burn { - mint: accounts.mint.to_account_info().clone(), - from: accounts.from.to_account_info().clone(), - authority: accounts.authority.clone(), + mint: accounts.mint.to_account_info(), + from: accounts.from.to_account_info(), + authority: accounts.authority.to_account_info(), }; let cpi_program = accounts.token_program.to_account_info(); CpiContext::new(cpi_program, cpi_accounts) @@ -246,8 +246,8 @@ impl<'a, 'b, 'c, 'info> From<&mut ProxySetAuthority<'info>> accounts: &mut ProxySetAuthority<'info>, ) -> CpiContext<'a, 'b, 'c, 'info, SetAuthority<'info>> { let cpi_accounts = SetAuthority { - account_or_mint: accounts.account_or_mint.clone(), - current_authority: accounts.current_authority.clone(), + account_or_mint: accounts.account_or_mint.to_account_info(), + current_authority: accounts.current_authority.to_account_info(), }; // TODO: Support multisig signers let cpi_program = accounts.token_program.to_account_info(); CpiContext::new(cpi_program, cpi_accounts) diff --git a/tests/spl/token-wrapper/programs/token-wrapper/src/lib.rs b/tests/spl/token-wrapper/programs/token-wrapper/src/lib.rs index f0b12551d3..b8a38727d8 100644 --- a/tests/spl/token-wrapper/programs/token-wrapper/src/lib.rs +++ b/tests/spl/token-wrapper/programs/token-wrapper/src/lib.rs @@ -11,9 +11,7 @@ //! 2. Users can call the unwrap function to burn Y and withdraw X unwrapped tokens use anchor_lang::prelude::*; -use anchor_spl::token_interface::{ - self, Mint, TokenAccount, TokenInterface, -}; +use anchor_spl::token_interface::{self, Mint, TokenAccount, TokenInterface}; declare_id!("4ZPcGU8MX8oL2u1EtErHzixAbgNBNeE9yoYq3kKMqnAy"); @@ -24,16 +22,16 @@ pub mod token_wrapper { pub const WRAPPER_AUTH_SEED: &[u8] = b"wrapr"; pub const WRAPPER_VAULT_SEED: &[u8] = b"vault"; - pub fn initialize( - ctx: Context, - initializer_amount: u64, - ) -> Result<()> { + pub fn initialize(ctx: Context, initializer_amount: u64) -> Result<()> { // deposit into vault token_interface::transfer_checked( CpiContext::new( ctx.accounts.deposit_token_program.to_account_info(), token_interface::TransferChecked { - from: ctx.accounts.initializer_deposit_token_account.to_account_info(), + from: ctx + .accounts + .initializer_deposit_token_account + .to_account_info(), mint: ctx.accounts.deposit_mint.to_account_info(), to: ctx.accounts.deposit_token_vault.to_account_info(), authority: ctx.accounts.initializer.to_account_info(), @@ -56,7 +54,10 @@ pub mod token_wrapper { ctx.accounts.wrapped_token_program.to_account_info(), token_interface::MintTo { mint: ctx.accounts.wrapped_mint.to_account_info(), - to: ctx.accounts.initializer_wrapped_token_account.to_account_info(), + to: ctx + .accounts + .initializer_wrapped_token_account + .to_account_info(), authority: ctx.accounts.wrapper_authority.to_account_info(), }, signer_seeds, @@ -138,7 +139,7 @@ pub mod token_wrapper { to: ctx.accounts.user_deposit_token_account.to_account_info(), authority: ctx.accounts.wrapper_authority.to_account_info(), }, - signer_seeds + signer_seeds, ), unwrap_amount, ctx.accounts.deposit_mint.decimals, @@ -201,7 +202,7 @@ pub struct Initialize<'info> { seeds = [WRAPPER_AUTH_SEED, deposit_mint.key().as_ref(), wrapped_mint.key().as_ref()], bump, )] - pub wrapper_authority: AccountInfo<'info>, + pub wrapper_authority: UncheckedAccount<'info>, pub system_program: Program<'info, System>, pub deposit_token_program: Interface<'info, TokenInterface>, @@ -252,7 +253,7 @@ pub struct Wrap<'info> { seeds = [WRAPPER_AUTH_SEED, deposit_mint.key().as_ref(), wrapped_mint.key().as_ref()], bump, )] - pub wrapper_authority: AccountInfo<'info>, + pub wrapper_authority: UncheckedAccount<'info>, pub deposit_token_program: Interface<'info, TokenInterface>, pub wrapped_token_program: Interface<'info, TokenInterface>, @@ -302,7 +303,7 @@ pub struct Unwrap<'info> { seeds = [crate::token_wrapper::WRAPPER_AUTH_SEED, deposit_mint.key().as_ref(), wrapped_mint.key().as_ref()], bump, )] - pub wrapper_authority: AccountInfo<'info>, + pub wrapper_authority: UncheckedAccount<'info>, pub deposit_token_program: Interface<'info, TokenInterface>, pub wrapped_token_program: Interface<'info, TokenInterface>, From d435a3636d8a5242ab99a26a77fffc3f4c93bedf Mon Sep 17 00:00:00 2001 From: Jean Marchand Date: Tue, 25 Apr 2023 22:55:52 +0200 Subject: [PATCH 02/11] Fix tests --- bench/COMPUTE_UNITS.md | 8 -- tests/auction-house | 2 +- tests/bench/bench.json | 10 +-- tests/bench/programs/bench/src/lib.rs | 47 ---------- tests/bench/scripts/generate-ix.ts | 4 - tests/bench/tests/compute-units.ts | 4 - .../programs/cashiers-check/src/lib.rs | 42 ++++----- tests/chat/programs/chat/src/lib.rs | 2 +- .../programs/native-system/src/lib.rs | 26 +++--- tests/errors/programs/errors/src/lib.rs | 6 +- tests/escrow/programs/escrow/src/lib.rs | 44 ++++------ tests/ido-pool/programs/ido-pool/src/lib.rs | 8 +- tests/multisig/programs/multisig/src/lib.rs | 4 +- .../programs/pda-derivation/src/lib.rs | 4 +- tests/pyth/programs/pyth/src/lib.rs | 4 +- tests/safety-checks/Anchor.toml | 1 - .../programs/account-info/Cargo.toml | 19 ---- .../programs/account-info/Xargo.toml | 2 - .../programs/account-info/src/lib.rs | 16 ---- .../programs/ignore-non-accounts/src/lib.rs | 10 +-- tests/safety-checks/test.sh | 11 --- tests/swap/programs/swap/src/lib.rs | 88 +++++++++---------- tests/zero-copy/programs/zero-copy/src/lib.rs | 2 +- tests/zero-copy/programs/zero-cpi/src/lib.rs | 4 +- 24 files changed, 119 insertions(+), 249 deletions(-) delete mode 100644 tests/safety-checks/programs/account-info/Cargo.toml delete mode 100644 tests/safety-checks/programs/account-info/Xargo.toml delete mode 100644 tests/safety-checks/programs/account-info/src/lib.rs diff --git a/bench/COMPUTE_UNITS.md b/bench/COMPUTE_UNITS.md index 0e68f3a312..3e1f717213 100644 --- a/bench/COMPUTE_UNITS.md +++ b/bench/COMPUTE_UNITS.md @@ -13,10 +13,6 @@ The programs and their tests are located in [/tests/bench](https://github.com/co | Instruction | Compute Units | +/- | | --------------------------- | ------------- | --- | -| accountInfo1 | 954 | - | -| accountInfo2 | 1567 | - | -| accountInfo4 | 2059 | - | -| accountInfo8 | 3856 | - | | accountEmptyInit1 | 5958 | - | | accountEmpty1 | 1090 | - | | accountEmptyInit2 | 10583 | - | @@ -109,10 +105,6 @@ The programs and their tests are located in [/tests/bench](https://github.com/co | Instruction | Compute Units | +/- | | --------------------------- | ------------- | --- | -| accountInfo1 | 954 | N/A | -| accountInfo2 | 1567 | N/A | -| accountInfo4 | 2059 | N/A | -| accountInfo8 | 3856 | N/A | | accountEmptyInit1 | 5958 | N/A | | accountEmpty1 | 1090 | N/A | | accountEmptyInit2 | 10574 | N/A | diff --git a/tests/auction-house b/tests/auction-house index b73b60e55a..c211c31888 160000 --- a/tests/auction-house +++ b/tests/auction-house @@ -1 +1 @@ -Subproject commit b73b60e55a87bda1d2770c7c10db920db9cdb06b +Subproject commit c211c31888cefa8cac102a3f428d5cc7357a00a3 diff --git a/tests/bench/bench.json b/tests/bench/bench.json index 28cf6152fd..db5e01afdb 100644 --- a/tests/bench/bench.json +++ b/tests/bench/bench.json @@ -1,10 +1,6 @@ { "0.27.0": { "computeUnits": { - "accountInfo1": 954, - "accountInfo2": 1567, - "accountInfo4": 2059, - "accountInfo8": 3856, "accountEmptyInit1": 5958, "accountEmpty1": 1090, "accountEmptyInit2": 10574, @@ -92,10 +88,6 @@ }, "unreleased": { "computeUnits": { - "accountInfo1": 954, - "accountInfo2": 1567, - "accountInfo4": 2059, - "accountInfo8": 3856, "accountEmptyInit1": 5958, "accountEmpty1": 1090, "accountEmptyInit2": 10583, @@ -181,4 +173,4 @@ "uncheckedAccount8": 3855 } } -} \ No newline at end of file +} diff --git a/tests/bench/programs/bench/src/lib.rs b/tests/bench/programs/bench/src/lib.rs index e9a2a6b8e1..263b471286 100644 --- a/tests/bench/programs/bench/src/lib.rs +++ b/tests/bench/programs/bench/src/lib.rs @@ -9,22 +9,6 @@ declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"); pub mod bench { use super::*; - pub fn account_info1(_ctx: Context) -> Result<()> { - Ok(()) - } - - pub fn account_info2(_ctx: Context) -> Result<()> { - Ok(()) - } - - pub fn account_info4(_ctx: Context) -> Result<()> { - Ok(()) - } - - pub fn account_info8(_ctx: Context) -> Result<()> { - Ok(()) - } - pub fn account_empty_init1(_ctx: Context) -> Result<()> { Ok(()) } @@ -379,37 +363,6 @@ pub struct Unsized { pub field: Vec, } -#[derive(Accounts)] -pub struct AccountInfo1<'info> { - pub account1: AccountInfo<'info>, -} - -#[derive(Accounts)] -pub struct AccountInfo2<'info> { - pub account1: AccountInfo<'info>, - pub account2: AccountInfo<'info>, -} - -#[derive(Accounts)] -pub struct AccountInfo4<'info> { - pub account1: AccountInfo<'info>, - pub account2: AccountInfo<'info>, - pub account3: AccountInfo<'info>, - pub account4: AccountInfo<'info>, -} - -#[derive(Accounts)] -pub struct AccountInfo8<'info> { - pub account1: AccountInfo<'info>, - pub account2: AccountInfo<'info>, - pub account3: AccountInfo<'info>, - pub account4: AccountInfo<'info>, - pub account5: AccountInfo<'info>, - pub account6: AccountInfo<'info>, - pub account7: AccountInfo<'info>, - pub account8: AccountInfo<'info>, -} - #[derive(Accounts)] pub struct AccountEmptyInit1<'info> { #[account(mut)] diff --git a/tests/bench/scripts/generate-ix.ts b/tests/bench/scripts/generate-ix.ts index ba61c4a020..857ce6eeb2 100644 --- a/tests/bench/scripts/generate-ix.ts +++ b/tests/bench/scripts/generate-ix.ts @@ -25,10 +25,6 @@ type Instruction = { * If an instruction already exists, it will be skipped. */ const INSTRUCTIONS: Instruction[] = [ - { - name: "account_info", - accountType: "AccountInfo<'info>", - }, { name: "account_empty_init", accountType: "Account<'info, Empty>", diff --git a/tests/bench/tests/compute-units.ts b/tests/bench/tests/compute-units.ts index 4b5c8fbc2a..9b589733fa 100644 --- a/tests/bench/tests/compute-units.ts +++ b/tests/bench/tests/compute-units.ts @@ -144,10 +144,6 @@ describe(IDL.name, () => { await tokenProgram.provider.sendAndConfirm!(tx, [mintKp, tokenKp]); }); - it("AccountInfo", async () => { - await measureComputeUnits("accountInfo"); - }); - it("Account Empty", async () => { await measureComputeUnits("accountEmpty"); }); diff --git a/tests/cashiers-check/programs/cashiers-check/src/lib.rs b/tests/cashiers-check/programs/cashiers-check/src/lib.rs index 9cdae60d7d..eb06e2cdcc 100644 --- a/tests/cashiers-check/programs/cashiers-check/src/lib.rs +++ b/tests/cashiers-check/programs/cashiers-check/src/lib.rs @@ -22,11 +22,11 @@ pub mod cashiers_check { ) -> Result<()> { // Transfer funds to the check. let cpi_accounts = Transfer { - from: ctx.accounts.from.to_account_info().clone(), - to: ctx.accounts.vault.to_account_info().clone(), - authority: ctx.accounts.owner.clone(), + from: ctx.accounts.from.to_account_info(), + to: ctx.accounts.vault.to_account_info(), + authority: ctx.accounts.owner.to_account_info(), }; - let cpi_program = ctx.accounts.token_program.clone(); + let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new(cpi_program, cpi_accounts); token::transfer(cpi_ctx, amount)?; @@ -50,11 +50,11 @@ pub mod cashiers_check { ]; let signer = &[&seeds[..]]; let cpi_accounts = Transfer { - from: ctx.accounts.vault.to_account_info().clone(), - to: ctx.accounts.to.to_account_info().clone(), - authority: ctx.accounts.check_signer.clone(), + from: ctx.accounts.vault.to_account_info(), + to: ctx.accounts.to.to_account_info(), + authority: ctx.accounts.check_signer.to_account_info(), }; - let cpi_program = ctx.accounts.token_program.clone(); + let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new_with_signer(cpi_program, cpi_accounts, signer); token::transfer(cpi_ctx, ctx.accounts.check.amount)?; // Burn the check for one time use. @@ -70,11 +70,11 @@ pub mod cashiers_check { ]; let signer = &[&seeds[..]]; let cpi_accounts = Transfer { - from: ctx.accounts.vault.to_account_info().clone(), - to: ctx.accounts.from.to_account_info().clone(), - authority: ctx.accounts.check_signer.clone(), + from: ctx.accounts.vault.to_account_info(), + to: ctx.accounts.from.to_account_info(), + authority: ctx.accounts.check_signer.to_account_info(), }; - let cpi_program = ctx.accounts.token_program.clone(); + let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new_with_signer(cpi_program, cpi_accounts, signer); token::transfer(cpi_ctx, ctx.accounts.check.amount)?; ctx.accounts.check.burned = true; @@ -91,7 +91,7 @@ pub struct CreateCheck<'info> { #[account(mut, constraint = &vault.owner == check_signer.key)] vault: Account<'info, TokenAccount>, // Program derived address for the check. - check_signer: AccountInfo<'info>, + check_signer: UncheckedAccount<'info>, // Token account the check is made from. #[account(mut, has_one = owner)] from: Account<'info, TokenAccount>, @@ -99,8 +99,8 @@ pub struct CreateCheck<'info> { #[account(constraint = from.mint == to.mint)] to: Account<'info, TokenAccount>, // Owner of the `from` token account. - owner: AccountInfo<'info>, - token_program: AccountInfo<'info>, + owner: UncheckedAccount<'info>, + token_program: UncheckedAccount<'info>, } impl<'info> CreateCheck<'info> { @@ -122,16 +122,16 @@ pub struct CashCheck<'info> { #[account(mut, has_one = vault, has_one = to)] check: Account<'info, Check>, #[account(mut)] - vault: AccountInfo<'info>, + vault: UncheckedAccount<'info>, #[account( seeds = [check.to_account_info().key.as_ref()], bump = check.nonce, )] - check_signer: AccountInfo<'info>, + check_signer: UncheckedAccount<'info>, #[account(mut, has_one = owner)] to: Account<'info, TokenAccount>, owner: Signer<'info>, - token_program: AccountInfo<'info>, + token_program: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -139,16 +139,16 @@ pub struct CancelCheck<'info> { #[account(mut, has_one = vault, has_one = from)] check: Account<'info, Check>, #[account(mut)] - vault: AccountInfo<'info>, + vault: UncheckedAccount<'info>, #[account( seeds = [check.to_account_info().key.as_ref()], bump = check.nonce, )] - check_signer: AccountInfo<'info>, + check_signer: UncheckedAccount<'info>, #[account(mut, has_one = owner)] from: Account<'info, TokenAccount>, owner: Signer<'info>, - token_program: AccountInfo<'info>, + token_program: UncheckedAccount<'info>, } #[account] diff --git a/tests/chat/programs/chat/src/lib.rs b/tests/chat/programs/chat/src/lib.rs index 8dff89241f..08e383b4a5 100644 --- a/tests/chat/programs/chat/src/lib.rs +++ b/tests/chat/programs/chat/src/lib.rs @@ -50,7 +50,7 @@ pub struct CreateUser<'info> { user: Account<'info, User>, #[account(mut)] authority: Signer<'info>, - system_program: AccountInfo<'info>, + system_program: UncheckedAccount<'info>, } #[derive(Accounts)] diff --git a/tests/custom-coder/programs/native-system/src/lib.rs b/tests/custom-coder/programs/native-system/src/lib.rs index 8ac2b71574..a6b9774478 100644 --- a/tests/custom-coder/programs/native-system/src/lib.rs +++ b/tests/custom-coder/programs/native-system/src/lib.rs @@ -112,7 +112,7 @@ pub struct Transfer<'info> { from: Signer<'info>, #[account(mut)] /// CHECK: - to: AccountInfo<'info>, + to: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -121,7 +121,7 @@ pub struct CreateAccountWithSeed<'info> { from: Signer<'info>, #[account(mut)] /// CHECK: - to: AccountInfo<'info>, + to: UncheckedAccount<'info>, base: Signer<'info>, } @@ -129,9 +129,9 @@ pub struct CreateAccountWithSeed<'info> { pub struct AdvanceNonceAccount<'info> { #[account(mut)] /// CHECK: - nonce: AccountInfo<'info>, + nonce: UncheckedAccount<'info>, /// CHECK: - recent_blockhashes: AccountInfo<'info>, + recent_blockhashes: UncheckedAccount<'info>, authorized: Signer<'info>, } @@ -139,12 +139,12 @@ pub struct AdvanceNonceAccount<'info> { pub struct WithdrawNonceAccount<'info> { #[account(mut)] /// CHECK: - nonce: AccountInfo<'info>, + nonce: UncheckedAccount<'info>, #[account(mut)] /// CHECK: - to: AccountInfo<'info>, + to: UncheckedAccount<'info>, /// CHECK: - recent_blockhashes: AccountInfo<'info>, + recent_blockhashes: UncheckedAccount<'info>, rent: Sysvar<'info, Rent>, authorized: Signer<'info>, } @@ -154,7 +154,7 @@ pub struct InitializeNonceAccount<'info> { #[account(mut)] nonce: Signer<'info>, /// CHECK: - recent_blockhashes: AccountInfo<'info>, + recent_blockhashes: UncheckedAccount<'info>, rent: Sysvar<'info, Rent>, } @@ -162,7 +162,7 @@ pub struct InitializeNonceAccount<'info> { pub struct AuthorizeNonceAccount<'info> { #[account(mut)] /// CHECK: - nonce: AccountInfo<'info>, + nonce: UncheckedAccount<'info>, authorized: Signer<'info>, } @@ -176,7 +176,7 @@ pub struct Allocate<'info> { pub struct AllocateWithSeed<'info> { #[account(mut)] /// CHECK: - account: AccountInfo<'info>, + account: UncheckedAccount<'info>, base: Signer<'info>, } @@ -184,7 +184,7 @@ pub struct AllocateWithSeed<'info> { pub struct AssignWithSeed<'info> { #[account(mut)] /// CHECK: - account: AccountInfo<'info>, + account: UncheckedAccount<'info>, base: Signer<'info>, } @@ -192,11 +192,11 @@ pub struct AssignWithSeed<'info> { pub struct TransferWithSeed<'info> { #[account(mut)] /// CHECK: - from: AccountInfo<'info>, + from: UncheckedAccount<'info>, base: Signer<'info>, #[account(mut)] /// CHECK: - to: AccountInfo<'info>, + to: UncheckedAccount<'info>, } #[derive(AnchorSerialize, AnchorDeserialize, Clone)] diff --git a/tests/errors/programs/errors/src/lib.rs b/tests/errors/programs/errors/src/lib.rs index edc4c755dd..2044844464 100644 --- a/tests/errors/programs/errors/src/lib.rs +++ b/tests/errors/programs/errors/src/lib.rs @@ -139,14 +139,14 @@ pub struct Hello {} #[derive(Accounts)] pub struct MutError<'info> { #[account(mut)] - my_account: AccountInfo<'info>, + my_account: UncheckedAccount<'info>, } #[derive(Accounts)] pub struct HasOneError<'info> { #[account(zero, has_one = owner)] my_account: Account<'info, HasOneAccount>, - owner: AccountInfo<'info>, + owner: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -162,7 +162,7 @@ pub struct HasOneAccount { #[derive(Accounts)] pub struct RawCustomError<'info> { #[account(constraint = *my_account.key == ID @ MyError::HelloCustom)] - my_account: AccountInfo<'info>, + my_account: UncheckedAccount<'info>, } #[account] diff --git a/tests/escrow/programs/escrow/src/lib.rs b/tests/escrow/programs/escrow/src/lib.rs index e0456344ab..8afed08665 100644 --- a/tests/escrow/programs/escrow/src/lib.rs +++ b/tests/escrow/programs/escrow/src/lib.rs @@ -128,7 +128,7 @@ pub struct InitializeEscrow<'info> { pub struct Exchange<'info> { #[account(signer)] /// CHECK: - pub taker: AccountInfo<'info>, + pub taker: UncheckedAccount<'info>, #[account(mut, token::mint = deposit_mint)] pub taker_deposit_token_account: Box>, #[account(mut, token::mint = receive_mint)] @@ -139,7 +139,7 @@ pub struct Exchange<'info> { pub initializer_receive_token_account: Box>, #[account(mut)] /// CHECK: - pub initializer_main_account: AccountInfo<'info>, + pub initializer_main_account: UncheckedAccount<'info>, #[account( mut, constraint = escrow_account.taker_amount <= taker_deposit_token_account.amount, @@ -150,7 +150,7 @@ pub struct Exchange<'info> { )] pub escrow_account: Account<'info, EscrowAccount>, /// CHECK: - pub pda_account: AccountInfo<'info>, + pub pda_account: UncheckedAccount<'info>, pub deposit_mint: Box>, pub receive_mint: Box>, pub deposit_token_program: Interface<'info, TokenInterface>, @@ -160,11 +160,11 @@ pub struct Exchange<'info> { #[derive(Accounts)] pub struct CancelEscrow<'info> { /// CHECK: - pub initializer: AccountInfo<'info>, + pub initializer: UncheckedAccount<'info>, #[account(mut)] pub pda_deposit_token_account: InterfaceAccount<'info, TokenAccount>, /// CHECK: - pub pda_account: AccountInfo<'info>, + pub pda_account: UncheckedAccount<'info>, #[account( mut, constraint = escrow_account.initializer_key == *initializer.key, @@ -193,11 +193,8 @@ impl<'info> From<&mut InitializeEscrow<'info>> { fn from(accounts: &mut InitializeEscrow<'info>) -> Self { let cpi_accounts = SetAuthority { - account_or_mint: accounts - .initializer_deposit_token_account - .to_account_info() - .clone(), - current_authority: accounts.initializer.to_account_info().clone(), + account_or_mint: accounts.initializer_deposit_token_account.to_account_info(), + current_authority: accounts.initializer.to_account_info(), }; let cpi_program = accounts.token_program.to_account_info(); CpiContext::new(cpi_program, cpi_accounts) @@ -207,8 +204,8 @@ impl<'info> From<&mut InitializeEscrow<'info>> impl<'info> CancelEscrow<'info> { fn into_set_authority_context(&self) -> CpiContext<'_, '_, '_, 'info, SetAuthority<'info>> { let cpi_accounts = SetAuthority { - account_or_mint: self.pda_deposit_token_account.to_account_info().clone(), - current_authority: self.pda_account.clone(), + account_or_mint: self.pda_deposit_token_account.to_account_info(), + current_authority: self.pda_account.to_account_info(), }; let cpi_program = self.token_program.to_account_info(); CpiContext::new(cpi_program, cpi_accounts) @@ -218,8 +215,8 @@ impl<'info> CancelEscrow<'info> { impl<'info> Exchange<'info> { fn into_set_authority_context(&self) -> CpiContext<'_, '_, '_, 'info, SetAuthority<'info>> { let cpi_accounts = SetAuthority { - account_or_mint: self.pda_deposit_token_account.to_account_info().clone(), - current_authority: self.pda_account.clone(), + account_or_mint: self.pda_deposit_token_account.to_account_info(), + current_authority: self.pda_account.to_account_info(), }; let cpi_program = self.receive_token_program.to_account_info(); CpiContext::new(cpi_program, cpi_accounts) @@ -231,10 +228,10 @@ impl<'info> Exchange<'info> { &self, ) -> CpiContext<'_, '_, '_, 'info, TransferChecked<'info>> { let cpi_accounts = TransferChecked { - from: self.pda_deposit_token_account.to_account_info().clone(), - mint: self.receive_mint.to_account_info().clone(), - to: self.taker_receive_token_account.to_account_info().clone(), - authority: self.pda_account.clone(), + from: self.pda_deposit_token_account.to_account_info(), + mint: self.receive_mint.to_account_info(), + to: self.taker_receive_token_account.to_account_info(), + authority: self.pda_account.to_account_info(), }; let cpi_program = self.receive_token_program.to_account_info(); CpiContext::new(cpi_program, cpi_accounts) @@ -246,13 +243,10 @@ impl<'info> Exchange<'info> { &self, ) -> CpiContext<'_, '_, '_, 'info, TransferChecked<'info>> { let cpi_accounts = TransferChecked { - from: self.taker_deposit_token_account.to_account_info().clone(), - mint: self.deposit_mint.to_account_info().clone(), - to: self - .initializer_receive_token_account - .to_account_info() - .clone(), - authority: self.taker.clone(), + from: self.taker_deposit_token_account.to_account_info(), + mint: self.deposit_mint.to_account_info(), + to: self.initializer_receive_token_account.to_account_info(), + authority: self.taker.to_account_info(), }; let cpi_program = self.deposit_token_program.to_account_info(); CpiContext::new(cpi_program, cpi_accounts) diff --git a/tests/ido-pool/programs/ido-pool/src/lib.rs b/tests/ido-pool/programs/ido-pool/src/lib.rs index 53afe43ea3..0e72a49a2f 100644 --- a/tests/ido-pool/programs/ido-pool/src/lib.rs +++ b/tests/ido-pool/programs/ido-pool/src/lib.rs @@ -205,7 +205,7 @@ pub mod ido_pool { if ctx.accounts.user_redeemable.amount == 0 { let cpi_accounts = CloseAccount { account: ctx.accounts.user_redeemable.to_account_info(), - destination: ctx.accounts.user_authority.clone(), + destination: ctx.accounts.user_authority.to_account_info(), authority: ctx.accounts.ido_account.to_account_info(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); @@ -268,7 +268,7 @@ pub mod ido_pool { if ctx.accounts.escrow_usdc.amount == 0 { let cpi_accounts = CloseAccount { account: ctx.accounts.escrow_usdc.to_account_info(), - destination: ctx.accounts.user_authority.clone(), + destination: ctx.accounts.user_authority.to_account_info(), authority: ctx.accounts.ido_account.to_account_info(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); @@ -460,7 +460,7 @@ pub struct ExchangeRedeemableForWatermelon<'info> { pub payer: Signer<'info>, // User Accounts #[account(mut)] // Sol rent from empty redeemable account is refunded to the user - pub user_authority: AccountInfo<'info>, + pub user_authority: UncheckedAccount<'info>, // TODO replace with ATA constraints #[account(mut, constraint = user_watermelon.owner == user_authority.key(), @@ -523,7 +523,7 @@ pub struct WithdrawFromEscrow<'info> { pub payer: Signer<'info>, // User Accounts #[account(mut)] - pub user_authority: AccountInfo<'info>, + pub user_authority: UncheckedAccount<'info>, #[account(mut, constraint = user_usdc.owner == user_authority.key(), constraint = user_usdc.mint == usdc_mint.key())] diff --git a/tests/multisig/programs/multisig/src/lib.rs b/tests/multisig/programs/multisig/src/lib.rs index 847161cc4a..448153727b 100644 --- a/tests/multisig/programs/multisig/src/lib.rs +++ b/tests/multisig/programs/multisig/src/lib.rs @@ -197,7 +197,7 @@ pub struct Auth<'info> { seeds = [multisig.to_account_info().key.as_ref()], bump = multisig.nonce, )] - multisig_signer: AccountInfo<'info>, + multisig_signer: UncheckedAccount<'info>, } #[derive(Accounts)] @@ -207,7 +207,7 @@ pub struct ExecuteTransaction<'info> { seeds = [multisig.to_account_info().key.as_ref()], bump = multisig.nonce, )] - multisig_signer: AccountInfo<'info>, + multisig_signer: UncheckedAccount<'info>, #[account(mut, has_one = multisig)] transaction: Account<'info, Transaction>, } diff --git a/tests/pda-derivation/programs/pda-derivation/src/lib.rs b/tests/pda-derivation/programs/pda-derivation/src/lib.rs index f695813a89..516bf71ff3 100644 --- a/tests/pda-derivation/programs/pda-derivation/src/lib.rs +++ b/tests/pda-derivation/programs/pda-derivation/src/lib.rs @@ -68,7 +68,7 @@ pub struct InitMyAccount<'info> { base: Account<'info, BaseAccount>, // Intentionally using this qualified form instead of importing to test parsing another_base: Account<'info, crate::other::AnotherBaseAccount>, - base2: AccountInfo<'info>, + base2: UncheckedAccount<'info>, #[account( init, payer = payer, @@ -112,7 +112,7 @@ pub struct Nested<'info> { bump, )] /// CHECK: Not needed - account_nested: AccountInfo<'info>, + account_nested: UncheckedAccount<'info>, } #[account] diff --git a/tests/pyth/programs/pyth/src/lib.rs b/tests/pyth/programs/pyth/src/lib.rs index ff85804237..1a004f09f9 100644 --- a/tests/pyth/programs/pyth/src/lib.rs +++ b/tests/pyth/programs/pyth/src/lib.rs @@ -31,11 +31,11 @@ pub mod pyth { #[derive(Accounts)] pub struct SetPrice<'info> { #[account(mut)] - pub price: AccountInfo<'info>, + pub price: UncheckedAccount<'info>, } #[derive(Accounts)] pub struct Initialize<'info> { #[account(mut)] - pub price: AccountInfo<'info>, + pub price: UncheckedAccount<'info>, } diff --git a/tests/safety-checks/Anchor.toml b/tests/safety-checks/Anchor.toml index 5961a5b9ed..3fc545c4bb 100644 --- a/tests/safety-checks/Anchor.toml +++ b/tests/safety-checks/Anchor.toml @@ -1,6 +1,5 @@ [programs.localnet] unchecked_account = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS" -account_info = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS" [registry] url = "https://anchor.projectserum.com" diff --git a/tests/safety-checks/programs/account-info/Cargo.toml b/tests/safety-checks/programs/account-info/Cargo.toml deleted file mode 100644 index e222f06ed7..0000000000 --- a/tests/safety-checks/programs/account-info/Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -[package] -name = "account-info" -version = "0.1.0" -description = "Created with Anchor" -edition = "2018" - -[lib] -crate-type = ["cdylib", "lib"] -name = "account_info" - -[features] -no-entrypoint = [] -no-idl = [] -no-log-ix-name = [] -cpi = ["no-entrypoint"] -default = [] - -[dependencies] -anchor-lang = { path = "../../../../lang" } diff --git a/tests/safety-checks/programs/account-info/Xargo.toml b/tests/safety-checks/programs/account-info/Xargo.toml deleted file mode 100644 index 475fb71ed1..0000000000 --- a/tests/safety-checks/programs/account-info/Xargo.toml +++ /dev/null @@ -1,2 +0,0 @@ -[target.bpfel-unknown-unknown.dependencies.std] -features = [] diff --git a/tests/safety-checks/programs/account-info/src/lib.rs b/tests/safety-checks/programs/account-info/src/lib.rs deleted file mode 100644 index 74d8f12182..0000000000 --- a/tests/safety-checks/programs/account-info/src/lib.rs +++ /dev/null @@ -1,16 +0,0 @@ -use anchor_lang::prelude::*; - -declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"); - -#[program] -pub mod account_info { - use super::*; - pub fn initialize(ctx: Context) -> Result<()> { - Ok(()) - } -} - -#[derive(Accounts)] -pub struct Initialize<'info> { - unchecked: AccountInfo<'info>, -} diff --git a/tests/safety-checks/programs/ignore-non-accounts/src/lib.rs b/tests/safety-checks/programs/ignore-non-accounts/src/lib.rs index 30f4bea6b1..7726917a1d 100644 --- a/tests/safety-checks/programs/ignore-non-accounts/src/lib.rs +++ b/tests/safety-checks/programs/ignore-non-accounts/src/lib.rs @@ -13,18 +13,14 @@ pub mod ignore_non_accounts { #[derive(Accounts)] pub struct Initialize<'info> { /// CHECK: - checked1: UncheckedAccount<'info>, - /// CHECK: - checked2: AccountInfo<'info>, + checked: UncheckedAccount<'info>, } #[derive(Debug)] pub struct ShouldIgnore1<'info> { - unchecked1: UncheckedAccount<'info>, - unchecked2: AccountInfo<'info>, + unchecked: UncheckedAccount<'info>, } pub struct ShouldIgnore2<'info> { - unchecked1: UncheckedAccount<'info>, - unchecked2: AccountInfo<'info>, + unchecked: UncheckedAccount<'info>, } diff --git a/tests/safety-checks/test.sh b/tests/safety-checks/test.sh index 872d6c1f25..58a3bb0df5 100755 --- a/tests/safety-checks/test.sh +++ b/tests/safety-checks/test.sh @@ -13,17 +13,6 @@ if ! [[ $output =~ "Struct field \"unchecked\" is unsafe" ]]; then fi popd -# -# Build the AccountInfo variant. -# -pushd programs/account-info/ -output=$(anchor build 2>&1 > /dev/null) -if ! [[ $output =~ "Struct field \"unchecked\" is unsafe" ]]; then - echo "Error: expected /// CHECK error" - exit 1 -fi -popd - # # Build the control variant. # diff --git a/tests/swap/programs/swap/src/lib.rs b/tests/swap/programs/swap/src/lib.rs index 1e4fa5f44c..2af076704a 100644 --- a/tests/swap/programs/swap/src/lib.rs +++ b/tests/swap/programs/swap/src/lib.rs @@ -57,8 +57,8 @@ pub mod swap { // Execute trade. let orderbook: OrderbookClient<'info> = (&*ctx.accounts).into(); match side { - Side::Bid => orderbook.buy(amount, referral.clone())?, - Side::Ask => orderbook.sell(amount, referral.clone())?, + Side::Bid => orderbook.buy(amount, referral.to_account_info())?, + Side::Ask => orderbook.sell(amount, referral.to_account_info())?, }; orderbook.settle(referral)?; @@ -122,8 +122,8 @@ pub mod swap { // Execute the trade. let orderbook = ctx.accounts.orderbook_from(); - orderbook.sell(amount, referral.clone())?; - orderbook.settle(referral.clone())?; + orderbook.sell(amount, referral.to_account_info())?; + orderbook.settle(referral.to_account_info())?; // Token balances after the trade. let base_after = token::accessor::amount(&ctx.accounts.from.coin_wallet)?; @@ -144,7 +144,7 @@ pub mod swap { // Execute the trade. let orderbook = ctx.accounts.orderbook_to(); - orderbook.buy(sell_proceeds, referral.clone())?; + orderbook.buy(sell_proceeds, referral.to_account_info())?; orderbook.settle(referral)?; // Token balances after the trade. @@ -192,25 +192,25 @@ fn apply_risk_checks(event: DidSwap) -> Result<()> { pub struct Swap<'info> { market: MarketAccounts<'info>, #[account(signer)] - authority: AccountInfo<'info>, + authority: UncheckedAccount<'info>, #[account(mut)] - pc_wallet: AccountInfo<'info>, + pc_wallet: UncheckedAccount<'info>, // Programs. - dex_program: AccountInfo<'info>, - token_program: AccountInfo<'info>, + dex_program: UncheckedAccount<'info>, + token_program: UncheckedAccount<'info>, // Sysvars. - rent: AccountInfo<'info>, + rent: UncheckedAccount<'info>, } impl<'info> From<&Swap<'info>> for OrderbookClient<'info> { fn from(accounts: &Swap<'info>) -> OrderbookClient<'info> { OrderbookClient { - market: accounts.market.clone(), - authority: accounts.authority.clone(), - pc_wallet: accounts.pc_wallet.clone(), - dex_program: accounts.dex_program.clone(), - token_program: accounts.token_program.clone(), - rent: accounts.rent.clone(), + market: accounts.market.to_account_info(), + authority: accounts.authority.to_account_info(), + pc_wallet: accounts.pc_wallet.to_account_info(), + dex_program: accounts.dex_program.to_account_info(), + token_program: accounts.token_program.to_account_info(), + rent: accounts.rent.to_account_info(), } } } @@ -225,35 +225,35 @@ pub struct SwapTransitive<'info> { to: MarketAccounts<'info>, // Must be the authority over all open orders accounts used. #[account(signer)] - authority: AccountInfo<'info>, + authority: UncheckedAccount<'info>, #[account(mut)] - pc_wallet: AccountInfo<'info>, + pc_wallet: UncheckedAccount<'info>, // Programs. - dex_program: AccountInfo<'info>, - token_program: AccountInfo<'info>, + dex_program: UncheckedAccount<'info>, + token_program: UncheckedAccount<'info>, // Sysvars. - rent: AccountInfo<'info>, + rent: UncheckedAccount<'info>, } impl<'info> SwapTransitive<'info> { fn orderbook_from(&self) -> OrderbookClient<'info> { OrderbookClient { - market: self.from.clone(), - authority: self.authority.clone(), - pc_wallet: self.pc_wallet.clone(), - dex_program: self.dex_program.clone(), - token_program: self.token_program.clone(), - rent: self.rent.clone(), + market: self.from.to_account_info(), + authority: self.authority.to_account_info(), + pc_wallet: self.pc_wallet.to_account_info(), + dex_program: self.dex_program.to_account_info(), + token_program: self.token_program.to_account_info(), + rent: self.rent.to_account_info(), } } fn orderbook_to(&self) -> OrderbookClient<'info> { OrderbookClient { - market: self.to.clone(), - authority: self.authority.clone(), - pc_wallet: self.pc_wallet.clone(), - dex_program: self.dex_program.clone(), - token_program: self.token_program.clone(), - rent: self.rent.clone(), + market: self.to.to_account_info(), + authority: self.authority.to_account_info(), + pc_wallet: self.pc_wallet.to_account_info(), + dex_program: self.dex_program.to_account_info(), + token_program: self.token_program.to_account_info(), + rent: self.rent.to_account_info(), } } } @@ -394,36 +394,36 @@ fn coin_lots(market: &MarketState, size: u64) -> u64 { #[derive(Accounts, Clone)] pub struct MarketAccounts<'info> { #[account(mut)] - market: AccountInfo<'info>, + market: UncheckedAccount<'info>, #[account(mut)] - open_orders: AccountInfo<'info>, + open_orders: UncheckedAccount<'info>, #[account(mut)] - request_queue: AccountInfo<'info>, + request_queue: UncheckedAccount<'info>, #[account(mut)] - event_queue: AccountInfo<'info>, + event_queue: UncheckedAccount<'info>, #[account(mut)] - bids: AccountInfo<'info>, + bids: UncheckedAccount<'info>, #[account(mut)] - asks: AccountInfo<'info>, + asks: UncheckedAccount<'info>, // The `spl_token::Account` that funds will be taken from, i.e., transferred // from the user into the market's vault. // // For bids, this is the base currency. For asks, the quote. #[account(mut)] - order_payer_token_account: AccountInfo<'info>, + order_payer_token_account: UncheckedAccount<'info>, // Also known as the "base" currency. For a given A/B market, // this is the vault for the A mint. #[account(mut)] - coin_vault: AccountInfo<'info>, + coin_vault: UncheckedAccount<'info>, // Also known as the "quote" currency. For a given A/B market, // this is the vault for the B mint. #[account(mut)] - pc_vault: AccountInfo<'info>, + pc_vault: UncheckedAccount<'info>, // PDA owner of the DEX's token accounts for base + quote currencies. - vault_signer: AccountInfo<'info>, + vault_signer: UncheckedAccount<'info>, // User wallets. #[account(mut)] - coin_wallet: AccountInfo<'info>, + coin_wallet: UncheckedAccount<'info>, } #[derive(AnchorSerialize, AnchorDeserialize)] diff --git a/tests/zero-copy/programs/zero-copy/src/lib.rs b/tests/zero-copy/programs/zero-copy/src/lib.rs index 3db1e5b09b..af9b8a1649 100644 --- a/tests/zero-copy/programs/zero-copy/src/lib.rs +++ b/tests/zero-copy/programs/zero-copy/src/lib.rs @@ -104,7 +104,7 @@ pub struct CreateBar<'info> { #[account(mut)] authority: Signer<'info>, foo: AccountLoader<'info, Foo>, - system_program: AccountInfo<'info>, + system_program: UncheckedAccount<'info>, } #[derive(Accounts)] pub struct UpdateBar<'info> { diff --git a/tests/zero-copy/programs/zero-cpi/src/lib.rs b/tests/zero-copy/programs/zero-cpi/src/lib.rs index 1ce2fdaa64..3b25775b5c 100644 --- a/tests/zero-copy/programs/zero-cpi/src/lib.rs +++ b/tests/zero-copy/programs/zero-cpi/src/lib.rs @@ -11,7 +11,7 @@ pub mod zero_cpi { pub fn check_cpi(ctx: Context, data: u64) -> Result<()> { let cpi_program = ctx.accounts.zero_copy_program.to_account_info(); let cpi_accounts = UpdateBar { - authority: ctx.accounts.authority.clone(), + authority: ctx.accounts.authority.to_account_info(), bar: ctx.accounts.bar.to_account_info(), foo: ctx.accounts.foo.to_account_info(), }; @@ -29,7 +29,7 @@ pub struct CheckCpi<'info> { )] bar: AccountLoader<'info, Bar>, #[account(signer)] - authority: AccountInfo<'info>, + authority: UncheckedAccount<'info>, foo: AccountLoader<'info, Foo>, zero_copy_program: Program<'info, ZeroCopy>, } From f81d10fdf3639416a2bd54bf28cc85fda933e598 Mon Sep 17 00:00:00 2001 From: Jean Marchand Date: Wed, 26 Apr 2023 00:08:42 +0200 Subject: [PATCH 03/11] Fix swap test --- tests/swap/programs/swap/src/lib.rs | 62 ++++++++++++++--------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/tests/swap/programs/swap/src/lib.rs b/tests/swap/programs/swap/src/lib.rs index 2af076704a..b9b16899c4 100644 --- a/tests/swap/programs/swap/src/lib.rs +++ b/tests/swap/programs/swap/src/lib.rs @@ -57,8 +57,8 @@ pub mod swap { // Execute trade. let orderbook: OrderbookClient<'info> = (&*ctx.accounts).into(); match side { - Side::Bid => orderbook.buy(amount, referral.to_account_info())?, - Side::Ask => orderbook.sell(amount, referral.to_account_info())?, + Side::Bid => orderbook.buy(amount, referral.clone())?, + Side::Ask => orderbook.sell(amount, referral.clone())?, }; orderbook.settle(referral)?; @@ -122,8 +122,8 @@ pub mod swap { // Execute the trade. let orderbook = ctx.accounts.orderbook_from(); - orderbook.sell(amount, referral.to_account_info())?; - orderbook.settle(referral.to_account_info())?; + orderbook.sell(amount, referral.clone())?; + orderbook.settle(referral.clone())?; // Token balances after the trade. let base_after = token::accessor::amount(&ctx.accounts.from.coin_wallet)?; @@ -144,7 +144,7 @@ pub mod swap { // Execute the trade. let orderbook = ctx.accounts.orderbook_to(); - orderbook.buy(sell_proceeds, referral.to_account_info())?; + orderbook.buy(sell_proceeds, referral.clone())?; orderbook.settle(referral)?; // Token balances after the trade. @@ -205,7 +205,7 @@ pub struct Swap<'info> { impl<'info> From<&Swap<'info>> for OrderbookClient<'info> { fn from(accounts: &Swap<'info>) -> OrderbookClient<'info> { OrderbookClient { - market: accounts.market.to_account_info(), + market: accounts.market.clone(), authority: accounts.authority.to_account_info(), pc_wallet: accounts.pc_wallet.to_account_info(), dex_program: accounts.dex_program.to_account_info(), @@ -238,7 +238,7 @@ pub struct SwapTransitive<'info> { impl<'info> SwapTransitive<'info> { fn orderbook_from(&self) -> OrderbookClient<'info> { OrderbookClient { - market: self.from.to_account_info(), + market: self.from.clone(), authority: self.authority.to_account_info(), pc_wallet: self.pc_wallet.to_account_info(), dex_program: self.dex_program.to_account_info(), @@ -248,7 +248,7 @@ impl<'info> SwapTransitive<'info> { } fn orderbook_to(&self) -> OrderbookClient<'info> { OrderbookClient { - market: self.to.to_account_info(), + market: self.to.clone(), authority: self.authority.to_account_info(), pc_wallet: self.pc_wallet.to_account_info(), dex_program: self.dex_program.to_account_info(), @@ -334,20 +334,20 @@ impl<'info> OrderbookClient<'info> { let limit = 65535; let dex_accs = dex::NewOrderV3 { - market: self.market.market.clone(), - open_orders: self.market.open_orders.clone(), - request_queue: self.market.request_queue.clone(), - event_queue: self.market.event_queue.clone(), - market_bids: self.market.bids.clone(), - market_asks: self.market.asks.clone(), - order_payer_token_account: self.market.order_payer_token_account.clone(), - open_orders_authority: self.authority.clone(), - coin_vault: self.market.coin_vault.clone(), - pc_vault: self.market.pc_vault.clone(), - token_program: self.token_program.clone(), - rent: self.rent.clone(), + market: self.market.market.to_account_info(), + open_orders: self.market.open_orders.to_account_info(), + request_queue: self.market.request_queue.to_account_info(), + event_queue: self.market.event_queue.to_account_info(), + market_bids: self.market.bids.to_account_info(), + market_asks: self.market.asks.to_account_info(), + order_payer_token_account: self.market.order_payer_token_account.to_account_info(), + open_orders_authority: self.authority.to_account_info(), + coin_vault: self.market.coin_vault.to_account_info(), + pc_vault: self.market.pc_vault.to_account_info(), + token_program: self.token_program.to_account_info(), + rent: self.rent.to_account_info(), }; - let mut ctx = CpiContext::new(self.dex_program.clone(), dex_accs); + let mut ctx = CpiContext::new(self.dex_program.to_account_info(), dex_accs); if let Some(referral) = referral { ctx = ctx.with_remaining_accounts(vec![referral]); } @@ -366,17 +366,17 @@ impl<'info> OrderbookClient<'info> { fn settle(&self, referral: Option>) -> Result<()> { let settle_accs = dex::SettleFunds { - market: self.market.market.clone(), - open_orders: self.market.open_orders.clone(), - open_orders_authority: self.authority.clone(), - coin_vault: self.market.coin_vault.clone(), - pc_vault: self.market.pc_vault.clone(), - coin_wallet: self.market.coin_wallet.clone(), - pc_wallet: self.pc_wallet.clone(), - vault_signer: self.market.vault_signer.clone(), - token_program: self.token_program.clone(), + market: self.market.market.to_account_info(), + open_orders: self.market.open_orders.to_account_info(), + open_orders_authority: self.authority.to_account_info(), + coin_vault: self.market.coin_vault.to_account_info(), + pc_vault: self.market.pc_vault.to_account_info(), + coin_wallet: self.market.coin_wallet.to_account_info(), + pc_wallet: self.pc_wallet.to_account_info(), + vault_signer: self.market.vault_signer.to_account_info(), + token_program: self.token_program.to_account_info(), }; - let mut ctx = CpiContext::new(self.dex_program.clone(), settle_accs); + let mut ctx = CpiContext::new(self.dex_program.to_account_info(), settle_accs); if let Some(referral) = referral { ctx = ctx.with_remaining_accounts(vec![referral]); } From 625c72d36b396197267ff65d24ca32b284d96cb4 Mon Sep 17 00:00:00 2001 From: Jean Marchand Date: Wed, 26 Apr 2023 12:52:23 +0200 Subject: [PATCH 04/11] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10e4703c31..74220ebece 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ The minor version will be incremented upon a breaking change and the patch versi ### Breaking +- lang: Remove the use of `AccountInfo` in the context of the accounts. Use `UncheckedAccount` instead ([#2470](https://github.com/coral-xyz/anchor/pull/2470)). - lang: Identifiers that are intended for internal usage(`program_id`, `accounts`, `ix_data`, `remaining_accounts`) have been renamed with `__` prefix ([#2464](https://github.com/coral-xyz/anchor/pull/2464)) ## [0.27.0] - 2023-03-08 From 0341e29a89603a1109a0c4572526fe50008c5988 Mon Sep 17 00:00:00 2001 From: Jean Marchand Date: Fri, 5 May 2023 10:00:46 +0200 Subject: [PATCH 05/11] Remove AccountInfo --- docs/src/pages/docs/the-accounts-struct.md | 2 +- lang/derive/accounts/src/lib.rs | 22 +- lang/src/accounts/account.rs | 9 + lang/src/accounts/account_info.rs | 29 +- lang/src/accounts/account_loader.rs | 9 +- lang/src/accounts/boxed.rs | 7 + lang/src/accounts/interface.rs | 7 + lang/src/accounts/interface_account.rs | 9 + lang/src/accounts/mod.rs | 1 + lang/src/accounts/program.rs | 7 + lang/src/accounts/signer.rs | 7 + lang/src/accounts/system_account.rs | 7 + lang/src/accounts/sysvar.rs | 7 + lang/src/accounts/unchecked_account.rs | 6 + lang/src/system_program.rs | 163 ++++----- .../codegen/accounts/__cpi_client_accounts.rs | 4 +- lang/syn/src/codegen/accounts/constraints.rs | 38 +-- lang/syn/src/codegen/accounts/mod.rs | 21 +- lang/syn/src/codegen/program/idl.rs | 4 +- lang/syn/src/lib.rs | 13 - lang/syn/src/parser/accounts/mod.rs | 29 +- spl/src/associated_token.rs | 41 ++- spl/src/dex.rs | 111 +++--- spl/src/metadata.rs | 316 ++++++++---------- spl/src/shmem.rs | 24 +- spl/src/stake.rs | 52 +-- spl/src/token.rs | 209 ++++++------ spl/src/token_2022.rs | 225 +++++++------ tests/cpi-returns/programs/caller/src/lib.rs | 6 +- .../programs/token-proxy/src/lib.rs | 36 +- .../programs/token-wrapper/src/lib.rs | 44 +-- 31 files changed, 742 insertions(+), 723 deletions(-) diff --git a/docs/src/pages/docs/the-accounts-struct.md b/docs/src/pages/docs/the-accounts-struct.md index a8c6865ced..2f1cd76e09 100644 --- a/docs/src/pages/docs/the-accounts-struct.md +++ b/docs/src/pages/docs/the-accounts-struct.md @@ -138,7 +138,7 @@ You can find information about all constraints in the reference. We will cover s ## Safety checks -Two of the Anchor account types, [AccountInfo](https://docs.rs/anchor-lang/latest/anchor_lang/accounts/account_info/index.html) and [UncheckedAccount](https://docs.rs/anchor-lang/latest/anchor_lang/accounts/unchecked_account/index.html) do not implement any checks on the account being passed. Anchor implements safety checks that encourage additional documentation describing why additional checks are not necesssary. +One of the Anchor account types, [UncheckedAccount](https://docs.rs/anchor-lang/latest/anchor_lang/accounts/unchecked_account/index.html) does not implement any checks on the account being passed. Anchor implements safety checks that encourage additional documentation describing why additional checks are not necesssary. Attempting to build a program containing the following excerpt with `anchor build`: diff --git a/lang/derive/accounts/src/lib.rs b/lang/derive/accounts/src/lib.rs index dbb76b852e..0bec7b7644 100644 --- a/lang/derive/accounts/src/lib.rs +++ b/lang/derive/accounts/src/lib.rs @@ -65,9 +65,9 @@ use syn::parse_macro_input; /// Example: ///

 /// #[account(signer)]
-/// pub authority: AccountInfo<'info>,
+/// pub authority: UncheckedAccount<'info>,
 /// #[account(signer @ MyError::MyErrorCode)]
-/// pub payer: AccountInfo<'info>
+/// pub payer: UncheckedAccount<'info>
 ///                 
/// /// @@ -173,13 +173,13 @@ use syn::parse_macro_input; ///         init, payer = payer, ///         space = 8 + 8, owner = other_program.key() ///     )] -///     pub account_for_other_program: AccountInfo<'info>, +///     pub account_for_other_program: UncheckedAccount<'info>, ///     #[account( ///         init, payer = payer, space = 8 + 8, ///         owner = other_program.key(), ///         seeds = [b"other_seed"], bump ///     )] -///     pub pda_for_other_program: AccountInfo<'info>, +///     pub pda_for_other_program: UncheckedAccount<'info>, ///     #[account(mut)] ///     pub payer: Signer<'info>, ///     pub system_program: Program<'info, System>, @@ -254,21 +254,21 @@ use syn::parse_macro_input; /// #[instruction(first_bump: u8, second_bump: u8)] /// pub struct Example { /// #[account(seeds = [b"example_seed"], bump)] -/// pub canonical_pda: AccountInfo<'info>, +/// pub canonical_pda: UncheckedAccount<'info>, /// #[account( /// seeds = [b"example_seed"], /// bump, /// seeds::program = other_program.key() /// )] -/// pub canonical_pda_two: AccountInfo<'info>, +/// pub canonical_pda_two: UncheckedAccount<'info>, /// #[account(seeds = [b"other_seed"], bump = first_bump)] -/// pub arbitrary_pda: AccountInfo<'info> +/// pub arbitrary_pda: UncheckedAccount<'info> /// #[account( /// seeds = [b"other_seed"], /// bump = second_bump, /// seeds::program = other_program.key() /// )] -/// pub arbitrary_pda_two: AccountInfo<'info>, +/// pub arbitrary_pda_two: UncheckedAccount<'info>, /// pub other_program: Program<'info, OtherProgram> /// } /// @@ -337,7 +337,7 @@ use syn::parse_macro_input; /// Example: ///

 /// #[account(executable)]
-/// pub my_program: AccountInfo<'info>
+/// pub my_program: UncheckedAccount<'info>
 ///                 
/// /// @@ -356,7 +356,7 @@ use syn::parse_macro_input; /// #[account(zero, rent_exempt = skip)] /// pub skipped_account: Account<'info, MyData>, /// #[account(rent_exempt = enforce)] -/// pub enforced_account: AccountInfo<'info> +/// pub enforced_account: UncheckedAccount<'info> /// /// /// @@ -629,7 +629,7 @@ use syn::parse_macro_input; /// /// /// -#[proc_macro_derive(Accounts, attributes(account, instruction, only_cpi))] +#[proc_macro_derive(Accounts, attributes(account, instruction))] pub fn derive_anchor_deserialize(item: TokenStream) -> TokenStream { parse_macro_input!(item as anchor_syn::AccountsStruct) .to_token_stream() diff --git a/lang/src/accounts/account.rs b/lang/src/accounts/account.rs index 184b0c55b2..7d3ea2fd90 100644 --- a/lang/src/accounts/account.rs +++ b/lang/src/accounts/account.rs @@ -2,6 +2,7 @@ use crate::bpf_writer::BpfWriter; use crate::error::{Error, ErrorCode}; +use crate::prelude::UncheckedAccount; use crate::{ AccountDeserialize, AccountSerialize, Accounts, AccountsClose, AccountsExit, Key, Owner, Result, ToAccountInfo, ToAccountInfos, ToAccountMetas, @@ -429,3 +430,11 @@ impl<'info, T: AccountSerialize + AccountDeserialize + Clone> Key for Account<'i *self.info.key } } + +impl<'info, T: AccountSerialize + AccountDeserialize + Clone> From> + for UncheckedAccount<'info> +{ + fn from(value: Account<'info, T>) -> Self { + UncheckedAccount::try_from(value.info) + } +} diff --git a/lang/src/accounts/account_info.rs b/lang/src/accounts/account_info.rs index 2cdbe6584c..6b09cb3ad5 100644 --- a/lang/src/accounts/account_info.rs +++ b/lang/src/accounts/account_info.rs @@ -1,30 +1,5 @@ -//! AccountInfo can be used as a type but -//! [Unchecked Account](crate::accounts::unchecked_account::UncheckedAccount) -//! should be used instead. - -use crate::{AccountsExit, Key, ToAccountInfos, ToAccountMetas}; -use solana_program::account_info::AccountInfo; -use solana_program::instruction::AccountMeta; -use solana_program::pubkey::Pubkey; - -impl<'info> ToAccountMetas for AccountInfo<'info> { - fn to_account_metas(&self, is_signer: Option) -> Vec { - let is_signer = is_signer.unwrap_or(self.is_signer); - let meta = match self.is_writable { - false => AccountMeta::new_readonly(*self.key, is_signer), - true => AccountMeta::new(*self.key, is_signer), - }; - vec![meta] - } -} - -impl<'info> ToAccountInfos<'info> for AccountInfo<'info> { - fn to_account_infos(&self) -> Vec> { - vec![self.clone()] - } -} - -impl<'info> AccountsExit<'info> for AccountInfo<'info> {} +use crate::Key; +use solana_program::{account_info::AccountInfo, pubkey::Pubkey}; impl<'info> Key for AccountInfo<'info> { fn key(&self) -> Pubkey { diff --git a/lang/src/accounts/account_loader.rs b/lang/src/accounts/account_loader.rs index 1d2d2861bd..322b41faaa 100644 --- a/lang/src/accounts/account_loader.rs +++ b/lang/src/accounts/account_loader.rs @@ -2,6 +2,7 @@ use crate::bpf_writer::BpfWriter; use crate::error::{Error, ErrorCode}; +use crate::prelude::UncheckedAccount; use crate::{ Accounts, AccountsClose, AccountsExit, Key, Owner, Result, ToAccountInfo, ToAccountInfos, ToAccountMetas, ZeroCopy, @@ -80,7 +81,7 @@ use std::ops::DerefMut; /// bar: AccountLoader<'info, Bar>, /// #[account(mut)] /// authority: Signer<'info>, -/// system_program: AccountInfo<'info>, +/// system_program: UncheckedAccount<'info>, /// } /// /// #[derive(Accounts)] @@ -281,3 +282,9 @@ impl<'info, T: ZeroCopy + Owner> Key for AccountLoader<'info, T> { *self.acc_info.key } } + +impl<'info, T: ZeroCopy + Owner> From> for UncheckedAccount<'info> { + fn from(value: AccountLoader<'info, T>) -> Self { + UncheckedAccount::try_from(value.acc_info) + } +} diff --git a/lang/src/accounts/boxed.rs b/lang/src/accounts/boxed.rs index b143024ead..f956fe22e4 100644 --- a/lang/src/accounts/boxed.rs +++ b/lang/src/accounts/boxed.rs @@ -13,6 +13,7 @@ //! } //! ``` +use crate::prelude::UncheckedAccount; use crate::{Accounts, AccountsClose, AccountsExit, Result, ToAccountInfos, ToAccountMetas}; use solana_program::account_info::AccountInfo; use solana_program::instruction::AccountMeta; @@ -55,3 +56,9 @@ impl<'info, T: AccountsClose<'info>> AccountsClose<'info> for Box { T::close(self, sol_destination) } } + +impl<'info, T: Into>> From> for UncheckedAccount<'info> { + fn from(value: Box) -> Self { + value.into() + } +} diff --git a/lang/src/accounts/interface.rs b/lang/src/accounts/interface.rs index 2c3e4dac86..d3bca457b0 100644 --- a/lang/src/accounts/interface.rs +++ b/lang/src/accounts/interface.rs @@ -2,6 +2,7 @@ use crate::accounts::program::Program; use crate::error::{Error, ErrorCode}; +use crate::prelude::UncheckedAccount; use crate::{ AccountDeserialize, Accounts, AccountsExit, CheckId, Key, Result, ToAccountInfos, ToAccountMetas, @@ -142,3 +143,9 @@ impl<'info, T: AccountDeserialize> Key for Interface<'info, T> { self.0.key() } } + +impl<'info, T> From> for UncheckedAccount<'info> { + fn from(value: Interface<'info, T>) -> Self { + value.0.into() + } +} diff --git a/lang/src/accounts/interface_account.rs b/lang/src/accounts/interface_account.rs index 44817a29e1..4dc1577737 100644 --- a/lang/src/accounts/interface_account.rs +++ b/lang/src/accounts/interface_account.rs @@ -2,6 +2,7 @@ use crate::accounts::account::Account; use crate::error::ErrorCode; +use crate::prelude::UncheckedAccount; use crate::{ AccountDeserialize, AccountSerialize, Accounts, AccountsClose, AccountsExit, CheckOwner, Key, Owners, Result, ToAccountInfos, ToAccountMetas, @@ -329,3 +330,11 @@ impl<'info, T: AccountSerialize + AccountDeserialize + Clone> Key for InterfaceA self.account.key() } } + +impl<'info, T: AccountSerialize + AccountDeserialize + Clone> From> + for UncheckedAccount<'info> +{ + fn from(value: InterfaceAccount<'info, T>) -> Self { + value.account.into() + } +} diff --git a/lang/src/accounts/mod.rs b/lang/src/accounts/mod.rs index a5e55ebeab..e26f3bc619 100644 --- a/lang/src/accounts/mod.rs +++ b/lang/src/accounts/mod.rs @@ -1,6 +1,7 @@ //! Account types that can be used in the account validation struct. pub mod account; +#[doc(hidden)] pub mod account_info; pub mod account_loader; pub mod boxed; diff --git a/lang/src/accounts/program.rs b/lang/src/accounts/program.rs index 2aa8b9f7e2..0ba0ccb2d2 100644 --- a/lang/src/accounts/program.rs +++ b/lang/src/accounts/program.rs @@ -1,6 +1,7 @@ //! Type validating that the account is the given Program use crate::error::{Error, ErrorCode}; +use crate::prelude::UncheckedAccount; use crate::{ AccountDeserialize, Accounts, AccountsExit, Id, Key, Result, ToAccountInfos, ToAccountMetas, }; @@ -196,3 +197,9 @@ impl<'info, T: AccountDeserialize> Key for Program<'info, T> { *self.info.key } } + +impl<'info, T> From> for UncheckedAccount<'info> { + fn from(value: Program<'info, T>) -> Self { + UncheckedAccount::try_from(value.info) + } +} diff --git a/lang/src/accounts/signer.rs b/lang/src/accounts/signer.rs index 7d757024a3..b79d1ecfe5 100644 --- a/lang/src/accounts/signer.rs +++ b/lang/src/accounts/signer.rs @@ -1,5 +1,6 @@ //! Type validating that the account signed the transaction use crate::error::ErrorCode; +use crate::prelude::UncheckedAccount; use crate::{Accounts, AccountsExit, Key, Result, ToAccountInfos, ToAccountMetas}; use solana_program::account_info::AccountInfo; use solana_program::instruction::AccountMeta; @@ -110,3 +111,9 @@ impl<'info> Key for Signer<'info> { *self.info.key } } + +impl<'info> From> for UncheckedAccount<'info> { + fn from(value: Signer<'info>) -> Self { + UncheckedAccount::try_from(value.info) + } +} diff --git a/lang/src/accounts/system_account.rs b/lang/src/accounts/system_account.rs index 8c90fd537c..283b865d43 100644 --- a/lang/src/accounts/system_account.rs +++ b/lang/src/accounts/system_account.rs @@ -1,6 +1,7 @@ //! Type validating that the account is owned by the system program use crate::error::ErrorCode; +use crate::prelude::UncheckedAccount; use crate::*; use solana_program::account_info::AccountInfo; use solana_program::instruction::AccountMeta; @@ -89,3 +90,9 @@ impl<'info> Key for SystemAccount<'info> { *self.info.key } } + +impl<'info> From> for UncheckedAccount<'info> { + fn from(value: SystemAccount<'info>) -> Self { + UncheckedAccount::try_from(value.info) + } +} diff --git a/lang/src/accounts/sysvar.rs b/lang/src/accounts/sysvar.rs index c955ff9c15..881791a7e2 100644 --- a/lang/src/accounts/sysvar.rs +++ b/lang/src/accounts/sysvar.rs @@ -1,6 +1,7 @@ //! Type validating that the account is a sysvar and deserializing it use crate::error::ErrorCode; +use crate::prelude::UncheckedAccount; use crate::{Accounts, AccountsExit, Key, Result, ToAccountInfos, ToAccountMetas}; use solana_program::account_info::AccountInfo; use solana_program::instruction::AccountMeta; @@ -121,3 +122,9 @@ impl<'info, T: solana_program::sysvar::Sysvar> Key for Sysvar<'info, T> { *self.info.key } } + +impl<'info, T: solana_program::sysvar::Sysvar> From> for UncheckedAccount<'info> { + fn from(value: Sysvar<'info, T>) -> Self { + UncheckedAccount::try_from(value.info) + } +} diff --git a/lang/src/accounts/unchecked_account.rs b/lang/src/accounts/unchecked_account.rs index 5a00127579..3f13a0dfb0 100644 --- a/lang/src/accounts/unchecked_account.rs +++ b/lang/src/accounts/unchecked_account.rs @@ -75,3 +75,9 @@ impl<'info> Key for UncheckedAccount<'info> { *self.0.key } } + +impl<'info> From> for UncheckedAccount<'info> { + fn from(value: AccountInfo<'info>) -> Self { + UncheckedAccount::try_from(value) + } +} diff --git a/lang/src/system_program.rs b/lang/src/system_program.rs index b11d514ce0..73cef9a5b6 100644 --- a/lang/src/system_program.rs +++ b/lang/src/system_program.rs @@ -22,9 +22,9 @@ pub fn advance_nonce_account<'info>( crate::solana_program::program::invoke_signed( &ix, &[ - ctx.accounts.nonce, - ctx.accounts.recent_blockhashes, - ctx.accounts.authorized, + ctx.accounts.nonce.to_account_info(), + ctx.accounts.recent_blockhashes.to_account_info(), + ctx.accounts.authorized.to_account_info(), ], ctx.signer_seeds, ) @@ -32,11 +32,10 @@ pub fn advance_nonce_account<'info>( } #[derive(Accounts)] -#[only_cpi] pub struct AdvanceNonceAccount<'info> { - pub nonce: AccountInfo<'info>, - pub authorized: AccountInfo<'info>, - pub recent_blockhashes: AccountInfo<'info>, + pub nonce: UncheckedAccount<'info>, + pub authorized: UncheckedAccount<'info>, + pub recent_blockhashes: UncheckedAccount<'info>, } pub fn allocate<'info>( @@ -49,16 +48,15 @@ pub fn allocate<'info>( ); crate::solana_program::program::invoke_signed( &ix, - &[ctx.accounts.account_to_allocate], + &[ctx.accounts.account_to_allocate.to_account_info()], ctx.signer_seeds, ) .map_err(Into::into) } #[derive(Accounts)] -#[only_cpi] pub struct Allocate<'info> { - pub account_to_allocate: AccountInfo<'info>, + pub account_to_allocate: UncheckedAccount<'info>, } pub fn allocate_with_seed<'info>( @@ -76,17 +74,19 @@ pub fn allocate_with_seed<'info>( ); crate::solana_program::program::invoke_signed( &ix, - &[ctx.accounts.account_to_allocate, ctx.accounts.base], + &[ + ctx.accounts.account_to_allocate.to_account_info(), + ctx.accounts.base.to_account_info(), + ], ctx.signer_seeds, ) .map_err(Into::into) } #[derive(Accounts)] -#[only_cpi] pub struct AllocateWithSeed<'info> { - pub account_to_allocate: AccountInfo<'info>, - pub base: AccountInfo<'info>, + pub account_to_allocate: UncheckedAccount<'info>, + pub base: UncheckedAccount<'info>, } pub fn assign<'info>( @@ -99,16 +99,15 @@ pub fn assign<'info>( ); crate::solana_program::program::invoke_signed( &ix, - &[ctx.accounts.account_to_assign], + &[ctx.accounts.account_to_assign.to_account_info()], ctx.signer_seeds, ) .map_err(Into::into) } #[derive(Accounts)] -#[only_cpi] pub struct Assign<'info> { - pub account_to_assign: AccountInfo<'info>, + pub account_to_assign: UncheckedAccount<'info>, } pub fn assign_with_seed<'info>( @@ -124,17 +123,19 @@ pub fn assign_with_seed<'info>( ); crate::solana_program::program::invoke_signed( &ix, - &[ctx.accounts.account_to_assign, ctx.accounts.base], + &[ + ctx.accounts.account_to_assign.to_account_info(), + ctx.accounts.base.to_account_info(), + ], ctx.signer_seeds, ) .map_err(Into::into) } #[derive(Accounts)] -#[only_cpi] pub struct AssignWithSeed<'info> { - pub account_to_assign: AccountInfo<'info>, - pub base: AccountInfo<'info>, + pub account_to_assign: UncheckedAccount<'info>, + pub base: UncheckedAccount<'info>, } pub fn authorize_nonce_account<'info>( @@ -148,17 +149,19 @@ pub fn authorize_nonce_account<'info>( ); crate::solana_program::program::invoke_signed( &ix, - &[ctx.accounts.nonce, ctx.accounts.authorized], + &[ + ctx.accounts.nonce.to_account_info(), + ctx.accounts.authorized.to_account_info(), + ], ctx.signer_seeds, ) .map_err(Into::into) } #[derive(Accounts)] -#[only_cpi] pub struct AuthorizeNonceAccount<'info> { - pub nonce: AccountInfo<'info>, - pub authorized: AccountInfo<'info>, + pub nonce: UncheckedAccount<'info>, + pub authorized: UncheckedAccount<'info>, } pub fn create_account<'info>( @@ -176,17 +179,19 @@ pub fn create_account<'info>( ); crate::solana_program::program::invoke_signed( &ix, - &[ctx.accounts.from, ctx.accounts.to], + &[ + ctx.accounts.from.to_account_info(), + ctx.accounts.to.to_account_info(), + ], ctx.signer_seeds, ) .map_err(Into::into) } #[derive(Accounts)] -#[only_cpi] pub struct CreateAccount<'info> { - pub from: AccountInfo<'info>, - pub to: AccountInfo<'info>, + pub from: UncheckedAccount<'info>, + pub to: UncheckedAccount<'info>, } pub fn create_account_with_seed<'info>( @@ -207,18 +212,21 @@ pub fn create_account_with_seed<'info>( ); crate::solana_program::program::invoke_signed( &ix, - &[ctx.accounts.from, ctx.accounts.to, ctx.accounts.base], + &[ + ctx.accounts.from.to_account_info(), + ctx.accounts.to.to_account_info(), + ctx.accounts.base.to_account_info(), + ], ctx.signer_seeds, ) .map_err(Into::into) } #[derive(Accounts)] -#[only_cpi] pub struct CreateAccountWithSeed<'info> { - pub from: AccountInfo<'info>, - pub to: AccountInfo<'info>, - pub base: AccountInfo<'info>, + pub from: UncheckedAccount<'info>, + pub to: UncheckedAccount<'info>, + pub base: UncheckedAccount<'info>, } pub fn create_nonce_account<'info>( @@ -234,16 +242,19 @@ pub fn create_nonce_account<'info>( ); crate::solana_program::program::invoke_signed( &ixs[0], - &[ctx.accounts.from, ctx.accounts.nonce.clone()], + &[ + ctx.accounts.from.to_account_info(), + ctx.accounts.nonce.to_account_info(), + ], ctx.signer_seeds, )?; crate::solana_program::program::invoke_signed( &ixs[1], &[ - ctx.accounts.nonce, - ctx.accounts.recent_blockhashes, - ctx.accounts.rent, + ctx.accounts.nonce.to_account_info(), + ctx.accounts.recent_blockhashes.to_account_info(), + ctx.accounts.rent.to_account_info(), ], ctx.signer_seeds, ) @@ -251,12 +262,11 @@ pub fn create_nonce_account<'info>( } #[derive(Accounts)] -#[only_cpi] pub struct CreateNonceAccount<'info> { - pub from: AccountInfo<'info>, - pub nonce: AccountInfo<'info>, - pub recent_blockhashes: AccountInfo<'info>, - pub rent: AccountInfo<'info>, + pub from: UncheckedAccount<'info>, + pub nonce: UncheckedAccount<'info>, + pub recent_blockhashes: UncheckedAccount<'info>, + pub rent: UncheckedAccount<'info>, } pub fn create_nonce_account_with_seed<'info>( @@ -276,9 +286,9 @@ pub fn create_nonce_account_with_seed<'info>( crate::solana_program::program::invoke_signed( &ixs[0], &[ - ctx.accounts.from, - ctx.accounts.nonce.clone(), - ctx.accounts.base, + ctx.accounts.from.to_account_info(), + ctx.accounts.nonce.to_account_info(), + ctx.accounts.base.to_account_info(), ], ctx.signer_seeds, )?; @@ -286,9 +296,9 @@ pub fn create_nonce_account_with_seed<'info>( crate::solana_program::program::invoke_signed( &ixs[1], &[ - ctx.accounts.nonce, - ctx.accounts.recent_blockhashes, - ctx.accounts.rent, + ctx.accounts.nonce.to_account_info(), + ctx.accounts.recent_blockhashes.to_account_info(), + ctx.accounts.rent.to_account_info(), ], ctx.signer_seeds, ) @@ -296,13 +306,12 @@ pub fn create_nonce_account_with_seed<'info>( } #[derive(Accounts)] -#[only_cpi] pub struct CreateNonceAccountWithSeed<'info> { - pub from: AccountInfo<'info>, - pub nonce: AccountInfo<'info>, - pub base: AccountInfo<'info>, - pub recent_blockhashes: AccountInfo<'info>, - pub rent: AccountInfo<'info>, + pub from: UncheckedAccount<'info>, + pub nonce: UncheckedAccount<'info>, + pub base: UncheckedAccount<'info>, + pub recent_blockhashes: UncheckedAccount<'info>, + pub rent: UncheckedAccount<'info>, } pub fn transfer<'info>( @@ -316,17 +325,19 @@ pub fn transfer<'info>( ); crate::solana_program::program::invoke_signed( &ix, - &[ctx.accounts.from, ctx.accounts.to], + &[ + ctx.accounts.from.to_account_info(), + ctx.accounts.to.to_account_info(), + ], ctx.signer_seeds, ) .map_err(Into::into) } #[derive(Accounts)] -#[only_cpi] pub struct Transfer<'info> { - pub from: AccountInfo<'info>, - pub to: AccountInfo<'info>, + pub from: UncheckedAccount<'info>, + pub to: UncheckedAccount<'info>, } pub fn transfer_with_seed<'info>( @@ -345,18 +356,21 @@ pub fn transfer_with_seed<'info>( ); crate::solana_program::program::invoke_signed( &ix, - &[ctx.accounts.from, ctx.accounts.base, ctx.accounts.to], + &[ + ctx.accounts.from.to_account_info(), + ctx.accounts.base.to_account_info(), + ctx.accounts.to.to_account_info(), + ], ctx.signer_seeds, ) .map_err(Into::into) } #[derive(Accounts)] -#[only_cpi] pub struct TransferWithSeed<'info> { - pub from: AccountInfo<'info>, - pub base: AccountInfo<'info>, - pub to: AccountInfo<'info>, + pub from: UncheckedAccount<'info>, + pub base: UncheckedAccount<'info>, + pub to: UncheckedAccount<'info>, } pub fn withdraw_nonce_account<'info>( @@ -372,11 +386,11 @@ pub fn withdraw_nonce_account<'info>( crate::solana_program::program::invoke_signed( &ix, &[ - ctx.accounts.nonce, - ctx.accounts.to, - ctx.accounts.recent_blockhashes, - ctx.accounts.rent, - ctx.accounts.authorized, + ctx.accounts.nonce.to_account_info(), + ctx.accounts.to.to_account_info(), + ctx.accounts.recent_blockhashes.to_account_info(), + ctx.accounts.rent.to_account_info(), + ctx.accounts.authorized.to_account_info(), ], ctx.signer_seeds, ) @@ -384,11 +398,10 @@ pub fn withdraw_nonce_account<'info>( } #[derive(Accounts)] -#[only_cpi] pub struct WithdrawNonceAccount<'info> { - pub nonce: AccountInfo<'info>, - pub to: AccountInfo<'info>, - pub recent_blockhashes: AccountInfo<'info>, - pub rent: AccountInfo<'info>, - pub authorized: AccountInfo<'info>, + pub nonce: UncheckedAccount<'info>, + pub to: UncheckedAccount<'info>, + pub recent_blockhashes: UncheckedAccount<'info>, + pub rent: UncheckedAccount<'info>, + pub authorized: UncheckedAccount<'info>, } diff --git a/lang/syn/src/codegen/accounts/__cpi_client_accounts.rs b/lang/syn/src/codegen/accounts/__cpi_client_accounts.rs index 57b4f53730..569b8e142e 100644 --- a/lang/syn/src/codegen/accounts/__cpi_client_accounts.rs +++ b/lang/syn/src/codegen/accounts/__cpi_client_accounts.rs @@ -63,12 +63,12 @@ pub fn generate(accs: &AccountsStruct) -> proc_macro2::TokenStream { if f.is_optional { quote! { #docs - pub #name: Option> + pub #name: Option> } } else { quote! { #docs - pub #name: anchor_lang::solana_program::account_info::AccountInfo<'info> + pub #name: anchor_lang::accounts::unchecked_account::UncheckedAccount<'info> } } } diff --git a/lang/syn/src/codegen/accounts/constraints.rs b/lang/syn/src/codegen/accounts/constraints.rs index 2a515d7116..0b580652fd 100644 --- a/lang/syn/src/codegen/accounts/constraints.rs +++ b/lang/syn/src/codegen/accounts/constraints.rs @@ -390,8 +390,8 @@ fn generate_constraint_realloc( anchor_lang::context::CpiContext::new( system_program.to_account_info(), anchor_lang::system_program::Transfer { - from: #payer.to_account_info(), - to: __field_info.clone(), + from: #payer.to_account_info().into(), + to: __field_info.clone().into(), }, ), __new_rent_minimum.checked_sub(__field_info.lamports()).unwrap(), @@ -557,9 +557,9 @@ fn generate_constraint_init_group( // Initialize the token account. let cpi_program = #token_program.to_account_info(); let accounts = ::anchor_spl::token_interface::InitializeAccount3 { - account: #field.to_account_info(), - mint: #mint.to_account_info(), - authority: #owner.to_account_info(), + account: #field.to_account_info().into(), + mint: #mint.to_account_info().into(), + authority: #owner.to_account_info().into(), }; let cpi_ctx = anchor_lang::context::CpiContext::new(cpi_program, accounts); ::anchor_spl::token_interface::initialize_account3(cpi_ctx)?; @@ -624,12 +624,12 @@ fn generate_constraint_init_group( let cpi_program = associated_token_program.to_account_info(); let cpi_accounts = ::anchor_spl::associated_token::Create { - payer: #payer.to_account_info(), - associated_token: #field.to_account_info(), - authority: #owner.to_account_info(), - mint: #mint.to_account_info(), - system_program: system_program.to_account_info(), - token_program: #token_program.to_account_info(), + payer: #payer.to_account_info().into(), + associated_token: #field.to_account_info().into(), + authority: #owner.to_account_info().into(), + mint: #mint.to_account_info().into(), + system_program: system_program.to_account_info().into(), + token_program: #token_program.to_account_info().into(), }; let cpi_ctx = anchor_lang::context::CpiContext::new(cpi_program, cpi_accounts); ::anchor_spl::associated_token::create(cpi_ctx)?; @@ -716,7 +716,7 @@ fn generate_constraint_init_group( // Initialize the mint account. let cpi_program = #token_program.to_account_info(); let accounts = ::anchor_spl::token_interface::InitializeMint2 { - mint: #field.to_account_info(), + mint: #field.to_account_info().into(), }; let cpi_ctx = anchor_lang::context::CpiContext::new(cpi_program, accounts); ::anchor_spl::token_interface::initialize_mint2(cpi_ctx, #decimals, &#owner.key(), #freeze_authority)?; @@ -1142,13 +1142,13 @@ fn generate_create_account( let space = #space; let lamports = __anchor_rent.minimum_balance(space); let cpi_accounts = anchor_lang::system_program::CreateAccount { - from: #payer.to_account_info(), - to: #field.to_account_info() + from: #payer.to_account_info().into(), + to: #field.to_account_info().into(), }; let cpi_context = anchor_lang::context::CpiContext::new(system_program.to_account_info(), cpi_accounts); anchor_lang::system_program::create_account(cpi_context.with_signer(&[#seeds_with_nonce]), lamports, space as u64, #owner)?; } else { - require_keys_neq!(#payer.key(), #field.key(), anchor_lang::error::ErrorCode::TryingToInitPayerAsProgramAccount); + require_keys_neq!(#payer.key(), *#field.key, anchor_lang::error::ErrorCode::TryingToInitPayerAsProgramAccount); // Fund the account for rent exemption. let required_lamports = __anchor_rent .minimum_balance(#space) @@ -1156,21 +1156,21 @@ fn generate_create_account( .saturating_sub(__current_lamports); if required_lamports > 0 { let cpi_accounts = anchor_lang::system_program::Transfer { - from: #payer.to_account_info(), - to: #field.to_account_info(), + from: #payer.to_account_info().into(), + to: #field.to_account_info().into(), }; let cpi_context = anchor_lang::context::CpiContext::new(system_program.to_account_info(), cpi_accounts); anchor_lang::system_program::transfer(cpi_context, required_lamports)?; } // Allocate space. let cpi_accounts = anchor_lang::system_program::Allocate { - account_to_allocate: #field.to_account_info() + account_to_allocate: #field.to_account_info().into(), }; let cpi_context = anchor_lang::context::CpiContext::new(system_program.to_account_info(), cpi_accounts); anchor_lang::system_program::allocate(cpi_context.with_signer(&[#seeds_with_nonce]), #space as u64)?; // Assign to the spl token program. let cpi_accounts = anchor_lang::system_program::Assign { - account_to_assign: #field.to_account_info() + account_to_assign: #field.to_account_info().into(), }; let cpi_context = anchor_lang::context::CpiContext::new(system_program.to_account_info(), cpi_accounts); anchor_lang::system_program::assign(cpi_context.with_signer(&[#seeds_with_nonce]), #owner)?; diff --git a/lang/syn/src/codegen/accounts/mod.rs b/lang/syn/src/codegen/accounts/mod.rs index fd4a855e66..3a239cbe33 100644 --- a/lang/syn/src/codegen/accounts/mod.rs +++ b/lang/syn/src/codegen/accounts/mod.rs @@ -22,21 +22,14 @@ pub fn generate(accs: &AccountsStruct) -> proc_macro2::TokenStream { let __client_accounts_mod = __client_accounts::generate(accs); let __cpi_client_accounts_mod = __cpi_client_accounts::generate(accs); - if accs.only_cpi { - quote! { - #impl_to_account_infos - #impl_to_account_metas - } - } else { - quote! { - #impl_try_accounts - #impl_to_account_infos - #impl_to_account_metas - #impl_exit + quote! { + #impl_try_accounts + #impl_to_account_infos + #impl_to_account_metas + #impl_exit - #__client_accounts_mod - #__cpi_client_accounts_mod - } + #__client_accounts_mod + #__cpi_client_accounts_mod } } diff --git a/lang/syn/src/codegen/program/idl.rs b/lang/syn/src/codegen/program/idl.rs index 2e4c83f94f..eecfbdcbde 100644 --- a/lang/syn/src/codegen/program/idl.rs +++ b/lang/syn/src/codegen/program/idl.rs @@ -224,8 +224,8 @@ pub fn idl_accounts_and_functions() -> proc_macro2::TokenStream { anchor_lang::context::CpiContext::new( accounts.system_program.to_account_info(), anchor_lang::system_program::Transfer { - from: accounts.authority.to_account_info(), - to: accounts.idl.to_account_info(), + from: accounts.authority.to_account_info().into(), + to: accounts.idl.to_account_info().into(), }, ), new_rent_minimum diff --git a/lang/syn/src/lib.rs b/lang/syn/src/lib.rs index 210d957dd6..80f74af598 100644 --- a/lang/syn/src/lib.rs +++ b/lang/syn/src/lib.rs @@ -93,8 +93,6 @@ pub struct AccountsStruct { pub fields: Vec, // Instruction data api expression. instruction_api: Option>, - // Used internally to limit the codegen - only_cpi: bool, } impl Parse for AccountsStruct { @@ -121,7 +119,6 @@ impl AccountsStruct { strct: ItemStruct, fields: Vec, instruction_api: Option>, - only_cpi: bool, ) -> Self { let ident = strct.ident.clone(); let generics = strct.generics; @@ -130,7 +127,6 @@ impl AccountsStruct { generics, fields, instruction_api, - only_cpi, } } @@ -243,9 +239,6 @@ impl Field { let account_ty = self.account_ty(); let container_ty = self.container_ty(); let inner_ty = match &self.ty { - Ty::AccountInfo => quote! { - AccountInfo - }, Ty::UncheckedAccount => quote! { UncheckedAccount }, @@ -322,7 +315,6 @@ impl Field { }, }; match &self.ty { - Ty::AccountInfo => quote! { #field.to_account_info() }, Ty::UncheckedAccount => { quote! { UncheckedAccount::try_from(#field.to_account_info()) } } @@ -402,7 +394,6 @@ impl Field { Ty::InterfaceAccount(_) => { quote! { anchor_lang::accounts::interface_account::InterfaceAccount } } - Ty::AccountInfo => quote! {}, Ty::UncheckedAccount => quote! {}, Ty::Signer => quote! {}, Ty::SystemAccount => quote! {}, @@ -413,9 +404,6 @@ impl Field { // Returns the inner account struct type. pub fn account_ty(&self) -> proc_macro2::TokenStream { match &self.ty { - Ty::AccountInfo => quote! { - AccountInfo - }, Ty::UncheckedAccount => quote! { UncheckedAccount }, @@ -487,7 +475,6 @@ pub struct CompositeField { // A type of an account field. #[derive(Debug, PartialEq, Eq)] pub enum Ty { - AccountInfo, UncheckedAccount, AccountLoader(AccountLoaderTy), Sysvar(SysvarTy), diff --git a/lang/syn/src/parser/accounts/mod.rs b/lang/syn/src/parser/accounts/mod.rs index 45018e0a05..acee1c80a3 100644 --- a/lang/syn/src/parser/accounts/mod.rs +++ b/lang/syn/src/parser/accounts/mod.rs @@ -20,7 +20,6 @@ pub fn parse(strct: &syn::ItemStruct) -> ParseResult { }) .map(|ix_attr| ix_attr.parse_args_with(Punctuated::::parse_terminated)) .transpose()?; - let only_cpi = strct.attrs.iter().any(|a| a.path.is_ident("only_cpi")); let fields = match &strct.fields { syn::Fields::Named(fields) => fields .named @@ -35,33 +34,9 @@ pub fn parse(strct: &syn::ItemStruct) -> ParseResult { } }; - if !only_cpi { - prevent_account_info(&fields)?; - } - constraints_cross_checks(&fields)?; - Ok(AccountsStruct::new( - strct.clone(), - fields, - instruction_api, - only_cpi, - )) -} - -fn prevent_account_info(fields: &[AccountField]) -> ParseResult<()> { - let field = fields.iter().find(|f| match f { - AccountField::Field(acc_f) => acc_f.ty == Ty::AccountInfo, - _ => false, - }); - - match field { - Some(f) => Err(ParseError::new( - f.ident().span(), - "AccountInfo can no longer be used in the context. Please use UncheckedAccount instead.", - )), - None => Ok(()), - } + Ok(AccountsStruct::new(strct.clone(), fields, instruction_api)) } fn constraints_cross_checks(fields: &[AccountField]) -> ParseResult<()> { @@ -318,7 +293,6 @@ fn is_field_primitive(f: &syn::Field) -> ParseResult { let r = matches!( ident_string(f)?.0.as_str(), "Sysvar" - | "AccountInfo" | "UncheckedAccount" | "AccountLoader" | "Account" @@ -336,7 +310,6 @@ fn parse_ty(f: &syn::Field) -> ParseResult<(Ty, bool)> { let (ident, optional, path) = ident_string(f)?; let ty = match ident.as_str() { "Sysvar" => Ty::Sysvar(parse_sysvar(&path)?), - "AccountInfo" => Ty::AccountInfo, "UncheckedAccount" => Ty::UncheckedAccount, "AccountLoader" => Ty::AccountLoader(parse_program_account_loader(&path)?), "Account" => Ty::Account(parse_account_ty(&path)?), diff --git a/spl/src/associated_token.rs b/spl/src/associated_token.rs index 6e43cd39e0..8c32cae542 100644 --- a/spl/src/associated_token.rs +++ b/spl/src/associated_token.rs @@ -1,7 +1,7 @@ -use anchor_lang::solana_program::account_info::AccountInfo; +use anchor_lang::prelude::UncheckedAccount; use anchor_lang::solana_program::pubkey::Pubkey; -use anchor_lang::Result; use anchor_lang::{context::CpiContext, Accounts}; +use anchor_lang::{Result, ToAccountInfo}; pub use spl_associated_token_account::{ get_associated_token_address, get_associated_token_address_with_program_id, ID, @@ -17,12 +17,12 @@ pub fn create<'info>(ctx: CpiContext<'_, '_, '_, 'info, Create<'info>>) -> Resul solana_program::program::invoke_signed( &ix, &[ - ctx.accounts.payer, - ctx.accounts.associated_token, - ctx.accounts.authority, - ctx.accounts.mint, - ctx.accounts.system_program, - ctx.accounts.token_program, + ctx.accounts.payer.to_account_info(), + ctx.accounts.associated_token.to_account_info(), + ctx.accounts.authority.to_account_info(), + ctx.accounts.mint.to_account_info(), + ctx.accounts.system_program.to_account_info(), + ctx.accounts.token_program.to_account_info(), ], ctx.signer_seeds, ) @@ -41,12 +41,12 @@ pub fn create_idempotent<'info>( solana_program::program::invoke_signed( &ix, &[ - ctx.accounts.payer, - ctx.accounts.associated_token, - ctx.accounts.authority, - ctx.accounts.mint, - ctx.accounts.system_program, - ctx.accounts.token_program, + ctx.accounts.payer.to_account_info(), + ctx.accounts.associated_token.to_account_info(), + ctx.accounts.authority.to_account_info(), + ctx.accounts.mint.to_account_info(), + ctx.accounts.system_program.to_account_info(), + ctx.accounts.token_program.to_account_info(), ], ctx.signer_seeds, ) @@ -54,14 +54,13 @@ pub fn create_idempotent<'info>( } #[derive(Accounts)] -#[only_cpi] pub struct Create<'info> { - pub payer: AccountInfo<'info>, - pub associated_token: AccountInfo<'info>, - pub authority: AccountInfo<'info>, - pub mint: AccountInfo<'info>, - pub system_program: AccountInfo<'info>, - pub token_program: AccountInfo<'info>, + pub payer: UncheckedAccount<'info>, + pub associated_token: UncheckedAccount<'info>, + pub authority: UncheckedAccount<'info>, + pub mint: UncheckedAccount<'info>, + pub system_program: UncheckedAccount<'info>, + pub token_program: UncheckedAccount<'info>, } type CreateIdempotent<'info> = Create<'info>; diff --git a/spl/src/dex.rs b/spl/src/dex.rs index bfe2965051..207e1945f6 100644 --- a/spl/src/dex.rs +++ b/spl/src/dex.rs @@ -1,4 +1,4 @@ -use anchor_lang::solana_program::account_info::AccountInfo; +use anchor_lang::prelude::UncheckedAccount; use anchor_lang::solana_program::program_error::ProgramError; use anchor_lang::solana_program::pubkey::Pubkey; use anchor_lang::{context::CpiContext, Accounts, Result, ToAccountInfos}; @@ -203,97 +203,90 @@ pub fn initialize_market<'info>( } #[derive(Accounts)] -#[only_cpi] pub struct NewOrderV3<'info> { - pub market: AccountInfo<'info>, - pub open_orders: AccountInfo<'info>, - pub request_queue: AccountInfo<'info>, - pub event_queue: AccountInfo<'info>, - pub market_bids: AccountInfo<'info>, - pub market_asks: AccountInfo<'info>, + pub market: UncheckedAccount<'info>, + pub open_orders: UncheckedAccount<'info>, + pub request_queue: UncheckedAccount<'info>, + pub event_queue: UncheckedAccount<'info>, + pub market_bids: UncheckedAccount<'info>, + pub market_asks: UncheckedAccount<'info>, // Token account where funds are transferred from for the order. If // posting a bid market A/B, then this is the SPL token account for B. - pub order_payer_token_account: AccountInfo<'info>, - pub open_orders_authority: AccountInfo<'info>, + pub order_payer_token_account: UncheckedAccount<'info>, + pub open_orders_authority: UncheckedAccount<'info>, // Also known as the "base" currency. For a given A/B market, // this is the vault for the A mint. - pub coin_vault: AccountInfo<'info>, + pub coin_vault: UncheckedAccount<'info>, // Also known as the "quote" currency. For a given A/B market, // this is the vault for the B mint. - pub pc_vault: AccountInfo<'info>, - pub token_program: AccountInfo<'info>, - pub rent: AccountInfo<'info>, + pub pc_vault: UncheckedAccount<'info>, + pub token_program: UncheckedAccount<'info>, + pub rent: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct CancelOrderV2<'info> { - pub market: AccountInfo<'info>, - pub market_bids: AccountInfo<'info>, - pub market_asks: AccountInfo<'info>, - pub open_orders: AccountInfo<'info>, - pub open_orders_authority: AccountInfo<'info>, - pub event_queue: AccountInfo<'info>, + pub market: UncheckedAccount<'info>, + pub market_bids: UncheckedAccount<'info>, + pub market_asks: UncheckedAccount<'info>, + pub open_orders: UncheckedAccount<'info>, + pub open_orders_authority: UncheckedAccount<'info>, + pub event_queue: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct SettleFunds<'info> { - pub market: AccountInfo<'info>, - pub open_orders: AccountInfo<'info>, - pub open_orders_authority: AccountInfo<'info>, - pub coin_vault: AccountInfo<'info>, - pub pc_vault: AccountInfo<'info>, - pub coin_wallet: AccountInfo<'info>, - pub pc_wallet: AccountInfo<'info>, - pub vault_signer: AccountInfo<'info>, - pub token_program: AccountInfo<'info>, + pub market: UncheckedAccount<'info>, + pub open_orders: UncheckedAccount<'info>, + pub open_orders_authority: UncheckedAccount<'info>, + pub coin_vault: UncheckedAccount<'info>, + pub pc_vault: UncheckedAccount<'info>, + pub coin_wallet: UncheckedAccount<'info>, + pub pc_wallet: UncheckedAccount<'info>, + pub vault_signer: UncheckedAccount<'info>, + pub token_program: UncheckedAccount<'info>, } /// To use an (optional) market authority, add it as the first account of the /// CpiContext's `remaining_accounts` Vec. #[derive(Accounts)] -#[only_cpi] pub struct InitOpenOrders<'info> { - pub open_orders: AccountInfo<'info>, - pub authority: AccountInfo<'info>, - pub market: AccountInfo<'info>, - pub rent: AccountInfo<'info>, + pub open_orders: UncheckedAccount<'info>, + pub authority: UncheckedAccount<'info>, + pub market: UncheckedAccount<'info>, + pub rent: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct CloseOpenOrders<'info> { - pub open_orders: AccountInfo<'info>, - pub authority: AccountInfo<'info>, - pub destination: AccountInfo<'info>, - pub market: AccountInfo<'info>, + pub open_orders: UncheckedAccount<'info>, + pub authority: UncheckedAccount<'info>, + pub destination: UncheckedAccount<'info>, + pub market: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct SweepFees<'info> { - pub market: AccountInfo<'info>, - pub pc_vault: AccountInfo<'info>, - pub sweep_authority: AccountInfo<'info>, - pub sweep_receiver: AccountInfo<'info>, - pub vault_signer: AccountInfo<'info>, - pub token_program: AccountInfo<'info>, + pub market: UncheckedAccount<'info>, + pub pc_vault: UncheckedAccount<'info>, + pub sweep_authority: UncheckedAccount<'info>, + pub sweep_receiver: UncheckedAccount<'info>, + pub vault_signer: UncheckedAccount<'info>, + pub token_program: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct InitializeMarket<'info> { - pub market: AccountInfo<'info>, - pub coin_mint: AccountInfo<'info>, - pub pc_mint: AccountInfo<'info>, - pub coin_vault: AccountInfo<'info>, - pub pc_vault: AccountInfo<'info>, - pub bids: AccountInfo<'info>, - pub asks: AccountInfo<'info>, - pub req_q: AccountInfo<'info>, - pub event_q: AccountInfo<'info>, - pub rent: AccountInfo<'info>, + pub market: UncheckedAccount<'info>, + pub coin_mint: UncheckedAccount<'info>, + pub pc_mint: UncheckedAccount<'info>, + pub coin_vault: UncheckedAccount<'info>, + pub pc_vault: UncheckedAccount<'info>, + pub bids: UncheckedAccount<'info>, + pub asks: UncheckedAccount<'info>, + pub req_q: UncheckedAccount<'info>, + pub event_q: UncheckedAccount<'info>, + pub rent: UncheckedAccount<'info>, } #[derive(Clone)] diff --git a/spl/src/metadata.rs b/spl/src/metadata.rs index 2f30539b39..296c853ba1 100644 --- a/spl/src/metadata.rs +++ b/spl/src/metadata.rs @@ -1,8 +1,12 @@ -use anchor_lang::context::CpiContext; -use anchor_lang::{Accounts, ErrorCode, Result, ToAccountInfos}; -use mpl_token_metadata::state::{CollectionDetails, DataV2, TokenMetadataAccount}; -use mpl_token_metadata::ID; -use solana_program::account_info::AccountInfo; +use anchor_lang::{ + context::CpiContext, + prelude::{ErrorCode, UncheckedAccount}, + Accounts, Result, ToAccountInfos, +}; +use mpl_token_metadata::{ + state::{CollectionDetails, DataV2, TokenMetadataAccount}, + ID, +}; use solana_program::pubkey::Pubkey; use std::ops::Deref; @@ -554,114 +558,105 @@ pub fn unverify_sized_collection_item<'info>( } #[derive(Accounts)] -#[only_cpi] pub struct ApproveCollectionAuthority<'info> { - pub collection_authority_record: AccountInfo<'info>, - pub new_collection_authority: AccountInfo<'info>, - pub update_authority: AccountInfo<'info>, - pub payer: AccountInfo<'info>, - pub metadata: AccountInfo<'info>, - pub mint: AccountInfo<'info>, + pub collection_authority_record: UncheckedAccount<'info>, + pub new_collection_authority: UncheckedAccount<'info>, + pub update_authority: UncheckedAccount<'info>, + pub payer: UncheckedAccount<'info>, + pub metadata: UncheckedAccount<'info>, + pub mint: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct BubblegumSetCollectionSize<'info> { - pub metadata_account: AccountInfo<'info>, - pub update_authority: AccountInfo<'info>, - pub mint: AccountInfo<'info>, - pub bubblegum_signer: AccountInfo<'info>, + pub metadata_account: UncheckedAccount<'info>, + pub update_authority: UncheckedAccount<'info>, + pub mint: UncheckedAccount<'info>, + pub bubblegum_signer: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct BurnEditionNft<'info> { - pub metadata: AccountInfo<'info>, - pub owner: AccountInfo<'info>, - pub print_edition_mint: AccountInfo<'info>, - pub master_edition_mint: AccountInfo<'info>, - pub print_edition_token: AccountInfo<'info>, - pub master_edition_token: AccountInfo<'info>, - pub master_edition: AccountInfo<'info>, - pub print_edition: AccountInfo<'info>, - pub edition_marker: AccountInfo<'info>, - pub spl_token: AccountInfo<'info>, + pub metadata: UncheckedAccount<'info>, + pub owner: UncheckedAccount<'info>, + pub print_edition_mint: UncheckedAccount<'info>, + pub master_edition_mint: UncheckedAccount<'info>, + pub print_edition_token: UncheckedAccount<'info>, + pub master_edition_token: UncheckedAccount<'info>, + pub master_edition: UncheckedAccount<'info>, + pub print_edition: UncheckedAccount<'info>, + pub edition_marker: UncheckedAccount<'info>, + pub spl_token: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct BurnNft<'info> { - pub metadata: AccountInfo<'info>, - pub owner: AccountInfo<'info>, - pub mint: AccountInfo<'info>, - pub token: AccountInfo<'info>, - pub edition: AccountInfo<'info>, - pub spl_token: AccountInfo<'info>, + pub metadata: UncheckedAccount<'info>, + pub owner: UncheckedAccount<'info>, + pub mint: UncheckedAccount<'info>, + pub token: UncheckedAccount<'info>, + pub edition: UncheckedAccount<'info>, + pub spl_token: UncheckedAccount<'info>, } #[deprecated(note = "internal instructions deprecated by Metaplex")] #[derive(Accounts)] -#[only_cpi] pub struct CreateMetadataAccountsV2<'info> { - pub metadata: AccountInfo<'info>, - pub mint: AccountInfo<'info>, - pub mint_authority: AccountInfo<'info>, - pub payer: AccountInfo<'info>, - pub update_authority: AccountInfo<'info>, - pub system_program: AccountInfo<'info>, - pub rent: AccountInfo<'info>, + pub metadata: UncheckedAccount<'info>, + pub mint: UncheckedAccount<'info>, + pub mint_authority: UncheckedAccount<'info>, + pub payer: UncheckedAccount<'info>, + pub update_authority: UncheckedAccount<'info>, + pub system_program: UncheckedAccount<'info>, + pub rent: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct CreateMetadataAccountsV3<'info> { - pub metadata: AccountInfo<'info>, - pub mint: AccountInfo<'info>, - pub mint_authority: AccountInfo<'info>, - pub payer: AccountInfo<'info>, - pub update_authority: AccountInfo<'info>, - pub system_program: AccountInfo<'info>, - pub rent: AccountInfo<'info>, + pub metadata: UncheckedAccount<'info>, + pub mint: UncheckedAccount<'info>, + pub mint_authority: UncheckedAccount<'info>, + pub payer: UncheckedAccount<'info>, + pub update_authority: UncheckedAccount<'info>, + pub system_program: UncheckedAccount<'info>, + pub rent: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct UpdateMetadataAccountsV2<'info> { - pub metadata: AccountInfo<'info>, - pub update_authority: AccountInfo<'info>, + pub metadata: UncheckedAccount<'info>, + pub update_authority: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct CreateMasterEditionV3<'info> { - pub edition: AccountInfo<'info>, - pub mint: AccountInfo<'info>, - pub update_authority: AccountInfo<'info>, - pub mint_authority: AccountInfo<'info>, - pub payer: AccountInfo<'info>, - pub metadata: AccountInfo<'info>, - pub token_program: AccountInfo<'info>, - pub system_program: AccountInfo<'info>, - pub rent: AccountInfo<'info>, + pub edition: UncheckedAccount<'info>, + pub mint: UncheckedAccount<'info>, + pub update_authority: UncheckedAccount<'info>, + pub mint_authority: UncheckedAccount<'info>, + pub payer: UncheckedAccount<'info>, + pub metadata: UncheckedAccount<'info>, + pub token_program: UncheckedAccount<'info>, + pub system_program: UncheckedAccount<'info>, + pub rent: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct MintNewEditionFromMasterEditionViaToken<'info> { - pub new_metadata: AccountInfo<'info>, - pub new_edition: AccountInfo<'info>, - pub master_edition: AccountInfo<'info>, - pub new_mint: AccountInfo<'info>, - pub edition_mark_pda: AccountInfo<'info>, - pub new_mint_authority: AccountInfo<'info>, - pub payer: AccountInfo<'info>, - pub token_account_owner: AccountInfo<'info>, - pub token_account: AccountInfo<'info>, - pub new_metadata_update_authority: AccountInfo<'info>, - pub metadata: AccountInfo<'info>, - pub token_program: AccountInfo<'info>, - pub system_program: AccountInfo<'info>, - pub rent: AccountInfo<'info>, + pub new_metadata: UncheckedAccount<'info>, + pub new_edition: UncheckedAccount<'info>, + pub master_edition: UncheckedAccount<'info>, + pub new_mint: UncheckedAccount<'info>, + pub edition_mark_pda: UncheckedAccount<'info>, + pub new_mint_authority: UncheckedAccount<'info>, + pub payer: UncheckedAccount<'info>, + pub token_account_owner: UncheckedAccount<'info>, + pub token_account: UncheckedAccount<'info>, + pub new_metadata_update_authority: UncheckedAccount<'info>, + pub metadata: UncheckedAccount<'info>, + pub token_program: UncheckedAccount<'info>, + pub system_program: UncheckedAccount<'info>, + pub rent: UncheckedAccount<'info>, // // Not actually used by the program but still needed because it's needed // for the pda calculation in the helper. :/ @@ -669,155 +664,140 @@ pub struct MintNewEditionFromMasterEditionViaToken<'info> { // The better thing to do would be to remove this and have the instruction // helper pass in the `edition_mark_pda` directly. // - pub metadata_mint: AccountInfo<'info>, + pub metadata_mint: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct RevokeCollectionAuthority<'info> { - pub collection_authority_record: AccountInfo<'info>, - pub delegate_authority: AccountInfo<'info>, - pub revoke_authority: AccountInfo<'info>, - pub metadata: AccountInfo<'info>, - pub mint: AccountInfo<'info>, + pub collection_authority_record: UncheckedAccount<'info>, + pub delegate_authority: UncheckedAccount<'info>, + pub revoke_authority: UncheckedAccount<'info>, + pub metadata: UncheckedAccount<'info>, + pub mint: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct SetCollectionSize<'info> { - pub metadata: AccountInfo<'info>, - pub mint: AccountInfo<'info>, - pub update_authority: AccountInfo<'info>, - pub system_program: AccountInfo<'info>, + pub metadata: UncheckedAccount<'info>, + pub mint: UncheckedAccount<'info>, + pub update_authority: UncheckedAccount<'info>, + pub system_program: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct SetTokenStandard<'info> { - pub metadata_account: AccountInfo<'info>, - pub update_authority: AccountInfo<'info>, - pub mint_account: AccountInfo<'info>, + pub metadata_account: UncheckedAccount<'info>, + pub update_authority: UncheckedAccount<'info>, + pub mint_account: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct VerifyCollection<'info> { - pub payer: AccountInfo<'info>, - pub metadata: AccountInfo<'info>, - pub collection_authority: AccountInfo<'info>, - pub collection_mint: AccountInfo<'info>, - pub collection_metadata: AccountInfo<'info>, - pub collection_master_edition: AccountInfo<'info>, + pub payer: UncheckedAccount<'info>, + pub metadata: UncheckedAccount<'info>, + pub collection_authority: UncheckedAccount<'info>, + pub collection_mint: UncheckedAccount<'info>, + pub collection_metadata: UncheckedAccount<'info>, + pub collection_master_edition: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct VerifySizedCollectionItem<'info> { - pub payer: AccountInfo<'info>, - pub metadata: AccountInfo<'info>, - pub collection_authority: AccountInfo<'info>, - pub collection_mint: AccountInfo<'info>, - pub collection_metadata: AccountInfo<'info>, - pub collection_master_edition: AccountInfo<'info>, + pub payer: UncheckedAccount<'info>, + pub metadata: UncheckedAccount<'info>, + pub collection_authority: UncheckedAccount<'info>, + pub collection_mint: UncheckedAccount<'info>, + pub collection_metadata: UncheckedAccount<'info>, + pub collection_master_edition: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct SetAndVerifyCollection<'info> { - pub metadata: AccountInfo<'info>, - pub collection_authority: AccountInfo<'info>, - pub payer: AccountInfo<'info>, - pub update_authority: AccountInfo<'info>, - pub collection_mint: AccountInfo<'info>, - pub collection_metadata: AccountInfo<'info>, - pub collection_master_edition: AccountInfo<'info>, + pub metadata: UncheckedAccount<'info>, + pub collection_authority: UncheckedAccount<'info>, + pub payer: UncheckedAccount<'info>, + pub update_authority: UncheckedAccount<'info>, + pub collection_mint: UncheckedAccount<'info>, + pub collection_metadata: UncheckedAccount<'info>, + pub collection_master_edition: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct SetAndVerifySizedCollectionItem<'info> { - pub metadata: AccountInfo<'info>, - pub collection_authority: AccountInfo<'info>, - pub payer: AccountInfo<'info>, - pub update_authority: AccountInfo<'info>, - pub collection_mint: AccountInfo<'info>, - pub collection_metadata: AccountInfo<'info>, - pub collection_master_edition: AccountInfo<'info>, + pub metadata: UncheckedAccount<'info>, + pub collection_authority: UncheckedAccount<'info>, + pub payer: UncheckedAccount<'info>, + pub update_authority: UncheckedAccount<'info>, + pub collection_mint: UncheckedAccount<'info>, + pub collection_metadata: UncheckedAccount<'info>, + pub collection_master_edition: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct FreezeDelegatedAccount<'info> { - pub metadata: AccountInfo<'info>, - pub delegate: AccountInfo<'info>, - pub token_account: AccountInfo<'info>, - pub edition: AccountInfo<'info>, - pub mint: AccountInfo<'info>, - pub token_program: AccountInfo<'info>, + pub metadata: UncheckedAccount<'info>, + pub delegate: UncheckedAccount<'info>, + pub token_account: UncheckedAccount<'info>, + pub edition: UncheckedAccount<'info>, + pub mint: UncheckedAccount<'info>, + pub token_program: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct ThawDelegatedAccount<'info> { - pub metadata: AccountInfo<'info>, - pub delegate: AccountInfo<'info>, - pub token_account: AccountInfo<'info>, - pub edition: AccountInfo<'info>, - pub mint: AccountInfo<'info>, - pub token_program: AccountInfo<'info>, + pub metadata: UncheckedAccount<'info>, + pub delegate: UncheckedAccount<'info>, + pub token_account: UncheckedAccount<'info>, + pub edition: UncheckedAccount<'info>, + pub mint: UncheckedAccount<'info>, + pub token_program: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct UpdatePrimarySaleHappenedViaToken<'info> { - pub metadata: AccountInfo<'info>, - pub owner: AccountInfo<'info>, - pub token: AccountInfo<'info>, + pub metadata: UncheckedAccount<'info>, + pub owner: UncheckedAccount<'info>, + pub token: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct SignMetadata<'info> { - pub creator: AccountInfo<'info>, - pub metadata: AccountInfo<'info>, + pub creator: UncheckedAccount<'info>, + pub metadata: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct RemoveCreatorVerification<'info> { - pub creator: AccountInfo<'info>, - pub metadata: AccountInfo<'info>, + pub creator: UncheckedAccount<'info>, + pub metadata: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct Utilize<'info> { - pub metadata: AccountInfo<'info>, - pub token_account: AccountInfo<'info>, - pub mint: AccountInfo<'info>, - pub use_authority: AccountInfo<'info>, - pub owner: AccountInfo<'info>, + pub metadata: UncheckedAccount<'info>, + pub token_account: UncheckedAccount<'info>, + pub mint: UncheckedAccount<'info>, + pub use_authority: UncheckedAccount<'info>, + pub owner: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct UnverifyCollection<'info> { - pub metadata: AccountInfo<'info>, - pub collection_authority: AccountInfo<'info>, - pub collection_mint: AccountInfo<'info>, - pub collection: AccountInfo<'info>, - pub collection_master_edition_account: AccountInfo<'info>, + pub metadata: UncheckedAccount<'info>, + pub collection_authority: UncheckedAccount<'info>, + pub collection_mint: UncheckedAccount<'info>, + pub collection: UncheckedAccount<'info>, + pub collection_master_edition_account: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct UnverifySizedCollectionItem<'info> { - pub metadata: AccountInfo<'info>, - pub collection_authority: AccountInfo<'info>, - pub payer: AccountInfo<'info>, - pub collection_mint: AccountInfo<'info>, - pub collection: AccountInfo<'info>, - pub collection_master_edition_account: AccountInfo<'info>, + pub metadata: UncheckedAccount<'info>, + pub collection_authority: UncheckedAccount<'info>, + pub payer: UncheckedAccount<'info>, + pub collection_mint: UncheckedAccount<'info>, + pub collection: UncheckedAccount<'info>, + pub collection_master_edition_account: UncheckedAccount<'info>, } #[derive(Clone, Debug, PartialEq)] diff --git a/spl/src/shmem.rs b/spl/src/shmem.rs index e3de56438a..311b5c9bfe 100644 --- a/spl/src/shmem.rs +++ b/spl/src/shmem.rs @@ -1,13 +1,13 @@ //! CPI API for interacting with the SPL shared memory //! [program](https://github.com/solana-labs/solana-program-library/tree/master/shared-memory). -use anchor_lang::ToAccountInfo; -use anchor_lang::{context::CpiContext, Accounts}; -use solana_program::account_info::AccountInfo; -use solana_program::declare_id; -use solana_program::entrypoint::ProgramResult; -use solana_program::instruction::{AccountMeta, Instruction}; +use anchor_lang::{context::CpiContext, prelude::UncheckedAccount, Accounts, ToAccountInfo}; use solana_program::program; +use solana_program::{ + declare_id, + entrypoint::ProgramResult, + instruction::{AccountMeta, Instruction}, +}; // TODO: update this once the final shared memory program gets released. // shmem4EWT2sPdVGvTZCzXXRAURL9G5vpPxNwSeKhHUL. @@ -28,25 +28,23 @@ pub fn ret<'a, 'b, 'c, 'info>( accounts: vec![AccountMeta::new(*ctx.accounts.buffer.key, false)], data, }; - let mut accounts = vec![ctx.accounts.buffer]; - accounts.push(ctx.program.clone()); + let mut accounts = vec![ctx.accounts.buffer.to_account_info()]; + accounts.push(ctx.program.to_account_info()); program::invoke(&instruction, &accounts) } #[derive(Accounts)] -#[only_cpi] pub struct Ret<'info> { #[account(mut)] - pub buffer: AccountInfo<'info>, + pub buffer: UncheckedAccount<'info>, } // A set of accounts that can be used with shared memory. #[derive(Accounts)] -#[only_cpi] pub struct Shmem<'info> { // Shared memory account to write the return value into. #[account(mut, constraint = shmem.owner == shmem_program.key)] - pub shmem: AccountInfo<'info>, + pub shmem: UncheckedAccount<'info>, #[account(constraint = shmem_program.key == &ID)] - pub shmem_program: AccountInfo<'info>, + pub shmem_program: UncheckedAccount<'info>, } diff --git a/spl/src/stake.rs b/spl/src/stake.rs index bfbb8de030..ad674a99c8 100644 --- a/spl/src/stake.rs +++ b/spl/src/stake.rs @@ -1,5 +1,6 @@ use anchor_lang::{ context::CpiContext, + prelude::UncheckedAccount, solana_program::{ account_info::AccountInfo, pubkey::Pubkey, @@ -9,7 +10,7 @@ use anchor_lang::{ state::{StakeAuthorize, StakeState}, }, }, - Accounts, Result, + Accounts, Result, ToAccountInfo, }; use borsh::BorshDeserialize; use std::ops::Deref; @@ -29,9 +30,9 @@ pub fn authorize<'info>( custodian.as_ref().map(|c| c.key), ); let mut account_infos = vec![ - ctx.accounts.stake, - ctx.accounts.clock, - ctx.accounts.authorized, + ctx.accounts.stake.to_account_info(), + ctx.accounts.clock.to_account_info(), + ctx.accounts.authorized.to_account_info(), ]; if let Some(c) = custodian { account_infos.push(c); @@ -53,11 +54,11 @@ pub fn withdraw<'info>( custodian.as_ref().map(|c| c.key), ); let mut account_infos = vec![ - ctx.accounts.stake, - ctx.accounts.to, - ctx.accounts.clock, - ctx.accounts.stake_history, - ctx.accounts.withdrawer, + ctx.accounts.stake.to_account_info(), + ctx.accounts.to.to_account_info(), + ctx.accounts.clock.to_account_info(), + ctx.accounts.stake_history.to_account_info(), + ctx.accounts.withdrawer.to_account_info(), ]; if let Some(c) = custodian { account_infos.push(c); @@ -72,7 +73,11 @@ pub fn deactivate_stake<'info>( let ix = stake::instruction::deactivate_stake(ctx.accounts.stake.key, ctx.accounts.staker.key); solana_program::program::invoke_signed( &ix, - &[ctx.accounts.stake, ctx.accounts.clock, ctx.accounts.staker], + &[ + ctx.accounts.stake.to_account_info(), + ctx.accounts.clock.to_account_info(), + ctx.accounts.staker.to_account_info(), + ], ctx.signer_seeds, ) .map_err(Into::into) @@ -81,51 +86,48 @@ pub fn deactivate_stake<'info>( // CPI accounts #[derive(Accounts)] -#[only_cpi] pub struct Authorize<'info> { /// The stake account to be updated - pub stake: AccountInfo<'info>, + pub stake: UncheckedAccount<'info>, /// The existing authority - pub authorized: AccountInfo<'info>, + pub authorized: UncheckedAccount<'info>, /// The new authority to replace the existing authority - pub new_authorized: AccountInfo<'info>, + pub new_authorized: UncheckedAccount<'info>, /// Clock sysvar - pub clock: AccountInfo<'info>, + pub clock: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct Withdraw<'info> { /// The stake account to be updated - pub stake: AccountInfo<'info>, + pub stake: UncheckedAccount<'info>, /// The stake account's withdraw authority - pub withdrawer: AccountInfo<'info>, + pub withdrawer: UncheckedAccount<'info>, /// Account to send withdrawn lamports to - pub to: AccountInfo<'info>, + pub to: UncheckedAccount<'info>, /// Clock sysvar - pub clock: AccountInfo<'info>, + pub clock: UncheckedAccount<'info>, /// StakeHistory sysvar - pub stake_history: AccountInfo<'info>, + pub stake_history: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct DeactivateStake<'info> { /// The stake account to be deactivated - pub stake: AccountInfo<'info>, + pub stake: UncheckedAccount<'info>, /// The stake account's stake authority - pub staker: AccountInfo<'info>, + pub staker: UncheckedAccount<'info>, /// Clock sysvar - pub clock: AccountInfo<'info>, + pub clock: UncheckedAccount<'info>, } // State diff --git a/spl/src/token.rs b/spl/src/token.rs index 44f2f64d05..127da5b7c0 100644 --- a/spl/src/token.rs +++ b/spl/src/token.rs @@ -1,9 +1,10 @@ +use anchor_lang::prelude::UncheckedAccount; use anchor_lang::solana_program::account_info::AccountInfo; use anchor_lang::solana_program::program_pack::Pack; use anchor_lang::solana_program::pubkey::Pubkey; use anchor_lang::{context::CpiContext, Accounts}; -use anchor_lang::{solana_program, Result}; +use anchor_lang::{solana_program, Result, ToAccountInfo}; use std::ops::Deref; pub use spl_token; @@ -23,7 +24,11 @@ pub fn transfer<'info>( )?; solana_program::program::invoke_signed( &ix, - &[ctx.accounts.from, ctx.accounts.to, ctx.accounts.authority], + &[ + ctx.accounts.from.to_account_info(), + ctx.accounts.to.to_account_info(), + ctx.accounts.authority.to_account_info(), + ], ctx.signer_seeds, ) .map_err(Into::into) @@ -47,10 +52,10 @@ pub fn transfer_checked<'info>( solana_program::program::invoke_signed( &ix, &[ - ctx.accounts.from, - ctx.accounts.mint, - ctx.accounts.to, - ctx.accounts.authority, + ctx.accounts.from.to_account_info(), + ctx.accounts.mint.to_account_info(), + ctx.accounts.to.to_account_info(), + ctx.accounts.authority.to_account_info(), ], ctx.signer_seeds, ) @@ -71,7 +76,11 @@ pub fn mint_to<'info>( )?; solana_program::program::invoke_signed( &ix, - &[ctx.accounts.to, ctx.accounts.mint, ctx.accounts.authority], + &[ + ctx.accounts.to.to_account_info(), + ctx.accounts.mint.to_account_info(), + ctx.accounts.authority.to_account_info(), + ], ctx.signer_seeds, ) .map_err(Into::into) @@ -88,7 +97,11 @@ pub fn burn<'info>(ctx: CpiContext<'_, '_, '_, 'info, Burn<'info>>, amount: u64) )?; solana_program::program::invoke_signed( &ix, - &[ctx.accounts.from, ctx.accounts.mint, ctx.accounts.authority], + &[ + ctx.accounts.from.to_account_info(), + ctx.accounts.mint.to_account_info(), + ctx.accounts.authority.to_account_info(), + ], ctx.signer_seeds, ) .map_err(Into::into) @@ -109,9 +122,9 @@ pub fn approve<'info>( solana_program::program::invoke_signed( &ix, &[ - ctx.accounts.to, - ctx.accounts.delegate, - ctx.accounts.authority, + ctx.accounts.to.to_account_info(), + ctx.accounts.delegate.to_account_info(), + ctx.accounts.authority.to_account_info(), ], ctx.signer_seeds, ) @@ -136,10 +149,10 @@ pub fn approve_checked<'info>( solana_program::program::invoke_signed( &ix, &[ - ctx.accounts.to, - ctx.accounts.mint, - ctx.accounts.delegate, - ctx.accounts.authority, + ctx.accounts.to.to_account_info(), + ctx.accounts.mint.to_account_info(), + ctx.accounts.delegate.to_account_info(), + ctx.accounts.authority.to_account_info(), ], ctx.signer_seeds, ) @@ -155,7 +168,10 @@ pub fn revoke<'info>(ctx: CpiContext<'_, '_, '_, 'info, Revoke<'info>>) -> Resul )?; solana_program::program::invoke_signed( &ix, - &[ctx.accounts.source, ctx.accounts.authority], + &[ + ctx.accounts.source.to_account_info(), + ctx.accounts.authority.to_account_info(), + ], ctx.signer_seeds, ) .map_err(Into::into) @@ -173,10 +189,10 @@ pub fn initialize_account<'info>( solana_program::program::invoke_signed( &ix, &[ - ctx.accounts.account, - ctx.accounts.mint, - ctx.accounts.authority, - ctx.accounts.rent, + ctx.accounts.account.to_account_info(), + ctx.accounts.mint.to_account_info(), + ctx.accounts.authority.to_account_info(), + ctx.accounts.rent.to_account_info(), ], ctx.signer_seeds, ) @@ -194,7 +210,10 @@ pub fn initialize_account3<'info>( )?; solana_program::program::invoke_signed( &ix, - &[ctx.accounts.account, ctx.accounts.mint], + &[ + ctx.accounts.account.to_account_info(), + ctx.accounts.mint.to_account_info(), + ], ctx.signer_seeds, ) .map_err(Into::into) @@ -211,9 +230,9 @@ pub fn close_account<'info>(ctx: CpiContext<'_, '_, '_, 'info, CloseAccount<'inf solana_program::program::invoke_signed( &ix, &[ - ctx.accounts.account, - ctx.accounts.destination, - ctx.accounts.authority, + ctx.accounts.account.to_account_info(), + ctx.accounts.destination.to_account_info(), + ctx.accounts.authority.to_account_info(), ], ctx.signer_seeds, ) @@ -233,9 +252,9 @@ pub fn freeze_account<'info>( solana_program::program::invoke_signed( &ix, &[ - ctx.accounts.account, - ctx.accounts.mint, - ctx.accounts.authority, + ctx.accounts.account.to_account_info(), + ctx.accounts.mint.to_account_info(), + ctx.accounts.authority.to_account_info(), ], ctx.signer_seeds, ) @@ -253,9 +272,9 @@ pub fn thaw_account<'info>(ctx: CpiContext<'_, '_, '_, 'info, ThawAccount<'info> solana_program::program::invoke_signed( &ix, &[ - ctx.accounts.account, - ctx.accounts.mint, - ctx.accounts.authority, + ctx.accounts.account.to_account_info(), + ctx.accounts.mint.to_account_info(), + ctx.accounts.authority.to_account_info(), ], ctx.signer_seeds, ) @@ -277,7 +296,10 @@ pub fn initialize_mint<'info>( )?; solana_program::program::invoke_signed( &ix, - &[ctx.accounts.mint, ctx.accounts.rent], + &[ + ctx.accounts.mint.to_account_info(), + ctx.accounts.rent.to_account_info(), + ], ctx.signer_seeds, ) .map_err(Into::into) @@ -296,8 +318,12 @@ pub fn initialize_mint2<'info>( freeze_authority, decimals, )?; - solana_program::program::invoke_signed(&ix, &[ctx.accounts.mint], ctx.signer_seeds) - .map_err(Into::into) + solana_program::program::invoke_signed( + &ix, + &[ctx.accounts.mint.to_account_info()], + ctx.signer_seeds, + ) + .map_err(Into::into) } pub fn set_authority<'info>( @@ -320,7 +346,10 @@ pub fn set_authority<'info>( )?; solana_program::program::invoke_signed( &ix, - &[ctx.accounts.account_or_mint, ctx.accounts.current_authority], + &[ + ctx.accounts.account_or_mint.to_account_info(), + ctx.accounts.current_authority.to_account_info(), + ], ctx.signer_seeds, ) .map_err(Into::into) @@ -328,132 +357,120 @@ pub fn set_authority<'info>( pub fn sync_native<'info>(ctx: CpiContext<'_, '_, '_, 'info, SyncNative<'info>>) -> Result<()> { let ix = spl_token::instruction::sync_native(&spl_token::ID, ctx.accounts.account.key)?; - solana_program::program::invoke_signed(&ix, &[ctx.accounts.account], ctx.signer_seeds) - .map_err(Into::into) + solana_program::program::invoke_signed( + &ix, + &[ctx.accounts.account.to_account_info()], + ctx.signer_seeds, + ) + .map_err(Into::into) } #[derive(Accounts)] -#[only_cpi] pub struct Transfer<'info> { - pub from: AccountInfo<'info>, - pub to: AccountInfo<'info>, - pub authority: AccountInfo<'info>, + pub from: UncheckedAccount<'info>, + pub to: UncheckedAccount<'info>, + pub authority: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct TransferChecked<'info> { - pub from: AccountInfo<'info>, - pub mint: AccountInfo<'info>, - pub to: AccountInfo<'info>, - pub authority: AccountInfo<'info>, + pub from: UncheckedAccount<'info>, + pub mint: UncheckedAccount<'info>, + pub to: UncheckedAccount<'info>, + pub authority: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct MintTo<'info> { - pub mint: AccountInfo<'info>, - pub to: AccountInfo<'info>, - pub authority: AccountInfo<'info>, + pub mint: UncheckedAccount<'info>, + pub to: UncheckedAccount<'info>, + pub authority: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct Burn<'info> { - pub mint: AccountInfo<'info>, - pub from: AccountInfo<'info>, - pub authority: AccountInfo<'info>, + pub mint: UncheckedAccount<'info>, + pub from: UncheckedAccount<'info>, + pub authority: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct Approve<'info> { - pub to: AccountInfo<'info>, - pub delegate: AccountInfo<'info>, - pub authority: AccountInfo<'info>, + pub to: UncheckedAccount<'info>, + pub delegate: UncheckedAccount<'info>, + pub authority: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct ApproveChecked<'info> { - pub to: AccountInfo<'info>, - pub mint: AccountInfo<'info>, - pub delegate: AccountInfo<'info>, - pub authority: AccountInfo<'info>, + pub to: UncheckedAccount<'info>, + pub mint: UncheckedAccount<'info>, + pub delegate: UncheckedAccount<'info>, + pub authority: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct Revoke<'info> { - pub source: AccountInfo<'info>, - pub authority: AccountInfo<'info>, + pub source: UncheckedAccount<'info>, + pub authority: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct InitializeAccount<'info> { - pub account: AccountInfo<'info>, - pub mint: AccountInfo<'info>, - pub authority: AccountInfo<'info>, - pub rent: AccountInfo<'info>, + pub account: UncheckedAccount<'info>, + pub mint: UncheckedAccount<'info>, + pub authority: UncheckedAccount<'info>, + pub rent: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct InitializeAccount3<'info> { - pub account: AccountInfo<'info>, - pub mint: AccountInfo<'info>, - pub authority: AccountInfo<'info>, + pub account: UncheckedAccount<'info>, + pub mint: UncheckedAccount<'info>, + pub authority: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct CloseAccount<'info> { - pub account: AccountInfo<'info>, - pub destination: AccountInfo<'info>, - pub authority: AccountInfo<'info>, + pub account: UncheckedAccount<'info>, + pub destination: UncheckedAccount<'info>, + pub authority: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct FreezeAccount<'info> { - pub account: AccountInfo<'info>, - pub mint: AccountInfo<'info>, - pub authority: AccountInfo<'info>, + pub account: UncheckedAccount<'info>, + pub mint: UncheckedAccount<'info>, + pub authority: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct ThawAccount<'info> { - pub account: AccountInfo<'info>, - pub mint: AccountInfo<'info>, - pub authority: AccountInfo<'info>, + pub account: UncheckedAccount<'info>, + pub mint: UncheckedAccount<'info>, + pub authority: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct InitializeMint<'info> { - pub mint: AccountInfo<'info>, - pub rent: AccountInfo<'info>, + pub mint: UncheckedAccount<'info>, + pub rent: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct InitializeMint2<'info> { - pub mint: AccountInfo<'info>, + pub mint: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct SetAuthority<'info> { - pub current_authority: AccountInfo<'info>, - pub account_or_mint: AccountInfo<'info>, + pub current_authority: UncheckedAccount<'info>, + pub account_or_mint: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct SyncNative<'info> { - pub account: AccountInfo<'info>, + pub account: UncheckedAccount<'info>, } #[derive(Clone, Debug, Default, PartialEq)] diff --git a/spl/src/token_2022.rs b/spl/src/token_2022.rs index f97c761b40..cf9133d2a1 100644 --- a/spl/src/token_2022.rs +++ b/spl/src/token_2022.rs @@ -1,8 +1,9 @@ -use anchor_lang::solana_program::account_info::AccountInfo; - -use anchor_lang::solana_program::pubkey::Pubkey; -use anchor_lang::{context::CpiContext, Accounts}; -use anchor_lang::{solana_program, Result}; +use anchor_lang::{ + context::CpiContext, + prelude::UncheckedAccount, + solana_program::{self, pubkey::Pubkey}, + Accounts, Result, ToAccountInfo, +}; pub use spl_token_2022; pub use spl_token_2022::ID; @@ -26,7 +27,11 @@ pub fn transfer<'info>( )?; solana_program::program::invoke_signed( &ix, - &[ctx.accounts.from, ctx.accounts.to, ctx.accounts.authority], + &[ + ctx.accounts.from.to_account_info(), + ctx.accounts.to.to_account_info(), + ctx.accounts.authority.to_account_info(), + ], ctx.signer_seeds, ) .map_err(Into::into) @@ -50,10 +55,10 @@ pub fn transfer_checked<'info>( solana_program::program::invoke_signed( &ix, &[ - ctx.accounts.from, - ctx.accounts.mint, - ctx.accounts.to, - ctx.accounts.authority, + ctx.accounts.from.to_account_info(), + ctx.accounts.mint.to_account_info(), + ctx.accounts.to.to_account_info(), + ctx.accounts.authority.to_account_info(), ], ctx.signer_seeds, ) @@ -74,7 +79,11 @@ pub fn mint_to<'info>( )?; solana_program::program::invoke_signed( &ix, - &[ctx.accounts.to, ctx.accounts.mint, ctx.accounts.authority], + &[ + ctx.accounts.to.to_account_info(), + ctx.accounts.mint.to_account_info(), + ctx.accounts.authority.to_account_info(), + ], ctx.signer_seeds, ) .map_err(Into::into) @@ -91,7 +100,11 @@ pub fn burn<'info>(ctx: CpiContext<'_, '_, '_, 'info, Burn<'info>>, amount: u64) )?; solana_program::program::invoke_signed( &ix, - &[ctx.accounts.from, ctx.accounts.mint, ctx.accounts.authority], + &[ + ctx.accounts.from.to_account_info(), + ctx.accounts.mint.to_account_info(), + ctx.accounts.authority.to_account_info(), + ], ctx.signer_seeds, ) .map_err(Into::into) @@ -112,9 +125,9 @@ pub fn approve<'info>( solana_program::program::invoke_signed( &ix, &[ - ctx.accounts.to, - ctx.accounts.delegate, - ctx.accounts.authority, + ctx.accounts.to.to_account_info(), + ctx.accounts.delegate.to_account_info(), + ctx.accounts.authority.to_account_info(), ], ctx.signer_seeds, ) @@ -130,7 +143,10 @@ pub fn revoke<'info>(ctx: CpiContext<'_, '_, '_, 'info, Revoke<'info>>) -> Resul )?; solana_program::program::invoke_signed( &ix, - &[ctx.accounts.source, ctx.accounts.authority], + &[ + ctx.accounts.source.to_account_info(), + ctx.accounts.authority.to_account_info(), + ], ctx.signer_seeds, ) .map_err(Into::into) @@ -148,10 +164,10 @@ pub fn initialize_account<'info>( solana_program::program::invoke( &ix, &[ - ctx.accounts.account, - ctx.accounts.mint, - ctx.accounts.authority, - ctx.accounts.rent, + ctx.accounts.account.to_account_info(), + ctx.accounts.mint.to_account_info(), + ctx.accounts.authority.to_account_info(), + ctx.accounts.rent.to_account_info(), ], ) .map_err(Into::into) @@ -166,8 +182,14 @@ pub fn initialize_account3<'info>( ctx.accounts.mint.key, ctx.accounts.authority.key, )?; - solana_program::program::invoke(&ix, &[ctx.accounts.account, ctx.accounts.mint]) - .map_err(Into::into) + solana_program::program::invoke( + &ix, + &[ + ctx.accounts.account.to_account_info(), + ctx.accounts.mint.to_account_info(), + ], + ) + .map_err(Into::into) } pub fn close_account<'info>(ctx: CpiContext<'_, '_, '_, 'info, CloseAccount<'info>>) -> Result<()> { @@ -181,9 +203,9 @@ pub fn close_account<'info>(ctx: CpiContext<'_, '_, '_, 'info, CloseAccount<'inf solana_program::program::invoke_signed( &ix, &[ - ctx.accounts.account, - ctx.accounts.destination, - ctx.accounts.authority, + ctx.accounts.account.to_account_info(), + ctx.accounts.destination.to_account_info(), + ctx.accounts.authority.to_account_info(), ], ctx.signer_seeds, ) @@ -203,9 +225,9 @@ pub fn freeze_account<'info>( solana_program::program::invoke_signed( &ix, &[ - ctx.accounts.account, - ctx.accounts.mint, - ctx.accounts.authority, + ctx.accounts.account.to_account_info(), + ctx.accounts.mint.to_account_info(), + ctx.accounts.authority.to_account_info(), ], ctx.signer_seeds, ) @@ -223,9 +245,9 @@ pub fn thaw_account<'info>(ctx: CpiContext<'_, '_, '_, 'info, ThawAccount<'info> solana_program::program::invoke_signed( &ix, &[ - ctx.accounts.account, - ctx.accounts.mint, - ctx.accounts.authority, + ctx.accounts.account.to_account_info(), + ctx.accounts.mint.to_account_info(), + ctx.accounts.authority.to_account_info(), ], ctx.signer_seeds, ) @@ -245,8 +267,14 @@ pub fn initialize_mint<'info>( freeze_authority, decimals, )?; - solana_program::program::invoke(&ix, &[ctx.accounts.mint, ctx.accounts.rent]) - .map_err(Into::into) + solana_program::program::invoke( + &ix, + &[ + ctx.accounts.mint.to_account_info(), + ctx.accounts.rent.to_account_info(), + ], + ) + .map_err(Into::into) } pub fn initialize_mint2<'info>( @@ -262,7 +290,7 @@ pub fn initialize_mint2<'info>( freeze_authority, decimals, )?; - solana_program::program::invoke(&ix, &[ctx.accounts.mint]).map_err(Into::into) + solana_program::program::invoke(&ix, &[ctx.accounts.mint.to_account_info()]).map_err(Into::into) } pub fn set_authority<'info>( @@ -285,7 +313,10 @@ pub fn set_authority<'info>( )?; solana_program::program::invoke_signed( &ix, - &[ctx.accounts.account_or_mint, ctx.accounts.current_authority], + &[ + ctx.accounts.account_or_mint.to_account_info(), + ctx.accounts.current_authority.to_account_info(), + ], ctx.signer_seeds, ) .map_err(Into::into) @@ -293,7 +324,8 @@ pub fn set_authority<'info>( pub fn sync_native<'info>(ctx: CpiContext<'_, '_, '_, 'info, SyncNative<'info>>) -> Result<()> { let ix = spl_token_2022::instruction::sync_native(ctx.program.key, ctx.accounts.account.key)?; - solana_program::program::invoke(&ix, &[ctx.accounts.account]).map_err(Into::into) + solana_program::program::invoke(&ix, &[ctx.accounts.account.to_account_info()]) + .map_err(Into::into) } pub fn get_account_data_size<'info>( @@ -305,7 +337,7 @@ pub fn get_account_data_size<'info>( ctx.accounts.mint.key, extension_types, )?; - solana_program::program::invoke(&ix, &[ctx.accounts.mint])?; + solana_program::program::invoke(&ix, &[ctx.accounts.mint.to_account_info()])?; solana_program::program::get_return_data() .ok_or(solana_program::program_error::ProgramError::InvalidInstructionData) .and_then(|(key, data)| { @@ -329,7 +361,7 @@ pub fn initialize_mint_close_authority<'info>( ctx.accounts.mint.key, close_authority, )?; - solana_program::program::invoke(&ix, &[ctx.accounts.mint]).map_err(Into::into) + solana_program::program::invoke(&ix, &[ctx.accounts.mint.to_account_info()]).map_err(Into::into) } pub fn initialize_immutable_owner<'info>( @@ -339,7 +371,8 @@ pub fn initialize_immutable_owner<'info>( ctx.program.key, ctx.accounts.account.key, )?; - solana_program::program::invoke(&ix, &[ctx.accounts.account]).map_err(Into::into) + solana_program::program::invoke(&ix, &[ctx.accounts.account.to_account_info()]) + .map_err(Into::into) } pub fn amount_to_ui_amount<'info>( @@ -351,7 +384,7 @@ pub fn amount_to_ui_amount<'info>( ctx.accounts.account.key, amount, )?; - solana_program::program::invoke(&ix, &[ctx.accounts.account])?; + solana_program::program::invoke(&ix, &[ctx.accounts.account.to_account_info()])?; solana_program::program::get_return_data() .ok_or(solana_program::program_error::ProgramError::InvalidInstructionData) .and_then(|(key, data)| { @@ -375,7 +408,7 @@ pub fn ui_amount_to_amount<'info>( ctx.accounts.account.key, ui_amount, )?; - solana_program::program::invoke(&ix, &[ctx.accounts.account])?; + solana_program::program::invoke(&ix, &[ctx.accounts.account.to_account_info()])?; solana_program::program::get_return_data() .ok_or(solana_program::program_error::ProgramError::InvalidInstructionData) .and_then(|(key, data)| { @@ -391,148 +424,128 @@ pub fn ui_amount_to_amount<'info>( } #[derive(Accounts)] -#[only_cpi] pub struct Transfer<'info> { - pub from: AccountInfo<'info>, - pub to: AccountInfo<'info>, - pub authority: AccountInfo<'info>, + pub from: UncheckedAccount<'info>, + pub to: UncheckedAccount<'info>, + pub authority: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct TransferChecked<'info> { - pub from: AccountInfo<'info>, - pub mint: AccountInfo<'info>, - pub to: AccountInfo<'info>, - pub authority: AccountInfo<'info>, + pub from: UncheckedAccount<'info>, + pub mint: UncheckedAccount<'info>, + pub to: UncheckedAccount<'info>, + pub authority: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct MintTo<'info> { - pub mint: AccountInfo<'info>, - pub to: AccountInfo<'info>, - pub authority: AccountInfo<'info>, + pub mint: UncheckedAccount<'info>, + pub to: UncheckedAccount<'info>, + pub authority: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct Burn<'info> { - pub mint: AccountInfo<'info>, - pub from: AccountInfo<'info>, - pub authority: AccountInfo<'info>, + pub mint: UncheckedAccount<'info>, + pub from: UncheckedAccount<'info>, + pub authority: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct Approve<'info> { - pub to: AccountInfo<'info>, - pub delegate: AccountInfo<'info>, - pub authority: AccountInfo<'info>, + pub to: UncheckedAccount<'info>, + pub delegate: UncheckedAccount<'info>, + pub authority: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct Revoke<'info> { - pub source: AccountInfo<'info>, - pub authority: AccountInfo<'info>, + pub source: UncheckedAccount<'info>, + pub authority: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct InitializeAccount<'info> { - pub account: AccountInfo<'info>, - pub mint: AccountInfo<'info>, - pub authority: AccountInfo<'info>, - pub rent: AccountInfo<'info>, + pub account: UncheckedAccount<'info>, + pub mint: UncheckedAccount<'info>, + pub authority: UncheckedAccount<'info>, + pub rent: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct InitializeAccount3<'info> { - pub account: AccountInfo<'info>, - pub mint: AccountInfo<'info>, - pub authority: AccountInfo<'info>, + pub account: UncheckedAccount<'info>, + pub mint: UncheckedAccount<'info>, + pub authority: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct CloseAccount<'info> { - pub account: AccountInfo<'info>, - pub destination: AccountInfo<'info>, - pub authority: AccountInfo<'info>, + pub account: UncheckedAccount<'info>, + pub destination: UncheckedAccount<'info>, + pub authority: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct FreezeAccount<'info> { - pub account: AccountInfo<'info>, - pub mint: AccountInfo<'info>, - pub authority: AccountInfo<'info>, + pub account: UncheckedAccount<'info>, + pub mint: UncheckedAccount<'info>, + pub authority: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct ThawAccount<'info> { - pub account: AccountInfo<'info>, - pub mint: AccountInfo<'info>, - pub authority: AccountInfo<'info>, + pub account: UncheckedAccount<'info>, + pub mint: UncheckedAccount<'info>, + pub authority: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct InitializeMint<'info> { - pub mint: AccountInfo<'info>, - pub rent: AccountInfo<'info>, + pub mint: UncheckedAccount<'info>, + pub rent: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct InitializeMint2<'info> { - pub mint: AccountInfo<'info>, + pub mint: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct SetAuthority<'info> { - pub current_authority: AccountInfo<'info>, - pub account_or_mint: AccountInfo<'info>, + pub current_authority: UncheckedAccount<'info>, + pub account_or_mint: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct SyncNative<'info> { - pub account: AccountInfo<'info>, + pub account: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct GetAccountDataSize<'info> { - pub mint: AccountInfo<'info>, + pub mint: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct InitializeMintCloseAuthority<'info> { - pub mint: AccountInfo<'info>, + pub mint: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct InitializeImmutableOwner<'info> { - pub account: AccountInfo<'info>, + pub account: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct AmountToUiAmount<'info> { - pub account: AccountInfo<'info>, + pub account: UncheckedAccount<'info>, } #[derive(Accounts)] -#[only_cpi] pub struct UiAmountToAmount<'info> { - pub account: AccountInfo<'info>, + pub account: UncheckedAccount<'info>, } #[derive(Clone)] diff --git a/tests/cpi-returns/programs/caller/src/lib.rs b/tests/cpi-returns/programs/caller/src/lib.rs index ff093e971e..30715746f7 100644 --- a/tests/cpi-returns/programs/caller/src/lib.rs +++ b/tests/cpi-returns/programs/caller/src/lib.rs @@ -18,7 +18,7 @@ pub mod caller { pub fn cpi_call_return_u64(ctx: Context) -> Result<()> { let cpi_program = ctx.accounts.cpi_return_program.to_account_info(); let cpi_accounts = CpiReturn { - account: ctx.accounts.cpi_return.to_account_info(), + account: ctx.accounts.cpi_return.clone().into(), }; let cpi_ctx = CpiContext::new(cpi_program, cpi_accounts); let result = callee::cpi::return_u64(cpi_ctx)?; @@ -30,7 +30,7 @@ pub mod caller { pub fn cpi_call_return_struct(ctx: Context) -> Result<()> { let cpi_program = ctx.accounts.cpi_return_program.to_account_info(); let cpi_accounts = CpiReturn { - account: ctx.accounts.cpi_return.to_account_info(), + account: ctx.accounts.cpi_return.clone().into(), }; let cpi_ctx = CpiContext::new(cpi_program, cpi_accounts); let result = callee::cpi::return_struct(cpi_ctx)?; @@ -42,7 +42,7 @@ pub mod caller { pub fn cpi_call_return_vec(ctx: Context) -> Result<()> { let cpi_program = ctx.accounts.cpi_return_program.to_account_info(); let cpi_accounts = CpiReturn { - account: ctx.accounts.cpi_return.to_account_info(), + account: ctx.accounts.cpi_return.clone().into(), }; let cpi_ctx = CpiContext::new(cpi_program, cpi_accounts); let result = callee::cpi::return_vec(cpi_ctx)?; diff --git a/tests/spl/token-proxy/programs/token-proxy/src/lib.rs b/tests/spl/token-proxy/programs/token-proxy/src/lib.rs index 264fd61a70..dd88842c5a 100644 --- a/tests/spl/token-proxy/programs/token-proxy/src/lib.rs +++ b/tests/spl/token-proxy/programs/token-proxy/src/lib.rs @@ -21,19 +21,19 @@ mod token_proxy { if let Some(token_program) = &ctx.accounts.token_program { if let Some(mint) = &ctx.accounts.mint { let cpi_accounts = TransferChecked { - from: ctx.accounts.from.to_account_info(), - mint: mint.to_account_info(), - to: ctx.accounts.to.to_account_info(), - authority: ctx.accounts.authority.to_account_info(), + from: ctx.accounts.from.clone().into(), + mint: mint.clone().into(), + to: ctx.accounts.to.clone().into(), + authority: ctx.accounts.authority.clone().into(), }; let cpi_program = token_program.to_account_info(); let cpi_context = CpiContext::new(cpi_program, cpi_accounts); token_interface::transfer_checked(cpi_context, amount, mint.decimals) } else { let cpi_accounts = Transfer { - from: ctx.accounts.from.to_account_info(), - to: ctx.accounts.to.to_account_info(), - authority: ctx.accounts.authority.to_account_info(), + from: ctx.accounts.from.clone().into(), + to: ctx.accounts.to.clone().into(), + authority: ctx.accounts.authority.clone().into(), }; let cpi_program = token_program.to_account_info(); let cpi_context = CpiContext::new(cpi_program, cpi_accounts); @@ -204,9 +204,9 @@ impl<'a, 'b, 'c, 'info> From<&mut ProxyTransfer<'info>> { fn from(accounts: &mut ProxyTransfer<'info>) -> CpiContext<'a, 'b, 'c, 'info, Transfer<'info>> { let cpi_accounts = Transfer { - from: accounts.from.to_account_info(), - to: accounts.to.to_account_info(), - authority: accounts.authority.to_account_info(), + from: accounts.from.clone().into(), + to: accounts.to.clone().into(), + authority: accounts.authority.clone().into(), }; let cpi_program = accounts.token_program.to_account_info(); CpiContext::new(cpi_program, cpi_accounts) @@ -218,9 +218,9 @@ impl<'a, 'b, 'c, 'info> From<&mut ProxyMintTo<'info>> { fn from(accounts: &mut ProxyMintTo<'info>) -> CpiContext<'a, 'b, 'c, 'info, MintTo<'info>> { let cpi_accounts = MintTo { - mint: accounts.mint.to_account_info(), - to: accounts.to.to_account_info(), - authority: accounts.authority.to_account_info(), + mint: accounts.mint.clone().into(), + to: accounts.to.clone().into(), + authority: accounts.authority.clone().into(), }; let cpi_program = accounts.token_program.to_account_info(); CpiContext::new(cpi_program, cpi_accounts) @@ -230,9 +230,9 @@ impl<'a, 'b, 'c, 'info> From<&mut ProxyMintTo<'info>> impl<'a, 'b, 'c, 'info> From<&mut ProxyBurn<'info>> for CpiContext<'a, 'b, 'c, 'info, Burn<'info>> { fn from(accounts: &mut ProxyBurn<'info>) -> CpiContext<'a, 'b, 'c, 'info, Burn<'info>> { let cpi_accounts = Burn { - mint: accounts.mint.to_account_info(), - from: accounts.from.to_account_info(), - authority: accounts.authority.to_account_info(), + mint: accounts.mint.clone().into(), + from: accounts.from.clone().into(), + authority: accounts.authority.clone().into(), }; let cpi_program = accounts.token_program.to_account_info(); CpiContext::new(cpi_program, cpi_accounts) @@ -246,8 +246,8 @@ impl<'a, 'b, 'c, 'info> From<&mut ProxySetAuthority<'info>> accounts: &mut ProxySetAuthority<'info>, ) -> CpiContext<'a, 'b, 'c, 'info, SetAuthority<'info>> { let cpi_accounts = SetAuthority { - account_or_mint: accounts.account_or_mint.to_account_info(), - current_authority: accounts.current_authority.to_account_info(), + account_or_mint: accounts.account_or_mint.clone().into(), + current_authority: accounts.current_authority.clone().into(), }; // TODO: Support multisig signers let cpi_program = accounts.token_program.to_account_info(); CpiContext::new(cpi_program, cpi_accounts) diff --git a/tests/spl/token-wrapper/programs/token-wrapper/src/lib.rs b/tests/spl/token-wrapper/programs/token-wrapper/src/lib.rs index b8a38727d8..fad1f5a42f 100644 --- a/tests/spl/token-wrapper/programs/token-wrapper/src/lib.rs +++ b/tests/spl/token-wrapper/programs/token-wrapper/src/lib.rs @@ -31,10 +31,11 @@ pub mod token_wrapper { from: ctx .accounts .initializer_deposit_token_account - .to_account_info(), - mint: ctx.accounts.deposit_mint.to_account_info(), - to: ctx.accounts.deposit_token_vault.to_account_info(), - authority: ctx.accounts.initializer.to_account_info(), + .clone() + .into(), + mint: ctx.accounts.deposit_mint.clone().into(), + to: ctx.accounts.deposit_token_vault.clone().into(), + authority: ctx.accounts.initializer.clone().into(), }, ), initializer_amount, @@ -53,12 +54,13 @@ pub mod token_wrapper { CpiContext::new_with_signer( ctx.accounts.wrapped_token_program.to_account_info(), token_interface::MintTo { - mint: ctx.accounts.wrapped_mint.to_account_info(), + mint: ctx.accounts.wrapped_mint.clone().into(), to: ctx .accounts .initializer_wrapped_token_account - .to_account_info(), - authority: ctx.accounts.wrapper_authority.to_account_info(), + .clone() + .into(), + authority: ctx.accounts.wrapper_authority.clone().into(), }, signer_seeds, ), @@ -74,10 +76,10 @@ pub mod token_wrapper { CpiContext::new( ctx.accounts.deposit_token_program.to_account_info(), token_interface::TransferChecked { - from: ctx.accounts.user_deposit_token_account.to_account_info(), - mint: ctx.accounts.deposit_mint.to_account_info(), - to: ctx.accounts.deposit_token_vault.to_account_info(), - authority: ctx.accounts.signer.to_account_info(), + from: ctx.accounts.user_deposit_token_account.clone().into(), + mint: ctx.accounts.deposit_mint.clone().into(), + to: ctx.accounts.deposit_token_vault.clone().into(), + authority: ctx.accounts.signer.clone().into(), }, ), wrap_amount, @@ -96,9 +98,9 @@ pub mod token_wrapper { CpiContext::new_with_signer( ctx.accounts.wrapped_token_program.to_account_info(), token_interface::MintTo { - mint: ctx.accounts.wrapped_mint.to_account_info(), - to: ctx.accounts.user_wrapped_token_account.to_account_info(), - authority: ctx.accounts.wrapper_authority.to_account_info(), + mint: ctx.accounts.wrapped_mint.clone().into(), + to: ctx.accounts.user_wrapped_token_account.clone().into(), + authority: ctx.accounts.wrapper_authority.clone().into(), }, signer_seeds, ), @@ -114,9 +116,9 @@ pub mod token_wrapper { CpiContext::new( ctx.accounts.wrapped_token_program.to_account_info(), token_interface::Burn { - mint: ctx.accounts.wrapped_mint.to_account_info(), - from: ctx.accounts.user_wrapped_token_account.to_account_info(), - authority: ctx.accounts.signer.to_account_info(), + mint: ctx.accounts.wrapped_mint.clone().into(), + from: ctx.accounts.user_wrapped_token_account.clone().into(), + authority: ctx.accounts.signer.clone().into(), }, ), unwrap_amount, @@ -134,10 +136,10 @@ pub mod token_wrapper { CpiContext::new_with_signer( ctx.accounts.deposit_token_program.to_account_info(), token_interface::TransferChecked { - from: ctx.accounts.deposit_token_vault.to_account_info(), - mint: ctx.accounts.deposit_mint.to_account_info(), - to: ctx.accounts.user_deposit_token_account.to_account_info(), - authority: ctx.accounts.wrapper_authority.to_account_info(), + from: ctx.accounts.deposit_token_vault.clone().into(), + mint: ctx.accounts.deposit_mint.clone().into(), + to: ctx.accounts.user_deposit_token_account.clone().into(), + authority: ctx.accounts.wrapper_authority.clone().into(), }, signer_seeds, ), From 5281720afab8d7a39eab649d2c938d00de00dabf Mon Sep 17 00:00:00 2001 From: Jean Marchand Date: Fri, 5 May 2023 10:09:18 +0200 Subject: [PATCH 06/11] Squashed commit of the following: commit ac86e15756b8bde5d15fde5ebe0f46f47bcb5049 Author: Matthew Callens Date: Wed May 3 17:53:46 2023 -0500 spl: remove mpl `create_metadata_account_v2` wrapper that were removed from program (#2480) * remove mpl ix wrappers that were removed from program * update changelog commit c1667120e6d44d4a9a2ed4d49f20443ca99ce41e Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Wed May 3 09:09:41 2023 +0200 bench: Add a script to sync benchmark results for all versions (#2477) commit a195106117ebaa6ab97e8963b7f1d66225eee4bc Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Mon May 1 13:39:50 2023 +0200 spl: Use fixed version for `winnow` crate to fix new builds (#2478) commit 03b1e4df6b3b70895b3ce29118f8b3c7c483ce12 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Thu Apr 27 12:10:23 2023 +0200 Upgrade `clap` to 4.2.4 (#2474) commit 876ef416107355b4ac4c0a31b8048c471ae09675 Author: Proph3t Date: Thu Apr 27 08:53:04 2023 +0000 docs: fix broken links in `AccountLoader` docs (#2473) commit c14ae6b4f8ac284c155cb146436c6de6e59c4603 Author: Tuan Pham Minh Date: Wed Apr 26 00:07:39 2023 +0700 Fix typo of `is_signer` field in intro-to-solana docs page (#2469) --- CHANGELOG.md | 1 + Cargo.lock | 455 +++++++++++------- avm/Cargo.lock | 338 +++++++++---- avm/Cargo.toml | 6 +- cli/Cargo.toml | 2 +- client/example/Cargo.toml | 2 +- docs/src/pages/docs/intro-to-solana.md | 2 +- lang/src/accounts/account_loader.rs | 4 +- spl/Cargo.toml | 7 +- spl/src/metadata.rs | 59 +-- tests/bench/Anchor.toml | 7 +- tests/bench/README.md | 14 +- tests/bench/programs/bench/Cargo.toml | 5 + tests/bench/programs/bench/src/lib.rs | 4 +- .../{update-bench.ts => sync-markdown.ts} | 28 +- tests/bench/scripts/sync.ts | 66 +++ tests/bench/scripts/utils.ts | 140 +++++- tests/bench/tests/compute-units.ts | 20 +- 18 files changed, 787 insertions(+), 373 deletions(-) rename tests/bench/scripts/{update-bench.ts => sync-markdown.ts} (68%) create mode 100644 tests/bench/scripts/sync.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 74220ebece..9817b2d820 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ The minor version will be incremented upon a breaking change and the patch versi - lang: Remove the use of `AccountInfo` in the context of the accounts. Use `UncheckedAccount` instead ([#2470](https://github.com/coral-xyz/anchor/pull/2470)). - lang: Identifiers that are intended for internal usage(`program_id`, `accounts`, `ix_data`, `remaining_accounts`) have been renamed with `__` prefix ([#2464](https://github.com/coral-xyz/anchor/pull/2464)) +- spl: Remove the `metadata::create_metadata_account_v2` deprecated wrapper since it was removed from token metadata program ([#2480](https://github.com/coral-xyz/anchor/pull/2480)) ## [0.27.0] - 2023-03-08 diff --git a/Cargo.lock b/Cargo.lock index a8fb158eb4..a56e49d6c6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -101,8 +101,8 @@ version = "0.27.0" dependencies = [ "anchor-syn", "anyhow", - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "regex", "syn 1.0.109", ] @@ -114,8 +114,8 @@ dependencies = [ "anchor-syn", "anyhow", "bs58 0.4.0", - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "rustversion", "syn 1.0.109", ] @@ -125,7 +125,7 @@ name = "anchor-attribute-constant" version = "0.27.0" dependencies = [ "anchor-syn", - "proc-macro2 1.0.47", + "proc-macro2 1.0.56", "syn 1.0.109", ] @@ -134,8 +134,8 @@ name = "anchor-attribute-error" version = "0.27.0" dependencies = [ "anchor-syn", - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", ] @@ -145,8 +145,8 @@ version = "0.27.0" dependencies = [ "anchor-syn", "anyhow", - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", ] @@ -156,8 +156,8 @@ version = "0.27.0" dependencies = [ "anchor-syn", "anyhow", - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", ] @@ -171,7 +171,7 @@ dependencies = [ "anyhow", "cargo_toml", "chrono", - "clap 4.0.26", + "clap 4.2.4", "dirs", "flate2", "heck 0.4.0", @@ -216,8 +216,8 @@ version = "0.27.0" dependencies = [ "anchor-syn", "anyhow", - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", ] @@ -225,8 +225,8 @@ dependencies = [ name = "anchor-derive-space" version = "0.27.0" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", ] @@ -263,6 +263,7 @@ dependencies = [ "spl-associated-token-account", "spl-token", "spl-token-2022", + "winnow", ] [[package]] @@ -272,8 +273,8 @@ dependencies = [ "anyhow", "bs58 0.3.1", "heck 0.3.3", - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "serde", "serde_json", "sha2 0.9.9", @@ -299,6 +300,55 @@ dependencies = [ "winapi", ] +[[package]] +name = "anstream" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6342bd4f5a1205d7f41e94a41a901f5647c938cdfa96036338e8533c9d6c2450" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is-terminal", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" + +[[package]] +name = "anstyle-parse" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "anstyle-wincon" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +dependencies = [ + "anstyle", + "windows-sys 0.48.0", +] + [[package]] name = "anyhow" version = "1.0.66" @@ -354,7 +404,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db02d390bf6643fb404d3d22d31aee1c4bc4459600aef9113833d17e786c6e44" dependencies = [ - "quote 1.0.21", + "quote 1.0.26", "syn 1.0.109", ] @@ -366,7 +416,7 @@ checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20" dependencies = [ "num-bigint 0.4.3", "num-traits", - "quote 1.0.21", + "quote 1.0.26", "syn 1.0.109", ] @@ -445,8 +495,8 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "726535892e8eae7e70657b4c8ea93d26b8553afb1ce617caee529ef96d7dee6c" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", "synstructure", ] @@ -457,8 +507,8 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2777730b2039ac0f95f093556e61b6d26cebed5393ca6f152717777cec3a42ed" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", ] @@ -497,8 +547,8 @@ version = "0.1.58" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e805d94e6b5001b651426cf4cd446b1ab5f319d27bab5c644f61de0a804360c" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", ] @@ -634,7 +684,7 @@ dependencies = [ "borsh-derive-internal", "borsh-schema-derive-internal", "proc-macro-crate 0.1.5", - "proc-macro2 1.0.47", + "proc-macro2 1.0.56", "syn 1.0.109", ] @@ -644,8 +694,8 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5449c28a7b352f2d1e592a8a28bf139bc71afb0764a14f3c02500935d8c44065" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", ] @@ -655,8 +705,8 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdbd5696d8bfa21d53d9fe39a714a18538bad11492a42d066dbbc395fb1951c0" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", ] @@ -724,8 +774,8 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9e1f5fa78f69496407a27ae9ed989e3c3b072310286f5ef385525e4cbc24a9" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", ] @@ -844,30 +894,38 @@ dependencies = [ [[package]] name = "clap" -version = "4.0.26" +version = "4.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2148adefda54e14492fb9bddcc600b4344c5d1a3123bd666dcb939c6f0e0e57e" +checksum = "956ac1f6381d8d82ab4684768f89c0ea3afe66925ceadb4eeb3fc452ffc55d62" dependencies = [ - "atty", - "bitflags", + "clap_builder", "clap_derive", - "clap_lex 0.3.0", "once_cell", +] + +[[package]] +name = "clap_builder" +version = "4.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84080e799e54cff944f4b4a4b0e71630b0e0443b25b985175c7dddc1a859b749" +dependencies = [ + "anstream", + "anstyle", + "bitflags", + "clap_lex 0.4.1", "strsim 0.10.0", - "termcolor", ] [[package]] name = "clap_derive" -version = "4.0.21" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0177313f9f02afc995627906bbd8967e2be069f5261954222dac78290c2b9014" +checksum = "3f9644cd56d6b87dbe899ef8b053e331c0637664e9e21a33dfcdc36093f5c5c4" dependencies = [ "heck 0.4.0", - "proc-macro-error", - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.109", + "proc-macro2 1.0.56", + "quote 1.0.26", + "syn 2.0.15", ] [[package]] @@ -881,12 +939,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.3.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8" -dependencies = [ - "os_str_bytes", -] +checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" [[package]] name = "codespan-reporting" @@ -898,6 +953,12 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "combine" version = "3.8.1" @@ -1104,8 +1165,8 @@ dependencies = [ "cc", "codespan-reporting", "once_cell", - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "scratch", "syn 1.0.109", ] @@ -1122,8 +1183,8 @@ version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "309e4fb93eed90e1e14bea0da16b209f81813ba9fc7830c20ed151dd7bc0a4d7" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", ] @@ -1145,8 +1206,8 @@ checksum = "001d80444f28e193f30c2f293455da62dcf9a6b29918a4253152ae2b1de592cb" dependencies = [ "fnv", "ident_case", - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "strsim 0.10.0", "syn 1.0.109", ] @@ -1158,7 +1219,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b36230598a2d5de7ec1c6f51f72d8a99a9208daff41de2084d06e3fd3ea56685" dependencies = [ "darling_core", - "quote 1.0.21", + "quote 1.0.26", "syn 1.0.109", ] @@ -1203,8 +1264,8 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", ] @@ -1292,8 +1353,8 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3bf95dc3f046b9da4f2d51833c0d3547d8564ef6910f5c1ed130306a75b92886" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", ] @@ -1406,8 +1467,8 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "355f93763ef7b0ae1c43c4d8eccc9d5848d84ad1a1d8ce61c421d1ac85a19d05" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", ] @@ -1418,8 +1479,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eb359f1476bf611266ac1f5355bc14aeca37b299d0ebccc038ee7058891c9cb" dependencies = [ "once_cell", - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", ] @@ -1438,8 +1499,8 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "946ee94e3dbf58fdd324f9ce245c7b238d46a66f00e86a020b71996349e46cce" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", ] @@ -1458,13 +1519,13 @@ dependencies = [ [[package]] name = "errno" -version = "0.2.8" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" dependencies = [ "errno-dragonfly", "libc", - "winapi", + "windows-sys 0.48.0", ] [[package]] @@ -1605,8 +1666,8 @@ version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", ] @@ -1770,12 +1831,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.2.6" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -dependencies = [ - "libc", -] +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" [[package]] name = "histogram" @@ -1988,12 +2046,13 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "1.0.4" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7d6c6f8c91b4b9ed43484ad1a938e393caf35960fce7f82a040497207bd8e9e" +checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" dependencies = [ + "hermit-abi 0.3.1", "libc", - "windows-sys 0.42.0", + "windows-sys 0.48.0", ] [[package]] @@ -2004,14 +2063,14 @@ checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b" [[package]] name = "is-terminal" -version = "0.4.2" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189" +checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" dependencies = [ - "hermit-abi 0.2.6", + "hermit-abi 0.3.1", "io-lifetimes", "rustix", - "windows-sys 0.42.0", + "windows-sys 0.48.0", ] [[package]] @@ -2117,9 +2176,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.137" +version = "0.2.142" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" +checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" [[package]] name = "libloading" @@ -2190,9 +2249,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.1.4" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" +checksum = "36eb31c1778188ae1e64398743890d0877fef36d11521ac60406b42016e8c2cf" [[package]] name = "lock_api" @@ -2321,9 +2380,9 @@ dependencies = [ [[package]] name = "mpl-token-metadata" -version = "1.9.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8831a402e72f24052d019a83d72b70c38673caaf198e6e345575a77f98166b1" +checksum = "aed414104154928aa995a44a0a474c449d04ce5a4ee6c975ad41c5d2912f0dfe" dependencies = [ "arrayref", "borsh", @@ -2345,15 +2404,15 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12989bc45715b0ee91944855130131479f9c772e198a910c3eb0ea327d5bffc3" dependencies = [ - "quote 1.0.21", + "quote 1.0.26", "syn 1.0.109", ] [[package]] name = "mpl-utils" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fc48e64c50dba956acb46eec86d6968ef0401ef37031426da479f1f2b592066" +checksum = "822133b6cba8f9a43e5e0e189813be63dd795858f54155c729833be472ffdb51" dependencies = [ "arrayref", "borsh", @@ -2443,8 +2502,8 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", ] @@ -2516,8 +2575,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b0498641e53dd6ac1a4f22547548caa6864cc4933784319cd1775271c5a46ce" dependencies = [ "proc-macro-crate 1.2.1", - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", ] @@ -2694,8 +2753,8 @@ checksum = "92aacdc5f16768709a569e913f7451034034178b05bdc8acda226659a3dccc66" dependencies = [ "phf_generator", "phf_shared 0.11.1", - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", ] @@ -2811,30 +2870,6 @@ dependencies = [ "toml", ] -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", - "version_check", -] - [[package]] name = "proc-macro2" version = "0.4.30" @@ -2846,9 +2881,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.47" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" dependencies = [ "unicode-ident", ] @@ -2923,11 +2958,11 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.21" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" dependencies = [ - "proc-macro2 1.0.47", + "proc-macro2 1.0.56", ] [[package]] @@ -3233,16 +3268,16 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.7" +version = "0.37.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fdebc4b395b7fbb9ab11e462e20ed9051e7b16e42d24042c776eca0ac81b03" +checksum = "a0661814f891c57c930a610266415528da53c4933e6dea5fb350cbfe048a9ece" dependencies = [ "bitflags", "errno", "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys 0.42.0", + "windows-sys 0.48.0", ] [[package]] @@ -3342,8 +3377,8 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bdbda6ac5cd1321e724fa9cee216f3a61885889b896f073b8f82322789c5250e" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", ] @@ -3428,8 +3463,8 @@ version = "1.0.154" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fc80d722935453bcafdc2c9a73cd6fac4dc1938f0346035d84bf99fa9e33217" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", ] @@ -3473,8 +3508,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1966009f3c05f095697c537312f5415d1e3ed31ce0a56942bac4c771c5c335e" dependencies = [ "darling", - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", ] @@ -3586,8 +3621,8 @@ version = "0.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "63927d22a1e8b74bda98cc6e151fcdf178b7abb0dc6c4f81e0bbf5ffe2fc4ec8" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "shank_macro_impl", "syn 1.0.109", ] @@ -3599,8 +3634,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40ce03403df682f80f4dc1efafa87a4d0cb89b03726d0565e6364bdca5b9a441" dependencies = [ "anyhow", - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "serde", "syn 1.0.109", ] @@ -3883,8 +3918,8 @@ version = "1.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06395428329810ade1d2518a7e75d8a6f02d01fe548aabb60ff1ba6a2eaebbe5" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "rustc_version 0.4.0", "syn 1.0.109", ] @@ -4258,8 +4293,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f809319358d5da7c3a0ac08ebf4d87b21170d928dbb7260254e8f3061f7f9e0e" dependencies = [ "bs58 0.4.0", - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "rustversion", "syn 1.0.109", ] @@ -4608,8 +4643,19 @@ version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +dependencies = [ + "proc-macro2 1.0.56", + "quote 1.0.26", "unicode-ident", ] @@ -4619,8 +4665,8 @@ version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", "unicode-xid 0.2.4", ] @@ -4710,8 +4756,8 @@ version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", ] @@ -4824,8 +4870,8 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", ] @@ -4914,8 +4960,8 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", ] @@ -5089,6 +5135,12 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + [[package]] name = "vec_map" version = "0.8.2" @@ -5165,8 +5217,8 @@ dependencies = [ "bumpalo", "log", "once_cell", - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", "wasm-bindgen-shared", ] @@ -5189,7 +5241,7 @@ version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" dependencies = [ - "quote 1.0.21", + "quote 1.0.26", "wasm-bindgen-macro-support", ] @@ -5199,8 +5251,8 @@ version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", "wasm-bindgen-backend", "wasm-bindgen-shared", @@ -5291,21 +5343,51 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ - "windows_aarch64_gnullvm", + "windows_aarch64_gnullvm 0.42.0", "windows_aarch64_msvc 0.42.0", "windows_i686_gnu 0.42.0", "windows_i686_msvc 0.42.0", "windows_x86_64_gnu 0.42.0", - "windows_x86_64_gnullvm", + "windows_x86_64_gnullvm 0.42.0", "windows_x86_64_msvc 0.42.0", ] +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +dependencies = [ + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + [[package]] name = "windows_aarch64_msvc" version = "0.36.1" @@ -5318,6 +5400,12 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" + [[package]] name = "windows_i686_gnu" version = "0.36.1" @@ -5330,6 +5418,12 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + [[package]] name = "windows_i686_msvc" version = "0.36.1" @@ -5342,6 +5436,12 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + [[package]] name = "windows_x86_64_gnu" version = "0.36.1" @@ -5354,12 +5454,24 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" + [[package]] name = "windows_x86_64_msvc" version = "0.36.1" @@ -5372,6 +5484,21 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + +[[package]] +name = "winnow" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae8970b36c66498d8ff1d66685dc86b91b29db0c7739899012f63a63814b4b28" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.10.1" @@ -5442,8 +5569,8 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f8f187641dad4f680d25c4bfc4225b418165984179f26ca76ec4fb6441d3a17" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.56", + "quote 1.0.26", "syn 1.0.109", "synstructure", ] diff --git a/avm/Cargo.lock b/avm/Cargo.lock index 6ec821b121..f47d50f177 100644 --- a/avm/Cargo.lock +++ b/avm/Cargo.lock @@ -3,22 +3,60 @@ version = 3 [[package]] -name = "anyhow" -version = "1.0.66" +name = "anstream" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" +checksum = "6342bd4f5a1205d7f41e94a41a901f5647c938cdfa96036338e8533c9d6c2450" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is-terminal", + "utf8parse", +] [[package]] -name = "atty" -version = "0.2.14" +name = "anstyle" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" + +[[package]] +name = "anstyle-parse" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" dependencies = [ - "hermit-abi", - "libc", - "winapi", + "utf8parse", ] +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "anstyle-wincon" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +dependencies = [ + "anstyle", + "windows-sys 0.48.0", +] + +[[package]] +name = "anyhow" +version = "1.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" + [[package]] name = "autocfg" version = "1.1.0" @@ -86,40 +124,51 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.0.26" +version = "4.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2148adefda54e14492fb9bddcc600b4344c5d1a3123bd666dcb939c6f0e0e57e" +checksum = "956ac1f6381d8d82ab4684768f89c0ea3afe66925ceadb4eeb3fc452ffc55d62" dependencies = [ - "atty", - "bitflags", + "clap_builder", "clap_derive", - "clap_lex", "once_cell", +] + +[[package]] +name = "clap_builder" +version = "4.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84080e799e54cff944f4b4a4b0e71630b0e0443b25b985175c7dddc1a859b749" +dependencies = [ + "anstream", + "anstyle", + "bitflags", + "clap_lex", "strsim", - "termcolor", ] [[package]] name = "clap_derive" -version = "4.0.21" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0177313f9f02afc995627906bbd8967e2be069f5261954222dac78290c2b9014" +checksum = "3f9644cd56d6b87dbe899ef8b053e331c0637664e9e21a33dfcdc36093f5c5c4" dependencies = [ "heck", - "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] name = "clap_lex" -version = "0.3.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8" -dependencies = [ - "os_str_bytes", -] +checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "dirs" @@ -150,6 +199,27 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "errno" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "fastrand" version = "1.8.0" @@ -273,6 +343,12 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + [[package]] name = "http" version = "0.2.8" @@ -373,12 +449,35 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "io-lifetimes" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" +dependencies = [ + "hermit-abi 0.3.1", + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "ipnet" version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f88c5561171189e69df9d98bcf18fd5f9558300f7ea7b801eb8a0fd748bd8745" +[[package]] +name = "is-terminal" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" +dependencies = [ + "hermit-abi 0.3.1", + "io-lifetimes", + "rustix", + "windows-sys 0.48.0", +] + [[package]] name = "itoa" version = "1.0.4" @@ -396,9 +495,15 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.137" +version = "0.2.142" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" + +[[package]] +name = "linux-raw-sys" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" +checksum = "36eb31c1778188ae1e64398743890d0877fef36d11521ac60406b42016e8c2cf" [[package]] name = "log" @@ -430,7 +535,7 @@ dependencies = [ "libc", "log", "wasi", - "windows-sys", + "windows-sys 0.42.0", ] [[package]] @@ -439,7 +544,7 @@ version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", ] @@ -449,12 +554,6 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" -[[package]] -name = "os_str_bytes" -version = "6.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" - [[package]] name = "percent-encoding" version = "2.2.0" @@ -473,44 +572,20 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - [[package]] name = "proc-macro2" -version = "1.0.47" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.21" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" dependencies = [ "proc-macro2", ] @@ -598,6 +673,20 @@ dependencies = [ "winapi", ] +[[package]] +name = "rustix" +version = "0.37.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0661814f891c57c930a610266415528da53c4933e6dea5fb350cbfe048a9ece" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys 0.48.0", +] + [[package]] name = "rustls" version = "0.20.8" @@ -658,7 +747,7 @@ checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -726,6 +815,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "tempfile" version = "3.3.0" @@ -740,15 +840,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "termcolor" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" -dependencies = [ - "winapi-util", -] - [[package]] name = "thiserror" version = "1.0.37" @@ -766,7 +857,7 @@ checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", ] [[package]] @@ -798,7 +889,7 @@ dependencies = [ "num_cpus", "pin-project-lite", "socket2", - "windows-sys", + "windows-sys 0.42.0", ] [[package]] @@ -897,10 +988,10 @@ dependencies = [ ] [[package]] -name = "version_check" -version = "0.9.4" +name = "utf8parse" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "want" @@ -939,7 +1030,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 1.0.103", "wasm-bindgen-shared", ] @@ -973,7 +1064,7 @@ checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.103", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1029,15 +1120,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -1050,13 +1132,37 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.42.0", + "windows_aarch64_msvc 0.42.0", + "windows_i686_gnu 0.42.0", + "windows_i686_msvc 0.42.0", + "windows_x86_64_gnu 0.42.0", + "windows_x86_64_gnullvm 0.42.0", + "windows_x86_64_msvc 0.42.0", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +dependencies = [ + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", ] [[package]] @@ -1065,42 +1171,84 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + [[package]] name = "windows_aarch64_msvc" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" + [[package]] name = "windows_i686_gnu" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + [[package]] name = "windows_i686_msvc" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + [[package]] name = "windows_x86_64_gnu" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" + [[package]] name = "windows_x86_64_msvc" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + [[package]] name = "winreg" version = "0.10.1" diff --git a/avm/Cargo.toml b/avm/Cargo.toml index 40ddf76067..dc314cdec0 100644 --- a/avm/Cargo.toml +++ b/avm/Cargo.toml @@ -13,16 +13,16 @@ name = "anchor" path = "src/anchor/main.rs" [dependencies] -clap = { version = "4.0.26", features = [ "derive" ]} +clap = { version = "4.2.4", features = ["derive"]} cfg-if = "1.0.0" anyhow = "1.0.32" dirs = "4.0.0" semver = "1.0.4" -serde = { version = "1.0.136", features = [ "derive" ]} +serde = { version = "1.0.136", features = ["derive"] } serde_json = "1.0.78" thiserror = "1.0.30" once_cell = { version = "1.8.0" } -reqwest = { version = "0.11.9", default-features = false, features = ['blocking', 'json', 'rustls-tls'] } +reqwest = { version = "0.11.9", default-features = false, features = ["blocking", "json", "rustls-tls"] } tempfile = "3.3.0" [workspace] diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 6daa019eca..63537baf59 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -17,7 +17,7 @@ dev = [] default = [] [dependencies] -clap = { version = "4.0.26", features = ["derive"] } +clap = { version = "4.2.4", features = ["derive"] } anyhow = "1.0.32" syn = { version = "1.0.60", features = ["full", "extra-traits"] } anchor-lang = { path = "../lang", version = "0.27.0" } diff --git a/client/example/Cargo.toml b/client/example/Cargo.toml index 5af6efd894..56768daab0 100644 --- a/client/example/Cargo.toml +++ b/client/example/Cargo.toml @@ -16,5 +16,5 @@ optional = { path = "../../tests/optional/programs/optional", features = ["no-en events = { path = "../../tests/events/programs/events", features = ["no-entrypoint"] } shellexpand = "2.1.0" anyhow = "1.0.32" -clap = { version = "4.0.26", features = ["derive"] } +clap = { version = "4.2.4", features = ["derive"] } solana-sdk = "1.14.16" diff --git a/docs/src/pages/docs/intro-to-solana.md b/docs/src/pages/docs/intro-to-solana.md index dd0e4b52d7..a491e0270e 100644 --- a/docs/src/pages/docs/intro-to-solana.md +++ b/docs/src/pages/docs/intro-to-solana.md @@ -31,7 +31,7 @@ The first point means that even if in theory the program may read and write to a > This design is partly responsible for Solana’s high throughput. The runtime can look at all the incoming transactions of a program (and even across programs) and can check whether the memory regions in the first argument of the transactions overlap. If they don’t, the runtime can run these transactions in parallel because they don’t conflict with each other. Even better, if the runtime sees that two transactions access overlapping memory regions but only read and don’t write, it can also parallelize those transactions because they do not conflict with each other. -How exactly can a transaction specify a memory region/account? To answer that, we need to look deeper into what properties an account has ([docs here](https://docs.rs/solana-program/latest/solana_program/account_info/struct.AccountInfo.html)). This is the data structure for an account in a transaction. The `is_signer` and `is_writable` fields are set per transaction (e.g. `is_signed` is set if the corresponding private key of the account's `key` field signed the transaction) and are not part of the metadata that is saved in the heap). In front of the user data that the account can store (in the `data` field) , there is some metadata connected to each account. First, it has a key property which is a ed25519 public key and serves as the address of the account. This is how the transaction can specify which accounts the program may access in the transaction. +How exactly can a transaction specify a memory region/account? To answer that, we need to look deeper into what properties an account has ([docs here](https://docs.rs/solana-program/latest/solana_program/account_info/struct.AccountInfo.html)). This is the data structure for an account in a transaction. The `is_signer` and `is_writable` fields are set per transaction (e.g. `is_signer` is set if the corresponding private key of the account's `key` field signed the transaction) and are not part of the metadata that is saved in the heap). In front of the user data that the account can store (in the `data` field) , there is some metadata connected to each account. First, it has a key property which is a ed25519 public key and serves as the address of the account. This is how the transaction can specify which accounts the program may access in the transaction. ![Transaction](/transaction.svg) diff --git a/lang/src/accounts/account_loader.rs b/lang/src/accounts/account_loader.rs index 322b41faaa..50f544ed16 100644 --- a/lang/src/accounts/account_loader.rs +++ b/lang/src/accounts/account_loader.rs @@ -22,7 +22,7 @@ use std::ops::DerefMut; /// Type facilitating on demand zero copy deserialization. /// /// Note that using accounts in this way is distinctly different from using, -/// for example, the [`Account`](./struct.Account.html). Namely, +/// for example, the [`Account`](crate::accounts::account::Account). Namely, /// one must call /// - `load_init` after initializing an account (this will ignore the missing /// account discriminator that gets added only after the user's instruction code) @@ -30,7 +30,7 @@ use std::ops::DerefMut; /// - `load_mut` when the account is mutable /// /// For more details on zero-copy-deserialization, see the -/// [`account`](./attr.account.html) attribute. +/// [`account`](crate::account) attribute. ///

/// ⚠️ When using this type it's important to be mindful /// of any calls to the load functions so as not to diff --git a/spl/Cargo.toml b/spl/Cargo.toml index 0c4f21af13..3d4b200632 100644 --- a/spl/Cargo.toml +++ b/spl/Cargo.toml @@ -28,4 +28,9 @@ solana-program = "1.14.16" spl-token = { version = "3.5.0", features = ["no-entrypoint"], optional = true } spl-token-2022 = { version = "0.5.0", features = ["no-entrypoint"], optional = true } spl-associated-token-account = { version = "1.1.1", features = ["no-entrypoint"], optional = true } -mpl-token-metadata = { version = "^1.9.0", optional = true, features = ["no-entrypoint"] } +mpl-token-metadata = { version = "^1.11.0", optional = true, features = ["no-entrypoint"] } + +# TODO: Remove after updating to latest version of platform-tools. +# Latest solana version(1.14.17) as of 2023-05-01 comes with rustc 1.62.0-dev but MSRV for latest +# version of this crate is 1.64.0. See https://github.com/solana-labs/solana/pull/31418 +winnow = "=0.4.1" diff --git a/spl/src/metadata.rs b/spl/src/metadata.rs index 296c853ba1..151afd81eb 100644 --- a/spl/src/metadata.rs +++ b/spl/src/metadata.rs @@ -1,7 +1,6 @@ use anchor_lang::{ - context::CpiContext, - prelude::{ErrorCode, UncheckedAccount}, - Accounts, Result, ToAccountInfos, + context::CpiContext, error::ErrorCode, prelude::UncheckedAccount, Accounts, Result, + ToAccountInfos, }; use mpl_token_metadata::{ state::{CollectionDetails, DataV2, TokenMetadataAccount}, @@ -54,7 +53,6 @@ pub fn bubblegum_set_collection_size<'info>( pub fn burn_edition_nft<'info>( ctx: CpiContext<'_, '_, '_, 'info, BurnEditionNft<'info>>, - collection_metadata: Option, ) -> Result<()> { let ix = mpl_token_metadata::instruction::burn_edition_nft( ID, @@ -99,47 +97,6 @@ pub fn burn_nft<'info>( .map_err(Into::into) } -#[deprecated(note = "internal instructions deprecated by Metaplex")] -pub fn create_metadata_accounts_v2<'info>( - ctx: CpiContext<'_, '_, '_, 'info, CreateMetadataAccountsV2<'info>>, - data: DataV2, - is_mutable: bool, - update_authority_is_signer: bool, -) -> Result<()> { - let DataV2 { - name, - symbol, - uri, - creators, - seller_fee_basis_points, - collection, - uses, - } = data; - let ix = mpl_token_metadata::instruction::create_metadata_accounts_v2( - ID, - *ctx.accounts.metadata.key, - *ctx.accounts.mint.key, - *ctx.accounts.mint_authority.key, - *ctx.accounts.payer.key, - *ctx.accounts.update_authority.key, - name, - symbol, - uri, - creators, - seller_fee_basis_points, - update_authority_is_signer, - is_mutable, - collection, - uses, - ); - solana_program::program::invoke_signed( - &ix, - &ToAccountInfos::to_account_infos(&ctx), - ctx.signer_seeds, - ) - .map_err(Into::into) -} - pub fn create_metadata_accounts_v3<'info>( ctx: CpiContext<'_, '_, '_, 'info, CreateMetadataAccountsV3<'info>>, data: DataV2, @@ -599,18 +556,6 @@ pub struct BurnNft<'info> { pub spl_token: UncheckedAccount<'info>, } -#[deprecated(note = "internal instructions deprecated by Metaplex")] -#[derive(Accounts)] -pub struct CreateMetadataAccountsV2<'info> { - pub metadata: UncheckedAccount<'info>, - pub mint: UncheckedAccount<'info>, - pub mint_authority: UncheckedAccount<'info>, - pub payer: UncheckedAccount<'info>, - pub update_authority: UncheckedAccount<'info>, - pub system_program: UncheckedAccount<'info>, - pub rent: UncheckedAccount<'info>, -} - #[derive(Accounts)] pub struct CreateMetadataAccountsV3<'info> { pub metadata: UncheckedAccount<'info>, diff --git a/tests/bench/Anchor.toml b/tests/bench/Anchor.toml index 8e0cf1d521..661873a265 100644 --- a/tests/bench/Anchor.toml +++ b/tests/bench/Anchor.toml @@ -3,13 +3,14 @@ cluster = "localnet" wallet = "~/.config/solana/id.json" [programs.localnet] -bench = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS" +bench = "Bench11111111111111111111111111111111111111" [workspace] members = ["programs/bench"] [scripts] -test = "yarn run ts-mocha -t 1000000 -p ./tsconfig.json -t 1000000 tests/**/*.ts" -update-bench = "yarn run ts-node scripts/update-bench.ts" +test = "yarn run ts-mocha -t 1000000 -p ./tsconfig.json tests/**/*.ts" +sync = "yarn run ts-node scripts/sync.ts" +sync-markdown = "yarn run ts-node scripts/sync-markdown.ts" generate-ix = "yarn run ts-node scripts/generate-ix.ts" bump-version = "yarn run ts-node scripts/bump-version.ts" diff --git a/tests/bench/README.md b/tests/bench/README.md index b57b50d0f8..061e1d54ac 100644 --- a/tests/bench/README.md +++ b/tests/bench/README.md @@ -4,21 +4,25 @@ The bench program and its tests are used to measure the performance of Anchor pr ## How -Create a program -> Write tests that measure usage -> Compare the results -> Save the new result - -The script will check whether there is a difference between the current result and the last saved result(in `bench.json`) at the end of the tests. If the difference between the results is greater than 1%, the new data will be saved in `bench.json` and Markdown files in [/bench](https://github.com/coral-xyz/anchor/tree/master/bench) will be updated accordingly. +We run the same tests that measure some metric for each Anchor version starting from `0.27.0`. If the difference between the results is greater than 1%, the new data will be saved in `bench.json` and Markdown files in [/bench](https://github.com/coral-xyz/anchor/tree/master/bench) will be updated accordingly. ## Scripts +| :memo: TL;DR | +| :----------------------------------------------------------------------------------------------------------------------------- | +| If you've made changes to programs or tests in this directory, run `anchor run sync`, otherwise run `anchor test --skip-lint`. | + `anchor test --skip-lint`: Run all tests and update benchmark files when necessary. This is the only command that needs to be run for most use cases. --- The following scripts are useful when making changes to how benchmarking works. -`anchor run update-bench`: Update Markdown files in [/bench](https://github.com/coral-xyz/anchor/tree/master/bench) based on the data from `bench.json`. +`anchor run sync`: Sync all benchmark files by running tests for each version. If you've made changes to the bench program or its tests, you should run this command to sync the results. + +`anchor run sync-markdown`: Sync Markdown files in [/bench](https://github.com/coral-xyz/anchor/tree/master/bench) based on the data from `bench.json`. -`anchor run generate-ix`: Generate instructions with repetitive accounts. +`anchor run generate-ix`: Generate program instructions with repetitive accounts. --- diff --git a/tests/bench/programs/bench/Cargo.toml b/tests/bench/programs/bench/Cargo.toml index d7b162620b..1d21010acf 100644 --- a/tests/bench/programs/bench/Cargo.toml +++ b/tests/bench/programs/bench/Cargo.toml @@ -14,3 +14,8 @@ cpi = ["no-entrypoint"] [dependencies] anchor-lang = { path = "../../../../lang" } anchor-spl = { path = "../../../../spl" } + +# TODO: Remove this and store lock files for each version instead. +# Latest solana version(1.14.17) as of 2023-05-01 comes with rustc 1.62.0-dev but MSRV for latest +# version of this crate is 1.64.0. See https://github.com/solana-labs/solana/pull/31418 +winnow = "=0.4.1" diff --git a/tests/bench/programs/bench/src/lib.rs b/tests/bench/programs/bench/src/lib.rs index 263b471286..dc171590fd 100644 --- a/tests/bench/programs/bench/src/lib.rs +++ b/tests/bench/programs/bench/src/lib.rs @@ -1,9 +1,11 @@ //! This program is used to measure the performance of Anchor programs. +//! +//! If you are making a change to this program, run `anchor run sync`. use anchor_lang::prelude::*; use anchor_spl::token_interface::{Mint, TokenAccount, TokenInterface}; -declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"); +declare_id!("Bench11111111111111111111111111111111111111"); #[program] pub mod bench { diff --git a/tests/bench/scripts/update-bench.ts b/tests/bench/scripts/sync-markdown.ts similarity index 68% rename from tests/bench/scripts/update-bench.ts rename to tests/bench/scripts/sync-markdown.ts index 9b6cd063bb..1c8e1eab3d 100644 --- a/tests/bench/scripts/update-bench.ts +++ b/tests/bench/scripts/sync-markdown.ts @@ -1,4 +1,4 @@ -/** Update Markdown files in /bench */ +/** Sync Markdown files in /bench based on the data from bench.json */ import { BenchData, Markdown } from "./utils"; @@ -33,19 +33,27 @@ import { BenchData, Markdown } from "./utils"; bench.compareComputeUnits( newComputeUnitsResult, oldComputeUnitsResult, - (ixName, newComputeUnits, oldComputeUnits) => { - const percentChange = ( - (newComputeUnits / oldComputeUnits - 1) * - 100 - ).toFixed(2); + ({ ixName, newComputeUnits, oldComputeUnits }) => { + if (newComputeUnits === null) { + // Deleted instruction + return; + } let changeText; - if (isNaN(oldComputeUnits)) { + if (oldComputeUnits === null) { + // New instruction changeText = "N/A"; - } else if (+percentChange > 0) { - changeText = `🔴 **+${percentChange}%**`; } else { - changeText = `🟢 **${percentChange}%**`; + const percentChange = ( + (newComputeUnits / oldComputeUnits - 1) * + 100 + ).toFixed(2); + + if (+percentChange > 0) { + changeText = `🔴 **+${percentChange}%**`; + } else { + changeText = `🟢 **${percentChange}%**`; + } } table.insert(ixName, newComputeUnits.toString(), changeText); diff --git a/tests/bench/scripts/sync.ts b/tests/bench/scripts/sync.ts new file mode 100644 index 0000000000..b535921d18 --- /dev/null +++ b/tests/bench/scripts/sync.ts @@ -0,0 +1,66 @@ +/** + * Sync all saved data by re-running the tests for each version. + * + * This script should be used when the bench program or its tests has changed + * and all data needs to be updated. + */ + +import path from "path"; +import { spawnSync } from "child_process"; + +import { ANCHOR_VERSION_ARG, BenchData, Toml } from "./utils"; + +(async () => { + const bench = await BenchData.open(); + + const cargoToml = await Toml.open( + path.join("..", "programs", "bench", "Cargo.toml") + ); + const anchorToml = await Toml.open(path.join("..", "Anchor.toml")); + + for (const version of bench.getVersions()) { + console.log(`Updating '${version}'...`); + + const isUnreleased = version === "unreleased"; + + // Update the anchor dependency versions + for (const dependency of ["lang", "spl"]) { + cargoToml.replaceValue(`anchor-${dependency}`, () => { + return isUnreleased + ? `{ path = "../../../../${dependency}" }` + : `"${version}"`; + }); + } + + // Save Cargo.toml + await cargoToml.save(); + + // Update `anchor test` command to pass version in Anchor.toml + anchorToml.replaceValue( + "test", + (cmd) => { + return cmd.includes(ANCHOR_VERSION_ARG) + ? cmd.replace( + new RegExp(`\\s*${ANCHOR_VERSION_ARG}\\s+(.+)`), + (arg, ver) => (isUnreleased ? "" : arg.replace(ver, version)) + ) + : `${cmd} ${ANCHOR_VERSION_ARG} ${version}`; + }, + { insideQuotes: true } + ); + + // Save Anchor.toml + await anchorToml.save(); + + // Run the command to update the current version's results + const result = spawnSync("anchor", ["test", "--skip-lint"]); + console.log(result.output.toString()); + + // Check for failure + if (result.status !== 0) { + console.error("Please fix the error and re-run this command."); + process.exitCode = 1; + return; + } + } +})(); diff --git a/tests/bench/scripts/utils.ts b/tests/bench/scripts/utils.ts index 8350cbbb61..02bd38804d 100644 --- a/tests/bench/scripts/utils.ts +++ b/tests/bench/scripts/utils.ts @@ -2,6 +2,9 @@ import * as fs from "fs/promises"; import path from "path"; import { spawnSync } from "child_process"; +/** Version that is used in bench data file */ +export type Version = "unreleased" | (`${number}.${number}.${number}` & {}); + /** Persistent benchmark data(mapping of `Version -> Data`) */ type Bench = { [key: string]: { @@ -21,7 +24,10 @@ export type ComputeUnits = { [key: string]: number }; export const THRESHOLD_PERCENTAGE = 1; /** Path to the benchmark Markdown files */ -export const BENCH_DIR_PATH = "../../bench"; +export const BENCH_DIR_PATH = path.join("..", "..", "bench"); + +/** Command line argument for Anchor version */ +export const ANCHOR_VERSION_ARG = "--anchor-version"; /** Utility class to handle benchmark data related operations */ export class BenchData { @@ -56,43 +62,74 @@ export class BenchData { } /** Get the stored results based on version */ - get(version: string) { + get(version: Version) { return this.#data[version]; } - /** Get unreleased version results */ - getUnreleased() { - return this.get("unreleased"); - } - /** Get all versions */ getVersions() { - return Object.keys(this.#data); + return Object.keys(this.#data) as Version[]; } /** Compare and update compute units changes */ compareComputeUnits( newComputeUnitsResult: ComputeUnits, oldComputeUnitsResult: ComputeUnits, - changeCb: ( - ixName: string, - newComputeUnits: number, - oldComputeUnits: number - ) => void, + changeCb: (args: { + ixName: string; + newComputeUnits: number | null; + oldComputeUnits: number | null; + }) => void, noChangeCb?: (ixName: string, computeUnits: number) => void ) { let needsUpdate = false; + const checkIxs = ( + comparedFrom: ComputeUnits, + comparedTo: ComputeUnits, + cb: (ixName: string, computeUnits: number) => void + ) => { + for (const ixName in comparedFrom) { + if (comparedTo[ixName] === undefined) { + cb(ixName, comparedFrom[ixName]); + } + } + }; + + // New instruction + checkIxs( + newComputeUnitsResult, + oldComputeUnitsResult, + (ixName, computeUnits) => { + console.log(`New instruction '${ixName}'`); + changeCb({ + ixName, + newComputeUnits: computeUnits, + oldComputeUnits: null, + }); + needsUpdate = true; + } + ); + + // Deleted instruction + checkIxs( + oldComputeUnitsResult, + newComputeUnitsResult, + (ixName, computeUnits) => { + console.log(`Deleted instruction '${ixName}'`); + changeCb({ + ixName, + newComputeUnits: null, + oldComputeUnits: computeUnits, + }); + needsUpdate = true; + } + ); + // Compare compute units changes for (const ixName in newComputeUnitsResult) { const oldComputeUnits = oldComputeUnitsResult[ixName]; const newComputeUnits = newComputeUnitsResult[ixName]; - if (!oldComputeUnits) { - console.log(`New instruction '${ixName}'`); - needsUpdate = true; - changeCb(ixName, newComputeUnits, NaN); - continue; - } const percentage = THRESHOLD_PERCENTAGE / 100; const oldMaximumAllowedDelta = oldComputeUnits * percentage; @@ -119,8 +156,12 @@ export class BenchData { `Compute units change '${ixName}' (${oldComputeUnits} -> ${newComputeUnits})` ); + changeCb({ + ixName, + newComputeUnits, + oldComputeUnits, + }); needsUpdate = true; - changeCb(ixName, newComputeUnits, oldComputeUnits); } else { noChangeCb?.(ixName, newComputeUnits); } @@ -131,14 +172,14 @@ export class BenchData { /** Bump benchmark data version to the given version */ bumpVersion(newVersion: string) { - const versions = Object.keys(this.#data); - const unreleasedVersion = versions[versions.length - 1]; - if (this.#data[newVersion]) { console.error(`Version '${newVersion}' already exists!`); process.exit(1); } + const versions = this.getVersions(); + const unreleasedVersion = versions[versions.length - 1]; + // Add the new version this.#data[newVersion] = this.get(unreleasedVersion); @@ -296,3 +337,56 @@ class MarkdownTable { ); } } + +/** Utility class to handle TOML related operations */ +export class Toml { + /** TOML filepath */ + #path: string; + + /** TOML text */ + #text: string; + + constructor(path: string, text: string) { + this.#path = path; + this.#text = text; + } + + /** Open the TOML file */ + static async open(tomlPath: string) { + tomlPath = path.join(__dirname, tomlPath); + const text = await fs.readFile(tomlPath, { + encoding: "utf8", + }); + return new Toml(tomlPath, text); + } + + /** Save the TOML file */ + async save() { + await fs.writeFile(this.#path, this.#text); + } + + /** Replace the value for the given key */ + replaceValue( + key: string, + cb: (previous: string) => string, + opts?: { insideQuotes: boolean } + ) { + this.#text = this.#text.replace( + new RegExp(`${key}\\s*=\\s*${opts?.insideQuotes ? `"(.*)"` : "(.*)"}`), + (line, value) => line.replace(value, cb(value)) + ); + } +} + +/** + * Get Anchor version from the passed arguments. + * + * Defaults to `unreleased`. + */ +export const getVersionFromArgs = () => { + const args = process.argv; + const anchorVersionArgIndex = args.indexOf(ANCHOR_VERSION_ARG); + return anchorVersionArgIndex === -1 + ? "unreleased" + : (args[anchorVersionArgIndex + 1] as Version); +}; diff --git a/tests/bench/tests/compute-units.ts b/tests/bench/tests/compute-units.ts index 9b589733fa..bf96b0a710 100644 --- a/tests/bench/tests/compute-units.ts +++ b/tests/bench/tests/compute-units.ts @@ -3,7 +3,7 @@ import * as token from "@coral-xyz/spl-token"; import { spawnSync } from "child_process"; import { Bench, IDL } from "../target/types/bench"; -import { BenchData, ComputeUnits } from "../scripts/utils"; +import { BenchData, ComputeUnits, getVersionFromArgs } from "../scripts/utils"; describe(IDL.name, () => { // Configure the client to use the local cluster @@ -222,12 +222,17 @@ describe(IDL.name, () => { const bench = await BenchData.open(); // Compare and update compute units changes - const oldComputeUnits = bench.getUnreleased().computeUnits; + const version = getVersionFromArgs(); + const oldComputeUnits = bench.get(version).computeUnits; const { needsUpdate } = bench.compareComputeUnits( computeUnits, oldComputeUnits, - (ixName, newComputeUnits) => { - oldComputeUnits[ixName] = newComputeUnits; + ({ ixName, newComputeUnits: newValue }) => { + if (newValue === null) { + delete oldComputeUnits[ixName]; + } else { + oldComputeUnits[ixName] = newValue; + } } ); @@ -235,10 +240,13 @@ describe(IDL.name, () => { console.log("Updating benchmark files..."); // Save bench data file - // (needs to happen before running the `update-bench` script) + // (needs to happen before running the `sync-markdown` script) await bench.save(); - spawnSync("anchor", ["run", "update-bench"]); + // Only update markdown files on `unreleased` version + if (version === "unreleased") { + spawnSync("anchor", ["run", "sync-markdown"]); + } } }); }); From 2f6ddbebd164a9c6f14659b26f2c372e8ec79dbc Mon Sep 17 00:00:00 2001 From: Jean Marchand Date: Fri, 5 May 2023 11:48:08 +0200 Subject: [PATCH 07/11] Fix boxed accounts --- bench/COMPUTE_UNITS.md | 174 +++++++++--------- .../basic-3/programs/puppet-master/src/lib.rs | 2 +- lang/src/accounts/boxed.rs | 2 +- tests/bench/bench.json | 54 +++--- .../programs/cashiers-check/src/lib.rs | 18 +- tests/escrow/programs/escrow/src/lib.rs | 34 ++-- tests/ido-pool/programs/ido-pool/src/lib.rs | 70 +++---- tests/swap/programs/swap/src/lib.rs | 76 ++++---- tests/yarn.lock | 31 +--- tests/zero-copy/programs/zero-cpi/src/lib.rs | 6 +- 10 files changed, 234 insertions(+), 233 deletions(-) diff --git a/bench/COMPUTE_UNITS.md b/bench/COMPUTE_UNITS.md index 3e1f717213..5eaed7364d 100644 --- a/bench/COMPUTE_UNITS.md +++ b/bench/COMPUTE_UNITS.md @@ -11,91 +11,91 @@ The programs and their tests are located in [/tests/bench](https://github.com/co ## [Unreleased] -| Instruction | Compute Units | +/- | -| --------------------------- | ------------- | --- | -| accountEmptyInit1 | 5958 | - | -| accountEmpty1 | 1090 | - | -| accountEmptyInit2 | 10583 | - | -| accountEmpty2 | 1852 | - | -| accountEmptyInit4 | 19557 | - | -| accountEmpty4 | 2646 | - | -| accountEmptyInit8 | 37541 | - | -| accountEmpty8 | 5043 | - | -| accountSizedInit1 | 6063 | - | -| accountSized1 | 1135 | - | -| accountSizedInit2 | 10783 | - | -| accountSized2 | 1966 | - | -| accountSizedInit4 | 19975 | - | -| accountSized4 | 2787 | - | -| accountSizedInit8 | 38381 | - | -| accountSized8 | 5359 | - | -| accountUnsizedInit1 | 6193 | - | -| accountUnsized1 | 1243 | - | -| accountUnsizedInit2 | 11042 | - | -| accountUnsized2 | 1893 | - | -| accountUnsizedInit4 | 20495 | - | -| accountUnsized4 | 3104 | - | -| accountUnsizedInit8 | 39419 | - | -| accountUnsized8 | 6051 | - | -| boxedAccountEmptyInit1 | 6160 | - | -| boxedAccountEmpty1 | 976 | - | -| boxedAccountEmptyInit2 | 10784 | - | -| boxedAccountEmpty2 | 1499 | - | -| boxedAccountEmptyInit4 | 19500 | - | -| boxedAccountEmpty4 | 2530 | - | -| boxedAccountEmptyInit8 | 37415 | - | -| boxedAccountEmpty8 | 4780 | - | -| boxedAccountSizedInit1 | 6256 | - | -| boxedAccountSized1 | 1003 | - | -| boxedAccountSizedInit2 | 10975 | - | -| boxedAccountSized2 | 1554 | - | -| boxedAccountSizedInit4 | 19884 | - | -| boxedAccountSized4 | 2642 | - | -| boxedAccountSizedInit8 | 38182 | - | -| boxedAccountSized8 | 5003 | - | -| boxedAccountUnsizedInit1 | 6374 | - | -| boxedAccountUnsized1 | 1069 | - | -| boxedAccountUnsizedInit2 | 11211 | - | -| boxedAccountUnsized2 | 1679 | - | -| boxedAccountUnsizedInit4 | 20351 | - | -| boxedAccountUnsized4 | 2899 | - | -| boxedAccountUnsizedInit8 | 39118 | - | -| boxedAccountUnsized8 | 5517 | - | -| boxedInterfaceAccountMint1 | 2299 | - | -| boxedInterfaceAccountMint2 | 4053 | - | -| boxedInterfaceAccountMint4 | 7538 | - | -| boxedInterfaceAccountMint8 | 14699 | - | -| boxedInterfaceAccountToken1 | 1737 | - | -| boxedInterfaceAccountToken2 | 2928 | - | -| boxedInterfaceAccountToken4 | 5291 | - | -| boxedInterfaceAccountToken8 | 10205 | - | -| interfaceAccountMint1 | 2530 | - | -| interfaceAccountMint2 | 4726 | - | -| interfaceAccountMint4 | 9431 | - | -| interfaceAccountMint8 | 17709 | - | -| interfaceAccountToken1 | 1755 | - | -| interfaceAccountToken2 | 3211 | - | -| interfaceAccountToken4 | 6006 | - | -| interface1 | 999 | - | -| interface2 | 1574 | - | -| interface4 | 1996 | - | -| interface8 | 3651 | - | -| program1 | 999 | - | -| program2 | 1573 | - | -| program4 | 1998 | - | -| program8 | 3651 | - | -| signer1 | 958 | - | -| signer2 | 1576 | - | -| signer4 | 2079 | - | -| signer8 | 3895 | - | -| systemAccount1 | 1013 | - | -| systemAccount2 | 1686 | - | -| systemAccount4 | 2298 | - | -| systemAccount8 | 4336 | - | -| uncheckedAccount1 | 953 | - | -| uncheckedAccount2 | 1567 | - | -| uncheckedAccount4 | 2060 | - | -| uncheckedAccount8 | 3855 | - | +| Instruction | Compute Units | +/- | +| --------------------------- | ------------- | ------------- | +| accountEmptyInit1 | 6246 | 🔴 **+4.83%** | +| accountEmpty1 | 1090 | - | +| accountEmptyInit2 | 11090 | 🔴 **+4.88%** | +| accountEmpty2 | 1852 | - | +| accountEmptyInit4 | 20579 | 🔴 **+5.23%** | +| accountEmpty4 | 2646 | - | +| accountEmptyInit8 | 39582 | 🔴 **+5.44%** | +| accountEmpty8 | 5043 | - | +| accountSizedInit1 | 6353 | 🔴 **+4.78%** | +| accountSized1 | 1135 | - | +| accountSizedInit2 | 11301 | 🔴 **+4.80%** | +| accountSized2 | 1966 | - | +| accountSizedInit4 | 21000 | 🔴 **+5.13%** | +| accountSized4 | 2787 | - | +| accountSizedInit8 | 40422 | 🔴 **+5.32%** | +| accountSized8 | 5359 | - | +| accountUnsizedInit1 | 6482 | 🔴 **+4.67%** | +| accountUnsized1 | 1243 | - | +| accountUnsizedInit2 | 11560 | 🔴 **+4.69%** | +| accountUnsized2 | 1893 | - | +| accountUnsizedInit4 | 21519 | 🔴 **+5.00%** | +| accountUnsized4 | 3104 | - | +| accountUnsizedInit8 | 41461 | 🔴 **+5.18%** | +| accountUnsized8 | 6051 | - | +| boxedAccountEmptyInit1 | 6447 | 🔴 **+4.66%** | +| boxedAccountEmpty1 | 976 | - | +| boxedAccountEmptyInit2 | 11292 | 🔴 **+4.71%** | +| boxedAccountEmpty2 | 1499 | - | +| boxedAccountEmptyInit4 | 20521 | 🔴 **+5.24%** | +| boxedAccountEmpty4 | 2530 | - | +| boxedAccountEmptyInit8 | 39456 | 🔴 **+5.46%** | +| boxedAccountEmpty8 | 4780 | - | +| boxedAccountSizedInit1 | 6544 | 🔴 **+4.60%** | +| boxedAccountSized1 | 1003 | - | +| boxedAccountSizedInit2 | 11485 | 🔴 **+4.65%** | +| boxedAccountSized2 | 1554 | - | +| boxedAccountSizedInit4 | 20904 | 🔴 **+5.13%** | +| boxedAccountSized4 | 2642 | - | +| boxedAccountSizedInit8 | 40224 | 🔴 **+5.35%** | +| boxedAccountSized8 | 5003 | - | +| boxedAccountUnsizedInit1 | 6661 | 🔴 **+4.50%** | +| boxedAccountUnsized1 | 1069 | - | +| boxedAccountUnsizedInit2 | 11720 | 🔴 **+4.54%** | +| boxedAccountUnsized2 | 1679 | - | +| boxedAccountUnsizedInit4 | 21372 | 🔴 **+5.02%** | +| boxedAccountUnsized4 | 2899 | - | +| boxedAccountUnsizedInit8 | 41159 | 🔴 **+5.22%** | +| boxedAccountUnsized8 | 5517 | - | +| boxedInterfaceAccountMint1 | 2299 | - | +| boxedInterfaceAccountMint2 | 4053 | - | +| boxedInterfaceAccountMint4 | 7538 | - | +| boxedInterfaceAccountMint8 | 14699 | - | +| boxedInterfaceAccountToken1 | 1737 | - | +| boxedInterfaceAccountToken2 | 2928 | - | +| boxedInterfaceAccountToken4 | 5291 | - | +| boxedInterfaceAccountToken8 | 10205 | - | +| interfaceAccountMint1 | 2530 | - | +| interfaceAccountMint2 | 4726 | - | +| interfaceAccountMint4 | 9431 | - | +| interfaceAccountMint8 | 17709 | - | +| interfaceAccountToken1 | 1755 | - | +| interfaceAccountToken2 | 3211 | - | +| interfaceAccountToken4 | 6006 | - | +| interface1 | 999 | - | +| interface2 | 1574 | - | +| interface4 | 1996 | - | +| interface8 | 3651 | - | +| program1 | 999 | - | +| program2 | 1573 | - | +| program4 | 1998 | - | +| program8 | 3651 | - | +| signer1 | 958 | - | +| signer2 | 1576 | - | +| signer4 | 2079 | - | +| signer8 | 3895 | - | +| systemAccount1 | 1013 | - | +| systemAccount2 | 1686 | - | +| systemAccount4 | 2298 | - | +| systemAccount8 | 4336 | - | +| uncheckedAccount1 | 953 | - | +| uncheckedAccount2 | 1567 | - | +| uncheckedAccount4 | 2060 | - | +| uncheckedAccount8 | 3855 | - | ### Notable changes @@ -105,6 +105,10 @@ The programs and their tests are located in [/tests/bench](https://github.com/co | Instruction | Compute Units | +/- | | --------------------------- | ------------- | --- | +| accountInfo1 | 954 | N/A | +| accountInfo2 | 1567 | N/A | +| accountInfo4 | 2059 | N/A | +| accountInfo8 | 3856 | N/A | | accountEmptyInit1 | 5958 | N/A | | accountEmpty1 | 1090 | N/A | | accountEmptyInit2 | 10574 | N/A | diff --git a/examples/tutorial/basic-3/programs/puppet-master/src/lib.rs b/examples/tutorial/basic-3/programs/puppet-master/src/lib.rs index 29d32bac7b..8afdb7c335 100644 --- a/examples/tutorial/basic-3/programs/puppet-master/src/lib.rs +++ b/examples/tutorial/basic-3/programs/puppet-master/src/lib.rs @@ -12,7 +12,7 @@ mod puppet_master { pub fn pull_strings(ctx: Context, data: u64) -> anchor_lang::Result<()> { let cpi_program = ctx.accounts.puppet_program.to_account_info(); let cpi_accounts = SetData { - puppet: ctx.accounts.puppet.to_account_info(), + puppet: ctx.accounts.puppet.to_account_info().into(), }; let cpi_ctx = CpiContext::new(cpi_program, cpi_accounts); puppet::cpi::set_data(cpi_ctx, data) diff --git a/lang/src/accounts/boxed.rs b/lang/src/accounts/boxed.rs index f956fe22e4..61763071a7 100644 --- a/lang/src/accounts/boxed.rs +++ b/lang/src/accounts/boxed.rs @@ -59,6 +59,6 @@ impl<'info, T: AccountsClose<'info>> AccountsClose<'info> for Box { impl<'info, T: Into>> From> for UncheckedAccount<'info> { fn from(value: Box) -> Self { - value.into() + T::into(*value) } } diff --git a/tests/bench/bench.json b/tests/bench/bench.json index db5e01afdb..3efc655c61 100644 --- a/tests/bench/bench.json +++ b/tests/bench/bench.json @@ -1,6 +1,10 @@ { "0.27.0": { "computeUnits": { + "accountInfo1": 954, + "accountInfo2": 1567, + "accountInfo4": 2059, + "accountInfo8": 3856, "accountEmptyInit1": 5958, "accountEmpty1": 1090, "accountEmptyInit2": 10574, @@ -88,53 +92,53 @@ }, "unreleased": { "computeUnits": { - "accountEmptyInit1": 5958, + "accountEmptyInit1": 6246, "accountEmpty1": 1090, - "accountEmptyInit2": 10583, + "accountEmptyInit2": 11090, "accountEmpty2": 1852, - "accountEmptyInit4": 19557, + "accountEmptyInit4": 20579, "accountEmpty4": 2646, - "accountEmptyInit8": 37541, + "accountEmptyInit8": 39582, "accountEmpty8": 5043, - "accountSizedInit1": 6063, + "accountSizedInit1": 6353, "accountSized1": 1135, - "accountSizedInit2": 10783, + "accountSizedInit2": 11301, "accountSized2": 1966, - "accountSizedInit4": 19975, + "accountSizedInit4": 21000, "accountSized4": 2787, - "accountSizedInit8": 38381, + "accountSizedInit8": 40422, "accountSized8": 5359, - "accountUnsizedInit1": 6193, + "accountUnsizedInit1": 6482, "accountUnsized1": 1243, - "accountUnsizedInit2": 11042, + "accountUnsizedInit2": 11560, "accountUnsized2": 1893, - "accountUnsizedInit4": 20495, + "accountUnsizedInit4": 21519, "accountUnsized4": 3104, - "accountUnsizedInit8": 39419, + "accountUnsizedInit8": 41461, "accountUnsized8": 6051, - "boxedAccountEmptyInit1": 6160, + "boxedAccountEmptyInit1": 6447, "boxedAccountEmpty1": 976, - "boxedAccountEmptyInit2": 10784, + "boxedAccountEmptyInit2": 11292, "boxedAccountEmpty2": 1499, - "boxedAccountEmptyInit4": 19500, + "boxedAccountEmptyInit4": 20521, "boxedAccountEmpty4": 2530, - "boxedAccountEmptyInit8": 37415, + "boxedAccountEmptyInit8": 39456, "boxedAccountEmpty8": 4780, - "boxedAccountSizedInit1": 6256, + "boxedAccountSizedInit1": 6544, "boxedAccountSized1": 1003, - "boxedAccountSizedInit2": 10975, + "boxedAccountSizedInit2": 11485, "boxedAccountSized2": 1554, - "boxedAccountSizedInit4": 19884, + "boxedAccountSizedInit4": 20904, "boxedAccountSized4": 2642, - "boxedAccountSizedInit8": 38182, + "boxedAccountSizedInit8": 40224, "boxedAccountSized8": 5003, - "boxedAccountUnsizedInit1": 6374, + "boxedAccountUnsizedInit1": 6661, "boxedAccountUnsized1": 1069, - "boxedAccountUnsizedInit2": 11211, + "boxedAccountUnsizedInit2": 11720, "boxedAccountUnsized2": 1679, - "boxedAccountUnsizedInit4": 20351, + "boxedAccountUnsizedInit4": 21372, "boxedAccountUnsized4": 2899, - "boxedAccountUnsizedInit8": 39118, + "boxedAccountUnsizedInit8": 41159, "boxedAccountUnsized8": 5517, "boxedInterfaceAccountMint1": 2299, "boxedInterfaceAccountMint2": 4053, @@ -173,4 +177,4 @@ "uncheckedAccount8": 3855 } } -} +} \ No newline at end of file diff --git a/tests/cashiers-check/programs/cashiers-check/src/lib.rs b/tests/cashiers-check/programs/cashiers-check/src/lib.rs index eb06e2cdcc..25fd217377 100644 --- a/tests/cashiers-check/programs/cashiers-check/src/lib.rs +++ b/tests/cashiers-check/programs/cashiers-check/src/lib.rs @@ -22,9 +22,9 @@ pub mod cashiers_check { ) -> Result<()> { // Transfer funds to the check. let cpi_accounts = Transfer { - from: ctx.accounts.from.to_account_info(), - to: ctx.accounts.vault.to_account_info(), - authority: ctx.accounts.owner.to_account_info(), + from: ctx.accounts.from.to_account_info().into(), + to: ctx.accounts.vault.to_account_info().into(), + authority: ctx.accounts.owner.to_account_info().into(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new(cpi_program, cpi_accounts); @@ -50,9 +50,9 @@ pub mod cashiers_check { ]; let signer = &[&seeds[..]]; let cpi_accounts = Transfer { - from: ctx.accounts.vault.to_account_info(), - to: ctx.accounts.to.to_account_info(), - authority: ctx.accounts.check_signer.to_account_info(), + from: ctx.accounts.vault.to_account_info().into(), + to: ctx.accounts.to.to_account_info().into(), + authority: ctx.accounts.check_signer.to_account_info().into(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new_with_signer(cpi_program, cpi_accounts, signer); @@ -70,9 +70,9 @@ pub mod cashiers_check { ]; let signer = &[&seeds[..]]; let cpi_accounts = Transfer { - from: ctx.accounts.vault.to_account_info(), - to: ctx.accounts.from.to_account_info(), - authority: ctx.accounts.check_signer.to_account_info(), + from: ctx.accounts.vault.to_account_info().into(), + to: ctx.accounts.from.to_account_info().into(), + authority: ctx.accounts.check_signer.to_account_info().into(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new_with_signer(cpi_program, cpi_accounts, signer); diff --git a/tests/escrow/programs/escrow/src/lib.rs b/tests/escrow/programs/escrow/src/lib.rs index 8afed08665..ad769089c9 100644 --- a/tests/escrow/programs/escrow/src/lib.rs +++ b/tests/escrow/programs/escrow/src/lib.rs @@ -193,8 +193,11 @@ impl<'info> From<&mut InitializeEscrow<'info>> { fn from(accounts: &mut InitializeEscrow<'info>) -> Self { let cpi_accounts = SetAuthority { - account_or_mint: accounts.initializer_deposit_token_account.to_account_info(), - current_authority: accounts.initializer.to_account_info(), + account_or_mint: accounts + .initializer_deposit_token_account + .to_account_info() + .into(), + current_authority: accounts.initializer.to_account_info().into(), }; let cpi_program = accounts.token_program.to_account_info(); CpiContext::new(cpi_program, cpi_accounts) @@ -204,8 +207,8 @@ impl<'info> From<&mut InitializeEscrow<'info>> impl<'info> CancelEscrow<'info> { fn into_set_authority_context(&self) -> CpiContext<'_, '_, '_, 'info, SetAuthority<'info>> { let cpi_accounts = SetAuthority { - account_or_mint: self.pda_deposit_token_account.to_account_info(), - current_authority: self.pda_account.to_account_info(), + account_or_mint: self.pda_deposit_token_account.to_account_info().into(), + current_authority: self.pda_account.to_account_info().into(), }; let cpi_program = self.token_program.to_account_info(); CpiContext::new(cpi_program, cpi_accounts) @@ -215,8 +218,8 @@ impl<'info> CancelEscrow<'info> { impl<'info> Exchange<'info> { fn into_set_authority_context(&self) -> CpiContext<'_, '_, '_, 'info, SetAuthority<'info>> { let cpi_accounts = SetAuthority { - account_or_mint: self.pda_deposit_token_account.to_account_info(), - current_authority: self.pda_account.to_account_info(), + account_or_mint: self.pda_deposit_token_account.to_account_info().into(), + current_authority: self.pda_account.to_account_info().into(), }; let cpi_program = self.receive_token_program.to_account_info(); CpiContext::new(cpi_program, cpi_accounts) @@ -228,10 +231,10 @@ impl<'info> Exchange<'info> { &self, ) -> CpiContext<'_, '_, '_, 'info, TransferChecked<'info>> { let cpi_accounts = TransferChecked { - from: self.pda_deposit_token_account.to_account_info(), - mint: self.receive_mint.to_account_info(), - to: self.taker_receive_token_account.to_account_info(), - authority: self.pda_account.to_account_info(), + from: self.pda_deposit_token_account.to_account_info().into(), + mint: self.receive_mint.to_account_info().into(), + to: self.taker_receive_token_account.to_account_info().into(), + authority: self.pda_account.to_account_info().into(), }; let cpi_program = self.receive_token_program.to_account_info(); CpiContext::new(cpi_program, cpi_accounts) @@ -243,10 +246,13 @@ impl<'info> Exchange<'info> { &self, ) -> CpiContext<'_, '_, '_, 'info, TransferChecked<'info>> { let cpi_accounts = TransferChecked { - from: self.taker_deposit_token_account.to_account_info(), - mint: self.deposit_mint.to_account_info(), - to: self.initializer_receive_token_account.to_account_info(), - authority: self.taker.to_account_info(), + from: self.taker_deposit_token_account.to_account_info().into(), + mint: self.deposit_mint.to_account_info().into(), + to: self + .initializer_receive_token_account + .to_account_info() + .into(), + authority: self.taker.to_account_info().into(), }; let cpi_program = self.deposit_token_program.to_account_info(); CpiContext::new(cpi_program, cpi_accounts) diff --git a/tests/ido-pool/programs/ido-pool/src/lib.rs b/tests/ido-pool/programs/ido-pool/src/lib.rs index 0e72a49a2f..f1fad12d5f 100644 --- a/tests/ido-pool/programs/ido-pool/src/lib.rs +++ b/tests/ido-pool/programs/ido-pool/src/lib.rs @@ -51,9 +51,13 @@ pub mod ido_pool { // Transfer Watermelon from ido_authority to pool account. let cpi_accounts = Transfer { - from: ctx.accounts.ido_authority_watermelon.to_account_info(), - to: ctx.accounts.pool_watermelon.to_account_info(), - authority: ctx.accounts.ido_authority.to_account_info(), + from: ctx + .accounts + .ido_authority_watermelon + .to_account_info() + .into(), + to: ctx.accounts.pool_watermelon.to_account_info().into(), + authority: ctx.accounts.ido_authority.to_account_info().into(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new(cpi_program, cpi_accounts); @@ -81,9 +85,9 @@ pub mod ido_pool { // Transfer user's USDC to pool USDC account. let cpi_accounts = Transfer { - from: ctx.accounts.user_usdc.to_account_info(), - to: ctx.accounts.pool_usdc.to_account_info(), - authority: ctx.accounts.user_authority.to_account_info(), + from: ctx.accounts.user_usdc.to_account_info().into(), + to: ctx.accounts.pool_usdc.to_account_info().into(), + authority: ctx.accounts.user_authority.to_account_info().into(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new(cpi_program, cpi_accounts); @@ -97,9 +101,9 @@ pub mod ido_pool { ]; let signer = &[&seeds[..]]; let cpi_accounts = MintTo { - mint: ctx.accounts.redeemable_mint.to_account_info(), - to: ctx.accounts.user_redeemable.to_account_info(), - authority: ctx.accounts.ido_account.to_account_info(), + mint: ctx.accounts.redeemable_mint.to_account_info().into(), + to: ctx.accounts.user_redeemable.to_account_info().into(), + authority: ctx.accounts.ido_account.to_account_info().into(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new_with_signer(cpi_program, cpi_accounts, signer); @@ -134,9 +138,9 @@ pub mod ido_pool { // Burn the user's redeemable tokens. let cpi_accounts = Burn { - mint: ctx.accounts.redeemable_mint.to_account_info(), - from: ctx.accounts.user_redeemable.to_account_info(), - authority: ctx.accounts.ido_account.to_account_info(), + mint: ctx.accounts.redeemable_mint.to_account_info().into(), + from: ctx.accounts.user_redeemable.to_account_info().into(), + authority: ctx.accounts.ido_account.to_account_info().into(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new_with_signer(cpi_program, cpi_accounts, signer); @@ -144,9 +148,9 @@ pub mod ido_pool { // Transfer USDC from pool account to the user's escrow account. let cpi_accounts = Transfer { - from: ctx.accounts.pool_usdc.to_account_info(), - to: ctx.accounts.escrow_usdc.to_account_info(), - authority: ctx.accounts.ido_account.to_account_info(), + from: ctx.accounts.pool_usdc.to_account_info().into(), + to: ctx.accounts.escrow_usdc.to_account_info().into(), + authority: ctx.accounts.ido_account.to_account_info().into(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new_with_signer(cpi_program, cpi_accounts, signer); @@ -182,9 +186,9 @@ pub mod ido_pool { // Burn the user's redeemable tokens. let cpi_accounts = Burn { - mint: ctx.accounts.redeemable_mint.to_account_info(), - from: ctx.accounts.user_redeemable.to_account_info(), - authority: ctx.accounts.ido_account.to_account_info(), + mint: ctx.accounts.redeemable_mint.to_account_info().into(), + from: ctx.accounts.user_redeemable.to_account_info().into(), + authority: ctx.accounts.ido_account.to_account_info().into(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new_with_signer(cpi_program, cpi_accounts, signer); @@ -192,9 +196,9 @@ pub mod ido_pool { // Transfer Watermelon from pool account to user. let cpi_accounts = Transfer { - from: ctx.accounts.pool_watermelon.to_account_info(), - to: ctx.accounts.user_watermelon.to_account_info(), - authority: ctx.accounts.ido_account.to_account_info(), + from: ctx.accounts.pool_watermelon.to_account_info().into(), + to: ctx.accounts.user_watermelon.to_account_info().into(), + authority: ctx.accounts.ido_account.to_account_info().into(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new_with_signer(cpi_program, cpi_accounts, signer); @@ -204,9 +208,9 @@ pub mod ido_pool { ctx.accounts.user_redeemable.reload()?; if ctx.accounts.user_redeemable.amount == 0 { let cpi_accounts = CloseAccount { - account: ctx.accounts.user_redeemable.to_account_info(), - destination: ctx.accounts.user_authority.to_account_info(), - authority: ctx.accounts.ido_account.to_account_info(), + account: ctx.accounts.user_redeemable.to_account_info().into(), + destination: ctx.accounts.user_authority.to_account_info().into(), + authority: ctx.accounts.ido_account.to_account_info().into(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new_with_signer(cpi_program, cpi_accounts, signer); @@ -227,9 +231,9 @@ pub mod ido_pool { ]; let signer = &[&seeds[..]]; let cpi_accounts = Transfer { - from: ctx.accounts.pool_usdc.to_account_info(), - to: ctx.accounts.ido_authority_usdc.to_account_info(), - authority: ctx.accounts.ido_account.to_account_info(), + from: ctx.accounts.pool_usdc.to_account_info().into(), + to: ctx.accounts.ido_authority_usdc.to_account_info().into(), + authority: ctx.accounts.ido_account.to_account_info().into(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new_with_signer(cpi_program, cpi_accounts, signer); @@ -255,9 +259,9 @@ pub mod ido_pool { // Transfer USDC from user's escrow account to user's USDC account. let cpi_accounts = Transfer { - from: ctx.accounts.escrow_usdc.to_account_info(), - to: ctx.accounts.user_usdc.to_account_info(), - authority: ctx.accounts.ido_account.to_account_info(), + from: ctx.accounts.escrow_usdc.to_account_info().into(), + to: ctx.accounts.user_usdc.to_account_info().into(), + authority: ctx.accounts.ido_account.to_account_info().into(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new_with_signer(cpi_program, cpi_accounts, signer); @@ -267,9 +271,9 @@ pub mod ido_pool { ctx.accounts.escrow_usdc.reload()?; if ctx.accounts.escrow_usdc.amount == 0 { let cpi_accounts = CloseAccount { - account: ctx.accounts.escrow_usdc.to_account_info(), - destination: ctx.accounts.user_authority.to_account_info(), - authority: ctx.accounts.ido_account.to_account_info(), + account: ctx.accounts.escrow_usdc.to_account_info().into(), + destination: ctx.accounts.user_authority.to_account_info().into(), + authority: ctx.accounts.ido_account.to_account_info().into(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new_with_signer(cpi_program, cpi_accounts, signer); diff --git a/tests/swap/programs/swap/src/lib.rs b/tests/swap/programs/swap/src/lib.rs index b9b16899c4..4ec8380b81 100644 --- a/tests/swap/programs/swap/src/lib.rs +++ b/tests/swap/programs/swap/src/lib.rs @@ -206,11 +206,11 @@ impl<'info> From<&Swap<'info>> for OrderbookClient<'info> { fn from(accounts: &Swap<'info>) -> OrderbookClient<'info> { OrderbookClient { market: accounts.market.clone(), - authority: accounts.authority.to_account_info(), - pc_wallet: accounts.pc_wallet.to_account_info(), - dex_program: accounts.dex_program.to_account_info(), - token_program: accounts.token_program.to_account_info(), - rent: accounts.rent.to_account_info(), + authority: accounts.authority.to_account_info().into(), + pc_wallet: accounts.pc_wallet.to_account_info().into(), + dex_program: accounts.dex_program.to_account_info().into(), + token_program: accounts.token_program.to_account_info().into(), + rent: accounts.rent.to_account_info().into(), } } } @@ -239,21 +239,21 @@ impl<'info> SwapTransitive<'info> { fn orderbook_from(&self) -> OrderbookClient<'info> { OrderbookClient { market: self.from.clone(), - authority: self.authority.to_account_info(), - pc_wallet: self.pc_wallet.to_account_info(), - dex_program: self.dex_program.to_account_info(), - token_program: self.token_program.to_account_info(), - rent: self.rent.to_account_info(), + authority: self.authority.to_account_info().into(), + pc_wallet: self.pc_wallet.to_account_info().into(), + dex_program: self.dex_program.to_account_info().into(), + token_program: self.token_program.to_account_info().into(), + rent: self.rent.to_account_info().into(), } } fn orderbook_to(&self) -> OrderbookClient<'info> { OrderbookClient { market: self.to.clone(), - authority: self.authority.to_account_info(), - pc_wallet: self.pc_wallet.to_account_info(), - dex_program: self.dex_program.to_account_info(), - token_program: self.token_program.to_account_info(), - rent: self.rent.to_account_info(), + authority: self.authority.to_account_info().into(), + pc_wallet: self.pc_wallet.to_account_info().into(), + dex_program: self.dex_program.to_account_info().into(), + token_program: self.token_program.to_account_info().into(), + rent: self.rent.to_account_info().into(), } } } @@ -334,18 +334,22 @@ impl<'info> OrderbookClient<'info> { let limit = 65535; let dex_accs = dex::NewOrderV3 { - market: self.market.market.to_account_info(), - open_orders: self.market.open_orders.to_account_info(), - request_queue: self.market.request_queue.to_account_info(), - event_queue: self.market.event_queue.to_account_info(), - market_bids: self.market.bids.to_account_info(), - market_asks: self.market.asks.to_account_info(), - order_payer_token_account: self.market.order_payer_token_account.to_account_info(), - open_orders_authority: self.authority.to_account_info(), - coin_vault: self.market.coin_vault.to_account_info(), - pc_vault: self.market.pc_vault.to_account_info(), - token_program: self.token_program.to_account_info(), - rent: self.rent.to_account_info(), + market: self.market.market.to_account_info().into(), + open_orders: self.market.open_orders.to_account_info().into(), + request_queue: self.market.request_queue.to_account_info().into(), + event_queue: self.market.event_queue.to_account_info().into(), + market_bids: self.market.bids.to_account_info().into(), + market_asks: self.market.asks.to_account_info().into(), + order_payer_token_account: self + .market + .order_payer_token_account + .to_account_info() + .into(), + open_orders_authority: self.authority.to_account_info().into(), + coin_vault: self.market.coin_vault.to_account_info().into(), + pc_vault: self.market.pc_vault.to_account_info().into(), + token_program: self.token_program.to_account_info().into(), + rent: self.rent.to_account_info().into(), }; let mut ctx = CpiContext::new(self.dex_program.to_account_info(), dex_accs); if let Some(referral) = referral { @@ -366,15 +370,15 @@ impl<'info> OrderbookClient<'info> { fn settle(&self, referral: Option>) -> Result<()> { let settle_accs = dex::SettleFunds { - market: self.market.market.to_account_info(), - open_orders: self.market.open_orders.to_account_info(), - open_orders_authority: self.authority.to_account_info(), - coin_vault: self.market.coin_vault.to_account_info(), - pc_vault: self.market.pc_vault.to_account_info(), - coin_wallet: self.market.coin_wallet.to_account_info(), - pc_wallet: self.pc_wallet.to_account_info(), - vault_signer: self.market.vault_signer.to_account_info(), - token_program: self.token_program.to_account_info(), + market: self.market.market.to_account_info().into(), + open_orders: self.market.open_orders.to_account_info().into(), + open_orders_authority: self.authority.to_account_info().into(), + coin_vault: self.market.coin_vault.to_account_info().into(), + pc_vault: self.market.pc_vault.to_account_info().into(), + coin_wallet: self.market.coin_wallet.to_account_info().into(), + pc_wallet: self.pc_wallet.to_account_info().into(), + vault_signer: self.market.vault_signer.to_account_info().into(), + token_program: self.token_program.to_account_info().into(), }; let mut ctx = CpiContext::new(self.dex_program.to_account_info(), settle_accs); if let Some(referral) = referral { diff --git a/tests/yarn.lock b/tests/yarn.lock index f0a8cc1209..437dd856ee 100644 --- a/tests/yarn.lock +++ b/tests/yarn.lock @@ -16,28 +16,7 @@ dependencies: regenerator-runtime "^0.13.4" -"@coral-xyz/anchor@=0.27.0": - version "0.26.0" - resolved "https://registry.yarnpkg.com/@coral-xyz/anchor/-/anchor-0.26.0.tgz#c8e4f7177e93441afd030f22d777d54d0194d7d1" - integrity sha512-PxRl+wu5YyptWiR9F2MBHOLLibm87Z4IMUBPreX+DYBtPM+xggvcPi0KAN7+kIL4IrIhXI8ma5V0MCXxSN1pHg== - dependencies: - "@coral-xyz/borsh" "^0.26.0" - "@solana/web3.js" "^1.68.0" - base64-js "^1.5.1" - bn.js "^5.1.2" - bs58 "^4.0.1" - buffer-layout "^1.2.2" - camelcase "^6.3.0" - cross-fetch "^3.1.5" - crypto-hash "^1.3.0" - eventemitter3 "^4.0.7" - js-sha256 "^0.9.0" - pako "^2.0.3" - snake-case "^3.0.4" - superstruct "^0.15.4" - toml "^3.0.0" - -"@coral-xyz/anchor@file:../ts/packages/anchor": +"@coral-xyz/anchor@=0.27.0", "@coral-xyz/anchor@file:../ts/packages/anchor": version "0.27.0" dependencies: "@coral-xyz/borsh" "^0.27.0" @@ -56,10 +35,10 @@ superstruct "^0.15.4" toml "^3.0.0" -"@coral-xyz/borsh@^0.26.0", "@coral-xyz/borsh@^0.27.0": - version "0.26.0" - resolved "https://registry.yarnpkg.com/@coral-xyz/borsh/-/borsh-0.26.0.tgz#d054f64536d824634969e74138f9f7c52bbbc0d5" - integrity sha512-uCZ0xus0CszQPHYfWAqKS5swS1UxvePu83oOF+TWpUkedsNlg6p2p4azxZNSSqwXb9uXMFgxhuMBX9r3Xoi0vQ== +"@coral-xyz/borsh@^0.27.0": + version "0.27.0" + resolved "https://registry.yarnpkg.com/@coral-xyz/borsh/-/borsh-0.27.0.tgz#700c647ea5262b1488957ac7fb4e8acf72c72b63" + integrity sha512-tJKzhLukghTWPLy+n8K8iJKgBq1yLT/AxaNd10yJrX8mI56ao5+OFAKAqW/h0i79KCvb4BK0VGO5ECmmolFz9A== dependencies: bn.js "^5.1.2" buffer-layout "^1.2.0" diff --git a/tests/zero-copy/programs/zero-cpi/src/lib.rs b/tests/zero-copy/programs/zero-cpi/src/lib.rs index 3b25775b5c..f3b5e5355a 100644 --- a/tests/zero-copy/programs/zero-cpi/src/lib.rs +++ b/tests/zero-copy/programs/zero-cpi/src/lib.rs @@ -11,9 +11,9 @@ pub mod zero_cpi { pub fn check_cpi(ctx: Context, data: u64) -> Result<()> { let cpi_program = ctx.accounts.zero_copy_program.to_account_info(); let cpi_accounts = UpdateBar { - authority: ctx.accounts.authority.to_account_info(), - bar: ctx.accounts.bar.to_account_info(), - foo: ctx.accounts.foo.to_account_info(), + authority: ctx.accounts.authority.to_account_info().into(), + bar: ctx.accounts.bar.to_account_info().into(), + foo: ctx.accounts.foo.to_account_info().into(), }; let cpi_ctx = CpiContext::new(cpi_program, cpi_accounts); zero_copy::cpi::update_bar(cpi_ctx, data)?; From d8ace33b134f25c2da9a454f01c048806a614426 Mon Sep 17 00:00:00 2001 From: Jean Marchand Date: Sat, 10 Jun 2023 12:55:22 +0200 Subject: [PATCH 08/11] Squashed commit of the following: commit e1afcbf71e0f2e10fae14525934a6a68479167b9 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Fri Jun 9 18:00:35 2023 +0200 v0.28.0 (#2527) commit c7c73194d880a47d0d37f84af779d89588695f61 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Thu Jun 8 18:59:44 2023 +0200 Allow wider range of dependency versions to reduce dependency issues (#2524) commit 6df34e7678b8d8d329f446631142dcb8e76624a0 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Wed Jun 7 19:12:56 2023 +0200 Update crate authors and remove outdated registry (#2522) commit 1705d1637618eda0dabb06384aa14e8a0c960650 Author: Jean Marchand (Exotic Markets) Date: Wed Jun 7 16:29:23 2023 +0200 docs: Add doc for InitSpace macro (#2521) commit 3d7c97be90e3398f62fdeca9d288815b6205c687 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Tue Jun 6 19:28:24 2023 +0200 cli: Accept program lib name for `anchor deploy --program-name` (#2519) commit a88be4209a0f70535e57157fbe6ddb5af436f7a6 Author: Sergo Date: Tue Jun 6 14:07:33 2023 +0300 ts: Validate `error.data` exists on simulation response (#2508) commit 65c9d6e9b9a89806c3bdc67ed3948aeb125f364a Author: Jean Marchand (Exotic Markets) Date: Tue Jun 6 09:43:46 2023 +0200 client: Add async to anchor-client (#2488) Co-authored-by: acheron commit b8eda6980c895d709b2859ef456e0bc83675f903 Author: Deep Mehta <65382963+0xdeepmehta@users.noreply.github.com> Date: Mon Jun 5 22:35:24 2023 +0530 cli: Print not found message if the given program cannot be found during deployment (#2517) commit 1902b8e5868d65e4d5b8dd351192a6936d4d6130 Author: CanardMandarin Date: Mon Jun 5 14:16:10 2023 +0200 cli: Update programs in `Anchor.toml` when using `anchor new` (#2516) commit 383e44078811fdf26dc73a4ad834b812c7b5636e Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Sun Jun 4 21:02:16 2023 +0200 cli: Initialize with the correct program id (#2509) commit 835dc5b07f12bf9cfd40f1b6d309d210c1b44a74 Author: Sarfaraz Nawaz Date: Sun Jun 4 23:20:03 2023 +0530 lang: Rename derive_anchor_deserialize -> derive_init_space (#2510) commit 1c6f86e5f7793ce6adefe9cbfa11939647c509ce Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Sun Jun 4 13:09:39 2023 +0200 Upgrade Solana to 1.16.0 (#2512) commit 2bf8afebd2f77f43a2e1e36bb4bf016fe2f289c8 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Tue May 30 19:50:45 2023 +0200 cli: Use `confirmed` commitment level in commands (#2506) commit 70d922301e809a6c936a5fe73b99df9aba130fe6 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Sun May 28 22:34:53 2023 +0200 cli: Add `anchor keys sync` command (#2505) commit 0c8498d195df377bd0982d33db0a0225772afd16 Author: cavemanloverboy <93507302+cavemanloverboy@users.noreply.github.com> Date: Sat May 27 06:53:02 2023 -0700 cli: Exit `anchor clean` without error when dirs don't exist (#2504) commit 23b90bffc023058aec1004dbc0898c233fb6e9b0 Author: Noah Gundotra Date: Fri May 26 12:36:46 2023 -0400 Feature: CPI Events API (#2438) Co-authored-by: acheron commit c3625c8cf2ea1cb5f94859f6234c2d73c6f17928 Author: Last Emperor <46998219+lastemp@users.noreply.github.com> Date: Wed May 24 15:05:47 2023 +0300 examples: Add an example with `instruction` method (#2501) Co-authored-by: acheron commit 67eb7520b5ef738b4990bc44c292cfefcb63412e Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Sat May 20 20:34:38 2023 +0200 tests: Fix zero-copy tests (#2498) commit f9d0eca7040a7607e35e37b610e3600c1b78fd4e Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Fri May 19 13:18:14 2023 +0200 spl: Update `spl-token-2022` to 0.6.1 (#2496) commit 4793b90db17f233c30c8c9213756213f987a345b Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Fri May 19 10:58:16 2023 +0200 Fix `toml_datetime` 1.64.0 MSRV error (#2495) commit 41a4d820d3d376830e281852cf244a7b2adcbe7b Author: chalda Date: Thu May 18 19:12:25 2023 +0200 cli: Add print base64 instruction option for some of the IDL commands (#2486) Co-authored-by: acheron commit b7bada148cead931bc3bdae7e9a641e9be66e6a6 Author: Pierre Date: Tue May 16 23:46:40 2023 +1000 fix: remove skip preflight from cli (#2492) --------- Co-authored-by: acheron commit 89e94d1d6ae3c7af79ec1e329b8755c4a8155dfa Author: Ryan De La O Date: Sat May 13 02:17:47 2023 -0700 cli: Fix incorrect metadata.address generation (#2485) Currently when running 'anchor deploy --program-name --program-keypair ' the cli still uses the auto-generated keypair when fetching the program id to add to the IDL metadata at the end. It should instead use the address from the specified keypair. --------- Co-authored-by: acheron commit 714d5248636493a3d1db1481f16052836ee59e94 Author: CanardMandarin Date: Tue May 9 16:17:11 2023 +0200 lang: Add error message when Mint and TokenAccount with `init` are not ordered correctly (#2484) commit 9a93a2eccce37b3d3e3c390966ec11589a16d7ef Author: James Date: Mon May 8 10:17:51 2023 +0100 ts: Improve IDL typing (#2482) * Use XOR pattern for enum variants to prevent two variants being used at the same time. * Fix unknown for types like Option<[u8; 32]> commit d1ddf002935efedb3fcb4a28aa580afd3d1f88a6 Author: CanardMandarin Date: Sun May 7 11:03:37 2023 +0200 lang: Fix incorrectly checking the first init constraint (#2483) --- .github/actions/setup-ts/action.yaml | 6 +- .github/workflows/no-caching-tests.yaml | 2 +- .github/workflows/reusable-tests.yaml | 59 +- .github/workflows/tests.yaml | 2 +- CHANGELOG.md | 19 + Cargo.lock | 1924 +++++++++-------- Cargo.toml | 1 + LICENSE | 2 +- VERSION | 2 +- avm/Cargo.lock | 1259 ----------- avm/Cargo.toml | 14 +- bench/COMPUTE_UNITS.md | 270 ++- cli/Cargo.toml | 51 +- cli/npm-package/package.json | 2 +- cli/src/config.rs | 50 +- cli/src/lib.rs | 511 +++-- cli/src/rust_template.rs | 29 +- client/Cargo.toml | 25 +- client/example/Cargo.toml | 6 +- client/example/run-test.sh | 24 + client/example/src/blocking.rs | 329 +++ client/example/src/main.rs | 326 +-- client/example/src/nonblocking.rs | 306 +++ client/src/blocking.rs | 109 + client/src/lib.rs | 334 +-- client/src/nonblocking.rs | 102 + docker/Makefile | 4 +- docs/programs/tic-tac-toe/Anchor.toml | 3 - docs/programs/tic-tac-toe/Cargo.lock | 22 +- .../programs/tic-tac-toe/Cargo.toml | 2 +- docs/src/pages/docs/installation.md | 2 +- docs/src/pages/docs/publishing-source.md | 2 +- docs/src/pages/docs/release-notes.md | 30 + docs/src/pages/docs/space.md | 34 +- docs/src/pages/docs/verifiable-builds.md | 4 +- examples/tutorial/basic-0/package.json | 2 +- examples/tutorial/basic-1/package.json | 2 +- examples/tutorial/basic-2/package.json | 2 +- examples/tutorial/basic-3/package.json | 2 +- examples/tutorial/basic-4/package.json | 2 +- examples/tutorial/basic-5/Anchor.toml | 9 + examples/tutorial/basic-5/Cargo.toml | 4 + examples/tutorial/basic-5/README.md | 13 + examples/tutorial/basic-5/package.json | 19 + .../basic-5/programs/basic-5/Cargo.toml | 17 + .../basic-5/programs/basic-5/Xargo.toml | 2 + .../basic-5/programs/basic-5/src/lib.rs | 115 + examples/tutorial/basic-5/tests/basic-5.ts | 120 + examples/tutorial/basic-5/tsconfig.json | 10 + examples/tutorial/package.json | 13 +- examples/tutorial/yarn.lock | 568 +---- lang/Cargo.toml | 38 +- lang/attribute/access-control/Cargo.toml | 16 +- lang/attribute/account/Cargo.toml | 18 +- lang/attribute/constant/Cargo.toml | 10 +- lang/attribute/error/Cargo.toml | 12 +- lang/attribute/event/Cargo.toml | 15 +- lang/attribute/event/src/lib.rs | 139 +- lang/attribute/program/Cargo.toml | 14 +- lang/derive/accounts/Cargo.toml | 14 +- lang/derive/accounts/src/lib.rs | 2 +- lang/derive/space/Cargo.toml | 10 +- lang/derive/space/src/lib.rs | 2 +- lang/src/error.rs | 5 + lang/src/event.rs | 3 + lang/src/lib.rs | 6 + lang/syn/Cargo.toml | 25 +- lang/syn/src/codegen/program/dispatch.rs | 31 +- lang/syn/src/codegen/program/handlers.rs | 52 +- lang/syn/src/parser/accounts/event_cpi.rs | 70 + lang/syn/src/parser/accounts/mod.rs | 59 +- lang/tests/generics_test.rs | 4 + spl/Cargo.toml | 23 +- spl/src/token_2022.rs | 2 +- tests/anchor-cli-account/Anchor.toml | 3 - tests/anchor-cli-account/package.json | 2 +- .../programs/account-command/Cargo.toml | 2 +- tests/anchor-cli-idl/Anchor.toml | 3 - tests/anchor-cli-idl/package.json | 2 +- tests/bench/bench.json | 245 ++- tests/bench/package.json | 2 +- tests/bench/programs/bench/Cargo.toml | 5 - tests/bpf-upgradeable-state/Anchor.toml | 3 - tests/cashiers-check/package.json | 2 +- tests/cfo/package.json | 2 +- tests/cfo/programs/cfo/src/lib.rs | 2 +- tests/chat/package.json | 2 +- tests/composite/package.json | 2 +- tests/cpi-returns/Anchor.toml | 3 - tests/cpi-returns/package.json | 2 +- tests/custom-coder/Anchor.toml | 3 - tests/custom-coder/package.json | 2 +- tests/declare-id/package.json | 2 +- tests/docs/package.json | 2 +- tests/errors/package.json | 2 +- tests/escrow/package.json | 2 +- tests/escrow/programs/escrow/Cargo.toml | 1 - tests/escrow/programs/escrow/src/lib.rs | 6 +- tests/events/package.json | 2 +- tests/events/programs/events/Cargo.toml | 2 +- tests/events/programs/events/src/lib.rs | 12 + tests/events/tests/events.js | 134 +- tests/floats/Anchor.toml | 3 - tests/floats/package.json | 2 +- tests/ido-pool/package.json | 2 +- tests/lockup/package.json | 2 +- tests/misc/package.json | 2 +- tests/multiple-suites-run-single/Anchor.toml | 3 - tests/multiple-suites/Anchor.toml | 3 - tests/multiple-suites/package.json | 2 +- tests/multisig/package.json | 2 +- tests/optional/package.json | 2 +- tests/package.json | 6 - tests/pda-derivation/package.json | 2 +- tests/pyth/package.json | 2 +- tests/realloc/Anchor.toml | 3 - tests/realloc/package.json | 2 +- tests/relations-derivation/package.json | 2 +- tests/safety-checks/Anchor.toml | 3 - tests/spl/token-proxy/package.json | 2 +- .../programs/token-proxy/Cargo.toml | 1 - .../programs/token-proxy/src/lib.rs | 10 +- tests/spl/token-wrapper/package.json | 2 +- .../programs/token-wrapper/Cargo.toml | 1 - tests/swap/package.json | 2 +- tests/system-accounts/package.json | 2 +- tests/sysvars/package.json | 2 +- tests/tictactoe/package.json | 2 +- tests/typescript/package.json | 2 +- tests/validator-clone/Anchor.toml | 3 - tests/validator-clone/package.json | 2 +- tests/yarn.lock | 84 +- tests/zero-copy/package.json | 2 +- tests/zero-copy/programs/zero-copy/Cargo.toml | 4 +- .../zero-copy/tests/compute_unit_test.rs | 2 +- tests/zero-copy/rust-toolchain.toml | 3 + ts/packages/anchor/package.json | 4 +- .../anchor/src/program/accounts-resolver.ts | 51 + .../anchor/src/program/namespace/types.ts | 48 +- ts/packages/anchor/src/utils/rpc.ts | 2 +- ts/packages/borsh/package.json | 2 +- .../spl-associated-token-account/package.json | 2 +- ts/packages/spl-binary-option/package.json | 2 +- .../spl-binary-oracle-pair/package.json | 2 +- ts/packages/spl-feature-proposal/package.json | 2 +- ts/packages/spl-governance/package.json | 2 +- ts/packages/spl-memo/package.json | 2 +- ts/packages/spl-name-service/package.json | 2 +- ts/packages/spl-record/package.json | 2 +- ts/packages/spl-stake-pool/package.json | 2 +- ts/packages/spl-stateless-asks/package.json | 2 +- ts/packages/spl-token-lending/package.json | 2 +- ts/packages/spl-token-swap/package.json | 2 +- ts/packages/spl-token/package.json | 4 +- 154 files changed, 4125 insertions(+), 3968 deletions(-) delete mode 100644 avm/Cargo.lock create mode 100644 client/example/src/blocking.rs create mode 100644 client/example/src/nonblocking.rs create mode 100644 client/src/blocking.rs create mode 100644 client/src/nonblocking.rs create mode 100644 examples/tutorial/basic-5/Anchor.toml create mode 100644 examples/tutorial/basic-5/Cargo.toml create mode 100644 examples/tutorial/basic-5/README.md create mode 100644 examples/tutorial/basic-5/package.json create mode 100644 examples/tutorial/basic-5/programs/basic-5/Cargo.toml create mode 100644 examples/tutorial/basic-5/programs/basic-5/Xargo.toml create mode 100644 examples/tutorial/basic-5/programs/basic-5/src/lib.rs create mode 100644 examples/tutorial/basic-5/tests/basic-5.ts create mode 100644 examples/tutorial/basic-5/tsconfig.json create mode 100644 lang/src/event.rs create mode 100644 lang/syn/src/parser/accounts/event_cpi.rs create mode 100644 tests/zero-copy/rust-toolchain.toml diff --git a/.github/actions/setup-ts/action.yaml b/.github/actions/setup-ts/action.yaml index 2db49efd10..590f6a68a1 100644 --- a/.github/actions/setup-ts/action.yaml +++ b/.github/actions/setup-ts/action.yaml @@ -20,7 +20,7 @@ runs: path: | ./ts/dist/ key: solana-${{ runner.os }}-v0000-${{ env.NODE_VERSION }}-${{ hashFiles('./ts/**/*.ts') }} - - run: cd ts/packages/borsh && yarn --frozen-lockfile && yarn build && cd ../../../ + - run: cd ts/packages/borsh && yarn --frozen-lockfile && yarn build && yarn link && cd ../../../ shell: bash - run: cd ts/packages/anchor && yarn --frozen-lockfile && yarn build:node && yarn link && cd ../../../ shell: bash @@ -28,7 +28,7 @@ runs: shell: bash - run: cd ts/packages/spl-token && yarn --frozen-lockfile && yarn build:node && yarn link && cd ../../../ shell: bash - - run: cd examples/tutorial && yarn link @coral-xyz/anchor && yarn --frozen-lockfile && cd ../../ + - run: cd examples/tutorial && yarn link @coral-xyz/anchor @coral-xyz/borsh && yarn --frozen-lockfile && cd ../../ shell: bash - - run: cd tests && yarn link @coral-xyz/anchor && yarn link @coral-xyz/spl-associated-token-account && yarn link @coral-xyz/spl-token && yarn --frozen-lockfile && cd .. + - run: cd tests && yarn link @coral-xyz/anchor @coral-xyz/borsh @coral-xyz/spl-associated-token-account @coral-xyz/spl-token && yarn --frozen-lockfile && cd .. shell: bash diff --git a/.github/workflows/no-caching-tests.yaml b/.github/workflows/no-caching-tests.yaml index c87e985de8..3338e84c91 100644 --- a/.github/workflows/no-caching-tests.yaml +++ b/.github/workflows/no-caching-tests.yaml @@ -11,7 +11,7 @@ jobs: uses: ./.github/workflows/reusable-tests.yaml with: cache: false - solana_cli_version: 1.14.16 + solana_cli_version: 1.16.0 node_version: 17.0.1 cargo_profile: release anchor_binary_name: anchor-binary-no-caching diff --git a/.github/workflows/reusable-tests.yaml b/.github/workflows/reusable-tests.yaml index e69c38a7da..b6cc067bd1 100644 --- a/.github/workflows/reusable-tests.yaml +++ b/.github/workflows/reusable-tests.yaml @@ -332,33 +332,34 @@ jobs: # - run: cd tests/misc && chmod +x ci.sh && ./ci.sh # - run: cd tests/misc && anchor test --skip-lint - test-anchor-init: - needs: setup-anchor-cli - name: Test Anchor Init - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/setup/ - - uses: ./.github/actions/setup-ts/ - - uses: ./.github/actions/setup-solana/ + # TODO: Re-enable after releasing `0.28.0`. See https://github.com/coral-xyz/anchor/pull/2512 + # test-anchor-init: + # needs: setup-anchor-cli + # name: Test Anchor Init + # runs-on: ubuntu-latest + # timeout-minutes: 30 + # steps: + # - uses: actions/checkout@v3 + # - uses: ./.github/actions/setup/ + # - uses: ./.github/actions/setup-ts/ + # - uses: ./.github/actions/setup-solana/ - - uses: actions/cache@v3 - if: ${{ env.CACHE != 'false' }} - name: Cache Cargo registry + index - id: cache-anchor - with: - path: ${{ env.CARGO_CACHE_PATH }} - key: cargo-${{ runner.os }}-${{ env.CARGO_PROFILE }}-anchor-${{ hashFiles('**/Cargo.lock') }} + # - uses: actions/cache@v3 + # if: ${{ env.CACHE != 'false' }} + # name: Cache Cargo registry + index + # id: cache-anchor + # with: + # path: ${{ env.CARGO_CACHE_PATH }} + # key: cargo-${{ runner.os }}-${{ env.CARGO_PROFILE }}-anchor-${{ hashFiles('**/Cargo.lock') }} - - uses: actions/download-artifact@v3 - with: - name: ${{ env.ANCHOR_BINARY_NAME }} - path: ~/.cargo/bin/ - - run: chmod +x ~/.cargo/bin/anchor + # - uses: actions/download-artifact@v3 + # with: + # name: ${{ env.ANCHOR_BINARY_NAME }} + # path: ~/.cargo/bin/ + # - run: chmod +x ~/.cargo/bin/anchor - - run: cd "$(mktemp -d)" && anchor init hello-anchor && cd hello-anchor && yarn link @coral-xyz/anchor && yarn && anchor test && yarn lint:fix - - uses: ./.github/actions/git-diff/ + # - run: cd "$(mktemp -d)" && anchor init hello-anchor && cd hello-anchor && yarn link @coral-xyz/anchor && yarn && anchor test && yarn lint:fix + # - uses: ./.github/actions/git-diff/ test-programs: needs: setup-anchor-cli @@ -383,7 +384,9 @@ jobs: path: tests/multisig # - cmd: cd tests/lockup && anchor test --skip-lint # path: tests/lockup - - cmd: cd tests/swap/deps/openbook-dex/dex && cargo build-bpf -- --locked && cd ../../../ && anchor test --skip-lint + # TODO: Remove `1.14.18` installation if/when https://github.com/solana-labs/solana/issues/31960 is solved + # `swap` tests don't work with Solana `1.16.0`, downgrade to `1.14.18` + - cmd: cd tests/swap/deps/openbook-dex/dex && solana-install init 1.14.18 && cargo build-bpf -- --locked && cd ../../../ && solana-install init $SOLANA_CLI_VERSION && anchor test --skip-lint path: tests/swap - cmd: cd tests/escrow && anchor test --skip-lint && npx tsc --noEmit path: tests/escrow @@ -403,7 +406,7 @@ jobs: path: tests/declare-id - cmd: cd tests/typescript && anchor test --skip-lint && npx tsc --noEmit path: tests/typescript - - cmd: cd tests/zero-copy && anchor test --skip-lint && cd programs/zero-copy && cargo test-bpf + - cmd: cd tests/zero-copy && rustup toolchain install 1.66.1-x86_64-unknown-linux-gnu && anchor test --skip-lint && cd programs/zero-copy && cargo test-bpf path: tests/zero-copy - cmd: cd tests/chat && anchor test --skip-lint path: tests/chat @@ -411,7 +414,9 @@ jobs: path: tests/ido-pool # - cmd: cd tests/cfo && anchor run test-with-build && cd deps/stake && git checkout Cargo.lock && cd ../swap && git checkout Cargo.lock # path: tests/cfo - - cmd: cd tests/auction-house && yarn --frozen-lockfile && anchor test --skip-lint && git checkout Cargo.lock + # TODO: Remove `1.14.18` installation if/when https://github.com/solana-labs/solana/issues/31960 is solved + # `auction-house` tests don't work with Solana `1.16.0`, downgrade to `1.14.18` + - cmd: cd tests/auction-house && solana-install init 1.14.18 && yarn --frozen-lockfile && anchor test --skip-lint && git checkout Cargo.lock path: tests/auction-house - cmd: cd tests/floats && yarn --frozen-lockfile && anchor test --skip-lint && npx tsc --noEmit path: tests/floats diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 9bcdb0401f..bf903d19fe 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -14,7 +14,7 @@ jobs: uses: ./.github/workflows/reusable-tests.yaml with: cache: true - solana_cli_version: 1.14.16 + solana_cli_version: 1.16.0 node_version: 17.0.1 cargo_profile: debug anchor_binary_name: anchor-binary diff --git a/CHANGELOG.md b/CHANGELOG.md index 9817b2d820..d767462ad7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,15 +12,34 @@ The minor version will be incremented upon a breaking change and the patch versi ### Features +### Fixes + +### Breaking + +## [0.28.0] - 2023-06-09 + +### Features + +- client: Add `async` feature flag to use an asynchronous anchor-client ([#2488](https://github.com/coral-xyz/anchor/pull/2488)). - spl: Add metadata wrappers `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](https://github.com/coral-xyz/anchor/pull/2430)) - spl: Add `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](https://github.com/coral-xyz/anchor/pull/2460)) - cli: Add support for Solidity programs. `anchor init` and `anchor new` take an option `--solidity` which creates solidity code rather than rust. `anchor build` and `anchor test` work accordingly ([#2421](https://github.com/coral-xyz/anchor/pull/2421)) - bench: Add benchmarking for compute units usage ([#2466](https://github.com/coral-xyz/anchor/pull/2466)) +- cli: `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](https://github.com/coral-xyz/anchor/pull/2486)). +- lang: Add `emit_cpi!` and `#[event_cpi]` macros(behind `event-cpi` feature flag) to store event logs in transaction metadata ([#2438](https://github.com/coral-xyz/anchor/pull/2438)). +- cli: Add `keys sync` command to sync program id declarations ([#2505](https://github.com/coral-xyz/anchor/pull/2505)). +- cli: Create new programs with correct program ids ([#2509](https://github.com/coral-xyz/anchor/pull/2509)). +- cli, client, lang, spl: Update Solana toolchain and dependencies to `1.16.0` and specify maximum version of `<1.17.0` ([#2512](https://github.com/coral-xyz/anchor/pull/2512)). +- cli: `anchor deploy` command's `--program-name` argument accepts program lib names ([#2519](https://github.com/coral-xyz/anchor/pull/2519)). ### Fixes - ts: Narrowed `AccountClient` type to it's appropriate account type ([#2440](https://github.com/coral-xyz/anchor/pull/2440)) - lang: Fix inability to use identifiers `program_id`, `accounts`, `ix_data`, `remaining_accounts` in instruction arguments ([#2464](https://github.com/coral-xyz/anchor/pull/2464)) +- cli: Fix incorrect `metadata.address` generation in IDL after deploying with a custom keypair ([#2485](https://github.com/coral-xyz/anchor/pull/2485)) +- cli: IDL commands no longer hang when the payer doesn't have funds to pay for the transaction fee ([#2492](https://github.com/coral-xyz/anchor/pull/2492)) +- cli: Fix `anchor new` not updating `Anchor.toml` ([#2516](https://github.com/coral-xyz/anchor/pull/2516)). +- client, lang, spl: Allow wider range of dependency versions to reduce dependency issues ([#2524](https://github.com/coral-xyz/anchor/pull/2524)). ### Breaking diff --git a/Cargo.lock b/Cargo.lock index a56e49d6c6..88b5768d6e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -34,7 +34,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" dependencies = [ "cfg-if", - "cipher 0.3.0", + "cipher", "cpufeatures", "opaque-debug", ] @@ -47,7 +47,7 @@ checksum = "589c637f0e68c877bbd59a4599bbe849cac8e5f3e4b5a3ebae8f528cd218dcdc" dependencies = [ "aead", "aes", - "cipher 0.3.0", + "cipher", "ctr", "polyval", "subtle", @@ -60,16 +60,28 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.8", + "getrandom 0.2.10", + "once_cell", + "version_check", +] + +[[package]] +name = "ahash" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +dependencies = [ + "cfg-if", + "getrandom 0.2.10", "once_cell", "version_check", ] [[package]] name = "aho-corasick" -version = "0.7.19" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" +checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" dependencies = [ "memchr", ] @@ -97,88 +109,91 @@ checksum = "6b2d54853319fd101b8dd81de382bcbf3e03410a64d8928bbee85a3e7dcde483" [[package]] name = "anchor-attribute-access-control" -version = "0.27.0" +version = "0.28.0" dependencies = [ "anchor-syn", "anyhow", - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.60", + "quote 1.0.28", "regex", "syn 1.0.109", ] [[package]] name = "anchor-attribute-account" -version = "0.27.0" +version = "0.28.0" dependencies = [ "anchor-syn", "anyhow", - "bs58 0.4.0", - "proc-macro2 1.0.56", - "quote 1.0.26", + "bs58 0.5.0", + "proc-macro2 1.0.60", + "quote 1.0.28", "rustversion", "syn 1.0.109", ] [[package]] name = "anchor-attribute-constant" -version = "0.27.0" +version = "0.28.0" dependencies = [ "anchor-syn", - "proc-macro2 1.0.56", + "proc-macro2 1.0.60", "syn 1.0.109", ] [[package]] name = "anchor-attribute-error" -version = "0.27.0" +version = "0.28.0" dependencies = [ "anchor-syn", - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.60", + "quote 1.0.28", "syn 1.0.109", ] [[package]] name = "anchor-attribute-event" -version = "0.27.0" +version = "0.28.0" dependencies = [ "anchor-syn", "anyhow", - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.60", + "quote 1.0.28", "syn 1.0.109", ] [[package]] name = "anchor-attribute-program" -version = "0.27.0" +version = "0.28.0" dependencies = [ "anchor-syn", "anyhow", - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.60", + "quote 1.0.28", "syn 1.0.109", ] [[package]] name = "anchor-cli" -version = "0.27.0" +version = "0.28.0" dependencies = [ "anchor-client", "anchor-lang", "anchor-syn", "anyhow", + "base64 0.13.1", + "bincode", "cargo_toml", "chrono", - "clap 4.2.4", + "clap 4.3.2", "dirs", "flate2", - "heck 0.4.0", + "heck 0.4.1", "pathdiff", "portpicker", + "regex", "reqwest", - "semver 1.0.16", + "semver", "serde", "serde_json", "shellexpand", @@ -197,42 +212,44 @@ dependencies = [ [[package]] name = "anchor-client" -version = "0.27.0" +version = "0.28.0" dependencies = [ "anchor-lang", "anyhow", + "futures", "regex", "serde", "solana-account-decoder", "solana-client", "solana-sdk", "thiserror", + "tokio", "url", ] [[package]] name = "anchor-derive-accounts" -version = "0.27.0" +version = "0.28.0" dependencies = [ "anchor-syn", "anyhow", - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.60", + "quote 1.0.28", "syn 1.0.109", ] [[package]] name = "anchor-derive-space" -version = "0.27.0" +version = "0.28.0" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.60", + "quote 1.0.28", "syn 1.0.109", ] [[package]] name = "anchor-lang" -version = "0.27.0" +version = "0.28.0" dependencies = [ "anchor-attribute-access-control", "anchor-attribute-account", @@ -245,43 +262,49 @@ dependencies = [ "arrayref", "base64 0.13.1", "bincode", - "borsh", + "borsh 0.10.3", "bytemuck", + "getrandom 0.2.10", "solana-program", "thiserror", ] [[package]] name = "anchor-spl" -version = "0.27.0" +version = "0.28.0" dependencies = [ "anchor-lang", - "borsh", + "borsh 0.10.3", "mpl-token-metadata", "serum_dex", "solana-program", "spl-associated-token-account", "spl-token", "spl-token-2022", - "winnow", ] [[package]] name = "anchor-syn" -version = "0.27.0" +version = "0.28.0" dependencies = [ "anyhow", - "bs58 0.3.1", + "bs58 0.5.0", "heck 0.3.3", - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.60", + "quote 1.0.28", "serde", "serde_json", - "sha2 0.9.9", + "sha2 0.10.6", "syn 1.0.109", "thiserror", ] +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + [[package]] name = "android_system_properties" version = "0.1.5" @@ -302,9 +325,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6342bd4f5a1205d7f41e94a41a901f5647c938cdfa96036338e8533c9d6c2450" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" dependencies = [ "anstyle", "anstyle-parse", @@ -351,15 +374,15 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.66" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" +checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" [[package]] name = "ark-bn254" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea691771ebbb28aea556c044e2e5c5227398d840cee0c34d4d20fa8eb2689e8c" +checksum = "a22f4561524cd949590d78d7d4c5df8f592430d221f7f3c9497bbafd8972120f" dependencies = [ "ark-ec", "ark-ff", @@ -368,73 +391,105 @@ dependencies = [ [[package]] name = "ark-ec" -version = "0.3.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea978406c4b1ca13c2db2373b05cc55429c3575b8b21f1b9ee859aa5b03dd42" +checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" dependencies = [ "ark-ff", + "ark-poly", "ark-serialize", "ark-std", "derivative", + "hashbrown 0.13.2", + "itertools 0.10.5", "num-traits", "zeroize", ] [[package]] name = "ark-ff" -version = "0.3.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b3235cc41ee7a12aaaf2c575a2ad7b46713a8a50bda2fc3b003a04845c05dd6" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" dependencies = [ "ark-ff-asm", "ark-ff-macros", "ark-serialize", "ark-std", "derivative", + "digest 0.10.7", + "itertools 0.10.5", "num-bigint 0.4.3", "num-traits", "paste", - "rustc_version 0.3.3", + "rustc_version", "zeroize", ] [[package]] name = "ark-ff-asm" -version = "0.3.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db02d390bf6643fb404d3d22d31aee1c4bc4459600aef9113833d17e786c6e44" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" dependencies = [ - "quote 1.0.26", + "quote 1.0.28", "syn 1.0.109", ] [[package]] name = "ark-ff-macros" -version = "0.3.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" dependencies = [ "num-bigint 0.4.3", "num-traits", - "quote 1.0.26", + "proc-macro2 1.0.60", + "quote 1.0.28", "syn 1.0.109", ] +[[package]] +name = "ark-poly" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", +] + [[package]] name = "ark-serialize" -version = "0.3.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6c2b318ee6e10f8c2853e73a83adc0ccb88995aa978d8a3408d492ab2ee671" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" dependencies = [ + "ark-serialize-derive", "ark-std", - "digest 0.9.0", + "digest 0.10.7", + "num-bigint 0.4.3", +] + +[[package]] +name = "ark-serialize-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" +dependencies = [ + "proc-macro2 1.0.60", + "quote 1.0.28", + "syn 1.0.109", ] [[package]] name = "ark-std" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" dependencies = [ "num-traits", "rand 0.8.5", @@ -448,9 +503,9 @@ checksum = "9ad284aeb45c13f2fb4f084de4a420ebf447423bdf9386c0540ce33cb3ef4b8c" [[package]] name = "arrayref" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" [[package]] name = "arrayvec" @@ -475,9 +530,9 @@ dependencies = [ [[package]] name = "asn1-rs" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf6690c370453db30743b373a60ba498fc0d6d83b11f4abfd87a84a075db5dd4" +checksum = "7f6fd5ddaf0351dff5b8da21b2fb4ff8e08ddd02857f0bf69c47639106c0fff0" dependencies = [ "asn1-rs-derive", "asn1-rs-impl", @@ -486,7 +541,7 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.16", + "time 0.3.22", ] [[package]] @@ -495,8 +550,8 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "726535892e8eae7e70657b4c8ea93d26b8553afb1ce617caee529ef96d7dee6c" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.60", + "quote 1.0.28", "syn 1.0.109", "synstructure", ] @@ -507,8 +562,8 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2777730b2039ac0f95f093556e61b6d26cebed5393ca6f152717777cec3a42ed" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.60", + "quote 1.0.28", "syn 1.0.109", ] @@ -518,6 +573,17 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" +[[package]] +name = "async-channel" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833" +dependencies = [ + "concurrent-queue", + "event-listener", + "futures-core", +] + [[package]] name = "async-compression" version = "0.3.15" @@ -543,13 +609,13 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.58" +version = "0.1.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e805d94e6b5001b651426cf4cd446b1ab5f319d27bab5c644f61de0a804360c" +checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 1.0.109", + "proc-macro2 1.0.60", + "quote 1.0.28", + "syn 2.0.18", ] [[package]] @@ -569,6 +635,23 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "avm" +version = "0.28.0" +dependencies = [ + "anyhow", + "cfg-if", + "clap 4.3.2", + "dirs", + "once_cell", + "reqwest", + "semver", + "serde", + "serde_json", + "tempfile", + "thiserror", +] + [[package]] name = "base64" version = "0.12.3" @@ -581,11 +664,17 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +[[package]] +name = "base64" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" + [[package]] name = "base64ct" -version = "1.5.3" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "bincode" @@ -628,16 +717,16 @@ dependencies = [ [[package]] name = "blake3" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08e53fc5a564bb15bfe6fae56bd71522205f1f91893f9c0116edad6496c183f" +checksum = "729b71f35bd3fa1a4c86b85d32c8b9069ea7fe14f7a53cfabb65f62d4265b888" dependencies = [ "arrayref", "arrayvec", "cc", "cfg-if", "constant_time_eq", - "digest 0.10.5", + "digest 0.10.7", ] [[package]] @@ -652,9 +741,9 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array", ] @@ -671,20 +760,43 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15bf3650200d8bffa99015595e10f1fbd17de07abbc25bb067da79e769939bfa" dependencies = [ - "borsh-derive", + "borsh-derive 0.9.3", "hashbrown 0.11.2", ] +[[package]] +name = "borsh" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" +dependencies = [ + "borsh-derive 0.10.3", + "hashbrown 0.13.2", +] + [[package]] name = "borsh-derive" version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6441c552f230375d18e3cc377677914d2ca2b0d36e52129fe15450a2dce46775" dependencies = [ - "borsh-derive-internal", - "borsh-schema-derive-internal", + "borsh-derive-internal 0.9.3", + "borsh-schema-derive-internal 0.9.3", + "proc-macro-crate 0.1.5", + "proc-macro2 1.0.60", + "syn 1.0.109", +] + +[[package]] +name = "borsh-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0754613691538d51f329cce9af41d7b7ca150bc973056f1156611489475f54f7" +dependencies = [ + "borsh-derive-internal 0.10.3", + "borsh-schema-derive-internal 0.10.3", "proc-macro-crate 0.1.5", - "proc-macro2 1.0.56", + "proc-macro2 1.0.60", "syn 1.0.109", ] @@ -694,8 +806,19 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5449c28a7b352f2d1e592a8a28bf139bc71afb0764a14f3c02500935d8c44065" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.60", + "quote 1.0.28", + "syn 1.0.109", +] + +[[package]] +name = "borsh-derive-internal" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb" +dependencies = [ + "proc-macro2 1.0.60", + "quote 1.0.28", "syn 1.0.109", ] @@ -705,8 +828,19 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdbd5696d8bfa21d53d9fe39a714a18538bad11492a42d066dbbc395fb1951c0" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.60", + "quote 1.0.28", + "syn 1.0.109", +] + +[[package]] +name = "borsh-schema-derive-internal" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd" +dependencies = [ + "proc-macro2 1.0.60", + "quote 1.0.28", "syn 1.0.109", ] @@ -723,9 +857,9 @@ dependencies = [ [[package]] name = "brotli-decompressor" -version = "2.3.2" +version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ad2d4653bf5ca36ae797b1f4bb4dbddb60ce49ca4aed8a2ce4829f60425b80" +checksum = "4b6561fd3f895a11e8f72af2cb7d22e08366bebc2b6b57f7744c4bda27034744" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -733,21 +867,24 @@ dependencies = [ [[package]] name = "bs58" -version = "0.3.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "476e9cd489f9e121e02ffa6014a8ef220ecb15c05ed23fc34cca13925dc283fb" +checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bs58" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" +checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" +dependencies = [ + "tinyvec", +] [[package]] name = "bumpalo" -version = "3.11.1" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" +checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" [[package]] name = "bv" @@ -761,22 +898,22 @@ dependencies = [ [[package]] name = "bytemuck" -version = "1.12.1" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f5715e491b5a1598fc2bef5a606847b5dc1d48ea625bd3c02c00de8285591da" +checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" dependencies = [ "bytemuck_derive", ] [[package]] name = "bytemuck_derive" -version = "1.2.1" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9e1f5fa78f69496407a27ae9ed989e3c3b072310286f5ef385525e4cbc24a9" +checksum = "fdde5c9cd29ebd706ce1b35600920a33550e402fc998a2e53ad3b42c3c47a192" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 1.0.109", + "proc-macro2 1.0.60", + "quote 1.0.28", + "syn 2.0.18", ] [[package]] @@ -787,15 +924,15 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.2.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "caps" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938c50180feacea622ef3b8f4a496057c868dcf8ac7a64d781dd8f3f51a9c143" +checksum = "190baaad529bcfbde9e1a19022c42781bdb6ff9de25721abdb8fd98c0807730b" dependencies = [ "libc", "thiserror", @@ -803,9 +940,9 @@ dependencies = [ [[package]] name = "cargo_toml" -version = "0.13.0" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa0e3586af56b3bfa51fca452bd56e8dbbbd5d8d81cbf0b7e4e35b695b537eb8" +checksum = "497049e9477329f8f6a559972ee42e117487d01d1e8c2cc9f836ea6fa23a9e1a" dependencies = [ "serde", "toml", @@ -828,16 +965,16 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.22" +version = "0.4.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1" +checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" dependencies = [ + "android-tzdata", "iana-time-zone", "js-sys", - "num-integer", "num-traits", "serde", - "time 0.1.44", + "time 0.1.45", "wasm-bindgen", "winapi", ] @@ -851,16 +988,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "cipher" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1873270f8f7942c191139cb8a40fd228da6c3fd2fc376d7e92d47aa14aeb59e" -dependencies = [ - "crypto-common", - "inout", -] - [[package]] name = "clap" version = "2.34.0" @@ -878,9 +1005,9 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.23" +version = "3.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" +checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ "atty", "bitflags", @@ -894,9 +1021,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.2.4" +version = "4.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ac1f6381d8d82ab4684768f89c0ea3afe66925ceadb4eeb3fc452ffc55d62" +checksum = "401a4694d2bf92537b6867d94de48c4842089645fdcdf6c71865b175d836e9c2" dependencies = [ "clap_builder", "clap_derive", @@ -905,27 +1032,27 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.2.4" +version = "4.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84080e799e54cff944f4b4a4b0e71630b0e0443b25b985175c7dddc1a859b749" +checksum = "72394f3339a76daf211e57d4bcb374410f3965dcc606dd0e03738c7888766980" dependencies = [ "anstream", "anstyle", "bitflags", - "clap_lex 0.4.1", + "clap_lex 0.5.0", "strsim 0.10.0", ] [[package]] name = "clap_derive" -version = "4.2.0" +version = "4.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9644cd56d6b87dbe899ef8b053e331c0637664e9e21a33dfcdc36093f5c5c4" +checksum = "b8cd2b2a819ad6eec39e8f1d6b53001af1e5469f8c177579cdaeb313115b825f" dependencies = [ - "heck 0.4.0", - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 2.0.15", + "heck 0.4.1", + "proc-macro2 1.0.60", + "quote 1.0.28", + "syn 2.0.18", ] [[package]] @@ -939,19 +1066,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" - -[[package]] -name = "codespan-reporting" -version = "0.11.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" -dependencies = [ - "termcolor", - "unicode-width", -] +checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" [[package]] name = "colorchoice" @@ -972,18 +1089,26 @@ dependencies = [ "unreachable", ] +[[package]] +name = "concurrent-queue" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62ec6771ecfa0762d24683ee5a32ad78487a3d3afdc0fb8cae19d2c5deb50b7c" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "console" -version = "0.15.2" +version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c050367d967ced717c04b65d8c619d863ef9292ce0c5760028655a2fb298718c" +checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8" dependencies = [ "encode_unicode", "lazy_static", "libc", - "terminal_size", "unicode-width", - "winapi", + "windows-sys 0.45.0", ] [[package]] @@ -998,9 +1123,9 @@ dependencies = [ [[package]] name = "console_log" -version = "0.2.0" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501a375961cef1a0d44767200e66e4a559283097e91d0730b1d75dfb2f8a1494" +checksum = "e89f72f65e8501878b8a004d5a1afb780987e2ce2b4532c562e367a72c57499f" dependencies = [ "log", "web-sys", @@ -1014,9 +1139,9 @@ checksum = "e4c78c047431fee22c1a7bb92e00ad095a02a983affe4d8a72e2a2c62c1b94f3" [[package]] name = "constant_time_eq" -version = "0.1.5" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +checksum = "13418e745008f7349ec7e449155f419a61b92b58a99cc3616942b926825ec76b" [[package]] name = "core-foundation" @@ -1030,15 +1155,15 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "cpufeatures" -version = "0.2.5" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" dependencies = [ "libc", ] @@ -1054,9 +1179,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.6" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" dependencies = [ "cfg-if", "crossbeam-utils", @@ -1064,9 +1189,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" dependencies = [ "cfg-if", "crossbeam-epoch", @@ -1075,22 +1200,22 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.11" +version = "0.9.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f916dfc5d356b0ed9dae65f1db9fc9770aa2851d2662b988ccf4fe3516e86348" +checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", - "memoffset 0.6.5", + "memoffset 0.8.0", "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.12" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edbafec5fa1f196ca66527c1b12c2ec4745ca14b50f1ad8f9f6f720b55d11fac" +checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" dependencies = [ "cfg-if", ] @@ -1127,7 +1252,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" dependencies = [ - "cipher 0.3.0", + "cipher", ] [[package]] @@ -1144,55 +1269,11 @@ dependencies = [ "zeroize", ] -[[package]] -name = "cxx" -version = "1.0.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b7d4e43b25d3c994662706a1d4fcfc32aaa6afd287502c111b237093bb23f3a" -dependencies = [ - "cc", - "cxxbridge-flags", - "cxxbridge-macro", - "link-cplusplus", -] - -[[package]] -name = "cxx-build" -version = "1.0.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84f8829ddc213e2c1368e51a2564c552b65a8cb6a28f31e576270ac81d5e5827" -dependencies = [ - "cc", - "codespan-reporting", - "once_cell", - "proc-macro2 1.0.56", - "quote 1.0.26", - "scratch", - "syn 1.0.109", -] - -[[package]] -name = "cxxbridge-flags" -version = "1.0.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e72537424b474af1460806647c41d4b6d35d09ef7fe031c5c2fa5766047cc56a" - -[[package]] -name = "cxxbridge-macro" -version = "1.0.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "309e4fb93eed90e1e14bea0da16b209f81813ba9fc7830c20ed151dd7bc0a4d7" -dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 1.0.109", -] - [[package]] name = "darling" -version = "0.14.3" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0808e1bd8671fb44a113a14e13497557533369847788fa2ae912b6ebfce9fa8" +checksum = "0558d22a7b463ed0241e993f76f09f30b126687447751a8638587b864e4b3944" dependencies = [ "darling_core", "darling_macro", @@ -1200,34 +1281,34 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.14.3" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "001d80444f28e193f30c2f293455da62dcf9a6b29918a4253152ae2b1de592cb" +checksum = "ab8bfa2e259f8ee1ce5e97824a3c55ec4404a0d772ca7fa96bf19f0752a046eb" dependencies = [ "fnv", "ident_case", - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.60", + "quote 1.0.28", "strsim 0.10.0", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] name = "darling_macro" -version = "0.14.3" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b36230598a2d5de7ec1c6f51f72d8a99a9208daff41de2084d06e3fd3ea56685" +checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a" dependencies = [ "darling_core", - "quote 1.0.26", - "syn 1.0.109", + "quote 1.0.28", + "syn 2.0.18", ] [[package]] name = "data-encoding" -version = "2.3.2" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" +checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" [[package]] name = "der" @@ -1240,9 +1321,9 @@ dependencies = [ [[package]] name = "der-parser" -version = "8.1.0" +version = "8.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42d4bc9b0db0a0df9ae64634ac5bdefb7afcb534e182275ca0beadbe486701c1" +checksum = "dbd676fbbab537128ef0278adb5576cf363cff6aa22a7b24effe97347cfab61e" dependencies = [ "asn1-rs", "displaydoc", @@ -1264,18 +1345,19 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.60", + "quote 1.0.28", "syn 1.0.109", ] [[package]] name = "dialoguer" -version = "0.10.2" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92e7e37ecef6857fdc0c0c5d42fd5b0938e46590c2183cc92dd310a6d078eb1" +checksum = "59c6f2989294b9a498d3ad5491a79c6deb604617378e1cdc4bfc1c1361fe2f87" dependencies = [ "console", + "shell-words", "tempfile", "zeroize", ] @@ -1297,11 +1379,11 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.5" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adfbc57365a37acbd2ebf2b64d7e69bb766e2fea813521ed536f5d0520dcf86c" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer 0.10.3", + "block-buffer 0.10.4", "crypto-common", "subtle", ] @@ -1349,13 +1431,13 @@ dependencies = [ [[package]] name = "displaydoc" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bf95dc3f046b9da4f2d51833c0d3547d8564ef6910f5c1ed130306a75b92886" +checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 1.0.109", + "proc-macro2 1.0.60", + "quote 1.0.28", + "syn 2.0.18", ] [[package]] @@ -1389,9 +1471,9 @@ checksum = "abe71d579d1812060163dff96056261deb5bf6729b100fa2e36a68b9649ba3d3" [[package]] name = "ed25519" -version = "1.5.2" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e9c280362032ea4203659fc489832d0204ef09f247a0506f170dafcac08c369" +checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" dependencies = [ "signature", ] @@ -1424,9 +1506,9 @@ dependencies = [ [[package]] name = "either" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "ena" @@ -1445,43 +1527,31 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" -version = "0.8.31" +version = "0.8.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b" +checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" dependencies = [ "cfg-if", ] [[package]] name = "enum-iterator" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "706d9e7cf1c7664859d79cd524e4e53ea2b67ea03c98cc2870c5e539695d597e" +checksum = "7add3873b5dd076766ee79c8e406ad1a472c385476b9e38849f8eec24f1be689" dependencies = [ "enum-iterator-derive", ] [[package]] name = "enum-iterator-derive" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "355f93763ef7b0ae1c43c4d8eccc9d5848d84ad1a1d8ce61c421d1ac85a19d05" +checksum = "eecf8589574ce9b895052fa12d69af7a233f99e6107f5cb8dd1044f2a17bfdcb" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 1.0.109", -] - -[[package]] -name = "enum_dispatch" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eb359f1476bf611266ac1f5355bc14aeca37b299d0ebccc038ee7058891c9cb" -dependencies = [ - "once_cell", - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 1.0.109", + "proc-macro2 1.0.60", + "quote 1.0.28", + "syn 2.0.18", ] [[package]] @@ -1499,8 +1569,8 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "946ee94e3dbf58fdd324f9ce245c7b238d46a66f00e86a020b71996349e46cce" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.60", + "quote 1.0.28", "syn 1.0.109", ] @@ -1546,9 +1616,9 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "fastrand" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" dependencies = [ "instant", ] @@ -1561,24 +1631,24 @@ checksum = "835a3dc7d1ec9e75e2b5fb4ba75396837112d2060b03f7d43bc1897c7f7211da" [[package]] name = "field-offset" -version = "0.3.4" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e1c54951450cbd39f3dbcf1005ac413b49487dabf18a720ad2383eccfeffb92" +checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f" dependencies = [ - "memoffset 0.6.5", - "rustc_version 0.3.3", + "memoffset 0.9.0", + "rustc_version", ] [[package]] name = "filetime" -version = "0.2.18" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b9663d381d07ae25dc88dbdf27df458faa83a9b25336bcac83d5e452b5fc9d3" +checksum = "5cbc844cecaee9d4443931972e1289c8ff485cb4cc2767cb03ca139ed6885153" dependencies = [ "cfg-if", "libc", - "redox_syscall", - "windows-sys 0.42.0", + "redox_syscall 0.2.16", + "windows-sys 0.48.0", ] [[package]] @@ -1589,9 +1659,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.24" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6" +checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" dependencies = [ "crc32fast", "miniz_oxide", @@ -1605,18 +1675,18 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" dependencies = [ "percent-encoding", ] [[package]] name = "futures" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38390104763dc37a5145a53c29c63c1290b5d316d6086ec32c293f6736051bb0" +checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" dependencies = [ "futures-channel", "futures-core", @@ -1629,9 +1699,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" dependencies = [ "futures-core", "futures-sink", @@ -1639,15 +1709,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" [[package]] name = "futures-executor" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7acc85df6714c176ab5edf386123fafe217be88c0840ec11f199441134a074e2" +checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" dependencies = [ "futures-core", "futures-task", @@ -1656,38 +1726,38 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" [[package]] name = "futures-macro" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" +checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 1.0.109", + "proc-macro2 1.0.60", + "quote 1.0.28", + "syn 2.0.18", ] [[package]] name = "futures-sink" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" [[package]] name = "futures-task" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" [[package]] name = "futures-util" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ "futures-channel", "futures-core", @@ -1703,9 +1773,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.6" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "serde", "typenum", @@ -1737,9 +1807,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "js-sys", @@ -1761,9 +1831,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.15" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" +checksum = "d357c7ae988e7d2182f7d7871d0b963962420b0678b0997ce7de72001aeab782" dependencies = [ "bytes", "fnv", @@ -1793,7 +1863,7 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" dependencies = [ - "ahash", + "ahash 0.7.6", ] [[package]] @@ -1801,8 +1871,14 @@ name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash", + "ahash 0.8.3", ] [[package]] @@ -1816,9 +1892,9 @@ dependencies = [ [[package]] name = "heck" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" @@ -1829,6 +1905,15 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + [[package]] name = "hermit-abi" version = "0.3.1" @@ -1857,7 +1942,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "digest 0.10.5", + "digest 0.10.7", ] [[package]] @@ -1873,9 +1958,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" dependencies = [ "bytes", "fnv", @@ -1913,9 +1998,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.20" +version = "0.14.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02c929dc5c39e335a03c405292728118860721b10190d98c2a0f0efd5baafbac" +checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4" dependencies = [ "bytes", "futures-channel", @@ -1937,9 +2022,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.23.0" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d87c48c02e0dc5e3b849a2041db3029fd066650f8f717c07bf8ed78ccb895cac" +checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c" dependencies = [ "http", "hyper", @@ -1950,26 +2035,25 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.52" +version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c422fb4f6e80490d0afcacf5c3de2c22ab8e631e0cd7cb2d4a3baf844720a52a" +checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "winapi", + "windows", ] [[package]] name = "iana-time-zone-haiku" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" dependencies = [ - "cxx", - "cxx-build", + "cc", ] [[package]] @@ -1980,9 +2064,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -2006,9 +2090,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.9.1" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", @@ -2016,25 +2100,17 @@ dependencies = [ [[package]] name = "indicatif" -version = "0.17.3" +version = "0.17.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cef509aa9bc73864d6756f0d34d35504af3cf0844373afe9b8669a5b8005a729" +checksum = "8ff8cc23a7393a397ed1d7f56e6365cba772aba9f9912ab968b03043c395d057" dependencies = [ "console", + "instant", "number_prefix", "portable-atomic", "unicode-width", ] -[[package]] -name = "inout" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" -dependencies = [ - "generic-array", -] - [[package]] name = "instant" version = "0.1.12" @@ -2046,9 +2122,9 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ "hermit-abi 0.3.1", "libc", @@ -2057,9 +2133,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.5.0" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b" +checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" [[package]] name = "is-terminal" @@ -2093,24 +2169,24 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "jobserver" -version = "0.1.25" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b" +checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" dependencies = [ "libc", ] [[package]] name = "js-sys" -version = "0.3.60" +version = "0.3.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +checksum = "2f37a4a5928311ac501dee68b3c7613a1037d0edb30c8e5427bd832d55d1b790" dependencies = [ "wasm-bindgen", ] @@ -2132,15 +2208,18 @@ dependencies = [ [[package]] name = "keccak" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9b7d56ba4a8344d6be9729995e6b06f928af29998cdf79fe390cbf6b1fee838" +checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" +dependencies = [ + "cpufeatures", +] [[package]] name = "lalrpop" -version = "0.19.9" +version = "0.19.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f34313ec00c2eb5c3c87ca6732ea02dcf3af99c3ff7a8fb622ffb99c9d860a87" +checksum = "0a1cbf952127589f2851ab2046af368fd20645491bb4b376f04b7f94d7a9837b" dependencies = [ "ascii-canvas", "bit-set", @@ -2150,9 +2229,8 @@ dependencies = [ "itertools 0.10.5", "lalrpop-util", "petgraph", - "pico-args", "regex", - "regex-syntax", + "regex-syntax 0.6.29", "string_cache", "term", "tiny-keccak", @@ -2161,9 +2239,9 @@ dependencies = [ [[package]] name = "lalrpop-util" -version = "0.19.9" +version = "0.19.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5c1f7869c94d214466c5fd432dfed12c379fd87786768d36455892d46b18edd" +checksum = "d3c48237b9604c5a4702de6b824e02006c3214327564636aef27c1028a8fa0ed" dependencies = [ "regex", ] @@ -2176,19 +2254,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.142" +version = "0.2.146" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" - -[[package]] -name = "libloading" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd" -dependencies = [ - "cfg-if", - "winapi", -] +checksum = "f92be4933c13fd498862a9e02a3055f8a8d9c039ce33db97306fd5a6caa7f29b" [[package]] name = "libsecp256k1" @@ -2238,26 +2306,17 @@ dependencies = [ "libsecp256k1-core", ] -[[package]] -name = "link-cplusplus" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" -dependencies = [ - "cc", -] - [[package]] name = "linux-raw-sys" -version = "0.3.4" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36eb31c1778188ae1e64398743890d0877fef36d11521ac60406b42016e8c2cf" +checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "lock_api" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" dependencies = [ "autocfg", "scopeguard", @@ -2265,12 +2324,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.17" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" [[package]] name = "memchr" @@ -2289,9 +2345,9 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.6.5" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" dependencies = [ "autocfg", ] @@ -2305,6 +2361,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memoffset" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +dependencies = [ + "autocfg", +] + [[package]] name = "merlin" version = "3.0.0" @@ -2319,9 +2384,9 @@ dependencies = [ [[package]] name = "mime" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "mime_guess" @@ -2341,32 +2406,42 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.5.4" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" dependencies = [ "adler", ] [[package]] name = "mio" -version = "0.8.5" +version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" +checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc" dependencies = [ "libc", "log", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.42.0", + "miow", + "ntapi", + "winapi", +] + +[[package]] +name = "miow" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" +dependencies = [ + "winapi", ] [[package]] name = "mpl-token-auth-rules" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a69803fbfbc4bb0327de86f49d2639692c7c60276cb87d6cced84bb8189f2000" +checksum = "24dcb2b0ec0e9246f6f035e0336ba3359c21f6928dfd90281999e2c8e8ab53eb" dependencies = [ - "borsh", + "borsh 0.9.3", "mpl-token-metadata-context-derive", "num-derive", "num-traits", @@ -2380,12 +2455,12 @@ dependencies = [ [[package]] name = "mpl-token-metadata" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aed414104154928aa995a44a0a474c449d04ce5a4ee6c975ad41c5d2912f0dfe" +checksum = "f661ff8c1d64c48cf207c0d259783d411a4249058c1b861fabd8bb6ce30ae4d8" dependencies = [ "arrayref", - "borsh", + "borsh 0.9.3", "mpl-token-auth-rules", "mpl-token-metadata-context-derive", "mpl-utils", @@ -2404,7 +2479,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12989bc45715b0ee91944855130131479f9c772e198a910c3eb0ea327d5bffc3" dependencies = [ - "quote 1.0.26", + "quote 1.0.28", "syn 1.0.109", ] @@ -2415,7 +2490,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "822133b6cba8f9a43e5e0e189813be63dd795858f54155c729833be472ffdb51" dependencies = [ "arrayref", - "borsh", + "borsh 0.9.3", "solana-program", "spl-token", ] @@ -2428,28 +2503,37 @@ checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" [[package]] name = "nix" -version = "0.25.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4" +checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" dependencies = [ - "autocfg", "bitflags", "cfg-if", "libc", - "memoffset 0.6.5", + "memoffset 0.7.1", "pin-utils", + "static_assertions", ] [[package]] name = "nom" -version = "7.1.1" +version = "7.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" dependencies = [ "memchr", "minimal-lexical", ] +[[package]] +name = "ntapi" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f" +dependencies = [ + "winapi", +] + [[package]] name = "num" version = "0.2.1" @@ -2502,8 +2586,8 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.60", + "quote 1.0.28", "syn 1.0.109", ] @@ -2551,42 +2635,54 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.13.1" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ - "hermit-abi 0.1.19", + "hermit-abi 0.2.6", "libc", ] [[package]] name = "num_enum" -version = "0.5.7" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9" +dependencies = [ + "num_enum_derive 0.5.11", +] + +[[package]] +name = "num_enum" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf5395665662ef45796a4ff5486c5d41d29e0c09640af4c5f17fd94ee2c119c9" +checksum = "7a015b430d3c108a207fd776d2e2196aaf8b1cf8cf93253e3a097ff3085076a1" dependencies = [ - "num_enum_derive", + "num_enum_derive 0.6.1", ] [[package]] name = "num_enum_derive" -version = "0.5.7" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b0498641e53dd6ac1a4f22547548caa6864cc4933784319cd1775271c5a46ce" +checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799" dependencies = [ - "proc-macro-crate 1.2.1", - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro-crate 1.3.1", + "proc-macro2 1.0.60", + "quote 1.0.28", "syn 1.0.109", ] [[package]] -name = "num_threads" -version = "0.1.6" +name = "num_enum_derive" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" +checksum = "96667db765a921f7b295ffee8b60472b686a51d4f21c2ee4ffdb94c7013b65a6" dependencies = [ - "libc", + "proc-macro-crate 1.3.1", + "proc-macro2 1.0.60", + "quote 1.0.28", + "syn 2.0.18", ] [[package]] @@ -2597,18 +2693,18 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "oid-registry" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d4bda43fd1b844cbc6e6e54b5444e2b1bc7838bce59ad205902cccbb26d6761" +checksum = "9bedf36ffb6ba96c2eb7144ef6270557b52e54b20c0a8e1eb2ff99a6c6959bff" dependencies = [ "asn1-rs", ] [[package]] name = "once_cell" -version = "1.16.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "opaque-debug" @@ -2624,9 +2720,20 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "os_str_bytes" -version = "6.3.1" +version = "6.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3baf96e39c5359d2eb0dd6ccb42c62b91d9678aa68160d261b9e0ccbf9e9dea9" +checksum = "ceedf44fb00f2d1984b0bc98102627ce622e083e49a5bacdb3e514fa4238e267" + +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core 0.8.6", +] [[package]] name = "parking_lot" @@ -2635,27 +2742,41 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core", + "parking_lot_core 0.9.8", ] [[package]] name = "parking_lot_core" -version = "0.9.4" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dc9e0dc2adc1c69d09143aff38d3d30c5c3f0df0dad82e6d25547af174ebec0" +checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" dependencies = [ "cfg-if", + "instant", "libc", - "redox_syscall", + "redox_syscall 0.2.16", "smallvec", - "windows-sys 0.42.0", + "winapi", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.3.5", + "smallvec", + "windows-targets 0.48.0", ] [[package]] name = "paste" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba" +checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" [[package]] name = "pathdiff" @@ -2678,7 +2799,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" dependencies = [ - "digest 0.10.5", + "digest 0.10.7", ] [[package]] @@ -2692,9 +2813,9 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "percentage" @@ -2702,17 +2823,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fd23b938276f14057220b707937bcb42fa76dda7560e57a2da30cb52d557937" dependencies = [ - "num", -] - -[[package]] -name = "pest" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbc7bc69c062e492337d74d59b120c274fd3d261b6bf6d3207d499b4b379c41a" -dependencies = [ - "thiserror", - "ucd-trie", + "num", ] [[package]] @@ -2753,8 +2864,8 @@ checksum = "92aacdc5f16768709a569e913f7451034034178b05bdc8acda226659a3dccc66" dependencies = [ "phf_generator", "phf_shared 0.11.1", - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.60", + "quote 1.0.28", "syn 1.0.109", ] @@ -2776,12 +2887,6 @@ dependencies = [ "siphasher", ] -[[package]] -name = "pico-args" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db8bcd96cb740d03149cbad5518db9fd87126a10ab519c011893b1754134c468" - [[package]] name = "pin-project-lite" version = "0.2.9" @@ -2805,6 +2910,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "pkg-config" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" + [[package]] name = "plain" version = "0.2.3" @@ -2825,9 +2936,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "0.3.19" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26f6a7b87c2e435a3241addceeeff740ff8b7e76b74c13bf9acb17fa454ea00b" +checksum = "767eb9f07d4a5ebcb39bbf2d452058a93c011373abf6832e24194a1c3f004794" [[package]] name = "portpicker" @@ -2840,9 +2951,9 @@ dependencies = [ [[package]] name = "ppv-lite86" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "precomputed-hash" @@ -2861,13 +2972,12 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "1.2.1" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "thiserror", - "toml", + "toml_edit", ] [[package]] @@ -2881,9 +2991,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "dec2b086b7a862cf4de201096214fa870344cf922b2b30c167badb3af3195406" dependencies = [ "unicode-ident", ] @@ -2917,9 +3027,9 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72ef4ced82a24bb281af338b9e8f94429b6eca01b4e66d899f40031f074e74c9" +checksum = "67c10f662eee9c94ddd7135043e544f3c82fa839a1e7b865911331961b53186c" dependencies = [ "bytes", "rand 0.8.5", @@ -2958,11 +3068,11 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.26" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" dependencies = [ - "proc-macro2 1.0.56", + "proc-macro2 1.0.60", ] [[package]] @@ -3024,7 +3134,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.8", + "getrandom 0.2.10", ] [[package]] @@ -3047,21 +3157,19 @@ dependencies = [ [[package]] name = "rayon" -version = "1.5.3" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d" +checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" dependencies = [ - "autocfg", - "crossbeam-deque", "either", "rayon-core", ] [[package]] name = "rayon-core" -version = "1.9.3" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" +checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" dependencies = [ "crossbeam-channel", "crossbeam-deque", @@ -3077,7 +3185,7 @@ checksum = "ffbe84efe2f38dea12e9bfc1f65377fdf03e53a18cb3b995faedf7934c7e785b" dependencies = [ "pem", "ring", - "time 0.3.16", + "time 0.3.22", "yasna", ] @@ -3090,51 +3198,57 @@ dependencies = [ "bitflags", ] +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags", +] + [[package]] name = "redox_users" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.8", - "redox_syscall", + "getrandom 0.2.10", + "redox_syscall 0.2.16", "thiserror", ] [[package]] name = "regex" -version = "1.6.0" +version = "1.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.7.2", ] [[package]] name = "regex-syntax" -version = "0.6.27" +version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] -name = "remove_dir_all" -version = "0.5.3" +name = "regex-syntax" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] +checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" [[package]] name = "reqwest" -version = "0.11.12" +version = "0.11.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "431949c384f4e2ae07605ccaa56d1d9d2ecdb5cadd4f9577ccfab29f2e5149fc" +checksum = "13293b639a097af28fc8a90f22add145a9c954e49d77da06263d58cf44d5fb91" dependencies = [ "async-compression", - "base64 0.13.1", + "base64 0.21.2", "bytes", "encoding_rs", "futures-core", @@ -3229,9 +3343,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.21" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustc-hash" @@ -3239,22 +3353,13 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" -[[package]] -name = "rustc_version" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" -dependencies = [ - "semver 0.11.0", -] - [[package]] name = "rustc_version" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.16", + "semver", ] [[package]] @@ -3268,9 +3373,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.15" +version = "0.37.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0661814f891c57c930a610266415528da53c4933e6dea5fb350cbfe048a9ece" +checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" dependencies = [ "bitflags", "errno", @@ -3282,9 +3387,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.20.7" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "539a2bfe908f471bfa933876bd1eb6a19cf2176d375f82ef7f99530a40e48c2c" +checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" dependencies = [ "log", "ring", @@ -3306,24 +3411,24 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0864aeff53f8c05aa08d86e5ef839d3dfcf07aeba2db32f12db0ef716e87bd55" +checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" dependencies = [ - "base64 0.13.1", + "base64 0.21.2", ] [[package]] name = "rustversion" -version = "1.0.9" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8" +checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" [[package]] name = "ryu" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "safe-transmute" @@ -3342,12 +3447,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.20" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" +checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" dependencies = [ - "lazy_static", - "windows-sys 0.36.1", + "windows-sys 0.42.0", ] [[package]] @@ -3356,12 +3460,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "scratch" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" - [[package]] name = "scroll" version = "0.11.0" @@ -3377,8 +3475,8 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bdbda6ac5cd1321e724fa9cee216f3a61885889b896f073b8f82322789c5250e" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.60", + "quote 1.0.28", "syn 1.0.109", ] @@ -3394,9 +3492,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.7.0" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bc1bb97804af6631813c55739f771071e0f2ed33ee20b68c86ec505d906356c" +checksum = "1fc758eb7bffce5b308734e9b0c1468893cae9ff70ebf13e7090be8dcbcc83a8" dependencies = [ "bitflags", "core-foundation", @@ -3407,9 +3505,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.6.1" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" +checksum = "f51d0c0d83bec45f16480d0ce0058397a69e48fcdc52d1dc8855fb68acbd31a7" dependencies = [ "core-foundation-sys", "libc", @@ -3417,62 +3515,44 @@ dependencies = [ [[package]] name = "semver" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver" -version = "1.0.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" - -[[package]] -name = "semver-parser" -version = "0.10.2" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" -dependencies = [ - "pest", -] +checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" [[package]] name = "serde" -version = "1.0.154" +version = "1.0.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cdd151213925e7f1ab45a9bbfb129316bd00799784b174b7cc7bcd16961c49e" +checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" dependencies = [ "serde_derive", ] [[package]] name = "serde_bytes" -version = "0.11.7" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfc50e8183eeeb6178dcb167ae34a8051d63535023ae38b5d8d12beae193d37b" +checksum = "416bda436f9aab92e02c8e10d49a15ddd339cea90b6e340fe51ed97abb548294" dependencies = [ "serde", ] [[package]] name = "serde_derive" -version = "1.0.154" +version = "1.0.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fc80d722935453bcafdc2c9a73cd6fac4dc1938f0346035d84bf99fa9e33217" +checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 1.0.109", + "proc-macro2 1.0.60", + "quote 1.0.28", + "syn 2.0.18", ] [[package]] name = "serde_json" -version = "1.0.87" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" +checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" dependencies = [ "itoa", "ryu", @@ -3493,9 +3573,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "2.2.0" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30d904179146de381af4c93d3af6ca4984b3152db687dacb9c3c35e86f39809c" +checksum = "07ff71d2c147a7b57362cead5e22f772cd52f6ab31cfcd9edcd7f6aeb2a0afbe" dependencies = [ "serde", "serde_with_macros", @@ -3503,21 +3583,21 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "2.2.0" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1966009f3c05f095697c537312f5415d1e3ed31ce0a56942bac4c771c5c335e" +checksum = "881b6f881b17d13214e5d494c939ebab463d01264ce1811e9d4ac3a882e7695f" dependencies = [ "darling", - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 1.0.109", + "proc-macro2 1.0.60", + "quote 1.0.28", + "syn 2.0.18", ] [[package]] name = "serde_yaml" -version = "0.9.17" +version = "0.9.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb06d4b6cdaef0e0c51fa881acb721bed3c924cfaa71d9c94a3b771dfdf6567" +checksum = "d9d684e3ec7de3bf5466b32bd75303ac16f0736426e5a4e0d6e489559ce1249c" dependencies = [ "indexmap", "itoa", @@ -3539,7 +3619,7 @@ dependencies = [ "field-offset", "itertools 0.9.0", "num-traits", - "num_enum", + "num_enum 0.5.11", "safe-transmute", "serde", "solana-program", @@ -3551,13 +3631,13 @@ dependencies = [ [[package]] name = "sha-1" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f" +checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.5", + "digest 0.10.7", ] [[package]] @@ -3581,7 +3661,7 @@ checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.5", + "digest 0.10.7", ] [[package]] @@ -3598,11 +3678,11 @@ dependencies = [ [[package]] name = "sha3" -version = "0.10.6" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" dependencies = [ - "digest 0.10.5", + "digest 0.10.7", "keccak", ] @@ -3621,8 +3701,8 @@ version = "0.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "63927d22a1e8b74bda98cc6e151fcdf178b7abb0dc6c4f81e0bbf5ffe2fc4ec8" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.60", + "quote 1.0.28", "shank_macro_impl", "syn 1.0.109", ] @@ -3634,12 +3714,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40ce03403df682f80f4dc1efafa87a4d0cb89b03726d0565e6364bdca5b9a441" dependencies = [ "anyhow", - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.60", + "quote 1.0.28", "serde", "syn 1.0.109", ] +[[package]] +name = "shell-words" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" + [[package]] name = "shellexpand" version = "2.1.2" @@ -3651,9 +3737,9 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" dependencies = [ "libc", ] @@ -3682,9 +3768,9 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" dependencies = [ "autocfg", ] @@ -3697,9 +3783,9 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "socket2" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" dependencies = [ "libc", "winapi", @@ -3707,12 +3793,12 @@ dependencies = [ [[package]] name = "solana-account-decoder" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e4ac2e5e6474d17f19341df43c62b62ee1e362bae9b06bc30223252dd4a362" +checksum = "579f978391c966b0a8f94467e446fd8155ed668e9d074c614329d4bad47134ac" dependencies = [ "Inflector", - "base64 0.13.1", + "base64 0.21.2", "bincode", "bs58 0.4.0", "bv", @@ -3731,16 +3817,16 @@ dependencies = [ [[package]] name = "solana-address-lookup-table-program" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baac6a0dfc38f64e5e5e178e9eeade05ef1a2c644c95062523c6bc21f19f8866" +checksum = "b73818e763f0f23ff538c5e42a07b1a76d556ff5719780a897147fe2958d345a" dependencies = [ "bincode", "bytemuck", "log", "num-derive", "num-traits", - "rustc_version 0.4.0", + "rustc_version", "serde", "solana-frozen-abi", "solana-frozen-abi-macro", @@ -3752,9 +3838,9 @@ dependencies = [ [[package]] name = "solana-clap-utils" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f0a43f9bcf2405e50190cf3943046663caae557db9eb71a628f359e3f4f3eea" +checksum = "770e68ef834e2835687facdf7e706f12e7f5c0e17044c0b956f068f6297a1685" dependencies = [ "chrono", "clap 2.34.0", @@ -3770,9 +3856,9 @@ dependencies = [ [[package]] name = "solana-cli-config" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c79aa0d4d3cef702ca522c1b8dca170eb7137254b6d608f46bcb3a26d6fffd3" +checksum = "95cb48e3e7679ebb2188960cefde449899005753edf7f2d830080f16a7572b7b" dependencies = [ "dirs-next", "lazy_static", @@ -3786,13 +3872,12 @@ dependencies = [ [[package]] name = "solana-client" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fe890559c3d8e29123ed0bfba47d5d714acb1db2e4a9a981c9171960ae01425" +checksum = "0f3059c513c25718282bc53432f7d8b0a06748161d6dcbdf67ecc6fa2bcec520" dependencies = [ "async-trait", "bincode", - "enum_dispatch", "futures", "futures-util", "indexmap", @@ -3804,7 +3889,6 @@ dependencies = [ "solana-connection-cache", "solana-measure", "solana-metrics", - "solana-net-utils", "solana-pubsub-client", "solana-quic-client", "solana-rpc-client", @@ -3821,9 +3905,9 @@ dependencies = [ [[package]] name = "solana-config-program" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebb520c573b28060cadd8ae0fa6ae116cf74dac01078bc437d8b3e3ab00efd22" +checksum = "daad46dde420f68e4064ccba14e604f8ac97a88553234bcd2a087c1030b3f522" dependencies = [ "bincode", "chrono", @@ -3835,9 +3919,9 @@ dependencies = [ [[package]] name = "solana-connection-cache" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c913dfcaf847cecd8866e4aeaa440b34c8a5dae6c1c90b7a8cb3265ff9fc775" +checksum = "ea40235b2b75e6a125f95c14d91884516e7229fb0505930b1ae38d05b3ad32b3" dependencies = [ "async-trait", "bincode", @@ -3846,9 +3930,9 @@ dependencies = [ "log", "rand 0.7.3", "rayon", + "rcgen", "solana-measure", "solana-metrics", - "solana-net-utils", "solana-sdk", "thiserror", "tokio", @@ -3856,9 +3940,9 @@ dependencies = [ [[package]] name = "solana-faucet" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d90180632e0528cd46e0ebfaf98977b24fc4593422be9b200e0dfaf97ee09cc7" +checksum = "919219ad369fd499afd7af560186748816aa5f8320284458825e33592a60f6fe" dependencies = [ "bincode", "byteorder", @@ -3880,13 +3964,13 @@ dependencies = [ [[package]] name = "solana-frozen-abi" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48f7051cccdf891ac2603cdd295eb651529fe2b678b6b3af60b82dec9a9b3b06" +checksum = "e0ec1a23136ef6072f3c6e3eabf6349dc0219ae23129c44754a4f9f8506941cd" dependencies = [ - "ahash", + "ahash 0.8.3", "blake3", - "block-buffer 0.9.0", + "block-buffer 0.10.4", "bs58 0.4.0", "bv", "byteorder", @@ -3894,14 +3978,13 @@ dependencies = [ "either", "generic-array", "getrandom 0.1.16", - "hashbrown 0.12.3", "im", "lazy_static", "log", "memmap2", "once_cell", "rand_core 0.6.4", - "rustc_version 0.4.0", + "rustc_version", "serde", "serde_bytes", "serde_derive", @@ -3914,21 +3997,21 @@ dependencies = [ [[package]] name = "solana-frozen-abi-macro" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06395428329810ade1d2518a7e75d8a6f02d01fe548aabb60ff1ba6a2eaebbe5" +checksum = "89744bbdcb6dc87805bf50f3db4520adf56b9fdd2a55b80b8de3b4c97b5c4bc8" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", - "rustc_version 0.4.0", - "syn 1.0.109", + "proc-macro2 1.0.60", + "quote 1.0.28", + "rustc_version", + "syn 2.0.18", ] [[package]] name = "solana-logger" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "170714ca3612e4df75f57c2c14c8ab74654b3b66f668986aeed456cedcf24446" +checksum = "4fc342d61b86066ca7bb72ab4ba17f677b8c2c3a3e71fb9286a57097f3b36b85" dependencies = [ "env_logger", "lazy_static", @@ -3937,9 +4020,9 @@ dependencies = [ [[package]] name = "solana-measure" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52b03528be5a0fbbe4c06a4e1758d155363b51f7c782435b1eb1d4804ab124e3" +checksum = "ea333a383efa6ddab7f4ba48273502af563abeb392f5731a00b22b9f45c15491" dependencies = [ "log", "solana-sdk", @@ -3947,9 +4030,9 @@ dependencies = [ [[package]] name = "solana-metrics" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc5ff9cbbe50e9918576ff46b4e38d9a946c33fc442982ce7ff397a3b851922a" +checksum = "7f7cced7756637c9d9b46aa52dca715bd0efb396f29aade27ecbd336787174fd" dependencies = [ "crossbeam-channel", "gethostname", @@ -3961,12 +4044,12 @@ dependencies = [ [[package]] name = "solana-net-utils" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26f35dff5b963ec471514e89bd99c7ac43545756221c99b63c2229cf5f37ebb2" +checksum = "8a17ef4a81db76c9604037cadecdbd83c0b82cce3576a275e48327b4d06a98d7" dependencies = [ "bincode", - "clap 3.2.23", + "clap 3.2.25", "crossbeam-channel", "log", "nix", @@ -3983,11 +4066,11 @@ dependencies = [ [[package]] name = "solana-perf" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d630964a18fb466d79c3f5e191f37083b52b584a3f596e17f4bd41a145254d" +checksum = "7b4bcf9dd10dffe2707c1dfd91b695c2dc3cb9585a7cbb17ed24c7d98a4103e9" dependencies = [ - "ahash", + "ahash 0.8.3", "bincode", "bv", "caps", @@ -4010,20 +4093,20 @@ dependencies = [ [[package]] name = "solana-program" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ae9f0fa7db3a4e90fa0df2723ac8cbc042e579cf109cd0380bc5a8c88bed924" +checksum = "aaf210d64911289b4a76cbd1fd0bfc6ab1d08e9d568a2dd021d03835d2e7efb6" dependencies = [ "ark-bn254", "ark-ec", "ark-ff", + "ark-serialize", "array-bytes", - "base64 0.13.1", + "base64 0.21.2", "bincode", "bitflags", "blake3", - "borsh", - "borsh-derive", + "borsh 0.10.3", "bs58 0.4.0", "bv", "bytemuck", @@ -4031,28 +4114,28 @@ dependencies = [ "console_error_panic_hook", "console_log", "curve25519-dalek", - "getrandom 0.2.8", + "getrandom 0.2.10", "itertools 0.10.5", "js-sys", "lazy_static", "libc", "libsecp256k1", "log", - "memoffset 0.8.0", + "memoffset 0.9.0", "num-bigint 0.4.3", "num-derive", "num-traits", - "parking_lot", + "parking_lot 0.12.1", "rand 0.7.3", "rand_chacha 0.2.2", - "rustc_version 0.4.0", + "rustc_version", "rustversion", "serde", "serde_bytes", "serde_derive", "serde_json", "sha2 0.10.6", - "sha3 0.10.6", + "sha3 0.10.8", "solana-frozen-abi", "solana-frozen-abi-macro", "solana-sdk-macro", @@ -4064,22 +4147,22 @@ dependencies = [ [[package]] name = "solana-program-runtime" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbb3250dc9a0abc87693437ae0bb3eb02603396dcf7698c06f77c33b2c0291ca" +checksum = "b2dbb6d2286cb5bae6e480b0d9acae38c6618e3ff858319b64c455e6039661b1" dependencies = [ - "base64 0.13.1", + "base64 0.21.2", "bincode", "eager", "enum-iterator", "itertools 0.10.5", "libc", - "libloading", "log", "num-derive", "num-traits", + "percentage", "rand 0.7.3", - "rustc_version 0.4.0", + "rustc_version", "serde", "solana-frozen-abi", "solana-frozen-abi-macro", @@ -4092,15 +4175,15 @@ dependencies = [ [[package]] name = "solana-pubsub-client" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e441892b9a00fdceebb0e7eee3226f2f5985a15d081aab1924a298f24cdadb2" +checksum = "a4313ba746070ee268076535b36ed5e4dcf584e5ec815ca04d714af5d485d765" dependencies = [ "crossbeam-channel", "futures-util", "log", "reqwest", - "semver 1.0.16", + "semver", "serde", "serde_derive", "serde_json", @@ -4117,9 +4200,9 @@ dependencies = [ [[package]] name = "solana-quic-client" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d19f3bd22bd8cef3bd7007e878f8ee1e9534a2b2ad99abc1ac05ed3d9f9bed" +checksum = "6a57937b9919152f3f2b1a5c9874113edf82e267be1c1f2448780e515ce115bb" dependencies = [ "async-mutex", "async-trait", @@ -4130,6 +4213,7 @@ dependencies = [ "quinn", "quinn-proto", "quinn-udp", + "rcgen", "rustls", "solana-connection-cache", "solana-measure", @@ -4138,16 +4222,15 @@ dependencies = [ "solana-rpc-client-api", "solana-sdk", "solana-streamer", - "solana-tpu-client", "thiserror", "tokio", ] [[package]] name = "solana-rayon-threadlimit" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30893a53deeb0a3e32451f4f7cb063484e1504a06b127c4b40c223ea90093d7b" +checksum = "49e5674c5786d04e4c1766e580827a417e7a523d724b4c1e8bb6c1842097ff3c" dependencies = [ "lazy_static", "num_cpus", @@ -4155,18 +4238,18 @@ dependencies = [ [[package]] name = "solana-remote-wallet" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "970f142fbf6bda164847f60977ad56adde32cafb7c798d2e005110410754aa85" +checksum = "123151e4cba3be5e887c333e430c43316d3b882e9a364f3368a6ac448bcfd1bb" dependencies = [ "console", "dialoguer", "log", "num-derive", "num-traits", - "parking_lot", + "parking_lot 0.12.1", "qstring", - "semver 1.0.16", + "semver", "solana-sdk", "thiserror", "uriparse", @@ -4174,18 +4257,18 @@ dependencies = [ [[package]] name = "solana-rpc-client" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "075485c8ce9300df10b67f01bb9e9ecb79c4c96c58e4b8aacac20e63c6144149" +checksum = "d81847cc7339aec68c34819e6223ce5782ca62b4b402ec7976ba9af0ff82f400" dependencies = [ "async-trait", - "base64 0.13.1", + "base64 0.21.2", "bincode", "bs58 0.4.0", "indicatif", "log", "reqwest", - "semver 1.0.16", + "semver", "serde", "serde_derive", "serde_json", @@ -4200,15 +4283,15 @@ dependencies = [ [[package]] name = "solana-rpc-client-api" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0623112b87c9e65ef00538e27203b6129518d40376a4aa2ddc4fae5bf78a8a2c" +checksum = "41df84c31b89e75b0b47bf3ef265042fd3c806f4c0d8d928c7f7f7a04b67472d" dependencies = [ - "base64 0.13.1", + "base64 0.21.2", "bs58 0.4.0", "jsonrpc-core", "reqwest", - "semver 1.0.16", + "semver", "serde", "serde_derive", "serde_json", @@ -4222,9 +4305,9 @@ dependencies = [ [[package]] name = "solana-rpc-client-nonce-utils" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a70673c11ff5d831c4e569b41aeb86c0e9c68dba79515b7c6f42b8f842be76fe" +checksum = "6c96a92be32409c7fd101169e34a0c4be17bd336a5bf4b22e52880ffda599126" dependencies = [ "clap 2.34.0", "solana-clap-utils", @@ -4235,21 +4318,21 @@ dependencies = [ [[package]] name = "solana-sdk" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbefda9f9bda78fd9d91ae21c38d9693e94d5979838fb69b70c6addb8dab953f" +checksum = "e0a43b1c03aa69e1410ada4b5b2971ab948806c188015ac54684deec67d2739a" dependencies = [ "assert_matches", - "base64 0.13.1", + "base64 0.21.2", "bincode", "bitflags", - "borsh", + "borsh 0.10.3", "bs58 0.4.0", "bytemuck", "byteorder", "chrono", "derivation-path", - "digest 0.10.5", + "digest 0.10.7", "ed25519-dalek", "ed25519-dalek-bip32", "generic-array", @@ -4262,12 +4345,12 @@ dependencies = [ "memmap2", "num-derive", "num-traits", - "num_enum", + "num_enum 0.6.1", "pbkdf2 0.11.0", "qstring", "rand 0.7.3", "rand_chacha 0.2.2", - "rustc_version 0.4.0", + "rustc_version", "rustversion", "serde", "serde_bytes", @@ -4275,7 +4358,7 @@ dependencies = [ "serde_json", "serde_with", "sha2 0.10.6", - "sha3 0.10.6", + "sha3 0.10.8", "solana-frozen-abi", "solana-frozen-abi-macro", "solana-logger", @@ -4288,23 +4371,25 @@ dependencies = [ [[package]] name = "solana-sdk-macro" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f809319358d5da7c3a0ac08ebf4d87b21170d928dbb7260254e8f3061f7f9e0e" +checksum = "aec66b2d42de3e7a90086ca6ec16f66ac0019bfc3a6ca44ade2404a9dc8c128a" dependencies = [ "bs58 0.4.0", - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.60", + "quote 1.0.28", "rustversion", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] name = "solana-streamer" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddd5b3dad02879b083b7218b9f9596d97cee8deda2b625bff67db95d8920f5f7" +checksum = "be763578e5c6719e543e9d86d9517d3b2dde6581db76b942b4bd4a1c3ed19256" dependencies = [ + "async-channel", + "bytes", "crossbeam-channel", "futures-util", "histogram", @@ -4332,9 +4417,9 @@ dependencies = [ [[package]] name = "solana-thin-client" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b16bdd6347caf841a007952c748cd35c3ec8395aa3816ac59b4a9b4c102237de" +checksum = "8baffff86187a65ef4cfa190019108c4c3b1738ecfd51b862eeac19a8f8caf98" dependencies = [ "bincode", "log", @@ -4343,14 +4428,13 @@ dependencies = [ "solana-rpc-client", "solana-rpc-client-api", "solana-sdk", - "solana-tpu-client", ] [[package]] name = "solana-tpu-client" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50a7dfa7a85ba000656d91c8847b61f8fa9b8067443449fab8e4c35fe01dee5c" +checksum = "0d068ff8db750b4cc3a0a2bce228370bc3f4b7883c53fab64a862a7ba1e7343b" dependencies = [ "async-trait", "bincode", @@ -4363,7 +4447,6 @@ dependencies = [ "solana-connection-cache", "solana-measure", "solana-metrics", - "solana-net-utils", "solana-pubsub-client", "solana-rpc-client", "solana-rpc-client-api", @@ -4374,14 +4457,14 @@ dependencies = [ [[package]] name = "solana-transaction-status" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b803e356fc2de0074866a6da007e721c950e754747e761a263b7f9e4c17edefa" +checksum = "eb0138e64aa7a6c2630c26d450bcdc296a57a399fb256fe85707aec10ac978ee" dependencies = [ "Inflector", - "base64 0.13.1", + "base64 0.21.2", "bincode", - "borsh", + "borsh 0.9.3", "bs58 0.4.0", "lazy_static", "log", @@ -4400,29 +4483,28 @@ dependencies = [ [[package]] name = "solana-udp-client" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1b0d7efeb2cb7dafbf3b085c895e440b8947fe5def6bdad17ebae9badfdecb0" +checksum = "e61134203fd0598b31cd24fd2f2d5866419911e4dbdb93fe9ad53404f6d79819" dependencies = [ "async-trait", "solana-connection-cache", "solana-net-utils", "solana-sdk", "solana-streamer", - "solana-tpu-client", "thiserror", "tokio", ] [[package]] name = "solana-version" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c3df7b4a4dc0a39da78d790845089a8d112fcd6d2d003ae93830387a564cfc5" +checksum = "0869902287377b9fd67fe6d1135ef612a9983f74cbee0e99fc5faf6df095dc15" dependencies = [ "log", - "rustc_version 0.4.0", - "semver 1.0.16", + "rustc_version", + "semver", "serde", "serde_derive", "solana-frozen-abi", @@ -4432,15 +4514,15 @@ dependencies = [ [[package]] name = "solana-vote-program" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2439b8c68f000f8c3713eceabb5cabc8528d276e5bc971c694d4103d4be958ff" +checksum = "e5764f7601a524e52d3ef70d314c68678ef623f8e1f7e48b3ccc3dec09d80503" dependencies = [ "bincode", "log", "num-derive", "num-traits", - "rustc_version 0.4.0", + "rustc_version", "serde", "serde_derive", "solana-frozen-abi", @@ -4454,17 +4536,16 @@ dependencies = [ [[package]] name = "solana-zk-token-sdk" -version = "1.15.2" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a290aa32014e007b03f952d5b784433d95636c65a3fb08d19dc5658a450941c" +checksum = "34a565bea0147718f57ee8bbd79438341769acd53f634d665c34114040ea7c26" dependencies = [ "aes-gcm-siv", "arrayref", - "base64 0.13.1", + "base64 0.21.2", "bincode", "bytemuck", "byteorder", - "cipher 0.4.3", "curve25519-dalek", "getrandom 0.1.16", "itertools 0.10.5", @@ -4485,9 +4566,9 @@ dependencies = [ [[package]] name = "solana_rbpf" -version = "0.2.38" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4e9e5085099858adba23d0a0b5298da8803f89999cb567ecafab9c916cdf53d" +checksum = "5c0820fa96c8e644159a308b338465d2a6314b0a71abc92ed3ecf9ad61c906e3" dependencies = [ "byteorder", "combine", @@ -4533,12 +4614,12 @@ dependencies = [ [[package]] name = "spl-associated-token-account" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc000f0fdf1f12f99d77d398137c1751345b18c88258ce0f99b7872cf6c9bd6" +checksum = "978dba3bcbe88d0c2c58366c254d9ea41c5f73357e72fc0bdee4d6b5fc99c8f4" dependencies = [ "assert_matches", - "borsh", + "borsh 0.9.3", "num-derive", "num-traits", "solana-program", @@ -4566,22 +4647,22 @@ dependencies = [ "bytemuck", "num-derive", "num-traits", - "num_enum", + "num_enum 0.5.11", "solana-program", "thiserror", ] [[package]] name = "spl-token-2022" -version = "0.5.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0edb869dbe159b018f17fb9bfa67118c30f232d7f54a73742bc96794dff77ed8" +checksum = "0043b590232c400bad5ee9eb983ced003d15163c4c5d56b090ac6d9a57457b47" dependencies = [ "arrayref", "bytemuck", "num-derive", "num-traits", - "num_enum", + "num_enum 0.5.11", "solana-program", "solana-zk-token-sdk", "spl-memo", @@ -4603,7 +4684,7 @@ checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b" dependencies = [ "new_debug_unreachable", "once_cell", - "parking_lot", + "parking_lot 0.12.1", "phf_shared 0.10.0", "precomputed-hash", ] @@ -4643,19 +4724,19 @@ version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.60", + "quote 1.0.28", "unicode-ident", ] [[package]] name = "syn" -version = "2.0.15" +version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.60", + "quote 1.0.28", "unicode-ident", ] @@ -4665,8 +4746,8 @@ version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.60", + "quote 1.0.28", "syn 1.0.109", "unicode-xid 0.2.4", ] @@ -4684,16 +4765,16 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.3.0" +version = "3.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6" dependencies = [ + "autocfg", "cfg-if", "fastrand", - "libc", - "redox_syscall", - "remove_dir_all", - "winapi", + "redox_syscall 0.3.5", + "rustix", + "windows-sys 0.48.0", ] [[package]] @@ -4709,23 +4790,13 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.1.3" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" dependencies = [ "winapi-util", ] -[[package]] -name = "terminal_size" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "textwrap" version = "0.11.0" @@ -4743,29 +4814,29 @@ checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "thiserror" -version = "1.0.37" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.37" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 1.0.109", + "proc-macro2 1.0.60", + "quote 1.0.28", + "syn 2.0.18", ] [[package]] name = "time" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" dependencies = [ "libc", "wasi 0.10.0+wasi-snapshot-preview1", @@ -4774,13 +4845,11 @@ dependencies = [ [[package]] name = "time" -version = "0.3.16" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fab5c8b9980850e06d92ddbe3ab839c062c801f3927c0fb8abd6fc8e918fbca" +checksum = "ea9e1b3cf1243ae005d9e74085d4d542f3125458f3a81af210d901dcd7411efd" dependencies = [ "itoa", - "libc", - "num_threads", "serde", "time-core", "time-macros", @@ -4788,15 +4857,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" +checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" [[package]] name = "time-macros" -version = "0.2.5" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65bb801831d812c562ae7d2bfb531f26e66e4e1f6b17307ba4149c5064710e5b" +checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" dependencies = [ "time-core", ] @@ -4840,15 +4909,15 @@ dependencies = [ [[package]] name = "tinyvec_macros" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.24.2" +version = "1.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a12a59981d9e3c38d216785b0c37399f6e415e8d0712047620f189371b0bb" +checksum = "b9d0183f6f6001549ab68f8c7585093bb732beefbcf6d23a10b9b95c73a1dd49" dependencies = [ "autocfg", "bytes", @@ -4856,22 +4925,22 @@ dependencies = [ "memchr", "mio", "num_cpus", - "parking_lot", + "once_cell", + "parking_lot 0.11.2", "pin-project-lite", "signal-hook-registry", - "socket2", "tokio-macros", - "windows-sys 0.42.0", + "winapi", ] [[package]] name = "tokio-macros" -version = "1.8.0" +version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" +checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.60", + "quote 1.0.28", "syn 1.0.109", ] @@ -4888,9 +4957,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d660770404473ccd7bc9f8b28494a811bc18542b915c0855c51e8f419d5223ce" +checksum = "8fb52b74f05dbf495a8fba459fdc331812b96aa086d9eb78101fa0d4569c3313" dependencies = [ "futures-core", "pin-project-lite", @@ -4915,9 +4984,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.4" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740" +checksum = "f988a1a1adc2fb21f9c12aa96441da33a1728193ae0b95d2be22dbd17fcb4e5c" dependencies = [ "bytes", "futures-core", @@ -4929,13 +4998,30 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.9" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" dependencies = [ "serde", ] +[[package]] +name = "toml_datetime" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a76a9312f5ba4c2dec6b9161fdf25d87ad8a09256ccea5a556fef03c706a10f" + +[[package]] +name = "toml_edit" +version = "0.19.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2380d56e8670370eee6566b0bfd4265f65b3f432e8c6d85623f728d4fa31f739" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + [[package]] name = "tower-service" version = "0.3.2" @@ -4949,6 +5035,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", + "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -4956,29 +5043,29 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" +checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 1.0.109", + "proc-macro2 1.0.60", + "quote 1.0.28", + "syn 2.0.18", ] [[package]] name = "tracing-core" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" dependencies = [ "once_cell", ] [[package]] name = "try-lock" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "tungstenite" @@ -5004,15 +5091,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" - -[[package]] -name = "ucd-trie" -version = "0.1.5" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "unicase" @@ -5025,15 +5106,15 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.8" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.5" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" +checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" [[package]] name = "unicode-normalization" @@ -5046,9 +5127,9 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.10.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" [[package]] name = "unicode-width" @@ -5089,9 +5170,9 @@ dependencies = [ [[package]] name = "unsafe-libyaml" -version = "0.2.5" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc7ed8ba44ca06be78ea1ad2c3682a43349126c8818054231ee6f4748012aed2" +checksum = "1865806a559042e51ab5414598446a5871b561d21b6764f2eabb0dd481d880a6" [[package]] name = "unsize" @@ -5120,9 +5201,9 @@ dependencies = [ [[package]] name = "url" -version = "2.3.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" dependencies = [ "form_urlencoded", "idna", @@ -5161,12 +5242,11 @@ checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" [[package]] name = "walkdir" -version = "2.3.2" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" dependencies = [ "same-file", - "winapi", "winapi-util", ] @@ -5200,9 +5280,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.83" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +checksum = "5bba0e8cb82ba49ff4e229459ff22a191bbe9a1cb3a341610c9c33efc27ddf73" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -5210,24 +5290,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.83" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb" dependencies = [ "bumpalo", "log", "once_cell", - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 1.0.109", + "proc-macro2 1.0.60", + "quote 1.0.28", + "syn 2.0.18", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.33" +version = "0.4.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23639446165ca5a5de86ae1d8896b737ae80319560fbaa4c2887b7da6e7ebd7d" +checksum = "2d1985d03709c53167ce907ff394f5316aa22cb4e12761295c5dc57dacb6297e" dependencies = [ "cfg-if", "js-sys", @@ -5237,38 +5317,38 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.83" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +checksum = "14d6b024f1a526bb0234f52840389927257beb670610081360e5a03c5df9c258" dependencies = [ - "quote 1.0.26", + "quote 1.0.28", "wasm-bindgen-macro-support", ] [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.83" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 1.0.109", + "proc-macro2 1.0.60", + "quote 1.0.28", + "syn 2.0.18", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.83" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" +checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93" [[package]] name = "web-sys" -version = "0.3.60" +version = "0.3.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" +checksum = "3bdd9ef4e984da1187bf8110c5cf5b845fbc87a23602cdf912386a76fcd3a7c2" dependencies = [ "js-sys", "wasm-bindgen", @@ -5286,9 +5366,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.22.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368bfe657969fb01238bb756d351dcade285e0f6fcbd36dcb23359a5169975be" +checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" dependencies = [ "webpki", ] @@ -5325,16 +5405,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "windows-sys" -version = "0.36.1" +name = "windows" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows_aarch64_msvc 0.36.1", - "windows_i686_gnu 0.36.1", - "windows_i686_msvc 0.36.1", - "windows_x86_64_gnu 0.36.1", - "windows_x86_64_msvc 0.36.1", + "windows-targets 0.48.0", ] [[package]] @@ -5343,13 +5419,22 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ - "windows_aarch64_gnullvm 0.42.0", - "windows_aarch64_msvc 0.42.0", - "windows_i686_gnu 0.42.0", - "windows_i686_msvc 0.42.0", - "windows_x86_64_gnu 0.42.0", - "windows_x86_64_gnullvm 0.42.0", - "windows_x86_64_msvc 0.42.0", + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", ] [[package]] @@ -5358,7 +5443,22 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.0", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", ] [[package]] @@ -5378,9 +5478,9 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_gnullvm" @@ -5390,15 +5490,9 @@ checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] name = "windows_aarch64_msvc" -version = "0.36.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_aarch64_msvc" @@ -5408,15 +5502,9 @@ checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_i686_gnu" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" - -[[package]] -name = "windows_i686_gnu" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_gnu" @@ -5426,15 +5514,9 @@ checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" - -[[package]] -name = "windows_i686_msvc" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_i686_msvc" @@ -5444,15 +5526,9 @@ checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_x86_64_gnu" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnu" @@ -5462,9 +5538,9 @@ checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_gnullvm" @@ -5474,15 +5550,9 @@ checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "windows_x86_64_msvc" @@ -5492,9 +5562,9 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "winnow" -version = "0.4.1" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae8970b36c66498d8ff1d66685dc86b91b29db0c7739899012f63a63814b4b28" +checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699" dependencies = [ "memchr", ] @@ -5533,7 +5603,7 @@ dependencies = [ "oid-registry", "rusticata-macros", "thiserror", - "time 0.3.16", + "time 0.3.22", ] [[package]] @@ -5547,11 +5617,11 @@ dependencies = [ [[package]] name = "yasna" -version = "0.5.0" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "346d34a236c9d3e5f3b9b74563f238f955bbd05fa0b8b4efa53c130c43982f4c" +checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" dependencies = [ - "time 0.3.16", + "time 0.3.22", ] [[package]] @@ -5565,14 +5635,13 @@ dependencies = [ [[package]] name = "zeroize_derive" -version = "1.3.2" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f8f187641dad4f680d25c4bfc4225b418165984179f26ca76ec4fb6441d3a17" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 1.0.109", - "synstructure", + "proc-macro2 1.0.60", + "quote 1.0.28", + "syn 2.0.18", ] [[package]] @@ -5596,10 +5665,11 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.1+zstd.1.5.2" +version = "2.0.8+zstd.1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fd07cbbc53846d9145dbffdf6dd09a7a0aa52be46741825f5c97bdd4f73f12b" +checksum = "5556e6ee25d32df2586c098bbfa278803692a20d0ab9565e049480d52707ec8c" dependencies = [ "cc", "libc", + "pkg-config", ] diff --git a/Cargo.toml b/Cargo.toml index b5cd7e7f8a..cb142aac1b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ codegen-units = 1 [workspace] members = [ + "avm", "cli", "client", "lang", diff --git a/LICENSE b/LICENSE index 357bb56729..3624ef8623 100644 --- a/LICENSE +++ b/LICENSE @@ -187,7 +187,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2020 Serum Foundation + Copyright 2020 Anchor Maintainers Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/VERSION b/VERSION index 1b58cc1018..697f087f37 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.27.0 +0.28.0 diff --git a/avm/Cargo.lock b/avm/Cargo.lock deleted file mode 100644 index f47d50f177..0000000000 --- a/avm/Cargo.lock +++ /dev/null @@ -1,1259 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "anstream" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6342bd4f5a1205d7f41e94a41a901f5647c938cdfa96036338e8533c9d6c2450" -dependencies = [ - "anstyle", - "anstyle-parse", - "anstyle-query", - "anstyle-wincon", - "colorchoice", - "is-terminal", - "utf8parse", -] - -[[package]] -name = "anstyle" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" - -[[package]] -name = "anstyle-parse" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" -dependencies = [ - "utf8parse", -] - -[[package]] -name = "anstyle-query" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" -dependencies = [ - "windows-sys 0.48.0", -] - -[[package]] -name = "anstyle-wincon" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" -dependencies = [ - "anstyle", - "windows-sys 0.48.0", -] - -[[package]] -name = "anyhow" -version = "1.0.66" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "avm" -version = "0.27.0" -dependencies = [ - "anyhow", - "cfg-if", - "clap", - "dirs", - "once_cell", - "reqwest", - "semver", - "serde", - "serde_json", - "tempfile", - "thiserror", -] - -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - -[[package]] -name = "base64" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bumpalo" -version = "3.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" - -[[package]] -name = "bytes" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" - -[[package]] -name = "cc" -version = "1.0.77" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "clap" -version = "4.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ac1f6381d8d82ab4684768f89c0ea3afe66925ceadb4eeb3fc452ffc55d62" -dependencies = [ - "clap_builder", - "clap_derive", - "once_cell", -] - -[[package]] -name = "clap_builder" -version = "4.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84080e799e54cff944f4b4a4b0e71630b0e0443b25b985175c7dddc1a859b749" -dependencies = [ - "anstream", - "anstyle", - "bitflags", - "clap_lex", - "strsim", -] - -[[package]] -name = "clap_derive" -version = "4.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9644cd56d6b87dbe899ef8b053e331c0637664e9e21a33dfcdc36093f5c5c4" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn 2.0.15", -] - -[[package]] -name = "clap_lex" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" - -[[package]] -name = "colorchoice" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" - -[[package]] -name = "dirs" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs-sys" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" -dependencies = [ - "libc", - "redox_users", - "winapi", -] - -[[package]] -name = "encoding_rs" -version = "0.8.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "errno" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" -dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "fastrand" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" -dependencies = [ - "instant", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "form_urlencoded" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" -dependencies = [ - "percent-encoding", -] - -[[package]] -name = "futures-channel" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" -dependencies = [ - "futures-core", -] - -[[package]] -name = "futures-core" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" - -[[package]] -name = "futures-io" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" - -[[package]] -name = "futures-sink" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" - -[[package]] -name = "futures-task" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" - -[[package]] -name = "futures-util" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" -dependencies = [ - "futures-core", - "futures-io", - "futures-task", - "memchr", - "pin-project-lite", - "pin-utils", - "slab", -] - -[[package]] -name = "getrandom" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "h2" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http", - "indexmap", - "slab", - "tokio", - "tokio-util", - "tracing", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[package]] -name = "heck" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" - -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - -[[package]] -name = "hermit-abi" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" - -[[package]] -name = "http" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - -[[package]] -name = "http-body" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" -dependencies = [ - "bytes", - "http", - "pin-project-lite", -] - -[[package]] -name = "httparse" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" - -[[package]] -name = "httpdate" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" - -[[package]] -name = "hyper" -version = "0.14.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "034711faac9d2166cb1baf1a2fb0b60b1f277f8492fd72176c17f3515e1abd3c" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "socket2", - "tokio", - "tower-service", - "tracing", - "want", -] - -[[package]] -name = "hyper-rustls" -version = "0.23.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c" -dependencies = [ - "http", - "hyper", - "rustls", - "tokio", - "tokio-rustls", -] - -[[package]] -name = "idna" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "indexmap" -version = "1.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" -dependencies = [ - "autocfg", - "hashbrown", -] - -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" -dependencies = [ - "hermit-abi 0.3.1", - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "ipnet" -version = "2.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f88c5561171189e69df9d98bcf18fd5f9558300f7ea7b801eb8a0fd748bd8745" - -[[package]] -name = "is-terminal" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" -dependencies = [ - "hermit-abi 0.3.1", - "io-lifetimes", - "rustix", - "windows-sys 0.48.0", -] - -[[package]] -name = "itoa" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" - -[[package]] -name = "js-sys" -version = "0.3.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "libc" -version = "0.2.142" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" - -[[package]] -name = "linux-raw-sys" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36eb31c1778188ae1e64398743890d0877fef36d11521ac60406b42016e8c2cf" - -[[package]] -name = "log" -version = "0.4.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "memchr" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "mime" -version = "0.3.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" - -[[package]] -name = "mio" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" -dependencies = [ - "libc", - "log", - "wasi", - "windows-sys 0.42.0", -] - -[[package]] -name = "num_cpus" -version = "1.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5" -dependencies = [ - "hermit-abi 0.1.19", - "libc", -] - -[[package]] -name = "once_cell" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" - -[[package]] -name = "percent-encoding" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" - -[[package]] -name = "pin-project-lite" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "proc-macro2" -version = "1.0.56" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags", -] - -[[package]] -name = "redox_users" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" -dependencies = [ - "getrandom", - "redox_syscall", - "thiserror", -] - -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] - -[[package]] -name = "reqwest" -version = "0.11.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68cc60575865c7831548863cc02356512e3f1dc2f3f82cb837d7fc4cc8f3c97c" -dependencies = [ - "base64 0.13.1", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "hyper", - "hyper-rustls", - "ipnet", - "js-sys", - "log", - "mime", - "once_cell", - "percent-encoding", - "pin-project-lite", - "rustls", - "rustls-pemfile", - "serde", - "serde_json", - "serde_urlencoded", - "tokio", - "tokio-rustls", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "webpki-roots", - "winreg", -] - -[[package]] -name = "ring" -version = "0.16.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" -dependencies = [ - "cc", - "libc", - "once_cell", - "spin", - "untrusted", - "web-sys", - "winapi", -] - -[[package]] -name = "rustix" -version = "0.37.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0661814f891c57c930a610266415528da53c4933e6dea5fb350cbfe048a9ece" -dependencies = [ - "bitflags", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys", - "windows-sys 0.48.0", -] - -[[package]] -name = "rustls" -version = "0.20.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" -dependencies = [ - "log", - "ring", - "sct", - "webpki", -] - -[[package]] -name = "rustls-pemfile" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" -dependencies = [ - "base64 0.21.0", -] - -[[package]] -name = "ryu" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" - -[[package]] -name = "sct" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" -dependencies = [ - "ring", - "untrusted", -] - -[[package]] -name = "semver" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4" - -[[package]] -name = "serde" -version = "1.0.147" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.147" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.103", -] - -[[package]] -name = "serde_json" -version = "1.0.88" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e8b3801309262e8184d9687fb697586833e939767aea0dda89f5a8e650e8bd7" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "serde_urlencoded" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" -dependencies = [ - "form_urlencoded", - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "slab" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" -dependencies = [ - "autocfg", -] - -[[package]] -name = "socket2" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - -[[package]] -name = "syn" -version = "1.0.103" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "tempfile" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" -dependencies = [ - "cfg-if", - "fastrand", - "libc", - "redox_syscall", - "remove_dir_all", - "winapi", -] - -[[package]] -name = "thiserror" -version = "1.0.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.103", -] - -[[package]] -name = "tinyvec" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" - -[[package]] -name = "tokio" -version = "1.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af" -dependencies = [ - "autocfg", - "bytes", - "libc", - "memchr", - "mio", - "num_cpus", - "pin-project-lite", - "socket2", - "windows-sys 0.42.0", -] - -[[package]] -name = "tokio-rustls" -version = "0.23.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" -dependencies = [ - "rustls", - "tokio", - "webpki", -] - -[[package]] -name = "tokio-util" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "pin-project-lite", - "tokio", - "tracing", -] - -[[package]] -name = "tower-service" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" - -[[package]] -name = "tracing" -version = "0.1.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" -dependencies = [ - "cfg-if", - "pin-project-lite", - "tracing-core", -] - -[[package]] -name = "tracing-core" -version = "0.1.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" -dependencies = [ - "once_cell", -] - -[[package]] -name = "try-lock" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" - -[[package]] -name = "unicode-bidi" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" - -[[package]] -name = "unicode-ident" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" - -[[package]] -name = "unicode-normalization" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "untrusted" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" - -[[package]] -name = "url" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" -dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", -] - -[[package]] -name = "utf8parse" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" - -[[package]] -name = "want" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" -dependencies = [ - "log", - "try-lock", -] - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "wasm-bindgen" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn 1.0.103", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23639446165ca5a5de86ae1d8896b737ae80319560fbaa4c2887b7da6e7ebd7d" -dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.103", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" - -[[package]] -name = "web-sys" -version = "0.3.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "webpki" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" -dependencies = [ - "ring", - "untrusted", -] - -[[package]] -name = "webpki-roots" -version = "0.22.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" -dependencies = [ - "webpki", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows-sys" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" -dependencies = [ - "windows_aarch64_gnullvm 0.42.0", - "windows_aarch64_msvc 0.42.0", - "windows_i686_gnu 0.42.0", - "windows_i686_msvc 0.42.0", - "windows_x86_64_gnu 0.42.0", - "windows_x86_64_gnullvm 0.42.0", - "windows_x86_64_msvc 0.42.0", -] - -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" -dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" - -[[package]] -name = "windows_i686_gnu" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" - -[[package]] -name = "windows_i686_msvc" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" - -[[package]] -name = "winreg" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" -dependencies = [ - "winapi", -] diff --git a/avm/Cargo.toml b/avm/Cargo.toml index dc314cdec0..53faaabbed 100644 --- a/avm/Cargo.toml +++ b/avm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "avm" -version = "0.27.0" +version = "0.28.0" rust-version = "1.60" edition = "2021" @@ -13,16 +13,14 @@ name = "anchor" path = "src/anchor/main.rs" [dependencies] -clap = { version = "4.2.4", features = ["derive"]} -cfg-if = "1.0.0" anyhow = "1.0.32" +cfg-if = "1.0.0" +clap = { version = "4.2.4", features = ["derive"]} dirs = "4.0.0" +once_cell = { version = "1.8.0" } +reqwest = { version = "0.11.9", default-features = false, features = ["blocking", "json", "rustls-tls"] } semver = "1.0.4" serde = { version = "1.0.136", features = ["derive"] } serde_json = "1.0.78" -thiserror = "1.0.30" -once_cell = { version = "1.8.0" } -reqwest = { version = "0.11.9", default-features = false, features = ["blocking", "json", "rustls-tls"] } tempfile = "3.3.0" - -[workspace] +thiserror = "1.0.30" diff --git a/bench/COMPUTE_UNITS.md b/bench/COMPUTE_UNITS.md index 5eaed7364d..2aafbf2062 100644 --- a/bench/COMPUTE_UNITS.md +++ b/bench/COMPUTE_UNITS.md @@ -11,91 +11,191 @@ The programs and their tests are located in [/tests/bench](https://github.com/co ## [Unreleased] -| Instruction | Compute Units | +/- | -| --------------------------- | ------------- | ------------- | -| accountEmptyInit1 | 6246 | 🔴 **+4.83%** | -| accountEmpty1 | 1090 | - | -| accountEmptyInit2 | 11090 | 🔴 **+4.88%** | -| accountEmpty2 | 1852 | - | -| accountEmptyInit4 | 20579 | 🔴 **+5.23%** | -| accountEmpty4 | 2646 | - | -| accountEmptyInit8 | 39582 | 🔴 **+5.44%** | -| accountEmpty8 | 5043 | - | -| accountSizedInit1 | 6353 | 🔴 **+4.78%** | -| accountSized1 | 1135 | - | -| accountSizedInit2 | 11301 | 🔴 **+4.80%** | -| accountSized2 | 1966 | - | -| accountSizedInit4 | 21000 | 🔴 **+5.13%** | -| accountSized4 | 2787 | - | -| accountSizedInit8 | 40422 | 🔴 **+5.32%** | -| accountSized8 | 5359 | - | -| accountUnsizedInit1 | 6482 | 🔴 **+4.67%** | -| accountUnsized1 | 1243 | - | -| accountUnsizedInit2 | 11560 | 🔴 **+4.69%** | -| accountUnsized2 | 1893 | - | -| accountUnsizedInit4 | 21519 | 🔴 **+5.00%** | -| accountUnsized4 | 3104 | - | -| accountUnsizedInit8 | 41461 | 🔴 **+5.18%** | -| accountUnsized8 | 6051 | - | -| boxedAccountEmptyInit1 | 6447 | 🔴 **+4.66%** | -| boxedAccountEmpty1 | 976 | - | -| boxedAccountEmptyInit2 | 11292 | 🔴 **+4.71%** | -| boxedAccountEmpty2 | 1499 | - | -| boxedAccountEmptyInit4 | 20521 | 🔴 **+5.24%** | -| boxedAccountEmpty4 | 2530 | - | -| boxedAccountEmptyInit8 | 39456 | 🔴 **+5.46%** | -| boxedAccountEmpty8 | 4780 | - | -| boxedAccountSizedInit1 | 6544 | 🔴 **+4.60%** | -| boxedAccountSized1 | 1003 | - | -| boxedAccountSizedInit2 | 11485 | 🔴 **+4.65%** | -| boxedAccountSized2 | 1554 | - | -| boxedAccountSizedInit4 | 20904 | 🔴 **+5.13%** | -| boxedAccountSized4 | 2642 | - | -| boxedAccountSizedInit8 | 40224 | 🔴 **+5.35%** | -| boxedAccountSized8 | 5003 | - | -| boxedAccountUnsizedInit1 | 6661 | 🔴 **+4.50%** | -| boxedAccountUnsized1 | 1069 | - | -| boxedAccountUnsizedInit2 | 11720 | 🔴 **+4.54%** | -| boxedAccountUnsized2 | 1679 | - | -| boxedAccountUnsizedInit4 | 21372 | 🔴 **+5.02%** | -| boxedAccountUnsized4 | 2899 | - | -| boxedAccountUnsizedInit8 | 41159 | 🔴 **+5.22%** | -| boxedAccountUnsized8 | 5517 | - | -| boxedInterfaceAccountMint1 | 2299 | - | -| boxedInterfaceAccountMint2 | 4053 | - | -| boxedInterfaceAccountMint4 | 7538 | - | -| boxedInterfaceAccountMint8 | 14699 | - | -| boxedInterfaceAccountToken1 | 1737 | - | -| boxedInterfaceAccountToken2 | 2928 | - | -| boxedInterfaceAccountToken4 | 5291 | - | -| boxedInterfaceAccountToken8 | 10205 | - | -| interfaceAccountMint1 | 2530 | - | -| interfaceAccountMint2 | 4726 | - | -| interfaceAccountMint4 | 9431 | - | -| interfaceAccountMint8 | 17709 | - | -| interfaceAccountToken1 | 1755 | - | -| interfaceAccountToken2 | 3211 | - | -| interfaceAccountToken4 | 6006 | - | -| interface1 | 999 | - | -| interface2 | 1574 | - | -| interface4 | 1996 | - | -| interface8 | 3651 | - | -| program1 | 999 | - | -| program2 | 1573 | - | -| program4 | 1998 | - | -| program8 | 3651 | - | -| signer1 | 958 | - | -| signer2 | 1576 | - | -| signer4 | 2079 | - | -| signer8 | 3895 | - | -| systemAccount1 | 1013 | - | -| systemAccount2 | 1686 | - | -| systemAccount4 | 2298 | - | -| systemAccount8 | 4336 | - | -| uncheckedAccount1 | 953 | - | -| uncheckedAccount2 | 1567 | - | -| uncheckedAccount4 | 2060 | - | -| uncheckedAccount8 | 3855 | - | +| Instruction | Compute Units | +/- | +| --------------------------- | ------------- | --- | +| accountInfo1 | 1015 | - | +| accountInfo2 | 1475 | - | +| accountInfo4 | 1964 | - | +| accountInfo8 | 3856 | - | +| accountEmptyInit1 | 5817 | - | +| accountEmpty1 | 1149 | - | +| accountEmptyInit2 | 10402 | - | +| accountEmpty2 | 1754 | - | +| accountEmptyInit4 | 19557 | - | +| accountEmpty4 | 2540 | - | +| accountEmptyInit8 | 37541 | - | +| accountEmpty8 | 5043 | - | +| accountSizedInit1 | 5924 | - | +| accountSized1 | 1214 | - | +| accountSizedInit2 | 10783 | - | +| accountSized2 | 1873 | - | +| accountSizedInit4 | 19975 | - | +| accountSized4 | 2787 | - | +| accountSizedInit8 | 38381 | - | +| accountSized8 | 5359 | - | +| accountUnsizedInit1 | 6052 | - | +| accountUnsized1 | 1338 | - | +| accountUnsizedInit2 | 10929 | - | +| accountUnsized2 | 1778 | - | +| accountUnsizedInit4 | 20495 | - | +| accountUnsized4 | 3136 | - | +| accountUnsizedInit8 | 39419 | - | +| accountUnsized8 | 5952 | - | +| boxedAccountEmptyInit1 | 6034 | - | +| boxedAccountEmpty1 | 888 | - | +| boxedAccountEmptyInit2 | 10633 | - | +| boxedAccountEmpty2 | 1401 | - | +| boxedAccountEmptyInit4 | 19500 | - | +| boxedAccountEmpty4 | 2424 | - | +| boxedAccountEmptyInit8 | 37415 | - | +| boxedAccountEmpty8 | 4659 | - | +| boxedAccountSizedInit1 | 6130 | - | +| boxedAccountSized1 | 917 | - | +| boxedAccountSizedInit2 | 10828 | - | +| boxedAccountSized2 | 1463 | - | +| boxedAccountSizedInit4 | 19884 | - | +| boxedAccountSized4 | 2543 | - | +| boxedAccountSizedInit8 | 38182 | - | +| boxedAccountSized8 | 4898 | - | +| boxedAccountUnsizedInit1 | 6240 | - | +| boxedAccountUnsized1 | 972 | - | +| boxedAccountUnsizedInit2 | 11048 | - | +| boxedAccountUnsized2 | 1570 | - | +| boxedAccountUnsizedInit4 | 20138 | - | +| boxedAccountUnsized4 | 2768 | - | +| boxedAccountUnsizedInit8 | 39118 | - | +| boxedAccountUnsized8 | 5347 | - | +| boxedInterfaceAccountMint1 | 2299 | - | +| boxedInterfaceAccountMint2 | 4129 | - | +| boxedInterfaceAccountMint4 | 7783 | - | +| boxedInterfaceAccountMint8 | 15281 | - | +| boxedInterfaceAccountToken1 | 2023 | - | +| boxedInterfaceAccountToken2 | 3582 | - | +| boxedInterfaceAccountToken4 | 6692 | - | +| boxedInterfaceAccountToken8 | 13098 | - | +| interfaceAccountMint1 | 2364 | - | +| interfaceAccountMint2 | 5030 | - | +| interfaceAccountMint4 | 9803 | - | +| interfaceAccountMint8 | 18400 | - | +| interfaceAccountToken1 | 2091 | - | +| interfaceAccountToken2 | 3948 | - | +| interfaceAccountToken4 | 7547 | - | +| interface1 | 1059 | - | +| interface2 | 1479 | - | +| interface4 | 1900 | - | +| interface8 | 3651 | - | +| program1 | 1053 | - | +| program2 | 1467 | - | +| program4 | 1878 | - | +| program8 | 3598 | - | +| signer1 | 1018 | - | +| signer2 | 1484 | - | +| signer4 | 1984 | - | +| signer8 | 3895 | - | +| systemAccount1 | 1072 | - | +| systemAccount2 | 1590 | - | +| systemAccount4 | 2195 | - | +| systemAccount8 | 4336 | - | +| uncheckedAccount1 | 1014 | - | +| uncheckedAccount2 | 1475 | - | +| uncheckedAccount4 | 1965 | - | +| uncheckedAccount8 | 3855 | - | + +### Notable changes + +--- + +## [0.28.0] + +| Instruction | Compute Units | +/- | +| --------------------------- | ------------- | -------------- | +| accountInfo1 | 1015 | 🔴 **+6.39%** | +| accountInfo2 | 1475 | 🟢 **-5.87%** | +| accountInfo4 | 1964 | 🟢 **-4.61%** | +| accountInfo8 | 3856 | - | +| accountEmptyInit1 | 5817 | 🟢 **-2.37%** | +| accountEmpty1 | 1149 | 🔴 **+5.41%** | +| accountEmptyInit2 | 10402 | 🟢 **-1.63%** | +| accountEmpty2 | 1754 | 🟢 **-5.29%** | +| accountEmptyInit4 | 19557 | - | +| accountEmpty4 | 2540 | 🟢 **-4.01%** | +| accountEmptyInit8 | 37541 | - | +| accountEmpty8 | 5043 | - | +| accountSizedInit1 | 5924 | 🟢 **-2.29%** | +| accountSized1 | 1214 | 🔴 **+6.96%** | +| accountSizedInit2 | 10783 | - | +| accountSized2 | 1873 | 🟢 **-4.73%** | +| accountSizedInit4 | 19975 | - | +| accountSized4 | 2787 | - | +| accountSizedInit8 | 38381 | - | +| accountSized8 | 5359 | - | +| accountUnsizedInit1 | 6052 | 🟢 **-2.28%** | +| accountUnsized1 | 1338 | 🔴 **+7.64%** | +| accountUnsizedInit2 | 10929 | 🟢 **-1.02%** | +| accountUnsized2 | 1778 | 🟢 **-6.08%** | +| accountUnsizedInit4 | 20495 | - | +| accountUnsized4 | 3136 | 🔴 **+1.03%** | +| accountUnsizedInit8 | 39419 | - | +| accountUnsized8 | 5952 | 🟢 **-1.64%** | +| boxedAccountEmptyInit1 | 6034 | 🟢 **-2.05%** | +| boxedAccountEmpty1 | 888 | 🟢 **-9.02%** | +| boxedAccountEmptyInit2 | 10633 | 🟢 **-1.40%** | +| boxedAccountEmpty2 | 1401 | 🟢 **-6.54%** | +| boxedAccountEmptyInit4 | 19500 | - | +| boxedAccountEmpty4 | 2424 | 🟢 **-4.19%** | +| boxedAccountEmptyInit8 | 37415 | - | +| boxedAccountEmpty8 | 4659 | 🟢 **-2.53%** | +| boxedAccountSizedInit1 | 6130 | 🟢 **-2.01%** | +| boxedAccountSized1 | 917 | 🟢 **-8.57%** | +| boxedAccountSizedInit2 | 10828 | 🟢 **-1.34%** | +| boxedAccountSized2 | 1463 | 🟢 **-5.86%** | +| boxedAccountSizedInit4 | 19884 | - | +| boxedAccountSized4 | 2543 | 🟢 **-3.75%** | +| boxedAccountSizedInit8 | 38182 | - | +| boxedAccountSized8 | 4898 | 🟢 **-2.10%** | +| boxedAccountUnsizedInit1 | 6240 | 🟢 **-2.10%** | +| boxedAccountUnsized1 | 972 | 🟢 **-9.07%** | +| boxedAccountUnsizedInit2 | 11048 | 🟢 **-1.45%** | +| boxedAccountUnsized2 | 1570 | 🟢 **-6.49%** | +| boxedAccountUnsizedInit4 | 20138 | 🟢 **-1.05%** | +| boxedAccountUnsized4 | 2768 | 🟢 **-4.52%** | +| boxedAccountUnsizedInit8 | 39118 | - | +| boxedAccountUnsized8 | 5347 | 🟢 **-3.08%** | +| boxedInterfaceAccountMint1 | 2299 | - | +| boxedInterfaceAccountMint2 | 4129 | 🔴 **+1.88%** | +| boxedInterfaceAccountMint4 | 7783 | 🔴 **+3.25%** | +| boxedInterfaceAccountMint8 | 15281 | 🔴 **+3.96%** | +| boxedInterfaceAccountToken1 | 2023 | 🔴 **+16.47%** | +| boxedInterfaceAccountToken2 | 3582 | 🔴 **+22.34%** | +| boxedInterfaceAccountToken4 | 6692 | 🔴 **+26.48%** | +| boxedInterfaceAccountToken8 | 13098 | 🔴 **+28.35%** | +| interfaceAccountMint1 | 2364 | 🟢 **-6.56%** | +| interfaceAccountMint2 | 5030 | 🔴 **+6.43%** | +| interfaceAccountMint4 | 9803 | 🔴 **+3.94%** | +| interfaceAccountMint8 | 18400 | 🔴 **+3.90%** | +| interfaceAccountToken1 | 2091 | 🔴 **+19.15%** | +| interfaceAccountToken2 | 3948 | 🔴 **+22.95%** | +| interfaceAccountToken4 | 7547 | 🔴 **+25.66%** | +| interface1 | 1059 | 🔴 **+6.01%** | +| interface2 | 1479 | 🟢 **-6.04%** | +| interface4 | 1900 | 🟢 **-4.81%** | +| interface8 | 3651 | - | +| program1 | 1053 | 🔴 **+5.41%** | +| program2 | 1467 | 🟢 **-6.74%** | +| program4 | 1878 | 🟢 **-6.01%** | +| program8 | 3598 | 🟢 **-1.45%** | +| signer1 | 1018 | 🔴 **+6.26%** | +| signer2 | 1484 | 🟢 **-5.84%** | +| signer4 | 1984 | 🟢 **-4.57%** | +| signer8 | 3895 | - | +| systemAccount1 | 1072 | 🔴 **+5.82%** | +| systemAccount2 | 1590 | 🟢 **-5.69%** | +| systemAccount4 | 2195 | 🟢 **-4.48%** | +| systemAccount8 | 4336 | - | +| uncheckedAccount1 | 1014 | 🔴 **+6.40%** | +| uncheckedAccount2 | 1475 | 🟢 **-5.87%** | +| uncheckedAccount4 | 1965 | 🟢 **-4.61%** | +| uncheckedAccount8 | 3855 | - | ### Notable changes diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 63537baf59..76b26fb5e3 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "anchor-cli" -version = "0.27.0" -authors = ["armaniferrante "] +version = "0.28.0" +authors = ["Anchor Maintainers "] rust-version = "1.60" edition = "2021" repository = "https://github.com/coral-xyz/anchor" @@ -17,31 +17,34 @@ dev = [] default = [] [dependencies] -clap = { version = "4.2.4", features = ["derive"] } +anchor-client = { path = "../client", version = "0.28.0" } +anchor-lang = { path = "../lang", version = "0.28.0" } +anchor-syn = { path = "../lang/syn", features = ["event-cpi", "idl", "init-if-needed"], version = "0.28.0" } anyhow = "1.0.32" -syn = { version = "1.0.60", features = ["full", "extra-traits"] } -anchor-lang = { path = "../lang", version = "0.27.0" } -anchor-client = { path = "../client", version = "0.27.0" } -anchor-syn = { path = "../lang/syn", features = ["idl", "init-if-needed"], version = "0.27.0" } +base64 = "0.13.1" +bincode = "1.3.3" +cargo_toml = "0.13.0" +chrono = "0.4.19" +clap = { version = "4.2.4", features = ["derive"] } +dirs = "4.0" +flate2 = "1.0.19" +heck = "0.4.0" +pathdiff = "0.2.0" +portpicker = "0.1.1" +regex = "1.8.3" +reqwest = { version = "0.11.4", default-features = false, features = ["multipart", "blocking", "rustls-tls"] } +semver = "1.0.4" +serde = { version = "1.0.122", features = ["derive"] } serde_json = "1.0" shellexpand = "2.1.0" -toml = "0.5.8" +solana-client = ">=1.14, <1.17" +solana-cli-config = ">=1.14, <1.17" +solana-faucet = ">=1.14, <1.17" +solana-program = ">=1.14, <1.17" +solana-sdk = ">=1.14, <1.17" solang-parser = "=0.2.3" -semver = "1.0.4" -serde = { version = "1.0.122", features = ["derive"] } -solana-sdk = "1.14.16" -solana-program = "1.14.16" -solana-client = "1.14.16" -solana-cli-config = "1.14.16" -solana-faucet = "1.14.16" -dirs = "4.0" -heck = "0.4.0" -flate2 = "1.0.19" +syn = { version = "1.0.60", features = ["full", "extra-traits"] } tar = "0.4.35" -reqwest = { version = "0.11.4", default-features = false, features = ["multipart", "blocking", "rustls-tls"] } -tokio = "1.24" -pathdiff = "0.2.0" -cargo_toml = "0.13.0" +tokio = "~1.14.1" +toml = "0.5.8" walkdir = "2.3.2" -chrono = "0.4.19" -portpicker = "0.1.1" diff --git a/cli/npm-package/package.json b/cli/npm-package/package.json index f01dffe6fe..7ca1aa7514 100644 --- a/cli/npm-package/package.json +++ b/cli/npm-package/package.json @@ -1,6 +1,6 @@ { "name": "@coral-xyz/anchor-cli", - "version": "0.27.0", + "version": "0.28.0", "description": "Anchor CLI tool", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/cli/src/config.rs b/cli/src/config.rs index 1b4ae8a4d4..03c6b81884 100644 --- a/cli/src/config.rs +++ b/cli/src/config.rs @@ -263,6 +263,33 @@ impl WithPath { Ok(r) } + /// Read and get all the programs from the workspace. + /// + /// This method will only return the given program if `name` exists. + pub fn get_programs(&self, name: Option) -> Result> { + let programs = self.read_all_programs()?; + let programs = match name { + Some(name) => vec![programs + .into_iter() + .find(|program| { + name == program.lib_name + || name == program.path.file_name().unwrap().to_str().unwrap() + }) + .ok_or_else(|| anyhow!("Program {name} not found"))?], + None => programs, + }; + + Ok(programs) + } + + /// Get the specified program from the workspace. + pub fn get_program(&self, name: &str) -> Result { + self.get_programs(Some(name.to_owned()))? + .into_iter() + .next() + .ok_or_else(|| anyhow!("Expected a program")) + } + pub fn canonicalize_workspace(&self) -> Result<(Vec, Vec)> { let members = self .workspace @@ -296,29 +323,6 @@ impl WithPath { .collect(); Ok((members, exclude)) } - - pub fn get_program(&self, name: &str) -> Result>> { - for program in self.read_all_programs()? { - let cargo_toml = program.path.join("Cargo.toml"); - if !cargo_toml.exists() { - return Err(anyhow!( - "Did not find Cargo.toml at the path: {}", - program.path.display() - )); - } - let p_lib_name = Manifest::from_path(&cargo_toml)?.lib_name()?; - if name == p_lib_name { - let path = self - .path() - .parent() - .unwrap() - .canonicalize()? - .join(&program.path); - return Ok(Some(WithPath::new(program, path))); - } - } - Ok(None) - } } impl std::ops::Deref for WithPath { diff --git a/cli/src/lib.rs b/cli/src/lib.rs index 0f70c8fcf2..228fd36e22 100644 --- a/cli/src/lib.rs +++ b/cli/src/lib.rs @@ -14,13 +14,13 @@ use flate2::read::ZlibDecoder; use flate2::write::{GzEncoder, ZlibEncoder}; use flate2::Compression; use heck::{ToKebabCase, ToSnakeCase}; +use regex::RegexBuilder; use reqwest::blocking::multipart::{Form, Part}; use reqwest::blocking::Client; use semver::{Version, VersionReq}; use serde::{Deserialize, Serialize}; use serde_json::{json, Map, Value as JsonValue}; use solana_client::rpc_client::RpcClient; -use solana_client::rpc_config::RpcSendTransactionConfig; use solana_program::instruction::{AccountMeta, Instruction}; use solana_sdk::account_utils::StateMut; use solana_sdk::bpf_loader; @@ -324,7 +324,14 @@ pub enum Command { #[derive(Debug, Parser)] pub enum KeysCommand { + /// List all of the program keys. List, + /// Sync the program's `declare_id!` pubkey with the program's actual pubkey. + Sync { + /// Only sync the given program instead of all programs + #[clap(short, long)] + program_name: Option, + }, } #[derive(Debug, Parser)] @@ -337,6 +344,10 @@ pub enum IdlCommand { }, Close { program_id: Pubkey, + /// When used, the content of the instruction will only be printed in base64 form and not executed. + /// Useful for multisig execution when the local wallet keypair is not available. + #[clap(long)] + print_only: bool, }, /// Writes an IDL into a buffer account. This can be used with SetBuffer /// to perform an upgrade. @@ -351,6 +362,10 @@ pub enum IdlCommand { /// Address of the buffer account to set as the idl on the program. #[clap(short, long)] buffer: Pubkey, + /// When used, the content of the instruction will only be printed in base64 form and not executed. + /// Useful for multisig execution when the local wallet keypair is not available. + #[clap(long)] + print_only: bool, }, /// Upgrades the IDL to the new file. An alias for first writing and then /// then setting the idl buffer account. @@ -370,6 +385,10 @@ pub enum IdlCommand { /// New authority of the IDL account. #[clap(short, long)] new_authority: Pubkey, + /// When used, the content of the instruction will only be printed in base64 form and not executed. + /// Useful for multisig execution when the local wallet keypair is not available. + #[clap(long)] + print_only: bool, }, /// Command to remove the ability to modify the IDL account. This should /// likely be used in conjection with eliminating an "upgrade authority" on @@ -623,14 +642,15 @@ fn init( } let mut localnet = BTreeMap::new(); + let program_id = if solidity { + solidity_template::default_program_id() + } else { + rust_template::get_or_create_program_id(&rust_name) + }; localnet.insert( rust_name, ProgramDeployment { - address: if solidity { - solidity_template::default_program_id() - } else { - rust_template::default_program_id() - }, + address: program_id, path: None, idl: None, }, @@ -756,11 +776,31 @@ fn new(cfg_override: &ConfigOverride, solidity: bool, name: String) -> Result<() } Some(parent) => { std::env::set_current_dir(parent)?; - if solidity { - new_solidity_program(&name)?; - } else { - new_rust_program(&name)?; + + let cluster = cfg.provider.cluster.clone(); + let programs = cfg.programs.entry(cluster).or_insert(BTreeMap::new()); + if programs.contains_key(&name) { + return Err(anyhow!("Program already exists")); } + + programs.insert( + name.clone(), + ProgramDeployment { + address: if solidity { + new_solidity_program(&name)?; + solidity_template::default_program_id() + } else { + new_rust_program(&name)?; + rust_template::get_or_create_program_id(&name) + }, + path: None, + idl: None, + }, + ); + + let toml = cfg.to_string(); + fs::write("Anchor.toml", toml)?; + println!("Created new program."); } }; @@ -1657,14 +1697,12 @@ fn cd_member(cfg_override: &ConfigOverride, program_name: &str) -> Result<()> { } pub fn verify_bin(program_id: Pubkey, bin_path: &Path, cluster: &str) -> Result { - let client = RpcClient::new(cluster.to_string()); + // Use `finalized` state for verify + let client = RpcClient::new_with_commitment(cluster, CommitmentConfig::finalized()); // Get the deployed build artifacts. let (deployed_bin, state) = { - let account = client - .get_account_with_commitment(&program_id, CommitmentConfig::default())? - .value - .map_or(Err(anyhow!("Program account not found")), Ok)?; + let account = client.get_account(&program_id)?; if account.owner == bpf_loader::id() || account.owner == bpf_loader_deprecated::id() { let bin = account.data.to_vec(); let state = BinVerificationState::ProgramData { @@ -1677,13 +1715,7 @@ pub fn verify_bin(program_id: Pubkey, bin_path: &Path, cluster: &str) -> Result< UpgradeableLoaderState::Program { programdata_address, } => { - let account = client - .get_account_with_commitment( - &programdata_address, - CommitmentConfig::default(), - )? - .value - .map_or(Err(anyhow!("Program data account not found")), Ok)?; + let account = client.get_account(&programdata_address)?; let bin = account.data [UpgradeableLoaderState::size_of_programdata_metadata()..] .to_vec(); @@ -1772,19 +1804,12 @@ fn fetch_idl(cfg_override: &ConfigOverride, idl_addr: Pubkey) -> Result { } }; - let client = RpcClient::new(url); - - let mut account = client - .get_account_with_commitment(&idl_addr, CommitmentConfig::processed())? - .value - .map_or(Err(anyhow!("IDL account not found")), Ok)?; + let client = create_client(url); + let mut account = client.get_account(&idl_addr)?; if account.executable { let idl_addr = IdlAccount::address(&idl_addr); - account = client - .get_account_with_commitment(&idl_addr, CommitmentConfig::processed())? - .value - .map_or(Err(anyhow!("IDL account not found")), Ok)?; + account = client.get_account(&idl_addr)?; } // Cut off account discriminator. @@ -1824,14 +1849,19 @@ fn idl(cfg_override: &ConfigOverride, subcmd: IdlCommand) -> Result<()> { program_id, filepath, } => idl_init(cfg_override, program_id, filepath), - IdlCommand::Close { program_id } => idl_close(cfg_override, program_id), + IdlCommand::Close { + program_id, + print_only, + } => idl_close(cfg_override, program_id, print_only), IdlCommand::WriteBuffer { program_id, filepath, } => idl_write_buffer(cfg_override, program_id, filepath).map(|_| ()), - IdlCommand::SetBuffer { program_id, buffer } => { - idl_set_buffer(cfg_override, program_id, buffer) - } + IdlCommand::SetBuffer { + program_id, + buffer, + print_only, + } => idl_set_buffer(cfg_override, program_id, buffer, print_only), IdlCommand::Upgrade { program_id, filepath, @@ -1840,7 +1870,8 @@ fn idl(cfg_override: &ConfigOverride, subcmd: IdlCommand) -> Result<()> { program_id, address, new_authority, - } => idl_set_authority(cfg_override, program_id, address, new_authority), + print_only, + } => idl_set_authority(cfg_override, program_id, address, new_authority, print_only), IdlCommand::EraseAuthority { program_id } => idl_erase_authority(cfg_override, program_id), IdlCommand::Authority { program_id } => idl_authority(cfg_override, program_id), IdlCommand::Parse { @@ -1853,6 +1884,12 @@ fn idl(cfg_override: &ConfigOverride, subcmd: IdlCommand) -> Result<()> { } } +fn get_idl_account(client: &RpcClient, idl_address: &Pubkey) -> Result { + let account = client.get_account(idl_address)?; + let mut data: &[u8] = &account.data; + AccountDeserialize::try_deserialize(&mut data).map_err(|e| anyhow!("{:?}", e)) +} + fn idl_init(cfg_override: &ConfigOverride, program_id: Pubkey, idl_filepath: String) -> Result<()> { with_workspace(cfg_override, |cfg| { let keypair = cfg.provider.wallet.to_string(); @@ -1867,12 +1904,14 @@ fn idl_init(cfg_override: &ConfigOverride, program_id: Pubkey, idl_filepath: Str }) } -fn idl_close(cfg_override: &ConfigOverride, program_id: Pubkey) -> Result<()> { +fn idl_close(cfg_override: &ConfigOverride, program_id: Pubkey, print_only: bool) -> Result<()> { with_workspace(cfg_override, |cfg| { let idl_address = IdlAccount::address(&program_id); - idl_close_account(cfg, &program_id, idl_address)?; + idl_close_account(cfg, &program_id, idl_address, print_only)?; - println!("Idl account closed: {idl_address:?}"); + if !print_only { + println!("Idl account closed: {idl_address:?}"); + } Ok(()) }) @@ -1898,19 +1937,30 @@ fn idl_write_buffer( }) } -fn idl_set_buffer(cfg_override: &ConfigOverride, program_id: Pubkey, buffer: Pubkey) -> Result<()> { +fn idl_set_buffer( + cfg_override: &ConfigOverride, + program_id: Pubkey, + buffer: Pubkey, + print_only: bool, +) -> Result<()> { with_workspace(cfg_override, |cfg| { let keypair = solana_sdk::signature::read_keypair_file(&cfg.provider.wallet.to_string()) .map_err(|_| anyhow!("Unable to read keypair file"))?; let url = cluster_url(cfg, &cfg.test_validator); - let client = RpcClient::new(url); + let client = create_client(url); + let idl_address = IdlAccount::address(&program_id); + let idl_authority = if print_only { + get_idl_account(&client, &idl_address)?.authority + } else { + keypair.pubkey() + }; // Instruction to set the buffer onto the IdlAccount. - let set_buffer_ix = { + let ix = { let accounts = vec![ AccountMeta::new(buffer, false), - AccountMeta::new(IdlAccount::address(&program_id), false), - AccountMeta::new(keypair.pubkey(), true), + AccountMeta::new(idl_address, false), + AccountMeta::new(idl_authority, true), ]; let mut data = anchor_lang::idl::IDL_IX_TAG.to_le_bytes().to_vec(); data.append(&mut IdlInstruction::SetBuffer.try_to_vec()?); @@ -1921,24 +1971,21 @@ fn idl_set_buffer(cfg_override: &ConfigOverride, program_id: Pubkey, buffer: Pub } }; - // Build the transaction. - let latest_hash = client.get_latest_blockhash()?; - let tx = Transaction::new_signed_with_payer( - &[set_buffer_ix], - Some(&keypair.pubkey()), - &[&keypair], - latest_hash, - ); + if print_only { + print_idl_instruction("SetBuffer", &ix, &idl_address)?; + } else { + // Build the transaction. + let latest_hash = client.get_latest_blockhash()?; + let tx = Transaction::new_signed_with_payer( + &[ix], + Some(&keypair.pubkey()), + &[&keypair], + latest_hash, + ); - // Send the transaction. - client.send_and_confirm_transaction_with_spinner_and_config( - &tx, - CommitmentConfig::confirmed(), - RpcSendTransactionConfig { - skip_preflight: true, - ..RpcSendTransactionConfig::default() - }, - )?; + // Send the transaction. + client.send_and_confirm_transaction_with_spinner(&tx)?; + } Ok(()) }) @@ -1950,18 +1997,15 @@ fn idl_upgrade( idl_filepath: String, ) -> Result<()> { let buffer = idl_write_buffer(cfg_override, program_id, idl_filepath)?; - idl_set_buffer(cfg_override, program_id, buffer) + idl_set_buffer(cfg_override, program_id, buffer, false) } fn idl_authority(cfg_override: &ConfigOverride, program_id: Pubkey) -> Result<()> { with_workspace(cfg_override, |cfg| { let url = cluster_url(cfg, &cfg.test_validator); - let client = RpcClient::new(url); + let client = create_client(url); let idl_address = { - let account = client - .get_account_with_commitment(&program_id, CommitmentConfig::processed())? - .value - .map_or(Err(anyhow!("Account not found")), Ok)?; + let account = client.get_account(&program_id)?; if account.executable { IdlAccount::address(&program_id) } else { @@ -1969,9 +2013,7 @@ fn idl_authority(cfg_override: &ConfigOverride, program_id: Pubkey) -> Result<() } }; - let account = client.get_account(&idl_address)?; - let mut data: &[u8] = &account.data; - let idl_account: IdlAccount = AccountDeserialize::try_deserialize(&mut data)?; + let idl_account = get_idl_account(&client, &idl_address)?; println!("{:?}", idl_account.authority); @@ -1984,6 +2026,7 @@ fn idl_set_authority( program_id: Pubkey, address: Option, new_authority: Pubkey, + print_only: bool, ) -> Result<()> { with_workspace(cfg_override, |cfg| { // Misc. @@ -1994,7 +2037,13 @@ fn idl_set_authority( let keypair = solana_sdk::signature::read_keypair_file(&cfg.provider.wallet.to_string()) .map_err(|_| anyhow!("Unable to read keypair file"))?; let url = cluster_url(cfg, &cfg.test_validator); - let client = RpcClient::new(url); + let client = create_client(url); + + let idl_authority = if print_only { + get_idl_account(&client, &idl_address)?.authority + } else { + keypair.pubkey() + }; // Instruction data. let data = @@ -2003,7 +2052,7 @@ fn idl_set_authority( // Instruction accounts. let accounts = vec![ AccountMeta::new(idl_address, false), - AccountMeta::new_readonly(keypair.pubkey(), true), + AccountMeta::new_readonly(idl_authority, true), ]; // Instruction. @@ -2012,24 +2061,22 @@ fn idl_set_authority( accounts, data, }; - // Send transaction. - let latest_hash = client.get_latest_blockhash()?; - let tx = Transaction::new_signed_with_payer( - &[ix], - Some(&keypair.pubkey()), - &[&keypair], - latest_hash, - ); - client.send_and_confirm_transaction_with_spinner_and_config( - &tx, - CommitmentConfig::confirmed(), - RpcSendTransactionConfig { - skip_preflight: true, - ..RpcSendTransactionConfig::default() - }, - )?; - println!("Authority update complete."); + if print_only { + print_idl_instruction("SetAuthority", &ix, &idl_address)?; + } else { + // Send transaction. + let latest_hash = client.get_latest_blockhash()?; + let tx = Transaction::new_signed_with_payer( + &[ix], + Some(&keypair.pubkey()), + &[&keypair], + latest_hash, + ); + client.send_and_confirm_transaction_with_spinner(&tx)?; + + println!("Authority update complete."); + } Ok(()) }) @@ -2046,22 +2093,32 @@ fn idl_erase_authority(cfg_override: &ConfigOverride, program_id: Pubkey) -> Res return Ok(()); } - idl_set_authority(cfg_override, program_id, None, ERASED_AUTHORITY)?; + idl_set_authority(cfg_override, program_id, None, ERASED_AUTHORITY, false)?; Ok(()) } -fn idl_close_account(cfg: &Config, program_id: &Pubkey, idl_address: Pubkey) -> Result<()> { +fn idl_close_account( + cfg: &Config, + program_id: &Pubkey, + idl_address: Pubkey, + print_only: bool, +) -> Result<()> { let keypair = solana_sdk::signature::read_keypair_file(&cfg.provider.wallet.to_string()) .map_err(|_| anyhow!("Unable to read keypair file"))?; let url = cluster_url(cfg, &cfg.test_validator); - let client = RpcClient::new(url); + let client = create_client(url); + let idl_authority = if print_only { + get_idl_account(&client, &idl_address)?.authority + } else { + keypair.pubkey() + }; // Instruction accounts. let accounts = vec![ AccountMeta::new(idl_address, false), - AccountMeta::new_readonly(keypair.pubkey(), true), - AccountMeta::new(keypair.pubkey(), true), + AccountMeta::new_readonly(idl_authority, true), + AccountMeta::new(keypair.pubkey(), false), ]; // Instruction. let ix = Instruction { @@ -2069,22 +2126,20 @@ fn idl_close_account(cfg: &Config, program_id: &Pubkey, idl_address: Pubkey) -> accounts, data: { serialize_idl_ix(anchor_lang::idl::IdlInstruction::Close {})? }, }; - // Send transaction. - let latest_hash = client.get_latest_blockhash()?; - let tx = Transaction::new_signed_with_payer( - &[ix], - Some(&keypair.pubkey()), - &[&keypair], - latest_hash, - ); - client.send_and_confirm_transaction_with_spinner_and_config( - &tx, - CommitmentConfig::confirmed(), - RpcSendTransactionConfig { - skip_preflight: true, - ..RpcSendTransactionConfig::default() - }, - )?; + + if print_only { + print_idl_instruction("Close", &ix, &idl_address)?; + } else { + // Send transaction. + let latest_hash = client.get_latest_blockhash()?; + let tx = Transaction::new_signed_with_payer( + &[ix], + Some(&keypair.pubkey()), + &[&keypair], + latest_hash, + ); + client.send_and_confirm_transaction_with_spinner(&tx)?; + } Ok(()) } @@ -2101,7 +2156,7 @@ fn idl_write(cfg: &Config, program_id: &Pubkey, idl: &Idl, idl_address: Pubkey) let keypair = solana_sdk::signature::read_keypair_file(&cfg.provider.wallet.to_string()) .map_err(|_| anyhow!("Unable to read keypair file"))?; let url = cluster_url(cfg, &cfg.test_validator); - let client = RpcClient::new(url); + let client = create_client(url); // Serialize and compress the idl. let idl_data = { @@ -2141,14 +2196,7 @@ fn idl_write(cfg: &Config, program_id: &Pubkey, idl: &Idl, idl_address: Pubkey) &[&keypair], latest_hash, ); - client.send_and_confirm_transaction_with_spinner_and_config( - &tx, - CommitmentConfig::confirmed(), - RpcSendTransactionConfig { - skip_preflight: true, - ..RpcSendTransactionConfig::default() - }, - )?; + client.send_and_confirm_transaction_with_spinner(&tx)?; offset += MAX_WRITE_SIZE; } Ok(()) @@ -2196,6 +2244,35 @@ fn write_idl(idl: &Idl, out: OutFile) -> Result<()> { Ok(()) } +/// Print `base64+borsh` encoded IDL instruction. +fn print_idl_instruction(ix_name: &str, ix: &Instruction, idl_address: &Pubkey) -> Result<()> { + println!("Print only mode. No execution!"); + println!("Instruction: {ix_name}"); + println!("IDL address: {idl_address}"); + println!("Program: {}", ix.program_id); + + // Serialize with `bincode` because `Instruction` does not implement `BorshSerialize` + let mut serialized_ix = bincode::serialize(ix)?; + + // Remove extra bytes in order to make the serialized instruction `borsh` compatible + // `bincode` uses 8 bytes(LE) for length meanwhile `borsh` uses 4 bytes(LE) + let mut remove_extra_vec_bytes = |index: usize| { + serialized_ix.drain((index + 4)..(index + 8)); + }; + + let accounts_index = std::mem::size_of_val(&ix.program_id); + remove_extra_vec_bytes(accounts_index); + let data_index = accounts_index + 4 + std::mem::size_of_val(&*ix.accounts); + remove_extra_vec_bytes(data_index); + + println!( + "Base64 encoded instruction: {}", + base64::encode(serialized_ix) + ); + + Ok(()) +} + fn account( cfg_override: &ConfigOverride, account_type: String, @@ -2244,7 +2321,7 @@ fn account( .unwrap_or(Cluster::Localnet); cluster = cfg_override.cluster.as_ref().unwrap_or(cluster); - let data = RpcClient::new(cluster.url()).get_account_data(&address)?; + let data = create_client(cluster.url()).get_account_data(&address)?; if data.len() < 8 { return Err(anyhow!( "The account has less than 8 bytes and is not an Anchor account." @@ -2708,7 +2785,7 @@ fn validator_flags( } else if key == "clone" { // Client for fetching accounts data let client = if let Some(url) = entries["url"].as_str() { - RpcClient::new(url.to_string()) + create_client(url) } else { return Err(anyhow!( "Validator url for Solana's JSON RPC should be provided in order to clone accounts from it" @@ -2727,12 +2804,7 @@ fn validator_flags( .collect::>>()?; let accounts_keys = pubkeys.iter().cloned().collect::>(); - let accounts = client - .get_multiple_accounts_with_commitment( - &accounts_keys, - CommitmentConfig::default(), - )? - .value; + let accounts = client.get_multiple_accounts(&accounts_keys)?; // Check if there are program accounts for (account, acc_key) in accounts.iter().zip(accounts_keys) { @@ -2840,7 +2912,6 @@ fn start_test_validator( flags: Option>, test_log_stdout: bool, ) -> Result { - // let (test_ledger_directory, test_ledger_log_filename) = test_validator_file_paths(test_validator); @@ -2892,7 +2963,7 @@ fn start_test_validator( .map_err(|e| anyhow::format_err!("{}", e.to_string()))?; // Wait for the validator to be ready. - let client = RpcClient::new(rpc_url); + let client = create_client(rpc_url); let mut count = 0; let ms_wait = test_validator .as_ref() @@ -2973,23 +3044,31 @@ fn clean(cfg_override: &ConfigOverride) -> Result<()> { let target_dir = cfg_parent.join("target"); let deploy_dir = target_dir.join("deploy"); - for entry in fs::read_dir(target_dir)? { - let path = entry?.path(); - if path.is_dir() && path != deploy_dir { - fs::remove_dir_all(&path) - .map_err(|e| anyhow!("Could not remove directory {}: {}", path.display(), e))?; - } else if path.is_file() { - fs::remove_file(&path) - .map_err(|e| anyhow!("Could not remove file {}: {}", path.display(), e))?; + if target_dir.exists() { + for entry in fs::read_dir(target_dir)? { + let path = entry?.path(); + if path.is_dir() && path != deploy_dir { + fs::remove_dir_all(&path) + .map_err(|e| anyhow!("Could not remove directory {}: {}", path.display(), e))?; + } else if path.is_file() { + fs::remove_file(&path) + .map_err(|e| anyhow!("Could not remove file {}: {}", path.display(), e))?; + } } + } else { + println!("skipping target directory: not found") } - for file in fs::read_dir(deploy_dir)? { - let path = file?.path(); - if path.extension() != Some(&OsString::from("json")) { - fs::remove_file(&path) - .map_err(|e| anyhow!("Could not remove file {}: {}", path.display(), e))?; + if deploy_dir.exists() { + for file in fs::read_dir(deploy_dir)? { + let path = file?.path(); + if path.extension() != Some(&OsString::from("json")) { + fs::remove_file(&path) + .map_err(|e| anyhow!("Could not remove file {}: {}", path.display(), e))?; + } } + } else { + println!("skipping deploy directory: not found") } Ok(()) @@ -2997,39 +3076,38 @@ fn clean(cfg_override: &ConfigOverride) -> Result<()> { fn deploy( cfg_override: &ConfigOverride, - program_str: Option, + program_name: Option, program_keypair: Option, ) -> Result<()> { + // Execute the code within the workspace with_workspace(cfg_override, |cfg| { let url = cluster_url(cfg, &cfg.test_validator); let keypair = cfg.provider.wallet.to_string(); // Deploy the programs. - println!("Deploying workspace: {url}"); - println!("Upgrade authority: {keypair}"); + println!("Deploying cluster: {}", url); + println!("Upgrade authority: {}", keypair); - for mut program in cfg.read_all_programs()? { - if let Some(single_prog_str) = &program_str { - let program_name = program.path.file_name().unwrap().to_str().unwrap(); - if single_prog_str.as_str() != program_name { - continue; - } - } + for mut program in cfg.get_programs(program_name)? { let binary_path = program.binary_path().display().to_string(); - println!( - "Deploying program {:?}...", - program.path.file_name().unwrap().to_str().unwrap() - ); - - println!("Program path: {binary_path}..."); - - let program_keypair_filepath = match &program_keypair { - Some(program_keypair) => program_keypair.clone(), - None => program.keypair_file()?.path().display().to_string(), + println!("Deploying program {:?}...", program.lib_name); + println!("Program path: {}...", binary_path); + + let (program_keypair_filepath, program_id) = match &program_keypair { + Some(path) => ( + path.clone(), + solana_sdk::signature::read_keypair_file(path) + .map_err(|_| anyhow!("Unable to read keypair file"))? + .pubkey(), + ), + None => ( + program.keypair_file()?.path().display().to_string(), + program.pubkey()?, + ), }; - // Send deploy transactions. + // Send deploy transactions using the Solana CLI let exit = std::process::Command::new("solana") .arg("program") .arg("deploy") @@ -3044,16 +3122,17 @@ fn deploy( .stderr(Stdio::inherit()) .output() .expect("Must deploy"); + + // Check if deployment was successful if !exit.status.success() { println!("There was a problem deploying: {exit:?}."); std::process::exit(exit.status.code().unwrap_or(1)); } - let program_pubkey = program.pubkey()?; if let Some(mut idl) = program.idl.as_mut() { // Add program address to the IDL. idl.metadata = Some(serde_json::to_value(IdlTestMetadata { - address: program_pubkey.to_string(), + address: program_id.to_string(), })?); // Persist it. @@ -3113,7 +3192,7 @@ fn create_idl_account( let keypair = solana_sdk::signature::read_keypair_file(keypair_path) .map_err(|_| anyhow!("Unable to read keypair file"))?; let url = cluster_url(cfg, &cfg.test_validator); - let client = RpcClient::new(url); + let client = create_client(url); let idl_data = serialize_idl(idl)?; // Run `Create instruction. @@ -3168,14 +3247,7 @@ fn create_idl_account( &[&keypair], latest_hash, ); - client.send_and_confirm_transaction_with_spinner_and_config( - &tx, - CommitmentConfig::finalized(), - RpcSendTransactionConfig { - skip_preflight: true, - ..RpcSendTransactionConfig::default() - }, - )?; + client.send_and_confirm_transaction_with_spinner(&tx)?; } // Write directly to the IDL account buffer. @@ -3193,7 +3265,7 @@ fn create_idl_buffer( let keypair = solana_sdk::signature::read_keypair_file(keypair_path) .map_err(|_| anyhow!("Unable to read keypair file"))?; let url = cluster_url(cfg, &cfg.test_validator); - let client = RpcClient::new(url); + let client = create_client(url); let buffer = Keypair::new(); @@ -3236,14 +3308,7 @@ fn create_idl_buffer( ); // Send the transaction. - client.send_and_confirm_transaction_with_spinner_and_config( - &tx, - CommitmentConfig::confirmed(), - RpcSendTransactionConfig { - skip_preflight: true, - ..RpcSendTransactionConfig::default() - }, - )?; + client.send_and_confirm_transaction_with_spinner(&tx)?; Ok(buffer.pubkey()) } @@ -3488,12 +3553,10 @@ fn publish( // Discover the various workspace configs. let cfg = Config::discover(cfg_override)?.expect("Not in workspace."); - let program = cfg - .get_program(&program_name)? - .ok_or_else(|| anyhow!("Workspace member not found"))?; + let program = cfg.get_program(&program_name)?; let program_cargo_lock = pathdiff::diff_paths( - program.path().join("Cargo.lock"), + program.path.join("Cargo.lock"), cfg.path().parent().unwrap(), ) .ok_or_else(|| anyhow!("Unable to diff Cargo.lock path"))?; @@ -3678,6 +3741,7 @@ fn registry_api_token(_cfg_override: &ConfigOverride) -> Result { fn keys(cfg_override: &ConfigOverride, cmd: KeysCommand) -> Result<()> { match cmd { KeysCommand::List => keys_list(cfg_override), + KeysCommand::Sync { program_name } => keys_sync(cfg_override, program_name), } } @@ -3691,6 +3755,72 @@ fn keys_list(cfg_override: &ConfigOverride) -> Result<()> { }) } +/// Sync the program's `declare_id!` pubkey with the pubkey from `target/deploy/.json`. +fn keys_sync(cfg_override: &ConfigOverride, program_name: Option) -> Result<()> { + with_workspace(cfg_override, |cfg| { + let declare_id_regex = RegexBuilder::new(r#"^(([\w]+::)*)declare_id!\("(\w*)"\)"#) + .multi_line(true) + .build() + .unwrap(); + + for program in cfg.get_programs(program_name)? { + // Get the pubkey from the keypair file + let actual_program_id = program.pubkey()?.to_string(); + + // Handle declaration in program files + let src_path = program.path.join("src"); + let files_to_check = vec![src_path.join("lib.rs"), src_path.join("id.rs")]; + + for path in files_to_check { + let mut content = match fs::read_to_string(&path) { + Ok(content) => content, + Err(_) => continue, + }; + + let incorrect_program_id = declare_id_regex + .captures(&content) + .and_then(|captures| captures.get(3)) + .filter(|program_id_match| program_id_match.as_str() != actual_program_id); + if let Some(program_id_match) = incorrect_program_id { + println!("Found incorrect program id declaration in {path:?}"); + + // Update the program id + content.replace_range(program_id_match.range(), &actual_program_id); + fs::write(&path, content)?; + + println!("Updated to {actual_program_id}\n"); + break; + } + } + + // Handle declaration in Anchor.toml + 'outer: for programs in cfg.programs.values_mut() { + for (name, mut deployment) in programs { + // Skip other programs + if name != &program.lib_name { + continue; + } + + if deployment.address.to_string() != actual_program_id { + println!("Found incorrect program id declaration in Anchor.toml for the program `{name}`"); + + // Update the program id + deployment.address = Pubkey::from_str(&actual_program_id).unwrap(); + fs::write(cfg.path(), cfg.to_string())?; + + println!("Updated to {actual_program_id}\n"); + break 'outer; + } + } + } + } + + println!("All program id declarations are synced."); + + Ok(()) + }) +} + fn localnet( cfg_override: &ConfigOverride, skip_build: bool, @@ -3822,6 +3952,11 @@ fn strip_workspace_prefix(absolute_path: String) -> String { .into() } +/// Create a new [`RpcClient`] with `confirmed` commitment level instead of the default(finalized). +fn create_client(url: U) -> RpcClient { + RpcClient::new_with_commitment(url, CommitmentConfig::confirmed()) +} + #[cfg(test)] mod tests { use super::*; diff --git a/cli/src/rust_template.rs b/cli/src/rust_template.rs index 04a284f177..f05d67f7da 100644 --- a/cli/src/rust_template.rs +++ b/cli/src/rust_template.rs @@ -3,13 +3,26 @@ use crate::VERSION; use anchor_syn::idl::Idl; use anyhow::Result; use heck::{ToLowerCamelCase, ToSnakeCase, ToUpperCamelCase}; -use solana_sdk::pubkey::Pubkey; -use std::fmt::Write; - -pub fn default_program_id() -> Pubkey { - "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS" - .parse() - .unwrap() +use solana_sdk::{ + pubkey::Pubkey, + signature::{read_keypair_file, write_keypair_file, Keypair}, + signer::Signer, +}; +use std::{fmt::Write, path::Path}; + +/// Read the program keypair file or create a new one if it doesn't exist. +pub fn get_or_create_program_id(name: &str) -> Pubkey { + let keypair_path = Path::new("target") + .join("deploy") + .join(format!("{}-keypair.json", name.to_snake_case())); + + read_keypair_file(&keypair_path) + .unwrap_or_else(|_| { + let keypair = Keypair::new(); + write_keypair_file(&keypair, keypair_path).expect("Unable to create program keypair"); + keypair + }) + .pubkey() } pub fn virtual_manifest() -> &'static str { @@ -192,7 +205,7 @@ pub mod {} {{ #[derive(Accounts)] pub struct Initialize {{}} "#, - default_program_id(), + get_or_create_program_id(name), name.to_snake_case(), ) } diff --git a/client/Cargo.toml b/client/Cargo.toml index 2f950e0afb..1abfc9de59 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "anchor-client" -version = "0.27.0" -authors = ["Serum Foundation "] +version = "0.28.0" +authors = ["Anchor Maintainers "] rust-version = "1.60" edition = "2021" license = "Apache-2.0" @@ -9,14 +9,17 @@ description = "Rust client for Anchor programs" [features] debug = [] +async = [] [dependencies] -anchor-lang = { path = "../lang", version = "0.27.0" } -anyhow = "1.0.32" -regex = "1.4.5" -serde = { version = "1.0.122", features = ["derive"] } -solana-client = "1.14.7" -solana-sdk = "1.14.16" -solana-account-decoder = "1.14.16" -thiserror = "1.0.20" -url = "2.2.2" +anchor-lang = { path = "../lang", version = "0.28.0" } +anyhow = "1" +futures = { version = "0.3" } +regex = "1" +serde = { version = "1", features = ["derive"] } +solana-client = ">=1.14, <1.17" +solana-sdk = ">=1.14, <1.17" +solana-account-decoder = ">=1.14, <1.17" +thiserror = "1" +tokio = { version = "1", features = ["rt", "sync"] } +url = "2" diff --git a/client/example/Cargo.toml b/client/example/Cargo.toml index 56768daab0..f18138d3fe 100644 --- a/client/example/Cargo.toml +++ b/client/example/Cargo.toml @@ -7,6 +7,9 @@ edition = "2021" [workspace] +[features] +async = ["anchor-client/async"] + [dependencies] anchor-client = { path = "../", features = ["debug"] } basic-2 = { path = "../../examples/tutorial/basic-2/programs/basic-2", features = ["no-entrypoint"] } @@ -17,4 +20,5 @@ events = { path = "../../tests/events/programs/events", features = ["no-entrypoi shellexpand = "2.1.0" anyhow = "1.0.32" clap = { version = "4.2.4", features = ["derive"] } -solana-sdk = "1.14.16" +tokio = { version = "1", features = ["full"] } +solana-sdk = ">=1.14, <1.17" diff --git a/client/example/run-test.sh b/client/example/run-test.sh index 4264cdf78e..13f3e47f8b 100755 --- a/client/example/run-test.sh +++ b/client/example/run-test.sh @@ -74,6 +74,30 @@ main() { --optional-pid $optional_pid \ --multithreaded + # + # Restart validator for async test + # + cleanup + solana-test-validator -r \ + --bpf-program $composite_pid ../../tests/composite/target/deploy/composite.so \ + --bpf-program $basic_2_pid ../../examples/tutorial/basic-2/target/deploy/basic_2.so \ + --bpf-program $basic_4_pid ../../examples/tutorial/basic-4/target/deploy/basic_4.so \ + --bpf-program $events_pid ../../tests/events/target/deploy/events.so \ + --bpf-program $optional_pid ../../tests/optional/target/deploy/optional.so \ + > test-validator.log & + sleep 5 + + # + # Run async test. + # + cargo run --features async -- \ + --composite-pid $composite_pid \ + --basic-2-pid $basic_2_pid \ + --basic-4-pid $basic_4_pid \ + --events-pid $events_pid \ + --optional-pid $optional_pid \ + --multithreaded + } cleanup() { diff --git a/client/example/src/blocking.rs b/client/example/src/blocking.rs new file mode 100644 index 0000000000..eaf7a01b28 --- /dev/null +++ b/client/example/src/blocking.rs @@ -0,0 +1,329 @@ +use anchor_client::solana_sdk::pubkey::Pubkey; +use anchor_client::solana_sdk::signature::{Keypair, Signer}; +use anchor_client::solana_sdk::system_instruction; +use anchor_client::{Client, Cluster}; +use anyhow::Result; +use clap::Parser; +use solana_sdk::commitment_config::CommitmentConfig; +use solana_sdk::signature::read_keypair_file; +use solana_sdk::system_program; +// The `accounts` and `instructions` modules are generated by the framework. +use basic_2::accounts as basic_2_accounts; +use basic_2::instruction as basic_2_instruction; +use basic_2::Counter; +use events::instruction as events_instruction; +use events::MyEvent; +use optional::accounts::Initialize as OptionalInitialize; +use optional::instruction as optional_instruction; +// The `accounts` and `instructions` modules are generated by the framework. +use basic_4::accounts as basic_4_accounts; +use basic_4::instruction as basic_4_instruction; +use basic_4::Counter as CounterAccount; +// The `accounts` and `instructions` modules are generated by the framework. +use crate::Opts; +use composite::accounts::{Bar, CompositeUpdate, Foo, Initialize}; +use composite::instruction as composite_instruction; +use composite::{DummyA, DummyB}; +use optional::account::{DataAccount, DataPda}; +use std::ops::Deref; +use std::rc::Rc; +use std::sync::Arc; +use std::thread::sleep; +use std::time::Duration; + +type TestFn = &'static (dyn Fn(&Client, Pubkey) -> Result<()> + Send + Sync); + +pub fn main() -> Result<()> { + let opts = Opts::parse(); + + // Wallet and cluster params. + let payer = read_keypair_file(&*shellexpand::tilde("~/.config/solana/id.json")) + .expect("Example requires a keypair file"); + let url = Cluster::Custom( + "http://localhost:8899".to_string(), + "ws://127.0.0.1:8900".to_string(), + ); + + if !opts.multithreaded { + // Client. + let payer = Rc::new(payer); + let client = + Client::new_with_options(url.clone(), payer.clone(), CommitmentConfig::processed()); + + // Run tests on single thread with a single client using an Rc + println!("\nStarting single thread test..."); + composite(&client, opts.composite_pid)?; + basic_2(&client, opts.basic_2_pid)?; + basic_4(&client, opts.basic_4_pid)?; + + // Can also use references, since they deref to a signer + let payer: &Keypair = &payer; + let client = Client::new_with_options(url, payer, CommitmentConfig::processed()); + events(&client, opts.events_pid)?; + optional(&client, opts.optional_pid)?; + } else { + // Client. + let payer = Arc::new(payer); + let client = Client::new_with_options(url, payer, CommitmentConfig::processed()); + let client = Arc::new(client); + + // Run tests multithreaded while sharing a client + println!("\nStarting multithread test..."); + let client = Arc::new(client); + let tests: Vec<(TestFn>, Pubkey)> = vec![ + (&composite, opts.composite_pid), + (&basic_2, opts.basic_2_pid), + (&basic_4, opts.basic_4_pid), + (&events, opts.events_pid), + (&optional, opts.optional_pid), + ]; + let mut handles = vec![]; + for (test, arg) in tests { + let local_client = Arc::clone(&client); + handles.push(std::thread::spawn(move || test(&local_client, arg))); + } + for handle in handles { + assert!(handle.join().unwrap().is_ok()); + } + } + + // Success. + Ok(()) +} + +// Runs a client for examples/tutorial/composite. +// +// Make sure to run a localnet with the program deploy to run this example. +pub fn composite + Clone>( + client: &Client, + pid: Pubkey, +) -> Result<()> { + // Program client. + let program = client.program(pid)?; + + // `Initialize` parameters. + let dummy_a = Keypair::new(); + let dummy_b = Keypair::new(); + + // Build and send a transaction. + program + .request() + .instruction(system_instruction::create_account( + &program.payer(), + &dummy_a.pubkey(), + program.rpc().get_minimum_balance_for_rent_exemption(500)?, + 500, + &program.id(), + )) + .instruction(system_instruction::create_account( + &program.payer(), + &dummy_b.pubkey(), + program.rpc().get_minimum_balance_for_rent_exemption(500)?, + 500, + &program.id(), + )) + .signer(&dummy_a) + .signer(&dummy_b) + .accounts(Initialize { + dummy_a: dummy_a.pubkey(), + dummy_b: dummy_b.pubkey(), + }) + .args(composite_instruction::Initialize) + .send()?; + + // Assert the transaction worked. + let dummy_a_account: DummyA = program.account(dummy_a.pubkey())?; + let dummy_b_account: DummyB = program.account(dummy_b.pubkey())?; + assert_eq!(dummy_a_account.data, 0); + assert_eq!(dummy_b_account.data, 0); + + // Build and send another transaction, using composite account parameters. + program + .request() + .accounts(CompositeUpdate { + foo: Foo { + dummy_a: dummy_a.pubkey(), + }, + bar: Bar { + dummy_b: dummy_b.pubkey(), + }, + }) + .args(composite_instruction::CompositeUpdate { + dummy_a: 1234, + dummy_b: 4321, + }) + .send()?; + + // Assert the transaction worked. + let dummy_a_account: DummyA = program.account(dummy_a.pubkey())?; + let dummy_b_account: DummyB = program.account(dummy_b.pubkey())?; + assert_eq!(dummy_a_account.data, 1234); + assert_eq!(dummy_b_account.data, 4321); + + println!("Composite success!"); + + Ok(()) +} + +// Runs a client for examples/tutorial/basic-2. +// +// Make sure to run a localnet with the program deploy to run this example. +pub fn basic_2 + Clone>( + client: &Client, + pid: Pubkey, +) -> Result<()> { + let program = client.program(pid)?; + + // `Create` parameters. + let counter = Keypair::new(); + let authority = program.payer(); + + // Build and send a transaction. + program + .request() + .signer(&counter) + .accounts(basic_2_accounts::Create { + counter: counter.pubkey(), + user: authority, + system_program: system_program::ID, + }) + .args(basic_2_instruction::Create { authority }) + .send()?; + + let counter_account: Counter = program.account(counter.pubkey())?; + + assert_eq!(counter_account.authority, authority); + assert_eq!(counter_account.count, 0); + + println!("Basic 2 success!"); + + Ok(()) +} + +pub fn events + Clone>( + client: &Client, + pid: Pubkey, +) -> Result<()> { + let program = client.program(pid)?; + + let (sender, receiver) = std::sync::mpsc::channel(); + let event_unsubscriber = program.on(move |_, event: MyEvent| { + if sender.send(event).is_err() { + println!("Error while transferring the event.") + } + })?; + + sleep(Duration::from_millis(1000)); + + program + .request() + .args(events_instruction::Initialize {}) + .send()?; + + let event = receiver.recv().unwrap(); + assert_eq!(event.data, 5); + assert_eq!(event.label, "hello".to_string()); + + event_unsubscriber.unsubscribe(); + + println!("Events success!"); + + Ok(()) +} + +pub fn basic_4 + Clone>( + client: &Client, + pid: Pubkey, +) -> Result<()> { + let program = client.program(pid)?; + let authority = program.payer(); + let (counter, _) = Pubkey::find_program_address(&[b"counter"], &pid); + + program + .request() + .accounts(basic_4_accounts::Initialize { + counter, + authority, + system_program: system_program::ID, + }) + .args(basic_4_instruction::Initialize {}) + .send()?; + let counter_account: CounterAccount = program.account(counter)?; + assert_eq!(counter_account.authority, authority); + assert_eq!(counter_account.count, 0); + + program + .request() + .accounts(basic_4_accounts::Increment { counter, authority }) + .args(basic_4_instruction::Increment {}) + .send()?; + + let counter_account: CounterAccount = program.account(counter)?; + assert_eq!(counter_account.authority, authority); + assert_eq!(counter_account.count, 1); + + println!("Basic 4 success!"); + + Ok(()) +} + +// Runs a client for tests/optional. +// +// Make sure to run a localnet with the program deploy to run this example. +pub fn optional + Clone>( + client: &Client, + pid: Pubkey, +) -> Result<()> { + // Program client. + let program = client.program(pid)?; + + // `Initialize` parameters. + let data_account_keypair = Keypair::new(); + + let data_account_key = data_account_keypair.pubkey(); + + let data_pda_seeds = &[DataPda::PREFIX.as_ref(), data_account_key.as_ref()]; + let data_pda_key = Pubkey::find_program_address(data_pda_seeds, &pid).0; + let required_keypair = Keypair::new(); + let value: u64 = 10; + + // Build and send a transaction. + + program + .request() + .instruction(system_instruction::create_account( + &program.payer(), + &required_keypair.pubkey(), + program + .rpc() + .get_minimum_balance_for_rent_exemption(DataAccount::LEN)?, + DataAccount::LEN as u64, + &program.id(), + )) + .signer(&data_account_keypair) + .signer(&required_keypair) + .accounts(OptionalInitialize { + payer: Some(program.payer()), + required: required_keypair.pubkey(), + system_program: Some(system_program::id()), + optional_account: Some(data_account_keypair.pubkey()), + optional_pda: None, + }) + .args(optional_instruction::Initialize { value, key: pid }) + .send() + .unwrap(); + + // Assert the transaction worked. + let required: DataAccount = program.account(required_keypair.pubkey())?; + assert_eq!(required.data, 0); + + let optional_pda = program.account::(data_pda_key); + assert!(optional_pda.is_err()); + + let optional_account: DataAccount = program.account(data_account_keypair.pubkey())?; + assert_eq!(optional_account.data, value * 2); + + println!("Optional success!"); + + Ok(()) +} diff --git a/client/example/src/main.rs b/client/example/src/main.rs index 770a9a894f..f13e76c7d1 100644 --- a/client/example/src/main.rs +++ b/client/example/src/main.rs @@ -1,33 +1,12 @@ -use anchor_client::solana_sdk::commitment_config::CommitmentConfig; use anchor_client::solana_sdk::pubkey::Pubkey; -use anchor_client::solana_sdk::signature::read_keypair_file; -use anchor_client::solana_sdk::signature::{Keypair, Signer}; -use anchor_client::solana_sdk::system_instruction; -use anchor_client::{Client, Cluster, EventContext}; use anyhow::Result; -use solana_sdk::system_program; -// The `accounts` and `instructions` modules are generated by the framework. -use basic_2::accounts as basic_2_accounts; -use basic_2::instruction as basic_2_instruction; -use basic_2::Counter; -use events::instruction as events_instruction; -use events::MyEvent; -use optional::accounts::Initialize as OptionalInitialize; -use optional::instruction as optional_instruction; -// The `accounts` and `instructions` modules are generated by the framework. -use basic_4::accounts as basic_4_accounts; -use basic_4::instruction as basic_4_instruction; -use basic_4::Counter as CounterAccount; use clap::Parser; -// The `accounts` and `instructions` modules are generated by the framework. -use composite::accounts::{Bar, CompositeUpdate, Foo, Initialize}; -use composite::instruction as composite_instruction; -use composite::{DummyA, DummyB}; -use optional::account::{DataAccount, DataPda}; -use std::ops::Deref; -use std::rc::Rc; -use std::sync::Arc; -use std::time::Duration; + +#[cfg(not(feature = "async"))] +mod blocking; + +#[cfg(feature = "async")] +mod nonblocking; #[derive(Parser, Debug)] pub struct Opts { @@ -45,296 +24,15 @@ pub struct Opts { multithreaded: bool, } -type TestFn = &'static (dyn Fn(&Client, Pubkey) -> Result<()> + Send + Sync); - // This example assumes a local validator is running with the programs // deployed at the addresses given by the CLI args. +#[cfg(not(feature = "async"))] fn main() -> Result<()> { - let opts = Opts::parse(); - - // Wallet and cluster params. - let payer = read_keypair_file(&*shellexpand::tilde("~/.config/solana/id.json")) - .expect("Example requires a keypair file"); - let url = Cluster::Custom( - "http://localhost:8899".to_string(), - "ws://127.0.0.1:8900".to_string(), - ); - - if !opts.multithreaded { - // Client. - let payer = Rc::new(payer); - let client = - Client::new_with_options(url.clone(), payer.clone(), CommitmentConfig::processed()); - - // Run tests on single thread with a single client using an Rc - println!("\nStarting single thread test..."); - composite(&client, opts.composite_pid)?; - basic_2(&client, opts.basic_2_pid)?; - basic_4(&client, opts.basic_4_pid)?; - - // Can also use references, since they deref to a signer - let payer: &Keypair = &payer; - let client = Client::new_with_options(url, payer, CommitmentConfig::processed()); - events(&client, opts.events_pid)?; - optional(&client, opts.optional_pid)?; - } else { - // Client. - let payer = Arc::new(payer); - let client = Client::new_with_options(url, payer, CommitmentConfig::processed()); - let client = Arc::new(client); - - // Run tests multithreaded while sharing a client - println!("\nStarting multithread test..."); - let client = Arc::new(client); - let tests: Vec<(TestFn>, Pubkey)> = vec![ - (&composite, opts.composite_pid), - (&basic_2, opts.basic_2_pid), - (&basic_4, opts.basic_4_pid), - (&events, opts.events_pid), - (&optional, opts.optional_pid), - ]; - let mut handles = vec![]; - for (test, arg) in tests { - let local_client = Arc::clone(&client); - handles.push(std::thread::spawn(move || test(&local_client, arg))); - } - for handle in handles { - assert!(handle.join().unwrap().is_ok()); - } - } - - // Success. - Ok(()) -} - -// Runs a client for examples/tutorial/composite. -// -// Make sure to run a localnet with the program deploy to run this example. -fn composite + Clone>( - client: &Client, - pid: Pubkey, -) -> Result<()> { - // Program client. - let program = client.program(pid); - - // `Initialize` parameters. - let dummy_a = Keypair::new(); - let dummy_b = Keypair::new(); - - // Build and send a transaction. - program - .request() - .instruction(system_instruction::create_account( - &program.payer(), - &dummy_a.pubkey(), - program.rpc().get_minimum_balance_for_rent_exemption(500)?, - 500, - &program.id(), - )) - .instruction(system_instruction::create_account( - &program.payer(), - &dummy_b.pubkey(), - program.rpc().get_minimum_balance_for_rent_exemption(500)?, - 500, - &program.id(), - )) - .signer(&dummy_a) - .signer(&dummy_b) - .accounts(Initialize { - dummy_a: dummy_a.pubkey(), - dummy_b: dummy_b.pubkey(), - }) - .args(composite_instruction::Initialize) - .send()?; - - // Assert the transaction worked. - let dummy_a_account: DummyA = program.account(dummy_a.pubkey())?; - let dummy_b_account: DummyB = program.account(dummy_b.pubkey())?; - assert_eq!(dummy_a_account.data, 0); - assert_eq!(dummy_b_account.data, 0); - - // Build and send another transaction, using composite account parameters. - program - .request() - .accounts(CompositeUpdate { - foo: Foo { - dummy_a: dummy_a.pubkey(), - }, - bar: Bar { - dummy_b: dummy_b.pubkey(), - }, - }) - .args(composite_instruction::CompositeUpdate { - dummy_a: 1234, - dummy_b: 4321, - }) - .send()?; - - // Assert the transaction worked. - let dummy_a_account: DummyA = program.account(dummy_a.pubkey())?; - let dummy_b_account: DummyB = program.account(dummy_b.pubkey())?; - assert_eq!(dummy_a_account.data, 1234); - assert_eq!(dummy_b_account.data, 4321); - - println!("Composite success!"); - - Ok(()) -} - -// Runs a client for examples/tutorial/basic-2. -// -// Make sure to run a localnet with the program deploy to run this example. -fn basic_2 + Clone>(client: &Client, pid: Pubkey) -> Result<()> { - let program = client.program(pid); - - // `Create` parameters. - let counter = Keypair::new(); - let authority = program.payer(); - - // Build and send a transaction. - program - .request() - .signer(&counter) - .accounts(basic_2_accounts::Create { - counter: counter.pubkey(), - user: authority, - system_program: system_program::ID, - }) - .args(basic_2_instruction::Create { authority }) - .send()?; - - let counter_account: Counter = program.account(counter.pubkey())?; - - assert_eq!(counter_account.authority, authority); - assert_eq!(counter_account.count, 0); - - println!("Basic 2 success!"); - - Ok(()) + blocking::main() } -fn events + Clone>(client: &Client, pid: Pubkey) -> Result<()> { - let program = client.program(pid); - - let (sender, receiver) = std::sync::mpsc::channel(); - let handle = program.on(move |_ctx: &EventContext, event: MyEvent| { - sender.send(event).unwrap(); - })?; - - std::thread::sleep(Duration::from_millis(1000)); - - program - .request() - .args(events_instruction::Initialize {}) - .send()?; - - let event = receiver.recv().unwrap(); - assert_eq!(event.data, 5); - assert_eq!(event.label, "hello".to_string()); - - // TODO: remove once https://github.com/solana-labs/solana/issues/16102 - // is addressed. Until then, drop the subscription handle in another - // thread so that we deadlock in the other thread as to not block - // this thread. - std::thread::spawn(move || { - drop(handle); - }); - - println!("Events success!"); - - Ok(()) -} - -pub fn basic_4 + Clone>( - client: &Client, - pid: Pubkey, -) -> Result<()> { - let program = client.program(pid); - let authority = program.payer(); - let (counter, _) = Pubkey::find_program_address(&[b"counter"], &pid); - - program - .request() - .accounts(basic_4_accounts::Initialize { - counter, - authority, - system_program: system_program::ID, - }) - .args(basic_4_instruction::Initialize {}) - .send()?; - let counter_account: CounterAccount = program.account(counter)?; - assert_eq!(counter_account.authority, authority); - assert_eq!(counter_account.count, 0); - - program - .request() - .accounts(basic_4_accounts::Increment { counter, authority }) - .args(basic_4_instruction::Increment {}) - .send()?; - - let counter_account: CounterAccount = program.account(counter)?; - assert_eq!(counter_account.authority, authority); - assert_eq!(counter_account.count, 1); - - println!("Basic 4 success!"); - - Ok(()) -} - -// Runs a client for tests/optional. -// -// Make sure to run a localnet with the program deploy to run this example. -fn optional + Clone>(client: &Client, pid: Pubkey) -> Result<()> { - // Program client. - let program = client.program(pid); - - // `Initialize` parameters. - let data_account_keypair = Keypair::new(); - - let data_account_key = data_account_keypair.pubkey(); - - let data_pda_seeds = &[DataPda::PREFIX.as_ref(), data_account_key.as_ref()]; - let data_pda_key = Pubkey::find_program_address(data_pda_seeds, &pid).0; - let required_keypair = Keypair::new(); - let value: u64 = 10; - - // Build and send a transaction. - - program - .request() - .instruction(system_instruction::create_account( - &program.payer(), - &required_keypair.pubkey(), - program - .rpc() - .get_minimum_balance_for_rent_exemption(DataAccount::LEN)?, - DataAccount::LEN as u64, - &program.id(), - )) - .signer(&data_account_keypair) - .signer(&required_keypair) - .accounts(OptionalInitialize { - payer: Some(program.payer()), - required: required_keypair.pubkey(), - system_program: Some(system_program::id()), - optional_account: Some(data_account_keypair.pubkey()), - optional_pda: None, - }) - .args(optional_instruction::Initialize { value, key: pid }) - .send() - .unwrap(); - - // Assert the transaction worked. - let required: DataAccount = program.account(required_keypair.pubkey())?; - assert_eq!(required.data, 0); - - let optional_pda = program.account::(data_pda_key); - assert!(optional_pda.is_err()); - - let optional_account: DataAccount = program.account(data_account_keypair.pubkey())?; - assert_eq!(optional_account.data, value * 2); - - println!("Optional success!"); - - Ok(()) +#[cfg(feature = "async")] +#[tokio::main] +async fn main() -> Result<()> { + nonblocking::main().await } diff --git a/client/example/src/nonblocking.rs b/client/example/src/nonblocking.rs new file mode 100644 index 0000000000..eeee5d4f18 --- /dev/null +++ b/client/example/src/nonblocking.rs @@ -0,0 +1,306 @@ +use anchor_client::solana_sdk::pubkey::Pubkey; +use anchor_client::solana_sdk::signature::{Keypair, Signer}; +use anchor_client::solana_sdk::system_instruction; +use anchor_client::{Client, Cluster}; +use anyhow::Result; +use clap::Parser; +use solana_sdk::commitment_config::CommitmentConfig; +use solana_sdk::signature::read_keypair_file; +use solana_sdk::system_program; +// The `accounts` and `instructions` modules are generated by the framework. +use basic_2::accounts as basic_2_accounts; +use basic_2::instruction as basic_2_instruction; +use basic_2::Counter; +use events::instruction as events_instruction; +use events::MyEvent; +use optional::accounts::Initialize as OptionalInitialize; +use optional::instruction as optional_instruction; +// The `accounts` and `instructions` modules are generated by the framework. +use basic_4::accounts as basic_4_accounts; +use basic_4::instruction as basic_4_instruction; +use basic_4::Counter as CounterAccount; +// The `accounts` and `instructions` modules are generated by the framework. +use crate::Opts; +use composite::accounts::{Bar, CompositeUpdate, Foo, Initialize}; +use composite::instruction as composite_instruction; +use composite::{DummyA, DummyB}; +use optional::account::{DataAccount, DataPda}; +use std::ops::Deref; +use std::rc::Rc; +use std::time::Duration; +use tokio::sync::mpsc; +use tokio::time::sleep; + +pub async fn main() -> Result<()> { + let opts = Opts::parse(); + + // Wallet and cluster params. + let payer = read_keypair_file(&*shellexpand::tilde("~/.config/solana/id.json")) + .expect("Example requires a keypair file"); + let url = Cluster::Custom( + "http://localhost:8899".to_string(), + "ws://127.0.0.1:8900".to_string(), + ); + + // Client. + let payer = Rc::new(payer); + let client = + Client::new_with_options(url.clone(), payer.clone(), CommitmentConfig::processed()); + + println!("\nStarting async test..."); + composite(&client, opts.composite_pid).await?; + basic_2(&client, opts.basic_2_pid).await?; + basic_4(&client, opts.basic_4_pid).await?; + + // Can also use references, since they deref to a signer + let payer: &Keypair = &payer; + let client = Client::new_with_options(url, payer, CommitmentConfig::processed()); + events(&client, opts.events_pid).await?; + optional(&client, opts.optional_pid).await?; + // Success. + Ok(()) +} + +pub async fn composite + Clone>( + client: &Client, + pid: Pubkey, +) -> Result<()> { + // Program client. + let program = client.program(pid)?; + + // `Initialize` parameters. + let dummy_a = Keypair::new(); + let dummy_b = Keypair::new(); + + // Build and send a transaction. + program + .request() + .instruction(system_instruction::create_account( + &program.payer(), + &dummy_a.pubkey(), + program + .async_rpc() + .get_minimum_balance_for_rent_exemption(500) + .await?, + 500, + &program.id(), + )) + .instruction(system_instruction::create_account( + &program.payer(), + &dummy_b.pubkey(), + program + .async_rpc() + .get_minimum_balance_for_rent_exemption(500) + .await?, + 500, + &program.id(), + )) + .signer(&dummy_a) + .signer(&dummy_b) + .accounts(Initialize { + dummy_a: dummy_a.pubkey(), + dummy_b: dummy_b.pubkey(), + }) + .args(composite_instruction::Initialize) + .send() + .await?; + + // Assert the transaction worked. + let dummy_a_account: DummyA = program.account(dummy_a.pubkey()).await?; + let dummy_b_account: DummyB = program.account(dummy_b.pubkey()).await?; + assert_eq!(dummy_a_account.data, 0); + assert_eq!(dummy_b_account.data, 0); + + // Build and send another transaction, using composite account parameters. + program + .request() + .accounts(CompositeUpdate { + foo: Foo { + dummy_a: dummy_a.pubkey(), + }, + bar: Bar { + dummy_b: dummy_b.pubkey(), + }, + }) + .args(composite_instruction::CompositeUpdate { + dummy_a: 1234, + dummy_b: 4321, + }) + .send() + .await?; + + // Assert the transaction worked. + let dummy_a_account: DummyA = program.account(dummy_a.pubkey()).await?; + let dummy_b_account: DummyB = program.account(dummy_b.pubkey()).await?; + assert_eq!(dummy_a_account.data, 1234); + assert_eq!(dummy_b_account.data, 4321); + + println!("Composite success!"); + + Ok(()) +} + +pub async fn basic_2 + Clone>( + client: &Client, + pid: Pubkey, +) -> Result<()> { + let program = client.program(pid)?; + + // `Create` parameters. + let counter = Keypair::new(); + let authority = program.payer(); + + // Build and send a transaction. + program + .request() + .signer(&counter) + .accounts(basic_2_accounts::Create { + counter: counter.pubkey(), + user: authority, + system_program: system_program::ID, + }) + .args(basic_2_instruction::Create { authority }) + .send() + .await?; + + let counter_account: Counter = program.account(counter.pubkey()).await?; + + assert_eq!(counter_account.authority, authority); + assert_eq!(counter_account.count, 0); + + println!("Basic 2 success!"); + + Ok(()) +} + +pub async fn events + Clone>( + client: &Client, + pid: Pubkey, +) -> Result<()> { + let program = client.program(pid)?; + + let (sender, mut receiver) = mpsc::unbounded_channel(); + let event_unsubscriber = program + .on(move |_, event: MyEvent| { + if sender.send(event).is_err() { + println!("Error while transferring the event.") + } + }) + .await?; + + sleep(Duration::from_millis(1000)).await; + + program + .request() + .args(events_instruction::Initialize {}) + .send() + .await?; + + let event = receiver.recv().await.unwrap(); + assert_eq!(event.data, 5); + assert_eq!(event.label, "hello".to_string()); + + event_unsubscriber.unsubscribe().await; + + println!("Events success!"); + + Ok(()) +} + +pub async fn basic_4 + Clone>( + client: &Client, + pid: Pubkey, +) -> Result<()> { + let program = client.program(pid)?; + let authority = program.payer(); + let (counter, _) = Pubkey::find_program_address(&[b"counter"], &pid); + + program + .request() + .accounts(basic_4_accounts::Initialize { + counter, + authority, + system_program: system_program::ID, + }) + .args(basic_4_instruction::Initialize {}) + .send() + .await?; + let counter_account: CounterAccount = program.account(counter).await?; + assert_eq!(counter_account.authority, authority); + assert_eq!(counter_account.count, 0); + + program + .request() + .accounts(basic_4_accounts::Increment { counter, authority }) + .args(basic_4_instruction::Increment {}) + .send() + .await?; + + let counter_account: CounterAccount = program.account(counter).await?; + assert_eq!(counter_account.authority, authority); + assert_eq!(counter_account.count, 1); + + println!("Basic 4 success!"); + + Ok(()) +} + +pub async fn optional + Clone>( + client: &Client, + pid: Pubkey, +) -> Result<()> { + // Program client. + let program = client.program(pid)?; + + // `Initialize` parameters. + let data_account_keypair = Keypair::new(); + + let data_account_key = data_account_keypair.pubkey(); + + let data_pda_seeds = &[DataPda::PREFIX.as_ref(), data_account_key.as_ref()]; + let data_pda_key = Pubkey::find_program_address(data_pda_seeds, &pid).0; + let required_keypair = Keypair::new(); + let value: u64 = 10; + + // Build and send a transaction. + + program + .request() + .instruction(system_instruction::create_account( + &program.payer(), + &required_keypair.pubkey(), + program + .async_rpc() + .get_minimum_balance_for_rent_exemption(DataAccount::LEN) + .await?, + DataAccount::LEN as u64, + &program.id(), + )) + .signer(&data_account_keypair) + .signer(&required_keypair) + .accounts(OptionalInitialize { + payer: Some(program.payer()), + required: required_keypair.pubkey(), + system_program: Some(system_program::id()), + optional_account: Some(data_account_keypair.pubkey()), + optional_pda: None, + }) + .args(optional_instruction::Initialize { value, key: pid }) + .send() + .await + .unwrap(); + + // Assert the transaction worked. + let required: DataAccount = program.account(required_keypair.pubkey()).await?; + assert_eq!(required.data, 0); + + let optional_pda = program.account::(data_pda_key).await; + assert!(optional_pda.is_err()); + + let optional_account: DataAccount = program.account(data_account_keypair.pubkey()).await?; + assert_eq!(optional_account.data, value * 2); + + println!("Optional success!"); + + Ok(()) +} diff --git a/client/src/blocking.rs b/client/src/blocking.rs new file mode 100644 index 0000000000..492729d630 --- /dev/null +++ b/client/src/blocking.rs @@ -0,0 +1,109 @@ +use crate::{ + ClientError, Config, EventContext, EventUnsubscriber, Program, ProgramAccountsIterator, + RequestBuilder, +}; +use anchor_lang::{prelude::Pubkey, AccountDeserialize, Discriminator}; +use solana_client::{rpc_config::RpcSendTransactionConfig, rpc_filter::RpcFilterType}; +use solana_sdk::{ + commitment_config::CommitmentConfig, signature::Signature, signer::Signer, + transaction::Transaction, +}; +use std::{marker::PhantomData, ops::Deref, sync::Arc}; +use tokio::{ + runtime::{Builder, Handle}, + sync::RwLock, +}; + +impl<'a> EventUnsubscriber<'a> { + /// Unsubscribe gracefully. + pub fn unsubscribe(self) { + self.runtime_handle.block_on(self.unsubscribe_internal()) + } +} + +impl + Clone> Program { + pub fn new(program_id: Pubkey, cfg: Config) -> Result { + let rt: tokio::runtime::Runtime = Builder::new_multi_thread().enable_all().build()?; + + Ok(Self { + program_id, + cfg, + sub_client: Arc::new(RwLock::new(None)), + rt, + }) + } + + /// Returns the account at the given address. + pub fn account(&self, address: Pubkey) -> Result { + self.rt.block_on(self.account_internal(address)) + } + + /// Returns all program accounts of the given type matching the given filters + pub fn accounts( + &self, + filters: Vec, + ) -> Result, ClientError> { + self.accounts_lazy(filters)?.collect() + } + + /// Returns all program accounts of the given type matching the given filters as an iterator + /// Deserialization is executed lazily + pub fn accounts_lazy( + &self, + filters: Vec, + ) -> Result, ClientError> { + self.rt.block_on(self.accounts_lazy_internal(filters)) + } + + pub fn on( + &self, + f: impl Fn(&EventContext, T) + Send + 'static, + ) -> Result { + let (handle, rx) = self.rt.block_on(self.on_internal(f))?; + + Ok(EventUnsubscriber { + handle, + rx, + runtime_handle: self.rt.handle(), + _lifetime_marker: PhantomData, + }) + } +} + +impl<'a, C: Deref + Clone> RequestBuilder<'a, C> { + pub fn from( + program_id: Pubkey, + cluster: &str, + payer: C, + options: Option, + handle: &'a Handle, + ) -> Self { + Self { + program_id, + payer, + cluster: cluster.to_string(), + accounts: Vec::new(), + options: options.unwrap_or_default(), + instructions: Vec::new(), + instruction_data: None, + signers: Vec::new(), + handle, + } + } + + pub fn signed_transaction(&self) -> Result { + self.handle.block_on(self.signed_transaction_internal()) + } + + pub fn send(&self) -> Result { + self.handle.block_on(self.send_internal()) + } + + pub fn send_with_spinner_and_config( + &self, + config: RpcSendTransactionConfig, + ) -> Result { + self.handle + .block_on(self.send_with_spinner_and_config_internal(config)) + } +} diff --git a/client/src/lib.rs b/client/src/lib.rs index 477914a6a1..c25624a11c 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -6,27 +6,42 @@ use anchor_lang::solana_program::instruction::{AccountMeta, Instruction}; use anchor_lang::solana_program::program_error::ProgramError; use anchor_lang::solana_program::pubkey::Pubkey; use anchor_lang::{AccountDeserialize, Discriminator, InstructionData, ToAccountMetas}; +use futures::{Future, StreamExt}; use regex::Regex; use solana_account_decoder::UiAccountEncoding; -use solana_client::client_error::ClientError as SolanaClientError; -use solana_client::nonblocking::rpc_client::RpcClient as AsyncRpcClient; -use solana_client::pubsub_client::{PubsubClient, PubsubClientError, PubsubClientSubscription}; -use solana_client::rpc_client::RpcClient; use solana_client::rpc_config::{ RpcAccountInfoConfig, RpcProgramAccountsConfig, RpcSendTransactionConfig, RpcTransactionLogsConfig, RpcTransactionLogsFilter, }; use solana_client::rpc_filter::{Memcmp, RpcFilterType}; -use solana_client::rpc_response::{Response as RpcResponse, RpcLogsResponse}; +use solana_client::{ + client_error::ClientError as SolanaClientError, + nonblocking::{ + pubsub_client::{PubsubClient, PubsubClientError}, + rpc_client::RpcClient as AsyncRpcClient, + }, + rpc_client::RpcClient, + rpc_response::{Response as RpcResponse, RpcLogsResponse}, +}; use solana_sdk::account::Account; use solana_sdk::commitment_config::CommitmentConfig; use solana_sdk::signature::{Signature, Signer}; use solana_sdk::transaction::Transaction; -use std::convert::Into; use std::iter::Map; +use std::marker::PhantomData; use std::ops::Deref; +use std::pin::Pin; +use std::sync::Arc; use std::vec::IntoIter; use thiserror::Error; +use tokio::{ + runtime::Handle, + sync::{ + mpsc::{unbounded_channel, UnboundedReceiver}, + RwLock, + }, + task::JoinHandle, +}; pub use anchor_lang; pub use cluster::Cluster; @@ -35,12 +50,15 @@ pub use solana_sdk; mod cluster; +#[cfg(not(feature = "async"))] +mod blocking; +#[cfg(feature = "async")] +mod nonblocking; + const PROGRAM_LOG: &str = "Program log: "; const PROGRAM_DATA: &str = "Program data: "; -/// EventHandle unsubscribes from a program event stream on drop. -pub type EventHandle = PubsubClientSubscription>; - +type UnsubscribeFn = Box Pin + Send>> + Send>; /// Client defines the base configuration for building RPC clients to /// communicate with Anchor programs running on a Solana cluster. It's /// primary use is to build a `Program` client via the `program` method. @@ -69,31 +87,50 @@ impl> Client { } } - pub fn program(&self, program_id: Pubkey) -> Program { - Program { - program_id, - cfg: Config { - cluster: self.cfg.cluster.clone(), - options: self.cfg.options, - payer: self.cfg.payer.clone(), - }, - } + pub fn program(&self, program_id: Pubkey) -> Result, ClientError> { + let cfg = Config { + cluster: self.cfg.cluster.clone(), + options: self.cfg.options, + payer: self.cfg.payer.clone(), + }; + + Program::new(program_id, cfg) } } // Internal configuration for a client. #[derive(Debug)] -struct Config { +pub struct Config { cluster: Cluster, payer: C, options: Option, } +pub struct EventUnsubscriber<'a> { + handle: JoinHandle>, + rx: UnboundedReceiver, + #[cfg(not(feature = "async"))] + runtime_handle: &'a Handle, + _lifetime_marker: PhantomData<&'a Handle>, +} + +impl<'a> EventUnsubscriber<'a> { + async fn unsubscribe_internal(mut self) { + if let Some(unsubscribe) = self.rx.recv().await { + unsubscribe().await; + } + + let _ = self.handle.await; + } +} + /// Program is the primary client handle to be used to build and send requests. -#[derive(Debug)] pub struct Program { program_id: Pubkey, cfg: Config, + sub_client: Arc>>, + #[cfg(not(feature = "async"))] + rt: tokio::runtime::Runtime, } impl + Clone> Program { @@ -108,34 +145,47 @@ impl + Clone> Program { self.cfg.cluster.url(), self.cfg.payer.clone(), self.cfg.options, + #[cfg(not(feature = "async"))] + self.rt.handle(), + ) + } + + pub fn id(&self) -> Pubkey { + self.program_id + } + + pub fn rpc(&self) -> RpcClient { + RpcClient::new_with_commitment( + self.cfg.cluster.url().to_string(), + self.cfg.options.unwrap_or_default(), ) } - /// Returns the account at the given address. - pub fn account(&self, address: Pubkey) -> Result { - let rpc_client = RpcClient::new_with_commitment( + pub fn async_rpc(&self) -> AsyncRpcClient { + AsyncRpcClient::new_with_commitment( + self.cfg.cluster.url().to_string(), + self.cfg.options.unwrap_or_default(), + ) + } + + async fn account_internal( + &self, + address: Pubkey, + ) -> Result { + let rpc_client = AsyncRpcClient::new_with_commitment( self.cfg.cluster.url().to_string(), self.cfg.options.unwrap_or_default(), ); let account = rpc_client - .get_account_with_commitment(&address, CommitmentConfig::processed())? + .get_account_with_commitment(&address, CommitmentConfig::processed()) + .await? .value .ok_or(ClientError::AccountNotFound)?; let mut data: &[u8] = &account.data; T::try_deserialize(&mut data).map_err(Into::into) } - /// Returns all program accounts of the given type matching the given filters - pub fn accounts( - &self, - filters: Vec, - ) -> Result, ClientError> { - self.accounts_lazy(filters)?.collect() - } - - /// Returns all program accounts of the given type matching the given filters as an iterator - /// Deserialization is executed lazily - pub fn accounts_lazy( + async fn accounts_lazy_internal( &self, filters: Vec, ) -> Result, ClientError> { @@ -151,8 +201,9 @@ impl + Clone> Program { }; Ok(ProgramAccountsIterator { inner: self - .rpc() - .get_program_accounts_with_config(&self.id(), config)? + .async_rpc() + .get_program_accounts_with_config(&self.id(), config) + .await? .into_iter() .map(|(key, account)| { Ok((key, T::try_deserialize(&mut (&account.data as &[u8]))?)) @@ -160,86 +211,64 @@ impl + Clone> Program { }) } - pub fn rpc(&self) -> RpcClient { - RpcClient::new_with_commitment( - self.cfg.cluster.url().to_string(), - self.cfg.options.unwrap_or_default(), - ) - } + async fn init_sub_client_if_needed(&self) -> Result<(), ClientError> { + let lock = &self.sub_client; + let mut client = lock.write().await; - pub fn async_rpc(&self) -> AsyncRpcClient { - AsyncRpcClient::new_with_commitment( - self.cfg.cluster.url().to_string(), - self.cfg.options.unwrap_or_default(), - ) - } + if client.is_none() { + let sub_client = PubsubClient::new(self.cfg.cluster.ws_url()).await?; + *client = Some(sub_client); + } - pub fn id(&self) -> Pubkey { - self.program_id + Ok(()) } - pub fn on( + async fn on_internal( &self, f: impl Fn(&EventContext, T) + Send + 'static, - ) -> Result { - let addresses = vec![self.program_id.to_string()]; - let filter = RpcTransactionLogsFilter::Mentions(addresses); - let ws_url = self.cfg.cluster.ws_url().to_string(); - let cfg = RpcTransactionLogsConfig { + ) -> Result< + ( + JoinHandle>, + UnboundedReceiver, + ), + ClientError, + > { + self.init_sub_client_if_needed().await?; + let (tx, rx) = unbounded_channel::<_>(); + let config = RpcTransactionLogsConfig { commitment: self.cfg.options, }; - let self_program_str = self.program_id.to_string(); - let (client, receiver) = PubsubClient::logs_subscribe(&ws_url, filter, cfg)?; - std::thread::spawn(move || { - loop { - match receiver.recv() { - Ok(logs) => { - let ctx = EventContext { - signature: logs.value.signature.parse().unwrap(), - slot: logs.context.slot, - }; - let mut logs = &logs.value.logs[..]; - if !logs.is_empty() { - if let Ok(mut execution) = Execution::new(&mut logs) { - for l in logs { - // Parse the log. - let (event, new_program, did_pop) = { - if self_program_str == execution.program() { - handle_program_log(&self_program_str, l).unwrap_or_else( - |e| { - println!("Unable to parse log: {e}"); - std::process::exit(1); - }, - ) - } else { - let (program, did_pop) = - handle_system_log(&self_program_str, l); - (None, program, did_pop) - } - }; - // Emit the event. - if let Some(e) = event { - f(&ctx, e); - } - // Switch program context on CPI. - if let Some(new_program) = new_program { - execution.push(new_program); - } - // Program returned. - if did_pop { - execution.pop(); - } - } - } - } - } - Err(_err) => { - return; + let program_id_str = self.program_id.to_string(); + let filter = RpcTransactionLogsFilter::Mentions(vec![program_id_str.clone()]); + + let lock = Arc::clone(&self.sub_client); + + let handle = tokio::spawn(async move { + if let Some(ref client) = *lock.read().await { + let (mut notifications, unsubscribe) = + client.logs_subscribe(filter, config).await?; + + tx.send(unsubscribe).map_err(|e| { + ClientError::SolanaClientPubsubError(PubsubClientError::UnexpectedMessageError( + e.to_string(), + )) + })?; + + while let Some(logs) = notifications.next().await { + let ctx = EventContext { + signature: logs.value.signature.parse().unwrap(), + slot: logs.context.slot, + }; + let events = parse_logs_response(logs, &program_id_str); + for e in events { + f(&ctx, e); } } } + Ok::<(), ClientError>(()) }); - Ok(client) + + Ok((handle, rx)) } } @@ -373,6 +402,8 @@ pub enum ClientError { SolanaClientPubsubError(#[from] PubsubClientError), #[error("Unable to parse log: {0}")] LogParseError(String), + #[error(transparent)] + IOError(#[from] std::io::Error), } /// `RequestBuilder` provides a builder interface to create and send @@ -387,27 +418,11 @@ pub struct RequestBuilder<'a, C> { // Serialized instruction data for the target RPC. instruction_data: Option>, signers: Vec<&'a dyn Signer>, + #[cfg(not(feature = "async"))] + handle: &'a Handle, } impl<'a, C: Deref + Clone> RequestBuilder<'a, C> { - pub fn from( - program_id: Pubkey, - cluster: &str, - payer: C, - options: Option, - ) -> Self { - Self { - program_id, - payer, - cluster: cluster.to_string(), - accounts: Vec::new(), - options: options.unwrap_or_default(), - instructions: Vec::new(), - instruction_data: None, - signers: Vec::new(), - } - } - #[must_use] pub fn payer(mut self, payer: C) -> Self { self.payer = payer; @@ -488,36 +503,39 @@ impl<'a, C: Deref + Clone> RequestBuilder<'a, C> { Ok(tx) } - pub fn signed_transaction(&self) -> Result { - let latest_hash = - RpcClient::new_with_commitment(&self.cluster, self.options).get_latest_blockhash()?; - let tx = self.signed_transaction_with_blockhash(latest_hash)?; - - Ok(tx) - } - pub fn transaction(&self) -> Result { let instructions = &self.instructions; let tx = Transaction::new_with_payer(instructions, Some(&self.payer.pubkey())); Ok(tx) } - pub fn send(self) -> Result { - let rpc_client = RpcClient::new_with_commitment(&self.cluster, self.options); - let latest_hash = rpc_client.get_latest_blockhash()?; + async fn signed_transaction_internal(&self) -> Result { + let latest_hash = + AsyncRpcClient::new_with_commitment(self.cluster.to_owned(), self.options) + .get_latest_blockhash() + .await?; + let tx = self.signed_transaction_with_blockhash(latest_hash)?; + + Ok(tx) + } + + async fn send_internal(&self) -> Result { + let rpc_client = AsyncRpcClient::new_with_commitment(self.cluster.to_owned(), self.options); + let latest_hash = rpc_client.get_latest_blockhash().await?; let tx = self.signed_transaction_with_blockhash(latest_hash)?; rpc_client .send_and_confirm_transaction(&tx) + .await .map_err(Into::into) } - pub fn send_with_spinner_and_config( - self, + async fn send_with_spinner_and_config_internal( + &self, config: RpcSendTransactionConfig, ) -> Result { - let rpc_client = RpcClient::new_with_commitment(&self.cluster, self.options); - let latest_hash = rpc_client.get_latest_blockhash()?; + let rpc_client = AsyncRpcClient::new_with_commitment(self.cluster.to_owned(), self.options); + let latest_hash = rpc_client.get_latest_blockhash().await?; let tx = self.signed_transaction_with_blockhash(latest_hash)?; rpc_client @@ -526,10 +544,50 @@ impl<'a, C: Deref + Clone> RequestBuilder<'a, C> { rpc_client.commitment(), config, ) + .await .map_err(Into::into) } } +fn parse_logs_response( + logs: RpcResponse, + program_id_str: &str, +) -> Vec { + let mut logs = &logs.value.logs[..]; + let mut events: Vec = Vec::new(); + if !logs.is_empty() { + if let Ok(mut execution) = Execution::new(&mut logs) { + for l in logs { + // Parse the log. + let (event, new_program, did_pop) = { + if program_id_str == execution.program() { + handle_program_log(program_id_str, l).unwrap_or_else(|e| { + println!("Unable to parse log: {e}"); + std::process::exit(1); + }) + } else { + let (program, did_pop) = handle_system_log(program_id_str, l); + (None, program, did_pop) + } + }; + // Emit the event. + if let Some(e) = event { + events.push(e); + } + // Switch program context on CPI. + if let Some(new_program) = new_program { + execution.push(new_program); + } + // Program returned. + if did_pop { + execution.pop(); + } + } + } + } + events +} + #[cfg(test)] mod tests { use super::*; diff --git a/client/src/nonblocking.rs b/client/src/nonblocking.rs new file mode 100644 index 0000000000..93f06c114b --- /dev/null +++ b/client/src/nonblocking.rs @@ -0,0 +1,102 @@ +use crate::{ + ClientError, Config, EventContext, EventUnsubscriber, Program, ProgramAccountsIterator, + RequestBuilder, +}; +use anchor_lang::{prelude::Pubkey, AccountDeserialize, Discriminator}; +use solana_client::{rpc_config::RpcSendTransactionConfig, rpc_filter::RpcFilterType}; +use solana_sdk::{ + commitment_config::CommitmentConfig, signature::Signature, signer::Signer, + transaction::Transaction, +}; +use std::{marker::PhantomData, ops::Deref, sync::Arc}; +use tokio::sync::RwLock; + +impl<'a> EventUnsubscriber<'a> { + /// Unsubscribe gracefully. + pub async fn unsubscribe(self) { + self.unsubscribe_internal().await + } +} + +impl + Clone> Program { + pub fn new(program_id: Pubkey, cfg: Config) -> Result { + Ok(Self { + program_id, + cfg, + sub_client: Arc::new(RwLock::new(None)), + }) + } + + /// Returns the account at the given address. + pub async fn account(&self, address: Pubkey) -> Result { + self.account_internal(address).await + } + + /// Returns all program accounts of the given type matching the given filters + pub async fn accounts( + &self, + filters: Vec, + ) -> Result, ClientError> { + self.accounts_lazy(filters).await?.collect() + } + + /// Returns all program accounts of the given type matching the given filters as an iterator + /// Deserialization is executed lazily + pub async fn accounts_lazy( + &self, + filters: Vec, + ) -> Result, ClientError> { + self.accounts_lazy_internal(filters).await + } + + /// Subscribe to program logs. + /// + /// Returns an [`EventUnsubscriber`] to unsubscribe and close connection gracefully. + pub async fn on( + &self, + f: impl Fn(&EventContext, T) + Send + 'static, + ) -> Result { + let (handle, rx) = self.on_internal(f).await?; + + Ok(EventUnsubscriber { + handle, + rx, + _lifetime_marker: PhantomData, + }) + } +} + +impl<'a, C: Deref + Clone> RequestBuilder<'a, C> { + pub fn from( + program_id: Pubkey, + cluster: &str, + payer: C, + options: Option, + ) -> Self { + Self { + program_id, + payer, + cluster: cluster.to_string(), + accounts: Vec::new(), + options: options.unwrap_or_default(), + instructions: Vec::new(), + instruction_data: None, + signers: Vec::new(), + } + } + + pub async fn signed_transaction(&self) -> Result { + self.signed_transaction_internal().await + } + + pub async fn send(self) -> Result { + self.send_internal().await + } + + pub async fn send_with_spinner_and_config( + self, + config: RpcSendTransactionConfig, + ) -> Result { + self.send_with_spinner_and_config_internal(config).await + } +} diff --git a/docker/Makefile b/docker/Makefile index ecd508ba8f..2db15881cc 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -2,11 +2,11 @@ WORKDIR=$(PWD) # # Anchor version. # -ANCHOR_CLI=v0.27.0 +ANCHOR_CLI=v0.28.0 # # Solana toolchain. # -SOLANA_CLI=v1.14.16 +SOLANA_CLI=v1.16.0 # # Build version should match the Anchor cli version. # diff --git a/docs/programs/tic-tac-toe/Anchor.toml b/docs/programs/tic-tac-toe/Anchor.toml index ecfc70d19f..0fcca0714f 100644 --- a/docs/programs/tic-tac-toe/Anchor.toml +++ b/docs/programs/tic-tac-toe/Anchor.toml @@ -1,9 +1,6 @@ [programs.localnet] tic_tac_toe = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS" -[registry] -url = "https://anchor.projectserum.com" - [provider] cluster = "localnet" wallet = "~/.config/solana/id.json" diff --git a/docs/programs/tic-tac-toe/Cargo.lock b/docs/programs/tic-tac-toe/Cargo.lock index 72585804b3..5119a2cf8b 100644 --- a/docs/programs/tic-tac-toe/Cargo.lock +++ b/docs/programs/tic-tac-toe/Cargo.lock @@ -24,7 +24,7 @@ dependencies = [ [[package]] name = "anchor-attribute-access-control" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf7d535e1381be3de2c0716c0a1c1e32ad9df1042cddcf7bc18d743569e53319" dependencies = [ @@ -38,7 +38,7 @@ dependencies = [ [[package]] name = "anchor-attribute-account" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3bcd731f21048a032be27c7791701120e44f3f6371358fc4261a7f716283d29" dependencies = [ @@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "anchor-attribute-constant" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1be64a48e395fe00b8217287f226078be2cf32dae42fdf8a885b997945c3d28" dependencies = [ @@ -64,7 +64,7 @@ dependencies = [ [[package]] name = "anchor-attribute-error" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38ea6713d1938c0da03656ff8a693b17dc0396da66d1ba320557f07e86eca0d4" dependencies = [ @@ -76,7 +76,7 @@ dependencies = [ [[package]] name = "anchor-attribute-event" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d401f11efb3644285685f8339829a9786d43ed7490bb1699f33c478d04d5a582" dependencies = [ @@ -89,7 +89,7 @@ dependencies = [ [[package]] name = "anchor-attribute-interface" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6700a6f5c888a9c33fe8afc0c64fd8575fa28d05446037306d0f96102ae4480" dependencies = [ @@ -103,7 +103,7 @@ dependencies = [ [[package]] name = "anchor-attribute-program" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ad769993b5266714e8939e47fbdede90e5c030333c7522d99a4d4748cf26712" dependencies = [ @@ -116,7 +116,7 @@ dependencies = [ [[package]] name = "anchor-attribute-state" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e677fae4a016a554acdd0e3b7f178d3acafaa7e7ffac6b8690cf4e171f1c116" dependencies = [ @@ -129,7 +129,7 @@ dependencies = [ [[package]] name = "anchor-derive-accounts" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "340beef6809d1c3fcc7ae219153d981e95a8a277ff31985bd7050e32645dc9a8" dependencies = [ @@ -142,7 +142,7 @@ dependencies = [ [[package]] name = "anchor-lang" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "662ceafe667448ee4199a4be2ee83b6bb76da28566eee5cea05f96ab38255af8" dependencies = [ @@ -166,7 +166,7 @@ dependencies = [ [[package]] name = "anchor-syn" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0418bcb5daac3b8cb1b60d8fdb1d468ca36f5509f31fb51179326fae1028fdcc" dependencies = [ diff --git a/docs/programs/tic-tac-toe/programs/tic-tac-toe/Cargo.toml b/docs/programs/tic-tac-toe/programs/tic-tac-toe/Cargo.toml index 9415d1337e..1042435cd5 100644 --- a/docs/programs/tic-tac-toe/programs/tic-tac-toe/Cargo.toml +++ b/docs/programs/tic-tac-toe/programs/tic-tac-toe/Cargo.toml @@ -16,6 +16,6 @@ cpi = ["no-entrypoint"] default = [] [dependencies] -anchor-lang = "=0.27.0" +anchor-lang = "=0.28.0" num-traits = "0.2" num-derive = "0.3" diff --git a/docs/src/pages/docs/installation.md b/docs/src/pages/docs/installation.md index 9241846fde..be03133836 100644 --- a/docs/src/pages/docs/installation.md +++ b/docs/src/pages/docs/installation.md @@ -63,7 +63,7 @@ Anchor binaries are available via an NPM package [`@coral-xyz/anchor-cli`](https We can also use Cargo to install the CLI directly. Make sure that the `--tag` argument uses the version you want (the version here is just an example). ```shell -cargo install --git https://github.com/coral-xyz/anchor --tag v0.27.0 anchor-cli --locked +cargo install --git https://github.com/coral-xyz/anchor --tag v0.28.0 anchor-cli --locked ``` On Linux systems you may need to install additional dependencies if cargo install fails. On Ubuntu, diff --git a/docs/src/pages/docs/publishing-source.md b/docs/src/pages/docs/publishing-source.md index 1d3324f1bc..da022e3466 100644 --- a/docs/src/pages/docs/publishing-source.md +++ b/docs/src/pages/docs/publishing-source.md @@ -34,7 +34,7 @@ have an `Anchor.toml` to define the build. An example `Anchor.toml` config looks as follows, ```toml -anchor_version = "0.27.0" +anchor_version = "0.28.0" [workspace] members = ["programs/multisig"] diff --git a/docs/src/pages/docs/release-notes.md b/docs/src/pages/docs/release-notes.md index b402f102c9..a98e2e7d0c 100644 --- a/docs/src/pages/docs/release-notes.md +++ b/docs/src/pages/docs/release-notes.md @@ -8,6 +8,36 @@ The minor version will be incremented upon a breaking change and the patch versi --- +## [0.28.0] - 2023-06-09 + +### Features + +- client: Add `async` feature flag to use an asynchronous anchor-client ([#2488](https://github.com/coral-xyz/anchor/pull/2488)). +- spl: Add metadata wrappers `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](https://github.com/coral-xyz/anchor/pull/2430)) +- spl: Add `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](https://github.com/coral-xyz/anchor/pull/2460)) +- cli: Add support for Solidity programs. `anchor init` and `anchor new` take an option `--solidity` which creates solidity code rather than rust. `anchor build` and `anchor test` work accordingly ([#2421](https://github.com/coral-xyz/anchor/pull/2421)) +- bench: Add benchmarking for compute units usage ([#2466](https://github.com/coral-xyz/anchor/pull/2466)) +- cli: `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](https://github.com/coral-xyz/anchor/pull/2486)). +- lang: Add `emit_cpi!` and `#[event_cpi]` macros(behind `event-cpi` feature flag) to store event logs in transaction metadata ([#2438](https://github.com/coral-xyz/anchor/pull/2438)). +- cli: Add `keys sync` command to sync program id declarations ([#2505](https://github.com/coral-xyz/anchor/pull/2505)). +- cli: Create new programs with correct program ids ([#2509](https://github.com/coral-xyz/anchor/pull/2509)). +- cli, client, lang, spl: Update Solana toolchain and dependencies to `1.16.0` and specify maximum version of `<1.17.0` ([#2512](https://github.com/coral-xyz/anchor/pull/2512)). +- cli: `anchor deploy` command's `--program-name` argument accepts program lib names ([#2519](https://github.com/coral-xyz/anchor/pull/2519)). + +### Fixes + +- ts: Narrowed `AccountClient` type to it's appropriate account type ([#2440](https://github.com/coral-xyz/anchor/pull/2440)) +- lang: Fix inability to use identifiers `program_id`, `accounts`, `ix_data`, `remaining_accounts` in instruction arguments ([#2464](https://github.com/coral-xyz/anchor/pull/2464)) +- cli: Fix incorrect `metadata.address` generation in IDL after deploying with a custom keypair ([#2485](https://github.com/coral-xyz/anchor/pull/2485)) +- cli: IDL commands no longer hang when the payer doesn't have funds to pay for the transaction fee ([#2492](https://github.com/coral-xyz/anchor/pull/2492)) +- cli: Fix `anchor new` not updating `Anchor.toml` ([#2516](https://github.com/coral-xyz/anchor/pull/2516)). +- client, lang, spl: Allow wider range of dependency versions to reduce dependency issues ([#2524](https://github.com/coral-xyz/anchor/pull/2524)). + +### Breaking + +- lang: Identifiers that are intended for internal usage(`program_id`, `accounts`, `ix_data`, `remaining_accounts`) have been renamed with `__` prefix ([#2464](https://github.com/coral-xyz/anchor/pull/2464)) +- spl: Remove the `metadata::create_metadata_account_v2` deprecated wrapper since it was removed from token metadata program ([#2480](https://github.com/coral-xyz/anchor/pull/2480)) + ## [0.27.0] - 2023-03-08 ### Features diff --git a/docs/src/pages/docs/space.md b/docs/src/pages/docs/space.md index 45bb46a756..40bd6ba971 100644 --- a/docs/src/pages/docs/space.md +++ b/docs/src/pages/docs/space.md @@ -12,6 +12,8 @@ so there the `C` layout applies. In addition to the space for the account data, you have to add `8` to the `space` constraint for Anchor's internal discriminator (see the example). +## Type chart + | Types | Space in bytes | Details/Example | | ---------- | ----------------------------- | ----------------------------------------------------------------------------------------------- | | bool | 1 | would only require 1 bit but still uses 1 byte | @@ -29,7 +31,7 @@ In addition to the space for the account data, you have to add `8` to the `space | f32 | 4 | serialization will fail for NaN | | f64 | 8 | serialization will fail for NaN | -# Example +## Example ```rust #[account] @@ -59,3 +61,33 @@ pub struct InitializeMyData<'info> { pub system_program: Program<'info, System> } ``` + +## The InitSpace macro + +Sometimes it can be difficult to calculate the initial space of an account. This macro will add an `INIT_SPACE` constant to the structure. It is not necessary for the structure to contain the `#[account]` macro to generate the constant. Here's an example: + +```rust +#[account] +#[derive(InitSpace)] +pub struct ExampleAccount { + pub data: u64, + #[max_len(50)] + pub string_one: String, + #[max_len(10, 5)] + pub nested: Vec>, +} + +#[derive(Accounts)] +pub struct Initialize<'info> { + #[account(mut)] + pub payer: Signer<'info>, + pub system_program: Program<'info, System>, + #[account(init, payer = payer, space = 8 + ExampleAccount::INIT_SPACE)] + pub data: Account<'info, ExampleAccount>, +} +``` + +A few important things to know: + +- Don't forget the discriminator when defining `space` +- The `max_len` length represents the length of the structure, not the total length. (ie: the `max_len` of a Vec will be `max_len` \* 4) diff --git a/docs/src/pages/docs/verifiable-builds.md b/docs/src/pages/docs/verifiable-builds.md index fd0ae383a3..ca79db672e 100644 --- a/docs/src/pages/docs/verifiable-builds.md +++ b/docs/src/pages/docs/verifiable-builds.md @@ -37,10 +37,10 @@ If the program has an IDL, it will also check the IDL deployed on chain matches. ## Images -A docker image for each version of Anchor is published on [Docker Hub](https://hub.docker.com/r/projectserum/build). They are tagged in the form `projectserum/build:`. For example, to get the image for Anchor `v0.27.0` one can run +A docker image for each version of Anchor is published on [Docker Hub](https://hub.docker.com/r/projectserum/build). They are tagged in the form `projectserum/build:`. For example, to get the image for Anchor `v0.28.0` one can run ```shell -docker pull projectserum/build:v0.27.0 +docker pull projectserum/build:v0.28.0 ``` ## Removing an Image diff --git a/examples/tutorial/basic-0/package.json b/examples/tutorial/basic-0/package.json index e5a07fa02e..ca7115f612 100644 --- a/examples/tutorial/basic-0/package.json +++ b/examples/tutorial/basic-0/package.json @@ -1,6 +1,6 @@ { "name": "basic-0", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/examples/tutorial/basic-1/package.json b/examples/tutorial/basic-1/package.json index 81a4d01c16..9fd9704f4b 100644 --- a/examples/tutorial/basic-1/package.json +++ b/examples/tutorial/basic-1/package.json @@ -1,6 +1,6 @@ { "name": "basic-1", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/examples/tutorial/basic-2/package.json b/examples/tutorial/basic-2/package.json index 8af52deb2a..771d3ba1af 100644 --- a/examples/tutorial/basic-2/package.json +++ b/examples/tutorial/basic-2/package.json @@ -1,6 +1,6 @@ { "name": "basic-2", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/examples/tutorial/basic-3/package.json b/examples/tutorial/basic-3/package.json index 713808a27e..c02567767c 100644 --- a/examples/tutorial/basic-3/package.json +++ b/examples/tutorial/basic-3/package.json @@ -1,6 +1,6 @@ { "name": "basic-3", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/examples/tutorial/basic-4/package.json b/examples/tutorial/basic-4/package.json index 1360fff2ed..a4eed191ab 100644 --- a/examples/tutorial/basic-4/package.json +++ b/examples/tutorial/basic-4/package.json @@ -1,6 +1,6 @@ { "name": "basic-4", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/examples/tutorial/basic-5/Anchor.toml b/examples/tutorial/basic-5/Anchor.toml new file mode 100644 index 0000000000..e7f396fc7f --- /dev/null +++ b/examples/tutorial/basic-5/Anchor.toml @@ -0,0 +1,9 @@ +[provider] +cluster = "localnet" +wallet = "~/.config/solana/id.json" + +[programs.localnet] +basic_5 = "DuT6R8tQGYa8ACYXyudFJtxDppSALLcmK39b7918jeSC" + +[scripts] +test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" \ No newline at end of file diff --git a/examples/tutorial/basic-5/Cargo.toml b/examples/tutorial/basic-5/Cargo.toml new file mode 100644 index 0000000000..7aa6203805 --- /dev/null +++ b/examples/tutorial/basic-5/Cargo.toml @@ -0,0 +1,4 @@ +[workspace] +members = [ + "programs/*" +] \ No newline at end of file diff --git a/examples/tutorial/basic-5/README.md b/examples/tutorial/basic-5/README.md new file mode 100644 index 0000000000..0ee5c5636c --- /dev/null +++ b/examples/tutorial/basic-5/README.md @@ -0,0 +1,13 @@ +# basic-5 + +This is a robot program developed as a Rust Smart Contract(running on Solana Blockchain). +It simplifies actions of a robot on-chain. +This program acts as an example for developers who are new to Solana ecosystem to learn on how the typescript client interacts with the program on-chain. + +Instructions of the program: + +1. Create +2. Walk +3. Run +4. Jump +5. Reset \ No newline at end of file diff --git a/examples/tutorial/basic-5/package.json b/examples/tutorial/basic-5/package.json new file mode 100644 index 0000000000..823d909792 --- /dev/null +++ b/examples/tutorial/basic-5/package.json @@ -0,0 +1,19 @@ +{ + "name": "basic-5", + "version": "0.28.0", + "license": "(MIT OR Apache-2.0)", + "homepage": "https://github.com/coral-xyz/anchor#readme", + "bugs": { + "url": "https://github.com/coral-xyz/anchor/issues" + }, + "repository": { + "type": "git", + "url": "https://github.com/coral-xyz/anchor.git" + }, + "engines": { + "node": ">=11" + }, + "scripts": { + "test": "anchor test --skip-lint" + } + } \ No newline at end of file diff --git a/examples/tutorial/basic-5/programs/basic-5/Cargo.toml b/examples/tutorial/basic-5/programs/basic-5/Cargo.toml new file mode 100644 index 0000000000..8b5ee1f8e3 --- /dev/null +++ b/examples/tutorial/basic-5/programs/basic-5/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "basic-5" +version = "0.1.0" +description = "Created with Anchor" +rust-version = "1.60" +edition = "2021" + +[lib] +crate-type = ["cdylib", "lib"] +name = "basic_5" + +[features] +no-entrypoint = [] +cpi = ["no-entrypoint"] + +[dependencies] +anchor-lang = { path = "../../../../../lang" } \ No newline at end of file diff --git a/examples/tutorial/basic-5/programs/basic-5/Xargo.toml b/examples/tutorial/basic-5/programs/basic-5/Xargo.toml new file mode 100644 index 0000000000..475fb71ed1 --- /dev/null +++ b/examples/tutorial/basic-5/programs/basic-5/Xargo.toml @@ -0,0 +1,2 @@ +[target.bpfel-unknown-unknown.dependencies.std] +features = [] diff --git a/examples/tutorial/basic-5/programs/basic-5/src/lib.rs b/examples/tutorial/basic-5/programs/basic-5/src/lib.rs new file mode 100644 index 0000000000..03542a69c3 --- /dev/null +++ b/examples/tutorial/basic-5/programs/basic-5/src/lib.rs @@ -0,0 +1,115 @@ +use anchor_lang::prelude::*; + +declare_id!("DuT6R8tQGYa8ACYXyudFJtxDppSALLcmK39b7918jeSC"); + +#[program] +pub mod basic_5 { + use super::*; + + pub fn create(ctx: Context) -> Result<()> { + let action_state = &mut ctx.accounts.action_state; + // * - means dereferencing + action_state.user = *ctx.accounts.user.key; + // Lets initialize the state + action_state.action = 0; + + Ok(()) + } + + pub fn walk(ctx: Context) -> Result<()> { + let action_state = &mut ctx.accounts.action_state; + // Lets change the robot action state to "walk" + action_state.action = 1; + + Ok(()) + } + + pub fn run(ctx: Context) -> Result<()> { + let action_state = &mut ctx.accounts.action_state; + // Lets change the robot action state to "run" + action_state.action = 2; + + Ok(()) + } + + pub fn jump(ctx: Context) -> Result<()> { + let action_state = &mut ctx.accounts.action_state; + // Lets change the robot action state to "jump" + action_state.action = 3; + + Ok(()) + } + + pub fn reset(ctx: Context) -> Result<()> { + let action_state = &mut ctx.accounts.action_state; + // Lets reset the robot action states + action_state.action = 0; + + Ok(()) + } +} + +#[derive(Accounts)] +pub struct Create<'info> { + // init means to create action_state account + // bump to use unique address for action_state account + #[account( + init, + payer = user, + space = 8 + ActionState::INIT_SPACE, + seeds = [b"action-state", user.key().as_ref()], + bump + )] + pub action_state: Account<'info, ActionState>, + // mut makes it changeble (mutable) + #[account(mut)] + pub user: Signer<'info>, + pub system_program: Program<'info, System>, +} + +#[derive(Accounts)] +pub struct Walk<'info> { + // Only the user on account action_state, should be able to change state + #[account(mut, has_one = user)] + pub action_state: Account<'info, ActionState>, + // mut makes it changeble (mutable) + #[account(mut)] + pub user: Signer<'info>, +} + +#[derive(Accounts)] +pub struct Run<'info> { + // Only the user on account action_state, should be able to change state + #[account(mut, has_one = user)] + pub action_state: Account<'info, ActionState>, + // mut makes it changeble (mutable) + #[account(mut)] + pub user: Signer<'info>, +} + +#[derive(Accounts)] +pub struct Jump<'info> { + // Only the user on account action_state, should be able to change state + #[account(mut, has_one = user)] + pub action_state: Account<'info, ActionState>, + // mut makes it changeble (mutable) + #[account(mut)] + pub user: Signer<'info>, +} + +#[derive(Accounts)] +pub struct Reset<'info> { + // Only the user on account action_state, should be able to change state + #[account(mut, has_one = user)] + pub action_state: Account<'info, ActionState>, + // mut makes it changeble (mutable) + #[account(mut)] + pub user: Signer<'info>, +} + +#[account] +#[derive(InitSpace)] +pub struct ActionState { + pub user: Pubkey, + pub action: u8, +} diff --git a/examples/tutorial/basic-5/tests/basic-5.ts b/examples/tutorial/basic-5/tests/basic-5.ts new file mode 100644 index 0000000000..4433f420ae --- /dev/null +++ b/examples/tutorial/basic-5/tests/basic-5.ts @@ -0,0 +1,120 @@ +import * as anchor from "@coral-xyz/anchor"; +import { Basic5 } from "../target/types/basic_5"; + +describe("basic-5", () => { + const provider = anchor.AnchorProvider.local(); + + // Configure the client to use the local cluster. + anchor.setProvider(provider); + + const program = anchor.workspace.Basic5 as anchor.Program; + const user = provider.wallet.publicKey; + + let [actionState] = anchor.web3.PublicKey.findProgramAddressSync( + [Buffer.from("action-state"), user.toBuffer()], + program.programId + ); + + it("basic-5: Robot actions!", async () => { + // Create instruction: set up the Solana accounts to be used + const createInstruction = await program.methods + .create() + .accounts({ + actionState, + user, + systemProgram: anchor.web3.SystemProgram.programId, + }) + .instruction(); + // Walk instruction: Invoke the Robot to walk + const walkInstruction = await program.methods + .walk() + .accounts({ + actionState, + user, + }) + .instruction(); + // Run instruction: Invoke the Robot to run + const runInstruction = await program.methods + .run() + .accounts({ + actionState, + user, + }) + .instruction(); + // Jump instruction: Invoke the Robot to jump + const jumpInstruction = await program.methods + .jump() + .accounts({ + actionState, + user, + }) + .instruction(); + // Reset instruction: Reset actions of the Robot + const resetInstruction = await program.methods + .reset() + .accounts({ + actionState, + user, + }) + .instruction(); + + // Array of instructions + const instructions: anchor.web3.TransactionInstruction[] = [ + createInstruction, + walkInstruction, + runInstruction, + jumpInstruction, + resetInstruction, + ]; + + await createAndSendV0Tx(instructions); + }); + + async function createAndSendV0Tx( + txInstructions: anchor.web3.TransactionInstruction[] + ) { + // Step 1 - Fetch the latest blockhash + let latestBlockhash = await provider.connection.getLatestBlockhash( + "confirmed" + ); + console.log( + " ✅ - Fetched latest blockhash. Last Valid Height:", + latestBlockhash.lastValidBlockHeight + ); + + // Step 2 - Generate Transaction Message + const messageV0 = new anchor.web3.TransactionMessage({ + payerKey: user, + recentBlockhash: latestBlockhash.blockhash, + instructions: txInstructions, + }).compileToV0Message(); + console.log(" ✅ - Compiled Transaction Message"); + const transaction = new anchor.web3.VersionedTransaction(messageV0); + + // Step 3 - Sign your transaction with the required `Signers` + provider.wallet.signTransaction(transaction); + console.log(" ✅ - Transaction Signed"); + + // Step 4 - Send our v0 transaction to the cluster + const txid = await provider.connection.sendTransaction(transaction, { + maxRetries: 5, + }); + console.log(" ✅ - Transaction sent to network"); + + // Step 5 - Confirm Transaction + const confirmation = await provider.connection.confirmTransaction({ + signature: txid, + blockhash: latestBlockhash.blockhash, + lastValidBlockHeight: latestBlockhash.lastValidBlockHeight, + }); + if (confirmation.value.err) { + throw new Error( + ` ❌ - Transaction not confirmed.\nReason: ${confirmation.value.err}` + ); + } + + console.log("🎉 Transaction Succesfully Confirmed!"); + let result = await program.account.actionState.fetch(actionState); + console.log("Robot action state details: ", result); + } +}); diff --git a/examples/tutorial/basic-5/tsconfig.json b/examples/tutorial/basic-5/tsconfig.json new file mode 100644 index 0000000000..8634a05df4 --- /dev/null +++ b/examples/tutorial/basic-5/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "types": ["mocha"], + "typeRoots": ["./node_modules/@types"], + "lib": ["es2015"], + "module": "commonjs", + "target": "es6", + "esModuleInterop": true + } +} diff --git a/examples/tutorial/package.json b/examples/tutorial/package.json index fba8354deb..ed6d464b36 100644 --- a/examples/tutorial/package.json +++ b/examples/tutorial/package.json @@ -10,13 +10,14 @@ "basic-1", "basic-2", "basic-3", - "basic-4" + "basic-4", + "basic-5" ], - "dependencies": { - "@coral-xyz/anchor": "file:../../ts/packages/anchor" - }, "devDependencies": { - "mocha": "9.2.2", - "prettier": "^2.5.1" + "mocha": "^9.2.2", + "prettier": "^2.5.1", + "@types/mocha": "^9.1.1", + "ts-mocha": "^10.0.0", + "typescript": "^4.9.5" } } diff --git a/examples/tutorial/yarn.lock b/examples/tutorial/yarn.lock index e83796f9a8..d8a4305c88 100644 --- a/examples/tutorial/yarn.lock +++ b/examples/tutorial/yarn.lock @@ -2,151 +2,21 @@ # yarn lockfile v1 -"@babel/runtime@^7.12.5": - version "7.16.3" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.16.3.tgz#b86f0db02a04187a3c17caa77de69840165d42d5" - integrity sha512-WBwekcqacdY2e9AF/Q7WLFUWmdJGJTkbjqTjoMDgXkVZ3ZRUvOPsLb5KdwISoQVsbP+DQzVZW4Zhci0DvpbNTQ== - dependencies: - regenerator-runtime "^0.13.4" - -"@babel/runtime@^7.17.2": - version "7.20.6" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.20.6.tgz#facf4879bfed9b5326326273a64220f099b0fce3" - integrity sha512-Q+8MqP7TiHMWzSfwiJwXCjyf4GYA4Dgw3emg/7xmwsdLJOZUp+nMqcOwOzzYheuM1rhDu8FSj2l0aoMygEuXuA== - dependencies: - regenerator-runtime "^0.13.11" - -"@coral-xyz/anchor@file:../../ts/packages/anchor": - version "0.27.0" - dependencies: - "@coral-xyz/borsh" "^0.27.0" - "@solana/web3.js" "^1.68.0" - base64-js "^1.5.1" - bn.js "^5.1.2" - bs58 "^4.0.1" - buffer-layout "^1.2.2" - camelcase "^6.3.0" - cross-fetch "^3.1.5" - crypto-hash "^1.3.0" - eventemitter3 "^4.0.7" - js-sha256 "^0.9.0" - pako "^2.0.3" - snake-case "^3.0.4" - superstruct "^0.15.4" - toml "^3.0.0" - -"@coral-xyz/borsh@^0.27.0": - version "0.26.0" - resolved "https://registry.yarnpkg.com/@coral-xyz/borsh/-/borsh-0.26.0.tgz#d054f64536d824634969e74138f9f7c52bbbc0d5" - integrity sha512-uCZ0xus0CszQPHYfWAqKS5swS1UxvePu83oOF+TWpUkedsNlg6p2p4azxZNSSqwXb9uXMFgxhuMBX9r3Xoi0vQ== - dependencies: - bn.js "^5.1.2" - buffer-layout "^1.2.0" - -"@noble/ed25519@^1.7.0": - version "1.7.1" - resolved "https://registry.yarnpkg.com/@noble/ed25519/-/ed25519-1.7.1.tgz#6899660f6fbb97798a6fbd227227c4589a454724" - integrity sha512-Rk4SkJFaXZiznFyC/t77Q0NKS4FL7TLJJsVG2V2oiEq3kJVeTdxysEe/yRWSpnWMe808XRDJ+VFh5pt/FN5plw== +"@types/json5@^0.0.29": + version "0.0.29" + resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" + integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ== -"@noble/hashes@^1.1.2": - version "1.1.4" - resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.1.4.tgz#2611ebf5764c1bf754da7c7794de4fb30512336d" - integrity sha512-+PYsVPrTSqtVjatKt2A/Proukn2Yrz61OBThOCKErc5w2/r1Fh37vbDv0Eah7pyNltrmacjwTvdw3JoR+WE4TA== - -"@noble/secp256k1@^1.6.3": - version "1.7.0" - resolved "https://registry.yarnpkg.com/@noble/secp256k1/-/secp256k1-1.7.0.tgz#d15357f7c227e751d90aa06b05a0e5cf993ba8c1" - integrity sha512-kbacwGSsH/CTout0ZnZWxnW1B+jH/7r/WAAKLBtrRJ/+CUH7lgmQzl3GTrQua3SGKWNSDsS6lmjnDpIJ5Dxyaw== - -"@solana/buffer-layout@^4.0.0": - version "4.0.1" - resolved "https://registry.yarnpkg.com/@solana/buffer-layout/-/buffer-layout-4.0.1.tgz#b996235eaec15b1e0b5092a8ed6028df77fa6c15" - integrity sha512-E1ImOIAD1tBZFRdjeM4/pzTiTApC0AOBGwyAMS4fwIodCWArzJ3DWdoh8cKxeFM2fElkxBh2Aqts1BPC373rHA== - dependencies: - buffer "~6.0.3" - -"@solana/web3.js@^1.68.0": - version "1.70.1" - resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.70.1.tgz#4a2df47cc32a0f67be5161e772b2ceb6512281fa" - integrity sha512-AnaqCF1cJ3w7d0yhvLGAKAcRI+n5o+ursQihhoTe4cUh8/9d4gbT73SoHYElS7e67OtAgLmSfbcC5hcOAgdvnQ== - dependencies: - "@babel/runtime" "^7.12.5" - "@noble/ed25519" "^1.7.0" - "@noble/hashes" "^1.1.2" - "@noble/secp256k1" "^1.6.3" - "@solana/buffer-layout" "^4.0.0" - bigint-buffer "^1.1.5" - bn.js "^5.0.0" - borsh "^0.7.0" - bs58 "^4.0.1" - buffer "6.0.1" - fast-stable-stringify "^1.0.0" - jayson "^3.4.4" - node-fetch "2" - rpc-websockets "^7.5.0" - superstruct "^0.14.2" - -"@types/connect@^3.4.33": - version "3.4.35" - resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.35.tgz#5fcf6ae445e4021d1fc2219a4873cc73a3bb2ad1" - integrity sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ== - dependencies: - "@types/node" "*" - -"@types/express-serve-static-core@^4.17.9": - version "4.17.25" - resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.25.tgz#e42f7046adc65ece2eb6059b77aecfbe9e9f82e0" - integrity sha512-OUJIVfRMFijZukGGwTpKNFprqCCXk5WjNGvUgB/CxxBR40QWSjsNK86+yvGKlCOGc7sbwfHLaXhkG+NsytwBaQ== - dependencies: - "@types/node" "*" - "@types/qs" "*" - "@types/range-parser" "*" - -"@types/lodash@^4.14.159": - version "4.14.176" - resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.176.tgz#641150fc1cda36fbfa329de603bbb175d7ee20c0" - integrity sha512-xZmuPTa3rlZoIbtDUyJKZQimJV3bxCmzMIO2c9Pz9afyDro6kr7R79GwcB6mRhuoPmV2p1Vb66WOJH7F886WKQ== - -"@types/node@*": - version "16.11.7" - resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.7.tgz#36820945061326978c42a01e56b61cd223dfdc42" - integrity sha512-QB5D2sqfSjCmTuWcBWyJ+/44bcjO7VbjSbOE0ucoVbAsSNQc4Lt6QkgkVXkTDwkL4z/beecZNDvVX15D4P8Jbw== - -"@types/node@^12.12.54": - version "12.20.37" - resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.37.tgz#abb38afa9d6e8a2f627a8cb52290b3c80fbe61ed" - integrity sha512-i1KGxqcvJaLQali+WuypQnXwcplhtNtjs66eNsZpp2P2FL/trJJxx/VWsM0YCL2iMoIJrbXje48lvIQAQ4p2ZA== - -"@types/qs@*": - version "6.9.7" - resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.7.tgz#63bb7d067db107cc1e457c303bc25d511febf6cb" - integrity sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw== - -"@types/range-parser@*": - version "1.2.4" - resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.4.tgz#cd667bcfdd025213aafb7ca5915a932590acdcdc" - integrity sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw== - -"@types/ws@^7.4.4": - version "7.4.7" - resolved "https://registry.yarnpkg.com/@types/ws/-/ws-7.4.7.tgz#f7c390a36f7a0679aa69de2d501319f4f8d9b702" - integrity sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww== - dependencies: - "@types/node" "*" +"@types/mocha@^9.1.1": + version "9.1.1" + resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-9.1.1.tgz#e7c4f1001eefa4b8afbd1eee27a237fee3bf29c4" + integrity sha512-Z61JK7DKDtdKTWwLeElSEBcWGRLY8g95ic5FoQqI9CMx0ns/Ghep3B4DfcEimiKMvtamNVULVNKEsiwV3aQmXw== "@ungap/promise-all-settled@1.1.2": version "1.1.2" resolved "https://registry.yarnpkg.com/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz#aa58042711d6e3275dd37dc597e5d31e8c290a44" integrity sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q== -JSONStream@^1.3.5: - version "1.3.5" - resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.5.tgz#3208c1f08d3a4d99261ab64f92302bc15e111ca0" - integrity sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ== - dependencies: - jsonparse "^1.2.0" - through ">=2.2.7 <3" - ansi-colors@4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" @@ -177,61 +47,21 @@ argparse@^2.0.1: resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== +arrify@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" + integrity sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA== + balanced-match@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== -base-x@^3.0.2: - version "3.0.9" - resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.9.tgz#6349aaabb58526332de9f60995e548a53fe21320" - integrity sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ== - dependencies: - safe-buffer "^5.0.1" - -base64-js@^1.3.1, base64-js@^1.5.1: - version "1.5.1" - resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" - integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== - -bigint-buffer@^1.1.5: - version "1.1.5" - resolved "https://registry.yarnpkg.com/bigint-buffer/-/bigint-buffer-1.1.5.tgz#d038f31c8e4534c1f8d0015209bf34b4fa6dd442" - integrity sha512-trfYco6AoZ+rKhKnxA0hgX0HAbVP/s808/EuDSe2JDzUnCp/xAsli35Orvk67UrTEcwuxZqYZDmfA2RXJgxVvA== - dependencies: - bindings "^1.3.0" - binary-extensions@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== -bindings@^1.3.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.5.0.tgz#10353c9e945334bc0511a6d90b38fbc7c9c504df" - integrity sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ== - dependencies: - file-uri-to-path "1.0.0" - -bn.js@^5.0.0, bn.js@^5.1.2: - version "5.2.0" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.0.tgz#358860674396c6997771a9d051fcc1b57d4ae002" - integrity sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw== - -bn.js@^5.2.0: - version "5.2.1" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.1.tgz#0bc527a6a0d18d0aa8d5b0538ce4a77dccfa7b70" - integrity sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ== - -borsh@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/borsh/-/borsh-0.7.0.tgz#6e9560d719d86d90dc589bca60ffc8a6c51fec2a" - integrity sha512-CLCsZGIBCFnPtkNnieW/a8wmreDmfUtjU2m9yHrzPXIlNbqVs0AQrSatSG6vdNYUqdc83tkQi2eHfF98ubzQLA== - dependencies: - bn.js "^5.2.0" - bs58 "^4.0.0" - text-encoding-utf-8 "^1.0.2" - brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" @@ -252,51 +82,16 @@ browser-stdout@1.3.1: resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw== -bs58@^4.0.0, bs58@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/bs58/-/bs58-4.0.1.tgz#be161e76c354f6f788ae4071f63f34e8c4f0a42a" - integrity sha1-vhYedsNU9veIrkBx9j806MTwpCo= - dependencies: - base-x "^3.0.2" - -buffer-layout@^1.2.0, buffer-layout@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/buffer-layout/-/buffer-layout-1.2.2.tgz#b9814e7c7235783085f9ca4966a0cfff112259d5" - integrity sha512-kWSuLN694+KTk8SrYvCqwP2WcgQjoRCiF5b4QDvkkz8EmgD+aWAIceGFKMIAdmF/pH+vpgNV3d3kAKorcdAmWA== - -buffer@6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.1.tgz#3cbea8c1463e5a0779e30b66d4c88c6ffa182ac2" - integrity sha512-rVAXBwEcEoYtxnHSO5iWyhzV/O1WMtkUYWlfdLS7FjU4PnSJJHEfHXi/uHPI5EwltmOA794gN3bm3/pzuctWjQ== - dependencies: - base64-js "^1.3.1" - ieee754 "^1.2.1" - -buffer@~6.0.3: - version "6.0.3" - resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6" - integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA== - dependencies: - base64-js "^1.3.1" - ieee754 "^1.2.1" - -bufferutil@^4.0.1: - version "4.0.5" - resolved "https://registry.yarnpkg.com/bufferutil/-/bufferutil-4.0.5.tgz#da9ea8166911cc276bf677b8aed2d02d31f59028" - integrity sha512-HTm14iMQKK2FjFLRTM5lAVcyaUzOnqbPtesFIvREgXpJHdQm8bWS+GkQgIkfaBYRHuCnea7w8UVNfwiAQhlr9A== - dependencies: - node-gyp-build "^4.3.0" +buffer-from@^1.0.0, buffer-from@^1.1.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" + integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== camelcase@^6.0.0: version "6.2.0" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.2.0.tgz#924af881c9d525ac9d87f40d964e5cea982a1809" integrity sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg== -camelcase@^6.3.0: - version "6.3.0" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" - integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== - chalk@^4.1.0: version "4.1.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" @@ -341,28 +136,11 @@ color-name@~1.1.4: resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== -commander@^2.20.3: - version "2.20.3" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" - integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== - concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= -cross-fetch@^3.1.5: - version "3.1.5" - resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.5.tgz#e1389f44d9e7ba767907f7af8454787952ab534f" - integrity sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw== - dependencies: - node-fetch "2.6.7" - -crypto-hash@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/crypto-hash/-/crypto-hash-1.3.0.tgz#b402cb08f4529e9f4f09346c3e275942f845e247" - integrity sha512-lyAZ0EMyjDkVvz8WOeVnuCPvKVBXcMv1l5SVqO1yC7PzTwrD/pPje/BIRbWhMoPe436U+Y2nD7f5bFx0kt+Sbg== - debug@4.3.3: version "4.3.3" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.3.tgz#04266e0b70a98d4462e6e288e38259213332b664" @@ -375,41 +153,21 @@ decamelize@^4.0.0: resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-4.0.0.tgz#aa472d7bf660eb15f3494efd531cab7f2a709837" integrity sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ== -delay@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/delay/-/delay-5.0.0.tgz#137045ef1b96e5071060dd5be60bf9334436bd1d" - integrity sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw== - diff@5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b" integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w== -dot-case@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/dot-case/-/dot-case-3.0.4.tgz#9b2b670d00a431667a8a75ba29cd1b98809ce751" - integrity sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w== - dependencies: - no-case "^3.0.4" - tslib "^2.0.3" +diff@^3.1.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" + integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA== emoji-regex@^8.0.0: version "8.0.0" resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== -es6-promise@^4.0.3: - version "4.2.8" - resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.8.tgz#4eb21594c972bc40553d276e510539143db53e0a" - integrity sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w== - -es6-promisify@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203" - integrity sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM= - dependencies: - es6-promise "^4.0.3" - escalade@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" @@ -420,26 +178,6 @@ escape-string-regexp@4.0.0: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== -eventemitter3@^4.0.7: - version "4.0.7" - resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" - integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== - -eyes@^0.1.8: - version "0.1.8" - resolved "https://registry.yarnpkg.com/eyes/-/eyes-0.1.8.tgz#62cf120234c683785d902348a800ef3e0cc20bc0" - integrity sha1-Ys8SAjTGg3hdkCNIqADvPgzCC8A= - -fast-stable-stringify@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fast-stable-stringify/-/fast-stable-stringify-1.0.0.tgz#5c5543462b22aeeefd36d05b34e51c78cb86d313" - integrity sha512-wpYMUmFu5f00Sm0cj2pfivpmawLZ0NKdviQ4w9zJeR8JVtOpOxHmLaJuj0vxvGqMJQWyP/COUkF75/57OKyRag== - -file-uri-to-path@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" - integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw== - fill-range@^7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" @@ -509,11 +247,6 @@ he@1.2.0: resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== -ieee754@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" - integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== - inflight@^1.0.4: version "1.0.6" resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" @@ -571,37 +304,6 @@ isexe@^2.0.0: resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= -isomorphic-ws@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz#55fd4cd6c5e6491e76dc125938dd863f5cd4f2dc" - integrity sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w== - -jayson@^3.4.4: - version "3.6.5" - resolved "https://registry.yarnpkg.com/jayson/-/jayson-3.6.5.tgz#e560bcad4daf098c7391f46ba8efc9d6f34a4102" - integrity sha512-wmOjX+eQcnCDyPF4KORomaIj9wj3h0B5VEbeD0+2VHfTfErB+h1zpR7oBkgCZp36AFjp3+a4CLz6U72BYpFHAw== - dependencies: - "@types/connect" "^3.4.33" - "@types/express-serve-static-core" "^4.17.9" - "@types/lodash" "^4.14.159" - "@types/node" "^12.12.54" - "@types/ws" "^7.4.4" - JSONStream "^1.3.5" - commander "^2.20.3" - delay "^5.0.0" - es6-promisify "^5.0.0" - eyes "^0.1.8" - isomorphic-ws "^4.0.1" - json-stringify-safe "^5.0.1" - lodash "^4.17.20" - uuid "^3.4.0" - ws "^7.4.5" - -js-sha256@^0.9.0: - version "0.9.0" - resolved "https://registry.yarnpkg.com/js-sha256/-/js-sha256-0.9.0.tgz#0b89ac166583e91ef9123644bd3c5334ce9d0966" - integrity sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA== - js-yaml@4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" @@ -609,15 +311,12 @@ js-yaml@4.1.0: dependencies: argparse "^2.0.1" -json-stringify-safe@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" - integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus= - -jsonparse@^1.2.0: - version "1.3.1" - resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" - integrity sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA= +json5@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.2.tgz#63d98d60f21b313b77c4d6da18bfa69d80e1d593" + integrity sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA== + dependencies: + minimist "^1.2.0" locate-path@^6.0.0: version "6.0.0" @@ -626,11 +325,6 @@ locate-path@^6.0.0: dependencies: p-locate "^5.0.0" -lodash@^4.17.20: - version "4.17.21" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" - integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== - log-symbols@4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.1.0.tgz#3fbdbb95b4683ac9fc785111e792e558d4abd503" @@ -639,12 +333,10 @@ log-symbols@4.1.0: chalk "^4.1.0" is-unicode-supported "^0.1.0" -lower-case@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-2.0.2.tgz#6fa237c63dbdc4a82ca0fd882e4722dc5e634e28" - integrity sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg== - dependencies: - tslib "^2.0.3" +make-error@^1.1.1: + version "1.3.6" + resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" + integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== minimatch@4.2.1: version "4.2.1" @@ -660,7 +352,19 @@ minimatch@^3.0.4: dependencies: brace-expansion "^1.1.7" -mocha@9.2.2: +minimist@^1.2.0, minimist@^1.2.6: + version "1.2.8" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" + integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== + +mkdirp@^0.5.1: + version "0.5.6" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.6.tgz#7def03d2432dcae4ba1d611445c48396062255f6" + integrity sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw== + dependencies: + minimist "^1.2.6" + +mocha@^9.2.2: version "9.2.2" resolved "https://registry.yarnpkg.com/mocha/-/mocha-9.2.2.tgz#d70db46bdb93ca57402c809333e5a84977a88fb9" integrity sha512-L6XC3EdwT6YrIk0yXpavvLkn8h+EU+Y5UcCHKECyMbdUIxyMuZj4bX4U9e1nvnvUUvQVsV2VHQr5zLdcUkhW/g== @@ -705,26 +409,6 @@ nanoid@3.3.1: resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.1.tgz#6347a18cac88af88f58af0b3594b723d5e99bb35" integrity sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw== -no-case@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/no-case/-/no-case-3.0.4.tgz#d361fd5c9800f558551a8369fc0dcd4662b6124d" - integrity sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg== - dependencies: - lower-case "^2.0.2" - tslib "^2.0.3" - -node-fetch@2, node-fetch@2.6.7: - version "2.6.7" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" - integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== - dependencies: - whatwg-url "^5.0.0" - -node-gyp-build@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.3.0.tgz#9f256b03e5826150be39c764bf51e993946d71a3" - integrity sha512-iWjXZvmboq0ja1pUGULQBexmxq8CV4xBhX7VDOTbL7ZR4FOowwY/VOtRxBN/yKxmdGoIp4j5ysNT4u3S2pDQ3Q== - normalize-path@^3.0.0, normalize-path@~3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" @@ -751,11 +435,6 @@ p-locate@^5.0.0: dependencies: p-limit "^3.0.2" -pako@^2.0.3: - version "2.0.4" - resolved "https://registry.yarnpkg.com/pako/-/pako-2.0.4.tgz#6cebc4bbb0b6c73b0d5b8d7e8476e2b2fbea576d" - integrity sha512-v8tweI900AUkZN6heMU/4Uy4cXRc2AYNRggVmTR+dEncawDJgCdLMximOVA2p4qO57WMynangsfGRb5WD6L1Bg== - path-exists@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" @@ -790,35 +469,12 @@ readdirp@~3.6.0: dependencies: picomatch "^2.2.1" -regenerator-runtime@^0.13.11: - version "0.13.11" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz#f6dca3e7ceec20590d07ada785636a90cdca17f9" - integrity sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg== - -regenerator-runtime@^0.13.4: - version "0.13.9" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52" - integrity sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA== - require-directory@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= -rpc-websockets@^7.5.0: - version "7.5.0" - resolved "https://registry.yarnpkg.com/rpc-websockets/-/rpc-websockets-7.5.0.tgz#bbeb87572e66703ff151e50af1658f98098e2748" - integrity sha512-9tIRi1uZGy7YmDjErf1Ax3wtqdSSLIlnmL5OtOzgd5eqPKbsPpwDP5whUDO2LQay3Xp0CcHlcNSGzacNRluBaQ== - dependencies: - "@babel/runtime" "^7.17.2" - eventemitter3 "^4.0.7" - uuid "^8.3.2" - ws "^8.5.0" - optionalDependencies: - bufferutil "^4.0.1" - utf-8-validate "^5.0.2" - -safe-buffer@^5.0.1, safe-buffer@^5.1.0: +safe-buffer@^5.1.0: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== @@ -830,13 +486,18 @@ serialize-javascript@6.0.0: dependencies: randombytes "^2.1.0" -snake-case@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/snake-case/-/snake-case-3.0.4.tgz#4f2bbd568e9935abdfd593f34c691dadb49c452c" - integrity sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg== +source-map-support@^0.5.6: + version "0.5.21" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" + integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== dependencies: - dot-case "^3.0.4" - tslib "^2.0.3" + buffer-from "^1.0.0" + source-map "^0.6.0" + +source-map@^0.6.0: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== string-width@^4.1.0, string-width@^4.2.0: version "4.2.3" @@ -854,21 +515,16 @@ strip-ansi@^6.0.0, strip-ansi@^6.0.1: dependencies: ansi-regex "^5.0.1" +strip-bom@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" + integrity sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA== + strip-json-comments@3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== -superstruct@^0.14.2: - version "0.14.2" - resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-0.14.2.tgz#0dbcdf3d83676588828f1cf5ed35cda02f59025b" - integrity sha512-nPewA6m9mR3d6k7WkZ8N8zpTWfenFH3q9pA2PkuiZxINr9DKB2+40wEQf0ixn8VaGuJ78AB6iWOtStI+/4FKZQ== - -superstruct@^0.15.4: - version "0.15.5" - resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-0.15.5.tgz#0f0a8d3ce31313f0d84c6096cd4fa1bfdedc9dab" - integrity sha512-4AOeU+P5UuE/4nOUkmcQdW5y7i9ndt1cQd/3iUe+LTz3RxESf/W/5lg4B74HbDMMv8PHnPnGCQFH45kBcrQYoQ== - supports-color@8.1.1: version "8.1.1" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" @@ -883,16 +539,6 @@ supports-color@^7.1.0: dependencies: has-flag "^4.0.0" -text-encoding-utf-8@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz#585b62197b0ae437e3c7b5d0af27ac1021e10d13" - integrity sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg== - -"through@>=2.2.7 <3": - version "2.3.8" - resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" - integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= - to-regex-range@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" @@ -900,50 +546,43 @@ to-regex-range@^5.0.1: dependencies: is-number "^7.0.0" -toml@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/toml/-/toml-3.0.0.tgz#342160f1af1904ec9d204d03a5d61222d762c5ee" - integrity sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w== - -tr46@~0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" - integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= - -tslib@^2.0.3: - version "2.3.1" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01" - integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw== - -utf-8-validate@^5.0.2: - version "5.0.7" - resolved "https://registry.yarnpkg.com/utf-8-validate/-/utf-8-validate-5.0.7.tgz#c15a19a6af1f7ad9ec7ddc425747ca28c3644922" - integrity sha512-vLt1O5Pp+flcArHGIyKEQq883nBt8nN8tVBcoL0qUXj2XT1n7p70yGIq2VK98I5FdZ1YHc0wk/koOnHjnXWk1Q== +ts-mocha@^10.0.0: + version "10.0.0" + resolved "https://registry.yarnpkg.com/ts-mocha/-/ts-mocha-10.0.0.tgz#41a8d099ac90dbbc64b06976c5025ffaebc53cb9" + integrity sha512-VRfgDO+iiuJFlNB18tzOfypJ21xn2xbuZyDvJvqpTbWgkAgD17ONGr8t+Tl8rcBtOBdjXp5e/Rk+d39f7XBHRw== dependencies: - node-gyp-build "^4.3.0" - -uuid@^3.4.0: - version "3.4.0" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" - integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== - -uuid@^8.3.2: - version "8.3.2" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" - integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== - -webidl-conversions@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" - integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE= + ts-node "7.0.1" + optionalDependencies: + tsconfig-paths "^3.5.0" -whatwg-url@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" - integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0= - dependencies: - tr46 "~0.0.3" - webidl-conversions "^3.0.0" +ts-node@7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-7.0.1.tgz#9562dc2d1e6d248d24bc55f773e3f614337d9baf" + integrity sha512-BVwVbPJRspzNh2yfslyT1PSbl5uIk03EZlb493RKHN4qej/D06n1cEhjlOJG69oFsE7OT8XjpTUcYf6pKTLMhw== + dependencies: + arrify "^1.0.0" + buffer-from "^1.1.0" + diff "^3.1.0" + make-error "^1.1.1" + minimist "^1.2.0" + mkdirp "^0.5.1" + source-map-support "^0.5.6" + yn "^2.0.0" + +tsconfig-paths@^3.5.0: + version "3.14.2" + resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz#6e32f1f79412decd261f92d633a9dc1cfa99f088" + integrity sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g== + dependencies: + "@types/json5" "^0.0.29" + json5 "^1.0.2" + minimist "^1.2.6" + strip-bom "^3.0.0" + +typescript@^4.9.5: + version "4.9.5" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a" + integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== which@2.0.2: version "2.0.2" @@ -971,16 +610,6 @@ wrappy@1: resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= -ws@^7.4.5: - version "7.5.5" - resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.5.tgz#8b4bc4af518cfabd0473ae4f99144287b33eb881" - integrity sha512-BAkMFcAzl8as1G/hArkxOxq3G7pjUqQ3gzYbLL0/5zNkph70e+lCoxBGnm6AW1+/aiNeV4fnKqZ8m4GZewmH2w== - -ws@^8.5.0: - version "8.11.0" - resolved "https://registry.yarnpkg.com/ws/-/ws-8.11.0.tgz#6a0d36b8edfd9f96d8b25683db2f8d7de6e8e143" - integrity sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg== - y18n@^5.0.5: version "5.0.8" resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" @@ -1019,6 +648,11 @@ yargs@16.2.0: y18n "^5.0.5" yargs-parser "^20.2.2" +yn@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/yn/-/yn-2.0.0.tgz#e5adabc8acf408f6385fc76495684c88e6af689a" + integrity sha512-uTv8J/wiWTgUTg+9vLTi//leUl5vDQS6uii/emeTb2ssY7vl6QWf2fFbIIGjnhjvbdKlU0ed7QPgY1htTC86jQ== + yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" diff --git a/lang/Cargo.toml b/lang/Cargo.toml index af8b0529ce..7fa25bd652 100644 --- a/lang/Cargo.toml +++ b/lang/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "anchor-lang" -version = "0.27.0" -authors = ["Serum Foundation "] +version = "0.28.0" +authors = ["Anchor Maintainers "] repository = "https://github.com/coral-xyz/anchor" rust-version = "1.60" edition = "2021" @@ -13,6 +13,7 @@ allow-missing-optionals = ["anchor-derive-accounts/allow-missing-optionals"] init-if-needed = ["anchor-derive-accounts/init-if-needed"] derive = [] default = [] +event-cpi = ["anchor-attribute-event/event-cpi"] anchor-debug = [ "anchor-attribute-access-control/anchor-debug", "anchor-attribute-account/anchor-debug", @@ -25,18 +26,21 @@ anchor-debug = [ ] [dependencies] -anchor-attribute-access-control = { path = "./attribute/access-control", version = "0.27.0" } -anchor-attribute-account = { path = "./attribute/account", version = "0.27.0" } -anchor-attribute-constant = { path = "./attribute/constant", version = "0.27.0" } -anchor-attribute-error = { path = "./attribute/error", version = "0.27.0" } -anchor-attribute-program = { path = "./attribute/program", version = "0.27.0" } -anchor-attribute-event = { path = "./attribute/event", version = "0.27.0" } -anchor-derive-accounts = { path = "./derive/accounts", version = "0.27.0" } -anchor-derive-space = { path = "./derive/space", version = "0.27.0" } -arrayref = "0.3.6" -base64 = "0.13.0" -borsh = "0.9" -bytemuck = "1.4.0" -solana-program = "1.14.16" -thiserror = "1.0.20" -bincode = "1.3.3" +anchor-attribute-access-control = { path = "./attribute/access-control", version = "0.28.0" } +anchor-attribute-account = { path = "./attribute/account", version = "0.28.0" } +anchor-attribute-constant = { path = "./attribute/constant", version = "0.28.0" } +anchor-attribute-error = { path = "./attribute/error", version = "0.28.0" } +anchor-attribute-event = { path = "./attribute/event", version = "0.28.0" } +anchor-attribute-program = { path = "./attribute/program", version = "0.28.0" } +anchor-derive-accounts = { path = "./derive/accounts", version = "0.28.0" } +anchor-derive-space = { path = "./derive/space", version = "0.28.0" } +arrayref = "0.3" +base64 = "0.13" +bincode = "1" +borsh = ">=0.9, <0.11" +bytemuck = "1" +solana-program = ">=1.14, <1.17" +thiserror = "1" + +# TODO: Remove. This crate has been added to fix a build error with the 1.16.0 release. +getrandom = { version = "0.2", features = ["custom"] } diff --git a/lang/attribute/access-control/Cargo.toml b/lang/attribute/access-control/Cargo.toml index 945b24842a..ed7fdca286 100644 --- a/lang/attribute/access-control/Cargo.toml +++ b/lang/attribute/access-control/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "anchor-attribute-access-control" -version = "0.27.0" -authors = ["Serum Foundation "] +version = "0.28.0" +authors = ["Anchor Maintainers "] repository = "https://github.com/coral-xyz/anchor" license = "Apache-2.0" description = "Anchor attribute macro for instruction access control" @@ -15,9 +15,9 @@ proc-macro = true anchor-debug = ["anchor-syn/anchor-debug"] [dependencies] -proc-macro2 = "1.0" -quote = "1.0" -syn = { version = "1.0.60", features = ["full"] } -anyhow = "1.0.32" -anchor-syn = { path = "../../syn", version = "0.27.0" } -regex = "1.0" +anchor-syn = { path = "../../syn", version = "0.28.0" } +anyhow = "1" +proc-macro2 = "1" +quote = "1" +regex = "1" +syn = { version = "1", features = ["full"] } diff --git a/lang/attribute/account/Cargo.toml b/lang/attribute/account/Cargo.toml index 908cd402cd..f64f1172e4 100644 --- a/lang/attribute/account/Cargo.toml +++ b/lang/attribute/account/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "anchor-attribute-account" -version = "0.27.0" -authors = ["Serum Foundation "] +version = "0.28.0" +authors = ["Anchor Maintainers "] repository = "https://github.com/coral-xyz/anchor" license = "Apache-2.0" description = "Anchor attribute macro for defining an account" @@ -15,10 +15,10 @@ proc-macro = true anchor-debug = ["anchor-syn/anchor-debug"] [dependencies] -proc-macro2 = "1.0" -quote = "1.0" -syn = { version = "1.0.60", features = ["full"] } -anyhow = "1.0.32" -anchor-syn = { path = "../../syn", version = "0.27.0", features = ["hash"] } -rustversion = "1.0.3" -bs58 = "0.4.0" \ No newline at end of file +anchor-syn = { path = "../../syn", version = "0.28.0", features = ["hash"] } +anyhow = "1" +bs58 = "0.5" +proc-macro2 = "1" +quote = "1" +rustversion = "1" +syn = { version = "1", features = ["full"] } diff --git a/lang/attribute/constant/Cargo.toml b/lang/attribute/constant/Cargo.toml index c2684470a6..df95b1e9d1 100644 --- a/lang/attribute/constant/Cargo.toml +++ b/lang/attribute/constant/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "anchor-attribute-constant" -version = "0.27.0" -authors = ["Serum Foundation "] +version = "0.28.0" +authors = ["Anchor Maintainers "] repository = "https://github.com/coral-xyz/anchor" license = "Apache-2.0" description = "Anchor attribute macro for creating constant types" @@ -15,6 +15,6 @@ proc-macro = true anchor-debug = ["anchor-syn/anchor-debug"] [dependencies] -proc-macro2 = "1.0" -syn = { version = "1.0.60", features = ["full"] } -anchor-syn = { path = "../../syn", version = "0.27.0" } +anchor-syn = { path = "../../syn", version = "0.28.0" } +proc-macro2 = "1" +syn = { version = "1", features = ["full"] } diff --git a/lang/attribute/error/Cargo.toml b/lang/attribute/error/Cargo.toml index 2822c222f8..2b2eae0e54 100644 --- a/lang/attribute/error/Cargo.toml +++ b/lang/attribute/error/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "anchor-attribute-error" -version = "0.27.0" -authors = ["Serum Foundation "] +version = "0.28.0" +authors = ["Anchor Maintainers "] repository = "https://github.com/coral-xyz/anchor" license = "Apache-2.0" description = "Anchor attribute macro for creating error types" @@ -15,7 +15,7 @@ proc-macro = true anchor-debug = ["anchor-syn/anchor-debug"] [dependencies] -proc-macro2 = "1.0" -quote = "1.0" -syn = { version = "1.0.60", features = ["full"] } -anchor-syn = { path = "../../syn", version = "0.27.0" } +anchor-syn = { path = "../../syn", version = "0.28.0" } +proc-macro2 = "1" +quote = "1" +syn = { version = "1", features = ["full"] } diff --git a/lang/attribute/event/Cargo.toml b/lang/attribute/event/Cargo.toml index 59857fe929..2a117c8569 100644 --- a/lang/attribute/event/Cargo.toml +++ b/lang/attribute/event/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "anchor-attribute-event" -version = "0.27.0" -authors = ["Serum Foundation "] +version = "0.28.0" +authors = ["Anchor Maintainers "] repository = "https://github.com/coral-xyz/anchor" license = "Apache-2.0" description = "Anchor attribute macro for defining an event" @@ -13,10 +13,11 @@ proc-macro = true [features] anchor-debug = ["anchor-syn/anchor-debug"] +event-cpi = ["anchor-syn/event-cpi"] [dependencies] -proc-macro2 = "1.0" -quote = "1.0" -syn = { version = "1.0.60", features = ["full"] } -anyhow = "1.0.32" -anchor-syn = { path = "../../syn", version = "0.27.0", features = ["hash"] } +anchor-syn = { path = "../../syn", version = "0.28.0", features = ["hash"] } +anyhow = "1" +proc-macro2 = "1" +quote = "1" +syn = { version = "1", features = ["full"] } diff --git a/lang/attribute/event/src/lib.rs b/lang/attribute/event/src/lib.rs index 33933bdfda..7301162d3e 100644 --- a/lang/attribute/event/src/lib.rs +++ b/lang/attribute/event/src/lib.rs @@ -1,5 +1,7 @@ extern crate proc_macro; +#[cfg(feature = "event-cpi")] +use anchor_syn::parser::accounts::event_cpi::{add_event_cpi_accounts, EventAuthority}; use quote::quote; use syn::parse_macro_input; @@ -45,6 +47,14 @@ pub fn event( }) } +// EventIndex is a marker macro. It functionally does nothing other than +// allow one to mark fields with the `#[index]` inert attribute, which is +// used to add metadata to IDLs. +#[proc_macro_derive(EventIndex, attributes(index))] +pub fn derive_event(_item: proc_macro::TokenStream) -> proc_macro::TokenStream { + proc_macro::TokenStream::from(quote! {}) +} + /// Logs an event that can be subscribed to by clients. /// Uses the [`sol_log_data`](https://docs.rs/solana-program/latest/solana_program/log/fn.sol_log_data.html) /// syscall which results in the following log: @@ -81,10 +91,127 @@ pub fn emit(input: proc_macro::TokenStream) -> proc_macro::TokenStream { }) } -// EventIndex is a marker macro. It functionally does nothing other than -// allow one to mark fields with the `#[index]` inert attribute, which is -// used to add metadata to IDLs. -#[proc_macro_derive(EventIndex, attributes(index))] -pub fn derive_event(_item: proc_macro::TokenStream) -> proc_macro::TokenStream { - proc_macro::TokenStream::from(quote! {}) +/// Log an event by making a self-CPI that can be subscribed to by clients. +/// +/// This way of logging events is more reliable than [`emit!`](emit!) because RPCs are less likely +/// to truncate CPI information than program logs. +/// +/// Uses a [`invoke_signed`](https://docs.rs/solana-program/latest/solana_program/program/fn.invoke_signed.html) +/// syscall to store the event data in the ledger, which results in the data being stored in the +/// transaction metadata. +/// +/// This method requires the usage of an additional PDA to guarantee that the self-CPI is truly +/// being invoked by the same program. Requiring this PDA to be a signer during `invoke_signed` +/// syscall ensures that the program is the one doing the logging. +/// +/// The necessary accounts are added to the accounts struct via [`#[event_cpi]`](event_cpi) +/// attribute macro. +/// +/// # Example +/// +/// ```ignore +/// use anchor_lang::prelude::*; +/// +/// #[program] +/// pub mod my_program { +/// use super::*; +/// +/// pub fn my_instruction(ctx: Context) -> Result<()> { +/// emit_cpi!(MyEvent { data: 42 }); +/// Ok(()) +/// } +/// } +/// +/// #[event_cpi] +/// #[derive(Accounts)] +/// pub struct MyInstruction {} +/// +/// #[event] +/// pub struct MyEvent { +/// pub data: u64, +/// } +/// ``` +/// +/// **NOTE:** This macro requires `ctx` to be in scope. +/// +/// *Only available with `event-cpi` feature enabled.* +#[cfg(feature = "event-cpi")] +#[proc_macro] +pub fn emit_cpi(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + let event_struct = parse_macro_input!(input as syn::Expr); + + let authority = EventAuthority::get(); + let authority_name = authority.name_token_stream(); + let authority_name_str = authority.name; + let authority_seeds = authority.seeds; + + proc_macro::TokenStream::from(quote! { + { + let authority_info = ctx.accounts.#authority_name.to_account_info(); + let authority_bump = *ctx.bumps.get(#authority_name_str).unwrap(); + + let disc = anchor_lang::event::EVENT_IX_TAG_LE; + let inner_data = anchor_lang::Event::data(&#event_struct); + let ix_data: Vec = disc.into_iter().chain(inner_data.into_iter()).collect(); + + let ix = anchor_lang::solana_program::instruction::Instruction::new_with_bytes( + crate::ID, + &ix_data, + vec![ + anchor_lang::solana_program::instruction::AccountMeta::new_readonly( + *authority_info.key, + true, + ), + ], + ); + anchor_lang::solana_program::program::invoke_signed( + &ix, + &[authority_info], + &[&[#authority_seeds, &[authority_bump]]], + ) + .map_err(anchor_lang::error::Error::from)?; + } + }) +} + +/// An attribute macro to add necessary event CPI accounts to the given accounts struct. +/// +/// Two accounts named `event_authority` and `program` will be appended to the list of accounts. +/// +/// # Example +/// +/// ```ignore +/// #[event_cpi] +/// #[derive(Accounts)] +/// pub struct MyInstruction<'info> { +/// pub signer: Signer<'info>, +/// } +/// ``` +/// +/// The code above will be expanded to: +/// +/// ```ignore +/// #[derive(Accounts)] +/// pub struct MyInstruction<'info> { +/// pub signer: Signer<'info>, +/// /// CHECK: Only the event authority can invoke self-CPI +/// #[account(seeds = [b"__event_authority"], bump)] +/// pub event_authority: AccountInfo<'info>, +/// /// CHECK: Self-CPI will fail if the program is not the current program +/// pub program: AccountInfo<'info>, +/// } +/// ``` +/// +/// See [`emit_cpi!`](emit_cpi!) for a full example. +/// +/// *Only available with `event-cpi` feature enabled.* +#[cfg(feature = "event-cpi")] +#[proc_macro_attribute] +pub fn event_cpi( + _attr: proc_macro::TokenStream, + input: proc_macro::TokenStream, +) -> proc_macro::TokenStream { + let accounts_struct = parse_macro_input!(input as syn::ItemStruct); + let accounts_struct = add_event_cpi_accounts(&accounts_struct).unwrap(); + proc_macro::TokenStream::from(quote! {#accounts_struct}) } diff --git a/lang/attribute/program/Cargo.toml b/lang/attribute/program/Cargo.toml index 85946bc34d..3090b3ab7c 100644 --- a/lang/attribute/program/Cargo.toml +++ b/lang/attribute/program/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "anchor-attribute-program" -version = "0.27.0" -authors = ["Serum Foundation "] +version = "0.28.0" +authors = ["Anchor Maintainers "] repository = "https://github.com/coral-xyz/anchor" license = "Apache-2.0" description = "Anchor attribute macro for defining a program" @@ -15,8 +15,8 @@ proc-macro = true anchor-debug = ["anchor-syn/anchor-debug"] [dependencies] -proc-macro2 = "1.0" -quote = "1.0" -syn = { version = "1.0.60", features = ["full"] } -anyhow = "1.0.32" -anchor-syn = { path = "../../syn", version = "0.27.0" } +anchor-syn = { path = "../../syn", version = "0.28.0" } +anyhow = "1" +proc-macro2 = "1" +quote = "1" +syn = { version = "1", features = ["full"] } diff --git a/lang/derive/accounts/Cargo.toml b/lang/derive/accounts/Cargo.toml index 0a9e67ff54..65a990ec2b 100644 --- a/lang/derive/accounts/Cargo.toml +++ b/lang/derive/accounts/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "anchor-derive-accounts" -version = "0.27.0" -authors = ["Serum Foundation "] +version = "0.28.0" +authors = ["Anchor Maintainers "] repository = "https://github.com/coral-xyz/anchor" license = "Apache-2.0" description = "Anchor Derive macro for accounts" @@ -18,8 +18,8 @@ default = [] anchor-debug = ["anchor-syn/anchor-debug"] [dependencies] -proc-macro2 = "1.0" -quote = "1.0" -syn = { version = "1.0.60", features = ["full"] } -anyhow = "1.0.32" -anchor-syn = { path = "../../syn", version = "0.27.0" } +anyhow = "1" +proc-macro2 = "1" +quote = "1" +syn = { version = "1", features = ["full"] } +anchor-syn = { path = "../../syn", version = "0.28.0" } diff --git a/lang/derive/accounts/src/lib.rs b/lang/derive/accounts/src/lib.rs index 0bec7b7644..390281e920 100644 --- a/lang/derive/accounts/src/lib.rs +++ b/lang/derive/accounts/src/lib.rs @@ -117,7 +117,7 @@ use syn::parse_macro_input; /// The given space number is the size of the account in bytes, so accounts that hold /// a variable number of items such as a Vec should allocate sufficient space for all items that may /// be added to the data structure because account size is fixed. -/// Check out the space reference +/// Check out the space reference /// and the borsh library /// (which anchor uses under the hood for serialization) specification to learn how much /// space different data structures require. diff --git a/lang/derive/space/Cargo.toml b/lang/derive/space/Cargo.toml index 87bd62212e..f5cbb5d1b7 100644 --- a/lang/derive/space/Cargo.toml +++ b/lang/derive/space/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "anchor-derive-space" -version = "0.27.0" -authors = ["Serum Foundation "] +version = "0.28.0" +authors = ["Anchor Maintainers "] repository = "https://github.com/coral-xyz/anchor" license = "Apache-2.0" description = "Anchor Derive macro to automatically calculate the size of a structure or an enum" @@ -12,6 +12,6 @@ edition = "2021" proc-macro = true [dependencies] -proc-macro2 = "1.0" -quote = "1.0" -syn = { version = "1.0", features = ["extra-traits"]} +proc-macro2 = "1" +quote = "1" +syn = { version = "1", features = ["extra-traits"]} diff --git a/lang/derive/space/src/lib.rs b/lang/derive/space/src/lib.rs index 22a3da8e2c..bd045b0c4e 100644 --- a/lang/derive/space/src/lib.rs +++ b/lang/derive/space/src/lib.rs @@ -35,7 +35,7 @@ use syn::{ /// } /// ``` #[proc_macro_derive(InitSpace, attributes(max_len))] -pub fn derive_anchor_deserialize(item: TokenStream) -> TokenStream { +pub fn derive_init_space(item: TokenStream) -> TokenStream { let input = parse_macro_input!(item as DeriveInput); let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); let name = input.ident; diff --git a/lang/src/error.rs b/lang/src/error.rs index b6a8c9cbc3..79e6a21890 100644 --- a/lang/src/error.rs +++ b/lang/src/error.rs @@ -44,6 +44,11 @@ pub enum ErrorCode { #[msg("IDL account must be empty in order to resize, try closing first")] IdlAccountNotEmpty, + // Event instructions + /// 1500 - The program was compiled without `event-cpi` feature + #[msg("The program was compiled without `event-cpi` feature")] + EventInstructionStub = 1500, + // Constraints /// 2000 - A mut constraint was violated #[msg("A mut constraint was violated")] diff --git a/lang/src/event.rs b/lang/src/event.rs new file mode 100644 index 0000000000..99f2abde12 --- /dev/null +++ b/lang/src/event.rs @@ -0,0 +1,3 @@ +// Sha256(anchor:event)[..8] +pub const EVENT_IX_TAG: u64 = 0x1d9acb512ea545e4; +pub const EVENT_IX_TAG_LE: [u8; 8] = EVENT_IX_TAG.to_le_bytes(); diff --git a/lang/src/lib.rs b/lang/src/lib.rs index 0317ea5cdc..1fb1a80918 100644 --- a/lang/src/lib.rs +++ b/lang/src/lib.rs @@ -38,6 +38,8 @@ mod common; pub mod context; pub mod error; #[doc(hidden)] +pub mod event; +#[doc(hidden)] pub mod idl; pub mod system_program; @@ -48,6 +50,8 @@ pub use anchor_attribute_account::{account, declare_id, zero_copy}; pub use anchor_attribute_constant::constant; pub use anchor_attribute_error::*; pub use anchor_attribute_event::{emit, event}; +#[cfg(feature = "event-cpi")] +pub use anchor_attribute_event::{emit_cpi, event_cpi}; pub use anchor_attribute_program::program; pub use anchor_derive_accounts::Accounts; pub use anchor_derive_space::InitSpace; @@ -299,6 +303,8 @@ pub mod prelude { AccountsClose, AccountsExit, AnchorDeserialize, AnchorSerialize, Id, InitSpace, Key, Owner, ProgramData, Result, Space, ToAccountInfo, ToAccountInfos, ToAccountMetas, }; + #[cfg(feature = "event-cpi")] + pub use super::{emit_cpi, event_cpi}; pub use anchor_attribute_error::*; pub use borsh; pub use error::*; diff --git a/lang/syn/Cargo.toml b/lang/syn/Cargo.toml index f1e7b85f0e..e1a8b7b0fd 100644 --- a/lang/syn/Cargo.toml +++ b/lang/syn/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "anchor-syn" -version = "0.27.0" -authors = ["Serum Foundation "] +version = "0.28.0" +authors = ["Anchor Maintainers "] repository = "https://github.com/coral-xyz/anchor" license = "Apache-2.0" description = "Anchor syntax parsing and code generation tools" @@ -16,15 +16,16 @@ hash = [] default = [] anchor-debug = [] seeds = [] +event-cpi = [] [dependencies] -proc-macro2 = { version = "1.0", features=["span-locations"]} -quote = "1.0" -syn = { version = "1.0.60", features = ["full", "extra-traits", "parsing"] } -anyhow = "1.0.32" -heck = "0.3.1" -serde = { version = "1.0.122", features = ["derive"] } -serde_json = "1.0" -sha2 = "0.9.2" -thiserror = "1.0" -bs58 = "0.3.1" +anyhow = "1" +bs58 = "0.5" +heck = "0.3" +proc-macro2 = { version = "1", features=["span-locations"]} +quote = "1" +serde = { version = "1", features = ["derive"] } +serde_json = "1" +sha2 = "0.10" +syn = { version = "1", features = ["full", "extra-traits", "parsing"] } +thiserror = "1" diff --git a/lang/syn/src/codegen/program/dispatch.rs b/lang/syn/src/codegen/program/dispatch.rs index dac9015082..2c6090b887 100644 --- a/lang/syn/src/codegen/program/dispatch.rs +++ b/lang/syn/src/codegen/program/dispatch.rs @@ -27,9 +27,13 @@ pub fn generate(program: &Program) -> proc_macro2::TokenStream { } }) .collect(); + let fallback_fn = gen_fallback(program).unwrap_or(quote! { Err(anchor_lang::error::ErrorCode::InstructionFallbackNotFound.into()) }); + + let event_cpi_handler = generate_event_cpi_handler(); + quote! { /// Performs method dispatch. /// @@ -67,17 +71,24 @@ pub fn generate(program: &Program) -> proc_macro2::TokenStream { #(#global_dispatch_arms)* anchor_lang::idl::IDL_IX_TAG_LE => { // If the method identifier is the IDL tag, then execute an IDL - // instruction, injected into all Anchor programs. - if cfg!(not(feature = "no-idl")) { + // instruction, injected into all Anchor programs unless they have + // no-idl enabled + #[cfg(not(feature = "no-idl"))] + { __private::__idl::__idl_dispatch( program_id, accounts, &ix_data, ) - } else { + } + #[cfg(feature = "no-idl")] + { Err(anchor_lang::error::ErrorCode::IdlInstructionStub.into()) } } + anchor_lang::event::EVENT_IX_TAG_LE => { + #event_cpi_handler + } _ => { #fallback_fn } @@ -96,3 +107,17 @@ pub fn gen_fallback(program: &Program) -> Option { } }) } + +/// Generate the event-cpi instruction handler based on whether the `event-cpi` feature is enabled. +pub fn generate_event_cpi_handler() -> proc_macro2::TokenStream { + #[cfg(feature = "event-cpi")] + quote! { + // `event-cpi` feature is enabled, dispatch self-cpi instruction + __private::__events::__event_dispatch(program_id, accounts, &ix_data) + } + #[cfg(not(feature = "event-cpi"))] + quote! { + // `event-cpi` feature is not enabled + Err(anchor_lang::error::ErrorCode::EventInstructionStub.into()) + } +} diff --git a/lang/syn/src/codegen/program/handlers.rs b/lang/syn/src/codegen/program/handlers.rs index 321f93785d..07ee097b41 100644 --- a/lang/syn/src/codegen/program/handlers.rs +++ b/lang/syn/src/codegen/program/handlers.rs @@ -91,6 +91,8 @@ pub fn generate(program: &Program) -> proc_macro2::TokenStream { } }; + let event_cpi_mod = generate_event_cpi_mod(); + let non_inlined_handlers: Vec = program .ixs .iter() @@ -173,14 +175,14 @@ pub fn generate(program: &Program) -> proc_macro2::TokenStream { #idl_accounts_and_functions } - - /// __global mod defines wrapped handlers for global instructions. pub mod __global { use super::*; #(#non_inlined_handlers)* } + + #event_cpi_mod } } } @@ -189,3 +191,49 @@ fn generate_ix_variant_name(name: String) -> proc_macro2::TokenStream { let n = name.to_camel_case(); n.parse().unwrap() } + +/// Generate the event module based on whether the `event-cpi` feature is enabled. +fn generate_event_cpi_mod() -> proc_macro2::TokenStream { + #[cfg(feature = "event-cpi")] + { + let authority = crate::parser::accounts::event_cpi::EventAuthority::get(); + let authority_name = authority.name; + let authority_seeds = authority.seeds; + + quote! { + /// __events mod defines handler for self-cpi based event logging + pub mod __events { + use super::*; + + #[inline(never)] + pub fn __event_dispatch( + program_id: &Pubkey, + accounts: &[AccountInfo], + event_data: &[u8], + ) -> anchor_lang::Result<()> { + let given_event_authority = next_account_info(&mut accounts.iter())?; + if !given_event_authority.is_signer { + return Err(anchor_lang::error::Error::from( + anchor_lang::error::ErrorCode::ConstraintSigner, + ) + .with_account_name(#authority_name)); + } + + let (expected_event_authority, _) = + Pubkey::find_program_address(&[#authority_seeds], &program_id); + if given_event_authority.key() != expected_event_authority { + return Err(anchor_lang::error::Error::from( + anchor_lang::error::ErrorCode::ConstraintSeeds, + ) + .with_account_name(#authority_name) + .with_pubkeys((given_event_authority.key(), expected_event_authority))); + } + + Ok(()) + } + } + } + } + #[cfg(not(feature = "event-cpi"))] + quote! {} +} diff --git a/lang/syn/src/parser/accounts/event_cpi.rs b/lang/syn/src/parser/accounts/event_cpi.rs new file mode 100644 index 0000000000..fccbd2b3f4 --- /dev/null +++ b/lang/syn/src/parser/accounts/event_cpi.rs @@ -0,0 +1,70 @@ +use quote::quote; + +/// This struct is used to keep the authority account information in sync. +pub struct EventAuthority { + /// Account name of the event authority + pub name: &'static str, + /// Seeds expression of the event authority + pub seeds: proc_macro2::TokenStream, +} + +impl EventAuthority { + /// Returns the account name and the seeds expression of the event authority. + pub fn get() -> Self { + Self { + name: "event_authority", + seeds: quote! {b"__event_authority"}, + } + } + + /// Returns the name without surrounding quotes. + pub fn name_token_stream(&self) -> proc_macro2::TokenStream { + let name_token_stream = syn::parse_str::(self.name).unwrap(); + quote! {#name_token_stream} + } +} + +/// Add necessary event CPI accounts to the given accounts struct. +pub fn add_event_cpi_accounts( + accounts_struct: &syn::ItemStruct, +) -> syn::parse::Result { + let syn::ItemStruct { + attrs, + vis, + struct_token, + ident, + generics, + fields, + .. + } = accounts_struct; + + let fields = fields.into_iter().collect::>(); + + let info_lifetime = generics + .lifetimes() + .next() + .map(|lifetime| quote! {#lifetime}) + .unwrap_or(quote! {'info}); + let generics = generics + .lt_token + .map(|_| quote! {#generics}) + .unwrap_or(quote! {<'info>}); + + let authority = EventAuthority::get(); + let authority_name = authority.name_token_stream(); + let authority_seeds = authority.seeds; + + let accounts_struct = quote! { + #(#attrs)* + #vis #struct_token #ident #generics { + #(#fields,)* + + /// CHECK: Only the event authority can invoke self-CPI + #[account(seeds = [#authority_seeds], bump)] + pub #authority_name: AccountInfo<#info_lifetime>, + /// CHECK: Self-CPI will fail if the program is not the current program + pub program: AccountInfo<#info_lifetime>, + } + }; + syn::parse2(accounts_struct) +} diff --git a/lang/syn/src/parser/accounts/mod.rs b/lang/syn/src/parser/accounts/mod.rs index acee1c80a3..c5a34a78d2 100644 --- a/lang/syn/src/parser/accounts/mod.rs +++ b/lang/syn/src/parser/accounts/mod.rs @@ -1,3 +1,7 @@ +pub mod constraints; +#[cfg(feature = "event-cpi")] +pub mod event_cpi; + use crate::parser::docs; use crate::*; use syn::parse::{Error as ParseError, Result as ParseResult}; @@ -7,10 +11,8 @@ use syn::token::Comma; use syn::Expr; use syn::Path; -pub mod constraints; - -pub fn parse(strct: &syn::ItemStruct) -> ParseResult { - let instruction_api: Option> = strct +pub fn parse(accounts_struct: &syn::ItemStruct) -> ParseResult { + let instruction_api: Option> = accounts_struct .attrs .iter() .find(|a| { @@ -20,7 +22,24 @@ pub fn parse(strct: &syn::ItemStruct) -> ParseResult { }) .map(|ix_attr| ix_attr.parse_args_with(Punctuated::::parse_terminated)) .transpose()?; - let fields = match &strct.fields { + + #[cfg(feature = "event-cpi")] + let accounts_struct = { + let is_event_cpi = accounts_struct + .attrs + .iter() + .filter_map(|attr| attr.path.get_ident()) + .any(|ident| *ident == "event_cpi"); + if is_event_cpi { + event_cpi::add_event_cpi_accounts(accounts_struct)? + } else { + accounts_struct.clone() + } + }; + #[cfg(not(feature = "event-cpi"))] + let accounts_struct = accounts_struct.clone(); + + let fields = match &accounts_struct.fields { syn::Fields::Named(fields) => fields .named .iter() @@ -28,7 +47,7 @@ pub fn parse(strct: &syn::ItemStruct) -> ParseResult { .collect::>>()?, _ => { return Err(ParseError::new_spanned( - &strct.fields, + &accounts_struct.fields, "fields must be named", )) } @@ -36,7 +55,11 @@ pub fn parse(strct: &syn::ItemStruct) -> ParseResult { constraints_cross_checks(&fields)?; - Ok(AccountsStruct::new(strct.clone(), fields, instruction_api)) + Ok(AccountsStruct::new( + accounts_struct, + fields, + instruction_api, + )) } fn constraints_cross_checks(fields: &[AccountField]) -> ParseResult<()> { @@ -126,7 +149,7 @@ fn constraints_cross_checks(fields: &[AccountField]) -> ParseResult<()> { } } - for field in init_fields { + for (pos, field) in init_fields.iter().enumerate() { // Get payer for init-ed account let associated_payer_name = match field.constraints.init.clone().unwrap().payer { // composite payer, check not supported @@ -162,7 +185,7 @@ fn constraints_cross_checks(fields: &[AccountField]) -> ParseResult<()> { )); } } - match kind { + match &field.constraints.init.as_ref().unwrap().kind { // This doesn't catch cases like account.key() or account.key. // My guess is that doesn't happen often and we can revisit // this if I'm wrong. @@ -178,6 +201,24 @@ fn constraints_cross_checks(fields: &[AccountField]) -> ParseResult<()> { )); } } + + // Make sure initialiazed token accounts are always declared after their corresponding mint. + InitKind::Mint { .. } => { + if init_fields.iter().enumerate().any(|(f_pos, f)| { + match &f.constraints.init.as_ref().unwrap().kind { + InitKind::Token { mint, .. } + | InitKind::AssociatedToken { mint, .. } => { + field.ident == mint.to_token_stream().to_string() && pos > f_pos + } + _ => false, + } + }) { + return Err(ParseError::new( + field.ident.span(), + "because of the init constraint, the mint has to be declared before the corresponding token account", + )); + } + } _ => (), } } diff --git a/lang/tests/generics_test.rs b/lang/tests/generics_test.rs index c7b6c8304e..c2039359ad 100644 --- a/lang/tests/generics_test.rs +++ b/lang/tests/generics_test.rs @@ -47,6 +47,10 @@ impl BorshDeserialize for WrappedU8Array { fn deserialize(_buf: &mut &[u8]) -> borsh::maybestd::io::Result { todo!() } + + fn deserialize_reader(_reader: &mut R) -> std::io::Result { + todo!() + } } impl Owner for WrappedU8Array { fn owner() -> Pubkey { diff --git a/spl/Cargo.toml b/spl/Cargo.toml index 3d4b200632..e369848938 100644 --- a/spl/Cargo.toml +++ b/spl/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "anchor-spl" -version = "0.27.0" -authors = ["Serum Foundation "] +version = "0.28.0" +authors = ["Anchor Maintainers "] rust-version = "1.60" edition = "2021" license = "Apache-2.0" @@ -21,16 +21,11 @@ metadata = ["mpl-token-metadata"] dex = ["serum_dex"] [dependencies] -anchor-lang = { path = "../lang", version = "0.27.0", features = ["derive"] } -borsh = { version = "^0.9", optional = true } +anchor-lang = { path = "../lang", version = "0.28.0", features = ["derive"] } +borsh = { version = ">=0.9, <0.11", optional = true } +mpl-token-metadata = { version = "1.11", optional = true, features = ["no-entrypoint"] } serum_dex = { git = "https://github.com/openbook-dex/program/", rev = "1be91f2", version = "0.4.0", features = ["no-entrypoint"], optional = true } -solana-program = "1.14.16" -spl-token = { version = "3.5.0", features = ["no-entrypoint"], optional = true } -spl-token-2022 = { version = "0.5.0", features = ["no-entrypoint"], optional = true } -spl-associated-token-account = { version = "1.1.1", features = ["no-entrypoint"], optional = true } -mpl-token-metadata = { version = "^1.11.0", optional = true, features = ["no-entrypoint"] } - -# TODO: Remove after updating to latest version of platform-tools. -# Latest solana version(1.14.17) as of 2023-05-01 comes with rustc 1.62.0-dev but MSRV for latest -# version of this crate is 1.64.0. See https://github.com/solana-labs/solana/pull/31418 -winnow = "=0.4.1" +solana-program = ">=1.14, <1.17" +spl-associated-token-account = { version = "1", features = ["no-entrypoint"], optional = true } +spl-token = { version = "3.5", features = ["no-entrypoint"], optional = true } +spl-token-2022 = { version = "0.6", features = ["no-entrypoint"], optional = true } diff --git a/spl/src/token_2022.rs b/spl/src/token_2022.rs index cf9133d2a1..9901dd8128 100644 --- a/spl/src/token_2022.rs +++ b/spl/src/token_2022.rs @@ -9,7 +9,7 @@ pub use spl_token_2022; pub use spl_token_2022::ID; #[deprecated( - since = "0.27.0", + since = "0.28.0", note = "please use `transfer_checked` or `transfer_checked_with_fee` instead" )] pub fn transfer<'info>( diff --git a/tests/anchor-cli-account/Anchor.toml b/tests/anchor-cli-account/Anchor.toml index 9f7d566bd6..f2b9acf113 100644 --- a/tests/anchor-cli-account/Anchor.toml +++ b/tests/anchor-cli-account/Anchor.toml @@ -1,9 +1,6 @@ [programs.localnet] account_command = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS" -[registry] -url = "https://anchor.projectserum.com" - [provider] cluster = "localnet" wallet = "~/.config/solana/id.json" diff --git a/tests/anchor-cli-account/package.json b/tests/anchor-cli-account/package.json index e57b7a612c..e79b8cdcd2 100644 --- a/tests/anchor-cli-account/package.json +++ b/tests/anchor-cli-account/package.json @@ -1,6 +1,6 @@ { "name": "anchor-cli-account", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/anchor-cli-account/programs/account-command/Cargo.toml b/tests/anchor-cli-account/programs/account-command/Cargo.toml index db2136edc4..a078db6a90 100644 --- a/tests/anchor-cli-account/programs/account-command/Cargo.toml +++ b/tests/anchor-cli-account/programs/account-command/Cargo.toml @@ -16,4 +16,4 @@ cpi = ["no-entrypoint"] default = [] [dependencies] -anchor-lang = "0.27.0" +anchor-lang = { path = "../../../../lang" } diff --git a/tests/anchor-cli-idl/Anchor.toml b/tests/anchor-cli-idl/Anchor.toml index e6431c8cbc..ffbd65c6dc 100644 --- a/tests/anchor-cli-idl/Anchor.toml +++ b/tests/anchor-cli-idl/Anchor.toml @@ -5,9 +5,6 @@ seeds = false idl_commands_one = "2uA3amp95zsEHUpo8qnLMhcFAUsiKVEcKHXS1JetFjU5" idl_commands_two = "DE4UbHnAcT6Kfh1fVTPRPwpiA3vipmQ4xR3gcLwX3wwS" -[registry] -url = "https://anchor.projectserum.com" - [provider] cluster = "localnet" wallet = "./keypairs/deployer-keypair.json" diff --git a/tests/anchor-cli-idl/package.json b/tests/anchor-cli-idl/package.json index c75d16b8bf..75fe5442a1 100644 --- a/tests/anchor-cli-idl/package.json +++ b/tests/anchor-cli-idl/package.json @@ -1,6 +1,6 @@ { "name": "anchor-cli-idl", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/bench/bench.json b/tests/bench/bench.json index 3efc655c61..75cff928ab 100644 --- a/tests/bench/bench.json +++ b/tests/bench/bench.json @@ -90,90 +90,185 @@ "uncheckedAccount8": 3855 } }, - "unreleased": { + "0.28.0": { "computeUnits": { - "accountEmptyInit1": 6246, - "accountEmpty1": 1090, - "accountEmptyInit2": 11090, - "accountEmpty2": 1852, - "accountEmptyInit4": 20579, - "accountEmpty4": 2646, - "accountEmptyInit8": 39582, + "accountInfo1": 1015, + "accountInfo2": 1475, + "accountInfo4": 1964, + "accountInfo8": 3856, + "accountEmptyInit1": 5817, + "accountEmpty1": 1149, + "accountEmptyInit2": 10402, + "accountEmpty2": 1754, + "accountEmptyInit4": 19557, + "accountEmpty4": 2540, + "accountEmptyInit8": 37541, "accountEmpty8": 5043, - "accountSizedInit1": 6353, - "accountSized1": 1135, - "accountSizedInit2": 11301, - "accountSized2": 1966, - "accountSizedInit4": 21000, + "accountSizedInit1": 5924, + "accountSized1": 1214, + "accountSizedInit2": 10783, + "accountSized2": 1873, + "accountSizedInit4": 19975, "accountSized4": 2787, "accountSizedInit8": 40422, "accountSized8": 5359, - "accountUnsizedInit1": 6482, - "accountUnsized1": 1243, - "accountUnsizedInit2": 11560, - "accountUnsized2": 1893, - "accountUnsizedInit4": 21519, - "accountUnsized4": 3104, - "accountUnsizedInit8": 41461, - "accountUnsized8": 6051, - "boxedAccountEmptyInit1": 6447, - "boxedAccountEmpty1": 976, - "boxedAccountEmptyInit2": 11292, - "boxedAccountEmpty2": 1499, - "boxedAccountEmptyInit4": 20521, - "boxedAccountEmpty4": 2530, - "boxedAccountEmptyInit8": 39456, - "boxedAccountEmpty8": 4780, - "boxedAccountSizedInit1": 6544, - "boxedAccountSized1": 1003, - "boxedAccountSizedInit2": 11485, - "boxedAccountSized2": 1554, - "boxedAccountSizedInit4": 20904, - "boxedAccountSized4": 2642, - "boxedAccountSizedInit8": 40224, - "boxedAccountSized8": 5003, - "boxedAccountUnsizedInit1": 6661, - "boxedAccountUnsized1": 1069, - "boxedAccountUnsizedInit2": 11720, - "boxedAccountUnsized2": 1679, - "boxedAccountUnsizedInit4": 21372, - "boxedAccountUnsized4": 2899, - "boxedAccountUnsizedInit8": 41159, - "boxedAccountUnsized8": 5517, + "accountUnsizedInit1": 6052, + "accountUnsized1": 1338, + "accountUnsizedInit2": 10929, + "accountUnsized2": 1778, + "accountUnsizedInit4": 20495, + "accountUnsized4": 3136, + "accountUnsizedInit8": 39419, + "accountUnsized8": 5952, + "boxedAccountEmptyInit1": 6034, + "boxedAccountEmpty1": 888, + "boxedAccountEmptyInit2": 10633, + "boxedAccountEmpty2": 1401, + "boxedAccountEmptyInit4": 19500, + "boxedAccountEmpty4": 2424, + "boxedAccountEmptyInit8": 37415, + "boxedAccountEmpty8": 4659, + "boxedAccountSizedInit1": 6130, + "boxedAccountSized1": 917, + "boxedAccountSizedInit2": 10828, + "boxedAccountSized2": 1463, + "boxedAccountSizedInit4": 19884, + "boxedAccountSized4": 2543, + "boxedAccountSizedInit8": 38182, + "boxedAccountSized8": 4898, + "boxedAccountUnsizedInit1": 6240, + "boxedAccountUnsized1": 972, + "boxedAccountUnsizedInit2": 11048, + "boxedAccountUnsized2": 1570, + "boxedAccountUnsizedInit4": 20138, + "boxedAccountUnsized4": 2768, + "boxedAccountUnsizedInit8": 39118, + "boxedAccountUnsized8": 5347, "boxedInterfaceAccountMint1": 2299, - "boxedInterfaceAccountMint2": 4053, - "boxedInterfaceAccountMint4": 7538, - "boxedInterfaceAccountMint8": 14699, - "boxedInterfaceAccountToken1": 1737, - "boxedInterfaceAccountToken2": 2928, - "boxedInterfaceAccountToken4": 5291, - "boxedInterfaceAccountToken8": 10205, - "interfaceAccountMint1": 2530, - "interfaceAccountMint2": 4726, - "interfaceAccountMint4": 9431, - "interfaceAccountMint8": 17709, - "interfaceAccountToken1": 1755, - "interfaceAccountToken2": 3211, - "interfaceAccountToken4": 6006, - "interface1": 999, - "interface2": 1574, - "interface4": 1996, + "boxedInterfaceAccountMint2": 4129, + "boxedInterfaceAccountMint4": 7783, + "boxedInterfaceAccountMint8": 15281, + "boxedInterfaceAccountToken1": 2023, + "boxedInterfaceAccountToken2": 3582, + "boxedInterfaceAccountToken4": 6692, + "boxedInterfaceAccountToken8": 13098, + "interfaceAccountMint1": 2364, + "interfaceAccountMint2": 5030, + "interfaceAccountMint4": 9803, + "interfaceAccountMint8": 18400, + "interfaceAccountToken1": 2091, + "interfaceAccountToken2": 3948, + "interfaceAccountToken4": 7547, + "interface1": 1059, + "interface2": 1479, + "interface4": 1900, "interface8": 3651, - "program1": 999, - "program2": 1573, - "program4": 1998, - "program8": 3651, - "signer1": 958, - "signer2": 1576, - "signer4": 2079, + "program1": 1053, + "program2": 1467, + "program4": 1878, + "program8": 3598, + "signer1": 1018, + "signer2": 1484, + "signer4": 1984, "signer8": 3895, - "systemAccount1": 1013, - "systemAccount2": 1686, - "systemAccount4": 2298, + "systemAccount1": 1072, + "systemAccount2": 1590, + "systemAccount4": 2195, "systemAccount8": 4336, - "uncheckedAccount1": 953, - "uncheckedAccount2": 1567, - "uncheckedAccount4": 2060, + "uncheckedAccount1": 1014, + "uncheckedAccount2": 1475, + "uncheckedAccount4": 1965, + "uncheckedAccount8": 3855 + } + }, + "unreleased": { + "computeUnits": { + "accountInfo1": 1015, + "accountInfo2": 1475, + "accountInfo4": 1964, + "accountInfo8": 3856, + "accountEmptyInit1": 5817, + "accountEmpty1": 1149, + "accountEmptyInit2": 10402, + "accountEmpty2": 1754, + "accountEmptyInit4": 19557, + "accountEmpty4": 2540, + "accountEmptyInit8": 37541, + "accountEmpty8": 5043, + "accountSizedInit1": 5924, + "accountSized1": 1214, + "accountSizedInit2": 10783, + "accountSized2": 1873, + "accountSizedInit4": 19975, + "accountSized4": 2787, + "accountSizedInit8": 38381, + "accountSized8": 5359, + "accountUnsizedInit1": 6052, + "accountUnsized1": 1338, + "accountUnsizedInit2": 10929, + "accountUnsized2": 1778, + "accountUnsizedInit4": 20495, + "accountUnsized4": 3136, + "accountUnsizedInit8": 39419, + "accountUnsized8": 5952, + "boxedAccountEmptyInit1": 6034, + "boxedAccountEmpty1": 888, + "boxedAccountEmptyInit2": 10633, + "boxedAccountEmpty2": 1401, + "boxedAccountEmptyInit4": 19500, + "boxedAccountEmpty4": 2424, + "boxedAccountEmptyInit8": 37415, + "boxedAccountEmpty8": 4659, + "boxedAccountSizedInit1": 6130, + "boxedAccountSized1": 917, + "boxedAccountSizedInit2": 10828, + "boxedAccountSized2": 1463, + "boxedAccountSizedInit4": 19884, + "boxedAccountSized4": 2543, + "boxedAccountSizedInit8": 38182, + "boxedAccountSized8": 4898, + "boxedAccountUnsizedInit1": 6240, + "boxedAccountUnsized1": 972, + "boxedAccountUnsizedInit2": 11048, + "boxedAccountUnsized2": 1570, + "boxedAccountUnsizedInit4": 20138, + "boxedAccountUnsized4": 2768, + "boxedAccountUnsizedInit8": 39118, + "boxedAccountUnsized8": 5347, + "boxedInterfaceAccountMint1": 2299, + "boxedInterfaceAccountMint2": 4129, + "boxedInterfaceAccountMint4": 7783, + "boxedInterfaceAccountMint8": 15281, + "boxedInterfaceAccountToken1": 2023, + "boxedInterfaceAccountToken2": 3582, + "boxedInterfaceAccountToken4": 6692, + "boxedInterfaceAccountToken8": 13098, + "interfaceAccountMint1": 2364, + "interfaceAccountMint2": 5030, + "interfaceAccountMint4": 9803, + "interfaceAccountMint8": 18400, + "interfaceAccountToken1": 2091, + "interfaceAccountToken2": 3948, + "interfaceAccountToken4": 7547, + "interface1": 1059, + "interface2": 1479, + "interface4": 1900, + "interface8": 3651, + "program1": 1053, + "program2": 1467, + "program4": 1878, + "program8": 3598, + "signer1": 1018, + "signer2": 1484, + "signer4": 1984, + "signer8": 3895, + "systemAccount1": 1072, + "systemAccount2": 1590, + "systemAccount4": 2195, + "systemAccount8": 4336, + "uncheckedAccount1": 1014, + "uncheckedAccount2": 1475, + "uncheckedAccount4": 1965, "uncheckedAccount8": 3855 } } diff --git a/tests/bench/package.json b/tests/bench/package.json index 1562b32fdf..1aa54d8e6c 100644 --- a/tests/bench/package.json +++ b/tests/bench/package.json @@ -1,6 +1,6 @@ { "name": "bench", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/bench/programs/bench/Cargo.toml b/tests/bench/programs/bench/Cargo.toml index 1d21010acf..d7b162620b 100644 --- a/tests/bench/programs/bench/Cargo.toml +++ b/tests/bench/programs/bench/Cargo.toml @@ -14,8 +14,3 @@ cpi = ["no-entrypoint"] [dependencies] anchor-lang = { path = "../../../../lang" } anchor-spl = { path = "../../../../spl" } - -# TODO: Remove this and store lock files for each version instead. -# Latest solana version(1.14.17) as of 2023-05-01 comes with rustc 1.62.0-dev but MSRV for latest -# version of this crate is 1.64.0. See https://github.com/solana-labs/solana/pull/31418 -winnow = "=0.4.1" diff --git a/tests/bpf-upgradeable-state/Anchor.toml b/tests/bpf-upgradeable-state/Anchor.toml index 84740b9ee9..05c0441427 100644 --- a/tests/bpf-upgradeable-state/Anchor.toml +++ b/tests/bpf-upgradeable-state/Anchor.toml @@ -1,9 +1,6 @@ [programs.localnet] bpf_upgradeable_state = "Cum9tTyj5HwcEiAmhgaS7Bbj4UczCwsucrCkxRECzM4e" -[registry] -url = "https://anchor.projectserum.com" - [provider] cluster = "localnet" wallet = "~/.config/solana/id.json" diff --git a/tests/cashiers-check/package.json b/tests/cashiers-check/package.json index 1f56283e14..41f8c0365a 100644 --- a/tests/cashiers-check/package.json +++ b/tests/cashiers-check/package.json @@ -1,6 +1,6 @@ { "name": "cashiers-check", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/cfo/package.json b/tests/cfo/package.json index 1dd9b105ae..fb0491695d 100644 --- a/tests/cfo/package.json +++ b/tests/cfo/package.json @@ -1,6 +1,6 @@ { "name": "cfo", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/cfo/programs/cfo/src/lib.rs b/tests/cfo/programs/cfo/src/lib.rs index 963987d399..64f1ff8f52 100644 --- a/tests/cfo/programs/cfo/src/lib.rs +++ b/tests/cfo/programs/cfo/src/lib.rs @@ -195,7 +195,7 @@ pub mod cfo { let expiry_ts = 1853942400; // 9/30/2028. let expiry_receiver = *ctx.accounts.officer.to_account_info().key; let locked_kind = { - let start_ts = 1633017600; // 9/30.27.0. + let start_ts = 1633017600; // 9/30.28.0. let end_ts = 1822320000; // 9/30/2027. let period_count = 2191; RewardVendorKind::Locked { diff --git a/tests/chat/package.json b/tests/chat/package.json index d179276e37..d26fe79f92 100644 --- a/tests/chat/package.json +++ b/tests/chat/package.json @@ -1,6 +1,6 @@ { "name": "chat", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/composite/package.json b/tests/composite/package.json index 56a8839caa..c6d6ac2885 100644 --- a/tests/composite/package.json +++ b/tests/composite/package.json @@ -1,6 +1,6 @@ { "name": "composite", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/cpi-returns/Anchor.toml b/tests/cpi-returns/Anchor.toml index 99bb4acbfc..4530f3f072 100644 --- a/tests/cpi-returns/Anchor.toml +++ b/tests/cpi-returns/Anchor.toml @@ -5,9 +5,6 @@ seeds = false callee = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS" caller = "HmbTLCmaGvZhKnn1Zfa1JVnp7vkMV4DYVxPLWBVoN65L" -[registry] -url = "https://anchor.projectserum.com" - [provider] cluster = "localnet" wallet = "~/.config/solana/id.json" diff --git a/tests/cpi-returns/package.json b/tests/cpi-returns/package.json index bf2b7d573f..9da75b9ea9 100644 --- a/tests/cpi-returns/package.json +++ b/tests/cpi-returns/package.json @@ -1,6 +1,6 @@ { "name": "cpi-returns", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/custom-coder/Anchor.toml b/tests/custom-coder/Anchor.toml index 551beb5234..a957b45c6e 100644 --- a/tests/custom-coder/Anchor.toml +++ b/tests/custom-coder/Anchor.toml @@ -3,9 +3,6 @@ native_system = "9NxAd91hhJ3ZBTHytYP894y4ESRKG7n8VbLgdyYGJFLB" spl_associated_token = "4dUGnkre6uBhX1abB4ofkoecGN4aDXdiWSaWLUjVw6bh" spl_token = "FmpfPa1LHEYRbueNMnwNVd2JvyQ89GXGWdyZEXNNKV8w" -[registry] -url = "https://anchor.projectserum.com" - [provider] cluster = "localnet" wallet = "~/.config/solana/id.json" diff --git a/tests/custom-coder/package.json b/tests/custom-coder/package.json index a8d53528f4..35ad0768db 100644 --- a/tests/custom-coder/package.json +++ b/tests/custom-coder/package.json @@ -1,6 +1,6 @@ { "name": "custom-coder", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/declare-id/package.json b/tests/declare-id/package.json index b3563c35da..b5e4542c31 100644 --- a/tests/declare-id/package.json +++ b/tests/declare-id/package.json @@ -1,6 +1,6 @@ { "name": "declare-id", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/docs/package.json b/tests/docs/package.json index 84a393ac8e..306b55d202 100644 --- a/tests/docs/package.json +++ b/tests/docs/package.json @@ -1,6 +1,6 @@ { "name": "errors", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/errors/package.json b/tests/errors/package.json index 84a393ac8e..306b55d202 100644 --- a/tests/errors/package.json +++ b/tests/errors/package.json @@ -1,6 +1,6 @@ { "name": "errors", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/escrow/package.json b/tests/escrow/package.json index 5a3d57f022..649b8f93b2 100644 --- a/tests/escrow/package.json +++ b/tests/escrow/package.json @@ -1,6 +1,6 @@ { "name": "escrow", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/escrow/programs/escrow/Cargo.toml b/tests/escrow/programs/escrow/Cargo.toml index dd6bcf9e0b..1a75dd327c 100644 --- a/tests/escrow/programs/escrow/Cargo.toml +++ b/tests/escrow/programs/escrow/Cargo.toml @@ -18,4 +18,3 @@ default = [] [dependencies] anchor-lang = { path = "../../../../lang" } anchor-spl = { path = "../../../../spl" } -spl-token-2022 = { version = "0.5.0", features = ["no-entrypoint"] } diff --git a/tests/escrow/programs/escrow/src/lib.rs b/tests/escrow/programs/escrow/src/lib.rs index ad769089c9..48ca814d86 100644 --- a/tests/escrow/programs/escrow/src/lib.rs +++ b/tests/escrow/programs/escrow/src/lib.rs @@ -16,10 +16,10 @@ //! - Initializer will get back ownership of their token X account use anchor_lang::prelude::*; -use anchor_spl::token_interface::{ - self, Mint, SetAuthority, TokenAccount, TokenInterface, TransferChecked, +use anchor_spl::{ + token_2022::spl_token_2022::instruction::AuthorityType, + token_interface::{self, Mint, SetAuthority, TokenAccount, TokenInterface, TransferChecked}, }; -use spl_token_2022::instruction::AuthorityType; declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"); diff --git a/tests/events/package.json b/tests/events/package.json index e2a35186c0..8ddc8065e4 100644 --- a/tests/events/package.json +++ b/tests/events/package.json @@ -1,6 +1,6 @@ { "name": "events", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/events/programs/events/Cargo.toml b/tests/events/programs/events/Cargo.toml index ed8601cc57..7b00b1a898 100644 --- a/tests/events/programs/events/Cargo.toml +++ b/tests/events/programs/events/Cargo.toml @@ -16,4 +16,4 @@ cpi = ["no-entrypoint"] default = [] [dependencies] -anchor-lang = { path = "../../../../lang" } +anchor-lang = { path = "../../../../lang", features = ["event-cpi"] } diff --git a/tests/events/programs/events/src/lib.rs b/tests/events/programs/events/src/lib.rs index ef17b7b4e3..ff3f57c0e3 100644 --- a/tests/events/programs/events/src/lib.rs +++ b/tests/events/programs/events/src/lib.rs @@ -23,6 +23,14 @@ pub mod events { }); Ok(()) } + + pub fn test_event_cpi(ctx: Context) -> Result<()> { + emit_cpi!(MyOtherEvent { + data: 7, + label: "cpi".to_string(), + }); + Ok(()) + } } #[derive(Accounts)] @@ -31,6 +39,10 @@ pub struct Initialize {} #[derive(Accounts)] pub struct TestEvent {} +#[event_cpi] +#[derive(Accounts)] +pub struct TestEventCpi {} + #[event] pub struct MyEvent { pub data: u64, diff --git a/tests/events/tests/events.js b/tests/events/tests/events.js index b938e0555c..28a3599f90 100644 --- a/tests/events/tests/events.js +++ b/tests/events/tests/events.js @@ -1,61 +1,117 @@ const anchor = require("@coral-xyz/anchor"); const { assert } = require("chai"); -describe("events", () => { +describe("Events", () => { // Configure the client to use the local cluster. anchor.setProvider(anchor.AnchorProvider.env()); const program = anchor.workspace.Events; - it("Is initialized!", async () => { - let listener = null; + describe("Normal event", () => { + it("Single event works", async () => { + let listener = null; - let [event, slot] = await new Promise((resolve, _reject) => { - listener = program.addEventListener("MyEvent", (event, slot) => { - resolve([event, slot]); + let [event, slot] = await new Promise((resolve, _reject) => { + listener = program.addEventListener("MyEvent", (event, slot) => { + resolve([event, slot]); + }); + program.rpc.initialize(); }); - program.rpc.initialize(); - }); - await program.removeEventListener(listener); + await program.removeEventListener(listener); - assert.isAbove(slot, 0); - assert.strictEqual(event.data.toNumber(), 5); - assert.strictEqual(event.label, "hello"); - }); + assert.isAbove(slot, 0); + assert.strictEqual(event.data.toNumber(), 5); + assert.strictEqual(event.label, "hello"); + }); - it("Multiple events", async () => { - // Sleep so we don't get this transaction has already been processed. - await sleep(2000); + it("Multiple events work", async () => { + let listenerOne = null; + let listenerTwo = null; - let listenerOne = null; - let listenerTwo = null; + let [eventOne, slotOne] = await new Promise((resolve, _reject) => { + listenerOne = program.addEventListener("MyEvent", (event, slot) => { + resolve([event, slot]); + }); + program.rpc.initialize(); + }); - let [eventOne, slotOne] = await new Promise((resolve, _reject) => { - listenerOne = program.addEventListener("MyEvent", (event, slot) => { - resolve([event, slot]); + let [eventTwo, slotTwo] = await new Promise((resolve, _reject) => { + listenerTwo = program.addEventListener( + "MyOtherEvent", + (event, slot) => { + resolve([event, slot]); + } + ); + program.rpc.testEvent(); }); - program.rpc.initialize(); + + await program.removeEventListener(listenerOne); + await program.removeEventListener(listenerTwo); + + assert.isAbove(slotOne, 0); + assert.strictEqual(eventOne.data.toNumber(), 5); + assert.strictEqual(eventOne.label, "hello"); + + assert.isAbove(slotTwo, 0); + assert.strictEqual(eventTwo.data.toNumber(), 6); + assert.strictEqual(eventTwo.label, "bye"); }); + }); - let [eventTwo, slotTwo] = await new Promise((resolve, _reject) => { - listenerTwo = program.addEventListener("MyOtherEvent", (event, slot) => { - resolve([event, slot]); - }); - program.rpc.testEvent(); + describe("Self-CPI event", () => { + it("Works without accounts being specified", async () => { + const tx = await program.methods.testEventCpi().transaction(); + const config = { + commitment: "confirmed", + }; + const txHash = await program.provider.sendAndConfirm(tx, [], config); + const txResult = await program.provider.connection.getTransaction( + txHash, + config + ); + + const ixData = anchor.utils.bytes.bs58.decode( + txResult.meta.innerInstructions[0].instructions[0].data + ); + const eventData = anchor.utils.bytes.base64.encode(ixData.slice(8)); + const event = program.coder.events.decode(eventData); + + assert.strictEqual(event.name, "MyOtherEvent"); + assert.strictEqual(event.data.label, "cpi"); + assert.strictEqual(event.data.data.toNumber(), 7); }); - await program.removeEventListener(listenerOne); - await program.removeEventListener(listenerTwo); + it("Malicious invocation throws", async () => { + const tx = new anchor.web3.Transaction(); + tx.add( + new anchor.web3.TransactionInstruction({ + programId: program.programId, + keys: [ + { + pubkey: anchor.web3.PublicKey.findProgramAddressSync( + [Buffer.from("__event_authority")], + program.programId + )[0], + isSigner: false, + isWritable: false, + }, + { + pubkey: program.programId, + isSigner: false, + isWritable: false, + }, + ], + data: Buffer.from([0xe4, 0x45, 0xa5, 0x2e, 0x51, 0xcb, 0x9a, 0x1d]), + }) + ); - assert.isAbove(slotOne, 0); - assert.strictEqual(eventOne.data.toNumber(), 5); - assert.strictEqual(eventOne.label, "hello"); + try { + await program.provider.sendAndConfirm(tx, []); + } catch (e) { + if (e.logs.some((log) => log.includes("ConstraintSigner"))) return; + console.log(e); + } - assert.isAbove(slotTwo, 0); - assert.strictEqual(eventTwo.data.toNumber(), 6); - assert.strictEqual(eventTwo.label, "bye"); + throw new Error("Was able to invoke the self-CPI instruction"); + }); }); }); - -function sleep(ms) { - return new Promise((resolve) => setTimeout(resolve, ms)); -} diff --git a/tests/floats/Anchor.toml b/tests/floats/Anchor.toml index 7fcee42ab1..8059ac97be 100644 --- a/tests/floats/Anchor.toml +++ b/tests/floats/Anchor.toml @@ -1,9 +1,6 @@ [programs.localnet] floats = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS" -[registry] -url = "https://anchor.projectserum.com" - [provider] cluster = "localnet" wallet = "~/.config/solana/id.json" diff --git a/tests/floats/package.json b/tests/floats/package.json index 2e43c27e20..402d2c5ead 100644 --- a/tests/floats/package.json +++ b/tests/floats/package.json @@ -1,6 +1,6 @@ { "name": "floats", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/ido-pool/package.json b/tests/ido-pool/package.json index cfbe968034..a8854533a7 100644 --- a/tests/ido-pool/package.json +++ b/tests/ido-pool/package.json @@ -1,6 +1,6 @@ { "name": "ido-pool", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/lockup/package.json b/tests/lockup/package.json index 5abe0765a9..3cdab49c20 100644 --- a/tests/lockup/package.json +++ b/tests/lockup/package.json @@ -1,6 +1,6 @@ { "name": "lockup", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/misc/package.json b/tests/misc/package.json index b21d0b88e8..ef25054d3d 100644 --- a/tests/misc/package.json +++ b/tests/misc/package.json @@ -1,6 +1,6 @@ { "name": "misc", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/multiple-suites-run-single/Anchor.toml b/tests/multiple-suites-run-single/Anchor.toml index 7962da68ec..9fd5b1e610 100644 --- a/tests/multiple-suites-run-single/Anchor.toml +++ b/tests/multiple-suites-run-single/Anchor.toml @@ -3,9 +3,6 @@ seeds = false [programs.localnet] multiple_suites_run_single = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS" -[registry] -url = "https://anchor.projectserum.com" - [provider] cluster = "localnet" wallet = "~/.config/solana/id.json" diff --git a/tests/multiple-suites/Anchor.toml b/tests/multiple-suites/Anchor.toml index 0f9c656715..71218d34e2 100644 --- a/tests/multiple-suites/Anchor.toml +++ b/tests/multiple-suites/Anchor.toml @@ -3,9 +3,6 @@ seeds = false [programs.localnet] multiple_suites = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS" -[registry] -url = "https://anchor.projectserum.com" - [provider] cluster = "localnet" wallet = "~/.config/solana/id.json" diff --git a/tests/multiple-suites/package.json b/tests/multiple-suites/package.json index c4e0bd2055..08468de6eb 100644 --- a/tests/multiple-suites/package.json +++ b/tests/multiple-suites/package.json @@ -1,6 +1,6 @@ { "name": "multiple-suites", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/multisig/package.json b/tests/multisig/package.json index 930af15a71..b0e00da77a 100644 --- a/tests/multisig/package.json +++ b/tests/multisig/package.json @@ -1,6 +1,6 @@ { "name": "multisig", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/optional/package.json b/tests/optional/package.json index 64771f1cfd..a42c21a1e8 100644 --- a/tests/optional/package.json +++ b/tests/optional/package.json @@ -1,6 +1,6 @@ { "name": "optional", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/package.json b/tests/package.json index 64befea791..87139e3198 100644 --- a/tests/package.json +++ b/tests/package.json @@ -45,17 +45,11 @@ "bpf-upgradeable-state" ], "dependencies": { - "@coral-xyz/anchor": "file:../ts/packages/anchor", - "@coral-xyz/spl-associated-token-account": "file:../ts/packages/spl-associated-token-account", - "@coral-xyz/spl-token": "file:../ts/packages/spl-token", "@project-serum/common": "^0.0.1-beta.3", "@project-serum/serum": "^0.13.60", "@solana/spl-token": "^0.1.8", "@solana/web3.js": "^1.68.0" }, - "resolutions": { - "@coral-xyz/anchor/@solana/web3.js": "^1.68.0" - }, "devDependencies": { "@types/bn.js": "^5.1.1", "@types/chai": "^4.3.0", diff --git a/tests/pda-derivation/package.json b/tests/pda-derivation/package.json index 579e989a19..3f609237f0 100644 --- a/tests/pda-derivation/package.json +++ b/tests/pda-derivation/package.json @@ -1,6 +1,6 @@ { "name": "pda-derivation", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/pyth/package.json b/tests/pyth/package.json index 784cadfd72..658e560f5c 100644 --- a/tests/pyth/package.json +++ b/tests/pyth/package.json @@ -1,6 +1,6 @@ { "name": "pyth", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/realloc/Anchor.toml b/tests/realloc/Anchor.toml index a9ac74c5b7..0f978f9cd6 100644 --- a/tests/realloc/Anchor.toml +++ b/tests/realloc/Anchor.toml @@ -4,9 +4,6 @@ seeds = false [programs.localnet] realloc = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS" -[registry] -url = "https://anchor.projectserum.com" - [provider] cluster = "localnet" wallet = "~/.config/solana/id.json" diff --git a/tests/realloc/package.json b/tests/realloc/package.json index 64e20159b1..9fb98944c8 100644 --- a/tests/realloc/package.json +++ b/tests/realloc/package.json @@ -1,6 +1,6 @@ { "name": "realloc", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/relations-derivation/package.json b/tests/relations-derivation/package.json index 9f5e389b8b..7387b72b0b 100644 --- a/tests/relations-derivation/package.json +++ b/tests/relations-derivation/package.json @@ -1,6 +1,6 @@ { "name": "relations-derivation", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/safety-checks/Anchor.toml b/tests/safety-checks/Anchor.toml index 3fc545c4bb..66f6426e56 100644 --- a/tests/safety-checks/Anchor.toml +++ b/tests/safety-checks/Anchor.toml @@ -1,9 +1,6 @@ [programs.localnet] unchecked_account = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS" -[registry] -url = "https://anchor.projectserum.com" - [provider] cluster = "localnet" wallet = "~/.config/solana/id.json" diff --git a/tests/spl/token-proxy/package.json b/tests/spl/token-proxy/package.json index d1a1f4c5ad..4701369876 100644 --- a/tests/spl/token-proxy/package.json +++ b/tests/spl/token-proxy/package.json @@ -1,6 +1,6 @@ { "name": "token-proxy", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/spl/token-proxy/programs/token-proxy/Cargo.toml b/tests/spl/token-proxy/programs/token-proxy/Cargo.toml index dbf8f4a201..122355d369 100644 --- a/tests/spl/token-proxy/programs/token-proxy/Cargo.toml +++ b/tests/spl/token-proxy/programs/token-proxy/Cargo.toml @@ -16,4 +16,3 @@ cpi = ["no-entrypoint"] [dependencies] anchor-lang = { path = "../../../../../lang" } anchor-spl = { path = "../../../../../spl" } -spl-token-2022 = { version = "0.5.0", features = ["no-entrypoint"] } diff --git a/tests/spl/token-proxy/programs/token-proxy/src/lib.rs b/tests/spl/token-proxy/programs/token-proxy/src/lib.rs index dd88842c5a..91cf6197d1 100644 --- a/tests/spl/token-proxy/programs/token-proxy/src/lib.rs +++ b/tests/spl/token-proxy/programs/token-proxy/src/lib.rs @@ -1,9 +1,13 @@ //! This example demonstrates the use of the `anchor_spl::token` CPI client. use anchor_lang::prelude::*; -use anchor_spl::associated_token::AssociatedToken; -use anchor_spl::token_interface::{ - self, Burn, Mint, MintTo, SetAuthority, TokenAccount, TokenInterface, Transfer, TransferChecked, +use anchor_spl::{ + associated_token::AssociatedToken, + token_2022::spl_token_2022, + token_interface::{ + self, Burn, Mint, MintTo, SetAuthority, TokenAccount, TokenInterface, Transfer, + TransferChecked, + }, }; declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"); diff --git a/tests/spl/token-wrapper/package.json b/tests/spl/token-wrapper/package.json index f83cd8038f..b6d85be63d 100644 --- a/tests/spl/token-wrapper/package.json +++ b/tests/spl/token-wrapper/package.json @@ -1,6 +1,6 @@ { "name": "token-wrapper", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/spl/token-wrapper/programs/token-wrapper/Cargo.toml b/tests/spl/token-wrapper/programs/token-wrapper/Cargo.toml index 0026c17632..e83d329891 100644 --- a/tests/spl/token-wrapper/programs/token-wrapper/Cargo.toml +++ b/tests/spl/token-wrapper/programs/token-wrapper/Cargo.toml @@ -18,4 +18,3 @@ default = [] [dependencies] anchor-lang = { path = "../../../../../lang" } anchor-spl = { path = "../../../../../spl" } -spl-token-2022 = { version = "0.5.0", features = ["no-entrypoint"] } diff --git a/tests/swap/package.json b/tests/swap/package.json index 565e73cd29..dc81d4d404 100644 --- a/tests/swap/package.json +++ b/tests/swap/package.json @@ -1,6 +1,6 @@ { "name": "swap", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/system-accounts/package.json b/tests/system-accounts/package.json index 8807339651..3f8a0918ff 100644 --- a/tests/system-accounts/package.json +++ b/tests/system-accounts/package.json @@ -1,6 +1,6 @@ { "name": "system-accounts", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/sysvars/package.json b/tests/sysvars/package.json index 522a118da4..0d43bcb2cb 100644 --- a/tests/sysvars/package.json +++ b/tests/sysvars/package.json @@ -1,6 +1,6 @@ { "name": "sysvars", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/tictactoe/package.json b/tests/tictactoe/package.json index 920858231a..bfb5a6c60f 100644 --- a/tests/tictactoe/package.json +++ b/tests/tictactoe/package.json @@ -1,6 +1,6 @@ { "name": "tictactoe", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/typescript/package.json b/tests/typescript/package.json index dc7056a422..15522250c3 100644 --- a/tests/typescript/package.json +++ b/tests/typescript/package.json @@ -1,6 +1,6 @@ { "name": "typescript-example", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/validator-clone/Anchor.toml b/tests/validator-clone/Anchor.toml index deef6b0440..b7906a0280 100644 --- a/tests/validator-clone/Anchor.toml +++ b/tests/validator-clone/Anchor.toml @@ -3,9 +3,6 @@ seeds = false [programs.localnet] validator_clone = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS" -[registry] -url = "https://anchor.projectserum.com" - [provider] cluster = "localnet" wallet = "~/.config/solana/id.json" diff --git a/tests/validator-clone/package.json b/tests/validator-clone/package.json index f339f4e4af..6bf62cb2ad 100644 --- a/tests/validator-clone/package.json +++ b/tests/validator-clone/package.json @@ -1,6 +1,6 @@ { "name": "validator-clone", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/yarn.lock b/tests/yarn.lock index 437dd856ee..b3ddadbe26 100644 --- a/tests/yarn.lock +++ b/tests/yarn.lock @@ -16,53 +16,6 @@ dependencies: regenerator-runtime "^0.13.4" -"@coral-xyz/anchor@=0.27.0", "@coral-xyz/anchor@file:../ts/packages/anchor": - version "0.27.0" - dependencies: - "@coral-xyz/borsh" "^0.27.0" - "@solana/web3.js" "^1.68.0" - base64-js "^1.5.1" - bn.js "^5.1.2" - bs58 "^4.0.1" - buffer-layout "^1.2.2" - camelcase "^6.3.0" - cross-fetch "^3.1.5" - crypto-hash "^1.3.0" - eventemitter3 "^4.0.7" - js-sha256 "^0.9.0" - pako "^2.0.3" - snake-case "^3.0.4" - superstruct "^0.15.4" - toml "^3.0.0" - -"@coral-xyz/borsh@^0.27.0": - version "0.27.0" - resolved "https://registry.yarnpkg.com/@coral-xyz/borsh/-/borsh-0.27.0.tgz#700c647ea5262b1488957ac7fb4e8acf72c72b63" - integrity sha512-tJKzhLukghTWPLy+n8K8iJKgBq1yLT/AxaNd10yJrX8mI56ao5+OFAKAqW/h0i79KCvb4BK0VGO5ECmmolFz9A== - dependencies: - bn.js "^5.1.2" - buffer-layout "^1.2.0" - -"@coral-xyz/spl-associated-token-account@file:../ts/packages/spl-associated-token-account": - version "1.1.1" - dependencies: - "@coral-xyz/anchor" "=0.27.0" - "@native-to-anchor/buffer-layout" "=0.1.0" - -"@coral-xyz/spl-token@file:../ts/packages/spl-token": - version "0.27.0" - dependencies: - "@coral-xyz/anchor" "=0.27.0" - "@native-to-anchor/buffer-layout" "=0.1.0" - -"@native-to-anchor/buffer-layout@=0.1.0": - version "0.1.0" - resolved "https://registry.yarnpkg.com/@native-to-anchor/buffer-layout/-/buffer-layout-0.1.0.tgz#ff0cb66341bc820b8ee73bb1d1d43bae7e3554b0" - integrity sha512-7Ykz9KRAm53XqHj5blDUKPX+OXAPO4GZBW4zJhfHGIAbzmqsUFh9kMqR66Bak3mp6wyv1OVTwSr8ZGHKswPxDg== - dependencies: - "@solana/buffer-layout" "=4.0.0" - "@solana/buffer-layout-utils" "=0.2.0" - "@noble/ed25519@^1.7.0": version "1.7.0" resolved "https://registry.yarnpkg.com/@noble/ed25519/-/ed25519-1.7.0.tgz#583ac38340a479314b9e348d4572101ed9492f9d" @@ -126,17 +79,7 @@ bn.js "^5.1.2" buffer-layout "^1.2.0" -"@solana/buffer-layout-utils@=0.2.0": - version "0.2.0" - resolved "https://registry.yarnpkg.com/@solana/buffer-layout-utils/-/buffer-layout-utils-0.2.0.tgz#b45a6cab3293a2eb7597cceb474f229889d875ca" - integrity sha512-szG4sxgJGktbuZYDg2FfNmkMi0DYQoVjN2h7ta1W1hPrwzarcFLBq9UpX1UjNXsNpT9dn+chgprtWGioUAr4/g== - dependencies: - "@solana/buffer-layout" "^4.0.0" - "@solana/web3.js" "^1.32.0" - bigint-buffer "^1.1.5" - bignumber.js "^9.0.1" - -"@solana/buffer-layout@=4.0.0", "@solana/buffer-layout@^4.0.0": +"@solana/buffer-layout@^4.0.0": version "4.0.0" resolved "https://registry.yarnpkg.com/@solana/buffer-layout/-/buffer-layout-4.0.0.tgz#75b1b11adc487234821c81dfae3119b73a5fd734" integrity sha512-lR0EMP2HC3+Mxwd4YcnZb0smnaDw7Bl2IQWZiTevRH5ZZBZn6VRWn3/92E3qdU4SSImJkA6IDHawOHAnx/qUvQ== @@ -155,7 +98,7 @@ buffer-layout "^1.2.0" dotenv "10.0.0" -"@solana/web3.js@^1.17.0", "@solana/web3.js@^1.21.0", "@solana/web3.js@^1.32.0": +"@solana/web3.js@^1.17.0", "@solana/web3.js@^1.21.0": version "1.64.0" resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.64.0.tgz#b7f5a976976039a0161242e94d6e1224ab5d30f9" integrity sha512-AcFaoy48GxSmzBryVwB88C/UPJd/UQa+nFrO/uPc8ww6RCjanZY2vEZxdfTZub+q1NMUckwXpPwF32jJLe7SPA== @@ -349,11 +292,6 @@ bigint-buffer@^1.1.5: dependencies: bindings "^1.3.0" -bignumber.js@^9.0.1: - version "9.1.0" - resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.0.tgz#8d340146107fe3a6cb8d40699643c302e8773b62" - integrity sha512-4LwHK4nfDOraBCtst+wOWIHbu1vhvAPJK8g8nROd4iuc3PSEjWif/qwbkh8jwCJz6yDBvtU4KPynETgrfh7y3A== - binary-extensions@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" @@ -424,7 +362,7 @@ buffer-from@^1.0.0, buffer-from@^1.1.0: resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== -buffer-layout@^1.2.0, buffer-layout@^1.2.2: +buffer-layout@^1.2.0: version "1.2.2" resolved "https://registry.yarnpkg.com/buffer-layout/-/buffer-layout-1.2.2.tgz#b9814e7c7235783085f9ca4966a0cfff112259d5" integrity sha512-kWSuLN694+KTk8SrYvCqwP2WcgQjoRCiF5b4QDvkkz8EmgD+aWAIceGFKMIAdmF/pH+vpgNV3d3kAKorcdAmWA== @@ -457,7 +395,7 @@ camelcase@^5.3.1: resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== -camelcase@^6.0.0, camelcase@^6.3.0: +camelcase@^6.0.0: version "6.3.0" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== @@ -533,13 +471,6 @@ concat-map@0.0.1: resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== -cross-fetch@^3.1.5: - version "3.1.5" - resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.5.tgz#e1389f44d9e7ba767907f7af8454787952ab534f" - integrity sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw== - dependencies: - node-fetch "2.6.7" - crypto-hash@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/crypto-hash/-/crypto-hash-1.3.0.tgz#b402cb08f4529e9f4f09346c3e275942f845e247" @@ -999,7 +930,7 @@ no-case@^3.0.4: lower-case "^2.0.2" tslib "^2.0.3" -node-fetch@2, node-fetch@2.6.7: +node-fetch@2: version "2.6.7" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== @@ -1176,11 +1107,6 @@ superstruct@^0.14.2: resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-0.14.2.tgz#0dbcdf3d83676588828f1cf5ed35cda02f59025b" integrity sha512-nPewA6m9mR3d6k7WkZ8N8zpTWfenFH3q9pA2PkuiZxINr9DKB2+40wEQf0ixn8VaGuJ78AB6iWOtStI+/4FKZQ== -superstruct@^0.15.4: - version "0.15.5" - resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-0.15.5.tgz#0f0a8d3ce31313f0d84c6096cd4fa1bfdedc9dab" - integrity sha512-4AOeU+P5UuE/4nOUkmcQdW5y7i9ndt1cQd/3iUe+LTz3RxESf/W/5lg4B74HbDMMv8PHnPnGCQFH45kBcrQYoQ== - supports-color@8.1.1: version "8.1.1" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" diff --git a/tests/zero-copy/package.json b/tests/zero-copy/package.json index 9856302aa4..cdbbe92e0b 100644 --- a/tests/zero-copy/package.json +++ b/tests/zero-copy/package.json @@ -1,6 +1,6 @@ { "name": "zero-copy", - "version": "0.27.0", + "version": "0.28.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://github.com/coral-xyz/anchor#readme", "bugs": { diff --git a/tests/zero-copy/programs/zero-copy/Cargo.toml b/tests/zero-copy/programs/zero-copy/Cargo.toml index 9735eae387..d2f2295c4b 100644 --- a/tests/zero-copy/programs/zero-copy/Cargo.toml +++ b/tests/zero-copy/programs/zero-copy/Cargo.toml @@ -21,5 +21,5 @@ anchor-lang = { path = "../../../../lang" } bytemuck = {version = "1.4.0", features = ["derive", "min_const_generics"]} [dev-dependencies] -anchor-client = { path = "../../../../client", features = ["debug"] } -solana-program-test = "1.14.16" +anchor-client = { path = "../../../../client", features = ["debug", "async"] } +solana-program-test = ">=1.14, <1.17" diff --git a/tests/zero-copy/programs/zero-copy/tests/compute_unit_test.rs b/tests/zero-copy/programs/zero-copy/tests/compute_unit_test.rs index deada7d792..5fa1a1d257 100644 --- a/tests/zero-copy/programs/zero-copy/tests/compute_unit_test.rs +++ b/tests/zero-copy/programs/zero-copy/tests/compute_unit_test.rs @@ -46,7 +46,7 @@ async fn update_foo() { Rc::new(Keypair::new()), CommitmentConfig::processed(), ); - let program = client.program(zero_copy::id()); + let program = client.program(zero_copy::id()).unwrap(); let update_ix = program .request() .accounts(zero_copy::accounts::UpdateFoo { diff --git a/tests/zero-copy/rust-toolchain.toml b/tests/zero-copy/rust-toolchain.toml new file mode 100644 index 0000000000..7bd4253328 --- /dev/null +++ b/tests/zero-copy/rust-toolchain.toml @@ -0,0 +1,3 @@ +# TODO: Remove when `cargo-test-sbf` works with stable Rust +[toolchain] +channel = "1.66.1-x86_64-unknown-linux-gnu" diff --git a/ts/packages/anchor/package.json b/ts/packages/anchor/package.json index efe6a380e8..093f2a9466 100644 --- a/ts/packages/anchor/package.json +++ b/ts/packages/anchor/package.json @@ -1,6 +1,6 @@ { "name": "@coral-xyz/anchor", - "version": "0.27.0", + "version": "0.28.0", "description": "Anchor client", "module": "./dist/esm/index.js", "main": "./dist/cjs/index.js", @@ -33,7 +33,7 @@ "test": "jest tests --detectOpenHandles" }, "dependencies": { - "@coral-xyz/borsh": "^0.27.0", + "@coral-xyz/borsh": "^0.28.0", "@solana/web3.js": "^1.68.0", "base64-js": "^1.5.1", "bn.js": "^5.1.2", diff --git a/ts/packages/anchor/src/program/accounts-resolver.ts b/ts/packages/anchor/src/program/accounts-resolver.ts index 3d144f7f1f..42b483e7d2 100644 --- a/ts/packages/anchor/src/program/accounts-resolver.ts +++ b/ts/packages/anchor/src/program/accounts-resolver.ts @@ -88,6 +88,7 @@ export class AccountsResolver { // addresses. That is, one PDA can be used as a seed in another. public async resolve() { await this.resolveConst(this._idlIx.accounts); + this._resolveEventCpi(this._idlIx.accounts); // Auto populate pdas and relations until we stop finding new accounts while ( @@ -225,6 +226,56 @@ export class AccountsResolver { } } + /** + * Resolve event CPI accounts `eventAuthority` and `program`. + * + * Accounts will only be resolved if they are declared next to each other to + * reduce the chance of name collision. + */ + private _resolveEventCpi( + accounts: IdlAccountItem[], + path: string[] = [] + ): void { + for (const i in accounts) { + const accountDescOrAccounts = accounts[i]; + const subAccounts = (accountDescOrAccounts as IdlAccounts).accounts; + if (subAccounts) { + this._resolveEventCpi(subAccounts, [ + ...path, + camelCase(accountDescOrAccounts.name), + ]); + } + + // Validate next index exists + const nextIndex = +i + 1; + if (nextIndex === accounts.length) return; + + const currentName = camelCase(accounts[i].name); + const nextName = camelCase(accounts[nextIndex].name); + + // Populate event CPI accounts if they exist + if (currentName === "eventAuthority" && nextName === "program") { + const currentPath = [...path, currentName]; + const nextPath = [...path, nextName]; + + if (!this.get(currentPath)) { + this.set( + currentPath, + PublicKey.findProgramAddressSync( + [Buffer.from("__event_authority")], + this._programId + )[0] + ); + } + if (!this.get(nextPath)) { + this.set(nextPath, this._programId); + } + + return; + } + } + } + private async resolvePdas( accounts: IdlAccountItem[], path: string[] = [] diff --git a/ts/packages/anchor/src/program/namespace/types.ts b/ts/packages/anchor/src/program/namespace/types.ts index dd8a0ae94a..ecf9e9c304 100644 --- a/ts/packages/anchor/src/program/namespace/types.ts +++ b/ts/packages/anchor/src/program/namespace/types.ts @@ -124,24 +124,20 @@ type TypeMap = { [K in "u64" | "i64" | "u128" | "i128" | "u256" | "i256"]: BN; }; -export type DecodeType = T extends keyof TypeMap +export type DecodeType = IdlType extends T + ? unknown + : T extends keyof TypeMap ? TypeMap[T] : T extends { defined: keyof Defined } ? Defined[T["defined"]] - : T extends { option: { defined: keyof Defined } } - ? Defined[T["option"]["defined"]] | null - : T extends { option: keyof TypeMap } - ? TypeMap[T["option"]] | null - : T extends { coption: { defined: keyof Defined } } - ? Defined[T["coption"]["defined"]] | null - : T extends { coption: keyof TypeMap } - ? TypeMap[T["coption"]] | null - : T extends { vec: keyof TypeMap } - ? TypeMap[T["vec"]][] - : T extends { vec: { defined: keyof Defined } } - ? Defined[T["vec"]["defined"]][] - : T extends { array: [defined: keyof TypeMap, size: number] } - ? TypeMap[T["array"][0]][] + : T extends { option: IdlType } + ? DecodeType | null + : T extends { coption: IdlType } + ? DecodeType | null + : T extends { vec: IdlType } + ? DecodeType[] + : T extends { array: [defined: IdlType, size: number] } + ? DecodeType[] : unknown; /** @@ -196,18 +192,24 @@ declare type DecodeEnumFields< } : Record; -/** - * Since TypeScript do not provide OneOf helper we can - * simply mark enum variants with +? - */ -declare type DecodeEnum = { - // X = IdlEnumVariant - [X in K["variants"][number] as Uncapitalize]+?: DecodeEnumFields< - NonNullable, +type DecodeEnumVariants = { + [V in I["variants"][number] as Uncapitalize]: DecodeEnumFields< + NonNullable, Defined >; }; +type ValueOf = T[keyof T]; +type XorEnumVariants> = ValueOf<{ + [K1 in keyof T]: { + [K2 in Exclude]?: never; + } & { [K2 in K1]: T[K2] }; +}>; + +type DecodeEnum = XorEnumVariants< + DecodeEnumVariants +>; + type DecodeStruct = { [F in I["fields"][number] as F["name"]]: DecodeType; }; diff --git a/ts/packages/anchor/src/utils/rpc.ts b/ts/packages/anchor/src/utils/rpc.ts index b13868c8b2..65ea805707 100644 --- a/ts/packages/anchor/src/utils/rpc.ts +++ b/ts/packages/anchor/src/utils/rpc.ts @@ -195,7 +195,7 @@ export async function simulateTransaction( if ("error" in res) { let logs; if ("data" in res.error) { - logs = res.error.data.logs; + logs = res.error.data?.logs; if (logs && Array.isArray(logs)) { const traceIndent = "\n "; const logTrace = traceIndent + logs.join(traceIndent); diff --git a/ts/packages/borsh/package.json b/ts/packages/borsh/package.json index 5f3e16edd3..4cf7f5d05f 100644 --- a/ts/packages/borsh/package.json +++ b/ts/packages/borsh/package.json @@ -1,6 +1,6 @@ { "name": "@coral-xyz/borsh", - "version": "0.27.0", + "version": "0.28.0", "description": "Anchor Borsh", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/ts/packages/spl-associated-token-account/package.json b/ts/packages/spl-associated-token-account/package.json index f6dab33097..c440115086 100644 --- a/ts/packages/spl-associated-token-account/package.json +++ b/ts/packages/spl-associated-token-account/package.json @@ -27,7 +27,7 @@ "watch": "tsc -p tsconfig.cjs.json --watch" }, "dependencies": { - "@coral-xyz/anchor": "=0.27.0", + "@coral-xyz/anchor": "=0.28.0", "@native-to-anchor/buffer-layout": "=0.1.0" }, "devDependencies": { diff --git a/ts/packages/spl-binary-option/package.json b/ts/packages/spl-binary-option/package.json index c402c9f850..670f05aeeb 100644 --- a/ts/packages/spl-binary-option/package.json +++ b/ts/packages/spl-binary-option/package.json @@ -27,7 +27,7 @@ "watch": "tsc -p tsconfig.cjs.json --watch" }, "dependencies": { - "@coral-xyz/anchor": "=0.27.0", + "@coral-xyz/anchor": "=0.28.0", "@native-to-anchor/buffer-layout": "=0.1.0" }, "devDependencies": { diff --git a/ts/packages/spl-binary-oracle-pair/package.json b/ts/packages/spl-binary-oracle-pair/package.json index 043f4d2f66..6176f30d6f 100644 --- a/ts/packages/spl-binary-oracle-pair/package.json +++ b/ts/packages/spl-binary-oracle-pair/package.json @@ -27,7 +27,7 @@ "watch": "tsc -p tsconfig.cjs.json --watch" }, "dependencies": { - "@coral-xyz/anchor": "=0.27.0", + "@coral-xyz/anchor": "=0.28.0", "@native-to-anchor/buffer-layout": "=0.1.0" }, "devDependencies": { diff --git a/ts/packages/spl-feature-proposal/package.json b/ts/packages/spl-feature-proposal/package.json index 0acadf8b54..1130cdd8aa 100644 --- a/ts/packages/spl-feature-proposal/package.json +++ b/ts/packages/spl-feature-proposal/package.json @@ -27,7 +27,7 @@ "watch": "tsc -p tsconfig.cjs.json --watch" }, "dependencies": { - "@coral-xyz/anchor": "=0.27.0", + "@coral-xyz/anchor": "=0.28.0", "@native-to-anchor/buffer-layout": "=0.1.0" }, "devDependencies": { diff --git a/ts/packages/spl-governance/package.json b/ts/packages/spl-governance/package.json index 816abad737..0d08f319fc 100644 --- a/ts/packages/spl-governance/package.json +++ b/ts/packages/spl-governance/package.json @@ -27,7 +27,7 @@ "watch": "tsc -p tsconfig.cjs.json --watch" }, "dependencies": { - "@coral-xyz/anchor": "=0.27.0", + "@coral-xyz/anchor": "=0.28.0", "@native-to-anchor/buffer-layout": "=0.1.0" }, "devDependencies": { diff --git a/ts/packages/spl-memo/package.json b/ts/packages/spl-memo/package.json index 884e008636..4b6eeaf7d5 100644 --- a/ts/packages/spl-memo/package.json +++ b/ts/packages/spl-memo/package.json @@ -27,7 +27,7 @@ "watch": "tsc -p tsconfig.cjs.json --watch" }, "dependencies": { - "@coral-xyz/anchor": "=0.27.0" + "@coral-xyz/anchor": "=0.28.0" }, "devDependencies": { "@rollup/plugin-commonjs": "=21.0.2", diff --git a/ts/packages/spl-name-service/package.json b/ts/packages/spl-name-service/package.json index 85f6d78b8e..a292af6cb8 100644 --- a/ts/packages/spl-name-service/package.json +++ b/ts/packages/spl-name-service/package.json @@ -27,7 +27,7 @@ "watch": "tsc -p tsconfig.cjs.json --watch" }, "dependencies": { - "@coral-xyz/anchor": "=0.27.0", + "@coral-xyz/anchor": "=0.28.0", "@native-to-anchor/buffer-layout": "=0.1.0" }, "devDependencies": { diff --git a/ts/packages/spl-record/package.json b/ts/packages/spl-record/package.json index 992b2af28e..0857a71196 100644 --- a/ts/packages/spl-record/package.json +++ b/ts/packages/spl-record/package.json @@ -27,7 +27,7 @@ "watch": "tsc -p tsconfig.cjs.json --watch" }, "dependencies": { - "@coral-xyz/anchor": "=0.27.0", + "@coral-xyz/anchor": "=0.28.0", "@native-to-anchor/buffer-layout": "=0.1.0" }, "devDependencies": { diff --git a/ts/packages/spl-stake-pool/package.json b/ts/packages/spl-stake-pool/package.json index 778cb28fb3..b10612a298 100644 --- a/ts/packages/spl-stake-pool/package.json +++ b/ts/packages/spl-stake-pool/package.json @@ -27,7 +27,7 @@ "watch": "tsc -p tsconfig.cjs.json --watch" }, "dependencies": { - "@coral-xyz/anchor": "=0.27.0", + "@coral-xyz/anchor": "=0.28.0", "@native-to-anchor/buffer-layout": "=0.1.0" }, "devDependencies": { diff --git a/ts/packages/spl-stateless-asks/package.json b/ts/packages/spl-stateless-asks/package.json index 65cf26ff4d..05dd5e3bfd 100644 --- a/ts/packages/spl-stateless-asks/package.json +++ b/ts/packages/spl-stateless-asks/package.json @@ -27,7 +27,7 @@ "watch": "tsc -p tsconfig.cjs.json --watch" }, "dependencies": { - "@coral-xyz/anchor": "=0.27.0", + "@coral-xyz/anchor": "=0.28.0", "@native-to-anchor/buffer-layout": "=0.1.0" }, "devDependencies": { diff --git a/ts/packages/spl-token-lending/package.json b/ts/packages/spl-token-lending/package.json index 90e039abe6..a6f20f4c89 100644 --- a/ts/packages/spl-token-lending/package.json +++ b/ts/packages/spl-token-lending/package.json @@ -27,7 +27,7 @@ "watch": "tsc -p tsconfig.cjs.json --watch" }, "dependencies": { - "@coral-xyz/anchor": "=0.27.0", + "@coral-xyz/anchor": "=0.28.0", "@native-to-anchor/buffer-layout": "=0.1.0" }, "devDependencies": { diff --git a/ts/packages/spl-token-swap/package.json b/ts/packages/spl-token-swap/package.json index e419e1b8fb..b27f22a7cd 100644 --- a/ts/packages/spl-token-swap/package.json +++ b/ts/packages/spl-token-swap/package.json @@ -27,7 +27,7 @@ "watch": "tsc -p tsconfig.cjs.json --watch" }, "dependencies": { - "@coral-xyz/anchor": "=0.27.0", + "@coral-xyz/anchor": "=0.28.0", "@native-to-anchor/buffer-layout": "=0.1.0" }, "devDependencies": { diff --git a/ts/packages/spl-token/package.json b/ts/packages/spl-token/package.json index c943aaa810..6a8d362074 100644 --- a/ts/packages/spl-token/package.json +++ b/ts/packages/spl-token/package.json @@ -1,7 +1,7 @@ { "name": "@coral-xyz/spl-token", "description": "Anchor client for Solana Program Library Token", - "version": "0.27.0", + "version": "0.28.0", "author": "acheron ", "license": "Apache-2.0", "repository": { @@ -27,7 +27,7 @@ "watch": "tsc -p tsconfig.cjs.json --watch" }, "dependencies": { - "@coral-xyz/anchor": "=0.27.0", + "@coral-xyz/anchor": "=0.28.0", "@native-to-anchor/buffer-layout": "=0.1.0" }, "devDependencies": { From 4815e0a055d3ffaf22e29f2c57ae2a62538b7837 Mon Sep 17 00:00:00 2001 From: Jean Marchand Date: Sat, 10 Jun 2023 13:54:37 +0200 Subject: [PATCH 09/11] Fix event_cpi --- bench/COMPUTE_UNITS.md | 174 +++++++++++----------- lang/syn/src/parser/accounts/event_cpi.rs | 4 +- tests/bench/bench.json | 152 +++++++++---------- 3 files changed, 161 insertions(+), 169 deletions(-) diff --git a/bench/COMPUTE_UNITS.md b/bench/COMPUTE_UNITS.md index 2aafbf2062..ea53be4455 100644 --- a/bench/COMPUTE_UNITS.md +++ b/bench/COMPUTE_UNITS.md @@ -11,95 +11,91 @@ The programs and their tests are located in [/tests/bench](https://github.com/co ## [Unreleased] -| Instruction | Compute Units | +/- | -| --------------------------- | ------------- | --- | -| accountInfo1 | 1015 | - | -| accountInfo2 | 1475 | - | -| accountInfo4 | 1964 | - | -| accountInfo8 | 3856 | - | -| accountEmptyInit1 | 5817 | - | -| accountEmpty1 | 1149 | - | -| accountEmptyInit2 | 10402 | - | -| accountEmpty2 | 1754 | - | -| accountEmptyInit4 | 19557 | - | -| accountEmpty4 | 2540 | - | -| accountEmptyInit8 | 37541 | - | -| accountEmpty8 | 5043 | - | -| accountSizedInit1 | 5924 | - | -| accountSized1 | 1214 | - | -| accountSizedInit2 | 10783 | - | -| accountSized2 | 1873 | - | -| accountSizedInit4 | 19975 | - | -| accountSized4 | 2787 | - | -| accountSizedInit8 | 38381 | - | -| accountSized8 | 5359 | - | -| accountUnsizedInit1 | 6052 | - | -| accountUnsized1 | 1338 | - | -| accountUnsizedInit2 | 10929 | - | -| accountUnsized2 | 1778 | - | -| accountUnsizedInit4 | 20495 | - | -| accountUnsized4 | 3136 | - | -| accountUnsizedInit8 | 39419 | - | -| accountUnsized8 | 5952 | - | -| boxedAccountEmptyInit1 | 6034 | - | -| boxedAccountEmpty1 | 888 | - | -| boxedAccountEmptyInit2 | 10633 | - | -| boxedAccountEmpty2 | 1401 | - | -| boxedAccountEmptyInit4 | 19500 | - | -| boxedAccountEmpty4 | 2424 | - | -| boxedAccountEmptyInit8 | 37415 | - | -| boxedAccountEmpty8 | 4659 | - | -| boxedAccountSizedInit1 | 6130 | - | -| boxedAccountSized1 | 917 | - | -| boxedAccountSizedInit2 | 10828 | - | -| boxedAccountSized2 | 1463 | - | -| boxedAccountSizedInit4 | 19884 | - | -| boxedAccountSized4 | 2543 | - | -| boxedAccountSizedInit8 | 38182 | - | -| boxedAccountSized8 | 4898 | - | -| boxedAccountUnsizedInit1 | 6240 | - | -| boxedAccountUnsized1 | 972 | - | -| boxedAccountUnsizedInit2 | 11048 | - | -| boxedAccountUnsized2 | 1570 | - | -| boxedAccountUnsizedInit4 | 20138 | - | -| boxedAccountUnsized4 | 2768 | - | -| boxedAccountUnsizedInit8 | 39118 | - | -| boxedAccountUnsized8 | 5347 | - | -| boxedInterfaceAccountMint1 | 2299 | - | -| boxedInterfaceAccountMint2 | 4129 | - | -| boxedInterfaceAccountMint4 | 7783 | - | -| boxedInterfaceAccountMint8 | 15281 | - | -| boxedInterfaceAccountToken1 | 2023 | - | -| boxedInterfaceAccountToken2 | 3582 | - | -| boxedInterfaceAccountToken4 | 6692 | - | -| boxedInterfaceAccountToken8 | 13098 | - | -| interfaceAccountMint1 | 2364 | - | -| interfaceAccountMint2 | 5030 | - | -| interfaceAccountMint4 | 9803 | - | -| interfaceAccountMint8 | 18400 | - | -| interfaceAccountToken1 | 2091 | - | -| interfaceAccountToken2 | 3948 | - | -| interfaceAccountToken4 | 7547 | - | -| interface1 | 1059 | - | -| interface2 | 1479 | - | -| interface4 | 1900 | - | -| interface8 | 3651 | - | -| program1 | 1053 | - | -| program2 | 1467 | - | -| program4 | 1878 | - | -| program8 | 3598 | - | -| signer1 | 1018 | - | -| signer2 | 1484 | - | -| signer4 | 1984 | - | -| signer8 | 3895 | - | -| systemAccount1 | 1072 | - | -| systemAccount2 | 1590 | - | -| systemAccount4 | 2195 | - | -| systemAccount8 | 4336 | - | -| uncheckedAccount1 | 1014 | - | -| uncheckedAccount2 | 1475 | - | -| uncheckedAccount4 | 1965 | - | -| uncheckedAccount8 | 3855 | - | +| Instruction | Compute Units | +/- | +| --------------------------- | ------------- | -------------- | +| accountEmptyInit1 | 6245 | 🔴 **+7.36%** | +| accountEmpty1 | 1090 | 🟢 **-5.13%** | +| accountEmptyInit2 | 11090 | 🔴 **+6.61%** | +| accountEmpty2 | 1850 | 🔴 **+5.47%** | +| accountEmptyInit4 | 20579 | 🔴 **+5.23%** | +| accountEmpty4 | 2645 | 🔴 **+4.13%** | +| accountEmptyInit8 | 39581 | 🔴 **+5.43%** | +| accountEmpty8 | 5043 | - | +| accountSizedInit1 | 6353 | 🔴 **+7.24%** | +| accountSized1 | 1137 | 🟢 **-6.34%** | +| accountSizedInit2 | 11303 | 🔴 **+4.82%** | +| accountSized2 | 1966 | 🔴 **+4.97%** | +| accountSizedInit4 | 21000 | 🔴 **+5.13%** | +| accountSized4 | 2787 | - | +| accountSizedInit8 | 40421 | 🔴 **+5.32%** | +| accountSized8 | 5359 | - | +| accountUnsizedInit1 | 6482 | 🔴 **+7.11%** | +| accountUnsized1 | 1244 | 🟢 **-7.03%** | +| accountUnsizedInit2 | 11560 | 🔴 **+5.77%** | +| accountUnsized2 | 1895 | 🔴 **+6.58%** | +| accountUnsizedInit4 | 21520 | 🔴 **+5.00%** | +| accountUnsized4 | 3136 | - | +| accountUnsizedInit8 | 41460 | 🔴 **+5.18%** | +| accountUnsized8 | 6050 | 🔴 **+1.65%** | +| boxedAccountEmptyInit1 | 6449 | 🔴 **+6.88%** | +| boxedAccountEmpty1 | 976 | 🔴 **+9.91%** | +| boxedAccountEmptyInit2 | 11292 | 🔴 **+6.20%** | +| boxedAccountEmpty2 | 1498 | 🔴 **+6.92%** | +| boxedAccountEmptyInit4 | 20520 | 🔴 **+5.23%** | +| boxedAccountEmpty4 | 2530 | 🔴 **+4.37%** | +| boxedAccountEmptyInit8 | 39456 | 🔴 **+5.46%** | +| boxedAccountEmpty8 | 4779 | 🔴 **+2.58%** | +| boxedAccountSizedInit1 | 6544 | 🔴 **+6.75%** | +| boxedAccountSized1 | 1003 | 🔴 **+9.38%** | +| boxedAccountSizedInit2 | 11485 | 🔴 **+6.07%** | +| boxedAccountSized2 | 1555 | 🔴 **+6.29%** | +| boxedAccountSizedInit4 | 20906 | 🔴 **+5.14%** | +| boxedAccountSized4 | 2641 | 🔴 **+3.85%** | +| boxedAccountSizedInit8 | 40224 | 🔴 **+5.35%** | +| boxedAccountSized8 | 5003 | 🔴 **+2.14%** | +| boxedAccountUnsizedInit1 | 6660 | 🔴 **+6.73%** | +| boxedAccountUnsized1 | 1070 | 🔴 **+10.08%** | +| boxedAccountUnsizedInit2 | 11720 | 🔴 **+6.08%** | +| boxedAccountUnsized2 | 1679 | 🔴 **+6.94%** | +| boxedAccountUnsizedInit4 | 21373 | 🔴 **+6.13%** | +| boxedAccountUnsized4 | 2898 | 🔴 **+4.70%** | +| boxedAccountUnsizedInit8 | 41159 | 🔴 **+5.22%** | +| boxedAccountUnsized8 | 5518 | 🔴 **+3.20%** | +| boxedInterfaceAccountMint1 | 2299 | - | +| boxedInterfaceAccountMint2 | 4051 | 🟢 **-1.89%** | +| boxedInterfaceAccountMint4 | 7538 | 🟢 **-3.15%** | +| boxedInterfaceAccountMint8 | 14699 | 🟢 **-3.81%** | +| boxedInterfaceAccountToken1 | 1738 | 🟢 **-14.09%** | +| boxedInterfaceAccountToken2 | 2927 | 🟢 **-18.29%** | +| boxedInterfaceAccountToken4 | 5291 | 🟢 **-20.94%** | +| boxedInterfaceAccountToken8 | 10204 | 🟢 **-22.09%** | +| interfaceAccountMint1 | 2531 | 🔴 **+7.06%** | +| interfaceAccountMint2 | 4727 | 🟢 **-6.02%** | +| interfaceAccountMint4 | 9430 | 🟢 **-3.80%** | +| interfaceAccountMint8 | 17708 | 🟢 **-3.76%** | +| interfaceAccountToken1 | 1757 | 🟢 **-15.97%** | +| interfaceAccountToken2 | 3210 | 🟢 **-18.69%** | +| interfaceAccountToken4 | 6006 | 🟢 **-20.42%** | +| interface1 | 999 | 🟢 **-5.67%** | +| interface2 | 1573 | 🔴 **+6.36%** | +| interface4 | 1996 | 🔴 **+5.05%** | +| interface8 | 3651 | - | +| program1 | 999 | 🟢 **-5.13%** | +| program2 | 1573 | 🔴 **+7.23%** | +| program4 | 1998 | 🔴 **+6.39%** | +| program8 | 3651 | 🔴 **+1.47%** | +| signer1 | 957 | 🟢 **-5.99%** | +| signer2 | 1577 | 🔴 **+6.27%** | +| signer4 | 2080 | 🔴 **+4.84%** | +| signer8 | 3895 | - | +| systemAccount1 | 1012 | 🟢 **-5.60%** | +| systemAccount2 | 1687 | 🔴 **+6.10%** | +| systemAccount4 | 2297 | 🔴 **+4.65%** | +| systemAccount8 | 4336 | - | +| uncheckedAccount1 | 952 | 🟢 **-6.11%** | +| uncheckedAccount2 | 1566 | 🔴 **+6.17%** | +| uncheckedAccount4 | 2058 | 🔴 **+4.73%** | +| uncheckedAccount8 | 3855 | - | ### Notable changes diff --git a/lang/syn/src/parser/accounts/event_cpi.rs b/lang/syn/src/parser/accounts/event_cpi.rs index fccbd2b3f4..49740bc9d0 100644 --- a/lang/syn/src/parser/accounts/event_cpi.rs +++ b/lang/syn/src/parser/accounts/event_cpi.rs @@ -61,9 +61,9 @@ pub fn add_event_cpi_accounts( /// CHECK: Only the event authority can invoke self-CPI #[account(seeds = [#authority_seeds], bump)] - pub #authority_name: AccountInfo<#info_lifetime>, + pub #authority_name: UncheckedAccount<#info_lifetime>, /// CHECK: Self-CPI will fail if the program is not the current program - pub program: AccountInfo<#info_lifetime>, + pub program: UncheckedAccount<#info_lifetime>, } }; syn::parse2(accounts_struct) diff --git a/tests/bench/bench.json b/tests/bench/bench.json index 3ba211b92c..481b4ce4e6 100644 --- a/tests/bench/bench.json +++ b/tests/bench/bench.json @@ -183,92 +183,88 @@ }, "unreleased": { "computeUnits": { - "accountInfo1": 1015, - "accountInfo2": 1475, - "accountInfo4": 1964, - "accountInfo8": 3856, - "accountEmptyInit1": 5817, - "accountEmpty1": 1149, - "accountEmptyInit2": 10402, - "accountEmpty2": 1754, - "accountEmptyInit4": 19557, - "accountEmpty4": 2540, - "accountEmptyInit8": 37541, + "accountEmptyInit1": 6245, + "accountEmpty1": 1090, + "accountEmptyInit2": 11090, + "accountEmpty2": 1850, + "accountEmptyInit4": 20579, + "accountEmpty4": 2645, + "accountEmptyInit8": 39581, "accountEmpty8": 5043, - "accountSizedInit1": 5924, - "accountSized1": 1214, - "accountSizedInit2": 10783, - "accountSized2": 1873, - "accountSizedInit4": 19975, + "accountSizedInit1": 6353, + "accountSized1": 1137, + "accountSizedInit2": 11303, + "accountSized2": 1966, + "accountSizedInit4": 21000, "accountSized4": 2787, - "accountSizedInit8": 38381, + "accountSizedInit8": 40421, "accountSized8": 5359, - "accountUnsizedInit1": 6052, - "accountUnsized1": 1338, - "accountUnsizedInit2": 10929, - "accountUnsized2": 1778, - "accountUnsizedInit4": 20495, + "accountUnsizedInit1": 6482, + "accountUnsized1": 1244, + "accountUnsizedInit2": 11560, + "accountUnsized2": 1895, + "accountUnsizedInit4": 21520, "accountUnsized4": 3136, - "accountUnsizedInit8": 39419, - "accountUnsized8": 5952, - "boxedAccountEmptyInit1": 6034, - "boxedAccountEmpty1": 888, - "boxedAccountEmptyInit2": 10633, - "boxedAccountEmpty2": 1401, - "boxedAccountEmptyInit4": 19500, - "boxedAccountEmpty4": 2424, - "boxedAccountEmptyInit8": 37415, - "boxedAccountEmpty8": 4659, - "boxedAccountSizedInit1": 6130, - "boxedAccountSized1": 917, - "boxedAccountSizedInit2": 10828, - "boxedAccountSized2": 1463, - "boxedAccountSizedInit4": 19884, - "boxedAccountSized4": 2543, - "boxedAccountSizedInit8": 38182, - "boxedAccountSized8": 4898, - "boxedAccountUnsizedInit1": 6240, - "boxedAccountUnsized1": 972, - "boxedAccountUnsizedInit2": 11048, - "boxedAccountUnsized2": 1570, - "boxedAccountUnsizedInit4": 20138, - "boxedAccountUnsized4": 2768, - "boxedAccountUnsizedInit8": 39118, - "boxedAccountUnsized8": 5347, + "accountUnsizedInit8": 41460, + "accountUnsized8": 6050, + "boxedAccountEmptyInit1": 6449, + "boxedAccountEmpty1": 976, + "boxedAccountEmptyInit2": 11292, + "boxedAccountEmpty2": 1498, + "boxedAccountEmptyInit4": 20520, + "boxedAccountEmpty4": 2530, + "boxedAccountEmptyInit8": 39456, + "boxedAccountEmpty8": 4779, + "boxedAccountSizedInit1": 6544, + "boxedAccountSized1": 1003, + "boxedAccountSizedInit2": 11485, + "boxedAccountSized2": 1555, + "boxedAccountSizedInit4": 20906, + "boxedAccountSized4": 2641, + "boxedAccountSizedInit8": 40224, + "boxedAccountSized8": 5003, + "boxedAccountUnsizedInit1": 6660, + "boxedAccountUnsized1": 1070, + "boxedAccountUnsizedInit2": 11720, + "boxedAccountUnsized2": 1679, + "boxedAccountUnsizedInit4": 21373, + "boxedAccountUnsized4": 2898, + "boxedAccountUnsizedInit8": 41159, + "boxedAccountUnsized8": 5518, "boxedInterfaceAccountMint1": 2299, - "boxedInterfaceAccountMint2": 4129, - "boxedInterfaceAccountMint4": 7783, - "boxedInterfaceAccountMint8": 15281, - "boxedInterfaceAccountToken1": 2023, - "boxedInterfaceAccountToken2": 3582, - "boxedInterfaceAccountToken4": 6692, - "boxedInterfaceAccountToken8": 13098, - "interfaceAccountMint1": 2364, - "interfaceAccountMint2": 5030, - "interfaceAccountMint4": 9803, - "interfaceAccountMint8": 18400, - "interfaceAccountToken1": 2091, - "interfaceAccountToken2": 3948, - "interfaceAccountToken4": 7547, - "interface1": 1059, - "interface2": 1479, - "interface4": 1900, + "boxedInterfaceAccountMint2": 4051, + "boxedInterfaceAccountMint4": 7538, + "boxedInterfaceAccountMint8": 14699, + "boxedInterfaceAccountToken1": 1738, + "boxedInterfaceAccountToken2": 2927, + "boxedInterfaceAccountToken4": 5291, + "boxedInterfaceAccountToken8": 10204, + "interfaceAccountMint1": 2531, + "interfaceAccountMint2": 4727, + "interfaceAccountMint4": 9430, + "interfaceAccountMint8": 17708, + "interfaceAccountToken1": 1757, + "interfaceAccountToken2": 3210, + "interfaceAccountToken4": 6006, + "interface1": 999, + "interface2": 1573, + "interface4": 1996, "interface8": 3651, - "program1": 1053, - "program2": 1467, - "program4": 1878, - "program8": 3598, - "signer1": 1018, - "signer2": 1484, - "signer4": 1984, + "program1": 999, + "program2": 1573, + "program4": 1998, + "program8": 3651, + "signer1": 957, + "signer2": 1577, + "signer4": 2080, "signer8": 3895, - "systemAccount1": 1072, - "systemAccount2": 1590, - "systemAccount4": 2195, + "systemAccount1": 1012, + "systemAccount2": 1687, + "systemAccount4": 2297, "systemAccount8": 4336, - "uncheckedAccount1": 1014, - "uncheckedAccount2": 1475, - "uncheckedAccount4": 1965, + "uncheckedAccount1": 952, + "uncheckedAccount2": 1566, + "uncheckedAccount4": 2058, "uncheckedAccount8": 3855 } } From 4eb602e2fd5759b17ce1b9373ab7671ab75e4ff3 Mon Sep 17 00:00:00 2001 From: Jean Marchand Date: Sat, 10 Jun 2023 14:49:45 +0200 Subject: [PATCH 10/11] Update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d767462ad7..de7a375d21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ The minor version will be incremented upon a breaking change and the patch versi ### Breaking +- lang: Remove the use of `AccountInfo` in the context of the accounts. Use `UncheckedAccount` instead ([#2470](https://github.com/coral-xyz/anchor/pull/2470)). + ## [0.28.0] - 2023-06-09 ### Features @@ -43,7 +45,6 @@ The minor version will be incremented upon a breaking change and the patch versi ### Breaking -- lang: Remove the use of `AccountInfo` in the context of the accounts. Use `UncheckedAccount` instead ([#2470](https://github.com/coral-xyz/anchor/pull/2470)). - lang: Identifiers that are intended for internal usage(`program_id`, `accounts`, `ix_data`, `remaining_accounts`) have been renamed with `__` prefix ([#2464](https://github.com/coral-xyz/anchor/pull/2464)) - spl: Remove the `metadata::create_metadata_account_v2` deprecated wrapper since it was removed from token metadata program ([#2480](https://github.com/coral-xyz/anchor/pull/2480)) From 035e74652e0e22f5cd726a0babf681f428fda2c2 Mon Sep 17 00:00:00 2001 From: Jean Marchand Date: Fri, 16 Jun 2023 13:33:20 +0200 Subject: [PATCH 11/11] Update bench --- bench/COMPUTE_UNITS.md | 170 ++++++++++++++++++++--------------------- tests/bench/bench.json | 128 +++++++++++++++---------------- 2 files changed, 149 insertions(+), 149 deletions(-) diff --git a/bench/COMPUTE_UNITS.md b/bench/COMPUTE_UNITS.md index ea53be4455..775a8d3186 100644 --- a/bench/COMPUTE_UNITS.md +++ b/bench/COMPUTE_UNITS.md @@ -11,91 +11,91 @@ The programs and their tests are located in [/tests/bench](https://github.com/co ## [Unreleased] -| Instruction | Compute Units | +/- | -| --------------------------- | ------------- | -------------- | -| accountEmptyInit1 | 6245 | 🔴 **+7.36%** | -| accountEmpty1 | 1090 | 🟢 **-5.13%** | -| accountEmptyInit2 | 11090 | 🔴 **+6.61%** | -| accountEmpty2 | 1850 | 🔴 **+5.47%** | -| accountEmptyInit4 | 20579 | 🔴 **+5.23%** | -| accountEmpty4 | 2645 | 🔴 **+4.13%** | -| accountEmptyInit8 | 39581 | 🔴 **+5.43%** | -| accountEmpty8 | 5043 | - | -| accountSizedInit1 | 6353 | 🔴 **+7.24%** | -| accountSized1 | 1137 | 🟢 **-6.34%** | -| accountSizedInit2 | 11303 | 🔴 **+4.82%** | -| accountSized2 | 1966 | 🔴 **+4.97%** | -| accountSizedInit4 | 21000 | 🔴 **+5.13%** | -| accountSized4 | 2787 | - | -| accountSizedInit8 | 40421 | 🔴 **+5.32%** | -| accountSized8 | 5359 | - | -| accountUnsizedInit1 | 6482 | 🔴 **+7.11%** | -| accountUnsized1 | 1244 | 🟢 **-7.03%** | -| accountUnsizedInit2 | 11560 | 🔴 **+5.77%** | -| accountUnsized2 | 1895 | 🔴 **+6.58%** | -| accountUnsizedInit4 | 21520 | 🔴 **+5.00%** | -| accountUnsized4 | 3136 | - | -| accountUnsizedInit8 | 41460 | 🔴 **+5.18%** | -| accountUnsized8 | 6050 | 🔴 **+1.65%** | -| boxedAccountEmptyInit1 | 6449 | 🔴 **+6.88%** | -| boxedAccountEmpty1 | 976 | 🔴 **+9.91%** | -| boxedAccountEmptyInit2 | 11292 | 🔴 **+6.20%** | -| boxedAccountEmpty2 | 1498 | 🔴 **+6.92%** | -| boxedAccountEmptyInit4 | 20520 | 🔴 **+5.23%** | -| boxedAccountEmpty4 | 2530 | 🔴 **+4.37%** | -| boxedAccountEmptyInit8 | 39456 | 🔴 **+5.46%** | -| boxedAccountEmpty8 | 4779 | 🔴 **+2.58%** | -| boxedAccountSizedInit1 | 6544 | 🔴 **+6.75%** | -| boxedAccountSized1 | 1003 | 🔴 **+9.38%** | -| boxedAccountSizedInit2 | 11485 | 🔴 **+6.07%** | -| boxedAccountSized2 | 1555 | 🔴 **+6.29%** | -| boxedAccountSizedInit4 | 20906 | 🔴 **+5.14%** | -| boxedAccountSized4 | 2641 | 🔴 **+3.85%** | -| boxedAccountSizedInit8 | 40224 | 🔴 **+5.35%** | -| boxedAccountSized8 | 5003 | 🔴 **+2.14%** | -| boxedAccountUnsizedInit1 | 6660 | 🔴 **+6.73%** | -| boxedAccountUnsized1 | 1070 | 🔴 **+10.08%** | -| boxedAccountUnsizedInit2 | 11720 | 🔴 **+6.08%** | -| boxedAccountUnsized2 | 1679 | 🔴 **+6.94%** | -| boxedAccountUnsizedInit4 | 21373 | 🔴 **+6.13%** | -| boxedAccountUnsized4 | 2898 | 🔴 **+4.70%** | -| boxedAccountUnsizedInit8 | 41159 | 🔴 **+5.22%** | -| boxedAccountUnsized8 | 5518 | 🔴 **+3.20%** | -| boxedInterfaceAccountMint1 | 2299 | - | -| boxedInterfaceAccountMint2 | 4051 | 🟢 **-1.89%** | -| boxedInterfaceAccountMint4 | 7538 | 🟢 **-3.15%** | -| boxedInterfaceAccountMint8 | 14699 | 🟢 **-3.81%** | -| boxedInterfaceAccountToken1 | 1738 | 🟢 **-14.09%** | -| boxedInterfaceAccountToken2 | 2927 | 🟢 **-18.29%** | -| boxedInterfaceAccountToken4 | 5291 | 🟢 **-20.94%** | -| boxedInterfaceAccountToken8 | 10204 | 🟢 **-22.09%** | -| interfaceAccountMint1 | 2531 | 🔴 **+7.06%** | -| interfaceAccountMint2 | 4727 | 🟢 **-6.02%** | -| interfaceAccountMint4 | 9430 | 🟢 **-3.80%** | -| interfaceAccountMint8 | 17708 | 🟢 **-3.76%** | -| interfaceAccountToken1 | 1757 | 🟢 **-15.97%** | -| interfaceAccountToken2 | 3210 | 🟢 **-18.69%** | -| interfaceAccountToken4 | 6006 | 🟢 **-20.42%** | -| interface1 | 999 | 🟢 **-5.67%** | -| interface2 | 1573 | 🔴 **+6.36%** | -| interface4 | 1996 | 🔴 **+5.05%** | -| interface8 | 3651 | - | -| program1 | 999 | 🟢 **-5.13%** | -| program2 | 1573 | 🔴 **+7.23%** | -| program4 | 1998 | 🔴 **+6.39%** | -| program8 | 3651 | 🔴 **+1.47%** | -| signer1 | 957 | 🟢 **-5.99%** | -| signer2 | 1577 | 🔴 **+6.27%** | -| signer4 | 2080 | 🔴 **+4.84%** | -| signer8 | 3895 | - | -| systemAccount1 | 1012 | 🟢 **-5.60%** | -| systemAccount2 | 1687 | 🔴 **+6.10%** | -| systemAccount4 | 2297 | 🔴 **+4.65%** | -| systemAccount8 | 4336 | - | -| uncheckedAccount1 | 952 | 🟢 **-6.11%** | -| uncheckedAccount2 | 1566 | 🔴 **+6.17%** | -| uncheckedAccount4 | 2058 | 🔴 **+4.73%** | -| uncheckedAccount8 | 3855 | - | +| Instruction | Compute Units | +/- | +| --------------------------- | ------------- | ------------- | +| accountEmptyInit1 | 6099 | 🔴 **+4.85%** | +| accountEmpty1 | 1149 | - | +| accountEmptyInit2 | 10904 | 🔴 **+4.83%** | +| accountEmpty2 | 1752 | - | +| accountEmptyInit4 | 20579 | 🔴 **+5.23%** | +| accountEmpty4 | 2539 | - | +| accountEmptyInit8 | 39581 | 🔴 **+5.43%** | +| accountEmpty8 | 5043 | - | +| accountSizedInit1 | 6209 | 🔴 **+4.81%** | +| accountSized1 | 1216 | - | +| accountSizedInit2 | 11183 | 🔴 **+3.71%** | +| accountSized2 | 1873 | - | +| accountSizedInit4 | 21000 | 🔴 **+5.13%** | +| accountSized4 | 2787 | - | +| accountSizedInit8 | 40421 | 🔴 **+5.32%** | +| accountSized8 | 5359 | - | +| accountUnsizedInit1 | 6337 | 🔴 **+4.71%** | +| accountUnsized1 | 1339 | - | +| accountUnsizedInit2 | 11432 | 🔴 **+4.60%** | +| accountUnsized2 | 1780 | - | +| accountUnsizedInit4 | 21520 | 🔴 **+5.00%** | +| accountUnsized4 | 3136 | - | +| accountUnsizedInit8 | 41460 | 🔴 **+5.18%** | +| accountUnsized8 | 5951 | - | +| boxedAccountEmptyInit1 | 6316 | 🔴 **+4.67%** | +| boxedAccountEmpty1 | 888 | - | +| boxedAccountEmptyInit2 | 11130 | 🔴 **+4.67%** | +| boxedAccountEmpty2 | 1401 | - | +| boxedAccountEmptyInit4 | 20307 | 🔴 **+4.14%** | +| boxedAccountEmpty4 | 2424 | - | +| boxedAccountEmptyInit8 | 39456 | 🔴 **+5.46%** | +| boxedAccountEmpty8 | 4658 | - | +| boxedAccountSizedInit1 | 6413 | 🔴 **+4.62%** | +| boxedAccountSized1 | 917 | - | +| boxedAccountSizedInit2 | 11327 | 🔴 **+4.61%** | +| boxedAccountSized2 | 1462 | - | +| boxedAccountSizedInit4 | 20906 | 🔴 **+5.14%** | +| boxedAccountSized4 | 2543 | - | +| boxedAccountSizedInit8 | 40224 | 🔴 **+5.35%** | +| boxedAccountSized8 | 4898 | - | +| boxedAccountUnsizedInit1 | 6521 | 🔴 **+4.50%** | +| boxedAccountUnsized1 | 973 | - | +| boxedAccountUnsizedInit2 | 11546 | 🔴 **+4.51%** | +| boxedAccountUnsized2 | 1570 | - | +| boxedAccountUnsizedInit4 | 21136 | 🔴 **+4.96%** | +| boxedAccountUnsized4 | 2767 | - | +| boxedAccountUnsizedInit8 | 41159 | 🔴 **+5.22%** | +| boxedAccountUnsized8 | 5348 | - | +| boxedInterfaceAccountMint1 | 2299 | - | +| boxedInterfaceAccountMint2 | 4127 | - | +| boxedInterfaceAccountMint4 | 7783 | - | +| boxedInterfaceAccountMint8 | 15281 | - | +| boxedInterfaceAccountToken1 | 2024 | - | +| boxedInterfaceAccountToken2 | 3581 | - | +| boxedInterfaceAccountToken4 | 6692 | - | +| boxedInterfaceAccountToken8 | 13098 | - | +| interfaceAccountMint1 | 2365 | - | +| interfaceAccountMint2 | 5031 | - | +| interfaceAccountMint4 | 9802 | - | +| interfaceAccountMint8 | 18399 | - | +| interfaceAccountToken1 | 2093 | - | +| interfaceAccountToken2 | 3947 | - | +| interfaceAccountToken4 | 7547 | - | +| interface1 | 1059 | - | +| interface2 | 1479 | - | +| interface4 | 1900 | - | +| interface8 | 3651 | - | +| program1 | 1053 | - | +| program2 | 1467 | - | +| program4 | 1878 | - | +| program8 | 3598 | - | +| signer1 | 1018 | - | +| signer2 | 1485 | - | +| signer4 | 1985 | - | +| signer8 | 3895 | - | +| systemAccount1 | 1071 | - | +| systemAccount2 | 1591 | - | +| systemAccount4 | 2194 | - | +| systemAccount8 | 4336 | - | +| uncheckedAccount1 | 1013 | - | +| uncheckedAccount2 | 1474 | - | +| uncheckedAccount4 | 1963 | - | +| uncheckedAccount8 | 3855 | - | ### Notable changes diff --git a/tests/bench/bench.json b/tests/bench/bench.json index 481b4ce4e6..4cb3b65825 100644 --- a/tests/bench/bench.json +++ b/tests/bench/bench.json @@ -183,88 +183,88 @@ }, "unreleased": { "computeUnits": { - "accountEmptyInit1": 6245, - "accountEmpty1": 1090, - "accountEmptyInit2": 11090, - "accountEmpty2": 1850, + "accountEmptyInit1": 6099, + "accountEmpty1": 1149, + "accountEmptyInit2": 10904, + "accountEmpty2": 1752, "accountEmptyInit4": 20579, - "accountEmpty4": 2645, + "accountEmpty4": 2539, "accountEmptyInit8": 39581, "accountEmpty8": 5043, - "accountSizedInit1": 6353, - "accountSized1": 1137, - "accountSizedInit2": 11303, - "accountSized2": 1966, + "accountSizedInit1": 6209, + "accountSized1": 1216, + "accountSizedInit2": 11183, + "accountSized2": 1873, "accountSizedInit4": 21000, "accountSized4": 2787, "accountSizedInit8": 40421, "accountSized8": 5359, - "accountUnsizedInit1": 6482, - "accountUnsized1": 1244, - "accountUnsizedInit2": 11560, - "accountUnsized2": 1895, + "accountUnsizedInit1": 6337, + "accountUnsized1": 1339, + "accountUnsizedInit2": 11432, + "accountUnsized2": 1780, "accountUnsizedInit4": 21520, "accountUnsized4": 3136, "accountUnsizedInit8": 41460, - "accountUnsized8": 6050, - "boxedAccountEmptyInit1": 6449, - "boxedAccountEmpty1": 976, - "boxedAccountEmptyInit2": 11292, - "boxedAccountEmpty2": 1498, - "boxedAccountEmptyInit4": 20520, - "boxedAccountEmpty4": 2530, + "accountUnsized8": 5951, + "boxedAccountEmptyInit1": 6316, + "boxedAccountEmpty1": 888, + "boxedAccountEmptyInit2": 11130, + "boxedAccountEmpty2": 1401, + "boxedAccountEmptyInit4": 20307, + "boxedAccountEmpty4": 2424, "boxedAccountEmptyInit8": 39456, - "boxedAccountEmpty8": 4779, - "boxedAccountSizedInit1": 6544, - "boxedAccountSized1": 1003, - "boxedAccountSizedInit2": 11485, - "boxedAccountSized2": 1555, + "boxedAccountEmpty8": 4658, + "boxedAccountSizedInit1": 6413, + "boxedAccountSized1": 917, + "boxedAccountSizedInit2": 11327, + "boxedAccountSized2": 1462, "boxedAccountSizedInit4": 20906, - "boxedAccountSized4": 2641, + "boxedAccountSized4": 2543, "boxedAccountSizedInit8": 40224, - "boxedAccountSized8": 5003, - "boxedAccountUnsizedInit1": 6660, - "boxedAccountUnsized1": 1070, - "boxedAccountUnsizedInit2": 11720, - "boxedAccountUnsized2": 1679, - "boxedAccountUnsizedInit4": 21373, - "boxedAccountUnsized4": 2898, + "boxedAccountSized8": 4898, + "boxedAccountUnsizedInit1": 6521, + "boxedAccountUnsized1": 973, + "boxedAccountUnsizedInit2": 11546, + "boxedAccountUnsized2": 1570, + "boxedAccountUnsizedInit4": 21136, + "boxedAccountUnsized4": 2767, "boxedAccountUnsizedInit8": 41159, - "boxedAccountUnsized8": 5518, + "boxedAccountUnsized8": 5348, "boxedInterfaceAccountMint1": 2299, - "boxedInterfaceAccountMint2": 4051, - "boxedInterfaceAccountMint4": 7538, - "boxedInterfaceAccountMint8": 14699, - "boxedInterfaceAccountToken1": 1738, - "boxedInterfaceAccountToken2": 2927, - "boxedInterfaceAccountToken4": 5291, - "boxedInterfaceAccountToken8": 10204, - "interfaceAccountMint1": 2531, - "interfaceAccountMint2": 4727, - "interfaceAccountMint4": 9430, - "interfaceAccountMint8": 17708, - "interfaceAccountToken1": 1757, - "interfaceAccountToken2": 3210, - "interfaceAccountToken4": 6006, - "interface1": 999, - "interface2": 1573, - "interface4": 1996, + "boxedInterfaceAccountMint2": 4127, + "boxedInterfaceAccountMint4": 7783, + "boxedInterfaceAccountMint8": 15281, + "boxedInterfaceAccountToken1": 2024, + "boxedInterfaceAccountToken2": 3581, + "boxedInterfaceAccountToken4": 6692, + "boxedInterfaceAccountToken8": 13098, + "interfaceAccountMint1": 2365, + "interfaceAccountMint2": 5031, + "interfaceAccountMint4": 9802, + "interfaceAccountMint8": 18399, + "interfaceAccountToken1": 2093, + "interfaceAccountToken2": 3947, + "interfaceAccountToken4": 7547, + "interface1": 1059, + "interface2": 1479, + "interface4": 1900, "interface8": 3651, - "program1": 999, - "program2": 1573, - "program4": 1998, - "program8": 3651, - "signer1": 957, - "signer2": 1577, - "signer4": 2080, + "program1": 1053, + "program2": 1467, + "program4": 1878, + "program8": 3598, + "signer1": 1018, + "signer2": 1485, + "signer4": 1985, "signer8": 3895, - "systemAccount1": 1012, - "systemAccount2": 1687, - "systemAccount4": 2297, + "systemAccount1": 1071, + "systemAccount2": 1591, + "systemAccount4": 2194, "systemAccount8": 4336, - "uncheckedAccount1": 952, - "uncheckedAccount2": 1566, - "uncheckedAccount4": 2058, + "uncheckedAccount1": 1013, + "uncheckedAccount2": 1474, + "uncheckedAccount4": 1963, "uncheckedAccount8": 3855 } }