Skip to content

Commit

Permalink
SAY-07 : Function May Fail If the Number of Operations is Too Large
Browse files Browse the repository at this point in the history
Limit to 1000
  • Loading branch information
modship committed Oct 31, 2024
1 parent 56137b6 commit 6228187
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/snap/src/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ export async function addAccountOperation(address: string, operation: string) {
const accountsOperations: AccountsOperations =
(await StateManager.getState('accountOperations')) || {};
const operations = accountsOperations[address] || [];

// limit the number of operations to 1000
if (operations.length >= 1000) {
operations.shift();
}
operations.push(operation);
accountsOperations[address] = operations;
await StateManager.setState('accountOperations', accountsOperations);
Expand Down

0 comments on commit 6228187

Please sign in to comment.