@@ -12,13 +12,12 @@ use mvr_types::name::Name;
1212use mvr_types:: name_service:: Domain ;
1313use std:: str:: FromStr ;
1414use std:: sync:: Arc ;
15- use sui_indexer_alt_framework:: pipeline:: concurrent:: Handler ;
1615use sui_indexer_alt_framework:: pipeline:: Processor ;
17- use sui_pg_db:: { Connection , Db } ;
16+ use sui_indexer_alt_framework:: postgres:: { handler:: Handler , Connection } ;
17+ use sui_indexer_alt_framework:: types:: full_checkpoint_content:: Checkpoint ;
1818use sui_sdk_types:: StructTag ;
1919use sui_types:: base_types:: MoveObjectType ;
2020use sui_types:: dynamic_field:: Field ;
21- use sui_types:: full_checkpoint_content:: CheckpointData ;
2221
2322pub struct NameRecordHandler {
2423 type_ : MoveObjectType ,
@@ -53,8 +52,6 @@ impl NameRecordHandler {
5352}
5453#[ async_trait]
5554impl Handler for NameRecordHandler {
56- type Store = Db ;
57-
5855 async fn commit < ' a > (
5956 values : & [ Self :: Value ] ,
6057 conn : & mut Connection < ' a > ,
@@ -83,44 +80,46 @@ impl Handler for NameRecordHandler {
8380 }
8481}
8582
83+ #[ async_trait]
8684impl Processor for NameRecordHandler {
8785 const NAME : & ' static str = "NameRecord" ;
8886 type Value = NameRecord ;
8987
90- fn process ( & self , checkpoint : & Arc < CheckpointData > ) -> anyhow:: Result < Vec < Self :: Value > > {
88+ async fn process ( & self , checkpoint : & Arc < Checkpoint > ) -> anyhow:: Result < Vec < Self :: Value > > {
9189 checkpoint
9290 . transactions
9391 . iter ( )
9492 . try_fold ( vec ! [ ] , |result, tx| {
95- tx. output_objects . iter ( ) . try_fold ( result, |mut result, o| {
96- // TODO: do we need to check if the parent of the DF table entry is the MVR registry?
97- if matches ! ( o. type_( ) , Some ( t) if t == & self . type_) {
98- if let Some ( move_obj) = o. data . try_as_move ( ) {
99- let data: Field < Name , AppRecord > =
100- bcs:: from_bytes ( move_obj. contents ( ) ) ?;
101- let Name { org, app } = data. name ;
102- let name = Name :: new ( Domain { labels : org. labels } , app) ;
103- let AppRecord {
104- app_info,
105- networks,
106- metadata,
107- ..
108- } = data. value ;
93+ tx. output_objects ( & checkpoint. object_set )
94+ . try_fold ( result, |mut result, o| {
95+ // TODO: do we need to check if the parent of the DF table entry is the MVR registry?
96+ if matches ! ( o. type_( ) , Some ( t) if t == & self . type_) {
97+ if let Some ( move_obj) = o. data . try_as_move ( ) {
98+ let data: Field < Name , AppRecord > =
99+ bcs:: from_bytes ( move_obj. contents ( ) ) ?;
100+ let Name { org, app } = data. name ;
101+ let name = Name :: new ( Domain { labels : org. labels } , app) ;
102+ let AppRecord {
103+ app_info,
104+ networks,
105+ metadata,
106+ ..
107+ } = data. value ;
109108
110- result. push ( NameRecord {
111- name : name. to_string ( ) ,
112- object_version : o. version ( ) . value ( ) as i64 ,
113- mainnet_id : app_info
114- . and_then ( |info| Some ( info. package_info_id ?. to_string ( ) ) ) ,
115- testnet_id : networks
116- . get ( & TESTNET_CHAIN_ID . to_string ( ) )
117- . and_then ( |info| Some ( info. package_info_id ?. to_string ( ) ) ) ,
118- metadata : serde_json:: to_value ( into_hash_map ( metadata) ) ?,
119- } )
109+ result. push ( NameRecord {
110+ name : name. to_string ( ) ,
111+ object_version : o. version ( ) . value ( ) as i64 ,
112+ mainnet_id : app_info
113+ . and_then ( |info| Some ( info. package_info_id ?. to_string ( ) ) ) ,
114+ testnet_id : networks
115+ . get ( & TESTNET_CHAIN_ID . to_string ( ) )
116+ . and_then ( |info| Some ( info. package_info_id ?. to_string ( ) ) ) ,
117+ metadata : serde_json:: to_value ( into_hash_map ( metadata) ) ?,
118+ } )
119+ }
120120 }
121- }
122- Ok ( result)
123- } )
121+ Ok ( result)
122+ } )
124123 } )
125124 }
126125}
0 commit comments