Skip to content

feat: add getApprovals to PhishingController#8074

Merged
AugmentedMode merged 10 commits into
mainfrom
feat/get-evm-approvals
Mar 25, 2026
Merged

feat: add getApprovals to PhishingController#8074
AugmentedMode merged 10 commits into
mainfrom
feat/get-evm-approvals

Conversation

@AugmentedMode
Copy link
Copy Markdown
Contributor

@AugmentedMode AugmentedMode commented Mar 1, 2026

Summary

  • Adds getApprovals method to PhishingController that wraps the security alerts API POST /address/evm/approvals endpoint (Blockaid's approvals endpoint)
  • Returns token approvals for an EVM address with security enrichments (verdict, spender info, exposure data, allowance details)
  • Follows the existing scanAddress pattern (input validation, chain resolution, safelyExecuteWithTimeout) but intentionally does not cache — the frontend manages state

Changes

  • src/types.ts — Added ApprovalResultType/ApprovalFeatureType enums and types: Approval, ApprovalsResponse, Allowance, ApprovalAsset, Exposure, Spender, ApprovalFeature
  • src/PhishingController.ts — Added APPROVALS_ENDPOINT constant, PhishingControllerGetApprovalsAction action type, messenger registration, and getApprovals method
  • src/index.ts — Exported all new types and enums
  • src/PhishingController.test.ts — Added 8 test cases covering: valid response, missing address/chainId, unknown chain, HTTP errors, timeout, address/chainId normalization

Note

Medium Risk
Adds a new network-backed controller method that calls the Security Alerts approvals endpoint; correctness depends on chain resolution/support gating and error/timeout handling to avoid unexpected empty results.

Overview
Adds a new PhishingController:getApprovals messenger action and getApprovals(chainId, address) method that POSTs to the Security Alerts API (/address/evm/approvals) to retrieve token approvals with security enrichments, returning { approvals: [] } for invalid inputs, unsupported/unknown chains, HTTP errors, or timeouts.

Introduces approval domain types/enums (ApprovalsResponse, Approval, ApprovalResultType, etc.), a supported-chain allowlist (APPROVAL_SUPPORTED_CHAINS) with isApprovalSupportedChain, exports these from index.ts, and adds comprehensive unit tests covering success, normalization, unsupported chains, errors, and timeout behavior.

Written by Cursor Bugbot for commit e2ad990. This will update automatically on new commits. Configure here.

@AugmentedMode AugmentedMode requested a review from a team as a code owner March 1, 2026 02:33
@AugmentedMode AugmentedMode self-assigned this Mar 1, 2026
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@AugmentedMode AugmentedMode requested a review from a team as a code owner March 1, 2026 02:37
Comment thread packages/phishing-controller/src/PhishingController.ts Outdated
Comment thread packages/phishing-controller/src/PhishingController.ts
Comment thread packages/phishing-controller/src/types.ts
Comment thread packages/phishing-controller/src/PhishingController.test.ts
},
],
},
verdict: 'Benign',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May as well use the enum that is introduced (ApprovalResultType and ApprovalFeatureType).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, updated to use ApprovalResultType and ApprovalFeatureType enums.

* @param address - The address to get approvals for.
* @returns The approvals response containing approval data, or empty approvals on error.
*/
getApprovals = async (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flow duplicates scanAddress, seems like a good opportunity to extract the shared logic and reuse for both.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed there's duplication. Similar to the test scaffold

Comment thread packages/phishing-controller/src/PhishingController.ts Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Comment thread packages/phishing-controller/src/PhishingController.ts Outdated
@AugmentedMode AugmentedMode added this pull request to the merge queue Mar 25, 2026
Merged via the queue into main with commit cb48d45 Mar 25, 2026
326 checks passed
@AugmentedMode AugmentedMode deleted the feat/get-evm-approvals branch March 25, 2026 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants