Skip to content

Commit

Permalink
rename method names and display_options
Browse files Browse the repository at this point in the history
  • Loading branch information
tahsintunan committed Dec 11, 2023
1 parent 8b6dc11 commit 728857c
Show file tree
Hide file tree
Showing 15 changed files with 170 additions and 170 deletions.
38 changes: 26 additions & 12 deletions das_api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,50 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
digital_asset_types = { path = "../digital_asset_types", features = ["json_types", "sql_types"] }
jsonrpsee = {version = "0.16.2", features = ["server", "macros"]}
jsonrpsee-core = {version = "0.16.2", features =["server"]}
tower-http={version = "0.3.5", features = ["full"]}
tower={version="0.4.13", features = ["full"]}
digital_asset_types = { path = "../digital_asset_types", features = [
"json_types",
"sql_types",
] }
jsonrpsee = { version = "0.16.2", features = ["server", "macros"] }
jsonrpsee-core = { version = "0.16.2", features = ["server"] }
tower-http = { version = "0.3.5", features = ["full"] }
tower = { version = "0.4.13", features = ["full"] }
hyper = "0.14.23"
tracing = "0.1.35"
metrics = "0.20.1"
figment = { version = "0.10.6", features = ["env"] }
serde = "1.0.137"
thiserror = "1.0.31"
tokio = {version="1.23.0"}
tokio = { version = "1.23.0" }
async-trait = "0.1.56"
serde_json = "1.0.81"
cadence = "0.29.0"
cadence-macros = "0.29.0"
sqlx = { version = "0.6.2", features = ["macros", "runtime-tokio-rustls", "postgres", "uuid", "offline", "json"] }
sea-orm = { version = "0.10.6", features = ["macros", "runtime-tokio-rustls", "sqlx-postgres"] }
sqlx = { version = "0.6.2", features = [
"macros",
"runtime-tokio-rustls",
"postgres",
"uuid",
"offline",
"json",
] }
sea-orm = { version = "0.10.6", features = [
"macros",
"runtime-tokio-rustls",
"sqlx-postgres",
] }
tokio-postgres = "0.7.7"
solana-sdk = "~1.16.16"
bs58 = "0.4.0"
log = "0.4.17"
env_logger = "0.10"
schemars = "0.8.6"
schemars_derive = "0.8.6"
open-rpc-derive = { version = "0.0.4"}
open-rpc-schema = { version = "0.0.4"}
open-rpc-derive = { version = "0.0.4" }
open-rpc-schema = { version = "0.0.4" }
blockbuster = { git = "https://github.com/metaplex-foundation/blockbuster.git", rev = "e5d96d62969af42ce1c7f10cca88dc1c4f643598" }
anchor-lang = "0.28.0"
mpl-token-metadata = { version = "=2.0.0-beta.1", features = ["serde-feature"] }
mpl-token-metadata = { version = "=2.0.0-beta.1", features = ["serde-feature"] }
mpl-candy-machine-core = { version = "2.0.1", features = ["no-entrypoint"] }
mpl-bubblegum = "=1.0.1-beta.2"
mpl-candy-guard = { version = "2.0.0", features = ["no-entrypoint"] }
mpl-candy-guard = { version = "2.0.0", features = ["no-entrypoint"] }
72 changes: 33 additions & 39 deletions das_api/src/api/api_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,11 @@ impl ApiContract for DasApi {
.map_err(Into::into)
}

async fn get_asset_proof_batch(
async fn get_asset_proofs(
self: &DasApi,
payload: GetAssetProofBatch,
payload: GetAssetProofs,
) -> Result<HashMap<String, Option<AssetProof>>, DasApiError> {
let GetAssetProofBatch { ids } = payload;
let GetAssetProofs { ids } = payload;

let batch_size = ids.len();
if batch_size > 1000 {
Expand All @@ -258,31 +258,25 @@ impl ApiContract for DasApi {
}

async fn get_asset(self: &DasApi, payload: GetAsset) -> Result<Asset, DasApiError> {
let GetAsset {
id,
display_options,
} = payload;
let GetAsset { id, options } = payload;
let id_bytes = validate_pubkey(id.clone())?.to_bytes().to_vec();
let mut display_options = display_options.unwrap_or_default();
display_options.cdn_prefix = self.cdn_prefix.clone();
let mut options = options.unwrap_or_default();
options.cdn_prefix = self.cdn_prefix.clone();
get_asset(
&self.db_connection,
id_bytes,
&self.feature_flags,
&display_options.into(),
&options.into(),
)
.await
.map_err(Into::into)
}

async fn get_asset_batch(
async fn get_assets(
self: &DasApi,
payload: GetAssetBatch,
payload: GetAssets,
) -> Result<Vec<Option<Asset>>, DasApiError> {
let GetAssetBatch {
ids,
display_options,
} = payload;
let GetAssets { ids, options } = payload;

let batch_size = ids.len();
if batch_size > 1000 {
Expand All @@ -294,14 +288,14 @@ impl ApiContract for DasApi {
.map(|id| validate_pubkey(id.clone()).map(|id| id.to_bytes().to_vec()))
.collect::<Result<Vec<Vec<u8>>, _>>()?;

let mut display_options = display_options.unwrap_or_default();
display_options.cdn_prefix = self.cdn_prefix.clone();
let mut options = options.unwrap_or_default();
options.cdn_prefix = self.cdn_prefix.clone();

let assets = get_asset_batch(
&self.db_connection,
id_bytes,
batch_size as u64,
&display_options.into(),
&options.into(),
)
.await?;

Expand All @@ -320,7 +314,7 @@ impl ApiContract for DasApi {
page,
before,
after,
display_options,
options,
cursor,
} = payload;
let before: Option<String> = before.filter(|before| !before.is_empty());
Expand All @@ -330,15 +324,15 @@ impl ApiContract for DasApi {
let sort_by = sort_by.unwrap_or_default();
let page_options =
self.validate_pagination(&limit, &page, &before, &after, &cursor, &Some(&sort_by))?;
let mut display_options = display_options.unwrap_or_default();
display_options.cdn_prefix = self.cdn_prefix.clone();
let mut options = options.unwrap_or_default();
options.cdn_prefix = self.cdn_prefix.clone();
get_assets_by_owner(
&self.db_connection,
owner_address_bytes,
sort_by,
&page_options,
&self.feature_flags,
&display_options,
&options,
)
.await
.map_err(Into::into)
Expand All @@ -356,7 +350,7 @@ impl ApiContract for DasApi {
page,
before,
after,
display_options,
options,
cursor,
} = payload;
self.validate_sorting_for_collection(&group_key, &group_value, &sort_by)?;
Expand All @@ -365,15 +359,15 @@ impl ApiContract for DasApi {
let sort_by = sort_by.unwrap_or_default();
let page_options =
self.validate_pagination(&limit, &page, &before, &after, &cursor, &Some(&sort_by))?;
let mut display_options = display_options.unwrap_or_default();
display_options.cdn_prefix = self.cdn_prefix.clone();
let mut options = options.unwrap_or_default();
options.cdn_prefix = self.cdn_prefix.clone();
get_assets_by_group(
&self.db_connection,
group_value,
sort_by,
&page_options,
&self.feature_flags,
&display_options,
&options,
)
.await
.map_err(Into::into)
Expand All @@ -391,7 +385,7 @@ impl ApiContract for DasApi {
page,
before,
after,
display_options,
options,
cursor,
} = payload;
let creator_address = validate_pubkey(creator_address.clone())?;
Expand All @@ -401,16 +395,16 @@ impl ApiContract for DasApi {
let page_options =
self.validate_pagination(&limit, &page, &before, &after, &cursor, &Some(&sort_by))?;
let only_verified = only_verified.unwrap_or_default();
let mut display_options = display_options.unwrap_or_default();
display_options.cdn_prefix = self.cdn_prefix.clone();
let mut options = options.unwrap_or_default();
options.cdn_prefix = self.cdn_prefix.clone();
get_assets_by_creator(
&self.db_connection,
creator_address_bytes,
only_verified,
sort_by,
&page_options,
&self.feature_flags,
&display_options,
&options,
)
.await
.map_err(Into::into)
Expand All @@ -427,23 +421,23 @@ impl ApiContract for DasApi {
page,
before,
after,
display_options,
options,
cursor,
} = payload;
let authority_address = validate_pubkey(authority_address.clone())?;
let authority_address_bytes = authority_address.to_bytes().to_vec();
let sort_by = sort_by.unwrap_or_default();
let page_options =
self.validate_pagination(&limit, &page, &before, &after, &cursor, &Some(&sort_by))?;
let mut display_options = display_options.unwrap_or_default();
display_options.cdn_prefix = self.cdn_prefix.clone();
let mut options = options.unwrap_or_default();
options.cdn_prefix = self.cdn_prefix.clone();
get_assets_by_authority(
&self.db_connection,
authority_address_bytes,
sort_by,
&page_options,
&self.feature_flags,
&display_options,
&options,
)
.await
.map_err(Into::into)
Expand Down Expand Up @@ -477,7 +471,7 @@ impl ApiContract for DasApi {
before,
after,
json_uri,
display_options,
options,
cursor,
name,
} = payload;
Expand Down Expand Up @@ -535,16 +529,16 @@ impl ApiContract for DasApi {
let sort_by = sort_by.unwrap_or_default();
let page_options =
self.validate_pagination(&limit, &page, &before, &after, &cursor, &Some(&sort_by))?;
let mut display_options = display_options.unwrap_or_default();
display_options.cdn_prefix = self.cdn_prefix.clone();
let mut options = options.unwrap_or_default();
options.cdn_prefix = self.cdn_prefix.clone();
// Execute query
search_assets(
&self.db_connection,
saq,
sort_by,
&page_options,
&self.feature_flags,
&display_options,
&options,
)
.await
.map_err(Into::into)
Expand Down
Loading

0 comments on commit 728857c

Please sign in to comment.