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

refactor(store): update tablegen with namespaces output #2972

Merged
merged 16 commits into from
Jul 26, 2024

Conversation

holic
Copy link
Member

@holic holic commented Jul 25, 2024

reminders to self when refactoring worldgen:

  • update worldImportPath like we did here for storeImportPath
  • replace usages of usedInPath and then get rid of solidityRelativeImportPath and related code

Copy link

changeset-bot bot commented Jul 25, 2024

🦋 Changeset detected

Latest commit: e9071c7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 24 packages
Name Type
@latticexyz/store Patch
@latticexyz/cli Patch
@latticexyz/dev-tools Patch
@latticexyz/query Patch
@latticexyz/react Patch
@latticexyz/store-indexer Patch
@latticexyz/store-sync Patch
@latticexyz/world-modules Patch
@latticexyz/world Patch
mock-game-contracts Patch
ts-benchmarks Patch
@latticexyz/abi-ts Patch
@latticexyz/block-logs-stream Patch
@latticexyz/common Patch
@latticexyz/config Patch
create-mud Patch
@latticexyz/faucet Patch
@latticexyz/gas-report Patch
@latticexyz/protocol-parser Patch
@latticexyz/recs Patch
@latticexyz/schema-type Patch
solhint-config-mud Patch
solhint-plugin-mud Patch
@latticexyz/utils Patch

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

TestTypeInt64: { filePath: "./contracts/src/types.sol", type: "int64" },
TestTypeBool: { filePath: "./contracts/src/types.sol", type: "bool" },
TestTypeUint128: { filePath: "./contracts/src/types.sol", type: "uint128" },
TestTypeAddress: { filePath: "../contracts/src/types.sol", type: "address" },
Copy link
Member Author

@holic holic Jul 25, 2024

Choose a reason for hiding this comment

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

previously, codegen expected this path to be relative to process.cwd() (almost always the project root/same dir as the mud.config.ts)

once I changed the paths to be relative to the project root/mud.config.ts, this broke, because for this particular script, the config is in a slightly different place

this was an inconsistency/edge case that should now be more consistent and predictable and enables better resolving of user types from within namespaced directories

TestTypeAddress: { filePath: "../contracts/src/types.sol", type: "address" },
TestTypeInt64: { filePath: "../contracts/src/types.sol", type: "int64" },
"TestTypeLibrary.TestTypeBool": { filePath: "../contracts/src/types.sol", type: "bool" },
"TestTypeLibrary.TestTypeUint128": { filePath: "../contracts/src/types.sol", type: "uint128" },
Copy link
Member Author

Choose a reason for hiding this comment

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

previously, codegen would parse the file at filePath to determine where in the file was the specified user type and then propagate the fully qualified name everywhere

this felt too "automagic" to me and added a lot of complexity to codegen that I was able to remove by not automatically inferring the code path for the user type (with the nice side effect that we no longer need remappings for tablegen)

we can still support this (imo rare) case by specifying the fully qualified type name like above

(maybe in the future could improve this with a similar "label" approach where the label is used in config references like schemas, and allow specifying a fully qualified code path override of internalType that gets used in codegen)

@holic holic marked this pull request as ready for review July 25, 2024 15:55
@holic holic requested a review from alvrs as a code owner July 25, 2024 15:55
@@ -2,7 +2,7 @@ import { defineStore } from "./ts/config/v2/store";

export default defineStore({
codegen: {
storeImportPath: "../../",
storeImportPath: "./src",
Copy link
Member Author

Choose a reason for hiding this comment

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

fyi this is an internal config option

@holic holic merged commit 69eb63b into main Jul 26, 2024
14 checks passed
@holic holic deleted the holic/tablegen-namespaces branch July 26, 2024 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants