@@ -6,7 +6,7 @@ use std::time::{SystemTime, UNIX_EPOCH};
66use cainome:: cairo_serde:: { ByteArray , CairoSerde } ;
77use dojo_types:: schema:: { Struct , Ty } ;
88use erc:: {
9- store_token_attributes, update_contract_traits_from_metadata,
9+ extract_name_from_metadata , store_token_attributes, update_contract_traits_from_metadata,
1010 update_contract_traits_on_metadata_change, UpdateTokenMetadataQuery ,
1111} ;
1212use metrics:: { counter, histogram} ;
@@ -969,7 +969,7 @@ impl<P: Provider + Sync + Send + Clone + 'static> Executor<'_, P> {
969969
970970 // If we find a token already registered for this contract_address we dont need to
971971 // refetch the data since its same for all tokens of this contract
972- let ( name , symbol) = match res {
972+ let ( contract_name , symbol) = match res {
973973 Ok ( ( name, symbol) ) => {
974974 debug ! (
975975 target: LOG_TARGET ,
@@ -1058,6 +1058,10 @@ impl<P: Provider + Sync + Send + Clone + 'static> Executor<'_, P> {
10581058 }
10591059 } ;
10601060
1061+ // Try to get name from token metadata, fallback to contract name
1062+ let name = extract_name_from_metadata ( & register_nft_token. metadata )
1063+ . unwrap_or ( contract_name) ;
1064+
10611065 let query = sqlx:: query_as :: < _ , torii_sqlite_types:: Token > (
10621066 "INSERT INTO tokens (id, contract_address, token_id, name, symbol, decimals, \
10631067 metadata, total_supply, traits) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING *",
0 commit comments