Skip to content

Commit 690985e

Browse files
authored
interface: Split out instructions, state, errors from program (#616)
* interface: Split out instructions, state, errors from program #### Problem The token-2022 program has some heavy dependencies that most users of the crate don't care about. This causes dependency issues and long compilation times. Also, the program uses Agave dependencies, which creates circular dependencies and makes it impossible to upgrade to SDK v3 without some complicated gymnastics. #### Summary of changes Similar to the ATA's interface crate, split out everything need by Agave into a separate crate, which can also be used by on-chain programs as an rlib, and thus allow for LTO in program builds. * Rename serde-traits -> serde, remove repeated funcs * Cleanup deps, remove repeated functions, run format * Fix spelling issues and client generation * Address nits
1 parent cb6348c commit 690985e

File tree

98 files changed

+14496
-13912
lines changed

Some content is hidden

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

98 files changed

+14496
-13912
lines changed

.github/workflows/main.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,27 @@ jobs:
109109
- name: Lint Client Rust
110110
run: pnpm clients:rust:lint
111111

112+
format_and_lint_interface:
113+
name: Format & Lint Interface
114+
runs-on: ubuntu-latest
115+
steps:
116+
- name: Git Checkout
117+
uses: actions/checkout@v4
118+
119+
- name: Setup Environment
120+
uses: ./.github/actions/setup
121+
with:
122+
clippy: true
123+
rustfmt: true
124+
cargo-cache-key: cargo-interface-lint
125+
cargo-cache-fallback-key: cargo-interface
126+
127+
- name: Format
128+
run: pnpm interface:format
129+
130+
- name: Lint
131+
run: pnpm interface:lint
132+
112133
format_and_lint_client_rust_legacy:
113134
name: Format & Lint Client Rust Legacy
114135
runs-on: ubuntu-latest
@@ -171,6 +192,22 @@ jobs:
171192
- name: Lint Proof Tests
172193
run: pnpm confidential-transfer:proof-tests:lint
173194

195+
test_interface:
196+
name: Test Interface
197+
runs-on: ubuntu-latest
198+
steps:
199+
- name: Git Checkout
200+
uses: actions/checkout@v4
201+
202+
- name: Setup Environment
203+
uses: ./.github/actions/setup
204+
with:
205+
cargo-cache-key: cargo-interface-test
206+
cargo-cache-fallback-key: cargo-interface
207+
208+
- name: Test
209+
run: pnpm interface:test
210+
174211
test_confidential_transfer_proofs:
175212
name: Test Confidential Transfer Proofs
176213
runs-on: ubuntu-latest

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ members = [
1919
"confidential-transfer/proof-extraction",
2020
"confidential-transfer/proof-generation",
2121
"confidential-transfer/proof-tests",
22+
"interface",
2223
"program",
2324
]
2425

interface/Cargo.toml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
[package]
2+
name = "spl-token-2022-interface"
3+
version = "1.0.0"
4+
description = "Solana Program Library Token 2022 Interface"
5+
documentation = "https://docs.rs/spl-token-2022-interface"
6+
readme = "README.md"
7+
authors = { workspace = true }
8+
repository = { workspace = true }
9+
homepage = { workspace = true }
10+
license = { workspace = true }
11+
edition = { workspace = true }
12+
13+
[features]
14+
serde = ["dep:serde", "dep:serde_with", "dep:base64", "spl-pod/serde-traits"]
15+
16+
[dependencies]
17+
arrayref = "0.3.9"
18+
bytemuck = { version = "1.23.1", features = ["derive"] }
19+
num-derive = "0.4"
20+
num-traits = "0.2"
21+
num_enum = "0.7.4"
22+
solana-account-info = "2.3.0"
23+
solana-decode-error = "2.2.1"
24+
solana-instruction = "2.2.1"
25+
solana-msg = "2.2.1"
26+
solana-program-error = "2.2.1"
27+
solana-program-option = "2.2.1"
28+
solana-program-pack = "2.2.1"
29+
solana-pubkey = "2.2.1"
30+
solana-sdk-ids = "2.2.1"
31+
solana-zk-sdk = "2.3.4"
32+
spl-token-confidential-transfer-proof-extraction = { version = "0.4.0", path = "../confidential-transfer/proof-extraction" }
33+
spl-token-group-interface = { version = "0.6.0" }
34+
spl-token-metadata-interface = { version = "0.7.0" }
35+
spl-type-length-value = { version = "0.8.0" }
36+
spl-pod = { version = "0.5.1" }
37+
thiserror = "2.0"
38+
serde = { version = "1.0.219", optional = true }
39+
serde_with = { version = "3.14.0", optional = true }
40+
base64 = { version = "0.22.1", optional = true }
41+
42+
[target.'cfg(not(target_os = "solana"))'.dependencies]
43+
spl-token-confidential-transfer-proof-generation = { version = "0.4.0", path = "../confidential-transfer/proof-generation" }
44+
45+
[dev-dependencies]
46+
proptest = "1.7"
47+
solana-pubkey = { version = "2.2.1", features = ["curve25519"] }
48+
spl-token = { version = "8.0", features = ["no-entrypoint"] }
49+
spl-token-2022-interface = { path = ".", features = ["serde"] }
50+
serde_json = "1.0.141"
51+
52+
[lib]
53+
crate-type = ["lib"]
54+
55+
[package.metadata.docs.rs]
56+
targets = ["x86_64-unknown-linux-gnu"]
57+
58+
[lints]
59+
workspace = true
60+
61+
[package.metadata.solana]
62+
program-id = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"

interface/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Token-2022 Interface
2+
3+
A token program interface on the Solana blockchain, usable for fungible and
4+
non-fungible tokens.
5+
6+
This crate provides an interface that third parties can utilize to create and
7+
use their tokens.
8+
9+
Full documentation is available at [https://www.solana-program.com/docs/token-2022](https://www.solana-program.com/docs/token-2022)
10+
11+
## Audit
12+
13+
The repository [README](https://github.com/solana-labs/solana-program-library#audits)
14+
contains information about program audits.
File renamed without changes.

0 commit comments

Comments
 (0)