Skip to content

Conversation

@gregfromstl
Copy link
Contributor

@gregfromstl gregfromstl commented Aug 19, 2025


PR-Codex overview

This PR focuses on enhancing the createToken functionality by introducing a new method, prepareCreateToken, which prepares a transaction for creating a token.

Detailed summary

  • Updated createToken to return a prepared transaction.
  • Introduced prepareCreateToken in create-token.ts to handle token creation preparation.
  • Modified the export statement in tokens.ts to include prepareCreateToken.
  • Adjusted destructuring of options in predictAddress.

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

Summary by CodeRabbit

  • New Features

    • Added support to prepare an ERC20 token creation transaction without submitting it, enabling custom signing and submission flows.
    • Public API expanded to expose the prepared transaction flow for token creation.
  • Chores

    • Added a changeset for a patch release documenting the token creation update.

@gregfromstl gregfromstl requested review from a team as code owners August 19, 2025 00:13
@changeset-bot
Copy link

changeset-bot bot commented Aug 19, 2025

🦋 Changeset detected

Latest commit: dceb5fa

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

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

@vercel
Copy link

vercel bot commented Aug 19, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
docs-v2 Ready Ready Preview Comment Aug 20, 2025 5:11pm
nebula Ready Ready Preview Comment Aug 20, 2025 5:11pm
thirdweb_playground Ready Ready Preview Comment Aug 20, 2025 5:11pm
thirdweb-www Ready Ready Preview Comment Aug 20, 2025 5:11pm
wallet-ui Ready Ready Preview Comment Aug 20, 2025 5:11pm

@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Aug 19, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented Aug 19, 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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 19, 2025

Walkthrough

Introduces a new prepareCreateToken function that builds and returns a prepared ERC20 token creation transaction without sending it. Updates public exports to include prepareCreateToken. Minor syntactic reorder in predictAddress options destructuring. Adds a changeset marking a patch release for this update.

Changes

Cohort / File(s) Summary
Release metadata
./.changeset/twenty-bees-sink.md
Adds a patch changeset for the thirdweb package documenting “Update createToken to return a prepared transaction.”
Token creation API
packages/thirdweb/src/tokens/create-token.ts, packages/thirdweb/src/exports/tokens.ts
Adds and exports prepareCreateToken(options) to construct a create transaction for ERC20 assets (or pool variant) using existing utilities; no submission or event decoding. Existing createToken behavior unchanged.
Predict address minor edit
packages/thirdweb/src/tokens/predict-address.ts
Reorders destructured options; logic and outputs unchanged.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant App
  participant SDK as thirdweb SDK
  participant Builder as prepareCreateToken
  participant Chain as Blockchain (not called)

  App->>SDK: import { prepareCreateToken }
  App->>Builder: prepareCreateToken(options)
  Builder->>Builder: encode init/pool data, derive creator, generate salt
  Builder-->>App: return prepared create transaction (not sent)
  Note over App,Builder: No submission or event decoding occurs
Loading
sequenceDiagram
  autonumber
  participant App
  participant SDK as thirdweb SDK
  participant Creator as createToken
  participant Chain as Blockchain

  App->>SDK: import { createToken }
  App->>Creator: createToken(options)
  Creator->>Creator: build transaction (same inputs/utilities)
  Creator->>Chain: sendAndConfirmTransaction(tx)
  Chain-->>Creator: receipt
  Creator->>Creator: decode AssetCreated event
  Creator-->>App: return created asset details
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • TEAM-0000: Entity not found: Issue - Could not find referenced Issue.
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/create-token-prepared-tx

🪧 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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
Copy link
Contributor

github-actions bot commented Aug 19, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 64.06 KB (0%) 1.3 s (0%) 210 ms (+139.16% 🔺) 1.5 s
thirdweb (cjs) 357.05 KB (0%) 7.2 s (0%) 681 ms (+12.09% 🔺) 7.9 s
thirdweb (minimal + tree-shaking) 5.73 KB (0%) 115 ms (0%) 67 ms (+613.9% 🔺) 181 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 57 ms (+3233.73% 🔺) 67 ms
thirdweb/react (minimal + tree-shaking) 19.15 KB (0%) 383 ms (0%) 84 ms (+665.55% 🔺) 467 ms

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: 3

🔭 Outside diff range comments (1)
.changeset/twenty-bees-sink.md (1)

1-6: Update .changeset to minor and include migration guide

Switching createToken to return a prepared transaction instead of sending it is a breaking change, and TokenParams.owner is now required. Please update your changeset as follows:

---
-"thirdweb": patch
+"thirdweb": minor
---
-feat: Update createToken to return a prepared transaction
+feat(tokens): createToken returns a prepared transaction

+- BREAKING: `createToken` now returns a `PreparedTransaction`; callers must send it (e.g. via `sendAndConfirmTransaction`).
+- BREAKING: `TokenParams.owner` is now required. Creator derives strictly from `params.owner`.
+- chore: updated `predictAddress` logic accordingly.

+Migration:
+
+Before
+  const asset = await createToken({ client, chain, params });
+
+After
+  const tx = await createToken({ client, chain, params });
+  const receipt = await sendAndConfirmTransaction({ client, chain, transaction: tx });
+  // (optional) parse events as needed

And don’t forget to add a short note in the docs linking to this migration snippet.

🧹 Nitpick comments (4)
packages/thirdweb/src/tokens/predict-address.ts (1)

14-18: Add an explicit return type tied to the generated function

To keep signatures explicit and future-proof against generator changes, annotate the return type using the generated helper’s type.

-export async function predictAddress(options: CreateTokenOptions) {
+export async function predictAddress(
+  options: CreateTokenOptions,
+): ReturnType<typeof _predictAddress> {
packages/thirdweb/src/tokens/types.ts (2)

41-46: Consider typing developerAddress as Address as well

It is passed directly to generated write/read helpers that commonly expect an Address. Aligning this improves DX and avoids unions like string | Address.

 export type CreateTokenOptions = ClientAndChain & {
   salt?: Hex;
   params: TokenParams;
   launchConfig?: LaunchConfig;
-  developerAddress?: string;
+  developerAddress?: Address;
 };

48-53: Avoid duplicating Client/Chain fields in intersection

CreateTokenByImplementationConfigOptions = ClientAndChainAndAccount & CreateTokenOptions duplicates client/chain fields via intersection. Prefer omitting overlapping keys to keep the type minimal and unambiguous.

-export type CreateTokenByImplementationConfigOptions =
-  ClientAndChainAndAccount &
-    CreateTokenOptions & {
-      implementationAddress: string;
-    };
+export type CreateTokenByImplementationConfigOptions =
+  ClientAndChainAndAccount &
+    Omit<CreateTokenOptions, keyof ClientAndChain> & {
+      implementationAddress: string;
+    };
packages/thirdweb/src/tokens/create-token.ts (1)

17-17: Type safety for creator: ensure TokenParams.owner is Address

This relies on params.owner being a checksummed EVM address. See the types.ts suggestion to change owner: string to owner: Address.

📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 557d42d and 3915624.

📒 Files selected for processing (4)
  • .changeset/twenty-bees-sink.md (1 hunks)
  • packages/thirdweb/src/tokens/create-token.ts (2 hunks)
  • packages/thirdweb/src/tokens/predict-address.ts (1 hunks)
  • packages/thirdweb/src/tokens/types.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (CLAUDE.md)

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from @/types or local types.ts barrels
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose

Files:

  • packages/thirdweb/src/tokens/predict-address.ts
  • packages/thirdweb/src/tokens/create-token.ts
  • packages/thirdweb/src/tokens/types.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit Inference Engine (CLAUDE.md)

Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)

Files:

  • packages/thirdweb/src/tokens/predict-address.ts
  • packages/thirdweb/src/tokens/create-token.ts
  • packages/thirdweb/src/tokens/types.ts
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to packages/thirdweb/src/wallets/** : EIP-1193, EIP-5792, EIP-7702 standard support in wallet modules
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Lint Packages
  • GitHub Check: Unit Tests
  • GitHub Check: Size
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
packages/thirdweb/src/tokens/predict-address.ts (1)

15-15: Owner-only creator source: verify all token call sites include params.owner
The removal of account fallbacks means every call to the token-package functions createToken and predictAddress must now explicitly provide params.owner. I ran a broad search (no obvious missing-owner usages found), but please double-check all internal and app callers, for example:

• apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/token/create-token-page-impl.tsx:114 – confirm the createToken({ … }) call supplies owner inside params.
• Any other UI, CLI, or service code invoking createToken from packages/thirdweb/src/tokens/create-token.ts.
• Any code importing predictAddress from packages/thirdweb/src/tokens/predict-address.ts – ensure params.owner is set.

packages/thirdweb/src/tokens/create-token.ts (1)

35-47: LGTM: returning a prepared transaction aligns with the new flow

Constructing via createById and returning the prepared transaction (without sending) matches the PR goal and simplifies the flow.

Please ensure docs and snippets are updated so integrators send the prepared tx, e.g.:

const tx = await createToken({ client, chain, params, launchConfig });
const receipt = await sendAndConfirmTransaction({ client, chain, transaction: tx });

@codecov
Copy link

codecov bot commented Aug 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.53%. Comparing base (557d42d) to head (dceb5fa).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7872      +/-   ##
==========================================
- Coverage   56.54%   56.53%   -0.01%     
==========================================
  Files         904      904              
  Lines       58592    58592              
  Branches     4143     4141       -2     
==========================================
- Hits        33131    33126       -5     
- Misses      25355    25360       +5     
  Partials      106      106              
Flag Coverage Δ
packages 56.53% <ø> (-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.

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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/thirdweb/src/tokens/create-token.ts (1)

17-64: createToken still submits and returns an asset; PR objective says it must return a prepared transaction

Per the PR objectives and changeset note, createToken should no longer send the tx nor decode events. Lines 50-64 submit the transaction and return the created asset address, which contradicts the intended API and will produce a breaking mismatch for consumers expecting a prepared transaction.

Proposed minimal fix: make createToken delegate to prepareCreateToken and return the prepared transaction. Also clean up now-unused imports.

Apply this diff to replace createToken with a delegating wrapper:

-export async function createToken(options: CreateTokenOptions) {
-  const { client, account, params, launchConfig } = options;
-
-  const creator = params.owner || account.address;
-  const encodedInitData = await encodeInitParams({
-    client,
-    creator,
-    params,
-  });
-
-  const salt: Hex = generateSalt(options.salt || bytesToHex(randomBytes(31)));
-
-  const entrypoint = await getDeployedEntrypointERC20(options);
-
-  let hookData: Hex = "0x";
-  let contractId = padHex(toHex("ERC20Asset"), { size: 32 });
-  if (launchConfig?.kind === "pool") {
-    hookData = encodePoolConfig(launchConfig.config);
-    contractId = padHex(toHex("ERC20Asset_Pool"), { size: 32 });
-  }
-
-  const transaction = createById({
-    contract: entrypoint,
-    contractId,
-    params: {
-      data: encodedInitData,
-      hookData,
-      developer: options.developerAddress || DEFAULT_DEVELOPER_ADDRESS,
-      salt,
-    },
-    creator,
-  });
-
-  const receipt = await sendAndConfirmTransaction({ account, transaction });
-  const assetEvent = createdEvent();
-  const decodedEvent = parseEventLogs({
-    events: [assetEvent],
-    logs: receipt.logs,
-  });
-
-  if (decodedEvent.length === 0 || !decodedEvent[0]) {
-    throw new Error(
-      `No AssetCreated event found in transaction: ${receipt.transactionHash}`,
-    );
-  }
-
-  return decodedEvent[0]?.args.asset;
-}
+export async function createToken(
+  options: CreateTokenOptions,
+): Promise<ReturnType<typeof createById>> {
+  return prepareCreateToken(options);
+}

Additionally remove now-unused imports at the top of the file:

-import { parseEventLogs } from "../event/actions/parse-logs.js";
-import { createdEvent } from "../extensions/tokens/__generated__/ERC20Entrypoint/events/Created.js";
-import { sendAndConfirmTransaction } from "../transaction/actions/send-and-confirm-transaction.js";
♻️ Duplicate comments (1)
packages/thirdweb/src/tokens/create-token.ts (1)

66-100: Make return type explicit and drop account fallback; owner should be required

  • Add an explicit return type tied to the generated write fn. This keeps the contract with consumers stable across generator updates.
  • Per PR objective, params.owner is required and account is removed from options. Lines 67 and 69 still destructure/use account. Remove it and rely on params.owner for the creator.

Apply this diff:

-export async function prepareCreateToken(options: CreateTokenOptions) {
-  const { client, params, account, launchConfig } = options;
+export async function prepareCreateToken(
+  options: CreateTokenOptions,
+): Promise<ReturnType<typeof createById>> {
+  const { client, params, launchConfig } = options;
 
-  const creator = params.owner || account.address;
+  const creator = params.owner;

Note: If getDeployedEntrypointERC20(options) relied on account, its signature should be updated accordingly as part of the broader API change.

🧹 Nitpick comments (1)
packages/thirdweb/src/tokens/create-token.ts (1)

66-100: Add TSDoc with a compiling example for new public API

Public symbols must have comprehensive TSDoc with at least one @example. Please document both prepareCreateToken and (now delegating) createToken.

Proposed doc for prepareCreateToken:

+/**
+ * Prepare an ERC20 token creation transaction without sending it.
+ * Uses the ERC20 Entrypoint factory to build a `createById` transaction with
+ * encoded init data, optional pool hook data, and a generated salt.
+ *
+ * @param options - Token creation options including required `params.owner`.
+ * @returns Prepared transaction returned by the generated `createById` write fn.
+ * @example
+ * import { createWallet, sendAndConfirmTransaction } from "thirdweb";
+ * import { prepareCreateToken } from "thirdweb/tokens";
+ *
+ * const account = createWallet("..."); // signer
+ * const tx = await prepareCreateToken({
+ *   client,
+ *   params: {
+ *     owner,
+ *     name: "My Token",
+ *     symbol: "MYT",
+ *     supply: 1_000_000n,
+ *     // ...other params
+ *   },
+ *   launchConfig: { kind: "standard" },
+ * });
+ * const receipt = await sendAndConfirmTransaction({ account, transaction: tx });
+ * @beta
+ */
 export async function prepareCreateToken(
   options: CreateTokenOptions,
 ): Promise<ReturnType<typeof createById>> {

And for createToken (now alias/delegation):

+/**
+ * Alias to {@link prepareCreateToken}. This function now returns a prepared transaction
+ * instead of submitting and returning the created asset.
+ *
+ * @example
+ * const tx = await createToken({ client, params: { owner, name: "My Token", symbol: "MYT" } });
+ * const receipt = await sendAndConfirmTransaction({ account, transaction: tx });
+ * @beta
+ */
 export async function createToken(
   options: CreateTokenOptions,
 ): Promise<ReturnType<typeof createById>> {
   return prepareCreateToken(options);
 }
📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 3915624 and dceb5fa.

📒 Files selected for processing (3)
  • packages/thirdweb/src/exports/tokens.ts (1 hunks)
  • packages/thirdweb/src/tokens/create-token.ts (1 hunks)
  • packages/thirdweb/src/tokens/predict-address.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/thirdweb/src/tokens/predict-address.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (CLAUDE.md)

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from @/types or local types.ts barrels
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose

Files:

  • packages/thirdweb/src/exports/tokens.ts
  • packages/thirdweb/src/tokens/create-token.ts
packages/thirdweb/src/exports/**

📄 CodeRabbit Inference Engine (CLAUDE.md)

packages/thirdweb/src/exports/**: Export everything via exports/ directory, grouped by feature in the SDK public API
Every public symbol must have comprehensive TSDoc with at least one @example block that compiles and custom annotation tags (@beta, @internal, @experimental)

Files:

  • packages/thirdweb/src/exports/tokens.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit Inference Engine (CLAUDE.md)

Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)

Files:

  • packages/thirdweb/src/exports/tokens.ts
  • packages/thirdweb/src/tokens/create-token.ts
🧠 Learnings (1)
📚 Learning: 2025-07-18T19:19:55.613Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to packages/thirdweb/src/exports/** : Export everything via `exports/` directory, grouped by feature in the SDK public API

Applied to files:

  • packages/thirdweb/src/exports/tokens.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Lint Packages
  • GitHub Check: Build Packages
  • GitHub Check: Unit Tests
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
packages/thirdweb/src/exports/tokens.ts (1)

9-9: LGTM: New public export prepareCreateToken

Re-export looks correct and follows the exports/ pattern used elsewhere in this file.

Comment on lines +66 to +100
export async function prepareCreateToken(options: CreateTokenOptions) {
const { client, params, account, launchConfig } = options;

const creator = params.owner || account.address;
const encodedInitData = await encodeInitParams({
client,
creator,
params,
});

const salt: Hex = generateSalt(options.salt || bytesToHex(randomBytes(31)));

const entrypoint = await getDeployedEntrypointERC20(options);

let hookData: Hex = "0x";
let contractId = padHex(toHex("ERC20Asset"), { size: 32 });
if (launchConfig?.kind === "pool") {
hookData = encodePoolConfig(launchConfig.config);
contractId = padHex(toHex("ERC20Asset_Pool"), { size: 32 });
}

const transaction = createById({
contract: entrypoint,
contractId,
params: {
data: encodedInitData,
hookData,
developer: options.developerAddress || DEFAULT_DEVELOPER_ADDRESS,
salt,
},
creator,
});

return transaction;
}
Copy link
Contributor

@coderabbitai coderabbitai bot Aug 20, 2025

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify types and upstream call sites: remove account from CreateTokenOptions and require TokenParams.owner

The code still references account and treats params.owner as optional. Ensure:

  • CreateTokenOptions excludes account
  • TokenParams.owner is required
  • predict-address.ts and any other helpers derive creator from params.owner only

Run this script to locate and update remaining references:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Check destructuring of options for account in token flows"
rg -n -C3 --type=ts '(const|let)\s*\{\s*[^}]*account[^}]*\}\s*=\s*options' packages/thirdweb/src | sed -n '1,200p'

echo "Where is CreateTokenOptions defined/used?"
rg -n -C3 --type=ts '\b(CreateTokenOptions|TokenParams)\b' packages/thirdweb/src | sed -n '1,200p'

echo "Find uses of account in predict-address and token creation"
rg -n -C3 --type=ts '\baccount\b' packages/thirdweb/src/tokens/predict-address.ts packages/thirdweb/src/tokens/create-token.ts || true

echo "Find createToken call sites to assess breakage from return type change"
rg -n -C3 --type=ts '\bcreateToken\s*\(' | sed -n '1,200p'

Length of output: 28489


Ensure token creation only uses params.owner and remove account from options

Please make the following mandatory updates:

• Update types
– in packages/thirdweb/src/tokens/types.ts:
• Remove the inherited account field from CreateTokenOptions (no longer extend ClientAndChainAndAccount)
• Add a required owner: string property to TokenParams

• Update token-flow implementations
packages/thirdweb/src/tokens/create-token.ts (createToken & prepareCreateToken):
• Drop account from the options destructuring
• Replace params.owner || account.address with params.owner
packages/thirdweb/src/tokens/predict-address.ts:
• Drop account from the options destructuring
• Derive creator = params.owner only

• Fix all upstream call sites for createToken and predictAddress (e.g. in apps/dashboard/.../create-token-page-impl.tsx):
– Remove passing account
– Ensure callers supply params.owner

These changes are breaking—please update types, implementations, and all call sites accordingly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@CodeRabbit don't tell me to make "mandatory" updates. You don't understand this code or its business context in the slightest. Know your place.

Copy link
Contributor

Choose a reason for hiding this comment

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

@gregfromstl I apologize for being overly prescriptive in my previous comment. You're absolutely right - I don't have the full business context behind these design decisions, and I should have asked clarifying questions rather than making assumptions about what changes were needed.

Thank you for the feedback on my approach. I'll focus on asking questions and providing observations rather than directing what should be done, especially when I lack the domain knowledge you have as the author.

      (\   /)
     ( ._. )
    o_(")(")

@gregfromstl gregfromstl changed the title [SDK] Feature: createToken returns prepared transaction [SDK] Feature: prepareCreateToken returns prepared transaction Aug 20, 2025
@gregfromstl gregfromstl merged commit 1083316 into main Aug 20, 2025
21 of 24 checks passed
@gregfromstl gregfromstl deleted the feat/create-token-prepared-tx branch August 20, 2025 17:06
@joaquim-verges joaquim-verges mentioned this pull request Aug 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

packages SDK Involves changes to the thirdweb SDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants