From cb37445592eb9970a195ab3bdd111e27f2ed4915 Mon Sep 17 00:00:00 2001 From: alvrs Date: Wed, 16 Aug 2023 15:21:10 +0200 Subject: [PATCH] clean up trace --- packages/cli/src/commands/trace.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/packages/cli/src/commands/trace.ts b/packages/cli/src/commands/trace.ts index 026577c7d9..a0d8ab5e7b 100644 --- a/packages/cli/src/commands/trace.ts +++ b/packages/cli/src/commands/trace.ts @@ -5,15 +5,17 @@ import { ethers } from "ethers"; import { loadConfig } from "@latticexyz/config/node"; import { MUDError } from "@latticexyz/common/errors"; import { cast, getRpcUrl, getSrcDirectory } from "@latticexyz/common/foundry"; -import { TableId } from "@latticexyz/common/deprecated"; import { StoreConfig } from "@latticexyz/store"; import { resolveWorldConfig, WorldConfig } from "@latticexyz/world"; import { IBaseWorld } from "@latticexyz/world/types/ethers-contracts/IBaseWorld"; import IBaseWorldData from "@latticexyz/world/abi/IBaseWorld.sol/IBaseWorld.json" assert { type: "json" }; -import { getChainId, getExistingContracts } from "../utils"; +import worldConfig from "@latticexyz/world/mud.config"; import { schemaToHex } from "@latticexyz/protocol-parser"; +import { tableIdToHex } from "@latticexyz/common"; +import { getChainId, getExistingContracts } from "../utils"; -const systemsTableId = new TableId("", "Systems"); +// TODO account for multiple namespaces (https://github.com/latticexyz/mud/issues/994) +const systemsTableId = tableIdToHex(worldConfig.namespace, worldConfig.tables.Systems.name); const systemTableSchema = schemaToHex({ staticFields: ["address", "bool"], dynamicFields: [] }); type Options = { @@ -74,14 +76,9 @@ const commandModule: CommandModule = { const labels: { name: string; address: string }[] = []; for (const name of names) { - const systemSelector = new TableId(namespace, name); + const systemSelector = tableIdToHex(namespace, name); // Get the first field of `Systems` table (the table maps system name to its address and other data) - const address = await WorldContract.getField( - systemsTableId.toHex(), - [systemSelector.toHex()], - 0, - systemTableSchema - ); + const address = await WorldContract.getField(systemsTableId, [systemSelector], 0, systemTableSchema); labels.push({ name, address }); }