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

Cargo.lock

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

Cargo.toml

Lines changed: 7 additions & 1 deletion
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"

interface/Cargo.toml

Lines changed: 8 additions & 7 deletions
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" }

interface/README.md

Lines changed: 25 additions & 0 deletions
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).

p-token/Cargo.toml

Lines changed: 11 additions & 13 deletions
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"

p-token/README.md

Lines changed: 15 additions & 0 deletions
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)

p-token/keypair.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

p-token/src/processor/amount_to_ui_amount.rs

Lines changed: 1 addition & 1 deletion
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
};

p-token/src/processor/close_account.rs

Lines changed: 1 addition & 1 deletion
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
};

p-token/src/processor/get_account_data_size.rs

Lines changed: 1 addition & 1 deletion
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
};

0 commit comments

Comments
 (0)