Skip to content

p-token: Port interface and program from p-token repo #22

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 41 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
528d9b1
Initial version
febo Oct 3, 2024
6ecf53b
Use published crate
febo Oct 3, 2024
0c03567
Add interface crate
febo Oct 27, 2024
6f9bddf
Fix clippy warning
febo Nov 12, 2024
f0dc8e1
Add pod types
febo Nov 12, 2024
056fdb3
Add workspace dependencies
febo Nov 12, 2024
1fab6ae
Update program ID
febo Nov 12, 2024
98e6802
Enable rent exempt check
febo Nov 12, 2024
dfa0343
Rename program
febo Nov 12, 2024
86867da
More instructions
febo Nov 18, 2024
6168176
Few more instructions
febo Nov 20, 2024
c11fb53
Inline tweaks
febo Nov 21, 2024
c409d8f
instruction: SyncNative
febo Nov 21, 2024
7be9e68
Add remaining instructions
febo Nov 21, 2024
6900167
Refactor shared processors
febo Nov 21, 2024
4480ec1
Tweak inlines
febo Nov 21, 2024
c72774d
Fix typo
febo Nov 21, 2024
64139bd
processor: Split processor (#2)
febo Nov 24, 2024
145856d
Typo in comment
febo Nov 24, 2024
64cd1bf
Update pinocchio dependency
febo Nov 25, 2024
1998638
Switch to no_std
febo Nov 25, 2024
e232b38
Fix amount conversion
febo Nov 27, 2024
678f1ae
Add amount ui tests
febo Nov 27, 2024
96d2a8a
rafactor: Add trait types (#3)
febo Nov 28, 2024
aac59e7
Increase formatting buffer
febo Nov 28, 2024
1aa18f0
Use heapless entrypoint
febo Dec 4, 2024
06026b9
Change crate type
febo Dec 7, 2024
3877ccd
Update git dependency
febo Dec 7, 2024
402f522
Fix account owner check
febo Dec 24, 2024
f1a5e76
Remove unnecessary mut
febo Jan 9, 2025
93ab04c
Update pinocchio dependency
febo Jan 12, 2025
1fc2fe0
Add native amount setter
febo Jan 13, 2025
70ad09f
Avoid unnecessary trim
febo Jan 13, 2025
4275261
Add result check
febo Jan 13, 2025
22cdc21
Map error
febo Jan 13, 2025
5ecc302
Set native amount
febo Jan 13, 2025
346ddc3
Use overflow error
febo Jan 13, 2025
db57691
Update owner check
febo Jan 13, 2025
b3428c8
Update program id
febo Jan 13, 2025
e75ba41
Use interface program id
febo Jan 13, 2025
8797904
Add safety comments (#8)
febo Jan 23, 2025
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
15 changes: 15 additions & 0 deletions interface/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "token-interface"
version = "0.0.0"
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 }
61 changes: 61 additions & 0 deletions interface/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//! Error types

use pinocchio::program_error::ProgramError;

/// Errors that may be returned by the Token program.
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum TokenError {
// 0
/// Lamport balance below rent-exempt threshold.
NotRentExempt,
/// Insufficient funds for the operation requested.
InsufficientFunds,
/// Invalid Mint.
InvalidMint,
/// Account not associated with this Mint.
MintMismatch,
/// Owner does not match.
OwnerMismatch,

// 5
/// This token's supply is fixed and new tokens cannot be minted.
FixedSupply,
/// The account cannot be initialized because it is already being used.
AlreadyInUse,
/// Invalid number of provided signers.
InvalidNumberOfProvidedSigners,
/// Invalid number of required signers.
InvalidNumberOfRequiredSigners,
/// State is uninitialized.
UninitializedState,

// 10
/// Instruction does not support native tokens
NativeNotSupported,
/// Non-native account can only be closed if its balance is zero
NonNativeHasBalance,
/// Invalid instruction
InvalidInstruction,
/// State is invalid for requested operation.
InvalidState,
/// Operation overflowed
Overflow,

// 15
/// Account does not support specified authority type.
AuthorityTypeNotSupported,
/// This token mint cannot freeze accounts.
MintCannotFreeze,
/// Account is frozen; all account operations will fail
AccountFrozen,
/// Mint decimals mismatch between the client and mint
MintDecimalsMismatch,
/// Instruction does not support non-native tokens
NonNativeNotSupported,
}

impl From<TokenError> for ProgramError {
fn from(e: TokenError) -> Self {
ProgramError::Custom(e as u32)
}
}
Loading