Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(world-module-erc20): export erc20 module from internal #3319

Merged
merged 8 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw it's safe to just export * here since its internal

Loading