Skip to content

refactor: remove type castings and handle errors instead#4600

Merged
enesozturk merged 6 commits intomainfrom
enes/apkt-2298-remove-type-castings-in-the-code-and-improve-error-handling
Jul 2, 2025
Merged

refactor: remove type castings and handle errors instead#4600
enesozturk merged 6 commits intomainfrom
enes/apkt-2298-remove-type-castings-in-the-code-and-improve-error-handling

Conversation

@enesozturk
Copy link
Copy Markdown
Contributor

Description

  • Removes type casting for making sure we don't override any possible issues and throw errors if values are not expected
  • Removes type casting for custom 0x${string} and use @reown/appkit-common package for for types and namespace values

Type of change

  • Chore (non-breaking change that addresses non-functional tasks, maintenance, or code quality improvements)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Associated Issues

For Linear issues: Closes APKT-xxx
For GH issues: closes #...

Showcase (Optional)

If there is a UI change include the screenshots with before and after state.
If new feature is being introduced, include the link to demo recording.

Checklist

  • Code in this PR is covered by automated tests (Unit tests, E2E tests)
  • My changes generate no new warnings
  • I have reviewed my own code
  • I have filled out all required sections
  • I have tested my changes on the preview link
  • Approver of this PR confirms that the changes are tested on the preview link

@linear
Copy link
Copy Markdown

linear bot commented Jul 2, 2025

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Jul 2, 2025

🦋 Changeset detected

Latest commit: 7fac1cd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 23 packages
Name Type
@reown/appkit-adapter-ethers5 Patch
@reown/appkit-adapter-ethers Patch
@reown/appkit-adapter-solana Patch
@reown/appkit-adapter-wagmi Patch
@reown/appkit-utils Patch
@reown/appkit-experimental Patch
@reown/appkit-controllers Patch
@reown/appkit-scaffold-ui Patch
@reown/appkit Patch
@reown/appkit-common Patch
@reown/appkit-wallet Patch
@reown/appkit-siwe Patch
@reown/appkit-siwx Patch
@reown/appkit-pay Patch
@reown/appkit-ui Patch
@reown/appkit-adapter-bitcoin Patch
@reown/appkit-cdn Patch
@reown/appkit-cli Patch
@reown/appkit-codemod Patch
@reown/appkit-core Patch
@reown/appkit-polyfills Patch
@reown/appkit-testing Patch
@reown/appkit-wallet-button Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Copy Markdown

vercel bot commented Jul 2, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
appkit-basic-html ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 2, 2025 2:16pm
appkit-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 2, 2025 2:16pm
appkit-laboratory ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 2, 2025 2:16pm
10 Skipped Deployments
Name Status Preview Comments Updated (UTC)
appkit-basic-example ⬜️ Ignored (Inspect) Jul 2, 2025 2:16pm
appkit-basic-sign-client-example ⬜️ Ignored (Inspect) Jul 2, 2025 2:16pm
appkit-basic-up-example ⬜️ Ignored (Inspect) Visit Preview Jul 2, 2025 2:16pm
appkit-ethers5-bera ⬜️ Ignored (Inspect) Jul 2, 2025 2:16pm
appkit-nansen-demo ⬜️ Ignored (Inspect) Jul 2, 2025 2:16pm
appkit-vue-solana ⬜️ Ignored (Inspect) Jul 2, 2025 2:16pm
appkit-wagmi-cdn-example ⬜️ Ignored (Inspect) Jul 2, 2025 2:16pm
ethereum-provider-wagmi-example ⬜️ Ignored (Inspect) Jul 2, 2025 2:16pm
next-wagmi-solana-bitcoin-example ⬜️ Ignored (Inspect) Jul 2, 2025 2:16pm
vue-wagmi-example ⬜️ Ignored (Inspect) Jul 2, 2025 2:16pm

cursor[bot]

This comment was marked as outdated.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jul 2, 2025

Warnings
⚠️

🔑 Potential High‑entropy string detected in packages/adapters/solana/src/tests/mocks/Options.ts (line 6): com/coins/images/412...

⚠️

🔑 Potential High‑entropy string detected in packages/appkit/tests/client/estimate-gas.test.ts (line 57): 0x123456789012345678...

⚠️

🔑 Potential High‑entropy string detected in packages/appkit/tests/client/estimate-gas.test.ts (line 57): 0x123456789012345678...

⚠️

🔑 Potential High‑entropy string detected in packages/appkit/tests/client/estimate-gas.test.ts (line 57): 0x123456789012345678...

⚠️

🔑 Potential High‑entropy string detected in packages/appkit/tests/client/estimate-gas.test.ts (line 57): 0x123456789012345678...

⚠️

🔑 Potential High‑entropy string detected in packages/appkit/tests/client/estimate-gas.test.ts (line 57): 0x123456789012345678...

⚠️

🔑 Potential High‑entropy string detected in packages/appkit/tests/client/estimate-gas.test.ts (line 57): 0x123456789012345678...

⚠️

🔑 Potential High‑entropy string detected in packages/appkit/tests/client/estimate-gas.test.ts (line 57): 0x123456789012345678...

⚠️

🔑 Potential High‑entropy string detected in packages/appkit/tests/client/estimate-gas.test.ts (line 57): 0x123456789012345678...

⚠️

🔑 Potential High‑entropy string detected in apps/laboratory/src/components/Wagmi/WagmiSendUSDCTest.tsx (line 35): 0x1c7D4B196Cb0C7B01d...

⚠️

🔑 Potential High‑entropy string detected in apps/laboratory/src/components/Wagmi/WagmiSendUSDCTest.tsx (line 36): 0x0b2c639c533813f4aa...

⚠️

🔑 Potential High‑entropy string detected in apps/laboratory/src/components/Wagmi/WagmiSendUSDCTest.tsx (line 37): 0x833589fCD6eDb6E08f...

⚠️

🔑 Potential High‑entropy string detected in apps/laboratory/src/components/Wagmi/WagmiSendUSDCTest.tsx (line 38): 0xaf88d065e77c8cC223...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/src/utils/MobileWallet.ts (line 13): a797aa35c0fadbfc1a53...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/src/utils/MobileWallet.ts (line 17): 1ca0bdd4747578705b19...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/src/utils/MobileWallet.ts (line 21): fd20dc426fb37566d803...

⚠️

🔑 Potential High‑entropy string detected in apps/laboratory/src/components/Wagmi/WagmiSendCallsCustomAbiWithPaymasterServiceTest.tsx (line 295): org/token/0x833589fc...

⚠️

🔑 Potential High‑entropy string detected in apps/laboratory/src/components/Wagmi/WagmiSendCallsCustomAbiWithPaymasterServiceTest.tsx (line 295): 0x833589fcd6edb6e08f...

⚠️

🔑 Potential High‑entropy string detected in packages/common/src/utils/TypeUtil.ts (line 178): 0x6b175474e89094c44d...

⚠️

🔑 Potential High‑entropy string detected in packages/common/src/utils/TypeUtil.ts (line 178): 0x6b175474e89094c44d...

⚠️

🔑 Potential High‑entropy string detected in packages/common/src/utils/TypeUtil.ts (line 189): 0x06012c8cf97BEaD5de...

⚠️

🔑 Potential High‑entropy string detected in packages/experimental/tests/smart-session/requestValidation/validateCommonFields.test.ts (line 22): 0x2E65BAfA07238666c3...

⚠️

🔑 Potential High‑entropy string detected in packages/experimental/tests/smart-session/requestValidation/validateCommonFields.test.ts (line 87): 0x123456789012345678...

⚠️

🔑 Potential High‑entropy string detected in packages/experimental/tests/smart-session/requestValidation/validateCommonFields.test.ts (line 87): 12345678901234567890...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/src/utils/ConstantsUtil.ts (line 35): 25B8LJHSfpG6LVjR2ytU...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/src/utils/ConstantsUtil.ts (line 69): js/blob/d4bda2c05c4d...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/src/utils/ConstantsUtil.ts (line 225): 0xeeeeeeeeeeeeeeeeee...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/src/utils/ConstantsUtil.ts (line 226): So111111111111111111...

⚠️

🔑 Potential UUID detected in packages/controllers/src/utils/ConstantsUtil.ts (line 95): bf18c88d-495a-463b-b...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/mocks/SwapController.ts (line 8): 0xeeeeeeeeeeeeeeeeee...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/mocks/SwapController.ts (line 10): io/0x7d1afa7b718fb89...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/mocks/SwapController.ts (line 16): 0x2c89bbc92bd86f8075...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/mocks/SwapController.ts (line 18): io/0x2c89bbc92bd86f8...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/mocks/SwapController.ts (line 24): 0x3c499c542cef5e3811...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/mocks/SwapController.ts (line 26): io/0x3c499c542cef5e3...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/mocks/SwapController.ts (line 10): io/0x7d1afa7b718fb89...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/mocks/SwapController.ts (line 44): com/0xa0b86991c6218b...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/mocks/SwapController.ts (line 62): com/0x7d1afa7b718fb8...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/mocks/SwapController.ts (line 16): 0x2c89bbc92bd86f8075...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/mocks/SwapController.ts (line 75): com/0xb31f66aa3c1e78...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/mocks/SwapController.ts (line 24): 0x3c499c542cef5e3811...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/mocks/SwapController.ts (line 44): com/0xa0b86991c6218b...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/mocks/SwapController.ts (line 94): 11579208923731619542...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/mocks/SwapController.ts (line 8): 0xeeeeeeeeeeeeeeeeee...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/mocks/SwapController.ts (line 16): 0x2c89bbc92bd86f8075...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/mocks/SwapController.ts (line 111): 0xe8e0d27a1232ada1d7...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/mocks/SwapController.ts (line 112): 0x111111125421ca6dc4...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/mocks/SwapController.ts (line 113): 0x07ed23790000000000...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/utils/ERC7811.test.ts (line 19): 0x123456789012345678...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/utils/ERC7811.test.ts (line 19): 0x123456789012345678...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/utils/ERC7811.test.ts (line 19): 0x123456789012345678...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/utils/ERC7811.test.ts (line 19): 0x123456789012345678...

⚠️

🔑 Potential High‑entropy string detected in packages/experimental/tests/smart-session/CosignerService.test.ts (line 23): 0x123456789012345678...

⚠️

🔑 Potential High‑entropy string detected in packages/experimental/tests/smart-session/CosignerService.test.ts (line 40): 0x2E65BAfA07238666c3...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/controllers/ChainController.test.ts (line 91): 5eykt4UsFv8P8NJdTREp...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/controllers/ChainController.test.ts (line 91): 5eykt4UsFv8P8NJdTREp...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/controllers/ChainController.test.ts (line 242): 0xeeeeeeeeeeeeeeeeee...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/controllers/ChainController.test.ts (line 242): 0xeeeeeeeeeeeeeeeeee...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/controllers/ChainController.test.ts (line 91): 5eykt4UsFv8P8NJdTREp...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/controllers/ChainController.test.ts (line 252): So111111111111111111...

⚠️

🔑 Potential High‑entropy string detected in packages/pay/tests/utils/PaymentUtil.test.ts (line 51): 0x1234567890abcdef12...

⚠️

🔑 Potential High‑entropy string detected in packages/pay/tests/utils/PaymentUtil.test.ts (line 52): 0xabcdef1234567890ab...

⚠️

🔑 Potential High‑entropy string detected in packages/pay/tests/utils/PaymentUtil.test.ts (line 53): 0x7Fc66500c84A76Ad7e...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/utils/BalanceUtil.test.ts (line 39): 5eykt4UsFv8P8NJdTREp...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/utils/BalanceUtil.test.ts (line 39): 5eykt4UsFv8P8NJdTREp...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/utils/BalanceUtil.test.ts (line 54): 0x123456789012345678...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/tests/utils/BalanceUtil.test.ts (line 39): 5eykt4UsFv8P8NJdTREp...

⚠️

🔑 Potential UUID detected in packages/adapters/ethers/src/tests/client.test.ts (line 970): ba0ba0cd-17c6-4806-a...

⚠️

🔑 Potential High‑entropy string detected in packages/pay/tests/controllers/PayController.test.ts (line 27): 0xA0b86991c6218b36c1...

⚠️

🔑 Potential High‑entropy string detected in packages/pay/tests/controllers/PayController.test.ts (line 34): 0x123456789012345678...

⚠️

🔑 Potential High‑entropy string detected in packages/pay/tests/controllers/PayController.test.ts (line 34): 0x123456789012345678...

⚠️

🔑 Potential High‑entropy string detected in packages/pay/tests/controllers/PayController.test.ts (line 34): 0x123456789012345678...

⚠️

🔑 Potential High‑entropy string detected in packages/pay/tests/controllers/PayController.test.ts (line 27): 0xA0b86991c6218b36c1...

⚠️

🔑 Potential High‑entropy string detected in packages/pay/tests/controllers/PayController.test.ts (line 27): 0xA0b86991c6218b36c1...

⚠️

🔑 Potential High‑entropy string detected in packages/pay/tests/controllers/PayController.test.ts (line 27): 0xA0b86991c6218b36c1...

⚠️

🔑 Potential High‑entropy string detected in packages/pay/tests/controllers/PayController.test.ts (line 34): 0x123456789012345678...

⚠️

🔑 Potential High‑entropy string detected in packages/pay/tests/controllers/PayController.test.ts (line 34): 0x123456789012345678...

⚠️

🔑 Potential High‑entropy string detected in packages/pay/tests/controllers/PayController.test.ts (line 27): 0xA0b86991c6218b36c1...

⚠️

🔑 Potential High‑entropy string detected in packages/pay/tests/controllers/PayController.test.ts (line 34): 0x123456789012345678...

⚠️

🔑 Potential UUID detected in packages/adapters/wagmi/src/tests/client.test.ts (line 405): 07ba87ed-43aa-4adf-4...

⚠️

🔑 Potential High‑entropy string detected in packages/scaffold-ui/test/views/w3m-swap-preview-view.test.ts (line 50): 0x123456789abcdef123...

⚠️

🔑 Potential High‑entropy string detected in packages/scaffold-ui/test/views/w3m-wallet-send-preview-view.test.ts (line 99): 0x123456789abcdef123...

⚠️

🔑 Potential High‑entropy string detected in packages/scaffold-ui/test/views/w3m-wallet-receive-view.test.ts (line 47): 0x123456789abcdef123...

Generated by 🚫 dangerJS against 7fac1cd

@enesozturk enesozturk requested a review from a team July 2, 2025 10:24
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jul 2, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 77.68% 30852 / 39712
🔵 Statements 77.68% 30852 / 39712
🔵 Functions 68.77% 2539 / 3692
🔵 Branches 84.26% 6407 / 7603
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/adapters/ethers/src/utils/EthersMethods.ts 100% 96.55% 100% 100%
packages/adapters/ethers5/src/utils/Ethers5Methods.ts 19.23% 50% 33.33% 19.23% 15-16, 18, 29-56, 59-87, 90-112, 115-120
packages/adapters/wagmi/src/client.ts 77.63% 65.58% 80.48% 77.63% 114-115, 120-121, 132-134, 136, 198-199, 269-272, 346-347, 361, 381-382, 457-458, 469-470, 505-506, 523-524, 538-555, 574-575, 596-597, 601-602, 607-639, 658-664, 667-678, 687-688, 699-700, 721-723, 737-738, 751-752, 767-768, 817-818, 830-831, 839-840, 845-846, 850-855, 862-863, 871-872, 877-878, 887-888, 896-897, 902-903, 909-931, 934-947
packages/adapters/wagmi/src/connectors/AuthConnector.ts 6.52% 100% 25% 6.52% 54-55, 58-79, 82-129, 132-271
packages/adapters/wagmi/src/connectors/UniversalConnector.ts 60.66% 48.07% 55% 60.66% 76-88, 95-96, 105-106, 111-121, 139-140, 147-149, 171-178, 186-188, 231-232, 251-258, 270, 278-300, 304-305, 310-311, 332-333, 339, 343, 368-369, 373-380, 382-385, 387-388, 390-414, 416-417, 419-420, 422-432, 455-457, 460-465
packages/appkit-utils/src/ConstantsUtil.ts 100% 100% 100% 100%
packages/appkit-utils/src/ProviderUtil.ts 81.35% 77.77% 55.55% 81.35% 41, 45-47, 51, 67-68, 81-82, 88-89
packages/appkit/src/adapters/ChainAdapterBlueprint.ts 75% 91.66% 75.75% 75% 152-163, 245-246, 250-251, 274-278, 284-287, 511-538, 566-571, 598-599, 612-640, 649-650, 549
packages/appkit/src/client/appkit-base-client.ts 72.3% 88.52% 75.79% 72.3% 183, 194-197, 210-236, 268-269, 271-272, 277-278, 357-358, 394-400, 465-466, 495-501, 504-505, 508-509, 527-528, 543-544, 547-548, 589-593, 599-603, 644-648, 655-656, 659-660, 671-694, 703-704, 721-733, 737-758, 761-767, 770-776, 779-785, 788-794, 797-807, 810-816, 819-825, 841-853, 859-892, 895-905, 957-958, 963, 978-994, 1002, 1006-1013, 1080-1082, 1088-1089, 1097-1098, 1100-1101, 1106-1108, 1144-1153, 1188-1189, 1201-1202, 1207, 1230-1235, 1278, 1299-1300, 1310, 1312-1328, 1333, 1386-1397, 1439-1447, 1492, 1498-1502, 1521-1522, 1539-1542, 1578-1598, 1621-1632, 1661-1662, 1668-1694, 1902-1903, 1935-1936, 1939-1940, 1953-1956, 1959-1960, 1980-1981, 1984-1985, 1997-2007, 2025-2026, 2029-2035, 2039-2040, 2054, 2062, 2065, 2069, 2074-2093, 2096-2105, 2112-2113, 2127-2128, 2131-2132, 2139-2140, 2179-2180, 2263-2264, 2267-2268, 2271-2274, 2277-2278, 2281-2282, 2285-2286, 2289-2290, 2293-2297, 2306-2315, 2324-227, 1151, 1628, 2076-2097
packages/appkit/src/client/appkit.ts 46.24% 79.38% 84.61% 46.24% 69-129, 132-146, 149-156, 159-175, 178-190, 195-205, 211-212, 237-238, 245-246, 259-282, 290-302, 304, 306-325, 327-341, 366-372, 388, 409-410, 415-416, 431-515, 552-556, 578-579, 602-604, 612-613, 652-653
packages/appkit/src/universal-adapter/client.ts 53.45% 59.37% 36.11% 53.45% 20-21, 35-44, 95-99, 103, 105-109, 115, 125-158, 167-170, 173-176, 179-182, 184-187, 190-191, 194-195, 198-199, 202-203, 206-207, 210-211, 214-221, 234, 238-241, 257-258, 266-36, 126-180
packages/appkit/src/utils/HelpersUtil.ts 91.33% 95.34% 89.47% 91.33% 154-155, 214-217, 246, 304, 310-321, 344-350, 354-355
packages/common/src/utils/TypeUtil.ts 100% 100% 100% 100%
packages/controllers/exports/vue.ts 94.48% 93.54% 60% 94.48% 131-132, 204, 209, 214, 228, 291-294, 330-333, 357, 362, 376
packages/controllers/src/controllers/ChainController.ts 78.35% 88% 74.72% 78.35% 179-190, 194-213, 217-227, 231-253, 275-276, 297-298, 386-393, 397-410, 417-418, 437-438, 452-453, 458-459, 462-463, 472-473, 478-479, 495-496, 514-515, 536-539, 560-567, 614-620, 633-634, 668-669, 721, 747-748, 776-777, 787-788, 101, 197, 745
packages/controllers/src/controllers/ConnectionController.ts 80.78% 80.2% 52.87% 80.78% 162, 217-221, 224-228, 257-261, 269-270, 277-296, 303, 311, 315, 319, 323, 327, 331, 335, 339, 370-371, 374-375, 410, 414, 448-450, 461-462, 497-498, 508-509, 511-512, 520-521, 523-524, 530-542, 383
packages/controllers/src/controllers/ConnectorController.ts 85.71% 97.36% 73.77% 85.71% 62-64, 129-131, 142, 197-198, 213-214, 224-232, 294-314, 331-336, 408, 412-413
packages/controllers/src/controllers/EnsController.ts 81.1% 57.14% 66.66% 81.1% 43, 47, 82-83, 97-98, 110-112, 121-122, 125-126, 134, 140-141, 149-150, 163-165, 174-177
packages/controllers/src/controllers/ModalController.ts 96.36% 94.23% 84.61% 96.36% 66-67, 78, 88
packages/controllers/src/controllers/SendController.ts 58.92% 71.11% 58.82% 58.92% 73, 117-119, 121, 132-133, 138-139, 142-143, 163-178, 221-236, 241-272, 278-279, 291, 293-309, 313-330, 154-268
packages/controllers/src/controllers/SwapController.ts 50.68% 75.3% 63.79% 50.68% 55-58, 185, 195-196, 226-231, 264-266, 275-276, 284-298, 327, 336-337, 345-348, 381, 388, 393-410, 419-421, 435-436, 447-448, 460, 467-468, 472-480, 484, 486, 488, 490, 535-544, 571-609, 613-667, 671-725, 730-778, 782-864, 776-860
packages/controllers/src/utils/BalanceUtil.ts 95.65% 100% 100% 95.65% 39, 48, 70
packages/controllers/src/utils/ConstantsUtil.ts 100% 0% 100% 100%
packages/controllers/src/utils/CoreHelperUtil.ts 68.82% 86.42% 59.09% 68.82% 30, 34, 59-60, 76, 80, 87-88, 103-104, 115, 138-139, 175, 191-192, 210-216, 225-229, 246-247, 259-267, 287-302, 322-327, 335, 340, 351, 359, 361, 363-364, 374-379, 383-386, 396, 401, 406, 425-436, 467, 471-475, 484-487, 490-492, 496-511, 514-539, 428-446
packages/controllers/src/utils/MobileWallet.ts 100% 90.9% 100% 100%
packages/controllers/src/utils/SIWXUtil.ts 78.39% 71.01% 60.86% 78.39% 41-42, 46-47, 52-53, 59-72, 81-82, 85-86, 89-90, 93-94, 106-107, 142, 164-165, 167-168, 178-180, 188-194, 259, 304-328, 415-426, 438-439, 307-334
packages/experimental/src/smart-session/controllers/SmartSessionsController.ts 62.43% 61.53% 50% 62.43% 52-56, 58-81, 89-90, 97-98, 125-126, 155-156, 164-167, 171-172, 175-177, 185-186, 194, 200-238
packages/experimental/src/smart-session/helper/index.ts 83% 65.78% 100% 83% 25-26, 104, 128-129, 134-135, 138-139, 144-145, 148-149, 156, 160, 162, 164
packages/pay/src/controllers/PayController.ts 91.01% 82.97% 85.71% 91.01% 100-101, 161-162, 196, 296-297, 301-302, 307-310, 320-321, 326-327, 331-332, 336-337, 340-341, 399-400, 512-525, 534-535
packages/pay/src/utils/PaymentUtil.ts 86.81% 85.71% 100% 86.81% 77-81, 85-86, 111-115
packages/scaffold-ui/src/partials/w3m-account-default-widget/index.ts 80.26% 83.33% 65% 80.26% 74-75, 84, 88-90, 153, 159-160, 181, 204-205, 243, 251-252, 270, 277-278, 300, 304-305, 308-309, 312-313, 328, 332-342, 356-358, 376-378, 381-382, 339
packages/scaffold-ui/src/partials/w3m-account-tokens-widget/index.ts 89.04% 100% 77.77% 89.04% 37, 40, 47-48, 60, 74, 88, 103
packages/scaffold-ui/src/partials/w3m-account-wallet-features-widget/index.ts 71.53% 77.04% 68.18% 71.53% 73-80, 84, 95-97, 140, 155, 159-160, 174, 177, 195, 215, 234, 254, 276-277, 279-280, 282-283, 290-294, 310, 312, 322, 326-327, 330-331, 334-354, 375-376, 383-394, 350-391
packages/scaffold-ui/src/partials/w3m-activity-list/index.ts 66.04% 78.37% 77.77% 66.04% 60-66, 69, 72-75, 91-92, 105-106, 133-134, 156, 168-179, 182-197, 209, 249, 281, 293-300, 303-304, 310-324, 334-335, 322
packages/scaffold-ui/src/partials/w3m-email-login-widget/index.ts 88.88% 87.87% 91.66% 88.88% 48, 59-61, 84, 144-145, 151-152, 168-169, 178-179
packages/scaffold-ui/src/partials/w3m-onramp-providers-footer/index.ts 93.54% 100% 100% 93.54% 46, 54
packages/scaffold-ui/src/views/w3m-account-settings-view/index.ts 13.93% 100% 0% 13.93% 59-79, 82-83, 87-157, 161-188, 191-212, 215-220, 223-231, 234-268, 271-272, 275-300, 303-306, 309-329, 332-334
packages/scaffold-ui/src/views/w3m-choose-account-name-view/index.ts 20.51% 100% 0% 20.51% 25-28, 32-50, 54-79, 82-96, 99-109, 107
packages/scaffold-ui/src/views/w3m-connecting-external-view/index.ts 76.03% 71.42% 71.42% 76.03% 33-34, 57-67, 74-75, 93-100, 103-109, 160
packages/scaffold-ui/src/views/w3m-connecting-wc-view/index.ts 76.33% 63.46% 66.66% 76.33% 53-54, 62, 71, 83-84, 93, 104-105, 134-136, 155-156, 170-171, 179-180, 191, 195-198, 203, 207, 224, 228-242
packages/scaffold-ui/src/views/w3m-email-verify-otp-view/index.ts 70.21% 70% 50% 70.21% 34-35, 53-59, 63-67
packages/scaffold-ui/src/views/w3m-network-switch-view/index.ts 21.51% 100% 0% 21.51% 38-39, 42-43, 46-47, 51-103, 107-116, 119-126, 129-137, 140-151
packages/scaffold-ui/src/views/w3m-onramp-providers-view/index.ts 91.91% 63.15% 87.5% 91.91% 35, 65, 86, 115-116, 119-120, 130
packages/scaffold-ui/src/views/w3m-profile-wallets-view/index.ts 82.87% 91.21% 78.04% 82.87% 128, 139-141, 147-152, 159-160, 205, 221, 259, 277, 296, 303-304, 347-349, 357, 371, 392, 447, 475, 518, 522-540, 558-563, 566, 584-585, 589-595, 603-604, 607-612, 622-625, 630-631, 687, 716, 732-733, 748-753, 759-764, 767-772
packages/scaffold-ui/src/views/w3m-register-account-name-view/index.ts 25.3% 100% 0% 25.3% 51-66, 70-71, 74-77, 81-101, 105-118, 136-141, 144-145, 148-155, 158-178, 181-193, 196-203, 206-246, 249-252
packages/scaffold-ui/src/views/w3m-swap-view/index.ts 78.07% 75% 96% 78.07% 103-107, 117-119, 122-124, 127-138, 161, 167-169, 182, 191-192, 195-196, 212, 225, 246, 267-268, 292, 334-343, 361-377, 421-422, 439-440
packages/scaffold-ui/src/views/w3m-unsupported-chain-view/index.ts 67.64% 81.25% 70% 67.64% 49, 91, 97-103, 109, 122-123, 130-135, 164-184, 124
packages/scaffold-ui/src/views/w3m-wallet-compatible-networks-view/index.ts 20.83% 100% 0% 20.83% 26-27, 30-31, 35-46, 50-86
packages/scaffold-ui/src/views/w3m-wallet-send-preview-view/index.ts 79.43% 91.3% 85.71% 79.43% 136, 147, 155-158, 165-184, 182
packages/siwe/core/helpers/index.ts 20% 100% 0% 20% 10-11, 14-15, 18-23
packages/siwe/scaffold/views/w3m-connecting-siwe-view/index.ts 7.95% 100% 0% 7.95% 22-26, 30-78, 82-131, 134-153, 91-151
packages/siwx/src/verifiers/EIP155Verifier.ts 100% 100% 100% 100%
packages/ui/src/composites/wui-profile-button-v2/index.ts 7.69% 100% 0% 7.69% 21-84
Generated in workflow #13109 for commit 7fac1cd by the Vitest Coverage Report Action

cursor[bot]

This comment was marked as 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.

Bug: Incorrect Data Type for Hex Fields

The data field, which represents arbitrary hex-encoded transaction calldata or bytecode, is incorrectly typed as Address instead of Hex. This is evident in instances where example data like 0xdeadbeef is cast as Address, despite Address being specifically for 20-byte Ethereum addresses.

apps/laboratory/src/components/Wagmi/WagmiSendCallsTest.tsx#L21-L22

to: vitalikEthAddress as Address,
data: '0xdeadbeef' as Address

packages/controllers/src/utils/TypeUtil.ts#L326-L327

to: CaipAddress
data: Address

packages/controllers/src/utils/TypeUtil.ts#L346-L347

to: CaipAddress
data: Address

Fix in Cursor


Bug: Type Mismatch: Private Keys as Addresses

Private keys are incorrectly cast as Address type instead of Hex. Private keys are hex-encoded secrets (32-byte values), distinct from Ethereum addresses (20-byte values). This type mismatch, particularly when passed to functions like privateKeyToAccount and executeActionsWithECDSAKey, can cause type errors or runtime issues.

apps/laboratory/src/components/Wagmi/WagmiPurchaseDonutAsyncPermissionsTest.tsx#L81-L82

chain,
ecdsaPrivateKey: privateKey as Address,

apps/laboratory/src/components/Wagmi/WagmiCreatePasskeySignerTest.tsx#L39-L40

if (storedLocalSignerPrivateKey) {
privateKeyToAccount(storedLocalSignerPrivateKey as Address)

apps/laboratory/src/context/LocalEcdsaKeyContext.tsx#L46-L47

}
const accountSigner = privateKeyToAccount(storedPrivateKey as Address)

Fix in Cursor


Bug: Signature Type Mismatch Causes Verification Failures

The signature parameter is incorrectly cast as Address type. It should be Hex as cryptographic signatures are hex-encoded data (typically 65 bytes), not 20-byte Ethereum addresses. This type mismatch can cause verification failures.

packages/siwx/src/verifiers/EIP155Verifier.ts#L30-L31

message: session.message.toString(),
signature: session.signature as Address,

Fix in Cursor


Bug: Incorrect Type Usage for Chain IDs

The Address type is incorrectly used where Hex is required for values representing chain IDs. This impacts:

  • WalletGetAssetsParams: assetFilter keys and chainFilter values.
  • WalletGetAssetsResponse: The top-level Record key.
  • EIP5792Utils.ts: Chain ID variables used with the fromHex function.

packages/controllers/src/utils/TypeUtil.ts#L1043-L1050

account: Address
assetFilter?: Record<Address, (Address | 'native')[]>
assetTypeFilter?: ('NATIVE' | 'ERC20')[]
chainFilter?: Address[]
}
export type WalletGetAssetsResponse = Record<
Address,

apps/laboratory/src/utils/EIP5792Utils.ts#L40-L41

.map(cId => {
const chainId = fromHex(cId as Address, 'number')

Fix in Cursor


Bug: Incorrect Data Type for Transaction Calldata

The data field in BlockchainApiGenerateSwapCalldataResponse and BlockchainApiGenerateApproveCalldataResponse is incorrectly typed as Address. This field, which represents transaction calldata, should be typed as Hex as it contains encoded function calls and parameters, not an address.

packages/controllers/src/utils/TypeUtil.ts#L326-L327

to: CaipAddress
data: Address

packages/controllers/src/utils/TypeUtil.ts#L346-L347

to: CaipAddress
data: Address

Fix in Cursor


Bug: Incorrect Type Casting for Public Keys

Public keys are incorrectly cast to Address type. As public keys are hex-encoded cryptographic data and not Ethereum addresses, they should be cast to Hex type instead.

apps/laboratory/src/utils/EncodingUtils.ts#L73-L74

return {
key: formattedPublicKey as Address,

packages/experimental/tests/smart-session/requestValidation/mockRequest.ts#L11-L12

data: {
keys: [{ type: 'secp256k1', publicKey: '0x123456' as Address }]

Fix in Cursor


Bug: Incorrect Hex Typing in Transaction Interfaces

The data field in transaction-related interfaces is incorrectly typed as Address when it should be Hex. This field represents arbitrary hex-encoded bytes (such as bytecode or function call data), not an Ethereum address.

packages/controllers/src/utils/TypeUtil.ts#L346-L347

to: CaipAddress
data: Address

Fix in Cursor


Was this report helpful? Give feedback by reacting with 👍 or 👎

@enesozturk enesozturk enabled auto-merge July 2, 2025 15:10
@enesozturk enesozturk added this pull request to the merge queue Jul 2, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 2, 2025
@enesozturk enesozturk added this pull request to the merge queue Jul 2, 2025
Merged via the queue into main with commit 2d96652 Jul 2, 2025
56 of 60 checks passed
@enesozturk enesozturk deleted the enes/apkt-2298-remove-type-castings-in-the-code-and-improve-error-handling branch July 2, 2025 16:11
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