diff --git a/.changeset/loud-rockets-switch.md b/.changeset/loud-rockets-switch.md new file mode 100644 index 0000000000..2e80de7d69 --- /dev/null +++ b/.changeset/loud-rockets-switch.md @@ -0,0 +1,5 @@ +--- +"@latticexyz/common": patch +--- + +Upgraded prettier version to 3.2.5 and prettier-plugin-solidity version to 1.3.1. diff --git a/.changeset/nasty-waves-divide.md b/.changeset/nasty-waves-divide.md index f85dd96047..61ac31054c 100644 --- a/.changeset/nasty-waves-divide.md +++ b/.changeset/nasty-waves-divide.md @@ -22,7 +22,7 @@ const latestBlock$ = await createBlockStream({ publicClient, blockTag: "latest" const latestBlockNumber$ = latestBlock$.pipe( filter(isNonPendingBlock), - map((block) => block.number) + map((block) => block.number), ); latestBlockNumber$ @@ -38,7 +38,7 @@ latestBlockNumber$ "event StoreEphemeralRecord(bytes32 table, bytes32[] key, bytes data)", ]), }), - mergeMap(({ logs }) => from(groupLogsByBlockNumber(logs))) + mergeMap(({ logs }) => from(groupLogsByBlockNumber(logs))), ) .subscribe((block) => { console.log("got events for block", block); diff --git a/.changeset/tame-lemons-play.md b/.changeset/tame-lemons-play.md index e20f0bcd55..17de0f9339 100644 --- a/.changeset/tame-lemons-play.md +++ b/.changeset/tame-lemons-play.md @@ -172,7 +172,7 @@ As you migrate, you may find some features replaced, removed, or not included by .pipe( map((block) => Number(block.timestamp) * 1000), // Map to timestamp in ms filter((blockTimestamp) => blockTimestamp !== clock.lastUpdateTime), // Ignore if the clock was already refreshed with this block - filter((blockTimestamp) => blockTimestamp !== clock.currentTime) // Ignore if the current local timestamp is correct + filter((blockTimestamp) => blockTimestamp !== clock.currentTime), // Ignore if the current local timestamp is correct ) .subscribe(clock.update); // Update the local clock ``` diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e3efbf55d..12d6a624bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3395,7 +3395,7 @@ As you migrate, you may find some features replaced, removed, or not included by .pipe( map((block) => Number(block.timestamp) * 1000), // Map to timestamp in ms filter((blockTimestamp) => blockTimestamp !== clock.lastUpdateTime), // Ignore if the clock was already refreshed with this block - filter((blockTimestamp) => blockTimestamp !== clock.currentTime) // Ignore if the current local timestamp is correct + filter((blockTimestamp) => blockTimestamp !== clock.currentTime), // Ignore if the current local timestamp is correct ) .subscribe(clock.update); // Update the local clock ``` @@ -3633,7 +3633,7 @@ const latestBlock$ = await createBlockStream({ publicClient, blockTag: "latest" const latestBlockNumber$ = latestBlock$.pipe( filter(isNonPendingBlock), - map((block) => block.number) + map((block) => block.number), ); latestBlockNumber$ @@ -3649,7 +3649,7 @@ latestBlockNumber$ "event StoreEphemeralRecord(bytes32 table, bytes32[] key, bytes data)", ]), }), - mergeMap(({ logs }) => from(groupLogsByBlockNumber(logs))) + mergeMap(({ logs }) => from(groupLogsByBlockNumber(logs))), ) .subscribe((block) => { console.log("got events for block", block); diff --git a/docs/app/page.tsx b/docs/app/page.tsx index 7a954b39d5..bbb7c29d8c 100644 --- a/docs/app/page.tsx +++ b/docs/app/page.tsx @@ -24,7 +24,7 @@ export default async function HomePage() { "min-h-screen flex flex-col animate-in animate-duration-500 fade-in", "gap-12 p-8", "sm:justify-between", - "md:gap-16 md:p-16" + "md:gap-16 md:p-16", )} >
diff --git a/docs/components/MUDTable.module.css b/docs/components/MUDTable.module.css index becc677b84..97b6223686 100644 --- a/docs/components/MUDTable.module.css +++ b/docs/components/MUDTable.module.css @@ -1,5 +1,13 @@ .table { - font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace; + font-family: + ui-monospace, + SFMono-Regular, + Menlo, + Monaco, + Consolas, + Liberation Mono, + Courier New, + monospace; background-color: hsl(var(--nextra-primary-hue) 100% 66%/0.1); margin-top: 1em; text-align: center; diff --git a/docs/pages/changelog.mdx b/docs/pages/changelog.mdx index 9e3efbf55d..12d6a624bf 100644 --- a/docs/pages/changelog.mdx +++ b/docs/pages/changelog.mdx @@ -3395,7 +3395,7 @@ As you migrate, you may find some features replaced, removed, or not included by .pipe( map((block) => Number(block.timestamp) * 1000), // Map to timestamp in ms filter((blockTimestamp) => blockTimestamp !== clock.lastUpdateTime), // Ignore if the clock was already refreshed with this block - filter((blockTimestamp) => blockTimestamp !== clock.currentTime) // Ignore if the current local timestamp is correct + filter((blockTimestamp) => blockTimestamp !== clock.currentTime), // Ignore if the current local timestamp is correct ) .subscribe(clock.update); // Update the local clock ``` @@ -3633,7 +3633,7 @@ const latestBlock$ = await createBlockStream({ publicClient, blockTag: "latest" const latestBlockNumber$ = latestBlock$.pipe( filter(isNonPendingBlock), - map((block) => block.number) + map((block) => block.number), ); latestBlockNumber$ @@ -3649,7 +3649,7 @@ latestBlockNumber$ "event StoreEphemeralRecord(bytes32 table, bytes32[] key, bytes data)", ]), }), - mergeMap(({ logs }) => from(groupLogsByBlockNumber(logs))) + mergeMap(({ logs }) => from(groupLogsByBlockNumber(logs))), ) .subscribe((block) => { console.log("got events for block", block); diff --git a/docs/pages/guides/emojimon/3-players-and-movement.mdx b/docs/pages/guides/emojimon/3-players-and-movement.mdx index d5eac88e95..cefe114200 100644 --- a/docs/pages/guides/emojimon/3-players-and-movement.mdx +++ b/docs/pages/guides/emojimon/3-players-and-movement.mdx @@ -255,7 +255,7 @@ export type SystemCalls = ReturnType; export function createSystemCalls( { playerEntity, worldContract, waitForTransaction }: SetupNetworkResult, - { Player, Position }: ClientComponents + { Player, Position }: ClientComponents, ) { const moveBy = async (deltaX: number, deltaY: number) => { if (!playerEntity) { diff --git a/docs/pages/guides/emojimon/4-map-and-terrain.mdx b/docs/pages/guides/emojimon/4-map-and-terrain.mdx index 4e81e1584d..bbbc842494 100644 --- a/docs/pages/guides/emojimon/4-map-and-terrain.mdx +++ b/docs/pages/guides/emojimon/4-map-and-terrain.mdx @@ -445,7 +445,7 @@ export type SystemCalls = ReturnType; export function createSystemCalls( { playerEntity, worldContract, waitForTransaction }: SetupNetworkResult, - { MapConfig, Obstruction, Player, Position }: ClientComponents + { MapConfig, Obstruction, Player, Position }: ClientComponents, ) { const isObstructed = (x: number, y: number) => { return runQuery([Has(Obstruction), HasValue(Position, { x, y })]).size > 0; diff --git a/docs/pages/guides/emojimon/5-a-wild-emojimon-appears.mdx b/docs/pages/guides/emojimon/5-a-wild-emojimon-appears.mdx index 7392e1f57e..b7522d7304 100644 --- a/docs/pages/guides/emojimon/5-a-wild-emojimon-appears.mdx +++ b/docs/pages/guides/emojimon/5-a-wild-emojimon-appears.mdx @@ -718,7 +718,7 @@ export type SystemCalls = ReturnType; export function createSystemCalls( { playerEntity, worldContract, waitForTransaction }: SetupNetworkResult, - { Encounter, MapConfig, MonsterCatchAttempt, Obstruction, Player, Position }: ClientComponents + { Encounter, MapConfig, MonsterCatchAttempt, Obstruction, Player, Position }: ClientComponents, ) { const wrapPosition = (x: number, y: number) => { const mapConfig = getComponentValue(MapConfig, singletonEntity); @@ -890,7 +890,7 @@ export type SystemCalls = ReturnType; export function createSystemCalls( { playerEntity, worldContract, waitForTransaction }: SetupNetworkResult, - { Encounter, MapConfig, MonsterCatchAttempt, Obstruction, Player, Position }: ClientComponents + { Encounter, MapConfig, MonsterCatchAttempt, Obstruction, Player, Position }: ClientComponents, ) { const wrapPosition = (x: number, y: number) => { const mapConfig = getComponentValue(MapConfig, singletonEntity); diff --git a/docs/pages/guides/hello-world/add-table.mdx b/docs/pages/guides/hello-world/add-table.mdx index 0673138767..b1fa6dc4d6 100644 --- a/docs/pages/guides/hello-world/add-table.mdx +++ b/docs/pages/guides/hello-world/add-table.mdx @@ -261,7 +261,7 @@ This exclamation point tells the compiler that it's OK, there will be a real val ```html filename="index.html" copy showLineNumbers {12-17} - + diff --git a/docs/pages/store/reference/store-core.mdx b/docs/pages/store/reference/store-core.mdx index 4d9d0f1dd8..253ec361fc 100644 --- a/docs/pages/store/reference/store-core.mdx +++ b/docs/pages/store/reference/store-core.mdx @@ -770,7 +770,11 @@ Emitted when a new record is set in the store. ```solidity event Store_SetRecord( - ResourceId indexed tableId, bytes32[] keyTuple, bytes staticData, PackedCounter encodedLengths, bytes dynamicData + ResourceId indexed tableId, + bytes32[] keyTuple, + bytes staticData, + PackedCounter encodedLengths, + bytes dynamicData ); ``` @@ -810,13 +814,13 @@ Emitted when dynamic data in the store is spliced. ```solidity event Store_SpliceDynamicData( - ResourceId indexed tableId, - bytes32[] keyTuple, - uint8 dynamicFieldIndex, - uint48 start, - uint40 deleteCount, - PackedCounter encodedLengths, - bytes data + ResourceId indexed tableId, + bytes32[] keyTuple, + uint8 dynamicFieldIndex, + uint48 start, + uint40 deleteCount, + PackedCounter encodedLengths, + bytes data ); ``` diff --git a/docs/pages/store/reference/store.mdx b/docs/pages/store/reference/store.mdx index 6670f89e71..250240a5e9 100644 --- a/docs/pages/store/reference/store.mdx +++ b/docs/pages/store/reference/store.mdx @@ -19,7 +19,11 @@ Emitted when a new record is set in the store. ```solidity event Store_SetRecord( - ResourceId indexed tableId, bytes32[] keyTuple, bytes staticData, PackedCounter encodedLengths, bytes dynamicData + ResourceId indexed tableId, + bytes32[] keyTuple, + bytes staticData, + PackedCounter encodedLengths, + bytes dynamicData ); ``` @@ -59,13 +63,13 @@ Emitted when dynamic data in the store is spliced. ```solidity event Store_SpliceDynamicData( - ResourceId indexed tableId, - bytes32[] keyTuple, - uint8 dynamicFieldIndex, - uint48 start, - uint40 deleteCount, - PackedCounter encodedLengths, - bytes data + ResourceId indexed tableId, + bytes32[] keyTuple, + uint8 dynamicFieldIndex, + uint48 start, + uint40 deleteCount, + PackedCounter encodedLengths, + bytes data ); ``` diff --git a/docs/src/tailwindcss-plugins/animate.ts b/docs/src/tailwindcss-plugins/animate.ts index f64ba44b27..1c6e3c1369 100644 --- a/docs/src/tailwindcss-plugins/animate.ts +++ b/docs/src/tailwindcss-plugins/animate.ts @@ -37,7 +37,7 @@ module.exports = plugin( "fade-in": (value) => ({ "--tw-enter-opacity": value }), "fade-out": (value) => ({ "--tw-exit-opacity": value }), }, - { values: theme("animationOpacity") } + { values: theme("animationOpacity") }, ); matchUtilities( @@ -45,7 +45,7 @@ module.exports = plugin( "zoom-in": (value) => ({ "--tw-enter-scale": value }), "zoom-out": (value) => ({ "--tw-exit-scale": value }), }, - { values: theme("animationScale") } + { values: theme("animationScale") }, ); matchUtilities( @@ -53,7 +53,7 @@ module.exports = plugin( "spin-in": (value) => ({ "--tw-enter-rotate": value }), "spin-out": (value) => ({ "--tw-exit-rotate": value }), }, - { values: theme("animationRotate") } + { values: theme("animationRotate") }, ); matchUtilities( @@ -83,19 +83,19 @@ module.exports = plugin( "--tw-exit-translate-x": value, }), }, - { values: theme("animationTranslate") } + { values: theme("animationTranslate") }, ); matchUtilities( { "animate-duration": (value: string) => ({ animationDuration: value }) }, - { values: filterDefault(theme("animationDuration")) } + { values: filterDefault(theme("animationDuration")) }, ); matchUtilities({ delay: (value) => ({ animationDelay: value }) }, { values: theme("animationDelay") }); matchUtilities( { ease: (value: string) => ({ animationTimingFunction: value }) }, - { values: filterDefault(theme("animationTimingFunction")) } + { values: filterDefault(theme("animationTimingFunction")) }, ); addUtilities({ @@ -175,5 +175,5 @@ module.exports = plugin( }, }, }, - } + }, ); diff --git a/e2e/packages/client-vanilla/src/index.ts b/e2e/packages/client-vanilla/src/index.ts index 464d986f78..7899f3c949 100644 --- a/e2e/packages/client-vanilla/src/index.ts +++ b/e2e/packages/client-vanilla/src/index.ts @@ -17,7 +17,7 @@ _window.getEntities = (componentName: keyof typeof components) => Array.from(com _window.getKeys = (componentName: keyof typeof components) => Array.from(components[componentName].entities()).map((entity) => - decodeEntity(components[componentName].metadata.keySchema, entity) + decodeEntity(components[componentName].metadata.keySchema, entity), ); // Update block number in the UI diff --git a/e2e/packages/contracts/package.json b/e2e/packages/contracts/package.json index 27a8b462a5..3f1b229fb3 100644 --- a/e2e/packages/contracts/package.json +++ b/e2e/packages/contracts/package.json @@ -19,7 +19,7 @@ "dotenv": "^16.0.3", "ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0", "forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1", - "prettier": "^2.6.2", + "prettier": "3.2.5", "rimraf": "^3.0.2", "typescript": "5.1.6", "vite": "^4.2.1", diff --git a/e2e/packages/contracts/src/codegen/world/IWorld.sol b/e2e/packages/contracts/src/codegen/world/IWorld.sol index e0c902f4ad..62448e2b51 100644 --- a/e2e/packages/contracts/src/codegen/world/IWorld.sol +++ b/e2e/packages/contracts/src/codegen/world/IWorld.sol @@ -17,6 +17,4 @@ import { IVectorSystem } from "./IVectorSystem.sol"; * that are dynamically registered in the World during deployment. * @dev This is an autogenerated file; do not edit manually. */ -interface IWorld is IBaseWorld, ICustomErrorsSystem, INumberListSystem, INumberSystem, IVectorSystem { - -} +interface IWorld is IBaseWorld, ICustomErrorsSystem, INumberListSystem, INumberSystem, IVectorSystem {} diff --git a/e2e/packages/sync-test/compare/compare.test.ts b/e2e/packages/sync-test/compare/compare.test.ts index f3bb9b5351..c6d7f0f8f7 100644 --- a/e2e/packages/sync-test/compare/compare.test.ts +++ b/e2e/packages/sync-test/compare/compare.test.ts @@ -35,7 +35,7 @@ function setRecord( address: Address, tableId: TableId, key: Key, - data: Data + data: Data, ): void { state[address.toLowerCase()] ??= {}; state[address.toLowerCase()][tableId] ??= {}; @@ -46,7 +46,7 @@ function getRecord( state: Record>>, address: Address, tableId: TableId, - key: Key + key: Key, ): Data | undefined { return state[address]?.[tableId]?.[key]; } diff --git a/e2e/packages/sync-test/data/callPageFunction.ts b/e2e/packages/sync-test/data/callPageFunction.ts index ece5b02e01..89a9c395a4 100644 --- a/e2e/packages/sync-test/data/callPageFunction.ts +++ b/e2e/packages/sync-test/data/callPageFunction.ts @@ -9,7 +9,7 @@ import { deserialize, serialize } from "./utils"; export async function callPageFunction( page: Page, functionName: string, - args: unknown[] + args: unknown[], ): Promise | undefined> { const context = [functionName, args, serialize.toString(), deserialize.toString()] as const; const serializedValue = await page.evaluate(async ([functionName, args, serializeString, deserializeString]) => { diff --git a/e2e/packages/sync-test/data/callWorld.ts b/e2e/packages/sync-test/data/callWorld.ts index c19e1d9029..c6b58c04c6 100644 --- a/e2e/packages/sync-test/data/callWorld.ts +++ b/e2e/packages/sync-test/data/callWorld.ts @@ -23,6 +23,6 @@ export function callWorld(page: Page, method: T throw new Error([`Error executing ${_method} with args:`, JSON.stringify(_args), error].join("\n\n")); }); }, - [method, args] + [method, args], ); } diff --git a/e2e/packages/sync-test/data/types.ts b/e2e/packages/sync-test/data/types.ts index b79ac3f3b6..98369a7426 100644 --- a/e2e/packages/sync-test/data/types.ts +++ b/e2e/packages/sync-test/data/types.ts @@ -2,9 +2,10 @@ import { SchemaAbiType, SchemaAbiTypeToPrimitiveType } from "@latticexyz/schema-type"; import config from "../../contracts/mud.config"; import { Hex } from "viem"; -type SchemaToPrimitive = Schema extends Record - ? { [key in keyof Schema]: SchemaAbiTypeToPrimitiveType } - : never; +type SchemaToPrimitive = + Schema extends Record + ? { [key in keyof Schema]: SchemaAbiTypeToPrimitiveType } + : never; type Key = SchemaToPrimitive< (typeof config)["tables"][Table]["keySchema"] diff --git a/e2e/packages/sync-test/indexerSync.test.ts b/e2e/packages/sync-test/indexerSync.test.ts index f23edf5f16..3585c6e4a2 100644 --- a/e2e/packages/sync-test/indexerSync.test.ts +++ b/e2e/packages/sync-test/indexerSync.test.ts @@ -143,7 +143,7 @@ describe("Sync from indexer", async () => { y: -2, zone: "0x6d61703100000000000000000000000000000000000000000000000000000000", }, - ]) + ]), ); // Should not have thrown errors diff --git a/e2e/packages/sync-test/setup/openClientWithRootAccount.ts b/e2e/packages/sync-test/setup/openClientWithRootAccount.ts index 85b88658d6..98158ca286 100644 --- a/e2e/packages/sync-test/setup/openClientWithRootAccount.ts +++ b/e2e/packages/sync-test/setup/openClientWithRootAccount.ts @@ -12,6 +12,6 @@ export async function openClientWithRootAccount(page: Page, options?: { indexerU // I wish I could pass undefined values into URLSearchParams and have them be ignored during stringify ...(process.env.PRIVATE_KEY ? { privateKey: process.env.PRIVATE_KEY } : null), ...(options?.indexerUrl ? { indexerUrl: options?.indexerUrl } : null), - }).toString()}` + }).toString()}`, ); } diff --git a/e2e/packages/sync-test/setup/startBrowserAndPage.ts b/e2e/packages/sync-test/setup/startBrowserAndPage.ts index 0f18151879..9cbced06a0 100644 --- a/e2e/packages/sync-test/setup/startBrowserAndPage.ts +++ b/e2e/packages/sync-test/setup/startBrowserAndPage.ts @@ -2,7 +2,7 @@ import { Browser, Page, chromium } from "@playwright/test"; import chalk from "chalk"; export async function startBrowserAndPage( - reportError: (error: string) => void + reportError: (error: string) => void, ): Promise<{ browser: Browser; page: Page }> { // open browser page const browser = await chromium.launch(); diff --git a/e2e/packages/test-data/generate-bench-data-bulk.ts b/e2e/packages/test-data/generate-bench-data-bulk.ts index 313ad45a7d..c69fad503f 100644 --- a/e2e/packages/test-data/generate-bench-data-bulk.ts +++ b/e2e/packages/test-data/generate-bench-data-bulk.ts @@ -34,7 +34,7 @@ for (let i = 0; i < NUM_RECORDS.length; i++) { const logsFilename = path.join( path.dirname(fileURLToPath(import.meta.url)), - `../../../test-data/world-logs-bulk-${numRecords}.json` + `../../../test-data/world-logs-bulk-${numRecords}.json`, ); console.log("writing", logs.length, "logs to", logsFilename); diff --git a/e2e/packages/test-data/generate-bench-data-query.ts b/e2e/packages/test-data/generate-bench-data-query.ts index d97a976fd4..4e34afe75c 100644 --- a/e2e/packages/test-data/generate-bench-data-query.ts +++ b/e2e/packages/test-data/generate-bench-data-query.ts @@ -30,7 +30,7 @@ const logs = await generateLogs(rpc, async (worldContract) => { const logsFilename = path.join( path.dirname(fileURLToPath(import.meta.url)), - `../../../test-data/world-logs-query.json` + `../../../test-data/world-logs-query.json`, ); console.log("writing", logs.length, "logs to", logsFilename); diff --git a/e2e/packages/test-data/generateLogs.ts b/e2e/packages/test-data/generateLogs.ts index fff5449b2f..ba855efe61 100644 --- a/e2e/packages/test-data/generateLogs.ts +++ b/e2e/packages/test-data/generateLogs.ts @@ -31,7 +31,7 @@ type WorldContract = GetContractReturnType< export async function generateLogs( rpc: string, - transactionHook: (worldContract: WorldContract) => Promise + transactionHook: (worldContract: WorldContract) => Promise, ): Promise { console.log("deploying world"); const { stdout, stderr } = await execa("pnpm", ["mud", "deploy", "--rpc", rpc, "--saveDeployment", "false"], { @@ -88,7 +88,7 @@ export async function generateLogs( encodeEventTopics({ abi: [event], eventName: event.name, - }) + }), ), ], fromBlock: numberToHex(0n), diff --git a/e2e/pnpm-lock.yaml b/e2e/pnpm-lock.yaml index 5f0ff0d145..cce221a655 100644 --- a/e2e/pnpm-lock.yaml +++ b/e2e/pnpm-lock.yaml @@ -112,8 +112,8 @@ importers: specifier: https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1 version: github.com/foundry-rs/forge-std/74cfb77e308dd188d2f58864aaf44963ae6b88b1 prettier: - specifier: ^2.6.2 - version: 2.6.2 + specifier: 3.2.5 + version: 3.2.5 rimraf: specifier: ^3.0.2 version: 3.0.2 @@ -1531,9 +1531,9 @@ packages: resolution: {integrity: sha512-+JD93VELV9gHkqpV5gdL5/70HdGtEw4/XE1S4BC8f1mcPmdib3K5XsKVbnR1XcAyC41zOnifJ+9YRKxdIsXiUw==} dev: true - /prettier@2.6.2: - resolution: {integrity: sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==} - engines: {node: '>=10.13.0'} + /prettier@3.2.5: + resolution: {integrity: sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==} + engines: {node: '>=14'} hasBin: true dev: true diff --git a/examples/minimal/packages/client-phaser/src/mud/createSystemCalls.ts b/examples/minimal/packages/client-phaser/src/mud/createSystemCalls.ts index 1e0c674320..37203654b1 100644 --- a/examples/minimal/packages/client-phaser/src/mud/createSystemCalls.ts +++ b/examples/minimal/packages/client-phaser/src/mud/createSystemCalls.ts @@ -7,7 +7,7 @@ export type SystemCalls = ReturnType; export function createSystemCalls( { worldContract, waitForTransaction }: SetupNetworkResult, - { CounterTable }: ClientComponents + { CounterTable }: ClientComponents, ) { const increment = async () => { const tx = await worldContract.write.increment(); diff --git a/examples/minimal/packages/client-phaser/src/ui/App.tsx b/examples/minimal/packages/client-phaser/src/ui/App.tsx index 69529815b5..0ddd731ec7 100644 --- a/examples/minimal/packages/client-phaser/src/ui/App.tsx +++ b/examples/minimal/packages/client-phaser/src/ui/App.tsx @@ -26,7 +26,7 @@ export const App = () => { worldAbi: networkLayer.network.worldContract.abi, write$: networkLayer.network.write$, recsWorld: networkLayer.world, - }) + }), ); } }, [networkLayer]); diff --git a/examples/minimal/packages/client-phaser/src/ui/hooks/usePhaserLayer.tsx b/examples/minimal/packages/client-phaser/src/ui/hooks/usePhaserLayer.tsx index f0a4c36da7..c6292e57ff 100644 --- a/examples/minimal/packages/client-phaser/src/ui/hooks/usePhaserLayer.tsx +++ b/examples/minimal/packages/client-phaser/src/ui/hooks/usePhaserLayer.tsx @@ -79,7 +79,7 @@ export const usePhaserLayer = ({ networkLayer }: Props) => { } } }, - [container] + [container], ); return useMemo(() => ({ ref, phaserLayer }), [ref, phaserLayer]); diff --git a/examples/minimal/packages/client-react/src/index.tsx b/examples/minimal/packages/client-react/src/index.tsx index da8d70f020..1b005dc561 100644 --- a/examples/minimal/packages/client-react/src/index.tsx +++ b/examples/minimal/packages/client-react/src/index.tsx @@ -13,7 +13,7 @@ setup().then(async (result) => { root.render( - + , ); // https://vitejs.dev/guide/env-and-mode.html diff --git a/examples/minimal/packages/client-react/src/mud/createSystemCalls.ts b/examples/minimal/packages/client-react/src/mud/createSystemCalls.ts index 1e0c674320..37203654b1 100644 --- a/examples/minimal/packages/client-react/src/mud/createSystemCalls.ts +++ b/examples/minimal/packages/client-react/src/mud/createSystemCalls.ts @@ -7,7 +7,7 @@ export type SystemCalls = ReturnType; export function createSystemCalls( { worldContract, waitForTransaction }: SetupNetworkResult, - { CounterTable }: ClientComponents + { CounterTable }: ClientComponents, ) { const increment = async () => { const tx = await worldContract.write.increment(); diff --git a/examples/minimal/packages/contracts/package.json b/examples/minimal/packages/contracts/package.json index 1bd8b4276b..7d49c273a0 100644 --- a/examples/minimal/packages/contracts/package.json +++ b/examples/minimal/packages/contracts/package.json @@ -27,8 +27,8 @@ "@types/node": "^18.15.11", "ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0", "forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1", - "prettier": "^2.6.2", - "prettier-plugin-solidity": "1.1.3", + "prettier": "3.2.5", + "prettier-plugin-solidity": "1.3.1", "rimraf": "^3.0.2", "solhint": "^3.4.1", "solhint-config-mud": "file:../../../../packages/solhint-config-mud", diff --git a/examples/minimal/packages/contracts/src/codegen/world/IWorld.sol b/examples/minimal/packages/contracts/src/codegen/world/IWorld.sol index dfa955dbea..6eb7845c59 100644 --- a/examples/minimal/packages/contracts/src/codegen/world/IWorld.sol +++ b/examples/minimal/packages/contracts/src/codegen/world/IWorld.sol @@ -17,6 +17,4 @@ import { IStructSystem } from "./IStructSystem.sol"; * that are dynamically registered in the World during deployment. * @dev This is an autogenerated file; do not edit manually. */ -interface IWorld is IBaseWorld, IChatSystem, IIncrementSystem, IInventorySystem, IStructSystem { - -} +interface IWorld is IBaseWorld, IChatSystem, IIncrementSystem, IInventorySystem, IStructSystem {} diff --git a/examples/minimal/pnpm-lock.yaml b/examples/minimal/pnpm-lock.yaml index 932aaf3a72..f14ec12a18 100644 --- a/examples/minimal/pnpm-lock.yaml +++ b/examples/minimal/pnpm-lock.yaml @@ -339,11 +339,11 @@ importers: specifier: https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1 version: github.com/foundry-rs/forge-std/74cfb77e308dd188d2f58864aaf44963ae6b88b1 prettier: - specifier: ^2.6.2 - version: 2.6.2 + specifier: 3.2.5 + version: 3.2.5 prettier-plugin-solidity: - specifier: 1.1.3 - version: 1.1.3(prettier@2.6.2) + specifier: 1.3.1 + version: 1.3.1(prettier@3.2.5) rimraf: specifier: ^3.0.2 version: 3.0.2 @@ -1032,6 +1032,10 @@ packages: antlr4ts: 0.5.0-alpha.4 dev: true + /@solidity-parser/parser@0.17.0: + resolution: {integrity: sha512-Nko8R0/kUo391jsEHHxrGM07QFdnPGvlmox4rmH0kNiNAashItAilhy4Mv4pK5gQmW5f4sXAF58fwJbmlkGcVw==} + dev: true + /@solidstate/contracts@0.0.52: resolution: {integrity: sha512-xSBn5oLnfYtgNYrsRq/COlWHt0NxK26PFQ3FvI2DDMAFpZKFsffGLzUl8umezj2gVKpN7EZ+EVLdPKjqx6eUOw==} dev: true @@ -2885,22 +2889,16 @@ packages: engines: {node: '>= 0.8.0'} dev: true - /prettier-plugin-solidity@1.1.3(prettier@2.6.2): - resolution: {integrity: sha512-fQ9yucPi2sBbA2U2Xjh6m4isUTJ7S7QLc/XDDsktqqxYfTwdYKJ0EnnywXHwCGAaYbQNK+HIYPL1OemxuMsgeg==} - engines: {node: '>=12'} + /prettier-plugin-solidity@1.3.1(prettier@3.2.5): + resolution: {integrity: sha512-MN4OP5I2gHAzHZG1wcuJl0FsLS3c4Cc5494bbg+6oQWBPuEamjwDvmGfFMZ6NFzsh3Efd9UUxeT7ImgjNH4ozA==} + engines: {node: '>=16'} peerDependencies: - prettier: '>=2.3.0 || >=3.0.0-alpha.0' + prettier: '>=2.3.0' dependencies: - '@solidity-parser/parser': 0.16.0 - prettier: 2.6.2 - semver: 7.5.0 - solidity-comments-extractor: 0.0.7 - dev: true - - /prettier@2.6.2: - resolution: {integrity: sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==} - engines: {node: '>=10.13.0'} - hasBin: true + '@solidity-parser/parser': 0.17.0 + prettier: 3.2.5 + semver: 7.6.0 + solidity-comments-extractor: 0.0.8 dev: true /prettier@2.8.8: @@ -2911,6 +2909,12 @@ packages: dev: true optional: true + /prettier@3.2.5: + resolution: {integrity: sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==} + engines: {node: '>=14'} + hasBin: true + dev: true + /prop-types@15.8.1: resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==} dependencies: @@ -3096,6 +3100,14 @@ packages: lru-cache: 6.0.0 dev: true + /semver@7.6.0: + resolution: {integrity: sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==} + engines: {node: '>=10'} + hasBin: true + dependencies: + lru-cache: 6.0.0 + dev: true + /shallowequal@1.1.0: resolution: {integrity: sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==} dev: false @@ -3167,8 +3179,8 @@ packages: prettier: 2.8.8 dev: true - /solidity-comments-extractor@0.0.7: - resolution: {integrity: sha512-wciNMLg/Irp8OKGrh3S2tfvZiZ0NEyILfcRCXCD4mp7SgK/i9gzLfhY2hY7VMCQJ3kH9UB9BzNdibIVMchzyYw==} + /solidity-comments-extractor@0.0.8: + resolution: {integrity: sha512-htM7Vn6LhHreR+EglVMd2s+sZhcXAirB1Zlyrv5zBuTxieCvjfnRpd7iZk75m/u6NOlEyQ94C6TWbBn2cY7w8g==} dev: true /source-map-js@1.0.2: diff --git a/examples/multiple-accounts/package.json b/examples/multiple-accounts/package.json index 16893bf7de..9e94423c4d 100644 --- a/examples/multiple-accounts/package.json +++ b/examples/multiple-accounts/package.json @@ -14,7 +14,6 @@ "devDependencies": { "@latticexyz/cli": "link:../../packages/cli", "@types/debug": "4.1.7", - "@types/prettier": "2.7.2", "@typescript-eslint/eslint-plugin": "5.46.1", "@typescript-eslint/parser": "5.46.1", "eslint": "8.29.0", diff --git a/examples/multiple-accounts/packages/client/src/index.tsx b/examples/multiple-accounts/packages/client/src/index.tsx index 3ba2a44052..c9b662c9f0 100644 --- a/examples/multiple-accounts/packages/client/src/index.tsx +++ b/examples/multiple-accounts/packages/client/src/index.tsx @@ -13,7 +13,7 @@ setup().then(async (result) => { root.render( - + , ); // https://vitejs.dev/guide/env-and-mode.html diff --git a/examples/multiple-accounts/packages/contracts/package.json b/examples/multiple-accounts/packages/contracts/package.json index 6b71970f9e..461ceb6001 100644 --- a/examples/multiple-accounts/packages/contracts/package.json +++ b/examples/multiple-accounts/packages/contracts/package.json @@ -25,8 +25,8 @@ "@types/node": "^18.15.11", "ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0", "forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1", - "prettier": "^2.6.2", - "prettier-plugin-solidity": "1.1.3", + "prettier": "3.2.5", + "prettier-plugin-solidity": "1.3.1", "solhint": "^3.3.7", "solhint-config-mud": "2.0.0-next.15", "solhint-plugin-mud": "2.0.0-next.15" diff --git a/examples/multiple-accounts/packages/contracts/src/codegen/world/IWorld.sol b/examples/multiple-accounts/packages/contracts/src/codegen/world/IWorld.sol index f84aef6a65..2c909e6f4f 100644 --- a/examples/multiple-accounts/packages/contracts/src/codegen/world/IWorld.sol +++ b/examples/multiple-accounts/packages/contracts/src/codegen/world/IWorld.sol @@ -14,6 +14,4 @@ import { ILastCallSystem } from "./ILastCallSystem.sol"; * that are dynamically registered in the World during deployment. * @dev This is an autogenerated file; do not edit manually. */ -interface IWorld is IBaseWorld, ILastCallSystem { - -} +interface IWorld is IBaseWorld, ILastCallSystem {} diff --git a/examples/multiple-accounts/pnpm-lock.yaml b/examples/multiple-accounts/pnpm-lock.yaml index 7015942044..878afde32c 100644 --- a/examples/multiple-accounts/pnpm-lock.yaml +++ b/examples/multiple-accounts/pnpm-lock.yaml @@ -14,9 +14,6 @@ importers: '@types/debug': specifier: 4.1.7 version: 4.1.7 - '@types/prettier': - specifier: 2.7.2 - version: 2.7.2 '@typescript-eslint/eslint-plugin': specifier: 5.46.1 version: 5.46.1(@typescript-eslint/parser@5.46.1)(eslint@8.29.0)(typescript@5.1.6) @@ -128,11 +125,11 @@ importers: specifier: https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1 version: github.com/foundry-rs/forge-std/74cfb77e308dd188d2f58864aaf44963ae6b88b1 prettier: - specifier: ^2.6.2 - version: 2.8.8 + specifier: 3.2.5 + version: 3.2.5 prettier-plugin-solidity: - specifier: 1.1.3 - version: 1.1.3(prettier@2.8.8) + specifier: 1.3.1 + version: 1.3.1(prettier@3.2.5) solhint: specifier: ^3.3.7 version: 3.6.2(typescript@5.1.6) @@ -700,6 +697,10 @@ packages: antlr4ts: 0.5.0-alpha.4 dev: true + /@solidity-parser/parser@0.17.0: + resolution: {integrity: sha512-Nko8R0/kUo391jsEHHxrGM07QFdnPGvlmox4rmH0kNiNAashItAilhy4Mv4pK5gQmW5f4sXAF58fwJbmlkGcVw==} + dev: true + /@types/debug@4.1.7: resolution: {integrity: sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg==} dependencies: @@ -720,10 +721,6 @@ packages: undici-types: 5.26.5 dev: true - /@types/prettier@2.7.2: - resolution: {integrity: sha512-KufADq8uQqo1pYKVIYzfKbJfBAc0sOeXqGbFaSpv8MRmC/zXgowNZmFcbngndGk922QDmOASEXUZCaY48gs4cg==} - dev: true - /@types/prop-types@15.7.11: resolution: {integrity: sha512-ga8y9v9uyeiLdpKddhxYQkxNDrfvuPrlFb0N1qnZZByvcElJaXthF1UhvCh9TLWJBEHeNtdnbysW7Y6Uq8CVng==} dev: true @@ -2285,22 +2282,30 @@ packages: engines: {node: '>= 0.8.0'} dev: true - /prettier-plugin-solidity@1.1.3(prettier@2.8.8): - resolution: {integrity: sha512-fQ9yucPi2sBbA2U2Xjh6m4isUTJ7S7QLc/XDDsktqqxYfTwdYKJ0EnnywXHwCGAaYbQNK+HIYPL1OemxuMsgeg==} - engines: {node: '>=12'} + /prettier-plugin-solidity@1.3.1(prettier@3.2.5): + resolution: {integrity: sha512-MN4OP5I2gHAzHZG1wcuJl0FsLS3c4Cc5494bbg+6oQWBPuEamjwDvmGfFMZ6NFzsh3Efd9UUxeT7ImgjNH4ozA==} + engines: {node: '>=16'} peerDependencies: - prettier: '>=2.3.0 || >=3.0.0-alpha.0' + prettier: '>=2.3.0' dependencies: - '@solidity-parser/parser': 0.16.2 - prettier: 2.8.8 + '@solidity-parser/parser': 0.17.0 + prettier: 3.2.5 semver: 7.5.4 - solidity-comments-extractor: 0.0.7 + solidity-comments-extractor: 0.0.8 dev: true /prettier@2.8.8: resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==} engines: {node: '>=10.13.0'} hasBin: true + requiresBuild: true + dev: true + optional: true + + /prettier@3.2.5: + resolution: {integrity: sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==} + engines: {node: '>=14'} + hasBin: true dev: true /prop-types@15.8.1: @@ -2539,8 +2544,8 @@ packages: - typescript dev: true - /solidity-comments-extractor@0.0.7: - resolution: {integrity: sha512-wciNMLg/Irp8OKGrh3S2tfvZiZ0NEyILfcRCXCD4mp7SgK/i9gzLfhY2hY7VMCQJ3kH9UB9BzNdibIVMchzyYw==} + /solidity-comments-extractor@0.0.8: + resolution: {integrity: sha512-htM7Vn6LhHreR+EglVMd2s+sZhcXAirB1Zlyrv5zBuTxieCvjfnRpd7iZk75m/u6NOlEyQ94C6TWbBn2cY7w8g==} dev: true /source-map-js@1.0.2: diff --git a/package.json b/package.json index 17c7bc3c33..b9abb3e9e1 100644 --- a/package.json +++ b/package.json @@ -45,8 +45,8 @@ "execa": "^7.0.0", "husky": ">=6", "lint-staged": ">=10", - "prettier": "^2.8.4", - "prettier-plugin-solidity": "1.1.3", + "prettier": "3.2.5", + "prettier-plugin-solidity": "1.3.1", "rimraf": "^3.0.2", "turbo": "^1.9.3", "typescript": "5.1.6" diff --git a/packages/abi-ts/src/abi-ts.ts b/packages/abi-ts/src/abi-ts.ts index 8d12d0ee0a..a6093d52ec 100755 --- a/packages/abi-ts/src/abi-ts.ts +++ b/packages/abi-ts/src/abi-ts.ts @@ -21,7 +21,7 @@ yargs(hideBin(process.argv)) console.error(chalk.red(msg)); if (msg.includes("Missing required argument")) { console.log( - chalk.yellow(`Run 'pnpm abi-ts ${process.argv[2]} --help' for a list of available and required arguments.`) + chalk.yellow(`Run 'pnpm abi-ts ${process.argv[2]} --help' for a list of available and required arguments.`), ); } diff --git a/packages/block-logs-stream/CHANGELOG.md b/packages/block-logs-stream/CHANGELOG.md index 545ea08a88..7e9de47863 100644 --- a/packages/block-logs-stream/CHANGELOG.md +++ b/packages/block-logs-stream/CHANGELOG.md @@ -418,7 +418,7 @@ const latestBlockNumber$ = latestBlock$.pipe( filter(isNonPendingBlock), - map((block) => block.number) + map((block) => block.number), ); latestBlockNumber$ @@ -434,7 +434,7 @@ "event StoreEphemeralRecord(bytes32 table, bytes32[] key, bytes data)", ]), }), - mergeMap(({ logs }) => from(groupLogsByBlockNumber(logs))) + mergeMap(({ logs }) => from(groupLogsByBlockNumber(logs))), ) .subscribe((block) => { console.log("got events for block", block); diff --git a/packages/block-logs-stream/README.md b/packages/block-logs-stream/README.md index a76e15825f..0d7ccc924f 100644 --- a/packages/block-logs-stream/README.md +++ b/packages/block-logs-stream/README.md @@ -32,7 +32,7 @@ latestBlockNumber$ "event Store_DeleteRecord(bytes32 indexed tableId, bytes32[] keyTuple)", ]), }), - mergeMap(({ logs }) => from(groupLogsByBlockNumber(logs))) + mergeMap(({ logs }) => from(groupLogsByBlockNumber(logs))), ) .subscribe((block) => { console.log("got events for block", block); diff --git a/packages/block-logs-stream/src/blockRangeToLogs.test.ts b/packages/block-logs-stream/src/blockRangeToLogs.test.ts index a0474841b8..607a8dea77 100644 --- a/packages/block-logs-stream/src/blockRangeToLogs.test.ts +++ b/packages/block-logs-stream/src/blockRangeToLogs.test.ts @@ -41,7 +41,7 @@ describe("blockRangeToLogs", () => { publicClient, address: "0x", events: [], - }) + }), ); (async (): Promise => { diff --git a/packages/block-logs-stream/src/blockRangeToLogs.ts b/packages/block-logs-stream/src/blockRangeToLogs.ts index 825320f14d..9a87da6242 100644 --- a/packages/block-logs-stream/src/blockRangeToLogs.ts +++ b/packages/block-logs-stream/src/blockRangeToLogs.ts @@ -65,12 +65,12 @@ export function blockRangeToLogs({ fromBlock, toBlock, maxBlockRange, - }) + }), ).pipe( tap(({ toBlock }) => { fromBlock = toBlock + 1n; - }) + }), ); - }) + }), ); } diff --git a/packages/block-logs-stream/src/fetchLogs.test.ts b/packages/block-logs-stream/src/fetchLogs.test.ts index 7f95f507b9..4bd28cb1c2 100644 --- a/packages/block-logs-stream/src/fetchLogs.test.ts +++ b/packages/block-logs-stream/src/fetchLogs.test.ts @@ -150,7 +150,7 @@ describe("fetchLogs", () => { code: -32005, message: "block range exceeded", }, - }) + }), ); } @@ -374,7 +374,7 @@ describe("fetchLogs", () => { code: -32005, message: "rate limit exceeded", }, - }) + }), ); } diff --git a/packages/block-logs-stream/src/groupLogsByBlockNumber.ts b/packages/block-logs-stream/src/groupLogsByBlockNumber.ts index b0656acfbc..37fd614d35 100644 --- a/packages/block-logs-stream/src/groupLogsByBlockNumber.ts +++ b/packages/block-logs-stream/src/groupLogsByBlockNumber.ts @@ -24,7 +24,7 @@ export type GroupLogsByBlockNumberResult = { */ export function groupLogsByBlockNumber( logs: readonly TLog[], - toBlock?: BlockNumber + toBlock?: BlockNumber, ): GroupLogsByBlockNumberResult { const blockNumbers = Array.from(new Set(logs.map((log) => log.blockNumber))); blockNumbers.sort(bigIntSort); diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 0bec448c15..705083a33e 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1135,7 +1135,7 @@ .pipe( map((block) => Number(block.timestamp) * 1000), // Map to timestamp in ms filter((blockTimestamp) => blockTimestamp !== clock.lastUpdateTime), // Ignore if the clock was already refreshed with this block - filter((blockTimestamp) => blockTimestamp !== clock.currentTime) // Ignore if the current local timestamp is correct + filter((blockTimestamp) => blockTimestamp !== clock.currentTime), // Ignore if the current local timestamp is correct ) .subscribe(clock.update); // Update the local clock ``` diff --git a/packages/cli/src/commands/dev-contracts.ts b/packages/cli/src/commands/dev-contracts.ts index 084c271275..23b7b1d03c 100644 --- a/packages/cli/src/commands/dev-contracts.ts +++ b/packages/cli/src/commands/dev-contracts.ts @@ -106,7 +106,7 @@ const commandModule: CommandModule = { const mutuallyExclusiveOptions = ["mudVersion", "link", "tag", "commit", "restore"]; const numMutuallyExclusiveOptions = mutuallyExclusiveOptions.reduce( (acc, opt) => (options[opt] ? acc + 1 : acc), - 0 + 0, ); if (numMutuallyExclusiveOptions === 0) { diff --git a/packages/cli/src/commands/trace.ts b/packages/cli/src/commands/trace.ts index e6d55a9ece..e8659eb089 100644 --- a/packages/cli/src/commands/trace.ts +++ b/packages/cli/src/commands/trace.ts @@ -63,7 +63,7 @@ const commandModule: CommandModule = { const resolvedConfig = resolveWorldConfig( mudConfig, - existingContracts.map(({ basename }) => basename) + existingContracts.map(({ basename }) => basename), ); // Get worldAddress either from args or from worldsFile diff --git a/packages/cli/src/deploy/configToTables.ts b/packages/cli/src/deploy/configToTables.ts index 4c07a81bb3..3e9b0e5729 100644 --- a/packages/cli/src/deploy/configToTables.ts +++ b/packages/cli/src/deploy/configToTables.ts @@ -14,12 +14,12 @@ type UserTypes = config["userTypes"]; export type TableKey< config extends StoreConfig = StoreConfig, - table extends config["tables"][keyof config["tables"]] = config["tables"][keyof config["tables"]] + table extends config["tables"][keyof config["tables"]] = config["tables"][keyof config["tables"]], > = `${config["namespace"]}_${table["name"]}`; export type Table< config extends StoreConfig = StoreConfig, - table extends config["tables"][keyof config["tables"]] = config["tables"][keyof config["tables"]] + table extends config["tables"][keyof config["tables"]] = config["tables"][keyof config["tables"]], > = { readonly namespace: config["namespace"]; readonly name: table["name"]; @@ -63,6 +63,6 @@ export function configToTables(config: config): Tabl keySchema: resolveUserTypes(table.keySchema, userTypes) as any, valueSchema: resolveUserTypes(table.valueSchema, userTypes) as any, } satisfies Table, - ]) + ]), ) as Tables; } diff --git a/packages/cli/src/deploy/deployWorld.ts b/packages/cli/src/deploy/deployWorld.ts index 16c4c7bc75..7f5bf4ba04 100644 --- a/packages/cli/src/deploy/deployWorld.ts +++ b/packages/cli/src/deploy/deployWorld.ts @@ -10,7 +10,7 @@ import { WorldDeploy } from "./common"; export async function deployWorld( client: Client, deployerAddress: Hex, - salt: Hex + salt: Hex, ): Promise { const worldFactory = await ensureWorldFactory(client, deployerAddress); diff --git a/packages/cli/src/deploy/ensureContract.ts b/packages/cli/src/deploy/ensureContract.ts index b7110bcb1d..d86269ee54 100644 --- a/packages/cli/src/deploy/ensureContract.ts +++ b/packages/cli/src/deploy/ensureContract.ts @@ -32,11 +32,11 @@ export async function ensureContract({ if (deployedBytecodeSize > contractSizeLimit) { console.warn( - `\nBytecode for ${label} (${deployedBytecodeSize} bytes) is over the contract size limit (${contractSizeLimit} bytes). Run \`forge build --sizes\` for more info.\n` + `\nBytecode for ${label} (${deployedBytecodeSize} bytes) is over the contract size limit (${contractSizeLimit} bytes). Run \`forge build --sizes\` for more info.\n`, ); } else if (deployedBytecodeSize > contractSizeLimit * 0.95) { console.warn( - `\nBytecode for ${label} (${deployedBytecodeSize} bytes) is almost over the contract size limit (${contractSizeLimit} bytes). Run \`forge build --sizes\` for more info.\n` + `\nBytecode for ${label} (${deployedBytecodeSize} bytes) is almost over the contract size limit (${contractSizeLimit} bytes). Run \`forge build --sizes\` for more info.\n`, ); } @@ -56,7 +56,7 @@ export async function ensureContract({ debug(`failed to deploy ${label}, retrying in ${delay}ms...`); await wait(delay); }, - } + }, ), ]; } diff --git a/packages/cli/src/deploy/ensureDeployer.ts b/packages/cli/src/deploy/ensureDeployer.ts index 709f27d6f3..92c7c136b0 100644 --- a/packages/cli/src/deploy/ensureDeployer.ts +++ b/packages/cli/src/deploy/ensureDeployer.ts @@ -12,7 +12,7 @@ export async function ensureDeployer(client: Client func.signature).join(", ") + wrongSystem.map((func) => func.signature).join(", "), ); } } @@ -59,7 +59,7 @@ export async function ensureFunctions({ debug(`failed to register function ${func.signature}, retrying in ${delay}ms...`); await wait(delay); }, - } + }, ); } return pRetry( @@ -79,8 +79,8 @@ export async function ensureFunctions({ debug(`failed to register function ${func.signature}, retrying in ${delay}ms...`); await wait(delay); }, - } + }, ); - }) + }), ); } diff --git a/packages/cli/src/deploy/ensureModules.ts b/packages/cli/src/deploy/ensureModules.ts index dddef29a09..5a658a85c2 100644 --- a/packages/cli/src/deploy/ensureModules.ts +++ b/packages/cli/src/deploy/ensureModules.ts @@ -68,9 +68,9 @@ export async function ensureModules({ debug(`failed to install module ${mod.name}, retrying in ${delay}ms...`); await wait(delay); }, - } - ) - ) + }, + ), + ), ) ).filter(isDefined); } diff --git a/packages/cli/src/deploy/ensureNamespaceOwner.ts b/packages/cli/src/deploy/ensureNamespaceOwner.ts index 65384d2de3..0771951e90 100644 --- a/packages/cli/src/deploy/ensureNamespaceOwner.ts +++ b/packages/cli/src/deploy/ensureNamespaceOwner.ts @@ -24,7 +24,7 @@ export async function ensureNamespaceOwner({ "existing namespaces:", Array.from(existingNamespaces) .map((namespace) => (namespace === "" ? "" : namespace)) - .join(", ") + .join(", "), ); } @@ -39,7 +39,7 @@ export async function ensureNamespaceOwner({ key: { namespaceId: resourceToHex({ type: "namespace", namespace, name: "" }) }, }); return [namespace, owner]; - }) + }), ); const unauthorizedNamespaces = namespaceOwners @@ -63,8 +63,8 @@ export async function ensureNamespaceOwner({ abi: worldAbi, functionName: "registerNamespace", args: [resourceToHex({ namespace, type: "namespace", name: "" })], - }) - ) + }), + ), ); return registrationTxs; diff --git a/packages/cli/src/deploy/ensureSystems.ts b/packages/cli/src/deploy/ensureSystems.ts index 51bac4ae5b..dc1661a8c2 100644 --- a/packages/cli/src/deploy/ensureSystems.ts +++ b/packages/cli/src/deploy/ensureSystems.ts @@ -32,8 +32,8 @@ export async function ensureSystems({ worldSystems.some( (worldSystem) => worldSystem.systemId === system.systemId && - getAddress(worldSystem.address) === getAddress(system.getAddress(deployerAddress)) - ) + getAddress(worldSystem.address) === getAddress(system.getAddress(deployerAddress)), + ), ); if (existingSystems.length) { debug("existing systems", existingSystems.map(resourceToLabel).join(", ")); @@ -47,15 +47,15 @@ export async function ensureSystems({ worldSystems.some( (worldSystem) => worldSystem.systemId === system.systemId && - getAddress(worldSystem.address) !== getAddress(system.getAddress(deployerAddress)) - ) + getAddress(worldSystem.address) !== getAddress(system.getAddress(deployerAddress)), + ), ); if (systemsToUpgrade.length) { debug("upgrading systems", systemsToUpgrade.map(resourceToLabel).join(", ")); } const systemsToAdd = missingSystems.filter( - (system) => !worldSystems.some((worldSystem) => worldSystem.systemId === system.systemId) + (system) => !worldSystems.some((worldSystem) => worldSystem.systemId === system.systemId), ); if (systemsToAdd.length) { debug("registering new systems", systemsToAdd.map(resourceToLabel).join(", ")); @@ -90,9 +90,9 @@ export async function ensureSystems({ debug(`failed to register system ${resourceToLabel(system)}, retrying in ${delay}ms...`); await wait(delay); }, - } - ) - ) + }, + ), + ), ); // Adjust system access @@ -101,7 +101,7 @@ export async function ensureSystems({ const currentAccess = worldAccess.filter(({ resourceId }) => systemIds.includes(resourceId)); const desiredAccess = [ ...systems.flatMap((system) => - system.allowedAddresses.map((address) => ({ resourceId: system.systemId, address })) + system.allowedAddresses.map((address) => ({ resourceId: system.systemId, address })), ), ...systems.flatMap((system) => system.allowedSystemIds @@ -111,7 +111,7 @@ export async function ensureSystems({ worldSystems.find((s) => s.systemId === systemId)?.address ?? systems.find((s) => s.systemId === systemId)?.getAddress(deployerAddress), })) - .filter((access): access is typeof access & { address: Address } => access.address != null) + .filter((access): access is typeof access & { address: Address } => access.address != null), ), ]; @@ -119,16 +119,16 @@ export async function ensureSystems({ (access) => !currentAccess.some( ({ resourceId, address }) => - resourceId === access.resourceId && getAddress(address) === getAddress(access.address) - ) + resourceId === access.resourceId && getAddress(address) === getAddress(access.address), + ), ); const accessToRemove = currentAccess.filter( (access) => !desiredAccess.some( ({ resourceId, address }) => - resourceId === access.resourceId && getAddress(address) === getAddress(access.address) - ) + resourceId === access.resourceId && getAddress(address) === getAddress(access.address), + ), ); if (accessToRemove.length) { @@ -156,8 +156,8 @@ export async function ensureSystems({ debug(`failed to revoke access, retrying in ${delay}ms...`); await wait(delay); }, - } - ) + }, + ), ), ...accessToAdd.map((access) => pRetry( @@ -176,8 +176,8 @@ export async function ensureSystems({ debug(`failed to grant access, retrying in ${delay}ms...`); await wait(delay); }, - } - ) + }, + ), ), ]); diff --git a/packages/cli/src/deploy/ensureTables.ts b/packages/cli/src/deploy/ensureTables.ts index 31beddba46..0ab65681bd 100644 --- a/packages/cli/src/deploy/ensureTables.ts +++ b/packages/cli/src/deploy/ensureTables.ts @@ -54,9 +54,9 @@ export async function ensureTables({ debug(`failed to register table ${resourceToLabel(table)}, retrying in ${delay}ms...`); await wait(delay); }, - } - ) - ) + }, + ), + ), ); } diff --git a/packages/cli/src/deploy/ensureWorldFactory.ts b/packages/cli/src/deploy/ensureWorldFactory.ts index 0df1c21508..0c241f7669 100644 --- a/packages/cli/src/deploy/ensureWorldFactory.ts +++ b/packages/cli/src/deploy/ensureWorldFactory.ts @@ -13,7 +13,7 @@ import { Contract } from "./ensureContract"; export async function ensureWorldFactory( client: Client, - deployerAddress: Hex + deployerAddress: Hex, ): Promise
{ const accessManagementSystemDeployedBytecodeSize = size(accessManagementSystemBuild.deployedBytecode.object as Hex); const accessManagementSystemBytecode = accessManagementSystemBuild.bytecode.object as Hex; diff --git a/packages/cli/src/deploy/getFunctions.ts b/packages/cli/src/deploy/getFunctions.ts index 39b7955486..834dd2cecb 100644 --- a/packages/cli/src/deploy/getFunctions.ts +++ b/packages/cli/src/deploy/getFunctions.ts @@ -51,7 +51,7 @@ export async function getFunctions({ systemFunctionSignature, systemFunctionSelector, }; - }) + }), ); return functions; diff --git a/packages/cli/src/deploy/getResourceAccess.ts b/packages/cli/src/deploy/getResourceAccess.ts index e38a2b2cfd..a9642085be 100644 --- a/packages/cli/src/deploy/getResourceAccess.ts +++ b/packages/cli/src/deploy/getResourceAccess.ts @@ -35,8 +35,8 @@ export async function getResourceAccess({ await Promise.all( keys.map( async (key) => - [key, await getTableValue({ client, worldDeploy, table: worldTables.world_ResourceAccess, key })] as const - ) + [key, await getTableValue({ client, worldDeploy, table: worldTables.world_ResourceAccess, key })] as const, + ), ) ) .filter(([, value]) => value.access) diff --git a/packages/cli/src/deploy/getSystems.ts b/packages/cli/src/deploy/getSystems.ts index c87145efc1..b3cfa98eb6 100644 --- a/packages/cli/src/deploy/getSystems.ts +++ b/packages/cli/src/deploy/getSystems.ts @@ -42,6 +42,6 @@ export async function getSystems({ .map(({ address }) => address), functions: systemFunctions, }; - }) + }), ); } diff --git a/packages/cli/src/deploy/getTables.ts b/packages/cli/src/deploy/getTables.ts index 4154f38199..3342c7b9db 100644 --- a/packages/cli/src/deploy/getTables.ts +++ b/packages/cli/src/deploy/getTables.ts @@ -45,7 +45,7 @@ export async function getTables({ const valueAbiTypes = [...valueSchemaFields.staticFields, ...valueSchemaFields.dynamicFields]; const keySchema = Object.fromEntries( - keySchemaFields.staticFields.map((abiType, i) => [keyNames[i], abiType]) + keySchemaFields.staticFields.map((abiType, i) => [keyNames[i], abiType]), ) as KeySchema; const valueSchema = Object.fromEntries(valueAbiTypes.map((abiType, i) => [fieldNames[i], abiType])) as ValueSchema; diff --git a/packages/cli/src/deploy/logsToWorldDeploy.ts b/packages/cli/src/deploy/logsToWorldDeploy.ts index 81091270fd..a6f078766f 100644 --- a/packages/cli/src/deploy/logsToWorldDeploy.ts +++ b/packages/cli/src/deploy/logsToWorldDeploy.ts @@ -37,7 +37,7 @@ export function logsToWorldDeploy(logs: readonly Log[]): ? { storeVersion: hexToString(trim(log.args.storeVersion, { dir: "right" })) } : null), }), - {} + {}, ); if (address == null) throw new Error("could not find world address"); diff --git a/packages/cli/src/deploy/resolveConfig.ts b/packages/cli/src/deploy/resolveConfig.ts index bc56ad8dc2..2cde8cfc1f 100644 --- a/packages/cli/src/deploy/resolveConfig.ts +++ b/packages/cli/src/deploy/resolveConfig.ts @@ -61,7 +61,7 @@ export function resolveConfig({ allowAll: system.openAccess, allowedAddresses: system.accessListAddresses as Hex[], allowedSystemIds: system.accessListSystems.map((name) => - resourceToHex({ type: "system", namespace, name: resolvedConfig.systems[name].name }) + resourceToHex({ type: "system", namespace, name: resolvedConfig.systems[name].name }), ), getAddress: (deployer: Address) => getCreate2Address({ from: deployer, bytecode: contractData.bytecode, salt }), bytecode: contractData.bytecode, @@ -81,8 +81,8 @@ export function resolveConfig({ const names = overlappingSystems.map((system) => system.name); throw new Error( `Found systems with overlapping system ID: ${names.join( - ", " - )}.\n\nSystem IDs are generated from the first 16 bytes of the name, so you may need to rename them to avoid the overlap.` + ", ", + )}.\n\nSystem IDs are generated from the first 16 bytes of the name, so you may need to rename them to avoid the overlap.`, ); } @@ -96,9 +96,9 @@ export function resolveConfig({ type: table.offchainOnly ? "offchainTable" : "table", namespace: config.namespace, name: table.name, - }) + }), ), - ]) + ]), ), }; diff --git a/packages/cli/src/mud.ts b/packages/cli/src/mud.ts index b1f85a25fb..b01f04031b 100755 --- a/packages/cli/src/mud.ts +++ b/packages/cli/src/mud.ts @@ -26,7 +26,7 @@ async function run() { console.error(chalk.red(msg)); if (msg.includes("Missing required argument")) { console.log( - chalk.yellow(`Run 'pnpm mud ${process.argv[2]} --help' for a list of available and required arguments.`) + chalk.yellow(`Run 'pnpm mud ${process.argv[2]} --help' for a list of available and required arguments.`), ); } console.log(""); diff --git a/packages/cli/src/runDeploy.ts b/packages/cli/src/runDeploy.ts index ba668668b8..0535fe29f0 100644 --- a/packages/cli/src/runDeploy.ts +++ b/packages/cli/src/runDeploy.ts @@ -64,8 +64,8 @@ export async function runDeploy(opts: DeployOptions): Promise { const rpc = opts.rpc ?? (await getRpcUrl(profile)); console.log( chalk.bgBlue( - chalk.whiteBright(`\n Deploying MUD contracts${profile ? " with profile " + profile : ""} to RPC ${rpc} \n`) - ) + chalk.whiteBright(`\n Deploying MUD contracts${profile ? " with profile " + profile : ""} to RPC ${rpc} \n`), + ), ); // Run build @@ -78,7 +78,7 @@ export async function runDeploy(opts: DeployOptions): Promise { throw new MUDError( `Missing PRIVATE_KEY environment variable. Run 'echo "PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" > .env' -in your contracts directory to use the default anvil private key.` +in your contracts directory to use the default anvil private key.`, ); } @@ -126,7 +126,7 @@ in your contracts directory to use the default anvil private key.` writeFileSync(config.worldsFile, JSON.stringify(deploys, null, 2)); console.log( - chalk.bgGreen(chalk.whiteBright(`\n Deployment result (written to ${config.worldsFile} and ${deploysDir}): \n`)) + chalk.bgGreen(chalk.whiteBright(`\n Deployment result (written to ${config.worldsFile} and ${deploysDir}): \n`)), ); } diff --git a/packages/cli/src/utils/printMUD.ts b/packages/cli/src/utils/printMUD.ts index b3114e5916..5933c97d6f 100644 --- a/packages/cli/src/utils/printMUD.ts +++ b/packages/cli/src/utils/printMUD.ts @@ -9,6 +9,6 @@ export function printMUD() { | :\\/: || :\\/: || (__) | | '--'M|| '--'U|| '--'D| '------''------''------' -`) +`), ); } diff --git a/packages/cli/src/utils/utils/getContractData.ts b/packages/cli/src/utils/utils/getContractData.ts index a289b0443d..c527d2b873 100644 --- a/packages/cli/src/utils/utils/getContractData.ts +++ b/packages/cli/src/utils/utils/getContractData.ts @@ -9,7 +9,7 @@ import { Abi, Hex, size } from "viem"; */ export function getContractData( contractName: string, - forgeOutDirectory: string + forgeOutDirectory: string, ): { bytecode: Hex; abi: Abi; deployedBytecodeSize: number } { let data: any; const contractDataPath = path.join(forgeOutDirectory, contractName + ".sol", contractName + ".json"); diff --git a/packages/cli/src/utils/utils/postDeploy.ts b/packages/cli/src/utils/utils/postDeploy.ts index e30d63eaa1..a03eb1e2fa 100644 --- a/packages/cli/src/utils/utils/postDeploy.ts +++ b/packages/cli/src/utils/utils/postDeploy.ts @@ -7,7 +7,7 @@ export async function postDeploy( postDeployScript: string, worldAddress: string, rpc: string, - profile: string | undefined + profile: string | undefined, ): Promise { // Execute postDeploy forge script const postDeployPath = path.join(await getScriptDirectory(), postDeployScript + ".s.sol"); @@ -17,7 +17,7 @@ export async function postDeploy( ["script", postDeployScript, "--sig", "run(address)", worldAddress, "--broadcast", "--rpc-url", rpc, "-vvv"], { profile: profile, - } + }, ); } else { console.log(`No script at ${postDeployPath}, skipping post deploy hook`); diff --git a/packages/cli/tsup.config.ts b/packages/cli/tsup.config.ts index 8e74fd917d..cc3e3ca7de 100644 --- a/packages/cli/tsup.config.ts +++ b/packages/cli/tsup.config.ts @@ -14,7 +14,7 @@ const mudPackages: MudPackages = Object.fromEntries( JSON.parse(readFileSync(filename, "utf8")), ]) .filter(([, packageJson]) => !packageJson.private) - .map(([localPath, packageJson]) => [packageJson.name, { localPath }]) + .map(([localPath, packageJson]) => [packageJson.name, { localPath }]), ); export default defineConfig({ diff --git a/packages/common/CHANGELOG.md b/packages/common/CHANGELOG.md index 042dabaa3c..3d53ad41dd 100644 --- a/packages/common/CHANGELOG.md +++ b/packages/common/CHANGELOG.md @@ -669,7 +669,7 @@ .pipe( map((block) => Number(block.timestamp) * 1000), // Map to timestamp in ms filter((blockTimestamp) => blockTimestamp !== clock.lastUpdateTime), // Ignore if the clock was already refreshed with this block - filter((blockTimestamp) => blockTimestamp !== clock.currentTime) // Ignore if the current local timestamp is correct + filter((blockTimestamp) => blockTimestamp !== clock.currentTime), // Ignore if the current local timestamp is correct ) .subscribe(clock.update); // Update the local clock ``` diff --git a/packages/common/package.json b/packages/common/package.json index 216270c946..851a3659ef 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -59,8 +59,8 @@ "execa": "^7.0.0", "p-queue": "^7.4.1", "p-retry": "^5.1.2", - "prettier": "^2.8.4", - "prettier-plugin-solidity": "1.1.3", + "prettier": "3.2.5", + "prettier-plugin-solidity": "1.3.1", "viem": "2.7.12" }, "devDependencies": { diff --git a/packages/common/src/codegen/render-solidity/common.test.ts b/packages/common/src/codegen/render-solidity/common.test.ts index c754c07551..c249c21cec 100644 --- a/packages/common/src/codegen/render-solidity/common.test.ts +++ b/packages/common/src/codegen/render-solidity/common.test.ts @@ -22,38 +22,38 @@ describe("getLeftPaddingBits", () => { describe("renderValueTypeToBytes32", () => { it("returns Solidity code to cast native type to bytes32", () => { expect(renderValueTypeToBytes32("someField", { typeUnwrap: "", internalTypeId: "bytes32" })).toMatchInlineSnapshot( - '"someField"' + '"someField"', ); expect( - renderValueTypeToBytes32("someField", { typeUnwrap: "SomeStruct.unwrap", internalTypeId: "bytes32" }) + renderValueTypeToBytes32("someField", { typeUnwrap: "SomeStruct.unwrap", internalTypeId: "bytes32" }), ).toMatchInlineSnapshot('"SomeStruct.unwrap(someField)"'); expect(renderValueTypeToBytes32("someField", { typeUnwrap: "", internalTypeId: "bytes16" })).toMatchInlineSnapshot( - '"bytes32(someField)"' + '"bytes32(someField)"', ); expect( - renderValueTypeToBytes32("someField", { typeUnwrap: "SomeStruct.unwrap", internalTypeId: "bytes16" }) + renderValueTypeToBytes32("someField", { typeUnwrap: "SomeStruct.unwrap", internalTypeId: "bytes16" }), ).toMatchInlineSnapshot('"bytes32(SomeStruct.unwrap(someField))"'); expect(renderValueTypeToBytes32("someField", { typeUnwrap: "", internalTypeId: "uint8" })).toMatchInlineSnapshot( - '"bytes32(uint256(someField))"' + '"bytes32(uint256(someField))"', ); expect( - renderValueTypeToBytes32("someField", { typeUnwrap: "SomeStruct.unwrap", internalTypeId: "uint8" }) + renderValueTypeToBytes32("someField", { typeUnwrap: "SomeStruct.unwrap", internalTypeId: "uint8" }), ).toMatchInlineSnapshot('"bytes32(uint256(SomeStruct.unwrap(someField)))"'); expect(renderValueTypeToBytes32("someField", { typeUnwrap: "", internalTypeId: "bool" })).toMatchInlineSnapshot( - '"_boolToBytes32(someField)"' + '"_boolToBytes32(someField)"', ); expect( - renderValueTypeToBytes32("someField", { typeUnwrap: "SomeStruct.unwrap", internalTypeId: "bool" }) + renderValueTypeToBytes32("someField", { typeUnwrap: "SomeStruct.unwrap", internalTypeId: "bool" }), ).toMatchInlineSnapshot('"_boolToBytes32(SomeStruct.unwrap(someField))"'); expect(renderValueTypeToBytes32("someField", { typeUnwrap: "", internalTypeId: "address" })).toMatchInlineSnapshot( - '"bytes32(uint256(uint160(someField)))"' + '"bytes32(uint256(uint160(someField)))"', ); expect( - renderValueTypeToBytes32("someField", { typeUnwrap: "SomeStruct.unwrap", internalTypeId: "address" }) + renderValueTypeToBytes32("someField", { typeUnwrap: "SomeStruct.unwrap", internalTypeId: "address" }), ).toMatchInlineSnapshot('"bytes32(uint256(uint160(SomeStruct.unwrap(someField))))"'); }); }); diff --git a/packages/common/src/codegen/render-solidity/common.ts b/packages/common/src/codegen/render-solidity/common.ts index 0813f25160..58bbdf4b99 100644 --- a/packages/common/src/codegen/render-solidity/common.ts +++ b/packages/common/src/codegen/render-solidity/common.ts @@ -94,7 +94,7 @@ export function renderImports(imports: ImportDatum[]): string { path: solidityRelativeImportPath(importDatum.fromPath, importDatum.usedInPath), }; } - }) + }), ); } @@ -107,7 +107,7 @@ export function renderRelativeImports(imports: RelativeImportDatum[]): string { imports.map(({ symbol, fromPath, usedInPath }) => ({ symbol, path: solidityRelativeImportPath(fromPath, usedInPath), - })) + })), ); } @@ -154,7 +154,7 @@ interface RenderWithStoreCallbackData { */ export function renderWithStore( storeArgument: boolean, - callback: (data: RenderWithStoreCallbackData) => string + callback: (data: RenderWithStoreCallbackData) => string, ): string { let result = ""; result += callback({ _typedStore: undefined, _store: "StoreSwitch", _commentSuffix: "", _methodNamePrefix: "" }); @@ -190,7 +190,7 @@ export function renderWithStore( export function renderWithFieldSuffix( withSuffixlessFieldMethods: boolean, fieldName: string, - callback: (_methodNameSuffix: string) => string + callback: (_methodNameSuffix: string) => string, ): string { const methodNameSuffix = `${fieldName[0].toUpperCase()}${fieldName.slice(1)}`; let result = ""; @@ -214,7 +214,7 @@ export function renderTableId({ }: Pick): string { return ` // Hex below is the result of \`WorldResourceIdLib.encode({ namespace: ${JSON.stringify( - namespace + namespace, )}, name: ${JSON.stringify(name)}, typeId: ${offchainOnly ? "RESOURCE_OFFCHAIN_TABLE" : "RESOURCE_TABLE"} });\` ResourceId constant _tableId = ResourceId.wrap(${resourceToHex({ type: offchainOnly ? "offchainTable" : "table", @@ -231,7 +231,7 @@ export function renderTableId({ */ export function renderValueTypeToBytes32( name: string, - { typeUnwrap, internalTypeId }: Pick + { typeUnwrap, internalTypeId }: Pick, ): string { const innerText = typeUnwrap.length ? `${typeUnwrap}(${name})` : name; @@ -276,7 +276,7 @@ export function getLeftPaddingBits(field: Pick( lineTerminator: string, list: T[], - renderItem: (item: T, index: number) => string + renderItem: (item: T, index: number) => string, ): string { return list .map((item, index) => renderItem(item, index) + (index === list.length - 1 ? "" : lineTerminator)) diff --git a/packages/common/src/codegen/render-solidity/renderEnums.ts b/packages/common/src/codegen/render-solidity/renderEnums.ts index 00df0b1094..74d456d81a 100644 --- a/packages/common/src/codegen/render-solidity/renderEnums.ts +++ b/packages/common/src/codegen/render-solidity/renderEnums.ts @@ -13,7 +13,7 @@ export function renderEnums(enums: RenderEnum[]): string { enum ${name} { ${renderArguments(memberNames)} } - ` + `, ); return result; diff --git a/packages/common/src/codegen/render-solidity/renderTypeHelpers.ts b/packages/common/src/codegen/render-solidity/renderTypeHelpers.ts index 81b39c4baa..f6182d60e0 100644 --- a/packages/common/src/codegen/render-solidity/renderTypeHelpers.ts +++ b/packages/common/src/codegen/render-solidity/renderTypeHelpers.ts @@ -74,7 +74,7 @@ function renderWrapperStaticArray( functionName: string, elementType: string, staticLength: number, - internalTypeId: string + internalTypeId: string, ): string { // WARNING: ensure this still works if changing major solidity versions! // (the memory layout for static arrays may change) @@ -119,7 +119,7 @@ function renderUnwrapperStaticArray( functionName: string, elementType: string, staticLength: number, - internalTypeId: string + internalTypeId: string, ): string { // byte length for memory copying (more efficient than a loop) const byteLength = staticLength * 32; diff --git a/packages/common/src/codegen/utils/contractToInterface.ts b/packages/common/src/codegen/utils/contractToInterface.ts index 13c347290a..2e1e83e907 100644 --- a/packages/common/src/codegen/utils/contractToInterface.ts +++ b/packages/common/src/codegen/utils/contractToInterface.ts @@ -33,7 +33,7 @@ interface SymbolImport { */ export function contractToInterface( data: string, - contractName: string + contractName: string, ): { functions: ContractInterfaceFunction[]; errors: ContractInterfaceError[]; diff --git a/packages/common/src/codegen/utils/extractUserTypes.ts b/packages/common/src/codegen/utils/extractUserTypes.ts index 21f48c0ed2..8bdc960699 100644 --- a/packages/common/src/codegen/utils/extractUserTypes.ts +++ b/packages/common/src/codegen/utils/extractUserTypes.ts @@ -24,7 +24,7 @@ export interface SolidityUserDefinedType { export function extractUserTypes( data: string, userTypeNames: string[], - fromPath: string + fromPath: string, ): Record { const ast = parse(data); diff --git a/packages/common/src/codegen/utils/formatAndWrite.ts b/packages/common/src/codegen/utils/formatAndWrite.ts index f8cca27b1f..1121d58262 100644 --- a/packages/common/src/codegen/utils/formatAndWrite.ts +++ b/packages/common/src/codegen/utils/formatAndWrite.ts @@ -27,7 +27,7 @@ export async function formatAndWriteSolidity(output: string, fullOutputPath: str export async function formatAndWriteTypescript( output: string, fullOutputPath: string, - logPrefix: string + logPrefix: string, ): Promise { const formattedOutput = await formatTypescript(output); diff --git a/packages/common/src/codegen/utils/loadUserTypesFile.ts b/packages/common/src/codegen/utils/loadUserTypesFile.ts index cacbd59472..127299d92f 100644 --- a/packages/common/src/codegen/utils/loadUserTypesFile.ts +++ b/packages/common/src/codegen/utils/loadUserTypesFile.ts @@ -19,7 +19,7 @@ export type UserType = { export function loadAndExtractUserTypes( userTypes: Record, outputBaseDirectory: string, - remappings: [string, string][] + remappings: [string, string][], ): Record { const userTypesPerFile: Record = {}; for (const [userTypeName, { filePath: unresolvedFilePath }] of Object.entries(userTypes)) { @@ -37,7 +37,7 @@ export function loadAndExtractUserTypes( for (const [userTypeName, userType] of Object.entries(userTypesInFile)) { if (userType.internalTypeId !== userTypes[userTypeName].internalType) { throw new MUDError( - `User type "${userTypeName}" has internal type "${userType.internalTypeId}" but config specifies "${userTypes[userTypeName].internalType}"` + `User type "${userTypeName}" has internal type "${userType.internalTypeId}" but config specifies "${userTypes[userTypeName].internalType}"`, ); } } @@ -50,7 +50,7 @@ export function loadAndExtractUserTypes( function loadUserTypesFile( outputBaseDirectory: string, unresolvedFilePath: string, - remappings: [string, string][] + remappings: [string, string][], ): { filePath: string; data: string; diff --git a/packages/common/src/foundry/index.ts b/packages/common/src/foundry/index.ts index b7f29ee61a..83f20bff42 100644 --- a/packages/common/src/foundry/index.ts +++ b/packages/common/src/foundry/index.ts @@ -87,7 +87,7 @@ export async function getRemappings(profile?: string): Promise<[string, string][ */ export async function forge( args: string[], - options?: { profile?: string; silent?: boolean; env?: NodeJS.ProcessEnv } + options?: { profile?: string; silent?: boolean; env?: NodeJS.ProcessEnv }, ): Promise { const execOptions: Options = { env: { FOUNDRY_PROFILE: options?.profile, ...options?.env }, diff --git a/packages/common/src/getContract.ts b/packages/common/src/getContract.ts index a845359dd8..863eec55a2 100644 --- a/packages/common/src/getContract.ts +++ b/packages/common/src/getContract.ts @@ -42,7 +42,7 @@ export type GetContractOptions< TChain extends Chain, TAccount extends Account, TPublicClient extends PublicClient, - TWalletClient extends WalletClient + TWalletClient extends WalletClient, > = GetContractParameters< TTransport, TChain, @@ -63,7 +63,7 @@ export function getContract< TChain extends Chain, TAccount extends Account, TPublicClient extends PublicClient, - TWalletClient extends WalletClient + TWalletClient extends WalletClient, >({ abi, address, @@ -99,7 +99,7 @@ export function getContract< return ( ...parameters: [ args?: readonly unknown[], - options?: UnionOmit + options?: UnionOmit, ] ) => { const { args, options } = getFunctionParameters(parameters); @@ -125,7 +125,7 @@ export function getContract< return result; }; }, - } + }, ); } diff --git a/packages/common/src/hexToResource.ts b/packages/common/src/hexToResource.ts index 94178a9ed2..f95c93d15b 100644 --- a/packages/common/src/hexToResource.ts +++ b/packages/common/src/hexToResource.ts @@ -6,7 +6,7 @@ import { ReverseMap } from "./type-utils/common"; import { resourceToLabel } from "./resourceLabel"; const resourceTypeIdToType = Object.fromEntries( - Object.entries(resourceTypeIds).map(([key, value]) => [value, key]) + Object.entries(resourceTypeIds).map(([key, value]) => [value, key]), ) as ReverseMap; function getResourceType(resourceTypeId: string): ResourceType | undefined { diff --git a/packages/common/src/sendTransaction.ts b/packages/common/src/sendTransaction.ts index 9e64497825..7d08930f57 100644 --- a/packages/common/src/sendTransaction.ts +++ b/packages/common/src/sendTransaction.ts @@ -20,10 +20,10 @@ const debug = parentDebug.extend("sendTransaction"); export async function sendTransaction< TChain extends Chain | undefined, TAccount extends Account | undefined, - TChainOverride extends Chain | undefined + TChainOverride extends Chain | undefined, >( client: Client, - request: SendTransactionParameters + request: SendTransactionParameters, ): Promise { const rawAccount = request.account ?? client.account; if (!rawAccount) { @@ -83,8 +83,8 @@ export async function sendTransaction< // TODO: prepare again if there are gas errors? throw error; }, - } + }, ), - { throwOnTimeout: true } + { throwOnTimeout: true }, ); } diff --git a/packages/common/src/utils/groupBy.ts b/packages/common/src/utils/groupBy.ts index 5a81d49e3f..556f7a89b7 100644 --- a/packages/common/src/utils/groupBy.ts +++ b/packages/common/src/utils/groupBy.ts @@ -1,6 +1,6 @@ export function groupBy( values: readonly value[], - getKey: (value: value) => key + getKey: (value: value) => key, ): Map { const map = new Map(); for (const value of values) { diff --git a/packages/common/src/utils/mapObject.ts b/packages/common/src/utils/mapObject.ts index 189f568657..89434b19b9 100644 --- a/packages/common/src/utils/mapObject.ts +++ b/packages/common/src/utils/mapObject.ts @@ -3,9 +3,9 @@ */ export function mapObject< Source extends Record, - Target extends { [key in keyof Source]: unknown } + Target extends { [key in keyof Source]: unknown }, >(source: Source, valueMap: (value: Source[typeof key], key: keyof Source) => Target[typeof key]): Target { return Object.fromEntries( - Object.entries(source).map(([key, value]) => [key, valueMap(value as Source[keyof Source], key)]) + Object.entries(source).map(([key, value]) => [key, valueMap(value as Source[keyof Source], key)]), ) as Target; } diff --git a/packages/common/src/writeContract.ts b/packages/common/src/writeContract.ts index 973ecfb8bb..5818f18db4 100644 --- a/packages/common/src/writeContract.ts +++ b/packages/common/src/writeContract.ts @@ -26,10 +26,10 @@ export async function writeContract< abi extends Abi | readonly unknown[], functionName extends ContractFunctionName, args extends ContractFunctionArgs, - chainOverride extends Chain | undefined + chainOverride extends Chain | undefined, >( client: Client, - request: WriteContractParameters + request: WriteContractParameters, ): Promise { const rawAccount = request.account ?? client.account; if (!rawAccount) { @@ -88,8 +88,8 @@ export async function writeContract< // TODO: prepareWrite again if there are gas errors? throw error; }, - } + }, ), - { throwOnTimeout: true } + { throwOnTimeout: true }, ); } diff --git a/packages/config/src/library/dynamicResolution.ts b/packages/config/src/library/dynamicResolution.ts index 4fc1dbdbcc..cf6e4083eb 100644 --- a/packages/config/src/library/dynamicResolution.ts +++ b/packages/config/src/library/dynamicResolution.ts @@ -35,7 +35,7 @@ export function isDynamicResolution(value: unknown): value is DynamicResolution */ export function resolveWithContext( unresolved: any, - context: { systemAddresses?: Record>; tableIds?: Record } + context: { systemAddresses?: Record>; tableIds?: Record }, ): ValueWithType { if (!isDynamicResolution(unresolved)) return unresolved; let resolved: ValueWithType | undefined = undefined; diff --git a/packages/create-mud/CHANGELOG.md b/packages/create-mud/CHANGELOG.md index 71ccd47861..ddb24ed63f 100644 --- a/packages/create-mud/CHANGELOG.md +++ b/packages/create-mud/CHANGELOG.md @@ -636,7 +636,7 @@ .pipe( map((block) => Number(block.timestamp) * 1000), // Map to timestamp in ms filter((blockTimestamp) => blockTimestamp !== clock.lastUpdateTime), // Ignore if the clock was already refreshed with this block - filter((blockTimestamp) => blockTimestamp !== clock.currentTime) // Ignore if the current local timestamp is correct + filter((blockTimestamp) => blockTimestamp !== clock.currentTime), // Ignore if the current local timestamp is correct ) .subscribe(clock.update); // Update the local clock ``` diff --git a/packages/dev-tools/src/App.tsx b/packages/dev-tools/src/App.tsx index 08f1fd7ccb..0d74c3fcae 100644 --- a/packages/dev-tools/src/App.tsx +++ b/packages/dev-tools/src/App.tsx @@ -29,7 +29,7 @@ export function App() { className={twMerge( "pointer-events-auto w-full max-w-screen-sm h-full absolute right-0", "transition duration-500", - shown ? "translate-x-0" : "translate-x-full" + shown ? "translate-x-0" : "translate-x-full", )} >
@@ -49,7 +49,7 @@ export function App() { className={twMerge( "w-full h-full bg-slate-800 text-white/80 text-sm flex flex-col", "transition duration-500", - shown ? "opacity-100" : "opacity-0" + shown ? "opacity-100" : "opacity-0", )} > diff --git a/packages/dev-tools/src/actions/WriteSummary.tsx b/packages/dev-tools/src/actions/WriteSummary.tsx index 5ac4232835..8221805752 100644 --- a/packages/dev-tools/src/actions/WriteSummary.tsx +++ b/packages/dev-tools/src/actions/WriteSummary.tsx @@ -80,7 +80,7 @@ export function WriteSummary({ write }: Props) {
@@ -97,7 +97,7 @@ export function WriteSummary({ write }: Props) { target="_blank" className={twMerge( "flex-none font-mono text-xs text-white/40", - blockExplorer ? "hover:text-white/60 hover:underline" : null + blockExplorer ? "hover:text-white/60 hover:underline" : null, )} title={transactionReceipt.value.blockNumber.toString()} > @@ -110,7 +110,7 @@ export function WriteSummary({ write }: Props) { target="_blank" className={twMerge( "flex-none font-mono text-xs text-white/40", - blockExplorer ? "hover:text-white/60 hover:underline" : null + blockExplorer ? "hover:text-white/60 hover:underline" : null, )} title={hash.value} > diff --git a/packages/dev-tools/src/actions/getTransaction.ts b/packages/dev-tools/src/actions/getTransaction.ts index eba0191ee4..50763582b1 100644 --- a/packages/dev-tools/src/actions/getTransaction.ts +++ b/packages/dev-tools/src/actions/getTransaction.ts @@ -10,7 +10,7 @@ const cache: Record> = {}; export function getTransaction( publicClient: PublicClient, - write: ContractWrite + write: ContractWrite, ): Promise { if (!cache[write.id]) { cache[write.id] = write.result.then((hash) => publicClient.getTransaction({ hash })); diff --git a/packages/dev-tools/src/actions/getTransactionReceipt.ts b/packages/dev-tools/src/actions/getTransactionReceipt.ts index 531dcb06d3..425f840e74 100644 --- a/packages/dev-tools/src/actions/getTransactionReceipt.ts +++ b/packages/dev-tools/src/actions/getTransactionReceipt.ts @@ -7,7 +7,7 @@ const cache: Record> = {}; export function getTransactionReceipt( publicClient: PublicClient, - write: ContractWrite + write: ContractWrite, ): Promise { if (!cache[write.id]) { cache[write.id] = write.result.then((hash) => publicClient.waitForTransactionReceipt({ hash })); diff --git a/packages/dev-tools/src/actions/getTransactionResult.ts b/packages/dev-tools/src/actions/getTransactionResult.ts index e2c3f70d65..380f027b36 100644 --- a/packages/dev-tools/src/actions/getTransactionResult.ts +++ b/packages/dev-tools/src/actions/getTransactionResult.ts @@ -13,7 +13,7 @@ const cache: Record> = {}; export function getTransactionResult( publicClient: PublicClient, worldAbi: Abi, - write: ContractWrite + write: ContractWrite, ): Promise { if (!cache[write.id]) { const transaction = getTransaction(publicClient, write); diff --git a/packages/dev-tools/src/mount.tsx b/packages/dev-tools/src/mount.tsx index bfaff6c910..c54976211d 100644 --- a/packages/dev-tools/src/mount.tsx +++ b/packages/dev-tools/src/mount.tsx @@ -5,7 +5,7 @@ const containerId = "mud-dev-tools"; // TODO: rework to always return a unmount function (not a promise or possibly undefined) export async function mount( - opts: DevToolsOptions + opts: DevToolsOptions, ): Promise<(() => void) | undefined> { if (typeof window === "undefined") { console.warn("MUD dev-tools should only be used in browser bundles"); @@ -39,7 +39,7 @@ export async function mount( - + , ); document.body.appendChild(rootElement); diff --git a/packages/dev-tools/src/recs/ComponentDataTable.tsx b/packages/dev-tools/src/recs/ComponentDataTable.tsx index 5323d9af3f..6dce6eb87f 100644 --- a/packages/dev-tools/src/recs/ComponentDataTable.tsx +++ b/packages/dev-tools/src/recs/ComponentDataTable.tsx @@ -38,8 +38,8 @@ export function ComponentDataTable({ component }: Props) { {component.schema[name] === Type.T ? serialize(fieldValue) : Array.isArray(fieldValue) - ? fieldValue.map(String).join(", ") - : String(fieldValue)} + ? fieldValue.map(String).join(", ") + : String(fieldValue)} ); })} diff --git a/packages/dev-tools/src/recs/ComponentsPage.tsx b/packages/dev-tools/src/recs/ComponentsPage.tsx index ef95a1bb5b..9abc66bb9e 100644 --- a/packages/dev-tools/src/recs/ComponentsPage.tsx +++ b/packages/dev-tools/src/recs/ComponentsPage.tsx @@ -63,7 +63,7 @@ export function ComponentsPage() { }> } /> - - ) + , + ), ); diff --git a/packages/dev-tools/src/summary/SummaryPage.tsx b/packages/dev-tools/src/summary/SummaryPage.tsx index 230e18fa40..516aac5b16 100644 --- a/packages/dev-tools/src/summary/SummaryPage.tsx +++ b/packages/dev-tools/src/summary/SummaryPage.tsx @@ -8,7 +8,7 @@ import packageJson from "../../package.json"; import { useDevToolsContext } from "../DevToolsContext"; const isLinked = Object.entries(packageJson.dependencies).some( - ([name, version]) => name.startsWith("@latticexyz/") && version.startsWith("link:") + ([name, version]) => name.startsWith("@latticexyz/") && version.startsWith("link:"), ); export function SummaryPage() { diff --git a/packages/dev-tools/src/zustand/TablesPage.tsx b/packages/dev-tools/src/zustand/TablesPage.tsx index cd27b25dbc..4c28750e89 100644 --- a/packages/dev-tools/src/zustand/TablesPage.tsx +++ b/packages/dev-tools/src/zustand/TablesPage.tsx @@ -57,7 +57,7 @@ export function TablesPage() { (table: table): TableRecord
}>( - useStore.getState().getRecords(table) + useStore.getState().getRecords(table), ); useEffect(() => { return useStore.subscribe((state) => { diff --git a/packages/faucet/bin/parseEnv.ts b/packages/faucet/bin/parseEnv.ts index dd739618c9..7d17e6da78 100644 --- a/packages/faucet/bin/parseEnv.ts +++ b/packages/faucet/bin/parseEnv.ts @@ -13,7 +13,7 @@ const commonSchema = z.object({ }); export function parseEnv( - schema?: TSchema + schema?: TSchema, ): z.infer : typeof commonSchema> { const envSchema = schema !== undefined ? z.intersection(commonSchema, schema) : commonSchema; try { diff --git a/packages/faucet/src/createAppRouter.ts b/packages/faucet/src/createAppRouter.ts index c30c417911..ab8285c286 100644 --- a/packages/faucet/src/createAppRouter.ts +++ b/packages/faucet/src/createAppRouter.ts @@ -19,7 +19,7 @@ export function createAppRouter() { .input( z.object({ address: z.string().refine(isHex), - }) + }), ) .mutation(async (opts): Promise => { const { client, faucetAccount, dripAmount } = opts.ctx; diff --git a/packages/gas-report/ts/gas-report.ts b/packages/gas-report/ts/gas-report.ts index aac2397f12..2391c2f101 100755 --- a/packages/gas-report/ts/gas-report.ts +++ b/packages/gas-report/ts/gas-report.ts @@ -25,7 +25,7 @@ yargs(hideBin(process.argv)) console.error(chalk.red(msg)); if (msg.includes("Missing required argument")) { console.log( - chalk.yellow(`Run 'pnpm mud ${process.argv[2]} --help' for a list of available and required arguments.`) + chalk.yellow(`Run 'pnpm mud ${process.argv[2]} --help' for a list of available and required arguments.`), ); } diff --git a/packages/phaserx/src/createCamera.ts b/packages/phaserx/src/createCamera.ts index d7df7d9c91..4c131a15f5 100644 --- a/packages/phaserx/src/createCamera.ts +++ b/packages/phaserx/src/createCamera.ts @@ -20,7 +20,7 @@ export function createCamera(phaserCamera: Phaser.Cameras.Scene2D.Camera, option onPinch: (state) => pinchStream$.next(state), onWheel: (state) => wheelStream$.next(state), }, - {} + {}, ); // function getNearestLevel(currentZoom: number): number { @@ -51,7 +51,7 @@ export function createCamera(phaserCamera: Phaser.Cameras.Scene2D.Camera, option return zoom + scaledDelta; }), // Compute pinch speed map((zoom) => Math.min(Math.max(zoom, options.minZoom), options.maxZoom)), // Limit zoom values - scan((acc, curr) => [acc[1], curr], [1, 1]) // keep track of the last value to offset the map position (not implemented yet) + scan((acc, curr) => [acc[1], curr], [1, 1]), // keep track of the last value to offset the map position (not implemented yet) ) .subscribe(([, zoom]) => { // Set the gesture zoom state to the current zoom value to avoid zooming beyond the max values @@ -67,7 +67,7 @@ export function createCamera(phaserCamera: Phaser.Cameras.Scene2D.Camera, option // @ts-ignore map((state) => state.delta.map((x) => x * options.wheelSpeed)), // Compute wheel speed map((movement) => movement.map((m: number) => m / phaserCamera.zoom)), // Adjust for current zoom value - map((movement) => [phaserCamera.scrollX + movement[0], phaserCamera.scrollY + movement[1]]) // Compute new pinch + map((movement) => [phaserCamera.scrollX + movement[0], phaserCamera.scrollY + movement[1]]), // Compute new pinch ) .subscribe(([x, y]) => { phaserCamera.setScroll(x, y); diff --git a/packages/phaserx/src/createChunks.ts b/packages/phaserx/src/createChunks.ts index a300c50f9d..f940574344 100644 --- a/packages/phaserx/src/createChunks.ts +++ b/packages/phaserx/src/createChunks.ts @@ -19,9 +19,9 @@ export function createChunks(worldView$: Observable, chunkSize: number, pa width: width + 2 * padding, height: height + 2 * padding, }, - chunkSize - ) - ) + chunkSize, + ), + ), ); visibleChunkStream.subscribe((newVisibleChunks) => { diff --git a/packages/phaserx/src/createCulling.ts b/packages/phaserx/src/createCulling.ts index 7df01f83e9..e17419422f 100644 --- a/packages/phaserx/src/createCulling.ts +++ b/packages/phaserx/src/createCulling.ts @@ -50,7 +50,7 @@ export function createCulling(objectPool: ObjectPool, camera: Camera, chunks: Ch map((chunk: ChunkCoord) => from(chunkRegistry.get(chunk))), // Map to streams of entityIds mergeMap((entities) => entities), // Flatten the stream of entities map((entityId) => objectPool.get(entityId, "Existing")), // Map entityId to embodiedEntity - filterNullish() + filterNullish(), ); // Spawn entities when their chunk appears in the viewport @@ -77,7 +77,7 @@ export function createCulling(objectPool: ObjectPool, camera: Camera, chunks: Ch entity.despawn(); } }, - { fireImmediately: true } + { fireImmediately: true }, ); disposer.set(entity.id, dispose); } diff --git a/packages/phaserx/src/createDebugger.ts b/packages/phaserx/src/createDebugger.ts index e33bba3cf0..7cbddf3ea8 100644 --- a/packages/phaserx/src/createDebugger.ts +++ b/packages/phaserx/src/createDebugger.ts @@ -15,7 +15,7 @@ export function createDebugger( chunks: Chunks, scene: Phaser.Scene, objectPool: ObjectPool, - map: AnimatedTilemap + map: AnimatedTilemap, ) { const options = { logViewport: false, @@ -47,8 +47,8 @@ export function createDebugger( console.log( `Entities: ${objectPool.objects.size} / Pool size: ${Object.values(objectPool.groups).reduce( (acc, curr) => acc + curr.getChildren().length, - 0 - )} / Pool active: ${Object.values(objectPool.groups).reduce((acc, curr) => acc + curr.countActive(), 0)}` + 0, + )} / Pool active: ${Object.values(objectPool.groups).reduce((acc, curr) => acc + curr.countActive(), 0)}`, ); } @@ -66,7 +66,7 @@ export function createDebugger( chunks.chunkSize, chunks.chunkSize, getRandomColor(), - 0.5 + 0.5, ); visualChunk.setInteractive(); visualChunk.on("pointerup", () => { diff --git a/packages/phaserx/src/createEmbodiedEntity.ts b/packages/phaserx/src/createEmbodiedEntity.ts index faf53312cb..765243607b 100644 --- a/packages/phaserx/src/createEmbodiedEntity.ts +++ b/packages/phaserx/src/createEmbodiedEntity.ts @@ -14,7 +14,7 @@ export function createEmbodiedEntity( id: string, group: Phaser.GameObjects.Group, type: Type, - currentCameraFilter = 0 + currentCameraFilter = 0, ): EmbodiedEntity { const position: PixelCoord = observable({ x: 0, y: 0 }); const onOnce = new Map>(); @@ -136,7 +136,7 @@ export function createEmbodiedEntity( function executeGameObjectFunctions( gameObject: GameObject, - functions: Iterable> + functions: Iterable>, ) { if (!gameObject) return; for (const func of functions) { @@ -145,7 +145,7 @@ function executeGameObjectFunctions( } function modifiesPosition( - func: GameObjectFunction + func: GameObjectFunction, ): Partial | undefined { let newPosition: Partial | undefined = undefined; const gameObjectProxy = new Proxy( @@ -162,7 +162,7 @@ function modifiesPosition( if (prop === "y") newPosition = newPosition ? { ...newPosition, y: value } : { y: value }; return true; }, - } + }, ); func(gameObjectProxy as GameObject); return newPosition; diff --git a/packages/phaserx/src/createInput.ts b/packages/phaserx/src/createInput.ts index f1569d9147..7f38908b6a 100644 --- a/packages/phaserx/src/createInput.ts +++ b/packages/phaserx/src/createInput.ts @@ -42,25 +42,25 @@ export function createInput(inputPlugin: Phaser.Input.InputPlugin) { map(() => { return { pointer: inputPlugin.manager?.activePointer }; }), - filterNullish() + filterNullish(), ); const pointerdown$: Observable<{ pointer: Phaser.Input.Pointer; event: MouseEvent }> = fromEvent( document, - "mousedown" + "mousedown", ).pipe( filter(() => enabled.current), map((event) => ({ pointer: inputPlugin.manager?.activePointer, event: event as MouseEvent })), - filterNullish() + filterNullish(), ); const pointerup$: Observable<{ pointer: Phaser.Input.Pointer; event: MouseEvent }> = fromEvent( document, - "mouseup" + "mouseup", ).pipe( filter(() => enabled.current), map((event) => ({ pointer: inputPlugin.manager?.activePointer, event: event as MouseEvent })), - filterNullish() + filterNullish(), ); // Click stream @@ -73,7 +73,7 @@ export function createInput(inputPlugin: Phaser.Input.InputPlugin) { bufferCount(2, 1), // Store the last two timestamps filter(([prev, now]) => prev[0] && !now[0] && now[1] - prev[1] < 250), // Only care if button was pressed before and is not anymore and it happened within 500ms map(() => inputPlugin.manager?.activePointer), // Return the current pointer - filterNullish() + filterNullish(), ); // Double click stream @@ -84,14 +84,14 @@ export function createInput(inputPlugin: Phaser.Input.InputPlugin) { filter(([prev, now]) => now - prev < 500), // Filter clicks with more than 500ms distance throttleTime(500), // A third click within 500ms is not counted as another double click map(() => inputPlugin.manager?.activePointer), // Return the current pointer - filterNullish() + filterNullish(), ); // Right click stream const rightClick$ = merge(pointerdown$, pointerup$).pipe( filter(({ pointer }) => enabled.current && pointer.rightButtonDown()), map(() => inputPlugin.manager?.activePointer), // Return the current pointer - filterNullish() + filterNullish(), ); // Drag stream @@ -106,14 +106,14 @@ export function createInput(inputPlugin: Phaser.Input.InputPlugin) { ? { ...acc, width: curr.worldX - acc.x, height: curr.worldY - acc.y } // Update the width/height : { x: curr.worldX, y: curr.worldY, width: 0, height: 0 } // Else start the drag : undefined, - undefined + undefined, ), filterNullish(), - filter((area) => Math.abs(area.width) > 10 && Math.abs(area.height) > 10) // Prevent clicking to be mistaken as a drag - ) + filter((area) => Math.abs(area.width) > 10 && Math.abs(area.height) > 10), // Prevent clicking to be mistaken as a drag + ), ).pipe( filter(() => enabled.current), - distinctUntilChanged() // Prevent same value to be emitted in a row + distinctUntilChanged(), // Prevent same value to be emitted in a row ); const pressedKeys = observable(new Set()); @@ -170,7 +170,7 @@ export function createInput(inputPlugin: Phaser.Input.InputPlugin) { (passes) => { if (passes) callback(); }, - { fireImmediately: true } + { fireImmediately: true }, ); disposers.add(disposer); } diff --git a/packages/phaserx/src/createObjectPool.ts b/packages/phaserx/src/createObjectPool.ts index 654be498e8..e3535487cc 100644 --- a/packages/phaserx/src/createObjectPool.ts +++ b/packages/phaserx/src/createObjectPool.ts @@ -22,7 +22,7 @@ export function createObjectPool(scene: Phaser.Scene) { function get( entity: number | string, - type: Type + type: Type, ): ObjectPoolReturnType { if (typeof entity === "number") entity = String(entity); let embodiedEntity = objects.get(entity); diff --git a/packages/phaserx/src/guards.ts b/packages/phaserx/src/guards.ts index 96681af748..e6e83b8510 100644 --- a/packages/phaserx/src/guards.ts +++ b/packages/phaserx/src/guards.ts @@ -19,7 +19,7 @@ export function defineAssetsConfig(assets: A) { } export function defineMapConfig, L extends LayerConfig>( - config: MapConfig + config: MapConfig, ) { return config; } @@ -29,7 +29,7 @@ export function defineSceneConfig< S extends { [key: string]: Sprite }, T extends TilesetConfig, M extends MapsConfig, - Ans extends Animation[] + Ans extends Animation[], >(config: SceneConfig) { return config; } @@ -44,14 +44,14 @@ export function defineCameraConfig(config: CameraConfig) { export function isSprite( gameObject: Phaser.GameObjects.GameObject, - type: keyof GameObjectTypes + type: keyof GameObjectTypes, ): gameObject is GameObject<"Sprite"> { return type === "Sprite"; } export function isRectangle( gameObject: Phaser.GameObjects.GameObject, - type: keyof GameObjectTypes + type: keyof GameObjectTypes, ): gameObject is GameObject<"Rectangle"> { return type === "Rectangle"; } diff --git a/packages/phaserx/src/tilemap/createAnimatedTilemap.ts b/packages/phaserx/src/tilemap/createAnimatedTilemap.ts index cf01db3e70..449f30ecff 100644 --- a/packages/phaserx/src/tilemap/createAnimatedTilemap.ts +++ b/packages/phaserx/src/tilemap/createAnimatedTilemap.ts @@ -7,7 +7,7 @@ import { createVirtualTilemap } from "./createVirtualTilemap"; import { TileAnimation } from "./types"; export function createAnimatedTilemap( - config: Omit, "tiles"> & { animationInterval: number } + config: Omit, "tiles"> & { animationInterval: number }, ): AnimatedTilemap { const { layerConfig: { layers, defaultLayer }, diff --git a/packages/phaserx/src/tilemap/createChunkedTilemap.ts b/packages/phaserx/src/tilemap/createChunkedTilemap.ts index 2f4b92187b..360a27248e 100644 --- a/packages/phaserx/src/tilemap/createChunkedTilemap.ts +++ b/packages/phaserx/src/tilemap/createChunkedTilemap.ts @@ -20,7 +20,7 @@ export type ChunkedTilemapConfig( - params: ChunkedTilemapConfig + params: ChunkedTilemapConfig, ): ChunkedTilemap { const { scene, tilesets, layerConfig, chunks, backgroundTile, tiles, tileWidth, tileHeight } = params; const relevantTilesets = Object.keys(layerConfig.layers) @@ -68,7 +68,7 @@ export function createChunkedTilemap( - config: Omit, "tiles"> + config: Omit, "tiles">, ): VirtualTilemap { const { chunks, diff --git a/packages/phaserx/src/types.ts b/packages/phaserx/src/types.ts index c059ebbf49..031de7a11e 100644 --- a/packages/phaserx/src/types.ts +++ b/packages/phaserx/src/types.ts @@ -26,7 +26,7 @@ export type GameObjectTypes = typeof GameObjectClasses; export type GameObject = InstanceType; export type GameObjectFunction = ( - gameObject: GameObject + gameObject: GameObject, ) => Promise | void; export type GameScene = ReturnType; @@ -135,7 +135,7 @@ export type SceneConfig< S extends { [key: string]: Sprite }, T extends TilesetConfig, M extends MapsConfig, - Ans extends Animation[] + Ans extends Animation[], > = { preload?: (scene: Phaser.Scene) => void; create?: (scene: Phaser.Scene) => void; diff --git a/packages/phaserx/src/utils/chunks.ts b/packages/phaserx/src/utils/chunks.ts index 587d4f50d8..b6e47c2a44 100644 --- a/packages/phaserx/src/utils/chunks.ts +++ b/packages/phaserx/src/utils/chunks.ts @@ -21,7 +21,7 @@ export function getChunksInArea(area: Area, chunkSize: number) { x: topLeftChunk.x + x, y: topLeftChunk.y + y, }, - true + true, ); } } diff --git a/packages/phaserx/src/utils/coords.ts b/packages/phaserx/src/utils/coords.ts index fcd197f74c..4d20821360 100644 --- a/packages/phaserx/src/utils/coords.ts +++ b/packages/phaserx/src/utils/coords.ts @@ -64,7 +64,7 @@ export function tileCoordToChunkCoord( tileCoord: WorldCoord, tileWidth: number, tileHeight: number, - chunkSize: number + chunkSize: number, ): ChunkCoord { const pixelCoord = tileCoordToPixelCoord(tileCoord, tileWidth, tileHeight); return pixelToChunkCoord(pixelCoord, chunkSize); @@ -74,7 +74,7 @@ export function chunkCoordToTileCoord( chunkCoord: ChunkCoord, tileWidth: number, tileHeight: number, - chunkSize: number + chunkSize: number, ): WorldCoord { const pixelCoord = chunkToPixelCoord(chunkCoord, chunkSize); return pixelCoordToTileCoord(pixelCoord, tileWidth, tileHeight); diff --git a/packages/phaserx/src/utils/generateFrames.ts b/packages/phaserx/src/utils/generateFrames.ts index ef9ad74aec..99fa4a8ab6 100644 --- a/packages/phaserx/src/utils/generateFrames.ts +++ b/packages/phaserx/src/utils/generateFrames.ts @@ -2,7 +2,7 @@ import { Animation, Assets } from "../types"; export function generateFrames( anims: Phaser.Animations.AnimationManager, - animation: Animation + animation: Animation, ): Phaser.Types.Animations.AnimationFrame[] { if (animation.prefix && animation.suffix) { return anims.generateFrameNames(animation.assetKey, { diff --git a/packages/protocol-parser/src/decodeDynamicField.test.ts b/packages/protocol-parser/src/decodeDynamicField.test.ts index 4ad3b8236f..1120adac5f 100644 --- a/packages/protocol-parser/src/decodeDynamicField.test.ts +++ b/packages/protocol-parser/src/decodeDynamicField.test.ts @@ -22,28 +22,28 @@ describe("decodeDynamicField", () => { it("can decode uint256[]", () => { expect( - decodeDynamicField("uint256[]", "0x0000000000000000000000000000000000000000000000000000000000000000") + decodeDynamicField("uint256[]", "0x0000000000000000000000000000000000000000000000000000000000000000"), ).toStrictEqual([0n]); expect( - decodeDynamicField("uint256[]", "0x0000000000000000000000000000000000000000000000000000000000000001") + decodeDynamicField("uint256[]", "0x0000000000000000000000000000000000000000000000000000000000000001"), ).toStrictEqual([1n]); expect( - decodeDynamicField("uint256[]", "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff") + decodeDynamicField("uint256[]", "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), ).toStrictEqual([115792089237316195423570985008687907853269984665640564039457584007913129639935n]); expect( - decodeDynamicField("uint256[]", "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe") + decodeDynamicField("uint256[]", "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe"), ).toStrictEqual([115792089237316195423570985008687907853269984665640564039457584007913129639934n]); expect( decodeDynamicField( "uint256[]", - "0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001" - ) + "0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001", + ), ).toStrictEqual([1n, 1n]); expect( decodeDynamicField( "uint256[]", - "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" - ) + "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + ), ).toStrictEqual([ 115792089237316195423570985008687907853269984665640564039457584007913129639935n, 115792089237316195423570985008687907853269984665640564039457584007913129639935n, @@ -68,41 +68,41 @@ describe("decodeDynamicField", () => { it("can decode int256[]", () => { expect( - decodeDynamicField("int256[]", "0x0000000000000000000000000000000000000000000000000000000000000000") + decodeDynamicField("int256[]", "0x0000000000000000000000000000000000000000000000000000000000000000"), ).toStrictEqual([0n]); expect( - decodeDynamicField("int256[]", "0x0000000000000000000000000000000000000000000000000000000000000001") + decodeDynamicField("int256[]", "0x0000000000000000000000000000000000000000000000000000000000000001"), ).toStrictEqual([1n]); expect( - decodeDynamicField("int256[]", "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff") + decodeDynamicField("int256[]", "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), ).toStrictEqual([57896044618658097711785492504343953926634992332820282019728792003956564819967n]); expect( - decodeDynamicField("int256[]", "0x8000000000000000000000000000000000000000000000000000000000000000") + decodeDynamicField("int256[]", "0x8000000000000000000000000000000000000000000000000000000000000000"), ).toStrictEqual([-57896044618658097711785492504343953926634992332820282019728792003956564819968n]); expect( - decodeDynamicField("int256[]", "0x8000000000000000000000000000000000000000000000000000000000000001") + decodeDynamicField("int256[]", "0x8000000000000000000000000000000000000000000000000000000000000001"), ).toStrictEqual([-57896044618658097711785492504343953926634992332820282019728792003956564819967n]); expect( - decodeDynamicField("int256[]", "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff") + decodeDynamicField("int256[]", "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), ).toStrictEqual([-1n]); expect( decodeDynamicField( "int256[]", - "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" - ) + "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + ), ).toStrictEqual([57896044618658097711785492504343953926634992332820282019728792003956564819967n, -1n]); expect( decodeDynamicField( "int256[]", - "0x80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" - ) + "0x80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + ), ).toStrictEqual([-57896044618658097711785492504343953926634992332820282019728792003956564819968n, 0n]); expect( decodeDynamicField( "int256[]", - "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8000000000000000000000000000000000000000000000000000000000000001" - ) + "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8000000000000000000000000000000000000000000000000000000000000001", + ), ).toStrictEqual([-1n, -57896044618658097711785492504343953926634992332820282019728792003956564819967n]); }); @@ -129,13 +129,13 @@ describe("decodeDynamicField", () => { ]); expect(decodeDynamicField("bytes4[]", "0xff00ff00ff00ff00")).toStrictEqual(["0xff00ff00", "0xff00ff00"]); expect( - decodeDynamicField("bytes32[]", "0x0000000000000000000000000000000000000000000000000000000000000001") + decodeDynamicField("bytes32[]", "0x0000000000000000000000000000000000000000000000000000000000000001"), ).toStrictEqual(["0x0000000000000000000000000000000000000000000000000000000000000001"]); expect( decodeDynamicField( "bytes32[]", - "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" - ) + "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", + ), ).toStrictEqual([ "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000001", @@ -151,10 +151,10 @@ describe("decodeDynamicField", () => { ]); expect(() => decodeDynamicField("address[]", "0x00")).toThrow( - 'Hex value "0x00" has length of 2, but expected a multiple of 40 for address[] type.' + 'Hex value "0x00" has length of 2, but expected a multiple of 40 for address[] type.', ); expect(() => decodeDynamicField("address[]", "0xffffffffffffffffffffffffffffffffffffffffff")).toThrow( - 'Hex value "0xffffffffffffffffffffffffffffffffffffffffff" has length of 42, but expected a multiple of 40 for address[] type.' + 'Hex value "0xffffffffffffffffffffffffffffffffffffffffff" has length of 42, but expected a multiple of 40 for address[] type.', ); }); @@ -164,7 +164,7 @@ describe("decodeDynamicField", () => { expect(decodeDynamicField("bytes", "0x0001")).toBe("0x0001"); expect(decodeDynamicField("bytes", "0xff00ff00ff00ff00")).toBe("0xff00ff00ff00ff00"); expect(decodeDynamicField("bytes", "0x0000000000000000000000000000000000000000000000000000000000000001")).toBe( - "0x0000000000000000000000000000000000000000000000000000000000000001" + "0x0000000000000000000000000000000000000000000000000000000000000001", ); }); diff --git a/packages/protocol-parser/src/decodeDynamicField.ts b/packages/protocol-parser/src/decodeDynamicField.ts index 3fcb63876c..d9eaf52b64 100644 --- a/packages/protocol-parser/src/decodeDynamicField.ts +++ b/packages/protocol-parser/src/decodeDynamicField.ts @@ -14,7 +14,7 @@ import { InvalidHexLengthError, InvalidHexLengthForArrayFieldError } from "./err export function decodeDynamicField< TAbiType extends DynamicAbiType, - TPrimitiveType extends DynamicAbiTypeToPrimitiveType + TPrimitiveType extends DynamicAbiTypeToPrimitiveType, >(abiType: TAbiType, data: Hex): TPrimitiveType { if (abiType === "bytes") { return data as TPrimitiveType; diff --git a/packages/protocol-parser/src/decodeField.ts b/packages/protocol-parser/src/decodeField.ts index b3a63059d5..e6b6d881c7 100644 --- a/packages/protocol-parser/src/decodeField.ts +++ b/packages/protocol-parser/src/decodeField.ts @@ -5,7 +5,7 @@ import { decodeStaticField } from "./decodeStaticField"; export function decodeField< TAbiType extends SchemaAbiType, - TPrimitiveType extends SchemaAbiTypeToPrimitiveType + TPrimitiveType extends SchemaAbiTypeToPrimitiveType, >(abiType: TAbiType, data: Hex): TPrimitiveType { return ( isDynamicAbiType(abiType) ? decodeDynamicField(abiType, data) : decodeStaticField(abiType, data) diff --git a/packages/protocol-parser/src/decodeKey.ts b/packages/protocol-parser/src/decodeKey.ts index 2b11552ad8..bec0695e6a 100644 --- a/packages/protocol-parser/src/decodeKey.ts +++ b/packages/protocol-parser/src/decodeKey.ts @@ -4,12 +4,12 @@ import { decodeKeyTuple } from "./decodeKeyTuple"; export function decodeKey( keySchema: TSchema, - data: readonly Hex[] + data: readonly Hex[], ): SchemaToPrimitives { // TODO: refactor and move all decodeKeyTuple logic into this method so we can delete decodeKeyTuple const keyValues = decodeKeyTuple({ staticFields: Object.values(keySchema), dynamicFields: [] }, data); return Object.fromEntries( - Object.keys(keySchema).map((name, i) => [name, keyValues[i]]) + Object.keys(keySchema).map((name, i) => [name, keyValues[i]]), ) as SchemaToPrimitives; } diff --git a/packages/protocol-parser/src/decodeKeyTuple.test.ts b/packages/protocol-parser/src/decodeKeyTuple.test.ts index 362118332d..cd1c2c14c1 100644 --- a/packages/protocol-parser/src/decodeKeyTuple.test.ts +++ b/packages/protocol-parser/src/decodeKeyTuple.test.ts @@ -6,12 +6,12 @@ describe("decodeKeyTuple", () => { expect( decodeKeyTuple({ staticFields: ["bool"], dynamicFields: [] }, [ "0x0000000000000000000000000000000000000000000000000000000000000000", - ]) + ]), ).toStrictEqual([false]); expect( decodeKeyTuple({ staticFields: ["bool"], dynamicFields: [] }, [ "0x0000000000000000000000000000000000000000000000000000000000000001", - ]) + ]), ).toStrictEqual([true]); }); @@ -24,7 +24,7 @@ describe("decodeKeyTuple", () => { "0x000000000000000000000000ffffffffffffffffffffffffffffffffffffffff", "0x0000000000000000000000000000000000000000000000000000000000000001", "0x0000000000000000000000000000000000000000000000000000000000000003", - ]) + ]), ).toStrictEqual([ 42n, -42, diff --git a/packages/protocol-parser/src/decodeKeyTuple.ts b/packages/protocol-parser/src/decodeKeyTuple.ts index 623df1fac1..426806dd68 100644 --- a/packages/protocol-parser/src/decodeKeyTuple.ts +++ b/packages/protocol-parser/src/decodeKeyTuple.ts @@ -8,10 +8,10 @@ import { Schema } from "./common"; export function decodeKeyTuple(keySchema: Schema, keyTuple: readonly Hex[]): StaticPrimitiveType[] { if (keySchema.staticFields.length !== keyTuple.length) { throw new Error( - `key tuple length ${keyTuple.length} does not match key schema length ${keySchema.staticFields.length}` + `key tuple length ${keyTuple.length} does not match key schema length ${keySchema.staticFields.length}`, ); } return keyTuple.map( - (key, index) => decodeAbiParameters([{ type: keySchema.staticFields[index] }], key)[0] as StaticPrimitiveType + (key, index) => decodeAbiParameters([{ type: keySchema.staticFields[index] }], key)[0] as StaticPrimitiveType, ); } diff --git a/packages/protocol-parser/src/decodeRecord.test.ts b/packages/protocol-parser/src/decodeRecord.test.ts index 87e357f599..f09283c4ab 100644 --- a/packages/protocol-parser/src/decodeRecord.test.ts +++ b/packages/protocol-parser/src/decodeRecord.test.ts @@ -6,7 +6,7 @@ describe("decodeRecord", () => { const valueSchema = { staticFields: ["uint32", "uint128"], dynamicFields: ["uint32[]", "string"] } as const; const values = decodeRecord( valueSchema, - "0x0000000100000000000000000000000000000002000000000000000000000000000000000000000b0000000008000000000000130000000300000004736f6d6520737472696e67" + "0x0000000100000000000000000000000000000002000000000000000000000000000000000000000b0000000008000000000000130000000300000004736f6d6520737472696e67", ); expect(values).toStrictEqual([1, 2n, [3, 4], "some string"]); }); diff --git a/packages/protocol-parser/src/decodeRecord.ts b/packages/protocol-parser/src/decodeRecord.ts index 411d93327c..1ae389fbcf 100644 --- a/packages/protocol-parser/src/decodeRecord.ts +++ b/packages/protocol-parser/src/decodeRecord.ts @@ -34,7 +34,7 @@ export function decodeRecord(valueSchema: Schema, data: Hex): readonly (StaticPr expectedLength: schemaStaticDataLength, actualLength: actualStaticDataLength, bytesOffset, - } + }, ); } @@ -63,7 +63,7 @@ export function decodeRecord(valueSchema: Schema, data: Hex): readonly (StaticPr expectedLength: dataLayout.totalByteLength, actualLength: actualDynamicDataLength, bytesOffset, - } + }, ); } } diff --git a/packages/protocol-parser/src/decodeStaticField.test.ts b/packages/protocol-parser/src/decodeStaticField.test.ts index 8ad29713aa..307b324a97 100644 --- a/packages/protocol-parser/src/decodeStaticField.test.ts +++ b/packages/protocol-parser/src/decodeStaticField.test.ts @@ -7,22 +7,22 @@ describe("decodeStaticField", () => { expect(decodeStaticField("bool", "0x01")).toBe(true); expect(() => decodeStaticField("bool", "0x0")).toThrow( - 'Hex value "0x0" has length of 1, but expected length of 2 for bool type.' + 'Hex value "0x0" has length of 1, but expected length of 2 for bool type.', ); expect(() => decodeStaticField("bool", "0x1")).toThrow( - 'Hex value "0x1" has length of 1, but expected length of 2 for bool type.' + 'Hex value "0x1" has length of 1, but expected length of 2 for bool type.', ); expect(() => decodeStaticField("bool", "0x000")).toThrow( - 'Hex value "0x000" is an odd length (3). It must be an even length.' + 'Hex value "0x000" is an odd length (3). It must be an even length.', ); expect(() => decodeStaticField("bool", "0x001")).toThrow( - 'Hex value "0x001" is an odd length (3). It must be an even length.' + 'Hex value "0x001" is an odd length (3). It must be an even length.', ); expect(() => decodeStaticField("bool", "0x0000")).toThrow( - 'Hex value "0x0000" has length of 4, but expected length of 2 for bool type.' + 'Hex value "0x0000" has length of 4, but expected length of 2 for bool type.', ); expect(() => decodeStaticField("bool", "0x0001")).toThrow( - 'Hex value "0x0001" has length of 4, but expected length of 2 for bool type.' + 'Hex value "0x0001" has length of 4, but expected length of 2 for bool type.', ); }); @@ -36,10 +36,10 @@ describe("decodeStaticField", () => { expect(decodeStaticField("uint256", "0x0000000000000000000000000000000000000000000000000000000000000000")).toBe(0n); expect(decodeStaticField("uint256", "0x0000000000000000000000000000000000000000000000000000000000000001")).toBe(1n); expect(decodeStaticField("uint256", "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")).toBe( - 115792089237316195423570985008687907853269984665640564039457584007913129639935n + 115792089237316195423570985008687907853269984665640564039457584007913129639935n, ); expect(decodeStaticField("uint256", "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe")).toBe( - 115792089237316195423570985008687907853269984665640564039457584007913129639934n + 115792089237316195423570985008687907853269984665640564039457584007913129639934n, ); }); @@ -56,13 +56,13 @@ describe("decodeStaticField", () => { expect(decodeStaticField("int256", "0x0000000000000000000000000000000000000000000000000000000000000000")).toBe(0n); expect(decodeStaticField("int256", "0x0000000000000000000000000000000000000000000000000000000000000001")).toBe(1n); expect(decodeStaticField("int256", "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")).toBe( - 57896044618658097711785492504343953926634992332820282019728792003956564819967n + 57896044618658097711785492504343953926634992332820282019728792003956564819967n, ); expect(decodeStaticField("int256", "0x8000000000000000000000000000000000000000000000000000000000000000")).toBe( - -57896044618658097711785492504343953926634992332820282019728792003956564819968n + -57896044618658097711785492504343953926634992332820282019728792003956564819968n, ); expect(decodeStaticField("int256", "0x8000000000000000000000000000000000000000000000000000000000000001")).toBe( - -57896044618658097711785492504343953926634992332820282019728792003956564819967n + -57896044618658097711785492504343953926634992332820282019728792003956564819967n, ); expect(decodeStaticField("int256", "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")).toBe(-1n); }); @@ -72,23 +72,23 @@ describe("decodeStaticField", () => { expect(decodeStaticField("bytes2", "0x0001")).toBe("0x0001"); expect(decodeStaticField("bytes8", "0xff00ff00ff00ff00")).toBe("0xff00ff00ff00ff00"); expect(decodeStaticField("bytes32", "0x0000000000000000000000000000000000000000000000000000000000000001")).toBe( - "0x0000000000000000000000000000000000000000000000000000000000000001" + "0x0000000000000000000000000000000000000000000000000000000000000001", ); }); it("can decode address", () => { expect(decodeStaticField("address", "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266")).toBe( - "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" + "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", ); expect(decodeStaticField("address", "0xffffffffffffffffffffffffffffffffffffffff")).toBe( - "0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF" + "0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF", ); expect(() => decodeStaticField("address", "0x00")).toThrow( - 'Hex value "0x00" has length of 2, but expected length of 40 for address type.' + 'Hex value "0x00" has length of 2, but expected length of 40 for address type.', ); expect(() => decodeStaticField("address", "0xffffffffffffffffffffffffffffffffffffffffff")).toThrow( - 'Hex value "0xffffffffffffffffffffffffffffffffffffffffff" has length of 42, but expected length of 40 for address type.' + 'Hex value "0xffffffffffffffffffffffffffffffffffffffffff" has length of 42, but expected length of 40 for address type.', ); }); }); diff --git a/packages/protocol-parser/src/decodeStaticField.ts b/packages/protocol-parser/src/decodeStaticField.ts index e8595d8832..9d2819d307 100644 --- a/packages/protocol-parser/src/decodeStaticField.ts +++ b/packages/protocol-parser/src/decodeStaticField.ts @@ -10,7 +10,7 @@ import { InvalidHexLengthError, InvalidHexLengthForStaticFieldError } from "./er export function decodeStaticField< TAbiType extends StaticAbiType, - TPrimitiveType extends StaticAbiTypeToPrimitiveType + TPrimitiveType extends StaticAbiTypeToPrimitiveType, >(abiType: TAbiType, data: Hex): TPrimitiveType { if (data.length > 3 && data.length % 2 !== 0) { throw new InvalidHexLengthError(data); diff --git a/packages/protocol-parser/src/decodeValue.ts b/packages/protocol-parser/src/decodeValue.ts index bd96093fed..06bb1a4b4a 100644 --- a/packages/protocol-parser/src/decodeValue.ts +++ b/packages/protocol-parser/src/decodeValue.ts @@ -11,6 +11,6 @@ export function decodeValue(valueSchema: TSchema, d const valueTuple = decodeRecord({ staticFields, dynamicFields }, data); return Object.fromEntries( - Object.keys(valueSchema).map((name, i) => [name, valueTuple[i]]) + Object.keys(valueSchema).map((name, i) => [name, valueTuple[i]]), ) as SchemaToPrimitives; } diff --git a/packages/protocol-parser/src/decodeValueArgs.ts b/packages/protocol-parser/src/decodeValueArgs.ts index d9f5e5161f..62966ba93d 100644 --- a/packages/protocol-parser/src/decodeValueArgs.ts +++ b/packages/protocol-parser/src/decodeValueArgs.ts @@ -7,7 +7,7 @@ import { readHex } from "@latticexyz/common"; export function decodeValueArgs( valueSchema: TSchema, - { staticData, encodedLengths, dynamicData }: ValueArgs + { staticData, encodedLengths, dynamicData }: ValueArgs, ): SchemaToPrimitives { return decodeValue( valueSchema, @@ -15,6 +15,6 @@ export function decodeValueArgs( readHex(staticData, 0, staticDataLength(Object.values(valueSchema).filter(isStaticAbiType))), encodedLengths, dynamicData, - ]) + ]), ); } diff --git a/packages/protocol-parser/src/encodeField.ts b/packages/protocol-parser/src/encodeField.ts index 99e977a850..cacfda1caf 100644 --- a/packages/protocol-parser/src/encodeField.ts +++ b/packages/protocol-parser/src/encodeField.ts @@ -4,7 +4,7 @@ import { Hex, encodePacked } from "viem"; export function encodeField( fieldType: TSchemaAbiType, - value: AbiParameterToPrimitiveType<{ type: TSchemaAbiType }> + value: AbiParameterToPrimitiveType<{ type: TSchemaAbiType }>, ): Hex { if (isArrayAbiType(fieldType) && Array.isArray(value)) { const staticFieldType = arrayAbiTypeToStaticAbiType(fieldType); @@ -13,7 +13,7 @@ export function encodeField( ? "0x" : encodePacked( value.map(() => staticFieldType), - value + value, ); } return encodePacked([fieldType], [value]); diff --git a/packages/protocol-parser/src/encodeKeyTuple.test.ts b/packages/protocol-parser/src/encodeKeyTuple.test.ts index 048e0d2921..2d712fdfe3 100644 --- a/packages/protocol-parser/src/encodeKeyTuple.test.ts +++ b/packages/protocol-parser/src/encodeKeyTuple.test.ts @@ -12,8 +12,8 @@ describe("encodeKeyTuple", () => { staticFields: ["bool"], dynamicFields: [], }, - [true] - ) + [true], + ), ).toStrictEqual(["0x0000000000000000000000000000000000000000000000000000000000000001"]); }); @@ -26,7 +26,7 @@ describe("encodeKeyTuple", () => { "0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF", true, 3, - ]) + ]), ).toStrictEqual([ "0x000000000000000000000000000000000000000000000000000000000000002a", "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd6", diff --git a/packages/protocol-parser/src/encodeLengths.test.ts b/packages/protocol-parser/src/encodeLengths.test.ts index 70d6b53187..8bd77ba7de 100644 --- a/packages/protocol-parser/src/encodeLengths.test.ts +++ b/packages/protocol-parser/src/encodeLengths.test.ts @@ -4,13 +4,13 @@ import { encodeLengths } from "./encodeLengths"; describe("encodeLengths", () => { it("can encode empty tuple", () => { expect(encodeLengths([])).toMatchInlineSnapshot( - '"0x0000000000000000000000000000000000000000000000000000000000000000"' + '"0x0000000000000000000000000000000000000000000000000000000000000000"', ); }); it("can encode bool key tuple", () => { expect(encodeLengths(["0x1234", "0x12345678"])).toMatchInlineSnapshot( - '"0x0000000000000000000000000000000000000004000000000200000000000006"' + '"0x0000000000000000000000000000000000000004000000000200000000000006"', ); }); }); diff --git a/packages/protocol-parser/src/encodeLengths.ts b/packages/protocol-parser/src/encodeLengths.ts index 5a3bbf0827..156e275f84 100644 --- a/packages/protocol-parser/src/encodeLengths.ts +++ b/packages/protocol-parser/src/encodeLengths.ts @@ -7,6 +7,6 @@ export function encodeLengths(values: Hex[]): Hex { return padHex( concatHex([...byteLengths.map((length) => encodeField("uint40", length)), encodeField("uint56", totalByteLength)]), - { size: 32, dir: "left" } + { size: 32, dir: "left" }, ); } diff --git a/packages/protocol-parser/src/encodeRecord.test.ts b/packages/protocol-parser/src/encodeRecord.test.ts index 29222756fa..33be538fd3 100644 --- a/packages/protocol-parser/src/encodeRecord.test.ts +++ b/packages/protocol-parser/src/encodeRecord.test.ts @@ -6,7 +6,7 @@ describe("encodeRecord", () => { const valueSchema = { staticFields: ["uint32", "uint128"], dynamicFields: ["uint32[]", "string"] } as const; const hex = encodeRecord(valueSchema, [1, 2n, [3, 4], "some string"]); expect(hex).toBe( - "0x0000000100000000000000000000000000000002000000000000000000000000000000000000000b0000000008000000000000130000000300000004736f6d6520737472696e67" + "0x0000000100000000000000000000000000000002000000000000000000000000000000000000000b0000000008000000000000130000000300000004736f6d6520737472696e67", ); }); diff --git a/packages/protocol-parser/src/encodeRecord.ts b/packages/protocol-parser/src/encodeRecord.ts index b92287830c..6c0e0f4daf 100644 --- a/packages/protocol-parser/src/encodeRecord.ts +++ b/packages/protocol-parser/src/encodeRecord.ts @@ -6,7 +6,7 @@ import { Schema } from "./common"; /** @deprecated use `encodeValue` instead */ export function encodeRecord( valueSchema: Schema, - values: readonly (StaticPrimitiveType | DynamicPrimitiveType)[] + values: readonly (StaticPrimitiveType | DynamicPrimitiveType)[], ): Hex { const staticValues = values.slice(0, valueSchema.staticFields.length) as readonly StaticPrimitiveType[]; const dynamicValues = values.slice(valueSchema.staticFields.length) as readonly DynamicPrimitiveType[]; @@ -18,7 +18,7 @@ export function encodeRecord( if (valueSchema.dynamicFields.length === 0) return `0x${staticData}`; const dynamicDataItems = dynamicValues.map((value, i) => - encodeField(valueSchema.dynamicFields[i], value).replace(/^0x/, "") + encodeField(valueSchema.dynamicFields[i], value).replace(/^0x/, ""), ); const dynamicFieldByteLengths = dynamicDataItems.map((value) => value.length / 2).reverse(); diff --git a/packages/protocol-parser/src/encodeValue.ts b/packages/protocol-parser/src/encodeValue.ts index df85964b65..accb91e0a1 100644 --- a/packages/protocol-parser/src/encodeValue.ts +++ b/packages/protocol-parser/src/encodeValue.ts @@ -4,7 +4,7 @@ import { encodeValueArgs } from "./encodeValueArgs"; export function encodeValue( valueSchema: TSchema, - value: SchemaToPrimitives + value: SchemaToPrimitives, ): Hex { const { staticData, encodedLengths, dynamicData } = encodeValueArgs(valueSchema, value); return concatHex([staticData, encodedLengths, dynamicData]); diff --git a/packages/protocol-parser/src/encodeValueArgs.ts b/packages/protocol-parser/src/encodeValueArgs.ts index 5100f4f753..bc0723f93f 100644 --- a/packages/protocol-parser/src/encodeValueArgs.ts +++ b/packages/protocol-parser/src/encodeValueArgs.ts @@ -13,7 +13,7 @@ import { encodeLengths } from "./encodeLengths"; export function encodeValueArgs( valueSchema: TSchema, - value: SchemaToPrimitives + value: SchemaToPrimitives, ): ValueArgs { const valueSchemaEntries = Object.entries(valueSchema); const staticFields = valueSchemaEntries.filter(([, type]) => isStaticAbiType(type)) as [string, StaticAbiType][]; @@ -23,7 +23,7 @@ export function encodeValueArgs( const encodedStaticValues = staticFields.map(([name, type]) => encodeField(type, value[name] as StaticPrimitiveType)); const encodedDynamicValues = dynamicFields.map(([name, type]) => - encodeField(type, value[name] as DynamicPrimitiveType) + encodeField(type, value[name] as DynamicPrimitiveType), ); const encodedLengths = encodeLengths(encodedDynamicValues); diff --git a/packages/protocol-parser/src/errors.ts b/packages/protocol-parser/src/errors.ts index 1071b89564..168d0eb93d 100644 --- a/packages/protocol-parser/src/errors.ts +++ b/packages/protocol-parser/src/errors.ts @@ -29,7 +29,7 @@ export class InvalidHexLengthForStaticFieldError extends MUDError { super( `Hex value "${value}" has length of ${value.length - 2}, but expected length of ${ staticAbiTypeToByteLength[abiType] * 2 - } for ${abiType} type.` + } for ${abiType} type.`, ); } } @@ -40,7 +40,7 @@ export class InvalidHexLengthForArrayFieldError extends MUDError { super( `Hex value "${value}" has length of ${value.length - 2}, but expected a multiple of ${ staticAbiTypeToByteLength[abiType] * 2 - } for ${abiType}[] type.` + } for ${abiType}[] type.`, ); } } @@ -50,7 +50,7 @@ export class SchemaStaticLengthMismatchError extends MUDError { constructor(schemaData: Hex, definedLength: number, summedLength: number) { super( `Schema "${schemaData}" static data length (${definedLength}) did not match the summed length of all static fields (${summedLength}). ` + - `Is \`staticAbiTypeToByteLength\` up to date with Solidity schema types?` + `Is \`staticAbiTypeToByteLength\` up to date with Solidity schema types?`, ); } } @@ -59,7 +59,7 @@ export class PackedCounterLengthMismatchError extends MUDError { override name = "PackedCounterLengthMismatchError"; constructor(packedCounterData: Hex, definedLength: bigint, summedLength: bigint) { super( - `PackedCounter "${packedCounterData}" total bytes length (${definedLength}) did not match the summed length of all field byte lengths (${summedLength}).` + `PackedCounter "${packedCounterData}" total bytes length (${definedLength}) did not match the summed length of all field byte lengths (${summedLength}).`, ); } } diff --git a/packages/protocol-parser/src/hexToPackedCounter.test.ts b/packages/protocol-parser/src/hexToPackedCounter.test.ts index 82537cc018..91e6a090e0 100644 --- a/packages/protocol-parser/src/hexToPackedCounter.test.ts +++ b/packages/protocol-parser/src/hexToPackedCounter.test.ts @@ -20,16 +20,16 @@ describe("hexToPackedCounter", () => { it("throws if schema hex data is not bytes32", () => { expect(() => hexToPackedCounter("0x01234")).toThrowErrorMatchingInlineSnapshot( - '"Hex value \\"0x01234\\" has length of 5, but expected length of 64 for a packed counter."' + '"Hex value \\"0x01234\\" has length of 5, but expected length of 64 for a packed counter."', ); }); it("throws if packed counter total byte length doesn't match summed byte length of fields", () => { expect(() => - hexToPackedCounter("0x0000000000000000000000000000400000000020000000002000000000000040") + hexToPackedCounter("0x0000000000000000000000000000400000000020000000002000000000000040"), ).toThrowErrorMatchingInlineSnapshot( // eslint-disable-next-line max-len - '"PackedCounter \\"0x0000000000000000000000000000400000000020000000002000000000000040\\" total bytes length (64) did not match the summed length of all field byte lengths (128)."' + '"PackedCounter \\"0x0000000000000000000000000000400000000020000000002000000000000040\\" total bytes length (64) did not match the summed length of all field byte lengths (128)."', ); }); }); diff --git a/packages/protocol-parser/src/hexToSchema.test.ts b/packages/protocol-parser/src/hexToSchema.test.ts index a73b132bbf..cbff4ee435 100644 --- a/packages/protocol-parser/src/hexToSchema.test.ts +++ b/packages/protocol-parser/src/hexToSchema.test.ts @@ -55,14 +55,14 @@ describe("hexToSchema", () => { it("throws if schema hex data is not bytes32", () => { expect(() => hexToSchema("0x002502045f2381c3c4c5")).toThrow( - 'Hex value "0x002502045f2381c3c4c5" has length of 20, but expected length of 64 for a schema.' + 'Hex value "0x002502045f2381c3c4c5" has length of 20, but expected length of 64 for a schema.', ); }); it("throws if schema static field lengths do not match", () => { expect(() => hexToSchema("0x002502045f2381c3c4c500000000000000000000000000000000000000000000")).toThrow( // eslint-disable-next-line max-len - 'Schema "0x002502045f2381c3c4c500000000000000000000000000000000000000000000" static data length (37) did not match the summed length of all static fields (36). Is `staticAbiTypeToByteLength` up to date with Solidity schema types?' + 'Schema "0x002502045f2381c3c4c500000000000000000000000000000000000000000000" static data length (37) did not match the summed length of all static fields (36). Is `staticAbiTypeToByteLength` up to date with Solidity schema types?', ); }); }); diff --git a/packages/protocol-parser/src/hexToSchema.ts b/packages/protocol-parser/src/hexToSchema.ts index ff16f1e5cc..b0b74211bb 100644 --- a/packages/protocol-parser/src/hexToSchema.ts +++ b/packages/protocol-parser/src/hexToSchema.ts @@ -28,7 +28,7 @@ export function hexToSchema(data: Hex): Schema { if (actualStaticDataLength !== staticDataLength) { console.warn( `Schema "${data}" static data length (${staticDataLength}) did not match the summed length of all static fields (${actualStaticDataLength}). ` + - `Is \`staticAbiTypeToByteLength\` up to date with Solidity schema types?` + `Is \`staticAbiTypeToByteLength\` up to date with Solidity schema types?`, ); throw new SchemaStaticLengthMismatchError(data, staticDataLength, actualStaticDataLength); } diff --git a/packages/protocol-parser/src/schemaToHex.test.ts b/packages/protocol-parser/src/schemaToHex.test.ts index 57e051e5fe..82860e7331 100644 --- a/packages/protocol-parser/src/schemaToHex.test.ts +++ b/packages/protocol-parser/src/schemaToHex.test.ts @@ -4,13 +4,13 @@ import { schemaToHex } from "./schemaToHex"; describe("schemaToHex", () => { it("converts schema to hex", () => { expect(schemaToHex({ staticFields: ["bool"], dynamicFields: [] })).toBe( - "0x0001010060000000000000000000000000000000000000000000000000000000" + "0x0001010060000000000000000000000000000000000000000000000000000000", ); expect(schemaToHex({ staticFields: ["bool"], dynamicFields: ["bool[]"] })).toBe( - "0x0001010160c20000000000000000000000000000000000000000000000000000" + "0x0001010160c20000000000000000000000000000000000000000000000000000", ); expect( - schemaToHex({ staticFields: ["bytes32", "int32"], dynamicFields: ["uint256[]", "address[]", "bytes", "string"] }) + schemaToHex({ staticFields: ["bytes32", "int32"], dynamicFields: ["uint256[]", "address[]", "bytes", "string"] }), ).toBe("0x002402045f2381c3c4c500000000000000000000000000000000000000000000"); }); }); diff --git a/packages/react/src/useComponentValue.ts b/packages/react/src/useComponentValue.ts index fecb60ede4..aa7a7bbd10 100644 --- a/packages/react/src/useComponentValue.ts +++ b/packages/react/src/useComponentValue.ts @@ -13,18 +13,18 @@ import { useEffect, useState } from "react"; export function useComponentValue( component: Component, entity: Entity | undefined, - defaultValue: ComponentValue + defaultValue: ComponentValue, ): ComponentValue; export function useComponentValue( component: Component, - entity: Entity | undefined + entity: Entity | undefined, ): ComponentValue | undefined; export function useComponentValue( component: Component, entity: Entity | undefined, - defaultValue?: ComponentValue + defaultValue?: ComponentValue, ) { const [value, setValue] = useState(entity != null ? getComponentValue(component, entity) : undefined); diff --git a/packages/react/src/useEntityQuery.test.ts b/packages/react/src/useEntityQuery.test.ts index 484a8e80a5..12811c388c 100644 --- a/packages/react/src/useEntityQuery.test.ts +++ b/packages/react/src/useEntityQuery.test.ts @@ -36,7 +36,7 @@ describe("useEntityQuery", () => { const { result } = renderHook(() => useEntityQuery([Has(Position)], { updateOnValueChange: false })); const { result: resultOnValueChange } = renderHook(() => - useEntityQuery([Has(Position)], { updateOnValueChange: true }) + useEntityQuery([Has(Position)], { updateOnValueChange: true }), ); expect(result.current.length).toBe(2); @@ -80,7 +80,7 @@ describe("useEntityQuery", () => { const { result } = renderHook(() => useEntityQuery([Has(Position)], { updateOnValueChange: false })); const { result: resultOnValueChange } = renderHook(() => - useEntityQuery([Has(Position)], { updateOnValueChange: true }) + useEntityQuery([Has(Position)], { updateOnValueChange: true }), ); expect(result.all).toHaveLength(2); diff --git a/packages/react/src/usePromise.ts b/packages/react/src/usePromise.ts index a53806d37d..2c3fbfa111 100644 --- a/packages/react/src/usePromise.ts +++ b/packages/react/src/usePromise.ts @@ -7,7 +7,7 @@ export type UsePromiseResult = PromiseSettledResult> | { status: " export function usePromise(promise: PromiseLike | null | undefined) { const promiseRef = useRef(promise); const [result, setResult] = useState>( - promise == null ? { status: "idle" } : { status: "pending" } + promise == null ? { status: "idle" } : { status: "pending" }, ); useEffect(() => { diff --git a/packages/recs/CHANGELOG.md b/packages/recs/CHANGELOG.md index 4de2c01b38..472da33f59 100644 --- a/packages/recs/CHANGELOG.md +++ b/packages/recs/CHANGELOG.md @@ -339,7 +339,7 @@ .pipe( map((block) => Number(block.timestamp) * 1000), // Map to timestamp in ms filter((blockTimestamp) => blockTimestamp !== clock.lastUpdateTime), // Ignore if the clock was already refreshed with this block - filter((blockTimestamp) => blockTimestamp !== clock.currentTime) // Ignore if the current local timestamp is correct + filter((blockTimestamp) => blockTimestamp !== clock.currentTime), // Ignore if the current local timestamp is correct ) .subscribe(clock.update); // Update the local clock ``` diff --git a/packages/recs/src/Component.ts b/packages/recs/src/Component.ts index 58a56e8047..ccc5d038a5 100644 --- a/packages/recs/src/Component.ts +++ b/packages/recs/src/Component.ts @@ -55,7 +55,7 @@ function getComponentName(component: Component) { export function defineComponent( world: World, schema: S, - options?: { id?: string; metadata?: M; indexed?: boolean } + options?: { id?: string; metadata?: M; indexed?: boolean }, ) { if (Object.keys(schema).length === 0) throw new Error("Component schema must have at least one key"); const id = options?.id ?? uuid(); @@ -86,7 +86,7 @@ export function setComponent( component: Component, entity: Entity, value: ComponentValue, - options: ComponentMutationOptions = {} + options: ComponentMutationOptions = {}, ) { const entitySymbol = getEntitySymbol(entity); const prevValue = getComponentValue(component, entity); @@ -110,7 +110,7 @@ export function setComponent( "for entity", entity, ". Existing keys: ", - Object.keys(component.values) + Object.keys(component.values), ); } } @@ -141,7 +141,7 @@ export function updateComponent( entity: Entity, value: Partial>, initialValue?: ComponentValue, - options: ComponentMutationOptions = {} + options: ComponentMutationOptions = {}, ) { const currentValue = getComponentValue(component, entity); if (currentValue === undefined) { @@ -163,7 +163,7 @@ export function updateComponent( export function removeComponent( component: Component, entity: Entity, - options: ComponentMutationOptions = {} + options: ComponentMutationOptions = {}, ) { const entitySymbol = getEntitySymbol(entity); const prevValue = getComponentValue(component, entity); @@ -184,7 +184,7 @@ export function removeComponent( component: Component, - entity: Entity + entity: Entity, ): boolean { const entitySymbol = getEntitySymbol(entity); const map = Object.values(component.values)[0]; @@ -201,7 +201,7 @@ export function hasComponent( */ export function getComponentValue( component: Component, - entity: Entity + entity: Entity, ): ComponentValue | undefined { const value: Record = {}; const entitySymbol = getEntitySymbol(entity); @@ -230,7 +230,7 @@ export function getComponentValue( */ export function getComponentValueStrict( component: Component, - entity: Entity + entity: Entity, ): ComponentValue { const value = getComponentValue(component, entity); if (!value) throw new Error(`No value for component ${getComponentName(component)} on entity ${entity}`); @@ -253,7 +253,7 @@ export function getComponentValueStrict( */ export function componentValueEquals( a?: Partial>, - b?: ComponentValue + b?: ComponentValue, ): boolean { if (!a && !b) return true; if (!a || !b) return false; @@ -276,7 +276,7 @@ export function componentValueEquals( */ export function withValue( component: Component, - value: ComponentValue + value: ComponentValue, ): [Component, ComponentValue] { return [component, value]; } @@ -290,7 +290,7 @@ export function withValue( */ export function getEntitiesWithValue( component: Component | Indexer, - value: Partial> + value: Partial>, ): Set { // Shortcut for indexers if (isIndexer(component) && isFullComponentValue(component, value)) { @@ -315,7 +315,7 @@ export function getEntitiesWithValue( * @returns Set of all entities in the given component. */ export function getComponentEntities( - component: Component + component: Component, ): IterableIterator { return component.entities(); } @@ -335,7 +335,7 @@ export function getComponentEntities( * @returns overridable component */ export function overridableComponent( - component: Component + component: Component, ): OverridableComponent { let nonce = 0; @@ -457,7 +457,7 @@ export function overridableComponent !overriddenEntityValues.get(getEntitySymbol(e.entity))), - map((update) => ({ ...update, component: overriddenComponent })) + map((update) => ({ ...update, component: overriddenComponent })), ) .subscribe(update$); @@ -475,7 +475,7 @@ export function clearLocalCache(component: Component, uniqueWorldIdentifier?: st // Note: Only proof of concept for now - use this only for component that do not update frequently export function createLocalCache( component: Component, - uniqueWorldIdentifier?: string + uniqueWorldIdentifier?: string, ): Component { const { world, update$, values } = component; const cacheId = getLocalCacheId(component as Component, uniqueWorldIdentifier); @@ -509,7 +509,7 @@ export function createLocalCache { numUpdates++; const encoded = JSON.stringify( - Object.entries(mapObject(values, (m) => [...m.entries()].map((e) => [getEntityString(e[0]), e[1]]))) + Object.entries(mapObject(values, (m) => [...m.entries()].map((e) => [getEntityString(e[0]), e[1]]))), ); localStorage.setItem(cacheId, encoded); if (numUpdates > 200) { @@ -520,7 +520,7 @@ export function createLocalCache( - component: Component + component: Component, ): Indexer { const valueToEntities = new Map>(); diff --git a/packages/recs/src/Query.spec.ts b/packages/recs/src/Query.spec.ts index b75f91b474..1c200a5d34 100644 --- a/packages/recs/src/Query.spec.ts +++ b/packages/recs/src/Query.spec.ts @@ -98,27 +98,27 @@ describe("Query", () => { expect(runQuery([HasValue(OwnedByEntity, { value: Player })])).toEqual(new Set([Depth1])); expect(runQuery([ProxyExpand(OwnedByEntity, 0), HasValue(OwnedByEntity, { value: Player })])).toEqual( - new Set([Depth1]) + new Set([Depth1]), ); expect(runQuery([ProxyExpand(OwnedByEntity, 1), HasValue(OwnedByEntity, { value: Player })])).toEqual( - new Set([Depth1, Depth2]) + new Set([Depth1, Depth2]), ); expect(runQuery([ProxyExpand(OwnedByEntity, 2), HasValue(OwnedByEntity, { value: Player })])).toEqual( - new Set([Depth1, Depth2, Depth3]) + new Set([Depth1, Depth2, Depth3]), ); expect(runQuery([ProxyExpand(OwnedByEntity, 3), HasValue(OwnedByEntity, { value: Player })])).toEqual( - new Set([Depth1, Depth2, Depth3, Depth4]) + new Set([Depth1, Depth2, Depth3, Depth4]), ); expect(runQuery([ProxyExpand(OwnedByEntity, 4), HasValue(OwnedByEntity, { value: Player })])).toEqual( - new Set([Depth1, Depth2, Depth3, Depth4, Depth5]) + new Set([Depth1, Depth2, Depth3, Depth4, Depth5]), ); expect( - runQuery([ProxyExpand(OwnedByEntity, Number.MAX_SAFE_INTEGER), HasValue(OwnedByEntity, { value: Player })]) + runQuery([ProxyExpand(OwnedByEntity, Number.MAX_SAFE_INTEGER), HasValue(OwnedByEntity, { value: Player })]), ).toEqual(new Set([Depth1, Depth2, Depth3, Depth4, Depth5])); }); @@ -132,8 +132,8 @@ describe("Query", () => { expect( runQuery( [ProxyRead(OwnedByEntity, 1), HasValue(Name, { name: "Alice" })], - new Set([Depth1, Depth2, Depth3]) // Provide an initial set of entities - ) + new Set([Depth1, Depth2, Depth3]), // Provide an initial set of entities + ), ).toEqual(new Set([Depth1])); expect( @@ -142,7 +142,7 @@ describe("Query", () => { HasValue(Name, { name: "Alice" }), // Get all entities with name Alice or owned by Alice ProxyExpand(OwnedByEntity, 0), // Turn off proxy expand NotValue(Name, { name: "Alice" }), // Filter Alice, only keep entities owned by Alice - ]) + ]), ).toEqual(new Set([Depth1])); expect( @@ -151,15 +151,15 @@ describe("Query", () => { HasValue(Name, { name: "Alice" }), // Get all child entities of Alice (including alice) ProxyExpand(OwnedByEntity, 0), // Turn off proxy expand NotValue(Name, { name: "Alice" }), // Filter Alice, only keep entities owned by Alice - ]) + ]), ).toEqual(new Set([Depth1, Depth2, Depth3, Depth4])); // Get all entities from the initial set [Depth3] that have an indirect owner called Alice expect( runQuery( [ProxyRead(OwnedByEntity, Number.MAX_SAFE_INTEGER), HasValue(Name, { name: "Alice" })], - new Set([Depth3]) // Provide an initial set of entities - ) + new Set([Depth3]), // Provide an initial set of entities + ), ).toEqual(new Set([Depth3])); // Get all entities that have an indirect owner called Alice @@ -171,8 +171,8 @@ describe("Query", () => { ProxyRead(OwnedByEntity, 0), NotValue(Name, { name: "Alice" }), ], - new Set([Player, Depth1, Depth2, Depth3, Depth4]) // Provide an initial set of entities - ) + new Set([Player, Depth1, Depth2, Depth3, Depth4]), // Provide an initial set of entities + ), ).toEqual(new Set([Depth1, Depth2, Depth3, Depth4])); // Get all entities from the initial set [Depth3] that have an indirect owner called Alice and their direct child @@ -183,8 +183,8 @@ describe("Query", () => { ProxyExpand(OwnedByEntity, 1), HasValue(Name, { name: "Alice" }), ], - new Set([Depth2]) // Provide an initial set of entities - ) + new Set([Depth2]), // Provide an initial set of entities + ), ).toEqual(new Set([Depth2, Depth3])); }); @@ -204,15 +204,15 @@ describe("Query", () => { createEntity(world, [withValue(Position, { x: 1, y: 1 })]); expect(runQuery([ProxyExpand(FromPrototype, 1), Has(CanMove), Not(Prototype)])).toEqual( - new Set([instance1, instance2]) + new Set([instance1, instance2]), ); expect(runQuery([Has(Position), ProxyRead(FromPrototype, 1), Has(CanMove)])).toEqual( - new Set([instance1, instance2]) + new Set([instance1, instance2]), ); expect(runQuery([ProxyRead(FromPrototype, 1), Has(Position), Has(CanMove)])).toEqual( - new Set([instance1, instance2]) + new Set([instance1, instance2]), ); }); @@ -287,7 +287,7 @@ describe("Query", () => { Has(CanMove), // ...have the CanMove component... ProxyRead(OwnedByEntity, Number.MAX_SAFE_INTEGER), // ...and for whose owner holds... NotValue(Name, { name: "Alice" }), // ...their name is not Alice - ]) + ]), ).toEqual(new Set([Instance3, Entity8])); }); @@ -343,14 +343,14 @@ describe("Query", () => { entity: entities[0], component: CanMove, value: [{ value: true }, undefined], - }) + }), ); expect(mock).toHaveBeenCalledWith( expect.objectContaining({ entity: entities[1], component: CanMove, value: [{ value: true }, undefined], - }) + }), ); expect(mock).toBeCalledTimes(2); @@ -360,7 +360,7 @@ describe("Query", () => { entity: entities[2], component: CanMove, value: [{ value: true }, undefined], - }) + }), ); expect(mock).toHaveBeenCalledTimes(3); }); @@ -388,7 +388,7 @@ describe("Query", () => { entity: entity1, component: CanMove, value: [undefined, { value: true }], - }) + }), ); removeComponent(CanMove, entity2); @@ -398,7 +398,7 @@ describe("Query", () => { entity: entity2, component: CanMove, value: [undefined, { value: true }], - }) + }), ); }); }); @@ -617,7 +617,7 @@ describe("Query", () => { const query1 = defineQuery( [ProxyRead(OwnedByEntity, 1), HasValue(Name, { name: "Alice" })], - { initialSet: new Set([Depth1, Depth2, Depth3]) } // Provide an initial set of entities + { initialSet: new Set([Depth1, Depth2, Depth3]) }, // Provide an initial set of entities ); query1.update$.subscribe(); @@ -639,7 +639,7 @@ describe("Query", () => { const query4 = defineQuery( [ProxyRead(OwnedByEntity, Number.MAX_SAFE_INTEGER), HasValue(Name, { name: "Alice" })], - { initialSet: new Set([Depth3]) } // Provide an initial set of entities + { initialSet: new Set([Depth3]) }, // Provide an initial set of entities ); query4.update$.subscribe(); @@ -650,7 +650,7 @@ describe("Query", () => { ProxyRead(OwnedByEntity, 0), NotValue(Name, { name: "Alice" }), ], - { initialSet: new Set([Player, Depth1, Depth2, Depth3, Depth4]) } // Provide an initial set of entities + { initialSet: new Set([Player, Depth1, Depth2, Depth3, Depth4]) }, // Provide an initial set of entities ); query5.update$.subscribe(); @@ -660,7 +660,7 @@ describe("Query", () => { ProxyExpand(OwnedByEntity, 1), HasValue(Name, { name: "Alice" }), ], - { initialSet: new Set([Depth2]) } // Provide an initial set of entities + { initialSet: new Set([Depth2]) }, // Provide an initial set of entities ); query6.update$.subscribe(); diff --git a/packages/recs/src/Query.ts b/packages/recs/src/Query.ts index b32c2e2563..2ebce7fa81 100644 --- a/packages/recs/src/Query.ts +++ b/packages/recs/src/Query.ts @@ -88,7 +88,7 @@ export function Not(component: Component): NotQueryFragment */ export function HasValue( component: Component, - value: Partial> + value: Partial>, ): HasValueQueryFragment { return { type: QueryFragmentType.HasValue, component, value }; } @@ -112,7 +112,7 @@ export function HasValue( */ export function NotValue( component: Component, - value: Partial> + value: Partial>, ): NotValueQueryFragment { return { type: QueryFragmentType.NotValue, component, value }; } @@ -199,7 +199,7 @@ function passesQueryFragment(entity: Entity, fragment: EntityQ * @returns True if the query fragment is positive, else false. */ function isPositiveFragment( - fragment: QueryFragment + fragment: QueryFragment, ): fragment is HasQueryFragment | HasValueQueryFragment { return fragment.type === QueryFragmentType.Has || fragment.type == QueryFragmentType.HasValue; } @@ -211,7 +211,7 @@ function isPositiveFragment( * @returns True if the query fragment is negative, else false. */ function isNegativeFragment( - fragment: QueryFragment + fragment: QueryFragment, ): fragment is NotQueryFragment | NotValueQueryFragment { return fragment.type === QueryFragmentType.Not || fragment.type == QueryFragmentType.NotValue; } @@ -253,7 +253,7 @@ function isBreakingPassState(passes: boolean, fragment: EntityQueryFragment( entity: Entity, fragment: EntityQueryFragment, - proxyRead: ProxyReadQueryFragment + proxyRead: ProxyReadQueryFragment, ): boolean | null { let proxyEntity = entity; let passes = false; @@ -288,7 +288,7 @@ function passesQueryFragmentProxy( export function getChildEntities( entity: Entity, component: Component<{ value: Type.Entity }>, - depth: number + depth: number, ): Set { if (depth === 0) return new Set(); @@ -416,7 +416,7 @@ export function runQuery(fragments: QueryFragment[], initialSet?: Set): */ export function defineQuery( fragments: QueryFragment[], - options?: { runOnInit?: boolean; initialSet?: Set } + options?: { runOnInit?: boolean; initialSet?: Set }, ): { update$: Observable; matching: ObservableSet; @@ -503,7 +503,7 @@ export function defineQuery( return { ...update, type: UpdateType.Enter }; } }), - filterNullish() + filterNullish(), ); return { @@ -521,7 +521,7 @@ export function defineQuery( */ export function defineUpdateQuery( fragments: QueryFragment[], - options?: { runOnInit?: boolean } + options?: { runOnInit?: boolean }, ): Observable { return defineQuery(fragments, options).update$.pipe(filter((e) => e.type === UpdateType.Update)); } @@ -535,7 +535,7 @@ export function defineUpdateQuery( */ export function defineEnterQuery( fragments: QueryFragment[], - options?: { runOnInit?: boolean } + options?: { runOnInit?: boolean }, ): Observable { return defineQuery(fragments, options).update$.pipe(filter((e) => e.type === UpdateType.Enter)); } @@ -549,7 +549,7 @@ export function defineEnterQuery( */ export function defineExitQuery( fragments: QueryFragment[], - options?: { runOnInit?: boolean } + options?: { runOnInit?: boolean }, ): Observable { return defineQuery(fragments, options).update$.pipe(filter((e) => e.type === UpdateType.Exit)); } diff --git a/packages/recs/src/System.spec.ts b/packages/recs/src/System.spec.ts index 2f872323f6..4c0a6680a3 100644 --- a/packages/recs/src/System.spec.ts +++ b/packages/recs/src/System.spec.ts @@ -100,13 +100,13 @@ describe("System", () => { expect(mock).toHaveBeenCalledTimes(1); expect(mock).toHaveBeenCalledWith( - expect.objectContaining({ entity: entity1, component: CanMove, value: [{ value: true }, undefined] }) + expect.objectContaining({ entity: entity1, component: CanMove, value: [{ value: true }, undefined] }), ); const entity2 = createEntity(world, [withValue(CanMove, { value: true })]); expect(mock).toHaveBeenCalledTimes(2); expect(mock).toHaveBeenCalledWith( - expect.objectContaining({ entity: entity2, component: CanMove, value: [{ value: true }, undefined] }) + expect.objectContaining({ entity: entity2, component: CanMove, value: [{ value: true }, undefined] }), ); }); @@ -126,13 +126,13 @@ describe("System", () => { expect(mock).toHaveBeenCalledTimes(1); expect(mock).toHaveBeenCalledWith( - expect.objectContaining({ entity: entity1, component: CanMove, value: [undefined, { value: true }] }) + expect.objectContaining({ entity: entity1, component: CanMove, value: [undefined, { value: true }] }), ); removeComponent(CanMove, entity2); expect(mock).toHaveBeenCalledTimes(2); expect(mock).toHaveBeenCalledWith( - expect.objectContaining({ entity: entity2, component: CanMove, value: [undefined, { value: true }] }) + expect.objectContaining({ entity: entity2, component: CanMove, value: [undefined, { value: true }] }), ); }); }); diff --git a/packages/recs/src/System.ts b/packages/recs/src/System.ts index eaf8d2b2a0..6f91498bd3 100644 --- a/packages/recs/src/System.ts +++ b/packages/recs/src/System.ts @@ -36,7 +36,7 @@ export function defineUpdateSystem( world: World, query: QueryFragment[], system: (update: ComponentUpdate) => void, - options: { runOnInit?: boolean } = { runOnInit: true } + options: { runOnInit?: boolean } = { runOnInit: true }, ) { defineRxSystem(world, defineUpdateQuery(query, options), system); } @@ -56,7 +56,7 @@ export function defineEnterSystem( world: World, query: QueryFragment[], system: (update: ComponentUpdate) => void, - options: { runOnInit?: boolean } = { runOnInit: true } + options: { runOnInit?: boolean } = { runOnInit: true }, ) { defineRxSystem(world, defineEnterQuery(query, options), system); } @@ -76,7 +76,7 @@ export function defineExitSystem( world: World, query: QueryFragment[], system: (update: ComponentUpdate) => void, - options: { runOnInit?: boolean } = { runOnInit: true } + options: { runOnInit?: boolean } = { runOnInit: true }, ) { defineRxSystem(world, defineExitQuery(query, options), system); } @@ -96,7 +96,7 @@ export function defineSystem( world: World, query: QueryFragment[], system: (update: ComponentUpdate & { type: UpdateType }) => void, - options: { runOnInit?: boolean } = { runOnInit: true } + options: { runOnInit?: boolean } = { runOnInit: true }, ) { defineRxSystem(world, defineQuery(query, options).update$, system); } @@ -116,7 +116,7 @@ export function defineComponentSystem( world: World, component: Component, system: (update: ComponentUpdate) => void, - options: { runOnInit?: boolean } = { runOnInit: true } + options: { runOnInit?: boolean } = { runOnInit: true }, ) { const initial$ = options?.runOnInit ? from(getComponentEntities(component)).pipe(toUpdateStream(component)) : EMPTY; defineRxSystem(world, concat(initial$, component.update$), system); @@ -135,7 +135,7 @@ export function defineSyncSystem( query: QueryFragment[], component: (entity: Entity) => Component, value: (entity: Entity) => ComponentValue, - options: { update?: boolean; runOnInit?: boolean } = { update: false, runOnInit: true } + options: { update?: boolean; runOnInit?: boolean } = { update: false, runOnInit: true }, ) { defineSystem( world, @@ -145,6 +145,6 @@ export function defineSyncSystem( if (type === UpdateType.Exit) removeComponent(component(entity), entity); if (options?.update && type === UpdateType.Update) setComponent(component(entity), entity, value(entity)); }, - options + options, ); } diff --git a/packages/recs/src/deprecated/createActionSystem.spec.ts b/packages/recs/src/deprecated/createActionSystem.spec.ts index b1d0c0653f..ac224b2261 100644 --- a/packages/recs/src/deprecated/createActionSystem.spec.ts +++ b/packages/recs/src/deprecated/createActionSystem.spec.ts @@ -177,7 +177,7 @@ describe("ActionSystem", () => { expect(runQuery([HasValue(Action, { on: settlement1 })])).toEqual(new Set([entity1])); expect(runQuery([HasValue(Action, { on: settlement2 })])).toEqual(new Set([entity2])); expect(runQuery([HasValue(Action, { state: ActionState.Requested })])).toEqual( - new Set([entity1, entity2, entity3]) + new Set([entity1, entity2, entity3]), ); }); diff --git a/packages/recs/src/deprecated/createActionSystem.ts b/packages/recs/src/deprecated/createActionSystem.ts index 1cbe367ac1..94b245fce7 100644 --- a/packages/recs/src/deprecated/createActionSystem.ts +++ b/packages/recs/src/deprecated/createActionSystem.ts @@ -15,7 +15,7 @@ export type ActionSystem = ReturnType; export function createActionSystem( world: World, txReduced$: Observable, - waitForTransaction?: (tx: string) => Promise + waitForTransaction?: (tx: string) => Promise, ) { // Action component const Action = defineActionComponent(world); @@ -40,7 +40,7 @@ export function createActionSystem( * @returns Components including pending updates */ function withOptimisticUpdates( - component: Component + component: Component, ): OverridableComponent { const optimisticComponent = componentsWithOptimisticUpdates[component.id] || overridableComponent(component); @@ -99,7 +99,7 @@ export function createActionSystem( // This subscriotion makes sure the action requirement is checked again every time // one of the referenced components changes or the pending updates map changes const subscription = merge( - ...Object.values(action.componentsWithOptimisticUpdates).map((c) => c.update$) + ...Object.values(action.componentsWithOptimisticUpdates).map((c) => c.update$), ).subscribe(() => checkRequirement(action)); checkRequirement(action); disposer.set(action.id, { dispose: () => subscription?.unsubscribe() }); diff --git a/packages/recs/src/deprecated/defineActionComponent.ts b/packages/recs/src/deprecated/defineActionComponent.ts index 6d73b4882e..3da5829a50 100644 --- a/packages/recs/src/deprecated/defineActionComponent.ts +++ b/packages/recs/src/deprecated/defineActionComponent.ts @@ -12,7 +12,7 @@ export function defineActionComponent(world: World) { overrides: Type.OptionalStringArray, txHash: Type.OptionalString, }, - { id: "Action" } + { id: "Action" }, ); return Action as Component, Metadata, T>; } diff --git a/packages/recs/src/deprecated/waitForActionCompletion.ts b/packages/recs/src/deprecated/waitForActionCompletion.ts index c271c29ce5..e7378bab57 100644 --- a/packages/recs/src/deprecated/waitForActionCompletion.ts +++ b/packages/recs/src/deprecated/waitForActionCompletion.ts @@ -5,7 +5,7 @@ import { waitForComponentValueIn } from "./waitForComponentValueIn"; export async function waitForActionCompletion( Action: ReturnType, - entity: Entity + entity: Entity, ): Promise { return waitForComponentValueIn(Action, entity, [ { state: ActionState.Cancelled }, diff --git a/packages/recs/src/deprecated/waitForComponentValueIn.ts b/packages/recs/src/deprecated/waitForComponentValueIn.ts index 97fba687aa..318649b381 100644 --- a/packages/recs/src/deprecated/waitForComponentValueIn.ts +++ b/packages/recs/src/deprecated/waitForComponentValueIn.ts @@ -6,7 +6,7 @@ import { Component, Metadata, Entity, ComponentValue, Schema } from "../types"; export function waitForComponentValueIn( component: Component, entity: Entity, - values: Partial>[] + values: Partial>[], ): Promise { const [resolve, , promise] = deferred(); @@ -19,13 +19,13 @@ export function waitForComponentValueIn( const value$ = component.update$.pipe( filter((update) => update.entity === entity), // Ignore updates of other entities - map((update) => update.value[0]) // Map the update to the current value + map((update) => update.value[0]), // Map the update to the current value ); const subscription = value$ .pipe( startWith(getComponentValue(component, entity)), - filter((currentValue) => Boolean(values.find((searchValue) => componentValueEquals(searchValue, currentValue)))) + filter((currentValue) => Boolean(values.find((searchValue) => componentValueEquals(searchValue, currentValue)))), ) .subscribe(() => { resolve(); diff --git a/packages/recs/src/utils.ts b/packages/recs/src/utils.ts index 4407acc17a..33989a7ec5 100644 --- a/packages/recs/src/utils.ts +++ b/packages/recs/src/utils.ts @@ -12,7 +12,7 @@ import { Component, ComponentUpdate, ComponentValue, Entity, Indexer, Schema } f */ export function isComponentUpdate( update: ComponentUpdate, - component: Component + component: Component, ): update is ComponentUpdate { return update.component === component; } @@ -62,7 +62,7 @@ export function isIndexer(c: Component | Indexer): c is */ export function isFullComponentValue( component: Component, - value: Partial> + value: Partial>, ): value is ComponentValue { return Object.keys(component.schema).every((key) => key in value); } diff --git a/packages/schema-type/src/typescript/arrayAbiTypes.ts b/packages/schema-type/src/typescript/arrayAbiTypes.ts index 76c7d69673..00dc9a733c 100644 --- a/packages/schema-type/src/typescript/arrayAbiTypes.ts +++ b/packages/schema-type/src/typescript/arrayAbiTypes.ts @@ -11,7 +11,7 @@ export function isArrayAbiType(abiType: string): } export function arrayAbiTypeToStaticAbiType( - abiType: T + abiType: T, ): ArrayAbiTypeToStaticAbiType { return abiType.replace(arrayAbiTypePattern, "") as ArrayAbiTypeToStaticAbiType; } diff --git a/packages/schema-type/src/typescript/deprecated/mappings/AbiTypeToPrimitiveType.ts b/packages/schema-type/src/typescript/deprecated/mappings/AbiTypeToPrimitiveType.ts index 02982cc2a1..13c9b7c977 100644 --- a/packages/schema-type/src/typescript/deprecated/mappings/AbiTypeToPrimitiveType.ts +++ b/packages/schema-type/src/typescript/deprecated/mappings/AbiTypeToPrimitiveType.ts @@ -8,5 +8,5 @@ export type AbiTypeToPrimitiveType = T extends `${infer Static ? StaticAbiTypeToPrimitiveType[] : never : T extends AbiType - ? StaticAbiTypeToPrimitiveType - : never; + ? StaticAbiTypeToPrimitiveType + : never; diff --git a/packages/schema-type/src/typescript/deprecated/mappings/AbiTypeToSchemaType.ts b/packages/schema-type/src/typescript/deprecated/mappings/AbiTypeToSchemaType.ts index fb7f484ad9..9e0d93640a 100644 --- a/packages/schema-type/src/typescript/deprecated/mappings/AbiTypeToSchemaType.ts +++ b/packages/schema-type/src/typescript/deprecated/mappings/AbiTypeToSchemaType.ts @@ -2,5 +2,5 @@ import { SchemaTypeToAbiType } from "./SchemaTypeToAbiType"; import { SchemaType } from "../SchemaType"; export const AbiTypeToSchemaType = Object.fromEntries( - Object.entries(SchemaTypeToAbiType).map(([schemaType, abiType]) => [abiType, parseInt(schemaType) as SchemaType]) + Object.entries(SchemaTypeToAbiType).map(([schemaType, abiType]) => [abiType, parseInt(schemaType) as SchemaType]), ) satisfies Record; diff --git a/packages/schema-type/src/typescript/deprecated/types/StaticAbiTypes.ts b/packages/schema-type/src/typescript/deprecated/types/StaticAbiTypes.ts index d4b3506c13..db658108b5 100644 --- a/packages/schema-type/src/typescript/deprecated/types/StaticAbiTypes.ts +++ b/packages/schema-type/src/typescript/deprecated/types/StaticAbiTypes.ts @@ -6,5 +6,5 @@ import { StaticSchemaType } from "./StaticSchemaType"; export type StaticAbiType = (typeof SchemaTypeToAbiType)[StaticSchemaType]; export const StaticAbiTypes = AbiTypes.filter( - (abiType) => getStaticByteLength(AbiTypeToSchemaType[abiType]) > 0 + (abiType) => getStaticByteLength(AbiTypeToSchemaType[abiType]) > 0, ) as StaticAbiType[]; diff --git a/packages/schema-type/src/typescript/schemaAbiTypes.test.ts b/packages/schema-type/src/typescript/schemaAbiTypes.test.ts index 6d23754108..df77fed6f8 100644 --- a/packages/schema-type/src/typescript/schemaAbiTypes.test.ts +++ b/packages/schema-type/src/typescript/schemaAbiTypes.test.ts @@ -9,7 +9,7 @@ describe("schemaAbiTypes", () => { const soliditySchemaTypes = matches?.[1].replace(/\s/g, "").split(",") ?? []; const soliditySchemaTypesAsAbiTypes = soliditySchemaTypes.map((soliditySchemaType) => - soliditySchemaType.replace(/_ARRAY$/, "[]").toLowerCase() + soliditySchemaType.replace(/_ARRAY$/, "[]").toLowerCase(), ); expect(soliditySchemaTypesAsAbiTypes).toStrictEqual(schemaAbiTypes); diff --git a/packages/schema-type/src/typescript/utils.ts b/packages/schema-type/src/typescript/utils.ts index 65d1a05c65..543d6fd6d9 100644 --- a/packages/schema-type/src/typescript/utils.ts +++ b/packages/schema-type/src/typescript/utils.ts @@ -3,21 +3,22 @@ import { Hex } from "viem"; export type TupleSplit = O["length"] extends N ? [O, T] : T extends readonly [infer F, ...infer R] - ? TupleSplit - : [O, T]; + ? TupleSplit + : [O, T]; -export type LiteralToBroad = T extends Readonly> - ? readonly LiteralToBroad[] - : T extends Array - ? LiteralToBroad[] - : T extends number - ? number - : T extends bigint - ? bigint - : T extends Hex - ? Hex - : T extends boolean - ? boolean - : T extends string - ? string - : never; +export type LiteralToBroad = + T extends Readonly> + ? readonly LiteralToBroad[] + : T extends Array + ? LiteralToBroad[] + : T extends number + ? number + : T extends bigint + ? bigint + : T extends Hex + ? Hex + : T extends boolean + ? boolean + : T extends string + ? string + : never; diff --git a/packages/services/protobuf/ts/faucet/faucet.ts b/packages/services/protobuf/ts/faucet/faucet.ts index 0bdb04e62f..c60dc04035 100644 --- a/packages/services/protobuf/ts/faucet/faucet.ts +++ b/packages/services/protobuf/ts/faucet/faucet.ts @@ -231,7 +231,7 @@ export const FaucetStore = { } return acc; }, - {} + {}, ); message.usernameToAddress = Object.entries(object.usernameToAddress ?? {}).reduce<{ [key: string]: string }>( (acc, [key, value]) => { @@ -240,7 +240,7 @@ export const FaucetStore = { } return acc; }, - {} + {}, ); message.latestDrip = Object.entries(object.latestDrip ?? {}).reduce<{ [key: string]: number }>( (acc, [key, value]) => { @@ -249,7 +249,7 @@ export const FaucetStore = { } return acc; }, - {} + {}, ); message.totalDripCount = object.totalDripCount ?? 0; return message; @@ -1092,24 +1092,24 @@ export interface FaucetServiceImplementation { dripVerifyTweet(request: DripRequest, context: CallContext & CallContextExt): Promise>; timeUntilDrip( request: DripRequest, - context: CallContext & CallContextExt + context: CallContext & CallContextExt, ): Promise>; getLinkedTwitters( request: GetLinkedTwittersRequest, - context: CallContext & CallContextExt + context: CallContext & CallContextExt, ): Promise>; getLinkedTwitterForAddress( request: LinkedTwitterForAddressRequest, - context: CallContext & CallContextExt + context: CallContext & CallContextExt, ): Promise>; getLinkedAddressForTwitter( request: LinkedAddressForTwitterRequest, - context: CallContext & CallContextExt + context: CallContext & CallContextExt, ): Promise>; /** Admin utility endpoints for modifying state. Requires a signature with faucet private key. */ setLinkedTwitter( request: SetLinkedTwitterRequest, - context: CallContext & CallContextExt + context: CallContext & CallContextExt, ): Promise>; } @@ -1119,24 +1119,24 @@ export interface FaucetServiceClient { dripVerifyTweet(request: DeepPartial, options?: CallOptions & CallOptionsExt): Promise; timeUntilDrip( request: DeepPartial, - options?: CallOptions & CallOptionsExt + options?: CallOptions & CallOptionsExt, ): Promise; getLinkedTwitters( request: DeepPartial, - options?: CallOptions & CallOptionsExt + options?: CallOptions & CallOptionsExt, ): Promise; getLinkedTwitterForAddress( request: DeepPartial, - options?: CallOptions & CallOptionsExt + options?: CallOptions & CallOptionsExt, ): Promise; getLinkedAddressForTwitter( request: DeepPartial, - options?: CallOptions & CallOptionsExt + options?: CallOptions & CallOptionsExt, ): Promise; /** Admin utility endpoints for modifying state. Requires a signature with faucet private key. */ setLinkedTwitter( request: DeepPartial, - options?: CallOptions & CallOptionsExt + options?: CallOptions & CallOptionsExt, ): Promise; } @@ -1164,12 +1164,12 @@ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefi export type DeepPartial = T extends Builtin ? T : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } - : Partial; + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; function longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { diff --git a/packages/services/ts/faucet/createFaucetService.ts b/packages/services/ts/faucet/createFaucetService.ts index f82eb82c22..ea0b1c565b 100644 --- a/packages/services/ts/faucet/createFaucetService.ts +++ b/packages/services/ts/faucet/createFaucetService.ts @@ -8,7 +8,7 @@ import { FromTsProtoServiceDefinition } from "nice-grpc-web/lib/service-definiti * @returns FaucetServiceClient */ export function createFaucetService( - url: string + url: string, ): RawClient> { return createClient(FaucetServiceDefinition, createChannel(url)); } diff --git a/packages/solhint-plugin-mud/src/rules/NoMsgSender.ts b/packages/solhint-plugin-mud/src/rules/NoMsgSender.ts index 1c81e6ef51..fb3751c4dd 100644 --- a/packages/solhint-plugin-mud/src/rules/NoMsgSender.ts +++ b/packages/solhint-plugin-mud/src/rules/NoMsgSender.ts @@ -29,7 +29,7 @@ export class NoMsgSender implements SolhintRule { this.reporter.error( node, this.ruleId, - `Systems and their libraries should use "_msgSender()" or "_world()" instead of "msg.sender".` + `Systems and their libraries should use "_msgSender()" or "_world()" instead of "msg.sender".`, ); } } diff --git a/packages/solhint-plugin-mud/src/rules/SystemFileName.ts b/packages/solhint-plugin-mud/src/rules/SystemFileName.ts index 2e8706fbba..337cebb1d5 100644 --- a/packages/solhint-plugin-mud/src/rules/SystemFileName.ts +++ b/packages/solhint-plugin-mud/src/rules/SystemFileName.ts @@ -46,7 +46,7 @@ export class SystemFileName implements SolhintRule { this.reporter.error( node, this.ruleId, - `System file must contain a contract with a matching name "${expectedContractName}"` + `System file must contain a contract with a matching name "${expectedContractName}"`, ); } } diff --git a/packages/store-indexer/CHANGELOG.md b/packages/store-indexer/CHANGELOG.md index 10ee41a923..f5b485fae7 100644 --- a/packages/store-indexer/CHANGELOG.md +++ b/packages/store-indexer/CHANGELOG.md @@ -594,7 +594,7 @@ .pipe( map((block) => Number(block.timestamp) * 1000), // Map to timestamp in ms filter((blockTimestamp) => blockTimestamp !== clock.lastUpdateTime), // Ignore if the clock was already refreshed with this block - filter((blockTimestamp) => blockTimestamp !== clock.currentTime) // Ignore if the current local timestamp is correct + filter((blockTimestamp) => blockTimestamp !== clock.currentTime), // Ignore if the current local timestamp is correct ) .subscribe(clock.update); // Update the local clock ``` diff --git a/packages/store-indexer/bin/parseEnv.ts b/packages/store-indexer/bin/parseEnv.ts index 19be86cf8f..5a001a61a3 100644 --- a/packages/store-indexer/bin/parseEnv.ts +++ b/packages/store-indexer/bin/parseEnv.ts @@ -23,7 +23,7 @@ export const indexerEnvSchema = z.intersection( RPC_HTTP_URL: z.string().optional(), RPC_WS_URL: z.string(), }), - ]) + ]), ); export function parseEnv(envSchema: TSchema): z.infer { diff --git a/packages/store-indexer/bin/postgres-decoded-indexer.ts b/packages/store-indexer/bin/postgres-decoded-indexer.ts index 11339892ea..70bce8a446 100644 --- a/packages/store-indexer/bin/postgres-decoded-indexer.ts +++ b/packages/store-indexer/bin/postgres-decoded-indexer.ts @@ -22,8 +22,8 @@ const env = parseEnv( HEALTHCHECK_HOST: z.string().optional(), HEALTHCHECK_PORT: z.coerce.number().optional(), SENTRY_DSN: z.string().optional(), - }) - ) + }), + ), ); const transports: Transport[] = [ @@ -81,9 +81,10 @@ let isCaughtUp = false; combineLatest([latestBlockNumber$, storedBlockLogs$]) .pipe( filter( - ([latestBlockNumber, { blockNumber: lastBlockNumberProcessed }]) => latestBlockNumber === lastBlockNumberProcessed + ([latestBlockNumber, { blockNumber: lastBlockNumberProcessed }]) => + latestBlockNumber === lastBlockNumberProcessed, ), - first() + first(), ) .subscribe(() => { isCaughtUp = true; @@ -104,12 +105,12 @@ if (env.HEALTHCHECK_HOST != null || env.HEALTHCHECK_PORT != null) { server.use( healthcheck({ isReady: () => isCaughtUp, - }) + }), ); server.use(helloWorld()); server.listen({ host: env.HEALTHCHECK_HOST, port: env.HEALTHCHECK_PORT }); console.log( - `postgres indexer healthcheck server listening on http://${env.HEALTHCHECK_HOST}:${env.HEALTHCHECK_PORT}` + `postgres indexer healthcheck server listening on http://${env.HEALTHCHECK_HOST}:${env.HEALTHCHECK_PORT}`, ); } diff --git a/packages/store-indexer/bin/postgres-frontend.ts b/packages/store-indexer/bin/postgres-frontend.ts index 037a53cddf..f95d80919c 100644 --- a/packages/store-indexer/bin/postgres-frontend.ts +++ b/packages/store-indexer/bin/postgres-frontend.ts @@ -20,8 +20,8 @@ const env = parseEnv( z.object({ DATABASE_URL: z.string(), SENTRY_DSN: z.string().optional(), - }) - ) + }), + ), ); const database = postgres(env.DATABASE_URL, { prepare: false }); @@ -44,7 +44,7 @@ server.use( createContext: async () => ({ queryAdapter: await createQueryAdapter(drizzle(database)), }), - }) + }), ); server.listen({ host: env.HOST, port: env.PORT }); diff --git a/packages/store-indexer/bin/postgres-indexer.ts b/packages/store-indexer/bin/postgres-indexer.ts index 3bcffa9803..28b0ee2482 100644 --- a/packages/store-indexer/bin/postgres-indexer.ts +++ b/packages/store-indexer/bin/postgres-indexer.ts @@ -18,8 +18,8 @@ const env = parseEnv( DATABASE_URL: z.string(), HEALTHCHECK_HOST: z.string().optional(), HEALTHCHECK_PORT: z.coerce.number().optional(), - }) - ) + }), + ), ); const transports: Transport[] = [ @@ -82,9 +82,10 @@ let isCaughtUp = false; combineLatest([latestBlockNumber$, storedBlockLogs$]) .pipe( filter( - ([latestBlockNumber, { blockNumber: lastBlockNumberProcessed }]) => latestBlockNumber === lastBlockNumberProcessed + ([latestBlockNumber, { blockNumber: lastBlockNumberProcessed }]) => + latestBlockNumber === lastBlockNumberProcessed, ), - first() + first(), ) .subscribe(() => { isCaughtUp = true; @@ -103,12 +104,12 @@ if (env.HEALTHCHECK_HOST != null || env.HEALTHCHECK_PORT != null) { server.use( healthcheck({ isReady: () => isCaughtUp, - }) + }), ); server.use(helloWorld()); server.listen({ host: env.HEALTHCHECK_HOST, port: env.HEALTHCHECK_PORT }); console.log( - `postgres indexer healthcheck server listening on http://${env.HEALTHCHECK_HOST}:${env.HEALTHCHECK_PORT}` + `postgres indexer healthcheck server listening on http://${env.HEALTHCHECK_HOST}:${env.HEALTHCHECK_PORT}`, ); } diff --git a/packages/store-indexer/bin/sqlite-indexer.ts b/packages/store-indexer/bin/sqlite-indexer.ts index 416dc8d8ef..a544fea7d6 100644 --- a/packages/store-indexer/bin/sqlite-indexer.ts +++ b/packages/store-indexer/bin/sqlite-indexer.ts @@ -26,8 +26,8 @@ const env = parseEnv( z.object({ SQLITE_FILENAME: z.string().default("indexer.db"), SENTRY_DSN: z.string().optional(), - }) - ) + }), + ), ); const transports: Transport[] = [ @@ -60,7 +60,7 @@ try { currentChainState.schemaVersion, "to", schemaVersion, - "recreating database" + "recreating database", ); fs.truncateSync(env.SQLITE_FILENAME); } else if (currentChainState.lastUpdatedBlockNumber != null) { @@ -85,9 +85,10 @@ let isCaughtUp = false; combineLatest([latestBlockNumber$, storedBlockLogs$]) .pipe( filter( - ([latestBlockNumber, { blockNumber: lastBlockNumberProcessed }]) => latestBlockNumber === lastBlockNumberProcessed + ([latestBlockNumber, { blockNumber: lastBlockNumberProcessed }]) => + latestBlockNumber === lastBlockNumberProcessed, ), - first() + first(), ) .subscribe(() => { isCaughtUp = true; @@ -104,7 +105,7 @@ server.use(cors()); server.use( healthcheck({ isReady: () => isCaughtUp, - }) + }), ); server.use(helloWorld()); server.use(apiRoutes(database)); @@ -116,7 +117,7 @@ server.use( createContext: async () => ({ queryAdapter: await createQueryAdapter(database), }), - }) + }), ); server.listen({ host: env.HOST, port: env.PORT }); diff --git a/packages/store-indexer/src/koa-middleware/sentry.ts b/packages/store-indexer/src/koa-middleware/sentry.ts index ea59ea7492..e8999dffcd 100644 --- a/packages/store-indexer/src/koa-middleware/sentry.ts +++ b/packages/store-indexer/src/koa-middleware/sentry.ts @@ -31,8 +31,8 @@ export function requestHandler(): Koa.Middleware { include: { user: false, }, - }) - ) + }), + ), ); await next(); }); diff --git a/packages/store-indexer/src/postgres/apiRoutes.ts b/packages/store-indexer/src/postgres/apiRoutes.ts index 383700fc5f..66f5d63397 100644 --- a/packages/store-indexer/src/postgres/apiRoutes.ts +++ b/packages/store-indexer/src/postgres/apiRoutes.ts @@ -38,8 +38,8 @@ export function apiRoutes(database: Sql): Middleware { ctx.body = "no logs found"; error( `no logs found for chainId ${options.chainId}, address ${options.address}, filters ${JSON.stringify( - options.filters - )}` + options.filters, + )}`, ); return; } diff --git a/packages/store-indexer/src/postgres/deprecated/getLogs.ts b/packages/store-indexer/src/postgres/deprecated/getLogs.ts index e6138fef2e..a883e9b011 100644 --- a/packages/store-indexer/src/postgres/deprecated/getLogs.ts +++ b/packages/store-indexer/src/postgres/deprecated/getLogs.ts @@ -20,7 +20,7 @@ export async function getLogs( readonly chainId: number; readonly address?: Hex; readonly filters?: readonly SyncFilter[]; - } + }, ): Promise<{ blockNumber: bigint; logs: (StorageAdapterLog & { eventName: "Store_SetRecord" })[] }> { const benchmark = createBenchmark("drizzleGetLogs"); @@ -30,12 +30,12 @@ export async function getLogs( address != null ? eq(tables.recordsTable.address, address) : undefined, eq(tables.recordsTable.tableId, filter.tableId), filter.key0 != null ? eq(tables.recordsTable.key0, filter.key0) : undefined, - filter.key1 != null ? eq(tables.recordsTable.key1, filter.key1) : undefined - ) + filter.key1 != null ? eq(tables.recordsTable.key1, filter.key1) : undefined, + ), ) : address != null - ? [eq(tables.recordsTable.address, address)] - : []; + ? [eq(tables.recordsTable.address, address)] + : []; benchmark("parse config"); // Query for the block number that the indexer (i.e. chain) is at, in case the @@ -63,7 +63,7 @@ export async function getLogs( .from(tables.recordsTable) .where(or(...conditions)) .orderBy( - asc(tables.recordsTable.blockNumber) + asc(tables.recordsTable.blockNumber), // TODO: add logIndex (https://github.com/latticexyz/mud/issues/1979) ); benchmark("query records"); diff --git a/packages/store-indexer/src/postgres/queryLogs.ts b/packages/store-indexer/src/postgres/queryLogs.ts index b887a7a026..037f3bdc7b 100644 --- a/packages/store-indexer/src/postgres/queryLogs.ts +++ b/packages/store-indexer/src/postgres/queryLogs.ts @@ -26,16 +26,16 @@ export function queryLogs(sql: Sql, opts: z.infer): PendingQuery hex columns via custom types: https://github.com/porsager/postgres#custom-types diff --git a/packages/store-indexer/src/postgres/recordToLog.ts b/packages/store-indexer/src/postgres/recordToLog.ts index 097a7657f7..b74ec281d3 100644 --- a/packages/store-indexer/src/postgres/recordToLog.ts +++ b/packages/store-indexer/src/postgres/recordToLog.ts @@ -3,7 +3,7 @@ import { decodeDynamicField } from "@latticexyz/protocol-parser"; import { RecordData } from "./common"; export function recordToLog( - record: Omit + record: Omit, ): StorageAdapterLog & { eventName: "Store_SetRecord" } { return { address: record.address, diff --git a/packages/store-indexer/src/sqlite/getTablesWithRecords.ts b/packages/store-indexer/src/sqlite/getTablesWithRecords.ts index 987de4e641..10093c99ef 100644 --- a/packages/store-indexer/src/sqlite/getTablesWithRecords.ts +++ b/packages/store-indexer/src/sqlite/getTablesWithRecords.ts @@ -20,7 +20,7 @@ export function getTablesWithRecords( readonly chainId: number; readonly address?: Hex; readonly filters?: readonly SyncFilter[]; - } + }, ): { blockNumber: bigint | null; tables: readonly TableWithRecords[] } { const metadata = database .select() @@ -44,7 +44,7 @@ export function getTablesWithRecords( .from(sqliteTable) .where(eq(sqliteTable.__isDeleted, false)) .orderBy( - asc(sqliteTable.__lastUpdatedBlockNumber) + asc(sqliteTable.__lastUpdatedBlockNumber), // TODO: add logIndex (https://github.com/latticexyz/mud/issues/1979) ) .all(); @@ -56,7 +56,7 @@ export function getTablesWithRecords( (filter) => filter.tableId === table.tableId && (filter.key0 == null || filter.key0 === keyTuple[0]) && - (filter.key1 == null || filter.key1 === keyTuple[1]) + (filter.key1 == null || filter.key1 === keyTuple[1]), ); }); return { diff --git a/packages/store-sync/src/common.ts b/packages/store-sync/src/common.ts index 05aad07606..f0d05866e1 100644 --- a/packages/store-sync/src/common.ts +++ b/packages/store-sync/src/common.ts @@ -13,7 +13,7 @@ export const storeTables = resolveConfig(storeConfig).tables; export const worldTables = resolveConfig(worldConfig).tables; export const internalTableIds = [...Object.values(storeTables), ...Object.values(worldTables)].map( - (table) => table.tableId + (table) => table.tableId, ); export type ChainId = number; diff --git a/packages/store-sync/src/createStoreSync.ts b/packages/store-sync/src/createStoreSync.ts index 6b0fe1a628..ae2cf619be 100644 --- a/packages/store-sync/src/createStoreSync.ts +++ b/packages/store-sync/src/createStoreSync.ts @@ -73,7 +73,7 @@ export async function createStoreSync (filter) => filter.tableId === log.args.tableId && (filter.key0 == null || filter.key0 === log.args.keyTuple[0]) && - (filter.key1 == null || filter.key1 === log.args.keyTuple[1]) + (filter.key1 == null || filter.key1 === log.args.keyTuple[1]), ) : undefined; @@ -120,7 +120,7 @@ export async function createStoreSync return of(undefined); }), - shareReplay(1) + shareReplay(1), ); const storedInitialBlockLogs$ = initialBlockLogs$.pipe( @@ -168,13 +168,13 @@ export async function createStoreSync return { blockNumber, logs }; }), - shareReplay(1) + shareReplay(1), ); const startBlock$ = initialBlockLogs$.pipe( map((block) => bigIntMax(block?.blockNumber ?? 0n, initialStartBlock)), // TODO: if start block is still 0, find via deploy event - tap((startBlock) => debug("starting sync from block", startBlock)) + tap((startBlock) => debug("starting sync from block", startBlock)), ); const latestBlock$ = createBlockStream({ publicClient, blockTag: followBlockTag }).pipe(shareReplay(1)); @@ -183,7 +183,7 @@ export async function createStoreSync tap((blockNumber) => { debug("on block number", blockNumber, "for", followBlockTag, "block tag"); }), - shareReplay(1) + shareReplay(1), ); let startBlock: bigint | null = null; @@ -238,7 +238,7 @@ export async function createStoreSync } } }), - share() + share(), ); const storedBlockLogs$ = concat(storedInitialBlockLogs$, storedBlock$).pipe(share()); @@ -249,10 +249,10 @@ export async function createStoreSync const recentBlocks$ = storedBlockLogs$.pipe( scan( (recentBlocks, block) => [block, ...recentBlocks].slice(0, recentBlocksWindow), - [] + [], ), filter((recentBlocks) => recentBlocks.length > 0), - shareReplay(1) + shareReplay(1), ); // TODO: move to its own file so we can test it, have its own debug instance, etc. @@ -278,7 +278,7 @@ export async function createStoreSync throw error; } }), - tap((result) => debug("has tx?", tx, result)) + tap((result) => debug("has tx?", tx, result)), ); await firstValueFrom(hasTransaction$.pipe(filter(identity))); diff --git a/packages/store-sync/src/flattenSchema.ts b/packages/store-sync/src/flattenSchema.ts index 7cc9a92d90..dd2a61d019 100644 --- a/packages/store-sync/src/flattenSchema.ts +++ b/packages/store-sync/src/flattenSchema.ts @@ -2,7 +2,7 @@ import { mapObject } from "@latticexyz/common/utils"; import { ValueSchema } from "@latticexyz/store"; export function flattenSchema( - schema: schema + schema: schema, ): { readonly [k in keyof schema]: schema[k]["type"] } { return mapObject(schema, (value) => value.type); } diff --git a/packages/store-sync/src/getSnapshot.ts b/packages/store-sync/src/getSnapshot.ts index c79f2df255..f78d6e8cf0 100644 --- a/packages/store-sync/src/getSnapshot.ts +++ b/packages/store-sync/src/getSnapshot.ts @@ -63,7 +63,7 @@ export async function getSnapshot({ const result = await trpcIndexer.findAll.query({ chainId, address, filters }); // warn after we fetch from old endpoint so we know that the indexer is accessible console.warn( - `The indexer at ${indexerUrl} appears to be outdated. Consider upgrading to a recent version for better performance.` + `The indexer at ${indexerUrl} appears to be outdated. Consider upgrading to a recent version for better performance.`, ); // if the indexer returns no block number, it hasn't indexed this chain diff --git a/packages/store-sync/src/indexer-client/input.ts b/packages/store-sync/src/indexer-client/input.ts index 14107f1faa..643c88bf11 100644 --- a/packages/store-sync/src/indexer-client/input.ts +++ b/packages/store-sync/src/indexer-client/input.ts @@ -10,7 +10,7 @@ export const input = z.object({ tableId: z.string().refine(isHex), key0: z.string().refine(isHex).optional(), key1: z.string().refine(isHex).optional(), - }) + }), ) .default([]), }); diff --git a/packages/store-sync/src/isTableRegistrationLog.ts b/packages/store-sync/src/isTableRegistrationLog.ts index 8f6b6148d6..e7f9ac6acf 100644 --- a/packages/store-sync/src/isTableRegistrationLog.ts +++ b/packages/store-sync/src/isTableRegistrationLog.ts @@ -4,7 +4,7 @@ import { StorageAdapterLog, storeTables } from "./common"; * @internal */ export function isTableRegistrationLog( - log: StorageAdapterLog + log: StorageAdapterLog, ): log is StorageAdapterLog & { eventName: "Store_SetRecord" } { return log.eventName === "Store_SetRecord" && log.args.tableId === storeTables.Tables.tableId; } diff --git a/packages/store-sync/src/logToTable.test.ts b/packages/store-sync/src/logToTable.test.ts index f50e813bb5..0feb33c786 100644 --- a/packages/store-sync/src/logToTable.test.ts +++ b/packages/store-sync/src/logToTable.test.ts @@ -18,7 +18,7 @@ describe("logToTable", () => { // eslint-disable-next-line max-len "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000077461626c654964000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000000b6669656c644c61796f757400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000096b6579536368656d610000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b76616c7565536368656d610000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012616269456e636f6465644b65794e616d657300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014616269456e636f6465644669656c644e616d6573000000000000000000000000", }, - }) + }), ).toMatchInlineSnapshot(` { "address": "0x3Aa5ebB10DC797CAC828524e59A333d0A371443c", diff --git a/packages/store-sync/src/logToTable.ts b/packages/store-sync/src/logToTable.ts index 0d50dce3aa..c69e616186 100644 --- a/packages/store-sync/src/logToTable.ts +++ b/packages/store-sync/src/logToTable.ts @@ -17,7 +17,7 @@ export function logToTable(log: StorageAdapterLog & { eventName: "Store_SetRecor const value = decodeValue( // TODO: remove cast when we have strong types for user types schemasTable.valueSchema as ValueSchema, - concatHex([log.args.staticData, log.args.encodedLengths, log.args.dynamicData]) + concatHex([log.args.staticData, log.args.encodedLengths, log.args.dynamicData]), ); // TODO: remove cast when we have strong types for user types diff --git a/packages/store-sync/src/postgres-decoded/buildTable.test.ts b/packages/store-sync/src/postgres-decoded/buildTable.test.ts index f20f846392..b6369772f5 100644 --- a/packages/store-sync/src/postgres-decoded/buildTable.test.ts +++ b/packages/store-sync/src/postgres-decoded/buildTable.test.ts @@ -22,7 +22,7 @@ describe("buildTable", () => { dataType: column.dataType, sqlName: column.sqlName, notNull: column.notNull, - })) + })), ).toMatchInlineSnapshot(` { "__keyBytes": { @@ -81,7 +81,7 @@ describe("buildTable", () => { name: column.name, dataType: column.dataType, sqlName: column.sqlName, - })) + })), ).toMatchInlineSnapshot(` { "__keyBytes": { diff --git a/packages/store-sync/src/postgres-decoded/buildTable.ts b/packages/store-sync/src/postgres-decoded/buildTable.ts index 2f0a6f336c..56797a8438 100644 --- a/packages/store-sync/src/postgres-decoded/buildTable.ts +++ b/packages/store-sync/src/postgres-decoded/buildTable.ts @@ -56,10 +56,10 @@ export function buildTable [name, buildColumn(snakeCase(name), type).notNull()]) + Object.entries(keySchema).map(([name, type]) => [name, buildColumn(snakeCase(name), type).notNull()]), ); const valueColumns = Object.fromEntries( - Object.entries(valueSchema).map(([name, type]) => [name, buildColumn(snakeCase(name), type).notNull()]) + Object.entries(valueSchema).map(([name, type]) => [name, buildColumn(snakeCase(name), type).notNull()]), ); // TODO: make sure there are no meta columns that overlap with key/value columns diff --git a/packages/store-sync/src/postgres-decoded/createStorageAdapter.test.ts b/packages/store-sync/src/postgres-decoded/createStorageAdapter.test.ts index cf692f02a8..cb213fb258 100644 --- a/packages/store-sync/src/postgres-decoded/createStorageAdapter.test.ts +++ b/packages/store-sync/src/postgres-decoded/createStorageAdapter.test.ts @@ -22,7 +22,7 @@ const blocks = groupLogsByBlockNumber( strict: true, }); return formatLog(log as any as RpcLog, { args, eventName: eventName as string }) as StoreEventsLog; - }) + }), ); describe("createStorageAdapter", async () => { @@ -64,9 +64,9 @@ describe("createStorageAdapter", async () => { .where( eq( storageAdapter.tables.recordsTable.tableId, - resourceToHex({ type: "table", namespace: "", name: "NumberList" }) - ) - ) + resourceToHex({ type: "table", namespace: "", name: "NumberList" }), + ), + ), ).toMatchInlineSnapshot(` [ { diff --git a/packages/store-sync/src/postgres-decoded/createStorageAdapter.ts b/packages/store-sync/src/postgres-decoded/createStorageAdapter.ts index 227c0f39aa..d14401ef89 100644 --- a/packages/store-sync/src/postgres-decoded/createStorageAdapter.ts +++ b/packages/store-sync/src/postgres-decoded/createStorageAdapter.ts @@ -44,7 +44,7 @@ export async function createStorageAdapter ({ address: log.address, tableId: log.args.tableId })) + logs.map((log) => ({ address: log.address, tableId: log.args.tableId })), ); // TODO: check if DB schema/table was created? @@ -56,7 +56,7 @@ export async function createStorageAdapter { for (const log of logs) { const table = tables.find( - (table) => getAddress(table.address) === getAddress(log.address) && table.tableId === log.args.tableId + (table) => getAddress(table.address) === getAddress(log.address) && table.tableId === log.args.tableId, ); if (!table) { const { namespace, name } = hexToResource(log.args.tableId); @@ -80,8 +80,8 @@ export async function createStorageAdapter, - filters: { address: Hex | null; tableId: Hex | null }[] = [] + filters: { address: Hex | null; tableId: Hex | null }[] = [], ): Promise { const conditions = filters.map((filter) => and( filter.address != null ? eq(internalTables.recordsTable.address, filter.address) : undefined, - filter.tableId != null ? eq(internalTables.recordsTable.key0, filter.tableId) : undefined - ) + filter.tableId != null ? eq(internalTables.recordsTable.key0, filter.tableId) : undefined, + ), ); const records = await db @@ -34,7 +34,7 @@ export async function getTables( encodedLengths: record.encodedLengths ?? "0x", dynamicData: record.dynamicData ?? "0x", }, - } as const) + }) as const, ); const tables = logs.map(logToTable); diff --git a/packages/store-sync/src/postgres/createStorageAdapter.test.ts b/packages/store-sync/src/postgres/createStorageAdapter.test.ts index c05928640f..bd368633b0 100644 --- a/packages/store-sync/src/postgres/createStorageAdapter.test.ts +++ b/packages/store-sync/src/postgres/createStorageAdapter.test.ts @@ -20,7 +20,7 @@ const blocks = groupLogsByBlockNumber( strict: true, }); return formatLog(log as any as RpcLog, { args, eventName: eventName as string }) as StoreEventsLog; - }) + }), ); describe("createStorageAdapter", async () => { @@ -62,9 +62,9 @@ describe("createStorageAdapter", async () => { .where( eq( storageAdapter.tables.recordsTable.tableId, - resourceToHex({ type: "table", namespace: "", name: "NumberList" }) - ) - ) + resourceToHex({ type: "table", namespace: "", name: "NumberList" }), + ), + ), ).toMatchInlineSnapshot(` [ { diff --git a/packages/store-sync/src/postgres/createStorageAdapter.ts b/packages/store-sync/src/postgres/createStorageAdapter.ts index 43578e9ad9..91cfe6f225 100644 --- a/packages/store-sync/src/postgres/createStorageAdapter.ts +++ b/packages/store-sync/src/postgres/createStorageAdapter.ts @@ -80,8 +80,8 @@ export async function createStorageAdapter, - tables: PgTableWithColumns[] + tables: PgTableWithColumns[], ): Promise<() => Promise> { const schemaNames = unique(tables.map((table) => getTableConfig(table).schema).filter(isDefined)); @@ -49,7 +49,7 @@ export async function setupTables( if (primaryKeyColumns.length) { query = query.addPrimaryKeyConstraint( `${tableConfig.name}_${primaryKeyColumns.join("_")}_pk`, - primaryKeyColumns as any + primaryKeyColumns as any, ); } diff --git a/packages/store-sync/src/postgres/tables.ts b/packages/store-sync/src/postgres/tables.ts index b8871327d3..2f00011976 100644 --- a/packages/store-sync/src/postgres/tables.ts +++ b/packages/store-sync/src/postgres/tables.ts @@ -37,7 +37,7 @@ const recordsTable = pgSchema(schemaName).table( key1Index: index("key1_index").on(table.address, table.tableId, table.key1), // TODO: add indices for querying without table ID // TODO: add indices for querying multiple keys - }) + }), ); export const tables = { diff --git a/packages/store-sync/src/recs/decodeEntity.ts b/packages/store-sync/src/recs/decodeEntity.ts index ba2c084a7f..d4210de20b 100644 --- a/packages/store-sync/src/recs/decodeEntity.ts +++ b/packages/store-sync/src/recs/decodeEntity.ts @@ -5,18 +5,18 @@ import { KeySchema, SchemaToPrimitives } from "@latticexyz/protocol-parser"; export function decodeEntity( keySchema: TKeySchema, - entity: Entity + entity: Entity, ): SchemaToPrimitives { const hexKeyTuple = entityToHexKeyTuple(entity); if (hexKeyTuple.length !== Object.keys(keySchema).length) { throw new Error( - `entity key tuple length ${hexKeyTuple.length} does not match key schema length ${Object.keys(keySchema).length}` + `entity key tuple length ${hexKeyTuple.length} does not match key schema length ${Object.keys(keySchema).length}`, ); } return Object.fromEntries( Object.entries(keySchema).map(([key, type], index) => [ key, decodeAbiParameters([{ type }], hexKeyTuple[index] as Hex)[0], - ]) + ]), ) as SchemaToPrimitives; } diff --git a/packages/store-sync/src/recs/defineInternalComponents.ts b/packages/store-sync/src/recs/defineInternalComponents.ts index 992b878ce4..5b974cbd65 100644 --- a/packages/store-sync/src/recs/defineInternalComponents.ts +++ b/packages/store-sync/src/recs/defineInternalComponents.ts @@ -7,7 +7,7 @@ export function defineInternalComponents(world: World) { RegisteredTables: defineComponent<{ table: Type.T }, Metadata, Table>( world, { table: Type.T }, - { metadata: { componentName: "RegisteredTables" } } + { metadata: { componentName: "RegisteredTables" } }, ), SyncProgress: defineComponent( world, @@ -18,7 +18,7 @@ export function defineInternalComponents(world: World) { latestBlockNumber: Type.BigInt, lastBlockNumberProcessed: Type.BigInt, }, - { metadata: { componentName: "SyncProgress" } } + { metadata: { componentName: "SyncProgress" } }, ), } as const satisfies Record>; } diff --git a/packages/store-sync/src/recs/encodeEntity.ts b/packages/store-sync/src/recs/encodeEntity.ts index bef8a33c1b..061a630dee 100644 --- a/packages/store-sync/src/recs/encodeEntity.ts +++ b/packages/store-sync/src/recs/encodeEntity.ts @@ -5,14 +5,14 @@ import { KeySchema, SchemaToPrimitives } from "@latticexyz/protocol-parser"; export function encodeEntity( keySchema: TKeySchema, - key: SchemaToPrimitives + key: SchemaToPrimitives, ): Entity { if (Object.keys(keySchema).length !== Object.keys(key).length) { throw new Error( - `key length ${Object.keys(key).length} does not match key schema length ${Object.keys(keySchema).length}` + `key length ${Object.keys(key).length} does not match key schema length ${Object.keys(keySchema).length}`, ); } return hexKeyTupleToEntity( - Object.entries(keySchema).map(([keyName, type]) => encodeAbiParameters([{ type }], [key[keyName]])) + Object.entries(keySchema).map(([keyName, type]) => encodeAbiParameters([{ type }], [key[keyName]])), ); } diff --git a/packages/store-sync/src/recs/getTableEntity.ts b/packages/store-sync/src/recs/getTableEntity.ts index 5b92368da3..52ae66b6e3 100644 --- a/packages/store-sync/src/recs/getTableEntity.ts +++ b/packages/store-sync/src/recs/getTableEntity.ts @@ -10,6 +10,6 @@ export function getTableEntity(table: Pick( - component: Component + component: Component, ): component is Component { return ( component.metadata?.componentName != null && diff --git a/packages/store-sync/src/recs/recsStorage.test.ts b/packages/store-sync/src/recs/recsStorage.test.ts index afead84f6b..a1e5217cbe 100644 --- a/packages/store-sync/src/recs/recsStorage.test.ts +++ b/packages/store-sync/src/recs/recsStorage.test.ts @@ -21,7 +21,7 @@ const blocks = groupLogsByBlockNumber( strict: true, }); return formatLog(log as any as RpcLog, { args, eventName: eventName as string }) as StoreEventsLog; - }) + }), ); describe("recsStorage", () => { @@ -29,7 +29,7 @@ describe("recsStorage", () => { const world = createWorld(); const { components } = recsStorage({ world, tables }); expect(components.NumberList.id).toMatchInlineSnapshot( - '"0x746200000000000000000000000000004e756d6265724c697374000000000000"' + '"0x746200000000000000000000000000004e756d6265724c697374000000000000"', ); }); @@ -60,7 +60,9 @@ describe("recsStorage", () => { `); expect( - [...getComponentEntities(components.NumberList)].map((entity) => getComponentValue(components.NumberList, entity)) + [...getComponentEntities(components.NumberList)].map((entity) => + getComponentValue(components.NumberList, entity), + ), ).toMatchInlineSnapshot(` [ { diff --git a/packages/store-sync/src/recs/recsStorage.ts b/packages/store-sync/src/recs/recsStorage.ts index 85a956c402..36849aa6f2 100644 --- a/packages/store-sync/src/recs/recsStorage.ts +++ b/packages/store-sync/src/recs/recsStorage.ts @@ -60,7 +60,7 @@ export function recsStorage>({ components.RegisteredTables, tableEntity, { table: newTable }, - { skipUpdateStream: shouldSkipUpdateStream?.() } + { skipUpdateStream: shouldSkipUpdateStream?.() }, ); } } @@ -69,7 +69,7 @@ export function recsStorage>({ const { namespace, name } = hexToResource(log.args.tableId); const table = getComponentValue( components.RegisteredTables, - getTableEntity({ address: log.address, namespace, name }) + getTableEntity({ address: log.address, namespace, name }), )?.table; if (!table) { debug(`skipping update for unknown table: ${resourceToLabel({ namespace, name })} at ${log.address}`); @@ -82,7 +82,7 @@ export function recsStorage>({ `skipping update for unknown component: ${table.tableId} (${resourceToLabel({ namespace, name, - })}). Available components: ${Object.keys(components)}` + })}). Available components: ${Object.keys(components)}`, ); continue; } @@ -106,7 +106,7 @@ export function recsStorage>({ __encodedLengths: log.args.encodedLengths, __dynamicData: log.args.dynamicData, }, - { skipUpdateStream: shouldSkipUpdateStream?.() } + { skipUpdateStream: shouldSkipUpdateStream?.() }, ); } else if (log.eventName === "Store_SpliceStaticData") { // TODO: add tests that this works when no record had been set before @@ -134,7 +134,7 @@ export function recsStorage>({ ...newValue, __staticData: newStaticData, }, - { skipUpdateStream: shouldSkipUpdateStream?.() } + { skipUpdateStream: shouldSkipUpdateStream?.() }, ); } else if (log.eventName === "Store_SpliceDynamicData") { // TODO: add tests that this works when no record had been set before @@ -164,7 +164,7 @@ export function recsStorage>({ __encodedLengths: log.args.encodedLengths, __dynamicData: newDynamicData, }, - { skipUpdateStream: shouldSkipUpdateStream?.() } + { skipUpdateStream: shouldSkipUpdateStream?.() }, ); } else if (log.eventName === "Store_DeleteRecord") { debug("deleting component", { diff --git a/packages/store-sync/src/recs/tableToComponent.ts b/packages/store-sync/src/recs/tableToComponent.ts index cfd07a9107..588163b6f1 100644 --- a/packages/store-sync/src/recs/tableToComponent.ts +++ b/packages/store-sync/src/recs/tableToComponent.ts @@ -31,7 +31,7 @@ export function tableToComponent
(world: World, table: table Object.entries(table.valueSchema).map(([fieldName, { type: schemaAbiType }]) => [ fieldName, schemaAbiTypeToRecsType[schemaAbiType as SchemaAbiType], - ]) + ]), ), __staticData: Type.OptionalString, __encodedLengths: Type.OptionalString, @@ -45,6 +45,6 @@ export function tableToComponent
(world: World, table: table keySchema: mapObject(table.keySchema, ({ type }) => type), valueSchema: mapObject(table.valueSchema, ({ type }) => type), }, - } + }, ) as TableToComponent
; } diff --git a/packages/store-sync/src/recs/tablesToComponents.ts b/packages/store-sync/src/recs/tablesToComponents.ts index be1a2cde4e..5952f6aa7a 100644 --- a/packages/store-sync/src/recs/tablesToComponents.ts +++ b/packages/store-sync/src/recs/tablesToComponents.ts @@ -9,7 +9,7 @@ export type TablesToComponents> = { export function tablesToComponents>( world: World, - tables: tables + tables: tables, ): TablesToComponents { return mapObject(tables, (table) => tableToComponent(world, table)); } diff --git a/packages/store-sync/src/schemaToDefaults.ts b/packages/store-sync/src/schemaToDefaults.ts index 278b4c77c7..f7658c15e0 100644 --- a/packages/store-sync/src/schemaToDefaults.ts +++ b/packages/store-sync/src/schemaToDefaults.ts @@ -3,6 +3,6 @@ import { schemaAbiTypeToDefaultValue } from "@latticexyz/schema-type"; export function schemaToDefaults(valueSchema: TSchema): SchemaToPrimitives { return Object.fromEntries( - Object.entries(valueSchema).map(([key, abiType]) => [key, schemaAbiTypeToDefaultValue[abiType]]) + Object.entries(valueSchema).map(([key, abiType]) => [key, schemaAbiTypeToDefaultValue[abiType]]), ) as SchemaToPrimitives; } diff --git a/packages/store-sync/src/sqlite/buildTable.ts b/packages/store-sync/src/sqlite/buildTable.ts index 2b9b0efd5c..d37d77d8e7 100644 --- a/packages/store-sync/src/sqlite/buildTable.ts +++ b/packages/store-sync/src/sqlite/buildTable.ts @@ -53,11 +53,11 @@ export function buildTable [name, buildColumn(name, type).notNull()]) + Object.entries(keySchema).map(([name, type]) => [name, buildColumn(name, type).notNull()]), ); const valueColumns = Object.fromEntries( - Object.entries(valueSchema).map(([name, type]) => [name, buildColumn(name, type).notNull()]) + Object.entries(valueSchema).map(([name, type]) => [name, buildColumn(name, type).notNull()]), ); // TODO: unique constraint on key columns? diff --git a/packages/store-sync/src/sqlite/getTables.ts b/packages/store-sync/src/sqlite/getTables.ts index 008a772167..01f9e90aa9 100644 --- a/packages/store-sync/src/sqlite/getTables.ts +++ b/packages/store-sync/src/sqlite/getTables.ts @@ -6,17 +6,17 @@ import { mudStoreTables } from "./internalTables"; export function getTables( db: BaseSQLiteDatabase<"sync", void>, - conditions: Pick[] = [] + conditions: Pick[] = [], ): Table[] { const ids = Array.from( - new Set(conditions.map((condition) => getTableName(condition.address, condition.namespace, condition.name))) + new Set(conditions.map((condition) => getTableName(condition.address, condition.namespace, condition.name))), ); const tables = db .select() .from(mudStoreTables) .where(ids.length ? inArray(mudStoreTables.id, ids) : undefined) .orderBy( - asc(mudStoreTables.lastUpdatedBlockNumber) + asc(mudStoreTables.lastUpdatedBlockNumber), // TODO: add logIndex (https://github.com/latticexyz/mud/issues/1979) ) .all(); diff --git a/packages/store-sync/src/sqlite/sqliteStorage.test.ts b/packages/store-sync/src/sqlite/sqliteStorage.test.ts index c8afe6a3d5..ed21a8dc58 100644 --- a/packages/store-sync/src/sqlite/sqliteStorage.test.ts +++ b/packages/store-sync/src/sqlite/sqliteStorage.test.ts @@ -24,7 +24,7 @@ const blocks = groupLogsByBlockNumber( strict: true, }); return formatLog(log as any as RpcLog, { args, eventName: eventName as string }) as StoreEventsLog; - }) + }), ); describe("sqliteStorage", async () => { @@ -44,10 +44,10 @@ describe("sqliteStorage", async () => { it("should create tables and data from block log", async () => { expect(() => db.select().from(chainState).all()).toThrowErrorMatchingInlineSnapshot( - '"no such table: __chainState"' + '"no such table: __chainState"', ); expect(() => db.select().from(mudStoreTables).all()).toThrowErrorMatchingInlineSnapshot( - '"no such table: __mudStoreTables"' + '"no such table: __mudStoreTables"', ); const storageAdapter = await sqliteStorage({ database: db, publicClient }); diff --git a/packages/store-sync/src/sqlite/sqliteStorage.ts b/packages/store-sync/src/sqlite/sqliteStorage.ts index 6c369ab3b2..b29cd660aa 100644 --- a/packages/store-sync/src/sqlite/sqliteStorage.ts +++ b/packages/store-sync/src/sqlite/sqliteStorage.ts @@ -62,10 +62,10 @@ export async function sqliteStorage({ JSON.stringify({ address: getAddress(log.address), ...hexToResource(log.args.tableId), - }) - ) - ) - ).map((json) => JSON.parse(json)) + }), + ), + ), + ).map((json) => JSON.parse(json)), ); await database.transaction(async (tx) => { @@ -76,21 +76,21 @@ export async function sqliteStorage({ and( eq(mudStoreTables.address, address), eq(mudStoreTables.namespace, namespace), - eq(mudStoreTables.name, name) - ) + eq(mudStoreTables.name, name), + ), ) .run(); } for (const log of logs) { const table = tables.find( - (table) => table.address === getAddress(log.address) && table.tableId === log.args.tableId + (table) => table.address === getAddress(log.address) && table.tableId === log.args.tableId, ); if (!table) { const tableId = hexToResource(log.args.tableId); debug( `table ${resourceToLabel({ namespace: tableId.namespace, name: tableId.name })} not found, skipping log`, - log + log, ); continue; } diff --git a/packages/store-sync/src/sqlite/sqliteTableToSql.test.ts b/packages/store-sync/src/sqlite/sqliteTableToSql.test.ts index c07270f84e..cad8a1ca39 100644 --- a/packages/store-sync/src/sqlite/sqliteTableToSql.test.ts +++ b/packages/store-sync/src/sqlite/sqliteTableToSql.test.ts @@ -16,7 +16,7 @@ describe("sqliteTableToSql", () => { expect(sql).toMatchInlineSnapshot( // eslint-disable-next-line max-len - '"create table if not exists \\"some table\\" (\\"x\\" integer not null, \\"y\\" integer not null, \\"name\\" text default \'\' not null, \\"block_number\\" blob default \'1000\' not null, constraint \\"some table__primaryKey\\" primary key (\\"x\\", \\"y\\"))"' + '"create table if not exists \\"some table\\" (\\"x\\" integer not null, \\"y\\" integer not null, \\"name\\" text default \'\' not null, \\"block_number\\" blob default \'1000\' not null, constraint \\"some table__primaryKey\\" primary key (\\"x\\", \\"y\\"))"', ); }); @@ -29,7 +29,7 @@ describe("sqliteTableToSql", () => { const sql = sqliteTableToSql(table); expect(sql).toMatchInlineSnapshot( - '"create table if not exists \\"some table\\" (\\"name\\" text default \'\' not null)"' + '"create table if not exists \\"some table\\" (\\"name\\" text default \'\' not null)"', ); }); @@ -42,7 +42,7 @@ describe("sqliteTableToSql", () => { const sql = sqliteTableToSql(table); expect(sql).toMatchInlineSnapshot( - '"create table if not exists \\"some table\\" (\\"snake_case\\" text default \'\' not null, constraint \\"some table__primaryKey\\" primary key (\\"snake_case\\"))"' + '"create table if not exists \\"some table\\" (\\"snake_case\\" text default \'\' not null, constraint \\"some table__primaryKey\\" primary key (\\"snake_case\\"))"', ); }); }); diff --git a/packages/store-sync/src/tableToLog.test.ts b/packages/store-sync/src/tableToLog.test.ts index 0b58c4c45a..ca1f9de5f5 100644 --- a/packages/store-sync/src/tableToLog.test.ts +++ b/packages/store-sync/src/tableToLog.test.ts @@ -14,7 +14,7 @@ describe("tableToLog", () => { name: storeTables.Tables.name, keySchema: flattenSchema(storeTables.Tables.keySchema), valueSchema: flattenSchema(storeTables.Tables.valueSchema), - }) + }), ).toMatchInlineSnapshot(` { "address": "0x3Aa5ebB10DC797CAC828524e59A333d0A371443c", diff --git a/packages/store-sync/src/tablesWithRecordsToLogs.ts b/packages/store-sync/src/tablesWithRecordsToLogs.ts index a7e35d5a89..afd37437e5 100644 --- a/packages/store-sync/src/tablesWithRecordsToLogs.ts +++ b/packages/store-sync/src/tablesWithRecordsToLogs.ts @@ -18,8 +18,8 @@ export function tablesWithRecordsToLogs(tables: readonly TableWithRecords[]): St keyTuple: encodeKey(table.keySchema, record.key), ...encodeValueArgs(table.valueSchema, record.value), }, - }) - ) + }), + ), ), ]; } diff --git a/packages/store-sync/src/zustand/createStorageAdapter.test.ts b/packages/store-sync/src/zustand/createStorageAdapter.test.ts index 76fa8fc707..cdc089d051 100644 --- a/packages/store-sync/src/zustand/createStorageAdapter.test.ts +++ b/packages/store-sync/src/zustand/createStorageAdapter.test.ts @@ -20,7 +20,7 @@ const blocks = groupLogsByBlockNumber( strict: true, }); return formatLog(log as unknown as RpcLog, { args, eventName: eventName as string }) as StoreEventsLog; - }) + }), ); describe("createStorageAdapter", () => { diff --git a/packages/store-sync/src/zustand/createStorageAdapter.ts b/packages/store-sync/src/zustand/createStorageAdapter.ts index 7dcb55f20c..b8bb5f6974 100644 --- a/packages/store-sync/src/zustand/createStorageAdapter.ts +++ b/packages/store-sync/src/zustand/createStorageAdapter.ts @@ -32,7 +32,7 @@ export function createStorageAdapter({ debug( `skipping update for unknown table: ${resourceToLabel({ namespace, name })} (${log.args.tableId}) at ${ log.address - }` + }`, ); continue; } @@ -140,7 +140,7 @@ export function createStorageAdapter({ }, ]; }) - .filter(isDefined) + .filter(isDefined), ), }; diff --git a/packages/store-sync/src/zustand/createStore.ts b/packages/store-sync/src/zustand/createStore.ts index 77642e3eaa..93a2dd3258 100644 --- a/packages/store-sync/src/zustand/createStore.ts +++ b/packages/store-sync/src/zustand/createStore.ts @@ -36,11 +36,11 @@ export type ZustandState = { readonly getRecords:
(table: table) => TableRecords
; readonly getRecord:
( table: table, - key: SchemaToPrimitives + key: SchemaToPrimitives, ) => TableRecord
| undefined; readonly getValue:
( table: table, - key: SchemaToPrimitives + key: SchemaToPrimitives, ) => TableRecord
["value"] | undefined; }; @@ -65,12 +65,12 @@ export function createStore(opts: CreateStoreOptions(table: table): TableRecords
=> { const records = get().records; return Object.fromEntries( - Object.entries(records).filter(([id, record]) => record.table.tableId === table.tableId) + Object.entries(records).filter(([id, record]) => record.table.tableId === table.tableId), ) as unknown as TableRecords
; }, getRecord:
( table: table, - key: SchemaToPrimitives + key: SchemaToPrimitives, ): TableRecord
| undefined => { const keyTuple = encodeKey(flattenSchema(table.keySchema), key); const id = getId({ tableId: table.tableId, keyTuple }); @@ -78,7 +78,7 @@ export function createStore(opts: CreateStoreOptions( table: table, - key: SchemaToPrimitives + key: SchemaToPrimitives, ): TableRecord
["value"] | undefined => { return get().getRecord(table, key)?.value; }, diff --git a/packages/store-sync/src/zustand/getId.test.ts b/packages/store-sync/src/zustand/getId.test.ts index e47b398a4e..2016d318a0 100644 --- a/packages/store-sync/src/zustand/getId.test.ts +++ b/packages/store-sync/src/zustand/getId.test.ts @@ -7,9 +7,9 @@ describe("getId", () => { getId({ tableId: "0x74626d756473746f72650000000000005461626c657300000000000000000000", keyTuple: ["0x74626d756473746f72650000000000005461626c657300000000000000000000"], - }) + }), ).toMatchInlineSnapshot( - '"0x74626d756473746f72650000000000005461626c657300000000000000000000:0x74626d756473746f72650000000000005461626c657300000000000000000000"' + '"0x74626d756473746f72650000000000005461626c657300000000000000000000:0x74626d756473746f72650000000000005461626c657300000000000000000000"', ); }); }); diff --git a/packages/store-sync/src/zustand/logToTable.test.ts b/packages/store-sync/src/zustand/logToTable.test.ts index 010d25b7ed..fbaf89cd0c 100644 --- a/packages/store-sync/src/zustand/logToTable.test.ts +++ b/packages/store-sync/src/zustand/logToTable.test.ts @@ -18,7 +18,7 @@ describe("logToTable", () => { // eslint-disable-next-line max-len "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000077461626c654964000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000000b6669656c644c61796f757400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000096b6579536368656d610000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b76616c7565536368656d610000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012616269456e636f6465644b65794e616d657300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014616269456e636f6465644669656c644e616d6573000000000000000000000000", }, - }) + }), ).toMatchInlineSnapshot(` { "keySchema": { diff --git a/packages/store-sync/src/zustand/logToTable.ts b/packages/store-sync/src/zustand/logToTable.ts index 8d2b32e4e7..703f276704 100644 --- a/packages/store-sync/src/zustand/logToTable.ts +++ b/packages/store-sync/src/zustand/logToTable.ts @@ -14,7 +14,7 @@ export function logToTable(log: StorageAdapterLog & { eventName: "Store_SetRecor const value = decodeValue( schemasTable.valueSchema, - concatHex([log.args.staticData, log.args.encodedLengths, log.args.dynamicData]) + concatHex([log.args.staticData, log.args.encodedLengths, log.args.dynamicData]), ); const keySchema = hexToSchema(value.keySchema); diff --git a/packages/store-sync/src/zustand/syncToZustand.ts b/packages/store-sync/src/zustand/syncToZustand.ts index 850bb1c231..d5df3c0e80 100644 --- a/packages/store-sync/src/zustand/syncToZustand.ts +++ b/packages/store-sync/src/zustand/syncToZustand.ts @@ -9,7 +9,7 @@ import { SyncStep } from "../SyncStep"; type AllTables< config extends StoreConfig, - extraTables extends Tables | undefined + extraTables extends Tables | undefined, > = ResolvedStoreConfig["tables"] & (extraTables extends Tables ? extraTables : Record) & typeof storeTables & diff --git a/packages/store-sync/test/logsToBlocks.ts b/packages/store-sync/test/logsToBlocks.ts index e3ffb8a9ac..2c92392316 100644 --- a/packages/store-sync/test/logsToBlocks.ts +++ b/packages/store-sync/test/logsToBlocks.ts @@ -4,7 +4,7 @@ import { RpcLog, formatLog, decodeEventLog, Hex } from "viem"; import { StoreEventsLog } from "../src/common"; export function logsToBlocks( - rpcLogs: { data: string; topics: string[] }[] + rpcLogs: { data: string; topics: string[] }[], ): GroupLogsByBlockNumberResult { return groupLogsByBlockNumber( rpcLogs.map((log) => { @@ -15,6 +15,6 @@ export function logsToBlocks( strict: true, }); return formatLog(log as any as RpcLog, { args, eventName: eventName as string }) as StoreEventsLog; - }) + }), ); } diff --git a/packages/store/src/IStore.sol b/packages/store/src/IStore.sol index 7f8e54a0b6..6510e115dc 100644 --- a/packages/store/src/IStore.sol +++ b/packages/store/src/IStore.sol @@ -9,6 +9,4 @@ import { IStoreRegistration } from "./IStoreRegistration.sol"; * @title IStore * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz) */ -interface IStore is IStoreData, IStoreRegistration, IStoreErrors { - -} +interface IStore is IStoreData, IStoreRegistration, IStoreErrors {} diff --git a/packages/store/ts/codegen/field.ts b/packages/store/ts/codegen/field.ts index b9992e8ba7..ce62a59584 100644 --- a/packages/store/ts/codegen/field.ts +++ b/packages/store/ts/codegen/field.ts @@ -35,10 +35,10 @@ export function renderFieldMethods(options: RenderTableOptions): string { * @notice Get ${field.name}${_commentSuffix}. */ function ${_methodNamePrefix}get${_methodNameSuffix}(${renderArguments([ - _typedStore, - _typedTableId, - _typedKeyArgs, - ])}) internal view returns (${_typedFieldName}) { + _typedStore, + _typedTableId, + _typedKeyArgs, + ])}) internal view returns (${_typedFieldName}) { ${_keyTupleDefinition} ${ field.isDynamic @@ -56,8 +56,8 @@ export function renderFieldMethods(options: RenderTableOptions): string { } return ${renderDecodeFieldSingle(field)}; } - ` - ) + `, + ), ); } @@ -79,7 +79,7 @@ export function renderFieldMethods(options: RenderTableOptions): string { ${_store}.${setFieldMethod}(${internalArguments}); } `; - }) + }), ); if (field.isDynamic) { @@ -97,14 +97,14 @@ export function renderFieldMethods(options: RenderTableOptions): string { * @notice Get the length of ${field.name}${_commentSuffix}. */ function ${_methodNamePrefix}length${_methodNameSuffix}(${renderArguments([ - _typedStore, - _typedTableId, - _typedKeyArgs, - ])}) internal pure returns (uint256) { + _typedStore, + _typedTableId, + _typedKeyArgs, + ])}) internal pure returns (uint256) { return ${typeWrappingData.staticLength}; } - ` - ) + `, + ), ); } else { result += renderWithFieldSuffix(options.withSuffixlessFieldMethods, field.name, (_methodNameSuffix) => @@ -115,18 +115,18 @@ export function renderFieldMethods(options: RenderTableOptions): string { * @notice Get the length of ${field.name}${_commentSuffix}. */ function ${_methodNamePrefix}length${_methodNameSuffix}(${renderArguments([ - _typedStore, - _typedTableId, - _typedKeyArgs, - ])}) internal view returns (uint256) { + _typedStore, + _typedTableId, + _typedKeyArgs, + ])}) internal view returns (uint256) { ${_keyTupleDefinition} uint256 _byteLength = ${_store}.getDynamicFieldLength(_tableId, _keyTuple, ${dynamicSchemaIndex}); unchecked { return _byteLength / ${portionData.elementLength}; } } - ` - ) + `, + ), ); } @@ -139,11 +139,11 @@ export function renderFieldMethods(options: RenderTableOptions): string { * @dev Reverts with Store_IndexOutOfBounds if \`_index\` is out of bounds for the array. */ function ${_methodNamePrefix}getItem${_methodNameSuffix}(${renderArguments([ - _typedStore, - _typedTableId, - _typedKeyArgs, - "uint256 _index", - ])}) internal view returns (${portionData.typeWithLocation}) { + _typedStore, + _typedTableId, + _typedKeyArgs, + "uint256 _index", + ])}) internal view returns (${portionData.typeWithLocation}) { ${_keyTupleDefinition} unchecked { bytes memory _blob = ${_store}.getDynamicFieldSlice( @@ -156,8 +156,8 @@ export function renderFieldMethods(options: RenderTableOptions): string { return ${portionData.decoded}; } } - ` - ) + `, + ), ); } @@ -170,16 +170,16 @@ export function renderFieldMethods(options: RenderTableOptions): string { * @notice Push ${portionData.title} to ${field.name}${_commentSuffix}. */ function ${_methodNamePrefix}push${_methodNameSuffix}(${renderArguments([ - _typedStore, - _typedTableId, - _typedKeyArgs, - `${portionData.typeWithLocation} ${portionData.name}`, - ])}) internal { + _typedStore, + _typedTableId, + _typedKeyArgs, + `${portionData.typeWithLocation} ${portionData.name}`, + ])}) internal { ${_keyTupleDefinition} ${_store}.pushToDynamicField(_tableId, _keyTuple, ${dynamicSchemaIndex}, ${portionData.encoded}); } - ` - ) + `, + ), ); result += renderWithFieldSuffix(options.withSuffixlessFieldMethods, field.name, (_methodNameSuffix) => @@ -190,15 +190,15 @@ export function renderFieldMethods(options: RenderTableOptions): string { * @notice Pop ${portionData.title} from ${field.name}${_commentSuffix}. */ function ${_methodNamePrefix}pop${_methodNameSuffix}(${renderArguments([ - _typedStore, - _typedTableId, - _typedKeyArgs, - ])}) internal { + _typedStore, + _typedTableId, + _typedKeyArgs, + ])}) internal { ${_keyTupleDefinition} ${_store}.popFromDynamicField(_tableId, _keyTuple, ${dynamicSchemaIndex}, ${portionData.elementLength}); } - ` - ) + `, + ), ); } @@ -233,7 +233,7 @@ export function renderFieldMethods(options: RenderTableOptions): string { } } `; - }) + }), ); } } diff --git a/packages/store/ts/codegen/record.ts b/packages/store/ts/codegen/record.ts index 7d190b8185..bd540d7068 100644 --- a/packages/store/ts/codegen/record.ts +++ b/packages/store/ts/codegen/record.ts @@ -27,10 +27,10 @@ export function renderRecordMethods(options: RenderTableOptions) { * @notice Get the full data${_commentSuffix}. */ function ${_methodNamePrefix}get(${renderArguments([ - _typedStore, - _typedTableId, - _typedKeyArgs, - ])}) internal view returns (${renderDecodedRecord(options)}) { + _typedStore, + _typedTableId, + _typedKeyArgs, + ])}) internal view returns (${renderDecodedRecord(options)}) { ${_keyTupleDefinition} ( @@ -40,7 +40,7 @@ export function renderRecordMethods(options: RenderTableOptions) { ) = ${_store}.getRecord(_tableId, _keyTuple, _fieldLayout); return decode(_staticData, _encodedLengths, _dynamicData); } - ` + `, ); } @@ -70,7 +70,7 @@ export function renderRecordMethods(options: RenderTableOptions) { ${_store}.setRecord(${internalArguments}); } `; - } + }, ); if (structName !== undefined) { @@ -100,7 +100,7 @@ export function renderRecordMethods(options: RenderTableOptions) { ${_store}.setRecord(${internalArguments}); } `; - } + }, ); } @@ -170,7 +170,7 @@ export function renderDeleteRecordMethods(options: RenderTableOptions) { ${_store}.deleteRecord(${internalArguments}); } `; - } + }, ); } @@ -202,13 +202,13 @@ function renderDecodeFunctions({ structName, fields, staticFields, dynamicFields * @notice Decode the tightly packed blob of static data using this table's field layout. */ function decodeStatic(bytes memory _blob) internal pure returns (${renderArguments( - staticFields.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`) + staticFields.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`), )}) { ${renderList( staticFields, (field, index) => ` ${field.name} = ${renderDecodeValueType(field, staticOffsets[index])}; - ` + `, )} } `; @@ -220,7 +220,7 @@ function renderDecodeFunctions({ structName, fields, staticFields, dynamicFields * @notice Decode the tightly packed blob of dynamic data using the encoded lengths. */ function decodeDynamic(PackedCounter _encodedLengths, bytes memory _blob) internal pure returns (${renderArguments( - dynamicFields.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`) + dynamicFields.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`), )}) { ${renderList( dynamicFields, @@ -245,7 +245,7 @@ function renderDecodeFunctions({ structName, fields, staticFields, dynamicFields ${field.name} = ${renderDecodeDynamicFieldPartial(field)}; `; } - } + }, )} } `; @@ -273,7 +273,7 @@ function renderDecodeFunctions({ structName, fields, staticFields, dynamicFields if (dynamicFields.length > 0) { result += ` (${renderArguments( - dynamicFields.map((field) => `${fieldNamePrefix}${field.name}`) + dynamicFields.map((field) => `${fieldNamePrefix}${field.name}`), )}) = decodeDynamic(_encodedLengths, _dynamicData); `; } diff --git a/packages/store/ts/codegen/renderFieldLayout.test.ts b/packages/store/ts/codegen/renderFieldLayout.test.ts index 38b8b4b6df..89c6663f74 100644 --- a/packages/store/ts/codegen/renderFieldLayout.test.ts +++ b/packages/store/ts/codegen/renderFieldLayout.test.ts @@ -35,23 +35,23 @@ describe("renderFieldLayout", () => { ]; expect(renderFieldLayout(fields)).toMatchInlineSnapshot( - '"FieldLayout constant _fieldLayout = FieldLayout.wrap(0x013418040102030405060708090a0b0c0d0e0f10111213141516172000000000);"' + '"FieldLayout constant _fieldLayout = FieldLayout.wrap(0x013418040102030405060708090a0b0c0d0e0f10111213141516172000000000);"', ); expect(renderFieldLayout([{ isDynamic: false, staticByteLength: 2 }])).toMatchInlineSnapshot( - '"FieldLayout constant _fieldLayout = FieldLayout.wrap(0x0002010002000000000000000000000000000000000000000000000000000000);"' + '"FieldLayout constant _fieldLayout = FieldLayout.wrap(0x0002010002000000000000000000000000000000000000000000000000000000);"', ); expect(renderFieldLayout([{ isDynamic: false, staticByteLength: 8 }])).toMatchInlineSnapshot( - '"FieldLayout constant _fieldLayout = FieldLayout.wrap(0x0008010008000000000000000000000000000000000000000000000000000000);"' + '"FieldLayout constant _fieldLayout = FieldLayout.wrap(0x0008010008000000000000000000000000000000000000000000000000000000);"', ); expect(renderFieldLayout([{ isDynamic: false, staticByteLength: 16 }])).toMatchInlineSnapshot( - '"FieldLayout constant _fieldLayout = FieldLayout.wrap(0x0010010010000000000000000000000000000000000000000000000000000000);"' + '"FieldLayout constant _fieldLayout = FieldLayout.wrap(0x0010010010000000000000000000000000000000000000000000000000000000);"', ); expect(renderFieldLayout([{ isDynamic: true, staticByteLength: 0 }])).toMatchInlineSnapshot( - '"FieldLayout constant _fieldLayout = FieldLayout.wrap(0x0000000100000000000000000000000000000000000000000000000000000000);"' + '"FieldLayout constant _fieldLayout = FieldLayout.wrap(0x0000000100000000000000000000000000000000000000000000000000000000);"', ); }); diff --git a/packages/store/ts/codegen/renderTable.ts b/packages/store/ts/codegen/renderTable.ts index e7fba56e6b..b67fc87650 100644 --- a/packages/store/ts/codegen/renderTable.ts +++ b/packages/store/ts/codegen/renderTable.ts @@ -80,11 +80,11 @@ export function renderTable(options: RenderTableOptions) { // Hex-encoded key schema of (${keyTuple.map((field) => field.internalTypeId).join(", ")}) Schema constant _keySchema = Schema.wrap(${keySchemaToHex( - Object.fromEntries(keyTuple.map((field) => [field.name, field.internalTypeId])) as KeySchema + Object.fromEntries(keyTuple.map((field) => [field.name, field.internalTypeId])) as KeySchema, )}); // Hex-encoded value schema of (${fields.map((field) => field.internalTypeId).join(", ")}) Schema constant _valueSchema = Schema.wrap(${valueSchemaToHex( - Object.fromEntries(fields.map((field) => [field.name, field.internalTypeId])) as ValueSchema + Object.fromEntries(fields.map((field) => [field.name, field.internalTypeId])) as ValueSchema, )}); /** @@ -114,7 +114,7 @@ export function renderTable(options: RenderTableOptions) { function ${_methodNamePrefix}register(${renderArguments([_typedStore, _typedTableId])}) internal { ${_store}.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); } - ` + `, )} ${renderFieldMethods(options)} @@ -136,7 +136,7 @@ export function renderTable(options: RenderTableOptions) { * @return The dynamic (variable length) data, encoded into a sequence of bytes. */ function encode(${renderArguments( - options.fields.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`) + options.fields.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`), )}) internal pure returns (bytes memory, PackedCounter, bytes memory) { ${renderRecordData(options)} @@ -171,7 +171,7 @@ function renderEncodeStatic(staticFields: RenderStaticField[]) { * @return The static data, encoded into a sequence of bytes. */ function encodeStatic(${renderArguments( - staticFields.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`) + staticFields.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`), )}) internal pure returns (bytes memory) { return abi.encodePacked(${renderArguments(staticFields.map(({ name }) => name))}); } @@ -193,7 +193,7 @@ function renderEncodeLengths(dynamicFields: RenderDynamicField[]) { * @return _encodedLengths The lengths of the dynamic fields (packed into a single bytes32 value). */ function encodeLengths(${renderArguments( - dynamicFields.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`) + dynamicFields.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`), )}) internal pure returns (PackedCounter _encodedLengths) { // Lengths are effectively checked during copy by 2**40 bytes exceeding gas limits unchecked { @@ -205,7 +205,7 @@ function renderEncodeLengths(dynamicFields: RenderDynamicField[]) { } else { return `bytes(${name}).length`; } - }) + }), )} ); } @@ -228,7 +228,7 @@ function renderEncodeDynamic(dynamicFields: RenderDynamicField[]) { * @return The dynamic data, encoded into a sequence of bytes. */ function encodeDynamic(${renderArguments( - dynamicFields.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`) + dynamicFields.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`), )}) internal pure returns (bytes memory) { return abi.encodePacked(${renderArguments(dynamicFields.map((field) => renderEncodeFieldSingle(field)))}); } diff --git a/packages/store/ts/codegen/tableOptions.ts b/packages/store/ts/codegen/tableOptions.ts index b46b24d3d1..208fc42e6e 100644 --- a/packages/store/ts/codegen/tableOptions.ts +++ b/packages/store/ts/codegen/tableOptions.ts @@ -26,7 +26,7 @@ export interface TableOptions { */ export function getTableOptions( config: StoreConfig, - solidityUserTypes: Record + solidityUserTypes: Record, ): TableOptions[] { const storeImportPath = config.storeImportPath; diff --git a/packages/store/ts/codegen/tablegen.ts b/packages/store/ts/codegen/tablegen.ts index 18d0bcfb56..02cd7a62c2 100644 --- a/packages/store/ts/codegen/tablegen.ts +++ b/packages/store/ts/codegen/tablegen.ts @@ -15,7 +15,7 @@ export async function tablegen(config: StoreConfig, outputBaseDirectory: string, await Promise.all( uniqueTableDirectories.map(async (tableDir) => { await rm(path.join(outputBaseDirectory, tableDir), { recursive: true, force: true }); - }) + }), ); // write tables to files @@ -24,7 +24,7 @@ export async function tablegen(config: StoreConfig, outputBaseDirectory: string, const fullOutputPath = path.join(outputBaseDirectory, outputPath); const output = renderTable(renderOptions); await formatAndWriteSolidity(output, fullOutputPath, "Generated table"); - }) + }), ); // write table index diff --git a/packages/store/ts/codegen/tightcoder/renderDecodeSlice.ts b/packages/store/ts/codegen/tightcoder/renderDecodeSlice.ts index 77f088125d..1e1518eaec 100644 --- a/packages/store/ts/codegen/tightcoder/renderDecodeSlice.ts +++ b/packages/store/ts/codegen/tightcoder/renderDecodeSlice.ts @@ -25,7 +25,7 @@ export function renderDecodeSlice() { renderTightCoderDecode({ internalTypeId: staticAbiType, staticByteLength: staticAbiTypeToByteLength[staticAbiType], - }) + }), ) .join("\n")} } diff --git a/packages/store/ts/codegen/tightcoder/renderEncodeArray.ts b/packages/store/ts/codegen/tightcoder/renderEncodeArray.ts index 477445e1c6..27d894a2d4 100644 --- a/packages/store/ts/codegen/tightcoder/renderEncodeArray.ts +++ b/packages/store/ts/codegen/tightcoder/renderEncodeArray.ts @@ -23,7 +23,7 @@ export function renderEncodeArray() { renderTightCoderEncode({ internalTypeId: staticAbiType, staticByteLength: staticAbiTypeToByteLength[staticAbiType], - }) + }), ) .join("\n")} } diff --git a/packages/store/ts/codegen/userType.ts b/packages/store/ts/codegen/userType.ts index 72e613df37..62b371c8d9 100644 --- a/packages/store/ts/codegen/userType.ts +++ b/packages/store/ts/codegen/userType.ts @@ -14,7 +14,7 @@ import { StoreConfig } from "../config"; export function resolveAbiOrUserType( abiOrUserType: string, config: StoreConfig, - solidityUserTypes: Record + solidityUserTypes: Record, ): { schemaType: SchemaType; renderType: RenderType; @@ -47,7 +47,7 @@ export function importForAbiOrUserType( abiOrUserType: string, usedInDirectory: string, config: StoreConfig, - solidityUserTypes: Record + solidityUserTypes: Record, ): ImportDatum | undefined { // abi types which directly mirror a SchemaType if (abiOrUserType in AbiTypeToSchemaType) { @@ -103,7 +103,7 @@ export function getSchemaTypeInfo(schemaType: SchemaType): RenderType { export function getUserTypeInfo( userType: string, config: StoreConfig, - solidityUserTypes: Record + solidityUserTypes: Record, ): { schemaType: SchemaType; renderType: RenderType; diff --git a/packages/store/ts/common.ts b/packages/store/ts/common.ts index a4d57e182c..5a9d1ebeb9 100644 --- a/packages/store/ts/common.ts +++ b/packages/store/ts/common.ts @@ -33,14 +33,14 @@ export type SchemaToPrimitives = { export type ConfigFieldTypeToSchemaAbiType> = T extends SchemaAbiType ? T : T extends `${string}[${string}]` - ? "uint8[]" - : "uint8"; + ? "uint8[]" + : "uint8"; export type ConfigFieldTypeToPrimitiveType> = T extends SchemaAbiType ? SchemaAbiTypeToPrimitiveType : T extends `${string}[${string}]` // field type might include enums and enum arrays, which are mapped to uint8/uint8[] - ? number[] // map enum arrays to `number[]` - : number; // map enums to `number` + ? number[] // map enum arrays to `number[]` + : number; // map enums to `number` /** Map a table schema config like `{ value: "uint256", type: "SomeEnum" }` to its primitive types like `{ value: bigint, type: number }` */ export type SchemaConfigToPrimitives = { @@ -56,12 +56,12 @@ export type ConfigToTablesPrimitives = { export type ConfigToKeyPrimitives< C extends StoreConfig, - Table extends keyof ConfigToTablesPrimitives + Table extends keyof ConfigToTablesPrimitives, > = ConfigToTablesPrimitives[Table]["key"]; export type ConfigToValuePrimitives< C extends StoreConfig, - Table extends keyof ConfigToTablesPrimitives + Table extends keyof ConfigToTablesPrimitives, > = ConfigToTablesPrimitives[Table]["value"]; export type ConfigToRecordPrimitives> = { diff --git a/packages/store/ts/config/experimental/resolveConfig.test-d.ts b/packages/store/ts/config/experimental/resolveConfig.test-d.ts index 0c5f5e52a3..80d8c8a960 100644 --- a/packages/store/ts/config/experimental/resolveConfig.test-d.ts +++ b/packages/store/ts/config/experimental/resolveConfig.test-d.ts @@ -29,7 +29,7 @@ describe("resolveConfig", () => { valueSchema: "ResourceType", }, }, - }) + }), ); expectTypeOf().toEqualTypeOf<"the-namespace">(); diff --git a/packages/store/ts/config/experimental/resolveConfig.test.ts b/packages/store/ts/config/experimental/resolveConfig.test.ts index d6187ca73c..c011aa1d01 100644 --- a/packages/store/ts/config/experimental/resolveConfig.test.ts +++ b/packages/store/ts/config/experimental/resolveConfig.test.ts @@ -25,7 +25,7 @@ const config = resolveConfig( valueSchema: "ResourceType", }, }, - }) + }), ); describe("resolveConfig", () => { @@ -35,7 +35,7 @@ describe("resolveConfig", () => { expect(config.tables.Shorthand.name).toEqual("Shorthand"); expect(config.tables.Shorthand.tableId).toEqual( - resourceToHex({ type: "table", namespace: "the-namespace", name: "Shorthand" }) + resourceToHex({ type: "table", namespace: "the-namespace", name: "Shorthand" }), ); expect(config.tables.Shorthand.keySchema).toEqual({ diff --git a/packages/store/ts/config/experimental/resolveConfig.ts b/packages/store/ts/config/experimental/resolveConfig.ts index 83354fa8f5..0d03e36884 100644 --- a/packages/store/ts/config/experimental/resolveConfig.ts +++ b/packages/store/ts/config/experimental/resolveConfig.ts @@ -26,7 +26,7 @@ type ResolvedTableConfig< TUserTypes extends UserTypesConfig["userTypes"], TEnumNames extends StringForUnion, TNamespace extends string = string, - TName extends string = string + TName extends string = string, > = { keySchema: ResolvedKeySchema; valueSchema: ResolvedValueSchema; @@ -38,34 +38,34 @@ type ResolvedTableConfig< type ResolvedKeySchema< TKeySchema extends TableConfig["keySchema"], TUserTypes extends UserTypesConfig["userTypes"], - TEnumNames extends StringForUnion + TEnumNames extends StringForUnion, > = ResolvedSchema; type ResolvedValueSchema< TValueSchema extends TableConfig["valueSchema"], TUserTypes extends UserTypesConfig["userTypes"], - TEnumNames extends StringForUnion + TEnumNames extends StringForUnion, > = ResolvedSchema, TUserTypes, TEnumNames>; type ResolvedSchema< TSchema extends Exclude, TUserTypes extends UserTypesConfig["userTypes"], - TEnumNames extends StringForUnion + TEnumNames extends StringForUnion, > = { [key in keyof TSchema]: { type: TSchema[key] extends SchemaAbiType ? TSchema[key] : TSchema[key] extends keyof TUserTypes - ? TUserTypes[TSchema[key]] extends UserType - ? // Note: we mistakenly named the plain ABI type "internalType", - // while in Solidity ABIs the plain ABI type is called "type" and - // and the custom type "internalType". We're planning to - // change our version and align with Solidity ABIs going forward. - TUserTypes[TSchema[key]]["internalType"] - : never - : TSchema[key] extends TEnumNames - ? "uint8" - : never; + ? TUserTypes[TSchema[key]] extends UserType + ? // Note: we mistakenly named the plain ABI type "internalType", + // while in Solidity ABIs the plain ABI type is called "type" and + // and the custom type "internalType". We're planning to + // change our version and align with Solidity ABIs going forward. + TUserTypes[TSchema[key]]["internalType"] + : never + : TSchema[key] extends TEnumNames + ? "uint8" + : never; internalType: TSchema[key]; }; }; @@ -75,7 +75,7 @@ type ResolvedSchema< * @deprecated Internal only */ export function resolveConfig( - config: TStoreConfig + config: TStoreConfig, ): ResolvedStoreConfig { const resolvedTables: Record> = {}; @@ -85,7 +85,7 @@ export function resolveConfig( config.userTypes, Object.keys(config.enums), config.namespace, - key + key, ) as ReturnType; } @@ -99,13 +99,13 @@ function resolveTable< TUserTypes extends UserTypesConfig["userTypes"], TEnums extends StringForUnion[], TNamespace extends string, - TName extends string + TName extends string, >( tableConfig: TTableConfig, userTypes: TUserTypes, enums: TEnums, namespace: TNamespace, - name: TName + name: TName, ): ResolvedTableConfig { const { keySchema, valueSchema } = tableConfig; @@ -125,11 +125,11 @@ function resolveTable< function resolveKeySchema< TKeySchema extends TableConfig["keySchema"], TUserTypes extends UserTypesConfig["userTypes"], - TEnums extends StringForUnion[] + TEnums extends StringForUnion[], >( keySchema: TKeySchema, userTypes: TUserTypes, - enums: TEnums + enums: TEnums, ): ResolvedKeySchema { const schema = ( keySchema == null ? { key: "bytes32" } : typeof keySchema === "string" ? { key: keySchema } : keySchema @@ -140,11 +140,11 @@ function resolveKeySchema< function resolveValueSchema< TValueSchema extends TableConfig["valueSchema"], TUserTypes extends UserTypesConfig["userTypes"], - TEnums extends StringForUnion[] + TEnums extends StringForUnion[], >( valueSchema: TValueSchema, userTypes: TUserTypes, - enums: TEnums + enums: TEnums, ): ResolvedValueSchema { const schema = ( typeof valueSchema === "string" ? ({ value: valueSchema } as unknown as TValueSchema) : valueSchema @@ -155,7 +155,7 @@ function resolveValueSchema< function resolveSchema< TSchema extends Exclude | TableConfig["valueSchema"], string>, TUserTypes extends UserTypesConfig["userTypes"], - TEnums extends StringForUnion[] + TEnums extends StringForUnion[], >(schema: TSchema, userTypes: TUserTypes, enums: TEnums): ResolvedSchema { return mapObject>(schema, (value, key) => { const isUserType = userTypes && value in userTypes; diff --git a/packages/store/ts/config/storeConfig.ts b/packages/store/ts/config/storeConfig.ts index 01c2b5e002..dc474f4f49 100644 --- a/packages/store/ts/config/storeConfig.ts +++ b/packages/store/ts/config/storeConfig.ts @@ -73,7 +73,7 @@ export const zSchemaConfig = zFullSchemaConfig.or(zShorthandSchemaConfig); type ResolvedSchema< TSchema extends Record, - TUserTypes extends Record> + TUserTypes extends Record>, > = { [key in keyof TSchema]: TSchema[key] extends keyof TUserTypes ? TUserTypes[TSchema[key]]["internalType"] @@ -84,7 +84,7 @@ type ResolvedSchema< // (see https://github.com/latticexyz/mud/pull/1588) export function resolveUserTypes< TSchema extends Record, - TUserTypes extends Record> + TUserTypes extends Record>, >(schema: TSchema, userTypes: TUserTypes): ResolvedSchema { const resolvedSchema: Record = {}; for (const [key, value] of Object.entries(schema)) { @@ -109,7 +109,7 @@ export function resolveUserTypes< export interface TableConfig< UserTypes extends StringForUnion = StringForUnion, - StaticUserTypes extends StringForUnion = StringForUnion + StaticUserTypes extends StringForUnion = StringForUnion, > { /** Output directory path for the file. Default is "tables" */ directory?: string; @@ -136,7 +136,7 @@ export interface TableConfig< export type FullTableConfig< UserTypes extends StringForUnion = StringForUnion, - StaticUserTypes extends StringForUnion = StringForUnion + StaticUserTypes extends StringForUnion = StringForUnion, > = Required> & { valueSchema: FullSchemaConfig; }; @@ -197,7 +197,7 @@ export const zTableConfig = zFullTableConfig.or(zShorthandTableConfig); export type TablesConfig< UserTypes extends StringForUnion = StringForUnion, - StaticUserTypes extends StringForUnion = StringForUnion + StaticUserTypes extends StringForUnion = StringForUnion, > = Record | FieldData>; export const zTablesConfig = z.record(zTableName, zTableConfig).transform((tables) => { @@ -213,17 +213,17 @@ export const zTablesConfig = z.record(zTableName, zTableConfig).transform((table export type FullTablesConfig< UserTypes extends StringForUnion = StringForUnion, - StaticUserTypes extends StringForUnion = StringForUnion + StaticUserTypes extends StringForUnion = StringForUnion, > = Record>; export type ExpandTablesConfig> = { [TableName in keyof T]: T[TableName] extends FieldData ? ExpandTableConfig<{ valueSchema: { value: T[TableName] } }, TableName extends string ? TableName : never> : T[TableName] extends TableConfig - ? ExpandTableConfig - : // Weakly typed values get a weakly typed expansion. - // This shouldn't normally happen within `mudConfig`, but can be manually triggered via `ExpandMUDUserConfig` - ExpandTableConfig, TableName extends string ? TableName : string>; + ? ExpandTableConfig + : // Weakly typed values get a weakly typed expansion. + // This shouldn't normally happen within `mudConfig`, but can be manually triggered via `ExpandMUDUserConfig` + ExpandTableConfig, TableName extends string ? TableName : string>; }; /************************************************************************ @@ -242,22 +242,22 @@ export type EnumsConfig = never extends EnumNa enums?: Record; } : StringForUnion extends EnumNames - ? { - /** - * Enum names mapped to lists of their member names - * - * (enums aren't inferred - use `mudConfig` or `storeConfig` helper, and `as const` for variables) - */ - enums?: Record; - } - : { - /** - * Enum names mapped to lists of their member names - * - * Enums defined here can be used as types in table schemas/keys - */ - enums: Record; - }; + ? { + /** + * Enum names mapped to lists of their member names + * + * (enums aren't inferred - use `mudConfig` or `storeConfig` helper, and `as const` for variables) + */ + enums?: Record; + } + : { + /** + * Enum names mapped to lists of their member names + * + * Enums defined here can be used as types in table schemas/keys + */ + enums: Record; + }; export type FullEnumsConfig = { enums: Record; @@ -285,26 +285,26 @@ export type UserTypesConfig; } : StringForUnion extends UserTypeNames - ? { - /** - * User types mapped to file paths from which to import them. - * Paths are treated as relative to root. - * Paths that don't start with a "." have foundry remappings applied to them first. - * - * (user types aren't inferred - use `mudConfig` or `storeConfig` helper, and `as const` for variables) - */ - userTypes?: Record; - } - : { - /** - * User types mapped to file paths from which to import them. - * Paths are treated as relative to root. - * Paths that don't start with a "." have foundry remappings applied to them first. - * - * User types defined here can be used as types in table schemas/keys - */ - userTypes: Record; - }; + ? { + /** + * User types mapped to file paths from which to import them. + * Paths are treated as relative to root. + * Paths that don't start with a "." have foundry remappings applied to them first. + * + * (user types aren't inferred - use `mudConfig` or `storeConfig` helper, and `as const` for variables) + */ + userTypes?: Record; + } + : { + /** + * User types mapped to file paths from which to import them. + * Paths are treated as relative to root. + * Paths that don't start with a "." have foundry remappings applied to them first. + * + * User types defined here can be used as types in table schemas/keys + */ + userTypes: Record; + }; const zUserTypeConfig = z.object({ filePath: z.string(), @@ -327,7 +327,7 @@ export type MUDUserConfig< T extends MUDCoreUserConfig = MUDCoreUserConfig, EnumNames extends StringForUnion = StringForUnion, UserTypeNames extends StringForUnion = StringForUnion, - StaticUserTypes extends ExtractUserTypes = ExtractUserTypes + StaticUserTypes extends ExtractUserTypes = ExtractUserTypes, > = T & EnumsConfig & UserTypesConfig & { @@ -404,7 +404,7 @@ function validateStoreConfig(config: z.output, ctx: ctx.addIssue({ code: ZodIssueCode.custom, message: `Table library names, enum names, user type names must be globally unique: ${duplicateGlobalNames.join( - ", " + ", ", )}`, }); } @@ -432,7 +432,7 @@ function validateAbiOrUserType( userTypeNames: string[], staticUserTypeNames: string[], type: string, - ctx: RefinementCtx + ctx: RefinementCtx, ) { if (!(AbiTypes as string[]).includes(type) && !userTypeNames.includes(type)) { const staticArray = parseStaticArray(type); @@ -460,7 +460,7 @@ function validateStaticArray( staticUserTypeNames: string[], elementType: string, staticLength: number, - ctx: RefinementCtx + ctx: RefinementCtx, ) { validateStaticAbiOrUserType(staticUserTypeNames, elementType, ctx); diff --git a/packages/store/ts/register/mudConfig.ts b/packages/store/ts/register/mudConfig.ts index 907ef5fb1c..4ac0be54d4 100644 --- a/packages/store/ts/register/mudConfig.ts +++ b/packages/store/ts/register/mudConfig.ts @@ -9,7 +9,7 @@ export function mudConfig< // (`never` is overridden by inference, so only the defined enums can be used by default) EnumNames extends StringForUnion = never, UserTypeNames extends StringForUnion = never, - StaticUserTypes extends ExtractUserTypes = ExtractUserTypes + StaticUserTypes extends ExtractUserTypes = ExtractUserTypes, >(config: MUDUserConfig): ExpandMUDUserConfig { // eslint-disable-next-line @typescript-eslint/no-explicit-any return mudCoreConfig(config) as any; diff --git a/packages/store/ts/scripts/generate-tightcoder.ts b/packages/store/ts/scripts/generate-tightcoder.ts index dd95ddb9bb..d4f0a56579 100644 --- a/packages/store/ts/scripts/generate-tightcoder.ts +++ b/packages/store/ts/scripts/generate-tightcoder.ts @@ -6,5 +6,5 @@ await formatAndWriteSolidity(renderEncodeArray(), "src/tightcoder/EncodeArray.so await formatAndWriteSolidity( renderTightCoderAutoTest(), "test/tightcoder/TightCoderAuto.t.sol", - "Generated TightCoderAutoTest" + "Generated TightCoderAutoTest", ); diff --git a/packages/store/ts/storeEvents.test.ts b/packages/store/ts/storeEvents.test.ts index b7361f5664..e4e7c06daf 100644 --- a/packages/store/ts/storeEvents.test.ts +++ b/packages/store/ts/storeEvents.test.ts @@ -20,7 +20,7 @@ describe("Store events", () => { for (const storeEvent of storeEvents) { const parsedStoreEvent = parseAbiItem(storeEvent); const abiItem = IStoreAbi.find( - (item) => item.type === parsedStoreEvent.type && item.name === parsedStoreEvent.name + (item) => item.type === parsedStoreEvent.type && item.name === parsedStoreEvent.name, ); expect(abiItem).not.toBeUndefined(); expect(normalizeAbiEvent(parsedStoreEvent)).toMatchObject(normalizeAbiEvent(abiItem as AbiEvent)); diff --git a/packages/utils/src/bytes.ts b/packages/utils/src/bytes.ts index c90728e7b9..659cda462f 100644 --- a/packages/utils/src/bytes.ts +++ b/packages/utils/src/bytes.ts @@ -20,7 +20,7 @@ export function concatUint8Arrays(...arrays: Uint8Array[]): Uint8Array { return Uint8Array.from( arrays.reduce((acc, curr) => { return [...acc, ...curr]; - }, []) + }, []), ); } diff --git a/packages/utils/src/cubic.ts b/packages/utils/src/cubic.ts index 611da1a9b5..bddb47e232 100644 --- a/packages/utils/src/cubic.ts +++ b/packages/utils/src/cubic.ts @@ -30,7 +30,7 @@ export function cubicNoiseConfig( octave: number, scale: number, periodX = Number.MAX_SAFE_INTEGER, - periodY = Number.MAX_SAFE_INTEGER + periodY = Number.MAX_SAFE_INTEGER, ) { return { seed: Math.floor(seed * Number.MAX_SAFE_INTEGER), @@ -59,7 +59,7 @@ export function cubicNoiseSample1(config: ReturnType, x randomize(config.seed, tile(xi + 2, config.periodX), 0), lerp, 1, - 1 + 1, ) * 0.666666 + 0.166666 @@ -76,7 +76,7 @@ export function cubicNoiseSample1(config: ReturnType, x export function cubicNoiseSample2( { octave, periodX, periodY, seed, scale }: ReturnType, x: number, - y: number + y: number, ) { const xi = Math.floor(x / octave); const lerpX = Math.floor((x * ACCURACY) / octave) - xi * ACCURACY; @@ -99,11 +99,11 @@ export function cubicNoiseSample2( randomize(seed, x3, y), lerpX, ACCURACY, - 1 + 1, ); } return Math.floor( - interpolate(xSamples[0], xSamples[1], xSamples[2], xSamples[3], lerpY, ACCURACY, scale) / Math.pow(ACCURACY, 6) + interpolate(xSamples[0], xSamples[1], xSamples[2], xSamples[3], lerpY, ACCURACY, scale) / Math.pow(ACCURACY, 6), ); } diff --git a/packages/utils/src/mobx.ts b/packages/utils/src/mobx.ts index 659c28fa54..40583c831c 100644 --- a/packages/utils/src/mobx.ts +++ b/packages/utils/src/mobx.ts @@ -15,7 +15,7 @@ export async function awaitValue(comp: IComputedValue | IObser resolve(value); } }, - { fireImmediately: true } + { fireImmediately: true }, ); const value = await promise; diff --git a/packages/utils/src/objects.ts b/packages/utils/src/objects.ts index fc491bb3c5..8b75d21d22 100644 --- a/packages/utils/src/objects.ts +++ b/packages/utils/src/objects.ts @@ -6,7 +6,7 @@ */ export function mapObject( source: S, - valueMap: (value: S[keyof S], key: keyof S) => T[keyof S] + valueMap: (value: S[keyof S], key: keyof S) => T[keyof S], ): T { const target: Partial<{ [key in keyof typeof source]: T[keyof S] }> = {}; for (const key in source) { diff --git a/packages/utils/src/promise.ts b/packages/utils/src/promise.ts index fcd11bd2a6..0af015a14b 100644 --- a/packages/utils/src/promise.ts +++ b/packages/utils/src/promise.ts @@ -20,7 +20,7 @@ export const callWithRetry = ( fn: (...args: any[]) => Promise, args: any[] = [], maxRetries = 10, - retryInterval = 1000 + retryInterval = 1000, ): Promise => { const [resolve, reject, promise] = deferred(); const process = async () => { diff --git a/packages/utils/src/proxy.ts b/packages/utils/src/proxy.ts index dc41151af6..85c599c21c 100644 --- a/packages/utils/src/proxy.ts +++ b/packages/utils/src/proxy.ts @@ -20,7 +20,7 @@ function deepAccess(target: Record, path: string[]): any { * @returns Cached */ export function cacheUntilReady>( - target: IObservableValue | IComputedValue + target: IObservableValue | IComputedValue, ): Cached { // The call queue contains the path and arguments of calls to the // proxiedTarget while the target was not available yet. @@ -71,7 +71,7 @@ export function cacheUntilReady>( return promise; } }, - } + }, ); reaction( @@ -94,7 +94,7 @@ export function cacheUntilReady>( resolve(target); } } - } + }, ); return proxiedTarget as Cached; diff --git a/packages/utils/src/rx.ts b/packages/utils/src/rx.ts index b18835a6b4..7a37b1f24a 100644 --- a/packages/utils/src/rx.ts +++ b/packages/utils/src/rx.ts @@ -19,7 +19,7 @@ import { awaitValue } from "./mobx"; export function filterNullish(): OperatorFunction> { return pipe, Observable>>( - filter((x: T) => x != null) as OperatorFunction> + filter((x: T) => x != null) as OperatorFunction>, ); } @@ -50,7 +50,7 @@ export function stretch(spacingDelayMs: number) { }; }, null), filterNullish(), - mergeMap((i) => of(i.value).pipe(delay(i.delay)), 1) + mergeMap((i) => of(i.value).pipe(delay(i.delay)), 1), ); } @@ -65,7 +65,7 @@ export function computedToStream(comp: IComputedValue | IObservableValue { if (value != null) stream.next(value); }, - { fireImmediately: true } + { fireImmediately: true }, ); return stream; } @@ -77,7 +77,7 @@ export function observableToStream(obs: T): Observable { (value) => { if (value != null) stream.next(value); }, - { fireImmediately: true } + { fireImmediately: true }, ); return stream; } @@ -104,7 +104,7 @@ export async function streamToDefinedComputed(stream$: Observable): Promis */ export async function awaitStreamValue( stream$: Observable, - predicate: (value: T) => boolean = (value) => value != null + predicate: (value: T) => boolean = (value) => value != null, ): Promise { const [resolve, , promise] = deferred(); stream$.pipe(first(predicate)).subscribe(resolve); diff --git a/packages/utils/src/types.ts b/packages/utils/src/types.ts index 1649769316..b9c1f99a4a 100644 --- a/packages/utils/src/types.ts +++ b/packages/utils/src/types.ts @@ -8,13 +8,13 @@ export type CachedValue = Proxied extends true ? V extends Func ? AsyncFunc : V extends Record - ? Cached & { proxied: true } - : { proxied: true } + ? Cached & { proxied: true } + : { proxied: true } : V extends Func - ? Func - : V extends Record - ? V - : V & { proxied: false }; + ? Func + : V extends Record + ? V + : V & { proxied: false }; export type Cached = | ({ proxied: false } & { [key in keyof C]: CachedValue }) diff --git a/packages/world-modules/src/interfaces/IBaseWorld.sol b/packages/world-modules/src/interfaces/IBaseWorld.sol index 4f1b8656d3..c71f2becc9 100644 --- a/packages/world-modules/src/interfaces/IBaseWorld.sol +++ b/packages/world-modules/src/interfaces/IBaseWorld.sol @@ -13,6 +13,4 @@ import { IWorldKernel } from "@latticexyz/world/src/IWorldKernel.sol"; * that are dynamically registered in the World during deployment. * @dev This is an autogenerated file; do not edit manually. */ -interface IBaseWorld is IStore, IWorldKernel { - -} +interface IBaseWorld is IStore, IWorldKernel {} diff --git a/packages/world/src/codegen/interfaces/IBaseWorld.sol b/packages/world/src/codegen/interfaces/IBaseWorld.sol index df94bca083..a30241297a 100644 --- a/packages/world/src/codegen/interfaces/IBaseWorld.sol +++ b/packages/world/src/codegen/interfaces/IBaseWorld.sol @@ -29,6 +29,4 @@ interface IBaseWorld is IModuleInstallationSystem, IWorldRegistrationSystem, IRegistrationSystem -{ - -} +{} diff --git a/packages/world/src/codegen/interfaces/IRegistrationSystem.sol b/packages/world/src/codegen/interfaces/IRegistrationSystem.sol index 75389f6bfb..d4dd6649d8 100644 --- a/packages/world/src/codegen/interfaces/IRegistrationSystem.sol +++ b/packages/world/src/codegen/interfaces/IRegistrationSystem.sol @@ -8,6 +8,4 @@ pragma solidity >=0.8.24; * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz) * @dev This interface is automatically generated from the corresponding system contract. Do not edit manually. */ -interface IRegistrationSystem { - -} +interface IRegistrationSystem {} diff --git a/packages/world/ts/config/resolveWorldConfig.ts b/packages/world/ts/config/resolveWorldConfig.ts index d2b3830d19..db54d6f0f5 100644 --- a/packages/world/ts/config/resolveWorldConfig.ts +++ b/packages/world/ts/config/resolveWorldConfig.ts @@ -28,7 +28,7 @@ export function resolveWorldConfig(config: StoreConfig & WorldConfig, existingCo // Combine the default and overridden system names and filter out excluded systems const systemNames = [...new Set([...defaultSystemNames, ...overriddenSystemNames])].filter( - (name) => !config.excludeSystems.includes(name) + (name) => !config.excludeSystems.includes(name), ); // Resolve the config diff --git a/packages/world/ts/config/types.ts b/packages/world/ts/config/types.ts index 5cb70b6910..3a590229f0 100644 --- a/packages/world/ts/config/types.ts +++ b/packages/world/ts/config/types.ts @@ -5,30 +5,29 @@ import { zWorldConfig } from "./worldConfig"; import { SYSTEM_DEFAULTS } from "./defaults"; // zod doesn't preserve doc comments -export type SystemUserConfig = +export type SystemUserConfig = { + /** The full resource selector consists of namespace and name */ + name?: string; + /** + * Register function selectors for the system in the World. + * Defaults to true. + * Note: + * - For root systems all World function selectors will correspond to the system's function selectors. + * - For non-root systems, the World function selectors will be __. + */ + registerFunctionSelectors?: boolean; +} & ( | { - /** The full resource selector consists of namespace and name */ - name?: string; - /** - * Register function selectors for the system in the World. - * Defaults to true. - * Note: - * - For root systems all World function selectors will correspond to the system's function selectors. - * - For non-root systems, the World function selectors will be __. - */ - registerFunctionSelectors?: boolean; - } & ( - | { - /** If openAccess is true, any address can call the system */ - openAccess?: true; - } - | { - /** If openAccess is false, only the addresses or systems in `access` can call the system */ - openAccess: false; - /** An array of addresses or system names that can access the system */ - accessList: string[]; - } - ); + /** If openAccess is true, any address can call the system */ + openAccess?: true; + } + | { + /** If openAccess is false, only the addresses or systems in `access` can call the system */ + openAccess: false; + /** An array of addresses or system names that can access the system */ + accessList: string[]; + } +); export interface ExpandSystemConfig extends OrDefaults< diff --git a/packages/world/ts/config/worldConfig.ts b/packages/world/ts/config/worldConfig.ts index ecd579ac7f..71d56c8de7 100644 --- a/packages/world/ts/config/worldConfig.ts +++ b/packages/world/ts/config/worldConfig.ts @@ -20,7 +20,7 @@ const zSystemConfig = z.intersection( openAccess: z.literal(false), accessList: zSystemAccessList, }), - ]) + ]), ); const zValueWithType = z.object({ diff --git a/packages/world/ts/encodeSystemCalls.ts b/packages/world/ts/encodeSystemCalls.ts index fe027924da..f93301da43 100644 --- a/packages/world/ts/encodeSystemCalls.ts +++ b/packages/world/ts/encodeSystemCalls.ts @@ -6,7 +6,7 @@ import type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from "abitype" /** Encode system calls to be passed as arguments into `World.batchCall` */ export function encodeSystemCalls>( abi: abi, - systemCalls: readonly Omit, "abi">[] + systemCalls: readonly Omit, "abi">[], ): AbiParametersToPrimitiveTypes["inputs"]>[] { return systemCalls.map((systemCall) => encodeSystemCall({ ...systemCall, abi } as SystemCall)); } diff --git a/packages/world/ts/encodeSystemCallsFrom.ts b/packages/world/ts/encodeSystemCallsFrom.ts index f5c9bf548e..0e0b40d0da 100644 --- a/packages/world/ts/encodeSystemCallsFrom.ts +++ b/packages/world/ts/encodeSystemCallsFrom.ts @@ -7,9 +7,9 @@ import type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from "abitype" export function encodeSystemCallsFrom>( abi: abi, from: Address, - systemCalls: readonly Omit, "abi" | "from">[] + systemCalls: readonly Omit, "abi" | "from">[], ): AbiParametersToPrimitiveTypes["inputs"]>[] { return systemCalls.map((systemCall) => - encodeSystemCallFrom({ ...systemCall, abi, from } as SystemCallFrom) + encodeSystemCallFrom({ ...systemCall, abi, from } as SystemCallFrom), ); } diff --git a/packages/world/ts/node/render-solidity/renderSystemInterface.ts b/packages/world/ts/node/render-solidity/renderSystemInterface.ts index 9f01bda718..ceb3be23da 100644 --- a/packages/world/ts/node/render-solidity/renderSystemInterface.ts +++ b/packages/world/ts/node/render-solidity/renderSystemInterface.ts @@ -23,7 +23,7 @@ export function renderSystemInterface(options: RenderSystemInterfaceOptions) { function ${functionPrefix}${name}( ${renderArguments(parameters)} ) external ${stateMutability} ${renderReturnParameters(returnParameters)}; - ` + `, )} } `; diff --git a/packages/world/ts/node/render-solidity/worldgen.ts b/packages/world/ts/node/render-solidity/worldgen.ts index f9dbf77d37..af5313ead3 100644 --- a/packages/world/ts/node/render-solidity/worldgen.ts +++ b/packages/world/ts/node/render-solidity/worldgen.ts @@ -10,11 +10,11 @@ import { WorldConfig } from "../../config/types"; export async function worldgen( config: StoreConfig & WorldConfig, existingContracts: { path: string; basename: string }[], - outputBaseDirectory: string + outputBaseDirectory: string, ) { const resolvedConfig = resolveWorldConfig( config, - existingContracts.map(({ basename }) => basename) + existingContracts.map(({ basename }) => basename), ); const worldgenBaseDirectory = path.join(outputBaseDirectory, config.worldgenDirectory); diff --git a/packages/world/ts/worldEvents.test.ts b/packages/world/ts/worldEvents.test.ts index 080a1740fa..477e61127e 100644 --- a/packages/world/ts/worldEvents.test.ts +++ b/packages/world/ts/worldEvents.test.ts @@ -19,7 +19,7 @@ function normalizeAbiEvent(event: AbiEvent) { describe("WorldFactory events", () => { it("should match the ABI", () => { const forgeAbiItem = IWorldFactoryAbi.find( - (item) => item.type === "event" && item.name === "WorldDeployed" + (item) => item.type === "event" && item.name === "WorldDeployed", ) as AbiEvent; expect(normalizeAbiEvent(parseAbiItem(worldDeployedEvent))).toMatchObject(normalizeAbiEvent(forgeAbiItem)); }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index aec60e2104..32fd2a7753 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -39,11 +39,11 @@ importers: specifier: '>=10' version: 10.0.0 prettier: - specifier: ^2.8.4 - version: 2.8.4 + specifier: 3.2.5 + version: 3.2.5 prettier-plugin-solidity: - specifier: 1.1.3 - version: 1.1.3(prettier@2.8.4) + specifier: 1.3.1 + version: 1.3.1(prettier@3.2.5) rimraf: specifier: ^3.0.2 version: 3.0.2 @@ -282,11 +282,11 @@ importers: specifier: ^5.1.2 version: 5.1.2 prettier: - specifier: ^2.8.4 - version: 2.8.4 + specifier: 3.2.5 + version: 3.2.5 prettier-plugin-solidity: - specifier: 1.1.3 - version: 1.1.3(prettier@2.8.4) + specifier: 1.3.1 + version: 1.3.1(prettier@3.2.5) viem: specifier: 2.7.12 version: 2.7.12(typescript@5.1.6)(zod@3.21.4) @@ -3095,6 +3095,10 @@ packages: resolution: {integrity: sha512-ESipEcHyRHg4Np4SqBCfcXwyxxna1DgFVz69bgpLV8vzl/NP1DtcKsJ4dJZXWQhY/Z4J2LeKBiOkOVZn9ct33Q==} dependencies: antlr4ts: 0.5.0-alpha.4 + dev: false + + /@solidity-parser/parser@0.17.0: + resolution: {integrity: sha512-Nko8R0/kUo391jsEHHxrGM07QFdnPGvlmox4rmH0kNiNAashItAilhy4Mv4pK5gQmW5f4sXAF58fwJbmlkGcVw==} /@testing-library/react-hooks@8.0.1(@types/react@18.2.22)(react-test-renderer@18.2.0)(react@18.2.0): resolution: {integrity: sha512-Aqhl2IVmLt8IovEVarNDFuJDVWVvhnr9/GCU6UUnrYXwgDFF9h2L2o2P9KBni1AST5sT6riAyoukFLyjQUgD/g==} @@ -3384,8 +3388,8 @@ packages: resolution: {integrity: sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==} dev: true - /@types/prettier@2.7.2: - resolution: {integrity: sha512-KufADq8uQqo1pYKVIYzfKbJfBAc0sOeXqGbFaSpv8MRmC/zXgowNZmFcbngndGk922QDmOASEXUZCaY48gs4cg==} + /@types/prettier@2.7.3: + resolution: {integrity: sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==} dev: true /@types/prop-types@15.7.5: @@ -7311,7 +7315,7 @@ packages: '@jest/transform': 29.5.0 '@jest/types': 29.5.0 '@types/babel__traverse': 7.18.3 - '@types/prettier': 2.7.2 + '@types/prettier': 2.7.3 babel-preset-current-node-syntax: 1.0.1(@babel/core@7.21.4) chalk: 4.1.2 expect: 29.5.0 @@ -8914,16 +8918,16 @@ packages: engines: {node: '>= 0.8.0'} dev: true - /prettier-plugin-solidity@1.1.3(prettier@2.8.4): - resolution: {integrity: sha512-fQ9yucPi2sBbA2U2Xjh6m4isUTJ7S7QLc/XDDsktqqxYfTwdYKJ0EnnywXHwCGAaYbQNK+HIYPL1OemxuMsgeg==} - engines: {node: '>=12'} + /prettier-plugin-solidity@1.3.1(prettier@3.2.5): + resolution: {integrity: sha512-MN4OP5I2gHAzHZG1wcuJl0FsLS3c4Cc5494bbg+6oQWBPuEamjwDvmGfFMZ6NFzsh3Efd9UUxeT7ImgjNH4ozA==} + engines: {node: '>=16'} peerDependencies: - prettier: '>=2.3.0 || >=3.0.0-alpha.0' + prettier: '>=2.3.0' dependencies: - '@solidity-parser/parser': 0.16.0 - prettier: 2.8.4 - semver: 7.5.0 - solidity-comments-extractor: 0.0.7 + '@solidity-parser/parser': 0.17.0 + prettier: 3.2.5 + semver: 7.6.0 + solidity-comments-extractor: 0.0.8 /prettier@1.19.1: resolution: {integrity: sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==} @@ -8937,6 +8941,12 @@ packages: resolution: {integrity: sha512-vIS4Rlc2FNh0BySk3Wkd6xmwxB0FpOndW5fisM5H8hsZSxU2VWVB5CWIkIjWvrHjIhxk2g3bfMKM87zNTrZddw==} engines: {node: '>=10.13.0'} hasBin: true + dev: true + + /prettier@3.2.5: + resolution: {integrity: sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==} + engines: {node: '>=14'} + hasBin: true /pretty-format@27.5.1: resolution: {integrity: sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==} @@ -9541,6 +9551,13 @@ packages: dependencies: lru-cache: 6.0.0 + /semver@7.6.0: + resolution: {integrity: sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==} + engines: {node: '>=10'} + hasBin: true + dependencies: + lru-cache: 6.0.0 + /set-blocking@2.0.0: resolution: {integrity: sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==} @@ -9697,8 +9714,8 @@ packages: - supports-color dev: true - /solidity-comments-extractor@0.0.7: - resolution: {integrity: sha512-wciNMLg/Irp8OKGrh3S2tfvZiZ0NEyILfcRCXCD4mp7SgK/i9gzLfhY2hY7VMCQJ3kH9UB9BzNdibIVMchzyYw==} + /solidity-comments-extractor@0.0.8: + resolution: {integrity: sha512-htM7Vn6LhHreR+EglVMd2s+sZhcXAirB1Zlyrv5zBuTxieCvjfnRpd7iZk75m/u6NOlEyQ94C6TWbBn2cY7w8g==} /sonic-boom@3.3.0: resolution: {integrity: sha512-LYxp34KlZ1a2Jb8ZQgFCK3niIHzibdwtwNUWKg0qQRzsDoJ3Gfgkf8KdBTFU3SkejDEIlWwnSnpVdOZIhFMl/g==} diff --git a/scripts/changelog.ts b/scripts/changelog.ts index 9daee85ea1..42e4c61049 100644 --- a/scripts/changelog.ts +++ b/scripts/changelog.ts @@ -116,7 +116,7 @@ async function getChanges(include: "diff" | "all") { const changeset = readFileSync(changesetPath).toString(); const gitLog = (await execa("git", ["log", changesetPath])).stdout; return { ...parseChangeset(changeset), ...parseGitLog(gitLog) }; - }) + }), ); // Sort the changesets into patch, minor and major updates diff --git a/scripts/render-api-docs.ts b/scripts/render-api-docs.ts index bf8d5b70e3..f0925af297 100644 --- a/scripts/render-api-docs.ts +++ b/scripts/render-api-docs.ts @@ -271,12 +271,12 @@ const PUBLIC_APIS: PublicApis = { content = addSampleCodeFunction( content, "grantAccess", - "/world/namespaces-access-control#modifying-access-control" + "/world/namespaces-access-control#modifying-access-control", ); content = addSampleCodeFunction( content, "revokeAccess", - "/world/namespaces-access-control#modifying-access-control" + "/world/namespaces-access-control#modifying-access-control", ); content = addSampleCodeFunction(content, "registerTable", "/store/tables#manually-register-a-table"); content = addSampleCodeFunction(content, "call", "/world/systems#using-call"); @@ -285,7 +285,7 @@ const PUBLIC_APIS: PublicApis = { content = addSampleCodeFunction( content, "registerRootFunctionSelector", - "/world/function-selectors#root-function-selectors" + "/world/function-selectors#root-function-selectors", ); content = addSampleCodeFunction(content, "transferBalanceToAddress", "/world/balance"); @@ -294,7 +294,7 @@ const PUBLIC_APIS: PublicApis = { .replaceAll("This is an autogenerated file; do not edit manually", "") .replaceAll( "*This interface is automatically generated from the corresponding system contract. Do not edit manually.*", - "" + "", ) .replace(/## StoreData((.|\n)*?)### Functions/m, "### Functions") .replace(/#### constructor((.|\n)*?)#### storeVersion/m, "#### storeVersion") @@ -393,7 +393,7 @@ const PUBLIC_APIS: PublicApis = { content = addSampleCodeFunction( content, "registerRootFunctionSelector", - "/world/function-selectors#root-function-selectors" + "/world/function-selectors#root-function-selectors", ); content = addSampleCodeFunction(content, "transferBalanceToAddress", "/world/balance"); @@ -484,9 +484,9 @@ function addSampleCodeContract(content: string, contract: string, url: string): .replace( ")", `) | - | - | - |` + | - | - |`, ) - .replace("[Git Source](", `| [Usage Sample](${url}) | [Git Source](`) + .replace("[Git Source](", `| [Usage Sample](${url}) | [Git Source](`), ); } @@ -497,8 +497,8 @@ function addSampleCodeFunction(content: string, heading: string, url: string): s "\n", ` [Usage Sample](${url}) - ` - ) + `, + ), ); } @@ -525,7 +525,7 @@ function getPackages() { Object.values(PUBLIC_APIS) .map(({ inputFiles }) => inputFiles) .flat() - .map((input) => input.source.split("/")[0]) + .map((input) => input.source.split("/")[0]), ), ]; } @@ -575,11 +575,11 @@ async function renderDocs() { .map((fileName) => readFileSync(path.join(docsPath, fileName), { encoding: "utf8" })); }) .flat() - .join("\n") + .join("\n"), ); // Write the output file - writeFileSync(path.join(DOCS_ROOT, outputFile), formatMarkdown(content)); + writeFileSync(path.join(DOCS_ROOT, outputFile), await formatMarkdown(content)); } } diff --git a/templates/phaser/package.json b/templates/phaser/package.json index bef09b4664..f50980f9a7 100644 --- a/templates/phaser/package.json +++ b/templates/phaser/package.json @@ -14,7 +14,6 @@ "devDependencies": { "@latticexyz/cli": "link:../../packages/cli", "@types/debug": "4.1.7", - "@types/prettier": "2.7.2", "@typescript-eslint/eslint-plugin": "5.46.1", "@typescript-eslint/parser": "5.46.1", "eslint": "8.29.0", diff --git a/templates/phaser/packages/client/src/mud/createSystemCalls.ts b/templates/phaser/packages/client/src/mud/createSystemCalls.ts index f3c72c4e9f..fef3e78936 100644 --- a/templates/phaser/packages/client/src/mud/createSystemCalls.ts +++ b/templates/phaser/packages/client/src/mud/createSystemCalls.ts @@ -37,7 +37,7 @@ export function createSystemCalls( * (https://github.com/latticexyz/mud/blob/main/templates/phaser/packages/client/src/mud/setupNetwork.ts#L75-L81). */ { worldContract, waitForTransaction }: SetupNetworkResult, - { Counter }: ClientComponents + { Counter }: ClientComponents, ) { const increment = async () => { /* diff --git a/templates/phaser/packages/client/src/ui/App.tsx b/templates/phaser/packages/client/src/ui/App.tsx index a61f2ba87e..7dd4d29641 100644 --- a/templates/phaser/packages/client/src/ui/App.tsx +++ b/templates/phaser/packages/client/src/ui/App.tsx @@ -26,7 +26,7 @@ export const App = () => { worldAbi: networkLayer.network.worldContract.abi, write$: networkLayer.network.write$, recsWorld: networkLayer.world, - }) + }), ); } }, [networkLayer]); diff --git a/templates/phaser/packages/client/src/ui/hooks/usePhaserLayer.tsx b/templates/phaser/packages/client/src/ui/hooks/usePhaserLayer.tsx index ff47610f2c..2d428b0c24 100644 --- a/templates/phaser/packages/client/src/ui/hooks/usePhaserLayer.tsx +++ b/templates/phaser/packages/client/src/ui/hooks/usePhaserLayer.tsx @@ -80,7 +80,7 @@ export const usePhaserLayer = ({ networkLayer }: Props) => { } } }, - [container] + [container], ); return useMemo(() => ({ ref, phaserLayer }), [ref, phaserLayer]); diff --git a/templates/phaser/packages/contracts/package.json b/templates/phaser/packages/contracts/package.json index aa7c055744..b2640d68cd 100644 --- a/templates/phaser/packages/contracts/package.json +++ b/templates/phaser/packages/contracts/package.json @@ -25,8 +25,8 @@ "@types/node": "^18.15.11", "ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0", "forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1", - "prettier": "^2.6.2", - "prettier-plugin-solidity": "1.1.3", + "prettier": "3.2.5", + "prettier-plugin-solidity": "1.3.1", "solhint": "^3.3.7", "solhint-config-mud": "file:../../../../packages/solhint-config-mud", "solhint-plugin-mud": "file:../../../../packages/solhint-plugin-mud" diff --git a/templates/phaser/packages/contracts/src/codegen/world/IWorld.sol b/templates/phaser/packages/contracts/src/codegen/world/IWorld.sol index 27ea70acda..34615b56ae 100644 --- a/templates/phaser/packages/contracts/src/codegen/world/IWorld.sol +++ b/templates/phaser/packages/contracts/src/codegen/world/IWorld.sol @@ -14,6 +14,4 @@ import { IIncrementSystem } from "./IIncrementSystem.sol"; * that are dynamically registered in the World during deployment. * @dev This is an autogenerated file; do not edit manually. */ -interface IWorld is IBaseWorld, IIncrementSystem { - -} +interface IWorld is IBaseWorld, IIncrementSystem {} diff --git a/templates/react-ecs/package.json b/templates/react-ecs/package.json index 80edea1359..58440578e0 100644 --- a/templates/react-ecs/package.json +++ b/templates/react-ecs/package.json @@ -14,7 +14,6 @@ "devDependencies": { "@latticexyz/cli": "link:../../packages/cli", "@types/debug": "4.1.7", - "@types/prettier": "2.7.2", "@typescript-eslint/eslint-plugin": "5.46.1", "@typescript-eslint/parser": "5.46.1", "eslint": "8.29.0", diff --git a/templates/react-ecs/packages/client/src/index.tsx b/templates/react-ecs/packages/client/src/index.tsx index da8d70f020..1b005dc561 100644 --- a/templates/react-ecs/packages/client/src/index.tsx +++ b/templates/react-ecs/packages/client/src/index.tsx @@ -13,7 +13,7 @@ setup().then(async (result) => { root.render( - + , ); // https://vitejs.dev/guide/env-and-mode.html diff --git a/templates/react-ecs/packages/client/src/mud/createSystemCalls.ts b/templates/react-ecs/packages/client/src/mud/createSystemCalls.ts index 09e7807c6f..30b4f7f6b7 100644 --- a/templates/react-ecs/packages/client/src/mud/createSystemCalls.ts +++ b/templates/react-ecs/packages/client/src/mud/createSystemCalls.ts @@ -31,7 +31,7 @@ export function createSystemCalls( * (https://github.com/latticexyz/mud/blob/main/templates/react/packages/client/src/mud/setupNetwork.ts#L77-L83). */ { worldContract, waitForTransaction }: SetupNetworkResult, - { Counter }: ClientComponents + { Counter }: ClientComponents, ) { const increment = async () => { /* diff --git a/templates/react-ecs/packages/contracts/package.json b/templates/react-ecs/packages/contracts/package.json index aa7c055744..b2640d68cd 100644 --- a/templates/react-ecs/packages/contracts/package.json +++ b/templates/react-ecs/packages/contracts/package.json @@ -25,8 +25,8 @@ "@types/node": "^18.15.11", "ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0", "forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1", - "prettier": "^2.6.2", - "prettier-plugin-solidity": "1.1.3", + "prettier": "3.2.5", + "prettier-plugin-solidity": "1.3.1", "solhint": "^3.3.7", "solhint-config-mud": "file:../../../../packages/solhint-config-mud", "solhint-plugin-mud": "file:../../../../packages/solhint-plugin-mud" diff --git a/templates/react-ecs/packages/contracts/src/codegen/world/IWorld.sol b/templates/react-ecs/packages/contracts/src/codegen/world/IWorld.sol index 27ea70acda..34615b56ae 100644 --- a/templates/react-ecs/packages/contracts/src/codegen/world/IWorld.sol +++ b/templates/react-ecs/packages/contracts/src/codegen/world/IWorld.sol @@ -14,6 +14,4 @@ import { IIncrementSystem } from "./IIncrementSystem.sol"; * that are dynamically registered in the World during deployment. * @dev This is an autogenerated file; do not edit manually. */ -interface IWorld is IBaseWorld, IIncrementSystem { - -} +interface IWorld is IBaseWorld, IIncrementSystem {} diff --git a/templates/react/package.json b/templates/react/package.json index 16893bf7de..9e94423c4d 100644 --- a/templates/react/package.json +++ b/templates/react/package.json @@ -14,7 +14,6 @@ "devDependencies": { "@latticexyz/cli": "link:../../packages/cli", "@types/debug": "4.1.7", - "@types/prettier": "2.7.2", "@typescript-eslint/eslint-plugin": "5.46.1", "@typescript-eslint/parser": "5.46.1", "eslint": "8.29.0", diff --git a/templates/react/packages/client/src/index.tsx b/templates/react/packages/client/src/index.tsx index 3ba2a44052..c9b662c9f0 100644 --- a/templates/react/packages/client/src/index.tsx +++ b/templates/react/packages/client/src/index.tsx @@ -13,7 +13,7 @@ setup().then(async (result) => { root.render( - + , ); // https://vitejs.dev/guide/env-and-mode.html diff --git a/templates/react/packages/client/src/mud/createSystemCalls.ts b/templates/react/packages/client/src/mud/createSystemCalls.ts index 7f9cb42e04..d7714ec453 100644 --- a/templates/react/packages/client/src/mud/createSystemCalls.ts +++ b/templates/react/packages/client/src/mud/createSystemCalls.ts @@ -28,7 +28,7 @@ export function createSystemCalls( * syncToRecs * (https://github.com/latticexyz/mud/blob/main/templates/react/packages/client/src/mud/setupNetwork.ts#L77-L83). */ - { tables, useStore, worldContract, waitForTransaction }: SetupNetworkResult + { tables, useStore, worldContract, waitForTransaction }: SetupNetworkResult, ) { const addTask = async (label: string) => { const tx = await worldContract.write.addTask([label]); diff --git a/templates/react/packages/contracts/package.json b/templates/react/packages/contracts/package.json index aa7c055744..b2640d68cd 100644 --- a/templates/react/packages/contracts/package.json +++ b/templates/react/packages/contracts/package.json @@ -25,8 +25,8 @@ "@types/node": "^18.15.11", "ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0", "forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1", - "prettier": "^2.6.2", - "prettier-plugin-solidity": "1.1.3", + "prettier": "3.2.5", + "prettier-plugin-solidity": "1.3.1", "solhint": "^3.3.7", "solhint-config-mud": "file:../../../../packages/solhint-config-mud", "solhint-plugin-mud": "file:../../../../packages/solhint-plugin-mud" diff --git a/templates/react/packages/contracts/src/codegen/world/IWorld.sol b/templates/react/packages/contracts/src/codegen/world/IWorld.sol index 227796ea2e..b3848a4577 100644 --- a/templates/react/packages/contracts/src/codegen/world/IWorld.sol +++ b/templates/react/packages/contracts/src/codegen/world/IWorld.sol @@ -14,6 +14,4 @@ import { ITasksSystem } from "./ITasksSystem.sol"; * that are dynamically registered in the World during deployment. * @dev This is an autogenerated file; do not edit manually. */ -interface IWorld is IBaseWorld, ITasksSystem { - -} +interface IWorld is IBaseWorld, ITasksSystem {} diff --git a/templates/threejs/package.json b/templates/threejs/package.json index 0faad70ae7..010dc5af8a 100644 --- a/templates/threejs/package.json +++ b/templates/threejs/package.json @@ -14,7 +14,6 @@ "devDependencies": { "@latticexyz/cli": "link:../../packages/cli", "@types/debug": "4.1.7", - "@types/prettier": "2.7.2", "@typescript-eslint/eslint-plugin": "5.46.1", "@typescript-eslint/parser": "5.46.1", "eslint": "8.29.0", diff --git a/templates/threejs/packages/client/src/index.tsx b/templates/threejs/packages/client/src/index.tsx index da8d70f020..1b005dc561 100644 --- a/templates/threejs/packages/client/src/index.tsx +++ b/templates/threejs/packages/client/src/index.tsx @@ -13,7 +13,7 @@ setup().then(async (result) => { root.render( - + , ); // https://vitejs.dev/guide/env-and-mode.html diff --git a/templates/threejs/packages/client/src/mud/createSystemCalls.ts b/templates/threejs/packages/client/src/mud/createSystemCalls.ts index 145e2ef1e5..d537c578fb 100644 --- a/templates/threejs/packages/client/src/mud/createSystemCalls.ts +++ b/templates/threejs/packages/client/src/mud/createSystemCalls.ts @@ -30,7 +30,7 @@ export function createSystemCalls( * (https://github.com/latticexyz/mud/blob/main/templates/threejs/packages/client/src/mud/setupNetwork.ts#L75-L81). */ { worldContract, waitForTransaction, playerEntity }: SetupNetworkResult, - { Position }: ClientComponents + { Position }: ClientComponents, ) { const moveTo = async (x: number, y: number, z: number) => { /* diff --git a/templates/threejs/packages/contracts/package.json b/templates/threejs/packages/contracts/package.json index eaf3a8b0b8..f5c5dc1be2 100644 --- a/templates/threejs/packages/contracts/package.json +++ b/templates/threejs/packages/contracts/package.json @@ -24,8 +24,8 @@ "@types/node": "^18.15.11", "ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0", "forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1", - "prettier": "^2.6.2", - "prettier-plugin-solidity": "1.1.3", + "prettier": "3.2.5", + "prettier-plugin-solidity": "1.3.1", "solhint": "^3.3.7", "solhint-config-mud": "file:../../../../packages/solhint-config-mud", "solhint-plugin-mud": "file:../../../../packages/solhint-plugin-mud" diff --git a/templates/threejs/packages/contracts/src/codegen/world/IWorld.sol b/templates/threejs/packages/contracts/src/codegen/world/IWorld.sol index 576ff1607e..d27f33eb9a 100644 --- a/templates/threejs/packages/contracts/src/codegen/world/IWorld.sol +++ b/templates/threejs/packages/contracts/src/codegen/world/IWorld.sol @@ -14,6 +14,4 @@ import { IMoveSystem } from "./IMoveSystem.sol"; * that are dynamically registered in the World during deployment. * @dev This is an autogenerated file; do not edit manually. */ -interface IWorld is IBaseWorld, IMoveSystem { - -} +interface IWorld is IBaseWorld, IMoveSystem {} diff --git a/templates/vanilla/package.json b/templates/vanilla/package.json index d3affb9b3e..6d8b2d9f34 100644 --- a/templates/vanilla/package.json +++ b/templates/vanilla/package.json @@ -14,7 +14,6 @@ "devDependencies": { "@latticexyz/cli": "link:../../packages/cli", "@types/debug": "4.1.7", - "@types/prettier": "2.7.2", "@typescript-eslint/eslint-plugin": "5.46.1", "@typescript-eslint/parser": "5.46.1", "eslint": "8.29.0", diff --git a/templates/vanilla/packages/client/src/mud/createSystemCalls.ts b/templates/vanilla/packages/client/src/mud/createSystemCalls.ts index ebff84233d..f153b51e86 100644 --- a/templates/vanilla/packages/client/src/mud/createSystemCalls.ts +++ b/templates/vanilla/packages/client/src/mud/createSystemCalls.ts @@ -31,7 +31,7 @@ export function createSystemCalls( * (https://github.com/latticexyz/mud/blob/main/templates/vanilla/packages/client/src/mud/setupNetwork.ts#L77-L83). */ { worldContract, waitForTransaction }: SetupNetworkResult, - { Counter }: ClientComponents + { Counter }: ClientComponents, ) { const increment = async () => { /* diff --git a/templates/vanilla/packages/contracts/package.json b/templates/vanilla/packages/contracts/package.json index aa7c055744..b2640d68cd 100644 --- a/templates/vanilla/packages/contracts/package.json +++ b/templates/vanilla/packages/contracts/package.json @@ -25,8 +25,8 @@ "@types/node": "^18.15.11", "ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0", "forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1", - "prettier": "^2.6.2", - "prettier-plugin-solidity": "1.1.3", + "prettier": "3.2.5", + "prettier-plugin-solidity": "1.3.1", "solhint": "^3.3.7", "solhint-config-mud": "file:../../../../packages/solhint-config-mud", "solhint-plugin-mud": "file:../../../../packages/solhint-plugin-mud" diff --git a/templates/vanilla/packages/contracts/src/codegen/world/IWorld.sol b/templates/vanilla/packages/contracts/src/codegen/world/IWorld.sol index 27ea70acda..34615b56ae 100644 --- a/templates/vanilla/packages/contracts/src/codegen/world/IWorld.sol +++ b/templates/vanilla/packages/contracts/src/codegen/world/IWorld.sol @@ -14,6 +14,4 @@ import { IIncrementSystem } from "./IIncrementSystem.sol"; * that are dynamically registered in the World during deployment. * @dev This is an autogenerated file; do not edit manually. */ -interface IWorld is IBaseWorld, IIncrementSystem { - -} +interface IWorld is IBaseWorld, IIncrementSystem {}