Skip to content

Commit

Permalink
fix(cli): fix table IDs for module install (#1663)
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Sep 29, 2023
1 parent 82bb5b6 commit 87235a2
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 32 deletions.
5 changes: 5 additions & 0 deletions .changeset/cyan-timers-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/cli": patch
---

Fix table IDs for module install step of deploy
1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"path": "^0.12.7",
"throttle-debounce": "^5.0.0",
"typescript": "5.1.6",
"viem": "1.6.0",
"yargs": "^17.7.1",
"zod": "^3.21.4",
"zod-validation-error": "^1.3.0"
Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/utils/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { fastTxExecute } from "./utils/fastTxExecute";
import { getContractData } from "./utils/getContractData";
import { postDeploy } from "./utils/postDeploy";
import { setInternalFeePerGas } from "./utils/setInternalFeePerGas";
import { toBytes16 } from "./utils/toBytes16";
import { ContractCode } from "./utils/types";
import { resourceIdToHex } from "@latticexyz/common";

Expand Down
23 changes: 10 additions & 13 deletions packages/cli/src/utils/tables/getTableIds.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import { StoreConfig } from "@latticexyz/store";
import { TableIds } from "./types";
import { toBytes16 } from "../utils/toBytes16";
import { resourceIdToHex } from "@latticexyz/common";
import { hexToBytes } from "viem";

export function getTableIds(storeConfig: StoreConfig): TableIds {
const tableIds: TableIds = {};
for (const [tableName, { name }] of Object.entries(storeConfig.tables)) {
tableIds[tableName] = toResourceSelector(storeConfig.namespace, name);
for (const [tableName, { name, offchainOnly }] of Object.entries(storeConfig.tables)) {
tableIds[tableName] = hexToBytes(
resourceIdToHex({
type: offchainOnly ? "offchainTable" : "table",
namespace: storeConfig.namespace,
name,
})
);
}
return tableIds;
}

// (see https://github.com/latticexyz/mud/issues/499)
function toResourceSelector(namespace: string, file: string): Uint8Array {
const namespaceBytes = toBytes16(namespace);
const fileBytes = toBytes16(file);
const result = new Uint8Array(32);
result.set(namespaceBytes);
result.set(fileBytes, 16);
return result;
}
16 changes: 0 additions & 16 deletions packages/cli/src/utils/utils/toBytes16.ts

This file was deleted.

7 changes: 5 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 87235a2

Please sign in to comment.