Skip to content

Commit 80221f7

Browse files
committed
program: Deprecate re-exports from spl-token-interface
#### Problem We need pepole to know about spl-token-interface so they can start using it, but we haven't really promoted it. #### Summary of changes Do the right thing, and make the deprecations loud in spl-token, and stop using spl-token's re-exports everywhere in the repo.
1 parent 369b081 commit 80221f7

38 files changed

+325
-416
lines changed

Cargo.lock

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

p-token/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ solana-signer = "2.2.1"
4040
solana-transaction = "2.2.3"
4141
solana-transaction-error = "2.2.1"
4242
solana-system-interface = { workspace = true }
43-
spl-token = { version="^8", features=["no-entrypoint"] }
44-
spl-token-2022 = { version="^9", features=["no-entrypoint"] }
43+
spl-token-interface = "1"
44+
spl-token-2022-interface = "1"
4545

4646
[lints]
4747
workspace = true

p-token/tests/amount_to_ui_amount.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@ async fn amount_to_ui_amount() {
3333
.await
3434
.unwrap();
3535

36-
let amount_to_ui_amount_ix =
37-
spl_token::instruction::amount_to_ui_amount(&spl_token::ID, &mint, 1000).unwrap();
36+
let amount_to_ui_amount_ix = spl_token_interface::instruction::amount_to_ui_amount(
37+
&spl_token_interface::ID,
38+
&mint,
39+
1000,
40+
)
41+
.unwrap();
3842

3943
let tx = Transaction::new_signed_with_payer(
4044
&[amount_to_ui_amount_ix],
@@ -70,7 +74,8 @@ fn amount_to_ui_amount_with_maximum_decimals() {
7074
// succeed and return the correct UI amount.
7175

7276
let instruction =
73-
spl_token::instruction::amount_to_ui_amount(&spl_token::ID, &mint, 20).unwrap();
77+
spl_token_interface::instruction::amount_to_ui_amount(&spl_token_interface::ID, &mint, 20)
78+
.unwrap();
7479

7580
// The expected UI amount is "0.000....002" without the trailing zeros.
7681
let mut ui_amount = [b'0'; u8::MAX as usize + 1];
@@ -102,8 +107,12 @@ fn amount_to_ui_amount_with_u64_max() {
102107
// When we convert an u64::MAX amount using the mint, the transaction should
103108
// succeed and return the correct UI amount.
104109

105-
let instruction =
106-
spl_token::instruction::amount_to_ui_amount(&spl_token::ID, &mint, u64::MAX).unwrap();
110+
let instruction = spl_token_interface::instruction::amount_to_ui_amount(
111+
&spl_token_interface::ID,
112+
&mint,
113+
u64::MAX,
114+
)
115+
.unwrap();
107116

108117
// The expected UI amount is a `u64::MAX` with 255 decimal places.
109118
// - 2 digits for `0.`

p-token/tests/approve.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ async fn approve() {
5252

5353
let delegate = Pubkey::new_unique();
5454

55-
let approve_ix = spl_token::instruction::approve(
56-
&spl_token::ID,
55+
let approve_ix = spl_token_interface::instruction::approve(
56+
&spl_token_interface::ID,
5757
&account,
5858
&delegate,
5959
&owner.pubkey(),
@@ -77,7 +77,7 @@ async fn approve() {
7777
assert!(account.is_some());
7878

7979
let account = account.unwrap();
80-
let account = spl_token::state::Account::unpack(&account.data).unwrap();
80+
let account = spl_token_interface::state::Account::unpack(&account.data).unwrap();
8181

8282
assert!(account.delegate.is_some());
8383
assert!(account.delegate.unwrap() == delegate);

p-token/tests/approve_checked.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async fn approve_checked() {
5252

5353
let delegate = Pubkey::new_unique();
5454

55-
let approve_ix = spl_token::instruction::approve_checked(
55+
let approve_ix = spl_token_interface::instruction::approve_checked(
5656
&TOKEN_PROGRAM_ID,
5757
&account,
5858
&mint,
@@ -79,7 +79,7 @@ async fn approve_checked() {
7979
assert!(account.is_some());
8080

8181
let account = account.unwrap();
82-
let account = spl_token::state::Account::unpack(&account.data).unwrap();
82+
let account = spl_token_interface::state::Account::unpack(&account.data).unwrap();
8383

8484
assert!(account.delegate.is_some());
8585
assert!(account.delegate.unwrap() == delegate);

0 commit comments

Comments
 (0)