Skip to content

Commit 4565714

Browse files
vdrgfrolic
andauthored
fix(explorer): use table name helper from sqlite package (#3542)
Co-authored-by: Kevin Ingersoll <kingersoll@gmail.com>
1 parent dc0e85e commit 4565714

4 files changed

Lines changed: 8 additions & 6 deletions

File tree

.changeset/itchy-toys-smile.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@latticexyz/explorer": patch
3+
---
4+
5+
Fixed an issue with how MUD table names were translated SQLite table names when querying.

packages/explorer/src/app/(explorer)/utils/constructTableName.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Hex } from "viem";
22
import { Table } from "@latticexyz/config";
3-
import { snakeCase } from "../../../utils";
3+
import { getTableName } from "@latticexyz/store-sync/sqlite";
44
import { indexerForChainId } from "./indexerForChainId";
55

66
export function constructTableName(table: Table, worldAddress: Hex, chainId: number) {
@@ -9,7 +9,7 @@ export function constructTableName(table: Table, worldAddress: Hex, chainId: num
99
}
1010

1111
function constructSqliteTableName(table: Table, worldAddress: Hex) {
12-
return `${worldAddress}__${snakeCase(table.namespace)}__${snakeCase(table.name)}`;
12+
return getTableName(worldAddress, table.namespace, table.name);
1313
}
1414

1515
function constructDozerTableName(table: Table) {

packages/explorer/src/utils.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ export function cn(...inputs: ClassValue[]) {
66
return twMerge(clsx(inputs));
77
}
88

9-
export function snakeCase(str: string) {
10-
return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`).replace(/^_/, "");
11-
}
12-
139
export function formatBalance(wei: bigint) {
1410
const formatted = formatEther(wei);
1511
const magnitude = Math.floor(parseFloat(formatted)).toString().length;

packages/store-sync/src/sqlite/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from "./buildTable";
2+
export * from "./getTableName";
23
export * from "./getTables";
34
export * from "./internalTables";
45
export * from "./schemaVersion";

0 commit comments

Comments
 (0)