use {
juniper::{graphql_object, FieldResult},
std::str::FromStr,
};
pub struct QueryRoot;
#[graphql_object(context = crate::graphql::context::GraphQLContext)]
impl QueryRoot {
async fn global_config(
context: &crate::graphql::context::GraphQLContext,
pubkey: String,
) -> FieldResult<Option<crate::accounts::graphql::GlobalConfigGraphQL>> {
use carbon_core::postgres::{operations::Lookup, primitives::Pubkey as PgPubkey};
let pk = PgPubkey(
solana_pubkey::Pubkey::from_str(&pubkey)
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?,
);
let row = crate::accounts::postgres::GlobalConfigRow::lookup(pk, &context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(row.and_then(|row| row.try_into().ok()))
}
async fn list_global_config(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::accounts::graphql::GlobalConfigGraphQL>> {
let rows: Vec<crate::accounts::postgres::GlobalConfigRow> = sqlx::query_as(
r#"SELECT * FROM global_config_account ORDER BY __slot DESC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn platform_config(
context: &crate::graphql::context::GraphQLContext,
pubkey: String,
) -> FieldResult<Option<crate::accounts::graphql::PlatformConfigGraphQL>> {
use carbon_core::postgres::{operations::Lookup, primitives::Pubkey as PgPubkey};
let pk = PgPubkey(
solana_pubkey::Pubkey::from_str(&pubkey)
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?,
);
let row = crate::accounts::postgres::PlatformConfigRow::lookup(pk, &context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(row.and_then(|row| row.try_into().ok()))
}
async fn list_platform_config(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::accounts::graphql::PlatformConfigGraphQL>> {
let rows: Vec<crate::accounts::postgres::PlatformConfigRow> = sqlx::query_as(
r#"SELECT * FROM platform_config_account ORDER BY __slot DESC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn platform_global_access(
context: &crate::graphql::context::GraphQLContext,
pubkey: String,
) -> FieldResult<Option<crate::accounts::graphql::PlatformGlobalAccessGraphQL>> {
use carbon_core::postgres::{operations::Lookup, primitives::Pubkey as PgPubkey};
let pk = PgPubkey(
solana_pubkey::Pubkey::from_str(&pubkey)
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?,
);
let row = crate::accounts::postgres::PlatformGlobalAccessRow::lookup(pk, &context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(row.and_then(|row| row.try_into().ok()))
}
async fn list_platform_global_access(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::accounts::graphql::PlatformGlobalAccessGraphQL>> {
let rows: Vec<crate::accounts::postgres::PlatformGlobalAccessRow> = sqlx::query_as(
r#"SELECT * FROM platform_global_access_account ORDER BY __slot DESC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn pool_state(
context: &crate::graphql::context::GraphQLContext,
pubkey: String,
) -> FieldResult<Option<crate::accounts::graphql::PoolStateGraphQL>> {
use carbon_core::postgres::{operations::Lookup, primitives::Pubkey as PgPubkey};
let pk = PgPubkey(
solana_pubkey::Pubkey::from_str(&pubkey)
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?,
);
let row = crate::accounts::postgres::PoolStateRow::lookup(pk, &context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(row.and_then(|row| row.try_into().ok()))
}
async fn list_pool_state(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::accounts::graphql::PoolStateGraphQL>> {
let rows: Vec<crate::accounts::postgres::PoolStateRow> = sqlx::query_as(
r#"SELECT * FROM pool_state_account ORDER BY __slot DESC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn vesting_record(
context: &crate::graphql::context::GraphQLContext,
pubkey: String,
) -> FieldResult<Option<crate::accounts::graphql::VestingRecordGraphQL>> {
use carbon_core::postgres::{operations::Lookup, primitives::Pubkey as PgPubkey};
let pk = PgPubkey(
solana_pubkey::Pubkey::from_str(&pubkey)
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?,
);
let row = crate::accounts::postgres::VestingRecordRow::lookup(pk, &context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(row.and_then(|row| row.try_into().ok()))
}
async fn list_vesting_record(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::accounts::graphql::VestingRecordGraphQL>> {
let rows: Vec<crate::accounts::postgres::VestingRecordRow> = sqlx::query_as(
r#"SELECT * FROM vesting_record_account ORDER BY __slot DESC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn buy_exact_in(
context: &crate::graphql::context::GraphQLContext,
signature: String,
instruction_index: i32,
) -> FieldResult<Vec<crate::instructions::graphql::BuyExactInGraphQL>> {
let rows: Vec<crate::instructions::postgres::BuyExactInRow> = sqlx::query_as(
r#"SELECT * FROM buy_exact_in_instruction WHERE __signature = $1 AND __instruction_index = $2 ORDER BY __stack_height ASC"#,
)
.bind(signature)
.bind(instruction_index)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn list_buy_exact_in(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::instructions::graphql::BuyExactInGraphQL>> {
let rows: Vec<crate::instructions::postgres::BuyExactInRow> = sqlx::query_as(
r#"SELECT * FROM buy_exact_in_instruction ORDER BY __slot DESC, __signature DESC, __instruction_index ASC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn buy_exact_out(
context: &crate::graphql::context::GraphQLContext,
signature: String,
instruction_index: i32,
) -> FieldResult<Vec<crate::instructions::graphql::BuyExactOutGraphQL>> {
let rows: Vec<crate::instructions::postgres::BuyExactOutRow> = sqlx::query_as(
r#"SELECT * FROM buy_exact_out_instruction WHERE __signature = $1 AND __instruction_index = $2 ORDER BY __stack_height ASC"#,
)
.bind(signature)
.bind(instruction_index)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn list_buy_exact_out(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::instructions::graphql::BuyExactOutGraphQL>> {
let rows: Vec<crate::instructions::postgres::BuyExactOutRow> = sqlx::query_as(
r#"SELECT * FROM buy_exact_out_instruction ORDER BY __slot DESC, __signature DESC, __instruction_index ASC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn claim_creator_fee(
context: &crate::graphql::context::GraphQLContext,
signature: String,
instruction_index: i32,
) -> FieldResult<Vec<crate::instructions::graphql::ClaimCreatorFeeGraphQL>> {
let rows: Vec<crate::instructions::postgres::ClaimCreatorFeeRow> = sqlx::query_as(
r#"SELECT * FROM claim_creator_fee_instruction WHERE __signature = $1 AND __instruction_index = $2 ORDER BY __stack_height ASC"#,
)
.bind(signature)
.bind(instruction_index)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn list_claim_creator_fee(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::instructions::graphql::ClaimCreatorFeeGraphQL>> {
let rows: Vec<crate::instructions::postgres::ClaimCreatorFeeRow> = sqlx::query_as(
r#"SELECT * FROM claim_creator_fee_instruction ORDER BY __slot DESC, __signature DESC, __instruction_index ASC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn claim_platform_fee(
context: &crate::graphql::context::GraphQLContext,
signature: String,
instruction_index: i32,
) -> FieldResult<Vec<crate::instructions::graphql::ClaimPlatformFeeGraphQL>> {
let rows: Vec<crate::instructions::postgres::ClaimPlatformFeeRow> = sqlx::query_as(
r#"SELECT * FROM claim_platform_fee_instruction WHERE __signature = $1 AND __instruction_index = $2 ORDER BY __stack_height ASC"#,
)
.bind(signature)
.bind(instruction_index)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn list_claim_platform_fee(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::instructions::graphql::ClaimPlatformFeeGraphQL>> {
let rows: Vec<crate::instructions::postgres::ClaimPlatformFeeRow> = sqlx::query_as(
r#"SELECT * FROM claim_platform_fee_instruction ORDER BY __slot DESC, __signature DESC, __instruction_index ASC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn claim_platform_fee_from_vault(
context: &crate::graphql::context::GraphQLContext,
signature: String,
instruction_index: i32,
) -> FieldResult<Vec<crate::instructions::graphql::ClaimPlatformFeeFromVaultGraphQL>> {
let rows: Vec<crate::instructions::postgres::ClaimPlatformFeeFromVaultRow> = sqlx::query_as(
r#"SELECT * FROM claim_platform_fee_from_vault_instruction WHERE __signature = $1 AND __instruction_index = $2 ORDER BY __stack_height ASC"#,
)
.bind(signature)
.bind(instruction_index)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn list_claim_platform_fee_from_vault(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::instructions::graphql::ClaimPlatformFeeFromVaultGraphQL>> {
let rows: Vec<crate::instructions::postgres::ClaimPlatformFeeFromVaultRow> = sqlx::query_as(
r#"SELECT * FROM claim_platform_fee_from_vault_instruction ORDER BY __slot DESC, __signature DESC, __instruction_index ASC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn claim_vested_token(
context: &crate::graphql::context::GraphQLContext,
signature: String,
instruction_index: i32,
) -> FieldResult<Vec<crate::instructions::graphql::ClaimVestedTokenGraphQL>> {
let rows: Vec<crate::instructions::postgres::ClaimVestedTokenRow> = sqlx::query_as(
r#"SELECT * FROM claim_vested_token_instruction WHERE __signature = $1 AND __instruction_index = $2 ORDER BY __stack_height ASC"#,
)
.bind(signature)
.bind(instruction_index)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn list_claim_vested_token(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::instructions::graphql::ClaimVestedTokenGraphQL>> {
let rows: Vec<crate::instructions::postgres::ClaimVestedTokenRow> = sqlx::query_as(
r#"SELECT * FROM claim_vested_token_instruction ORDER BY __slot DESC, __signature DESC, __instruction_index ASC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn close_platform_global_access(
context: &crate::graphql::context::GraphQLContext,
signature: String,
instruction_index: i32,
) -> FieldResult<Vec<crate::instructions::graphql::ClosePlatformGlobalAccessGraphQL>> {
let rows: Vec<crate::instructions::postgres::ClosePlatformGlobalAccessRow> = sqlx::query_as(
r#"SELECT * FROM close_platform_global_access_instruction WHERE __signature = $1 AND __instruction_index = $2 ORDER BY __stack_height ASC"#,
)
.bind(signature)
.bind(instruction_index)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn list_close_platform_global_access(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::instructions::graphql::ClosePlatformGlobalAccessGraphQL>> {
let rows: Vec<crate::instructions::postgres::ClosePlatformGlobalAccessRow> = sqlx::query_as(
r#"SELECT * FROM close_platform_global_access_instruction ORDER BY __slot DESC, __signature DESC, __instruction_index ASC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn collect_fee(
context: &crate::graphql::context::GraphQLContext,
signature: String,
instruction_index: i32,
) -> FieldResult<Vec<crate::instructions::graphql::CollectFeeGraphQL>> {
let rows: Vec<crate::instructions::postgres::CollectFeeRow> = sqlx::query_as(
r#"SELECT * FROM collect_fee_instruction WHERE __signature = $1 AND __instruction_index = $2 ORDER BY __stack_height ASC"#,
)
.bind(signature)
.bind(instruction_index)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn list_collect_fee(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::instructions::graphql::CollectFeeGraphQL>> {
let rows: Vec<crate::instructions::postgres::CollectFeeRow> = sqlx::query_as(
r#"SELECT * FROM collect_fee_instruction ORDER BY __slot DESC, __signature DESC, __instruction_index ASC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn collect_migrate_fee(
context: &crate::graphql::context::GraphQLContext,
signature: String,
instruction_index: i32,
) -> FieldResult<Vec<crate::instructions::graphql::CollectMigrateFeeGraphQL>> {
let rows: Vec<crate::instructions::postgres::CollectMigrateFeeRow> = sqlx::query_as(
r#"SELECT * FROM collect_migrate_fee_instruction WHERE __signature = $1 AND __instruction_index = $2 ORDER BY __stack_height ASC"#,
)
.bind(signature)
.bind(instruction_index)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn list_collect_migrate_fee(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::instructions::graphql::CollectMigrateFeeGraphQL>> {
let rows: Vec<crate::instructions::postgres::CollectMigrateFeeRow> = sqlx::query_as(
r#"SELECT * FROM collect_migrate_fee_instruction ORDER BY __slot DESC, __signature DESC, __instruction_index ASC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn create_config(
context: &crate::graphql::context::GraphQLContext,
signature: String,
instruction_index: i32,
) -> FieldResult<Vec<crate::instructions::graphql::CreateConfigGraphQL>> {
let rows: Vec<crate::instructions::postgres::CreateConfigRow> = sqlx::query_as(
r#"SELECT * FROM create_config_instruction WHERE __signature = $1 AND __instruction_index = $2 ORDER BY __stack_height ASC"#,
)
.bind(signature)
.bind(instruction_index)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn list_create_config(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::instructions::graphql::CreateConfigGraphQL>> {
let rows: Vec<crate::instructions::postgres::CreateConfigRow> = sqlx::query_as(
r#"SELECT * FROM create_config_instruction ORDER BY __slot DESC, __signature DESC, __instruction_index ASC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn create_platform_config(
context: &crate::graphql::context::GraphQLContext,
signature: String,
instruction_index: i32,
) -> FieldResult<Vec<crate::instructions::graphql::CreatePlatformConfigGraphQL>> {
let rows: Vec<crate::instructions::postgres::CreatePlatformConfigRow> = sqlx::query_as(
r#"SELECT * FROM create_platform_config_instruction WHERE __signature = $1 AND __instruction_index = $2 ORDER BY __stack_height ASC"#,
)
.bind(signature)
.bind(instruction_index)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn list_create_platform_config(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::instructions::graphql::CreatePlatformConfigGraphQL>> {
let rows: Vec<crate::instructions::postgres::CreatePlatformConfigRow> = sqlx::query_as(
r#"SELECT * FROM create_platform_config_instruction ORDER BY __slot DESC, __signature DESC, __instruction_index ASC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn create_platform_global_access(
context: &crate::graphql::context::GraphQLContext,
signature: String,
instruction_index: i32,
) -> FieldResult<Vec<crate::instructions::graphql::CreatePlatformGlobalAccessGraphQL>> {
let rows: Vec<crate::instructions::postgres::CreatePlatformGlobalAccessRow> = sqlx::query_as(
r#"SELECT * FROM create_platform_global_access_instruction WHERE __signature = $1 AND __instruction_index = $2 ORDER BY __stack_height ASC"#,
)
.bind(signature)
.bind(instruction_index)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn list_create_platform_global_access(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::instructions::graphql::CreatePlatformGlobalAccessGraphQL>> {
let rows: Vec<crate::instructions::postgres::CreatePlatformGlobalAccessRow> = sqlx::query_as(
r#"SELECT * FROM create_platform_global_access_instruction ORDER BY __slot DESC, __signature DESC, __instruction_index ASC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn create_platform_vesting_account(
context: &crate::graphql::context::GraphQLContext,
signature: String,
instruction_index: i32,
) -> FieldResult<Vec<crate::instructions::graphql::CreatePlatformVestingAccountGraphQL>> {
let rows: Vec<crate::instructions::postgres::CreatePlatformVestingAccountRow> = sqlx::query_as(
r#"SELECT * FROM create_platform_vesting_account_instruction WHERE __signature = $1 AND __instruction_index = $2 ORDER BY __stack_height ASC"#,
)
.bind(signature)
.bind(instruction_index)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn list_create_platform_vesting_account(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::instructions::graphql::CreatePlatformVestingAccountGraphQL>> {
let rows: Vec<crate::instructions::postgres::CreatePlatformVestingAccountRow> = sqlx::query_as(
r#"SELECT * FROM create_platform_vesting_account_instruction ORDER BY __slot DESC, __signature DESC, __instruction_index ASC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn create_vesting_account(
context: &crate::graphql::context::GraphQLContext,
signature: String,
instruction_index: i32,
) -> FieldResult<Vec<crate::instructions::graphql::CreateVestingAccountGraphQL>> {
let rows: Vec<crate::instructions::postgres::CreateVestingAccountRow> = sqlx::query_as(
r#"SELECT * FROM create_vesting_account_instruction WHERE __signature = $1 AND __instruction_index = $2 ORDER BY __stack_height ASC"#,
)
.bind(signature)
.bind(instruction_index)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn list_create_vesting_account(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::instructions::graphql::CreateVestingAccountGraphQL>> {
let rows: Vec<crate::instructions::postgres::CreateVestingAccountRow> = sqlx::query_as(
r#"SELECT * FROM create_vesting_account_instruction ORDER BY __slot DESC, __signature DESC, __instruction_index ASC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn initialize(
context: &crate::graphql::context::GraphQLContext,
signature: String,
instruction_index: i32,
) -> FieldResult<Vec<crate::instructions::graphql::InitializeGraphQL>> {
let rows: Vec<crate::instructions::postgres::InitializeRow> = sqlx::query_as(
r#"SELECT * FROM initialize_instruction WHERE __signature = $1 AND __instruction_index = $2 ORDER BY __stack_height ASC"#,
)
.bind(signature)
.bind(instruction_index)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn list_initialize(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::instructions::graphql::InitializeGraphQL>> {
let rows: Vec<crate::instructions::postgres::InitializeRow> = sqlx::query_as(
r#"SELECT * FROM initialize_instruction ORDER BY __slot DESC, __signature DESC, __instruction_index ASC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn initialize_v2(
context: &crate::graphql::context::GraphQLContext,
signature: String,
instruction_index: i32,
) -> FieldResult<Vec<crate::instructions::graphql::InitializeV2GraphQL>> {
let rows: Vec<crate::instructions::postgres::InitializeV2Row> = sqlx::query_as(
r#"SELECT * FROM initialize_v2_instruction WHERE __signature = $1 AND __instruction_index = $2 ORDER BY __stack_height ASC"#,
)
.bind(signature)
.bind(instruction_index)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn list_initialize_v2(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::instructions::graphql::InitializeV2GraphQL>> {
let rows: Vec<crate::instructions::postgres::InitializeV2Row> = sqlx::query_as(
r#"SELECT * FROM initialize_v2_instruction ORDER BY __slot DESC, __signature DESC, __instruction_index ASC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn initialize_with_token2022(
context: &crate::graphql::context::GraphQLContext,
signature: String,
instruction_index: i32,
) -> FieldResult<Vec<crate::instructions::graphql::InitializeWithToken2022GraphQL>> {
let rows: Vec<crate::instructions::postgres::InitializeWithToken2022Row> = sqlx::query_as(
r#"SELECT * FROM initialize_with_token2022_instruction WHERE __signature = $1 AND __instruction_index = $2 ORDER BY __stack_height ASC"#,
)
.bind(signature)
.bind(instruction_index)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn list_initialize_with_token2022(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::instructions::graphql::InitializeWithToken2022GraphQL>> {
let rows: Vec<crate::instructions::postgres::InitializeWithToken2022Row> = sqlx::query_as(
r#"SELECT * FROM initialize_with_token2022_instruction ORDER BY __slot DESC, __signature DESC, __instruction_index ASC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn migrate_to_amm(
context: &crate::graphql::context::GraphQLContext,
signature: String,
instruction_index: i32,
) -> FieldResult<Vec<crate::instructions::graphql::MigrateToAmmGraphQL>> {
let rows: Vec<crate::instructions::postgres::MigrateToAmmRow> = sqlx::query_as(
r#"SELECT * FROM migrate_to_amm_instruction WHERE __signature = $1 AND __instruction_index = $2 ORDER BY __stack_height ASC"#,
)
.bind(signature)
.bind(instruction_index)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn list_migrate_to_amm(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::instructions::graphql::MigrateToAmmGraphQL>> {
let rows: Vec<crate::instructions::postgres::MigrateToAmmRow> = sqlx::query_as(
r#"SELECT * FROM migrate_to_amm_instruction ORDER BY __slot DESC, __signature DESC, __instruction_index ASC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn migrate_to_cpswap(
context: &crate::graphql::context::GraphQLContext,
signature: String,
instruction_index: i32,
) -> FieldResult<Vec<crate::instructions::graphql::MigrateToCpswapGraphQL>> {
let rows: Vec<crate::instructions::postgres::MigrateToCpswapRow> = sqlx::query_as(
r#"SELECT * FROM migrate_to_cpswap_instruction WHERE __signature = $1 AND __instruction_index = $2 ORDER BY __stack_height ASC"#,
)
.bind(signature)
.bind(instruction_index)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn list_migrate_to_cpswap(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::instructions::graphql::MigrateToCpswapGraphQL>> {
let rows: Vec<crate::instructions::postgres::MigrateToCpswapRow> = sqlx::query_as(
r#"SELECT * FROM migrate_to_cpswap_instruction ORDER BY __slot DESC, __signature DESC, __instruction_index ASC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn remove_platform_curve_param(
context: &crate::graphql::context::GraphQLContext,
signature: String,
instruction_index: i32,
) -> FieldResult<Vec<crate::instructions::graphql::RemovePlatformCurveParamGraphQL>> {
let rows: Vec<crate::instructions::postgres::RemovePlatformCurveParamRow> = sqlx::query_as(
r#"SELECT * FROM remove_platform_curve_param_instruction WHERE __signature = $1 AND __instruction_index = $2 ORDER BY __stack_height ASC"#,
)
.bind(signature)
.bind(instruction_index)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn list_remove_platform_curve_param(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::instructions::graphql::RemovePlatformCurveParamGraphQL>> {
let rows: Vec<crate::instructions::postgres::RemovePlatformCurveParamRow> = sqlx::query_as(
r#"SELECT * FROM remove_platform_curve_param_instruction ORDER BY __slot DESC, __signature DESC, __instruction_index ASC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn sell_exact_in(
context: &crate::graphql::context::GraphQLContext,
signature: String,
instruction_index: i32,
) -> FieldResult<Vec<crate::instructions::graphql::SellExactInGraphQL>> {
let rows: Vec<crate::instructions::postgres::SellExactInRow> = sqlx::query_as(
r#"SELECT * FROM sell_exact_in_instruction WHERE __signature = $1 AND __instruction_index = $2 ORDER BY __stack_height ASC"#,
)
.bind(signature)
.bind(instruction_index)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn list_sell_exact_in(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::instructions::graphql::SellExactInGraphQL>> {
let rows: Vec<crate::instructions::postgres::SellExactInRow> = sqlx::query_as(
r#"SELECT * FROM sell_exact_in_instruction ORDER BY __slot DESC, __signature DESC, __instruction_index ASC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn sell_exact_out(
context: &crate::graphql::context::GraphQLContext,
signature: String,
instruction_index: i32,
) -> FieldResult<Vec<crate::instructions::graphql::SellExactOutGraphQL>> {
let rows: Vec<crate::instructions::postgres::SellExactOutRow> = sqlx::query_as(
r#"SELECT * FROM sell_exact_out_instruction WHERE __signature = $1 AND __instruction_index = $2 ORDER BY __stack_height ASC"#,
)
.bind(signature)
.bind(instruction_index)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn list_sell_exact_out(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::instructions::graphql::SellExactOutGraphQL>> {
let rows: Vec<crate::instructions::postgres::SellExactOutRow> = sqlx::query_as(
r#"SELECT * FROM sell_exact_out_instruction ORDER BY __slot DESC, __signature DESC, __instruction_index ASC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn update_config(
context: &crate::graphql::context::GraphQLContext,
signature: String,
instruction_index: i32,
) -> FieldResult<Vec<crate::instructions::graphql::UpdateConfigGraphQL>> {
let rows: Vec<crate::instructions::postgres::UpdateConfigRow> = sqlx::query_as(
r#"SELECT * FROM update_config_instruction WHERE __signature = $1 AND __instruction_index = $2 ORDER BY __stack_height ASC"#,
)
.bind(signature)
.bind(instruction_index)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn list_update_config(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::instructions::graphql::UpdateConfigGraphQL>> {
let rows: Vec<crate::instructions::postgres::UpdateConfigRow> = sqlx::query_as(
r#"SELECT * FROM update_config_instruction ORDER BY __slot DESC, __signature DESC, __instruction_index ASC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn update_platform_config(
context: &crate::graphql::context::GraphQLContext,
signature: String,
instruction_index: i32,
) -> FieldResult<Vec<crate::instructions::graphql::UpdatePlatformConfigGraphQL>> {
let rows: Vec<crate::instructions::postgres::UpdatePlatformConfigRow> = sqlx::query_as(
r#"SELECT * FROM update_platform_config_instruction WHERE __signature = $1 AND __instruction_index = $2 ORDER BY __stack_height ASC"#,
)
.bind(signature)
.bind(instruction_index)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn list_update_platform_config(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::instructions::graphql::UpdatePlatformConfigGraphQL>> {
let rows: Vec<crate::instructions::postgres::UpdatePlatformConfigRow> = sqlx::query_as(
r#"SELECT * FROM update_platform_config_instruction ORDER BY __slot DESC, __signature DESC, __instruction_index ASC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn update_platform_curve_param(
context: &crate::graphql::context::GraphQLContext,
signature: String,
instruction_index: i32,
) -> FieldResult<Vec<crate::instructions::graphql::UpdatePlatformCurveParamGraphQL>> {
let rows: Vec<crate::instructions::postgres::UpdatePlatformCurveParamRow> = sqlx::query_as(
r#"SELECT * FROM update_platform_curve_param_instruction WHERE __signature = $1 AND __instruction_index = $2 ORDER BY __stack_height ASC"#,
)
.bind(signature)
.bind(instruction_index)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn list_update_platform_curve_param(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::instructions::graphql::UpdatePlatformCurveParamGraphQL>> {
let rows: Vec<crate::instructions::postgres::UpdatePlatformCurveParamRow> = sqlx::query_as(
r#"SELECT * FROM update_platform_curve_param_instruction ORDER BY __slot DESC, __signature DESC, __instruction_index ASC LIMIT $1 OFFSET $2"#,
)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
async fn list_cpi_events(
context: &crate::graphql::context::GraphQLContext,
limit: i32,
offset: i32,
) -> FieldResult<Vec<crate::instructions::graphql::CpiEventGraphQL>> {
let rows: Vec<crate::instructions::postgres::CpiEventRow> =
sqlx::query_as(r#"SELECT * FROM cpi_events ORDER BY __slot DESC LIMIT $1 OFFSET $2"#)
.bind(limit)
.bind(offset)
.fetch_all(&*context.pool)
.await
.map_err(|e| juniper::FieldError::new(e.to_string(), juniper::Value::null()))?;
Ok(rows
.into_iter()
.filter_map(|row| row.try_into().ok())
.collect())
}
}