Skip to content

Conversation

@tomiir
Copy link
Collaborator

@tomiir tomiir commented Nov 13, 2025

Description

  • Fire all send related events in the same method for consistency
  • Remove send events from UI

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-4271

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

Note

Centralizes SEND_* event emission in SendController.sendToken (initiated/success/rejected/error), removes event logic from submethods and UI, and updates tests accordingly.

  • Controllers (packages/controllers):
    • SendController:
      • Centralizes event tracking in sendToken() emitting SEND_INITIATED, SEND_SUCCESS, and SEND_REJECTED/SEND_ERROR with standardized properties (isSmartAccount, token, amount, network, hash).
      • Removes event emission from sendEvmToken(), sendNativeToken(), sendERC20Token(), and sendSolanaToken(); simplifies control flow and keeps hash assignment and balance updates.
      • Adds Event type usage and consolidates error handling (including user-rejection detection via ErrorUtil).
      • Enhances fetchTokenBalance() with onError callback and SnackController.showError('Token Balance Unavailable').
  • UI (packages/scaffold-ui):
    • w3m-wallet-send-preview-view: removes EventsController usage; relies on SendController.sendToken() for events; shows user-facing errors via SnackController and success via SnackController/navigation.
  • Tests:
    • Updates controller and view tests to assert new centralized event flow (SEND_INITIATEDSEND_SUCCESS/SEND_REJECTED/SEND_ERROR) and UI error display behavior.
  • Changeset:
    • Patch releases for @reown/appkit-controllers and @reown/appkit-scaffold-ui noting improved send flow events handling.

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

Copilot AI review requested due to automatic review settings November 13, 2025 15:25
@linear
Copy link

linear bot commented Nov 13, 2025

@changeset-bot
Copy link

changeset-bot bot commented Nov 13, 2025

🦋 Changeset detected

Latest commit: 24da3af

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

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

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

vercel bot commented Nov 13, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
appkit-basic-html Ready Ready Preview Comment Nov 13, 2025 4:04pm
appkit-demo Ready Ready Preview Comment Nov 13, 2025 4:04pm
appkit-gallery Ready Ready Preview Nov 13, 2025 4:04pm
appkit-headless-sample-app Ready Ready Preview Comment Nov 13, 2025 4:04pm
appkit-laboratory Ready Ready Preview Comment Nov 13, 2025 4:04pm
10 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
appkit-basic-example Ignored Ignored Nov 13, 2025 4:04pm
appkit-basic-sign-client-example Ignored Ignored Nov 13, 2025 4:04pm
appkit-basic-up-example Ignored Ignored Nov 13, 2025 4:04pm
appkit-ethers5-bera Ignored Ignored Nov 13, 2025 4:04pm
appkit-nansen-demo Ignored Ignored Nov 13, 2025 4:04pm
appkit-vue-solana Ignored Ignored Nov 13, 2025 4:04pm
appkit-wagmi-cdn-example Ignored Ignored Nov 13, 2025 4:04pm
ethereum-provider-wagmi-example Ignored Ignored Nov 13, 2025 4:04pm
next-wagmi-solana-bitcoin-example Ignored Ignored Nov 13, 2025 4:04pm
vue-wagmi-example Ignored Ignored Nov 13, 2025 4:04pm

@github-actions
Copy link
Contributor

github-actions bot commented Nov 13, 2025

Visual Regression Test Results ✅ Passed

✨ No visual changes detected

Chromatic Build: https://www.chromatic.com/build?appId=6493191bf4b10fed8ca7353f&number=415
Storybook Preview: https://6493191bf4b10fed8ca7353f-loigbfuxcf.chromatic.com/

Copilot finished reviewing on behalf of tomiir November 13, 2025 15:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors send-related event tracking to improve consistency by centralizing all event firing in the SendController.sendToken() method rather than having events scattered across UI components and various helper methods.

Key Changes:

  • Moved SEND_INITIATED, SEND_SUCCESS, SEND_REJECTED, and SEND_ERROR event tracking from UI and helper methods into the main sendToken() method
  • Replaced return statements with break statements in the chain namespace switch to allow the success event to fire after send completion
  • Removed duplicate event tracking calls from sendEvmToken(), sendNativeToken(), sendERC20Token(), and sendSolanaToken()

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/scaffold-ui/src/views/w3m-wallet-send-preview-view/index.ts Removed error event tracking from UI layer (SEND_REJECTED/SEND_ERROR), moving responsibility to controller
packages/controllers/src/controllers/SendController.ts Centralized all send-related event tracking in sendToken() method; added Event type import; replaced return with break statements in switch cases; removed duplicate event calls from helper methods

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 13, 2025

📦 Bundle Size Check

All bundles are within size limits

📊 View detailed bundle sizes

> @reown/[email protected] size /home/runner/work/appkit/appkit


> size-limit

@reown/appkit - Main Entry
Size limit:   80 kB
Size:         73.79 kB with all dependencies, minified and gzipped
Loading time: 1.5 s    on slow 3G
Running time: 667 ms   on Snapdragon 410
Total time:   2.2 s
@reown/appkit/react
Size limit:   230 kB
Size:         224.65 kB with all dependencies, minified and gzipped
Loading time: 4.4 s     on slow 3G
Running time: 1.2 s     on Snapdragon 410
Total time:   5.6 s
@reown/appkit/vue
Size limit:   80 kB
Size:         73.79 kB with all dependencies, minified and gzipped
Loading time: 1.5 s    on slow 3G
Running time: 461 ms   on Snapdragon 410
Total time:   2 s
@reown/appkit-scaffold-ui
Size limit:   220 kB
Size:         206.42 kB with all dependencies, minified and gzipped
Loading time: 4.1 s     on slow 3G
Running time: 648 ms    on Snapdragon 410
Total time:   4.7 s
@reown/appkit-ui
Size limit:   500 kB
Size:         13.15 kB with all dependencies, minified and gzipped
Loading time: 257 ms   on slow 3G
Running time: 114 ms   on Snapdragon 410
Total time:   371 ms

@github-actions
Copy link
Contributor

github-actions bot commented Nov 13, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 79.67% 38085 / 47802
🔵 Statements 79.67% 38085 / 47802
🔵 Functions 77.74% 4116 / 5294
🔵 Branches 86.57% 9271 / 10709
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/controllers/src/controllers/SendController.ts 75.08% 69.87% 70.27% 75.08% 83, 155, 197-198, 201-202, 205-206, 217-218, 220-229, 275-290, 295-315, 321-322, 332-348, 355-356, 360-361, 385-386
packages/scaffold-ui/src/views/w3m-wallet-send-preview-view/index.ts 94.49% 89.28% 85.71% 94.49% 137, 148, 156-159, 164
Generated in workflow #16342 for commit 24da3af by the Vitest Coverage Report Action

Copy link

@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: Stale Hash Corrupts Transaction Events

The sendEvmToken method only updates state.hash when hash is truthy, but resetSend doesn't clear state.hash. If a transaction returns no hash, the SEND_SUCCESS event will incorrectly report the hash from a previous transaction instead of an empty string, causing event tracking to associate the wrong transaction hash with the current send operation.

packages/controllers/src/controllers/SendController.ts#L208-L228

if (SendController.state.token?.address) {
const { hash } = await SendController.sendERC20Token({
receiverAddress: SendController.state.receiverAddress,
tokenAddress: SendController.state.token.address,
sendTokenAmount: SendController.state.sendTokenAmount,
decimals: SendController.state.token.quantity.decimals
})
if (hash) {
state.hash = hash
}
} else {
const { hash } = await SendController.sendNativeToken({
receiverAddress: SendController.state.receiverAddress,
sendTokenAmount: SendController.state.sendTokenAmount,
decimals: SendController.state.token.quantity.decimals
})
if (hash) {
state.hash = hash
}

Fix in Cursor Fix in Web


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.

3 participants