-
Notifications
You must be signed in to change notification settings - Fork 4
feat: add example spending limit hook #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
/// @dev An enumerable set of the periods. | ||
EnumerableSetLib.Uint8Set periods; | ||
/// @dev Mapping of `uint8(period)` to `TokenPeriodSpendStorage`. | ||
mapping(uint256 => TokenPeriodSpendStorage) spends; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this BY period? How would that work if you have two spend periods for the same token that overlap? You'll have to check both periods states and combine the spends somehow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you have two periods for the same token they all must be true:
- Minute, 10 AND hour, 100
You would loop through all of the periods, increment the spend for each and check none exceed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You add the same amount to each tracked period spend
/// @dev Set the spend limit for a key hash. | ||
/// Uses msg.sender to compute the accountKeyHash. | ||
function setSpendLimit(bytes32 keyHash, address token, SpendPeriod period, uint256 limit) external { | ||
AccountKeyHash accountKeyHash = keyHash.wrap(msg.sender); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe use a different word? wrap is keyword for a custom type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok! I did hashSender
No description provided.