Skip to content

[WIP] ERC20 assets #7321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft

[WIP] ERC20 assets #7321

wants to merge 8 commits into from

Conversation

kumaryash90
Copy link
Member

@kumaryash90 kumaryash90 commented Jun 11, 2025


PR-Codex overview

This PR focuses on enhancing the thirdweb library by introducing new functionality related to ERC20 assets, including event handling, token creation, and infrastructure deployment.

Detailed summary

  • Added new events for AssetEntrypointERC20 and FeeManager.
  • Introduced functions for creating and deploying ERC20 tokens.
  • Implemented getOrDeployERC20AssetImpl for managing asset implementations.
  • Enhanced event preparation and transaction handling for asset operations.
  • Updated constants for ERC20 settings and defaults.

The following files were skipped due to too many changes: packages/thirdweb/src/extensions/assets/__generated__/AssetEntrypointERC20/write/listAsset.ts, packages/thirdweb/src/extensions/assets/__generated__/AssetEntrypointERC20/write/distributeAsset.ts, packages/thirdweb/src/extensions/assets/__generated__/AssetEntrypointERC20/write/createAsset.ts, packages/thirdweb/src/extensions/assets/__generated__/AssetEntrypointERC20/write/sellAsset.ts, packages/thirdweb/src/extensions/assets/__generated__/AssetEntrypointERC20/write/buyAsset.ts, packages/thirdweb/src/extensions/assets/__generated__/ERC20Asset/write/initialize.ts, packages/thirdweb/src/extensions/assets/__generated__/AssetEntrypointERC20/write/addImplementation.ts, packages/thirdweb/src/extensions/assets/__generated__/AssetEntrypointERC20/write/createAssetById.ts, packages/thirdweb/src/extensions/assets/__generated__/AssetInfraDeployer/write/deployInfraProxyDeterministic.ts, packages/thirdweb/src/extensions/assets/__generated__/AssetEntrypointERC20/write/createAssetByImplementationConfig.ts, packages/thirdweb/src/assets/bootstrap.ts

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

Summary by CodeRabbit

  • New Features
    • Introduced support for the AssetEntrypointERC20 contract, enabling advanced asset creation, management, and distribution functionalities.
    • Added new functions and types for token creation, making it easier to create and manage tokens within the platform.
    • Enhanced exports for asset-related features, allowing for more streamlined imports and integration.

@kumaryash90 kumaryash90 requested review from jnsdls, joaquim-verges and a team as code owners June 11, 2025 14:14
Copy link

changeset-bot bot commented Jun 11, 2025

🦋 Changeset detected

Latest commit: ca39e62

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

This PR includes changesets to release 2 packages
Name Type
thirdweb Patch
@thirdweb-dev/wagmi-adapter 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

Copy link

vercel bot commented Jun 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-v2 ❌ Failed (Inspect) Jun 12, 2025 7:28pm
login ❌ Failed (Inspect) Jun 12, 2025 7:28pm
thirdweb_playground ❌ Failed (Inspect) Jun 12, 2025 7:28pm
thirdweb-www ❌ Failed (Inspect) Jun 12, 2025 7:28pm
wallet-ui ❌ Failed (Inspect) Jun 12, 2025 7:28pm

Copy link
Contributor

graphite-app bot commented Jun 11, 2025

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.

Copy link
Contributor

coderabbitai bot commented Jun 11, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

A new ABI JSON file for the AssetEntrypointERC20 contract interface was added, alongside new TypeScript files introducing a stub for a createToken function and its type. These are re-exported through the asset module's entry points, and a new aggregator file forwards all asset exports for broader accessibility.

Changes

File(s) Change Summary
packages/thirdweb/scripts/generate/abis/assets/AssetEntrypointERC20.json Added ABI JSON for AssetEntrypointERC20 contract, defining functions, events, and errors.
packages/thirdweb/src/assets/create-token.ts Introduced empty CreateTokenArgs type and stub createToken function.
packages/thirdweb/src/assets/index.ts Re-exported createToken and CreateTokenArgs from create-token.js.
packages/thirdweb/src/exports/assets.ts Added file re-exporting all from ../assets/index.js.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant AssetsModule
    participant CreateTokenStub

    User->>AssetsModule: import { createToken } from 'assets'
    User->>CreateTokenStub: createToken(params: CreateTokenArgs)
    CreateTokenStub-->>User: (no implementation/return)
Loading

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Jun 11, 2025
@kumaryash90 kumaryash90 marked this pull request as draft June 11, 2025 14:15
@kumaryash90 kumaryash90 added the DO NOT MERGE This pull request is still in progress and is not ready to be merged. label Jun 11, 2025
@kumaryash90 kumaryash90 changed the title OCR ERC20 assets integration [WIP] OCR ERC20 assets integration Jun 11, 2025
@kumaryash90 kumaryash90 changed the title [WIP] OCR ERC20 assets integration [WIP] ERC20 assets Jun 11, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
packages/thirdweb/src/assets/index.ts (1)

1-4: Same extension concern & future export growth

  1. Ensure the .js suffix plays nicely with the compiler/bundler (see previous note).
  2. As assets utilities grow, consider grouping exports in an index.ts barrel only once they stabilise; otherwise tree-shaking may pull in unfinished stubs.
packages/thirdweb/scripts/generate/abis/assets/AssetEntrypointERC20.json (1)

1-34: Nit: store ABI as generated artefact, not source

Committed raw ABI arrays bloat the repo (~4 KB here) and create noisy diffs. If this file is generated by a script in /scripts/generate, prefer ignoring it in Git and generating during build/publish instead.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 950bbae and 388c7a0.

⛔ Files ignored due to path filters (19)
  • packages/thirdweb/src/extensions/assets/__generated__/AssetEntrypointERC20/events/AssetCreated.ts is excluded by !**/__generated__/**
  • packages/thirdweb/src/extensions/assets/__generated__/AssetEntrypointERC20/events/AssetDistributed.ts is excluded by !**/__generated__/**
  • packages/thirdweb/src/extensions/assets/__generated__/AssetEntrypointERC20/events/ImplementationAdded.ts is excluded by !**/__generated__/**
  • packages/thirdweb/src/extensions/assets/__generated__/AssetEntrypointERC20/events/RewardLockerUpdated.ts is excluded by !**/__generated__/**
  • packages/thirdweb/src/extensions/assets/__generated__/AssetEntrypointERC20/events/RouterUpdated.ts is excluded by !**/__generated__/**
  • packages/thirdweb/src/extensions/assets/__generated__/AssetEntrypointERC20/read/getImplementation.ts is excluded by !**/__generated__/**
  • packages/thirdweb/src/extensions/assets/__generated__/AssetEntrypointERC20/read/getRewardLocker.ts is excluded by !**/__generated__/**
  • packages/thirdweb/src/extensions/assets/__generated__/AssetEntrypointERC20/read/getRouter.ts is excluded by !**/__generated__/**
  • packages/thirdweb/src/extensions/assets/__generated__/AssetEntrypointERC20/write/addImplementation.ts is excluded by !**/__generated__/**
  • packages/thirdweb/src/extensions/assets/__generated__/AssetEntrypointERC20/write/buyAsset.ts is excluded by !**/__generated__/**
  • packages/thirdweb/src/extensions/assets/__generated__/AssetEntrypointERC20/write/createAsset.ts is excluded by !**/__generated__/**
  • packages/thirdweb/src/extensions/assets/__generated__/AssetEntrypointERC20/write/createAssetById.ts is excluded by !**/__generated__/**
  • packages/thirdweb/src/extensions/assets/__generated__/AssetEntrypointERC20/write/createAssetByImplementationConfig.ts is excluded by !**/__generated__/**
  • packages/thirdweb/src/extensions/assets/__generated__/AssetEntrypointERC20/write/distributeAsset.ts is excluded by !**/__generated__/**
  • packages/thirdweb/src/extensions/assets/__generated__/AssetEntrypointERC20/write/initialize.ts is excluded by !**/__generated__/**
  • packages/thirdweb/src/extensions/assets/__generated__/AssetEntrypointERC20/write/listAsset.ts is excluded by !**/__generated__/**
  • packages/thirdweb/src/extensions/assets/__generated__/AssetEntrypointERC20/write/sellAsset.ts is excluded by !**/__generated__/**
  • packages/thirdweb/src/extensions/assets/__generated__/AssetEntrypointERC20/write/setRewardLocker.ts is excluded by !**/__generated__/**
  • packages/thirdweb/src/extensions/assets/__generated__/AssetEntrypointERC20/write/setRouter.ts is excluded by !**/__generated__/**
📒 Files selected for processing (4)
  • packages/thirdweb/scripts/generate/abis/assets/AssetEntrypointERC20.json (1 hunks)
  • packages/thirdweb/src/assets/create-token.ts (1 hunks)
  • packages/thirdweb/src/assets/index.ts (1 hunks)
  • packages/thirdweb/src/exports/assets.ts (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
packages/thirdweb/src/assets/create-token.ts

[error] 1-1: Don't use '{}' as a type.

Prefer explicitly define the object shape. '{}' means "any non-nullable value".

(lint/complexity/noBannedTypes)


[error] 3-3: This parameter is unused.

Unused variables usually are result of incomplete refactoring, typos and other source of bugs.
Unsafe fix: If this is intentional, prepend params with an underscore.

(lint/correctness/noUnusedVariables)

⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Lint Packages
  • GitHub Check: Build Packages
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Unit Tests
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
packages/thirdweb/src/exports/assets.ts (1)

1-1: Double-check relative path & extension

The re-export targets "../assets/index.js", but the source file is index.ts in the same tree.
This pattern is okay if tsc emits .js files beside .d.ts and the runtime resolution happens on compiled output. Otherwise you’ll hit module-not-found in tests or ts-node. Verify the build pipeline supports “import with .js extension from TS”.

packages/thirdweb/scripts/generate/abis/assets/AssetEntrypointERC20.json (1)

7-12:

❌ Incorrect review comment

Struct/event field size mismatch – potential ABI desync

Struct addImplementation.config uses bytes createHookData, but ImplementationAdded event declares bytes32 createHookData.
If the underlying Solidity contract really emits bytes32, calls encoding bytes will still compile but the event parser will truncate data.

Confirm the canonical Solidity source and align both the function parameter and event field to the same type.


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Searching for the ImplementationAdded event in Solidity files..."
rg -n "event ImplementationAdded" --glob "*.sol"
echo

echo "Context around event ImplementationAdded:"
rg -A3 -B3 "event ImplementationAdded" --glob "*.sol"
echo

echo "Searching for function addImplementation in Solidity files..."
rg -n "function addImplementation" --glob "*.sol"
echo

echo "Context around function addImplementation:"
rg -A3 -B3 "function addImplementation" --glob "*.sol"
echo

echo "Searching for structs related to ImplementationConfig or config:"
rg -n "struct .*Implementation.*" --glob "*.sol"
echo

echo "Context around those struct definitions:"
rg -A3 -B3 "struct .*Implementation.*" --glob "*.sol"

Length of output: 358


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Searching for the ImplementationAdded event in JSON ABI files..."
rg -n '"name":\s*"ImplementationAdded"' --glob "*.json"

echo
echo "Context around the ImplementationAdded event:"
rg -A5 -B5 '"name":\s*"ImplementationAdded"' --glob "*.json"

echo
echo "Inspecting createHookData field in this event:"
rg -A2 -B2 '"createHookData"' --glob "*.json"

Length of output: 216


No ImplementationAdded event in ABI – review comment can be ignored

The ABI at packages/thirdweb/scripts/generate/abis/assets/AssetEntrypointERC20.json only contains function definitions and does not declare any ImplementationAdded event (nor a bytes32 createHookData field). There is no mismatch to resolve.

Likely an incorrect or invalid review comment.

Copy link
Contributor

github-actions bot commented Jun 11, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 62.57 KB (0%) 1.3 s (0%) 233 ms (+187.43% 🔺) 1.5 s
thirdweb (cjs) 345.55 KB (0%) 7 s (0%) 649 ms (+7.25% 🔺) 7.6 s
thirdweb (minimal + tree-shaking) 5.7 KB (0%) 114 ms (0%) 77 ms (+1286.76% 🔺) 191 ms
thirdweb/chains (tree-shaking) 531 B (0%) 11 ms (0%) 14 ms (+708.98% 🔺) 24 ms
thirdweb/react (minimal + tree-shaking) 19.56 KB (0%) 392 ms (0%) 50 ms (+287.87% 🔺) 441 ms

Copy link

codecov bot commented Jun 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.57%. Comparing base (950bbae) to head (5298dab).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7321   +/-   ##
=======================================
  Coverage   55.57%   55.57%           
=======================================
  Files         909      909           
  Lines       58675    58675           
  Branches     4157     4160    +3     
=======================================
+ Hits        32608    32610    +2     
+ Misses      25960    25959    -1     
+ Partials      107      106    -1     
Flag Coverage Δ
packages 55.57% <ø> (+<0.01%) ⬆️

see 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DO NOT MERGE This pull request is still in progress and is not ready to be merged. packages SDK Involves changes to the thirdweb SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant