@@ -174,13 +174,12 @@ class BaseEventProcessor {
174174 const { ddo : ddoDatabase , ddoState } = await getDatabase ( )
175175 const saveDDO = await ddoDatabase . update ( { ...ddo . getDDOData ( ) } )
176176 const ddoInstance = DDOManager . getDDOClass ( ddo . getDDOData ( ) )
177- const { id, nftAddress } = ddoInstance . getDDOData ( )
178- const { indexedMetadata } = ddoInstance . getAssetFields ( )
177+ const { id, nftAddress, indexedMetadata } = ddoInstance . getDDOData ( )
179178 await ddoState . update (
180179 this . networkId ,
181180 id ,
182181 nftAddress ,
183- indexedMetadata ?. event ?. txid ,
182+ indexedMetadata ?. event ?. tx ,
184183 true
185184 )
186185 INDEXER_LOGGER . logMessage (
@@ -190,13 +189,12 @@ class BaseEventProcessor {
190189 } catch ( err ) {
191190 const { ddoState } = await getDatabase ( )
192191 const ddoInstance = DDOManager . getDDOClass ( ddo . getDDOData ( ) )
193- const { id, nftAddress } = ddoInstance . getDDOData ( )
194- const { indexedMetadata } = ddoInstance . getAssetFields ( )
192+ const { id, nftAddress, indexedMetadata } = ddoInstance . getDDOData ( )
195193 await ddoState . update (
196194 this . networkId ,
197195 id ,
198196 nftAddress ,
199- indexedMetadata ?. event ?. txid ,
197+ indexedMetadata ?. event ?. tx ,
200198 true ,
201199 err . message
202200 )
@@ -750,20 +748,12 @@ export class MetadataStateEventProcessor extends BaseEventProcessor {
750748 }
751749
752750 const ddoInstance = DDOManager . getDDOClass ( ddo )
753-
754751 INDEXER_LOGGER . logMessage ( `Found did ${ did } on network ${ chainId } ` )
755752
756753 if (
757754 'nft' in ddoInstance . getDDOData ( ) . indexedMetadata &&
758755 ddoInstance . getDDOData ( ) . indexedMetadata . nft . state !== metadataState
759756 ) {
760- let shortVersion : {
761- id : any
762- chainId : any
763- nftAddress : any
764- indexedMetadata : any
765- } = null
766-
767757 if (
768758 ddoInstance . getDDOData ( ) . indexedMetadata . nft . state === MetadataStates . ACTIVE &&
769759 [ MetadataStates . REVOKED , MetadataStates . DEPRECATED ] . includes ( metadataState )
@@ -773,7 +763,11 @@ export class MetadataStateEventProcessor extends BaseEventProcessor {
773763 ddoInstance . getDDOData ( ) . indexedMetadata . nft . state
774764 } to ${ metadataState } `
775765 )
776- shortVersion = {
766+
767+ // We should keep it here, because in further development we'll store
768+ // the previous structure of the non-visible DDOs (full version)
769+ // in case their state changes back to active.
770+ const shortDdoInstance = DDOManager . getDDOClass ( {
777771 id : ddo . id ,
778772 chainId,
779773 nftAddress : ddo . nftAddress ,
@@ -782,33 +776,22 @@ export class MetadataStateEventProcessor extends BaseEventProcessor {
782776 state : metadataState
783777 }
784778 }
785- }
786- }
787-
788- // We should keep it here, because in further development we'll store
789- // the previous structure of the non-visible DDOs (full version)
790- // in case their state changes back to active.
791- ddoInstance . getDDOData ( ) . indexedMetadata . nft . state = metadataState
792- if ( shortVersion ) {
793- Object . keys ( ddoInstance . getDDOData ( ) ) . forEach ( ( key ) => {
794- if ( ! ( key in shortVersion ) ) {
795- delete ddoInstance . getDDOData ( ) [ key ]
796- }
797779 } )
798780
799- ddoInstance . getDDOData ( ) . id = shortVersion . id
800- ddoInstance . getDDOData ( ) . chainId = shortVersion . chainId
801- ddoInstance . getDDOData ( ) . nftAddress = shortVersion . nftAddress
802- ddoInstance . getDDOData ( ) . indexedMetadata = shortVersion . indexedMetadata
803- }
804- } else {
805- // Still update until we validate and polish schemas for DDO.
806- // But it should update ONLY if the first condition is met.
807- // Check https://github.com/oceanprotocol/aquarius/blob/84a560ea972485e46dd3c2cfc3cdb298b65d18fa/aquarius/events/processors.py#L663
808- ddoInstance . getDDOData ( ) . indexedMetadata . nft = {
809- state : metadataState
781+ const savedDDO = await this . createOrUpdateDDO (
782+ shortDdoInstance ,
783+ EVENTS . METADATA_STATE
784+ )
785+ return savedDDO
810786 }
811787 }
788+
789+ // Still update until we validate and polish schemas for DDO.
790+ // But it should update ONLY if the first condition is met.
791+ // Check https://github.com/oceanprotocol/aquarius/blob/84a560ea972485e46dd3c2cfc3cdb298b65d18fa/aquarius/events/processors.py#L663
792+ ddoInstance . getDDOData ( ) . indexedMetadata . nft = {
793+ state : metadataState
794+ }
812795 INDEXER_LOGGER . logMessage (
813796 `Found did ${ did } for state updating on network ${ chainId } `
814797 )
0 commit comments