@@ -2046,27 +2046,33 @@ export function handlePortalData(event: PortalData): void {
20462046 }
20472047
20482048 // Handle portal options
2049- let contract = AavegotchiDiamond . bind ( event . address ) ;
2050- let openPortalResponse = contract . try_portalAavegotchiTraits (
2051- BigInt . fromString ( portal . id )
2052- ) ;
2053-
2054- if ( ! openPortalResponse . reverted ) {
2055- let array = openPortalResponse . value ;
2056- for ( let i = 0 ; i < 10 ; i ++ ) {
2057- let possibleAavegotchiTraits = array [ i ] ;
2058- let gotchi = getOrCreateAavegotchiOption ( portal . id , i ) ;
2059- gotchi . portal = portal . id ;
2060- gotchi . owner = portal . owner ;
2061- gotchi . randomNumber = possibleAavegotchiTraits . randomNumber ;
2062- gotchi . numericTraits = possibleAavegotchiTraits . numericTraits ;
2063- gotchi . collateralType = possibleAavegotchiTraits . collateralType ;
2064- gotchi . minimumStake = possibleAavegotchiTraits . minimumStake ;
2065- //calculate base rarity score
2066- gotchi . baseRarityScore = calculateBaseRarityScore ( gotchi . numericTraits ) ;
2067-
2068- gotchi . save ( ) ;
2049+ let options = data . options ;
2050+
2051+ // Log the options array for debugging
2052+ log . info ( "PortalData - Portal ID: {}, Options length: {}" , [
2053+ portal . id ,
2054+ options . length . toString ( ) ,
2055+ ] ) ;
2056+
2057+ if ( options ?. length > 0 ) {
2058+ for ( let i = 0 ; i < options . length ; i ++ ) {
2059+ let option = getOrCreateAavegotchiOption (
2060+ portal . id ,
2061+ options [ i ] . portalOptionId
2062+ ) ;
2063+ option . portal = portal . id ;
2064+ option . owner = portal . owner ;
2065+ option . portalOptionId = options [ i ] . portalOptionId ;
2066+ option . randomNumber = options [ i ] . randomNumber ;
2067+ option . numericTraits = options [ i ] . numericTraits ;
2068+ option . collateralType = options [ i ] . collateralType ;
2069+ option . minimumStake = options [ i ] . minimumStake ;
2070+ option . baseRarityScore = options [ i ] . baseRarityScore ;
2071+
2072+ option . save ( ) ;
20692073 }
2074+ } else {
2075+ log . warning ( "PortalData - No options found for portal {}" , [ portal . id ] ) ;
20702076 }
20712077
20722078 portal . save ( ) ;
0 commit comments