-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: rework abi-ts changesets (#1413)
- Loading branch information
Showing
3 changed files
with
40 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(...); | ||
``` |