Skip to content

Conversation

@joaquim-verges
Copy link
Member

@joaquim-verges joaquim-verges commented Sep 14, 2025


PR-Codex overview

This PR introduces a validation check in the useStepExecutor hook to ensure that a wallet is provided before executing transactions, enhancing error handling for transaction execution.

Detailed summary

  • Added a check to verify if flatTxs has elements and if wallet is not provided.
  • If the wallet is absent, an ApiError is thrown with code "INVALID_INPUT" and a message indicating the issue.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • Bug Fixes
    • Provides an immediate, clear error when attempting to execute transactions without a connected wallet.
    • Returns a standardized INVALID_INPUT (400) instead of failing later in the flow, reducing confusing failures.
    • Maintains existing behavior when a wallet is connected; onramp and execution paths are unchanged.
    • No public API changes; improves consistency and reliability of error handling.

@vercel
Copy link

vercel bot commented Sep 14, 2025

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

Project Deployment Preview Comments Updated (UTC)
docs-v2 Ready Ready Preview Comment Sep 14, 2025 11:41am
nebula Ready Ready Preview Comment Sep 14, 2025 11:41am
thirdweb_playground Ready Ready Preview Comment Sep 14, 2025 11:41am
thirdweb-www Ready Ready Preview Comment Sep 14, 2025 11:41am
wallet-ui Ready Ready Preview Comment Sep 14, 2025 11:41am

@changeset-bot
Copy link

changeset-bot bot commented Sep 14, 2025

⚠️ No Changeset found

Latest commit: 13ffc5d

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 14, 2025

Walkthrough

An early input validation was added to useStepExecutor’s execute function: when flattened transactions exist and no wallet is supplied, it throws an INVALID_INPUT ApiError before onramp handling. The rest of the onramp and transaction execution logic remains unchanged. No public API signatures were modified.

Changes

Cohort / File(s) Summary
Step Executor Hook
packages/thirdweb/src/react/core/hooks/useStepExecutor.ts
Added early check: if flatTxs.length > 0 and no wallet, throw ApiError (code: INVALID_INPUT, message: "No wallet provided to execute transactions", status 400) before onramp logic. Existing later wallet check and execution flow unchanged. No API signature changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Caller
  participant Hook as useStepExecutor.execute
  participant Onramp as Onramp Handler
  participant Tx as Tx Runner

  Caller->>Hook: execute(steps, wallet)
  rect rgba(200,230,255,0.4)
    note over Hook: New early validation
    Hook->>Hook: if flatTxs.length > 0 && !wallet
    Hook-->>Caller: throw ApiError(INVALID_INPUT, 400)
  end

  Hook->>Onramp: Handle onramp (if applicable)
  Onramp-->>Hook: Result / continue

  Hook->>Tx: Execute transactions
  Tx-->>Hook: Execution result
  Hook-->>Caller: Return result or downstream error
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description includes the repository template header and a PR-Codex summary describing the wallet validation change but leaves the template sections as placeholders rather than filled content. Specifically, "Notes for the reviewer" and "How to test" are not populated and there are no concrete test instructions, reproduction steps, or setup details. As a result reviewers lack actionable guidance to validate or exercise the change. Please complete the template by filling "Notes for the reviewer" with the rationale, important edge cases, and any behavioral or compatibility considerations, and fill "How to test" with specific unit/integration tests to run, manual reproduction steps or playground links and the expected outcomes; also include the Linear/issue tag if applicable and any special setup required to exercise the change.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "[SDK] Add wallet validation before executing transactions" concisely and accurately summarizes the primary change of adding an early wallet validation before transaction execution. It is specific to the SDK and directly relates to the modified behavior in useStepExecutor. This phrasing is clear for teammates scanning commit history.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch _SDK_Add_wallet_validation_before_executing_transactions

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 97e5080 and 13ffc5d.

📒 Files selected for processing (1)
  • packages/thirdweb/src/react/core/hooks/useStepExecutor.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from @/types or local types.ts barrels
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose

**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from @/types where applicable
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size

Files:

  • packages/thirdweb/src/react/core/hooks/useStepExecutor.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)

Files:

  • packages/thirdweb/src/react/core/hooks/useStepExecutor.ts
packages/thirdweb/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

packages/thirdweb/**/*.{ts,tsx}: Every public symbol must have comprehensive TSDoc with at least one compiling @example and a custom tag (@beta, @internal, @experimental, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
Lazy‑load heavy dependencies inside async paths (e.g., const { jsPDF } = await import("jspdf"))

Files:

  • packages/thirdweb/src/react/core/hooks/useStepExecutor.ts
🧬 Code graph analysis (1)
packages/thirdweb/src/react/core/hooks/useStepExecutor.ts (1)
packages/thirdweb/src/bridge/types/Errors.ts (1)
  • ApiError (11-36)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Lint Packages
  • GitHub Check: Build Packages
  • GitHub Check: Unit Tests
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
packages/thirdweb/src/react/core/hooks/useStepExecutor.ts (1)

411-417: Don't block onramp — gate or remove redundant early wallet check.

The early guard at packages/thirdweb/src/react/core/hooks/useStepExecutor.ts:411-417 duplicates the later wallet check (around line 433) and will prevent the onramp step from starting when flatTxs.length > 0 and no wallet is present.

Option A (gate to non-onramp flows):

-      if (flatTxs.length > 0 && !wallet) {
+      // Only require wallet upfront when there is no onramp step
+      if (flatTxs.length > 0 && !wallet && preparedQuote.type !== "onramp") {
         throw new ApiError({
           code: "INVALID_INPUT",
           message: "No wallet provided to execute transactions",
           statusCode: 400,
         });
       }

Option B (remove the early check; keep the later guard at line ~433):

-      if (flatTxs.length > 0 && !wallet) {
-        throw new ApiError({
-          code: "INVALID_INPUT",
-          message: "No wallet provided to execute transactions",
-          statusCode: 400,
-        });
-      }

If keeping any early check, retain the later one as well to catch mid-flight disconnects. Confirm intended UX: allow starting onramp without a wallet, or require wallet before starting.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • TEAM-0000: Entity not found: Issue - Could not find referenced Issue.

Comment @coderabbitai help to get the list of available commands and usage tips.

@joaquim-verges joaquim-verges marked this pull request as ready for review September 14, 2025 10:58
@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Sep 14, 2025
@joaquim-verges joaquim-verges requested review from a team as code owners September 14, 2025 10:58
Copy link
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link
Contributor

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 63.96 KB (0%) 1.3 s (0%) 204 ms (+272.23% 🔺) 1.5 s
thirdweb (cjs) 361.44 KB (0%) 7.3 s (0%) 597 ms (+26.17% 🔺) 7.9 s
thirdweb (minimal + tree-shaking) 5.73 KB (0%) 115 ms (0%) 57 ms (+2646.41% 🔺) 171 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 35 ms (+1446.11% 🔺) 45 ms
thirdweb/react (minimal + tree-shaking) 19.15 KB (0%) 383 ms (0%) 49 ms (+1628.41% 🔺) 432 ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

packages SDK Involves changes to the thirdweb SDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants