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
19 changes: 19 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ carbon-stabble-stable-swap-decoder = { path = "decoders/carbon-stabble-stable-sw
carbon-stabble-weighted-swap-decoder = { path = "decoders/carbon-stabble-weighted-swap-decoder", version = "0.11.0" }
carbon-stake-program-decoder = { path = "decoders/carbon-stake-program-decoder", version = "0.11.0" }
carbon-stream-message-datasource = { path = "datasources/stream-message-datasource", version = "0.11.0" }
carbon-swig-decoder = { path = "decoders/swig-decoder", version = "0.11.0" }
carbon-system-program-decoder = { path = "decoders/system-program-decoder", version = "0.11.0" }
carbon-test-utils = { path = "crates/test-utils", version = "0.11.0" }
carbon-token-2022-decoder = { path = "decoders/token-2022-decoder", version = "0.11.0" }
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ Decoders for most popular Solana programs are published and maintained:
| `carbon-solayer-pool-restaking-decoder` | Solayer Pool Restaking Program Decoder | sSo1iU21jBrU9VaJ8PJib1MtorefUV4fzC9GURa2KNn |
| `carbon-stabble-stable-swap-decoder` | Stabble Stable Swap Decoder | swapNyd8XiQwJ6ianp9snpu4brUqFxadzvHebnAXjJZ |
| `carbon-stabble-weighted-swap-decoder` | Stabble Weighted Swap Decoder | swapFpHZwjELNnjvThjajtiVmkz3yPQEHjLtka2fwHW |
| `carbon-stake-program-decoder` | Stake Program Decoder | Stake11111111111111111111111111111111111111 |
| `carbon-stake-program-decoder` | Stake Program Decoder | swigypWHEksbC64pWKwah1WTeh9JXwx8H1rJHLdbQMB |
| `carbon-swig-decoder`. | Swig Program Decoder | Stake11111111111111111111111111111111111111 |
| `carbon-system-program-decoder` | System Program Decoder | 11111111111111111111111111111111 |
| `carbon-token-2022-decoder` | Token 2022 Program Decoder | TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb |
| `carbon-token-program-decoder` | Token Program Decoder | TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA |
Expand Down
50 changes: 50 additions & 0 deletions decoders/swig-decoder/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[package]
name = "carbon-swig-decoder"
version = "0.11.0"
edition = "2021"

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

[features]
default = []
serde = ["dep:serde", "dep:serde-big-array"]
postgres = [
"carbon-core/postgres",
"dep:sqlx",
"dep:async-trait",
"dep:sqlx_migrator",
"serde",
]
graphql = [
"carbon-core/graphql",
"dep:juniper",
"dep:base64",
"serde",
]

[dependencies]
# Core dependencies
carbon-core = { version = "0.11.0", default-features = false }
solana-pubkey = { version = "^2.3.6" }
solana-account = { version = "~2.2" }
solana-instruction = { version = "~2.3", default-features = false }
serde_json = "1.0.138"

# Serialization (optional)
serde = { version = "1.0.219", features = ["derive"], optional = true }
serde-big-array = { version = "0.5.1", optional = true }

# Postgres dependencies (optional)
sqlx = { version = "0.8.6", features = ["postgres", "rust_decimal"], optional = true }
async-trait = { version = "0.1", optional = true }
sqlx_migrator = { version = "0.17.0", optional = true }

# GraphQL dependencies (optional)
juniper = { version = "0.16.1", optional = true }
base64 = { version = "0.22", optional = true }


[dev-dependencies]
carbon-test-utils = { version = "0.11.0" }

6 changes: 6 additions & 0 deletions decoders/swig-decoder/src/graphql/context.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#[derive(Clone)]
pub struct GraphQLContext {
pub pool: std::sync::Arc<sqlx::PgPool>,
}

impl juniper::Context for GraphQLContext {}
4 changes: 4 additions & 0 deletions decoders/swig-decoder/src/graphql/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pub mod context;
pub mod query;

pub use query::*;
11 changes: 11 additions & 0 deletions decoders/swig-decoder/src/graphql/query.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use juniper::{graphql_object, FieldResult};
use std::str::FromStr;

pub struct QueryRoot;

#[graphql_object(context = crate::graphql::context::GraphQLContext)]
impl QueryRoot {
// Accounts

// Instructions (per-instruction list and lookup by signature+index)
}
74 changes: 74 additions & 0 deletions decoders/swig-decoder/src/instructions/add_authority_v1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//! This code was AUTOGENERATED using the Codama library.
//! Please DO NOT EDIT THIS FILE, instead use visitors
//! to add features, then rerun Codama to update it.
//!
//! <https://github.com/codama-idl/codama>
//!

use carbon_core::account_utils::next_account;
use carbon_core::borsh::{self, BorshDeserialize};
use carbon_core::deserialize::ArrangeAccounts;

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(
Debug,
Clone,
carbon_core::borsh::BorshSerialize,
carbon_core::borsh::BorshDeserialize,
PartialEq,
)]
pub struct AddAuthorityV1 {}

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct AddAuthorityV1InstructionAccounts {
pub swig: solana_pubkey::Pubkey,
pub payer: solana_pubkey::Pubkey,
pub system_program: solana_pubkey::Pubkey,
pub remaining: Vec<solana_instruction::AccountMeta>,
}

impl AddAuthorityV1 {
pub fn decode(data: &[u8]) -> Option<Self> {
if data.len() < 1 {
return None;
}
let discriminator = &data[0..1];
if discriminator != &[1] {
return None;
}

let mut data_slice = data;

data_slice = &data_slice[1..];

if let Ok(decoded) = Self::deserialize(&mut data_slice) {
return Some(decoded);
}

None
}
}

impl ArrangeAccounts for AddAuthorityV1 {
type ArrangedAccounts = AddAuthorityV1InstructionAccounts;

fn arrange_accounts(
accounts: &[solana_instruction::AccountMeta],
) -> Option<Self::ArrangedAccounts> {
let mut iter = accounts.iter();

let swig = next_account(&mut iter)?;
let payer = next_account(&mut iter)?;
let system_program = next_account(&mut iter)?;

let remaining = iter.as_slice();

Some(AddAuthorityV1InstructionAccounts {
swig: swig,
payer: payer,
system_program: system_program,
remaining: remaining.to_vec(),
})
}
}
74 changes: 74 additions & 0 deletions decoders/swig-decoder/src/instructions/create_session_v1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//! This code was AUTOGENERATED using the Codama library.
//! Please DO NOT EDIT THIS FILE, instead use visitors
//! to add features, then rerun Codama to update it.
//!
//! <https://github.com/codama-idl/codama>
//!

use carbon_core::account_utils::next_account;
use carbon_core::borsh::{self, BorshDeserialize};
use carbon_core::deserialize::ArrangeAccounts;

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(
Debug,
Clone,
carbon_core::borsh::BorshSerialize,
carbon_core::borsh::BorshDeserialize,
PartialEq,
)]
pub struct CreateSessionV1 {}

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct CreateSessionV1InstructionAccounts {
pub swig: solana_pubkey::Pubkey,
pub payer: solana_pubkey::Pubkey,
pub system_program: solana_pubkey::Pubkey,
pub remaining: Vec<solana_instruction::AccountMeta>,
}

impl CreateSessionV1 {
pub fn decode(data: &[u8]) -> Option<Self> {
if data.len() < 1 {
return None;
}
let discriminator = &data[0..1];
if discriminator != &[5] {
return None;
}

let mut data_slice = data;

data_slice = &data_slice[1..];

if let Ok(decoded) = Self::deserialize(&mut data_slice) {
return Some(decoded);
}

None
}
}

impl ArrangeAccounts for CreateSessionV1 {
type ArrangedAccounts = CreateSessionV1InstructionAccounts;

fn arrange_accounts(
accounts: &[solana_instruction::AccountMeta],
) -> Option<Self::ArrangedAccounts> {
let mut iter = accounts.iter();

let swig = next_account(&mut iter)?;
let payer = next_account(&mut iter)?;
let system_program = next_account(&mut iter)?;

let remaining = iter.as_slice();

Some(CreateSessionV1InstructionAccounts {
swig: swig,
payer: payer,
system_program: system_program,
remaining: remaining.to_vec(),
})
}
}
77 changes: 77 additions & 0 deletions decoders/swig-decoder/src/instructions/create_sub_account_v1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//! This code was AUTOGENERATED using the Codama library.
//! Please DO NOT EDIT THIS FILE, instead use visitors
//! to add features, then rerun Codama to update it.
//!
//! <https://github.com/codama-idl/codama>
//!

use carbon_core::account_utils::next_account;
use carbon_core::borsh::{self, BorshDeserialize};
use carbon_core::deserialize::ArrangeAccounts;

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(
Debug,
Clone,
carbon_core::borsh::BorshSerialize,
carbon_core::borsh::BorshDeserialize,
PartialEq,
)]
pub struct CreateSubAccountV1 {}

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct CreateSubAccountV1InstructionAccounts {
pub swig: solana_pubkey::Pubkey,
pub payer: solana_pubkey::Pubkey,
pub sub_account: solana_pubkey::Pubkey,
pub system_program: solana_pubkey::Pubkey,
pub remaining: Vec<solana_instruction::AccountMeta>,
}

impl CreateSubAccountV1 {
pub fn decode(data: &[u8]) -> Option<Self> {
if data.len() < 1 {
return None;
}
let discriminator = &data[0..1];
if discriminator != &[6] {
return None;
}

let mut data_slice = data;

data_slice = &data_slice[1..];

if let Ok(decoded) = Self::deserialize(&mut data_slice) {
return Some(decoded);
}

None
}
}

impl ArrangeAccounts for CreateSubAccountV1 {
type ArrangedAccounts = CreateSubAccountV1InstructionAccounts;

fn arrange_accounts(
accounts: &[solana_instruction::AccountMeta],
) -> Option<Self::ArrangedAccounts> {
let mut iter = accounts.iter();

let swig = next_account(&mut iter)?;
let payer = next_account(&mut iter)?;
let sub_account = next_account(&mut iter)?;
let system_program = next_account(&mut iter)?;

let remaining = iter.as_slice();

Some(CreateSubAccountV1InstructionAccounts {
swig: swig,
payer: payer,
sub_account: sub_account,
system_program: system_program,
remaining: remaining.to_vec(),
})
}
}
Loading