Skip to content

feat(sdk): add EthereumService with viem contract instances for all Audius ETH contracts#13929

Merged
rickyrombo merged 16 commits intomainfrom
mjp-ethereum-service
Mar 16, 2026
Merged

feat(sdk): add EthereumService with viem contract instances for all Audius ETH contracts#13929
rickyrombo merged 16 commits intomainfrom
mjp-ethereum-service

Conversation

@rickyrombo
Copy link
Contributor

Summary

  • Introduces EthereumService — a new SDK service exposing viem contract instances for all 10 Audius Ethereum contracts (AudiusToken, AudiusWormhole, Staking, DelegateManager, Governance, ServiceProviderFactory, ClaimsManager, EthRewardsManager, ServiceTypeManager, TrustedNotifierManager)
  • Follows SDK service patterns — uses getDefaultEthereumServiceConfig + mergeConfigWithDefaults for config, with per-environment address overrides
  • Moves Ethereum clients into the servicepublicClient, ethWalletClient, and audiusWalletClient are constructor params on EthereumService; no longer separate fields on ServicesContainer
  • Removes standalone helpers — callers use sdk.services.ethereum.<contract>.read.* directly instead of one-off helper functions
  • Removes @audius/common ethereum wrapper — deleted packages/common/src/services/ethereum/ethereum.ts; AudiusBackend.ts and useAudioBalance.ts now use sdk.services.ethereum contracts directly
  • Restores identity-relay ethWalletClient for web — web's audiusSdk.ts injects a custom EthereumService with a viem wallet client that proxies writes through IDENTITY_SERVICE/ethereum/rpc so identity pays gas fees

Key design decisions

  • Dual-client getContract({ client: { public, wallet } }) gives every contract instance both .read.* and .simulate.* (and .write.*) without needing to thread clients through every call site
  • Explicit GetContractReturnType<Abi, { public: PublicClient; wallet: WalletClient }> annotations on contract properties — avoids TypeScript "type too large to serialize" errors from inference
  • audiusWalletClient stored privately on EthereumService; permitAudioToken and wormholeTransferTokens use it directly for typed-data signing with no extra parameters

Test plan

  • Web typechecks pass (npm run typecheck in packages/web)
  • Common typechecks pass (npm run typecheck in packages/common)
  • SDK typechecks pass (npm run typecheck in packages/sdk)
  • ETH→SOL AUDIO transfer flow works (permit + Wormhole bridge) in web app
  • Wallet balance display works in web app (reads from audiusToken.read.balanceOf, staking.read.totalStakedFor, delegateManager.read.getTotalDelegatorStake)

🤖 Generated with Claude Code

@gitguardian
Copy link

gitguardian bot commented Mar 16, 2026

⚠️ GitGuardian has uncovered 9 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
4714545 Triggered Generic High Entropy Secret c567e27 packages/sdk/src/sdk/config/development.ts View secret
10622417 Triggered Generic High Entropy Secret c567e27 packages/sdk/src/sdk/config/development.ts View secret
1606950 Triggered Generic High Entropy Secret b46317f packages/sdk/src/sdk/config/production.ts View secret
10622416 Triggered Generic High Entropy Secret c567e27 packages/sdk/src/sdk/config/production.ts View secret
1606950 Triggered Generic High Entropy Secret c567e27 packages/sdk/src/sdk/config/production.ts View secret
2460750 Triggered Generic High Entropy Secret c567e27 packages/sdk/src/sdk/config/production.ts View secret
10622416 Triggered Generic High Entropy Secret b46317f packages/sdk/src/sdk/config/production.ts View secret
10622417 Triggered Generic High Entropy Secret b46317f packages/sdk/src/sdk/config/development.ts View secret
4714545 Triggered Generic High Entropy Secret b46317f packages/sdk/src/sdk/config/development.ts View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@changeset-bot
Copy link

changeset-bot bot commented Mar 16, 2026

🦋 Changeset detected

Latest commit: 7794bbd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@audius/sdk Major
@audius/sdk-legacy Patch
@audius/sp-actions Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Base automatically changed from mjp-eth to main March 16, 2026 23:07
rickyrombo and others added 14 commits March 16, 2026 16:10
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…udius ETH contracts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…iusTokenAddress

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ervices

- Add ethWalletClient and ethPublicClient as injectable overrides in ServicesContainer
- createSdkWithServices uses injected clients when building EthereumService,
  then exposes them on the returned container via ethereum.ethWalletClient / .publicClient
- Web audiusSdk.ts only injects ethWalletClient (identity relay) — no longer
  needs to construct EthereumService manually
- WalletClient.ts uses ethereum.audiusWormhole.address instead of importing
  AudiusWormhole from @audius/eth directly
- Remove @audius/eth from packages/common dependencies

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Consistent with publicClient — both are unprefixed inside EthereumService
since the eth context is already implied by the class name.
ServicesContainer retains ethWalletClient/ethPublicClient for disambiguation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
getAddress() already returns Address (0x${string}), no cast needed.
Also drops unused Hex import from both files.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…t to EthereumService

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…alletClient

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rickyrombo rickyrombo force-pushed the mjp-ethereum-service branch from ceb8211 to a6a46cf Compare March 16, 2026 23:12
rickyrombo and others added 2 commits March 16, 2026 16:24
Conflict resolution during rebase accidentally changed sdk() — revert to
createSdkWithServices which wires up EthereumService automatically.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…diusBackend

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

🌐 Web preview ready

Preview URL: https://audius-web-preview-pr-13929.audius.workers.dev

Unique preview for this PR (deployed from this branch).
Workflow run

@rickyrombo rickyrombo merged commit 4f924fe into main Mar 16, 2026
15 checks passed
@rickyrombo rickyrombo deleted the mjp-ethereum-service branch March 16, 2026 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant