Skip to content
Closed
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ test-ledger/
minio
test.db
docker-compose.yml

photon.log
86 changes: 60 additions & 26 deletions Cargo.lock

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

20 changes: 15 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "photon-indexer"
publish = true
readme = "README.md"
repository = "https://github.com/helius-labs/photon"
version = "0.51.0"
version = "0.52.4"

[[bin]]
name = "photon"
Expand Down Expand Up @@ -82,11 +82,21 @@ solana-pubkey = "2.3.0"
solana-transaction-status = "1.18.0"

light-concurrent-merkle-tree = "2.1.0"
light-batched-merkle-tree = "0.3.0"
light-merkle-tree-metadata = "0.3.0"
light-compressed-account = { version = "0.3.0", features = ["anchor"] }
light-hasher = { version = "3.1.0" }

# light-batched-merkle-tree = "0.3.0"
# light-merkle-tree-metadata = "0.3.0"
# light-compressed-account = { version = "0.3.0", features = ["anchor"] }

light-batched-merkle-tree = { version = "0.3.0", git = "https://github.com/lightprotocol/light-protocol", rev = "e3f0863db" }
light-merkle-tree-metadata = { version = "0.3.0", git = "https://github.com/lightprotocol/light-protocol", rev = "e3f0863db" }
light-compressed-account = { version = "0.3.0", features = [ "anchor"], git = "https://github.com/lightprotocol/light-protocol", rev = "e3f0863db" }

# light-batched-merkle-tree = { path = "../light-protocol/program-libs/batched-merkle-tree" }
# light-merkle-tree-metadata = { path = "../light-protocol/program-libs/merkle-tree-metadata" }
# light-compressed-account = { features = ["anchor"], path = "../light-protocol/program-libs/compressed-account" }


light-hasher = { version = "3.1.0" }
light-poseidon = "0.3.0"

sqlx = { version = "0.6.2", features = [
Expand Down
3 changes: 1 addition & 2 deletions src/api/method/get_compressed_account_balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::common::typedefs::context::Context;
use crate::common::typedefs::unsigned_integer::UnsignedInteger;
use crate::dao::generated::accounts;
use sea_orm::{DatabaseConnection, EntityTrait, QueryFilter, QuerySelect};
use sqlx::types::Decimal;

pub async fn get_compressed_account_balance(
conn: &DatabaseConnection,
Expand All @@ -22,7 +21,7 @@ pub async fn get_compressed_account_balance(
.one(conn)
.await?
.map(|x| x.lamports)
.unwrap_or(Decimal::from(0));
.unwrap_or_else(|| "0".to_string());

Ok(AccountBalanceResponse {
value: UnsignedInteger(parse_decimal(balance)?),
Expand Down
2 changes: 1 addition & 1 deletion src/api/method/get_compressed_balance_by_owner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub async fn get_compressed_balance_by_owner(
.into_model::<LamportModel>()
.all(conn)
.await?
.iter()
.into_iter()
.map(|x| parse_decimal(x.lamports))
.collect::<Result<Vec<u64>, PhotonApiError>>()?;

Expand Down
3 changes: 2 additions & 1 deletion src/api/method/get_compressed_mint_token_holders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::common::typedefs::bs58_string::Base58String;
use crate::common::typedefs::context::Context;
use crate::common::typedefs::limit::Limit;
use crate::common::typedefs::serializable_pubkey::SerializablePubkey;
use crate::common::typedefs::unsigned_integer::UnsignedInteger;
use crate::common::typedefs::unsigned_integer::{serialize_u64_as_string, UnsignedInteger};
use crate::dao::generated::token_owner_balances;

use super::super::error::PhotonApiError;
Expand All @@ -16,6 +16,7 @@ use super::utils::{parse_decimal, PAGE_LIMIT};
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
pub struct OwnerBalance {
pub owner: SerializablePubkey,
#[serde(serialize_with = "serialize_u64_as_string")]
pub balance: UnsignedInteger,
}

Expand Down
6 changes: 3 additions & 3 deletions src/api/method/get_compressed_token_account_balance.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::common::typedefs::unsigned_integer::UnsignedInteger;
use crate::common::typedefs::unsigned_integer::{serialize_u64_as_string, UnsignedInteger};
use crate::dao::generated::token_accounts;
use sea_orm::{DatabaseConnection, EntityTrait, QueryFilter, QuerySelect};
use serde::{Deserialize, Serialize};
Expand All @@ -7,14 +7,14 @@ use super::super::error::PhotonApiError;
use super::utils::{parse_decimal, AccountDataTable};
use super::utils::{BalanceModel, CompressedAccountRequest};
use crate::common::typedefs::context::Context;
use sqlx::types::Decimal;
use utoipa::ToSchema;

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
#[serde(deny_unknown_fields, rename_all = "camelCase")]
// This is a struct because in the future we might add other fields here like decimals or uiAmount,
// which is a string representation with decimals in the form of "10.00"
pub struct TokenAccountBalance {
#[serde(serialize_with = "serialize_u64_as_string")]
pub amount: UnsignedInteger,
}

Expand All @@ -40,7 +40,7 @@ pub async fn get_compressed_token_account_balance(
.one(conn)
.await?
.map(|x| x.amount)
.unwrap_or(Decimal::from(0));
.unwrap_or_else(|| "0".to_string());

Ok(GetCompressedTokenAccountBalanceResponse {
value: TokenAccountBalance {
Expand Down
3 changes: 2 additions & 1 deletion src/api/method/get_compressed_token_balances_by_owner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::common::typedefs::bs58_string::Base58String;
use crate::common::typedefs::context::Context;
use crate::common::typedefs::limit::Limit;
use crate::common::typedefs::serializable_pubkey::SerializablePubkey;
use crate::common::typedefs::unsigned_integer::UnsignedInteger;
use crate::common::typedefs::unsigned_integer::{serialize_u64_as_string, UnsignedInteger};
use crate::dao::generated::token_owner_balances;

use super::super::error::PhotonApiError;
Expand All @@ -15,6 +15,7 @@ use super::utils::{parse_decimal, PAGE_LIMIT};
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
pub struct TokenBalance {
pub mint: SerializablePubkey,
#[serde(serialize_with = "serialize_u64_as_string")]
pub balance: UnsignedInteger,
}

Expand Down
Loading