diff --git a/digital_asset_types/src/dao/generated/asset_data.rs b/digital_asset_types/src/dao/generated/asset_data.rs index 814eeeb3a..374ed854a 100644 --- a/digital_asset_types/src/dao/generated/asset_data.rs +++ b/digital_asset_types/src/dao/generated/asset_data.rs @@ -24,6 +24,8 @@ pub struct Model { pub metadata: Json, pub slot_updated: i64, pub reindex: Option, + pub raw_name: Vec, + pub raw_symbol: Vec, } #[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] @@ -36,6 +38,8 @@ pub enum Column { Metadata, SlotUpdated, Reindex, + RawName, + RawSymbol, } #[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] @@ -67,6 +71,8 @@ impl ColumnTrait for Column { Self::Metadata => ColumnType::JsonBinary.def(), Self::SlotUpdated => ColumnType::BigInteger.def(), Self::Reindex => ColumnType::Boolean.def(), + Self::RawName => ColumnType::Binary.def(), + Self::RawSymbol => ColumnType::Binary.def(), } } } diff --git a/digital_asset_types/tests/common.rs b/digital_asset_types/tests/common.rs index f92af81ed..bbe3cf509 100644 --- a/digital_asset_types/tests/common.rs +++ b/digital_asset_types/tests/common.rs @@ -83,6 +83,8 @@ pub fn create_asset_data( metadata: JsonValue::String("processing".to_string()), slot_updated: 0, reindex: None, + raw_name: metadata.name.into_bytes().to_vec().clone(), + raw_symbol: metadata.symbol.into_bytes().to_vec().clone(), }, ) } diff --git a/digital_asset_types/tests/json_parsing.rs b/digital_asset_types/tests/json_parsing.rs index 6dc8dc22c..76fe0572d 100644 --- a/digital_asset_types/tests/json_parsing.rs +++ b/digital_asset_types/tests/json_parsing.rs @@ -34,6 +34,8 @@ pub async fn parse_onchain_json(json: serde_json::Value) -> Content { metadata: json, slot_updated: 0, reindex: None, + raw_name: String::from("Handalf").into_bytes().to_vec(), + raw_symbol: String::from("").into_bytes().to_vec(), }; v1_content_from_json(&asset_data).unwrap() diff --git a/migration/src/lib.rs b/migration/src/lib.rs index eb47577c8..58e454bb5 100644 --- a/migration/src/lib.rs +++ b/migration/src/lib.rs @@ -28,6 +28,7 @@ mod m20230720_120101_add_asset_grouping_verified; mod m20230720_130101_remove_asset_grouping_null_constraints; mod m20230724_120101_add_group_info_seq; mod m20230726_013107_remove_not_null_constraint_from_group_value; +mod m20230918_182123_add_raw_name_symbol; pub struct Migrator; @@ -58,11 +59,12 @@ impl MigratorTrait for Migrator { Box::new(m20230615_120101_remove_asset_null_constraints::Migration), Box::new(m20230620_120101_add_was_decompressed::Migration), Box::new(m20230623_120101_add_leaf_sequence_number::Migration), - Box::new(m20230726_013107_remove_not_null_constraint_from_group_value::Migration), Box::new(m20230712_120101_remove_asset_creators_null_constraints::Migration), Box::new(m20230720_120101_add_asset_grouping_verified::Migration), Box::new(m20230720_130101_remove_asset_grouping_null_constraints::Migration), Box::new(m20230724_120101_add_group_info_seq::Migration), + Box::new(m20230726_013107_remove_not_null_constraint_from_group_value::Migration), + Box::new(m20230918_182123_add_raw_name_symbol::Migration), ] } } diff --git a/migration/src/m20230918_182123_add_raw_name_symbol.rs b/migration/src/m20230918_182123_add_raw_name_symbol.rs new file mode 100644 index 000000000..88d488911 --- /dev/null +++ b/migration/src/m20230918_182123_add_raw_name_symbol.rs @@ -0,0 +1,57 @@ +use sea_orm_migration::prelude::*; + +#[derive(DeriveMigrationName)] +pub struct Migration; + +#[async_trait::async_trait] +impl MigrationTrait for Migration { + async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { + manager + .alter_table( + sea_query::Table::alter() + .table(asset_data::Entity) + .add_column(ColumnDef::new(Alias::new("raw_name")).binary()) + .to_owned(), + ) + .await?; + manager + .alter_table( + sea_query::Table::alter() + .table(asset_data::Entity) + .add_column(ColumnDef::new(Alias::new("raw_symbol")).binary()) + .to_owned(), + ) + .await?; + Ok(()) + } + + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { + manager + .alter_table( + sea_query::Table::alter() + .table(asset_data::Entity) + .drop_column(Alias::new("raw_name")) + .to_owned(), + ) + .await?; + + manager + .alter_table( + sea_query::Table::alter() + .table(asset_data::Entity) + .drop_column(Alias::new("raw_symbol")) + .to_owned(), + ) + .await?; + Ok(()) + } +} + +/// Learn more at https://docs.rs/sea-query#iden +#[derive(Iden)] +enum Post { + Table, + Id, + Title, + Text, +} diff --git a/nft_ingester/src/program_transformers/bubblegum/mint_v1.rs b/nft_ingester/src/program_transformers/bubblegum/mint_v1.rs index c96b8ed6f..fc1b5f8ec 100644 --- a/nft_ingester/src/program_transformers/bubblegum/mint_v1.rs +++ b/nft_ingester/src/program_transformers/bubblegum/mint_v1.rs @@ -62,6 +62,8 @@ where let id_bytes = id.to_bytes(); let slot_i = bundle.slot as i64; let uri = metadata.uri.trim().replace('\0', ""); + let name = metadata.name.clone().into_bytes(); + let symbol = metadata.symbol.clone().into_bytes(); let mut chain_data = ChainDataV1 { name: metadata.name.clone(), symbol: metadata.symbol.clone(), @@ -95,6 +97,8 @@ where metadata_mutability: Set(Mutability::Mutable), slot_updated: Set(slot_i), reindex: Set(Some(true)), + raw_name: Set(name.to_vec()), + raw_symbol: Set(symbol.to_vec()), ..Default::default() }; diff --git a/nft_ingester/src/program_transformers/token_metadata/v1_asset.rs b/nft_ingester/src/program_transformers/token_metadata/v1_asset.rs index 21ff6624c..1b8e51df5 100644 --- a/nft_ingester/src/program_transformers/token_metadata/v1_asset.rs +++ b/nft_ingester/src/program_transformers/token_metadata/v1_asset.rs @@ -163,9 +163,11 @@ pub async fn save_v1_asset( }, None => (NotSet, NotSet), }; + let name = data.name.clone().into_bytes(); + let symbol = data.symbol.clone().into_bytes(); let mut chain_data = ChainDataV1 { - name: data.name, - symbol: data.symbol, + name: data.name.clone(), + symbol: data.symbol.clone(), edition_nonce: metadata.edition_nonce, primary_sale_happened: metadata.primary_sale_happened, token_standard: metadata.token_standard, @@ -191,6 +193,8 @@ pub async fn save_v1_asset( slot_updated: Set(slot_i), reindex: Set(Some(true)), id: Set(id.to_vec()), + raw_name: Set(name.to_vec()), + raw_symbol: Set(symbol.to_vec()), }; let txn = conn.begin().await?; let mut query = asset_data::Entity::insert(asset_data_model)