-
Notifications
You must be signed in to change notification settings - Fork 181
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
feat(cli,create-mud,store,world): add abi-ts to replace typechain #1403
Conversation
🦋 Changeset detectedLatest commit: 1efce8d The changes in this PR will be included in the next version bump. This PR includes changesets to release 28 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
4386db2
to
54212f7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is very exciting! just minor nits
@@ -3,7 +3,7 @@ import { createFaucetService } from "@latticexyz/services/faucet"; | |||
import { encodeEntity, syncToRecs } from "@latticexyz/store-sync/recs"; | |||
import { getNetworkConfig } from "./getNetworkConfig"; | |||
import { world } from "./world"; | |||
import { IWorld__factory } from "contracts/types/ethers-contracts/factories/IWorld__factory"; | |||
import IWorldAbi from "contracts/abi-ts/IWorld.sol/IWorld"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -66,7 +65,7 @@ const commandModule: CommandModule<Options, Options> = { | |||
|
|||
// Create World contract instance from deployed address | |||
const provider = new ethers.providers.StaticJsonRpcProvider(rpc); | |||
const WorldContract = new ethers.Contract(worldAddress, IBaseWorldData.abi, provider) as IBaseWorld; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct! this would have been the last remaining spot to use typechain, so I opted to ditch it all for the short time that we're between ethers and viem for deploys
@@ -14,7 +14,6 @@ | |||
"./register": "./dist/ts/register/index.js", | |||
"./node": "./dist/ts/node/index.js", | |||
"./abi/*": "./abi/*", | |||
"./types/*": "./types/*", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we mention this change in the changeset? (if consumers relied on these types they need to either generate them via typechain in their project or use abitype)
Same for the corresponding store package change
Co-authored-by: alvarius <alvarius@lattice.xyz>
Co-authored-by: alvarius <alvarius@lattice.xyz>
// Run typechain to rebuild typescript types for the contracts | ||
await worldtypes(); | ||
// Generate TS-friendly ABI files | ||
// We rebuild into a separate dir to have a clean set of ABIs without test/script contracts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this comment still up to date?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, still relevant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more context:
We need forge to build everything to run things like tests, scripts, etc. But for a clean ABI dir, we want to ignore these. It's tricky to use the same target dir (e.g. out
) because then tests won't find the build files they need to run. So we use a separate dir just for ABIs.
Since abi-ts can now target/build a specific ABI file or glob, we could simplify this to just a single output dir and only build IWorld ABI, but has trade-offs in that it's a bit harder for users to expand that if they want to include more ABIs in their TS code.
big diff because I removed checked-in types from example and e2e dirs (don't think we need em in here for now and they were a pain to update if core stuff changed)
TODO:
related to microsoft/TypeScript#32063