@@ -2046,21 +2046,27 @@ export function handlePortalData(event: PortalData): void {
20462046 }
20472047
20482048 // Handle portal options
2049- let options = data . options ;
2050- for ( let i = 0 ; i < options . length ; i ++ ) {
2051- let option = getOrCreateAavegotchiOption (
2052- portal . id ,
2053- options [ i ] . portalOptionId
2054- ) ;
2055- option . portal = portal . id ;
2056- option . owner = portal . owner ;
2057- option . portalOptionId = options [ i ] . portalOptionId ;
2058- option . randomNumber = options [ i ] . randomNumber ;
2059- option . numericTraits = options [ i ] . numericTraits ;
2060- option . collateralType = options [ i ] . collateralType ;
2061- option . minimumStake = options [ i ] . minimumStake ;
2062- option . baseRarityScore = calculateBaseRarityScore ( option . numericTraits ) ;
2063- option . save ( ) ;
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 ( ) ;
2069+ }
20642070 }
20652071
20662072 portal . save ( ) ;
0 commit comments