Skip to content

Commit

Permalink
clean up trace
Browse files Browse the repository at this point in the history
  • Loading branch information
alvrs committed Aug 16, 2023
1 parent b141c1f commit cb37445
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions packages/cli/src/commands/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -74,14 +76,9 @@ const commandModule: CommandModule<Options, Options> = {

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 });
}

Expand Down

0 comments on commit cb37445

Please sign in to comment.