Skip to content

Commit

Permalink
docs: rework abi-ts changesets
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Sep 7, 2023
1 parent 9af542d commit cc2c0d4
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 19 deletions.
19 changes: 19 additions & 0 deletions .changeset/short-ads-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
"@latticexyz/abi-ts": minor
"@latticexyz/cli": minor
---

Added a new `@latticexyz/abi-ts` package to generate TS type declaration files (`.d.ts`) for each ABI JSON file.

This allows you to import your JSON ABI and use it directly with libraries like [viem](https://npmjs.com/package/viem) and [abitype](https://npmjs.com/package/abitype).

```
pnpm add @latticexyz/abi-ts
pnpm abi-ts
```

By default, `abi-ts` looks for files with the glob `**/*.abi.json`, but you can customize this glob with the `--input` argument, e.g.

```console
pnpm abi-ts --input 'abi/IWorld.sol/IWorld.abi.json'
```
20 changes: 1 addition & 19 deletions .changeset/six-cats-agree.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
---
"@latticexyz/abi-ts": minor
"@latticexyz/cli": minor
"@latticexyz/store": minor
"@latticexyz/world": minor
"create-mud": minor
---

Added a new `@latticexyz/abi-ts` package to generate TS type declaration files (`.d.ts`) for each ABI JSON file. This replaces our usage TypeChain everywhere. It's also bundled into `@latticexyz/cli` under the `mud abi-ts` command.
We now use `@latticexyz/abi-ts` to generate TS type declaration files (`.d.ts`) for each ABI JSON file. This replaces our usage TypeChain everywhere.

If you have a MUD project created from an older template, you can replace TypeChain with `abi-ts` by first updating your contracts' `package.json`:

Expand All @@ -31,17 +27,3 @@ And update your client's `setupNetwork.ts` with:
- abi: IWorld__factory.abi,
+ abi: IWorldAbi,
```

If you previously relied on TypeChain types from `@latticexyz/store` or `@latticexyz/world`, you will either need to migrate to viem or abitype using ABI JSON imports or generate TypeChain types from our exported ABI JSON files.

```ts
import { getContract } from "viem";
import IStoreAbi from "@latticexyz/store/abi/IStore.sol/IStore.abi.json";

const storeContract = getContract({
abi: IStoreAbi,
...
});

await storeContract.write.setRecord(...);
```
20 changes: 20 additions & 0 deletions .changeset/unlucky-guests-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
"@latticexyz/store": minor
"@latticexyz/world": minor
---

We now use `@latticexyz/abi-ts` to generate TS type declaration files (`.d.ts`) for each ABI JSON file. This replaces our usage TypeChain everywhere.

If you previously relied on TypeChain types from `@latticexyz/store` or `@latticexyz/world`, you will either need to migrate to viem or abitype using ABI JSON imports or generate TypeChain types from our exported ABI JSON files.

```ts
import { getContract } from "viem";
import IStoreAbi from "@latticexyz/store/abi/IStore.sol/IStore.abi.json";

const storeContract = getContract({
abi: IStoreAbi,
...
});

await storeContract.write.setRecord(...);
```

0 comments on commit cc2c0d4

Please sign in to comment.