@@ -83,6 +83,8 @@ func EndBlockerAtomic(ctx sdk.Context, keeper *keeper.Keeper, validContractsInfo
83
83
}
84
84
85
85
failedContractsToReasons := map [string ]string {}
86
+ failedContractsPreRents := map [string ]uint64 {}
87
+ failedContractsPostRents := map [string ]uint64 {}
86
88
// persistent contract rent charges for failed contracts and discard everything else
87
89
env .failedContractAddressesToErrors .Range (func (failedContractAddress string , failedReason error ) bool {
88
90
cachedContract , err := keeper .GetContract (cachedCtx , failedContractAddress )
@@ -96,6 +98,8 @@ func EndBlockerAtomic(ctx sdk.Context, keeper *keeper.Keeper, validContractsInfo
96
98
return true
97
99
}
98
100
contract .RentBalance = cachedContract .RentBalance
101
+ failedContractsPreRents [failedContractAddress ] = preRunRents [failedContractAddress ]
102
+ failedContractsPostRents [failedContractAddress ] = contract .RentBalance
99
103
err = keeper .SetContract (ctx , & contract )
100
104
if err != nil {
101
105
ctx .Logger ().Error (fmt .Sprintf ("error %s when persisting contract %s's rent balance" , err , failedContractAddress ))
@@ -104,6 +108,7 @@ func EndBlockerAtomic(ctx sdk.Context, keeper *keeper.Keeper, validContractsInfo
104
108
failedContractsToReasons [failedContractAddress ] = dexutils .GetTruncatedErrors (failedReason )
105
109
return true
106
110
})
111
+ TransferRentFromDexToCollector (ctx , keeper .BankKeeper , failedContractsPreRents , failedContractsPostRents )
107
112
108
113
// restore keeper in-memory state
109
114
newGoContext := context .WithValue (ctx .Context (), dexutils .DexMemStateContextKey , memStateCopy )
0 commit comments