@@ -322,42 +322,46 @@ func RefundIAPNFTBUY(ctx sdk.Context, pylons *pylonskeeper.Keeper, accKeeper *au
322322 // Query All recipes made with cookbook on chain
323323 recipes := pylons .GetAllRecipesByCookbook (ctx , cookbook .Id )
324324 for _ , recipe := range recipes {
325- // Check If Recipe is executed atleast once
326- if recipe .Entries .ItemOutputs [0 ].AmountMinted > 0 {
327- // Query All Execution Record of the Recipe
328- executions := pylons .GetAllExecuteRecipeHis (ctx , cookbook .Id , recipe .Id )
329- for _ , execution := range executions {
330- if execution .CreatedAt >= Aug8DateUnix {
331- if IAPAddress [execution .Sender ] {
332- // If recipe is executed after 8th August, i.e. first IAP purchase
333- // If executor has purchased form IAP
334- // If amount is in upylons
335- amount , _ := sdk .ParseCoinNormalized (execution .Amount )
336- if amount .Denom == types .PylonsCoinDenom {
337- err := bank .SendCoinsFromAccountToModule (
338- ctx ,
339- sdk .MustAccAddressFromBech32 (execution .Sender ),
340- types .PaymentsProcessorName ,
341- sdk .NewCoins (amount ),
342- )
343- if err != nil {
344- // case: user do not have enough IAP tokens
345- continue
346- }
347- err = bank .SendCoinsFromModuleToAccount (
348- ctx ,
349- types .PaymentsProcessorName ,
350- sdk .MustAccAddressFromBech32 (cookbook .Creator ),
351- sdk .NewCoins (amount ),
352- )
353- if err != nil {
354- panic (err )
325+
326+ if len (recipe .Entries .ItemOutputs ) > 0 {
327+ // Check If Recipe is executed atleast once
328+ if recipe .Entries .ItemOutputs [0 ].AmountMinted > 0 {
329+ // Query All Execution Record of the Recipe
330+ executions := pylons .GetAllExecuteRecipeHis (ctx , cookbook .Id , recipe .Id )
331+ for _ , execution := range executions {
332+ if execution .CreatedAt >= Aug8DateUnix {
333+ if IAPAddress [execution .Sender ] {
334+ // If recipe is executed after 8th August, i.e. first IAP purchase
335+ // If executor has purchased form IAP
336+ // If amount is in upylons
337+ amount , _ := sdk .ParseCoinNormalized (execution .Amount )
338+ if amount .Denom == types .PylonsCoinDenom {
339+ err := bank .SendCoinsFromAccountToModule (
340+ ctx ,
341+ sdk .MustAccAddressFromBech32 (execution .Sender ),
342+ types .PaymentsProcessorName ,
343+ sdk .NewCoins (amount ),
344+ )
345+ if err != nil {
346+ // case: user do not have enough IAP tokens
347+ continue
348+ }
349+ err = bank .SendCoinsFromModuleToAccount (
350+ ctx ,
351+ types .PaymentsProcessorName ,
352+ sdk .MustAccAddressFromBech32 (cookbook .Creator ),
353+ sdk .NewCoins (amount ),
354+ )
355+ if err != nil {
356+ panic (err )
357+ }
355358 }
356359 }
357360 }
358361 }
359362 }
360363 }
364+
361365 }
362366 }
363367}
0 commit comments