Skip to content

Commit b01bdcd

Browse files
committed
fix: updated createToken to just return a prepared tx
1 parent 557d42d commit b01bdcd

File tree

2 files changed

+12
-25
lines changed

2 files changed

+12
-25
lines changed

packages/thirdweb/src/tokens/create-token.ts

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import { bytesToHex, randomBytes } from "@noble/hashes/utils";
22
import type { Hex } from "viem";
3-
import { parseEventLogs } from "../event/actions/parse-logs.js";
4-
import { createdEvent } from "../extensions/tokens/__generated__/ERC20Entrypoint/events/Created.js";
53
import { createById } from "../extensions/tokens/__generated__/ERC20Entrypoint/write/createById.js";
6-
import { sendAndConfirmTransaction } from "../transaction/actions/send-and-confirm-transaction.js";
74
import { padHex, toHex } from "../utils/encoding/hex.js";
85
import { DEFAULT_DEVELOPER_ADDRESS } from "./constants.js";
96
import { getDeployedEntrypointERC20 } from "./get-entrypoint-erc20.js";
@@ -15,9 +12,9 @@ import {
1512
import type { CreateTokenOptions } from "./types.js";
1613

1714
export async function createToken(options: CreateTokenOptions) {
18-
const { client, account, params, launchConfig } = options;
15+
const { client, params, launchConfig } = options;
1916

20-
const creator = params.owner || account.address;
17+
const creator = params.owner;
2118
const encodedInitData = await encodeInitParams({
2219
client,
2320
creator,
@@ -47,18 +44,5 @@ export async function createToken(options: CreateTokenOptions) {
4744
creator,
4845
});
4946

50-
const receipt = await sendAndConfirmTransaction({ account, transaction });
51-
const assetEvent = createdEvent();
52-
const decodedEvent = parseEventLogs({
53-
events: [assetEvent],
54-
logs: receipt.logs,
55-
});
56-
57-
if (decodedEvent.length === 0 || !decodedEvent[0]) {
58-
throw new Error(
59-
`No AssetCreated event found in transaction: ${receipt.transactionHash}`,
60-
);
61-
}
62-
63-
return decodedEvent[0]?.args.asset;
47+
return transaction;
6448
}

packages/thirdweb/src/tokens/types.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import type { Hex } from "viem";
22
import type { FileOrBufferOrString } from "../storage/upload/types.js";
3-
import type { ClientAndChainAndAccount } from "../utils/types.js";
3+
import type {
4+
ClientAndChainAndAccount,
5+
ClientAndChain,
6+
} from "../utils/types.js";
47

58
export type TokenParams = {
69
name: string;
@@ -11,7 +14,7 @@ export type TokenParams = {
1114
symbol?: string;
1215
contractURI?: string;
1316
maxSupply: bigint;
14-
owner?: string;
17+
owner: string;
1518
};
1619

1720
export type PoolConfig = {
@@ -35,7 +38,7 @@ type LaunchConfig =
3538
| { kind: "pool"; config: PoolConfig }
3639
| { kind: "distribute"; config: DistributeConfig };
3740

38-
export type CreateTokenOptions = ClientAndChainAndAccount & {
41+
export type CreateTokenOptions = ClientAndChain & {
3942
salt?: Hex;
4043
params: TokenParams;
4144
launchConfig?: LaunchConfig;
@@ -44,6 +47,6 @@ export type CreateTokenOptions = ClientAndChainAndAccount & {
4447

4548
export type CreateTokenByImplementationConfigOptions =
4649
ClientAndChainAndAccount &
47-
CreateTokenOptions & {
48-
implementationAddress: string;
49-
};
50+
CreateTokenOptions & {
51+
implementationAddress: string;
52+
};

0 commit comments

Comments
 (0)