From 51e3d32c18bbe29f0cb0d3e096bfc5de6deecb3f Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Wed, 20 Sep 2023 17:40:25 -0400 Subject: [PATCH 01/42] docs(changeset): Restructure directory layout and extends viem client" --- .changeset/long-pillows-sip.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/long-pillows-sip.md diff --git a/.changeset/long-pillows-sip.md b/.changeset/long-pillows-sip.md new file mode 100644 index 0000000..250714d --- /dev/null +++ b/.changeset/long-pillows-sip.md @@ -0,0 +1,5 @@ +--- +"reverse-mirage": major +--- + +Restructure directory layout and extends viem client" From c17fe9deccfbdd40698f59afaef33bae40c415c8 Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Wed, 20 Sep 2023 17:41:18 -0400 Subject: [PATCH 02/42] RELEASING: Releasing 1 package(s) Releases: reverse-mirage@1.0.0-next.0 [skip ci] --- packages/core/CHANGELOG.md | 6 ++++++ packages/core/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index 2171a7c..627e6b3 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,11 @@ # reverse-mirage +## 1.0.0-next.0 + +### Major Changes + +- 51e3d32: Restructure directory layout and extends viem client" + ## 0.1.11 ### Patch Changes diff --git a/packages/core/package.json b/packages/core/package.json index 3d4b80d..23191af 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "reverse-mirage", - "version": "0.1.11", + "version": "1.0.0-next.0", "description": "Application level typescript utilities for Ethereum", "type": "module", "sideEffects": false, From a8eb6ed70d9d5bfea206a27aafab54ae4e261cb5 Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Wed, 20 Sep 2023 17:41:56 -0400 Subject: [PATCH 03/42] prerelease --- .changeset/pre.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .changeset/pre.json diff --git a/.changeset/pre.json b/.changeset/pre.json new file mode 100644 index 0000000..62889ec --- /dev/null +++ b/.changeset/pre.json @@ -0,0 +1,10 @@ +{ + "mode": "pre", + "tag": "next", + "initialVersions": { + "reverse-mirage": "0.1.11" + }, + "changesets": [ + "long-pillows-sip" + ] +} From 89be0b84ecb4a82ae570c12822c5115cb05edc25 Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Fri, 22 Sep 2023 11:56:49 -0400 Subject: [PATCH 04/42] refactor erc721 abi, remove id field --- packages/core/src/erc721/index.ts | 4 +- .../erc721/publicActions/getERC721.test.ts | 9 +-- .../src/erc721/publicActions/getERC721.ts | 17 ++--- .../publicActions/getERC721Approved.test.ts | 11 +-- .../erc721/publicActions/getERC721Approved.ts | 6 +- .../publicActions/getERC721BalanceOf.test.ts | 9 +-- .../publicActions/getERC721Data.test.ts | 9 +-- .../publicActions/getERC721DataMax.test.ts | 9 +-- .../publicActions/getERC721IDData.test.ts | 71 ------------------- .../erc721/publicActions/getERC721IDData.ts | 46 ------------ .../getERC721IsApprovedForAll.test.ts | 9 +-- .../publicActions/getERC721Name.test.ts | 9 +-- .../publicActions/getERC721OwnerOf.test.ts | 11 +-- .../erc721/publicActions/getERC721OwnerOf.ts | 6 +- .../getERC721SupportsInterface.test.ts | 9 +-- .../publicActions/getERC721Symbol.test.ts | 9 +-- .../publicActions/getERC721TokenURI.test.ts | 11 +-- .../erc721/publicActions/getERC721TokenURI.ts | 6 +- packages/core/src/erc721/types.ts | 10 --- packages/core/src/erc721/utils.test.ts | 47 ++++-------- packages/core/src/erc721/utils.ts | 18 +---- .../simulateERC721Approve.test.ts | 12 +--- .../walletActions/simulateERC721Approve.ts | 7 +- .../simulateERC721SetApprovalForAll.test.ts | 9 +-- .../simulateERC721Transfer.test.ts | 18 ++--- .../walletActions/simulateERC721Transfer.ts | 11 +-- packages/core/src/index.ts | 3 - 27 files changed, 67 insertions(+), 329 deletions(-) delete mode 100644 packages/core/src/erc721/publicActions/getERC721IDData.test.ts delete mode 100644 packages/core/src/erc721/publicActions/getERC721IDData.ts 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, From 88a51b06670e188deae36a2c8339cd7f7342f86a Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Fri, 22 Sep 2023 12:29:09 -0400 Subject: [PATCH 05/42] pass full request to reads --- .../src/erc1155/publicActions/getERC1155.ts | 28 ++++++++------- .../publicActions/getERC1155BalanceOf.ts | 16 +++++---- .../getERC1155IsApprovedForAll.ts | 12 ++++--- .../erc1155/publicActions/getERC1155URI.ts | 12 ++++--- .../core/src/erc20/publicActions/getERC20.ts | 26 +++++++------- .../erc20/publicActions/getERC20Allowance.ts | 16 +++++---- .../erc20/publicActions/getERC20BalanceOf.ts | 16 +++++---- .../erc20/publicActions/getERC20Decimals.ts | 8 +++-- .../publicActions/getERC20DomainSeparator.ts | 8 +++-- .../src/erc20/publicActions/getERC20Name.ts | 8 +++-- .../src/erc20/publicActions/getERC20Permit.ts | 30 ++++++++-------- .../erc20/publicActions/getERC20PermitData.ts | 26 ++++++++------ .../publicActions/getERC20PermitNonce.ts | 12 ++++--- .../src/erc20/publicActions/getERC20Symbol.ts | 8 +++-- .../publicActions/getERC20TotalSupply.ts | 12 ++++--- .../erc20/publicActions/getIsERC20Permit.ts | 34 +++++++++++-------- .../erc20/walletActions/signERC20Permit.ts | 2 ++ .../src/erc721/publicActions/getERC721.ts | 22 ++++++------ .../erc721/publicActions/getERC721Approved.ts | 12 ++++--- .../publicActions/getERC721BalanceOf.ts | 12 ++++--- .../src/erc721/publicActions/getERC721Data.ts | 23 ++++++++----- .../getERC721IsApprovedForAll.ts | 12 ++++--- .../src/erc721/publicActions/getERC721Name.ts | 8 +++-- .../erc721/publicActions/getERC721OwnerOf.ts | 12 ++++--- .../getERC721SupportsInterface.ts | 12 ++++--- .../erc721/publicActions/getERC721Symbol.ts | 8 +++-- .../erc721/publicActions/getERC721TokenURI.ts | 12 ++++--- .../native/publicActions/getNativeBalance.ts | 14 +++++--- 28 files changed, 242 insertions(+), 179 deletions(-) diff --git a/packages/core/src/erc1155/publicActions/getERC1155.ts b/packages/core/src/erc1155/publicActions/getERC1155.ts index 2ff4b85..1dfdcbf 100644 --- a/packages/core/src/erc1155/publicActions/getERC1155.ts +++ b/packages/core/src/erc1155/publicActions/getERC1155.ts @@ -20,38 +20,40 @@ export const getERC1155 = < T extends "select" | undefined, >( client: Client, - args: GetERC1155Parameters, + { erc1155, ...request }: GetERC1155Parameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC1155ABI, - address: args.erc1155.address, + address: erc1155.address, functionName: "uri", - args: [args.erc1155.id], + args: [erc1155.id], + ...request, }).then((data) => createERC1155( - args.erc1155.address, - args.erc1155.id, + erc1155.address, + erc1155.id, data, - args.erc1155.chainID, - args.blockNumber, + erc1155.chainID, + erc1155.blockCreated, ), ) : { read: () => readContract(client, { abi: solmateERC1155ABI, - address: args.erc1155.address, + address: erc1155.address, functionName: "uri", - args: [args.erc1155.id], + args: [erc1155.id], + ...request, }), parse: (data) => createERC1155( - args.erc1155.address, - args.erc1155.id, + erc1155.address, + erc1155.id, data, - args.erc1155.chainID, - args.blockNumber, + erc1155.chainID, + erc1155.blockCreated, ), }) as ReverseMirage; diff --git a/packages/core/src/erc1155/publicActions/getERC1155BalanceOf.ts b/packages/core/src/erc1155/publicActions/getERC1155BalanceOf.ts index c5a91ca..aef8698 100644 --- a/packages/core/src/erc1155/publicActions/getERC1155BalanceOf.ts +++ b/packages/core/src/erc1155/publicActions/getERC1155BalanceOf.ts @@ -25,23 +25,25 @@ export const getERC1155BalanceOf = < T extends "select" | undefined, >( client: Client, - args: GetERC1155BalanceOfParameters, + { erc1155, address, ...request }: GetERC1155BalanceOfParameters, type?: T, ): ReverseMirage, T> => (type === undefined ? readContract(client, { abi: solmateERC1155ABI, - address: args.erc1155.address, + address: erc1155.address, functionName: "balanceOf", - args: [args.address, args.erc1155.id], - }).then((data) => createERC1155Data(args.erc1155, data)) + args: [address, erc1155.id], + ...request, + }).then((data) => createERC1155Data(erc1155, data)) : { read: () => readContract(client, { abi: solmateERC1155ABI, - address: args.erc1155.address, + address: erc1155.address, functionName: "balanceOf", - args: [args.address, args.erc1155.id], + args: [address, erc1155.id], + ...request, }), - parse: (data) => createERC1155Data(args.erc1155, data), + parse: (data) => createERC1155Data(erc1155, data), }) as ReverseMirage, T>; diff --git a/packages/core/src/erc1155/publicActions/getERC1155IsApprovedForAll.ts b/packages/core/src/erc1155/publicActions/getERC1155IsApprovedForAll.ts index 05b885c..5bed0d9 100644 --- a/packages/core/src/erc1155/publicActions/getERC1155IsApprovedForAll.ts +++ b/packages/core/src/erc1155/publicActions/getERC1155IsApprovedForAll.ts @@ -22,23 +22,25 @@ export const getERC1155IsApprovedForAll = < T extends "select" | undefined, >( client: Client, - args: GetERC1155IsApprovedForAllParameters, + { erc1155, owner, spender, ...request }: GetERC1155IsApprovedForAllParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC1155ABI, - address: args.erc1155.address, + address: erc1155.address, functionName: "isApprovedForAll", - args: [args.owner, args.spender], + args: [owner, spender], + ...request, }) : { read: () => readContract(client, { abi: solmateERC1155ABI, - address: args.erc1155.address, + address: erc1155.address, functionName: "isApprovedForAll", - args: [args.owner, args.spender], + args: [owner, spender], + ...request, }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc1155/publicActions/getERC1155URI.ts b/packages/core/src/erc1155/publicActions/getERC1155URI.ts index 6eb0eaa..8a36ae7 100644 --- a/packages/core/src/erc1155/publicActions/getERC1155URI.ts +++ b/packages/core/src/erc1155/publicActions/getERC1155URI.ts @@ -16,23 +16,25 @@ export const getERC1155URI = < T extends "select" | undefined, >( client: Client, - args: GetERC1155URIParameters, + { erc1155, ...request }: GetERC1155URIParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC1155ABI, - address: args.erc1155.address, + address: erc1155.address, functionName: "uri", - args: [args.erc1155.id], + args: [erc1155.id], + ...request, }) : { read: () => readContract(client, { abi: solmateERC1155ABI, - address: args.erc1155.address, + address: erc1155.address, functionName: "uri", - args: [args.erc1155.id], + args: [erc1155.id], + ...request, }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc20/publicActions/getERC20.ts b/packages/core/src/erc20/publicActions/getERC20.ts index 1352bc8..1d071ac 100644 --- a/packages/core/src/erc20/publicActions/getERC20.ts +++ b/packages/core/src/erc20/publicActions/getERC20.ts @@ -22,38 +22,38 @@ export const getERC20 = < T extends "select" | undefined, >( client: Client, - args: GetERC20Parameters, + { erc20, ...request }: GetERC20Parameters, type?: T, ): ReverseMirage<[string, string, number], GetERC20NameReturnType, T> => (type === undefined ? Promise.all([ - getERC20Name(client, args), - getERC20Symbol(client, args), - getERC20Decimals(client, args), + getERC20Name(client, { erc20, ...request }), + getERC20Symbol(client, { erc20, ...request }), + getERC20Decimals(client, { erc20, ...request }), ]).then(([name, symbol, decimals]) => createERC20( - args.erc20.address, + erc20.address, name, symbol, decimals, - args.erc20.chainID, - args.erc20.blockCreated, + erc20.chainID, + erc20.blockCreated, ), ) : { read: () => Promise.all([ - getERC20Name(client, args, "select").read(), - getERC20Symbol(client, args, "select").read(), - getERC20Decimals(client, args, "select").read(), + getERC20Name(client, { erc20, ...request }, "select").read(), + getERC20Symbol(client, { erc20, ...request }, "select").read(), + getERC20Decimals(client, { erc20, ...request }, "select").read(), ]), parse: ([name, symbol, decimals]) => createERC20( - args.erc20.address, + erc20.address, name, symbol, decimals, - args.erc20.chainID, - args.erc20.blockCreated, + erc20.chainID, + erc20.blockCreated, ), }) as ReverseMirage<[string, string, number], GetERC20NameReturnType, T>; diff --git a/packages/core/src/erc20/publicActions/getERC20Allowance.ts b/packages/core/src/erc20/publicActions/getERC20Allowance.ts index 696bac0..dcba31a 100644 --- a/packages/core/src/erc20/publicActions/getERC20Allowance.ts +++ b/packages/core/src/erc20/publicActions/getERC20Allowance.ts @@ -25,23 +25,25 @@ export const getERC20Allowance = < T extends "select" | undefined, >( client: Client, - args: GetERC20AllowanceParameters, + { erc20, owner, spender, ...request }: GetERC20AllowanceParameters, type?: T, ): ReverseMirage, T> => (type === undefined ? readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "allowance", - args: [args.owner, args.spender], - }).then((data) => createAmountFromRaw(args.erc20, data)) + args: [owner, spender], + ...request, + }).then((data) => createAmountFromRaw(erc20, data)) : { read: () => readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "allowance", - args: [args.owner, args.spender], + args: [owner, spender], + ...request, }), - parse: (data) => createAmountFromRaw(args.erc20, data), + parse: (data) => createAmountFromRaw(erc20, data), }) as ReverseMirage, T>; diff --git a/packages/core/src/erc20/publicActions/getERC20BalanceOf.ts b/packages/core/src/erc20/publicActions/getERC20BalanceOf.ts index 2beac48..cab772e 100644 --- a/packages/core/src/erc20/publicActions/getERC20BalanceOf.ts +++ b/packages/core/src/erc20/publicActions/getERC20BalanceOf.ts @@ -25,23 +25,25 @@ export const getERC20BalanceOf = < T extends "select" | undefined, >( client: Client, - args: GetERC20BalanceOfParameters, + { erc20, address, ...request }: GetERC20BalanceOfParameters, type?: T, ): ReverseMirage, T> => (type === undefined ? readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "balanceOf", - args: [args.address], - }).then((data) => createAmountFromRaw(args.erc20, data)) + args: [address], + ...request, + }).then((data) => createAmountFromRaw(erc20, data)) : { read: () => readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "balanceOf", - args: [args.address], + args: [address], + ...request, }), - parse: (data) => createAmountFromRaw(args.erc20, data), + parse: (data) => createAmountFromRaw(erc20, data), }) as ReverseMirage, T>; diff --git a/packages/core/src/erc20/publicActions/getERC20Decimals.ts b/packages/core/src/erc20/publicActions/getERC20Decimals.ts index aaf7871..881c6bd 100644 --- a/packages/core/src/erc20/publicActions/getERC20Decimals.ts +++ b/packages/core/src/erc20/publicActions/getERC20Decimals.ts @@ -16,21 +16,23 @@ export const getERC20Decimals = < T extends "select" | undefined, >( client: Client, - args: GetERC20DecimalsParameters, + { erc20, ...request }: GetERC20DecimalsParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "decimals", + ...request, }) : { read: () => readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "decimals", + ...request, }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc20/publicActions/getERC20DomainSeparator.ts b/packages/core/src/erc20/publicActions/getERC20DomainSeparator.ts index a42097f..4044b30 100644 --- a/packages/core/src/erc20/publicActions/getERC20DomainSeparator.ts +++ b/packages/core/src/erc20/publicActions/getERC20DomainSeparator.ts @@ -22,21 +22,23 @@ export const getERC20DomainSeparator = < T extends "select" | undefined, >( client: Client, - args: GetERC20DomainSeparatorParameters, + { erc20, ...request }: GetERC20DomainSeparatorParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "DOMAIN_SEPARATOR", + ...request, }) : { read: () => readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "DOMAIN_SEPARATOR", + ...request, }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc20/publicActions/getERC20Name.ts b/packages/core/src/erc20/publicActions/getERC20Name.ts index 38df44c..db5e4e8 100644 --- a/packages/core/src/erc20/publicActions/getERC20Name.ts +++ b/packages/core/src/erc20/publicActions/getERC20Name.ts @@ -16,21 +16,23 @@ export const getERC20Name = < T extends "select" | undefined, >( client: Client, - args: GetERC20NameParameters, + { erc20, ...request }: GetERC20NameParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "name", + ...request, }) : { read: () => readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "name", + ...request, }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc20/publicActions/getERC20Permit.ts b/packages/core/src/erc20/publicActions/getERC20Permit.ts index 682031f..6b9adc9 100644 --- a/packages/core/src/erc20/publicActions/getERC20Permit.ts +++ b/packages/core/src/erc20/publicActions/getERC20Permit.ts @@ -22,41 +22,41 @@ export const getERC20Permit = < T extends "select" | undefined, >( client: Client, - args: GetERC20PermitParameters, + { erc20, ...request }: GetERC20PermitParameters, type?: T, ): ReverseMirage<[string, string, number], GetERC20PermitReturnType, T> => (type === undefined ? Promise.all([ - getERC20Name(client, args), - getERC20Symbol(client, args), - getERC20Decimals(client, args), + getERC20Name(client, { erc20, ...request }), + getERC20Symbol(client, { erc20, ...request }), + getERC20Decimals(client, { erc20, ...request }), ]).then(([name, symbol, decimals]) => createERC20Permit( - args.erc20.address, + erc20.address, name, symbol, decimals, - args.erc20.version ?? "1", - args.erc20.chainID, - args.erc20.blockCreated, + erc20.version ?? "1", + erc20.chainID, + erc20.blockCreated, ), ) : { read: () => Promise.all([ - getERC20Name(client, args, "select").read(), - getERC20Symbol(client, args, "select").read(), - getERC20Decimals(client, args, "select").read(), + getERC20Name(client, { erc20, ...request }, "select").read(), + getERC20Symbol(client, { erc20, ...request }, "select").read(), + getERC20Decimals(client, { erc20, ...request }, "select").read(), ]), parse: ([name, symbol, decimals]) => createERC20Permit( - args.erc20.address, + erc20.address, name, symbol, decimals, - args.erc20.version ?? "1", - args.erc20.chainID, - args.erc20.blockCreated, + erc20.version ?? "1", + erc20.chainID, + erc20.blockCreated, ), }) as ReverseMirage< [string, string, number], diff --git a/packages/core/src/erc20/publicActions/getERC20PermitData.ts b/packages/core/src/erc20/publicActions/getERC20PermitData.ts index 4c643b7..cc11c77 100644 --- a/packages/core/src/erc20/publicActions/getERC20PermitData.ts +++ b/packages/core/src/erc20/publicActions/getERC20PermitData.ts @@ -25,44 +25,48 @@ export const getERC20PermitData = < T extends "select" | undefined, >( client: Client, - args: GetERC20PermitDataParameters, + { erc20, address, ...request }: GetERC20PermitDataParameters, type?: T, ): ReverseMirage<[bigint, bigint], GetERC20PermitDataReturnType, T> => (type === undefined ? Promise.all([ readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "balanceOf", - args: [args.address], + args: [address], + ...request, }), readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "nonces", - args: [args.address], + args: [address], + ...request, }), ]).then(([balance, nonce]) => - createERC20PermitDataFromRaw(args.erc20, balance, nonce), + createERC20PermitDataFromRaw(erc20, balance, nonce), ) : { read: () => Promise.all([ readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "balanceOf", - args: [args.address], + args: [address], + ...request, }), readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "nonces", - args: [args.address], + args: [address], + ...request, }), ]), parse: ([balance, nonce]) => - createERC20PermitDataFromRaw(args.erc20, balance, nonce), + createERC20PermitDataFromRaw(erc20, balance, nonce), }) as ReverseMirage< [bigint, bigint], GetERC20PermitDataReturnType, diff --git a/packages/core/src/erc20/publicActions/getERC20PermitNonce.ts b/packages/core/src/erc20/publicActions/getERC20PermitNonce.ts index e99b751..fd7353d 100644 --- a/packages/core/src/erc20/publicActions/getERC20PermitNonce.ts +++ b/packages/core/src/erc20/publicActions/getERC20PermitNonce.ts @@ -22,23 +22,25 @@ export const getERC20PermitNonce = < T extends "select" | undefined, >( client: Client, - args: GetERC20PermitNonceParameters, + { erc20, address, ...request }: GetERC20PermitNonceParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "nonces", - args: [args.address], + args: [address], + ...request, }) : { read: () => readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "nonces", - args: [args.address], + args: [address], + ...request, }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc20/publicActions/getERC20Symbol.ts b/packages/core/src/erc20/publicActions/getERC20Symbol.ts index e014c39..ec0d21a 100644 --- a/packages/core/src/erc20/publicActions/getERC20Symbol.ts +++ b/packages/core/src/erc20/publicActions/getERC20Symbol.ts @@ -16,21 +16,23 @@ export const getERC20Symbol = < T extends "select" | undefined, >( client: Client, - args: GetERC20SymbolParameters, + { erc20, ...request }: GetERC20SymbolParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "symbol", + ...request, }) : { read: () => readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "symbol", + ...request, }), parse: (data: string) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc20/publicActions/getERC20TotalSupply.ts b/packages/core/src/erc20/publicActions/getERC20TotalSupply.ts index 0fc5bbe..f2b9d2d 100644 --- a/packages/core/src/erc20/publicActions/getERC20TotalSupply.ts +++ b/packages/core/src/erc20/publicActions/getERC20TotalSupply.ts @@ -19,21 +19,23 @@ export const getERC20TotalSupply = < T extends "select" | undefined, >( client: Client, - args: GetERC20TotalSupplyParameters, + { erc20, ...request }: GetERC20TotalSupplyParameters, type?: T, ): ReverseMirage, T> => (type === undefined ? readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "totalSupply", - }).then((data) => createAmountFromRaw(args.erc20, data)) + ...request, + }).then((data) => createAmountFromRaw(erc20, data)) : { read: () => readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "totalSupply", + ...request, }), - parse: (data) => createAmountFromRaw(args.erc20, data), + parse: (data) => createAmountFromRaw(erc20, data), }) as ReverseMirage, T>; diff --git a/packages/core/src/erc20/publicActions/getIsERC20Permit.ts b/packages/core/src/erc20/publicActions/getIsERC20Permit.ts index 1fcce79..8f597cf 100644 --- a/packages/core/src/erc20/publicActions/getIsERC20Permit.ts +++ b/packages/core/src/erc20/publicActions/getIsERC20Permit.ts @@ -34,7 +34,7 @@ export const getIsERC20Permit = < T extends "select" | undefined, >( client: Client, - args: GetIsERC20PermitParameters, + { erc20, ...request }: GetIsERC20PermitParameters, type?: T, ): ReverseMirage< [[string, string, number], Hex] | [[string, string, number]], @@ -43,40 +43,46 @@ export const getIsERC20Permit = < > => (type === undefined ? Promise.all([ - getERC20Permit(client, args), - getERC20DomainSeparator(client, args), + getERC20Permit(client, { erc20, ...request }), + getERC20DomainSeparator(client, { erc20, ...request }), ]) .then(([erc20]) => erc20) - .catch(() => getERC20(client, args)) + .catch(() => getERC20(client, { erc20, ...request })) : { read: async () => { try { return await Promise.all([ - getERC20Permit(client, args, "select").read(), - getERC20DomainSeparator(client, args, "select").read(), + getERC20Permit(client, { erc20, ...request }, "select").read(), + getERC20DomainSeparator( + client, + { erc20, ...request }, + "select", + ).read(), ]); } catch { - return await Promise.all([getERC20(client, args, "select").read()]); + return await Promise.all([ + getERC20(client, { erc20, ...request }, "select").read(), + ]); } }, parse: (data) => data.length === 1 ? createERC20( - args.erc20.address, + erc20.address, data[0][0], data[0][1], data[0][2], - args.erc20.chainID, - args.erc20.blockCreated, + erc20.chainID, + erc20.blockCreated, ) : createERC20Permit( - args.erc20.address, + erc20.address, data[0][0], data[0][1], data[0][2], - args.erc20.version ?? "1", - args.erc20.chainID, - args.erc20.blockCreated, + erc20.version ?? "1", + erc20.chainID, + erc20.blockCreated, ), }) as ReverseMirage< [[string, string, number], Hex] | [[string, string, number]], diff --git a/packages/core/src/erc20/walletActions/signERC20Permit.ts b/packages/core/src/erc20/walletActions/signERC20Permit.ts index 2ee2fa7..24dc037 100644 --- a/packages/core/src/erc20/walletActions/signERC20Permit.ts +++ b/packages/core/src/erc20/walletActions/signERC20Permit.ts @@ -31,6 +31,7 @@ export const signERC20Permit = < spender, deadline, account = client.account, + ...request }: SignERC20PermitParameters, ) => { const domain = { @@ -56,5 +57,6 @@ export const signERC20Permit = < nonce: permitData.nonce, }, account: account!, + ...request, }); }; diff --git a/packages/core/src/erc721/publicActions/getERC721.ts b/packages/core/src/erc721/publicActions/getERC721.ts index 0e001f4..7c4d27b 100644 --- a/packages/core/src/erc721/publicActions/getERC721.ts +++ b/packages/core/src/erc721/publicActions/getERC721.ts @@ -21,34 +21,34 @@ export const getERC721 = < T extends "select" | undefined, >( client: Client, - args: GetERC721Parameters, + { erc721, ...request }: GetERC721Parameters, type?: T, ): ReverseMirage<[string, string], GetERC721ReturnType, T> => (type === undefined ? Promise.all([ - getERC721Name(client, args), - getERC721Symbol(client, args), + getERC721Name(client, { erc721, ...request }), + getERC721Symbol(client, { erc721, ...request }), ]).then(([name, symbol]) => createERC721( - args.erc721.address, + erc721.address, name, symbol, - args.erc721.chainID, - args.blockNumber, + erc721.chainID, + erc721.blockCreated, ), ) : { read: () => Promise.all([ - getERC721Name(client, args, "select").read(), - getERC721Symbol(client, args, "select").read(), + getERC721Name(client, { erc721, ...request }, "select").read(), + getERC721Symbol(client, { erc721, ...request }, "select").read(), ]), parse: ([name, symbol]) => createERC721( - args.erc721.address, + erc721.address, name, symbol, - args.erc721.chainID, - args.blockNumber, + erc721.chainID, + erc721.blockCreated, ), }) as ReverseMirage<[string, string], GetERC721ReturnType, T>; diff --git a/packages/core/src/erc721/publicActions/getERC721Approved.ts b/packages/core/src/erc721/publicActions/getERC721Approved.ts index 3407d61..8ef832e 100644 --- a/packages/core/src/erc721/publicActions/getERC721Approved.ts +++ b/packages/core/src/erc721/publicActions/getERC721Approved.ts @@ -22,23 +22,25 @@ export const getERC721Approved = < T extends "select" | undefined, >( client: Client, - args: GetERC721ApprovedParameters, + { erc721, id, ...request }: GetERC721ApprovedParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "getApproved", - args: [args.id], + args: [id], + ...request, }) : { read: () => readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "getApproved", - args: [args.id], + args: [id], + ...request, }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc721/publicActions/getERC721BalanceOf.ts b/packages/core/src/erc721/publicActions/getERC721BalanceOf.ts index 2f5d90c..00e05c2 100644 --- a/packages/core/src/erc721/publicActions/getERC721BalanceOf.ts +++ b/packages/core/src/erc721/publicActions/getERC721BalanceOf.ts @@ -22,23 +22,25 @@ export const getERC721BalanceOf = < T extends "select" | undefined, >( client: Client, - args: GetERC721BalanceOfParameters, + { erc721, address, ...request }: GetERC721BalanceOfParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "balanceOf", - args: [args.address], + args: [address], + ...request, }) : { read: () => readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "balanceOf", - args: [args.address], + args: [address], + ...request, }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc721/publicActions/getERC721Data.ts b/packages/core/src/erc721/publicActions/getERC721Data.ts index c1bcb1a..455d8c7 100644 --- a/packages/core/src/erc721/publicActions/getERC721Data.ts +++ b/packages/core/src/erc721/publicActions/getERC721Data.ts @@ -25,20 +25,27 @@ export const getERC721Data = < T extends "select" | undefined, >( client: Client, - args: GetERC721DataParameters, + { erc721, address, ...request }: GetERC721DataParameters, type?: T, ): ReverseMirage, T> => (type === undefined - ? getERC721BalanceOf(client, args).then((data) => { - if (data > Number.MAX_SAFE_INTEGER) - throw Error("balance exceeds maximum representable number"); - return createERC721Data(args.erc721, Number(data)); - }) + ? getERC721BalanceOf(client, { erc721, address, ...request }).then( + (data) => { + if (data > Number.MAX_SAFE_INTEGER) + throw Error("balance exceeds maximum representable number"); + return createERC721Data(erc721, Number(data)); + }, + ) : { - read: () => getERC721BalanceOf(client, args, "select").read(), + read: () => + getERC721BalanceOf( + client, + { erc721, address, ...request }, + "select", + ).read(), parse: (data) => { if (data > Number.MAX_SAFE_INTEGER) throw Error("balance exceeds maximum representable number"); - return createERC721Data(args.erc721, Number(data)); + return createERC721Data(erc721, Number(data)); }, }) as ReverseMirage, T>; diff --git a/packages/core/src/erc721/publicActions/getERC721IsApprovedForAll.ts b/packages/core/src/erc721/publicActions/getERC721IsApprovedForAll.ts index 8f81ce0..420df7a 100644 --- a/packages/core/src/erc721/publicActions/getERC721IsApprovedForAll.ts +++ b/packages/core/src/erc721/publicActions/getERC721IsApprovedForAll.ts @@ -22,23 +22,25 @@ export const getERC721IsApprovedForAll = < T extends "select" | undefined, >( client: Client, - args: GetERC721IsApprovedForAllParameters, + { erc721, owner, spender, ...request }: GetERC721IsApprovedForAllParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "isApprovedForAll", - args: [args.owner, args.spender], + args: [owner, spender], + ...request, }) : { read: () => readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "isApprovedForAll", - args: [args.owner, args.spender], + args: [owner, spender], + ...request, }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc721/publicActions/getERC721Name.ts b/packages/core/src/erc721/publicActions/getERC721Name.ts index 4d26aad..6494551 100644 --- a/packages/core/src/erc721/publicActions/getERC721Name.ts +++ b/packages/core/src/erc721/publicActions/getERC721Name.ts @@ -16,21 +16,23 @@ export const getERC721Name = < T extends "select" | undefined, >( client: Client, - args: GetERC721NameParameters, + { erc721, ...request }: GetERC721NameParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "name", + ...request, }) : { read: () => readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "name", + ...request, }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc721/publicActions/getERC721OwnerOf.ts b/packages/core/src/erc721/publicActions/getERC721OwnerOf.ts index 42eb31b..5e70660 100644 --- a/packages/core/src/erc721/publicActions/getERC721OwnerOf.ts +++ b/packages/core/src/erc721/publicActions/getERC721OwnerOf.ts @@ -22,23 +22,25 @@ export const getERC721OwnerOf = < T extends "select" | undefined, >( client: Client, - args: GetERC721OwnerOfParameters, + { erc721, id, ...request }: GetERC721OwnerOfParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "ownerOf", - args: [args.id], + args: [id], + ...request, }) : { read: () => readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "ownerOf", - args: [args.id], + args: [id], + ...request, }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc721/publicActions/getERC721SupportsInterface.ts b/packages/core/src/erc721/publicActions/getERC721SupportsInterface.ts index 6ff1892..3ba0392 100644 --- a/packages/core/src/erc721/publicActions/getERC721SupportsInterface.ts +++ b/packages/core/src/erc721/publicActions/getERC721SupportsInterface.ts @@ -22,23 +22,25 @@ export const getERC721SupportsInterface = < T extends "select" | undefined, >( client: Client, - args: GetERC721SupportsInterfaceParameters, + { erc721, interfaceID, ...request }: GetERC721SupportsInterfaceParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "supportsInterface", - args: [args.interfaceID], + args: [interfaceID], + ...request, }) : { read: () => readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "supportsInterface", - args: [args.interfaceID], + args: [interfaceID], + ...request, }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc721/publicActions/getERC721Symbol.ts b/packages/core/src/erc721/publicActions/getERC721Symbol.ts index 81bbea2..41b4aff 100644 --- a/packages/core/src/erc721/publicActions/getERC721Symbol.ts +++ b/packages/core/src/erc721/publicActions/getERC721Symbol.ts @@ -16,21 +16,23 @@ export const getERC721Symbol = < T extends "select" | undefined, >( client: Client, - args: GetERC721SymbolParameters, + { erc721, ...request }: GetERC721SymbolParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "symbol", + ...request, }) : { read: () => readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "symbol", + ...request, }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc721/publicActions/getERC721TokenURI.ts b/packages/core/src/erc721/publicActions/getERC721TokenURI.ts index 3f2ad96..50f3b83 100644 --- a/packages/core/src/erc721/publicActions/getERC721TokenURI.ts +++ b/packages/core/src/erc721/publicActions/getERC721TokenURI.ts @@ -16,23 +16,25 @@ export const getERC721TokenURI = < T extends "select" | undefined, >( client: Client, - args: GetERC721TokenURIParameters, + { erc721, id, ...request }: GetERC721TokenURIParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "tokenURI", - args: [args.id], + args: [id], + ...request, }) : { read: () => readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "tokenURI", - args: [args.id], + args: [id], + ...request, }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/native/publicActions/getNativeBalance.ts b/packages/core/src/native/publicActions/getNativeBalance.ts index f316404..acda95c 100644 --- a/packages/core/src/native/publicActions/getNativeBalance.ts +++ b/packages/core/src/native/publicActions/getNativeBalance.ts @@ -18,16 +18,20 @@ export const getNativeBalance = < T extends "select" | undefined, >( client: Client, - args: GetNativeBalanceParameters, + { + address, + nativeCurrency, + ...request + }: GetNativeBalanceParameters, type?: T, ): ReverseMirage, T> => (type === undefined - ? getBalance(client, { address: args.address }).then((data) => - createAmountFromRaw(args.nativeCurrency, data), + ? getBalance(client, { address: address, ...request }).then((data) => + createAmountFromRaw(nativeCurrency, data), ) : { - read: () => getBalance(client, { address: args.address }), - parse: (data: bigint) => createAmountFromRaw(args.nativeCurrency, data), + read: () => getBalance(client, { address: address, ...request }), + parse: (data: bigint) => createAmountFromRaw(nativeCurrency, data), }) as ReverseMirage< bigint, GetNativeBalanceReturnType, From a7b45b711ac9f4905f1860309a61dffd613df700 Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Fri, 22 Sep 2023 14:03:42 -0400 Subject: [PATCH 06/42] Fix: bug with getERC20 return type --- packages/core/src/erc20/publicActions/getERC20.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core/src/erc20/publicActions/getERC20.ts b/packages/core/src/erc20/publicActions/getERC20.ts index 1d071ac..3cd826e 100644 --- a/packages/core/src/erc20/publicActions/getERC20.ts +++ b/packages/core/src/erc20/publicActions/getERC20.ts @@ -4,7 +4,7 @@ import type { ReverseMirage } from "../../types/rm.js"; import type { BaseERC20, ERC20 } from "../types.js"; import { createERC20 } from "../utils.js"; import { getERC20Decimals } from "./getERC20Decimals.js"; -import { type GetERC20NameReturnType, getERC20Name } from "./getERC20Name.js"; +import { getERC20Name } from "./getERC20Name.js"; import { getERC20Symbol } from "./getERC20Symbol.js"; export type GetERC20Parameters = Omit< @@ -24,7 +24,7 @@ export const getERC20 = < client: Client, { erc20, ...request }: GetERC20Parameters, type?: T, -): ReverseMirage<[string, string, number], GetERC20NameReturnType, T> => +): ReverseMirage<[string, string, number], GetERC20ReturnType, T> => (type === undefined ? Promise.all([ getERC20Name(client, { erc20, ...request }), @@ -56,4 +56,4 @@ export const getERC20 = < erc20.chainID, erc20.blockCreated, ), - }) as ReverseMirage<[string, string, number], GetERC20NameReturnType, T>; + }) as ReverseMirage<[string, string, number], GetERC20ReturnType, T>; From 0f4896bcee3b05730422e9885218ec65ba7149ee Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Fri, 22 Sep 2023 14:16:53 -0400 Subject: [PATCH 07/42] erc721 and 1155 base assets --- docs/.vitepress/config.mts | 8 -------- packages/core/src/erc1155/index.ts | 1 + packages/core/src/erc1155/publicActions/getERC1155.ts | 8 ++++---- .../core/src/erc1155/publicActions/getERC1155BalanceOf.ts | 8 ++++---- .../erc1155/publicActions/getERC1155IsApprovedForAll.ts | 4 ++-- packages/core/src/erc1155/publicActions/getERC1155URI.ts | 4 ++-- packages/core/src/erc1155/types.ts | 6 ++++-- packages/core/src/erc1155/utils.ts | 4 ++-- .../walletActions/simulateERC1155SetApprovalForAll.ts | 4 ++-- .../src/erc1155/walletActions/simulateERC1155Transfer.ts | 4 ++-- .../erc1155/walletActions/simulateERC1155TransferBatch.ts | 4 ++-- packages/core/src/erc721/index.ts | 1 + packages/core/src/erc721/publicActions/getERC721.ts | 8 ++++---- .../core/src/erc721/publicActions/getERC721Approved.ts | 4 ++-- .../core/src/erc721/publicActions/getERC721BalanceOf.ts | 4 ++-- packages/core/src/erc721/publicActions/getERC721Data.ts | 8 ++++---- .../src/erc721/publicActions/getERC721IsApprovedForAll.ts | 4 ++-- packages/core/src/erc721/publicActions/getERC721Name.ts | 4 ++-- .../core/src/erc721/publicActions/getERC721OwnerOf.ts | 4 ++-- .../erc721/publicActions/getERC721SupportsInterface.ts | 4 ++-- packages/core/src/erc721/publicActions/getERC721Symbol.ts | 4 ++-- .../core/src/erc721/publicActions/getERC721TokenURI.ts | 4 ++-- packages/core/src/erc721/types.ts | 6 ++++-- packages/core/src/erc721/utils.ts | 4 ++-- .../src/erc721/walletActions/simulateERC721Approve.ts | 4 ++-- .../walletActions/simulateERC721SetApprovalForAll.ts | 4 ++-- .../src/erc721/walletActions/simulateERC721Transfer.ts | 4 ++-- packages/core/src/index.ts | 2 ++ 28 files changed, 64 insertions(+), 64 deletions(-) diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index 4355d96..a0e7c12 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -196,10 +196,6 @@ export default defineConfig({ text: "createERC721Data", link: "", }, - { - text: "createERC721DataID", - link: "", - }, ], }, { @@ -245,10 +241,6 @@ export default defineConfig({ text: "getERC721Data", link: "", }, - { - text: "getERC721DataID", - link: "", - }, ], }, { diff --git a/packages/core/src/erc1155/index.ts b/packages/core/src/erc1155/index.ts index 899fbf7..8efebb8 100644 --- a/packages/core/src/erc1155/index.ts +++ b/packages/core/src/erc1155/index.ts @@ -1,4 +1,5 @@ export type { + BaseERC1155, ERC1155, ERC1155Data, } from "./types.js"; diff --git a/packages/core/src/erc1155/publicActions/getERC1155.ts b/packages/core/src/erc1155/publicActions/getERC1155.ts index 1dfdcbf..1044488 100644 --- a/packages/core/src/erc1155/publicActions/getERC1155.ts +++ b/packages/core/src/erc1155/publicActions/getERC1155.ts @@ -2,18 +2,18 @@ import type { Chain, Client, ReadContractParameters, Transport } from "viem"; import { readContract } from "viem/contract"; import { solmateErc1155ABI as solmateERC1155ABI } from "../../generated.js"; import type { ReverseMirage } from "../../types/rm.js"; -import type { ERC1155 } from "../types.js"; +import type { BaseERC1155 } from "../types.js"; import { createERC1155 } from "../utils.js"; export type GetERC1155Parameters = Omit< ReadContractParameters, "address" | "abi" | "functionName" | "args" > & { - erc1155: Pick & - Partial>; + erc1155: Pick & + Partial>; }; -export type GetERC1155ReturnType = ERC1155; +export type GetERC1155ReturnType = BaseERC1155; export const getERC1155 = < TChain extends Chain | undefined, diff --git a/packages/core/src/erc1155/publicActions/getERC1155BalanceOf.ts b/packages/core/src/erc1155/publicActions/getERC1155BalanceOf.ts index aef8698..31a9afa 100644 --- a/packages/core/src/erc1155/publicActions/getERC1155BalanceOf.ts +++ b/packages/core/src/erc1155/publicActions/getERC1155BalanceOf.ts @@ -8,20 +8,20 @@ import type { import { readContract } from "viem/contract"; import { solmateErc1155ABI as solmateERC1155ABI } from "../../generated.js"; import type { ReverseMirage } from "../../types/rm.js"; -import type { ERC1155, ERC1155Data } from "../types.js"; +import type { BaseERC1155, ERC1155Data } from "../types.js"; import { createERC1155Data } from "../utils.js"; -export type GetERC1155BalanceOfParameters = Omit< +export type GetERC1155BalanceOfParameters = Omit< ReadContractParameters, "address" | "abi" | "functionName" | "args" > & { erc1155: TERC1155; address: Address }; -export type GetERC1155BalanceOfReturnType = +export type GetERC1155BalanceOfReturnType = ERC1155Data; export const getERC1155BalanceOf = < TChain extends Chain | undefined, - TERC1155 extends ERC1155, + TERC1155 extends BaseERC1155, T extends "select" | undefined, >( client: Client, diff --git a/packages/core/src/erc1155/publicActions/getERC1155IsApprovedForAll.ts b/packages/core/src/erc1155/publicActions/getERC1155IsApprovedForAll.ts index 5bed0d9..9f06db2 100644 --- a/packages/core/src/erc1155/publicActions/getERC1155IsApprovedForAll.ts +++ b/packages/core/src/erc1155/publicActions/getERC1155IsApprovedForAll.ts @@ -8,12 +8,12 @@ import type { import { readContract } from "viem/contract"; import { solmateErc1155ABI as solmateERC1155ABI } from "../../generated.js"; import type { ReverseMirage } from "../../types/rm.js"; -import type { ERC1155 } from "../types.js"; +import type { BaseERC1155 } from "../types.js"; export type GetERC1155IsApprovedForAllParameters = Omit< ReadContractParameters, "address" | "abi" | "functionName" | "args" -> & { erc1155: Pick; owner: Address; spender: Address }; +> & { erc1155: Pick; owner: Address; spender: Address }; export type GetERC1155IsApprovedForAllReturnType = boolean; diff --git a/packages/core/src/erc1155/publicActions/getERC1155URI.ts b/packages/core/src/erc1155/publicActions/getERC1155URI.ts index 8a36ae7..e4bab89 100644 --- a/packages/core/src/erc1155/publicActions/getERC1155URI.ts +++ b/packages/core/src/erc1155/publicActions/getERC1155URI.ts @@ -2,12 +2,12 @@ import type { Chain, Client, ReadContractParameters, Transport } from "viem"; import { readContract } from "viem/contract"; import { solmateErc1155ABI as solmateERC1155ABI } from "../../generated.js"; import type { ReverseMirage } from "../../types/rm.js"; -import type { ERC1155 } from "../types.js"; +import type { BaseERC1155 } from "../types.js"; export type GetERC1155URIParameters = Omit< ReadContractParameters, "address" | "abi" | "functionName" | "args" -> & { erc1155: Pick }; +> & { erc1155: Pick }; export type GetERC1155URIReturnType = string; diff --git a/packages/core/src/erc1155/types.ts b/packages/core/src/erc1155/types.ts index 4480e08..f587206 100644 --- a/packages/core/src/erc1155/types.ts +++ b/packages/core/src/erc1155/types.ts @@ -2,14 +2,16 @@ import type { Address } from "viem"; import type { Amount } from "../amount/types.js"; import type { Token } from "../types/token.js"; -export type ERC1155 = Token<"erc1155"> & { +export type BaseERC1155 = Token & { address: Address; id: bigint; uri: string; blockCreated: bigint; }; -export type ERC1155Data = Amount< +export type ERC1155 = BaseERC1155<"erc1155">; + +export type ERC1155Data = Amount< TERC1155, `${TERC1155["type"]}Data` >; diff --git a/packages/core/src/erc1155/utils.ts b/packages/core/src/erc1155/utils.ts index 883843d..fc43aee 100644 --- a/packages/core/src/erc1155/utils.ts +++ b/packages/core/src/erc1155/utils.ts @@ -1,5 +1,5 @@ import { type Address, getAddress } from "viem"; -import type { ERC1155, ERC1155Data } from "./types.js"; +import type { BaseERC1155, ERC1155, ERC1155Data } from "./types.js"; /** * Creates an {@link ERC1155} @@ -22,7 +22,7 @@ export const createERC1155 = ( /** * Creates an {@link ERC1155Data} */ -export const createERC1155Data = ( +export const createERC1155Data = ( erc1155: TERC1155, amount: bigint, ): ERC1155Data => ({ diff --git a/packages/core/src/erc1155/walletActions/simulateERC1155SetApprovalForAll.ts b/packages/core/src/erc1155/walletActions/simulateERC1155SetApprovalForAll.ts index e61f602..433f5c4 100644 --- a/packages/core/src/erc1155/walletActions/simulateERC1155SetApprovalForAll.ts +++ b/packages/core/src/erc1155/walletActions/simulateERC1155SetApprovalForAll.ts @@ -8,10 +8,10 @@ import type { } from "viem"; import { simulateContract } from "viem/contract"; import { solmateErc1155ABI as solmateERC1155 } from "../../generated.js"; -import type { ERC1155 } from "../types.js"; +import type { BaseERC1155 } from "../types.js"; export type ERC1155SetApprovalForAllParameters = { - erc1155: Pick; + erc1155: Pick; spender: Address; approved: boolean; }; diff --git a/packages/core/src/erc1155/walletActions/simulateERC1155Transfer.ts b/packages/core/src/erc1155/walletActions/simulateERC1155Transfer.ts index 49824d2..dfa6262 100644 --- a/packages/core/src/erc1155/walletActions/simulateERC1155Transfer.ts +++ b/packages/core/src/erc1155/walletActions/simulateERC1155Transfer.ts @@ -9,10 +9,10 @@ import type { } from "viem"; import { simulateContract } from "viem/contract"; import { solmateErc1155ABI as solmateERC1155 } from "../../generated.js"; -import type { ERC1155, ERC1155Data } from "../types.js"; +import type { BaseERC1155, ERC1155Data } from "../types.js"; export type ERC1155TransferParameters = { - erc1155Data: ERC1155Data; + erc1155Data: ERC1155Data; from?: Address; to: Address; data?: Hex; diff --git a/packages/core/src/erc1155/walletActions/simulateERC1155TransferBatch.ts b/packages/core/src/erc1155/walletActions/simulateERC1155TransferBatch.ts index ce442a8..557f514 100644 --- a/packages/core/src/erc1155/walletActions/simulateERC1155TransferBatch.ts +++ b/packages/core/src/erc1155/walletActions/simulateERC1155TransferBatch.ts @@ -10,10 +10,10 @@ import { } from "viem"; import { simulateContract } from "viem/contract"; import { solmateErc1155ABI as solmateERC1155 } from "../../generated.js"; -import type { ERC1155, ERC1155Data } from "../types.js"; +import type { BaseERC1155, ERC1155Data } from "../types.js"; export type ERC1155TransferBatchParameters = { - erc1155Data: ERC1155Data[]; + erc1155Data: ERC1155Data[]; from?: Address; to: Address; data?: Hex; diff --git a/packages/core/src/erc721/index.ts b/packages/core/src/erc721/index.ts index 66cd6cd..8211afb 100644 --- a/packages/core/src/erc721/index.ts +++ b/packages/core/src/erc721/index.ts @@ -1,4 +1,5 @@ export type { + BaseERC721, ERC721, ERC721Data, } from "./types.js"; diff --git a/packages/core/src/erc721/publicActions/getERC721.ts b/packages/core/src/erc721/publicActions/getERC721.ts index 7c4d27b..abd77dc 100644 --- a/packages/core/src/erc721/publicActions/getERC721.ts +++ b/packages/core/src/erc721/publicActions/getERC721.ts @@ -1,7 +1,7 @@ import type { Chain, Client, ReadContractParameters, Transport } from "viem"; import { solmateErc721ABI as solmateERC721ABI } from "../../generated.js"; import type { ReverseMirage } from "../../types/rm.js"; -import type { ERC721 } from "../types.js"; +import type { BaseERC721 } from "../types.js"; import { createERC721 } from "../utils.js"; import { getERC721Name } from "./getERC721Name.js"; import { getERC721Symbol } from "./getERC721Symbol.js"; @@ -10,11 +10,11 @@ export type GetERC721Parameters = Omit< ReadContractParameters, "address" | "abi" | "functionName" | "args" > & { - erc721: Pick & - Partial>; + erc721: Pick & + Partial>; }; -export type GetERC721ReturnType = ERC721; +export type GetERC721ReturnType = BaseERC721; export const getERC721 = < TChain extends Chain | undefined, diff --git a/packages/core/src/erc721/publicActions/getERC721Approved.ts b/packages/core/src/erc721/publicActions/getERC721Approved.ts index 8ef832e..0eac762 100644 --- a/packages/core/src/erc721/publicActions/getERC721Approved.ts +++ b/packages/core/src/erc721/publicActions/getERC721Approved.ts @@ -8,12 +8,12 @@ import type { import { readContract } from "viem/contract"; import { solmateErc721ABI as solmateERC721ABI } from "../../generated.js"; import type { ReverseMirage } from "../../types/rm.js"; -import type { ERC721 } from "../types.js"; +import type { BaseERC721 } from "../types.js"; export type GetERC721ApprovedParameters = Omit< ReadContractParameters, "address" | "abi" | "functionName" | "args" -> & { erc721: Pick; id: bigint }; +> & { erc721: Pick; id: bigint }; export type GetERC721ApprovedReturnType = Address; diff --git a/packages/core/src/erc721/publicActions/getERC721BalanceOf.ts b/packages/core/src/erc721/publicActions/getERC721BalanceOf.ts index 00e05c2..69260b0 100644 --- a/packages/core/src/erc721/publicActions/getERC721BalanceOf.ts +++ b/packages/core/src/erc721/publicActions/getERC721BalanceOf.ts @@ -8,12 +8,12 @@ import type { import { readContract } from "viem/contract"; import { solmateErc721ABI as solmateERC721ABI } from "../../generated.js"; import type { ReverseMirage } from "../../types/rm.js"; -import type { ERC721 } from "../types.js"; +import type { BaseERC721 } from "../types.js"; export type GetERC721BalanceOfParameters = Omit< ReadContractParameters, "address" | "abi" | "functionName" | "args" -> & { erc721: Pick; address: Address }; +> & { erc721: Pick; address: Address }; export type GetERC721BalanceOfReturnType = bigint; diff --git a/packages/core/src/erc721/publicActions/getERC721Data.ts b/packages/core/src/erc721/publicActions/getERC721Data.ts index 455d8c7..9505ea7 100644 --- a/packages/core/src/erc721/publicActions/getERC721Data.ts +++ b/packages/core/src/erc721/publicActions/getERC721Data.ts @@ -7,21 +7,21 @@ import type { } from "viem"; import { solmateErc721ABI as solmateERC721ABI } from "../../generated.js"; import type { ReverseMirage } from "../../types/rm.js"; -import type { ERC721, ERC721Data } from "../types.js"; +import type { BaseERC721, ERC721Data } from "../types.js"; import { createERC721Data } from "../utils.js"; import { getERC721BalanceOf } from "./getERC721BalanceOf.js"; -export type GetERC721DataParameters = Omit< +export type GetERC721DataParameters = Omit< ReadContractParameters, "address" | "abi" | "functionName" | "args" > & { erc721: TERC721; address: Address }; -export type GetERC721DataReturnType = +export type GetERC721DataReturnType = ERC721Data; export const getERC721Data = < TChain extends Chain | undefined, - TERC721 extends ERC721, + TERC721 extends BaseERC721, T extends "select" | undefined, >( client: Client, diff --git a/packages/core/src/erc721/publicActions/getERC721IsApprovedForAll.ts b/packages/core/src/erc721/publicActions/getERC721IsApprovedForAll.ts index 420df7a..41e66c5 100644 --- a/packages/core/src/erc721/publicActions/getERC721IsApprovedForAll.ts +++ b/packages/core/src/erc721/publicActions/getERC721IsApprovedForAll.ts @@ -8,12 +8,12 @@ import type { import { readContract } from "viem/contract"; import { solmateErc721ABI as solmateERC721ABI } from "../../generated.js"; import type { ReverseMirage } from "../../types/rm.js"; -import type { ERC721 } from "../types.js"; +import type { BaseERC721 } from "../types.js"; export type GetERC721IsApprovedForAllParameters = Omit< ReadContractParameters, "address" | "abi" | "functionName" | "args" -> & { erc721: Pick; owner: Address; spender: Address }; +> & { erc721: Pick; owner: Address; spender: Address }; export type GetERC721IsApprovedForAllReturnType = boolean; diff --git a/packages/core/src/erc721/publicActions/getERC721Name.ts b/packages/core/src/erc721/publicActions/getERC721Name.ts index 6494551..c66a84b 100644 --- a/packages/core/src/erc721/publicActions/getERC721Name.ts +++ b/packages/core/src/erc721/publicActions/getERC721Name.ts @@ -2,12 +2,12 @@ import type { 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 } from "../types.js"; +import type { BaseERC721 } from "../types.js"; export type GetERC721NameParameters = Omit< ReadContractParameters, "address" | "abi" | "functionName" | "args" -> & { erc721: Pick }; +> & { erc721: Pick }; export type GetERC721NameReturnType = string; diff --git a/packages/core/src/erc721/publicActions/getERC721OwnerOf.ts b/packages/core/src/erc721/publicActions/getERC721OwnerOf.ts index 5e70660..87aa835 100644 --- a/packages/core/src/erc721/publicActions/getERC721OwnerOf.ts +++ b/packages/core/src/erc721/publicActions/getERC721OwnerOf.ts @@ -8,12 +8,12 @@ import type { import { readContract } from "viem/contract"; import { solmateErc721ABI as solmateERC721ABI } from "../../generated.js"; import type { ReverseMirage } from "../../types/rm.js"; -import type { ERC721 } from "../types.js"; +import type { BaseERC721 } from "../types.js"; export type GetERC721OwnerOfParameters = Omit< ReadContractParameters, "address" | "abi" | "functionName" | "args" -> & { erc721: Pick; id: bigint }; +> & { erc721: Pick; id: bigint }; export type GetERC721OwnerOfReturnType = Address; diff --git a/packages/core/src/erc721/publicActions/getERC721SupportsInterface.ts b/packages/core/src/erc721/publicActions/getERC721SupportsInterface.ts index 3ba0392..1f71914 100644 --- a/packages/core/src/erc721/publicActions/getERC721SupportsInterface.ts +++ b/packages/core/src/erc721/publicActions/getERC721SupportsInterface.ts @@ -8,12 +8,12 @@ import type { import { readContract } from "viem/contract"; import { solmateErc721ABI as solmateERC721ABI } from "../../generated.js"; import type { ReverseMirage } from "../../types/rm.js"; -import type { ERC721 } from "../types.js"; +import type { BaseERC721 } from "../types.js"; export type GetERC721SupportsInterfaceParameters = Omit< ReadContractParameters, "address" | "abi" | "functionName" | "args" -> & { erc721: Pick; interfaceID: Hex }; +> & { erc721: Pick; interfaceID: Hex }; export type GetERC721SupportsInterfaceReturnType = boolean; diff --git a/packages/core/src/erc721/publicActions/getERC721Symbol.ts b/packages/core/src/erc721/publicActions/getERC721Symbol.ts index 41b4aff..48ccd1b 100644 --- a/packages/core/src/erc721/publicActions/getERC721Symbol.ts +++ b/packages/core/src/erc721/publicActions/getERC721Symbol.ts @@ -2,12 +2,12 @@ import type { 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 } from "../types.js"; +import type { BaseERC721 } from "../types.js"; export type GetERC721SymbolParameters = Omit< ReadContractParameters, "address" | "abi" | "functionName" | "args" -> & { erc721: Pick }; +> & { erc721: Pick }; export type GetERC721SymbolReturnType = string; diff --git a/packages/core/src/erc721/publicActions/getERC721TokenURI.ts b/packages/core/src/erc721/publicActions/getERC721TokenURI.ts index 50f3b83..c94cf1c 100644 --- a/packages/core/src/erc721/publicActions/getERC721TokenURI.ts +++ b/packages/core/src/erc721/publicActions/getERC721TokenURI.ts @@ -2,12 +2,12 @@ import type { 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 } from "../types.js"; +import type { BaseERC721 } from "../types.js"; export type GetERC721TokenURIParameters = Omit< ReadContractParameters, "address" | "abi" | "functionName" | "args" -> & { erc721: Pick; id: bigint }; +> & { erc721: Pick; id: bigint }; export type GetERC721TokenURIReturnType = string; diff --git a/packages/core/src/erc721/types.ts b/packages/core/src/erc721/types.ts index 099106b..3d48a67 100644 --- a/packages/core/src/erc721/types.ts +++ b/packages/core/src/erc721/types.ts @@ -2,15 +2,17 @@ import type { Address } from "viem"; import type { Token, TokenData } from "../types/token.js"; import type { Tuple } from "../types/tuple.js"; -export type ERC721 = Token<"erc721"> & { +export type BaseERC721 = Token & { address: Address; name: string; symbol: string; blockCreated: bigint; }; +export type ERC721 = BaseERC721<"erc721">; + export type ERC721Data< - TERC721 extends ERC721, + TERC721 extends BaseERC721, TBalance extends number = number, > = TokenData< TERC721, diff --git a/packages/core/src/erc721/utils.ts b/packages/core/src/erc721/utils.ts index f9bb7ff..e6f78bd 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 } from "./types.js"; +import type { BaseERC721, ERC721, ERC721Data } from "./types.js"; /** * Creates an {@link ERC721} @@ -24,7 +24,7 @@ export const createERC721 = ( * Creates an {@link ERC721Data} */ export const createERC721Data = < - TERC721 extends ERC721, + TERC721 extends BaseERC721, TBalance extends number, >( erc721: TERC721, diff --git a/packages/core/src/erc721/walletActions/simulateERC721Approve.ts b/packages/core/src/erc721/walletActions/simulateERC721Approve.ts index e1e9e7a..9fde2ff 100644 --- a/packages/core/src/erc721/walletActions/simulateERC721Approve.ts +++ b/packages/core/src/erc721/walletActions/simulateERC721Approve.ts @@ -8,10 +8,10 @@ import type { } from "viem"; import { simulateContract } from "viem/contract"; import { solmateErc721ABI as solmateERC721 } from "../../generated.js"; -import type { ERC721 } from "../types.js"; +import type { BaseERC721 } from "../types.js"; export type ERC721ApproveParameters = { - erc721: Pick; + erc721: Pick; id: bigint; spender: Address; }; diff --git a/packages/core/src/erc721/walletActions/simulateERC721SetApprovalForAll.ts b/packages/core/src/erc721/walletActions/simulateERC721SetApprovalForAll.ts index d268f5b..065da18 100644 --- a/packages/core/src/erc721/walletActions/simulateERC721SetApprovalForAll.ts +++ b/packages/core/src/erc721/walletActions/simulateERC721SetApprovalForAll.ts @@ -8,10 +8,10 @@ import type { } from "viem"; import { simulateContract } from "viem/contract"; import { solmateErc721ABI as solmateERC721 } from "../../generated.js"; -import type { ERC721 } from "../types.js"; +import type { BaseERC721 } from "../types.js"; export type ERC721SetApprovalForAllParameters = { - erc721: Pick; + erc721: Pick; spender: Address; approved: boolean; }; diff --git a/packages/core/src/erc721/walletActions/simulateERC721Transfer.ts b/packages/core/src/erc721/walletActions/simulateERC721Transfer.ts index f659314..4198ffe 100644 --- a/packages/core/src/erc721/walletActions/simulateERC721Transfer.ts +++ b/packages/core/src/erc721/walletActions/simulateERC721Transfer.ts @@ -9,10 +9,10 @@ import type { } from "viem"; import { simulateContract } from "viem/contract"; import { solmateErc721ABI as solmateERC721 } from "../../generated.js"; -import type { ERC721 } from "../types.js"; +import type { BaseERC721 } from "../types.js"; export type ERC721TransferParameters = { - erc721: Pick; + erc721: Pick; id: bigint; from?: Address; to: Address; diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 95eb46f..ddee3dc 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -64,6 +64,7 @@ export { } from "./erc20/index.js"; export { + type BaseERC721, type ERC721, type ERC721Data, createERC721, @@ -85,6 +86,7 @@ export { } from "./erc721/index.js"; export { + type BaseERC1155, type ERC1155, type ERC1155Data, createERC1155, From 64ac88a4db8666673049bbbccd6f5131fe976291 Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Fri, 22 Sep 2023 14:31:22 -0400 Subject: [PATCH 08/42] docs(changeset): bug fixes --- .changeset/good-jobs-think.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/good-jobs-think.md diff --git a/.changeset/good-jobs-think.md b/.changeset/good-jobs-think.md new file mode 100644 index 0000000..4ba6368 --- /dev/null +++ b/.changeset/good-jobs-think.md @@ -0,0 +1,5 @@ +--- +"reverse-mirage": patch +--- + +bug fixes From d3f56e853483922e47056e7a6802cae38f7f3bf6 Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Fri, 22 Sep 2023 14:33:22 -0400 Subject: [PATCH 09/42] RELEASING: Releasing 1 package(s) Releases: reverse-mirage@1.0.0-next.1 [skip ci] --- packages/core/CHANGELOG.md | 6 ++++++ packages/core/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index 627e6b3..b996c4e 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,11 @@ # reverse-mirage +## 1.0.0-next.1 + +### Patch Changes + +- 64ac88a: bug fixes + ## 1.0.0-next.0 ### Major Changes diff --git a/packages/core/package.json b/packages/core/package.json index 23191af..7a0bf05 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "reverse-mirage", - "version": "1.0.0-next.0", + "version": "1.0.0-next.1", "description": "Application level typescript utilities for Ethereum", "type": "module", "sideEffects": false, From c147f62635adb4c479b4f8b8e1a587d93fe53909 Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Sun, 24 Sep 2023 20:16:56 -0400 Subject: [PATCH 10/42] release new version --- .changeset/pre.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.changeset/pre.json b/.changeset/pre.json index 62889ec..94fa07f 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -5,6 +5,7 @@ "reverse-mirage": "0.1.11" }, "changesets": [ + "good-jobs-think", "long-pillows-sip" ] } From d2dc6f3557c3590a887672905b531cfcfda992dc Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Sun, 24 Sep 2023 23:00:19 -0400 Subject: [PATCH 11/42] wallet action decorator --- examples/next-interface/hooks/useBalance.ts | 12 +- .../core/src/decorator/publicActions.test.ts | 21 ++ packages/core/src/decorator/publicActions.ts | 212 ++++++++++++++++++ .../core/src/decorator/walletActions.test.ts | 51 +++++ packages/core/src/decorator/walletActions.ts | 15 ++ .../src/erc1155/publicActions/getERC1155.ts | 58 ++--- .../publicActions/getERC1155BalanceOf.ts | 31 +-- .../getERC1155IsApprovedForAll.ts | 35 +-- .../erc1155/publicActions/getERC1155URI.ts | 35 +-- .../src/erc20/publicActions/getERC20.test.ts | 12 - .../core/src/erc20/publicActions/getERC20.ts | 55 ++--- .../publicActions/getERC20Allowance.test.ts | 19 -- .../erc20/publicActions/getERC20Allowance.ts | 31 +-- .../publicActions/getERC20BalanceOf.test.ts | 18 -- .../erc20/publicActions/getERC20BalanceOf.ts | 31 +-- .../publicActions/getERC20Decimals.test.ts | 12 - .../erc20/publicActions/getERC20Decimals.ts | 32 +-- .../getERC20DomainSeparator.test.ts | 12 - .../publicActions/getERC20DomainSeparator.ts | 32 +-- .../erc20/publicActions/getERC20Name.test.ts | 12 - .../src/erc20/publicActions/getERC20Name.ts | 32 +-- .../publicActions/getERC20Permit.test.ts | 12 - .../src/erc20/publicActions/getERC20Permit.ts | 62 ++--- .../publicActions/getERC20PermitData.test.ts | 18 -- .../erc20/publicActions/getERC20PermitData.ts | 67 ++---- .../publicActions/getERC20PermitNonce.test.ts | 13 -- .../publicActions/getERC20PermitNonce.ts | 35 +-- .../publicActions/getERC20Symbol.test.ts | 12 - .../src/erc20/publicActions/getERC20Symbol.ts | 32 +-- .../publicActions/getERC20TotalSupply.test.ts | 17 -- .../publicActions/getERC20TotalSupply.ts | 28 +-- .../erc20/publicActions/getIsERC20Permit.ts | 76 +------ .../erc721/publicActions/getERC721.test.ts | 12 - .../src/erc721/publicActions/getERC721.ts | 49 ++-- .../publicActions/getERC721Approved.test.ts | 13 -- .../erc721/publicActions/getERC721Approved.ts | 35 +-- .../publicActions/getERC721BalanceOf.test.ts | 13 -- .../publicActions/getERC721BalanceOf.ts | 35 +-- .../publicActions/getERC721Data.test.ts | 13 -- .../src/erc721/publicActions/getERC721Data.ts | 31 +-- .../getERC721IsApprovedForAll.test.ts | 14 -- .../getERC721IsApprovedForAll.ts | 35 +-- .../publicActions/getERC721Name.test.ts | 12 - .../src/erc721/publicActions/getERC721Name.ts | 32 +-- .../publicActions/getERC721OwnerOf.test.ts | 13 -- .../erc721/publicActions/getERC721OwnerOf.ts | 35 +-- .../getERC721SupportsInterface.test.ts | 13 -- .../getERC721SupportsInterface.ts | 35 +-- .../publicActions/getERC721Symbol.test.ts | 12 - .../erc721/publicActions/getERC721Symbol.ts | 32 +-- .../publicActions/getERC721TokenURI.test.ts | 13 -- .../erc721/publicActions/getERC721TokenURI.ts | 35 +-- packages/core/src/index.ts | 5 +- .../native/publicActions/getNativeBalance.ts | 20 +- packages/core/src/types/index.ts | 1 - packages/core/src/types/rm.ts | 10 - packages/core/src/utils/getQueryKey.ts | 16 +- 57 files changed, 572 insertions(+), 1102 deletions(-) create mode 100644 packages/core/src/decorator/publicActions.test.ts create mode 100644 packages/core/src/decorator/publicActions.ts create mode 100644 packages/core/src/decorator/walletActions.test.ts create mode 100644 packages/core/src/decorator/walletActions.ts delete mode 100644 packages/core/src/types/rm.ts diff --git a/examples/next-interface/hooks/useBalance.ts b/examples/next-interface/hooks/useBalance.ts index 7134236..e97a03a 100644 --- a/examples/next-interface/hooks/useBalance.ts +++ b/examples/next-interface/hooks/useBalance.ts @@ -20,17 +20,7 @@ export const useBalance = ( ), enabled: [erc20, address].some((a) => a === undefined) ? false : true, queryFn: () => - getERC20BalanceOf( - publicClient, - { erc20: erc20!, address: address! }, - "select", - ).read(), - select: (data) => - getERC20BalanceOf( - publicClient, - { erc20: erc20!, address: address! }, - "select", - ).parse(data), + getERC20BalanceOf(publicClient, { erc20: erc20!, address: address! }), staleTime: Infinity, refetchInterval: userRefectchInterval, }); diff --git a/packages/core/src/decorator/publicActions.test.ts b/packages/core/src/decorator/publicActions.test.ts new file mode 100644 index 0000000..c8de0dd --- /dev/null +++ b/packages/core/src/decorator/publicActions.test.ts @@ -0,0 +1,21 @@ +import { expect, test } from "vitest"; +import { BOB, anvilEther } from "../_test/constants.js"; +import { publicClient } from "../_test/utils.js"; +import { amountEqualTo, createAmountFromString } from "../amount/utils.js"; +import { publicActionReverseMirage } from "./publicActions.js"; + +test("public actions decorator", async () => { + const nativeBalanceBob = await publicClient + .extend(publicActionReverseMirage) + .getNativeBalance({ + nativeCurrency: anvilEther, + address: BOB, + }); + + expect( + amountEqualTo( + nativeBalanceBob, + createAmountFromString(anvilEther, "10000"), + ), + ).toBe(true); +}); diff --git a/packages/core/src/decorator/publicActions.ts b/packages/core/src/decorator/publicActions.ts new file mode 100644 index 0000000..9d278b4 --- /dev/null +++ b/packages/core/src/decorator/publicActions.ts @@ -0,0 +1,212 @@ +import type { Chain, Client, Transport } from "viem"; +import { + type BaseERC20, + type ERC20Permit, + getERC20, + getERC20Allowance, + getERC20BalanceOf, + getERC20Decimals, + getERC20DomainSeparator, + getERC20Name, + getERC20Permit, + getERC20PermitData, + getERC20PermitNonce, + getERC20Symbol, + getERC20TotalSupply, + getIsERC20Permit, +} from "../erc20/index.js"; +import type { GetERC20Parameters } from "../erc20/publicActions/getERC20.js"; +import type { GetERC20AllowanceParameters } from "../erc20/publicActions/getERC20Allowance.js"; +import type { GetERC20BalanceOfParameters } from "../erc20/publicActions/getERC20BalanceOf.js"; +import type { GetERC20DecimalsParameters } from "../erc20/publicActions/getERC20Decimals.js"; +import type { GetERC20DomainSeparatorParameters } from "../erc20/publicActions/getERC20DomainSeparator.js"; +import type { GetERC20NameParameters } from "../erc20/publicActions/getERC20Name.js"; +import type { GetERC20PermitParameters } from "../erc20/publicActions/getERC20Permit.js"; +import type { GetERC20PermitDataParameters } from "../erc20/publicActions/getERC20PermitData.js"; +import type { GetERC20PermitNonceParameters } from "../erc20/publicActions/getERC20PermitNonce.js"; +import type { GetERC20SymbolParameters } from "../erc20/publicActions/getERC20Symbol.js"; +import type { GetERC20TotalSupplyParameters } from "../erc20/publicActions/getERC20TotalSupply.js"; +import type { GetIsERC20PermitParameters } from "../erc20/publicActions/getIsERC20Permit.js"; +import { + type SimulateERC20ApproveParameters, + simulateERC20Approve, +} from "../erc20/walletActions/simulateERC20Approve.js"; +import { + type SimulateERC20PermitParameters, + simulateERC20Permit, +} from "../erc20/walletActions/simulateERC20Permit.js"; +import { + type SimulateERC20TransferParameters, + simulateERC20Transfer, +} from "../erc20/walletActions/simulateERC20Transfer.js"; +import { + type SimulateERC20TransferFromParameters, + simulateERC20TransferFrom, +} from "../erc20/walletActions/simulateERC20TransferFrom.js"; +import { + type BaseERC721, + getERC721, + getERC721Approved, + getERC721BalanceOf, + getERC721Data, + getERC721IsApprovedForAll, + getERC721Name, + getERC721OwnerOf, + getERC721SupportsInterface, + getERC721Symbol, + getERC721TokenURI, +} from "../erc721/index.js"; +import type { GetERC721Parameters } from "../erc721/publicActions/getERC721.js"; +import type { GetERC721ApprovedParameters } from "../erc721/publicActions/getERC721Approved.js"; +import type { GetERC721BalanceOfParameters } from "../erc721/publicActions/getERC721BalanceOf.js"; +import type { GetERC721DataParameters } from "../erc721/publicActions/getERC721Data.js"; +import type { GetERC721IsApprovedForAllParameters } from "../erc721/publicActions/getERC721IsApprovedForAll.js"; +import type { GetERC721NameParameters } from "../erc721/publicActions/getERC721Name.js"; +import type { GetERC721OwnerOfParameters } from "../erc721/publicActions/getERC721OwnerOf.js"; +import type { GetERC721SupportsInterfaceParameters } from "../erc721/publicActions/getERC721SupportsInterface.js"; +import type { GetERC721SymbolParameters } from "../erc721/publicActions/getERC721Symbol.js"; +import type { GetERC721TokenURIParameters } from "../erc721/publicActions/getERC721TokenURI.js"; +import { + type SimulateERC721ApproveParameters, + simulateERC721Approve, +} from "../erc721/walletActions/simulateERC721Approve.js"; +import { + type SimulateERC721SetApprovalForAllParameters, + simulateERC721SetApprovalForAll, +} from "../erc721/walletActions/simulateERC721SetApprovalForAll.js"; +import { + type SimulateERC721TransferParameters, + simulateERC721Transfer, +} from "../erc721/walletActions/simulateERC721Transfer.js"; +import { + type BaseERC1155, + getERC1155, + getERC1155BalanceOf, + getERC1155IsApprovedForAll, + getERC1155URI, +} from "../erc1155/index.js"; +import type { GetERC1155Parameters } from "../erc1155/publicActions/getERC1155.js"; +import type { GetERC1155BalanceOfParameters } from "../erc1155/publicActions/getERC1155BalanceOf.js"; +import type { GetERC1155IsApprovedForAllParameters } from "../erc1155/publicActions/getERC1155IsApprovedForAll.js"; +import type { GetERC1155URIParameters } from "../erc1155/publicActions/getERC1155URI.js"; +import { + type SimulateERC1155SetApprovalForAllParameters, + simulateERC1155SetApprovalForAll, +} from "../erc1155/walletActions/simulateERC1155SetApprovalForAll.js"; +import { + type SimulateERC1155TransferParameters, + simulateERC1155Transfer, +} from "../erc1155/walletActions/simulateERC1155Transfer.js"; +import { + type SimulateERC1155TransferBatchParameters, + simulateERC1155TransferBatch, +} from "../erc1155/walletActions/simulateERC1155TransferBatch.js"; +import { + type GetNativeBalanceParameters, + getNativeBalance, +} from "../native/publicActions/getNativeBalance.js"; +import type { NativeCurrency } from "../native/types.js"; +import { + type SimulateWETHDepositParameters, + simulateWETHDeposit, +} from "../weth/walletActions/simulateWETHDeposit.js"; +import { + type SimulateWETHWithdrawParameters, + simulateWETHWithdraw, +} from "../weth/walletActions/simulateWETHWithdraw.js"; + +export const publicActionReverseMirage = < + TChain extends Chain | undefined = Chain | undefined, +>( + client: Client, +) => ({ + getNativeBalance: ( + args: GetNativeBalanceParameters, + ) => getNativeBalance(client, args), + + getERC20: (args: GetERC20Parameters) => getERC20(client, args), + getERC20Allowance: ( + args: GetERC20AllowanceParameters, + ) => getERC20Allowance(client, args), + getERC20BalanceOf: ( + args: GetERC20BalanceOfParameters, + ) => getERC20BalanceOf(client, args), + getERC20TotalSupply: ( + args: GetERC20TotalSupplyParameters, + ) => getERC20TotalSupply(client, args), + getERC20Name: (args: GetERC20NameParameters) => getERC20Name(client, args), + getERC20Symbol: (args: GetERC20SymbolParameters) => + getERC20Symbol(client, args), + getERC20Decimals: (args: GetERC20DecimalsParameters) => + getERC20Decimals(client, args), + getERC20DomainSeparator: (args: GetERC20DomainSeparatorParameters) => + getERC20DomainSeparator(client, args), + getERC20Permit: (args: GetERC20PermitParameters) => + getERC20Permit(client, args), + getERC20PermitNonce: (args: GetERC20PermitNonceParameters) => + getERC20PermitNonce(client, args), + getERC20PermitData: ( + args: GetERC20PermitDataParameters, + ) => getERC20PermitData(client, args), + getIsERC20Permit: (args: GetIsERC20PermitParameters) => + getIsERC20Permit(client, args), + + getERC721: (args: GetERC721Parameters) => getERC721(client, args), + getERC721Approved: (args: GetERC721ApprovedParameters) => + getERC721Approved(client, args), + getERC721BalanceOf: (args: GetERC721BalanceOfParameters) => + getERC721BalanceOf(client, args), + getERC721OwnerOf: (args: GetERC721OwnerOfParameters) => + getERC721OwnerOf(client, args), + getERC721Data: ( + args: GetERC721DataParameters, + ) => getERC721Data(client, args), + getERC721Name: (args: GetERC721NameParameters) => getERC721Name(client, args), + getERC721Symbol: (args: GetERC721SymbolParameters) => + getERC721Symbol(client, args), + getERC721TokenURI: (args: GetERC721TokenURIParameters) => + getERC721TokenURI(client, args), + getERC721IsApprovedForAll: (args: GetERC721IsApprovedForAllParameters) => + getERC721IsApprovedForAll(client, args), + getERC721SupportsInterface: (args: GetERC721SupportsInterfaceParameters) => + getERC721SupportsInterface(client, args), + + getERC1155: (args: GetERC1155Parameters) => getERC1155(client, args), + getERC1155BalanceOf: ( + args: GetERC1155BalanceOfParameters, + ) => getERC1155BalanceOf(client, args), + getERC1155IsApprovedForAll: (args: GetERC1155IsApprovedForAllParameters) => + getERC1155IsApprovedForAll(client, args), + getERC1155URI: (args: GetERC1155URIParameters) => getERC1155URI(client, args), + + simulateWETHDeposit: (args: SimulateWETHDepositParameters) => + simulateWETHDeposit(client, args), + simulateWETHWithdraw: (args: SimulateWETHWithdrawParameters) => + simulateWETHWithdraw(client, args), + + simulateERC20Approve: (args: SimulateERC20ApproveParameters) => + simulateERC20Approve(client, args), + simulateERC20Permit: (args: SimulateERC20PermitParameters) => + simulateERC20Permit(client, args), + simulateERC20Transfer: (args: SimulateERC20TransferParameters) => + simulateERC20Transfer(client, args), + simulateERC20TransferFrom: (args: SimulateERC20TransferFromParameters) => + simulateERC20TransferFrom(client, args), + + simulateERC721Approve: (args: SimulateERC721ApproveParameters) => + simulateERC721Approve(client, args), + simulateERC721SetApprovalForAll: ( + args: SimulateERC721SetApprovalForAllParameters, + ) => simulateERC721SetApprovalForAll(client, args), + simulateERC721Transfer: (args: SimulateERC721TransferParameters) => + simulateERC721Transfer(client, args), + + simulateERC1155SetApprovalForAll: ( + args: SimulateERC1155SetApprovalForAllParameters, + ) => simulateERC1155SetApprovalForAll(client, args), + simulateERC1155Transfer: (args: SimulateERC1155TransferParameters) => + simulateERC1155Transfer(client, args), + simulateERC1155TransferBatch: ( + args: SimulateERC1155TransferBatchParameters, + ) => simulateERC1155TransferBatch(client, args), +}); diff --git a/packages/core/src/decorator/walletActions.test.ts b/packages/core/src/decorator/walletActions.test.ts new file mode 100644 index 0000000..7de6cf2 --- /dev/null +++ b/packages/core/src/decorator/walletActions.test.ts @@ -0,0 +1,51 @@ +import { recoverTypedDataAddress, zeroAddress } from "viem"; +import { foundry } from "viem/chains"; +import { expect, test } from "vitest"; +import { ALICE, BOB } from "../_test/constants.js"; +import { walletClient } from "../_test/utils.js"; +import { + PermitType, + createERC20Permit, + createERC20PermitDataFromString, +} from "../erc20/index.js"; +import { walletActionReverseMirage } from "./walletActions.js"; + +const erc20 = createERC20Permit( + zeroAddress, + "name", + "symbol", + 18, + "1", + foundry.id, +); + +test("sign erc20 permit", async () => { + const signature = await walletClient + .extend(walletActionReverseMirage) + .signERC20Permit({ + permitData: createERC20PermitDataFromString(erc20, ".5", 0n), + spender: BOB, + deadline: 2n ** 256n - 1n, + }); + + const signer = await recoverTypedDataAddress({ + domain: { + name: "name", + version: "1", + chainId: foundry.id, + verifyingContract: zeroAddress, + }, + types: PermitType, + primaryType: "Permit", + message: { + owner: ALICE, + spender: BOB, + value: 5n * 10n ** 17n, + deadline: 2n ** 256n - 1n, + nonce: 0n, + }, + signature, + }); + + expect(signer).toBe(ALICE); +}); diff --git a/packages/core/src/decorator/walletActions.ts b/packages/core/src/decorator/walletActions.ts new file mode 100644 index 0000000..dd9d06e --- /dev/null +++ b/packages/core/src/decorator/walletActions.ts @@ -0,0 +1,15 @@ +import type { Account, Chain, Client, Transport } from "viem"; +import { + type SignERC20PermitParameters, + signERC20Permit, +} from "../erc20/walletActions/signERC20Permit.js"; + +export const walletActionReverseMirage = < + TChain extends Chain = Chain, + TAccount extends Account | undefined = Account | undefined, +>( + client: Client, +) => ({ + signERC20Permit: (args: SignERC20PermitParameters) => + signERC20Permit(client, args), +}); diff --git a/packages/core/src/erc1155/publicActions/getERC1155.ts b/packages/core/src/erc1155/publicActions/getERC1155.ts index 1044488..1b6bc32 100644 --- a/packages/core/src/erc1155/publicActions/getERC1155.ts +++ b/packages/core/src/erc1155/publicActions/getERC1155.ts @@ -1,7 +1,6 @@ import type { Chain, Client, ReadContractParameters, Transport } from "viem"; import { readContract } from "viem/contract"; import { solmateErc1155ABI as solmateERC1155ABI } from "../../generated.js"; -import type { ReverseMirage } from "../../types/rm.js"; import type { BaseERC1155 } from "../types.js"; import { createERC1155 } from "../utils.js"; @@ -15,45 +14,22 @@ export type GetERC1155Parameters = Omit< export type GetERC1155ReturnType = BaseERC1155; -export const getERC1155 = < - TChain extends Chain | undefined, - T extends "select" | undefined, ->( +export const getERC1155 = ( client: Client, { erc1155, ...request }: GetERC1155Parameters, - type?: T, -): ReverseMirage => - (type === undefined - ? readContract(client, { - abi: solmateERC1155ABI, - address: erc1155.address, - functionName: "uri", - args: [erc1155.id], - ...request, - }).then((data) => - createERC1155( - erc1155.address, - erc1155.id, - data, - erc1155.chainID, - erc1155.blockCreated, - ), - ) - : { - read: () => - readContract(client, { - abi: solmateERC1155ABI, - address: erc1155.address, - functionName: "uri", - args: [erc1155.id], - ...request, - }), - parse: (data) => - createERC1155( - erc1155.address, - erc1155.id, - data, - erc1155.chainID, - erc1155.blockCreated, - ), - }) as ReverseMirage; +): Promise => + readContract(client, { + abi: solmateERC1155ABI, + address: erc1155.address, + functionName: "uri", + args: [erc1155.id], + ...request, + }).then((data) => + createERC1155( + erc1155.address, + erc1155.id, + data, + erc1155.chainID, + erc1155.blockCreated, + ), + ); diff --git a/packages/core/src/erc1155/publicActions/getERC1155BalanceOf.ts b/packages/core/src/erc1155/publicActions/getERC1155BalanceOf.ts index 31a9afa..60337ed 100644 --- a/packages/core/src/erc1155/publicActions/getERC1155BalanceOf.ts +++ b/packages/core/src/erc1155/publicActions/getERC1155BalanceOf.ts @@ -7,7 +7,6 @@ import type { } from "viem"; import { readContract } from "viem/contract"; import { solmateErc1155ABI as solmateERC1155ABI } from "../../generated.js"; -import type { ReverseMirage } from "../../types/rm.js"; import type { BaseERC1155, ERC1155Data } from "../types.js"; import { createERC1155Data } from "../utils.js"; @@ -22,28 +21,14 @@ export type GetERC1155BalanceOfReturnType = export const getERC1155BalanceOf = < TChain extends Chain | undefined, TERC1155 extends BaseERC1155, - T extends "select" | undefined, >( client: Client, { erc1155, address, ...request }: GetERC1155BalanceOfParameters, - type?: T, -): ReverseMirage, T> => - (type === undefined - ? readContract(client, { - abi: solmateERC1155ABI, - address: erc1155.address, - functionName: "balanceOf", - args: [address, erc1155.id], - ...request, - }).then((data) => createERC1155Data(erc1155, data)) - : { - read: () => - readContract(client, { - abi: solmateERC1155ABI, - address: erc1155.address, - functionName: "balanceOf", - args: [address, erc1155.id], - ...request, - }), - parse: (data) => createERC1155Data(erc1155, data), - }) as ReverseMirage, T>; +): Promise> => + readContract(client, { + abi: solmateERC1155ABI, + address: erc1155.address, + functionName: "balanceOf", + args: [address, erc1155.id], + ...request, + }).then((data) => createERC1155Data(erc1155, data)); diff --git a/packages/core/src/erc1155/publicActions/getERC1155IsApprovedForAll.ts b/packages/core/src/erc1155/publicActions/getERC1155IsApprovedForAll.ts index 9f06db2..1de635e 100644 --- a/packages/core/src/erc1155/publicActions/getERC1155IsApprovedForAll.ts +++ b/packages/core/src/erc1155/publicActions/getERC1155IsApprovedForAll.ts @@ -7,7 +7,6 @@ import type { } from "viem"; import { readContract } from "viem/contract"; import { solmateErc1155ABI as solmateERC1155ABI } from "../../generated.js"; -import type { ReverseMirage } from "../../types/rm.js"; import type { BaseERC1155 } from "../types.js"; export type GetERC1155IsApprovedForAllParameters = Omit< @@ -17,30 +16,14 @@ export type GetERC1155IsApprovedForAllParameters = Omit< export type GetERC1155IsApprovedForAllReturnType = boolean; -export const getERC1155IsApprovedForAll = < - TChain extends Chain | undefined, - T extends "select" | undefined, ->( +export const getERC1155IsApprovedForAll = ( client: Client, { erc1155, owner, spender, ...request }: GetERC1155IsApprovedForAllParameters, - type?: T, -): ReverseMirage => - (type === undefined - ? readContract(client, { - abi: solmateERC1155ABI, - address: erc1155.address, - functionName: "isApprovedForAll", - args: [owner, spender], - ...request, - }) - : { - read: () => - readContract(client, { - abi: solmateERC1155ABI, - address: erc1155.address, - functionName: "isApprovedForAll", - args: [owner, spender], - ...request, - }), - parse: (data) => data, - }) as ReverseMirage; +): Promise => + readContract(client, { + abi: solmateERC1155ABI, + address: erc1155.address, + functionName: "isApprovedForAll", + args: [owner, spender], + ...request, + }); diff --git a/packages/core/src/erc1155/publicActions/getERC1155URI.ts b/packages/core/src/erc1155/publicActions/getERC1155URI.ts index e4bab89..4cf14c5 100644 --- a/packages/core/src/erc1155/publicActions/getERC1155URI.ts +++ b/packages/core/src/erc1155/publicActions/getERC1155URI.ts @@ -1,7 +1,6 @@ import type { Chain, Client, ReadContractParameters, Transport } from "viem"; import { readContract } from "viem/contract"; import { solmateErc1155ABI as solmateERC1155ABI } from "../../generated.js"; -import type { ReverseMirage } from "../../types/rm.js"; import type { BaseERC1155 } from "../types.js"; export type GetERC1155URIParameters = Omit< @@ -11,30 +10,14 @@ export type GetERC1155URIParameters = Omit< export type GetERC1155URIReturnType = string; -export const getERC1155URI = < - TChain extends Chain | undefined, - T extends "select" | undefined, ->( +export const getERC1155URI = ( client: Client, { erc1155, ...request }: GetERC1155URIParameters, - type?: T, -): ReverseMirage => - (type === undefined - ? readContract(client, { - abi: solmateERC1155ABI, - address: erc1155.address, - functionName: "uri", - args: [erc1155.id], - ...request, - }) - : { - read: () => - readContract(client, { - abi: solmateERC1155ABI, - address: erc1155.address, - functionName: "uri", - args: [erc1155.id], - ...request, - }), - parse: (data) => data, - }) as ReverseMirage; +): Promise => + readContract(client, { + abi: solmateERC1155ABI, + address: erc1155.address, + functionName: "uri", + args: [erc1155.id], + ...request, + }); diff --git a/packages/core/src/erc20/publicActions/getERC20.test.ts b/packages/core/src/erc20/publicActions/getERC20.test.ts index 885ec31..8e2cca5 100644 --- a/packages/core/src/erc20/publicActions/getERC20.test.ts +++ b/packages/core/src/erc20/publicActions/getERC20.test.ts @@ -40,15 +40,3 @@ test("read erc20", async () => { }); expect(_erc20).toStrictEqual(erc20); }); - -test("read erc20 select", async () => { - const rm = getERC20( - publicClient, - { - erc20, - }, - "select", - ); - - expect(await rm.read().then((data) => rm.parse(data))).toStrictEqual(erc20); -}); diff --git a/packages/core/src/erc20/publicActions/getERC20.ts b/packages/core/src/erc20/publicActions/getERC20.ts index 3cd826e..7818d9e 100644 --- a/packages/core/src/erc20/publicActions/getERC20.ts +++ b/packages/core/src/erc20/publicActions/getERC20.ts @@ -1,6 +1,5 @@ import type { Chain, Client, ReadContractParameters, Transport } from "viem"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; -import type { ReverseMirage } from "../../types/rm.js"; import type { BaseERC20, ERC20 } from "../types.js"; import { createERC20 } from "../utils.js"; import { getERC20Decimals } from "./getERC20Decimals.js"; @@ -17,43 +16,21 @@ export type GetERC20Parameters = Omit< export type GetERC20ReturnType = ERC20; -export const getERC20 = < - TChain extends Chain | undefined, - T extends "select" | undefined, ->( +export const getERC20 = ( client: Client, { erc20, ...request }: GetERC20Parameters, - type?: T, -): ReverseMirage<[string, string, number], GetERC20ReturnType, T> => - (type === undefined - ? Promise.all([ - getERC20Name(client, { erc20, ...request }), - getERC20Symbol(client, { erc20, ...request }), - getERC20Decimals(client, { erc20, ...request }), - ]).then(([name, symbol, decimals]) => - createERC20( - erc20.address, - name, - symbol, - decimals, - erc20.chainID, - erc20.blockCreated, - ), - ) - : { - read: () => - Promise.all([ - getERC20Name(client, { erc20, ...request }, "select").read(), - getERC20Symbol(client, { erc20, ...request }, "select").read(), - getERC20Decimals(client, { erc20, ...request }, "select").read(), - ]), - parse: ([name, symbol, decimals]) => - createERC20( - erc20.address, - name, - symbol, - decimals, - erc20.chainID, - erc20.blockCreated, - ), - }) as ReverseMirage<[string, string, number], GetERC20ReturnType, T>; +): Promise => + Promise.all([ + getERC20Name(client, { erc20, ...request }), + getERC20Symbol(client, { erc20, ...request }), + getERC20Decimals(client, { erc20, ...request }), + ]).then(([name, symbol, decimals]) => + createERC20( + erc20.address, + name, + symbol, + decimals, + erc20.chainID, + erc20.blockCreated, + ), + ); diff --git a/packages/core/src/erc20/publicActions/getERC20Allowance.test.ts b/packages/core/src/erc20/publicActions/getERC20Allowance.test.ts index 97ea9c7..1e0ac72 100644 --- a/packages/core/src/erc20/publicActions/getERC20Allowance.test.ts +++ b/packages/core/src/erc20/publicActions/getERC20Allowance.test.ts @@ -61,22 +61,3 @@ test("read allowance", async () => { true, ); }); - -test("read allowance select", async () => { - const rm = getERC20Allowance( - publicClient, - { - erc20, - owner: ALICE, - spender: BOB, - }, - "select", - ); - - expect( - amountEqualTo( - await rm.read().then((data) => rm.parse(data)), - createAmountFromString(erc20, "2"), - ), - ).toBe(true); -}); diff --git a/packages/core/src/erc20/publicActions/getERC20Allowance.ts b/packages/core/src/erc20/publicActions/getERC20Allowance.ts index dcba31a..cbc35bf 100644 --- a/packages/core/src/erc20/publicActions/getERC20Allowance.ts +++ b/packages/core/src/erc20/publicActions/getERC20Allowance.ts @@ -8,7 +8,6 @@ import type { import { readContract } from "viem/contract"; import { createAmountFromRaw } from "../../amount/utils.js"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; -import type { ReverseMirage } from "../../types/rm.js"; import type { BaseERC20, ERC20Amount } from "../types.js"; export type GetERC20AllowanceParameters = Omit< @@ -22,28 +21,14 @@ export type GetERC20AllowanceReturnType = export const getERC20Allowance = < TChain extends Chain | undefined, TERC20 extends BaseERC20, - T extends "select" | undefined, >( client: Client, { erc20, owner, spender, ...request }: GetERC20AllowanceParameters, - type?: T, -): ReverseMirage, T> => - (type === undefined - ? readContract(client, { - abi: solmateERC20ABI, - address: erc20.address, - functionName: "allowance", - args: [owner, spender], - ...request, - }).then((data) => createAmountFromRaw(erc20, data)) - : { - read: () => - readContract(client, { - abi: solmateERC20ABI, - address: erc20.address, - functionName: "allowance", - args: [owner, spender], - ...request, - }), - parse: (data) => createAmountFromRaw(erc20, data), - }) as ReverseMirage, T>; +): Promise> => + readContract(client, { + abi: solmateERC20ABI, + address: erc20.address, + functionName: "allowance", + args: [owner, spender], + ...request, + }).then((data) => createAmountFromRaw(erc20, data)); diff --git a/packages/core/src/erc20/publicActions/getERC20BalanceOf.test.ts b/packages/core/src/erc20/publicActions/getERC20BalanceOf.test.ts index a9f700f..35e49db 100644 --- a/packages/core/src/erc20/publicActions/getERC20BalanceOf.test.ts +++ b/packages/core/src/erc20/publicActions/getERC20BalanceOf.test.ts @@ -60,21 +60,3 @@ test("read balance", async () => { amountEqualTo(balanceOfAlice, createAmountFromString(erc20, "1")), ).toBe(true); }); - -test("read balance select", async () => { - const balanceOfRM = getERC20BalanceOf( - publicClient, - { - erc20, - address: ALICE, - }, - "select", - ); - - expect( - amountEqualTo( - await balanceOfRM.read().then((data) => balanceOfRM.parse(data)), - createAmountFromString(erc20, "1"), - ), - ).toBe(true); -}); diff --git a/packages/core/src/erc20/publicActions/getERC20BalanceOf.ts b/packages/core/src/erc20/publicActions/getERC20BalanceOf.ts index cab772e..5b645d7 100644 --- a/packages/core/src/erc20/publicActions/getERC20BalanceOf.ts +++ b/packages/core/src/erc20/publicActions/getERC20BalanceOf.ts @@ -8,7 +8,6 @@ import type { import { readContract } from "viem/contract"; import { createAmountFromRaw } from "../../amount/utils.js"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; -import type { ReverseMirage } from "../../types/rm.js"; import type { BaseERC20, ERC20Amount } from "../types.js"; export type GetERC20BalanceOfParameters = Omit< @@ -22,28 +21,14 @@ export type GetERC20BalanceOfReturnType = export const getERC20BalanceOf = < TChain extends Chain | undefined, TERC20 extends BaseERC20, - T extends "select" | undefined, >( client: Client, { erc20, address, ...request }: GetERC20BalanceOfParameters, - type?: T, -): ReverseMirage, T> => - (type === undefined - ? readContract(client, { - abi: solmateERC20ABI, - address: erc20.address, - functionName: "balanceOf", - args: [address], - ...request, - }).then((data) => createAmountFromRaw(erc20, data)) - : { - read: () => - readContract(client, { - abi: solmateERC20ABI, - address: erc20.address, - functionName: "balanceOf", - args: [address], - ...request, - }), - parse: (data) => createAmountFromRaw(erc20, data), - }) as ReverseMirage, T>; +): Promise> => + readContract(client, { + abi: solmateERC20ABI, + address: erc20.address, + functionName: "balanceOf", + args: [address], + ...request, + }).then((data) => createAmountFromRaw(erc20, data)); diff --git a/packages/core/src/erc20/publicActions/getERC20Decimals.test.ts b/packages/core/src/erc20/publicActions/getERC20Decimals.test.ts index f548f8c..e10ddb1 100644 --- a/packages/core/src/erc20/publicActions/getERC20Decimals.test.ts +++ b/packages/core/src/erc20/publicActions/getERC20Decimals.test.ts @@ -47,15 +47,3 @@ test("read decimals", async () => { }); expect(decimals).toBe(18); }); - -test("read decimals select", async () => { - const rm = getERC20Decimals( - publicClient, - { - erc20, - }, - "select", - ); - - expect(await rm.read().then((data) => rm.parse(data))).toBe(18); -}); diff --git a/packages/core/src/erc20/publicActions/getERC20Decimals.ts b/packages/core/src/erc20/publicActions/getERC20Decimals.ts index 881c6bd..0628179 100644 --- a/packages/core/src/erc20/publicActions/getERC20Decimals.ts +++ b/packages/core/src/erc20/publicActions/getERC20Decimals.ts @@ -1,7 +1,6 @@ import type { Chain, Client, ReadContractParameters, Transport } from "viem"; import { readContract } from "viem/contract"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; -import type { ReverseMirage } from "../../types/rm.js"; import type { BaseERC20 } from "../types.js"; export type GetERC20DecimalsParameters = Omit< @@ -11,28 +10,13 @@ export type GetERC20DecimalsParameters = Omit< export type GetERC20DecimalsReturnType = number; -export const getERC20Decimals = < - TChain extends Chain | undefined, - T extends "select" | undefined, ->( +export const getERC20Decimals = ( client: Client, { erc20, ...request }: GetERC20DecimalsParameters, - type?: T, -): ReverseMirage => - (type === undefined - ? readContract(client, { - abi: solmateERC20ABI, - address: erc20.address, - functionName: "decimals", - ...request, - }) - : { - read: () => - readContract(client, { - abi: solmateERC20ABI, - address: erc20.address, - functionName: "decimals", - ...request, - }), - parse: (data) => data, - }) as ReverseMirage; +): Promise => + readContract(client, { + abi: solmateERC20ABI, + address: erc20.address, + functionName: "decimals", + ...request, + }); diff --git a/packages/core/src/erc20/publicActions/getERC20DomainSeparator.test.ts b/packages/core/src/erc20/publicActions/getERC20DomainSeparator.test.ts index cc6d6ca..b6aa080 100644 --- a/packages/core/src/erc20/publicActions/getERC20DomainSeparator.test.ts +++ b/packages/core/src/erc20/publicActions/getERC20DomainSeparator.test.ts @@ -48,15 +48,3 @@ test("read domain separator", async () => { expect(ds).toBeTruthy(); assertType(ds); }); - -test("read domain separator select", async () => { - const rm = getERC20DomainSeparator( - publicClient, - { - erc20, - }, - "select", - ); - - expect(await rm.read().then((data) => rm.parse(data))).toBeTruthy(); -}); diff --git a/packages/core/src/erc20/publicActions/getERC20DomainSeparator.ts b/packages/core/src/erc20/publicActions/getERC20DomainSeparator.ts index 4044b30..153156a 100644 --- a/packages/core/src/erc20/publicActions/getERC20DomainSeparator.ts +++ b/packages/core/src/erc20/publicActions/getERC20DomainSeparator.ts @@ -7,7 +7,6 @@ import type { } from "viem"; import { readContract } from "viem/contract"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; -import type { ReverseMirage } from "../../types/rm.js"; import type { BaseERC20 } from "../types.js"; export type GetERC20DomainSeparatorParameters = Omit< @@ -17,28 +16,13 @@ export type GetERC20DomainSeparatorParameters = Omit< export type GetERC20DomainSeparatorReturnType = Hex; -export const getERC20DomainSeparator = < - TChain extends Chain | undefined, - T extends "select" | undefined, ->( +export const getERC20DomainSeparator = ( client: Client, { erc20, ...request }: GetERC20DomainSeparatorParameters, - type?: T, -): ReverseMirage => - (type === undefined - ? readContract(client, { - abi: solmateERC20ABI, - address: erc20.address, - functionName: "DOMAIN_SEPARATOR", - ...request, - }) - : { - read: () => - readContract(client, { - abi: solmateERC20ABI, - address: erc20.address, - functionName: "DOMAIN_SEPARATOR", - ...request, - }), - parse: (data) => data, - }) as ReverseMirage; +): Promise => + readContract(client, { + abi: solmateERC20ABI, + address: erc20.address, + functionName: "DOMAIN_SEPARATOR", + ...request, + }); diff --git a/packages/core/src/erc20/publicActions/getERC20Name.test.ts b/packages/core/src/erc20/publicActions/getERC20Name.test.ts index f563c67..856c074 100644 --- a/packages/core/src/erc20/publicActions/getERC20Name.test.ts +++ b/packages/core/src/erc20/publicActions/getERC20Name.test.ts @@ -47,15 +47,3 @@ test("read name", async () => { }); expect(name).toBe("name"); }); - -test("read name select", async () => { - const rm = getERC20Name( - publicClient, - { - erc20, - }, - "select", - ); - - expect(await rm.read().then((data) => rm.parse(data))).toBe("name"); -}); diff --git a/packages/core/src/erc20/publicActions/getERC20Name.ts b/packages/core/src/erc20/publicActions/getERC20Name.ts index db5e4e8..8a437f5 100644 --- a/packages/core/src/erc20/publicActions/getERC20Name.ts +++ b/packages/core/src/erc20/publicActions/getERC20Name.ts @@ -1,7 +1,6 @@ import type { Chain, Client, ReadContractParameters, Transport } from "viem"; import { readContract } from "viem/contract"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; -import type { ReverseMirage } from "../../types/rm.js"; import type { BaseERC20 } from "../types.js"; export type GetERC20NameParameters = Omit< @@ -11,28 +10,13 @@ export type GetERC20NameParameters = Omit< export type GetERC20NameReturnType = string; -export const getERC20Name = < - TChain extends Chain | undefined, - T extends "select" | undefined, ->( +export const getERC20Name = ( client: Client, { erc20, ...request }: GetERC20NameParameters, - type?: T, -): ReverseMirage => - (type === undefined - ? readContract(client, { - abi: solmateERC20ABI, - address: erc20.address, - functionName: "name", - ...request, - }) - : { - read: () => - readContract(client, { - abi: solmateERC20ABI, - address: erc20.address, - functionName: "name", - ...request, - }), - parse: (data) => data, - }) as ReverseMirage; +): Promise => + readContract(client, { + abi: solmateERC20ABI, + address: erc20.address, + functionName: "name", + ...request, + }); diff --git a/packages/core/src/erc20/publicActions/getERC20Permit.test.ts b/packages/core/src/erc20/publicActions/getERC20Permit.test.ts index 75b24d8..c67fd09 100644 --- a/packages/core/src/erc20/publicActions/getERC20Permit.test.ts +++ b/packages/core/src/erc20/publicActions/getERC20Permit.test.ts @@ -47,15 +47,3 @@ test("read erc20 permit", async () => { }); expect(_erc20).toStrictEqual(erc20); }); - -test("read erc20 permit select", async () => { - const rm = getERC20Permit( - publicClient, - { - erc20, - }, - "select", - ); - - expect(await rm.read().then((data) => rm.parse(data))).toStrictEqual(erc20); -}); diff --git a/packages/core/src/erc20/publicActions/getERC20Permit.ts b/packages/core/src/erc20/publicActions/getERC20Permit.ts index 6b9adc9..cef0db0 100644 --- a/packages/core/src/erc20/publicActions/getERC20Permit.ts +++ b/packages/core/src/erc20/publicActions/getERC20Permit.ts @@ -1,6 +1,5 @@ import type { Chain, Client, ReadContractParameters, Transport } from "viem"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; -import type { ReverseMirage } from "../../types/rm.js"; import type { ERC20Permit } from "../types.js"; import { createERC20Permit } from "../utils.js"; import { getERC20Decimals } from "./getERC20Decimals.js"; @@ -17,49 +16,22 @@ export type GetERC20PermitParameters = Omit< export type GetERC20PermitReturnType = ERC20Permit; -export const getERC20Permit = < - TChain extends Chain | undefined, - T extends "select" | undefined, ->( +export const getERC20Permit = ( client: Client, { erc20, ...request }: GetERC20PermitParameters, - type?: T, -): ReverseMirage<[string, string, number], GetERC20PermitReturnType, T> => - (type === undefined - ? Promise.all([ - getERC20Name(client, { erc20, ...request }), - getERC20Symbol(client, { erc20, ...request }), - getERC20Decimals(client, { erc20, ...request }), - ]).then(([name, symbol, decimals]) => - createERC20Permit( - erc20.address, - name, - symbol, - decimals, - erc20.version ?? "1", - erc20.chainID, - erc20.blockCreated, - ), - ) - : { - read: () => - Promise.all([ - getERC20Name(client, { erc20, ...request }, "select").read(), - getERC20Symbol(client, { erc20, ...request }, "select").read(), - getERC20Decimals(client, { erc20, ...request }, "select").read(), - ]), - parse: ([name, symbol, decimals]) => - createERC20Permit( - erc20.address, - name, - symbol, - decimals, - erc20.version ?? "1", - erc20.chainID, - erc20.blockCreated, - ), - }) as ReverseMirage< - [string, string, number], - GetERC20PermitReturnType, - T - >; +): Promise => + Promise.all([ + getERC20Name(client, { erc20, ...request }), + getERC20Symbol(client, { erc20, ...request }), + getERC20Decimals(client, { erc20, ...request }), + ]).then(([name, symbol, decimals]) => + createERC20Permit( + erc20.address, + name, + symbol, + decimals, + erc20.version ?? "1", + erc20.chainID, + erc20.blockCreated, + ), + ); diff --git a/packages/core/src/erc20/publicActions/getERC20PermitData.test.ts b/packages/core/src/erc20/publicActions/getERC20PermitData.test.ts index a9e5ebf..37c1ddd 100644 --- a/packages/core/src/erc20/publicActions/getERC20PermitData.test.ts +++ b/packages/core/src/erc20/publicActions/getERC20PermitData.test.ts @@ -63,21 +63,3 @@ test("read permit data", async () => { amountEqualTo(data, createERC20PermitDataFromString(erc20, "1", 0n)), ).toBe(true); }); - -test("read permit data select", async () => { - const rm = getERC20PermitData( - publicClient, - { - erc20, - address: ALICE, - }, - "select", - ); - - expect( - amountEqualTo( - await rm.read().then((data) => rm.parse(data)), - createERC20PermitDataFromString(erc20, "1", 0n), - ), - ).toBe(true); -}); diff --git a/packages/core/src/erc20/publicActions/getERC20PermitData.ts b/packages/core/src/erc20/publicActions/getERC20PermitData.ts index cc11c77..c14d9b9 100644 --- a/packages/core/src/erc20/publicActions/getERC20PermitData.ts +++ b/packages/core/src/erc20/publicActions/getERC20PermitData.ts @@ -7,7 +7,6 @@ import type { } from "viem"; import { readContract } from "viem/contract"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; -import type { ReverseMirage } from "../../types/rm.js"; import type { ERC20Permit, ERC20PermitData } from "../types.js"; import { createERC20PermitDataFromRaw } from "../utils.js"; @@ -22,53 +21,25 @@ export type GetERC20PermitDataReturnType = export const getERC20PermitData = < TChain extends Chain | undefined, TERC20 extends ERC20Permit, - T extends "select" | undefined, >( client: Client, { erc20, address, ...request }: GetERC20PermitDataParameters, - type?: T, -): ReverseMirage<[bigint, bigint], GetERC20PermitDataReturnType, T> => - (type === undefined - ? Promise.all([ - readContract(client, { - abi: solmateERC20ABI, - address: erc20.address, - functionName: "balanceOf", - args: [address], - ...request, - }), - readContract(client, { - abi: solmateERC20ABI, - address: erc20.address, - functionName: "nonces", - args: [address], - ...request, - }), - ]).then(([balance, nonce]) => - createERC20PermitDataFromRaw(erc20, balance, nonce), - ) - : { - read: () => - Promise.all([ - readContract(client, { - abi: solmateERC20ABI, - address: erc20.address, - functionName: "balanceOf", - args: [address], - ...request, - }), - readContract(client, { - abi: solmateERC20ABI, - address: erc20.address, - functionName: "nonces", - args: [address], - ...request, - }), - ]), - parse: ([balance, nonce]) => - createERC20PermitDataFromRaw(erc20, balance, nonce), - }) as ReverseMirage< - [bigint, bigint], - GetERC20PermitDataReturnType, - T - >; +): Promise> => + Promise.all([ + readContract(client, { + abi: solmateERC20ABI, + address: erc20.address, + functionName: "balanceOf", + args: [address], + ...request, + }), + readContract(client, { + abi: solmateERC20ABI, + address: erc20.address, + functionName: "nonces", + args: [address], + ...request, + }), + ]).then(([balance, nonce]) => + createERC20PermitDataFromRaw(erc20, balance, nonce), + ); diff --git a/packages/core/src/erc20/publicActions/getERC20PermitNonce.test.ts b/packages/core/src/erc20/publicActions/getERC20PermitNonce.test.ts index 790f97b..a5b544b 100644 --- a/packages/core/src/erc20/publicActions/getERC20PermitNonce.test.ts +++ b/packages/core/src/erc20/publicActions/getERC20PermitNonce.test.ts @@ -48,16 +48,3 @@ test("read nonce", async () => { }); expect(nonce).toBe(0n); }); - -test("read nonce select", async () => { - const rm = getERC20PermitNonce( - publicClient, - { - erc20, - address: ALICE, - }, - "select", - ); - - expect(await rm.read().then((data) => rm.parse(data))).toBe(0n); -}); diff --git a/packages/core/src/erc20/publicActions/getERC20PermitNonce.ts b/packages/core/src/erc20/publicActions/getERC20PermitNonce.ts index fd7353d..2f0ba44 100644 --- a/packages/core/src/erc20/publicActions/getERC20PermitNonce.ts +++ b/packages/core/src/erc20/publicActions/getERC20PermitNonce.ts @@ -7,7 +7,6 @@ import type { } from "viem"; import { readContract } from "viem/contract"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; -import type { ReverseMirage } from "../../types/rm.js"; import type { ERC20Permit } from "../types.js"; export type GetERC20PermitNonceParameters = Omit< @@ -17,30 +16,14 @@ export type GetERC20PermitNonceParameters = Omit< export type GetERC20PermitNonceReturnType = bigint; -export const getERC20PermitNonce = < - TChain extends Chain | undefined, - T extends "select" | undefined, ->( +export const getERC20PermitNonce = ( client: Client, { erc20, address, ...request }: GetERC20PermitNonceParameters, - type?: T, -): ReverseMirage => - (type === undefined - ? readContract(client, { - abi: solmateERC20ABI, - address: erc20.address, - functionName: "nonces", - args: [address], - ...request, - }) - : { - read: () => - readContract(client, { - abi: solmateERC20ABI, - address: erc20.address, - functionName: "nonces", - args: [address], - ...request, - }), - parse: (data) => data, - }) as ReverseMirage; +): Promise => + readContract(client, { + abi: solmateERC20ABI, + address: erc20.address, + functionName: "nonces", + args: [address], + ...request, + }); diff --git a/packages/core/src/erc20/publicActions/getERC20Symbol.test.ts b/packages/core/src/erc20/publicActions/getERC20Symbol.test.ts index ff1d871..4df1d5c 100644 --- a/packages/core/src/erc20/publicActions/getERC20Symbol.test.ts +++ b/packages/core/src/erc20/publicActions/getERC20Symbol.test.ts @@ -47,15 +47,3 @@ test("read symbol", async () => { }); expect(symbol).toBe("symbol"); }); - -test("read symbol select", async () => { - const rm = getERC20Symbol( - publicClient, - { - erc20, - }, - "select", - ); - - expect(await rm.read().then((data) => rm.parse(data))).toBe("symbol"); -}); diff --git a/packages/core/src/erc20/publicActions/getERC20Symbol.ts b/packages/core/src/erc20/publicActions/getERC20Symbol.ts index ec0d21a..9ae44d6 100644 --- a/packages/core/src/erc20/publicActions/getERC20Symbol.ts +++ b/packages/core/src/erc20/publicActions/getERC20Symbol.ts @@ -1,7 +1,6 @@ import type { Chain, Client, ReadContractParameters, Transport } from "viem"; import { readContract } from "viem/contract"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; -import type { ReverseMirage } from "../../types/rm.js"; import type { BaseERC20 } from "../types.js"; export type GetERC20SymbolParameters = Omit< @@ -11,28 +10,13 @@ export type GetERC20SymbolParameters = Omit< export type GetERC20SymbolReturnType = string; -export const getERC20Symbol = < - TChain extends Chain | undefined, - T extends "select" | undefined, ->( +export const getERC20Symbol = ( client: Client, { erc20, ...request }: GetERC20SymbolParameters, - type?: T, -): ReverseMirage => - (type === undefined - ? readContract(client, { - abi: solmateERC20ABI, - address: erc20.address, - functionName: "symbol", - ...request, - }) - : { - read: () => - readContract(client, { - abi: solmateERC20ABI, - address: erc20.address, - functionName: "symbol", - ...request, - }), - parse: (data: string) => data, - }) as ReverseMirage; +): Promise => + readContract(client, { + abi: solmateERC20ABI, + address: erc20.address, + functionName: "symbol", + ...request, + }); diff --git a/packages/core/src/erc20/publicActions/getERC20TotalSupply.test.ts b/packages/core/src/erc20/publicActions/getERC20TotalSupply.test.ts index 3442f46..b110a77 100644 --- a/packages/core/src/erc20/publicActions/getERC20TotalSupply.test.ts +++ b/packages/core/src/erc20/publicActions/getERC20TotalSupply.test.ts @@ -59,20 +59,3 @@ test("read total supply", async () => { true, ); }); - -test("read total supply select", async () => { - const rm = getERC20TotalSupply( - publicClient, - { - erc20, - }, - "select", - ); - - expect( - amountEqualTo( - await rm.read().then((data) => rm.parse(data)), - createAmountFromString(erc20, "1"), - ), - ).toBe(true); -}); diff --git a/packages/core/src/erc20/publicActions/getERC20TotalSupply.ts b/packages/core/src/erc20/publicActions/getERC20TotalSupply.ts index f2b9d2d..b5dab28 100644 --- a/packages/core/src/erc20/publicActions/getERC20TotalSupply.ts +++ b/packages/core/src/erc20/publicActions/getERC20TotalSupply.ts @@ -2,7 +2,6 @@ import type { Chain, Client, ReadContractParameters, Transport } from "viem"; import { readContract } from "viem/contract"; import { createAmountFromRaw } from "../../amount/utils.js"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; -import type { ReverseMirage } from "../../types/rm.js"; import type { BaseERC20, ERC20Amount } from "../types.js"; export type GetERC20TotalSupplyParameters = Omit< @@ -16,26 +15,13 @@ export type GetERC20TotalSupplyReturnType = export const getERC20TotalSupply = < TChain extends Chain | undefined, TERC20 extends BaseERC20, - T extends "select" | undefined, >( client: Client, { erc20, ...request }: GetERC20TotalSupplyParameters, - type?: T, -): ReverseMirage, T> => - (type === undefined - ? readContract(client, { - abi: solmateERC20ABI, - address: erc20.address, - functionName: "totalSupply", - ...request, - }).then((data) => createAmountFromRaw(erc20, data)) - : { - read: () => - readContract(client, { - abi: solmateERC20ABI, - address: erc20.address, - functionName: "totalSupply", - ...request, - }), - parse: (data) => createAmountFromRaw(erc20, data), - }) as ReverseMirage, T>; +): Promise> => + readContract(client, { + abi: solmateERC20ABI, + address: erc20.address, + functionName: "totalSupply", + ...request, + }).then((data) => createAmountFromRaw(erc20, data)); diff --git a/packages/core/src/erc20/publicActions/getIsERC20Permit.ts b/packages/core/src/erc20/publicActions/getIsERC20Permit.ts index 8f597cf..bdad04e 100644 --- a/packages/core/src/erc20/publicActions/getIsERC20Permit.ts +++ b/packages/core/src/erc20/publicActions/getIsERC20Permit.ts @@ -1,14 +1,6 @@ -import type { - Chain, - Client, - Hex, - ReadContractParameters, - Transport, -} from "viem"; +import type { Chain, Client, ReadContractParameters, Transport } from "viem"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; -import type { ReverseMirage } from "../../types/rm.js"; import type { BaseERC20, ERC20, ERC20Permit } from "../types.js"; -import { createERC20, createERC20Permit } from "../utils.js"; import { getERC20 } from "./getERC20.js"; import { getERC20DomainSeparator } from "./getERC20DomainSeparator.js"; import { getERC20Permit } from "./getERC20Permit.js"; @@ -29,63 +21,13 @@ export type GetIsERC20PermitReturnType = ERC20 | ERC20Permit; * * Implementation is determined by checking if calling `DOMAIN_SEPARATOR()` reverts */ -export const getIsERC20Permit = < - TChain extends Chain | undefined, - T extends "select" | undefined, ->( +export const getIsERC20Permit = ( client: Client, { erc20, ...request }: GetIsERC20PermitParameters, - type?: T, -): ReverseMirage< - [[string, string, number], Hex] | [[string, string, number]], - GetIsERC20PermitReturnType, - T -> => - (type === undefined - ? Promise.all([ - getERC20Permit(client, { erc20, ...request }), - getERC20DomainSeparator(client, { erc20, ...request }), - ]) - .then(([erc20]) => erc20) - .catch(() => getERC20(client, { erc20, ...request })) - : { - read: async () => { - try { - return await Promise.all([ - getERC20Permit(client, { erc20, ...request }, "select").read(), - getERC20DomainSeparator( - client, - { erc20, ...request }, - "select", - ).read(), - ]); - } catch { - return await Promise.all([ - getERC20(client, { erc20, ...request }, "select").read(), - ]); - } - }, - parse: (data) => - data.length === 1 - ? createERC20( - erc20.address, - data[0][0], - data[0][1], - data[0][2], - erc20.chainID, - erc20.blockCreated, - ) - : createERC20Permit( - erc20.address, - data[0][0], - data[0][1], - data[0][2], - erc20.version ?? "1", - erc20.chainID, - erc20.blockCreated, - ), - }) as ReverseMirage< - [[string, string, number], Hex] | [[string, string, number]], - GetIsERC20PermitReturnType, - T - >; +): Promise => + Promise.all([ + getERC20Permit(client, { erc20, ...request }), + getERC20DomainSeparator(client, { erc20, ...request }), + ]) + .then(([erc20]) => erc20) + .catch(() => getERC20(client, { erc20, ...request })); diff --git a/packages/core/src/erc721/publicActions/getERC721.test.ts b/packages/core/src/erc721/publicActions/getERC721.test.ts index 803b657..5aebd49 100644 --- a/packages/core/src/erc721/publicActions/getERC721.test.ts +++ b/packages/core/src/erc721/publicActions/getERC721.test.ts @@ -40,15 +40,3 @@ test("read erc721", async () => { }); expect(_erc721).toStrictEqual(erc721); }); - -test("read erc721 select", async () => { - const rm = getERC721( - publicClient, - { - erc721, - }, - "select", - ); - - expect(await rm.read().then((data) => rm.parse(data))).toStrictEqual(erc721); -}); diff --git a/packages/core/src/erc721/publicActions/getERC721.ts b/packages/core/src/erc721/publicActions/getERC721.ts index abd77dc..488bf07 100644 --- a/packages/core/src/erc721/publicActions/getERC721.ts +++ b/packages/core/src/erc721/publicActions/getERC721.ts @@ -1,6 +1,5 @@ import type { Chain, Client, ReadContractParameters, Transport } from "viem"; import { solmateErc721ABI as solmateERC721ABI } from "../../generated.js"; -import type { ReverseMirage } from "../../types/rm.js"; import type { BaseERC721 } from "../types.js"; import { createERC721 } from "../utils.js"; import { getERC721Name } from "./getERC721Name.js"; @@ -16,39 +15,19 @@ export type GetERC721Parameters = Omit< export type GetERC721ReturnType = BaseERC721; -export const getERC721 = < - TChain extends Chain | undefined, - T extends "select" | undefined, ->( +export const getERC721 = ( client: Client, { erc721, ...request }: GetERC721Parameters, - type?: T, -): ReverseMirage<[string, string], GetERC721ReturnType, T> => - (type === undefined - ? Promise.all([ - getERC721Name(client, { erc721, ...request }), - getERC721Symbol(client, { erc721, ...request }), - ]).then(([name, symbol]) => - createERC721( - erc721.address, - name, - symbol, - erc721.chainID, - erc721.blockCreated, - ), - ) - : { - read: () => - Promise.all([ - getERC721Name(client, { erc721, ...request }, "select").read(), - getERC721Symbol(client, { erc721, ...request }, "select").read(), - ]), - parse: ([name, symbol]) => - createERC721( - erc721.address, - name, - symbol, - erc721.chainID, - erc721.blockCreated, - ), - }) as ReverseMirage<[string, string], GetERC721ReturnType, T>; +): Promise => + Promise.all([ + getERC721Name(client, { erc721, ...request }), + getERC721Symbol(client, { erc721, ...request }), + ]).then(([name, symbol]) => + createERC721( + erc721.address, + name, + symbol, + erc721.chainID, + erc721.blockCreated, + ), + ); diff --git a/packages/core/src/erc721/publicActions/getERC721Approved.test.ts b/packages/core/src/erc721/publicActions/getERC721Approved.test.ts index ac67485..293a5e8 100644 --- a/packages/core/src/erc721/publicActions/getERC721Approved.test.ts +++ b/packages/core/src/erc721/publicActions/getERC721Approved.test.ts @@ -57,16 +57,3 @@ test("read approved", async () => { }); expect(owner).toBe(BOB); }); - -test("read approved select", async () => { - const rm = getERC721Approved( - publicClient, - { - erc721, - id: 0n, - }, - "select", - ); - - expect(await rm.read().then((data) => rm.parse(data))).toBe(BOB); -}); diff --git a/packages/core/src/erc721/publicActions/getERC721Approved.ts b/packages/core/src/erc721/publicActions/getERC721Approved.ts index 0eac762..8009033 100644 --- a/packages/core/src/erc721/publicActions/getERC721Approved.ts +++ b/packages/core/src/erc721/publicActions/getERC721Approved.ts @@ -7,7 +7,6 @@ import type { } from "viem"; import { readContract } from "viem/contract"; import { solmateErc721ABI as solmateERC721ABI } from "../../generated.js"; -import type { ReverseMirage } from "../../types/rm.js"; import type { BaseERC721 } from "../types.js"; export type GetERC721ApprovedParameters = Omit< @@ -17,30 +16,14 @@ export type GetERC721ApprovedParameters = Omit< export type GetERC721ApprovedReturnType = Address; -export const getERC721Approved = < - TChain extends Chain | undefined, - T extends "select" | undefined, ->( +export const getERC721Approved = ( client: Client, { erc721, id, ...request }: GetERC721ApprovedParameters, - type?: T, -): ReverseMirage => - (type === undefined - ? readContract(client, { - abi: solmateERC721ABI, - address: erc721.address, - functionName: "getApproved", - args: [id], - ...request, - }) - : { - read: () => - readContract(client, { - abi: solmateERC721ABI, - address: erc721.address, - functionName: "getApproved", - args: [id], - ...request, - }), - parse: (data) => data, - }) as ReverseMirage; +): Promise => + readContract(client, { + abi: solmateERC721ABI, + address: erc721.address, + functionName: "getApproved", + args: [id], + ...request, + }); diff --git a/packages/core/src/erc721/publicActions/getERC721BalanceOf.test.ts b/packages/core/src/erc721/publicActions/getERC721BalanceOf.test.ts index c77b45b..1e9bfe8 100644 --- a/packages/core/src/erc721/publicActions/getERC721BalanceOf.test.ts +++ b/packages/core/src/erc721/publicActions/getERC721BalanceOf.test.ts @@ -49,16 +49,3 @@ test("read balance", async () => { }); expect(balanceOfAlice).toBe(1n); }); - -test("read balance select", async () => { - const rm = getERC721BalanceOf( - publicClient, - { - erc721, - address: ALICE, - }, - "select", - ); - - expect(await rm.read().then((data) => rm.parse(data))).toBe(1n); -}); diff --git a/packages/core/src/erc721/publicActions/getERC721BalanceOf.ts b/packages/core/src/erc721/publicActions/getERC721BalanceOf.ts index 69260b0..f5af7b7 100644 --- a/packages/core/src/erc721/publicActions/getERC721BalanceOf.ts +++ b/packages/core/src/erc721/publicActions/getERC721BalanceOf.ts @@ -7,7 +7,6 @@ import type { } from "viem"; import { readContract } from "viem/contract"; import { solmateErc721ABI as solmateERC721ABI } from "../../generated.js"; -import type { ReverseMirage } from "../../types/rm.js"; import type { BaseERC721 } from "../types.js"; export type GetERC721BalanceOfParameters = Omit< @@ -17,30 +16,14 @@ export type GetERC721BalanceOfParameters = Omit< export type GetERC721BalanceOfReturnType = bigint; -export const getERC721BalanceOf = < - TChain extends Chain | undefined, - T extends "select" | undefined, ->( +export const getERC721BalanceOf = ( client: Client, { erc721, address, ...request }: GetERC721BalanceOfParameters, - type?: T, -): ReverseMirage => - (type === undefined - ? readContract(client, { - abi: solmateERC721ABI, - address: erc721.address, - functionName: "balanceOf", - args: [address], - ...request, - }) - : { - read: () => - readContract(client, { - abi: solmateERC721ABI, - address: erc721.address, - functionName: "balanceOf", - args: [address], - ...request, - }), - parse: (data) => data, - }) as ReverseMirage; +): Promise => + readContract(client, { + abi: solmateERC721ABI, + address: erc721.address, + functionName: "balanceOf", + args: [address], + ...request, + }); diff --git a/packages/core/src/erc721/publicActions/getERC721Data.test.ts b/packages/core/src/erc721/publicActions/getERC721Data.test.ts index 1410c8d..4d82046 100644 --- a/packages/core/src/erc721/publicActions/getERC721Data.test.ts +++ b/packages/core/src/erc721/publicActions/getERC721Data.test.ts @@ -50,16 +50,3 @@ test("read balance", async () => { expect(data.balance).toBe(1); expect(data.ids).toBe(undefined); }); - -test("read balance select", async () => { - const rm = getERC721Data( - publicClient, - { - erc721, - address: ALICE, - }, - "select", - ); - - expect((await rm.read().then((data) => rm.parse(data))).balance).toBe(1); -}); diff --git a/packages/core/src/erc721/publicActions/getERC721Data.ts b/packages/core/src/erc721/publicActions/getERC721Data.ts index 9505ea7..d81eae9 100644 --- a/packages/core/src/erc721/publicActions/getERC721Data.ts +++ b/packages/core/src/erc721/publicActions/getERC721Data.ts @@ -6,7 +6,6 @@ import type { Transport, } from "viem"; import { solmateErc721ABI as solmateERC721ABI } from "../../generated.js"; -import type { ReverseMirage } from "../../types/rm.js"; import type { BaseERC721, ERC721Data } from "../types.js"; import { createERC721Data } from "../utils.js"; import { getERC721BalanceOf } from "./getERC721BalanceOf.js"; @@ -22,30 +21,12 @@ export type GetERC721DataReturnType = export const getERC721Data = < TChain extends Chain | undefined, TERC721 extends BaseERC721, - T extends "select" | undefined, >( client: Client, { erc721, address, ...request }: GetERC721DataParameters, - type?: T, -): ReverseMirage, T> => - (type === undefined - ? getERC721BalanceOf(client, { erc721, address, ...request }).then( - (data) => { - if (data > Number.MAX_SAFE_INTEGER) - throw Error("balance exceeds maximum representable number"); - return createERC721Data(erc721, Number(data)); - }, - ) - : { - read: () => - getERC721BalanceOf( - client, - { erc721, address, ...request }, - "select", - ).read(), - parse: (data) => { - if (data > Number.MAX_SAFE_INTEGER) - throw Error("balance exceeds maximum representable number"); - return createERC721Data(erc721, Number(data)); - }, - }) as ReverseMirage, T>; +): Promise> => + getERC721BalanceOf(client, { erc721, address, ...request }).then((data) => { + if (data > Number.MAX_SAFE_INTEGER) + throw Error("balance exceeds maximum representable number"); + return createERC721Data(erc721, Number(data)); + }); diff --git a/packages/core/src/erc721/publicActions/getERC721IsApprovedForAll.test.ts b/packages/core/src/erc721/publicActions/getERC721IsApprovedForAll.test.ts index a0a489f..64fdf02 100644 --- a/packages/core/src/erc721/publicActions/getERC721IsApprovedForAll.test.ts +++ b/packages/core/src/erc721/publicActions/getERC721IsApprovedForAll.test.ts @@ -50,17 +50,3 @@ test("read is approved for all", async () => { }); expect(owner).toBe(true); }); - -test("read is approved for all select", async () => { - const rm = getERC721IsApprovedForAll( - publicClient, - { - erc721, - owner: ALICE, - spender: BOB, - }, - "select", - ); - - expect(await rm.read().then((data) => rm.parse(data))).toBe(true); -}); diff --git a/packages/core/src/erc721/publicActions/getERC721IsApprovedForAll.ts b/packages/core/src/erc721/publicActions/getERC721IsApprovedForAll.ts index 41e66c5..f02cac4 100644 --- a/packages/core/src/erc721/publicActions/getERC721IsApprovedForAll.ts +++ b/packages/core/src/erc721/publicActions/getERC721IsApprovedForAll.ts @@ -7,7 +7,6 @@ import type { } from "viem"; import { readContract } from "viem/contract"; import { solmateErc721ABI as solmateERC721ABI } from "../../generated.js"; -import type { ReverseMirage } from "../../types/rm.js"; import type { BaseERC721 } from "../types.js"; export type GetERC721IsApprovedForAllParameters = Omit< @@ -17,30 +16,14 @@ export type GetERC721IsApprovedForAllParameters = Omit< export type GetERC721IsApprovedForAllReturnType = boolean; -export const getERC721IsApprovedForAll = < - TChain extends Chain | undefined, - T extends "select" | undefined, ->( +export const getERC721IsApprovedForAll = ( client: Client, { erc721, owner, spender, ...request }: GetERC721IsApprovedForAllParameters, - type?: T, -): ReverseMirage => - (type === undefined - ? readContract(client, { - abi: solmateERC721ABI, - address: erc721.address, - functionName: "isApprovedForAll", - args: [owner, spender], - ...request, - }) - : { - read: () => - readContract(client, { - abi: solmateERC721ABI, - address: erc721.address, - functionName: "isApprovedForAll", - args: [owner, spender], - ...request, - }), - parse: (data) => data, - }) as ReverseMirage; +): Promise => + readContract(client, { + abi: solmateERC721ABI, + address: erc721.address, + functionName: "isApprovedForAll", + args: [owner, spender], + ...request, + }); diff --git a/packages/core/src/erc721/publicActions/getERC721Name.test.ts b/packages/core/src/erc721/publicActions/getERC721Name.test.ts index af836ae..1da8472 100644 --- a/packages/core/src/erc721/publicActions/getERC721Name.test.ts +++ b/packages/core/src/erc721/publicActions/getERC721Name.test.ts @@ -40,15 +40,3 @@ test("read name", async () => { }); expect(name).toBe("name"); }); - -test("read name select", async () => { - const rm = getERC721Name( - publicClient, - { - erc721, - }, - "select", - ); - - expect(await rm.read().then((data) => rm.parse(data))).toBe("name"); -}); diff --git a/packages/core/src/erc721/publicActions/getERC721Name.ts b/packages/core/src/erc721/publicActions/getERC721Name.ts index c66a84b..43cfe94 100644 --- a/packages/core/src/erc721/publicActions/getERC721Name.ts +++ b/packages/core/src/erc721/publicActions/getERC721Name.ts @@ -1,7 +1,6 @@ import type { 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 { BaseERC721 } from "../types.js"; export type GetERC721NameParameters = Omit< @@ -11,28 +10,13 @@ export type GetERC721NameParameters = Omit< export type GetERC721NameReturnType = string; -export const getERC721Name = < - TChain extends Chain | undefined, - T extends "select" | undefined, ->( +export const getERC721Name = ( client: Client, { erc721, ...request }: GetERC721NameParameters, - type?: T, -): ReverseMirage => - (type === undefined - ? readContract(client, { - abi: solmateERC721ABI, - address: erc721.address, - functionName: "name", - ...request, - }) - : { - read: () => - readContract(client, { - abi: solmateERC721ABI, - address: erc721.address, - functionName: "name", - ...request, - }), - parse: (data) => data, - }) as ReverseMirage; +): Promise => + readContract(client, { + abi: solmateERC721ABI, + address: erc721.address, + functionName: "name", + ...request, + }); diff --git a/packages/core/src/erc721/publicActions/getERC721OwnerOf.test.ts b/packages/core/src/erc721/publicActions/getERC721OwnerOf.test.ts index e043023..dd8c687 100644 --- a/packages/core/src/erc721/publicActions/getERC721OwnerOf.test.ts +++ b/packages/core/src/erc721/publicActions/getERC721OwnerOf.test.ts @@ -49,16 +49,3 @@ test("read owner", async () => { }); expect(owner).toBe(ALICE); }); - -test("read owner select", async () => { - const rm = getERC721OwnerOf( - publicClient, - { - erc721, - id: 0n, - }, - "select", - ); - - expect(await rm.read().then((data) => rm.parse(data))).toBe(ALICE); -}); diff --git a/packages/core/src/erc721/publicActions/getERC721OwnerOf.ts b/packages/core/src/erc721/publicActions/getERC721OwnerOf.ts index 87aa835..6255369 100644 --- a/packages/core/src/erc721/publicActions/getERC721OwnerOf.ts +++ b/packages/core/src/erc721/publicActions/getERC721OwnerOf.ts @@ -7,7 +7,6 @@ import type { } from "viem"; import { readContract } from "viem/contract"; import { solmateErc721ABI as solmateERC721ABI } from "../../generated.js"; -import type { ReverseMirage } from "../../types/rm.js"; import type { BaseERC721 } from "../types.js"; export type GetERC721OwnerOfParameters = Omit< @@ -17,30 +16,14 @@ export type GetERC721OwnerOfParameters = Omit< export type GetERC721OwnerOfReturnType = Address; -export const getERC721OwnerOf = < - TChain extends Chain | undefined, - T extends "select" | undefined, ->( +export const getERC721OwnerOf = ( client: Client, { erc721, id, ...request }: GetERC721OwnerOfParameters, - type?: T, -): ReverseMirage => - (type === undefined - ? readContract(client, { - abi: solmateERC721ABI, - address: erc721.address, - functionName: "ownerOf", - args: [id], - ...request, - }) - : { - read: () => - readContract(client, { - abi: solmateERC721ABI, - address: erc721.address, - functionName: "ownerOf", - args: [id], - ...request, - }), - parse: (data) => data, - }) as ReverseMirage; +): Promise => + readContract(client, { + abi: solmateERC721ABI, + address: erc721.address, + functionName: "ownerOf", + args: [id], + ...request, + }); diff --git a/packages/core/src/erc721/publicActions/getERC721SupportsInterface.test.ts b/packages/core/src/erc721/publicActions/getERC721SupportsInterface.test.ts index 98c183b..21a447d 100644 --- a/packages/core/src/erc721/publicActions/getERC721SupportsInterface.test.ts +++ b/packages/core/src/erc721/publicActions/getERC721SupportsInterface.test.ts @@ -41,16 +41,3 @@ test("read supports interface", async () => { }); expect(symbol).toBe(true); }); - -test("read supports interface select", async () => { - const rm = getERC721SupportsInterface( - publicClient, - { - erc721, - interfaceID: "0x01ffc9a7", - }, - "select", - ); - - expect(await rm.read().then((data) => rm.parse(data))).toBe(true); -}); diff --git a/packages/core/src/erc721/publicActions/getERC721SupportsInterface.ts b/packages/core/src/erc721/publicActions/getERC721SupportsInterface.ts index 1f71914..c845a04 100644 --- a/packages/core/src/erc721/publicActions/getERC721SupportsInterface.ts +++ b/packages/core/src/erc721/publicActions/getERC721SupportsInterface.ts @@ -7,7 +7,6 @@ import type { } from "viem"; import { readContract } from "viem/contract"; import { solmateErc721ABI as solmateERC721ABI } from "../../generated.js"; -import type { ReverseMirage } from "../../types/rm.js"; import type { BaseERC721 } from "../types.js"; export type GetERC721SupportsInterfaceParameters = Omit< @@ -17,30 +16,14 @@ export type GetERC721SupportsInterfaceParameters = Omit< export type GetERC721SupportsInterfaceReturnType = boolean; -export const getERC721SupportsInterface = < - TChain extends Chain | undefined, - T extends "select" | undefined, ->( +export const getERC721SupportsInterface = ( client: Client, { erc721, interfaceID, ...request }: GetERC721SupportsInterfaceParameters, - type?: T, -): ReverseMirage => - (type === undefined - ? readContract(client, { - abi: solmateERC721ABI, - address: erc721.address, - functionName: "supportsInterface", - args: [interfaceID], - ...request, - }) - : { - read: () => - readContract(client, { - abi: solmateERC721ABI, - address: erc721.address, - functionName: "supportsInterface", - args: [interfaceID], - ...request, - }), - parse: (data) => data, - }) as ReverseMirage; +): Promise => + readContract(client, { + abi: solmateERC721ABI, + address: erc721.address, + functionName: "supportsInterface", + args: [interfaceID], + ...request, + }); diff --git a/packages/core/src/erc721/publicActions/getERC721Symbol.test.ts b/packages/core/src/erc721/publicActions/getERC721Symbol.test.ts index 6e86cd1..73c11ec 100644 --- a/packages/core/src/erc721/publicActions/getERC721Symbol.test.ts +++ b/packages/core/src/erc721/publicActions/getERC721Symbol.test.ts @@ -40,15 +40,3 @@ test("read symbol", async () => { }); expect(symbol).toBe("symbol"); }); - -test("read symbol select", async () => { - const rm = getERC721Symbol( - publicClient, - { - erc721, - }, - "select", - ); - - expect(await rm.read().then((data) => rm.parse(data))).toBe("symbol"); -}); diff --git a/packages/core/src/erc721/publicActions/getERC721Symbol.ts b/packages/core/src/erc721/publicActions/getERC721Symbol.ts index 48ccd1b..0e89866 100644 --- a/packages/core/src/erc721/publicActions/getERC721Symbol.ts +++ b/packages/core/src/erc721/publicActions/getERC721Symbol.ts @@ -1,7 +1,6 @@ import type { 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 { BaseERC721 } from "../types.js"; export type GetERC721SymbolParameters = Omit< @@ -11,28 +10,13 @@ export type GetERC721SymbolParameters = Omit< export type GetERC721SymbolReturnType = string; -export const getERC721Symbol = < - TChain extends Chain | undefined, - T extends "select" | undefined, ->( +export const getERC721Symbol = ( client: Client, { erc721, ...request }: GetERC721SymbolParameters, - type?: T, -): ReverseMirage => - (type === undefined - ? readContract(client, { - abi: solmateERC721ABI, - address: erc721.address, - functionName: "symbol", - ...request, - }) - : { - read: () => - readContract(client, { - abi: solmateERC721ABI, - address: erc721.address, - functionName: "symbol", - ...request, - }), - parse: (data) => data, - }) as ReverseMirage; +): Promise => + readContract(client, { + abi: solmateERC721ABI, + address: erc721.address, + functionName: "symbol", + ...request, + }); diff --git a/packages/core/src/erc721/publicActions/getERC721TokenURI.test.ts b/packages/core/src/erc721/publicActions/getERC721TokenURI.test.ts index 8e6af50..e81f01b 100644 --- a/packages/core/src/erc721/publicActions/getERC721TokenURI.test.ts +++ b/packages/core/src/erc721/publicActions/getERC721TokenURI.test.ts @@ -41,16 +41,3 @@ test("read uri", async () => { }); expect(uri).toBe("mitch.com"); }); - -test("read uri select", async () => { - const rm = getERC721TokenURI( - publicClient, - { - erc721, - id: 0n, - }, - "select", - ); - - expect(await rm.read().then((data) => rm.parse(data))).toBe("mitch.com"); -}); diff --git a/packages/core/src/erc721/publicActions/getERC721TokenURI.ts b/packages/core/src/erc721/publicActions/getERC721TokenURI.ts index c94cf1c..04d8900 100644 --- a/packages/core/src/erc721/publicActions/getERC721TokenURI.ts +++ b/packages/core/src/erc721/publicActions/getERC721TokenURI.ts @@ -1,7 +1,6 @@ import type { 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 { BaseERC721 } from "../types.js"; export type GetERC721TokenURIParameters = Omit< @@ -11,30 +10,14 @@ export type GetERC721TokenURIParameters = Omit< export type GetERC721TokenURIReturnType = string; -export const getERC721TokenURI = < - TChain extends Chain | undefined, - T extends "select" | undefined, ->( +export const getERC721TokenURI = ( client: Client, { erc721, id, ...request }: GetERC721TokenURIParameters, - type?: T, -): ReverseMirage => - (type === undefined - ? readContract(client, { - abi: solmateERC721ABI, - address: erc721.address, - functionName: "tokenURI", - args: [id], - ...request, - }) - : { - read: () => - readContract(client, { - abi: solmateERC721ABI, - address: erc721.address, - functionName: "tokenURI", - args: [id], - ...request, - }), - parse: (data) => data, - }) as ReverseMirage; +): Promise => + readContract(client, { + abi: solmateERC721ABI, + address: erc721.address, + functionName: "tokenURI", + args: [id], + ...request, + }); diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index ddee3dc..ca2a590 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -150,8 +150,6 @@ export { export type { BigIntIsh, - ReverseMirage, - ReverseMirageRead, Token, TokenData, Tuple, @@ -166,3 +164,6 @@ export { simulateWETHDeposit, simulateWETHWithdraw, } from "./weth/index.js"; + +export { publicActionReverseMirage } from "./decorator/publicActions.js"; +export { walletActionReverseMirage } from "./decorator/walletActions.js"; diff --git a/packages/core/src/native/publicActions/getNativeBalance.ts b/packages/core/src/native/publicActions/getNativeBalance.ts index acda95c..30249d3 100644 --- a/packages/core/src/native/publicActions/getNativeBalance.ts +++ b/packages/core/src/native/publicActions/getNativeBalance.ts @@ -1,7 +1,6 @@ import type { Chain, Client, GetBalanceParameters, Transport } from "viem"; import { getBalance } from "viem/actions"; import { createAmountFromRaw } from "../../amount/utils.js"; -import type { ReverseMirage } from "../../types/rm.js"; import type { NativeCurrency, NativeCurrencyAmount } from "../types.js"; export type GetNativeBalanceParameters = @@ -15,7 +14,6 @@ export type GetNativeBalanceReturnType = export const getNativeBalance = < TChain extends Chain | undefined, TNativeCurrency extends NativeCurrency, - T extends "select" | undefined, >( client: Client, { @@ -23,17 +21,7 @@ export const getNativeBalance = < nativeCurrency, ...request }: GetNativeBalanceParameters, - type?: T, -): ReverseMirage, T> => - (type === undefined - ? getBalance(client, { address: address, ...request }).then((data) => - createAmountFromRaw(nativeCurrency, data), - ) - : { - read: () => getBalance(client, { address: address, ...request }), - parse: (data: bigint) => createAmountFromRaw(nativeCurrency, data), - }) as ReverseMirage< - bigint, - GetNativeBalanceReturnType, - T - >; +): Promise> => + getBalance(client, { address: address, ...request }).then((data) => + createAmountFromRaw(nativeCurrency, data), + ); diff --git a/packages/core/src/types/index.ts b/packages/core/src/types/index.ts index 1316843..0111f1b 100644 --- a/packages/core/src/types/index.ts +++ b/packages/core/src/types/index.ts @@ -1,4 +1,3 @@ export type { BigIntIsh } from "./bigintish.js"; -export type { ReverseMirage, ReverseMirageRead } from "./rm.js"; export type { Token, TokenData } from "./token.js"; export type { Tuple } from "./tuple.js"; diff --git a/packages/core/src/types/rm.ts b/packages/core/src/types/rm.ts deleted file mode 100644 index 2bc8733..0000000 --- a/packages/core/src/types/rm.ts +++ /dev/null @@ -1,10 +0,0 @@ -export type ReverseMirage< - TRet, - TParse, - T extends "select" | undefined, -> = undefined extends T ? Promise : ReverseMirageRead; - -export type ReverseMirageRead = { - read: () => Promise; - parse: (data: TRet) => TParse; -}; diff --git a/packages/core/src/utils/getQueryKey.ts b/packages/core/src/utils/getQueryKey.ts index 4f610a0..10b4689 100644 --- a/packages/core/src/utils/getQueryKey.ts +++ b/packages/core/src/utils/getQueryKey.ts @@ -1,18 +1,16 @@ -import type { ReverseMirageRead } from "../types/rm.js"; - /** * Return a query key for a specific `get` action and its arguments * @description Used specifically for frontend data collection * @see https://tanstack.com/query/v4/docs/react/guides/query-keys */ export const getQueryKey = ( - get: ( - // biome-ignore lint/suspicious/noExplicitAny: dont need - client: any, - args: TArgs, - type?: "select" | undefined, - // biome-ignore lint/suspicious/noExplicitAny: dont need - ) => ReverseMirageRead, + get: + | (( + // biome-ignore lint/suspicious/noExplicitAny: dont need + client: any, + args: TArgs, + ) => unknown) + | ((args: TArgs) => unknown), args: TArgs, chainID: number, ) => { From f2de3868d58c70635fbd6aa30b8db109b28c5020 Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Sun, 24 Sep 2023 23:08:31 -0400 Subject: [PATCH 12/42] RELEASING: Releasing 0 package(s) Releases: [skip ci] From 89add6a75e0281228ced98371592ef2cdb8a56aa Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Sun, 24 Sep 2023 23:09:33 -0400 Subject: [PATCH 13/42] docs(changeset): Add decorator to extend viem --- .changeset/young-schools-punch.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/young-schools-punch.md diff --git a/.changeset/young-schools-punch.md b/.changeset/young-schools-punch.md new file mode 100644 index 0000000..7fc4d27 --- /dev/null +++ b/.changeset/young-schools-punch.md @@ -0,0 +1,5 @@ +--- +"reverse-mirage": patch +--- + +Add decorator to extend viem From 388d0db5910448cb91a3459432d515427c35bf3f Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Sun, 24 Sep 2023 23:09:57 -0400 Subject: [PATCH 14/42] RELEASING: Releasing 1 package(s) Releases: reverse-mirage@1.0.0-next.2 [skip ci] --- packages/core/CHANGELOG.md | 6 ++++++ packages/core/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index b996c4e..43921e2 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,11 @@ # reverse-mirage +## 1.0.0-next.2 + +### Patch Changes + +- 89add6a: Add decorator to extend viem + ## 1.0.0-next.1 ### Patch Changes diff --git a/packages/core/package.json b/packages/core/package.json index 7a0bf05..f457810 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "reverse-mirage", - "version": "1.0.0-next.1", + "version": "1.0.0-next.2", "description": "Application level typescript utilities for Ethereum", "type": "module", "sideEffects": false, From 9a45a2b862c6c5f8f09549726f73d42fca0be0e9 Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Sun, 24 Sep 2023 23:21:58 -0400 Subject: [PATCH 15/42] version --- .changeset/pre.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.changeset/pre.json b/.changeset/pre.json index 94fa07f..311d845 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -6,6 +6,7 @@ }, "changesets": [ "good-jobs-think", - "long-pillows-sip" + "long-pillows-sip", + "young-schools-punch" ] } From 959bd957cbeeb23ed880aab99841f36f7265a4de Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Tue, 26 Sep 2023 09:19:07 -0400 Subject: [PATCH 16/42] docs --- docs/.vitepress/config.mts | 9 +++------ docs/erc20/createERC20.md | 35 +++++++++++++++++++++++++++++++++++ docs/erc20/introduction.md | 17 +++++++++++++++++ docs/index.md | 23 +++++++++++++++++++++-- docs/installation.md | 17 ----------------- packages/core/src/index.ts | 6 +++--- 6 files changed, 79 insertions(+), 28 deletions(-) create mode 100644 docs/erc20/createERC20.md create mode 100644 docs/erc20/introduction.md delete mode 100644 docs/installation.md diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index a0e7c12..17ce0f4 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -13,23 +13,20 @@ export default defineConfig({ sidebar: [ { text: "Introduction", - items: [ - { text: "Getting started", link: "/" }, - { text: "Installation", link: "/installation" }, - ], + items: [{ text: "Getting started", link: "/" }], }, { text: "ERC20", collapsed: true, items: [ - { text: "Introduction", link: "" }, + { text: "Introduction", link: "erc20/introduction" }, { text: "Utilities", items: [ { text: "createERC20", - link: "", + link: "erc20/createERC20", }, { text: "createERC20Amount", diff --git a/docs/erc20/createERC20.md b/docs/erc20/createERC20.md new file mode 100644 index 0000000..53efd29 --- /dev/null +++ b/docs/erc20/createERC20.md @@ -0,0 +1,35 @@ +--- +head: + - - meta + - property: og:title + content: createERC20 + - - meta + - name: description + content: Create an erc20. + - - meta + - property: og:description + content: Creates an erc20. + +--- + +# createERC20 + +Creates an `erc20`. + +## Usage + +::: code-group + +```ts [example.ts] +import { createERC20 } from 'reverse-mirage' + +const usdc = createERC20({ // [!code focus:7] + address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', + name: 'USD Coin', + symbol: 'USDC', + decimals: 6, + chainID: 1, +}) +``` + +::: diff --git a/docs/erc20/introduction.md b/docs/erc20/introduction.md new file mode 100644 index 0000000..0d91209 --- /dev/null +++ b/docs/erc20/introduction.md @@ -0,0 +1,17 @@ +--- +head: + - - meta + - property: og:title + content: Introduction to ERC20 + - - meta + - name: description + content: A brief introduction on what ERC20 does in reverse mirage. + - - meta + - property: og:description + content: A brief introduction on what ERC20 does in reverse mirage. + +--- + +# Introduction to ERC20 + +The ERC20 entity in reverse mirage is an abstraction over the Ethereum fungible token standard. There are multiple methods for safely reading from and writing to a contract that implements this standard. EIP 2612 (permit) is also supported. diff --git a/docs/index.md b/docs/index.md index fe59071..d2400c4 100644 --- a/docs/index.md +++ b/docs/index.md @@ -18,16 +18,17 @@ ```ts import { createPublicClient, http } from 'viem' -import {publicActions, amountToNumber} from 'reverse-mirage' +import {publicActionsReverseMirage, amountToNumber} from 'reverse-mirage' export const publicClient = createPublicClient({ chain: mainnet, transport: http() -}).extend(publicActions) +}).extend(publicActionsReverseMirage) // read token metadata const usdc = await publicClient.getERC20({ address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // usdc + chainID: 1 // mainnet }) console.log(usdc.decimals) // 6 @@ -40,3 +41,21 @@ const vitalikBalance = await publicClient.getERC20Balance({ console.log(amountToNumber(vitalikBalance)) // 420.69 ``` + +## Installation + +::: code-group + +```bash [npm] +npm i reverse-mirage +``` + +```bash [pnpm] +pnpm i reverse-mirage +``` + +```bash [bun] +bun i reverse-mirage +``` + +::: diff --git a/docs/installation.md b/docs/installation.md deleted file mode 100644 index e16b9ef..0000000 --- a/docs/installation.md +++ /dev/null @@ -1,17 +0,0 @@ -# Installation - -::: code-group - -```bash [npm] -npm i reverse-mirage -``` - -```bash [pnpm] -pnpm i reverse-mirage -``` - -```bash [bun] -bun i reverse-mirage -``` - -::: diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index ca2a590..c95dfeb 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -43,7 +43,7 @@ export { createERC20PermitDataFromRaw, createERC20PermitDataFromString, PermitType, - solmateERC20ABI, + solmateERC20ABI as erc20ABI, getERC20, getERC20Allowance, getERC20BalanceOf, @@ -69,7 +69,7 @@ export { type ERC721Data, createERC721, createERC721Data, - solmateERC721ABI, + solmateERC721ABI as erc721ABI, getERC721, getERC721Approved, getERC721BalanceOf, @@ -91,7 +91,7 @@ export { type ERC1155Data, createERC1155, createERC1155Data, - solmateERC1155ABI, + solmateERC1155ABI as erc1155ABI, getERC1155, getERC1155BalanceOf, getERC1155IsApprovedForAll, From 32b3f292c0b59b6c1920c17d85e10da7e81a42e4 Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Tue, 26 Sep 2023 10:42:36 -0400 Subject: [PATCH 17/42] change to write contract --- README.md | 12 ++- examples/next-interface/hooks/useTransfer.ts | 5 +- packages/core/src/decorator/publicActions.ts | 84 +------------------ packages/core/src/decorator/walletActions.ts | 83 ++++++++++++++++++ packages/core/src/erc1155/index.ts | 6 +- ... => writeERC1155SetApprovalForAll.test.ts} | 6 +- ...ll.ts => writeERC1155SetApprovalForAll.ts} | 39 ++++----- ...r.test.ts => writeERC1155Transfer.test.ts} | 6 +- ...155Transfer.ts => writeERC1155Transfer.ts} | 37 ++++---- ...t.ts => writeERC1155TransferBatch.test.ts} | 10 +-- ...rBatch.ts => writeERC1155TransferBatch.ts} | 37 ++++---- packages/core/src/erc20/index.ts | 8 +- ...rove.test.ts => writeERC20Approve.test.ts} | 9 +- ...teERC20Approve.ts => writeERC20Approve.ts} | 39 ++++----- ...ermit.test.ts => writeERC20Permit.test.ts} | 8 +- ...lateERC20Permit.ts => writeERC20Permit.ts} | 39 ++++----- ...fer.test.ts => writeERC20Transfer.test.ts} | 9 +- ...ERC20Transfer.ts => writeERC20Transfer.ts} | 39 ++++----- ...test.ts => writeERC20TransferFrom.test.ts} | 9 +- ...nsferFrom.ts => writeERC20TransferFrom.ts} | 39 ++++----- packages/core/src/erc721/index.ts | 6 +- ...ove.test.ts => writeERC721Approve.test.ts} | 6 +- ...ERC721Approve.ts => writeERC721Approve.ts} | 37 ++++---- ...s => writeERC721SetApprovalForAll.test.ts} | 6 +- ...All.ts => writeERC721SetApprovalForAll.ts} | 37 ++++---- ...er.test.ts => writeERC721Transfer.test.ts} | 14 +--- ...C721Transfer.ts => writeERC721Transfer.ts} | 47 +++++------ packages/core/src/index.ts | 24 +++--- packages/core/src/weth/index.ts | 4 +- ...posit.test.ts => writeWETHDeposit.test.ts} | 9 +- ...lateWETHDeposit.ts => writeWETHDeposit.ts} | 37 ++++---- ...draw.test.ts => writeWETHWithdraw.test.ts} | 22 ++--- ...teWETHWithdraw.ts => writeWETHWithdraw.ts} | 37 ++++---- packages/core/tsup.config.ts | 2 + 34 files changed, 363 insertions(+), 449 deletions(-) rename packages/core/src/erc1155/walletActions/{simulateERC1155SetApprovalForAll.test.ts => writeERC1155SetApprovalForAll.test.ts} (88%) rename packages/core/src/erc1155/walletActions/{simulateERC1155SetApprovalForAll.ts => writeERC1155SetApprovalForAll.ts} (56%) rename packages/core/src/erc1155/walletActions/{simulateERC1155Transfer.test.ts => writeERC1155Transfer.test.ts} (90%) rename packages/core/src/erc1155/walletActions/{simulateERC1155Transfer.ts => writeERC1155Transfer.ts} (63%) rename packages/core/src/erc1155/walletActions/{simulateERC1155TransferBatch.test.ts => writeERC1155TransferBatch.test.ts} (87%) rename packages/core/src/erc1155/walletActions/{simulateERC1155TransferBatch.ts => writeERC1155TransferBatch.ts} (68%) rename packages/core/src/erc20/walletActions/{simulateERC20Approve.test.ts => writeERC20Approve.test.ts} (87%) rename packages/core/src/erc20/walletActions/{simulateERC20Approve.ts => writeERC20Approve.ts} (53%) rename packages/core/src/erc20/walletActions/{simulateERC20Permit.test.ts => writeERC20Permit.test.ts} (91%) rename packages/core/src/erc20/walletActions/{simulateERC20Permit.ts => writeERC20Permit.ts} (60%) rename packages/core/src/erc20/walletActions/{simulateERC20Transfer.test.ts => writeERC20Transfer.test.ts} (88%) rename packages/core/src/erc20/walletActions/{simulateERC20Transfer.ts => writeERC20Transfer.ts} (52%) rename packages/core/src/erc20/walletActions/{simulateERC20TransferFrom.test.ts => writeERC20TransferFrom.test.ts} (89%) rename packages/core/src/erc20/walletActions/{simulateERC20TransferFrom.ts => writeERC20TransferFrom.ts} (53%) rename packages/core/src/erc721/walletActions/{simulateERC721Approve.test.ts => writeERC721Approve.test.ts} (89%) rename packages/core/src/erc721/walletActions/{simulateERC721Approve.ts => writeERC721Approve.ts} (56%) rename packages/core/src/erc721/walletActions/{simulateERC721SetApprovalForAll.test.ts => writeERC721SetApprovalForAll.test.ts} (88%) rename packages/core/src/erc721/walletActions/{simulateERC721SetApprovalForAll.ts => writeERC721SetApprovalForAll.ts} (56%) rename packages/core/src/erc721/walletActions/{simulateERC721Transfer.test.ts => writeERC721Transfer.test.ts} (81%) rename packages/core/src/erc721/walletActions/{simulateERC721Transfer.ts => writeERC721Transfer.ts} (73%) rename packages/core/src/weth/walletActions/{simulateWETHDeposit.test.ts => writeWETHDeposit.test.ts} (86%) rename packages/core/src/weth/walletActions/{simulateWETHDeposit.ts => writeWETHDeposit.ts} (56%) rename packages/core/src/weth/walletActions/{simulateWETHWithdraw.test.ts => writeWETHWithdraw.test.ts} (74%) rename packages/core/src/weth/walletActions/{simulateWETHWithdraw.ts => writeWETHWithdraw.ts} (55%) diff --git a/README.md b/README.md index ef65f7d..0a18839 100644 --- a/README.md +++ b/README.md @@ -11,13 +11,13 @@ Application level typescript utilities for Ethereum. ## Features -- ✅ ~30x faster than `@uniswap/sdk-core` -- ✅ Abstactions for most commonly used token standards +- ✅ ~10x faster, ~3x smaller than `@uniswap/sdk-core` +- ✅ Abstactions for commonly used token standards - ✅ Supports `permit` - ✅ Extensible to build apps and libraries - ✅ Seamless extension to [Viem](https://github.com/wagmi-dev/viem) - ✅ TypeScript ready -- ✅ Test suite running against [forked](https://ethereum.org/en/glossary/#fork) Ethereum network +- ✅ Test suite running against local Ethereum network ## Example @@ -45,3 +45,9 @@ const vitalikBalance = await publicClient.getERC20Balance({ console.log(amountToNumber(vitalikBalance)) // 420.69 ``` + +## Installation + +```sh +npm i reverse-mirage +``` diff --git a/examples/next-interface/hooks/useTransfer.ts b/examples/next-interface/hooks/useTransfer.ts index 20b643b..a8e75f3 100644 --- a/examples/next-interface/hooks/useTransfer.ts +++ b/examples/next-interface/hooks/useTransfer.ts @@ -6,7 +6,7 @@ import { type ERC20Amount, getERC20BalanceOf, getQueryKey, - simulateERC20Transfer, + writeERC20Transfer, } from "reverse-mirage"; import { getAddress } from "viem"; import { type Address, useWalletClient } from "wagmi"; @@ -36,10 +36,9 @@ export const useTransfer = ( } & { toast: TxToast; }) => { - const { request } = await simulateERC20Transfer(client, { + const hash = await writeERC20Transfer(walletClient.data!, { args: { to, amount }, }); - const hash = await walletClient.data!.writeContract(request); toaster.txPending({ ...toast, hash }); diff --git a/packages/core/src/decorator/publicActions.ts b/packages/core/src/decorator/publicActions.ts index 9d278b4..8d36562 100644 --- a/packages/core/src/decorator/publicActions.ts +++ b/packages/core/src/decorator/publicActions.ts @@ -27,22 +27,7 @@ import type { GetERC20PermitNonceParameters } from "../erc20/publicActions/getER import type { GetERC20SymbolParameters } from "../erc20/publicActions/getERC20Symbol.js"; import type { GetERC20TotalSupplyParameters } from "../erc20/publicActions/getERC20TotalSupply.js"; import type { GetIsERC20PermitParameters } from "../erc20/publicActions/getIsERC20Permit.js"; -import { - type SimulateERC20ApproveParameters, - simulateERC20Approve, -} from "../erc20/walletActions/simulateERC20Approve.js"; -import { - type SimulateERC20PermitParameters, - simulateERC20Permit, -} from "../erc20/walletActions/simulateERC20Permit.js"; -import { - type SimulateERC20TransferParameters, - simulateERC20Transfer, -} from "../erc20/walletActions/simulateERC20Transfer.js"; -import { - type SimulateERC20TransferFromParameters, - simulateERC20TransferFrom, -} from "../erc20/walletActions/simulateERC20TransferFrom.js"; + import { type BaseERC721, getERC721, @@ -66,18 +51,6 @@ import type { GetERC721OwnerOfParameters } from "../erc721/publicActions/getERC7 import type { GetERC721SupportsInterfaceParameters } from "../erc721/publicActions/getERC721SupportsInterface.js"; import type { GetERC721SymbolParameters } from "../erc721/publicActions/getERC721Symbol.js"; import type { GetERC721TokenURIParameters } from "../erc721/publicActions/getERC721TokenURI.js"; -import { - type SimulateERC721ApproveParameters, - simulateERC721Approve, -} from "../erc721/walletActions/simulateERC721Approve.js"; -import { - type SimulateERC721SetApprovalForAllParameters, - simulateERC721SetApprovalForAll, -} from "../erc721/walletActions/simulateERC721SetApprovalForAll.js"; -import { - type SimulateERC721TransferParameters, - simulateERC721Transfer, -} from "../erc721/walletActions/simulateERC721Transfer.js"; import { type BaseERC1155, getERC1155, @@ -89,31 +62,11 @@ import type { GetERC1155Parameters } from "../erc1155/publicActions/getERC1155.j import type { GetERC1155BalanceOfParameters } from "../erc1155/publicActions/getERC1155BalanceOf.js"; import type { GetERC1155IsApprovedForAllParameters } from "../erc1155/publicActions/getERC1155IsApprovedForAll.js"; import type { GetERC1155URIParameters } from "../erc1155/publicActions/getERC1155URI.js"; -import { - type SimulateERC1155SetApprovalForAllParameters, - simulateERC1155SetApprovalForAll, -} from "../erc1155/walletActions/simulateERC1155SetApprovalForAll.js"; -import { - type SimulateERC1155TransferParameters, - simulateERC1155Transfer, -} from "../erc1155/walletActions/simulateERC1155Transfer.js"; -import { - type SimulateERC1155TransferBatchParameters, - simulateERC1155TransferBatch, -} from "../erc1155/walletActions/simulateERC1155TransferBatch.js"; import { type GetNativeBalanceParameters, + type NativeCurrency, getNativeBalance, -} from "../native/publicActions/getNativeBalance.js"; -import type { NativeCurrency } from "../native/types.js"; -import { - type SimulateWETHDepositParameters, - simulateWETHDeposit, -} from "../weth/walletActions/simulateWETHDeposit.js"; -import { - type SimulateWETHWithdrawParameters, - simulateWETHWithdraw, -} from "../weth/walletActions/simulateWETHWithdraw.js"; +} from "../native/index.js"; export const publicActionReverseMirage = < TChain extends Chain | undefined = Chain | undefined, @@ -178,35 +131,4 @@ export const publicActionReverseMirage = < getERC1155IsApprovedForAll: (args: GetERC1155IsApprovedForAllParameters) => getERC1155IsApprovedForAll(client, args), getERC1155URI: (args: GetERC1155URIParameters) => getERC1155URI(client, args), - - simulateWETHDeposit: (args: SimulateWETHDepositParameters) => - simulateWETHDeposit(client, args), - simulateWETHWithdraw: (args: SimulateWETHWithdrawParameters) => - simulateWETHWithdraw(client, args), - - simulateERC20Approve: (args: SimulateERC20ApproveParameters) => - simulateERC20Approve(client, args), - simulateERC20Permit: (args: SimulateERC20PermitParameters) => - simulateERC20Permit(client, args), - simulateERC20Transfer: (args: SimulateERC20TransferParameters) => - simulateERC20Transfer(client, args), - simulateERC20TransferFrom: (args: SimulateERC20TransferFromParameters) => - simulateERC20TransferFrom(client, args), - - simulateERC721Approve: (args: SimulateERC721ApproveParameters) => - simulateERC721Approve(client, args), - simulateERC721SetApprovalForAll: ( - args: SimulateERC721SetApprovalForAllParameters, - ) => simulateERC721SetApprovalForAll(client, args), - simulateERC721Transfer: (args: SimulateERC721TransferParameters) => - simulateERC721Transfer(client, args), - - simulateERC1155SetApprovalForAll: ( - args: SimulateERC1155SetApprovalForAllParameters, - ) => simulateERC1155SetApprovalForAll(client, args), - simulateERC1155Transfer: (args: SimulateERC1155TransferParameters) => - simulateERC1155Transfer(client, args), - simulateERC1155TransferBatch: ( - args: SimulateERC1155TransferBatchParameters, - ) => simulateERC1155TransferBatch(client, args), }); diff --git a/packages/core/src/decorator/walletActions.ts b/packages/core/src/decorator/walletActions.ts index dd9d06e..90d537a 100644 --- a/packages/core/src/decorator/walletActions.ts +++ b/packages/core/src/decorator/walletActions.ts @@ -3,6 +3,55 @@ import { type SignERC20PermitParameters, signERC20Permit, } from "../erc20/walletActions/signERC20Permit.js"; +import { + type WriteERC1155TransferParameters, + writeERC1155Transfer, +} from "../erc1155/walletActions/writeERC1155Transfer.js"; +import { + type WriteERC1155TransferBatchParameters, + writeERC1155TransferBatch, +} from "../erc1155/walletActions/writeERC1155TransferBatch.js"; +import { + type WriteWETHDepositParameters, + writeWETHDeposit, +} from "../weth/walletActions/writeWETHDeposit.js"; +import { + type WriteWETHWithdrawParameters, + writeWETHWithdraw, +} from "../weth/walletActions/writeWETHWithdraw.js"; + +import { + type WriteERC20ApproveParameters, + writeERC20Approve, +} from "../erc20/walletActions/writeERC20Approve.js"; +import { + type WriteERC20PermitParameters, + writeERC20Permit, +} from "../erc20/walletActions/writeERC20Permit.js"; +import { + type WriteERC20TransferParameters, + writeERC20Transfer, +} from "../erc20/walletActions/writeERC20Transfer.js"; +import { + type WriteERC20TransferFromParameters, + writeERC20TransferFrom, +} from "../erc20/walletActions/writeERC20TransferFrom.js"; +import { + type WriteERC721ApproveParameters, + writeERC721Approve, +} from "../erc721/walletActions/writeERC721Approve.js"; +import { + type WriteERC721SetApprovalForAllParameters, + writeERC721SetApprovalForAll, +} from "../erc721/walletActions/writeERC721SetApprovalForAll.js"; +import { + type WriteERC721TransferParameters, + writeERC721Transfer, +} from "../erc721/walletActions/writeERC721Transfer.js"; +import { + type WriteERC1155SetApprovalForAllParameters, + writeERC1155SetApprovalForAll, +} from "../erc1155/walletActions/writeERC1155SetApprovalForAll.js"; export const walletActionReverseMirage = < TChain extends Chain = Chain, @@ -12,4 +61,38 @@ export const walletActionReverseMirage = < ) => ({ signERC20Permit: (args: SignERC20PermitParameters) => signERC20Permit(client, args), + + writeWETHDeposit: (args: WriteWETHDepositParameters) => + writeWETHDeposit(client, args), + writeWETHWithdraw: (args: WriteWETHWithdrawParameters) => + writeWETHWithdraw(client, args), + + writeERC20Approve: (args: WriteERC20ApproveParameters) => + writeERC20Approve(client, args), + writeERC20Permit: (args: WriteERC20PermitParameters) => + writeERC20Permit(client, args), + writeERC20Transfer: (args: WriteERC20TransferParameters) => + writeERC20Transfer(client, args), + writeERC20TransferFrom: ( + args: WriteERC20TransferFromParameters, + ) => writeERC20TransferFrom(client, args), + + writeERC721Approve: (args: WriteERC721ApproveParameters) => + writeERC721Approve(client, args), + writeERC721SetApprovalForAll: ( + args: WriteERC721SetApprovalForAllParameters, + ) => writeERC721SetApprovalForAll(client, args), + writeERC721Transfer: ( + args: WriteERC721TransferParameters, + ) => writeERC721Transfer(client, args), + + writeERC1155SetApprovalForAll: ( + args: WriteERC1155SetApprovalForAllParameters, + ) => writeERC1155SetApprovalForAll(client, args), + writeERC1155Transfer: ( + args: WriteERC1155TransferParameters, + ) => writeERC1155Transfer(client, args), + writeERC1155TransferBatch: ( + args: WriteERC1155TransferBatchParameters, + ) => writeERC1155TransferBatch(client, args), }); diff --git a/packages/core/src/erc1155/index.ts b/packages/core/src/erc1155/index.ts index 8efebb8..131b4a8 100644 --- a/packages/core/src/erc1155/index.ts +++ b/packages/core/src/erc1155/index.ts @@ -13,6 +13,6 @@ export { getERC1155BalanceOf } from "./publicActions/getERC1155BalanceOf.js"; export { getERC1155IsApprovedForAll } from "./publicActions/getERC1155IsApprovedForAll.js"; export { getERC1155URI } from "./publicActions/getERC1155URI.js"; -export { simulateERC1155Transfer } from "./walletActions/simulateERC1155Transfer.js"; -export { simulateERC1155TransferBatch } from "./walletActions/simulateERC1155TransferBatch.js"; -export { simulateERC1155SetApprovalForAll } from "./walletActions/simulateERC1155SetApprovalForAll.js"; +export { writeERC1155Transfer } from "./walletActions/writeERC1155Transfer.js"; +export { writeERC1155TransferBatch } from "./walletActions/writeERC1155TransferBatch.js"; +export { writeERC1155SetApprovalForAll } from "./walletActions/writeERC1155SetApprovalForAll.js"; diff --git a/packages/core/src/erc1155/walletActions/simulateERC1155SetApprovalForAll.test.ts b/packages/core/src/erc1155/walletActions/writeERC1155SetApprovalForAll.test.ts similarity index 88% rename from packages/core/src/erc1155/walletActions/simulateERC1155SetApprovalForAll.test.ts rename to packages/core/src/erc1155/walletActions/writeERC1155SetApprovalForAll.test.ts index 528c23e..81c97fb 100644 --- a/packages/core/src/erc1155/walletActions/simulateERC1155SetApprovalForAll.test.ts +++ b/packages/core/src/erc1155/walletActions/writeERC1155SetApprovalForAll.test.ts @@ -9,7 +9,7 @@ import { erc1155ABI } from "../../generated.js"; import { getERC1155IsApprovedForAll } from "../publicActions/getERC1155IsApprovedForAll.js"; import type { ERC1155 } from "../types.js"; import { createERC1155 } from "../utils.js"; -import { simulateERC1155SetApprovalForAll } from "./simulateERC1155SetApprovalForAll.js"; +import { writeERC1155SetApprovalForAll } from "./writeERC1155SetApprovalForAll.js"; let id: Hex | undefined = undefined; @@ -49,15 +49,13 @@ beforeEach(async () => { }); test("set approval for all", async () => { - const { request } = await simulateERC1155SetApprovalForAll(publicClient, { + const hash = await writeERC1155SetApprovalForAll(walletClient, { args: { erc1155, spender: BOB, approved: true, }, - account: ALICE, }); - const hash = await walletClient.writeContract(request); await publicClient.waitForTransactionReceipt({ hash }); diff --git a/packages/core/src/erc1155/walletActions/simulateERC1155SetApprovalForAll.ts b/packages/core/src/erc1155/walletActions/writeERC1155SetApprovalForAll.ts similarity index 56% rename from packages/core/src/erc1155/walletActions/simulateERC1155SetApprovalForAll.ts rename to packages/core/src/erc1155/walletActions/writeERC1155SetApprovalForAll.ts index 433f5c4..425daf2 100644 --- a/packages/core/src/erc1155/walletActions/simulateERC1155SetApprovalForAll.ts +++ b/packages/core/src/erc1155/walletActions/writeERC1155SetApprovalForAll.ts @@ -1,12 +1,13 @@ import type { + Account, Address, Chain, Client, - SimulateContractParameters, - SimulateContractReturnType, Transport, + WriteContractParameters, + WriteContractReturnType, } from "viem"; -import { simulateContract } from "viem/contract"; +import { writeContract } from "viem/contract"; import { solmateErc1155ABI as solmateERC1155 } from "../../generated.js"; import type { BaseERC1155 } from "../types.js"; @@ -16,50 +17,42 @@ export type ERC1155SetApprovalForAllParameters = { approved: boolean; }; -export type SimulateERC1155SetApprovalForAllParameters< +export type WriteERC1155SetApprovalForAllParameters< TChain extends Chain | undefined = Chain, + TAccount extends Account | undefined = Account | undefined, TChainOverride extends Chain | undefined = Chain | undefined, > = Omit< - SimulateContractParameters< + WriteContractParameters< typeof solmateERC1155, "setApprovalForAll", TChain, + TAccount, TChainOverride >, "args" | "address" | "abi" | "functionName" > & { args: ERC1155SetApprovalForAllParameters }; -export type SimulateERC1155SetApprovalForAllReturnType< - TChain extends Chain | undefined, - TChainOverride extends Chain | undefined = undefined, -> = SimulateContractReturnType< - typeof solmateERC1155, - "setApprovalForAll", - TChain, - TChainOverride ->; - -export const simulateERC1155SetApprovalForAll = < +export const writeERC1155SetApprovalForAll = < TChain extends Chain | undefined, + TAccount extends Account | undefined, TChainOverride extends Chain | undefined, >( - client: Client, + client: Client, { args: { erc1155, spender, approved }, ...request - }: SimulateERC1155SetApprovalForAllParameters, -): Promise< - SimulateERC1155SetApprovalForAllReturnType -> => - simulateContract(client, { + }: WriteERC1155SetApprovalForAllParameters, +): Promise => + writeContract(client, { address: erc1155.address, abi: solmateERC1155, functionName: "setApprovalForAll", args: [spender, approved], ...request, - } as unknown as SimulateContractParameters< + } as unknown as WriteContractParameters< typeof solmateERC1155, "setApprovalForAll", TChain, + TAccount, TChainOverride >); diff --git a/packages/core/src/erc1155/walletActions/simulateERC1155Transfer.test.ts b/packages/core/src/erc1155/walletActions/writeERC1155Transfer.test.ts similarity index 90% rename from packages/core/src/erc1155/walletActions/simulateERC1155Transfer.test.ts rename to packages/core/src/erc1155/walletActions/writeERC1155Transfer.test.ts index 8031a8f..d9dab18 100644 --- a/packages/core/src/erc1155/walletActions/simulateERC1155Transfer.test.ts +++ b/packages/core/src/erc1155/walletActions/writeERC1155Transfer.test.ts @@ -9,7 +9,7 @@ import { erc1155ABI } from "../../generated.js"; import { getERC1155BalanceOf } from "../publicActions/getERC1155BalanceOf.js"; import type { ERC1155 } from "../types.js"; import { createERC1155, createERC1155Data } from "../utils.js"; -import { simulateERC1155Transfer } from "./simulateERC1155Transfer.js"; +import { writeERC1155Transfer } from "./writeERC1155Transfer.js"; let id: Hex | undefined = undefined; @@ -49,11 +49,9 @@ beforeEach(async () => { }); test("can transfer", async () => { - const { request } = await simulateERC1155Transfer(publicClient, { + const hash = await writeERC1155Transfer(walletClient, { args: { to: BOB, erc1155Data: createERC1155Data(erc1155, 5n) }, - account: ALICE, }); - const hash = await walletClient.writeContract(request); await publicClient.waitForTransactionReceipt({ hash }); const balanceALICE = await getERC1155BalanceOf(publicClient, { diff --git a/packages/core/src/erc1155/walletActions/simulateERC1155Transfer.ts b/packages/core/src/erc1155/walletActions/writeERC1155Transfer.ts similarity index 63% rename from packages/core/src/erc1155/walletActions/simulateERC1155Transfer.ts rename to packages/core/src/erc1155/walletActions/writeERC1155Transfer.ts index dfa6262..a3b12cd 100644 --- a/packages/core/src/erc1155/walletActions/simulateERC1155Transfer.ts +++ b/packages/core/src/erc1155/walletActions/writeERC1155Transfer.ts @@ -1,13 +1,14 @@ import type { + Account, Address, Chain, Client, Hex, - SimulateContractParameters, - SimulateContractReturnType, Transport, + WriteContractParameters, + WriteContractReturnType, } from "viem"; -import { simulateContract } from "viem/contract"; +import { writeContract } from "viem/contract"; import { solmateErc1155ABI as solmateERC1155 } from "../../generated.js"; import type { BaseERC1155, ERC1155Data } from "../types.js"; @@ -18,40 +19,33 @@ export type ERC1155TransferParameters = { data?: Hex; }; -export type SimulateERC1155TransferParameters< +export type WriteERC1155TransferParameters< TChain extends Chain | undefined = Chain, + TAccount extends Account | undefined = Account | undefined, TChainOverride extends Chain | undefined = Chain | undefined, > = Omit< - SimulateContractParameters< + WriteContractParameters< typeof solmateERC1155, "safeTransferFrom", TChain, + TAccount, TChainOverride >, "args" | "address" | "abi" | "functionName" > & { args: ERC1155TransferParameters }; -export type SimulateERC1155TransferReturnType< - TChain extends Chain | undefined, - TChainOverride extends Chain | undefined = undefined, -> = SimulateContractReturnType< - typeof solmateERC1155, - "safeTransferFrom", - TChain, - TChainOverride ->; - -export const simulateERC1155Transfer = < +export const writeERC1155Transfer = < TChain extends Chain | undefined, + TAccount extends Account | undefined, TChainOverride extends Chain | undefined, >( - client: Client, + client: Client, { args: { erc1155Data, to, from, data }, ...request - }: SimulateERC1155TransferParameters, -): Promise> => - simulateContract(client, { + }: WriteERC1155TransferParameters, +): Promise => + writeContract(client, { address: erc1155Data.token.address, abi: solmateERC1155, functionName: "safeTransferFrom", @@ -67,9 +61,10 @@ export const simulateERC1155Transfer = < data ?? "0x", ], ...request, - } as unknown as SimulateContractParameters< + } as unknown as WriteContractParameters< typeof solmateERC1155, "safeTransferFrom", TChain, + TAccount, TChainOverride >); diff --git a/packages/core/src/erc1155/walletActions/simulateERC1155TransferBatch.test.ts b/packages/core/src/erc1155/walletActions/writeERC1155TransferBatch.test.ts similarity index 87% rename from packages/core/src/erc1155/walletActions/simulateERC1155TransferBatch.test.ts rename to packages/core/src/erc1155/walletActions/writeERC1155TransferBatch.test.ts index dfb942a..d60ea9a 100644 --- a/packages/core/src/erc1155/walletActions/simulateERC1155TransferBatch.test.ts +++ b/packages/core/src/erc1155/walletActions/writeERC1155TransferBatch.test.ts @@ -9,7 +9,7 @@ import { erc1155ABI } from "../../generated.js"; import { getERC1155BalanceOf } from "../publicActions/getERC1155BalanceOf.js"; import type { ERC1155 } from "../types.js"; import { createERC1155, createERC1155Data } from "../utils.js"; -import { simulateERC1155TransferBatch } from "./simulateERC1155TransferBatch.js"; +import { writeERC1155TransferBatch } from "./writeERC1155TransferBatch.js"; let id: Hex | undefined = undefined; @@ -51,7 +51,7 @@ beforeEach(async () => { test("can transfer batch", async () => { await expect( async () => - await simulateERC1155TransferBatch(publicClient, { + await writeERC1155TransferBatch(publicClient, { args: { to: BOB, erc1155Data: [] }, account: ALICE, }), @@ -59,7 +59,7 @@ test("can transfer batch", async () => { await expect( async () => - await simulateERC1155TransferBatch(publicClient, { + await writeERC1155TransferBatch(publicClient, { account: ALICE, args: { to: BOB, @@ -71,8 +71,7 @@ test("can transfer batch", async () => { }), ).rejects.toThrowError(); - const { request } = await simulateERC1155TransferBatch(publicClient, { - account: ALICE, + const hash = await writeERC1155TransferBatch(walletClient, { args: { to: BOB, erc1155Data: [ @@ -81,7 +80,6 @@ test("can transfer batch", async () => { ], }, }); - const hash = await walletClient.writeContract(request); await publicClient.waitForTransactionReceipt({ hash }); const balanceBOB = await getERC1155BalanceOf(publicClient, { diff --git a/packages/core/src/erc1155/walletActions/simulateERC1155TransferBatch.ts b/packages/core/src/erc1155/walletActions/writeERC1155TransferBatch.ts similarity index 68% rename from packages/core/src/erc1155/walletActions/simulateERC1155TransferBatch.ts rename to packages/core/src/erc1155/walletActions/writeERC1155TransferBatch.ts index 557f514..d7d1dd4 100644 --- a/packages/core/src/erc1155/walletActions/simulateERC1155TransferBatch.ts +++ b/packages/core/src/erc1155/walletActions/writeERC1155TransferBatch.ts @@ -1,14 +1,15 @@ import { + type Account, type Address, type Chain, type Client, type Hex, - type SimulateContractParameters, - type SimulateContractReturnType, type Transport, + type WriteContractParameters, + type WriteContractReturnType, getAddress, } from "viem"; -import { simulateContract } from "viem/contract"; +import { writeContract } from "viem/contract"; import { solmateErc1155ABI as solmateERC1155 } from "../../generated.js"; import type { BaseERC1155, ERC1155Data } from "../types.js"; @@ -19,39 +20,32 @@ export type ERC1155TransferBatchParameters = { data?: Hex; }; -export type SimulateERC1155TransferBatchParameters< +export type WriteERC1155TransferBatchParameters< TChain extends Chain | undefined = Chain, + TAccount extends Account | undefined = Account | undefined, TChainOverride extends Chain | undefined = Chain | undefined, > = Omit< - SimulateContractParameters< + WriteContractParameters< typeof solmateERC1155, "safeBatchTransferFrom", TChain, + TAccount, TChainOverride >, "args" | "address" | "abi" | "functionName" > & { args: ERC1155TransferBatchParameters }; -export type SimulateERC1155TransferBatchReturnType< - TChain extends Chain | undefined, - TChainOverride extends Chain | undefined = undefined, -> = SimulateContractReturnType< - typeof solmateERC1155, - "safeBatchTransferFrom", - TChain, - TChainOverride ->; - -export const simulateERC1155TransferBatch = < +export const writeERC1155TransferBatch = < TChain extends Chain | undefined, + TAccount extends Account | undefined, TChainOverride extends Chain | undefined, >( - client: Client, + client: Client, { args: { erc1155Data, to, from, data }, ...request - }: SimulateERC1155TransferBatchParameters, -): Promise> => { + }: WriteERC1155TransferBatchParameters, +): Promise => { const address = erc1155Data.reduce((addr: Address | undefined, cur) => { if (addr === undefined) return getAddress(cur.token.address); else if (addr !== getAddress(cur.token.address)) @@ -61,7 +55,7 @@ export const simulateERC1155TransferBatch = < if (address === undefined) throw Error("No tokens passed to transfer"); - return simulateContract(client, { + return writeContract(client, { address, abi: solmateERC1155, functionName: "safeBatchTransferFrom", @@ -77,10 +71,11 @@ export const simulateERC1155TransferBatch = < data ?? "0x", ], ...request, - } as unknown as SimulateContractParameters< + } as unknown as WriteContractParameters< typeof solmateERC1155, "safeBatchTransferFrom", TChain, + TAccount, TChainOverride >); }; diff --git a/packages/core/src/erc20/index.ts b/packages/core/src/erc20/index.ts index 5991eb8..9ed22fd 100644 --- a/packages/core/src/erc20/index.ts +++ b/packages/core/src/erc20/index.ts @@ -32,7 +32,7 @@ export { getERC20TotalSupply } from "./publicActions/getERC20TotalSupply.js"; export { getIsERC20Permit } from "./publicActions/getIsERC20Permit.js"; export { signERC20Permit } from "./walletActions/signERC20Permit.js"; -export { simulateERC20Approve } from "./walletActions/simulateERC20Approve.js"; -export { simulateERC20Permit } from "./walletActions/simulateERC20Permit.js"; -export { simulateERC20Transfer } from "./walletActions/simulateERC20Transfer.js"; -export { simulateERC20TransferFrom } from "./walletActions/simulateERC20TransferFrom.js"; +export { writeERC20Approve } from "./walletActions/writeERC20Approve.js"; +export { writeERC20Permit } from "./walletActions/writeERC20Permit.js"; +export { writeERC20Transfer } from "./walletActions/writeERC20Transfer.js"; +export { writeERC20TransferFrom } from "./walletActions/writeERC20TransferFrom.js"; diff --git a/packages/core/src/erc20/walletActions/simulateERC20Approve.test.ts b/packages/core/src/erc20/walletActions/writeERC20Approve.test.ts similarity index 87% rename from packages/core/src/erc20/walletActions/simulateERC20Approve.test.ts rename to packages/core/src/erc20/walletActions/writeERC20Approve.test.ts index 1e9161f..cd4a8d9 100644 --- a/packages/core/src/erc20/walletActions/simulateERC20Approve.test.ts +++ b/packages/core/src/erc20/walletActions/writeERC20Approve.test.ts @@ -10,7 +10,7 @@ import { erc20PermitABI } from "../../generated.js"; import { getERC20Allowance } from "../publicActions/getERC20Allowance.js"; import type { ERC20 } from "../types.js"; import { createERC20 } from "../utils.js"; -import { simulateERC20Approve } from "./simulateERC20Approve.js"; +import { writeERC20Approve } from "./writeERC20Approve.js"; let id: Hex | undefined = undefined; @@ -36,14 +36,11 @@ beforeEach(async () => { id = await testClient.snapshot(); }); -test("simulate approve", async () => { - const { request } = await simulateERC20Approve(publicClient, { +test("Write approve", async () => { + const hash = await writeERC20Approve(walletClient, { args: { amount: createAmountFromString(erc20, "1"), spender: BOB }, - account: ALICE, }); - const hash = await walletClient.writeContract(request); - await publicClient.waitForTransactionReceipt({ hash }); const allowance = await getERC20Allowance(publicClient, { diff --git a/packages/core/src/erc20/walletActions/simulateERC20Approve.ts b/packages/core/src/erc20/walletActions/writeERC20Approve.ts similarity index 53% rename from packages/core/src/erc20/walletActions/simulateERC20Approve.ts rename to packages/core/src/erc20/walletActions/writeERC20Approve.ts index f493a68..fc9ac3e 100644 --- a/packages/core/src/erc20/walletActions/simulateERC20Approve.ts +++ b/packages/core/src/erc20/walletActions/writeERC20Approve.ts @@ -1,62 +1,57 @@ import type { + Account, Address, Chain, Client, - SimulateContractParameters, - SimulateContractReturnType, Transport, + WriteContractParameters, + WriteContractReturnType, } from "viem"; -import { simulateContract } from "viem/contract"; -import type { BaseERC20, ERC20Amount } from "../../erc20/types.js"; +import { writeContract } from "viem/contract"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; +import type { BaseERC20, ERC20Amount } from "../types.js"; export type ERC20ApproveParameters = { amount: ERC20Amount; spender: Address; }; -export type SimulateERC20ApproveParameters< +export type WriteERC20ApproveParameters< TChain extends Chain | undefined = Chain, + TAccount extends Account | undefined = Account | undefined, TChainOverride extends Chain | undefined = Chain | undefined, > = Omit< - SimulateContractParameters< + WriteContractParameters< typeof solmateERC20ABI, "approve", TChain, + TAccount, TChainOverride >, "args" | "address" | "abi" | "functionName" > & { args: ERC20ApproveParameters }; -export type SimulateERC20ApproveReturnType< - TChain extends Chain | undefined, - TChainOverride extends Chain | undefined = undefined, -> = SimulateContractReturnType< - typeof solmateERC20ABI, - "approve", - TChain, - TChainOverride ->; - -export const simulateERC20Approve = < +export const writeERC20Approve = < TChain extends Chain | undefined, + TAccount extends Account | undefined, TChainOverride extends Chain | undefined, >( - client: Client, + client: Client, { args: { amount, spender }, ...request - }: SimulateERC20ApproveParameters, -): Promise> => - simulateContract(client, { + }: WriteERC20ApproveParameters, +): Promise => + writeContract(client, { address: amount.token.address, abi: solmateERC20ABI, functionName: "approve", args: [spender, amount.amount], ...request, - } as unknown as SimulateContractParameters< + } as unknown as WriteContractParameters< typeof solmateERC20ABI, "approve", TChain, + TAccount, TChainOverride >); diff --git a/packages/core/src/erc20/walletActions/simulateERC20Permit.test.ts b/packages/core/src/erc20/walletActions/writeERC20Permit.test.ts similarity index 91% rename from packages/core/src/erc20/walletActions/simulateERC20Permit.test.ts rename to packages/core/src/erc20/walletActions/writeERC20Permit.test.ts index 5707f1a..e496e33 100644 --- a/packages/core/src/erc20/walletActions/simulateERC20Permit.test.ts +++ b/packages/core/src/erc20/walletActions/writeERC20Permit.test.ts @@ -13,7 +13,7 @@ import { createERC20PermitDataFromString, } from "../utils.js"; import { signERC20Permit } from "./signERC20Permit.js"; -import { simulateERC20Permit } from "./simulateERC20Permit.js"; +import { writeERC20Permit } from "./writeERC20Permit.js"; let id: Hex | undefined = undefined; @@ -54,14 +54,14 @@ beforeEach(async () => { id = await testClient.snapshot(); }); -test("simulate permit", async () => { +test("write permit", async () => { const signature = await signERC20Permit(walletClient, { permitData: createERC20PermitDataFromString(erc20, "1", 0n), spender: BOB, deadline: 2n ** 256n - 1n, }); - const { request } = await simulateERC20Permit(publicClient, { + const hash = await writeERC20Permit(walletClient, { args: { permitData: createERC20PermitDataFromString(erc20, "1", 0n), owner: ALICE, @@ -71,8 +71,6 @@ test("simulate permit", async () => { }, }); - const hash = await walletClient.writeContract(request); - await publicClient.waitForTransactionReceipt({ hash }); const allowance = await getERC20Allowance(publicClient, { diff --git a/packages/core/src/erc20/walletActions/simulateERC20Permit.ts b/packages/core/src/erc20/walletActions/writeERC20Permit.ts similarity index 60% rename from packages/core/src/erc20/walletActions/simulateERC20Permit.ts rename to packages/core/src/erc20/walletActions/writeERC20Permit.ts index 4be48f0..b746cb3 100644 --- a/packages/core/src/erc20/walletActions/simulateERC20Permit.ts +++ b/packages/core/src/erc20/walletActions/writeERC20Permit.ts @@ -1,15 +1,16 @@ import type { + Account, Address, Chain, Client, Hex, - SimulateContractParameters, - SimulateContractReturnType, Transport, + WriteContractParameters, + WriteContractReturnType, } from "viem"; -import { simulateContract } from "viem/contract"; -import type { ERC20Permit, ERC20PermitData } from "../../erc20/types.js"; +import { writeContract } from "viem/contract"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; +import type { ERC20Permit, ERC20PermitData } from "../types.js"; export type ERC20PermitParameters = { signature: Hex; @@ -19,53 +20,47 @@ export type ERC20PermitParameters = { deadline: bigint; }; -export type SimulateERC20PermitParameters< +export type WriteERC20PermitParameters< TChain extends Chain | undefined = Chain, + TAccount extends Account | undefined = Account | undefined, TChainOverride extends Chain | undefined = Chain | undefined, > = Omit< - SimulateContractParameters< + WriteContractParameters< typeof solmateERC20ABI, "permit", TChain, + TAccount, TChainOverride >, "args" | "address" | "abi" | "functionName" > & { args: ERC20PermitParameters }; -export type SimulateERC20PermitReturnType< - TChain extends Chain | undefined, - TChainOverride extends Chain | undefined = undefined, -> = SimulateContractReturnType< - typeof solmateERC20ABI, - "permit", - TChain, - TChainOverride ->; - -export const simulateERC20Permit = < +export const writeERC20Permit = < TChain extends Chain | undefined, + TAccount extends Account | undefined, TChainOverride extends Chain | undefined, >( - client: Client, + client: Client, { args: { owner, spender, signature, permitData, deadline }, ...request - }: SimulateERC20PermitParameters, -): Promise> => { + }: WriteERC20PermitParameters, +): Promise => { const r = `0x${signature.substring(2, 2 + 64)}` as const; const s = `0x${signature.substring(2 + 64, 2 + 64 + 64)}` as const; const v = Number(`0x${signature.substring(2 + 64 + 64)}`); - return simulateContract(client, { + return writeContract(client, { address: permitData.token.address, abi: solmateERC20ABI, functionName: "permit", args: [owner, spender, permitData.amount, deadline, v, r, s], ...request, - } as unknown as SimulateContractParameters< + } as unknown as WriteContractParameters< typeof solmateERC20ABI, "permit", TChain, + TAccount, TChainOverride >); }; diff --git a/packages/core/src/erc20/walletActions/simulateERC20Transfer.test.ts b/packages/core/src/erc20/walletActions/writeERC20Transfer.test.ts similarity index 88% rename from packages/core/src/erc20/walletActions/simulateERC20Transfer.test.ts rename to packages/core/src/erc20/walletActions/writeERC20Transfer.test.ts index 57f268e..691eb6e 100644 --- a/packages/core/src/erc20/walletActions/simulateERC20Transfer.test.ts +++ b/packages/core/src/erc20/walletActions/writeERC20Transfer.test.ts @@ -10,7 +10,7 @@ import { erc20PermitABI } from "../../generated.js"; import { getERC20BalanceOf } from "../publicActions/getERC20BalanceOf.js"; import type { ERC20 } from "../types.js"; import { createERC20 } from "../utils.js"; -import { simulateERC20Transfer } from "./simulateERC20Transfer.js"; +import { writeERC20Transfer } from "./writeERC20Transfer.js"; let id: Hex | undefined = undefined; @@ -44,14 +44,11 @@ beforeEach(async () => { id = await testClient.snapshot(); }); -test("simulate transfer", async () => { - const { request } = await simulateERC20Transfer(publicClient, { +test("write transfer", async () => { + const hash = await writeERC20Transfer(walletClient, { args: { amount: createAmountFromString(erc20, "1"), to: BOB }, - account: ALICE, }); - const hash = await walletClient.writeContract(request); - await publicClient.waitForTransactionReceipt({ hash }); const balance = await getERC20BalanceOf(publicClient, { diff --git a/packages/core/src/erc20/walletActions/simulateERC20Transfer.ts b/packages/core/src/erc20/walletActions/writeERC20Transfer.ts similarity index 52% rename from packages/core/src/erc20/walletActions/simulateERC20Transfer.ts rename to packages/core/src/erc20/walletActions/writeERC20Transfer.ts index 8326e25..2b82691 100644 --- a/packages/core/src/erc20/walletActions/simulateERC20Transfer.ts +++ b/packages/core/src/erc20/walletActions/writeERC20Transfer.ts @@ -1,62 +1,57 @@ import type { + Account, Address, Chain, Client, - SimulateContractParameters, - SimulateContractReturnType, Transport, + WriteContractParameters, + WriteContractReturnType, } from "viem"; -import { simulateContract } from "viem/contract"; -import type { BaseERC20, ERC20Amount } from "../../erc20/types.js"; +import { writeContract } from "viem/contract"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; +import type { BaseERC20, ERC20Amount } from "../types.js"; export type ERC20TransferParameters = { amount: ERC20Amount; to: Address; }; -export type SimulateERC20TransferParameters< +export type WriteERC20TransferParameters< TChain extends Chain | undefined = Chain, + TAccount extends Account | undefined = Account | undefined, TChainOverride extends Chain | undefined = Chain | undefined, > = Omit< - SimulateContractParameters< + WriteContractParameters< typeof solmateERC20ABI, "transfer", TChain, + TAccount, TChainOverride >, "args" | "address" | "abi" | "functionName" > & { args: ERC20TransferParameters }; -export type SimulateERC20TransferReturnType< - TChain extends Chain | undefined, - TChainOverride extends Chain | undefined = undefined, -> = SimulateContractReturnType< - typeof solmateERC20ABI, - "transfer", - TChain, - TChainOverride ->; - -export const simulateERC20Transfer = < +export const writeERC20Transfer = < TChain extends Chain | undefined, + TAccount extends Account | undefined, TChainOverride extends Chain | undefined, >( - client: Client, + client: Client, { args: { amount, to }, ...request - }: SimulateERC20TransferParameters, -): Promise> => - simulateContract(client, { + }: WriteERC20TransferParameters, +): Promise => + writeContract(client, { address: amount.token.address, abi: solmateERC20ABI, functionName: "transfer", args: [to, amount.amount], ...request, - } as unknown as SimulateContractParameters< + } as unknown as WriteContractParameters< typeof solmateERC20ABI, "transfer", TChain, + TAccount, TChainOverride >); diff --git a/packages/core/src/erc20/walletActions/simulateERC20TransferFrom.test.ts b/packages/core/src/erc20/walletActions/writeERC20TransferFrom.test.ts similarity index 89% rename from packages/core/src/erc20/walletActions/simulateERC20TransferFrom.test.ts rename to packages/core/src/erc20/walletActions/writeERC20TransferFrom.test.ts index 0e46f55..d3d8ab7 100644 --- a/packages/core/src/erc20/walletActions/simulateERC20TransferFrom.test.ts +++ b/packages/core/src/erc20/walletActions/writeERC20TransferFrom.test.ts @@ -10,7 +10,7 @@ import { erc20PermitABI } from "../../generated.js"; import { getERC20BalanceOf } from "../publicActions/getERC20BalanceOf.js"; import type { ERC20 } from "../types.js"; import { createERC20 } from "../utils.js"; -import { simulateERC20TransferFrom } from "./simulateERC20TransferFrom.js"; +import { writeERC20TransferFrom } from "./writeERC20TransferFrom.js"; let id: Hex | undefined = undefined; @@ -52,14 +52,11 @@ beforeEach(async () => { id = await testClient.snapshot(); }); -test("simulate transfer from", async () => { - const { request } = await simulateERC20TransferFrom(publicClient, { +test("write transfer from", async () => { + const hash = await writeERC20TransferFrom(walletClient, { args: { amount: createAmountFromString(erc20, "1"), from: ALICE, to: BOB }, - account: ALICE, }); - const hash = await walletClient.writeContract(request); - await publicClient.waitForTransactionReceipt({ hash }); const balance = await getERC20BalanceOf(publicClient, { diff --git a/packages/core/src/erc20/walletActions/simulateERC20TransferFrom.ts b/packages/core/src/erc20/walletActions/writeERC20TransferFrom.ts similarity index 53% rename from packages/core/src/erc20/walletActions/simulateERC20TransferFrom.ts rename to packages/core/src/erc20/walletActions/writeERC20TransferFrom.ts index a5a79c3..6bd4008 100644 --- a/packages/core/src/erc20/walletActions/simulateERC20TransferFrom.ts +++ b/packages/core/src/erc20/walletActions/writeERC20TransferFrom.ts @@ -1,14 +1,15 @@ import type { + Account, Address, Chain, Client, - SimulateContractParameters, - SimulateContractReturnType, Transport, + WriteContractParameters, + WriteContractReturnType, } from "viem"; -import { simulateContract } from "viem/contract"; -import type { BaseERC20, ERC20Amount } from "../../erc20/types.js"; +import { writeContract } from "viem/contract"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; +import type { BaseERC20, ERC20Amount } from "../types.js"; export type ERC20TransferFromParameters = { amount: ERC20Amount; @@ -16,48 +17,42 @@ export type ERC20TransferFromParameters = { to: Address; }; -export type SimulateERC20TransferFromParameters< +export type WriteERC20TransferFromParameters< TChain extends Chain | undefined = Chain, + TAccount extends Account | undefined = Account | undefined, TChainOverride extends Chain | undefined = Chain | undefined, > = Omit< - SimulateContractParameters< + WriteContractParameters< typeof solmateERC20ABI, "transferFrom", TChain, + TAccount, TChainOverride >, "args" | "address" | "abi" | "functionName" > & { args: ERC20TransferFromParameters }; -export type SimulateERC20TransferFromReturnType< - TChain extends Chain | undefined, - TChainOverride extends Chain | undefined = undefined, -> = SimulateContractReturnType< - typeof solmateERC20ABI, - "transferFrom", - TChain, - TChainOverride ->; - -export const simulateERC20TransferFrom = < +export const writeERC20TransferFrom = < TChain extends Chain | undefined, + TAccount extends Account | undefined, TChainOverride extends Chain | undefined, >( - client: Client, + client: Client, { args: { amount, from, to }, ...request - }: SimulateERC20TransferFromParameters, -): Promise> => - simulateContract(client, { + }: WriteERC20TransferFromParameters, +): Promise => + writeContract(client, { address: amount.token.address, abi: solmateERC20ABI, functionName: "transferFrom", args: [from, to, amount.amount], ...request, - } as unknown as SimulateContractParameters< + } as unknown as WriteContractParameters< typeof solmateERC20ABI, "transferFrom", TChain, + TAccount, TChainOverride >); diff --git a/packages/core/src/erc721/index.ts b/packages/core/src/erc721/index.ts index 8211afb..707c7bf 100644 --- a/packages/core/src/erc721/index.ts +++ b/packages/core/src/erc721/index.ts @@ -19,6 +19,6 @@ export { getERC721OwnerOf } from "./publicActions/getERC721OwnerOf.js"; export { getERC721SupportsInterface } from "./publicActions/getERC721SupportsInterface.js"; export { getERC721TokenURI } from "./publicActions/getERC721TokenURI.js"; -export { simulateERC721Transfer } from "./walletActions/simulateERC721Transfer.js"; -export { simulateERC721Approve } from "./walletActions/simulateERC721Approve.js"; -export { simulateERC721SetApprovalForAll } from "./walletActions/simulateERC721SetApprovalForAll.js"; +export { writeERC721Transfer } from "./walletActions/writeERC721Transfer.js"; +export { writeERC721Approve } from "./walletActions/writeERC721Approve.js"; +export { writeERC721SetApprovalForAll } from "./walletActions/writeERC721SetApprovalForAll.js"; diff --git a/packages/core/src/erc721/walletActions/simulateERC721Approve.test.ts b/packages/core/src/erc721/walletActions/writeERC721Approve.test.ts similarity index 89% rename from packages/core/src/erc721/walletActions/simulateERC721Approve.test.ts rename to packages/core/src/erc721/walletActions/writeERC721Approve.test.ts index 94522d9..63cb8cf 100644 --- a/packages/core/src/erc721/walletActions/simulateERC721Approve.test.ts +++ b/packages/core/src/erc721/walletActions/writeERC721Approve.test.ts @@ -9,7 +9,7 @@ import { erc721ABI } from "../../generated.js"; import { getERC721Approved } from "../publicActions/getERC721Approved.js"; import type { ERC721 } from "../types.js"; import { createERC721 } from "../utils.js"; -import { simulateERC721Approve } from "./simulateERC721Approve.js"; +import { writeERC721Approve } from "./writeERC721Approve.js"; let id: Hex | undefined = undefined; @@ -44,15 +44,13 @@ beforeEach(async () => { }); test("approve", async () => { - const { request } = await simulateERC721Approve(publicClient, { + const hash = await writeERC721Approve(walletClient, { args: { erc721, id: 0n, spender: BOB, }, - account: ALICE, }); - const hash = await walletClient.writeContract(request); await publicClient.waitForTransactionReceipt({ hash }); diff --git a/packages/core/src/erc721/walletActions/simulateERC721Approve.ts b/packages/core/src/erc721/walletActions/writeERC721Approve.ts similarity index 56% rename from packages/core/src/erc721/walletActions/simulateERC721Approve.ts rename to packages/core/src/erc721/walletActions/writeERC721Approve.ts index 9fde2ff..0eaf575 100644 --- a/packages/core/src/erc721/walletActions/simulateERC721Approve.ts +++ b/packages/core/src/erc721/walletActions/writeERC721Approve.ts @@ -1,12 +1,13 @@ import type { + Account, Address, Chain, Client, - SimulateContractParameters, - SimulateContractReturnType, Transport, + WriteContractParameters, + WriteContractReturnType, } from "viem"; -import { simulateContract } from "viem/contract"; +import { writeContract } from "viem/contract"; import { solmateErc721ABI as solmateERC721 } from "../../generated.js"; import type { BaseERC721 } from "../types.js"; @@ -16,48 +17,42 @@ export type ERC721ApproveParameters = { spender: Address; }; -export type SimulateERC721ApproveParameters< +export type WriteERC721ApproveParameters< TChain extends Chain | undefined = Chain, + TAccount extends Account | undefined = Account | undefined, TChainOverride extends Chain | undefined = Chain | undefined, > = Omit< - SimulateContractParameters< + WriteContractParameters< typeof solmateERC721, "approve", TChain, + TAccount, TChainOverride >, "args" | "address" | "abi" | "functionName" > & { args: ERC721ApproveParameters }; -export type SimulateERC721ApproveReturnType< - TChain extends Chain | undefined, - TChainOverride extends Chain | undefined = undefined, -> = SimulateContractReturnType< - typeof solmateERC721, - "approve", - TChain, - TChainOverride ->; - -export const simulateERC721Approve = < +export const writeERC721Approve = < TChain extends Chain | undefined, + TAccount extends Account | undefined, TChainOverride extends Chain | undefined, >( - client: Client, + client: Client, { args: { erc721, spender, id }, ...request - }: SimulateERC721ApproveParameters, -): Promise> => - simulateContract(client, { + }: WriteERC721ApproveParameters, +): Promise => + writeContract(client, { address: erc721.address, abi: solmateERC721, functionName: "approve", args: [spender, id], ...request, - } as unknown as SimulateContractParameters< + } as unknown as WriteContractParameters< typeof solmateERC721, "approve", TChain, + TAccount, TChainOverride >); diff --git a/packages/core/src/erc721/walletActions/simulateERC721SetApprovalForAll.test.ts b/packages/core/src/erc721/walletActions/writeERC721SetApprovalForAll.test.ts similarity index 88% rename from packages/core/src/erc721/walletActions/simulateERC721SetApprovalForAll.test.ts rename to packages/core/src/erc721/walletActions/writeERC721SetApprovalForAll.test.ts index 1ffa542..12462e5 100644 --- a/packages/core/src/erc721/walletActions/simulateERC721SetApprovalForAll.test.ts +++ b/packages/core/src/erc721/walletActions/writeERC721SetApprovalForAll.test.ts @@ -9,7 +9,7 @@ import { erc721ABI } from "../../generated.js"; import { getERC721IsApprovedForAll } from "../publicActions/getERC721IsApprovedForAll.js"; import type { ERC721 } from "../types.js"; import { createERC721 } from "../utils.js"; -import { simulateERC721SetApprovalForAll } from "./simulateERC721SetApprovalForAll.js"; +import { writeERC721SetApprovalForAll } from "./writeERC721SetApprovalForAll.js"; let id: Hex | undefined = undefined; @@ -44,15 +44,13 @@ beforeEach(async () => { }); test("set approval for all", async () => { - const { request } = await simulateERC721SetApprovalForAll(publicClient, { + const hash = await writeERC721SetApprovalForAll(walletClient, { args: { erc721, spender: BOB, approved: true, }, - account: ALICE, }); - const hash = await walletClient.writeContract(request); await publicClient.waitForTransactionReceipt({ hash }); diff --git a/packages/core/src/erc721/walletActions/simulateERC721SetApprovalForAll.ts b/packages/core/src/erc721/walletActions/writeERC721SetApprovalForAll.ts similarity index 56% rename from packages/core/src/erc721/walletActions/simulateERC721SetApprovalForAll.ts rename to packages/core/src/erc721/walletActions/writeERC721SetApprovalForAll.ts index 065da18..d3e94ac 100644 --- a/packages/core/src/erc721/walletActions/simulateERC721SetApprovalForAll.ts +++ b/packages/core/src/erc721/walletActions/writeERC721SetApprovalForAll.ts @@ -1,12 +1,13 @@ import type { + Account, Address, Chain, Client, - SimulateContractParameters, - SimulateContractReturnType, Transport, + WriteContractParameters, + WriteContractReturnType, } from "viem"; -import { simulateContract } from "viem/contract"; +import { writeContract } from "viem/contract"; import { solmateErc721ABI as solmateERC721 } from "../../generated.js"; import type { BaseERC721 } from "../types.js"; @@ -16,48 +17,42 @@ export type ERC721SetApprovalForAllParameters = { approved: boolean; }; -export type SimulateERC721SetApprovalForAllParameters< +export type WriteERC721SetApprovalForAllParameters< TChain extends Chain | undefined = Chain, + TAccount extends Account | undefined = Account | undefined, TChainOverride extends Chain | undefined = Chain | undefined, > = Omit< - SimulateContractParameters< + WriteContractParameters< typeof solmateERC721, "setApprovalForAll", TChain, + TAccount, TChainOverride >, "args" | "address" | "abi" | "functionName" > & { args: ERC721SetApprovalForAllParameters }; -export type SimulateERC721SetApprovalForAllReturnType< - TChain extends Chain | undefined, - TChainOverride extends Chain | undefined = undefined, -> = SimulateContractReturnType< - typeof solmateERC721, - "setApprovalForAll", - TChain, - TChainOverride ->; - -export const simulateERC721SetApprovalForAll = < +export const writeERC721SetApprovalForAll = < TChain extends Chain | undefined, + TAccount extends Account | undefined, TChainOverride extends Chain | undefined, >( - client: Client, + client: Client, { args: { erc721, spender, approved }, ...request - }: SimulateERC721SetApprovalForAllParameters, -): Promise> => - simulateContract(client, { + }: WriteERC721SetApprovalForAllParameters, +): Promise => + writeContract(client, { address: erc721.address, abi: solmateERC721, functionName: "setApprovalForAll", args: [spender, approved], ...request, - } as unknown as SimulateContractParameters< + } as unknown as WriteContractParameters< typeof solmateERC721, "setApprovalForAll", TChain, + TAccount, TChainOverride >); diff --git a/packages/core/src/erc721/walletActions/simulateERC721Transfer.test.ts b/packages/core/src/erc721/walletActions/writeERC721Transfer.test.ts similarity index 81% rename from packages/core/src/erc721/walletActions/simulateERC721Transfer.test.ts rename to packages/core/src/erc721/walletActions/writeERC721Transfer.test.ts index 87fe322..ba3e76e 100644 --- a/packages/core/src/erc721/walletActions/simulateERC721Transfer.test.ts +++ b/packages/core/src/erc721/walletActions/writeERC721Transfer.test.ts @@ -9,7 +9,7 @@ import { erc721ABI } from "../../generated.js"; import { getERC721OwnerOf } from "../publicActions/getERC721OwnerOf.js"; import type { ERC721 } from "../types.js"; import { createERC721 } from "../utils.js"; -import { simulateERC721Transfer } from "./simulateERC721Transfer.js"; +import { writeERC721Transfer } from "./writeERC721Transfer.js"; let id: Hex | undefined = undefined; @@ -44,47 +44,41 @@ beforeEach(async () => { }); test("can transfer", async () => { - const { request } = await simulateERC721Transfer(publicClient, { + const hash = await writeERC721Transfer(walletClient, { args: { to: BOB, erc721, id: 0n, }, - account: ALICE, }); - const hash = await walletClient.writeContract(request); await publicClient.waitForTransactionReceipt({ hash }); expect(await getERC721OwnerOf(publicClient, { erc721, id: 0n })).toBe(BOB); }); test("can transfer safe", async () => { - const { request } = await simulateERC721Transfer(publicClient, { + const hash = await writeERC721Transfer(walletClient, { args: { to: BOB, erc721, id: 0n, data: "safe", }, - account: ALICE, }); - const hash = await walletClient.writeContract(request); await publicClient.waitForTransactionReceipt({ hash }); expect(await getERC721OwnerOf(publicClient, { erc721, id: 0n })).toBe(BOB); }); test("can transfer data", async () => { - const { request } = await simulateERC721Transfer(publicClient, { + const hash = await writeERC721Transfer(walletClient, { args: { to: BOB, erc721, id: 0n, data: "0x", }, - account: ALICE, }); - const hash = await walletClient.writeContract(request); await publicClient.waitForTransactionReceipt({ hash }); 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/writeERC721Transfer.ts similarity index 73% rename from packages/core/src/erc721/walletActions/simulateERC721Transfer.ts rename to packages/core/src/erc721/walletActions/writeERC721Transfer.ts index 4198ffe..5a9b987 100644 --- a/packages/core/src/erc721/walletActions/simulateERC721Transfer.ts +++ b/packages/core/src/erc721/walletActions/writeERC721Transfer.ts @@ -1,13 +1,14 @@ import type { + Account, Address, Chain, Client, Hex, - SimulateContractParameters, - SimulateContractReturnType, Transport, + WriteContractParameters, + WriteContractReturnType, } from "viem"; -import { simulateContract } from "viem/contract"; +import { writeContract } from "viem/contract"; import { solmateErc721ABI as solmateERC721 } from "../../generated.js"; import type { BaseERC721 } from "../types.js"; @@ -19,41 +20,34 @@ export type ERC721TransferParameters = { data?: "safe" | Hex; }; -export type SimulateERC721TransferParameters< +export type WriteERC721TransferParameters< TChain extends Chain | undefined = Chain, + TAccount extends Account | undefined = Account | undefined, TChainOverride extends Chain | undefined = Chain | undefined, > = Omit< - SimulateContractParameters< + WriteContractParameters< typeof solmateERC721, "transferFrom", TChain, + TAccount, TChainOverride >, "args" | "address" | "abi" | "functionName" > & { args: ERC721TransferParameters }; -export type SimulateERC721TransferReturnType< - TChain extends Chain | undefined, - TChainOverride extends Chain | undefined = undefined, -> = SimulateContractReturnType< - typeof solmateERC721, - "transferFrom", - TChain, - TChainOverride ->; - -export const simulateERC721Transfer = < +export const writeERC721Transfer = < TChain extends Chain | undefined, + TAccount extends Account | undefined, TChainOverride extends Chain | undefined, >( - client: Client, + client: Client, { args: { erc721, from, to, data, id }, ...request - }: SimulateERC721TransferParameters, -) => + }: WriteERC721TransferParameters, +): Promise => data === undefined - ? simulateContract(client, { + ? writeContract(client, { address: erc721.address, abi: solmateERC721, functionName: "transferFrom", @@ -67,14 +61,15 @@ export const simulateERC721Transfer = < id, ], ...request, - } as unknown as SimulateContractParameters< + } as unknown as WriteContractParameters< typeof solmateERC721, "transferFrom", TChain, + TAccount, TChainOverride >) : data === "safe" - ? simulateContract(client, { + ? writeContract(client, { address: erc721.address, abi: solmateERC721, functionName: "safeTransferFrom", @@ -88,13 +83,14 @@ export const simulateERC721Transfer = < id, ], ...request, - } as unknown as SimulateContractParameters< + } as unknown as WriteContractParameters< typeof solmateERC721, "safeTransferFrom", TChain, + TAccount, TChainOverride >) - : simulateContract(client, { + : writeContract(client, { address: erc721.address, abi: solmateERC721, functionName: "safeTransferFrom", @@ -109,9 +105,10 @@ export const simulateERC721Transfer = < data, ], ...request, - } as unknown as SimulateContractParameters< + } as unknown as WriteContractParameters< typeof solmateERC721, "safeTransferFrom", TChain, + TAccount, TChainOverride >); diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index c95dfeb..b583b60 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -57,10 +57,10 @@ export { getERC20TotalSupply, getIsERC20Permit, signERC20Permit, - simulateERC20Approve, - simulateERC20Permit, - simulateERC20Transfer, - simulateERC20TransferFrom, + writeERC20Approve, + writeERC20Permit, + writeERC20Transfer, + writeERC20TransferFrom, } from "./erc20/index.js"; export { @@ -80,9 +80,9 @@ export { getERC721OwnerOf, getERC721SupportsInterface, getERC721TokenURI, - simulateERC721Transfer, - simulateERC721Approve, - simulateERC721SetApprovalForAll, + writeERC721Transfer, + writeERC721Approve, + writeERC721SetApprovalForAll, } from "./erc721/index.js"; export { @@ -96,9 +96,9 @@ export { getERC1155BalanceOf, getERC1155IsApprovedForAll, getERC1155URI, - simulateERC1155Transfer, - simulateERC1155TransferBatch, - simulateERC1155SetApprovalForAll, + writeERC1155Transfer, + writeERC1155TransferBatch, + writeERC1155SetApprovalForAll, } from "./erc1155/index.js"; export { @@ -161,8 +161,8 @@ export { type WETH, createWETH, weth9ABI, - simulateWETHDeposit, - simulateWETHWithdraw, + writeWETHDeposit, + writeWETHWithdraw, } from "./weth/index.js"; export { publicActionReverseMirage } from "./decorator/publicActions.js"; diff --git a/packages/core/src/weth/index.ts b/packages/core/src/weth/index.ts index 27e7cb5..93e402b 100644 --- a/packages/core/src/weth/index.ts +++ b/packages/core/src/weth/index.ts @@ -4,5 +4,5 @@ export { createWETH } from "./utils.js"; export { weth9ABI } from "../generated.js"; -export { simulateWETHDeposit } from "./walletActions/simulateWETHDeposit.js"; -export { simulateWETHWithdraw } from "./walletActions/simulateWETHWithdraw.js"; +export { writeWETHDeposit } from "./walletActions/writeWETHDeposit.js"; +export { writeWETHWithdraw } from "./walletActions/writeWETHWithdraw.js"; diff --git a/packages/core/src/weth/walletActions/simulateWETHDeposit.test.ts b/packages/core/src/weth/walletActions/writeWETHDeposit.test.ts similarity index 86% rename from packages/core/src/weth/walletActions/simulateWETHDeposit.test.ts rename to packages/core/src/weth/walletActions/writeWETHDeposit.test.ts index 91d1320..cf92841 100644 --- a/packages/core/src/weth/walletActions/simulateWETHDeposit.test.ts +++ b/packages/core/src/weth/walletActions/writeWETHDeposit.test.ts @@ -10,7 +10,7 @@ import { getERC20BalanceOf } from "../../erc20/publicActions/getERC20BalanceOf.j import { weth9ABI } from "../../generated.js"; import type { WETH } from "../types.js"; import { createWETH } from "../utils.js"; -import { simulateWETHDeposit } from "./simulateWETHDeposit.js"; +import { writeWETHDeposit } from "./writeWETHDeposit.js"; let id: Hex | undefined = undefined; @@ -35,14 +35,11 @@ beforeEach(async () => { id = await testClient.snapshot(); }); -test("simulate deposit", async () => { - const { request } = await simulateWETHDeposit(publicClient, { +test("write deposit", async () => { + const hash = await writeWETHDeposit(walletClient, { args: { amount: createAmountFromString(weth, "1") }, - account: ALICE, }); - const hash = await walletClient.writeContract(request); - await publicClient.waitForTransactionReceipt({ hash }); const balance = await getERC20BalanceOf(publicClient, { diff --git a/packages/core/src/weth/walletActions/simulateWETHDeposit.ts b/packages/core/src/weth/walletActions/writeWETHDeposit.ts similarity index 56% rename from packages/core/src/weth/walletActions/simulateWETHDeposit.ts rename to packages/core/src/weth/walletActions/writeWETHDeposit.ts index 615df1a..ee4e618 100644 --- a/packages/core/src/weth/walletActions/simulateWETHDeposit.ts +++ b/packages/core/src/weth/walletActions/writeWETHDeposit.ts @@ -1,59 +1,54 @@ import type { + Account, Chain, Client, - SimulateContractParameters, - SimulateContractReturnType, Transport, + WriteContractParameters, + WriteContractReturnType, } from "viem"; -import { simulateContract } from "viem/contract"; +import { writeContract } from "viem/contract"; import type { ERC20Amount } from "../../erc20/types.js"; import { weth9ABI } from "../../generated.js"; import type { WETH } from "../types.js"; export type WETHDepositParameters = { amount: ERC20Amount }; -export type SimulateWETHDepositParameters< +export type WriteWETHDepositParameters< TChain extends Chain | undefined = Chain, + TAccount extends Account | undefined = Account | undefined, TChainOverride extends Chain | undefined = Chain | undefined, > = Omit< - SimulateContractParameters< + WriteContractParameters< typeof weth9ABI, "deposit", TChain, + TAccount, TChainOverride >, "args" | "address" | "abi" | "functionName" | "value" > & { args: WETHDepositParameters }; -export type SimulateWETHDepositReturnType< - TChain extends Chain | undefined, - TChainOverride extends Chain | undefined = undefined, -> = SimulateContractReturnType< - typeof weth9ABI, - "deposit", - TChain, - TChainOverride ->; - -export const simulateWETHDeposit = < +export const writeWETHDeposit = < TChain extends Chain | undefined, + TAccount extends Account | undefined, TChainOverride extends Chain | undefined, >( - client: Client, + client: Client, { args: { amount }, ...request - }: SimulateWETHDepositParameters, -): Promise> => - simulateContract(client, { + }: WriteWETHDepositParameters, +): Promise => + writeContract(client, { address: amount.token.address, abi: weth9ABI, functionName: "deposit", value: amount.amount, ...request, - } as unknown as SimulateContractParameters< + } as unknown as WriteContractParameters< typeof weth9ABI, "deposit", TChain, + TAccount, TChainOverride >); diff --git a/packages/core/src/weth/walletActions/simulateWETHWithdraw.test.ts b/packages/core/src/weth/walletActions/writeWETHWithdraw.test.ts similarity index 74% rename from packages/core/src/weth/walletActions/simulateWETHWithdraw.test.ts rename to packages/core/src/weth/walletActions/writeWETHWithdraw.test.ts index 4499d62..32a0f3e 100644 --- a/packages/core/src/weth/walletActions/simulateWETHWithdraw.test.ts +++ b/packages/core/src/weth/walletActions/writeWETHWithdraw.test.ts @@ -10,8 +10,8 @@ import { getERC20BalanceOf } from "../../erc20/publicActions/getERC20BalanceOf.j import { weth9ABI } from "../../generated.js"; import type { WETH } from "../types.js"; import { createWETH } from "../utils.js"; -import { simulateWETHDeposit } from "./simulateWETHDeposit.js"; -import { simulateWETHWithdraw } from "./simulateWETHWithdraw.js"; +import { writeWETHDeposit } from "./writeWETHDeposit.js"; +import { writeWETHWithdraw } from "./writeWETHWithdraw.js"; let id: Hex | undefined = undefined; @@ -36,25 +36,17 @@ beforeEach(async () => { id = await testClient.snapshot(); }); -test("simulate withdraw", async () => { - const { request } = await simulateWETHDeposit(publicClient, { +test("write withdraw", async () => { + const hash = await writeWETHDeposit(publicClient, { args: { amount: createAmountFromString(weth, "1") }, account: ALICE, }); - const hash = await walletClient.writeContract(request); - await publicClient.waitForTransactionReceipt({ hash }); - const { request: withdrawRequest } = await simulateWETHWithdraw( - publicClient, - { - args: { amount: createAmountFromString(weth, "1") }, - account: ALICE, - }, - ); - - const requestHash = await walletClient.writeContract(withdrawRequest); + const requestHash = await writeWETHWithdraw(walletClient, { + args: { amount: createAmountFromString(weth, "1") }, + }); await publicClient.waitForTransactionReceipt({ hash: requestHash }); diff --git a/packages/core/src/weth/walletActions/simulateWETHWithdraw.ts b/packages/core/src/weth/walletActions/writeWETHWithdraw.ts similarity index 55% rename from packages/core/src/weth/walletActions/simulateWETHWithdraw.ts rename to packages/core/src/weth/walletActions/writeWETHWithdraw.ts index f99f2bf..7e4896d 100644 --- a/packages/core/src/weth/walletActions/simulateWETHWithdraw.ts +++ b/packages/core/src/weth/walletActions/writeWETHWithdraw.ts @@ -1,59 +1,54 @@ import type { + Account, Chain, Client, - SimulateContractParameters, - SimulateContractReturnType, Transport, + WriteContractParameters, + WriteContractReturnType, } from "viem"; -import { simulateContract } from "viem/contract"; +import { writeContract } from "viem/contract"; import type { ERC20Amount } from "../../erc20/types.js"; import { weth9ABI } from "../../generated.js"; import type { WETH } from "../types.js"; export type WETHWithdrawParameters = { amount: ERC20Amount }; -export type SimulateWETHWithdrawParameters< +export type WriteWETHWithdrawParameters< TChain extends Chain | undefined = Chain, + TAccount extends Account | undefined = Account | undefined, TChainOverride extends Chain | undefined = Chain | undefined, > = Omit< - SimulateContractParameters< + WriteContractParameters< typeof weth9ABI, "withdraw", TChain, + TAccount, TChainOverride >, "args" | "address" | "abi" | "functionName" > & { args: WETHWithdrawParameters }; -export type SimulateWETHWithdrawReturnType< - TChain extends Chain | undefined, - TChainOverride extends Chain | undefined = undefined, -> = SimulateContractReturnType< - typeof weth9ABI, - "withdraw", - TChain, - TChainOverride ->; - -export const simulateWETHWithdraw = < +export const writeWETHWithdraw = < TChain extends Chain | undefined, + TAccount extends Account | undefined, TChainOverride extends Chain | undefined, >( - client: Client, + client: Client, { args: { amount }, ...request - }: SimulateWETHWithdrawParameters, -): Promise> => - simulateContract(client, { + }: WriteWETHWithdrawParameters, +): Promise => + writeContract(client, { address: amount.token.address, abi: weth9ABI, functionName: "withdraw", args: [amount.amount], ...request, - } as unknown as SimulateContractParameters< + } as unknown as WriteContractParameters< typeof weth9ABI, "withdraw", TChain, + TAccount, TChainOverride >); diff --git a/packages/core/tsup.config.ts b/packages/core/tsup.config.ts index c427bc3..425cf9b 100644 --- a/packages/core/tsup.config.ts +++ b/packages/core/tsup.config.ts @@ -9,4 +9,6 @@ export default defineConfig({ sourcemap: true, dts: true, clean: true, + minify: true, + treeshake: true, }); From ad4046cb885ce25113beb1d20a740890e4b53f83 Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Tue, 26 Sep 2023 10:43:50 -0400 Subject: [PATCH 18/42] docs(changeset): Change wallet actions to write contract --- .changeset/afraid-tables-love.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/afraid-tables-love.md diff --git a/.changeset/afraid-tables-love.md b/.changeset/afraid-tables-love.md new file mode 100644 index 0000000..420bb5e --- /dev/null +++ b/.changeset/afraid-tables-love.md @@ -0,0 +1,5 @@ +--- +"reverse-mirage": patch +--- + +Change wallet actions to write contract From 02372381a5df59f07ee72c9adcb02c49fcca489e Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Tue, 26 Sep 2023 10:47:39 -0400 Subject: [PATCH 19/42] RELEASING: Releasing 1 package(s) Releases: reverse-mirage@1.0.0-next.3 [skip ci] --- packages/core/CHANGELOG.md | 6 ++++++ packages/core/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index 43921e2..bef29ef 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,11 @@ # reverse-mirage +## 1.0.0-next.3 + +### Patch Changes + +- ad4046c: Change wallet actions to write contract + ## 1.0.0-next.2 ### Patch Changes diff --git a/packages/core/package.json b/packages/core/package.json index f457810..dd857b5 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "reverse-mirage", - "version": "1.0.0-next.2", + "version": "1.0.0-next.3", "description": "Application level typescript utilities for Ethereum", "type": "module", "sideEffects": false, From a7d39124cb7768fd65348b47a6cc7caa5a55f3c8 Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Tue, 26 Sep 2023 10:49:40 -0400 Subject: [PATCH 20/42] p --- .changeset/pre.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.changeset/pre.json b/.changeset/pre.json index 311d845..04a93e5 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -5,6 +5,7 @@ "reverse-mirage": "0.1.11" }, "changesets": [ + "afraid-tables-love", "good-jobs-think", "long-pillows-sip", "young-schools-punch" From 4eb30d22426ff4a1f7b66a1f0ccee1842b972c6a Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Tue, 26 Sep 2023 10:55:00 -0400 Subject: [PATCH 21/42] rename docs --- docs/.vitepress/config.mts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index 17ce0f4..943b7f3 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -99,19 +99,19 @@ export default defineConfig({ text: "Wallet Actions", items: [ { - text: "simulateERC20Transfer", + text: "writeERC20Transfer", link: "", }, { - text: "simulateERC20Approve", + text: "writeERC20Approve", link: "", }, { - text: "simulateERC20TransferFrom", + text: "writeERC20TransferFrom", link: "", }, { - text: "simulateERC20Permit", + text: "writeERC20Permit", link: "", }, { @@ -166,11 +166,11 @@ export default defineConfig({ text: "Wallet Actions", items: [ { - text: "simulateWETHDeposit", + text: "writeWETHDeposit", link: "", }, { - text: "simulateWETHWithdraw", + text: "writeWETHWithdraw", link: "", }, ], @@ -244,15 +244,15 @@ export default defineConfig({ text: "Wallet Actions", items: [ { - text: "simulateERC721Transfer", + text: "writeERC721Transfer", link: "", }, { - text: "simulateERC721Approve", + text: "writeERC721Approve", link: "", }, { - text: "simulateERC721SetApprovalForAll", + text: "writeERC721SetApprovalForAll", link: "", }, ], @@ -302,15 +302,15 @@ export default defineConfig({ text: "Wallet Actions", items: [ { - text: "simulateERC1155Transfer", + text: "writeERC1155Transfer", link: "", }, { - text: "simulateERC1155TransferBatch", + text: "writeERC1155TransferBatch", link: "", }, { - text: "simulateERC1155SetApprovalForAll", + text: "writeERC1155SetApprovalForAll", link: "", }, ], From b94a7ee4f66e4bcb76125ecfe02a2028fb88bcd3 Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Tue, 26 Sep 2023 15:39:36 -0400 Subject: [PATCH 22/42] Revert "change to write contract" This reverts commit 32b3f292c0b59b6c1920c17d85e10da7e81a42e4. --- README.md | 12 +-- examples/next-interface/hooks/useTransfer.ts | 5 +- packages/core/src/decorator/publicActions.ts | 84 ++++++++++++++++++- packages/core/src/decorator/walletActions.ts | 83 ------------------ packages/core/src/erc1155/index.ts | 6 +- ... simulateERC1155SetApprovalForAll.test.ts} | 6 +- ...ts => simulateERC1155SetApprovalForAll.ts} | 39 +++++---- ...est.ts => simulateERC1155Transfer.test.ts} | 6 +- ...Transfer.ts => simulateERC1155Transfer.ts} | 37 ++++---- ...s => simulateERC1155TransferBatch.test.ts} | 10 ++- ...tch.ts => simulateERC1155TransferBatch.ts} | 37 ++++---- packages/core/src/erc20/index.ts | 8 +- ...e.test.ts => simulateERC20Approve.test.ts} | 9 +- ...RC20Approve.ts => simulateERC20Approve.ts} | 39 +++++---- ...it.test.ts => simulateERC20Permit.test.ts} | 8 +- ...eERC20Permit.ts => simulateERC20Permit.ts} | 39 +++++---- ....test.ts => simulateERC20Transfer.test.ts} | 9 +- ...20Transfer.ts => simulateERC20Transfer.ts} | 39 +++++---- ...t.ts => simulateERC20TransferFrom.test.ts} | 9 +- ...erFrom.ts => simulateERC20TransferFrom.ts} | 39 +++++---- packages/core/src/erc721/index.ts | 6 +- ....test.ts => simulateERC721Approve.test.ts} | 6 +- ...721Approve.ts => simulateERC721Approve.ts} | 37 ++++---- ...> simulateERC721SetApprovalForAll.test.ts} | 6 +- ....ts => simulateERC721SetApprovalForAll.ts} | 37 ++++---- ...test.ts => simulateERC721Transfer.test.ts} | 14 +++- ...1Transfer.ts => simulateERC721Transfer.ts} | 47 ++++++----- packages/core/src/index.ts | 24 +++--- packages/core/src/weth/index.ts | 4 +- ...it.test.ts => simulateWETHDeposit.test.ts} | 9 +- ...eWETHDeposit.ts => simulateWETHDeposit.ts} | 37 ++++---- ...w.test.ts => simulateWETHWithdraw.test.ts} | 22 +++-- ...ETHWithdraw.ts => simulateWETHWithdraw.ts} | 37 ++++---- packages/core/tsup.config.ts | 2 - 34 files changed, 449 insertions(+), 363 deletions(-) rename packages/core/src/erc1155/walletActions/{writeERC1155SetApprovalForAll.test.ts => simulateERC1155SetApprovalForAll.test.ts} (88%) rename packages/core/src/erc1155/walletActions/{writeERC1155SetApprovalForAll.ts => simulateERC1155SetApprovalForAll.ts} (56%) rename packages/core/src/erc1155/walletActions/{writeERC1155Transfer.test.ts => simulateERC1155Transfer.test.ts} (90%) rename packages/core/src/erc1155/walletActions/{writeERC1155Transfer.ts => simulateERC1155Transfer.ts} (63%) rename packages/core/src/erc1155/walletActions/{writeERC1155TransferBatch.test.ts => simulateERC1155TransferBatch.test.ts} (87%) rename packages/core/src/erc1155/walletActions/{writeERC1155TransferBatch.ts => simulateERC1155TransferBatch.ts} (68%) rename packages/core/src/erc20/walletActions/{writeERC20Approve.test.ts => simulateERC20Approve.test.ts} (87%) rename packages/core/src/erc20/walletActions/{writeERC20Approve.ts => simulateERC20Approve.ts} (53%) rename packages/core/src/erc20/walletActions/{writeERC20Permit.test.ts => simulateERC20Permit.test.ts} (91%) rename packages/core/src/erc20/walletActions/{writeERC20Permit.ts => simulateERC20Permit.ts} (60%) rename packages/core/src/erc20/walletActions/{writeERC20Transfer.test.ts => simulateERC20Transfer.test.ts} (88%) rename packages/core/src/erc20/walletActions/{writeERC20Transfer.ts => simulateERC20Transfer.ts} (52%) rename packages/core/src/erc20/walletActions/{writeERC20TransferFrom.test.ts => simulateERC20TransferFrom.test.ts} (89%) rename packages/core/src/erc20/walletActions/{writeERC20TransferFrom.ts => simulateERC20TransferFrom.ts} (53%) rename packages/core/src/erc721/walletActions/{writeERC721Approve.test.ts => simulateERC721Approve.test.ts} (89%) rename packages/core/src/erc721/walletActions/{writeERC721Approve.ts => simulateERC721Approve.ts} (56%) rename packages/core/src/erc721/walletActions/{writeERC721SetApprovalForAll.test.ts => simulateERC721SetApprovalForAll.test.ts} (88%) rename packages/core/src/erc721/walletActions/{writeERC721SetApprovalForAll.ts => simulateERC721SetApprovalForAll.ts} (56%) rename packages/core/src/erc721/walletActions/{writeERC721Transfer.test.ts => simulateERC721Transfer.test.ts} (81%) rename packages/core/src/erc721/walletActions/{writeERC721Transfer.ts => simulateERC721Transfer.ts} (73%) rename packages/core/src/weth/walletActions/{writeWETHDeposit.test.ts => simulateWETHDeposit.test.ts} (86%) rename packages/core/src/weth/walletActions/{writeWETHDeposit.ts => simulateWETHDeposit.ts} (56%) rename packages/core/src/weth/walletActions/{writeWETHWithdraw.test.ts => simulateWETHWithdraw.test.ts} (74%) rename packages/core/src/weth/walletActions/{writeWETHWithdraw.ts => simulateWETHWithdraw.ts} (55%) diff --git a/README.md b/README.md index 0a18839..ef65f7d 100644 --- a/README.md +++ b/README.md @@ -11,13 +11,13 @@ Application level typescript utilities for Ethereum. ## Features -- ✅ ~10x faster, ~3x smaller than `@uniswap/sdk-core` -- ✅ Abstactions for commonly used token standards +- ✅ ~30x faster than `@uniswap/sdk-core` +- ✅ Abstactions for most commonly used token standards - ✅ Supports `permit` - ✅ Extensible to build apps and libraries - ✅ Seamless extension to [Viem](https://github.com/wagmi-dev/viem) - ✅ TypeScript ready -- ✅ Test suite running against local Ethereum network +- ✅ Test suite running against [forked](https://ethereum.org/en/glossary/#fork) Ethereum network ## Example @@ -45,9 +45,3 @@ const vitalikBalance = await publicClient.getERC20Balance({ console.log(amountToNumber(vitalikBalance)) // 420.69 ``` - -## Installation - -```sh -npm i reverse-mirage -``` diff --git a/examples/next-interface/hooks/useTransfer.ts b/examples/next-interface/hooks/useTransfer.ts index a8e75f3..20b643b 100644 --- a/examples/next-interface/hooks/useTransfer.ts +++ b/examples/next-interface/hooks/useTransfer.ts @@ -6,7 +6,7 @@ import { type ERC20Amount, getERC20BalanceOf, getQueryKey, - writeERC20Transfer, + simulateERC20Transfer, } from "reverse-mirage"; import { getAddress } from "viem"; import { type Address, useWalletClient } from "wagmi"; @@ -36,9 +36,10 @@ export const useTransfer = ( } & { toast: TxToast; }) => { - const hash = await writeERC20Transfer(walletClient.data!, { + const { request } = await simulateERC20Transfer(client, { args: { to, amount }, }); + const hash = await walletClient.data!.writeContract(request); toaster.txPending({ ...toast, hash }); diff --git a/packages/core/src/decorator/publicActions.ts b/packages/core/src/decorator/publicActions.ts index 8d36562..9d278b4 100644 --- a/packages/core/src/decorator/publicActions.ts +++ b/packages/core/src/decorator/publicActions.ts @@ -27,7 +27,22 @@ import type { GetERC20PermitNonceParameters } from "../erc20/publicActions/getER import type { GetERC20SymbolParameters } from "../erc20/publicActions/getERC20Symbol.js"; import type { GetERC20TotalSupplyParameters } from "../erc20/publicActions/getERC20TotalSupply.js"; import type { GetIsERC20PermitParameters } from "../erc20/publicActions/getIsERC20Permit.js"; - +import { + type SimulateERC20ApproveParameters, + simulateERC20Approve, +} from "../erc20/walletActions/simulateERC20Approve.js"; +import { + type SimulateERC20PermitParameters, + simulateERC20Permit, +} from "../erc20/walletActions/simulateERC20Permit.js"; +import { + type SimulateERC20TransferParameters, + simulateERC20Transfer, +} from "../erc20/walletActions/simulateERC20Transfer.js"; +import { + type SimulateERC20TransferFromParameters, + simulateERC20TransferFrom, +} from "../erc20/walletActions/simulateERC20TransferFrom.js"; import { type BaseERC721, getERC721, @@ -51,6 +66,18 @@ import type { GetERC721OwnerOfParameters } from "../erc721/publicActions/getERC7 import type { GetERC721SupportsInterfaceParameters } from "../erc721/publicActions/getERC721SupportsInterface.js"; import type { GetERC721SymbolParameters } from "../erc721/publicActions/getERC721Symbol.js"; import type { GetERC721TokenURIParameters } from "../erc721/publicActions/getERC721TokenURI.js"; +import { + type SimulateERC721ApproveParameters, + simulateERC721Approve, +} from "../erc721/walletActions/simulateERC721Approve.js"; +import { + type SimulateERC721SetApprovalForAllParameters, + simulateERC721SetApprovalForAll, +} from "../erc721/walletActions/simulateERC721SetApprovalForAll.js"; +import { + type SimulateERC721TransferParameters, + simulateERC721Transfer, +} from "../erc721/walletActions/simulateERC721Transfer.js"; import { type BaseERC1155, getERC1155, @@ -62,11 +89,31 @@ import type { GetERC1155Parameters } from "../erc1155/publicActions/getERC1155.j import type { GetERC1155BalanceOfParameters } from "../erc1155/publicActions/getERC1155BalanceOf.js"; import type { GetERC1155IsApprovedForAllParameters } from "../erc1155/publicActions/getERC1155IsApprovedForAll.js"; import type { GetERC1155URIParameters } from "../erc1155/publicActions/getERC1155URI.js"; +import { + type SimulateERC1155SetApprovalForAllParameters, + simulateERC1155SetApprovalForAll, +} from "../erc1155/walletActions/simulateERC1155SetApprovalForAll.js"; +import { + type SimulateERC1155TransferParameters, + simulateERC1155Transfer, +} from "../erc1155/walletActions/simulateERC1155Transfer.js"; +import { + type SimulateERC1155TransferBatchParameters, + simulateERC1155TransferBatch, +} from "../erc1155/walletActions/simulateERC1155TransferBatch.js"; import { type GetNativeBalanceParameters, - type NativeCurrency, getNativeBalance, -} from "../native/index.js"; +} from "../native/publicActions/getNativeBalance.js"; +import type { NativeCurrency } from "../native/types.js"; +import { + type SimulateWETHDepositParameters, + simulateWETHDeposit, +} from "../weth/walletActions/simulateWETHDeposit.js"; +import { + type SimulateWETHWithdrawParameters, + simulateWETHWithdraw, +} from "../weth/walletActions/simulateWETHWithdraw.js"; export const publicActionReverseMirage = < TChain extends Chain | undefined = Chain | undefined, @@ -131,4 +178,35 @@ export const publicActionReverseMirage = < getERC1155IsApprovedForAll: (args: GetERC1155IsApprovedForAllParameters) => getERC1155IsApprovedForAll(client, args), getERC1155URI: (args: GetERC1155URIParameters) => getERC1155URI(client, args), + + simulateWETHDeposit: (args: SimulateWETHDepositParameters) => + simulateWETHDeposit(client, args), + simulateWETHWithdraw: (args: SimulateWETHWithdrawParameters) => + simulateWETHWithdraw(client, args), + + simulateERC20Approve: (args: SimulateERC20ApproveParameters) => + simulateERC20Approve(client, args), + simulateERC20Permit: (args: SimulateERC20PermitParameters) => + simulateERC20Permit(client, args), + simulateERC20Transfer: (args: SimulateERC20TransferParameters) => + simulateERC20Transfer(client, args), + simulateERC20TransferFrom: (args: SimulateERC20TransferFromParameters) => + simulateERC20TransferFrom(client, args), + + simulateERC721Approve: (args: SimulateERC721ApproveParameters) => + simulateERC721Approve(client, args), + simulateERC721SetApprovalForAll: ( + args: SimulateERC721SetApprovalForAllParameters, + ) => simulateERC721SetApprovalForAll(client, args), + simulateERC721Transfer: (args: SimulateERC721TransferParameters) => + simulateERC721Transfer(client, args), + + simulateERC1155SetApprovalForAll: ( + args: SimulateERC1155SetApprovalForAllParameters, + ) => simulateERC1155SetApprovalForAll(client, args), + simulateERC1155Transfer: (args: SimulateERC1155TransferParameters) => + simulateERC1155Transfer(client, args), + simulateERC1155TransferBatch: ( + args: SimulateERC1155TransferBatchParameters, + ) => simulateERC1155TransferBatch(client, args), }); diff --git a/packages/core/src/decorator/walletActions.ts b/packages/core/src/decorator/walletActions.ts index 90d537a..dd9d06e 100644 --- a/packages/core/src/decorator/walletActions.ts +++ b/packages/core/src/decorator/walletActions.ts @@ -3,55 +3,6 @@ import { type SignERC20PermitParameters, signERC20Permit, } from "../erc20/walletActions/signERC20Permit.js"; -import { - type WriteERC1155TransferParameters, - writeERC1155Transfer, -} from "../erc1155/walletActions/writeERC1155Transfer.js"; -import { - type WriteERC1155TransferBatchParameters, - writeERC1155TransferBatch, -} from "../erc1155/walletActions/writeERC1155TransferBatch.js"; -import { - type WriteWETHDepositParameters, - writeWETHDeposit, -} from "../weth/walletActions/writeWETHDeposit.js"; -import { - type WriteWETHWithdrawParameters, - writeWETHWithdraw, -} from "../weth/walletActions/writeWETHWithdraw.js"; - -import { - type WriteERC20ApproveParameters, - writeERC20Approve, -} from "../erc20/walletActions/writeERC20Approve.js"; -import { - type WriteERC20PermitParameters, - writeERC20Permit, -} from "../erc20/walletActions/writeERC20Permit.js"; -import { - type WriteERC20TransferParameters, - writeERC20Transfer, -} from "../erc20/walletActions/writeERC20Transfer.js"; -import { - type WriteERC20TransferFromParameters, - writeERC20TransferFrom, -} from "../erc20/walletActions/writeERC20TransferFrom.js"; -import { - type WriteERC721ApproveParameters, - writeERC721Approve, -} from "../erc721/walletActions/writeERC721Approve.js"; -import { - type WriteERC721SetApprovalForAllParameters, - writeERC721SetApprovalForAll, -} from "../erc721/walletActions/writeERC721SetApprovalForAll.js"; -import { - type WriteERC721TransferParameters, - writeERC721Transfer, -} from "../erc721/walletActions/writeERC721Transfer.js"; -import { - type WriteERC1155SetApprovalForAllParameters, - writeERC1155SetApprovalForAll, -} from "../erc1155/walletActions/writeERC1155SetApprovalForAll.js"; export const walletActionReverseMirage = < TChain extends Chain = Chain, @@ -61,38 +12,4 @@ export const walletActionReverseMirage = < ) => ({ signERC20Permit: (args: SignERC20PermitParameters) => signERC20Permit(client, args), - - writeWETHDeposit: (args: WriteWETHDepositParameters) => - writeWETHDeposit(client, args), - writeWETHWithdraw: (args: WriteWETHWithdrawParameters) => - writeWETHWithdraw(client, args), - - writeERC20Approve: (args: WriteERC20ApproveParameters) => - writeERC20Approve(client, args), - writeERC20Permit: (args: WriteERC20PermitParameters) => - writeERC20Permit(client, args), - writeERC20Transfer: (args: WriteERC20TransferParameters) => - writeERC20Transfer(client, args), - writeERC20TransferFrom: ( - args: WriteERC20TransferFromParameters, - ) => writeERC20TransferFrom(client, args), - - writeERC721Approve: (args: WriteERC721ApproveParameters) => - writeERC721Approve(client, args), - writeERC721SetApprovalForAll: ( - args: WriteERC721SetApprovalForAllParameters, - ) => writeERC721SetApprovalForAll(client, args), - writeERC721Transfer: ( - args: WriteERC721TransferParameters, - ) => writeERC721Transfer(client, args), - - writeERC1155SetApprovalForAll: ( - args: WriteERC1155SetApprovalForAllParameters, - ) => writeERC1155SetApprovalForAll(client, args), - writeERC1155Transfer: ( - args: WriteERC1155TransferParameters, - ) => writeERC1155Transfer(client, args), - writeERC1155TransferBatch: ( - args: WriteERC1155TransferBatchParameters, - ) => writeERC1155TransferBatch(client, args), }); diff --git a/packages/core/src/erc1155/index.ts b/packages/core/src/erc1155/index.ts index 131b4a8..8efebb8 100644 --- a/packages/core/src/erc1155/index.ts +++ b/packages/core/src/erc1155/index.ts @@ -13,6 +13,6 @@ export { getERC1155BalanceOf } from "./publicActions/getERC1155BalanceOf.js"; export { getERC1155IsApprovedForAll } from "./publicActions/getERC1155IsApprovedForAll.js"; export { getERC1155URI } from "./publicActions/getERC1155URI.js"; -export { writeERC1155Transfer } from "./walletActions/writeERC1155Transfer.js"; -export { writeERC1155TransferBatch } from "./walletActions/writeERC1155TransferBatch.js"; -export { writeERC1155SetApprovalForAll } from "./walletActions/writeERC1155SetApprovalForAll.js"; +export { simulateERC1155Transfer } from "./walletActions/simulateERC1155Transfer.js"; +export { simulateERC1155TransferBatch } from "./walletActions/simulateERC1155TransferBatch.js"; +export { simulateERC1155SetApprovalForAll } from "./walletActions/simulateERC1155SetApprovalForAll.js"; diff --git a/packages/core/src/erc1155/walletActions/writeERC1155SetApprovalForAll.test.ts b/packages/core/src/erc1155/walletActions/simulateERC1155SetApprovalForAll.test.ts similarity index 88% rename from packages/core/src/erc1155/walletActions/writeERC1155SetApprovalForAll.test.ts rename to packages/core/src/erc1155/walletActions/simulateERC1155SetApprovalForAll.test.ts index 81c97fb..528c23e 100644 --- a/packages/core/src/erc1155/walletActions/writeERC1155SetApprovalForAll.test.ts +++ b/packages/core/src/erc1155/walletActions/simulateERC1155SetApprovalForAll.test.ts @@ -9,7 +9,7 @@ import { erc1155ABI } from "../../generated.js"; import { getERC1155IsApprovedForAll } from "../publicActions/getERC1155IsApprovedForAll.js"; import type { ERC1155 } from "../types.js"; import { createERC1155 } from "../utils.js"; -import { writeERC1155SetApprovalForAll } from "./writeERC1155SetApprovalForAll.js"; +import { simulateERC1155SetApprovalForAll } from "./simulateERC1155SetApprovalForAll.js"; let id: Hex | undefined = undefined; @@ -49,13 +49,15 @@ beforeEach(async () => { }); test("set approval for all", async () => { - const hash = await writeERC1155SetApprovalForAll(walletClient, { + const { request } = await simulateERC1155SetApprovalForAll(publicClient, { args: { erc1155, spender: BOB, approved: true, }, + account: ALICE, }); + const hash = await walletClient.writeContract(request); await publicClient.waitForTransactionReceipt({ hash }); diff --git a/packages/core/src/erc1155/walletActions/writeERC1155SetApprovalForAll.ts b/packages/core/src/erc1155/walletActions/simulateERC1155SetApprovalForAll.ts similarity index 56% rename from packages/core/src/erc1155/walletActions/writeERC1155SetApprovalForAll.ts rename to packages/core/src/erc1155/walletActions/simulateERC1155SetApprovalForAll.ts index 425daf2..433f5c4 100644 --- a/packages/core/src/erc1155/walletActions/writeERC1155SetApprovalForAll.ts +++ b/packages/core/src/erc1155/walletActions/simulateERC1155SetApprovalForAll.ts @@ -1,13 +1,12 @@ import type { - Account, Address, Chain, Client, + SimulateContractParameters, + SimulateContractReturnType, Transport, - WriteContractParameters, - WriteContractReturnType, } from "viem"; -import { writeContract } from "viem/contract"; +import { simulateContract } from "viem/contract"; import { solmateErc1155ABI as solmateERC1155 } from "../../generated.js"; import type { BaseERC1155 } from "../types.js"; @@ -17,42 +16,50 @@ export type ERC1155SetApprovalForAllParameters = { approved: boolean; }; -export type WriteERC1155SetApprovalForAllParameters< +export type SimulateERC1155SetApprovalForAllParameters< TChain extends Chain | undefined = Chain, - TAccount extends Account | undefined = Account | undefined, TChainOverride extends Chain | undefined = Chain | undefined, > = Omit< - WriteContractParameters< + SimulateContractParameters< typeof solmateERC1155, "setApprovalForAll", TChain, - TAccount, TChainOverride >, "args" | "address" | "abi" | "functionName" > & { args: ERC1155SetApprovalForAllParameters }; -export const writeERC1155SetApprovalForAll = < +export type SimulateERC1155SetApprovalForAllReturnType< + TChain extends Chain | undefined, + TChainOverride extends Chain | undefined = undefined, +> = SimulateContractReturnType< + typeof solmateERC1155, + "setApprovalForAll", + TChain, + TChainOverride +>; + +export const simulateERC1155SetApprovalForAll = < TChain extends Chain | undefined, - TAccount extends Account | undefined, TChainOverride extends Chain | undefined, >( - client: Client, + client: Client, { args: { erc1155, spender, approved }, ...request - }: WriteERC1155SetApprovalForAllParameters, -): Promise => - writeContract(client, { + }: SimulateERC1155SetApprovalForAllParameters, +): Promise< + SimulateERC1155SetApprovalForAllReturnType +> => + simulateContract(client, { address: erc1155.address, abi: solmateERC1155, functionName: "setApprovalForAll", args: [spender, approved], ...request, - } as unknown as WriteContractParameters< + } as unknown as SimulateContractParameters< typeof solmateERC1155, "setApprovalForAll", TChain, - TAccount, TChainOverride >); diff --git a/packages/core/src/erc1155/walletActions/writeERC1155Transfer.test.ts b/packages/core/src/erc1155/walletActions/simulateERC1155Transfer.test.ts similarity index 90% rename from packages/core/src/erc1155/walletActions/writeERC1155Transfer.test.ts rename to packages/core/src/erc1155/walletActions/simulateERC1155Transfer.test.ts index d9dab18..8031a8f 100644 --- a/packages/core/src/erc1155/walletActions/writeERC1155Transfer.test.ts +++ b/packages/core/src/erc1155/walletActions/simulateERC1155Transfer.test.ts @@ -9,7 +9,7 @@ import { erc1155ABI } from "../../generated.js"; import { getERC1155BalanceOf } from "../publicActions/getERC1155BalanceOf.js"; import type { ERC1155 } from "../types.js"; import { createERC1155, createERC1155Data } from "../utils.js"; -import { writeERC1155Transfer } from "./writeERC1155Transfer.js"; +import { simulateERC1155Transfer } from "./simulateERC1155Transfer.js"; let id: Hex | undefined = undefined; @@ -49,9 +49,11 @@ beforeEach(async () => { }); test("can transfer", async () => { - const hash = await writeERC1155Transfer(walletClient, { + const { request } = await simulateERC1155Transfer(publicClient, { args: { to: BOB, erc1155Data: createERC1155Data(erc1155, 5n) }, + account: ALICE, }); + const hash = await walletClient.writeContract(request); await publicClient.waitForTransactionReceipt({ hash }); const balanceALICE = await getERC1155BalanceOf(publicClient, { diff --git a/packages/core/src/erc1155/walletActions/writeERC1155Transfer.ts b/packages/core/src/erc1155/walletActions/simulateERC1155Transfer.ts similarity index 63% rename from packages/core/src/erc1155/walletActions/writeERC1155Transfer.ts rename to packages/core/src/erc1155/walletActions/simulateERC1155Transfer.ts index a3b12cd..dfa6262 100644 --- a/packages/core/src/erc1155/walletActions/writeERC1155Transfer.ts +++ b/packages/core/src/erc1155/walletActions/simulateERC1155Transfer.ts @@ -1,14 +1,13 @@ import type { - Account, Address, Chain, Client, Hex, + SimulateContractParameters, + SimulateContractReturnType, Transport, - WriteContractParameters, - WriteContractReturnType, } from "viem"; -import { writeContract } from "viem/contract"; +import { simulateContract } from "viem/contract"; import { solmateErc1155ABI as solmateERC1155 } from "../../generated.js"; import type { BaseERC1155, ERC1155Data } from "../types.js"; @@ -19,33 +18,40 @@ export type ERC1155TransferParameters = { data?: Hex; }; -export type WriteERC1155TransferParameters< +export type SimulateERC1155TransferParameters< TChain extends Chain | undefined = Chain, - TAccount extends Account | undefined = Account | undefined, TChainOverride extends Chain | undefined = Chain | undefined, > = Omit< - WriteContractParameters< + SimulateContractParameters< typeof solmateERC1155, "safeTransferFrom", TChain, - TAccount, TChainOverride >, "args" | "address" | "abi" | "functionName" > & { args: ERC1155TransferParameters }; -export const writeERC1155Transfer = < +export type SimulateERC1155TransferReturnType< + TChain extends Chain | undefined, + TChainOverride extends Chain | undefined = undefined, +> = SimulateContractReturnType< + typeof solmateERC1155, + "safeTransferFrom", + TChain, + TChainOverride +>; + +export const simulateERC1155Transfer = < TChain extends Chain | undefined, - TAccount extends Account | undefined, TChainOverride extends Chain | undefined, >( - client: Client, + client: Client, { args: { erc1155Data, to, from, data }, ...request - }: WriteERC1155TransferParameters, -): Promise => - writeContract(client, { + }: SimulateERC1155TransferParameters, +): Promise> => + simulateContract(client, { address: erc1155Data.token.address, abi: solmateERC1155, functionName: "safeTransferFrom", @@ -61,10 +67,9 @@ export const writeERC1155Transfer = < data ?? "0x", ], ...request, - } as unknown as WriteContractParameters< + } as unknown as SimulateContractParameters< typeof solmateERC1155, "safeTransferFrom", TChain, - TAccount, TChainOverride >); diff --git a/packages/core/src/erc1155/walletActions/writeERC1155TransferBatch.test.ts b/packages/core/src/erc1155/walletActions/simulateERC1155TransferBatch.test.ts similarity index 87% rename from packages/core/src/erc1155/walletActions/writeERC1155TransferBatch.test.ts rename to packages/core/src/erc1155/walletActions/simulateERC1155TransferBatch.test.ts index d60ea9a..dfb942a 100644 --- a/packages/core/src/erc1155/walletActions/writeERC1155TransferBatch.test.ts +++ b/packages/core/src/erc1155/walletActions/simulateERC1155TransferBatch.test.ts @@ -9,7 +9,7 @@ import { erc1155ABI } from "../../generated.js"; import { getERC1155BalanceOf } from "../publicActions/getERC1155BalanceOf.js"; import type { ERC1155 } from "../types.js"; import { createERC1155, createERC1155Data } from "../utils.js"; -import { writeERC1155TransferBatch } from "./writeERC1155TransferBatch.js"; +import { simulateERC1155TransferBatch } from "./simulateERC1155TransferBatch.js"; let id: Hex | undefined = undefined; @@ -51,7 +51,7 @@ beforeEach(async () => { test("can transfer batch", async () => { await expect( async () => - await writeERC1155TransferBatch(publicClient, { + await simulateERC1155TransferBatch(publicClient, { args: { to: BOB, erc1155Data: [] }, account: ALICE, }), @@ -59,7 +59,7 @@ test("can transfer batch", async () => { await expect( async () => - await writeERC1155TransferBatch(publicClient, { + await simulateERC1155TransferBatch(publicClient, { account: ALICE, args: { to: BOB, @@ -71,7 +71,8 @@ test("can transfer batch", async () => { }), ).rejects.toThrowError(); - const hash = await writeERC1155TransferBatch(walletClient, { + const { request } = await simulateERC1155TransferBatch(publicClient, { + account: ALICE, args: { to: BOB, erc1155Data: [ @@ -80,6 +81,7 @@ test("can transfer batch", async () => { ], }, }); + const hash = await walletClient.writeContract(request); await publicClient.waitForTransactionReceipt({ hash }); const balanceBOB = await getERC1155BalanceOf(publicClient, { diff --git a/packages/core/src/erc1155/walletActions/writeERC1155TransferBatch.ts b/packages/core/src/erc1155/walletActions/simulateERC1155TransferBatch.ts similarity index 68% rename from packages/core/src/erc1155/walletActions/writeERC1155TransferBatch.ts rename to packages/core/src/erc1155/walletActions/simulateERC1155TransferBatch.ts index d7d1dd4..557f514 100644 --- a/packages/core/src/erc1155/walletActions/writeERC1155TransferBatch.ts +++ b/packages/core/src/erc1155/walletActions/simulateERC1155TransferBatch.ts @@ -1,15 +1,14 @@ import { - type Account, type Address, type Chain, type Client, type Hex, + type SimulateContractParameters, + type SimulateContractReturnType, type Transport, - type WriteContractParameters, - type WriteContractReturnType, getAddress, } from "viem"; -import { writeContract } from "viem/contract"; +import { simulateContract } from "viem/contract"; import { solmateErc1155ABI as solmateERC1155 } from "../../generated.js"; import type { BaseERC1155, ERC1155Data } from "../types.js"; @@ -20,32 +19,39 @@ export type ERC1155TransferBatchParameters = { data?: Hex; }; -export type WriteERC1155TransferBatchParameters< +export type SimulateERC1155TransferBatchParameters< TChain extends Chain | undefined = Chain, - TAccount extends Account | undefined = Account | undefined, TChainOverride extends Chain | undefined = Chain | undefined, > = Omit< - WriteContractParameters< + SimulateContractParameters< typeof solmateERC1155, "safeBatchTransferFrom", TChain, - TAccount, TChainOverride >, "args" | "address" | "abi" | "functionName" > & { args: ERC1155TransferBatchParameters }; -export const writeERC1155TransferBatch = < +export type SimulateERC1155TransferBatchReturnType< + TChain extends Chain | undefined, + TChainOverride extends Chain | undefined = undefined, +> = SimulateContractReturnType< + typeof solmateERC1155, + "safeBatchTransferFrom", + TChain, + TChainOverride +>; + +export const simulateERC1155TransferBatch = < TChain extends Chain | undefined, - TAccount extends Account | undefined, TChainOverride extends Chain | undefined, >( - client: Client, + client: Client, { args: { erc1155Data, to, from, data }, ...request - }: WriteERC1155TransferBatchParameters, -): Promise => { + }: SimulateERC1155TransferBatchParameters, +): Promise> => { const address = erc1155Data.reduce((addr: Address | undefined, cur) => { if (addr === undefined) return getAddress(cur.token.address); else if (addr !== getAddress(cur.token.address)) @@ -55,7 +61,7 @@ export const writeERC1155TransferBatch = < if (address === undefined) throw Error("No tokens passed to transfer"); - return writeContract(client, { + return simulateContract(client, { address, abi: solmateERC1155, functionName: "safeBatchTransferFrom", @@ -71,11 +77,10 @@ export const writeERC1155TransferBatch = < data ?? "0x", ], ...request, - } as unknown as WriteContractParameters< + } as unknown as SimulateContractParameters< typeof solmateERC1155, "safeBatchTransferFrom", TChain, - TAccount, TChainOverride >); }; diff --git a/packages/core/src/erc20/index.ts b/packages/core/src/erc20/index.ts index 9ed22fd..5991eb8 100644 --- a/packages/core/src/erc20/index.ts +++ b/packages/core/src/erc20/index.ts @@ -32,7 +32,7 @@ export { getERC20TotalSupply } from "./publicActions/getERC20TotalSupply.js"; export { getIsERC20Permit } from "./publicActions/getIsERC20Permit.js"; export { signERC20Permit } from "./walletActions/signERC20Permit.js"; -export { writeERC20Approve } from "./walletActions/writeERC20Approve.js"; -export { writeERC20Permit } from "./walletActions/writeERC20Permit.js"; -export { writeERC20Transfer } from "./walletActions/writeERC20Transfer.js"; -export { writeERC20TransferFrom } from "./walletActions/writeERC20TransferFrom.js"; +export { simulateERC20Approve } from "./walletActions/simulateERC20Approve.js"; +export { simulateERC20Permit } from "./walletActions/simulateERC20Permit.js"; +export { simulateERC20Transfer } from "./walletActions/simulateERC20Transfer.js"; +export { simulateERC20TransferFrom } from "./walletActions/simulateERC20TransferFrom.js"; diff --git a/packages/core/src/erc20/walletActions/writeERC20Approve.test.ts b/packages/core/src/erc20/walletActions/simulateERC20Approve.test.ts similarity index 87% rename from packages/core/src/erc20/walletActions/writeERC20Approve.test.ts rename to packages/core/src/erc20/walletActions/simulateERC20Approve.test.ts index cd4a8d9..1e9161f 100644 --- a/packages/core/src/erc20/walletActions/writeERC20Approve.test.ts +++ b/packages/core/src/erc20/walletActions/simulateERC20Approve.test.ts @@ -10,7 +10,7 @@ import { erc20PermitABI } from "../../generated.js"; import { getERC20Allowance } from "../publicActions/getERC20Allowance.js"; import type { ERC20 } from "../types.js"; import { createERC20 } from "../utils.js"; -import { writeERC20Approve } from "./writeERC20Approve.js"; +import { simulateERC20Approve } from "./simulateERC20Approve.js"; let id: Hex | undefined = undefined; @@ -36,11 +36,14 @@ beforeEach(async () => { id = await testClient.snapshot(); }); -test("Write approve", async () => { - const hash = await writeERC20Approve(walletClient, { +test("simulate approve", async () => { + const { request } = await simulateERC20Approve(publicClient, { args: { amount: createAmountFromString(erc20, "1"), spender: BOB }, + account: ALICE, }); + const hash = await walletClient.writeContract(request); + await publicClient.waitForTransactionReceipt({ hash }); const allowance = await getERC20Allowance(publicClient, { diff --git a/packages/core/src/erc20/walletActions/writeERC20Approve.ts b/packages/core/src/erc20/walletActions/simulateERC20Approve.ts similarity index 53% rename from packages/core/src/erc20/walletActions/writeERC20Approve.ts rename to packages/core/src/erc20/walletActions/simulateERC20Approve.ts index fc9ac3e..f493a68 100644 --- a/packages/core/src/erc20/walletActions/writeERC20Approve.ts +++ b/packages/core/src/erc20/walletActions/simulateERC20Approve.ts @@ -1,57 +1,62 @@ import type { - Account, Address, Chain, Client, + SimulateContractParameters, + SimulateContractReturnType, Transport, - WriteContractParameters, - WriteContractReturnType, } from "viem"; -import { writeContract } from "viem/contract"; +import { simulateContract } from "viem/contract"; +import type { BaseERC20, ERC20Amount } from "../../erc20/types.js"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; -import type { BaseERC20, ERC20Amount } from "../types.js"; export type ERC20ApproveParameters = { amount: ERC20Amount; spender: Address; }; -export type WriteERC20ApproveParameters< +export type SimulateERC20ApproveParameters< TChain extends Chain | undefined = Chain, - TAccount extends Account | undefined = Account | undefined, TChainOverride extends Chain | undefined = Chain | undefined, > = Omit< - WriteContractParameters< + SimulateContractParameters< typeof solmateERC20ABI, "approve", TChain, - TAccount, TChainOverride >, "args" | "address" | "abi" | "functionName" > & { args: ERC20ApproveParameters }; -export const writeERC20Approve = < +export type SimulateERC20ApproveReturnType< + TChain extends Chain | undefined, + TChainOverride extends Chain | undefined = undefined, +> = SimulateContractReturnType< + typeof solmateERC20ABI, + "approve", + TChain, + TChainOverride +>; + +export const simulateERC20Approve = < TChain extends Chain | undefined, - TAccount extends Account | undefined, TChainOverride extends Chain | undefined, >( - client: Client, + client: Client, { args: { amount, spender }, ...request - }: WriteERC20ApproveParameters, -): Promise => - writeContract(client, { + }: SimulateERC20ApproveParameters, +): Promise> => + simulateContract(client, { address: amount.token.address, abi: solmateERC20ABI, functionName: "approve", args: [spender, amount.amount], ...request, - } as unknown as WriteContractParameters< + } as unknown as SimulateContractParameters< typeof solmateERC20ABI, "approve", TChain, - TAccount, TChainOverride >); diff --git a/packages/core/src/erc20/walletActions/writeERC20Permit.test.ts b/packages/core/src/erc20/walletActions/simulateERC20Permit.test.ts similarity index 91% rename from packages/core/src/erc20/walletActions/writeERC20Permit.test.ts rename to packages/core/src/erc20/walletActions/simulateERC20Permit.test.ts index e496e33..5707f1a 100644 --- a/packages/core/src/erc20/walletActions/writeERC20Permit.test.ts +++ b/packages/core/src/erc20/walletActions/simulateERC20Permit.test.ts @@ -13,7 +13,7 @@ import { createERC20PermitDataFromString, } from "../utils.js"; import { signERC20Permit } from "./signERC20Permit.js"; -import { writeERC20Permit } from "./writeERC20Permit.js"; +import { simulateERC20Permit } from "./simulateERC20Permit.js"; let id: Hex | undefined = undefined; @@ -54,14 +54,14 @@ beforeEach(async () => { id = await testClient.snapshot(); }); -test("write permit", async () => { +test("simulate permit", async () => { const signature = await signERC20Permit(walletClient, { permitData: createERC20PermitDataFromString(erc20, "1", 0n), spender: BOB, deadline: 2n ** 256n - 1n, }); - const hash = await writeERC20Permit(walletClient, { + const { request } = await simulateERC20Permit(publicClient, { args: { permitData: createERC20PermitDataFromString(erc20, "1", 0n), owner: ALICE, @@ -71,6 +71,8 @@ test("write permit", async () => { }, }); + const hash = await walletClient.writeContract(request); + await publicClient.waitForTransactionReceipt({ hash }); const allowance = await getERC20Allowance(publicClient, { diff --git a/packages/core/src/erc20/walletActions/writeERC20Permit.ts b/packages/core/src/erc20/walletActions/simulateERC20Permit.ts similarity index 60% rename from packages/core/src/erc20/walletActions/writeERC20Permit.ts rename to packages/core/src/erc20/walletActions/simulateERC20Permit.ts index b746cb3..4be48f0 100644 --- a/packages/core/src/erc20/walletActions/writeERC20Permit.ts +++ b/packages/core/src/erc20/walletActions/simulateERC20Permit.ts @@ -1,16 +1,15 @@ import type { - Account, Address, Chain, Client, Hex, + SimulateContractParameters, + SimulateContractReturnType, Transport, - WriteContractParameters, - WriteContractReturnType, } from "viem"; -import { writeContract } from "viem/contract"; +import { simulateContract } from "viem/contract"; +import type { ERC20Permit, ERC20PermitData } from "../../erc20/types.js"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; -import type { ERC20Permit, ERC20PermitData } from "../types.js"; export type ERC20PermitParameters = { signature: Hex; @@ -20,47 +19,53 @@ export type ERC20PermitParameters = { deadline: bigint; }; -export type WriteERC20PermitParameters< +export type SimulateERC20PermitParameters< TChain extends Chain | undefined = Chain, - TAccount extends Account | undefined = Account | undefined, TChainOverride extends Chain | undefined = Chain | undefined, > = Omit< - WriteContractParameters< + SimulateContractParameters< typeof solmateERC20ABI, "permit", TChain, - TAccount, TChainOverride >, "args" | "address" | "abi" | "functionName" > & { args: ERC20PermitParameters }; -export const writeERC20Permit = < +export type SimulateERC20PermitReturnType< + TChain extends Chain | undefined, + TChainOverride extends Chain | undefined = undefined, +> = SimulateContractReturnType< + typeof solmateERC20ABI, + "permit", + TChain, + TChainOverride +>; + +export const simulateERC20Permit = < TChain extends Chain | undefined, - TAccount extends Account | undefined, TChainOverride extends Chain | undefined, >( - client: Client, + client: Client, { args: { owner, spender, signature, permitData, deadline }, ...request - }: WriteERC20PermitParameters, -): Promise => { + }: SimulateERC20PermitParameters, +): Promise> => { const r = `0x${signature.substring(2, 2 + 64)}` as const; const s = `0x${signature.substring(2 + 64, 2 + 64 + 64)}` as const; const v = Number(`0x${signature.substring(2 + 64 + 64)}`); - return writeContract(client, { + return simulateContract(client, { address: permitData.token.address, abi: solmateERC20ABI, functionName: "permit", args: [owner, spender, permitData.amount, deadline, v, r, s], ...request, - } as unknown as WriteContractParameters< + } as unknown as SimulateContractParameters< typeof solmateERC20ABI, "permit", TChain, - TAccount, TChainOverride >); }; diff --git a/packages/core/src/erc20/walletActions/writeERC20Transfer.test.ts b/packages/core/src/erc20/walletActions/simulateERC20Transfer.test.ts similarity index 88% rename from packages/core/src/erc20/walletActions/writeERC20Transfer.test.ts rename to packages/core/src/erc20/walletActions/simulateERC20Transfer.test.ts index 691eb6e..57f268e 100644 --- a/packages/core/src/erc20/walletActions/writeERC20Transfer.test.ts +++ b/packages/core/src/erc20/walletActions/simulateERC20Transfer.test.ts @@ -10,7 +10,7 @@ import { erc20PermitABI } from "../../generated.js"; import { getERC20BalanceOf } from "../publicActions/getERC20BalanceOf.js"; import type { ERC20 } from "../types.js"; import { createERC20 } from "../utils.js"; -import { writeERC20Transfer } from "./writeERC20Transfer.js"; +import { simulateERC20Transfer } from "./simulateERC20Transfer.js"; let id: Hex | undefined = undefined; @@ -44,11 +44,14 @@ beforeEach(async () => { id = await testClient.snapshot(); }); -test("write transfer", async () => { - const hash = await writeERC20Transfer(walletClient, { +test("simulate transfer", async () => { + const { request } = await simulateERC20Transfer(publicClient, { args: { amount: createAmountFromString(erc20, "1"), to: BOB }, + account: ALICE, }); + const hash = await walletClient.writeContract(request); + await publicClient.waitForTransactionReceipt({ hash }); const balance = await getERC20BalanceOf(publicClient, { diff --git a/packages/core/src/erc20/walletActions/writeERC20Transfer.ts b/packages/core/src/erc20/walletActions/simulateERC20Transfer.ts similarity index 52% rename from packages/core/src/erc20/walletActions/writeERC20Transfer.ts rename to packages/core/src/erc20/walletActions/simulateERC20Transfer.ts index 2b82691..8326e25 100644 --- a/packages/core/src/erc20/walletActions/writeERC20Transfer.ts +++ b/packages/core/src/erc20/walletActions/simulateERC20Transfer.ts @@ -1,57 +1,62 @@ import type { - Account, Address, Chain, Client, + SimulateContractParameters, + SimulateContractReturnType, Transport, - WriteContractParameters, - WriteContractReturnType, } from "viem"; -import { writeContract } from "viem/contract"; +import { simulateContract } from "viem/contract"; +import type { BaseERC20, ERC20Amount } from "../../erc20/types.js"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; -import type { BaseERC20, ERC20Amount } from "../types.js"; export type ERC20TransferParameters = { amount: ERC20Amount; to: Address; }; -export type WriteERC20TransferParameters< +export type SimulateERC20TransferParameters< TChain extends Chain | undefined = Chain, - TAccount extends Account | undefined = Account | undefined, TChainOverride extends Chain | undefined = Chain | undefined, > = Omit< - WriteContractParameters< + SimulateContractParameters< typeof solmateERC20ABI, "transfer", TChain, - TAccount, TChainOverride >, "args" | "address" | "abi" | "functionName" > & { args: ERC20TransferParameters }; -export const writeERC20Transfer = < +export type SimulateERC20TransferReturnType< + TChain extends Chain | undefined, + TChainOverride extends Chain | undefined = undefined, +> = SimulateContractReturnType< + typeof solmateERC20ABI, + "transfer", + TChain, + TChainOverride +>; + +export const simulateERC20Transfer = < TChain extends Chain | undefined, - TAccount extends Account | undefined, TChainOverride extends Chain | undefined, >( - client: Client, + client: Client, { args: { amount, to }, ...request - }: WriteERC20TransferParameters, -): Promise => - writeContract(client, { + }: SimulateERC20TransferParameters, +): Promise> => + simulateContract(client, { address: amount.token.address, abi: solmateERC20ABI, functionName: "transfer", args: [to, amount.amount], ...request, - } as unknown as WriteContractParameters< + } as unknown as SimulateContractParameters< typeof solmateERC20ABI, "transfer", TChain, - TAccount, TChainOverride >); diff --git a/packages/core/src/erc20/walletActions/writeERC20TransferFrom.test.ts b/packages/core/src/erc20/walletActions/simulateERC20TransferFrom.test.ts similarity index 89% rename from packages/core/src/erc20/walletActions/writeERC20TransferFrom.test.ts rename to packages/core/src/erc20/walletActions/simulateERC20TransferFrom.test.ts index d3d8ab7..0e46f55 100644 --- a/packages/core/src/erc20/walletActions/writeERC20TransferFrom.test.ts +++ b/packages/core/src/erc20/walletActions/simulateERC20TransferFrom.test.ts @@ -10,7 +10,7 @@ import { erc20PermitABI } from "../../generated.js"; import { getERC20BalanceOf } from "../publicActions/getERC20BalanceOf.js"; import type { ERC20 } from "../types.js"; import { createERC20 } from "../utils.js"; -import { writeERC20TransferFrom } from "./writeERC20TransferFrom.js"; +import { simulateERC20TransferFrom } from "./simulateERC20TransferFrom.js"; let id: Hex | undefined = undefined; @@ -52,11 +52,14 @@ beforeEach(async () => { id = await testClient.snapshot(); }); -test("write transfer from", async () => { - const hash = await writeERC20TransferFrom(walletClient, { +test("simulate transfer from", async () => { + const { request } = await simulateERC20TransferFrom(publicClient, { args: { amount: createAmountFromString(erc20, "1"), from: ALICE, to: BOB }, + account: ALICE, }); + const hash = await walletClient.writeContract(request); + await publicClient.waitForTransactionReceipt({ hash }); const balance = await getERC20BalanceOf(publicClient, { diff --git a/packages/core/src/erc20/walletActions/writeERC20TransferFrom.ts b/packages/core/src/erc20/walletActions/simulateERC20TransferFrom.ts similarity index 53% rename from packages/core/src/erc20/walletActions/writeERC20TransferFrom.ts rename to packages/core/src/erc20/walletActions/simulateERC20TransferFrom.ts index 6bd4008..a5a79c3 100644 --- a/packages/core/src/erc20/walletActions/writeERC20TransferFrom.ts +++ b/packages/core/src/erc20/walletActions/simulateERC20TransferFrom.ts @@ -1,15 +1,14 @@ import type { - Account, Address, Chain, Client, + SimulateContractParameters, + SimulateContractReturnType, Transport, - WriteContractParameters, - WriteContractReturnType, } from "viem"; -import { writeContract } from "viem/contract"; +import { simulateContract } from "viem/contract"; +import type { BaseERC20, ERC20Amount } from "../../erc20/types.js"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; -import type { BaseERC20, ERC20Amount } from "../types.js"; export type ERC20TransferFromParameters = { amount: ERC20Amount; @@ -17,42 +16,48 @@ export type ERC20TransferFromParameters = { to: Address; }; -export type WriteERC20TransferFromParameters< +export type SimulateERC20TransferFromParameters< TChain extends Chain | undefined = Chain, - TAccount extends Account | undefined = Account | undefined, TChainOverride extends Chain | undefined = Chain | undefined, > = Omit< - WriteContractParameters< + SimulateContractParameters< typeof solmateERC20ABI, "transferFrom", TChain, - TAccount, TChainOverride >, "args" | "address" | "abi" | "functionName" > & { args: ERC20TransferFromParameters }; -export const writeERC20TransferFrom = < +export type SimulateERC20TransferFromReturnType< + TChain extends Chain | undefined, + TChainOverride extends Chain | undefined = undefined, +> = SimulateContractReturnType< + typeof solmateERC20ABI, + "transferFrom", + TChain, + TChainOverride +>; + +export const simulateERC20TransferFrom = < TChain extends Chain | undefined, - TAccount extends Account | undefined, TChainOverride extends Chain | undefined, >( - client: Client, + client: Client, { args: { amount, from, to }, ...request - }: WriteERC20TransferFromParameters, -): Promise => - writeContract(client, { + }: SimulateERC20TransferFromParameters, +): Promise> => + simulateContract(client, { address: amount.token.address, abi: solmateERC20ABI, functionName: "transferFrom", args: [from, to, amount.amount], ...request, - } as unknown as WriteContractParameters< + } as unknown as SimulateContractParameters< typeof solmateERC20ABI, "transferFrom", TChain, - TAccount, TChainOverride >); diff --git a/packages/core/src/erc721/index.ts b/packages/core/src/erc721/index.ts index 707c7bf..8211afb 100644 --- a/packages/core/src/erc721/index.ts +++ b/packages/core/src/erc721/index.ts @@ -19,6 +19,6 @@ export { getERC721OwnerOf } from "./publicActions/getERC721OwnerOf.js"; export { getERC721SupportsInterface } from "./publicActions/getERC721SupportsInterface.js"; export { getERC721TokenURI } from "./publicActions/getERC721TokenURI.js"; -export { writeERC721Transfer } from "./walletActions/writeERC721Transfer.js"; -export { writeERC721Approve } from "./walletActions/writeERC721Approve.js"; -export { writeERC721SetApprovalForAll } from "./walletActions/writeERC721SetApprovalForAll.js"; +export { simulateERC721Transfer } from "./walletActions/simulateERC721Transfer.js"; +export { simulateERC721Approve } from "./walletActions/simulateERC721Approve.js"; +export { simulateERC721SetApprovalForAll } from "./walletActions/simulateERC721SetApprovalForAll.js"; diff --git a/packages/core/src/erc721/walletActions/writeERC721Approve.test.ts b/packages/core/src/erc721/walletActions/simulateERC721Approve.test.ts similarity index 89% rename from packages/core/src/erc721/walletActions/writeERC721Approve.test.ts rename to packages/core/src/erc721/walletActions/simulateERC721Approve.test.ts index 63cb8cf..94522d9 100644 --- a/packages/core/src/erc721/walletActions/writeERC721Approve.test.ts +++ b/packages/core/src/erc721/walletActions/simulateERC721Approve.test.ts @@ -9,7 +9,7 @@ import { erc721ABI } from "../../generated.js"; import { getERC721Approved } from "../publicActions/getERC721Approved.js"; import type { ERC721 } from "../types.js"; import { createERC721 } from "../utils.js"; -import { writeERC721Approve } from "./writeERC721Approve.js"; +import { simulateERC721Approve } from "./simulateERC721Approve.js"; let id: Hex | undefined = undefined; @@ -44,13 +44,15 @@ beforeEach(async () => { }); test("approve", async () => { - const hash = await writeERC721Approve(walletClient, { + const { request } = await simulateERC721Approve(publicClient, { args: { erc721, id: 0n, spender: BOB, }, + account: ALICE, }); + const hash = await walletClient.writeContract(request); await publicClient.waitForTransactionReceipt({ hash }); diff --git a/packages/core/src/erc721/walletActions/writeERC721Approve.ts b/packages/core/src/erc721/walletActions/simulateERC721Approve.ts similarity index 56% rename from packages/core/src/erc721/walletActions/writeERC721Approve.ts rename to packages/core/src/erc721/walletActions/simulateERC721Approve.ts index 0eaf575..9fde2ff 100644 --- a/packages/core/src/erc721/walletActions/writeERC721Approve.ts +++ b/packages/core/src/erc721/walletActions/simulateERC721Approve.ts @@ -1,13 +1,12 @@ import type { - Account, Address, Chain, Client, + SimulateContractParameters, + SimulateContractReturnType, Transport, - WriteContractParameters, - WriteContractReturnType, } from "viem"; -import { writeContract } from "viem/contract"; +import { simulateContract } from "viem/contract"; import { solmateErc721ABI as solmateERC721 } from "../../generated.js"; import type { BaseERC721 } from "../types.js"; @@ -17,42 +16,48 @@ export type ERC721ApproveParameters = { spender: Address; }; -export type WriteERC721ApproveParameters< +export type SimulateERC721ApproveParameters< TChain extends Chain | undefined = Chain, - TAccount extends Account | undefined = Account | undefined, TChainOverride extends Chain | undefined = Chain | undefined, > = Omit< - WriteContractParameters< + SimulateContractParameters< typeof solmateERC721, "approve", TChain, - TAccount, TChainOverride >, "args" | "address" | "abi" | "functionName" > & { args: ERC721ApproveParameters }; -export const writeERC721Approve = < +export type SimulateERC721ApproveReturnType< + TChain extends Chain | undefined, + TChainOverride extends Chain | undefined = undefined, +> = SimulateContractReturnType< + typeof solmateERC721, + "approve", + TChain, + TChainOverride +>; + +export const simulateERC721Approve = < TChain extends Chain | undefined, - TAccount extends Account | undefined, TChainOverride extends Chain | undefined, >( - client: Client, + client: Client, { args: { erc721, spender, id }, ...request - }: WriteERC721ApproveParameters, -): Promise => - writeContract(client, { + }: SimulateERC721ApproveParameters, +): Promise> => + simulateContract(client, { address: erc721.address, abi: solmateERC721, functionName: "approve", args: [spender, id], ...request, - } as unknown as WriteContractParameters< + } as unknown as SimulateContractParameters< typeof solmateERC721, "approve", TChain, - TAccount, TChainOverride >); diff --git a/packages/core/src/erc721/walletActions/writeERC721SetApprovalForAll.test.ts b/packages/core/src/erc721/walletActions/simulateERC721SetApprovalForAll.test.ts similarity index 88% rename from packages/core/src/erc721/walletActions/writeERC721SetApprovalForAll.test.ts rename to packages/core/src/erc721/walletActions/simulateERC721SetApprovalForAll.test.ts index 12462e5..1ffa542 100644 --- a/packages/core/src/erc721/walletActions/writeERC721SetApprovalForAll.test.ts +++ b/packages/core/src/erc721/walletActions/simulateERC721SetApprovalForAll.test.ts @@ -9,7 +9,7 @@ import { erc721ABI } from "../../generated.js"; import { getERC721IsApprovedForAll } from "../publicActions/getERC721IsApprovedForAll.js"; import type { ERC721 } from "../types.js"; import { createERC721 } from "../utils.js"; -import { writeERC721SetApprovalForAll } from "./writeERC721SetApprovalForAll.js"; +import { simulateERC721SetApprovalForAll } from "./simulateERC721SetApprovalForAll.js"; let id: Hex | undefined = undefined; @@ -44,13 +44,15 @@ beforeEach(async () => { }); test("set approval for all", async () => { - const hash = await writeERC721SetApprovalForAll(walletClient, { + const { request } = await simulateERC721SetApprovalForAll(publicClient, { args: { erc721, spender: BOB, approved: true, }, + account: ALICE, }); + const hash = await walletClient.writeContract(request); await publicClient.waitForTransactionReceipt({ hash }); diff --git a/packages/core/src/erc721/walletActions/writeERC721SetApprovalForAll.ts b/packages/core/src/erc721/walletActions/simulateERC721SetApprovalForAll.ts similarity index 56% rename from packages/core/src/erc721/walletActions/writeERC721SetApprovalForAll.ts rename to packages/core/src/erc721/walletActions/simulateERC721SetApprovalForAll.ts index d3e94ac..065da18 100644 --- a/packages/core/src/erc721/walletActions/writeERC721SetApprovalForAll.ts +++ b/packages/core/src/erc721/walletActions/simulateERC721SetApprovalForAll.ts @@ -1,13 +1,12 @@ import type { - Account, Address, Chain, Client, + SimulateContractParameters, + SimulateContractReturnType, Transport, - WriteContractParameters, - WriteContractReturnType, } from "viem"; -import { writeContract } from "viem/contract"; +import { simulateContract } from "viem/contract"; import { solmateErc721ABI as solmateERC721 } from "../../generated.js"; import type { BaseERC721 } from "../types.js"; @@ -17,42 +16,48 @@ export type ERC721SetApprovalForAllParameters = { approved: boolean; }; -export type WriteERC721SetApprovalForAllParameters< +export type SimulateERC721SetApprovalForAllParameters< TChain extends Chain | undefined = Chain, - TAccount extends Account | undefined = Account | undefined, TChainOverride extends Chain | undefined = Chain | undefined, > = Omit< - WriteContractParameters< + SimulateContractParameters< typeof solmateERC721, "setApprovalForAll", TChain, - TAccount, TChainOverride >, "args" | "address" | "abi" | "functionName" > & { args: ERC721SetApprovalForAllParameters }; -export const writeERC721SetApprovalForAll = < +export type SimulateERC721SetApprovalForAllReturnType< + TChain extends Chain | undefined, + TChainOverride extends Chain | undefined = undefined, +> = SimulateContractReturnType< + typeof solmateERC721, + "setApprovalForAll", + TChain, + TChainOverride +>; + +export const simulateERC721SetApprovalForAll = < TChain extends Chain | undefined, - TAccount extends Account | undefined, TChainOverride extends Chain | undefined, >( - client: Client, + client: Client, { args: { erc721, spender, approved }, ...request - }: WriteERC721SetApprovalForAllParameters, -): Promise => - writeContract(client, { + }: SimulateERC721SetApprovalForAllParameters, +): Promise> => + simulateContract(client, { address: erc721.address, abi: solmateERC721, functionName: "setApprovalForAll", args: [spender, approved], ...request, - } as unknown as WriteContractParameters< + } as unknown as SimulateContractParameters< typeof solmateERC721, "setApprovalForAll", TChain, - TAccount, TChainOverride >); diff --git a/packages/core/src/erc721/walletActions/writeERC721Transfer.test.ts b/packages/core/src/erc721/walletActions/simulateERC721Transfer.test.ts similarity index 81% rename from packages/core/src/erc721/walletActions/writeERC721Transfer.test.ts rename to packages/core/src/erc721/walletActions/simulateERC721Transfer.test.ts index ba3e76e..87fe322 100644 --- a/packages/core/src/erc721/walletActions/writeERC721Transfer.test.ts +++ b/packages/core/src/erc721/walletActions/simulateERC721Transfer.test.ts @@ -9,7 +9,7 @@ import { erc721ABI } from "../../generated.js"; import { getERC721OwnerOf } from "../publicActions/getERC721OwnerOf.js"; import type { ERC721 } from "../types.js"; import { createERC721 } from "../utils.js"; -import { writeERC721Transfer } from "./writeERC721Transfer.js"; +import { simulateERC721Transfer } from "./simulateERC721Transfer.js"; let id: Hex | undefined = undefined; @@ -44,41 +44,47 @@ beforeEach(async () => { }); test("can transfer", async () => { - const hash = await writeERC721Transfer(walletClient, { + const { request } = await simulateERC721Transfer(publicClient, { args: { to: BOB, erc721, id: 0n, }, + account: ALICE, }); + const hash = await walletClient.writeContract(request); await publicClient.waitForTransactionReceipt({ hash }); expect(await getERC721OwnerOf(publicClient, { erc721, id: 0n })).toBe(BOB); }); test("can transfer safe", async () => { - const hash = await writeERC721Transfer(walletClient, { + const { request } = await simulateERC721Transfer(publicClient, { args: { to: BOB, erc721, id: 0n, data: "safe", }, + account: ALICE, }); + const hash = await walletClient.writeContract(request); await publicClient.waitForTransactionReceipt({ hash }); expect(await getERC721OwnerOf(publicClient, { erc721, id: 0n })).toBe(BOB); }); test("can transfer data", async () => { - const hash = await writeERC721Transfer(walletClient, { + const { request } = await simulateERC721Transfer(publicClient, { args: { to: BOB, erc721, id: 0n, data: "0x", }, + account: ALICE, }); + const hash = await walletClient.writeContract(request); await publicClient.waitForTransactionReceipt({ hash }); expect(await getERC721OwnerOf(publicClient, { erc721, id: 0n })).toBe(BOB); diff --git a/packages/core/src/erc721/walletActions/writeERC721Transfer.ts b/packages/core/src/erc721/walletActions/simulateERC721Transfer.ts similarity index 73% rename from packages/core/src/erc721/walletActions/writeERC721Transfer.ts rename to packages/core/src/erc721/walletActions/simulateERC721Transfer.ts index 5a9b987..4198ffe 100644 --- a/packages/core/src/erc721/walletActions/writeERC721Transfer.ts +++ b/packages/core/src/erc721/walletActions/simulateERC721Transfer.ts @@ -1,14 +1,13 @@ import type { - Account, Address, Chain, Client, Hex, + SimulateContractParameters, + SimulateContractReturnType, Transport, - WriteContractParameters, - WriteContractReturnType, } from "viem"; -import { writeContract } from "viem/contract"; +import { simulateContract } from "viem/contract"; import { solmateErc721ABI as solmateERC721 } from "../../generated.js"; import type { BaseERC721 } from "../types.js"; @@ -20,34 +19,41 @@ export type ERC721TransferParameters = { data?: "safe" | Hex; }; -export type WriteERC721TransferParameters< +export type SimulateERC721TransferParameters< TChain extends Chain | undefined = Chain, - TAccount extends Account | undefined = Account | undefined, TChainOverride extends Chain | undefined = Chain | undefined, > = Omit< - WriteContractParameters< + SimulateContractParameters< typeof solmateERC721, "transferFrom", TChain, - TAccount, TChainOverride >, "args" | "address" | "abi" | "functionName" > & { args: ERC721TransferParameters }; -export const writeERC721Transfer = < +export type SimulateERC721TransferReturnType< + TChain extends Chain | undefined, + TChainOverride extends Chain | undefined = undefined, +> = SimulateContractReturnType< + typeof solmateERC721, + "transferFrom", + TChain, + TChainOverride +>; + +export const simulateERC721Transfer = < TChain extends Chain | undefined, - TAccount extends Account | undefined, TChainOverride extends Chain | undefined, >( - client: Client, + client: Client, { args: { erc721, from, to, data, id }, ...request - }: WriteERC721TransferParameters, -): Promise => + }: SimulateERC721TransferParameters, +) => data === undefined - ? writeContract(client, { + ? simulateContract(client, { address: erc721.address, abi: solmateERC721, functionName: "transferFrom", @@ -61,15 +67,14 @@ export const writeERC721Transfer = < id, ], ...request, - } as unknown as WriteContractParameters< + } as unknown as SimulateContractParameters< typeof solmateERC721, "transferFrom", TChain, - TAccount, TChainOverride >) : data === "safe" - ? writeContract(client, { + ? simulateContract(client, { address: erc721.address, abi: solmateERC721, functionName: "safeTransferFrom", @@ -83,14 +88,13 @@ export const writeERC721Transfer = < id, ], ...request, - } as unknown as WriteContractParameters< + } as unknown as SimulateContractParameters< typeof solmateERC721, "safeTransferFrom", TChain, - TAccount, TChainOverride >) - : writeContract(client, { + : simulateContract(client, { address: erc721.address, abi: solmateERC721, functionName: "safeTransferFrom", @@ -105,10 +109,9 @@ export const writeERC721Transfer = < data, ], ...request, - } as unknown as WriteContractParameters< + } as unknown as SimulateContractParameters< typeof solmateERC721, "safeTransferFrom", TChain, - TAccount, TChainOverride >); diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index b583b60..c95dfeb 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -57,10 +57,10 @@ export { getERC20TotalSupply, getIsERC20Permit, signERC20Permit, - writeERC20Approve, - writeERC20Permit, - writeERC20Transfer, - writeERC20TransferFrom, + simulateERC20Approve, + simulateERC20Permit, + simulateERC20Transfer, + simulateERC20TransferFrom, } from "./erc20/index.js"; export { @@ -80,9 +80,9 @@ export { getERC721OwnerOf, getERC721SupportsInterface, getERC721TokenURI, - writeERC721Transfer, - writeERC721Approve, - writeERC721SetApprovalForAll, + simulateERC721Transfer, + simulateERC721Approve, + simulateERC721SetApprovalForAll, } from "./erc721/index.js"; export { @@ -96,9 +96,9 @@ export { getERC1155BalanceOf, getERC1155IsApprovedForAll, getERC1155URI, - writeERC1155Transfer, - writeERC1155TransferBatch, - writeERC1155SetApprovalForAll, + simulateERC1155Transfer, + simulateERC1155TransferBatch, + simulateERC1155SetApprovalForAll, } from "./erc1155/index.js"; export { @@ -161,8 +161,8 @@ export { type WETH, createWETH, weth9ABI, - writeWETHDeposit, - writeWETHWithdraw, + simulateWETHDeposit, + simulateWETHWithdraw, } from "./weth/index.js"; export { publicActionReverseMirage } from "./decorator/publicActions.js"; diff --git a/packages/core/src/weth/index.ts b/packages/core/src/weth/index.ts index 93e402b..27e7cb5 100644 --- a/packages/core/src/weth/index.ts +++ b/packages/core/src/weth/index.ts @@ -4,5 +4,5 @@ export { createWETH } from "./utils.js"; export { weth9ABI } from "../generated.js"; -export { writeWETHDeposit } from "./walletActions/writeWETHDeposit.js"; -export { writeWETHWithdraw } from "./walletActions/writeWETHWithdraw.js"; +export { simulateWETHDeposit } from "./walletActions/simulateWETHDeposit.js"; +export { simulateWETHWithdraw } from "./walletActions/simulateWETHWithdraw.js"; diff --git a/packages/core/src/weth/walletActions/writeWETHDeposit.test.ts b/packages/core/src/weth/walletActions/simulateWETHDeposit.test.ts similarity index 86% rename from packages/core/src/weth/walletActions/writeWETHDeposit.test.ts rename to packages/core/src/weth/walletActions/simulateWETHDeposit.test.ts index cf92841..91d1320 100644 --- a/packages/core/src/weth/walletActions/writeWETHDeposit.test.ts +++ b/packages/core/src/weth/walletActions/simulateWETHDeposit.test.ts @@ -10,7 +10,7 @@ import { getERC20BalanceOf } from "../../erc20/publicActions/getERC20BalanceOf.j import { weth9ABI } from "../../generated.js"; import type { WETH } from "../types.js"; import { createWETH } from "../utils.js"; -import { writeWETHDeposit } from "./writeWETHDeposit.js"; +import { simulateWETHDeposit } from "./simulateWETHDeposit.js"; let id: Hex | undefined = undefined; @@ -35,11 +35,14 @@ beforeEach(async () => { id = await testClient.snapshot(); }); -test("write deposit", async () => { - const hash = await writeWETHDeposit(walletClient, { +test("simulate deposit", async () => { + const { request } = await simulateWETHDeposit(publicClient, { args: { amount: createAmountFromString(weth, "1") }, + account: ALICE, }); + const hash = await walletClient.writeContract(request); + await publicClient.waitForTransactionReceipt({ hash }); const balance = await getERC20BalanceOf(publicClient, { diff --git a/packages/core/src/weth/walletActions/writeWETHDeposit.ts b/packages/core/src/weth/walletActions/simulateWETHDeposit.ts similarity index 56% rename from packages/core/src/weth/walletActions/writeWETHDeposit.ts rename to packages/core/src/weth/walletActions/simulateWETHDeposit.ts index ee4e618..615df1a 100644 --- a/packages/core/src/weth/walletActions/writeWETHDeposit.ts +++ b/packages/core/src/weth/walletActions/simulateWETHDeposit.ts @@ -1,54 +1,59 @@ import type { - Account, Chain, Client, + SimulateContractParameters, + SimulateContractReturnType, Transport, - WriteContractParameters, - WriteContractReturnType, } from "viem"; -import { writeContract } from "viem/contract"; +import { simulateContract } from "viem/contract"; import type { ERC20Amount } from "../../erc20/types.js"; import { weth9ABI } from "../../generated.js"; import type { WETH } from "../types.js"; export type WETHDepositParameters = { amount: ERC20Amount }; -export type WriteWETHDepositParameters< +export type SimulateWETHDepositParameters< TChain extends Chain | undefined = Chain, - TAccount extends Account | undefined = Account | undefined, TChainOverride extends Chain | undefined = Chain | undefined, > = Omit< - WriteContractParameters< + SimulateContractParameters< typeof weth9ABI, "deposit", TChain, - TAccount, TChainOverride >, "args" | "address" | "abi" | "functionName" | "value" > & { args: WETHDepositParameters }; -export const writeWETHDeposit = < +export type SimulateWETHDepositReturnType< + TChain extends Chain | undefined, + TChainOverride extends Chain | undefined = undefined, +> = SimulateContractReturnType< + typeof weth9ABI, + "deposit", + TChain, + TChainOverride +>; + +export const simulateWETHDeposit = < TChain extends Chain | undefined, - TAccount extends Account | undefined, TChainOverride extends Chain | undefined, >( - client: Client, + client: Client, { args: { amount }, ...request - }: WriteWETHDepositParameters, -): Promise => - writeContract(client, { + }: SimulateWETHDepositParameters, +): Promise> => + simulateContract(client, { address: amount.token.address, abi: weth9ABI, functionName: "deposit", value: amount.amount, ...request, - } as unknown as WriteContractParameters< + } as unknown as SimulateContractParameters< typeof weth9ABI, "deposit", TChain, - TAccount, TChainOverride >); diff --git a/packages/core/src/weth/walletActions/writeWETHWithdraw.test.ts b/packages/core/src/weth/walletActions/simulateWETHWithdraw.test.ts similarity index 74% rename from packages/core/src/weth/walletActions/writeWETHWithdraw.test.ts rename to packages/core/src/weth/walletActions/simulateWETHWithdraw.test.ts index 32a0f3e..4499d62 100644 --- a/packages/core/src/weth/walletActions/writeWETHWithdraw.test.ts +++ b/packages/core/src/weth/walletActions/simulateWETHWithdraw.test.ts @@ -10,8 +10,8 @@ import { getERC20BalanceOf } from "../../erc20/publicActions/getERC20BalanceOf.j import { weth9ABI } from "../../generated.js"; import type { WETH } from "../types.js"; import { createWETH } from "../utils.js"; -import { writeWETHDeposit } from "./writeWETHDeposit.js"; -import { writeWETHWithdraw } from "./writeWETHWithdraw.js"; +import { simulateWETHDeposit } from "./simulateWETHDeposit.js"; +import { simulateWETHWithdraw } from "./simulateWETHWithdraw.js"; let id: Hex | undefined = undefined; @@ -36,17 +36,25 @@ beforeEach(async () => { id = await testClient.snapshot(); }); -test("write withdraw", async () => { - const hash = await writeWETHDeposit(publicClient, { +test("simulate withdraw", async () => { + const { request } = await simulateWETHDeposit(publicClient, { args: { amount: createAmountFromString(weth, "1") }, account: ALICE, }); + const hash = await walletClient.writeContract(request); + await publicClient.waitForTransactionReceipt({ hash }); - const requestHash = await writeWETHWithdraw(walletClient, { - args: { amount: createAmountFromString(weth, "1") }, - }); + const { request: withdrawRequest } = await simulateWETHWithdraw( + publicClient, + { + args: { amount: createAmountFromString(weth, "1") }, + account: ALICE, + }, + ); + + const requestHash = await walletClient.writeContract(withdrawRequest); await publicClient.waitForTransactionReceipt({ hash: requestHash }); diff --git a/packages/core/src/weth/walletActions/writeWETHWithdraw.ts b/packages/core/src/weth/walletActions/simulateWETHWithdraw.ts similarity index 55% rename from packages/core/src/weth/walletActions/writeWETHWithdraw.ts rename to packages/core/src/weth/walletActions/simulateWETHWithdraw.ts index 7e4896d..f99f2bf 100644 --- a/packages/core/src/weth/walletActions/writeWETHWithdraw.ts +++ b/packages/core/src/weth/walletActions/simulateWETHWithdraw.ts @@ -1,54 +1,59 @@ import type { - Account, Chain, Client, + SimulateContractParameters, + SimulateContractReturnType, Transport, - WriteContractParameters, - WriteContractReturnType, } from "viem"; -import { writeContract } from "viem/contract"; +import { simulateContract } from "viem/contract"; import type { ERC20Amount } from "../../erc20/types.js"; import { weth9ABI } from "../../generated.js"; import type { WETH } from "../types.js"; export type WETHWithdrawParameters = { amount: ERC20Amount }; -export type WriteWETHWithdrawParameters< +export type SimulateWETHWithdrawParameters< TChain extends Chain | undefined = Chain, - TAccount extends Account | undefined = Account | undefined, TChainOverride extends Chain | undefined = Chain | undefined, > = Omit< - WriteContractParameters< + SimulateContractParameters< typeof weth9ABI, "withdraw", TChain, - TAccount, TChainOverride >, "args" | "address" | "abi" | "functionName" > & { args: WETHWithdrawParameters }; -export const writeWETHWithdraw = < +export type SimulateWETHWithdrawReturnType< + TChain extends Chain | undefined, + TChainOverride extends Chain | undefined = undefined, +> = SimulateContractReturnType< + typeof weth9ABI, + "withdraw", + TChain, + TChainOverride +>; + +export const simulateWETHWithdraw = < TChain extends Chain | undefined, - TAccount extends Account | undefined, TChainOverride extends Chain | undefined, >( - client: Client, + client: Client, { args: { amount }, ...request - }: WriteWETHWithdrawParameters, -): Promise => - writeContract(client, { + }: SimulateWETHWithdrawParameters, +): Promise> => + simulateContract(client, { address: amount.token.address, abi: weth9ABI, functionName: "withdraw", args: [amount.amount], ...request, - } as unknown as WriteContractParameters< + } as unknown as SimulateContractParameters< typeof weth9ABI, "withdraw", TChain, - TAccount, TChainOverride >); diff --git a/packages/core/tsup.config.ts b/packages/core/tsup.config.ts index 425cf9b..c427bc3 100644 --- a/packages/core/tsup.config.ts +++ b/packages/core/tsup.config.ts @@ -9,6 +9,4 @@ export default defineConfig({ sourcemap: true, dts: true, clean: true, - minify: true, - treeshake: true, }); From 459498d4eb9f60dfdf4290d998b78e09d128705b Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Tue, 26 Sep 2023 15:40:52 -0400 Subject: [PATCH 23/42] minify --- packages/core/tsup.config.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/core/tsup.config.ts b/packages/core/tsup.config.ts index c427bc3..425cf9b 100644 --- a/packages/core/tsup.config.ts +++ b/packages/core/tsup.config.ts @@ -9,4 +9,6 @@ export default defineConfig({ sourcemap: true, dts: true, clean: true, + minify: true, + treeshake: true, }); From c385d61a1447d1ba92d64d1e0de0a4918e331da9 Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Tue, 26 Sep 2023 16:33:50 -0400 Subject: [PATCH 24/42] update readme --- README.md | 71 ++++++++- packages/core/package.json | 20 ++- pnpm-lock.yaml | 289 +++++++++++++++++++++++++++++++++++++ 3 files changed, 373 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ef65f7d..e140ba2 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Application level typescript utilities for Ethereum. ## Features -- ✅ ~30x faster than `@uniswap/sdk-core` +- ✅ 10x-100x faster, 10.3x smaller than [`@uniswap/sdk-core`](https://github.com/uniswap/sdk-core) - ✅ Abstactions for most commonly used token standards - ✅ Supports `permit` - ✅ Extensible to build apps and libraries @@ -23,7 +23,8 @@ Application level typescript utilities for Ethereum. ```ts import { createPublicClient, http } from 'viem' -import {publicActions, amountToNumber} from 'reverse-mirage' +import { mainnet } from 'viem/chains' +import { publicActions, amountToNumber } from 'reverse-mirage' export const publicClient = createPublicClient({ chain: mainnet, @@ -33,9 +34,11 @@ export const publicClient = createPublicClient({ // read token metadata const usdc = await publicClient.getERC20({ address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // usdc + id: mainnet.id }) console.log(usdc.decimals) // 6 +console.log(usdc.name) // USD Coin // read a balance const vitalikBalance = await publicClient.getERC20Balance({ @@ -43,5 +46,69 @@ const vitalikBalance = await publicClient.getERC20Balance({ address: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045' // vitalik }) +console.log(vitalikBalance.amount) // 420690000n console.log(amountToNumber(vitalikBalance)) // 420.69 ``` + +## Installation + +```sh +npm i reverse-mirage +``` + +## Benchmarks + +Benchmarks are done with [mitata](https://github.com/evanwashere/mitata). To reproduce: + +```sh +cd packages/core/ +bun run src/amount/utils.bench.ts +``` + +### Results + +```sh + +• amount add +------------------------------------------------------ ----------------------------- +reverse mirage 70.6 ns/iter (67.13 ns … 154.07 ns) 68.33 ns 124.84 ns 133.01 ns +uniswap 576.84 ns/iter (549.89 ns … 802.03 ns) 606.01 ns 802.03 ns 802.03 ns + +summary for amount add + reverse mirage + 8.17x faster than uniswap + +• amount equalTo +------------------------------------------------------ ----------------------------- +reverse mirage 11.33 ns/iter (11.2 ns … 15.59 ns) 11.22 ns 13.56 ns 13.99 ns +uniswap 120.47 ns/iter (114.63 ns … 202.19 ns) 117.75 ns 189.68 ns 192.36 ns + +summary for amount equalTo + reverse mirage + 10.63x faster than uniswap + +• amount to number +------------------------------------------------------ ----------------------------- +reverse mirage 9.42 ns/iter (9.3 ns … 14.22 ns) 9.32 ns 11.57 ns 12.18 ns +uniswap 1.28 µs/iter (1.22 µs … 1.54 µs) 1.29 µs 1.54 µs 1.54 µs + +summary for amount to number + reverse mirage + 136.14x faster than uniswap + +• amount to significant +------------------------------------------------------ ----------------------------- +reverse mirage 70.7 ns/iter (68.35 ns … 144.63 ns) 71.15 ns 77.24 ns 125.2 ns +uniswap 2.12 µs/iter (2 µs … 2.96 µs) 2.11 µs 2.96 µs 2.96 µs + +summary for amount to significant + reverse mirage + 30.03x faster than uniswap +``` + +## Bundle Size + +```sh +reverse-mirage: 5.17 kB +@uniswap/sdk-core: 53.4 kB +``` diff --git a/packages/core/package.json b/packages/core/package.json index dd857b5..72e18e3 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -26,11 +26,19 @@ "test:ci": "CI=true vitest --coverage", "test:cov": "vitest --coverage" }, - "keywords": [ - "eth", - "ethereum", - "dapps", - "web3" + "keywords": ["eth", "ethereum", "dapps", "web3"], + "size-limit": [ + { + "name": "reverse-mirage (cjs)", + "path": "./dist/index.cjs", + "limit": "7 kB" + }, + { + "name": "reverse-mirage", + "path": "./dist/index.js", + "limit": "7 kB", + "import": "*" + } ], "author": "Kyle Scott", "license": "MIT", @@ -50,11 +58,13 @@ }, "devDependencies": { "@biomejs/biome": "^1.2.2", + "@size-limit/preset-small-lib": "^9.0.0", "@uniswap/sdk-core": "^4.0.7", "@viem/anvil": "^0.0.6", "@vitest/coverage-v8": "^0.34.4", "bun": "^1.0.2", "mitata": "^0.1.6", + "size-limit": "^9.0.0", "tsup": "^7.2.0", "typescript": "^5.2.2", "viem": "^1.10.14", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e5b900a..0bbba74 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -112,6 +112,9 @@ importers: '@biomejs/biome': specifier: ^1.2.2 version: 1.2.2 + '@size-limit/preset-small-lib': + specifier: ^9.0.0 + version: 9.0.0(size-limit@9.0.0) '@uniswap/sdk-core': specifier: ^4.0.7 version: 4.0.7 @@ -127,6 +130,9 @@ importers: mitata: specifier: ^0.1.6 version: 0.1.6 + size-limit: + specifier: ^9.0.0 + version: 9.0.0 tsup: specifier: ^7.2.0 version: 7.2.0(typescript@5.2.2) @@ -831,6 +837,15 @@ packages: dev: true optional: true + /@esbuild/android-arm64@0.19.3: + resolution: {integrity: sha512-w+Akc0vv5leog550kjJV9Ru+MXMR2VuMrui3C61mnysim0gkFCPOUTAfzTP0qX+HpN9Syu3YA3p1hf3EPqObRw==} + engines: {node: '>=12'} + cpu: [arm64] + os: [android] + requiresBuild: true + dev: true + optional: true + /@esbuild/android-arm@0.16.17: resolution: {integrity: sha512-N9x1CMXVhtWEAMS7pNNONyA14f71VPQN9Cnavj1XQh6T7bskqiLLrSca4O0Vr8Wdcga943eThxnVp3JLnBMYtw==} engines: {node: '>=12'} @@ -849,6 +864,15 @@ packages: dev: true optional: true + /@esbuild/android-arm@0.19.3: + resolution: {integrity: sha512-Lemgw4io4VZl9GHJmjiBGzQ7ONXRfRPHcUEerndjwiSkbxzrpq0Uggku5MxxrXdwJ+pTj1qyw4jwTu7hkPsgIA==} + engines: {node: '>=12'} + cpu: [arm] + os: [android] + requiresBuild: true + dev: true + optional: true + /@esbuild/android-x64@0.16.17: resolution: {integrity: sha512-a3kTv3m0Ghh4z1DaFEuEDfz3OLONKuFvI4Xqczqx4BqLyuFaFkuaG4j2MtA6fuWEFeC5x9IvqnX7drmRq/fyAQ==} engines: {node: '>=12'} @@ -867,6 +891,15 @@ packages: dev: true optional: true + /@esbuild/android-x64@0.19.3: + resolution: {integrity: sha512-FKQJKkK5MXcBHoNZMDNUAg1+WcZlV/cuXrWCoGF/TvdRiYS4znA0m5Il5idUwfxrE20bG/vU1Cr5e1AD6IEIjQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [android] + requiresBuild: true + dev: true + optional: true + /@esbuild/darwin-arm64@0.16.17: resolution: {integrity: sha512-/2agbUEfmxWHi9ARTX6OQ/KgXnOWfsNlTeLcoV7HSuSTv63E4DqtAc+2XqGw1KHxKMHGZgbVCZge7HXWX9Vn+w==} engines: {node: '>=12'} @@ -885,6 +918,15 @@ packages: dev: true optional: true + /@esbuild/darwin-arm64@0.19.3: + resolution: {integrity: sha512-kw7e3FXU+VsJSSSl2nMKvACYlwtvZB8RUIeVShIEY6PVnuZ3c9+L9lWB2nWeeKWNNYDdtL19foCQ0ZyUL7nqGw==} + engines: {node: '>=12'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + /@esbuild/darwin-x64@0.16.17: resolution: {integrity: sha512-2By45OBHulkd9Svy5IOCZt376Aa2oOkiE9QWUK9fe6Tb+WDr8hXL3dpqi+DeLiMed8tVXspzsTAvd0jUl96wmg==} engines: {node: '>=12'} @@ -903,6 +945,15 @@ packages: dev: true optional: true + /@esbuild/darwin-x64@0.19.3: + resolution: {integrity: sha512-tPfZiwF9rO0jW6Jh9ipi58N5ZLoSjdxXeSrAYypy4psA2Yl1dAMhM71KxVfmjZhJmxRjSnb29YlRXXhh3GqzYw==} + engines: {node: '>=12'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + /@esbuild/freebsd-arm64@0.16.17: resolution: {integrity: sha512-mt+cxZe1tVx489VTb4mBAOo2aKSnJ33L9fr25JXpqQqzbUIw/yzIzi+NHwAXK2qYV1lEFp4OoVeThGjUbmWmdw==} engines: {node: '>=12'} @@ -921,6 +972,15 @@ packages: dev: true optional: true + /@esbuild/freebsd-arm64@0.19.3: + resolution: {integrity: sha512-ERDyjOgYeKe0Vrlr1iLrqTByB026YLPzTytDTz1DRCYM+JI92Dw2dbpRHYmdqn6VBnQ9Bor6J8ZlNwdZdxjlSg==} + engines: {node: '>=12'} + cpu: [arm64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + /@esbuild/freebsd-x64@0.16.17: resolution: {integrity: sha512-8ScTdNJl5idAKjH8zGAsN7RuWcyHG3BAvMNpKOBaqqR7EbUhhVHOqXRdL7oZvz8WNHL2pr5+eIT5c65kA6NHug==} engines: {node: '>=12'} @@ -939,6 +999,15 @@ packages: dev: true optional: true + /@esbuild/freebsd-x64@0.19.3: + resolution: {integrity: sha512-nXesBZ2Ad1qL+Rm3crN7NmEVJ5uvfLFPLJev3x1j3feCQXfAhoYrojC681RhpdOph8NsvKBBwpYZHR7W0ifTTA==} + engines: {node: '>=12'} + cpu: [x64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + /@esbuild/linux-arm64@0.16.17: resolution: {integrity: sha512-7S8gJnSlqKGVJunnMCrXHU9Q8Q/tQIxk/xL8BqAP64wchPCTzuM6W3Ra8cIa1HIflAvDnNOt2jaL17vaW+1V0g==} engines: {node: '>=12'} @@ -957,6 +1026,15 @@ packages: dev: true optional: true + /@esbuild/linux-arm64@0.19.3: + resolution: {integrity: sha512-qXvYKmXj8GcJgWq3aGvxL/JG1ZM3UR272SdPU4QSTzD0eymrM7leiZH77pvY3UetCy0k1xuXZ+VPvoJNdtrsWQ==} + engines: {node: '>=12'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + /@esbuild/linux-arm@0.16.17: resolution: {integrity: sha512-iihzrWbD4gIT7j3caMzKb/RsFFHCwqqbrbH9SqUSRrdXkXaygSZCZg1FybsZz57Ju7N/SHEgPyaR0LZ8Zbe9gQ==} engines: {node: '>=12'} @@ -975,6 +1053,15 @@ packages: dev: true optional: true + /@esbuild/linux-arm@0.19.3: + resolution: {integrity: sha512-zr48Cg/8zkzZCzDHNxXO/89bf9e+r4HtzNUPoz4GmgAkF1gFAFmfgOdCbR8zMbzFDGb1FqBBhdXUpcTQRYS1cQ==} + engines: {node: '>=12'} + cpu: [arm] + os: [linux] + requiresBuild: true + dev: true + optional: true + /@esbuild/linux-ia32@0.16.17: resolution: {integrity: sha512-kiX69+wcPAdgl3Lonh1VI7MBr16nktEvOfViszBSxygRQqSpzv7BffMKRPMFwzeJGPxcio0pdD3kYQGpqQ2SSg==} engines: {node: '>=12'} @@ -993,6 +1080,15 @@ packages: dev: true optional: true + /@esbuild/linux-ia32@0.19.3: + resolution: {integrity: sha512-7XlCKCA0nWcbvYpusARWkFjRQNWNGlt45S+Q18UeS///K6Aw8bB2FKYe9mhVWy/XLShvCweOLZPrnMswIaDXQA==} + engines: {node: '>=12'} + cpu: [ia32] + os: [linux] + requiresBuild: true + dev: true + optional: true + /@esbuild/linux-loong64@0.16.17: resolution: {integrity: sha512-dTzNnQwembNDhd654cA4QhbS9uDdXC3TKqMJjgOWsC0yNCbpzfWoXdZvp0mY7HU6nzk5E0zpRGGx3qoQg8T2DQ==} engines: {node: '>=12'} @@ -1011,6 +1107,15 @@ packages: dev: true optional: true + /@esbuild/linux-loong64@0.19.3: + resolution: {integrity: sha512-qGTgjweER5xqweiWtUIDl9OKz338EQqCwbS9c2Bh5jgEH19xQ1yhgGPNesugmDFq+UUSDtWgZ264st26b3de8A==} + engines: {node: '>=12'} + cpu: [loong64] + os: [linux] + requiresBuild: true + dev: true + optional: true + /@esbuild/linux-mips64el@0.16.17: resolution: {integrity: sha512-ezbDkp2nDl0PfIUn0CsQ30kxfcLTlcx4Foz2kYv8qdC6ia2oX5Q3E/8m6lq84Dj/6b0FrkgD582fJMIfHhJfSw==} engines: {node: '>=12'} @@ -1029,6 +1134,15 @@ packages: dev: true optional: true + /@esbuild/linux-mips64el@0.19.3: + resolution: {integrity: sha512-gy1bFskwEyxVMFRNYSvBauDIWNggD6pyxUksc0MV9UOBD138dKTzr8XnM2R4mBsHwVzeuIH8X5JhmNs2Pzrx+A==} + engines: {node: '>=12'} + cpu: [mips64el] + os: [linux] + requiresBuild: true + dev: true + optional: true + /@esbuild/linux-ppc64@0.16.17: resolution: {integrity: sha512-dzS678gYD1lJsW73zrFhDApLVdM3cUF2MvAa1D8K8KtcSKdLBPP4zZSLy6LFZ0jYqQdQ29bjAHJDgz0rVbLB3g==} engines: {node: '>=12'} @@ -1047,6 +1161,15 @@ packages: dev: true optional: true + /@esbuild/linux-ppc64@0.19.3: + resolution: {integrity: sha512-UrYLFu62x1MmmIe85rpR3qou92wB9lEXluwMB/STDzPF9k8mi/9UvNsG07Tt9AqwPQXluMQ6bZbTzYt01+Ue5g==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [linux] + requiresBuild: true + dev: true + optional: true + /@esbuild/linux-riscv64@0.16.17: resolution: {integrity: sha512-ylNlVsxuFjZK8DQtNUwiMskh6nT0vI7kYl/4fZgV1llP5d6+HIeL/vmmm3jpuoo8+NuXjQVZxmKuhDApK0/cKw==} engines: {node: '>=12'} @@ -1065,6 +1188,15 @@ packages: dev: true optional: true + /@esbuild/linux-riscv64@0.19.3: + resolution: {integrity: sha512-9E73TfyMCbE+1AwFOg3glnzZ5fBAFK4aawssvuMgCRqCYzE0ylVxxzjEfut8xjmKkR320BEoMui4o/t9KA96gA==} + engines: {node: '>=12'} + cpu: [riscv64] + os: [linux] + requiresBuild: true + dev: true + optional: true + /@esbuild/linux-s390x@0.16.17: resolution: {integrity: sha512-gzy7nUTO4UA4oZ2wAMXPNBGTzZFP7mss3aKR2hH+/4UUkCOyqmjXiKpzGrY2TlEUhbbejzXVKKGazYcQTZWA/w==} engines: {node: '>=12'} @@ -1083,6 +1215,15 @@ packages: dev: true optional: true + /@esbuild/linux-s390x@0.19.3: + resolution: {integrity: sha512-LlmsbuBdm1/D66TJ3HW6URY8wO6IlYHf+ChOUz8SUAjVTuaisfuwCOAgcxo3Zsu3BZGxmI7yt//yGOxV+lHcEA==} + engines: {node: '>=12'} + cpu: [s390x] + os: [linux] + requiresBuild: true + dev: true + optional: true + /@esbuild/linux-x64@0.16.17: resolution: {integrity: sha512-mdPjPxfnmoqhgpiEArqi4egmBAMYvaObgn4poorpUaqmvzzbvqbowRllQ+ZgzGVMGKaPkqUmPDOOFQRUFDmeUw==} engines: {node: '>=12'} @@ -1101,6 +1242,15 @@ packages: dev: true optional: true + /@esbuild/linux-x64@0.19.3: + resolution: {integrity: sha512-ogV0+GwEmvwg/8ZbsyfkYGaLACBQWDvO0Kkh8LKBGKj9Ru8VM39zssrnu9Sxn1wbapA2qNS6BiLdwJZGouyCwQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + /@esbuild/netbsd-x64@0.16.17: resolution: {integrity: sha512-/PzmzD/zyAeTUsduZa32bn0ORug+Jd1EGGAUJvqfeixoEISYpGnAezN6lnJoskauoai0Jrs+XSyvDhppCPoKOA==} engines: {node: '>=12'} @@ -1119,6 +1269,15 @@ packages: dev: true optional: true + /@esbuild/netbsd-x64@0.19.3: + resolution: {integrity: sha512-o1jLNe4uzQv2DKXMlmEzf66Wd8MoIhLNO2nlQBHLtWyh2MitDG7sMpfCO3NTcoTMuqHjfufgUQDFRI5C+xsXQw==} + engines: {node: '>=12'} + cpu: [x64] + os: [netbsd] + requiresBuild: true + dev: true + optional: true + /@esbuild/openbsd-x64@0.16.17: resolution: {integrity: sha512-2yaWJhvxGEz2RiftSk0UObqJa/b+rIAjnODJgv2GbGGpRwAfpgzyrg1WLK8rqA24mfZa9GvpjLcBBg8JHkoodg==} engines: {node: '>=12'} @@ -1137,6 +1296,15 @@ packages: dev: true optional: true + /@esbuild/openbsd-x64@0.19.3: + resolution: {integrity: sha512-AZJCnr5CZgZOdhouLcfRdnk9Zv6HbaBxjcyhq0StNcvAdVZJSKIdOiPB9az2zc06ywl0ePYJz60CjdKsQacp5Q==} + engines: {node: '>=12'} + cpu: [x64] + os: [openbsd] + requiresBuild: true + dev: true + optional: true + /@esbuild/sunos-x64@0.16.17: resolution: {integrity: sha512-xtVUiev38tN0R3g8VhRfN7Zl42YCJvyBhRKw1RJjwE1d2emWTVToPLNEQj/5Qxc6lVFATDiy6LjVHYhIPrLxzw==} engines: {node: '>=12'} @@ -1155,6 +1323,15 @@ packages: dev: true optional: true + /@esbuild/sunos-x64@0.19.3: + resolution: {integrity: sha512-Acsujgeqg9InR4glTRvLKGZ+1HMtDm94ehTIHKhJjFpgVzZG9/pIcWW/HA/DoMfEyXmANLDuDZ2sNrWcjq1lxw==} + engines: {node: '>=12'} + cpu: [x64] + os: [sunos] + requiresBuild: true + dev: true + optional: true + /@esbuild/win32-arm64@0.16.17: resolution: {integrity: sha512-ga8+JqBDHY4b6fQAmOgtJJue36scANy4l/rL97W+0wYmijhxKetzZdKOJI7olaBaMhWt8Pac2McJdZLxXWUEQw==} engines: {node: '>=12'} @@ -1173,6 +1350,15 @@ packages: dev: true optional: true + /@esbuild/win32-arm64@0.19.3: + resolution: {integrity: sha512-FSrAfjVVy7TifFgYgliiJOyYynhQmqgPj15pzLyJk8BUsnlWNwP/IAy6GAiB1LqtoivowRgidZsfpoYLZH586A==} + engines: {node: '>=12'} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + /@esbuild/win32-ia32@0.16.17: resolution: {integrity: sha512-WnsKaf46uSSF/sZhwnqE4L/F89AYNMiD4YtEcYekBt9Q7nj0DiId2XH2Ng2PHM54qi5oPrQ8luuzGszqi/veig==} engines: {node: '>=12'} @@ -1191,6 +1377,15 @@ packages: dev: true optional: true + /@esbuild/win32-ia32@0.19.3: + resolution: {integrity: sha512-xTScXYi12xLOWZ/sc5RBmMN99BcXp/eEf7scUC0oeiRoiT5Vvo9AycuqCp+xdpDyAU+LkrCqEpUS9fCSZF8J3Q==} + engines: {node: '>=12'} + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: true + optional: true + /@esbuild/win32-x64@0.16.17: resolution: {integrity: sha512-y+EHuSchhL7FjHgvQL/0fnnFmO4T1bhvWANX6gcnqTjtnKWbTvUMCpGnv2+t+31d7RzyEAYAd4u2fnIhHL6N/Q==} engines: {node: '>=12'} @@ -1209,6 +1404,15 @@ packages: dev: true optional: true + /@esbuild/win32-x64@0.19.3: + resolution: {integrity: sha512-FbUN+0ZRXsypPyWE2IwIkVjDkDnJoMJARWOcFZn4KPPli+QnKqF0z1anvfaYe3ev5HFCpRDLLBDHyOALLppWHw==} + engines: {node: '>=12'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + /@ethersproject/address@5.7.0: resolution: {integrity: sha512-9wYhYt7aghVGo758POM5nqcOMaE168Q6aRLJZwUmiqSrAungkG74gSSeKEIR7ukixesdRZGPgVqme6vmxs1fkA==} dependencies: @@ -1684,6 +1888,37 @@ packages: resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==} dev: true + /@size-limit/esbuild@9.0.0(size-limit@9.0.0): + resolution: {integrity: sha512-y3NY0inaFeLqV6SRXNVILhawQdQcODxF30qft6OalsrqtQtBjt++6ZeahYhUbrVexUEWRh6c7yPCe8RvHn8hlA==} + engines: {node: ^18.0.0 || >=20.0.0} + peerDependencies: + size-limit: 9.0.0 + dependencies: + esbuild: 0.19.3 + nanoid: 3.3.6 + size-limit: 9.0.0 + dev: true + + /@size-limit/file@9.0.0(size-limit@9.0.0): + resolution: {integrity: sha512-oM2UaH2FRq4q22k+R+P6xCpzET10T94LFdSjb9svVu/vOD7NaB9LGcG6se8TW1BExXiyXO4GEhLsBt3uMKM3qA==} + engines: {node: ^18.0.0 || >=20.0.0} + peerDependencies: + size-limit: 9.0.0 + dependencies: + semver: 7.5.4 + size-limit: 9.0.0 + dev: true + + /@size-limit/preset-small-lib@9.0.0(size-limit@9.0.0): + resolution: {integrity: sha512-nkbZxn12pTpABYVyX5nsjQuLFpn8wDmd2XKoq/MiqKOc3ocz5BBwXTruqTL5ZKDW1OxEAWZMQlxf2kg3kY3X1Q==} + peerDependencies: + size-limit: 9.0.0 + dependencies: + '@size-limit/esbuild': 9.0.0(size-limit@9.0.0) + '@size-limit/file': 9.0.0(size-limit@9.0.0) + size-limit: 9.0.0 + dev: true + /@solana/buffer-layout@4.0.1: resolution: {integrity: sha512-E1ImOIAD1tBZFRdjeM4/pzTiTApC0AOBGwyAMS4fwIodCWArzJ3DWdoh8cKxeFM2fElkxBh2Aqts1BPC373rHA==} engines: {node: '>=5.10'} @@ -3132,6 +3367,11 @@ packages: streamsearch: 1.1.0 dev: false + /bytes-iec@3.1.1: + resolution: {integrity: sha512-fey6+4jDK7TFtFg/klGSvNKJctyU7n2aQdnM+CO0ruLPbqqMOM8Tio0Pc+deqUeVKX1tL5DQep1zQ7+37aTAsA==} + engines: {node: '>= 0.8'} + dev: true + /cac@6.7.14: resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} engines: {node: '>=8'} @@ -3752,6 +3992,36 @@ packages: '@esbuild/win32-x64': 0.18.20 dev: true + /esbuild@0.19.3: + resolution: {integrity: sha512-UlJ1qUUA2jL2nNib1JTSkifQTcYTroFqRjwCFW4QYEKEsixXD5Tik9xML7zh2gTxkYTBKGHNH9y7txMwVyPbjw==} + engines: {node: '>=12'} + hasBin: true + requiresBuild: true + optionalDependencies: + '@esbuild/android-arm': 0.19.3 + '@esbuild/android-arm64': 0.19.3 + '@esbuild/android-x64': 0.19.3 + '@esbuild/darwin-arm64': 0.19.3 + '@esbuild/darwin-x64': 0.19.3 + '@esbuild/freebsd-arm64': 0.19.3 + '@esbuild/freebsd-x64': 0.19.3 + '@esbuild/linux-arm': 0.19.3 + '@esbuild/linux-arm64': 0.19.3 + '@esbuild/linux-ia32': 0.19.3 + '@esbuild/linux-loong64': 0.19.3 + '@esbuild/linux-mips64el': 0.19.3 + '@esbuild/linux-ppc64': 0.19.3 + '@esbuild/linux-riscv64': 0.19.3 + '@esbuild/linux-s390x': 0.19.3 + '@esbuild/linux-x64': 0.19.3 + '@esbuild/netbsd-x64': 0.19.3 + '@esbuild/openbsd-x64': 0.19.3 + '@esbuild/sunos-x64': 0.19.3 + '@esbuild/win32-arm64': 0.19.3 + '@esbuild/win32-ia32': 0.19.3 + '@esbuild/win32-x64': 0.19.3 + dev: true + /escalade@3.1.1: resolution: {integrity: sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==} engines: {node: '>=6'} @@ -5012,6 +5282,12 @@ packages: engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true + /nanospinner@1.1.0: + resolution: {integrity: sha512-yFvNYMig4AthKYfHFl1sLj7B2nkHL4lzdig4osvl9/LdGbXwrdFRoqBS98gsEsOakr0yH+r5NZ/1Y9gdVB8trA==} + dependencies: + picocolors: 1.0.0 + dev: true + /next@13.4.19(@babel/core@7.22.20)(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-HuPSzzAbJ1T4BD8e0bs6B9C1kWQ6gv8ykZoRWs5AQoiIuqbGHHdQO7Ljuvg05Q0Z24E2ABozHe6FxDvI6HfyAw==} engines: {node: '>=16.8.0'} @@ -5993,6 +6269,19 @@ packages: resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==} dev: true + /size-limit@9.0.0: + resolution: {integrity: sha512-DrA7o2DeRN3s+vwCA9nn7Ck9Y4pn9t0GNUwQRpKqBtBmNkl6LA2s/NlNCdtKHrEkRTeYA1ZQ65mnYveo9rUqgA==} + engines: {node: ^18.0.0 || >=20.0.0} + hasBin: true + dependencies: + bytes-iec: 3.1.1 + chokidar: 3.5.3 + globby: 11.1.0 + lilconfig: 2.1.0 + nanospinner: 1.1.0 + picocolors: 1.0.0 + dev: true + /slash@3.0.0: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} engines: {node: '>=8'} From 19349244317250bec581cb7bcb879b19a6c35909 Mon Sep 17 00:00:00 2001 From: kyscott18 <43524469+kyscott18@users.noreply.github.com> Date: Tue, 26 Sep 2023 16:47:30 -0400 Subject: [PATCH 25/42] Update README.md --- README.md | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index e140ba2..790546b 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ console.log(amountToNumber(vitalikBalance)) // 420.69 ## Installation ```sh -npm i reverse-mirage +$ npm i reverse-mirage ``` ## Benchmarks @@ -61,14 +61,13 @@ npm i reverse-mirage Benchmarks are done with [mitata](https://github.com/evanwashere/mitata). To reproduce: ```sh -cd packages/core/ -bun run src/amount/utils.bench.ts +$ cd packages/core/ +$ bun run src/amount/utils.bench.ts ``` ### Results ```sh - • amount add ------------------------------------------------------ ----------------------------- reverse mirage 70.6 ns/iter (67.13 ns … 154.07 ns) 68.33 ns 124.84 ns 133.01 ns @@ -105,10 +104,8 @@ summary for amount to significant reverse mirage 30.03x faster than uniswap ``` - ## Bundle Size -```sh -reverse-mirage: 5.17 kB -@uniswap/sdk-core: 53.4 kB -``` +`reverse-mirage`: **5.17 kB** + +`@uniswap/sdk-core`: **53.4 kB** From 28dc03e4cf1b0273b68ece39368c02f7958e30ac Mon Sep 17 00:00:00 2001 From: kyscott18 <43524469+kyscott18@users.noreply.github.com> Date: Tue, 26 Sep 2023 17:02:10 -0400 Subject: [PATCH 26/42] Update README.md --- README.md | 42 +++++------------------------------------- 1 file changed, 5 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 790546b..414de9c 100644 --- a/README.md +++ b/README.md @@ -67,43 +67,11 @@ $ bun run src/amount/utils.bench.ts ### Results -```sh -• amount add ------------------------------------------------------- ----------------------------- -reverse mirage 70.6 ns/iter (67.13 ns … 154.07 ns) 68.33 ns 124.84 ns 133.01 ns -uniswap 576.84 ns/iter (549.89 ns … 802.03 ns) 606.01 ns 802.03 ns 802.03 ns - -summary for amount add - reverse mirage - 8.17x faster than uniswap - -• amount equalTo ------------------------------------------------------- ----------------------------- -reverse mirage 11.33 ns/iter (11.2 ns … 15.59 ns) 11.22 ns 13.56 ns 13.99 ns -uniswap 120.47 ns/iter (114.63 ns … 202.19 ns) 117.75 ns 189.68 ns 192.36 ns - -summary for amount equalTo - reverse mirage - 10.63x faster than uniswap - -• amount to number ------------------------------------------------------- ----------------------------- -reverse mirage 9.42 ns/iter (9.3 ns … 14.22 ns) 9.32 ns 11.57 ns 12.18 ns -uniswap 1.28 µs/iter (1.22 µs … 1.54 µs) 1.29 µs 1.54 µs 1.54 µs - -summary for amount to number - reverse mirage - 136.14x faster than uniswap - -• amount to significant ------------------------------------------------------- ----------------------------- -reverse mirage 70.7 ns/iter (68.35 ns … 144.63 ns) 71.15 ns 77.24 ns 125.2 ns -uniswap 2.12 µs/iter (2 µs … 2.96 µs) 2.11 µs 2.96 µs 2.96 µs - -summary for amount to significant - reverse mirage - 30.03x faster than uniswap -``` +* amount add: `reverse mirage` **8.17x** faster than `@uniswap/sdk-core` +* amount equal to: `reverse-mirage` **10.63x** faster than `@uniswap/sdk-core` +* amount to number: `reverse-mirage` **136.14x** faster than `@uniswap/sdk-core` +* amount to significant: `reverse-mirage` **30.03x** faster than `@uniswap/sdk-core`\ + ## Bundle Size `reverse-mirage`: **5.17 kB** From 5b2e3566ec0892be9169ea16f89f1ba881949bb1 Mon Sep 17 00:00:00 2001 From: kyscott18 <43524469+kyscott18@users.noreply.github.com> Date: Tue, 26 Sep 2023 17:02:25 -0400 Subject: [PATCH 27/42] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 414de9c..876e74f 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ $ bun run src/amount/utils.bench.ts * amount add: `reverse mirage` **8.17x** faster than `@uniswap/sdk-core` * amount equal to: `reverse-mirage` **10.63x** faster than `@uniswap/sdk-core` * amount to number: `reverse-mirage` **136.14x** faster than `@uniswap/sdk-core` -* amount to significant: `reverse-mirage` **30.03x** faster than `@uniswap/sdk-core`\ +* amount to significant: `reverse-mirage` **30.03x** faster than `@uniswap/sdk-core` ## Bundle Size From 8d6298d0922b9a6a53783aee21270274b3d78293 Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Tue, 26 Sep 2023 17:32:38 -0400 Subject: [PATCH 28/42] docs --- README.md | 8 ++--- docs/.vitepress/config.mts | 7 +++-- docs/benchmark.md | 14 +++++++++ docs/example.md | 0 docs/index.md | 18 ++++++++---- .../next-interface/hooks/internal/utils.ts | 29 +++++++++++++++++++ examples/next-interface/hooks/useBalance.ts | 4 +-- examples/next-interface/hooks/useChain.ts | 2 -- examples/next-interface/hooks/useTransfer.ts | 2 +- examples/next-interface/pages/_app.tsx | 1 - packages/core/src/index.ts | 2 -- packages/core/src/utils/getQueryKey.ts | 26 ----------------- packages/core/src/utils/index.ts | 1 - 13 files changed, 68 insertions(+), 46 deletions(-) create mode 100644 docs/benchmark.md create mode 100644 docs/example.md delete mode 100644 packages/core/src/utils/getQueryKey.ts delete mode 100644 packages/core/src/utils/index.ts diff --git a/README.md b/README.md index 876e74f..ec8a6a7 100644 --- a/README.md +++ b/README.md @@ -17,19 +17,19 @@ Application level typescript utilities for Ethereum. - ✅ Extensible to build apps and libraries - ✅ Seamless extension to [Viem](https://github.com/wagmi-dev/viem) - ✅ TypeScript ready -- ✅ Test suite running against [forked](https://ethereum.org/en/glossary/#fork) Ethereum network +- ✅ Test suite running against local Ethereum network ## Example ```ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' -import { publicActions, amountToNumber } from 'reverse-mirage' +import { publicActionsReverseMirage, amountToNumber } from 'reverse-mirage' export const publicClient = createPublicClient({ chain: mainnet, transport: http() -}).extend(publicActions) +}).extend(publicActionsReverseMirage) // read token metadata const usdc = await publicClient.getERC20({ @@ -71,7 +71,7 @@ $ bun run src/amount/utils.bench.ts * amount equal to: `reverse-mirage` **10.63x** faster than `@uniswap/sdk-core` * amount to number: `reverse-mirage` **136.14x** faster than `@uniswap/sdk-core` * amount to significant: `reverse-mirage` **30.03x** faster than `@uniswap/sdk-core` - + ## Bundle Size `reverse-mirage`: **5.17 kB** diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index 943b7f3..bdfd2a7 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -13,14 +13,17 @@ export default defineConfig({ sidebar: [ { text: "Introduction", - items: [{ text: "Getting started", link: "/" }], + items: [ + { text: "Getting started", link: "/" }, + { text: "Benchmarks", link: "benchmark" }, + { text: "Examples", link: "example" }, + ], }, { text: "ERC20", collapsed: true, items: [ { text: "Introduction", link: "erc20/introduction" }, - { text: "Utilities", items: [ diff --git a/docs/benchmark.md b/docs/benchmark.md new file mode 100644 index 0000000..ff4c856 --- /dev/null +++ b/docs/benchmark.md @@ -0,0 +1,14 @@ +# Benchmarks + +## Results + +* amount add: `reverse mirage` **8.17x** faster than `@uniswap/sdk-core` +* amount equal to: `reverse-mirage` **10.63x** faster than `@uniswap/sdk-core` +* amount to number: `reverse-mirage` **136.14x** faster than `@uniswap/sdk-core` +* amount to significant: `reverse-mirage` **30.03x** faster than `@uniswap/sdk-core` + +## Bundle Size + +`reverse-mirage`: **5.17 kB** + +`@uniswap/sdk-core`: **53.4 kB** diff --git a/docs/example.md b/docs/example.md new file mode 100644 index 0000000..e69de29 diff --git a/docs/index.md b/docs/index.md index d2400c4..07824d4 100644 --- a/docs/index.md +++ b/docs/index.md @@ -6,19 +6,22 @@ ## Features -- ✅ ~30x faster than `@uniswap/sdk-core` +- ✅ 10x-100x faster, 10.3x smaller than [`@uniswap/sdk-core`](https://github.com/uniswap/sdk-core) - ✅ Abstactions for most commonly used token standards - ✅ Supports `permit` - ✅ Extensible to build apps and libraries - ✅ Seamless extension to [Viem](https://github.com/wagmi-dev/viem) - ✅ TypeScript ready -- ✅ Test suite running against [forked](https://ethereum.org/en/glossary/#fork) Ethereum network +- ✅ Test suite running against local Ethereum network ## Example -```ts +::: code-group + +```ts [example.ts] import { createPublicClient, http } from 'viem' -import {publicActionsReverseMirage, amountToNumber} from 'reverse-mirage' +import { mainnet } from 'viem/chains' +import { publicActionsReverseMirage, amountToNumber } from 'reverse-mirage' export const publicClient = createPublicClient({ chain: mainnet, @@ -28,10 +31,11 @@ export const publicClient = createPublicClient({ // read token metadata const usdc = await publicClient.getERC20({ address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // usdc - chainID: 1 // mainnet + id: mainnet.id }) console.log(usdc.decimals) // 6 +console.log(usdc.name) // USD Coin // read a balance const vitalikBalance = await publicClient.getERC20Balance({ @@ -39,9 +43,13 @@ const vitalikBalance = await publicClient.getERC20Balance({ address: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045' // vitalik }) +console.log(vitalikBalance.amount) // 420690000n console.log(amountToNumber(vitalikBalance)) // 420.69 ``` +::: + + ## Installation ::: code-group diff --git a/examples/next-interface/hooks/internal/utils.ts b/examples/next-interface/hooks/internal/utils.ts index a67873e..6e6b56f 100644 --- a/examples/next-interface/hooks/internal/utils.ts +++ b/examples/next-interface/hooks/internal/utils.ts @@ -1,3 +1,32 @@ +import { serialize } from "wagmi"; + export const userRefectchInterval = 60 * 1_000; export const externalRefetchInterval = 10_000; + +/** + * Return a query key for a specific `get` action and its arguments + * @description Used specifically for frontend data collection + * @see https://tanstack.com/query/v4/docs/react/guides/query-keys + */ +export const getQueryKey = ( + get: + | (( + // biome-ignore lint/suspicious/noExplicitAny: dont need + client: any, + args: TArgs, + ) => unknown) + | ((args: TArgs) => unknown), + args: TArgs, + chainID: number, +) => { + return [ + { + chainID, + read: { + name: get.name, + args: serialize(args), + }, + }, + ] as const; +}; diff --git a/examples/next-interface/hooks/useBalance.ts b/examples/next-interface/hooks/useBalance.ts index e97a03a..41222c8 100644 --- a/examples/next-interface/hooks/useBalance.ts +++ b/examples/next-interface/hooks/useBalance.ts @@ -1,8 +1,8 @@ import { useQuery } from "@tanstack/react-query"; -import { type ERC20, getERC20BalanceOf, getQueryKey } from "reverse-mirage"; +import { type ERC20, getERC20BalanceOf } from "reverse-mirage"; import { type Address, usePublicClient } from "wagmi"; import type { HookArg } from "./internal/types"; -import { userRefectchInterval } from "./internal/utils"; +import { getQueryKey, userRefectchInterval } from "./internal/utils"; import { useChainID } from "./useChain"; export const useBalance = ( diff --git a/examples/next-interface/hooks/useChain.ts b/examples/next-interface/hooks/useChain.ts index 61aed4a..e24819b 100644 --- a/examples/next-interface/hooks/useChain.ts +++ b/examples/next-interface/hooks/useChain.ts @@ -4,8 +4,6 @@ import { useChainId } from "wagmi"; export type SupportedChainIDs = typeof chains[number]["id"]; export const useChainID = (): SupportedChainIDs => { - console.log("chain"); - const chainNumber = useChainId(); return chainNumber as SupportedChainIDs; }; diff --git a/examples/next-interface/hooks/useTransfer.ts b/examples/next-interface/hooks/useTransfer.ts index 20b643b..d528b99 100644 --- a/examples/next-interface/hooks/useTransfer.ts +++ b/examples/next-interface/hooks/useTransfer.ts @@ -5,13 +5,13 @@ import { type BaseERC20, type ERC20Amount, getERC20BalanceOf, - getQueryKey, simulateERC20Transfer, } from "reverse-mirage"; import { getAddress } from "viem"; import { type Address, useWalletClient } from "wagmi"; import type { HookArg } from "./internal/types"; import { useFastClient } from "./internal/useFastClient"; +import { getQueryKey } from "./internal/utils"; import { useChainID } from "./useChain"; export const useTransfer = ( diff --git a/examples/next-interface/pages/_app.tsx b/examples/next-interface/pages/_app.tsx index 75c6db6..3172747 100644 --- a/examples/next-interface/pages/_app.tsx +++ b/examples/next-interface/pages/_app.tsx @@ -50,7 +50,6 @@ const config = createConfig({ const queryClient = new QueryClient(); export default function App({ Component, pageProps }: AppProps) { - console.log(1); return ( diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index c95dfeb..1c571ff 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -155,8 +155,6 @@ export type { Tuple, } from "./types/index.js"; -export { getQueryKey } from "./utils/index.js"; - export { type WETH, createWETH, diff --git a/packages/core/src/utils/getQueryKey.ts b/packages/core/src/utils/getQueryKey.ts deleted file mode 100644 index 10b4689..0000000 --- a/packages/core/src/utils/getQueryKey.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Return a query key for a specific `get` action and its arguments - * @description Used specifically for frontend data collection - * @see https://tanstack.com/query/v4/docs/react/guides/query-keys - */ -export const getQueryKey = ( - get: - | (( - // biome-ignore lint/suspicious/noExplicitAny: dont need - client: any, - args: TArgs, - ) => unknown) - | ((args: TArgs) => unknown), - args: TArgs, - chainID: number, -) => { - return [ - { - chainID, - read: { - name: get.name, - args, - }, - }, - ] as const; -}; diff --git a/packages/core/src/utils/index.ts b/packages/core/src/utils/index.ts deleted file mode 100644 index cc12af2..0000000 --- a/packages/core/src/utils/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { getQueryKey } from "./getQueryKey.js"; From df7fbab34f763710e9dfd0c2270b1780fe015163 Mon Sep 17 00:00:00 2001 From: kyscott18 <43524469+kyscott18@users.noreply.github.com> Date: Tue, 26 Sep 2023 17:44:35 -0400 Subject: [PATCH 29/42] Update example.md --- docs/example.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/example.md b/docs/example.md index e69de29..05881ad 100644 --- a/docs/example.md +++ b/docs/example.md @@ -0,0 +1,4 @@ +# Examples + +A beta interface has been built using `reverse-mirage` [here](https://github.com/kyscott18/reverse-mirage/examples/next-interface) +Screenshot 2023-09-26 at 5 25 36 PM From e59663d7913803d45881b48d46714f86bf9847b9 Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Tue, 26 Sep 2023 17:47:37 -0400 Subject: [PATCH 30/42] example --- docs/example.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/example.md b/docs/example.md index 05881ad..71ab36e 100644 --- a/docs/example.md +++ b/docs/example.md @@ -1,4 +1,11 @@ # Examples -A beta interface has been built using `reverse-mirage` [here](https://github.com/kyscott18/reverse-mirage/examples/next-interface) +A beta interface has been built using `reverse-mirage` [here](https://github.com/kyscott18/reverse-mirage/tree/v1/examples/next-interface/next-interface). + +## Features + +* Runs on an anvil local node +* Transfer test tokens +* Reset node state from interface + Screenshot 2023-09-26 at 5 25 36 PM From 08c222a4866a601e9634430a003fded9f06a1cfa Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Tue, 26 Sep 2023 20:37:21 -0400 Subject: [PATCH 31/42] docs --- README.md | 2 +- docs/.vitepress/config.mts | 18 ------------------ docs/erc20/createERC20.md | 6 ++++++ docs/erc20/introduction.md | 17 ----------------- docs/example.md | 3 ++- docs/index.md | 11 +++++++---- 6 files changed, 16 insertions(+), 41 deletions(-) delete mode 100644 docs/erc20/introduction.md diff --git a/README.md b/README.md index ec8a6a7..afa3d81 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [bundle]: https://bundlephobia.com/result?p=reverse-mirage@latest [bundle-badge]:https://img.shields.io/bundlephobia/minzip/reverse-mirage/latest.svg -Application level typescript utilities for Ethereum. +Building blocks for Ethereum app development. Built using [Viem](https://viem.sh). ## Features diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index bdfd2a7..ad9f28d 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -23,7 +23,6 @@ export default defineConfig({ text: "ERC20", collapsed: true, items: [ - { text: "Introduction", link: "erc20/introduction" }, { text: "Utilities", items: [ @@ -129,7 +128,6 @@ export default defineConfig({ text: "Native", collapsed: true, items: [ - { text: "Introduction", link: "" }, { text: "Utilities", items: [ @@ -154,8 +152,6 @@ export default defineConfig({ text: "WETH", collapsed: true, items: [ - { text: "Introduction", link: "" }, - { text: "Utilities", items: [ @@ -184,7 +180,6 @@ export default defineConfig({ text: "ERC721", collapsed: true, items: [ - { text: "Introduction", link: "" }, { text: "Utilities", items: [ @@ -266,7 +261,6 @@ export default defineConfig({ text: "ERC1155", collapsed: true, items: [ - { text: "Introduction", link: "" }, { text: "Utilities", items: [ @@ -324,7 +318,6 @@ export default defineConfig({ text: "Amount", collapsed: true, items: [ - { text: "Introduction", link: "" }, { text: "createAmountFromString", link: "", @@ -379,7 +372,6 @@ export default defineConfig({ text: "Price", collapsed: true, items: [ - { text: "Introduction", link: "" }, { text: "createPrice", link: "", @@ -450,7 +442,6 @@ export default defineConfig({ text: "Fraction", collapsed: true, items: [ - { text: "Introduction", link: "" }, { text: "createFraction", link: "", @@ -509,15 +500,6 @@ export default defineConfig({ text: "Chains", link: "", }, - { - text: "Utilities", - items: [ - { - text: "getQueryKey", - link: "", - }, - ], - }, ], socialLinks: [ diff --git a/docs/erc20/createERC20.md b/docs/erc20/createERC20.md index 53efd29..0bde632 100644 --- a/docs/erc20/createERC20.md +++ b/docs/erc20/createERC20.md @@ -33,3 +33,9 @@ const usdc = createERC20({ // [!code focus:7] ``` ::: + +## Returns + +`erc20` + +The erc20 token that was just created. diff --git a/docs/erc20/introduction.md b/docs/erc20/introduction.md deleted file mode 100644 index 0d91209..0000000 --- a/docs/erc20/introduction.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -head: - - - meta - - property: og:title - content: Introduction to ERC20 - - - meta - - name: description - content: A brief introduction on what ERC20 does in reverse mirage. - - - meta - - property: og:description - content: A brief introduction on what ERC20 does in reverse mirage. - ---- - -# Introduction to ERC20 - -The ERC20 entity in reverse mirage is an abstraction over the Ethereum fungible token standard. There are multiple methods for safely reading from and writing to a contract that implements this standard. EIP 2612 (permit) is also supported. diff --git a/docs/example.md b/docs/example.md index 71ab36e..dca6669 100644 --- a/docs/example.md +++ b/docs/example.md @@ -1,10 +1,11 @@ # Examples -A beta interface has been built using `reverse-mirage` [here](https://github.com/kyscott18/reverse-mirage/tree/v1/examples/next-interface/next-interface). +A [beta interface](https://github.com/kyscott18/reverse-mirage/tree/v1/examples/next-interface) has been built using `reverse-mirage`. ## Features * Runs on an anvil local node +* Query balances * Transfer test tokens * Reset node state from interface diff --git a/docs/index.md b/docs/index.md index 07824d4..288b7f3 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,16 +1,20 @@ -# Reverse Mirage +# `reverse-mirage` ## Overview -`reverse-mirage` is a lightweight, fast, and type-safe Ethereum library built with [Viem](https://viem.sh) for working with ERC20s, prices, NFTs, Wrapped Ether, and more! +Building blocks for Ethereum app development. Built using [Viem](https://viem.sh). + +::: warning +This documentation is still under active development. +::: ## Features - ✅ 10x-100x faster, 10.3x smaller than [`@uniswap/sdk-core`](https://github.com/uniswap/sdk-core) - ✅ Abstactions for most commonly used token standards -- ✅ Supports `permit` - ✅ Extensible to build apps and libraries - ✅ Seamless extension to [Viem](https://github.com/wagmi-dev/viem) +- ✅ Supports `permit` - ✅ TypeScript ready - ✅ Test suite running against local Ethereum network @@ -49,7 +53,6 @@ console.log(amountToNumber(vitalikBalance)) // 420.69 ::: - ## Installation ::: code-group From d0747f8d5821ee48db12fb5cd365f7ac9769e7ae Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Wed, 27 Sep 2023 12:28:18 -0400 Subject: [PATCH 32/42] update deps --- examples/next-interface/hooks/useSetup.ts | 3 +- examples/next-interface/hooks/useTransfer.ts | 2 +- examples/next-interface/package.json | 12 +- package.json | 8 +- packages/core/package.json | 15 +- .../src/erc1155/publicActions/getERC1155.ts | 2 +- .../publicActions/getERC1155BalanceOf.ts | 2 +- .../getERC1155IsApprovedForAll.ts | 2 +- .../erc1155/publicActions/getERC1155URI.ts | 2 +- .../simulateERC1155SetApprovalForAll.ts | 2 +- .../walletActions/simulateERC1155Transfer.ts | 2 +- .../simulateERC1155TransferBatch.ts | 2 +- .../erc20/publicActions/getERC20Allowance.ts | 2 +- .../erc20/publicActions/getERC20BalanceOf.ts | 2 +- .../erc20/publicActions/getERC20Decimals.ts | 2 +- .../publicActions/getERC20DomainSeparator.ts | 2 +- .../src/erc20/publicActions/getERC20Name.ts | 2 +- .../erc20/publicActions/getERC20PermitData.ts | 2 +- .../publicActions/getERC20PermitNonce.ts | 2 +- .../src/erc20/publicActions/getERC20Symbol.ts | 2 +- .../publicActions/getERC20TotalSupply.ts | 2 +- packages/core/src/erc20/utils.ts | 3 +- .../erc20/walletActions/signERC20Permit.ts | 16 +- .../walletActions/simulateERC20Approve.ts | 2 +- .../walletActions/simulateERC20Permit.ts | 2 +- .../walletActions/simulateERC20Transfer.ts | 2 +- .../simulateERC20TransferFrom.ts | 2 +- .../erc721/publicActions/getERC721Approved.ts | 2 +- .../publicActions/getERC721BalanceOf.ts | 2 +- .../getERC721IsApprovedForAll.ts | 2 +- .../src/erc721/publicActions/getERC721Name.ts | 2 +- .../erc721/publicActions/getERC721OwnerOf.ts | 2 +- .../getERC721SupportsInterface.ts | 2 +- .../erc721/publicActions/getERC721Symbol.ts | 2 +- .../erc721/publicActions/getERC721TokenURI.ts | 2 +- packages/core/src/erc721/utils.ts | 3 +- .../walletActions/simulateERC721Approve.ts | 2 +- .../simulateERC721SetApprovalForAll.ts | 2 +- .../walletActions/simulateERC721Transfer.ts | 2 +- packages/core/src/weth/utils.ts | 3 +- .../weth/walletActions/simulateWETHDeposit.ts | 2 +- .../walletActions/simulateWETHWithdraw.ts | 2 +- pnpm-lock.yaml | 808 +++++++++--------- 43 files changed, 485 insertions(+), 454 deletions(-) diff --git a/examples/next-interface/hooks/useSetup.ts b/examples/next-interface/hooks/useSetup.ts index 233985b..eaf4d03 100644 --- a/examples/next-interface/hooks/useSetup.ts +++ b/examples/next-interface/hooks/useSetup.ts @@ -4,7 +4,8 @@ import { testClient, walletClient } from "@/pages/_app"; import { useMutation, useQueryClient } from "@tanstack/react-query"; import { createERC20 } from "reverse-mirage"; import invariant from "tiny-invariant"; -import { type Hex, parseEther } from "viem"; +import { type Hex } from "viem"; +import { parseEther } from "viem/utils"; import { useChainId, usePublicClient } from "wagmi"; import ERC20 from "../../../contracts/out/ERC20.sol/ERC20.json"; import { erc20ABI } from "../generated"; diff --git a/examples/next-interface/hooks/useTransfer.ts b/examples/next-interface/hooks/useTransfer.ts index d528b99..d566b41 100644 --- a/examples/next-interface/hooks/useTransfer.ts +++ b/examples/next-interface/hooks/useTransfer.ts @@ -7,7 +7,7 @@ import { getERC20BalanceOf, simulateERC20Transfer, } from "reverse-mirage"; -import { getAddress } from "viem"; +import { getAddress } from "viem/utils"; import { type Address, useWalletClient } from "wagmi"; import type { HookArg } from "./internal/types"; import { useFastClient } from "./internal/useFastClient"; diff --git a/examples/next-interface/package.json b/examples/next-interface/package.json index 34295bd..24f5bc4 100644 --- a/examples/next-interface/package.json +++ b/examples/next-interface/package.json @@ -14,7 +14,7 @@ "@rainbow-me/rainbowkit": "^1.0.1", "@tanstack/react-query": "^4.35.3", "clsx": "^2.0.0", - "next": "13.4.19", + "next": "13.5.3", "react": "18.2.0", "react-countup": "^6.4.2", "react-dom": "18.2.0", @@ -23,16 +23,16 @@ "tiny-invariant": "^1.3.1", "ts-extras": "^0.11.0", "unstated-next": "^1.1.0", - "viem": "^1.10.14", + "viem": "^1.12.2", "wagmi": "^1.4.2" }, "devDependencies": { "@biomejs/biome": "^1.2.2", "@tanstack/react-query-devtools": "^4.35.3", - "@types/node": "^20.6.2", - "@types/react": "^18.2.22", - "@types/react-dom": "^18.2.7", - "autoprefixer": "^10.4.15", + "@types/node": "^20.7.0", + "@types/react": "^18.2.23", + "@types/react-dom": "^18.2.8", + "autoprefixer": "^10.4.16", "csstype": "^3.1.2", "postcss": "^8.4.30", "tailwindcss": "^3.3.3", diff --git a/package.json b/package.json index 92e8b90..6ef7493 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,9 @@ "description": "", "private": true, "type": "module", - "workspaces": ["packages/*"], + "workspaces": [ + "packages/*" + ], "scripts": { "install:packages": "pnpm --filter './packages/**' install", "preinstall": "npx -y only-allow pnpm", @@ -28,9 +30,9 @@ "devDependencies": { "@biomejs/biome": "^1.2.2", "@changesets/cli": "^2.26.2", - "@wagmi/cli": "^1.5.0", + "@wagmi/cli": "^1.5.2", "husky": "^8.0.3", "typescript": "^5.2.2", - "vitepress": "1.0.0-rc.14" + "vitepress": "1.0.0-rc.20" } } diff --git a/packages/core/package.json b/packages/core/package.json index 72e18e3..abf0fda 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -26,7 +26,12 @@ "test:ci": "CI=true vitest --coverage", "test:cov": "vitest --coverage" }, - "keywords": ["eth", "ethereum", "dapps", "web3"], + "keywords": [ + "eth", + "ethereum", + "dapps", + "web3" + ], "size-limit": [ { "name": "reverse-mirage (cjs)", @@ -61,14 +66,14 @@ "@size-limit/preset-small-lib": "^9.0.0", "@uniswap/sdk-core": "^4.0.7", "@viem/anvil": "^0.0.6", - "@vitest/coverage-v8": "^0.34.4", - "bun": "^1.0.2", + "@vitest/coverage-v8": "^0.34.5", + "bun": "^1.0.3", "mitata": "^0.1.6", "size-limit": "^9.0.0", "tsup": "^7.2.0", "typescript": "^5.2.2", - "viem": "^1.10.14", - "vitest": "^0.34.4" + "viem": "^1.12.2", + "vitest": "^0.34.5" }, "packageManager": "pnpm@8.6.10" } diff --git a/packages/core/src/erc1155/publicActions/getERC1155.ts b/packages/core/src/erc1155/publicActions/getERC1155.ts index 1b6bc32..af9c106 100644 --- a/packages/core/src/erc1155/publicActions/getERC1155.ts +++ b/packages/core/src/erc1155/publicActions/getERC1155.ts @@ -1,5 +1,5 @@ import type { Chain, Client, ReadContractParameters, Transport } from "viem"; -import { readContract } from "viem/contract"; +import { readContract } from "viem/actions"; import { solmateErc1155ABI as solmateERC1155ABI } from "../../generated.js"; import type { BaseERC1155 } from "../types.js"; import { createERC1155 } from "../utils.js"; diff --git a/packages/core/src/erc1155/publicActions/getERC1155BalanceOf.ts b/packages/core/src/erc1155/publicActions/getERC1155BalanceOf.ts index 60337ed..6614210 100644 --- a/packages/core/src/erc1155/publicActions/getERC1155BalanceOf.ts +++ b/packages/core/src/erc1155/publicActions/getERC1155BalanceOf.ts @@ -5,7 +5,7 @@ import type { ReadContractParameters, Transport, } from "viem"; -import { readContract } from "viem/contract"; +import { readContract } from "viem/actions"; import { solmateErc1155ABI as solmateERC1155ABI } from "../../generated.js"; import type { BaseERC1155, ERC1155Data } from "../types.js"; import { createERC1155Data } from "../utils.js"; diff --git a/packages/core/src/erc1155/publicActions/getERC1155IsApprovedForAll.ts b/packages/core/src/erc1155/publicActions/getERC1155IsApprovedForAll.ts index 1de635e..4516c55 100644 --- a/packages/core/src/erc1155/publicActions/getERC1155IsApprovedForAll.ts +++ b/packages/core/src/erc1155/publicActions/getERC1155IsApprovedForAll.ts @@ -5,7 +5,7 @@ import type { ReadContractParameters, Transport, } from "viem"; -import { readContract } from "viem/contract"; +import { readContract } from "viem/actions"; import { solmateErc1155ABI as solmateERC1155ABI } from "../../generated.js"; import type { BaseERC1155 } from "../types.js"; diff --git a/packages/core/src/erc1155/publicActions/getERC1155URI.ts b/packages/core/src/erc1155/publicActions/getERC1155URI.ts index 4cf14c5..b92f143 100644 --- a/packages/core/src/erc1155/publicActions/getERC1155URI.ts +++ b/packages/core/src/erc1155/publicActions/getERC1155URI.ts @@ -1,5 +1,5 @@ import type { Chain, Client, ReadContractParameters, Transport } from "viem"; -import { readContract } from "viem/contract"; +import { readContract } from "viem/actions"; import { solmateErc1155ABI as solmateERC1155ABI } from "../../generated.js"; import type { BaseERC1155 } from "../types.js"; diff --git a/packages/core/src/erc1155/walletActions/simulateERC1155SetApprovalForAll.ts b/packages/core/src/erc1155/walletActions/simulateERC1155SetApprovalForAll.ts index 433f5c4..0f18b66 100644 --- a/packages/core/src/erc1155/walletActions/simulateERC1155SetApprovalForAll.ts +++ b/packages/core/src/erc1155/walletActions/simulateERC1155SetApprovalForAll.ts @@ -6,7 +6,7 @@ import type { SimulateContractReturnType, Transport, } from "viem"; -import { simulateContract } from "viem/contract"; +import { simulateContract } from "viem/actions"; import { solmateErc1155ABI as solmateERC1155 } from "../../generated.js"; import type { BaseERC1155 } from "../types.js"; diff --git a/packages/core/src/erc1155/walletActions/simulateERC1155Transfer.ts b/packages/core/src/erc1155/walletActions/simulateERC1155Transfer.ts index dfa6262..b679c75 100644 --- a/packages/core/src/erc1155/walletActions/simulateERC1155Transfer.ts +++ b/packages/core/src/erc1155/walletActions/simulateERC1155Transfer.ts @@ -7,7 +7,7 @@ import type { SimulateContractReturnType, Transport, } from "viem"; -import { simulateContract } from "viem/contract"; +import { simulateContract } from "viem/actions"; import { solmateErc1155ABI as solmateERC1155 } from "../../generated.js"; import type { BaseERC1155, ERC1155Data } from "../types.js"; diff --git a/packages/core/src/erc1155/walletActions/simulateERC1155TransferBatch.ts b/packages/core/src/erc1155/walletActions/simulateERC1155TransferBatch.ts index 557f514..6f3505f 100644 --- a/packages/core/src/erc1155/walletActions/simulateERC1155TransferBatch.ts +++ b/packages/core/src/erc1155/walletActions/simulateERC1155TransferBatch.ts @@ -8,7 +8,7 @@ import { type Transport, getAddress, } from "viem"; -import { simulateContract } from "viem/contract"; +import { simulateContract } from "viem/actions"; import { solmateErc1155ABI as solmateERC1155 } from "../../generated.js"; import type { BaseERC1155, ERC1155Data } from "../types.js"; diff --git a/packages/core/src/erc20/publicActions/getERC20Allowance.ts b/packages/core/src/erc20/publicActions/getERC20Allowance.ts index cbc35bf..80864ff 100644 --- a/packages/core/src/erc20/publicActions/getERC20Allowance.ts +++ b/packages/core/src/erc20/publicActions/getERC20Allowance.ts @@ -5,7 +5,7 @@ import type { ReadContractParameters, Transport, } from "viem"; -import { readContract } from "viem/contract"; +import { readContract } from "viem/actions"; import { createAmountFromRaw } from "../../amount/utils.js"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; import type { BaseERC20, ERC20Amount } from "../types.js"; diff --git a/packages/core/src/erc20/publicActions/getERC20BalanceOf.ts b/packages/core/src/erc20/publicActions/getERC20BalanceOf.ts index 5b645d7..17828fd 100644 --- a/packages/core/src/erc20/publicActions/getERC20BalanceOf.ts +++ b/packages/core/src/erc20/publicActions/getERC20BalanceOf.ts @@ -5,7 +5,7 @@ import type { ReadContractParameters, Transport, } from "viem"; -import { readContract } from "viem/contract"; +import { readContract } from "viem/actions"; import { createAmountFromRaw } from "../../amount/utils.js"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; import type { BaseERC20, ERC20Amount } from "../types.js"; diff --git a/packages/core/src/erc20/publicActions/getERC20Decimals.ts b/packages/core/src/erc20/publicActions/getERC20Decimals.ts index 0628179..d9ec229 100644 --- a/packages/core/src/erc20/publicActions/getERC20Decimals.ts +++ b/packages/core/src/erc20/publicActions/getERC20Decimals.ts @@ -1,5 +1,5 @@ import type { Chain, Client, ReadContractParameters, Transport } from "viem"; -import { readContract } from "viem/contract"; +import { readContract } from "viem/actions"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; import type { BaseERC20 } from "../types.js"; diff --git a/packages/core/src/erc20/publicActions/getERC20DomainSeparator.ts b/packages/core/src/erc20/publicActions/getERC20DomainSeparator.ts index 153156a..67e7f15 100644 --- a/packages/core/src/erc20/publicActions/getERC20DomainSeparator.ts +++ b/packages/core/src/erc20/publicActions/getERC20DomainSeparator.ts @@ -5,7 +5,7 @@ import type { ReadContractParameters, Transport, } from "viem"; -import { readContract } from "viem/contract"; +import { readContract } from "viem/actions"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; import type { BaseERC20 } from "../types.js"; diff --git a/packages/core/src/erc20/publicActions/getERC20Name.ts b/packages/core/src/erc20/publicActions/getERC20Name.ts index 8a437f5..6e105d2 100644 --- a/packages/core/src/erc20/publicActions/getERC20Name.ts +++ b/packages/core/src/erc20/publicActions/getERC20Name.ts @@ -1,5 +1,5 @@ import type { Chain, Client, ReadContractParameters, Transport } from "viem"; -import { readContract } from "viem/contract"; +import { readContract } from "viem/actions"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; import type { BaseERC20 } from "../types.js"; diff --git a/packages/core/src/erc20/publicActions/getERC20PermitData.ts b/packages/core/src/erc20/publicActions/getERC20PermitData.ts index c14d9b9..d413f43 100644 --- a/packages/core/src/erc20/publicActions/getERC20PermitData.ts +++ b/packages/core/src/erc20/publicActions/getERC20PermitData.ts @@ -5,7 +5,7 @@ import type { ReadContractParameters, Transport, } from "viem"; -import { readContract } from "viem/contract"; +import { readContract } from "viem/actions"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; import type { ERC20Permit, ERC20PermitData } from "../types.js"; import { createERC20PermitDataFromRaw } from "../utils.js"; diff --git a/packages/core/src/erc20/publicActions/getERC20PermitNonce.ts b/packages/core/src/erc20/publicActions/getERC20PermitNonce.ts index 2f0ba44..f77e6b5 100644 --- a/packages/core/src/erc20/publicActions/getERC20PermitNonce.ts +++ b/packages/core/src/erc20/publicActions/getERC20PermitNonce.ts @@ -5,7 +5,7 @@ import type { ReadContractParameters, Transport, } from "viem"; -import { readContract } from "viem/contract"; +import { readContract } from "viem/actions"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; import type { ERC20Permit } from "../types.js"; diff --git a/packages/core/src/erc20/publicActions/getERC20Symbol.ts b/packages/core/src/erc20/publicActions/getERC20Symbol.ts index 9ae44d6..55051c4 100644 --- a/packages/core/src/erc20/publicActions/getERC20Symbol.ts +++ b/packages/core/src/erc20/publicActions/getERC20Symbol.ts @@ -1,5 +1,5 @@ import type { Chain, Client, ReadContractParameters, Transport } from "viem"; -import { readContract } from "viem/contract"; +import { readContract } from "viem/actions"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; import type { BaseERC20 } from "../types.js"; diff --git a/packages/core/src/erc20/publicActions/getERC20TotalSupply.ts b/packages/core/src/erc20/publicActions/getERC20TotalSupply.ts index b5dab28..d982209 100644 --- a/packages/core/src/erc20/publicActions/getERC20TotalSupply.ts +++ b/packages/core/src/erc20/publicActions/getERC20TotalSupply.ts @@ -1,5 +1,5 @@ import type { Chain, Client, ReadContractParameters, Transport } from "viem"; -import { readContract } from "viem/contract"; +import { readContract } from "viem/actions"; import { createAmountFromRaw } from "../../amount/utils.js"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; import type { BaseERC20, ERC20Amount } from "../types.js"; diff --git a/packages/core/src/erc20/utils.ts b/packages/core/src/erc20/utils.ts index b333ff9..a888109 100644 --- a/packages/core/src/erc20/utils.ts +++ b/packages/core/src/erc20/utils.ts @@ -1,4 +1,5 @@ -import { type Address, getAddress } from "viem"; +import { type Address } from "viem"; +import { getAddress } from "viem/utils"; import { createAmountFromFraction, createAmountFromRaw, diff --git a/packages/core/src/erc20/walletActions/signERC20Permit.ts b/packages/core/src/erc20/walletActions/signERC20Permit.ts index 24dc037..646ef22 100644 --- a/packages/core/src/erc20/walletActions/signERC20Permit.ts +++ b/packages/core/src/erc20/walletActions/signERC20Permit.ts @@ -1,13 +1,13 @@ -import { - type Account, - type Address, - type Chain, - type Client, - type SignTypedDataParameters, - type Transport, - getAddress, +import type { + Account, + Address, + Chain, + Client, + SignTypedDataParameters, + Transport, } from "viem"; import { signTypedData } from "viem/actions"; +import { getAddress } from "viem/utils"; import type { ERC20Permit, ERC20PermitData } from "../types.js"; import { PermitType } from "../utils.js"; diff --git a/packages/core/src/erc20/walletActions/simulateERC20Approve.ts b/packages/core/src/erc20/walletActions/simulateERC20Approve.ts index f493a68..b845733 100644 --- a/packages/core/src/erc20/walletActions/simulateERC20Approve.ts +++ b/packages/core/src/erc20/walletActions/simulateERC20Approve.ts @@ -6,7 +6,7 @@ import type { SimulateContractReturnType, Transport, } from "viem"; -import { simulateContract } from "viem/contract"; +import { simulateContract } from "viem/actions"; import type { BaseERC20, ERC20Amount } from "../../erc20/types.js"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; diff --git a/packages/core/src/erc20/walletActions/simulateERC20Permit.ts b/packages/core/src/erc20/walletActions/simulateERC20Permit.ts index 4be48f0..7275abd 100644 --- a/packages/core/src/erc20/walletActions/simulateERC20Permit.ts +++ b/packages/core/src/erc20/walletActions/simulateERC20Permit.ts @@ -7,7 +7,7 @@ import type { SimulateContractReturnType, Transport, } from "viem"; -import { simulateContract } from "viem/contract"; +import { simulateContract } from "viem/actions"; import type { ERC20Permit, ERC20PermitData } from "../../erc20/types.js"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; diff --git a/packages/core/src/erc20/walletActions/simulateERC20Transfer.ts b/packages/core/src/erc20/walletActions/simulateERC20Transfer.ts index 8326e25..ec57b99 100644 --- a/packages/core/src/erc20/walletActions/simulateERC20Transfer.ts +++ b/packages/core/src/erc20/walletActions/simulateERC20Transfer.ts @@ -6,7 +6,7 @@ import type { SimulateContractReturnType, Transport, } from "viem"; -import { simulateContract } from "viem/contract"; +import { simulateContract } from "viem/actions"; import type { BaseERC20, ERC20Amount } from "../../erc20/types.js"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; diff --git a/packages/core/src/erc20/walletActions/simulateERC20TransferFrom.ts b/packages/core/src/erc20/walletActions/simulateERC20TransferFrom.ts index a5a79c3..cfc40e3 100644 --- a/packages/core/src/erc20/walletActions/simulateERC20TransferFrom.ts +++ b/packages/core/src/erc20/walletActions/simulateERC20TransferFrom.ts @@ -6,7 +6,7 @@ import type { SimulateContractReturnType, Transport, } from "viem"; -import { simulateContract } from "viem/contract"; +import { simulateContract } from "viem/actions"; import type { BaseERC20, ERC20Amount } from "../../erc20/types.js"; import { solmateErc20ABI as solmateERC20ABI } from "../../generated.js"; diff --git a/packages/core/src/erc721/publicActions/getERC721Approved.ts b/packages/core/src/erc721/publicActions/getERC721Approved.ts index 8009033..4b08d02 100644 --- a/packages/core/src/erc721/publicActions/getERC721Approved.ts +++ b/packages/core/src/erc721/publicActions/getERC721Approved.ts @@ -5,7 +5,7 @@ import type { ReadContractParameters, Transport, } from "viem"; -import { readContract } from "viem/contract"; +import { readContract } from "viem/actions"; import { solmateErc721ABI as solmateERC721ABI } from "../../generated.js"; import type { BaseERC721 } from "../types.js"; diff --git a/packages/core/src/erc721/publicActions/getERC721BalanceOf.ts b/packages/core/src/erc721/publicActions/getERC721BalanceOf.ts index f5af7b7..8cbf6ed 100644 --- a/packages/core/src/erc721/publicActions/getERC721BalanceOf.ts +++ b/packages/core/src/erc721/publicActions/getERC721BalanceOf.ts @@ -5,7 +5,7 @@ import type { ReadContractParameters, Transport, } from "viem"; -import { readContract } from "viem/contract"; +import { readContract } from "viem/actions"; import { solmateErc721ABI as solmateERC721ABI } from "../../generated.js"; import type { BaseERC721 } from "../types.js"; diff --git a/packages/core/src/erc721/publicActions/getERC721IsApprovedForAll.ts b/packages/core/src/erc721/publicActions/getERC721IsApprovedForAll.ts index f02cac4..3cb8e15 100644 --- a/packages/core/src/erc721/publicActions/getERC721IsApprovedForAll.ts +++ b/packages/core/src/erc721/publicActions/getERC721IsApprovedForAll.ts @@ -5,7 +5,7 @@ import type { ReadContractParameters, Transport, } from "viem"; -import { readContract } from "viem/contract"; +import { readContract } from "viem/actions"; import { solmateErc721ABI as solmateERC721ABI } from "../../generated.js"; import type { BaseERC721 } from "../types.js"; diff --git a/packages/core/src/erc721/publicActions/getERC721Name.ts b/packages/core/src/erc721/publicActions/getERC721Name.ts index 43cfe94..d87431f 100644 --- a/packages/core/src/erc721/publicActions/getERC721Name.ts +++ b/packages/core/src/erc721/publicActions/getERC721Name.ts @@ -1,5 +1,5 @@ import type { Chain, Client, ReadContractParameters, Transport } from "viem"; -import { readContract } from "viem/contract"; +import { readContract } from "viem/actions"; import { solmateErc721ABI as solmateERC721ABI } from "../../generated.js"; import type { BaseERC721 } from "../types.js"; diff --git a/packages/core/src/erc721/publicActions/getERC721OwnerOf.ts b/packages/core/src/erc721/publicActions/getERC721OwnerOf.ts index 6255369..4853bac 100644 --- a/packages/core/src/erc721/publicActions/getERC721OwnerOf.ts +++ b/packages/core/src/erc721/publicActions/getERC721OwnerOf.ts @@ -5,7 +5,7 @@ import type { ReadContractParameters, Transport, } from "viem"; -import { readContract } from "viem/contract"; +import { readContract } from "viem/actions"; import { solmateErc721ABI as solmateERC721ABI } from "../../generated.js"; import type { BaseERC721 } from "../types.js"; diff --git a/packages/core/src/erc721/publicActions/getERC721SupportsInterface.ts b/packages/core/src/erc721/publicActions/getERC721SupportsInterface.ts index c845a04..130e6aa 100644 --- a/packages/core/src/erc721/publicActions/getERC721SupportsInterface.ts +++ b/packages/core/src/erc721/publicActions/getERC721SupportsInterface.ts @@ -5,7 +5,7 @@ import type { ReadContractParameters, Transport, } from "viem"; -import { readContract } from "viem/contract"; +import { readContract } from "viem/actions"; import { solmateErc721ABI as solmateERC721ABI } from "../../generated.js"; import type { BaseERC721 } from "../types.js"; diff --git a/packages/core/src/erc721/publicActions/getERC721Symbol.ts b/packages/core/src/erc721/publicActions/getERC721Symbol.ts index 0e89866..0eeb12e 100644 --- a/packages/core/src/erc721/publicActions/getERC721Symbol.ts +++ b/packages/core/src/erc721/publicActions/getERC721Symbol.ts @@ -1,5 +1,5 @@ import type { Chain, Client, ReadContractParameters, Transport } from "viem"; -import { readContract } from "viem/contract"; +import { readContract } from "viem/actions"; import { solmateErc721ABI as solmateERC721ABI } from "../../generated.js"; import type { BaseERC721 } from "../types.js"; diff --git a/packages/core/src/erc721/publicActions/getERC721TokenURI.ts b/packages/core/src/erc721/publicActions/getERC721TokenURI.ts index 04d8900..a33d204 100644 --- a/packages/core/src/erc721/publicActions/getERC721TokenURI.ts +++ b/packages/core/src/erc721/publicActions/getERC721TokenURI.ts @@ -1,5 +1,5 @@ import type { Chain, Client, ReadContractParameters, Transport } from "viem"; -import { readContract } from "viem/contract"; +import { readContract } from "viem/actions"; import { solmateErc721ABI as solmateERC721ABI } from "../../generated.js"; import type { BaseERC721 } from "../types.js"; diff --git a/packages/core/src/erc721/utils.ts b/packages/core/src/erc721/utils.ts index e6f78bd..847cb70 100644 --- a/packages/core/src/erc721/utils.ts +++ b/packages/core/src/erc721/utils.ts @@ -1,4 +1,5 @@ -import { type Address, getAddress } from "viem"; +import { type Address } from "viem"; +import { getAddress } from "viem/utils"; import type { Tuple } from "../types/tuple.js"; import type { BaseERC721, ERC721, ERC721Data } from "./types.js"; diff --git a/packages/core/src/erc721/walletActions/simulateERC721Approve.ts b/packages/core/src/erc721/walletActions/simulateERC721Approve.ts index 9fde2ff..5ee5772 100644 --- a/packages/core/src/erc721/walletActions/simulateERC721Approve.ts +++ b/packages/core/src/erc721/walletActions/simulateERC721Approve.ts @@ -6,7 +6,7 @@ import type { SimulateContractReturnType, Transport, } from "viem"; -import { simulateContract } from "viem/contract"; +import { simulateContract } from "viem/actions"; import { solmateErc721ABI as solmateERC721 } from "../../generated.js"; import type { BaseERC721 } from "../types.js"; diff --git a/packages/core/src/erc721/walletActions/simulateERC721SetApprovalForAll.ts b/packages/core/src/erc721/walletActions/simulateERC721SetApprovalForAll.ts index 065da18..367745a 100644 --- a/packages/core/src/erc721/walletActions/simulateERC721SetApprovalForAll.ts +++ b/packages/core/src/erc721/walletActions/simulateERC721SetApprovalForAll.ts @@ -6,7 +6,7 @@ import type { SimulateContractReturnType, Transport, } from "viem"; -import { simulateContract } from "viem/contract"; +import { simulateContract } from "viem/actions"; import { solmateErc721ABI as solmateERC721 } from "../../generated.js"; import type { BaseERC721 } from "../types.js"; diff --git a/packages/core/src/erc721/walletActions/simulateERC721Transfer.ts b/packages/core/src/erc721/walletActions/simulateERC721Transfer.ts index 4198ffe..679e329 100644 --- a/packages/core/src/erc721/walletActions/simulateERC721Transfer.ts +++ b/packages/core/src/erc721/walletActions/simulateERC721Transfer.ts @@ -7,7 +7,7 @@ import type { SimulateContractReturnType, Transport, } from "viem"; -import { simulateContract } from "viem/contract"; +import { simulateContract } from "viem/actions"; import { solmateErc721ABI as solmateERC721 } from "../../generated.js"; import type { BaseERC721 } from "../types.js"; diff --git a/packages/core/src/weth/utils.ts b/packages/core/src/weth/utils.ts index 1c51ff9..307ec83 100644 --- a/packages/core/src/weth/utils.ts +++ b/packages/core/src/weth/utils.ts @@ -1,4 +1,5 @@ -import { type Address, getAddress } from "viem"; +import { type Address } from "viem"; +import { getAddress } from "viem/utils"; import type { WETH } from "./types.js"; /** diff --git a/packages/core/src/weth/walletActions/simulateWETHDeposit.ts b/packages/core/src/weth/walletActions/simulateWETHDeposit.ts index 615df1a..910b6f8 100644 --- a/packages/core/src/weth/walletActions/simulateWETHDeposit.ts +++ b/packages/core/src/weth/walletActions/simulateWETHDeposit.ts @@ -5,7 +5,7 @@ import type { SimulateContractReturnType, Transport, } from "viem"; -import { simulateContract } from "viem/contract"; +import { simulateContract } from "viem/actions"; import type { ERC20Amount } from "../../erc20/types.js"; import { weth9ABI } from "../../generated.js"; import type { WETH } from "../types.js"; diff --git a/packages/core/src/weth/walletActions/simulateWETHWithdraw.ts b/packages/core/src/weth/walletActions/simulateWETHWithdraw.ts index f99f2bf..36e6ffa 100644 --- a/packages/core/src/weth/walletActions/simulateWETHWithdraw.ts +++ b/packages/core/src/weth/walletActions/simulateWETHWithdraw.ts @@ -5,7 +5,7 @@ import type { SimulateContractReturnType, Transport, } from "viem"; -import { simulateContract } from "viem/contract"; +import { simulateContract } from "viem/actions"; import type { ERC20Amount } from "../../erc20/types.js"; import { weth9ABI } from "../../generated.js"; import type { WETH } from "../types.js"; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0bbba74..654d28e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,8 +15,8 @@ importers: specifier: ^2.26.2 version: 2.26.2 '@wagmi/cli': - specifier: ^1.5.0 - version: 1.5.0(typescript@5.2.2) + specifier: ^1.5.2 + version: 1.5.2(typescript@5.2.2) husky: specifier: ^8.0.3 version: 8.0.3 @@ -24,14 +24,14 @@ importers: specifier: ^5.2.2 version: 5.2.2 vitepress: - specifier: 1.0.0-rc.14 - version: 1.0.0-rc.14(@algolia/client-search@4.20.0)(search-insights@2.8.2) + specifier: 1.0.0-rc.20 + version: 1.0.0-rc.20(@algolia/client-search@4.20.0)(search-insights@2.8.3) examples/next-interface: dependencies: '@rainbow-me/rainbowkit': specifier: ^1.0.1 - version: 1.0.1(@types/react@18.2.22)(react-dom@18.2.0)(react@18.2.0)(viem@1.10.14)(wagmi@1.4.2) + version: 1.0.1(@types/react@18.2.23)(react-dom@18.2.0)(react@18.2.0)(viem@1.12.2)(wagmi@1.4.2) '@tanstack/react-query': specifier: ^4.35.3 version: 4.35.3(react-dom@18.2.0)(react@18.2.0) @@ -39,14 +39,14 @@ importers: specifier: ^2.0.0 version: 2.0.0 next: - specifier: 13.4.19 - version: 13.4.19(@babel/core@7.22.20)(react-dom@18.2.0)(react@18.2.0) + specifier: 13.5.3 + version: 13.5.3(@babel/core@7.23.0)(react-dom@18.2.0)(react@18.2.0) react: specifier: 18.2.0 version: 18.2.0 react-countup: specifier: ^6.4.2 - version: 6.4.2(@babel/core@7.22.20)(react@18.2.0) + version: 6.4.2(@babel/core@7.23.0)(react@18.2.0) react-dom: specifier: 18.2.0 version: 18.2.0(react@18.2.0) @@ -66,11 +66,11 @@ importers: specifier: ^1.1.0 version: 1.1.0 viem: - specifier: ^1.10.14 - version: 1.10.14(typescript@5.2.2)(zod@3.22.2) + specifier: ^1.12.2 + version: 1.12.2(typescript@5.2.2)(zod@3.22.2) wagmi: specifier: ^1.4.2 - version: 1.4.2(@types/react@18.2.22)(react-dom@18.2.0)(react@18.2.0)(typescript@5.2.2)(viem@1.10.14) + version: 1.4.2(@types/react@18.2.23)(react-dom@18.2.0)(react@18.2.0)(typescript@5.2.2)(viem@1.12.2) devDependencies: '@biomejs/biome': specifier: ^1.2.2 @@ -79,17 +79,17 @@ importers: specifier: ^4.35.3 version: 4.35.3(@tanstack/react-query@4.35.3)(react-dom@18.2.0)(react@18.2.0) '@types/node': - specifier: ^20.6.2 - version: 20.6.2 + specifier: ^20.7.0 + version: 20.7.0 '@types/react': - specifier: ^18.2.22 - version: 18.2.22 + specifier: ^18.2.23 + version: 18.2.23 '@types/react-dom': - specifier: ^18.2.7 - version: 18.2.7 + specifier: ^18.2.8 + version: 18.2.8 autoprefixer: - specifier: ^10.4.15 - version: 10.4.15(postcss@8.4.30) + specifier: ^10.4.16 + version: 10.4.16(postcss@8.4.30) csstype: specifier: ^3.1.2 version: 3.1.2 @@ -122,11 +122,11 @@ importers: specifier: ^0.0.6 version: 0.0.6 '@vitest/coverage-v8': - specifier: ^0.34.4 - version: 0.34.4(vitest@0.34.4) + specifier: ^0.34.5 + version: 0.34.5(vitest@0.34.5) bun: - specifier: ^1.0.2 - version: 1.0.2 + specifier: ^1.0.3 + version: 1.0.3 mitata: specifier: ^0.1.6 version: 0.1.6 @@ -140,21 +140,21 @@ importers: specifier: ^5.2.2 version: 5.2.2 viem: - specifier: ^1.10.14 - version: 1.10.14(typescript@5.2.2)(zod@3.22.2) + specifier: ^1.12.2 + version: 1.12.2(typescript@5.2.2)(zod@3.22.2) vitest: - specifier: ^0.34.4 - version: 0.34.4 + specifier: ^0.34.5 + version: 0.34.5 packages: /@adraffy/ens-normalize@1.9.4: resolution: {integrity: sha512-UK0bHA7hh9cR39V+4gl2/NnBBjoXIxkuWAPCaY4X7fbH4L/azIi7ilWOCjMUYfpJgraLUAqkRi2BqrjME8Rynw==} - /@algolia/autocomplete-core@1.9.3(@algolia/client-search@4.20.0)(algoliasearch@4.20.0)(search-insights@2.8.2): + /@algolia/autocomplete-core@1.9.3(@algolia/client-search@4.20.0)(algoliasearch@4.20.0)(search-insights@2.8.3): resolution: {integrity: sha512-009HdfugtGCdC4JdXUbVJClA0q0zh24yyePn+KUGk3rP7j8FEe/m5Yo/z65gn6nP/cM39PxpzqKrL7A6fP6PPw==} dependencies: - '@algolia/autocomplete-plugin-algolia-insights': 1.9.3(@algolia/client-search@4.20.0)(algoliasearch@4.20.0)(search-insights@2.8.2) + '@algolia/autocomplete-plugin-algolia-insights': 1.9.3(@algolia/client-search@4.20.0)(algoliasearch@4.20.0)(search-insights@2.8.3) '@algolia/autocomplete-shared': 1.9.3(@algolia/client-search@4.20.0)(algoliasearch@4.20.0) transitivePeerDependencies: - '@algolia/client-search' @@ -162,13 +162,13 @@ packages: - search-insights dev: true - /@algolia/autocomplete-plugin-algolia-insights@1.9.3(@algolia/client-search@4.20.0)(algoliasearch@4.20.0)(search-insights@2.8.2): + /@algolia/autocomplete-plugin-algolia-insights@1.9.3(@algolia/client-search@4.20.0)(algoliasearch@4.20.0)(search-insights@2.8.3): resolution: {integrity: sha512-a/yTUkcO/Vyy+JffmAnTWbr4/90cLzw+CC3bRbhnULr/EM0fGNvM13oQQ14f2moLMcVDyAx/leczLlAOovhSZg==} peerDependencies: search-insights: '>= 1 < 3' dependencies: '@algolia/autocomplete-shared': 1.9.3(@algolia/client-search@4.20.0)(algoliasearch@4.20.0) - search-insights: 2.8.2 + search-insights: 2.8.3 transitivePeerDependencies: - '@algolia/client-search' - algoliasearch @@ -309,21 +309,21 @@ packages: engines: {node: '>=6.9.0'} dev: false - /@babel/core@7.22.20: - resolution: {integrity: sha512-Y6jd1ahLubuYweD/zJH+vvOY141v4f9igNQAQ+MBgq9JlHS2iTsZKn1aMsb3vGccZsXI16VzTBw52Xx0DWmtnA==} + /@babel/core@7.23.0: + resolution: {integrity: sha512-97z/ju/Jy1rZmDxybphrBuI+jtJjFVoz7Mr9yUQVVVi+DNZE333uFQeMOqcCIy1x3WYBIbWftUSLmbNXNT7qFQ==} engines: {node: '>=6.9.0'} dependencies: '@ampproject/remapping': 2.2.1 '@babel/code-frame': 7.22.13 - '@babel/generator': 7.22.15 + '@babel/generator': 7.23.0 '@babel/helper-compilation-targets': 7.22.15 - '@babel/helper-module-transforms': 7.22.20(@babel/core@7.22.20) - '@babel/helpers': 7.22.15 - '@babel/parser': 7.22.16 + '@babel/helper-module-transforms': 7.23.0(@babel/core@7.23.0) + '@babel/helpers': 7.23.1 + '@babel/parser': 7.23.0 '@babel/template': 7.22.15 - '@babel/traverse': 7.22.20 - '@babel/types': 7.22.19 - convert-source-map: 1.9.0 + '@babel/traverse': 7.23.0 + '@babel/types': 7.23.0 + convert-source-map: 2.0.0 debug: 4.3.4 gensync: 1.0.0-beta.2 json5: 2.2.3 @@ -332,11 +332,11 @@ packages: - supports-color dev: false - /@babel/generator@7.22.15: - resolution: {integrity: sha512-Zu9oWARBqeVOW0dZOjXc3JObrzuqothQ3y/n1kUtrjCoCPLkXUwMvOo/F/TCfoHMbWIFlWwpZtkZVb9ga4U2pA==} + /@babel/generator@7.23.0: + resolution: {integrity: sha512-lN85QRR+5IbYrMWM6Y4pE/noaQtg4pNiqeNGX60eqOfo6gtEj6uw/JagelB8vVztSd7R6M5n1+PQkDbHbBRU4g==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.22.19 + '@babel/types': 7.23.0 '@jridgewell/gen-mapping': 0.3.3 '@jridgewell/trace-mapping': 0.3.19 jsesc: 2.5.2 @@ -348,7 +348,7 @@ packages: dependencies: '@babel/compat-data': 7.22.20 '@babel/helper-validator-option': 7.22.15 - browserslist: 4.21.10 + browserslist: 4.22.0 lru-cache: 5.1.1 semver: 6.3.1 dev: false @@ -358,35 +358,35 @@ packages: engines: {node: '>=6.9.0'} dev: false - /@babel/helper-function-name@7.22.5: - resolution: {integrity: sha512-wtHSq6jMRE3uF2otvfuD3DIvVhOsSNshQl0Qrd7qC9oQJzHvOL4qQXlQn2916+CXGywIjpGuIkoyZRRxHPiNQQ==} + /@babel/helper-function-name@7.23.0: + resolution: {integrity: sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw==} engines: {node: '>=6.9.0'} dependencies: '@babel/template': 7.22.15 - '@babel/types': 7.22.19 + '@babel/types': 7.23.0 dev: false /@babel/helper-hoist-variables@7.22.5: resolution: {integrity: sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.22.19 + '@babel/types': 7.23.0 dev: false /@babel/helper-module-imports@7.22.15: resolution: {integrity: sha512-0pYVBnDKZO2fnSPCrgM/6WMc7eS20Fbok+0r88fp+YtWVLZrp4CkafFGIp+W0VKw4a22sgebPT99y+FDNMdP4w==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.22.19 + '@babel/types': 7.23.0 dev: false - /@babel/helper-module-transforms@7.22.20(@babel/core@7.22.20): - resolution: {integrity: sha512-dLT7JVWIUUxKOs1UnJUBR3S70YK+pKX6AbJgB2vMIvEkZkrfJDbYDJesnPshtKV4LhDOR3Oc5YULeDizRek+5A==} + /@babel/helper-module-transforms@7.23.0(@babel/core@7.23.0): + resolution: {integrity: sha512-WhDWw1tdrlT0gMgUJSlX0IQvoO1eN279zrAUbVB+KpV2c3Tylz8+GnKOLllCS6Z/iZQEyVYxhZVUdPTqs2YYPw==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0 dependencies: - '@babel/core': 7.22.20 + '@babel/core': 7.23.0 '@babel/helper-environment-visitor': 7.22.20 '@babel/helper-module-imports': 7.22.15 '@babel/helper-simple-access': 7.22.5 @@ -398,14 +398,14 @@ packages: resolution: {integrity: sha512-n0H99E/K+Bika3++WNL17POvo4rKWZ7lZEp1Q+fStVbUi8nxPQEBOlTmCOxW/0JsS56SKKQ+ojAe2pHKJHN35w==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.22.19 + '@babel/types': 7.23.0 dev: false /@babel/helper-split-export-declaration@7.22.6: resolution: {integrity: sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.22.19 + '@babel/types': 7.23.0 dev: false /@babel/helper-string-parser@7.22.5: @@ -421,13 +421,13 @@ packages: engines: {node: '>=6.9.0'} dev: false - /@babel/helpers@7.22.15: - resolution: {integrity: sha512-7pAjK0aSdxOwR+CcYAqgWOGy5dcfvzsTIfFTb2odQqW47MDfv14UaJDY6eng8ylM2EaeKXdxaSWESbkmaQHTmw==} + /@babel/helpers@7.23.1: + resolution: {integrity: sha512-chNpneuK18yW5Oxsr+t553UZzzAs3aZnFm4bxhebsNTeshrC95yA7l5yl7GBAG+JG1rF0F7zzD2EixK9mWSDoA==} engines: {node: '>=6.9.0'} dependencies: '@babel/template': 7.22.15 - '@babel/traverse': 7.22.20 - '@babel/types': 7.22.19 + '@babel/traverse': 7.23.0 + '@babel/types': 7.23.0 transitivePeerDependencies: - supports-color dev: false @@ -440,15 +440,15 @@ packages: chalk: 2.4.2 js-tokens: 4.0.0 - /@babel/parser@7.22.16: - resolution: {integrity: sha512-+gPfKv8UWeKKeJTUxe59+OobVcrYHETCsORl61EmSkmgymguYk/X5bp7GuUIXaFsc6y++v8ZxPsLSSuujqDphA==} + /@babel/parser@7.23.0: + resolution: {integrity: sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==} engines: {node: '>=6.0.0'} hasBin: true dependencies: - '@babel/types': 7.22.19 + '@babel/types': 7.23.0 - /@babel/runtime@7.22.15: - resolution: {integrity: sha512-T0O+aa+4w0u06iNmapipJXMV4HoUir03hpx3/YqXXhu9xim3w+dVphjFWl1OH8NbZHw5Lbm9k45drDkgq2VNNA==} + /@babel/runtime@7.23.1: + resolution: {integrity: sha512-hC2v6p8ZSI/W0HUzh3V8C5g+NwSKzKPtJwSpTjwl0o297GP9+ZLQSkdvHz46CM3LqyoXxq+5G9komY+eSqSO0g==} engines: {node: '>=6.9.0'} dependencies: regenerator-runtime: 0.14.0 @@ -458,30 +458,30 @@ packages: engines: {node: '>=6.9.0'} dependencies: '@babel/code-frame': 7.22.13 - '@babel/parser': 7.22.16 - '@babel/types': 7.22.19 + '@babel/parser': 7.23.0 + '@babel/types': 7.23.0 dev: false - /@babel/traverse@7.22.20: - resolution: {integrity: sha512-eU260mPZbU7mZ0N+X10pxXhQFMGTeLb9eFS0mxehS8HZp9o1uSnFeWQuG1UPrlxgA7QoUzFhOnilHDp0AXCyHw==} + /@babel/traverse@7.23.0: + resolution: {integrity: sha512-t/QaEvyIoIkwzpiZ7aoSKK8kObQYeF7T2v+dazAYCb8SXtp58zEVkWW7zAnju8FNKNdr4ScAOEDmMItbyOmEYw==} engines: {node: '>=6.9.0'} dependencies: '@babel/code-frame': 7.22.13 - '@babel/generator': 7.22.15 + '@babel/generator': 7.23.0 '@babel/helper-environment-visitor': 7.22.20 - '@babel/helper-function-name': 7.22.5 + '@babel/helper-function-name': 7.23.0 '@babel/helper-hoist-variables': 7.22.5 '@babel/helper-split-export-declaration': 7.22.6 - '@babel/parser': 7.22.16 - '@babel/types': 7.22.19 + '@babel/parser': 7.23.0 + '@babel/types': 7.23.0 debug: 4.3.4 globals: 11.12.0 transitivePeerDependencies: - supports-color dev: false - /@babel/types@7.22.19: - resolution: {integrity: sha512-P7LAw/LbojPzkgp5oznjE6tQEIWbp4PkkfrZDINTro9zgBRtI324/EYsiSI7lhPbpIQ+DCeR2NNmMWANGGfZsg==} + /@babel/types@7.23.0: + resolution: {integrity: sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==} engines: {node: '>=6.9.0'} dependencies: '@babel/helper-string-parser': 7.22.5 @@ -563,7 +563,7 @@ packages: /@changesets/apply-release-plan@6.1.4: resolution: {integrity: sha512-FMpKF1fRlJyCZVYHr3CbinpZZ+6MwvOtWUuO8uo+svcATEoc1zRDcj23pAurJ2TZ/uVz1wFHH6K3NlACy0PLew==} dependencies: - '@babel/runtime': 7.22.15 + '@babel/runtime': 7.23.1 '@changesets/config': 2.3.1 '@changesets/get-version-range-type': 0.3.2 '@changesets/git': 2.0.0 @@ -581,7 +581,7 @@ packages: /@changesets/assemble-release-plan@5.2.4: resolution: {integrity: sha512-xJkWX+1/CUaOUWTguXEbCDTyWJFECEhmdtbkjhn5GVBGxdP/JwaHBIU9sW3FR6gD07UwZ7ovpiPclQZs+j+mvg==} dependencies: - '@babel/runtime': 7.22.15 + '@babel/runtime': 7.23.1 '@changesets/errors': 0.1.4 '@changesets/get-dependents-graph': 1.3.6 '@changesets/types': 5.2.1 @@ -599,7 +599,7 @@ packages: resolution: {integrity: sha512-dnWrJTmRR8bCHikJHl9b9HW3gXACCehz4OasrXpMp7sx97ECuBGGNjJhjPhdZNCvMy9mn4BWdplI323IbqsRig==} hasBin: true dependencies: - '@babel/runtime': 7.22.15 + '@babel/runtime': 7.23.1 '@changesets/apply-release-plan': 6.1.4 '@changesets/assemble-release-plan': 5.2.4 '@changesets/changelog-git': 0.1.14 @@ -614,8 +614,8 @@ packages: '@changesets/types': 5.2.1 '@changesets/write': 0.2.3 '@manypkg/get-packages': 1.1.3 - '@types/is-ci': 3.0.0 - '@types/semver': 7.5.2 + '@types/is-ci': 3.0.1 + '@types/semver': 7.5.3 ansi-colors: 4.1.3 chalk: 2.4.2 enquirer: 2.4.1 @@ -665,7 +665,7 @@ packages: /@changesets/get-release-plan@3.0.17: resolution: {integrity: sha512-6IwKTubNEgoOZwDontYc2x2cWXfr6IKxP3IhKeK+WjyD6y3M4Gl/jdQvBw+m/5zWILSOCAaGLu2ZF6Q+WiPniw==} dependencies: - '@babel/runtime': 7.22.15 + '@babel/runtime': 7.23.1 '@changesets/assemble-release-plan': 5.2.4 '@changesets/config': 2.3.1 '@changesets/pre': 1.0.14 @@ -681,7 +681,7 @@ packages: /@changesets/git@2.0.0: resolution: {integrity: sha512-enUVEWbiqUTxqSnmesyJGWfzd51PY4H7mH9yUw0hPVpZBJ6tQZFMU3F3mT/t9OJ/GjyiM4770i+sehAn6ymx6A==} dependencies: - '@babel/runtime': 7.22.15 + '@babel/runtime': 7.23.1 '@changesets/errors': 0.1.4 '@changesets/types': 5.2.1 '@manypkg/get-packages': 1.1.3 @@ -706,7 +706,7 @@ packages: /@changesets/pre@1.0.14: resolution: {integrity: sha512-dTsHmxQWEQekHYHbg+M1mDVYFvegDh9j/kySNuDKdylwfMEevTeDouR7IfHNyVodxZXu17sXoJuf2D0vi55FHQ==} dependencies: - '@babel/runtime': 7.22.15 + '@babel/runtime': 7.23.1 '@changesets/errors': 0.1.4 '@changesets/types': 5.2.1 '@manypkg/get-packages': 1.1.3 @@ -716,7 +716,7 @@ packages: /@changesets/read@0.5.9: resolution: {integrity: sha512-T8BJ6JS6j1gfO1HFq50kU3qawYxa4NTbI/ASNVVCBTsKquy2HYwM9r7ZnzkiMe8IEObAJtUVGSrePCOxAK2haQ==} dependencies: - '@babel/runtime': 7.22.15 + '@babel/runtime': 7.23.1 '@changesets/git': 2.0.0 '@changesets/logger': 0.0.5 '@changesets/parse': 0.3.16 @@ -737,7 +737,7 @@ packages: /@changesets/write@0.2.3: resolution: {integrity: sha512-Dbamr7AIMvslKnNYsLFafaVORx4H0pvCA2MHqgtNCySMe1blImEyAEOzDmcgKAkgz4+uwoLz7demIrX+JBr/Xw==} dependencies: - '@babel/runtime': 7.22.15 + '@babel/runtime': 7.23.1 '@changesets/types': 5.2.1 fs-extra: 7.0.1 human-id: 1.0.2 @@ -758,7 +758,7 @@ packages: eth-json-rpc-filters: 5.1.0 eth-rpc-errors: 4.0.2 json-rpc-engine: 6.1.0 - keccak: 3.0.3 + keccak: 3.0.4 preact: 10.17.1 qs: 6.11.2 rxjs: 6.6.7 @@ -776,10 +776,10 @@ packages: resolution: {integrity: sha512-SPiDHaWKQZpwR2siD0KQUwlStvIAnEyK6tAE2h2Wuoq8ue9skzhlyVQ1ddzOxX6khULnAALDiR/isSF3bnuciA==} dev: true - /@docsearch/js@3.5.2(@algolia/client-search@4.20.0)(search-insights@2.8.2): + /@docsearch/js@3.5.2(@algolia/client-search@4.20.0)(search-insights@2.8.3): resolution: {integrity: sha512-p1YFTCDflk8ieHgFJYfmyHBki1D61+U9idwrLh+GQQMrBSP3DLGKpy0XUJtPjAOPltcVbqsTjiPFfH7JImjUNg==} dependencies: - '@docsearch/react': 3.5.2(@algolia/client-search@4.20.0)(search-insights@2.8.2) + '@docsearch/react': 3.5.2(@algolia/client-search@4.20.0)(search-insights@2.8.3) preact: 10.17.1 transitivePeerDependencies: - '@algolia/client-search' @@ -789,7 +789,7 @@ packages: - search-insights dev: true - /@docsearch/react@3.5.2(@algolia/client-search@4.20.0)(search-insights@2.8.2): + /@docsearch/react@3.5.2(@algolia/client-search@4.20.0)(search-insights@2.8.3): resolution: {integrity: sha512-9Ahcrs5z2jq/DcAvYtvlqEBHImbm4YJI8M9y0x6Tqg598P40HTEkX7hsMcIuThI+hTFxRGZ9hll0Wygm2yEjng==} peerDependencies: '@types/react': '>= 16.8.0 < 19.0.0' @@ -806,11 +806,11 @@ packages: search-insights: optional: true dependencies: - '@algolia/autocomplete-core': 1.9.3(@algolia/client-search@4.20.0)(algoliasearch@4.20.0)(search-insights@2.8.2) + '@algolia/autocomplete-core': 1.9.3(@algolia/client-search@4.20.0)(algoliasearch@4.20.0)(search-insights@2.8.3) '@algolia/autocomplete-preset-algolia': 1.9.3(@algolia/client-search@4.20.0)(algoliasearch@4.20.0) '@docsearch/css': 3.5.2 algoliasearch: 4.20.0 - search-insights: 2.8.2 + search-insights: 2.8.3 transitivePeerDependencies: - '@algolia/client-search' dev: true @@ -1509,7 +1509,7 @@ packages: /@manypkg/find-root@1.1.0: resolution: {integrity: sha512-mki5uBvhHzO8kYYix/WRy2WX8S3B5wdVSc9D6KcU5lQNglP2yt58/VfLuAK49glRXChosY8ap2oJ1qgma3GUVA==} dependencies: - '@babel/runtime': 7.22.15 + '@babel/runtime': 7.23.1 '@types/node': 12.20.55 find-up: 4.1.0 fs-extra: 8.1.0 @@ -1518,7 +1518,7 @@ packages: /@manypkg/get-packages@1.1.3: resolution: {integrity: sha512-fo+QhuU3qE/2TQMQmbVMqaQ6EWbMhi4ABWP+O4AM1NqPBuy0OrApV5LO6BrrgnhtAHS2NH6RrVk9OL181tTi8A==} dependencies: - '@babel/runtime': 7.22.15 + '@babel/runtime': 7.23.1 '@changesets/types': 4.1.0 '@manypkg/find-root': 1.1.0 fs-extra: 8.1.0 @@ -1534,7 +1534,7 @@ packages: resolution: {integrity: sha512-9cIRrfkWvHblSiNDVXsjivqa9Ak0RYo/1H6tqTqTbAx+oBK2Sva0lWDHxGchOqA7bySGUJKAWSNJvH6gdHZ0gQ==} engines: {node: '>=14.0.0'} dependencies: - '@types/debug': 4.1.8 + '@types/debug': 4.1.9 debug: 4.3.4 semver: 7.5.4 superstruct: 1.0.3 @@ -1542,73 +1542,73 @@ packages: - supports-color dev: false - /@motionone/animation@10.15.1: - resolution: {integrity: sha512-mZcJxLjHor+bhcPuIFErMDNyrdb2vJur8lSfMCsuCB4UyV8ILZLvK+t+pg56erv8ud9xQGK/1OGPt10agPrCyQ==} + /@motionone/animation@10.16.3: + resolution: {integrity: sha512-QUGWpLbMFLhyqKlngjZhjtxM8IqiJQjLK0DF+XOF6od9nhSvlaeEpOY/UMCRVcZn/9Tr2rZO22EkuCIjYdI74g==} dependencies: - '@motionone/easing': 10.15.1 - '@motionone/types': 10.15.1 - '@motionone/utils': 10.15.1 + '@motionone/easing': 10.16.3 + '@motionone/types': 10.16.3 + '@motionone/utils': 10.16.3 tslib: 2.6.2 dev: false - /@motionone/dom@10.16.2: - resolution: {integrity: sha512-bnuHdNbge1FutZXv+k7xub9oPWcF0hsu8y1HTH/qg6av58YI0VufZ3ngfC7p2xhMJMnoh0LXFma2EGTgPeCkeg==} + /@motionone/dom@10.16.4: + resolution: {integrity: sha512-HPHlVo/030qpRj9R8fgY50KTN4Ko30moWRTA3L3imrsRBmob93cTYmodln49HYFbQm01lFF7X523OkKY0DX6UA==} dependencies: - '@motionone/animation': 10.15.1 - '@motionone/generators': 10.15.1 - '@motionone/types': 10.15.1 - '@motionone/utils': 10.15.1 + '@motionone/animation': 10.16.3 + '@motionone/generators': 10.16.4 + '@motionone/types': 10.16.3 + '@motionone/utils': 10.16.3 hey-listen: 1.0.8 tslib: 2.6.2 dev: false - /@motionone/easing@10.15.1: - resolution: {integrity: sha512-6hIHBSV+ZVehf9dcKZLT7p5PEKHGhDwky2k8RKkmOvUoYP3S+dXsKupyZpqx5apjd9f+php4vXk4LuS+ADsrWw==} + /@motionone/easing@10.16.3: + resolution: {integrity: sha512-HWTMZbTmZojzwEuKT/xCdvoMPXjYSyQvuVM6jmM0yoGU6BWzsmYMeB4bn38UFf618fJCNtP9XeC/zxtKWfbr0w==} dependencies: - '@motionone/utils': 10.15.1 + '@motionone/utils': 10.16.3 tslib: 2.6.2 dev: false - /@motionone/generators@10.15.1: - resolution: {integrity: sha512-67HLsvHJbw6cIbLA/o+gsm7h+6D4Sn7AUrB/GPxvujse1cGZ38F5H7DzoH7PhX+sjvtDnt2IhFYF2Zp1QTMKWQ==} + /@motionone/generators@10.16.4: + resolution: {integrity: sha512-geFZ3w0Rm0ZXXpctWsSf3REGywmLLujEjxPYpBR0j+ymYwof0xbV6S5kGqqsDKgyWKVWpUInqQYvQfL6fRbXeg==} dependencies: - '@motionone/types': 10.15.1 - '@motionone/utils': 10.15.1 + '@motionone/types': 10.16.3 + '@motionone/utils': 10.16.3 tslib: 2.6.2 dev: false - /@motionone/svelte@10.16.2: - resolution: {integrity: sha512-38xsroKrfK+aHYhuQlE6eFcGy0EwrB43Q7RGjF73j/kRUTcLNu/LAaKiLLsN5lyqVzCgTBVt4TMT/ShWbTbc5Q==} + /@motionone/svelte@10.16.4: + resolution: {integrity: sha512-zRVqk20lD1xqe+yEDZhMYgftsuHc25+9JSo+r0a0OWUJFocjSV9D/+UGhX4xgJsuwB9acPzXLr20w40VnY2PQA==} dependencies: - '@motionone/dom': 10.16.2 + '@motionone/dom': 10.16.4 tslib: 2.6.2 dev: false - /@motionone/types@10.15.1: - resolution: {integrity: sha512-iIUd/EgUsRZGrvW0jqdst8st7zKTzS9EsKkP+6c6n4MPZoQHwiHuVtTQLD6Kp0bsBLhNzKIBlHXponn/SDT4hA==} + /@motionone/types@10.16.3: + resolution: {integrity: sha512-W4jkEGFifDq73DlaZs3HUfamV2t1wM35zN/zX7Q79LfZ2sc6C0R1baUHZmqc/K5F3vSw3PavgQ6HyHLd/MXcWg==} dev: false - /@motionone/utils@10.15.1: - resolution: {integrity: sha512-p0YncgU+iklvYr/Dq4NobTRdAPv9PveRDUXabPEeOjBLSO/1FNB2phNTZxOxpi1/GZwYpAoECEa0Wam+nsmhSw==} + /@motionone/utils@10.16.3: + resolution: {integrity: sha512-WNWDksJIxQkaI9p9Z9z0+K27xdqISGNFy1SsWVGaiedTHq0iaT6iZujby8fT/ZnZxj1EOaxJtSfUPCFNU5CRoA==} dependencies: - '@motionone/types': 10.15.1 + '@motionone/types': 10.16.3 hey-listen: 1.0.8 tslib: 2.6.2 dev: false - /@motionone/vue@10.16.2: - resolution: {integrity: sha512-7/dEK/nWQXOkJ70bqb2KyNfSWbNvWqKKq1C8juj+0Mg/AorgD8O5wE3naddK0G+aXuNMqRuc4jlsYHHWHtIzVw==} + /@motionone/vue@10.16.4: + resolution: {integrity: sha512-z10PF9JV6SbjFq+/rYabM+8CVlMokgl8RFGvieSGNTmrkQanfHn+15XBrhG3BgUfvmTeSeyShfOHpG0i9zEdcg==} dependencies: - '@motionone/dom': 10.16.2 + '@motionone/dom': 10.16.4 tslib: 2.6.2 dev: false - /@next/env@13.4.19: - resolution: {integrity: sha512-FsAT5x0jF2kkhNkKkukhsyYOrRqtSxrEhfliniIq0bwWbuXLgyt3Gv0Ml+b91XwjwArmuP7NxCiGd++GGKdNMQ==} + /@next/env@13.5.3: + resolution: {integrity: sha512-X4te86vsbjsB7iO4usY9jLPtZ827Mbx+WcwNBGUOIuswuTAKQtzsuoxc/6KLxCMvogKG795MhrR1LDhYgDvasg==} dev: false - /@next/swc-darwin-arm64@13.4.19: - resolution: {integrity: sha512-vv1qrjXeGbuF2mOkhkdxMDtv9np7W4mcBtaDnHU+yJG+bBwa6rYsYSCI/9Xm5+TuF5SbZbrWO6G1NfTh1TMjvQ==} + /@next/swc-darwin-arm64@13.5.3: + resolution: {integrity: sha512-6hiYNJxJmyYvvKGrVThzo4nTcqvqUTA/JvKim7Auaj33NexDqSNwN5YrrQu+QhZJCIpv2tULSHt+lf+rUflLSw==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] @@ -1616,8 +1616,8 @@ packages: dev: false optional: true - /@next/swc-darwin-x64@13.4.19: - resolution: {integrity: sha512-jyzO6wwYhx6F+7gD8ddZfuqO4TtpJdw3wyOduR4fxTUCm3aLw7YmHGYNjS0xRSYGAkLpBkH1E0RcelyId6lNsw==} + /@next/swc-darwin-x64@13.5.3: + resolution: {integrity: sha512-UpBKxu2ob9scbpJyEq/xPgpdrgBgN3aLYlxyGqlYX5/KnwpJpFuIHU2lx8upQQ7L+MEmz+fA1XSgesoK92ppwQ==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] @@ -1625,8 +1625,8 @@ packages: dev: false optional: true - /@next/swc-linux-arm64-gnu@13.4.19: - resolution: {integrity: sha512-vdlnIlaAEh6H+G6HrKZB9c2zJKnpPVKnA6LBwjwT2BTjxI7e0Hx30+FoWCgi50e+YO49p6oPOtesP9mXDRiiUg==} + /@next/swc-linux-arm64-gnu@13.5.3: + resolution: {integrity: sha512-5AzM7Yx1Ky+oLY6pHs7tjONTF22JirDPd5Jw/3/NazJ73uGB05NqhGhB4SbeCchg7SlVYVBeRMrMSZwJwq/xoA==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] @@ -1634,8 +1634,8 @@ packages: dev: false optional: true - /@next/swc-linux-arm64-musl@13.4.19: - resolution: {integrity: sha512-aU0HkH2XPgxqrbNRBFb3si9Ahu/CpaR5RPmN2s9GiM9qJCiBBlZtRTiEca+DC+xRPyCThTtWYgxjWHgU7ZkyvA==} + /@next/swc-linux-arm64-musl@13.5.3: + resolution: {integrity: sha512-A/C1shbyUhj7wRtokmn73eBksjTM7fFQoY2v/0rTM5wehpkjQRLOXI8WJsag2uLhnZ4ii5OzR1rFPwoD9cvOgA==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] @@ -1643,8 +1643,8 @@ packages: dev: false optional: true - /@next/swc-linux-x64-gnu@13.4.19: - resolution: {integrity: sha512-htwOEagMa/CXNykFFeAHHvMJeqZfNQEoQvHfsA4wgg5QqGNqD5soeCer4oGlCol6NGUxknrQO6VEustcv+Md+g==} + /@next/swc-linux-x64-gnu@13.5.3: + resolution: {integrity: sha512-FubPuw/Boz8tKkk+5eOuDHOpk36F80rbgxlx4+xty/U71e3wZZxVYHfZXmf0IRToBn1Crb8WvLM9OYj/Ur815g==} engines: {node: '>= 10'} cpu: [x64] os: [linux] @@ -1652,8 +1652,8 @@ packages: dev: false optional: true - /@next/swc-linux-x64-musl@13.4.19: - resolution: {integrity: sha512-4Gj4vvtbK1JH8ApWTT214b3GwUh9EKKQjY41hH/t+u55Knxi/0wesMzwQRhppK6Ddalhu0TEttbiJ+wRcoEj5Q==} + /@next/swc-linux-x64-musl@13.5.3: + resolution: {integrity: sha512-DPw8nFuM1uEpbX47tM3wiXIR0Qa+atSzs9Q3peY1urkhofx44o7E1svnq+a5Q0r8lAcssLrwiM+OyJJgV/oj7g==} engines: {node: '>= 10'} cpu: [x64] os: [linux] @@ -1661,8 +1661,8 @@ packages: dev: false optional: true - /@next/swc-win32-arm64-msvc@13.4.19: - resolution: {integrity: sha512-bUfDevQK4NsIAHXs3/JNgnvEY+LRyneDN788W2NYiRIIzmILjba7LaQTfihuFawZDhRtkYCv3JDC3B4TwnmRJw==} + /@next/swc-win32-arm64-msvc@13.5.3: + resolution: {integrity: sha512-zBPSP8cHL51Gub/YV8UUePW7AVGukp2D8JU93IHbVDu2qmhFAn9LWXiOOLKplZQKxnIPUkJTQAJDCWBWU4UWUA==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] @@ -1670,8 +1670,8 @@ packages: dev: false optional: true - /@next/swc-win32-ia32-msvc@13.4.19: - resolution: {integrity: sha512-Y5kikILFAr81LYIFaw6j/NrOtmiM4Sf3GtOc0pn50ez2GCkr+oejYuKGcwAwq3jiTKuzF6OF4iT2INPoxRycEA==} + /@next/swc-win32-ia32-msvc@13.5.3: + resolution: {integrity: sha512-ONcL/lYyGUj4W37D4I2I450SZtSenmFAvapkJQNIJhrPMhzDU/AdfLkW98NvH1D2+7FXwe7yclf3+B7v28uzBQ==} engines: {node: '>= 10'} cpu: [ia32] os: [win32] @@ -1679,8 +1679,8 @@ packages: dev: false optional: true - /@next/swc-win32-x64-msvc@13.4.19: - resolution: {integrity: sha512-YzA78jBDXMYiINdPdJJwGgPNT3YqBNNGhsthsDoWHL9p24tEJn9ViQf/ZqTbwSpX/RrkPupLfuuTH2sf73JBAw==} + /@next/swc-win32-x64-msvc@13.5.3: + resolution: {integrity: sha512-2Vz2tYWaLqJvLcWbbTlJ5k9AN6JD7a5CN2pAeIzpbecK8ZF/yobA39cXtv6e+Z8c5UJuVOmaTldEAIxvsIux/Q==} engines: {node: '>= 10'} cpu: [x64] os: [win32] @@ -1718,55 +1718,55 @@ packages: fastq: 1.15.0 dev: true - /@oven/bun-darwin-aarch64@1.0.2: - resolution: {integrity: sha512-zuhgD8ZaiMGtr4W8KTUCKECuuyFhRoY48qwjoHWJPp5icL+oTKfiU/DxhxZzXc/b0vihKM/LX/BdlNTYRxCB/A==} + /@oven/bun-darwin-aarch64@1.0.3: + resolution: {integrity: sha512-FvP7Kv51+Et68zOofN0+tpYjFmC8aUKl24+YjFnTTlhjVCpd2BIijJFohC6hYE6BeqqFzbsXwRtBXzTye32Jow==} cpu: [arm64] os: [darwin] requiresBuild: true dev: true optional: true - /@oven/bun-darwin-x64-baseline@1.0.2: - resolution: {integrity: sha512-+yrg+ECiwXJsnaIj1eeBVJooNK8pUD7uI+wbWZypaeY4k+Q48YDT2er40AiMbpfQE3bTjQhcrMrD0qOaghyZvw==} + /@oven/bun-darwin-x64-baseline@1.0.3: + resolution: {integrity: sha512-QKarwvjkBrD/LfIeGw9B9G8HU/JBZtmdaCJMSJG34S0esGoXiDNg1oMYScfR5eCod4v5Z6Gx2urhZFLzFLkb5Q==} cpu: [x64] os: [darwin] requiresBuild: true dev: true optional: true - /@oven/bun-darwin-x64@1.0.2: - resolution: {integrity: sha512-6oideJEl0BsXirWay1eNRf5gHIR3eTZnN8lAvrBXv46heRK+VLP8WACxdYb8f5Z7HsWYr59QivdHV6165MTMFw==} + /@oven/bun-darwin-x64@1.0.3: + resolution: {integrity: sha512-23rAnim46LZWaZ1K7D9QBdCur/5qvHosm17x18Py1OQvVXKpzq/gL23AJEjaeGntkoVWHx/mowkPhzzNMi16fA==} cpu: [x64] os: [darwin] requiresBuild: true dev: true optional: true - /@oven/bun-linux-aarch64@1.0.2: - resolution: {integrity: sha512-gVOwBHjOB+ucM3gOCsorRxt6U42QUJTDFkWGqQZmzPu2HL02d5t2tfr4/HpEzUXSrY5tJV0HRd/iWaXIA5a+mQ==} + /@oven/bun-linux-aarch64@1.0.3: + resolution: {integrity: sha512-wXPFtoyf0E9DFGkK+P3wYfOvZxWTjcs2nm32/dHdY4VhyMNUkOL5+5f/lJDazRnXWELb2bM9ZjCTD/DOYgS3yA==} cpu: [arm64] os: [linux] requiresBuild: true dev: true optional: true - /@oven/bun-linux-x64-baseline@1.0.2: - resolution: {integrity: sha512-BQER9BlUPieDnNJEC1bLOod7UR153Q0bGARjto7EuUrXlwB2HXsoVSwU8AYiAQBhCxNBxv6UcGaqH58DbX5Dog==} + /@oven/bun-linux-x64-baseline@1.0.3: + resolution: {integrity: sha512-1QMJh/s99xLqcUwu5PCCfYe++1/gY3+yeA/tcAdQT3tWxDitAeqC85xFgYslUWj5xQ7DLsEaGETBcQ2n5rHUpQ==} cpu: [x64] os: [linux] requiresBuild: true dev: true optional: true - /@oven/bun-linux-x64@1.0.2: - resolution: {integrity: sha512-sBOMGfyO1A6oSpYkv++WaNB2IcA2J9Z4dttfeo6ArrHYrCBLguDKhm3mKrqA6EdYmqX14ub2Ox2yXeWT5v0QiQ==} + /@oven/bun-linux-x64@1.0.3: + resolution: {integrity: sha512-Tt2AaFvDcf1wW+EDbtYa/rySEan78cYEzElUU/Bb/Aq8mNT1wZfFvIgE2hnBa/rQzbNhGgbNE/4GBKJflJBx4A==} cpu: [x64] os: [linux] requiresBuild: true dev: true optional: true - /@rainbow-me/rainbowkit@1.0.1(@types/react@18.2.22)(react-dom@18.2.0)(react@18.2.0)(viem@1.10.14)(wagmi@1.4.2): + /@rainbow-me/rainbowkit@1.0.1(@types/react@18.2.23)(react-dom@18.2.0)(react@18.2.0)(viem@1.12.2)(wagmi@1.4.2): resolution: {integrity: sha512-P+2lgHaN5X84K1e+MARUydyhYRS+nStN4H470QloBBWP5UsidHZpSJGd4qi0WFtfR6zBff96N6kmsfJo7PjFhQ==} engines: {node: '>=12.4'} peerDependencies: @@ -1782,14 +1782,14 @@ packages: qrcode: 1.5.0 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) - react-remove-scroll: 2.5.4(@types/react@18.2.22)(react@18.2.0) - viem: 1.10.14(typescript@5.2.2)(zod@3.22.2) - wagmi: 1.4.2(@types/react@18.2.22)(react-dom@18.2.0)(react@18.2.0)(typescript@5.2.2)(viem@1.10.14) + react-remove-scroll: 2.5.4(@types/react@18.2.23)(react@18.2.0) + viem: 1.12.2(typescript@5.2.2)(zod@3.22.2) + wagmi: 1.4.2(@types/react@18.2.23)(react-dom@18.2.0)(react@18.2.0)(typescript@5.2.2)(viem@1.12.2) transitivePeerDependencies: - '@types/react' dev: false - /@rollup/plugin-babel@6.0.3(@babel/core@7.22.20): + /@rollup/plugin-babel@6.0.3(@babel/core@7.23.0): resolution: {integrity: sha512-fKImZKppa1A/gX73eg4JGo+8kQr/q1HBQaCGKECZ0v4YBBv3lFqi14+7xyApECzvkLTHCifx+7ntcrvtBIRcpg==} engines: {node: '>=14.0.0'} peerDependencies: @@ -1802,7 +1802,7 @@ packages: rollup: optional: true dependencies: - '@babel/core': 7.22.20 + '@babel/core': 7.23.0 '@babel/helper-module-imports': 7.22.15 '@rollup/pluginutils': 5.0.4 dev: false @@ -1816,7 +1816,7 @@ packages: rollup: optional: true dependencies: - '@types/estree': 1.0.1 + '@types/estree': 1.0.2 estree-walker: 2.0.2 picomatch: 2.3.1 dev: false @@ -1828,7 +1828,6 @@ packages: events: 3.3.0 transitivePeerDependencies: - bufferutil - - encoding - typescript - utf-8-validate - zod @@ -1837,11 +1836,10 @@ packages: /@safe-global/safe-apps-sdk@8.0.0(typescript@5.2.2): resolution: {integrity: sha512-gYw0ki/EAuV1oSyMxpqandHjnthZjYYy+YWpTAzf8BqfXM3ItcZLpjxfg+3+mXW8HIO+3jw6T9iiqEXsqHaMMw==} dependencies: - '@safe-global/safe-gateway-typescript-sdk': 3.9.0 - viem: 1.10.14(typescript@5.2.2)(zod@3.22.2) + '@safe-global/safe-gateway-typescript-sdk': 3.12.0 + viem: 1.12.2(typescript@5.2.2)(zod@3.22.2) transitivePeerDependencies: - bufferutil - - encoding - typescript - utf-8-validate - zod @@ -1850,22 +1848,18 @@ packages: /@safe-global/safe-apps-sdk@8.1.0(typescript@5.2.2): resolution: {integrity: sha512-XJbEPuaVc7b9n23MqlF6c+ToYIS3f7P2Sel8f3cSBQ9WORE4xrSuvhMpK9fDSFqJ7by/brc+rmJR/5HViRr0/w==} dependencies: - '@safe-global/safe-gateway-typescript-sdk': 3.9.0 - viem: 1.10.14(typescript@5.2.2)(zod@3.22.2) + '@safe-global/safe-gateway-typescript-sdk': 3.12.0 + viem: 1.12.2(typescript@5.2.2)(zod@3.22.2) transitivePeerDependencies: - bufferutil - - encoding - typescript - utf-8-validate - zod dev: false - /@safe-global/safe-gateway-typescript-sdk@3.9.0: - resolution: {integrity: sha512-DxRM/sBBQhv955dPtdo0z2Bf2fXxrzoRUnGyTa3+4Z0RAhcyiqnffRP1Bt3tyuvlyfZnFL0RsvkqDcAIKzq3RQ==} - dependencies: - cross-fetch: 3.1.8 - transitivePeerDependencies: - - encoding + /@safe-global/safe-gateway-typescript-sdk@3.12.0: + resolution: {integrity: sha512-hExCo62lScVC9/ztVqYEYL2pFxcqLTvB8fj0WtdP5FWrvbtEgD0pbVolchzD5bf85pbzvEwdAxSVS7EdCZxTNw==} + engines: {node: '>=16'} dev: false /@scure/base@1.1.3: @@ -1929,7 +1923,7 @@ packages: /@solana/web3.js@1.78.5: resolution: {integrity: sha512-2ZHsDNqkKdglJQrIvJ3p2DmgS3cGnary3VJyqt9C1SPrpAtLYzcElr3xyXJOznyQTU/8AMw+GoF11lFoKbicKg==} dependencies: - '@babel/runtime': 7.22.15 + '@babel/runtime': 7.23.1 '@noble/curves': 1.2.0 '@noble/hashes': 1.3.2 '@solana/buffer-layout': 4.0.1 @@ -2066,8 +2060,8 @@ packages: '@stablelib/wipe': 1.0.1 dev: false - /@swc/helpers@0.5.1: - resolution: {integrity: sha512-sJ902EfIzn1Fa+qYmjdQqh8tPsoxyBz+8yBKC2HKUxyezKJFwPGOn7pv4WY6QuQW//ySQi5lJjA/ZT9sNWWNTg==} + /@swc/helpers@0.5.2: + resolution: {integrity: sha512-E4KcWTpoLHqwPHLxidpOqQbcrZVgi0rsmmZXUle1jXmJfuIf/UWpczUJ7MZZ5tlxytgJXyp0w4PGkkeLiuIdZw==} dependencies: tslib: 2.6.2 dev: false @@ -2145,24 +2139,24 @@ packages: resolution: {integrity: sha512-VOVRLM1mBxIRxydiViqPcKn6MIxZytrbMpd6RJLIWKxUNr3zux8no0Oc7kJx0WAPIitgZ0gkrDS+btlqQpubpw==} dev: true - /@types/connect@3.4.35: - resolution: {integrity: sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==} + /@types/connect@3.4.36: + resolution: {integrity: sha512-P63Zd/JUGq+PdrM1lv0Wv5SBYeA2+CORvbrXbngriYY0jzLUWfQMQQxOhjONEz/wlHOAxOdY7CY65rgQdTjq2w==} dependencies: - '@types/node': 20.6.2 + '@types/node': 20.7.0 dev: false - /@types/debug@4.1.8: - resolution: {integrity: sha512-/vPO1EPOs306Cvhwv7KfVfYvOJqA/S/AXjaHQiJboCZzcNDb+TIJFN9/2C9DZ//ijSKWioNyUxD792QmDJ+HKQ==} + /@types/debug@4.1.9: + resolution: {integrity: sha512-8Hz50m2eoS56ldRlepxSBa6PWEVCtzUo/92HgLc2qTMnotJNIm7xP+UZhyWoYsyOdd5dxZ+NZLb24rsKyFs2ow==} dependencies: - '@types/ms': 0.7.31 + '@types/ms': 0.7.32 dev: false - /@types/estree@1.0.1: - resolution: {integrity: sha512-LG4opVs2ANWZ1TJoKc937iMmNstM/d0ae1vNbnBvBhqCSezgVUOzcLCqbI5elV8Vy6WKwKjaqR+zO9VKirBBCA==} + /@types/estree@1.0.2: + resolution: {integrity: sha512-VeiPZ9MMwXjO32/Xu7+OwflfmeoRwkE/qzndw42gGtgJwZopBnzy2gD//NN1+go1mADzkDcqf/KnFRSjTJ8xJA==} dev: false - /@types/is-ci@3.0.0: - resolution: {integrity: sha512-Q0Op0hdWbYd1iahB+IFNQcWXFq4O0Q5MwQP7uN0souuQ4rPg1vEYcnIOfr1gY+M+6rc8FGoRaBO1mOOvL29sEQ==} + /@types/is-ci@3.0.1: + resolution: {integrity: sha512-mnb1ngaGQPm6LFZaNdh3xPOoQMkrQb/KBPhPPN2p2Wk8XgeUqWj6xPnvyQ8rvcK/VFritVmQG8tvQuy7g+9/nQ==} dependencies: ci-info: 3.8.0 dev: true @@ -2171,49 +2165,64 @@ packages: resolution: {integrity: sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==} dev: true - /@types/minimist@1.2.2: - resolution: {integrity: sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==} + /@types/linkify-it@3.0.3: + resolution: {integrity: sha512-pTjcqY9E4nOI55Wgpz7eiI8+LzdYnw3qxXCfHyBDdPbYvbyLgWLJGh8EdPvqawwMK1Uo1794AUkkR38Fr0g+2g==} + dev: true + + /@types/markdown-it@13.0.2: + resolution: {integrity: sha512-Tla7hH9oeXHOlJyBFdoqV61xWE9FZf/y2g+gFVwQ2vE1/eBzjUno5JCd3Hdb5oATve5OF6xNjZ/4VIZhVVx+hA==} + dependencies: + '@types/linkify-it': 3.0.3 + '@types/mdurl': 1.0.3 dev: true - /@types/ms@0.7.31: - resolution: {integrity: sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==} + /@types/mdurl@1.0.3: + resolution: {integrity: sha512-T5k6kTXak79gwmIOaDF2UUQXFbnBE0zBUzF20pz7wDYu0RQMzWg+Ml/Pz50214NsFHBITkoi5VtdjFZnJ2ijjA==} + dev: true + + /@types/minimist@1.2.3: + resolution: {integrity: sha512-ZYFzrvyWUNhaPomn80dsMNgMeXxNWZBdkuG/hWlUvXvbdUH8ZERNBGXnU87McuGcWDsyzX2aChCv/SVN348k3A==} + dev: true + + /@types/ms@0.7.32: + resolution: {integrity: sha512-xPSg0jm4mqgEkNhowKgZFBNtwoEwF6gJ4Dhww+GFpm3IgtNseHQZ5IqdNwnquZEoANxyDAKDRAdVo4Z72VvD/g==} dev: false /@types/node@12.20.55: resolution: {integrity: sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==} - /@types/node@20.6.2: - resolution: {integrity: sha512-Y+/1vGBHV/cYk6OI1Na/LHzwnlNCAfU3ZNGrc1LdRe/LAIbdDPTTv/HU3M7yXN448aTVDq3eKRm2cg7iKLb8gw==} + /@types/node@20.7.0: + resolution: {integrity: sha512-zI22/pJW2wUZOVyguFaUL1HABdmSVxpXrzIqkjsHmyUjNhPoWM1CKfvVuXfetHhIok4RY573cqS0mZ1SJEnoTg==} - /@types/normalize-package-data@2.4.1: - resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==} + /@types/normalize-package-data@2.4.2: + resolution: {integrity: sha512-lqa4UEhhv/2sjjIQgjX8B+RBjj47eo0mzGasklVJ78UKGQY1r0VpB9XHDaZZO9qzEFDdy4MrXLuEaSmPrPSe/A==} dev: true - /@types/prop-types@15.7.6: - resolution: {integrity: sha512-RK/kBbYOQQHLYj9Z95eh7S6t7gq4Ojt/NT8HTk8bWVhA5DaF+5SMnxHKkP4gPNN3wAZkKP+VjAf0ebtYzf+fxg==} + /@types/prop-types@15.7.7: + resolution: {integrity: sha512-FbtmBWCcSa2J4zL781Zf1p5YUBXQomPEcep9QZCfRfQgTxz3pJWiDFLebohZ9fFntX5ibzOkSsrJ0TEew8cAog==} - /@types/react-dom@18.2.7: - resolution: {integrity: sha512-GRaAEriuT4zp9N4p1i8BDBYmEyfo+xQ3yHjJU4eiK5NDa1RmUZG+unZABUTK4/Ox/M+GaHwb6Ow8rUITrtjszA==} + /@types/react-dom@18.2.8: + resolution: {integrity: sha512-bAIvO5lN/U8sPGvs1Xm61rlRHHaq5rp5N3kp9C+NJ/Q41P8iqjkXSu0+/qu8POsjH9pNWb0OYabFez7taP7omw==} dependencies: - '@types/react': 18.2.22 + '@types/react': 18.2.23 dev: true - /@types/react@18.2.22: - resolution: {integrity: sha512-60fLTOLqzarLED2O3UQImc/lsNRgG0jE/a1mPW9KjMemY0LMITWEsbS4VvZ4p6rorEHd5YKxxmMKSDK505GHpA==} + /@types/react@18.2.23: + resolution: {integrity: sha512-qHLW6n1q2+7KyBEYnrZpcsAmU/iiCh9WGCKgXvMxx89+TYdJWRjZohVIo9XTcoLhfX3+/hP0Pbulu3bCZQ9PSA==} dependencies: - '@types/prop-types': 15.7.6 - '@types/scheduler': 0.16.3 + '@types/prop-types': 15.7.7 + '@types/scheduler': 0.16.4 csstype: 3.1.2 - /@types/scheduler@0.16.3: - resolution: {integrity: sha512-5cJ8CB4yAx7BH1oMvdU0Jh9lrEXyPkar6F9G/ERswkCuvP4KQZfZkSjcMbAICCpQTN4OuZn8tz0HiKv9TGZgrQ==} + /@types/scheduler@0.16.4: + resolution: {integrity: sha512-2L9ifAGl7wmXwP4v3pN4p2FLhD0O1qsJpvKmNin5VA8+UvNVb447UDaAEV6UdrkA+m/Xs58U1RFps44x6TFsVQ==} - /@types/semver@7.5.2: - resolution: {integrity: sha512-7aqorHYgdNO4DM36stTiGO3DvKoex9TQRwsJU6vMaFGyqpBA1MNZkz+PG3gaNUPpTAOYhT1WR7M1JyA3fbS9Cw==} + /@types/semver@7.5.3: + resolution: {integrity: sha512-OxepLK9EuNEIPxWNME+C6WwbRAOOI2o2BaQEGzz5Lu2e4Z5eDnEo+/aVEDMIXywoJitJ7xWd641wrGLZdtwRyw==} dev: true - /@types/trusted-types@2.0.3: - resolution: {integrity: sha512-NfQ4gyz38SL8sDNrSixxU2Os1a5xcdFxipAFxYEuLUlvU2uDwS4NUpsImcf1//SlWItCVMMLiylsxbmNMToV/g==} + /@types/trusted-types@2.0.4: + resolution: {integrity: sha512-IDaobHimLQhjwsQ/NMwRVfa/yL7L/wriQPMhw1ZJall0KX6E1oxk29XMDeilW5qTIg5aoiqf5Udy8U/51aNoQQ==} dev: false /@types/web-bluetooth@0.0.17: @@ -2223,13 +2232,13 @@ packages: /@types/ws@7.4.7: resolution: {integrity: sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==} dependencies: - '@types/node': 20.6.2 + '@types/node': 20.7.0 dev: false - /@types/ws@8.5.5: - resolution: {integrity: sha512-lwhs8hktwxSjf9UaZ9tG5M03PGogvFaH8gUgLNbN9HKIg0dvv6q+gkSuJ8HN4/VbyxkuLzCjlN7GquQ0gUJfIg==} + /@types/ws@8.5.6: + resolution: {integrity: sha512-8B5EO9jLVCy+B58PLHvLDuOD8DRVMgQzq8d55SjLCOn9kqGyqOvy27exVaTio1q1nX5zLu8/6N0n2ThSxOM6tg==} dependencies: - '@types/node': 20.6.2 + '@types/node': 20.7.0 /@uniswap/sdk-core@4.0.7: resolution: {integrity: sha512-jscx7KUIWzQatcL5PHY6xy0gEL9IGQcL5h/obxzX9foP2KoNk9cq66Ia8I2Kvpa7zBcPOeW1hU0hJNBq6CzcIQ==} @@ -2283,15 +2292,15 @@ packages: execa: 7.2.0 get-port: 6.1.2 http-proxy: 1.18.1 - ws: 8.14.1(bufferutil@4.0.7)(utf-8-validate@5.0.10) + ws: 8.14.2(bufferutil@4.0.7)(utf-8-validate@5.0.10) transitivePeerDependencies: - bufferutil - debug - utf-8-validate dev: true - /@vitest/coverage-v8@0.34.4(vitest@0.34.4): - resolution: {integrity: sha512-TZ5ghzhmg3COQqfBShL+zRQEInHmV9TSwghTdfkHpCTyTOr+rxo6x41vCNcVfWysWULtqtBVpY6YFNovxnESfA==} + /@vitest/coverage-v8@0.34.5(vitest@0.34.5): + resolution: {integrity: sha512-97xjhRTSdmeeHCm2nNHhT3hLsMYkAhHXm/rwj6SZ3voka8xiCJrwgtfIjoZIFEL4OO0KezGmVuHWQXcMunULIA==} peerDependencies: vitest: '>=0.32.0 <1' dependencies: @@ -2306,43 +2315,43 @@ packages: std-env: 3.4.3 test-exclude: 6.0.0 v8-to-istanbul: 9.1.0 - vitest: 0.34.4 + vitest: 0.34.5 transitivePeerDependencies: - supports-color dev: true - /@vitest/expect@0.34.4: - resolution: {integrity: sha512-XlMKX8HyYUqB8dsY8Xxrc64J2Qs9pKMt2Z8vFTL4mBWXJsg4yoALHzJfDWi8h5nkO4Zua4zjqtapQ/IluVkSnA==} + /@vitest/expect@0.34.5: + resolution: {integrity: sha512-/3RBIV9XEH+nRpRMqDJBufKIOQaYUH2X6bt0rKSCW0MfKhXFLYsR5ivHifeajRSTsln0FwJbitxLKHSQz/Xwkw==} dependencies: - '@vitest/spy': 0.34.4 - '@vitest/utils': 0.34.4 - chai: 4.3.8 + '@vitest/spy': 0.34.5 + '@vitest/utils': 0.34.5 + chai: 4.3.9 dev: true - /@vitest/runner@0.34.4: - resolution: {integrity: sha512-hwwdB1StERqUls8oV8YcpmTIpVeJMe4WgYuDongVzixl5hlYLT2G8afhcdADeDeqCaAmZcSgLTLtqkjPQF7x+w==} + /@vitest/runner@0.34.5: + resolution: {integrity: sha512-RDEE3ViVvl7jFSCbnBRyYuu23XxmvRTSZWW6W4M7eC5dOsK75d5LIf6uhE5Fqf809DQ1+9ICZZNxhIolWHU4og==} dependencies: - '@vitest/utils': 0.34.4 + '@vitest/utils': 0.34.5 p-limit: 4.0.0 pathe: 1.1.1 dev: true - /@vitest/snapshot@0.34.4: - resolution: {integrity: sha512-GCsh4coc3YUSL/o+BPUo7lHQbzpdttTxL6f4q0jRx2qVGoYz/cyTRDJHbnwks6TILi6560bVWoBpYC10PuTLHw==} + /@vitest/snapshot@0.34.5: + resolution: {integrity: sha512-+ikwSbhu6z2yOdtKmk/aeoDZ9QPm2g/ZO5rXT58RR9Vmu/kB2MamyDSx77dctqdZfP3Diqv4mbc/yw2kPT8rmA==} dependencies: magic-string: 0.30.3 pathe: 1.1.1 pretty-format: 29.7.0 dev: true - /@vitest/spy@0.34.4: - resolution: {integrity: sha512-PNU+fd7DUPgA3Ya924b1qKuQkonAW6hL7YUjkON3wmBwSTIlhOSpy04SJ0NrRsEbrXgMMj6Morh04BMf8k+w0g==} + /@vitest/spy@0.34.5: + resolution: {integrity: sha512-epsicsfhvBjRjCMOC/3k00mP/TBGQy8/P0DxOFiWyLt55gnZ99dqCfCiAsKO17BWVjn4eZRIjKvcqNmSz8gvmg==} dependencies: tinyspy: 2.1.1 dev: true - /@vitest/utils@0.34.4: - resolution: {integrity: sha512-yR2+5CHhp/K4ySY0Qtd+CAL9f5Yh1aXrKfAT42bq6CtlGPh92jIDDDSg7ydlRow1CP+dys4TrOrbELOyNInHSg==} + /@vitest/utils@0.34.5: + resolution: {integrity: sha512-ur6CmmYQoeHMwmGb0v+qwkwN3yopZuZyf4xt1DBBSGBed8Hf9Gmbm/5dEWqgpLPdRx6Av6jcWXrjcKfkTzg/pw==} dependencies: diff-sequences: 29.6.3 loupe: 2.3.6 @@ -2352,7 +2361,7 @@ packages: /@vue/compiler-core@3.3.4: resolution: {integrity: sha512-cquyDNvZ6jTbf/+x+AgM2Arrp6G4Dzbb0R64jiG804HRMfRiFXWI6kqUVqZ6ZR0bQhIoQjB4+2bhNtVwndW15g==} dependencies: - '@babel/parser': 7.22.16 + '@babel/parser': 7.23.0 '@vue/shared': 3.3.4 estree-walker: 2.0.2 source-map-js: 1.0.2 @@ -2368,7 +2377,7 @@ packages: /@vue/compiler-sfc@3.3.4: resolution: {integrity: sha512-6y/d8uw+5TkCuzBkgLS0v3lSM3hJDntFEiUORM11pQ/hKvkhSKZrXW6i69UyXlJQisJxuUEJKAWEqWbWsLeNKQ==} dependencies: - '@babel/parser': 7.22.16 + '@babel/parser': 7.23.0 '@vue/compiler-core': 3.3.4 '@vue/compiler-dom': 3.3.4 '@vue/compiler-ssr': 3.3.4 @@ -2394,7 +2403,7 @@ packages: /@vue/reactivity-transform@3.3.4: resolution: {integrity: sha512-MXgwjako4nu5WFLAjpBnCj/ieqcjE2aJBINUNQzkZQfzIZA4xn+0fV1tIYBJvvva3N3OvKGofRLvQIwEQPpaXw==} dependencies: - '@babel/parser': 7.22.16 + '@babel/parser': 7.23.0 '@vue/compiler-core': 3.3.4 '@vue/shared': 3.3.4 estree-walker: 2.0.2 @@ -2448,7 +2457,7 @@ packages: - vue dev: true - /@vueuse/integrations@10.4.1(focus-trap@7.5.2)(vue@3.3.4): + /@vueuse/integrations@10.4.1(focus-trap@7.5.3)(vue@3.3.4): resolution: {integrity: sha512-uRBPyG5Lxoh1A/J+boiioPT3ELEAPEo4t8W6Mr4yTKIQBeW/FcbsotZNPr4k9uz+3QEksMmflWloS9wCnypM7g==} peerDependencies: async-validator: '*' @@ -2491,7 +2500,7 @@ packages: dependencies: '@vueuse/core': 10.4.1(vue@3.3.4) '@vueuse/shared': 10.4.1(vue@3.3.4) - focus-trap: 7.5.2 + focus-trap: 7.5.3 vue-demi: 0.14.6(vue@3.3.4) transitivePeerDependencies: - '@vue/composition-api' @@ -2511,8 +2520,8 @@ packages: - vue dev: true - /@wagmi/cli@1.5.0(typescript@5.2.2): - resolution: {integrity: sha512-3L1b/zgdkYPYsnBbtalRcEmSJWGy9hnZjCmkjAj5FDXfaslMmJFTJiNDDYpkpxCtL9iqjbYj0y3ECW7mDfJr7A==} + /@wagmi/cli@1.5.2(typescript@5.2.2): + resolution: {integrity: sha512-UfLMYhW6mQBCjR8A5s01Chf9GpHzdpcuuBuzJ36QGXcMSJAxylz5ImVZWfCRV0ct1UruydjKVSW1QSI6azNxRQ==} engines: {node: '>=14'} hasBin: true peerDependencies: @@ -2548,14 +2557,14 @@ packages: picocolors: 1.0.0 prettier: 2.8.8 typescript: 5.2.2 - viem: 1.10.14(typescript@5.2.2)(zod@3.22.2) + viem: 1.12.2(typescript@5.2.2)(zod@3.22.2) zod: 3.22.2 transitivePeerDependencies: - bufferutil - utf-8-validate dev: true - /@wagmi/connectors@3.1.2(@types/react@18.2.22)(react@18.2.0)(typescript@5.2.2)(viem@1.10.14): + /@wagmi/connectors@3.1.2(@types/react@18.2.23)(react@18.2.0)(typescript@5.2.2)(viem@1.12.2): resolution: {integrity: sha512-IlLKErqCzQRBUcCvXGPowcczbWcvJtEG006gPsAoePNJEXCHEWoKASghgu+L/bqD7006Z6mW6zlTNjcSQJvFAg==} peerDependencies: typescript: '>=5.0.4' @@ -2570,12 +2579,12 @@ packages: '@safe-global/safe-apps-sdk': 8.1.0(typescript@5.2.2) '@walletconnect/ethereum-provider': 2.10.1(@walletconnect/modal@2.6.2) '@walletconnect/legacy-provider': 2.0.0 - '@walletconnect/modal': 2.6.2(@types/react@18.2.22)(react@18.2.0) + '@walletconnect/modal': 2.6.2(@types/react@18.2.23)(react@18.2.0) '@walletconnect/utils': 2.10.1 abitype: 0.8.7(typescript@5.2.2)(zod@3.22.2) eventemitter3: 4.0.7 typescript: 5.2.2 - viem: 1.10.14(typescript@5.2.2)(zod@3.22.2) + viem: 1.12.2(typescript@5.2.2)(zod@3.22.2) transitivePeerDependencies: - '@react-native-async-storage/async-storage' - '@types/react' @@ -2588,7 +2597,7 @@ packages: - zod dev: false - /@wagmi/core@1.4.2(@types/react@18.2.22)(react@18.2.0)(typescript@5.2.2)(viem@1.10.14): + /@wagmi/core@1.4.2(@types/react@18.2.23)(react@18.2.0)(typescript@5.2.2)(viem@1.12.2): resolution: {integrity: sha512-szgNs2DCbBXKsq3wdm/YD8FWkg7lfmTRAv25b2nJYJUTQN59pVXznlWfq8VCJLamhKOYjeYHlTQxXkAeUAJdhw==} peerDependencies: typescript: '>=5.0.4' @@ -2597,12 +2606,12 @@ packages: typescript: optional: true dependencies: - '@wagmi/connectors': 3.1.2(@types/react@18.2.22)(react@18.2.0)(typescript@5.2.2)(viem@1.10.14) + '@wagmi/connectors': 3.1.2(@types/react@18.2.23)(react@18.2.0)(typescript@5.2.2)(viem@1.12.2) abitype: 0.8.7(typescript@5.2.2)(zod@3.22.2) eventemitter3: 4.0.7 typescript: 5.2.2 - viem: 1.10.14(typescript@5.2.2)(zod@3.22.2) - zustand: 4.4.1(@types/react@18.2.22)(react@18.2.0) + viem: 1.12.2(typescript@5.2.2)(zod@3.22.2) + zustand: 4.4.1(@types/react@18.2.23)(react@18.2.0) transitivePeerDependencies: - '@react-native-async-storage/async-storage' - '@types/react' @@ -2679,7 +2688,7 @@ packages: '@walletconnect/jsonrpc-provider': 1.0.13 '@walletconnect/jsonrpc-types': 1.0.3 '@walletconnect/jsonrpc-utils': 1.0.8 - '@walletconnect/modal': 2.6.2(@types/react@18.2.22)(react@18.2.0) + '@walletconnect/modal': 2.6.2(@types/react@18.2.23)(react@18.2.0) '@walletconnect/sign-client': 2.10.1 '@walletconnect/types': 2.10.1 '@walletconnect/universal-provider': 2.10.1 @@ -2834,19 +2843,19 @@ packages: tslib: 1.14.1 dev: false - /@walletconnect/modal-core@2.6.2(@types/react@18.2.22)(react@18.2.0): + /@walletconnect/modal-core@2.6.2(@types/react@18.2.23)(react@18.2.0): resolution: {integrity: sha512-cv8ibvdOJQv2B+nyxP9IIFdxvQznMz8OOr/oR/AaUZym4hjXNL/l1a2UlSQBXrVjo3xxbouMxLb3kBsHoYP2CA==} dependencies: - valtio: 1.11.2(@types/react@18.2.22)(react@18.2.0) + valtio: 1.11.2(@types/react@18.2.23)(react@18.2.0) transitivePeerDependencies: - '@types/react' - react dev: false - /@walletconnect/modal-ui@2.6.2(@types/react@18.2.22)(react@18.2.0): + /@walletconnect/modal-ui@2.6.2(@types/react@18.2.23)(react@18.2.0): resolution: {integrity: sha512-rbdstM1HPGvr7jprQkyPggX7rP4XiCG85ZA+zWBEX0dVQg8PpAgRUqpeub4xQKDgY7pY/xLRXSiCVdWGqvG2HA==} dependencies: - '@walletconnect/modal-core': 2.6.2(@types/react@18.2.22)(react@18.2.0) + '@walletconnect/modal-core': 2.6.2(@types/react@18.2.23)(react@18.2.0) lit: 2.8.0 motion: 10.16.2 qrcode: 1.5.3 @@ -2855,11 +2864,11 @@ packages: - react dev: false - /@walletconnect/modal@2.6.2(@types/react@18.2.22)(react@18.2.0): + /@walletconnect/modal@2.6.2(@types/react@18.2.23)(react@18.2.0): resolution: {integrity: sha512-eFopgKi8AjKf/0U4SemvcYw9zlLpx9njVN8sf6DAkowC2Md0gPU/UNEbH1Wwj407pEKnEds98pKWib1NN1ACoA==} dependencies: - '@walletconnect/modal-core': 2.6.2(@types/react@18.2.22)(react@18.2.0) - '@walletconnect/modal-ui': 2.6.2(@types/react@18.2.22)(react@18.2.0) + '@walletconnect/modal-core': 2.6.2(@types/react@18.2.23)(react@18.2.0) + '@walletconnect/modal-ui': 2.6.2(@types/react@18.2.23)(react@18.2.0) transitivePeerDependencies: - '@types/react' - react @@ -3190,15 +3199,15 @@ packages: engines: {node: '>=8.0.0'} dev: false - /autoprefixer@10.4.15(postcss@8.4.30): - resolution: {integrity: sha512-KCuPB8ZCIqFdA4HwKXsvz7j6gvSDNhDP7WnUjBleRkKjPdvCmHFuQ77ocavI8FT6NdvlBnE2UFr2H4Mycn8Vew==} + /autoprefixer@10.4.16(postcss@8.4.30): + resolution: {integrity: sha512-7vd3UC6xKp0HLfua5IjZlcXvGAGy7cBAXTg2lyQ/8WpNhd6SiZ8Be+xm3FyBSYJx5GKcpRCzBh7RH4/0dnY+uQ==} engines: {node: ^10 || ^12 || >=14} hasBin: true peerDependencies: postcss: ^8.1.0 dependencies: - browserslist: 4.21.10 - caniuse-lite: 1.0.30001535 + browserslist: 4.22.0 + caniuse-lite: 1.0.30001540 fraction.js: 4.3.6 normalize-range: 0.1.2 picocolors: 1.0.0 @@ -3296,15 +3305,15 @@ packages: wcwidth: 1.0.1 dev: true - /browserslist@4.21.10: - resolution: {integrity: sha512-bipEBdZfVH5/pwrvqc+Ub0kUPVfGUhlKxbvfD+z1BDnPEO/X98ruXGA1WP5ASpAFKan7Qr6j736IacbZQuAlKQ==} + /browserslist@4.22.0: + resolution: {integrity: sha512-v+Jcv64L2LbfTC6OnRcaxtqJNJuQAVhZKSJfR/6hn7lhnChUXl4amwVviqN1k411BB+3rRoKMitELRn1CojeRA==} engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true dependencies: - caniuse-lite: 1.0.30001535 - electron-to-chromium: 1.4.523 + caniuse-lite: 1.0.30001540 + electron-to-chromium: 1.4.531 node-releases: 2.0.13 - update-browserslist-db: 1.0.11(browserslist@4.21.10) + update-browserslist-db: 1.0.13(browserslist@4.22.0) /bs58@4.0.1: resolution: {integrity: sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==} @@ -3323,21 +3332,21 @@ packages: engines: {node: '>=6.14.2'} requiresBuild: true dependencies: - node-gyp-build: 4.6.0 + node-gyp-build: 4.6.1 - /bun@1.0.2: - resolution: {integrity: sha512-CkVsc5kMaiV2HCuEBkAZ4mOFBL/C8k7Ui4XnvwP8AAPWCkFXx40OQ5GOHw8qbOZr2+Vzux2vO9JptJPQpA41iA==} + /bun@1.0.3: + resolution: {integrity: sha512-BABgUgJIjSDG6nIviXMfpVx828ocCZW0siajECm51LLgXA9lyraEtZMV7fcDEVm2clb8sVZfd7vm+fqCJLFZJQ==} cpu: [arm64, x64] os: [darwin, linux] hasBin: true requiresBuild: true optionalDependencies: - '@oven/bun-darwin-aarch64': 1.0.2 - '@oven/bun-darwin-x64': 1.0.2 - '@oven/bun-darwin-x64-baseline': 1.0.2 - '@oven/bun-linux-aarch64': 1.0.2 - '@oven/bun-linux-x64': 1.0.2 - '@oven/bun-linux-x64-baseline': 1.0.2 + '@oven/bun-darwin-aarch64': 1.0.3 + '@oven/bun-darwin-x64': 1.0.3 + '@oven/bun-darwin-x64-baseline': 1.0.3 + '@oven/bun-linux-aarch64': 1.0.3 + '@oven/bun-linux-x64': 1.0.3 + '@oven/bun-linux-x64-baseline': 1.0.3 dev: true /bundle-require@3.1.2(esbuild@0.16.17): @@ -3350,8 +3359,8 @@ packages: load-tsconfig: 0.2.5 dev: true - /bundle-require@4.0.1(esbuild@0.18.20): - resolution: {integrity: sha512-9NQkRHlNdNpDBGmLpngF3EFDcwodhMUuLz9PaWYciVcQF9SE4LFjM2DB/xV1Li5JiuDMv7ZUWuC3rGbqR0MAXQ==} + /bundle-require@4.0.2(esbuild@0.18.20): + resolution: {integrity: sha512-jwzPOChofl67PSTW2SGubV9HBQAhhR2i6nskiOThauo9dzwDUgOWQScFVaJkjEfYX+UXiD+LEx8EblQMc2wIag==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} peerDependencies: esbuild: '>=0.17' @@ -3408,8 +3417,8 @@ packages: resolution: {integrity: sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==} engines: {node: '>=6'} - /caniuse-lite@1.0.30001535: - resolution: {integrity: sha512-48jLyUkiWFfhm/afF7cQPqPjaUmSraEhK4j+FCTJpgnGGEZHqyLe3hmWH7lIooZdSzXL0ReMvHz0vKDoTBsrwg==} + /caniuse-lite@1.0.30001540: + resolution: {integrity: sha512-9JL38jscuTJBTcuETxm8QLsFr/F6v0CYYTEU6r5+qSM98P2Q0Hmu0eG1dTG5GBUmywU3UlcVOUSIJYY47rdFSw==} /capital-case@1.0.4: resolution: {integrity: sha512-ds37W8CytHgwnhGGTi88pcPyR15qoNkOpYwmMMfnWqqWgESapLqvDx6huFjQ5vqWSn2Z06173XNA7LtMOeUh1A==} @@ -3419,14 +3428,14 @@ packages: upper-case-first: 2.0.2 dev: true - /chai@4.3.8: - resolution: {integrity: sha512-vX4YvVVtxlfSZ2VecZgFUTU5qPCYsobVI2O9FmwEXBhDigYGQA6jRXCycIs1yJnnWbZ6/+a2zNIF5DfVCcJBFQ==} + /chai@4.3.9: + resolution: {integrity: sha512-tH8vhfA1CfuYMkALXj+wmZcqiwqOfshU9Gry+NYiiLqIddrobkBhALv6XD4yDz68qapphYI4vSaqhqAdThCAAA==} engines: {node: '>=4'} dependencies: assertion-error: 1.1.0 - check-error: 1.0.2 + check-error: 1.0.3 deep-eql: 4.1.3 - get-func-name: 2.0.0 + get-func-name: 2.0.2 loupe: 2.3.6 pathval: 1.1.1 type-detect: 4.0.8 @@ -3473,8 +3482,10 @@ packages: resolution: {integrity: sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==} dev: true - /check-error@1.0.2: - resolution: {integrity: sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==} + /check-error@1.0.3: + resolution: {integrity: sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==} + dependencies: + get-func-name: 2.0.2 dev: true /chokidar@3.5.3: @@ -3589,6 +3600,11 @@ packages: /convert-source-map@1.9.0: resolution: {integrity: sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==} + dev: true + + /convert-source-map@2.0.0: + resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} + dev: false /copy-anything@3.0.5: resolution: {integrity: sha512-yCEafptTtb4bk7GLEQoM8KVJpxAfdBJYaXyzQEgQQQgYrZiDp8SJmGKlYza6CYjEDNstAdNdKA3UuoULlEbS6w==} @@ -3823,8 +3839,8 @@ packages: stream-shift: 1.0.1 dev: false - /electron-to-chromium@1.4.523: - resolution: {integrity: sha512-9AreocSUWnzNtvLcbpng6N+GkXnCcBR80IQkxRC9Dfdyg4gaWNUPBujAHUpKkiUkoSoR9UlhA4zD/IgBklmhzg==} + /electron-to-chromium@1.4.531: + resolution: {integrity: sha512-H6gi5E41Rn3/mhKlPaT1aIMg/71hTAqn0gYEllSuw9igNWtvQwu185jiCZoZD29n7Zukgh7GVZ3zGf0XvkhqjQ==} /emoji-regex@8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} @@ -4235,14 +4251,14 @@ packages: pkg-dir: 4.2.0 dev: true - /focus-trap@7.5.2: - resolution: {integrity: sha512-p6vGNNWLDGwJCiEjkSK6oERj/hEyI9ITsSwIUICBoKLlWiTWXJRfQibCwcoi50rTZdbi87qDtUlMCmQwsGSgPw==} + /focus-trap@7.5.3: + resolution: {integrity: sha512-7UsT/eSJcTPF0aZp73u7hBRTABz26knRRTJfoTGFCQD5mUImLIIOwWWCrtoQdmWa7dykBi6H+Cp5i3S/kvsMeA==} dependencies: tabbable: 6.2.0 dev: true - /follow-redirects@1.15.2: - resolution: {integrity: sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==} + /follow-redirects@1.15.3: + resolution: {integrity: sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==} engines: {node: '>=4.0'} peerDependencies: debug: '*' @@ -4332,8 +4348,8 @@ packages: resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==} engines: {node: 6.* || 8.* || >= 10.*} - /get-func-name@2.0.0: - resolution: {integrity: sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==} + /get-func-name@2.0.2: + resolution: {integrity: sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==} dev: true /get-intrinsic@1.2.1: @@ -4536,7 +4552,7 @@ packages: engines: {node: '>=8.0.0'} dependencies: eventemitter3: 4.0.7 - follow-redirects: 1.15.2 + follow-redirects: 1.15.3 requires-port: 1.0.0 transitivePeerDependencies: - debug @@ -4870,7 +4886,7 @@ packages: engines: {node: '>=8'} hasBin: true dependencies: - '@types/connect': 3.4.35 + '@types/connect': 3.4.36 '@types/node': 12.20.55 '@types/ws': 7.4.7 JSONStream: 1.3.5 @@ -4971,13 +4987,13 @@ packages: engines: {'0': node >= 0.2.0} dev: false - /keccak@3.0.3: - resolution: {integrity: sha512-JZrLIAJWuZxKbCilMpNz5Vj7Vtb4scDG3dMXLOsbzBmQGyjwE61BbW7bJkfKKCShXiQZt3T6sBgALRtmd+nZaQ==} + /keccak@3.0.4: + resolution: {integrity: sha512-3vKuW0jV8J3XNTzvfyicFR5qvxrSAGl7KIhvgOu5cmWwM7tZRj3fMbj/pfIf4be7aznbc+prBWGjywox/g2Y6Q==} engines: {node: '>=10.0.0'} requiresBuild: true dependencies: node-addon-api: 2.0.2 - node-gyp-build: 4.6.0 + node-gyp-build: 4.6.1 readable-stream: 3.6.2 dev: false @@ -5015,7 +5031,7 @@ packages: /lit-html@2.8.0: resolution: {integrity: sha512-o9t+MQM3P4y7M7yNzqAyjp7z+mQGa4NS4CxiyLqFPyFWyc4O+nodLrkrxSaCTrla6M5YOLaT3RpbbqjszB5g3Q==} dependencies: - '@types/trusted-types': 2.0.3 + '@types/trusted-types': 2.0.4 dev: false /lit@2.8.0: @@ -5095,7 +5111,7 @@ packages: /loupe@2.3.6: resolution: {integrity: sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==} dependencies: - get-func-name: 2.0.0 + get-func-name: 2.0.2 dev: true /lower-case@2.0.2: @@ -5154,14 +5170,14 @@ packages: /media-query-parser@2.0.2: resolution: {integrity: sha512-1N4qp+jE0pL5Xv4uEcwVUhIkwdUO3S/9gML90nqKA7v7FcOS5vUtatfzok9S9U1EJU8dHWlcv95WLnKmmxZI9w==} dependencies: - '@babel/runtime': 7.22.15 + '@babel/runtime': 7.23.1 dev: false /meow@6.1.1: resolution: {integrity: sha512-3YffViIt2QWgTy6Pale5QpopX/IvU3LPL03jOTqp6pGj3VjesdO/U8CuHMKpnQr4shCNCM5fd5XFFvIIl6JBHg==} engines: {node: '>=8'} dependencies: - '@types/minimist': 1.2.2 + '@types/minimist': 1.2.3 camelcase-keys: 6.2.2 decamelize-keys: 1.1.1 hard-rejection: 2.1.0 @@ -5250,12 +5266,12 @@ packages: /motion@10.16.2: resolution: {integrity: sha512-p+PurYqfUdcJZvtnmAqu5fJgV2kR0uLFQuBKtLeFVTrYEVllI99tiOTSefVNYuip9ELTEkepIIDftNdze76NAQ==} dependencies: - '@motionone/animation': 10.15.1 - '@motionone/dom': 10.16.2 - '@motionone/svelte': 10.16.2 - '@motionone/types': 10.15.1 - '@motionone/utils': 10.15.1 - '@motionone/vue': 10.16.2 + '@motionone/animation': 10.16.3 + '@motionone/dom': 10.16.4 + '@motionone/svelte': 10.16.4 + '@motionone/types': 10.16.3 + '@motionone/utils': 10.16.3 + '@motionone/vue': 10.16.4 dev: false /ms@2.1.2: @@ -5288,9 +5304,9 @@ packages: picocolors: 1.0.0 dev: true - /next@13.4.19(@babel/core@7.22.20)(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-HuPSzzAbJ1T4BD8e0bs6B9C1kWQ6gv8ykZoRWs5AQoiIuqbGHHdQO7Ljuvg05Q0Z24E2ABozHe6FxDvI6HfyAw==} - engines: {node: '>=16.8.0'} + /next@13.5.3(@babel/core@7.23.0)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-4Nt4HRLYDW/yRpJ/QR2t1v63UOMS55A38dnWv3UDOWGezuY0ZyFO1ABNbD7mulVzs9qVhgy2+ppjdsANpKP1mg==} + engines: {node: '>=16.14.0'} hasBin: true peerDependencies: '@opentelemetry/api': ^1.1.0 @@ -5303,26 +5319,26 @@ packages: sass: optional: true dependencies: - '@next/env': 13.4.19 - '@swc/helpers': 0.5.1 + '@next/env': 13.5.3 + '@swc/helpers': 0.5.2 busboy: 1.6.0 - caniuse-lite: 1.0.30001535 + caniuse-lite: 1.0.30001540 postcss: 8.4.14 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) - styled-jsx: 5.1.1(@babel/core@7.22.20)(react@18.2.0) + styled-jsx: 5.1.1(@babel/core@7.23.0)(react@18.2.0) watchpack: 2.4.0 zod: 3.21.4 optionalDependencies: - '@next/swc-darwin-arm64': 13.4.19 - '@next/swc-darwin-x64': 13.4.19 - '@next/swc-linux-arm64-gnu': 13.4.19 - '@next/swc-linux-arm64-musl': 13.4.19 - '@next/swc-linux-x64-gnu': 13.4.19 - '@next/swc-linux-x64-musl': 13.4.19 - '@next/swc-win32-arm64-msvc': 13.4.19 - '@next/swc-win32-ia32-msvc': 13.4.19 - '@next/swc-win32-x64-msvc': 13.4.19 + '@next/swc-darwin-arm64': 13.5.3 + '@next/swc-darwin-x64': 13.5.3 + '@next/swc-linux-arm64-gnu': 13.5.3 + '@next/swc-linux-arm64-musl': 13.5.3 + '@next/swc-linux-x64-gnu': 13.5.3 + '@next/swc-linux-x64-musl': 13.5.3 + '@next/swc-win32-arm64-msvc': 13.5.3 + '@next/swc-win32-ia32-msvc': 13.5.3 + '@next/swc-win32-x64-msvc': 13.5.3 transitivePeerDependencies: - '@babel/core' - babel-plugin-macros @@ -5365,8 +5381,8 @@ packages: formdata-polyfill: 4.0.10 dev: true - /node-gyp-build@4.6.0: - resolution: {integrity: sha512-NTZVKn9IylLwUzaKjkas1e4u2DLNcV4rdYagA4PWdPwW87Bi7z+BznyKSRwS/761tV/lzCGXplWsiaMjLqP2zQ==} + /node-gyp-build@4.6.1: + resolution: {integrity: sha512-24vnklJmyRS8ViBNI8KbtK/r/DmXQMRiOMXTNz2nrTnAYUwjmEEbnnpB/+kt+yWRv73bPsSPRFddrcIbAxSiMQ==} hasBin: true /node-releases@2.0.13: @@ -5884,12 +5900,12 @@ packages: safe-buffer: 5.2.1 dev: false - /react-countup@6.4.2(@babel/core@7.22.20)(react@18.2.0): + /react-countup@6.4.2(@babel/core@7.23.0)(react@18.2.0): resolution: {integrity: sha512-wdDrNb2lPFGbLb+i0FTgswPbWziubS6KZRII8NRpXmUCoZsi15PFbIHgBz60Dyxd4KPuRvwsK5aawIU4OPP3jA==} peerDependencies: react: '>= 16.3.0' dependencies: - '@rollup/plugin-babel': 6.0.3(@babel/core@7.22.20) + '@rollup/plugin-babel': 6.0.3(@babel/core@7.23.0) countup.js: 2.8.0 react: 18.2.0 transitivePeerDependencies: @@ -5925,7 +5941,7 @@ packages: resolution: {integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==} dev: true - /react-remove-scroll-bar@2.3.4(@types/react@18.2.22)(react@18.2.0): + /react-remove-scroll-bar@2.3.4(@types/react@18.2.23)(react@18.2.0): resolution: {integrity: sha512-63C4YQBUt0m6ALadE9XV56hV8BgJWDmmTPY758iIJjfQKt2nYwoUrPk0LXRXcB/yIj82T1/Ixfdpdk68LwIB0A==} engines: {node: '>=10'} peerDependencies: @@ -5935,13 +5951,13 @@ packages: '@types/react': optional: true dependencies: - '@types/react': 18.2.22 + '@types/react': 18.2.23 react: 18.2.0 - react-style-singleton: 2.2.1(@types/react@18.2.22)(react@18.2.0) + react-style-singleton: 2.2.1(@types/react@18.2.23)(react@18.2.0) tslib: 2.6.2 dev: false - /react-remove-scroll@2.5.4(@types/react@18.2.22)(react@18.2.0): + /react-remove-scroll@2.5.4(@types/react@18.2.23)(react@18.2.0): resolution: {integrity: sha512-xGVKJJr0SJGQVirVFAUZ2k1QLyO6m+2fy0l8Qawbp5Jgrv3DeLalrfMNBFSlmz5kriGGzsVBtGVnf4pTKIhhWA==} engines: {node: '>=10'} peerDependencies: @@ -5951,16 +5967,16 @@ packages: '@types/react': optional: true dependencies: - '@types/react': 18.2.22 + '@types/react': 18.2.23 react: 18.2.0 - react-remove-scroll-bar: 2.3.4(@types/react@18.2.22)(react@18.2.0) - react-style-singleton: 2.2.1(@types/react@18.2.22)(react@18.2.0) + react-remove-scroll-bar: 2.3.4(@types/react@18.2.23)(react@18.2.0) + react-style-singleton: 2.2.1(@types/react@18.2.23)(react@18.2.0) tslib: 2.6.2 - use-callback-ref: 1.3.0(@types/react@18.2.22)(react@18.2.0) - use-sidecar: 1.1.2(@types/react@18.2.22)(react@18.2.0) + use-callback-ref: 1.3.0(@types/react@18.2.23)(react@18.2.0) + use-sidecar: 1.1.2(@types/react@18.2.23)(react@18.2.0) dev: false - /react-style-singleton@2.2.1(@types/react@18.2.22)(react@18.2.0): + /react-style-singleton@2.2.1(@types/react@18.2.23)(react@18.2.0): resolution: {integrity: sha512-ZWj0fHEMyWkHzKYUr2Bs/4zU6XLmq9HsgBURm7g5pAVfyn49DgUiNgY2d4lXRlYSiCif9YBGpQleewkcqddc7g==} engines: {node: '>=10'} peerDependencies: @@ -5970,7 +5986,7 @@ packages: '@types/react': optional: true dependencies: - '@types/react': 18.2.22 + '@types/react': 18.2.23 get-nonce: 1.0.1 invariant: 2.2.4 react: 18.2.0 @@ -6002,7 +6018,7 @@ packages: resolution: {integrity: sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==} engines: {node: '>=8'} dependencies: - '@types/normalize-package-data': 2.4.1 + '@types/normalize-package-data': 2.4.2 normalize-package-data: 2.5.0 parse-json: 5.2.0 type-fest: 0.6.0 @@ -6100,8 +6116,8 @@ packages: engines: {iojs: '>=1.0.0', node: '>=0.10.0'} dev: true - /rollup@3.29.2: - resolution: {integrity: sha512-CJouHoZ27v6siztc21eEQGo0kIcE5D1gVPA571ez0mMYb25LGYGKnVNXpEj5MGlepmDWGXNjDB5q7uNiPHC11A==} + /rollup@3.29.3: + resolution: {integrity: sha512-T7du6Hum8jOkSWetjRgbwpM6Sy0nECYrYRSmZjayFcOddtKJWU4d17AC3HNUk7HRuqy4p+G7aEZclSHytqUmEg==} engines: {node: '>=14.18.0', npm: '>=8.0.0'} hasBin: true optionalDependencies: @@ -6111,10 +6127,10 @@ packages: /rpc-websockets@7.6.0: resolution: {integrity: sha512-Jgcs8q6t8Go98dEulww1x7RysgTkzpCMelVxZW4hvuyFtOGpeUz9prpr2KjUa/usqxgFCd9Tu3+yhHEP9GVmiQ==} dependencies: - '@babel/runtime': 7.22.15 + '@babel/runtime': 7.23.1 eventemitter3: 4.0.7 uuid: 8.3.2 - ws: 8.14.1(bufferutil@4.0.7)(utf-8-validate@5.0.10) + ws: 8.14.2(bufferutil@4.0.7)(utf-8-validate@5.0.10) optionalDependencies: bufferutil: 4.0.7 utf-8-validate: 5.0.10 @@ -6172,8 +6188,8 @@ packages: dependencies: loose-envify: 1.4.0 - /search-insights@2.8.2: - resolution: {integrity: sha512-PxA9M5Q2bpBelVvJ3oDZR8nuY00Z6qwOxL53wNpgzV28M/D6u9WUbImDckjLSILBF8F1hn/mgyuUaOPtjow4Qw==} + /search-insights@2.8.3: + resolution: {integrity: sha512-W9rZfQ9XEfF0O6ntgQOTI7Txc8nkZrO4eJ/pTHK0Br6wWND2sPGPoWg+yGhdIW7wMbLqk8dc23IyEtLlNGpeNw==} dev: true /semver@5.7.2: @@ -6345,7 +6361,7 @@ packages: resolution: {integrity: sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA==} dependencies: spdx-expression-parse: 3.0.1 - spdx-license-ids: 3.0.13 + spdx-license-ids: 3.0.15 dev: true /spdx-exceptions@2.3.0: @@ -6356,11 +6372,11 @@ packages: resolution: {integrity: sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==} dependencies: spdx-exceptions: 2.3.0 - spdx-license-ids: 3.0.13 + spdx-license-ids: 3.0.15 dev: true - /spdx-license-ids@3.0.13: - resolution: {integrity: sha512-XkD+zwiqXHikFZm4AX/7JSCXA98U5Db4AFd5XUg/+9UNtnH75+Z9KxtpYiJZx36mUDVOwH83pl7yvCer6ewM3w==} + /spdx-license-ids@3.0.15: + resolution: {integrity: sha512-lpT8hSQp9jAKp9mhtBU4Xjon8LPGBvLIuBiSVhMEtmLecTh2mO0tlqrAMp47tBXzMr13NJMQ2lf7RpQGLJ3HsQ==} dev: true /split-on-first@1.1.0: @@ -6498,7 +6514,7 @@ packages: acorn: 8.10.0 dev: true - /styled-jsx@5.1.1(@babel/core@7.22.20)(react@18.2.0): + /styled-jsx@5.1.1(@babel/core@7.23.0)(react@18.2.0): resolution: {integrity: sha512-pW7uC1l4mBZ8ugbiZrcIsiIvVx1UmTfw7UkC3Um2tmfUq9Bhk8IiyEIPl6F8agHgjzku6j0xQEZbfA5uSgSaCw==} engines: {node: '>= 12.0.0'} peerDependencies: @@ -6511,7 +6527,7 @@ packages: babel-plugin-macros: optional: true dependencies: - '@babel/core': 7.22.20 + '@babel/core': 7.23.0 client-only: 0.0.1 react: 18.2.0 dev: false @@ -6736,7 +6752,7 @@ packages: typescript: optional: true dependencies: - bundle-require: 4.0.1(esbuild@0.18.20) + bundle-require: 4.0.2(esbuild@0.18.20) cac: 6.7.14 chokidar: 3.5.3 debug: 4.3.4 @@ -6746,7 +6762,7 @@ packages: joycon: 3.1.1 postcss-load-config: 4.0.1(postcss@8.4.30) resolve-from: 5.0.0 - rollup: 3.29.2 + rollup: 3.29.3 source-map: 0.8.0-beta.0 sucrase: 3.34.0 tree-kill: 1.2.2 @@ -6877,13 +6893,13 @@ packages: resolution: {integrity: sha512-AAn47ZncPvgBGOvMcn8tSRxsrqwf2VdAPxLASTuLJvZt4rhKfDvUkmYZLGfclImSfTVMv7tF4ynaVxin0JjDCA==} dev: false - /update-browserslist-db@1.0.11(browserslist@4.21.10): - resolution: {integrity: sha512-dCwEFf0/oT85M1fHBg4F0jtLwJrutGoHSQXCh7u4o2t1drG+c0a9Flnqww6XUKSfQMPpJBRjU8d4RXB09qtvaA==} + /update-browserslist-db@1.0.13(browserslist@4.22.0): + resolution: {integrity: sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==} hasBin: true peerDependencies: browserslist: '>= 4.21.0' dependencies: - browserslist: 4.21.10 + browserslist: 4.22.0 escalade: 3.1.1 picocolors: 1.0.0 @@ -6899,7 +6915,7 @@ packages: tslib: 2.6.2 dev: true - /use-callback-ref@1.3.0(@types/react@18.2.22)(react@18.2.0): + /use-callback-ref@1.3.0(@types/react@18.2.23)(react@18.2.0): resolution: {integrity: sha512-3FT9PRuRdbB9HfXhEq35u4oZkvpJ5kuYbpqhCfmiZyReuRgpnhDlbr2ZEnnuS0RrJAPn6l23xjFg9kpDM+Ms7w==} engines: {node: '>=10'} peerDependencies: @@ -6909,12 +6925,12 @@ packages: '@types/react': optional: true dependencies: - '@types/react': 18.2.22 + '@types/react': 18.2.23 react: 18.2.0 tslib: 2.6.2 dev: false - /use-sidecar@1.1.2(@types/react@18.2.22)(react@18.2.0): + /use-sidecar@1.1.2(@types/react@18.2.23)(react@18.2.0): resolution: {integrity: sha512-epTbsLuzZ7lPClpz2TyryBfztm7m+28DlEv2ZCQ3MDr5ssiwyOwGH/e5F9CkfWjJ1t4clvI58yF822/GUkjjhw==} engines: {node: '>=10'} peerDependencies: @@ -6924,7 +6940,7 @@ packages: '@types/react': optional: true dependencies: - '@types/react': 18.2.22 + '@types/react': 18.2.23 detect-node-es: 1.1.0 react: 18.2.0 tslib: 2.6.2 @@ -6942,7 +6958,7 @@ packages: engines: {node: '>=6.14.2'} requiresBuild: true dependencies: - node-gyp-build: 4.6.0 + node-gyp-build: 4.6.1 /util-deprecate@1.0.2: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} @@ -6978,7 +6994,7 @@ packages: spdx-expression-parse: 3.0.1 dev: true - /valtio@1.11.2(@types/react@18.2.22)(react@18.2.0): + /valtio@1.11.2(@types/react@18.2.23)(react@18.2.0): resolution: {integrity: sha512-1XfIxnUXzyswPAPXo1P3Pdx2mq/pIqZICkWN60Hby0d9Iqb+MEIpqgYVlbflvHdrp2YR/q3jyKWRPJJ100yxaw==} engines: {node: '>=12.20.0'} peerDependencies: @@ -6990,14 +7006,14 @@ packages: react: optional: true dependencies: - '@types/react': 18.2.22 + '@types/react': 18.2.23 proxy-compare: 2.5.1 react: 18.2.0 use-sync-external-store: 1.2.0(react@18.2.0) dev: false - /viem@1.10.14(typescript@5.2.2)(zod@3.22.2): - resolution: {integrity: sha512-GRwFXLFr+/7+7nYYkABgHom3zMIE3DdxZ/DP78QlYWUanpjUV5IebxMOm6pfKD+ZAj3vf9YPAmz+WogjiUgDWw==} + /viem@1.12.2(typescript@5.2.2)(zod@3.22.2): + resolution: {integrity: sha512-aCaUCyg72ES+jK4s6tVYOMnOt4if71RwzgiUAUpAuaCgvHFfh9DCnwuEfwkxEZLE2vafOsirgJ3fcn7nsDVQoQ==} peerDependencies: typescript: '>=5.0.4' peerDependenciesMeta: @@ -7009,7 +7025,7 @@ packages: '@noble/hashes': 1.3.2 '@scure/bip32': 1.3.2 '@scure/bip39': 1.2.1 - '@types/ws': 8.5.5 + '@types/ws': 8.5.6 abitype: 0.9.8(typescript@5.2.2)(zod@3.22.2) isomorphic-ws: 5.0.0(ws@8.13.0) typescript: 5.2.2 @@ -7019,8 +7035,8 @@ packages: - utf-8-validate - zod - /vite-node@0.34.4(@types/node@20.6.2): - resolution: {integrity: sha512-ho8HtiLc+nsmbwZMw8SlghESEE3KxJNp04F/jPUCLVvaURwt0d+r9LxEqCX5hvrrOQ0GSyxbYr5ZfRYhQ0yVKQ==} + /vite-node@0.34.5(@types/node@20.7.0): + resolution: {integrity: sha512-RNZ+DwbCvDoI5CbCSQSyRyzDTfFvFauvMs6Yq4ObJROKlIKuat1KgSX/Ako5rlDMfVCyMcpMRMTkJBxd6z8YRA==} engines: {node: '>=v14.18.0'} hasBin: true dependencies: @@ -7029,7 +7045,7 @@ packages: mlly: 1.4.2 pathe: 1.1.1 picocolors: 1.0.0 - vite: 4.4.9(@types/node@20.6.2) + vite: 4.4.9(@types/node@20.7.0) transitivePeerDependencies: - '@types/node' - less @@ -7041,7 +7057,7 @@ packages: - terser dev: true - /vite@4.4.9(@types/node@20.6.2): + /vite@4.4.9(@types/node@20.7.0): resolution: {integrity: sha512-2mbUn2LlUmNASWwSCNSJ/EG2HuSRTnVNaydp6vMCm5VIqJsjMfbIWtbH2kDuwUVW5mMUKKZvGPX/rqeqVvv1XA==} engines: {node: ^14.18.0 || >=16.0.0} hasBin: true @@ -7069,33 +7085,37 @@ packages: terser: optional: true dependencies: - '@types/node': 20.6.2 + '@types/node': 20.7.0 esbuild: 0.18.20 postcss: 8.4.30 - rollup: 3.29.2 + rollup: 3.29.3 optionalDependencies: fsevents: 2.3.3 dev: true - /vitepress@1.0.0-rc.14(@algolia/client-search@4.20.0)(search-insights@2.8.2): - resolution: {integrity: sha512-yChIeXOAcNvVnSVjhziH1vte0uhKb00PuZf7KdIMfx3ixTMAz73Nn+6gREvCv0SdH+anteGUKz5eljv0ygcgGQ==} + /vitepress@1.0.0-rc.20(@algolia/client-search@4.20.0)(search-insights@2.8.3): + resolution: {integrity: sha512-CykMUJ8JLxLcGWek0ew3wln4RYbsOd1+0YzXITTpajggpynm2S331TNkJVOkHrMRc6GYe3y4pS40GfgcW0ZwAw==} hasBin: true peerDependencies: markdown-it-mathjax3: ^4.3.2 + postcss: ^8.4.30 peerDependenciesMeta: markdown-it-mathjax3: optional: true + postcss: + optional: true dependencies: '@docsearch/css': 3.5.2 - '@docsearch/js': 3.5.2(@algolia/client-search@4.20.0)(search-insights@2.8.2) + '@docsearch/js': 3.5.2(@algolia/client-search@4.20.0)(search-insights@2.8.3) + '@types/markdown-it': 13.0.2 '@vue/devtools-api': 6.5.0 '@vueuse/core': 10.4.1(vue@3.3.4) - '@vueuse/integrations': 10.4.1(focus-trap@7.5.2)(vue@3.3.4) - focus-trap: 7.5.2 + '@vueuse/integrations': 10.4.1(focus-trap@7.5.3)(vue@3.3.4) + focus-trap: 7.5.3 mark.js: 8.11.1 minisearch: 6.1.0 shiki: 0.14.4 - vite: 4.4.9(@types/node@20.6.2) + vite: 4.4.9(@types/node@20.7.0) vue: 3.3.4 transitivePeerDependencies: - '@algolia/client-search' @@ -7124,8 +7144,8 @@ packages: - universal-cookie dev: true - /vitest@0.34.4: - resolution: {integrity: sha512-SE/laOsB6995QlbSE6BtkpXDeVNLJc1u2LHRG/OpnN4RsRzM3GQm4nm3PQCK5OBtrsUqnhzLdnT7se3aeNGdlw==} + /vitest@0.34.5: + resolution: {integrity: sha512-CPI68mmnr2DThSB3frSuE5RLm9wo5wU4fbDrDwWQQB1CWgq9jQVoQwnQSzYAjdoBOPoH2UtXpOgHVge/uScfZg==} engines: {node: '>=v14.18.0'} hasBin: true peerDependencies: @@ -7157,16 +7177,16 @@ packages: dependencies: '@types/chai': 4.3.6 '@types/chai-subset': 1.3.3 - '@types/node': 20.6.2 - '@vitest/expect': 0.34.4 - '@vitest/runner': 0.34.4 - '@vitest/snapshot': 0.34.4 - '@vitest/spy': 0.34.4 - '@vitest/utils': 0.34.4 + '@types/node': 20.7.0 + '@vitest/expect': 0.34.5 + '@vitest/runner': 0.34.5 + '@vitest/snapshot': 0.34.5 + '@vitest/spy': 0.34.5 + '@vitest/utils': 0.34.5 acorn: 8.10.0 acorn-walk: 8.2.0 cac: 6.7.14 - chai: 4.3.8 + chai: 4.3.9 debug: 4.3.4 local-pkg: 0.4.3 magic-string: 0.30.3 @@ -7176,8 +7196,8 @@ packages: strip-literal: 1.3.0 tinybench: 2.5.1 tinypool: 0.7.0 - vite: 4.4.9(@types/node@20.6.2) - vite-node: 0.34.4(@types/node@20.6.2) + vite: 4.4.9(@types/node@20.7.0) + vite-node: 0.34.5(@types/node@20.7.0) why-is-node-running: 2.2.2 transitivePeerDependencies: - less @@ -7222,7 +7242,7 @@ packages: '@vue/shared': 3.3.4 dev: true - /wagmi@1.4.2(@types/react@18.2.22)(react-dom@18.2.0)(react@18.2.0)(typescript@5.2.2)(viem@1.10.14): + /wagmi@1.4.2(@types/react@18.2.23)(react-dom@18.2.0)(react@18.2.0)(typescript@5.2.2)(viem@1.12.2): resolution: {integrity: sha512-Cxu0LatB44stqHoqdc6dgsTb9woYH1bEquJFq9PbTkePmnRCvceAD4aFUREUTaBWzIBcouhFlanWweDzEnb3mg==} peerDependencies: react: '>=17.0.0' @@ -7235,12 +7255,12 @@ packages: '@tanstack/query-sync-storage-persister': 4.35.3 '@tanstack/react-query': 4.35.3(react-dom@18.2.0)(react@18.2.0) '@tanstack/react-query-persist-client': 4.35.5(@tanstack/react-query@4.35.3) - '@wagmi/core': 1.4.2(@types/react@18.2.22)(react@18.2.0)(typescript@5.2.2)(viem@1.10.14) + '@wagmi/core': 1.4.2(@types/react@18.2.23)(react@18.2.0)(typescript@5.2.2)(viem@1.12.2) abitype: 0.8.7(typescript@5.2.2)(zod@3.22.2) react: 18.2.0 typescript: 5.2.2 use-sync-external-store: 1.2.0(react@18.2.0) - viem: 1.10.14(typescript@5.2.2)(zod@3.22.2) + viem: 1.12.2(typescript@5.2.2)(zod@3.22.2) transitivePeerDependencies: - '@react-native-async-storage/async-storage' - '@types/react' @@ -7397,8 +7417,8 @@ packages: utf-8-validate: optional: true - /ws@8.14.1(bufferutil@4.0.7)(utf-8-validate@5.0.10): - resolution: {integrity: sha512-4OOseMUq8AzRBI/7SLMUwO+FEDnguetSk7KMb1sHwvF2w2Wv5Hoj0nlifx8vtGsftE/jWHojPy8sMMzYLJ2G/A==} + /ws@8.14.2(bufferutil@4.0.7)(utf-8-validate@5.0.10): + resolution: {integrity: sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g==} engines: {node: '>=10.0.0'} peerDependencies: bufferutil: ^4.0.1 @@ -7499,7 +7519,7 @@ packages: /zod@3.22.2: resolution: {integrity: sha512-wvWkphh5WQsJbVk1tbx1l1Ly4yg+XecD+Mq280uBGt9wa5BKSWf4Mhp6GmrkPixhMxmabYY7RbzlwVP32pbGCg==} - /zustand@4.4.1(@types/react@18.2.22)(react@18.2.0): + /zustand@4.4.1(@types/react@18.2.23)(react@18.2.0): resolution: {integrity: sha512-QCPfstAS4EBiTQzlaGP1gmorkh/UL1Leaj2tdj+zZCZ/9bm0WS7sI2wnfD5lpOszFqWJ1DcPnGoY8RDL61uokw==} engines: {node: '>=12.7.0'} peerDependencies: @@ -7514,7 +7534,7 @@ packages: react: optional: true dependencies: - '@types/react': 18.2.22 + '@types/react': 18.2.23 react: 18.2.0 use-sync-external-store: 1.2.0(react@18.2.0) dev: false From 22f43d0e329516020034a23f6fa1cec985db5a06 Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Wed, 27 Sep 2023 12:31:34 -0400 Subject: [PATCH 33/42] docs(changeset): Update dependencies, revert simulate changes --- .changeset/eighty-files-work.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/eighty-files-work.md diff --git a/.changeset/eighty-files-work.md b/.changeset/eighty-files-work.md new file mode 100644 index 0000000..0ab5571 --- /dev/null +++ b/.changeset/eighty-files-work.md @@ -0,0 +1,5 @@ +--- +"reverse-mirage": patch +--- + +Update dependencies, revert simulate changes From 0b511f08eb2444c47be28492a8838104b1d681b9 Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Wed, 27 Sep 2023 12:33:27 -0400 Subject: [PATCH 34/42] RELEASING: Releasing 1 package(s) Releases: reverse-mirage@1.0.0-next.4 [skip ci] --- packages/core/CHANGELOG.md | 6 ++++++ packages/core/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index bef29ef..afb0346 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,11 @@ # reverse-mirage +## 1.0.0-next.4 + +### Patch Changes + +- 22f43d0: Update dependencies, revert simulate changes + ## 1.0.0-next.3 ### Patch Changes diff --git a/packages/core/package.json b/packages/core/package.json index abf0fda..30a476e 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "reverse-mirage", - "version": "1.0.0-next.3", + "version": "1.0.0-next.4", "description": "Application level typescript utilities for Ethereum", "type": "module", "sideEffects": false, From 681174b36819814c1bd58bcedcca76e8439717a4 Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Wed, 27 Sep 2023 12:34:37 -0400 Subject: [PATCH 35/42] publish next 4 --- .changeset/pre.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.changeset/pre.json b/.changeset/pre.json index 04a93e5..50d4ed4 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -6,6 +6,7 @@ }, "changesets": [ "afraid-tables-love", + "eighty-files-work", "good-jobs-think", "long-pillows-sip", "young-schools-punch" From 89db9c086d2a1166501e569025aa8fba974605c6 Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Wed, 27 Sep 2023 17:45:47 -0400 Subject: [PATCH 36/42] cleanup mono --- README.md | 8 +++----- package.json | 10 +--------- pnpm-lock.yaml | 40 ++++++++++++++++++++++++++++++++++++---- tsconfig.json | 35 ----------------------------------- 4 files changed, 40 insertions(+), 53 deletions(-) delete mode 100644 tsconfig.json diff --git a/README.md b/README.md index afa3d81..6be6a0c 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,15 @@ -# Reverse Mirage [![GitHub Actions][gha-badge]][gha] [![npm version][npm-badge]][npm] [![npm bundle size][bundle-badge]][bundle] +# Reverse Mirage [![GitHub Actions][gha-badge]][gha] [![npm version][npm-badge]][npm] [gha]: https://github.com/kyscott18/reverse-mirage/actions [gha-badge]: https://github.com/kyscott18/reverse-mirage/actions/workflows/main.yml/badge.svg [npm]: https://www.npmjs.com/package/reverse-mirage/v/latest [npm-badge]: https://img.shields.io/npm/v/reverse-mirage/latest.svg -[bundle]: https://bundlephobia.com/result?p=reverse-mirage@latest -[bundle-badge]:https://img.shields.io/bundlephobia/minzip/reverse-mirage/latest.svg Building blocks for Ethereum app development. Built using [Viem](https://viem.sh). ## Features -- ✅ 10x-100x faster, 10.3x smaller than [`@uniswap/sdk-core`](https://github.com/uniswap/sdk-core) +- ✅ 10x-100x faster, 10.4x smaller than [`@uniswap/sdk-core`](https://github.com/uniswap/sdk-core) - ✅ Abstactions for most commonly used token standards - ✅ Supports `permit` - ✅ Extensible to build apps and libraries @@ -74,6 +72,6 @@ $ bun run src/amount/utils.bench.ts ## Bundle Size -`reverse-mirage`: **5.17 kB** +`reverse-mirage`: **5.12 kB** `@uniswap/sdk-core`: **53.4 kB** diff --git a/package.json b/package.json index 6ef7493..d2ccd20 100644 --- a/package.json +++ b/package.json @@ -4,13 +4,10 @@ "description": "", "private": true, "type": "module", - "workspaces": [ - "packages/*" - ], "scripts": { "install:packages": "pnpm --filter './packages/**' install", "preinstall": "npx -y only-allow pnpm", - "codegen": "pnpm wagmi generate", + "codegen": "wagmi generate", "changeset:publish": "pnpm codegen && pnpm build && pnpm changeset publish", "build": "pnpm --filter 'reverse-mirage' build && pnpm --filter !'reverse-mirage' build", "lint": "pnpm --parallel lint", @@ -23,16 +20,11 @@ "keywords": [], "author": "", "license": "MIT", - "engines": { - "node": ">=18", - "pnpm": ">=8" - }, "devDependencies": { "@biomejs/biome": "^1.2.2", "@changesets/cli": "^2.26.2", "@wagmi/cli": "^1.5.2", "husky": "^8.0.3", - "typescript": "^5.2.2", "vitepress": "1.0.0-rc.20" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 654d28e..f431620 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,9 +20,6 @@ importers: husky: specifier: ^8.0.3 version: 8.0.3 - typescript: - specifier: ^5.2.2 - version: 5.2.2 vitepress: specifier: 1.0.0-rc.20 version: 1.0.0-rc.20(@algolia/client-search@4.20.0)(search-insights@2.8.3) @@ -7057,6 +7054,41 @@ packages: - terser dev: true + /vite@4.4.9: + resolution: {integrity: sha512-2mbUn2LlUmNASWwSCNSJ/EG2HuSRTnVNaydp6vMCm5VIqJsjMfbIWtbH2kDuwUVW5mMUKKZvGPX/rqeqVvv1XA==} + engines: {node: ^14.18.0 || >=16.0.0} + hasBin: true + peerDependencies: + '@types/node': '>= 14' + less: '*' + lightningcss: ^1.21.0 + sass: '*' + stylus: '*' + sugarss: '*' + terser: ^5.4.0 + peerDependenciesMeta: + '@types/node': + optional: true + less: + optional: true + lightningcss: + optional: true + sass: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + dependencies: + esbuild: 0.18.20 + postcss: 8.4.30 + rollup: 3.29.3 + optionalDependencies: + fsevents: 2.3.3 + dev: true + /vite@4.4.9(@types/node@20.7.0): resolution: {integrity: sha512-2mbUn2LlUmNASWwSCNSJ/EG2HuSRTnVNaydp6vMCm5VIqJsjMfbIWtbH2kDuwUVW5mMUKKZvGPX/rqeqVvv1XA==} engines: {node: ^14.18.0 || >=16.0.0} @@ -7115,7 +7147,7 @@ packages: mark.js: 8.11.1 minisearch: 6.1.0 shiki: 0.14.4 - vite: 4.4.9(@types/node@20.7.0) + vite: 4.4.9 vue: 3.3.4 transitivePeerDependencies: - '@algolia/client-search' diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index e0bd4e6..0000000 --- a/tsconfig.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - // This tsconfig file contains the shared config for the build (tsconfig.build.json) and type checking (tsconfig.json) config. - "compilerOptions": { - // Type checking - "strict": true, - "useDefineForClassFields": true, // Not enabled by default in `strict` mode unless we bump `target` to ES2022. - "noFallthroughCasesInSwitch": true, // Not enabled by default in `strict` mode. - "noImplicitReturns": true, // Not enabled by default in `strict` mode. - "useUnknownInCatchVariables": true, // TODO: This would normally be enabled in `strict` mode but would require some adjustments to the codebase. - "noImplicitOverride": true, // Not enabled by default in `strict` mode. - "noUnusedLocals": true, // Not enabled by default in `strict` mode. - "noUnusedParameters": true, // Not enabled by default in `strict` mode. - "exactOptionalPropertyTypes": true, - "noUncheckedIndexedAccess": true, - // JavaScript support - "allowJs": false, - "checkJs": false, - // Interop constraints - "esModuleInterop": false, - "allowSyntheticDefaultImports": false, - "forceConsistentCasingInFileNames": true, - "verbatimModuleSyntax": true, - "importHelpers": true, // This is only used for build validation. Since we do not have `tslib` installed, this will fail if we accidentally make use of anything that'd require injection of helpers. - "resolveJsonModule":true, - // Language and environment - "moduleResolution": "NodeNext", - "module": "NodeNext", - "target": "ES2021", // Setting this to `ES2021` enables native support for `Node v16+`: https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping. - "lib": [ - "ES2022" - ], - // Skip type checking for node modules - "skipLibCheck": true - } -} \ No newline at end of file From b286801e7a42a01eaa8040301a05490c13ab3e58 Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Wed, 27 Sep 2023 18:17:44 -0400 Subject: [PATCH 37/42] docs --- docs/.vitepress/config.mts | 15 +++++++++------ docs/benchmark.md | 2 +- docs/example.md | 2 +- docs/index.md | 2 +- docs/start.md | 23 +++++++++++++++++++++++ 5 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 docs/start.md diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index ad9f28d..31657bb 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -4,19 +4,22 @@ import { defineConfig } from "vitepress"; export default defineConfig({ title: "Reverse Mirage", description: "Application level typescript utilities for Ethereum", - head: [["script", { src: "/_vercel/insights/script.js" }]], + head: [ + ["script", { src: "https://cdn.vercel-insights.com/v1/script.debug.js" }], + ], themeConfig: { search: { provider: "local", }, sidebar: [ + { text: "Introduction", link: "/" }, { - text: "Introduction", + text: "Overview", items: [ - { text: "Getting started", link: "/" }, - { text: "Benchmarks", link: "benchmark" }, - { text: "Examples", link: "example" }, + { text: "Getting started", link: "/start" }, + { text: "Benchmarks", link: "/benchmark" }, + { text: "Examples", link: "/example" }, ], }, { @@ -28,7 +31,7 @@ export default defineConfig({ items: [ { text: "createERC20", - link: "erc20/createERC20", + link: "/erc20/createERC20", }, { text: "createERC20Amount", diff --git a/docs/benchmark.md b/docs/benchmark.md index ff4c856..306afd3 100644 --- a/docs/benchmark.md +++ b/docs/benchmark.md @@ -9,6 +9,6 @@ ## Bundle Size -`reverse-mirage`: **5.17 kB** +`reverse-mirage`: **5.12 kB** `@uniswap/sdk-core`: **53.4 kB** diff --git a/docs/example.md b/docs/example.md index dca6669..ed1dfad 100644 --- a/docs/example.md +++ b/docs/example.md @@ -5,7 +5,7 @@ A [beta interface](https://github.com/kyscott18/reverse-mirage/tree/v1/examples/ ## Features * Runs on an anvil local node -* Query balances +* Query balances, automatically update after transactions * Transfer test tokens * Reset node state from interface diff --git a/docs/index.md b/docs/index.md index 288b7f3..9e31721 100644 --- a/docs/index.md +++ b/docs/index.md @@ -10,7 +10,7 @@ This documentation is still under active development. ## Features -- ✅ 10x-100x faster, 10.3x smaller than [`@uniswap/sdk-core`](https://github.com/uniswap/sdk-core) +- ✅ 10x-100x faster, 10.4x smaller than [`@uniswap/sdk-core`](https://github.com/uniswap/sdk-core) - ✅ Abstactions for most commonly used token standards - ✅ Extensible to build apps and libraries - ✅ Seamless extension to [Viem](https://github.com/wagmi-dev/viem) diff --git a/docs/start.md b/docs/start.md new file mode 100644 index 0000000..565ce69 --- /dev/null +++ b/docs/start.md @@ -0,0 +1,23 @@ +# Getting Started + +## Overview + +what we are trying to do and how. + +you should know viem well before using this. + +## Entities + +### Ethereum contracts + +### Derived from Ethereum + +## Utilities + +## Read actions + +## Write actions + +## Extras + +### Chains From aa84cffc46253bda28a3a3aaed4c6aa307244d80 Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Wed, 27 Sep 2023 21:45:23 -0400 Subject: [PATCH 38/42] more docs --- docs/index.md | 2 +- docs/start.md | 172 ++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 168 insertions(+), 6 deletions(-) diff --git a/docs/index.md b/docs/index.md index 9e31721..f635d5a 100644 --- a/docs/index.md +++ b/docs/index.md @@ -35,7 +35,7 @@ export const publicClient = createPublicClient({ // read token metadata const usdc = await publicClient.getERC20({ address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // usdc - id: mainnet.id + id: mainnet.id, }) console.log(usdc.decimals) // 6 diff --git a/docs/start.md b/docs/start.md index 565ce69..3e8f94a 100644 --- a/docs/start.md +++ b/docs/start.md @@ -2,22 +2,184 @@ ## Overview -what we are trying to do and how. +`reverse-mirage` is a set of TypeScript utilities that provide low-level building blocks for Ethereum app development. `reverse-mirage` is focued on developer experience, stability, bundle size, and performance: -you should know viem well before using this. +- **Developer experience** Automatic type safety and inference, comprehensive documentation, expressive types. +- **Stability** Test suite runs against local Ethereum networks, near complete test coverage. +- **Bundle size** Tree-shakable and lightweight. +- **Performance** Optimized arithmetic functions, decoding, and parsing all taking advantage of modern javascript. -## Entities +`reverse-mirage` relies heavily on [`viem`](https://viem.sh). All users should be familiar with this package before continuing. -### Ethereum contracts +## Types -### Derived from Ethereum +### Tokens + +Tokens represent an asset on Ethereum. Tokens by themselves don't hold any specific state, but can be used to read from Ethereum or send a transaction. Currently `reverse-mirage` has: + +- **ERC20**: Fungible tokens +- **ERC721**: Non-fungible tokens +- **ERC1155**: Semi-fungible tokens +- **Native**: Native currency i.e. Ether +- **WETH**: ERC20 wrapped native currency + +### Convenience + +Convenience types help make it easier to use Ethereum in TypeScript. This includes: + +- **Amount**: Token amounts with support for decimals +- **Price**: Exchange rates between tokens with support for decimals ## Utilities +There are many functions for creating certain types. + +::: code-group + +```ts [create.ts] +import { mainnet } from 'viem/chains' +import { + createNativeCurrency, + createAmountFromString, + createAmountFromRaw, + } from 'reverse-mirage' +// [!code focus:5] +const eth = createNativeCurrency('Ether', 'ETH', 18, mainnet.id) + +createAmountFromString(eth, '15') +createAmountFromRaw(1000000000000000000n) + +``` + +::: + +### Convenience Utilities + +Convenience types also contain certain arithmetic and decoding functions. + +::: code-group + +```ts [amounts.ts] +import { mainnet } from 'viem/chains' +import { + createNativeCurrency, + createAmountFromString, + amountAdd, + amountMultiply, + amountEqual, + amountToNumber, + } from 'reverse-mirage' +// [!code focus:9] +const eth = createNativeCurrency('Ether', 'ETH', 18, mainnet.id) +const amount = createAmountFromString(eth, '15') + +const a = amountAdd(amount, amount) +const b = amountMultiply(amount, 2) + +console.log(amountEqual(a, b)) // true +console.log(amountToNumber(a)) // 30 + +``` + +::: + ## Read actions +Read actions are used to read data from Ethereum. There are many functions for each token type. + +::: code-group + +```ts [read.ts] +import { createPublicClient, http } from 'viem' +import { mainnet } from 'viem/chains' +import { publicActionsReverseMirage, amountToNumber } from 'reverse-mirage' + +export const publicClient = createPublicClient({ + chain: mainnet, + transport: http() +}).extend(publicActionsReverseMirage) +// [!code focus:12] +// read token metadata +const usdc = await publicClient.getERC20({ + address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // usdc + id: mainnet.id, +}) + +// read a balance +const vitalikBalance = await publicClient.getERC20Balance({ + erc20: usdc, + address: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', // vitalik +}) + +``` + +::: + ## Write actions +Write actions are used to prepare a transaction for Ethereum. Each token type has its own set of write actions. + +::: code-group + +```ts [read.ts] +import { createPublicClient, http } from 'viem' +import { mainnet } from 'viem/chains' +import { publicActionsReverseMirage, amountToNumber } from 'reverse-mirage' + +export const publicClient = createPublicClient({ + chain: mainnet, + transport: http() +}).extend(publicActionsReverseMirage) +// [!code focus:13] +const usdc = await publicClient.getERC20({ + address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // usdc + id: mainnet.id +}) + +// send usdc +const { request } = await publicClient.simulateERC20Transfer({ + args: { + amount: createAmountFromString(usdc, '5'), + to: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', // vitalik + }, +}) + +``` + +::: + ## Extras ### Chains + +Known tokens are also exported for popular chains. + +::: code-group + +```ts [chains.ts] +import { celoTokens } from 'reverse-mirage' +// [!code focus:3] +console.log(celoTokens.native.decimals) // 18 +console.log(celoTokens.weth.address) // 0x471E...a438 + +``` + +::: + +`native` and `weth` are exported for: + +- **mainnet** +- **goerli** +- **sepolia** +- **celo** +- **celoAlfajores** +- **optimism** +- **optimismGoerli** +- **base** +- **baseGoerli** +- **arbitrum** +- **arbitrumGoerli** + +### ABIs + +`erc20`, `erc721`, `erc1155`, and `weth` all have a corresponding exported Abi. From 348afa76a33c4a17a475c6fb6632645c636c4d66 Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Wed, 27 Sep 2023 21:50:07 -0400 Subject: [PATCH 39/42] try fix actions #1 --- package.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package.json b/package.json index d2ccd20..d1c425c 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,10 @@ "test:ci": "pnpm --parallel test:ci", "test:cov": "pnpm --parallel test:cov" }, + "engines": { + "node": ">=18", + "pnpm": ">=8" + }, "keywords": [], "author": "", "license": "MIT", From cd5336664e28d8eeb1293538b19fbe8d3e73d80c Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Wed, 27 Sep 2023 21:53:59 -0400 Subject: [PATCH 40/42] try fix actions #2 --- package.json | 1 + pnpm-lock.yaml | 40 ++++------------------------------------ tsconfig.json | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 36 deletions(-) create mode 100644 tsconfig.json diff --git a/package.json b/package.json index d1c425c..f1e3891 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "@changesets/cli": "^2.26.2", "@wagmi/cli": "^1.5.2", "husky": "^8.0.3", + "typescript": "^5.2.2", "vitepress": "1.0.0-rc.20" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f431620..654d28e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,6 +20,9 @@ importers: husky: specifier: ^8.0.3 version: 8.0.3 + typescript: + specifier: ^5.2.2 + version: 5.2.2 vitepress: specifier: 1.0.0-rc.20 version: 1.0.0-rc.20(@algolia/client-search@4.20.0)(search-insights@2.8.3) @@ -7054,41 +7057,6 @@ packages: - terser dev: true - /vite@4.4.9: - resolution: {integrity: sha512-2mbUn2LlUmNASWwSCNSJ/EG2HuSRTnVNaydp6vMCm5VIqJsjMfbIWtbH2kDuwUVW5mMUKKZvGPX/rqeqVvv1XA==} - engines: {node: ^14.18.0 || >=16.0.0} - hasBin: true - peerDependencies: - '@types/node': '>= 14' - less: '*' - lightningcss: ^1.21.0 - sass: '*' - stylus: '*' - sugarss: '*' - terser: ^5.4.0 - peerDependenciesMeta: - '@types/node': - optional: true - less: - optional: true - lightningcss: - optional: true - sass: - optional: true - stylus: - optional: true - sugarss: - optional: true - terser: - optional: true - dependencies: - esbuild: 0.18.20 - postcss: 8.4.30 - rollup: 3.29.3 - optionalDependencies: - fsevents: 2.3.3 - dev: true - /vite@4.4.9(@types/node@20.7.0): resolution: {integrity: sha512-2mbUn2LlUmNASWwSCNSJ/EG2HuSRTnVNaydp6vMCm5VIqJsjMfbIWtbH2kDuwUVW5mMUKKZvGPX/rqeqVvv1XA==} engines: {node: ^14.18.0 || >=16.0.0} @@ -7147,7 +7115,7 @@ packages: mark.js: 8.11.1 minisearch: 6.1.0 shiki: 0.14.4 - vite: 4.4.9 + vite: 4.4.9(@types/node@20.7.0) vue: 3.3.4 transitivePeerDependencies: - '@algolia/client-search' diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..e0bd4e6 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,35 @@ +{ + // This tsconfig file contains the shared config for the build (tsconfig.build.json) and type checking (tsconfig.json) config. + "compilerOptions": { + // Type checking + "strict": true, + "useDefineForClassFields": true, // Not enabled by default in `strict` mode unless we bump `target` to ES2022. + "noFallthroughCasesInSwitch": true, // Not enabled by default in `strict` mode. + "noImplicitReturns": true, // Not enabled by default in `strict` mode. + "useUnknownInCatchVariables": true, // TODO: This would normally be enabled in `strict` mode but would require some adjustments to the codebase. + "noImplicitOverride": true, // Not enabled by default in `strict` mode. + "noUnusedLocals": true, // Not enabled by default in `strict` mode. + "noUnusedParameters": true, // Not enabled by default in `strict` mode. + "exactOptionalPropertyTypes": true, + "noUncheckedIndexedAccess": true, + // JavaScript support + "allowJs": false, + "checkJs": false, + // Interop constraints + "esModuleInterop": false, + "allowSyntheticDefaultImports": false, + "forceConsistentCasingInFileNames": true, + "verbatimModuleSyntax": true, + "importHelpers": true, // This is only used for build validation. Since we do not have `tslib` installed, this will fail if we accidentally make use of anything that'd require injection of helpers. + "resolveJsonModule":true, + // Language and environment + "moduleResolution": "NodeNext", + "module": "NodeNext", + "target": "ES2021", // Setting this to `ES2021` enables native support for `Node v16+`: https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping. + "lib": [ + "ES2022" + ], + // Skip type checking for node modules + "skipLibCheck": true + } +} \ No newline at end of file From ec349331fee1f8605e512bca285f9d059108bd84 Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Wed, 27 Sep 2023 21:56:59 -0400 Subject: [PATCH 41/42] RELEASING: Releasing 2 package(s) Releases: reverse-mirage@1.0.0 reverse-mirage-next-example@0.1.1 [skip ci] --- .changeset/afraid-tables-love.md | 5 ----- .changeset/eighty-files-work.md | 5 ----- .changeset/good-jobs-think.md | 5 ----- .changeset/long-pillows-sip.md | 5 ----- .changeset/young-schools-punch.md | 5 ----- examples/next-interface/CHANGELOG.md | 12 ++++++++++++ examples/next-interface/package.json | 2 +- packages/core/CHANGELOG.md | 13 +++++++++++++ packages/core/package.json | 2 +- 9 files changed, 27 insertions(+), 27 deletions(-) delete mode 100644 .changeset/afraid-tables-love.md delete mode 100644 .changeset/eighty-files-work.md delete mode 100644 .changeset/good-jobs-think.md delete mode 100644 .changeset/long-pillows-sip.md delete mode 100644 .changeset/young-schools-punch.md create mode 100644 examples/next-interface/CHANGELOG.md diff --git a/.changeset/afraid-tables-love.md b/.changeset/afraid-tables-love.md deleted file mode 100644 index 420bb5e..0000000 --- a/.changeset/afraid-tables-love.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"reverse-mirage": patch ---- - -Change wallet actions to write contract diff --git a/.changeset/eighty-files-work.md b/.changeset/eighty-files-work.md deleted file mode 100644 index 0ab5571..0000000 --- a/.changeset/eighty-files-work.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"reverse-mirage": patch ---- - -Update dependencies, revert simulate changes diff --git a/.changeset/good-jobs-think.md b/.changeset/good-jobs-think.md deleted file mode 100644 index 4ba6368..0000000 --- a/.changeset/good-jobs-think.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"reverse-mirage": patch ---- - -bug fixes diff --git a/.changeset/long-pillows-sip.md b/.changeset/long-pillows-sip.md deleted file mode 100644 index 250714d..0000000 --- a/.changeset/long-pillows-sip.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"reverse-mirage": major ---- - -Restructure directory layout and extends viem client" diff --git a/.changeset/young-schools-punch.md b/.changeset/young-schools-punch.md deleted file mode 100644 index 7fc4d27..0000000 --- a/.changeset/young-schools-punch.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"reverse-mirage": patch ---- - -Add decorator to extend viem diff --git a/examples/next-interface/CHANGELOG.md b/examples/next-interface/CHANGELOG.md new file mode 100644 index 0000000..6ec316c --- /dev/null +++ b/examples/next-interface/CHANGELOG.md @@ -0,0 +1,12 @@ +# reverse-mirage-next-example + +## 0.1.1 + +### Patch Changes + +- Updated dependencies [ad4046c] +- Updated dependencies [22f43d0] +- Updated dependencies [64ac88a] +- Updated dependencies [51e3d32] +- Updated dependencies [89add6a] + - reverse-mirage@1.0.0 diff --git a/examples/next-interface/package.json b/examples/next-interface/package.json index 24f5bc4..a9d1b41 100644 --- a/examples/next-interface/package.json +++ b/examples/next-interface/package.json @@ -1,6 +1,6 @@ { "name": "reverse-mirage-next-example", - "version": "0.1.0", + "version": "0.1.1", "private": true, "scripts": { "dev": "next dev", diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index afb0346..62db448 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,18 @@ # reverse-mirage +## 1.0.0 + +### Major Changes + +- 51e3d32: Restructure directory layout and extends viem client" + +### Patch Changes + +- ad4046c: Change wallet actions to write contract +- 22f43d0: Update dependencies, revert simulate changes +- 64ac88a: bug fixes +- 89add6a: Add decorator to extend viem + ## 1.0.0-next.4 ### Patch Changes diff --git a/packages/core/package.json b/packages/core/package.json index 30a476e..c3d96ce 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "reverse-mirage", - "version": "1.0.0-next.4", + "version": "1.0.0", "description": "Application level typescript utilities for Ethereum", "type": "module", "sideEffects": false, From a32f4ab40f3aee752fa0ba36edb1e2b0c801bc60 Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Wed, 27 Sep 2023 21:58:15 -0400 Subject: [PATCH 42/42] publish --- .changeset/pre.json | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 .changeset/pre.json diff --git a/.changeset/pre.json b/.changeset/pre.json deleted file mode 100644 index 50d4ed4..0000000 --- a/.changeset/pre.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "mode": "pre", - "tag": "next", - "initialVersions": { - "reverse-mirage": "0.1.11" - }, - "changesets": [ - "afraid-tables-love", - "eighty-files-work", - "good-jobs-think", - "long-pillows-sip", - "young-schools-punch" - ] -}