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 all send-flow telemetry in SendController.sendToken, removes event emissions from UI, and updates tests to cover new event lifecycle and error handling.

  • Controllers (packages/controllers)
    • Centralize send-flow events in SendController.sendToken: emits SEND_INITIATED, SEND_SUCCESS, SEND_REJECTED/SEND_ERROR with unified properties via getSdkEventProperties.
    • Remove event emissions from sendEvmToken/sendNativeToken/sendERC20Token/sendSolanaToken; keep balance updates; call resetSend only after overall success; preserve state.hash on reset.
    • Improve loading handling (setLoading around send), minor control-flow fixes, and add error-path telemetry.
    • fetchTokenBalance: add retry gating and SnackController.showError('Token Balance Unavailable') on failure.
  • UI (packages/scaffold-ui)
    • Remove send-flow event emissions from w3m-wallet-send-preview-view; delegate to SendController; show success/error snacks only.
  • Tests
    • Add/adjust tests for SEND_INITIATEDSEND_SUCCESS/SEND_REJECTED/SEND_ERROR lifecycle, Solana path via sendToken, loading state, and UI snack errors.
  • Changeset
    • Patch bumps for @reown/appkit-controllers and @reown/appkit-scaffold-ui with improved send-flow events handling.

Written by Cursor Bugbot for commit cd36fdd. 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: cd36fdd

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

This PR includes changesets to release 25 packages
Name Type
@reown/appkit-controllers Patch
@reown/appkit-scaffold-ui Patch
@reown/appkit-adapter-bitcoin Patch
@reown/appkit-adapter-ethers Patch
@reown/appkit-adapter-ethers5 Patch
@reown/appkit-adapter-solana Patch
@reown/appkit-adapter-ton Patch
@reown/appkit-adapter-wagmi Patch
@reown/appkit Patch
@reown/appkit-ui Patch
@reown/appkit-core Patch
@reown/appkit-utils Patch
@reown/appkit-siwe Patch
@reown/appkit-siwx Patch
@reown/appkit-wallet-button Patch
@reown/appkit-experimental Patch
@reown/appkit-pay Patch
@reown/appkit-cdn Patch
@reown/appkit-universal-connector Patch
@reown/appkit-testing Patch
@reown/appkit-common Patch
@reown/appkit-polyfills Patch
@reown/appkit-wallet Patch
@reown/appkit-cli Patch
@reown/appkit-codemod 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

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 Dec 8, 2025 8:31pm
appkit-demo Ready Ready Preview Comment Dec 8, 2025 8:31pm
appkit-gallery Ready Ready Preview Dec 8, 2025 8:31pm
appkit-headless-sample-app Ready Ready Preview Comment Dec 8, 2025 8:31pm
appkit-laboratory Ready Ready Preview Comment Dec 8, 2025 8:31pm
10 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
appkit-basic-example Ignored Ignored Dec 8, 2025 8:31pm
appkit-basic-sign-client-example Ignored Ignored Dec 8, 2025 8:31pm
appkit-basic-up-example Ignored Ignored Dec 8, 2025 8:31pm
appkit-ethers5-bera Ignored Ignored Dec 8, 2025 8:31pm
appkit-nansen-demo Ignored Ignored Dec 8, 2025 8:31pm
appkit-vue-solana Ignored Ignored Dec 8, 2025 8:31pm
appkit-wagmi-cdn-example Ignored Ignored Dec 8, 2025 8:31pm
ethereum-provider-wagmi-example Ignored Ignored Dec 8, 2025 8:31pm
next-wagmi-solana-bitcoin-example Ignored Ignored Dec 8, 2025 8:31pm
vue-wagmi-example Ignored Ignored Dec 8, 2025 8:31pm

@github-actions
Copy link
Contributor

github-actions bot commented Nov 13, 2025

Visual Regression Test Results ❌ Failed

⚠️ 6 visual change(s) detected

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

👉 Please review the visual changes in Chromatic and accept or reject them.

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/appkit-monorepo@1.7.1 size /home/runner/work/appkit/appkit


> size-limit

@reown/appkit - Main Entry
Size limit:   80 kB
Size:         71.3 kB with all dependencies, minified and gzipped
Loading time: 1.4 s   on slow 3G
Running time: 826 ms  on Snapdragon 410
Total time:   2.3 s
@reown/appkit/react
Size limit:   230 kB
Size:         228.36 kB with all dependencies, minified and gzipped
Loading time: 4.5 s     on slow 3G
Running time: 1.3 s     on Snapdragon 410
Total time:   5.8 s
@reown/appkit/vue
Size limit:   80 kB
Size:         71.3 kB with all dependencies, minified and gzipped
Loading time: 1.4 s   on slow 3G
Running time: 406 ms  on Snapdragon 410
Total time:   1.8 s
@reown/appkit-scaffold-ui
Size limit:   220 kB
Size:         209.67 kB with all dependencies, minified and gzipped
Loading time: 4.1 s     on slow 3G
Running time: 760 ms    on Snapdragon 410
Total time:   4.9 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: 100 ms   on Snapdragon 410
Total time:   357 ms

@github-actions
Copy link
Contributor

github-actions bot commented Nov 13, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 79.74% 38371 / 48115
🔵 Statements 79.74% 38371 / 48115
🔵 Functions 77.27% 4111 / 5320
🔵 Branches 86.6% 9329 / 10772
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 #16480 for commit cd36fdd 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


event: 'SEND_REJECTED'
})
} else {
EventsController.sendEvent(event)
Copy link

Choose a reason for hiding this comment

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

Bug: EVM user rejection shows generic error instead of specific message

The refactoring removes the conversion of user rejection errors to UserRejectedRequestError (which was done via throw new UserRejectedRequestError(err) in the old code). The new code just re-throws the original error (throw err). However, the UI in w3m-wallet-send-preview-view checks error.originalName === 'UserRejectedRequestError' to decide whether to show the original error message. Since the error is no longer wrapped, originalName won't match for EVM chains, causing users to see "Failed to send transaction. Please try again." instead of the actual rejection message like "User rejected request".

Additional Locations (1)

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