Skip to content

Commit

Permalink
chore(world-module-erc20): export erc20 module from internal (#3319)
Browse files Browse the repository at this point in the history
Co-authored-by: Kevin Ingersoll <[email protected]>
  • Loading branch information
vdrg and holic authored Oct 23, 2024
1 parent 1712814 commit 9080377
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .changeset/giant-birds-argue.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
4 changes: 2 additions & 2 deletions packages/world-module-erc20/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -105,7 +105,7 @@ export default defineWorld({
},
},
modules: [
defineERC20Config({
defineERC20Module({
namespace: "erc20Namespace",
name: "MyToken",
symbol: "MTK",
Expand Down
6 changes: 3 additions & 3 deletions packages/world-module-erc20/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
"license": "MIT",
"type": "module",
"exports": {
"./internal": "./dist/internal.js",
"./mud.config": "./dist/mud.config.js",
".": "./dist/index.js",
"./out/*": "./out/*"
},
"typesVersions": {
"*": {
"mud.config": [
"./dist/mud.config.d.ts"
],
"module": [
"./dist/module.d.ts"
"internal": [
"./dist/internal.d.ts"
]
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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],
Expand Down
1 change: 1 addition & 0 deletions packages/world-module-erc20/ts/exports/internal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { defineERC20Module } from "../defineERC20Module";
2 changes: 1 addition & 1 deletion packages/world-module-erc20/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
1 change: 1 addition & 0 deletions packages/world/ts/exports/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export * from "../getFunctions";
export * from "../getWorldAbi";

export { resolveTableId, resolveWithContext } from "../config/v2/dynamicResolution";
export { ModuleInput } from "../config/v2/input";

0 comments on commit 9080377

Please sign in to comment.