Skip to content

Commit

Permalink
spl: Remove solana-program dependency (#2900)
Browse files Browse the repository at this point in the history
  • Loading branch information
acheroncrypto authored Apr 11, 2024
1 parent e3ced78 commit 1f0bf0e
Show file tree
Hide file tree
Showing 28 changed files with 137 additions and 130 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The minor version will be incremented upon a breaking change and the patch versi
- idl: Add `docs` field for constants ([#2887](https://github.com/coral-xyz/anchor/pull/2887)).
- idl: Store deployment addresses for other clusters ([#2892](https://github.com/coral-xyz/anchor/pull/2892)).
- lang: Add `Event` utility type to get events from bytes ([#2897](https://github.com/coral-xyz/anchor/pull/2897)).
- spl: Add support for [token extensions](https://solana.com/solutions/token-extensions) ([#2789](https://github.com/coral-xyz/anchor/pull/2789)).
- lang, spl: Add support for [token extensions](https://solana.com/solutions/token-extensions) ([#2789](https://github.com/coral-xyz/anchor/pull/2789)).

### Fixes

Expand All @@ -70,6 +70,7 @@ The minor version will be incremented upon a breaking change and the patch versi
- client: Fix `parse_logs_response` to prevent panics when more than 1 outer instruction exists in logs ([#2856](https://github.com/coral-xyz/anchor/pull/2856)).
- avm, cli: Fix `stdsimd` feature compilation error from `ahash` when installing the CLI using newer Rust versions ([#2867](https://github.com/coral-xyz/anchor/pull/2867)).
- spl: Fix not being able to deserialize newer token 2022 extensions ([#2876](https://github.com/coral-xyz/anchor/pull/2876)).
- spl: Remove `solana-program` dependency ([#2900](https://github.com/coral-xyz/anchor/pull/2900)).

### Breaking

Expand Down
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions spl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ anchor-lang = { path = "../lang", version = "0.29.0", features = ["derive"] }
borsh = { version = ">=0.9, <0.11", optional = true }
mpl-token-metadata = { version = "4", optional = true }
serum_dex = { git = "https://github.com/openbook-dex/program/", rev = "1be91f2", version = "0.4.0", features = ["no-entrypoint"], optional = true }
solana-program = "1.16"
spl-associated-token-account = { version = "3", features = ["no-entrypoint"], optional = true }
spl-memo = { version = "4", features = ["no-entrypoint"], optional = true }
spl-token = { version = "4", features = ["no-entrypoint"], optional = true }
spl-token-2022 = { version = "3", features = ["no-entrypoint"], optional = true }
spl-token-group-interface = { version = "0.2.3", optional = true }
spl-token-metadata-interface = { version = "0.3.3", optional = true }
spl-pod = { version = "0.2.2", optional = true }
spl-pod = { version = "0.2.2", optional = true }
4 changes: 2 additions & 2 deletions spl/src/associated_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub fn create<'info>(ctx: CpiContext<'_, '_, '_, 'info, Create<'info>>) -> Resul
ctx.accounts.mint.key,
ctx.accounts.token_program.key,
);
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&[
ctx.accounts.payer,
Expand All @@ -38,7 +38,7 @@ pub fn create_idempotent<'info>(
ctx.accounts.mint.key,
ctx.accounts.token_program.key,
);
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&[
ctx.accounts.payer,
Expand Down
18 changes: 9 additions & 9 deletions spl/src/dex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use std::num::NonZeroU64;
pub use serum_dex;

#[cfg(not(feature = "devnet"))]
anchor_lang::solana_program::declare_id!("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX");
anchor_lang::declare_id!("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX");

#[cfg(feature = "devnet")]
anchor_lang::solana_program::declare_id!("EoTcMgcDRTJVZDMZWBoU6rhYHZfkNTVEAfz3uUJRcYGj");
anchor_lang::declare_id!("EoTcMgcDRTJVZDMZWBoU6rhYHZfkNTVEAfz3uUJRcYGj");

#[allow(clippy::too_many_arguments)]
pub fn new_order_v3<'info>(
Expand Down Expand Up @@ -52,7 +52,7 @@ pub fn new_order_v3<'info>(
max_native_pc_qty_including_fees,
)
.map_err(|pe| ProgramError::from(pe))?;
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand All @@ -77,7 +77,7 @@ pub fn cancel_order_v2<'info>(
order_id,
)
.map_err(|pe| ProgramError::from(pe))?;
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand All @@ -101,7 +101,7 @@ pub fn settle_funds<'info>(ctx: CpiContext<'_, '_, '_, 'info, SettleFunds<'info>
ctx.accounts.vault_signer.key,
)
.map_err(|pe| ProgramError::from(pe))?;
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand All @@ -120,7 +120,7 @@ pub fn init_open_orders<'info>(
ctx.remaining_accounts.first().map(|acc| acc.key),
)
.map_err(|pe| ProgramError::from(pe))?;
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand All @@ -139,7 +139,7 @@ pub fn close_open_orders<'info>(
ctx.accounts.market.key,
)
.map_err(|pe| ProgramError::from(pe))?;
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand All @@ -158,7 +158,7 @@ pub fn sweep_fees<'info>(ctx: CpiContext<'_, '_, '_, 'info, SweepFees<'info>>) -
ctx.accounts.token_program.key,
)
.map_err(|pe| ProgramError::from(pe))?;
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand Down Expand Up @@ -194,7 +194,7 @@ pub fn initialize_market<'info>(
pc_dust_threshold,
)
.map_err(|pe| ProgramError::from(pe))?;
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand Down
2 changes: 1 addition & 1 deletion spl/src/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ macro_rules! vote_weight_record {
let vwr: spl_governance_addin_api::voter_weight::VoterWeightRecord =
anchor_lang::AnchorDeserialize::deserialize(&mut data)
.map_err(|_| anchor_lang::error::ErrorCode::AccountDidNotDeserialize)?;
if !solana_program::program_pack::IsInitialized::is_initialized(&vwr) {
if !anchor_lang::solana_program::program_pack::IsInitialized::is_initialized(&vwr) {
return Err(anchor_lang::error::ErrorCode::AccountDidNotSerialize.into());
}
Ok(VoterWeightRecord(vwr))
Expand Down
8 changes: 6 additions & 2 deletions spl/src/memo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ pub fn build_memo<'info>(ctx: CpiContext<'_, '_, '_, 'info, BuildMemo>, memo: &[
.map(|account| account.key)
.collect::<Vec<_>>(),
);
solana_program::program::invoke_signed(&ix, &ctx.remaining_accounts, ctx.signer_seeds)
.map_err(Into::into)
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ctx.remaining_accounts,
ctx.signer_seeds,
)
.map_err(Into::into)
}

#[derive(Accounts)]
Expand Down
52 changes: 26 additions & 26 deletions spl/src/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use anchor_lang::context::CpiContext;
use anchor_lang::error::ErrorCode;
use anchor_lang::solana_program::account_info::AccountInfo;
use anchor_lang::solana_program::pubkey::Pubkey;
use anchor_lang::solana_program::sysvar;
use anchor_lang::{system_program, Accounts, Result, ToAccountInfos};
use solana_program::account_info::AccountInfo;
use solana_program::pubkey::Pubkey;
use solana_program::sysvar;
use std::ops::Deref;

pub use mpl_token_metadata;
Expand All @@ -23,7 +23,7 @@ pub fn approve_collection_authority<'info>(
update_authority: *ctx.accounts.update_authority.key,
}
.instruction();
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand All @@ -48,7 +48,7 @@ pub fn bubblegum_set_collection_size<'info>(
set_collection_size_args: mpl_token_metadata::types::SetCollectionSizeArgs { size },
},
);
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand All @@ -72,7 +72,7 @@ pub fn burn_edition_nft<'info>(
spl_token_program: *ctx.accounts.spl_token.key,
}
.instruction();
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand Down Expand Up @@ -109,7 +109,7 @@ pub fn burn_nft<'info>(
token_account: *ctx.accounts.token.key,
}
.instruction();
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand Down Expand Up @@ -143,7 +143,7 @@ pub fn create_metadata_accounts_v3<'info>(
is_mutable,
},
);
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand All @@ -170,7 +170,7 @@ pub fn update_metadata_accounts_v2<'info>(
is_mutable,
},
);
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand All @@ -196,7 +196,7 @@ pub fn create_master_edition_v3<'info>(
.instruction(
mpl_token_metadata::instructions::CreateMasterEditionV3InstructionArgs { max_supply },
);
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand Down Expand Up @@ -230,7 +230,7 @@ pub fn mint_new_edition_from_master_edition_via_token<'info>(
mpl_token_metadata::types::MintNewEditionFromMasterEditionViaTokenArgs { edition },
},
);
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand All @@ -249,7 +249,7 @@ pub fn revoke_collection_authority<'info>(
revoke_authority: *ctx.accounts.revoke_authority.key,
}
.instruction();
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand All @@ -273,7 +273,7 @@ pub fn set_collection_size<'info>(
set_collection_size_args: mpl_token_metadata::types::SetCollectionSizeArgs { size },
},
);
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand All @@ -295,7 +295,7 @@ pub fn verify_collection<'info>(
payer: *ctx.accounts.payer.key,
}
.instruction();
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand All @@ -317,7 +317,7 @@ pub fn verify_sized_collection_item<'info>(
payer: *ctx.accounts.payer.key,
}
.instruction();
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand All @@ -340,7 +340,7 @@ pub fn set_and_verify_collection<'info>(
update_authority: *ctx.accounts.update_authority.key,
}
.instruction();
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand All @@ -363,7 +363,7 @@ pub fn set_and_verify_sized_collection_item<'info>(
update_authority: *ctx.accounts.update_authority.key,
}
.instruction();
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand All @@ -382,7 +382,7 @@ pub fn freeze_delegated_account<'info>(
token_program: *ctx.accounts.token_program.key,
}
.instruction();
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand All @@ -401,7 +401,7 @@ pub fn thaw_delegated_account<'info>(
token_program: *ctx.accounts.token_program.key,
}
.instruction();
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand All @@ -418,7 +418,7 @@ pub fn update_primary_sale_happened_via_token<'info>(
token: *ctx.accounts.token.key,
}
.instruction();
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand All @@ -437,7 +437,7 @@ pub fn set_token_standard<'info>(
update_authority: *ctx.accounts.update_authority.key,
}
.instruction();
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand All @@ -451,7 +451,7 @@ pub fn sign_metadata<'info>(ctx: CpiContext<'_, '_, '_, 'info, SignMetadata<'inf
metadata: *ctx.accounts.metadata.key,
}
.instruction();
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand All @@ -467,7 +467,7 @@ pub fn remove_creator_verification<'info>(
metadata: *ctx.accounts.metadata.key,
}
.instruction();
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand Down Expand Up @@ -495,7 +495,7 @@ pub fn utilize<'info>(
use_authority_record,
}
.instruction(mpl_token_metadata::instructions::UtilizeInstructionArgs { number_of_uses });
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand All @@ -516,7 +516,7 @@ pub fn unverify_collection<'info>(
metadata: *ctx.accounts.metadata.key,
}
.instruction();
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand All @@ -538,7 +538,7 @@ pub fn unverify_sized_collection_item<'info>(
payer: *ctx.accounts.payer.key,
}
.instruction();
solana_program::program::invoke_signed(
anchor_lang::solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
Expand Down
2 changes: 1 addition & 1 deletion spl/src/mint.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use anchor_lang::solana_program::declare_id;
use anchor_lang::declare_id;

pub use srm::ID as SRM;
mod srm {
Expand Down
Loading

0 comments on commit 1f0bf0e

Please sign in to comment.