Skip to content

Commit

Permalink
Intermediate commit (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmantica11 authored Nov 16, 2024
1 parent 380ea2a commit 0273820
Show file tree
Hide file tree
Showing 32 changed files with 267 additions and 62 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion 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.48.0"
version = "0.49.0"

[[bin]]
name = "photon"
Expand Down
16 changes: 14 additions & 2 deletions src/api/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use super::method::get_compressed_mint_token_holders::{
get_compressed_mint_token_holders, GetCompressedMintTokenHoldersRequest, OwnerBalancesResponse,
};
use super::method::get_compressed_token_balances_by_owner::{
get_compressed_token_balances_by_owner, GetCompressedTokenBalancesByOwnerRequest,
TokenBalancesResponse,
get_compressed_token_balances_by_owner, get_compressed_token_balances_by_owner_v2,
GetCompressedTokenBalancesByOwnerRequest, TokenBalancesResponse, TokenBalancesResponseV2,
};
use super::method::get_compression_signatures_for_account::get_compression_signatures_for_account;
use super::method::get_compression_signatures_for_address::{
Expand Down Expand Up @@ -184,6 +184,13 @@ impl PhotonApi {
get_compressed_token_balances_by_owner(&self.db_conn, request).await
}

pub async fn get_compressed_token_balances_by_owner_v2(
&self,
request: GetCompressedTokenBalancesByOwnerRequest,
) -> Result<TokenBalancesResponseV2, PhotonApiError> {
get_compressed_token_balances_by_owner_v2(&self.db_conn, request).await
}

pub async fn get_compressed_token_account_balance(
&self,
request: CompressedAccountRequest,
Expand Down Expand Up @@ -311,6 +318,11 @@ impl PhotonApi {
request: Some(GetCompressedTokenBalancesByOwnerRequest::schema().1),
response: TokenBalancesResponse::schema().1,
},
OpenApiSpec {
name: "getCompressedTokenBalancesByOwnerV2".to_string(),
request: Some(GetCompressedTokenBalancesByOwnerRequest::schema().1),
response: TokenBalancesResponseV2::schema().1,
},
OpenApiSpec {
name: "getCompressedAccountsByOwner".to_string(),
request: Some(GetCompressedAccountsByOwnerRequest::schema().1),
Expand Down
38 changes: 33 additions & 5 deletions src/api/method/get_compressed_token_balances_by_owner.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

use sea_orm::{ColumnTrait, DatabaseConnection, EntityTrait, QueryFilter, QueryOrder, QuerySelect};
use serde::{Deserialize, Serialize};
use utoipa::ToSchema;
Expand All @@ -8,11 +7,8 @@ use crate::common::typedefs::serializable_pubkey::SerializablePubkey;
use crate::common::typedefs::unsigned_integer::UnsignedInteger;
use crate::dao::generated::token_owner_balances;

use super::utils::{
parse_decimal, Context, Limit,
PAGE_LIMIT,
};
use super::super::error::PhotonApiError;
use super::utils::{parse_decimal, Context, Limit, PAGE_LIMIT};

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
pub struct TokenBalance {
Expand Down Expand Up @@ -108,3 +104,35 @@ pub async fn get_compressed_token_balances_by_owner(
context,
})
}

// We do not use generics to simplify documentation generation.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
#[serde(deny_unknown_fields, rename_all = "camelCase")]
pub struct TokenBalancesResponseV2 {
pub context: Context,
pub value: TokenBalanceListV2,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
pub struct TokenBalanceListV2 {
pub items: Vec<TokenBalance>,
pub cursor: Option<Base58String>,
}

pub async fn get_compressed_token_balances_by_owner_v2(
conn: &DatabaseConnection,
request: GetCompressedTokenBalancesByOwnerRequest,
) -> Result<TokenBalancesResponseV2, PhotonApiError> {
let response = get_compressed_token_balances_by_owner(conn, request).await?;
let context = response.context;
let token_balance_list = response.value;
let token_balances = token_balance_list.token_balances;
let cursor = token_balance_list.cursor;
Ok(TokenBalancesResponseV2 {
value: TokenBalanceListV2 {
items: token_balances,
cursor,
},
context,
})
}
11 changes: 11 additions & 0 deletions src/api/rpc_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,5 +302,16 @@ fn build_rpc_module(api_and_indexer: PhotonApi) -> Result<RpcModule<PhotonApi>,
},
)?;

module.register_async_method(
"getCompressedTokenBalancesByOwnerV2",
|rpc_params, rpc_context| async move {
let api = rpc_context.as_ref();
let payload = rpc_params.parse()?;
api.get_compressed_token_balances_by_owner_v2(payload)
.await
.map_err(Into::into)
},
)?;

Ok(module)
}
2 changes: 2 additions & 0 deletions src/openapi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::api::method::get_compressed_mint_token_holders::OwnerBalancesResponse
use crate::api::method::get_compressed_token_account_balance::TokenAccountBalance;
use crate::api::method::get_compressed_token_balances_by_owner::TokenBalance;
use crate::api::method::get_compressed_token_balances_by_owner::TokenBalanceList;
use crate::api::method::get_compressed_token_balances_by_owner::TokenBalanceListV2;
use crate::api::method::get_multiple_compressed_accounts::AccountList;

use crate::api::method::get_multiple_new_address_proofs::AddressListWithTrees;
Expand Down Expand Up @@ -108,6 +109,7 @@ const JSON_CONTENT_TYPE: &str = "application/json";
OwnerBalance,
OwnerBalanceList,
OwnerBalancesResponse,
TokenBalanceListV2,
)))]
struct ApiDoc;

Expand Down
2 changes: 1 addition & 1 deletion src/openapi/specs/getCompressedAccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ info:
description: Solana indexer for general compression
license:
name: Apache-2.0
version: 0.47.0
version: 0.49.0
servers:
- url: https://mainnet.helius-rpc.com?api-key=<api_key>
paths:
Expand Down
2 changes: 1 addition & 1 deletion src/openapi/specs/getCompressedAccountBalance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ info:
description: Solana indexer for general compression
license:
name: Apache-2.0
version: 0.47.0
version: 0.49.0
servers:
- url: https://mainnet.helius-rpc.com?api-key=<api_key>
paths:
Expand Down
6 changes: 3 additions & 3 deletions src/openapi/specs/getCompressedAccountProof.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ info:
description: Solana indexer for general compression
license:
name: Apache-2.0
version: 0.47.0
version: 0.49.0
servers:
- url: https://mainnet.helius-rpc.com?api-key=<api_key>
paths:
Expand Down Expand Up @@ -126,5 +126,5 @@ components:
SerializablePubkey:
type: string
description: A Solana public key represented as a base58 string.
default: 11111116djSnXB2wXVGT4xDLsfTnkp1p4cCxHAfRq
example: 11111116djSnXB2wXVGT4xDLsfTnkp1p4cCxHAfRq
default: 11111117353mdUKehx9GW6JNHznGt5oSZs9fWkVkB
example: 11111117353mdUKehx9GW6JNHznGt5oSZs9fWkVkB
6 changes: 3 additions & 3 deletions src/openapi/specs/getCompressedAccountsByOwner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ info:
description: Solana indexer for general compression
license:
name: Apache-2.0
version: 0.47.0
version: 0.49.0
servers:
- url: https://mainnet.helius-rpc.com?api-key=<api_key>
paths:
Expand Down Expand Up @@ -212,8 +212,8 @@ components:
SerializablePubkey:
type: string
description: A Solana public key represented as a base58 string.
default: 11111114DhpssPJgSi1YU7hCMfYt1BJ334YgsffXm
example: 11111114DhpssPJgSi1YU7hCMfYt1BJ334YgsffXm
default: 11111114d3RrygbPdAtMuFnDmzsN8T5fYKVQ7FVr7
example: 11111114d3RrygbPdAtMuFnDmzsN8T5fYKVQ7FVr7
UnsignedInteger:
type: integer
default: 100
Expand Down
2 changes: 1 addition & 1 deletion src/openapi/specs/getCompressedBalanceByOwner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ info:
description: Solana indexer for general compression
license:
name: Apache-2.0
version: 0.47.0
version: 0.49.0
servers:
- url: https://mainnet.helius-rpc.com?api-key=<api_key>
paths:
Expand Down
6 changes: 3 additions & 3 deletions src/openapi/specs/getCompressedMintTokenHolders.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ info:
description: Solana indexer for general compression
license:
name: Apache-2.0
version: 0.47.0
version: 0.49.0
servers:
- url: https://mainnet.helius-rpc.com?api-key=<api_key>
paths:
Expand Down Expand Up @@ -132,8 +132,8 @@ components:
SerializablePubkey:
type: string
description: A Solana public key represented as a base58 string.
default: 11111114d3RrygbPdAtMuFnDmzsN8T5fYKVQ7FVr7
example: 11111114d3RrygbPdAtMuFnDmzsN8T5fYKVQ7FVr7
default: 111111152P2r5yt6odmBLPsFCLBrFisJ3aS7LqLAT
example: 111111152P2r5yt6odmBLPsFCLBrFisJ3aS7LqLAT
UnsignedInteger:
type: integer
default: 100
Expand Down
2 changes: 1 addition & 1 deletion src/openapi/specs/getCompressedTokenAccountBalance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ info:
description: Solana indexer for general compression
license:
name: Apache-2.0
version: 0.47.0
version: 0.49.0
servers:
- url: https://mainnet.helius-rpc.com?api-key=<api_key>
paths:
Expand Down
6 changes: 3 additions & 3 deletions src/openapi/specs/getCompressedTokenAccountsByDelegate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ info:
description: Solana indexer for general compression
license:
name: Apache-2.0
version: 0.47.0
version: 0.49.0
servers:
- url: https://mainnet.helius-rpc.com?api-key=<api_key>
paths:
Expand Down Expand Up @@ -173,8 +173,8 @@ components:
SerializablePubkey:
type: string
description: A Solana public key represented as a base58 string.
default: 11111115q4EpJaTXAZWpCg3J2zppWGSZ46KXozzo9
example: 11111115q4EpJaTXAZWpCg3J2zppWGSZ46KXozzo9
default: 11111116EPqoQskEM2Pddp8KTL9JdYEBZMGF3aq7V
example: 11111116EPqoQskEM2Pddp8KTL9JdYEBZMGF3aq7V
TokenAcccount:
type: object
required:
Expand Down
6 changes: 3 additions & 3 deletions src/openapi/specs/getCompressedTokenAccountsByOwner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ info:
description: Solana indexer for general compression
license:
name: Apache-2.0
version: 0.47.0
version: 0.49.0
servers:
- url: https://mainnet.helius-rpc.com?api-key=<api_key>
paths:
Expand Down Expand Up @@ -173,8 +173,8 @@ components:
SerializablePubkey:
type: string
description: A Solana public key represented as a base58 string.
default: 11111115RidqCHAoz6dzmXxGcfWLNzevYqNpaRAUo
example: 11111115RidqCHAoz6dzmXxGcfWLNzevYqNpaRAUo
default: 11111115q4EpJaTXAZWpCg3J2zppWGSZ46KXozzo9
example: 11111115q4EpJaTXAZWpCg3J2zppWGSZ46KXozzo9
TokenAcccount:
type: object
required:
Expand Down
2 changes: 1 addition & 1 deletion src/openapi/specs/getCompressedTokenBalancesByOwner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ info:
description: Solana indexer for general compression
license:
name: Apache-2.0
version: 0.47.0
version: 0.49.0
servers:
- url: https://mainnet.helius-rpc.com?api-key=<api_key>
paths:
Expand Down
Loading

0 comments on commit 0273820

Please sign in to comment.