Skip to content

# Sequence diagram for wallet connection flow in wagmi demo app #137

@Dargon789

Description

@Dargon789

Reviewer's Guide

Introduces a new secure ID generation strategy for the dapp client, adds a wagmi-based demo app scaffold, and configures multiple CI/security workflows and project metadata files (issue templates, security policy, pipelines, and funding).

Sequence diagram for wallet connection flow in wagmi demo app

sequenceDiagram
  actor User
  participant Browser
  participant App
  participant WagmiProvider
  participant ConnectHook
  participant Connector
  participant Blockchain

  User->>Browser: Load page
  Browser->>App: Render App component
  App->>WagmiProvider: Initialize with config
  App->>ConnectHook: useConnect()
  ConnectHook-->>App: connectors, connect, status, error

  User->>App: Click connect button for connector
  App->>ConnectHook: connect(connector)
  ConnectHook->>Connector: initiate connection
  Connector->>Blockchain: wallet RPC / authorization
  Blockchain-->>Connector: connection approved
  Connector-->>ConnectHook: connection result (account, chainId)
  ConnectHook-->>App: status updated to connected
  App-->>User: Render connected state and Disconnect button

  User->>App: Click Disconnect
  App->>Connector: disconnect()
  Connector->>Blockchain: terminate session
  Blockchain-->>Connector: disconnected
  Connector-->>App: status updated to disconnected
  App-->>User: Render disconnected state
Loading

Class diagram for updated DappTransport ID generation

classDiagram
  class DappTransport {
    -someInternalState
    +sendMessage(message)
    +receiveMessage(message)
    -generateId() string
  }

  class WindowCrypto {
    +getRandomValues(array Uint32Array) Uint32Array
  }

  class MathRandomLegacy {
    +random() number
  }

  DappTransport ..> WindowCrypto : uses
  DappTransport ..> MathRandomLegacy : replaces
Loading

Class diagram for wagmi React demo app structure

classDiagram
  class App {
    +App() JSXElement
  }

  class MainEntrypoint {
    +main() void
  }

  class WagmiProvider {
    +WagmiProvider(config Config, children ReactNode)
  }

  class QueryClientProvider {
    +QueryClientProvider(client QueryClient, children ReactNode)
  }

  class QueryClient {
    +QueryClient()
  }

  class Config {
    +chains Chain[]
    +connectors Connector[]
    +transports Map<int, Transport>
  }

  class Chain {
    +id int
    +name string
  }

  class Connector {
    +uid string
    +name string
    +connect() Promise<Account>
    +disconnect() Promise<void>
  }

  class AccountHookResult {
    +status string
    +addresses string[]
    +chainId int
  }

  class ConnectHookResult {
    +connect(connector Connector) void
    +connectors Connector[]
    +status string
    +error Error
  }

  class DisconnectHookResult {
    +disconnect() void
  }

  MainEntrypoint --> WagmiProvider : wraps
  WagmiProvider --> QueryClientProvider : wraps
  QueryClientProvider --> App : renders

  MainEntrypoint --> QueryClient : creates
  WagmiProvider --> Config : uses

  App --> AccountHookResult : useAccount
  App --> ConnectHookResult : useConnect
  App --> DisconnectHookResult : useDisconnect

  Config --> Chain : contains
  Config --> Connector : contains
Loading

File-Level Changes

Change Details Files
Use cryptographically secure randomness for DappTransport ID generation.
  • Replace Math.random-based ID suffix with crypto.getRandomValues using a Uint32Array.
  • Generate a base-36 random string from two 32-bit values and slice to 9 characters.
  • Preserve existing timestamp-based prefix while improving randomness quality.
packages/wallet/dapp-client/src/DappTransport.ts
Add wagmi-based React demo application scaffolded with Vite.
  • Create a new wagmi-project package with Vite/React/TypeScript tooling and dependencies.
  • Set up WagmiProvider, QueryClientProvider, and Buffer global in main entrypoint.
  • Implement a simple App component showing account status and allowing wallet connection/disconnection.
  • Configure wagmi client with mainnet and sepolia chains and common connectors.
  • Add Vite, TypeScript, Biome, and CSS configuration and boilerplate files for the new project.
wagmi-project/package.json
wagmi-project/tsconfig.json
wagmi-project/tsconfig.node.json
wagmi-project/vite.config.ts
wagmi-project/index.html
wagmi-project/src/main.tsx
wagmi-project/src/App.tsx
wagmi-project/src/wagmi.ts
wagmi-project/src/index.css
wagmi-project/src/vite-env.d.ts
wagmi-project/.gitignore
wagmi-project/.npmrc
wagmi-project/biome.json
wagmi-project/README.md
Introduce security scanning and CI pipeline configurations across multiple platforms.
  • Add GitHub Actions workflow to run Fortify AST SAST scans on master branch and PRs.
  • Configure CircleCI with a basic executor and placeholder job using a Docker image.
  • Add Azure Pipelines YAML for basic Node.js build on master branch.
.github/workflows/fortify.yml
.circleci/config.yml
azure-pipelines.yml
Add repository templates and security policy documentation.
  • Add GitHub issue templates for bug reports, feature requests, and a custom template.
  • Create SECURITY.md outlining supported versions and vulnerability reporting process.
  • Add FUNDING.json and CNAME placeholders for project funding and custom domain configuration.
.github/ISSUE_TEMPLATE/bug_report.md
.github/ISSUE_TEMPLATE/feature_request.md
.github/ISSUE_TEMPLATE/custom.md
SECURITY.md
FUNDING.json
CNAME
Add auxiliary project and cache-related files.
  • Introduce an empty .codesandbox/tasks.json file for CodeSandbox integration.
  • Add V8 compile cache map artifacts under v8-compile-cache-0/.
  • Add various wagmi-project root config files such as .gitignore, .npmrc, and Biome configuration.
.codesandbox/tasks.json
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
wagmi-project/.gitignore
wagmi-project/.npmrc
wagmi-project/biome.json

Possibly linked issues

  • Fix merge branch 0xsequence/master #86: They match: this PR implements the wagmi app, Fortify workflow, CI, and templates requested in the issue.
  • Feature/integration #17: They both describe adding the wagmi React app plus SECURITY.md, Azure pipeline, and related scaffolding files.
  • 0xsequence/master #79: PR implements the Fortify workflow, CircleCI config, issue templates, and React Query upgrade described in the issue.

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 #136 (comment)

Sub-issues

Metadata

Metadata

Assignees

Labels

dependenciesPull requests that update a dependency filedocumentationImprovements or additions to documentationduplicateThis issue or pull request already existsenhancementNew feature or requestgood first issueGood for newcomershelp wantedExtra attention is neededinvalidThis doesn't seem rightjavascriptPull requests that update javascript codequestionFurther information is requested

Projects

Status

In Review

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions