Trackers are increment only and immutable in storage. To start an approval tally from scratch, you will need to map the approval to a new unused tracker ID. This can be done simply by editing amountTrackerId (because this changes the whole ID) or restructuring to change one of the other fields that make up the overall ID.
IMPORTANT: Because of the immutable nature, be careful to not revert to a previously used ID unintentionally because the starting point will be the previous tally (not starting from scratch).
As-Needed Basis
Only increment when necessary (e.g., if no amount restrictions, don't track amounts). Meaning, if there is no need to increment the tally (unlimited limit and/or not restrictions), we do not increment for efficiency purposes. For example, if we only have requirements for numTransfers but do not need the amounts, we do not increment the amounts.
Example Tracker States
Periodic Resets
Trackers support periodic resets to zero using time intervals.
Leave the values at 0 to disable periodic resets.
How It Works
First Update: If it's the first update of the interval, all tracker progress is reset to zero
Recurring: Useful for recurring subscriptions (e.g., one transfer per month)
No Reset: Set both values to 0 for no periodic resets
Example
This creates a monthly reset cycle starting from August 13, 2023.
interface ResetTimeIntervals<T extends NumberType> {
startTime: T; // Original start time of the first interval
intervalLength: T; // Interval length in unix milliseconds
}
{
"approvalAmounts": {
"overallApprovalAmount": "100",
"amountTrackerId": "monthly-tracker",
"resetTimeIntervals": {
"startTime": "1691978400000", // Aug 13, 2023
"intervalLength": "2592000000" // 30 days in milliseconds
}
}
}