Skip to content

refactor: replace all any types with specific types#343

Open
its-applekid wants to merge 4 commits into
ethereum-optimism:mainfrom
its-applekid:feat/replace-any-types
Open

refactor: replace all any types with specific types#343
its-applekid wants to merge 4 commits into
ethereum-optimism:mainfrom
its-applekid:feat/replace-any-types

Conversation

@its-applekid
Copy link
Copy Markdown

Summary

Replaces 41 occurrences of any type with specific, properly-typed alternatives across 13 SDK files and 5 mock/test files. Follows TypeScript best practices with proper type safety patterns.

Changes

Source Files (4 files):

  • lend/providers/aave/sdk.ts — typed Aave reserve response
  • lend/providers/morpho/api.ts — defined MorphoVaultData interfaces
  • lend/providers/morpho/sdk.ts — typed vault and allocation params
  • services/mocks/MockChainManager.ts — 'as unknown as T' pattern

Test/Mock Files (9 files):

  • Uses as unknown as SpecificType for mock objects
  • Error handling: NodeJS.ErrnoException for spawn errors
  • Custom RPC methods: eslint-disable for anvil methods (unavoidable)
  • Proper viem client/account type returns

Verification

✅ All 47 test files pass (339 tests, 10 skipped)
✅ 0 no-explicit-any warnings
✅ TypeScript strict mode passes
✅ No behavioral changes — purely typing

Notes

Anvil impersonate/stop methods and intentional invalid chain tests keep as any with eslint-disable comments since those are legitimate exceptions (unavoidable due to viem's typed interface vs Anvil's custom RPC methods).

Closes #337

- GuardrailWallet contract with allowlists and spending limits
- Mock contracts (USDC, Morpho vault, Chainlink oracle)
- Comprehensive gas tests measuring overhead
- Results: ~96k gas overhead (+104%) with allowlist + spending limits
- Confirmed O(1) allowlist lookups (100 contracts = same cost as 2)
- Oracle read: 10k gas (mock), expect 40-50k in production
Replace 'any' with specific types in lend and service source files:
- lend/providers/aave/sdk.ts: typed formattedReserve parameter
- lend/providers/morpho/api.ts: defined Morpho GraphQL response types
- lend/providers/morpho/sdk.ts: typed vault and allocation parameters
- services/__mocks__/MockChainManager.ts: use 'as unknown as T' pattern

41 → 28 remaining any types
Replace 'any' with specific types in test and mock files using patterns:
- Mocks: use 'as unknown as SpecificType' for mock objects
- Error handling: NodeJS.ErrnoException for spawn errors
- Custom RPC methods: eslint-disable for anvil methods (unavoidable)
- Test utilities: type specific viem client/account returns
- Unsupported chain testing: eslint-disable for intentional invalid types

All 47 test files pass, 0 no-explicit-any warnings, typecheck clean
@its-applekid its-applekid requested a review from a team as a code owner March 28, 2026 02:58
@its-applekid its-applekid requested a review from tremarkley March 28, 2026 02:58
@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 28, 2026

👷 Deploy request for actions-ui pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit ca73bb2

@wiz-inc-a178a98b5d
Copy link
Copy Markdown

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities -
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations 3 Low
SAST Finding SAST Findings 2 Medium
Software Management Finding Software Management Findings -
Total 2 Medium 3 Low

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

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.

Replace all any types with specific types

1 participant