Skip to content

refactor: Blockchain API calls#4606

Merged
tomiir merged 28 commits intomainfrom
refactor/balance-calls
Jul 23, 2025
Merged

refactor: Blockchain API calls#4606
tomiir merged 28 commits intomainfrom
refactor/balance-calls

Conversation

@ganchoradkov
Copy link
Copy Markdown
Member

Description

Refactored the Send, Swap and Activity screens to improve the efficiency of http calls. Also implemented local caching to some of the blockchain api calls

Send page

Fetches tokens/price info only if a token is already selected, else they are fetched in token select screen

Activity page

Added temporary local cache to transactions history so users can still refresh the history but not hit the backend everytime the page is opened

Swap

  • Default native token amount set to 0 instead of 1
  • Starts network price interval only when both tokens are selected
  • Added visibility listener so the network price calls are disabled while the page is in background

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

https://linear.app/reown/issue/APKT-3169/activity-page-http-calls-improvement-proposal
https://linear.app/reown/issue/APKT-3168/send-page-http-calls-improvement-proposal
https://linear.app/reown/issue/APKT-3166/swap-page-http-calls-reduction-proposal

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

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Jul 4, 2025

⚠️ No Changeset found

Latest commit: 0992e53

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@vercel
Copy link
Copy Markdown

vercel bot commented Jul 4, 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 23, 2025 7:37am
appkit-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 23, 2025 7:37am
appkit-gallery ✅ Ready (Inspect) Visit Preview Jul 23, 2025 7:37am
appkit-laboratory ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 23, 2025 7:37am
10 Skipped Deployments
Name Status Preview Comments Updated (UTC)
appkit-basic-example ⬜️ Ignored (Inspect) Jul 23, 2025 7:37am
appkit-basic-sign-client-example ⬜️ Ignored (Inspect) Jul 23, 2025 7:37am
appkit-basic-up-example ⬜️ Ignored (Inspect) Visit Preview Jul 23, 2025 7:37am
appkit-ethers5-bera ⬜️ Ignored (Inspect) Jul 23, 2025 7:37am
appkit-nansen-demo ⬜️ Ignored (Inspect) Jul 23, 2025 7:37am
appkit-vue-solana ⬜️ Ignored (Inspect) Jul 23, 2025 7:37am
appkit-wagmi-cdn-example ⬜️ Ignored (Inspect) Jul 23, 2025 7:37am
ethereum-provider-wagmi-example ⬜️ Ignored (Inspect) Jul 23, 2025 7:37am
next-wagmi-solana-bitcoin-example ⬜️ Ignored (Inspect) Jul 23, 2025 7:37am
vue-wagmi-example ⬜️ Ignored (Inspect) Jul 23, 2025 7:37am

cursor[bot]

This comment was marked as outdated.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jul 4, 2025

Warnings
⚠️

🔑 Potential High‑entropy string detected in apps/laboratory/tests/wallet-features.spec.ts (line 13): 7674bb4e353bf5288676...

⚠️

🔑 Potential High‑entropy string detected in apps/laboratory/tests/wallet-features.spec.ts (line 14): c57ca95b47569778a828...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/src/controllers/BlockchainApiController.ts (line 54): 0xA0b86991c6218b36c1...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/src/controllers/BlockchainApiController.ts (line 60): 0x2791Bca1f2de4661ED...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/src/controllers/BlockchainApiController.ts (line 54): 0xA0b86991c6218b36c1...

⚠️

🔑 Potential High‑entropy string detected in packages/controllers/src/controllers/BlockchainApiController.ts (line 60): 0x2791Bca1f2de4661ED...

⚠️

🔑 Potential UUID detected in packages/controllers/src/controllers/BlockchainApiController.ts (line 46): 2b92315d-eab7-5bef-8...

⚠️

🔑 Potential UUID detected in packages/controllers/src/controllers/BlockchainApiController.ts (line 46): 2b92315d-eab7-5bef-8...

⚠️

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

⚠️

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

⚠️

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

⚠️

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

⚠️

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

⚠️

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

⚠️

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

⚠️

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

⚠️

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

⚠️

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

Generated by 🚫 dangerJS against 0992e53

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jul 4, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 77.61% 31406 / 40465
🔵 Statements 77.61% 31406 / 40465
🔵 Functions 68.95% 2588 / 3753
🔵 Branches 84.45% 6623 / 7842
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/common/src/utils/SafeLocalStorage.ts 96.61% 95.23% 100% 96.61% 68-69
packages/controllers/src/controllers/BlockchainApiController.ts 41.74% 69.44% 31.91% 41.74% 166-167, 173-174, 187-189, 209-210, 216, 231-269, 273-292, 296-308, 315-342, 350-351, 366-385, 389-418, 422-447, 457-460, 489-499, 503-516, 520-530, 534-552, 556-584, 588-606, 610-646, 650-659, 662-678, 291-333, 384-446, 515-677
packages/controllers/src/controllers/SwapController.ts 54.9% 75.23% 68.33% 54.9% 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, 579-609, 613-667, 671-725, 729-730, 745-746, 762-781, 785-867, 779-863
packages/controllers/src/utils/StorageUtil.ts 67.97% 83.25% 64.8% 67.97% 97-98, 116-119, 123-127, 135-136, 151-152, 161-164, 172-173, 182-185, 198-201, 208-209, 216-219, 223-227, 234-237, 241-246, 253-254, 261-262, 275-276, 287-288, 299-300, 312-313, 316-324, 327-331, 334-338, 346-347, 359-360, 366, 369, 371-372, 376-377, 385-392, 404-405, 410-418, 435-436, 451-452, 461-462, 470, 472-473, 476-477, 491-492, 502-503, 517-518, 526, 529, 531-532, 535-536, 553-554, 564-565, 576-577, 580-587, 775-783, 787-803, 806-836, 839-855, 858-866, 869-883, 889-899, 902-911, 810-823
packages/scaffold-ui/src/views/w3m-swap-view/index.ts 79.3% 70.88% 89.65% 79.3% 107-111, 121-123, 126-128, 131-146, 170, 221-225, 236, 245-246, 249-250, 266, 279, 300, 321-322, 346, 388-397, 415-431, 475-476, 493-494
packages/scaffold-ui/src/views/w3m-wallet-send-select-token-view/index.ts 92.55% 90.9% 86.66% 92.55% 63, 72, 95, 131, 164, 171-172
packages/scaffold-ui/src/views/w3m-wallet-send-view/index.ts 96.59% 95.65% 90% 96.59% 106, 152-153
packages/ui/src/composites/wui-token-list-item/index.ts 87.14% 82.35% 85.71% 87.14% 45-46, 100-103, 114-115, 118-119
Generated in workflow #13602 for commit 0992e53 by the Vitest Coverage Report Action

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

# Conflicts:
#	packages/common/src/utils/SafeLocalStorage.ts
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: Unnecessary API Calls Due to Mismanaged Subscriptions

The price fetching interval and visibility change subscription are mismanaged. The SwapController subscription unnecessarily restarts the price update interval and re-registers the visibility change listener on any state change, not just when tokens change. Furthermore, the interval, once started when sourceToken and toToken are present, continues to run and make unnecessary API calls even after these tokens are cleared, as there is no logic to stop it.

packages/scaffold-ui/src/views/w3m-swap-view/index.ts#L143-L147

if (newState.sourceToken && newState.toToken) {
this.watchTokensAndValues()
}
})

Fix in CursorFix in Web


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

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