@@ -76,13 +76,14 @@ export default function () {
7676 // upsert domain
7777 await context . db
7878 . insert ( schema . v1Domain )
79- . values ( {
80- id : domainId ,
81- parentId,
82- labelHash,
83- } )
79+ . values ( { id : domainId , parentId, labelHash } )
8480 . onConflictDoNothing ( ) ;
8581
82+ // update rootRegistryOwner
83+ await context . db
84+ . update ( schema . v1Domain , { id : domainId } )
85+ . set ( { rootRegistryOwnerId : interpretAddress ( owner ) } ) ;
86+
8687 // materialize domain owner
8788 // NOTE: despite Domain.ownerId being materialized from other sources of truth (i.e. Registrars
8889 // like BaseRegistrars & NameWrapper) it's ok to always set it here because the Registrar-emitted
@@ -99,25 +100,25 @@ export default function () {
99100 context : Context ;
100101 event : EventWithArgs < { node : Node ; owner : Address } > ;
101102 } ) {
102- const { node, owner : _owner } = event . args ;
103- const owner = interpretAddress ( _owner ) ;
103+ const { node, owner } = event . args ;
104104
105105 // ENSv2 model does not include root node, no-op
106106 if ( node === ROOT_NODE ) return ;
107107
108108 const domainId = makeENSv1DomainId ( node ) ;
109109
110- if ( owner === null ) {
111- await context . db . delete ( schema . v1Domain , { id : domainId } ) ;
112- } else {
113- // materialize domain owner
114- // NOTE: despite Domain.ownerId being materialized from other sources of truth (i.e. Registrars
115- // like BaseRegistrars & NameWrapper) it's ok to always set it here because the Registrar-emitted
116- // events occur _after_ the Registry events. So when a name is wrapped, for example, the Registry's
117- // owner changes to that of the NameWrapper but then the NameWrapper emits NameWrapped, and this
118- // indexing code re-materializes the Domain.ownerId to the NameWraper-emitted value.
119- await materializeENSv1DomainEffectiveOwner ( context , domainId , owner ) ;
120- }
110+ // set the domain's rootRegistryOwner to `owner`
111+ await context . db
112+ . update ( schema . v1Domain , { id : domainId } )
113+ . set ( { rootRegistryOwnerId : interpretAddress ( owner ) } ) ;
114+
115+ // materialize domain owner
116+ // NOTE: despite Domain.ownerId being materialized from other sources of truth (i.e. Registrars
117+ // like BaseRegistrars & NameWrapper) it's ok to always set it here because the Registrar-emitted
118+ // events occur _after_ the Registry events. So when a name is wrapped, for example, the Registry's
119+ // owner changes to that of the NameWrapper but then the NameWrapper emits NameWrapped, and this
120+ // indexing code re-materializes the Domain.ownerId to the NameWraper-emitted value.
121+ await materializeENSv1DomainEffectiveOwner ( context , domainId , owner ) ;
121122 }
122123
123124 /**
0 commit comments