Skip to content

Sequence diagram for JSON-RPC parse error handling in handleHttpRequest #612

@Dargon789

Description

@Dargon789

Reviewer's Guide

Improves security and infrastructure around the wallet app while adding a new wagmi-based demo project. Key changes include a cryptographically secure ID generator in the dapp client, safer JSON-RPC error responses, CI/config updates, and the introduction of a standalone Vite+wagmi React example app with basic wallet connectivity and UI wiring.

Sequence diagram for JSON-RPC parse error handling in handleHttpRequest

sequenceDiagram
  participant Client
  participant Server
  participant handleHttpRequest
  participant errorResponse

  Client->>Server: HTTP request with JSON body
  Server->>handleHttpRequest: handleHttpRequest(req, res, debug)
  handleHttpRequest->>handleHttpRequest: JSON.parse(body)
  alt parse error
    handleHttpRequest-->>handleHttpRequest: [throw SyntaxError]
    handleHttpRequest->>errorResponse: errorResponse(undefined, -32700, Parse_error)
    errorResponse-->>handleHttpRequest: generic_error_payload
    handleHttpRequest->>Client: HTTP 400 with generic Parse error JSON
  else valid JSON
    handleHttpRequest-->>Client: normal JSON-RPC response
  end
Loading

File-Level Changes

Change Details Files
Switch ID generation in the dapp transport to cryptographically secure randomness.
  • Replace Math.random-based ID suffix with crypto.getRandomValues using a Uint32Array
  • Generate a base-36 random string from two 32-bit values, padded and sliced to fixed length
  • Preserve existing Date.now-based prefix while improving entropy and predictability resistance
packages/wallet/dapp-client/src/DappTransport.ts
Harden HTTP JSON parse error handling in the primitives CLI server.
  • Catch JSON parse errors during request handling and log them server-side
  • Return a standardized JSON-RPC parse error response without echoing internal error details to clients
packages/wallet/primitives-cli/src/subcommands/server.ts
Adjust CI workflows and permissions for GitHub Actions and tests.
  • Add explicit contents read and issues write permissions to pnpm-format-label workflow to comply with GitHub permission model
  • Insert an extra pnpm install step without frozen lockfile before running tests build job to ensure dependencies are installed
.github/workflows/on_pr_pnpm-format-label.yml
.github/workflows/tests.yml
Introduce CircleCI configuration for Foundry-based solidity tests.
  • Define a CircleCI job that uses the foundry Docker image
  • Checkout code and initialize git submodules recursively
  • Run forge build and forge test -vvv as part of the test workflow
.circleci/config.yml
Add a new wagmi-based Vite React demo project with basic wallet connectivity.
  • Create a Vite+React TypeScript app scaffolded by create-wagmi with strict TS config and Biome linting
  • Configure wagmi with mainnet and sepolia chains plus injected, Coinbase Wallet, and WalletConnect connectors
  • Set up React Query client and WagmiProvider in main entry point
  • Define a large App component that initializes the Sequence wallet, manages environment/network selection, and exposes many demo actions (connect/auth flows, signing, transactions, token queries, and advanced wallet actions) via a button-driven UI
  • Add basic theming styles, HTML shell, vite config, and project metadata files including package.json, tsconfigs, README, .gitignore, and biome config
wagmi-project/package.json
wagmi-project/tsconfig.json
wagmi-project/tsconfig.node.json
wagmi-project/src/App.tsx
wagmi-project/src/main.tsx
wagmi-project/src/wagmi.ts
wagmi-project/src/index.css
wagmi-project/src/vite-env.d.ts
wagmi-project/index.html
wagmi-project/vite.config.ts
wagmi-project/README.md
wagmi-project/.gitignore
wagmi-project/.npmrc
wagmi-project/biome.json
Check in additional build/cache artifacts and lockfile updates from dependency tooling.
  • Update or add yarn.lock under the account abstraction sequence submodule path
  • Commit v8-compile-cache .MAP artifacts under the v8-compile-cache-0 hierarchy
lib/signals-implicit-mode/lib/sequence-v3/lib/account-abstraction/yarn.lock
v8-compile-cache-0/x64/11.3.244.8-node.19/zSprojectzSsequence.jszSnode_moduleszS.pnpmzS@preconstruct+cli@2.8.7zSnode_moduleszS@preconstructzSclizSbin.js.MAP
v8-compile-cache-0/x64/11.3.244.8-node.19/zSprojectzSworkspacezSnode_moduleszS.pnpmzS@preconstruct+cli@2.8.7zSnode_moduleszS@preconstructzSclizSbin.js.MAP

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Originally posted by @sourcery-ai[bot] in #611 (comment)

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdependenciesPull requests that update a dependency filedocumentationImprovements or additions to documentationduplicateThis issue or pull request already exists

Projects

Status

Done

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions