-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
724 additions
and
6 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
dist | ||
out | ||
test-contracts-out | ||
broadcast | ||
cache |
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
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,56 @@ | ||
import { SchemaType } from "@latticexyz/schema-type"; | ||
import path from "path"; | ||
import { parseStoreConfig, StoreUserConfig } from "../src/config/index.js"; | ||
import { tablegen } from "../src/render-solidity/tablegen.js"; | ||
import { logError } from "../src/utils/errors.js"; | ||
import { getSrcDirectory } from "../src/utils/forgeConfig.js"; | ||
|
||
// This config is used only for tests | ||
const config: StoreUserConfig = { | ||
tables: { | ||
Table1: { | ||
primaryKeys: { | ||
k1: SchemaType.UINT256, | ||
k2: SchemaType.INT32, | ||
k3: SchemaType.BYTES16, | ||
k4: SchemaType.ADDRESS, | ||
k5: SchemaType.BOOL, | ||
k6: "Enum1", | ||
k7: "Enum2", | ||
}, | ||
schema: { | ||
v1: SchemaType.UINT256, | ||
v2: SchemaType.INT32, | ||
v3: SchemaType.BYTES16, | ||
v4: SchemaType.ADDRESS, | ||
v5: SchemaType.BOOL, | ||
v6: "Enum1", | ||
v7: "Enum2", | ||
}, | ||
}, | ||
}, | ||
|
||
userTypes: { | ||
enums: { | ||
Enum1: ["E1", "E2", "E3"], | ||
Enum2: ["E1"], | ||
}, | ||
}, | ||
}; | ||
|
||
// Aside from avoiding `mud.config.mts` in cli package (could cause issues), | ||
// this also tests that tablegen can work as a standalone function | ||
const parsedConfig = await (async () => { | ||
try { | ||
return await parseStoreConfig(config); | ||
} catch (error: unknown) { | ||
logError(error); | ||
} | ||
})(); | ||
|
||
const srcDirectory = await getSrcDirectory(); | ||
if (parsedConfig !== undefined) { | ||
tablegen(parsedConfig, srcDirectory); | ||
} else { | ||
process.exit(1); | ||
} |
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
Oops, something went wrong.