Skip to content

Switch to viem - #584

Open
sirpy wants to merge 18 commits into
masterfrom
switch-to-viem
Open

sirpy wants to merge 18 commits into
masterfrom
switch-to-viem

Conversation

@sirpy

@sirpy sirpy commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Description

Switch wallet to viem with fallback rpcs from chainlist use @goodwidget/core createviemfallbackclient

Summary by Sourcery

Migrate blockchain wallet operations from Web3 to viem with resilient RPC fallbacks while preserving local and KMS transaction workflows.

New Features:

  • Replace wallet blockchain clients with viem and GoodWidget fallback clients, using configured RPCs with Chainlist discovery as fallbacks.
  • Support viem-based contract reads, transaction encoding, native transfers, receipt handling, and local or KMS transaction signing.

Bug Fixes:

  • Improve transaction error normalization, nonce queue recovery, timeout handling, and reverted-transaction detection.

Enhancements:

  • Update blockchain configuration and wallet integrations to use viem clients, bigint-compatible values, and viem contract interfaces.
  • Remove obsolete staking and fishing task implementations and their related administrative endpoint and configuration.
  • Update wallet, verification, and GoodID integrations for viem contract and account representations.

Build:

  • Add viem and @goodwidget/core dependencies and update the lockfile.

Documentation:

  • Document viem wallet clients, RPC fallback behavior, contract usage, and isolated wallet test execution.

Tests:

  • Add comprehensive viem wallet coverage for fallback RPC creation, transaction submission, KMS signing, nonce handling, bigint values, and reverted transactions.
  • Migrate wallet tests from Web3 APIs to viem APIs and remove obsolete staking-related tests.

@sourcery-ai

sourcery-ai Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Sorry @sirpy, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 1 day and 1 hour by commenting @sourcery-ai review. Upgrade to get a review now.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unbounded retries on insufficient funds can stall staking operations, while unsafe post-broadcast lock release can corrupt nonce reservations and allow duplicate-nonce submissions.

7 open issues
What changed in this PR

Migrates the server’s blockchain wallet infrastructure from Web3.js to viem, using GoodWidget’s fallback clients while retaining KMS signing and queued transaction workflows.

Changes:

  • Adds configurable HTTP RPC fallbacks and Chainlist discovery.
  • Migrates wallet, contract, staking, and event operations to viem APIs.
  • Updates transaction handling, tests, documentation, dependencies, and lint rules.
File Description
src/​server/​verification/​verificationAPI.js Uses viem contract addresses and expands request logging.
src/​server/​utils/​helpers.js Applies formatting-only changes.
src/​server/​storage/​cron/​CleanupAbandonedSignups.js Reformats the cleanup query without changing behavior.
src/​server/​goodid/​veramo.js Retrieves signing accounts from the migrated wallet model.
src/​server/​blockchain/​Web3Wallet.js Implements viem clients, contract operations, and transaction submission.
src/​server/​blockchain/​stakingModelTasksV2.js Migrates staking and fishing operations to viem.
src/​server/​blockchain/​stakingModelTasksOld.js Migrates legacy staking and fishing operations to viem.
src/​server/​blockchain/​MultiWallet.js Uses viem contract addresses for chain filtering.
src/​server/​blockchain/​BaseAdminWallet.js Migrates faucet setup and reads to viem.
src/​server/​blockchain/​AdminWallet.js Migrates mainnet clients and transaction handling.
src/​server/​blockchain/​__tests__/​viemWallet.test.js Adds fallback, signing, receipt, and nonce tests.
src/​server/​blockchain/​__tests__/​stakingModelManager.test.js Updates staking tests for viem interfaces.
src/​server/​blockchain/​__tests__/​fishManager.test.js Updates fishing tests for viem interfaces.
src/​server/​blockchain/​__tests__/​baseWallet.test.js Updates contract-address assertions.
src/​server/​blockchain/​__tests__/​adminWalletKMS.test.js Migrates KMS transaction checks and removes the custom WETH test.
src/​server/​blockchain/​__tests__/​adminWallet.test.js Updates wallet reads and bigint assertions.
README.md Documents viem usage, RPC behavior, and wallet testing.
package.json Adds viem and GoodWidget dependencies.
.eslintrc Adjusts import validation for the new dependencies.

Review effort: Balanced

Comment thread src/server/blockchain/AdminWallet.js Resolved
Comment thread src/server/blockchain/AdminWallet.js Resolved
Comment thread src/server/blockchain/Web3Wallet.js Resolved
Comment thread src/server/blockchain/Web3Wallet.js Resolved
Comment thread src/server/blockchain/Web3Wallet.js Resolved
sirpy and others added 2 commits November 4, 2026 16:28
Convert bigint values to strings in transaction receipt.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: sirpy <671095+sirpy@users.noreply.github.com>

This branch has not been deployed

No deployments
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