Skip to content
Open
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
329 changes: 301 additions & 28 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ solana-transaction = "~2.2"
solana-transaction-context = "~2.2"
solana-transaction-status = "~2.2"
spl-memo = "5.0.0"
spl-token = "6.0.0"
spl-token = "8.0.0"
spl-token-2022 = "9.0.0"
sqlx = { version = "0.8.5", features = [
"macros",
"runtime-tokio-rustls",
Expand Down
2 changes: 2 additions & 0 deletions decoders/token-2022-decoder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ serde = { workspace = true }
serde-big-array = { workspace = true }
solana-account = { workspace = true }
solana-instruction = { workspace = true, default-features = false }
solana-program-pack = { workspace = true }
solana-pubkey = { workspace = true }
spl-token-2022 = { workspace = true, features = ["no-entrypoint"] }
13 changes: 0 additions & 13 deletions decoders/token-2022-decoder/src/accounts/mint.rs

This file was deleted.

35 changes: 19 additions & 16 deletions decoders/token-2022-decoder/src/accounts/mod.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
use {
super::Token2022Decoder,
crate::PROGRAM_ID,
carbon_core::{account::AccountDecoder, deserialize::CarbonDeserialize},
carbon_core::account::AccountDecoder,
solana_account::ReadableAccount,
solana_program_pack::Pack,
spl_token_2022::{
extension::StateWithExtensions,
state::{Account as TokenAccount, Mint, Multisig},
},
};
pub mod mint;
pub mod multisig;
pub mod token;

pub enum Token2022Account {
Mint(mint::Mint),
Token(token::Token),
Multisig(multisig::Multisig),
pub enum Token2022Account<'data> {
Mint(StateWithExtensions<'data, Mint>),
Token(StateWithExtensions<'data, TokenAccount>),
Multisig(Multisig),
}

impl AccountDecoder<'_> for Token2022Decoder {
type AccountType = Token2022Account;
impl<'data> AccountDecoder<'data> for Token2022Decoder {
type AccountType = Token2022Account<'data>;

fn decode_account(
&self,
account: &solana_account::Account,
account: &'data solana_account::Account,
) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
if !account.owner.eq(&PROGRAM_ID) {
if !account.owner.eq(&spl_token_2022::id()) {
return None;
}

if let Some(decoded_account) = mint::Mint::deserialize(account.data.as_slice()) {
if let Ok(decoded_account) = StateWithExtensions::<Mint>::unpack(account.data()) {
return Some(carbon_core::account::DecodedAccount {
lamports: account.lamports,
data: Token2022Account::Mint(decoded_account),
Expand All @@ -33,7 +36,7 @@ impl AccountDecoder<'_> for Token2022Decoder {
});
}

if let Some(decoded_account) = token::Token::deserialize(account.data.as_slice()) {
if let Ok(decoded_account) = StateWithExtensions::<TokenAccount>::unpack(account.data()) {
return Some(carbon_core::account::DecodedAccount {
lamports: account.lamports,
data: Token2022Account::Token(decoded_account),
Expand All @@ -43,7 +46,7 @@ impl AccountDecoder<'_> for Token2022Decoder {
});
}

if let Some(decoded_account) = multisig::Multisig::deserialize(account.data.as_slice()) {
if let Ok(decoded_account) = Multisig::unpack(account.data()) {
return Some(carbon_core::account::DecodedAccount {
lamports: account.lamports,
data: Token2022Account::Multisig(decoded_account),
Expand Down
12 changes: 0 additions & 12 deletions decoders/token-2022-decoder/src/accounts/multisig.rs

This file was deleted.

19 changes: 0 additions & 19 deletions decoders/token-2022-decoder/src/accounts/token.rs

This file was deleted.

4 changes: 1 addition & 3 deletions decoders/token-2022-decoder/src/instructions/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use crate::PROGRAM_ID;

use super::Token2022Decoder;
pub mod amount_to_ui_amount;
pub mod apply_confidential_pending_balance;
Expand Down Expand Up @@ -187,7 +185,7 @@ impl carbon_core::instruction::InstructionDecoder<'_> for Token2022Decoder {
&self,
instruction: &solana_instruction::Instruction,
) -> Option<carbon_core::instruction::DecodedInstruction<Self::InstructionType>> {
if !instruction.program_id.eq(&PROGRAM_ID) {
if !instruction.program_id.eq(&spl_token_2022::id()) {
return None;
}

Expand Down
3 changes: 1 addition & 2 deletions decoders/token-2022-decoder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ pub mod accounts;
pub mod instructions;
pub mod types;

pub const PROGRAM_ID: Pubkey =
Pubkey::from_str_const("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");
pub const PROGRAM_ID: Pubkey = spl_token_2022::id();
2 changes: 1 addition & 1 deletion decoders/token-program-decoder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ solana-account = { workspace = true }
solana-instruction = { workspace = true, default-features = false }
solana-program-pack = { workspace = true }
solana-pubkey = { workspace = true }
spl-token = { workspace = true }
spl-token = { workspace = true, features = ["no-entrypoint"] }
sqlx = { workspace = true, optional = true }
sqlx_migrator = { workspace = true, optional = true }
Loading