Skip to content

Commit 5adaa0e

Browse files
authored
p-token: Add interface and p-token to workspace (#24)
* Update workspace * Remove unused * Filter p-token program * Rename interface crate * Add readme * Nits * Update cargo lock
1 parent 2f189b1 commit 5adaa0e

30 files changed

+3305
-121
lines changed

Diff for: Cargo.lock

+3,209-72
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Cargo.toml

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
[workspace]
22
resolver = "2"
3-
members = ["program"]
3+
members = ["interface", "p-token", "program"]
4+
5+
[workspace.package]
6+
authors = ["Anza Maintainers <[email protected]>"]
7+
repository = "https://github.com/solana-program/token"
8+
license = "Apache-2.0"
9+
edition = "2021"
410

511
[workspace.lints.rust.unexpected_cfgs]
612
level = "warn"

Diff for: interface/Cargo.toml

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
[package]
2-
name = "token-interface"
2+
name = "spl-token-interface"
33
version = "0.0.0"
4-
edition = { workspace = true }
4+
description = "Instructions and types for interacting with SPL Token program"
5+
authors = { workspace = true}
6+
repository = { workspace = true}
7+
license = { workspace = true}
8+
edition = { workspace = true}
59
readme = "./README.md"
6-
license = { workspace = true }
7-
repository = { workspace = true }
8-
publish = false
910

1011
[lib]
1112
crate-type = ["rlib"]
1213

1314
[dependencies]
14-
pinocchio = { workspace = true }
15-
pinocchio-pubkey = { workspace = true }
15+
pinocchio = { version = "0.7", git = "https://github.com/febo/pinocchio.git", branch = "febo/close-unstable" }
16+
pinocchio-pubkey = { version = "0.2", git = "https://github.com/febo/pinocchio.git", branch = "febo/close-unstable" }

Diff for: interface/README.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<p align="center">
2+
<a href="https://solana.com">
3+
<img alt="Solana" src="https://github.com/user-attachments/assets/534af75d-6347-48dc-8943-129423b2ba63" height="80" />
4+
</a>
5+
</p>
6+
7+
# SPL Token Interface
8+
9+
This crate contains instructions and constructors for interacting with the [SPL Token program](https://spl.solana.com/token).
10+
11+
The Token program defines a common implementation for Fungible and Non Fungible tokens.
12+
13+
## Getting Started
14+
15+
From your project folder:
16+
17+
```bash
18+
cargo add spl-token-interface
19+
```
20+
21+
This will add the `spl-token-interface` dependency to your `Cargo.toml` file.
22+
23+
## Documentation
24+
25+
Read more about the SPL Token program on the crate [documentation](https://docs.rs/spl-token-interface).

Diff for: p-token/Cargo.toml

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
[package]
2-
name = "token-program"
2+
name = "pinocchio-token-program"
33
version = "0.0.0"
4-
edition = { workspace = true }
4+
description = "A pinocchio-based Token (aka 'p-token') program"
5+
authors = { workspace = true}
6+
repository = { workspace = true}
7+
license = { workspace = true}
8+
edition = { workspace = true}
59
readme = "./README.md"
6-
license = { workspace = true }
7-
repository = { workspace = true }
8-
publish = false
9-
10-
[package.metadata.solana]
11-
program-id = "PToken1111111111111111111111111111111111111"
1210

1311
[lib]
1412
crate-type = ["cdylib"]
@@ -18,13 +16,13 @@ logging = []
1816
test-sbf = []
1917

2018
[dependencies]
21-
pinocchio = { workspace = true }
22-
pinocchio-log = { workspace = true }
23-
token-interface = { version = "^0", path = "../interface" }
19+
pinocchio = { version = "0.7", git = "https://github.com/febo/pinocchio.git", branch = "febo/close-unstable" }
20+
pinocchio-log = { version = "0.3", git = "https://github.com/febo/pinocchio.git", branch = "febo/close-unstable" }
21+
spl-token-interface = { version = "^0", path = "../interface" }
2422

2523
[dev-dependencies]
2624
assert_matches = "1.5.0"
27-
solana-program-test = "~1.18"
28-
solana-sdk = "~1.18"
25+
solana-program-test = "2.1"
26+
solana-sdk = "2.1"
2927
spl-token = { version="^4", features=["no-entrypoint"] }
3028
test-case = "3.3.1"

Diff for: p-token/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
11
# `p-token`
22

33
A `pinocchio`-based Token program.
4+
5+
## Overview
6+
7+
`p-token` is a reimplementation of the SPL Token program, one of the most popular programs on Solana, using [`pinocchio`](https://github.com/anza-xyz/pinocchio). The purpose is to have an implementation that optimizes the compute units, while being fully compatible with the original implementation &mdash; i.e., support the exact same instruction and account layouts as SPL Token, byte for byte.
8+
9+
## Features
10+
11+
- `no_std` crate
12+
- Same instruction and account layout as SPL Token
13+
- Minimal CU usage
14+
15+
16+
## License
17+
18+
The code is licensed under the [Apache License Version 2.0](LICENSE)

Diff for: p-token/keypair.json

-1
This file was deleted.

Diff for: p-token/src/processor/amount_to_ui_amount.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use pinocchio::{
33
account_info::AccountInfo, program::set_return_data, program_error::ProgramError, ProgramResult,
44
};
55
use pinocchio_log::logger::{Argument, Logger};
6-
use token_interface::{
6+
use spl_token_interface::{
77
error::TokenError,
88
state::{load, mint::Mint},
99
};

Diff for: p-token/src/processor/close_account.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use pinocchio::{
22
account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey, ProgramResult,
33
};
4-
use token_interface::{
4+
use spl_token_interface::{
55
error::TokenError,
66
state::{account::Account, load},
77
};

Diff for: p-token/src/processor/get_account_data_size.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use pinocchio::{
22
account_info::AccountInfo, program::set_return_data, program_error::ProgramError, ProgramResult,
33
};
4-
use token_interface::{
4+
use spl_token_interface::{
55
error::TokenError,
66
state::{account::Account, load, mint::Mint, RawType},
77
};

Diff for: p-token/src/processor/initialize_immutable_owner.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use pinocchio::{account_info::AccountInfo, msg, program_error::ProgramError, ProgramResult};
2-
use token_interface::{
2+
use spl_token_interface::{
33
error::TokenError,
44
state::{account::Account, load_unchecked, Initializable},
55
};

Diff for: p-token/src/processor/initialize_mint.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use pinocchio::{
66
sysvars::{rent::Rent, Sysvar},
77
ProgramResult,
88
};
9-
use token_interface::{
9+
use spl_token_interface::{
1010
error::TokenError,
1111
state::{load_mut_unchecked, mint::Mint, Initializable},
1212
};

Diff for: p-token/src/processor/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use pinocchio::{
88
account_info::AccountInfo, memory::sol_memcpy, program_error::ProgramError, pubkey::Pubkey,
99
ProgramResult,
1010
};
11-
use token_interface::{
11+
use spl_token_interface::{
1212
error::TokenError,
1313
program::ID as TOKEN_PROGRAM_ID,
1414
state::{

Diff for: p-token/src/processor/revoke.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use pinocchio::{account_info::AccountInfo, program_error::ProgramError, ProgramResult};
2-
use token_interface::{
2+
use spl_token_interface::{
33
error::TokenError,
44
state::{account::Account, load_mut},
55
};

Diff for: p-token/src/processor/set_authority.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use core::marker::PhantomData;
33
use pinocchio::{
44
account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey, ProgramResult,
55
};
6-
use token_interface::{
6+
use spl_token_interface::{
77
error::TokenError,
88
instruction::AuthorityType,
99
state::{account::Account, load_mut, mint::Mint, RawType},

Diff for: p-token/src/processor/shared/approve.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use pinocchio::{account_info::AccountInfo, program_error::ProgramError, ProgramResult};
2-
use token_interface::{
2+
use spl_token_interface::{
33
error::TokenError,
44
state::{account::Account, load, load_mut, mint::Mint},
55
};

Diff for: p-token/src/processor/shared/burn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use pinocchio::{account_info::AccountInfo, program_error::ProgramError, ProgramResult};
2-
use token_interface::{
2+
use spl_token_interface::{
33
error::TokenError,
44
state::{account::Account, load_mut, mint::Mint},
55
};

Diff for: p-token/src/processor/shared/initialize_account.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use pinocchio::{
55
sysvars::{rent::Rent, Sysvar},
66
ProgramResult,
77
};
8-
use token_interface::{
8+
use spl_token_interface::{
99
error::TokenError,
1010
native_mint::is_native_mint,
1111
state::{

Diff for: p-token/src/processor/shared/initialize_multisig.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use pinocchio::{
44
sysvars::{rent::Rent, Sysvar},
55
ProgramResult,
66
};
7-
use token_interface::{
7+
use spl_token_interface::{
88
error::TokenError,
99
state::{load_mut_unchecked, multisig::Multisig, Initializable},
1010
};

Diff for: p-token/src/processor/shared/mint_to.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use pinocchio::{account_info::AccountInfo, program_error::ProgramError, ProgramResult};
2-
use token_interface::{
2+
use spl_token_interface::{
33
error::TokenError,
44
state::{account::Account, load_mut, mint::Mint},
55
};

Diff for: p-token/src/processor/shared/toggle_account_state.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use pinocchio::{account_info::AccountInfo, program_error::ProgramError, ProgramResult};
2-
use token_interface::{
2+
use spl_token_interface::{
33
error::TokenError,
44
state::{account::Account, account_state::AccountState, load, load_mut, mint::Mint},
55
};

Diff for: p-token/src/processor/shared/transfer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use pinocchio::{account_info::AccountInfo, program_error::ProgramError, ProgramResult};
2-
use token_interface::{
2+
use spl_token_interface::{
33
error::TokenError,
44
state::{account::Account, load, load_mut, load_mut_unchecked, mint::Mint},
55
};

Diff for: p-token/src/processor/sync_native.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use pinocchio::{account_info::AccountInfo, program_error::ProgramError, ProgramResult};
2-
use token_interface::{
2+
use spl_token_interface::{
33
error::TokenError,
44
state::{account::Account, load_mut},
55
};

Diff for: p-token/src/processor/ui_amount_to_amount.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use core::str::from_utf8;
22
use pinocchio::{
33
account_info::AccountInfo, program::set_return_data, program_error::ProgramError, ProgramResult,
44
};
5-
use token_interface::{
5+
use spl_token_interface::{
66
error::TokenError,
77
state::{load, mint::Mint},
88
};

Diff for: p-token/tests/initialize_mint.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use solana_sdk::{
1414
system_instruction,
1515
transaction::Transaction,
1616
};
17-
use token_interface::state::mint::Mint;
17+
use spl_token_interface::state::mint::Mint;
1818

1919
#[test_case::test_case(TOKEN_PROGRAM_ID ; "p-token")]
2020
#[tokio::test]

Diff for: p-token/tests/initialize_mint2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use solana_sdk::{
1414
system_instruction,
1515
transaction::Transaction,
1616
};
17-
use token_interface::state::mint::Mint;
17+
use spl_token_interface::state::mint::Mint;
1818

1919
#[test_case::test_case(TOKEN_PROGRAM_ID ; "p-token")]
2020
#[tokio::test]

Diff for: p-token/tests/setup/mint.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use solana_sdk::{
55
program_error::ProgramError, pubkey::Pubkey, signature::Keypair, signer::Signer,
66
system_instruction, transaction::Transaction,
77
};
8-
use token_interface::state::mint::Mint;
8+
use spl_token_interface::state::mint::Mint;
99

1010
pub async fn initialize(
1111
context: &mut ProgramTestContext,

Diff for: p-token/tests/setup/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ pub mod account;
55
#[allow(dead_code)]
66
pub mod mint;
77

8-
pub const TOKEN_PROGRAM_ID: Pubkey = Pubkey::new_from_array(token_interface::program::ID);
8+
pub const TOKEN_PROGRAM_ID: Pubkey = Pubkey::new_from_array(spl_token_interface::program::ID);

Diff for: program/Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
name = "spl-token"
33
version = "7.0.0"
44
description = "Solana Program Library Token"
5-
authors = ["Anza Maintainers <[email protected]>"]
6-
repository = "https://github.com/solana-program/token"
7-
license = "Apache-2.0"
8-
edition = "2021"
5+
authors = { workspace = true}
6+
repository = { workspace = true}
7+
license = { workspace = true}
8+
edition = { workspace = true}
99

1010
[features]
1111
no-entrypoint = []

Diff for: scripts/utils.mjs

+5-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,11 @@ export function getProgramFolders() {
6565
}
6666

6767
export function getAllProgramFolders() {
68-
return getCargo().workspace.members.filter((member) =>
69-
(getCargo(member).lib?.['crate-type'] ?? []).includes('cdylib')
68+
return getCargo().workspace.members.filter(
69+
(member) =>
70+
(getCargo(member).lib?.['crate-type'] ?? []).includes('cdylib') &&
71+
// Exclude the pinocchio-token-program crate.
72+
getCargo(member).package?.name !== 'pinocchio-token-program'
7073
);
7174
}
7275

0 commit comments

Comments
 (0)