Skip to content

Commit

Permalink
Revert "store data as is in the database (#44)"
Browse files Browse the repository at this point in the history
This reverts commit 2c453f6.
  • Loading branch information
NicolasPennie committed Jun 6, 2023
1 parent 7d9bb2b commit 8a2776f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
19 changes: 2 additions & 17 deletions digital_asset_types/src/dapi/common/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,6 @@ pub fn safe_select<'a>(
.and_then(|v| v.pop())
}

fn sanitize(val: Value) -> Result<String, &'static str> {
match val {
Value::String(s) => Ok(s.trim().replace("\0", "").to_string()),
_ => Err("Provided value is not a string"),
}
}

pub fn v1_content_from_json(
asset_data: &asset_data::Model,
cdn_prefix: Option<String>,
Expand All @@ -148,23 +141,15 @@ pub fn v1_content_from_json(
let mut meta: MetadataMap = MetadataMap::new();
let name = safe_select(chain_data_selector, "$.name");
if let Some(name) = name {
if let Ok(name) = sanitize(name.clone()) {
meta.set_item("name", Value::String(name));
} else {
meta.set_item("name", name.clone());
}
meta.set_item("name", name.clone());
}
let desc = safe_select(selector, "$.description");
if let Some(desc) = desc {
meta.set_item("description", desc.clone());
}
let symbol = safe_select(chain_data_selector, "$.symbol");
if let Some(symbol) = symbol {
if let Ok(symbol) = sanitize(symbol.clone()) {
meta.set_item("symbol", Value::String(symbol));
} else {
meta.set_item("symbol", symbol.clone());
}
meta.set_item("symbol", symbol.clone());
}
let symbol = safe_select(selector, "$.attributes");
if let Some(symbol) = symbol {
Expand Down
3 changes: 2 additions & 1 deletion nft_ingester/src/program_transformers/bubblegum/mint_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ where
let id_bytes = id.to_bytes();
let slot_i = bundle.slot as i64;
let uri = metadata.uri.trim().replace('\0', "");
let chain_data = ChainDataV1 {
let mut chain_data = ChainDataV1 {
name: metadata.name.clone(),
symbol: metadata.symbol.clone(),
edition_nonce: metadata.edition_nonce,
Expand All @@ -73,6 +73,7 @@ where
total: u.total,
}),
};
chain_data.sanitize();
let chain_data_json = serde_json::to_value(chain_data)
.map_err(|e| IngesterError::DeserializationError(e.to_string()))?;
let chain_mutability = match metadata.is_mutable {
Expand Down

0 comments on commit 8a2776f

Please sign in to comment.