From 8a2776fa4bbe50e9e96d190b56147733ea8afdb0 Mon Sep 17 00:00:00 2001 From: Nicolas Pennie Date: Mon, 5 Jun 2023 19:59:58 -0700 Subject: [PATCH] Revert "store data as is in the database (#44)" This reverts commit 2c453f6d39f80ea3a8ef99c6f2f7d801fe6768e6. --- digital_asset_types/src/dapi/common/asset.rs | 19 ++----------------- .../program_transformers/bubblegum/mint_v1.rs | 3 ++- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/digital_asset_types/src/dapi/common/asset.rs b/digital_asset_types/src/dapi/common/asset.rs index add8b6a77..34af49868 100644 --- a/digital_asset_types/src/dapi/common/asset.rs +++ b/digital_asset_types/src/dapi/common/asset.rs @@ -127,13 +127,6 @@ pub fn safe_select<'a>( .and_then(|v| v.pop()) } -fn sanitize(val: Value) -> Result { - 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, @@ -148,11 +141,7 @@ 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 { @@ -160,11 +149,7 @@ pub fn v1_content_from_json( } 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 { diff --git a/nft_ingester/src/program_transformers/bubblegum/mint_v1.rs b/nft_ingester/src/program_transformers/bubblegum/mint_v1.rs index 748112e62..5f6fddbff 100644 --- a/nft_ingester/src/program_transformers/bubblegum/mint_v1.rs +++ b/nft_ingester/src/program_transformers/bubblegum/mint_v1.rs @@ -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, @@ -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 {