Skip to content

Commit ef44763

Browse files
committed
fix token-2022 errors
1 parent 9b66aaf commit ef44763

File tree

12 files changed

+643
-48
lines changed

12 files changed

+643
-48
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,25 @@ resolver = "2"
4343
overflow-checks = true
4444

4545
[workspace.dependencies]
46+
47+
# misc
4648
borsh = "1.5.7"
4749
borsh-derive = "1.5.7"
50+
mpl-token-metadata = { version = "5.1.1", features = [ "no-entrypoint" ] }
51+
52+
53+
# spl
4854
solana-program = "3.0"
4955
spl-token = { version = "8.0.0", features = [ "no-entrypoint" ] }
56+
spl-token-2022 = {version = "9.0.0" , features = [ "no-entrypoint" ] }
5057
spl-associated-token-account = { version = "7.0.0", features = [ "no-entrypoint" ] }
58+
59+
# interface
5160
solana-system-interface = {version = "2.0.0", features = ["bincode"]}
61+
spl-token-interface = "2.0.0"
62+
spl-associated-token-account-interface = "2.0.0"
63+
spl-token-2022-interface = "2.0.0"
64+
65+
# pinocchio
5266
pinocchio = "=0.8.1"
5367
pinocchio-log = "0.4.0"
54-
mpl-token-metadata = { version = "5.1.1", features = [ "no-entrypoint" ] }

tokens/token-2022/default-account-state/native/program/Cargo.toml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
borsh = "0.9.3"
8-
borsh-derive = "0.9.1"
9-
solana-program = "1.18.17"
10-
spl-associated-token-account = { version="2.0.0", features = [ "no-entrypoint" ] }
11-
spl-token-2022 = {version = "0.7.0", features = [ "no-entrypoint" ] }
7+
borsh.workspace = true
8+
borsh-derive.workspace = true
9+
solana-program.workspace = true
10+
solana-system-interface.workspace = true
11+
spl-token-interface.workspace = true
12+
spl-associated-token-account-interface.workspace = true
13+
spl-token-2022-interface.workspace = true
1214

1315
[lib]
1416
crate-type = ["cdylib", "lib"]

tokens/token-2022/default-account-state/native/program/src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(unexpected_cfgs)]
2+
use solana_system_interface::instruction as system_instruction;
13
use {
24
borsh::{BorshDeserialize, BorshSerialize},
35
solana_program::{
@@ -8,10 +10,9 @@ use {
810
program::invoke,
911
pubkey::Pubkey,
1012
rent::Rent,
11-
system_instruction,
1213
sysvar::Sysvar,
1314
},
14-
spl_token_2022::{
15+
spl_token_2022_interface::{
1516
extension::{
1617
default_account_state::instruction::{
1718
initialize_default_account_state, update_default_account_state,
@@ -48,7 +49,8 @@ fn process_instruction(
4849
let token_program = next_account_info(accounts_iter)?;
4950

5051
// Find the size for the account with the Extension
51-
let space = ExtensionType::get_account_len::<Mint>(&[ExtensionType::DefaultAccountState]);
52+
let space =
53+
ExtensionType::try_calculate_account_len::<Mint>(&[ExtensionType::DefaultAccountState])?;
5254

5355
// Get the required rent exemption amount for the account
5456
let rent_required = Rent::get()?.minimum_balance(space);

tokens/token-2022/mint-close-authority/native/program/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
borsh = "0.9.3"
8-
borsh-derive = "0.9.1"
9-
solana-program = "2.0"
10-
spl-associated-token-account = { version="2.0.0", features = [ "no-entrypoint" ] }
11-
spl-token-2022 = {version = "0.7.0", features = [ "no-entrypoint" ] }
7+
borsh.workspace = true
8+
borsh-derive.workspace = true
9+
solana-program.workspace = true
10+
solana-system-interface.workspace = true
11+
spl-token-2022-interface.workspace = true
1212

1313
[lib]
1414
crate-type = ["cdylib", "lib"]

tokens/token-2022/mint-close-authority/native/program/src/lib.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(unexpected_cfgs)]
12
use {
23
borsh::{BorshDeserialize, BorshSerialize},
34
solana_program::{
@@ -8,10 +9,12 @@ use {
89
program::invoke,
910
pubkey::Pubkey,
1011
rent::Rent,
11-
system_instruction,
1212
sysvar::Sysvar,
1313
},
14-
spl_token_2022::{extension::ExtensionType, instruction as token_instruction, state::Mint},
14+
solana_system_interface::instruction as system_instruction,
15+
spl_token_2022_interface::{
16+
extension::ExtensionType, instruction as token_instruction, state::Mint,
17+
},
1518
};
1619

1720
#[derive(BorshSerialize, BorshDeserialize, Debug)]
@@ -39,7 +42,8 @@ fn process_instruction(
3942
let token_program = next_account_info(accounts_iter)?;
4043

4144
// Find the size for the account with the Extension
42-
let space = ExtensionType::get_account_len::<Mint>(&[ExtensionType::MintCloseAuthority]);
45+
let space =
46+
ExtensionType::try_calculate_account_len::<Mint>(&[ExtensionType::MintCloseAuthority])?;
4347

4448
// Get the required rent exemption amount for the account
4549
let rent_required = Rent::get()?.minimum_balance(space);

tokens/token-2022/multiple-extensions/native/program/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
borsh = "0.9.3"
8-
borsh-derive = "0.9.1"
9-
solana-program = "1.18.17"
10-
spl-associated-token-account = { version="2.0.0", features = [ "no-entrypoint" ] }
11-
spl-token-2022 = {version = "0.7.0", features = [ "no-entrypoint" ] }
7+
borsh.workspace = true
8+
borsh-derive.workspace = true
9+
solana-program.workspace = true
10+
solana-system-interface.workspace = true
11+
spl-token-2022-interface.workspace = true
1212

1313
[lib]
1414
crate-type = ["cdylib", "lib"]

tokens/token-2022/multiple-extensions/native/program/src/lib.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(unexpected_cfgs)]
12
use {
23
borsh::{BorshDeserialize, BorshSerialize},
34
solana_program::{
@@ -8,10 +9,12 @@ use {
89
program::invoke,
910
pubkey::Pubkey,
1011
rent::Rent,
11-
system_instruction,
1212
sysvar::Sysvar,
1313
},
14-
spl_token_2022::{extension::ExtensionType, instruction as token_instruction, state::Mint},
14+
solana_system_interface::instruction as system_instruction,
15+
spl_token_2022_interface::{
16+
extension::ExtensionType, instruction as token_instruction, state::Mint,
17+
},
1518
};
1619

1720
#[derive(BorshSerialize, BorshDeserialize, Debug)]
@@ -39,10 +42,10 @@ fn process_instruction(
3942
let token_program = next_account_info(accounts_iter)?;
4043

4144
// Find the size for the Mint account with the the number of extensions we want to use.
42-
let space = ExtensionType::get_account_len::<Mint>(&[
45+
let space = ExtensionType::try_calculate_account_len::<Mint>(&[
4346
ExtensionType::MintCloseAuthority,
4447
ExtensionType::NonTransferable,
45-
]);
48+
])?;
4649

4750
// Get the required rent exemption amount for the account
4851
let rent_required = Rent::get()?.minimum_balance(space);

tokens/token-2022/non-transferable/native/program/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
borsh = "0.9.3"
8-
borsh-derive = "0.9.1"
9-
solana-program = "2.0"
10-
spl-associated-token-account = { version="2.0.0", features = [ "no-entrypoint" ] }
11-
spl-token-2022 = {version = "0.7.0", features = [ "no-entrypoint" ] }
7+
borsh.workspace = true
8+
borsh-derive.workspace = true
9+
solana-program.workspace = true
10+
solana-system-interface.workspace = true
11+
spl-token-2022-interface.workspace = true
1212

1313
[lib]
1414
crate-type = ["cdylib", "lib"]

tokens/token-2022/non-transferable/native/program/src/lib.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(unexpected_cfgs)]
12
use {
23
borsh::{BorshDeserialize, BorshSerialize},
34
solana_program::{
@@ -8,10 +9,12 @@ use {
89
program::invoke,
910
pubkey::Pubkey,
1011
rent::Rent,
11-
system_instruction,
1212
sysvar::Sysvar,
1313
},
14-
spl_token_2022::{extension::ExtensionType, instruction as token_instruction, state::Mint},
14+
solana_system_interface::instruction as system_instruction,
15+
spl_token_2022_interface::{
16+
extension::ExtensionType, instruction as token_instruction, state::Mint,
17+
},
1518
};
1619

1720
#[derive(BorshSerialize, BorshDeserialize, Debug)]
@@ -38,7 +41,8 @@ fn process_instruction(
3841
let token_program = next_account_info(accounts_iter)?;
3942

4043
// Find the size for the account with the Extension
41-
let space = ExtensionType::get_account_len::<Mint>(&[ExtensionType::NonTransferable]);
44+
let space =
45+
ExtensionType::try_calculate_account_len::<Mint>(&[ExtensionType::NonTransferable])?;
4246

4347
// Get the required rent exemption amount for the account
4448
let rent_required = Rent::get()?.minimum_balance(space);

0 commit comments

Comments
 (0)