refactor(sdk): replace any with specific types in lend provider sources#405
Open
cats2101 wants to merge 1 commit intoethereum-optimism:mainfrom
Open
refactor(sdk): replace any with specific types in lend provider sources#405cats2101 wants to merge 1 commit intoethereum-optimism:mainfrom
any with specific types in lend provider sources#405cats2101 wants to merge 1 commit intoethereum-optimism:mainfrom
Conversation
👷 Deploy request for actions-ui pending review.Visit the deploys page to approve it
|
35f069b to
cc0ddea
Compare
Part of ethereum-optimism#337. Replaces `any` with specific types in SDK source files (tests other than the directly-affected fixtures are untouched): - `lend/providers/morpho/api.ts`: type the GraphQL response with a `MorphoApiVault` interface and surface it from the fetch helper. - `lend/providers/morpho/sdk.ts`: type vault inputs as `AccrualVault` and allocations as `VaultMarketAllocation` from `@morpho-org/blue-sdk`; use `MorphoApiVault` for the GraphQL-sourced variant. - `lend/providers/aave/sdk.ts`: type `formattedReserve` as `FormatReserveUSDResponse` from `@aave/math-utils`. - `services/__mocks__/MockChainManager.ts` and `lend/__mocks__/MockLendProvider.ts`: replace `as any` with `as unknown as <SpecificType>` per the issue guidelines. Direct fixture call sites in the Morpho sdk tests are cast with `as unknown as AccrualVault` / `MorphoApiVault` to keep the partial test objects compatible. Remaining `any` warnings live in other test files and are left for follow-up PRs. pnpm typecheck, pnpm lint (no new warnings), and pnpm test all pass.
cc0ddea to
d26dea7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Scoped first pass at #337: replaces
anywith specific types across the lend provider SDK source files (Morpho + Aave). Tests left for a follow-up so this stays reviewable.Changes
packages/sdk/src/lend/providers/morpho/api.tsMorphoRewardAsset,MorphoReward,MorphoMarketState,MorphoAllocation,MorphoVaultState,MorphoApiVault.fetchRewardsreturn type changed fromPromise<any | null>toPromise<MorphoApiVault | null>.MorphoVaultApiResponseshape instead ofas any.packages/sdk/src/lend/providers/morpho/sdk.tscalculateBaseApy(vault: any)→calculateBaseApy(vault: AccrualVault)(from@morpho-org/blue-sdk).VaultMarketAllocation.calculateApyBreakdownvault param typed asAccrualVault.calculateRewardsBreakdownparam typed asMorphoApiVault..reducecallbackallocparam now inferred from the typed array.packages/sdk/src/lend/providers/aave/sdk.tscalculateApyBreakdownreserve param typed withFormatReserveUSDResponsefrom@aave/math-utilsinstead ofany.packages/sdk/src/services/__mocks__/MockChainManager.tsas anycasts tightened toas unknown as PublicClient/as unknown as BundlerClient.packages/sdk/src/lend/__mocks__/MockLendProvider.tssimulateErrormock method typed asMockedFunction<(...args: never[]) => unknown>instead ofany.Test adjustments
morpho/__tests__/api.test.ts: added non-null assertions where tests already checkexpect(vaultData).not.toBeNull()beforehand.morpho/__tests__/sdk.test.ts: partial fixtures cast withas unknown as AccrualVault/as unknown as MorphoApiVaultat call sites, per the pattern suggested in the issue.Scope
This PR only touches lend provider source files and the mocks/tests directly affected by those signature changes. The remaining
anywarnings are in other test files and unrelated modules — happy to tackle those in follow-up PRs to keep reviews focused.Verification
pnpm typecheck— passespnpm lint— 13@typescript-eslint/no-explicit-anywarnings resolved (35 → 22); no new warnings introducedpnpm -r test— 467 passed, 10 skippedPart of #337.