Skip to content

Feat/x402#2402

Open
lwin-kyaw wants to merge 21 commits intomasterfrom
feat/x402
Open

Feat/x402#2402
lwin-kyaw wants to merge 21 commits intomasterfrom
feat/x402

Conversation

@lwin-kyaw
Copy link
Contributor

@lwin-kyaw lwin-kyaw commented Mar 18, 2026

Motivation and Context

Jira Link: https://consensyssoftware.atlassian.net/browse/EMBED-143?atlOrigin=eyJpIjoiYzYxN2I1NDE1OTQ4NDY0NjhlOGUzMzA4YTc0ZjUzMDMiLCJwIjoiaiJ9

Description

  • Add shared x402 payment-fetch support to @web3auth/no-modal and expose useX402Fetch from both the no-modal and modal React/Vue entry points.
  • Support both EVM and Solana payment flows, including provider-backed signers, Solana wallet signing, automatic account tracking, and a shim for x402 v2 402 responses that return payment requirements in the response body.
  • Add end-to-end demo coverage with a new x402-test-server, a wagmi React example, and Vue demo updates for Base Sepolia and Solana network switching.

Changes

  • Add shared x402 primitives in packages/no-modal/src/base/x402, including helpers to build EVM/Solana payment-aware fetch clients.
  • Add new useX402Fetch hooks for React and Vue in @web3auth/no-modal, then re-export the hook and related types through @web3auth/modal.
  • Normalize body-based x402 v2 402 responses into the PAYMENT-REQUIRED header so the underlying @x402/fetch client can handle servers that return payment requirements in the JSON body.
  • Add demo/x402-test-server, an Express app with free and paid endpoints like /weather, /premium-data, and /weather-plain for testing x402 flows against EVM and Solana networks.
  • Update demo/wagmi-react-app to include an X402 demo component, Base Sepolia chain config, and an env var for the x402 test content URL.
  • Update demo/vue-app-new to expose x402 actions in the dashboard, add Base Sepolia and Solana network switching helpers, and include the required config, translation, and env updates.
  • Refresh supporting dependencies and lockfiles for the x402 and Solana additions, and include a few small Vue/Solana integration fixes found during the demo work.

Test Plan

  • Start demo/x402-test-server with valid EVM and Solana recipient addresses.
  • Verify useX402Fetch succeeds from demo/wagmi-react-app on Base Sepolia.
  • Verify useX402Fetch succeeds from demo/vue-app-new for both EVM and Solana wallets.
  • Verify /weather-plain returns a body-based 402 response that is still handled correctly by the client shim.
  • Smoke test the new React/Vue exports from @web3auth/no-modal and @web3auth/modal.

Recordings (if appropriate):

React Hook

Screen.Recording.2026-03-20.at.7.52.48.PM.mov

Vue Composable

Screen.Recording.2026-03-20.at.7.51.42.PM.mov

Types of changes

  • 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)

Checklist:

  • My code follows the code style of this project. (run lint)
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My code requires a db migration.

AI Reviews

x402_auth_2.md
x402_auth_1.md


Note

Medium Risk
Adds a new payment-enabled fetch flow (useX402Fetch) plus chain/network switching logic and upgrades several core web3 dependencies, which could impact wallet/chain interactions in the demo apps.

Overview
Adds an x402 payment protocol demo to demo/vue-app-new, wiring useX402Fetch into the dashboard to fetch paid content via VITE_APP_X402_TEST_CONTENT_URL, with a one-click switch helper to Base Sepolia.

Improves chain handling in the Vue demo by adding explicit Solana devnet/mainnet switching, expanding supported EVM chains to include Base Sepolia (0x14a34), and defaulting the form store to include all configured EVM+Solana chains.

Housekeeping: ignores .npmrc, updates .env.sample files (Vue + wagmi React demo), fixes a reactive status binding in settings, and bumps/refreshes the demo’s dependency set and lockfile (notably @solana/kit, @toruslabs/*, and related transitive deps).

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

@vercel
Copy link

vercel bot commented Mar 18, 2026

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

Project Deployment Actions Updated (UTC)
web3auth-web Ready Ready Preview, Comment Mar 20, 2026 0:12am

Request Review

@lwin-kyaw lwin-kyaw marked this pull request as ready for review March 20, 2026 01:53
@lwin-kyaw lwin-kyaw changed the base branch from v10 to master March 20, 2026 06:01
}"
/>
<Tag v-bind="{ minWidth: 'inherit' }" :class="['uppercase', { '!bg-blue-400 text-white': status === CONNECTOR_STATUS.READY }]">
<Tag v-bind="{ minWidth: 'inherit' }" :class="['uppercase', { '!bg-blue-400 text-white': status.value === CONNECTOR_STATUS.READY }]">
Copy link

Choose a reason for hiding this comment

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

Vue template incorrectly accesses .value on auto-unwrapped ref

Medium Severity

In Vue 3 <script setup> templates, refs are automatically unwrapped. status comes from useWeb3Auth() (line 22) and is a ref, so in the template it's already the raw string value. Accessing status.value tries to read .value on the unwrapped string, yielding undefined. This means the condition status.value === CONNECTOR_STATUS.READY is always false, and the blue highlight styling is never applied. The original status === CONNECTOR_STATUS.READY was correct.

Fix in Cursor Fix in Web

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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

import { useEffect, useMemo, useState } from "react";

import { useChain } from "../../hooks";
import { useChain } from "../../hooks/useChain";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is to eliminate the circular import.

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.

1 participant