From 90803770ee72bfd2b9ba9a7990285d1c5866f362 Mon Sep 17 00:00:00 2001 From: V Date: Wed, 23 Oct 2024 10:37:07 -0300 Subject: [PATCH] chore(world-module-erc20): export erc20 module from internal (#3319) Co-authored-by: Kevin Ingersoll --- .changeset/giant-birds-argue.md | 4 ++-- packages/world-module-erc20/README.md | 4 ++-- packages/world-module-erc20/package.json | 6 +++--- .../ts/{exports/index.ts => defineERC20Module.ts} | 5 +++-- packages/world-module-erc20/ts/exports/internal.ts | 1 + packages/world-module-erc20/tsup.config.ts | 2 +- packages/world/ts/exports/internal.ts | 1 + 7 files changed, 13 insertions(+), 10 deletions(-) rename packages/world-module-erc20/ts/{exports/index.ts => defineERC20Module.ts} (71%) create mode 100644 packages/world-module-erc20/ts/exports/internal.ts diff --git a/.changeset/giant-birds-argue.md b/.changeset/giant-birds-argue.md index 422a6e2193..a9290bab97 100644 --- a/.changeset/giant-birds-argue.md +++ b/.changeset/giant-birds-argue.md @@ -7,10 +7,10 @@ The new ERC20 World Module provides a simpler alternative to the ERC20 Puppet Mo To install this module, you can import and define the module configuration from the NPM package: ```typescript -import { defineERC20Config } from "@latticexyz/world-module-erc20"; +import { defineERC20Module } from "@latticexyz/world-module-erc20/internal"; // Add the output of this function to your World's modules -const config = defineERC20Config({ namespace: "erc20Namespace", name: "MyToken", symbol: "MTK" }); +const erc20Module = defineERC20Module({ namespace: "erc20Namespace", name: "MyToken", symbol: "MTK" }); ``` For detailed installation instructions, please check out the [`@latticexyz/world-module-erc20` README.md](https://github.com/latticexyz/mud/blob/main/packages/world-module-erc20/README.md). diff --git a/packages/world-module-erc20/README.md b/packages/world-module-erc20/README.md index 376b9d5334..e5234edf75 100644 --- a/packages/world-module-erc20/README.md +++ b/packages/world-module-erc20/README.md @@ -92,7 +92,7 @@ In your MUD config: ```typescript import { defineWorld } from "@latticexyz/world"; -import { defineERC20Config } from "@latticexyz/world-module-erc20"; +import { defineERC20Module } from "@latticexyz/world-module-erc20/internal"; export default defineWorld({ namespace: "app", @@ -105,7 +105,7 @@ export default defineWorld({ }, }, modules: [ - defineERC20Config({ + defineERC20Module({ namespace: "erc20Namespace", name: "MyToken", symbol: "MTK", diff --git a/packages/world-module-erc20/package.json b/packages/world-module-erc20/package.json index 9b2f749668..a0f9611446 100644 --- a/packages/world-module-erc20/package.json +++ b/packages/world-module-erc20/package.json @@ -10,8 +10,8 @@ "license": "MIT", "type": "module", "exports": { + "./internal": "./dist/internal.js", "./mud.config": "./dist/mud.config.js", - ".": "./dist/index.js", "./out/*": "./out/*" }, "typesVersions": { @@ -19,8 +19,8 @@ "mud.config": [ "./dist/mud.config.d.ts" ], - "module": [ - "./dist/module.d.ts" + "internal": [ + "./dist/internal.d.ts" ] } }, diff --git a/packages/world-module-erc20/ts/exports/index.ts b/packages/world-module-erc20/ts/defineERC20Module.ts similarity index 71% rename from packages/world-module-erc20/ts/exports/index.ts rename to packages/world-module-erc20/ts/defineERC20Module.ts index dc7389f17c..5c9533a06c 100644 --- a/packages/world-module-erc20/ts/exports/index.ts +++ b/packages/world-module-erc20/ts/defineERC20Module.ts @@ -1,12 +1,13 @@ import { encodeAbiParameters, stringToHex } from "viem"; +import { ModuleInput } from "@latticexyz/world/internal"; -export type DefineERC20ConfigInput = { +export type DefineERC20ModuleInput = { namespace: string; name: string; symbol: string; }; -export function defineERC20Config({ namespace, name, symbol }: DefineERC20ConfigInput) { +export function defineERC20Module({ namespace, name, symbol }: DefineERC20ModuleInput): ModuleInput { const erc20ModuleArgs = encodeAbiParameters( [{ type: "bytes14" }, { type: "string" }, { type: "string" }], [stringToHex(namespace, { size: 14 }), name, symbol], diff --git a/packages/world-module-erc20/ts/exports/internal.ts b/packages/world-module-erc20/ts/exports/internal.ts new file mode 100644 index 0000000000..7c24958b2f --- /dev/null +++ b/packages/world-module-erc20/ts/exports/internal.ts @@ -0,0 +1 @@ +export { defineERC20Module } from "../defineERC20Module"; diff --git a/packages/world-module-erc20/tsup.config.ts b/packages/world-module-erc20/tsup.config.ts index e4f6e18a78..3f2057dd81 100644 --- a/packages/world-module-erc20/tsup.config.ts +++ b/packages/world-module-erc20/tsup.config.ts @@ -3,7 +3,7 @@ import { defineConfig } from "tsup"; export default defineConfig({ entry: { "mud.config": "mud.config.ts", - index: "ts/exports/index.ts", + internal: "ts/exports/internal.ts", }, target: "esnext", format: ["esm"], diff --git a/packages/world/ts/exports/internal.ts b/packages/world/ts/exports/internal.ts index 9899b7b47a..9515e42046 100644 --- a/packages/world/ts/exports/internal.ts +++ b/packages/world/ts/exports/internal.ts @@ -11,3 +11,4 @@ export * from "../getFunctions"; export * from "../getWorldAbi"; export { resolveTableId, resolveWithContext } from "../config/v2/dynamicResolution"; +export { ModuleInput } from "../config/v2/input";