Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: simplify permission log controller (#3662)
## Explanation Initially, I took the PermissionLogController from the extension and converted it to TypeScript. During my work on this simplification task, I realized that the primary functions in use are `createMiddleware`, for logging permission activities and history, and `updateAccountsHistory`, which is triggered on account changes. The controller also tracks two state-level properties: `permissionHistory`, used on the extension's permissions page, and `permissionActivityLog`, which is currently not in use but retained for an upcoming feature. Additionally, the rest of the functions in the PermissionLogController are private, serving as helper functions. ## Changes ### Kept public - `createMiddleware`. - `updateAccountsHistory`. ### Changed to private - `logRequest`: helper function only used within the controller. - `logResponse`: helper function only used within the controller. - `logPermissionsHistory`: helper function only used within the controller. - `commitNewHistory`: helper function only used within the controller. - `getRequestedMethods`: helper function only used within the controller. - `getAccountsFromPermission`: helper function only used within the controller. - `getAccountToTimeMap`: included in the controller instead of outside controller class as a private helper function. ### Removed - `sinon` dependency: removed in favor of builtin jest fake timers. - `getActivityLog`: originally returns the state of permissionActivityLog, but now state can be accessed with state property directly. - `updateActivityLog`: originally updates the state for permissionActivityLog, replaced by this.update already available on the controller. - `getHistory`: originally returns the state of PermissionHistory, but now state can be accessed with state property directly - `updateHistory`: originally updates the state for PermissionHistory, replaced by this.update already available on the controller. ## References * Fixes [#1824](#1824) ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've highlighted breaking changes using the "BREAKING" category above as appropriate
- Loading branch information