@@ -992,7 +992,7 @@ access(all) contract FlowTransactionScheduler {
992992
993993 // Get the mapping of how much effort has been used
994994 // for each priority for the timestamp
995- let slotPriorityEffortsUsed = self .slotUsedEffort [sanitizedTimestamp ]!
995+ let slotPriorityEffortsUsed = & self .slotUsedEffort [sanitizedTimestamp ]! as &{ Priority : UInt64 }
996996
997997 // Get the exclusive reserves for each priority
998998 let highReserve = self .config .priorityEffortReserve [Priority .High ]!
@@ -1053,8 +1053,8 @@ access(all) contract FlowTransactionScheduler {
10531053 }
10541054
10551055 // Add this transaction id to the slot
1056- let slotQueue = self .slotQueue [slot ]!
1057- if let priorityQueue = slotQueue [txData .priority ] {
1056+ let slotQueue = & self .slotQueue [slot ]! as auth ( Mutate ) &{ Priority : { UInt64 : UInt64 }}
1057+ if let priorityQueue = * slotQueue [txData .priority ] {
10581058 priorityQueue [txData .id ] = txData .executionEffort
10591059 slotQueue [txData .priority ] = priorityQueue
10601060 } else {
@@ -1063,17 +1063,14 @@ access(all) contract FlowTransactionScheduler {
10631063 }
10641064 }
10651065
1066- self .slotQueue [slot ] = slotQueue
1067-
10681066 // Add the execution effort for this transaction to the total for the slot's priority
1069- let slotEfforts = self .slotUsedEffort [slot ]!
1067+ let slotEfforts = & self .slotUsedEffort [slot ]! as auth ( Mutate ) &{ Priority : UInt64 }
10701068 var newPriorityEffort = slotEfforts [txData .priority ]! + txData .executionEffort
10711069 slotEfforts [txData .priority ] = newPriorityEffort
10721070 var newTotalEffort : UInt64 = 0
10731071 for priority in slotEfforts .keys {
10741072 newTotalEffort = newTotalEffort .saturatingAdd (slotEfforts [priority ]! )
10751073 }
1076- self .slotUsedEffort [slot ] = slotEfforts
10771074
10781075 // Need to potentially reschedule low priority transactions to make room for the new transaction
10791076 // Iterate through them and record which ones to reschedule until the total effort is less than the limit
@@ -1466,6 +1463,15 @@ access(all) contract FlowTransactionScheduler {
14661463 )
14671464 }
14681465
1466+ /// Allows users to calculate the fee for a scheduled transaction without having to call the expensive estimate function
1467+ /// @param executionEffort: The execution effort of the transaction
1468+ /// @param priority: The priority of the transaction
1469+ /// @param dataSizeMB: The size of the data that was passed when the transaction was originally scheduled
1470+ /// @return UFix64: The fee in Flow tokens that is required to pay for the transaction
1471+ access (all ) fun calculateFee (executionEffort : UInt64 , priority : Priority , dataSizeMB : UFix64 ): UFix64 {
1472+ return self .sharedScheduler .borrow ()! .calculateFee (executionEffort : executionEffort , priority : priority , dataSizeMB : dataSizeMB )
1473+ }
1474+
14691475 access (all ) fun cancel (scheduledTx : @ScheduledTransaction ): @FlowToken.Vault {
14701476 let id = scheduledTx .id
14711477 destroy scheduledTx
0 commit comments