diff --git a/packages/core/src/erc721/index.ts b/packages/core/src/erc721/index.ts index 551c543..66cd6cd 100644 --- a/packages/core/src/erc721/index.ts +++ b/packages/core/src/erc721/index.ts @@ -1,10 +1,9 @@ export type { ERC721, - ERC721IDData, ERC721Data, } from "./types.js"; -export { createERC721, createERC721Data, createERC721IDData } from "./utils.js"; +export { createERC721, createERC721Data } from "./utils.js"; export { solmateErc721ABI as solmateERC721ABI } from "../generated.js"; @@ -12,7 +11,6 @@ export { getERC721 } from "./publicActions/getERC721.js"; export { getERC721Approved } from "./publicActions/getERC721Approved.js"; export { getERC721BalanceOf } from "./publicActions/getERC721BalanceOf.js"; export { getERC721Data } from "./publicActions/getERC721Data.js"; -export { getERC721IDData } from "./publicActions/getERC721IDData.js"; export { getERC721IsApprovedForAll } from "./publicActions/getERC721IsApprovedForAll.js"; export { getERC721Name } from "./publicActions/getERC721Name.js"; export { getERC721Symbol } from "./publicActions/getERC721Symbol.js"; diff --git a/packages/core/src/erc721/publicActions/getERC721.test.ts b/packages/core/src/erc721/publicActions/getERC721.test.ts index 879b3fb..803b657 100644 --- a/packages/core/src/erc721/publicActions/getERC721.test.ts +++ b/packages/core/src/erc721/publicActions/getERC721.test.ts @@ -27,14 +27,7 @@ beforeAll(async () => { hash: deployHash, }); invariant(contractAddress); - erc721 = createERC721( - contractAddress, - "name", - "symbol", - 0n, - "mitch.com", - foundry.id, - ); + erc721 = createERC721(contractAddress, "name", "symbol", foundry.id); } else { await testClient.revert({ id }); } diff --git a/packages/core/src/erc721/publicActions/getERC721.ts b/packages/core/src/erc721/publicActions/getERC721.ts index ea17af1..0e001f4 100644 --- a/packages/core/src/erc721/publicActions/getERC721.ts +++ b/packages/core/src/erc721/publicActions/getERC721.ts @@ -5,13 +5,12 @@ import type { ERC721 } from "../types.js"; import { createERC721 } from "../utils.js"; import { getERC721Name } from "./getERC721Name.js"; import { getERC721Symbol } from "./getERC721Symbol.js"; -import { getERC721TokenURI } from "./getERC721TokenURI.js"; export type GetERC721Parameters = Omit< ReadContractParameters, "address" | "abi" | "functionName" | "args" > & { - erc721: Pick & + erc721: Pick & Partial>; }; @@ -24,19 +23,16 @@ export const getERC721 = < client: Client, args: GetERC721Parameters, type?: T, -): ReverseMirage<[string, string, string], GetERC721ReturnType, T> => +): ReverseMirage<[string, string], GetERC721ReturnType, T> => (type === undefined ? Promise.all([ getERC721Name(client, args), getERC721Symbol(client, args), - getERC721TokenURI(client, args), - ]).then(([name, symbol, tokenURI]) => + ]).then(([name, symbol]) => createERC721( args.erc721.address, name, symbol, - args.erc721.id, - tokenURI, args.erc721.chainID, args.blockNumber, ), @@ -46,16 +42,13 @@ export const getERC721 = < Promise.all([ getERC721Name(client, args, "select").read(), getERC721Symbol(client, args, "select").read(), - getERC721TokenURI(client, args, "select").read(), ]), - parse: ([name, symbol, tokenURI]) => + parse: ([name, symbol]) => createERC721( args.erc721.address, name, symbol, - args.erc721.id, - tokenURI, args.erc721.chainID, args.blockNumber, ), - }) as ReverseMirage<[string, string, string], GetERC721ReturnType, T>; + }) as ReverseMirage<[string, string], GetERC721ReturnType, T>; diff --git a/packages/core/src/erc721/publicActions/getERC721Approved.test.ts b/packages/core/src/erc721/publicActions/getERC721Approved.test.ts index f7b7d82..ac67485 100644 --- a/packages/core/src/erc721/publicActions/getERC721Approved.test.ts +++ b/packages/core/src/erc721/publicActions/getERC721Approved.test.ts @@ -27,14 +27,7 @@ beforeAll(async () => { hash: deployHash, }); invariant(contractAddress); - erc721 = createERC721( - contractAddress, - "name", - "symbol", - 0n, - "mitch.com", - foundry.id, - ); + erc721 = createERC721(contractAddress, "name", "symbol", foundry.id); const mintHash = await walletClient.writeContract({ abi: erc721ABI, @@ -60,6 +53,7 @@ beforeAll(async () => { test("read approved", async () => { const owner = await getERC721Approved(publicClient, { erc721, + id: 0n, }); expect(owner).toBe(BOB); }); @@ -69,6 +63,7 @@ test("read approved select", async () => { publicClient, { erc721, + id: 0n, }, "select", ); diff --git a/packages/core/src/erc721/publicActions/getERC721Approved.ts b/packages/core/src/erc721/publicActions/getERC721Approved.ts index 865928e..3407d61 100644 --- a/packages/core/src/erc721/publicActions/getERC721Approved.ts +++ b/packages/core/src/erc721/publicActions/getERC721Approved.ts @@ -13,7 +13,7 @@ import type { ERC721 } from "../types.js"; export type GetERC721ApprovedParameters = Omit< ReadContractParameters, "address" | "abi" | "functionName" | "args" -> & { erc721: Pick }; +> & { erc721: Pick; id: bigint }; export type GetERC721ApprovedReturnType = Address; @@ -30,7 +30,7 @@ export const getERC721Approved = < abi: solmateERC721ABI, address: args.erc721.address, functionName: "getApproved", - args: [args.erc721.id], + args: [args.id], }) : { read: () => @@ -38,7 +38,7 @@ export const getERC721Approved = < abi: solmateERC721ABI, address: args.erc721.address, functionName: "getApproved", - args: [args.erc721.id], + args: [args.id], }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc721/publicActions/getERC721BalanceOf.test.ts b/packages/core/src/erc721/publicActions/getERC721BalanceOf.test.ts index e03988c..c77b45b 100644 --- a/packages/core/src/erc721/publicActions/getERC721BalanceOf.test.ts +++ b/packages/core/src/erc721/publicActions/getERC721BalanceOf.test.ts @@ -27,14 +27,7 @@ beforeAll(async () => { hash: deployHash, }); invariant(contractAddress); - erc721 = createERC721( - contractAddress, - "name", - "symbol", - 0n, - "mitch.com", - foundry.id, - ); + erc721 = createERC721(contractAddress, "name", "symbol", foundry.id); const mintHash = await walletClient.writeContract({ abi: erc721ABI, diff --git a/packages/core/src/erc721/publicActions/getERC721Data.test.ts b/packages/core/src/erc721/publicActions/getERC721Data.test.ts index 1e6eb7a..1410c8d 100644 --- a/packages/core/src/erc721/publicActions/getERC721Data.test.ts +++ b/packages/core/src/erc721/publicActions/getERC721Data.test.ts @@ -27,14 +27,7 @@ beforeAll(async () => { hash: deployHash, }); invariant(contractAddress); - erc721 = createERC721( - contractAddress, - "name", - "symbol", - 0n, - "mitch.com", - foundry.id, - ); + erc721 = createERC721(contractAddress, "name", "symbol", foundry.id); const mintHash = await walletClient.writeContract({ abi: erc721ABI, diff --git a/packages/core/src/erc721/publicActions/getERC721DataMax.test.ts b/packages/core/src/erc721/publicActions/getERC721DataMax.test.ts index acb5392..8d23c77 100644 --- a/packages/core/src/erc721/publicActions/getERC721DataMax.test.ts +++ b/packages/core/src/erc721/publicActions/getERC721DataMax.test.ts @@ -20,14 +20,7 @@ test("erc721 max balance", async () => { hash: deployHash, }); invariant(contractAddress); - const erc721 = createERC721( - contractAddress, - "name", - "symbol", - 0n, - "https://mitch.com", - foundry.id, - ); + const erc721 = createERC721(contractAddress, "name", "symbol", foundry.id); await expect(() => getERC721Data(publicClient, { erc721, address: ALICE }), ).rejects.toThrowError(); diff --git a/packages/core/src/erc721/publicActions/getERC721IDData.test.ts b/packages/core/src/erc721/publicActions/getERC721IDData.test.ts deleted file mode 100644 index dfebb1f..0000000 --- a/packages/core/src/erc721/publicActions/getERC721IDData.test.ts +++ /dev/null @@ -1,71 +0,0 @@ -import invariant from "tiny-invariant"; -import type { Hex } from "viem"; -import { foundry } from "viem/chains"; -import { beforeAll, expect, test } from "vitest"; -import ERC721Bytecode from "../../../../../contracts/out/ERC721.sol/ERC721.json"; -import { ALICE } from "../../_test/constants.js"; -import { publicClient, testClient, walletClient } from "../../_test/utils.js"; -import { erc721ABI } from "../../generated.js"; -import type { ERC721 } from "../types.js"; -import { createERC721 } from "../utils.js"; -import { getERC721IDData } from "./getERC721IDData.js"; - -let id: Hex | undefined = undefined; - -let erc721: ERC721; - -beforeAll(async () => { - if (id === undefined || erc721 === undefined) { - const deployHash = await walletClient.deployContract({ - account: ALICE, - abi: erc721ABI, - bytecode: ERC721Bytecode.bytecode.object as Hex, - args: ["name", "symbol", "mitch.com"], - }); - - const { contractAddress } = await publicClient.waitForTransactionReceipt({ - hash: deployHash, - }); - invariant(contractAddress); - erc721 = createERC721( - contractAddress, - "name", - "symbol", - 0n, - "mitch.com", - foundry.id, - ); - - const mintHash = await walletClient.writeContract({ - abi: erc721ABI, - functionName: "mint", - address: contractAddress, - args: [ALICE, 0n], - }); - await publicClient.waitForTransactionReceipt({ hash: mintHash }); - } else { - await testClient.revert({ id }); - } - id = await testClient.snapshot(); -}); - -test("read id data", async () => { - const owner = await getERC721IDData(publicClient, { - erc721, - address: ALICE, - }); - expect(owner).toBe(true); -}); - -test("read id data select", async () => { - const rm = getERC721IDData( - publicClient, - { - erc721, - address: ALICE, - }, - "select", - ); - - expect(await rm.read().then((data) => rm.parse(data))).toBe(true); -}); diff --git a/packages/core/src/erc721/publicActions/getERC721IDData.ts b/packages/core/src/erc721/publicActions/getERC721IDData.ts deleted file mode 100644 index e5383b5..0000000 --- a/packages/core/src/erc721/publicActions/getERC721IDData.ts +++ /dev/null @@ -1,46 +0,0 @@ -import type { - Address, - Chain, - Client, - ReadContractParameters, - Transport, -} from "viem"; -import { readContract } from "viem/contract"; -import { solmateErc721ABI as solmateERC721ABI } from "../../generated.js"; -import type { ReverseMirage } from "../../types/rm.js"; -import type { ERC721, ERC721IDData } from "../types.js"; - -export type GetERC721IDDataParameters = Omit< - ReadContractParameters, - "address" | "abi" | "functionName" | "args" -> & { erc721: Pick; address: Address }; - -export type GetERC721IDDataReturnType = - ERC721IDData; - -export const getERC721IDData = < - TChain extends Chain | undefined, - TERC721 extends ERC721, - T extends "select" | undefined, ->( - client: Client, - args: GetERC721IDDataParameters, - type?: T, -): ReverseMirage, T> => - (type === undefined - ? readContract(client, { - abi: solmateERC721ABI, - address: args.erc721.address, - functionName: "ownerOf", - args: [args.erc721.id], - }).then((data) => data === args.address) - : { - read: () => - readContract(client, { - abi: solmateERC721ABI, - address: args.erc721.address, - functionName: "ownerOf", - args: [args.erc721.id], - }), - parse: (data) => data === args.address, - }) as ReverseMirage, T>; diff --git a/packages/core/src/erc721/publicActions/getERC721IsApprovedForAll.test.ts b/packages/core/src/erc721/publicActions/getERC721IsApprovedForAll.test.ts index 87dbad8..a0a489f 100644 --- a/packages/core/src/erc721/publicActions/getERC721IsApprovedForAll.test.ts +++ b/packages/core/src/erc721/publicActions/getERC721IsApprovedForAll.test.ts @@ -27,14 +27,7 @@ beforeAll(async () => { hash: deployHash, }); invariant(contractAddress); - erc721 = createERC721( - contractAddress, - "name", - "symbol", - 0n, - "mitch.com", - foundry.id, - ); + erc721 = createERC721(contractAddress, "name", "symbol", foundry.id); const approvedHash = await walletClient.writeContract({ abi: erc721ABI, diff --git a/packages/core/src/erc721/publicActions/getERC721Name.test.ts b/packages/core/src/erc721/publicActions/getERC721Name.test.ts index 68635e8..af836ae 100644 --- a/packages/core/src/erc721/publicActions/getERC721Name.test.ts +++ b/packages/core/src/erc721/publicActions/getERC721Name.test.ts @@ -27,14 +27,7 @@ beforeAll(async () => { hash: deployHash, }); invariant(contractAddress); - erc721 = createERC721( - contractAddress, - "name", - "symbol", - 0n, - "mitch.com", - foundry.id, - ); + erc721 = createERC721(contractAddress, "name", "symbol", foundry.id); } else { await testClient.revert({ id }); } diff --git a/packages/core/src/erc721/publicActions/getERC721OwnerOf.test.ts b/packages/core/src/erc721/publicActions/getERC721OwnerOf.test.ts index 861e6e1..e043023 100644 --- a/packages/core/src/erc721/publicActions/getERC721OwnerOf.test.ts +++ b/packages/core/src/erc721/publicActions/getERC721OwnerOf.test.ts @@ -27,14 +27,7 @@ beforeAll(async () => { hash: deployHash, }); invariant(contractAddress); - erc721 = createERC721( - contractAddress, - "name", - "symbol", - 0n, - "mitch.com", - foundry.id, - ); + erc721 = createERC721(contractAddress, "name", "symbol", foundry.id); const mintHash = await walletClient.writeContract({ abi: erc721ABI, @@ -52,6 +45,7 @@ beforeAll(async () => { test("read owner", async () => { const owner = await getERC721OwnerOf(publicClient, { erc721, + id: 0n, }); expect(owner).toBe(ALICE); }); @@ -61,6 +55,7 @@ test("read owner select", async () => { publicClient, { erc721, + id: 0n, }, "select", ); diff --git a/packages/core/src/erc721/publicActions/getERC721OwnerOf.ts b/packages/core/src/erc721/publicActions/getERC721OwnerOf.ts index 9909232..42eb31b 100644 --- a/packages/core/src/erc721/publicActions/getERC721OwnerOf.ts +++ b/packages/core/src/erc721/publicActions/getERC721OwnerOf.ts @@ -13,7 +13,7 @@ import type { ERC721 } from "../types.js"; export type GetERC721OwnerOfParameters = Omit< ReadContractParameters, "address" | "abi" | "functionName" | "args" -> & { erc721: Pick }; +> & { erc721: Pick; id: bigint }; export type GetERC721OwnerOfReturnType = Address; @@ -30,7 +30,7 @@ export const getERC721OwnerOf = < abi: solmateERC721ABI, address: args.erc721.address, functionName: "ownerOf", - args: [args.erc721.id], + args: [args.id], }) : { read: () => @@ -38,7 +38,7 @@ export const getERC721OwnerOf = < abi: solmateERC721ABI, address: args.erc721.address, functionName: "ownerOf", - args: [args.erc721.id], + args: [args.id], }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc721/publicActions/getERC721SupportsInterface.test.ts b/packages/core/src/erc721/publicActions/getERC721SupportsInterface.test.ts index 3e5685e..98c183b 100644 --- a/packages/core/src/erc721/publicActions/getERC721SupportsInterface.test.ts +++ b/packages/core/src/erc721/publicActions/getERC721SupportsInterface.test.ts @@ -27,14 +27,7 @@ beforeAll(async () => { hash: deployHash, }); invariant(contractAddress); - erc721 = createERC721( - contractAddress, - "name", - "symbol", - 0n, - "mitch.com", - foundry.id, - ); + erc721 = createERC721(contractAddress, "name", "symbol", foundry.id); } else { await testClient.revert({ id }); } diff --git a/packages/core/src/erc721/publicActions/getERC721Symbol.test.ts b/packages/core/src/erc721/publicActions/getERC721Symbol.test.ts index 02e6821..6e86cd1 100644 --- a/packages/core/src/erc721/publicActions/getERC721Symbol.test.ts +++ b/packages/core/src/erc721/publicActions/getERC721Symbol.test.ts @@ -27,14 +27,7 @@ beforeAll(async () => { hash: deployHash, }); invariant(contractAddress); - erc721 = createERC721( - contractAddress, - "name", - "symbol", - 0n, - "mitch.com", - foundry.id, - ); + erc721 = createERC721(contractAddress, "name", "symbol", foundry.id); } else { await testClient.revert({ id }); } diff --git a/packages/core/src/erc721/publicActions/getERC721TokenURI.test.ts b/packages/core/src/erc721/publicActions/getERC721TokenURI.test.ts index 5d19785..8e6af50 100644 --- a/packages/core/src/erc721/publicActions/getERC721TokenURI.test.ts +++ b/packages/core/src/erc721/publicActions/getERC721TokenURI.test.ts @@ -27,14 +27,7 @@ beforeAll(async () => { hash: deployHash, }); invariant(contractAddress); - erc721 = createERC721( - contractAddress, - "name", - "symbol", - 0n, - "mitch.com", - foundry.id, - ); + erc721 = createERC721(contractAddress, "name", "symbol", foundry.id); } else { await testClient.revert({ id }); } @@ -44,6 +37,7 @@ beforeAll(async () => { test("read uri", async () => { const uri = await getERC721TokenURI(publicClient, { erc721, + id: 0n, }); expect(uri).toBe("mitch.com"); }); @@ -53,6 +47,7 @@ test("read uri select", async () => { publicClient, { erc721, + id: 0n, }, "select", ); diff --git a/packages/core/src/erc721/publicActions/getERC721TokenURI.ts b/packages/core/src/erc721/publicActions/getERC721TokenURI.ts index 2625680..3f2ad96 100644 --- a/packages/core/src/erc721/publicActions/getERC721TokenURI.ts +++ b/packages/core/src/erc721/publicActions/getERC721TokenURI.ts @@ -7,7 +7,7 @@ import type { ERC721 } from "../types.js"; export type GetERC721TokenURIParameters = Omit< ReadContractParameters, "address" | "abi" | "functionName" | "args" -> & { erc721: Pick }; +> & { erc721: Pick; id: bigint }; export type GetERC721TokenURIReturnType = string; @@ -24,7 +24,7 @@ export const getERC721TokenURI = < abi: solmateERC721ABI, address: args.erc721.address, functionName: "tokenURI", - args: [args.erc721.id], + args: [args.id], }) : { read: () => @@ -32,7 +32,7 @@ export const getERC721TokenURI = < abi: solmateERC721ABI, address: args.erc721.address, functionName: "tokenURI", - args: [args.erc721.id], + args: [args.id], }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc721/types.ts b/packages/core/src/erc721/types.ts index eceaba9..099106b 100644 --- a/packages/core/src/erc721/types.ts +++ b/packages/core/src/erc721/types.ts @@ -6,19 +6,9 @@ export type ERC721 = Token<"erc721"> & { address: Address; name: string; symbol: string; - id: bigint; - tokenURI: string; blockCreated: bigint; }; -export type ERC721IDData = TokenData< - TERC721, - `${TERC721["type"]}IDData`, - { - owned: boolean; - } ->; - export type ERC721Data< TERC721 extends ERC721, TBalance extends number = number, diff --git a/packages/core/src/erc721/utils.test.ts b/packages/core/src/erc721/utils.test.ts index 0595597..ed68af5 100644 --- a/packages/core/src/erc721/utils.test.ts +++ b/packages/core/src/erc721/utils.test.ts @@ -1,49 +1,28 @@ import { zeroAddress } from "viem"; import { foundry } from "viem/chains"; -import { describe, expect, test } from "vitest"; -import { createERC721, createERC721Data, createERC721IDData } from "./utils.js"; +import { expect, test } from "vitest"; +import { createERC721, createERC721Data } from "./utils.js"; const erc721 = { type: "erc721", address: zeroAddress, name: "name", symbol: "symbol", - id: 0n, - tokenURI: "https://mitch.com", chainID: foundry.id, blockCreated: 0n, } as const; -describe("utils", () => { - test("can create erc721", () => { - expect( - createERC721( - zeroAddress, - "name", - "symbol", - 0n, - "https://mitch.com", - foundry.id, - ), - ).toStrictEqual(erc721); - }); - - test("can create erc721 id data", () => { - expect(createERC721IDData(erc721, true)).toStrictEqual({ - type: "erc721IDData", - token: erc721, - owned: true, - }); - }); +test("can create erc721", () => { + expect(createERC721(zeroAddress, "name", "symbol", foundry.id)).toStrictEqual( + erc721, + ); +}); - test("can create erc721 data", () => { - expect(createERC721Data(erc721, 6, [0n, 1n, 2n, 3n, 4n, 5n])).toStrictEqual( - { - type: "erc721Data", - balance: 6, - ids: [0n, 1n, 2n, 3n, 4n, 5n], - token: erc721, - }, - ); +test("can create erc721 data", () => { + expect(createERC721Data(erc721, 6, [0n, 1n, 2n, 3n, 4n, 5n])).toStrictEqual({ + type: "erc721Data", + balance: 6, + ids: [0n, 1n, 2n, 3n, 4n, 5n], + token: erc721, }); }); diff --git a/packages/core/src/erc721/utils.ts b/packages/core/src/erc721/utils.ts index 9b6aba9..f9bb7ff 100644 --- a/packages/core/src/erc721/utils.ts +++ b/packages/core/src/erc721/utils.ts @@ -1,6 +1,6 @@ import { type Address, getAddress } from "viem"; import type { Tuple } from "../types/tuple.js"; -import type { ERC721, ERC721Data, ERC721IDData } from "./types.js"; +import type { ERC721, ERC721Data } from "./types.js"; /** * Creates an {@link ERC721} @@ -9,8 +9,6 @@ export const createERC721 = ( address: Address, name: string, symbol: string, - id: bigint, - tokenURI: string, chainID: number, blockCreated = 0n, ): ERC721 => ({ @@ -18,24 +16,10 @@ export const createERC721 = ( address: getAddress(address), name, symbol, - id, - tokenURI, chainID, blockCreated, }); -/** - * Creates an {@link ERC721IDData} - */ -export const createERC721IDData = ( - erc721: TERC721, - owned: boolean, -): ERC721IDData => ({ - type: `${erc721.type as TERC721["type"]}IDData`, - token: erc721, - owned, -}); - /** * Creates an {@link ERC721Data} */ diff --git a/packages/core/src/erc721/walletActions/simulateERC721Approve.test.ts b/packages/core/src/erc721/walletActions/simulateERC721Approve.test.ts index 38e7391..94522d9 100644 --- a/packages/core/src/erc721/walletActions/simulateERC721Approve.test.ts +++ b/packages/core/src/erc721/walletActions/simulateERC721Approve.test.ts @@ -27,14 +27,7 @@ beforeEach(async () => { hash: deployHash, }); invariant(contractAddress); - erc721 = createERC721( - contractAddress, - "name", - "symbol", - 0n, - "https://mitch.com", - foundry.id, - ); + erc721 = createERC721(contractAddress, "name", "symbol", foundry.id); const mintHash = await walletClient.writeContract({ abi: erc721ABI, @@ -54,6 +47,7 @@ test("approve", async () => { const { request } = await simulateERC721Approve(publicClient, { args: { erc721, + id: 0n, spender: BOB, }, account: ALICE, @@ -62,5 +56,5 @@ test("approve", async () => { await publicClient.waitForTransactionReceipt({ hash }); - expect(await getERC721Approved(publicClient, { erc721 })).toBe(BOB); + expect(await getERC721Approved(publicClient, { erc721, id: 0n })).toBe(BOB); }); diff --git a/packages/core/src/erc721/walletActions/simulateERC721Approve.ts b/packages/core/src/erc721/walletActions/simulateERC721Approve.ts index 34d922b..e1e9e7a 100644 --- a/packages/core/src/erc721/walletActions/simulateERC721Approve.ts +++ b/packages/core/src/erc721/walletActions/simulateERC721Approve.ts @@ -11,7 +11,8 @@ import { solmateErc721ABI as solmateERC721 } from "../../generated.js"; import type { ERC721 } from "../types.js"; export type ERC721ApproveParameters = { - erc721: Pick; + erc721: Pick; + id: bigint; spender: Address; }; @@ -44,7 +45,7 @@ export const simulateERC721Approve = < >( client: Client, { - args: { erc721, spender }, + args: { erc721, spender, id }, ...request }: SimulateERC721ApproveParameters, ): Promise> => @@ -52,7 +53,7 @@ export const simulateERC721Approve = < address: erc721.address, abi: solmateERC721, functionName: "approve", - args: [spender, erc721.id], + args: [spender, id], ...request, } as unknown as SimulateContractParameters< typeof solmateERC721, diff --git a/packages/core/src/erc721/walletActions/simulateERC721SetApprovalForAll.test.ts b/packages/core/src/erc721/walletActions/simulateERC721SetApprovalForAll.test.ts index 277bf33..1ffa542 100644 --- a/packages/core/src/erc721/walletActions/simulateERC721SetApprovalForAll.test.ts +++ b/packages/core/src/erc721/walletActions/simulateERC721SetApprovalForAll.test.ts @@ -27,14 +27,7 @@ beforeEach(async () => { hash: deployHash, }); invariant(contractAddress); - erc721 = createERC721( - contractAddress, - "name", - "symbol", - 0n, - "https://mitch.com", - foundry.id, - ); + erc721 = createERC721(contractAddress, "name", "symbol", foundry.id); const mintHash = await walletClient.writeContract({ abi: erc721ABI, diff --git a/packages/core/src/erc721/walletActions/simulateERC721Transfer.test.ts b/packages/core/src/erc721/walletActions/simulateERC721Transfer.test.ts index c298122..87fe322 100644 --- a/packages/core/src/erc721/walletActions/simulateERC721Transfer.test.ts +++ b/packages/core/src/erc721/walletActions/simulateERC721Transfer.test.ts @@ -27,14 +27,7 @@ beforeEach(async () => { hash: deployHash, }); invariant(contractAddress); - erc721 = createERC721( - contractAddress, - "name", - "symbol", - 0n, - "https://mitch.com", - foundry.id, - ); + erc721 = createERC721(contractAddress, "name", "symbol", foundry.id); const mintHash = await walletClient.writeContract({ abi: erc721ABI, @@ -55,13 +48,14 @@ test("can transfer", async () => { args: { to: BOB, erc721, + id: 0n, }, account: ALICE, }); const hash = await walletClient.writeContract(request); await publicClient.waitForTransactionReceipt({ hash }); - expect(await getERC721OwnerOf(publicClient, { erc721 })).toBe(BOB); + expect(await getERC721OwnerOf(publicClient, { erc721, id: 0n })).toBe(BOB); }); test("can transfer safe", async () => { @@ -69,6 +63,7 @@ test("can transfer safe", async () => { args: { to: BOB, erc721, + id: 0n, data: "safe", }, account: ALICE, @@ -76,7 +71,7 @@ test("can transfer safe", async () => { const hash = await walletClient.writeContract(request); await publicClient.waitForTransactionReceipt({ hash }); - expect(await getERC721OwnerOf(publicClient, { erc721 })).toBe(BOB); + expect(await getERC721OwnerOf(publicClient, { erc721, id: 0n })).toBe(BOB); }); test("can transfer data", async () => { @@ -84,6 +79,7 @@ test("can transfer data", async () => { args: { to: BOB, erc721, + id: 0n, data: "0x", }, account: ALICE, @@ -91,5 +87,5 @@ test("can transfer data", async () => { const hash = await walletClient.writeContract(request); await publicClient.waitForTransactionReceipt({ hash }); - expect(await getERC721OwnerOf(publicClient, { erc721 })).toBe(BOB); + expect(await getERC721OwnerOf(publicClient, { erc721, id: 0n })).toBe(BOB); }); diff --git a/packages/core/src/erc721/walletActions/simulateERC721Transfer.ts b/packages/core/src/erc721/walletActions/simulateERC721Transfer.ts index a821941..f659314 100644 --- a/packages/core/src/erc721/walletActions/simulateERC721Transfer.ts +++ b/packages/core/src/erc721/walletActions/simulateERC721Transfer.ts @@ -12,7 +12,8 @@ import { solmateErc721ABI as solmateERC721 } from "../../generated.js"; import type { ERC721 } from "../types.js"; export type ERC721TransferParameters = { - erc721: Pick; + erc721: Pick; + id: bigint; from?: Address; to: Address; data?: "safe" | Hex; @@ -47,7 +48,7 @@ export const simulateERC721Transfer = < >( client: Client, { - args: { erc721, from, to, data }, + args: { erc721, from, to, data, id }, ...request }: SimulateERC721TransferParameters, ) => @@ -63,7 +64,7 @@ export const simulateERC721Transfer = < ? request.account.address : request.account))!, to, - erc721.id, + id, ], ...request, } as unknown as SimulateContractParameters< @@ -84,7 +85,7 @@ export const simulateERC721Transfer = < ? request.account.address : request.account))!, to, - erc721.id, + id, ], ...request, } as unknown as SimulateContractParameters< @@ -104,7 +105,7 @@ export const simulateERC721Transfer = < ? request.account.address : request.account))!, to, - erc721.id, + id, data, ], ...request, diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index a5e5407..95eb46f 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -65,17 +65,14 @@ export { export { type ERC721, - type ERC721IDData, type ERC721Data, createERC721, createERC721Data, - createERC721IDData, solmateERC721ABI, getERC721, getERC721Approved, getERC721BalanceOf, getERC721Data, - getERC721IDData, getERC721IsApprovedForAll, getERC721Name, getERC721Symbol,