Skip to content

Commit 1ff4d83

Browse files
committed
feat(spl): Update to Solana 3.0
1 parent 7e85ed8 commit 1ff4d83

File tree

29 files changed

+1597
-3519
lines changed

29 files changed

+1597
-3519
lines changed

Cargo.lock

Lines changed: 478 additions & 1882 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spl/Cargo.toml

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,36 @@ rustdoc-args = ["--cfg", "docsrs"]
1313
[features]
1414
default = ["associated_token", "mint", "token", "token_2022", "token_2022_extensions"]
1515
anchor-debug = ["anchor-lang/anchor-debug"]
16-
associated_token = ["spl-associated-token-account"]
16+
associated_token = ["spl-associated-token-account-interface"]
1717
devnet = []
1818
governance = []
1919
idl-build = ["anchor-lang/idl-build"]
20-
memo = ["spl-memo"]
21-
metadata = ["mpl-token-metadata"]
20+
memo = ["spl-memo-interface"]
21+
metadata = ["mpl-token-metadata", "dep:solana-sysvar", "dep:base64ct"]
2222
mint = []
23-
stake = ["borsh"]
24-
token = ["spl-token"]
25-
token_2022 = ["spl-token-2022"]
23+
stake = ["dep:borsh", "dep:solana-stake-interface"]
24+
token = ["spl-token-interface"]
25+
token_2022 = ["spl-token-2022-interface"]
2626
token_2022_extensions = [
27-
"spl-token-2022",
27+
"spl-token-2022-interface",
2828
"spl-token-group-interface",
2929
"spl-token-metadata-interface",
3030
"spl-pod",
3131
]
3232

3333
[dependencies]
3434
anchor-lang = { path = "../lang", version = "0.32.1", features = ["derive"] }
35+
# FIXME(edition2024): Not used directly, but upstream crates resolve to this version,
36+
# which uses Edition 2024
37+
base64ct = { version = "<1.8.0", optional = true }
3538
borsh = { version = "1.5.7", optional = true }
36-
mpl-token-metadata = { version = "5", optional = true }
37-
spl-associated-token-account = { version = "7", features = ["no-entrypoint"], optional = true }
38-
spl-memo = { version = "6", features = ["no-entrypoint"], optional = true }
39-
spl-pod = { version = "0.5", optional = true }
40-
spl-token = { version = "8", features = ["no-entrypoint"], optional = true }
41-
spl-token-2022 = { version = "8", features = ["no-entrypoint"], optional = true }
42-
spl-token-group-interface = { version = "0.6", optional = true }
43-
spl-token-metadata-interface = { version = "0.7", optional = true }
39+
mpl-token-metadata = { version = "=5.1.2-alpha.1", optional = true }
40+
solana-stake-interface = { version = "2", features = ["borsh"], optional = true }
41+
solana-sysvar = { version = "3", optional = true }
42+
spl-associated-token-account-interface = { version = "2", optional = true }
43+
spl-memo-interface = { version = "2", optional = true }
44+
spl-pod = { version = "0.7", optional = true }
45+
spl-token-interface = { version = "2", optional = true }
46+
spl-token-2022-interface = { version = "2", optional = true }
47+
spl-token-group-interface = { version = "0.7", optional = true }
48+
spl-token-metadata-interface = { version = "0.8", optional = true }

spl/src/associated_token.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ use anchor_lang::solana_program::pubkey::Pubkey;
55
use anchor_lang::Result;
66
use anchor_lang::{context::CpiContext, Accounts};
77

8-
pub use spl_associated_token_account;
9-
pub use spl_associated_token_account::{
10-
get_associated_token_address, get_associated_token_address_with_program_id, ID,
8+
pub use ::spl_associated_token_account_interface as spl_associated_token_account;
9+
pub use ::spl_associated_token_account_interface::{
10+
address::{get_associated_token_address, get_associated_token_address_with_program_id},
11+
program::ID,
1112
};
1213

1314
pub fn create<'info>(ctx: CpiContext<'_, '_, '_, 'info, Create<'info>>) -> Result<()> {

spl/src/memo.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ use anchor_lang::solana_program::pubkey::Pubkey;
22
use anchor_lang::Result;
33
use anchor_lang::{context::CpiContext, Accounts};
44

5-
pub use spl_memo;
6-
pub use spl_memo::ID;
5+
pub use spl_memo_interface::instruction as spl_memo;
6+
pub use spl_memo_interface::v3::ID;
77

88
pub fn build_memo<'info>(ctx: CpiContext<'_, '_, '_, 'info, BuildMemo>, memo: &[u8]) -> Result<()> {
99
let ix = spl_memo::build_memo(
10+
&ID,
1011
memo,
1112
&ctx.remaining_accounts
1213
.iter()

spl/src/metadata.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use anchor_lang::context::CpiContext;
22
use anchor_lang::error::ErrorCode;
33
use anchor_lang::solana_program::account_info::AccountInfo;
44
use anchor_lang::solana_program::pubkey::Pubkey;
5-
use anchor_lang::solana_program::sysvar;
65
use anchor_lang::{system_program, Accounts, Result, ToAccountInfos};
76
use std::ops::Deref;
87

@@ -190,7 +189,7 @@ pub fn create_master_edition_v3<'info>(
190189
payer: *ctx.accounts.payer.key,
191190
rent: None,
192191
system_program: system_program::ID,
193-
token_program: spl_token::ID,
192+
token_program: spl_token_interface::ID,
194193
update_authority: *ctx.accounts.update_authority.key,
195194
}
196195
.instruction(
@@ -222,7 +221,7 @@ pub fn mint_new_edition_from_master_edition_via_token<'info>(
222221
system_program: system_program::ID,
223222
token_account: *ctx.accounts.token_account.key,
224223
token_account_owner: *ctx.accounts.token_account_owner.key,
225-
token_program: spl_token::ID,
224+
token_program: spl_token_interface::ID,
226225
}
227226
.instruction(
228227
mpl_token_metadata::instructions::MintNewEditionFromMasterEditionViaTokenInstructionArgs {
@@ -482,15 +481,15 @@ pub fn utilize<'info>(
482481
number_of_uses: u64,
483482
) -> Result<()> {
484483
let ix = mpl_token_metadata::instructions::Utilize {
485-
ata_program: spl_associated_token_account::ID,
484+
ata_program: spl_associated_token_account_interface::program::ID,
486485
burner,
487486
metadata: *ctx.accounts.metadata.key,
488487
mint: *ctx.accounts.mint.key,
489488
owner: *ctx.accounts.owner.key,
490-
rent: sysvar::rent::ID,
489+
rent: solana_sysvar::rent::ID,
491490
system_program: system_program::ID,
492491
token_account: *ctx.accounts.token_account.key,
493-
token_program: spl_token::ID,
492+
token_program: spl_token_interface::ID,
494493
use_authority: *ctx.accounts.use_authority.key,
495494
use_authority_record,
496495
}

spl/src/stake.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
use anchor_lang::{
22
context::CpiContext,
3-
solana_program::{
4-
account_info::AccountInfo,
5-
pubkey::Pubkey,
6-
stake::{
7-
self,
8-
program::ID,
9-
state::{StakeAuthorize, StakeState},
10-
},
11-
},
3+
solana_program::{account_info::AccountInfo, pubkey::Pubkey},
124
Accounts, Result,
135
};
146
use borsh::BorshDeserialize;
7+
use solana_stake_interface::{
8+
self as stake,
9+
program::ID,
10+
state::{StakeAuthorize, StakeStateV2},
11+
};
1512
use std::ops::Deref;
1613

1714
// CPI functions
@@ -128,15 +125,15 @@ pub struct DeactivateStake<'info> {
128125
// State
129126

130127
#[derive(Clone)]
131-
pub struct StakeAccount(StakeState);
128+
pub struct StakeAccount(StakeStateV2);
132129

133130
impl anchor_lang::AccountDeserialize for StakeAccount {
134131
fn try_deserialize(buf: &mut &[u8]) -> anchor_lang::Result<Self> {
135132
Self::try_deserialize_unchecked(buf)
136133
}
137134

138135
fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result<Self> {
139-
StakeState::deserialize(buf).map(Self).map_err(Into::into)
136+
StakeStateV2::deserialize(buf).map(Self).map_err(Into::into)
140137
}
141138
}
142139

@@ -149,7 +146,7 @@ impl anchor_lang::Owner for StakeAccount {
149146
}
150147

151148
impl Deref for StakeAccount {
152-
type Target = StakeState;
149+
type Target = StakeStateV2;
153150

154151
fn deref(&self) -> &Self::Target {
155152
&self.0

spl/src/token.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use anchor_lang::Result;
77
use anchor_lang::{context::CpiContext, Accounts};
88
use std::ops::Deref;
99

10-
pub use spl_token;
1110
pub use spl_token::ID;
11+
pub use spl_token_interface as spl_token;
1212

1313
pub fn transfer<'info>(
1414
ctx: CpiContext<'_, '_, '_, 'info, Transfer<'info>>,

spl/src/token_2022.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use anchor_lang::solana_program::pubkey::Pubkey;
55
use anchor_lang::Result;
66
use anchor_lang::{context::CpiContext, Accounts};
77

8-
pub use spl_token_2022;
98
pub use spl_token_2022::ID;
9+
pub use spl_token_2022_interface as spl_token_2022;
1010

1111
#[deprecated(
1212
since = "0.28.0",

spl/src/token_2022_extensions/cpi_guard.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use anchor_lang::solana_program::account_info::AccountInfo;
44
use anchor_lang::solana_program::pubkey::Pubkey;
55
use anchor_lang::Result;
66
use anchor_lang::{context::CpiContext, Accounts};
7+
use spl_token_2022_interface as spl_token_2022;
78

89
pub fn cpi_guard_enable<'info>(ctx: CpiContext<'_, '_, '_, 'info, CpiGuard<'info>>) -> Result<()> {
910
let ix = spl_token_2022::extension::cpi_guard::instruction::enable_cpi_guard(

spl/src/token_2022_extensions/default_account_state.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use anchor_lang::solana_program::pubkey::Pubkey;
55
use anchor_lang::Result;
66
use anchor_lang::{context::CpiContext, Accounts};
77
use spl_token_2022::state::AccountState;
8+
use spl_token_2022_interface as spl_token_2022;
89

910
pub fn default_account_state_initialize<'info>(
1011
ctx: CpiContext<'_, '_, '_, 'info, DefaultAccountStateInitialize<'info>>,

0 commit comments

Comments
 (0)