Skip to content

interface: Fix spelling #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,281 changes: 3,209 additions & 72 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
[workspace]
resolver = "2"
members = ["program"]
members = ["interface", "p-token", "program"]

[workspace.package]
authors = ["Anza Maintainers <[email protected]>"]
repository = "https://github.com/solana-program/token"
license = "Apache-2.0"
edition = "2021"

[workspace.lints.rust.unexpected_cfgs]
level = "warn"
Expand Down
15 changes: 8 additions & 7 deletions interface/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
[package]
name = "token-interface"
name = "spl-token-interface"
version = "0.0.0"
edition = { workspace = true }
description = "Instructions and types for interacting with SPL Token program"
authors = { workspace = true}
repository = { workspace = true}
license = { workspace = true}
edition = { workspace = true}
readme = "./README.md"
license = { workspace = true }
repository = { workspace = true }
publish = false

[lib]
crate-type = ["rlib"]

[dependencies]
pinocchio = { workspace = true }
pinocchio-pubkey = { workspace = true }
pinocchio = { version = "0.7", git = "https://github.com/febo/pinocchio.git", branch = "febo/close-unstable" }
pinocchio-pubkey = { version = "0.2", git = "https://github.com/febo/pinocchio.git", branch = "febo/close-unstable" }
25 changes: 25 additions & 0 deletions interface/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<p align="center">
<a href="https://solana.com">
<img alt="Solana" src="https://github.com/user-attachments/assets/534af75d-6347-48dc-8943-129423b2ba63" height="80" />
</a>
</p>

# SPL Token Interface

This crate contains instructions and constructors for interacting with the [SPL Token program](https://spl.solana.com/token).

The Token program defines a common implementation for Fungible and Non Fungible tokens.

## Getting Started

From your project folder:

```bash
cargo add spl-token-interface
```

This will add the `spl-token-interface` dependency to your `Cargo.toml` file.

## Documentation

Read more about the SPL Token program on the crate [documentation](https://docs.rs/spl-token-interface).
58 changes: 28 additions & 30 deletions interface/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub enum TokenInstruction<'a> {
/// associated with another mint, that mint must be initialized before this
/// command can succeed.
///
/// The `InitializeAccount` instruction requires no signers and MUST be
/// The [`InitializeAccount`] instruction requires no signers and MUST be
/// included within the same Transaction as the system program's
/// `CreateAccount` instruction that creates the account being initialized.
/// Otherwise another party can acquire ownership of the uninitialized
Expand All @@ -57,7 +57,7 @@ pub enum TokenInstruction<'a> {
/// present. The variant field represents the number of signers (M)
/// required to validate this multisignature account.
///
/// The `InitializeMultisig` instruction requires no signers and MUST be
/// The [`InitializeMultisig`] instruction requires no signers and MUST be
/// included within the same Transaction as the system program's
/// `CreateAccount` instruction that creates the account being initialized.
/// Otherwise another party can acquire ownership of the uninitialized
Expand All @@ -67,8 +67,7 @@ pub enum TokenInstruction<'a> {
///
/// 0. `[writable]` The multisignature account to initialize.
/// 1. `[]` Rent sysvar
/// 2. ..2+N. `[]` The signer accounts, must equal to N where 1 <= N <=
/// 11.
/// 2. `..+N` `[signer]` The signer accounts, must equal to N where `1 <= N <= 11`.
InitializeMultisig {
/// The number of signers (M) required to validate this multisignature
/// account.
Expand All @@ -91,7 +90,7 @@ pub enum TokenInstruction<'a> {
/// 0. `[writable]` The source account.
/// 1. `[writable]` The destination account.
/// 2. `[]` The source account's multisignature owner/delegate.
/// 3. ..3+M `[signer]` M signer accounts.
/// 3. `..+M` `[signer]` M signer accounts.
Transfer {
/// The amount of tokens to transfer.
amount: u64,
Expand All @@ -111,7 +110,7 @@ pub enum TokenInstruction<'a> {
/// 0. `[writable]` The source account.
/// 1. `[]` The delegate.
/// 2. `[]` The source account's multisignature owner.
/// 3. ..3+M `[signer]` M signer accounts
/// 3. `..+M` `[signer]` M signer accounts
Approve {
/// The amount of tokens the delegate is approved for.
amount: u64,
Expand All @@ -128,7 +127,7 @@ pub enum TokenInstruction<'a> {
/// * Multisignature owner
/// 0. `[writable]` The source account.
/// 1. `[]` The source account's multisignature owner.
/// 2. ..2+M `[signer]` M signer accounts
/// 2. `..+M` `[signer]` M signer accounts
Revoke,

/// Sets a new authority of a mint or account.
Expand All @@ -142,7 +141,7 @@ pub enum TokenInstruction<'a> {
/// * Multisignature authority
/// 0. `[writable]` The mint or account to change the authority of.
/// 1. `[]` The mint's or account's current multisignature authority.
/// 2. ..2+M `[signer]` M signer accounts
/// 2. `..+M` `[signer]` M signer accounts
SetAuthority {
/// The type of authority to update.
authority_type: AuthorityType,
Expand All @@ -164,7 +163,7 @@ pub enum TokenInstruction<'a> {
/// 0. `[writable]` The mint.
/// 1. `[writable]` The account to mint tokens to.
/// 2. `[]` The mint's multisignature mint-tokens authority.
/// 3. ..3+M `[signer]` M signer accounts.
/// 3. `..+M` `[signer]` M signer accounts.
MintTo {
/// The amount of new tokens to mint.
amount: u64,
Expand All @@ -184,7 +183,7 @@ pub enum TokenInstruction<'a> {
/// 0. `[writable]` The account to burn from.
/// 1. `[writable]` The token mint.
/// 2. `[]` The account's multisignature owner/delegate.
/// 3. ..3+M `[signer]` M signer accounts.
/// 3. `..+M` `[signer]` M signer accounts.
Burn {
/// The amount of tokens to burn.
amount: u64,
Expand All @@ -204,10 +203,10 @@ pub enum TokenInstruction<'a> {
/// 0. `[writable]` The account to close.
/// 1. `[writable]` The destination account.
/// 2. `[]` The account's multisignature owner.
/// 3. ..3+M `[signer]` M signer accounts.
/// 3. `..+M` `[signer]` M signer accounts.
CloseAccount,

/// Freeze an Initialized account using the Mint's freeze_authority (if
/// Freeze an Initialized account using the Mint's [`freeze_authority`] (if
/// set).
///
/// Accounts expected by this instruction:
Expand All @@ -221,10 +220,10 @@ pub enum TokenInstruction<'a> {
/// 0. `[writable]` The account to freeze.
/// 1. `[]` The token mint.
/// 2. `[]` The mint's multisignature freeze authority.
/// 3. ..3+M `[signer]` M signer accounts.
/// 3. `..+M` `[signer]` M signer accounts.
FreezeAccount,

/// Thaw a Frozen account using the Mint's freeze_authority (if set).
/// Thaw a Frozen account using the Mint's [`freeze_authority`] (if set).
///
/// Accounts expected by this instruction:
///
Expand All @@ -237,7 +236,7 @@ pub enum TokenInstruction<'a> {
/// 0. `[writable]` The account to freeze.
/// 1. `[]` The token mint.
/// 2. `[]` The mint's multisignature freeze authority.
/// 3. ..3+M `[signer]` M signer accounts.
/// 3. `..+M` `[signer]` M signer accounts.
ThawAccount,

/// Transfers tokens from one account to another either directly or via a
Expand All @@ -262,7 +261,7 @@ pub enum TokenInstruction<'a> {
/// 1. `[]` The token mint.
/// 2. `[writable]` The destination account.
/// 3. `[]` The source account's multisignature owner/delegate.
/// 4. ..4+M `[signer]` M signer accounts.
/// 4. `..+M` `[signer]` M signer accounts.
TransferChecked {
/// The amount of tokens to transfer.
amount: u64,
Expand Down Expand Up @@ -290,7 +289,7 @@ pub enum TokenInstruction<'a> {
/// 1. `[]` The token mint.
/// 2. `[]` The delegate.
/// 3. `[]` The source account's multisignature owner.
/// 4. ..4+M `[signer]` M signer accounts
/// 4. `..+M` `[signer]` M signer accounts
ApproveChecked {
/// The amount of tokens the delegate is approved for.
amount: u64,
Expand All @@ -301,7 +300,7 @@ pub enum TokenInstruction<'a> {
/// Mints new tokens to an account. The native mint does not support
/// minting.
///
/// This instruction differs from MintTo in that the decimals value is
/// This instruction differs from [`MintTo`] in that the decimals value is
/// checked by the caller. This may be useful when creating transactions
/// offline or within a hardware wallet.
///
Expand All @@ -316,15 +315,15 @@ pub enum TokenInstruction<'a> {
/// 0. `[writable]` The mint.
/// 1. `[writable]` The account to mint tokens to.
/// 2. `[]` The mint's multisignature mint-tokens authority.
/// 3. ..3+M `[signer]` M signer accounts.
/// 3. `..+M` `[signer]` M signer accounts.
MintToChecked {
/// The amount of new tokens to mint.
amount: u64,
/// Expected number of base 10 digits to the right of the decimal place.
decimals: u8,
},

/// Burns tokens by removing them from an account. `BurnChecked` does not
/// Burns tokens by removing them from an account. [`BurnChecked`] does not
/// support accounts associated with the native mint, use `CloseAccount`
/// instead.
///
Expand All @@ -343,15 +342,15 @@ pub enum TokenInstruction<'a> {
/// 0. `[writable]` The account to burn from.
/// 1. `[writable]` The token mint.
/// 2. `[]` The account's multisignature owner/delegate.
/// 3. ..3+M `[signer]` M signer accounts.
/// 3. `..+M` `[signer]` M signer accounts.
BurnChecked {
/// The amount of tokens to burn.
amount: u64,
/// Expected number of base 10 digits to the right of the decimal place.
decimals: u8,
},

/// Like InitializeAccount, but the owner pubkey is passed via instruction
/// Like [`InitializeAccount`], but the owner pubkey is passed via instruction
/// data rather than the accounts list. This variant may be preferable
/// when using Cross Program Invocation from an instruction that does
/// not need the owner's `AccountInfo` otherwise.
Expand All @@ -378,7 +377,7 @@ pub enum TokenInstruction<'a> {
/// lamports.
SyncNative,

/// Like InitializeAccount2, but does not require the Rent sysvar to be
/// Like [`InitializeAccount2`], but does not require the Rent sysvar to be
/// provided
///
/// Accounts expected by this instruction:
Expand All @@ -390,14 +389,13 @@ pub enum TokenInstruction<'a> {
owner: Pubkey,
},

/// Like InitializeMultisig, but does not require the Rent sysvar to be
/// Like [`InitializeMultisig`], but does not require the Rent sysvar to be
/// provided
///
/// Accounts expected by this instruction:
///
/// 0. `[writable]` The multisignature account to initialize.
/// 1. ..1+N. `[]` The signer accounts, must equal to N where 1 <= N <=
/// 11.
/// 1. `..+N` `[signer]` The signer accounts, must equal to N where `1 <= N <= 11`.
InitializeMultisig2 {
/// The number of signers (M) required to validate this multisignature
/// account.
Expand Down Expand Up @@ -433,7 +431,7 @@ pub enum TokenInstruction<'a> {
/// Initialize the Immutable Owner extension for the given token account
///
/// Fails if the account has already been initialized, so must be called
/// before `InitializeAccount`.
/// before [`InitializeAccount`].
///
/// No-ops in this version of the program, but is included for compatibility
/// with the Associated Token Account program.
Expand All @@ -446,7 +444,7 @@ pub enum TokenInstruction<'a> {
/// None
InitializeImmutableOwner,

/// Convert an Amount of tokens to a UiAmount `string`, using the given
/// Convert an Amount of tokens to a `UiAmount` `string`, using the given
/// mint. In this version of the program, the mint can only specify the
/// number of decimals.
///
Expand All @@ -463,7 +461,7 @@ pub enum TokenInstruction<'a> {
amount: u64,
},

/// Convert a UiAmount of tokens to a little-endian `u64` raw Amount, using
/// Convert a `UiAmount` of tokens to a little-endian `u64` raw Amount, using
/// the given mint. In this version of the program, the mint can only
/// specify the number of decimals.
///
Expand All @@ -474,7 +472,7 @@ pub enum TokenInstruction<'a> {
///
/// 0. `[]` The mint to calculate for
UiAmountToAmount {
/// The ui_amount of tokens to reformat.
/// The `ui_amount` of tokens to reformat.
ui_amount: &'a str,
},
// Any new variants also need to be added to program-2022 `TokenInstruction`, so that the
Expand Down
2 changes: 1 addition & 1 deletion interface/src/native_mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use pinocchio::pubkey::Pubkey;

/// There are 10^9 lamports in one SOL
/// There are `10^9` lamports in one SOL
pub const DECIMALS: u8 = 9;

// The Mint for native SOL Token accounts
Expand Down
2 changes: 1 addition & 1 deletion interface/src/state/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct Account {
/// Indicates whether this account represents a native token or not.
is_native: [u8; 4],

/// If is_native.is_some, this is a native token, and the value logs the
/// If `is_native.is_some`, this is a native token, and the value logs the
/// rent-exempt reserve. An Account is required to be rent-exempt, so
/// the value is used by the Processor to ensure that wrapped SOL
/// accounts do not drop below this threshold.
Expand Down
24 changes: 11 additions & 13 deletions p-token/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
[package]
name = "token-program"
name = "pinocchio-token-program"
version = "0.0.0"
edition = { workspace = true }
description = "A pinocchio-based Token (aka 'p-token') program"
authors = { workspace = true}
repository = { workspace = true}
license = { workspace = true}
edition = { workspace = true}
readme = "./README.md"
license = { workspace = true }
repository = { workspace = true }
publish = false

[package.metadata.solana]
program-id = "PToken1111111111111111111111111111111111111"

[lib]
crate-type = ["cdylib"]
Expand All @@ -18,13 +16,13 @@ logging = []
test-sbf = []

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

[dev-dependencies]
assert_matches = "1.5.0"
solana-program-test = "~1.18"
solana-sdk = "~1.18"
solana-program-test = "2.1"
solana-sdk = "2.1"
spl-token = { version="^4", features=["no-entrypoint"] }
test-case = "3.3.1"
15 changes: 15 additions & 0 deletions p-token/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# `p-token`

A `pinocchio`-based Token program.

## Overview

`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.

## Features

- `no_std` crate
- Same instruction and account layout as SPL Token
- Minimal CU usage


## License

The code is licensed under the [Apache License Version 2.0](LICENSE)
1 change: 0 additions & 1 deletion p-token/keypair.json

This file was deleted.

2 changes: 1 addition & 1 deletion p-token/src/processor/amount_to_ui_amount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use pinocchio::{
account_info::AccountInfo, program::set_return_data, program_error::ProgramError, ProgramResult,
};
use pinocchio_log::logger::{Argument, Logger};
use token_interface::{
use spl_token_interface::{
error::TokenError,
state::{load, mint::Mint},
};
Expand Down
Loading