Skip to content

Commit 77dcb84

Browse files
feboFernando Esteban Barril Otero
authored andcommitted
Moved ahead of migration (solana-program#9)
1 parent 8fe3789 commit 77dcb84

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+4862
-0
lines changed

p-token/interface/Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "token-interface"
3+
version = "0.0.0"
4+
edition = { workspace = true }
5+
readme = "./README.md"
6+
license = { workspace = true }
7+
repository = { workspace = true }
8+
publish = false
9+
10+
[lib]
11+
crate-type = ["rlib"]
12+
13+
[dependencies]
14+
pinocchio = { workspace = true }
15+
pinocchio-pubkey = { workspace = true }

p-token/interface/src/error.rs

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
//! Error types
2+
3+
use pinocchio::program_error::ProgramError;
4+
5+
/// Errors that may be returned by the Token program.
6+
#[derive(Clone, Debug, Eq, PartialEq)]
7+
pub enum TokenError {
8+
// 0
9+
/// Lamport balance below rent-exempt threshold.
10+
NotRentExempt,
11+
/// Insufficient funds for the operation requested.
12+
InsufficientFunds,
13+
/// Invalid Mint.
14+
InvalidMint,
15+
/// Account not associated with this Mint.
16+
MintMismatch,
17+
/// Owner does not match.
18+
OwnerMismatch,
19+
20+
// 5
21+
/// This token's supply is fixed and new tokens cannot be minted.
22+
FixedSupply,
23+
/// The account cannot be initialized because it is already being used.
24+
AlreadyInUse,
25+
/// Invalid number of provided signers.
26+
InvalidNumberOfProvidedSigners,
27+
/// Invalid number of required signers.
28+
InvalidNumberOfRequiredSigners,
29+
/// State is uninitialized.
30+
UninitializedState,
31+
32+
// 10
33+
/// Instruction does not support native tokens
34+
NativeNotSupported,
35+
/// Non-native account can only be closed if its balance is zero
36+
NonNativeHasBalance,
37+
/// Invalid instruction
38+
InvalidInstruction,
39+
/// State is invalid for requested operation.
40+
InvalidState,
41+
/// Operation overflowed
42+
Overflow,
43+
44+
// 15
45+
/// Account does not support specified authority type.
46+
AuthorityTypeNotSupported,
47+
/// This token mint cannot freeze accounts.
48+
MintCannotFreeze,
49+
/// Account is frozen; all account operations will fail
50+
AccountFrozen,
51+
/// Mint decimals mismatch between the client and mint
52+
MintDecimalsMismatch,
53+
/// Instruction does not support non-native tokens
54+
NonNativeNotSupported,
55+
}
56+
57+
impl From<TokenError> for ProgramError {
58+
fn from(e: TokenError) -> Self {
59+
ProgramError::Custom(e as u32)
60+
}
61+
}

0 commit comments

Comments
 (0)