diff --git a/.changeset/blue-seals-relate.md b/.changeset/blue-seals-relate.md new file mode 100644 index 0000000000..84b94339ee --- /dev/null +++ b/.changeset/blue-seals-relate.md @@ -0,0 +1,5 @@ +--- +"@latticexyz/dev-tools": minor +--- + +Improved rendering of transactions that make calls via World's `call` and `callFrom` methods diff --git a/.changeset/thin-rice-trade.md b/.changeset/thin-rice-trade.md new file mode 100644 index 0000000000..13d4781cbe --- /dev/null +++ b/.changeset/thin-rice-trade.md @@ -0,0 +1,5 @@ +--- +"@latticexyz/store-indexer": patch +--- + +Added README and refactored handling of common environment variables diff --git a/.changeset/twelve-monkeys-juggle.md b/.changeset/twelve-monkeys-juggle.md new file mode 100644 index 0000000000..203bfe6c37 --- /dev/null +++ b/.changeset/twelve-monkeys-juggle.md @@ -0,0 +1,5 @@ +--- +"@latticexyz/faucet": patch +--- + +Added README diff --git a/examples/minimal/packages/client-phaser/package.json b/examples/minimal/packages/client-phaser/package.json index d3799d9672..d89bea645a 100644 --- a/examples/minimal/packages/client-phaser/package.json +++ b/examples/minimal/packages/client-phaser/package.json @@ -40,8 +40,8 @@ "zustand": "^4.3.8" }, "devDependencies": { - "@types/react": "^18.2.6", - "@types/react-dom": "^18.2.4", + "@types/react": "18.2.22", + "@types/react-dom": "18.2.7", "@types/styled-components": "^5.1.26", "@typescript-eslint/eslint-plugin": "^5.46.1", "@typescript-eslint/parser": "^5.46.1", diff --git a/examples/minimal/packages/client-react/package.json b/examples/minimal/packages/client-react/package.json index 0b69a60485..eb739ab293 100644 --- a/examples/minimal/packages/client-react/package.json +++ b/examples/minimal/packages/client-react/package.json @@ -35,8 +35,8 @@ "viem": "1.6.0" }, "devDependencies": { - "@types/react": "^18.2.6", - "@types/react-dom": "^18.2.4", + "@types/react": "18.2.22", + "@types/react-dom": "18.2.7", "@vitejs/plugin-react": "^3.1.0", "eslint-plugin-react": "7.31.11", "eslint-plugin-react-hooks": "4.6.0", diff --git a/examples/minimal/pnpm-lock.yaml b/examples/minimal/pnpm-lock.yaml index 7f09b57e02..f480d20160 100644 --- a/examples/minimal/pnpm-lock.yaml +++ b/examples/minimal/pnpm-lock.yaml @@ -112,11 +112,11 @@ importers: version: 4.3.8(react@18.2.0) devDependencies: '@types/react': - specifier: ^18.2.6 - version: 18.2.6 + specifier: 18.2.22 + version: 18.2.22 '@types/react-dom': - specifier: ^18.2.4 - version: 18.2.4 + specifier: 18.2.7 + version: 18.2.7 '@types/styled-components': specifier: ^5.1.26 version: 5.1.26 @@ -209,11 +209,11 @@ importers: version: 1.6.0(typescript@5.1.6) devDependencies: '@types/react': - specifier: ^18.2.6 - version: 18.2.6 + specifier: 18.2.22 + version: 18.2.22 '@types/react-dom': - specifier: ^18.2.4 - version: 18.2.4 + specifier: 18.2.7 + version: 18.2.7 '@vitejs/plugin-react': specifier: ^3.1.0 version: 3.1.0(vite@4.2.1) @@ -1072,7 +1072,7 @@ packages: /@types/hoist-non-react-statics@3.3.1: resolution: {integrity: sha512-iMIqiko6ooLrTh1joXodJK5X9xeEALT1kM5G3ZLhD3hszxBdIEd5C75U834D9mLcINgD4OyZf5uQXjkuYydWvA==} dependencies: - '@types/react': 18.2.6 + '@types/react': 18.2.22 hoist-non-react-statics: 3.3.2 dev: true @@ -1091,14 +1091,14 @@ packages: resolution: {integrity: sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==} dev: true - /@types/react-dom@18.2.4: - resolution: {integrity: sha512-G2mHoTMTL4yoydITgOGwWdWMVd8sNgyEP85xVmMKAPUBwQWm9wBPQUmvbeF4V3WBY1P7mmL4BkjQ0SqUpf1snw==} + /@types/react-dom@18.2.7: + resolution: {integrity: sha512-GRaAEriuT4zp9N4p1i8BDBYmEyfo+xQ3yHjJU4eiK5NDa1RmUZG+unZABUTK4/Ox/M+GaHwb6Ow8rUITrtjszA==} dependencies: - '@types/react': 18.2.6 + '@types/react': 18.2.22 dev: true - /@types/react@18.2.6: - resolution: {integrity: sha512-wRZClXn//zxCFW+ye/D2qY65UsYP1Fpex2YXorHc8awoNamkMZSvBxwxdYVInsHOZZd2Ppq8isnSzJL5Mpf8OA==} + /@types/react@18.2.22: + resolution: {integrity: sha512-60fLTOLqzarLED2O3UQImc/lsNRgG0jE/a1mPW9KjMemY0LMITWEsbS4VvZ4p6rorEHd5YKxxmMKSDK505GHpA==} dependencies: '@types/prop-types': 15.7.5 '@types/scheduler': 0.16.3 @@ -1117,7 +1117,7 @@ packages: resolution: {integrity: sha512-KuKJ9Z6xb93uJiIyxo/+ksS7yLjS1KzG6iv5i78dhVg/X3u5t1H7juRWqVmodIdz6wGVaIApo1u01kmFRdJHVw==} dependencies: '@types/hoist-non-react-statics': 3.3.1 - '@types/react': 18.2.6 + '@types/react': 18.2.22 csstype: 3.1.2 dev: true diff --git a/packages/cli/contracts/src/codegen/Tables.sol b/packages/cli/contracts/src/codegen/Tables.sol deleted file mode 100644 index de034e0789..0000000000 --- a/packages/cli/contracts/src/codegen/Tables.sol +++ /dev/null @@ -1,10 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; - -/* Autogenerated file. Do not edit manually. */ - -import { Statics, StaticsData, StaticsTableId } from "./tables/Statics.sol"; -import { Dynamics1, Dynamics1Data, Dynamics1TableId } from "./tables/Dynamics1.sol"; -import { Dynamics2, Dynamics2Data, Dynamics2TableId } from "./tables/Dynamics2.sol"; -import { Singleton, SingletonTableId } from "./tables/Singleton.sol"; -import { Ephemeral, EphemeralTableId } from "./tables/Ephemeral.sol"; diff --git a/packages/cli/contracts/src/codegen/Types.sol b/packages/cli/contracts/src/codegen/Types.sol deleted file mode 100644 index 85fa534462..0000000000 --- a/packages/cli/contracts/src/codegen/Types.sol +++ /dev/null @@ -1,13 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; - -/* Autogenerated file. Do not edit manually. */ -enum Enum1 { - E1, - E2, - E3 -} - -enum Enum2 { - E1 -} diff --git a/packages/dev-tools/package.json b/packages/dev-tools/package.json index c1af28ac22..26e18693d9 100644 --- a/packages/dev-tools/package.json +++ b/packages/dev-tools/package.json @@ -41,8 +41,8 @@ "zustand": "^4.3.7" }, "devDependencies": { - "@types/react": "^18.2.6", - "@types/react-dom": "^18.2.4", + "@types/react": "18.2.22", + "@types/react-dom": "18.2.7", "@types/ws": "^8.5.4", "autoprefixer": "^10.4.14", "postcss": "^8.4.23", diff --git a/packages/dev-tools/src/actions/WriteSummary.tsx b/packages/dev-tools/src/actions/WriteSummary.tsx index f7f4dca1a5..42aee498ec 100644 --- a/packages/dev-tools/src/actions/WriteSummary.tsx +++ b/packages/dev-tools/src/actions/WriteSummary.tsx @@ -1,4 +1,4 @@ -import { decodeEventLog, AbiEventSignatureNotFoundError } from "viem"; +import { decodeEventLog, AbiEventSignatureNotFoundError, decodeFunctionData, Hex } from "viem"; import { twMerge } from "tailwind-merge"; import { isDefined } from "@latticexyz/common/utils"; import { PendingIcon } from "../icons/PendingIcon"; @@ -56,6 +56,17 @@ export function WriteSummary({ write }: Props) { .filter(isDefined) : null; + let functionName = write.request.functionName; + let functionArgs = write.request.args; + if (functionName === "call" || functionName === "callFrom") { + const functionSelectorAndArgs: Hex = write.request?.args?.length + ? (write.request.args[write.request.args.length - 1] as Hex) + : `0x`; + const functionData = decodeFunctionData({ abi: worldAbi, data: functionSelectorAndArgs }); + functionName = functionData.functionName; + functionArgs = functionData.args; + } + return (
{ @@ -73,7 +84,10 @@ export function WriteSummary({ write }: Props) { )} >
- {write.request.functionName}({write.request.args?.map((value) => serialize(value)).join(", ")}) + {functionName}({functionArgs?.map((value) => serialize(value)).join(", ")}){" "} + {write.request.functionName !== functionName ? ( + via {write.request.functionName} + ) : null}
{transactionReceipt.status === "fulfilled" ? ( Object.values(values).some(isDefined)) +); + +export function parseEnv( + schema?: TSchema +): z.infer : typeof commonSchema> { + const envSchema = schema !== undefined ? z.intersection(commonSchema, schema) : commonSchema; + return envSchema.parse(process.env, { + errorMap: (issue) => ({ + message: `Missing or invalid environment variable: ${issue.path.join(".")}`, + }), + }); +} diff --git a/packages/store-indexer/bin/postgres-indexer.ts b/packages/store-indexer/bin/postgres-indexer.ts index b2b7068276..3a0428684a 100644 --- a/packages/store-indexer/bin/postgres-indexer.ts +++ b/packages/store-indexer/bin/postgres-indexer.ts @@ -13,30 +13,13 @@ import { drizzle } from "drizzle-orm/postgres-js"; import postgres from "postgres"; import { cleanDatabase, postgresStorage, schemaVersion } from "@latticexyz/store-sync/postgres"; import { createStoreSync } from "@latticexyz/store-sync"; +import { parseEnv } from "./parseEnv"; -const env = z - .intersection( - z.object({ - HOST: z.string().default("0.0.0.0"), - PORT: z.coerce.number().positive().default(3001), - DATABASE_URL: z.string(), - START_BLOCK: z.coerce.bigint().nonnegative().default(0n), - MAX_BLOCK_RANGE: z.coerce.bigint().positive().default(1000n), - POLLING_INTERVAL: z.coerce.number().positive().default(1000), - }), - z - .object({ - RPC_HTTP_URL: z.string(), - RPC_WS_URL: z.string(), - }) - .partial() - .refine((values) => Object.values(values).some(isDefined)) - ) - .parse(process.env, { - errorMap: (issue) => ({ - message: `Missing or invalid environment variable: ${issue.path.join(".")}`, - }), - }); +const env = parseEnv( + z.object({ + DATABASE_URL: z.string(), + }) +); const transports: Transport[] = [ // prefer WS when specified diff --git a/packages/store-indexer/bin/sqlite-indexer.ts b/packages/store-indexer/bin/sqlite-indexer.ts index 483dc9a823..afa4ab97bb 100644 --- a/packages/store-indexer/bin/sqlite-indexer.ts +++ b/packages/store-indexer/bin/sqlite-indexer.ts @@ -13,30 +13,13 @@ import { chainState, schemaVersion, syncToSqlite } from "@latticexyz/store-sync/ import { createQueryAdapter } from "../src/sqlite/createQueryAdapter"; import { isDefined } from "@latticexyz/common/utils"; import { combineLatest, filter, first } from "rxjs"; +import { parseEnv } from "./parseEnv"; -const env = z - .intersection( - z.object({ - HOST: z.string().default("0.0.0.0"), - PORT: z.coerce.number().positive().default(3001), - SQLITE_FILENAME: z.string().default("indexer.db"), - START_BLOCK: z.coerce.bigint().nonnegative().default(0n), - MAX_BLOCK_RANGE: z.coerce.bigint().positive().default(1000n), - POLLING_INTERVAL: z.coerce.number().positive().default(1000), - }), - z - .object({ - RPC_HTTP_URL: z.string(), - RPC_WS_URL: z.string(), - }) - .partial() - .refine((values) => Object.values(values).some(isDefined)) - ) - .parse(process.env, { - errorMap: (issue) => ({ - message: `Missing or invalid environment variable: ${issue.path.join(".")}`, - }), - }); +const env = parseEnv( + z.object({ + SQLITE_FILENAME: z.string().default("indexer.db"), + }) +); const transports: Transport[] = [ // prefer WS when specified diff --git a/packages/store/src/Types.sol b/packages/store/src/Types.sol deleted file mode 100644 index 5dc3f4b242..0000000000 --- a/packages/store/src/Types.sol +++ /dev/null @@ -1,7 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; - -enum ExecutionMode { - Delegate, - Autonomous -} diff --git a/packages/world/gas-report.json b/packages/world/gas-report.json index 493ad867bf..c021f1084d 100644 --- a/packages/world/gas-report.json +++ b/packages/world/gas-report.json @@ -39,13 +39,13 @@ "file": "test/KeysInTableModule.t.sol", "test": "testInstallComposite", "name": "install keys in table module", - "gasUsed": 1413542 + "gasUsed": 1413512 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallGas", "name": "install keys in table module", - "gasUsed": 1413542 + "gasUsed": 1413512 }, { "file": "test/KeysInTableModule.t.sol", @@ -57,13 +57,13 @@ "file": "test/KeysInTableModule.t.sol", "test": "testInstallSingleton", "name": "install keys in table module", - "gasUsed": 1413542 + "gasUsed": 1413512 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "install keys in table module", - "gasUsed": 1413542 + "gasUsed": 1413512 }, { "file": "test/KeysInTableModule.t.sol", @@ -81,7 +81,7 @@ "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "install keys in table module", - "gasUsed": 1413542 + "gasUsed": 1413512 }, { "file": "test/KeysInTableModule.t.sol", @@ -99,7 +99,7 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testGetKeysWithValueGas", "name": "install keys with value module", - "gasUsed": 652831 + "gasUsed": 652783 }, { "file": "test/KeysWithValueModule.t.sol", @@ -117,7 +117,7 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "install keys with value module", - "gasUsed": 652831 + "gasUsed": 652783 }, { "file": "test/KeysWithValueModule.t.sol", @@ -129,7 +129,7 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "install keys with value module", - "gasUsed": 652831 + "gasUsed": 652783 }, { "file": "test/KeysWithValueModule.t.sol", @@ -147,7 +147,7 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "install keys with value module", - "gasUsed": 652831 + "gasUsed": 652783 }, { "file": "test/KeysWithValueModule.t.sol", @@ -231,31 +231,31 @@ "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromCallboundDelegation", "name": "register a callbound delegation", - "gasUsed": 113987 + "gasUsed": 113954 }, { "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromCallboundDelegation", "name": "call a system via a callbound delegation", - "gasUsed": 33547 + "gasUsed": 33517 }, { "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromTimeboundDelegation", "name": "register a timebound delegation", - "gasUsed": 108424 + "gasUsed": 108418 }, { "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromTimeboundDelegation", "name": "call a system via a timebound delegation", - "gasUsed": 26672 + "gasUsed": 26642 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstall", "name": "install unique entity module", - "gasUsed": 679050 + "gasUsed": 678987 }, { "file": "test/UniqueEntityModule.t.sol", @@ -267,7 +267,7 @@ "file": "test/UniqueEntityModule.t.sol", "test": "testInstallRoot", "name": "installRoot unique entity module", - "gasUsed": 669120 + "gasUsed": 669072 }, { "file": "test/UniqueEntityModule.t.sol", @@ -339,7 +339,7 @@ "file": "test/World.t.sol", "test": "testRegisterTable", "name": "Register a new table in the namespace", - "gasUsed": 641714 + "gasUsed": 641696 }, { "file": "test/World.t.sol", diff --git a/packages/world/src/Delegation.sol b/packages/world/src/Delegation.sol index 8a4a0b9b8e..14855a1ae0 100644 --- a/packages/world/src/Delegation.sol +++ b/packages/world/src/Delegation.sol @@ -44,7 +44,7 @@ library DelegationInstance { (bool success, bytes memory data) = SystemCall.call({ caller: delegatee, resourceSelector: Delegation.unwrap(self), - callData: abi.encodeWithSelector(IDelegationControl.verify.selector, delegator, systemId, callData), + callData: abi.encodeCall(IDelegationControl.verify, (delegator, systemId, callData)), value: 0 }); diff --git a/packages/world/src/Tables.sol b/packages/world/src/Tables.sol deleted file mode 100644 index 021a7371bf..0000000000 --- a/packages/world/src/Tables.sol +++ /dev/null @@ -1,23 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; - -/* Autogenerated file. Do not edit manually. */ - -import { NamespaceOwner, NamespaceOwnerTableId } from "./tables/NamespaceOwner.sol"; -import { ResourceAccess, ResourceAccessTableId } from "./tables/ResourceAccess.sol"; -import { InstalledModules, InstalledModulesTableId } from "./tables/InstalledModules.sol"; -import { Delegations, DelegationsTableId } from "./tables/Delegations.sol"; -import { Balances, BalancesTableId } from "./modules/core/tables/Balances.sol"; -import { Systems, SystemsTableId } from "./modules/core/tables/Systems.sol"; -import { SystemRegistry, SystemRegistryTableId } from "./modules/core/tables/SystemRegistry.sol"; -import { SystemHooks, SystemHooksTableId } from "./modules/core/tables/SystemHooks.sol"; -import { ResourceType, ResourceTypeTableId } from "./modules/core/tables/ResourceType.sol"; -import { FunctionSelectors, FunctionSelectorsTableId } from "./modules/core/tables/FunctionSelectors.sol"; -import { KeysWithValue } from "./modules/keyswithvalue/tables/KeysWithValue.sol"; -import { KeysInTable, KeysInTableData, KeysInTableTableId } from "./modules/keysintable/tables/KeysInTable.sol"; -import { UsedKeysIndex, UsedKeysIndexTableId } from "./modules/keysintable/tables/UsedKeysIndex.sol"; -import { UniqueEntity } from "./modules/uniqueentity/tables/UniqueEntity.sol"; -import { CallboundDelegations, CallboundDelegationsTableId } from "./modules/std-delegations/tables/CallboundDelegations.sol"; -import { TimeboundDelegations, TimeboundDelegationsTableId } from "./modules/std-delegations/tables/TimeboundDelegations.sol"; -import { Bool } from "./../test/tables/Bool.sol"; -import { AddressArray } from "./../test/tables/AddressArray.sol"; diff --git a/packages/world/src/Types.sol b/packages/world/src/Types.sol deleted file mode 100644 index 6c4b0ff193..0000000000 --- a/packages/world/src/Types.sol +++ /dev/null @@ -1,10 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; - -/* Autogenerated file. Do not edit manually. */ -enum Resource { - NONE, - NAMESPACE, - TABLE, - SYSTEM -} diff --git a/packages/world/src/Utils.sol b/packages/world/src/Utils.sol index dd5a4138dc..b54e5d7653 100644 --- a/packages/world/src/Utils.sol +++ b/packages/world/src/Utils.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.0; import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; import { ResourceSelector } from "./ResourceSelector.sol"; -import { SystemRegistry } from "./Tables.sol"; +import { SystemRegistry } from "./index.sol"; library Utils { /** diff --git a/packages/world/src/World.sol b/packages/world/src/World.sol index 87d0d38056..73464c011b 100644 --- a/packages/world/src/World.sol +++ b/packages/world/src/World.sol @@ -85,7 +85,7 @@ contract World is StoreRead, IStoreData, IWorldKernel { msgSender: msg.sender, msgValue: 0, target: address(module), - callData: abi.encodeWithSelector(IModule.installRoot.selector, args) + callData: abi.encodeCall(IModule.installRoot, (args)) }); // Register the module in the InstalledModules table diff --git a/packages/world/src/interfaces/IDelegationControl.sol b/packages/world/src/interfaces/IDelegationControl.sol index 3f77f24632..6f68af9b32 100644 --- a/packages/world/src/interfaces/IDelegationControl.sol +++ b/packages/world/src/interfaces/IDelegationControl.sol @@ -8,5 +8,5 @@ bytes4 constant DELEGATION_CONTROL_INTERFACE_ID = IDelegationControl.verify.sele WORLD_CONTEXT_CONSUMER_INTERFACE_ID; interface IDelegationControl is IWorldContextConsumer { - function verify(address delegator, bytes32 systemId, bytes calldata callData) external returns (bool); + function verify(address delegator, bytes32 systemId, bytes memory callData) external returns (bool); } diff --git a/packages/world/src/modules/core/implementations/ModuleInstallationSystem.sol b/packages/world/src/modules/core/implementations/ModuleInstallationSystem.sol index 527cf62eba..dfa2fa6fa4 100644 --- a/packages/world/src/modules/core/implementations/ModuleInstallationSystem.sol +++ b/packages/world/src/modules/core/implementations/ModuleInstallationSystem.sol @@ -24,7 +24,7 @@ contract ModuleInstallationSystem is System { msgSender: _msgSender(), msgValue: 0, target: address(module), - callData: abi.encodeWithSelector(IModule.install.selector, args) + callData: abi.encodeCall(IModule.install, (args)) }); // Register the module in the InstalledModules table diff --git a/packages/world/src/modules/core/implementations/StoreRegistrationSystem.sol b/packages/world/src/modules/core/implementations/StoreRegistrationSystem.sol index f51e198b4a..f79d328b9c 100644 --- a/packages/world/src/modules/core/implementations/StoreRegistrationSystem.sol +++ b/packages/world/src/modules/core/implementations/StoreRegistrationSystem.sol @@ -57,7 +57,7 @@ contract StoreRegistrationSystem is System, IWorldErrors { msgSender: _msgSender(), msgValue: 0, target: systemAddress, - callData: abi.encodeWithSelector(WorldRegistrationSystem.registerNamespace.selector, namespace) + callData: abi.encodeCall(WorldRegistrationSystem.registerNamespace, (namespace)) }); } else { // otherwise require caller to own the namespace diff --git a/packages/world/test/StandardDelegationsModule.t.sol b/packages/world/test/StandardDelegationsModule.t.sol index 72b83642d8..28006e43c4 100644 --- a/packages/world/test/StandardDelegationsModule.t.sol +++ b/packages/world/test/StandardDelegationsModule.t.sol @@ -42,12 +42,9 @@ contract StandardDelegationsModuleTest is Test, GasReporter { world.registerDelegation( delegatee, CALLBOUND_DELEGATION, - abi.encodeWithSelector( - CallboundDelegationControl.initDelegation.selector, - delegatee, - systemResourceSelector, - abi.encodeWithSelector(WorldTestSystem.msgSender.selector), - 1 + abi.encodeCall( + CallboundDelegationControl.initDelegation, + (delegatee, systemResourceSelector, abi.encodeCall(WorldTestSystem.msgSender, ()), 1) ) ); endGasReport(); @@ -58,7 +55,7 @@ contract StandardDelegationsModuleTest is Test, GasReporter { bytes memory returnData = world.callFrom( delegator, systemResourceSelector, - abi.encodeWithSelector(WorldTestSystem.msgSender.selector) + abi.encodeCall(WorldTestSystem.msgSender, ()) ); endGasReport(); address returnedAddress = abi.decode(returnData, (address)); @@ -69,7 +66,7 @@ contract StandardDelegationsModuleTest is Test, GasReporter { // Expect the delegation to have been used up vm.prank(delegatee); vm.expectRevert(abi.encodeWithSelector(IWorldErrors.DelegationNotFound.selector, delegator, delegatee)); - world.callFrom(delegator, systemResourceSelector, abi.encodeWithSelector(WorldTestSystem.msgSender.selector)); + world.callFrom(delegator, systemResourceSelector, abi.encodeCall(WorldTestSystem.msgSender, ())); } function testCallFromTimeboundDelegation() public { @@ -84,7 +81,7 @@ contract StandardDelegationsModuleTest is Test, GasReporter { world.registerDelegation( delegatee, TIMEBOUND_DELEGATION, - abi.encodeWithSelector(TimeboundDelegationControl.initDelegation.selector, delegatee, maxTimestamp) + abi.encodeCall(TimeboundDelegationControl.initDelegation, (delegatee, maxTimestamp)) ); endGasReport(); @@ -94,7 +91,7 @@ contract StandardDelegationsModuleTest is Test, GasReporter { bytes memory returnData = world.callFrom( delegator, systemResourceSelector, - abi.encodeWithSelector(WorldTestSystem.msgSender.selector) + abi.encodeCall(WorldTestSystem.msgSender, ()) ); endGasReport(); address returnedAddress = abi.decode(returnData, (address)); @@ -105,13 +102,13 @@ contract StandardDelegationsModuleTest is Test, GasReporter { // Set the timestamp to maxTimestamp and expect the delegation to still be valid vm.warp(maxTimestamp); vm.prank(delegatee); - world.callFrom(delegator, systemResourceSelector, abi.encodeWithSelector(WorldTestSystem.msgSender.selector)); + world.callFrom(delegator, systemResourceSelector, abi.encodeCall(WorldTestSystem.msgSender, ())); // Set the timestamp to maxTimestamp+1 and expect the delegation to be expired vm.warp(maxTimestamp + 1); vm.prank(delegatee); vm.expectRevert(abi.encodeWithSelector(IWorldErrors.DelegationNotFound.selector, delegator, delegatee)); - world.callFrom(delegator, systemResourceSelector, abi.encodeWithSelector(WorldTestSystem.msgSender.selector)); + world.callFrom(delegator, systemResourceSelector, abi.encodeCall(WorldTestSystem.msgSender, ())); } function testRegisterDelegationRevertInterfaceNotSupported() public { diff --git a/packages/world/test/Utils.t.sol b/packages/world/test/Utils.t.sol index de0acda0d0..d3def80af0 100644 --- a/packages/world/test/Utils.t.sol +++ b/packages/world/test/Utils.t.sol @@ -35,7 +35,7 @@ contract UtilsTest is Test { bytes memory data = world.call( ResourceSelector.from(namespace, name), - abi.encodeWithSelector(UtilsTestSystem.systemNamespace.selector) + abi.encodeCall(UtilsTestSystem.systemNamespace, ()) ); returnedNamespace = abi.decode(data, (bytes16)); } diff --git a/packages/world/test/World.t.sol b/packages/world/test/World.t.sol index d9d076bbd4..9194959b2d 100644 --- a/packages/world/test/World.t.sol +++ b/packages/world/test/World.t.sol @@ -276,10 +276,7 @@ contract WorldTest is Test, GasReporter { bytes32 resourceSelector = ResourceSelector.from("namespace", "testSystem"); world.registerSystem(resourceSelector, system, false); - bytes memory result = world.call( - resourceSelector, - abi.encodeWithSelector(WorldTestSystem.getStoreAddress.selector) - ); + bytes memory result = world.call(resourceSelector, abi.encodeCall(WorldTestSystem.getStoreAddress, ())); assertEq(abi.decode(result, (address)), address(world)); } @@ -684,17 +681,14 @@ contract WorldTest is Test, GasReporter { // Call a system function without arguments via the World startGasReport("call a system via the World"); - bytes memory result = world.call(resourceSelector, abi.encodeWithSelector(WorldTestSystem.msgSender.selector)); + bytes memory result = world.call(resourceSelector, abi.encodeCall(WorldTestSystem.msgSender, ())); endGasReport(); // Expect the system to have received the caller's address assertEq(address(uint160(uint256(bytes32(result)))), address(this)); // Call a system function with arguments via the World - result = world.call( - resourceSelector, - abi.encodeWithSelector(WorldTestSystem.echo.selector, bytes32(uint256(0x123))) - ); + result = world.call(resourceSelector, abi.encodeCall(WorldTestSystem.echo, (bytes32(uint256(0x123))))); // Expect the return data to be decodeable as a tuple (address returnedAddress, bytes32 returnedBytes32) = abi.decode(result, (address, bytes32)); @@ -708,15 +702,15 @@ contract WorldTest is Test, GasReporter { // Expect an error when trying to call a private system from an address that doesn't have access _expectAccessDenied(address(0x01), "namespace", "testSystem"); - world.call(resourceSelector, abi.encodeWithSelector(WorldTestSystem.msgSender.selector)); + world.call(resourceSelector, abi.encodeCall(WorldTestSystem.msgSender, ())); // Expect the World to have access vm.prank(address(world)); - world.call(resourceSelector, abi.encodeWithSelector(WorldTestSystem.msgSender.selector)); + world.call(resourceSelector, abi.encodeCall(WorldTestSystem.msgSender, ())); // Expect errors from the system to be forwarded vm.expectRevert(abi.encodeWithSelector(WorldTestSystem.WorldTestSystemError.selector, "test error")); - world.call(resourceSelector, abi.encodeWithSelector(WorldTestSystem.err.selector, "test error")); + world.call(resourceSelector, abi.encodeCall(WorldTestSystem.err, ("test error"))); // Register another system in the same namespace WorldTestSystem subSystem = new WorldTestSystem(); @@ -725,7 +719,7 @@ contract WorldTest is Test, GasReporter { // Call the subsystem via the World (with access to the base route) returnedAddress = abi.decode( - world.call(subsystemResourceSelector, abi.encodeWithSelector(WorldTestSystem.msgSender.selector)), + world.call(subsystemResourceSelector, abi.encodeCall(WorldTestSystem.msgSender, ())), (address) ); assertEq(returnedAddress, address(this)); @@ -734,14 +728,16 @@ contract WorldTest is Test, GasReporter { // (Note: just for testing purposes, in reality systems can call subsystems directly instead of via two indirections like here) bytes memory nestedReturndata = world.call( resourceSelector, - abi.encodeWithSelector( - WorldTestSystem.delegateCallSubSystem.selector, // Function in system - address(subSystem), // Address of subsystem - WorldContextProvider.appendContext({ - callData: abi.encodeWithSelector(WorldTestSystem.msgSender.selector), - msgSender: address(this), - msgValue: uint256(0) - }) + abi.encodeCall( + WorldTestSystem.delegateCallSubSystem, // Function in system + ( + address(subSystem), // Address of subsystem + WorldContextProvider.appendContext({ + callData: abi.encodeCall(WorldTestSystem.msgSender, ()), + msgSender: address(this), + msgValue: uint256(0) + }) + ) ) ); @@ -759,11 +755,7 @@ contract WorldTest is Test, GasReporter { // Call a system via callFrom with the own address vm.prank(caller); - bytes memory returnData = world.callFrom( - caller, - resourceSelector, - abi.encodeWithSelector(WorldTestSystem.msgSender.selector) - ); + bytes memory returnData = world.callFrom(caller, resourceSelector, abi.encodeCall(WorldTestSystem.msgSender, ())); address returnedAddress = abi.decode(returnData, (address)); // Expect the system to have received the delegator's address @@ -790,7 +782,7 @@ contract WorldTest is Test, GasReporter { bytes memory returnData = world.callFrom( delegator, resourceSelector, - abi.encodeWithSelector(WorldTestSystem.msgSender.selector) + abi.encodeCall(WorldTestSystem.msgSender, ()) ); endGasReport(); address returnedAddress = abi.decode(returnData, (address)); @@ -814,7 +806,7 @@ contract WorldTest is Test, GasReporter { ) ); vm.prank(address(1)); - world.callFrom(address(2), resourceSelector, abi.encodeWithSelector(WorldTestSystem.msgSender.selector)); + world.callFrom(address(2), resourceSelector, abi.encodeCall(WorldTestSystem.msgSender, ())); } function testCallFromLimitedDelegation() public { @@ -1079,7 +1071,7 @@ contract WorldTest is Test, GasReporter { // Call a system function that writes data to the World world.call( rootSystemId, - abi.encodeWithSelector(WorldTestSystem.writeData.selector, bytes16("namespace"), bytes16("testTable"), true) + abi.encodeCall(WorldTestSystem.writeData, (bytes16("namespace"), bytes16("testTable"), true)) ); // Expect the data to be written @@ -1104,10 +1096,7 @@ contract WorldTest is Test, GasReporter { world.registerSystem(systemId, system, false); // Call a system function that writes data to the World - world.call( - systemId, - abi.encodeWithSelector(WorldTestSystem.writeData.selector, bytes16("namespace"), bytes16("testTable"), true) - ); + world.call(systemId, abi.encodeCall(WorldTestSystem.writeData, (bytes16("namespace"), bytes16("testTable"), true))); // Expect the data to be written assertTrue(Bool.get(world, tableId)); @@ -1122,7 +1111,7 @@ contract WorldTest is Test, GasReporter { // Call the root sysyem vm.expectEmit(true, true, true, true); emit WorldTestSystemLog("delegatecall"); - world.call(resourceSelector, abi.encodeWithSelector(WorldTestSystem.emitCallType.selector)); + world.call(resourceSelector, abi.encodeCall(WorldTestSystem.emitCallType, ())); } function testCallAutonomousSystem() public { @@ -1134,7 +1123,7 @@ contract WorldTest is Test, GasReporter { // Call the sysyem vm.expectEmit(true, true, true, true); emit WorldTestSystemLog("call"); - world.call(resourceSelector, abi.encodeWithSelector(WorldTestSystem.emitCallType.selector)); + world.call(resourceSelector, abi.encodeCall(WorldTestSystem.emitCallType, ())); } function testRegisterFunctionSelector() public { @@ -1291,9 +1280,7 @@ contract WorldTest is Test, GasReporter { assertEq(address(system).balance, 0); // Send 0.5 eth to the system's receiveEther function via the World - (bool success, ) = address(world).call{ value: 0.5 ether }( - abi.encodeWithSelector(WorldTestSystem.receiveEther.selector) - ); + (bool success, ) = address(world).call{ value: 0.5 ether }(abi.encodeCall(WorldTestSystem.receiveEther, ())); assertTrue(success, "transfer should succeed"); assertEq(alice.balance, 0.5 ether, "alice should have 0.5 ether"); assertEq(address(world).balance, 0.5 ether, "world should have 0.5 ether"); @@ -1323,9 +1310,7 @@ contract WorldTest is Test, GasReporter { assertEq(address(system).balance, 0); // Send 0.5 eth to the system's msgSender function (non-payable) via the World - (bool success, ) = address(world).call{ value: 0.5 ether }( - abi.encodeWithSelector(WorldTestSystem.msgSender.selector) - ); + (bool success, ) = address(world).call{ value: 0.5 ether }(abi.encodeCall(WorldTestSystem.msgSender, ())); // The call should succeed because the value is not forwarded to the system assertTrue(success, "transfer should succeed"); assertEq(alice.balance, 0.5 ether, "alice should have 0.5 ether"); @@ -1416,9 +1401,7 @@ contract WorldTest is Test, GasReporter { assertEq(address(system).balance, 0); // Send 0.5 eth to the system's receiveEther function via the World - (bool success, ) = address(world).call{ value: 0.5 ether }( - abi.encodeWithSelector(WorldTestSystem.receiveEther.selector) - ); + (bool success, ) = address(world).call{ value: 0.5 ether }(abi.encodeCall(WorldTestSystem.receiveEther, ())); assertTrue(success, "transfer should succeed"); assertEq(alice.balance, 0.5 ether, "alice should have 0.5 ether"); assertEq(address(world).balance, 0.5 ether, "world should have 0.5 ether"); diff --git a/packages/world/test/WorldContext.t.sol b/packages/world/test/WorldContext.t.sol index 174c90bfd3..a264b510b0 100644 --- a/packages/world/test/WorldContext.t.sol +++ b/packages/world/test/WorldContext.t.sol @@ -34,7 +34,7 @@ contract WorldContextTest is Test, GasReporter { msgSender: msgSender, msgValue: msgValue, target: address(consumer), - callData: abi.encodeWithSelector(TestContextConsumer.emitContext.selector, args) + callData: abi.encodeCall(TestContextConsumer.emitContext, (args)) }); } @@ -47,7 +47,7 @@ contract WorldContextTest is Test, GasReporter { msgSender: msgSender, msgValue: msgValue, target: address(consumer), - callData: abi.encodeWithSelector(TestContextConsumer.emitContext.selector, args) + callData: abi.encodeCall(TestContextConsumer.emitContext, (args)) }); } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 077747e8e9..bbdbb441ca 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -379,11 +379,11 @@ importers: version: 4.3.7(react@18.2.0) devDependencies: '@types/react': - specifier: ^18.2.6 - version: 18.2.6 + specifier: 18.2.22 + version: 18.2.22 '@types/react-dom': - specifier: ^18.2.4 - version: 18.2.4 + specifier: 18.2.7 + version: 18.2.7 '@types/ws': specifier: ^8.5.4 version: 8.5.4 @@ -600,10 +600,10 @@ importers: devDependencies: '@testing-library/react-hooks': specifier: ^8.0.1 - version: 8.0.1(@types/react@18.2.6)(react-test-renderer@18.2.0)(react@18.2.0) + version: 8.0.1(@types/react@18.2.22)(react-test-renderer@18.2.0)(react@18.2.0) '@types/react': - specifier: ^18.2.6 - version: 18.2.6 + specifier: 18.2.22 + version: 18.2.22 '@vitejs/plugin-react': specifier: ^4.0.0 version: 4.0.0(vite@4.3.6) @@ -3029,7 +3029,7 @@ packages: antlr4ts: 0.5.0-alpha.4 dev: false - /@testing-library/react-hooks@8.0.1(@types/react@18.2.6)(react-test-renderer@18.2.0)(react@18.2.0): + /@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==} engines: {node: '>=12'} peerDependencies: @@ -3046,7 +3046,7 @@ packages: optional: true dependencies: '@babel/runtime': 7.21.0 - '@types/react': 18.2.6 + '@types/react': 18.2.22 react: 18.2.0 react-error-boundary: 3.1.4(react@18.2.0) react-test-renderer: 18.2.0(react@18.2.0) @@ -3282,14 +3282,14 @@ packages: resolution: {integrity: sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==} dev: true - /@types/react-dom@18.2.4: - resolution: {integrity: sha512-G2mHoTMTL4yoydITgOGwWdWMVd8sNgyEP85xVmMKAPUBwQWm9wBPQUmvbeF4V3WBY1P7mmL4BkjQ0SqUpf1snw==} + /@types/react-dom@18.2.7: + resolution: {integrity: sha512-GRaAEriuT4zp9N4p1i8BDBYmEyfo+xQ3yHjJU4eiK5NDa1RmUZG+unZABUTK4/Ox/M+GaHwb6Ow8rUITrtjszA==} dependencies: - '@types/react': 18.2.6 + '@types/react': 18.2.22 dev: true - /@types/react@18.2.6: - resolution: {integrity: sha512-wRZClXn//zxCFW+ye/D2qY65UsYP1Fpex2YXorHc8awoNamkMZSvBxwxdYVInsHOZZd2Ppq8isnSzJL5Mpf8OA==} + /@types/react@18.2.22: + resolution: {integrity: sha512-60fLTOLqzarLED2O3UQImc/lsNRgG0jE/a1mPW9KjMemY0LMITWEsbS4VvZ4p6rorEHd5YKxxmMKSDK505GHpA==} dependencies: '@types/prop-types': 15.7.5 '@types/scheduler': 0.16.3 diff --git a/templates/phaser/packages/client/package.json b/templates/phaser/packages/client/package.json index 9bc539ac0f..4692415744 100644 --- a/templates/phaser/packages/client/package.json +++ b/templates/phaser/packages/client/package.json @@ -34,8 +34,8 @@ }, "devDependencies": { "@types/lodash": "^4.14.194", - "@types/react": "^18.2.6", - "@types/react-dom": "^18.2.4", + "@types/react": "18.2.22", + "@types/react-dom": "18.2.7", "@types/styled-components": "^5.1.26", "@vitejs/plugin-react": "^3.1.0", "eslint-plugin-react": "7.31.11", diff --git a/templates/react/packages/client/package.json b/templates/react/packages/client/package.json index 7328d90df6..1855fbf09e 100644 --- a/templates/react/packages/client/package.json +++ b/templates/react/packages/client/package.json @@ -27,8 +27,8 @@ "viem": "1.6.0" }, "devDependencies": { - "@types/react": "^18.2.6", - "@types/react-dom": "^18.2.4", + "@types/react": "18.2.22", + "@types/react-dom": "18.2.7", "@vitejs/plugin-react": "^3.1.0", "eslint-plugin-react": "7.31.11", "eslint-plugin-react-hooks": "4.6.0", diff --git a/templates/threejs/packages/client/package.json b/templates/threejs/packages/client/package.json index 030dce939d..ee97435dd0 100644 --- a/templates/threejs/packages/client/package.json +++ b/templates/threejs/packages/client/package.json @@ -28,8 +28,8 @@ "viem": "1.6.0" }, "devDependencies": { - "@types/react": "^18.2.6", - "@types/react-dom": "^18.2.4", + "@types/react": "18.2.22", + "@types/react-dom": "18.2.7", "@vitejs/plugin-react": "^3.1.0", "eslint-plugin-react": "7.31.11", "eslint-plugin-react-hooks": "4.6.0",